@learncard/vpqr-plugin 1.1.24 → 1.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- "use strict";var Po=Object.create;var he=Object.defineProperty;var zo=Object.getOwnPropertyDescriptor;var jo=Object.getOwnPropertyNames;var Vo=Object.getPrototypeOf,Ho=Object.prototype.hasOwnProperty;var s=(t,e)=>he(t,"name",{value:e,configurable:!0});var Ko=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},Wo=(t,e)=>{for(var r in e)he(t,r,{get:e[r],enumerable:!0})},Nr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of jo(e))!Ho.call(t,o)&&o!==r&&he(t,o,{get:()=>e[o],enumerable:!(n=zo(e,o))||n.enumerable});return t};var Qo=(t,e,r)=>(r=t!=null?Po(Vo(t)):{},Nr(e||!t||!t.__esModule?he(r,"default",{value:t,enumerable:!0}):r,t)),Xo=t=>Nr(he({},"__esModule",{value:!0}),t);var wo=Ko((ku,yo)=>{"use strict";var Gi="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",Zi="0123456789ABCDEFGHIJKLMNOPQRSTUV",Ji="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function Yi(t,e){var r=t.indexOf(e);if(r===-1)throw new Error("Invalid character found: "+e);return r}s(Yi,"readChar");yo.exports=s(function(e,r){var n;switch(r){case"RFC3548":case"RFC4648":n=Gi,e=e.replace(/=+$/,"");break;case"RFC4648-HEX":n=Zi,e=e.replace(/=+$/,"");break;case"Crockford":n=Ji,e=e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1");break;default:throw new Error("Unknown base32 variant: "+r)}for(var o=e.length,i=0,c=0,f=0,u=new Uint8Array(o*5/8|0),d=0;d<o;d++)c=c<<5|Yi(n,e[d]),i+=5,i>=8&&(u[f++]=c>>>i-8&255,i-=8);return u.buffer},"base32Decode")});var xs={};Wo(xs,{getVpqrPlugin:()=>ms});module.exports=Xo(xs);var Go=["string","number","bigint","symbol"],Zo=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Lr(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(Go.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(Jo(t))return"Buffer";let r=Yo(t);return r||"Object"}s(Lr,"is");function Jo(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}s(Jo,"isBuffer");function Yo(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(Zo.includes(e))return e}s(Yo,"getObjectType");var Pt=class Pt{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};s(Pt,"Type");var a=Pt;a.uint=new a(0,"uint",!0);a.negint=new a(1,"negint",!0);a.bytes=new a(2,"bytes",!0);a.string=new a(3,"string",!0);a.array=new a(4,"array",!1);a.map=new a(5,"map",!1);a.tag=new a(6,"tag",!1);a.float=new a(7,"float",!0);a.false=new a(7,"false",!0);a.true=new a(7,"true",!0);a.null=new a(7,"null",!0);a.undefined=new a(7,"undefined",!0);a.break=new a(7,"break",!0);var zt=class zt{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};s(zt,"Token");var l=zt;var re=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",qo=new TextDecoder,ei=new TextEncoder;function ze(t){return re&&globalThis.Buffer.isBuffer(t)}s(ze,"isBuffer");function jt(t){return t instanceof Uint8Array?ze(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}s(jt,"asU8A");var zr=re?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):$r(t,e,r):(t,e,r)=>r-e>64?qo.decode(t.subarray(e,r)):$r(t,e,r),jr=re?t=>t.length>64?globalThis.Buffer.from(t):Fr(t):t=>t.length>64?ei.encode(t):Fr(t),z=s(t=>Uint8Array.from(t),"fromArray"),ne=re?(t,e,r)=>ze(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),Vr=re?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),jt(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let o of t)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Hr=re?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function je(t,e){if(ze(t)&&ze(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}s(je,"compare");function Fr(t){let e=[],r=0;for(let n=0;n<t.length;n++){let o=t.charCodeAt(n);o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(t.charCodeAt(++n)&1023),e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128)}return e}s(Fr,"utf8ToBytes");function $r(t,e,r){let n=[];for(;e<r;){let o=t[e],i=null,c=o>239?4:o>223?3:o>191?2:1;if(e+c<=r){let f,u,d,h;switch(c){case 1:o<128&&(i=o);break;case 2:f=t[e+1],(f&192)===128&&(h=(o&31)<<6|f&63,h>127&&(i=h));break;case 3:f=t[e+1],u=t[e+2],(f&192)===128&&(u&192)===128&&(h=(o&15)<<12|(f&63)<<6|u&63,h>2047&&(h<55296||h>57343)&&(i=h));break;case 4:f=t[e+1],u=t[e+2],d=t[e+3],(f&192)===128&&(u&192)===128&&(d&192)===128&&(h=(o&15)<<18|(f&63)<<12|(u&63)<<6|d&63,h>65535&&h<1114112&&(i=h))}}i===null?(i=65533,c=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),e+=c}return ti(n)}s($r,"utf8Slice");var Pr=4096;function ti(t){let e=t.length;if(e<=Pr)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Pr));return r}s(ti,"decodeCodePointsArray");var ri=256,Vt=class Vt{constructor(e=ri){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(e,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(r=Hr(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=ne(n,0,this.cursor)}else r=Vr(this.chunks,this.cursor);return e&&this.reset(),r}};s(Vt,"Bl");var me=Vt;var m="CBOR decode error:",Ht="CBOR encode error:",xe=[];xe[23]=1;xe[24]=2;xe[25]=3;xe[26]=5;xe[27]=9;function j(t,e,r){if(t.length-e<r)throw new Error(`${m} not enough data for type`)}s(j,"assertEnoughData");var B=[24,256,65536,4294967296,BigInt("18446744073709551616")];function S(t,e,r){j(t,e,1);let n=t[e];if(r.strict===!0&&n<B[0])throw new Error(`${m} integer encoded in more bytes than necessary (strict decode)`);return n}s(S,"readUint8");function I(t,e,r){j(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<B[1])throw new Error(`${m} integer encoded in more bytes than necessary (strict decode)`);return n}s(I,"readUint16");function M(t,e,r){j(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<B[2])throw new Error(`${m} integer encoded in more bytes than necessary (strict decode)`);return n}s(M,"readUint32");function R(t,e,r){j(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],o=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<B[3])throw new Error(`${m} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${m} integers outside of the safe integer range are not supported`)}s(R,"readUint64");function Kr(t,e,r,n){return new l(a.uint,S(t,e+1,n),2)}s(Kr,"decodeUint8");function Wr(t,e,r,n){return new l(a.uint,I(t,e+1,n),3)}s(Wr,"decodeUint16");function Qr(t,e,r,n){return new l(a.uint,M(t,e+1,n),5)}s(Qr,"decodeUint32");function Xr(t,e,r,n){return new l(a.uint,R(t,e+1,n),9)}s(Xr,"decodeUint64");function v(t,e){return _(t,0,e.value)}s(v,"encodeUint");function _(t,e,r){if(r<B[0]){let n=Number(r);t.push([e|n])}else if(r<B[1]){let n=Number(r);t.push([e|24,n])}else if(r<B[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<B[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<B[4]){let o=[e|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),c=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=c&255,c=c>>8,o[3]=c&255,c=c>>8,o[2]=c&255,c=c>>8,o[1]=c&255,t.push(o)}else throw new Error(`${m} encountered BigInt larger than allowable range`)}}s(_,"encodeUintValue");v.encodedSize=s(function(e){return _.encodedSize(e.value)},"encodedSize");_.encodedSize=s(function(e){return e<B[0]?1:e<B[1]?2:e<B[2]?3:e<B[3]?5:9},"encodedSize");v.compareTokens=s(function(e,r){return e.value<r.value?-1:e.value>r.value?1:0},"compareTokens");function Gr(t,e,r,n){return new l(a.negint,-1-S(t,e+1,n),2)}s(Gr,"decodeNegint8");function Zr(t,e,r,n){return new l(a.negint,-1-I(t,e+1,n),3)}s(Zr,"decodeNegint16");function Jr(t,e,r,n){return new l(a.negint,-1-M(t,e+1,n),5)}s(Jr,"decodeNegint32");var Kt=BigInt(-1),Yr=BigInt(1);function qr(t,e,r,n){let o=R(t,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new l(a.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${m} integers outside of the safe integer range are not supported`);return new l(a.negint,Kt-BigInt(o),9)}s(qr,"decodeNegint64");function Ve(t,e){let r=e.value,n=typeof r=="bigint"?r*Kt-Yr:r*-1-1;_(t,e.type.majorEncoded,n)}s(Ve,"encodeNegint");Ve.encodedSize=s(function(e){let r=e.value,n=typeof r=="bigint"?r*Kt-Yr:r*-1-1;return n<B[0]?1:n<B[1]?2:n<B[2]?3:n<B[3]?5:9},"encodedSize");Ve.compareTokens=s(function(e,r){return e.value<r.value?1:e.value>r.value?-1:0},"compareTokens");function ge(t,e,r,n){j(t,e,r+n);let o=ne(t,e+r,e+r+n);return new l(a.bytes,o,r+n)}s(ge,"toToken");function en(t,e,r,n){return ge(t,e,1,r)}s(en,"decodeBytesCompact");function tn(t,e,r,n){return ge(t,e,2,S(t,e+1,n))}s(tn,"decodeBytes8");function rn(t,e,r,n){return ge(t,e,3,I(t,e+1,n))}s(rn,"decodeBytes16");function nn(t,e,r,n){return ge(t,e,5,M(t,e+1,n))}s(nn,"decodeBytes32");function on(t,e,r,n){let o=R(t,e+1,n);if(typeof o=="bigint")throw new Error(`${m} 64-bit integer bytes lengths not supported`);return ge(t,e,9,o)}s(on,"decodeBytes64");function He(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===a.string?jr(t.value):t.value),t.encodedBytes}s(He,"tokenBytes");function oe(t,e){let r=He(e);_(t,e.type.majorEncoded,r.length),t.push(r)}s(oe,"encodeBytes");oe.encodedSize=s(function(e){let r=He(e);return _.encodedSize(r.length)+r.length},"encodedSize");oe.compareTokens=s(function(e,r){return oi(He(e),He(r))},"compareTokens");function oi(t,e){return t.length<e.length?-1:t.length>e.length?1:je(t,e)}s(oi,"compareBytes");function ye(t,e,r,n,o){let i=r+n;j(t,e,i);let c=new l(a.string,zr(t,e+r,e+i),i);return o.retainStringBytes===!0&&(c.byteValue=ne(t,e+r,e+i)),c}s(ye,"toToken");function sn(t,e,r,n){return ye(t,e,1,r,n)}s(sn,"decodeStringCompact");function cn(t,e,r,n){return ye(t,e,2,S(t,e+1,n),n)}s(cn,"decodeString8");function an(t,e,r,n){return ye(t,e,3,I(t,e+1,n),n)}s(an,"decodeString16");function fn(t,e,r,n){return ye(t,e,5,M(t,e+1,n),n)}s(fn,"decodeString32");function un(t,e,r,n){let o=R(t,e+1,n);if(typeof o=="bigint")throw new Error(`${m} 64-bit integer string lengths not supported`);return ye(t,e,9,o,n)}s(un,"decodeString64");var dn=oe;function ie(t,e,r,n){return new l(a.array,n,r)}s(ie,"toToken");function ln(t,e,r,n){return ie(t,e,1,r)}s(ln,"decodeArrayCompact");function pn(t,e,r,n){return ie(t,e,2,S(t,e+1,n))}s(pn,"decodeArray8");function hn(t,e,r,n){return ie(t,e,3,I(t,e+1,n))}s(hn,"decodeArray16");function mn(t,e,r,n){return ie(t,e,5,M(t,e+1,n))}s(mn,"decodeArray32");function xn(t,e,r,n){let o=R(t,e+1,n);if(typeof o=="bigint")throw new Error(`${m} 64-bit integer array lengths not supported`);return ie(t,e,9,o)}s(xn,"decodeArray64");function gn(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${m} indefinite length items not allowed`);return ie(t,e,1,1/0)}s(gn,"decodeArrayIndefinite");function Ke(t,e){_(t,a.array.majorEncoded,e.value)}s(Ke,"encodeArray");Ke.compareTokens=v.compareTokens;Ke.encodedSize=s(function(e){return _.encodedSize(e.value)},"encodedSize");function se(t,e,r,n){return new l(a.map,n,r)}s(se,"toToken");function yn(t,e,r,n){return se(t,e,1,r)}s(yn,"decodeMapCompact");function wn(t,e,r,n){return se(t,e,2,S(t,e+1,n))}s(wn,"decodeMap8");function bn(t,e,r,n){return se(t,e,3,I(t,e+1,n))}s(bn,"decodeMap16");function En(t,e,r,n){return se(t,e,5,M(t,e+1,n))}s(En,"decodeMap32");function Cn(t,e,r,n){let o=R(t,e+1,n);if(typeof o=="bigint")throw new Error(`${m} 64-bit integer map lengths not supported`);return se(t,e,9,o)}s(Cn,"decodeMap64");function Tn(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${m} indefinite length items not allowed`);return se(t,e,1,1/0)}s(Tn,"decodeMapIndefinite");function We(t,e){_(t,a.map.majorEncoded,e.value)}s(We,"encodeMap");We.compareTokens=v.compareTokens;We.encodedSize=s(function(e){return _.encodedSize(e.value)},"encodedSize");function An(t,e,r,n){return new l(a.tag,r,1)}s(An,"decodeTagCompact");function Bn(t,e,r,n){return new l(a.tag,S(t,e+1,n),2)}s(Bn,"decodeTag8");function _n(t,e,r,n){return new l(a.tag,I(t,e+1,n),3)}s(_n,"decodeTag16");function kn(t,e,r,n){return new l(a.tag,M(t,e+1,n),5)}s(kn,"decodeTag32");function Dn(t,e,r,n){return new l(a.tag,R(t,e+1,n),9)}s(Dn,"decodeTag64");function Qe(t,e){_(t,a.tag.majorEncoded,e.value)}s(Qe,"encodeTag");Qe.compareTokens=v.compareTokens;Qe.encodedSize=s(function(e){return _.encodedSize(e.value)},"encodedSize");var ui=20,di=21,li=22,pi=23;function Un(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${m} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new l(a.null,null,1):new l(a.undefined,void 0,1)}s(Un,"decodeUndefined");function Sn(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${m} indefinite length items not allowed`);return new l(a.break,void 0,1)}s(Sn,"decodeBreak");function Wt(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${m} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${m} Infinity values are not supported`)}return new l(a.float,t,e)}s(Wt,"createToken");function In(t,e,r,n){return Wt(Qt(t,e+1),3,n)}s(In,"decodeFloat16");function Mn(t,e,r,n){return Wt(Xt(t,e+1),5,n)}s(Mn,"decodeFloat32");function Rn(t,e,r,n){return Wt(Ln(t,e+1),9,n)}s(Rn,"decodeFloat64");function Xe(t,e,r){let n=e.value;if(n===!1)t.push([a.float.majorEncoded|ui]);else if(n===!0)t.push([a.float.majorEncoded|di]);else if(n===null)t.push([a.float.majorEncoded|li]);else if(n===void 0)t.push([a.float.majorEncoded|pi]);else{let o,i=!1;(!r||r.float64!==!0)&&(vn(n),o=Qt(F,1),n===o||Number.isNaN(n)?(F[0]=249,t.push(F.slice(0,3)),i=!0):(Nn(n),o=Xt(F,1),n===o&&(F[0]=250,t.push(F.slice(0,5)),i=!0))),i||(hi(n),o=Ln(F,1),F[0]=251,t.push(F.slice(0,9)))}}s(Xe,"encodeFloat");Xe.encodedSize=s(function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){vn(n);let o=Qt(F,1);if(n===o||Number.isNaN(n))return 3;if(Nn(n),o=Xt(F,1),n===o)return 5}return 9},"encodedSize");var On=new ArrayBuffer(9),N=new DataView(On,1),F=new Uint8Array(On,0);function vn(t){if(t===1/0)N.setUint16(0,31744,!1);else if(t===-1/0)N.setUint16(0,64512,!1);else if(Number.isNaN(t))N.setUint16(0,32256,!1);else{N.setFloat32(0,t);let e=N.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)N.setUint16(0,31744,!1);else if(r===0)N.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?N.setUint16(0,0):o<-14?N.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):N.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}s(vn,"encodeFloat16");function Qt(t,e){if(t.length-e<2)throw new Error(`${m} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}s(Qt,"readFloat16");function Nn(t){N.setFloat32(0,t,!1)}s(Nn,"encodeFloat32");function Xt(t,e){if(t.length-e<4)throw new Error(`${m} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}s(Xt,"readFloat32");function hi(t){N.setFloat64(0,t,!1)}s(hi,"encodeFloat64");function Ln(t,e){if(t.length-e<8)throw new Error(`${m} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}s(Ln,"readFloat64");Xe.compareTokens=v.compareTokens;function y(t,e,r){throw new Error(`${m} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}s(y,"invalidMinor");function Ge(t){return()=>{throw new Error(`${m} ${t}`)}}s(Ge,"errorer");var p=[];for(let t=0;t<=23;t++)p[t]=y;p[24]=Kr;p[25]=Wr;p[26]=Qr;p[27]=Xr;p[28]=y;p[29]=y;p[30]=y;p[31]=y;for(let t=32;t<=55;t++)p[t]=y;p[56]=Gr;p[57]=Zr;p[58]=Jr;p[59]=qr;p[60]=y;p[61]=y;p[62]=y;p[63]=y;for(let t=64;t<=87;t++)p[t]=en;p[88]=tn;p[89]=rn;p[90]=nn;p[91]=on;p[92]=y;p[93]=y;p[94]=y;p[95]=Ge("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)p[t]=sn;p[120]=cn;p[121]=an;p[122]=fn;p[123]=un;p[124]=y;p[125]=y;p[126]=y;p[127]=Ge("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)p[t]=ln;p[152]=pn;p[153]=hn;p[154]=mn;p[155]=xn;p[156]=y;p[157]=y;p[158]=y;p[159]=gn;for(let t=160;t<=183;t++)p[t]=yn;p[184]=wn;p[185]=bn;p[186]=En;p[187]=Cn;p[188]=y;p[189]=y;p[190]=y;p[191]=Tn;for(let t=192;t<=215;t++)p[t]=An;p[216]=Bn;p[217]=_n;p[218]=kn;p[219]=Dn;p[220]=y;p[221]=y;p[222]=y;p[223]=y;for(let t=224;t<=243;t++)p[t]=Ge("simple values are not supported");p[244]=y;p[245]=y;p[246]=y;p[247]=Un;p[248]=Ge("simple values are not supported");p[249]=In;p[250]=Mn;p[251]=Rn;p[252]=y;p[253]=y;p[254]=y;p[255]=Sn;var $=[];for(let t=0;t<24;t++)$[t]=new l(a.uint,t,1);for(let t=-1;t>=-24;t--)$[31-t]=new l(a.negint,t,1);$[64]=new l(a.bytes,new Uint8Array(0),1);$[96]=new l(a.string,"",1);$[128]=new l(a.array,0,1);$[160]=new l(a.map,0,1);$[244]=new l(a.false,!1,1);$[245]=new l(a.true,!0,1);$[246]=new l(a.null,null,1);function Gt(t){switch(t.type){case a.false:return z([244]);case a.true:return z([245]);case a.null:return z([246]);case a.bytes:return t.value.length?void 0:z([64]);case a.string:return t.value===""?z([96]):void 0;case a.array:return t.value===0?z([128]):void 0;case a.map:return t.value===0?z([160]):void 0;case a.uint:return t.value<24?z([Number(t.value)]):void 0;case a.negint:if(t.value>=-24)return z([31-Number(t.value)])}}s(Gt,"quickEncodeToken");var xi={float64:!1,mapSorter:wi,quickEncodeToken:Gt},$n=Object.freeze({float64:!0,mapSorter:bi,quickEncodeToken:Gt});function gi(){let t=[];return t[a.uint.major]=v,t[a.negint.major]=Ve,t[a.bytes.major]=oe,t[a.string.major]=dn,t[a.array.major]=Ke,t[a.map.major]=We,t[a.tag.major]=Qe,t[a.float.major]=Xe,t}s(gi,"makeCborEncoders");var Jt=gi(),Zt=new me,Ye=class Ye{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${Ht} object contains circular references`);return new Ye(r,e)}};s(Ye,"Ref");var Je=Ye,H={null:new l(a.null,null),undefined:new l(a.undefined,void 0),true:new l(a.true,!0),false:new l(a.false,!1),emptyArray:new l(a.array,0),emptyMap:new l(a.map,0)},K={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new l(a.float,t):t>=0?new l(a.uint,t):new l(a.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new l(a.uint,t):new l(a.negint,t)},Uint8Array(t,e,r,n){return new l(a.bytes,t)},string(t,e,r,n){return new l(a.string,t)},boolean(t,e,r,n){return t?H.true:H.false},null(t,e,r,n){return H.null},undefined(t,e,r,n){return H.undefined},ArrayBuffer(t,e,r,n){return new l(a.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new l(a.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[H.emptyArray,new l(a.break)]:H.emptyArray;n=Je.createCheck(n,t);let o=[],i=0;for(let c of t)o[i++]=Ze(c,r,n);return r.addBreakTokens?[new l(a.array,t.length),o,new l(a.break)]:[new l(a.array,t.length),o]},Object(t,e,r,n){let o=e!=="Object",i=o?t.keys():Object.keys(t),c=o?t.size:i.length;if(!c)return r.addBreakTokens===!0?[H.emptyMap,new l(a.break)]:H.emptyMap;n=Je.createCheck(n,t);let f=[],u=0;for(let d of i)f[u++]=[Ze(d,r,n),Ze(o?t.get(d):t[d],r,n)];return yi(f,r),r.addBreakTokens?[new l(a.map,c),f,new l(a.break)]:[new l(a.map,c),f]}};K.Map=K.Object;K.Buffer=K.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))K[`${t}Array`]=K.DataView;function Ze(t,e={},r){let n=Lr(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||K[n];if(typeof o=="function"){let c=o(t,n,e,r);if(c!=null)return c}let i=K[n];if(!i)throw new Error(`${Ht} unsupported type: ${n}`);return i(t,n,e,r)}s(Ze,"objectToTokens");function yi(t,e){e.mapSorter&&t.sort(e.mapSorter)}s(yi,"sortMapEntries");function wi(t,e){let r=Array.isArray(t[0])?t[0][0]:t[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=Jt[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}s(wi,"mapSorter");function bi(t,e){if(t[0]instanceof l&&e[0]instanceof l){let r=t[0],n=e[0];return r._keyBytes||(r._keyBytes=Fn(r.value)),n._keyBytes||(n._keyBytes=Fn(n.value)),je(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}s(bi,"rfc8949MapSorter");function Fn(t){return zn(t,Jt,$n)}s(Fn,"encodeRfc8949");function Pn(t,e,r,n){if(Array.isArray(e))for(let o of e)Pn(t,o,r,n);else r[e.type.major](t,e,n)}s(Pn,"tokensToEncoded");function zn(t,e,r){let n=Ze(t,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=e[n.type.major];if(i.encodedSize){let c=i.encodedSize(n,r),f=new me(c);if(i(f,n,r),f.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return jt(f.chunks[0])}}return Zt.reset(),Pn(Zt,n,e,r),Zt.toBytes(!0)}s(zn,"encodeCustom");function we(t,e){return e=Object.assign({},xi,e),zn(t,Jt,e)}s(we,"encode");var Ei={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Yt=class Yt{constructor(e,r={}){this._pos=0,this.data=e,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],r=$[e];if(r===void 0){let n=p[e];if(!n)throw new Error(`${m} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}};s(Yt,"Tokeniser");var qe=Yt,be=Symbol.for("DONE"),et=Symbol.for("BREAK");function Ci(t,e,r){let n=[];for(let o=0;o<t.value;o++){let i=ce(e,r);if(i===et){if(t.value===1/0)break;throw new Error(`${m} got unexpected break to lengthed array`)}if(i===be)throw new Error(`${m} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=i}return n}s(Ci,"tokenToArray");function Ti(t,e,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let c=0;c<t.value;c++){let f=ce(e,r);if(f===et){if(t.value===1/0)break;throw new Error(`${m} got unexpected break to lengthed map`)}if(f===be)throw new Error(`${m} found map but not enough entries (got ${c} [no key], expected ${t.value})`);if(n!==!0&&typeof f!="string")throw new Error(`${m} non-string keys not supported (got ${typeof f})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(f)||!n&&f in o))throw new Error(`${m} found repeat map key "${f}"`);let u=ce(e,r);if(u===be)throw new Error(`${m} found map but not enough entries (got ${c} [no value], expected ${t.value})`);n?i.set(f,u):o[f]=u}return n?i:o}s(Ti,"tokenToMap");function ce(t,e){if(t.done())return be;let r=t.next();if(r.type===a.break)return et;if(r.type.terminal)return r.value;if(r.type===a.array)return Ci(r,t,e);if(r.type===a.map)return Ti(r,t,e);if(r.type===a.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=ce(t,e);return e.tags[r.value](n)}throw new Error(`${m} tag not supported (${r.value})`)}throw new Error("unsupported")}s(ce,"tokensToObject");function jn(t,e){if(!(t instanceof Uint8Array))throw new Error(`${m} data to decode must be a Uint8Array`);e=Object.assign({},Ei,e);let r=e.tokenizer||new qe(t,e),n=ce(r,e);if(n===be)throw new Error(`${m} did not find any content to decode`);if(n===et)throw new Error(`${m} got unexpected break`);return[n,t.subarray(r.pos())]}s(jn,"decodeFirst");function Ee(t,e){let[r,n]=jn(t,e);if(n.length>0)throw new Error(`${m} too many terminals, data makes no sense`);return r}s(Ee,"decode");var qt=class qt extends Error{constructor(e,r){super(),this.message=r,this.value=e,this.stack=new Error(`${e}: ${r}`).stack,this.name=this.constructor.name}};s(qt,"CborldError");var C=qt;var P=new Map([["@context",0],["@type",2],["@id",4],["@value",6],["@direction",8],["@graph",10],["@included",12],["@index",14],["@json",16],["@language",18],["@list",20],["@nest",22],["@reverse",24],["@base",26],["@container",28],["@default",30],["@embed",32],["@explicit",34],["@none",36],["@omitDefault",38],["@prefix",40],["@preserve",42],["@protected",44],["@requireAll",46],["@set",48],["@version",50],["@vocab",52]]),rt=100;var er=class er{decode({value:e}={}){throw new Error("Must be implemented by derived class.")}static createDecoder({value:e,transformer:r}={}){throw new Error("Must be implemented by derived class.")}};s(er,"CborldDecoder");var A=er;var tr=new Map,rr=new Map;T(16,"https://www.w3.org/ns/activitystreams");T(17,"https://www.w3.org/2018/credentials/v1");T(18,"https://www.w3.org/ns/did/v1");T(19,"https://w3id.org/security/suites/ed25519-2018/v1");T(20,"https://w3id.org/security/suites/ed25519-2020/v1");T(21,"https://w3id.org/cit/v1");T(22,"https://w3id.org/age/v1");T(23,"https://w3id.org/security/suites/x25519-2020/v1");T(24,"https://w3id.org/veres-one/v1");T(25,"https://w3id.org/webkms/v1");T(26,"https://w3id.org/zcap/v1");T(27,"https://w3id.org/security/suites/hmac-2019/v1");T(28,"https://w3id.org/security/suites/aes-2019/v1");T(29,"https://w3id.org/vaccination/v1");T(30,"https://w3id.org/vc-revocation-list-2020/v1");T(31,"https://w3id.org/dcc/v1");T(32,"https://w3id.org/vc/status-list/v1");T(48,"https://w3id.org/security/data-integrity/v1");T(49,"https://w3id.org/security/multikey/v1");T(50,"https://purl.imsglobal.org/spec/ob/v3p0/context.json");T(51,"https://w3id.org/security/data-integrity/v2");function T(t,e){rr.set(e,t),tr.set(t,e)}s(T,"_addRegistration");var nt=class nt extends A{constructor({reverseAppContextMap:e}={}){super(),this.reverseAppContextMap=e}decode({value:e}={}){if(typeof e!="number")return nr(e);let r=tr.get(e)||this.reverseAppContextMap.get(e);if(r===void 0)throw new C("ERR_UNDEFINED_COMPRESSED_CONTEXT",`Undefined compressed context "${e}".`);return r}static createDecoder({transformer:e}={}){let{reverseAppContextMap:r}=e;return new nt({reverseAppContextMap:r})}};s(nt,"ContextDecoder");var Ce=nt;function nr(t){if(Array.isArray(t))return t.map(nr);if(!(t instanceof Map))return t;let e={};for(let[r,n]of t)e[r]=nr(n);return e}s(nr,"_mapToObject");function W(t,e){return JSON.stringify(t,null,2)}s(W,"inspect");var Xn="3.7.8",Ai=Xn,fe=typeof Buffer=="function",Vn=typeof TextDecoder=="function"?new TextDecoder:void 0,Hn=typeof TextEncoder=="function"?new TextEncoder:void 0,Bi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Te=Array.prototype.slice.call(Bi),ot=(t=>{let e={};return t.forEach((r,n)=>e[r]=n),e})(Te),_i=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,k=String.fromCharCode.bind(String),Kn=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):t=>new Uint8Array(Array.prototype.slice.call(t,0)),Gn=s(t=>t.replace(/=/g,"").replace(/[+\/]/g,e=>e=="+"?"-":"_"),"_mkUriSafe"),Zn=s(t=>t.replace(/[^A-Za-z0-9\+\/]/g,""),"_tidyB64"),Jn=s(t=>{let e,r,n,o,i="",c=t.length%3;for(let f=0;f<t.length;){if((r=t.charCodeAt(f++))>255||(n=t.charCodeAt(f++))>255||(o=t.charCodeAt(f++))>255)throw new TypeError("invalid character found");e=r<<16|n<<8|o,i+=Te[e>>18&63]+Te[e>>12&63]+Te[e>>6&63]+Te[e&63]}return c?i.slice(0,c-3)+"===".substring(c):i},"btoaPolyfill"),sr=typeof btoa=="function"?t=>btoa(t):fe?t=>Buffer.from(t,"binary").toString("base64"):Jn,or=fe?t=>Buffer.from(t).toString("base64"):t=>{let r=[];for(let n=0,o=t.length;n<o;n+=4096)r.push(k.apply(null,t.subarray(n,n+4096)));return sr(r.join(""))},it=s((t,e=!1)=>e?Gn(or(t)):or(t),"fromUint8Array"),ki=s(t=>{if(t.length<2){var e=t.charCodeAt(0);return e<128?t:e<2048?k(192|e>>>6)+k(128|e&63):k(224|e>>>12&15)+k(128|e>>>6&63)+k(128|e&63)}else{var e=65536+(t.charCodeAt(0)-55296)*1024+(t.charCodeAt(1)-56320);return k(240|e>>>18&7)+k(128|e>>>12&63)+k(128|e>>>6&63)+k(128|e&63)}},"cb_utob"),Di=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Yn=s(t=>t.replace(Di,ki),"utob"),Wn=fe?t=>Buffer.from(t,"utf8").toString("base64"):Hn?t=>or(Hn.encode(t)):t=>sr(Yn(t)),ae=s((t,e=!1)=>e?Gn(Wn(t)):Wn(t),"encode"),Qn=s(t=>ae(t,!0),"encodeURI"),Ui=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Si=s(t=>{switch(t.length){case 4:var e=(7&t.charCodeAt(0))<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|63&t.charCodeAt(3),r=e-65536;return k((r>>>10)+55296)+k((r&1023)+56320);case 3:return k((15&t.charCodeAt(0))<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2));default:return k((31&t.charCodeAt(0))<<6|63&t.charCodeAt(1))}},"cb_btou"),qn=s(t=>t.replace(Ui,Si),"btou"),eo=s(t=>{if(t=t.replace(/\s+/g,""),!_i.test(t))throw new TypeError("malformed base64.");t+="==".slice(2-(t.length&3));let e,r,n,o=[];for(let i=0;i<t.length;)e=ot[t.charAt(i++)]<<18|ot[t.charAt(i++)]<<12|(r=ot[t.charAt(i++)])<<6|(n=ot[t.charAt(i++)]),r===64?o.push(k(e>>16&255)):n===64?o.push(k(e>>16&255,e>>8&255)):o.push(k(e>>16&255,e>>8&255,e&255));return o.join("")},"atobPolyfill"),cr=typeof atob=="function"?t=>atob(Zn(t)):fe?t=>Buffer.from(t,"base64").toString("binary"):eo,to=fe?t=>Kn(Buffer.from(t,"base64")):t=>Kn(cr(t).split("").map(e=>e.charCodeAt(0))),ro=s(t=>to(no(t)),"toUint8Array"),Ii=fe?t=>Buffer.from(t,"base64").toString("utf8"):Vn?t=>Vn.decode(to(t)):t=>qn(cr(t)),no=s(t=>Zn(t.replace(/[-_]/g,e=>e=="-"?"+":"/")),"_unURI"),ir=s(t=>Ii(no(t)),"decode"),Mi=s(t=>{if(typeof t!="string")return!1;let e=t.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(e)||!/[^\s0-9a-zA-Z\-_]/.test(e)},"isValid"),oo=s(t=>({value:t,enumerable:!1,writable:!0,configurable:!0}),"_noEnum"),io=s(function(){let t=s((e,r)=>Object.defineProperty(String.prototype,e,oo(r)),"_add");t("fromBase64",function(){return ir(this)}),t("toBase64",function(e){return ae(this,e)}),t("toBase64URI",function(){return ae(this,!0)}),t("toBase64URL",function(){return ae(this,!0)}),t("toUint8Array",function(){return ro(this)})},"extendString"),so=s(function(){let t=s((e,r)=>Object.defineProperty(Uint8Array.prototype,e,oo(r)),"_add");t("toBase64",function(e){return it(this,e)}),t("toBase64URI",function(){return it(this,!0)}),t("toBase64URL",function(){return it(this,!0)})},"extendUint8Array"),Ri=s(()=>{io(),so()},"extendBuiltins"),st={version:Xn,VERSION:Ai,atob:cr,atobPolyfill:eo,btoa:sr,btoaPolyfill:Jn,fromBase64:ir,toBase64:ae,encode:ae,encodeURI:Qn,encodeURL:Qn,utob:Yn,btou:qn,decode:ir,isValid:Mi,fromUint8Array:it,toUint8Array:ro,extendString:io,extendUint8Array:so,extendBuiltins:Ri};var co={};function ao(t,e,r){if(!(t instanceof Uint8Array))throw new TypeError('"input" must be a Uint8Array.');if(typeof e!="string")throw new TypeError('"alphabet" must be a string.');if(r!==void 0&&typeof r!="number")throw new TypeError('"maxline" must be a number.');if(t.length===0)return"";let n="",o=0,i=e.length,c=e.charAt(0),f=[0];for(o=0;o<t.length;++o){let u=t[o];for(let d=0;d<f.length;++d)u+=f[d]<<8,f[d]=u%i,u=u/i|0;for(;u>0;)f.push(u%i),u=u/i|0}for(o=0;t[o]===0&&o<t.length-1;++o)n+=c;for(o=f.length-1;o>=0;--o)n+=e[f[o]];if(r){let u=new RegExp(".{1,"+r+"}","g");n=n.match(u).join(`\r
2
- `)}return n}s(ao,"encode");function fo(t,e){if(typeof t!="string")throw new TypeError('"input" must be a string.');if(typeof e!="string")throw new TypeError('"alphabet" must be a string.');if(t.length===0)return new Uint8Array;let r=co[e];if(!r){r=co[e]=[];for(let c=0;c<e.length;++c)r[e.charCodeAt(c)]=c}t=t.replace(/\s/g,"");let n=e.length,o=e.charAt(0),i=[0];for(let c=0;c<t.length;c++){let f=r[t.charCodeAt(c)];if(f===void 0)return;let u=f;for(let d=0;d<i.length;++d)u+=i[d]*n,i[d]=u&255,u>>=8;for(;u>0;)i.push(u&255),u>>=8}for(let c=0;t[c]===o&&c<t.length-1;++c)i.push(0);return new Uint8Array(i.reverse())}s(fo,"decode");var uo="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Ae(t,e){return ao(t,uo,e)}s(Ae,"encode");function ct(t){return fo(t,uo)}s(ct,"decode");var ft=class ft extends A{decode({value:e}={}){let{buffer:r,byteOffset:n,length:o}=e,i=new Uint8Array(r,n+1,o-1);return e[0]===122?`z${Ae(i)}`:e[0]===77?`M${st.fromUint8Array(i)}`:e}static createDecoder({value:e}={}){if(!(e instanceof Uint8Array))return!1;if(e[0]===122||e[0]===77)return new ft}};s(ft,"MultibaseDecoder");var at=ft;var ar=class ar{constructor({appContextMap:e,documentLoader:r}={}){this.appContextMap=e,this.documentLoader=r}_beforeObjectContexts(){}_afterObjectContexts(){}_beforeTypeScopedContexts(){}async _transform({obj:e,transformMap:r,contextStack:n=[]}){this._beforeObjectContexts({obj:e,transformMap:r});let o=await this._applyEmbeddedContexts({obj:e,contextStack:n});this._afterObjectContexts({obj:e,transformMap:r});let i=n.slice();this._beforeTypeScopedContexts({activeCtx:o,obj:e,transformMap:r}),o=await this._applyTypeScopedContexts({obj:e,contextStack:n});let{aliases:c,scopedContextMap:f,termMap:u}=o,d=this._getEntries({obj:e,transformMap:r,transformer:this,termMap:u});for(let[h,x]of d){let{term:g}=h;if(g==="@id"||c.id.has(g)){this._transformObjectId({obj:e,transformMap:r,termInfo:h,value:x});continue}if(g==="@type"||c.type.has(g)){this._transformObjectType({obj:e,transformMap:r,termInfo:h,value:x});continue}let w=i,U,Fe=f.get(g);Fe&&(U=await this._applyEmbeddedContexts({obj:{"@context":Fe},contextStack:n}),w=n.slice());let{plural:$e,def:$t}=h,L=this._getTermType({activeCtx:U||o,def:$t}),Pe=$e?x:[x],te=[];for(let X of Pe){if(X===null){te.push(null);continue}if(!this._transformTypedValue({entries:te,termType:L,value:X,termInfo:h})){if(typeof X!="object"){te.push(X);continue}if(Array.isArray(X)){await this._transformArray({entries:te,contextStack:w,value:X});continue}await this._transformObject({entries:te,contextStack:w,value:X})}}U&&U.revert(),this._assignEntries({entries:te,obj:e,transformMap:r,termInfo:h})}o.revert()}async _applyEmbeddedContexts({obj:e,contextStack:r}){let n=r.length,o=e["@context"];await this._updateContextStack({contextStack:r,contexts:o});let i=r[r.length-1];return i||(i={aliases:{id:new Set,type:new Set},context:{},scopedContextMap:new Map,termMap:new Map}),{...i,revert(){r.length=n}}}async _applyTypeScopedContexts({obj:e,contextStack:r}){let n=r.length,o=r[r.length-1];o||(o={aliases:{id:new Set,type:new Set},context:{},scopedContextMap:new Map,termMap:new Map});let{aliases:i}=o,c=[],f=["@type",...i.type];for(let d of f){let h=e[d];Array.isArray(h)?c.push(...h):c.push(h)}c=[...new Set(c)].sort();let{scopedContextMap:u}=o;for(let d of c){let h=u.get(d);h&&(await this._updateContextStack({contextStack:r,contexts:h}),o=r[r.length-1],{scopedContextMap:u}=o)}return{...o,revert(){r.length=n}}}async _updateContextStack({contextStack:e,contexts:r,transformer:n}){if(!r)return;Array.isArray(r)||(r=[r]);let{contextMap:o}=this;for(let i of r){let c=o.get(i);if(!c){let g=i,w;typeof i=="string"&&(w=i,{"@context":g}=await this._getDocument({url:w})),c=await this._addContext({context:g,contextUrl:w,transformer:n})}let f={aliases:{id:new Set(c.aliases.id),type:new Set(c.aliases.type)},context:i,scopedContextMap:new Map(c.scopedContextMap),termMap:new Map(c.termMap)},u=e[e.length-1];if(e.push(f),!u)continue;let{aliases:d,termMap:h}=f;for(let g of["id","type"])for(let w of u.aliases[g])i[w]===null||f.termMap.has(w)||d[g].add(w);let{scopedContextMap:x}=f;for(let[g,w]of u.scopedContextMap)i[g]===null||x.has(g)||x.set(g,w);for(let[g,w]of u.termMap)i[g]===null||h.has(g)||h.set(g,w)}}async _addContext({context:e,contextUrl:r}){let{contextMap:n,termToId:o,idToTerm:i}=this,c=e["@import"];if(c){let x=n.get(c);if(!x){let{"@context":g}=await this._getDocument({url:c});x=await this._addContext({context:g,contextUrl:c})}e={...x.context,...e}}let f=new Map,u=new Map,d={aliases:{id:new Set,type:new Set},context:e,scopedContextMap:f,termMap:u},h=Object.keys(e).sort();for(let x of h){let g=e[x];if(!g||(g==="@id"||g.id==="@id"?d.aliases.id.add(x):(g==="@type"||g.id==="@type")&&d.aliases.type.add(x),P.has(x)))continue;if(!o.has(x)){let U=this.nextTermId;this.nextTermId+=2,o.set(x,U),i&&i.set(U,x)}u.set(x,g);let w=g["@context"];w&&f.set(x,w)}return n.set(r||e,d),d}async _getDocument({url:e}){let{document:r}=await this.documentLoader(e);return typeof r=="string"?JSON.parse(r):r}_getTermType({activeCtx:e,def:r}){let{"@type":n}=r;if(!n)return;let[o,...i]=n.split(":"),c=e.termMap.get(o);if(c===void 0)return n;if(typeof c=="string")return c+i.join(":");if(!(typeof c=="object"&&typeof c["@id"]=="string"))throw new C("ERR_INVALID_TERM_DEFINITION",'JSON-LD term definitions must be strings or objects with "@id".');return c["@id"]+i.join(":")}_getIdForTerm({term:e,plural:r}){let n=this.termToId.get(e);if(n===void 0)throw new C("ERR_UNDEFINED_TERM","CBOR-LD compression requires all terms to be defined in a JSON-LD context.");return r?n+1:n}_getTermForId({id:e}){let r=(e&1)===1;return{term:this.idToTerm.get(r?e-1:e),plural:r}}};s(ar,"Transformer");var ue=ar;var lo=new Map([[1024,"did:v1:nym:"],[1025,"did:key:"]]),ut=class ut extends A{decode({value:e}={}){let r=lo.get(e[0]);return typeof e[1]=="string"?r+=e[1]:r+=`z${Ae(e[1])}`,e.length>2&&(typeof e[2]=="string"?r+=`#${e[2]}`:r+=`#z${Ae(e[2])}`),r}static createDecoder({value:e}={}){return!(Array.isArray(e)&&e.length>1&&e.length<=3)||!lo.has(e[0])?!1:new ut}};s(ut,"Base58DidUrlDecoder");var Be=ut;var dt=class dt extends A{constructor({secure:e}={}){super(),this.secure=e}decode({value:e}={}){return`${this.secure?"https://":"http://"}${e[1]}`}static createDecoder({value:e}={}){return e.length===2&&typeof e[1]=="string"?new dt({secure:e[0]===2}):!1}};s(dt,"HttpUrlDecoder");var _e=dt;var po=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Oi(t){return typeof t=="string"&&po.test(t)}s(Oi,"validate");var lt=Oi;var D=[];for(let t=0;t<256;++t)D.push((t+256).toString(16).slice(1));function vi(t,e=0){return D[t[e+0]]+D[t[e+1]]+D[t[e+2]]+D[t[e+3]]+"-"+D[t[e+4]]+D[t[e+5]]+"-"+D[t[e+6]]+D[t[e+7]]+"-"+D[t[e+8]]+D[t[e+9]]+"-"+D[t[e+10]]+D[t[e+11]]+D[t[e+12]]+D[t[e+13]]+D[t[e+14]]+D[t[e+15]]}s(vi,"unsafeStringify");function Ni(t,e=0){let r=vi(t,e);if(!lt(r))throw TypeError("Stringified UUID is invalid");return r}s(Ni,"stringify");var fr=Ni;function Li(t){if(!lt(t))throw TypeError("Invalid UUID");let e,r=new Uint8Array(16);return r[0]=(e=parseInt(t.slice(0,8),16))>>>24,r[1]=e>>>16&255,r[2]=e>>>8&255,r[3]=e&255,r[4]=(e=parseInt(t.slice(9,13),16))>>>8,r[5]=e&255,r[6]=(e=parseInt(t.slice(14,18),16))>>>8,r[7]=e&255,r[8]=(e=parseInt(t.slice(19,23),16))>>>8,r[9]=e&255,r[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,r[11]=e/4294967296&255,r[12]=e>>>24&255,r[13]=e>>>16&255,r[14]=e>>>8&255,r[15]=e&255,r}s(Li,"parse");var ur=Li;var ht=class ht extends A{decode({value:e}={}){return`urn:uuid:${typeof e[1]=="string"?e[1]:fr(e[1])}`}static createDecoder({value:e}={}){if(e.length===2&&(typeof e[1]=="string"||e[1]instanceof Uint8Array))return new ht}};s(ht,"UuidUrnDecoder");var pt=ht;var Fi=new Map([[1,_e],[2,_e],[3,pt],[1024,Be],[1025,Be]]),dr=class dr extends A{static createDecoder({value:e}={}){if(!(Array.isArray(e)||e.length>1))return!1;let r=Fi.get(e[0]);return r&&r.createDecoder({value:e})}};s(dr,"UriDecoder");var Z=dr;var mt=class mt extends A{constructor({term:e}={}){super(),this.term=e}decode(){return this.term}static createDecoder({value:e,transformer:r}={}){if(Array.isArray(e))return Z.createDecoder({value:e,transformer:r});let n=r.idToTerm.get(e);if(n!==void 0)return new mt({term:n})}};s(mt,"VocabTermDecoder");var J=mt;var gt=class gt extends A{decode({value:e}={}){let r=new Date(e*1e3).toISOString();return r.substring(0,r.indexOf("T"))}static createDecoder({value:e}={}){if(typeof e=="number")return new gt}};s(gt,"XsdDateDecoder");var xt=gt;var ke=class ke extends A{constructor({value:e}={}){super(),this.value=e}decode({value:e}={}){return typeof e=="number"?new Date(e*1e3).toISOString().replace(".000Z","Z"):new Date(e[0]*1e3+e[1]).toISOString()}static createDecoder({value:e}={}){if(typeof e=="number")return new ke;if(Array.isArray(e)&&e.length===2&&(typeof e[0]=="number"||typeof e[1]=="number"))return new ke}};s(ke,"XsdDateTimeDecoder");var yt=ke;var $i=new Map([["@id",Z],["@vocab",J],["https://w3id.org/security#multibase",at],["http://www.w3.org/2001/XMLSchema#date",xt],["http://www.w3.org/2001/XMLSchema#dateTime",yt]]),lr=P.get("@context"),ho=lr+1,pr=class pr extends ue{constructor({documentLoader:e,appContextMap:r}={}){if(super({documentLoader:e,appContextMap:r}),this.reverseAppContextMap=new Map,r)for(let[n,o]of r)this.reverseAppContextMap.set(o,n)}async decompress({compressedBytes:e,diagnose:r}={}){this.contextMap=new Map,this.termToId=new Map(P),this.nextTermId=rt,this.idToTerm=new Map;for(let[f,u]of this.termToId)this.idToTerm.set(u,f);let n=Ee(e,{useMaps:!0});r&&(r("Diagnostic CBOR-LD decompression transform map(s):"),r(W(n,{depth:null,colors:!0})));let o=[],i=Array.isArray(n),c=i?n:[n];for(let f of c){let u={};await this._transform({obj:u,transformMap:f}),o.push(u)}return i?o:o[0]}_beforeObjectContexts({obj:e,transformMap:r}){let n=r.get(lr);if(n){let i=Ce.createDecoder({value:n,transformer:this});e["@context"]=i?i.decode({value:n}):n}let o=r.get(ho);if(o){if(n)throw new C("ERR_INVALID_ENCODED_CONTEXT","Both singular and plural context IDs were found in the CBOR-LD input.");if(!Array.isArray(o))throw new C("ERR_INVALID_ENCODED_CONTEXT","Encoded plural context value must be an array.");let i=[];for(let c of o){let f=Ce.createDecoder({value:c,transformer:this});i.push(f?f.decode({value:c}):c)}e["@context"]=i}}_beforeTypeScopedContexts({activeCtx:e,obj:r,transformMap:n}){let{termToId:o}=this,i=["@type",...e.aliases.type];for(let c of i){let f=o.get(c),u=n.get(f);if(u===void 0&&(u=n.get(f+1)),u!==void 0)if(Array.isArray(u))r[c]=u.map(d=>{let h=J.createDecoder({value:d,transformer:this});return h?h.decode({value:d}):d});else{let d=J.createDecoder({value:u,transformer:this});r[c]=d?d.decode({value:u}):u}}}_getEntries({transformMap:e,termMap:r}){let n=[];for(let[o,i]of e){if(o===lr||o===ho)continue;let{term:c,plural:f}=this._getTermForId({id:o});if(c===void 0)throw new C("ERR_UNKNOWN_CBORLD_TERM_ID",`Unknown term ID '${o}' was detected in the CBOR-LD input.`);let u=r.get(c);if(u===void 0&&!(c.startsWith("@")&&P.has(c)))throw new C("ERR_UNKNOWN_CBORLD_TERM",`Unknown term "${c}" was detected in the CBOR-LD input.`);n.push([{term:c,termId:o,plural:f,def:u},i])}return n.sort(Pi)}_getTermInfo({termMap:e,key:r}){let{term:n,plural:o}=this._getTermForId({id:r});if(n===void 0)throw new C("ERR_UNKNOWN_CBORLD_TERM_ID",`Unknown term ID '${r}' was detected in the CBOR-LD input.`);let i=e.get(n);if(i===void 0&&!(n.startsWith("@")&&P.has(n)))throw new C("ERR_UNKNOWN_CBORLD_TERM",`Unknown term "${n}" was detected in the CBOR-LD input.`);return{term:n,termId:r,plural:o,def:i}}_transformObjectId({obj:e,termInfo:r,value:n}){let o=Z.createDecoder({value:n});e[r.term]=o?o.decode({value:n}):n}_transformObjectType({obj:e,termInfo:r,value:n}){let{term:o,plural:i}=r,c=i?n:[n],f=[];for(let u of c){let d=J.createDecoder({value:u,transformer:this});f.push(d?d.decode({value:u}):u)}e[o]=i?f:f[0]}_transformTypedValue({entries:e,termType:r,value:n}){let o=$i.get(r),i=o&&o.createDecoder({value:n,transformer:this});if(i)return e.push(i.decode({value:n})),!0}async _transformArray({entries:e,contextStack:r,value:n}){let o=[];for(let i of n){let c={};o.push(c),await this._transform({obj:c,transformMap:i,contextStack:r})}e.push(o)}async _transformObject({entries:e,contextStack:r,value:n}){let o={};return e.push(o),this._transform({obj:o,transformMap:n,contextStack:r})}_assignEntries({entries:e,obj:r,termInfo:n}){let{term:o,plural:i}=n;r[o]=i?e:e[0]}};s(pr,"Decompressor");var wt=pr;function Pi([{term:t}],[{term:e}]){return t<e?-1:t>e?1:0}s(Pi,"_sortEntriesByTerm");async function hr({cborldBytes:t,documentLoader:e,appContextMap:r=new Map,diagnose:n}){if(!(t instanceof Uint8Array))throw new TypeError('"cborldBytes" must be a Uint8Array.');let o=0;if(t[o++]!==217)throw new C("ERR_NOT_CBORLD",'CBOR-LD must start with a CBOR major type "Tag" header of `0xd9`.');if(t[o++]!==5)throw new C("ERR_NOT_CBORLD","CBOR-LD 16-bit tag must start with `0x05`.");let i=t[o];if(i===void 0)throw new C("ERR_NOT_CBORLD","Truncated CBOR-LD 16-bit tag.");if(!(i===0||i===1))throw new C("ERR_NOT_CBORLD",`Unsupported CBOR-LD compression mode "${i}".`);o++;let{buffer:c,byteOffset:f,length:u}=t,d=new Uint8Array(c,f+o,u-o);if(i===0)return Ee(d,{useMaps:!1});let x=await new wt({documentLoader:e,appContextMap:r}).decompress({compressedBytes:d,diagnose:n});return n&&(n("Diagnostic JSON-LD result:"),n(W(x,{depth:null,colors:!0}))),x}s(hr,"decode");var mr=class mr{encode(){throw new Error("Must be implemented by derived class.")}static createEncoder({value:e}={}){throw new Error("Must be implemented by derived class.")}};s(mr,"CborldEncoder");var b=mr;var Et=class Et extends b{constructor({context:e,appContextMap:r}={}){super(),this.context=e,this.appContextMap=r}encode(){let{context:e}=this,r=rr.get(e)||this.appContextMap.get(e);return r===void 0?new l(a.string,e):new l(a.uint,r)}static createEncoder({value:e,transformer:r}={}){if(typeof e!="string")return!1;let{appContextMap:n}=r;return new Et({context:e,appContextMap:n})}};s(Et,"ContextEncoder");var bt=Et;var Tt=class Tt extends b{constructor({value:e}={}){super(),this.value=e}encode(){let{value:e}=this,r,n;e[0]==="z"?(r=122,n=ct(e.substr(1))):e[0]==="M"&&(r=77,n=st.toUint8Array(e.substr(1)));let o=new Uint8Array(1+n.length);return o[0]=r,o.set(n,1),new l(a.bytes,o)}static createEncoder({value:e}={}){if(typeof e!="string")return!1;if(e[0]==="z"||e[0]==="M")return new Tt({value:e})}};s(Tt,"MultibaseEncoder");var Ct=Tt;var mo=new Map([["did:v1:nym:",1024],["did:key:",1025]]),At=class At extends b{constructor({value:e,scheme:r}={}){super(),this.value=e,this.scheme=r}encode(){let{value:e,scheme:r}=this,n=e.substr(r.length),[o,i]=n.split("#"),c=[new l(a.uint,mo.get(r)),xo(o)];return i!==void 0&&c.push(xo(i)),[new l(a.array,c.length),c]}static createEncoder({value:e}={}){let r=[...mo.keys()];for(let n of r)if(e.startsWith(n))return new At({value:e,scheme:n})}};s(At,"Base58DidUrlEncoder");var De=At;function xo(t){if(t.startsWith("z")){let e=ct(t.substr(1));if(e)return new l(a.bytes,e)}return new l(a.string,t)}s(xo,"_multibase58ToToken");var Ue=class Ue extends b{constructor({value:e,secure:r}={}){super(),this.value=e,this.secure=r}encode(){let{value:e,secure:r}=this,n=r?8:7,o=[new l(a.uint,r?2:1),new l(a.string,e.substr(n))];return[new l(a.array,o.length),o]}static createEncoder({value:e}={}){if(e.startsWith("https://"))return new Ue({value:e,secure:!0});if(e.startsWith("http://"))return new Ue({value:e,secure:!1})}};s(Ue,"HttpUrlEncoder");var Se=Ue;var _t=class _t extends b{constructor({value:e}={}){super(),this.value=e}encode(){let{value:e}=this,r=e.substr(9),n=[new l(a.uint,3)];if(r.toLowerCase()===r){let o=ur(r);n.push(new l(a.bytes,o))}else n.push(new l(a.string,r));return[new l(a.array,n.length),n]}static createEncoder({value:e}={}){if(e.startsWith("urn:uuid:"))return new _t({value:e})}};s(_t,"UuidUrnEncoder");var Bt=_t;var zi=new Map([["http",Se],["https",Se],["urn:uuid",Bt],["did:v1:nym",De],["did:key",De]]),xr=class xr extends b{static createEncoder({value:e}={}){if(typeof e!="string")return!1;let r;try{let{protocol:o,pathname:i}=new URL(e);r=o,i.includes(":")&&(r+=i);let c=e.split(":");c.pop(),r=c.join(":")}catch{return!1}let n=zi.get(r);return n&&n.createEncoder({value:e})}};s(xr,"UriEncoder");var Y=xr;var kt=class kt extends b{constructor({termId:e}={}){super(),this.termId=e}encode(){return new l(a.uint,this.termId)}static createEncoder({value:e,transformer:r}={}){let{termToId:n}=r,o=n.get(e);return o!==void 0?new kt({termId:o}):Y.createEncoder({value:e})}};s(kt,"VocabTermEncoder");var Ie=kt;var Ut=class Ut extends b{constructor({value:e,parsed:r}={}){super(),this.value=e,this.parsed=r}encode(){let{value:e,parsed:r}=this,n=Math.floor(r/1e3),o=new Date(n*1e3).toISOString(),i=o.substring(0,o.indexOf("T"));return e!==i?new l(a.string,e):new l(a.uint,n)}static createEncoder({value:e}={}){if(e.includes("T"))return!1;let r=Date.parse(e);return isNaN(r)?!1:new Ut({value:e,parsed:r})}};s(Ut,"XsdDateEncoder");var Dt=Ut;var It=class It extends b{constructor({value:e,parsed:r}={}){super(),this.value=e,this.parsed=r}encode(){let{value:e,parsed:r}=this,n=Math.floor(r/1e3),o=new l(a.uint,n),i=e.indexOf(".");if(i===-1){let d=new Date(n*1e3).toISOString().replace(".000Z","Z");return e!==d?new l(a.string,e):o}let c=parseInt(e.substr(i+1),10),f=new Date(n*1e3+c).toISOString();if(e!==f)return new l(a.string,e);let u=[o,new l(a.uint,c)];return[new l(a.array,u.length),u]}static createEncoder({value:e}={}){if(!e.includes("T"))return!1;let r=Date.parse(e);return isNaN(r)?!1:new It({value:e,parsed:r})}};s(It,"XsdDateTimeEncoder");var St=It;var ji=new Map([["@id",Y],["@vocab",Ie],["https://w3id.org/security#multibase",Ct],["http://www.w3.org/2001/XMLSchema#date",Dt],["http://www.w3.org/2001/XMLSchema#dateTime",St]]),go=P.get("@context"),Vi=go+1,Hi={Object(t){if(t instanceof b)return t.encode({obj:t})}},gr=class gr extends ue{constructor({documentLoader:e,appContextMap:r}={}){super({documentLoader:e,appContextMap:r})}async compress({jsonldDocument:e,diagnose:r}={}){let n=await this._createTransformMaps({jsonldDocument:e});return r&&(r("Diagnostic CBOR-LD compression transform map(s):"),r(W(n,{depth:null,colors:!0}))),we(n,{typeEncoders:Hi})}async _createTransformMaps({jsonldDocument:e}){this.contextMap=new Map,this.termToId=new Map(P),this.nextTermId=rt;let r=[],n=Array.isArray(e),o=n?e:[e];for(let i of o){let c=new Map;await this._transform({obj:i,transformMap:c}),r.push(c)}return n?r:r[0]}_afterObjectContexts({obj:e,transformMap:r}){let n=e["@context"];if(!n)return;let o=[],i=Array.isArray(n),c=i?n:[n];for(let u of c){let d=bt.createEncoder({value:u,transformer:this});o.push(d||u)}let f=i?Vi:go;r.set(f,i?o:o[0])}_getEntries({obj:e,termMap:r}){let n=[],o=Object.keys(e).sort();for(let i of o){if(i==="@context")continue;let c=r.get(i);if(c===void 0&&!(i.startsWith("@")&&P.has(i)))throw new C("ERR_UNKNOWN_CBORLD_TERM",`Unknown term '${i}' was detected in the JSON-LD input.`);let f=e[i],u=Array.isArray(f),d=this._getIdForTerm({term:i,plural:u});n.push([{term:i,termId:d,plural:u,def:c},f])}return n}_transformObjectId({transformMap:e,termInfo:r,value:n}){let{termId:o}=r,i=Y.createEncoder({value:n,transformer:this,termInfo:r});e.set(o,i||n)}_transformObjectType({transformMap:e,termInfo:r,value:n}){let{termId:o,plural:i}=r,c=i?n:[n],f=[];for(let u of c){let d=Ie.createEncoder({value:u,transformer:this,termInfo:r});f.push(d||u)}e.set(o,i?f:f[0])}_transformTypedValue({entries:e,termType:r,value:n,termInfo:o}){let i=ji.get(r),c=i&&i.createEncoder({value:n,transformer:this,termInfo:o});if(c)return e.push(c),!0}async _transformArray({entries:e,contextStack:r,value:n}){let o=[];for(let i of n){let c=new Map;o.push(c),await this._transform({obj:i,transformMap:c,contextStack:r})}e.push(o)}async _transformObject({entries:e,contextStack:r,value:n}){let o=new Map;e.push(o),await this._transform({obj:n,transformMap:o,contextStack:r})}_assignEntries({entries:e,transformMap:r,termInfo:n}){let{termId:o,plural:i}=n;r.set(o,i?e:e[0])}};s(gr,"Compressor");var Mt=gr;async function yr({jsonldDocument:t,documentLoader:e,appContextMap:r=new Map,compressionMode:n=1,diagnose:o}={}){if(!(n===0||n===1))throw new TypeError('"compressionMode" must be "0" (no compression) or "1" for compression mode version 1.');let i=new Uint8Array([217,5,n]),c;n===0?c=we(t):c=await new Mt({documentLoader:e,appContextMap:r}).compress({jsonldDocument:t,diagnose:o});let f=i.length+c.length,u=new Uint8Array(f);return u.set(i),u.set(c,i.length),o&&(o("Diagnostic CBOR-LD result:"),o(W(u,{depth:null,colors:!0}))),u}s(yr,"encode");function wr(t){if(t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray)return new DataView(t.buffer,t.byteOffset,t.byteLength);if(t instanceof ArrayBuffer)return new DataView(t);throw new TypeError("Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray")}s(wr,"toDataView");var Wi="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",Qi="0123456789ABCDEFGHIJKLMNOPQRSTUV",Xi="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function br(t,e,r){r=r||{};let n,o;switch(e){case"RFC3548":case"RFC4648":n=Wi,o=!0;break;case"RFC4648-HEX":n=Qi,o=!0;break;case"Crockford":n=Xi,o=!1;break;default:throw new Error("Unknown base32 variant: "+e)}let i=r.padding!==void 0?r.padding:o,c=wr(t),f=0,u=0,d="";for(let h=0;h<c.byteLength;h++)for(u=u<<8|c.getUint8(h),f+=8;f>=5;)d+=n[u>>>f-5&31],f-=5;if(f>0&&(d+=n[u<<5-f&31]),i)for(;d.length%8!==0;)d+="=";return d}s(br,"base32Encode");var Lo=Qo(wo(),1);var E;(function(t){t[t.Terminator=0]="Terminator",t[t.Numeric=1]="Numeric",t[t.Alphanumeric=2]="Alphanumeric",t[t.StructuredAppend=3]="StructuredAppend",t[t.Byte=4]="Byte",t[t.Kanji=8]="Kanji",t[t.ECI=7]="ECI"})(E||(E={}));var Er=class Er{constructor(e,r){this.bytes=[],this.mode=e,this.data=r}getLength(){return this.bytes.length}getLengthInBits(e){let r=this.mode,n=new Error(`illegal mode: ${r}`);if(1<=e&&e<10)switch(r){case E.Numeric:return 10;case E.Alphanumeric:return 9;case E.Byte:return 8;case E.Kanji:return 8;default:throw n}else if(e<27)switch(r){case E.Numeric:return 12;case E.Alphanumeric:return 11;case E.Byte:return 16;case E.Kanji:return 10;default:throw n}else if(e<41)switch(r){case E.Numeric:return 14;case E.Alphanumeric:return 13;case E.Byte:return 16;case E.Kanji:return 12;default:throw n}else throw new Error(`illegal version: ${e}`)}};s(Er,"QRData");var Q=Er;function bo(t){let e=0,{length:r}=t,n=[];for(let o=0;o<r;o++){let i=t.charCodeAt(o);i<128?n[e++]=i:i<2048?(n[e++]=i>>6|192,n[e++]=i&63|128):(i&64512)===55296&&o+1<r&&(t.charCodeAt(o+1)&64512)===56320?(i=65536+((i&1023)<<10)+(t.charCodeAt(++o)&1023),n[e++]=i>>18|240,n[e++]=i>>12&63|128,n[e++]=i>>6&63|128,n[e++]=i&63|128):(n[e++]=i>>12|224,n[e++]=i>>6&63|128,n[e++]=i&63|128)}return n}s(bo,"encode");var Cr=class Cr extends Q{constructor(e,r){if(super(E.Byte,e),this.encoding=-1,typeof r=="function"){let{encoding:n,bytes:o}=r(e);this.bytes=o,this.encoding=n}else this.bytes=bo(e),this.encoding=26}writeTo(e){let{bytes:r}=this;for(let n of r)e.put(n,8)}};s(Cr,"QRByte");var Rt=Cr;var q=[],Tr=[];for(let t=0;t<256;t++)Tr[t]=0,q[t]=t<8?1<<t:q[t-4]^q[t-5]^q[t-6]^q[t-8];for(let t=0;t<255;t++)Tr[q[t]]=t;function de(t){if(t<1)throw new Error(`illegal log: ${t}`);return Tr[t]}s(de,"glog");function Me(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return q[t]}s(Me,"gexp");var Re=class Re{constructor(e,r=0){let n=0,{length:o}=e;for(;n<o&&e[n]===0;)n++;o-=n;let i=[];for(let c=0;c<o;c++)i.push(e[n+c]);for(let c=0;c<r;c++)i.push(0);this.num=i}getAt(e){return this.num[e]}getLength(){return this.num.length}multiply(e){let r=[],n=e.getLength(),o=this.getLength(),i=o+n-1;for(let c=0;c<i;c++)r.push(0);for(let c=0;c<o;c++)for(let f=0;f<n;f++)r[c+f]^=Me(de(this.getAt(c))+de(e.getAt(f)));return new Re(r)}mod(e){let r=e.getLength(),n=this.getLength();if(n-r<0)return this;let o=de(this.getAt(0))-de(e.getAt(0)),i=[];for(let c=0;c<n;c++)i.push(this.getAt(c));for(let c=0;c<r;c++)i[c]^=Me(de(e.getAt(c))+o);return new Re(i).mod(e)}};s(Re,"Polynomial");var ee=Re;var qi=3,es=3,Eo=40,ts=10,rs=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],ns=21522,Bo=1335,_o=7973;function ko(t){return rs[t-1]}s(ko,"getAlignmentPattern");function Do(t){let e=new ee([1]);for(let r=0;r<t;r++)e=e.multiply(new ee([1,Me(r)]));return e}s(Do,"getErrorCorrectionPolynomial");function le(t){let e=0;for(;t!==0;)e++,t>>>=1;return e}s(le,"getBCHDigit");var Co=le(_o);function Uo(t){let e=t<<12;for(;le(e)-Co>=0;)e^=_o<<le(e)-Co;return t<<12|e}s(Uo,"getBCHVersion");var To=le(Bo);function So(t){let e=t<<10;for(;le(e)-To>=0;)e^=Bo<<le(e)-To;return(t<<10|e)^ns}s(So,"getBCHVersionInfo");function Ao(t,e){let r=t.getMatrixSize(),n=0;for(let o=0;o<r;o++){let i=!1,c=0;for(let f=0;f<r;f++){let u=e?t.isDark(o,f):t.isDark(f,o);u===i?(c++,c===5?n+=qi:c>5&&n++):(i=u,c=1)}}return n}s(Ao,"applyMaskPenaltyRule1Internal");function os(t){return Ao(t,!0)+Ao(t,!1)}s(os,"applyMaskPenaltyRule1");function is(t){let e=t.getMatrixSize(),r=0;for(let n=0;n<e-1;n++)for(let o=0;o<e-1;o++){let i=t.isDark(n,o);i===t.isDark(n,o+1)&&i===t.isDark(n+1,o)&&i===t.isDark(n+1,o+1)&&(r+=es)}return r}s(is,"applyMaskPenaltyRule2");function Ot(t,e,r,n,o){r=Math.max(r,0),n=Math.min(n,t.getMatrixSize());for(let i=r;i<n;i++)if(o?t.isDark(e,i):t.isDark(i,e))return!1;return!0}s(Ot,"isFourWhite");function ss(t){let e=t.getMatrixSize(),r=0;for(let n=0;n<e;n++)for(let o=0;o<e;o++)o+6<e&&t.isDark(n,o)&&!t.isDark(n,o+1)&&t.isDark(n,o+2)&&t.isDark(n,o+3)&&t.isDark(n,o+4)&&!t.isDark(n,o+5)&&t.isDark(n,o+6)&&(Ot(t,n,o-4,o,!0)||Ot(t,n,o+7,o+11,!0))&&(r+=Eo),n+6<e&&t.isDark(n,o)&&!t.isDark(n+1,o)&&t.isDark(n+2,o)&&t.isDark(n+3,o)&&t.isDark(n+4,o)&&!t.isDark(n+5,o)&&t.isDark(n+6,o)&&(Ot(t,o,n-4,n,!1)||Ot(t,o,n+7,n+11,!1))&&(r+=Eo);return r}s(ss,"applyMaskPenaltyRule3");function cs(t){let e=t.getMatrixSize(),r=0;for(let i=0;i<e;i++)for(let c=0;c<e;c++)t.isDark(i,c)&&r++;let n=e*e;return Math.floor(Math.abs(r*20-n*10)/n)*ts}s(cs,"applyMaskPenaltyRule4");function Io(t){return os(t)+is(t)+ss(t)+cs(t)}s(Io,"calculateMaskPenalty");var O;(function(t){t[t.L=1]="L",t[t.M=0]="M",t[t.Q=3]="Q",t[t.H=2]="H"})(O||(O={}));var V=class V{constructor(e,r){this.dataCount=r,this.totalCount=e}getDataCount(){return this.dataCount}getTotalCount(){return this.totalCount}static getRSBlocks(e,r){let n=[],o=V.getRSBlockTable(e,r),i=o.length/3;for(let c=0;c<i;c++){let f=o[c*3+0],u=o[c*3+1],d=o[c*3+2];for(let h=0;h<f;h++)n.push(new V(u,d))}return n}static getRSBlockTable(e,r){switch(r){case O.L:return V.RS_BLOCK_TABLE[(e-1)*4+0];case O.M:return V.RS_BLOCK_TABLE[(e-1)*4+1];case O.Q:return V.RS_BLOCK_TABLE[(e-1)*4+2];case O.H:return V.RS_BLOCK_TABLE[(e-1)*4+3];default:throw new Error(`illegal error correction level: ${r}`)}}};s(V,"RSBlock");var Oe=V;Oe.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];var Ar=class Ar{constructor(){this.length=0,this.buffer=[]}getBuffer(){return this.buffer}getLengthInBits(){return this.length}getBit(e){return(this.buffer[e/8>>0]>>>7-e%8&1)===1}put(e,r){for(let n=0;n<r;n++)this.putBit((e>>>r-n-1&1)===1)}putBit(e){let{buffer:r}=this;this.length===r.length*8&&r.push(0),e&&(r[this.length/8>>0]|=128>>>this.length%8),this.length++}};s(Ar,"BitBuffer");var ve=Ar;var Br=class Br{constructor(e){let r=1<<e,n=r+1;this.bof=r,this.eof=n,this.depth=e,this.reset()}reset(){let e=this.depth+1;this.bits=e,this.size=1<<e,this.codes=new Map,this.unused=this.eof+1}add(e,r){let{unused:n}=this;if(n>4095)return!1;this.codes.set(e<<8|r,n++);let{bits:o,size:i}=this;return n>i&&(i=1<<++o),this.bits=o,this.size=i,this.unused=n,!0}get(e,r){return this.codes.get(e<<8|r)}};s(Br,"Dict");var vt=Br;var _r=class _r{constructor(e){this.bits=0,this.buffer=0,this.bytes=[],this.dict=e}write(e){let{bits:r}=this,n=this.buffer|e<<r;r+=this.dict.bits;let{bytes:o}=this;for(;r>=8;)o.push(n&255),n>>=8,r-=8;this.bits=r,this.buffer=n}pipe(e){let{bytes:r}=this;this.bits>0&&r.push(this.buffer),e.writeByte(this.dict.depth);let{length:n}=r;for(let o=0;o<n;){let i=n-o;i>=255?(e.writeByte(255),e.writeBytes(r,o,255),o+=255):(e.writeByte(i),e.writeBytes(r,o,i),o=n)}e.writeByte(0)}};s(_r,"DictStream");var Nt=_r;function Mo(t,e,r){let n=new vt(e),o=new Nt(n);if(o.write(n.bof),t.length>0){let i=t[0],{length:c}=t;for(let f=1;f<c;f++){let u=t[f],d=n.get(i,u);d!=null?i=d:(o.write(i),n.add(i,u)||(o.write(n.bof),n.reset()),i=u)}o.write(i)}o.write(n.eof),o.pipe(r)}s(Mo,"compress");var kr=class kr{constructor(){this.bytes=[]}writeByte(e){this.bytes.push(e&255)}writeInt16(e){this.bytes.push(e&255,e>>8&255)}writeBytes(e,r=0,n=e.length){let o=this.bytes;for(let i=0;i<n;i++)o.push(e[r+i]&255)}};s(kr,"ByteStream");var pe=kr;var{fromCharCode:Dr}=String;function Ro(t){if(t&=63,t>=0){if(t<26)return 65+t;if(t<52)return 97+(t-26);if(t<62)return 48+(t-52);if(t===62)return 43;if(t===63)return 47}throw new Error(`illegal char: ${Dr(t)}`)}s(Ro,"encode");var Ur=class Ur{constructor(){this.bits=0,this.buffer=0,this.length=0,this.stream=new pe}get bytes(){return this.stream.bytes}write(e){let r=this.bits+8,{stream:n}=this,o=this.buffer<<8|e&255;for(;r>=6;)n.writeByte(Ro(o>>>r-6)),r-=6;this.length++,this.bits=r,this.buffer=o}close(){let{bits:e,stream:r,length:n}=this;if(e>0&&(r.writeByte(Ro(this.buffer<<6-e)),this.bits=0,this.buffer=0),n%3!=0){let o=3-n%3;for(let i=0;i<o;i++)r.writeByte(61)}}};s(Ur,"Base64Stream");var Lt=Ur;var Sr=class Sr{constructor(e,r,{foreground:n=[0,0,0],background:o=[255,255,255]}={}){this.pixels=[],this.width=e,this.height=r,this.foreground=n,this.background=o}encodeImpl(){let e=new pe,{width:r,height:n,background:o,foreground:i}=this;return e.writeBytes([71,73,70,56,57,97]),e.writeInt16(r),e.writeInt16(n),e.writeBytes([128,0,0]),e.writeBytes([o[0],o[1],o[2]]),e.writeBytes([i[0],i[1],i[2]]),e.writeByte(44),e.writeInt16(0),e.writeInt16(0),e.writeInt16(r),e.writeInt16(n),e.writeByte(0),Mo(this.pixels,2,e),e.writeByte(59),e.bytes}set(e,r,n){this.pixels[r*this.width+e]=n}toDataURL(){let e=this.encodeImpl(),r=new Lt;for(let i of e)r.write(i);r.close();let n=r.bytes,o="data:image/gif;base64,";for(let i of n)o+=Dr(i);return o}};s(Sr,"GIFImage");var Ft=Sr;function Oo(t){switch(t){case 0:return(e,r)=>(e+r&1)===0;case 1:return(e,r)=>(r&1)===0;case 2:return(e,r)=>e%3===0;case 3:return(e,r)=>(e+r)%3===0;case 4:return(e,r)=>((e/3>>0)+(r/2>>0)&1)===0;case 5:return(e,r)=>(e*r&1)+e*r%3===0;case 6:return(e,r)=>((e*r&1)+e*r%3&1)===0;case 7:return(e,r)=>(e*r%3+(e+r&1)&1)===0;default:throw new Error(`illegal mask: ${t}`)}}s(Oo,"getMaskFunc");var as=236,fs=17,{toString:us}=Object.prototype;function ds(t,e){if(t<0||t>=1e6)throw new Error("byte mode encoding hint out of range");e.put(E.ECI,4),t<128?e.put(t,8):t<16384?(e.put(2,2),e.put(t,14)):(e.put(6,3),e.put(t,21))}s(ds,"appendECI");function vo(t,e,r,n){let o=new ve,i=Oe.getRSBlocks(t,e);for(let f of n){let u=f.mode;r&&u===E.Byte&&ds(f.encoding,o),o.put(u,4),o.put(f.getLength(),f.getLengthInBits(t)),f.writeTo(o)}let c=0;for(let f of i)c+=f.getDataCount();return c*=8,[o,i,c]}s(vo,"prepareData");function ls(t,e){let r=0,n=0,o=0,i=[],c=[],f=e.length,u=t.getBuffer();for(let d=0;d<f;d++){let h=e[d],x=h.getDataCount(),g=h.getTotalCount()-x;n=Math.max(n,x),o=Math.max(o,g),i[d]=[];for(let L=0;L<x;L++)i[d][L]=255&u[L+r];r+=x;let w=Do(g),U=w.getLength()-1,$e=new ee(i[d],U).mod(w),$t=$e.getLength();c[d]=[];for(let L=0;L<U;L++){let Pe=L+$t-U;c[d][L]=Pe>=0?$e.getAt(Pe):0}}t=new ve;for(let d=0;d<n;d++)for(let h=0;h<f;h++)d<i[h].length&&t.put(i[h][d],8);for(let d=0;d<o;d++)for(let h=0;h<f;h++)d<c[h].length&&t.put(c[h][d],8);return t}s(ls,"createBytes");function ps(t,e,r){for(t.getLengthInBits()+4<=r&&t.put(0,4);t.getLengthInBits()%8!==0;)t.putBit(!1);for(;!(t.getLengthInBits()>=r||(t.put(as,8),t.getLengthInBits()>=r));)t.put(fs,8);return ls(t,e)}s(ps,"createData");var Ir=class Ir{constructor(e={}){this.matrixSize=0,this.chunks=[],this.matrix=[];let{version:r=0,encodingHint:n=!1,errorCorrectionLevel:o=O.L}=e;this.setVersion(r),this.setEncodingHint(n),this.setErrorCorrectionLevel(o)}getMatrix(){return this.matrix}getMatrixSize(){return this.matrixSize}getVersion(){return this.version}setVersion(e){return this.version=Math.min(40,Math.max(0,e>>0)),this.auto=this.version===0,this}getErrorCorrectionLevel(){return this.errorCorrectionLevel}setErrorCorrectionLevel(e){switch(e){case O.L:case O.M:case O.Q:case O.H:this.errorCorrectionLevel=e}return this}getEncodingHint(){return this.encodingHint}setEncodingHint(e){return this.encodingHint=e,this}write(e){let{chunks:r}=this;if(e instanceof Q)r.push(e);else if(us.call(e)==="[object String]")r.push(new Rt(e));else throw new Error(`illegal data: ${e}`);return this}isDark(e,r){return this.matrix[e][r]===!0}setupFinderPattern(e,r){let{matrix:n}=this,o=this.matrixSize;for(let i=-1;i<=7;i++)for(let c=-1;c<=7;c++)e+i<=-1||o<=e+i||r+c<=-1||o<=r+c||(0<=i&&i<=6&&(c===0||c===6)||0<=c&&c<=6&&(i===0||i===6)||2<=i&&i<=4&&2<=c&&c<=4?n[e+i][r+c]=!0:n[e+i][r+c]=!1)}setupAlignmentPattern(){let{matrix:e}=this,r=ko(this.version),{length:n}=r;for(let o=0;o<n;o++)for(let i=0;i<n;i++){let c=r[o],f=r[i];if(e[c][f]===null)for(let u=-2;u<=2;u++)for(let d=-2;d<=2;d++)u===-2||u===2||d===-2||d===2||u===0&&d===0?e[c+u][f+d]=!0:e[c+u][f+d]=!1}}setupTimingPattern(){let{matrix:e}=this,r=this.matrixSize-8;for(let n=8;n<r;n++){let o=n%2===0;e[n][6]===null&&(e[n][6]=o),e[6][n]===null&&(e[6][n]=o)}}setupFormatInfo(e){let{matrix:r}=this,n=this.errorCorrectionLevel<<3|e,o=So(n),i=this.matrixSize;for(let c=0;c<15;c++){let f=(o>>c&1)===1;c<6?r[c][8]=f:c<8?r[c+1][8]=f:r[i-15+c][8]=f,c<8?r[8][i-c-1]=f:c<9?r[8][15-c-1+1]=f:r[8][15-c-1]=f}r[i-8][8]=!0}setupVersionInfo(){if(this.version>=7){let{matrix:e}=this,r=this.matrixSize,n=Uo(this.version);for(let o=0;o<18;o++){let i=(n>>o&1)===1;e[o/3>>0][o%3+r-8-3]=i,e[o%3+r-8-3][o/3>>0]=i}}}setupCodewords(e,r){let{matrix:n}=this,o=this.matrixSize,i=e.getLengthInBits(),c=Oo(r),f=0;for(let u=o-1;u>=1;u-=2){u===6&&(u=5);for(let d=0;d<o;d++)for(let h=0;h<2;h++){let x=u-h,w=(u+1&2)===0?o-1-d:d;if(n[w][x]!==null)continue;let U=!1;f<i&&(U=e.getBit(f++)),c(x,w)&&(U=!U),n[w][x]=U}}}buildMatrix(e,r){let n=[],o=this.matrixSize;for(let i=0;i<o;i++){n[i]=[];for(let c=0;c<o;c++)n[i][c]=null}this.matrix=n,this.setupFinderPattern(0,0),this.setupFinderPattern(o-7,0),this.setupFinderPattern(0,o-7),this.setupAlignmentPattern(),this.setupTimingPattern(),this.setupFormatInfo(r),this.setupVersionInfo(),this.setupCodewords(e,r)}make(){let e,r,n,{chunks:o,errorCorrectionLevel:i}=this;if(this.auto){let h=1;for(;h<=40&&([e,r,n]=vo(h,i,this.encodingHint,o),!(e.getLengthInBits()<=n));h++);let x=e.getLengthInBits();if(x>n)throw new Error(`data overflow: ${x} > ${n}`);this.version=h}else[e,r,n]=vo(this.version,i,this.encodingHint,o);this.matrixSize=this.version*4+17;let c=[],f=ps(e,r,n),u=-1,d=Number.MAX_VALUE;for(let h=0;h<8;h++){this.buildMatrix(f,h),c.push(this.matrix);let x=Io(this);x<d&&(d=x,u=h)}return this.matrix=c[u],this}toDataURL(e=2,r=e*4,n){e=Math.max(1,e>>0),r=Math.max(0,r>>0);let o=this.matrixSize,i=e*o+r*2,c=r,f=i-r,u=new Ft(i,i,n);for(let d=0;d<i;d++)for(let h=0;h<i;h++)if(c<=h&&h<f&&c<=d&&d<f){let x=(d-c)/e>>0,g=(h-c)/e>>0;u.set(h,d,this.isDark(x,g)?1:0)}else u.set(h,d,0);return u.toDataURL()}clear(){this.chunks=[]}};s(Ir,"Encoder");var Ne=Ir;function No(t){let{length:e}=t,r=[];for(let n=0;n<e;n++)r.push(t.charCodeAt(n));return r}s(No,"encode");function Mr(t){if(48<=t&&t<=57)return t-48;if(65<=t&&t<=90)return t-65+10;switch(t){case 32:return 36;case 36:return 37;case 37:return 38;case 42:return 39;case 43:return 40;case 45:return 41;case 46:return 42;case 47:return 43;case 58:return 44;default:throw new Error(`illegal char: ${String.fromCharCode(t)}`)}}s(Mr,"getByte");var Rr=class Rr extends Q{constructor(e){super(E.Alphanumeric,e),this.bytes=No(e)}writeTo(e){let r=0,{bytes:n}=this,{length:o}=n;for(;r+1<o;)e.put(Mr(n[r])*45+Mr(n[r+1]),11),r+=2;r<o&&e.put(Mr(n[r]),6)}};s(Rr,"QRAlphanumeric");var Le=Rr;var Fo="VP1",$o="B";function hs({bytes:t,size:e}){let r=new Ne;r.setEncodingHint(!0);let n=br(t,"RFC4648",{padding:!1}),o=`${Fo}-${$o}${n}`;return r.write(new Le(o)),r.make(),{payload:o,encodedCborld:n,version:r.getVersion(),imageDataUrl:r.toDataURL(e)}}s(hs,"_bytesToQrCodeDataUrl");async function Or({vp:t,documentLoader:e,size:r,diagnose:n}={}){let o=await yr({jsonldDocument:t,documentLoader:e,diagnose:n}),{payload:i,imageDataUrl:c,encodedCborld:f,version:u}=hs({bytes:o,size:r});return{payload:i,imageDataUrl:c,encodedCborld:f,rawCborldBytes:o,version:u}}s(Or,"toQrCode");async function vr({text:t,documentLoader:e,diagnose:r}={}){let n=Fo+"-";if(!(t&&t.startsWith(n)))throw TypeError("Unsupported VP QR format.");let o=t.slice(n.length);if(!o.startsWith($o))throw TypeError("Payload must be multibase base32 (RFC4648) encoded.");let i=(0,Lo.default)(o.slice(1),"RFC4648"),c=new Uint8Array(i);return{vp:await hr({cborldBytes:c,documentLoader:e,diagnose:r})}}s(vr,"fromQrCode");var ms=s(t=>({name:"Vpqr",displayName:"VP QR",description:"Allows reading and creating QR codes with Verifiable Presentations in them",methods:{vpFromQrCode:s(async(e,r)=>(await vr({text:r,documentLoader:s(async n=>({document:await t.invoke.contextLoader(n)}),"documentLoader")}))?.vp,"vpFromQrCode"),vpToQrCode:s(async(e,r)=>(await Or({vp:r,documentLoader:s(async n=>({document:await t.invoke.contextLoader(n)}),"documentLoader")}))?.imageDataUrl,"vpToQrCode")}}),"getVpqrPlugin");
1
+ "use strict";var Xo=Object.create;var pe=Object.defineProperty;var Go=Object.getOwnPropertyDescriptor;var Jo=Object.getOwnPropertyNames;var Zo=Object.getPrototypeOf,Yo=Object.prototype.hasOwnProperty;var i=(t,e)=>pe(t,"name",{value:e,configurable:!0});var qo=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),es=(t,e)=>{for(var r in e)pe(t,r,{get:e[r],enumerable:!0})},Hr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Jo(e))!Yo.call(t,o)&&o!==r&&pe(t,o,{get:()=>e[o],enumerable:!(n=Go(e,o))||n.enumerable});return t};var ts=(t,e,r)=>(r=t!=null?Xo(Zo(t)):{},Hr(e||!t||!t.__esModule?pe(r,"default",{value:t,enumerable:!0}):r,t)),rs=t=>Hr(pe({},"__esModule",{value:!0}),t);var Do=qo((ju,Bo)=>{"use strict";var ai="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",fi="0123456789ABCDEFGHIJKLMNOPQRSTUV",ui="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function di(t,e){var r=t.indexOf(e);if(r===-1)throw new Error("Invalid character found: "+e);return r}i(di,"readChar");Bo.exports=i(function(e,r){var n;switch(r){case"RFC3548":case"RFC4648":n=ai,e=e.replace(/=+$/,"");break;case"RFC4648-HEX":n=fi,e=e.replace(/=+$/,"");break;case"Crockford":n=ui,e=e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1");break;default:throw new Error("Unknown base32 variant: "+r)}for(var o=e.length,s=0,c=0,f=0,u=new Uint8Array(o*5/8|0),d=0;d<o;d++)c=c<<5|di(n,e[d]),s+=5,s>=8&&(u[f++]=c>>>s-8&255,s-=8);return u.buffer},"base32Decode")});var Ii={};es(Ii,{getVpqrPlugin:()=>Ui});module.exports=rs(Ii);var ns=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Wt(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(e==="string"||e==="number"||e==="bigint"||e==="symbol")return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(t instanceof Uint8Array)return"Uint8Array";if(t.constructor===Object)return"Object";let r=os(t);return r||"Object"}i(Wt,"is");function os(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(ns.includes(e))return e}i(os,"getObjectType");var Qt=class Qt{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}static equals(e,r){return e===r||e.major===r.major&&e.name===r.name}};i(Qt,"Type");var a=Qt;a.uint=new a(0,"uint",!0);a.negint=new a(1,"negint",!0);a.bytes=new a(2,"bytes",!0);a.string=new a(3,"string",!0);a.array=new a(4,"array",!1);a.map=new a(5,"map",!1);a.tag=new a(6,"tag",!1);a.float=new a(7,"float",!0);a.false=new a(7,"false",!0);a.true=new a(7,"true",!0);a.null=new a(7,"null",!0);a.undefined=new a(7,"undefined",!0);a.break=new a(7,"break",!0);var Xt=class Xt{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};i(Xt,"Token");var l=Xt;var he=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",ss=new TextEncoder;function Ke(t){return he&&globalThis.Buffer.isBuffer(t)}i(Ke,"isBuffer");function me(t){return t instanceof Uint8Array?Ke(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}i(me,"asU8A");var is=24,cs=200,We=he?t=>t.length>=is?globalThis.Buffer.from(t):Kr(t):t=>t.length>=cs?ss.encode(t):Kr(t),j=i(t=>Uint8Array.from(t),"fromArray"),Wr=he?(t,e,r)=>Ke(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),Qr=he?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),me(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let o of t)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Xr=he?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function Qe(t,e){if(Ke(t)&&Ke(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}i(Qe,"compare");function Kr(t){let e=[],r=0;for(let n=0;n<t.length;n++){let o=t.charCodeAt(n);o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(t.charCodeAt(++n)&1023),e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128)}return e}i(Kr,"utf8ToBytes");var as=256,Gt=class Gt{constructor(e=as){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(e,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(r=Xr(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Wr(n,0,this.cursor)}else r=Qr(this.chunks,this.cursor);return e&&this.reset(),r}};i(Gt,"Bl");var xe=Gt,Jt=class Jt{constructor(e){this.dest=e,this.cursor=0,this.chunks=[e]}reset(){this.cursor=0}push(e){if(this.cursor+e.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(e,this.cursor),this.cursor+=e.length}toBytes(e=!1){let r=this.dest.subarray(0,this.cursor);return e&&this.reset(),r}};i(Jt,"U8Bl");var Xe=Jt;var m="CBOR decode error:",Ge="CBOR encode error:",ge=[];ge[23]=1;ge[24]=2;ge[25]=3;ge[26]=5;ge[27]=9;function V(t,e,r){if(t.length-e<r)throw new Error(`${m} not enough data for type`)}i(V,"assertEnoughData");var B=[24,256,65536,4294967296,BigInt("18446744073709551616")];function k(t,e,r){V(t,e,1);let n=t[e];if(r.strict===!0&&n<B[0])throw new Error(`${m} integer encoded in more bytes than necessary (strict decode)`);return n}i(k,"readUint8");function M(t,e,r){V(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<B[1])throw new Error(`${m} integer encoded in more bytes than necessary (strict decode)`);return n}i(M,"readUint16");function S(t,e,r){V(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<B[2])throw new Error(`${m} integer encoded in more bytes than necessary (strict decode)`);return n}i(S,"readUint32");function R(t,e,r){V(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],o=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],s=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&s<B[3])throw new Error(`${m} integer encoded in more bytes than necessary (strict decode)`);if(s<=Number.MAX_SAFE_INTEGER)return Number(s);if(r.allowBigInt===!0)return s;throw new Error(`${m} integers outside of the safe integer range are not supported`)}i(R,"readUint64");function Gr(t,e,r,n){return new l(a.uint,k(t,e+1,n),2)}i(Gr,"decodeUint8");function Jr(t,e,r,n){return new l(a.uint,M(t,e+1,n),3)}i(Jr,"decodeUint16");function Zr(t,e,r,n){return new l(a.uint,S(t,e+1,n),5)}i(Zr,"decodeUint32");function Yr(t,e,r,n){return new l(a.uint,R(t,e+1,n),9)}i(Yr,"decodeUint64");function N(t,e){return b(t,0,e.value)}i(N,"encodeUint");function b(t,e,r){if(r<B[0]){let n=Number(r);t.push([e|n])}else if(r<B[1]){let n=Number(r);t.push([e|24,n])}else if(r<B[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<B[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<B[4]){let o=[e|27,0,0,0,0,0,0,0],s=Number(n&BigInt(4294967295)),c=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=s&255,s=s>>8,o[7]=s&255,s=s>>8,o[6]=s&255,s=s>>8,o[5]=s&255,o[4]=c&255,c=c>>8,o[3]=c&255,c=c>>8,o[2]=c&255,c=c>>8,o[1]=c&255,t.push(o)}else throw new Error(`${m} encountered BigInt larger than allowable range`)}}i(b,"encodeUintValue");N.encodedSize=i(function(e){return b.encodedSize(e.value)},"encodedSize");b.encodedSize=i(function(e){return e<B[0]?1:e<B[1]?2:e<B[2]?3:e<B[3]?5:9},"encodedSize");N.compareTokens=i(function(e,r){return e.value<r.value?-1:e.value>r.value?1:0},"compareTokens");function qr(t,e,r,n){return new l(a.negint,-1-k(t,e+1,n),2)}i(qr,"decodeNegint8");function en(t,e,r,n){return new l(a.negint,-1-M(t,e+1,n),3)}i(en,"decodeNegint16");function tn(t,e,r,n){return new l(a.negint,-1-S(t,e+1,n),5)}i(tn,"decodeNegint32");var Zt=BigInt(-1),rn=BigInt(1);function nn(t,e,r,n){let o=R(t,e+1,n);if(typeof o!="bigint"){let s=-1-o;if(s>=Number.MIN_SAFE_INTEGER)return new l(a.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${m} integers outside of the safe integer range are not supported`);return new l(a.negint,Zt-BigInt(o),9)}i(nn,"decodeNegint64");function Je(t,e){let r=e.value,n=typeof r=="bigint"?r*Zt-rn:r*-1-1;b(t,e.type.majorEncoded,n)}i(Je,"encodeNegint");Je.encodedSize=i(function(e){let r=e.value,n=typeof r=="bigint"?r*Zt-rn:r*-1-1;return n<B[0]?1:n<B[1]?2:n<B[2]?3:n<B[3]?5:9},"encodedSize");Je.compareTokens=i(function(e,r){return e.value<r.value?1:e.value>r.value?-1:0},"compareTokens");function ye(t,e,r,n){V(t,e,r+n);let o=t.slice(e+r,e+r+n);return new l(a.bytes,o,r+n)}i(ye,"toToken");function on(t,e,r,n){return ye(t,e,1,r)}i(on,"decodeBytesCompact");function sn(t,e,r,n){return ye(t,e,2,k(t,e+1,n))}i(sn,"decodeBytes8");function cn(t,e,r,n){return ye(t,e,3,M(t,e+1,n))}i(cn,"decodeBytes16");function an(t,e,r,n){return ye(t,e,5,S(t,e+1,n))}i(an,"decodeBytes32");function fn(t,e,r,n){let o=R(t,e+1,n);if(typeof o=="bigint")throw new Error(`${m} 64-bit integer bytes lengths not supported`);return ye(t,e,9,o)}i(fn,"decodeBytes64");function Ze(t){return t.encodedBytes===void 0&&(t.encodedBytes=a.equals(t.type,a.string)?We(t.value):t.value),t.encodedBytes}i(Ze,"tokenBytes");function re(t,e){let r=Ze(e);b(t,e.type.majorEncoded,r.length),t.push(r)}i(re,"encodeBytes");re.encodedSize=i(function(e){let r=Ze(e);return b.encodedSize(r.length)+r.length},"encodedSize");re.compareTokens=i(function(e,r){return us(Ze(e),Ze(r))},"compareTokens");function us(t,e){return t.length<e.length?-1:t.length>e.length?1:Qe(t,e)}i(us,"compareBytes");var un=new TextDecoder,ls=32;function ps(t,e,r){if(r-e<ls){let o="";for(let s=e;s<r;s++){let c=t[s];if(c&128)return un.decode(t.subarray(e,r));o+=String.fromCharCode(c)}return o}return un.decode(t.subarray(e,r))}i(ps,"toStr");function we(t,e,r,n,o){let s=r+n;V(t,e,s);let c=new l(a.string,ps(t,e+r,e+s),s);return o.retainStringBytes===!0&&(c.byteValue=t.slice(e+r,e+s)),c}i(we,"toToken");function dn(t,e,r,n){return we(t,e,1,r,n)}i(dn,"decodeStringCompact");function ln(t,e,r,n){return we(t,e,2,k(t,e+1,n),n)}i(ln,"decodeString8");function pn(t,e,r,n){return we(t,e,3,M(t,e+1,n),n)}i(pn,"decodeString16");function hn(t,e,r,n){return we(t,e,5,S(t,e+1,n),n)}i(hn,"decodeString32");function mn(t,e,r,n){let o=R(t,e+1,n);if(typeof o=="bigint")throw new Error(`${m} 64-bit integer string lengths not supported`);return we(t,e,9,o,n)}i(mn,"decodeString64");var xn=re;function ne(t,e,r,n){return new l(a.array,n,r)}i(ne,"toToken");function gn(t,e,r,n){return ne(t,e,1,r)}i(gn,"decodeArrayCompact");function yn(t,e,r,n){return ne(t,e,2,k(t,e+1,n))}i(yn,"decodeArray8");function wn(t,e,r,n){return ne(t,e,3,M(t,e+1,n))}i(wn,"decodeArray16");function bn(t,e,r,n){return ne(t,e,5,S(t,e+1,n))}i(bn,"decodeArray32");function En(t,e,r,n){let o=R(t,e+1,n);if(typeof o=="bigint")throw new Error(`${m} 64-bit integer array lengths not supported`);return ne(t,e,9,o)}i(En,"decodeArray64");function Cn(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${m} indefinite length items not allowed`);return ne(t,e,1,1/0)}i(Cn,"decodeArrayIndefinite");function Ye(t,e){b(t,a.array.majorEncoded,e.value)}i(Ye,"encodeArray");Ye.compareTokens=N.compareTokens;Ye.encodedSize=i(function(e){return b.encodedSize(e.value)},"encodedSize");function oe(t,e,r,n){return new l(a.map,n,r)}i(oe,"toToken");function Tn(t,e,r,n){return oe(t,e,1,r)}i(Tn,"decodeMapCompact");function An(t,e,r,n){return oe(t,e,2,k(t,e+1,n))}i(An,"decodeMap8");function _n(t,e,r,n){return oe(t,e,3,M(t,e+1,n))}i(_n,"decodeMap16");function Bn(t,e,r,n){return oe(t,e,5,S(t,e+1,n))}i(Bn,"decodeMap32");function Dn(t,e,r,n){let o=R(t,e+1,n);if(typeof o=="bigint")throw new Error(`${m} 64-bit integer map lengths not supported`);return oe(t,e,9,o)}i(Dn,"decodeMap64");function Un(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${m} indefinite length items not allowed`);return oe(t,e,1,1/0)}i(Un,"decodeMapIndefinite");function qe(t,e){b(t,a.map.majorEncoded,e.value)}i(qe,"encodeMap");qe.compareTokens=N.compareTokens;qe.encodedSize=i(function(e){return b.encodedSize(e.value)},"encodedSize");function In(t,e,r,n){return new l(a.tag,r,1)}i(In,"decodeTagCompact");function kn(t,e,r,n){return new l(a.tag,k(t,e+1,n),2)}i(kn,"decodeTag8");function Mn(t,e,r,n){return new l(a.tag,M(t,e+1,n),3)}i(Mn,"decodeTag16");function Sn(t,e,r,n){return new l(a.tag,S(t,e+1,n),5)}i(Sn,"decodeTag32");function Rn(t,e,r,n){return new l(a.tag,R(t,e+1,n),9)}i(Rn,"decodeTag64");function et(t,e){b(t,a.tag.majorEncoded,e.value)}i(et,"encodeTag");et.compareTokens=N.compareTokens;et.encodedSize=i(function(e){return b.encodedSize(e.value)},"encodedSize");var Yt=20,qt=21,er=22,tr=23;function On(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${m} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new l(a.null,null,1):new l(a.undefined,void 0,1)}i(On,"decodeUndefined");function Nn(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${m} indefinite length items not allowed`);return new l(a.break,void 0,1)}i(Nn,"decodeBreak");function rr(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${m} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${m} Infinity values are not supported`)}return new l(a.float,t,e)}i(rr,"createToken");function vn(t,e,r,n){return rr(nr(t,e+1),3,n)}i(vn,"decodeFloat16");function Ln(t,e,r,n){return rr(or(t,e+1),5,n)}i(Ln,"decodeFloat32");function Fn(t,e,r,n){return rr(zn(t,e+1),9,n)}i(Fn,"decodeFloat64");function be(t,e,r){let n=e.value;if(n===!1)t.push([a.float.majorEncoded|Yt]);else if(n===!0)t.push([a.float.majorEncoded|qt]);else if(n===null)t.push([a.float.majorEncoded|er]);else if(n===void 0)t.push([a.float.majorEncoded|tr]);else{let o,s=!1;(!r||r.float64!==!0)&&(Pn(n),o=nr(F,1),n===o||Number.isNaN(n)?(F[0]=249,t.push(F.slice(0,3)),s=!0):(jn(n),o=or(F,1),n===o&&(F[0]=250,t.push(F.slice(0,5)),s=!0))),s||(ys(n),o=zn(F,1),F[0]=251,t.push(F.slice(0,9)))}}i(be,"encodeFloat");be.encodedSize=i(function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Pn(n);let o=nr(F,1);if(n===o||Number.isNaN(n))return 3;if(jn(n),o=or(F,1),n===o)return 5}return 9},"encodedSize");var $n=new ArrayBuffer(9),v=new DataView($n,1),F=new Uint8Array($n,0);function Pn(t){if(t===1/0)v.setUint16(0,31744,!1);else if(t===-1/0)v.setUint16(0,64512,!1);else if(Number.isNaN(t))v.setUint16(0,32256,!1);else{v.setFloat32(0,t);let e=v.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)v.setUint16(0,31744,!1);else if(r===0)v.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?v.setUint16(0,0):o<-14?v.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):v.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}i(Pn,"encodeFloat16");function nr(t,e){if(t.length-e<2)throw new Error(`${m} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,s;return n===0?s=o*2**-24:n!==31?s=(o+1024)*2**(n-25):s=o===0?1/0:NaN,r&32768?-s:s}i(nr,"readFloat16");function jn(t){v.setFloat32(0,t,!1)}i(jn,"encodeFloat32");function or(t,e){if(t.length-e<4)throw new Error(`${m} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}i(or,"readFloat32");function ys(t){v.setFloat64(0,t,!1)}i(ys,"encodeFloat64");function zn(t,e){if(t.length-e<8)throw new Error(`${m} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}i(zn,"readFloat64");be.compareTokens=N.compareTokens;function y(t,e,r){throw new Error(`${m} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}i(y,"invalidMinor");function tt(t){return()=>{throw new Error(`${m} ${t}`)}}i(tt,"errorer");var p=[];for(let t=0;t<=23;t++)p[t]=y;p[24]=Gr;p[25]=Jr;p[26]=Zr;p[27]=Yr;p[28]=y;p[29]=y;p[30]=y;p[31]=y;for(let t=32;t<=55;t++)p[t]=y;p[56]=qr;p[57]=en;p[58]=tn;p[59]=nn;p[60]=y;p[61]=y;p[62]=y;p[63]=y;for(let t=64;t<=87;t++)p[t]=on;p[88]=sn;p[89]=cn;p[90]=an;p[91]=fn;p[92]=y;p[93]=y;p[94]=y;p[95]=tt("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)p[t]=dn;p[120]=ln;p[121]=pn;p[122]=hn;p[123]=mn;p[124]=y;p[125]=y;p[126]=y;p[127]=tt("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)p[t]=gn;p[152]=yn;p[153]=wn;p[154]=bn;p[155]=En;p[156]=y;p[157]=y;p[158]=y;p[159]=Cn;for(let t=160;t<=183;t++)p[t]=Tn;p[184]=An;p[185]=_n;p[186]=Bn;p[187]=Dn;p[188]=y;p[189]=y;p[190]=y;p[191]=Un;for(let t=192;t<=215;t++)p[t]=In;p[216]=kn;p[217]=Mn;p[218]=Sn;p[219]=Rn;p[220]=y;p[221]=y;p[222]=y;p[223]=y;for(let t=224;t<=243;t++)p[t]=tt("simple values are not supported");p[244]=y;p[245]=y;p[246]=y;p[247]=On;p[248]=tt("simple values are not supported");p[249]=vn;p[250]=Ln;p[251]=Fn;p[252]=y;p[253]=y;p[254]=y;p[255]=Nn;var $=[];for(let t=0;t<24;t++)$[t]=new l(a.uint,t,1);for(let t=-1;t>=-24;t--)$[31-t]=new l(a.negint,t,1);$[64]=new l(a.bytes,new Uint8Array(0),1);$[96]=new l(a.string,"",1);$[128]=new l(a.array,0,1);$[160]=new l(a.map,0,1);$[244]=new l(a.false,!1,1);$[245]=new l(a.true,!0,1);$[246]=new l(a.null,null,1);function sr(t){switch(t.type){case a.false:return j([244]);case a.true:return j([245]);case a.null:return j([246]);case a.bytes:return t.value.length?void 0:j([64]);case a.string:return t.value===""?j([96]):void 0;case a.array:return t.value===0?j([128]):void 0;case a.map:return t.value===0?j([160]):void 0;case a.uint:return t.value<24?j([Number(t.value)]):void 0;case a.negint:if(t.value>=-24)return j([31-Number(t.value)])}}i(sr,"quickEncodeToken");var bs={float64:!1,mapSorter:Ts,quickEncodeToken:sr},Qn=Object.freeze({float64:!0,mapSorter:As,quickEncodeToken:sr});function Es(){let t=[];return t[a.uint.major]=N,t[a.negint.major]=Je,t[a.bytes.major]=re,t[a.string.major]=xn,t[a.array.major]=Ye,t[a.map.major]=qe,t[a.tag.major]=et,t[a.float.major]=be,t}i(Es,"makeCborEncoders");var se=Es(),rt=new xe,ot=class ot{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${Ge} object contains circular references`);return new ot(r,e)}};i(ot,"Ref");var Ce=ot,K={null:new l(a.null,null),undefined:new l(a.undefined,void 0),true:new l(a.true,!0),false:new l(a.false,!1),emptyArray:new l(a.array,0),emptyMap:new l(a.map,0)},z={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new l(a.float,t):t>=0?new l(a.uint,t):new l(a.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new l(a.uint,t):new l(a.negint,t)},Uint8Array(t,e,r,n){return new l(a.bytes,t)},string(t,e,r,n){return new l(a.string,t)},boolean(t,e,r,n){return t?K.true:K.false},null(t,e,r,n){return K.null},undefined(t,e,r,n){return K.undefined},ArrayBuffer(t,e,r,n){return new l(a.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new l(a.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[K.emptyArray,new l(a.break)]:K.emptyArray;n=Ce.createCheck(n,t);let o=[],s=0;for(let c of t)o[s++]=nt(c,r,n);return r.addBreakTokens?[new l(a.array,t.length),o,new l(a.break)]:[new l(a.array,t.length),o]},Object(t,e,r,n){let o=e!=="Object",s=o?t.keys():Object.keys(t),c=o?t.size:s.length,f;if(c){f=new Array(c),n=Ce.createCheck(n,t);let u=!o&&r.ignoreUndefinedProperties,d=0;for(let h of s){let x=o?t.get(h):t[h];u&&x===void 0||(f[d++]=[nt(h,r,n),nt(x,r,n)])}d<c&&(f.length=d)}return f?.length?(Cs(f,r),r.addBreakTokens?[new l(a.map,f.length),f,new l(a.break)]:[new l(a.map,f.length),f]):r.addBreakTokens===!0?[K.emptyMap,new l(a.break)]:K.emptyMap}};z.Map=z.Object;z.Buffer=z.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))z[`${t}Array`]=z.DataView;function nt(t,e={},r){let n=Wt(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||z[n];if(typeof o=="function"){let c=o(t,n,e,r);if(c!=null)return c}let s=z[n];if(!s)throw new Error(`${Ge} unsupported type: ${n}`);return s(t,n,e,r)}i(nt,"objectToTokens");function Cs(t,e){e.mapSorter&&t.sort(e.mapSorter)}i(Cs,"sortMapEntries");function Ts(t,e){let r=Array.isArray(t[0])?t[0][0]:t[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,s=se[o].compareTokens(r,n);return s===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),s}i(Ts,"mapSorter");function As(t,e){if(t[0]instanceof l&&e[0]instanceof l){let r=t[0],n=e[0];return r._keyBytes||(r._keyBytes=Vn(r.value)),n._keyBytes||(n._keyBytes=Vn(n.value)),Qe(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}i(As,"rfc8949MapSorter");function Vn(t){return Gn(t,se,Qn)}i(Vn,"encodeRfc8949");function Ee(t,e,r,n){if(Array.isArray(e))for(let o of e)Ee(t,o,r,n);else r[e.type.major](t,e,n)}i(Ee,"tokensToEncoded");var Hn=a.uint.majorEncoded,Kn=a.negint.majorEncoded,_s=a.bytes.majorEncoded,Bs=a.string.majorEncoded,Wn=a.array.majorEncoded,Ds=a.float.majorEncoded|Yt,Us=a.float.majorEncoded|qt,Is=a.float.majorEncoded|er,ks=a.float.majorEncoded|tr,Ms=BigInt(-1),Ss=BigInt(1);function Rs(t){return t.addBreakTokens!==!0}i(Rs,"canDirectEncode");function Xn(t,e,r,n){let o=Wt(e),s=r.typeEncoders&&r.typeEncoders[o];if(s){let c=s(e,o,r,n);if(c!=null){Ee(t,c,se,r);return}}switch(o){case"null":t.push([Is]);return;case"undefined":t.push([ks]);return;case"boolean":t.push([e?Us:Ds]);return;case"number":!Number.isInteger(e)||!Number.isSafeInteger(e)?be(t,new l(a.float,e),r):e>=0?b(t,Hn,e):b(t,Kn,e*-1-1);return;case"bigint":e>=BigInt(0)?b(t,Hn,e):b(t,Kn,e*Ms-Ss);return;case"string":{let c=We(e);b(t,Bs,c.length),t.push(c);return}case"Uint8Array":b(t,_s,e.length),t.push(e);return;case"Array":if(!e.length){t.push([Wn]);return}n=Ce.createCheck(n,e),b(t,Wn,e.length);for(let c of e)Xn(t,c,r,n);return;case"Object":case"Map":{let c=z.Object(e,o,r,n);Ee(t,c,se,r)}return;default:{let c=z[o];if(!c)throw new Error(`${Ge} unsupported type: ${o}`);let f=c(e,o,r,n);Ee(t,f,se,r)}}}i(Xn,"directEncode");function Gn(t,e,r,n){let o=n instanceof Uint8Array,s=o?new Xe(n):rt,c=nt(t,r);if(!Array.isArray(c)&&r.quickEncodeToken){let f=r.quickEncodeToken(c);if(f)return o?(s.push(f),s.toBytes()):f;let u=e[c.type.major];if(u.encodedSize){let d=u.encodedSize(c,r);if(o||(s=new xe(d)),u(s,c,r),s.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${c} was wrong`);return o?s.toBytes():me(s.chunks[0])}}return s.reset(),Ee(s,c,e,r),s.toBytes(!0)}i(Gn,"encodeCustom");function Te(t,e){return e=Object.assign({},bs,e),Rs(e)?(rt.reset(),Xn(rt,t,e,void 0),rt.toBytes(!0)):Gn(t,se,e)}i(Te,"encode");var Os={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},ir=class ir{constructor(e,r={}){this._pos=0,this.data=e,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],r=$[e];if(r===void 0){let n=p[e];if(!n)throw new Error(`${m} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}};i(ir,"Tokeniser");var st=ir,Ae=Symbol.for("DONE"),it=Symbol.for("BREAK");function Ns(t,e,r){let n=[];for(let o=0;o<t.value;o++){let s=ie(e,r);if(s===it){if(t.value===1/0)break;throw new Error(`${m} got unexpected break to lengthed array`)}if(s===Ae)throw new Error(`${m} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=s}return n}i(Ns,"tokenToArray");function vs(t,e,r){let n=r.useMaps===!0,o=r.rejectDuplicateMapKeys===!0,s=n?void 0:{},c=n?new Map:void 0;for(let f=0;f<t.value;f++){let u=ie(e,r);if(u===it){if(t.value===1/0)break;throw new Error(`${m} got unexpected break to lengthed map`)}if(u===Ae)throw new Error(`${m} found map but not enough entries (got ${f} [no key], expected ${t.value})`);if(!n&&typeof u!="string")throw new Error(`${m} non-string keys not supported (got ${typeof u})`);if(o&&(n&&c.has(u)||!n&&Object.hasOwn(s,u)))throw new Error(`${m} found repeat map key "${u}"`);let d=ie(e,r);if(d===Ae)throw new Error(`${m} found map but not enough entries (got ${f} [no value], expected ${t.value})`);n?c.set(u,d):s[u]=d}return n?c:s}i(vs,"tokenToMap");function ie(t,e){if(t.done())return Ae;let r=t.next();if(a.equals(r.type,a.break))return it;if(r.type.terminal)return r.value;if(a.equals(r.type,a.array))return Ns(r,t,e);if(a.equals(r.type,a.map))return vs(r,t,e);if(a.equals(r.type,a.tag)){if(e.tags&&typeof e.tags[r.value]=="function"){let n=ie(t,e);return e.tags[r.value](n)}throw new Error(`${m} tag not supported (${r.value})`)}throw new Error("unsupported")}i(ie,"tokensToObject");function Jn(t,e){if(!(t instanceof Uint8Array))throw new Error(`${m} data to decode must be a Uint8Array`);e=Object.assign({},Os,e);let r=me(t),n=e.tokenizer||new st(r,e),o=ie(n,e);if(o===Ae)throw new Error(`${m} did not find any content to decode`);if(o===it)throw new Error(`${m} got unexpected break`);return[o,t.subarray(n.pos())]}i(Jn,"decodeFirst");function _e(t,e){let[r,n]=Jn(t,e);if(n.length>0)throw new Error(`${m} too many terminals, data makes no sense`);return r}i(_e,"decode");var cr=class cr extends Error{constructor(e,r){super(),this.message=r,this.value=e,this.stack=new Error(`${e}: ${r}`).stack,this.name=this.constructor.name}};i(cr,"CborldError");var T=cr;var P=new Map([["@context",0],["@type",2],["@id",4],["@value",6],["@direction",8],["@graph",10],["@included",12],["@index",14],["@json",16],["@language",18],["@list",20],["@nest",22],["@reverse",24],["@base",26],["@container",28],["@default",30],["@embed",32],["@explicit",34],["@none",36],["@omitDefault",38],["@prefix",40],["@preserve",42],["@protected",44],["@requireAll",46],["@set",48],["@version",50],["@vocab",52]]),at=100;var ar=class ar{decode({value:e}={}){throw new Error("Must be implemented by derived class.")}static createDecoder({value:e,transformer:r}={}){throw new Error("Must be implemented by derived class.")}};i(ar,"CborldDecoder");var _=ar;var fr=new Map,ur=new Map;A(16,"https://www.w3.org/ns/activitystreams");A(17,"https://www.w3.org/2018/credentials/v1");A(18,"https://www.w3.org/ns/did/v1");A(19,"https://w3id.org/security/suites/ed25519-2018/v1");A(20,"https://w3id.org/security/suites/ed25519-2020/v1");A(21,"https://w3id.org/cit/v1");A(22,"https://w3id.org/age/v1");A(23,"https://w3id.org/security/suites/x25519-2020/v1");A(24,"https://w3id.org/veres-one/v1");A(25,"https://w3id.org/webkms/v1");A(26,"https://w3id.org/zcap/v1");A(27,"https://w3id.org/security/suites/hmac-2019/v1");A(28,"https://w3id.org/security/suites/aes-2019/v1");A(29,"https://w3id.org/vaccination/v1");A(30,"https://w3id.org/vc-revocation-list-2020/v1");A(31,"https://w3id.org/dcc/v1");A(32,"https://w3id.org/vc/status-list/v1");A(48,"https://w3id.org/security/data-integrity/v1");A(49,"https://w3id.org/security/multikey/v1");A(50,"https://purl.imsglobal.org/spec/ob/v3p0/context.json");A(51,"https://w3id.org/security/data-integrity/v2");function A(t,e){ur.set(e,t),fr.set(t,e)}i(A,"_addRegistration");var ft=class ft extends _{constructor({reverseAppContextMap:e}={}){super(),this.reverseAppContextMap=e}decode({value:e}={}){if(typeof e!="number")return dr(e);let r=fr.get(e)||this.reverseAppContextMap.get(e);if(r===void 0)throw new T("ERR_UNDEFINED_COMPRESSED_CONTEXT",`Undefined compressed context "${e}".`);return r}static createDecoder({transformer:e}={}){let{reverseAppContextMap:r}=e;return new ft({reverseAppContextMap:r})}};i(ft,"ContextDecoder");var Be=ft;function dr(t){if(Array.isArray(t))return t.map(dr);if(!(t instanceof Map))return t;let e={};for(let[r,n]of t)e[r]=dr(n);return e}i(dr,"_mapToObject");function W(t,e){return JSON.stringify(t,null,2)}i(W,"inspect");var ro="3.8.0",Ls=ro,ae=typeof Buffer=="function",Zn=typeof TextDecoder=="function"?new TextDecoder("utf-8",{ignoreBOM:!0}):void 0,Yn=typeof TextEncoder=="function"?new TextEncoder:void 0,Fs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",De=Array.prototype.slice.call(Fs),ut=(t=>{let e={};return t.forEach((r,n)=>e[r]=n),e})(De),$s=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,D=String.fromCharCode.bind(String),qn=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):t=>new Uint8Array(Array.prototype.slice.call(t,0)),no=i(t=>t.replace(/=/g,"").replace(/[+\/]/g,e=>e=="+"?"-":"_"),"_mkUriSafe"),oo=i(t=>t.replace(/[^A-Za-z0-9\+\/]/g,""),"_tidyB64"),so=i(t=>{let e,r,n,o,s="",c=t.length%3;for(let f=0;f<t.length;){if((r=t.charCodeAt(f++))>255||(n=t.charCodeAt(f++))>255||(o=t.charCodeAt(f++))>255)throw new TypeError("invalid character found");e=r<<16|n<<8|o,s+=De[e>>18&63]+De[e>>12&63]+De[e>>6&63]+De[e&63]}return c?s.slice(0,c-3)+"===".substring(c):s},"btoaPolyfill"),hr=typeof btoa=="function"?t=>btoa(t):ae?t=>Buffer.from(t,"binary").toString("base64"):so,lr=ae?t=>Buffer.from(t).toString("base64"):t=>{let r=[];for(let n=0,o=t.length;n<o;n+=4096)r.push(D.apply(null,t.subarray(n,n+4096)));return hr(r.join(""))},dt=i((t,e=!1)=>e?no(lr(t)):lr(t),"fromUint8Array"),Ps=i(t=>{if(t.length<2){var e=t.charCodeAt(0);return e<128?t:e<2048?D(192|e>>>6)+D(128|e&63):D(224|e>>>12&15)+D(128|e>>>6&63)+D(128|e&63)}else{var e=65536+(t.charCodeAt(0)-55296)*1024+(t.charCodeAt(1)-56320);return D(240|e>>>18&7)+D(128|e>>>12&63)+D(128|e>>>6&63)+D(128|e&63)}},"cb_utob"),js=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,io=i(t=>t.replace(js,Ps),"utob"),eo=ae?t=>Buffer.from(t,"utf8").toString("base64"):Yn?t=>lr(Yn.encode(t)):t=>hr(io(t)),ce=i((t,e=!1)=>e?no(eo(t)):eo(t),"encode"),to=i(t=>ce(t,!0),"encodeURI"),zs=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Vs=i(t=>{switch(t.length){case 4:var e=(7&t.charCodeAt(0))<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|63&t.charCodeAt(3),r=e-65536;return D((r>>>10)+55296)+D((r&1023)+56320);case 3:return D((15&t.charCodeAt(0))<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2));default:return D((31&t.charCodeAt(0))<<6|63&t.charCodeAt(1))}},"cb_btou"),co=i(t=>t.replace(zs,Vs),"btou"),ao=i(t=>{if(t=t.replace(/\s+/g,""),!$s.test(t))throw new TypeError("malformed base64.");t+="==".slice(2-(t.length&3));let e,r,n,o=[];for(let s=0;s<t.length;)e=ut[t.charAt(s++)]<<18|ut[t.charAt(s++)]<<12|(r=ut[t.charAt(s++)])<<6|(n=ut[t.charAt(s++)]),r===64?o.push(D(e>>16&255)):n===64?o.push(D(e>>16&255,e>>8&255)):o.push(D(e>>16&255,e>>8&255,e&255));return o.join("")},"atobPolyfill"),mr=typeof atob=="function"?t=>atob(oo(t)):ae?t=>Buffer.from(t,"base64").toString("binary"):ao,fo=ae?t=>qn(Buffer.from(t,"base64")):t=>qn(mr(t).split("").map(e=>e.charCodeAt(0))),uo=i(t=>fo(lo(t)),"toUint8Array"),Hs=ae?t=>Buffer.from(t,"base64").toString("utf8"):Zn?t=>Zn.decode(fo(t)):t=>co(mr(t)),lo=i(t=>oo(t.replace(/[-_]/g,e=>e=="-"?"+":"/")),"_unURI"),pr=i(t=>Hs(lo(t)),"decode"),Ks=i(t=>{if(typeof t!="string")return!1;let e=t.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(e)||!/[^\s0-9a-zA-Z\-_]/.test(e)},"isValid"),po=i(t=>({value:t,enumerable:!1,writable:!0,configurable:!0}),"_noEnum"),ho=i(function(){let t=i((e,r)=>Object.defineProperty(String.prototype,e,po(r)),"_add");t("fromBase64",function(){return pr(this)}),t("toBase64",function(e){return ce(this,e)}),t("toBase64URI",function(){return ce(this,!0)}),t("toBase64URL",function(){return ce(this,!0)}),t("toUint8Array",function(){return uo(this)})},"extendString"),mo=i(function(){let t=i((e,r)=>Object.defineProperty(Uint8Array.prototype,e,po(r)),"_add");t("toBase64",function(e){return dt(this,e)}),t("toBase64URI",function(){return dt(this,!0)}),t("toBase64URL",function(){return dt(this,!0)})},"extendUint8Array"),Ws=i(()=>{ho(),mo()},"extendBuiltins"),lt={version:ro,VERSION:Ls,atob:mr,atobPolyfill:ao,btoa:hr,btoaPolyfill:so,fromBase64:pr,toBase64:ce,encode:ce,encodeURI:to,encodeURL:to,utob:io,btou:co,decode:pr,isValid:Ks,fromUint8Array:dt,toUint8Array:uo,extendString:ho,extendUint8Array:mo,extendBuiltins:Ws};var xo={};function go(t,e,r){if(!(t instanceof Uint8Array))throw new TypeError('"input" must be a Uint8Array.');if(typeof e!="string")throw new TypeError('"alphabet" must be a string.');if(r!==void 0&&typeof r!="number")throw new TypeError('"maxline" must be a number.');if(t.length===0)return"";let n="",o=0,s=e.length,c=e.charAt(0),f=[0];for(o=0;o<t.length;++o){let u=t[o];for(let d=0;d<f.length;++d)u+=f[d]<<8,f[d]=u%s,u=u/s|0;for(;u>0;)f.push(u%s),u=u/s|0}for(o=0;t[o]===0&&o<t.length-1;++o)n+=c;for(o=f.length-1;o>=0;--o)n+=e[f[o]];if(r){let u=new RegExp(".{1,"+r+"}","g");n=n.match(u).join(`\r
2
+ `)}return n}i(go,"encode");function yo(t,e){if(typeof t!="string")throw new TypeError('"input" must be a string.');if(typeof e!="string")throw new TypeError('"alphabet" must be a string.');if(t.length===0)return new Uint8Array;let r=xo[e];if(!r){r=xo[e]=[];for(let c=0;c<e.length;++c)r[e.charCodeAt(c)]=c}t=t.replace(/\s/g,"");let n=e.length,o=e.charAt(0),s=[0];for(let c=0;c<t.length;c++){let f=r[t.charCodeAt(c)];if(f===void 0)return;let u=f;for(let d=0;d<s.length;++d)u+=s[d]*n,s[d]=u&255,u>>=8;for(;u>0;)s.push(u&255),u>>=8}for(let c=0;t[c]===o&&c<t.length-1;++c)s.push(0);return new Uint8Array(s.reverse())}i(yo,"decode");var wo="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Ue(t,e){return go(t,wo,e)}i(Ue,"encode");function pt(t){return yo(t,wo)}i(pt,"decode");var mt=class mt extends _{decode({value:e}={}){let{buffer:r,byteOffset:n,length:o}=e,s=new Uint8Array(r,n+1,o-1);return e[0]===122?`z${Ue(s)}`:e[0]===77?`M${lt.fromUint8Array(s)}`:e}static createDecoder({value:e}={}){if(!(e instanceof Uint8Array))return!1;if(e[0]===122||e[0]===77)return new mt}};i(mt,"MultibaseDecoder");var ht=mt;var xr=class xr{constructor({appContextMap:e,documentLoader:r}={}){this.appContextMap=e,this.documentLoader=r}_beforeObjectContexts(){}_afterObjectContexts(){}_beforeTypeScopedContexts(){}async _transform({obj:e,transformMap:r,contextStack:n=[]}){this._beforeObjectContexts({obj:e,transformMap:r});let o=await this._applyEmbeddedContexts({obj:e,contextStack:n});this._afterObjectContexts({obj:e,transformMap:r});let s=n.slice();this._beforeTypeScopedContexts({activeCtx:o,obj:e,transformMap:r}),o=await this._applyTypeScopedContexts({obj:e,contextStack:n});let{aliases:c,scopedContextMap:f,termMap:u}=o,d=this._getEntries({obj:e,transformMap:r,transformer:this,termMap:u});for(let[h,x]of d){let{term:g}=h;if(g==="@id"||c.id.has(g)){this._transformObjectId({obj:e,transformMap:r,termInfo:h,value:x});continue}if(g==="@type"||c.type.has(g)){this._transformObjectType({obj:e,transformMap:r,termInfo:h,value:x});continue}let w=s,I,ze=f.get(g);ze&&(I=await this._applyEmbeddedContexts({obj:{"@context":ze},contextStack:n}),w=n.slice());let{plural:Ve,def:Kt}=h,L=this._getTermType({activeCtx:I||o,def:Kt}),He=Ve?x:[x],te=[];for(let X of He){if(X===null){te.push(null);continue}if(!this._transformTypedValue({entries:te,termType:L,value:X,termInfo:h})){if(typeof X!="object"){te.push(X);continue}if(Array.isArray(X)){await this._transformArray({entries:te,contextStack:w,value:X});continue}await this._transformObject({entries:te,contextStack:w,value:X})}}I&&I.revert(),this._assignEntries({entries:te,obj:e,transformMap:r,termInfo:h})}o.revert()}async _applyEmbeddedContexts({obj:e,contextStack:r}){let n=r.length,o=e["@context"];await this._updateContextStack({contextStack:r,contexts:o});let s=r[r.length-1];return s||(s={aliases:{id:new Set,type:new Set},context:{},scopedContextMap:new Map,termMap:new Map}),{...s,revert(){r.length=n}}}async _applyTypeScopedContexts({obj:e,contextStack:r}){let n=r.length,o=r[r.length-1];o||(o={aliases:{id:new Set,type:new Set},context:{},scopedContextMap:new Map,termMap:new Map});let{aliases:s}=o,c=[],f=["@type",...s.type];for(let d of f){let h=e[d];Array.isArray(h)?c.push(...h):c.push(h)}c=[...new Set(c)].sort();let{scopedContextMap:u}=o;for(let d of c){let h=u.get(d);h&&(await this._updateContextStack({contextStack:r,contexts:h}),o=r[r.length-1],{scopedContextMap:u}=o)}return{...o,revert(){r.length=n}}}async _updateContextStack({contextStack:e,contexts:r,transformer:n}){if(!r)return;Array.isArray(r)||(r=[r]);let{contextMap:o}=this;for(let s of r){let c=o.get(s);if(!c){let g=s,w;typeof s=="string"&&(w=s,{"@context":g}=await this._getDocument({url:w})),c=await this._addContext({context:g,contextUrl:w,transformer:n})}let f={aliases:{id:new Set(c.aliases.id),type:new Set(c.aliases.type)},context:s,scopedContextMap:new Map(c.scopedContextMap),termMap:new Map(c.termMap)},u=e[e.length-1];if(e.push(f),!u)continue;let{aliases:d,termMap:h}=f;for(let g of["id","type"])for(let w of u.aliases[g])s[w]===null||f.termMap.has(w)||d[g].add(w);let{scopedContextMap:x}=f;for(let[g,w]of u.scopedContextMap)s[g]===null||x.has(g)||x.set(g,w);for(let[g,w]of u.termMap)s[g]===null||h.has(g)||h.set(g,w)}}async _addContext({context:e,contextUrl:r}){let{contextMap:n,termToId:o,idToTerm:s}=this,c=e["@import"];if(c){let x=n.get(c);if(!x){let{"@context":g}=await this._getDocument({url:c});x=await this._addContext({context:g,contextUrl:c})}e={...x.context,...e}}let f=new Map,u=new Map,d={aliases:{id:new Set,type:new Set},context:e,scopedContextMap:f,termMap:u},h=Object.keys(e).sort();for(let x of h){let g=e[x];if(!g||(g==="@id"||g.id==="@id"?d.aliases.id.add(x):(g==="@type"||g.id==="@type")&&d.aliases.type.add(x),P.has(x)))continue;if(!o.has(x)){let I=this.nextTermId;this.nextTermId+=2,o.set(x,I),s&&s.set(I,x)}u.set(x,g);let w=g["@context"];w&&f.set(x,w)}return n.set(r||e,d),d}async _getDocument({url:e}){let{document:r}=await this.documentLoader(e);return typeof r=="string"?JSON.parse(r):r}_getTermType({activeCtx:e,def:r}){let{"@type":n}=r;if(!n)return;let[o,...s]=n.split(":"),c=e.termMap.get(o);if(c===void 0)return n;if(typeof c=="string")return c+s.join(":");if(!(typeof c=="object"&&typeof c["@id"]=="string"))throw new T("ERR_INVALID_TERM_DEFINITION",'JSON-LD term definitions must be strings or objects with "@id".');return c["@id"]+s.join(":")}_getIdForTerm({term:e,plural:r}){let n=this.termToId.get(e);if(n===void 0)throw new T("ERR_UNDEFINED_TERM","CBOR-LD compression requires all terms to be defined in a JSON-LD context.");return r?n+1:n}_getTermForId({id:e}){let r=(e&1)===1;return{term:this.idToTerm.get(r?e-1:e),plural:r}}};i(xr,"Transformer");var fe=xr;var bo=new Map([[1024,"did:v1:nym:"],[1025,"did:key:"]]),xt=class xt extends _{decode({value:e}={}){let r=bo.get(e[0]);return typeof e[1]=="string"?r+=e[1]:r+=`z${Ue(e[1])}`,e.length>2&&(typeof e[2]=="string"?r+=`#${e[2]}`:r+=`#z${Ue(e[2])}`),r}static createDecoder({value:e}={}){return!(Array.isArray(e)&&e.length>1&&e.length<=3)||!bo.has(e[0])?!1:new xt}};i(xt,"Base58DidUrlDecoder");var Ie=xt;var gt=class gt extends _{constructor({secure:e}={}){super(),this.secure=e}decode({value:e}={}){return`${this.secure?"https://":"http://"}${e[1]}`}static createDecoder({value:e}={}){return e.length===2&&typeof e[1]=="string"?new gt({secure:e[0]===2}):!1}};i(gt,"HttpUrlDecoder");var ke=gt;var Eo=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Qs(t){return typeof t=="string"&&Eo.test(t)}i(Qs,"validate");var yt=Qs;var U=[];for(let t=0;t<256;++t)U.push((t+256).toString(16).slice(1));function Xs(t,e=0){return U[t[e+0]]+U[t[e+1]]+U[t[e+2]]+U[t[e+3]]+"-"+U[t[e+4]]+U[t[e+5]]+"-"+U[t[e+6]]+U[t[e+7]]+"-"+U[t[e+8]]+U[t[e+9]]+"-"+U[t[e+10]]+U[t[e+11]]+U[t[e+12]]+U[t[e+13]]+U[t[e+14]]+U[t[e+15]]}i(Xs,"unsafeStringify");function Gs(t,e=0){let r=Xs(t,e);if(!yt(r))throw TypeError("Stringified UUID is invalid");return r}i(Gs,"stringify");var gr=Gs;function Js(t){if(!yt(t))throw TypeError("Invalid UUID");let e,r=new Uint8Array(16);return r[0]=(e=parseInt(t.slice(0,8),16))>>>24,r[1]=e>>>16&255,r[2]=e>>>8&255,r[3]=e&255,r[4]=(e=parseInt(t.slice(9,13),16))>>>8,r[5]=e&255,r[6]=(e=parseInt(t.slice(14,18),16))>>>8,r[7]=e&255,r[8]=(e=parseInt(t.slice(19,23),16))>>>8,r[9]=e&255,r[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,r[11]=e/4294967296&255,r[12]=e>>>24&255,r[13]=e>>>16&255,r[14]=e>>>8&255,r[15]=e&255,r}i(Js,"parse");var yr=Js;var bt=class bt extends _{decode({value:e}={}){return`urn:uuid:${typeof e[1]=="string"?e[1]:gr(e[1])}`}static createDecoder({value:e}={}){if(e.length===2&&(typeof e[1]=="string"||e[1]instanceof Uint8Array))return new bt}};i(bt,"UuidUrnDecoder");var wt=bt;var Zs=new Map([[1,ke],[2,ke],[3,wt],[1024,Ie],[1025,Ie]]),wr=class wr extends _{static createDecoder({value:e}={}){if(!(Array.isArray(e)||e.length>1))return!1;let r=Zs.get(e[0]);return r&&r.createDecoder({value:e})}};i(wr,"UriDecoder");var J=wr;var Et=class Et extends _{constructor({term:e}={}){super(),this.term=e}decode(){return this.term}static createDecoder({value:e,transformer:r}={}){if(Array.isArray(e))return J.createDecoder({value:e,transformer:r});let n=r.idToTerm.get(e);if(n!==void 0)return new Et({term:n})}};i(Et,"VocabTermDecoder");var Z=Et;var Tt=class Tt extends _{decode({value:e}={}){let r=new Date(e*1e3).toISOString();return r.substring(0,r.indexOf("T"))}static createDecoder({value:e}={}){if(typeof e=="number")return new Tt}};i(Tt,"XsdDateDecoder");var Ct=Tt;var Me=class Me extends _{constructor({value:e}={}){super(),this.value=e}decode({value:e}={}){return typeof e=="number"?new Date(e*1e3).toISOString().replace(".000Z","Z"):new Date(e[0]*1e3+e[1]).toISOString()}static createDecoder({value:e}={}){if(typeof e=="number")return new Me;if(Array.isArray(e)&&e.length===2&&(typeof e[0]=="number"||typeof e[1]=="number"))return new Me}};i(Me,"XsdDateTimeDecoder");var At=Me;var Ys=new Map([["@id",J],["@vocab",Z],["https://w3id.org/security#multibase",ht],["http://www.w3.org/2001/XMLSchema#date",Ct],["http://www.w3.org/2001/XMLSchema#dateTime",At]]),br=P.get("@context"),Co=br+1,Er=class Er extends fe{constructor({documentLoader:e,appContextMap:r}={}){if(super({documentLoader:e,appContextMap:r}),this.reverseAppContextMap=new Map,r)for(let[n,o]of r)this.reverseAppContextMap.set(o,n)}async decompress({compressedBytes:e,diagnose:r}={}){this.contextMap=new Map,this.termToId=new Map(P),this.nextTermId=at,this.idToTerm=new Map;for(let[f,u]of this.termToId)this.idToTerm.set(u,f);let n=_e(e,{useMaps:!0});r&&(r("Diagnostic CBOR-LD decompression transform map(s):"),r(W(n,{depth:null,colors:!0})));let o=[],s=Array.isArray(n),c=s?n:[n];for(let f of c){let u={};await this._transform({obj:u,transformMap:f}),o.push(u)}return s?o:o[0]}_beforeObjectContexts({obj:e,transformMap:r}){let n=r.get(br);if(n){let s=Be.createDecoder({value:n,transformer:this});e["@context"]=s?s.decode({value:n}):n}let o=r.get(Co);if(o){if(n)throw new T("ERR_INVALID_ENCODED_CONTEXT","Both singular and plural context IDs were found in the CBOR-LD input.");if(!Array.isArray(o))throw new T("ERR_INVALID_ENCODED_CONTEXT","Encoded plural context value must be an array.");let s=[];for(let c of o){let f=Be.createDecoder({value:c,transformer:this});s.push(f?f.decode({value:c}):c)}e["@context"]=s}}_beforeTypeScopedContexts({activeCtx:e,obj:r,transformMap:n}){let{termToId:o}=this,s=["@type",...e.aliases.type];for(let c of s){let f=o.get(c),u=n.get(f);if(u===void 0&&(u=n.get(f+1)),u!==void 0)if(Array.isArray(u))r[c]=u.map(d=>{let h=Z.createDecoder({value:d,transformer:this});return h?h.decode({value:d}):d});else{let d=Z.createDecoder({value:u,transformer:this});r[c]=d?d.decode({value:u}):u}}}_getEntries({transformMap:e,termMap:r}){let n=[];for(let[o,s]of e){if(o===br||o===Co)continue;let{term:c,plural:f}=this._getTermForId({id:o});if(c===void 0)throw new T("ERR_UNKNOWN_CBORLD_TERM_ID",`Unknown term ID '${o}' was detected in the CBOR-LD input.`);let u=r.get(c);if(u===void 0&&!(c.startsWith("@")&&P.has(c)))throw new T("ERR_UNKNOWN_CBORLD_TERM",`Unknown term "${c}" was detected in the CBOR-LD input.`);n.push([{term:c,termId:o,plural:f,def:u},s])}return n.sort(qs)}_getTermInfo({termMap:e,key:r}){let{term:n,plural:o}=this._getTermForId({id:r});if(n===void 0)throw new T("ERR_UNKNOWN_CBORLD_TERM_ID",`Unknown term ID '${r}' was detected in the CBOR-LD input.`);let s=e.get(n);if(s===void 0&&!(n.startsWith("@")&&P.has(n)))throw new T("ERR_UNKNOWN_CBORLD_TERM",`Unknown term "${n}" was detected in the CBOR-LD input.`);return{term:n,termId:r,plural:o,def:s}}_transformObjectId({obj:e,termInfo:r,value:n}){let o=J.createDecoder({value:n});e[r.term]=o?o.decode({value:n}):n}_transformObjectType({obj:e,termInfo:r,value:n}){let{term:o,plural:s}=r,c=s?n:[n],f=[];for(let u of c){let d=Z.createDecoder({value:u,transformer:this});f.push(d?d.decode({value:u}):u)}e[o]=s?f:f[0]}_transformTypedValue({entries:e,termType:r,value:n}){let o=Ys.get(r),s=o&&o.createDecoder({value:n,transformer:this});if(s)return e.push(s.decode({value:n})),!0}async _transformArray({entries:e,contextStack:r,value:n}){let o=[];for(let s of n){let c={};o.push(c),await this._transform({obj:c,transformMap:s,contextStack:r})}e.push(o)}async _transformObject({entries:e,contextStack:r,value:n}){let o={};return e.push(o),this._transform({obj:o,transformMap:n,contextStack:r})}_assignEntries({entries:e,obj:r,termInfo:n}){let{term:o,plural:s}=n;r[o]=s?e:e[0]}};i(Er,"Decompressor");var _t=Er;function qs([{term:t}],[{term:e}]){return t<e?-1:t>e?1:0}i(qs,"_sortEntriesByTerm");async function Cr({cborldBytes:t,documentLoader:e,appContextMap:r=new Map,diagnose:n}){if(!(t instanceof Uint8Array))throw new TypeError('"cborldBytes" must be a Uint8Array.');let o=0;if(t[o++]!==217)throw new T("ERR_NOT_CBORLD",'CBOR-LD must start with a CBOR major type "Tag" header of `0xd9`.');if(t[o++]!==5)throw new T("ERR_NOT_CBORLD","CBOR-LD 16-bit tag must start with `0x05`.");let s=t[o];if(s===void 0)throw new T("ERR_NOT_CBORLD","Truncated CBOR-LD 16-bit tag.");if(!(s===0||s===1))throw new T("ERR_NOT_CBORLD",`Unsupported CBOR-LD compression mode "${s}".`);o++;let{buffer:c,byteOffset:f,length:u}=t,d=new Uint8Array(c,f+o,u-o);if(s===0)return _e(d,{useMaps:!1});let x=await new _t({documentLoader:e,appContextMap:r}).decompress({compressedBytes:d,diagnose:n});return n&&(n("Diagnostic JSON-LD result:"),n(W(x,{depth:null,colors:!0}))),x}i(Cr,"decode");var Tr=class Tr{encode(){throw new Error("Must be implemented by derived class.")}static createEncoder({value:e}={}){throw new Error("Must be implemented by derived class.")}};i(Tr,"CborldEncoder");var E=Tr;var Dt=class Dt extends E{constructor({context:e,appContextMap:r}={}){super(),this.context=e,this.appContextMap=r}encode(){let{context:e}=this,r=ur.get(e)||this.appContextMap.get(e);return r===void 0?new l(a.string,e):new l(a.uint,r)}static createEncoder({value:e,transformer:r}={}){if(typeof e!="string")return!1;let{appContextMap:n}=r;return new Dt({context:e,appContextMap:n})}};i(Dt,"ContextEncoder");var Bt=Dt;var It=class It extends E{constructor({value:e}={}){super(),this.value=e}encode(){let{value:e}=this,r,n;e[0]==="z"?(r=122,n=pt(e.substr(1))):e[0]==="M"&&(r=77,n=lt.toUint8Array(e.substr(1)));let o=new Uint8Array(1+n.length);return o[0]=r,o.set(n,1),new l(a.bytes,o)}static createEncoder({value:e}={}){if(typeof e!="string")return!1;if(e[0]==="z"||e[0]==="M")return new It({value:e})}};i(It,"MultibaseEncoder");var Ut=It;var To=new Map([["did:v1:nym:",1024],["did:key:",1025]]),kt=class kt extends E{constructor({value:e,scheme:r}={}){super(),this.value=e,this.scheme=r}encode(){let{value:e,scheme:r}=this,n=e.substr(r.length),[o,s]=n.split("#"),c=[new l(a.uint,To.get(r)),Ao(o)];return s!==void 0&&c.push(Ao(s)),[new l(a.array,c.length),c]}static createEncoder({value:e}={}){let r=[...To.keys()];for(let n of r)if(e.startsWith(n))return new kt({value:e,scheme:n})}};i(kt,"Base58DidUrlEncoder");var Se=kt;function Ao(t){if(t.startsWith("z")){let e=pt(t.substr(1));if(e)return new l(a.bytes,e)}return new l(a.string,t)}i(Ao,"_multibase58ToToken");var Re=class Re extends E{constructor({value:e,secure:r}={}){super(),this.value=e,this.secure=r}encode(){let{value:e,secure:r}=this,n=r?8:7,o=[new l(a.uint,r?2:1),new l(a.string,e.substr(n))];return[new l(a.array,o.length),o]}static createEncoder({value:e}={}){if(e.startsWith("https://"))return new Re({value:e,secure:!0});if(e.startsWith("http://"))return new Re({value:e,secure:!1})}};i(Re,"HttpUrlEncoder");var Oe=Re;var St=class St extends E{constructor({value:e}={}){super(),this.value=e}encode(){let{value:e}=this,r=e.substr(9),n=[new l(a.uint,3)];if(r.toLowerCase()===r){let o=yr(r);n.push(new l(a.bytes,o))}else n.push(new l(a.string,r));return[new l(a.array,n.length),n]}static createEncoder({value:e}={}){if(e.startsWith("urn:uuid:"))return new St({value:e})}};i(St,"UuidUrnEncoder");var Mt=St;var ei=new Map([["http",Oe],["https",Oe],["urn:uuid",Mt],["did:v1:nym",Se],["did:key",Se]]),Ar=class Ar extends E{static createEncoder({value:e}={}){if(typeof e!="string")return!1;let r;try{let{protocol:o,pathname:s}=new URL(e);r=o,s.includes(":")&&(r+=s);let c=e.split(":");c.pop(),r=c.join(":")}catch{return!1}let n=ei.get(r);return n&&n.createEncoder({value:e})}};i(Ar,"UriEncoder");var Y=Ar;var Rt=class Rt extends E{constructor({termId:e}={}){super(),this.termId=e}encode(){return new l(a.uint,this.termId)}static createEncoder({value:e,transformer:r}={}){let{termToId:n}=r,o=n.get(e);return o!==void 0?new Rt({termId:o}):Y.createEncoder({value:e})}};i(Rt,"VocabTermEncoder");var Ne=Rt;var Nt=class Nt extends E{constructor({value:e,parsed:r}={}){super(),this.value=e,this.parsed=r}encode(){let{value:e,parsed:r}=this,n=Math.floor(r/1e3),o=new Date(n*1e3).toISOString(),s=o.substring(0,o.indexOf("T"));return e!==s?new l(a.string,e):new l(a.uint,n)}static createEncoder({value:e}={}){if(e.includes("T"))return!1;let r=Date.parse(e);return isNaN(r)?!1:new Nt({value:e,parsed:r})}};i(Nt,"XsdDateEncoder");var Ot=Nt;var Lt=class Lt extends E{constructor({value:e,parsed:r}={}){super(),this.value=e,this.parsed=r}encode(){let{value:e,parsed:r}=this,n=Math.floor(r/1e3),o=new l(a.uint,n),s=e.indexOf(".");if(s===-1){let d=new Date(n*1e3).toISOString().replace(".000Z","Z");return e!==d?new l(a.string,e):o}let c=parseInt(e.substr(s+1),10),f=new Date(n*1e3+c).toISOString();if(e!==f)return new l(a.string,e);let u=[o,new l(a.uint,c)];return[new l(a.array,u.length),u]}static createEncoder({value:e}={}){if(!e.includes("T"))return!1;let r=Date.parse(e);return isNaN(r)?!1:new Lt({value:e,parsed:r})}};i(Lt,"XsdDateTimeEncoder");var vt=Lt;var ti=new Map([["@id",Y],["@vocab",Ne],["https://w3id.org/security#multibase",Ut],["http://www.w3.org/2001/XMLSchema#date",Ot],["http://www.w3.org/2001/XMLSchema#dateTime",vt]]),_o=P.get("@context"),ri=_o+1,ni={Object(t){if(t instanceof E)return t.encode({obj:t})}},_r=class _r extends fe{constructor({documentLoader:e,appContextMap:r}={}){super({documentLoader:e,appContextMap:r})}async compress({jsonldDocument:e,diagnose:r}={}){let n=await this._createTransformMaps({jsonldDocument:e});return r&&(r("Diagnostic CBOR-LD compression transform map(s):"),r(W(n,{depth:null,colors:!0}))),Te(n,{typeEncoders:ni})}async _createTransformMaps({jsonldDocument:e}){this.contextMap=new Map,this.termToId=new Map(P),this.nextTermId=at;let r=[],n=Array.isArray(e),o=n?e:[e];for(let s of o){let c=new Map;await this._transform({obj:s,transformMap:c}),r.push(c)}return n?r:r[0]}_afterObjectContexts({obj:e,transformMap:r}){let n=e["@context"];if(!n)return;let o=[],s=Array.isArray(n),c=s?n:[n];for(let u of c){let d=Bt.createEncoder({value:u,transformer:this});o.push(d||u)}let f=s?ri:_o;r.set(f,s?o:o[0])}_getEntries({obj:e,termMap:r}){let n=[],o=Object.keys(e).sort();for(let s of o){if(s==="@context")continue;let c=r.get(s);if(c===void 0&&!(s.startsWith("@")&&P.has(s)))throw new T("ERR_UNKNOWN_CBORLD_TERM",`Unknown term '${s}' was detected in the JSON-LD input.`);let f=e[s],u=Array.isArray(f),d=this._getIdForTerm({term:s,plural:u});n.push([{term:s,termId:d,plural:u,def:c},f])}return n}_transformObjectId({transformMap:e,termInfo:r,value:n}){let{termId:o}=r,s=Y.createEncoder({value:n,transformer:this,termInfo:r});e.set(o,s||n)}_transformObjectType({transformMap:e,termInfo:r,value:n}){let{termId:o,plural:s}=r,c=s?n:[n],f=[];for(let u of c){let d=Ne.createEncoder({value:u,transformer:this,termInfo:r});f.push(d||u)}e.set(o,s?f:f[0])}_transformTypedValue({entries:e,termType:r,value:n,termInfo:o}){let s=ti.get(r),c=s&&s.createEncoder({value:n,transformer:this,termInfo:o});if(c)return e.push(c),!0}async _transformArray({entries:e,contextStack:r,value:n}){let o=[];for(let s of n){let c=new Map;o.push(c),await this._transform({obj:s,transformMap:c,contextStack:r})}e.push(o)}async _transformObject({entries:e,contextStack:r,value:n}){let o=new Map;e.push(o),await this._transform({obj:n,transformMap:o,contextStack:r})}_assignEntries({entries:e,transformMap:r,termInfo:n}){let{termId:o,plural:s}=n;r.set(o,s?e:e[0])}};i(_r,"Compressor");var Ft=_r;async function Br({jsonldDocument:t,documentLoader:e,appContextMap:r=new Map,compressionMode:n=1,diagnose:o}={}){if(!(n===0||n===1))throw new TypeError('"compressionMode" must be "0" (no compression) or "1" for compression mode version 1.');let s=new Uint8Array([217,5,n]),c;n===0?c=Te(t):c=await new Ft({documentLoader:e,appContextMap:r}).compress({jsonldDocument:t,diagnose:o});let f=s.length+c.length,u=new Uint8Array(f);return u.set(s),u.set(c,s.length),o&&(o("Diagnostic CBOR-LD result:"),o(W(u,{depth:null,colors:!0}))),u}i(Br,"encode");function Dr(t){if(t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray)return new DataView(t.buffer,t.byteOffset,t.byteLength);if(t instanceof ArrayBuffer)return new DataView(t);throw new TypeError("Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray")}i(Dr,"toDataView");var si="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",ii="0123456789ABCDEFGHIJKLMNOPQRSTUV",ci="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function Ur(t,e,r){r=r||{};let n,o;switch(e){case"RFC3548":case"RFC4648":n=si,o=!0;break;case"RFC4648-HEX":n=ii,o=!0;break;case"Crockford":n=ci,o=!1;break;default:throw new Error("Unknown base32 variant: "+e)}let s=r.padding!==void 0?r.padding:o,c=Dr(t),f=0,u=0,d="";for(let h=0;h<c.byteLength;h++)for(u=u<<8|c.getUint8(h),f+=8;f>=5;)d+=n[u>>>f-5&31],f-=5;if(f>0&&(d+=n[u<<5-f&31]),s)for(;d.length%8!==0;)d+="=";return d}i(Ur,"base32Encode");var Ko=ts(Do(),1);var C;(function(t){t[t.Terminator=0]="Terminator",t[t.Numeric=1]="Numeric",t[t.Alphanumeric=2]="Alphanumeric",t[t.StructuredAppend=3]="StructuredAppend",t[t.Byte=4]="Byte",t[t.Kanji=8]="Kanji",t[t.ECI=7]="ECI"})(C||(C={}));var Ir=class Ir{constructor(e,r){this.bytes=[],this.mode=e,this.data=r}getLength(){return this.bytes.length}getLengthInBits(e){let r=this.mode,n=new Error(`illegal mode: ${r}`);if(1<=e&&e<10)switch(r){case C.Numeric:return 10;case C.Alphanumeric:return 9;case C.Byte:return 8;case C.Kanji:return 8;default:throw n}else if(e<27)switch(r){case C.Numeric:return 12;case C.Alphanumeric:return 11;case C.Byte:return 16;case C.Kanji:return 10;default:throw n}else if(e<41)switch(r){case C.Numeric:return 14;case C.Alphanumeric:return 13;case C.Byte:return 16;case C.Kanji:return 12;default:throw n}else throw new Error(`illegal version: ${e}`)}};i(Ir,"QRData");var Q=Ir;function Uo(t){let e=0,{length:r}=t,n=[];for(let o=0;o<r;o++){let s=t.charCodeAt(o);s<128?n[e++]=s:s<2048?(n[e++]=s>>6|192,n[e++]=s&63|128):(s&64512)===55296&&o+1<r&&(t.charCodeAt(o+1)&64512)===56320?(s=65536+((s&1023)<<10)+(t.charCodeAt(++o)&1023),n[e++]=s>>18|240,n[e++]=s>>12&63|128,n[e++]=s>>6&63|128,n[e++]=s&63|128):(n[e++]=s>>12|224,n[e++]=s>>6&63|128,n[e++]=s&63|128)}return n}i(Uo,"encode");var kr=class kr extends Q{constructor(e,r){if(super(C.Byte,e),this.encoding=-1,typeof r=="function"){let{encoding:n,bytes:o}=r(e);this.bytes=o,this.encoding=n}else this.bytes=Uo(e),this.encoding=26}writeTo(e){let{bytes:r}=this;for(let n of r)e.put(n,8)}};i(kr,"QRByte");var $t=kr;var q=[],Mr=[];for(let t=0;t<256;t++)Mr[t]=0,q[t]=t<8?1<<t:q[t-4]^q[t-5]^q[t-6]^q[t-8];for(let t=0;t<255;t++)Mr[q[t]]=t;function ue(t){if(t<1)throw new Error(`illegal log: ${t}`);return Mr[t]}i(ue,"glog");function ve(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return q[t]}i(ve,"gexp");var Le=class Le{constructor(e,r=0){let n=0,{length:o}=e;for(;n<o&&e[n]===0;)n++;o-=n;let s=[];for(let c=0;c<o;c++)s.push(e[n+c]);for(let c=0;c<r;c++)s.push(0);this.num=s}getAt(e){return this.num[e]}getLength(){return this.num.length}multiply(e){let r=[],n=e.getLength(),o=this.getLength(),s=o+n-1;for(let c=0;c<s;c++)r.push(0);for(let c=0;c<o;c++)for(let f=0;f<n;f++)r[c+f]^=ve(ue(this.getAt(c))+ue(e.getAt(f)));return new Le(r)}mod(e){let r=e.getLength(),n=this.getLength();if(n-r<0)return this;let o=ue(this.getAt(0))-ue(e.getAt(0)),s=[];for(let c=0;c<n;c++)s.push(this.getAt(c));for(let c=0;c<r;c++)s[c]^=ve(ue(e.getAt(c))+o);return new Le(s).mod(e)}};i(Le,"Polynomial");var ee=Le;var li=3,pi=3,Io=40,hi=10,mi=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],xi=21522,Ro=1335,Oo=7973;function No(t){return mi[t-1]}i(No,"getAlignmentPattern");function vo(t){let e=new ee([1]);for(let r=0;r<t;r++)e=e.multiply(new ee([1,ve(r)]));return e}i(vo,"getErrorCorrectionPolynomial");function de(t){let e=0;for(;t!==0;)e++,t>>>=1;return e}i(de,"getBCHDigit");var ko=de(Oo);function Lo(t){let e=t<<12;for(;de(e)-ko>=0;)e^=Oo<<de(e)-ko;return t<<12|e}i(Lo,"getBCHVersion");var Mo=de(Ro);function Fo(t){let e=t<<10;for(;de(e)-Mo>=0;)e^=Ro<<de(e)-Mo;return(t<<10|e)^xi}i(Fo,"getBCHVersionInfo");function So(t,e){let r=t.getMatrixSize(),n=0;for(let o=0;o<r;o++){let s=!1,c=0;for(let f=0;f<r;f++){let u=e?t.isDark(o,f):t.isDark(f,o);u===s?(c++,c===5?n+=li:c>5&&n++):(s=u,c=1)}}return n}i(So,"applyMaskPenaltyRule1Internal");function gi(t){return So(t,!0)+So(t,!1)}i(gi,"applyMaskPenaltyRule1");function yi(t){let e=t.getMatrixSize(),r=0;for(let n=0;n<e-1;n++)for(let o=0;o<e-1;o++){let s=t.isDark(n,o);s===t.isDark(n,o+1)&&s===t.isDark(n+1,o)&&s===t.isDark(n+1,o+1)&&(r+=pi)}return r}i(yi,"applyMaskPenaltyRule2");function Pt(t,e,r,n,o){r=Math.max(r,0),n=Math.min(n,t.getMatrixSize());for(let s=r;s<n;s++)if(o?t.isDark(e,s):t.isDark(s,e))return!1;return!0}i(Pt,"isFourWhite");function wi(t){let e=t.getMatrixSize(),r=0;for(let n=0;n<e;n++)for(let o=0;o<e;o++)o+6<e&&t.isDark(n,o)&&!t.isDark(n,o+1)&&t.isDark(n,o+2)&&t.isDark(n,o+3)&&t.isDark(n,o+4)&&!t.isDark(n,o+5)&&t.isDark(n,o+6)&&(Pt(t,n,o-4,o,!0)||Pt(t,n,o+7,o+11,!0))&&(r+=Io),n+6<e&&t.isDark(n,o)&&!t.isDark(n+1,o)&&t.isDark(n+2,o)&&t.isDark(n+3,o)&&t.isDark(n+4,o)&&!t.isDark(n+5,o)&&t.isDark(n+6,o)&&(Pt(t,o,n-4,n,!1)||Pt(t,o,n+7,n+11,!1))&&(r+=Io);return r}i(wi,"applyMaskPenaltyRule3");function bi(t){let e=t.getMatrixSize(),r=0;for(let s=0;s<e;s++)for(let c=0;c<e;c++)t.isDark(s,c)&&r++;let n=e*e;return Math.floor(Math.abs(r*20-n*10)/n)*hi}i(bi,"applyMaskPenaltyRule4");function $o(t){return gi(t)+yi(t)+wi(t)+bi(t)}i($o,"calculateMaskPenalty");var O;(function(t){t[t.L=1]="L",t[t.M=0]="M",t[t.Q=3]="Q",t[t.H=2]="H"})(O||(O={}));var H=class H{constructor(e,r){this.dataCount=r,this.totalCount=e}getDataCount(){return this.dataCount}getTotalCount(){return this.totalCount}static getRSBlocks(e,r){let n=[],o=H.getRSBlockTable(e,r),s=o.length/3;for(let c=0;c<s;c++){let f=o[c*3+0],u=o[c*3+1],d=o[c*3+2];for(let h=0;h<f;h++)n.push(new H(u,d))}return n}static getRSBlockTable(e,r){switch(r){case O.L:return H.RS_BLOCK_TABLE[(e-1)*4+0];case O.M:return H.RS_BLOCK_TABLE[(e-1)*4+1];case O.Q:return H.RS_BLOCK_TABLE[(e-1)*4+2];case O.H:return H.RS_BLOCK_TABLE[(e-1)*4+3];default:throw new Error(`illegal error correction level: ${r}`)}}};i(H,"RSBlock");var Fe=H;Fe.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];var Sr=class Sr{constructor(){this.length=0,this.buffer=[]}getBuffer(){return this.buffer}getLengthInBits(){return this.length}getBit(e){return(this.buffer[e/8>>0]>>>7-e%8&1)===1}put(e,r){for(let n=0;n<r;n++)this.putBit((e>>>r-n-1&1)===1)}putBit(e){let{buffer:r}=this;this.length===r.length*8&&r.push(0),e&&(r[this.length/8>>0]|=128>>>this.length%8),this.length++}};i(Sr,"BitBuffer");var $e=Sr;var Rr=class Rr{constructor(e){let r=1<<e,n=r+1;this.bof=r,this.eof=n,this.depth=e,this.reset()}reset(){let e=this.depth+1;this.bits=e,this.size=1<<e,this.codes=new Map,this.unused=this.eof+1}add(e,r){let{unused:n}=this;if(n>4095)return!1;this.codes.set(e<<8|r,n++);let{bits:o,size:s}=this;return n>s&&(s=1<<++o),this.bits=o,this.size=s,this.unused=n,!0}get(e,r){return this.codes.get(e<<8|r)}};i(Rr,"Dict");var jt=Rr;var Or=class Or{constructor(e){this.bits=0,this.buffer=0,this.bytes=[],this.dict=e}write(e){let{bits:r}=this,n=this.buffer|e<<r;r+=this.dict.bits;let{bytes:o}=this;for(;r>=8;)o.push(n&255),n>>=8,r-=8;this.bits=r,this.buffer=n}pipe(e){let{bytes:r}=this;this.bits>0&&r.push(this.buffer),e.writeByte(this.dict.depth);let{length:n}=r;for(let o=0;o<n;){let s=n-o;s>=255?(e.writeByte(255),e.writeBytes(r,o,255),o+=255):(e.writeByte(s),e.writeBytes(r,o,s),o=n)}e.writeByte(0)}};i(Or,"DictStream");var zt=Or;function Po(t,e,r){let n=new jt(e),o=new zt(n);if(o.write(n.bof),t.length>0){let s=t[0],{length:c}=t;for(let f=1;f<c;f++){let u=t[f],d=n.get(s,u);d!=null?s=d:(o.write(s),n.add(s,u)||(o.write(n.bof),n.reset()),s=u)}o.write(s)}o.write(n.eof),o.pipe(r)}i(Po,"compress");var Nr=class Nr{constructor(){this.bytes=[]}writeByte(e){this.bytes.push(e&255)}writeInt16(e){this.bytes.push(e&255,e>>8&255)}writeBytes(e,r=0,n=e.length){let o=this.bytes;for(let s=0;s<n;s++)o.push(e[r+s]&255)}};i(Nr,"ByteStream");var le=Nr;var{fromCharCode:vr}=String;function jo(t){if(t&=63,t>=0){if(t<26)return 65+t;if(t<52)return 97+(t-26);if(t<62)return 48+(t-52);if(t===62)return 43;if(t===63)return 47}throw new Error(`illegal char: ${vr(t)}`)}i(jo,"encode");var Lr=class Lr{constructor(){this.bits=0,this.buffer=0,this.length=0,this.stream=new le}get bytes(){return this.stream.bytes}write(e){let r=this.bits+8,{stream:n}=this,o=this.buffer<<8|e&255;for(;r>=6;)n.writeByte(jo(o>>>r-6)),r-=6;this.length++,this.bits=r,this.buffer=o}close(){let{bits:e,stream:r,length:n}=this;if(e>0&&(r.writeByte(jo(this.buffer<<6-e)),this.bits=0,this.buffer=0),n%3!=0){let o=3-n%3;for(let s=0;s<o;s++)r.writeByte(61)}}};i(Lr,"Base64Stream");var Vt=Lr;var Fr=class Fr{constructor(e,r,{foreground:n=[0,0,0],background:o=[255,255,255]}={}){this.pixels=[],this.width=e,this.height=r,this.foreground=n,this.background=o}encodeImpl(){let e=new le,{width:r,height:n,background:o,foreground:s}=this;return e.writeBytes([71,73,70,56,57,97]),e.writeInt16(r),e.writeInt16(n),e.writeBytes([128,0,0]),e.writeBytes([o[0],o[1],o[2]]),e.writeBytes([s[0],s[1],s[2]]),e.writeByte(44),e.writeInt16(0),e.writeInt16(0),e.writeInt16(r),e.writeInt16(n),e.writeByte(0),Po(this.pixels,2,e),e.writeByte(59),e.bytes}set(e,r,n){this.pixels[r*this.width+e]=n}toDataURL(){let e=this.encodeImpl(),r=new Vt;for(let s of e)r.write(s);r.close();let n=r.bytes,o="data:image/gif;base64,";for(let s of n)o+=vr(s);return o}};i(Fr,"GIFImage");var Ht=Fr;function zo(t){switch(t){case 0:return(e,r)=>(e+r&1)===0;case 1:return(e,r)=>(r&1)===0;case 2:return(e,r)=>e%3===0;case 3:return(e,r)=>(e+r)%3===0;case 4:return(e,r)=>((e/3>>0)+(r/2>>0)&1)===0;case 5:return(e,r)=>(e*r&1)+e*r%3===0;case 6:return(e,r)=>((e*r&1)+e*r%3&1)===0;case 7:return(e,r)=>(e*r%3+(e+r&1)&1)===0;default:throw new Error(`illegal mask: ${t}`)}}i(zo,"getMaskFunc");var Ei=236,Ci=17,{toString:Ti}=Object.prototype;function Ai(t,e){if(t<0||t>=1e6)throw new Error("byte mode encoding hint out of range");e.put(C.ECI,4),t<128?e.put(t,8):t<16384?(e.put(2,2),e.put(t,14)):(e.put(6,3),e.put(t,21))}i(Ai,"appendECI");function Vo(t,e,r,n){let o=new $e,s=Fe.getRSBlocks(t,e);for(let f of n){let u=f.mode;r&&u===C.Byte&&Ai(f.encoding,o),o.put(u,4),o.put(f.getLength(),f.getLengthInBits(t)),f.writeTo(o)}let c=0;for(let f of s)c+=f.getDataCount();return c*=8,[o,s,c]}i(Vo,"prepareData");function _i(t,e){let r=0,n=0,o=0,s=[],c=[],f=e.length,u=t.getBuffer();for(let d=0;d<f;d++){let h=e[d],x=h.getDataCount(),g=h.getTotalCount()-x;n=Math.max(n,x),o=Math.max(o,g),s[d]=[];for(let L=0;L<x;L++)s[d][L]=255&u[L+r];r+=x;let w=vo(g),I=w.getLength()-1,Ve=new ee(s[d],I).mod(w),Kt=Ve.getLength();c[d]=[];for(let L=0;L<I;L++){let He=L+Kt-I;c[d][L]=He>=0?Ve.getAt(He):0}}t=new $e;for(let d=0;d<n;d++)for(let h=0;h<f;h++)d<s[h].length&&t.put(s[h][d],8);for(let d=0;d<o;d++)for(let h=0;h<f;h++)d<c[h].length&&t.put(c[h][d],8);return t}i(_i,"createBytes");function Bi(t,e,r){for(t.getLengthInBits()+4<=r&&t.put(0,4);t.getLengthInBits()%8!==0;)t.putBit(!1);for(;!(t.getLengthInBits()>=r||(t.put(Ei,8),t.getLengthInBits()>=r));)t.put(Ci,8);return _i(t,e)}i(Bi,"createData");var $r=class $r{constructor(e={}){this.matrixSize=0,this.chunks=[],this.matrix=[];let{version:r=0,encodingHint:n=!1,errorCorrectionLevel:o=O.L}=e;this.setVersion(r),this.setEncodingHint(n),this.setErrorCorrectionLevel(o)}getMatrix(){return this.matrix}getMatrixSize(){return this.matrixSize}getVersion(){return this.version}setVersion(e){return this.version=Math.min(40,Math.max(0,e>>0)),this.auto=this.version===0,this}getErrorCorrectionLevel(){return this.errorCorrectionLevel}setErrorCorrectionLevel(e){switch(e){case O.L:case O.M:case O.Q:case O.H:this.errorCorrectionLevel=e}return this}getEncodingHint(){return this.encodingHint}setEncodingHint(e){return this.encodingHint=e,this}write(e){let{chunks:r}=this;if(e instanceof Q)r.push(e);else if(Ti.call(e)==="[object String]")r.push(new $t(e));else throw new Error(`illegal data: ${e}`);return this}isDark(e,r){return this.matrix[e][r]===!0}setupFinderPattern(e,r){let{matrix:n}=this,o=this.matrixSize;for(let s=-1;s<=7;s++)for(let c=-1;c<=7;c++)e+s<=-1||o<=e+s||r+c<=-1||o<=r+c||(0<=s&&s<=6&&(c===0||c===6)||0<=c&&c<=6&&(s===0||s===6)||2<=s&&s<=4&&2<=c&&c<=4?n[e+s][r+c]=!0:n[e+s][r+c]=!1)}setupAlignmentPattern(){let{matrix:e}=this,r=No(this.version),{length:n}=r;for(let o=0;o<n;o++)for(let s=0;s<n;s++){let c=r[o],f=r[s];if(e[c][f]===null)for(let u=-2;u<=2;u++)for(let d=-2;d<=2;d++)u===-2||u===2||d===-2||d===2||u===0&&d===0?e[c+u][f+d]=!0:e[c+u][f+d]=!1}}setupTimingPattern(){let{matrix:e}=this,r=this.matrixSize-8;for(let n=8;n<r;n++){let o=n%2===0;e[n][6]===null&&(e[n][6]=o),e[6][n]===null&&(e[6][n]=o)}}setupFormatInfo(e){let{matrix:r}=this,n=this.errorCorrectionLevel<<3|e,o=Fo(n),s=this.matrixSize;for(let c=0;c<15;c++){let f=(o>>c&1)===1;c<6?r[c][8]=f:c<8?r[c+1][8]=f:r[s-15+c][8]=f,c<8?r[8][s-c-1]=f:c<9?r[8][15-c-1+1]=f:r[8][15-c-1]=f}r[s-8][8]=!0}setupVersionInfo(){if(this.version>=7){let{matrix:e}=this,r=this.matrixSize,n=Lo(this.version);for(let o=0;o<18;o++){let s=(n>>o&1)===1;e[o/3>>0][o%3+r-8-3]=s,e[o%3+r-8-3][o/3>>0]=s}}}setupCodewords(e,r){let{matrix:n}=this,o=this.matrixSize,s=e.getLengthInBits(),c=zo(r),f=0;for(let u=o-1;u>=1;u-=2){u===6&&(u=5);for(let d=0;d<o;d++)for(let h=0;h<2;h++){let x=u-h,w=(u+1&2)===0?o-1-d:d;if(n[w][x]!==null)continue;let I=!1;f<s&&(I=e.getBit(f++)),c(x,w)&&(I=!I),n[w][x]=I}}}buildMatrix(e,r){let n=[],o=this.matrixSize;for(let s=0;s<o;s++){n[s]=[];for(let c=0;c<o;c++)n[s][c]=null}this.matrix=n,this.setupFinderPattern(0,0),this.setupFinderPattern(o-7,0),this.setupFinderPattern(0,o-7),this.setupAlignmentPattern(),this.setupTimingPattern(),this.setupFormatInfo(r),this.setupVersionInfo(),this.setupCodewords(e,r)}make(){let e,r,n,{chunks:o,errorCorrectionLevel:s}=this;if(this.auto){let h=1;for(;h<=40&&([e,r,n]=Vo(h,s,this.encodingHint,o),!(e.getLengthInBits()<=n));h++);let x=e.getLengthInBits();if(x>n)throw new Error(`data overflow: ${x} > ${n}`);this.version=h}else[e,r,n]=Vo(this.version,s,this.encodingHint,o);this.matrixSize=this.version*4+17;let c=[],f=Bi(e,r,n),u=-1,d=Number.MAX_VALUE;for(let h=0;h<8;h++){this.buildMatrix(f,h),c.push(this.matrix);let x=$o(this);x<d&&(d=x,u=h)}return this.matrix=c[u],this}toDataURL(e=2,r=e*4,n){e=Math.max(1,e>>0),r=Math.max(0,r>>0);let o=this.matrixSize,s=e*o+r*2,c=r,f=s-r,u=new Ht(s,s,n);for(let d=0;d<s;d++)for(let h=0;h<s;h++)if(c<=h&&h<f&&c<=d&&d<f){let x=(d-c)/e>>0,g=(h-c)/e>>0;u.set(h,d,this.isDark(x,g)?1:0)}else u.set(h,d,0);return u.toDataURL()}clear(){this.chunks=[]}};i($r,"Encoder");var Pe=$r;function Ho(t){let{length:e}=t,r=[];for(let n=0;n<e;n++)r.push(t.charCodeAt(n));return r}i(Ho,"encode");function Pr(t){if(48<=t&&t<=57)return t-48;if(65<=t&&t<=90)return t-65+10;switch(t){case 32:return 36;case 36:return 37;case 37:return 38;case 42:return 39;case 43:return 40;case 45:return 41;case 46:return 42;case 47:return 43;case 58:return 44;default:throw new Error(`illegal char: ${String.fromCharCode(t)}`)}}i(Pr,"getByte");var jr=class jr extends Q{constructor(e){super(C.Alphanumeric,e),this.bytes=Ho(e)}writeTo(e){let r=0,{bytes:n}=this,{length:o}=n;for(;r+1<o;)e.put(Pr(n[r])*45+Pr(n[r+1]),11),r+=2;r<o&&e.put(Pr(n[r]),6)}};i(jr,"QRAlphanumeric");var je=jr;var Wo="VP1",Qo="B";function Di({bytes:t,size:e}){let r=new Pe;r.setEncodingHint(!0);let n=Ur(t,"RFC4648",{padding:!1}),o=`${Wo}-${Qo}${n}`;return r.write(new je(o)),r.make(),{payload:o,encodedCborld:n,version:r.getVersion(),imageDataUrl:r.toDataURL(e)}}i(Di,"_bytesToQrCodeDataUrl");async function zr({vp:t,documentLoader:e,size:r,diagnose:n}={}){let o=await Br({jsonldDocument:t,documentLoader:e,diagnose:n}),{payload:s,imageDataUrl:c,encodedCborld:f,version:u}=Di({bytes:o,size:r});return{payload:s,imageDataUrl:c,encodedCborld:f,rawCborldBytes:o,version:u}}i(zr,"toQrCode");async function Vr({text:t,documentLoader:e,diagnose:r}={}){let n=Wo+"-";if(!(t&&t.startsWith(n)))throw TypeError("Unsupported VP QR format.");let o=t.slice(n.length);if(!o.startsWith(Qo))throw TypeError("Payload must be multibase base32 (RFC4648) encoded.");let s=(0,Ko.default)(o.slice(1),"RFC4648"),c=new Uint8Array(s);return{vp:await Cr({cborldBytes:c,documentLoader:e,diagnose:r})}}i(Vr,"fromQrCode");var Ui=i(t=>({name:"Vpqr",displayName:"VP QR",description:"Allows reading and creating QR codes with Verifiable Presentations in them",methods:{vpFromQrCode:i(async(e,r)=>(await Vr({text:r,documentLoader:i(async n=>({document:await t.invoke.contextLoader(n)}),"documentLoader")}))?.vp,"vpFromQrCode"),vpToQrCode:i(async(e,r)=>(await zr({vp:r,documentLoader:i(async n=>({document:await t.invoke.contextLoader(n)}),"documentLoader")}))?.imageDataUrl,"vpToQrCode")}}),"getVpqrPlugin");
3
3
  /*! Bundled license information:
4
4
 
5
5
  @digitalbazaar/cborld/lib/CborldError.js: