@junobuild/core 0.0.59 → 0.0.60

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,59 +1,59 @@
1
1
  import { createRequire as topLevelCreateRequire } from 'module';
2
2
  const require = topLevelCreateRequire(import.meta.url);
3
- var Oy=Object.create;var ps=Object.defineProperty;var Ny=Object.getOwnPropertyDescriptor;var Py=Object.getOwnPropertyNames;var Ry=Object.getPrototypeOf,Iy=Object.prototype.hasOwnProperty;var $n=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Vf=(t,e)=>()=>(t&&(e=t(t=0)),e);var J=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Uy=(t,e)=>{for(var r in e)ps(t,r,{get:e[r],enumerable:!0})},Hf=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Py(e))!Iy.call(t,i)&&i!==r&&ps(t,i,{get:()=>e[i],enumerable:!(n=Ny(e,i))||n.enumerable});return t};var Kn=(t,e,r)=>(r=t!=null?Oy(Ry(t)):{},Hf(e||!t||!t.__esModule?ps(r,"default",{value:t,enumerable:!0}):r,t)),Fy=t=>Hf(ps({},"__esModule",{value:!0}),t);var $f=J(Yn=>{"use strict";Object.defineProperty(Yn,"__esModule",{value:!0});Yn.decode=Yn.encode=void 0;var ys="abcdefghijklmnopqrstuvwxyz234567",Gn=Object.create(null);for(let t=0;t<ys.length;t++)Gn[ys[t]]=t;Gn[0]=Gn.o;Gn[1]=Gn.i;function My(t){let e=0,r=0,n="";function i(s){return e<0?r|=s>>-e:r=s<<e&248,e>3?(e-=8,1):(e<4&&(n+=ys[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?ys[r>>3]:"")}Yn.encode=My;function Cy(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=Gn[o.toLowerCase()];if(a===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);a<<=3,r|=a>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=a<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}Yn.decode=Cy});var Kf=J(bs=>{"use strict";Object.defineProperty(bs,"__esModule",{value:!0});bs.getCrc32=void 0;var qy=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);function jy(t){let e=new Uint8Array(t),r=-1;for(let n=0;n<e.length;n++){let s=(e[n]^r)&255;r=qy[s]^r>>>8}return(r^-1)>>>0}bs.getCrc32=jy});var Aa=J(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.output=_t.exists=_t.hash=_t.bytes=_t.bool=_t.number=_t.isBytes=void 0;function gs(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}_t.number=gs;function Gf(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}_t.bool=Gf;function Yf(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}_t.isBytes=Yf;function Sa(t,...e){if(!Yf(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}_t.bytes=Sa;function Wf(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");gs(t.outputLen),gs(t.blockLen)}_t.hash=Wf;function zf(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}_t.exists=zf;function Df(t,e){Sa(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}_t.output=Df;var ky={number:gs,bool:Gf,bytes:Sa,hash:Wf,exists:zf,output:Df};_t.default=ky});var Zf=J(_s=>{"use strict";Object.defineProperty(_s,"__esModule",{value:!0});_s.crypto=void 0;var ms=$n("node:crypto");_s.crypto=ms&&typeof ms=="object"&&"webcrypto"in ms?ms.webcrypto:void 0});var xn=J(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});pe.randomBytes=pe.wrapXOFConstructorWithOpts=pe.wrapConstructorWithOpts=pe.wrapConstructor=pe.checkOpts=pe.Hash=pe.concatBytes=pe.toBytes=pe.utf8ToBytes=pe.asyncLoop=pe.nextTick=pe.hexToBytes=pe.bytesToHex=pe.byteSwap32=pe.byteSwapIfBE=pe.byteSwap=pe.isLE=pe.rotl=pe.rotr=pe.createView=pe.u32=pe.u8=pe.isBytes=void 0;var Oa=Zf(),Pa=Aa();function Vy(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}pe.isBytes=Vy;var Hy=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);pe.u8=Hy;var $y=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));pe.u32=$y;var Ky=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);pe.createView=Ky;var Gy=(t,e)=>t<<32-e|t>>>e;pe.rotr=Gy;var Yy=(t,e)=>t<<e|t>>>32-e>>>0;pe.rotl=Yy;pe.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var Wy=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;pe.byteSwap=Wy;pe.byteSwapIfBE=pe.isLE?t=>t:t=>(0,pe.byteSwap)(t);function zy(t){for(let e=0;e<t.length;e++)t[e]=(0,pe.byteSwap)(t[e])}pe.byteSwap32=zy;var Dy=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Zy(t){(0,Pa.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=Dy[t[r]];return e}pe.bytesToHex=Zy;var Cr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Xf(t){if(t>=Cr._0&&t<=Cr._9)return t-Cr._0;if(t>=Cr._A&&t<=Cr._F)return t-(Cr._A-10);if(t>=Cr._a&&t<=Cr._f)return t-(Cr._a-10)}function Xy(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=Xf(t.charCodeAt(s)),a=Xf(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}pe.hexToBytes=Xy;var Jy=async()=>{};pe.nextTick=Jy;async function Ly(t,e,r){let n=Date.now();for(let i=0;i<t;i++){r(i);let s=Date.now()-n;s>=0&&s<e||(await(0,pe.nextTick)(),n+=s)}}pe.asyncLoop=Ly;function Jf(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}pe.utf8ToBytes=Jf;function ws(t){return typeof t=="string"&&(t=Jf(t)),(0,Pa.bytes)(t),t}pe.toBytes=ws;function Qy(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];(0,Pa.bytes)(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}pe.concatBytes=Qy;var Na=class{clone(){return this._cloneInto()}};pe.Hash=Na;var eb={}.toString;function tb(t,e){if(e!==void 0&&eb.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}pe.checkOpts=tb;function rb(t){let e=n=>t().update(ws(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}pe.wrapConstructor=rb;function nb(t){let e=(n,i)=>t(i).update(ws(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}pe.wrapConstructorWithOpts=nb;function ib(t){let e=(n,i)=>t(i).update(ws(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}pe.wrapXOFConstructorWithOpts=ib;function sb(t=32){if(Oa.crypto&&typeof Oa.crypto.getRandomValues=="function")return Oa.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}pe.randomBytes=sb});var Ua=J(zr=>{"use strict";Object.defineProperty(zr,"__esModule",{value:!0});zr.HashMD=zr.Maj=zr.Chi=void 0;var Ra=Aa(),Ti=xn();function ob(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,f=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+f,a,n)}var ab=(t,e,r)=>t&e^~t&r;zr.Chi=ab;var cb=(t,e,r)=>t&e^t&r^e&r;zr.Maj=cb;var Ia=class extends Ti.Hash{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,Ti.createView)(this.buffer)}update(e){(0,Ra.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,Ti.toBytes)(e);let s=e.length;for(let o=0;o<s;){let a=Math.min(i-this.pos,s-o);if(a===i){let c=(0,Ti.createView)(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,Ra.exists)(this),(0,Ra.output)(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let d=o;d<i;d++)r[d]=0;ob(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=(0,Ti.createView)(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,l=this.get();if(f>l.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,l[d],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}};zr.HashMD=Ia});var xs=J(Wn=>{"use strict";Object.defineProperty(Wn,"__esModule",{value:!0});Wn.sha224=Wn.sha256=void 0;var Fa=Ua(),Xt=xn(),ub=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Dr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Zr=new Uint32Array(64),Es=class extends Fa.HashMD{constructor(){super(64,32,8,!1),this.A=Dr[0]|0,this.B=Dr[1]|0,this.C=Dr[2]|0,this.D=Dr[3]|0,this.E=Dr[4]|0,this.F=Dr[5]|0,this.G=Dr[6]|0,this.H=Dr[7]|0}get(){let{A:e,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[e,r,n,i,s,o,a,c]}set(e,r,n,i,s,o,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let d=0;d<16;d++,r+=4)Zr[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){let v=Zr[d-15],E=Zr[d-2],g=(0,Xt.rotr)(v,7)^(0,Xt.rotr)(v,18)^v>>>3,m=(0,Xt.rotr)(E,17)^(0,Xt.rotr)(E,19)^E>>>10;Zr[d]=m+Zr[d-7]+g+Zr[d-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:f,H:l}=this;for(let d=0;d<64;d++){let v=(0,Xt.rotr)(a,6)^(0,Xt.rotr)(a,11)^(0,Xt.rotr)(a,25),E=l+v+(0,Fa.Chi)(a,c,f)+ub[d]+Zr[d]|0,m=((0,Xt.rotr)(n,2)^(0,Xt.rotr)(n,13)^(0,Xt.rotr)(n,22))+(0,Fa.Maj)(n,i,s)|0;l=f,f=c,c=a,a=o+E|0,o=s,s=i,i=n,n=E+m|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,l=l+this.H|0,this.set(n,i,s,o,a,c,f,l)}roundClean(){Zr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Ma=class extends Es{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};Wn.sha256=(0,Xt.wrapConstructor)(()=>new Es);Wn.sha224=(0,Xt.wrapConstructor)(()=>new Ma)});var Lf=J(vs=>{"use strict";Object.defineProperty(vs,"__esModule",{value:!0});vs.sha224=void 0;var fb=xs();function lb(t){return fb.sha224.create().update(new Uint8Array(t)).digest()}vs.sha224=lb});var Rt=J(pr=>{"use strict";Object.defineProperty(pr,"__esModule",{value:!0});pr.Principal=pr.JSON_KEY_PRINCIPAL=void 0;var Qf=$f(),db=Kf(),hb=Lf();pr.JSON_KEY_PRINCIPAL="__principal__";var pb=2,el=4,yb="aaaaa-aa",bb=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},gb=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),Ca=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([el]))}static managementCanister(){return this.fromHex(yb)}static selfAuthenticating(e){let r=(0,hb.sha224)(e);return new this(new Uint8Array([...r,pb]))}static from(e){if(typeof e=="string")return t.fromText(e);if(Object.getPrototypeOf(e)===Uint8Array.prototype)return new t(e);if(typeof e=="object"&&e!==null&&e._isPrincipal===!0)return new t(e._arr);throw new Error(`Impossible to convert ${JSON.stringify(e)} to Principal.`)}static fromHex(e){return new this(bb(e))}static fromText(e){let r=e;if(e.includes(pr.JSON_KEY_PRINCIPAL)){let o=JSON.parse(e);pr.JSON_KEY_PRINCIPAL in o&&(r=o[pr.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,Qf.decode)(n);i=i.slice(4,i.length);let s=new this(i);if(s.toText()!==r)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${r}" may not be a valid Principal ID).`);return s}static fromUint8Array(e){return new this(e)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===el}toUint8Array(){return this._arr}toHex(){return gb(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,(0,db.getCrc32)(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),a=(0,Qf.encode)(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[pr.JSON_KEY_PRINCIPAL]:this.toText()}}compareTo(e){for(let r=0;r<Math.min(this._arr.length,e._arr.length);r++){if(this._arr[r]<e._arr[r])return"lt";if(this._arr[r]>e._arr[r])return"gt"}return this._arr.length<e._arr.length?"lt":this._arr.length>e._arr.length?"gt":"eq"}ltEq(e){let r=this.compareTo(e);return r=="lt"||r=="eq"}gtEq(e){let r=this.compareTo(e);return r=="gt"||r=="eq"}};pr.Principal=Ca});var dl=J(As=>{"use strict";As.byteLength=xb;As.toByteArray=Tb;As.fromByteArray=Ab;var br=[],Jt=[],Eb=typeof Uint8Array<"u"?Uint8Array:Array,Ka="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(vn=0,fl=Ka.length;vn<fl;++vn)br[vn]=Ka[vn],Jt[Ka.charCodeAt(vn)]=vn;var vn,fl;Jt[45]=62;Jt[95]=63;function ll(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function xb(t){var e=ll(t),r=e[0],n=e[1];return(r+n)*3/4-n}function vb(t,e,r){return(e+r)*3/4-r}function Tb(t){var e,r=ll(t),n=r[0],i=r[1],s=new Eb(vb(t,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=Jt[t.charCodeAt(c)]<<18|Jt[t.charCodeAt(c+1)]<<12|Jt[t.charCodeAt(c+2)]<<6|Jt[t.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=Jt[t.charCodeAt(c)]<<2|Jt[t.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=Jt[t.charCodeAt(c)]<<10|Jt[t.charCodeAt(c+1)]<<4|Jt[t.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function Bb(t){return br[t>>18&63]+br[t>>12&63]+br[t>>6&63]+br[t&63]}function Sb(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push(Bb(n));return i.join("")}function Ab(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(Sb(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(br[e>>2]+br[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(br[e>>10]+br[e>>4&63]+br[e<<2&63]+"=")),i.join("")}});var Ya=J(Ga=>{Ga.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,f=c>>1,l=-7,d=r?i-1:0,v=r?-1:1,E=t[e+d];for(d+=v,s=E&(1<<-l)-1,E>>=-l,l+=a;l>0;s=s*256+t[e+d],d+=v,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=o*256+t[e+d],d+=v,l-=8);if(s===0)s=1-f;else{if(s===c)return o?NaN:(E?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-f}return(E?-1:1)*o*Math.pow(2,s-n)};Ga.write=function(t,e,r,n,i,s){var o,a,c,f=s*8-i-1,l=(1<<f)-1,d=l>>1,v=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=n?0:s-1,g=n?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+d>=1?e+=v/c:e+=v*Math.pow(2,1-d),e*c>=2&&(o++,c/=2),o+d>=l?(a=0,o=l):o+d>=1?(a=(e*c-1)*Math.pow(2,i),o=o+d):(a=e*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;t[r+E]=a&255,E+=g,a/=256,i-=8);for(o=o<<i|a,f+=i;f>0;t[r+E]=o&255,E+=g,o/=256,f-=8);t[r+E-g]|=m*128}});var Nl=J(Ln=>{"use strict";var Wa=dl(),Xn=Ya(),hl=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Ln.Buffer=V;Ln.SlowBuffer=Ub;Ln.INSPECT_MAX_BYTES=50;var Os=2147483647;Ln.kMaxLength=Os;V.TYPED_ARRAY_SUPPORT=Ob();!V.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Ob(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(V.prototype,"parent",{enumerable:!0,get:function(){if(V.isBuffer(this))return this.buffer}});Object.defineProperty(V.prototype,"offset",{enumerable:!0,get:function(){if(V.isBuffer(this))return this.byteOffset}});function jr(t){if(t>Os)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,V.prototype),e}function V(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Xa(t)}return gl(t,e,r)}V.poolSize=8192;function gl(t,e,r){if(typeof t=="string")return Pb(t,e);if(ArrayBuffer.isView(t))return Rb(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(gr(t,ArrayBuffer)||t&&gr(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(gr(t,SharedArrayBuffer)||t&&gr(t.buffer,SharedArrayBuffer)))return Da(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return V.from(n,e,r);let i=Ib(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return V.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}V.from=function(t,e,r){return gl(t,e,r)};Object.setPrototypeOf(V.prototype,Uint8Array.prototype);Object.setPrototypeOf(V,Uint8Array);function ml(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function Nb(t,e,r){return ml(t),t<=0?jr(t):e!==void 0?typeof r=="string"?jr(t).fill(e,r):jr(t).fill(e):jr(t)}V.alloc=function(t,e,r){return Nb(t,e,r)};function Xa(t){return ml(t),jr(t<0?0:Ja(t)|0)}V.allocUnsafe=function(t){return Xa(t)};V.allocUnsafeSlow=function(t){return Xa(t)};function Pb(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!V.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=_l(t,e)|0,n=jr(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function za(t){let e=t.length<0?0:Ja(t.length)|0,r=jr(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Rb(t){if(gr(t,Uint8Array)){let e=new Uint8Array(t);return Da(e.buffer,e.byteOffset,e.byteLength)}return za(t)}function Da(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,V.prototype),n}function Ib(t){if(V.isBuffer(t)){let e=Ja(t.length)|0,r=jr(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Qa(t.length)?jr(0):za(t);if(t.type==="Buffer"&&Array.isArray(t.data))return za(t.data)}function Ja(t){if(t>=Os)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Os.toString(16)+" bytes");return t|0}function Ub(t){return+t!=t&&(t=0),V.alloc(+t)}V.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==V.prototype};V.compare=function(e,r){if(gr(e,Uint8Array)&&(e=V.from(e,e.offset,e.byteLength)),gr(r,Uint8Array)&&(r=V.from(r,r.offset,r.byteLength)),!V.isBuffer(e)||!V.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};V.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};V.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return V.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=V.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(gr(o,Uint8Array))s+o.length>i.length?(V.isBuffer(o)||(o=V.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(V.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function _l(t,e){if(V.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||gr(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Za(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ol(t).length;default:if(i)return n?-1:Za(t).length;e=(""+e).toLowerCase(),i=!0}}V.byteLength=_l;function Fb(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Gb(this,e,r);case"utf8":case"utf-8":return El(this,e,r);case"ascii":return $b(this,e,r);case"latin1":case"binary":return Kb(this,e,r);case"base64":return Vb(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Yb(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}V.prototype._isBuffer=!0;function Tn(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}V.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)Tn(this,r,r+1);return this};V.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)Tn(this,r,r+3),Tn(this,r+1,r+2);return this};V.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)Tn(this,r,r+7),Tn(this,r+1,r+6),Tn(this,r+2,r+5),Tn(this,r+3,r+4);return this};V.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?El(this,0,e):Fb.apply(this,arguments)};V.prototype.toLocaleString=V.prototype.toString;V.prototype.equals=function(e){if(!V.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:V.compare(this,e)===0};V.prototype.inspect=function(){let e="",r=Ln.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};hl&&(V.prototype[hl]=V.prototype.inspect);V.prototype.compare=function(e,r,n,i,s){if(gr(e,Uint8Array)&&(e=V.from(e,e.offset,e.byteLength)),!V.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,a=n-r,c=Math.min(o,a),f=this.slice(i,s),l=e.slice(r,n);for(let d=0;d<c;++d)if(f[d]!==l[d]){o=f[d],a=l[d];break}return o<a?-1:a<o?1:0};function wl(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Qa(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=V.from(e,n)),V.isBuffer(e))return e.length===0?-1:pl(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):pl(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function pl(t,e,r,n,i){let s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(l,d){return s===1?l[d]:l.readUInt16BE(d*s)}let f;if(i){let l=-1;for(f=r;f<o;f++)if(c(t,f)===c(e,l===-1?0:f-l)){if(l===-1&&(l=f),f-l+1===a)return l*s}else l!==-1&&(f-=f-l),l=-1}else for(r+a>o&&(r=o-a),f=r;f>=0;f--){let l=!0;for(let d=0;d<a;d++)if(c(t,f+d)!==c(e,d)){l=!1;break}if(l)return f}return-1}V.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};V.prototype.indexOf=function(e,r,n){return wl(this,e,r,n,!0)};V.prototype.lastIndexOf=function(e,r,n){return wl(this,e,r,n,!1)};function Mb(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(e.substr(o*2,2),16);if(Qa(a))return o;t[r+o]=a}return o}function Cb(t,e,r,n){return Ns(Za(e,t.length-r),t,r,n)}function qb(t,e,r,n){return Ns(Zb(e),t,r,n)}function jb(t,e,r,n){return Ns(Ol(e),t,r,n)}function kb(t,e,r,n){return Ns(Xb(e,t.length-r),t,r,n)}V.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return Mb(this,e,r,n);case"utf8":case"utf-8":return Cb(this,e,r,n);case"ascii":case"latin1":case"binary":return qb(this,e,r,n);case"base64":return jb(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return kb(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};V.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Vb(t,e,r){return e===0&&r===t.length?Wa.fromByteArray(t):Wa.fromByteArray(t.slice(e,r))}function El(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,f,l,d;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)===128&&(d=(s&31)<<6|c&63,d>127&&(o=d));break;case 3:c=t[i+1],f=t[i+2],(c&192)===128&&(f&192)===128&&(d=(s&15)<<12|(c&63)<<6|f&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:c=t[i+1],f=t[i+2],l=t[i+3],(c&192)===128&&(f&192)===128&&(l&192)===128&&(d=(s&15)<<18|(c&63)<<12|(f&63)<<6|l&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return Hb(n)}var yl=4096;function Hb(t){let e=t.length;if(e<=yl)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=yl));return r}function $b(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Kb(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Gb(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=e;s<r;++s)i+=Jb[t[s]];return i}function Yb(t,e,r){let n=t.slice(e,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}V.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,V.prototype),i};function pt(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}V.prototype.readUintLE=V.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||pt(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};V.prototype.readUintBE=V.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||pt(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};V.prototype.readUint8=V.prototype.readUInt8=function(e,r){return e=e>>>0,r||pt(e,1,this.length),this[e]};V.prototype.readUint16LE=V.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||pt(e,2,this.length),this[e]|this[e+1]<<8};V.prototype.readUint16BE=V.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||pt(e,2,this.length),this[e]<<8|this[e+1]};V.prototype.readUint32LE=V.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||pt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};V.prototype.readUint32BE=V.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||pt(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};V.prototype.readBigUInt64LE=Xr(function(e){e=e>>>0,Jn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Bi(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});V.prototype.readBigUInt64BE=Xr(function(e){e=e>>>0,Jn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Bi(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});V.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||pt(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};V.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||pt(e,r,this.length);let i=r,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};V.prototype.readInt8=function(e,r){return e=e>>>0,r||pt(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};V.prototype.readInt16LE=function(e,r){e=e>>>0,r||pt(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};V.prototype.readInt16BE=function(e,r){e=e>>>0,r||pt(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};V.prototype.readInt32LE=function(e,r){return e=e>>>0,r||pt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};V.prototype.readInt32BE=function(e,r){return e=e>>>0,r||pt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};V.prototype.readBigInt64LE=Xr(function(e){e=e>>>0,Jn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Bi(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});V.prototype.readBigInt64BE=Xr(function(e){e=e>>>0,Jn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Bi(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});V.prototype.readFloatLE=function(e,r){return e=e>>>0,r||pt(e,4,this.length),Xn.read(this,e,!0,23,4)};V.prototype.readFloatBE=function(e,r){return e=e>>>0,r||pt(e,4,this.length),Xn.read(this,e,!1,23,4)};V.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||pt(e,8,this.length),Xn.read(this,e,!0,52,8)};V.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||pt(e,8,this.length),Xn.read(this,e,!1,52,8)};function jt(t,e,r,n,i,s){if(!V.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}V.prototype.writeUintLE=V.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;jt(this,e,r,n,a,0)}let s=1,o=0;for(this[r]=e&255;++o<n&&(s*=256);)this[r+o]=e/s&255;return r+n};V.prototype.writeUintBE=V.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;jt(this,e,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=e&255;--s>=0&&(o*=256);)this[r+s]=e/o&255;return r+n};V.prototype.writeUint8=V.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,1,255,0),this[r]=e&255,r+1};V.prototype.writeUint16LE=V.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};V.prototype.writeUint16BE=V.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};V.prototype.writeUint32LE=V.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};V.prototype.writeUint32BE=V.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function xl(t,e,r,n,i){Al(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,r}function vl(t,e,r,n,i){Al(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s=s>>8,t[r+6]=s,s=s>>8,t[r+5]=s,s=s>>8,t[r+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o=o>>8,t[r+2]=o,o=o>>8,t[r+1]=o,o=o>>8,t[r]=o,r+8}V.prototype.writeBigUInt64LE=Xr(function(e,r=0){return xl(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});V.prototype.writeBigUInt64BE=Xr(function(e,r=0){return vl(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});V.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);jt(this,e,r,n,c-1,-c)}let s=0,o=1,a=0;for(this[r]=e&255;++s<n&&(o*=256);)e<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};V.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);jt(this,e,r,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[r+s]=e&255;--s>=0&&(o*=256);)e<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};V.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};V.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};V.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};V.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};V.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||jt(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};V.prototype.writeBigInt64LE=Xr(function(e,r=0){return xl(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});V.prototype.writeBigInt64BE=Xr(function(e,r=0){return vl(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Tl(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Bl(t,e,r,n,i){return e=+e,r=r>>>0,i||Tl(t,e,r,4,34028234663852886e22,-34028234663852886e22),Xn.write(t,e,r,n,23,4),r+4}V.prototype.writeFloatLE=function(e,r,n){return Bl(this,e,r,!0,n)};V.prototype.writeFloatBE=function(e,r,n){return Bl(this,e,r,!1,n)};function Sl(t,e,r,n,i){return e=+e,r=r>>>0,i||Tl(t,e,r,8,17976931348623157e292,-17976931348623157e292),Xn.write(t,e,r,n,52,8),r+8}V.prototype.writeDoubleLE=function(e,r,n){return Sl(this,e,r,!0,n)};V.prototype.writeDoubleBE=function(e,r,n){return Sl(this,e,r,!1,n)};V.prototype.copy=function(e,r,n,i){if(!V.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),s};V.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!V.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=r;s<n;++s)this[s]=e;else{let o=V.isBuffer(e)?e:V.from(e,i),a=o.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var Zn={};function La(t,e,r){Zn[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}La("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);La("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);La("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=bl(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=bl(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function bl(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function Wb(t,e,r){Jn(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Bi(e,t.length-(r+1))}function Al(t,e,r,n,i,s){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",a;throw s>3?e===0||e===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${e}${o} and <= ${r}${o}`,new Zn.ERR_OUT_OF_RANGE("value",a,t)}Wb(n,i,s)}function Jn(t,e){if(typeof t!="number")throw new Zn.ERR_INVALID_ARG_TYPE(e,"number",t)}function Bi(t,e,r){throw Math.floor(t)!==t?(Jn(t,r),new Zn.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new Zn.ERR_BUFFER_OUT_OF_BOUNDS:new Zn.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var zb=/[^+/0-9A-Za-z-_]/g;function Db(t){if(t=t.split("=")[0],t=t.trim().replace(zb,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Za(t,e){e=e||1/0;let r,n=t.length,i=null,s=[];for(let o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function Zb(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Xb(t,e){let r,n,i,s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function Ol(t){return Wa.toByteArray(Db(t))}function Ns(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function gr(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Qa(t){return t!==t}var Jb=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Xr(t){return typeof BigInt>"u"?Lb:t}function Lb(){throw new Error("BigInt not supported")}});var Pl=J(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.ReplicaRejectCode=void 0;var Qb;(function(t){t[t.SysFatal=1]="SysFatal",t[t.SysTransient=2]="SysTransient",t[t.DestinationInvalid=3]="DestinationInvalid",t[t.CanisterReject=4]="CanisterReject",t[t.CanisterError=5]="CanisterError"})(Qb=Si.ReplicaRejectCode||(Si.ReplicaRejectCode={}))});var Qn=J(Ps=>{"use strict";Object.defineProperty(Ps,"__esModule",{value:!0});Ps.AgentError=void 0;var ec=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};Ps.AgentError=ec});var Us=J(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.bufFromBufLike=kt.uint8ToBuf=kt.PipeArrayBuffer=kt.fromHexString=kt.toHexString=kt.concat=void 0;function eg(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e}kt.concat=eg;function tg(t){return new Uint8Array(t).reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}kt.toHexString=tg;function rg(t){var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))}kt.fromHexString=rg;var tc=class{constructor(e,r=e?.byteLength||0){this._buffer=Is(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return Is(this._view.slice())}get byteLength(){return this._view.byteLength}read(e){let r=this._view.subarray(0,e);return this._view=this._view.subarray(e),r.slice().buffer}readUint8(){let e=this._view[0];return this._view=this._view.subarray(1),e}write(e){let r=new Uint8Array(e),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+r.byteLength>=this._buffer.byteLength?this.alloc(r.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+r.byteLength),this._view.set(r,n)}get end(){return this._view.byteLength===0}alloc(e){let r=new ArrayBuffer((this._buffer.byteLength+e)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+e);n.set(this._view),this._buffer=r,this._view=n}};kt.PipeArrayBuffer=tc;function Rs(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}kt.uint8ToBuf=Rs;function Is(t){return t instanceof Uint8Array?Rs(t):t instanceof ArrayBuffer?t:Array.isArray(t)?Rs(new Uint8Array(t)):"buffer"in t?Is(t.buffer):Rs(new Uint8Array(t))}kt.bufFromBufLike=Is});var rc=J(Fs=>{"use strict";Object.defineProperty(Fs,"__esModule",{value:!0});Fs.idlLabelToId=void 0;function ng(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function ig(t){if(/^_\d+_$/.test(t)||/^_0x[0-9a-fA-F]+_$/.test(t)){let e=+t.slice(1,-1);if(Number.isSafeInteger(e)&&e>=0&&e<2**32)return e}return ng(t)}Fs.idlLabelToId=ig});var ic=J(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.readIntLE=De.readUIntLE=De.writeIntLE=De.writeUIntLE=De.slebDecode=De.slebEncode=De.lebDecode=De.lebEncode=De.safeReadUint8=De.safeRead=void 0;var nc=Us();function Rl(){throw new Error("unexpected end of buffer")}function Il(t,e){return t.byteLength<e&&Rl(),t.read(e)}De.safeRead=Il;function Ms(t){let e=t.readUint8();return e===void 0&&Rl(),e}De.safeReadUint8=Ms;function sg(t){if(typeof t=="number"&&(t=BigInt(t)),t<BigInt(0))throw new Error("Cannot leb encode negative values.");let e=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,r=new nc.PipeArrayBuffer(new ArrayBuffer(e),0);for(;;){let n=Number(t&BigInt(127));if(t/=BigInt(128),t===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}De.lebEncode=sg;function Ul(t){let e=BigInt(1),r=BigInt(0),n;do n=Ms(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}De.lebDecode=Ul;function og(t){typeof t=="number"&&(t=BigInt(t));let e=t<BigInt(0);e&&(t=-t-BigInt(1));let r=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,n=new nc.PipeArrayBuffer(new ArrayBuffer(r),0);for(;;){let s=i(t);if(t/=BigInt(128),e&&t===BigInt(0)&&s&64||!e&&t===BigInt(0)&&!(s&64)){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let o=s%BigInt(128);return Number(e?BigInt(128)-o-BigInt(1):o)}return n.buffer}De.slebEncode=og;function ag(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if(!(e[r]&64))return Ul(t);break}let n=new Uint8Array(Il(t,r+1)),i=BigInt(0);for(let s=n.byteLength-1;s>=0;s--)i=i*BigInt(128)+BigInt(128-(n[s]&127)-1);return-i-BigInt(1)}De.slebDecode=ag;function cg(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return Fl(t,e)}De.writeUIntLE=cg;function Fl(t,e){t=BigInt(t);let r=new nc.PipeArrayBuffer(new ArrayBuffer(Math.min(1,e)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(t%i);for(r.write(new Uint8Array([o]));++n<e;)t<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((t/i-s)%BigInt(256)),r.write(new Uint8Array([o])),i*=BigInt(256);return r.buffer}De.writeIntLE=Fl;function Ml(t,e){let r=BigInt(Ms(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(Ms(t));r=r+n*s}return r}De.readUIntLE=Ml;function ug(t,e){let r=Ml(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}De.readIntLE=ug});var Cl=J(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});ei.iexp2=ei.ilog2=void 0;function fg(t){let e=BigInt(t);if(t<=0)throw new RangeError("Input must be positive");return e.toString(2).length-1}ei.ilog2=fg;function lg(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}ei.iexp2=lg});var uc=J(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.Variant=H.Record=H.Opt=H.Vec=H.Tuple=H.Principal=H.Nat64=H.Nat32=H.Nat16=H.Nat8=H.Int64=H.Int32=H.Int16=H.Int8=H.Float64=H.Float32=H.Nat=H.Int=H.Text=H.Null=H.Bool=H.Unknown=H.Reserved=H.Empty=H.decode=H.encode=H.ServiceClass=H.FuncClass=H.PrincipalClass=H.RecClass=H.VariantClass=H.TupleClass=H.RecordClass=H.OptClass=H.VecClass=H.FixedNatClass=H.FixedIntClass=H.FloatClass=H.NatClass=H.IntClass=H.TextClass=H.ReservedClass=H.NullClass=H.BoolClass=H.UnknownClass=H.EmptyClass=H.ConstructType=H.PrimitiveType=H.Type=H.Visitor=void 0;H.Service=H.Func=H.Rec=void 0;var dg=Rt(),Pe=Us(),mr=rc(),ie=ic(),sc=Cl(),Cs="DIDL",ql=400;function Ai(t,e,r){return t.map((n,i)=>r(n,e[i]))}var oc=class{constructor(){this._typs=[],this._idx=new Map}has(e){return this._idx.has(e.name)}add(e,r){let n=this._typs.length;this._idx.set(e.name,n),this._typs.push(r)}merge(e,r){let n=this._idx.get(e.name),i=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+e);if(i===void 0)throw new Error("Missing type index for "+r);this._typs[n]=this._typs[i],this._typs.splice(i,1),this._idx.delete(r)}encode(){let e=(0,ie.lebEncode)(this._typs.length),r=(0,Pe.concat)(...this._typs);return(0,Pe.concat)(e,r)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return(0,ie.slebEncode)(this._idx.get(e)||0)}},ac=class{visitType(e,r){throw new Error("Not implemented")}visitPrimitive(e,r){return this.visitType(e,r)}visitEmpty(e,r){return this.visitPrimitive(e,r)}visitBool(e,r){return this.visitPrimitive(e,r)}visitNull(e,r){return this.visitPrimitive(e,r)}visitReserved(e,r){return this.visitPrimitive(e,r)}visitText(e,r){return this.visitPrimitive(e,r)}visitNumber(e,r){return this.visitPrimitive(e,r)}visitInt(e,r){return this.visitNumber(e,r)}visitNat(e,r){return this.visitNumber(e,r)}visitFloat(e,r){return this.visitPrimitive(e,r)}visitFixedInt(e,r){return this.visitNumber(e,r)}visitFixedNat(e,r){return this.visitNumber(e,r)}visitPrincipal(e,r){return this.visitPrimitive(e,r)}visitConstruct(e,r){return this.visitType(e,r)}visitVec(e,r,n){return this.visitConstruct(e,n)}visitOpt(e,r,n){return this.visitConstruct(e,n)}visitRecord(e,r,n){return this.visitConstruct(e,n)}visitTuple(e,r,n){let i=r.map((s,o)=>[`_${o}_`,s]);return this.visitRecord(e,i,n)}visitVariant(e,r,n){return this.visitConstruct(e,n)}visitRec(e,r,n){return this.visitConstruct(r,n)}visitFunc(e,r){return this.visitConstruct(e,r)}visitService(e,r){return this.visitConstruct(e,r)}};H.Visitor=ac;var ti=class{display(){return this.name}valueToString(e){return tt(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}};H.Type=ti;var Vt=class extends ti{checkType(e){if(this.name!==e.name)throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`);return e}_buildTypeTableImpl(e){}};H.PrimitiveType=Vt;var wr=class extends ti{checkType(e){if(e instanceof Jr){let r=e.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`)}encodeType(e){return e.indexOf(this.name)}};H.ConstructType=wr;var qs=class extends Vt{accept(e,r){return e.visitEmpty(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return(0,ie.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};H.EmptyClass=qs;var js=class extends ti{checkType(e){throw new Error("Method not implemented for unknown.")}accept(e,r){throw e.visitType(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(e,r){let n=r.decodeValue(e,r);Object(n)!==n&&(n=Object(n));let i;return r instanceof Jr?i=()=>r.getType():i=()=>r,Object.defineProperty(n,"type",{value:i,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}};H.UnknownClass=js;var ks=class extends Vt{accept(e,r){return e.visitBool(this,r)}covariant(e){if(typeof e=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return(0,ie.slebEncode)(-2)}decodeValue(e,r){switch(this.checkType(r),(0,ie.safeReadUint8)(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};H.BoolClass=ks;var Vs=class extends Vt{accept(e,r){return e.visitNull(this,r)}covariant(e){if(e===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ie.slebEncode)(-1)}decodeValue(e,r){return this.checkType(r),null}get name(){return"null"}};H.NullClass=Vs;var ri=class extends Vt{accept(e,r){return e.visitReserved(this,r)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ie.slebEncode)(-16)}decodeValue(e,r){return r.name!==this.name&&r.decodeValue(e,r),null}get name(){return"reserved"}};H.ReservedClass=ri;var Hs=class extends Vt{accept(e,r){return e.visitText(this,r)}covariant(e){if(typeof e=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=new TextEncoder().encode(e),n=(0,ie.lebEncode)(r.byteLength);return(0,Pe.concat)(n,r)}encodeType(){return(0,ie.slebEncode)(-15)}decodeValue(e,r){this.checkType(r);let n=(0,ie.lebDecode)(e),i=(0,ie.safeRead)(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}};H.TextClass=Hs;var $s=class extends Vt{accept(e,r){return e.visitInt(this,r)}covariant(e){if(typeof e=="bigint"||Number.isInteger(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,ie.slebEncode)(e)}encodeType(){return(0,ie.slebEncode)(-4)}decodeValue(e,r){return this.checkType(r),(0,ie.slebDecode)(e)}get name(){return"int"}valueToString(e){return e.toString()}};H.IntClass=$s;var Ks=class extends Vt{accept(e,r){return e.visitNat(this,r)}covariant(e){if(typeof e=="bigint"&&e>=BigInt(0)||Number.isInteger(e)&&e>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,ie.lebEncode)(e)}encodeType(){return(0,ie.slebEncode)(-3)}decodeValue(e,r){return this.checkType(r),(0,ie.lebDecode)(e)}get name(){return"nat"}valueToString(e){return e.toString()}};H.NatClass=Ks;var Oi=class extends Vt{constructor(e){if(super(),this._bits=e,e!==32&&e!==64)throw new Error("not a valid float type")}accept(e,r){return e.visitFloat(this,r)}covariant(e){if(typeof e=="number"||e instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,e,!0):n.setFloat64(0,e,!0),r}encodeType(){let e=this._bits===32?-13:-14;return(0,ie.slebEncode)(e)}decodeValue(e,r){this.checkType(r);let n=(0,ie.safeRead)(e,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(e){return e.toString()}};H.FloatClass=Oi;var kr=class extends Vt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=(0,sc.iexp2)(this._bits-1)*BigInt(-1),n=(0,sc.iexp2)(this._bits-1)-BigInt(1),i=!1;if(typeof e=="bigint")i=e>=r&&e<=n;else if(Number.isInteger(e)){let s=BigInt(e);i=s>=r&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,ie.writeIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,ie.slebEncode)(-9-e)}decodeValue(e,r){this.checkType(r);let n=(0,ie.readIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}};H.FixedIntClass=kr;var _r=class extends Vt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=(0,sc.iexp2)(this._bits),n=!1;if(typeof e=="bigint"&&e>=BigInt(0)?n=e<r:Number.isInteger(e)&&e>=0?n=BigInt(e)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,ie.writeUIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,ie.slebEncode)(-5-e)}decodeValue(e,r){this.checkType(r);let n=(0,ie.readUIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}};H.FixedNatClass=_r;var Gs=class t extends wr{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof _r&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof _r?this._type._bits:this._type instanceof kr?this._type._bits:0;if(ArrayBuffer.isView(e)&&r==e.BYTES_PER_ELEMENT*8||Array.isArray(e)&&e.every((n,i)=>{try{return this._type.covariant(n)}catch(s){throw new Error(`Invalid ${this.display()} argument:
3
+ var Uy=Object.create;var vs=Object.defineProperty;var Fy=Object.getOwnPropertyDescriptor;var My=Object.getOwnPropertyNames;var Cy=Object.getPrototypeOf,qy=Object.prototype.hasOwnProperty;var zn=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Ll=(t,e)=>()=>(t&&(e=t(t=0)),e);var L=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),jy=(t,e)=>{for(var r in e)vs(t,r,{get:e[r],enumerable:!0})},Ql=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of My(e))!qy.call(t,i)&&i!==r&&vs(t,i,{get:()=>e[i],enumerable:!(n=Fy(e,i))||n.enumerable});return t};var Dn=(t,e,r)=>(r=t!=null?Uy(Cy(t)):{},Ql(e||!t||!t.__esModule?vs(r,"default",{value:t,enumerable:!0}):r,t)),ky=t=>Ql(vs({},"__esModule",{value:!0}),t);var ef=L(Xn=>{"use strict";Object.defineProperty(Xn,"__esModule",{value:!0});Xn.decode=Xn.encode=void 0;var Ts="abcdefghijklmnopqrstuvwxyz234567",Zn=Object.create(null);for(let t=0;t<Ts.length;t++)Zn[Ts[t]]=t;Zn[0]=Zn.o;Zn[1]=Zn.i;function Vy(t){let e=0,r=0,n="";function i(s){return e<0?r|=s>>-e:r=s<<e&248,e>3?(e-=8,1):(e<4&&(n+=Ts[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?Ts[r>>3]:"")}Xn.encode=Vy;function Hy(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=Zn[o.toLowerCase()];if(a===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);a<<=3,r|=a>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=a<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}Xn.decode=Hy});var tf=L(Ss=>{"use strict";Object.defineProperty(Ss,"__esModule",{value:!0});Ss.getCrc32=void 0;var $y=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);function Ky(t){let e=new Uint8Array(t),r=-1;for(let n=0;n<e.length;n++){let s=(e[n]^r)&255;r=$y[s]^r>>>8}return(r^-1)>>>0}Ss.getCrc32=Ky});var Ca=L(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});bt.output=bt.exists=bt.hash=bt.bytes=bt.bool=bt.number=bt.isBytes=void 0;function Bs(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}bt.number=Bs;function rf(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}bt.bool=rf;function nf(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}bt.isBytes=nf;function Ma(t,...e){if(!nf(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}bt.bytes=Ma;function sf(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Bs(t.outputLen),Bs(t.blockLen)}bt.hash=sf;function of(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}bt.exists=of;function af(t,e){Ma(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}bt.output=af;var Gy={number:Bs,bool:rf,bytes:Ma,hash:sf,exists:of,output:af};bt.default=Gy});var cf=L(Os=>{"use strict";Object.defineProperty(Os,"__esModule",{value:!0});Os.crypto=void 0;var As=zn("node:crypto");Os.crypto=As&&typeof As=="object"&&"webcrypto"in As?As.webcrypto:void 0});var Bn=L(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.randomBytes=ye.wrapXOFConstructorWithOpts=ye.wrapConstructorWithOpts=ye.wrapConstructor=ye.checkOpts=ye.Hash=ye.concatBytes=ye.toBytes=ye.utf8ToBytes=ye.asyncLoop=ye.nextTick=ye.hexToBytes=ye.bytesToHex=ye.byteSwap32=ye.byteSwapIfBE=ye.byteSwap=ye.isLE=ye.rotl=ye.rotr=ye.createView=ye.u32=ye.u8=ye.isBytes=void 0;var qa=cf(),ka=Ca();function Yy(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}ye.isBytes=Yy;var Wy=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);ye.u8=Wy;var zy=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));ye.u32=zy;var Dy=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);ye.createView=Dy;var Zy=(t,e)=>t<<32-e|t>>>e;ye.rotr=Zy;var Xy=(t,e)=>t<<e|t>>>32-e>>>0;ye.rotl=Xy;ye.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var Jy=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;ye.byteSwap=Jy;ye.byteSwapIfBE=ye.isLE?t=>t:t=>(0,ye.byteSwap)(t);function Ly(t){for(let e=0;e<t.length;e++)t[e]=(0,ye.byteSwap)(t[e])}ye.byteSwap32=Ly;var Qy=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function eb(t){(0,ka.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=Qy[t[r]];return e}ye.bytesToHex=eb;var Hr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function uf(t){if(t>=Hr._0&&t<=Hr._9)return t-Hr._0;if(t>=Hr._A&&t<=Hr._F)return t-(Hr._A-10);if(t>=Hr._a&&t<=Hr._f)return t-(Hr._a-10)}function tb(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=uf(t.charCodeAt(s)),a=uf(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}ye.hexToBytes=tb;var rb=async()=>{};ye.nextTick=rb;async function nb(t,e,r){let n=Date.now();for(let i=0;i<t;i++){r(i);let s=Date.now()-n;s>=0&&s<e||(await(0,ye.nextTick)(),n+=s)}}ye.asyncLoop=nb;function lf(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}ye.utf8ToBytes=lf;function Ns(t){return typeof t=="string"&&(t=lf(t)),(0,ka.bytes)(t),t}ye.toBytes=Ns;function ib(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];(0,ka.bytes)(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}ye.concatBytes=ib;var ja=class{clone(){return this._cloneInto()}};ye.Hash=ja;var sb={}.toString;function ob(t,e){if(e!==void 0&&sb.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}ye.checkOpts=ob;function ab(t){let e=n=>t().update(Ns(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}ye.wrapConstructor=ab;function cb(t){let e=(n,i)=>t(i).update(Ns(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}ye.wrapConstructorWithOpts=cb;function ub(t){let e=(n,i)=>t(i).update(Ns(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}ye.wrapXOFConstructorWithOpts=ub;function lb(t=32){if(qa.crypto&&typeof qa.crypto.getRandomValues=="function")return qa.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}ye.randomBytes=lb});var $a=L(Lr=>{"use strict";Object.defineProperty(Lr,"__esModule",{value:!0});Lr.HashMD=Lr.Maj=Lr.Chi=void 0;var Va=Ca(),Ui=Bn();function fb(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,f=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+f,a,n)}var db=(t,e,r)=>t&e^~t&r;Lr.Chi=db;var hb=(t,e,r)=>t&e^t&r^e&r;Lr.Maj=hb;var Ha=class extends Ui.Hash{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,Ui.createView)(this.buffer)}update(e){(0,Va.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,Ui.toBytes)(e);let s=e.length;for(let o=0;o<s;){let a=Math.min(i-this.pos,s-o);if(a===i){let c=(0,Ui.createView)(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,Va.exists)(this),(0,Va.output)(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let h=o;h<i;h++)r[h]=0;fb(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=(0,Ui.createView)(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,d=this.get();if(f>d.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<f;h++)a.setUint32(4*h,d[h],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}};Lr.HashMD=Ha});var Ps=L(Jn=>{"use strict";Object.defineProperty(Jn,"__esModule",{value:!0});Jn.sha224=Jn.sha256=void 0;var Ka=$a(),er=Bn(),pb=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Qr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),en=new Uint32Array(64),Rs=class extends Ka.HashMD{constructor(){super(64,32,8,!1),this.A=Qr[0]|0,this.B=Qr[1]|0,this.C=Qr[2]|0,this.D=Qr[3]|0,this.E=Qr[4]|0,this.F=Qr[5]|0,this.G=Qr[6]|0,this.H=Qr[7]|0}get(){let{A:e,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[e,r,n,i,s,o,a,c]}set(e,r,n,i,s,o,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let h=0;h<16;h++,r+=4)en[h]=e.getUint32(r,!1);for(let h=16;h<64;h++){let B=en[h-15],w=en[h-2],u=(0,er.rotr)(B,7)^(0,er.rotr)(B,18)^B>>>3,g=(0,er.rotr)(w,17)^(0,er.rotr)(w,19)^w>>>10;en[h]=g+en[h-7]+u+en[h-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:f,H:d}=this;for(let h=0;h<64;h++){let B=(0,er.rotr)(a,6)^(0,er.rotr)(a,11)^(0,er.rotr)(a,25),w=d+B+(0,Ka.Chi)(a,c,f)+pb[h]+en[h]|0,g=((0,er.rotr)(n,2)^(0,er.rotr)(n,13)^(0,er.rotr)(n,22))+(0,Ka.Maj)(n,i,s)|0;d=f,f=c,c=a,a=o+w|0,o=s,s=i,i=n,n=w+g|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,d=d+this.H|0,this.set(n,i,s,o,a,c,f,d)}roundClean(){en.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Ga=class extends Rs{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};Jn.sha256=(0,er.wrapConstructor)(()=>new Rs);Jn.sha224=(0,er.wrapConstructor)(()=>new Ga)});var ff=L(Is=>{"use strict";Object.defineProperty(Is,"__esModule",{value:!0});Is.sha224=void 0;var yb=Ps();function bb(t){return yb.sha224.create().update(new Uint8Array(t)).digest()}Is.sha224=bb});var Nt=L(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.Principal=mr.JSON_KEY_PRINCIPAL=void 0;var df=ef(),gb=tf(),mb=ff();mr.JSON_KEY_PRINCIPAL="__principal__";var _b=2,hf=4,wb="aaaaa-aa",Eb=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},xb=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),Ya=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([hf]))}static managementCanister(){return this.fromHex(wb)}static selfAuthenticating(e){let r=(0,mb.sha224)(e);return new this(new Uint8Array([...r,_b]))}static from(e){if(typeof e=="string")return t.fromText(e);if(Object.getPrototypeOf(e)===Uint8Array.prototype)return new t(e);if(typeof e=="object"&&e!==null&&e._isPrincipal===!0)return new t(e._arr);throw new Error(`Impossible to convert ${JSON.stringify(e)} to Principal.`)}static fromHex(e){return new this(Eb(e))}static fromText(e){let r=e;if(e.includes(mr.JSON_KEY_PRINCIPAL)){let o=JSON.parse(e);mr.JSON_KEY_PRINCIPAL in o&&(r=o[mr.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,df.decode)(n);i=i.slice(4,i.length);let s=new this(i);if(s.toText()!==r)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${r}" may not be a valid Principal ID).`);return s}static fromUint8Array(e){return new this(e)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===hf}toUint8Array(){return this._arr}toHex(){return xb(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,(0,gb.getCrc32)(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),a=(0,df.encode)(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[mr.JSON_KEY_PRINCIPAL]:this.toText()}}compareTo(e){for(let r=0;r<Math.min(this._arr.length,e._arr.length);r++){if(this._arr[r]<e._arr[r])return"lt";if(this._arr[r]>e._arr[r])return"gt"}return this._arr.length<e._arr.length?"lt":this._arr.length>e._arr.length?"gt":"eq"}ltEq(e){let r=this.compareTo(e);return r=="lt"||r=="eq"}gtEq(e){let r=this.compareTo(e);return r=="gt"||r=="eq"}};mr.Principal=Ya});var Sf=L(Cs=>{"use strict";Cs.byteLength=Ab;Cs.toByteArray=Nb;Cs.fromByteArray=Ib;var wr=[],tr=[],Bb=typeof Uint8Array<"u"?Uint8Array:Array,La="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(An=0,vf=La.length;An<vf;++An)wr[An]=La[An],tr[La.charCodeAt(An)]=An;var An,vf;tr[45]=62;tr[95]=63;function Tf(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function Ab(t){var e=Tf(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Ob(t,e,r){return(e+r)*3/4-r}function Nb(t){var e,r=Tf(t),n=r[0],i=r[1],s=new Bb(Ob(t,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=tr[t.charCodeAt(c)]<<18|tr[t.charCodeAt(c+1)]<<12|tr[t.charCodeAt(c+2)]<<6|tr[t.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=tr[t.charCodeAt(c)]<<2|tr[t.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=tr[t.charCodeAt(c)]<<10|tr[t.charCodeAt(c+1)]<<4|tr[t.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function Rb(t){return wr[t>>18&63]+wr[t>>12&63]+wr[t>>6&63]+wr[t&63]}function Pb(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push(Rb(n));return i.join("")}function Ib(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(Pb(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(wr[e>>2]+wr[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(wr[e>>10]+wr[e>>4&63]+wr[e<<2&63]+"=")),i.join("")}});var ec=L(Qa=>{Qa.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,f=c>>1,d=-7,h=r?i-1:0,B=r?-1:1,w=t[e+h];for(h+=B,s=w&(1<<-d)-1,w>>=-d,d+=a;d>0;s=s*256+t[e+h],h+=B,d-=8);for(o=s&(1<<-d)-1,s>>=-d,d+=n;d>0;o=o*256+t[e+h],h+=B,d-=8);if(s===0)s=1-f;else{if(s===c)return o?NaN:(w?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-f}return(w?-1:1)*o*Math.pow(2,s-n)};Qa.write=function(t,e,r,n,i,s){var o,a,c,f=s*8-i-1,d=(1<<f)-1,h=d>>1,B=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=n?0:s-1,u=n?1:-1,g=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=d):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+h>=1?e+=B/c:e+=B*Math.pow(2,1-h),e*c>=2&&(o++,c/=2),o+h>=d?(a=0,o=d):o+h>=1?(a=(e*c-1)*Math.pow(2,i),o=o+h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+w]=a&255,w+=u,a/=256,i-=8);for(o=o<<i|a,f+=i;f>0;t[r+w]=o&255,w+=u,o/=256,f-=8);t[r+w-u]|=g*128}});var $f=L(ni=>{"use strict";var tc=Sf(),ti=ec(),Bf=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ni.Buffer=$;ni.SlowBuffer=jb;ni.INSPECT_MAX_BYTES=50;var qs=2147483647;ni.kMaxLength=qs;$.TYPED_ARRAY_SUPPORT=Ub();!$.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Ub(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty($.prototype,"parent",{enumerable:!0,get:function(){if($.isBuffer(this))return this.buffer}});Object.defineProperty($.prototype,"offset",{enumerable:!0,get:function(){if($.isBuffer(this))return this.byteOffset}});function Kr(t){if(t>qs)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,$.prototype),e}function $(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return sc(t)}return Rf(t,e,r)}$.poolSize=8192;function Rf(t,e,r){if(typeof t=="string")return Mb(t,e);if(ArrayBuffer.isView(t))return Cb(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Er(t,ArrayBuffer)||t&&Er(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Er(t,SharedArrayBuffer)||t&&Er(t.buffer,SharedArrayBuffer)))return nc(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return $.from(n,e,r);let i=qb(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return $.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}$.from=function(t,e,r){return Rf(t,e,r)};Object.setPrototypeOf($.prototype,Uint8Array.prototype);Object.setPrototypeOf($,Uint8Array);function Pf(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function Fb(t,e,r){return Pf(t),t<=0?Kr(t):e!==void 0?typeof r=="string"?Kr(t).fill(e,r):Kr(t).fill(e):Kr(t)}$.alloc=function(t,e,r){return Fb(t,e,r)};function sc(t){return Pf(t),Kr(t<0?0:oc(t)|0)}$.allocUnsafe=function(t){return sc(t)};$.allocUnsafeSlow=function(t){return sc(t)};function Mb(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!$.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=If(t,e)|0,n=Kr(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function rc(t){let e=t.length<0?0:oc(t.length)|0,r=Kr(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Cb(t){if(Er(t,Uint8Array)){let e=new Uint8Array(t);return nc(e.buffer,e.byteOffset,e.byteLength)}return rc(t)}function nc(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,$.prototype),n}function qb(t){if($.isBuffer(t)){let e=oc(t.length)|0,r=Kr(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||cc(t.length)?Kr(0):rc(t);if(t.type==="Buffer"&&Array.isArray(t.data))return rc(t.data)}function oc(t){if(t>=qs)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+qs.toString(16)+" bytes");return t|0}function jb(t){return+t!=t&&(t=0),$.alloc(+t)}$.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==$.prototype};$.compare=function(e,r){if(Er(e,Uint8Array)&&(e=$.from(e,e.offset,e.byteLength)),Er(r,Uint8Array)&&(r=$.from(r,r.offset,r.byteLength)),!$.isBuffer(e)||!$.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};$.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};$.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return $.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=$.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(Er(o,Uint8Array))s+o.length>i.length?($.isBuffer(o)||(o=$.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if($.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function If(t,e){if($.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Er(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return ic(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Hf(t).length;default:if(i)return n?-1:ic(t).length;e=(""+e).toLowerCase(),i=!0}}$.byteLength=If;function kb(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Zb(this,e,r);case"utf8":case"utf-8":return Ff(this,e,r);case"ascii":return zb(this,e,r);case"latin1":case"binary":return Db(this,e,r);case"base64":return Yb(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Xb(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}$.prototype._isBuffer=!0;function On(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}$.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)On(this,r,r+1);return this};$.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)On(this,r,r+3),On(this,r+1,r+2);return this};$.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)On(this,r,r+7),On(this,r+1,r+6),On(this,r+2,r+5),On(this,r+3,r+4);return this};$.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Ff(this,0,e):kb.apply(this,arguments)};$.prototype.toLocaleString=$.prototype.toString;$.prototype.equals=function(e){if(!$.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:$.compare(this,e)===0};$.prototype.inspect=function(){let e="",r=ni.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};Bf&&($.prototype[Bf]=$.prototype.inspect);$.prototype.compare=function(e,r,n,i,s){if(Er(e,Uint8Array)&&(e=$.from(e,e.offset,e.byteLength)),!$.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,a=n-r,c=Math.min(o,a),f=this.slice(i,s),d=e.slice(r,n);for(let h=0;h<c;++h)if(f[h]!==d[h]){o=f[h],a=d[h];break}return o<a?-1:a<o?1:0};function Uf(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,cc(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=$.from(e,n)),$.isBuffer(e))return e.length===0?-1:Af(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):Af(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Af(t,e,r,n,i){let s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(d,h){return s===1?d[h]:d.readUInt16BE(h*s)}let f;if(i){let d=-1;for(f=r;f<o;f++)if(c(t,f)===c(e,d===-1?0:f-d)){if(d===-1&&(d=f),f-d+1===a)return d*s}else d!==-1&&(f-=f-d),d=-1}else for(r+a>o&&(r=o-a),f=r;f>=0;f--){let d=!0;for(let h=0;h<a;h++)if(c(t,f+h)!==c(e,h)){d=!1;break}if(d)return f}return-1}$.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};$.prototype.indexOf=function(e,r,n){return Uf(this,e,r,n,!0)};$.prototype.lastIndexOf=function(e,r,n){return Uf(this,e,r,n,!1)};function Vb(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(e.substr(o*2,2),16);if(cc(a))return o;t[r+o]=a}return o}function Hb(t,e,r,n){return js(ic(e,t.length-r),t,r,n)}function $b(t,e,r,n){return js(eg(e),t,r,n)}function Kb(t,e,r,n){return js(Hf(e),t,r,n)}function Gb(t,e,r,n){return js(tg(e,t.length-r),t,r,n)}$.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return Vb(this,e,r,n);case"utf8":case"utf-8":return Hb(this,e,r,n);case"ascii":case"latin1":case"binary":return $b(this,e,r,n);case"base64":return Kb(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Gb(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};$.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Yb(t,e,r){return e===0&&r===t.length?tc.fromByteArray(t):tc.fromByteArray(t.slice(e,r))}function Ff(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,f,d,h;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)===128&&(h=(s&31)<<6|c&63,h>127&&(o=h));break;case 3:c=t[i+1],f=t[i+2],(c&192)===128&&(f&192)===128&&(h=(s&15)<<12|(c&63)<<6|f&63,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:c=t[i+1],f=t[i+2],d=t[i+3],(c&192)===128&&(f&192)===128&&(d&192)===128&&(h=(s&15)<<18|(c&63)<<12|(f&63)<<6|d&63,h>65535&&h<1114112&&(o=h))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return Wb(n)}var Of=4096;function Wb(t){let e=t.length;if(e<=Of)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Of));return r}function zb(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Db(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Zb(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=e;s<r;++s)i+=rg[t[s]];return i}function Xb(t,e,r){let n=t.slice(e,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}$.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,$.prototype),i};function lt(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}$.prototype.readUintLE=$.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||lt(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};$.prototype.readUintBE=$.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||lt(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};$.prototype.readUint8=$.prototype.readUInt8=function(e,r){return e=e>>>0,r||lt(e,1,this.length),this[e]};$.prototype.readUint16LE=$.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||lt(e,2,this.length),this[e]|this[e+1]<<8};$.prototype.readUint16BE=$.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||lt(e,2,this.length),this[e]<<8|this[e+1]};$.prototype.readUint32LE=$.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||lt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};$.prototype.readUint32BE=$.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||lt(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};$.prototype.readBigUInt64LE=tn(function(e){e=e>>>0,ri(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Fi(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});$.prototype.readBigUInt64BE=tn(function(e){e=e>>>0,ri(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Fi(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});$.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||lt(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};$.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||lt(e,r,this.length);let i=r,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};$.prototype.readInt8=function(e,r){return e=e>>>0,r||lt(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};$.prototype.readInt16LE=function(e,r){e=e>>>0,r||lt(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};$.prototype.readInt16BE=function(e,r){e=e>>>0,r||lt(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};$.prototype.readInt32LE=function(e,r){return e=e>>>0,r||lt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};$.prototype.readInt32BE=function(e,r){return e=e>>>0,r||lt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};$.prototype.readBigInt64LE=tn(function(e){e=e>>>0,ri(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Fi(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});$.prototype.readBigInt64BE=tn(function(e){e=e>>>0,ri(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Fi(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});$.prototype.readFloatLE=function(e,r){return e=e>>>0,r||lt(e,4,this.length),ti.read(this,e,!0,23,4)};$.prototype.readFloatBE=function(e,r){return e=e>>>0,r||lt(e,4,this.length),ti.read(this,e,!1,23,4)};$.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||lt(e,8,this.length),ti.read(this,e,!0,52,8)};$.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||lt(e,8,this.length),ti.read(this,e,!1,52,8)};function qt(t,e,r,n,i,s){if(!$.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}$.prototype.writeUintLE=$.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;qt(this,e,r,n,a,0)}let s=1,o=0;for(this[r]=e&255;++o<n&&(s*=256);)this[r+o]=e/s&255;return r+n};$.prototype.writeUintBE=$.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;qt(this,e,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=e&255;--s>=0&&(o*=256);)this[r+s]=e/o&255;return r+n};$.prototype.writeUint8=$.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||qt(this,e,r,1,255,0),this[r]=e&255,r+1};$.prototype.writeUint16LE=$.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||qt(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};$.prototype.writeUint16BE=$.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||qt(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};$.prototype.writeUint32LE=$.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||qt(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};$.prototype.writeUint32BE=$.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||qt(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function Mf(t,e,r,n,i){Vf(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,r}function Cf(t,e,r,n,i){Vf(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s=s>>8,t[r+6]=s,s=s>>8,t[r+5]=s,s=s>>8,t[r+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o=o>>8,t[r+2]=o,o=o>>8,t[r+1]=o,o=o>>8,t[r]=o,r+8}$.prototype.writeBigUInt64LE=tn(function(e,r=0){return Mf(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});$.prototype.writeBigUInt64BE=tn(function(e,r=0){return Cf(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});$.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);qt(this,e,r,n,c-1,-c)}let s=0,o=1,a=0;for(this[r]=e&255;++s<n&&(o*=256);)e<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};$.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);qt(this,e,r,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[r+s]=e&255;--s>=0&&(o*=256);)e<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};$.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||qt(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};$.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||qt(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};$.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||qt(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};$.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||qt(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};$.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||qt(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};$.prototype.writeBigInt64LE=tn(function(e,r=0){return Mf(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});$.prototype.writeBigInt64BE=tn(function(e,r=0){return Cf(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function qf(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function jf(t,e,r,n,i){return e=+e,r=r>>>0,i||qf(t,e,r,4,34028234663852886e22,-34028234663852886e22),ti.write(t,e,r,n,23,4),r+4}$.prototype.writeFloatLE=function(e,r,n){return jf(this,e,r,!0,n)};$.prototype.writeFloatBE=function(e,r,n){return jf(this,e,r,!1,n)};function kf(t,e,r,n,i){return e=+e,r=r>>>0,i||qf(t,e,r,8,17976931348623157e292,-17976931348623157e292),ti.write(t,e,r,n,52,8),r+8}$.prototype.writeDoubleLE=function(e,r,n){return kf(this,e,r,!0,n)};$.prototype.writeDoubleBE=function(e,r,n){return kf(this,e,r,!1,n)};$.prototype.copy=function(e,r,n,i){if(!$.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),s};$.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!$.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=r;s<n;++s)this[s]=e;else{let o=$.isBuffer(e)?e:$.from(e,i),a=o.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var ei={};function ac(t,e,r){ei[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}ac("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ac("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);ac("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=Nf(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Nf(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Nf(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function Jb(t,e,r){ri(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Fi(e,t.length-(r+1))}function Vf(t,e,r,n,i,s){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",a;throw s>3?e===0||e===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${e}${o} and <= ${r}${o}`,new ei.ERR_OUT_OF_RANGE("value",a,t)}Jb(n,i,s)}function ri(t,e){if(typeof t!="number")throw new ei.ERR_INVALID_ARG_TYPE(e,"number",t)}function Fi(t,e,r){throw Math.floor(t)!==t?(ri(t,r),new ei.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new ei.ERR_BUFFER_OUT_OF_BOUNDS:new ei.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Lb=/[^+/0-9A-Za-z-_]/g;function Qb(t){if(t=t.split("=")[0],t=t.trim().replace(Lb,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function ic(t,e){e=e||1/0;let r,n=t.length,i=null,s=[];for(let o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function eg(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function tg(t,e){let r,n,i,s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function Hf(t){return tc.toByteArray(Qb(t))}function js(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Er(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function cc(t){return t!==t}var rg=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function tn(t){return typeof BigInt>"u"?ng:t}function ng(){throw new Error("BigInt not supported")}});var Kf=L(Mi=>{"use strict";Object.defineProperty(Mi,"__esModule",{value:!0});Mi.ReplicaRejectCode=void 0;var ig;(function(t){t[t.SysFatal=1]="SysFatal",t[t.SysTransient=2]="SysTransient",t[t.DestinationInvalid=3]="DestinationInvalid",t[t.CanisterReject=4]="CanisterReject",t[t.CanisterError=5]="CanisterError"})(ig=Mi.ReplicaRejectCode||(Mi.ReplicaRejectCode={}))});var ii=L(ks=>{"use strict";Object.defineProperty(ks,"__esModule",{value:!0});ks.AgentError=void 0;var uc=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};ks.AgentError=uc});var $s=L(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.bufFromBufLike=jt.uint8ToBuf=jt.PipeArrayBuffer=jt.fromHexString=jt.toHexString=jt.concat=void 0;function sg(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e}jt.concat=sg;function og(t){return new Uint8Array(t).reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}jt.toHexString=og;function ag(t){var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))}jt.fromHexString=ag;var lc=class{constructor(e,r=e?.byteLength||0){this._buffer=Hs(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return Hs(this._view.slice())}get byteLength(){return this._view.byteLength}read(e){let r=this._view.subarray(0,e);return this._view=this._view.subarray(e),r.slice().buffer}readUint8(){let e=this._view[0];return this._view=this._view.subarray(1),e}write(e){let r=new Uint8Array(e),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+r.byteLength>=this._buffer.byteLength?this.alloc(r.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+r.byteLength),this._view.set(r,n)}get end(){return this._view.byteLength===0}alloc(e){let r=new ArrayBuffer((this._buffer.byteLength+e)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+e);n.set(this._view),this._buffer=r,this._view=n}};jt.PipeArrayBuffer=lc;function Vs(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}jt.uint8ToBuf=Vs;function Hs(t){return t instanceof Uint8Array?Vs(t):t instanceof ArrayBuffer?t:Array.isArray(t)?Vs(new Uint8Array(t)):"buffer"in t?Hs(t.buffer):Vs(new Uint8Array(t))}jt.bufFromBufLike=Hs});var fc=L(Ks=>{"use strict";Object.defineProperty(Ks,"__esModule",{value:!0});Ks.idlLabelToId=void 0;function cg(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function ug(t){if(/^_\d+_$/.test(t)||/^_0x[0-9a-fA-F]+_$/.test(t)){let e=+t.slice(1,-1);if(Number.isSafeInteger(e)&&e>=0&&e<2**32)return e}return cg(t)}Ks.idlLabelToId=ug});var hc=L(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.readIntLE=Ze.readUIntLE=Ze.writeIntLE=Ze.writeUIntLE=Ze.slebDecode=Ze.slebEncode=Ze.lebDecode=Ze.lebEncode=Ze.safeReadUint8=Ze.safeRead=void 0;var dc=$s();function Gf(){throw new Error("unexpected end of buffer")}function Yf(t,e){return t.byteLength<e&&Gf(),t.read(e)}Ze.safeRead=Yf;function Gs(t){let e=t.readUint8();return e===void 0&&Gf(),e}Ze.safeReadUint8=Gs;function lg(t){if(typeof t=="number"&&(t=BigInt(t)),t<BigInt(0))throw new Error("Cannot leb encode negative values.");let e=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,r=new dc.PipeArrayBuffer(new ArrayBuffer(e),0);for(;;){let n=Number(t&BigInt(127));if(t/=BigInt(128),t===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}Ze.lebEncode=lg;function Wf(t){let e=BigInt(1),r=BigInt(0),n;do n=Gs(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}Ze.lebDecode=Wf;function fg(t){typeof t=="number"&&(t=BigInt(t));let e=t<BigInt(0);e&&(t=-t-BigInt(1));let r=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,n=new dc.PipeArrayBuffer(new ArrayBuffer(r),0);for(;;){let s=i(t);if(t/=BigInt(128),e&&t===BigInt(0)&&s&64||!e&&t===BigInt(0)&&!(s&64)){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let o=s%BigInt(128);return Number(e?BigInt(128)-o-BigInt(1):o)}return n.buffer}Ze.slebEncode=fg;function dg(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if(!(e[r]&64))return Wf(t);break}let n=new Uint8Array(Yf(t,r+1)),i=BigInt(0);for(let s=n.byteLength-1;s>=0;s--)i=i*BigInt(128)+BigInt(128-(n[s]&127)-1);return-i-BigInt(1)}Ze.slebDecode=dg;function hg(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return zf(t,e)}Ze.writeUIntLE=hg;function zf(t,e){t=BigInt(t);let r=new dc.PipeArrayBuffer(new ArrayBuffer(Math.min(1,e)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(t%i);for(r.write(new Uint8Array([o]));++n<e;)t<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((t/i-s)%BigInt(256)),r.write(new Uint8Array([o])),i*=BigInt(256);return r.buffer}Ze.writeIntLE=zf;function Df(t,e){let r=BigInt(Gs(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(Gs(t));r=r+n*s}return r}Ze.readUIntLE=Df;function pg(t,e){let r=Df(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}Ze.readIntLE=pg});var Zf=L(si=>{"use strict";Object.defineProperty(si,"__esModule",{value:!0});si.iexp2=si.ilog2=void 0;function yg(t){let e=BigInt(t);if(t<=0)throw new RangeError("Input must be positive");return e.toString(2).length-1}si.ilog2=yg;function bg(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}si.iexp2=bg});var mc=L(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.Variant=K.Record=K.Opt=K.Vec=K.Tuple=K.Principal=K.Nat64=K.Nat32=K.Nat16=K.Nat8=K.Int64=K.Int32=K.Int16=K.Int8=K.Float64=K.Float32=K.Nat=K.Int=K.Text=K.Null=K.Bool=K.Unknown=K.Reserved=K.Empty=K.decode=K.encode=K.ServiceClass=K.FuncClass=K.PrincipalClass=K.RecClass=K.VariantClass=K.TupleClass=K.RecordClass=K.OptClass=K.VecClass=K.FixedNatClass=K.FixedIntClass=K.FloatClass=K.NatClass=K.IntClass=K.TextClass=K.ReservedClass=K.NullClass=K.BoolClass=K.UnknownClass=K.EmptyClass=K.ConstructType=K.PrimitiveType=K.Type=K.Visitor=void 0;K.Service=K.Func=K.Rec=void 0;var gg=Nt(),Oe=$s(),xr=fc(),ie=hc(),pc=Zf(),Ys="DIDL",Xf=400;function Ci(t,e,r){return t.map((n,i)=>r(n,e[i]))}var yc=class{constructor(){this._typs=[],this._idx=new Map}has(e){return this._idx.has(e.name)}add(e,r){let n=this._typs.length;this._idx.set(e.name,n),this._typs.push(r)}merge(e,r){let n=this._idx.get(e.name),i=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+e);if(i===void 0)throw new Error("Missing type index for "+r);this._typs[n]=this._typs[i],this._typs.splice(i,1),this._idx.delete(r)}encode(){let e=(0,ie.lebEncode)(this._typs.length),r=(0,Oe.concat)(...this._typs);return(0,Oe.concat)(e,r)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return(0,ie.slebEncode)(this._idx.get(e)||0)}},bc=class{visitType(e,r){throw new Error("Not implemented")}visitPrimitive(e,r){return this.visitType(e,r)}visitEmpty(e,r){return this.visitPrimitive(e,r)}visitBool(e,r){return this.visitPrimitive(e,r)}visitNull(e,r){return this.visitPrimitive(e,r)}visitReserved(e,r){return this.visitPrimitive(e,r)}visitText(e,r){return this.visitPrimitive(e,r)}visitNumber(e,r){return this.visitPrimitive(e,r)}visitInt(e,r){return this.visitNumber(e,r)}visitNat(e,r){return this.visitNumber(e,r)}visitFloat(e,r){return this.visitPrimitive(e,r)}visitFixedInt(e,r){return this.visitNumber(e,r)}visitFixedNat(e,r){return this.visitNumber(e,r)}visitPrincipal(e,r){return this.visitPrimitive(e,r)}visitConstruct(e,r){return this.visitType(e,r)}visitVec(e,r,n){return this.visitConstruct(e,n)}visitOpt(e,r,n){return this.visitConstruct(e,n)}visitRecord(e,r,n){return this.visitConstruct(e,n)}visitTuple(e,r,n){let i=r.map((s,o)=>[`_${o}_`,s]);return this.visitRecord(e,i,n)}visitVariant(e,r,n){return this.visitConstruct(e,n)}visitRec(e,r,n){return this.visitConstruct(r,n)}visitFunc(e,r){return this.visitConstruct(e,r)}visitService(e,r){return this.visitConstruct(e,r)}};K.Visitor=bc;var oi=class{display(){return this.name}valueToString(e){return Qe(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}};K.Type=oi;var kt=class extends oi{checkType(e){if(this.name!==e.name)throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`);return e}_buildTypeTableImpl(e){}};K.PrimitiveType=kt;var Tr=class extends oi{checkType(e){if(e instanceof rn){let r=e.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`)}encodeType(e){return e.indexOf(this.name)}};K.ConstructType=Tr;var Ws=class extends kt{accept(e,r){return e.visitEmpty(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return(0,ie.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};K.EmptyClass=Ws;var zs=class extends oi{checkType(e){throw new Error("Method not implemented for unknown.")}accept(e,r){throw e.visitType(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(e,r){let n=r.decodeValue(e,r);Object(n)!==n&&(n=Object(n));let i;return r instanceof rn?i=()=>r.getType():i=()=>r,Object.defineProperty(n,"type",{value:i,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}};K.UnknownClass=zs;var Ds=class extends kt{accept(e,r){return e.visitBool(this,r)}covariant(e){if(typeof e=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return(0,ie.slebEncode)(-2)}decodeValue(e,r){switch(this.checkType(r),(0,ie.safeReadUint8)(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};K.BoolClass=Ds;var Zs=class extends kt{accept(e,r){return e.visitNull(this,r)}covariant(e){if(e===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ie.slebEncode)(-1)}decodeValue(e,r){return this.checkType(r),null}get name(){return"null"}};K.NullClass=Zs;var ai=class extends kt{accept(e,r){return e.visitReserved(this,r)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ie.slebEncode)(-16)}decodeValue(e,r){return r.name!==this.name&&r.decodeValue(e,r),null}get name(){return"reserved"}};K.ReservedClass=ai;var Xs=class extends kt{accept(e,r){return e.visitText(this,r)}covariant(e){if(typeof e=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){let r=new TextEncoder().encode(e),n=(0,ie.lebEncode)(r.byteLength);return(0,Oe.concat)(n,r)}encodeType(){return(0,ie.slebEncode)(-15)}decodeValue(e,r){this.checkType(r);let n=(0,ie.lebDecode)(e),i=(0,ie.safeRead)(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}};K.TextClass=Xs;var Js=class extends kt{accept(e,r){return e.visitInt(this,r)}covariant(e){if(typeof e=="bigint"||Number.isInteger(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){return(0,ie.slebEncode)(e)}encodeType(){return(0,ie.slebEncode)(-4)}decodeValue(e,r){return this.checkType(r),(0,ie.slebDecode)(e)}get name(){return"int"}valueToString(e){return e.toString()}};K.IntClass=Js;var Ls=class extends kt{accept(e,r){return e.visitNat(this,r)}covariant(e){if(typeof e=="bigint"&&e>=BigInt(0)||Number.isInteger(e)&&e>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){return(0,ie.lebEncode)(e)}encodeType(){return(0,ie.slebEncode)(-3)}decodeValue(e,r){return this.checkType(r),(0,ie.lebDecode)(e)}get name(){return"nat"}valueToString(e){return e.toString()}};K.NatClass=Ls;var qi=class extends kt{constructor(e){if(super(),this._bits=e,e!==32&&e!==64)throw new Error("not a valid float type")}accept(e,r){return e.visitFloat(this,r)}covariant(e){if(typeof e=="number"||e instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,e,!0):n.setFloat64(0,e,!0),r}encodeType(){let e=this._bits===32?-13:-14;return(0,ie.slebEncode)(e)}decodeValue(e,r){this.checkType(r);let n=(0,ie.safeRead)(e,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(e){return e.toString()}};K.FloatClass=qi;var Gr=class extends kt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=(0,pc.iexp2)(this._bits-1)*BigInt(-1),n=(0,pc.iexp2)(this._bits-1)-BigInt(1),i=!1;if(typeof e=="bigint")i=e>=r&&e<=n;else if(Number.isInteger(e)){let s=BigInt(e);i=s>=r&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){return(0,ie.writeIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,ie.slebEncode)(-9-e)}decodeValue(e,r){this.checkType(r);let n=(0,ie.readIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}};K.FixedIntClass=Gr;var vr=class extends kt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=(0,pc.iexp2)(this._bits),n=!1;if(typeof e=="bigint"&&e>=BigInt(0)?n=e<r:Number.isInteger(e)&&e>=0?n=BigInt(e)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){return(0,ie.writeUIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,ie.slebEncode)(-5-e)}decodeValue(e,r){this.checkType(r);let n=(0,ie.readUIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}};K.FixedNatClass=vr;var Qs=class t extends Tr{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof vr&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof vr?this._type._bits:this._type instanceof Gr?this._type._bits:0;if(ArrayBuffer.isView(e)&&r==e.BYTES_PER_ELEMENT*8||Array.isArray(e)&&e.every((n,i)=>{try{return this._type.covariant(n)}catch(s){throw new Error(`Invalid ${this.display()} argument:
4
4
 
5
- index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=(0,ie.lebEncode)(e.length);if(this._blobOptimization)return(0,Pe.concat)(r,new Uint8Array(e));if(ArrayBuffer.isView(e))return(0,Pe.concat)(r,new Uint8Array(e.buffer));let n=new Pe.PipeArrayBuffer(new ArrayBuffer(r.byteLength+e.length),0);n.write(r);for(let i of e){let s=this._type.encodeValue(i);n.write(new Uint8Array(s))}return n.buffer}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=(0,ie.slebEncode)(-19),n=this._type.encodeType(e);e.add(this,(0,Pe.concat)(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a vector type");let i=Number((0,ie.lebDecode)(e));if(this._type instanceof _r){if(this._type._bits==8)return new Uint8Array(e.read(i));if(this._type._bits==16)return new Uint16Array(e.read(i*2));if(this._type._bits==32)return new Uint32Array(e.read(i*4));if(this._type._bits==64)return new BigUint64Array(e.read(i*8))}if(this._type instanceof kr){if(this._type._bits==8)return new Int8Array(e.read(i));if(this._type._bits==16)return new Int16Array(e.read(i*2));if(this._type._bits==32)return new Int32Array(e.read(i*4));if(this._type._bits==64)return new BigInt64Array(e.read(i*8))}let s=[];for(let o=0;o<i;o++)s.push(this._type.decodeValue(e,n._type));return s}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(e){return"vec {"+e.map(n=>this._type.valueToString(n)).join("; ")+"}"}};H.VecClass=Gs;var ni=class t extends wr{constructor(e){super(),this._type=e}accept(e,r){return e.visitOpt(this,this._type,r)}covariant(e){try{if(Array.isArray(e)&&(e.length===0||e.length===1&&this._type.covariant(e[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${tt(e)}
5
+ index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){let r=(0,ie.lebEncode)(e.length);if(this._blobOptimization)return(0,Oe.concat)(r,new Uint8Array(e));if(ArrayBuffer.isView(e))return(0,Oe.concat)(r,new Uint8Array(e.buffer));let n=new Oe.PipeArrayBuffer(new ArrayBuffer(r.byteLength+e.length),0);n.write(r);for(let i of e){let s=this._type.encodeValue(i);n.write(new Uint8Array(s))}return n.buffer}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=(0,ie.slebEncode)(-19),n=this._type.encodeType(e);e.add(this,(0,Oe.concat)(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a vector type");let i=Number((0,ie.lebDecode)(e));if(this._type instanceof vr){if(this._type._bits==8)return new Uint8Array(e.read(i));if(this._type._bits==16)return new Uint16Array(e.read(i*2));if(this._type._bits==32)return new Uint32Array(e.read(i*4));if(this._type._bits==64)return new BigUint64Array(e.read(i*8))}if(this._type instanceof Gr){if(this._type._bits==8)return new Int8Array(e.read(i));if(this._type._bits==16)return new Int16Array(e.read(i*2));if(this._type._bits==32)return new Int32Array(e.read(i*4));if(this._type._bits==64)return new BigInt64Array(e.read(i*8))}let s=[];for(let o=0;o<i;o++)s.push(this._type.decodeValue(e,n._type));return s}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(e){return"vec {"+e.map(n=>this._type.valueToString(n)).join("; ")+"}"}};K.VecClass=Qs;var ci=class t extends Tr{constructor(e){super(),this._type=e}accept(e,r){return e.visitOpt(this,this._type,r)}covariant(e){try{if(Array.isArray(e)&&(e.length===0||e.length===1&&this._type.covariant(e[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}
6
6
 
7
- -> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return e.length===0?new Uint8Array([0]):(0,Pe.concat)(new Uint8Array([1]),this._type.encodeValue(e[0]))}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=(0,ie.slebEncode)(-18),n=this._type.encodeType(e);e.add(this,(0,Pe.concat)(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not an option type");switch((0,ie.safeReadUint8)(e)){case 0:return[];case 1:return[this._type.decodeValue(e,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(e){return e.length===0?"null":`opt ${this._type.valueToString(e[0])}`}};H.OptClass=ni;var Ni=class t extends wr{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,mr.idlLabelToId)(r[0])-(0,mr.idlLabelToId)(n[0]))}accept(e,r){return e.visitRecord(this,this._fields,r)}tryAsTuple(){let e=[];for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(n!==`_${r}_`)return null;e.push(i)}return e}covariant(e){if(typeof e=="object"&&this._fields.every(([r,n])=>{if(!e.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
7
+ -> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){return e.length===0?new Uint8Array([0]):(0,Oe.concat)(new Uint8Array([1]),this._type.encodeValue(e[0]))}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=(0,ie.slebEncode)(-18),n=this._type.encodeType(e);e.add(this,(0,Oe.concat)(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not an option type");switch((0,ie.safeReadUint8)(e)){case 0:return[];case 1:return[this._type.decodeValue(e,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(e){return e.length===0?"null":`opt ${this._type.valueToString(e[0])}`}};K.OptClass=ci;var ji=class t extends Tr{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,xr.idlLabelToId)(r[0])-(0,xr.idlLabelToId)(n[0]))}accept(e,r){return e.visitRecord(this,this._fields,r)}tryAsTuple(){let e=[];for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(n!==`_${r}_`)return null;e.push(i)}return e}covariant(e){if(typeof e=="object"&&this._fields.every(([r,n])=>{if(!e.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
8
8
 
9
- field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=this._fields.map(([i])=>e[i]),n=Ai(this._fields,r,([,i],s)=>i.encodeValue(s));return(0,Pe.concat)(...n)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,ie.slebEncode)(-20),n=(0,ie.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Pe.concat)((0,ie.lebEncode)((0,mr.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Pe.concat)(r,n,(0,Pe.concat)(...i)))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a record type");let i={},s=0,o=0;for(;o<n._fields.length;){let[a,c]=n._fields[o];if(s>=this._fields.length){c.decodeValue(e,c),o++;continue}let[f,l]=this._fields[s],d=(0,mr.idlLabelToId)(this._fields[s][0]),v=(0,mr.idlLabelToId)(a);if(d===v)i[f]=l.decodeValue(e,c),s++,o++;else if(v>d)if(l instanceof ni||l instanceof ri)i[f]=[],s++;else throw new Error("Cannot find required field "+f);else c.decodeValue(e,c),o++}for(let[a,c]of this._fields.slice(s))if(c instanceof ni||c instanceof ri)i[a]=[];else throw new Error("Cannot find required field "+a);return i}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(e){let r=this._fields.map(([i])=>e[i]);return`record {${Ai(this._fields,r,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}};H.RecordClass=Ni;var Ys=class t extends Ni{constructor(e){let r={};e.forEach((n,i)=>r["_"+i+"_"]=n),super(r),this._components=e}accept(e,r){return e.visitTuple(this,this._components,r)}covariant(e){if(Array.isArray(e)&&e.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(e[n])}catch(i){throw new Error(`Invalid ${this.display()} argument:
9
+ field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){let r=this._fields.map(([i])=>e[i]),n=Ci(this._fields,r,([,i],s)=>i.encodeValue(s));return(0,Oe.concat)(...n)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,ie.slebEncode)(-20),n=(0,ie.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Oe.concat)((0,ie.lebEncode)((0,xr.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Oe.concat)(r,n,(0,Oe.concat)(...i)))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a record type");let i={},s=0,o=0;for(;o<n._fields.length;){let[a,c]=n._fields[o];if(s>=this._fields.length){c.decodeValue(e,c),o++;continue}let[f,d]=this._fields[s],h=(0,xr.idlLabelToId)(this._fields[s][0]),B=(0,xr.idlLabelToId)(a);if(h===B)i[f]=d.decodeValue(e,c),s++,o++;else if(B>h)if(d instanceof ci||d instanceof ai)i[f]=[],s++;else throw new Error("Cannot find required field "+f);else c.decodeValue(e,c),o++}for(let[a,c]of this._fields.slice(s))if(c instanceof ci||c instanceof ai)i[a]=[];else throw new Error("Cannot find required field "+a);return i}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(e){let r=this._fields.map(([i])=>e[i]);return`record {${Ci(this._fields,r,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}};K.RecordClass=ji;var eo=class t extends ji{constructor(e){let r={};e.forEach((n,i)=>r["_"+i+"_"]=n),super(r),this._components=e}accept(e,r){return e.visitTuple(this,this._components,r)}covariant(e){if(Array.isArray(e)&&e.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(e[n])}catch(i){throw new Error(`Invalid ${this.display()} argument:
10
10
 
11
- index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=Ai(this._components,e,(n,i)=>n.encodeValue(i));return(0,Pe.concat)(...r)}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let i=[];for(let[s,o]of n._components.entries())s>=this._components.length?o.decodeValue(e,o):i.push(this._components[s].decodeValue(e,o));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(e){return`record {${Ai(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}};H.TupleClass=Ys;var Ws=class t extends wr{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,mr.idlLabelToId)(r[0])-(0,mr.idlLabelToId)(n[0]))}accept(e,r){return e.visitVariant(this,this._fields,r)}covariant(e){if(typeof e=="object"&&Object.entries(e).length===1&&this._fields.every(([r,n])=>{try{return!e.hasOwnProperty(r)||n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
11
+ index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){let r=Ci(this._components,e,(n,i)=>n.encodeValue(i));return(0,Oe.concat)(...r)}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let i=[];for(let[s,o]of n._components.entries())s>=this._components.length?o.decodeValue(e,o):i.push(this._components[s].decodeValue(e,o));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(e){return`record {${Ci(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}};K.TupleClass=eo;var to=class t extends Tr{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,xr.idlLabelToId)(r[0])-(0,xr.idlLabelToId)(n[0]))}accept(e,r){return e.visitVariant(this,this._fields,r)}covariant(e){if(typeof e=="object"&&Object.entries(e).length===1&&this._fields.every(([r,n])=>{try{return!e.hasOwnProperty(r)||n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
12
12
 
13
- variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(e.hasOwnProperty(n)){let s=(0,ie.lebEncode)(r),o=i.encodeValue(e[n]);return(0,Pe.concat)(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let r=(0,ie.slebEncode)(-21),n=(0,ie.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Pe.concat)((0,ie.lebEncode)((0,mr.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Pe.concat)(r,n,...i))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a variant type");let i=Number((0,ie.lebDecode)(e));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,o]=n._fields[i];for(let[a,c]of this._fields)if((0,mr.idlLabelToId)(s)===(0,mr.idlLabelToId)(a)){let f=c.decodeValue(e,o);return{[a]:f}}throw new Error("Cannot find field hash "+s)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(e){for(let[r,n]of this._fields)if(e.hasOwnProperty(r)){let i=n.valueToString(e[r]);return i==="null"?`variant {${r}}`:`variant {${r}=${i}}`}throw new Error("Variant has no data: "+e)}};H.VariantClass=Ws;var Jr=class t extends wr{constructor(){super(...arguments),this._id=t._counter++,this._type=void 0}accept(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return e.visitRec(this,this._type,r)}fill(e){this._type=e}getType(){return this._type}covariant(e){if(this._type&&this._type.covariant(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(e)}_buildTypeTableImpl(e){if(!this._type)throw Error("Recursive type uninitialized.");e.add(this,new Uint8Array([])),this._type.buildTypeTable(e),e.merge(this,this._type.name)}decodeValue(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(e,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(e)}};H.RecClass=Jr;Jr._counter=0;function cc(t){if((0,ie.safeReadUint8)(t)!==1)throw new Error("Cannot decode principal");let r=Number((0,ie.lebDecode)(t));return dg.Principal.fromUint8Array(new Uint8Array((0,ie.safeRead)(t,r)))}var zs=class extends Vt{accept(e,r){return e.visitPrincipal(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=(0,ie.lebEncode)(r.byteLength);return(0,Pe.concat)(new Uint8Array([1]),n,r)}encodeType(){return(0,ie.slebEncode)(-24)}decodeValue(e,r){return this.checkType(r),cc(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}};H.PrincipalClass=zs;var Pi=class extends wr{constructor(e,r,n=[]){super(),this.argTypes=e,this.retTypes=r,this.annotations=n}static argsToString(e,r){if(e.length!==r.length)throw new Error("arity mismatch");return"("+e.map((n,i)=>n.valueToString(r[i])).join(", ")+")"}accept(e,r){return e.visitFunc(this,r)}covariant(e){if(Array.isArray(e)&&e.length===2&&e[0]&&e[0]._isPrincipal&&typeof e[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue([e,r]){let n=e.toUint8Array(),i=(0,ie.lebEncode)(n.byteLength),s=(0,Pe.concat)(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),a=(0,ie.lebEncode)(o.byteLength);return(0,Pe.concat)(new Uint8Array([1]),s,a,o)}_buildTypeTableImpl(e){this.argTypes.forEach(f=>f.buildTypeTable(e)),this.retTypes.forEach(f=>f.buildTypeTable(e));let r=(0,ie.slebEncode)(-22),n=(0,ie.lebEncode)(this.argTypes.length),i=(0,Pe.concat)(...this.argTypes.map(f=>f.encodeType(e))),s=(0,ie.lebEncode)(this.retTypes.length),o=(0,Pe.concat)(...this.retTypes.map(f=>f.encodeType(e))),a=(0,ie.lebEncode)(this.annotations.length),c=(0,Pe.concat)(...this.annotations.map(f=>this.encodeAnnotation(f)));e.add(this,(0,Pe.concat)(r,n,i,s,o,a,c))}decodeValue(e){if((0,ie.safeReadUint8)(e)!==1)throw new Error("Cannot decode function reference");let n=cc(e),i=Number((0,ie.lebDecode)(e)),s=(0,ie.safeRead)(e,i),a=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,a]}get name(){let e=this.argTypes.map(i=>i.name).join(", "),r=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${e}) -> (${r})${n}`}valueToString([e,r]){return`func "${e.toText()}".${r}`}display(){let e=this.argTypes.map(i=>i.display()).join(", "),r=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${e}) \u2192 (${r})${n}`}encodeAnnotation(e){if(e==="query")return new Uint8Array([1]);if(e==="oneway")return new Uint8Array([2]);if(e==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}};H.FuncClass=Pi;var Ds=class extends wr{constructor(e){super(),this._fields=Object.entries(e).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(e,r){return e.visitService(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=(0,ie.lebEncode)(r.length);return(0,Pe.concat)(new Uint8Array([1]),n,r)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,ie.slebEncode)(-23),n=(0,ie.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>{let a=new TextEncoder().encode(s),c=(0,ie.lebEncode)(a.length);return(0,Pe.concat)(c,a,o.encodeType(e))});e.add(this,(0,Pe.concat)(r,n,...i))}decodeValue(e){return cc(e)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};H.ServiceClass=Ds;function tt(t){let e=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>ql?e.substring(0,ql-3)+"...":e}function hg(t,e){if(e.length<t.length)throw Error("Wrong number of message arguments");let r=new oc;t.forEach(c=>c.buildTypeTable(r));let n=new TextEncoder().encode(Cs),i=r.encode(),s=(0,ie.lebEncode)(e.length),o=(0,Pe.concat)(...t.map(c=>c.encodeType(r))),a=(0,Pe.concat)(...Ai(t,e,(c,f)=>{try{c.covariant(f)}catch(l){throw new Error(l.message+`
13
+ variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(e.hasOwnProperty(n)){let s=(0,ie.lebEncode)(r),o=i.encodeValue(e[n]);return(0,Oe.concat)(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let r=(0,ie.slebEncode)(-21),n=(0,ie.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Oe.concat)((0,ie.lebEncode)((0,xr.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Oe.concat)(r,n,...i))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a variant type");let i=Number((0,ie.lebDecode)(e));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,o]=n._fields[i];for(let[a,c]of this._fields)if((0,xr.idlLabelToId)(s)===(0,xr.idlLabelToId)(a)){let f=c.decodeValue(e,o);return{[a]:f}}throw new Error("Cannot find field hash "+s)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(e){for(let[r,n]of this._fields)if(e.hasOwnProperty(r)){let i=n.valueToString(e[r]);return i==="null"?`variant {${r}}`:`variant {${r}=${i}}`}throw new Error("Variant has no data: "+e)}};K.VariantClass=to;var rn=class t extends Tr{constructor(){super(...arguments),this._id=t._counter++,this._type=void 0}accept(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return e.visitRec(this,this._type,r)}fill(e){this._type=e}getType(){return this._type}covariant(e){if(this._type&&this._type.covariant(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(e)}_buildTypeTableImpl(e){if(!this._type)throw Error("Recursive type uninitialized.");e.add(this,new Uint8Array([])),this._type.buildTypeTable(e),e.merge(this,this._type.name)}decodeValue(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(e,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(e)}};K.RecClass=rn;rn._counter=0;function gc(t){if((0,ie.safeReadUint8)(t)!==1)throw new Error("Cannot decode principal");let r=Number((0,ie.lebDecode)(t));return gg.Principal.fromUint8Array(new Uint8Array((0,ie.safeRead)(t,r)))}var ro=class extends kt{accept(e,r){return e.visitPrincipal(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=(0,ie.lebEncode)(r.byteLength);return(0,Oe.concat)(new Uint8Array([1]),n,r)}encodeType(){return(0,ie.slebEncode)(-24)}decodeValue(e,r){return this.checkType(r),gc(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}};K.PrincipalClass=ro;var ki=class extends Tr{constructor(e,r,n=[]){super(),this.argTypes=e,this.retTypes=r,this.annotations=n}static argsToString(e,r){if(e.length!==r.length)throw new Error("arity mismatch");return"("+e.map((n,i)=>n.valueToString(r[i])).join(", ")+")"}accept(e,r){return e.visitFunc(this,r)}covariant(e){if(Array.isArray(e)&&e.length===2&&e[0]&&e[0]._isPrincipal&&typeof e[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue([e,r]){let n=e.toUint8Array(),i=(0,ie.lebEncode)(n.byteLength),s=(0,Oe.concat)(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),a=(0,ie.lebEncode)(o.byteLength);return(0,Oe.concat)(new Uint8Array([1]),s,a,o)}_buildTypeTableImpl(e){this.argTypes.forEach(f=>f.buildTypeTable(e)),this.retTypes.forEach(f=>f.buildTypeTable(e));let r=(0,ie.slebEncode)(-22),n=(0,ie.lebEncode)(this.argTypes.length),i=(0,Oe.concat)(...this.argTypes.map(f=>f.encodeType(e))),s=(0,ie.lebEncode)(this.retTypes.length),o=(0,Oe.concat)(...this.retTypes.map(f=>f.encodeType(e))),a=(0,ie.lebEncode)(this.annotations.length),c=(0,Oe.concat)(...this.annotations.map(f=>this.encodeAnnotation(f)));e.add(this,(0,Oe.concat)(r,n,i,s,o,a,c))}decodeValue(e){if((0,ie.safeReadUint8)(e)!==1)throw new Error("Cannot decode function reference");let n=gc(e),i=Number((0,ie.lebDecode)(e)),s=(0,ie.safeRead)(e,i),a=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,a]}get name(){let e=this.argTypes.map(i=>i.name).join(", "),r=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${e}) -> (${r})${n}`}valueToString([e,r]){return`func "${e.toText()}".${r}`}display(){let e=this.argTypes.map(i=>i.display()).join(", "),r=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${e}) \u2192 (${r})${n}`}encodeAnnotation(e){if(e==="query")return new Uint8Array([1]);if(e==="oneway")return new Uint8Array([2]);if(e==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}};K.FuncClass=ki;var no=class extends Tr{constructor(e){super(),this._fields=Object.entries(e).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(e,r){return e.visitService(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=(0,ie.lebEncode)(r.length);return(0,Oe.concat)(new Uint8Array([1]),n,r)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,ie.slebEncode)(-23),n=(0,ie.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>{let a=new TextEncoder().encode(s),c=(0,ie.lebEncode)(a.length);return(0,Oe.concat)(c,a,o.encodeType(e))});e.add(this,(0,Oe.concat)(r,n,...i))}decodeValue(e){return gc(e)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};K.ServiceClass=no;function Qe(t){let e=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>Xf?e.substring(0,Xf-3)+"...":e}function mg(t,e){if(e.length<t.length)throw Error("Wrong number of message arguments");let r=new yc;t.forEach(c=>c.buildTypeTable(r));let n=new TextEncoder().encode(Ys),i=r.encode(),s=(0,ie.lebEncode)(e.length),o=(0,Oe.concat)(...t.map(c=>c.encodeType(r))),a=(0,Oe.concat)(...Ci(t,e,(c,f)=>{try{c.covariant(f)}catch(d){throw new Error(d.message+`
14
14
 
15
- `)}return c.encodeValue(f)}));return(0,Pe.concat)(n,i,s,o,a)}H.encode=hg;function pg(t,e){let r=new Pe.PipeArrayBuffer(e);if(e.byteLength<Cs.length)throw new Error("Message length smaller than magic number");let n=(0,ie.safeRead)(r,Cs.length),i=new TextDecoder().decode(n);if(i!==Cs)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(E){let g=[],m=Number((0,ie.lebDecode)(E));for(let k=0;k<m;k++){let F=Number((0,ie.slebDecode)(E));switch(F){case-18:case-19:{let K=Number((0,ie.slebDecode)(E));g.push([F,K]);break}case-20:case-21:{let K=[],P=Number((0,ie.lebDecode)(E)),q;for(;P--;){let D=Number((0,ie.lebDecode)(E));if(D>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof q=="number"&&q>=D)throw new Error("field id collision or not sorted");q=D;let z=Number((0,ie.slebDecode)(E));K.push([D,z])}g.push([F,K]);break}case-22:{let K=[],P=Number((0,ie.lebDecode)(E));for(;P--;)K.push(Number((0,ie.slebDecode)(E)));let q=[],D=Number((0,ie.lebDecode)(E));for(;D--;)q.push(Number((0,ie.slebDecode)(E)));let z=[],$=Number((0,ie.lebDecode)(E));for(;$--;)switch(Number((0,ie.lebDecode)(E))){case 1:{z.push("query");break}case 2:{z.push("oneway");break}case 3:{z.push("composite_query");break}default:throw new Error("unknown annotation")}g.push([F,[K,q,z]]);break}case-23:{let K=Number((0,ie.lebDecode)(E)),P=[];for(;K--;){let q=Number((0,ie.lebDecode)(E)),D=new TextDecoder().decode((0,ie.safeRead)(E,q)),z=(0,ie.slebDecode)(E);P.push([D,z])}g.push([F,P]);break}default:throw new Error("Illegal op_code: "+F)}}let O=[],T=Number((0,ie.lebDecode)(E));for(let k=0;k<T;k++)O.push(Number((0,ie.slebDecode)(E)));return[g,O]}let[o,a]=s(r);if(a.length<t.length)throw new Error("Wrong number of return values");let c=o.map(E=>Kl());function f(E){if(E<-24)throw new Error("future value not supported");if(E<0)switch(E){case-1:return H.Null;case-2:return H.Bool;case-3:return H.Nat;case-4:return H.Int;case-5:return H.Nat8;case-6:return H.Nat16;case-7:return H.Nat32;case-8:return H.Nat64;case-9:return H.Int8;case-10:return H.Int16;case-11:return H.Int32;case-12:return H.Int64;case-13:return H.Float32;case-14:return H.Float64;case-15:return H.Text;case-16:return H.Reserved;case-17:return H.Empty;case-24:return H.Principal;default:throw new Error("Illegal op_code: "+E)}if(E>=o.length)throw new Error("type index out of range");return c[E]}function l(E){switch(E[0]){case-19:{let g=f(E[1]);return kl(g)}case-18:{let g=f(E[1]);return Vl(g)}case-20:{let g={};for(let[T,k]of E[1]){let F=`_${T}_`;g[F]=f(k)}let m=Hl(g),O=m.tryAsTuple();return Array.isArray(O)?jl(...O):m}case-21:{let g={};for(let[m,O]of E[1]){let T=`_${m}_`;g[T]=f(O)}return $l(g)}case-22:{let[g,m,O]=E[1];return Gl(g.map(T=>f(T)),m.map(T=>f(T)),O)}case-23:{let g={},m=E[1];for(let[O,T]of m){let k=f(T);if(k instanceof Jr&&(k=k.getType()),!(k instanceof Pi))throw new Error("Illegal service definition: services can only contain functions");g[O]=k}return Yl(g)}default:throw new Error("Illegal op_code: "+E[0])}}o.forEach((E,g)=>{if(E[0]===-22){let m=l(E);c[g].fill(m)}}),o.forEach((E,g)=>{if(E[0]!==-22){let m=l(E);c[g].fill(m)}});let d=a.map(E=>f(E)),v=t.map((E,g)=>E.decodeValue(r,d[g]));for(let E=t.length;E<d.length;E++)d[E].decodeValue(r,d[E]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return v}H.decode=pg;H.Empty=new qs;H.Reserved=new ri;H.Unknown=new js;H.Bool=new ks;H.Null=new Vs;H.Text=new Hs;H.Int=new $s;H.Nat=new Ks;H.Float32=new Oi(32);H.Float64=new Oi(64);H.Int8=new kr(8);H.Int16=new kr(16);H.Int32=new kr(32);H.Int64=new kr(64);H.Nat8=new _r(8);H.Nat16=new _r(16);H.Nat32=new _r(32);H.Nat64=new _r(64);H.Principal=new zs;function jl(...t){return new Ys(t)}H.Tuple=jl;function kl(t){return new Gs(t)}H.Vec=kl;function Vl(t){return new ni(t)}H.Opt=Vl;function Hl(t){return new Ni(t)}H.Record=Hl;function $l(t){return new Ws(t)}H.Variant=$l;function Kl(){return new Jr}H.Rec=Kl;function Gl(t,e,r=[]){return new Pi(t,e,r)}H.Func=Gl;function Yl(t){return new Ds(t)}H.Service=Yl});var bc=J(Bt=>{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});Bt.VecForm=Bt.OptionForm=Bt.VariantForm=Bt.TupleForm=Bt.RecordForm=Bt.InputForm=Bt.InputBox=void 0;var fc=class{constructor(e,r){this.idl=e,this.ui=r,this.label=null,this.value=void 0;let n=document.createElement("span");n.className="status",this.status=n,r.input&&(r.input.addEventListener("blur",()=>{r.input.value!==""&&this.parse()}),r.input.addEventListener("input",()=>{n.style.display="none",r.input.classList.remove("reject")}))}isRejected(){return this.value===void 0}parse(e={}){if(this.ui.form){let r=this.ui.form.parse(e);return this.value=r,r}if(this.ui.input){let r=this.ui.input;try{let n=this.ui.parse(this.idl,e,r.value);if(!this.idl.covariant(n))throw new Error(`${r.value} is not of type ${this.idl.display()}`);return this.status.style.display="none",this.value=n,n}catch(n){r.classList.add("reject"),this.status.style.display="block",this.status.innerHTML="InputError: "+n.message,this.value=void 0;return}}return null}render(e){let r=document.createElement("span");if(this.label){let n=document.createElement("label");n.innerText=this.label,r.appendChild(n)}this.ui.input&&(r.appendChild(this.ui.input),r.appendChild(this.status)),this.ui.form&&this.ui.form.render(r),e.appendChild(r)}};Bt.InputBox=fc;var Lr=class{constructor(e){this.ui=e,this.form=[]}renderForm(e){this.ui.container?(this.form.forEach(r=>r.render(this.ui.container)),e.appendChild(this.ui.container)):this.form.forEach(r=>r.render(e))}render(e){if(this.ui.open&&this.ui.event){e.appendChild(this.ui.open);let r=this;r.ui.open.addEventListener(r.ui.event,()=>{if(r.ui.container)r.ui.container.innerHTML="";else{let n=r.ui.open.nextElementSibling;n&&n.parentNode.removeChild(n)}r.generateForm(),r.renderForm(e)})}else this.generateForm(),this.renderForm(e)}};Bt.InputForm=Lr;var lc=class extends Lr{constructor(e,r){super(r),this.fields=e,this.ui=r}generateForm(){this.form=this.fields.map(([e,r])=>{let n=this.ui.render(r);return this.ui.labelMap&&this.ui.labelMap.hasOwnProperty(e)?n.label=this.ui.labelMap[e]+" ":n.label=e+" ",n})}parse(e){let r={};if(this.fields.forEach(([n,i],s)=>{let o=this.form[s].parse(e);r[n]=o}),!this.form.some(n=>n.isRejected()))return r}};Bt.RecordForm=lc;var dc=class extends Lr{constructor(e,r){super(r),this.components=e,this.ui=r}generateForm(){this.form=this.components.map(e=>this.ui.render(e))}parse(e){let r=[];if(this.components.forEach((n,i)=>{let s=this.form[i].parse(e);r.push(s)}),!this.form.some(n=>n.isRejected()))return r}};Bt.TupleForm=dc;var hc=class extends Lr{constructor(e,r){super(r),this.fields=e,this.ui=r}generateForm(){let e=this.ui.open.selectedIndex,[r,n]=this.fields[e],i=this.ui.render(n);this.form=[i]}parse(e){let r=this.ui.open,n=r.options[r.selectedIndex].value,i=this.form[0].parse(e);if(i===void 0)return;let s={};return s[n]=i,s}};Bt.VariantForm=hc;var pc=class extends Lr{constructor(e,r){super(r),this.ty=e,this.ui=r}generateForm(){if(this.ui.open.checked){let e=this.ui.render(this.ty);this.form=[e]}else this.form=[]}parse(e){if(this.form.length===0)return[];{let r=this.form[0].parse(e);return r===void 0?void 0:[r]}}};Bt.OptionForm=pc;var yc=class extends Lr{constructor(e,r){super(r),this.ty=e,this.ui=r}generateForm(){let e=+this.ui.open.value;this.form=[];for(let r=0;r<e;r++){let n=this.ui.render(this.ty);this.form.push(n)}}parse(e){let r=this.form.map(n=>n.parse(e));if(!this.form.some(n=>n.isRejected()))return r}};Bt.VecForm=yc});var zl=J(Te=>{"use strict";var yg=Te&&Te.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),bg=Te&&Te.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Wl=Te&&Te.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&yg(e,t,r);return bg(e,t),e};Object.defineProperty(Te,"__esModule",{value:!0});Te.renderValue=Te.renderInput=Te.Render=Te.vecForm=Te.optForm=Te.variantForm=Te.tupleForm=Te.recordForm=Te.inputBox=void 0;var Xs=Wl(uc()),gc=Rt(),ii=Wl(bc()),gg={parse:Tg},Ri={render:Ec},mg=(t,e)=>new ii.InputBox(t,Object.assign(Object.assign({},gg),e));Te.inputBox=mg;var _g=(t,e)=>new ii.RecordForm(t,Object.assign(Object.assign({},Ri),e));Te.recordForm=_g;var wg=(t,e)=>new ii.TupleForm(t,Object.assign(Object.assign({},Ri),e));Te.tupleForm=wg;var Eg=(t,e)=>new ii.VariantForm(t,Object.assign(Object.assign({},Ri),e));Te.variantForm=Eg;var xg=(t,e)=>new ii.OptionForm(t,Object.assign(Object.assign({},Ri),e));Te.optForm=xg;var vg=(t,e)=>new ii.VecForm(t,Object.assign(Object.assign({},Ri),e));Te.vecForm=vg;var Zs=class extends Xs.Visitor{visitType(e,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=e.display(),(0,Te.inputBox)(e,{input:n})}visitNull(e,r){return(0,Te.inputBox)(e,{})}visitRecord(e,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Te.recordForm)(r,i);return(0,Te.inputBox)(e,{form:s})}visitTuple(e,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Te.tupleForm)(r,i);return(0,Te.inputBox)(e,{form:s})}visitVariant(e,r,n){let i=document.createElement("select");for(let[a,c]of r){let f=new Option(a);i.add(f)}i.selectedIndex=-1,i.classList.add("open");let s={open:i,event:"change"},o=(0,Te.variantForm)(r,s);return(0,Te.inputBox)(e,{form:o})}visitOpt(e,r,n){let i=document.createElement("input");i.type="checkbox",i.classList.add("open");let s=(0,Te.optForm)(r,{open:i,event:"change"});return(0,Te.inputBox)(e,{form:s})}visitVec(e,r,n){let i=document.createElement("input");i.type="number",i.min="0",i.max="100",i.style.width="8rem",i.placeholder="len",i.classList.add("open");let s=document.createElement("div");s.classList.add("popup-form");let o=(0,Te.vecForm)(r,{open:i,event:"change",container:s});return(0,Te.inputBox)(e,{form:o})}visitRec(e,r,n){return Ec(r)}};Te.Render=Zs;var mc=class extends Xs.Visitor{visitNull(e,r){return null}visitBool(e,r){if(r==="true")return!0;if(r==="false")return!1;throw new Error(`Cannot parse ${r} as boolean`)}visitText(e,r){return r}visitFloat(e,r){return parseFloat(r)}visitFixedInt(e,r){return e._bits<=32?parseInt(r,10):BigInt(r)}visitFixedNat(e,r){return e._bits<=32?parseInt(r,10):BigInt(r)}visitNumber(e,r){return BigInt(r)}visitPrincipal(e,r){return gc.Principal.fromText(r)}visitService(e,r){return gc.Principal.fromText(r)}visitFunc(e,r){let n=r.split(".",2);return[gc.Principal.fromText(n[0]),n[1]]}},_c=class extends Xs.Visitor{visitNull(e,r){return null}visitBool(e,r){return Math.random()<.5}visitText(e,r){return Math.random().toString(36).substring(6)}visitFloat(e,r){return Math.random()}visitInt(e,r){return BigInt(this.generateNumber(!0))}visitNat(e,r){return BigInt(this.generateNumber(!1))}visitFixedInt(e,r){let n=this.generateNumber(!0);return e._bits<=32?n:BigInt(r)}visitFixedNat(e,r){let n=this.generateNumber(!1);return e._bits<=32?n:BigInt(r)}generateNumber(e){let r=Math.floor(Math.random()*100);return e&&Math.random()<.5?-r:r}};function Tg(t,e,r){return e.random&&r===""?t.accept(new _c,r):t.accept(new mc,r)}function Ec(t){return t.accept(new Zs,null)}Te.renderInput=Ec;function Bn(t,e,r){return t.accept(new wc,{input:e,value:r})}Te.renderValue=Bn;var wc=class extends Xs.Visitor{visitType(e,r){r.input.ui.input.value=e.valueToString(r.value)}visitNull(e,r){}visitText(e,r){r.input.ui.input.value=r.value}visitRec(e,r,n){Bn(r,n.input,n.value)}visitOpt(e,r,n){if(n.value.length!==0){let i=n.input.ui.form,s=i.ui.open;s.checked=!0,s.dispatchEvent(new Event(i.ui.event)),Bn(r,i.form[0],n.value[0])}}visitRecord(e,r,n){let i=n.input.ui.form;r.forEach(([s,o],a)=>{Bn(o,i.form[a],n.value[s])})}visitTuple(e,r,n){let i=n.input.ui.form;r.forEach((s,o)=>{Bn(s,i.form[o],n.value[o])})}visitVariant(e,r,n){let i=n.input.ui.form,s=Object.entries(n.value)[0];r.forEach(([o,a],c)=>{if(o===s[0]){let f=i.ui.open;f.selectedIndex=c,f.dispatchEvent(new Event(i.ui.event)),Bn(a,i.form[0],s[1])}})}visitVec(e,r,n){let i=n.input.ui.form,s=n.value.length,o=i.ui.open;o.value=s,o.dispatchEvent(new Event(i.ui.event)),n.value.forEach((a,c)=>{Bn(r,i.form[c],a)})}}});var Zl=J(Dl=>{"use strict";Object.defineProperty(Dl,"__esModule",{value:!0})});var oi=J(yt=>{"use strict";var Xl=yt&&yt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Bg=yt&&yt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),si=yt&&yt.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Xl(e,t,r)},Sg=yt&&yt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Xl(e,t,r);return Bg(e,t),e};Object.defineProperty(yt,"__esModule",{value:!0});yt.IDL=void 0;si(zl(),yt);si(bc(),yt);yt.IDL=Sg(uc());si(rc(),yt);si(ic(),yt);si(Us(),yt);si(Zl(),yt)});var Ii=J((Jl,Js)=>{(function(t){"use strict";var e,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",a=1e14,c=14,f=9007199254740991,l=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],d=1e7,v=1e9;function E(P){var q,D,z,$=N.prototype={constructor:N,toString:null,valueOf:null},se=new N(1),ee=20,de=4,ce=-7,xe=21,Z=-1e7,C=1e7,X=!1,j=1,U=0,W={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},L="0123456789abcdefghijklmnopqrstuvwxyz",ne=!0;function N(u,h){var p,B,x,S,I,_,A,M,R=this;if(!(R instanceof N))return new N(u,h);if(h==null){if(u&&u._isBigNumber===!0){R.s=u.s,!u.c||u.e>C?R.c=R.e=null:u.e<Z?R.c=[R.e=0]:(R.e=u.e,R.c=u.c.slice());return}if((_=typeof u=="number")&&u*0==0){if(R.s=1/u<0?(u=-u,-1):1,u===~~u){for(S=0,I=u;I>=10;I/=10,S++);S>C?R.c=R.e=null:(R.e=S,R.c=[u]);return}M=String(u)}else{if(!r.test(M=String(u)))return z(R,M,_);R.s=M.charCodeAt(0)==45?(M=M.slice(1),-1):1}(S=M.indexOf("."))>-1&&(M=M.replace(".","")),(I=M.search(/e/i))>0?(S<0&&(S=I),S+=+M.slice(I+1),M=M.substring(0,I)):S<0&&(S=M.length)}else{if(T(h,2,L.length,"Base"),h==10&&ne)return R=new N(u),ae(R,ee+R.e+1,de);if(M=String(u),_=typeof u=="number"){if(u*0!=0)return z(R,M,_,h);if(R.s=1/u<0?(M=M.slice(1),-1):1,N.DEBUG&&M.replace(/^0\.0*|\./,"").length>15)throw Error(o+u)}else R.s=M.charCodeAt(0)===45?(M=M.slice(1),-1):1;for(p=L.slice(0,h),S=I=0,A=M.length;I<A;I++)if(p.indexOf(B=M.charAt(I))<0){if(B=="."){if(I>S){S=A;continue}}else if(!x&&(M==M.toUpperCase()&&(M=M.toLowerCase())||M==M.toLowerCase()&&(M=M.toUpperCase()))){x=!0,I=-1,S=0;continue}return z(R,String(u),_,h)}_=!1,M=D(M,h,10,R.s),(S=M.indexOf("."))>-1?M=M.replace(".",""):S=M.length}for(I=0;M.charCodeAt(I)===48;I++);for(A=M.length;M.charCodeAt(--A)===48;);if(M=M.slice(I,++A)){if(A-=I,_&&N.DEBUG&&A>15&&(u>f||u!==i(u)))throw Error(o+R.s*u);if((S=S-I-1)>C)R.c=R.e=null;else if(S<Z)R.c=[R.e=0];else{if(R.e=S,R.c=[],I=(S+1)%c,S<0&&(I+=c),I<A){for(I&&R.c.push(+M.slice(0,I)),A-=c;I<A;)R.c.push(+M.slice(I,I+=c));I=c-(M=M.slice(I)).length}else I-=A;for(;I--;M+="0");R.c.push(+M)}}else R.c=[R.e=0]}N.clone=E,N.ROUND_UP=0,N.ROUND_DOWN=1,N.ROUND_CEIL=2,N.ROUND_FLOOR=3,N.ROUND_HALF_UP=4,N.ROUND_HALF_DOWN=5,N.ROUND_HALF_EVEN=6,N.ROUND_HALF_CEIL=7,N.ROUND_HALF_FLOOR=8,N.EUCLID=9,N.config=N.set=function(u){var h,p;if(u!=null)if(typeof u=="object"){if(u.hasOwnProperty(h="DECIMAL_PLACES")&&(p=u[h],T(p,0,v,h),ee=p),u.hasOwnProperty(h="ROUNDING_MODE")&&(p=u[h],T(p,0,8,h),de=p),u.hasOwnProperty(h="EXPONENTIAL_AT")&&(p=u[h],p&&p.pop?(T(p[0],-v,0,h),T(p[1],0,v,h),ce=p[0],xe=p[1]):(T(p,-v,v,h),ce=-(xe=p<0?-p:p))),u.hasOwnProperty(h="RANGE"))if(p=u[h],p&&p.pop)T(p[0],-v,-1,h),T(p[1],1,v,h),Z=p[0],C=p[1];else if(T(p,-v,v,h),p)Z=-(C=p<0?-p:p);else throw Error(s+h+" cannot be zero: "+p);if(u.hasOwnProperty(h="CRYPTO"))if(p=u[h],p===!!p)if(p)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))X=p;else throw X=!p,Error(s+"crypto unavailable");else X=p;else throw Error(s+h+" not true or false: "+p);if(u.hasOwnProperty(h="MODULO_MODE")&&(p=u[h],T(p,0,9,h),j=p),u.hasOwnProperty(h="POW_PRECISION")&&(p=u[h],T(p,0,v,h),U=p),u.hasOwnProperty(h="FORMAT"))if(p=u[h],typeof p=="object")W=p;else throw Error(s+h+" not an object: "+p);if(u.hasOwnProperty(h="ALPHABET"))if(p=u[h],typeof p=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(p))ne=p.slice(0,10)=="0123456789",L=p;else throw Error(s+h+" invalid: "+p)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:ee,ROUNDING_MODE:de,EXPONENTIAL_AT:[ce,xe],RANGE:[Z,C],CRYPTO:X,MODULO_MODE:j,POW_PRECISION:U,FORMAT:W,ALPHABET:L}},N.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!N.DEBUG)return!0;var h,p,B=u.c,x=u.e,S=u.s;e:if({}.toString.call(B)=="[object Array]"){if((S===1||S===-1)&&x>=-v&&x<=v&&x===i(x)){if(B[0]===0){if(x===0&&B.length===1)return!0;break e}if(h=(x+1)%c,h<1&&(h+=c),String(B[0]).length==h){for(h=0;h<B.length;h++)if(p=B[h],p<0||p>=a||p!==i(p))break e;if(p!==0)return!0}}}else if(B===null&&x===null&&(S===null||S===1||S===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},N.maximum=N.max=function(){return fe(arguments,-1)},N.minimum=N.min=function(){return fe(arguments,1)},N.random=function(){var u=9007199254740992,h=Math.random()*u&2097151?function(){return i(Math.random()*u)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(p){var B,x,S,I,_,A=0,M=[],R=new N(se);if(p==null?p=ee:T(p,0,v),I=n(p/c),X)if(crypto.getRandomValues){for(B=crypto.getRandomValues(new Uint32Array(I*=2));A<I;)_=B[A]*131072+(B[A+1]>>>11),_>=9e15?(x=crypto.getRandomValues(new Uint32Array(2)),B[A]=x[0],B[A+1]=x[1]):(M.push(_%1e14),A+=2);A=I/2}else if(crypto.randomBytes){for(B=crypto.randomBytes(I*=7);A<I;)_=(B[A]&31)*281474976710656+B[A+1]*1099511627776+B[A+2]*4294967296+B[A+3]*16777216+(B[A+4]<<16)+(B[A+5]<<8)+B[A+6],_>=9e15?crypto.randomBytes(7).copy(B,A):(M.push(_%1e14),A+=7);A=I/7}else throw X=!1,Error(s+"crypto unavailable");if(!X)for(;A<I;)_=h(),_<9e15&&(M[A++]=_%1e14);for(I=M[--A],p%=c,I&&p&&(_=l[c-p],M[A]=i(I/_)*_);M[A]===0;M.pop(),A--);if(A<0)M=[S=0];else{for(S=-1;M[0]===0;M.splice(0,1),S-=c);for(A=1,_=M[0];_>=10;_/=10,A++);A<c&&(S-=c-A)}return R.e=S,R.c=M,R}}(),N.sum=function(){for(var u=1,h=arguments,p=new N(h[0]);u<h.length;)p=p.plus(h[u++]);return p},D=function(){var u="0123456789";function h(p,B,x,S){for(var I,_=[0],A,M=0,R=p.length;M<R;){for(A=_.length;A--;_[A]*=B);for(_[0]+=S.indexOf(p.charAt(M++)),I=0;I<_.length;I++)_[I]>x-1&&(_[I+1]==null&&(_[I+1]=0),_[I+1]+=_[I]/x|0,_[I]%=x)}return _.reverse()}return function(p,B,x,S,I){var _,A,M,R,Y,Q,le,Ee,Re=p.indexOf("."),ke=ee,ve=de;for(Re>=0&&(R=U,U=0,p=p.replace(".",""),Ee=new N(B),Q=Ee.pow(p.length-Re),U=R,Ee.c=h(K(m(Q.c),Q.e,"0"),10,x,u),Ee.e=Ee.c.length),le=h(p,B,x,I?(_=L,u):(_=u,L)),M=R=le.length;le[--R]==0;le.pop());if(!le[0])return _.charAt(0);if(Re<0?--M:(Q.c=le,Q.e=M,Q.s=S,Q=q(Q,Ee,ke,ve,x),le=Q.c,Y=Q.r,M=Q.e),A=M+ke+1,Re=le[A],R=x/2,Y=Y||A<0||le[A+1]!=null,Y=ve<4?(Re!=null||Y)&&(ve==0||ve==(Q.s<0?3:2)):Re>R||Re==R&&(ve==4||Y||ve==6&&le[A-1]&1||ve==(Q.s<0?8:7)),A<1||!le[0])p=Y?K(_.charAt(1),-ke,_.charAt(0)):_.charAt(0);else{if(le.length=A,Y)for(--x;++le[--A]>x;)le[A]=0,A||(++M,le=[1].concat(le));for(R=le.length;!le[--R];);for(Re=0,p="";Re<=R;p+=_.charAt(le[Re++]));p=K(p,M,_.charAt(0))}return p}}(),q=function(){function u(B,x,S){var I,_,A,M,R=0,Y=B.length,Q=x%d,le=x/d|0;for(B=B.slice();Y--;)A=B[Y]%d,M=B[Y]/d|0,I=le*A+M*Q,_=Q*A+I%d*d+R,R=(_/S|0)+(I/d|0)+le*M,B[Y]=_%S;return R&&(B=[R].concat(B)),B}function h(B,x,S,I){var _,A;if(S!=I)A=S>I?1:-1;else for(_=A=0;_<S;_++)if(B[_]!=x[_]){A=B[_]>x[_]?1:-1;break}return A}function p(B,x,S,I){for(var _=0;S--;)B[S]-=_,_=B[S]<x[S]?1:0,B[S]=_*I+B[S]-x[S];for(;!B[0]&&B.length>1;B.splice(0,1));}return function(B,x,S,I,_){var A,M,R,Y,Q,le,Ee,Re,ke,ve,he,Qe,Mr,wn,En,Ct,Oe,qt=B.s==x.s?1:-1,mt=B.c,$e=x.c;if(!mt||!mt[0]||!$e||!$e[0])return new N(!B.s||!x.s||(mt?$e&&mt[0]==$e[0]:!$e)?NaN:mt&&mt[0]==0||!$e?qt*0:qt/0);for(Re=new N(qt),ke=Re.c=[],M=B.e-x.e,qt=S+M+1,_||(_=a,M=g(B.e/c)-g(x.e/c),qt=qt/c|0),R=0;$e[R]==(mt[R]||0);R++);if($e[R]>(mt[R]||0)&&M--,qt<0)ke.push(1),Y=!0;else{for(wn=mt.length,Ct=$e.length,R=0,qt+=2,Q=i(_/($e[0]+1)),Q>1&&($e=u($e,Q,_),mt=u(mt,Q,_),Ct=$e.length,wn=mt.length),Mr=Ct,ve=mt.slice(0,Ct),he=ve.length;he<Ct;ve[he++]=0);Oe=$e.slice(),Oe=[0].concat(Oe),En=$e[0],$e[1]>=_/2&&En++;do{if(Q=0,A=h($e,ve,Ct,he),A<0){if(Qe=ve[0],Ct!=he&&(Qe=Qe*_+(ve[1]||0)),Q=i(Qe/En),Q>1)for(Q>=_&&(Q=_-1),le=u($e,Q,_),Ee=le.length,he=ve.length;h(le,ve,Ee,he)==1;)Q--,p(le,Ct<Ee?Oe:$e,Ee,_),Ee=le.length,A=1;else Q==0&&(A=Q=1),le=$e.slice(),Ee=le.length;if(Ee<he&&(le=[0].concat(le)),p(ve,le,he,_),he=ve.length,A==-1)for(;h($e,ve,Ct,he)<1;)Q++,p(ve,Ct<he?Oe:$e,he,_),he=ve.length}else A===0&&(Q++,ve=[0]);ke[R++]=Q,ve[0]?ve[he++]=mt[Mr]||0:(ve=[mt[Mr]],he=1)}while((Mr++<wn||ve[0]!=null)&&qt--);Y=ve[0]!=null,ke[0]||ke.splice(0,1)}if(_==a){for(R=1,qt=ke[0];qt>=10;qt/=10,R++);ae(Re,S+(Re.e=R+M*c-1)+1,I,Y)}else Re.e=M,Re.r=+Y;return Re}}();function y(u,h,p,B){var x,S,I,_,A;if(p==null?p=de:T(p,0,8),!u.c)return u.toString();if(x=u.c[0],I=u.e,h==null)A=m(u.c),A=B==1||B==2&&(I<=ce||I>=xe)?F(A,I):K(A,I,"0");else if(u=ae(new N(u),h,p),S=u.e,A=m(u.c),_=A.length,B==1||B==2&&(h<=S||S<=ce)){for(;_<h;A+="0",_++);A=F(A,S)}else if(h-=I,A=K(A,S,"0"),S+1>_){if(--h>0)for(A+=".";h--;A+="0");}else if(h+=S-_,h>0)for(S+1==_&&(A+=".");h--;A+="0");return u.s<0&&x?"-"+A:A}function fe(u,h){for(var p,B,x=1,S=new N(u[0]);x<u.length;x++)B=new N(u[x]),(!B.s||(p=O(S,B))===h||p===0&&S.s===h)&&(S=B);return S}function ue(u,h,p){for(var B=1,x=h.length;!h[--x];h.pop());for(x=h[0];x>=10;x/=10,B++);return(p=B+p*c-1)>C?u.c=u.e=null:p<Z?u.c=[u.e=0]:(u.e=p,u.c=h),u}z=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,h=/^([^.]+)\.$/,p=/^\.([^.]+)$/,B=/^-?(Infinity|NaN)$/,x=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(S,I,_,A){var M,R=_?I:I.replace(x,"");if(B.test(R))S.s=isNaN(R)?null:R<0?-1:1;else{if(!_&&(R=R.replace(u,function(Y,Q,le){return M=(le=le.toLowerCase())=="x"?16:le=="b"?2:8,!A||A==M?Q:Y}),A&&(M=A,R=R.replace(h,"$1").replace(p,"0.$1")),I!=R))return new N(R,M);if(N.DEBUG)throw Error(s+"Not a"+(A?" base "+A:"")+" number: "+I);S.s=null}S.c=S.e=null}}();function ae(u,h,p,B){var x,S,I,_,A,M,R,Y=u.c,Q=l;if(Y){e:{for(x=1,_=Y[0];_>=10;_/=10,x++);if(S=h-x,S<0)S+=c,I=h,A=Y[M=0],R=i(A/Q[x-I-1]%10);else if(M=n((S+1)/c),M>=Y.length)if(B){for(;Y.length<=M;Y.push(0));A=R=0,x=1,S%=c,I=S-c+1}else break e;else{for(A=_=Y[M],x=1;_>=10;_/=10,x++);S%=c,I=S-c+x,R=I<0?0:i(A/Q[x-I-1]%10)}if(B=B||h<0||Y[M+1]!=null||(I<0?A:A%Q[x-I-1]),B=p<4?(R||B)&&(p==0||p==(u.s<0?3:2)):R>5||R==5&&(p==4||B||p==6&&(S>0?I>0?A/Q[x-I]:0:Y[M-1])%10&1||p==(u.s<0?8:7)),h<1||!Y[0])return Y.length=0,B?(h-=u.e+1,Y[0]=Q[(c-h%c)%c],u.e=-h||0):Y[0]=u.e=0,u;if(S==0?(Y.length=M,_=1,M--):(Y.length=M+1,_=Q[c-S],Y[M]=I>0?i(A/Q[x-I]%Q[I])*_:0),B)for(;;)if(M==0){for(S=1,I=Y[0];I>=10;I/=10,S++);for(I=Y[0]+=_,_=1;I>=10;I/=10,_++);S!=_&&(u.e++,Y[0]==a&&(Y[0]=1));break}else{if(Y[M]+=_,Y[M]!=a)break;Y[M--]=0,_=1}for(S=Y.length;Y[--S]===0;Y.pop());}u.e>C?u.c=u.e=null:u.e<Z&&(u.c=[u.e=0])}return u}function te(u){var h,p=u.e;return p===null?u.toString():(h=m(u.c),h=p<=ce||p>=xe?F(h,p):K(h,p,"0"),u.s<0?"-"+h:h)}return $.absoluteValue=$.abs=function(){var u=new N(this);return u.s<0&&(u.s=1),u},$.comparedTo=function(u,h){return O(this,new N(u,h))},$.decimalPlaces=$.dp=function(u,h){var p,B,x,S=this;if(u!=null)return T(u,0,v),h==null?h=de:T(h,0,8),ae(new N(S),u+S.e+1,h);if(!(p=S.c))return null;if(B=((x=p.length-1)-g(this.e/c))*c,x=p[x])for(;x%10==0;x/=10,B--);return B<0&&(B=0),B},$.dividedBy=$.div=function(u,h){return q(this,new N(u,h),ee,de)},$.dividedToIntegerBy=$.idiv=function(u,h){return q(this,new N(u,h),0,1)},$.exponentiatedBy=$.pow=function(u,h){var p,B,x,S,I,_,A,M,R,Y=this;if(u=new N(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+te(u));if(h!=null&&(h=new N(h)),_=u.e>14,!Y.c||!Y.c[0]||Y.c[0]==1&&!Y.e&&Y.c.length==1||!u.c||!u.c[0])return R=new N(Math.pow(+te(Y),_?u.s*(2-k(u)):+te(u))),h?R.mod(h):R;if(A=u.s<0,h){if(h.c?!h.c[0]:!h.s)return new N(NaN);B=!A&&Y.isInteger()&&h.isInteger(),B&&(Y=Y.mod(h))}else{if(u.e>9&&(Y.e>0||Y.e<-1||(Y.e==0?Y.c[0]>1||_&&Y.c[1]>=24e7:Y.c[0]<8e13||_&&Y.c[0]<=9999975e7)))return S=Y.s<0&&k(u)?-0:0,Y.e>-1&&(S=1/S),new N(A?1/S:S);U&&(S=n(U/c+2))}for(_?(p=new N(.5),A&&(u.s=1),M=k(u)):(x=Math.abs(+te(u)),M=x%2),R=new N(se);;){if(M){if(R=R.times(Y),!R.c)break;S?R.c.length>S&&(R.c.length=S):B&&(R=R.mod(h))}if(x){if(x=i(x/2),x===0)break;M=x%2}else if(u=u.times(p),ae(u,u.e+1,1),u.e>14)M=k(u);else{if(x=+te(u),x===0)break;M=x%2}Y=Y.times(Y),S?Y.c&&Y.c.length>S&&(Y.c.length=S):B&&(Y=Y.mod(h))}return B?R:(A&&(R=se.div(R)),h?R.mod(h):S?ae(R,U,de,I):R)},$.integerValue=function(u){var h=new N(this);return u==null?u=de:T(u,0,8),ae(h,h.e+1,u)},$.isEqualTo=$.eq=function(u,h){return O(this,new N(u,h))===0},$.isFinite=function(){return!!this.c},$.isGreaterThan=$.gt=function(u,h){return O(this,new N(u,h))>0},$.isGreaterThanOrEqualTo=$.gte=function(u,h){return(h=O(this,new N(u,h)))===1||h===0},$.isInteger=function(){return!!this.c&&g(this.e/c)>this.c.length-2},$.isLessThan=$.lt=function(u,h){return O(this,new N(u,h))<0},$.isLessThanOrEqualTo=$.lte=function(u,h){return(h=O(this,new N(u,h)))===-1||h===0},$.isNaN=function(){return!this.s},$.isNegative=function(){return this.s<0},$.isPositive=function(){return this.s>0},$.isZero=function(){return!!this.c&&this.c[0]==0},$.minus=function(u,h){var p,B,x,S,I=this,_=I.s;if(u=new N(u,h),h=u.s,!_||!h)return new N(NaN);if(_!=h)return u.s=-h,I.plus(u);var A=I.e/c,M=u.e/c,R=I.c,Y=u.c;if(!A||!M){if(!R||!Y)return R?(u.s=-h,u):new N(Y?I:NaN);if(!R[0]||!Y[0])return Y[0]?(u.s=-h,u):new N(R[0]?I:de==3?-0:0)}if(A=g(A),M=g(M),R=R.slice(),_=A-M){for((S=_<0)?(_=-_,x=R):(M=A,x=Y),x.reverse(),h=_;h--;x.push(0));x.reverse()}else for(B=(S=(_=R.length)<(h=Y.length))?_:h,_=h=0;h<B;h++)if(R[h]!=Y[h]){S=R[h]<Y[h];break}if(S&&(x=R,R=Y,Y=x,u.s=-u.s),h=(B=Y.length)-(p=R.length),h>0)for(;h--;R[p++]=0);for(h=a-1;B>_;){if(R[--B]<Y[B]){for(p=B;p&&!R[--p];R[p]=h);--R[p],R[B]+=a}R[B]-=Y[B]}for(;R[0]==0;R.splice(0,1),--M);return R[0]?ue(u,R,M):(u.s=de==3?-1:1,u.c=[u.e=0],u)},$.modulo=$.mod=function(u,h){var p,B,x=this;return u=new N(u,h),!x.c||!u.s||u.c&&!u.c[0]?new N(NaN):!u.c||x.c&&!x.c[0]?new N(x):(j==9?(B=u.s,u.s=1,p=q(x,u,0,3),u.s=B,p.s*=B):p=q(x,u,0,j),u=x.minus(p.times(u)),!u.c[0]&&j==1&&(u.s=x.s),u)},$.multipliedBy=$.times=function(u,h){var p,B,x,S,I,_,A,M,R,Y,Q,le,Ee,Re,ke,ve=this,he=ve.c,Qe=(u=new N(u,h)).c;if(!he||!Qe||!he[0]||!Qe[0])return!ve.s||!u.s||he&&!he[0]&&!Qe||Qe&&!Qe[0]&&!he?u.c=u.e=u.s=null:(u.s*=ve.s,!he||!Qe?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(B=g(ve.e/c)+g(u.e/c),u.s*=ve.s,A=he.length,Y=Qe.length,A<Y&&(Ee=he,he=Qe,Qe=Ee,x=A,A=Y,Y=x),x=A+Y,Ee=[];x--;Ee.push(0));for(Re=a,ke=d,x=Y;--x>=0;){for(p=0,Q=Qe[x]%ke,le=Qe[x]/ke|0,I=A,S=x+I;S>x;)M=he[--I]%ke,R=he[I]/ke|0,_=le*M+R*Q,M=Q*M+_%ke*ke+Ee[S]+p,p=(M/Re|0)+(_/ke|0)+le*R,Ee[S--]=M%Re;Ee[S]=p}return p?++B:Ee.splice(0,1),ue(u,Ee,B)},$.negated=function(){var u=new N(this);return u.s=-u.s||null,u},$.plus=function(u,h){var p,B=this,x=B.s;if(u=new N(u,h),h=u.s,!x||!h)return new N(NaN);if(x!=h)return u.s=-h,B.minus(u);var S=B.e/c,I=u.e/c,_=B.c,A=u.c;if(!S||!I){if(!_||!A)return new N(x/0);if(!_[0]||!A[0])return A[0]?u:new N(_[0]?B:x*0)}if(S=g(S),I=g(I),_=_.slice(),x=S-I){for(x>0?(I=S,p=A):(x=-x,p=_),p.reverse();x--;p.push(0));p.reverse()}for(x=_.length,h=A.length,x-h<0&&(p=A,A=_,_=p,h=x),x=0;h;)x=(_[--h]=_[h]+A[h]+x)/a|0,_[h]=a===_[h]?0:_[h]%a;return x&&(_=[x].concat(_),++I),ue(u,_,I)},$.precision=$.sd=function(u,h){var p,B,x,S=this;if(u!=null&&u!==!!u)return T(u,1,v),h==null?h=de:T(h,0,8),ae(new N(S),u,h);if(!(p=S.c))return null;if(x=p.length-1,B=x*c+1,x=p[x]){for(;x%10==0;x/=10,B--);for(x=p[0];x>=10;x/=10,B++);}return u&&S.e+1>B&&(B=S.e+1),B},$.shiftedBy=function(u){return T(u,-f,f),this.times("1e"+u)},$.squareRoot=$.sqrt=function(){var u,h,p,B,x,S=this,I=S.c,_=S.s,A=S.e,M=ee+4,R=new N("0.5");if(_!==1||!I||!I[0])return new N(!_||_<0&&(!I||I[0])?NaN:I?S:1/0);if(_=Math.sqrt(+te(S)),_==0||_==1/0?(h=m(I),(h.length+A)%2==0&&(h+="0"),_=Math.sqrt(+h),A=g((A+1)/2)-(A<0||A%2),_==1/0?h="5e"+A:(h=_.toExponential(),h=h.slice(0,h.indexOf("e")+1)+A),p=new N(h)):p=new N(_+""),p.c[0]){for(A=p.e,_=A+M,_<3&&(_=0);;)if(x=p,p=R.times(x.plus(q(S,x,M,1))),m(x.c).slice(0,_)===(h=m(p.c)).slice(0,_))if(p.e<A&&--_,h=h.slice(_-3,_+1),h=="9999"||!B&&h=="4999"){if(!B&&(ae(x,x.e+ee+2,0),x.times(x).eq(S))){p=x;break}M+=4,_+=4,B=1}else{(!+h||!+h.slice(1)&&h.charAt(0)=="5")&&(ae(p,p.e+ee+2,1),u=!p.times(p).eq(S));break}}return ae(p,p.e+ee+1,de,u)},$.toExponential=function(u,h){return u!=null&&(T(u,0,v),u++),y(this,u,h,1)},$.toFixed=function(u,h){return u!=null&&(T(u,0,v),u=u+this.e+1),y(this,u,h)},$.toFormat=function(u,h,p){var B,x=this;if(p==null)u!=null&&h&&typeof h=="object"?(p=h,h=null):u&&typeof u=="object"?(p=u,u=h=null):p=W;else if(typeof p!="object")throw Error(s+"Argument not an object: "+p);if(B=x.toFixed(u,h),x.c){var S,I=B.split("."),_=+p.groupSize,A=+p.secondaryGroupSize,M=p.groupSeparator||"",R=I[0],Y=I[1],Q=x.s<0,le=Q?R.slice(1):R,Ee=le.length;if(A&&(S=_,_=A,A=S,Ee-=S),_>0&&Ee>0){for(S=Ee%_||_,R=le.substr(0,S);S<Ee;S+=_)R+=M+le.substr(S,_);A>0&&(R+=M+le.slice(S)),Q&&(R="-"+R)}B=Y?R+(p.decimalSeparator||"")+((A=+p.fractionGroupSize)?Y.replace(new RegExp("\\d{"+A+"}\\B","g"),"$&"+(p.fractionGroupSeparator||"")):Y):R}return(p.prefix||"")+B+(p.suffix||"")},$.toFraction=function(u){var h,p,B,x,S,I,_,A,M,R,Y,Q,le=this,Ee=le.c;if(u!=null&&(_=new N(u),!_.isInteger()&&(_.c||_.s!==1)||_.lt(se)))throw Error(s+"Argument "+(_.isInteger()?"out of range: ":"not an integer: ")+te(_));if(!Ee)return new N(le);for(h=new N(se),M=p=new N(se),B=A=new N(se),Q=m(Ee),S=h.e=Q.length-le.e-1,h.c[0]=l[(I=S%c)<0?c+I:I],u=!u||_.comparedTo(h)>0?S>0?h:M:_,I=C,C=1/0,_=new N(Q),A.c[0]=0;R=q(_,h,0,1),x=p.plus(R.times(B)),x.comparedTo(u)!=1;)p=B,B=x,M=A.plus(R.times(x=M)),A=x,h=_.minus(R.times(x=h)),_=x;return x=q(u.minus(p),B,0,1),A=A.plus(x.times(M)),p=p.plus(x.times(B)),A.s=M.s=le.s,S=S*2,Y=q(M,B,S,de).minus(le).abs().comparedTo(q(A,p,S,de).minus(le).abs())<1?[M,B]:[A,p],C=I,Y},$.toNumber=function(){return+te(this)},$.toPrecision=function(u,h){return u!=null&&T(u,1,v),y(this,u,h,2)},$.toString=function(u){var h,p=this,B=p.s,x=p.e;return x===null?B?(h="Infinity",B<0&&(h="-"+h)):h="NaN":(u==null?h=x<=ce||x>=xe?F(m(p.c),x):K(m(p.c),x,"0"):u===10&&ne?(p=ae(new N(p),ee+x+1,de),h=K(m(p.c),p.e,"0")):(T(u,2,L.length,"Base"),h=D(K(m(p.c),x,"0"),10,u,B,!0)),B<0&&p.c[0]&&(h="-"+h)),h},$.valueOf=$.toJSON=function(){return te(this)},$._isBigNumber=!0,P!=null&&N.set(P),N}function g(P){var q=P|0;return P>0||P===q?q:q-1}function m(P){for(var q,D,z=1,$=P.length,se=P[0]+"";z<$;){for(q=P[z++]+"",D=c-q.length;D--;q="0"+q);se+=q}for($=se.length;se.charCodeAt(--$)===48;);return se.slice(0,$+1||1)}function O(P,q){var D,z,$=P.c,se=q.c,ee=P.s,de=q.s,ce=P.e,xe=q.e;if(!ee||!de)return null;if(D=$&&!$[0],z=se&&!se[0],D||z)return D?z?0:-de:ee;if(ee!=de)return ee;if(D=ee<0,z=ce==xe,!$||!se)return z?0:!$^D?1:-1;if(!z)return ce>xe^D?1:-1;for(de=(ce=$.length)<(xe=se.length)?ce:xe,ee=0;ee<de;ee++)if($[ee]!=se[ee])return $[ee]>se[ee]^D?1:-1;return ce==xe?0:ce>xe^D?1:-1}function T(P,q,D,z){if(P<q||P>D||P!==i(P))throw Error(s+(z||"Argument")+(typeof P=="number"?P<q||P>D?" out of range: ":" not an integer: ":" not a primitive number: ")+String(P))}function k(P){var q=P.c.length-1;return g(P.e/c)==q&&P.c[q]%2!=0}function F(P,q){return(P.length>1?P.charAt(0)+"."+P.slice(1):P)+(q<0?"e":"e+")+q}function K(P,q,D){var z,$;if(q<0){for($=D+".";++q;$+=D);P=$+P}else if(z=P.length,++q>z){for($=D,q-=z;--q;$+=D);P+=$}else q<z&&(P=P.slice(0,q)+"."+P.slice(q));return P}e=E(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof Js<"u"&&Js.exports?Js.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(Jl)});var Ql=J((px,Ll)=>{Ll.exports=function(e,r,n){var i=new e.Uint8Array(n),s=r.pushInt,o=r.pushInt32,a=r.pushInt32Neg,c=r.pushInt64,f=r.pushInt64Neg,l=r.pushFloat,d=r.pushFloatSingle,v=r.pushFloatDouble,E=r.pushTrue,g=r.pushFalse,m=r.pushUndefined,O=r.pushNull,T=r.pushInfinity,k=r.pushInfinityNeg,F=r.pushNaN,K=r.pushNaNNeg,P=r.pushArrayStart,q=r.pushArrayStartFixed,D=r.pushArrayStartFixed32,z=r.pushArrayStartFixed64,$=r.pushObjectStart,se=r.pushObjectStartFixed,ee=r.pushObjectStartFixed32,de=r.pushObjectStartFixed64,ce=r.pushByteString,xe=r.pushByteStringStart,Z=r.pushUtf8String,C=r.pushUtf8StringStart,X=r.pushSimpleUnassigned,j=r.pushTagStart,U=r.pushTagStart4,W=r.pushTagStart8,L=r.pushTagUnassigned,ne=r.pushBreak,N=e.Math.pow,y=0,fe=0,ue=0;function ae(w){for(w=w|0,y=0,fe=w;(y|0)<(fe|0)&&(ue=Ay[i[y]&255](i[y]|0)|0,!((ue|0)>0)););return ue|0}function te(w){return w=w|0,((y|0)+(w|0)|0)<(fe|0)?0:1}function u(w){return w=w|0,i[w|0]<<8|i[w+1|0]|0}function h(w){return w=w|0,i[w|0]<<24|i[w+1|0]<<16|i[w+2|0]<<8|i[w+3|0]|0}function p(w){return w=w|0,s(w|0),y=y+1|0,0}function B(w){return w=w|0,te(1)|0?1:(s(i[y+1|0]|0),y=y+2|0,0)}function x(w){return w=w|0,te(2)|0?1:(s(u(y+1|0)|0),y=y+3|0,0)}function S(w){return w=w|0,te(4)|0?1:(o(u(y+1|0)|0,u(y+3|0)|0),y=y+5|0,0)}function I(w){return w=w|0,te(8)|0?1:(c(u(y+1|0)|0,u(y+3|0)|0,u(y+5|0)|0,u(y+7|0)|0),y=y+9|0,0)}function _(w){return w=w|0,s(-1-(w-32|0)|0),y=y+1|0,0}function A(w){return w=w|0,te(1)|0?1:(s(-1-(i[y+1|0]|0)|0),y=y+2|0,0)}function M(w){w=w|0;var Se=0;return te(2)|0?1:(Se=u(y+1|0)|0,s(-1-(Se|0)|0),y=y+3|0,0)}function R(w){return w=w|0,te(4)|0?1:(a(u(y+1|0)|0,u(y+3|0)|0),y=y+5|0,0)}function Y(w){return w=w|0,te(8)|0?1:(f(u(y+1|0)|0,u(y+3|0)|0,u(y+5|0)|0,u(y+7|0)|0),y=y+9|0,0)}function Q(w){w=w|0;var Se=0,Ae=0,Be=0;return Be=w-64|0,te(Be|0)|0?1:(Se=y+1|0,Ae=(y+1|0)+(Be|0)|0,ce(Se|0,Ae|0),y=Ae|0,0)}function le(w){w=w|0;var Se=0,Ae=0,Be=0;return te(1)|0||(Be=i[y+1|0]|0,Se=y+2|0,Ae=(y+2|0)+(Be|0)|0,te(Be+1|0)|0)?1:(ce(Se|0,Ae|0),y=Ae|0,0)}function Ee(w){w=w|0;var Se=0,Ae=0,Be=0;return te(2)|0||(Be=u(y+1|0)|0,Se=y+3|0,Ae=(y+3|0)+(Be|0)|0,te(Be+2|0)|0)?1:(ce(Se|0,Ae|0),y=Ae|0,0)}function Re(w){w=w|0;var Se=0,Ae=0,Be=0;return te(4)|0||(Be=h(y+1|0)|0,Se=y+5|0,Ae=(y+5|0)+(Be|0)|0,te(Be+4|0)|0)?1:(ce(Se|0,Ae|0),y=Ae|0,0)}function ke(w){return w=w|0,1}function ve(w){return w=w|0,xe(),y=y+1|0,0}function he(w){w=w|0;var Se=0,Ae=0,Be=0;return Be=w-96|0,te(Be|0)|0?1:(Se=y+1|0,Ae=(y+1|0)+(Be|0)|0,Z(Se|0,Ae|0),y=Ae|0,0)}function Qe(w){w=w|0;var Se=0,Ae=0,Be=0;return te(1)|0||(Be=i[y+1|0]|0,Se=y+2|0,Ae=(y+2|0)+(Be|0)|0,te(Be+1|0)|0)?1:(Z(Se|0,Ae|0),y=Ae|0,0)}function Mr(w){w=w|0;var Se=0,Ae=0,Be=0;return te(2)|0||(Be=u(y+1|0)|0,Se=y+3|0,Ae=(y+3|0)+(Be|0)|0,te(Be+2|0)|0)?1:(Z(Se|0,Ae|0),y=Ae|0,0)}function wn(w){w=w|0;var Se=0,Ae=0,Be=0;return te(4)|0||(Be=h(y+1|0)|0,Se=y+5|0,Ae=(y+5|0)+(Be|0)|0,te(Be+4|0)|0)?1:(Z(Se|0,Ae|0),y=Ae|0,0)}function En(w){return w=w|0,1}function Ct(w){return w=w|0,C(),y=y+1|0,0}function Oe(w){return w=w|0,q(w-128|0),y=y+1|0,0}function qt(w){return w=w|0,te(1)|0?1:(q(i[y+1|0]|0),y=y+2|0,0)}function mt(w){return w=w|0,te(2)|0?1:(q(u(y+1|0)|0),y=y+3|0,0)}function $e(w){return w=w|0,te(4)|0?1:(D(u(y+1|0)|0,u(y+3|0)|0),y=y+5|0,0)}function ay(w){return w=w|0,te(8)|0?1:(z(u(y+1|0)|0,u(y+3|0)|0,u(y+5|0)|0,u(y+7|0)|0),y=y+9|0,0)}function cy(w){return w=w|0,P(),y=y+1|0,0}function Ke(w){w=w|0;var Se=0;return Se=w-160|0,te(Se|0)|0?1:(se(Se|0),y=y+1|0,0)}function uy(w){return w=w|0,te(1)|0?1:(se(i[y+1|0]|0),y=y+2|0,0)}function fy(w){return w=w|0,te(2)|0?1:(se(u(y+1|0)|0),y=y+3|0,0)}function ly(w){return w=w|0,te(4)|0?1:(ee(u(y+1|0)|0,u(y+3|0)|0),y=y+5|0,0)}function dy(w){return w=w|0,te(8)|0?1:(de(u(y+1|0)|0,u(y+3|0)|0,u(y+5|0)|0,u(y+7|0)|0),y=y+9|0,0)}function hy(w){return w=w|0,$(),y=y+1|0,0}function Hn(w){return w=w|0,j(w-192|0|0),y=y+1|0,0}function gE(w){return w=w|0,j(w|0),y=y+1|0,0}function mE(w){return w=w|0,j(w|0),y=y+1|0,0}function _E(w){return w=w|0,j(w|0),y=y+1|0,0}function wE(w){return w=w|0,j(w|0),y=y+1|0,0}function dt(w){return w=w|0,j(w-192|0|0),y=y+1|0,0}function EE(w){return w=w|0,j(w|0),y=y+1|0,0}function xE(w){return w=w|0,j(w|0),y=y+1|0,0}function vE(w){return w=w|0,j(w|0),y=y+1|0,0}function py(w){return w=w|0,te(1)|0?1:(j(i[y+1|0]|0),y=y+2|0,0)}function yy(w){return w=w|0,te(2)|0?1:(j(u(y+1|0)|0),y=y+3|0,0)}function by(w){return w=w|0,te(4)|0?1:(U(u(y+1|0)|0,u(y+3|0)|0),y=y+5|0,0)}function gy(w){return w=w|0,te(8)|0?1:(W(u(y+1|0)|0,u(y+3|0)|0,u(y+5|0)|0,u(y+7|0)|0),y=y+9|0,0)}function rt(w){return w=w|0,X((w|0)-224|0),y=y+1|0,0}function my(w){return w=w|0,g(),y=y+1|0,0}function _y(w){return w=w|0,E(),y=y+1|0,0}function wy(w){return w=w|0,O(),y=y+1|0,0}function Ey(w){return w=w|0,m(),y=y+1|0,0}function xy(w){return w=w|0,te(1)|0?1:(X(i[y+1|0]|0),y=y+2|0,0)}function vy(w){w=w|0;var Se=0,Ae=0,Be=1,hs=0,vi=0,TE=0;return te(2)|0?1:(Se=i[y+1|0]|0,Ae=i[y+2|0]|0,(Se|0)&128&&(Be=-1),hs=+(((Se|0)&124)>>2),vi=+(((Se|0)&3)<<8|Ae),+hs==0?l(+(+Be*5960464477539063e-23*+vi)):+hs==31?+Be==1?+vi>0?F():T():+vi>0?K():k():l(+(+Be*N(2,+(+hs-25))*+(1024+vi))),y=y+3|0,0)}function Ty(w){return w=w|0,te(4)|0?1:(d(i[y+1|0]|0,i[y+2|0]|0,i[y+3|0]|0,i[y+4|0]|0),y=y+5|0,0)}function By(w){return w=w|0,te(8)|0?1:(v(i[y+1|0]|0,i[y+2|0]|0,i[y+3|0]|0,i[y+4|0]|0,i[y+5|0]|0,i[y+6|0]|0,i[y+7|0]|0,i[y+8|0]|0),y=y+9|0,0)}function qe(w){return w=w|0,1}function Sy(w){return w=w|0,ne(),y=y+1|0,0}var Ay=[p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,B,x,S,I,qe,qe,qe,qe,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,A,M,R,Y,qe,qe,qe,qe,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,le,Ee,Re,ke,qe,qe,qe,ve,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,Qe,Mr,wn,En,qe,qe,qe,Ct,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,Oe,qt,mt,$e,ay,qe,qe,qe,cy,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,uy,fy,ly,dy,qe,qe,qe,hy,Hn,Hn,Hn,Hn,Hn,Hn,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,dt,py,yy,by,gy,qe,qe,qe,qe,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,my,_y,wy,Ey,xy,vy,Ty,By,qe,qe,qe,Sy];return{parse:ae}}});var Ui=J(Kt=>{"use strict";var xc=Ii().BigNumber;Kt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Kt.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36};Kt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Kt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Kt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Kt.SHIFT32=Math.pow(2,32);Kt.SHIFT16=Math.pow(2,16);Kt.MAX_SAFE_HIGH=2097151;Kt.NEG_ONE=new xc(-1);Kt.TEN=new xc(10);Kt.TWO=new xc(2);Kt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Ls=J(Lt=>{"use strict";var{Buffer:Ag}=$n("buffer"),td=Ii().BigNumber,rd=Ui(),ed=rd.SHIFT32,Og=rd.SHIFT16,Ng=2097151;Lt.parseHalf=function(e){var r,n,i;return i=e[0]&128?-1:1,r=(e[0]&124)>>2,n=(e[0]&3)<<8|e[1],r?r===31?i*(n?NaN:1/0):i*Math.pow(2,r-25)*(1024+n):i*5960464477539063e-23*n};function Pg(t){return t<16?"0"+t.toString(16):t.toString(16)}Lt.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=Pg(t[n]);return new td(r,16)};Lt.buildMap=t=>{let e=new Map,r=Object.keys(t),n=r.length;for(let i=0;i<n;i++)e.set(r[i],t[r[i]]);return e};Lt.buildInt32=(t,e)=>t*Og+e;Lt.buildInt64=(t,e,r,n)=>{let i=Lt.buildInt32(t,e),s=Lt.buildInt32(r,n);return i>Ng?new td(i).times(ed).plus(s):i*ed+s};Lt.writeHalf=function(e,r){let n=Ag.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if(i&8191)return!1;var s=i>>16&32768;let o=i>>23&255,a=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(a>>13);else if(o>=103&&o<113){if(a&(1<<126-o)-1)return!1;s+=a+8388608>>126-o}else return!1;return e.writeUInt16BE(s,0),!0};Lt.keySorter=function(t,e){var r=t[0].byteLength,n=e[0].byteLength;return r>n?1:n>r?-1:t[0].compare(e[0])};Lt.isNegativeZero=t=>t===0&&1/t<0;Lt.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var Sc=J((gx,nd)=>{"use strict";var Bc=Ui(),Rg=Bc.MT,Qs=Bc.SIMPLE,vc=Bc.SYMS,Tc=class t{constructor(e){if(typeof e!="number")throw new Error("Invalid Simple type: "+typeof e);if(e<0||e>255||(e|0)!==e)throw new Error("value must be a small positive integer: "+e);this.value=e}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,Rg.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case Qs.FALSE:return!1;case Qs.TRUE:return!0;case Qs.NULL:return r?null:vc.NULL;case Qs.UNDEFINED:return r?void 0:vc.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return vc.BREAK;default:return new t(e)}}};nd.exports=Tc});var Oc=J((mx,id)=>{"use strict";var Ac=class t{constructor(e,r,n){if(this.tag=e,this.value=r,this.err=n,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(e){return e._pushTag(this.tag),e.pushAny(this.value)}convert(e){var r,n;if(n=e?.[this.tag],typeof n!="function"&&(n=t["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(t,this.value)}catch(i){return r=i,this.err=r,this}}};id.exports=Ac});var Pc=J((_x,od)=>{"use strict";var{URL:Ig,URLSearchParams:Ug,format:Fg}=$n("url"),sd="http://localhost",Nc=class extends Ig{constructor(e="",r=sd){super(e,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}format(){return this.toString()}};od.exports={URLWithLegacySupport:Nc,URLSearchParams:Ug,format:Fg,defaultBase:sd}});var ud=J((wx,cd)=>{"use strict";var{URLWithLegacySupport:ad,format:Mg}=Pc();cd.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new ad(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new ad(t,Mg(o)).toString()}});var Rc=J((Ex,fd)=>{"use strict";var{URLWithLegacySupport:Cg,format:qg,URLSearchParams:jg,defaultBase:kg}=Pc(),Vg=ud();fd.exports={URL:Cg,URLSearchParams:jg,format:qg,relative:Vg,defaultBase:kg}});var Ic=J((xx,dd)=>{"use strict";var{Buffer:ai}=$n("buffer"),ld=Ya(),Hg=Ii().BigNumber,$g=Ql(),It=Ls(),Me=Ui(),Kg=Sc(),Gg=Oc(),{URL:Yg}=Rc(),Fi=class t{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=It.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=ai.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>It.arrayBufferToBignumber(r),3:r=>Me.NEG_ONE.minus(It.arrayBufferToBignumber(r)),4:r=>Me.TEN.pow(r[0]).times(r[1]),5:r=>Me.TWO.pow(r[0]).times(r[1]),32:r=>new Yg(r),35:r=>new RegExp(r)},e.tags),this.parser=$g(global,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var e=this._parents.pop();if(e.length>0)throw new Error(`Missing ${e.length} elements`);switch(e.type){case Me.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case Me.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case Me.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case Me.PARENT.MAP:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(e.ref,e.length));break;case Me.PARENT.OBJECT:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(e.ref,e.length));break;case Me.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===Me.PARENT.TAG&&this._dec()}_dec(){let e=this._currentParent;e.length<0||(e.length--,e.length===0&&this._closeParent())}_push(e,r){let n=this._currentParent;switch(n.values++,n.type){case Me.PARENT.ARRAY:case Me.PARENT.BYTE_STRING:case Me.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case Me.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=Me.PARENT.MAP,n.ref=It.buildMap(n.ref)));break;case Me.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case Me.PARENT.TAG:this._ref.push(e),r||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(e,r,n){this._parents[this._depth]={type:r,length:n,ref:e,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:Me.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,r){let n=this._knownTags[e];return n?n(r):new Gg(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return ai.concat(e)}createByteStringFromHeap(e,r){return e===r?ai.alloc(0):ai.from(this._heap.slice(e,r))}createInt(e){return e}createInt32(e,r){return It.buildInt32(e,r)}createInt64(e,r,n,i){return It.buildInt64(e,r,n,i)}createFloat(e){return e}createFloatSingle(e,r,n,i){return ld.read([e,r,n,i],0,!1,23,4)}createFloatDouble(e,r,n,i,s,o,a,c){return ld.read([e,r,n,i,s,o,a,c],0,!1,52,8)}createInt32Neg(e,r){return-1-It.buildInt32(e,r)}createInt64Neg(e,r,n,i){let s=It.buildInt32(e,r),o=It.buildInt32(n,i);return s>Me.MAX_SAFE_HIGH?Me.NEG_ONE.minus(new Hg(s).times(Me.SHIFT32).plus(o)):-1-(s*Me.SHIFT32+o)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(e,r){return e.join("")}createUtf8StringFromHeap(e,r){return e===r?"":this._buffer.toString("utf8",e,r)}createSimpleUnassigned(e){return new Kg(e)}pushInt(e){this._push(this.createInt(e))}pushInt32(e,r){this._push(this.createInt32(e,r))}pushInt64(e,r,n,i){this._push(this.createInt64(e,r,n,i))}pushFloat(e){this._push(this.createFloat(e))}pushFloatSingle(e,r,n,i){this._push(this.createFloatSingle(e,r,n,i))}pushFloatDouble(e,r,n,i,s,o,a,c){this._push(this.createFloatDouble(e,r,n,i,s,o,a,c))}pushInt32Neg(e,r){this._push(this.createInt32Neg(e,r))}pushInt64Neg(e,r,n,i){this._push(this.createInt64Neg(e,r,n,i))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],Me.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,r){let n=It.buildInt32(e,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,r,n,i){let s=It.buildInt64(e,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,r){let n=It.buildInt32(e,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,r,n,i){let s=It.buildInt64(e,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:Me.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(e,r){this._push(this.createByteStringFromHeap(e,r))}pushUtf8StringStart(){this._parents[this._depth]={type:Me.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(e,r){this._push(this.createUtf8StringFromHeap(e,r))}pushSimpleUnassigned(e){this._push(this.createSimpleUnassigned(e))}pushTagStart(e){this._parents[this._depth]={type:Me.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,r){this.pushTagStart(It.buildInt32(e,r))}pushTagStart8(e,r,n,i){this.pushTagStart(It.buildInt64(e,r,n,i))}pushTagUnassigned(e){this._push(this.createTag(e))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(e){if(e===0){this._push(this.createObject({}));return}this._createParent({},Me.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),Me.PARENT.ARRAY,e)}_decode(e){if(e.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(e);let r=this.parser.parse(e.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(r>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(e){return this._decode(e),this._res[0]}decodeAll(e){return this._decode(e),this._res}static decode(e,r){return typeof e=="string"&&(e=ai.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=ai.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};Fi.decodeFirst=Fi.decode;dd.exports=Fi});var yd=J((vx,pd)=>{"use strict";var{Buffer:Uc}=$n("buffer"),Wg=Ic(),zg=Ls(),Fc=class t extends Wg{createTag(e,r){return`${e}(${r})`}createInt(e){return super.createInt(e).toString()}createInt32(e,r){return super.createInt32(e,r).toString()}createInt64(e,r,n,i){return super.createInt64(e,r,n,i).toString()}createInt32Neg(e,r){return super.createInt32Neg(e,r).toString()}createInt64Neg(e,r,n,i){return super.createInt64Neg(e,r,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(e){let r=super.createFloat(e);return zg.isNegativeZero(e)?"-0_1":`${r}_1`}createFloatSingle(e,r,n,i){return`${super.createFloatSingle(e,r,n,i)}_2`}createFloatDouble(e,r,n,i,s,o,a,c){return`${super.createFloatDouble(e,r,n,i,s,o,a,c)}_3`}createByteString(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(e,r){return`h'${Uc.from(super.createByteStringFromHeap(e,r)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(e){return`simple(${e})`}createArray(e,r){let n=super.createArray(e,r);return r===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(e,r){let n=super.createMap(e),i=Array.from(n.keys()).reduce(hd(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(e,r){let n=super.createObject(e),i=Object.keys(n).reduce(hd(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,r){return`"${Uc.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=Uc.from(e,r||"hex")),new t().decodeFirst(e)}};pd.exports=Fc;function hd(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var wd=J((Tx,_d)=>{"use strict";var{Buffer:Er}=$n("buffer"),{URL:Dg}=Rc(),Cc=Ii().BigNumber,Mc=Ls(),at=Ui(),or=at.MT,eo=at.NUMBYTES,bd=at.SHIFT32,gd=at.SYMS,ci=at.TAG,Zg=at.MT.SIMPLE_FLOAT<<5|at.NUMBYTES.TWO,Xg=at.MT.SIMPLE_FLOAT<<5|at.NUMBYTES.FOUR,Jg=at.MT.SIMPLE_FLOAT<<5|at.NUMBYTES.EIGHT,Lg=at.MT.SIMPLE_FLOAT<<5|at.SIMPLE.TRUE,Qg=at.MT.SIMPLE_FLOAT<<5|at.SIMPLE.FALSE,em=at.MT.SIMPLE_FLOAT<<5|at.SIMPLE.UNDEFINED,md=at.MT.SIMPLE_FLOAT<<5|at.SIMPLE.NULL,tm=new Cc("0x20000000000000"),rm=Er.from("f97e00","hex"),nm=Er.from("f9fc00","hex"),im=Er.from("f97c00","hex");function sm(t){return{}.toString.call(t).slice(8,-1)}var qc=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[Dg,this._pushUrl],[Cc,this._pushBigNumber]];let r=e.genTypes||[],n=r.length;for(let i=0;i<n;i++)this.addSemanticType(r[i][0],r[i][1]);this._reset()}addSemanticType(e,r){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===e){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,o}return this.semanticTypes.push([e,r]),null}push(e){return e&&(this.result[this.offset]=e,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=e.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(e,r,n){return this.result[this.offset]=e,this.resultMethod[this.offset]=r,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(e){return this.pushWrite(e,1,1)}_pushUInt16BE(e){return this.pushWrite(e,2,2)}_pushUInt32BE(e){return this.pushWrite(e,3,4)}_pushDoubleBE(e){return this.pushWrite(e,4,8)}_pushNaN(){return this.push(rm)}_pushInfinity(e){let r=e<0?nm:im;return this.push(r)}_pushFloat(e){let r=Er.allocUnsafe(2);if(Mc.writeHalf(r,e)&&Mc.parseHalf(r)===e)return this._pushUInt8(Zg)&&this.push(r);let n=Er.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(Xg)&&this.push(n):this._pushUInt8(Jg)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|eo.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|eo.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|eo.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|eo.EIGHT)&&this._pushUInt32BE(Math.floor(e/bd))&&this._pushUInt32BE(e%bd):r===or.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,or.NEG_INT,e):this._pushInt(e,or.POS_INT)}_pushNumber(e){switch(!1){case e===e:return this._pushNaN(e);case isFinite(e):return this._pushInfinity(e);case e%1!==0:return this._pushIntNum(e);default:return this._pushFloat(e)}}_pushString(e){let r=Er.byteLength(e,"utf8");return this._pushInt(r,or.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?Lg:Qg)}_pushUndefined(e){return this._pushUInt8(em)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,or.ARRAY))return!1;for(let i=0;i<n;i++)if(!e.pushAny(r[i]))return!1;return!0}_pushTag(e){return this._pushInt(e,or.TAG)}_pushDate(e,r){return e._pushTag(ci.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,or.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(ci.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,or.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(ci.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=ci.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=ci.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=Er.from(n,"hex");return this._pushTag(r)&&this._pushBuffer(this,i)}_pushBigNumber(e,r){if(r.isNaN())return e._pushNaN();if(!r.isFinite())return e._pushInfinity(r.isNegative()?-1/0:1/0);if(r.isInteger())return e._pushBigint(r);if(!(e._pushTag(ci.DECIMAL_FRAC)&&e._pushInt(2,or.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new Cc(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(tm)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,or.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(e){if(!e)return this._pushUInt8(md);for(var r=this.semanticTypes.length,n=0;n<r;n++)if(e instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(e,this,e);var i=e.encodeCBOR;if(typeof i=="function")return i.call(e,this);var s=Object.keys(e),o=s.length;return this._pushInt(o,or.MAP)?this._pushRawMap(o,s.map(a=>[a,e[a]])):!1}_pushRawMap(e,r){r=r.map(function(i){return i[0]=t.encode(i[0]),i}).sort(Mc.keySorter);for(var n=0;n<e;n++)if(!this.push(r[n][0])||!this.pushAny(r[n][1]))return!1;return!0}write(e){return this.pushAny(e)}pushAny(e){var r=sm(e);switch(r){case"Number":return this._pushNumber(e);case"String":return this._pushString(e);case"Boolean":return this._pushBoolean(e);case"Object":return this._pushObject(e);case"Array":return this._pushArray(this,e);case"Uint8Array":return this._pushBuffer(this,Er.isBuffer(e)?e:Er.from(e));case"Null":return this._pushUInt8(md);case"Undefined":return this._pushUndefined(e);case"Map":return this._pushMap(this,e);case"Set":return this._pushSet(this,e);case"URL":return this._pushUrl(this,e);case"BigNumber":return this._pushBigNumber(this,e);case"Date":return this._pushDate(this,e);case"RegExp":return this._pushRegexp(this,e);case"Symbol":switch(e){case gd.NULL:return this._pushObject(null);case gd.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+e.toString())}default:throw new Error("Unknown type: "+typeof e+", "+(e?e.toString():""))}}finalize(){if(this.offset===0)return null;for(var e=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=r[o];var a=Er.allocUnsafe(s),c=0,f=0;for(o=0;o<i;o++){switch(f=r[o],n[o]){case 0:e[o].copy(a,c);break;case 1:a.writeUInt8(e[o],c,!0);break;case 2:a.writeUInt16BE(e[o],c,!0);break;case 3:a.writeUInt32BE(e[o],c,!0);break;case 4:a.writeDoubleBE(e[o],c,!0);break;case 5:a.write(e[o],c,f,"utf8");break;default:throw new Error("unkown method")}c+=f}var l=a;return this._reset(),l}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(e){let r=new t;if(!r.pushAny(e))throw new Error("Failed to encode input");return r.finalize()}};_d.exports=qc});var to=J(ct=>{"use strict";ct.Diagnose=yd();ct.Decoder=Ic();ct.Encoder=wd();ct.Simple=Sc();ct.Tagged=Oc();ct.decodeAll=ct.Decoder.decodeAll;ct.decodeFirst=ct.Decoder.decodeFirst;ct.diagnose=ct.Diagnose.diagnose;ct.encode=ct.Encoder.encode;ct.decode=ct.Decoder.decode;ct.leveldb={decode:ct.Decoder.decodeAll,encode:ct.Encoder.encode,buffer:!0,name:"cbor"}});var Gt=J(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.bufFromBufLike=St.uint8ToBuf=St.bufEquals=St.compare=St.fromHex=St.toHex=St.concat=void 0;function om(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e.buffer}St.concat=om;function am(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}St.toHex=am;var cm=new RegExp(/^[0-9a-fA-F]+$/);function um(t){if(!cm.test(t))throw new Error("Invalid hexadecimal string.");let e=[...t].reduce((r,n,i)=>(r[i/2|0]=(r[i/2|0]||"")+n,r),[]).map(r=>Number.parseInt(r,16));return new Uint8Array(e).buffer}St.fromHex=um;function Ed(t,e){if(t.byteLength!==e.byteLength)return t.byteLength-e.byteLength;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return r[i]-n[i];return 0}St.compare=Ed;function fm(t,e){return Ed(t,e)===0}St.bufEquals=fm;function ro(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}St.uint8ToBuf=ro;function xd(t){return t instanceof Uint8Array?ro(t):t instanceof ArrayBuffer?t:Array.isArray(t)?ro(new Uint8Array(t)):"buffer"in t?xd(t.buffer):ro(new Uint8Array(t))}St.bufFromBufLike=xd});var qi=J(Qt=>{"use strict";var lm=Qt&&Qt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Qt,"__esModule",{value:!0});Qt.hashOfMap=Qt.requestIdOf=Qt.hashValue=Qt.hash=void 0;var vd=oi(),dm=lm(to()),hm=xs(),Mi=Gt();function Qr(t){return(0,Mi.uint8ToBuf)(hm.sha256.create().update(new Uint8Array(t)).digest())}Qt.hash=Qr;function Ci(t){if(t instanceof dm.default.Tagged)return Ci(t.value);if(typeof t=="string")return Td(t);if(typeof t=="number")return Qr((0,vd.lebEncode)(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return Qr(t);if(Array.isArray(t)){let e=t.map(Ci);return Qr((0,Mi.concat)(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return Qr(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return Ci(t.toHash());if(typeof t=="object")return jc(t);if(typeof t=="bigint")return Qr((0,vd.lebEncode)(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}Qt.hashValue=Ci;var Td=t=>{let e=new TextEncoder().encode(t);return Qr(e)};function pm(t){return jc(t)}Qt.requestIdOf=pm;function jc(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=Td(o),f=Ci(a);return[c,f]}).sort(([o],[a])=>(0,Mi.compare)(o,a)),i=(0,Mi.concat)(...n.map(o=>(0,Mi.concat)(...o)));return Qr(i)}Qt.hashOfMap=jc});var Hc=J(xr=>{"use strict";var ym=xr&&xr.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};Object.defineProperty(xr,"__esModule",{value:!0});xr.createIdentityDescriptor=xr.AnonymousIdentity=xr.SignIdentity=void 0;var Bd=Rt(),bm=qi(),Sd=Gt(),gm=new TextEncoder().encode(`
16
- ic-request`),kc=class{getPrincipal(){return this._principal||(this._principal=Bd.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=ym(e,["body"]),i=await(0,bm.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,Sd.concat)(gm,i))}})}};xr.SignIdentity=kc;var Vc=class{getPrincipal(){return Bd.Principal.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};xr.AnonymousIdentity=Vc;function mm(t){return"getPublicKey"in t?{type:"PublicKeyIdentity",publicKey:(0,Sd.toHex)(t.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}xr.createIdentityDescriptor=mm});var Gc=J(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});var _m=9007199254740992;function Vr(t,...e){let r=new Uint8Array(t.byteLength+e.reduce((i,s)=>i+s.byteLength,0));r.set(new Uint8Array(t),0);let n=t.byteLength;for(let i of e)r.set(new Uint8Array(i),n),n+=i.byteLength;return r.buffer}function ar(t,e,r){r=r.replace(/[^0-9a-fA-F]/g,"");let n=2**(e-24);r=r.slice(-n*2).padStart(n*2,"0");let i=[(t<<5)+e].concat(r.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function no(t,e){if(e<24)return new Uint8Array([(t<<5)+e]).buffer;{let r=e<=255?24:e<=65535?25:e<=4294967295?26:27;return ar(t,r,e.toString(16))}}function Ad(t){let e=[];for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);n<128?e.push(n):n<2048?e.push(192|n>>6,128|n&63):n<55296||n>=57344?e.push(224|n>>12,128|n>>6&63,128|n&63):(r++,n=(n&1023)<<10|t.charCodeAt(r)&1023,e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return Vr(new Uint8Array(no(3,t.length)),new Uint8Array(e))}function wm(t,e){if(t==14277111)return Vr(new Uint8Array([217,217,247]),e);if(t<24)return Vr(new Uint8Array([192+t]),e);{let r=t<=255?24:t<=65535?25:t<=4294967295?26:27,n=2**(r-24),i=t.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+r].concat(i.match(/../g).map(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}Ve.tagged=wm;function ji(t){return new Uint8Array(t).buffer}Ve.raw=ji;function $c(t){if(isNaN(t))throw new RangeError("Invalid number.");t=Math.min(Math.max(0,t),23);let e=[0+t];return new Uint8Array(e).buffer}Ve.uSmall=$c;function Od(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),255),t=t.toString(16),ar(0,24,t)}Ve.u8=Od;function Nd(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),65535),t=t.toString(16),ar(0,25,t)}Ve.u16=Nd;function Pd(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),4294967295),t=t.toString(16),ar(0,26,t)}Ve.u32=Pd;function Kc(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return ar(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),_m),t=t.toString(16),ar(0,27,t)}Ve.u64=Kc;function Rd(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return $c(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}Ve.iSmall=Rd;function Id(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),255),t=t.toString(16),ar(1,24,t)}Ve.i8=Id;function Ud(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),65535),t=t.toString(16),ar(1,25,t)}Ve.i16=Ud;function Fd(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),4294967295),t=t.toString(16),ar(1,26,t)}Ve.i32=Fd;function Md(t,e){if(typeof t=="string"&&e==16){if(t.startsWith("-")?t=t.slice(1):t="0",t.match(/[^0-9a-fA-F]/)||t.length>16)throw new RangeError("Invalid number.");let r=!1,n=t.split("").reduceRight((i,s)=>{if(r)return s+i;let o=parseInt(s,16)-1;return o>=0?(r=!0,o.toString(16)+i):"f"+i},"");return r?ar(1,27,n):Kc(0)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),9007199254740992),t=t.toString(16),ar(1,27,t)}Ve.i64=Md;function Em(t){return t>=0?t<24?$c(t):t<=255?Od(t):t<=65535?Nd(t):t<=4294967295?Pd(t):Kc(t):t>=-24?Rd(t):t>=-255?Id(t):t>=-65535?Ud(t):t>=-4294967295?Fd(t):Md(t)}Ve.number=Em;function xm(t){return Vr(no(2,t.byteLength),t)}Ve.bytes=xm;function vm(t){return Ad(t)}Ve.string=vm;function Tm(t){return Vr(no(4,t.length),...t)}Ve.array=Tm;function Bm(t,e=!1){t instanceof Map||(t=new Map(Object.entries(t)));let r=Array.from(t.entries());return e&&(r=r.sort(([n],[i])=>n.localeCompare(i))),Vr(no(5,t.size),...r.map(([n,i])=>Vr(Ad(n),i)))}Ve.map=Bm;function Sm(t){let e=new Float32Array([t]);return Vr(new Uint8Array([250]),new Uint8Array(e.buffer))}Ve.singleFloat=Sm;function Am(t){let e=new Float64Array([t]);return Vr(new Uint8Array([251]),new Uint8Array(e.buffer))}Ve.doubleFloat=Am;function Om(t){return t?Cd():qd()}Ve.bool=Om;function Cd(){return ji(new Uint8Array([245]))}Ve.true_=Cd;function qd(){return ji(new Uint8Array([244]))}Ve.false_=qd;function Nm(){return ji(new Uint8Array([246]))}Ve.null_=Nm;function Pm(){return ji(new Uint8Array([247]))}Ve.undefined_=Pm});var jd=J(en=>{"use strict";var Rm=en&&en.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(en,"__esModule",{value:!0});var cr=Rm(Gc()),Im=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],io=class{constructor(e,r=!1){this._serializer=e,this._stable=r,this.name="jsonDefault",this.priority=-100}match(e){return["undefined","boolean","number","string","object"].indexOf(typeof e)!=-1}encode(e){switch(typeof e){case"undefined":return cr.undefined_();case"boolean":return cr.bool(e);case"number":return Math.floor(e)===e?cr.number(e):cr.doubleFloat(e);case"string":return cr.string(e);case"object":if(e===null)return cr.null_();if(Array.isArray(e))return cr.array(e.map(r=>this._serializer.serializeValue(r)));if(Im.find(r=>e instanceof r))return cr.bytes(e.buffer);if(Object.getOwnPropertyNames(e).indexOf("toJSON")!==-1)return this.encode(e.toJSON());if(e instanceof Map){let r=new Map;for(let[n,i]of e.entries())r.set(n,this._serializer.serializeValue(i));return cr.map(r,this._stable)}else{let r=new Map;for(let[n,i]of Object.entries(e))r.set(n,this._serializer.serializeValue(i));return cr.map(r,this._stable)}default:throw new Error("Invalid value.")}}};en.JsonDefaultCborEncoder=io;var so=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};en.ToCborEncoder=so;var oo=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new io(r,e)),r.addEncoder(new so),r}removeEncoder(e){for(let r of this._encoders.values())r.name==e&&this._encoders.delete(r)}addEncoder(e){this._encoders.add(e)}getEncoderFor(e){let r=null;for(let n of this._encoders)(!r||n.priority>r.priority)&&n.match(e)&&(r=n);if(r===null)throw new Error("Could not find an encoder for value.");return r}serializeValue(e){return this.getEncoderFor(e).encode(e)}serialize(e){return this.serializeValue(e)}};en.CborSerializer=oo;var Yc=class extends oo{serialize(e){return cr.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};en.SelfDescribeCborSerializer=Yc});var ki=J(Sn=>{"use strict";function Um(t){for(var e in t)Sn.hasOwnProperty(e)||(Sn[e]=t[e])}var Fm=Sn&&Sn.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(Sn,"__esModule",{value:!0});Um(jd());var Mm=Fm(Gc());Sn.value=Mm});var Vi=J(Et=>{"use strict";var Cm=Et&&Et.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),qm=Et&&Et.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),jm=Et&&Et.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Cm(e,t,r);return qm(e,t),e},km=Et&&Et.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Et,"__esModule",{value:!0});Et.decode=Et.encode=Et.CborTag=void 0;var Vm=km(to()),ui=jm(ki()),Hm=ki(),ao=Gt(),Wc=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return ui.value.bytes(e.toUint8Array())}},zc=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return ui.value.bytes(new Uint8Array(e))}},Dc=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?ui.value.tagged(2,ui.value.bytes((0,ao.fromHex)(e.toString(16)))):ui.value.tagged(3,ui.value.bytes((0,ao.fromHex)((BigInt("-1")*e).toString(16))))}},co=Hm.SelfDescribeCborSerializer.withDefaultEncoders(!0);co.addEncoder(new Wc);co.addEncoder(new zc);co.addEncoder(new Dc);var Vd;(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(Vd=Et.CborTag||(Et.CborTag={}));function $m(t){return co.serialize(t)}Et.encode=$m;function kd(t){let e=t.byteLength,r=BigInt(0);for(let n=0;n<e;n++)r=r*BigInt(256)+BigInt(t[n]);return r}var Zc=class extends Vm.default.Decoder{createByteString(e){return(0,ao.concat)(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}};function Km(t){let e=new Uint8Array(t),r=new Zc({size:e.byteLength,tags:{2:n=>kd(n),3:n=>-kd(n),[Vd.Semantic]:n=>n}});try{return r.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,ao.toHex)(e)}`)}}Et.decode=Km});var Xc=J(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.randomNumber=void 0;var Gm=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let t=new Uint32Array(1);return window.crypto.getRandomValues(t),t[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let t=new Uint32Array(1);return crypto.getRandomValues(t),t[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};uo.randomNumber=Gm});var Hi=J(An=>{"use strict";Object.defineProperty(An,"__esModule",{value:!0});An.makeNonce=An.SubmitRequestType=void 0;var fo=Xc(),Ym;(function(t){t.Call="call"})(Ym=An.SubmitRequestType||(An.SubmitRequestType={}));function Wm(){let t=new ArrayBuffer(16),e=new DataView(t),r=(0,fo.randomNumber)(),n=(0,fo.randomNumber)(),i=(0,fo.randomNumber)(),s=(0,fo.randomNumber)();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}An.makeNonce=Wm});var ho=J(At=>{"use strict";var zm=At&&At.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Dm=At&&At.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Zm=At&&At.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&zm(e,t,r);return Dm(e,t),e};Object.defineProperty(At,"__esModule",{value:!0});At.httpHeadersTransform=At.makeExpiryTransform=At.makeNonceTransform=At.Expiry=void 0;var Xm=oi(),Jm=Zm(ki()),Lm=Hi(),Qm=BigInt(1e6),e1=60*1e3,lo=class{constructor(e){let s=BigInt(Math.floor(Date.now()+e-e1))*Qm/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return Jm.value.u64(this._value.toString(16),16)}toHash(){return(0,Xm.lebEncode)(this._value)}};At.Expiry=lo;function t1(t=Lm.makeNonce){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}At.makeNonceTransform=t1;function r1(t){return async e=>{e.body.ingress_expiry=new lo(t)}}At.makeExpiryTransform=r1;function n1(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}At.httpHeadersTransform=n1});var Lc=J(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.AgentHTTPResponseError=void 0;var i1=Qn(),Jc=class extends i1.AgentError{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};po.AgentHTTPResponseError=Jc});var er=J(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});Ge.bitMask=void 0;Ge.isBytes=bo;Ge.abytes=go;Ge.bytesToHex=eu;Ge.numberToHexUnpadded=Gd;Ge.hexToNumber=tu;Ge.hexToBytes=mo;Ge.bytesToNumberBE=a1;Ge.bytesToNumberLE=c1;Ge.numberToBytesBE=Yd;Ge.numberToBytesLE=u1;Ge.numberToVarBytesBE=f1;Ge.ensureBytes=l1;Ge.concatBytes=Wd;Ge.equalBytes=d1;Ge.utf8ToBytes=h1;Ge.bitLen=p1;Ge.bitGet=y1;Ge.bitSet=b1;Ge.createHmacDrbg=m1;Ge.validateObject=w1;var Kd=BigInt(0),yo=BigInt(1),s1=BigInt(2);function bo(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function go(t){if(!bo(t))throw new Error("Uint8Array expected")}var o1=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function eu(t){go(t);let e="";for(let r=0;r<t.length;r++)e+=o1[t[r]];return e}function Gd(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function tu(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var Hr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Hd(t){if(t>=Hr._0&&t<=Hr._9)return t-Hr._0;if(t>=Hr._A&&t<=Hr._F)return t-(Hr._A-10);if(t>=Hr._a&&t<=Hr._f)return t-(Hr._a-10)}function mo(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=Hd(t.charCodeAt(s)),a=Hd(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function a1(t){return tu(eu(t))}function c1(t){return go(t),tu(eu(Uint8Array.from(t).reverse()))}function Yd(t,e){return mo(t.toString(16).padStart(e*2,"0"))}function u1(t,e){return Yd(t,e).reverse()}function f1(t){return mo(Gd(t))}function l1(t,e,r){let n;if(typeof e=="string")try{n=mo(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(bo(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function Wd(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];go(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}function d1(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function h1(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function p1(t){let e;for(e=0;t>Kd;t>>=yo,e+=1);return e}function y1(t,e){return t>>BigInt(e)&yo}function b1(t,e,r){return t|(r?yo:Kd)<<BigInt(e)}var g1=t=>(s1<<BigInt(t-1))-yo;Ge.bitMask=g1;var Qc=t=>new Uint8Array(t),$d=t=>Uint8Array.from(t);function m1(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=Qc(t),i=Qc(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...d)=>r(i,n,...d),c=(d=Qc())=>{i=a($d([0]),d),n=a(),d.length!==0&&(i=a($d([1]),d),n=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let d=0,v=[];for(;d<e;){n=a();let E=n.slice();v.push(E),d+=n.length}return Wd(...v)};return(d,v)=>{o(),c(d);let E;for(;!(E=v(f()));)c();return o(),E}}var _1={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||bo(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function w1(t,e,r={}){let n=(i,s,o)=>{let a=_1[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return t}});var $r=J(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.isNegativeLE=void 0;We.mod=Yt;We.pow=Zd;We.pow2=T1;We.invert=_o;We.tonelliShanks=Xd;We.FpSqrt=Jd;We.validateField=A1;We.FpPow=Ld;We.FpInvertBatch=Qd;We.FpDiv=O1;We.FpIsSquare=N1;We.nLength=nu;We.Field=P1;We.FpSqrtOdd=R1;We.FpSqrtEven=I1;We.hashToPrivateScalar=U1;We.getFieldBytesLength=iu;We.getMinHashLength=e0;We.mapHashToField=F1;var Wt=er(),ut=BigInt(0),je=BigInt(1),tn=BigInt(2),E1=BigInt(3),ru=BigInt(4),zd=BigInt(5),Dd=BigInt(8),x1=BigInt(9),v1=BigInt(16);function Yt(t,e){let r=t%e;return r>=ut?r:e+r}function Zd(t,e,r){if(r<=ut||e<ut)throw new Error("Expected power/modulo > 0");if(r===je)return ut;let n=je;for(;e>ut;)e&je&&(n=n*t%r),t=t*t%r,e>>=je;return n}function T1(t,e,r){let n=t;for(;e-- >ut;)n*=n,n%=r;return n}function _o(t,e){if(t===ut||e<=ut)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Yt(t,e),n=e,i=ut,s=je,o=je,a=ut;for(;r!==ut;){let f=n/r,l=n%r,d=i-o*f,v=s-a*f;n=r,r=l,i=o,s=a,o=d,a=v}if(n!==je)throw new Error("invert: does not exist");return Yt(i,e)}function Xd(t){let e=(t-je)/tn,r,n,i;for(r=t-je,n=0;r%tn===ut;r/=tn,n++);for(i=tn;i<t&&Zd(i,e,t)!==t-je;i++);if(n===1){let o=(t+je)/ru;return function(c,f){let l=c.pow(f,o);if(!c.eql(c.sqr(l),f))throw new Error("Cannot find square root");return l}}let s=(r+je)/tn;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,l=a.pow(a.mul(a.ONE,i),r),d=a.pow(c,s),v=a.pow(c,r);for(;!a.eql(v,a.ONE);){if(a.eql(v,a.ZERO))return a.ZERO;let E=1;for(let m=a.sqr(v);E<f&&!a.eql(m,a.ONE);E++)m=a.sqr(m);let g=a.pow(l,je<<BigInt(f-E-1));l=a.sqr(g),d=a.mul(d,g),v=a.mul(v,l),f=E}return d}}function Jd(t){if(t%ru===E1){let e=(t+je)/ru;return function(n,i){let s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(t%Dd===zd){let e=(t-zd)/Dd;return function(n,i){let s=n.mul(i,tn),o=n.pow(s,e),a=n.mul(i,o),c=n.mul(n.mul(a,tn),o),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),i))throw new Error("Cannot find square root");return f}}return t%v1,Xd(t)}var B1=(t,e)=>(Yt(t,e)&je)===je;We.isNegativeLE=B1;var S1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function A1(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=S1.reduce((n,i)=>(n[i]="function",n),e);return(0,Wt.validateObject)(t,r)}function Ld(t,e,r){if(r<ut)throw new Error("Expected power > 0");if(r===ut)return t.ONE;if(r===je)return e;let n=t.ONE,i=e;for(;r>ut;)r&je&&(n=t.mul(n,i)),i=t.sqr(i),r>>=je;return n}function Qd(t,e){let r=new Array(e.length),n=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),i=t.inv(n);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),i),r}function O1(t,e,r){return t.mul(e,typeof r=="bigint"?_o(r,t.ORDER):t.inv(r))}function N1(t){let e=(t.ORDER-je)/tn;return r=>{let n=t.pow(r,e);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}}function nu(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function P1(t,e,r=!1,n={}){if(t<=ut)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=nu(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=Jd(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:(0,Wt.bitMask)(i),ZERO:ut,ONE:je,create:c=>Yt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ut<=c&&c<t},is0:c=>c===ut,isOdd:c=>(c&je)===je,neg:c=>Yt(-c,t),eql:(c,f)=>c===f,sqr:c=>Yt(c*c,t),add:(c,f)=>Yt(c+f,t),sub:(c,f)=>Yt(c-f,t),mul:(c,f)=>Yt(c*f,t),pow:(c,f)=>Ld(a,c,f),div:(c,f)=>Yt(c*_o(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>_o(c,t),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>Qd(a,c),cmov:(c,f,l)=>l?f:c,toBytes:c=>r?(0,Wt.numberToBytesLE)(c,s):(0,Wt.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,Wt.bytesToNumberLE)(c):(0,Wt.bytesToNumberBE)(c)}});return Object.freeze(a)}function R1(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?r:t.neg(r)}function I1(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function U1(t,e,r=!1){t=(0,Wt.ensureBytes)("privateHash",t);let n=t.length,i=nu(e).nByteLength+8;if(i<24||n<i||n>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${n}`);let s=r?(0,Wt.bytesToNumberLE)(t):(0,Wt.bytesToNumberBE)(t);return Yt(s,e-je)+je}function iu(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function e0(t){let e=iu(t);return e+Math.ceil(e/2)}function F1(t,e,r=!1){let n=t.length,i=iu(e),s=e0(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?(0,Wt.bytesToNumberBE)(t):(0,Wt.bytesToNumberLE)(t),a=Yt(o,e-je)+je;return r?(0,Wt.numberToBytesLE)(a,i):(0,Wt.numberToBytesBE)(a,i)}});var wo=J(On=>{"use strict";Object.defineProperty(On,"__esModule",{value:!0});On.expand_message_xmd=t0;On.expand_message_xof=r0;On.hash_to_field=su;On.isogenyMap=j1;On.createHasher=k1;var M1=$r(),Ot=er(),C1=Ot.bytesToNumberBE;function rn(t,e){if(t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);let r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=t&255,t>>>=8;return new Uint8Array(r)}function q1(t,e){let r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function ou(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function t0(t,e,r,n){(0,Ot.abytes)(t),(0,Ot.abytes)(e),ou(r),e.length>255&&(e=n((0,Ot.concatBytes)((0,Ot.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(r/i);if(o>255)throw new Error("Invalid xmd length");let a=(0,Ot.concatBytes)(e,rn(e.length,1)),c=rn(0,s),f=rn(r,2),l=new Array(o),d=n((0,Ot.concatBytes)(c,t,f,rn(0,1),a));l[0]=n((0,Ot.concatBytes)(d,rn(1,1),a));for(let E=1;E<=o;E++){let g=[q1(d,l[E-1]),rn(E+1,1),a];l[E]=n((0,Ot.concatBytes)(...g))}return(0,Ot.concatBytes)(...l).slice(0,r)}function r0(t,e,r,n,i){if((0,Ot.abytes)(t),(0,Ot.abytes)(e),ou(r),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update((0,Ot.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(t).update(rn(r,2)).update(e).update(rn(e.length,1)).digest()}function su(t,e,r){(0,Ot.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:a,DST:c}=r;(0,Ot.abytes)(t),ou(e);let f=typeof c=="string"?(0,Ot.utf8ToBytes)(c):c,l=n.toString(2).length,d=Math.ceil((l+i)/8),v=e*s*d,E;if(a==="xmd")E=t0(t,f,v,o);else if(a==="xof")E=r0(t,f,v,i,o);else if(a==="_internal_pass")E=t;else throw new Error('expand must be "xmd" or "xof"');let g=new Array(e);for(let m=0;m<e;m++){let O=new Array(s);for(let T=0;T<s;T++){let k=d*(T+m*s),F=E.subarray(k,k+d);O[T]=(0,M1.mod)(C1(F),n)}g[m]=O}return g}function j1(t,e){let r=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,a,c]=r.map(f=>f.reduce((l,d)=>t.add(t.mul(l,n),d)));return n=t.div(s,o),i=t.mul(i,t.div(a,c)),{x:n,y:i}}}function k1(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=su(n,2,{...r,DST:r.DST,...i}),o=t.fromAffine(e(s[0])),a=t.fromAffine(e(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=su(n,1,{...r,DST:r.encodeDST,...i}),o=t.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(let s of n)if(typeof s!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${s} in array`);let i=t.fromAffine(e(n)).clearCofactor();return i.assertValidity(),i}}}});var cu=J(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});Eo.wNAF=$1;Eo.validateBasic=K1;var n0=$r(),V1=er(),H1=BigInt(0),au=BigInt(1);function $1(t,e){let r=(i,s)=>{let o=s.negate();return i?o:s},n=i=>{let s=Math.ceil(e/i)+1,o=2**(i-1);return{windows:s,windowSize:o}};return{constTimeNegate:r,unsafeLadder(i,s){let o=t.ZERO,a=i;for(;s>H1;)s&au&&(o=o.add(a)),a=a.double(),s>>=au;return o},precomputeWindow(i,s){let{windows:o,windowSize:a}=n(s),c=[],f=i,l=f;for(let d=0;d<o;d++){l=f,c.push(l);for(let v=1;v<a;v++)l=l.add(f),c.push(l);f=l.double()}return c},wNAF(i,s,o){let{windows:a,windowSize:c}=n(i),f=t.ZERO,l=t.BASE,d=BigInt(2**i-1),v=2**i,E=BigInt(i);for(let g=0;g<a;g++){let m=g*c,O=Number(o&d);o>>=E,O>c&&(O-=v,o+=au);let T=m,k=m+Math.abs(O)-1,F=g%2!==0,K=O<0;O===0?l=l.add(r(F,s[T])):f=f.add(r(K,s[k]))}return{p:f,f:l}},wNAFCached(i,s,o,a){let c=i._WINDOW_SIZE||1,f=s.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&s.set(i,a(f))),this.wNAF(c,f,o)}}}function K1(t){return(0,n0.validateField)(t.Fp),(0,V1.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,n0.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}});var fu=J(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});Ut.DER=void 0;Ut.weierstrassPoints=s0;Ut.weierstrass=D1;Ut.SWUFpSqrtRatio=o0;Ut.mapToCurveSimpleSWU=Z1;var uu=cu(),fi=$r(),ze=er(),vr=er();function G1(t){let e=(0,uu.validateBasic)(t);ze.validateObject(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:Y1,hexToBytes:W1}=ze;Ut.DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=Ut.DER;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");let r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:Y1(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=Ut.DER,r=typeof t=="string"?W1(t):t;ze.abytes(r);let n=r.length;if(n<2||r[0]!=48)throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:i,l:s}=Ut.DER._parseInt(r.subarray(2)),{d:o,l:a}=Ut.DER._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(t){let e=f=>Number.parseInt(f[0],16)&8?"00"+f:f,r=f=>{let l=f.toString(16);return l.length&1?`0${l}`:l},n=e(r(t.s)),i=e(r(t.r)),s=n.length/2,o=i.length/2,a=r(s),c=r(o);return`30${r(o+s+4)}02${c}${i}02${a}${n}`}};var ur=BigInt(0),Ze=BigInt(1),nn=BigInt(2),xo=BigInt(3),i0=BigInt(4);function s0(t){let e=G1(t),{Fp:r}=e,n=e.toBytes||((g,m,O)=>{let T=m.toAffine();return ze.concatBytes(Uint8Array.from([4]),r.toBytes(T.x),r.toBytes(T.y))}),i=e.fromBytes||(g=>{let m=g.subarray(1),O=r.fromBytes(m.subarray(0,r.BYTES)),T=r.fromBytes(m.subarray(r.BYTES,2*r.BYTES));return{x:O,y:T}});function s(g){let{a:m,b:O}=e,T=r.sqr(g),k=r.mul(T,g);return r.add(r.add(k,r.mul(g,m)),O)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(g){return typeof g=="bigint"&&ur<g&&g<e.n}function a(g){if(!o(g))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(g){let{allowedPrivateKeyLengths:m,nByteLength:O,wrapPrivateKey:T,n:k}=e;if(m&&typeof g!="bigint"){if(ze.isBytes(g)&&(g=ze.bytesToHex(g)),typeof g!="string"||!m.includes(g.length))throw new Error("Invalid key");g=g.padStart(O*2,"0")}let F;try{F=typeof g=="bigint"?g:ze.bytesToNumberBE((0,vr.ensureBytes)("private key",g,O))}catch{throw new Error(`private key must be ${O} bytes, hex or bigint, not ${typeof g}`)}return T&&(F=fi.mod(F,k)),a(F),F}let f=new Map;function l(g){if(!(g instanceof d))throw new Error("ProjectivePoint expected")}class d{constructor(m,O,T){if(this.px=m,this.py=O,this.pz=T,m==null||!r.isValid(m))throw new Error("x required");if(O==null||!r.isValid(O))throw new Error("y required");if(T==null||!r.isValid(T))throw new Error("z required")}static fromAffine(m){let{x:O,y:T}=m||{};if(!m||!r.isValid(O)||!r.isValid(T))throw new Error("invalid affine point");if(m instanceof d)throw new Error("projective point not allowed");let k=F=>r.eql(F,r.ZERO);return k(O)&&k(T)?d.ZERO:new d(O,T,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(m){let O=r.invertBatch(m.map(T=>T.pz));return m.map((T,k)=>T.toAffine(O[k])).map(d.fromAffine)}static fromHex(m){let O=d.fromAffine(i((0,vr.ensureBytes)("pointHex",m)));return O.assertValidity(),O}static fromPrivateKey(m){return d.BASE.multiply(c(m))}_setWindowSize(m){this._WINDOW_SIZE=m,f.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:m,y:O}=this.toAffine();if(!r.isValid(m)||!r.isValid(O))throw new Error("bad point: x or y not FE");let T=r.sqr(O),k=s(m);if(!r.eql(T,k))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:m}=this.toAffine();if(r.isOdd)return!r.isOdd(m);throw new Error("Field doesn't support isOdd")}equals(m){l(m);let{px:O,py:T,pz:k}=this,{px:F,py:K,pz:P}=m,q=r.eql(r.mul(O,P),r.mul(F,k)),D=r.eql(r.mul(T,P),r.mul(K,k));return q&&D}negate(){return new d(this.px,r.neg(this.py),this.pz)}double(){let{a:m,b:O}=e,T=r.mul(O,xo),{px:k,py:F,pz:K}=this,P=r.ZERO,q=r.ZERO,D=r.ZERO,z=r.mul(k,k),$=r.mul(F,F),se=r.mul(K,K),ee=r.mul(k,F);return ee=r.add(ee,ee),D=r.mul(k,K),D=r.add(D,D),P=r.mul(m,D),q=r.mul(T,se),q=r.add(P,q),P=r.sub($,q),q=r.add($,q),q=r.mul(P,q),P=r.mul(ee,P),D=r.mul(T,D),se=r.mul(m,se),ee=r.sub(z,se),ee=r.mul(m,ee),ee=r.add(ee,D),D=r.add(z,z),z=r.add(D,z),z=r.add(z,se),z=r.mul(z,ee),q=r.add(q,z),se=r.mul(F,K),se=r.add(se,se),z=r.mul(se,ee),P=r.sub(P,z),D=r.mul(se,$),D=r.add(D,D),D=r.add(D,D),new d(P,q,D)}add(m){l(m);let{px:O,py:T,pz:k}=this,{px:F,py:K,pz:P}=m,q=r.ZERO,D=r.ZERO,z=r.ZERO,$=e.a,se=r.mul(e.b,xo),ee=r.mul(O,F),de=r.mul(T,K),ce=r.mul(k,P),xe=r.add(O,T),Z=r.add(F,K);xe=r.mul(xe,Z),Z=r.add(ee,de),xe=r.sub(xe,Z),Z=r.add(O,k);let C=r.add(F,P);return Z=r.mul(Z,C),C=r.add(ee,ce),Z=r.sub(Z,C),C=r.add(T,k),q=r.add(K,P),C=r.mul(C,q),q=r.add(de,ce),C=r.sub(C,q),z=r.mul($,Z),q=r.mul(se,ce),z=r.add(q,z),q=r.sub(de,z),z=r.add(de,z),D=r.mul(q,z),de=r.add(ee,ee),de=r.add(de,ee),ce=r.mul($,ce),Z=r.mul(se,Z),de=r.add(de,ce),ce=r.sub(ee,ce),ce=r.mul($,ce),Z=r.add(Z,ce),ee=r.mul(de,Z),D=r.add(D,ee),ee=r.mul(C,Z),q=r.mul(xe,q),q=r.sub(q,ee),ee=r.mul(xe,de),z=r.mul(C,z),z=r.add(z,ee),new d(q,D,z)}subtract(m){return this.add(m.negate())}is0(){return this.equals(d.ZERO)}wNAF(m){return E.wNAFCached(this,f,m,O=>{let T=r.invertBatch(O.map(k=>k.pz));return O.map((k,F)=>k.toAffine(T[F])).map(d.fromAffine)})}multiplyUnsafe(m){let O=d.ZERO;if(m===ur)return O;if(a(m),m===Ze)return this;let{endo:T}=e;if(!T)return E.unsafeLadder(this,m);let{k1neg:k,k1:F,k2neg:K,k2:P}=T.splitScalar(m),q=O,D=O,z=this;for(;F>ur||P>ur;)F&Ze&&(q=q.add(z)),P&Ze&&(D=D.add(z)),z=z.double(),F>>=Ze,P>>=Ze;return k&&(q=q.negate()),K&&(D=D.negate()),D=new d(r.mul(D.px,T.beta),D.py,D.pz),q.add(D)}multiply(m){a(m);let O=m,T,k,{endo:F}=e;if(F){let{k1neg:K,k1:P,k2neg:q,k2:D}=F.splitScalar(O),{p:z,f:$}=this.wNAF(P),{p:se,f:ee}=this.wNAF(D);z=E.constTimeNegate(K,z),se=E.constTimeNegate(q,se),se=new d(r.mul(se.px,F.beta),se.py,se.pz),T=z.add(se),k=$.add(ee)}else{let{p:K,f:P}=this.wNAF(O);T=K,k=P}return d.normalizeZ([T,k])[0]}multiplyAndAddUnsafe(m,O,T){let k=d.BASE,F=(P,q)=>q===ur||q===Ze||!P.equals(k)?P.multiplyUnsafe(q):P.multiply(q),K=F(this,O).add(F(m,T));return K.is0()?void 0:K}toAffine(m){let{px:O,py:T,pz:k}=this,F=this.is0();m==null&&(m=F?r.ONE:r.inv(k));let K=r.mul(O,m),P=r.mul(T,m),q=r.mul(k,m);if(F)return{x:r.ZERO,y:r.ZERO};if(!r.eql(q,r.ONE))throw new Error("invZ was invalid");return{x:K,y:P}}isTorsionFree(){let{h:m,isTorsionFree:O}=e;if(m===Ze)return!0;if(O)return O(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:m,clearCofactor:O}=e;return m===Ze?this:O?O(d,this):this.multiplyUnsafe(e.h)}toRawBytes(m=!0){return this.assertValidity(),n(d,this,m)}toHex(m=!0){return ze.bytesToHex(this.toRawBytes(m))}}d.BASE=new d(e.Gx,e.Gy,r.ONE),d.ZERO=new d(r.ZERO,r.ONE,r.ZERO);let v=e.nBitLength,E=(0,uu.wNAF)(d,e.endo?Math.ceil(v/2):v);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:o}}function z1(t){let e=(0,uu.validateBasic)(t);return ze.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function D1(t){let e=z1(t),{Fp:r,n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function o(Z){return ur<Z&&Z<r.ORDER}function a(Z){return fi.mod(Z,n)}function c(Z){return fi.invert(Z,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:l,weierstrassEquation:d,isWithinCurveOrder:v}=s0({...e,toBytes(Z,C,X){let j=C.toAffine(),U=r.toBytes(j.x),W=ze.concatBytes;return X?W(Uint8Array.from([C.hasEvenY()?2:3]),U):W(Uint8Array.from([4]),U,r.toBytes(j.y))},fromBytes(Z){let C=Z.length,X=Z[0],j=Z.subarray(1);if(C===i&&(X===2||X===3)){let U=ze.bytesToNumberBE(j);if(!o(U))throw new Error("Point is not on curve");let W=d(U),L;try{L=r.sqrt(W)}catch(y){let fe=y instanceof Error?": "+y.message:"";throw new Error("Point is not on curve"+fe)}let ne=(L&Ze)===Ze;return(X&1)===1!==ne&&(L=r.neg(L)),{x:U,y:L}}else if(C===s&&X===4){let U=r.fromBytes(j.subarray(0,r.BYTES)),W=r.fromBytes(j.subarray(r.BYTES,2*r.BYTES));return{x:U,y:W}}else throw new Error(`Point of length ${C} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),E=Z=>ze.bytesToHex(ze.numberToBytesBE(Z,e.nByteLength));function g(Z){let C=n>>Ze;return Z>C}function m(Z){return g(Z)?a(-Z):Z}let O=(Z,C,X)=>ze.bytesToNumberBE(Z.slice(C,X));class T{constructor(C,X,j){this.r=C,this.s=X,this.recovery=j,this.assertValidity()}static fromCompact(C){let X=e.nByteLength;return C=(0,vr.ensureBytes)("compactSignature",C,X*2),new T(O(C,0,X),O(C,X,2*X))}static fromDER(C){let{r:X,s:j}=Ut.DER.toSig((0,vr.ensureBytes)("DER",C));return new T(X,j)}assertValidity(){if(!v(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!v(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(C){return new T(this.r,this.s,C)}recoverPublicKey(C){let{r:X,s:j,recovery:U}=this,W=D((0,vr.ensureBytes)("msgHash",C));if(U==null||![0,1,2,3].includes(U))throw new Error("recovery id invalid");let L=U===2||U===3?X+e.n:X;if(L>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let ne=U&1?"03":"02",N=f.fromHex(ne+E(L)),y=c(L),fe=a(-W*y),ue=a(j*y),ae=f.BASE.multiplyAndAddUnsafe(N,fe,ue);if(!ae)throw new Error("point at infinify");return ae.assertValidity(),ae}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new T(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return ze.hexToBytes(this.toDERHex())}toDERHex(){return Ut.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ze.hexToBytes(this.toCompactHex())}toCompactHex(){return E(this.r)+E(this.s)}}let k={isValidPrivateKey(Z){try{return l(Z),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let Z=fi.getMinHashLength(e.n);return fi.mapHashToField(e.randomBytes(Z),e.n)},precompute(Z=8,C=f.BASE){return C._setWindowSize(Z),C.multiply(BigInt(3)),C}};function F(Z,C=!0){return f.fromPrivateKey(Z).toRawBytes(C)}function K(Z){let C=ze.isBytes(Z),X=typeof Z=="string",j=(C||X)&&Z.length;return C?j===i||j===s:X?j===2*i||j===2*s:Z instanceof f}function P(Z,C,X=!0){if(K(Z))throw new Error("first arg must be private key");if(!K(C))throw new Error("second arg must be public key");return f.fromHex(C).multiply(l(Z)).toRawBytes(X)}let q=e.bits2int||function(Z){let C=ze.bytesToNumberBE(Z),X=Z.length*8-e.nBitLength;return X>0?C>>BigInt(X):C},D=e.bits2int_modN||function(Z){return a(q(Z))},z=ze.bitMask(e.nBitLength);function $(Z){if(typeof Z!="bigint")throw new Error("bigint expected");if(!(ur<=Z&&Z<z))throw new Error(`bigint expected < 2^${e.nBitLength}`);return ze.numberToBytesBE(Z,e.nByteLength)}function se(Z,C,X=ee){if(["recovered","canonical"].some(u=>u in X))throw new Error("sign() legacy options not supported");let{hash:j,randomBytes:U}=e,{lowS:W,prehash:L,extraEntropy:ne}=X;W==null&&(W=!0),Z=(0,vr.ensureBytes)("msgHash",Z),L&&(Z=(0,vr.ensureBytes)("prehashed msgHash",j(Z)));let N=D(Z),y=l(C),fe=[$(y),$(N)];if(ne!=null&&ne!==!1){let u=ne===!0?U(r.BYTES):ne;fe.push((0,vr.ensureBytes)("extraEntropy",u))}let ue=ze.concatBytes(...fe),ae=N;function te(u){let h=q(u);if(!v(h))return;let p=c(h),B=f.BASE.multiply(h).toAffine(),x=a(B.x);if(x===ur)return;let S=a(p*a(ae+x*y));if(S===ur)return;let I=(B.x===x?0:2)|Number(B.y&Ze),_=S;return W&&g(S)&&(_=m(S),I^=1),new T(x,_,I)}return{seed:ue,k2sig:te}}let ee={lowS:e.lowS,prehash:!1},de={lowS:e.lowS,prehash:!1};function ce(Z,C,X=ee){let{seed:j,k2sig:U}=se(Z,C,X),W=e;return ze.createHmacDrbg(W.hash.outputLen,W.nByteLength,W.hmac)(j,U)}f.BASE._setWindowSize(8);function xe(Z,C,X,j=de){let U=Z;if(C=(0,vr.ensureBytes)("msgHash",C),X=(0,vr.ensureBytes)("publicKey",X),"strict"in j)throw new Error("options.strict was renamed to lowS");let{lowS:W,prehash:L}=j,ne,N;try{if(typeof U=="string"||ze.isBytes(U))try{ne=T.fromDER(U)}catch(B){if(!(B instanceof Ut.DER.Err))throw B;ne=T.fromCompact(U)}else if(typeof U=="object"&&typeof U.r=="bigint"&&typeof U.s=="bigint"){let{r:B,s:x}=U;ne=new T(B,x)}else throw new Error("PARSE");N=f.fromHex(X)}catch(B){if(B.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(W&&ne.hasHighS())return!1;L&&(C=e.hash(C));let{r:y,s:fe}=ne,ue=D(C),ae=c(fe),te=a(ue*ae),u=a(y*ae),h=f.BASE.multiplyAndAddUnsafe(N,te,u)?.toAffine();return h?a(h.x)===y:!1}return{CURVE:e,getPublicKey:F,getSharedSecret:P,sign:ce,verify:xe,ProjectivePoint:f,Signature:T,utils:k}}function o0(t,e){let r=t.ORDER,n=ur;for(let g=r-Ze;g%nn===ur;g/=nn)n+=Ze;let i=n,s=nn<<i-Ze-Ze,o=s*nn,a=(r-Ze)/o,c=(a-Ze)/nn,f=o-Ze,l=s,d=t.pow(e,a),v=t.pow(e,(a+Ze)/nn),E=(g,m)=>{let O=d,T=t.pow(m,f),k=t.sqr(T);k=t.mul(k,m);let F=t.mul(g,k);F=t.pow(F,c),F=t.mul(F,T),T=t.mul(F,m),k=t.mul(F,g);let K=t.mul(k,T);F=t.pow(K,l);let P=t.eql(F,t.ONE);T=t.mul(k,v),F=t.mul(K,O),k=t.cmov(T,k,P),K=t.cmov(F,K,P);for(let q=i;q>Ze;q--){let D=q-nn;D=nn<<D-Ze;let z=t.pow(K,D),$=t.eql(z,t.ONE);T=t.mul(k,O),O=t.mul(O,O),z=t.mul(K,O),k=t.cmov(T,k,$),K=t.cmov(z,K,$)}return{isValid:P,value:k}};if(t.ORDER%i0===xo){let g=(t.ORDER-xo)/i0,m=t.sqrt(t.neg(e));E=(O,T)=>{let k=t.sqr(T),F=t.mul(O,T);k=t.mul(k,F);let K=t.pow(k,g);K=t.mul(K,F);let P=t.mul(K,m),q=t.mul(t.sqr(K),T),D=t.eql(q,O),z=t.cmov(P,K,D);return{isValid:D,value:z}}}return E}function Z1(t,e){if(fi.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=o0(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,a,c,f,l,d;i=t.sqr(n),i=t.mul(i,e.Z),s=t.sqr(i),s=t.add(s,i),o=t.add(s,t.ONE),o=t.mul(o,e.B),a=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),a=t.mul(a,e.A),s=t.sqr(o),f=t.sqr(a),c=t.mul(f,e.A),s=t.add(s,c),s=t.mul(s,o),f=t.mul(f,a),c=t.mul(f,e.B),s=t.add(s,c),l=t.mul(i,o);let{isValid:v,value:E}=r(s,f);d=t.mul(i,n),d=t.mul(d,E),l=t.cmov(l,o,v),d=t.cmov(d,E,v);let g=t.isOdd(n)===t.isOdd(d);return d=t.cmov(t.neg(d),d,g),l=t.div(l,a),{x:l,y:d}}}});var f0=J(du=>{"use strict";Object.defineProperty(du,"__esModule",{value:!0});du.bls=X1;var a0=$r(),$i=er(),c0=wo(),u0=fu(),lu=BigInt(2),vo=BigInt(3);function X1(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=(0,$i.bitLen)(t.params.x);function a(C){let{x:X,y:j}=C,U=X,W=j,L=n.ONE,ne=U,N=W,y=L,fe=[];for(let ue=o-2;ue>=0;ue--){let ae=n.sqr(N),te=n.sqr(y),u=n.multiplyByB(n.mul(te,vo)),h=n.mul(u,vo),p=n.sub(n.sub(n.sqr(n.add(N,y)),te),ae);if(fe.push([n.sub(u,ae),n.mul(n.sqr(ne),vo),n.neg(p)]),ne=n.div(n.mul(n.mul(n.sub(ae,h),ne),N),lu),N=n.sub(n.sqr(n.div(n.add(ae,h),lu)),n.mul(n.sqr(u),vo)),y=n.mul(ae,p),(0,$i.bitGet)(t.params.x,ue)){let B=n.sub(N,n.mul(W,y)),x=n.sub(ne,n.mul(U,y));fe.push([n.sub(n.mul(B,U),n.mul(x,W)),n.neg(B),x]);let S=n.sqr(x),I=n.mul(S,x),_=n.mul(S,ne),A=n.add(n.sub(I,n.mul(_,lu)),n.mul(n.sqr(B),y));ne=n.mul(x,A),N=n.sub(n.mul(n.sub(_,A),B),n.mul(I,N)),y=n.mul(y,I)}}return fe}function c(C,X){let{x:j}=t.params,U=X[0],W=X[1],L=s.ONE;for(let ne=0,N=o-2;N>=0;N--,ne++){let y=C[ne];if(L=s.multiplyBy014(L,y[0],n.mul(y[1],U),n.mul(y[2],W)),(0,$i.bitGet)(j,N)){ne+=1;let fe=C[ne];L=s.multiplyBy014(L,fe[0],n.mul(fe[1],U),n.mul(fe[2],W))}N!==0&&(L=s.sqr(L))}return s.conjugate(L)}let f={randomPrivateKey:()=>{let C=(0,a0.getMinHashLength)(r.ORDER);return(0,a0.mapHashToField)(t.randomBytes(C),r.ORDER)},calcPairingPrecomputes:a},l=(0,u0.weierstrassPoints)({n:r.ORDER,...t.G1}),d=Object.assign(l,(0,c0.createHasher)(l.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults}));function v(C){let X=C;return X._PPRECOMPUTES||(X._PPRECOMPUTES=a(C.toAffine())),X._PPRECOMPUTES}let E=(0,u0.weierstrassPoints)({n:r.ORDER,...t.G2}),g=Object.assign(E,(0,c0.createHasher)(E.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),{ShortSignature:m}=t.G1,{Signature:O}=t.G2;function T(C,X,j=!0){if(C.equals(d.ProjectivePoint.ZERO)||X.equals(g.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");C.assertValidity(),X.assertValidity();let U=C.toAffine(),W=c(v(X),[U.x,U.y]);return j?s.finalExponentiate(W):W}function k(C){return C instanceof d.ProjectivePoint?C:d.ProjectivePoint.fromHex(C)}function F(C,X){return C instanceof d.ProjectivePoint?C:d.hashToCurve((0,$i.ensureBytes)("point",C),X)}function K(C){return C instanceof g.ProjectivePoint?C:O.fromHex(C)}function P(C,X){return C instanceof g.ProjectivePoint?C:g.hashToCurve((0,$i.ensureBytes)("point",C),X)}function q(C){return d.ProjectivePoint.fromPrivateKey(C).toRawBytes(!0)}function D(C){return g.ProjectivePoint.fromPrivateKey(C).toRawBytes(!0)}function z(C,X,j){let U=P(C,j);U.assertValidity();let W=U.multiply(d.normPrivateKeyToScalar(X));return C instanceof g.ProjectivePoint?W:O.toRawBytes(W)}function $(C,X,j){let U=F(C,j);U.assertValidity();let W=U.multiply(d.normPrivateKeyToScalar(X));return C instanceof d.ProjectivePoint?W:m.toRawBytes(W)}function se(C,X,j,U){let W=k(j),L=P(X,U),ne=d.ProjectivePoint.BASE,N=K(C),y=T(W.negate(),L,!1),fe=T(ne,N,!1),ue=s.finalExponentiate(s.mul(fe,y));return s.eql(ue,s.ONE)}function ee(C,X,j,U){let W=K(j),L=F(X,U),ne=g.ProjectivePoint.BASE,N=k(C),y=T(L,W,!1),fe=T(N,ne.negate(),!1),ue=s.finalExponentiate(s.mul(fe,y));return s.eql(ue,s.ONE)}function de(C){if(!C.length)throw new Error("Expected non-empty array");let j=C.map(k).reduce((U,W)=>U.add(W),d.ProjectivePoint.ZERO);return C[0]instanceof d.ProjectivePoint?(j.assertValidity(),j):j.toRawBytes(!0)}function ce(C){if(!C.length)throw new Error("Expected non-empty array");let j=C.map(K).reduce((U,W)=>U.add(W),g.ProjectivePoint.ZERO);return C[0]instanceof g.ProjectivePoint?(j.assertValidity(),j):O.toRawBytes(j)}function xe(C){if(!C.length)throw new Error("Expected non-empty array");let j=C.map(k).reduce((U,W)=>U.add(W),d.ProjectivePoint.ZERO);return C[0]instanceof d.ProjectivePoint?(j.assertValidity(),j):m.toRawBytes(j)}function Z(C,X,j,U){if(!X.length)throw new Error("Expected non-empty messages array");if(j.length!==X.length)throw new Error("Pubkey count should equal msg count");let W=K(C),L=X.map(N=>P(N,U)),ne=j.map(k);try{let N=[];for(let ue of new Set(L)){let ae=L.reduce((te,u,h)=>u===ue?te.add(ne[h]):te,d.ProjectivePoint.ZERO);N.push(T(ae,ue,!1))}N.push(T(d.ProjectivePoint.BASE.negate(),W,!1));let y=N.reduce((ue,ae)=>s.mul(ue,ae),s.ONE),fe=s.finalExponentiate(y);return s.eql(fe,s.ONE)}catch{return!1}}return d.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:q,getPublicKeyForShortSignatures:D,sign:z,signShortSignature:$,verify:se,verifyBatch:Z,verifyShortSignature:ee,aggregatePublicKeys:de,aggregateSignatures:ce,aggregateShortSignatures:xe,millerLoop:c,pairing:T,G1:d,G2:g,Signature:O,ShortSignature:m,fields:{Fr:r,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{x:t.params.x,r:t.params.r,G1b:t.G1.b,G2b:t.G2.b},utils:f}}});var U0=J(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.bls12_381=void 0;var A0=xs(),J1=xn(),L1=f0(),on=$r(),ge=er(),O0=wo(),N0=fu(),st=BigInt(0),Nn=BigInt(1),Xe=BigInt(2),To=BigInt(3),Ki=BigInt(4),Q1=BigInt(8),e_=BigInt(16),yu=BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),G=on.Field(yu),l0=on.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),d0=({c0:t,c1:e},{c0:r,c1:n})=>({c0:G.add(t,r),c1:G.add(e,n)}),h0=({c0:t,c1:e},{c0:r,c1:n})=>({c0:G.sub(t,r),c1:G.sub(e,n)}),p0=({c0:t,c1:e},r)=>{if(typeof r=="bigint")return{c0:G.mul(t,r),c1:G.mul(e,r)};let{c0:n,c1:i}=r,s=G.mul(t,n),o=G.mul(e,i),a=G.sub(s,o),c=G.sub(G.mul(G.add(t,e),G.add(n,i)),G.add(s,o));return{c0:a,c1:c}},y0=({c0:t,c1:e})=>{let r=G.add(t,e),n=G.sub(t,e),i=G.add(t,t);return{c0:G.mul(r,n),c1:G.mul(i,e)}},Bo=yu*yu,b={ORDER:Bo,BITS:(0,ge.bitLen)(Bo),BYTES:Math.ceil((0,ge.bitLen)(Bo)/8),MASK:(0,ge.bitMask)((0,ge.bitLen)(Bo)),ZERO:{c0:G.ZERO,c1:G.ZERO},ONE:{c0:G.ONE,c1:G.ZERO},create:t=>t,isValid:({c0:t,c1:e})=>typeof t=="bigint"&&typeof e=="bigint",is0:({c0:t,c1:e})=>G.is0(t)&&G.is0(e),eql:({c0:t,c1:e},{c0:r,c1:n})=>G.eql(t,r)&&G.eql(e,n),neg:({c0:t,c1:e})=>({c0:G.neg(t),c1:G.neg(e)}),pow:(t,e)=>on.FpPow(b,t,e),invertBatch:t=>on.FpInvertBatch(b,t),add:d0,sub:h0,mul:p0,sqr:y0,addN:d0,subN:h0,mulN:p0,sqrN:y0,div:(t,e)=>b.mul(t,typeof e=="bigint"?G.inv(G.create(e)):b.inv(e)),inv:({c0:t,c1:e})=>{let r=G.inv(G.create(t*t+e*e));return{c0:G.mul(r,G.create(t)),c1:G.mul(r,G.create(-e))}},sqrt:t=>{if(b.eql(t,b.ZERO))return b.ZERO;let e=b.pow(t,(b.ORDER+Q1)/e_),r=b.div(b.sqr(e),t),n=r_,i=[n[0],n[2],n[4],n[6]].find(E=>b.eql(E,r));if(!i)throw new Error("No root");let s=n.indexOf(i),o=n[s/2];if(!o)throw new Error("Invalid root");let a=b.div(e,o),c=b.neg(a),{re:f,im:l}=b.reim(a),{re:d,im:v}=b.reim(c);return l>v||l===v&&f>d?a:c},isOdd:t=>{let{re:e,im:r}=b.reim(t),n=e%Xe,i=e===st,s=r%Xe;return BigInt(n||i&&s)==Nn},fromBytes(t){if(t.length!==b.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:G.fromBytes(t.subarray(0,G.BYTES)),c1:G.fromBytes(t.subarray(G.BYTES))}},toBytes:({c0:t,c1:e})=>(0,ge.concatBytes)(G.toBytes(t),G.toBytes(e)),cmov:({c0:t,c1:e},{c0:r,c1:n},i)=>({c0:G.cmov(t,r,i),c1:G.cmov(e,n,i)}),reim:({c0:t,c1:e})=>({re:t,im:e}),mulByNonresidue:({c0:t,c1:e})=>({c0:G.sub(t,e),c1:G.add(t,e)}),multiplyByB:({c0:t,c1:e})=>{let r=G.mul(t,Ki),n=G.mul(e,Ki);return{c0:G.sub(r,n),c1:G.add(r,n)}},fromBigTuple:t=>{if(t.length!==2)throw new Error("Invalid tuple");let e=t.map(r=>G.create(r));return{c0:e[0],c1:e[1]}},frobeniusMap:({c0:t,c1:e},r)=>({c0:t,c1:G.mul(e,t_[r%2])})},t_=[BigInt("0x1"),BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa")].map(t=>G.create(t)),sn=BigInt("0x6af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09"),r_=[[Nn,st],[sn,-sn],[st,Nn],[sn,sn],[-Nn,st],[-sn,sn],[st,-Nn],[-sn,-sn]].map(t=>b.fromBigTuple(t)),b0=({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s})=>({c0:b.add(t,n),c1:b.add(e,i),c2:b.add(r,s)}),g0=({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s})=>({c0:b.sub(t,n),c1:b.sub(e,i),c2:b.sub(r,s)}),m0=({c0:t,c1:e,c2:r},n)=>{if(typeof n=="bigint")return{c0:b.mul(t,n),c1:b.mul(e,n),c2:b.mul(r,n)};let{c0:i,c1:s,c2:o}=n,a=b.mul(t,i),c=b.mul(e,s),f=b.mul(r,o);return{c0:b.add(a,b.mulByNonresidue(b.sub(b.mul(b.add(e,r),b.add(s,o)),b.add(c,f)))),c1:b.add(b.sub(b.mul(b.add(t,e),b.add(i,s)),b.add(a,c)),b.mulByNonresidue(f)),c2:b.sub(b.add(c,b.mul(b.add(t,r),b.add(i,o))),b.add(a,f))}},_0=({c0:t,c1:e,c2:r})=>{let n=b.sqr(t),i=b.mul(b.mul(t,e),Xe),s=b.mul(b.mul(e,r),Xe),o=b.sqr(r);return{c0:b.add(b.mulByNonresidue(s),n),c1:b.add(b.mulByNonresidue(o),i),c2:b.sub(b.sub(b.add(b.add(i,b.sqr(b.add(b.sub(t,e),r))),s),n),o)}},re={ORDER:b.ORDER,BITS:3*b.BITS,BYTES:3*b.BYTES,MASK:(0,ge.bitMask)(3*b.BITS),ZERO:{c0:b.ZERO,c1:b.ZERO,c2:b.ZERO},ONE:{c0:b.ONE,c1:b.ZERO,c2:b.ZERO},create:t=>t,isValid:({c0:t,c1:e,c2:r})=>b.isValid(t)&&b.isValid(e)&&b.isValid(r),is0:({c0:t,c1:e,c2:r})=>b.is0(t)&&b.is0(e)&&b.is0(r),neg:({c0:t,c1:e,c2:r})=>({c0:b.neg(t),c1:b.neg(e),c2:b.neg(r)}),eql:({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s})=>b.eql(t,n)&&b.eql(e,i)&&b.eql(r,s),sqrt:()=>{throw new Error("Not implemented")},div:(t,e)=>re.mul(t,typeof e=="bigint"?G.inv(G.create(e)):re.inv(e)),pow:(t,e)=>on.FpPow(re,t,e),invertBatch:t=>on.FpInvertBatch(re,t),add:b0,sub:g0,mul:m0,sqr:_0,addN:b0,subN:g0,mulN:m0,sqrN:_0,inv:({c0:t,c1:e,c2:r})=>{let n=b.sub(b.sqr(t),b.mulByNonresidue(b.mul(r,e))),i=b.sub(b.mulByNonresidue(b.sqr(r)),b.mul(t,e)),s=b.sub(b.sqr(e),b.mul(t,r)),o=b.inv(b.add(b.mulByNonresidue(b.add(b.mul(r,i),b.mul(e,s))),b.mul(t,n)));return{c0:b.mul(o,n),c1:b.mul(o,i),c2:b.mul(o,s)}},fromBytes:t=>{if(t.length!==re.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:b.fromBytes(t.subarray(0,b.BYTES)),c1:b.fromBytes(t.subarray(b.BYTES,2*b.BYTES)),c2:b.fromBytes(t.subarray(2*b.BYTES))}},toBytes:({c0:t,c1:e,c2:r})=>(0,ge.concatBytes)(b.toBytes(t),b.toBytes(e),b.toBytes(r)),cmov:({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s},o)=>({c0:b.cmov(t,n,o),c1:b.cmov(e,i,o),c2:b.cmov(r,s,o)}),fromBigSix:t=>{if(!Array.isArray(t)||t.length!==6)throw new Error("Invalid Fp6 usage");return{c0:b.fromBigTuple(t.slice(0,2)),c1:b.fromBigTuple(t.slice(2,4)),c2:b.fromBigTuple(t.slice(4,6))}},frobeniusMap:({c0:t,c1:e,c2:r},n)=>({c0:b.frobeniusMap(t,n),c1:b.mul(b.frobeniusMap(e,n),n_[n%6]),c2:b.mul(b.frobeniusMap(r,n),i_[n%6])}),mulByNonresidue:({c0:t,c1:e,c2:r})=>({c0:b.mulByNonresidue(r),c1:t,c2:e}),multiplyBy1:({c0:t,c1:e,c2:r},n)=>({c0:b.mulByNonresidue(b.mul(r,n)),c1:b.mul(t,n),c2:b.mul(e,n)}),multiplyBy01({c0:t,c1:e,c2:r},n,i){let s=b.mul(t,n),o=b.mul(e,i);return{c0:b.add(b.mulByNonresidue(b.sub(b.mul(b.add(e,r),i),o)),s),c1:b.sub(b.sub(b.mul(b.add(n,i),b.add(t,e)),s),o),c2:b.add(b.sub(b.mul(b.add(t,r),n),s),o)}},multiplyByFp2:({c0:t,c1:e,c2:r},n)=>({c0:b.mul(t,n),c1:b.mul(e,n),c2:b.mul(r,n)})},n_=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x1")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe")]].map(t=>b.fromBigTuple(t)),i_=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad"),BigInt("0x0")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa"),BigInt("0x0")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff"),BigInt("0x0")]].map(t=>b.fromBigTuple(t)),bu=BigInt("0xd201000000010000"),s_=(0,ge.bitLen)(bu),w0=({c0:t,c1:e},{c0:r,c1:n})=>({c0:re.add(t,r),c1:re.add(e,n)}),E0=({c0:t,c1:e},{c0:r,c1:n})=>({c0:re.sub(t,r),c1:re.sub(e,n)}),x0=({c0:t,c1:e},r)=>{if(typeof r=="bigint")return{c0:re.mul(t,r),c1:re.mul(e,r)};let{c0:n,c1:i}=r,s=re.mul(t,n),o=re.mul(e,i);return{c0:re.add(s,re.mulByNonresidue(o)),c1:re.sub(re.mul(re.add(t,e),re.add(n,i)),re.add(s,o))}},v0=({c0:t,c1:e})=>{let r=re.mul(t,e);return{c0:re.sub(re.sub(re.mul(re.add(re.mulByNonresidue(e),t),re.add(t,e)),r),re.mulByNonresidue(r)),c1:re.add(r,r)}};function hu(t,e){let r=b.sqr(t),n=b.sqr(e);return{first:b.add(b.mulByNonresidue(n),r),second:b.sub(b.sub(b.sqr(b.add(t,e)),r),n)}}var ye={ORDER:b.ORDER,BITS:2*b.BITS,BYTES:2*b.BYTES,MASK:(0,ge.bitMask)(2*b.BITS),ZERO:{c0:re.ZERO,c1:re.ZERO},ONE:{c0:re.ONE,c1:re.ZERO},create:t=>t,isValid:({c0:t,c1:e})=>re.isValid(t)&&re.isValid(e),is0:({c0:t,c1:e})=>re.is0(t)&&re.is0(e),neg:({c0:t,c1:e})=>({c0:re.neg(t),c1:re.neg(e)}),eql:({c0:t,c1:e},{c0:r,c1:n})=>re.eql(t,r)&&re.eql(e,n),sqrt:()=>{throw new Error("Not implemented")},inv:({c0:t,c1:e})=>{let r=re.inv(re.sub(re.sqr(t),re.mulByNonresidue(re.sqr(e))));return{c0:re.mul(t,r),c1:re.neg(re.mul(e,r))}},div:(t,e)=>ye.mul(t,typeof e=="bigint"?G.inv(G.create(e)):ye.inv(e)),pow:(t,e)=>on.FpPow(ye,t,e),invertBatch:t=>on.FpInvertBatch(ye,t),add:w0,sub:E0,mul:x0,sqr:v0,addN:w0,subN:E0,mulN:x0,sqrN:v0,fromBytes:t=>{if(t.length!==ye.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:re.fromBytes(t.subarray(0,re.BYTES)),c1:re.fromBytes(t.subarray(re.BYTES))}},toBytes:({c0:t,c1:e})=>(0,ge.concatBytes)(re.toBytes(t),re.toBytes(e)),cmov:({c0:t,c1:e},{c0:r,c1:n},i)=>({c0:re.cmov(t,r,i),c1:re.cmov(e,n,i)}),fromBigTwelve:t=>({c0:re.fromBigSix(t.slice(0,6)),c1:re.fromBigSix(t.slice(6,12))}),frobeniusMap(t,e){let r=re.frobeniusMap(t.c0,e),{c0:n,c1:i,c2:s}=re.frobeniusMap(t.c1,e),o=o_[e%12];return{c0:r,c1:re.create({c0:b.mul(n,o),c1:b.mul(i,o),c2:b.mul(s,o)})}},multiplyBy014:({c0:t,c1:e},r,n,i)=>{let s=re.multiplyBy01(t,r,n),o=re.multiplyBy1(e,i);return{c0:re.add(re.mulByNonresidue(o),s),c1:re.sub(re.sub(re.multiplyBy01(re.add(e,t),r,b.add(n,i)),s),o)}},multiplyByFp2:({c0:t,c1:e},r)=>({c0:re.multiplyByFp2(t,r),c1:re.multiplyByFp2(e,r)}),conjugate:({c0:t,c1:e})=>({c0:t,c1:re.neg(e)}),_cyclotomicSquare:({c0:t,c1:e})=>{let{c0:r,c1:n,c2:i}=t,{c0:s,c1:o,c2:a}=e,{first:c,second:f}=hu(r,o),{first:l,second:d}=hu(s,i),{first:v,second:E}=hu(n,a),g=b.mulByNonresidue(E);return{c0:re.create({c0:b.add(b.mul(b.sub(c,r),Xe),c),c1:b.add(b.mul(b.sub(l,n),Xe),l),c2:b.add(b.mul(b.sub(v,i),Xe),v)}),c1:re.create({c0:b.add(b.mul(b.add(g,s),Xe),g),c1:b.add(b.mul(b.add(f,o),Xe),f),c2:b.add(b.mul(b.add(d,a),Xe),d)})}},_cyclotomicExp(t,e){let r=ye.ONE;for(let n=s_-1;n>=0;n--)r=ye._cyclotomicSquare(r),(0,ge.bitGet)(e,n)&&(r=ye.mul(r,t));return r},finalExponentiate:t=>{let e=bu,r=ye.div(ye.frobeniusMap(t,6),t),n=ye.mul(ye.frobeniusMap(r,2),r),i=ye.conjugate(ye._cyclotomicExp(n,e)),s=ye.mul(ye.conjugate(ye._cyclotomicSquare(n)),i),o=ye.conjugate(ye._cyclotomicExp(s,e)),a=ye.conjugate(ye._cyclotomicExp(o,e)),c=ye.mul(ye.conjugate(ye._cyclotomicExp(a,e)),ye._cyclotomicSquare(i)),f=ye.conjugate(ye._cyclotomicExp(c,e)),l=ye.frobeniusMap(ye.mul(i,a),2),d=ye.frobeniusMap(ye.mul(o,n),3),v=ye.frobeniusMap(ye.mul(c,ye.conjugate(n)),1),E=ye.mul(ye.mul(f,ye.conjugate(s)),n);return ye.mul(ye.mul(ye.mul(l,d),v),E)}},o_=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8"),BigInt("0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff"),BigInt("0x0")],[BigInt("0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2"),BigInt("0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995"),BigInt("0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116")],[BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa"),BigInt("0x0")],[BigInt("0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3"),BigInt("0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09"),BigInt("0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad"),BigInt("0x0")],[BigInt("0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116"),BigInt("0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995")]].map(t=>b.fromBigTuple(t)),a_=(0,O0.isogenyMap)(b,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(t=>t.map(e=>b.fromBigTuple(e.map(BigInt))))),c_=(0,O0.isogenyMap)(G,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(e=>BigInt(e)))),u_=(0,N0.mapToCurveSimpleSWU)(b,{A:b.create({c0:G.create(st),c1:G.create(BigInt(240))}),B:b.create({c0:G.create(BigInt(1012)),c1:G.create(BigInt(1012))}),Z:b.create({c0:G.create(BigInt(-2)),c1:G.create(BigInt(-1))})}),f_=(0,N0.mapToCurveSimpleSWU)(G,{A:G.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:G.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:G.create(BigInt(11))}),P0=re.create({c0:b.ZERO,c1:b.ONE,c2:b.ZERO}),R0=ye.create({c0:P0,c1:re.ZERO}),I0=ye.create({c0:re.ZERO,c1:P0}),[l_,d_]=ye.invertBatch([R0,I0]);function h_(t,e){let r=ye.mul(ye.frobeniusMap(ye.multiplyByFp2(l_,t),1),R0).c0.c0,n=ye.mul(ye.frobeniusMap(ye.multiplyByFp2(d_,e),1),I0).c0.c0;return[r,n]}function T0(t,e){let r=e.toAffine(),n=h_(r.x,r.y);return new t(n[0],n[1],b.ONE)}var p_=BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac");function y_(t,e){return[b.mul(t,p_),b.neg(e)]}function b_(t,e){let r=e.toAffine(),n=y_(r.x,r.y);return new t(n[0],n[1],b.ONE)}var pu=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:G.ORDER,m:2,k:128,expand:"xmd",hash:A0.sha256}),Ao=Gi(G.toBytes(st),{infinity:!0,compressed:!0});function So(t){t=t.slice();let e=t[0]&224,r=!!(e>>7&1),n=!!(e>>6&1),i=!!(e>>5&1);return t[0]&=31,{compressed:r,infinity:n,sort:i,value:t}}function Gi(t,e){if(t[0]&224)throw new Error("setMask: non-empty mask");return e.compressed&&(t[0]|=128),e.infinity&&(t[0]|=64),e.sort&&(t[0]|=32),t}function B0(t){t.assertValidity();let e=t.equals(it.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return Ao.slice();let i=G.ORDER,s=!!(n*Xe/i);return Gi((0,ge.numberToBytesBE)(r,G.BYTES),{compressed:!0,sort:s})}function S0(t){t.assertValidity();let e=G.BYTES;if(t.equals(it.bls12_381.G2.ProjectivePoint.ZERO))return(0,ge.concatBytes)(Ao,(0,ge.numberToBytesBE)(st,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=b.reim(r),{re:o,im:a}=b.reim(n),f=!!((a>st?a*Xe:o*Xe)/G.ORDER&Nn),l=i;return(0,ge.concatBytes)(Gi((0,ge.numberToBytesBE)(s,e),{sort:f,compressed:!0}),(0,ge.numberToBytesBE)(l,e))}it.bls12_381=(0,L1.bls)({fields:{Fp:G,Fp2:b,Fp6:re,Fp12:ye,Fr:l0},G1:{Fp:G,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:G.ZERO,b:Ki,htfDefaults:{...pu,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(t,e)=>{let r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new t(G.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(it.bls12_381.params.x).negate().multiplyUnsafe(it.bls12_381.params.x).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(it.bls12_381.params.x).add(e),mapToCurve:t=>{let{x:e,y:r}=f_(G.create(t[0]));return c_(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=So(t);if(i.length===48&&e){let s=G.ORDER,o=(0,ge.bytesToNumberBE)(i),a=G.create(o&G.MASK);if(r){if(a!==st)throw new Error("G1: non-empty compressed point at infinity");return{x:st,y:st}}let c=G.add(G.pow(a,To),G.create(it.bls12_381.params.G1b)),f=G.sqrt(c);if(!f)throw new Error("Invalid compressed G1 point");return f*Xe/s!==BigInt(n)&&(f=G.neg(f)),{x:G.create(a),y:G.create(f)}}else if(i.length===96&&!e){let s=(0,ge.bytesToNumberBE)(i.subarray(0,G.BYTES)),o=(0,ge.bytesToNumberBE)(i.subarray(G.BYTES));if(r){if(s!==st||o!==st)throw new Error("G1: non-empty point at infinity");return it.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:G.create(s),y:G.create(o)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(t,e,r)=>{let n=e.equals(t.ZERO),{x:i,y:s}=e.toAffine();if(r){if(n)return Ao.slice();let o=G.ORDER,a=!!(s*Xe/o);return Gi((0,ge.numberToBytesBE)(i,G.BYTES),{compressed:!0,sort:a})}else return n?(0,ge.concatBytes)(new Uint8Array([64]),new Uint8Array(2*G.BYTES-1)):(0,ge.concatBytes)((0,ge.numberToBytesBE)(i,G.BYTES),(0,ge.numberToBytesBE)(s,G.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=So((0,ge.ensureBytes)("signatureHex",t,48)),i=G.ORDER,s=(0,ge.bytesToNumberBE)(n);if(e)return it.bls12_381.G1.ProjectivePoint.ZERO;let o=G.create(s&G.MASK),a=G.add(G.pow(o,To),G.create(it.bls12_381.params.G1b)),c=G.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let f=BigInt(r);c*Xe/i!==f&&(c=G.neg(c));let l=it.bls12_381.G1.ProjectivePoint.fromAffine({x:o,y:c});return l.assertValidity(),l},toRawBytes(t){return B0(t)},toHex(t){return(0,ge.bytesToHex)(B0(t))}}},G2:{Fp:b,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:b.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:b.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:b.ZERO,b:b.fromBigTuple([Ki,Ki]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...pu},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=u_(b.fromBigTuple(t));return a_(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(it.bls12_381.params.x).negate().equals(T0(t,e)),clearCofactor:(t,e)=>{let r=it.bls12_381.params.x,n=e.multiplyUnsafe(r).negate(),i=T0(t,e),s=e.double();return s=b_(t,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),s=s.add(i),s=s.subtract(n),s.subtract(e)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=So(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=G.BYTES,o=(a,c,f)=>(0,ge.bytesToNumberBE)(a.slice(c,f));if(i.length===96&&e){let a=it.bls12_381.params.G2b,c=G.ORDER;if(r){if(i.reduce((m,O)=>m!==0?O+1:O,0)>0)throw new Error("Invalid compressed G2 point");return{x:b.ZERO,y:b.ZERO}}let f=o(i,0,s),l=o(i,s,2*s),d=b.create({c0:G.create(l),c1:G.create(f)}),v=b.add(b.pow(d,To),a),E=b.sqrt(v),g=E.c1===st?E.c0*Xe/c:E.c1*Xe/c?Nn:st;return E=n&&g>0?E:b.neg(E),{x:d,y:E}}else if(i.length===192&&!e){if(r){if(i.reduce((d,v)=>d!==0?v+1:v,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:b.ZERO,y:b.ZERO}}let a=o(i,0,s),c=o(i,s,2*s),f=o(i,2*s,3*s),l=o(i,3*s,4*s);return{x:b.fromBigTuple([c,a]),y:b.fromBigTuple([l,f])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(t,e,r)=>{let{BYTES:n,ORDER:i}=G,s=e.equals(t.ZERO),{x:o,y:a}=e.toAffine();if(r){if(s)return(0,ge.concatBytes)(Ao,(0,ge.numberToBytesBE)(st,n));let c=!!(a.c1===st?a.c0*Xe/i:a.c1*Xe/i);return(0,ge.concatBytes)(Gi((0,ge.numberToBytesBE)(o.c1,n),{compressed:!0,sort:c}),(0,ge.numberToBytesBE)(o.c0,n))}else{if(s)return(0,ge.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:f}=b.reim(o),{re:l,im:d}=b.reim(a);return(0,ge.concatBytes)((0,ge.numberToBytesBE)(f,n),(0,ge.numberToBytesBE)(c,n),(0,ge.numberToBytesBE)(d,n),(0,ge.numberToBytesBE)(l,n))}},Signature:{fromHex(t){let{infinity:e,sort:r,value:n}=So((0,ge.ensureBytes)("signatureHex",t)),i=G.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=(0,ge.bytesToNumberBE)(n.slice(0,s)),a=(0,ge.bytesToNumberBE)(n.slice(s));if(e)return it.bls12_381.G2.ProjectivePoint.ZERO;let c=G.create(o&G.MASK),f=G.create(a),l=b.create({c0:f,c1:c}),d=b.add(b.pow(l,To),it.bls12_381.params.G2b),v=b.sqrt(d);if(!v)throw new Error("Failed to find a square root");let{re:E,im:g}=b.reim(v),m=BigInt(r),O=g>st&&g*Xe/i!==m,T=g===st&&E*Xe/i!==m;(O||T)&&(v=b.neg(v));let k=it.bls12_381.G2.ProjectivePoint.fromAffine({x:l,y:v});return k.assertValidity(),k},toRawBytes(t){return S0(t)},toHex(t){return(0,ge.bytesToHex)(S0(t))}}},params:{x:bu,r:l0.ORDER},htfDefaults:pu,hash:A0.sha256,randomBytes:J1.randomBytes})});var mu=J(Yi=>{"use strict";Object.defineProperty(Yi,"__esModule",{value:!0});Yi.blsVerify=Yi.verify=void 0;var g_=U0(),gu=Gt();function m_(t,e,r){let n=typeof t=="string"?t:(0,gu.toHex)(t),i=typeof e=="string"?e:(0,gu.toHex)(e),s=typeof r=="string"?r:(0,gu.toHex)(r);return g_.bls12_381.verifyShortSignature(i,s,n)}Yi.blsVerify=m_});var Oo=J(Pn=>{"use strict";Object.defineProperty(Pn,"__esModule",{value:!0});Pn.decodeTime=Pn.decodeLeb128=void 0;var F0=oi(),__=t=>(0,F0.lebDecode)(new F0.PipeArrayBuffer(t));Pn.decodeLeb128=__;var w_=t=>{let e=(0,Pn.decodeLeb128)(t);return new Date(Number(e)/1e6)};Pn.decodeTime=w_});var Xi=J(Ne=>{"use strict";var E_=Ne&&Ne.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),x_=Ne&&Ne.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),M0=Ne&&Ne.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&E_(e,t,r);return x_(e,t),e};Object.defineProperty(Ne,"__esModule",{value:!0});Ne.check_canister_ranges=Ne.find_label=Ne.flatten_forks=Ne.lookup_path=Ne.LookupStatus=Ne.reconstruct=Ne.lookupResultToBuffer=Ne.Certificate=Ne.hashTreeToString=Ne.NodeType=Ne.CertificateVerificationError=void 0;var C0=M0(Vi()),v_=Qn(),No=qi(),fr=Gt(),_u=Rt(),T_=M0(mu()),B_=Oo(),Kr=class extends v_.AgentError{constructor(e){super(`Invalid certificate: ${e}`)}};Ne.CertificateVerificationError=Kr;var xt;(function(t){t[t.Empty=0]="Empty",t[t.Fork=1]="Fork",t[t.Labeled=2]="Labeled",t[t.Leaf=3]="Leaf",t[t.Pruned=4]="Pruned"})(xt=Ne.NodeType||(Ne.NodeType={}));function Po(t){let e=n=>n.split(`
15
+ `)}return c.encodeValue(f)}));return(0,Oe.concat)(n,i,s,o,a)}K.encode=mg;function _g(t,e){let r=new Oe.PipeArrayBuffer(e);if(e.byteLength<Ys.length)throw new Error("Message length smaller than magic number");let n=(0,ie.safeRead)(r,Ys.length),i=new TextDecoder().decode(n);if(i!==Ys)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(w){let u=[],g=Number((0,ie.lebDecode)(w));for(let N=0;N<g;N++){let V=Number((0,ie.slebDecode)(w));switch(V){case-18:case-19:{let W=Number((0,ie.slebDecode)(w));u.push([V,W]);break}case-20:case-21:{let W=[],T=Number((0,ie.lebDecode)(w)),C;for(;T--;){let z=Number((0,ie.lebDecode)(w));if(z>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof C=="number"&&C>=z)throw new Error("field id collision or not sorted");C=z;let D=Number((0,ie.slebDecode)(w));W.push([z,D])}u.push([V,W]);break}case-22:{let W=[],T=Number((0,ie.lebDecode)(w));for(;T--;)W.push(Number((0,ie.slebDecode)(w)));let C=[],z=Number((0,ie.lebDecode)(w));for(;z--;)C.push(Number((0,ie.slebDecode)(w)));let D=[],G=Number((0,ie.lebDecode)(w));for(;G--;)switch(Number((0,ie.lebDecode)(w))){case 1:{D.push("query");break}case 2:{D.push("oneway");break}case 3:{D.push("composite_query");break}default:throw new Error("unknown annotation")}u.push([V,[W,C,D]]);break}case-23:{let W=Number((0,ie.lebDecode)(w)),T=[];for(;W--;){let C=Number((0,ie.lebDecode)(w)),z=new TextDecoder().decode((0,ie.safeRead)(w,C)),D=(0,ie.slebDecode)(w);T.push([z,D])}u.push([V,T]);break}default:throw new Error("Illegal op_code: "+V)}}let U=[],F=Number((0,ie.lebDecode)(w));for(let N=0;N<F;N++)U.push(Number((0,ie.slebDecode)(w)));return[u,U]}let[o,a]=s(r);if(a.length<t.length)throw new Error("Wrong number of return values");let c=o.map(w=>rd());function f(w){if(w<-24)throw new Error("future value not supported");if(w<0)switch(w){case-1:return K.Null;case-2:return K.Bool;case-3:return K.Nat;case-4:return K.Int;case-5:return K.Nat8;case-6:return K.Nat16;case-7:return K.Nat32;case-8:return K.Nat64;case-9:return K.Int8;case-10:return K.Int16;case-11:return K.Int32;case-12:return K.Int64;case-13:return K.Float32;case-14:return K.Float64;case-15:return K.Text;case-16:return K.Reserved;case-17:return K.Empty;case-24:return K.Principal;default:throw new Error("Illegal op_code: "+w)}if(w>=o.length)throw new Error("type index out of range");return c[w]}function d(w){switch(w[0]){case-19:{let u=f(w[1]);return Lf(u)}case-18:{let u=f(w[1]);return Qf(u)}case-20:{let u={};for(let[F,N]of w[1]){let V=`_${F}_`;u[V]=f(N)}let g=ed(u),U=g.tryAsTuple();return Array.isArray(U)?Jf(...U):g}case-21:{let u={};for(let[g,U]of w[1]){let F=`_${g}_`;u[F]=f(U)}return td(u)}case-22:{let[u,g,U]=w[1];return nd(u.map(F=>f(F)),g.map(F=>f(F)),U)}case-23:{let u={},g=w[1];for(let[U,F]of g){let N=f(F);if(N instanceof rn&&(N=N.getType()),!(N instanceof ki))throw new Error("Illegal service definition: services can only contain functions");u[U]=N}return id(u)}default:throw new Error("Illegal op_code: "+w[0])}}o.forEach((w,u)=>{if(w[0]===-22){let g=d(w);c[u].fill(g)}}),o.forEach((w,u)=>{if(w[0]!==-22){let g=d(w);c[u].fill(g)}});let h=a.map(w=>f(w)),B=t.map((w,u)=>w.decodeValue(r,h[u]));for(let w=t.length;w<h.length;w++)h[w].decodeValue(r,h[w]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return B}K.decode=_g;K.Empty=new Ws;K.Reserved=new ai;K.Unknown=new zs;K.Bool=new Ds;K.Null=new Zs;K.Text=new Xs;K.Int=new Js;K.Nat=new Ls;K.Float32=new qi(32);K.Float64=new qi(64);K.Int8=new Gr(8);K.Int16=new Gr(16);K.Int32=new Gr(32);K.Int64=new Gr(64);K.Nat8=new vr(8);K.Nat16=new vr(16);K.Nat32=new vr(32);K.Nat64=new vr(64);K.Principal=new ro;function Jf(...t){return new eo(t)}K.Tuple=Jf;function Lf(t){return new Qs(t)}K.Vec=Lf;function Qf(t){return new ci(t)}K.Opt=Qf;function ed(t){return new ji(t)}K.Record=ed;function td(t){return new to(t)}K.Variant=td;function rd(){return new rn}K.Rec=rd;function nd(t,e,r=[]){return new ki(t,e,r)}K.Func=nd;function id(t){return new no(t)}K.Service=id});var Sc=L(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});vt.VecForm=vt.OptionForm=vt.VariantForm=vt.TupleForm=vt.RecordForm=vt.InputForm=vt.InputBox=void 0;var _c=class{constructor(e,r){this.idl=e,this.ui=r,this.label=null,this.value=void 0;let n=document.createElement("span");n.className="status",this.status=n,r.input&&(r.input.addEventListener("blur",()=>{r.input.value!==""&&this.parse()}),r.input.addEventListener("input",()=>{n.style.display="none",r.input.classList.remove("reject")}))}isRejected(){return this.value===void 0}parse(e={}){if(this.ui.form){let r=this.ui.form.parse(e);return this.value=r,r}if(this.ui.input){let r=this.ui.input;try{let n=this.ui.parse(this.idl,e,r.value);if(!this.idl.covariant(n))throw new Error(`${r.value} is not of type ${this.idl.display()}`);return this.status.style.display="none",this.value=n,n}catch(n){r.classList.add("reject"),this.status.style.display="block",this.status.innerHTML="InputError: "+n.message,this.value=void 0;return}}return null}render(e){let r=document.createElement("span");if(this.label){let n=document.createElement("label");n.innerText=this.label,r.appendChild(n)}this.ui.input&&(r.appendChild(this.ui.input),r.appendChild(this.status)),this.ui.form&&this.ui.form.render(r),e.appendChild(r)}};vt.InputBox=_c;var nn=class{constructor(e){this.ui=e,this.form=[]}renderForm(e){this.ui.container?(this.form.forEach(r=>r.render(this.ui.container)),e.appendChild(this.ui.container)):this.form.forEach(r=>r.render(e))}render(e){if(this.ui.open&&this.ui.event){e.appendChild(this.ui.open);let r=this;r.ui.open.addEventListener(r.ui.event,()=>{if(r.ui.container)r.ui.container.innerHTML="";else{let n=r.ui.open.nextElementSibling;n&&n.parentNode.removeChild(n)}r.generateForm(),r.renderForm(e)})}else this.generateForm(),this.renderForm(e)}};vt.InputForm=nn;var wc=class extends nn{constructor(e,r){super(r),this.fields=e,this.ui=r}generateForm(){this.form=this.fields.map(([e,r])=>{let n=this.ui.render(r);return this.ui.labelMap&&this.ui.labelMap.hasOwnProperty(e)?n.label=this.ui.labelMap[e]+" ":n.label=e+" ",n})}parse(e){let r={};if(this.fields.forEach(([n,i],s)=>{let o=this.form[s].parse(e);r[n]=o}),!this.form.some(n=>n.isRejected()))return r}};vt.RecordForm=wc;var Ec=class extends nn{constructor(e,r){super(r),this.components=e,this.ui=r}generateForm(){this.form=this.components.map(e=>this.ui.render(e))}parse(e){let r=[];if(this.components.forEach((n,i)=>{let s=this.form[i].parse(e);r.push(s)}),!this.form.some(n=>n.isRejected()))return r}};vt.TupleForm=Ec;var xc=class extends nn{constructor(e,r){super(r),this.fields=e,this.ui=r}generateForm(){let e=this.ui.open.selectedIndex,[r,n]=this.fields[e],i=this.ui.render(n);this.form=[i]}parse(e){let r=this.ui.open,n=r.options[r.selectedIndex].value,i=this.form[0].parse(e);if(i===void 0)return;let s={};return s[n]=i,s}};vt.VariantForm=xc;var vc=class extends nn{constructor(e,r){super(r),this.ty=e,this.ui=r}generateForm(){if(this.ui.open.checked){let e=this.ui.render(this.ty);this.form=[e]}else this.form=[]}parse(e){if(this.form.length===0)return[];{let r=this.form[0].parse(e);return r===void 0?void 0:[r]}}};vt.OptionForm=vc;var Tc=class extends nn{constructor(e,r){super(r),this.ty=e,this.ui=r}generateForm(){let e=+this.ui.open.value;this.form=[];for(let r=0;r<e;r++){let n=this.ui.render(this.ty);this.form.push(n)}}parse(e){let r=this.form.map(n=>n.parse(e));if(!this.form.some(n=>n.isRejected()))return r}};vt.VecForm=Tc});var od=L(Ee=>{"use strict";var wg=Ee&&Ee.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Eg=Ee&&Ee.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),sd=Ee&&Ee.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&wg(e,t,r);return Eg(e,t),e};Object.defineProperty(Ee,"__esModule",{value:!0});Ee.renderValue=Ee.renderInput=Ee.Render=Ee.vecForm=Ee.optForm=Ee.variantForm=Ee.tupleForm=Ee.recordForm=Ee.inputBox=void 0;var so=sd(mc()),Bc=Nt(),ui=sd(Sc()),xg={parse:Ng},Vi={render:Rc},vg=(t,e)=>new ui.InputBox(t,Object.assign(Object.assign({},xg),e));Ee.inputBox=vg;var Tg=(t,e)=>new ui.RecordForm(t,Object.assign(Object.assign({},Vi),e));Ee.recordForm=Tg;var Sg=(t,e)=>new ui.TupleForm(t,Object.assign(Object.assign({},Vi),e));Ee.tupleForm=Sg;var Bg=(t,e)=>new ui.VariantForm(t,Object.assign(Object.assign({},Vi),e));Ee.variantForm=Bg;var Ag=(t,e)=>new ui.OptionForm(t,Object.assign(Object.assign({},Vi),e));Ee.optForm=Ag;var Og=(t,e)=>new ui.VecForm(t,Object.assign(Object.assign({},Vi),e));Ee.vecForm=Og;var io=class extends so.Visitor{visitType(e,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=e.display(),(0,Ee.inputBox)(e,{input:n})}visitNull(e,r){return(0,Ee.inputBox)(e,{})}visitRecord(e,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.recordForm)(r,i);return(0,Ee.inputBox)(e,{form:s})}visitTuple(e,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.tupleForm)(r,i);return(0,Ee.inputBox)(e,{form:s})}visitVariant(e,r,n){let i=document.createElement("select");for(let[a,c]of r){let f=new Option(a);i.add(f)}i.selectedIndex=-1,i.classList.add("open");let s={open:i,event:"change"},o=(0,Ee.variantForm)(r,s);return(0,Ee.inputBox)(e,{form:o})}visitOpt(e,r,n){let i=document.createElement("input");i.type="checkbox",i.classList.add("open");let s=(0,Ee.optForm)(r,{open:i,event:"change"});return(0,Ee.inputBox)(e,{form:s})}visitVec(e,r,n){let i=document.createElement("input");i.type="number",i.min="0",i.max="100",i.style.width="8rem",i.placeholder="len",i.classList.add("open");let s=document.createElement("div");s.classList.add("popup-form");let o=(0,Ee.vecForm)(r,{open:i,event:"change",container:s});return(0,Ee.inputBox)(e,{form:o})}visitRec(e,r,n){return Rc(r)}};Ee.Render=io;var Ac=class extends so.Visitor{visitNull(e,r){return null}visitBool(e,r){if(r==="true")return!0;if(r==="false")return!1;throw new Error(`Cannot parse ${r} as boolean`)}visitText(e,r){return r}visitFloat(e,r){return parseFloat(r)}visitFixedInt(e,r){return e._bits<=32?parseInt(r,10):BigInt(r)}visitFixedNat(e,r){return e._bits<=32?parseInt(r,10):BigInt(r)}visitNumber(e,r){return BigInt(r)}visitPrincipal(e,r){return Bc.Principal.fromText(r)}visitService(e,r){return Bc.Principal.fromText(r)}visitFunc(e,r){let n=r.split(".",2);return[Bc.Principal.fromText(n[0]),n[1]]}},Oc=class extends so.Visitor{visitNull(e,r){return null}visitBool(e,r){return Math.random()<.5}visitText(e,r){return Math.random().toString(36).substring(6)}visitFloat(e,r){return Math.random()}visitInt(e,r){return BigInt(this.generateNumber(!0))}visitNat(e,r){return BigInt(this.generateNumber(!1))}visitFixedInt(e,r){let n=this.generateNumber(!0);return e._bits<=32?n:BigInt(r)}visitFixedNat(e,r){let n=this.generateNumber(!1);return e._bits<=32?n:BigInt(r)}generateNumber(e){let r=Math.floor(Math.random()*100);return e&&Math.random()<.5?-r:r}};function Ng(t,e,r){return e.random&&r===""?t.accept(new Oc,r):t.accept(new Ac,r)}function Rc(t){return t.accept(new io,null)}Ee.renderInput=Rc;function Nn(t,e,r){return t.accept(new Nc,{input:e,value:r})}Ee.renderValue=Nn;var Nc=class extends so.Visitor{visitType(e,r){r.input.ui.input.value=e.valueToString(r.value)}visitNull(e,r){}visitText(e,r){r.input.ui.input.value=r.value}visitRec(e,r,n){Nn(r,n.input,n.value)}visitOpt(e,r,n){if(n.value.length!==0){let i=n.input.ui.form,s=i.ui.open;s.checked=!0,s.dispatchEvent(new Event(i.ui.event)),Nn(r,i.form[0],n.value[0])}}visitRecord(e,r,n){let i=n.input.ui.form;r.forEach(([s,o],a)=>{Nn(o,i.form[a],n.value[s])})}visitTuple(e,r,n){let i=n.input.ui.form;r.forEach((s,o)=>{Nn(s,i.form[o],n.value[o])})}visitVariant(e,r,n){let i=n.input.ui.form,s=Object.entries(n.value)[0];r.forEach(([o,a],c)=>{if(o===s[0]){let f=i.ui.open;f.selectedIndex=c,f.dispatchEvent(new Event(i.ui.event)),Nn(a,i.form[0],s[1])}})}visitVec(e,r,n){let i=n.input.ui.form,s=n.value.length,o=i.ui.open;o.value=s,o.dispatchEvent(new Event(i.ui.event)),n.value.forEach((a,c)=>{Nn(r,i.form[c],a)})}}});var cd=L(ad=>{"use strict";Object.defineProperty(ad,"__esModule",{value:!0})});var fi=L(ft=>{"use strict";var ud=ft&&ft.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Rg=ft&&ft.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),li=ft&&ft.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&ud(e,t,r)},Pg=ft&&ft.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&ud(e,t,r);return Rg(e,t),e};Object.defineProperty(ft,"__esModule",{value:!0});ft.IDL=void 0;li(od(),ft);li(Sc(),ft);ft.IDL=Pg(mc());li(fc(),ft);li(hc(),ft);li($s(),ft);li(cd(),ft)});var Hi=L((ld,oo)=>{(function(t){"use strict";var e,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",a=1e14,c=14,f=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],h=1e7,B=1e9;function w(T){var C,z,D,G=P.prototype={constructor:P,toString:null,valueOf:null},ne=new P(1),Q=20,le=4,E=-7,_=21,m=-1e7,x=1e7,j=!1,H=1,X=0,oe={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},ae="0123456789abcdefghijklmnopqrstuvwxyz",Y=!0;function P(l,y){var b,R,A,O,q,v,I,k,M=this;if(!(M instanceof P))return new P(l,y);if(y==null){if(l&&l._isBigNumber===!0){M.s=l.s,!l.c||l.e>x?M.c=M.e=null:l.e<m?M.c=[M.e=0]:(M.e=l.e,M.c=l.c.slice());return}if((v=typeof l=="number")&&l*0==0){if(M.s=1/l<0?(l=-l,-1):1,l===~~l){for(O=0,q=l;q>=10;q/=10,O++);O>x?M.c=M.e=null:(M.e=O,M.c=[l]);return}k=String(l)}else{if(!r.test(k=String(l)))return D(M,k,v);M.s=k.charCodeAt(0)==45?(k=k.slice(1),-1):1}(O=k.indexOf("."))>-1&&(k=k.replace(".","")),(q=k.search(/e/i))>0?(O<0&&(O=q),O+=+k.slice(q+1),k=k.substring(0,q)):O<0&&(O=k.length)}else{if(F(y,2,ae.length,"Base"),y==10&&Y)return M=new P(l),de(M,Q+M.e+1,le);if(k=String(l),v=typeof l=="number"){if(l*0!=0)return D(M,k,v,y);if(M.s=1/l<0?(k=k.slice(1),-1):1,P.DEBUG&&k.replace(/^0\.0*|\./,"").length>15)throw Error(o+l)}else M.s=k.charCodeAt(0)===45?(k=k.slice(1),-1):1;for(b=ae.slice(0,y),O=q=0,I=k.length;q<I;q++)if(b.indexOf(R=k.charAt(q))<0){if(R=="."){if(q>O){O=I;continue}}else if(!A&&(k==k.toUpperCase()&&(k=k.toLowerCase())||k==k.toLowerCase()&&(k=k.toUpperCase()))){A=!0,q=-1,O=0;continue}return D(M,String(l),v,y)}v=!1,k=z(k,y,10,M.s),(O=k.indexOf("."))>-1?k=k.replace(".",""):O=k.length}for(q=0;k.charCodeAt(q)===48;q++);for(I=k.length;k.charCodeAt(--I)===48;);if(k=k.slice(q,++I)){if(I-=q,v&&P.DEBUG&&I>15&&(l>f||l!==i(l)))throw Error(o+M.s*l);if((O=O-q-1)>x)M.c=M.e=null;else if(O<m)M.c=[M.e=0];else{if(M.e=O,M.c=[],q=(O+1)%c,O<0&&(q+=c),q<I){for(q&&M.c.push(+k.slice(0,q)),I-=c;q<I;)M.c.push(+k.slice(q,q+=c));q=c-(k=k.slice(q)).length}else q-=I;for(;q--;k+="0");M.c.push(+k)}}else M.c=[M.e=0]}P.clone=w,P.ROUND_UP=0,P.ROUND_DOWN=1,P.ROUND_CEIL=2,P.ROUND_FLOOR=3,P.ROUND_HALF_UP=4,P.ROUND_HALF_DOWN=5,P.ROUND_HALF_EVEN=6,P.ROUND_HALF_CEIL=7,P.ROUND_HALF_FLOOR=8,P.EUCLID=9,P.config=P.set=function(l){var y,b;if(l!=null)if(typeof l=="object"){if(l.hasOwnProperty(y="DECIMAL_PLACES")&&(b=l[y],F(b,0,B,y),Q=b),l.hasOwnProperty(y="ROUNDING_MODE")&&(b=l[y],F(b,0,8,y),le=b),l.hasOwnProperty(y="EXPONENTIAL_AT")&&(b=l[y],b&&b.pop?(F(b[0],-B,0,y),F(b[1],0,B,y),E=b[0],_=b[1]):(F(b,-B,B,y),E=-(_=b<0?-b:b))),l.hasOwnProperty(y="RANGE"))if(b=l[y],b&&b.pop)F(b[0],-B,-1,y),F(b[1],1,B,y),m=b[0],x=b[1];else if(F(b,-B,B,y),b)m=-(x=b<0?-b:b);else throw Error(s+y+" cannot be zero: "+b);if(l.hasOwnProperty(y="CRYPTO"))if(b=l[y],b===!!b)if(b)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))j=b;else throw j=!b,Error(s+"crypto unavailable");else j=b;else throw Error(s+y+" not true or false: "+b);if(l.hasOwnProperty(y="MODULO_MODE")&&(b=l[y],F(b,0,9,y),H=b),l.hasOwnProperty(y="POW_PRECISION")&&(b=l[y],F(b,0,B,y),X=b),l.hasOwnProperty(y="FORMAT"))if(b=l[y],typeof b=="object")oe=b;else throw Error(s+y+" not an object: "+b);if(l.hasOwnProperty(y="ALPHABET"))if(b=l[y],typeof b=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(b))Y=b.slice(0,10)=="0123456789",ae=b;else throw Error(s+y+" invalid: "+b)}else throw Error(s+"Object expected: "+l);return{DECIMAL_PLACES:Q,ROUNDING_MODE:le,EXPONENTIAL_AT:[E,_],RANGE:[m,x],CRYPTO:j,MODULO_MODE:H,POW_PRECISION:X,FORMAT:oe,ALPHABET:ae}},P.isBigNumber=function(l){if(!l||l._isBigNumber!==!0)return!1;if(!P.DEBUG)return!0;var y,b,R=l.c,A=l.e,O=l.s;e:if({}.toString.call(R)=="[object Array]"){if((O===1||O===-1)&&A>=-B&&A<=B&&A===i(A)){if(R[0]===0){if(A===0&&R.length===1)return!0;break e}if(y=(A+1)%c,y<1&&(y+=c),String(R[0]).length==y){for(y=0;y<R.length;y++)if(b=R[y],b<0||b>=a||b!==i(b))break e;if(b!==0)return!0}}}else if(R===null&&A===null&&(O===null||O===1||O===-1))return!0;throw Error(s+"Invalid BigNumber: "+l)},P.maximum=P.max=function(){return ee(arguments,-1)},P.minimum=P.min=function(){return ee(arguments,1)},P.random=function(){var l=9007199254740992,y=Math.random()*l&2097151?function(){return i(Math.random()*l)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(b){var R,A,O,q,v,I=0,k=[],M=new P(ne);if(b==null?b=Q:F(b,0,B),q=n(b/c),j)if(crypto.getRandomValues){for(R=crypto.getRandomValues(new Uint32Array(q*=2));I<q;)v=R[I]*131072+(R[I+1]>>>11),v>=9e15?(A=crypto.getRandomValues(new Uint32Array(2)),R[I]=A[0],R[I+1]=A[1]):(k.push(v%1e14),I+=2);I=q/2}else if(crypto.randomBytes){for(R=crypto.randomBytes(q*=7);I<q;)v=(R[I]&31)*281474976710656+R[I+1]*1099511627776+R[I+2]*4294967296+R[I+3]*16777216+(R[I+4]<<16)+(R[I+5]<<8)+R[I+6],v>=9e15?crypto.randomBytes(7).copy(R,I):(k.push(v%1e14),I+=7);I=q/7}else throw j=!1,Error(s+"crypto unavailable");if(!j)for(;I<q;)v=y(),v<9e15&&(k[I++]=v%1e14);for(q=k[--I],b%=c,q&&b&&(v=d[c-b],k[I]=i(q/v)*v);k[I]===0;k.pop(),I--);if(I<0)k=[O=0];else{for(O=-1;k[0]===0;k.splice(0,1),O-=c);for(I=1,v=k[0];v>=10;v/=10,I++);I<c&&(O-=c-I)}return M.e=O,M.c=k,M}}(),P.sum=function(){for(var l=1,y=arguments,b=new P(y[0]);l<y.length;)b=b.plus(y[l++]);return b},z=function(){var l="0123456789";function y(b,R,A,O){for(var q,v=[0],I,k=0,M=b.length;k<M;){for(I=v.length;I--;v[I]*=R);for(v[0]+=O.indexOf(b.charAt(k++)),q=0;q<v.length;q++)v[q]>A-1&&(v[q+1]==null&&(v[q+1]=0),v[q+1]+=v[q]/A|0,v[q]%=A)}return v.reverse()}return function(b,R,A,O,q){var v,I,k,M,Z,te,fe,_e,Fe=b.indexOf("."),He=Q,we=le;for(Fe>=0&&(M=X,X=0,b=b.replace(".",""),_e=new P(R),te=_e.pow(b.length-Fe),X=M,_e.c=y(W(g(te.c),te.e,"0"),10,A,l),_e.e=_e.c.length),fe=y(b,R,A,q?(v=ae,l):(v=l,ae)),k=M=fe.length;fe[--M]==0;fe.pop());if(!fe[0])return v.charAt(0);if(Fe<0?--k:(te.c=fe,te.e=k,te.s=O,te=C(te,_e,He,we,A),fe=te.c,Z=te.r,k=te.e),I=k+He+1,Fe=fe[I],M=A/2,Z=Z||I<0||fe[I+1]!=null,Z=we<4?(Fe!=null||Z)&&(we==0||we==(te.s<0?3:2)):Fe>M||Fe==M&&(we==4||Z||we==6&&fe[I-1]&1||we==(te.s<0?8:7)),I<1||!fe[0])b=Z?W(v.charAt(1),-He,v.charAt(0)):v.charAt(0);else{if(fe.length=I,Z)for(--A;++fe[--I]>A;)fe[I]=0,I||(++k,fe=[1].concat(fe));for(M=fe.length;!fe[--M];);for(Fe=0,b="";Fe<=M;b+=v.charAt(fe[Fe++]));b=W(b,k,v.charAt(0))}return b}}(),C=function(){function l(R,A,O){var q,v,I,k,M=0,Z=R.length,te=A%h,fe=A/h|0;for(R=R.slice();Z--;)I=R[Z]%h,k=R[Z]/h|0,q=fe*I+k*te,v=te*I+q%h*h+M,M=(v/O|0)+(q/h|0)+fe*k,R[Z]=v%O;return M&&(R=[M].concat(R)),R}function y(R,A,O,q){var v,I;if(O!=q)I=O>q?1:-1;else for(v=I=0;v<O;v++)if(R[v]!=A[v]){I=R[v]>A[v]?1:-1;break}return I}function b(R,A,O,q){for(var v=0;O--;)R[O]-=v,v=R[O]<A[O]?1:0,R[O]=v*q+R[O]-A[O];for(;!R[0]&&R.length>1;R.splice(0,1));}return function(R,A,O,q,v){var I,k,M,Z,te,fe,_e,Fe,He,we,pe,et,Jr,Sn,Pi,Qt,Re,Ct=R.s==A.s?1:-1,yt=R.c,Ye=A.c;if(!yt||!yt[0]||!Ye||!Ye[0])return new P(!R.s||!A.s||(yt?Ye&&yt[0]==Ye[0]:!Ye)?NaN:yt&&yt[0]==0||!Ye?Ct*0:Ct/0);for(Fe=new P(Ct),He=Fe.c=[],k=R.e-A.e,Ct=O+k+1,v||(v=a,k=u(R.e/c)-u(A.e/c),Ct=Ct/c|0),M=0;Ye[M]==(yt[M]||0);M++);if(Ye[M]>(yt[M]||0)&&k--,Ct<0)He.push(1),Z=!0;else{for(Sn=yt.length,Qt=Ye.length,M=0,Ct+=2,te=i(v/(Ye[0]+1)),te>1&&(Ye=l(Ye,te,v),yt=l(yt,te,v),Qt=Ye.length,Sn=yt.length),Jr=Qt,we=yt.slice(0,Qt),pe=we.length;pe<Qt;we[pe++]=0);Re=Ye.slice(),Re=[0].concat(Re),Pi=Ye[0],Ye[1]>=v/2&&Pi++;do{if(te=0,I=y(Ye,we,Qt,pe),I<0){if(et=we[0],Qt!=pe&&(et=et*v+(we[1]||0)),te=i(et/Pi),te>1)for(te>=v&&(te=v-1),fe=l(Ye,te,v),_e=fe.length,pe=we.length;y(fe,we,_e,pe)==1;)te--,b(fe,Qt<_e?Re:Ye,_e,v),_e=fe.length,I=1;else te==0&&(I=te=1),fe=Ye.slice(),_e=fe.length;if(_e<pe&&(fe=[0].concat(fe)),b(we,fe,pe,v),pe=we.length,I==-1)for(;y(Ye,we,Qt,pe)<1;)te++,b(we,Qt<pe?Re:Ye,pe,v),pe=we.length}else I===0&&(te++,we=[0]);He[M++]=te,we[0]?we[pe++]=yt[Jr]||0:(we=[yt[Jr]],pe=1)}while((Jr++<Sn||we[0]!=null)&&Ct--);Z=we[0]!=null,He[0]||He.splice(0,1)}if(v==a){for(M=1,Ct=He[0];Ct>=10;Ct/=10,M++);de(Fe,O+(Fe.e=M+k*c-1)+1,q,Z)}else Fe.e=k,Fe.r=+Z;return Fe}}();function p(l,y,b,R){var A,O,q,v,I;if(b==null?b=le:F(b,0,8),!l.c)return l.toString();if(A=l.c[0],q=l.e,y==null)I=g(l.c),I=R==1||R==2&&(q<=E||q>=_)?V(I,q):W(I,q,"0");else if(l=de(new P(l),y,b),O=l.e,I=g(l.c),v=I.length,R==1||R==2&&(y<=O||O<=E)){for(;v<y;I+="0",v++);I=V(I,O)}else if(y-=q,I=W(I,O,"0"),O+1>v){if(--y>0)for(I+=".";y--;I+="0");}else if(y+=O-v,y>0)for(O+1==v&&(I+=".");y--;I+="0");return l.s<0&&A?"-"+I:I}function ee(l,y){for(var b,R,A=1,O=new P(l[0]);A<l.length;A++)R=new P(l[A]),(!R.s||(b=U(O,R))===y||b===0&&O.s===y)&&(O=R);return O}function re(l,y,b){for(var R=1,A=y.length;!y[--A];y.pop());for(A=y[0];A>=10;A/=10,R++);return(b=R+b*c-1)>x?l.c=l.e=null:b<m?l.c=[l.e=0]:(l.e=b,l.c=y),l}D=function(){var l=/^(-?)0([xbo])(?=\w[\w.]*$)/i,y=/^([^.]+)\.$/,b=/^\.([^.]+)$/,R=/^-?(Infinity|NaN)$/,A=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(O,q,v,I){var k,M=v?q:q.replace(A,"");if(R.test(M))O.s=isNaN(M)?null:M<0?-1:1;else{if(!v&&(M=M.replace(l,function(Z,te,fe){return k=(fe=fe.toLowerCase())=="x"?16:fe=="b"?2:8,!I||I==k?te:Z}),I&&(k=I,M=M.replace(y,"$1").replace(b,"0.$1")),q!=M))return new P(M,k);if(P.DEBUG)throw Error(s+"Not a"+(I?" base "+I:"")+" number: "+q);O.s=null}O.c=O.e=null}}();function de(l,y,b,R){var A,O,q,v,I,k,M,Z=l.c,te=d;if(Z){e:{for(A=1,v=Z[0];v>=10;v/=10,A++);if(O=y-A,O<0)O+=c,q=y,I=Z[k=0],M=i(I/te[A-q-1]%10);else if(k=n((O+1)/c),k>=Z.length)if(R){for(;Z.length<=k;Z.push(0));I=M=0,A=1,O%=c,q=O-c+1}else break e;else{for(I=v=Z[k],A=1;v>=10;v/=10,A++);O%=c,q=O-c+A,M=q<0?0:i(I/te[A-q-1]%10)}if(R=R||y<0||Z[k+1]!=null||(q<0?I:I%te[A-q-1]),R=b<4?(M||R)&&(b==0||b==(l.s<0?3:2)):M>5||M==5&&(b==4||R||b==6&&(O>0?q>0?I/te[A-q]:0:Z[k-1])%10&1||b==(l.s<0?8:7)),y<1||!Z[0])return Z.length=0,R?(y-=l.e+1,Z[0]=te[(c-y%c)%c],l.e=-y||0):Z[0]=l.e=0,l;if(O==0?(Z.length=k,v=1,k--):(Z.length=k+1,v=te[c-O],Z[k]=q>0?i(I/te[A-q]%te[q])*v:0),R)for(;;)if(k==0){for(O=1,q=Z[0];q>=10;q/=10,O++);for(q=Z[0]+=v,v=1;q>=10;q/=10,v++);O!=v&&(l.e++,Z[0]==a&&(Z[0]=1));break}else{if(Z[k]+=v,Z[k]!=a)break;Z[k--]=0,v=1}for(O=Z.length;Z[--O]===0;Z.pop());}l.e>x?l.c=l.e=null:l.e<m&&(l.c=[l.e=0])}return l}function J(l){var y,b=l.e;return b===null?l.toString():(y=g(l.c),y=b<=E||b>=_?V(y,b):W(y,b,"0"),l.s<0?"-"+y:y)}return G.absoluteValue=G.abs=function(){var l=new P(this);return l.s<0&&(l.s=1),l},G.comparedTo=function(l,y){return U(this,new P(l,y))},G.decimalPlaces=G.dp=function(l,y){var b,R,A,O=this;if(l!=null)return F(l,0,B),y==null?y=le:F(y,0,8),de(new P(O),l+O.e+1,y);if(!(b=O.c))return null;if(R=((A=b.length-1)-u(this.e/c))*c,A=b[A])for(;A%10==0;A/=10,R--);return R<0&&(R=0),R},G.dividedBy=G.div=function(l,y){return C(this,new P(l,y),Q,le)},G.dividedToIntegerBy=G.idiv=function(l,y){return C(this,new P(l,y),0,1)},G.exponentiatedBy=G.pow=function(l,y){var b,R,A,O,q,v,I,k,M,Z=this;if(l=new P(l),l.c&&!l.isInteger())throw Error(s+"Exponent not an integer: "+J(l));if(y!=null&&(y=new P(y)),v=l.e>14,!Z.c||!Z.c[0]||Z.c[0]==1&&!Z.e&&Z.c.length==1||!l.c||!l.c[0])return M=new P(Math.pow(+J(Z),v?l.s*(2-N(l)):+J(l))),y?M.mod(y):M;if(I=l.s<0,y){if(y.c?!y.c[0]:!y.s)return new P(NaN);R=!I&&Z.isInteger()&&y.isInteger(),R&&(Z=Z.mod(y))}else{if(l.e>9&&(Z.e>0||Z.e<-1||(Z.e==0?Z.c[0]>1||v&&Z.c[1]>=24e7:Z.c[0]<8e13||v&&Z.c[0]<=9999975e7)))return O=Z.s<0&&N(l)?-0:0,Z.e>-1&&(O=1/O),new P(I?1/O:O);X&&(O=n(X/c+2))}for(v?(b=new P(.5),I&&(l.s=1),k=N(l)):(A=Math.abs(+J(l)),k=A%2),M=new P(ne);;){if(k){if(M=M.times(Z),!M.c)break;O?M.c.length>O&&(M.c.length=O):R&&(M=M.mod(y))}if(A){if(A=i(A/2),A===0)break;k=A%2}else if(l=l.times(b),de(l,l.e+1,1),l.e>14)k=N(l);else{if(A=+J(l),A===0)break;k=A%2}Z=Z.times(Z),O?Z.c&&Z.c.length>O&&(Z.c.length=O):R&&(Z=Z.mod(y))}return R?M:(I&&(M=ne.div(M)),y?M.mod(y):O?de(M,X,le,q):M)},G.integerValue=function(l){var y=new P(this);return l==null?l=le:F(l,0,8),de(y,y.e+1,l)},G.isEqualTo=G.eq=function(l,y){return U(this,new P(l,y))===0},G.isFinite=function(){return!!this.c},G.isGreaterThan=G.gt=function(l,y){return U(this,new P(l,y))>0},G.isGreaterThanOrEqualTo=G.gte=function(l,y){return(y=U(this,new P(l,y)))===1||y===0},G.isInteger=function(){return!!this.c&&u(this.e/c)>this.c.length-2},G.isLessThan=G.lt=function(l,y){return U(this,new P(l,y))<0},G.isLessThanOrEqualTo=G.lte=function(l,y){return(y=U(this,new P(l,y)))===-1||y===0},G.isNaN=function(){return!this.s},G.isNegative=function(){return this.s<0},G.isPositive=function(){return this.s>0},G.isZero=function(){return!!this.c&&this.c[0]==0},G.minus=function(l,y){var b,R,A,O,q=this,v=q.s;if(l=new P(l,y),y=l.s,!v||!y)return new P(NaN);if(v!=y)return l.s=-y,q.plus(l);var I=q.e/c,k=l.e/c,M=q.c,Z=l.c;if(!I||!k){if(!M||!Z)return M?(l.s=-y,l):new P(Z?q:NaN);if(!M[0]||!Z[0])return Z[0]?(l.s=-y,l):new P(M[0]?q:le==3?-0:0)}if(I=u(I),k=u(k),M=M.slice(),v=I-k){for((O=v<0)?(v=-v,A=M):(k=I,A=Z),A.reverse(),y=v;y--;A.push(0));A.reverse()}else for(R=(O=(v=M.length)<(y=Z.length))?v:y,v=y=0;y<R;y++)if(M[y]!=Z[y]){O=M[y]<Z[y];break}if(O&&(A=M,M=Z,Z=A,l.s=-l.s),y=(R=Z.length)-(b=M.length),y>0)for(;y--;M[b++]=0);for(y=a-1;R>v;){if(M[--R]<Z[R]){for(b=R;b&&!M[--b];M[b]=y);--M[b],M[R]+=a}M[R]-=Z[R]}for(;M[0]==0;M.splice(0,1),--k);return M[0]?re(l,M,k):(l.s=le==3?-1:1,l.c=[l.e=0],l)},G.modulo=G.mod=function(l,y){var b,R,A=this;return l=new P(l,y),!A.c||!l.s||l.c&&!l.c[0]?new P(NaN):!l.c||A.c&&!A.c[0]?new P(A):(H==9?(R=l.s,l.s=1,b=C(A,l,0,3),l.s=R,b.s*=R):b=C(A,l,0,H),l=A.minus(b.times(l)),!l.c[0]&&H==1&&(l.s=A.s),l)},G.multipliedBy=G.times=function(l,y){var b,R,A,O,q,v,I,k,M,Z,te,fe,_e,Fe,He,we=this,pe=we.c,et=(l=new P(l,y)).c;if(!pe||!et||!pe[0]||!et[0])return!we.s||!l.s||pe&&!pe[0]&&!et||et&&!et[0]&&!pe?l.c=l.e=l.s=null:(l.s*=we.s,!pe||!et?l.c=l.e=null:(l.c=[0],l.e=0)),l;for(R=u(we.e/c)+u(l.e/c),l.s*=we.s,I=pe.length,Z=et.length,I<Z&&(_e=pe,pe=et,et=_e,A=I,I=Z,Z=A),A=I+Z,_e=[];A--;_e.push(0));for(Fe=a,He=h,A=Z;--A>=0;){for(b=0,te=et[A]%He,fe=et[A]/He|0,q=I,O=A+q;O>A;)k=pe[--q]%He,M=pe[q]/He|0,v=fe*k+M*te,k=te*k+v%He*He+_e[O]+b,b=(k/Fe|0)+(v/He|0)+fe*M,_e[O--]=k%Fe;_e[O]=b}return b?++R:_e.splice(0,1),re(l,_e,R)},G.negated=function(){var l=new P(this);return l.s=-l.s||null,l},G.plus=function(l,y){var b,R=this,A=R.s;if(l=new P(l,y),y=l.s,!A||!y)return new P(NaN);if(A!=y)return l.s=-y,R.minus(l);var O=R.e/c,q=l.e/c,v=R.c,I=l.c;if(!O||!q){if(!v||!I)return new P(A/0);if(!v[0]||!I[0])return I[0]?l:new P(v[0]?R:A*0)}if(O=u(O),q=u(q),v=v.slice(),A=O-q){for(A>0?(q=O,b=I):(A=-A,b=v),b.reverse();A--;b.push(0));b.reverse()}for(A=v.length,y=I.length,A-y<0&&(b=I,I=v,v=b,y=A),A=0;y;)A=(v[--y]=v[y]+I[y]+A)/a|0,v[y]=a===v[y]?0:v[y]%a;return A&&(v=[A].concat(v),++q),re(l,v,q)},G.precision=G.sd=function(l,y){var b,R,A,O=this;if(l!=null&&l!==!!l)return F(l,1,B),y==null?y=le:F(y,0,8),de(new P(O),l,y);if(!(b=O.c))return null;if(A=b.length-1,R=A*c+1,A=b[A]){for(;A%10==0;A/=10,R--);for(A=b[0];A>=10;A/=10,R++);}return l&&O.e+1>R&&(R=O.e+1),R},G.shiftedBy=function(l){return F(l,-f,f),this.times("1e"+l)},G.squareRoot=G.sqrt=function(){var l,y,b,R,A,O=this,q=O.c,v=O.s,I=O.e,k=Q+4,M=new P("0.5");if(v!==1||!q||!q[0])return new P(!v||v<0&&(!q||q[0])?NaN:q?O:1/0);if(v=Math.sqrt(+J(O)),v==0||v==1/0?(y=g(q),(y.length+I)%2==0&&(y+="0"),v=Math.sqrt(+y),I=u((I+1)/2)-(I<0||I%2),v==1/0?y="5e"+I:(y=v.toExponential(),y=y.slice(0,y.indexOf("e")+1)+I),b=new P(y)):b=new P(v+""),b.c[0]){for(I=b.e,v=I+k,v<3&&(v=0);;)if(A=b,b=M.times(A.plus(C(O,A,k,1))),g(A.c).slice(0,v)===(y=g(b.c)).slice(0,v))if(b.e<I&&--v,y=y.slice(v-3,v+1),y=="9999"||!R&&y=="4999"){if(!R&&(de(A,A.e+Q+2,0),A.times(A).eq(O))){b=A;break}k+=4,v+=4,R=1}else{(!+y||!+y.slice(1)&&y.charAt(0)=="5")&&(de(b,b.e+Q+2,1),l=!b.times(b).eq(O));break}}return de(b,b.e+Q+1,le,l)},G.toExponential=function(l,y){return l!=null&&(F(l,0,B),l++),p(this,l,y,1)},G.toFixed=function(l,y){return l!=null&&(F(l,0,B),l=l+this.e+1),p(this,l,y)},G.toFormat=function(l,y,b){var R,A=this;if(b==null)l!=null&&y&&typeof y=="object"?(b=y,y=null):l&&typeof l=="object"?(b=l,l=y=null):b=oe;else if(typeof b!="object")throw Error(s+"Argument not an object: "+b);if(R=A.toFixed(l,y),A.c){var O,q=R.split("."),v=+b.groupSize,I=+b.secondaryGroupSize,k=b.groupSeparator||"",M=q[0],Z=q[1],te=A.s<0,fe=te?M.slice(1):M,_e=fe.length;if(I&&(O=v,v=I,I=O,_e-=O),v>0&&_e>0){for(O=_e%v||v,M=fe.substr(0,O);O<_e;O+=v)M+=k+fe.substr(O,v);I>0&&(M+=k+fe.slice(O)),te&&(M="-"+M)}R=Z?M+(b.decimalSeparator||"")+((I=+b.fractionGroupSize)?Z.replace(new RegExp("\\d{"+I+"}\\B","g"),"$&"+(b.fractionGroupSeparator||"")):Z):M}return(b.prefix||"")+R+(b.suffix||"")},G.toFraction=function(l){var y,b,R,A,O,q,v,I,k,M,Z,te,fe=this,_e=fe.c;if(l!=null&&(v=new P(l),!v.isInteger()&&(v.c||v.s!==1)||v.lt(ne)))throw Error(s+"Argument "+(v.isInteger()?"out of range: ":"not an integer: ")+J(v));if(!_e)return new P(fe);for(y=new P(ne),k=b=new P(ne),R=I=new P(ne),te=g(_e),O=y.e=te.length-fe.e-1,y.c[0]=d[(q=O%c)<0?c+q:q],l=!l||v.comparedTo(y)>0?O>0?y:k:v,q=x,x=1/0,v=new P(te),I.c[0]=0;M=C(v,y,0,1),A=b.plus(M.times(R)),A.comparedTo(l)!=1;)b=R,R=A,k=I.plus(M.times(A=k)),I=A,y=v.minus(M.times(A=y)),v=A;return A=C(l.minus(b),R,0,1),I=I.plus(A.times(k)),b=b.plus(A.times(R)),I.s=k.s=fe.s,O=O*2,Z=C(k,R,O,le).minus(fe).abs().comparedTo(C(I,b,O,le).minus(fe).abs())<1?[k,R]:[I,b],x=q,Z},G.toNumber=function(){return+J(this)},G.toPrecision=function(l,y){return l!=null&&F(l,1,B),p(this,l,y,2)},G.toString=function(l){var y,b=this,R=b.s,A=b.e;return A===null?R?(y="Infinity",R<0&&(y="-"+y)):y="NaN":(l==null?y=A<=E||A>=_?V(g(b.c),A):W(g(b.c),A,"0"):l===10&&Y?(b=de(new P(b),Q+A+1,le),y=W(g(b.c),b.e,"0")):(F(l,2,ae.length,"Base"),y=z(W(g(b.c),A,"0"),10,l,R,!0)),R<0&&b.c[0]&&(y="-"+y)),y},G.valueOf=G.toJSON=function(){return J(this)},G._isBigNumber=!0,T!=null&&P.set(T),P}function u(T){var C=T|0;return T>0||T===C?C:C-1}function g(T){for(var C,z,D=1,G=T.length,ne=T[0]+"";D<G;){for(C=T[D++]+"",z=c-C.length;z--;C="0"+C);ne+=C}for(G=ne.length;ne.charCodeAt(--G)===48;);return ne.slice(0,G+1||1)}function U(T,C){var z,D,G=T.c,ne=C.c,Q=T.s,le=C.s,E=T.e,_=C.e;if(!Q||!le)return null;if(z=G&&!G[0],D=ne&&!ne[0],z||D)return z?D?0:-le:Q;if(Q!=le)return Q;if(z=Q<0,D=E==_,!G||!ne)return D?0:!G^z?1:-1;if(!D)return E>_^z?1:-1;for(le=(E=G.length)<(_=ne.length)?E:_,Q=0;Q<le;Q++)if(G[Q]!=ne[Q])return G[Q]>ne[Q]^z?1:-1;return E==_?0:E>_^z?1:-1}function F(T,C,z,D){if(T<C||T>z||T!==i(T))throw Error(s+(D||"Argument")+(typeof T=="number"?T<C||T>z?" out of range: ":" not an integer: ":" not a primitive number: ")+String(T))}function N(T){var C=T.c.length-1;return u(T.e/c)==C&&T.c[C]%2!=0}function V(T,C){return(T.length>1?T.charAt(0)+"."+T.slice(1):T)+(C<0?"e":"e+")+C}function W(T,C,z){var D,G;if(C<0){for(G=z+".";++C;G+=z);T=G+T}else if(D=T.length,++C>D){for(G=z,C-=D;--C;G+=z);T+=G}else C<D&&(T=T.slice(0,C)+"."+T.slice(C));return T}e=w(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof oo<"u"&&oo.exports?oo.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(ld)});var dd=L((mx,fd)=>{fd.exports=function(e,r,n){var i=new e.Uint8Array(n),s=r.pushInt,o=r.pushInt32,a=r.pushInt32Neg,c=r.pushInt64,f=r.pushInt64Neg,d=r.pushFloat,h=r.pushFloatSingle,B=r.pushFloatDouble,w=r.pushTrue,u=r.pushFalse,g=r.pushUndefined,U=r.pushNull,F=r.pushInfinity,N=r.pushInfinityNeg,V=r.pushNaN,W=r.pushNaNNeg,T=r.pushArrayStart,C=r.pushArrayStartFixed,z=r.pushArrayStartFixed32,D=r.pushArrayStartFixed64,G=r.pushObjectStart,ne=r.pushObjectStartFixed,Q=r.pushObjectStartFixed32,le=r.pushObjectStartFixed64,E=r.pushByteString,_=r.pushByteStringStart,m=r.pushUtf8String,x=r.pushUtf8StringStart,j=r.pushSimpleUnassigned,H=r.pushTagStart,X=r.pushTagStart4,oe=r.pushTagStart8,ae=r.pushTagUnassigned,Y=r.pushBreak,P=e.Math.pow,p=0,ee=0,re=0;function de(S){for(S=S|0,p=0,ee=S;(p|0)<(ee|0)&&(re=Iy[i[p]&255](i[p]|0)|0,!((re|0)>0)););return re|0}function J(S){return S=S|0,((p|0)+(S|0)|0)<(ee|0)?0:1}function l(S){return S=S|0,i[S|0]<<8|i[S+1|0]|0}function y(S){return S=S|0,i[S|0]<<24|i[S+1|0]<<16|i[S+2|0]<<8|i[S+3|0]|0}function b(S){return S=S|0,s(S|0),p=p+1|0,0}function R(S){return S=S|0,J(1)|0?1:(s(i[p+1|0]|0),p=p+2|0,0)}function A(S){return S=S|0,J(2)|0?1:(s(l(p+1|0)|0),p=p+3|0,0)}function O(S){return S=S|0,J(4)|0?1:(o(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function q(S){return S=S|0,J(8)|0?1:(c(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function v(S){return S=S|0,s(-1-(S-32|0)|0),p=p+1|0,0}function I(S){return S=S|0,J(1)|0?1:(s(-1-(i[p+1|0]|0)|0),p=p+2|0,0)}function k(S){S=S|0;var Te=0;return J(2)|0?1:(Te=l(p+1|0)|0,s(-1-(Te|0)|0),p=p+3|0,0)}function M(S){return S=S|0,J(4)|0?1:(a(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function Z(S){return S=S|0,J(8)|0?1:(f(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function te(S){S=S|0;var Te=0,Be=0,xe=0;return xe=S-64|0,J(xe|0)|0?1:(Te=p+1|0,Be=(p+1|0)+(xe|0)|0,E(Te|0,Be|0),p=Be|0,0)}function fe(S){S=S|0;var Te=0,Be=0,xe=0;return J(1)|0||(xe=i[p+1|0]|0,Te=p+2|0,Be=(p+2|0)+(xe|0)|0,J(xe+1|0)|0)?1:(E(Te|0,Be|0),p=Be|0,0)}function _e(S){S=S|0;var Te=0,Be=0,xe=0;return J(2)|0||(xe=l(p+1|0)|0,Te=p+3|0,Be=(p+3|0)+(xe|0)|0,J(xe+2|0)|0)?1:(E(Te|0,Be|0),p=Be|0,0)}function Fe(S){S=S|0;var Te=0,Be=0,xe=0;return J(4)|0||(xe=y(p+1|0)|0,Te=p+5|0,Be=(p+5|0)+(xe|0)|0,J(xe+4|0)|0)?1:(E(Te|0,Be|0),p=Be|0,0)}function He(S){return S=S|0,1}function we(S){return S=S|0,_(),p=p+1|0,0}function pe(S){S=S|0;var Te=0,Be=0,xe=0;return xe=S-96|0,J(xe|0)|0?1:(Te=p+1|0,Be=(p+1|0)+(xe|0)|0,m(Te|0,Be|0),p=Be|0,0)}function et(S){S=S|0;var Te=0,Be=0,xe=0;return J(1)|0||(xe=i[p+1|0]|0,Te=p+2|0,Be=(p+2|0)+(xe|0)|0,J(xe+1|0)|0)?1:(m(Te|0,Be|0),p=Be|0,0)}function Jr(S){S=S|0;var Te=0,Be=0,xe=0;return J(2)|0||(xe=l(p+1|0)|0,Te=p+3|0,Be=(p+3|0)+(xe|0)|0,J(xe+2|0)|0)?1:(m(Te|0,Be|0),p=Be|0,0)}function Sn(S){S=S|0;var Te=0,Be=0,xe=0;return J(4)|0||(xe=y(p+1|0)|0,Te=p+5|0,Be=(p+5|0)+(xe|0)|0,J(xe+4|0)|0)?1:(m(Te|0,Be|0),p=Be|0,0)}function Pi(S){return S=S|0,1}function Qt(S){return S=S|0,x(),p=p+1|0,0}function Re(S){return S=S|0,C(S-128|0),p=p+1|0,0}function Ct(S){return S=S|0,J(1)|0?1:(C(i[p+1|0]|0),p=p+2|0,0)}function yt(S){return S=S|0,J(2)|0?1:(C(l(p+1|0)|0),p=p+3|0,0)}function Ye(S){return S=S|0,J(4)|0?1:(z(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function dy(S){return S=S|0,J(8)|0?1:(D(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function hy(S){return S=S|0,T(),p=p+1|0,0}function We(S){S=S|0;var Te=0;return Te=S-160|0,J(Te|0)|0?1:(ne(Te|0),p=p+1|0,0)}function py(S){return S=S|0,J(1)|0?1:(ne(i[p+1|0]|0),p=p+2|0,0)}function yy(S){return S=S|0,J(2)|0?1:(ne(l(p+1|0)|0),p=p+3|0,0)}function by(S){return S=S|0,J(4)|0?1:(Q(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function gy(S){return S=S|0,J(8)|0?1:(le(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function my(S){return S=S|0,G(),p=p+1|0,0}function Wn(S){return S=S|0,H(S-192|0|0),p=p+1|0,0}function EE(S){return S=S|0,H(S|0),p=p+1|0,0}function xE(S){return S=S|0,H(S|0),p=p+1|0,0}function vE(S){return S=S|0,H(S|0),p=p+1|0,0}function TE(S){return S=S|0,H(S|0),p=p+1|0,0}function ct(S){return S=S|0,H(S-192|0|0),p=p+1|0,0}function SE(S){return S=S|0,H(S|0),p=p+1|0,0}function BE(S){return S=S|0,H(S|0),p=p+1|0,0}function AE(S){return S=S|0,H(S|0),p=p+1|0,0}function _y(S){return S=S|0,J(1)|0?1:(H(i[p+1|0]|0),p=p+2|0,0)}function wy(S){return S=S|0,J(2)|0?1:(H(l(p+1|0)|0),p=p+3|0,0)}function Ey(S){return S=S|0,J(4)|0?1:(X(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function xy(S){return S=S|0,J(8)|0?1:(oe(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function tt(S){return S=S|0,j((S|0)-224|0),p=p+1|0,0}function vy(S){return S=S|0,u(),p=p+1|0,0}function Ty(S){return S=S|0,w(),p=p+1|0,0}function Sy(S){return S=S|0,U(),p=p+1|0,0}function By(S){return S=S|0,g(),p=p+1|0,0}function Ay(S){return S=S|0,J(1)|0?1:(j(i[p+1|0]|0),p=p+2|0,0)}function Oy(S){S=S|0;var Te=0,Be=0,xe=1,xs=0,Ii=0,OE=0;return J(2)|0?1:(Te=i[p+1|0]|0,Be=i[p+2|0]|0,(Te|0)&128&&(xe=-1),xs=+(((Te|0)&124)>>2),Ii=+(((Te|0)&3)<<8|Be),+xs==0?d(+(+xe*5960464477539063e-23*+Ii)):+xs==31?+xe==1?+Ii>0?V():F():+Ii>0?W():N():d(+(+xe*P(2,+(+xs-25))*+(1024+Ii))),p=p+3|0,0)}function Ny(S){return S=S|0,J(4)|0?1:(h(i[p+1|0]|0,i[p+2|0]|0,i[p+3|0]|0,i[p+4|0]|0),p=p+5|0,0)}function Ry(S){return S=S|0,J(8)|0?1:(B(i[p+1|0]|0,i[p+2|0]|0,i[p+3|0]|0,i[p+4|0]|0,i[p+5|0]|0,i[p+6|0]|0,i[p+7|0]|0,i[p+8|0]|0),p=p+9|0,0)}function ke(S){return S=S|0,1}function Py(S){return S=S|0,Y(),p=p+1|0,0}var Iy=[b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,R,A,O,q,ke,ke,ke,ke,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,I,k,M,Z,ke,ke,ke,ke,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,fe,_e,Fe,He,ke,ke,ke,we,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,et,Jr,Sn,Pi,ke,ke,ke,Qt,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Ct,yt,Ye,dy,ke,ke,ke,hy,We,We,We,We,We,We,We,We,We,We,We,We,We,We,We,We,We,We,We,We,We,We,We,We,py,yy,by,gy,ke,ke,ke,my,Wn,Wn,Wn,Wn,Wn,Wn,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,_y,wy,Ey,xy,ke,ke,ke,ke,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,vy,Ty,Sy,By,Ay,Oy,Ny,Ry,ke,ke,ke,Py];return{parse:de}}});var $i=L(Gt=>{"use strict";var Pc=Hi().BigNumber;Gt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Gt.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36};Gt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Gt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Gt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Gt.SHIFT32=Math.pow(2,32);Gt.SHIFT16=Math.pow(2,16);Gt.MAX_SAFE_HIGH=2097151;Gt.NEG_ONE=new Pc(-1);Gt.TEN=new Pc(10);Gt.TWO=new Pc(2);Gt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var ao=L(rr=>{"use strict";var{Buffer:Ig}=zn("buffer"),pd=Hi().BigNumber,yd=$i(),hd=yd.SHIFT32,Ug=yd.SHIFT16,Fg=2097151;rr.parseHalf=function(e){var r,n,i;return i=e[0]&128?-1:1,r=(e[0]&124)>>2,n=(e[0]&3)<<8|e[1],r?r===31?i*(n?NaN:1/0):i*Math.pow(2,r-25)*(1024+n):i*5960464477539063e-23*n};function Mg(t){return t<16?"0"+t.toString(16):t.toString(16)}rr.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=Mg(t[n]);return new pd(r,16)};rr.buildMap=t=>{let e=new Map,r=Object.keys(t),n=r.length;for(let i=0;i<n;i++)e.set(r[i],t[r[i]]);return e};rr.buildInt32=(t,e)=>t*Ug+e;rr.buildInt64=(t,e,r,n)=>{let i=rr.buildInt32(t,e),s=rr.buildInt32(r,n);return i>Fg?new pd(i).times(hd).plus(s):i*hd+s};rr.writeHalf=function(e,r){let n=Ig.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if(i&8191)return!1;var s=i>>16&32768;let o=i>>23&255,a=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(a>>13);else if(o>=103&&o<113){if(a&(1<<126-o)-1)return!1;s+=a+8388608>>126-o}else return!1;return e.writeUInt16BE(s,0),!0};rr.keySorter=function(t,e){var r=t[0].byteLength,n=e[0].byteLength;return r>n?1:n>r?-1:t[0].compare(e[0])};rr.isNegativeZero=t=>t===0&&1/t<0;rr.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var Mc=L((Ex,bd)=>{"use strict";var Fc=$i(),Cg=Fc.MT,co=Fc.SIMPLE,Ic=Fc.SYMS,Uc=class t{constructor(e){if(typeof e!="number")throw new Error("Invalid Simple type: "+typeof e);if(e<0||e>255||(e|0)!==e)throw new Error("value must be a small positive integer: "+e);this.value=e}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,Cg.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case co.FALSE:return!1;case co.TRUE:return!0;case co.NULL:return r?null:Ic.NULL;case co.UNDEFINED:return r?void 0:Ic.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return Ic.BREAK;default:return new t(e)}}};bd.exports=Uc});var qc=L((xx,gd)=>{"use strict";var Cc=class t{constructor(e,r,n){if(this.tag=e,this.value=r,this.err=n,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(e){return e._pushTag(this.tag),e.pushAny(this.value)}convert(e){var r,n;if(n=e?.[this.tag],typeof n!="function"&&(n=t["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(t,this.value)}catch(i){return r=i,this.err=r,this}}};gd.exports=Cc});var kc=L((vx,_d)=>{"use strict";var{URL:qg,URLSearchParams:jg,format:kg}=zn("url"),md="http://localhost",jc=class extends qg{constructor(e="",r=md){super(e,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}format(){return this.toString()}};_d.exports={URLWithLegacySupport:jc,URLSearchParams:jg,format:kg,defaultBase:md}});var xd=L((Tx,Ed)=>{"use strict";var{URLWithLegacySupport:wd,format:Vg}=kc();Ed.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new wd(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new wd(t,Vg(o)).toString()}});var Vc=L((Sx,vd)=>{"use strict";var{URLWithLegacySupport:Hg,format:$g,URLSearchParams:Kg,defaultBase:Gg}=kc(),Yg=xd();vd.exports={URL:Hg,URLSearchParams:Kg,format:$g,relative:Yg,defaultBase:Gg}});var Hc=L((Bx,Sd)=>{"use strict";var{Buffer:di}=zn("buffer"),Td=ec(),Wg=Hi().BigNumber,zg=dd(),Rt=ao(),Ce=$i(),Dg=Mc(),Zg=qc(),{URL:Xg}=Vc(),Ki=class t{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=Rt.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=di.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>Rt.arrayBufferToBignumber(r),3:r=>Ce.NEG_ONE.minus(Rt.arrayBufferToBignumber(r)),4:r=>Ce.TEN.pow(r[0]).times(r[1]),5:r=>Ce.TWO.pow(r[0]).times(r[1]),32:r=>new Xg(r),35:r=>new RegExp(r)},e.tags),this.parser=zg(global,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var e=this._parents.pop();if(e.length>0)throw new Error(`Missing ${e.length} elements`);switch(e.type){case Ce.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case Ce.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case Ce.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case Ce.PARENT.MAP:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(e.ref,e.length));break;case Ce.PARENT.OBJECT:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(e.ref,e.length));break;case Ce.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===Ce.PARENT.TAG&&this._dec()}_dec(){let e=this._currentParent;e.length<0||(e.length--,e.length===0&&this._closeParent())}_push(e,r){let n=this._currentParent;switch(n.values++,n.type){case Ce.PARENT.ARRAY:case Ce.PARENT.BYTE_STRING:case Ce.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case Ce.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=Ce.PARENT.MAP,n.ref=Rt.buildMap(n.ref)));break;case Ce.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case Ce.PARENT.TAG:this._ref.push(e),r||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(e,r,n){this._parents[this._depth]={type:r,length:n,ref:e,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:Ce.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,r){let n=this._knownTags[e];return n?n(r):new Zg(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return di.concat(e)}createByteStringFromHeap(e,r){return e===r?di.alloc(0):di.from(this._heap.slice(e,r))}createInt(e){return e}createInt32(e,r){return Rt.buildInt32(e,r)}createInt64(e,r,n,i){return Rt.buildInt64(e,r,n,i)}createFloat(e){return e}createFloatSingle(e,r,n,i){return Td.read([e,r,n,i],0,!1,23,4)}createFloatDouble(e,r,n,i,s,o,a,c){return Td.read([e,r,n,i,s,o,a,c],0,!1,52,8)}createInt32Neg(e,r){return-1-Rt.buildInt32(e,r)}createInt64Neg(e,r,n,i){let s=Rt.buildInt32(e,r),o=Rt.buildInt32(n,i);return s>Ce.MAX_SAFE_HIGH?Ce.NEG_ONE.minus(new Wg(s).times(Ce.SHIFT32).plus(o)):-1-(s*Ce.SHIFT32+o)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(e,r){return e.join("")}createUtf8StringFromHeap(e,r){return e===r?"":this._buffer.toString("utf8",e,r)}createSimpleUnassigned(e){return new Dg(e)}pushInt(e){this._push(this.createInt(e))}pushInt32(e,r){this._push(this.createInt32(e,r))}pushInt64(e,r,n,i){this._push(this.createInt64(e,r,n,i))}pushFloat(e){this._push(this.createFloat(e))}pushFloatSingle(e,r,n,i){this._push(this.createFloatSingle(e,r,n,i))}pushFloatDouble(e,r,n,i,s,o,a,c){this._push(this.createFloatDouble(e,r,n,i,s,o,a,c))}pushInt32Neg(e,r){this._push(this.createInt32Neg(e,r))}pushInt64Neg(e,r,n,i){this._push(this.createInt64Neg(e,r,n,i))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],Ce.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,r){let n=Rt.buildInt32(e,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,r,n,i){let s=Rt.buildInt64(e,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,r){let n=Rt.buildInt32(e,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,r,n,i){let s=Rt.buildInt64(e,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:Ce.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(e,r){this._push(this.createByteStringFromHeap(e,r))}pushUtf8StringStart(){this._parents[this._depth]={type:Ce.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(e,r){this._push(this.createUtf8StringFromHeap(e,r))}pushSimpleUnassigned(e){this._push(this.createSimpleUnassigned(e))}pushTagStart(e){this._parents[this._depth]={type:Ce.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,r){this.pushTagStart(Rt.buildInt32(e,r))}pushTagStart8(e,r,n,i){this.pushTagStart(Rt.buildInt64(e,r,n,i))}pushTagUnassigned(e){this._push(this.createTag(e))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(e){if(e===0){this._push(this.createObject({}));return}this._createParent({},Ce.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),Ce.PARENT.ARRAY,e)}_decode(e){if(e.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(e);let r=this.parser.parse(e.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(r>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(e){return this._decode(e),this._res[0]}decodeAll(e){return this._decode(e),this._res}static decode(e,r){return typeof e=="string"&&(e=di.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=di.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};Ki.decodeFirst=Ki.decode;Sd.exports=Ki});var Od=L((Ax,Ad)=>{"use strict";var{Buffer:$c}=zn("buffer"),Jg=Hc(),Lg=ao(),Kc=class t extends Jg{createTag(e,r){return`${e}(${r})`}createInt(e){return super.createInt(e).toString()}createInt32(e,r){return super.createInt32(e,r).toString()}createInt64(e,r,n,i){return super.createInt64(e,r,n,i).toString()}createInt32Neg(e,r){return super.createInt32Neg(e,r).toString()}createInt64Neg(e,r,n,i){return super.createInt64Neg(e,r,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(e){let r=super.createFloat(e);return Lg.isNegativeZero(e)?"-0_1":`${r}_1`}createFloatSingle(e,r,n,i){return`${super.createFloatSingle(e,r,n,i)}_2`}createFloatDouble(e,r,n,i,s,o,a,c){return`${super.createFloatDouble(e,r,n,i,s,o,a,c)}_3`}createByteString(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(e,r){return`h'${$c.from(super.createByteStringFromHeap(e,r)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(e){return`simple(${e})`}createArray(e,r){let n=super.createArray(e,r);return r===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(e,r){let n=super.createMap(e),i=Array.from(n.keys()).reduce(Bd(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(e,r){let n=super.createObject(e),i=Object.keys(n).reduce(Bd(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,r){return`"${$c.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=$c.from(e,r||"hex")),new t().decodeFirst(e)}};Ad.exports=Kc;function Bd(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var Ud=L((Ox,Id)=>{"use strict";var{Buffer:Sr}=zn("buffer"),{URL:Qg}=Vc(),Yc=Hi().BigNumber,Gc=ao(),it=$i(),ur=it.MT,uo=it.NUMBYTES,Nd=it.SHIFT32,Rd=it.SYMS,hi=it.TAG,em=it.MT.SIMPLE_FLOAT<<5|it.NUMBYTES.TWO,tm=it.MT.SIMPLE_FLOAT<<5|it.NUMBYTES.FOUR,rm=it.MT.SIMPLE_FLOAT<<5|it.NUMBYTES.EIGHT,nm=it.MT.SIMPLE_FLOAT<<5|it.SIMPLE.TRUE,im=it.MT.SIMPLE_FLOAT<<5|it.SIMPLE.FALSE,sm=it.MT.SIMPLE_FLOAT<<5|it.SIMPLE.UNDEFINED,Pd=it.MT.SIMPLE_FLOAT<<5|it.SIMPLE.NULL,om=new Yc("0x20000000000000"),am=Sr.from("f97e00","hex"),cm=Sr.from("f9fc00","hex"),um=Sr.from("f97c00","hex");function lm(t){return{}.toString.call(t).slice(8,-1)}var Wc=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[Qg,this._pushUrl],[Yc,this._pushBigNumber]];let r=e.genTypes||[],n=r.length;for(let i=0;i<n;i++)this.addSemanticType(r[i][0],r[i][1]);this._reset()}addSemanticType(e,r){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===e){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,o}return this.semanticTypes.push([e,r]),null}push(e){return e&&(this.result[this.offset]=e,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=e.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(e,r,n){return this.result[this.offset]=e,this.resultMethod[this.offset]=r,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(e){return this.pushWrite(e,1,1)}_pushUInt16BE(e){return this.pushWrite(e,2,2)}_pushUInt32BE(e){return this.pushWrite(e,3,4)}_pushDoubleBE(e){return this.pushWrite(e,4,8)}_pushNaN(){return this.push(am)}_pushInfinity(e){let r=e<0?cm:um;return this.push(r)}_pushFloat(e){let r=Sr.allocUnsafe(2);if(Gc.writeHalf(r,e)&&Gc.parseHalf(r)===e)return this._pushUInt8(em)&&this.push(r);let n=Sr.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(tm)&&this.push(n):this._pushUInt8(rm)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|uo.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|uo.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|uo.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|uo.EIGHT)&&this._pushUInt32BE(Math.floor(e/Nd))&&this._pushUInt32BE(e%Nd):r===ur.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,ur.NEG_INT,e):this._pushInt(e,ur.POS_INT)}_pushNumber(e){switch(!1){case e===e:return this._pushNaN(e);case isFinite(e):return this._pushInfinity(e);case e%1!==0:return this._pushIntNum(e);default:return this._pushFloat(e)}}_pushString(e){let r=Sr.byteLength(e,"utf8");return this._pushInt(r,ur.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?nm:im)}_pushUndefined(e){return this._pushUInt8(sm)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,ur.ARRAY))return!1;for(let i=0;i<n;i++)if(!e.pushAny(r[i]))return!1;return!0}_pushTag(e){return this._pushInt(e,ur.TAG)}_pushDate(e,r){return e._pushTag(hi.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,ur.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(hi.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,ur.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(hi.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=hi.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=hi.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=Sr.from(n,"hex");return this._pushTag(r)&&this._pushBuffer(this,i)}_pushBigNumber(e,r){if(r.isNaN())return e._pushNaN();if(!r.isFinite())return e._pushInfinity(r.isNegative()?-1/0:1/0);if(r.isInteger())return e._pushBigint(r);if(!(e._pushTag(hi.DECIMAL_FRAC)&&e._pushInt(2,ur.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new Yc(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(om)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,ur.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(e){if(!e)return this._pushUInt8(Pd);for(var r=this.semanticTypes.length,n=0;n<r;n++)if(e instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(e,this,e);var i=e.encodeCBOR;if(typeof i=="function")return i.call(e,this);var s=Object.keys(e),o=s.length;return this._pushInt(o,ur.MAP)?this._pushRawMap(o,s.map(a=>[a,e[a]])):!1}_pushRawMap(e,r){r=r.map(function(i){return i[0]=t.encode(i[0]),i}).sort(Gc.keySorter);for(var n=0;n<e;n++)if(!this.push(r[n][0])||!this.pushAny(r[n][1]))return!1;return!0}write(e){return this.pushAny(e)}pushAny(e){var r=lm(e);switch(r){case"Number":return this._pushNumber(e);case"String":return this._pushString(e);case"Boolean":return this._pushBoolean(e);case"Object":return this._pushObject(e);case"Array":return this._pushArray(this,e);case"Uint8Array":return this._pushBuffer(this,Sr.isBuffer(e)?e:Sr.from(e));case"Null":return this._pushUInt8(Pd);case"Undefined":return this._pushUndefined(e);case"Map":return this._pushMap(this,e);case"Set":return this._pushSet(this,e);case"URL":return this._pushUrl(this,e);case"BigNumber":return this._pushBigNumber(this,e);case"Date":return this._pushDate(this,e);case"RegExp":return this._pushRegexp(this,e);case"Symbol":switch(e){case Rd.NULL:return this._pushObject(null);case Rd.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+e.toString())}default:throw new Error("Unknown type: "+typeof e+", "+(e?e.toString():""))}}finalize(){if(this.offset===0)return null;for(var e=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=r[o];var a=Sr.allocUnsafe(s),c=0,f=0;for(o=0;o<i;o++){switch(f=r[o],n[o]){case 0:e[o].copy(a,c);break;case 1:a.writeUInt8(e[o],c,!0);break;case 2:a.writeUInt16BE(e[o],c,!0);break;case 3:a.writeUInt32BE(e[o],c,!0);break;case 4:a.writeDoubleBE(e[o],c,!0);break;case 5:a.write(e[o],c,f,"utf8");break;default:throw new Error("unkown method")}c+=f}var d=a;return this._reset(),d}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(e){let r=new t;if(!r.pushAny(e))throw new Error("Failed to encode input");return r.finalize()}};Id.exports=Wc});var lo=L(st=>{"use strict";st.Diagnose=Od();st.Decoder=Hc();st.Encoder=Ud();st.Simple=Mc();st.Tagged=qc();st.decodeAll=st.Decoder.decodeAll;st.decodeFirst=st.Decoder.decodeFirst;st.diagnose=st.Diagnose.diagnose;st.encode=st.Encoder.encode;st.decode=st.Decoder.decode;st.leveldb={decode:st.Decoder.decodeAll,encode:st.Encoder.encode,buffer:!0,name:"cbor"}});var Yt=L(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.bufFromBufLike=Tt.uint8ToBuf=Tt.bufEquals=Tt.compare=Tt.fromHex=Tt.toHex=Tt.concat=void 0;function fm(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e.buffer}Tt.concat=fm;function dm(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}Tt.toHex=dm;var hm=new RegExp(/^[0-9a-fA-F]+$/);function pm(t){if(!hm.test(t))throw new Error("Invalid hexadecimal string.");let e=[...t].reduce((r,n,i)=>(r[i/2|0]=(r[i/2|0]||"")+n,r),[]).map(r=>Number.parseInt(r,16));return new Uint8Array(e).buffer}Tt.fromHex=pm;function Fd(t,e){if(t.byteLength!==e.byteLength)return t.byteLength-e.byteLength;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return r[i]-n[i];return 0}Tt.compare=Fd;function ym(t,e){return Fd(t,e)===0}Tt.bufEquals=ym;function fo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}Tt.uint8ToBuf=fo;function Md(t){return t instanceof Uint8Array?fo(t):t instanceof ArrayBuffer?t:Array.isArray(t)?fo(new Uint8Array(t)):"buffer"in t?Md(t.buffer):fo(new Uint8Array(t))}Tt.bufFromBufLike=Md});var Wi=L(nr=>{"use strict";var bm=nr&&nr.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(nr,"__esModule",{value:!0});nr.hashOfMap=nr.requestIdOf=nr.hashValue=nr.hash=void 0;var Cd=fi(),gm=bm(lo()),mm=Ps(),Gi=Yt();function sn(t){return(0,Gi.uint8ToBuf)(mm.sha256.create().update(new Uint8Array(t)).digest())}nr.hash=sn;function Yi(t){if(t instanceof gm.default.Tagged)return Yi(t.value);if(typeof t=="string")return qd(t);if(typeof t=="number")return sn((0,Cd.lebEncode)(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return sn(t);if(Array.isArray(t)){let e=t.map(Yi);return sn((0,Gi.concat)(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return sn(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return Yi(t.toHash());if(typeof t=="object")return zc(t);if(typeof t=="bigint")return sn((0,Cd.lebEncode)(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}nr.hashValue=Yi;var qd=t=>{let e=new TextEncoder().encode(t);return sn(e)};function _m(t){return zc(t)}nr.requestIdOf=_m;function zc(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=qd(o),f=Yi(a);return[c,f]}).sort(([o],[a])=>(0,Gi.compare)(o,a)),i=(0,Gi.concat)(...n.map(o=>(0,Gi.concat)(...o)));return sn(i)}nr.hashOfMap=zc});var Xc=L(Br=>{"use strict";var wm=Br&&Br.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};Object.defineProperty(Br,"__esModule",{value:!0});Br.createIdentityDescriptor=Br.AnonymousIdentity=Br.SignIdentity=void 0;var jd=Nt(),Em=Wi(),kd=Yt(),xm=new TextEncoder().encode(`
16
+ ic-request`),Dc=class{getPrincipal(){return this._principal||(this._principal=jd.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=wm(e,["body"]),i=await(0,Em.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,kd.concat)(xm,i))}})}};Br.SignIdentity=Dc;var Zc=class{getPrincipal(){return jd.Principal.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};Br.AnonymousIdentity=Zc;function vm(t){return"getPublicKey"in t?{type:"PublicKeyIdentity",publicKey:(0,kd.toHex)(t.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}Br.createIdentityDescriptor=vm});var Qc=L($e=>{"use strict";Object.defineProperty($e,"__esModule",{value:!0});var Tm=9007199254740992;function Yr(t,...e){let r=new Uint8Array(t.byteLength+e.reduce((i,s)=>i+s.byteLength,0));r.set(new Uint8Array(t),0);let n=t.byteLength;for(let i of e)r.set(new Uint8Array(i),n),n+=i.byteLength;return r.buffer}function lr(t,e,r){r=r.replace(/[^0-9a-fA-F]/g,"");let n=2**(e-24);r=r.slice(-n*2).padStart(n*2,"0");let i=[(t<<5)+e].concat(r.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function ho(t,e){if(e<24)return new Uint8Array([(t<<5)+e]).buffer;{let r=e<=255?24:e<=65535?25:e<=4294967295?26:27;return lr(t,r,e.toString(16))}}function Vd(t){let e=[];for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);n<128?e.push(n):n<2048?e.push(192|n>>6,128|n&63):n<55296||n>=57344?e.push(224|n>>12,128|n>>6&63,128|n&63):(r++,n=(n&1023)<<10|t.charCodeAt(r)&1023,e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return Yr(new Uint8Array(ho(3,t.length)),new Uint8Array(e))}function Sm(t,e){if(t==14277111)return Yr(new Uint8Array([217,217,247]),e);if(t<24)return Yr(new Uint8Array([192+t]),e);{let r=t<=255?24:t<=65535?25:t<=4294967295?26:27,n=2**(r-24),i=t.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+r].concat(i.match(/../g).map(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}$e.tagged=Sm;function zi(t){return new Uint8Array(t).buffer}$e.raw=zi;function Jc(t){if(isNaN(t))throw new RangeError("Invalid number.");t=Math.min(Math.max(0,t),23);let e=[0+t];return new Uint8Array(e).buffer}$e.uSmall=Jc;function Hd(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),255),t=t.toString(16),lr(0,24,t)}$e.u8=Hd;function $d(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),65535),t=t.toString(16),lr(0,25,t)}$e.u16=$d;function Kd(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),4294967295),t=t.toString(16),lr(0,26,t)}$e.u32=Kd;function Lc(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return lr(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),Tm),t=t.toString(16),lr(0,27,t)}$e.u64=Lc;function Gd(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return Jc(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}$e.iSmall=Gd;function Yd(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),255),t=t.toString(16),lr(1,24,t)}$e.i8=Yd;function Wd(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),65535),t=t.toString(16),lr(1,25,t)}$e.i16=Wd;function zd(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),4294967295),t=t.toString(16),lr(1,26,t)}$e.i32=zd;function Dd(t,e){if(typeof t=="string"&&e==16){if(t.startsWith("-")?t=t.slice(1):t="0",t.match(/[^0-9a-fA-F]/)||t.length>16)throw new RangeError("Invalid number.");let r=!1,n=t.split("").reduceRight((i,s)=>{if(r)return s+i;let o=parseInt(s,16)-1;return o>=0?(r=!0,o.toString(16)+i):"f"+i},"");return r?lr(1,27,n):Lc(0)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),9007199254740992),t=t.toString(16),lr(1,27,t)}$e.i64=Dd;function Bm(t){return t>=0?t<24?Jc(t):t<=255?Hd(t):t<=65535?$d(t):t<=4294967295?Kd(t):Lc(t):t>=-24?Gd(t):t>=-255?Yd(t):t>=-65535?Wd(t):t>=-4294967295?zd(t):Dd(t)}$e.number=Bm;function Am(t){return Yr(ho(2,t.byteLength),t)}$e.bytes=Am;function Om(t){return Vd(t)}$e.string=Om;function Nm(t){return Yr(ho(4,t.length),...t)}$e.array=Nm;function Rm(t,e=!1){t instanceof Map||(t=new Map(Object.entries(t)));let r=Array.from(t.entries());return e&&(r=r.sort(([n],[i])=>n.localeCompare(i))),Yr(ho(5,t.size),...r.map(([n,i])=>Yr(Vd(n),i)))}$e.map=Rm;function Pm(t){let e=new Float32Array([t]);return Yr(new Uint8Array([250]),new Uint8Array(e.buffer))}$e.singleFloat=Pm;function Im(t){let e=new Float64Array([t]);return Yr(new Uint8Array([251]),new Uint8Array(e.buffer))}$e.doubleFloat=Im;function Um(t){return t?Zd():Xd()}$e.bool=Um;function Zd(){return zi(new Uint8Array([245]))}$e.true_=Zd;function Xd(){return zi(new Uint8Array([244]))}$e.false_=Xd;function Fm(){return zi(new Uint8Array([246]))}$e.null_=Fm;function Mm(){return zi(new Uint8Array([247]))}$e.undefined_=Mm});var Jd=L(on=>{"use strict";var Cm=on&&on.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(on,"__esModule",{value:!0});var fr=Cm(Qc()),qm=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],po=class{constructor(e,r=!1){this._serializer=e,this._stable=r,this.name="jsonDefault",this.priority=-100}match(e){return["undefined","boolean","number","string","object"].indexOf(typeof e)!=-1}encode(e){switch(typeof e){case"undefined":return fr.undefined_();case"boolean":return fr.bool(e);case"number":return Math.floor(e)===e?fr.number(e):fr.doubleFloat(e);case"string":return fr.string(e);case"object":if(e===null)return fr.null_();if(Array.isArray(e))return fr.array(e.map(r=>this._serializer.serializeValue(r)));if(qm.find(r=>e instanceof r))return fr.bytes(e.buffer);if(Object.getOwnPropertyNames(e).indexOf("toJSON")!==-1)return this.encode(e.toJSON());if(e instanceof Map){let r=new Map;for(let[n,i]of e.entries())r.set(n,this._serializer.serializeValue(i));return fr.map(r,this._stable)}else{let r=new Map;for(let[n,i]of Object.entries(e))r.set(n,this._serializer.serializeValue(i));return fr.map(r,this._stable)}default:throw new Error("Invalid value.")}}};on.JsonDefaultCborEncoder=po;var yo=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};on.ToCborEncoder=yo;var bo=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new po(r,e)),r.addEncoder(new yo),r}removeEncoder(e){for(let r of this._encoders.values())r.name==e&&this._encoders.delete(r)}addEncoder(e){this._encoders.add(e)}getEncoderFor(e){let r=null;for(let n of this._encoders)(!r||n.priority>r.priority)&&n.match(e)&&(r=n);if(r===null)throw new Error("Could not find an encoder for value.");return r}serializeValue(e){return this.getEncoderFor(e).encode(e)}serialize(e){return this.serializeValue(e)}};on.CborSerializer=bo;var eu=class extends bo{serialize(e){return fr.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};on.SelfDescribeCborSerializer=eu});var Di=L(Rn=>{"use strict";function jm(t){for(var e in t)Rn.hasOwnProperty(e)||(Rn[e]=t[e])}var km=Rn&&Rn.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(Rn,"__esModule",{value:!0});jm(Jd());var Vm=km(Qc());Rn.value=Vm});var Zi=L(mt=>{"use strict";var Hm=mt&&mt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),$m=mt&&mt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Km=mt&&mt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Hm(e,t,r);return $m(e,t),e},Gm=mt&&mt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(mt,"__esModule",{value:!0});mt.decode=mt.encode=mt.CborTag=void 0;var Ym=Gm(lo()),pi=Km(Di()),Wm=Di(),go=Yt(),tu=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return pi.value.bytes(e.toUint8Array())}},ru=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return pi.value.bytes(new Uint8Array(e))}},nu=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?pi.value.tagged(2,pi.value.bytes((0,go.fromHex)(e.toString(16)))):pi.value.tagged(3,pi.value.bytes((0,go.fromHex)((BigInt("-1")*e).toString(16))))}},mo=Wm.SelfDescribeCborSerializer.withDefaultEncoders(!0);mo.addEncoder(new tu);mo.addEncoder(new ru);mo.addEncoder(new nu);var Qd;(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(Qd=mt.CborTag||(mt.CborTag={}));function zm(t){return mo.serialize(t)}mt.encode=zm;function Ld(t){let e=t.byteLength,r=BigInt(0);for(let n=0;n<e;n++)r=r*BigInt(256)+BigInt(t[n]);return r}var iu=class extends Ym.default.Decoder{createByteString(e){return(0,go.concat)(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}};function Dm(t){let e=new Uint8Array(t),r=new iu({size:e.byteLength,tags:{2:n=>Ld(n),3:n=>-Ld(n),[Qd.Semantic]:n=>n}});try{return r.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,go.toHex)(e)}`)}}mt.decode=Dm});var su=L(_o=>{"use strict";Object.defineProperty(_o,"__esModule",{value:!0});_o.randomNumber=void 0;var Zm=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let t=new Uint32Array(1);return window.crypto.getRandomValues(t),t[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let t=new Uint32Array(1);return crypto.getRandomValues(t),t[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};_o.randomNumber=Zm});var Xi=L(Pn=>{"use strict";Object.defineProperty(Pn,"__esModule",{value:!0});Pn.makeNonce=Pn.SubmitRequestType=void 0;var wo=su(),Xm;(function(t){t.Call="call"})(Xm=Pn.SubmitRequestType||(Pn.SubmitRequestType={}));function Jm(){let t=new ArrayBuffer(16),e=new DataView(t),r=(0,wo.randomNumber)(),n=(0,wo.randomNumber)(),i=(0,wo.randomNumber)(),s=(0,wo.randomNumber)();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}Pn.makeNonce=Jm});var xo=L(St=>{"use strict";var Lm=St&&St.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Qm=St&&St.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),e_=St&&St.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Lm(e,t,r);return Qm(e,t),e};Object.defineProperty(St,"__esModule",{value:!0});St.httpHeadersTransform=St.makeExpiryTransform=St.makeNonceTransform=St.Expiry=void 0;var t_=fi(),r_=e_(Di()),n_=Xi(),i_=BigInt(1e6),s_=60*1e3,Eo=class{constructor(e){let s=BigInt(Math.floor(Date.now()+e-s_))*i_/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return r_.value.u64(this._value.toString(16),16)}toHash(){return(0,t_.lebEncode)(this._value)}};St.Expiry=Eo;function o_(t=n_.makeNonce){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}St.makeNonceTransform=o_;function a_(t){return async e=>{e.body.ingress_expiry=new Eo(t)}}St.makeExpiryTransform=a_;function c_(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}St.httpHeadersTransform=c_});var au=L(vo=>{"use strict";Object.defineProperty(vo,"__esModule",{value:!0});vo.AgentHTTPResponseError=void 0;var u_=ii(),ou=class extends u_.AgentError{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};vo.AgentHTTPResponseError=ou});var Wt=L(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.notImplemented=Pe.bitMask=void 0;Pe.isBytes=So;Pe.abytes=Bo;Pe.abool=f_;Pe.bytesToHex=fu;Pe.numberToHexUnpadded=r0;Pe.hexToNumber=du;Pe.hexToBytes=Ao;Pe.bytesToNumberBE=h_;Pe.bytesToNumberLE=p_;Pe.numberToBytesBE=n0;Pe.numberToBytesLE=y_;Pe.numberToVarBytesBE=b_;Pe.ensureBytes=g_;Pe.concatBytes=i0;Pe.equalBytes=m_;Pe.utf8ToBytes=__;Pe.inRange=s0;Pe.aInRange=w_;Pe.bitLen=E_;Pe.bitGet=x_;Pe.bitSet=v_;Pe.createHmacDrbg=S_;Pe.validateObject=A_;Pe.memoized=N_;var lu=BigInt(0),To=BigInt(1),l_=BigInt(2);function So(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Bo(t){if(!So(t))throw new Error("Uint8Array expected")}function f_(t,e){if(typeof e!="boolean")throw new Error(`${t} must be valid boolean, got "${e}".`)}var d_=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function fu(t){Bo(t);let e="";for(let r=0;r<t.length;r++)e+=d_[t[r]];return e}function r0(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function du(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var Wr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function e0(t){if(t>=Wr._0&&t<=Wr._9)return t-Wr._0;if(t>=Wr._A&&t<=Wr._F)return t-(Wr._A-10);if(t>=Wr._a&&t<=Wr._f)return t-(Wr._a-10)}function Ao(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=e0(t.charCodeAt(s)),a=e0(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function h_(t){return du(fu(t))}function p_(t){return Bo(t),du(fu(Uint8Array.from(t).reverse()))}function n0(t,e){return Ao(t.toString(16).padStart(e*2,"0"))}function y_(t,e){return n0(t,e).reverse()}function b_(t){return Ao(r0(t))}function g_(t,e,r){let n;if(typeof e=="string")try{n=Ao(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(So(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function i0(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];Bo(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}function m_(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function __(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}var cu=t=>typeof t=="bigint"&&lu<=t;function s0(t,e,r){return cu(t)&&cu(e)&&cu(r)&&e<=t&&t<r}function w_(t,e,r,n){if(!s0(e,r,n))throw new Error(`expected valid ${t}: ${r} <= n < ${n}, got ${typeof e} ${e}`)}function E_(t){let e;for(e=0;t>lu;t>>=To,e+=1);return e}function x_(t,e){return t>>BigInt(e)&To}function v_(t,e,r){return t|(r?To:lu)<<BigInt(e)}var T_=t=>(l_<<BigInt(t-1))-To;Pe.bitMask=T_;var uu=t=>new Uint8Array(t),t0=t=>Uint8Array.from(t);function S_(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=uu(t),i=uu(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...h)=>r(i,n,...h),c=(h=uu())=>{i=a(t0([0]),h),n=a(),h.length!==0&&(i=a(t0([1]),h),n=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0,B=[];for(;h<e;){n=a();let w=n.slice();B.push(w),h+=n.length}return i0(...B)};return(h,B)=>{o(),c(h);let w;for(;!(w=B(f()));)c();return o(),w}}var B_={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||So(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function A_(t,e,r={}){let n=(i,s,o)=>{let a=B_[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return t}var O_=()=>{throw new Error("not implemented")};Pe.notImplemented=O_;function N_(t){let e=new WeakMap;return(r,...n)=>{let i=e.get(r);if(i!==void 0)return i;let s=t(r,...n);return e.set(r,s),s}}});var Ar=L(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.isNegativeLE=void 0;ze.mod=zt;ze.pow=c0;ze.pow2=U_;ze.invert=Oo;ze.tonelliShanks=u0;ze.FpSqrt=l0;ze.validateField=C_;ze.FpPow=f0;ze.FpInvertBatch=d0;ze.FpDiv=q_;ze.FpLegendre=h0;ze.FpIsSquare=j_;ze.nLength=pu;ze.Field=k_;ze.FpSqrtOdd=V_;ze.FpSqrtEven=H_;ze.hashToPrivateScalar=$_;ze.getFieldBytesLength=yu;ze.getMinHashLength=p0;ze.mapHashToField=K_;var Dt=Wt(),ot=BigInt(0),Ve=BigInt(1),an=BigInt(2),R_=BigInt(3),hu=BigInt(4),o0=BigInt(5),a0=BigInt(8),P_=BigInt(9),I_=BigInt(16);function zt(t,e){let r=t%e;return r>=ot?r:e+r}function c0(t,e,r){if(r<=ot||e<ot)throw new Error("Expected power/modulo > 0");if(r===Ve)return ot;let n=Ve;for(;e>ot;)e&Ve&&(n=n*t%r),t=t*t%r,e>>=Ve;return n}function U_(t,e,r){let n=t;for(;e-- >ot;)n*=n,n%=r;return n}function Oo(t,e){if(t===ot||e<=ot)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=zt(t,e),n=e,i=ot,s=Ve,o=Ve,a=ot;for(;r!==ot;){let f=n/r,d=n%r,h=i-o*f,B=s-a*f;n=r,r=d,i=o,s=a,o=h,a=B}if(n!==Ve)throw new Error("invert: does not exist");return zt(i,e)}function u0(t){let e=(t-Ve)/an,r,n,i;for(r=t-Ve,n=0;r%an===ot;r/=an,n++);for(i=an;i<t&&c0(i,e,t)!==t-Ve;i++);if(n===1){let o=(t+Ve)/hu;return function(c,f){let d=c.pow(f,o);if(!c.eql(c.sqr(d),f))throw new Error("Cannot find square root");return d}}let s=(r+Ve)/an;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,d=a.pow(a.mul(a.ONE,i),r),h=a.pow(c,s),B=a.pow(c,r);for(;!a.eql(B,a.ONE);){if(a.eql(B,a.ZERO))return a.ZERO;let w=1;for(let g=a.sqr(B);w<f&&!a.eql(g,a.ONE);w++)g=a.sqr(g);let u=a.pow(d,Ve<<BigInt(f-w-1));d=a.sqr(u),h=a.mul(h,u),B=a.mul(B,d),f=w}return h}}function l0(t){if(t%hu===R_){let e=(t+Ve)/hu;return function(n,i){let s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(t%a0===o0){let e=(t-o0)/a0;return function(n,i){let s=n.mul(i,an),o=n.pow(s,e),a=n.mul(i,o),c=n.mul(n.mul(a,an),o),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),i))throw new Error("Cannot find square root");return f}}return t%I_,u0(t)}var F_=(t,e)=>(zt(t,e)&Ve)===Ve;ze.isNegativeLE=F_;var M_=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function C_(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=M_.reduce((n,i)=>(n[i]="function",n),e);return(0,Dt.validateObject)(t,r)}function f0(t,e,r){if(r<ot)throw new Error("Expected power > 0");if(r===ot)return t.ONE;if(r===Ve)return e;let n=t.ONE,i=e;for(;r>ot;)r&Ve&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Ve;return n}function d0(t,e){let r=new Array(e.length),n=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),i=t.inv(n);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),i),r}function q_(t,e,r){return t.mul(e,typeof r=="bigint"?Oo(r,t.ORDER):t.inv(r))}function h0(t){let e=(t-Ve)/an;return(r,n)=>r.pow(n,e)}function j_(t){let e=h0(t.ORDER);return r=>{let n=e(t,r);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}}function pu(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function k_(t,e,r=!1,n={}){if(t<=ot)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=pu(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=l0(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:(0,Dt.bitMask)(i),ZERO:ot,ONE:Ve,create:c=>zt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ot<=c&&c<t},is0:c=>c===ot,isOdd:c=>(c&Ve)===Ve,neg:c=>zt(-c,t),eql:(c,f)=>c===f,sqr:c=>zt(c*c,t),add:(c,f)=>zt(c+f,t),sub:(c,f)=>zt(c-f,t),mul:(c,f)=>zt(c*f,t),pow:(c,f)=>f0(a,c,f),div:(c,f)=>zt(c*Oo(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Oo(c,t),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>d0(a,c),cmov:(c,f,d)=>d?f:c,toBytes:c=>r?(0,Dt.numberToBytesLE)(c,s):(0,Dt.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,Dt.bytesToNumberLE)(c):(0,Dt.bytesToNumberBE)(c)}});return Object.freeze(a)}function V_(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?r:t.neg(r)}function H_(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function $_(t,e,r=!1){t=(0,Dt.ensureBytes)("privateHash",t);let n=t.length,i=pu(e).nByteLength+8;if(i<24||n<i||n>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${n}`);let s=r?(0,Dt.bytesToNumberLE)(t):(0,Dt.bytesToNumberBE)(t);return zt(s,e-Ve)+Ve}function yu(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function p0(t){let e=yu(t);return e+Math.ceil(e/2)}function K_(t,e,r=!1){let n=t.length,i=yu(e),s=p0(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?(0,Dt.bytesToNumberBE)(t):(0,Dt.bytesToNumberLE)(t),a=zt(o,e-Ve)+Ve;return r?(0,Dt.numberToBytesLE)(a,i):(0,Dt.numberToBytesBE)(a,i)}});var No=L(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});In.expand_message_xmd=y0;In.expand_message_xof=b0;In.hash_to_field=bu;In.isogenyMap=z_;In.createHasher=D_;var G_=Ar(),Bt=Wt(),Y_=Bt.bytesToNumberBE;function cn(t,e){if(t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);let r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=t&255,t>>>=8;return new Uint8Array(r)}function W_(t,e){let r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function gu(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function y0(t,e,r,n){(0,Bt.abytes)(t),(0,Bt.abytes)(e),gu(r),e.length>255&&(e=n((0,Bt.concatBytes)((0,Bt.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(r/i);if(o>255)throw new Error("Invalid xmd length");let a=(0,Bt.concatBytes)(e,cn(e.length,1)),c=cn(0,s),f=cn(r,2),d=new Array(o),h=n((0,Bt.concatBytes)(c,t,f,cn(0,1),a));d[0]=n((0,Bt.concatBytes)(h,cn(1,1),a));for(let w=1;w<=o;w++){let u=[W_(h,d[w-1]),cn(w+1,1),a];d[w]=n((0,Bt.concatBytes)(...u))}return(0,Bt.concatBytes)(...d).slice(0,r)}function b0(t,e,r,n,i){if((0,Bt.abytes)(t),(0,Bt.abytes)(e),gu(r),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update((0,Bt.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(t).update(cn(r,2)).update(e).update(cn(e.length,1)).digest()}function bu(t,e,r){(0,Bt.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:a,DST:c}=r;(0,Bt.abytes)(t),gu(e);let f=typeof c=="string"?(0,Bt.utf8ToBytes)(c):c,d=n.toString(2).length,h=Math.ceil((d+i)/8),B=e*s*h,w;if(a==="xmd")w=y0(t,f,B,o);else if(a==="xof")w=b0(t,f,B,i,o);else if(a==="_internal_pass")w=t;else throw new Error('expand must be "xmd" or "xof"');let u=new Array(e);for(let g=0;g<e;g++){let U=new Array(s);for(let F=0;F<s;F++){let N=h*(F+g*s),V=w.subarray(N,N+h);U[F]=(0,G_.mod)(Y_(V),n)}u[g]=U}return u}function z_(t,e){let r=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,a,c]=r.map(f=>f.reduce((d,h)=>t.add(t.mul(d,n),h)));return n=t.div(s,o),i=t.mul(i,t.div(a,c)),{x:n,y:i}}}function D_(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=bu(n,2,{...r,DST:r.DST,...i}),o=t.fromAffine(e(s[0])),a=t.fromAffine(e(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=bu(n,1,{...r,DST:r.encodeDST,...i}),o=t.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(let s of n)if(typeof s!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${s} in array`);let i=t.fromAffine(e(n)).clearCofactor();return i.assertValidity(),i}}}});var wu=L(Ro=>{"use strict";Object.defineProperty(Ro,"__esModule",{value:!0});Ro.wNAF=J_;Ro.validateBasic=L_;var g0=Ar(),Z_=Wt(),X_=BigInt(0),mu=BigInt(1),_u=new WeakMap,m0=new WeakMap;function J_(t,e){let r=(s,o)=>{let a=o.negate();return s?a:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error(`Wrong window size=${s}, should be [1..${e}]`)},i=s=>{n(s);let o=Math.ceil(e/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:r,unsafeLadder(s,o){let a=t.ZERO,c=s;for(;o>X_;)o&mu&&(a=a.add(c)),c=c.double(),o>>=mu;return a},precomputeWindow(s,o){let{windows:a,windowSize:c}=i(o),f=[],d=s,h=d;for(let B=0;B<a;B++){h=d,f.push(h);for(let w=1;w<c;w++)h=h.add(d),f.push(h);d=h.double()}return f},wNAF(s,o,a){let{windows:c,windowSize:f}=i(s),d=t.ZERO,h=t.BASE,B=BigInt(2**s-1),w=2**s,u=BigInt(s);for(let g=0;g<c;g++){let U=g*f,F=Number(a&B);a>>=u,F>f&&(F-=w,a+=mu);let N=U,V=U+Math.abs(F)-1,W=g%2!==0,T=F<0;F===0?h=h.add(r(W,o[N])):d=d.add(r(T,o[V]))}return{p:d,f:h}},wNAFCached(s,o,a){let c=m0.get(s)||1,f=_u.get(s);return f||(f=this.precomputeWindow(s,c),c!==1&&_u.set(s,a(f))),this.wNAF(c,f,o)},setWindowSize(s,o){n(o),m0.set(s,o),_u.delete(s)}}}function L_(t){return(0,g0.validateField)(t.Fp),(0,Z_.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,g0.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}});var xu=L(Pt=>{"use strict";Object.defineProperty(Pt,"__esModule",{value:!0});Pt.DER=void 0;Pt.weierstrassPoints=E0;Pt.weierstrass=n1;Pt.SWUFpSqrtRatio=x0;Pt.mapToCurveSimpleSWU=i1;var Eu=wu(),yi=Ar(),Ne=Wt(),_t=Wt();function _0(t){t.lowS!==void 0&&(0,_t.abool)("lowS",t.lowS),t.prehash!==void 0&&(0,_t.abool)("prehash",t.prehash)}function Q_(t){let e=(0,Eu.validateBasic)(t);Ne.validateObject(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:e1,hexToBytes:t1}=Ne;Pt.DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=Pt.DER;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");let r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:e1(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=Pt.DER,r=typeof t=="string"?t1(t):t;Ne.abytes(r);let n=r.length;if(n<2||r[0]!=48)throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:i,l:s}=Pt.DER._parseInt(r.subarray(2)),{d:o,l:a}=Pt.DER._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(t){let e=f=>Number.parseInt(f[0],16)&8?"00"+f:f,r=f=>{let d=f.toString(16);return d.length&1?`0${d}`:d},n=e(r(t.s)),i=e(r(t.r)),s=n.length/2,o=i.length/2,a=r(s),c=r(o);return`30${r(o+s+4)}02${c}${i}02${a}${n}`}};var Or=BigInt(0),qe=BigInt(1),un=BigInt(2),Po=BigInt(3),w0=BigInt(4);function E0(t){let e=Q_(t),{Fp:r}=e,n=e.toBytes||((u,g,U)=>{let F=g.toAffine();return Ne.concatBytes(Uint8Array.from([4]),r.toBytes(F.x),r.toBytes(F.y))}),i=e.fromBytes||(u=>{let g=u.subarray(1),U=r.fromBytes(g.subarray(0,r.BYTES)),F=r.fromBytes(g.subarray(r.BYTES,2*r.BYTES));return{x:U,y:F}});function s(u){let{a:g,b:U}=e,F=r.sqr(u),N=r.mul(F,u);return r.add(r.add(N,r.mul(u,g)),U)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(u){return Ne.inRange(u,qe,e.n)}function a(u){let{allowedPrivateKeyLengths:g,nByteLength:U,wrapPrivateKey:F,n:N}=e;if(g&&typeof u!="bigint"){if(Ne.isBytes(u)&&(u=Ne.bytesToHex(u)),typeof u!="string"||!g.includes(u.length))throw new Error("Invalid key");u=u.padStart(U*2,"0")}let V;try{V=typeof u=="bigint"?u:Ne.bytesToNumberBE((0,_t.ensureBytes)("private key",u,U))}catch{throw new Error(`private key must be ${U} bytes, hex or bigint, not ${typeof u}`)}return F&&(V=yi.mod(V,N)),Ne.aInRange("private key",V,qe,N),V}function c(u){if(!(u instanceof h))throw new Error("ProjectivePoint expected")}let f=(0,_t.memoized)((u,g)=>{let{px:U,py:F,pz:N}=u;if(r.eql(N,r.ONE))return{x:U,y:F};let V=u.is0();g==null&&(g=V?r.ONE:r.inv(N));let W=r.mul(U,g),T=r.mul(F,g),C=r.mul(N,g);if(V)return{x:r.ZERO,y:r.ZERO};if(!r.eql(C,r.ONE))throw new Error("invZ was invalid");return{x:W,y:T}}),d=(0,_t.memoized)(u=>{if(u.is0()){if(e.allowInfinityPoint&&!r.is0(u.py))return;throw new Error("bad point: ZERO")}let{x:g,y:U}=u.toAffine();if(!r.isValid(g)||!r.isValid(U))throw new Error("bad point: x or y not FE");let F=r.sqr(U),N=s(g);if(!r.eql(F,N))throw new Error("bad point: equation left != right");if(!u.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(g,U,F){if(this.px=g,this.py=U,this.pz=F,g==null||!r.isValid(g))throw new Error("x required");if(U==null||!r.isValid(U))throw new Error("y required");if(F==null||!r.isValid(F))throw new Error("z required");Object.freeze(this)}static fromAffine(g){let{x:U,y:F}=g||{};if(!g||!r.isValid(U)||!r.isValid(F))throw new Error("invalid affine point");if(g instanceof h)throw new Error("projective point not allowed");let N=V=>r.eql(V,r.ZERO);return N(U)&&N(F)?h.ZERO:new h(U,F,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){let U=r.invertBatch(g.map(F=>F.pz));return g.map((F,N)=>F.toAffine(U[N])).map(h.fromAffine)}static fromHex(g){let U=h.fromAffine(i((0,_t.ensureBytes)("pointHex",g)));return U.assertValidity(),U}static fromPrivateKey(g){return h.BASE.multiply(a(g))}_setWindowSize(g){w.setWindowSize(this,g)}assertValidity(){d(this)}hasEvenY(){let{y:g}=this.toAffine();if(r.isOdd)return!r.isOdd(g);throw new Error("Field doesn't support isOdd")}equals(g){c(g);let{px:U,py:F,pz:N}=this,{px:V,py:W,pz:T}=g,C=r.eql(r.mul(U,T),r.mul(V,N)),z=r.eql(r.mul(F,T),r.mul(W,N));return C&&z}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){let{a:g,b:U}=e,F=r.mul(U,Po),{px:N,py:V,pz:W}=this,T=r.ZERO,C=r.ZERO,z=r.ZERO,D=r.mul(N,N),G=r.mul(V,V),ne=r.mul(W,W),Q=r.mul(N,V);return Q=r.add(Q,Q),z=r.mul(N,W),z=r.add(z,z),T=r.mul(g,z),C=r.mul(F,ne),C=r.add(T,C),T=r.sub(G,C),C=r.add(G,C),C=r.mul(T,C),T=r.mul(Q,T),z=r.mul(F,z),ne=r.mul(g,ne),Q=r.sub(D,ne),Q=r.mul(g,Q),Q=r.add(Q,z),z=r.add(D,D),D=r.add(z,D),D=r.add(D,ne),D=r.mul(D,Q),C=r.add(C,D),ne=r.mul(V,W),ne=r.add(ne,ne),D=r.mul(ne,Q),T=r.sub(T,D),z=r.mul(ne,G),z=r.add(z,z),z=r.add(z,z),new h(T,C,z)}add(g){c(g);let{px:U,py:F,pz:N}=this,{px:V,py:W,pz:T}=g,C=r.ZERO,z=r.ZERO,D=r.ZERO,G=e.a,ne=r.mul(e.b,Po),Q=r.mul(U,V),le=r.mul(F,W),E=r.mul(N,T),_=r.add(U,F),m=r.add(V,W);_=r.mul(_,m),m=r.add(Q,le),_=r.sub(_,m),m=r.add(U,N);let x=r.add(V,T);return m=r.mul(m,x),x=r.add(Q,E),m=r.sub(m,x),x=r.add(F,N),C=r.add(W,T),x=r.mul(x,C),C=r.add(le,E),x=r.sub(x,C),D=r.mul(G,m),C=r.mul(ne,E),D=r.add(C,D),C=r.sub(le,D),D=r.add(le,D),z=r.mul(C,D),le=r.add(Q,Q),le=r.add(le,Q),E=r.mul(G,E),m=r.mul(ne,m),le=r.add(le,E),E=r.sub(Q,E),E=r.mul(G,E),m=r.add(m,E),Q=r.mul(le,m),z=r.add(z,Q),Q=r.mul(x,m),C=r.mul(_,C),C=r.sub(C,Q),Q=r.mul(_,le),D=r.mul(x,D),D=r.add(D,Q),new h(C,z,D)}subtract(g){return this.add(g.negate())}is0(){return this.equals(h.ZERO)}wNAF(g){return w.wNAFCached(this,g,h.normalizeZ)}multiplyUnsafe(g){Ne.aInRange("scalar",g,Or,e.n);let U=h.ZERO;if(g===Or)return U;if(g===qe)return this;let{endo:F}=e;if(!F)return w.unsafeLadder(this,g);let{k1neg:N,k1:V,k2neg:W,k2:T}=F.splitScalar(g),C=U,z=U,D=this;for(;V>Or||T>Or;)V&qe&&(C=C.add(D)),T&qe&&(z=z.add(D)),D=D.double(),V>>=qe,T>>=qe;return N&&(C=C.negate()),W&&(z=z.negate()),z=new h(r.mul(z.px,F.beta),z.py,z.pz),C.add(z)}multiply(g){let{endo:U,n:F}=e;Ne.aInRange("scalar",g,qe,F);let N,V;if(U){let{k1neg:W,k1:T,k2neg:C,k2:z}=U.splitScalar(g),{p:D,f:G}=this.wNAF(T),{p:ne,f:Q}=this.wNAF(z);D=w.constTimeNegate(W,D),ne=w.constTimeNegate(C,ne),ne=new h(r.mul(ne.px,U.beta),ne.py,ne.pz),N=D.add(ne),V=G.add(Q)}else{let{p:W,f:T}=this.wNAF(g);N=W,V=T}return h.normalizeZ([N,V])[0]}multiplyAndAddUnsafe(g,U,F){let N=h.BASE,V=(T,C)=>C===Or||C===qe||!T.equals(N)?T.multiplyUnsafe(C):T.multiply(C),W=V(this,U).add(V(g,F));return W.is0()?void 0:W}toAffine(g){return f(this,g)}isTorsionFree(){let{h:g,isTorsionFree:U}=e;if(g===qe)return!0;if(U)return U(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:g,clearCofactor:U}=e;return g===qe?this:U?U(h,this):this.multiplyUnsafe(e.h)}toRawBytes(g=!0){return(0,_t.abool)("isCompressed",g),this.assertValidity(),n(h,this,g)}toHex(g=!0){return(0,_t.abool)("isCompressed",g),Ne.bytesToHex(this.toRawBytes(g))}}h.BASE=new h(e.Gx,e.Gy,r.ONE),h.ZERO=new h(r.ZERO,r.ONE,r.ZERO);let B=e.nBitLength,w=(0,Eu.wNAF)(h,e.endo?Math.ceil(B/2):B);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:o}}function r1(t){let e=(0,Eu.validateBasic)(t);return Ne.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function n1(t){let e=r1(t),{Fp:r,n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function o(_){return yi.mod(_,n)}function a(_){return yi.invert(_,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:d,isWithinCurveOrder:h}=E0({...e,toBytes(_,m,x){let j=m.toAffine(),H=r.toBytes(j.x),X=Ne.concatBytes;return(0,_t.abool)("isCompressed",x),x?X(Uint8Array.from([m.hasEvenY()?2:3]),H):X(Uint8Array.from([4]),H,r.toBytes(j.y))},fromBytes(_){let m=_.length,x=_[0],j=_.subarray(1);if(m===i&&(x===2||x===3)){let H=Ne.bytesToNumberBE(j);if(!Ne.inRange(H,qe,r.ORDER))throw new Error("Point is not on curve");let X=d(H),oe;try{oe=r.sqrt(X)}catch(P){let p=P instanceof Error?": "+P.message:"";throw new Error("Point is not on curve"+p)}let ae=(oe&qe)===qe;return(x&1)===1!==ae&&(oe=r.neg(oe)),{x:H,y:oe}}else if(m===s&&x===4){let H=r.fromBytes(j.subarray(0,r.BYTES)),X=r.fromBytes(j.subarray(r.BYTES,2*r.BYTES));return{x:H,y:X}}else throw new Error(`Point of length ${m} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),B=_=>Ne.bytesToHex(Ne.numberToBytesBE(_,e.nByteLength));function w(_){let m=n>>qe;return _>m}function u(_){return w(_)?o(-_):_}let g=(_,m,x)=>Ne.bytesToNumberBE(_.slice(m,x));class U{constructor(m,x,j){this.r=m,this.s=x,this.recovery=j,this.assertValidity()}static fromCompact(m){let x=e.nByteLength;return m=(0,_t.ensureBytes)("compactSignature",m,x*2),new U(g(m,0,x),g(m,x,2*x))}static fromDER(m){let{r:x,s:j}=Pt.DER.toSig((0,_t.ensureBytes)("DER",m));return new U(x,j)}assertValidity(){Ne.aInRange("r",this.r,qe,n),Ne.aInRange("s",this.s,qe,n)}addRecoveryBit(m){return new U(this.r,this.s,m)}recoverPublicKey(m){let{r:x,s:j,recovery:H}=this,X=C((0,_t.ensureBytes)("msgHash",m));if(H==null||![0,1,2,3].includes(H))throw new Error("recovery id invalid");let oe=H===2||H===3?x+e.n:x;if(oe>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let ae=H&1?"03":"02",Y=c.fromHex(ae+B(oe)),P=a(oe),p=o(-X*P),ee=o(j*P),re=c.BASE.multiplyAndAddUnsafe(Y,p,ee);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new U(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Ne.hexToBytes(this.toDERHex())}toDERHex(){return Pt.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ne.hexToBytes(this.toCompactHex())}toCompactHex(){return B(this.r)+B(this.s)}}let F={isValidPrivateKey(_){try{return f(_),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let _=yi.getMinHashLength(e.n);return yi.mapHashToField(e.randomBytes(_),e.n)},precompute(_=8,m=c.BASE){return m._setWindowSize(_),m.multiply(BigInt(3)),m}};function N(_,m=!0){return c.fromPrivateKey(_).toRawBytes(m)}function V(_){let m=Ne.isBytes(_),x=typeof _=="string",j=(m||x)&&_.length;return m?j===i||j===s:x?j===2*i||j===2*s:_ instanceof c}function W(_,m,x=!0){if(V(_))throw new Error("first arg must be private key");if(!V(m))throw new Error("second arg must be public key");return c.fromHex(m).multiply(f(_)).toRawBytes(x)}let T=e.bits2int||function(_){let m=Ne.bytesToNumberBE(_),x=_.length*8-e.nBitLength;return x>0?m>>BigInt(x):m},C=e.bits2int_modN||function(_){return o(T(_))},z=Ne.bitMask(e.nBitLength);function D(_){return Ne.aInRange(`num < 2^${e.nBitLength}`,_,Or,z),Ne.numberToBytesBE(_,e.nByteLength)}function G(_,m,x=ne){if(["recovered","canonical"].some(J=>J in x))throw new Error("sign() legacy options not supported");let{hash:j,randomBytes:H}=e,{lowS:X,prehash:oe,extraEntropy:ae}=x;X==null&&(X=!0),_=(0,_t.ensureBytes)("msgHash",_),_0(x),oe&&(_=(0,_t.ensureBytes)("prehashed msgHash",j(_)));let Y=C(_),P=f(m),p=[D(P),D(Y)];if(ae!=null&&ae!==!1){let J=ae===!0?H(r.BYTES):ae;p.push((0,_t.ensureBytes)("extraEntropy",J))}let ee=Ne.concatBytes(...p),re=Y;function de(J){let l=T(J);if(!h(l))return;let y=a(l),b=c.BASE.multiply(l).toAffine(),R=o(b.x);if(R===Or)return;let A=o(y*o(re+R*P));if(A===Or)return;let O=(b.x===R?0:2)|Number(b.y&qe),q=A;return X&&w(A)&&(q=u(A),O^=1),new U(R,q,O)}return{seed:ee,k2sig:de}}let ne={lowS:e.lowS,prehash:!1},Q={lowS:e.lowS,prehash:!1};function le(_,m,x=ne){let{seed:j,k2sig:H}=G(_,m,x),X=e;return Ne.createHmacDrbg(X.hash.outputLen,X.nByteLength,X.hmac)(j,H)}c.BASE._setWindowSize(8);function E(_,m,x,j=Q){let H=_;if(m=(0,_t.ensureBytes)("msgHash",m),x=(0,_t.ensureBytes)("publicKey",x),"strict"in j)throw new Error("options.strict was renamed to lowS");_0(j);let{lowS:X,prehash:oe}=j,ae,Y;try{if(typeof H=="string"||Ne.isBytes(H))try{ae=U.fromDER(H)}catch(b){if(!(b instanceof Pt.DER.Err))throw b;ae=U.fromCompact(H)}else if(typeof H=="object"&&typeof H.r=="bigint"&&typeof H.s=="bigint"){let{r:b,s:R}=H;ae=new U(b,R)}else throw new Error("PARSE");Y=c.fromHex(x)}catch(b){if(b.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(X&&ae.hasHighS())return!1;oe&&(m=e.hash(m));let{r:P,s:p}=ae,ee=C(m),re=a(p),de=o(ee*re),J=o(P*re),l=c.BASE.multiplyAndAddUnsafe(Y,de,J)?.toAffine();return l?o(l.x)===P:!1}return{CURVE:e,getPublicKey:N,getSharedSecret:W,sign:le,verify:E,ProjectivePoint:c,Signature:U,utils:F}}function x0(t,e){let r=t.ORDER,n=Or;for(let u=r-qe;u%un===Or;u/=un)n+=qe;let i=n,s=un<<i-qe-qe,o=s*un,a=(r-qe)/o,c=(a-qe)/un,f=o-qe,d=s,h=t.pow(e,a),B=t.pow(e,(a+qe)/un),w=(u,g)=>{let U=h,F=t.pow(g,f),N=t.sqr(F);N=t.mul(N,g);let V=t.mul(u,N);V=t.pow(V,c),V=t.mul(V,F),F=t.mul(V,g),N=t.mul(V,u);let W=t.mul(N,F);V=t.pow(W,d);let T=t.eql(V,t.ONE);F=t.mul(N,B),V=t.mul(W,U),N=t.cmov(F,N,T),W=t.cmov(V,W,T);for(let C=i;C>qe;C--){let z=C-un;z=un<<z-qe;let D=t.pow(W,z),G=t.eql(D,t.ONE);F=t.mul(N,U),U=t.mul(U,U),D=t.mul(W,U),N=t.cmov(F,N,G),W=t.cmov(D,W,G)}return{isValid:T,value:N}};if(t.ORDER%w0===Po){let u=(t.ORDER-Po)/w0,g=t.sqrt(t.neg(e));w=(U,F)=>{let N=t.sqr(F),V=t.mul(U,F);N=t.mul(N,V);let W=t.pow(N,u);W=t.mul(W,V);let T=t.mul(W,g),C=t.mul(t.sqr(W),F),z=t.eql(C,U),D=t.cmov(T,W,z);return{isValid:z,value:D}}}return w}function i1(t,e){if(yi.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=x0(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,a,c,f,d,h;i=t.sqr(n),i=t.mul(i,e.Z),s=t.sqr(i),s=t.add(s,i),o=t.add(s,t.ONE),o=t.mul(o,e.B),a=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),a=t.mul(a,e.A),s=t.sqr(o),f=t.sqr(a),c=t.mul(f,e.A),s=t.add(s,c),s=t.mul(s,o),f=t.mul(f,a),c=t.mul(f,e.B),s=t.add(s,c),d=t.mul(i,o);let{isValid:B,value:w}=r(s,f);h=t.mul(i,n),h=t.mul(h,w),d=t.cmov(d,o,B),h=t.cmov(h,w,B);let u=t.isOdd(n)===t.isOdd(h);return h=t.cmov(t.neg(h),h,u),d=t.div(d,a),{x:d,y:h}}}});var A0=L(Tu=>{"use strict";Object.defineProperty(Tu,"__esModule",{value:!0});Tu.bls=a1;var v0=Ar(),vu=Wt(),T0=No(),S0=xu(),s1=BigInt(0),Io=BigInt(1),B0=BigInt(2),bi=BigInt(3);function o1(t){let e=[];for(;t>Io;t>>=Io)(t&Io)===s1?e.unshift(0):(t&bi)===bi?(e.unshift(-1),t+=Io):e.unshift(1);return e}function a1(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=t.params.xNegative,a=t.params.twistType,c=(0,S0.weierstrassPoints)({n:r.ORDER,...t.G1}),f=Object.assign(c,(0,T0.createHasher)(c.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults})),d=(0,S0.weierstrassPoints)({n:r.ORDER,...t.G2}),h=Object.assign(d,(0,T0.createHasher)(d.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),B;if(a==="multiplicative")B=(Y,P,p,ee,re,de)=>s.mul014(ee,Y,n.mul(P,re),n.mul(p,de));else if(a==="divisive")B=(Y,P,p,ee,re,de)=>s.mul034(ee,n.mul(p,de),n.mul(P,re),Y);else throw new Error("bls: unknown twist type");let w=n.div(n.ONE,n.mul(n.ONE,B0));function u(Y,P,p,ee){let re=n.sqr(p),de=n.sqr(ee),J=n.mulByB(n.mul(de,bi)),l=n.mul(J,bi),y=n.sub(n.sub(n.sqr(n.add(p,ee)),de),re),b=n.sub(J,re),R=n.mul(n.sqr(P),bi),A=n.neg(y);return Y.push([b,R,A]),P=n.mul(n.mul(n.mul(n.sub(re,l),P),p),w),p=n.sub(n.sqr(n.mul(n.add(re,l),w)),n.mul(n.sqr(J),bi)),ee=n.mul(re,y),{Rx:P,Ry:p,Rz:ee}}function g(Y,P,p,ee,re,de){let J=n.sub(p,n.mul(de,ee)),l=n.sub(P,n.mul(re,ee)),y=n.sub(n.mul(J,re),n.mul(l,de)),b=n.neg(J),R=l;Y.push([y,b,R]);let A=n.sqr(l),O=n.mul(A,l),q=n.mul(A,P),v=n.add(n.sub(O,n.mul(q,B0)),n.mul(n.sqr(J),ee));return P=n.mul(l,v),p=n.sub(n.mul(n.sub(q,v),J),n.mul(O,p)),ee=n.mul(ee,O),{Rx:P,Ry:p,Rz:ee}}let U=o1(t.params.ateLoopSize),F=(0,vu.memoized)(Y=>{let P=Y,{x:p,y:ee}=P.toAffine(),re=p,de=ee,J=n.neg(ee),l=re,y=de,b=n.ONE,R=[];for(let A of U){let O=[];({Rx:l,Ry:y,Rz:b}=u(O,l,y,b)),A&&({Rx:l,Ry:y,Rz:b}=g(O,l,y,b,re,A===-1?J:de)),R.push(O)}if(t.postPrecompute){let A=R[R.length-1];t.postPrecompute(l,y,b,re,de,g.bind(null,A))}return R});function N(Y,P=!1){let p=s.ONE;if(Y.length){let ee=Y[0][0].length;for(let re=0;re<ee;re++){p=s.sqr(p);for(let[de,J,l]of Y)for(let[y,b,R]of de[re])p=B(y,b,R,p,J,l)}}return o&&(p=s.conjugate(p)),P?s.finalExponentiate(p):p}function V(Y,P=!0){let p=[];f.ProjectivePoint.normalizeZ(Y.map(({g1:ee})=>ee)),h.ProjectivePoint.normalizeZ(Y.map(({g2:ee})=>ee));for(let{g1:ee,g2:re}of Y){if(ee.equals(f.ProjectivePoint.ZERO)||re.equals(h.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");ee.assertValidity(),re.assertValidity();let de=ee.toAffine();p.push([F(re),de.x,de.y])}return N(p,P)}function W(Y,P,p=!0){return V([{g1:Y,g2:P}],p)}let T={randomPrivateKey:()=>{let Y=(0,v0.getMinHashLength)(r.ORDER);return(0,v0.mapHashToField)(t.randomBytes(Y),r.ORDER)},calcPairingPrecomputes:F},{ShortSignature:C}=t.G1,{Signature:z}=t.G2;function D(Y){return Y instanceof f.ProjectivePoint?Y:f.ProjectivePoint.fromHex(Y)}function G(Y,P){return Y instanceof f.ProjectivePoint?Y:f.hashToCurve((0,vu.ensureBytes)("point",Y),P)}function ne(Y){return Y instanceof h.ProjectivePoint?Y:z.fromHex(Y)}function Q(Y,P){return Y instanceof h.ProjectivePoint?Y:h.hashToCurve((0,vu.ensureBytes)("point",Y),P)}function le(Y){return f.ProjectivePoint.fromPrivateKey(Y).toRawBytes(!0)}function E(Y){return h.ProjectivePoint.fromPrivateKey(Y).toRawBytes(!0)}function _(Y,P,p){let ee=Q(Y,p);ee.assertValidity();let re=ee.multiply(f.normPrivateKeyToScalar(P));return Y instanceof h.ProjectivePoint?re:z.toRawBytes(re)}function m(Y,P,p){let ee=G(Y,p);ee.assertValidity();let re=ee.multiply(f.normPrivateKeyToScalar(P));return Y instanceof f.ProjectivePoint?re:C.toRawBytes(re)}function x(Y,P,p,ee){let re=D(p),de=Q(P,ee),J=f.ProjectivePoint.BASE,l=ne(Y),y=V([{g1:re.negate(),g2:de},{g1:J,g2:l}]);return s.eql(y,s.ONE)}function j(Y,P,p,ee){let re=ne(p),de=G(P,ee),J=h.ProjectivePoint.BASE,l=D(Y),y=V([{g1:de,g2:re},{g1:l,g2:J.negate()}]);return s.eql(y,s.ONE)}function H(Y){if(!Y.length)throw new Error("Expected non-empty array");let p=Y.map(D).reduce((ee,re)=>ee.add(re),f.ProjectivePoint.ZERO);return Y[0]instanceof f.ProjectivePoint?(p.assertValidity(),p):p.toRawBytes(!0)}function X(Y){if(!Y.length)throw new Error("Expected non-empty array");let p=Y.map(ne).reduce((ee,re)=>ee.add(re),h.ProjectivePoint.ZERO);return Y[0]instanceof h.ProjectivePoint?(p.assertValidity(),p):z.toRawBytes(p)}function oe(Y){if(!Y.length)throw new Error("Expected non-empty array");let p=Y.map(D).reduce((ee,re)=>ee.add(re),f.ProjectivePoint.ZERO);return Y[0]instanceof f.ProjectivePoint?(p.assertValidity(),p):C.toRawBytes(p)}function ae(Y,P,p,ee){if(!P.length)throw new Error("Expected non-empty messages array");if(p.length!==P.length)throw new Error("Pubkey count should equal msg count");let re=ne(Y),de=P.map(b=>Q(b,ee)),J=p.map(D),l=new Map;for(let b=0;b<J.length;b++){let R=J[b],A=de[b],O=l.get(A);O===void 0&&(O=[],l.set(A,O)),O.push(R)}let y=[];try{for(let[b,R]of l){let A=R.reduce((O,q)=>O.add(q));y.push({g1:A,g2:b})}return y.push({g1:f.ProjectivePoint.BASE.negate(),g2:re}),s.eql(V(y),s.ONE)}catch{return!1}}return f.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:le,getPublicKeyForShortSignatures:E,sign:_,signShortSignature:m,verify:x,verifyBatch:ae,verifyShortSignature:j,aggregatePublicKeys:H,aggregateSignatures:X,aggregateShortSignatures:oe,millerLoopBatch:N,pairing:W,pairingBatch:V,G1:f,G2:h,Signature:z,ShortSignature:C,fields:{Fr:r,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:t.params.ateLoopSize,r:t.params.r,G1b:t.G1.b,G2b:t.G2.b},utils:T}}});var N0=L(Uo=>{"use strict";Object.defineProperty(Uo,"__esModule",{value:!0});Uo.psiFrobenius=u1;Uo.tower12=l1;var ln=Ar(),dr=Wt(),c1=BigInt(0),gi=BigInt(1),zr=BigInt(2),O0=BigInt(3);function Su(t,e,r,n,i=1,s){let o=BigInt(s===void 0?n:s),a=r**BigInt(n),c=[];for(let f=0;f<i;f++){let d=BigInt(f+1),h=[];for(let B=0,w=gi;B<n;B++){let u=(d*w-d)/o%a;h.push(t.pow(e,u)),w*=r}c.push(h)}return c}function u1(t,e,r){let n=e.pow(r,(t.ORDER-gi)/O0),i=e.pow(r,(t.ORDER-gi)/zr);function s(B,w){let u=e.mul(e.frobeniusMap(B,1),n),g=e.mul(e.frobeniusMap(w,1),i);return[u,g]}let o=e.pow(r,(t.ORDER**zr-gi)/O0),a=e.pow(r,(t.ORDER**zr-gi)/zr);if(!e.eql(a,e.neg(e.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(B,w){return[e.mul(B,o),e.neg(w)]}let f=B=>(w,u)=>{let g=u.toAffine(),U=B(g.x,g.y);return w.fromAffine({x:U[0],y:U[1]})},d=f(s),h=f(c);return{psi:s,psi2:c,G2psi:d,G2psi2:h,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:a}}function l1(t){let{ORDER:e}=t,r=ln.Field(e),n=r.create(t.NONRESIDUE||BigInt(-1)),i=ln.FpLegendre(e),s=r.div(r.ONE,zr),o=Su(r,n,r.ORDER,2)[0],a=({c0:E,c1:_},{c0:m,c1:x})=>({c0:r.add(E,m),c1:r.add(_,x)}),c=({c0:E,c1:_},{c0:m,c1:x})=>({c0:r.sub(E,m),c1:r.sub(_,x)}),f=({c0:E,c1:_},m)=>{if(typeof m=="bigint")return{c0:r.mul(E,m),c1:r.mul(_,m)};let{c0:x,c1:j}=m,H=r.mul(E,x),X=r.mul(_,j),oe=r.sub(H,X),ae=r.sub(r.mul(r.add(E,_),r.add(x,j)),r.add(H,X));return{c0:oe,c1:ae}},d=({c0:E,c1:_})=>{let m=r.add(E,_),x=r.sub(E,_),j=r.add(E,E);return{c0:r.mul(m,x),c1:r.mul(j,_)}},h=E=>{if(E.length!==2)throw new Error("Invalid tuple");let _=E.map(m=>r.create(m));return{c0:_[0],c1:_[1]}},B=e*e,w=h(t.FP2_NONRESIDUE),u={ORDER:B,NONRESIDUE:w,BITS:(0,dr.bitLen)(B),BYTES:Math.ceil((0,dr.bitLen)(B)/8),MASK:(0,dr.bitMask)((0,dr.bitLen)(B)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:E=>E,isValid:({c0:E,c1:_})=>typeof E=="bigint"&&typeof _=="bigint",is0:({c0:E,c1:_})=>r.is0(E)&&r.is0(_),eql:({c0:E,c1:_},{c0:m,c1:x})=>r.eql(E,m)&&r.eql(_,x),neg:({c0:E,c1:_})=>({c0:r.neg(E),c1:r.neg(_)}),pow:(E,_)=>ln.FpPow(u,E,_),invertBatch:E=>ln.FpInvertBatch(u,E),add:a,sub:c,mul:f,sqr:d,addN:a,subN:c,mulN:f,sqrN:d,div:(E,_)=>u.mul(E,typeof _=="bigint"?r.inv(r.create(_)):u.inv(_)),inv:({c0:E,c1:_})=>{let m=r.inv(r.create(E*E+_*_));return{c0:r.mul(m,r.create(E)),c1:r.mul(m,r.create(-_))}},sqrt:E=>{if(t.Fp2sqrt)return t.Fp2sqrt(E);let{c0:_,c1:m}=E;if(r.is0(m))return r.eql(i(r,_),r.ONE)?u.create({c0:r.sqrt(_),c1:r.ZERO}):u.create({c0:r.ZERO,c1:r.sqrt(r.div(_,n))});let x=r.sqrt(r.sub(r.sqr(_),r.mul(r.sqr(m),n))),j=r.mul(r.add(x,_),s),H=i(r,j);!r.is0(H)&&!r.eql(H,r.ONE)&&(j=r.sub(j,x));let X=r.sqrt(j),oe=u.create({c0:X,c1:r.div(r.mul(m,s),X)});if(!u.eql(u.sqr(oe),E))throw new Error("Cannot find square root");let ae=oe,Y=u.neg(ae),{re:P,im:p}=u.reim(ae),{re:ee,im:re}=u.reim(Y);return p>re||p===re&&P>ee?ae:Y},isOdd:E=>{let{re:_,im:m}=u.reim(E),x=_%zr,j=_===c1,H=m%zr;return BigInt(x||j&&H)==gi},fromBytes(E){if(E.length!==u.BYTES)throw new Error(`fromBytes wrong length=${E.length}`);return{c0:r.fromBytes(E.subarray(0,r.BYTES)),c1:r.fromBytes(E.subarray(r.BYTES))}},toBytes:({c0:E,c1:_})=>(0,dr.concatBytes)(r.toBytes(E),r.toBytes(_)),cmov:({c0:E,c1:_},{c0:m,c1:x},j)=>({c0:r.cmov(E,m,j),c1:r.cmov(_,x,j)}),reim:({c0:E,c1:_})=>({re:E,im:_}),mulByNonresidue:({c0:E,c1:_})=>u.mul({c0:E,c1:_},w),mulByB:t.Fp2mulByB,fromBigTuple:h,frobeniusMap:({c0:E,c1:_},m)=>({c0:E,c1:r.mul(_,o[m%2])})},g=({c0:E,c1:_,c2:m},{c0:x,c1:j,c2:H})=>({c0:u.add(E,x),c1:u.add(_,j),c2:u.add(m,H)}),U=({c0:E,c1:_,c2:m},{c0:x,c1:j,c2:H})=>({c0:u.sub(E,x),c1:u.sub(_,j),c2:u.sub(m,H)}),F=({c0:E,c1:_,c2:m},x)=>{if(typeof x=="bigint")return{c0:u.mul(E,x),c1:u.mul(_,x),c2:u.mul(m,x)};let{c0:j,c1:H,c2:X}=x,oe=u.mul(E,j),ae=u.mul(_,H),Y=u.mul(m,X);return{c0:u.add(oe,u.mulByNonresidue(u.sub(u.mul(u.add(_,m),u.add(H,X)),u.add(ae,Y)))),c1:u.add(u.sub(u.mul(u.add(E,_),u.add(j,H)),u.add(oe,ae)),u.mulByNonresidue(Y)),c2:u.sub(u.add(ae,u.mul(u.add(E,m),u.add(j,X))),u.add(oe,Y))}},N=({c0:E,c1:_,c2:m})=>{let x=u.sqr(E),j=u.mul(u.mul(E,_),zr),H=u.mul(u.mul(_,m),zr),X=u.sqr(m);return{c0:u.add(u.mulByNonresidue(H),x),c1:u.add(u.mulByNonresidue(X),j),c2:u.sub(u.sub(u.add(u.add(j,u.sqr(u.add(u.sub(E,_),m))),H),x),X)}},[V,W]=Su(u,w,r.ORDER,6,2,3),T={ORDER:u.ORDER,BITS:3*u.BITS,BYTES:3*u.BYTES,MASK:(0,dr.bitMask)(3*u.BITS),ZERO:{c0:u.ZERO,c1:u.ZERO,c2:u.ZERO},ONE:{c0:u.ONE,c1:u.ZERO,c2:u.ZERO},create:E=>E,isValid:({c0:E,c1:_,c2:m})=>u.isValid(E)&&u.isValid(_)&&u.isValid(m),is0:({c0:E,c1:_,c2:m})=>u.is0(E)&&u.is0(_)&&u.is0(m),neg:({c0:E,c1:_,c2:m})=>({c0:u.neg(E),c1:u.neg(_),c2:u.neg(m)}),eql:({c0:E,c1:_,c2:m},{c0:x,c1:j,c2:H})=>u.eql(E,x)&&u.eql(_,j)&&u.eql(m,H),sqrt:dr.notImplemented,div:(E,_)=>T.mul(E,typeof _=="bigint"?r.inv(r.create(_)):T.inv(_)),pow:(E,_)=>ln.FpPow(T,E,_),invertBatch:E=>ln.FpInvertBatch(T,E),add:g,sub:U,mul:F,sqr:N,addN:g,subN:U,mulN:F,sqrN:N,inv:({c0:E,c1:_,c2:m})=>{let x=u.sub(u.sqr(E),u.mulByNonresidue(u.mul(m,_))),j=u.sub(u.mulByNonresidue(u.sqr(m)),u.mul(E,_)),H=u.sub(u.sqr(_),u.mul(E,m)),X=u.inv(u.add(u.mulByNonresidue(u.add(u.mul(m,j),u.mul(_,H))),u.mul(E,x)));return{c0:u.mul(X,x),c1:u.mul(X,j),c2:u.mul(X,H)}},fromBytes:E=>{if(E.length!==T.BYTES)throw new Error(`fromBytes wrong length=${E.length}`);return{c0:u.fromBytes(E.subarray(0,u.BYTES)),c1:u.fromBytes(E.subarray(u.BYTES,2*u.BYTES)),c2:u.fromBytes(E.subarray(2*u.BYTES))}},toBytes:({c0:E,c1:_,c2:m})=>(0,dr.concatBytes)(u.toBytes(E),u.toBytes(_),u.toBytes(m)),cmov:({c0:E,c1:_,c2:m},{c0:x,c1:j,c2:H},X)=>({c0:u.cmov(E,x,X),c1:u.cmov(_,j,X),c2:u.cmov(m,H,X)}),fromBigSix:E=>{if(!Array.isArray(E)||E.length!==6)throw new Error("Invalid Fp6 usage");return{c0:u.fromBigTuple(E.slice(0,2)),c1:u.fromBigTuple(E.slice(2,4)),c2:u.fromBigTuple(E.slice(4,6))}},frobeniusMap:({c0:E,c1:_,c2:m},x)=>({c0:u.frobeniusMap(E,x),c1:u.mul(u.frobeniusMap(_,x),V[x%6]),c2:u.mul(u.frobeniusMap(m,x),W[x%6])}),mulByFp2:({c0:E,c1:_,c2:m},x)=>({c0:u.mul(E,x),c1:u.mul(_,x),c2:u.mul(m,x)}),mulByNonresidue:({c0:E,c1:_,c2:m})=>({c0:u.mulByNonresidue(m),c1:E,c2:_}),mul1:({c0:E,c1:_,c2:m},x)=>({c0:u.mulByNonresidue(u.mul(m,x)),c1:u.mul(E,x),c2:u.mul(_,x)}),mul01({c0:E,c1:_,c2:m},x,j){let H=u.mul(E,x),X=u.mul(_,j);return{c0:u.add(u.mulByNonresidue(u.sub(u.mul(u.add(_,m),j),X)),H),c1:u.sub(u.sub(u.mul(u.add(x,j),u.add(E,_)),H),X),c2:u.add(u.sub(u.mul(u.add(E,m),x),H),X)}}},C=Su(u,w,r.ORDER,12,1,6)[0],z=({c0:E,c1:_},{c0:m,c1:x})=>({c0:T.add(E,m),c1:T.add(_,x)}),D=({c0:E,c1:_},{c0:m,c1:x})=>({c0:T.sub(E,m),c1:T.sub(_,x)}),G=({c0:E,c1:_},m)=>{if(typeof m=="bigint")return{c0:T.mul(E,m),c1:T.mul(_,m)};let{c0:x,c1:j}=m,H=T.mul(E,x),X=T.mul(_,j);return{c0:T.add(H,T.mulByNonresidue(X)),c1:T.sub(T.mul(T.add(E,_),T.add(x,j)),T.add(H,X))}},ne=({c0:E,c1:_})=>{let m=T.mul(E,_);return{c0:T.sub(T.sub(T.mul(T.add(T.mulByNonresidue(_),E),T.add(E,_)),m),T.mulByNonresidue(m)),c1:T.add(m,m)}};function Q(E,_){let m=u.sqr(E),x=u.sqr(_);return{first:u.add(u.mulByNonresidue(x),m),second:u.sub(u.sub(u.sqr(u.add(E,_)),m),x)}}let le={ORDER:u.ORDER,BITS:2*u.BITS,BYTES:2*u.BYTES,MASK:(0,dr.bitMask)(2*u.BITS),ZERO:{c0:T.ZERO,c1:T.ZERO},ONE:{c0:T.ONE,c1:T.ZERO},create:E=>E,isValid:({c0:E,c1:_})=>T.isValid(E)&&T.isValid(_),is0:({c0:E,c1:_})=>T.is0(E)&&T.is0(_),neg:({c0:E,c1:_})=>({c0:T.neg(E),c1:T.neg(_)}),eql:({c0:E,c1:_},{c0:m,c1:x})=>T.eql(E,m)&&T.eql(_,x),sqrt:dr.notImplemented,inv:({c0:E,c1:_})=>{let m=T.inv(T.sub(T.sqr(E),T.mulByNonresidue(T.sqr(_))));return{c0:T.mul(E,m),c1:T.neg(T.mul(_,m))}},div:(E,_)=>le.mul(E,typeof _=="bigint"?r.inv(r.create(_)):le.inv(_)),pow:(E,_)=>ln.FpPow(le,E,_),invertBatch:E=>ln.FpInvertBatch(le,E),add:z,sub:D,mul:G,sqr:ne,addN:z,subN:D,mulN:G,sqrN:ne,fromBytes:E=>{if(E.length!==le.BYTES)throw new Error(`fromBytes wrong length=${E.length}`);return{c0:T.fromBytes(E.subarray(0,T.BYTES)),c1:T.fromBytes(E.subarray(T.BYTES))}},toBytes:({c0:E,c1:_})=>(0,dr.concatBytes)(T.toBytes(E),T.toBytes(_)),cmov:({c0:E,c1:_},{c0:m,c1:x},j)=>({c0:T.cmov(E,m,j),c1:T.cmov(_,x,j)}),fromBigTwelve:E=>({c0:T.fromBigSix(E.slice(0,6)),c1:T.fromBigSix(E.slice(6,12))}),frobeniusMap(E,_){let{c0:m,c1:x,c2:j}=T.frobeniusMap(E.c1,_),H=C[_%12];return{c0:T.frobeniusMap(E.c0,_),c1:T.create({c0:u.mul(m,H),c1:u.mul(x,H),c2:u.mul(j,H)})}},mulByFp2:({c0:E,c1:_},m)=>({c0:T.mulByFp2(E,m),c1:T.mulByFp2(_,m)}),conjugate:({c0:E,c1:_})=>({c0:E,c1:T.neg(_)}),mul014:({c0:E,c1:_},m,x,j)=>{let H=T.mul01(E,m,x),X=T.mul1(_,j);return{c0:T.add(T.mulByNonresidue(X),H),c1:T.sub(T.sub(T.mul01(T.add(_,E),m,u.add(x,j)),H),X)}},mul034:({c0:E,c1:_},m,x,j)=>{let H=T.create({c0:u.mul(E.c0,m),c1:u.mul(E.c1,m),c2:u.mul(E.c2,m)}),X=T.mul01(_,x,j),oe=T.mul01(T.add(E,_),u.add(m,x),j);return{c0:T.add(T.mulByNonresidue(X),H),c1:T.sub(oe,T.add(H,X))}},_cyclotomicSquare:t.Fp12cyclotomicSquare,_cyclotomicExp:t.Fp12cyclotomicExp,finalExponentiate:t.Fp12finalExponentiate};return{Fp:r,Fp2:u,Fp6:T,Fp4Square:Q,Fp12:le}}});var j0=L(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});Ut.bls12_381=void 0;var F0=Ps(),f1=Bn(),d1=A0(),h1=Ar(),Se=Wt(),M0=No(),C0=xu(),q0=N0(),It=BigInt(0),Co=BigInt(1),dt=BigInt(2),Fo=BigInt(3),Ji=BigInt(4),fn=BigInt("0xd201000000010000"),p1=(0,Se.bitLen)(fn),{Fp:ue,Fp2:he,Fp6:Ou,Fp4Square:Bu,Fp12:ve}=(0,q0.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[Co,Co],Fp2mulByB:({c0:t,c1:e})=>{let r=ue.mul(t,Ji),n=ue.mul(e,Ji);return{c0:ue.sub(r,n),c1:ue.add(r,n)}},Fp12cyclotomicSquare:({c0:t,c1:e})=>{let{c0:r,c1:n,c2:i}=t,{c0:s,c1:o,c2:a}=e,{first:c,second:f}=Bu(r,o),{first:d,second:h}=Bu(s,i),{first:B,second:w}=Bu(n,a),u=he.mulByNonresidue(w);return{c0:Ou.create({c0:he.add(he.mul(he.sub(c,r),dt),c),c1:he.add(he.mul(he.sub(d,n),dt),d),c2:he.add(he.mul(he.sub(B,i),dt),B)}),c1:Ou.create({c0:he.add(he.mul(he.add(u,s),dt),u),c1:he.add(he.mul(he.add(f,o),dt),f),c2:he.add(he.mul(he.add(h,a),dt),h)})}},Fp12cyclotomicExp(t,e){let r=ve.ONE;for(let n=p1-1;n>=0;n--)r=ve._cyclotomicSquare(r),(0,Se.bitGet)(e,n)&&(r=ve.mul(r,t));return r},Fp12finalExponentiate:t=>{let e=fn,r=ve.div(ve.frobeniusMap(t,6),t),n=ve.mul(ve.frobeniusMap(r,2),r),i=ve.conjugate(ve._cyclotomicExp(n,e)),s=ve.mul(ve.conjugate(ve._cyclotomicSquare(n)),i),o=ve.conjugate(ve._cyclotomicExp(s,e)),a=ve.conjugate(ve._cyclotomicExp(o,e)),c=ve.mul(ve.conjugate(ve._cyclotomicExp(a,e)),ve._cyclotomicSquare(i)),f=ve.conjugate(ve._cyclotomicExp(c,e)),d=ve.frobeniusMap(ve.mul(i,a),2),h=ve.frobeniusMap(ve.mul(o,n),3),B=ve.frobeniusMap(ve.mul(c,ve.conjugate(n)),1),w=ve.mul(ve.mul(f,ve.conjugate(s)),n);return ve.mul(ve.mul(ve.mul(d,h),B),w)}}),R0=h1.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),y1=(0,M0.isogenyMap)(he,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(t=>t.map(e=>he.fromBigTuple(e.map(BigInt))))),b1=(0,M0.isogenyMap)(ue,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(e=>BigInt(e)))),g1=(0,C0.mapToCurveSimpleSWU)(he,{A:he.create({c0:ue.create(It),c1:ue.create(BigInt(240))}),B:he.create({c0:ue.create(BigInt(1012)),c1:ue.create(BigInt(1012))}),Z:he.create({c0:ue.create(BigInt(-2)),c1:ue.create(BigInt(-1))})}),m1=(0,C0.mapToCurveSimpleSWU)(ue,{A:ue.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:ue.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:ue.create(BigInt(11))}),{G2psi:P0,G2psi2:_1}=(0,q0.psiFrobenius)(ue,he,he.div(he.ONE,he.NONRESIDUE)),Au=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:ue.ORDER,m:2,k:128,expand:"xmd",hash:F0.sha256}),qo=Li(ue.toBytes(It),{infinity:!0,compressed:!0});function Mo(t){t=t.slice();let e=t[0]&224,r=!!(e>>7&1),n=!!(e>>6&1),i=!!(e>>5&1);return t[0]&=31,{compressed:r,infinity:n,sort:i,value:t}}function Li(t,e){if(t[0]&224)throw new Error("setMask: non-empty mask");return e.compressed&&(t[0]|=128),e.infinity&&(t[0]|=64),e.sort&&(t[0]|=32),t}function I0(t){t.assertValidity();let e=t.equals(Ut.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return qo.slice();let i=ue.ORDER,s=!!(n*dt/i);return Li((0,Se.numberToBytesBE)(r,ue.BYTES),{compressed:!0,sort:s})}function U0(t){t.assertValidity();let e=ue.BYTES;if(t.equals(Ut.bls12_381.G2.ProjectivePoint.ZERO))return(0,Se.concatBytes)(qo,(0,Se.numberToBytesBE)(It,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=he.reim(r),{re:o,im:a}=he.reim(n),f=!!((a>It?a*dt:o*dt)/ue.ORDER&Co),d=i;return(0,Se.concatBytes)(Li((0,Se.numberToBytesBE)(s,e),{sort:f,compressed:!0}),(0,Se.numberToBytesBE)(d,e))}Ut.bls12_381=(0,d1.bls)({fields:{Fp:ue,Fp2:he,Fp6:Ou,Fp12:ve,Fr:R0},G1:{Fp:ue,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:ue.ZERO,b:Ji,htfDefaults:{...Au,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(t,e)=>{let r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new t(ue.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(fn).negate().multiplyUnsafe(fn).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(fn).add(e),mapToCurve:t=>{let{x:e,y:r}=m1(ue.create(t[0]));return b1(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=Mo(t);if(i.length===48&&e){let s=ue.ORDER,o=(0,Se.bytesToNumberBE)(i),a=ue.create(o&ue.MASK);if(r){if(a!==It)throw new Error("G1: non-empty compressed point at infinity");return{x:It,y:It}}let c=ue.add(ue.pow(a,Fo),ue.create(Ut.bls12_381.params.G1b)),f=ue.sqrt(c);if(!f)throw new Error("Invalid compressed G1 point");return f*dt/s!==BigInt(n)&&(f=ue.neg(f)),{x:ue.create(a),y:ue.create(f)}}else if(i.length===96&&!e){let s=(0,Se.bytesToNumberBE)(i.subarray(0,ue.BYTES)),o=(0,Se.bytesToNumberBE)(i.subarray(ue.BYTES));if(r){if(s!==It||o!==It)throw new Error("G1: non-empty point at infinity");return Ut.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:ue.create(s),y:ue.create(o)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(t,e,r)=>{let n=e.equals(t.ZERO),{x:i,y:s}=e.toAffine();if(r){if(n)return qo.slice();let o=ue.ORDER,a=!!(s*dt/o);return Li((0,Se.numberToBytesBE)(i,ue.BYTES),{compressed:!0,sort:a})}else return n?(0,Se.concatBytes)(new Uint8Array([64]),new Uint8Array(2*ue.BYTES-1)):(0,Se.concatBytes)((0,Se.numberToBytesBE)(i,ue.BYTES),(0,Se.numberToBytesBE)(s,ue.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=Mo((0,Se.ensureBytes)("signatureHex",t,48)),i=ue.ORDER,s=(0,Se.bytesToNumberBE)(n);if(e)return Ut.bls12_381.G1.ProjectivePoint.ZERO;let o=ue.create(s&ue.MASK),a=ue.add(ue.pow(o,Fo),ue.create(Ut.bls12_381.params.G1b)),c=ue.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let f=BigInt(r);c*dt/i!==f&&(c=ue.neg(c));let d=Ut.bls12_381.G1.ProjectivePoint.fromAffine({x:o,y:c});return d.assertValidity(),d},toRawBytes(t){return I0(t)},toHex(t){return(0,Se.bytesToHex)(I0(t))}}},G2:{Fp:he,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:he.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:he.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:he.ZERO,b:he.fromBigTuple([Ji,Ji]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...Au},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=g1(he.fromBigTuple(t));return y1(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(fn).negate().equals(P0(t,e)),clearCofactor:(t,e)=>{let r=fn,n=e.multiplyUnsafe(r).negate(),i=P0(t,e),s=e.double();return s=_1(t,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),s=s.add(i),s=s.subtract(n),s.subtract(e)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=Mo(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=ue.BYTES,o=(a,c,f)=>(0,Se.bytesToNumberBE)(a.slice(c,f));if(i.length===96&&e){let a=Ut.bls12_381.params.G2b,c=ue.ORDER;if(r){if(i.reduce((g,U)=>g!==0?U+1:U,0)>0)throw new Error("Invalid compressed G2 point");return{x:he.ZERO,y:he.ZERO}}let f=o(i,0,s),d=o(i,s,2*s),h=he.create({c0:ue.create(d),c1:ue.create(f)}),B=he.add(he.pow(h,Fo),a),w=he.sqrt(B),u=w.c1===It?w.c0*dt/c:w.c1*dt/c?Co:It;return w=n&&u>0?w:he.neg(w),{x:h,y:w}}else if(i.length===192&&!e){if(r){if(i.reduce((h,B)=>h!==0?B+1:B,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:he.ZERO,y:he.ZERO}}let a=o(i,0,s),c=o(i,s,2*s),f=o(i,2*s,3*s),d=o(i,3*s,4*s);return{x:he.fromBigTuple([c,a]),y:he.fromBigTuple([d,f])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(t,e,r)=>{let{BYTES:n,ORDER:i}=ue,s=e.equals(t.ZERO),{x:o,y:a}=e.toAffine();if(r){if(s)return(0,Se.concatBytes)(qo,(0,Se.numberToBytesBE)(It,n));let c=!!(a.c1===It?a.c0*dt/i:a.c1*dt/i);return(0,Se.concatBytes)(Li((0,Se.numberToBytesBE)(o.c1,n),{compressed:!0,sort:c}),(0,Se.numberToBytesBE)(o.c0,n))}else{if(s)return(0,Se.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:f}=he.reim(o),{re:d,im:h}=he.reim(a);return(0,Se.concatBytes)((0,Se.numberToBytesBE)(f,n),(0,Se.numberToBytesBE)(c,n),(0,Se.numberToBytesBE)(h,n),(0,Se.numberToBytesBE)(d,n))}},Signature:{fromHex(t){let{infinity:e,sort:r,value:n}=Mo((0,Se.ensureBytes)("signatureHex",t)),i=ue.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=(0,Se.bytesToNumberBE)(n.slice(0,s)),a=(0,Se.bytesToNumberBE)(n.slice(s));if(e)return Ut.bls12_381.G2.ProjectivePoint.ZERO;let c=ue.create(o&ue.MASK),f=ue.create(a),d=he.create({c0:f,c1:c}),h=he.add(he.pow(d,Fo),Ut.bls12_381.params.G2b),B=he.sqrt(h);if(!B)throw new Error("Failed to find a square root");let{re:w,im:u}=he.reim(B),g=BigInt(r),U=u>It&&u*dt/i!==g,F=u===It&&w*dt/i!==g;(U||F)&&(B=he.neg(B));let N=Ut.bls12_381.G2.ProjectivePoint.fromAffine({x:d,y:B});return N.assertValidity(),N},toRawBytes(t){return U0(t)},toHex(t){return(0,Se.bytesToHex)(U0(t))}}},params:{ateLoopSize:fn,r:R0.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:Au,hash:F0.sha256,randomBytes:f1.randomBytes})});var Ru=L(Qi=>{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});Qi.blsVerify=Qi.verify=void 0;var w1=j0(),Nu=Yt();function E1(t,e,r){let n=typeof t=="string"?t:(0,Nu.toHex)(t),i=typeof e=="string"?e:(0,Nu.toHex)(e),s=typeof r=="string"?r:(0,Nu.toHex)(r);return w1.bls12_381.verifyShortSignature(i,s,n)}Qi.blsVerify=E1});var jo=L(Un=>{"use strict";Object.defineProperty(Un,"__esModule",{value:!0});Un.decodeTime=Un.decodeLeb128=void 0;var k0=fi(),x1=t=>(0,k0.lebDecode)(new k0.PipeArrayBuffer(t));Un.decodeLeb128=x1;var v1=t=>{let e=(0,Un.decodeLeb128)(t);return new Date(Number(e)/1e6)};Un.decodeTime=v1});var is=L(Ae=>{"use strict";var T1=Ae&&Ae.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),S1=Ae&&Ae.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),V0=Ae&&Ae.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&T1(e,t,r);return S1(e,t),e};Object.defineProperty(Ae,"__esModule",{value:!0});Ae.check_canister_ranges=Ae.find_label=Ae.flatten_forks=Ae.lookup_path=Ae.LookupStatus=Ae.reconstruct=Ae.lookupResultToBuffer=Ae.Certificate=Ae.hashTreeToString=Ae.NodeType=Ae.CertificateVerificationError=void 0;var H0=V0(Zi()),B1=ii(),ko=Wi(),hr=Yt(),Pu=Nt(),A1=V0(Ru()),O1=jo(),Dr=class extends B1.AgentError{constructor(e){super(`Invalid certificate: ${e}`)}};Ae.CertificateVerificationError=Dr;var wt;(function(t){t[t.Empty=0]="Empty",t[t.Fork=1]="Fork",t[t.Labeled=2]="Labeled",t[t.Leaf=3]="Leaf",t[t.Pruned=4]="Pruned"})(wt=Ae.NodeType||(Ae.NodeType={}));function Vo(t){let e=n=>n.split(`
17
17
  `).map(i=>" "+i).join(`
18
- `);function r(n){let i=new TextDecoder(void 0,{fatal:!0});try{return JSON.stringify(i.decode(n))}catch{return`data(...${n.byteLength} bytes)`}}switch(t[0]){case xt.Empty:return"()";case xt.Fork:if(t[1]instanceof Array&&t[2]instanceof ArrayBuffer){let n=Po(t[1]),i=Po(t[2]);return`sub(
18
+ `);function r(n){let i=new TextDecoder(void 0,{fatal:!0});try{return JSON.stringify(i.decode(n))}catch{return`data(...${n.byteLength} bytes)`}}switch(t[0]){case wt.Empty:return"()";case wt.Fork:if(t[1]instanceof Array&&t[2]instanceof ArrayBuffer){let n=Vo(t[1]),i=Vo(t[2]);return`sub(
19
19
  left:
20
20
  ${e(n)}
21
21
  ---
22
22
  right:
23
23
  ${e(i)}
24
- )`}else throw new Error("Invalid tree structure for fork");case xt.Labeled:if(t[1]instanceof ArrayBuffer&&t[2]instanceof ArrayBuffer){let n=r(t[1]),i=Po(t[2]);return`label(
24
+ )`}else throw new Error("Invalid tree structure for fork");case wt.Labeled:if(t[1]instanceof ArrayBuffer&&t[2]instanceof ArrayBuffer){let n=r(t[1]),i=Vo(t[2]);return`label(
25
25
  label:
26
26
  ${e(n)}
27
27
  sub:
28
28
  ${e(i)}
29
- )`}else throw new Error("Invalid tree structure for labeled");case xt.Leaf:{if(t[1]){if(Array.isArray(t[1]))return JSON.stringify(t[1])}else throw new Error("Invalid tree structure for leaf");return`leaf(...${t[1].byteLength} bytes)`}case xt.Pruned:{if(t[1]){if(Array.isArray(t[1]))return JSON.stringify(t[1])}else throw new Error("Invalid tree structure for pruned");return`pruned(${(0,fr.toHex)(new Uint8Array(t[1]))}`}default:return`unknown(${JSON.stringify(t[0])})`}}Ne.hashTreeToString=Po;function S_(t,e){let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]>n[i])return!0;return!1}var wu=class t{constructor(e,r,n,i,s=5){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=C0.decode(new Uint8Array(e))}static async create(e){let r=t.createUnverified(e);return await r.verify(),r}static createUnverified(e){let r=e.blsVerify;return r||(r=T_.blsVerify),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes)}lookup(e){return Ro(e,this.cert.tree)}lookup_label(e){return this.lookup([e])}async verify(){let e=await Di(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=O_(r),s=(0,fr.concat)(zi("ic-state-root"),e),o=!1,a=Eu(this.lookup(["time"]));if(!a)throw new Kr("Certificate does not contain a time");let c=5*60*1e3,f=this._maxAgeInMinutes*60*1e3,l=Date.now(),d=l-f,v=l+c,E=(0,B_.decodeTime)(a);if(E.getTime()<d)throw new Kr(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+E.toISOString()+" Current time: "+new Date(l).toISOString());if(E.getTime()>v)throw new Kr("Certificate is signed more than 5 minutes in the future. Certificate time: "+E.toISOString()+" Current time: "+new Date(l).toISOString());try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new Kr("Signature verification failed")}async _checkDelegationAndGetKey(e){if(!e)return this._rootKey;let r=await t.createUnverified({certificate:e.certificate,rootKey:this._rootKey,canisterId:this._canisterId,blsVerify:this._blsVerify,maxAgeInMinutes:1/0});if(r.cert.delegation)throw new Kr("Delegation certificates cannot be nested");if(await r.verify(),!q0({canisterId:this._canisterId,subnetId:_u.Principal.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new Kr(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,fr.toHex)(e.subnet_id)}`);let i=Eu(r.lookup(["subnet",e.subnet_id,"public_key"]));if(!i)throw new Error(`Could not find subnet key for subnet 0x${(0,fr.toHex)(e.subnet_id)}`);return i}};Ne.Certificate=wu;var Wi=(0,fr.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),A_=96;function O_(t){let e=Wi.byteLength+A_;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,Wi.byteLength);if(!(0,fr.bufEquals)(r,Wi))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${Wi}, but get ${r}`);return t.slice(Wi.byteLength)}function Eu(t){if(t.status===Ft.Found){if(t.value instanceof ArrayBuffer)return t.value;if(t.value instanceof Uint8Array)return t.value.buffer}}Ne.lookupResultToBuffer=Eu;async function Di(t){switch(t[0]){case xt.Empty:return(0,No.hash)(zi("ic-hashtree-empty"));case xt.Pruned:return t[1];case xt.Leaf:return(0,No.hash)((0,fr.concat)(zi("ic-hashtree-leaf"),t[1]));case xt.Labeled:return(0,No.hash)((0,fr.concat)(zi("ic-hashtree-labeled"),t[1],await Di(t[2])));case xt.Fork:return(0,No.hash)((0,fr.concat)(zi("ic-hashtree-fork"),await Di(t[1]),await Di(t[2])));default:throw new Error("unreachable")}}Ne.reconstruct=Di;function zi(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return(0,fr.concat)(e,r)}var Ft;(function(t){t.Unknown="unknown",t.Absent="absent",t.Found="found"})(Ft=Ne.LookupStatus||(Ne.LookupStatus={}));var Gr;(function(t){t.Less="less",t.Greater="greater"})(Gr||(Gr={}));function Ro(t,e){if(t.length===0)switch(e[0]){case xt.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?{status:Ft.Found,value:e[1]}:e[1]instanceof Uint8Array?{status:Ft.Found,value:e[1].buffer}:{status:Ft.Found,value:e[1]}}default:return{status:Ft.Found,value:e}}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=Zi(r,e);switch(n.status){case Ft.Found:return Ro(t.slice(1),n.value);case Gr.Greater:case Gr.Less:return{status:Ft.Absent};default:return n}}Ne.lookup_path=Ro;function xu(t){switch(t[0]){case xt.Empty:return[];case xt.Fork:return xu(t[1]).concat(xu(t[2]));default:return[t]}}Ne.flatten_forks=xu;function Zi(t,e){switch(e[0]){case xt.Labeled:return S_(t,e[1])?{status:Gr.Greater}:(0,fr.bufEquals)(t,e[1])?{status:Ft.Found,value:e[2]}:{status:Gr.Less};case xt.Fork:let r=Zi(t,e[1]);switch(r.status){case Gr.Greater:{let n=Zi(t,e[2]);return n.status===Gr.Less?{status:Ft.Absent}:n}case Ft.Unknown:{let n=Zi(t,e[2]);return n.status===Gr.Less?{status:Ft.Unknown}:n}default:return r}case xt.Pruned:return{status:Ft.Unknown};default:return{status:Ft.Absent}}}Ne.find_label=Zi;function q0(t){let{canisterId:e,subnetId:r,tree:n}=t,i=Ro(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==Ft.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return C0.decode(i.value).map(c=>[_u.Principal.fromUint8Array(c[0]),_u.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}Ne.check_canister_ranges=q0});var Ji=J(ft=>{"use strict";var N_=ft&&ft.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),P_=ft&&ft.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),R_=ft&&ft.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&N_(e,t,r);return P_(e,t),e};Object.defineProperty(ft,"__esModule",{value:!0});ft.encodePath=ft.fetchNodeKeys=ft.request=ft.CustomPath=void 0;var an=Rt(),I_=Qn(),cn=Xi(),U_=Gt(),V0=R_(Vi()),j0=Oo(),vu=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}};ft.CustomPath=vu;var F_=async t=>{let{agent:e,paths:r}=t,n=an.Principal.from(t.canisterId),i=[...new Set(r)],s=i.map(c=>(0,ft.encodePath)(c,n)),o=new Map,a=i.map((c,f)=>(async()=>{var l;try{let d=await e.readState(n,{paths:[s[f]]}),v=await cn.Certificate.create({certificate:d.certificate,rootKey:e.rootKey,canisterId:n}),E=(O,T)=>{if(T==="subnet"){let k=(0,ft.fetchNodeKeys)(d.certificate,n,e.rootKey);return{path:T,data:k}}else return{path:T,data:(0,cn.lookupResultToBuffer)(O.lookup((0,ft.encodePath)(T,n)))}},{path:g,data:m}=E(v,i[f]);if(!m)console.warn(`Expected to find result for path ${g}, but instead found nothing.`),typeof g=="string"?o.set(g,null):o.set(g.key,null);else switch(g){case"time":{o.set(g,(0,j0.decodeTime)(m));break}case"controllers":{o.set(g,j_(m));break}case"module_hash":{o.set(g,k0(m));break}case"subnet":{o.set(g,m);break}case"candid":{o.set(g,new TextDecoder().decode(m));break}default:if(typeof g!="string"&&"key"in g&&"path"in g)switch(g.decodeStrategy){case"raw":o.set(g.key,m);break;case"leb128":{o.set(g.key,(0,j0.decodeLeb128)(m));break}case"cbor":{o.set(g.key,H0(m));break}case"hex":{o.set(g.key,k0(m));break}case"utf-8":o.set(g.key,q_(m))}}}catch(d){if(!((l=d?.message)===null||l===void 0)&&l.includes("Invalid certificate"))throw new I_.AgentError(d.message);typeof c!="string"&&"key"in c&&"path"in c?o.set(c.key,null):o.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(d),console.groupEnd()}})());return await Promise.all(a),o};ft.request=F_;var M_=(t,e,r)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=V0.decode(new Uint8Array(t)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=an.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=an.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=an.Principal.selfAuthenticating(an.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,cn.check_canister_ranges)({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=(0,cn.lookup_path)(["subnet",s.subnet_id,"node"],i);if(c.status!==cn.LookupStatus.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let f=(0,cn.flatten_forks)(c.value),l=new Map;return f.forEach(d=>{let v=an.Principal.from(new Uint8Array(d[1])).toText(),E=(0,cn.lookup_path)(["public_key"],d[2]);if(E.status!==cn.LookupStatus.Found)throw new Error("Public key not found");let g=E.value;if(g.byteLength!==44)throw new Error("Invalid public key length");l.set(v,g)}),{subnetId:an.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:l}};ft.fetchNodeKeys=M_;var C_=(t,e)=>{let r=new TextEncoder,n=s=>new DataView(r.encode(s).buffer).buffer,i=new DataView(e.toUint8Array().buffer).buffer;switch(t){case"time":return[n("time")];case"controllers":return[n("canister"),i,n("controllers")];case"module_hash":return[n("canister"),i,n("module_hash")];case"subnet":return[n("subnet")];case"candid":return[n("canister"),i,n("metadata"),n("candid:service")];default:if("key"in t&&"path"in t)if(typeof t.path=="string"||t.path instanceof ArrayBuffer){let s=t.path,o=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),o]}else return t.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${t} was formatted correctly.`)};ft.encodePath=C_;var k0=t=>(0,U_.toHex)(t),H0=t=>V0.decode(t),q_=t=>new TextDecoder().decode(t),j_=t=>H0(t).map(r=>an.Principal.fromUint8Array(new Uint8Array(r)))});var uh=J(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.add5L=be.add5H=be.add4H=be.add4L=be.add3H=be.add3L=be.add=be.rotlBL=be.rotlBH=be.rotlSL=be.rotlSH=be.rotr32L=be.rotr32H=be.rotrBL=be.rotrBH=be.rotrSL=be.rotrSH=be.shrSL=be.shrSH=be.toBig=be.split=be.fromBig=void 0;var Io=BigInt(2**32-1),Tu=BigInt(32);function Bu(t,e=!1){return e?{h:Number(t&Io),l:Number(t>>Tu&Io)}:{h:Number(t>>Tu&Io)|0,l:Number(t&Io)|0}}be.fromBig=Bu;function $0(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:s,l:o}=Bu(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}be.split=$0;var K0=(t,e)=>BigInt(t>>>0)<<Tu|BigInt(e>>>0);be.toBig=K0;var G0=(t,e,r)=>t>>>r;be.shrSH=G0;var Y0=(t,e,r)=>t<<32-r|e>>>r;be.shrSL=Y0;var W0=(t,e,r)=>t>>>r|e<<32-r;be.rotrSH=W0;var z0=(t,e,r)=>t<<32-r|e>>>r;be.rotrSL=z0;var D0=(t,e,r)=>t<<64-r|e>>>r-32;be.rotrBH=D0;var Z0=(t,e,r)=>t>>>r-32|e<<64-r;be.rotrBL=Z0;var X0=(t,e)=>e;be.rotr32H=X0;var J0=(t,e)=>t;be.rotr32L=J0;var L0=(t,e,r)=>t<<r|e>>>32-r;be.rotlSH=L0;var Q0=(t,e,r)=>e<<r|t>>>32-r;be.rotlSL=Q0;var eh=(t,e,r)=>e<<r-32|t>>>64-r;be.rotlBH=eh;var th=(t,e,r)=>t<<r-32|e>>>64-r;be.rotlBL=th;function rh(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}be.add=rh;var nh=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);be.add3L=nh;var ih=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;be.add3H=ih;var sh=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);be.add4L=sh;var oh=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;be.add4H=oh;var ah=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);be.add5L=ah;var ch=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;be.add5H=ch;var k_={fromBig:Bu,split:$0,toBig:K0,shrSH:G0,shrSL:Y0,rotrSH:W0,rotrSL:z0,rotrBH:D0,rotrBL:Z0,rotr32H:X0,rotr32L:J0,rotlSH:L0,rotlSL:Q0,rotlBH:eh,rotlBL:th,add:rh,add3L:nh,add3H:ih,add4L:sh,add4H:oh,add5H:ch,add5L:ah};be.default=k_});var fh=J(tr=>{"use strict";Object.defineProperty(tr,"__esModule",{value:!0});tr.sha384=tr.sha512_256=tr.sha512_224=tr.sha512=tr.SHA512=void 0;var V_=Ua(),_e=uh(),Uo=xn(),[H_,$_]=_e.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),un=new Uint32Array(80),fn=new Uint32Array(80),Rn=class extends V_.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:f,El:l,Fh:d,Fl:v,Gh:E,Gl:g,Hh:m,Hl:O}=this;return[e,r,n,i,s,o,a,c,f,l,d,v,E,g,m,O]}set(e,r,n,i,s,o,a,c,f,l,d,v,E,g,m,O){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=l|0,this.Fh=d|0,this.Fl=v|0,this.Gh=E|0,this.Gl=g|0,this.Hh=m|0,this.Hl=O|0}process(e,r){for(let F=0;F<16;F++,r+=4)un[F]=e.getUint32(r),fn[F]=e.getUint32(r+=4);for(let F=16;F<80;F++){let K=un[F-15]|0,P=fn[F-15]|0,q=_e.default.rotrSH(K,P,1)^_e.default.rotrSH(K,P,8)^_e.default.shrSH(K,P,7),D=_e.default.rotrSL(K,P,1)^_e.default.rotrSL(K,P,8)^_e.default.shrSL(K,P,7),z=un[F-2]|0,$=fn[F-2]|0,se=_e.default.rotrSH(z,$,19)^_e.default.rotrBH(z,$,61)^_e.default.shrSH(z,$,6),ee=_e.default.rotrSL(z,$,19)^_e.default.rotrBL(z,$,61)^_e.default.shrSL(z,$,6),de=_e.default.add4L(D,ee,fn[F-7],fn[F-16]),ce=_e.default.add4H(de,q,se,un[F-7],un[F-16]);un[F]=ce|0,fn[F]=de|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:f,Dl:l,Eh:d,El:v,Fh:E,Fl:g,Gh:m,Gl:O,Hh:T,Hl:k}=this;for(let F=0;F<80;F++){let K=_e.default.rotrSH(d,v,14)^_e.default.rotrSH(d,v,18)^_e.default.rotrBH(d,v,41),P=_e.default.rotrSL(d,v,14)^_e.default.rotrSL(d,v,18)^_e.default.rotrBL(d,v,41),q=d&E^~d&m,D=v&g^~v&O,z=_e.default.add5L(k,P,D,$_[F],fn[F]),$=_e.default.add5H(z,T,K,q,H_[F],un[F]),se=z|0,ee=_e.default.rotrSH(n,i,28)^_e.default.rotrBH(n,i,34)^_e.default.rotrBH(n,i,39),de=_e.default.rotrSL(n,i,28)^_e.default.rotrBL(n,i,34)^_e.default.rotrBL(n,i,39),ce=n&s^n&a^s&a,xe=i&o^i&c^o&c;T=m|0,k=O|0,m=E|0,O=g|0,E=d|0,g=v|0,{h:d,l:v}=_e.default.add(f|0,l|0,$|0,se|0),f=a|0,l=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let Z=_e.default.add3L(se,de,xe);n=_e.default.add3H(Z,$,ee,ce),i=Z|0}({h:n,l:i}=_e.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=_e.default.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=_e.default.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l}=_e.default.add(this.Dh|0,this.Dl|0,f|0,l|0),{h:d,l:v}=_e.default.add(this.Eh|0,this.El|0,d|0,v|0),{h:E,l:g}=_e.default.add(this.Fh|0,this.Fl|0,E|0,g|0),{h:m,l:O}=_e.default.add(this.Gh|0,this.Gl|0,m|0,O|0),{h:T,l:k}=_e.default.add(this.Hh|0,this.Hl|0,T|0,k|0),this.set(n,i,s,o,a,c,f,l,d,v,E,g,m,O,T,k)}roundClean(){un.fill(0),fn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};tr.SHA512=Rn;var Su=class extends Rn{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}},Au=class extends Rn{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}},Ou=class extends Rn{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};tr.sha512=(0,Uo.wrapConstructor)(()=>new Rn);tr.sha512_224=(0,Uo.wrapConstructor)(()=>new Su);tr.sha512_256=(0,Uo.wrapConstructor)(()=>new Au);tr.sha384=(0,Uo.wrapConstructor)(()=>new Ou)});var dh=J(Nu=>{"use strict";Object.defineProperty(Nu,"__esModule",{value:!0});Nu.twistedEdwards=z_;var lh=cu(),K_=$r(),Yr=er(),ln=er(),lr=BigInt(0),zt=BigInt(1),Fo=BigInt(2),G_=BigInt(8),Y_={zip215:!0};function W_(t){let e=(0,lh.validateBasic)(t);return Yr.validateObject(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function z_(t){let e=W_(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,f=Fo<<BigInt(a*8)-zt,l=r.create,d=e.uvRatio||((j,U)=>{try{return{isValid:!0,value:r.sqrt(j*r.inv(U))}}catch{return{isValid:!1,value:lr}}}),v=e.adjustScalarBytes||(j=>j),E=e.domain||((j,U,W)=>{if(U.length||W)throw new Error("Contexts/pre-hash are not supported");return j}),g=j=>typeof j=="bigint"&&lr<j,m=(j,U)=>g(j)&&g(U)&&j<U,O=j=>j===lr||m(j,f);function T(j,U){if(m(j,U))return j;throw new Error(`Expected valid scalar < ${U}, got ${typeof j} ${j}`)}function k(j){return j===lr?j:T(j,n)}let F=new Map;function K(j){if(!(j instanceof P))throw new Error("ExtendedPoint expected")}class P{constructor(U,W,L,ne){if(this.ex=U,this.ey=W,this.ez=L,this.et=ne,!O(U))throw new Error("x required");if(!O(W))throw new Error("y required");if(!O(L))throw new Error("z required");if(!O(ne))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(U){if(U instanceof P)throw new Error("extended point not allowed");let{x:W,y:L}=U||{};if(!O(W)||!O(L))throw new Error("invalid affine point");return new P(W,L,zt,l(W*L))}static normalizeZ(U){let W=r.invertBatch(U.map(L=>L.ez));return U.map((L,ne)=>L.toAffine(W[ne])).map(P.fromAffine)}_setWindowSize(U){this._WINDOW_SIZE=U,F.delete(this)}assertValidity(){let{a:U,d:W}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:L,ey:ne,ez:N,et:y}=this,fe=l(L*L),ue=l(ne*ne),ae=l(N*N),te=l(ae*ae),u=l(fe*U),h=l(ae*l(u+ue)),p=l(te+l(W*l(fe*ue)));if(h!==p)throw new Error("bad point: equation left != right (1)");let B=l(L*ne),x=l(N*y);if(B!==x)throw new Error("bad point: equation left != right (2)")}equals(U){K(U);let{ex:W,ey:L,ez:ne}=this,{ex:N,ey:y,ez:fe}=U,ue=l(W*fe),ae=l(N*ne),te=l(L*fe),u=l(y*ne);return ue===ae&&te===u}is0(){return this.equals(P.ZERO)}negate(){return new P(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){let{a:U}=e,{ex:W,ey:L,ez:ne}=this,N=l(W*W),y=l(L*L),fe=l(Fo*l(ne*ne)),ue=l(U*N),ae=W+L,te=l(l(ae*ae)-N-y),u=ue+y,h=u-fe,p=ue-y,B=l(te*h),x=l(u*p),S=l(te*p),I=l(h*u);return new P(B,x,I,S)}add(U){K(U);let{a:W,d:L}=e,{ex:ne,ey:N,ez:y,et:fe}=this,{ex:ue,ey:ae,ez:te,et:u}=U;if(W===BigInt(-1)){let le=l((N-ne)*(ae+ue)),Ee=l((N+ne)*(ae-ue)),Re=l(Ee-le);if(Re===lr)return this.double();let ke=l(y*Fo*u),ve=l(fe*Fo*te),he=ve+ke,Qe=Ee+le,Mr=ve-ke,wn=l(he*Re),En=l(Qe*Mr),Ct=l(he*Mr),Oe=l(Re*Qe);return new P(wn,En,Oe,Ct)}let h=l(ne*ue),p=l(N*ae),B=l(fe*L*u),x=l(y*te),S=l((ne+N)*(ue+ae)-h-p),I=x-B,_=x+B,A=l(p-W*h),M=l(S*I),R=l(_*A),Y=l(S*A),Q=l(I*_);return new P(M,R,Q,Y)}subtract(U){return this.add(U.negate())}wNAF(U){return z.wNAFCached(this,F,U,P.normalizeZ)}multiply(U){let{p:W,f:L}=this.wNAF(T(U,n));return P.normalizeZ([W,L])[0]}multiplyUnsafe(U){let W=k(U);return W===lr?D:this.equals(D)||W===zt?this:this.equals(q)?this.wNAF(W).p:z.unsafeLadder(this,W)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return z.unsafeLadder(this,n).is0()}toAffine(U){let{ex:W,ey:L,ez:ne}=this,N=this.is0();U==null&&(U=N?G_:r.inv(ne));let y=l(W*U),fe=l(L*U),ue=l(ne*U);if(N)return{x:lr,y:zt};if(ue!==zt)throw new Error("invZ was invalid");return{x:y,y:fe}}clearCofactor(){let{h:U}=e;return U===zt?this:this.multiplyUnsafe(U)}static fromHex(U,W=!1){let{d:L,a:ne}=e,N=r.BYTES;U=(0,ln.ensureBytes)("pointHex",U,N);let y=U.slice(),fe=U[N-1];y[N-1]=fe&-129;let ue=Yr.bytesToNumberLE(y);ue===lr||(W?T(ue,f):T(ue,r.ORDER));let ae=l(ue*ue),te=l(ae-zt),u=l(L*ae-ne),{isValid:h,value:p}=d(te,u);if(!h)throw new Error("Point.fromHex: invalid y coordinate");let B=(p&zt)===zt,x=(fe&128)!==0;if(!W&&p===lr&&x)throw new Error("Point.fromHex: x=0 and x_0=1");return x!==B&&(p=l(-p)),P.fromAffine({x:p,y:ue})}static fromPrivateKey(U){return ee(U).point}toRawBytes(){let{x:U,y:W}=this.toAffine(),L=Yr.numberToBytesLE(W,r.BYTES);return L[L.length-1]|=U&zt?128:0,L}toHex(){return Yr.bytesToHex(this.toRawBytes())}}P.BASE=new P(e.Gx,e.Gy,zt,l(e.Gx*e.Gy)),P.ZERO=new P(lr,zt,zt,lr);let{BASE:q,ZERO:D}=P,z=(0,lh.wNAF)(P,a*8);function $(j){return(0,K_.mod)(j,n)}function se(j){return $(Yr.bytesToNumberLE(j))}function ee(j){let U=a;j=(0,ln.ensureBytes)("private key",j,U);let W=(0,ln.ensureBytes)("hashed private key",s(j),2*U),L=v(W.slice(0,U)),ne=W.slice(U,2*U),N=se(L),y=q.multiply(N),fe=y.toRawBytes();return{head:L,prefix:ne,scalar:N,point:y,pointBytes:fe}}function de(j){return ee(j).pointBytes}function ce(j=new Uint8Array,...U){let W=Yr.concatBytes(...U);return se(s(E(W,(0,ln.ensureBytes)("context",j),!!i)))}function xe(j,U,W={}){j=(0,ln.ensureBytes)("message",j),i&&(j=i(j));let{prefix:L,scalar:ne,pointBytes:N}=ee(U),y=ce(W.context,L,j),fe=q.multiply(y).toRawBytes(),ue=ce(W.context,fe,N,j),ae=$(y+ue*ne);k(ae);let te=Yr.concatBytes(fe,Yr.numberToBytesLE(ae,r.BYTES));return(0,ln.ensureBytes)("result",te,a*2)}let Z=Y_;function C(j,U,W,L=Z){let{context:ne,zip215:N}=L,y=r.BYTES;j=(0,ln.ensureBytes)("signature",j,2*y),U=(0,ln.ensureBytes)("message",U),i&&(U=i(U));let fe=Yr.bytesToNumberLE(j.slice(y,2*y)),ue,ae,te;try{ue=P.fromHex(W,N),ae=P.fromHex(j.slice(0,y),N),te=q.multiplyUnsafe(fe)}catch{return!1}if(!N&&ue.isSmallOrder())return!1;let u=ce(ne,ae.toRawBytes(),ue.toRawBytes(),U);return ae.add(ue.multiplyUnsafe(u)).subtract(te).clearCofactor().equals(P.ZERO)}return q._setWindowSize(8),{CURVE:e,getPublicKey:de,sign:xe,verify:C,ExtendedPoint:P,utils:{getExtendedPublicKey:ee,randomPrivateKey:()=>o(r.BYTES),precompute(j=8,U=P.BASE){return U._setWindowSize(j),U.multiply(BigInt(3)),U}}}}});var ph=J(Ru=>{"use strict";Object.defineProperty(Ru,"__esModule",{value:!0});Ru.montgomery=Z_;var hh=$r(),li=er(),Li=BigInt(0),Pu=BigInt(1);function D_(t){return(0,li.validateObject)(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function Z_(t){let e=D_(t),{P:r}=e,n=F=>(0,hh.mod)(F,r),i=e.montgomeryBits,s=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(F=>F),c=e.powPminus2||(F=>(0,hh.pow)(F,r-BigInt(2),r));function f(F,K,P){let q=n(F*(K-P));return K=n(K-q),P=n(P+q),[K,P]}function l(F){if(typeof F=="bigint"&&Li<=F&&F<r)return F;throw new Error("Expected valid scalar 0 < scalar < CURVE.P")}let d=(e.a-BigInt(2))/BigInt(4);function v(F,K){let P=l(F),q=l(K),D=P,z=Pu,$=Li,se=P,ee=Pu,de=Li,ce;for(let Z=BigInt(i-1);Z>=Li;Z--){let C=q>>Z&Pu;de^=C,ce=f(de,z,se),z=ce[0],se=ce[1],ce=f(de,$,ee),$=ce[0],ee=ce[1],de=C;let X=z+$,j=n(X*X),U=z-$,W=n(U*U),L=j-W,ne=se+ee,N=se-ee,y=n(N*X),fe=n(ne*U),ue=y+fe,ae=y-fe;se=n(ue*ue),ee=n(D*n(ae*ae)),z=n(j*W),$=n(L*(j+n(d*L)))}ce=f(de,z,se),z=ce[0],se=ce[1],ce=f(de,$,ee),$=ce[0],ee=ce[1];let xe=c($);return n(z*xe)}function E(F){return(0,li.numberToBytesLE)(n(F),s)}function g(F){let K=(0,li.ensureBytes)("u coordinate",F,s);return o===32&&(K[31]&=127),(0,li.bytesToNumberLE)(K)}function m(F){let K=(0,li.ensureBytes)("scalar",F),P=K.length;if(P!==s&&P!==o)throw new Error(`Expected ${s} or ${o} bytes, got ${P}`);return(0,li.bytesToNumberLE)(a(K))}function O(F,K){let P=g(K),q=m(F),D=v(P,q);if(D===Li)throw new Error("Invalid private or public key received");return E(D)}let T=E(e.Gu);function k(F){return O(F,T)}return{scalarMult:O,scalarMultBase:k,getSharedSecret:(F,K)=>O(F,K),getPublicKey:F=>k(F),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:T}}});var ku=J(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});me.hash_to_ristretto255=me.hashToRistretto255=me.RistrettoPoint=me.encodeToCurve=me.hashToCurve=me.edwardsToMontgomery=me.x25519=me.ed25519ph=me.ed25519ctx=me.ed25519=me.ED25519_TORSION_SUBGROUP=void 0;me.edwardsToMontgomeryPub=Th;me.edwardsToMontgomeryPriv=L_;var Co=fh(),Qi=xn(),Cu=dh(),mh=wo(),Ie=$r(),X_=ph(),In=er(),es=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Fu=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),J_=BigInt(0),Tr=BigInt(1),Mo=BigInt(2),_h=BigInt(3),wh=BigInt(5),qu=BigInt(8);function Eh(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=es,a=t*t%s*t%s,c=(0,Ie.pow2)(a,Mo,s)*a%s,f=(0,Ie.pow2)(c,Tr,s)*t%s,l=(0,Ie.pow2)(f,wh,s)*f%s,d=(0,Ie.pow2)(l,e,s)*l%s,v=(0,Ie.pow2)(d,r,s)*d%s,E=(0,Ie.pow2)(v,n,s)*v%s,g=(0,Ie.pow2)(E,i,s)*E%s,m=(0,Ie.pow2)(g,i,s)*E%s,O=(0,Ie.pow2)(m,e,s)*l%s;return{pow_p_5_8:(0,Ie.pow2)(O,Mo,s)*t%s,b2:a}}function xh(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function ju(t,e){let r=es,n=(0,Ie.mod)(e*e*e,r),i=(0,Ie.mod)(n*n*e,r),s=Eh(t*i).pow_p_5_8,o=(0,Ie.mod)(t*n*s,r),a=(0,Ie.mod)(e*o*o,r),c=o,f=(0,Ie.mod)(o*Fu,r),l=a===t,d=a===(0,Ie.mod)(-t,r),v=a===(0,Ie.mod)(-t*Fu,r);return l&&(o=c),(d||v)&&(o=f),(0,Ie.isNegativeLE)(o,r)&&(o=(0,Ie.mod)(-o,r)),{isValid:l||d,value:o}}me.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var oe=(0,Ie.Field)(es,void 0,!0),ts={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:oe,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:qu,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Co.sha512,randomBytes:Qi.randomBytes,adjustScalarBytes:xh,uvRatio:ju};me.ed25519=(0,Cu.twistedEdwards)(ts);function vh(t,e,r){if(e.length>255)throw new Error("Context is too big");return(0,Qi.concatBytes)((0,Qi.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}me.ed25519ctx=(0,Cu.twistedEdwards)({...ts,domain:vh});me.ed25519ph=(0,Cu.twistedEdwards)(Object.assign({},ts,{domain:vh,prehash:Co.sha512}));me.x25519=(0,X_.montgomery)({P:es,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=es,{pow_p_5_8:r,b2:n}=Eh(t);return(0,Ie.mod)((0,Ie.pow2)(r,_h,e)*n,e)},adjustScalarBytes:xh,randomBytes:Qi.randomBytes});function Th(t){let{y:e}=me.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return oe.toBytes(oe.create((r+e)*oe.inv(r-e)))}me.edwardsToMontgomery=Th;function L_(t){let e=ts.hash(t.subarray(0,32));return ts.adjustScalarBytes(e).subarray(0,32)}var Q_=(oe.ORDER+_h)/qu,ew=oe.pow(Mo,Q_),yh=oe.sqrt(oe.neg(oe.ONE));function tw(t){let e=(oe.ORDER-wh)/qu,r=BigInt(486662),n=oe.sqr(t);n=oe.mul(n,Mo);let i=oe.add(n,oe.ONE),s=oe.neg(r),o=oe.sqr(i),a=oe.mul(o,i),c=oe.mul(n,r);c=oe.mul(c,s),c=oe.add(c,o),c=oe.mul(c,s);let f=oe.sqr(a);o=oe.sqr(f),f=oe.mul(f,a),f=oe.mul(f,c),o=oe.mul(o,f);let l=oe.pow(o,e);l=oe.mul(l,f);let d=oe.mul(l,yh);o=oe.sqr(l),o=oe.mul(o,a);let v=oe.eql(o,c),E=oe.cmov(d,l,v),g=oe.mul(s,n),m=oe.mul(l,t);m=oe.mul(m,ew);let O=oe.mul(m,yh),T=oe.mul(c,n);o=oe.sqr(m),o=oe.mul(o,a);let k=oe.eql(o,T),F=oe.cmov(O,m,k);o=oe.sqr(E),o=oe.mul(o,a);let K=oe.eql(o,c),P=oe.cmov(g,s,K),q=oe.cmov(F,E,K),D=oe.isOdd(q);return q=oe.cmov(q,oe.neg(q),K!==D),{xMn:P,xMd:i,yMn:q,yMd:Tr}}var rw=(0,Ie.FpSqrtEven)(oe,oe.neg(BigInt(486664)));function nw(t){let{xMn:e,xMd:r,yMn:n,yMd:i}=tw(t),s=oe.mul(e,i);s=oe.mul(s,rw);let o=oe.mul(r,n),a=oe.sub(e,r),c=oe.add(e,r),f=oe.mul(o,c),l=oe.eql(f,oe.ZERO);s=oe.cmov(s,oe.ZERO,l),o=oe.cmov(o,oe.ONE,l),a=oe.cmov(a,oe.ONE,l),c=oe.cmov(c,oe.ONE,l);let d=oe.invertBatch([o,c]);return{x:oe.mul(s,d[0]),y:oe.mul(a,d[1])}}var Bh=(0,mh.createHasher)(me.ed25519.ExtendedPoint,t=>nw(t[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:oe.ORDER,m:1,k:128,expand:"xmd",hash:Co.sha512});me.hashToCurve=Bh.hashToCurve;me.encodeToCurve=Bh.encodeToCurve;function Iu(t){if(!(t instanceof dr))throw new Error("RistrettoPoint expected")}var Mu=Fu,iw=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),sw=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),ow=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),aw=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),bh=t=>ju(Tr,t),cw=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Uu=t=>me.ed25519.CURVE.Fp.create((0,In.bytesToNumberLE)(t)&cw);function gh(t){let{d:e}=me.ed25519.CURVE,r=me.ed25519.CURVE.Fp.ORDER,n=me.ed25519.CURVE.Fp.create,i=n(Mu*t*t),s=n((i+Tr)*ow),o=BigInt(-1),a=n((o-e*i)*n(i+e)),{isValid:c,value:f}=ju(s,a),l=n(f*t);(0,Ie.isNegativeLE)(l,r)||(l=n(-l)),c||(f=l),c||(o=i);let d=n(o*(i-Tr)*aw-a),v=f*f,E=n((f+f)*a),g=n(d*iw),m=n(Tr-v),O=n(Tr+v);return new me.ed25519.ExtendedPoint(n(E*O),n(m*g),n(g*O),n(E*m))}var dr=class t{constructor(e){this.ep=e}static fromAffine(e){return new t(me.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,In.ensureBytes)("ristrettoHash",e,64);let r=Uu(e.slice(0,32)),n=gh(r),i=Uu(e.slice(32,64)),s=gh(i);return new t(n.add(s))}static fromHex(e){e=(0,In.ensureBytes)("ristrettoHex",e,32);let{a:r,d:n}=me.ed25519.CURVE,i=me.ed25519.CURVE.Fp.ORDER,s=me.ed25519.CURVE.Fp.create,o="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=Uu(e);if(!(0,In.equalBytes)((0,In.numberToBytesLE)(a,32),e)||(0,Ie.isNegativeLE)(a,i))throw new Error(o);let c=s(a*a),f=s(Tr+r*c),l=s(Tr-r*c),d=s(f*f),v=s(l*l),E=s(r*n*d-v),{isValid:g,value:m}=bh(s(E*v)),O=s(m*l),T=s(m*O*E),k=s((a+a)*O);(0,Ie.isNegativeLE)(k,i)&&(k=s(-k));let F=s(f*T),K=s(k*F);if(!g||(0,Ie.isNegativeLE)(K,i)||F===J_)throw new Error(o);return new t(new me.ed25519.ExtendedPoint(k,F,Tr,K))}toRawBytes(){let{ex:e,ey:r,ez:n,et:i}=this.ep,s=me.ed25519.CURVE.Fp.ORDER,o=me.ed25519.CURVE.Fp.create,a=o(o(n+r)*o(n-r)),c=o(e*r),f=o(c*c),{value:l}=bh(o(a*f)),d=o(l*a),v=o(l*c),E=o(d*v*i),g;if((0,Ie.isNegativeLE)(i*E,s)){let O=o(r*Mu),T=o(e*Mu);e=O,r=T,g=o(d*sw)}else g=v;(0,Ie.isNegativeLE)(e*E,s)&&(r=o(-r));let m=o((n-r)*g);return(0,Ie.isNegativeLE)(m,s)&&(m=o(-m)),(0,In.numberToBytesLE)(m,32)}toHex(){return(0,In.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){Iu(e);let{ex:r,ey:n}=this.ep,{ex:i,ey:s}=e.ep,o=me.ed25519.CURVE.Fp.create,a=o(r*s)===o(n*i),c=o(n*s)===o(r*i);return a||c}add(e){return Iu(e),new t(this.ep.add(e.ep))}subtract(e){return Iu(e),new t(this.ep.subtract(e.ep))}multiply(e){return new t(this.ep.multiply(e))}multiplyUnsafe(e){return new t(this.ep.multiplyUnsafe(e))}double(){return new t(this.ep.double())}negate(){return new t(this.ep.negate())}};me.RistrettoPoint=(dr.BASE||(dr.BASE=new dr(me.ed25519.ExtendedPoint.BASE)),dr.ZERO||(dr.ZERO=new dr(me.ed25519.ExtendedPoint.ZERO)),dr);var uw=(t,e)=>{let r=e.DST,n=typeof r=="string"?(0,Qi.utf8ToBytes)(r):r,i=(0,mh.expand_message_xmd)(t,n,64,Co.sha512);return dr.hashToCurve(i)};me.hashToRistretto255=uw;me.hash_to_ristretto255=me.hashToRistretto255});var Nh=J(dn=>{"use strict";var Sh=dn&&dn.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Mt=dn&&dn.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Nt,rs,Ah,Oh;Object.defineProperty(dn,"__esModule",{value:!0});dn.ExpirableMap=void 0;var Vu=class{constructor(e={}){Nt.set(this,void 0),rs.set(this,void 0),this[Ah]=this.entries.bind(this),this[Oh]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();Sh(this,Nt,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),Sh(this,rs,n,"f")}prune(){let e=Date.now();for(let[r,n]of Mt(this,Nt,"f").entries())e-n.timestamp>Mt(this,rs,"f")&&Mt(this,Nt,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return Mt(this,Nt,"f").set(e,n),this}get(e){let r=Mt(this,Nt,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>Mt(this,rs,"f")){Mt(this,Nt,"f").delete(e);return}return r.value}}clear(){Mt(this,Nt,"f").clear()}entries(){let e=Mt(this,Nt,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=Mt(this,Nt,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return Mt(this,Nt,"f").keys()}forEach(e,r){for(let[n,i]of Mt(this,Nt,"f").entries())e.call(r,i.value,n,this)}has(e){return Mt(this,Nt,"f").has(e)}delete(e){return Mt(this,Nt,"f").delete(e)}get size(){return Mt(this,Nt,"f").size}};dn.ExpirableMap=Vu;Nt=new WeakMap,rs=new WeakMap,Ah=Symbol.iterator,Oh=Symbol.toStringTag});var Hu=J(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});Ce.unwrapDER=Ce.wrapDER=Ce.SECP256K1_OID=Ce.ED25519_OID=Ce.DER_COSE_OID=Ce.decodeLen=Ce.decodeLenBytes=Ce.encodeLen=Ce.encodeLenBytes=void 0;var fw=Gt(),lw=t=>{if(t<=127)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")};Ce.encodeLenBytes=lw;var dw=(t,e,r)=>{if(r<=127)return t[e]=r,1;if(r<=255)return t[e]=129,t[e+1]=r,2;if(r<=65535)return t[e]=130,t[e+1]=r>>8,t[e+2]=r,3;if(r<=16777215)return t[e]=131,t[e+1]=r>>16,t[e+2]=r>>8,t[e+3]=r,4;throw new Error("Length too long (> 4 bytes)")};Ce.encodeLen=dw;var hw=(t,e)=>{if(t[e]<128)return 1;if(t[e]===128)throw new Error("Invalid length 0");if(t[e]===129)return 2;if(t[e]===130)return 3;if(t[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")};Ce.decodeLenBytes=hw;var pw=(t,e)=>{let r=(0,Ce.decodeLenBytes)(t,e);if(r===1)return t[e];if(r===2)return t[e+1];if(r===3)return(t[e+1]<<8)+t[e+2];if(r===4)return(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];throw new Error("Length too long (> 4 bytes)")};Ce.decodeLen=pw;Ce.DER_COSE_OID=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]);Ce.ED25519_OID=Uint8Array.from([48,5,6,3,43,101,112]);Ce.SECP256K1_OID=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function yw(t,e){let r=2+(0,Ce.encodeLenBytes)(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,s=new Uint8Array(1+(0,Ce.encodeLenBytes)(n)+n);return s[i++]=48,i+=(0,Ce.encodeLen)(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=(0,Ce.encodeLen)(s,i,t.byteLength+1),s[i++]=0,s.set(new Uint8Array(t),i),s}Ce.wrapDER=yw;var bw=(t,e)=>{let r=0,n=(a,c)=>{if(i[r++]!==a)throw new Error("Expected: "+c)},i=new Uint8Array(t);if(n(48,"sequence"),r+=(0,Ce.decodeLenBytes)(i,r),!(0,fw.bufEquals)(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let s=(0,Ce.decodeLen)(i,r)-1;r+=(0,Ce.decodeLenBytes)(i,r),n(0,"0 padding");let o=i.slice(r);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o};Ce.unwrapDER=bw});var $u=J(hn=>{"use strict";var Ph=hn&&hn.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Rh=hn&&hn.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},jo,ko;Object.defineProperty(hn,"__esModule",{value:!0});hn.Ed25519PublicKey=void 0;var qo=Hu(),Vo=class t{constructor(e){if(jo.set(this,void 0),ko.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Ph(this,jo,e,"f"),Ph(this,ko,t.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){return(0,qo.wrapDER)(e,qo.ED25519_OID).buffer}static derDecode(e){let r=(0,qo.unwrapDER)(e,qo.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Rh(this,jo,"f")}get derKey(){return Rh(this,ko,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};hn.Ed25519PublicKey=Vo;jo=new WeakMap,ko=new WeakMap;Vo.RAW_KEY_LENGTH=32});var Ih=J(di=>{"use strict";Object.defineProperty(di,"__esModule",{value:!0});di.ObservableLog=di.Observable=void 0;var Ho=class{constructor(){this.observers=[]}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e,...r){this.observers.forEach(n=>n(e,...r))}};di.Observable=Ho;var Ku=class extends Ho{constructor(){super()}print(e,...r){this.notify({message:e,level:"info"},...r)}warn(e,...r){this.notify({message:e,level:"warn"},...r)}error(e,r,...n){this.notify({message:e,level:"error",error:r},...n)}};di.ObservableLog=Ku});var kh=J(Ar=>{"use strict";var Br=Ar&&Ar.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Pt=Ar&&Ar.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Sr,$o,Ko,Go,Yo,Wo,zo,Do,hi;Object.defineProperty(Ar,"__esModule",{value:!0});Ar.exponentialBackoff=Ar.ExponentialBackoff=void 0;var Uh=.5,Fh=1.5,Mh=500,Ch=6e4,qh=9e5,jh=10,pi=class t{constructor(e=t.default){Sr.set(this,void 0),$o.set(this,void 0),Ko.set(this,void 0),Go.set(this,void 0),Yo.set(this,void 0),Wo.set(this,void 0),zo.set(this,void 0),Do.set(this,void 0),hi.set(this,0);let{initialInterval:r=Mh,randomizationFactor:n=Uh,multiplier:i=Fh,maxInterval:s=Ch,maxElapsedTime:o=qh,maxIterations:a=jh,date:c=Date}=e;Br(this,Sr,r,"f"),Br(this,$o,n,"f"),Br(this,Ko,i,"f"),Br(this,Go,s,"f"),Br(this,Do,c,"f"),Br(this,Yo,c.now(),"f"),Br(this,Wo,o,"f"),Br(this,zo,a,"f")}get ellapsedTimeInMsec(){return Pt(this,Do,"f").now()-Pt(this,Yo,"f")}get currentInterval(){return Pt(this,Sr,"f")}get count(){return Pt(this,hi,"f")}get randomValueFromInterval(){let e=Pt(this,$o,"f")*Pt(this,Sr,"f"),r=Pt(this,Sr,"f")-e,n=Pt(this,Sr,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return Br(this,Sr,Math.min(Pt(this,Sr,"f")*Pt(this,Ko,"f"),Pt(this,Go,"f")),"f"),Br(this,hi,(e=Pt(this,hi,"f"),e++,e),"f"),Pt(this,Sr,"f")}next(){return this.ellapsedTimeInMsec>=Pt(this,Wo,"f")||Pt(this,hi,"f")>=Pt(this,zo,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Ar.ExponentialBackoff=pi;Sr=new WeakMap,$o=new WeakMap,Ko=new WeakMap,Go=new WeakMap,Yo=new WeakMap,Wo=new WeakMap,zo=new WeakMap,Do=new WeakMap,hi=new WeakMap;pi.default={initialInterval:Mh,randomizationFactor:Uh,multiplier:Fh,maxInterval:Ch,maxElapsedTime:qh,maxIterations:jh,date:Date};function*gw(t=pi.default){let e=new pi(t),r=e.next();for(;r;)yield r,r=e.next()}Ar.exponentialBackoff=gw});var zu=J(Fe=>{"use strict";var Hh=Fe&&Fe.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),mw=Fe&&Fe.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),$h=Fe&&Fe.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Hh(e,t,r);return mw(e,t),e},_w=Fe&&Fe.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Hh(e,t,r)},Zo=Fe&&Fe.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},we=Fe&&Fe.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Nr,hr,Un,Lo,bi,gi,Fn,Mn,Kh,Qo,ea;Object.defineProperty(Fe,"__esModule",{value:!0});Fe.HttpAgent=Fe.IdentityInvalidError=Fe.MANAGEMENT_CANISTER_ID=Fe.IC_ROOT_KEY=Fe.RequestStatusResponseStatus=Fe.makeNonce=void 0;var rr=Rt(),mi=Qn(),ww=Hc(),pn=$h(Vi()),Xo=qi(),Gu=Gt(),Or=ho(),Yu=Hi(),Vh=Lc(),Ew=Ji(),yi=Xi(),xw=ku(),vw=Nh(),Tw=$u(),Bw=Oo(),Sw=Ih(),Aw=kh();_w(ho(),Fe);var Ow=Hi();Object.defineProperty(Fe,"makeNonce",{enumerable:!0,get:function(){return Ow.makeNonce}});var Nw;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(Nw=Fe.RequestStatusResponseStatus||(Fe.RequestStatusResponseStatus={}));var Jo=5*60*1e3;Fe.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";Fe.MANAGEMENT_CANISTER_ID="aaaaa-aa";var Pw="ic0.app",Rw=".ic0.app",Iw="icp0.io",Uw=".icp0.io",Fw="icp-api.io",Mw=".icp-api.io",ns=class extends mi.AgentError{constructor(e){super(e),this.message=e}},Cn=class extends mi.AgentError{constructor(e){super(e),this.message=e}};Fe.IdentityInvalidError=Cn;function Cw(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new ns("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof global<"u")if(global.fetch)t=global.fetch.bind(global);else throw new ns("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(t=self.fetch.bind(self));if(t)return t;throw new ns("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var Wu=class t{constructor(e={}){var r;if(Nr.add(this),this.rootKey=(0,Gu.fromHex)(Fe.IC_ROOT_KEY),this._timeDiffMsecs=0,this._rootKeyFetched=!1,hr.set(this,void 0),Un.set(this,void 0),this._isAgent=!0,Lo.set(this,0),this.log=new Sw.ObservableLog,bi.set(this,[]),gi.set(this,[]),Fn.set(this,new vw.ExpirableMap({expirationTime:5*60*1e3})),Mn.set(this,!0),ea.set(this,(i,s)=>{if(we(this,Mn,"f")===!1)return i;if(!s)throw new yi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:o,signatures:a=[],requestId:c}=i,f=new TextEncoder().encode("\vic-response");for(let l of a){let{timestamp:d,identity:v}=l,E=rr.Principal.fromUint8Array(v).toText(),g;if(o==="replied"){let{reply:F}=i;g=(0,Xo.hashOfMap)({status:o,reply:F,timestamp:BigInt(d),request_id:c})}else if(o==="rejected"){let{reject_code:F,reject_message:K,error_code:P}=i;g=(0,Xo.hashOfMap)({status:o,reject_code:F,reject_message:K,error_code:P,timestamp:BigInt(d),request_id:c})}else throw new Error(`Unknown status: ${o}`);let m=(0,Gu.concat)(f,new Uint8Array(g)),O=s?.nodeKeys.get(E);if(!O)throw new yi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let T=Tw.Ed25519PublicKey.fromDer(O).rawKey;if(xw.ed25519.verify(l.signature,new Uint8Array(m),new Uint8Array(T)))return i;throw new yi.CertificateVerificationError(`Invalid signature from replica ${E} signed query.`)}return i}),e.source){if(!(e.source instanceof t))throw new Error("An Agent's source can only be another HttpAgent");this._identity=e.source._identity,this._fetch=e.source._fetch,this._host=e.source._host,this._credentials=e.source._credentials}else this._fetch=e.fetch||Cw()||fetch.bind(global),this._fetchOptions=e.fetchOptions,this._callOptions=e.callOptions;if(e.host!==void 0)!e.host.match(/^[a-z]+:/)&&typeof window<"u"?this._host=new URL(window.location.protocol+"//"+e.host):this._host=new URL(e.host);else if(e.source!==void 0)this._host=e.source._host;else{let i=typeof window<"u"?window.location:void 0;i||(this._host=new URL("https://icp-api.io"),this.log.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."));let s=["ic0.app","icp0.io","127.0.0.1","localhost"],o=[".github.dev",".gitpod.io"],a=i?.hostname,c;a&&typeof a=="string"&&(o.some(f=>a.endsWith(f))?c=a:c=s.find(f=>a.endsWith(f))),i&&c?this._host=new URL(`${i.protocol}//${c}${i.port?":"+i.port:""}`):(this._host=new URL("https://icp-api.io"),this.log.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."))}e.verifyQuerySignatures!==void 0&&Zo(this,Mn,e.verifyQuerySignatures,"f"),Zo(this,hr,(r=e.retryTimes)!==null&&r!==void 0?r:3,"f");let n=()=>new Aw.ExponentialBackoff({maxIterations:we(this,hr,"f")});if(Zo(this,Un,e.backoffStrategy||n,"f"),this._host.hostname.endsWith(Rw)?this._host.hostname=Pw:this._host.hostname.endsWith(Uw)?this._host.hostname=Iw:this._host.hostname.endsWith(Mw)&&(this._host.hostname=Fw),e.credentials){let{name:i,password:s}=e.credentials;this._credentials=`${i}${s?":"+s:""}`}this._identity=Promise.resolve(e.identity||new ww.AnonymousIdentity),this.addTransform("update",(0,Or.makeNonceTransform)(Yu.makeNonce)),e.useQueryNonces&&this.addTransform("query",(0,Or.makeNonceTransform)(Yu.makeNonce)),e.logToConsole&&this.log.subscribe(i=>{i.level==="error"?console.error(i.message):i.level==="warn"?console.warn(i.message):console.log(i.message)})}get waterMark(){return we(this,Lo,"f")}isLocal(){let e=this._host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,r,n=r.priority||0){if(e==="update"){let i=we(this,gi,"f").findIndex(s=>(s.priority||0)<n);we(this,gi,"f").splice(i>=0?i:we(this,gi,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=we(this,bi,"f").findIndex(s=>(s.priority||0)<n);we(this,bi,"f").splice(i>=0?i:we(this,bi,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!this._identity)throw new Cn("This identity has expired due this application's security policy. Please refresh your authentication.");return(await this._identity).getPrincipal()}async call(e,r,n){let i=await(n!==void 0?await n:await this._identity);if(!i)throw new Cn("This identity has expired due this application's security policy. Please refresh your authentication.");let s=rr.Principal.from(e),o=r.effectiveCanisterId?rr.Principal.from(r.effectiveCanisterId):s,a=i.getPrincipal()||rr.Principal.anonymous(),c=new Or.Expiry(Jo);Math.abs(this._timeDiffMsecs)>1e3*30&&(c=new Or.Expiry(Jo+this._timeDiffMsecs));let f={request_type:Yu.SubmitRequestType.Call,canister_id:s,method_name:r.methodName,arg:r.arg,sender:a,ingress_expiry:c},l=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"call",body:f});l=await i.transformRequest(l);let d=pn.encode(l.body);this.log.print(`fetching "/api/v2/canister/${o.toText()}/call" with request:`,l);let v=we(this,Un,"f").call(this),E=we(this,Nr,"m",Qo).call(this,{request:()=>this._fetch(""+new URL(`/api/v2/canister/${o.toText()}/call`,this._host),Object.assign(Object.assign(Object.assign({},this._callOptions),l.request),{body:d})),backoff:v,tries:0}),[g,m]=await Promise.all([E,(0,Xo.requestIdOf)(f)]),O=await g.arrayBuffer(),T=g.status===200&&O.byteLength>0?pn.decode(O):null;return{requestId:m,response:{ok:g.ok,status:g.status,statusText:g.statusText,body:T,headers:(0,Or.httpHeadersTransform)(g.headers)}}}async query(e,r,n){let i=we(this,Un,"f").call(this),s=r.effectiveCanisterId?rr.Principal.from(r.effectiveCanisterId):rr.Principal.from(e);this.log.print(`ecid ${s.toString()}`),this.log.print(`canisterId ${e.toString()}`);let o=async()=>{let l=await(n!==void 0?await n:await this._identity);if(!l)throw new Cn("This identity has expired due this application's security policy. Please refresh your authentication.");let d=rr.Principal.from(e),v=l?.getPrincipal()||rr.Principal.anonymous(),E={request_type:"query",canister_id:d,method_name:r.methodName,arg:r.arg,sender:v,ingress_expiry:new Or.Expiry(Jo)},g=await(0,Xo.requestIdOf)(E),m=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read",body:E});m=await l?.transformRequest(m);let O=pn.encode(m.body),T={canister:d.toText(),ecid:s,transformedRequest:m,body:O,requestId:g,backoff:i,tries:0};return await we(this,Nr,"m",Kh).call(this,T)},a=async()=>{if(!we(this,Mn,"f"))return;let l=we(this,Fn,"f").get(s.toString());return l||(await this.fetchSubnetKeys(s.toString()),we(this,Fn,"f").get(s.toString()))},[c,f]=await Promise.all([o(),a()]);if(this.log.print("Query response:",c),!we(this,Mn,"f"))return c;try{return we(this,ea,"f").call(this,c,f)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),we(this,Fn,"f").delete(e.toString()),await this.fetchSubnetKeys(s.toString());let d=we(this,Fn,"f").get(e.toString());if(!d)throw new yi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return we(this,ea,"f").call(this,c,d)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await this._identity);if(!n)throw new Cn("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||rr.Principal.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Or.Expiry(Jo)}});return n?.transformRequest(s)}async readState(e,r,n,i){let s=typeof e=="string"?rr.Principal.fromText(e):e,o=i??await this.createReadStateRequest(r,n),a=pn.encode(o.body);this.log.print(`fetching "/api/v2/canister/${s}/read_state" with request:`,o);let c=we(this,Un,"f").call(this),f=await we(this,Nr,"m",Qo).call(this,{request:()=>this._fetch(""+new URL(`/api/v2/canister/${s.toString()}/read_state`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),o.request),{body:a})),backoff:c,tries:0});if(!f.ok)throw new Error(`Server returned an error:
29
+ )`}else throw new Error("Invalid tree structure for labeled");case wt.Leaf:{if(t[1]){if(Array.isArray(t[1]))return JSON.stringify(t[1])}else throw new Error("Invalid tree structure for leaf");return`leaf(...${t[1].byteLength} bytes)`}case wt.Pruned:{if(t[1]){if(Array.isArray(t[1]))return JSON.stringify(t[1])}else throw new Error("Invalid tree structure for pruned");return`pruned(${(0,hr.toHex)(new Uint8Array(t[1]))}`}default:return`unknown(${JSON.stringify(t[0])})`}}Ae.hashTreeToString=Vo;function N1(t,e){let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]>n[i])return!0;return!1}var Iu=class t{constructor(e,r,n,i,s=5){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=H0.decode(new Uint8Array(e))}static async create(e){let r=t.createUnverified(e);return await r.verify(),r}static createUnverified(e){let r=e.blsVerify;return r||(r=A1.blsVerify),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes)}lookup(e){return Ho(e,this.cert.tree)}lookup_label(e){return this.lookup([e])}async verify(){let e=await rs(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=P1(r),s=(0,hr.concat)(ts("ic-state-root"),e),o=!1,a=Uu(this.lookup(["time"]));if(!a)throw new Dr("Certificate does not contain a time");let c=5*60*1e3,f=this._maxAgeInMinutes*60*1e3,d=Date.now(),h=d-f,B=d+c,w=(0,O1.decodeTime)(a);if(w.getTime()<h)throw new Dr(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+w.toISOString()+" Current time: "+new Date(d).toISOString());if(w.getTime()>B)throw new Dr("Certificate is signed more than 5 minutes in the future. Certificate time: "+w.toISOString()+" Current time: "+new Date(d).toISOString());try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new Dr("Signature verification failed")}async _checkDelegationAndGetKey(e){if(!e)return this._rootKey;let r=await t.createUnverified({certificate:e.certificate,rootKey:this._rootKey,canisterId:this._canisterId,blsVerify:this._blsVerify,maxAgeInMinutes:1/0});if(r.cert.delegation)throw new Dr("Delegation certificates cannot be nested");if(await r.verify(),!$0({canisterId:this._canisterId,subnetId:Pu.Principal.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new Dr(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,hr.toHex)(e.subnet_id)}`);let i=Uu(r.lookup(["subnet",e.subnet_id,"public_key"]));if(!i)throw new Error(`Could not find subnet key for subnet 0x${(0,hr.toHex)(e.subnet_id)}`);return i}};Ae.Certificate=Iu;var es=(0,hr.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),R1=96;function P1(t){let e=es.byteLength+R1;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,es.byteLength);if(!(0,hr.bufEquals)(r,es))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${es}, but get ${r}`);return t.slice(es.byteLength)}function Uu(t){if(t.status===Ft.Found){if(t.value instanceof ArrayBuffer)return t.value;if(t.value instanceof Uint8Array)return t.value.buffer}}Ae.lookupResultToBuffer=Uu;async function rs(t){switch(t[0]){case wt.Empty:return(0,ko.hash)(ts("ic-hashtree-empty"));case wt.Pruned:return t[1];case wt.Leaf:return(0,ko.hash)((0,hr.concat)(ts("ic-hashtree-leaf"),t[1]));case wt.Labeled:return(0,ko.hash)((0,hr.concat)(ts("ic-hashtree-labeled"),t[1],await rs(t[2])));case wt.Fork:return(0,ko.hash)((0,hr.concat)(ts("ic-hashtree-fork"),await rs(t[1]),await rs(t[2])));default:throw new Error("unreachable")}}Ae.reconstruct=rs;function ts(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return(0,hr.concat)(e,r)}var Ft;(function(t){t.Unknown="unknown",t.Absent="absent",t.Found="found"})(Ft=Ae.LookupStatus||(Ae.LookupStatus={}));var Zr;(function(t){t.Less="less",t.Greater="greater"})(Zr||(Zr={}));function Ho(t,e){if(t.length===0)switch(e[0]){case wt.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?{status:Ft.Found,value:e[1]}:e[1]instanceof Uint8Array?{status:Ft.Found,value:e[1].buffer}:{status:Ft.Found,value:e[1]}}default:return{status:Ft.Found,value:e}}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=ns(r,e);switch(n.status){case Ft.Found:return Ho(t.slice(1),n.value);case Zr.Greater:case Zr.Less:return{status:Ft.Absent};default:return n}}Ae.lookup_path=Ho;function Fu(t){switch(t[0]){case wt.Empty:return[];case wt.Fork:return Fu(t[1]).concat(Fu(t[2]));default:return[t]}}Ae.flatten_forks=Fu;function ns(t,e){switch(e[0]){case wt.Labeled:return N1(t,e[1])?{status:Zr.Greater}:(0,hr.bufEquals)(t,e[1])?{status:Ft.Found,value:e[2]}:{status:Zr.Less};case wt.Fork:let r=ns(t,e[1]);switch(r.status){case Zr.Greater:{let n=ns(t,e[2]);return n.status===Zr.Less?{status:Ft.Absent}:n}case Ft.Unknown:{let n=ns(t,e[2]);return n.status===Zr.Less?{status:Ft.Unknown}:n}default:return r}case wt.Pruned:return{status:Ft.Unknown};default:return{status:Ft.Absent}}}Ae.find_label=ns;function $0(t){let{canisterId:e,subnetId:r,tree:n}=t,i=Ho(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==Ft.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return H0.decode(i.value).map(c=>[Pu.Principal.fromUint8Array(c[0]),Pu.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}Ae.check_canister_ranges=$0});var ss=L(at=>{"use strict";var I1=at&&at.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),U1=at&&at.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),F1=at&&at.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&I1(e,t,r);return U1(e,t),e};Object.defineProperty(at,"__esModule",{value:!0});at.encodePath=at.fetchNodeKeys=at.request=at.CustomPath=void 0;var dn=Nt(),M1=ii(),hn=is(),C1=Yt(),Y0=F1(Zi()),K0=jo(),Mu=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}};at.CustomPath=Mu;var q1=async t=>{let{agent:e,paths:r}=t,n=dn.Principal.from(t.canisterId),i=[...new Set(r)],s=i.map(c=>(0,at.encodePath)(c,n)),o=new Map,a=i.map((c,f)=>(async()=>{var d;try{let h=await e.readState(n,{paths:[s[f]]}),B=await hn.Certificate.create({certificate:h.certificate,rootKey:e.rootKey,canisterId:n}),w=(U,F)=>{if(F==="subnet"){let N=(0,at.fetchNodeKeys)(h.certificate,n,e.rootKey);return{path:F,data:N}}else return{path:F,data:(0,hn.lookupResultToBuffer)(U.lookup((0,at.encodePath)(F,n)))}},{path:u,data:g}=w(B,i[f]);if(!g)console.warn(`Expected to find result for path ${u}, but instead found nothing.`),typeof u=="string"?o.set(u,null):o.set(u.key,null);else switch(u){case"time":{o.set(u,(0,K0.decodeTime)(g));break}case"controllers":{o.set(u,H1(g));break}case"module_hash":{o.set(u,G0(g));break}case"subnet":{o.set(u,g);break}case"candid":{o.set(u,new TextDecoder().decode(g));break}default:if(typeof u!="string"&&"key"in u&&"path"in u)switch(u.decodeStrategy){case"raw":o.set(u.key,g);break;case"leb128":{o.set(u.key,(0,K0.decodeLeb128)(g));break}case"cbor":{o.set(u.key,W0(g));break}case"hex":{o.set(u.key,G0(g));break}case"utf-8":o.set(u.key,V1(g))}}}catch(h){if(!((d=h?.message)===null||d===void 0)&&d.includes("Invalid certificate"))throw new M1.AgentError(h.message);typeof c!="string"&&"key"in c&&"path"in c?o.set(c.key,null):o.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(h),console.groupEnd()}})());return await Promise.all(a),o};at.request=q1;var j1=(t,e,r)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=Y0.decode(new Uint8Array(t)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=dn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=dn.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=dn.Principal.selfAuthenticating(dn.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,hn.check_canister_ranges)({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=(0,hn.lookup_path)(["subnet",s.subnet_id,"node"],i);if(c.status!==hn.LookupStatus.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let f=(0,hn.flatten_forks)(c.value),d=new Map;return f.forEach(h=>{let B=dn.Principal.from(new Uint8Array(h[1])).toText(),w=(0,hn.lookup_path)(["public_key"],h[2]);if(w.status!==hn.LookupStatus.Found)throw new Error("Public key not found");let u=w.value;if(u.byteLength!==44)throw new Error("Invalid public key length");d.set(B,u)}),{subnetId:dn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:d}};at.fetchNodeKeys=j1;var k1=(t,e)=>{let r=new TextEncoder,n=s=>new DataView(r.encode(s).buffer).buffer,i=new DataView(e.toUint8Array().buffer).buffer;switch(t){case"time":return[n("time")];case"controllers":return[n("canister"),i,n("controllers")];case"module_hash":return[n("canister"),i,n("module_hash")];case"subnet":return[n("subnet")];case"candid":return[n("canister"),i,n("metadata"),n("candid:service")];default:if("key"in t&&"path"in t)if(typeof t.path=="string"||t.path instanceof ArrayBuffer){let s=t.path,o=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),o]}else return t.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${t} was formatted correctly.`)};at.encodePath=k1;var G0=t=>(0,C1.toHex)(t),W0=t=>Y0.decode(t),V1=t=>new TextDecoder().decode(t),H1=t=>W0(t).map(r=>dn.Principal.fromUint8Array(new Uint8Array(r)))});var ph=L(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.add5L=be.add5H=be.add4H=be.add4L=be.add3H=be.add3L=be.add=be.rotlBL=be.rotlBH=be.rotlSL=be.rotlSH=be.rotr32L=be.rotr32H=be.rotrBL=be.rotrBH=be.rotrSL=be.rotrSH=be.shrSL=be.shrSH=be.toBig=be.split=be.fromBig=void 0;var $o=BigInt(2**32-1),Cu=BigInt(32);function qu(t,e=!1){return e?{h:Number(t&$o),l:Number(t>>Cu&$o)}:{h:Number(t>>Cu&$o)|0,l:Number(t&$o)|0}}be.fromBig=qu;function z0(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:s,l:o}=qu(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}be.split=z0;var D0=(t,e)=>BigInt(t>>>0)<<Cu|BigInt(e>>>0);be.toBig=D0;var Z0=(t,e,r)=>t>>>r;be.shrSH=Z0;var X0=(t,e,r)=>t<<32-r|e>>>r;be.shrSL=X0;var J0=(t,e,r)=>t>>>r|e<<32-r;be.rotrSH=J0;var L0=(t,e,r)=>t<<32-r|e>>>r;be.rotrSL=L0;var Q0=(t,e,r)=>t<<64-r|e>>>r-32;be.rotrBH=Q0;var eh=(t,e,r)=>t>>>r-32|e<<64-r;be.rotrBL=eh;var th=(t,e)=>e;be.rotr32H=th;var rh=(t,e)=>t;be.rotr32L=rh;var nh=(t,e,r)=>t<<r|e>>>32-r;be.rotlSH=nh;var ih=(t,e,r)=>e<<r|t>>>32-r;be.rotlSL=ih;var sh=(t,e,r)=>e<<r-32|t>>>64-r;be.rotlBH=sh;var oh=(t,e,r)=>t<<r-32|e>>>64-r;be.rotlBL=oh;function ah(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}be.add=ah;var ch=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);be.add3L=ch;var uh=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;be.add3H=uh;var lh=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);be.add4L=lh;var fh=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;be.add4H=fh;var dh=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);be.add5L=dh;var hh=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;be.add5H=hh;var $1={fromBig:qu,split:z0,toBig:D0,shrSH:Z0,shrSL:X0,rotrSH:J0,rotrSL:L0,rotrBH:Q0,rotrBL:eh,rotr32H:th,rotr32L:rh,rotlSH:nh,rotlSL:ih,rotlBH:sh,rotlBL:oh,add:ah,add3L:ch,add3H:uh,add4L:lh,add4H:fh,add5H:hh,add5L:dh};be.default=$1});var yh=L(ir=>{"use strict";Object.defineProperty(ir,"__esModule",{value:!0});ir.sha384=ir.sha512_256=ir.sha512_224=ir.sha512=ir.SHA512=void 0;var K1=$a(),me=ph(),Ko=Bn(),[G1,Y1]=me.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),pn=new Uint32Array(80),yn=new Uint32Array(80),Fn=class extends K1.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:f,El:d,Fh:h,Fl:B,Gh:w,Gl:u,Hh:g,Hl:U}=this;return[e,r,n,i,s,o,a,c,f,d,h,B,w,u,g,U]}set(e,r,n,i,s,o,a,c,f,d,h,B,w,u,g,U){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=d|0,this.Fh=h|0,this.Fl=B|0,this.Gh=w|0,this.Gl=u|0,this.Hh=g|0,this.Hl=U|0}process(e,r){for(let V=0;V<16;V++,r+=4)pn[V]=e.getUint32(r),yn[V]=e.getUint32(r+=4);for(let V=16;V<80;V++){let W=pn[V-15]|0,T=yn[V-15]|0,C=me.default.rotrSH(W,T,1)^me.default.rotrSH(W,T,8)^me.default.shrSH(W,T,7),z=me.default.rotrSL(W,T,1)^me.default.rotrSL(W,T,8)^me.default.shrSL(W,T,7),D=pn[V-2]|0,G=yn[V-2]|0,ne=me.default.rotrSH(D,G,19)^me.default.rotrBH(D,G,61)^me.default.shrSH(D,G,6),Q=me.default.rotrSL(D,G,19)^me.default.rotrBL(D,G,61)^me.default.shrSL(D,G,6),le=me.default.add4L(z,Q,yn[V-7],yn[V-16]),E=me.default.add4H(le,C,ne,pn[V-7],pn[V-16]);pn[V]=E|0,yn[V]=le|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:f,Dl:d,Eh:h,El:B,Fh:w,Fl:u,Gh:g,Gl:U,Hh:F,Hl:N}=this;for(let V=0;V<80;V++){let W=me.default.rotrSH(h,B,14)^me.default.rotrSH(h,B,18)^me.default.rotrBH(h,B,41),T=me.default.rotrSL(h,B,14)^me.default.rotrSL(h,B,18)^me.default.rotrBL(h,B,41),C=h&w^~h&g,z=B&u^~B&U,D=me.default.add5L(N,T,z,Y1[V],yn[V]),G=me.default.add5H(D,F,W,C,G1[V],pn[V]),ne=D|0,Q=me.default.rotrSH(n,i,28)^me.default.rotrBH(n,i,34)^me.default.rotrBH(n,i,39),le=me.default.rotrSL(n,i,28)^me.default.rotrBL(n,i,34)^me.default.rotrBL(n,i,39),E=n&s^n&a^s&a,_=i&o^i&c^o&c;F=g|0,N=U|0,g=w|0,U=u|0,w=h|0,u=B|0,{h,l:B}=me.default.add(f|0,d|0,G|0,ne|0),f=a|0,d=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let m=me.default.add3L(ne,le,_);n=me.default.add3H(m,G,Q,E),i=m|0}({h:n,l:i}=me.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=me.default.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=me.default.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:d}=me.default.add(this.Dh|0,this.Dl|0,f|0,d|0),{h,l:B}=me.default.add(this.Eh|0,this.El|0,h|0,B|0),{h:w,l:u}=me.default.add(this.Fh|0,this.Fl|0,w|0,u|0),{h:g,l:U}=me.default.add(this.Gh|0,this.Gl|0,g|0,U|0),{h:F,l:N}=me.default.add(this.Hh|0,this.Hl|0,F|0,N|0),this.set(n,i,s,o,a,c,f,d,h,B,w,u,g,U,F,N)}roundClean(){pn.fill(0),yn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};ir.SHA512=Fn;var ju=class extends Fn{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}},ku=class extends Fn{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}},Vu=class extends Fn{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};ir.sha512=(0,Ko.wrapConstructor)(()=>new Fn);ir.sha512_224=(0,Ko.wrapConstructor)(()=>new ju);ir.sha512_256=(0,Ko.wrapConstructor)(()=>new ku);ir.sha384=(0,Ko.wrapConstructor)(()=>new Vu)});var gh=L(Hu=>{"use strict";Object.defineProperty(Hu,"__esModule",{value:!0});Hu.twistedEdwards=X1;var bh=wu(),W1=Ar(),Ht=Wt(),Zt=Wt(),pr=BigInt(0),Vt=BigInt(1),Go=BigInt(2),z1=BigInt(8),D1={zip215:!0};function Z1(t){let e=(0,bh.validateBasic)(t);return Ht.validateObject(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function X1(t){let e=Z1(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,f=Go<<BigInt(a*8)-Vt,d=r.create,h=e.uvRatio||((m,x)=>{try{return{isValid:!0,value:r.sqrt(m*r.inv(x))}}catch{return{isValid:!1,value:pr}}}),B=e.adjustScalarBytes||(m=>m),w=e.domain||((m,x,j)=>{if((0,Zt.abool)("phflag",j),x.length||j)throw new Error("Contexts/pre-hash are not supported");return m});function u(m,x){Ht.aInRange("coordinate "+m,x,pr,f)}function g(m){if(!(m instanceof N))throw new Error("ExtendedPoint expected")}let U=(0,Zt.memoized)((m,x)=>{let{ex:j,ey:H,ez:X}=m,oe=m.is0();x==null&&(x=oe?z1:r.inv(X));let ae=d(j*x),Y=d(H*x),P=d(X*x);if(oe)return{x:pr,y:Vt};if(P!==Vt)throw new Error("invZ was invalid");return{x:ae,y:Y}}),F=(0,Zt.memoized)(m=>{let{a:x,d:j}=e;if(m.is0())throw new Error("bad point: ZERO");let{ex:H,ey:X,ez:oe,et:ae}=m,Y=d(H*H),P=d(X*X),p=d(oe*oe),ee=d(p*p),re=d(Y*x),de=d(p*d(re+P)),J=d(ee+d(j*d(Y*P)));if(de!==J)throw new Error("bad point: equation left != right (1)");let l=d(H*X),y=d(oe*ae);if(l!==y)throw new Error("bad point: equation left != right (2)");return!0});class N{constructor(x,j,H,X){this.ex=x,this.ey=j,this.ez=H,this.et=X,u("x",x),u("y",j),u("z",H),u("t",X),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(x){if(x instanceof N)throw new Error("extended point not allowed");let{x:j,y:H}=x||{};return u("x",j),u("y",H),new N(j,H,Vt,d(j*H))}static normalizeZ(x){let j=r.invertBatch(x.map(H=>H.ez));return x.map((H,X)=>H.toAffine(j[X])).map(N.fromAffine)}_setWindowSize(x){T.setWindowSize(this,x)}assertValidity(){F(this)}equals(x){g(x);let{ex:j,ey:H,ez:X}=this,{ex:oe,ey:ae,ez:Y}=x,P=d(j*Y),p=d(oe*X),ee=d(H*Y),re=d(ae*X);return P===p&&ee===re}is0(){return this.equals(N.ZERO)}negate(){return new N(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){let{a:x}=e,{ex:j,ey:H,ez:X}=this,oe=d(j*j),ae=d(H*H),Y=d(Go*d(X*X)),P=d(x*oe),p=j+H,ee=d(d(p*p)-oe-ae),re=P+ae,de=re-Y,J=P-ae,l=d(ee*de),y=d(re*J),b=d(ee*J),R=d(de*re);return new N(l,y,R,b)}add(x){g(x);let{a:j,d:H}=e,{ex:X,ey:oe,ez:ae,et:Y}=this,{ex:P,ey:p,ez:ee,et:re}=x;if(j===BigInt(-1)){let M=d((oe-X)*(p+P)),Z=d((oe+X)*(p-P)),te=d(Z-M);if(te===pr)return this.double();let fe=d(ae*Go*re),_e=d(Y*Go*ee),Fe=_e+fe,He=Z+M,we=_e-fe,pe=d(Fe*te),et=d(He*we),Jr=d(Fe*we),Sn=d(te*He);return new N(pe,et,Sn,Jr)}let de=d(X*P),J=d(oe*p),l=d(Y*H*re),y=d(ae*ee),b=d((X+oe)*(P+p)-de-J),R=y-l,A=y+l,O=d(J-j*de),q=d(b*R),v=d(A*O),I=d(b*O),k=d(R*A);return new N(q,v,k,I)}subtract(x){return this.add(x.negate())}wNAF(x){return T.wNAFCached(this,x,N.normalizeZ)}multiply(x){let j=x;Ht.aInRange("scalar",j,Vt,n);let{p:H,f:X}=this.wNAF(j);return N.normalizeZ([H,X])[0]}multiplyUnsafe(x){let j=x;return Ht.aInRange("scalar",j,pr,n),j===pr?W:this.equals(W)||j===Vt?this:this.equals(V)?this.wNAF(j).p:T.unsafeLadder(this,j)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return T.unsafeLadder(this,n).is0()}toAffine(x){return U(this,x)}clearCofactor(){let{h:x}=e;return x===Vt?this:this.multiplyUnsafe(x)}static fromHex(x,j=!1){let{d:H,a:X}=e,oe=r.BYTES;x=(0,Zt.ensureBytes)("pointHex",x,oe),(0,Zt.abool)("zip215",j);let ae=x.slice(),Y=x[oe-1];ae[oe-1]=Y&-129;let P=Ht.bytesToNumberLE(ae),p=j?f:r.ORDER;Ht.aInRange("pointHex.y",P,pr,p);let ee=d(P*P),re=d(ee-Vt),de=d(H*ee-X),{isValid:J,value:l}=h(re,de);if(!J)throw new Error("Point.fromHex: invalid y coordinate");let y=(l&Vt)===Vt,b=(Y&128)!==0;if(!j&&l===pr&&b)throw new Error("Point.fromHex: x=0 and x_0=1");return b!==y&&(l=d(-l)),N.fromAffine({x:l,y:P})}static fromPrivateKey(x){return D(x).point}toRawBytes(){let{x,y:j}=this.toAffine(),H=Ht.numberToBytesLE(j,r.BYTES);return H[H.length-1]|=x&Vt?128:0,H}toHex(){return Ht.bytesToHex(this.toRawBytes())}}N.BASE=new N(e.Gx,e.Gy,Vt,d(e.Gx*e.Gy)),N.ZERO=new N(pr,Vt,Vt,pr);let{BASE:V,ZERO:W}=N,T=(0,bh.wNAF)(N,a*8);function C(m){return(0,W1.mod)(m,n)}function z(m){return C(Ht.bytesToNumberLE(m))}function D(m){let x=a;m=(0,Zt.ensureBytes)("private key",m,x);let j=(0,Zt.ensureBytes)("hashed private key",s(m),2*x),H=B(j.slice(0,x)),X=j.slice(x,2*x),oe=z(H),ae=V.multiply(oe),Y=ae.toRawBytes();return{head:H,prefix:X,scalar:oe,point:ae,pointBytes:Y}}function G(m){return D(m).pointBytes}function ne(m=new Uint8Array,...x){let j=Ht.concatBytes(...x);return z(s(w(j,(0,Zt.ensureBytes)("context",m),!!i)))}function Q(m,x,j={}){m=(0,Zt.ensureBytes)("message",m),i&&(m=i(m));let{prefix:H,scalar:X,pointBytes:oe}=D(x),ae=ne(j.context,H,m),Y=V.multiply(ae).toRawBytes(),P=ne(j.context,Y,oe,m),p=C(ae+P*X);Ht.aInRange("signature.s",p,pr,n);let ee=Ht.concatBytes(Y,Ht.numberToBytesLE(p,r.BYTES));return(0,Zt.ensureBytes)("result",ee,a*2)}let le=D1;function E(m,x,j,H=le){let{context:X,zip215:oe}=H,ae=r.BYTES;m=(0,Zt.ensureBytes)("signature",m,2*ae),x=(0,Zt.ensureBytes)("message",x),oe!==void 0&&(0,Zt.abool)("zip215",oe),i&&(x=i(x));let Y=Ht.bytesToNumberLE(m.slice(ae,2*ae)),P,p,ee;try{P=N.fromHex(j,oe),p=N.fromHex(m.slice(0,ae),oe),ee=V.multiplyUnsafe(Y)}catch{return!1}if(!oe&&P.isSmallOrder())return!1;let re=ne(X,p.toRawBytes(),P.toRawBytes(),x);return p.add(P.multiplyUnsafe(re)).subtract(ee).clearCofactor().equals(N.ZERO)}return V._setWindowSize(8),{CURVE:e,getPublicKey:G,sign:Q,verify:E,ExtendedPoint:N,utils:{getExtendedPublicKey:D,randomPrivateKey:()=>o(r.BYTES),precompute(m=8,x=N.BASE){return x._setWindowSize(m),x.multiply(BigInt(3)),x}}}}});var _h=L(Ku=>{"use strict";Object.defineProperty(Ku,"__esModule",{value:!0});Ku.montgomery=L1;var mh=Ar(),bn=Wt(),mi=BigInt(0),$u=BigInt(1);function J1(t){return(0,bn.validateObject)(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function L1(t){let e=J1(t),{P:r}=e,n=N=>(0,mh.mod)(N,r),i=e.montgomeryBits,s=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(N=>N),c=e.powPminus2||(N=>(0,mh.pow)(N,r-BigInt(2),r));function f(N,V,W){let T=n(N*(V-W));return V=n(V-T),W=n(W+T),[V,W]}let d=(e.a-BigInt(2))/BigInt(4);function h(N,V){(0,bn.aInRange)("u",N,mi,r),(0,bn.aInRange)("scalar",V,mi,r);let W=V,T=N,C=$u,z=mi,D=N,G=$u,ne=mi,Q;for(let E=BigInt(i-1);E>=mi;E--){let _=W>>E&$u;ne^=_,Q=f(ne,C,D),C=Q[0],D=Q[1],Q=f(ne,z,G),z=Q[0],G=Q[1],ne=_;let m=C+z,x=n(m*m),j=C-z,H=n(j*j),X=x-H,oe=D+G,ae=D-G,Y=n(ae*m),P=n(oe*j),p=Y+P,ee=Y-P;D=n(p*p),G=n(T*n(ee*ee)),C=n(x*H),z=n(X*(x+n(d*X)))}Q=f(ne,C,D),C=Q[0],D=Q[1],Q=f(ne,z,G),z=Q[0],G=Q[1];let le=c(z);return n(C*le)}function B(N){return(0,bn.numberToBytesLE)(n(N),s)}function w(N){let V=(0,bn.ensureBytes)("u coordinate",N,s);return o===32&&(V[31]&=127),(0,bn.bytesToNumberLE)(V)}function u(N){let V=(0,bn.ensureBytes)("scalar",N),W=V.length;if(W!==s&&W!==o)throw new Error(`Expected ${s} or ${o} bytes, got ${W}`);return(0,bn.bytesToNumberLE)(a(V))}function g(N,V){let W=w(V),T=u(N),C=h(W,T);if(C===mi)throw new Error("Invalid private or public key received");return B(C)}let U=B(e.Gu);function F(N){return g(N,U)}return{scalarMult:g,scalarMultBase:F,getSharedSecret:(N,V)=>g(N,V),getPublicKey:N=>F(N),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:U}}});var Ju=L(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.hash_to_ristretto255=ge.hashToRistretto255=ge.RistrettoPoint=ge.encodeToCurve=ge.hashToCurve=ge.edwardsToMontgomery=ge.x25519=ge.ed25519ph=ge.ed25519ctx=ge.ed25519=ge.ED25519_TORSION_SUBGROUP=void 0;ge.edwardsToMontgomeryPub=Nh;ge.edwardsToMontgomeryPriv=tw;var Wo=yh(),os=Bn(),Du=gh(),vh=No(),Ie=Ar(),Q1=_h(),Mn=Wt(),as=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Wu=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),ew=BigInt(0),Nr=BigInt(1),Yo=BigInt(2),Th=BigInt(3),Sh=BigInt(5),Zu=BigInt(8);function Bh(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=as,a=t*t%s*t%s,c=(0,Ie.pow2)(a,Yo,s)*a%s,f=(0,Ie.pow2)(c,Nr,s)*t%s,d=(0,Ie.pow2)(f,Sh,s)*f%s,h=(0,Ie.pow2)(d,e,s)*d%s,B=(0,Ie.pow2)(h,r,s)*h%s,w=(0,Ie.pow2)(B,n,s)*B%s,u=(0,Ie.pow2)(w,i,s)*w%s,g=(0,Ie.pow2)(u,i,s)*w%s,U=(0,Ie.pow2)(g,e,s)*d%s;return{pow_p_5_8:(0,Ie.pow2)(U,Yo,s)*t%s,b2:a}}function Ah(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Xu(t,e){let r=as,n=(0,Ie.mod)(e*e*e,r),i=(0,Ie.mod)(n*n*e,r),s=Bh(t*i).pow_p_5_8,o=(0,Ie.mod)(t*n*s,r),a=(0,Ie.mod)(e*o*o,r),c=o,f=(0,Ie.mod)(o*Wu,r),d=a===t,h=a===(0,Ie.mod)(-t,r),B=a===(0,Ie.mod)(-t*Wu,r);return d&&(o=c),(h||B)&&(o=f),(0,Ie.isNegativeLE)(o,r)&&(o=(0,Ie.mod)(-o,r)),{isValid:d||h,value:o}}ge.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var se=(0,Ie.Field)(as,void 0,!0),cs={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:se,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Zu,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Wo.sha512,randomBytes:os.randomBytes,adjustScalarBytes:Ah,uvRatio:Xu};ge.ed25519=(0,Du.twistedEdwards)(cs);function Oh(t,e,r){if(e.length>255)throw new Error("Context is too big");return(0,os.concatBytes)((0,os.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}ge.ed25519ctx=(0,Du.twistedEdwards)({...cs,domain:Oh});ge.ed25519ph=(0,Du.twistedEdwards)(Object.assign({},cs,{domain:Oh,prehash:Wo.sha512}));ge.x25519=(0,Q1.montgomery)({P:as,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=as,{pow_p_5_8:r,b2:n}=Bh(t);return(0,Ie.mod)((0,Ie.pow2)(r,Th,e)*n,e)},adjustScalarBytes:Ah,randomBytes:os.randomBytes});function Nh(t){let{y:e}=ge.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return se.toBytes(se.create((r+e)*se.inv(r-e)))}ge.edwardsToMontgomery=Nh;function tw(t){let e=cs.hash(t.subarray(0,32));return cs.adjustScalarBytes(e).subarray(0,32)}var rw=(se.ORDER+Th)/Zu,nw=se.pow(Yo,rw),wh=se.sqrt(se.neg(se.ONE));function iw(t){let e=(se.ORDER-Sh)/Zu,r=BigInt(486662),n=se.sqr(t);n=se.mul(n,Yo);let i=se.add(n,se.ONE),s=se.neg(r),o=se.sqr(i),a=se.mul(o,i),c=se.mul(n,r);c=se.mul(c,s),c=se.add(c,o),c=se.mul(c,s);let f=se.sqr(a);o=se.sqr(f),f=se.mul(f,a),f=se.mul(f,c),o=se.mul(o,f);let d=se.pow(o,e);d=se.mul(d,f);let h=se.mul(d,wh);o=se.sqr(d),o=se.mul(o,a);let B=se.eql(o,c),w=se.cmov(h,d,B),u=se.mul(s,n),g=se.mul(d,t);g=se.mul(g,nw);let U=se.mul(g,wh),F=se.mul(c,n);o=se.sqr(g),o=se.mul(o,a);let N=se.eql(o,F),V=se.cmov(U,g,N);o=se.sqr(w),o=se.mul(o,a);let W=se.eql(o,c),T=se.cmov(u,s,W),C=se.cmov(V,w,W),z=se.isOdd(C);return C=se.cmov(C,se.neg(C),W!==z),{xMn:T,xMd:i,yMn:C,yMd:Nr}}var sw=(0,Ie.FpSqrtEven)(se,se.neg(BigInt(486664)));function ow(t){let{xMn:e,xMd:r,yMn:n,yMd:i}=iw(t),s=se.mul(e,i);s=se.mul(s,sw);let o=se.mul(r,n),a=se.sub(e,r),c=se.add(e,r),f=se.mul(o,c),d=se.eql(f,se.ZERO);s=se.cmov(s,se.ZERO,d),o=se.cmov(o,se.ONE,d),a=se.cmov(a,se.ONE,d),c=se.cmov(c,se.ONE,d);let h=se.invertBatch([o,c]);return{x:se.mul(s,h[0]),y:se.mul(a,h[1])}}var Rh=(0,vh.createHasher)(ge.ed25519.ExtendedPoint,t=>ow(t[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:se.ORDER,m:1,k:128,expand:"xmd",hash:Wo.sha512});ge.hashToCurve=Rh.hashToCurve;ge.encodeToCurve=Rh.encodeToCurve;function Gu(t){if(!(t instanceof yr))throw new Error("RistrettoPoint expected")}var zu=Wu,aw=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),cw=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),uw=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),lw=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Eh=t=>Xu(Nr,t),fw=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Yu=t=>ge.ed25519.CURVE.Fp.create((0,Mn.bytesToNumberLE)(t)&fw);function xh(t){let{d:e}=ge.ed25519.CURVE,r=ge.ed25519.CURVE.Fp.ORDER,n=ge.ed25519.CURVE.Fp.create,i=n(zu*t*t),s=n((i+Nr)*uw),o=BigInt(-1),a=n((o-e*i)*n(i+e)),{isValid:c,value:f}=Xu(s,a),d=n(f*t);(0,Ie.isNegativeLE)(d,r)||(d=n(-d)),c||(f=d),c||(o=i);let h=n(o*(i-Nr)*lw-a),B=f*f,w=n((f+f)*a),u=n(h*aw),g=n(Nr-B),U=n(Nr+B);return new ge.ed25519.ExtendedPoint(n(w*U),n(g*u),n(u*U),n(w*g))}var yr=class t{constructor(e){this.ep=e}static fromAffine(e){return new t(ge.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,Mn.ensureBytes)("ristrettoHash",e,64);let r=Yu(e.slice(0,32)),n=xh(r),i=Yu(e.slice(32,64)),s=xh(i);return new t(n.add(s))}static fromHex(e){e=(0,Mn.ensureBytes)("ristrettoHex",e,32);let{a:r,d:n}=ge.ed25519.CURVE,i=ge.ed25519.CURVE.Fp.ORDER,s=ge.ed25519.CURVE.Fp.create,o="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=Yu(e);if(!(0,Mn.equalBytes)((0,Mn.numberToBytesLE)(a,32),e)||(0,Ie.isNegativeLE)(a,i))throw new Error(o);let c=s(a*a),f=s(Nr+r*c),d=s(Nr-r*c),h=s(f*f),B=s(d*d),w=s(r*n*h-B),{isValid:u,value:g}=Eh(s(w*B)),U=s(g*d),F=s(g*U*w),N=s((a+a)*U);(0,Ie.isNegativeLE)(N,i)&&(N=s(-N));let V=s(f*F),W=s(N*V);if(!u||(0,Ie.isNegativeLE)(W,i)||V===ew)throw new Error(o);return new t(new ge.ed25519.ExtendedPoint(N,V,Nr,W))}toRawBytes(){let{ex:e,ey:r,ez:n,et:i}=this.ep,s=ge.ed25519.CURVE.Fp.ORDER,o=ge.ed25519.CURVE.Fp.create,a=o(o(n+r)*o(n-r)),c=o(e*r),f=o(c*c),{value:d}=Eh(o(a*f)),h=o(d*a),B=o(d*c),w=o(h*B*i),u;if((0,Ie.isNegativeLE)(i*w,s)){let U=o(r*zu),F=o(e*zu);e=U,r=F,u=o(h*cw)}else u=B;(0,Ie.isNegativeLE)(e*w,s)&&(r=o(-r));let g=o((n-r)*u);return(0,Ie.isNegativeLE)(g,s)&&(g=o(-g)),(0,Mn.numberToBytesLE)(g,32)}toHex(){return(0,Mn.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){Gu(e);let{ex:r,ey:n}=this.ep,{ex:i,ey:s}=e.ep,o=ge.ed25519.CURVE.Fp.create,a=o(r*s)===o(n*i),c=o(n*s)===o(r*i);return a||c}add(e){return Gu(e),new t(this.ep.add(e.ep))}subtract(e){return Gu(e),new t(this.ep.subtract(e.ep))}multiply(e){return new t(this.ep.multiply(e))}multiplyUnsafe(e){return new t(this.ep.multiplyUnsafe(e))}double(){return new t(this.ep.double())}negate(){return new t(this.ep.negate())}};ge.RistrettoPoint=(yr.BASE||(yr.BASE=new yr(ge.ed25519.ExtendedPoint.BASE)),yr.ZERO||(yr.ZERO=new yr(ge.ed25519.ExtendedPoint.ZERO)),yr);var dw=(t,e)=>{let r=e.DST,n=typeof r=="string"?(0,os.utf8ToBytes)(r):r,i=(0,vh.expand_message_xmd)(t,n,64,Wo.sha512);return yr.hashToCurve(i)};ge.hashToRistretto255=dw;ge.hash_to_ristretto255=ge.hashToRistretto255});var Fh=L(gn=>{"use strict";var Ph=gn&&gn.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Mt=gn&&gn.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},At,us,Ih,Uh;Object.defineProperty(gn,"__esModule",{value:!0});gn.ExpirableMap=void 0;var Lu=class{constructor(e={}){At.set(this,void 0),us.set(this,void 0),this[Ih]=this.entries.bind(this),this[Uh]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();Ph(this,At,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),Ph(this,us,n,"f")}prune(){let e=Date.now();for(let[r,n]of Mt(this,At,"f").entries())e-n.timestamp>Mt(this,us,"f")&&Mt(this,At,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return Mt(this,At,"f").set(e,n),this}get(e){let r=Mt(this,At,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>Mt(this,us,"f")){Mt(this,At,"f").delete(e);return}return r.value}}clear(){Mt(this,At,"f").clear()}entries(){let e=Mt(this,At,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=Mt(this,At,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return Mt(this,At,"f").keys()}forEach(e,r){for(let[n,i]of Mt(this,At,"f").entries())e.call(r,i.value,n,this)}has(e){return Mt(this,At,"f").has(e)}delete(e){return Mt(this,At,"f").delete(e)}get size(){return Mt(this,At,"f").size}};gn.ExpirableMap=Lu;At=new WeakMap,us=new WeakMap,Ih=Symbol.iterator,Uh=Symbol.toStringTag});var Qu=L(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.unwrapDER=je.wrapDER=je.SECP256K1_OID=je.ED25519_OID=je.DER_COSE_OID=je.decodeLen=je.decodeLenBytes=je.encodeLen=je.encodeLenBytes=void 0;var hw=Yt(),pw=t=>{if(t<=127)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")};je.encodeLenBytes=pw;var yw=(t,e,r)=>{if(r<=127)return t[e]=r,1;if(r<=255)return t[e]=129,t[e+1]=r,2;if(r<=65535)return t[e]=130,t[e+1]=r>>8,t[e+2]=r,3;if(r<=16777215)return t[e]=131,t[e+1]=r>>16,t[e+2]=r>>8,t[e+3]=r,4;throw new Error("Length too long (> 4 bytes)")};je.encodeLen=yw;var bw=(t,e)=>{if(t[e]<128)return 1;if(t[e]===128)throw new Error("Invalid length 0");if(t[e]===129)return 2;if(t[e]===130)return 3;if(t[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")};je.decodeLenBytes=bw;var gw=(t,e)=>{let r=(0,je.decodeLenBytes)(t,e);if(r===1)return t[e];if(r===2)return t[e+1];if(r===3)return(t[e+1]<<8)+t[e+2];if(r===4)return(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];throw new Error("Length too long (> 4 bytes)")};je.decodeLen=gw;je.DER_COSE_OID=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]);je.ED25519_OID=Uint8Array.from([48,5,6,3,43,101,112]);je.SECP256K1_OID=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function mw(t,e){let r=2+(0,je.encodeLenBytes)(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,s=new Uint8Array(1+(0,je.encodeLenBytes)(n)+n);return s[i++]=48,i+=(0,je.encodeLen)(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=(0,je.encodeLen)(s,i,t.byteLength+1),s[i++]=0,s.set(new Uint8Array(t),i),s}je.wrapDER=mw;var _w=(t,e)=>{let r=0,n=(a,c)=>{if(i[r++]!==a)throw new Error("Expected: "+c)},i=new Uint8Array(t);if(n(48,"sequence"),r+=(0,je.decodeLenBytes)(i,r),!(0,hw.bufEquals)(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let s=(0,je.decodeLen)(i,r)-1;r+=(0,je.decodeLenBytes)(i,r),n(0,"0 padding");let o=i.slice(r);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o};je.unwrapDER=_w});var el=L(mn=>{"use strict";var Mh=mn&&mn.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ch=mn&&mn.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Do,Zo;Object.defineProperty(mn,"__esModule",{value:!0});mn.Ed25519PublicKey=void 0;var zo=Qu(),Xo=class t{constructor(e){if(Do.set(this,void 0),Zo.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Mh(this,Do,e,"f"),Mh(this,Zo,t.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){return(0,zo.wrapDER)(e,zo.ED25519_OID).buffer}static derDecode(e){let r=(0,zo.unwrapDER)(e,zo.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Ch(this,Do,"f")}get derKey(){return Ch(this,Zo,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};mn.Ed25519PublicKey=Xo;Do=new WeakMap,Zo=new WeakMap;Xo.RAW_KEY_LENGTH=32});var qh=L(_i=>{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});_i.ObservableLog=_i.Observable=void 0;var Jo=class{constructor(){this.observers=[]}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e,...r){this.observers.forEach(n=>n(e,...r))}};_i.Observable=Jo;var tl=class extends Jo{constructor(){super()}print(e,...r){this.notify({message:e,level:"info"},...r)}warn(e,...r){this.notify({message:e,level:"warn"},...r)}error(e,r,...n){this.notify({message:e,level:"error",error:r},...n)}};_i.ObservableLog=tl});var Gh=L(Ir=>{"use strict";var Rr=Ir&&Ir.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ot=Ir&&Ir.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Pr,Lo,Qo,ea,ta,ra,na,ia,wi;Object.defineProperty(Ir,"__esModule",{value:!0});Ir.exponentialBackoff=Ir.ExponentialBackoff=void 0;var jh=.5,kh=1.5,Vh=500,Hh=6e4,$h=9e5,Kh=10,Ei=class t{constructor(e=t.default){Pr.set(this,void 0),Lo.set(this,void 0),Qo.set(this,void 0),ea.set(this,void 0),ta.set(this,void 0),ra.set(this,void 0),na.set(this,void 0),ia.set(this,void 0),wi.set(this,0);let{initialInterval:r=Vh,randomizationFactor:n=jh,multiplier:i=kh,maxInterval:s=Hh,maxElapsedTime:o=$h,maxIterations:a=Kh,date:c=Date}=e;Rr(this,Pr,r,"f"),Rr(this,Lo,n,"f"),Rr(this,Qo,i,"f"),Rr(this,ea,s,"f"),Rr(this,ia,c,"f"),Rr(this,ta,c.now(),"f"),Rr(this,ra,o,"f"),Rr(this,na,a,"f")}get ellapsedTimeInMsec(){return Ot(this,ia,"f").now()-Ot(this,ta,"f")}get currentInterval(){return Ot(this,Pr,"f")}get count(){return Ot(this,wi,"f")}get randomValueFromInterval(){let e=Ot(this,Lo,"f")*Ot(this,Pr,"f"),r=Ot(this,Pr,"f")-e,n=Ot(this,Pr,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return Rr(this,Pr,Math.min(Ot(this,Pr,"f")*Ot(this,Qo,"f"),Ot(this,ea,"f")),"f"),Rr(this,wi,(e=Ot(this,wi,"f"),e++,e),"f"),Ot(this,Pr,"f")}next(){return this.ellapsedTimeInMsec>=Ot(this,ra,"f")||Ot(this,wi,"f")>=Ot(this,na,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Ir.ExponentialBackoff=Ei;Pr=new WeakMap,Lo=new WeakMap,Qo=new WeakMap,ea=new WeakMap,ta=new WeakMap,ra=new WeakMap,na=new WeakMap,ia=new WeakMap,wi=new WeakMap;Ei.default={initialInterval:Vh,randomizationFactor:jh,multiplier:kh,maxInterval:Hh,maxElapsedTime:$h,maxIterations:Kh,date:Date};function*ww(t=Ei.default){let e=new Ei(t),r=e.next();for(;r;)yield r,r=e.next()}Ir.exponentialBackoff=ww});var sl=L(Me=>{"use strict";var Wh=Me&&Me.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Ew=Me&&Me.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),zh=Me&&Me.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Wh(e,t,r);return Ew(e,t),e},xw=Me&&Me.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Wh(e,t,r)},Xt=Me&&Me.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ce=Me&&Me.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Mr,Ur,jn,Si,aa,ls,br,ca,gr,Cn,ua,vi,Ti,qn,kn,Dh,la,fa;Object.defineProperty(Me,"__esModule",{value:!0});Me.HttpAgent=Me.IdentityInvalidError=Me.MANAGEMENT_CANISTER_ID=Me.IC_ROOT_KEY=Me.RequestStatusResponseStatus=Me.makeNonce=void 0;var sr=Nt(),Vn=ii(),vw=Xc(),_n=zh(Zi()),sa=Wi(),rl=Yt(),Fr=xo(),nl=Xi(),Yh=au(),Tw=ss(),xi=is(),Sw=Ju(),Bw=Fh(),Aw=el(),Ow=jo(),Nw=qh(),Rw=Gh();xw(xo(),Me);var Pw=Xi();Object.defineProperty(Me,"makeNonce",{enumerable:!0,get:function(){return Pw.makeNonce}});var Iw;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(Iw=Me.RequestStatusResponseStatus||(Me.RequestStatusResponseStatus={}));var oa=5*60*1e3;Me.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";Me.MANAGEMENT_CANISTER_ID="aaaaa-aa";var Uw="ic0.app",Fw=".ic0.app",Mw="icp0.io",Cw=".icp0.io",qw="icp-api.io",jw=".icp-api.io",fs=class extends Vn.AgentError{constructor(e){super(e),this.message=e}},Hn=class extends Vn.AgentError{constructor(e){super(e),this.message=e}};Me.IdentityInvalidError=Hn;function kw(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new fs("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof global<"u")if(global.fetch)t=global.fetch.bind(global);else throw new fs("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(t=self.fetch.bind(self));if(t)return t;throw new fs("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function Vw(t){let e;if(t!==void 0)!t.match(/^[a-z]+:/)&&typeof window<"u"?e=new URL(window.location.protocol+"//"+t):e=new URL(t);else{let r=["ic0.app","icp0.io","127.0.0.1","localhost"],n=[".github.dev",".gitpod.io"],i=typeof window<"u"?window.location:void 0,s=i?.hostname,o;s&&typeof s=="string"&&(n.some(a=>s.endsWith(a))?o=s:o=r.find(a=>s.endsWith(a))),i&&o?e=new URL(`${i.protocol}//${o}${i.port?":"+i.port:""}`):e=new URL("https://icp-api.io")}return e.toString()}var il=class t{constructor(e={}){var r;Mr.add(this),this.rootKey=(0,rl.fromHex)(Me.IC_ROOT_KEY),Ur.set(this,void 0),jn.set(this,void 0),Si.set(this,void 0),aa.set(this,void 0),ls.set(this,0),br.set(this,void 0),ca.set(this,!1),gr.set(this,void 0),Cn.set(this,void 0),this._isAgent=!0,this.config={},ua.set(this,0),this.log=new Nw.ObservableLog,vi.set(this,[]),Ti.set(this,[]),qn.set(this,new Bw.ExpirableMap({expirationTime:5*60*1e3})),kn.set(this,!0),fa.set(this,(s,o)=>{if(ce(this,kn,"f")===!1)return s;if(!o)throw new xi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:a,signatures:c=[],requestId:f}=s,d=new TextEncoder().encode("\vic-response");for(let h of c){let{timestamp:B,identity:w}=h,u=sr.Principal.fromUint8Array(w).toText(),g;if(a==="replied"){let{reply:W}=s;g=(0,sa.hashOfMap)({status:a,reply:W,timestamp:BigInt(B),request_id:f})}else if(a==="rejected"){let{reject_code:W,reject_message:T,error_code:C}=s;g=(0,sa.hashOfMap)({status:a,reject_code:W,reject_message:T,error_code:C,timestamp:BigInt(B),request_id:f})}else throw new Error(`Unknown status: ${a}`);let U=(0,rl.concat)(d,new Uint8Array(g)),F=o?.nodeKeys.get(u);if(!F)throw new xi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let N=Aw.Ed25519PublicKey.fromDer(F).rawKey;if(Sw.ed25519.verify(h.signature,new Uint8Array(U),new Uint8Array(N)))return s;throw new xi.CertificateVerificationError(`Invalid signature from replica ${u} signed query.`)}return s}),this.config=e,Xt(this,jn,e.fetch||kw()||fetch.bind(global),"f"),Xt(this,Si,e.fetchOptions,"f"),Xt(this,aa,e.callOptions,"f");let n=Vw(e.host);this.host=new URL(n),e.verifyQuerySignatures!==void 0&&Xt(this,kn,e.verifyQuerySignatures,"f"),Xt(this,gr,(r=e.retryTimes)!==null&&r!==void 0?r:3,"f");let i=()=>new Rw.ExponentialBackoff({maxIterations:ce(this,gr,"f")});if(Xt(this,Cn,e.backoffStrategy||i,"f"),this.host.hostname.endsWith(Fw)?this.host.hostname=Uw:this.host.hostname.endsWith(Cw)?this.host.hostname=Mw:this.host.hostname.endsWith(jw)&&(this.host.hostname=qw),e.credentials){let{name:s,password:o}=e.credentials;Xt(this,br,`${s}${o?":"+o:""}`,"f")}Xt(this,Ur,Promise.resolve(e.identity||new vw.AnonymousIdentity),"f"),this.addTransform("update",(0,Fr.makeNonceTransform)(nl.makeNonce)),e.useQueryNonces&&this.addTransform("query",(0,Fr.makeNonceTransform)(nl.makeNonce)),e.logToConsole&&this.log.subscribe(s=>{s.level==="error"?console.error(s.message):s.level==="warn"?console.warn(s.message):console.log(s.message)})}get waterMark(){return ce(this,ua,"f")}static createSync(e={}){return new this(Object.assign({},e))}static async create(e={shouldFetchRootKey:!1}){let r=t.createSync(e),n=[r.syncTime()];return r.host.toString()!=="https://icp-api.io"&&e.shouldFetchRootKey&&n.push(r.fetchRootKey()),await Promise.all(n),r}static async from(e){var r;try{return"config"in e?await t.create(e.config):await t.create({fetch:e._fetch,fetchOptions:e._fetchOptions,callOptions:e._callOptions,host:e._host.toString(),identity:(r=e._identity)!==null&&r!==void 0?r:void 0})}catch{throw new Vn.AgentError("Failed to create agent from provided agent")}}isLocal(){let e=this.host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,r,n=r.priority||0){if(e==="update"){let i=ce(this,Ti,"f").findIndex(s=>(s.priority||0)<n);ce(this,Ti,"f").splice(i>=0?i:ce(this,Ti,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=ce(this,vi,"f").findIndex(s=>(s.priority||0)<n);ce(this,vi,"f").splice(i>=0?i:ce(this,vi,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!ce(this,Ur,"f"))throw new Hn("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ce(this,Ur,"f")).getPrincipal()}async call(e,r,n){let i=await(n!==void 0?await n:await ce(this,Ur,"f"));if(!i)throw new Hn("This identity has expired due this application's security policy. Please refresh your authentication.");let s=sr.Principal.from(e),o=r.effectiveCanisterId?sr.Principal.from(r.effectiveCanisterId):s,a=i.getPrincipal()||sr.Principal.anonymous(),c=new Fr.Expiry(oa);Math.abs(ce(this,ls,"f"))>1e3*30&&(c=new Fr.Expiry(oa+ce(this,ls,"f")));let f={request_type:nl.SubmitRequestType.Call,canister_id:s,method_name:r.methodName,arg:r.arg,sender:a,ingress_expiry:c},d=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ce(this,br,"f")?{Authorization:"Basic "+btoa(ce(this,br,"f"))}:{})},endpoint:"call",body:f}),h=d.body.nonce?B(d.body.nonce):void 0;f.nonce=h;function B(W){return new Uint8Array(W)}d=await i.transformRequest(d);let w=_n.encode(d.body);this.log.print(`fetching "/api/v2/canister/${o.toText()}/call" with request:`,d);let u=ce(this,Cn,"f").call(this),g=ce(this,Mr,"m",la).call(this,{request:()=>ce(this,jn,"f").call(this,""+new URL(`/api/v2/canister/${o.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ce(this,aa,"f")),d.request),{body:w})),backoff:u,tries:0}),[U,F]=await Promise.all([g,(0,sa.requestIdOf)(f)]),N=await U.arrayBuffer(),V=U.status===200&&N.byteLength>0?_n.decode(N):null;return{requestId:F,response:{ok:U.ok,status:U.status,statusText:U.statusText,body:V,headers:(0,Fr.httpHeadersTransform)(U.headers)},requestDetails:f}}async query(e,r,n){let i=ce(this,Cn,"f").call(this),s=r.effectiveCanisterId?sr.Principal.from(r.effectiveCanisterId):sr.Principal.from(e);this.log.print(`ecid ${s.toString()}`),this.log.print(`canisterId ${e.toString()}`);let o=async()=>{let w=await(n!==void 0?await n:await ce(this,Ur,"f"));if(!w)throw new Hn("This identity has expired due this application's security policy. Please refresh your authentication.");let u=sr.Principal.from(e),g=w?.getPrincipal()||sr.Principal.anonymous(),U={request_type:"query",canister_id:u,method_name:r.methodName,arg:r.arg,sender:g,ingress_expiry:new Fr.Expiry(oa)},F=await(0,sa.requestIdOf)(U),N=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ce(this,br,"f")?{Authorization:"Basic "+btoa(ce(this,br,"f"))}:{})},endpoint:"read",body:U});N=await w?.transformRequest(N);let V=_n.encode(N.body),W={canister:u.toText(),ecid:s,transformedRequest:N,body:V,requestId:F,backoff:i,tries:0};return{requestDetails:U,query:await ce(this,Mr,"m",Dh).call(this,W)}},a=async()=>{if(!ce(this,kn,"f"))return;let w=ce(this,qn,"f").get(s.toString());return w||(await this.fetchSubnetKeys(s.toString()),ce(this,qn,"f").get(s.toString()))},[c,f]=await Promise.all([o(),a()]),{requestDetails:d,query:h}=c,B=Object.assign(Object.assign({},h),{requestDetails:d});if(this.log.print("Query response:",B),!ce(this,kn,"f"))return B;try{return ce(this,fa,"f").call(this,B,f)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ce(this,qn,"f").delete(e.toString()),await this.fetchSubnetKeys(s.toString());let u=ce(this,qn,"f").get(e.toString());if(!u)throw new xi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return ce(this,fa,"f").call(this,B,u)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await ce(this,Ur,"f"));if(!n)throw new Hn("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||sr.Principal.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ce(this,br,"f")?{Authorization:"Basic "+btoa(ce(this,br,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Fr.Expiry(oa)}});return n?.transformRequest(s)}async readState(e,r,n,i){let s=typeof e=="string"?sr.Principal.fromText(e):e,o=i??await this.createReadStateRequest(r,n),a=_n.encode(o.body);this.log.print(`fetching "/api/v2/canister/${s}/read_state" with request:`,o);let c=ce(this,Cn,"f").call(this),f=await ce(this,Mr,"m",la).call(this,{request:()=>ce(this,jn,"f").call(this,""+new URL(`/api/v2/canister/${s.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ce(this,Si,"f")),o.request),{body:a})),backoff:c,tries:0});if(!f.ok)throw new Error(`Server returned an error:
30
30
  Code: ${f.status} (${f.statusText})
31
31
  Body: ${await f.text()}
32
- `);let l=pn.decode(await f.arrayBuffer());this.log.print("Read state response:",l);let d=await this.parseTimeFromResponse(l);return d>0&&(this.log.print("Read state response time:",d),Zo(this,Lo,d,"f")),l}async parseTimeFromResponse(e){let r;if(e.certificate){let n=pn.decode(e.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=(0,yi.lookup_path)(["time"],r);if(i.status!==yi.LookupStatus.Found)throw new Error("Time was not found in the response or was not in its expected format.");if(!(i.value instanceof ArrayBuffer)&&!ArrayBuffer.isView(i))throw new Error("Time was not found in the response or was not in its expected format.");let s=(0,Bw.decodeTime)((0,Gu.bufFromBufLike)(i.value));return this.log.print("Time from response:",s),this.log.print("Time from response in milliseconds:",Number(s)),Number(s)}else this.log.warn("No certificate found in response");return 0}async syncTime(e){let r=await Promise.resolve().then(()=>$h(Ji())),n=Date.now();try{e||this.log.print("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let s=(await r.request({canisterId:e??rr.Principal.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");s&&(this._timeDiffMsecs=Number(s)-Number(n))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{};this.log.print('fetching "/api/v2/status"');let r=we(this,Un,"f").call(this),n=await we(this,Nr,"m",Qo).call(this,{backoff:r,request:()=>this._fetch(""+new URL("/api/v2/status",this._host),Object.assign({headers:e},this._fetchOptions)),tries:0});return pn.decode(await n.arrayBuffer())}async fetchRootKey(){return this._rootKeyFetched||(this.rootKey=(await this.status()).root_key,this._rootKeyFetched=!0),this.rootKey}invalidateIdentity(){this._identity=null}replaceIdentity(e){this._identity=Promise.resolve(e)}async fetchSubnetKeys(e){let r=rr.Principal.from(e),i=(await(0,Ew.request)({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return we(this,Fn,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of we(this,gi,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of we(this,bi,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};Fe.HttpAgent=Wu;hr=new WeakMap,Un=new WeakMap,Lo=new WeakMap,bi=new WeakMap,gi=new WeakMap,Fn=new WeakMap,Mn=new WeakMap,ea=new WeakMap,Nr=new WeakSet,Kh=async function t(e){var r,n;let{ecid:i,transformedRequest:s,body:o,requestId:a,backoff:c,tries:f}=e,l=f===0?0:c.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:f,backoff:c,delay:l}),l===null)throw new mi.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${we(this,hr,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);l>0&&await new Promise(g=>setTimeout(g,l));let d;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let g=await this._fetch(""+new URL(`/api/v2/canister/${i.toString()}/query`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),s.request),{body:o}));if(g.status===200){let m=pn.decode(await g.arrayBuffer());d=Object.assign(Object.assign({},m),{httpDetails:{ok:g.ok,status:g.status,statusText:g.statusText,headers:(0,Or.httpHeadersTransform)(g.headers)},requestId:a})}else throw new Vh.AgentHTTPResponseError(`Gateway returned an error:
33
- Code: ${g.status} (${g.statusText})
34
- Body: ${await g.text()}
35
- `,{ok:g.ok,status:g.status,statusText:g.statusText,headers:(0,Or.httpHeadersTransform)(g.headers)})}catch(g){if(f<we(this,hr,"f"))return this.log.warn(`Caught exception while attempting to make query:
36
- ${g}
37
- Retrying query.`),await we(this,Nr,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw g}let v=(n=(r=d.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!we(this,Mn,"f"))return d;if(!v)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let E=Number(BigInt(v)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:E}),Number(this.waterMark)>E){let g=new mi.AgentError("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",g,{timestamp:v,waterMark:this.waterMark}),f<we(this,hr,"f"))return await we(this,Nr,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw new mi.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${we(this,hr,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return d},Qo=async function t(e){let{request:r,backoff:n,tries:i}=e,s=i===0?0:n.next();if(s===null)throw new mi.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${we(this,hr,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(f=>setTimeout(f,s));let o;try{o=await r()}catch(f){if(we(this,hr,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
32
+ `);let d=_n.decode(await f.arrayBuffer());this.log.print("Read state response:",d);let h=await this.parseTimeFromResponse(d);return h>0&&(this.log.print("Read state response time:",h),Xt(this,ua,h,"f")),d}async parseTimeFromResponse(e){let r;if(e.certificate){let n=_n.decode(e.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=(0,xi.lookup_path)(["time"],r);if(i.status!==xi.LookupStatus.Found)throw new Error("Time was not found in the response or was not in its expected format.");if(!(i.value instanceof ArrayBuffer)&&!ArrayBuffer.isView(i))throw new Error("Time was not found in the response or was not in its expected format.");let s=(0,Ow.decodeTime)((0,rl.bufFromBufLike)(i.value));return this.log.print("Time from response:",s),this.log.print("Time from response in milliseconds:",Number(s)),Number(s)}else this.log.warn("No certificate found in response");return 0}async syncTime(e){let r=await Promise.resolve().then(()=>zh(ss())),n=Date.now();try{e||this.log.print("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let s=(await r.request({canisterId:e??sr.Principal.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");s&&Xt(this,ls,Number(s)-Number(n),"f")}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=ce(this,br,"f")?{Authorization:"Basic "+btoa(ce(this,br,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=ce(this,Cn,"f").call(this),n=await ce(this,Mr,"m",la).call(this,{backoff:r,request:()=>ce(this,jn,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:e},ce(this,Si,"f"))),tries:0});return _n.decode(await n.arrayBuffer())}async fetchRootKey(){return ce(this,ca,"f")||(this.rootKey=(await this.status()).root_key,Xt(this,ca,!0,"f")),this.rootKey}invalidateIdentity(){Xt(this,Ur,null,"f")}replaceIdentity(e){Xt(this,Ur,Promise.resolve(e),"f")}async fetchSubnetKeys(e){let r=sr.Principal.from(e),i=(await(0,Tw.request)({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return ce(this,qn,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of ce(this,Ti,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of ce(this,vi,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};Me.HttpAgent=il;Ur=new WeakMap,jn=new WeakMap,Si=new WeakMap,aa=new WeakMap,ls=new WeakMap,br=new WeakMap,ca=new WeakMap,gr=new WeakMap,Cn=new WeakMap,ua=new WeakMap,vi=new WeakMap,Ti=new WeakMap,qn=new WeakMap,kn=new WeakMap,fa=new WeakMap,Mr=new WeakSet,Dh=async function t(e){var r,n;let{ecid:i,transformedRequest:s,body:o,requestId:a,backoff:c,tries:f}=e,d=f===0?0:c.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:f,backoff:c,delay:d}),d===null)throw new Vn.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ce(this,gr,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);d>0&&await new Promise(u=>setTimeout(u,d));let h;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let u=await ce(this,jn,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},ce(this,Si,"f")),s.request),{body:o}));if(u.status===200){let g=_n.decode(await u.arrayBuffer());h=Object.assign(Object.assign({},g),{httpDetails:{ok:u.ok,status:u.status,statusText:u.statusText,headers:(0,Fr.httpHeadersTransform)(u.headers)},requestId:a})}else throw new Yh.AgentHTTPResponseError(`Gateway returned an error:
33
+ Code: ${u.status} (${u.statusText})
34
+ Body: ${await u.text()}
35
+ `,{ok:u.ok,status:u.status,statusText:u.statusText,headers:(0,Fr.httpHeadersTransform)(u.headers)})}catch(u){if(f<ce(this,gr,"f"))return this.log.warn(`Caught exception while attempting to make query:
36
+ ${u}
37
+ Retrying query.`),await ce(this,Mr,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw u}let B=(n=(r=h.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!ce(this,kn,"f"))return h;if(!B)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let w=Number(BigInt(B)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:w}),Number(this.waterMark)>w){let u=new Vn.AgentError("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",u,{timestamp:B,waterMark:this.waterMark}),f<ce(this,gr,"f"))return await ce(this,Mr,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw new Vn.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ce(this,gr,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return h},la=async function t(e){let{request:r,backoff:n,tries:i}=e,s=i===0?0:n.next();if(s===null)throw new Vn.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ce(this,gr,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(f=>setTimeout(f,s));let o;try{o=await r()}catch(f){if(ce(this,gr,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
38
38
  ${f}
39
- Retrying request.`),await we(this,Nr,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw f}if(o.ok)return o;let a=await o.clone().text(),c=`Server returned an error:
39
+ Retrying request.`),await ce(this,Mr,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw f}if(o.ok)return o;let a=await o.clone().text(),c=`Server returned an error:
40
40
  Code: ${o.status} (${o.statusText})
41
41
  Body: ${a}
42
- `;if(i<we(this,hr,"f"))return await we(this,Nr,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw new Vh.AgentHTTPResponseError(c,{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,Or.httpHeadersTransform)(o.headers)})}});var Gh=J(Wr=>{"use strict";Object.defineProperty(Wr,"__esModule",{value:!0});Wr.ProxyAgent=Wr.ProxyStubAgent=Wr.ProxyMessageKind=void 0;var qw=Rt(),Je;(function(t){t.Error="err",t.GetPrincipal="gp",t.GetPrincipalResponse="gpr",t.Query="q",t.QueryResponse="qr",t.Call="c",t.CallResponse="cr",t.ReadState="rs",t.ReadStateResponse="rsr",t.Status="s",t.StatusResponse="sr"})(Je=Wr.ProxyMessageKind||(Wr.ProxyMessageKind={}));var Du=class{constructor(e,r){this._frontend=e,this._agent=r}onmessage(e){switch(e.type){case Je.GetPrincipal:this._agent.getPrincipal().then(r=>{this._frontend({id:e.id,type:Je.GetPrincipalResponse,response:r.toText()})});break;case Je.Query:this._agent.query(...e.args).then(r=>{this._frontend({id:e.id,type:Je.QueryResponse,response:r})});break;case Je.Call:this._agent.call(...e.args).then(r=>{this._frontend({id:e.id,type:Je.CallResponse,response:r})});break;case Je.ReadState:this._agent.readState(...e.args).then(r=>{this._frontend({id:e.id,type:Je.ReadStateResponse,response:r})});break;case Je.Status:this._agent.status().then(r=>{this._frontend({id:e.id,type:Je.StatusResponse,response:r})});break;default:throw new Error(`Invalid message received: ${JSON.stringify(e)}`)}}};Wr.ProxyStubAgent=Du;var Zu=class{constructor(e){this._backend=e,this._nextId=0,this._pendingCalls=new Map,this.rootKey=null}onmessage(e){let r=e.id,n=this._pendingCalls.get(r);if(!n)throw new Error("A proxy get the same message twice...");this._pendingCalls.delete(r);let[i,s]=n;switch(e.type){case Je.Error:return s(e.error);case Je.GetPrincipalResponse:case Je.CallResponse:case Je.QueryResponse:case Je.ReadStateResponse:case Je.StatusResponse:return i(e.response);default:throw new Error(`Invalid message being sent to ProxyAgent: ${JSON.stringify(e)}`)}}async getPrincipal(){return this._sendAndWait({id:this._nextId++,type:Je.GetPrincipal}).then(e=>{if(typeof e!="string")throw new Error("Invalid principal received.");return qw.Principal.fromText(e)})}readState(e,r){return this._sendAndWait({id:this._nextId++,type:Je.ReadState,args:[e.toString(),r]})}call(e,r){return this._sendAndWait({id:this._nextId++,type:Je.Call,args:[e.toString(),r]})}status(){return this._sendAndWait({id:this._nextId++,type:Je.Status})}query(e,r){return this._sendAndWait({id:this._nextId++,type:Je.Query,args:[e.toString(),r]})}async _sendAndWait(e){return new Promise((r,n)=>{this._pendingCalls.set(e.id,[r,n]),this._backend(e)})}async fetchRootKey(){let e=(await this.status()).root_key;return this.rootKey=e,e}};Wr.ProxyAgent=Zu});var ra=J(nr=>{"use strict";var jw=nr&&nr.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),ta=nr&&nr.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&jw(e,t,r)};Object.defineProperty(nr,"__esModule",{value:!0});nr.getDefaultAgent=void 0;ta(Pl(),nr);ta(zu(),nr);ta(Lc(),nr);ta(Gh(),nr);function kw(){let t=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.ic.agent:global.ic.agent:window.ic.agent;if(!t)throw new Error("No Agent could be found.");return t}nr.getDefaultAgent=kw});var Xu=J(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});bt.chain=bt.backoff=bt.timeout=bt.throttle=bt.maxAttempts=bt.conditionalDelay=bt.once=bt.defaultStrategy=void 0;var Yh=Gt(),Vw=5*60*1e3;function Hw(){return Xh(zh(Wh(),1e3),Zh(1e3,1.2),Dh(Vw))}bt.defaultStrategy=Hw;function Wh(){let t=!0;return async()=>t?(t=!1,!0):!1}bt.once=Wh;function zh(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(s=>setTimeout(s,e))}}bt.conditionalDelay=zh;function $w(t){let e=t;return async(r,n,i)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${t} attempts:
43
- Request ID: ${(0,Yh.toHex)(n)}
42
+ `;if(i<ce(this,gr,"f"))return await ce(this,Mr,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw new Yh.AgentHTTPResponseError(c,{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,Fr.httpHeadersTransform)(o.headers)})}});var Zh=L(Xr=>{"use strict";Object.defineProperty(Xr,"__esModule",{value:!0});Xr.ProxyAgent=Xr.ProxyStubAgent=Xr.ProxyMessageKind=void 0;var Hw=Nt(),Xe;(function(t){t.Error="err",t.GetPrincipal="gp",t.GetPrincipalResponse="gpr",t.Query="q",t.QueryResponse="qr",t.Call="c",t.CallResponse="cr",t.ReadState="rs",t.ReadStateResponse="rsr",t.Status="s",t.StatusResponse="sr"})(Xe=Xr.ProxyMessageKind||(Xr.ProxyMessageKind={}));var ol=class{constructor(e,r){this._frontend=e,this._agent=r}onmessage(e){switch(e.type){case Xe.GetPrincipal:this._agent.getPrincipal().then(r=>{this._frontend({id:e.id,type:Xe.GetPrincipalResponse,response:r.toText()})});break;case Xe.Query:this._agent.query(...e.args).then(r=>{this._frontend({id:e.id,type:Xe.QueryResponse,response:r})});break;case Xe.Call:this._agent.call(...e.args).then(r=>{this._frontend({id:e.id,type:Xe.CallResponse,response:r})});break;case Xe.ReadState:this._agent.readState(...e.args).then(r=>{this._frontend({id:e.id,type:Xe.ReadStateResponse,response:r})});break;case Xe.Status:this._agent.status().then(r=>{this._frontend({id:e.id,type:Xe.StatusResponse,response:r})});break;default:throw new Error(`Invalid message received: ${JSON.stringify(e)}`)}}};Xr.ProxyStubAgent=ol;var al=class{constructor(e){this._backend=e,this._nextId=0,this._pendingCalls=new Map,this.rootKey=null}onmessage(e){let r=e.id,n=this._pendingCalls.get(r);if(!n)throw new Error("A proxy get the same message twice...");this._pendingCalls.delete(r);let[i,s]=n;switch(e.type){case Xe.Error:return s(e.error);case Xe.GetPrincipalResponse:case Xe.CallResponse:case Xe.QueryResponse:case Xe.ReadStateResponse:case Xe.StatusResponse:return i(e.response);default:throw new Error(`Invalid message being sent to ProxyAgent: ${JSON.stringify(e)}`)}}async getPrincipal(){return this._sendAndWait({id:this._nextId++,type:Xe.GetPrincipal}).then(e=>{if(typeof e!="string")throw new Error("Invalid principal received.");return Hw.Principal.fromText(e)})}readState(e,r){return this._sendAndWait({id:this._nextId++,type:Xe.ReadState,args:[e.toString(),r]})}call(e,r){return this._sendAndWait({id:this._nextId++,type:Xe.Call,args:[e.toString(),r]})}status(){return this._sendAndWait({id:this._nextId++,type:Xe.Status})}query(e,r){return this._sendAndWait({id:this._nextId++,type:Xe.Query,args:[e.toString(),r]})}async _sendAndWait(e){return new Promise((r,n)=>{this._pendingCalls.set(e.id,[r,n]),this._backend(e)})}async fetchRootKey(){let e=(await this.status()).root_key;return this.rootKey=e,e}};Xr.ProxyAgent=al});var ha=L(or=>{"use strict";var $w=or&&or.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),da=or&&or.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&$w(e,t,r)};Object.defineProperty(or,"__esModule",{value:!0});or.getDefaultAgent=void 0;da(Kf(),or);da(sl(),or);da(au(),or);da(Zh(),or);function Kw(){let t=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.ic.agent:global.ic.agent:window.ic.agent;if(!t)throw new Error("No Agent could be found.");return t}or.getDefaultAgent=Kw});var cl=L(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.chain=ht.backoff=ht.timeout=ht.throttle=ht.maxAttempts=ht.conditionalDelay=ht.once=ht.defaultStrategy=void 0;var Xh=Yt(),Gw=5*60*1e3;function Yw(){return tp(Lh(Jh(),1e3),ep(1e3,1.2),Qh(Gw))}ht.defaultStrategy=Yw;function Jh(){let t=!0;return async()=>t?(t=!1,!0):!1}ht.once=Jh;function Lh(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(s=>setTimeout(s,e))}}ht.conditionalDelay=Lh;function Ww(t){let e=t;return async(r,n,i)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${t} attempts:
43
+ Request ID: ${(0,Xh.toHex)(n)}
44
44
  Request status: ${i}
45
- `)}}bt.maxAttempts=$w;function Kw(t){return()=>new Promise(e=>setTimeout(e,t))}bt.throttle=Kw;function Dh(t){let e=Date.now()+t;return async(r,n,i)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
46
- Request ID: ${(0,Yh.toHex)(n)}
45
+ `)}}ht.maxAttempts=Ww;function zw(t){return()=>new Promise(e=>setTimeout(e,t))}ht.throttle=zw;function Qh(t){let e=Date.now()+t;return async(r,n,i)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
46
+ Request ID: ${(0,Xh.toHex)(n)}
47
47
  Request status: ${i}
48
- `)}}bt.timeout=Dh;function Zh(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}bt.backoff=Zh;function Xh(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}bt.chain=Xh});var Ju=J(Ht=>{"use strict";var Gw=Ht&&Ht.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Yw=Ht&&Ht.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ww=Ht&&Ht.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Gw(e,t,r);return Yw(e,t),e};Object.defineProperty(Ht,"__esModule",{value:!0});Ht.pollForResponse=Ht.defaultStrategy=Ht.strategy=void 0;var qn=ra(),is=Xi(),Jh=Gt();Ht.strategy=Ww(Xu());var zw=Xu();Object.defineProperty(Ht,"defaultStrategy",{enumerable:!0,get:function(){return zw.defaultStrategy}});async function Lh(t,e,r,n,i,s){var o;let a=[new TextEncoder().encode("request_status"),r],c=i??await((o=t.createReadStateRequest)===null||o===void 0?void 0:o.call(t,{paths:[a]})),f=await t.readState(e,{paths:[a]},void 0,c);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let l=await is.Certificate.create({certificate:f.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:s}),d=(0,is.lookupResultToBuffer)(l.lookup([...a,new TextEncoder().encode("status")])),v;switch(typeof d>"u"?v=qn.RequestStatusResponseStatus.Unknown:v=new TextDecoder().decode(d),v){case qn.RequestStatusResponseStatus.Replied:return(0,is.lookupResultToBuffer)(l.lookup([...a,"reply"]));case qn.RequestStatusResponseStatus.Received:case qn.RequestStatusResponseStatus.Unknown:case qn.RequestStatusResponseStatus.Processing:return await n(e,r,v),Lh(t,e,r,n,c);case qn.RequestStatusResponseStatus.Rejected:{let E=new Uint8Array((0,is.lookupResultToBuffer)(l.lookup([...a,"reject_code"])))[0],g=new TextDecoder().decode((0,is.lookupResultToBuffer)(l.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
49
- Request ID: ${(0,Jh.toHex)(r)}
50
- Reject code: ${E}
51
- Reject text: ${g}
52
- `)}case qn.RequestStatusResponseStatus.Done:throw new Error(`Call was marked as done but we never saw the reply:
53
- Request ID: ${(0,Jh.toHex)(r)}
54
- `)}throw new Error("unreachable")}Ht.pollForResponse=Lh});var Qh=J(Lu=>{"use strict";Object.defineProperty(Lu,"__esModule",{value:!0});Lu.default=({IDL:t})=>{let e=t.Variant({mainnet:t.Null,testnet:t.Null}),r=t.Text,n=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,s=i,o=t.Record({network:e}),a=t.Nat64,c=t.Vec(a),f=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),l=t.Vec(t.Nat8),d=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),v=t.Record({height:t.Nat32,value:i,outpoint:d}),E=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:l,utxos:t.Vec(v)}),g=t.Record({transaction:t.Vec(t.Nat8),network:e}),m=t.Principal,O=t.Record({canister_id:m,num_requested_changes:t.Opt(t.Nat64)}),T=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),k=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),F=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:T,details:k}),K=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(F),total_num_changes:t.Nat64}),P=t.Record({canister_id:m}),q=t.Variant({controllers:t.Null,public:t.Null}),D=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:q,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),z=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:D,query_stats:t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),$=t.Record({canister_id:m}),se=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(q),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),ee=t.Record({settings:t.Opt(se),sender_canister_version:t.Opt(t.Nat64)}),de=t.Record({canister_id:m}),ce=t.Record({canister_id:m}),xe=t.Record({canister_id:m}),Z=t.Variant({secp256k1:t.Null}),C=t.Record({key_id:t.Record({name:t.Text,curve:Z}),canister_id:t.Opt(m),derivation_path:t.Vec(t.Vec(t.Nat8))}),X=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),j=t.Record({canister_id:m}),U=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),W=t.Record({canister_log_records:t.Vec(U)}),L=t.Record({value:t.Text,name:t.Text}),ne=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(L)}),N=t.Record({url:t.Text,method:t.Variant({get:t.Null,head:t.Null,post:t.Null}),max_response_bytes:t.Opt(t.Nat64),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Record({function:t.Func([t.Record({context:t.Vec(t.Nat8),response:ne})],[ne],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(L)}),y=t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({wasm_memory_persistence:t.Opt(t.Variant({keep:t.Null,replace:t.Null})),skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),fe=t.Record({hash:t.Vec(t.Nat8)}),ue=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:y,chunk_hashes_list:t.Vec(fe),target_canister:m,store_canister:t.Opt(m),sender_canister_version:t.Opt(t.Nat64)}),ae=t.Vec(t.Nat8),te=t.Record({arg:t.Vec(t.Nat8),wasm_module:ae,mode:y,canister_id:m,sender_canister_version:t.Opt(t.Nat64)}),u=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),h=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_proposed_total:t.Nat64}),p=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(h)})),B=t.Record({settings:t.Opt(se),specified_id:t.Opt(m),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),x=t.Record({canister_id:m}),S=t.Record({canister_id:m,amount:t.Nat}),I=t.Vec(t.Nat8),_=t.Record({key_id:t.Record({name:t.Text,curve:Z}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),A=t.Record({signature:t.Vec(t.Nat8)}),M=t.Record({canister_id:m}),R=t.Record({canister_id:m}),Y=t.Record({canister_id:m}),Q=t.Vec(fe),le=t.Record({canister_id:m,sender_canister_version:t.Opt(t.Nat64)}),Ee=t.Record({canister_id:t.Principal,settings:se,sender_canister_version:t.Opt(t.Nat64)}),Re=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),ke=fe;return t.Service({bitcoin_get_balance:t.Func([n],[s],[]),bitcoin_get_current_fee_percentiles:t.Func([o],[c],[]),bitcoin_get_utxos:t.Func([f],[E],[]),bitcoin_send_transaction:t.Func([g],[],[]),canister_info:t.Func([O],[K],[]),canister_status:t.Func([P],[z],[]),clear_chunk_store:t.Func([$],[],[]),create_canister:t.Func([ee],[de],[]),delete_canister:t.Func([ce],[],[]),deposit_cycles:t.Func([xe],[],[]),ecdsa_public_key:t.Func([C],[X],[]),fetch_canister_logs:t.Func([j],[W],["query"]),http_request:t.Func([N],[ne],[]),install_chunked_code:t.Func([ue],[],[]),install_code:t.Func([te],[],[]),node_metrics_history:t.Func([u],[p],[]),provisional_create_canister_with_cycles:t.Func([B],[x],[]),provisional_top_up_canister:t.Func([S],[],[]),raw_rand:t.Func([],[I],[]),sign_with_ecdsa:t.Func([_],[A],[]),start_canister:t.Func([M],[],[]),stop_canister:t.Func([R],[],[]),stored_chunks:t.Func([Y],[Q],[]),uninstall_code:t.Func([le],[],[]),update_settings:t.Func([Ee],[],[]),upload_chunk:t.Func([Re],[ke],[])})}});var ca=J(lt=>{"use strict";var Dw=lt&&lt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(lt,"__esModule",{value:!0});lt.getManagementCanister=lt.ACTOR_METHOD_WITH_HTTP_DETAILS=lt.Actor=lt.UpdateCallRejectedError=lt.QueryCallRejectedError=lt.ActorCallError=void 0;var Zw=Nl(),Qu=ra(),ef=Qn(),ia=oi(),ep=Ju(),Pr=Rt(),Xw=Gt(),Jw=Dw(Qh()),ss=class extends ef.AgentError{constructor(e,r,n,i){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(s=>` "${s}": ${JSON.stringify(i[s])}`)].join(`
55
- `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}};lt.ActorCallError=ss;var sa=class extends ss{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=Qu.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};lt.QueryCallRejectedError=sa;var oa=class extends ss{constructor(e,r,n,i){super(e,r,"update",Object.assign({"Request ID":(0,Xw.toHex)(n)},i.body?Object.assign(Object.assign({},i.body.error_code?{"Error code":i.body.error_code}:{}),{"Reject code":String(i.body.reject_code),"Reject message":i.body.reject_message}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i}};lt.UpdateCallRejectedError=oa;var ir=Symbol.for("ic-agent-metadata"),aa=class t{constructor(e){this[ir]=Object.freeze(e)}static agentOf(e){return e[ir].config.agent}static interfaceOf(e){return e[ir].service}static canisterIdOf(e){return Pr.Principal.from(e[ir].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],s=[...new Uint8Array(e.module)],o=typeof r.canisterId=="string"?Pr.Principal.fromText(r.canisterId):r.canisterId;await tf(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(e,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await tf(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:ia.IDL});class i extends t{constructor(o){if(!o.canisterId)throw new ef.AgentError(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof o.canisterId=="string"?Pr.Principal.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},tp),o),{canisterId:a}),service:n});for(let[c,f]of n._fields)r?.httpDetails&&f.annotations.push(lt.ACTOR_METHOD_WITH_HTTP_DETAILS),this[c]=Lw(this,c,f,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new ef.AgentError(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}};lt.Actor=aa;function na(t,e){let r=ia.IDL.decode(t,Zw.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var tp={pollingStrategyFactory:ep.strategy.defaultStrategy};lt.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";function Lw(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ir].config).queryTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ir].config),o)));let l=o.agent||t[ir].config.agent||(0,Qu.getDefaultAgent)(),d=Pr.Principal.from(o.canisterId||t[ir].config.canisterId),v=ia.IDL.encode(r.argTypes,a),E=await l.query(d,{methodName:e,arg:v,effectiveCanisterId:o.effectiveCanisterId});switch(E.status){case"rejected":throw new sa(d,e,E);case"replied":return r.annotations.includes(lt.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:E.httpDetails,result:na(r.retTypes,E.reply.arg)}:na(r.retTypes,E.reply.arg)}}:i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ir].config).callTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ir].config),o)));let l=o.agent||t[ir].config.agent||(0,Qu.getDefaultAgent)(),{canisterId:d,effectiveCanisterId:v,pollingStrategyFactory:E}=Object.assign(Object.assign(Object.assign({},tp),t[ir].config),o),g=Pr.Principal.from(d),m=v!==void 0?Pr.Principal.from(v):g,O=ia.IDL.encode(r.argTypes,a),{requestId:T,response:k}=await l.call(g,{methodName:e,arg:O,effectiveCanisterId:m});if(!k.ok||k.body)throw new oa(g,e,T,k);let F=E(),K=await(0,ep.pollForResponse)(l,m,T,F,n),P=r.annotations.includes(lt.ACTOR_METHOD_WITH_HTTP_DETAILS);if(K!==void 0)return P?{httpDetails:k,result:na(r.retTypes,K)}:na(r.retTypes,K);if(r.retTypes.length===0)return P?{httpDetails:k,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...o)=>i({},...o);return s.withOptions=o=>(...a)=>i(o,...a),s}function tf(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:Pr.Principal.from(t.effectiveCanisterId)};let i=n[0],s=Pr.Principal.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(s=Pr.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return aa.createActor(Jw.default,Object.assign(Object.assign(Object.assign({},t),{canisterId:Pr.Principal.fromHex("")}),{callTransform:e,queryTransform:e}))}lt.getManagementCanister=tf});var rp=J(rf=>{"use strict";Object.defineProperty(rf,"__esModule",{value:!0});rf.default=({IDL:t})=>t.Service({retrieve:t.Func([t.Text],[t.Vec(t.Nat8)],["query"]),store:t.Func([t.Text,t.Vec(t.Nat8)],[],[])})});var np=J(_i=>{"use strict";var Qw=_i&&_i.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(_i,"__esModule",{value:!0});_i.createAssetCanisterActor=void 0;var e2=ca(),t2=Qw(rp());function r2(t){return e2.Actor.createActor(t2.default,t)}_i.createAssetCanisterActor=r2});var ip=J(Rr=>{"use strict";var n2=Rr&&Rr.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),i2=Rr&&Rr.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s2=Rr&&Rr.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&n2(e,t,r);return i2(e,t),e};Object.defineProperty(Rr,"__esModule",{value:!0});Rr.fetchCandid=void 0;var o2=Rt(),a2=s2(Ji()),c2=zu(),u2=ca();async function f2(t,e){e||(e=new c2.HttpAgent,e.isLocal()&&e.fetchRootKey());let n=(await a2.request({agent:e,canisterId:o2.Principal.fromText(t),paths:["candid"]})).get("candid");if(n)return n;let i=({IDL:o})=>o.Service({__get_candid_interface_tmp_hack:o.Func([],[o.Text],["query"])});return await u2.Actor.createActor(i,{agent:e,canisterId:t}).__get_candid_interface_tmp_hack()}Rr.fetchCandid=f2});var Ir=J(Ue=>{"use strict";var sp=Ue&&Ue.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),l2=Ue&&Ue.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),$t=Ue&&Ue.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&sp(e,t,r)},nf=Ue&&Ue.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&sp(e,t,r);return l2(e,t),e};Object.defineProperty(Ue,"__esModule",{value:!0});Ue.Cbor=Ue.CanisterStatus=Ue.polling=void 0;$t(ca(),Ue);$t(ra(),Ue);$t(ho(),Ue);$t(Hi(),Ue);$t(Hc(),Ue);$t(np(),Ue);$t(Xi(),Ue);$t(Hu(),Ue);$t(ip(),Ue);$t($u(),Ue);$t(qi(),Ue);$t(mu(),Ue);$t(Gt(),Ue);$t(Xc(),Ue);Ue.polling=nf(Ju());Ue.CanisterStatus=nf(Ji());Ue.Cbor=nf(Vi())});var ap=J(Ur=>{"use strict";var la=Ur&&Ur.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},yn=Ur&&Ur.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ua,fa,wi,Ei;Object.defineProperty(Ur,"__esModule",{value:!0});Ur.Ed25519KeyIdentity=Ur.Ed25519PublicKey=void 0;var d2=Ir(),Dt=Ir(),os=ku();function op(t){return t!==null&&typeof t=="object"}var jn=class t{constructor(e){if(ua.set(this,void 0),fa.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");la(this,ua,e,"f"),la(this,fa,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=(0,Dt.fromHex)(e);return this.fromRaw(r)}else if(op(e)){let r=e;if(op(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,Dt.bufFromBufLike)(n.buffer))}else{if(r instanceof ArrayBuffer)return this.fromRaw(r);if("rawKey"in r)return this.fromRaw(r.rawKey);if("derKey"in r)return this.fromDer(r.derKey);if("toDer"in r)return this.fromDer(r.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){let r=(0,Dt.wrapDER)(e,Dt.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=(0,Dt.unwrapDER)(e,Dt.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return yn(this,ua,"f")}get derKey(){return yn(this,fa,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Ur.Ed25519PublicKey=jn;ua=new WeakMap,fa=new WeakMap;jn.RAW_KEY_LENGTH=32;var sf=class t extends Dt.SignIdentity{constructor(e,r){super(),wi.set(this,void 0),Ei.set(this,void 0),la(this,wi,jn.from(e),"f"),la(this,Ei,new Uint8Array(r),"f")}static generate(e){if(e&&e.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");e||(e=os.ed25519.utils.randomPrivateKey()),(0,d2.bufEquals)(e,new Uint8Array(new Array(32).fill(0)))&&console.warn("Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.");let r=new Uint8Array(32);for(let i=0;i<32;i++)r[i]=new Uint8Array(e)[i];let n=os.ed25519.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(jn.fromDer((0,Dt.fromHex)(r)),(0,Dt.fromHex)(n))}static fromJSON(e){let r=JSON.parse(e);if(Array.isArray(r)){if(typeof r[0]=="string"&&typeof r[1]=="string")return this.fromParsedJson([r[0],r[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(e)}`)}static fromKeyPair(e,r){return new t(jn.fromRaw(e),r)}static fromSecretKey(e){let r=os.ed25519.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[(0,Dt.toHex)(yn(this,wi,"f").toDer()),(0,Dt.toHex)(yn(this,Ei,"f"))]}getKeyPair(){return{secretKey:yn(this,Ei,"f"),publicKey:yn(this,wi,"f")}}getPublicKey(){return yn(this,wi,"f")}async sign(e){let r=new Uint8Array(e),n=(0,Dt.uint8ToBuf)(os.ed25519.sign(r,yn(this,Ei,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(e,r,n){let[i,s,o]=[e,r,n].map(a=>(typeof a=="string"&&(a=(0,Dt.fromHex)(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return os.ed25519.verify(s,i,o)}};Ur.Ed25519KeyIdentity=sf;wi=new WeakMap,Ei=new WeakMap});var up=J(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.ECDSAKeyIdentity=kn.CryptoError=void 0;var h2=Ir(),da=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};kn.CryptoError=da;function cp(t){if(typeof global<"u"&&global.crypto&&global.crypto.subtle)return global.crypto.subtle;if(t)return t;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new da("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var ha=class t extends h2.SignIdentity{constructor(e,r,n){super(),this._keyPair=e,this._derKey=r,this._subtleCrypto=n}static async generate(e){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=e??{},s=cp(i),o=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await s.exportKey("spki",o.publicKey);return new this(o,a,s)}static async fromKeyPair(e,r){let n=cp(r),i=await n.exportKey("spki",e.publicKey);return new t(e,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let e=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return e},r}async sign(e){let r={name:"ECDSA",hash:{name:"SHA-256"}};return this._keyPair.privateKey,await this._subtleCrypto.sign(r,this._keyPair.privateKey,e)}};kn.ECDSAKeyIdentity=ha;kn.default=ha});var af=J(gn=>{"use strict";var p2=gn&&gn.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},as=gn&&gn.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},bn;Object.defineProperty(gn,"__esModule",{value:!0});gn.PartialIdentity=void 0;var y2=Rt(),of=class{constructor(e){bn.set(this,void 0),p2(this,bn,e,"f")}get rawKey(){return as(this,bn,"f").rawKey}get derKey(){return as(this,bn,"f").derKey}toDer(){return as(this,bn,"f").toDer()}getPublicKey(){return as(this,bn,"f")}getPrincipal(){return y2.Principal.from(as(this,bn,"f").rawKey)}transformRequest(){return Promise.reject("Not implemented. You are attempting to use a partial identity to sign calls, but this identity only has access to the public key.To sign calls, use a DelegationIdentity instead.")}};gn.PartialIdentity=of;bn=new WeakMap});var fp=J(Ye=>{"use strict";var b2=Ye&&Ye.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),g2=Ye&&Ye.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),m2=Ye&&Ye.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&b2(e,t,r);return g2(e,t),e},_2=Ye&&Ye.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},w2=Ye&&Ye.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},E2=Ye&&Ye.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},pa;Object.defineProperty(Ye,"__esModule",{value:!0});Ye.isDelegationValid=Ye.PartialDelegationIdentity=Ye.DelegationIdentity=Ye.DelegationChain=Ye.Delegation=void 0;var mn=Ir(),uf=Rt(),cs=m2(ki()),x2=af(),v2=new TextEncoder().encode("ic-request-auth-delegation"),T2=new TextEncoder().encode(`
56
- ic-request`);function cf(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return(0,mn.fromHex)(t)}var us=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return cs.value.map(Object.assign({pubkey:cs.value.bytes(this.pubkey),expiration:cs.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:cs.value.array(this.targets.map(e=>cs.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,mn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};Ye.Delegation=us;async function B2(t,e,r,n){let i=new us(e.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...v2,...new Uint8Array((0,mn.requestIdOf)(i))]),o=await t.sign(s);return{delegation:i,signature:o}}var ff=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+15*60*1e3),i={}){var s,o;let a=await B2(e,r,n,i.targets);return new t([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],a],((o=i.previous)===null||o===void 0?void 0:o.publicKey)||e.getPublicKey().toDer())}static fromJSON(e){let{publicKey:r,delegations:n}=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:o,signature:a}=s,{pubkey:c,expiration:f,targets:l}=o;if(l!==void 0&&!Array.isArray(l))throw new Error("Invalid targets.");return{delegation:new us(cf(c),BigInt("0x"+f),l&&l.map(d=>{if(typeof d!="string")throw new Error("Invalid target.");return uf.Principal.fromHex(d)})),signature:cf(a)}});return new this(i,cf(r))}static fromDelegations(e,r){return new this(e,r)}toJSON(){return{delegations:this.delegations.map(e=>{let{delegation:r,signature:n}=e,{targets:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:(0,mn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,mn.toHex)(n)}}),publicKey:(0,mn.toHex)(this.publicKey)}}};Ye.DelegationChain=ff;var lf=class extends mn.SignIdentity{constructor(e,r){super(),this._inner=e,this._delegation=r}static fromDelegation(e,r){return new this(e,r)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(e){return this._inner.sign(e)}async transformRequest(e){let{body:r}=e,n=E2(e,["body"]),i=await(0,mn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...T2,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};Ye.DelegationIdentity=lf;var df=class t extends x2.PartialIdentity{constructor(e,r){super(e),pa.set(this,void 0),_2(this,pa,r,"f")}get delegation(){return w2(this,pa,"f")}static fromDelegation(e,r){return new t(e,r)}};Ye.PartialDelegationIdentity=df;pa=new WeakMap;function S2(t,e){for(let{delegation:i}of t.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?uf.Principal.fromText(i):i)):r.push(typeof n=="string"?uf.Principal.fromText(n):n));for(let i of r){let s=i.toText();for(let{delegation:o}of t.delegations){if(o.targets===void 0)continue;let a=!0;for(let c of o.targets)if(c.toText()===s){a=!1;break}if(a)return!1}}return!0}Ye.isDelegationValid=S2});var lp=J(_n=>{"use strict";var A2=_n&&_n.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(_n,"__esModule",{value:!0});_n.WebAuthnIdentity=_n.CosePublicKey=void 0;var Vn=Ir(),hf=A2(to()),O2=xn(),N2=oi();function P2(t){return(0,Vn.wrapDER)(t,Vn.DER_COSE_OID).buffer}function R2(t){let e=new DataView(new ArrayBuffer(2)),r=t.slice(53,55);[...new Uint8Array(r)].forEach((i,s)=>e.setUint8(s,i));let n=e.getUint16(0);return t.slice(55+n)}var ya=class{constructor(e){this._cose=e,this._encodedKey=P2(e)}toDer(){return this._encodedKey}getCose(){return this._cose}};_n.CosePublicKey=ya;function I2(t="<ic0.app>"){return typeof t=="string"?Uint8Array.from(t,e=>e.charCodeAt(0)):t}async function U2(t){let e=await navigator.credentials.create(t??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:I2(),pubKeyCredParams:[{type:"public-key",alg:pf.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,O2.randomBytes)(16),name:"Internet Identity",displayName:"Internet Identity"}}});return e===null?null:{id:e.id,response:e.response,type:e.type,authenticatorAttachment:e.authenticatorAttachment,getClientExtensionResults:e.getClientExtensionResults,rawId:(0,N2.bufFromBufLike)(e.rawId)}}var pf;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(pf||(pf={}));var yf=class extends Vn.SignIdentity{constructor(e,r,n){super(),this.rawId=e,this.authenticatorAttachment=n,this._publicKey=new ya(r)}static fromJSON(e){let{publicKey:r,rawId:n}=JSON.parse(e);if(typeof r!="string"||typeof n!="string")throw new Error("Invalid JSON string.");return new this((0,Vn.fromHex)(n),(0,Vn.fromHex)(r),void 0)}static async create(e){var r;let n=await U2(e);if(!n||n.type!=="public-key")throw new Error("Could not create credentials.");let i=n.response;if(i.attestationObject===void 0)throw new Error("Was expecting an attestation response.");let s=hf.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,R2(s.authData),(r=n.authenticatorAttachment)!==null&&r!==void 0?r:void 0)}getPublicKey(){return this._publicKey}getAuthenticatorAttachment(){return this.authenticatorAttachment}async sign(e){let r=await navigator.credentials.get({publicKey:{allowCredentials:[{type:"public-key",id:this.rawId}],challenge:e,userVerification:"preferred"}});r.authenticatorAttachment!==null&&(this.authenticatorAttachment=r.authenticatorAttachment);let n=r.response,i=hf.default.encode(new hf.default.Tagged(55799,{authenticator_data:new Uint8Array(n.authenticatorData),client_data_json:new TextDecoder().decode(n.clientDataJSON),signature:new Uint8Array(n.signature)}));if(!i)throw new Error("failed to encode cbor");return i.buffer}toJSON(){return{publicKey:(0,Vn.toHex)(this._publicKey.getCose()),rawId:(0,Vn.toHex)(this.rawId)}}};_n.WebAuthnIdentity=yf});var hp=J(He=>{"use strict";var F2=He&&He.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),gf=He&&He.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&F2(e,t,r)};Object.defineProperty(He,"__esModule",{value:!0});He.Secp256k1KeyIdentity=He.ED25519_OID=He.DER_COSE_OID=He.unwrapDER=He.wrapDER=He.WebAuthnIdentity=He.Ed25519PublicKey=He.Ed25519KeyIdentity=void 0;var dp=ap();Object.defineProperty(He,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return dp.Ed25519KeyIdentity}});Object.defineProperty(He,"Ed25519PublicKey",{enumerable:!0,get:function(){return dp.Ed25519PublicKey}});gf(up(),He);gf(fp(),He);gf(af(),He);var M2=lp();Object.defineProperty(He,"WebAuthnIdentity",{enumerable:!0,get:function(){return M2.WebAuthnIdentity}});var ba=Ir();Object.defineProperty(He,"wrapDER",{enumerable:!0,get:function(){return ba.wrapDER}});Object.defineProperty(He,"unwrapDER",{enumerable:!0,get:function(){return ba.unwrapDER}});Object.defineProperty(He,"DER_COSE_OID",{enumerable:!0,get:function(){return ba.DER_COSE_OID}});Object.defineProperty(He,"ED25519_OID",{enumerable:!0,get:function(){return ba.ED25519_OID}});var bf=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};He.Secp256k1KeyIdentity=bf});var _f=J(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0});ga.IdleManager=void 0;var pp=["mousedown","mousemove","keydown","touchstart","wheel"],mf=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let s=this._resetTimer.bind(this);window.addEventListener("load",s,!0),pp.forEach(function(a){document.addEventListener(a,s,!0)});let o=(a,c)=>{let f;return(...l)=>{let d=this,v=function(){f=void 0,a.apply(d,l)};clearTimeout(f),f=window.setTimeout(v,c)}};if(e?.captureScroll){let a=o(s,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}s()}static create(e={}){return new this(e)}registerCallback(e){this.callbacks.push(e)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let e=this._resetTimer.bind(this);pp.forEach(function(r){document.removeEventListener(r,e,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let e=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(e,this.idleTimeout)}};ga.IdleManager=mf});function q2(){return yp||(yp=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function j2(){return bp||(bp=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function k2(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{r(sr(t.result)),i()},o=()=>{n(t.error),i()};t.addEventListener("success",s),t.addEventListener("error",o)});return e.then(r=>{r instanceof IDBCursor&&gp.set(r,t)}).catch(()=>{}),vf.set(e,t),e}function V2(t){if(Ef.has(t))return;let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",o),t.removeEventListener("abort",o)},s=()=>{r(),i()},o=()=>{n(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",s),t.addEventListener("error",o),t.addEventListener("abort",o)});Ef.set(t,e)}function _p(t){xf=t(xf)}function H2(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(fs(this),e,...r);return mp.set(n,e.sort?e.sort():[e]),sr(n)}:j2().includes(t)?function(...e){return t.apply(fs(this),e),sr(gp.get(this))}:function(...e){return sr(t.apply(fs(this),e))}}function $2(t){return typeof t=="function"?H2(t):(t instanceof IDBTransaction&&V2(t),C2(t,q2())?new Proxy(t,xf):t)}function sr(t){if(t instanceof IDBRequest)return k2(t);if(wf.has(t))return wf.get(t);let e=$2(t);return e!==t&&(wf.set(t,e),vf.set(e,t)),e}var C2,yp,bp,gp,Ef,mp,wf,vf,xf,fs,Tf=Vf(()=>{C2=(t,e)=>e.some(r=>t instanceof r);gp=new WeakMap,Ef=new WeakMap,mp=new WeakMap,wf=new WeakMap,vf=new WeakMap;xf={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return Ef.get(t);if(e==="objectStoreNames")return t.objectStoreNames||mp.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return sr(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};fs=t=>vf.get(t)});var Ep={};Uy(Ep,{deleteDB:()=>G2,openDB:()=>K2,unwrap:()=>fs,wrap:()=>sr});function K2(t,e,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(t,e),a=sr(o);return n&&o.addEventListener("upgradeneeded",c=>{n(sr(o.result),c.oldVersion,c.newVersion,sr(o.transaction),c)}),r&&o.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",f=>i(f.oldVersion,f.newVersion,f))}).catch(()=>{}),a}function G2(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),sr(r).then(()=>{})}function wp(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Bf.get(e))return Bf.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=W2.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||Y2.includes(r)))return;let s=async function(o,...a){let c=this.transaction(o,i?"readwrite":"readonly"),f=c.store;return n&&(f=f.index(a.shift())),(await Promise.all([f[r](...a),i&&c.done]))[0]};return Bf.set(e,s),s}var Y2,W2,Bf,xp=Vf(()=>{Tf();Tf();Y2=["get","getKey","getAll","getAllKeys","count"],W2=["put","add","delete","clear"],Bf=new Map;_p(t=>({...t,get:(e,r,n)=>wp(e,r)||t.get(e,r,n),has:(e,r)=>!!wp(e,r)||t.has(e,r)}))});var Af=J(ma=>{"use strict";Object.defineProperty(ma,"__esModule",{value:!0});ma.IdbKeyVal=void 0;var z2=(xp(),Fy(Ep)),ls=_a(),vp="auth-client-db",Tp="ic-keyval",D2=async(t=vp,e=Tp,r)=>(ls.isBrowser&&(localStorage!=null&&localStorage.getItem(ls.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(ls.KEY_STORAGE_DELEGATION),localStorage.removeItem(ls.KEY_STORAGE_KEY)),await(0,z2.openDB)(t,r,{upgrade:n=>{n.objectStoreNames,n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function Z2(t,e,r){return await t.get(e,r)}async function X2(t,e,r,n){return await t.put(e,n,r)}async function J2(t,e,r){return await t.delete(e,r)}var Sf=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=vp,storeName:n=Tp,version:i=ls.DB_VERSION}=e??{},s=await D2(r,n,i);return new t(s,n)}async set(e,r){return await X2(this._db,this._storeName,e,r)}async get(e){var r;return(r=await Z2(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await J2(this._db,this._storeName,e)}};ma.IdbKeyVal=Sf});var _a=J(ot=>{"use strict";var L2=ot&&ot.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Q2=ot&&ot.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},wa;Object.defineProperty(ot,"__esModule",{value:!0});ot.IdbStorage=ot.LocalStorage=ot.isBrowser=ot.DB_VERSION=ot.KEY_VECTOR=ot.KEY_STORAGE_DELEGATION=ot.KEY_STORAGE_KEY=void 0;var eE=Af();ot.KEY_STORAGE_KEY="identity";ot.KEY_STORAGE_DELEGATION="delegation";ot.KEY_VECTOR="iv";ot.DB_VERSION=1;ot.isBrowser=typeof window<"u";var Of=class{constructor(e="ic-",r){this.prefix=e,this._localStorage=r}get(e){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+e))}set(e,r){return this._getLocalStorage().setItem(this.prefix+e,r),Promise.resolve()}remove(e){return this._getLocalStorage().removeItem(this.prefix+e),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let e=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!e)throw new Error("Could not find local storage.");return e}};ot.LocalStorage=Of;var Nf=class{constructor(e){wa.set(this,void 0),L2(this,wa,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}eE.IdbKeyVal.create(Q2(this,wa,"f")).then(r=>{this.initializedDb=r,e(r)})})}async get(e){return await(await this._db).get(e)}async set(e,r){await(await this._db).set(e,r)}async remove(e){await(await this._db).remove(e)}};ot.IdbStorage=Nf;wa=new WeakMap});var Ap=J(Le=>{"use strict";var tE=Le&&Le.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),rE=Le&&Le.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&tE(e,t,r)};Object.defineProperty(Le,"__esModule",{value:!0});Le.AuthClient=Le.ERROR_USER_INTERRUPT=Le.IdbKeyVal=Le.KEY_STORAGE_KEY=Le.KEY_STORAGE_DELEGATION=Le.LocalStorage=Le.IdbStorage=void 0;var Bp=Ir(),Zt=hp(),Sp=_f(),vt=_a(),Ea=_a();Object.defineProperty(Le,"IdbStorage",{enumerable:!0,get:function(){return Ea.IdbStorage}});Object.defineProperty(Le,"LocalStorage",{enumerable:!0,get:function(){return Ea.LocalStorage}});Object.defineProperty(Le,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return Ea.KEY_STORAGE_DELEGATION}});Object.defineProperty(Le,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return Ea.KEY_STORAGE_KEY}});var nE=Af();Object.defineProperty(Le,"IdbKeyVal",{enumerable:!0,get:function(){return nE.IdbKeyVal}});var iE="https://identity.ic0.app",sE="#authorize",Pf="ECDSA",Rf="Ed25519",oE=500;Le.ERROR_USER_INTERRUPT="UserInterrupt";rE(_f(),Le);var Uf=class{constructor(e,r,n,i,s,o,a,c){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=o,this._idpWindow=a,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let s=(r=e.storage)!==null&&r!==void 0?r:new vt.IdbStorage,o=(n=e.keyType)!==null&&n!==void 0?n:Pf,a=null;if(e.identity)a=e.identity;else{let d=await s.get(vt.KEY_STORAGE_KEY);if(!d&&vt.isBrowser)try{let v=new vt.LocalStorage,E=await v.get(vt.KEY_STORAGE_DELEGATION),g=await v.get(vt.KEY_STORAGE_KEY);E&&g&&o===Pf&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(vt.KEY_STORAGE_DELEGATION,E),await s.set(vt.KEY_STORAGE_KEY,g),d=E,await v.remove(vt.KEY_STORAGE_DELEGATION),await v.remove(vt.KEY_STORAGE_KEY))}catch(v){console.error("error while attempting to recover localstorage: "+v)}if(d)try{typeof d=="object"?o===Rf&&typeof d=="string"?a=await Zt.Ed25519KeyIdentity.fromJSON(d):a=await Zt.ECDSAKeyIdentity.fromKeyPair(d):typeof d=="string"&&(a=Zt.Ed25519KeyIdentity.fromJSON(d))}catch{}}let c=new Bp.AnonymousIdentity,f=null;if(a)try{let d=await s.get(vt.KEY_STORAGE_DELEGATION);if(typeof d=="object"&&d!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?c=e.identity:d&&(f=Zt.DelegationChain.fromJSON(d),(0,Zt.isDelegationValid)(f)?"toDer"in a?c=Zt.PartialDelegationIdentity.fromDelegation(a,f):c=Zt.DelegationIdentity.fromDelegation(a,f):(await If(s),a=null))}catch(d){console.error(d),await If(s),a=null}let l;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?l=void 0:(f||e.identity)&&(l=Sp.IdleManager.create(e.idleOptions)),a||(o===Rf?(a=await Zt.Ed25519KeyIdentity.generate(),await s.set(vt.KEY_STORAGE_KEY,JSON.stringify(a.toJSON()))):(e.storage&&o===Pf&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${Rf}' as the key type, as it can serialize to a string`),a=await Zt.ECDSAKeyIdentity.generate(),await s.set(vt.KEY_STORAGE_KEY,a.getKeyPair()))),new this(c,a,f,s,l,e)}_registerDefaultIdleCallback(){var e,r;let n=(e=this._createOptions)===null||e===void 0?void 0:e.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(e,r){var n,i;let s=e.delegations.map(f=>({delegation:new Zt.Delegation(f.delegation.pubkey,f.delegation.expiration,f.delegation.targets),signature:f.signature.buffer})),o=Zt.DelegationChain.fromDelegations(s,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=o,"toDer"in a?this._identity=Zt.PartialDelegationIdentity.fromDelegation(a,this._chain):this._identity=Zt.DelegationIdentity.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=Sp.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(vt.KEY_STORAGE_DELEGATION,JSON.stringify(this._chain.toJSON())),r?.(e)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(e){var r,n,i,s;let o=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||iE);a.hash=sE,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=e?.maxTimeToLive)!==null&&i!==void 0?i:o},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Le.ERROR_USER_INTERRUPT,e?.onError):setTimeout(c,oE))};c()}_getEventHandler(e,r){return async n=>{var i,s,o;if(n.origin!==e.origin){console.warn(`WARNING: expected origin '${e.origin}', got '${n.origin}' (ignoring)`);return}let a=n.data;switch(a.kind){case"authorize-ready":{let c=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(s=r?.derivationOrigin)===null||s===void 0?void 0:s.toString()},r?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(c,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.text,r?.onError);break;default:break}}}_handleFailure(e,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(e),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(e={}){if(await If(this._storage),this._identity=new Bp.AnonymousIdentity,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};Le.AuthClient=Uf;async function If(t){await t.remove(vt.KEY_STORAGE_KEY),await t.remove(vt.KEY_STORAGE_DELEGATION),await t.remove(vt.KEY_VECTOR)}});var Va=Kn(Rt(),1);var et=t=>t==null,nt=t=>!et(t),mb=class extends Error{},Ts=(t,e)=>{if(et(t))throw new mb(e)},qa="__bigint__",ja="__principal__",ka="__uint8array__",_b=(t,e)=>typeof e=="bigint"?{[qa]:`${e}`}:nt(e)&&e instanceof Va.Principal?{[ja]:e.toText()}:nt(e)&&e instanceof Uint8Array?{[ka]:Array.from(e)}:e,wb=(t,e)=>{let r=n=>e[n];return nt(e)&&typeof e=="object"&&qa in e?BigInt(r(qa)):nt(e)&&typeof e=="object"&&ja in e?Va.Principal.fromText(r(ja)):nt(e)&&typeof e=="object"&&ka in e?Uint8Array.from(r(ka)):e},wt=t=>nt(t)?[t]:[],ht=t=>t?.[0],tl=async t=>{let e=new Blob([JSON.stringify(t,_b)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},Bs=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),wb)},rl=()=>typeof window<"u";var zn=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:r})=>r(e))}subscribe(e){let r=Symbol();return this.callbacks.push({id:r,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var qr=class t extends zn{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let r=super.subscribe(e);return e(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var Ha=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var nl=BigInt(144e11),il=!1,sl={width:576,height:576},ol={width:505,height:705},al="internetcomputer.org";var Dn="http://127.0.0.1:5987",cl="rdmx6-jaaaa-aaaaa-aaadq-cai";var yr=class t extends zn{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var $a=({width:t,height:e})=>{if(!rl()||et(window)||et(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-e/2,s=r/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${s}`};var Ss=class{#e;constructor({domain:e}){this.#e=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=yr.getInstance().get()?.container;if(et(n)||n===!1)return`https://identity.${this.#e??al}`;let i=yr.getInstance().get(),s=nt(i)&&nt(i?.internetIdentityId)?i.internetIdentityId:cl,{host:o,protocol:a}=new URL(n===!0?Dn:n);return/apple/i.test(navigator?.vendor)?`${a}//${o}?canisterId=${s}`:`${a}//${s}.${o.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:$a(sl)},identityProvider:r()}}},ul=class{#e;#t;constructor({appName:e,logoUrl:r}){this.#e=e,this.#t=r}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:$a(ol)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var Op=Kn(Ap(),1),xa=()=>Op.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Np=async({data:t})=>{try{return await Bs(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var Ff=async t=>{let{data:e,version:r,description:n}=t;return{description:wt(n),data:await tl(e),version:wt(r)}},Mf=t=>{let{version:e}=t;return{version:wt(e)}},ds=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:s,...o}=t;return{key:e,description:ht(i),owner:r.toText(),data:await Bs(s),version:ht(n),...o}};var Rp=Kn(Rt(),1);var Pp=t=>{if(et(t))return wt();switch(t.matcher){case"equal":return wt({Equal:t.timestamp});case"greaterThan":return wt({GreaterThan:t.timestamp});case"lessThan":return wt({LessThan:t.timestamp});case"between":return wt({Between:[t.timestamps.start,t.timestamps.end]});default:throw new Error("Invalid list matcher for timestamp",t)}},xi=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:et(t)?[]:[{key:wt(t.key),description:wt(t.description),created_at:Pp(t.createdAt),updated_at:Pp(t.updatedAt)}],paginate:wt(et(e)?void 0:{start_after:wt(e.startAfter),limit:wt(et(e.limit)?void 0:BigInt(e.limit))}),order:wt(et(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:wt(et(n)?void 0:typeof n=="string"?Rp.Principal.fromText(n):n)});var Ip=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),n=t.Record({field:r,desc:t.Bool}),i=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),s=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(i),description:t.Opt(t.Text),created_at:t.Opt(i)}),o=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),a=t.Record({order:t.Opt(n),owner:t.Opt(t.Principal),matcher:t.Opt(s),paginate:t.Opt(o)}),c=t.Record({controllers:t.Vec(t.Principal)}),f=t.Variant({Write:t.Null,Admin:t.Null}),l=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:f,expires_at:t.Opt(t.Nat64)}),d=t.Record({version:t.Opt(t.Nat64)}),v=t.Variant({Db:t.Null,Storage:t.Null}),E=t.Record({version:t.Opt(t.Nat64)}),g=t.Record({cycles:t.Nat,destination_id:t.Principal}),m=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),O=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),T=t.Record({key:m,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,O)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),k=t.Record({derivation_origin:t.Opt(t.Text)}),F=t.Record({internet_identity:t.Opt(k)}),K=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),P=t.Record({max_memory_size:t.Opt(K)}),q=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),D=t.Variant({Deny:t.Null,Allow:t.Null}),z=t.Record({status_code:t.Nat16,location:t.Text}),$=t.Record({iframe:t.Opt(q),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(K),raw_access:t.Opt(D),redirects:t.Opt(t.Vec(t.Tuple(t.Text,z)))}),se=t.Record({db:t.Opt(P),authentication:t.Opt(F),storage:$}),ee=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),de=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),ce=t.Variant({Heap:t.Null,Stable:t.Null}),xe=t.Record({memory:ce,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),Z=t.Variant({Callback:t.Record({token:xe,callback:t.Func([],[],["query"])})}),C=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(Z),status_code:t.Nat16}),X=t.Record({token:t.Opt(xe),body:t.Vec(t.Nat8)}),j=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),U=t.Record({batch_id:t.Nat}),W=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,T)),items_length:t.Nat64}),L=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),ne=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,ee)),items_length:t.Nat64}),N=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),y=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(ce),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:N,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:N}),fe=t.Record({stable:t.Nat64,heap:t.Nat64}),ue=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:f,expires_at:t.Opt(t.Nat64)}),ae=t.Record({controller:ue,controllers:t.Vec(t.Principal)}),te=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),u=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(ce),max_size:t.Opt(t.Nat),read:N,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:N}),h=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),p=t.Record({chunk_id:t.Nat});return t.Service({build_version:t.Func([],[t.Text],["query"]),commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,a],[t.Nat64],["query"]),count_collection_assets:t.Func([t.Text],[t.Nat64],["query"]),count_collection_docs:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text,a],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([c],[t.Vec(t.Tuple(t.Principal,l))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,d],[],[]),del_docs:t.Func([t.Text],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,d))],[],[]),del_rule:t.Func([v,t.Text,E],[],[]),deposit_cycles:t.Func([g],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(T)],["query"]),get_auth_config:t.Func([],[t.Opt(F)],["query"]),get_config:t.Func([],[se],[]),get_db_config:t.Func([],[t.Opt(P)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(ee)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(T)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(ee)))],["query"]),get_storage_config:t.Func([],[$],["query"]),http_request:t.Func([de],[C],["query"]),http_request_streaming_callback:t.Func([xe],[X],["query"]),init_asset_upload:t.Func([j],[U],[]),list_assets:t.Func([t.Text,a],[W],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,l))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,L))],["query"]),list_docs:t.Func([t.Text,a],[ne],["query"]),list_rules:t.Func([v],[t.Vec(t.Tuple(t.Text,y))],["query"]),memory_size:t.Func([],[fe],["query"]),set_auth_config:t.Func([F],[],[]),set_controllers:t.Func([ae],[t.Vec(t.Tuple(t.Principal,l))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([P],[],[]),set_doc:t.Func([t.Text,t.Text,te],[ee],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,te))],[t.Vec(t.Tuple(t.Text,ee))],[]),set_rule:t.Func([v,t.Text,u],[],[]),set_storage_config:t.Func([$],[],[]),upload_asset_chunk:t.Func([h],[p],[]),version:t.Func([],[t.Text],["query"])})};var va=Kn(Ir(),1);var Up=async({satelliteId:t,idlFactory:e,identity:r,fetch:n,container:i})=>{let o=nt(i)&&i!==!1?i===!0?Dn:i:"https://icp-api.io",a=new va.HttpAgent({identity:r,host:o,...n&&{fetch:n}});return nt(i)&&await a.fetchRootKey(),va.Actor.createActor(e,{agent:a,canisterId:t})};var Fp=({satelliteId:t,container:e})=>{let{satelliteId:r}=Cf({satelliteId:t}),{container:n}=qf({container:e});if(nt(n)&&n!==!1){let{host:i,protocol:s}=new URL(n===!0?Dn:n);return`${s}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},Cf=({satelliteId:t})=>nt(t)?{satelliteId:t}:yr.getInstance().get()??{satelliteId:void 0},qf=({container:t})=>nt(t)?{container:t}:yr.getInstance().get()??{container:void 0};var Tt=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=Cf({satelliteId:t});Ts(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=qf({container:e});return Up({satelliteId:n,container:i,idlFactory:Ip,...r})};var Mp=async({collection:t,key:e,satellite:r})=>{let{get_doc:n}=await Tt(r),i=ht(await n(t,e));if(!et(i))return ds({doc:i,key:e})},Cp=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await Tt(e),n=t.map(({collection:o,key:a})=>[o,a]),i=await r(n),s=[];for(let[o,a]of i){let c=ht(a);s.push(nt(c)?await ds({key:o,doc:c}):void 0)}return s},qp=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await Tt(r),{key:i}=e,s=await Ff(e),o=await n(t,i,s);return await ds({key:i,doc:o})},jp=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await Tt(e),n=[];for(let{collection:o,doc:a}of t){let{key:c}=a;n.push([o,c,await Ff(a)])}let i=await r(n),s=[];for(let[o,a]of i)s.push(await ds({key:o,doc:a}));return s},kp=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await Tt(r),{key:i}=e;return n(t,i,Mf(e))},Vp=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await Tt(e),n=t.map(({collection:i,doc:s})=>[i,s.key,Mf(s)]);await r(n)},Hp=async({collection:t,filter:e,satellite:r})=>{let{list_docs:n}=await Tt(r),{items:i,items_page:s,items_length:o,matches_length:a,matches_pages:c}=await n(t,xi(e)),f=[];for(let[l,d]of i){let{data:v,owner:E,description:g,version:m,...O}=d;f.push({key:l,description:ht(g),owner:E.toText(),data:await Np({data:v}),version:ht(m),...O})}return{items:f,items_length:o,items_page:ht(s),matches_length:a,matches_pages:ht(c)}},$p=async({collection:t,filter:e,satellite:r})=>{let{count_docs:n}=await Tt(r);return n(t,xi(e))};var Kp=Kn(Ir(),1);var gt=t=>t!==void 0?t:Ta()??new Kp.AnonymousIdentity;var Gp=async({satellite:t,...e})=>{let r=gt(t?.identity);return Mp({...e,satellite:{...t,identity:r}})},sv=async({satellite:t,...e})=>{let r=gt(t?.identity);return Cp({...e,satellite:{...t,identity:r}})},Yp=async({satellite:t,...e})=>{let r=gt(t?.identity);return qp({...e,satellite:{...t,identity:r}})},ov=async({satellite:t,...e})=>{let r=gt(t?.identity);return jp({...e,satellite:{...t,identity:r}})},av=async({satellite:t,...e})=>{let r=gt(t?.identity);return kp({...e,satellite:{...t,identity:r}})},cv=async({satellite:t,...e})=>{let r=gt(t?.identity);return Vp({...e,satellite:{...t,identity:r}})},uv=async({satellite:t,filter:e,...r})=>{let n=gt(t?.identity);return Hp({...r,filter:e??{},satellite:{...t,identity:n}})},fv=async({satellite:t,filter:e,...r})=>{let n=gt(t?.identity);return $p({...r,filter:e??{},satellite:{...t,identity:n}})};var Wp=async t=>{let e=Ta();if(et(e))throw new Error("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=await Gp({collection:"#user",key:r});return et(n)?await aE({userId:r,provider:t}):n},aE=async({userId:t,...e})=>Yp({collection:"#user",doc:{key:t,data:e}});var Fr,jf=async t=>{if(Fr=Fr??await xa(),!(await Fr?.isAuthenticated()??!1))return;let r=await Wp(t);qr.getInstance().set(r)},cE=async t=>new Promise(async(e,r)=>{Fr=Fr??await xa();let n=t?.provider??new Ss({});await Fr.login({onSuccess:async()=>{await jf(n.id),e()},onError:i=>r(i),maxTimeToLive:t?.maxTimeToLive??nl,allowPinAuthentication:t?.allowPin??il,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),kf=async()=>{await Fr?.logout(),Fr=void 0,qr.getInstance().reset()},Ta=()=>Fr?.getIdentity(),uE=async()=>(Fr??await xa()).getIdentity();var zp=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{Ha({message:"junoSignOutAuthTimer"}),await kf()};return r.onmessage=async({data:i})=>{let{msg:s,data:o}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":Ha({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},qr.getInstance().subscribe(i=>{if(et(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var Dp=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},Zp=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};var Ov=Kn(Rt(),1),fE=t=>t==null,lE=t=>!fE(t),Ba=t=>lE(t)?[t]:[],dE=()=>typeof window<"u",Xp=async({asset:{data:t,filename:e,collection:r,headers:n,token:i,fullPath:s,encoding:o,description:a},actor:c,init_asset_upload:f})=>{let{batch_id:l}=await f({collection:r,full_path:s,name:e,token:Ba(i),encoding_type:Ba(o),description:Ba(a)}),d=19e5,v=[],E=dE()?new Blob([await t.arrayBuffer()]):t,g=0n;for(let T=0;T<E.size;T+=d){let k=E.slice(T,T+d);v.push({batchId:l,chunk:k,actor:c,orderId:g}),g++}let m=[];for await(let T of hE({uploadChunks:v}))m=[...m,...T];let O=n.find(([T,k])=>T.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await c.commit_asset_upload({batch_id:l,chunk_ids:m.map(({chunk_id:T})=>T),headers:[...n,...O||[]]})};async function*hE({uploadChunks:t,limit:e=12}){for(let r=0;r<t.length;r=r+e){let n=t.slice(r,r+e);yield await Promise.all(n.map(i=>pE(i)))}}var pE=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:Ba(n)});var Jp=async({satellite:t,...e})=>{let r=await Tt(t);await Xp({actor:r,asset:e,init_asset_upload:async i=>await r.init_asset_upload(i)})},Lp=async({collection:t,satellite:e,filter:r})=>{let{list_assets:n}=await Tt(e),{items:i,items_length:s,items_page:o,matches_length:a,matches_pages:c}=await n(t,xi(r));return{items:i.map(([f,l])=>l),items_length:s,items_page:ht(o),matches_length:a,matches_pages:ht(c)}},Qp=async({collection:t,satellite:e,filter:r})=>{let{count_assets:n}=await Tt(e);return n(t,xi(r))},ey=async({collection:t,fullPath:e,satellite:r})=>(await Tt(r)).del_asset(t,e),ty=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await Tt(e),n=t.map(({collection:i,fullPath:s})=>[i,s]);await r(n)},ry=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await Tt(r);return ht(await n(t,e))},ny=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await Tt(e),n=t.map(({collection:s,fullPath:o})=>[s,o]);return(await r(n)).map(([s,o])=>ht(o))};var iy=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var $v=async t=>sy(t),Kv=async t=>sy({filename:t.data.name,...t}),sy=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:s,satellite:o,encoding:a,description:c})=>{let f=gt(o?.identity),l=decodeURI(t),d=i??`/${r}/${l}`,v={...o,identity:f};return await Jp({data:e,filename:l,collection:r,token:s,headers:n,fullPath:d,encoding:a,satellite:v,description:c}),{downloadUrl:oy({satellite:v,assetKey:{fullPath:d,token:s}}),fullPath:d,name:l}},Gv=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:gt(e?.identity)},{items:i,...s}=await Lp({collection:t,satellite:n,filter:r??{}}),o=i.map(({key:{full_path:a,token:c,name:f,owner:l,description:d},headers:v,encodings:E,created_at:g,updated_at:m})=>{let O=ht(c);return{fullPath:a,description:ht(d),name:f,downloadUrl:oy({satellite:n,assetKey:{fullPath:a,token:O}}),token:O,headers:v,encodings:E.reduce((T,[k,{modified:F,sha256:K,total_length:P}])=>({...T,[k]:{modified:F,sha256:iy(K),total_length:P}}),{}),owner:l.toText(),created_at:g,updated_at:m}});return{items:o,assets:o,...s}},Yv=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:gt(e?.identity)};return Qp({collection:t,satellite:n,filter:r??{}})},Wv=async({collection:t,fullPath:e,satellite:r})=>ey({collection:t,fullPath:e,satellite:{...r,identity:gt(r?.identity)}}),zv=async({assets:t,satellite:e})=>ty({assets:t,satellite:{...e,identity:gt(e?.identity)}}),Dv=async({satellite:t,...e})=>{let r=gt(t?.identity);return ry({...e,satellite:{...t,identity:r}})},Zv=async({satellite:t,...e})=>{let r=gt(t?.identity);return ny({...e,satellite:{...t,identity:r}})},oy=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:gt(r?.identity)};return`${Fp(n)}${t}${nt(e)?`?token=${e}`:""}`};var yE=t=>{let e=t?.satelliteId??Dp();Ts(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??Zp();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},n6=async t=>bE(t),bE=async t=>{let e=yE(t);yr.getInstance().set(e),await jf();let r=e.workers?.auth!==void 0?zp(e.workers.auth):void 0;return[...r?[r]:[]]},i6=t=>qr.getInstance().subscribe(t);export{Ss as InternetIdentityProvider,ul as NFIDProvider,i6 as authSubscribe,Yv as countAssets,fv as countDocs,Wv as deleteAsset,av as deleteDoc,zv as deleteManyAssets,cv as deleteManyDocs,oy as downloadUrl,Dv as getAsset,Gp as getDoc,Zv as getManyAssets,sv as getManyDocs,n6 as initJuno,bE as initSatellite,Gv as listAssets,uv as listDocs,Yp as setDoc,ov as setManyDocs,cE as signIn,kf as signOut,uE as unsafeIdentity,$v as uploadBlob,Kv as uploadFile};
48
+ `)}}ht.timeout=Qh;function ep(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}ht.backoff=ep;function tp(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}ht.chain=tp});var ul=L($t=>{"use strict";var Dw=$t&&$t.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Zw=$t&&$t.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Xw=$t&&$t.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Dw(e,t,r);return Zw(e,t),e};Object.defineProperty($t,"__esModule",{value:!0});$t.pollForResponse=$t.defaultStrategy=$t.strategy=void 0;var $n=ha(),ds=is(),rp=Yt();$t.strategy=Xw(cl());var Jw=cl();Object.defineProperty($t,"defaultStrategy",{enumerable:!0,get:function(){return Jw.defaultStrategy}});async function np(t,e,r,n,i,s){var o;let a=[new TextEncoder().encode("request_status"),r],c=i??await((o=t.createReadStateRequest)===null||o===void 0?void 0:o.call(t,{paths:[a]})),f=await t.readState(e,{paths:[a]},void 0,c);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let d=await ds.Certificate.create({certificate:f.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:s}),h=(0,ds.lookupResultToBuffer)(d.lookup([...a,new TextEncoder().encode("status")])),B;switch(typeof h>"u"?B=$n.RequestStatusResponseStatus.Unknown:B=new TextDecoder().decode(h),B){case $n.RequestStatusResponseStatus.Replied:return{reply:(0,ds.lookupResultToBuffer)(d.lookup([...a,"reply"])),certificate:d};case $n.RequestStatusResponseStatus.Received:case $n.RequestStatusResponseStatus.Unknown:case $n.RequestStatusResponseStatus.Processing:return await n(e,r,B),np(t,e,r,n,c);case $n.RequestStatusResponseStatus.Rejected:{let w=new Uint8Array((0,ds.lookupResultToBuffer)(d.lookup([...a,"reject_code"])))[0],u=new TextDecoder().decode((0,ds.lookupResultToBuffer)(d.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
49
+ Request ID: ${(0,rp.toHex)(r)}
50
+ Reject code: ${w}
51
+ Reject text: ${u}
52
+ `)}case $n.RequestStatusResponseStatus.Done:throw new Error(`Call was marked as done but we never saw the reply:
53
+ Request ID: ${(0,rp.toHex)(r)}
54
+ `)}throw new Error("unreachable")}$t.pollForResponse=np});var ip=L(ll=>{"use strict";Object.defineProperty(ll,"__esModule",{value:!0});ll.default=({IDL:t})=>{let e=t.Variant({mainnet:t.Null,testnet:t.Null}),r=t.Text,n=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,s=i,o=t.Record({network:e}),a=t.Nat64,c=t.Vec(a),f=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),d=t.Vec(t.Nat8),h=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),B=t.Record({height:t.Nat32,value:i,outpoint:h}),w=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:d,utxos:t.Vec(B)}),u=t.Record({transaction:t.Vec(t.Nat8),network:e}),g=t.Principal,U=t.Record({canister_id:g,num_requested_changes:t.Opt(t.Nat64)}),F=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),N=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),V=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:F,details:N}),W=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(V),total_num_changes:t.Nat64}),T=t.Record({canister_id:g}),C=t.Variant({controllers:t.Null,public:t.Null}),z=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:C,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),D=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:z,query_stats:t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),G=t.Record({canister_id:g}),ne=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(C),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),Q=t.Record({settings:t.Opt(ne),sender_canister_version:t.Opt(t.Nat64)}),le=t.Record({canister_id:g}),E=t.Record({canister_id:g}),_=t.Record({canister_id:g}),m=t.Variant({secp256k1:t.Null}),x=t.Record({key_id:t.Record({name:t.Text,curve:m}),canister_id:t.Opt(g),derivation_path:t.Vec(t.Vec(t.Nat8))}),j=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),H=t.Record({canister_id:g}),X=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),oe=t.Record({canister_log_records:t.Vec(X)}),ae=t.Record({value:t.Text,name:t.Text}),Y=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(ae)}),P=t.Record({url:t.Text,method:t.Variant({get:t.Null,head:t.Null,post:t.Null}),max_response_bytes:t.Opt(t.Nat64),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Record({function:t.Func([t.Record({context:t.Vec(t.Nat8),response:Y})],[Y],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(ae)}),p=t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({wasm_memory_persistence:t.Opt(t.Variant({keep:t.Null,replace:t.Null})),skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),ee=t.Record({hash:t.Vec(t.Nat8)}),re=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:p,chunk_hashes_list:t.Vec(ee),target_canister:g,store_canister:t.Opt(g),sender_canister_version:t.Opt(t.Nat64)}),de=t.Vec(t.Nat8),J=t.Record({arg:t.Vec(t.Nat8),wasm_module:de,mode:p,canister_id:g,sender_canister_version:t.Opt(t.Nat64)}),l=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),y=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_proposed_total:t.Nat64}),b=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(y)})),R=t.Record({settings:t.Opt(ne),specified_id:t.Opt(g),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),A=t.Record({canister_id:g}),O=t.Record({canister_id:g,amount:t.Nat}),q=t.Vec(t.Nat8),v=t.Record({key_id:t.Record({name:t.Text,curve:m}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),I=t.Record({signature:t.Vec(t.Nat8)}),k=t.Record({canister_id:g}),M=t.Record({canister_id:g}),Z=t.Record({canister_id:g}),te=t.Vec(ee),fe=t.Record({canister_id:g,sender_canister_version:t.Opt(t.Nat64)}),_e=t.Record({canister_id:t.Principal,settings:ne,sender_canister_version:t.Opt(t.Nat64)}),Fe=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),He=ee;return t.Service({bitcoin_get_balance:t.Func([n],[s],[]),bitcoin_get_current_fee_percentiles:t.Func([o],[c],[]),bitcoin_get_utxos:t.Func([f],[w],[]),bitcoin_send_transaction:t.Func([u],[],[]),canister_info:t.Func([U],[W],[]),canister_status:t.Func([T],[D],[]),clear_chunk_store:t.Func([G],[],[]),create_canister:t.Func([Q],[le],[]),delete_canister:t.Func([E],[],[]),deposit_cycles:t.Func([_],[],[]),ecdsa_public_key:t.Func([x],[j],[]),fetch_canister_logs:t.Func([H],[oe],["query"]),http_request:t.Func([P],[Y],[]),install_chunked_code:t.Func([re],[],[]),install_code:t.Func([J],[],[]),node_metrics_history:t.Func([l],[b],[]),provisional_create_canister_with_cycles:t.Func([R],[A],[]),provisional_top_up_canister:t.Func([O],[],[]),raw_rand:t.Func([],[q],[]),sign_with_ecdsa:t.Func([v],[I],[]),start_canister:t.Func([k],[],[]),stop_canister:t.Func([M],[],[]),stored_chunks:t.Func([Z],[te],[]),uninstall_code:t.Func([fe],[],[]),update_settings:t.Func([_e],[],[]),upload_chunk:t.Func([Fe],[He],[])})}});var ga=L(Ke=>{"use strict";var Lw=Ke&&Ke.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ke,"__esModule",{value:!0});Ke.AdvancedActor=Ke.getManagementCanister=Ke.ACTOR_METHOD_WITH_CERTIFICATE=Ke.ACTOR_METHOD_WITH_HTTP_DETAILS=Ke.Actor=Ke.UpdateCallRejectedError=Ke.QueryCallRejectedError=Ke.ActorCallError=void 0;var Qw=$f(),fl=ha(),dl=ii(),pa=fi(),sp=ul(),Cr=Nt(),e2=Yt(),t2=Lw(ip()),hs=class extends dl.AgentError{constructor(e,r,n,i){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(s=>` "${s}": ${JSON.stringify(i[s])}`)].join(`
55
+ `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}};Ke.ActorCallError=hs;var ya=class extends hs{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=fl.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};Ke.QueryCallRejectedError=ya;var ba=class extends hs{constructor(e,r,n,i){super(e,r,"update",Object.assign({"Request ID":(0,e2.toHex)(n)},i.body?Object.assign(Object.assign({},i.body.error_code?{"Error code":i.body.error_code}:{}),{"Reject code":String(i.body.reject_code),"Reject message":i.body.reject_message}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i}};Ke.UpdateCallRejectedError=ba;var ar=Symbol.for("ic-agent-metadata"),ps=class t{constructor(e){this[ar]=Object.freeze(e)}static agentOf(e){return e[ar].config.agent}static interfaceOf(e){return e[ar].service}static canisterIdOf(e){return Cr.Principal.from(e[ar].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],s=[...new Uint8Array(e.module)],o=typeof r.canisterId=="string"?Cr.Principal.fromText(r.canisterId):r.canisterId;await hl(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(e,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await hl(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:pa.IDL});class i extends t{constructor(o){if(!o.canisterId)throw new dl.AgentError(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof o.canisterId=="string"?Cr.Principal.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},op),o),{canisterId:a}),service:n});for(let[c,f]of n._fields)r?.httpDetails&&f.annotations.push(Ke.ACTOR_METHOD_WITH_HTTP_DETAILS),r?.certificate&&f.annotations.push(Ke.ACTOR_METHOD_WITH_CERTIFICATE),this[c]=r2(this,c,f,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new dl.AgentError(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(e,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(e,n))(r)}};Ke.Actor=ps;function Bi(t,e){let r=pa.IDL.decode(t,Qw.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var op={pollingStrategyFactory:sp.strategy.defaultStrategy};Ke.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";Ke.ACTOR_METHOD_WITH_CERTIFICATE="certificate";function r2(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ar].config).queryTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ar].config),o)));let d=o.agent||t[ar].config.agent||(0,fl.getDefaultAgent)(),h=Cr.Principal.from(o.canisterId||t[ar].config.canisterId),B=pa.IDL.encode(r.argTypes,a),w=await d.query(h,{methodName:e,arg:B,effectiveCanisterId:o.effectiveCanisterId}),u=Object.assign(Object.assign({},w.httpDetails),{requestDetails:w.requestDetails});switch(w.status){case"rejected":throw new ya(h,e,w);case"replied":return r.annotations.includes(Ke.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:u,result:Bi(r.retTypes,w.reply.arg)}:Bi(r.retTypes,w.reply.arg)}}:i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ar].config).callTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ar].config),o)));let d=o.agent||t[ar].config.agent||(0,fl.getDefaultAgent)(),{canisterId:h,effectiveCanisterId:B,pollingStrategyFactory:w}=Object.assign(Object.assign(Object.assign({},op),t[ar].config),o),u=Cr.Principal.from(h),g=B!==void 0?Cr.Principal.from(B):u,U=pa.IDL.encode(r.argTypes,a),{requestId:F,response:N,requestDetails:V}=await d.call(u,{methodName:e,arg:U,effectiveCanisterId:g});if(!N.ok||N.body)throw new ba(u,e,F,N);let W=w(),{certificate:T,reply:C}=await(0,sp.pollForResponse)(d,g,F,W,n),z=r.annotations.includes(Ke.ACTOR_METHOD_WITH_HTTP_DETAILS),D=r.annotations.includes(Ke.ACTOR_METHOD_WITH_CERTIFICATE),G=Object.assign(Object.assign({},N),{requestDetails:V});if(C!==void 0)return z&&D?{httpDetails:G,certificate:T,result:Bi(r.retTypes,C)}:D?{certificate:T,result:Bi(r.retTypes,C)}:z?{httpDetails:G,result:Bi(r.retTypes,C)}:Bi(r.retTypes,C);if(r.retTypes.length===0)return z?{httpDetails:N,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...o)=>i({},...o);return s.withOptions=o=>(...a)=>i(o,...a),s}function hl(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:Cr.Principal.from(t.effectiveCanisterId)};let i=n[0],s=Cr.Principal.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(s=Cr.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return ps.createActor(t2.default,Object.assign(Object.assign(Object.assign({},t),{canisterId:Cr.Principal.fromHex("")}),{callTransform:e,queryTransform:e}))}Ke.getManagementCanister=hl;var pl=class extends ps{constructor(e){super(e)}};Ke.AdvancedActor=pl});var ap=L(yl=>{"use strict";Object.defineProperty(yl,"__esModule",{value:!0});yl.default=({IDL:t})=>t.Service({retrieve:t.Func([t.Text],[t.Vec(t.Nat8)],["query"]),store:t.Func([t.Text,t.Vec(t.Nat8)],[],[])})});var cp=L(Ai=>{"use strict";var n2=Ai&&Ai.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ai,"__esModule",{value:!0});Ai.createAssetCanisterActor=void 0;var i2=ga(),s2=n2(ap());function o2(t){return i2.Actor.createActor(s2.default,t)}Ai.createAssetCanisterActor=o2});var up=L(qr=>{"use strict";var a2=qr&&qr.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),c2=qr&&qr.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),u2=qr&&qr.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&a2(e,t,r);return c2(e,t),e};Object.defineProperty(qr,"__esModule",{value:!0});qr.fetchCandid=void 0;var l2=Nt(),f2=u2(ss()),d2=sl(),h2=ga();async function p2(t,e){e||(e=await d2.HttpAgent.create());let n=(await f2.request({agent:e,canisterId:l2.Principal.fromText(t),paths:["candid"]})).get("candid");if(n)return n;let i=({IDL:o})=>o.Service({__get_candid_interface_tmp_hack:o.Func([],[o.Text],["query"])});return await h2.Actor.createActor(i,{agent:e,canisterId:t}).__get_candid_interface_tmp_hack()}qr.fetchCandid=p2});var jr=L(Ue=>{"use strict";var lp=Ue&&Ue.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),y2=Ue&&Ue.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Kt=Ue&&Ue.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&lp(e,t,r)},bl=Ue&&Ue.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&lp(e,t,r);return y2(e,t),e};Object.defineProperty(Ue,"__esModule",{value:!0});Ue.Cbor=Ue.CanisterStatus=Ue.polling=void 0;Kt(ga(),Ue);Kt(ha(),Ue);Kt(xo(),Ue);Kt(Xi(),Ue);Kt(Xc(),Ue);Kt(cp(),Ue);Kt(is(),Ue);Kt(Qu(),Ue);Kt(up(),Ue);Kt(el(),Ue);Kt(Wi(),Ue);Kt(Ru(),Ue);Kt(Yt(),Ue);Kt(su(),Ue);Ue.polling=bl(ul());Ue.CanisterStatus=bl(ss());Ue.Cbor=bl(Zi())});var dp=L(kr=>{"use strict";var wa=kr&&kr.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},wn=kr&&kr.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ma,_a,Oi,Ni;Object.defineProperty(kr,"__esModule",{value:!0});kr.Ed25519KeyIdentity=kr.Ed25519PublicKey=void 0;var b2=jr(),Jt=jr(),ys=Ju();function fp(t){return t!==null&&typeof t=="object"}var Kn=class t{constructor(e){if(ma.set(this,void 0),_a.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");wa(this,ma,e,"f"),wa(this,_a,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=(0,Jt.fromHex)(e);return this.fromRaw(r)}else if(fp(e)){let r=e;if(fp(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,Jt.bufFromBufLike)(n.buffer))}else{if(r instanceof ArrayBuffer)return this.fromRaw(r);if("rawKey"in r)return this.fromRaw(r.rawKey);if("derKey"in r)return this.fromDer(r.derKey);if("toDer"in r)return this.fromDer(r.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){let r=(0,Jt.wrapDER)(e,Jt.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=(0,Jt.unwrapDER)(e,Jt.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return wn(this,ma,"f")}get derKey(){return wn(this,_a,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};kr.Ed25519PublicKey=Kn;ma=new WeakMap,_a=new WeakMap;Kn.RAW_KEY_LENGTH=32;var gl=class t extends Jt.SignIdentity{constructor(e,r){super(),Oi.set(this,void 0),Ni.set(this,void 0),wa(this,Oi,Kn.from(e),"f"),wa(this,Ni,new Uint8Array(r),"f")}static generate(e){if(e&&e.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");e||(e=ys.ed25519.utils.randomPrivateKey()),(0,b2.bufEquals)(e,new Uint8Array(new Array(32).fill(0)))&&console.warn("Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.");let r=new Uint8Array(32);for(let i=0;i<32;i++)r[i]=new Uint8Array(e)[i];let n=ys.ed25519.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(Kn.fromDer((0,Jt.fromHex)(r)),(0,Jt.fromHex)(n))}static fromJSON(e){let r=JSON.parse(e);if(Array.isArray(r)){if(typeof r[0]=="string"&&typeof r[1]=="string")return this.fromParsedJson([r[0],r[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(e)}`)}static fromKeyPair(e,r){return new t(Kn.fromRaw(e),r)}static fromSecretKey(e){let r=ys.ed25519.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[(0,Jt.toHex)(wn(this,Oi,"f").toDer()),(0,Jt.toHex)(wn(this,Ni,"f"))]}getKeyPair(){return{secretKey:wn(this,Ni,"f"),publicKey:wn(this,Oi,"f")}}getPublicKey(){return wn(this,Oi,"f")}async sign(e){let r=new Uint8Array(e),n=(0,Jt.uint8ToBuf)(ys.ed25519.sign(r,wn(this,Ni,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(e,r,n){let[i,s,o]=[e,r,n].map(a=>(typeof a=="string"&&(a=(0,Jt.fromHex)(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return ys.ed25519.verify(s,i,o)}};kr.Ed25519KeyIdentity=gl;Oi=new WeakMap,Ni=new WeakMap});var pp=L(Gn=>{"use strict";Object.defineProperty(Gn,"__esModule",{value:!0});Gn.ECDSAKeyIdentity=Gn.CryptoError=void 0;var g2=jr(),Ea=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};Gn.CryptoError=Ea;function hp(t){if(typeof global<"u"&&global.crypto&&global.crypto.subtle)return global.crypto.subtle;if(t)return t;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new Ea("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var xa=class t extends g2.SignIdentity{constructor(e,r,n){super(),this._keyPair=e,this._derKey=r,this._subtleCrypto=n}static async generate(e){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=e??{},s=hp(i),o=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await s.exportKey("spki",o.publicKey);return new this(o,a,s)}static async fromKeyPair(e,r){let n=hp(r),i=await n.exportKey("spki",e.publicKey);return new t(e,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let e=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return e},r}async sign(e){let r={name:"ECDSA",hash:{name:"SHA-256"}};return this._keyPair.privateKey,await this._subtleCrypto.sign(r,this._keyPair.privateKey,e)}};Gn.ECDSAKeyIdentity=xa;Gn.default=xa});var _l=L(xn=>{"use strict";var m2=xn&&xn.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},bs=xn&&xn.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},En;Object.defineProperty(xn,"__esModule",{value:!0});xn.PartialIdentity=void 0;var _2=Nt(),ml=class{constructor(e){En.set(this,void 0),m2(this,En,e,"f")}get rawKey(){return bs(this,En,"f").rawKey}get derKey(){return bs(this,En,"f").derKey}toDer(){return bs(this,En,"f").toDer()}getPublicKey(){return bs(this,En,"f")}getPrincipal(){return _2.Principal.from(bs(this,En,"f").rawKey)}transformRequest(){return Promise.reject("Not implemented. You are attempting to use a partial identity to sign calls, but this identity only has access to the public key.To sign calls, use a DelegationIdentity instead.")}};xn.PartialIdentity=ml;En=new WeakMap});var yp=L(De=>{"use strict";var w2=De&&De.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),E2=De&&De.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),x2=De&&De.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&w2(e,t,r);return E2(e,t),e},v2=De&&De.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},T2=De&&De.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},S2=De&&De.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},va;Object.defineProperty(De,"__esModule",{value:!0});De.isDelegationValid=De.PartialDelegationIdentity=De.DelegationIdentity=De.DelegationChain=De.Delegation=void 0;var vn=jr(),El=Nt(),gs=x2(Di()),B2=_l(),A2=new TextEncoder().encode("ic-request-auth-delegation"),O2=new TextEncoder().encode(`
56
+ ic-request`);function wl(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return(0,vn.fromHex)(t)}var ms=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return gs.value.map(Object.assign({pubkey:gs.value.bytes(this.pubkey),expiration:gs.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:gs.value.array(this.targets.map(e=>gs.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,vn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};De.Delegation=ms;async function N2(t,e,r,n){let i=new ms(e.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...A2,...new Uint8Array((0,vn.requestIdOf)(i))]),o=await t.sign(s);return{delegation:i,signature:o}}var xl=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+15*60*1e3),i={}){var s,o;let a=await N2(e,r,n,i.targets);return new t([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],a],((o=i.previous)===null||o===void 0?void 0:o.publicKey)||e.getPublicKey().toDer())}static fromJSON(e){let{publicKey:r,delegations:n}=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:o,signature:a}=s,{pubkey:c,expiration:f,targets:d}=o;if(d!==void 0&&!Array.isArray(d))throw new Error("Invalid targets.");return{delegation:new ms(wl(c),BigInt("0x"+f),d&&d.map(h=>{if(typeof h!="string")throw new Error("Invalid target.");return El.Principal.fromHex(h)})),signature:wl(a)}});return new this(i,wl(r))}static fromDelegations(e,r){return new this(e,r)}toJSON(){return{delegations:this.delegations.map(e=>{let{delegation:r,signature:n}=e,{targets:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:(0,vn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,vn.toHex)(n)}}),publicKey:(0,vn.toHex)(this.publicKey)}}};De.DelegationChain=xl;var vl=class extends vn.SignIdentity{constructor(e,r){super(),this._inner=e,this._delegation=r}static fromDelegation(e,r){return new this(e,r)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(e){return this._inner.sign(e)}async transformRequest(e){let{body:r}=e,n=S2(e,["body"]),i=await(0,vn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...O2,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};De.DelegationIdentity=vl;var Tl=class t extends B2.PartialIdentity{constructor(e,r){super(e),va.set(this,void 0),v2(this,va,r,"f")}get delegation(){return T2(this,va,"f")}static fromDelegation(e,r){return new t(e,r)}};De.PartialDelegationIdentity=Tl;va=new WeakMap;function R2(t,e){for(let{delegation:i}of t.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?El.Principal.fromText(i):i)):r.push(typeof n=="string"?El.Principal.fromText(n):n));for(let i of r){let s=i.toText();for(let{delegation:o}of t.delegations){if(o.targets===void 0)continue;let a=!0;for(let c of o.targets)if(c.toText()===s){a=!1;break}if(a)return!1}}return!0}De.isDelegationValid=R2});var bp=L(Tn=>{"use strict";var P2=Tn&&Tn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Tn,"__esModule",{value:!0});Tn.WebAuthnIdentity=Tn.CosePublicKey=void 0;var Yn=jr(),Sl=P2(lo()),I2=Bn(),U2=fi();function F2(t){return(0,Yn.wrapDER)(t,Yn.DER_COSE_OID).buffer}function M2(t){let e=new DataView(new ArrayBuffer(2)),r=t.slice(53,55);[...new Uint8Array(r)].forEach((i,s)=>e.setUint8(s,i));let n=e.getUint16(0);return t.slice(55+n)}var Ta=class{constructor(e){this._cose=e,this._encodedKey=F2(e)}toDer(){return this._encodedKey}getCose(){return this._cose}};Tn.CosePublicKey=Ta;function C2(t="<ic0.app>"){return typeof t=="string"?Uint8Array.from(t,e=>e.charCodeAt(0)):t}async function q2(t){let e=await navigator.credentials.create(t??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:C2(),pubKeyCredParams:[{type:"public-key",alg:Bl.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,I2.randomBytes)(16),name:"Internet Identity",displayName:"Internet Identity"}}});return e===null?null:{id:e.id,response:e.response,type:e.type,authenticatorAttachment:e.authenticatorAttachment,getClientExtensionResults:e.getClientExtensionResults,rawId:(0,U2.bufFromBufLike)(e.rawId)}}var Bl;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(Bl||(Bl={}));var Al=class extends Yn.SignIdentity{constructor(e,r,n){super(),this.rawId=e,this.authenticatorAttachment=n,this._publicKey=new Ta(r)}static fromJSON(e){let{publicKey:r,rawId:n}=JSON.parse(e);if(typeof r!="string"||typeof n!="string")throw new Error("Invalid JSON string.");return new this((0,Yn.fromHex)(n),(0,Yn.fromHex)(r),void 0)}static async create(e){var r;let n=await q2(e);if(!n||n.type!=="public-key")throw new Error("Could not create credentials.");let i=n.response;if(i.attestationObject===void 0)throw new Error("Was expecting an attestation response.");let s=Sl.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,M2(s.authData),(r=n.authenticatorAttachment)!==null&&r!==void 0?r:void 0)}getPublicKey(){return this._publicKey}getAuthenticatorAttachment(){return this.authenticatorAttachment}async sign(e){let r=await navigator.credentials.get({publicKey:{allowCredentials:[{type:"public-key",id:this.rawId}],challenge:e,userVerification:"preferred"}});r.authenticatorAttachment!==null&&(this.authenticatorAttachment=r.authenticatorAttachment);let n=r.response,i=Sl.default.encode(new Sl.default.Tagged(55799,{authenticator_data:new Uint8Array(n.authenticatorData),client_data_json:new TextDecoder().decode(n.clientDataJSON),signature:new Uint8Array(n.signature)}));if(!i)throw new Error("failed to encode cbor");return i.buffer}toJSON(){return{publicKey:(0,Yn.toHex)(this._publicKey.getCose()),rawId:(0,Yn.toHex)(this.rawId)}}};Tn.WebAuthnIdentity=Al});var mp=L(Ge=>{"use strict";var j2=Ge&&Ge.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Nl=Ge&&Ge.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&j2(e,t,r)};Object.defineProperty(Ge,"__esModule",{value:!0});Ge.Secp256k1KeyIdentity=Ge.ED25519_OID=Ge.DER_COSE_OID=Ge.unwrapDER=Ge.wrapDER=Ge.WebAuthnIdentity=Ge.Ed25519PublicKey=Ge.Ed25519KeyIdentity=void 0;var gp=dp();Object.defineProperty(Ge,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return gp.Ed25519KeyIdentity}});Object.defineProperty(Ge,"Ed25519PublicKey",{enumerable:!0,get:function(){return gp.Ed25519PublicKey}});Nl(pp(),Ge);Nl(yp(),Ge);Nl(_l(),Ge);var k2=bp();Object.defineProperty(Ge,"WebAuthnIdentity",{enumerable:!0,get:function(){return k2.WebAuthnIdentity}});var Sa=jr();Object.defineProperty(Ge,"wrapDER",{enumerable:!0,get:function(){return Sa.wrapDER}});Object.defineProperty(Ge,"unwrapDER",{enumerable:!0,get:function(){return Sa.unwrapDER}});Object.defineProperty(Ge,"DER_COSE_OID",{enumerable:!0,get:function(){return Sa.DER_COSE_OID}});Object.defineProperty(Ge,"ED25519_OID",{enumerable:!0,get:function(){return Sa.ED25519_OID}});var Ol=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};Ge.Secp256k1KeyIdentity=Ol});var Pl=L(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.IdleManager=void 0;var _p=["mousedown","mousemove","keydown","touchstart","wheel"],Rl=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let s=this._resetTimer.bind(this);window.addEventListener("load",s,!0),_p.forEach(function(a){document.addEventListener(a,s,!0)});let o=(a,c)=>{let f;return(...d)=>{let h=this,B=function(){f=void 0,a.apply(h,d)};clearTimeout(f),f=window.setTimeout(B,c)}};if(e?.captureScroll){let a=o(s,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}s()}static create(e={}){return new this(e)}registerCallback(e){this.callbacks.push(e)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let e=this._resetTimer.bind(this);_p.forEach(function(r){document.removeEventListener(r,e,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let e=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(e,this.idleTimeout)}};Ba.IdleManager=Rl});function H2(){return wp||(wp=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function $2(){return Ep||(Ep=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function K2(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{r(cr(t.result)),i()},o=()=>{n(t.error),i()};t.addEventListener("success",s),t.addEventListener("error",o)});return e.then(r=>{r instanceof IDBCursor&&xp.set(r,t)}).catch(()=>{}),Ml.set(e,t),e}function G2(t){if(Ul.has(t))return;let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",o),t.removeEventListener("abort",o)},s=()=>{r(),i()},o=()=>{n(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",s),t.addEventListener("error",o),t.addEventListener("abort",o)});Ul.set(t,e)}function Tp(t){Fl=t(Fl)}function Y2(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(_s(this),e,...r);return vp.set(n,e.sort?e.sort():[e]),cr(n)}:$2().includes(t)?function(...e){return t.apply(_s(this),e),cr(xp.get(this))}:function(...e){return cr(t.apply(_s(this),e))}}function W2(t){return typeof t=="function"?Y2(t):(t instanceof IDBTransaction&&G2(t),V2(t,H2())?new Proxy(t,Fl):t)}function cr(t){if(t instanceof IDBRequest)return K2(t);if(Il.has(t))return Il.get(t);let e=W2(t);return e!==t&&(Il.set(t,e),Ml.set(e,t)),e}var V2,wp,Ep,xp,Ul,vp,Il,Ml,Fl,_s,Cl=Ll(()=>{V2=(t,e)=>e.some(r=>t instanceof r);xp=new WeakMap,Ul=new WeakMap,vp=new WeakMap,Il=new WeakMap,Ml=new WeakMap;Fl={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return Ul.get(t);if(e==="objectStoreNames")return t.objectStoreNames||vp.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return cr(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};_s=t=>Ml.get(t)});var Bp={};jy(Bp,{deleteDB:()=>D2,openDB:()=>z2,unwrap:()=>_s,wrap:()=>cr});function z2(t,e,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(t,e),a=cr(o);return n&&o.addEventListener("upgradeneeded",c=>{n(cr(o.result),c.oldVersion,c.newVersion,cr(o.transaction),c)}),r&&o.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",f=>i(f.oldVersion,f.newVersion,f))}).catch(()=>{}),a}function D2(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),cr(r).then(()=>{})}function Sp(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(ql.get(e))return ql.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=X2.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||Z2.includes(r)))return;let s=async function(o,...a){let c=this.transaction(o,i?"readwrite":"readonly"),f=c.store;return n&&(f=f.index(a.shift())),(await Promise.all([f[r](...a),i&&c.done]))[0]};return ql.set(e,s),s}var Z2,X2,ql,Ap=Ll(()=>{Cl();Cl();Z2=["get","getKey","getAll","getAllKeys","count"],X2=["put","add","delete","clear"],ql=new Map;Tp(t=>({...t,get:(e,r,n)=>Sp(e,r)||t.get(e,r,n),has:(e,r)=>!!Sp(e,r)||t.has(e,r)}))});var kl=L(Aa=>{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});Aa.IdbKeyVal=void 0;var J2=(Ap(),ky(Bp)),ws=Oa(),Op="auth-client-db",Np="ic-keyval",L2=async(t=Op,e=Np,r)=>(ws.isBrowser&&(localStorage!=null&&localStorage.getItem(ws.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(ws.KEY_STORAGE_DELEGATION),localStorage.removeItem(ws.KEY_STORAGE_KEY)),await(0,J2.openDB)(t,r,{upgrade:n=>{n.objectStoreNames,n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function Q2(t,e,r){return await t.get(e,r)}async function eE(t,e,r,n){return await t.put(e,n,r)}async function tE(t,e,r){return await t.delete(e,r)}var jl=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=Op,storeName:n=Np,version:i=ws.DB_VERSION}=e??{},s=await L2(r,n,i);return new t(s,n)}async set(e,r){return await eE(this._db,this._storeName,e,r)}async get(e){var r;return(r=await Q2(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await tE(this._db,this._storeName,e)}};Aa.IdbKeyVal=jl});var Oa=L(nt=>{"use strict";var rE=nt&&nt.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},nE=nt&&nt.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Na;Object.defineProperty(nt,"__esModule",{value:!0});nt.IdbStorage=nt.LocalStorage=nt.isBrowser=nt.DB_VERSION=nt.KEY_VECTOR=nt.KEY_STORAGE_DELEGATION=nt.KEY_STORAGE_KEY=void 0;var iE=kl();nt.KEY_STORAGE_KEY="identity";nt.KEY_STORAGE_DELEGATION="delegation";nt.KEY_VECTOR="iv";nt.DB_VERSION=1;nt.isBrowser=typeof window<"u";var Vl=class{constructor(e="ic-",r){this.prefix=e,this._localStorage=r}get(e){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+e))}set(e,r){return this._getLocalStorage().setItem(this.prefix+e,r),Promise.resolve()}remove(e){return this._getLocalStorage().removeItem(this.prefix+e),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let e=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!e)throw new Error("Could not find local storage.");return e}};nt.LocalStorage=Vl;var Hl=class{constructor(e){Na.set(this,void 0),rE(this,Na,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}iE.IdbKeyVal.create(nE(this,Na,"f")).then(r=>{this.initializedDb=r,e(r)})})}async get(e){return await(await this._db).get(e)}async set(e,r){await(await this._db).set(e,r)}async remove(e){await(await this._db).remove(e)}};nt.IdbStorage=Hl;Na=new WeakMap});var Ip=L(Je=>{"use strict";var sE=Je&&Je.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),oE=Je&&Je.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&sE(e,t,r)};Object.defineProperty(Je,"__esModule",{value:!0});Je.AuthClient=Je.ERROR_USER_INTERRUPT=Je.IdbKeyVal=Je.KEY_STORAGE_KEY=Je.KEY_STORAGE_DELEGATION=Je.LocalStorage=Je.IdbStorage=void 0;var Rp=jr(),Lt=mp(),Pp=Pl(),Et=Oa(),Ra=Oa();Object.defineProperty(Je,"IdbStorage",{enumerable:!0,get:function(){return Ra.IdbStorage}});Object.defineProperty(Je,"LocalStorage",{enumerable:!0,get:function(){return Ra.LocalStorage}});Object.defineProperty(Je,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return Ra.KEY_STORAGE_DELEGATION}});Object.defineProperty(Je,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return Ra.KEY_STORAGE_KEY}});var aE=kl();Object.defineProperty(Je,"IdbKeyVal",{enumerable:!0,get:function(){return aE.IdbKeyVal}});var cE="https://identity.ic0.app",uE="#authorize",$l="ECDSA",Kl="Ed25519",lE=500;Je.ERROR_USER_INTERRUPT="UserInterrupt";oE(Pl(),Je);var Yl=class{constructor(e,r,n,i,s,o,a,c){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=o,this._idpWindow=a,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let s=(r=e.storage)!==null&&r!==void 0?r:new Et.IdbStorage,o=(n=e.keyType)!==null&&n!==void 0?n:$l,a=null;if(e.identity)a=e.identity;else{let h=await s.get(Et.KEY_STORAGE_KEY);if(!h&&Et.isBrowser)try{let B=new Et.LocalStorage,w=await B.get(Et.KEY_STORAGE_DELEGATION),u=await B.get(Et.KEY_STORAGE_KEY);w&&u&&o===$l&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(Et.KEY_STORAGE_DELEGATION,w),await s.set(Et.KEY_STORAGE_KEY,u),h=w,await B.remove(Et.KEY_STORAGE_DELEGATION),await B.remove(Et.KEY_STORAGE_KEY))}catch(B){console.error("error while attempting to recover localstorage: "+B)}if(h)try{typeof h=="object"?o===Kl&&typeof h=="string"?a=await Lt.Ed25519KeyIdentity.fromJSON(h):a=await Lt.ECDSAKeyIdentity.fromKeyPair(h):typeof h=="string"&&(a=Lt.Ed25519KeyIdentity.fromJSON(h))}catch{}}let c=new Rp.AnonymousIdentity,f=null;if(a)try{let h=await s.get(Et.KEY_STORAGE_DELEGATION);if(typeof h=="object"&&h!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?c=e.identity:h&&(f=Lt.DelegationChain.fromJSON(h),(0,Lt.isDelegationValid)(f)?"toDer"in a?c=Lt.PartialDelegationIdentity.fromDelegation(a,f):c=Lt.DelegationIdentity.fromDelegation(a,f):(await Gl(s),a=null))}catch(h){console.error(h),await Gl(s),a=null}let d;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?d=void 0:(f||e.identity)&&(d=Pp.IdleManager.create(e.idleOptions)),a||(o===Kl?(a=await Lt.Ed25519KeyIdentity.generate(),await s.set(Et.KEY_STORAGE_KEY,JSON.stringify(a.toJSON()))):(e.storage&&o===$l&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${Kl}' as the key type, as it can serialize to a string`),a=await Lt.ECDSAKeyIdentity.generate(),await s.set(Et.KEY_STORAGE_KEY,a.getKeyPair()))),new this(c,a,f,s,d,e)}_registerDefaultIdleCallback(){var e,r;let n=(e=this._createOptions)===null||e===void 0?void 0:e.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(e,r){var n,i;let s=e.delegations.map(f=>({delegation:new Lt.Delegation(f.delegation.pubkey,f.delegation.expiration,f.delegation.targets),signature:f.signature.buffer})),o=Lt.DelegationChain.fromDelegations(s,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=o,"toDer"in a?this._identity=Lt.PartialDelegationIdentity.fromDelegation(a,this._chain):this._identity=Lt.DelegationIdentity.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=Pp.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(Et.KEY_STORAGE_DELEGATION,JSON.stringify(this._chain.toJSON())),r?.(e)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(e){var r,n,i,s;let o=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||cE);a.hash=uE,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=e?.maxTimeToLive)!==null&&i!==void 0?i:o},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Je.ERROR_USER_INTERRUPT,e?.onError):setTimeout(c,lE))};c()}_getEventHandler(e,r){return async n=>{var i,s,o;if(n.origin!==e.origin){console.warn(`WARNING: expected origin '${e.origin}', got '${n.origin}' (ignoring)`);return}let a=n.data;switch(a.kind){case"authorize-ready":{let c=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(s=r?.derivationOrigin)===null||s===void 0?void 0:s.toString()},r?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(c,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.text,r?.onError);break;default:break}}}_handleFailure(e,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(e),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(e={}){if(await Gl(this._storage),this._identity=new Rp.AnonymousIdentity,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};Je.AuthClient=Yl;async function Gl(t){await t.remove(Et.KEY_STORAGE_KEY),await t.remove(Et.KEY_STORAGE_DELEGATION),await t.remove(Et.KEY_VECTOR)}});var Za=Dn(Nt(),1);var Le=t=>t==null,rt=t=>!Le(t),vb=class extends Error{},Us=(t,e)=>{if(Le(t))throw new vb(e)},Wa="__bigint__",za="__principal__",Da="__uint8array__",Tb=(t,e)=>typeof e=="bigint"?{[Wa]:`${e}`}:rt(e)&&e instanceof Za.Principal?{[za]:e.toText()}:rt(e)&&e instanceof Uint8Array?{[Da]:Array.from(e)}:e,Sb=(t,e)=>{let r=n=>e[n];return rt(e)&&typeof e=="object"&&Wa in e?BigInt(r(Wa)):rt(e)&&typeof e=="object"&&za in e?Za.Principal.fromText(r(za)):rt(e)&&typeof e=="object"&&Da in e?Uint8Array.from(r(Da)):e},gt=t=>rt(t)?[t]:[],ut=t=>t?.[0],pf=async t=>{let e=new Blob([JSON.stringify(t,Tb)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},Fs=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),Sb)},yf=()=>typeof window<"u";var Ln=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:r})=>r(e))}subscribe(e){let r=Symbol();return this.callbacks.push({id:r,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var $r=class t extends Ln{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let r=super.subscribe(e);return e(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var Xa=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var bf=BigInt(144e11),gf=!1,mf={width:576,height:576},_f={width:505,height:705},wf="internetcomputer.org";var Qn="http://127.0.0.1:5987",Ef="rdmx6-jaaaa-aaaaa-aaadq-cai";var _r=class t extends Ln{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var Ja=({width:t,height:e})=>{if(!yf()||Le(window)||Le(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-e/2,s=r/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${s}`};var Ms=class{#e;constructor({domain:e}){this.#e=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=_r.getInstance().get()?.container;if(Le(n)||n===!1)return`https://identity.${this.#e??wf}`;let i=_r.getInstance().get(),s=rt(i)&&rt(i?.internetIdentityId)?i.internetIdentityId:Ef,{host:o,protocol:a}=new URL(n===!0?Qn:n);return/apple/i.test(navigator?.vendor)?`${a}//${o}?canisterId=${s}`:`${a}//${s}.${o.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:Ja(mf)},identityProvider:r()}}},xf=class{#e;#t;constructor({appName:e,logoUrl:r}){this.#e=e,this.#t=r}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:Ja(_f)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var Up=Dn(Ip(),1),Pa=()=>Up.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Fp=async({data:t})=>{try{return await Fs(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var Wl=async t=>{let{data:e,version:r,description:n}=t;return{description:gt(n),data:await pf(e),version:gt(r)}},zl=t=>{let{version:e}=t;return{version:gt(e)}},Es=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:s,...o}=t;return{key:e,description:ut(i),owner:r.toText(),data:await Fs(s),version:ut(n),...o}};var Cp=Dn(Nt(),1);var Mp=t=>{if(Le(t))return gt();switch(t.matcher){case"equal":return gt({Equal:t.timestamp});case"greaterThan":return gt({GreaterThan:t.timestamp});case"lessThan":return gt({LessThan:t.timestamp});case"between":return gt({Between:[t.timestamps.start,t.timestamps.end]});default:throw new Error("Invalid list matcher for timestamp",t)}},Ri=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:Le(t)?[]:[{key:gt(t.key),description:gt(t.description),created_at:Mp(t.createdAt),updated_at:Mp(t.updatedAt)}],paginate:gt(Le(e)?void 0:{start_after:gt(e.startAfter),limit:gt(Le(e.limit)?void 0:BigInt(e.limit))}),order:gt(Le(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:gt(Le(n)?void 0:typeof n=="string"?Cp.Principal.fromText(n):n)});var qp=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),n=t.Record({field:r,desc:t.Bool}),i=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),s=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(i),description:t.Opt(t.Text),created_at:t.Opt(i)}),o=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),a=t.Record({order:t.Opt(n),owner:t.Opt(t.Principal),matcher:t.Opt(s),paginate:t.Opt(o)}),c=t.Record({controllers:t.Vec(t.Principal)}),f=t.Variant({Write:t.Null,Admin:t.Null}),d=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:f,expires_at:t.Opt(t.Nat64)}),h=t.Record({version:t.Opt(t.Nat64)}),B=t.Variant({Db:t.Null,Storage:t.Null}),w=t.Record({version:t.Opt(t.Nat64)}),u=t.Record({cycles:t.Nat,destination_id:t.Principal}),g=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),U=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),F=t.Record({key:g,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,U)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),N=t.Record({derivation_origin:t.Opt(t.Text)}),V=t.Record({internet_identity:t.Opt(N)}),W=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),T=t.Record({max_memory_size:t.Opt(W)}),C=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),z=t.Variant({Deny:t.Null,Allow:t.Null}),D=t.Record({status_code:t.Nat16,location:t.Text}),G=t.Record({iframe:t.Opt(C),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(W),raw_access:t.Opt(z),redirects:t.Opt(t.Vec(t.Tuple(t.Text,D)))}),ne=t.Record({db:t.Opt(T),authentication:t.Opt(V),storage:G}),Q=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),le=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),E=t.Variant({Heap:t.Null,Stable:t.Null}),_=t.Record({memory:E,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),m=t.Variant({Callback:t.Record({token:_,callback:t.Func([],[],["query"])})}),x=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(m),status_code:t.Nat16}),j=t.Record({token:t.Opt(_),body:t.Vec(t.Nat8)}),H=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),X=t.Record({batch_id:t.Nat}),oe=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,F)),items_length:t.Nat64}),ae=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Y=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,Q)),items_length:t.Nat64}),P=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),p=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(E),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:P,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:P}),ee=t.Record({stable:t.Nat64,heap:t.Nat64}),re=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:f,expires_at:t.Opt(t.Nat64)}),de=t.Record({controller:re,controllers:t.Vec(t.Principal)}),J=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),l=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(E),max_size:t.Opt(t.Nat),read:P,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:P}),y=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),b=t.Record({chunk_id:t.Nat});return t.Service({build_version:t.Func([],[t.Text],["query"]),commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,a],[t.Nat64],["query"]),count_collection_assets:t.Func([t.Text],[t.Nat64],["query"]),count_collection_docs:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text,a],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([c],[t.Vec(t.Tuple(t.Principal,d))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,h],[],[]),del_docs:t.Func([t.Text],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,h))],[],[]),del_rule:t.Func([B,t.Text,w],[],[]),deposit_cycles:t.Func([u],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(F)],["query"]),get_auth_config:t.Func([],[t.Opt(V)],["query"]),get_config:t.Func([],[ne],[]),get_db_config:t.Func([],[t.Opt(T)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(Q)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(F)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(Q)))],["query"]),get_storage_config:t.Func([],[G],["query"]),http_request:t.Func([le],[x],["query"]),http_request_streaming_callback:t.Func([_],[j],["query"]),init_asset_upload:t.Func([H],[X],[]),list_assets:t.Func([t.Text,a],[oe],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,d))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,ae))],["query"]),list_docs:t.Func([t.Text,a],[Y],["query"]),list_rules:t.Func([B],[t.Vec(t.Tuple(t.Text,p))],["query"]),memory_size:t.Func([],[ee],["query"]),set_auth_config:t.Func([V],[],[]),set_controllers:t.Func([de],[t.Vec(t.Tuple(t.Principal,d))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([T],[],[]),set_doc:t.Func([t.Text,t.Text,J],[Q],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,J))],[t.Vec(t.Tuple(t.Text,Q))],[]),set_rule:t.Func([B,t.Text,l],[],[]),set_storage_config:t.Func([G],[],[]),upload_asset_chunk:t.Func([y],[b],[]),version:t.Func([],[t.Text],["query"])})};var Ia=Dn(jr(),1);var jp=async({satelliteId:t,idlFactory:e,identity:r,fetch:n,container:i})=>{let o=rt(i)&&i!==!1?i===!0?Qn:i:"https://icp-api.io",a=rt(i),c=await Ia.HttpAgent.create({identity:r,shouldFetchRootKey:a,host:o,...n&&{fetch:n}});return Ia.Actor.createActor(e,{agent:c,canisterId:t})};var kp=({satelliteId:t,container:e})=>{let{satelliteId:r}=Dl({satelliteId:t}),{container:n}=Zl({container:e});if(rt(n)&&n!==!1){let{host:i,protocol:s}=new URL(n===!0?Qn:n);return`${s}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},Dl=({satelliteId:t})=>rt(t)?{satelliteId:t}:_r.getInstance().get()??{satelliteId:void 0},Zl=({container:t})=>rt(t)?{container:t}:_r.getInstance().get()??{container:void 0};var xt=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=Dl({satelliteId:t});Us(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=Zl({container:e});return jp({satelliteId:n,container:i,idlFactory:qp,...r})};var Vp=async({collection:t,key:e,satellite:r})=>{let{get_doc:n}=await xt(r),i=ut(await n(t,e));if(!Le(i))return Es({doc:i,key:e})},Hp=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await xt(e),n=t.map(({collection:o,key:a})=>[o,a]),i=await r(n),s=[];for(let[o,a]of i){let c=ut(a);s.push(rt(c)?await Es({key:o,doc:c}):void 0)}return s},$p=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await xt(r),{key:i}=e,s=await Wl(e),o=await n(t,i,s);return await Es({key:i,doc:o})},Kp=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await xt(e),n=[];for(let{collection:o,doc:a}of t){let{key:c}=a;n.push([o,c,await Wl(a)])}let i=await r(n),s=[];for(let[o,a]of i)s.push(await Es({key:o,doc:a}));return s},Gp=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await xt(r),{key:i}=e;return n(t,i,zl(e))},Yp=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await xt(e),n=t.map(({collection:i,doc:s})=>[i,s.key,zl(s)]);await r(n)},Wp=async({collection:t,filter:e,satellite:r})=>{let{list_docs:n}=await xt(r),{items:i,items_page:s,items_length:o,matches_length:a,matches_pages:c}=await n(t,Ri(e)),f=[];for(let[d,h]of i){let{data:B,owner:w,description:u,version:g,...U}=h;f.push({key:d,description:ut(u),owner:w.toText(),data:await Fp({data:B}),version:ut(g),...U})}return{items:f,items_length:o,items_page:ut(s),matches_length:a,matches_pages:ut(c)}},zp=async({collection:t,filter:e,satellite:r})=>{let{count_docs:n}=await xt(r);return n(t,Ri(e))};var Dp=Dn(jr(),1);var pt=t=>t!==void 0?t:Ua()??new Dp.AnonymousIdentity;var Zp=async({satellite:t,...e})=>{let r=pt(t?.identity);return Vp({...e,satellite:{...t,identity:r}})},l8=async({satellite:t,...e})=>{let r=pt(t?.identity);return Hp({...e,satellite:{...t,identity:r}})},Xp=async({satellite:t,...e})=>{let r=pt(t?.identity);return $p({...e,satellite:{...t,identity:r}})},f8=async({satellite:t,...e})=>{let r=pt(t?.identity);return Kp({...e,satellite:{...t,identity:r}})},d8=async({satellite:t,...e})=>{let r=pt(t?.identity);return Gp({...e,satellite:{...t,identity:r}})},h8=async({satellite:t,...e})=>{let r=pt(t?.identity);return Yp({...e,satellite:{...t,identity:r}})},p8=async({satellite:t,filter:e,...r})=>{let n=pt(t?.identity);return Wp({...r,filter:e??{},satellite:{...t,identity:n}})},y8=async({satellite:t,filter:e,...r})=>{let n=pt(t?.identity);return zp({...r,filter:e??{},satellite:{...t,identity:n}})};var Jp=async t=>{let e=Ua();if(Le(e))throw new Error("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=await Zp({collection:"#user",key:r});return Le(n)?await fE({userId:r,provider:t}):n},fE=async({userId:t,...e})=>Xp({collection:"#user",doc:{key:t,data:e}});var Vr,Xl=async t=>{if(Vr=Vr??await Pa(),!(await Vr?.isAuthenticated()??!1))return;let r=await Jp(t);$r.getInstance().set(r)},dE=async t=>new Promise(async(e,r)=>{Vr=Vr??await Pa();let n=t?.provider??new Ms({});await Vr.login({onSuccess:async()=>{await Xl(n.id),e()},onError:i=>r(i),maxTimeToLive:t?.maxTimeToLive??bf,allowPinAuthentication:t?.allowPin??gf,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),Jl=async()=>{await Vr?.logout(),Vr=void 0,$r.getInstance().reset()},Ua=()=>Vr?.getIdentity(),hE=async()=>(Vr??await Pa()).getIdentity();var Lp=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{Xa({message:"junoSignOutAuthTimer"}),await Jl()};return r.onmessage=async({data:i})=>{let{msg:s,data:o}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":Xa({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},$r.getInstance().subscribe(i=>{if(Le(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var Qp=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},ey=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};var U8=Dn(Nt(),1),pE=t=>t==null,yE=t=>!pE(t),Fa=t=>yE(t)?[t]:[],bE=()=>typeof window<"u",ty=async({asset:{data:t,filename:e,collection:r,headers:n,token:i,fullPath:s,encoding:o,description:a},actor:c,init_asset_upload:f})=>{let{batch_id:d}=await f({collection:r,full_path:s,name:e,token:Fa(i),encoding_type:Fa(o),description:Fa(a)}),h=19e5,B=[],w=bE()?new Blob([await t.arrayBuffer()]):t,u=0n;for(let F=0;F<w.size;F+=h){let N=w.slice(F,F+h);B.push({batchId:d,chunk:N,actor:c,orderId:u}),u++}let g=[];for await(let F of gE({uploadChunks:B}))g=[...g,...F];let U=n.find(([F,N])=>F.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await c.commit_asset_upload({batch_id:d,chunk_ids:g.map(({chunk_id:F})=>F),headers:[...n,...U||[]]})};async function*gE({uploadChunks:t,limit:e=12}){for(let r=0;r<t.length;r=r+e){let n=t.slice(r,r+e);yield await Promise.all(n.map(i=>mE(i)))}}var mE=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:Fa(n)});var ry=async({satellite:t,...e})=>{let r=await xt(t);await ty({actor:r,asset:e,init_asset_upload:async i=>await r.init_asset_upload(i)})},ny=async({collection:t,satellite:e,filter:r})=>{let{list_assets:n}=await xt(e),{items:i,items_length:s,items_page:o,matches_length:a,matches_pages:c}=await n(t,Ri(r));return{items:i.map(([f,d])=>d),items_length:s,items_page:ut(o),matches_length:a,matches_pages:ut(c)}},iy=async({collection:t,satellite:e,filter:r})=>{let{count_assets:n}=await xt(e);return n(t,Ri(r))},sy=async({collection:t,fullPath:e,satellite:r})=>(await xt(r)).del_asset(t,e),oy=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await xt(e),n=t.map(({collection:i,fullPath:s})=>[i,s]);await r(n)},ay=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await xt(r);return ut(await n(t,e))},cy=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await xt(e),n=t.map(({collection:s,fullPath:o})=>[s,o]);return(await r(n)).map(([s,o])=>ut(o))};var uy=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var z8=async t=>ly(t),D8=async t=>ly({filename:t.data.name,...t}),ly=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:s,satellite:o,encoding:a,description:c})=>{let f=pt(o?.identity),d=decodeURI(t),h=i??`/${r}/${d}`,B={...o,identity:f};return await ry({data:e,filename:d,collection:r,token:s,headers:n,fullPath:h,encoding:a,satellite:B,description:c}),{downloadUrl:fy({satellite:B,assetKey:{fullPath:h,token:s}}),fullPath:h,name:d}},Z8=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:pt(e?.identity)},{items:i,...s}=await ny({collection:t,satellite:n,filter:r??{}}),o=i.map(({key:{full_path:a,token:c,name:f,owner:d,description:h},headers:B,encodings:w,created_at:u,updated_at:g})=>{let U=ut(c);return{fullPath:a,description:ut(h),name:f,downloadUrl:fy({satellite:n,assetKey:{fullPath:a,token:U}}),token:U,headers:B,encodings:w.reduce((F,[N,{modified:V,sha256:W,total_length:T}])=>({...F,[N]:{modified:V,sha256:uy(W),total_length:T}}),{}),owner:d.toText(),created_at:u,updated_at:g}});return{items:o,assets:o,...s}},X8=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:pt(e?.identity)};return iy({collection:t,satellite:n,filter:r??{}})},J8=async({collection:t,fullPath:e,satellite:r})=>sy({collection:t,fullPath:e,satellite:{...r,identity:pt(r?.identity)}}),L8=async({assets:t,satellite:e})=>oy({assets:t,satellite:{...e,identity:pt(e?.identity)}}),Q8=async({satellite:t,...e})=>{let r=pt(t?.identity);return ay({...e,satellite:{...t,identity:r}})},eT=async({satellite:t,...e})=>{let r=pt(t?.identity);return cy({...e,satellite:{...t,identity:r}})},fy=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:pt(r?.identity)};return`${kp(n)}${t}${rt(e)?`?token=${e}`:""}`};var _E=t=>{let e=t?.satelliteId??Qp();Us(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??ey();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},cT=async t=>wE(t),wE=async t=>{let e=_E(t);_r.getInstance().set(e),await Xl();let r=e.workers?.auth!==void 0?Lp(e.workers.auth):void 0;return[...r?[r]:[]]},uT=t=>$r.getInstance().subscribe(t);export{Ms as InternetIdentityProvider,xf as NFIDProvider,uT as authSubscribe,X8 as countAssets,y8 as countDocs,J8 as deleteAsset,d8 as deleteDoc,L8 as deleteManyAssets,h8 as deleteManyDocs,fy as downloadUrl,Q8 as getAsset,Zp as getDoc,eT as getManyAssets,l8 as getManyDocs,cT as initJuno,wE as initSatellite,Z8 as listAssets,p8 as listDocs,Xp as setDoc,f8 as setManyDocs,dE as signIn,Jl as signOut,hE as unsafeIdentity,z8 as uploadBlob,D8 as uploadFile};
57
57
  /*! Bundled license information:
58
58
 
59
59
  @noble/hashes/utils.js:
@@ -82,6 +82,9 @@ buffer/index.js:
82
82
  @noble/curves/abstract/weierstrass.js:
83
83
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
84
84
 
85
+ @noble/curves/abstract/bls.js:
86
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
87
+
85
88
  @noble/curves/bls12-381.js:
86
89
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
87
90