@junobuild/analytics 0.0.31 → 0.1.0
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.
- package/dist/browser/canisterStatus-RRYZEM7X.js +2 -0
- package/dist/browser/canisterStatus-RRYZEM7X.js.map +7 -0
- package/dist/browser/chunk-LVWHOONS.js +48 -0
- package/dist/browser/chunk-LVWHOONS.js.map +7 -0
- package/dist/browser/chunk-TEDR2MDT.js +2 -0
- package/dist/browser/chunk-TEDR2MDT.js.map +7 -0
- package/dist/browser/idb.services-DRO55BUZ.js +2 -0
- package/dist/browser/{idb.services-CVJFLYYN.js.map → idb.services-DRO55BUZ.js.map} +1 -1
- package/dist/browser/index.js +17 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/web-vitals-7PFSGNUA.js +2 -0
- package/dist/browser/web-vitals-7PFSGNUA.js.map +7 -0
- package/dist/node/index.mjs +95 -1
- package/dist/node/index.mjs.map +4 -4
- package/dist/workers/analytics.worker.js +16 -16
- package/dist/workers/analytics.worker.js.map +4 -4
- package/package.json +8 -3
- package/dist/browser/idb.services-CVJFLYYN.js +0 -2
- package/dist/browser/web-vitals-BPYNZXGZ.js +0 -2
- package/dist/browser/web-vitals-BPYNZXGZ.js.map +0 -7
package/dist/node/index.mjs
CHANGED
|
@@ -1,9 +1,103 @@
|
|
|
1
1
|
import { createRequire as topLevelCreateRequire } from 'module';
|
|
2
2
|
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
-
var Kt=Object.create;var ge=Object.defineProperty;var Wt=Object.getOwnPropertyDescriptor;var qt=Object.getOwnPropertyNames;var Gt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var $t=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var we=(e,t)=>()=>(e&&(t=e(e=0)),t);var w=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ze=(e,t)=>{for(var n in t)ge(e,n,{get:t[n],enumerable:!0})},Xt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of qt(t))!Jt.call(e,o)&&o!==n&&ge(e,o,{get:()=>t[o],enumerable:!(r=Wt(t,o))||r.enumerable});return e};var zt=(e,t,n)=>(n=e!=null?Kt(Gt(e)):{},Xt(t||!e||!e.__esModule?ge(n,"default",{value:e,enumerable:!0}):n,e));var Qe=w(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.decode=B.encode=void 0;var Q="abcdefghijklmnopqrstuvwxyz234567",N=Object.create(null);for(let e=0;e<Q.length;e++)N[Q[e]]=e;N[0]=N.o;N[1]=N.i;function Yt(e){let t=0,n=0,r="";function o(i){return t<0?n|=i>>-t:n=i<<t&248,t>3?(t-=8,1):(t<4&&(r+=Q[n>>3],t+=5),0)}for(let i=0;i<e.length;)i+=o(e[i]);return r+(t<0?Q[n>>3]:"")}B.encode=Yt;function Zt(e){let t=0,n=0,r=new Uint8Array(e.length*4/3|0),o=0;function i(a){let s=N[a.toLowerCase()];if(s===void 0)throw new Error(`Invalid character: ${JSON.stringify(a)}`);s<<=3,n|=s>>>t,t+=5,t>=8&&(r[o++]=n,t-=8,t>0?n=s<<5-t&255:n=0)}for(let a of e)i(a);return r.slice(0,o)}B.decode=Zt});var et=w(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.getCrc32=void 0;var Qt=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 en(e){let t=new Uint8Array(e),n=-1;for(let r=0;r<t.length;r++){let i=(t[r]^n)&255;n=Qt[i]^n>>>8}return(n^-1)>>>0}ee.getCrc32=en});var _e=w(h=>{"use strict";Object.defineProperty(h,"__esModule",{value:!0});h.isBytes=nt;h.number=te;h.bool=tt;h.bytes=ve;h.hash=rt;h.exists=ot;h.output=it;function te(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function tt(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function nt(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function ve(e,...t){if(!nt(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function rt(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");te(e.outputLen),te(e.blockLen)}function ot(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function it(e,t){ve(e);let n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}var tn={number:te,bool:tt,bytes:ve,hash:rt,exists:ot,output:it};h.default=tn});var at=w(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.crypto=void 0;var _=$t("node:crypto");ne.crypto=_&&typeof _=="object"&&"webcrypto"in _?_.webcrypto:_&&typeof _=="object"&&"randomBytes"in _?_:void 0});var Ee=w(f=>{"use strict";Object.defineProperty(f,"__esModule",{value:!0});f.Hash=f.nextTick=f.byteSwapIfBE=f.byteSwap=f.isLE=f.rotl=f.rotr=f.createView=f.u32=f.u8=void 0;f.isBytes=nn;f.byteSwap32=un;f.bytesToHex=ln;f.hexToBytes=pn;f.asyncLoop=bn;f.utf8ToBytes=ct;f.toBytes=re;f.concatBytes=mn;f.checkOpts=yn;f.wrapConstructor=gn;f.wrapConstructorWithOpts=wn;f.wrapXOFConstructorWithOpts=vn;f.randomBytes=_n;var U=at(),Te=_e();function nn(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}var rn=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);f.u8=rn;var on=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));f.u32=on;var an=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);f.createView=an;var sn=(e,t)=>e<<32-t|e>>>t;f.rotr=sn;var cn=(e,t)=>e<<t|e>>>32-t>>>0;f.rotl=cn;f.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var fn=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;f.byteSwap=fn;f.byteSwapIfBE=f.isLE?e=>e:e=>(0,f.byteSwap)(e);function un(e){for(let t=0;t<e.length;t++)e[t]=(0,f.byteSwap)(e[t])}var dn=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ln(e){(0,Te.bytes)(e);let t="";for(let n=0;n<e.length;n++)t+=dn[e[n]];return t}var v={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function st(e){if(e>=v._0&&e<=v._9)return e-v._0;if(e>=v._A&&e<=v._F)return e-(v._A-10);if(e>=v._a&&e<=v._f)return e-(v._a-10)}function pn(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);let t=e.length,n=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){let a=st(e.charCodeAt(i)),s=st(e.charCodeAt(i+1));if(a===void 0||s===void 0){let c=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}r[o]=a*16+s}return r}var xn=async()=>{};f.nextTick=xn;async function bn(e,t,n){let r=Date.now();for(let o=0;o<e;o++){n(o);let i=Date.now()-r;i>=0&&i<t||(await(0,f.nextTick)(),r+=i)}}function ct(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function re(e){return typeof e=="string"&&(e=ct(e)),(0,Te.bytes)(e),e}function mn(...e){let t=0;for(let r=0;r<e.length;r++){let o=e[r];(0,Te.bytes)(o),t+=o.length}let n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){let i=e[r];n.set(i,o),o+=i.length}return n}var Ie=class{clone(){return this._cloneInto()}};f.Hash=Ie;var hn={}.toString;function yn(e,t){if(t!==void 0&&hn.call(t)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(e,t)}function gn(e){let t=r=>e().update(re(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function wn(e){let t=(r,o)=>e(o).update(re(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function vn(e){let t=(r,o)=>e(o).update(re(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function _n(e=32){if(U.crypto&&typeof U.crypto.getRandomValues=="function")return U.crypto.getRandomValues(new Uint8Array(e));if(U.crypto&&typeof U.crypto.randomBytes=="function")return U.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}});var ft=w(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0});I.HashMD=I.Maj=I.Chi=void 0;var Pe=_e(),W=Ee();function In(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);let o=BigInt(32),i=BigInt(4294967295),a=Number(n>>o&i),s=Number(n&i),c=r?4:0,d=r?0:4;e.setUint32(t+c,a,r),e.setUint32(t+d,s,r)}var Tn=(e,t,n)=>e&t^~e&n;I.Chi=Tn;var En=(e,t,n)=>e&t^e&n^t&n;I.Maj=En;var ke=class extends W.Hash{constructor(t,n,r,o){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,W.createView)(this.buffer)}update(t){(0,Pe.exists)(this);let{view:n,buffer:r,blockLen:o}=this;t=(0,W.toBytes)(t);let i=t.length;for(let a=0;a<i;){let s=Math.min(o-this.pos,i-a);if(s===o){let c=(0,W.createView)(t);for(;o<=i-a;a+=o)this.process(c,a);continue}r.set(t.subarray(a,a+s),this.pos),this.pos+=s,a+=s,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,Pe.exists)(this),(0,Pe.output)(t,this),this.finished=!0;let{buffer:n,view:r,blockLen:o,isLE:i}=this,{pos:a}=this;n[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(r,0),a=0);for(let u=a;u<o;u++)n[u]=0;In(r,o-8,BigInt(this.length*8),i),this.process(r,0);let s=(0,W.createView)(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=c/4,p=this.get();if(d>p.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<d;u++)s.setUint32(4*u,p[u],i)}digest(){let{buffer:t,outputLen:n}=this;this.digestInto(t);let r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:n,buffer:r,length:o,finished:i,destroyed:a,pos:s}=this;return t.length=o,t.pos=s,t.finished=i,t.destroyed=a,o%n&&t.buffer.set(r),t}};I.HashMD=ke});var ut=w(P=>{"use strict";Object.defineProperty(P,"__esModule",{value:!0});P.sha224=P.sha256=P.SHA256=void 0;var Ae=ft(),x=Ee(),Pn=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]),T=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),E=new Uint32Array(64),q=class extends Ae.HashMD{constructor(){super(64,32,8,!1),this.A=T[0]|0,this.B=T[1]|0,this.C=T[2]|0,this.D=T[3]|0,this.E=T[4]|0,this.F=T[5]|0,this.G=T[6]|0,this.H=T[7]|0}get(){let{A:t,B:n,C:r,D:o,E:i,F:a,G:s,H:c}=this;return[t,n,r,o,i,a,s,c]}set(t,n,r,o,i,a,s,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=a|0,this.G=s|0,this.H=c|0}process(t,n){for(let u=0;u<16;u++,n+=4)E[u]=t.getUint32(n,!1);for(let u=16;u<64;u++){let A=E[u-15],S=E[u-2],Ye=(0,x.rotr)(A,7)^(0,x.rotr)(A,18)^A>>>3,ye=(0,x.rotr)(S,17)^(0,x.rotr)(S,19)^S>>>10;E[u]=ye+E[u-7]+Ye+E[u-16]|0}let{A:r,B:o,C:i,D:a,E:s,F:c,G:d,H:p}=this;for(let u=0;u<64;u++){let A=(0,x.rotr)(s,6)^(0,x.rotr)(s,11)^(0,x.rotr)(s,25),S=p+A+(0,Ae.Chi)(s,c,d)+Pn[u]+E[u]|0,ye=((0,x.rotr)(r,2)^(0,x.rotr)(r,13)^(0,x.rotr)(r,22))+(0,Ae.Maj)(r,o,i)|0;p=d,d=c,c=s,s=a+S|0,a=i,i=o,o=r,r=S+ye|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,a=a+this.D|0,s=s+this.E|0,c=c+this.F|0,d=d+this.G|0,p=p+this.H|0,this.set(r,o,i,a,s,c,d,p)}roundClean(){E.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};P.SHA256=q;var Se=class extends q{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}};P.sha256=(0,x.wrapConstructor)(()=>new q);P.sha224=(0,x.wrapConstructor)(()=>new Se)});var dt=w(oe=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});oe.sha224=void 0;var kn=ut();function An(e){return kn.sha224.create().update(new Uint8Array(e)).digest()}oe.sha224=An});var xt=w(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.Principal=y.JSON_KEY_PRINCIPAL=void 0;var lt=Qe(),Sn=et(),Cn=dt();y.JSON_KEY_PRINCIPAL="__principal__";var Ln=2,pt=4,Mn="aaaaa-aa",Nn=e=>{var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(n=>parseInt(n,16)))},Bn=e=>e.reduce((t,n)=>t+n.toString(16).padStart(2,"0"),""),Ce=class e{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([pt]))}static managementCanister(){return this.fromHex(Mn)}static selfAuthenticating(t){let n=(0,Cn.sha224)(t);return new this(new Uint8Array([...n,Ln]))}static from(t){if(typeof t=="string")return e.fromText(t);if(Object.getPrototypeOf(t)===Uint8Array.prototype)return new e(t);if(typeof t=="object"&&t!==null&&t._isPrincipal===!0)return new e(t._arr);throw new Error(`Impossible to convert ${JSON.stringify(t)} to Principal.`)}static fromHex(t){return new this(Nn(t))}static fromText(t){let n=t;if(t.includes(y.JSON_KEY_PRINCIPAL)){let a=JSON.parse(t);y.JSON_KEY_PRINCIPAL in a&&(n=a[y.JSON_KEY_PRINCIPAL])}let r=n.toLowerCase().replace(/-/g,""),o=(0,lt.decode)(r);o=o.slice(4,o.length);let i=new this(o);if(i.toText()!==n)throw new Error(`Principal "${i.toText()}" does not have a valid checksum (original value "${n}" may not be a valid Principal ID).`);return i}static fromUint8Array(t){return new this(t)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===pt}toUint8Array(){return this._arr}toHex(){return Bn(this._arr).toUpperCase()}toText(){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,(0,Sn.getCrc32)(this._arr));let r=new Uint8Array(t),o=Uint8Array.from(this._arr),i=new Uint8Array([...r,...o]),s=(0,lt.encode)(i).match(/.{1,5}/g);if(!s)throw new Error;return s.join("-")}toString(){return this.toText()}toJSON(){return{[y.JSON_KEY_PRINCIPAL]:this.toText()}}compareTo(t){for(let n=0;n<Math.min(this._arr.length,t._arr.length);n++){if(this._arr[n]<t._arr[n])return"lt";if(this._arr[n]>t._arr[n])return"gt"}return this._arr.length<t._arr.length?"lt":this._arr.length>t._arr.length?"gt":"eq"}ltEq(t){let n=this.compareTo(t);return n=="lt"||n=="eq"}gtEq(t){let n=this.compareTo(t);return n=="gt"||n=="eq"}};y.Principal=Ce});var Ct={};Ze(Ct,{CLSThresholds:()=>Oe,FCPThresholds:()=>Ue,FIDThresholds:()=>Fe,INPThresholds:()=>je,LCPThresholds:()=>De,TTFBThresholds:()=>Ve,onCLS:()=>Rn,onFCP:()=>It,onFID:()=>Qn,onINP:()=>Jn,onLCP:()=>$n,onTTFB:()=>zn});var Be,k,X,vt,fe,_t,M,Re,de,b,R,m,He,z,le,F,yt,ue,gt,Fn,Ke,Y,Ue,It,Oe,Rn,Tt,Me,se,Hn,Et,Kn,g,ce,Pt,Wn,qn,Gn,kt,je,Jn,De,Ne,$n,Ve,Xn,zn,$,Yn,wt,At,Zn,St,Fe,Qn,Lt=we(()=>{_t=-1,M=function(e){addEventListener("pageshow",function(t){t.persisted&&(_t=t.timeStamp,e(t))},!0)},Re=function(){var e=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},de=function(){var e=Re();return e&&e.activationStart||0},b=function(e,t){var n=Re(),r="navigate";return _t>=0?r="back-forward-cache":n&&(document.prerendering||de()>0?r="prerender":document.wasDiscarded?r="restore":n.type&&(r=n.type.replace(/_/g,"-"))),{name:e,value:t===void 0?-1:t,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r}},R=function(e,t,n){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var r=new PerformanceObserver(function(o){Promise.resolve().then(function(){t(o.getEntries())})});return r.observe(Object.assign({type:e,buffered:!0},n||{})),r}}catch{}},m=function(e,t,n,r){var o,i;return function(a){t.value>=0&&(a||r)&&((i=t.value-(o||0))||o===void 0)&&(o=t.value,t.delta=i,t.rating=function(s,c){return s>c[1]?"poor":s>c[0]?"needs-improvement":"good"}(t.value,n),e(t))}},He=function(e){requestAnimationFrame(function(){return requestAnimationFrame(function(){return e()})})},z=function(e){document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"&&e()})},le=function(e){var t=!1;return function(){t||(e(),t=!0)}},F=-1,yt=function(){return document.visibilityState!=="hidden"||document.prerendering?1/0:0},ue=function(e){document.visibilityState==="hidden"&&F>-1&&(F=e.type==="visibilitychange"?e.timeStamp:0,Fn())},gt=function(){addEventListener("visibilitychange",ue,!0),addEventListener("prerenderingchange",ue,!0)},Fn=function(){removeEventListener("visibilitychange",ue,!0),removeEventListener("prerenderingchange",ue,!0)},Ke=function(){return F<0&&(F=yt(),gt(),M(function(){setTimeout(function(){F=yt(),gt()},0)})),{get firstHiddenTime(){return F}}},Y=function(e){document.prerendering?addEventListener("prerenderingchange",function(){return e()},!0):e()},Ue=[1800,3e3],It=function(e,t){t=t||{},Y(function(){var n,r=Ke(),o=b("FCP"),i=R("paint",function(a){a.forEach(function(s){s.name==="first-contentful-paint"&&(i.disconnect(),s.startTime<r.firstHiddenTime&&(o.value=Math.max(s.startTime-de(),0),o.entries.push(s),n(!0)))})});i&&(n=m(e,o,Ue,t.reportAllChanges),M(function(a){o=b("FCP"),n=m(e,o,Ue,t.reportAllChanges),He(function(){o.value=performance.now()-a.timeStamp,n(!0)})}))})},Oe=[.1,.25],Rn=function(e,t){t=t||{},It(le(function(){var n,r=b("CLS",0),o=0,i=[],a=function(c){c.forEach(function(d){if(!d.hadRecentInput){var p=i[0],u=i[i.length-1];o&&d.startTime-u.startTime<1e3&&d.startTime-p.startTime<5e3?(o+=d.value,i.push(d)):(o=d.value,i=[d])}}),o>r.value&&(r.value=o,r.entries=i,n())},s=R("layout-shift",a);s&&(n=m(e,r,Oe,t.reportAllChanges),z(function(){a(s.takeRecords()),n(!0)}),M(function(){o=0,r=b("CLS",0),n=m(e,r,Oe,t.reportAllChanges),He(function(){return n()})}),setTimeout(n,0))}))},Tt=0,Me=1/0,se=0,Hn=function(e){e.forEach(function(t){t.interactionId&&(Me=Math.min(Me,t.interactionId),se=Math.max(se,t.interactionId),Tt=se?(se-Me)/7+1:0)})},Et=function(){return Be?Tt:performance.interactionCount||0},Kn=function(){"interactionCount"in performance||Be||(Be=R("event",Hn,{type:"event",buffered:!0,durationThreshold:0}))},g=[],ce=new Map,Pt=0,Wn=function(){var e=Math.min(g.length-1,Math.floor((Et()-Pt)/50));return g[e]},qn=[],Gn=function(e){if(qn.forEach(function(o){return o(e)}),e.interactionId||e.entryType==="first-input"){var t=g[g.length-1],n=ce.get(e.interactionId);if(n||g.length<10||e.duration>t.latency){if(n)e.duration>n.latency?(n.entries=[e],n.latency=e.duration):e.duration===n.latency&&e.startTime===n.entries[0].startTime&&n.entries.push(e);else{var r={id:e.interactionId,latency:e.duration,entries:[e]};ce.set(r.id,r),g.push(r)}g.sort(function(o,i){return i.latency-o.latency}),g.length>10&&g.splice(10).forEach(function(o){return ce.delete(o.id)})}}},kt=function(e){var t=self.requestIdleCallback||self.setTimeout,n=-1;return e=le(e),document.visibilityState==="hidden"?e():(n=t(e),z(e)),n},je=[200,500],Jn=function(e,t){"PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype&&(t=t||{},Y(function(){var n;Kn();var r,o=b("INP"),i=function(s){kt(function(){s.forEach(Gn);var c=Wn();c&&c.latency!==o.value&&(o.value=c.latency,o.entries=c.entries,r())})},a=R("event",i,{durationThreshold:(n=t.durationThreshold)!==null&&n!==void 0?n:40});r=m(e,o,je,t.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),z(function(){i(a.takeRecords()),r(!0)}),M(function(){Pt=Et(),g.length=0,ce.clear(),o=b("INP"),r=m(e,o,je,t.reportAllChanges)}))}))},De=[2500,4e3],Ne={},$n=function(e,t){t=t||{},Y(function(){var n,r=Ke(),o=b("LCP"),i=function(c){t.reportAllChanges||(c=c.slice(-1)),c.forEach(function(d){d.startTime<r.firstHiddenTime&&(o.value=Math.max(d.startTime-de(),0),o.entries=[d],n())})},a=R("largest-contentful-paint",i);if(a){n=m(e,o,De,t.reportAllChanges);var s=le(function(){Ne[o.id]||(i(a.takeRecords()),a.disconnect(),Ne[o.id]=!0,n(!0))});["keydown","click"].forEach(function(c){addEventListener(c,function(){return kt(s)},!0)}),z(s),M(function(c){o=b("LCP"),n=m(e,o,De,t.reportAllChanges),He(function(){o.value=performance.now()-c.timeStamp,Ne[o.id]=!0,n(!0)})})}})},Ve=[800,1800],Xn=function e(t){document.prerendering?Y(function(){return e(t)}):document.readyState!=="complete"?addEventListener("load",function(){return e(t)},!0):setTimeout(t,0)},zn=function(e,t){t=t||{};var n=b("TTFB"),r=m(e,n,Ve,t.reportAllChanges);Xn(function(){var o=Re();o&&(n.value=Math.max(o.responseStart-de(),0),n.entries=[o],r(!0),M(function(){n=b("TTFB",0),(r=m(e,n,Ve,t.reportAllChanges))(!0)}))})},$={passive:!0,capture:!0},Yn=new Date,wt=function(e,t){k||(k=t,X=e,vt=new Date,St(removeEventListener),At())},At=function(){if(X>=0&&X<vt-Yn){var e={entryType:"first-input",name:k.type,target:k.target,cancelable:k.cancelable,startTime:k.timeStamp,processingStart:k.timeStamp+X};fe.forEach(function(t){t(e)}),fe=[]}},Zn=function(e){if(e.cancelable){var t=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;e.type=="pointerdown"?function(n,r){var o=function(){wt(n,r),a()},i=function(){a()},a=function(){removeEventListener("pointerup",o,$),removeEventListener("pointercancel",i,$)};addEventListener("pointerup",o,$),addEventListener("pointercancel",i,$)}(t,e):wt(t,e)}},St=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach(function(t){return e(t,Zn,$)})},Fe=[100,300],Qn=function(e,t){t=t||{},Y(function(){var n,r=Ke(),o=b("FID"),i=function(c){c.startTime<r.firstHiddenTime&&(o.value=c.processingStart-c.startTime,o.entries.push(c),n(!0))},a=function(c){c.forEach(i)},s=R("first-input",a);n=m(e,o,Fe,t.reportAllChanges),s&&(z(le(function(){a(s.takeRecords()),s.disconnect()})),M(function(){var c;o=b("FID"),n=m(e,o,Fe,t.reportAllChanges),fe=[],X=-1,k=null,St(addEventListener),c=i,fe.push(c),At()}))})}});function H(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function Z(e,t){let n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);let r=H(n);return(o,i)=>r.then(a=>i(a.transaction(t,o).objectStore(t)))}function qe(){return We||(We=Z("keyval-store","keyval")),We}function pe(e,t,n=qe()){return n("readwrite",r=>(r.put(t,e),H(r.transaction)))}function xe(e,t=qe()){return t("readwrite",n=>(e.forEach(r=>n.delete(r)),H(n.transaction)))}function er(e,t){return e.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},H(e.transaction)}function be(e=qe()){return e("readonly",t=>{if(t.getAll&&t.getAllKeys)return Promise.all([H(t.getAllKeys()),H(t.getAll())]).then(([r,o])=>r.map((i,a)=>[i,o[a]]));let n=[];return e("readonly",r=>er(r,o=>n.push([o.key,o.value])).then(()=>n))})}var We,Mt=we(()=>{});var me={};Ze(me,{delPageViews:()=>rr,delPerformanceMetrics:()=>fr,delTrackEvents:()=>ar,getPageViews:()=>nr,getPerformanceMetrics:()=>cr,getTrackEvents:()=>ir,setPageView:()=>tr,setPerformanceMetric:()=>sr,setTrackEvent:()=>or});var Ge,Je,$e,tr,nr,rr,or,ir,ar,sr,cr,fr,he=we(()=>{"use strict";Mt();Ge=Z("juno-views","views"),Je=Z("juno-events","events"),$e=Z("juno-metrics","metrics"),tr=({key:e,view:t})=>pe(e,t,Ge),nr=()=>be(Ge),rr=e=>xe(e,Ge),or=({key:e,track:t})=>pe(e,t,Je),ir=()=>be(Je),ar=e=>xe(e,Je),sr=({key:e,view:t})=>pe(e,t,$e),cr=()=>be($e),fr=e=>xe(e,$e)});var Un=zt(xt(),1);var ie=e=>e==null,Le=e=>!ie(e),On=class extends Error{},C=(e,t)=>{if(ie(e))throw new On(t)};var O=e=>Le(e)?[e]:[];var ae=()=>typeof window<"u";import{webcrypto as mt}from"node:crypto";var bt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var jn=128,L,j;function Dn(e){!L||L.length<e?(L=Buffer.allocUnsafe(e*jn),mt.getRandomValues(L),j=0):j+e>L.length&&(mt.getRandomValues(L),j=0),j+=e}function D(e=21){Dn(e|=0);let t="";for(let n=j-e;n<j;n++)t+=bt[L[n]&63];return t}var ht=()=>BigInt(Date.now())*BigInt(1e6);var G=()=>({collected_at:ht(),updated_at:[],version:[]}),J=()=>{let{userAgent:e}=navigator;return{user_agent:O(e)}};var Vn="Analytics worker not initialized. Did you call `initOrbiter`?",V=e=>{ie(e)&&console.warn(Vn)};var Nt=async e=>{let{onCLS:t,onFCP:n,onINP:r,onLCP:o,onTTFB:i}=await Promise.resolve().then(()=>(Lt(),Ct)),a=s=>{(async()=>await ur({...s,sessionId:e}))()};t(a),n(a),r(a),o(a),i(a)},ur=async e=>{let t=dr(e);if(t==="unknown"){console.warn("Performance metric ignored. Unknown metric name.",e);return}if(t==="deprecated")return;await(await Promise.resolve().then(()=>(he(),me))).setPerformanceMetric({key:D(),view:t})},dr=({sessionId:e,name:t,value:n,delta:r,id:o,navigationType:i})=>{let s=(()=>{switch(t){case"CLS":return{CLS:null};case"FCP":return{FCP:null};case"INP":return{INP:null};case"LCP":return{LCP:null};case"TTFB":return{TTFB:null};case"FID":return"deprecated";default:return"unknown"}})();if(s==="unknown"||s==="deprecated")return s;let d={value:n,delta:r,id:o,navigation_type:O((()=>{switch(i){case"navigate":return{Navigate:null};case"restore":return{Restore:null};case"reload":return{Reload:null};case"back-forward":return{BackForward:null};case"back-forward-cache":return{BackForwardCache:null};case"prerender":return{Prerender:null};default:return}})())},{location:{href:p}}=document,{updated_at:u,...A}=G();return{href:p,metric_name:s,session_id:e,data:{WebVitalsMetric:d},...J(),...A}};var lr=()=>{if(!(typeof crypto>"u"))return D()},K=lr(),l,Bt=e=>{let{path:t}=e.worker??{},n=t??"./workers/analytics.worker.js";l=new Worker(n);let r=()=>console.warn("Unable to connect to the analytics web worker. Have you deployed it?");return l?.addEventListener("error",r,!1),xr(e),{cleanup(){l?.removeEventListener("error",r,!1)}}},Ut=()=>{let e=async()=>await jt(),t=new Proxy(history.pushState,{apply:async(n,r,o)=>{n.apply(r,o),await e()}});return history.pushState=t,addEventListener("popstate",e,{passive:!0}),{cleanup(){t=null,removeEventListener("popstate",e,!1)}}},Xe="No session ID initialized.",ze=async()=>{if(!ae())return;C(K,Xe);let{title:e,location:{href:t},referrer:n}=document,{innerWidth:r,innerHeight:o}=window,{timeZone:i}=Intl.DateTimeFormat().resolvedOptions(),a={title:e,href:t,referrer:O(Le(n)&&n!==""?n:void 0),device:{inner_width:r,inner_height:o},time_zone:i,session_id:K,...J(),...G()};await(await Promise.resolve().then(()=>(he(),me))).setPageView({key:D(),view:a})},Ot=async({options:e})=>{ae()&&e?.performance!==!1&&(C(K,Xe),await Nt(K))},jt=async()=>{V(l),await ze(),l?.postMessage({msg:"junoTrackPageView"})},pr=async e=>{if(!ae())return;C(K,Xe),V(l),await(await Promise.resolve().then(()=>(he(),me))).setTrackEvent({key:D(),track:{...e,session_id:K,...J(),...G()}}),l?.postMessage({msg:"junoTrackEvent"})},xr=e=>{V(l),l?.postMessage({msg:"junoInitEnvironment",data:e})},Dt=()=>{V(l),l?.postMessage({msg:"junoStartTrackTimer"})},Vt=()=>{V(l),l?.postMessage({msg:"junoStopTracker"})};var Ft=()=>{let e=()=>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??e():e()},Rt=()=>{let e=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_ORBITER_ID??import.meta.env?.PUBLIC_ORBITER_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_ORBITER_ID??e():e()},Ht=()=>{let e=()=>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??e():e()};var br=e=>{let t=e?.satelliteId??Ft();C(t,"Satellite ID is not configured. Orbiter cannot be initialized without a target Satellite.");let n=e?.orbiterId??Rt();C(n,"Orbiter ID is not configured. The analytics cannot be initialized without an Orbiter.");let r=e?.container??Ht();return{orbiterId:n,satelliteId:t,container:r,worker:e?.worker,options:e?.options}},eo=async e=>{await ze();let t=br(e),{cleanup:n}=Bt(t),{cleanup:r}=Ut();return await Ot(t),Dt(),()=>{Vt(),n(),r()}};export{eo as initOrbiter,pr as trackEvent,jt as trackPageView};
|
|
3
|
+
var Xp=Object.create;var Ra=Object.defineProperty;var Qp=Object.getOwnPropertyDescriptor;var Jp=Object.getOwnPropertyNames;var e1=Object.getPrototypeOf,t1=Object.prototype.hasOwnProperty;var Mn=(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 Pa=(t,e)=>()=>(t&&(e=t(t=0)),e);var re=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ff=(t,e)=>{for(var r in e)Ra(t,r,{get:e[r],enumerable:!0})},r1=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Jp(e))!t1.call(t,i)&&i!==r&&Ra(t,i,{get:()=>e[i],enumerable:!(n=Qp(e,i))||n.enumerable});return t};var qn=(t,e,r)=>(r=t!=null?Xp(e1(t)):{},r1(e||!t||!t.__esModule?Ra(r,"default",{value:t,enumerable:!0}):r,t));var Cf=re(Ss=>{"use strict";Ss.byteLength=i1;Ss.toByteArray=o1;Ss.fromByteArray=u1;var fr=[],Lt=[],n1=typeof Uint8Array<"u"?Uint8Array:Array,Ua="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(bn=0,Mf=Ua.length;bn<Mf;++bn)fr[bn]=Ua[bn],Lt[Ua.charCodeAt(bn)]=bn;var bn,Mf;Lt[45]=62;Lt[95]=63;function qf(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 i1(t){var e=qf(t),r=e[0],n=e[1];return(r+n)*3/4-n}function s1(t,e,r){return(e+r)*3/4-r}function o1(t){var e,r=qf(t),n=r[0],i=r[1],s=new n1(s1(t,n,i)),o=0,c=i>0?n-4:n,a;for(a=0;a<c;a+=4)e=Lt[t.charCodeAt(a)]<<18|Lt[t.charCodeAt(a+1)]<<12|Lt[t.charCodeAt(a+2)]<<6|Lt[t.charCodeAt(a+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=Lt[t.charCodeAt(a)]<<2|Lt[t.charCodeAt(a+1)]>>4,s[o++]=e&255),i===1&&(e=Lt[t.charCodeAt(a)]<<10|Lt[t.charCodeAt(a+1)]<<4|Lt[t.charCodeAt(a+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function a1(t){return fr[t>>18&63]+fr[t>>12&63]+fr[t>>6&63]+fr[t&63]}function c1(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(a1(n));return i.join("")}function u1(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,c=r-n;o<c;o+=s)i.push(c1(t,o,o+s>c?c:o+s));return n===1?(e=t[r-1],i.push(fr[e>>2]+fr[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(fr[e>>10]+fr[e>>4&63]+fr[e<<2&63]+"=")),i.join("")}});var Ma=re(Fa=>{Fa.read=function(t,e,r,n,i){var s,o,c=i*8-n-1,a=(1<<c)-1,l=a>>1,d=-7,b=r?i-1:0,m=r?-1:1,_=t[e+b];for(b+=m,s=_&(1<<-d)-1,_>>=-d,d+=c;d>0;s=s*256+t[e+b],b+=m,d-=8);for(o=s&(1<<-d)-1,s>>=-d,d+=n;d>0;o=o*256+t[e+b],b+=m,d-=8);if(s===0)s=1-l;else{if(s===a)return o?NaN:(_?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-l}return(_?-1:1)*o*Math.pow(2,s-n)};Fa.write=function(t,e,r,n,i,s){var o,c,a,l=s*8-i-1,d=(1<<l)-1,b=d>>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,_=n?0:s-1,f=n?1:-1,S=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,o=d):(o=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-o))<1&&(o--,a*=2),o+b>=1?e+=m/a:e+=m*Math.pow(2,1-b),e*a>=2&&(o++,a/=2),o+b>=d?(c=0,o=d):o+b>=1?(c=(e*a-1)*Math.pow(2,i),o=o+b):(c=e*Math.pow(2,b-1)*Math.pow(2,i),o=0));i>=8;t[r+_]=c&255,_+=f,c/=256,i-=8);for(o=o<<i|c,l+=i;l>0;t[r+_]=o&255,_+=f,o/=256,l-=8);t[r+_-f]|=S*128}});var el=re(Hn=>{"use strict";var qa=Cf(),kn=Ma(),kf=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Hn.Buffer=G;Hn.SlowBuffer=y1;Hn.INSPECT_MAX_BYTES=50;var As=2147483647;Hn.kMaxLength=As;G.TYPED_ARRAY_SUPPORT=f1();!G.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 f1(){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(G.prototype,"parent",{enumerable:!0,get:function(){if(G.isBuffer(this))return this.buffer}});Object.defineProperty(G.prototype,"offset",{enumerable:!0,get:function(){if(G.isBuffer(this))return this.byteOffset}});function Rr(t){if(t>As)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,G.prototype),e}function G(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 Ha(t)}return Vf(t,e,r)}G.poolSize=8192;function Vf(t,e,r){if(typeof t=="string")return d1(t,e);if(ArrayBuffer.isView(t))return h1(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(lr(t,ArrayBuffer)||t&&lr(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(lr(t,SharedArrayBuffer)||t&&lr(t.buffer,SharedArrayBuffer)))return ka(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 G.from(n,e,r);let i=p1(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return G.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)}G.from=function(t,e,r){return Vf(t,e,r)};Object.setPrototypeOf(G.prototype,Uint8Array.prototype);Object.setPrototypeOf(G,Uint8Array);function $f(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 l1(t,e,r){return $f(t),t<=0?Rr(t):e!==void 0?typeof r=="string"?Rr(t).fill(e,r):Rr(t).fill(e):Rr(t)}G.alloc=function(t,e,r){return l1(t,e,r)};function Ha(t){return $f(t),Rr(t<0?0:La(t)|0)}G.allocUnsafe=function(t){return Ha(t)};G.allocUnsafeSlow=function(t){return Ha(t)};function d1(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!G.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=Gf(t,e)|0,n=Rr(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Ca(t){let e=t.length<0?0:La(t.length)|0,r=Rr(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function h1(t){if(lr(t,Uint8Array)){let e=new Uint8Array(t);return ka(e.buffer,e.byteOffset,e.byteLength)}return Ca(t)}function ka(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,G.prototype),n}function p1(t){if(G.isBuffer(t)){let e=La(t.length)|0,r=Rr(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||$a(t.length)?Rr(0):Ca(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Ca(t.data)}function La(t){if(t>=As)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+As.toString(16)+" bytes");return t|0}function y1(t){return+t!=t&&(t=0),G.alloc(+t)}G.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==G.prototype};G.compare=function(e,r){if(lr(e,Uint8Array)&&(e=G.from(e,e.offset,e.byteLength)),lr(r,Uint8Array)&&(r=G.from(r,r.offset,r.byteLength)),!G.isBuffer(e)||!G.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};G.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}};G.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return G.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=G.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(lr(o,Uint8Array))s+o.length>i.length?(G.isBuffer(o)||(o=G.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(G.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function Gf(t,e){if(G.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||lr(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 ja(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Jf(t).length;default:if(i)return n?-1:ja(t).length;e=(""+e).toLowerCase(),i=!0}}G.byteLength=Gf;function b1(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 S1(this,e,r);case"utf8":case"utf-8":return Kf(this,e,r);case"ascii":return B1(this,e,r);case"latin1":case"binary":return T1(this,e,r);case"base64":return x1(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A1(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}G.prototype._isBuffer=!0;function gn(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}G.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)gn(this,r,r+1);return this};G.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)gn(this,r,r+3),gn(this,r+1,r+2);return this};G.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)gn(this,r,r+7),gn(this,r+1,r+6),gn(this,r+2,r+5),gn(this,r+3,r+4);return this};G.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Kf(this,0,e):b1.apply(this,arguments)};G.prototype.toLocaleString=G.prototype.toString;G.prototype.equals=function(e){if(!G.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:G.compare(this,e)===0};G.prototype.inspect=function(){let e="",r=Hn.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};kf&&(G.prototype[kf]=G.prototype.inspect);G.prototype.compare=function(e,r,n,i,s){if(lr(e,Uint8Array)&&(e=G.from(e,e.offset,e.byteLength)),!G.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,c=n-r,a=Math.min(o,c),l=this.slice(i,s),d=e.slice(r,n);for(let b=0;b<a;++b)if(l[b]!==d[b]){o=l[b],c=d[b];break}return o<c?-1:c<o?1:0};function Df(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,$a(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=G.from(e,n)),G.isBuffer(e))return e.length===0?-1:jf(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):jf(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function jf(t,e,r,n,i){let s=1,o=t.length,c=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,c/=2,r/=2}function a(d,b){return s===1?d[b]:d.readUInt16BE(b*s)}let l;if(i){let d=-1;for(l=r;l<o;l++)if(a(t,l)===a(e,d===-1?0:l-d)){if(d===-1&&(d=l),l-d+1===c)return d*s}else d!==-1&&(l-=l-d),d=-1}else for(r+c>o&&(r=o-c),l=r;l>=0;l--){let d=!0;for(let b=0;b<c;b++)if(a(t,l+b)!==a(e,b)){d=!1;break}if(d)return l}return-1}G.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};G.prototype.indexOf=function(e,r,n){return Df(this,e,r,n,!0)};G.prototype.lastIndexOf=function(e,r,n){return Df(this,e,r,n,!1)};function g1(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 c=parseInt(e.substr(o*2,2),16);if($a(c))return o;t[r+o]=c}return o}function m1(t,e,r,n){return Is(ja(e,t.length-r),t,r,n)}function w1(t,e,r,n){return Is(R1(e),t,r,n)}function _1(t,e,r,n){return Is(Jf(e),t,r,n)}function E1(t,e,r,n){return Is(P1(e,t.length-r),t,r,n)}G.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 g1(this,e,r,n);case"utf8":case"utf-8":return m1(this,e,r,n);case"ascii":case"latin1":case"binary":return w1(this,e,r,n);case"base64":return _1(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E1(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};G.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function x1(t,e,r){return e===0&&r===t.length?qa.fromByteArray(t):qa.fromByteArray(t.slice(e,r))}function Kf(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=r){let a,l,d,b;switch(c){case 1:s<128&&(o=s);break;case 2:a=t[i+1],(a&192)===128&&(b=(s&31)<<6|a&63,b>127&&(o=b));break;case 3:a=t[i+1],l=t[i+2],(a&192)===128&&(l&192)===128&&(b=(s&15)<<12|(a&63)<<6|l&63,b>2047&&(b<55296||b>57343)&&(o=b));break;case 4:a=t[i+1],l=t[i+2],d=t[i+3],(a&192)===128&&(l&192)===128&&(d&192)===128&&(b=(s&15)<<18|(a&63)<<12|(l&63)<<6|d&63,b>65535&&b<1114112&&(o=b))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=c}return v1(n)}var Hf=4096;function v1(t){let e=t.length;if(e<=Hf)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Hf));return r}function B1(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 T1(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 S1(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+=U1[t[s]];return i}function A1(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}G.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,G.prototype),i};function nt(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")}G.prototype.readUintLE=G.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||nt(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};G.prototype.readUintBE=G.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||nt(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};G.prototype.readUint8=G.prototype.readUInt8=function(e,r){return e=e>>>0,r||nt(e,1,this.length),this[e]};G.prototype.readUint16LE=G.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||nt(e,2,this.length),this[e]|this[e+1]<<8};G.prototype.readUint16BE=G.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||nt(e,2,this.length),this[e]<<8|this[e+1]};G.prototype.readUint32LE=G.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||nt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};G.prototype.readUint32BE=G.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||nt(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};G.prototype.readBigUInt64LE=Lr(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))});G.prototype.readBigUInt64BE=Lr(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)});G.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||nt(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};G.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||nt(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};G.prototype.readInt8=function(e,r){return e=e>>>0,r||nt(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};G.prototype.readInt16LE=function(e,r){e=e>>>0,r||nt(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};G.prototype.readInt16BE=function(e,r){e=e>>>0,r||nt(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};G.prototype.readInt32LE=function(e,r){return e=e>>>0,r||nt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};G.prototype.readInt32BE=function(e,r){return e=e>>>0,r||nt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};G.prototype.readBigInt64LE=Lr(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)});G.prototype.readBigInt64BE=Lr(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)});G.prototype.readFloatLE=function(e,r){return e=e>>>0,r||nt(e,4,this.length),kn.read(this,e,!0,23,4)};G.prototype.readFloatBE=function(e,r){return e=e>>>0,r||nt(e,4,this.length),kn.read(this,e,!1,23,4)};G.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||nt(e,8,this.length),kn.read(this,e,!0,52,8)};G.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||nt(e,8,this.length),kn.read(this,e,!1,52,8)};function At(t,e,r,n,i,s){if(!G.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")}G.prototype.writeUintLE=G.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;At(this,e,r,n,c,0)}let s=1,o=0;for(this[r]=e&255;++o<n&&(s*=256);)this[r+o]=e/s&255;return r+n};G.prototype.writeUintBE=G.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;At(this,e,r,n,c,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};G.prototype.writeUint8=G.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||At(this,e,r,1,255,0),this[r]=e&255,r+1};G.prototype.writeUint16LE=G.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||At(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};G.prototype.writeUint16BE=G.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||At(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};G.prototype.writeUint32LE=G.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||At(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};G.prototype.writeUint32BE=G.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||At(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 zf(t,e,r,n,i){Qf(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 Wf(t,e,r,n,i){Qf(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}G.prototype.writeBigUInt64LE=Lr(function(e,r=0){return zf(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});G.prototype.writeBigUInt64BE=Lr(function(e,r=0){return Wf(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});G.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let a=Math.pow(2,8*n-1);At(this,e,r,n,a-1,-a)}let s=0,o=1,c=0;for(this[r]=e&255;++s<n&&(o*=256);)e<0&&c===0&&this[r+s-1]!==0&&(c=1),this[r+s]=(e/o>>0)-c&255;return r+n};G.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let a=Math.pow(2,8*n-1);At(this,e,r,n,a-1,-a)}let s=n-1,o=1,c=0;for(this[r+s]=e&255;--s>=0&&(o*=256);)e<0&&c===0&&this[r+s+1]!==0&&(c=1),this[r+s]=(e/o>>0)-c&255;return r+n};G.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||At(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};G.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||At(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};G.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||At(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};G.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||At(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};G.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||At(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};G.prototype.writeBigInt64LE=Lr(function(e,r=0){return zf(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});G.prototype.writeBigInt64BE=Lr(function(e,r=0){return Wf(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Yf(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 Zf(t,e,r,n,i){return e=+e,r=r>>>0,i||Yf(t,e,r,4,34028234663852886e22,-34028234663852886e22),kn.write(t,e,r,n,23,4),r+4}G.prototype.writeFloatLE=function(e,r,n){return Zf(this,e,r,!0,n)};G.prototype.writeFloatBE=function(e,r,n){return Zf(this,e,r,!1,n)};function Xf(t,e,r,n,i){return e=+e,r=r>>>0,i||Yf(t,e,r,8,17976931348623157e292,-17976931348623157e292),kn.write(t,e,r,n,52,8),r+8}G.prototype.writeDoubleLE=function(e,r,n){return Xf(this,e,r,!0,n)};G.prototype.writeDoubleBE=function(e,r,n){return Xf(this,e,r,!1,n)};G.prototype.copy=function(e,r,n,i){if(!G.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};G.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"&&!G.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=G.isBuffer(e)?e:G.from(e,i),c=o.length;if(c===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%c]}return this};var Cn={};function Va(t,e,r){Cn[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}`}}}Va("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Va("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Va("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=Lf(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Lf(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Lf(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 I1(t,e,r){jn(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Bi(e,t.length-(r+1))}function Qf(t,e,r,n,i,s){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",c;throw s>3?e===0||e===BigInt(0)?c=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:c=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:c=`>= ${e}${o} and <= ${r}${o}`,new Cn.ERR_OUT_OF_RANGE("value",c,t)}I1(n,i,s)}function jn(t,e){if(typeof t!="number")throw new Cn.ERR_INVALID_ARG_TYPE(e,"number",t)}function Bi(t,e,r){throw Math.floor(t)!==t?(jn(t,r),new Cn.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new Cn.ERR_BUFFER_OUT_OF_BOUNDS:new Cn.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var N1=/[^+/0-9A-Za-z-_]/g;function O1(t){if(t=t.split("=")[0],t=t.trim().replace(N1,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function ja(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 R1(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function P1(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 Jf(t){return qa.toByteArray(O1(t))}function Is(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 lr(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function $a(t){return t!==t}var U1=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 Lr(t){return typeof BigInt>"u"?F1:t}function F1(){throw new Error("BigInt not supported")}});var Ga=re(Ti=>{"use strict";Object.defineProperty(Ti,"__esModule",{value:!0});Ti.ReplicaRejectCode=void 0;var M1;(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"})(M1=Ti.ReplicaRejectCode||(Ti.ReplicaRejectCode={}))});var tl=re(Vn=>{"use strict";Object.defineProperty(Vn,"__esModule",{value:!0});Vn.decode=Vn.encode=void 0;var Ns="abcdefghijklmnopqrstuvwxyz234567",Ln=Object.create(null);for(let t=0;t<Ns.length;t++)Ln[Ns[t]]=t;Ln[0]=Ln.o;Ln[1]=Ln.i;function q1(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+=Ns[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?Ns[r>>3]:"")}Vn.encode=q1;function C1(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let c=Ln[o.toLowerCase()];if(c===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);c<<=3,r|=c>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=c<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}Vn.decode=C1});var rl=re(Os=>{"use strict";Object.defineProperty(Os,"__esModule",{value:!0});Os.getCrc32=void 0;var k1=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 j1(t){let e=new Uint8Array(t),r=-1;for(let n=0;n<e.length;n++){let s=(e[n]^r)&255;r=k1[s]^r>>>8}return(r^-1)>>>0}Os.getCrc32=j1});var Ka=re(dr=>{"use strict";Object.defineProperty(dr,"__esModule",{value:!0});dr.isBytes=il;dr.number=Rs;dr.bool=nl;dr.bytes=Da;dr.hash=sl;dr.exists=ol;dr.output=al;function Rs(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function nl(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function il(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Da(t,...e){if(!il(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}`)}function sl(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Rs(t.outputLen),Rs(t.blockLen)}function ol(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")}function al(t,e){Da(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var H1={number:Rs,bool:nl,bytes:Da,hash:sl,exists:ol,output:al};dr.default=H1});var cl=re(Ps=>{"use strict";Object.defineProperty(Ps,"__esModule",{value:!0});Ps.crypto=void 0;var Vr=Mn("node:crypto");Ps.crypto=Vr&&typeof Vr=="object"&&"webcrypto"in Vr?Vr.webcrypto:Vr&&typeof Vr=="object"&&"randomBytes"in Vr?Vr:void 0});var Gn=re(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.Hash=_e.nextTick=_e.byteSwapIfBE=_e.byteSwap=_e.isLE=_e.rotl=_e.rotr=_e.createView=_e.u32=_e.u8=void 0;_e.isBytes=L1;_e.byteSwap32=W1;_e.bytesToHex=Z1;_e.hexToBytes=X1;_e.asyncLoop=J1;_e.utf8ToBytes=fl;_e.toBytes=Us;_e.concatBytes=ey;_e.checkOpts=ry;_e.wrapConstructor=ny;_e.wrapConstructorWithOpts=iy;_e.wrapXOFConstructorWithOpts=sy;_e.randomBytes=oy;var $n=cl(),Wa=Ka();function L1(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var V1=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);_e.u8=V1;var $1=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));_e.u32=$1;var G1=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);_e.createView=G1;var D1=(t,e)=>t<<32-e|t>>>e;_e.rotr=D1;var K1=(t,e)=>t<<e|t>>>32-e>>>0;_e.rotl=K1;_e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var z1=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;_e.byteSwap=z1;_e.byteSwapIfBE=_e.isLE?t=>t:t=>(0,_e.byteSwap)(t);function W1(t){for(let e=0;e<t.length;e++)t[e]=(0,_e.byteSwap)(t[e])}var Y1=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Z1(t){(0,Wa.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=Y1[t[r]];return e}var Pr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function ul(t){if(t>=Pr._0&&t<=Pr._9)return t-Pr._0;if(t>=Pr._A&&t<=Pr._F)return t-(Pr._A-10);if(t>=Pr._a&&t<=Pr._f)return t-(Pr._a-10)}function X1(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=ul(t.charCodeAt(s)),c=ul(t.charCodeAt(s+1));if(o===void 0||c===void 0){let a=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[i]=o*16+c}return n}var Q1=async()=>{};_e.nextTick=Q1;async function J1(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,_e.nextTick)(),n+=s)}}function fl(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Us(t){return typeof t=="string"&&(t=fl(t)),(0,Wa.bytes)(t),t}function ey(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];(0,Wa.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}var za=class{clone(){return this._cloneInto()}};_e.Hash=za;var ty={}.toString;function ry(t,e){if(e!==void 0&&ty.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function ny(t){let e=n=>t().update(Us(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function iy(t){let e=(n,i)=>t(i).update(Us(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}function sy(t){let e=(n,i)=>t(i).update(Us(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}function oy(t=32){if($n.crypto&&typeof $n.crypto.getRandomValues=="function")return $n.crypto.getRandomValues(new Uint8Array(t));if($n.crypto&&typeof $n.crypto.randomBytes=="function")return $n.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}});var Xa=re($r=>{"use strict";Object.defineProperty($r,"__esModule",{value:!0});$r.HashMD=$r.Maj=$r.Chi=void 0;var Ya=Ka(),Si=Gn();function ay(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),c=Number(r&s),a=n?4:0,l=n?0:4;t.setUint32(e+a,o,n),t.setUint32(e+l,c,n)}var cy=(t,e,r)=>t&e^~t&r;$r.Chi=cy;var uy=(t,e,r)=>t&e^t&r^e&r;$r.Maj=uy;var Za=class extends Si.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,Si.createView)(this.buffer)}update(e){(0,Ya.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,Si.toBytes)(e);let s=e.length;for(let o=0;o<s;){let c=Math.min(i-this.pos,s-o);if(c===i){let a=(0,Si.createView)(e);for(;i<=s-o;o+=i)this.process(a,o);continue}n.set(e.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,Ya.exists)(this),(0,Ya.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 b=o;b<i;b++)r[b]=0;ay(n,i-8,BigInt(this.length*8),s),this.process(n,0);let c=(0,Si.createView)(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=a/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let b=0;b<l;b++)c.setUint32(4*b,d[b],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:c}=this;return e.length=i,e.pos=c,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}};$r.HashMD=Za});var Fs=re(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Kr.sha224=Kr.sha256=Kr.SHA256=void 0;var Qa=Xa(),Vt=Gn(),fy=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]),Gr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Dr=new Uint32Array(64),Ai=class extends Qa.HashMD{constructor(){super(64,32,8,!1),this.A=Gr[0]|0,this.B=Gr[1]|0,this.C=Gr[2]|0,this.D=Gr[3]|0,this.E=Gr[4]|0,this.F=Gr[5]|0,this.G=Gr[6]|0,this.H=Gr[7]|0}get(){let{A:e,B:r,C:n,D:i,E:s,F:o,G:c,H:a}=this;return[e,r,n,i,s,o,c,a]}set(e,r,n,i,s,o,c,a){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=c|0,this.H=a|0}process(e,r){for(let b=0;b<16;b++,r+=4)Dr[b]=e.getUint32(r,!1);for(let b=16;b<64;b++){let m=Dr[b-15],_=Dr[b-2],f=(0,Vt.rotr)(m,7)^(0,Vt.rotr)(m,18)^m>>>3,S=(0,Vt.rotr)(_,17)^(0,Vt.rotr)(_,19)^_>>>10;Dr[b]=S+Dr[b-7]+f+Dr[b-16]|0}let{A:n,B:i,C:s,D:o,E:c,F:a,G:l,H:d}=this;for(let b=0;b<64;b++){let m=(0,Vt.rotr)(c,6)^(0,Vt.rotr)(c,11)^(0,Vt.rotr)(c,25),_=d+m+(0,Qa.Chi)(c,a,l)+fy[b]+Dr[b]|0,S=((0,Vt.rotr)(n,2)^(0,Vt.rotr)(n,13)^(0,Vt.rotr)(n,22))+(0,Qa.Maj)(n,i,s)|0;d=l,l=a,a=c,c=o+_|0,o=s,s=i,i=n,n=_+S|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,c=c+this.E|0,a=a+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(n,i,s,o,c,a,l,d)}roundClean(){Dr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};Kr.SHA256=Ai;var Ja=class extends Ai{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}};Kr.sha256=(0,Vt.wrapConstructor)(()=>new Ai);Kr.sha224=(0,Vt.wrapConstructor)(()=>new Ja)});var ll=re(Ms=>{"use strict";Object.defineProperty(Ms,"__esModule",{value:!0});Ms.sha224=void 0;var ly=Fs();function dy(t){return ly.sha224.create().update(new Uint8Array(t)).digest()}Ms.sha224=dy});var $t=re(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.Principal=hr.JSON_KEY_PRINCIPAL=void 0;var dl=tl(),hy=rl(),py=ll();hr.JSON_KEY_PRINCIPAL="__principal__";var yy=2,hl=4,by="aaaaa-aa",gy=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},my=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),ec=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([hl]))}static managementCanister(){return this.fromHex(by)}static selfAuthenticating(e){let r=(0,py.sha224)(e);return new this(new Uint8Array([...r,yy]))}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(gy(e))}static fromText(e){let r=e;if(e.includes(hr.JSON_KEY_PRINCIPAL)){let o=JSON.parse(e);hr.JSON_KEY_PRINCIPAL in o&&(r=o[hr.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,dl.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]===hl}toUint8Array(){return this._arr}toHex(){return my(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,(0,hy.getCrc32)(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),c=(0,dl.encode)(s).match(/.{1,5}/g);if(!c)throw new Error;return c.join("-")}toString(){return this.toText()}toJSON(){return{[hr.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"}};hr.Principal=ec});var It=re(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.bufFromBufLike=ht.uint8ToBuf=ht.bufEquals=ht.compare=ht.fromHex=ht.toHex=ht.concat=void 0;function wy(...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}ht.concat=wy;function _y(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}ht.toHex=_y;var Ey=new RegExp(/^[0-9a-fA-F]+$/);function xy(t){if(!Ey.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}ht.fromHex=xy;function pl(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}ht.compare=pl;function vy(t,e){return pl(t,e)===0}ht.bufEquals=vy;function qs(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}ht.uint8ToBuf=qs;function yl(t){return t instanceof Uint8Array?qs(t):t instanceof ArrayBuffer?t:Array.isArray(t)?qs(new Uint8Array(t)):"buffer"in t?yl(t.buffer):qs(new Uint8Array(t))}ht.bufFromBufLike=yl});var Dn=re(pr=>{"use strict";Object.defineProperty(pr,"__esModule",{value:!0});pr.UpdateCallRejectedError=pr.QueryCallRejectedError=pr.ActorCallError=pr.AgentError=void 0;var nc=$t(),By=Ga(),Ty=It(),Cs=class t extends Error{constructor(e){super(e),this.message=e,this.name="AgentError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};pr.AgentError=Cs;var Ii=class t extends Cs{constructor(e,r,n,i){let s=nc.Principal.from(e);super(["Call failed:",` Canister: ${s.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(o=>` "${o}": ${JSON.stringify(i[o])}`)].join(`
|
|
4
|
+
`)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i,this.name="ActorCallError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};pr.ActorCallError=Ii;var tc=class t extends Ii{constructor(e,r,n){var i;let s=nc.Principal.from(e);super(s,r,"query",{Status:n.status,Code:(i=By.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n,this.name="QueryCallRejectedError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};pr.QueryCallRejectedError=tc;var rc=class t extends Ii{constructor(e,r,n,i){let s=nc.Principal.from(e);super(s,r,"update",Object.assign({"Request ID":(0,Ty.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,this.name="UpdateCallRejectedError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};pr.UpdateCallRejectedError=rc});var Hs=re(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.bufFromBufLike=Nt.uint8ToBuf=Nt.PipeArrayBuffer=Nt.fromHexString=Nt.toHexString=Nt.concat=void 0;function Sy(...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}Nt.concat=Sy;function Ay(t){return new Uint8Array(t).reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}Nt.toHexString=Ay;function Iy(t){var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))}Nt.fromHexString=Iy;var ic=class{constructor(e,r=e?.byteLength||0){this._buffer=js(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return js(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}};Nt.PipeArrayBuffer=ic;function ks(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}Nt.uint8ToBuf=ks;function js(t){return t instanceof Uint8Array?ks(t):t instanceof ArrayBuffer?t:Array.isArray(t)?ks(new Uint8Array(t)):"buffer"in t?js(t.buffer):ks(new Uint8Array(t))}Nt.bufFromBufLike=js});var sc=re(Ls=>{"use strict";Object.defineProperty(Ls,"__esModule",{value:!0});Ls.idlLabelToId=void 0;function Ny(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function Oy(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 Ny(t)}Ls.idlLabelToId=Oy});var ac=re(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.readIntLE=We.readUIntLE=We.writeIntLE=We.writeUIntLE=We.slebDecode=We.slebEncode=We.lebDecode=We.lebEncode=We.safeReadUint8=We.safeRead=void 0;var oc=Hs();function bl(){throw new Error("unexpected end of buffer")}function gl(t,e){return t.byteLength<e&&bl(),t.read(e)}We.safeRead=gl;function Vs(t){let e=t.readUint8();return e===void 0&&bl(),e}We.safeReadUint8=Vs;function Ry(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 oc.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}We.lebEncode=Ry;function ml(t){let e=BigInt(1),r=BigInt(0),n;do n=Vs(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}We.lebDecode=ml;function Py(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 oc.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}We.slebEncode=Py;function Uy(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if(!(e[r]&64))return ml(t);break}let n=new Uint8Array(gl(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)}We.slebDecode=Uy;function Fy(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return wl(t,e)}We.writeUIntLE=Fy;function wl(t,e){t=BigInt(t);let r=new oc.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}We.writeIntLE=wl;function _l(t,e){let r=BigInt(Vs(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(Vs(t));r=r+n*s}return r}We.readUIntLE=_l;function My(t,e){let r=_l(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}We.readIntLE=My});var El=re(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});Kn.iexp2=Kn.ilog2=void 0;function qy(t){let e=BigInt(t);if(t<=0)throw new RangeError("Input must be positive");return e.toString(2).length-1}Kn.ilog2=qy;function Cy(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}Kn.iexp2=Cy});var dc=re(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.Variant=D.Record=D.Opt=D.Vec=D.Tuple=D.Principal=D.Nat64=D.Nat32=D.Nat16=D.Nat8=D.Int64=D.Int32=D.Int16=D.Int8=D.Float64=D.Float32=D.Nat=D.Int=D.Text=D.Null=D.Bool=D.Unknown=D.Reserved=D.Empty=D.decode=D.encode=D.ServiceClass=D.FuncClass=D.PrincipalClass=D.RecClass=D.VariantClass=D.TupleClass=D.RecordClass=D.OptClass=D.VecClass=D.FixedNatClass=D.FixedIntClass=D.FloatClass=D.NatClass=D.IntClass=D.TextClass=D.ReservedClass=D.NullClass=D.BoolClass=D.UnknownClass=D.EmptyClass=D.ConstructType=D.PrimitiveType=D.Type=D.Visitor=void 0;D.Service=D.Func=D.Rec=void 0;var ky=$t(),Ne=Hs(),yr=sc(),ne=ac(),cc=El(),$s="DIDL",xl=400;function Ni(t,e,r){return t.map((n,i)=>r(n,e[i]))}var uc=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,ne.lebEncode)(this._typs.length),r=(0,Ne.concat)(...this._typs);return(0,Ne.concat)(e,r)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return(0,ne.slebEncode)(this._idx.get(e)||0)}},fc=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)}};D.Visitor=fc;var zn=class{display(){return this.name}valueToString(e){return Ze(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}};D.Type=zn;var Ot=class extends zn{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){}};D.PrimitiveType=Ot;var gr=class extends zn{checkType(e){if(e instanceof zr){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)}};D.ConstructType=gr;var Gs=class extends Ot{accept(e,r){return e.visitEmpty(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Ze(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,ne.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};D.EmptyClass=Gs;var Ds=class extends zn{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: ${Ze(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 zr?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"}};D.UnknownClass=Ds;var Ks=class extends Ot{accept(e,r){return e.visitBool(this,r)}covariant(e){if(typeof e=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${Ze(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return(0,ne.slebEncode)(-2)}decodeValue(e,r){switch(this.checkType(r),(0,ne.safeReadUint8)(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};D.BoolClass=Ks;var zs=class extends Ot{accept(e,r){return e.visitNull(this,r)}covariant(e){if(e===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ze(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ne.slebEncode)(-1)}decodeValue(e,r){return this.checkType(r),null}get name(){return"null"}};D.NullClass=zs;var Wn=class extends Ot{accept(e,r){return e.visitReserved(this,r)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ne.slebEncode)(-16)}decodeValue(e,r){return r.name!==this.name&&r.decodeValue(e,r),null}get name(){return"reserved"}};D.ReservedClass=Wn;var Ws=class extends Ot{accept(e,r){return e.visitText(this,r)}covariant(e){if(typeof e=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Ze(e)}`)}encodeValue(e){let r=new TextEncoder().encode(e),n=(0,ne.lebEncode)(r.byteLength);return(0,Ne.concat)(n,r)}encodeType(){return(0,ne.slebEncode)(-15)}decodeValue(e,r){this.checkType(r);let n=(0,ne.lebDecode)(e),i=(0,ne.safeRead)(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}};D.TextClass=Ws;var Ys=class extends Ot{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: ${Ze(e)}`)}encodeValue(e){return(0,ne.slebEncode)(e)}encodeType(){return(0,ne.slebEncode)(-4)}decodeValue(e,r){return this.checkType(r),(0,ne.slebDecode)(e)}get name(){return"int"}valueToString(e){return e.toString()}};D.IntClass=Ys;var Zs=class extends Ot{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: ${Ze(e)}`)}encodeValue(e){return(0,ne.lebEncode)(e)}encodeType(){return(0,ne.slebEncode)(-3)}decodeValue(e,r){return this.checkType(r),(0,ne.lebDecode)(e)}get name(){return"nat"}valueToString(e){return e.toString()}};D.NatClass=Zs;var Oi=class extends Ot{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: ${Ze(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,ne.slebEncode)(e)}decodeValue(e,r){this.checkType(r);let n=(0,ne.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()}};D.FloatClass=Oi;var Ur=class extends Ot{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=(0,cc.iexp2)(this._bits-1)*BigInt(-1),n=(0,cc.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: ${Ze(e)}`)}encodeValue(e){return(0,ne.writeIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,ne.slebEncode)(-9-e)}decodeValue(e,r){this.checkType(r);let n=(0,ne.readIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}};D.FixedIntClass=Ur;var br=class extends Ot{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=(0,cc.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: ${Ze(e)}`)}encodeValue(e){return(0,ne.writeUIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,ne.slebEncode)(-5-e)}decodeValue(e,r){this.checkType(r);let n=(0,ne.readUIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}};D.FixedNatClass=br;var Xs=class t extends gr{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof br&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof br?this._type._bits:this._type instanceof Ur?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:
|
|
5
|
+
|
|
6
|
+
index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ze(e)}`)}encodeValue(e){let r=(0,ne.lebEncode)(e.length);if(this._blobOptimization)return(0,Ne.concat)(r,new Uint8Array(e));if(ArrayBuffer.isView(e))return(0,Ne.concat)(r,new Uint8Array(e.buffer));let n=new Ne.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,ne.slebEncode)(-19),n=this._type.encodeType(e);e.add(this,(0,Ne.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,ne.lebDecode)(e));if(this._type instanceof br){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 Ur){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("; ")+"}"}};D.VecClass=Xs;var Yn=class t extends gr{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: ${Ze(e)}
|
|
7
|
+
|
|
8
|
+
-> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${Ze(e)}`)}encodeValue(e){return e.length===0?new Uint8Array([0]):(0,Ne.concat)(new Uint8Array([1]),this._type.encodeValue(e[0]))}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=(0,ne.slebEncode)(-18),n=this._type.encodeType(e);e.add(this,(0,Ne.concat)(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not an option type");switch((0,ne.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])}`}};D.OptClass=Yn;var Ri=class t extends gr{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,yr.idlLabelToId)(r[0])-(0,yr.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:
|
|
9
|
+
|
|
10
|
+
field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ze(e)}`)}encodeValue(e){let r=this._fields.map(([i])=>e[i]),n=Ni(this._fields,r,([,i],s)=>i.encodeValue(s));return(0,Ne.concat)(...n)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,ne.slebEncode)(-20),n=(0,ne.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Ne.concat)((0,ne.lebEncode)((0,yr.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Ne.concat)(r,n,(0,Ne.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[c,a]=n._fields[o];if(s>=this._fields.length){a.decodeValue(e,a),o++;continue}let[l,d]=this._fields[s],b=(0,yr.idlLabelToId)(this._fields[s][0]),m=(0,yr.idlLabelToId)(c);if(b===m)i[l]=d.decodeValue(e,a),s++,o++;else if(m>b)if(d instanceof Yn||d instanceof Wn)i[l]=[],s++;else throw new Error("Cannot find required field "+l);else a.decodeValue(e,a),o++}for(let[c,a]of this._fields.slice(s))if(a instanceof Yn||a instanceof Wn)i[c]=[];else throw new Error("Cannot find required field "+c);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 {${Ni(this._fields,r,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}};D.RecordClass=Ri;var Qs=class t extends Ri{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:
|
|
11
|
+
|
|
12
|
+
index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ze(e)}`)}encodeValue(e){let r=Ni(this._components,e,(n,i)=>n.encodeValue(i));return(0,Ne.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 {${Ni(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}};D.TupleClass=Qs;var Js=class t extends gr{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,yr.idlLabelToId)(r[0])-(0,yr.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:
|
|
13
|
+
|
|
14
|
+
variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ze(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,ne.lebEncode)(r),o=i.encodeValue(e[n]);return(0,Ne.concat)(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let r=(0,ne.slebEncode)(-21),n=(0,ne.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Ne.concat)((0,ne.lebEncode)((0,yr.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Ne.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,ne.lebDecode)(e));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,o]=n._fields[i];for(let[c,a]of this._fields)if((0,yr.idlLabelToId)(s)===(0,yr.idlLabelToId)(c)){let l=a.decodeValue(e,o);return{[c]:l}}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)}};D.VariantClass=Js;var zr=class t extends gr{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: ${Ze(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)}};D.RecClass=zr;zr._counter=0;function lc(t){if((0,ne.safeReadUint8)(t)!==1)throw new Error("Cannot decode principal");let r=Number((0,ne.lebDecode)(t));return ky.Principal.fromUint8Array(new Uint8Array((0,ne.safeRead)(t,r)))}var eo=class extends Ot{accept(e,r){return e.visitPrincipal(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ze(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=(0,ne.lebEncode)(r.byteLength);return(0,Ne.concat)(new Uint8Array([1]),n,r)}encodeType(){return(0,ne.slebEncode)(-24)}decodeValue(e,r){return this.checkType(r),lc(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}};D.PrincipalClass=eo;var Pi=class extends gr{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: ${Ze(e)}`)}encodeValue([e,r]){let n=e.toUint8Array(),i=(0,ne.lebEncode)(n.byteLength),s=(0,Ne.concat)(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),c=(0,ne.lebEncode)(o.byteLength);return(0,Ne.concat)(new Uint8Array([1]),s,c,o)}_buildTypeTableImpl(e){this.argTypes.forEach(l=>l.buildTypeTable(e)),this.retTypes.forEach(l=>l.buildTypeTable(e));let r=(0,ne.slebEncode)(-22),n=(0,ne.lebEncode)(this.argTypes.length),i=(0,Ne.concat)(...this.argTypes.map(l=>l.encodeType(e))),s=(0,ne.lebEncode)(this.retTypes.length),o=(0,Ne.concat)(...this.retTypes.map(l=>l.encodeType(e))),c=(0,ne.lebEncode)(this.annotations.length),a=(0,Ne.concat)(...this.annotations.map(l=>this.encodeAnnotation(l)));e.add(this,(0,Ne.concat)(r,n,i,s,o,c,a))}decodeValue(e){if((0,ne.safeReadUint8)(e)!==1)throw new Error("Cannot decode function reference");let n=lc(e),i=Number((0,ne.lebDecode)(e)),s=(0,ne.safeRead)(e,i),c=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,c]}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")}};D.FuncClass=Pi;var to=class extends gr{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: ${Ze(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=(0,ne.lebEncode)(r.length);return(0,Ne.concat)(new Uint8Array([1]),n,r)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,ne.slebEncode)(-23),n=(0,ne.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>{let c=new TextEncoder().encode(s),a=(0,ne.lebEncode)(c.length);return(0,Ne.concat)(a,c,o.encodeType(e))});e.add(this,(0,Ne.concat)(r,n,...i))}decodeValue(e){return lc(e)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};D.ServiceClass=to;function Ze(t){let e=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>xl?e.substring(0,xl-3)+"...":e}function jy(t,e){if(e.length<t.length)throw Error("Wrong number of message arguments");let r=new uc;t.forEach(a=>a.buildTypeTable(r));let n=new TextEncoder().encode($s),i=r.encode(),s=(0,ne.lebEncode)(e.length),o=(0,Ne.concat)(...t.map(a=>a.encodeType(r))),c=(0,Ne.concat)(...Ni(t,e,(a,l)=>{try{a.covariant(l)}catch(d){throw new Error(d.message+`
|
|
15
|
+
|
|
16
|
+
`)}return a.encodeValue(l)}));return(0,Ne.concat)(n,i,s,o,c)}D.encode=jy;function Hy(t,e){let r=new Ne.PipeArrayBuffer(e);if(e.byteLength<$s.length)throw new Error("Message length smaller than magic number");let n=(0,ne.safeRead)(r,$s.length),i=new TextDecoder().decode(n);if(i!==$s)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(_){let f=[],S=Number((0,ne.lebDecode)(_));for(let q=0;q<S;q++){let M=Number((0,ne.slebDecode)(_));switch(M){case-18:case-19:{let $=Number((0,ne.slebDecode)(_));f.push([M,$]);break}case-20:case-21:{let $=[],v=Number((0,ne.lebDecode)(_)),V;for(;v--;){let K=Number((0,ne.lebDecode)(_));if(K>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof V=="number"&&V>=K)throw new Error("field id collision or not sorted");V=K;let W=Number((0,ne.slebDecode)(_));$.push([K,W])}f.push([M,$]);break}case-22:{let $=[],v=Number((0,ne.lebDecode)(_));for(;v--;)$.push(Number((0,ne.slebDecode)(_)));let V=[],K=Number((0,ne.lebDecode)(_));for(;K--;)V.push(Number((0,ne.slebDecode)(_)));let W=[],k=Number((0,ne.lebDecode)(_));for(;k--;)switch(Number((0,ne.lebDecode)(_))){case 1:{W.push("query");break}case 2:{W.push("oneway");break}case 3:{W.push("composite_query");break}default:throw new Error("unknown annotation")}f.push([M,[$,V,W]]);break}case-23:{let $=Number((0,ne.lebDecode)(_)),v=[];for(;$--;){let V=Number((0,ne.lebDecode)(_)),K=new TextDecoder().decode((0,ne.safeRead)(_,V)),W=(0,ne.slebDecode)(_);v.push([K,W])}f.push([M,v]);break}default:throw new Error("Illegal op_code: "+M)}}let O=[],F=Number((0,ne.lebDecode)(_));for(let q=0;q<F;q++)O.push(Number((0,ne.slebDecode)(_)));return[f,O]}let[o,c]=s(r);if(c.length<t.length)throw new Error("Wrong number of return values");let a=o.map(_=>Il());function l(_){if(_<-24)throw new Error("future value not supported");if(_<0)switch(_){case-1:return D.Null;case-2:return D.Bool;case-3:return D.Nat;case-4:return D.Int;case-5:return D.Nat8;case-6:return D.Nat16;case-7:return D.Nat32;case-8:return D.Nat64;case-9:return D.Int8;case-10:return D.Int16;case-11:return D.Int32;case-12:return D.Int64;case-13:return D.Float32;case-14:return D.Float64;case-15:return D.Text;case-16:return D.Reserved;case-17:return D.Empty;case-24:return D.Principal;default:throw new Error("Illegal op_code: "+_)}if(_>=o.length)throw new Error("type index out of range");return a[_]}function d(_){switch(_[0]){case-19:{let f=l(_[1]);return Bl(f)}case-18:{let f=l(_[1]);return Tl(f)}case-20:{let f={};for(let[F,q]of _[1]){let M=`_${F}_`;f[M]=l(q)}let S=Sl(f),O=S.tryAsTuple();return Array.isArray(O)?vl(...O):S}case-21:{let f={};for(let[S,O]of _[1]){let F=`_${S}_`;f[F]=l(O)}return Al(f)}case-22:{let[f,S,O]=_[1];return Nl(f.map(F=>l(F)),S.map(F=>l(F)),O)}case-23:{let f={},S=_[1];for(let[O,F]of S){let q=l(F);if(q instanceof zr&&(q=q.getType()),!(q instanceof Pi))throw new Error("Illegal service definition: services can only contain functions");f[O]=q}return Ol(f)}default:throw new Error("Illegal op_code: "+_[0])}}o.forEach((_,f)=>{if(_[0]===-22){let S=d(_);a[f].fill(S)}}),o.forEach((_,f)=>{if(_[0]!==-22){let S=d(_);a[f].fill(S)}});let b=c.map(_=>l(_)),m=t.map((_,f)=>_.decodeValue(r,b[f]));for(let _=t.length;_<b.length;_++)b[_].decodeValue(r,b[_]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return m}D.decode=Hy;D.Empty=new Gs;D.Reserved=new Wn;D.Unknown=new Ds;D.Bool=new Ks;D.Null=new zs;D.Text=new Ws;D.Int=new Ys;D.Nat=new Zs;D.Float32=new Oi(32);D.Float64=new Oi(64);D.Int8=new Ur(8);D.Int16=new Ur(16);D.Int32=new Ur(32);D.Int64=new Ur(64);D.Nat8=new br(8);D.Nat16=new br(16);D.Nat32=new br(32);D.Nat64=new br(64);D.Principal=new eo;function vl(...t){return new Qs(t)}D.Tuple=vl;function Bl(t){return new Xs(t)}D.Vec=Bl;function Tl(t){return new Yn(t)}D.Opt=Tl;function Sl(t){return new Ri(t)}D.Record=Sl;function Al(t){return new Js(t)}D.Variant=Al;function Il(){return new zr}D.Rec=Il;function Nl(t,e,r=[]){return new Pi(t,e,r)}D.Func=Nl;function Ol(t){return new to(t)}D.Service=Ol});var wc=re(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.VecForm=pt.OptionForm=pt.VariantForm=pt.TupleForm=pt.RecordForm=pt.InputForm=pt.InputBox=void 0;var hc=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)}};pt.InputBox=hc;var Wr=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)}};pt.InputForm=Wr;var pc=class extends Wr{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}};pt.RecordForm=pc;var yc=class extends Wr{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}};pt.TupleForm=yc;var bc=class extends Wr{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}};pt.VariantForm=bc;var gc=class extends Wr{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]}}};pt.OptionForm=gc;var mc=class extends Wr{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}};pt.VecForm=mc});var Pl=re(Ee=>{"use strict";var Ly=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]}),Vy=Ee&&Ee.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Rl=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)&&Ly(e,t,r);return Vy(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 no=Rl(dc()),_c=$t(),Zn=Rl(wc()),$y={parse:Zy},Ui={render:Bc},Gy=(t,e)=>new Zn.InputBox(t,Object.assign(Object.assign({},$y),e));Ee.inputBox=Gy;var Dy=(t,e)=>new Zn.RecordForm(t,Object.assign(Object.assign({},Ui),e));Ee.recordForm=Dy;var Ky=(t,e)=>new Zn.TupleForm(t,Object.assign(Object.assign({},Ui),e));Ee.tupleForm=Ky;var zy=(t,e)=>new Zn.VariantForm(t,Object.assign(Object.assign({},Ui),e));Ee.variantForm=zy;var Wy=(t,e)=>new Zn.OptionForm(t,Object.assign(Object.assign({},Ui),e));Ee.optForm=Wy;var Yy=(t,e)=>new Zn.VecForm(t,Object.assign(Object.assign({},Ui),e));Ee.vecForm=Yy;var ro=class extends no.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[c,a]of r){let l=new Option(c);i.add(l)}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 Bc(r)}};Ee.Render=ro;var Ec=class extends no.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 _c.Principal.fromText(r)}visitService(e,r){return _c.Principal.fromText(r)}visitFunc(e,r){let n=r.split(".",2);return[_c.Principal.fromText(n[0]),n[1]]}},xc=class extends no.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 Zy(t,e,r){return e.random&&r===""?t.accept(new xc,r):t.accept(new Ec,r)}function Bc(t){return t.accept(new ro,null)}Ee.renderInput=Bc;function mn(t,e,r){return t.accept(new vc,{input:e,value:r})}Ee.renderValue=mn;var vc=class extends no.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){mn(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)),mn(r,i.form[0],n.value[0])}}visitRecord(e,r,n){let i=n.input.ui.form;r.forEach(([s,o],c)=>{mn(o,i.form[c],n.value[s])})}visitTuple(e,r,n){let i=n.input.ui.form;r.forEach((s,o)=>{mn(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,c],a)=>{if(o===s[0]){let l=i.ui.open;l.selectedIndex=a,l.dispatchEvent(new Event(i.ui.event)),mn(c,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((c,a)=>{mn(r,i.form[a],c)})}}});var Fl=re(Ul=>{"use strict";Object.defineProperty(Ul,"__esModule",{value:!0})});var Fi=re(it=>{"use strict";var Ml=it&&it.__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]}),Xy=it&&it.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Xn=it&&it.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Ml(e,t,r)},Qy=it&&it.__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)&&Ml(e,t,r);return Xy(e,t),e};Object.defineProperty(it,"__esModule",{value:!0});it.IDL=void 0;Xn(Pl(),it);Xn(wc(),it);it.IDL=Qy(dc());Xn(sc(),it);Xn(ac(),it);Xn(Hs(),it);Xn(Fl(),it)});var Mi=re((ql,io)=>{(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: ",c=1e14,a=14,l=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],b=1e7,m=1e9;function _(v){var V,K,W,k=U.prototype={constructor:U,toString:null,valueOf:null},se=new U(1),ee=20,ie=4,w=-7,g=21,A=-1e7,T=1e7,I=!1,L=1,Y=0,ce={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},oe="0123456789abcdefghijklmnopqrstuvwxyz",z=!0;function U(u,p){var y,R,B,N,j,E,P,H,C=this;if(!(C instanceof U))return new U(u,p);if(p==null){if(u&&u._isBigNumber===!0){C.s=u.s,!u.c||u.e>T?C.c=C.e=null:u.e<A?C.c=[C.e=0]:(C.e=u.e,C.c=u.c.slice());return}if((E=typeof u=="number")&&u*0==0){if(C.s=1/u<0?(u=-u,-1):1,u===~~u){for(N=0,j=u;j>=10;j/=10,N++);N>T?C.c=C.e=null:(C.e=N,C.c=[u]);return}H=String(u)}else{if(!r.test(H=String(u)))return W(C,H,E);C.s=H.charCodeAt(0)==45?(H=H.slice(1),-1):1}(N=H.indexOf("."))>-1&&(H=H.replace(".","")),(j=H.search(/e/i))>0?(N<0&&(N=j),N+=+H.slice(j+1),H=H.substring(0,j)):N<0&&(N=H.length)}else{if(F(p,2,oe.length,"Base"),p==10&&z)return C=new U(u),de(C,ee+C.e+1,ie);if(H=String(u),E=typeof u=="number"){if(u*0!=0)return W(C,H,E,p);if(C.s=1/u<0?(H=H.slice(1),-1):1,U.DEBUG&&H.replace(/^0\.0*|\./,"").length>15)throw Error(o+u)}else C.s=H.charCodeAt(0)===45?(H=H.slice(1),-1):1;for(y=oe.slice(0,p),N=j=0,P=H.length;j<P;j++)if(y.indexOf(R=H.charAt(j))<0){if(R=="."){if(j>N){N=P;continue}}else if(!B&&(H==H.toUpperCase()&&(H=H.toLowerCase())||H==H.toLowerCase()&&(H=H.toUpperCase()))){B=!0,j=-1,N=0;continue}return W(C,String(u),E,p)}E=!1,H=K(H,p,10,C.s),(N=H.indexOf("."))>-1?H=H.replace(".",""):N=H.length}for(j=0;H.charCodeAt(j)===48;j++);for(P=H.length;H.charCodeAt(--P)===48;);if(H=H.slice(j,++P)){if(P-=j,E&&U.DEBUG&&P>15&&(u>l||u!==i(u)))throw Error(o+C.s*u);if((N=N-j-1)>T)C.c=C.e=null;else if(N<A)C.c=[C.e=0];else{if(C.e=N,C.c=[],j=(N+1)%a,N<0&&(j+=a),j<P){for(j&&C.c.push(+H.slice(0,j)),P-=a;j<P;)C.c.push(+H.slice(j,j+=a));j=a-(H=H.slice(j)).length}else j-=P;for(;j--;H+="0");C.c.push(+H)}}else C.c=[C.e=0]}U.clone=_,U.ROUND_UP=0,U.ROUND_DOWN=1,U.ROUND_CEIL=2,U.ROUND_FLOOR=3,U.ROUND_HALF_UP=4,U.ROUND_HALF_DOWN=5,U.ROUND_HALF_EVEN=6,U.ROUND_HALF_CEIL=7,U.ROUND_HALF_FLOOR=8,U.EUCLID=9,U.config=U.set=function(u){var p,y;if(u!=null)if(typeof u=="object"){if(u.hasOwnProperty(p="DECIMAL_PLACES")&&(y=u[p],F(y,0,m,p),ee=y),u.hasOwnProperty(p="ROUNDING_MODE")&&(y=u[p],F(y,0,8,p),ie=y),u.hasOwnProperty(p="EXPONENTIAL_AT")&&(y=u[p],y&&y.pop?(F(y[0],-m,0,p),F(y[1],0,m,p),w=y[0],g=y[1]):(F(y,-m,m,p),w=-(g=y<0?-y:y))),u.hasOwnProperty(p="RANGE"))if(y=u[p],y&&y.pop)F(y[0],-m,-1,p),F(y[1],1,m,p),A=y[0],T=y[1];else if(F(y,-m,m,p),y)A=-(T=y<0?-y:y);else throw Error(s+p+" cannot be zero: "+y);if(u.hasOwnProperty(p="CRYPTO"))if(y=u[p],y===!!y)if(y)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))I=y;else throw I=!y,Error(s+"crypto unavailable");else I=y;else throw Error(s+p+" not true or false: "+y);if(u.hasOwnProperty(p="MODULO_MODE")&&(y=u[p],F(y,0,9,p),L=y),u.hasOwnProperty(p="POW_PRECISION")&&(y=u[p],F(y,0,m,p),Y=y),u.hasOwnProperty(p="FORMAT"))if(y=u[p],typeof y=="object")ce=y;else throw Error(s+p+" not an object: "+y);if(u.hasOwnProperty(p="ALPHABET"))if(y=u[p],typeof y=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(y))z=y.slice(0,10)=="0123456789",oe=y;else throw Error(s+p+" invalid: "+y)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:ee,ROUNDING_MODE:ie,EXPONENTIAL_AT:[w,g],RANGE:[A,T],CRYPTO:I,MODULO_MODE:L,POW_PRECISION:Y,FORMAT:ce,ALPHABET:oe}},U.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!U.DEBUG)return!0;var p,y,R=u.c,B=u.e,N=u.s;e:if({}.toString.call(R)=="[object Array]"){if((N===1||N===-1)&&B>=-m&&B<=m&&B===i(B)){if(R[0]===0){if(B===0&&R.length===1)return!0;break e}if(p=(B+1)%a,p<1&&(p+=a),String(R[0]).length==p){for(p=0;p<R.length;p++)if(y=R[p],y<0||y>=c||y!==i(y))break e;if(y!==0)return!0}}}else if(R===null&&B===null&&(N===null||N===1||N===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},U.maximum=U.max=function(){return X(arguments,-1)},U.minimum=U.min=function(){return X(arguments,1)},U.random=function(){var u=9007199254740992,p=Math.random()*u&2097151?function(){return i(Math.random()*u)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(y){var R,B,N,j,E,P=0,H=[],C=new U(se);if(y==null?y=ee:F(y,0,m),j=n(y/a),I)if(crypto.getRandomValues){for(R=crypto.getRandomValues(new Uint32Array(j*=2));P<j;)E=R[P]*131072+(R[P+1]>>>11),E>=9e15?(B=crypto.getRandomValues(new Uint32Array(2)),R[P]=B[0],R[P+1]=B[1]):(H.push(E%1e14),P+=2);P=j/2}else if(crypto.randomBytes){for(R=crypto.randomBytes(j*=7);P<j;)E=(R[P]&31)*281474976710656+R[P+1]*1099511627776+R[P+2]*4294967296+R[P+3]*16777216+(R[P+4]<<16)+(R[P+5]<<8)+R[P+6],E>=9e15?crypto.randomBytes(7).copy(R,P):(H.push(E%1e14),P+=7);P=j/7}else throw I=!1,Error(s+"crypto unavailable");if(!I)for(;P<j;)E=p(),E<9e15&&(H[P++]=E%1e14);for(j=H[--P],y%=a,j&&y&&(E=d[a-y],H[P]=i(j/E)*E);H[P]===0;H.pop(),P--);if(P<0)H=[N=0];else{for(N=-1;H[0]===0;H.splice(0,1),N-=a);for(P=1,E=H[0];E>=10;E/=10,P++);P<a&&(N-=a-P)}return C.e=N,C.c=H,C}}(),U.sum=function(){for(var u=1,p=arguments,y=new U(p[0]);u<p.length;)y=y.plus(p[u++]);return y},K=function(){var u="0123456789";function p(y,R,B,N){for(var j,E=[0],P,H=0,C=y.length;H<C;){for(P=E.length;P--;E[P]*=R);for(E[0]+=N.indexOf(y.charAt(H++)),j=0;j<E.length;j++)E[j]>B-1&&(E[j+1]==null&&(E[j+1]=0),E[j+1]+=E[j]/B|0,E[j]%=B)}return E.reverse()}return function(y,R,B,N,j){var E,P,H,C,Z,J,le,we,Fe=y.indexOf("."),Le=ee,ge=ie;for(Fe>=0&&(C=Y,Y=0,y=y.replace(".",""),we=new U(R),J=we.pow(y.length-Fe),Y=C,we.c=p($(S(J.c),J.e,"0"),10,B,u),we.e=we.c.length),le=p(y,R,B,j?(E=oe,u):(E=u,oe)),H=C=le.length;le[--C]==0;le.pop());if(!le[0])return E.charAt(0);if(Fe<0?--H:(J.c=le,J.e=H,J.s=N,J=V(J,we,Le,ge,B),le=J.c,Z=J.r,H=J.e),P=H+Le+1,Fe=le[P],C=B/2,Z=Z||P<0||le[P+1]!=null,Z=ge<4?(Fe!=null||Z)&&(ge==0||ge==(J.s<0?3:2)):Fe>C||Fe==C&&(ge==4||Z||ge==6&&le[P-1]&1||ge==(J.s<0?8:7)),P<1||!le[0])y=Z?$(E.charAt(1),-Le,E.charAt(0)):E.charAt(0);else{if(le.length=P,Z)for(--B;++le[--P]>B;)le[P]=0,P||(++H,le=[1].concat(le));for(C=le.length;!le[--C];);for(Fe=0,y="";Fe<=C;y+=E.charAt(le[Fe++]));y=$(y,H,E.charAt(0))}return y}}(),V=function(){function u(R,B,N){var j,E,P,H,C=0,Z=R.length,J=B%b,le=B/b|0;for(R=R.slice();Z--;)P=R[Z]%b,H=R[Z]/b|0,j=le*P+H*J,E=J*P+j%b*b+C,C=(E/N|0)+(j/b|0)+le*H,R[Z]=E%N;return C&&(R=[C].concat(R)),R}function p(R,B,N,j){var E,P;if(N!=j)P=N>j?1:-1;else for(E=P=0;E<N;E++)if(R[E]!=B[E]){P=R[E]>B[E]?1:-1;break}return P}function y(R,B,N,j){for(var E=0;N--;)R[N]-=E,E=R[N]<B[N]?1:0,R[N]=E*j+R[N]-B[N];for(;!R[0]&&R.length>1;R.splice(0,1));}return function(R,B,N,j,E){var P,H,C,Z,J,le,we,Fe,Le,ge,he,ze,ur,Or,yn,Ht,Re,St=R.s==B.s?1:-1,ct=R.c,Ge=B.c;if(!ct||!ct[0]||!Ge||!Ge[0])return new U(!R.s||!B.s||(ct?Ge&&ct[0]==Ge[0]:!Ge)?NaN:ct&&ct[0]==0||!Ge?St*0:St/0);for(Fe=new U(St),Le=Fe.c=[],H=R.e-B.e,St=N+H+1,E||(E=c,H=f(R.e/a)-f(B.e/a),St=St/a|0),C=0;Ge[C]==(ct[C]||0);C++);if(Ge[C]>(ct[C]||0)&&H--,St<0)Le.push(1),Z=!0;else{for(Or=ct.length,Ht=Ge.length,C=0,St+=2,J=i(E/(Ge[0]+1)),J>1&&(Ge=u(Ge,J,E),ct=u(ct,J,E),Ht=Ge.length,Or=ct.length),ur=Ht,ge=ct.slice(0,Ht),he=ge.length;he<Ht;ge[he++]=0);Re=Ge.slice(),Re=[0].concat(Re),yn=Ge[0],Ge[1]>=E/2&&yn++;do{if(J=0,P=p(Ge,ge,Ht,he),P<0){if(ze=ge[0],Ht!=he&&(ze=ze*E+(ge[1]||0)),J=i(ze/yn),J>1)for(J>=E&&(J=E-1),le=u(Ge,J,E),we=le.length,he=ge.length;p(le,ge,we,he)==1;)J--,y(le,Ht<we?Re:Ge,we,E),we=le.length,P=1;else J==0&&(P=J=1),le=Ge.slice(),we=le.length;if(we<he&&(le=[0].concat(le)),y(ge,le,he,E),he=ge.length,P==-1)for(;p(Ge,ge,Ht,he)<1;)J++,y(ge,Ht<he?Re:Ge,he,E),he=ge.length}else P===0&&(J++,ge=[0]);Le[C++]=J,ge[0]?ge[he++]=ct[ur]||0:(ge=[ct[ur]],he=1)}while((ur++<Or||ge[0]!=null)&&St--);Z=ge[0]!=null,Le[0]||Le.splice(0,1)}if(E==c){for(C=1,St=Le[0];St>=10;St/=10,C++);de(Fe,N+(Fe.e=C+H*a-1)+1,j,Z)}else Fe.e=H,Fe.r=+Z;return Fe}}();function h(u,p,y,R){var B,N,j,E,P;if(y==null?y=ie:F(y,0,8),!u.c)return u.toString();if(B=u.c[0],j=u.e,p==null)P=S(u.c),P=R==1||R==2&&(j<=w||j>=g)?M(P,j):$(P,j,"0");else if(u=de(new U(u),p,y),N=u.e,P=S(u.c),E=P.length,R==1||R==2&&(p<=N||N<=w)){for(;E<p;P+="0",E++);P=M(P,N)}else if(p-=j,P=$(P,N,"0"),N+1>E){if(--p>0)for(P+=".";p--;P+="0");}else if(p+=N-E,p>0)for(N+1==E&&(P+=".");p--;P+="0");return u.s<0&&B?"-"+P:P}function X(u,p){for(var y,R,B=1,N=new U(u[0]);B<u.length;B++)R=new U(u[B]),(!R.s||(y=O(N,R))===p||y===0&&N.s===p)&&(N=R);return N}function te(u,p,y){for(var R=1,B=p.length;!p[--B];p.pop());for(B=p[0];B>=10;B/=10,R++);return(y=R+y*a-1)>T?u.c=u.e=null:y<A?u.c=[u.e=0]:(u.e=y,u.c=p),u}W=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,p=/^([^.]+)\.$/,y=/^\.([^.]+)$/,R=/^-?(Infinity|NaN)$/,B=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(N,j,E,P){var H,C=E?j:j.replace(B,"");if(R.test(C))N.s=isNaN(C)?null:C<0?-1:1;else{if(!E&&(C=C.replace(u,function(Z,J,le){return H=(le=le.toLowerCase())=="x"?16:le=="b"?2:8,!P||P==H?J:Z}),P&&(H=P,C=C.replace(p,"$1").replace(y,"0.$1")),j!=C))return new U(C,H);if(U.DEBUG)throw Error(s+"Not a"+(P?" base "+P:"")+" number: "+j);N.s=null}N.c=N.e=null}}();function de(u,p,y,R){var B,N,j,E,P,H,C,Z=u.c,J=d;if(Z){e:{for(B=1,E=Z[0];E>=10;E/=10,B++);if(N=p-B,N<0)N+=a,j=p,P=Z[H=0],C=i(P/J[B-j-1]%10);else if(H=n((N+1)/a),H>=Z.length)if(R){for(;Z.length<=H;Z.push(0));P=C=0,B=1,N%=a,j=N-a+1}else break e;else{for(P=E=Z[H],B=1;E>=10;E/=10,B++);N%=a,j=N-a+B,C=j<0?0:i(P/J[B-j-1]%10)}if(R=R||p<0||Z[H+1]!=null||(j<0?P:P%J[B-j-1]),R=y<4?(C||R)&&(y==0||y==(u.s<0?3:2)):C>5||C==5&&(y==4||R||y==6&&(N>0?j>0?P/J[B-j]:0:Z[H-1])%10&1||y==(u.s<0?8:7)),p<1||!Z[0])return Z.length=0,R?(p-=u.e+1,Z[0]=J[(a-p%a)%a],u.e=-p||0):Z[0]=u.e=0,u;if(N==0?(Z.length=H,E=1,H--):(Z.length=H+1,E=J[a-N],Z[H]=j>0?i(P/J[B-j]%J[j])*E:0),R)for(;;)if(H==0){for(N=1,j=Z[0];j>=10;j/=10,N++);for(j=Z[0]+=E,E=1;j>=10;j/=10,E++);N!=E&&(u.e++,Z[0]==c&&(Z[0]=1));break}else{if(Z[H]+=E,Z[H]!=c)break;Z[H--]=0,E=1}for(N=Z.length;Z[--N]===0;Z.pop());}u.e>T?u.c=u.e=null:u.e<A&&(u.c=[u.e=0])}return u}function Q(u){var p,y=u.e;return y===null?u.toString():(p=S(u.c),p=y<=w||y>=g?M(p,y):$(p,y,"0"),u.s<0?"-"+p:p)}return k.absoluteValue=k.abs=function(){var u=new U(this);return u.s<0&&(u.s=1),u},k.comparedTo=function(u,p){return O(this,new U(u,p))},k.decimalPlaces=k.dp=function(u,p){var y,R,B,N=this;if(u!=null)return F(u,0,m),p==null?p=ie:F(p,0,8),de(new U(N),u+N.e+1,p);if(!(y=N.c))return null;if(R=((B=y.length-1)-f(this.e/a))*a,B=y[B])for(;B%10==0;B/=10,R--);return R<0&&(R=0),R},k.dividedBy=k.div=function(u,p){return V(this,new U(u,p),ee,ie)},k.dividedToIntegerBy=k.idiv=function(u,p){return V(this,new U(u,p),0,1)},k.exponentiatedBy=k.pow=function(u,p){var y,R,B,N,j,E,P,H,C,Z=this;if(u=new U(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+Q(u));if(p!=null&&(p=new U(p)),E=u.e>14,!Z.c||!Z.c[0]||Z.c[0]==1&&!Z.e&&Z.c.length==1||!u.c||!u.c[0])return C=new U(Math.pow(+Q(Z),E?u.s*(2-q(u)):+Q(u))),p?C.mod(p):C;if(P=u.s<0,p){if(p.c?!p.c[0]:!p.s)return new U(NaN);R=!P&&Z.isInteger()&&p.isInteger(),R&&(Z=Z.mod(p))}else{if(u.e>9&&(Z.e>0||Z.e<-1||(Z.e==0?Z.c[0]>1||E&&Z.c[1]>=24e7:Z.c[0]<8e13||E&&Z.c[0]<=9999975e7)))return N=Z.s<0&&q(u)?-0:0,Z.e>-1&&(N=1/N),new U(P?1/N:N);Y&&(N=n(Y/a+2))}for(E?(y=new U(.5),P&&(u.s=1),H=q(u)):(B=Math.abs(+Q(u)),H=B%2),C=new U(se);;){if(H){if(C=C.times(Z),!C.c)break;N?C.c.length>N&&(C.c.length=N):R&&(C=C.mod(p))}if(B){if(B=i(B/2),B===0)break;H=B%2}else if(u=u.times(y),de(u,u.e+1,1),u.e>14)H=q(u);else{if(B=+Q(u),B===0)break;H=B%2}Z=Z.times(Z),N?Z.c&&Z.c.length>N&&(Z.c.length=N):R&&(Z=Z.mod(p))}return R?C:(P&&(C=se.div(C)),p?C.mod(p):N?de(C,Y,ie,j):C)},k.integerValue=function(u){var p=new U(this);return u==null?u=ie:F(u,0,8),de(p,p.e+1,u)},k.isEqualTo=k.eq=function(u,p){return O(this,new U(u,p))===0},k.isFinite=function(){return!!this.c},k.isGreaterThan=k.gt=function(u,p){return O(this,new U(u,p))>0},k.isGreaterThanOrEqualTo=k.gte=function(u,p){return(p=O(this,new U(u,p)))===1||p===0},k.isInteger=function(){return!!this.c&&f(this.e/a)>this.c.length-2},k.isLessThan=k.lt=function(u,p){return O(this,new U(u,p))<0},k.isLessThanOrEqualTo=k.lte=function(u,p){return(p=O(this,new U(u,p)))===-1||p===0},k.isNaN=function(){return!this.s},k.isNegative=function(){return this.s<0},k.isPositive=function(){return this.s>0},k.isZero=function(){return!!this.c&&this.c[0]==0},k.minus=function(u,p){var y,R,B,N,j=this,E=j.s;if(u=new U(u,p),p=u.s,!E||!p)return new U(NaN);if(E!=p)return u.s=-p,j.plus(u);var P=j.e/a,H=u.e/a,C=j.c,Z=u.c;if(!P||!H){if(!C||!Z)return C?(u.s=-p,u):new U(Z?j:NaN);if(!C[0]||!Z[0])return Z[0]?(u.s=-p,u):new U(C[0]?j:ie==3?-0:0)}if(P=f(P),H=f(H),C=C.slice(),E=P-H){for((N=E<0)?(E=-E,B=C):(H=P,B=Z),B.reverse(),p=E;p--;B.push(0));B.reverse()}else for(R=(N=(E=C.length)<(p=Z.length))?E:p,E=p=0;p<R;p++)if(C[p]!=Z[p]){N=C[p]<Z[p];break}if(N&&(B=C,C=Z,Z=B,u.s=-u.s),p=(R=Z.length)-(y=C.length),p>0)for(;p--;C[y++]=0);for(p=c-1;R>E;){if(C[--R]<Z[R]){for(y=R;y&&!C[--y];C[y]=p);--C[y],C[R]+=c}C[R]-=Z[R]}for(;C[0]==0;C.splice(0,1),--H);return C[0]?te(u,C,H):(u.s=ie==3?-1:1,u.c=[u.e=0],u)},k.modulo=k.mod=function(u,p){var y,R,B=this;return u=new U(u,p),!B.c||!u.s||u.c&&!u.c[0]?new U(NaN):!u.c||B.c&&!B.c[0]?new U(B):(L==9?(R=u.s,u.s=1,y=V(B,u,0,3),u.s=R,y.s*=R):y=V(B,u,0,L),u=B.minus(y.times(u)),!u.c[0]&&L==1&&(u.s=B.s),u)},k.multipliedBy=k.times=function(u,p){var y,R,B,N,j,E,P,H,C,Z,J,le,we,Fe,Le,ge=this,he=ge.c,ze=(u=new U(u,p)).c;if(!he||!ze||!he[0]||!ze[0])return!ge.s||!u.s||he&&!he[0]&&!ze||ze&&!ze[0]&&!he?u.c=u.e=u.s=null:(u.s*=ge.s,!he||!ze?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(R=f(ge.e/a)+f(u.e/a),u.s*=ge.s,P=he.length,Z=ze.length,P<Z&&(we=he,he=ze,ze=we,B=P,P=Z,Z=B),B=P+Z,we=[];B--;we.push(0));for(Fe=c,Le=b,B=Z;--B>=0;){for(y=0,J=ze[B]%Le,le=ze[B]/Le|0,j=P,N=B+j;N>B;)H=he[--j]%Le,C=he[j]/Le|0,E=le*H+C*J,H=J*H+E%Le*Le+we[N]+y,y=(H/Fe|0)+(E/Le|0)+le*C,we[N--]=H%Fe;we[N]=y}return y?++R:we.splice(0,1),te(u,we,R)},k.negated=function(){var u=new U(this);return u.s=-u.s||null,u},k.plus=function(u,p){var y,R=this,B=R.s;if(u=new U(u,p),p=u.s,!B||!p)return new U(NaN);if(B!=p)return u.s=-p,R.minus(u);var N=R.e/a,j=u.e/a,E=R.c,P=u.c;if(!N||!j){if(!E||!P)return new U(B/0);if(!E[0]||!P[0])return P[0]?u:new U(E[0]?R:B*0)}if(N=f(N),j=f(j),E=E.slice(),B=N-j){for(B>0?(j=N,y=P):(B=-B,y=E),y.reverse();B--;y.push(0));y.reverse()}for(B=E.length,p=P.length,B-p<0&&(y=P,P=E,E=y,p=B),B=0;p;)B=(E[--p]=E[p]+P[p]+B)/c|0,E[p]=c===E[p]?0:E[p]%c;return B&&(E=[B].concat(E),++j),te(u,E,j)},k.precision=k.sd=function(u,p){var y,R,B,N=this;if(u!=null&&u!==!!u)return F(u,1,m),p==null?p=ie:F(p,0,8),de(new U(N),u,p);if(!(y=N.c))return null;if(B=y.length-1,R=B*a+1,B=y[B]){for(;B%10==0;B/=10,R--);for(B=y[0];B>=10;B/=10,R++);}return u&&N.e+1>R&&(R=N.e+1),R},k.shiftedBy=function(u){return F(u,-l,l),this.times("1e"+u)},k.squareRoot=k.sqrt=function(){var u,p,y,R,B,N=this,j=N.c,E=N.s,P=N.e,H=ee+4,C=new U("0.5");if(E!==1||!j||!j[0])return new U(!E||E<0&&(!j||j[0])?NaN:j?N:1/0);if(E=Math.sqrt(+Q(N)),E==0||E==1/0?(p=S(j),(p.length+P)%2==0&&(p+="0"),E=Math.sqrt(+p),P=f((P+1)/2)-(P<0||P%2),E==1/0?p="5e"+P:(p=E.toExponential(),p=p.slice(0,p.indexOf("e")+1)+P),y=new U(p)):y=new U(E+""),y.c[0]){for(P=y.e,E=P+H,E<3&&(E=0);;)if(B=y,y=C.times(B.plus(V(N,B,H,1))),S(B.c).slice(0,E)===(p=S(y.c)).slice(0,E))if(y.e<P&&--E,p=p.slice(E-3,E+1),p=="9999"||!R&&p=="4999"){if(!R&&(de(B,B.e+ee+2,0),B.times(B).eq(N))){y=B;break}H+=4,E+=4,R=1}else{(!+p||!+p.slice(1)&&p.charAt(0)=="5")&&(de(y,y.e+ee+2,1),u=!y.times(y).eq(N));break}}return de(y,y.e+ee+1,ie,u)},k.toExponential=function(u,p){return u!=null&&(F(u,0,m),u++),h(this,u,p,1)},k.toFixed=function(u,p){return u!=null&&(F(u,0,m),u=u+this.e+1),h(this,u,p)},k.toFormat=function(u,p,y){var R,B=this;if(y==null)u!=null&&p&&typeof p=="object"?(y=p,p=null):u&&typeof u=="object"?(y=u,u=p=null):y=ce;else if(typeof y!="object")throw Error(s+"Argument not an object: "+y);if(R=B.toFixed(u,p),B.c){var N,j=R.split("."),E=+y.groupSize,P=+y.secondaryGroupSize,H=y.groupSeparator||"",C=j[0],Z=j[1],J=B.s<0,le=J?C.slice(1):C,we=le.length;if(P&&(N=E,E=P,P=N,we-=N),E>0&&we>0){for(N=we%E||E,C=le.substr(0,N);N<we;N+=E)C+=H+le.substr(N,E);P>0&&(C+=H+le.slice(N)),J&&(C="-"+C)}R=Z?C+(y.decimalSeparator||"")+((P=+y.fractionGroupSize)?Z.replace(new RegExp("\\d{"+P+"}\\B","g"),"$&"+(y.fractionGroupSeparator||"")):Z):C}return(y.prefix||"")+R+(y.suffix||"")},k.toFraction=function(u){var p,y,R,B,N,j,E,P,H,C,Z,J,le=this,we=le.c;if(u!=null&&(E=new U(u),!E.isInteger()&&(E.c||E.s!==1)||E.lt(se)))throw Error(s+"Argument "+(E.isInteger()?"out of range: ":"not an integer: ")+Q(E));if(!we)return new U(le);for(p=new U(se),H=y=new U(se),R=P=new U(se),J=S(we),N=p.e=J.length-le.e-1,p.c[0]=d[(j=N%a)<0?a+j:j],u=!u||E.comparedTo(p)>0?N>0?p:H:E,j=T,T=1/0,E=new U(J),P.c[0]=0;C=V(E,p,0,1),B=y.plus(C.times(R)),B.comparedTo(u)!=1;)y=R,R=B,H=P.plus(C.times(B=H)),P=B,p=E.minus(C.times(B=p)),E=B;return B=V(u.minus(y),R,0,1),P=P.plus(B.times(H)),y=y.plus(B.times(R)),P.s=H.s=le.s,N=N*2,Z=V(H,R,N,ie).minus(le).abs().comparedTo(V(P,y,N,ie).minus(le).abs())<1?[H,R]:[P,y],T=j,Z},k.toNumber=function(){return+Q(this)},k.toPrecision=function(u,p){return u!=null&&F(u,1,m),h(this,u,p,2)},k.toString=function(u){var p,y=this,R=y.s,B=y.e;return B===null?R?(p="Infinity",R<0&&(p="-"+p)):p="NaN":(u==null?p=B<=w||B>=g?M(S(y.c),B):$(S(y.c),B,"0"):u===10&&z?(y=de(new U(y),ee+B+1,ie),p=$(S(y.c),y.e,"0")):(F(u,2,oe.length,"Base"),p=K($(S(y.c),B,"0"),10,u,R,!0)),R<0&&y.c[0]&&(p="-"+p)),p},k.valueOf=k.toJSON=function(){return Q(this)},k._isBigNumber=!0,v!=null&&U.set(v),U}function f(v){var V=v|0;return v>0||v===V?V:V-1}function S(v){for(var V,K,W=1,k=v.length,se=v[0]+"";W<k;){for(V=v[W++]+"",K=a-V.length;K--;V="0"+V);se+=V}for(k=se.length;se.charCodeAt(--k)===48;);return se.slice(0,k+1||1)}function O(v,V){var K,W,k=v.c,se=V.c,ee=v.s,ie=V.s,w=v.e,g=V.e;if(!ee||!ie)return null;if(K=k&&!k[0],W=se&&!se[0],K||W)return K?W?0:-ie:ee;if(ee!=ie)return ee;if(K=ee<0,W=w==g,!k||!se)return W?0:!k^K?1:-1;if(!W)return w>g^K?1:-1;for(ie=(w=k.length)<(g=se.length)?w:g,ee=0;ee<ie;ee++)if(k[ee]!=se[ee])return k[ee]>se[ee]^K?1:-1;return w==g?0:w>g^K?1:-1}function F(v,V,K,W){if(v<V||v>K||v!==i(v))throw Error(s+(W||"Argument")+(typeof v=="number"?v<V||v>K?" out of range: ":" not an integer: ":" not a primitive number: ")+String(v))}function q(v){var V=v.c.length-1;return f(v.e/a)==V&&v.c[V]%2!=0}function M(v,V){return(v.length>1?v.charAt(0)+"."+v.slice(1):v)+(V<0?"e":"e+")+V}function $(v,V,K){var W,k;if(V<0){for(k=K+".";++V;k+=K);v=k+v}else if(W=v.length,++V>W){for(k=K,V-=W;--V;k+=K);v+=k}else V<W&&(v=v.slice(0,V)+"."+v.slice(V));return v}e=_(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof io<"u"&&io.exports?io.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(ql)});var kl=re((k8,Cl)=>{Cl.exports=function(e,r,n){var i=new e.Uint8Array(n),s=r.pushInt,o=r.pushInt32,c=r.pushInt32Neg,a=r.pushInt64,l=r.pushInt64Neg,d=r.pushFloat,b=r.pushFloatSingle,m=r.pushFloatDouble,_=r.pushTrue,f=r.pushFalse,S=r.pushUndefined,O=r.pushNull,F=r.pushInfinity,q=r.pushInfinityNeg,M=r.pushNaN,$=r.pushNaNNeg,v=r.pushArrayStart,V=r.pushArrayStartFixed,K=r.pushArrayStartFixed32,W=r.pushArrayStartFixed64,k=r.pushObjectStart,se=r.pushObjectStartFixed,ee=r.pushObjectStartFixed32,ie=r.pushObjectStartFixed64,w=r.pushByteString,g=r.pushByteStringStart,A=r.pushUtf8String,T=r.pushUtf8StringStart,I=r.pushSimpleUnassigned,L=r.pushTagStart,Y=r.pushTagStart4,ce=r.pushTagStart8,oe=r.pushTagUnassigned,z=r.pushBreak,U=e.Math.pow,h=0,X=0,te=0;function de(x){for(x=x|0,h=0,X=x;(h|0)<(X|0)&&(te=Zp[i[h]&255](i[h]|0)|0,!((te|0)>0)););return te|0}function Q(x){return x=x|0,((h|0)+(x|0)|0)<(X|0)?0:1}function u(x){return x=x|0,i[x|0]<<8|i[x+1|0]|0}function p(x){return x=x|0,i[x|0]<<24|i[x+1|0]<<16|i[x+2|0]<<8|i[x+3|0]|0}function y(x){return x=x|0,s(x|0),h=h+1|0,0}function R(x){return x=x|0,Q(1)|0?1:(s(i[h+1|0]|0),h=h+2|0,0)}function B(x){return x=x|0,Q(2)|0?1:(s(u(h+1|0)|0),h=h+3|0,0)}function N(x){return x=x|0,Q(4)|0?1:(o(u(h+1|0)|0,u(h+3|0)|0),h=h+5|0,0)}function j(x){return x=x|0,Q(8)|0?1:(a(u(h+1|0)|0,u(h+3|0)|0,u(h+5|0)|0,u(h+7|0)|0),h=h+9|0,0)}function E(x){return x=x|0,s(-1-(x-32|0)|0),h=h+1|0,0}function P(x){return x=x|0,Q(1)|0?1:(s(-1-(i[h+1|0]|0)|0),h=h+2|0,0)}function H(x){x=x|0;var Be=0;return Q(2)|0?1:(Be=u(h+1|0)|0,s(-1-(Be|0)|0),h=h+3|0,0)}function C(x){return x=x|0,Q(4)|0?1:(c(u(h+1|0)|0,u(h+3|0)|0),h=h+5|0,0)}function Z(x){return x=x|0,Q(8)|0?1:(l(u(h+1|0)|0,u(h+3|0)|0,u(h+5|0)|0,u(h+7|0)|0),h=h+9|0,0)}function J(x){x=x|0;var Be=0,Ae=0,xe=0;return xe=x-64|0,Q(xe|0)|0?1:(Be=h+1|0,Ae=(h+1|0)+(xe|0)|0,w(Be|0,Ae|0),h=Ae|0,0)}function le(x){x=x|0;var Be=0,Ae=0,xe=0;return Q(1)|0||(xe=i[h+1|0]|0,Be=h+2|0,Ae=(h+2|0)+(xe|0)|0,Q(xe+1|0)|0)?1:(w(Be|0,Ae|0),h=Ae|0,0)}function we(x){x=x|0;var Be=0,Ae=0,xe=0;return Q(2)|0||(xe=u(h+1|0)|0,Be=h+3|0,Ae=(h+3|0)+(xe|0)|0,Q(xe+2|0)|0)?1:(w(Be|0,Ae|0),h=Ae|0,0)}function Fe(x){x=x|0;var Be=0,Ae=0,xe=0;return Q(4)|0||(xe=p(h+1|0)|0,Be=h+5|0,Ae=(h+5|0)+(xe|0)|0,Q(xe+4|0)|0)?1:(w(Be|0,Ae|0),h=Ae|0,0)}function Le(x){return x=x|0,1}function ge(x){return x=x|0,g(),h=h+1|0,0}function he(x){x=x|0;var Be=0,Ae=0,xe=0;return xe=x-96|0,Q(xe|0)|0?1:(Be=h+1|0,Ae=(h+1|0)+(xe|0)|0,A(Be|0,Ae|0),h=Ae|0,0)}function ze(x){x=x|0;var Be=0,Ae=0,xe=0;return Q(1)|0||(xe=i[h+1|0]|0,Be=h+2|0,Ae=(h+2|0)+(xe|0)|0,Q(xe+1|0)|0)?1:(A(Be|0,Ae|0),h=Ae|0,0)}function ur(x){x=x|0;var Be=0,Ae=0,xe=0;return Q(2)|0||(xe=u(h+1|0)|0,Be=h+3|0,Ae=(h+3|0)+(xe|0)|0,Q(xe+2|0)|0)?1:(A(Be|0,Ae|0),h=Ae|0,0)}function Or(x){x=x|0;var Be=0,Ae=0,xe=0;return Q(4)|0||(xe=p(h+1|0)|0,Be=h+5|0,Ae=(h+5|0)+(xe|0)|0,Q(xe+4|0)|0)?1:(A(Be|0,Ae|0),h=Ae|0,0)}function yn(x){return x=x|0,1}function Ht(x){return x=x|0,T(),h=h+1|0,0}function Re(x){return x=x|0,V(x-128|0),h=h+1|0,0}function St(x){return x=x|0,Q(1)|0?1:(V(i[h+1|0]|0),h=h+2|0,0)}function ct(x){return x=x|0,Q(2)|0?1:(V(u(h+1|0)|0),h=h+3|0,0)}function Ge(x){return x=x|0,Q(4)|0?1:(K(u(h+1|0)|0,u(h+3|0)|0),h=h+5|0,0)}function Op(x){return x=x|0,Q(8)|0?1:(W(u(h+1|0)|0,u(h+3|0)|0,u(h+5|0)|0,u(h+7|0)|0),h=h+9|0,0)}function Rp(x){return x=x|0,v(),h=h+1|0,0}function De(x){x=x|0;var Be=0;return Be=x-160|0,Q(Be|0)|0?1:(se(Be|0),h=h+1|0,0)}function Pp(x){return x=x|0,Q(1)|0?1:(se(i[h+1|0]|0),h=h+2|0,0)}function Up(x){return x=x|0,Q(2)|0?1:(se(u(h+1|0)|0),h=h+3|0,0)}function Fp(x){return x=x|0,Q(4)|0?1:(ee(u(h+1|0)|0,u(h+3|0)|0),h=h+5|0,0)}function Mp(x){return x=x|0,Q(8)|0?1:(ie(u(h+1|0)|0,u(h+3|0)|0,u(h+5|0)|0,u(h+7|0)|0),h=h+9|0,0)}function qp(x){return x=x|0,k(),h=h+1|0,0}function Fn(x){return x=x|0,L(x-192|0|0),h=h+1|0,0}function i8(x){return x=x|0,L(x|0),h=h+1|0,0}function s8(x){return x=x|0,L(x|0),h=h+1|0,0}function o8(x){return x=x|0,L(x|0),h=h+1|0,0}function a8(x){return x=x|0,L(x|0),h=h+1|0,0}function rt(x){return x=x|0,L(x-192|0|0),h=h+1|0,0}function c8(x){return x=x|0,L(x|0),h=h+1|0,0}function u8(x){return x=x|0,L(x|0),h=h+1|0,0}function f8(x){return x=x|0,L(x|0),h=h+1|0,0}function Cp(x){return x=x|0,Q(1)|0?1:(L(i[h+1|0]|0),h=h+2|0,0)}function kp(x){return x=x|0,Q(2)|0?1:(L(u(h+1|0)|0),h=h+3|0,0)}function jp(x){return x=x|0,Q(4)|0?1:(Y(u(h+1|0)|0,u(h+3|0)|0),h=h+5|0,0)}function Hp(x){return x=x|0,Q(8)|0?1:(ce(u(h+1|0)|0,u(h+3|0)|0,u(h+5|0)|0,u(h+7|0)|0),h=h+9|0,0)}function Xe(x){return x=x|0,I((x|0)-224|0),h=h+1|0,0}function Lp(x){return x=x|0,f(),h=h+1|0,0}function Vp(x){return x=x|0,_(),h=h+1|0,0}function $p(x){return x=x|0,O(),h=h+1|0,0}function Gp(x){return x=x|0,S(),h=h+1|0,0}function Dp(x){return x=x|0,Q(1)|0?1:(I(i[h+1|0]|0),h=h+2|0,0)}function Kp(x){x=x|0;var Be=0,Ae=0,xe=1,Ts=0,vi=0,l8=0;return Q(2)|0?1:(Be=i[h+1|0]|0,Ae=i[h+2|0]|0,(Be|0)&128&&(xe=-1),Ts=+(((Be|0)&124)>>2),vi=+(((Be|0)&3)<<8|Ae),+Ts==0?d(+(+xe*5960464477539063e-23*+vi)):+Ts==31?+xe==1?+vi>0?M():F():+vi>0?$():q():d(+(+xe*U(2,+(+Ts-25))*+(1024+vi))),h=h+3|0,0)}function zp(x){return x=x|0,Q(4)|0?1:(b(i[h+1|0]|0,i[h+2|0]|0,i[h+3|0]|0,i[h+4|0]|0),h=h+5|0,0)}function Wp(x){return x=x|0,Q(8)|0?1:(m(i[h+1|0]|0,i[h+2|0]|0,i[h+3|0]|0,i[h+4|0]|0,i[h+5|0]|0,i[h+6|0]|0,i[h+7|0]|0,i[h+8|0]|0),h=h+9|0,0)}function je(x){return x=x|0,1}function Yp(x){return x=x|0,z(),h=h+1|0,0}var Zp=[y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,R,B,N,j,je,je,je,je,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,P,H,C,Z,je,je,je,je,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,le,we,Fe,Le,je,je,je,ge,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,ze,ur,Or,yn,je,je,je,Ht,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,Re,St,ct,Ge,Op,je,je,je,Rp,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,Pp,Up,Fp,Mp,je,je,je,qp,Fn,Fn,Fn,Fn,Fn,Fn,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,Cp,kp,jp,Hp,je,je,je,je,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Xe,Lp,Vp,$p,Gp,Dp,Kp,zp,Wp,je,je,je,Yp];return{parse:de}}});var qi=re(Ft=>{"use strict";var Tc=Mi().BigNumber;Ft.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Ft.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};Ft.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Ft.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Ft.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Ft.SHIFT32=Math.pow(2,32);Ft.SHIFT16=Math.pow(2,16);Ft.MAX_SAFE_HIGH=2097151;Ft.NEG_ONE=new Tc(-1);Ft.TEN=new Tc(10);Ft.TWO=new Tc(2);Ft.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var so=re(Gt=>{"use strict";var{Buffer:Jy}=Mn("buffer"),Hl=Mi().BigNumber,Ll=qi(),jl=Ll.SHIFT32,eb=Ll.SHIFT16,tb=2097151;Gt.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 rb(t){return t<16?"0"+t.toString(16):t.toString(16)}Gt.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=rb(t[n]);return new Hl(r,16)};Gt.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};Gt.buildInt32=(t,e)=>t*eb+e;Gt.buildInt64=(t,e,r,n)=>{let i=Gt.buildInt32(t,e),s=Gt.buildInt32(r,n);return i>tb?new Hl(i).times(jl).plus(s):i*jl+s};Gt.writeHalf=function(e,r){let n=Jy.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,c=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(c>>13);else if(o>=103&&o<113){if(c&(1<<126-o)-1)return!1;s+=c+8388608>>126-o}else return!1;return e.writeUInt16BE(s,0),!0};Gt.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])};Gt.isNegativeZero=t=>t===0&&1/t<0;Gt.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var Nc=re((L8,Vl)=>{"use strict";var Ic=qi(),nb=Ic.MT,oo=Ic.SIMPLE,Sc=Ic.SYMS,Ac=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,nb.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case oo.FALSE:return!1;case oo.TRUE:return!0;case oo.NULL:return r?null:Sc.NULL;case oo.UNDEFINED:return r?void 0:Sc.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return Sc.BREAK;default:return new t(e)}}};Vl.exports=Ac});var Rc=re((V8,$l)=>{"use strict";var Oc=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}}};$l.exports=Oc});var Uc=re(($8,Dl)=>{"use strict";var{URL:ib,URLSearchParams:sb,format:ob}=Mn("url"),Gl="http://localhost",Pc=class extends ib{constructor(e="",r=Gl){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()}};Dl.exports={URLWithLegacySupport:Pc,URLSearchParams:sb,format:ob,defaultBase:Gl}});var Wl=re((G8,zl)=>{"use strict";var{URLWithLegacySupport:Kl,format:ab}=Uc();zl.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new Kl(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new Kl(t,ab(o)).toString()}});var Fc=re((D8,Yl)=>{"use strict";var{URLWithLegacySupport:cb,format:ub,URLSearchParams:fb,defaultBase:lb}=Uc(),db=Wl();Yl.exports={URL:cb,URLSearchParams:fb,format:ub,relative:db,defaultBase:lb}});var Mc=re((K8,Xl)=>{"use strict";var{Buffer:Qn}=Mn("buffer"),Zl=Ma(),hb=Mi().BigNumber,pb=kl(),wt=so(),qe=qi(),yb=Nc(),bb=Rc(),{URL:gb}=Fc(),Ci=class t{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=wt.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=Qn.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>wt.arrayBufferToBignumber(r),3:r=>qe.NEG_ONE.minus(wt.arrayBufferToBignumber(r)),4:r=>qe.TEN.pow(r[0]).times(r[1]),5:r=>qe.TWO.pow(r[0]).times(r[1]),32:r=>new gb(r),35:r=>new RegExp(r)},e.tags),this.parser=pb(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 qe.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case qe.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case qe.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case qe.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 qe.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 qe.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===qe.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 qe.PARENT.ARRAY:case qe.PARENT.BYTE_STRING:case qe.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case qe.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=qe.PARENT.MAP,n.ref=wt.buildMap(n.ref)));break;case qe.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case qe.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:qe.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,r){let n=this._knownTags[e];return n?n(r):new bb(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return Qn.concat(e)}createByteStringFromHeap(e,r){return e===r?Qn.alloc(0):Qn.from(this._heap.slice(e,r))}createInt(e){return e}createInt32(e,r){return wt.buildInt32(e,r)}createInt64(e,r,n,i){return wt.buildInt64(e,r,n,i)}createFloat(e){return e}createFloatSingle(e,r,n,i){return Zl.read([e,r,n,i],0,!1,23,4)}createFloatDouble(e,r,n,i,s,o,c,a){return Zl.read([e,r,n,i,s,o,c,a],0,!1,52,8)}createInt32Neg(e,r){return-1-wt.buildInt32(e,r)}createInt64Neg(e,r,n,i){let s=wt.buildInt32(e,r),o=wt.buildInt32(n,i);return s>qe.MAX_SAFE_HIGH?qe.NEG_ONE.minus(new hb(s).times(qe.SHIFT32).plus(o)):-1-(s*qe.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 yb(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,c,a){this._push(this.createFloatDouble(e,r,n,i,s,o,c,a))}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([],qe.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,r){let n=wt.buildInt32(e,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,r,n,i){let s=wt.buildInt64(e,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,r){let n=wt.buildInt32(e,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,r,n,i){let s=wt.buildInt64(e,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:qe.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:qe.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:qe.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,r){this.pushTagStart(wt.buildInt32(e,r))}pushTagStart8(e,r,n,i){this.pushTagStart(wt.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({},qe.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),qe.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=Qn.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=Qn.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};Ci.decodeFirst=Ci.decode;Xl.exports=Ci});var e0=re((z8,Jl)=>{"use strict";var{Buffer:qc}=Mn("buffer"),mb=Mc(),wb=so(),Cc=class t extends mb{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 wb.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,c,a){return`${super.createFloatDouble(e,r,n,i,s,o,c,a)}_3`}createByteString(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(e,r){return`h'${qc.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(Ql(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(e,r){let n=super.createObject(e),i=Object.keys(n).reduce(Ql(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,r){return`"${qc.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=qc.from(e,r||"hex")),new t().decodeFirst(e)}};Jl.exports=Cc;function Ql(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var s0=re((W8,i0)=>{"use strict";var{Buffer:mr}=Mn("buffer"),{URL:_b}=Fc(),jc=Mi().BigNumber,kc=so(),Qe=qi(),Qt=Qe.MT,ao=Qe.NUMBYTES,t0=Qe.SHIFT32,r0=Qe.SYMS,Jn=Qe.TAG,Eb=Qe.MT.SIMPLE_FLOAT<<5|Qe.NUMBYTES.TWO,xb=Qe.MT.SIMPLE_FLOAT<<5|Qe.NUMBYTES.FOUR,vb=Qe.MT.SIMPLE_FLOAT<<5|Qe.NUMBYTES.EIGHT,Bb=Qe.MT.SIMPLE_FLOAT<<5|Qe.SIMPLE.TRUE,Tb=Qe.MT.SIMPLE_FLOAT<<5|Qe.SIMPLE.FALSE,Sb=Qe.MT.SIMPLE_FLOAT<<5|Qe.SIMPLE.UNDEFINED,n0=Qe.MT.SIMPLE_FLOAT<<5|Qe.SIMPLE.NULL,Ab=new jc("0x20000000000000"),Ib=mr.from("f97e00","hex"),Nb=mr.from("f9fc00","hex"),Ob=mr.from("f97c00","hex");function Rb(t){return{}.toString.call(t).slice(8,-1)}var Hc=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[_b,this._pushUrl],[jc,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(Ib)}_pushInfinity(e){let r=e<0?Nb:Ob;return this.push(r)}_pushFloat(e){let r=mr.allocUnsafe(2);if(kc.writeHalf(r,e)&&kc.parseHalf(r)===e)return this._pushUInt8(Eb)&&this.push(r);let n=mr.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(xb)&&this.push(n):this._pushUInt8(vb)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|ao.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|ao.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|ao.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|ao.EIGHT)&&this._pushUInt32BE(Math.floor(e/t0))&&this._pushUInt32BE(e%t0):r===Qt.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,Qt.NEG_INT,e):this._pushInt(e,Qt.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=mr.byteLength(e,"utf8");return this._pushInt(r,Qt.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?Bb:Tb)}_pushUndefined(e){return this._pushUInt8(Sb)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,Qt.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,Qt.TAG)}_pushDate(e,r){return e._pushTag(Jn.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,Qt.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(Jn.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,Qt.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(Jn.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=Jn.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=Jn.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=mr.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(Jn.DECIMAL_FRAC)&&e._pushInt(2,Qt.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new jc(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(Ab)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,Qt.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(e){if(!e)return this._pushUInt8(n0);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,Qt.MAP)?this._pushRawMap(o,s.map(c=>[c,e[c]])):!1}_pushRawMap(e,r){r=r.map(function(i){return i[0]=t.encode(i[0]),i}).sort(kc.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=Rb(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,mr.isBuffer(e)?e:mr.from(e));case"Null":return this._pushUInt8(n0);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 r0.NULL:return this._pushObject(null);case r0.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 c=mr.allocUnsafe(s),a=0,l=0;for(o=0;o<i;o++){switch(l=r[o],n[o]){case 0:e[o].copy(c,a);break;case 1:c.writeUInt8(e[o],a,!0);break;case 2:c.writeUInt16BE(e[o],a,!0);break;case 3:c.writeUInt32BE(e[o],a,!0);break;case 4:c.writeDoubleBE(e[o],a,!0);break;case 5:c.write(e[o],a,l,"utf8");break;default:throw new Error("unkown method")}a+=l}var d=c;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()}};i0.exports=Hc});var Lc=re(Je=>{"use strict";Je.Diagnose=e0();Je.Decoder=Mc();Je.Encoder=s0();Je.Simple=Nc();Je.Tagged=Rc();Je.decodeAll=Je.Decoder.decodeAll;Je.decodeFirst=Je.Decoder.decodeFirst;Je.diagnose=Je.Diagnose.diagnose;Je.encode=Je.Encoder.encode;Je.decode=Je.Decoder.decode;Je.leveldb={decode:Je.Decoder.decodeAll,encode:Je.Encoder.encode,buffer:!0,name:"cbor"}});var Hi=re(Dt=>{"use strict";var Pb=Dt&&Dt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Dt,"__esModule",{value:!0});Dt.hashOfMap=Dt.requestIdOf=Dt.hashValue=Dt.hash=void 0;var o0=Fi(),Ub=Pb(Lc()),Fb=Fs(),ki=It();function Yr(t){return(0,ki.uint8ToBuf)(Fb.sha256.create().update(new Uint8Array(t)).digest())}Dt.hash=Yr;function ji(t){if(t instanceof Ub.default.Tagged)return ji(t.value);if(typeof t=="string")return a0(t);if(typeof t=="number")return Yr((0,o0.lebEncode)(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return Yr(t);if(Array.isArray(t)){let e=t.map(ji);return Yr((0,ki.concat)(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return Yr(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return ji(t.toHash());if(typeof t=="object")return Vc(t);if(typeof t=="bigint")return Yr((0,o0.lebEncode)(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}Dt.hashValue=ji;var a0=t=>{let e=new TextEncoder().encode(t);return Yr(e)};function Mb(t){return Vc(t)}Dt.requestIdOf=Mb;function Vc(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,c])=>{let a=a0(o),l=ji(c);return[a,l]}).sort(([o],[c])=>(0,ki.compare)(o,c)),i=(0,ki.concat)(...n.map(o=>(0,ki.concat)(...o)));return Yr(i)}Dt.hashOfMap=Vc});var Dc=re(wr=>{"use strict";var qb=wr&&wr.__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(wr,"__esModule",{value:!0});wr.createIdentityDescriptor=wr.AnonymousIdentity=wr.SignIdentity=void 0;var c0=$t(),Cb=Hi(),u0=It(),kb=new TextEncoder().encode(`
|
|
17
|
+
ic-request`),$c=class{getPrincipal(){return this._principal||(this._principal=c0.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=qb(e,["body"]),i=await(0,Cb.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,u0.concat)(kb,i))}})}};wr.SignIdentity=$c;var Gc=class{getPrincipal(){return c0.Principal.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};wr.AnonymousIdentity=Gc;function jb(t){return"getPublicKey"in t?{type:"PublicKeyIdentity",publicKey:(0,u0.toHex)(t.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}wr.createIdentityDescriptor=jb});var Wc=re(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});var Hb=9007199254740992;function Fr(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 Jt(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 co(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 Jt(t,r,e.toString(16))}}function f0(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 Fr(new Uint8Array(co(3,t.length)),new Uint8Array(e))}function Lb(t,e){if(t==14277111)return Fr(new Uint8Array([217,217,247]),e);if(t<24)return Fr(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=Lb;function Li(t){return new Uint8Array(t).buffer}Ve.raw=Li;function Kc(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=Kc;function l0(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),Jt(0,24,t)}Ve.u8=l0;function d0(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),Jt(0,25,t)}Ve.u16=d0;function h0(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),Jt(0,26,t)}Ve.u32=h0;function zc(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return Jt(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),Hb),t=t.toString(16),Jt(0,27,t)}Ve.u64=zc;function p0(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return Kc(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}Ve.iSmall=p0;function y0(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),Jt(1,24,t)}Ve.i8=y0;function b0(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),Jt(1,25,t)}Ve.i16=b0;function g0(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),Jt(1,26,t)}Ve.i32=g0;function m0(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?Jt(1,27,n):zc(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),Jt(1,27,t)}Ve.i64=m0;function Vb(t){return t>=0?t<24?Kc(t):t<=255?l0(t):t<=65535?d0(t):t<=4294967295?h0(t):zc(t):t>=-24?p0(t):t>=-255?y0(t):t>=-65535?b0(t):t>=-4294967295?g0(t):m0(t)}Ve.number=Vb;function $b(t){return Fr(co(2,t.byteLength),t)}Ve.bytes=$b;function Gb(t){return f0(t)}Ve.string=Gb;function Db(t){return Fr(co(4,t.length),...t)}Ve.array=Db;function Kb(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))),Fr(co(5,t.size),...r.map(([n,i])=>Fr(f0(n),i)))}Ve.map=Kb;function zb(t){let e=new Float32Array([t]);return Fr(new Uint8Array([250]),new Uint8Array(e.buffer))}Ve.singleFloat=zb;function Wb(t){let e=new Float64Array([t]);return Fr(new Uint8Array([251]),new Uint8Array(e.buffer))}Ve.doubleFloat=Wb;function Yb(t){return t?w0():_0()}Ve.bool=Yb;function w0(){return Li(new Uint8Array([245]))}Ve.true_=w0;function _0(){return Li(new Uint8Array([244]))}Ve.false_=_0;function Zb(){return Li(new Uint8Array([246]))}Ve.null_=Zb;function Xb(){return Li(new Uint8Array([247]))}Ve.undefined_=Xb});var E0=re(Zr=>{"use strict";var Qb=Zr&&Zr.__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(Zr,"__esModule",{value:!0});var er=Qb(Wc()),Jb=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],uo=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 er.undefined_();case"boolean":return er.bool(e);case"number":return Math.floor(e)===e?er.number(e):er.doubleFloat(e);case"string":return er.string(e);case"object":if(e===null)return er.null_();if(Array.isArray(e))return er.array(e.map(r=>this._serializer.serializeValue(r)));if(Jb.find(r=>e instanceof r))return er.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 er.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 er.map(r,this._stable)}default:throw new Error("Invalid value.")}}};Zr.JsonDefaultCborEncoder=uo;var fo=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};Zr.ToCborEncoder=fo;var lo=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new uo(r,e)),r.addEncoder(new fo),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)}};Zr.CborSerializer=lo;var Yc=class extends lo{serialize(e){return er.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};Zr.SelfDescribeCborSerializer=Yc});var ho=re(wn=>{"use strict";function eg(t){for(var e in t)wn.hasOwnProperty(e)||(wn[e]=t[e])}var tg=wn&&wn.__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(wn,"__esModule",{value:!0});eg(E0());var rg=tg(Wc());wn.value=rg});var Vi=re(ut=>{"use strict";var ng=ut&&ut.__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]}),ig=ut&&ut.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),sg=ut&&ut.__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)&&ng(e,t,r);return ig(e,t),e},og=ut&&ut.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ut,"__esModule",{value:!0});ut.decode=ut.encode=ut.CborTag=void 0;var ag=og(Lc()),ei=sg(ho()),cg=ho(),po=It(),Zc=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return ei.value.bytes(e.toUint8Array())}},Xc=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return ei.value.bytes(new Uint8Array(e))}},Qc=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?ei.value.tagged(2,ei.value.bytes((0,po.fromHex)(e.toString(16)))):ei.value.tagged(3,ei.value.bytes((0,po.fromHex)((BigInt("-1")*e).toString(16))))}},yo=cg.SelfDescribeCborSerializer.withDefaultEncoders(!0);yo.addEncoder(new Zc);yo.addEncoder(new Xc);yo.addEncoder(new Qc);var v0;(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(v0=ut.CborTag||(ut.CborTag={}));function ug(t){return yo.serialize(t)}ut.encode=ug;function x0(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 Jc=class extends ag.default.Decoder{createByteString(e){return(0,po.concat)(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}};function fg(t){let e=new Uint8Array(t),r=new Jc({size:e.byteLength,tags:{2:n=>x0(n),3:n=>-x0(n),[v0.Semantic]:n=>n}});try{return r.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,po.toHex)(e)}`)}}ut.decode=fg});var eu=re(bo=>{"use strict";Object.defineProperty(bo,"__esModule",{value:!0});bo.randomNumber=void 0;var lg=()=>{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)};bo.randomNumber=lg});var $i=re(_n=>{"use strict";Object.defineProperty(_n,"__esModule",{value:!0});_n.makeNonce=_n.SubmitRequestType=void 0;var go=eu(),dg;(function(t){t.Call="call"})(dg=_n.SubmitRequestType||(_n.SubmitRequestType={}));function hg(){let t=new ArrayBuffer(16),e=new DataView(t),r=(0,go.randomNumber)(),n=(0,go.randomNumber)(),i=(0,go.randomNumber)(),s=(0,go.randomNumber)();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}_n.makeNonce=hg});var wo=re(yt=>{"use strict";var pg=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]}),yg=yt&&yt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),bg=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)&&pg(e,t,r);return yg(e,t),e};Object.defineProperty(yt,"__esModule",{value:!0});yt.httpHeadersTransform=yt.makeExpiryTransform=yt.makeNonceTransform=yt.Expiry=void 0;var gg=Fi(),mg=bg(ho()),wg=$i(),B0=BigInt(1e6),_g=60*1e3,mo=class{constructor(e){if(e<90*1e3){let c=BigInt(Date.now()+e)*B0/BigInt(1e9);this._value=c*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+e-_g))*B0/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return mg.value.u64(this._value.toString(16),16)}toHash(){return(0,gg.lebEncode)(this._value)}};yt.Expiry=mo;function Eg(t=wg.makeNonce){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}yt.makeNonceTransform=Eg;function xg(t){return async e=>{e.body.ingress_expiry=new mo(t)}}yt.makeExpiryTransform=xg;function vg(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}yt.httpHeadersTransform=vg});var ru=re(_o=>{"use strict";Object.defineProperty(_o,"__esModule",{value:!0});_o.AgentHTTPResponseError=void 0;var Bg=Dn(),tu=class extends Bg.AgentError{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};_o.AgentHTTPResponseError=tu});var Mt=re(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.notImplemented=Pe.bitMask=void 0;Pe.isBytes=xo;Pe.abytes=vo;Pe.abool=Sg;Pe.bytesToHex=ou;Pe.numberToHexUnpadded=A0;Pe.hexToNumber=au;Pe.hexToBytes=Bo;Pe.bytesToNumberBE=Ig;Pe.bytesToNumberLE=Ng;Pe.numberToBytesBE=I0;Pe.numberToBytesLE=Og;Pe.numberToVarBytesBE=Rg;Pe.ensureBytes=Pg;Pe.concatBytes=N0;Pe.equalBytes=Ug;Pe.utf8ToBytes=Fg;Pe.inRange=O0;Pe.aInRange=Mg;Pe.bitLen=qg;Pe.bitGet=Cg;Pe.bitSet=kg;Pe.createHmacDrbg=Hg;Pe.validateObject=Vg;Pe.memoized=Gg;var su=BigInt(0),Eo=BigInt(1),Tg=BigInt(2);function xo(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function vo(t){if(!xo(t))throw new Error("Uint8Array expected")}function Sg(t,e){if(typeof e!="boolean")throw new Error(`${t} must be valid boolean, got "${e}".`)}var Ag=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ou(t){vo(t);let e="";for(let r=0;r<t.length;r++)e+=Ag[t[r]];return e}function A0(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function au(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var Mr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function T0(t){if(t>=Mr._0&&t<=Mr._9)return t-Mr._0;if(t>=Mr._A&&t<=Mr._F)return t-(Mr._A-10);if(t>=Mr._a&&t<=Mr._f)return t-(Mr._a-10)}function Bo(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=T0(t.charCodeAt(s)),c=T0(t.charCodeAt(s+1));if(o===void 0||c===void 0){let a=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[i]=o*16+c}return n}function Ig(t){return au(ou(t))}function Ng(t){return vo(t),au(ou(Uint8Array.from(t).reverse()))}function I0(t,e){return Bo(t.toString(16).padStart(e*2,"0"))}function Og(t,e){return I0(t,e).reverse()}function Rg(t){return Bo(A0(t))}function Pg(t,e,r){let n;if(typeof e=="string")try{n=Bo(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(xo(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 N0(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];vo(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 Ug(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 Fg(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}var nu=t=>typeof t=="bigint"&&su<=t;function O0(t,e,r){return nu(t)&&nu(e)&&nu(r)&&e<=t&&t<r}function Mg(t,e,r,n){if(!O0(e,r,n))throw new Error(`expected valid ${t}: ${r} <= n < ${n}, got ${typeof e} ${e}`)}function qg(t){let e;for(e=0;t>su;t>>=Eo,e+=1);return e}function Cg(t,e){return t>>BigInt(e)&Eo}function kg(t,e,r){return t|(r?Eo:su)<<BigInt(e)}var jg=t=>(Tg<<BigInt(t-1))-Eo;Pe.bitMask=jg;var iu=t=>new Uint8Array(t),S0=t=>Uint8Array.from(t);function Hg(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=iu(t),i=iu(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},c=(...b)=>r(i,n,...b),a=(b=iu())=>{i=c(S0([0]),b),n=c(),b.length!==0&&(i=c(S0([1]),b),n=c())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let b=0,m=[];for(;b<e;){n=c();let _=n.slice();m.push(_),b+=n.length}return N0(...m)};return(b,m)=>{o(),a(b);let _;for(;!(_=m(l()));)a();return o(),_}}var Lg={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"||xo(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 Vg(t,e,r={}){let n=(i,s,o)=>{let c=Lg[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);let a=t[i];if(!(o&&a===void 0)&&!c(a,t))throw new Error(`Invalid param ${String(i)}=${a} (${typeof a}), 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 $g=()=>{throw new Error("not implemented")};Pe.notImplemented=$g;function Gg(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 _r=re(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});Ke.isNegativeLE=void 0;Ke.mod=qt;Ke.pow=U0;Ke.pow2=Wg;Ke.invert=To;Ke.tonelliShanks=F0;Ke.FpSqrt=M0;Ke.validateField=Xg;Ke.FpPow=q0;Ke.FpInvertBatch=C0;Ke.FpDiv=Qg;Ke.FpLegendre=k0;Ke.FpIsSquare=Jg;Ke.nLength=uu;Ke.Field=em;Ke.FpSqrtOdd=tm;Ke.FpSqrtEven=rm;Ke.hashToPrivateScalar=nm;Ke.getFieldBytesLength=fu;Ke.getMinHashLength=j0;Ke.mapHashToField=im;var Ct=Mt(),et=BigInt(0),He=BigInt(1),Xr=BigInt(2),Dg=BigInt(3),cu=BigInt(4),R0=BigInt(5),P0=BigInt(8),Kg=BigInt(9),zg=BigInt(16);function qt(t,e){let r=t%e;return r>=et?r:e+r}function U0(t,e,r){if(r<=et||e<et)throw new Error("Expected power/modulo > 0");if(r===He)return et;let n=He;for(;e>et;)e&He&&(n=n*t%r),t=t*t%r,e>>=He;return n}function Wg(t,e,r){let n=t;for(;e-- >et;)n*=n,n%=r;return n}function To(t,e){if(t===et||e<=et)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=qt(t,e),n=e,i=et,s=He,o=He,c=et;for(;r!==et;){let l=n/r,d=n%r,b=i-o*l,m=s-c*l;n=r,r=d,i=o,s=c,o=b,c=m}if(n!==He)throw new Error("invert: does not exist");return qt(i,e)}function F0(t){let e=(t-He)/Xr,r,n,i;for(r=t-He,n=0;r%Xr===et;r/=Xr,n++);for(i=Xr;i<t&&U0(i,e,t)!==t-He;i++);if(n===1){let o=(t+He)/cu;return function(a,l){let d=a.pow(l,o);if(!a.eql(a.sqr(d),l))throw new Error("Cannot find square root");return d}}let s=(r+He)/Xr;return function(c,a){if(c.pow(a,e)===c.neg(c.ONE))throw new Error("Cannot find square root");let l=n,d=c.pow(c.mul(c.ONE,i),r),b=c.pow(a,s),m=c.pow(a,r);for(;!c.eql(m,c.ONE);){if(c.eql(m,c.ZERO))return c.ZERO;let _=1;for(let S=c.sqr(m);_<l&&!c.eql(S,c.ONE);_++)S=c.sqr(S);let f=c.pow(d,He<<BigInt(l-_-1));d=c.sqr(f),b=c.mul(b,f),m=c.mul(m,d),l=_}return b}}function M0(t){if(t%cu===Dg){let e=(t+He)/cu;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%P0===R0){let e=(t-R0)/P0;return function(n,i){let s=n.mul(i,Xr),o=n.pow(s,e),c=n.mul(i,o),a=n.mul(n.mul(c,Xr),o),l=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(l),i))throw new Error("Cannot find square root");return l}}return t%zg,F0(t)}var Yg=(t,e)=>(qt(t,e)&He)===He;Ke.isNegativeLE=Yg;var Zg=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Xg(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Zg.reduce((n,i)=>(n[i]="function",n),e);return(0,Ct.validateObject)(t,r)}function q0(t,e,r){if(r<et)throw new Error("Expected power > 0");if(r===et)return t.ONE;if(r===He)return e;let n=t.ONE,i=e;for(;r>et;)r&He&&(n=t.mul(n,i)),i=t.sqr(i),r>>=He;return n}function C0(t,e){let r=new Array(e.length),n=e.reduce((s,o,c)=>t.is0(o)?s:(r[c]=s,t.mul(s,o)),t.ONE),i=t.inv(n);return e.reduceRight((s,o,c)=>t.is0(o)?s:(r[c]=t.mul(s,r[c]),t.mul(s,o)),i),r}function Qg(t,e,r){return t.mul(e,typeof r=="bigint"?To(r,t.ORDER):t.inv(r))}function k0(t){let e=(t-He)/Xr;return(r,n)=>r.pow(n,e)}function Jg(t){let e=k0(t.ORDER);return r=>{let n=e(t,r);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}}function uu(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function em(t,e,r=!1,n={}){if(t<=et)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=uu(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=M0(t),c=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:(0,Ct.bitMask)(i),ZERO:et,ONE:He,create:a=>qt(a,t),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return et<=a&&a<t},is0:a=>a===et,isOdd:a=>(a&He)===He,neg:a=>qt(-a,t),eql:(a,l)=>a===l,sqr:a=>qt(a*a,t),add:(a,l)=>qt(a+l,t),sub:(a,l)=>qt(a-l,t),mul:(a,l)=>qt(a*l,t),pow:(a,l)=>q0(c,a,l),div:(a,l)=>qt(a*To(l,t),t),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>To(a,t),sqrt:n.sqrt||(a=>o(c,a)),invertBatch:a=>C0(c,a),cmov:(a,l,d)=>d?l:a,toBytes:a=>r?(0,Ct.numberToBytesLE)(a,s):(0,Ct.numberToBytesBE)(a,s),fromBytes:a=>{if(a.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${a.length}`);return r?(0,Ct.bytesToNumberLE)(a):(0,Ct.bytesToNumberBE)(a)}});return Object.freeze(c)}function tm(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 rm(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 nm(t,e,r=!1){t=(0,Ct.ensureBytes)("privateHash",t);let n=t.length,i=uu(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,Ct.bytesToNumberLE)(t):(0,Ct.bytesToNumberBE)(t);return qt(s,e-He)+He}function fu(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 j0(t){let e=fu(t);return e+Math.ceil(e/2)}function im(t,e,r=!1){let n=t.length,i=fu(e),s=j0(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?(0,Ct.bytesToNumberBE)(t):(0,Ct.bytesToNumberLE)(t),c=qt(o,e-He)+He;return r?(0,Ct.numberToBytesLE)(c,i):(0,Ct.numberToBytesBE)(c,i)}});var So=re(En=>{"use strict";Object.defineProperty(En,"__esModule",{value:!0});En.expand_message_xmd=H0;En.expand_message_xof=L0;En.hash_to_field=lu;En.isogenyMap=cm;En.createHasher=um;var sm=_r(),bt=Mt(),om=bt.bytesToNumberBE;function Qr(t,e){if(Gi(t),Gi(e),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 am(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 Gi(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function H0(t,e,r,n){(0,bt.abytes)(t),(0,bt.abytes)(e),Gi(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(r>65535||o>255)throw new Error("expand_message_xmd: invalid lenInBytes");let c=(0,bt.concatBytes)(e,Qr(e.length,1)),a=Qr(0,s),l=Qr(r,2),d=new Array(o),b=n((0,bt.concatBytes)(a,t,l,Qr(0,1),c));d[0]=n((0,bt.concatBytes)(b,Qr(1,1),c));for(let _=1;_<=o;_++){let f=[am(b,d[_-1]),Qr(_+1,1),c];d[_]=n((0,bt.concatBytes)(...f))}return(0,bt.concatBytes)(...d).slice(0,r)}function L0(t,e,r,n,i){if((0,bt.abytes)(t),(0,bt.abytes)(e),Gi(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(Qr(r,2)).update(e).update(Qr(e.length,1)).digest()}function lu(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:c,DST:a}=r;(0,bt.abytes)(t),Gi(e);let l=typeof a=="string"?(0,bt.utf8ToBytes)(a):a,d=n.toString(2).length,b=Math.ceil((d+i)/8),m=e*s*b,_;if(c==="xmd")_=H0(t,l,m,o);else if(c==="xof")_=L0(t,l,m,i,o);else if(c==="_internal_pass")_=t;else throw new Error('expand must be "xmd" or "xof"');let f=new Array(e);for(let S=0;S<e;S++){let O=new Array(s);for(let F=0;F<s;F++){let q=b*(F+S*s),M=_.subarray(q,q+b);O[F]=(0,sm.mod)(om(M),n)}f[S]=O}return f}function cm(t,e){let r=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,c,a]=r.map(l=>l.reduce((d,b)=>t.add(t.mul(d,n),b)));return n=t.div(s,o),i=t.mul(i,t.div(c,a)),{x:n,y:i}}}function um(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=lu(n,2,{...r,DST:r.DST,...i}),o=t.fromAffine(e(s[0])),c=t.fromAffine(e(s[1])),a=o.add(c).clearCofactor();return a.assertValidity(),a},encodeToCurve(n,i){let s=lu(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 pu=re(Di=>{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});Di.wNAF=lm;Di.pippenger=dm;Di.validateBasic=hm;var V0=_r(),G0=Mt(),fm=BigInt(0),du=BigInt(1),hu=new WeakMap,$0=new WeakMap;function lm(t,e){let r=(s,o)=>{let c=o.negate();return s?c: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,c=2**(s-1);return{windows:o,windowSize:c}};return{constTimeNegate:r,unsafeLadder(s,o){let c=t.ZERO,a=s;for(;o>fm;)o&du&&(c=c.add(a)),a=a.double(),o>>=du;return c},precomputeWindow(s,o){let{windows:c,windowSize:a}=i(o),l=[],d=s,b=d;for(let m=0;m<c;m++){b=d,l.push(b);for(let _=1;_<a;_++)b=b.add(d),l.push(b);d=b.double()}return l},wNAF(s,o,c){let{windows:a,windowSize:l}=i(s),d=t.ZERO,b=t.BASE,m=BigInt(2**s-1),_=2**s,f=BigInt(s);for(let S=0;S<a;S++){let O=S*l,F=Number(c&m);c>>=f,F>l&&(F-=_,c+=du);let q=O,M=O+Math.abs(F)-1,$=S%2!==0,v=F<0;F===0?b=b.add(r($,o[q])):d=d.add(r(v,o[M]))}return{p:d,f:b}},wNAFCached(s,o,c){let a=$0.get(s)||1,l=hu.get(s);return l||(l=this.precomputeWindow(s,a),a!==1&&hu.set(s,c(l))),this.wNAF(a,l,o)},setWindowSize(s,o){n(o),$0.set(s,o),hu.delete(s)}}}function dm(t,e,r,n){if(!Array.isArray(r)||!Array.isArray(n)||n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((d,b)=>{if(!e.isValid(d))throw new Error(`wrong scalar at index ${b}`)}),r.forEach((d,b)=>{if(!(d instanceof t))throw new Error(`wrong point at index ${b}`)});let i=(0,G0.bitLen)(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<<s)-1,c=new Array(o+1).fill(t.ZERO),a=Math.floor((e.BITS-1)/s)*s,l=t.ZERO;for(let d=a;d>=0;d-=s){c.fill(t.ZERO);for(let m=0;m<n.length;m++){let _=n[m],f=Number(_>>BigInt(d)&BigInt(o));c[f]=c[f].add(r[m])}let b=t.ZERO;for(let m=c.length-1,_=t.ZERO;m>0;m--)_=_.add(c[m]),b=b.add(_);if(l=l.add(b),d!==0)for(let m=0;m<s;m++)l=l.double()}return l}function hm(t){return(0,V0.validateField)(t.Fp),(0,G0.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,V0.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}});var yu=re(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.DER=void 0;lt.weierstrassPoints=z0;lt.weierstrass=mm;lt.SWUFpSqrtRatio=W0;lt.mapToCurveSimpleSWU=wm;var Ao=pu(),xn=_r(),Te=Mt(),ft=Mt();function D0(t){t.lowS!==void 0&&(0,ft.abool)("lowS",t.lowS),t.prehash!==void 0&&(0,ft.abool)("prehash",t.prehash)}function pm(t){let e=(0,Ao.validateBasic)(t);Te.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:ym,hexToBytes:bm}=Te;lt.DER={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(t,e)=>{let{Err:r}=lt.DER;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,i=Te.numberToHexUnpadded(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?Te.numberToHexUnpadded(i.length/2|128):"";return`${Te.numberToHexUnpadded(t)}${s}${i}${e}`},decode(t,e){let{Err:r}=lt.DER,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let i=e[n++],s=!!(i&128),o=0;if(!s)o=i;else{let a=i&127;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let l=e.subarray(n,n+a);if(l.length!==a)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of l)o=o<<8|d;if(n+=a,o<128)throw new r("tlv.decode(long): not minimal encoding")}let c=e.subarray(n,n+o);if(c.length!==o)throw new r("tlv.decode: wrong value length");return{v:c,l:e.subarray(n+o)}}},_int:{encode(t){let{Err:e}=lt.DER;if(t<tr)throw new e("integer: negative integers are not allowed");let r=Te.numberToHexUnpadded(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected assertion");return r},decode(t){let{Err:e}=lt.DER;if(t[0]&128)throw new e("Invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return ym(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=lt.DER,i=typeof t=="string"?bm(t):t;Te.abytes(i);let{v:s,l:o}=n.decode(48,i);if(o.length)throw new e("Invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:l,l:d}=n.decode(2,a);if(d.length)throw new e("Invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(l)}},hexFromSig(t){let{_tlv:e,_int:r}=lt.DER,n=`${e.encode(2,r.encode(t.r))}${e.encode(2,r.encode(t.s))}`;return e.encode(48,n)}};var tr=BigInt(0),Ce=BigInt(1),Jr=BigInt(2),Io=BigInt(3),K0=BigInt(4);function z0(t){let e=pm(t),{Fp:r}=e,n=xn.Field(e.n,e.nBitLength),i=e.toBytes||((S,O,F)=>{let q=O.toAffine();return Te.concatBytes(Uint8Array.from([4]),r.toBytes(q.x),r.toBytes(q.y))}),s=e.fromBytes||(S=>{let O=S.subarray(1),F=r.fromBytes(O.subarray(0,r.BYTES)),q=r.fromBytes(O.subarray(r.BYTES,2*r.BYTES));return{x:F,y:q}});function o(S){let{a:O,b:F}=e,q=r.sqr(S),M=r.mul(q,S);return r.add(r.add(M,r.mul(S,O)),F)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function c(S){return Te.inRange(S,Ce,e.n)}function a(S){let{allowedPrivateKeyLengths:O,nByteLength:F,wrapPrivateKey:q,n:M}=e;if(O&&typeof S!="bigint"){if(Te.isBytes(S)&&(S=Te.bytesToHex(S)),typeof S!="string"||!O.includes(S.length))throw new Error("Invalid key");S=S.padStart(F*2,"0")}let $;try{$=typeof S=="bigint"?S:Te.bytesToNumberBE((0,ft.ensureBytes)("private key",S,F))}catch{throw new Error(`private key must be ${F} bytes, hex or bigint, not ${typeof S}`)}return q&&($=xn.mod($,M)),Te.aInRange("private key",$,Ce,M),$}function l(S){if(!(S instanceof m))throw new Error("ProjectivePoint expected")}let d=(0,ft.memoized)((S,O)=>{let{px:F,py:q,pz:M}=S;if(r.eql(M,r.ONE))return{x:F,y:q};let $=S.is0();O==null&&(O=$?r.ONE:r.inv(M));let v=r.mul(F,O),V=r.mul(q,O),K=r.mul(M,O);if($)return{x:r.ZERO,y:r.ZERO};if(!r.eql(K,r.ONE))throw new Error("invZ was invalid");return{x:v,y:V}}),b=(0,ft.memoized)(S=>{if(S.is0()){if(e.allowInfinityPoint&&!r.is0(S.py))return;throw new Error("bad point: ZERO")}let{x:O,y:F}=S.toAffine();if(!r.isValid(O)||!r.isValid(F))throw new Error("bad point: x or y not FE");let q=r.sqr(F),M=o(O);if(!r.eql(q,M))throw new Error("bad point: equation left != right");if(!S.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(O,F,q){if(this.px=O,this.py=F,this.pz=q,O==null||!r.isValid(O))throw new Error("x required");if(F==null||!r.isValid(F))throw new Error("y required");if(q==null||!r.isValid(q))throw new Error("z required");Object.freeze(this)}static fromAffine(O){let{x:F,y:q}=O||{};if(!O||!r.isValid(F)||!r.isValid(q))throw new Error("invalid affine point");if(O instanceof m)throw new Error("projective point not allowed");let M=$=>r.eql($,r.ZERO);return M(F)&&M(q)?m.ZERO:new m(F,q,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(O){let F=r.invertBatch(O.map(q=>q.pz));return O.map((q,M)=>q.toAffine(F[M])).map(m.fromAffine)}static fromHex(O){let F=m.fromAffine(s((0,ft.ensureBytes)("pointHex",O)));return F.assertValidity(),F}static fromPrivateKey(O){return m.BASE.multiply(a(O))}static msm(O,F){return(0,Ao.pippenger)(m,n,O,F)}_setWindowSize(O){f.setWindowSize(this,O)}assertValidity(){b(this)}hasEvenY(){let{y:O}=this.toAffine();if(r.isOdd)return!r.isOdd(O);throw new Error("Field doesn't support isOdd")}equals(O){l(O);let{px:F,py:q,pz:M}=this,{px:$,py:v,pz:V}=O,K=r.eql(r.mul(F,V),r.mul($,M)),W=r.eql(r.mul(q,V),r.mul(v,M));return K&&W}negate(){return new m(this.px,r.neg(this.py),this.pz)}double(){let{a:O,b:F}=e,q=r.mul(F,Io),{px:M,py:$,pz:v}=this,V=r.ZERO,K=r.ZERO,W=r.ZERO,k=r.mul(M,M),se=r.mul($,$),ee=r.mul(v,v),ie=r.mul(M,$);return ie=r.add(ie,ie),W=r.mul(M,v),W=r.add(W,W),V=r.mul(O,W),K=r.mul(q,ee),K=r.add(V,K),V=r.sub(se,K),K=r.add(se,K),K=r.mul(V,K),V=r.mul(ie,V),W=r.mul(q,W),ee=r.mul(O,ee),ie=r.sub(k,ee),ie=r.mul(O,ie),ie=r.add(ie,W),W=r.add(k,k),k=r.add(W,k),k=r.add(k,ee),k=r.mul(k,ie),K=r.add(K,k),ee=r.mul($,v),ee=r.add(ee,ee),k=r.mul(ee,ie),V=r.sub(V,k),W=r.mul(ee,se),W=r.add(W,W),W=r.add(W,W),new m(V,K,W)}add(O){l(O);let{px:F,py:q,pz:M}=this,{px:$,py:v,pz:V}=O,K=r.ZERO,W=r.ZERO,k=r.ZERO,se=e.a,ee=r.mul(e.b,Io),ie=r.mul(F,$),w=r.mul(q,v),g=r.mul(M,V),A=r.add(F,q),T=r.add($,v);A=r.mul(A,T),T=r.add(ie,w),A=r.sub(A,T),T=r.add(F,M);let I=r.add($,V);return T=r.mul(T,I),I=r.add(ie,g),T=r.sub(T,I),I=r.add(q,M),K=r.add(v,V),I=r.mul(I,K),K=r.add(w,g),I=r.sub(I,K),k=r.mul(se,T),K=r.mul(ee,g),k=r.add(K,k),K=r.sub(w,k),k=r.add(w,k),W=r.mul(K,k),w=r.add(ie,ie),w=r.add(w,ie),g=r.mul(se,g),T=r.mul(ee,T),w=r.add(w,g),g=r.sub(ie,g),g=r.mul(se,g),T=r.add(T,g),ie=r.mul(w,T),W=r.add(W,ie),ie=r.mul(I,T),K=r.mul(A,K),K=r.sub(K,ie),ie=r.mul(A,w),k=r.mul(I,k),k=r.add(k,ie),new m(K,W,k)}subtract(O){return this.add(O.negate())}is0(){return this.equals(m.ZERO)}wNAF(O){return f.wNAFCached(this,O,m.normalizeZ)}multiplyUnsafe(O){Te.aInRange("scalar",O,tr,e.n);let F=m.ZERO;if(O===tr)return F;if(O===Ce)return this;let{endo:q}=e;if(!q)return f.unsafeLadder(this,O);let{k1neg:M,k1:$,k2neg:v,k2:V}=q.splitScalar(O),K=F,W=F,k=this;for(;$>tr||V>tr;)$&Ce&&(K=K.add(k)),V&Ce&&(W=W.add(k)),k=k.double(),$>>=Ce,V>>=Ce;return M&&(K=K.negate()),v&&(W=W.negate()),W=new m(r.mul(W.px,q.beta),W.py,W.pz),K.add(W)}multiply(O){let{endo:F,n:q}=e;Te.aInRange("scalar",O,Ce,q);let M,$;if(F){let{k1neg:v,k1:V,k2neg:K,k2:W}=F.splitScalar(O),{p:k,f:se}=this.wNAF(V),{p:ee,f:ie}=this.wNAF(W);k=f.constTimeNegate(v,k),ee=f.constTimeNegate(K,ee),ee=new m(r.mul(ee.px,F.beta),ee.py,ee.pz),M=k.add(ee),$=se.add(ie)}else{let{p:v,f:V}=this.wNAF(O);M=v,$=V}return m.normalizeZ([M,$])[0]}multiplyAndAddUnsafe(O,F,q){let M=m.BASE,$=(V,K)=>K===tr||K===Ce||!V.equals(M)?V.multiplyUnsafe(K):V.multiply(K),v=$(this,F).add($(O,q));return v.is0()?void 0:v}toAffine(O){return d(this,O)}isTorsionFree(){let{h:O,isTorsionFree:F}=e;if(O===Ce)return!0;if(F)return F(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:O,clearCofactor:F}=e;return O===Ce?this:F?F(m,this):this.multiplyUnsafe(e.h)}toRawBytes(O=!0){return(0,ft.abool)("isCompressed",O),this.assertValidity(),i(m,this,O)}toHex(O=!0){return(0,ft.abool)("isCompressed",O),Te.bytesToHex(this.toRawBytes(O))}}m.BASE=new m(e.Gx,e.Gy,r.ONE),m.ZERO=new m(r.ZERO,r.ONE,r.ZERO);let _=e.nBitLength,f=(0,Ao.wNAF)(m,e.endo?Math.ceil(_/2):_);return{CURVE:e,ProjectivePoint:m,normPrivateKeyToScalar:a,weierstrassEquation:o,isWithinCurveOrder:c}}function gm(t){let e=(0,Ao.validateBasic)(t);return Te.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function mm(t){let e=gm(t),{Fp:r,n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function o(g){return xn.mod(g,n)}function c(g){return xn.invert(g,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:l,weierstrassEquation:d,isWithinCurveOrder:b}=z0({...e,toBytes(g,A,T){let I=A.toAffine(),L=r.toBytes(I.x),Y=Te.concatBytes;return(0,ft.abool)("isCompressed",T),T?Y(Uint8Array.from([A.hasEvenY()?2:3]),L):Y(Uint8Array.from([4]),L,r.toBytes(I.y))},fromBytes(g){let A=g.length,T=g[0],I=g.subarray(1);if(A===i&&(T===2||T===3)){let L=Te.bytesToNumberBE(I);if(!Te.inRange(L,Ce,r.ORDER))throw new Error("Point is not on curve");let Y=d(L),ce;try{ce=r.sqrt(Y)}catch(U){let h=U instanceof Error?": "+U.message:"";throw new Error("Point is not on curve"+h)}let oe=(ce&Ce)===Ce;return(T&1)===1!==oe&&(ce=r.neg(ce)),{x:L,y:ce}}else if(A===s&&T===4){let L=r.fromBytes(I.subarray(0,r.BYTES)),Y=r.fromBytes(I.subarray(r.BYTES,2*r.BYTES));return{x:L,y:Y}}else throw new Error(`Point of length ${A} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),m=g=>Te.bytesToHex(Te.numberToBytesBE(g,e.nByteLength));function _(g){let A=n>>Ce;return g>A}function f(g){return _(g)?o(-g):g}let S=(g,A,T)=>Te.bytesToNumberBE(g.slice(A,T));class O{constructor(A,T,I){this.r=A,this.s=T,this.recovery=I,this.assertValidity()}static fromCompact(A){let T=e.nByteLength;return A=(0,ft.ensureBytes)("compactSignature",A,T*2),new O(S(A,0,T),S(A,T,2*T))}static fromDER(A){let{r:T,s:I}=lt.DER.toSig((0,ft.ensureBytes)("DER",A));return new O(T,I)}assertValidity(){Te.aInRange("r",this.r,Ce,n),Te.aInRange("s",this.s,Ce,n)}addRecoveryBit(A){return new O(this.r,this.s,A)}recoverPublicKey(A){let{r:T,s:I,recovery:L}=this,Y=V((0,ft.ensureBytes)("msgHash",A));if(L==null||![0,1,2,3].includes(L))throw new Error("recovery id invalid");let ce=L===2||L===3?T+e.n:T;if(ce>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let oe=L&1?"03":"02",z=a.fromHex(oe+m(ce)),U=c(ce),h=o(-Y*U),X=o(I*U),te=a.BASE.multiplyAndAddUnsafe(z,h,X);if(!te)throw new Error("point at infinify");return te.assertValidity(),te}hasHighS(){return _(this.s)}normalizeS(){return this.hasHighS()?new O(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Te.hexToBytes(this.toDERHex())}toDERHex(){return lt.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Te.hexToBytes(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let F={isValidPrivateKey(g){try{return l(g),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let g=xn.getMinHashLength(e.n);return xn.mapHashToField(e.randomBytes(g),e.n)},precompute(g=8,A=a.BASE){return A._setWindowSize(g),A.multiply(BigInt(3)),A}};function q(g,A=!0){return a.fromPrivateKey(g).toRawBytes(A)}function M(g){let A=Te.isBytes(g),T=typeof g=="string",I=(A||T)&&g.length;return A?I===i||I===s:T?I===2*i||I===2*s:g instanceof a}function $(g,A,T=!0){if(M(g))throw new Error("first arg must be private key");if(!M(A))throw new Error("second arg must be public key");return a.fromHex(A).multiply(l(g)).toRawBytes(T)}let v=e.bits2int||function(g){let A=Te.bytesToNumberBE(g),T=g.length*8-e.nBitLength;return T>0?A>>BigInt(T):A},V=e.bits2int_modN||function(g){return o(v(g))},K=Te.bitMask(e.nBitLength);function W(g){return Te.aInRange(`num < 2^${e.nBitLength}`,g,tr,K),Te.numberToBytesBE(g,e.nByteLength)}function k(g,A,T=se){if(["recovered","canonical"].some(Q=>Q in T))throw new Error("sign() legacy options not supported");let{hash:I,randomBytes:L}=e,{lowS:Y,prehash:ce,extraEntropy:oe}=T;Y==null&&(Y=!0),g=(0,ft.ensureBytes)("msgHash",g),D0(T),ce&&(g=(0,ft.ensureBytes)("prehashed msgHash",I(g)));let z=V(g),U=l(A),h=[W(U),W(z)];if(oe!=null&&oe!==!1){let Q=oe===!0?L(r.BYTES):oe;h.push((0,ft.ensureBytes)("extraEntropy",Q))}let X=Te.concatBytes(...h),te=z;function de(Q){let u=v(Q);if(!b(u))return;let p=c(u),y=a.BASE.multiply(u).toAffine(),R=o(y.x);if(R===tr)return;let B=o(p*o(te+R*U));if(B===tr)return;let N=(y.x===R?0:2)|Number(y.y&Ce),j=B;return Y&&_(B)&&(j=f(B),N^=1),new O(R,j,N)}return{seed:X,k2sig:de}}let se={lowS:e.lowS,prehash:!1},ee={lowS:e.lowS,prehash:!1};function ie(g,A,T=se){let{seed:I,k2sig:L}=k(g,A,T),Y=e;return Te.createHmacDrbg(Y.hash.outputLen,Y.nByteLength,Y.hmac)(I,L)}a.BASE._setWindowSize(8);function w(g,A,T,I=ee){let L=g;if(A=(0,ft.ensureBytes)("msgHash",A),T=(0,ft.ensureBytes)("publicKey",T),"strict"in I)throw new Error("options.strict was renamed to lowS");D0(I);let{lowS:Y,prehash:ce}=I,oe,z;try{if(typeof L=="string"||Te.isBytes(L))try{oe=O.fromDER(L)}catch(y){if(!(y instanceof lt.DER.Err))throw y;oe=O.fromCompact(L)}else if(typeof L=="object"&&typeof L.r=="bigint"&&typeof L.s=="bigint"){let{r:y,s:R}=L;oe=new O(y,R)}else throw new Error("PARSE");z=a.fromHex(T)}catch(y){if(y.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(Y&&oe.hasHighS())return!1;ce&&(A=e.hash(A));let{r:U,s:h}=oe,X=V(A),te=c(h),de=o(X*te),Q=o(U*te),u=a.BASE.multiplyAndAddUnsafe(z,de,Q)?.toAffine();return u?o(u.x)===U:!1}return{CURVE:e,getPublicKey:q,getSharedSecret:$,sign:ie,verify:w,ProjectivePoint:a,Signature:O,utils:F}}function W0(t,e){let r=t.ORDER,n=tr;for(let f=r-Ce;f%Jr===tr;f/=Jr)n+=Ce;let i=n,s=Jr<<i-Ce-Ce,o=s*Jr,c=(r-Ce)/o,a=(c-Ce)/Jr,l=o-Ce,d=s,b=t.pow(e,c),m=t.pow(e,(c+Ce)/Jr),_=(f,S)=>{let O=b,F=t.pow(S,l),q=t.sqr(F);q=t.mul(q,S);let M=t.mul(f,q);M=t.pow(M,a),M=t.mul(M,F),F=t.mul(M,S),q=t.mul(M,f);let $=t.mul(q,F);M=t.pow($,d);let v=t.eql(M,t.ONE);F=t.mul(q,m),M=t.mul($,O),q=t.cmov(F,q,v),$=t.cmov(M,$,v);for(let V=i;V>Ce;V--){let K=V-Jr;K=Jr<<K-Ce;let W=t.pow($,K),k=t.eql(W,t.ONE);F=t.mul(q,O),O=t.mul(O,O),W=t.mul($,O),q=t.cmov(F,q,k),$=t.cmov(W,$,k)}return{isValid:v,value:q}};if(t.ORDER%K0===Io){let f=(t.ORDER-Io)/K0,S=t.sqrt(t.neg(e));_=(O,F)=>{let q=t.sqr(F),M=t.mul(O,F);q=t.mul(q,M);let $=t.pow(q,f);$=t.mul($,M);let v=t.mul($,S),V=t.mul(t.sqr($),F),K=t.eql(V,O),W=t.cmov(v,$,K);return{isValid:K,value:W}}}return _}function wm(t,e){if(xn.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=W0(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,c,a,l,d,b;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),c=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),c=t.mul(c,e.A),s=t.sqr(o),l=t.sqr(c),a=t.mul(l,e.A),s=t.add(s,a),s=t.mul(s,o),l=t.mul(l,c),a=t.mul(l,e.B),s=t.add(s,a),d=t.mul(i,o);let{isValid:m,value:_}=r(s,l);b=t.mul(i,n),b=t.mul(b,_),d=t.cmov(d,o,m),b=t.cmov(b,_,m);let f=t.isOdd(n)===t.isOdd(b);return b=t.cmov(t.neg(b),b,f),d=t.div(d,c),{x:d,y:b}}}});var J0=re(gu=>{"use strict";Object.defineProperty(gu,"__esModule",{value:!0});gu.bls=xm;var Y0=_r(),bu=Mt(),Z0=So(),X0=yu(),_m=BigInt(0),No=BigInt(1),Q0=BigInt(2),ti=BigInt(3);function Em(t){let e=[];for(;t>No;t>>=No)(t&No)===_m?e.unshift(0):(t&ti)===ti?(e.unshift(-1),t+=No):e.unshift(1);return e}function xm(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=t.params.xNegative,c=t.params.twistType,a=(0,X0.weierstrassPoints)({n:r.ORDER,...t.G1}),l=Object.assign(a,(0,Z0.createHasher)(a.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults})),d=(0,X0.weierstrassPoints)({n:r.ORDER,...t.G2}),b=Object.assign(d,(0,Z0.createHasher)(d.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),m;if(c==="multiplicative")m=(z,U,h,X,te,de)=>s.mul014(X,z,n.mul(U,te),n.mul(h,de));else if(c==="divisive")m=(z,U,h,X,te,de)=>s.mul034(X,n.mul(h,de),n.mul(U,te),z);else throw new Error("bls: unknown twist type");let _=n.div(n.ONE,n.mul(n.ONE,Q0));function f(z,U,h,X){let te=n.sqr(h),de=n.sqr(X),Q=n.mulByB(n.mul(de,ti)),u=n.mul(Q,ti),p=n.sub(n.sub(n.sqr(n.add(h,X)),de),te),y=n.sub(Q,te),R=n.mul(n.sqr(U),ti),B=n.neg(p);return z.push([y,R,B]),U=n.mul(n.mul(n.mul(n.sub(te,u),U),h),_),h=n.sub(n.sqr(n.mul(n.add(te,u),_)),n.mul(n.sqr(Q),ti)),X=n.mul(te,p),{Rx:U,Ry:h,Rz:X}}function S(z,U,h,X,te,de){let Q=n.sub(h,n.mul(de,X)),u=n.sub(U,n.mul(te,X)),p=n.sub(n.mul(Q,te),n.mul(u,de)),y=n.neg(Q),R=u;z.push([p,y,R]);let B=n.sqr(u),N=n.mul(B,u),j=n.mul(B,U),E=n.add(n.sub(N,n.mul(j,Q0)),n.mul(n.sqr(Q),X));return U=n.mul(u,E),h=n.sub(n.mul(n.sub(j,E),Q),n.mul(N,h)),X=n.mul(X,N),{Rx:U,Ry:h,Rz:X}}let O=Em(t.params.ateLoopSize),F=(0,bu.memoized)(z=>{let U=z,{x:h,y:X}=U.toAffine(),te=h,de=X,Q=n.neg(X),u=te,p=de,y=n.ONE,R=[];for(let B of O){let N=[];({Rx:u,Ry:p,Rz:y}=f(N,u,p,y)),B&&({Rx:u,Ry:p,Rz:y}=S(N,u,p,y,te,B===-1?Q:de)),R.push(N)}if(t.postPrecompute){let B=R[R.length-1];t.postPrecompute(u,p,y,te,de,S.bind(null,B))}return R});function q(z,U=!1){let h=s.ONE;if(z.length){let X=z[0][0].length;for(let te=0;te<X;te++){h=s.sqr(h);for(let[de,Q,u]of z)for(let[p,y,R]of de[te])h=m(p,y,R,h,Q,u)}}return o&&(h=s.conjugate(h)),U?s.finalExponentiate(h):h}function M(z,U=!0){let h=[];l.ProjectivePoint.normalizeZ(z.map(({g1:X})=>X)),b.ProjectivePoint.normalizeZ(z.map(({g2:X})=>X));for(let{g1:X,g2:te}of z){if(X.equals(l.ProjectivePoint.ZERO)||te.equals(b.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");X.assertValidity(),te.assertValidity();let de=X.toAffine();h.push([F(te),de.x,de.y])}return q(h,U)}function $(z,U,h=!0){return M([{g1:z,g2:U}],h)}let v={randomPrivateKey:()=>{let z=(0,Y0.getMinHashLength)(r.ORDER);return(0,Y0.mapHashToField)(t.randomBytes(z),r.ORDER)},calcPairingPrecomputes:F},{ShortSignature:V}=t.G1,{Signature:K}=t.G2;function W(z){return z instanceof l.ProjectivePoint?z:l.ProjectivePoint.fromHex(z)}function k(z,U){return z instanceof l.ProjectivePoint?z:l.hashToCurve((0,bu.ensureBytes)("point",z),U)}function se(z){return z instanceof b.ProjectivePoint?z:K.fromHex(z)}function ee(z,U){return z instanceof b.ProjectivePoint?z:b.hashToCurve((0,bu.ensureBytes)("point",z),U)}function ie(z){return l.ProjectivePoint.fromPrivateKey(z).toRawBytes(!0)}function w(z){return b.ProjectivePoint.fromPrivateKey(z).toRawBytes(!0)}function g(z,U,h){let X=ee(z,h);X.assertValidity();let te=X.multiply(l.normPrivateKeyToScalar(U));return z instanceof b.ProjectivePoint?te:K.toRawBytes(te)}function A(z,U,h){let X=k(z,h);X.assertValidity();let te=X.multiply(l.normPrivateKeyToScalar(U));return z instanceof l.ProjectivePoint?te:V.toRawBytes(te)}function T(z,U,h,X){let te=W(h),de=ee(U,X),Q=l.ProjectivePoint.BASE,u=se(z),p=M([{g1:te.negate(),g2:de},{g1:Q,g2:u}]);return s.eql(p,s.ONE)}function I(z,U,h,X){let te=se(h),de=k(U,X),Q=b.ProjectivePoint.BASE,u=W(z),p=M([{g1:de,g2:te},{g1:u,g2:Q.negate()}]);return s.eql(p,s.ONE)}function L(z){if(!z.length)throw new Error("Expected non-empty array");let h=z.map(W).reduce((X,te)=>X.add(te),l.ProjectivePoint.ZERO);return z[0]instanceof l.ProjectivePoint?(h.assertValidity(),h):h.toRawBytes(!0)}function Y(z){if(!z.length)throw new Error("Expected non-empty array");let h=z.map(se).reduce((X,te)=>X.add(te),b.ProjectivePoint.ZERO);return z[0]instanceof b.ProjectivePoint?(h.assertValidity(),h):K.toRawBytes(h)}function ce(z){if(!z.length)throw new Error("Expected non-empty array");let h=z.map(W).reduce((X,te)=>X.add(te),l.ProjectivePoint.ZERO);return z[0]instanceof l.ProjectivePoint?(h.assertValidity(),h):V.toRawBytes(h)}function oe(z,U,h,X){if(!U.length)throw new Error("Expected non-empty messages array");if(h.length!==U.length)throw new Error("Pubkey count should equal msg count");let te=se(z),de=U.map(y=>ee(y,X)),Q=h.map(W),u=new Map;for(let y=0;y<Q.length;y++){let R=Q[y],B=de[y],N=u.get(B);N===void 0&&(N=[],u.set(B,N)),N.push(R)}let p=[];try{for(let[y,R]of u){let B=R.reduce((N,j)=>N.add(j));p.push({g1:B,g2:y})}return p.push({g1:l.ProjectivePoint.BASE.negate(),g2:te}),s.eql(M(p),s.ONE)}catch{return!1}}return l.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:ie,getPublicKeyForShortSignatures:w,sign:g,signShortSignature:A,verify:T,verifyBatch:oe,verifyShortSignature:I,aggregatePublicKeys:L,aggregateSignatures:Y,aggregateShortSignatures:ce,millerLoopBatch:q,pairing:$,pairingBatch:M,G1:l,G2:b,Signature:K,ShortSignature:V,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:v}}});var td=re(Oo=>{"use strict";Object.defineProperty(Oo,"__esModule",{value:!0});Oo.psiFrobenius=Bm;Oo.tower12=Tm;var en=_r(),rr=Mt(),vm=BigInt(0),ri=BigInt(1),qr=BigInt(2),ed=BigInt(3);function mu(t,e,r,n,i=1,s){let o=BigInt(s===void 0?n:s),c=r**BigInt(n),a=[];for(let l=0;l<i;l++){let d=BigInt(l+1),b=[];for(let m=0,_=ri;m<n;m++){let f=(d*_-d)/o%c;b.push(t.pow(e,f)),_*=r}a.push(b)}return a}function Bm(t,e,r){let n=e.pow(r,(t.ORDER-ri)/ed),i=e.pow(r,(t.ORDER-ri)/qr);function s(m,_){let f=e.mul(e.frobeniusMap(m,1),n),S=e.mul(e.frobeniusMap(_,1),i);return[f,S]}let o=e.pow(r,(t.ORDER**qr-ri)/ed),c=e.pow(r,(t.ORDER**qr-ri)/qr);if(!e.eql(c,e.neg(e.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function a(m,_){return[e.mul(m,o),e.neg(_)]}let l=m=>(_,f)=>{let S=f.toAffine(),O=m(S.x,S.y);return _.fromAffine({x:O[0],y:O[1]})},d=l(s),b=l(a);return{psi:s,psi2:a,G2psi:d,G2psi2:b,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:c}}function Tm(t){let{ORDER:e}=t,r=en.Field(e),n=r.create(t.NONRESIDUE||BigInt(-1)),i=en.FpLegendre(e),s=r.div(r.ONE,qr),o=mu(r,n,r.ORDER,2)[0],c=({c0:w,c1:g},{c0:A,c1:T})=>({c0:r.add(w,A),c1:r.add(g,T)}),a=({c0:w,c1:g},{c0:A,c1:T})=>({c0:r.sub(w,A),c1:r.sub(g,T)}),l=({c0:w,c1:g},A)=>{if(typeof A=="bigint")return{c0:r.mul(w,A),c1:r.mul(g,A)};let{c0:T,c1:I}=A,L=r.mul(w,T),Y=r.mul(g,I),ce=r.sub(L,Y),oe=r.sub(r.mul(r.add(w,g),r.add(T,I)),r.add(L,Y));return{c0:ce,c1:oe}},d=({c0:w,c1:g})=>{let A=r.add(w,g),T=r.sub(w,g),I=r.add(w,w);return{c0:r.mul(A,T),c1:r.mul(I,g)}},b=w=>{if(w.length!==2)throw new Error("Invalid tuple");let g=w.map(A=>r.create(A));return{c0:g[0],c1:g[1]}},m=e*e,_=b(t.FP2_NONRESIDUE),f={ORDER:m,NONRESIDUE:_,BITS:(0,rr.bitLen)(m),BYTES:Math.ceil((0,rr.bitLen)(m)/8),MASK:(0,rr.bitMask)((0,rr.bitLen)(m)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:w=>w,isValid:({c0:w,c1:g})=>typeof w=="bigint"&&typeof g=="bigint",is0:({c0:w,c1:g})=>r.is0(w)&&r.is0(g),eql:({c0:w,c1:g},{c0:A,c1:T})=>r.eql(w,A)&&r.eql(g,T),neg:({c0:w,c1:g})=>({c0:r.neg(w),c1:r.neg(g)}),pow:(w,g)=>en.FpPow(f,w,g),invertBatch:w=>en.FpInvertBatch(f,w),add:c,sub:a,mul:l,sqr:d,addN:c,subN:a,mulN:l,sqrN:d,div:(w,g)=>f.mul(w,typeof g=="bigint"?r.inv(r.create(g)):f.inv(g)),inv:({c0:w,c1:g})=>{let A=r.inv(r.create(w*w+g*g));return{c0:r.mul(A,r.create(w)),c1:r.mul(A,r.create(-g))}},sqrt:w=>{if(t.Fp2sqrt)return t.Fp2sqrt(w);let{c0:g,c1:A}=w;if(r.is0(A))return r.eql(i(r,g),r.ONE)?f.create({c0:r.sqrt(g),c1:r.ZERO}):f.create({c0:r.ZERO,c1:r.sqrt(r.div(g,n))});let T=r.sqrt(r.sub(r.sqr(g),r.mul(r.sqr(A),n))),I=r.mul(r.add(T,g),s),L=i(r,I);!r.is0(L)&&!r.eql(L,r.ONE)&&(I=r.sub(I,T));let Y=r.sqrt(I),ce=f.create({c0:Y,c1:r.div(r.mul(A,s),Y)});if(!f.eql(f.sqr(ce),w))throw new Error("Cannot find square root");let oe=ce,z=f.neg(oe),{re:U,im:h}=f.reim(oe),{re:X,im:te}=f.reim(z);return h>te||h===te&&U>X?oe:z},isOdd:w=>{let{re:g,im:A}=f.reim(w),T=g%qr,I=g===vm,L=A%qr;return BigInt(T||I&&L)==ri},fromBytes(w){if(w.length!==f.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:r.fromBytes(w.subarray(0,r.BYTES)),c1:r.fromBytes(w.subarray(r.BYTES))}},toBytes:({c0:w,c1:g})=>(0,rr.concatBytes)(r.toBytes(w),r.toBytes(g)),cmov:({c0:w,c1:g},{c0:A,c1:T},I)=>({c0:r.cmov(w,A,I),c1:r.cmov(g,T,I)}),reim:({c0:w,c1:g})=>({re:w,im:g}),mulByNonresidue:({c0:w,c1:g})=>f.mul({c0:w,c1:g},_),mulByB:t.Fp2mulByB,fromBigTuple:b,frobeniusMap:({c0:w,c1:g},A)=>({c0:w,c1:r.mul(g,o[A%2])})},S=({c0:w,c1:g,c2:A},{c0:T,c1:I,c2:L})=>({c0:f.add(w,T),c1:f.add(g,I),c2:f.add(A,L)}),O=({c0:w,c1:g,c2:A},{c0:T,c1:I,c2:L})=>({c0:f.sub(w,T),c1:f.sub(g,I),c2:f.sub(A,L)}),F=({c0:w,c1:g,c2:A},T)=>{if(typeof T=="bigint")return{c0:f.mul(w,T),c1:f.mul(g,T),c2:f.mul(A,T)};let{c0:I,c1:L,c2:Y}=T,ce=f.mul(w,I),oe=f.mul(g,L),z=f.mul(A,Y);return{c0:f.add(ce,f.mulByNonresidue(f.sub(f.mul(f.add(g,A),f.add(L,Y)),f.add(oe,z)))),c1:f.add(f.sub(f.mul(f.add(w,g),f.add(I,L)),f.add(ce,oe)),f.mulByNonresidue(z)),c2:f.sub(f.add(oe,f.mul(f.add(w,A),f.add(I,Y))),f.add(ce,z))}},q=({c0:w,c1:g,c2:A})=>{let T=f.sqr(w),I=f.mul(f.mul(w,g),qr),L=f.mul(f.mul(g,A),qr),Y=f.sqr(A);return{c0:f.add(f.mulByNonresidue(L),T),c1:f.add(f.mulByNonresidue(Y),I),c2:f.sub(f.sub(f.add(f.add(I,f.sqr(f.add(f.sub(w,g),A))),L),T),Y)}},[M,$]=mu(f,_,r.ORDER,6,2,3),v={ORDER:f.ORDER,BITS:3*f.BITS,BYTES:3*f.BYTES,MASK:(0,rr.bitMask)(3*f.BITS),ZERO:{c0:f.ZERO,c1:f.ZERO,c2:f.ZERO},ONE:{c0:f.ONE,c1:f.ZERO,c2:f.ZERO},create:w=>w,isValid:({c0:w,c1:g,c2:A})=>f.isValid(w)&&f.isValid(g)&&f.isValid(A),is0:({c0:w,c1:g,c2:A})=>f.is0(w)&&f.is0(g)&&f.is0(A),neg:({c0:w,c1:g,c2:A})=>({c0:f.neg(w),c1:f.neg(g),c2:f.neg(A)}),eql:({c0:w,c1:g,c2:A},{c0:T,c1:I,c2:L})=>f.eql(w,T)&&f.eql(g,I)&&f.eql(A,L),sqrt:rr.notImplemented,div:(w,g)=>v.mul(w,typeof g=="bigint"?r.inv(r.create(g)):v.inv(g)),pow:(w,g)=>en.FpPow(v,w,g),invertBatch:w=>en.FpInvertBatch(v,w),add:S,sub:O,mul:F,sqr:q,addN:S,subN:O,mulN:F,sqrN:q,inv:({c0:w,c1:g,c2:A})=>{let T=f.sub(f.sqr(w),f.mulByNonresidue(f.mul(A,g))),I=f.sub(f.mulByNonresidue(f.sqr(A)),f.mul(w,g)),L=f.sub(f.sqr(g),f.mul(w,A)),Y=f.inv(f.add(f.mulByNonresidue(f.add(f.mul(A,I),f.mul(g,L))),f.mul(w,T)));return{c0:f.mul(Y,T),c1:f.mul(Y,I),c2:f.mul(Y,L)}},fromBytes:w=>{if(w.length!==v.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:f.fromBytes(w.subarray(0,f.BYTES)),c1:f.fromBytes(w.subarray(f.BYTES,2*f.BYTES)),c2:f.fromBytes(w.subarray(2*f.BYTES))}},toBytes:({c0:w,c1:g,c2:A})=>(0,rr.concatBytes)(f.toBytes(w),f.toBytes(g),f.toBytes(A)),cmov:({c0:w,c1:g,c2:A},{c0:T,c1:I,c2:L},Y)=>({c0:f.cmov(w,T,Y),c1:f.cmov(g,I,Y),c2:f.cmov(A,L,Y)}),fromBigSix:w=>{if(!Array.isArray(w)||w.length!==6)throw new Error("Invalid Fp6 usage");return{c0:f.fromBigTuple(w.slice(0,2)),c1:f.fromBigTuple(w.slice(2,4)),c2:f.fromBigTuple(w.slice(4,6))}},frobeniusMap:({c0:w,c1:g,c2:A},T)=>({c0:f.frobeniusMap(w,T),c1:f.mul(f.frobeniusMap(g,T),M[T%6]),c2:f.mul(f.frobeniusMap(A,T),$[T%6])}),mulByFp2:({c0:w,c1:g,c2:A},T)=>({c0:f.mul(w,T),c1:f.mul(g,T),c2:f.mul(A,T)}),mulByNonresidue:({c0:w,c1:g,c2:A})=>({c0:f.mulByNonresidue(A),c1:w,c2:g}),mul1:({c0:w,c1:g,c2:A},T)=>({c0:f.mulByNonresidue(f.mul(A,T)),c1:f.mul(w,T),c2:f.mul(g,T)}),mul01({c0:w,c1:g,c2:A},T,I){let L=f.mul(w,T),Y=f.mul(g,I);return{c0:f.add(f.mulByNonresidue(f.sub(f.mul(f.add(g,A),I),Y)),L),c1:f.sub(f.sub(f.mul(f.add(T,I),f.add(w,g)),L),Y),c2:f.add(f.sub(f.mul(f.add(w,A),T),L),Y)}}},V=mu(f,_,r.ORDER,12,1,6)[0],K=({c0:w,c1:g},{c0:A,c1:T})=>({c0:v.add(w,A),c1:v.add(g,T)}),W=({c0:w,c1:g},{c0:A,c1:T})=>({c0:v.sub(w,A),c1:v.sub(g,T)}),k=({c0:w,c1:g},A)=>{if(typeof A=="bigint")return{c0:v.mul(w,A),c1:v.mul(g,A)};let{c0:T,c1:I}=A,L=v.mul(w,T),Y=v.mul(g,I);return{c0:v.add(L,v.mulByNonresidue(Y)),c1:v.sub(v.mul(v.add(w,g),v.add(T,I)),v.add(L,Y))}},se=({c0:w,c1:g})=>{let A=v.mul(w,g);return{c0:v.sub(v.sub(v.mul(v.add(v.mulByNonresidue(g),w),v.add(w,g)),A),v.mulByNonresidue(A)),c1:v.add(A,A)}};function ee(w,g){let A=f.sqr(w),T=f.sqr(g);return{first:f.add(f.mulByNonresidue(T),A),second:f.sub(f.sub(f.sqr(f.add(w,g)),A),T)}}let ie={ORDER:f.ORDER,BITS:2*f.BITS,BYTES:2*f.BYTES,MASK:(0,rr.bitMask)(2*f.BITS),ZERO:{c0:v.ZERO,c1:v.ZERO},ONE:{c0:v.ONE,c1:v.ZERO},create:w=>w,isValid:({c0:w,c1:g})=>v.isValid(w)&&v.isValid(g),is0:({c0:w,c1:g})=>v.is0(w)&&v.is0(g),neg:({c0:w,c1:g})=>({c0:v.neg(w),c1:v.neg(g)}),eql:({c0:w,c1:g},{c0:A,c1:T})=>v.eql(w,A)&&v.eql(g,T),sqrt:rr.notImplemented,inv:({c0:w,c1:g})=>{let A=v.inv(v.sub(v.sqr(w),v.mulByNonresidue(v.sqr(g))));return{c0:v.mul(w,A),c1:v.neg(v.mul(g,A))}},div:(w,g)=>ie.mul(w,typeof g=="bigint"?r.inv(r.create(g)):ie.inv(g)),pow:(w,g)=>en.FpPow(ie,w,g),invertBatch:w=>en.FpInvertBatch(ie,w),add:K,sub:W,mul:k,sqr:se,addN:K,subN:W,mulN:k,sqrN:se,fromBytes:w=>{if(w.length!==ie.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:v.fromBytes(w.subarray(0,v.BYTES)),c1:v.fromBytes(w.subarray(v.BYTES))}},toBytes:({c0:w,c1:g})=>(0,rr.concatBytes)(v.toBytes(w),v.toBytes(g)),cmov:({c0:w,c1:g},{c0:A,c1:T},I)=>({c0:v.cmov(w,A,I),c1:v.cmov(g,T,I)}),fromBigTwelve:w=>({c0:v.fromBigSix(w.slice(0,6)),c1:v.fromBigSix(w.slice(6,12))}),frobeniusMap(w,g){let{c0:A,c1:T,c2:I}=v.frobeniusMap(w.c1,g),L=V[g%12];return{c0:v.frobeniusMap(w.c0,g),c1:v.create({c0:f.mul(A,L),c1:f.mul(T,L),c2:f.mul(I,L)})}},mulByFp2:({c0:w,c1:g},A)=>({c0:v.mulByFp2(w,A),c1:v.mulByFp2(g,A)}),conjugate:({c0:w,c1:g})=>({c0:w,c1:v.neg(g)}),mul014:({c0:w,c1:g},A,T,I)=>{let L=v.mul01(w,A,T),Y=v.mul1(g,I);return{c0:v.add(v.mulByNonresidue(Y),L),c1:v.sub(v.sub(v.mul01(v.add(g,w),A,f.add(T,I)),L),Y)}},mul034:({c0:w,c1:g},A,T,I)=>{let L=v.create({c0:f.mul(w.c0,A),c1:f.mul(w.c1,A),c2:f.mul(w.c2,A)}),Y=v.mul01(g,T,I),ce=v.mul01(v.add(w,g),f.add(A,T),I);return{c0:v.add(v.mulByNonresidue(Y),L),c1:v.sub(ce,v.add(L,Y))}},_cyclotomicSquare:t.Fp12cyclotomicSquare,_cyclotomicExp:t.Fp12cyclotomicExp,finalExponentiate:t.Fp12finalExponentiate};return{Fp:r,Fp2:f,Fp6:v,Fp4Square:ee,Fp12:ie}}});var fd=re(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.bls12_381=void 0;var od=Fs(),Sm=Gn(),Am=J0(),Im=_r(),Se=Mt(),ad=So(),cd=yu(),ud=td(),_t=BigInt(0),Uo=BigInt(1),st=BigInt(2),Ro=BigInt(3),Ki=BigInt(4),tn=BigInt("0xd201000000010000"),Nm=(0,Se.bitLen)(tn),{Fp:fe,Fp2:pe,Fp6:Eu,Fp4Square:wu,Fp12:ve}=(0,ud.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[Uo,Uo],Fp2mulByB:({c0:t,c1:e})=>{let r=fe.mul(t,Ki),n=fe.mul(e,Ki);return{c0:fe.sub(r,n),c1:fe.add(r,n)}},Fp12cyclotomicSquare:({c0:t,c1:e})=>{let{c0:r,c1:n,c2:i}=t,{c0:s,c1:o,c2:c}=e,{first:a,second:l}=wu(r,o),{first:d,second:b}=wu(s,i),{first:m,second:_}=wu(n,c),f=pe.mulByNonresidue(_);return{c0:Eu.create({c0:pe.add(pe.mul(pe.sub(a,r),st),a),c1:pe.add(pe.mul(pe.sub(d,n),st),d),c2:pe.add(pe.mul(pe.sub(m,i),st),m)}),c1:Eu.create({c0:pe.add(pe.mul(pe.add(f,s),st),f),c1:pe.add(pe.mul(pe.add(l,o),st),l),c2:pe.add(pe.mul(pe.add(b,c),st),b)})}},Fp12cyclotomicExp(t,e){let r=ve.ONE;for(let n=Nm-1;n>=0;n--)r=ve._cyclotomicSquare(r),(0,Se.bitGet)(e,n)&&(r=ve.mul(r,t));return r},Fp12finalExponentiate:t=>{let e=tn,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)),c=ve.conjugate(ve._cyclotomicExp(o,e)),a=ve.mul(ve.conjugate(ve._cyclotomicExp(c,e)),ve._cyclotomicSquare(i)),l=ve.conjugate(ve._cyclotomicExp(a,e)),d=ve.frobeniusMap(ve.mul(i,c),2),b=ve.frobeniusMap(ve.mul(o,n),3),m=ve.frobeniusMap(ve.mul(a,ve.conjugate(n)),1),_=ve.mul(ve.mul(l,ve.conjugate(s)),n);return ve.mul(ve.mul(ve.mul(d,b),m),_)}}),rd=Im.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),Om=(0,ad.isogenyMap)(pe,[[["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=>pe.fromBigTuple(e.map(BigInt))))),Rm=(0,ad.isogenyMap)(fe,[["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)))),Pm=(0,cd.mapToCurveSimpleSWU)(pe,{A:pe.create({c0:fe.create(_t),c1:fe.create(BigInt(240))}),B:pe.create({c0:fe.create(BigInt(1012)),c1:fe.create(BigInt(1012))}),Z:pe.create({c0:fe.create(BigInt(-2)),c1:fe.create(BigInt(-1))})}),Um=(0,cd.mapToCurveSimpleSWU)(fe,{A:fe.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:fe.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:fe.create(BigInt(11))}),{G2psi:nd,G2psi2:Fm}=(0,ud.psiFrobenius)(fe,pe,pe.div(pe.ONE,pe.NONRESIDUE)),_u=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:fe.ORDER,m:2,k:128,expand:"xmd",hash:od.sha256}),Fo=zi(fe.toBytes(_t),{infinity:!0,compressed:!0});function Po(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 zi(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 id(t){t.assertValidity();let e=t.equals(Et.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return Fo.slice();let i=fe.ORDER,s=!!(n*st/i);return zi((0,Se.numberToBytesBE)(r,fe.BYTES),{compressed:!0,sort:s})}function sd(t){t.assertValidity();let e=fe.BYTES;if(t.equals(Et.bls12_381.G2.ProjectivePoint.ZERO))return(0,Se.concatBytes)(Fo,(0,Se.numberToBytesBE)(_t,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=pe.reim(r),{re:o,im:c}=pe.reim(n),l=!!((c>_t?c*st:o*st)/fe.ORDER&Uo),d=i;return(0,Se.concatBytes)(zi((0,Se.numberToBytesBE)(s,e),{sort:l,compressed:!0}),(0,Se.numberToBytesBE)(d,e))}Et.bls12_381=(0,Am.bls)({fields:{Fp:fe,Fp2:pe,Fp6:Eu,Fp12:ve,Fr:rd},G1:{Fp:fe,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:fe.ZERO,b:Ki,htfDefaults:{..._u,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(fe.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(tn).negate().multiplyUnsafe(tn).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(tn).add(e),mapToCurve:t=>{let{x:e,y:r}=Um(fe.create(t[0]));return Rm(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=Po(t);if(i.length===48&&e){let s=fe.ORDER,o=(0,Se.bytesToNumberBE)(i),c=fe.create(o&fe.MASK);if(r){if(c!==_t)throw new Error("G1: non-empty compressed point at infinity");return{x:_t,y:_t}}let a=fe.add(fe.pow(c,Ro),fe.create(Et.bls12_381.params.G1b)),l=fe.sqrt(a);if(!l)throw new Error("Invalid compressed G1 point");return l*st/s!==BigInt(n)&&(l=fe.neg(l)),{x:fe.create(c),y:fe.create(l)}}else if(i.length===96&&!e){let s=(0,Se.bytesToNumberBE)(i.subarray(0,fe.BYTES)),o=(0,Se.bytesToNumberBE)(i.subarray(fe.BYTES));if(r){if(s!==_t||o!==_t)throw new Error("G1: non-empty point at infinity");return Et.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:fe.create(s),y:fe.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 Fo.slice();let o=fe.ORDER,c=!!(s*st/o);return zi((0,Se.numberToBytesBE)(i,fe.BYTES),{compressed:!0,sort:c})}else return n?(0,Se.concatBytes)(new Uint8Array([64]),new Uint8Array(2*fe.BYTES-1)):(0,Se.concatBytes)((0,Se.numberToBytesBE)(i,fe.BYTES),(0,Se.numberToBytesBE)(s,fe.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=Po((0,Se.ensureBytes)("signatureHex",t,48)),i=fe.ORDER,s=(0,Se.bytesToNumberBE)(n);if(e)return Et.bls12_381.G1.ProjectivePoint.ZERO;let o=fe.create(s&fe.MASK),c=fe.add(fe.pow(o,Ro),fe.create(Et.bls12_381.params.G1b)),a=fe.sqrt(c);if(!a)throw new Error("Invalid compressed G1 point");let l=BigInt(r);a*st/i!==l&&(a=fe.neg(a));let d=Et.bls12_381.G1.ProjectivePoint.fromAffine({x:o,y:a});return d.assertValidity(),d},toRawBytes(t){return id(t)},toHex(t){return(0,Se.bytesToHex)(id(t))}}},G2:{Fp:pe,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:pe.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:pe.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:pe.ZERO,b:pe.fromBigTuple([Ki,Ki]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{..._u},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=Pm(pe.fromBigTuple(t));return Om(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(tn).negate().equals(nd(t,e)),clearCofactor:(t,e)=>{let r=tn,n=e.multiplyUnsafe(r).negate(),i=nd(t,e),s=e.double();return s=Fm(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}=Po(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=fe.BYTES,o=(c,a,l)=>(0,Se.bytesToNumberBE)(c.slice(a,l));if(i.length===96&&e){let c=Et.bls12_381.params.G2b,a=fe.ORDER;if(r){if(i.reduce((S,O)=>S!==0?O+1:O,0)>0)throw new Error("Invalid compressed G2 point");return{x:pe.ZERO,y:pe.ZERO}}let l=o(i,0,s),d=o(i,s,2*s),b=pe.create({c0:fe.create(d),c1:fe.create(l)}),m=pe.add(pe.pow(b,Ro),c),_=pe.sqrt(m),f=_.c1===_t?_.c0*st/a:_.c1*st/a?Uo:_t;return _=n&&f>0?_:pe.neg(_),{x:b,y:_}}else if(i.length===192&&!e){if(r){if(i.reduce((b,m)=>b!==0?m+1:m,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:pe.ZERO,y:pe.ZERO}}let c=o(i,0,s),a=o(i,s,2*s),l=o(i,2*s,3*s),d=o(i,3*s,4*s);return{x:pe.fromBigTuple([a,c]),y:pe.fromBigTuple([d,l])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(t,e,r)=>{let{BYTES:n,ORDER:i}=fe,s=e.equals(t.ZERO),{x:o,y:c}=e.toAffine();if(r){if(s)return(0,Se.concatBytes)(Fo,(0,Se.numberToBytesBE)(_t,n));let a=!!(c.c1===_t?c.c0*st/i:c.c1*st/i);return(0,Se.concatBytes)(zi((0,Se.numberToBytesBE)(o.c1,n),{compressed:!0,sort:a}),(0,Se.numberToBytesBE)(o.c0,n))}else{if(s)return(0,Se.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:a,im:l}=pe.reim(o),{re:d,im:b}=pe.reim(c);return(0,Se.concatBytes)((0,Se.numberToBytesBE)(l,n),(0,Se.numberToBytesBE)(a,n),(0,Se.numberToBytesBE)(b,n),(0,Se.numberToBytesBE)(d,n))}},Signature:{fromHex(t){let{infinity:e,sort:r,value:n}=Po((0,Se.ensureBytes)("signatureHex",t)),i=fe.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)),c=(0,Se.bytesToNumberBE)(n.slice(s));if(e)return Et.bls12_381.G2.ProjectivePoint.ZERO;let a=fe.create(o&fe.MASK),l=fe.create(c),d=pe.create({c0:l,c1:a}),b=pe.add(pe.pow(d,Ro),Et.bls12_381.params.G2b),m=pe.sqrt(b);if(!m)throw new Error("Failed to find a square root");let{re:_,im:f}=pe.reim(m),S=BigInt(r),O=f>_t&&f*st/i!==S,F=f===_t&&_*st/i!==S;(O||F)&&(m=pe.neg(m));let q=Et.bls12_381.G2.ProjectivePoint.fromAffine({x:d,y:m});return q.assertValidity(),q},toRawBytes(t){return sd(t)},toHex(t){return(0,Se.bytesToHex)(sd(t))}}},params:{ateLoopSize:tn,r:rd.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:_u,hash:od.sha256,randomBytes:Sm.randomBytes})});var vu=re(Wi=>{"use strict";Object.defineProperty(Wi,"__esModule",{value:!0});Wi.blsVerify=Wi.verify=void 0;var Mm=fd(),xu=It();function qm(t,e,r){let n=typeof t=="string"?t:(0,xu.toHex)(t),i=typeof e=="string"?e:(0,xu.toHex)(e),s=typeof r=="string"?r:(0,xu.toHex)(r);return Mm.bls12_381.verifyShortSignature(i,s,n)}Wi.blsVerify=qm});var Mo=re(vn=>{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.decodeTime=vn.decodeLeb128=void 0;var ld=Fi(),Cm=t=>(0,ld.lebDecode)(new ld.PipeArrayBuffer(t));vn.decodeLeb128=Cm;var km=t=>{let e=(0,vn.decodeLeb128)(t);return new Date(Number(e)/1e6)};vn.decodeTime=km});var ni=re(Ie=>{"use strict";var jm=Ie&&Ie.__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]}),Hm=Ie&&Ie.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),dd=Ie&&Ie.__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)&&jm(e,t,r);return Hm(e,t),e};Object.defineProperty(Ie,"__esModule",{value:!0});Ie.check_canister_ranges=Ie.find_label=Ie.flatten_forks=Ie.lookup_path=Ie.LookupStatus=Ie.reconstruct=Ie.lookupResultToBuffer=Ie.Certificate=Ie.hashTreeToString=Ie.NodeType=Ie.CertificateVerificationError=void 0;var hd=dd(Vi()),Lm=Dn(),qo=Hi(),nr=It(),Bu=$t(),Vm=dd(vu()),$m=Mo(),Gm=Ji(),Cr=class extends Lm.AgentError{constructor(e){super(`Invalid certificate: ${e}`)}};Ie.CertificateVerificationError=Cr;var dt;(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"})(dt=Ie.NodeType||(Ie.NodeType={}));function Co(t){let e=n=>n.split(`
|
|
18
|
+
`).map(i=>" "+i).join(`
|
|
19
|
+
`);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 dt.Empty:return"()";case dt.Fork:if(t[1]instanceof Array&&t[2]instanceof ArrayBuffer){let n=Co(t[1]),i=Co(t[2]);return`sub(
|
|
20
|
+
left:
|
|
21
|
+
${e(n)}
|
|
22
|
+
---
|
|
23
|
+
right:
|
|
24
|
+
${e(i)}
|
|
25
|
+
)`}else throw new Error("Invalid tree structure for fork");case dt.Labeled:if(t[1]instanceof ArrayBuffer&&t[2]instanceof ArrayBuffer){let n=r(t[1]),i=Co(t[2]);return`label(
|
|
26
|
+
label:
|
|
27
|
+
${e(n)}
|
|
28
|
+
sub:
|
|
29
|
+
${e(i)}
|
|
30
|
+
)`}else throw new Error("Invalid tree structure for labeled");case dt.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 dt.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,nr.toHex)(new Uint8Array(t[1]))}`}default:return`unknown(${JSON.stringify(t[0])})`}}Ie.hashTreeToString=Co;function Dm(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 Tu=class t{constructor(e,r,n,i,s=5){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=hd.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=Vm.blsVerify),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes)}lookup(e){return ko(e,this.cert.tree)}lookup_label(e){return this.lookup([e])}async verify(){let e=await Xi(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=zm(r),s=(0,nr.concat)(Zi("ic-state-root"),e),o=!1,c=Su(this.lookup(["time"]));if(!c)throw new Cr("Certificate does not contain a time");let a=5*60*1e3,l=this._maxAgeInMinutes*60*1e3,d=Date.now(),b=d-l,m=d+a,_=(0,$m.decodeTime)(c);if(_.getTime()<b)throw new Cr(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+_.toISOString()+" Current time: "+new Date(d).toISOString());if(_.getTime()>m)throw new Cr("Certificate is signed more than 5 minutes in the future. Certificate time: "+_.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 Cr("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 Cr("Delegation certificates cannot be nested");if(await r.verify(),this._canisterId.toString()!==Gm.MANAGEMENT_CANISTER_ID&&!pd({canisterId:this._canisterId,subnetId:Bu.Principal.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new Cr(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,nr.toHex)(e.subnet_id)}`);let n=Su(r.lookup(["subnet",e.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${(0,nr.toHex)(e.subnet_id)}`);return n}};Ie.Certificate=Tu;var Yi=(0,nr.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Km=96;function zm(t){let e=Yi.byteLength+Km;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,Yi.byteLength);if(!(0,nr.bufEquals)(r,Yi))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${Yi}, but get ${r}`);return t.slice(Yi.byteLength)}function Su(t){if(t.status===xt.Found){if(t.value instanceof ArrayBuffer)return t.value;if(t.value instanceof Uint8Array)return t.value.buffer}}Ie.lookupResultToBuffer=Su;async function Xi(t){switch(t[0]){case dt.Empty:return(0,qo.hash)(Zi("ic-hashtree-empty"));case dt.Pruned:return t[1];case dt.Leaf:return(0,qo.hash)((0,nr.concat)(Zi("ic-hashtree-leaf"),t[1]));case dt.Labeled:return(0,qo.hash)((0,nr.concat)(Zi("ic-hashtree-labeled"),t[1],await Xi(t[2])));case dt.Fork:return(0,qo.hash)((0,nr.concat)(Zi("ic-hashtree-fork"),await Xi(t[1]),await Xi(t[2])));default:throw new Error("unreachable")}}Ie.reconstruct=Xi;function Zi(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return(0,nr.concat)(e,r)}var xt;(function(t){t.Unknown="unknown",t.Absent="absent",t.Found="found"})(xt=Ie.LookupStatus||(Ie.LookupStatus={}));var kr;(function(t){t.Less="less",t.Greater="greater"})(kr||(kr={}));function ko(t,e){if(t.length===0)switch(e[0]){case dt.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?{status:xt.Found,value:e[1]}:e[1]instanceof Uint8Array?{status:xt.Found,value:e[1].buffer}:{status:xt.Found,value:e[1]}}default:return{status:xt.Found,value:e}}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=Qi(r,e);switch(n.status){case xt.Found:return ko(t.slice(1),n.value);case kr.Greater:case kr.Less:return{status:xt.Absent};default:return n}}Ie.lookup_path=ko;function Au(t){switch(t[0]){case dt.Empty:return[];case dt.Fork:return Au(t[1]).concat(Au(t[2]));default:return[t]}}Ie.flatten_forks=Au;function Qi(t,e){switch(e[0]){case dt.Labeled:return Dm(t,e[1])?{status:kr.Greater}:(0,nr.bufEquals)(t,e[1])?{status:xt.Found,value:e[2]}:{status:kr.Less};case dt.Fork:let r=Qi(t,e[1]);switch(r.status){case kr.Greater:{let n=Qi(t,e[2]);return n.status===kr.Less?{status:xt.Absent}:n}case xt.Unknown:{let n=Qi(t,e[2]);return n.status===kr.Less?{status:xt.Unknown}:n}default:return r}case dt.Pruned:return{status:xt.Unknown};default:return{status:xt.Absent}}}Ie.find_label=Qi;function pd(t){let{canisterId:e,subnetId:r,tree:n}=t,i=ko(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==xt.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return hd.decode(i.value).map(a=>[Bu.Principal.fromUint8Array(a[0]),Bu.Principal.fromUint8Array(a[1])]).some(a=>a[0].ltEq(e)&&a[1].gtEq(e))}Ie.check_canister_ranges=pd});var es=re(tt=>{"use strict";var Wm=tt&&tt.__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]}),Ym=tt&&tt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Zm=tt&&tt.__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)&&Wm(e,t,r);return Ym(e,t),e};Object.defineProperty(tt,"__esModule",{value:!0});tt.encodePath=tt.fetchNodeKeys=tt.request=tt.CustomPath=void 0;var rn=$t(),Xm=Dn(),nn=ni(),Qm=It(),gd=Zm(Vi()),yd=Mo(),Iu=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}};tt.CustomPath=Iu;var Jm=async t=>{let{agent:e,paths:r}=t,n=rn.Principal.from(t.canisterId),i=[...new Set(r)],s=i.map(a=>(0,tt.encodePath)(a,n)),o=new Map,c=i.map((a,l)=>(async()=>{var d;try{let b=await e.readState(n,{paths:[s[l]]}),m=await nn.Certificate.create({certificate:b.certificate,rootKey:e.rootKey,canisterId:n}),_=(O,F)=>{if(F==="subnet"){let q=(0,tt.fetchNodeKeys)(b.certificate,n,e.rootKey);return{path:F,data:q}}else return{path:F,data:(0,nn.lookupResultToBuffer)(O.lookup((0,tt.encodePath)(F,n)))}},{path:f,data:S}=_(m,i[l]);if(!S)console.warn(`Expected to find result for path ${f}, but instead found nothing.`),typeof f=="string"?o.set(f,null):o.set(f.key,null);else switch(f){case"time":{o.set(f,(0,yd.decodeTime)(S));break}case"controllers":{o.set(f,nw(S));break}case"module_hash":{o.set(f,bd(S));break}case"subnet":{o.set(f,S);break}case"candid":{o.set(f,new TextDecoder().decode(S));break}default:if(typeof f!="string"&&"key"in f&&"path"in f)switch(f.decodeStrategy){case"raw":o.set(f.key,S);break;case"leb128":{o.set(f.key,(0,yd.decodeLeb128)(S));break}case"cbor":{o.set(f.key,md(S));break}case"hex":{o.set(f.key,bd(S));break}case"utf-8":o.set(f.key,rw(S))}}}catch(b){if(!((d=b?.message)===null||d===void 0)&&d.includes("Invalid certificate"))throw new Xm.AgentError(b.message);typeof a!="string"&&"key"in a&&"path"in a?o.set(a.key,null):o.set(a,null),console.group(),console.warn(`Expected to find result for path ${a}, but instead found nothing.`),console.warn(b),console.groupEnd()}})());return await Promise.all(c),o};tt.request=Jm;var ew=(t,e,r)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=gd.decode(new Uint8Array(t)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=rn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=rn.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=rn.Principal.selfAuthenticating(rn.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,nn.check_canister_ranges)({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let a=(0,nn.lookup_path)(["subnet",s.subnet_id,"node"],i);if(a.status!==nn.LookupStatus.Found)throw new Error("Node not found");if(a.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let l=(0,nn.flatten_forks)(a.value),d=new Map;return l.forEach(b=>{let m=rn.Principal.from(new Uint8Array(b[1])).toText(),_=(0,nn.lookup_path)(["public_key"],b[2]);if(_.status!==nn.LookupStatus.Found)throw new Error("Public key not found");let f=_.value;if(f.byteLength!==44)throw new Error("Invalid public key length");d.set(m,f)}),{subnetId:rn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:d}};tt.fetchNodeKeys=ew;var tw=(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.`)};tt.encodePath=tw;var bd=t=>(0,Qm.toHex)(t),md=t=>gd.decode(t),rw=t=>new TextDecoder().decode(t),nw=t=>md(t).map(r=>rn.Principal.fromUint8Array(new Uint8Array(r)))});var Hd=re(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.add5L=ye.add5H=ye.add4H=ye.add4L=ye.add3H=ye.add3L=ye.rotlBL=ye.rotlBH=ye.rotlSL=ye.rotlSH=ye.rotr32L=ye.rotr32H=ye.rotrBL=ye.rotrBH=ye.rotrSL=ye.rotrSH=ye.shrSL=ye.shrSH=ye.toBig=void 0;ye.fromBig=Ou;ye.split=wd;ye.add=Ud;var jo=BigInt(2**32-1),Nu=BigInt(32);function Ou(t,e=!1){return e?{h:Number(t&jo),l:Number(t>>Nu&jo)}:{h:Number(t>>Nu&jo)|0,l:Number(t&jo)|0}}function wd(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}=Ou(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}var _d=(t,e)=>BigInt(t>>>0)<<Nu|BigInt(e>>>0);ye.toBig=_d;var Ed=(t,e,r)=>t>>>r;ye.shrSH=Ed;var xd=(t,e,r)=>t<<32-r|e>>>r;ye.shrSL=xd;var vd=(t,e,r)=>t>>>r|e<<32-r;ye.rotrSH=vd;var Bd=(t,e,r)=>t<<32-r|e>>>r;ye.rotrSL=Bd;var Td=(t,e,r)=>t<<64-r|e>>>r-32;ye.rotrBH=Td;var Sd=(t,e,r)=>t>>>r-32|e<<64-r;ye.rotrBL=Sd;var Ad=(t,e)=>e;ye.rotr32H=Ad;var Id=(t,e)=>t;ye.rotr32L=Id;var Nd=(t,e,r)=>t<<r|e>>>32-r;ye.rotlSH=Nd;var Od=(t,e,r)=>e<<r|t>>>32-r;ye.rotlSL=Od;var Rd=(t,e,r)=>e<<r-32|t>>>64-r;ye.rotlBH=Rd;var Pd=(t,e,r)=>t<<r-32|e>>>64-r;ye.rotlBL=Pd;function Ud(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var Fd=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);ye.add3L=Fd;var Md=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;ye.add3H=Md;var qd=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);ye.add4L=qd;var Cd=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;ye.add4H=Cd;var kd=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);ye.add5L=kd;var jd=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;ye.add5H=jd;var iw={fromBig:Ou,split:wd,toBig:_d,shrSH:Ed,shrSL:xd,rotrSH:vd,rotrSL:Bd,rotrBH:Td,rotrBL:Sd,rotr32H:Ad,rotr32L:Id,rotlSH:Nd,rotlSL:Od,rotlBH:Rd,rotlBL:Pd,add:Ud,add3L:Fd,add3H:Md,add4L:qd,add4H:Cd,add5H:jd,add5L:kd};ye.default=iw});var Ld=re(ot=>{"use strict";Object.defineProperty(ot,"__esModule",{value:!0});ot.sha384=ot.sha512_256=ot.sha512_224=ot.sha512=ot.SHA384=ot.SHA512_256=ot.SHA512_224=ot.SHA512=void 0;var sw=Xa(),me=Hd(),$o=Gn(),[ow,aw]=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))),sn=new Uint32Array(80),on=new Uint32Array(80),Bn=class extends sw.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:c,Dl:a,Eh:l,El:d,Fh:b,Fl:m,Gh:_,Gl:f,Hh:S,Hl:O}=this;return[e,r,n,i,s,o,c,a,l,d,b,m,_,f,S,O]}set(e,r,n,i,s,o,c,a,l,d,b,m,_,f,S,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=c|0,this.Dl=a|0,this.Eh=l|0,this.El=d|0,this.Fh=b|0,this.Fl=m|0,this.Gh=_|0,this.Gl=f|0,this.Hh=S|0,this.Hl=O|0}process(e,r){for(let M=0;M<16;M++,r+=4)sn[M]=e.getUint32(r),on[M]=e.getUint32(r+=4);for(let M=16;M<80;M++){let $=sn[M-15]|0,v=on[M-15]|0,V=me.default.rotrSH($,v,1)^me.default.rotrSH($,v,8)^me.default.shrSH($,v,7),K=me.default.rotrSL($,v,1)^me.default.rotrSL($,v,8)^me.default.shrSL($,v,7),W=sn[M-2]|0,k=on[M-2]|0,se=me.default.rotrSH(W,k,19)^me.default.rotrBH(W,k,61)^me.default.shrSH(W,k,6),ee=me.default.rotrSL(W,k,19)^me.default.rotrBL(W,k,61)^me.default.shrSL(W,k,6),ie=me.default.add4L(K,ee,on[M-7],on[M-16]),w=me.default.add4H(ie,V,se,sn[M-7],sn[M-16]);sn[M]=w|0,on[M]=ie|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:c,Cl:a,Dh:l,Dl:d,Eh:b,El:m,Fh:_,Fl:f,Gh:S,Gl:O,Hh:F,Hl:q}=this;for(let M=0;M<80;M++){let $=me.default.rotrSH(b,m,14)^me.default.rotrSH(b,m,18)^me.default.rotrBH(b,m,41),v=me.default.rotrSL(b,m,14)^me.default.rotrSL(b,m,18)^me.default.rotrBL(b,m,41),V=b&_^~b&S,K=m&f^~m&O,W=me.default.add5L(q,v,K,aw[M],on[M]),k=me.default.add5H(W,F,$,V,ow[M],sn[M]),se=W|0,ee=me.default.rotrSH(n,i,28)^me.default.rotrBH(n,i,34)^me.default.rotrBH(n,i,39),ie=me.default.rotrSL(n,i,28)^me.default.rotrBL(n,i,34)^me.default.rotrBL(n,i,39),w=n&s^n&c^s&c,g=i&o^i&a^o&a;F=S|0,q=O|0,S=_|0,O=f|0,_=b|0,f=m|0,{h:b,l:m}=me.default.add(l|0,d|0,k|0,se|0),l=c|0,d=a|0,c=s|0,a=o|0,s=n|0,o=i|0;let A=me.default.add3L(se,ie,g);n=me.default.add3H(A,k,ee,w),i=A|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:c,l:a}=me.default.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:l,l:d}=me.default.add(this.Dh|0,this.Dl|0,l|0,d|0),{h:b,l:m}=me.default.add(this.Eh|0,this.El|0,b|0,m|0),{h:_,l:f}=me.default.add(this.Fh|0,this.Fl|0,_|0,f|0),{h:S,l:O}=me.default.add(this.Gh|0,this.Gl|0,S|0,O|0),{h:F,l:q}=me.default.add(this.Hh|0,this.Hl|0,F|0,q|0),this.set(n,i,s,o,c,a,l,d,b,m,_,f,S,O,F,q)}roundClean(){sn.fill(0),on.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)}};ot.SHA512=Bn;var Ho=class extends Bn{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}};ot.SHA512_224=Ho;var Lo=class extends Bn{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}};ot.SHA512_256=Lo;var Vo=class extends Bn{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}};ot.SHA384=Vo;ot.sha512=(0,$o.wrapConstructor)(()=>new Bn);ot.sha512_224=(0,$o.wrapConstructor)(()=>new Ho);ot.sha512_256=(0,$o.wrapConstructor)(()=>new Lo);ot.sha384=(0,$o.wrapConstructor)(()=>new Vo)});var $d=re(Pu=>{"use strict";Object.defineProperty(Pu,"__esModule",{value:!0});Pu.twistedEdwards=lw;var Ru=pu(),Vd=_r(),Pt=Mt(),kt=Mt(),ir=BigInt(0),Rt=BigInt(1),Go=BigInt(2),cw=BigInt(8),uw={zip215:!0};function fw(t){let e=(0,Ru.validateBasic)(t);return Pt.validateObject(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function lw(t){let e=fw(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:c,h:a}=e,l=Go<<BigInt(c*8)-Rt,d=r.create,b=(0,Vd.Field)(e.n,e.nBitLength),m=e.uvRatio||((T,I)=>{try{return{isValid:!0,value:r.sqrt(T*r.inv(I))}}catch{return{isValid:!1,value:ir}}}),_=e.adjustScalarBytes||(T=>T),f=e.domain||((T,I,L)=>{if((0,kt.abool)("phflag",L),I.length||L)throw new Error("Contexts/pre-hash are not supported");return T});function S(T,I){Pt.aInRange("coordinate "+T,I,ir,l)}function O(T){if(!(T instanceof M))throw new Error("ExtendedPoint expected")}let F=(0,kt.memoized)((T,I)=>{let{ex:L,ey:Y,ez:ce}=T,oe=T.is0();I==null&&(I=oe?cw:r.inv(ce));let z=d(L*I),U=d(Y*I),h=d(ce*I);if(oe)return{x:ir,y:Rt};if(h!==Rt)throw new Error("invZ was invalid");return{x:z,y:U}}),q=(0,kt.memoized)(T=>{let{a:I,d:L}=e;if(T.is0())throw new Error("bad point: ZERO");let{ex:Y,ey:ce,ez:oe,et:z}=T,U=d(Y*Y),h=d(ce*ce),X=d(oe*oe),te=d(X*X),de=d(U*I),Q=d(X*d(de+h)),u=d(te+d(L*d(U*h)));if(Q!==u)throw new Error("bad point: equation left != right (1)");let p=d(Y*ce),y=d(oe*z);if(p!==y)throw new Error("bad point: equation left != right (2)");return!0});class M{constructor(I,L,Y,ce){this.ex=I,this.ey=L,this.ez=Y,this.et=ce,S("x",I),S("y",L),S("z",Y),S("t",ce),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(I){if(I instanceof M)throw new Error("extended point not allowed");let{x:L,y:Y}=I||{};return S("x",L),S("y",Y),new M(L,Y,Rt,d(L*Y))}static normalizeZ(I){let L=r.invertBatch(I.map(Y=>Y.ez));return I.map((Y,ce)=>Y.toAffine(L[ce])).map(M.fromAffine)}static msm(I,L){return(0,Ru.pippenger)(M,b,I,L)}_setWindowSize(I){V.setWindowSize(this,I)}assertValidity(){q(this)}equals(I){O(I);let{ex:L,ey:Y,ez:ce}=this,{ex:oe,ey:z,ez:U}=I,h=d(L*U),X=d(oe*ce),te=d(Y*U),de=d(z*ce);return h===X&&te===de}is0(){return this.equals(M.ZERO)}negate(){return new M(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){let{a:I}=e,{ex:L,ey:Y,ez:ce}=this,oe=d(L*L),z=d(Y*Y),U=d(Go*d(ce*ce)),h=d(I*oe),X=L+Y,te=d(d(X*X)-oe-z),de=h+z,Q=de-U,u=h-z,p=d(te*Q),y=d(de*u),R=d(te*u),B=d(Q*de);return new M(p,y,B,R)}add(I){O(I);let{a:L,d:Y}=e,{ex:ce,ey:oe,ez:z,et:U}=this,{ex:h,ey:X,ez:te,et:de}=I;if(L===BigInt(-1)){let Z=d((oe-ce)*(X+h)),J=d((oe+ce)*(X-h)),le=d(J-Z);if(le===ir)return this.double();let we=d(z*Go*de),Fe=d(U*Go*te),Le=Fe+we,ge=J+Z,he=Fe-we,ze=d(Le*le),ur=d(ge*he),Or=d(Le*he),yn=d(le*ge);return new M(ze,ur,yn,Or)}let Q=d(ce*h),u=d(oe*X),p=d(U*Y*de),y=d(z*te),R=d((ce+oe)*(h+X)-Q-u),B=y-p,N=y+p,j=d(u-L*Q),E=d(R*B),P=d(N*j),H=d(R*j),C=d(B*N);return new M(E,P,C,H)}subtract(I){return this.add(I.negate())}wNAF(I){return V.wNAFCached(this,I,M.normalizeZ)}multiply(I){let L=I;Pt.aInRange("scalar",L,Rt,n);let{p:Y,f:ce}=this.wNAF(L);return M.normalizeZ([Y,ce])[0]}multiplyUnsafe(I){let L=I;return Pt.aInRange("scalar",L,ir,n),L===ir?v:this.equals(v)||L===Rt?this:this.equals($)?this.wNAF(L).p:V.unsafeLadder(this,L)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return V.unsafeLadder(this,n).is0()}toAffine(I){return F(this,I)}clearCofactor(){let{h:I}=e;return I===Rt?this:this.multiplyUnsafe(I)}static fromHex(I,L=!1){let{d:Y,a:ce}=e,oe=r.BYTES;I=(0,kt.ensureBytes)("pointHex",I,oe),(0,kt.abool)("zip215",L);let z=I.slice(),U=I[oe-1];z[oe-1]=U&-129;let h=Pt.bytesToNumberLE(z),X=L?l:r.ORDER;Pt.aInRange("pointHex.y",h,ir,X);let te=d(h*h),de=d(te-Rt),Q=d(Y*te-ce),{isValid:u,value:p}=m(de,Q);if(!u)throw new Error("Point.fromHex: invalid y coordinate");let y=(p&Rt)===Rt,R=(U&128)!==0;if(!L&&p===ir&&R)throw new Error("Point.fromHex: x=0 and x_0=1");return R!==y&&(p=d(-p)),M.fromAffine({x:p,y:h})}static fromPrivateKey(I){return k(I).point}toRawBytes(){let{x:I,y:L}=this.toAffine(),Y=Pt.numberToBytesLE(L,r.BYTES);return Y[Y.length-1]|=I&Rt?128:0,Y}toHex(){return Pt.bytesToHex(this.toRawBytes())}}M.BASE=new M(e.Gx,e.Gy,Rt,d(e.Gx*e.Gy)),M.ZERO=new M(ir,Rt,Rt,ir);let{BASE:$,ZERO:v}=M,V=(0,Ru.wNAF)(M,c*8);function K(T){return(0,Vd.mod)(T,n)}function W(T){return K(Pt.bytesToNumberLE(T))}function k(T){let I=c;T=(0,kt.ensureBytes)("private key",T,I);let L=(0,kt.ensureBytes)("hashed private key",s(T),2*I),Y=_(L.slice(0,I)),ce=L.slice(I,2*I),oe=W(Y),z=$.multiply(oe),U=z.toRawBytes();return{head:Y,prefix:ce,scalar:oe,point:z,pointBytes:U}}function se(T){return k(T).pointBytes}function ee(T=new Uint8Array,...I){let L=Pt.concatBytes(...I);return W(s(f(L,(0,kt.ensureBytes)("context",T),!!i)))}function ie(T,I,L={}){T=(0,kt.ensureBytes)("message",T),i&&(T=i(T));let{prefix:Y,scalar:ce,pointBytes:oe}=k(I),z=ee(L.context,Y,T),U=$.multiply(z).toRawBytes(),h=ee(L.context,U,oe,T),X=K(z+h*ce);Pt.aInRange("signature.s",X,ir,n);let te=Pt.concatBytes(U,Pt.numberToBytesLE(X,r.BYTES));return(0,kt.ensureBytes)("result",te,c*2)}let w=uw;function g(T,I,L,Y=w){let{context:ce,zip215:oe}=Y,z=r.BYTES;T=(0,kt.ensureBytes)("signature",T,2*z),I=(0,kt.ensureBytes)("message",I),oe!==void 0&&(0,kt.abool)("zip215",oe),i&&(I=i(I));let U=Pt.bytesToNumberLE(T.slice(z,2*z)),h,X,te;try{h=M.fromHex(L,oe),X=M.fromHex(T.slice(0,z),oe),te=$.multiplyUnsafe(U)}catch{return!1}if(!oe&&h.isSmallOrder())return!1;let de=ee(ce,X.toRawBytes(),h.toRawBytes(),I);return X.add(h.multiplyUnsafe(de)).subtract(te).clearCofactor().equals(M.ZERO)}return $._setWindowSize(8),{CURVE:e,getPublicKey:se,sign:ie,verify:g,ExtendedPoint:M,utils:{getExtendedPublicKey:k,randomPrivateKey:()=>o(r.BYTES),precompute(T=8,I=M.BASE){return I._setWindowSize(T),I.multiply(BigInt(3)),I}}}}});var Dd=re(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});Fu.montgomery=hw;var Gd=_r(),an=Mt(),ii=BigInt(0),Uu=BigInt(1);function dw(t){return(0,an.validateObject)(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function hw(t){let e=dw(t),{P:r}=e,n=q=>(0,Gd.mod)(q,r),i=e.montgomeryBits,s=Math.ceil(i/8),o=e.nByteLength,c=e.adjustScalarBytes||(q=>q),a=e.powPminus2||(q=>(0,Gd.pow)(q,r-BigInt(2),r));function l(q,M,$){let v=n(q*(M-$));return M=n(M-v),$=n($+v),[M,$]}let d=(e.a-BigInt(2))/BigInt(4);function b(q,M){(0,an.aInRange)("u",q,ii,r),(0,an.aInRange)("scalar",M,ii,r);let $=M,v=q,V=Uu,K=ii,W=q,k=Uu,se=ii,ee;for(let w=BigInt(i-1);w>=ii;w--){let g=$>>w&Uu;se^=g,ee=l(se,V,W),V=ee[0],W=ee[1],ee=l(se,K,k),K=ee[0],k=ee[1],se=g;let A=V+K,T=n(A*A),I=V-K,L=n(I*I),Y=T-L,ce=W+k,oe=W-k,z=n(oe*A),U=n(ce*I),h=z+U,X=z-U;W=n(h*h),k=n(v*n(X*X)),V=n(T*L),K=n(Y*(T+n(d*Y)))}ee=l(se,V,W),V=ee[0],W=ee[1],ee=l(se,K,k),K=ee[0],k=ee[1];let ie=a(K);return n(V*ie)}function m(q){return(0,an.numberToBytesLE)(n(q),s)}function _(q){let M=(0,an.ensureBytes)("u coordinate",q,s);return o===32&&(M[31]&=127),(0,an.bytesToNumberLE)(M)}function f(q){let M=(0,an.ensureBytes)("scalar",q),$=M.length;if($!==s&&$!==o)throw new Error(`Expected ${s} or ${o} bytes, got ${$}`);return(0,an.bytesToNumberLE)(c(M))}function S(q,M){let $=_(M),v=f(q),V=b($,v);if(V===ii)throw new Error("Invalid private or public key received");return m(V)}let O=m(e.Gu);function F(q){return S(q,O)}return{scalarMult:S,scalarMultBase:F,getSharedSecret:(q,M)=>S(q,M),getPublicKey:q=>F(q),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:O}}});var nh=re(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.hash_to_ristretto255=be.hashToRistretto255=be.RistrettoPoint=be.encodeToCurve=be.hashToCurve=be.edwardsToMontgomery=be.x25519=be.ed25519ph=be.ed25519ctx=be.ed25519=be.ED25519_TORSION_SUBGROUP=void 0;be.edwardsToMontgomeryPub=th;be.edwardsToMontgomeryPriv=bw;var Ko=Ld(),ts=Gn(),ju=$d(),Yd=So(),Ue=_r(),pw=Dd(),Tn=Mt(),rs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Cu=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),yw=BigInt(0),Er=BigInt(1),Do=BigInt(2),Zd=BigInt(3),Xd=BigInt(5),Hu=BigInt(8);function Qd(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=rs,c=t*t%s*t%s,a=(0,Ue.pow2)(c,Do,s)*c%s,l=(0,Ue.pow2)(a,Er,s)*t%s,d=(0,Ue.pow2)(l,Xd,s)*l%s,b=(0,Ue.pow2)(d,e,s)*d%s,m=(0,Ue.pow2)(b,r,s)*b%s,_=(0,Ue.pow2)(m,n,s)*m%s,f=(0,Ue.pow2)(_,i,s)*_%s,S=(0,Ue.pow2)(f,i,s)*_%s,O=(0,Ue.pow2)(S,e,s)*d%s;return{pow_p_5_8:(0,Ue.pow2)(O,Do,s)*t%s,b2:c}}function Jd(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Lu(t,e){let r=rs,n=(0,Ue.mod)(e*e*e,r),i=(0,Ue.mod)(n*n*e,r),s=Qd(t*i).pow_p_5_8,o=(0,Ue.mod)(t*n*s,r),c=(0,Ue.mod)(e*o*o,r),a=o,l=(0,Ue.mod)(o*Cu,r),d=c===t,b=c===(0,Ue.mod)(-t,r),m=c===(0,Ue.mod)(-t*Cu,r);return d&&(o=a),(b||m)&&(o=l),(0,Ue.isNegativeLE)(o,r)&&(o=(0,Ue.mod)(-o,r)),{isValid:d||b,value:o}}be.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var ae=(0,Ue.Field)(rs,void 0,!0),ns={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ae,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Hu,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ko.sha512,randomBytes:ts.randomBytes,adjustScalarBytes:Jd,uvRatio:Lu};be.ed25519=(0,ju.twistedEdwards)(ns);function eh(t,e,r){if(e.length>255)throw new Error("Context is too big");return(0,ts.concatBytes)((0,ts.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}be.ed25519ctx=(0,ju.twistedEdwards)({...ns,domain:eh});be.ed25519ph=(0,ju.twistedEdwards)(Object.assign({},ns,{domain:eh,prehash:Ko.sha512}));be.x25519=(0,pw.montgomery)({P:rs,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=rs,{pow_p_5_8:r,b2:n}=Qd(t);return(0,Ue.mod)((0,Ue.pow2)(r,Zd,e)*n,e)},adjustScalarBytes:Jd,randomBytes:ts.randomBytes});function th(t){let{y:e}=be.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return ae.toBytes(ae.create((r+e)*ae.inv(r-e)))}be.edwardsToMontgomery=th;function bw(t){let e=ns.hash(t.subarray(0,32));return ns.adjustScalarBytes(e).subarray(0,32)}var gw=(ae.ORDER+Zd)/Hu,mw=ae.pow(Do,gw),Kd=ae.sqrt(ae.neg(ae.ONE));function ww(t){let e=(ae.ORDER-Xd)/Hu,r=BigInt(486662),n=ae.sqr(t);n=ae.mul(n,Do);let i=ae.add(n,ae.ONE),s=ae.neg(r),o=ae.sqr(i),c=ae.mul(o,i),a=ae.mul(n,r);a=ae.mul(a,s),a=ae.add(a,o),a=ae.mul(a,s);let l=ae.sqr(c);o=ae.sqr(l),l=ae.mul(l,c),l=ae.mul(l,a),o=ae.mul(o,l);let d=ae.pow(o,e);d=ae.mul(d,l);let b=ae.mul(d,Kd);o=ae.sqr(d),o=ae.mul(o,c);let m=ae.eql(o,a),_=ae.cmov(b,d,m),f=ae.mul(s,n),S=ae.mul(d,t);S=ae.mul(S,mw);let O=ae.mul(S,Kd),F=ae.mul(a,n);o=ae.sqr(S),o=ae.mul(o,c);let q=ae.eql(o,F),M=ae.cmov(O,S,q);o=ae.sqr(_),o=ae.mul(o,c);let $=ae.eql(o,a),v=ae.cmov(f,s,$),V=ae.cmov(M,_,$),K=ae.isOdd(V);return V=ae.cmov(V,ae.neg(V),$!==K),{xMn:v,xMd:i,yMn:V,yMd:Er}}var _w=(0,Ue.FpSqrtEven)(ae,ae.neg(BigInt(486664)));function Ew(t){let{xMn:e,xMd:r,yMn:n,yMd:i}=ww(t),s=ae.mul(e,i);s=ae.mul(s,_w);let o=ae.mul(r,n),c=ae.sub(e,r),a=ae.add(e,r),l=ae.mul(o,a),d=ae.eql(l,ae.ZERO);s=ae.cmov(s,ae.ZERO,d),o=ae.cmov(o,ae.ONE,d),c=ae.cmov(c,ae.ONE,d),a=ae.cmov(a,ae.ONE,d);let b=ae.invertBatch([o,a]);return{x:ae.mul(s,b[0]),y:ae.mul(c,b[1])}}var rh=(0,Yd.createHasher)(be.ed25519.ExtendedPoint,t=>Ew(t[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:ae.ORDER,m:1,k:128,expand:"xmd",hash:Ko.sha512});be.hashToCurve=rh.hashToCurve;be.encodeToCurve=rh.encodeToCurve;function Mu(t){if(!(t instanceof sr))throw new Error("RistrettoPoint expected")}var ku=Cu,xw=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),vw=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Bw=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Tw=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),zd=t=>Lu(Er,t),Sw=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),qu=t=>be.ed25519.CURVE.Fp.create((0,Tn.bytesToNumberLE)(t)&Sw);function Wd(t){let{d:e}=be.ed25519.CURVE,r=be.ed25519.CURVE.Fp.ORDER,n=be.ed25519.CURVE.Fp.create,i=n(ku*t*t),s=n((i+Er)*Bw),o=BigInt(-1),c=n((o-e*i)*n(i+e)),{isValid:a,value:l}=Lu(s,c),d=n(l*t);(0,Ue.isNegativeLE)(d,r)||(d=n(-d)),a||(l=d),a||(o=i);let b=n(o*(i-Er)*Tw-c),m=l*l,_=n((l+l)*c),f=n(b*xw),S=n(Er-m),O=n(Er+m);return new be.ed25519.ExtendedPoint(n(_*O),n(S*f),n(f*O),n(_*S))}var sr=class t{constructor(e){this.ep=e}static fromAffine(e){return new t(be.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,Tn.ensureBytes)("ristrettoHash",e,64);let r=qu(e.slice(0,32)),n=Wd(r),i=qu(e.slice(32,64)),s=Wd(i);return new t(n.add(s))}static fromHex(e){e=(0,Tn.ensureBytes)("ristrettoHex",e,32);let{a:r,d:n}=be.ed25519.CURVE,i=be.ed25519.CURVE.Fp.ORDER,s=be.ed25519.CURVE.Fp.create,o="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",c=qu(e);if(!(0,Tn.equalBytes)((0,Tn.numberToBytesLE)(c,32),e)||(0,Ue.isNegativeLE)(c,i))throw new Error(o);let a=s(c*c),l=s(Er+r*a),d=s(Er-r*a),b=s(l*l),m=s(d*d),_=s(r*n*b-m),{isValid:f,value:S}=zd(s(_*m)),O=s(S*d),F=s(S*O*_),q=s((c+c)*O);(0,Ue.isNegativeLE)(q,i)&&(q=s(-q));let M=s(l*F),$=s(q*M);if(!f||(0,Ue.isNegativeLE)($,i)||M===yw)throw new Error(o);return new t(new be.ed25519.ExtendedPoint(q,M,Er,$))}toRawBytes(){let{ex:e,ey:r,ez:n,et:i}=this.ep,s=be.ed25519.CURVE.Fp.ORDER,o=be.ed25519.CURVE.Fp.create,c=o(o(n+r)*o(n-r)),a=o(e*r),l=o(a*a),{value:d}=zd(o(c*l)),b=o(d*c),m=o(d*a),_=o(b*m*i),f;if((0,Ue.isNegativeLE)(i*_,s)){let O=o(r*ku),F=o(e*ku);e=O,r=F,f=o(b*vw)}else f=m;(0,Ue.isNegativeLE)(e*_,s)&&(r=o(-r));let S=o((n-r)*f);return(0,Ue.isNegativeLE)(S,s)&&(S=o(-S)),(0,Tn.numberToBytesLE)(S,32)}toHex(){return(0,Tn.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){Mu(e);let{ex:r,ey:n}=this.ep,{ex:i,ey:s}=e.ep,o=be.ed25519.CURVE.Fp.create,c=o(r*s)===o(n*i),a=o(n*s)===o(r*i);return c||a}add(e){return Mu(e),new t(this.ep.add(e.ep))}subtract(e){return Mu(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())}};be.RistrettoPoint=(sr.BASE||(sr.BASE=new sr(be.ed25519.ExtendedPoint.BASE)),sr.ZERO||(sr.ZERO=new sr(be.ed25519.ExtendedPoint.ZERO)),sr);var Aw=(t,e)=>{let r=e.DST,n=typeof r=="string"?(0,ts.utf8ToBytes)(r):r,i=(0,Yd.expand_message_xmd)(t,n,64,Ko.sha512);return sr.hashToCurve(i)};be.hashToRistretto255=Aw;be.hash_to_ristretto255=be.hashToRistretto255});var ah=re(cn=>{"use strict";var ih=cn&&cn.__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},vt=cn&&cn.__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)},gt,is,sh,oh;Object.defineProperty(cn,"__esModule",{value:!0});cn.ExpirableMap=void 0;var Vu=class{constructor(e={}){gt.set(this,void 0),is.set(this,void 0),this[sh]=this.entries.bind(this),this[oh]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();ih(this,gt,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),ih(this,is,n,"f")}prune(){let e=Date.now();for(let[r,n]of vt(this,gt,"f").entries())e-n.timestamp>vt(this,is,"f")&&vt(this,gt,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return vt(this,gt,"f").set(e,n),this}get(e){let r=vt(this,gt,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>vt(this,is,"f")){vt(this,gt,"f").delete(e);return}return r.value}}clear(){vt(this,gt,"f").clear()}entries(){let e=vt(this,gt,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=vt(this,gt,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return vt(this,gt,"f").keys()}forEach(e,r){for(let[n,i]of vt(this,gt,"f").entries())e.call(r,i.value,n,this)}has(e){return vt(this,gt,"f").has(e)}delete(e){return vt(this,gt,"f").delete(e)}get size(){return vt(this,gt,"f").size}};cn.ExpirableMap=Vu;gt=new WeakMap,is=new WeakMap,sh=Symbol.iterator,oh=Symbol.toStringTag});var $u=re(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});ke.unwrapDER=ke.wrapDER=ke.SECP256K1_OID=ke.ED25519_OID=ke.DER_COSE_OID=ke.decodeLen=ke.decodeLenBytes=ke.encodeLen=ke.encodeLenBytes=void 0;var Iw=It(),Nw=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)")};ke.encodeLenBytes=Nw;var Ow=(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)")};ke.encodeLen=Ow;var Rw=(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)")};ke.decodeLenBytes=Rw;var Pw=(t,e)=>{let r=(0,ke.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)")};ke.decodeLen=Pw;ke.DER_COSE_OID=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]);ke.ED25519_OID=Uint8Array.from([48,5,6,3,43,101,112]);ke.SECP256K1_OID=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function Uw(t,e){let r=2+(0,ke.encodeLenBytes)(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,s=new Uint8Array(1+(0,ke.encodeLenBytes)(n)+n);return s[i++]=48,i+=(0,ke.encodeLen)(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=(0,ke.encodeLen)(s,i,t.byteLength+1),s[i++]=0,s.set(new Uint8Array(t),i),s}ke.wrapDER=Uw;var Fw=(t,e)=>{let r=0,n=(c,a)=>{if(i[r++]!==c)throw new Error("Expected: "+a)},i=new Uint8Array(t);if(n(48,"sequence"),r+=(0,ke.decodeLenBytes)(i,r),!(0,Iw.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,ke.decodeLen)(i,r)-1;r+=(0,ke.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};ke.unwrapDER=Fw});var Gu=re(un=>{"use strict";var ch=un&&un.__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},uh=un&&un.__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)},Wo,Yo;Object.defineProperty(un,"__esModule",{value:!0});un.Ed25519PublicKey=void 0;var zo=$u(),Zo=class t{constructor(e){if(Wo.set(this,void 0),Yo.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");ch(this,Wo,e,"f"),ch(this,Yo,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 uh(this,Wo,"f")}get derKey(){return uh(this,Yo,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};un.Ed25519PublicKey=Zo;Wo=new WeakMap,Yo=new WeakMap;Zo.RAW_KEY_LENGTH=32});var fh=re(si=>{"use strict";Object.defineProperty(si,"__esModule",{value:!0});si.ObservableLog=si.Observable=void 0;var Xo=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))}};si.Observable=Xo;var Du=class extends Xo{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)}};si.ObservableLog=Du});var gh=re(Br=>{"use strict";var xr=Br&&Br.__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=Br&&Br.__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)},vr,Qo,Jo,ea,ta,ra,na,ia,oi;Object.defineProperty(Br,"__esModule",{value:!0});Br.exponentialBackoff=Br.ExponentialBackoff=void 0;var lh=.5,dh=1.5,hh=500,ph=6e4,yh=9e5,bh=10,ai=class t{constructor(e=t.default){vr.set(this,void 0),Qo.set(this,void 0),Jo.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),oi.set(this,0);let{initialInterval:r=hh,randomizationFactor:n=lh,multiplier:i=dh,maxInterval:s=ph,maxElapsedTime:o=yh,maxIterations:c=bh,date:a=Date}=e;xr(this,vr,r,"f"),xr(this,Qo,n,"f"),xr(this,Jo,i,"f"),xr(this,ea,s,"f"),xr(this,ia,a,"f"),xr(this,ta,a.now(),"f"),xr(this,ra,o,"f"),xr(this,na,c,"f")}get ellapsedTimeInMsec(){return mt(this,ia,"f").now()-mt(this,ta,"f")}get currentInterval(){return mt(this,vr,"f")}get count(){return mt(this,oi,"f")}get randomValueFromInterval(){let e=mt(this,Qo,"f")*mt(this,vr,"f"),r=mt(this,vr,"f")-e,n=mt(this,vr,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return xr(this,vr,Math.min(mt(this,vr,"f")*mt(this,Jo,"f"),mt(this,ea,"f")),"f"),xr(this,oi,(e=mt(this,oi,"f"),e++,e),"f"),mt(this,vr,"f")}next(){return this.ellapsedTimeInMsec>=mt(this,ra,"f")||mt(this,oi,"f")>=mt(this,na,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Br.ExponentialBackoff=ai;vr=new WeakMap,Qo=new WeakMap,Jo=new WeakMap,ea=new WeakMap,ta=new WeakMap,ra=new WeakMap,na=new WeakMap,ia=new WeakMap,oi=new WeakMap;ai.default={initialInterval:hh,randomizationFactor:lh,multiplier:dh,maxInterval:ph,maxElapsedTime:yh,maxIterations:bh,date:Date};function*Mw(t=ai.default){let e=new ai(t),r=e.next();for(;r;)yield r,r=e.next()}Br.exponentialBackoff=Mw});var Ku=re(sa=>{"use strict";Object.defineProperty(sa,"__esModule",{value:!0});sa.DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS=void 0;sa.DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS=5*60*1e3});var Xu=re(Me=>{"use strict";var mh=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]}),qw=Me&&Me.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),wh=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)&&mh(e,t,r);return qw(e,t),e},Cw=Me&&Me.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&mh(e,t,r)},Bt=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},ue=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)},Sr,Tr,ln,li,ss,os,or,ca,ar,Sn,An,as,ui,fi,In,Nn,_h,ua,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 Kt=$t(),jr=Dn(),kw=Dc(),fn=wh(Vi()),oa=Hi(),zu=It(),zt=wo(),Wu=$i(),Yu=ru(),jw=es(),ci=ni(),Hw=nh(),Lw=ah(),Vw=Gu(),$w=Mo(),Gw=fh(),Dw=gh(),Kw=Ku();Cw(wo(),Me);var zw=$i();Object.defineProperty(Me,"makeNonce",{enumerable:!0,get:function(){return zw.makeNonce}});var Ww;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(Ww=Me.RequestStatusResponseStatus||(Me.RequestStatusResponseStatus={}));var aa=60*1e3;Me.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";Me.MANAGEMENT_CANISTER_ID="aaaaa-aa";var Yw="ic0.app",Zw=".ic0.app",Xw="icp0.io",Qw=".icp0.io",Jw="icp-api.io",e2=".icp-api.io",cs=class extends jr.AgentError{constructor(e){super(e),this.message=e}},On=class extends jr.AgentError{constructor(e){super(e),this.message=e}};Me.IdentityInvalidError=On;function t2(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new cs("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 cs("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 cs("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function r2(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(c=>s.endsWith(c))?o=s:o=r.find(c=>s.endsWith(c))),i&&o?e=new URL(`${i.protocol}//${o}${i.port?":"+i.port:""}`):e=new URL("https://icp-api.io")}return e.toString()}var Zu=class t{constructor(e={}){var r;Sr.add(this),Tr.set(this,void 0),ln.set(this,void 0),li.set(this,void 0),ss.set(this,void 0),os.set(this,0),or.set(this,void 0),ca.set(this,!1),ar.set(this,void 0),Sn.set(this,void 0),An.set(this,void 0),this._isAgent=!0,this.config={},as.set(this,0),this.log=new Gw.ObservableLog,ui.set(this,[]),fi.set(this,[]),In.set(this,new Lw.ExpirableMap({expirationTime:5*60*1e3})),Nn.set(this,!0),fa.set(this,(s,o)=>{if(ue(this,Nn,"f")===!1)return s;if(!o)throw new ci.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:c,signatures:a=[],requestId:l}=s,d=new TextEncoder().encode("\vic-response");for(let b of a){let{timestamp:m,identity:_}=b,f=Kt.Principal.fromUint8Array(_).toText(),S;if(c==="replied"){let{reply:$}=s;S=(0,oa.hashOfMap)({status:c,reply:$,timestamp:BigInt(m),request_id:l})}else if(c==="rejected"){let{reject_code:$,reject_message:v,error_code:V}=s;S=(0,oa.hashOfMap)({status:c,reject_code:$,reject_message:v,error_code:V,timestamp:BigInt(m),request_id:l})}else throw new Error(`Unknown status: ${c}`);let O=(0,zu.concat)(d,new Uint8Array(S)),F=o?.nodeKeys.get(f);if(!F)throw new ci.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let q=Vw.Ed25519PublicKey.fromDer(F).rawKey;if(Hw.ed25519.verify(b.signature,new Uint8Array(O),new Uint8Array(q)))return s;throw new ci.CertificateVerificationError(`Invalid signature from replica ${f} signed query.`)}return s}),this.config=e,Bt(this,ln,e.fetch||t2()||fetch.bind(global),"f"),Bt(this,li,e.fetchOptions,"f"),Bt(this,ss,e.callOptions,"f"),this.rootKey=e.rootKey?e.rootKey:(0,zu.fromHex)(Me.IC_ROOT_KEY);let n=r2(e.host);this.host=new URL(n),e.verifyQuerySignatures!==void 0&&Bt(this,Nn,e.verifyQuerySignatures,"f"),Bt(this,ar,(r=e.retryTimes)!==null&&r!==void 0?r:3,"f");let i=()=>new Dw.ExponentialBackoff({maxIterations:ue(this,ar,"f")});if(Bt(this,Sn,e.backoffStrategy||i,"f"),this.host.hostname.endsWith(Zw)?this.host.hostname=Yw:this.host.hostname.endsWith(Qw)?this.host.hostname=Xw:this.host.hostname.endsWith(e2)&&(this.host.hostname=Jw),e.credentials){let{name:s,password:o}=e.credentials;Bt(this,or,`${s}${o?":"+o:""}`,"f")}if(Bt(this,Tr,Promise.resolve(e.identity||new kw.AnonymousIdentity),"f"),e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes>5)throw new jr.AgentError(`The maximum ingress expiry time is 5 minutes. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);if(e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes<=0)throw new jr.AgentError(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);Bt(this,An,e.ingressExpiryInMinutes||5,"f"),this.addTransform("update",(0,zt.makeNonceTransform)(Wu.makeNonce)),e.useQueryNonces&&this.addTransform("query",(0,zt.makeNonceTransform)(Wu.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 ue(this,as,"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 jr.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=ue(this,fi,"f").findIndex(s=>(s.priority||0)<n);ue(this,fi,"f").splice(i>=0?i:ue(this,fi,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=ue(this,ui,"f").findIndex(s=>(s.priority||0)<n);ue(this,ui,"f").splice(i>=0?i:ue(this,ui,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!ue(this,Tr,"f"))throw new On("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ue(this,Tr,"f")).getPrincipal()}async call(e,r,n){var i;let s=(i=r.callSync)!==null&&i!==void 0?i:!0,o=await(n!==void 0?await n:await ue(this,Tr,"f"));if(!o)throw new On("This identity has expired due this application's security policy. Please refresh your authentication.");let c=Kt.Principal.from(e),a=r.effectiveCanisterId?Kt.Principal.from(r.effectiveCanisterId):c,l=o.getPrincipal()||Kt.Principal.anonymous(),d=new zt.Expiry(ue(this,An,"f")*aa);Math.abs(ue(this,os,"f"))>1e3*30&&(d=new zt.Expiry(ue(this,An,"f")*aa+ue(this,os,"f")));let b={request_type:Wu.SubmitRequestType.Call,canister_id:c,method_name:r.methodName,arg:r.arg,sender:l,ingress_expiry:d},m=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ue(this,or,"f")?{Authorization:"Basic "+btoa(ue(this,or,"f"))}:{})},endpoint:"call",body:b}),_=m.body.nonce?f(m.body.nonce):void 0;b.nonce=_;function f(F){return new Uint8Array(F)}m=await o.transformRequest(m);let S=fn.encode(m.body),O=ue(this,Sn,"f").call(this);try{let F=()=>(this.log.print(`fetching "/api/v3/canister/${a.toText()}/call" with request:`,m),ue(this,ln,"f").call(this,""+new URL(`/api/v3/canister/${a.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ue(this,ss,"f")),m.request),{body:S}))),q=()=>(this.log.print(`fetching "/api/v2/canister/${a.toText()}/call" with request:`,m),ue(this,ln,"f").call(this,""+new URL(`/api/v2/canister/${a.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ue(this,ss,"f")),m.request),{body:S}))),M=ue(this,Sr,"m",ua).call(this,{request:s?F:q,backoff:O,tries:0}),[$,v]=await Promise.all([M,(0,oa.requestIdOf)(b)]),V=await $.arrayBuffer(),K=$.status===200&&V.byteLength>0?fn.decode(V):null;if(K&&"certificate"in K){let W=await this.parseTimeFromResponse({certificate:K.certificate});Bt(this,as,W,"f")}return{requestId:v,response:{ok:$.ok,status:$.status,statusText:$.statusText,body:K,headers:(0,zt.httpHeadersTransform)($.headers)},requestDetails:b}}catch(F){if(F.message.includes("v3 api not supported."))return this.log.warn("v3 api not supported. Fall back to v2"),this.call(e,Object.assign(Object.assign({},r),{callSync:!1}),n);throw this.log.error("Error while making call:",F),F}}async query(e,r,n){let i=ue(this,Sn,"f").call(this),s=r.effectiveCanisterId?Kt.Principal.from(r.effectiveCanisterId):Kt.Principal.from(e);this.log.print(`ecid ${s.toString()}`),this.log.print(`canisterId ${e.toString()}`);let o=async()=>{let _=await(n!==void 0?n:ue(this,Tr,"f"));if(!_)throw new On("This identity has expired due this application's security policy. Please refresh your authentication.");let f=Kt.Principal.from(e),S=_?.getPrincipal()||Kt.Principal.anonymous(),O={request_type:"query",canister_id:f,method_name:r.methodName,arg:r.arg,sender:S,ingress_expiry:new zt.Expiry(ue(this,An,"f")*aa)},F=await(0,oa.requestIdOf)(O),q=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ue(this,or,"f")?{Authorization:"Basic "+btoa(ue(this,or,"f"))}:{})},endpoint:"read",body:O});q=await _?.transformRequest(q);let M=fn.encode(q.body),$={canister:f.toText(),ecid:s,transformedRequest:q,body:M,requestId:F,backoff:i,tries:0};return{requestDetails:O,query:await ue(this,Sr,"m",_h).call(this,$)}},c=async()=>{if(!ue(this,Nn,"f"))return;let _=ue(this,In,"f").get(s.toString());return _||(await this.fetchSubnetKeys(s.toString()),ue(this,In,"f").get(s.toString()))},[a,l]=await Promise.all([o(),c()]),{requestDetails:d,query:b}=a,m=Object.assign(Object.assign({},b),{requestDetails:d});if(this.log.print("Query response:",m),!ue(this,Nn,"f"))return m;try{return ue(this,fa,"f").call(this,m,l)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ue(this,In,"f").delete(e.toString()),await this.fetchSubnetKeys(s.toString());let f=ue(this,In,"f").get(e.toString());if(!f)throw new ci.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return ue(this,fa,"f").call(this,m,f)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await ue(this,Tr,"f"));if(!n)throw new On("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||Kt.Principal.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ue(this,or,"f")?{Authorization:"Basic "+btoa(ue(this,or,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new zt.Expiry(ue(this,An,"f")*aa)}});return n?.transformRequest(s)}async readState(e,r,n,i){let s=typeof e=="string"?Kt.Principal.fromText(e):e,o=i??await this.createReadStateRequest(r,n),c=Object.assign(Object.assign({},o.body),{ingress_expiry:new zt.Expiry(Kw.DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS)}),a=fn.encode(c);this.log.print(`fetching "/api/v2/canister/${s}/read_state" with request:`,o);let l=ue(this,Sn,"f").call(this);try{let d=await ue(this,Sr,"m",ua).call(this,{request:()=>ue(this,ln,"f").call(this,""+new URL(`/api/v2/canister/${s.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ue(this,li,"f")),o.request),{body:a})),backoff:l,tries:0});if(!d.ok)throw new Error(`Server returned an error:
|
|
31
|
+
Code: ${d.status} (${d.statusText})
|
|
32
|
+
Body: ${await d.text()}
|
|
33
|
+
`);let b=fn.decode(await d.arrayBuffer());this.log.print("Read state response:",b);let m=await this.parseTimeFromResponse(b);return m>0&&(this.log.print("Read state response time:",m),Bt(this,as,m,"f")),b}catch(d){throw this.log.error("Caught exception while attempting to read state",d),d}}async parseTimeFromResponse(e){let r;if(e.certificate){let n=fn.decode(e.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=(0,ci.lookup_path)(["time"],r);if(i.status!==ci.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,$w.decodeTime)((0,zu.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(()=>wh(es())),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??Kt.Principal.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");s&&Bt(this,os,Number(s)-Number(n),"f")}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=ue(this,or,"f")?{Authorization:"Basic "+btoa(ue(this,or,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=ue(this,Sn,"f").call(this),n=await ue(this,Sr,"m",ua).call(this,{backoff:r,request:()=>ue(this,ln,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:e},ue(this,li,"f"))),tries:0});return fn.decode(await n.arrayBuffer())}async fetchRootKey(){if(!ue(this,ca,"f")){let e=await this.status();this.rootKey=e.root_key,Bt(this,ca,!0,"f")}return this.rootKey}invalidateIdentity(){Bt(this,Tr,null,"f")}replaceIdentity(e){Bt(this,Tr,Promise.resolve(e),"f")}async fetchSubnetKeys(e){let r=Kt.Principal.from(e),i=(await(0,jw.request)({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return ue(this,In,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of ue(this,fi,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of ue(this,ui,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};Me.HttpAgent=Zu;Tr=new WeakMap,ln=new WeakMap,li=new WeakMap,ss=new WeakMap,os=new WeakMap,or=new WeakMap,ca=new WeakMap,ar=new WeakMap,Sn=new WeakMap,An=new WeakMap,as=new WeakMap,ui=new WeakMap,fi=new WeakMap,In=new WeakMap,Nn=new WeakMap,fa=new WeakMap,Sr=new WeakSet,_h=async function t(e){var r,n;let{ecid:i,transformedRequest:s,body:o,requestId:c,backoff:a,tries:l}=e,d=l===0?0:a.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:l,backoff:a,delay:d}),d===null)throw new jr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ue(this,ar,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);d>0&&await new Promise(f=>setTimeout(f,d));let b;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let f=await ue(this,ln,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},ue(this,li,"f")),s.request),{body:o}));if(f.status===200){let S=fn.decode(await f.arrayBuffer());b=Object.assign(Object.assign({},S),{httpDetails:{ok:f.ok,status:f.status,statusText:f.statusText,headers:(0,zt.httpHeadersTransform)(f.headers)},requestId:c})}else throw new Yu.AgentHTTPResponseError(`Gateway returned an error:
|
|
34
|
+
Code: ${f.status} (${f.statusText})
|
|
35
|
+
Body: ${await f.text()}
|
|
36
|
+
`,{ok:f.ok,status:f.status,statusText:f.statusText,headers:(0,zt.httpHeadersTransform)(f.headers)})}catch(f){if(l<ue(this,ar,"f"))return this.log.warn(`Caught exception while attempting to make query:
|
|
37
|
+
${f}
|
|
38
|
+
Retrying query.`),await ue(this,Sr,"m",t).call(this,Object.assign(Object.assign({},e),{tries:l+1}));throw f}let m=(n=(r=b.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!ue(this,Nn,"f"))return b;if(!m)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let _=Number(BigInt(m)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:_}),Number(this.waterMark)>_){let f=new jr.AgentError("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",f,{timestamp:m,waterMark:this.waterMark}),l<ue(this,ar,"f"))return await ue(this,Sr,"m",t).call(this,Object.assign(Object.assign({},e),{tries:l+1}));throw new jr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ue(this,ar,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return b},ua=async function t(e){let{request:r,backoff:n,tries:i}=e,s=i===0?0:n.next();if(s===null)throw new jr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ue(this,ar,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(l=>setTimeout(l,s));let o;try{o=await r()}catch(l){if(ue(this,ar,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
|
|
39
|
+
${l}
|
|
40
|
+
Retrying request.`),await ue(this,Sr,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw l}if(o.ok)return o;let c=await o.clone().text(),a=`Server returned an error:
|
|
41
|
+
Code: ${o.status} (${o.statusText})
|
|
42
|
+
Body: ${c}
|
|
43
|
+
`;if(o.status===404&&o.url.includes("api/v3"))throw new Yu.AgentHTTPResponseError("v3 api not supported. Fall back to v2",{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,zt.httpHeadersTransform)(o.headers)});if(i<ue(this,ar,"f"))return await ue(this,Sr,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw new Yu.AgentHTTPResponseError(a,{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,zt.httpHeadersTransform)(o.headers)})}});var Eh=re(Hr=>{"use strict";Object.defineProperty(Hr,"__esModule",{value:!0});Hr.ProxyAgent=Hr.ProxyStubAgent=Hr.ProxyMessageKind=void 0;var n2=$t(),Ye;(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"})(Ye=Hr.ProxyMessageKind||(Hr.ProxyMessageKind={}));var Qu=class{constructor(e,r){this._frontend=e,this._agent=r}onmessage(e){switch(e.type){case Ye.GetPrincipal:this._agent.getPrincipal().then(r=>{this._frontend({id:e.id,type:Ye.GetPrincipalResponse,response:r.toText()})});break;case Ye.Query:this._agent.query(...e.args).then(r=>{this._frontend({id:e.id,type:Ye.QueryResponse,response:r})});break;case Ye.Call:this._agent.call(...e.args).then(r=>{this._frontend({id:e.id,type:Ye.CallResponse,response:r})});break;case Ye.ReadState:this._agent.readState(...e.args).then(r=>{this._frontend({id:e.id,type:Ye.ReadStateResponse,response:r})});break;case Ye.Status:this._agent.status().then(r=>{this._frontend({id:e.id,type:Ye.StatusResponse,response:r})});break;default:throw new Error(`Invalid message received: ${JSON.stringify(e)}`)}}};Hr.ProxyStubAgent=Qu;var Ju=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 Ye.Error:return s(e.error);case Ye.GetPrincipalResponse:case Ye.CallResponse:case Ye.QueryResponse:case Ye.ReadStateResponse:case Ye.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:Ye.GetPrincipal}).then(e=>{if(typeof e!="string")throw new Error("Invalid principal received.");return n2.Principal.fromText(e)})}readState(e,r){return this._sendAndWait({id:this._nextId++,type:Ye.ReadState,args:[e.toString(),r]})}call(e,r){return this._sendAndWait({id:this._nextId++,type:Ye.Call,args:[e.toString(),r]})}status(){return this._sendAndWait({id:this._nextId++,type:Ye.Status})}query(e,r){return this._sendAndWait({id:this._nextId++,type:Ye.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}};Hr.ProxyAgent=Ju});var Ji=re(Wt=>{"use strict";var i2=Wt&&Wt.__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]}),la=Wt&&Wt.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&i2(e,t,r)};Object.defineProperty(Wt,"__esModule",{value:!0});Wt.getDefaultAgent=void 0;la(Ga(),Wt);la(Xu(),Wt);la(ru(),Wt);la(Eh(),Wt);function s2(){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}Wt.getDefaultAgent=s2});var da=re(at=>{"use strict";Object.defineProperty(at,"__esModule",{value:!0});at.chain=at.backoff=at.timeout=at.throttle=at.maxAttempts=at.conditionalDelay=at.once=at.defaultStrategy=void 0;var xh=It(),o2=5*60*1e3;function a2(){return Ah(Bh(vh(),1e3),Sh(1e3,1.2),Th(o2))}at.defaultStrategy=a2;function vh(){let t=!0;return async()=>t?(t=!1,!0):!1}at.once=vh;function Bh(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(s=>setTimeout(s,e))}}at.conditionalDelay=Bh;function c2(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:
|
|
44
|
+
Request ID: ${(0,xh.toHex)(n)}
|
|
45
|
+
Request status: ${i}
|
|
46
|
+
`)}}at.maxAttempts=c2;function u2(t){return()=>new Promise(e=>setTimeout(e,t))}at.throttle=u2;function Th(t){let e=Date.now()+t;return async(r,n,i)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
|
|
47
|
+
Request ID: ${(0,xh.toHex)(n)}
|
|
48
|
+
Request status: ${i}
|
|
49
|
+
`)}}at.timeout=Th;function Sh(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}at.backoff=Sh;function Ah(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}at.chain=Ah});var ha=re(Ut=>{"use strict";var f2=Ut&&Ut.__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=Ut&&Ut.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),d2=Ut&&Ut.__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)&&f2(e,t,r);return l2(e,t),e};Object.defineProperty(Ut,"__esModule",{value:!0});Ut.pollForResponse=Ut.defaultStrategy=Ut.strategy=void 0;var dn=Ji(),us=ni(),Ih=It();Ut.strategy=d2(da());var h2=da(),p2=Ku(),y2=da();Object.defineProperty(Ut,"defaultStrategy",{enumerable:!0,get:function(){return y2.defaultStrategy}});async function Nh(t,e,r,n=(0,h2.defaultStrategy)(),i,s){var o;let c=[new TextEncoder().encode("request_status"),r],a=i??await((o=t.createReadStateRequest)===null||o===void 0?void 0:o.call(t,{paths:[c]}));a.body.content.ingress_expiry=new dn.Expiry(p2.DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS);let l=await t.readState(e,{paths:[c]},void 0,a);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let d=await us.Certificate.create({certificate:l.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:s}),b=(0,us.lookupResultToBuffer)(d.lookup([...c,new TextEncoder().encode("status")])),m;switch(typeof b>"u"?m=dn.RequestStatusResponseStatus.Unknown:m=new TextDecoder().decode(b),m){case dn.RequestStatusResponseStatus.Replied:return{reply:(0,us.lookupResultToBuffer)(d.lookup([...c,"reply"])),certificate:d};case dn.RequestStatusResponseStatus.Received:case dn.RequestStatusResponseStatus.Unknown:case dn.RequestStatusResponseStatus.Processing:return await n(e,r,m),Nh(t,e,r,n,a,s);case dn.RequestStatusResponseStatus.Rejected:{let _=new Uint8Array((0,us.lookupResultToBuffer)(d.lookup([...c,"reject_code"])))[0],f=new TextDecoder().decode((0,us.lookupResultToBuffer)(d.lookup([...c,"reject_message"])));throw new Error(`Call was rejected:
|
|
50
|
+
Request ID: ${(0,Ih.toHex)(r)}
|
|
51
|
+
Reject code: ${_}
|
|
52
|
+
Reject text: ${f}
|
|
53
|
+
`)}case dn.RequestStatusResponseStatus.Done:throw new Error(`Call was marked as done but we never saw the reply:
|
|
54
|
+
Request ID: ${(0,Ih.toHex)(r)}
|
|
55
|
+
`)}throw new Error("unreachable")}Ut.pollForResponse=Nh});var Oh=re(ef=>{"use strict";Object.defineProperty(ef,"__esModule",{value:!0});ef.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}),c=t.Nat64,a=t.Vec(c),l=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),b=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),m=t.Record({height:t.Nat32,value:i,outpoint:b}),_=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:d,utxos:t.Vec(m)}),f=t.Record({transaction:t.Vec(t.Nat8),network:e}),S=t.Principal,O=t.Record({canister_id:S,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})}),q=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}),M=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:F,details:q}),$=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(M),total_num_changes:t.Nat64}),v=t.Record({canister_id:S}),V=t.Variant({controllers:t.Null,public:t.Null}),K=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:V,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),W=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:K,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}),k=t.Record({canister_id:S}),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(V),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)}),ie=t.Record({canister_id:S}),w=t.Record({canister_id:S}),g=t.Record({canister_id:S}),A=t.Variant({secp256k1:t.Null}),T=t.Record({key_id:t.Record({name:t.Text,curve:A}),canister_id:t.Opt(S),derivation_path:t.Vec(t.Vec(t.Nat8))}),I=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),L=t.Record({canister_id:S}),Y=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),ce=t.Record({canister_log_records:t.Vec(Y)}),oe=t.Record({value:t.Text,name:t.Text}),z=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(oe)}),U=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:z})],[z],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(oe)}),h=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}),X=t.Record({hash:t.Vec(t.Nat8)}),te=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:h,chunk_hashes_list:t.Vec(X),target_canister:S,store_canister:t.Opt(S),sender_canister_version:t.Opt(t.Nat64)}),de=t.Vec(t.Nat8),Q=t.Record({arg:t.Vec(t.Nat8),wasm_module:de,mode:h,canister_id:S,sender_canister_version:t.Opt(t.Nat64)}),u=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),p=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_proposed_total:t.Nat64}),y=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(p)})),R=t.Record({settings:t.Opt(se),specified_id:t.Opt(S),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),B=t.Record({canister_id:S}),N=t.Record({canister_id:S,amount:t.Nat}),j=t.Vec(t.Nat8),E=t.Variant({ed25519:t.Null,bip340secp256k1:t.Null}),P=t.Record({key_id:t.Record({algorithm:E,name:t.Text}),canister_id:t.Opt(S),derivation_path:t.Vec(t.Vec(t.Nat8))}),H=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),C=t.Record({key_id:t.Record({name:t.Text,curve:A}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),Z=t.Record({signature:t.Vec(t.Nat8)}),J=t.Record({key_id:t.Record({algorithm:E,name:t.Text}),derivation_path:t.Vec(t.Vec(t.Nat8)),message:t.Vec(t.Nat8)}),le=t.Record({signature:t.Vec(t.Nat8)}),we=t.Record({canister_id:S}),Fe=t.Record({canister_id:S}),Le=t.Record({canister_id:S}),ge=t.Vec(X),he=t.Record({canister_id:S,sender_canister_version:t.Opt(t.Nat64)}),ze=t.Record({canister_id:t.Principal,settings:se,sender_canister_version:t.Opt(t.Nat64)}),ur=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),Or=X;return t.Service({bitcoin_get_balance:t.Func([n],[s],[]),bitcoin_get_current_fee_percentiles:t.Func([o],[a],[]),bitcoin_get_utxos:t.Func([l],[_],[]),bitcoin_send_transaction:t.Func([f],[],[]),canister_info:t.Func([O],[$],[]),canister_status:t.Func([v],[W],[]),clear_chunk_store:t.Func([k],[],[]),create_canister:t.Func([ee],[ie],[]),delete_canister:t.Func([w],[],[]),deposit_cycles:t.Func([g],[],[]),ecdsa_public_key:t.Func([T],[I],[]),fetch_canister_logs:t.Func([L],[ce],["query"]),http_request:t.Func([U],[z],[]),install_chunked_code:t.Func([te],[],[]),install_code:t.Func([Q],[],[]),node_metrics_history:t.Func([u],[y],[]),provisional_create_canister_with_cycles:t.Func([R],[B],[]),provisional_top_up_canister:t.Func([N],[],[]),raw_rand:t.Func([],[j],[]),schnorr_public_key:t.Func([P],[H],[]),sign_with_ecdsa:t.Func([C],[Z],[]),sign_with_schnorr:t.Func([J],[le],[]),start_canister:t.Func([we],[],[]),stop_canister:t.Func([Fe],[],[]),stored_chunks:t.Func([Le],[ge],[]),uninstall_code:t.Func([he],[],[]),update_settings:t.Func([ze],[],[]),upload_chunk:t.Func([ur],[Or],[])})}});var ba=re($e=>{"use strict";var b2=$e&&$e.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty($e,"__esModule",{value:!0});$e.AdvancedActor=$e.getManagementCanister=$e.ACTOR_METHOD_WITH_CERTIFICATE=$e.ACTOR_METHOD_WITH_HTTP_DETAILS=$e.Actor=$e.UpdateCallRejectedError=$e.QueryCallRejectedError=$e.ActorCallError=void 0;var g2=el(),tf=Ji(),pa=Dn(),fs=Fi(),Rh=ha(),cr=$t(),m2=It(),di=ni(),w2=b2(Oh()),ls=class extends pa.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(`
|
|
56
|
+
`)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}};$e.ActorCallError=ls;var ya=class extends ls{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=tf.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};$e.QueryCallRejectedError=ya;var ds=class extends ls{constructor(e,r,n,i,s,o,c){super(e,r,"update",Object.assign({"Request ID":(0,m2.toHex)(n)},i.body?Object.assign(Object.assign({},c?{"Error code":c}:{}),{"Reject code":String(s),"Reject message":o}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.reject_code=s,this.reject_message=o,this.error_code=c}};$e.UpdateCallRejectedError=ds;var Yt=Symbol.for("ic-agent-metadata"),hs=class t{constructor(e){this[Yt]=Object.freeze(e)}static agentOf(e){return e[Yt].config.agent}static interfaceOf(e){return e[Yt].service}static canisterIdOf(e){return cr.Principal.from(e[Yt].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 rf(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 rf(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:fs.IDL});class i extends t{constructor(o){if(!o.canisterId)throw new pa.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 c=typeof o.canisterId=="string"?cr.Principal.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Ph),o),{canisterId:c}),service:n});for(let[a,l]of n._fields)r?.httpDetails&&l.annotations.push($e.ACTOR_METHOD_WITH_HTTP_DETAILS),r?.certificate&&l.annotations.push($e.ACTOR_METHOD_WITH_CERTIFICATE),this[a]=_2(this,a,l,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new pa.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)}};$e.Actor=hs;function hi(t,e){let r=fs.IDL.decode(t,g2.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var Ph={pollingStrategyFactory:Rh.strategy.defaultStrategy};$e.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";$e.ACTOR_METHOD_WITH_CERTIFICATE="certificate";function _2(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...c)=>{var a,l;o=Object.assign(Object.assign({},o),(l=(a=t[Yt].config).queryTransform)===null||l===void 0?void 0:l.call(a,e,c,Object.assign(Object.assign({},t[Yt].config),o)));let d=o.agent||t[Yt].config.agent||(0,tf.getDefaultAgent)(),b=cr.Principal.from(o.canisterId||t[Yt].config.canisterId),m=fs.IDL.encode(r.argTypes,c),_=await d.query(b,{methodName:e,arg:m,effectiveCanisterId:o.effectiveCanisterId}),f=Object.assign(Object.assign({},_.httpDetails),{requestDetails:_.requestDetails});switch(_.status){case"rejected":throw new ya(b,e,_);case"replied":return r.annotations.includes($e.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:f,result:hi(r.retTypes,_.reply.arg)}:hi(r.retTypes,_.reply.arg)}}:i=async(o,...c)=>{var a,l;o=Object.assign(Object.assign({},o),(l=(a=t[Yt].config).callTransform)===null||l===void 0?void 0:l.call(a,e,c,Object.assign(Object.assign({},t[Yt].config),o)));let d=o.agent||t[Yt].config.agent||(0,tf.getDefaultAgent)(),{canisterId:b,effectiveCanisterId:m,pollingStrategyFactory:_}=Object.assign(Object.assign(Object.assign({},Ph),t[Yt].config),o),f=cr.Principal.from(b),S=m!==void 0?cr.Principal.from(m):f,O=fs.IDL.encode(r.argTypes,c);if(d.rootKey==null)throw new pa.AgentError("Agent root key not initialized before making call");let{requestId:F,response:q,requestDetails:M}=await d.call(f,{methodName:e,arg:O,effectiveCanisterId:S}),$,v;if(q.body&&q.body.certificate){let k=q.body.certificate;v=await di.Certificate.create({certificate:(0,fs.bufFromBufLike)(k),rootKey:d.rootKey,canisterId:cr.Principal.from(b),blsVerify:n});let se=[new TextEncoder().encode("request_status"),F];switch(new TextDecoder().decode((0,di.lookupResultToBuffer)(v.lookup([...se,"status"])))){case"replied":$=(0,di.lookupResultToBuffer)(v.lookup([...se,"reply"]));break;case"rejected":{let ie=new Uint8Array((0,di.lookupResultToBuffer)(v.lookup([...se,"reject_code"])))[0],w=new TextDecoder().decode((0,di.lookupResultToBuffer)(v.lookup([...se,"reject_message"]))),g=(0,di.lookupResultToBuffer)(v.lookup([...se,"error_code"])),A=g?new TextDecoder().decode(g):void 0;throw new ds(f,e,F,q,ie,w,A)}}}else if(q.body&&"reject_message"in q.body){let{reject_code:k,reject_message:se,error_code:ee}=q.body;throw new ds(f,e,F,q,k,se,ee)}if(q.status===202){let k=_(),se=await(0,Rh.pollForResponse)(d,S,F,k,n);v=se.certificate,$=se.reply}let V=r.annotations.includes($e.ACTOR_METHOD_WITH_HTTP_DETAILS),K=r.annotations.includes($e.ACTOR_METHOD_WITH_CERTIFICATE),W=Object.assign(Object.assign({},q),{requestDetails:M});if($!==void 0)return V&&K?{httpDetails:W,certificate:v,result:hi(r.retTypes,$)}:K?{certificate:v,result:hi(r.retTypes,$)}:V?{httpDetails:W,result:hi(r.retTypes,$)}:hi(r.retTypes,$);if(r.retTypes.length===0)return V?{httpDetails:q,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=>(...c)=>i(o,...c),s}function rf(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 hs.createActor(w2.default,Object.assign(Object.assign(Object.assign({},t),{canisterId:cr.Principal.fromHex("")}),{callTransform:e,queryTransform:e}))}$e.getManagementCanister=rf;var nf=class extends hs{constructor(e){super(e)}};$e.AdvancedActor=nf});var Uh=re(sf=>{"use strict";Object.defineProperty(sf,"__esModule",{value:!0});sf.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 Fh=re(pi=>{"use strict";var E2=pi&&pi.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(pi,"__esModule",{value:!0});pi.createAssetCanisterActor=void 0;var x2=ba(),v2=E2(Uh());function B2(t){return x2.Actor.createActor(v2.default,t)}pi.createAssetCanisterActor=B2});var Mh=re(Ar=>{"use strict";var T2=Ar&&Ar.__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]}),S2=Ar&&Ar.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),A2=Ar&&Ar.__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)&&T2(e,t,r);return S2(e,t),e};Object.defineProperty(Ar,"__esModule",{value:!0});Ar.fetchCandid=void 0;var I2=$t(),N2=A2(es()),O2=Xu(),R2=ba();async function P2(t,e){e||(e=await O2.HttpAgent.create());let n=(await N2.request({agent:e,canisterId:I2.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 R2.Actor.createActor(i,{agent:e,canisterId:t}).__get_candid_interface_tmp_hack()}Ar.fetchCandid=P2});var af=re(Oe=>{"use strict";var qh=Oe&&Oe.__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]}),U2=Oe&&Oe.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Tt=Oe&&Oe.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&qh(e,t,r)},of=Oe&&Oe.__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)&&qh(e,t,r);return U2(e,t),e};Object.defineProperty(Oe,"__esModule",{value:!0});Oe.Cbor=Oe.CanisterStatus=Oe.polling=void 0;Tt(ba(),Oe);Tt(Ji(),Oe);Tt(wo(),Oe);Tt($i(),Oe);Tt(Dc(),Oe);Tt(Fh(),Oe);Tt(ni(),Oe);Tt($u(),Oe);Tt(Mh(),Oe);Tt(Gu(),Oe);Tt(Hi(),Oe);Tt(vu(),Oe);Tt(It(),Oe);Tt(eu(),Oe);Oe.polling=of(ha());Oe.CanisterStatus=of(es());Oe.Cbor=of(Vi());Tt(ha(),Oe)});var Rn=re((L3,Xh)=>{"use strict";var df=Object.defineProperty,F2=Object.getOwnPropertyDescriptor,M2=Object.getOwnPropertyNames,q2=Object.prototype.hasOwnProperty,C2=(t,e)=>{for(var r in e)df(t,r,{get:e[r],enumerable:!0})},k2=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of M2(e))!q2.call(t,i)&&i!==r&&df(t,i,{get:()=>e[i],enumerable:!(n=F2(e,i))||n.enumerable});return t},j2=t=>k2(df({},"__esModule",{value:!0}),t),Hh={};C2(Hh,{AgentManager:()=>W2,Canister:()=>K2,FromStringToTokenError:()=>Lh,ICPToken:()=>$2,InvalidPercentageError:()=>zh,NullishError:()=>Wh,TokenAmount:()=>G2,TokenAmountV2:()=>D2,arrayBufferToUint8Array:()=>t_,arrayOfNumberToUint8Array:()=>n_,asNonNullish:()=>Z2,asciiStringToByteArray:()=>i_,assertNonNullish:()=>gs,assertPercentageNumber:()=>X2,bigEndianCrc32:()=>d_,bigIntToUint8Array:()=>J2,candidNumberArrayToBigInt:()=>a_,convertStringToE8s:()=>Vh,createAgent:()=>Dh,createServices:()=>Y2,debounce:()=>g_,decodeBase32:()=>u_,defaultAgent:()=>Gh,encodeBase32:()=>c_,fromDefinedNullable:()=>w_,fromNullable:()=>hf,fromNullishNullable:()=>__,hexStringToUint8Array:()=>s_,isEmptyString:()=>z2,isNullish:()=>ga,jsonReplacer:()=>E_,jsonReviver:()=>x_,nonNullish:()=>Ir,notEmptyString:()=>$h,nowInBigIntNanoSeconds:()=>b_,numberToUint8Array:()=>e_,principalToSubAccount:()=>v_,secondsToDuration:()=>p_,smallerVersion:()=>B_,toNullable:()=>m_,uint8ArrayToArrayOfNumber:()=>r_,uint8ArrayToBigInt:()=>Q2,uint8ArrayToHexString:()=>o_});Xh.exports=j2(Hh);var Lh=(t=>(t[t.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",t[t.InvalidFormat=1]="InvalidFormat",t[t.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",t))(Lh||{}),H2=BigInt(1e8),L2=8,Vh=t=>{let e=t.includes("e")?Number(t).toLocaleString("en",{useGrouping:!1,maximumFractionDigits:20}):t;e=e.trim().replace(/[,']/g,"");let r=e.match(/\d*(\.\d*)?/);if(!r||r[0]!==e)return 1;let[n,i]=e.split("."),s=BigInt(0);if(n)try{s+=BigInt(n)*H2}catch{return 1}if(i){if(i.length>8)return 0;try{s+=BigInt(i.padEnd(8,"0"))}catch{return 1}}return s},V2=({amount:t,decimals:e})=>{t=t.trim().replace(/[,']/g,"");let r=t.match(/\d*(\.\d*)?/);if(!r||r[0]!==t)return 1;let[n,i]=t.split("."),s=0n,o=10n**BigInt(e);if(n)try{s+=BigInt(n)*o}catch{return 1}if(i){if(i.length>e)return 2;try{s+=BigInt(i.padEnd(e,"0"))}catch{return 1}}return s},$2={symbol:"ICP",name:"Internet Computer",decimals:8},G2=class ys{constructor(e,r){if(this.e8s=e,this.token=r,r.decimals!==8)throw new Error("Use TokenAmountV2 for number of decimals other than 8")}static fromE8s({amount:e,token:r}){return new ys(e,r)}static fromString({amount:e,token:r}){if(r.decimals!==8)throw new Error("Use TokenAmountV2 for number of decimals other than 8");let n=Vh(e);return typeof n=="bigint"?new ys(n,r):n}static fromNumber({amount:e,token:r}){let n=ys.fromString({amount:e.toString(),token:r});if(n instanceof ys)return n;throw n===0?new Error(`Number ${e} has more than 8 decimals`):new Error(`Invalid number ${e}`)}toE8s(){return this.e8s}},D2=class bs{constructor(e,r){this.ulps=e,this.token=r}static fromUlps({amount:e,token:r}){return new bs(e,r)}static fromString({amount:e,token:r}){let n=V2({amount:e,decimals:r.decimals});return typeof n=="bigint"?new bs(n,r):n}static fromNumber({amount:e,token:r}){let n=bs.fromString({amount:e.toFixed(Math.min(L2,r.decimals)),token:r});if(n instanceof bs)return n;throw n===2?new Error(`Number ${e} has more than ${r.decimals} decimals`):new Error(`Invalid number ${e}`)}toUlps(){return this.ulps}toE8s(){return this.token.decimals<8?this.ulps*10n**BigInt(8-this.token.decimals):this.token.decimals===8?this.ulps:this.ulps/10n**BigInt(this.token.decimals-8)}},K2=class{constructor(t,e,r){this.id=t,this.service=e,this.certifiedService=r,this.caller=({certified:n=!0})=>n?this.certifiedService:this.service}get canisterId(){return this.id}},Ch=af(),cf=af(),ga=t=>t==null,Ir=t=>!ga(t),$h=t=>Ir(t)&&t!=="",z2=t=>!$h(t),Gh=()=>cf.HttpAgent.createSync({host:"https://icp-api.io",identity:new cf.AnonymousIdentity}),Dh=async({identity:t,host:e,fetchRootKey:r=!1,verifyQuerySignatures:n=!1,retryTimes:i})=>await cf.HttpAgent.create({identity:t,...Ir(e)&&{host:e},verifyQuerySignatures:n,...Ir(i)&&{retryTimes:i},shouldFetchRootKey:r}),W2=class Kh{constructor(e){this.config=e,this.agents=void 0}static create(e){return new Kh(e)}async getAgent({identity:e}){let r=e.getPrincipal().toText();if(ga(this.agents)||ga(this.agents[r])){let n=await Dh({identity:e,fetchRootKey:this.config.fetchRootKey,host:this.config.host,verifyQuerySignatures:!0});return this.agents={...this.agents??{},[r]:n},n}return this.agents[r]}clearAgents(){this.agents=null}},Y2=({options:{canisterId:t,serviceOverride:e,certifiedServiceOverride:r,agent:n,callTransform:i,queryTransform:s},idlFactory:o,certifiedIdlFactory:c})=>{let a=n??Gh(),l=e??Ch.Actor.createActor(o,{agent:a,canisterId:t,callTransform:i,queryTransform:s}),d=r??Ch.Actor.createActor(c,{agent:a,canisterId:t,callTransform:i,queryTransform:s});return{service:l,certifiedService:d,agent:a,canisterId:t}},zh=class extends Error{},Wh=class extends Error{},gs=(t,e)=>{if(t==null)throw new Wh(e)},Z2=(t,e)=>(gs(t,e),t),X2=t=>{if(t<0||t>100)throw new zh(`${t} is not a valid percentage number.`)},Q2=t=>{let e=new DataView(t.buffer,t.byteOffset,t.byteLength);if(typeof e.getBigUint64=="function")return e.getBigUint64(0);{let r=BigInt(e.getUint32(0)),n=BigInt(e.getUint32(4));return(r<<BigInt(32))+n}},J2=t=>{let e=new ArrayBuffer(8),r=new DataView(e);if(typeof r.setBigUint64=="function")r.setBigUint64(0,t);else{let n=Number(t>>BigInt(32)),i=Number(t&BigInt(4294967295));r.setUint32(0,n),r.setUint32(4,i)}return new Uint8Array(e)},e_=t=>{let e=new DataView(new ArrayBuffer(8));for(let r=7;r>=0;--r)e.setUint8(r,t%256),t=t>>8;return new Uint8Array(e.buffer)},t_=t=>new Uint8Array(t),r_=t=>Array.from(t),n_=t=>new Uint8Array(t),i_=t=>Array.from(t).map(e=>e.charCodeAt(0)),s_=t=>{let e=t.match(/.{1,2}/g);return gs(e,"Invalid hex string."),Uint8Array.from(e.map(r=>parseInt(r,16)))},o_=t=>(t instanceof Uint8Array||(t=Uint8Array.from(t)),t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")),a_=t=>{let e=0n;for(let r=t.length-1;r>=0;r--)e=(e<<32n)+BigInt(t[r]);return e},ma="abcdefghijklmnopqrstuvwxyz234567",yi=Object.create(null);for(let t=0;t<ma.length;t++)yi[ma[t]]=t;yi[0]=yi.o;yi[1]=yi.i;var c_=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+=ma[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?ma[r>>3]:"")};function u_(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let c=yi[o.toLowerCase()];gs(c,`Invalid character: ${JSON.stringify(o)}`),c<<=3,r|=c>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=c<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}var f_=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]),l_=t=>{let e=-1;for(let r=0;r<t.length;r++){let n=(t[r]^e)&255;e=f_[n]^e>>>8}return(e^-1)>>>0},d_=t=>{let e=new ArrayBuffer(4);return new DataView(e).setUint32(0,l_(t),!1),new Uint8Array(e)},h_={year:"year",year_plural:"years",month:"month",month_plural:"months",day:"day",day_plural:"days",hour:"hour",hour_plural:"hours",minute:"minute",minute_plural:"minutes",second:"second",second_plural:"seconds"},p_=({seconds:t,i18n:e=h_})=>{let r=t/BigInt(60),n=r/BigInt(60);r-=n*BigInt(60);let i=n/BigInt(24);n-=i*BigInt(24);let s=y_(i);return i-=Yh(s),[ps("year",s),ps("day",i),ps("hour",n),ps("minute",r),...t>BigInt(0)&&t<BigInt(60)?[ps("second",t)]:[]].filter(({amount:o})=>o>0).slice(0,2).map(o=>`${o.amount} ${o.amount===1?e[o.labelKey]:e[`${o.labelKey}_plural`]}`).join(", ")},y_=t=>{let e=t/BigInt(365);for(;Yh(e)>t;)e--;return e},Yh=t=>{let e=t/BigInt(4);return t*BigInt(365)+e},ps=(t,e)=>({labelKey:t,amount:Number(e)}),b_=()=>BigInt(Date.now())*BigInt(1e6),g_=(t,e)=>{let r;return(...n)=>{let i=()=>t(...n);r&&clearTimeout(r),r=setTimeout(i,e!==void 0&&e>0?e:300)}},m_=t=>Ir(t)?[t]:[],hf=t=>t?.[0],w_=t=>{let e=hf(t);return gs(e),e},__=t=>hf(t??[]),Zh=$t(),uf="__bigint__",ff="__principal__",lf="__uint8array__",E_=(t,e)=>typeof e=="bigint"?{[uf]:`${e}`}:Ir(e)&&e instanceof Zh.Principal?{[ff]:e.toText()}:Ir(e)&&e instanceof Uint8Array?{[lf]:Array.from(e)}:e,x_=(t,e)=>{let r=n=>e[n];return Ir(e)&&typeof e=="object"&&uf in e?BigInt(r(uf)):Ir(e)&&typeof e=="object"&&ff in e?Zh.Principal.fromText(r(ff)):Ir(e)&&typeof e=="object"&&lf in e?Uint8Array.from(r(lf)):e},v_=t=>{let e=t.toUint8Array(),r=new Uint8Array(32);return r[0]=e.length,r.set(e,1),r},kh=(t,e)=>e>t.length?[...t,...[...Array(e-t.length).keys()].map(()=>0)]:t,jh=t=>{if(!Number.isNaN(Number(t)))return Number(t);let e=t.split("").reduce((r,n)=>Number.isNaN(Number(n))?r:r+n,"");return Number(e)},B_=({minVersion:t,currentVersion:e})=>{let r=kh(t.split(".").map(jh),3).join(".");return kh(e.split(".").map(jh),3).join(".").localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})<0}});var bp={};Ff(bp,{CLSThresholds:()=>mf,FCPThresholds:()=>gf,FIDThresholds:()=>xf,INPThresholds:()=>wf,LCPThresholds:()=>_f,TTFBThresholds:()=>Ef,onCLS:()=>N_,onFCP:()=>up,onFID:()=>L_,onINP:()=>M_,onLCP:()=>q_,onTTFB:()=>k_});var bf,hn,Es,ap,xa,cp,Un,vf,Ba,Zt,_i,Xt,Bf,xs,Ta,wi,ip,va,sp,I_,Tf,vs,gf,up,mf,N_,fp,pf,_a,O_,lp,R_,Nr,Ea,dp,P_,U_,F_,hp,wf,M_,_f,yf,q_,Ef,C_,k_,_s,j_,op,pp,H_,yp,xf,L_,gp=Pa(()=>{cp=-1,Un=function(t){addEventListener("pageshow",function(e){e.persisted&&(cp=e.timeStamp,t(e))},!0)},vf=function(){var t=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(t&&t.responseStart>0&&t.responseStart<performance.now())return t},Ba=function(){var t=vf();return t&&t.activationStart||0},Zt=function(t,e){var r=vf(),n="navigate";return cp>=0?n="back-forward-cache":r&&(document.prerendering||Ba()>0?n="prerender":document.wasDiscarded?n="restore":r.type&&(n=r.type.replace(/_/g,"-"))),{name:t,value:e===void 0?-1:e,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:n}},_i=function(t,e,r){try{if(PerformanceObserver.supportedEntryTypes.includes(t)){var n=new PerformanceObserver(function(i){Promise.resolve().then(function(){e(i.getEntries())})});return n.observe(Object.assign({type:t,buffered:!0},r||{})),n}}catch{}},Xt=function(t,e,r,n){var i,s;return function(o){e.value>=0&&(o||n)&&((s=e.value-(i||0))||i===void 0)&&(i=e.value,e.delta=s,e.rating=function(c,a){return c>a[1]?"poor":c>a[0]?"needs-improvement":"good"}(e.value,r),t(e))}},Bf=function(t){requestAnimationFrame(function(){return requestAnimationFrame(function(){return t()})})},xs=function(t){document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"&&t()})},Ta=function(t){var e=!1;return function(){e||(t(),e=!0)}},wi=-1,ip=function(){return document.visibilityState!=="hidden"||document.prerendering?1/0:0},va=function(t){document.visibilityState==="hidden"&&wi>-1&&(wi=t.type==="visibilitychange"?t.timeStamp:0,I_())},sp=function(){addEventListener("visibilitychange",va,!0),addEventListener("prerenderingchange",va,!0)},I_=function(){removeEventListener("visibilitychange",va,!0),removeEventListener("prerenderingchange",va,!0)},Tf=function(){return wi<0&&(wi=ip(),sp(),Un(function(){setTimeout(function(){wi=ip(),sp()},0)})),{get firstHiddenTime(){return wi}}},vs=function(t){document.prerendering?addEventListener("prerenderingchange",function(){return t()},!0):t()},gf=[1800,3e3],up=function(t,e){e=e||{},vs(function(){var r,n=Tf(),i=Zt("FCP"),s=_i("paint",function(o){o.forEach(function(c){c.name==="first-contentful-paint"&&(s.disconnect(),c.startTime<n.firstHiddenTime&&(i.value=Math.max(c.startTime-Ba(),0),i.entries.push(c),r(!0)))})});s&&(r=Xt(t,i,gf,e.reportAllChanges),Un(function(o){i=Zt("FCP"),r=Xt(t,i,gf,e.reportAllChanges),Bf(function(){i.value=performance.now()-o.timeStamp,r(!0)})}))})},mf=[.1,.25],N_=function(t,e){e=e||{},up(Ta(function(){var r,n=Zt("CLS",0),i=0,s=[],o=function(a){a.forEach(function(l){if(!l.hadRecentInput){var d=s[0],b=s[s.length-1];i&&l.startTime-b.startTime<1e3&&l.startTime-d.startTime<5e3?(i+=l.value,s.push(l)):(i=l.value,s=[l])}}),i>n.value&&(n.value=i,n.entries=s,r())},c=_i("layout-shift",o);c&&(r=Xt(t,n,mf,e.reportAllChanges),xs(function(){o(c.takeRecords()),r(!0)}),Un(function(){i=0,n=Zt("CLS",0),r=Xt(t,n,mf,e.reportAllChanges),Bf(function(){return r()})}),setTimeout(r,0))}))},fp=0,pf=1/0,_a=0,O_=function(t){t.forEach(function(e){e.interactionId&&(pf=Math.min(pf,e.interactionId),_a=Math.max(_a,e.interactionId),fp=_a?(_a-pf)/7+1:0)})},lp=function(){return bf?fp:performance.interactionCount||0},R_=function(){"interactionCount"in performance||bf||(bf=_i("event",O_,{type:"event",buffered:!0,durationThreshold:0}))},Nr=[],Ea=new Map,dp=0,P_=function(){var t=Math.min(Nr.length-1,Math.floor((lp()-dp)/50));return Nr[t]},U_=[],F_=function(t){if(U_.forEach(function(i){return i(t)}),t.interactionId||t.entryType==="first-input"){var e=Nr[Nr.length-1],r=Ea.get(t.interactionId);if(r||Nr.length<10||t.duration>e.latency){if(r)t.duration>r.latency?(r.entries=[t],r.latency=t.duration):t.duration===r.latency&&t.startTime===r.entries[0].startTime&&r.entries.push(t);else{var n={id:t.interactionId,latency:t.duration,entries:[t]};Ea.set(n.id,n),Nr.push(n)}Nr.sort(function(i,s){return s.latency-i.latency}),Nr.length>10&&Nr.splice(10).forEach(function(i){return Ea.delete(i.id)})}}},hp=function(t){var e=self.requestIdleCallback||self.setTimeout,r=-1;return t=Ta(t),document.visibilityState==="hidden"?t():(r=e(t),xs(t)),r},wf=[200,500],M_=function(t,e){"PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype&&(e=e||{},vs(function(){var r;R_();var n,i=Zt("INP"),s=function(c){hp(function(){c.forEach(F_);var a=P_();a&&a.latency!==i.value&&(i.value=a.latency,i.entries=a.entries,n())})},o=_i("event",s,{durationThreshold:(r=e.durationThreshold)!==null&&r!==void 0?r:40});n=Xt(t,i,wf,e.reportAllChanges),o&&(o.observe({type:"first-input",buffered:!0}),xs(function(){s(o.takeRecords()),n(!0)}),Un(function(){dp=lp(),Nr.length=0,Ea.clear(),i=Zt("INP"),n=Xt(t,i,wf,e.reportAllChanges)}))}))},_f=[2500,4e3],yf={},q_=function(t,e){e=e||{},vs(function(){var r,n=Tf(),i=Zt("LCP"),s=function(a){e.reportAllChanges||(a=a.slice(-1)),a.forEach(function(l){l.startTime<n.firstHiddenTime&&(i.value=Math.max(l.startTime-Ba(),0),i.entries=[l],r())})},o=_i("largest-contentful-paint",s);if(o){r=Xt(t,i,_f,e.reportAllChanges);var c=Ta(function(){yf[i.id]||(s(o.takeRecords()),o.disconnect(),yf[i.id]=!0,r(!0))});["keydown","click"].forEach(function(a){addEventListener(a,function(){return hp(c)},{once:!0,capture:!0})}),xs(c),Un(function(a){i=Zt("LCP"),r=Xt(t,i,_f,e.reportAllChanges),Bf(function(){i.value=performance.now()-a.timeStamp,yf[i.id]=!0,r(!0)})})}})},Ef=[800,1800],C_=function t(e){document.prerendering?vs(function(){return t(e)}):document.readyState!=="complete"?addEventListener("load",function(){return t(e)},!0):setTimeout(e,0)},k_=function(t,e){e=e||{};var r=Zt("TTFB"),n=Xt(t,r,Ef,e.reportAllChanges);C_(function(){var i=vf();i&&(r.value=Math.max(i.responseStart-Ba(),0),r.entries=[i],n(!0),Un(function(){r=Zt("TTFB",0),(n=Xt(t,r,Ef,e.reportAllChanges))(!0)}))})},_s={passive:!0,capture:!0},j_=new Date,op=function(t,e){hn||(hn=e,Es=t,ap=new Date,yp(removeEventListener),pp())},pp=function(){if(Es>=0&&Es<ap-j_){var t={entryType:"first-input",name:hn.type,target:hn.target,cancelable:hn.cancelable,startTime:hn.timeStamp,processingStart:hn.timeStamp+Es};xa.forEach(function(e){e(t)}),xa=[]}},H_=function(t){if(t.cancelable){var e=(t.timeStamp>1e12?new Date:performance.now())-t.timeStamp;t.type=="pointerdown"?function(r,n){var i=function(){op(r,n),o()},s=function(){o()},o=function(){removeEventListener("pointerup",i,_s),removeEventListener("pointercancel",s,_s)};addEventListener("pointerup",i,_s),addEventListener("pointercancel",s,_s)}(e,t):op(e,t)}},yp=function(t){["mousedown","keydown","touchstart","pointerdown"].forEach(function(e){return t(e,H_,_s)})},xf=[100,300],L_=function(t,e){e=e||{},vs(function(){var r,n=Tf(),i=Zt("FID"),s=function(a){a.startTime<n.firstHiddenTime&&(i.value=a.processingStart-a.startTime,i.entries.push(a),r(!0))},o=function(a){a.forEach(s)},c=_i("first-input",o);r=Xt(t,i,xf,e.reportAllChanges),c&&(xs(Ta(function(){o(c.takeRecords()),c.disconnect()})),Un(function(){var a;i=Zt("FID"),r=Xt(t,i,xf,e.reportAllChanges),xa=[],Es=-1,hn=null,yp(addEventListener),a=s,xa.push(a),pp()}))})}});function Ei(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function Bs(t,e){let r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);let n=Ei(r);return(i,s)=>n.then(o=>s(o.transaction(e,i).objectStore(e)))}function Af(){return Sf||(Sf=Bs("keyval-store","keyval")),Sf}function Sa(t,e,r=Af()){return r("readwrite",n=>(n.put(e,t),Ei(n.transaction)))}function Aa(t,e=Af()){return e("readwrite",r=>(t.forEach(n=>r.delete(n)),Ei(r.transaction)))}function V_(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Ei(t.transaction)}function Ia(t=Af()){return t("readonly",e=>{if(e.getAll&&e.getAllKeys)return Promise.all([Ei(e.getAllKeys()),Ei(e.getAll())]).then(([n,i])=>n.map((s,o)=>[s,i[o]]));let r=[];return t("readonly",n=>V_(n,i=>r.push([i.key,i.value])).then(()=>r))})}var Sf,mp=Pa(()=>{});var Na={};Ff(Na,{delPageViews:()=>D_,delPerformanceMetrics:()=>X_,delTrackEvents:()=>W_,getPageViews:()=>G_,getPerformanceMetrics:()=>Z_,getTrackEvents:()=>z_,setPageView:()=>$_,setPerformanceMetric:()=>Y_,setTrackEvent:()=>K_});var If,Nf,Of,$_,G_,D_,K_,z_,W_,Y_,Z_,X_,Oa=Pa(()=>{"use strict";mp();If=Bs("juno-views","views"),Nf=Bs("juno-events","events"),Of=Bs("juno-metrics","metrics"),$_=({key:t,view:e})=>Sa(t,e,If),G_=()=>Ia(If),D_=t=>Aa(t,If),K_=({key:t,track:e})=>Sa(t,e,Nf),z_=()=>Ia(Nf),W_=t=>Aa(t,Nf),Y_=({key:t,view:e})=>Sa(t,e,Of),Z_=()=>Ia(Of),X_=t=>Aa(t,Of)});var Uf=qn(Rn(),1);var pn=qn(Rn(),1);var Qh=qn(Rn(),1);var wa=()=>typeof window<"u";import{webcrypto as ep}from"node:crypto";var Jh="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var T_=128,Pn,bi;function S_(t){!Pn||Pn.length<t?(Pn=Buffer.allocUnsafe(t*T_),ep.getRandomValues(Pn),bi=0):bi+t>Pn.length&&(ep.getRandomValues(Pn),bi=0),bi+=t}function gi(t=21){S_(t|=0);let e="";for(let r=bi-t;r<bi;r++)e+=Jh[Pn[r]&63];return e}var rp=qn(Rn(),1);var tp=()=>BigInt(Date.now())*BigInt(1e6);var ms=()=>({collected_at:tp(),updated_at:[],version:[]}),ws=()=>{let{userAgent:t}=navigator;return{user_agent:(0,rp.toNullable)(t)}};var np=qn(Rn(),1),A_="Analytics worker not initialized. Did you call `initOrbiter`?",mi=t=>{(0,np.isNullish)(t)&&console.warn(A_)};var wp=qn(Rn(),1);var _p=async t=>{let{onCLS:e,onFCP:r,onINP:n,onLCP:i,onTTFB:s}=await Promise.resolve().then(()=>(gp(),bp)),o=c=>{(async()=>await Q_({...c,sessionId:t}))()};e(o),r(o),n(o),i(o),s(o)},Q_=async t=>{let e=J_(t);if(e==="unknown"){console.warn("Performance metric ignored. Unknown metric name.",t);return}if(e==="deprecated")return;await(await Promise.resolve().then(()=>(Oa(),Na))).setPerformanceMetric({key:gi(),view:e})},J_=({sessionId:t,name:e,value:r,delta:n,id:i,navigationType:s})=>{let c=(()=>{switch(e){case"CLS":return{CLS:null};case"FCP":return{FCP:null};case"INP":return{INP:null};case"LCP":return{LCP:null};case"TTFB":return{TTFB:null};case"FID":return"deprecated";default:return"unknown"}})();if(c==="unknown"||c==="deprecated")return c;let l={value:r,delta:n,id:i,navigation_type:(0,wp.toNullable)((()=>{switch(s){case"navigate":return{Navigate:null};case"restore":return{Restore:null};case"reload":return{Reload:null};case"back-forward":return{BackForward:null};case"back-forward-cache":return{BackForwardCache:null};case"prerender":return{Prerender:null};default:return}})())},{location:{href:d}}=document,{updated_at:b,...m}=ms();return{href:d,metric_name:c,session_id:t,data:{WebVitalsMetric:l},...ws(),...m}};var e8=()=>{if(!(typeof crypto>"u"))return gi()},xi=e8(),jt,Ep=t=>{let{path:e}=t.worker??{},r=e??"./workers/analytics.worker.js";jt=new Worker(r);let n=()=>console.warn("Unable to connect to the analytics web worker. Have you deployed it?");return jt?.addEventListener("error",n,!1),r8(t),{cleanup(){jt?.removeEventListener("error",n,!1)}}},xp=()=>{let t=async()=>await Bp(),e=new Proxy(history.pushState,{apply:async(r,n,i)=>{r.apply(n,i),await t()}});return history.pushState=e,addEventListener("popstate",t,{passive:!0}),{cleanup(){e=null,removeEventListener("popstate",t,!1)}}},Rf="No session ID initialized.",Pf=async()=>{if(!wa())return;(0,pn.assertNonNullish)(xi,Rf);let{title:t,location:{href:e},referrer:r}=document,{innerWidth:n,innerHeight:i}=window,{timeZone:s}=Intl.DateTimeFormat().resolvedOptions(),o={title:t,href:e,referrer:(0,pn.toNullable)((0,pn.nonNullish)(r)&&r!==""?r:void 0),device:{inner_width:n,inner_height:i},time_zone:s,session_id:xi,...ws(),...ms()};await(await Promise.resolve().then(()=>(Oa(),Na))).setPageView({key:gi(),view:o})},vp=async({options:t})=>{wa()&&t?.performance!==!1&&((0,pn.assertNonNullish)(xi,Rf),await _p(xi))},Bp=async()=>{mi(jt),await Pf(),jt?.postMessage({msg:"junoTrackPageView"})},t8=async t=>{if(!wa())return;(0,pn.assertNonNullish)(xi,Rf),mi(jt),await(await Promise.resolve().then(()=>(Oa(),Na))).setTrackEvent({key:gi(),track:{...t,session_id:xi,...ws(),...ms()}}),jt?.postMessage({msg:"junoTrackEvent"})},r8=t=>{mi(jt),jt?.postMessage({msg:"junoInitEnvironment",data:t})},Tp=()=>{mi(jt),jt?.postMessage({msg:"junoStartTrackTimer"})},Sp=()=>{mi(jt),jt?.postMessage({msg:"junoStopTracker"})};var Ap=()=>{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()},Ip=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_ORBITER_ID??import.meta.env?.PUBLIC_ORBITER_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_ORBITER_ID??t():t()},Np=()=>{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 n8=t=>{let e=t?.satelliteId??Ap();(0,Uf.assertNonNullish)(e,"Satellite ID is not configured. Orbiter cannot be initialized without a target Satellite.");let r=t?.orbiterId??Ip();(0,Uf.assertNonNullish)(r,"Orbiter ID is not configured. The analytics cannot be initialized without an Orbiter.");let n=t?.container??Np();return{orbiterId:r,satelliteId:e,container:n,worker:t?.worker,options:t?.options}},pE=async t=>{await Pf();let e=n8(t),{cleanup:r}=Ep(e),{cleanup:n}=xp();return await vp(e),Tp(),()=>{Sp(),r(),n()}};export{pE as initOrbiter,t8 as trackEvent,Bp as trackPageView};
|
|
4
57
|
/*! Bundled license information:
|
|
5
58
|
|
|
59
|
+
ieee754/index.js:
|
|
60
|
+
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
61
|
+
|
|
62
|
+
buffer/index.js:
|
|
63
|
+
(*!
|
|
64
|
+
* The buffer module from node.js, for the browser.
|
|
65
|
+
*
|
|
66
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
67
|
+
* @license MIT
|
|
68
|
+
*)
|
|
69
|
+
|
|
6
70
|
@noble/hashes/utils.js:
|
|
7
71
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
72
|
+
|
|
73
|
+
@noble/curves/abstract/utils.js:
|
|
74
|
+
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
75
|
+
|
|
76
|
+
@noble/curves/abstract/modular.js:
|
|
77
|
+
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
78
|
+
|
|
79
|
+
@noble/curves/abstract/curve.js:
|
|
80
|
+
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
81
|
+
|
|
82
|
+
@noble/curves/abstract/weierstrass.js:
|
|
83
|
+
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
84
|
+
|
|
85
|
+
@noble/curves/abstract/bls.js:
|
|
86
|
+
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
87
|
+
|
|
88
|
+
@noble/curves/abstract/tower.js:
|
|
89
|
+
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
90
|
+
|
|
91
|
+
@noble/curves/bls12-381.js:
|
|
92
|
+
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
93
|
+
|
|
94
|
+
@noble/curves/abstract/edwards.js:
|
|
95
|
+
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
96
|
+
|
|
97
|
+
@noble/curves/abstract/montgomery.js:
|
|
98
|
+
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
99
|
+
|
|
100
|
+
@noble/curves/ed25519.js:
|
|
101
|
+
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
8
102
|
*/
|
|
9
103
|
//# sourceMappingURL=index.mjs.map
|