@junobuild/analytics 0.1.8 → 0.2.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.
Files changed (49) hide show
  1. package/dist/browser/chunk-YVLJX3HV.js +2 -0
  2. package/dist/browser/chunk-YVLJX3HV.js.map +7 -0
  3. package/dist/browser/chunk-ZUUQVOC7.js +2 -0
  4. package/dist/browser/chunk-ZUUQVOC7.js.map +7 -0
  5. package/dist/browser/index.js +1 -1
  6. package/dist/browser/index.js.map +4 -4
  7. package/dist/browser/tracker.js +2 -0
  8. package/dist/browser/tracker.js.map +7 -0
  9. package/dist/browser/ua-parser-GFKOYVJI.js +2 -0
  10. package/dist/browser/ua-parser-GFKOYVJI.js.map +7 -0
  11. package/dist/browser/web-vitals-YBMS6D2C.js +2 -0
  12. package/dist/browser/web-vitals-YBMS6D2C.js.map +7 -0
  13. package/dist/node/index.mjs +1 -1
  14. package/dist/node/index.mjs.map +4 -4
  15. package/dist/types/api/orbiter.api.d.ts +26 -0
  16. package/dist/types/constants/container.constants.d.ts +1 -0
  17. package/dist/types/index.d.ts +8 -3
  18. package/dist/types/services/orbiter.services.d.ts +10 -0
  19. package/dist/types/services/performance.services.d.ts +11 -1
  20. package/dist/types/services/user-agent.services.d.ts +4 -0
  21. package/dist/types/tracker.d.ts +37 -0
  22. package/dist/types/types/env.d.ts +10 -25
  23. package/dist/types/types/orbiter.d.ts +95 -0
  24. package/dist/types/types/track.d.ts +2 -4
  25. package/dist/types/utils/analytics.utils.d.ts +2 -3
  26. package/dist/types/utils/dfinity/asserts.utils.d.ts +7 -0
  27. package/dist/types/utils/dfinity/debounce.utils.d.ts +12 -0
  28. package/dist/types/utils/dfinity/json.utils.d.ts +25 -0
  29. package/dist/types/utils/dfinity/nullish.utils.d.ts +30 -0
  30. package/dist/types/utils/env.utils.d.ts +5 -0
  31. package/dist/types/utils/log.utils.d.ts +1 -1
  32. package/package.json +5 -10
  33. package/dist/browser/idb.services-CVJFLYYN.js +0 -2
  34. package/dist/browser/idb.services-CVJFLYYN.js.map +0 -7
  35. package/dist/browser/web-vitals-JGDN2KW5.js +0 -2
  36. package/dist/browser/web-vitals-JGDN2KW5.js.map +0 -7
  37. package/dist/declarations/orbiter/orbiter.did.d.ts +0 -229
  38. package/dist/declarations/orbiter/orbiter.factory.certified.did.js +0 -255
  39. package/dist/declarations/orbiter/orbiter.factory.did.js +0 -271
  40. package/dist/declarations/orbiter/orbiter.factory.did.mjs +0 -271
  41. package/dist/types/api/actor.api.d.ts +0 -3
  42. package/dist/types/services/analytics.services.d.ts +0 -25
  43. package/dist/types/services/idb.services.d.ts +0 -19
  44. package/dist/types/types/idb.d.ts +0 -12
  45. package/dist/types/types/post-message.d.ts +0 -7
  46. package/dist/types/utils/actor.utils.d.ts +0 -6
  47. package/dist/types/workers/analytics.worker.d.ts +0 -1
  48. package/dist/workers/analytics.worker.js +0 -89
  49. package/dist/workers/analytics.worker.js.map +0 -7
@@ -1,89 +0,0 @@
1
- "use strict";(()=>{var Wl=Object.create;var Oi=Object.defineProperty;var Zl=Object.getOwnPropertyDescriptor;var Xl=Object.getOwnPropertyNames;var Jl=Object.getPrototypeOf,Ql=Object.prototype.hasOwnProperty;var ht=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ht=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),qn=(e,t)=>{for(var r in t)Oi(e,r,{get:t[r],enumerable:!0})},Cc=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Xl(t))!Ql.call(e,i)&&i!==r&&Oi(e,i,{get:()=>t[i],enumerable:!(n=Zl(t,i))||n.enumerable});return e};var sn=(e,t,r)=>(r=e!=null?Wl(Jl(e)):{},Cc(t||!e||!e.__esModule?Oi(r,"default",{value:e,enumerable:!0}):r,e)),Ll=e=>Cc(Oi({},"__esModule",{value:!0}),e);function qc(e){let t=0,r=0,n="";function i(s){return t<0?r|=s>>-t:r=s<<t&248,t>3?(t-=8,1):(t<4&&(n+=Fi[r>>3],t+=5),0)}for(let s=0;s<e.length;)s+=i(e[s]);return n+(t<0?Fi[r>>3]:"")}function Vc(e){let t=0,r=0,n=new Uint8Array(e.length*4/3|0),i=0;function s(o){let a=on[o.toLowerCase()];if(a===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);a<<=3,r|=a>>>t,t+=5,t>=8&&(n[i++]=r,t-=8,t>0?r=a<<5-t&255:r=0)}for(let o of e)s(o);return n.slice(0,i)}var Fi,on,$c=ht(()=>{Fi="abcdefghijklmnopqrstuvwxyz234567",on=Object.create(null);for(let e=0;e<Fi.length;e++)on[Fi[e]]=e;on[0]=on.o;on[1]=on.i});function jc(e){let t=new Uint8Array(e),r=-1;for(let n=0;n<t.length;n++){let s=(t[n]^r)&255;r=Dl[s]^r>>>8}return(r^-1)>>>0}var Dl,Hc=ht(()=>{Dl=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 th(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Ro(e,...t){if(!th(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 Oo(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 Gc(e,t){Ro(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Fo=ht(()=>{});var $r,zc=ht(()=>{$r=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});function Yc(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Uo(e){return typeof e=="string"&&(e=Yc(e)),Ro(e),e}function Vn(e){let t=n=>e().update(Uo(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Pi(e=32){if($r&&typeof $r.getRandomValues=="function")return $r.getRandomValues(new Uint8Array(e));if($r&&typeof $r.randomBytes=="function")return $r.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}var Ii,Re,Sm,Ui,Nm,an=ht(()=>{zc();Fo();Ii=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Re=(e,t)=>e<<32-t|e>>>t,Sm=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;Ui=class{clone(){return this._cloneInto()}},Nm={}.toString});function eh(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,l=n?0:4;e.setUint32(t+c,o,n),e.setUint32(t+l,a,n)}var Kc,Wc,cn,Io=ht(()=>{Fo();an();Kc=(e,t,r)=>e&t^~e&r,Wc=(e,t,r)=>e&t^e&r^t&r,cn=class extends Ui{constructor(t,r,n,i){super(),this.blockLen=t,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(t),this.view=Ii(this.buffer)}update(t){Oo(this);let{view:r,buffer:n,blockLen:i}=this;t=Uo(t);let s=t.length;for(let o=0;o<s;){let a=Math.min(i-this.pos,s-o);if(a===i){let c=Ii(t);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Oo(this),Gc(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let d=o;d<i;d++)r[d]=0;eh(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=Ii(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)a.setUint32(4*d,h[d],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return t.length=i,t.pos=a,t.finished=s,t.destroyed=o,i%r&&t.buffer.set(n),t}}});var rh,wr,br,ki,Po,$n,Zc,Mi=ht(()=>{Io();an();rh=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]),wr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),br=new Uint32Array(64),ki=class extends cn{constructor(){super(64,32,8,!1),this.A=wr[0]|0,this.B=wr[1]|0,this.C=wr[2]|0,this.D=wr[3]|0,this.E=wr[4]|0,this.F=wr[5]|0,this.G=wr[6]|0,this.H=wr[7]|0}get(){let{A:t,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[t,r,n,i,s,o,a,c]}set(t,r,n,i,s,o,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(t,r){for(let d=0;d<16;d++,r+=4)br[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){let g=br[d-15],w=br[d-2],f=Re(g,7)^Re(g,18)^g>>>3,O=Re(w,17)^Re(w,19)^w>>>10;br[d]=O+br[d-7]+f+br[d-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:l,H:h}=this;for(let d=0;d<64;d++){let g=Re(a,6)^Re(a,11)^Re(a,25),w=h+g+Kc(a,c,l)+rh[d]+br[d]|0,O=(Re(n,2)^Re(n,13)^Re(n,22))+Wc(n,i,s)|0;h=l,l=c,c=a,a=o+w|0,o=s,s=i,i=n,n=w+O|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,i,s,o,a,c,l,h)}roundClean(){br.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Po=class extends ki{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}},$n=Vn(()=>new ki),Zc=Vn(()=>new Po)});function Xc(e){return Zc.create().update(new Uint8Array(e)).digest()}var Jc=ht(()=>{Mi()});var Ci,nh,Qc,ih,sh,oh,dt,we=ht(()=>{$c();Hc();Jc();Ci="__principal__",nh=2,Qc=4,ih="aaaaa-aa",sh=e=>{var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))},oh=e=>e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),""),dt=class e{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Qc]))}static managementCanister(){return this.fromHex(ih)}static selfAuthenticating(t){let r=Xc(t);return new this(new Uint8Array([...r,nh]))}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(sh(t))}static fromText(t){let r=t;if(t.includes(Ci)){let o=JSON.parse(t);Ci in o&&(r=o[Ci])}let n=r.toLowerCase().replace(/-/g,""),i=Vc(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(t){return new this(t)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===Qc}toUint8Array(){return this._arr}toHex(){return oh(this._arr).toUpperCase()}toText(){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,jc(this._arr));let n=new Uint8Array(t),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),a=qc(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[Ci]:this.toText()}}compareTo(t){for(let r=0;r<Math.min(this._arr.length,t._arr.length);r++){if(this._arr[r]<t._arr[r])return"lt";if(this._arr[r]>t._arr[r])return"gt"}return this._arr.length<t._arr.length?"lt":this._arr.length>t._arr.length?"gt":"eq"}ltEq(t){let r=this.compareTo(t);return r=="lt"||r=="eq"}gtEq(t){let r=this.compareTo(t);return r=="gt"||r=="eq"}}});var tu=Ht(qi=>{"use strict";qi.byteLength=ch;qi.toByteArray=fh;qi.fromByteArray=dh;var Ye=[],ve=[],ah=typeof Uint8Array<"u"?Uint8Array:Array,ko="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(jr=0,Lc=ko.length;jr<Lc;++jr)Ye[jr]=ko[jr],ve[ko.charCodeAt(jr)]=jr;var jr,Lc;ve[45]=62;ve[95]=63;function Dc(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function ch(e){var t=Dc(e),r=t[0],n=t[1];return(r+n)*3/4-n}function uh(e,t,r){return(t+r)*3/4-r}function fh(e){var t,r=Dc(e),n=r[0],i=r[1],s=new ah(uh(e,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)t=ve[e.charCodeAt(c)]<<18|ve[e.charCodeAt(c+1)]<<12|ve[e.charCodeAt(c+2)]<<6|ve[e.charCodeAt(c+3)],s[o++]=t>>16&255,s[o++]=t>>8&255,s[o++]=t&255;return i===2&&(t=ve[e.charCodeAt(c)]<<2|ve[e.charCodeAt(c+1)]>>4,s[o++]=t&255),i===1&&(t=ve[e.charCodeAt(c)]<<10|ve[e.charCodeAt(c+1)]<<4|ve[e.charCodeAt(c+2)]>>2,s[o++]=t>>8&255,s[o++]=t&255),s}function lh(e){return Ye[e>>18&63]+Ye[e>>12&63]+Ye[e>>6&63]+Ye[e&63]}function hh(e,t,r){for(var n,i=[],s=t;s<r;s+=3)n=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(e[s+2]&255),i.push(lh(n));return i.join("")}function dh(e){for(var t,r=e.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(hh(e,o,o+s>a?a:o+s));return n===1?(t=e[r-1],i.push(Ye[t>>2]+Ye[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Ye[t>>10]+Ye[t>>4&63]+Ye[t<<2&63]+"=")),i.join("")}});var Co=Ht(Mo=>{Mo.read=function(e,t,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,l=c>>1,h=-7,d=r?i-1:0,g=r?-1:1,w=e[t+d];for(d+=g,s=w&(1<<-h)-1,w>>=-h,h+=a;h>0;s=s*256+e[t+d],d+=g,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=o*256+e[t+d],d+=g,h-=8);if(s===0)s=1-l;else{if(s===c)return o?NaN:(w?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-l}return(w?-1:1)*o*Math.pow(2,s-n)};Mo.write=function(e,t,r,n,i,s){var o,a,c,l=s*8-i-1,h=(1<<l)-1,d=h>>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=n?0:s-1,f=n?1:-1,O=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+d>=1?t+=g/c:t+=g*Math.pow(2,1-d),t*c>=2&&(o++,c/=2),o+d>=h?(a=0,o=h):o+d>=1?(a=(t*c-1)*Math.pow(2,i),o=o+d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;e[r+w]=a&255,w+=f,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;e[r+w]=o&255,w+=f,o/=256,l-=8);e[r+w-f]|=O*128}});var gu=Ht(hn=>{"use strict";var qo=tu(),fn=Co(),eu=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;hn.Buffer=H;hn.SlowBuffer=bh;hn.INSPECT_MAX_BYTES=50;var Vi=2147483647;hn.kMaxLength=Vi;H.TYPED_ARRAY_SUPPORT=ph();!H.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 ph(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(H.prototype,"parent",{enumerable:!0,get:function(){if(H.isBuffer(this))return this.buffer}});Object.defineProperty(H.prototype,"offset",{enumerable:!0,get:function(){if(H.isBuffer(this))return this.byteOffset}});function sr(e){if(e>Vi)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,H.prototype),t}function H(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Ho(e)}return su(e,t,r)}H.poolSize=8192;function su(e,t,r){if(typeof e=="string")return yh(e,t);if(ArrayBuffer.isView(e))return gh(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Ke(e,ArrayBuffer)||e&&Ke(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ke(e,SharedArrayBuffer)||e&&Ke(e.buffer,SharedArrayBuffer)))return $o(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return H.from(n,t,r);let i=wh(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return H.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}H.from=function(e,t,r){return su(e,t,r)};Object.setPrototypeOf(H.prototype,Uint8Array.prototype);Object.setPrototypeOf(H,Uint8Array);function ou(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function mh(e,t,r){return ou(e),e<=0?sr(e):t!==void 0?typeof r=="string"?sr(e).fill(t,r):sr(e).fill(t):sr(e)}H.alloc=function(e,t,r){return mh(e,t,r)};function Ho(e){return ou(e),sr(e<0?0:Go(e)|0)}H.allocUnsafe=function(e){return Ho(e)};H.allocUnsafeSlow=function(e){return Ho(e)};function yh(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!H.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=au(e,t)|0,n=sr(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function Vo(e){let t=e.length<0?0:Go(e.length)|0,r=sr(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function gh(e){if(Ke(e,Uint8Array)){let t=new Uint8Array(e);return $o(t.buffer,t.byteOffset,t.byteLength)}return Vo(e)}function $o(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,H.prototype),n}function wh(e){if(H.isBuffer(e)){let t=Go(e.length)|0,r=sr(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||Yo(e.length)?sr(0):Vo(e);if(e.type==="Buffer"&&Array.isArray(e.data))return Vo(e.data)}function Go(e){if(e>=Vi)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Vi.toString(16)+" bytes");return e|0}function bh(e){return+e!=e&&(e=0),H.alloc(+e)}H.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==H.prototype};H.compare=function(t,r){if(Ke(t,Uint8Array)&&(t=H.from(t,t.offset,t.byteLength)),Ke(r,Uint8Array)&&(r=H.from(r,r.offset,r.byteLength)),!H.isBuffer(t)||!H.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(t[s]!==r[s]){n=t[s],i=r[s];break}return n<i?-1:i<n?1:0};H.isEncoding=function(t){switch(String(t).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}};H.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return H.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=H.allocUnsafe(r),s=0;for(n=0;n<t.length;++n){let o=t[n];if(Ke(o,Uint8Array))s+o.length>i.length?(H.isBuffer(o)||(o=H.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(H.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function au(e,t){if(H.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Ke(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return jo(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return yu(e).length;default:if(i)return n?-1:jo(e).length;t=(""+t).toLowerCase(),i=!0}}H.byteLength=au;function xh(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return Oh(this,t,r);case"utf8":case"utf-8":return uu(this,t,r);case"ascii":return Nh(this,t,r);case"latin1":case"binary":return Rh(this,t,r);case"base64":return Th(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Fh(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}H.prototype._isBuffer=!0;function Hr(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}H.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<t;r+=2)Hr(this,r,r+1);return this};H.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<t;r+=4)Hr(this,r,r+3),Hr(this,r+1,r+2);return this};H.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<t;r+=8)Hr(this,r,r+7),Hr(this,r+1,r+6),Hr(this,r+2,r+5),Hr(this,r+3,r+4);return this};H.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?uu(this,0,t):xh.apply(this,arguments)};H.prototype.toLocaleString=H.prototype.toString;H.prototype.equals=function(t){if(!H.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:H.compare(this,t)===0};H.prototype.inspect=function(){let t="",r=hn.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};eu&&(H.prototype[eu]=H.prototype.inspect);H.prototype.compare=function(t,r,n,i,s){if(Ke(t,Uint8Array)&&(t=H.from(t,t.offset,t.byteLength)),!H.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>t.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===t)return 0;let o=s-i,a=n-r,c=Math.min(o,a),l=this.slice(i,s),h=t.slice(r,n);for(let d=0;d<c;++d)if(l[d]!==h[d]){o=l[d],a=h[d];break}return o<a?-1:a<o?1:0};function cu(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Yo(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=H.from(t,n)),H.isBuffer(t))return t.length===0?-1:ru(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ru(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ru(e,t,r,n,i){let s=1,o=e.length,a=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(h,d){return s===1?h[d]:h.readUInt16BE(d*s)}let l;if(i){let h=-1;for(l=r;l<o;l++)if(c(e,l)===c(t,h===-1?0:l-h)){if(h===-1&&(h=l),l-h+1===a)return h*s}else h!==-1&&(l-=l-h),h=-1}else for(r+a>o&&(r=o-a),l=r;l>=0;l--){let h=!0;for(let d=0;d<a;d++)if(c(e,l+d)!==c(t,d)){h=!1;break}if(h)return l}return-1}H.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};H.prototype.indexOf=function(t,r,n){return cu(this,t,r,n,!0)};H.prototype.lastIndexOf=function(t,r,n){return cu(this,t,r,n,!1)};function _h(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=t.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(t.substr(o*2,2),16);if(Yo(a))return o;e[r+o]=a}return o}function Eh(e,t,r,n){return $i(jo(t,e.length-r),e,r,n)}function vh(e,t,r,n){return $i(kh(t),e,r,n)}function Bh(e,t,r,n){return $i(yu(t),e,r,n)}function Ah(e,t,r,n){return $i(Mh(t,e.length-r),e,r,n)}H.prototype.write=function(t,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),t.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 _h(this,t,r,n);case"utf8":case"utf-8":return Eh(this,t,r,n);case"ascii":case"latin1":case"binary":return vh(this,t,r,n);case"base64":return Bh(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ah(this,t,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};H.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Th(e,t,r){return t===0&&r===e.length?qo.fromByteArray(e):qo.fromByteArray(e.slice(t,r))}function uu(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let s=e[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,l,h,d;switch(a){case 1:s<128&&(o=s);break;case 2:c=e[i+1],(c&192)===128&&(d=(s&31)<<6|c&63,d>127&&(o=d));break;case 3:c=e[i+1],l=e[i+2],(c&192)===128&&(l&192)===128&&(d=(s&15)<<12|(c&63)<<6|l&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:c=e[i+1],l=e[i+2],h=e[i+3],(c&192)===128&&(l&192)===128&&(h&192)===128&&(d=(s&15)<<18|(c&63)<<12|(l&63)<<6|h&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return Sh(n)}var nu=4096;function Sh(e){let t=e.length;if(t<=nu)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=nu));return r}function Nh(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function Rh(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function Oh(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=t;s<r;++s)i+=Ch[e[s]];return i}function Fh(e,t,r){let n=e.slice(t,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}H.prototype.slice=function(t,r){let n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);let i=this.subarray(t,r);return Object.setPrototypeOf(i,H.prototype),i};function Qt(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}H.prototype.readUintLE=H.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Qt(t,r,this.length);let i=this[t],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[t+o]*s;return i};H.prototype.readUintBE=H.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Qt(t,r,this.length);let i=this[t+--r],s=1;for(;r>0&&(s*=256);)i+=this[t+--r]*s;return i};H.prototype.readUint8=H.prototype.readUInt8=function(t,r){return t=t>>>0,r||Qt(t,1,this.length),this[t]};H.prototype.readUint16LE=H.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||Qt(t,2,this.length),this[t]|this[t+1]<<8};H.prototype.readUint16BE=H.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||Qt(t,2,this.length),this[t]<<8|this[t+1]};H.prototype.readUint32LE=H.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||Qt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};H.prototype.readUint32BE=H.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||Qt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};H.prototype.readBigUInt64LE=xr(function(t){t=t>>>0,ln(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&jn(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,s=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});H.prototype.readBigUInt64BE=xr(function(t){t=t>>>0,ln(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&jn(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],s=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});H.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Qt(t,r,this.length);let i=this[t],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[t+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};H.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Qt(t,r,this.length);let i=r,s=1,o=this[t+--i];for(;i>0&&(s*=256);)o+=this[t+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};H.prototype.readInt8=function(t,r){return t=t>>>0,r||Qt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};H.prototype.readInt16LE=function(t,r){t=t>>>0,r||Qt(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};H.prototype.readInt16BE=function(t,r){t=t>>>0,r||Qt(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};H.prototype.readInt32LE=function(t,r){return t=t>>>0,r||Qt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};H.prototype.readInt32BE=function(t,r){return t=t>>>0,r||Qt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};H.prototype.readBigInt64LE=xr(function(t){t=t>>>0,ln(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&jn(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});H.prototype.readBigInt64BE=xr(function(t){t=t>>>0,ln(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&jn(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});H.prototype.readFloatLE=function(t,r){return t=t>>>0,r||Qt(t,4,this.length),fn.read(this,t,!0,23,4)};H.prototype.readFloatBE=function(t,r){return t=t>>>0,r||Qt(t,4,this.length),fn.read(this,t,!1,23,4)};H.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||Qt(t,8,this.length),fn.read(this,t,!0,52,8)};H.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||Qt(t,8,this.length),fn.read(this,t,!1,52,8)};function he(e,t,r,n,i,s){if(!H.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}H.prototype.writeUintLE=H.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;he(this,t,r,n,a,0)}let s=1,o=0;for(this[r]=t&255;++o<n&&(s*=256);)this[r+o]=t/s&255;return r+n};H.prototype.writeUintBE=H.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;he(this,t,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=t&255;--s>=0&&(o*=256);)this[r+s]=t/o&255;return r+n};H.prototype.writeUint8=H.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||he(this,t,r,1,255,0),this[r]=t&255,r+1};H.prototype.writeUint16LE=H.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||he(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};H.prototype.writeUint16BE=H.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||he(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};H.prototype.writeUint32LE=H.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||he(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};H.prototype.writeUint32BE=H.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||he(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function fu(e,t,r,n,i){mu(t,n,i,e,r,7);let s=Number(t&BigInt(4294967295));e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,r}function lu(e,t,r,n,i){mu(t,n,i,e,r,7);let s=Number(t&BigInt(4294967295));e[r+7]=s,s=s>>8,e[r+6]=s,s=s>>8,e[r+5]=s,s=s>>8,e[r+4]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=o,o=o>>8,e[r+2]=o,o=o>>8,e[r+1]=o,o=o>>8,e[r]=o,r+8}H.prototype.writeBigUInt64LE=xr(function(t,r=0){return fu(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});H.prototype.writeBigUInt64BE=xr(function(t,r=0){return lu(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});H.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let c=Math.pow(2,8*n-1);he(this,t,r,n,c-1,-c)}let s=0,o=1,a=0;for(this[r]=t&255;++s<n&&(o*=256);)t<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(t/o>>0)-a&255;return r+n};H.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let c=Math.pow(2,8*n-1);he(this,t,r,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[r+s]=t&255;--s>=0&&(o*=256);)t<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(t/o>>0)-a&255;return r+n};H.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||he(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};H.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||he(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};H.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||he(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};H.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||he(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};H.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||he(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};H.prototype.writeBigInt64LE=xr(function(t,r=0){return fu(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});H.prototype.writeBigInt64BE=xr(function(t,r=0){return lu(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function hu(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function du(e,t,r,n,i){return t=+t,r=r>>>0,i||hu(e,t,r,4,34028234663852886e22,-34028234663852886e22),fn.write(e,t,r,n,23,4),r+4}H.prototype.writeFloatLE=function(t,r,n){return du(this,t,r,!0,n)};H.prototype.writeFloatBE=function(t,r,n){return du(this,t,r,!1,n)};function pu(e,t,r,n,i){return t=+t,r=r>>>0,i||hu(e,t,r,8,17976931348623157e292,-17976931348623157e292),fn.write(e,t,r,n,52,8),r+8}H.prototype.writeDoubleLE=function(t,r,n){return pu(this,t,r,!0,n)};H.prototype.writeDoubleBE=function(t,r,n){return pu(this,t,r,!1,n)};H.prototype.copy=function(t,r,n,i){if(!H.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.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),t.length-r<i-n&&(i=t.length-r+n);let s=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),r),s};H.prototype.fill=function(t,r,n,i){if(typeof t=="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"&&!H.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let o=t.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(t=o)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));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,t||(t=0);let s;if(typeof t=="number")for(s=r;s<n;++s)this[s]=t;else{let o=H.isBuffer(t)?t:H.from(t,i),a=o.length;if(a===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var un={};function zo(e,t,r){un[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}zo("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);zo("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);zo("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=iu(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=iu(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function iu(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function Uh(e,t,r){ln(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&jn(t,e.length-(r+1))}function mu(e,t,r,n,i,s){if(e>r||e<t){let o=typeof t=="bigint"?"n":"",a;throw s>3?t===0||t===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${t}${o} and <= ${r}${o}`,new un.ERR_OUT_OF_RANGE("value",a,e)}Uh(n,i,s)}function ln(e,t){if(typeof e!="number")throw new un.ERR_INVALID_ARG_TYPE(t,"number",e)}function jn(e,t,r){throw Math.floor(e)!==e?(ln(e,r),new un.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new un.ERR_BUFFER_OUT_OF_BOUNDS:new un.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var Ih=/[^+/0-9A-Za-z-_]/g;function Ph(e){if(e=e.split("=")[0],e=e.trim().replace(Ih,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function jo(e,t){t=t||1/0;let r,n=e.length,i=null,s=[];for(let o=0;o<n;++o){if(r=e.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=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 kh(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function Mh(e,t){let r,n,i,s=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)r=e.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function yu(e){return qo.toByteArray(Ph(e))}function $i(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Ke(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Yo(e){return e!==e}var Ch=function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t}();function xr(e){return typeof BigInt>"u"?qh:e}function qh(){throw new Error("BigInt not supported")}});var Hn,Ko=ht(()=>{(function(e){e[e.SysFatal=1]="SysFatal",e[e.SysTransient=2]="SysTransient",e[e.DestinationInvalid=3]="DestinationInvalid",e[e.CanisterReject=4]="CanisterReject",e[e.CanisterError=5]="CanisterError"})(Hn||(Hn={}))});function oe(...e){let t=new Uint8Array(e.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of e)t.set(new Uint8Array(n),r),r+=n.byteLength;return t.buffer}function Bt(e){return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}function Gr(e){if(!Vh.test(e))throw new Error("Invalid hexadecimal string.");let t=[...e].reduce((r,n,i)=>(r[i/2|0]=(r[i/2|0]||"")+n,r),[]).map(r=>Number.parseInt(r,16));return new Uint8Array(t).buffer}function Wo(e,t){if(e.byteLength!==t.byteLength)return e.byteLength-t.byteLength;let r=new Uint8Array(e),n=new Uint8Array(t);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return r[i]-n[i];return 0}function zr(e,t){return Wo(e,t)===0}function Gn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}function Zo(e){return e instanceof Uint8Array?Gn(e):e instanceof ArrayBuffer?e:Array.isArray(e)?Gn(new Uint8Array(e)):"buffer"in e?Zo(e.buffer):Gn(new Uint8Array(e))}var Vh,de=ht(()=>{Vh=new RegExp(/^[0-9a-fA-F]+$/)});var Ft,dn=ht(()=>{we();Ko();de();Ft=class e extends Error{constructor(t){super(t),this.message=t,this.name="AgentError",this.__proto__=e.prototype,Object.setPrototypeOf(this,e.prototype)}}});function Et(...e){let t=new Uint8Array(e.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of e)t.set(new Uint8Array(n),r),r+=n.byteLength;return t}function Xo(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}function zn(e){return e instanceof Uint8Array?Xo(e):e instanceof ArrayBuffer?e:Array.isArray(e)?Xo(new Uint8Array(e)):"buffer"in e?zn(e.buffer):Xo(new Uint8Array(e))}var Oe,ji=ht(()=>{Oe=class{constructor(t,r=t?.byteLength||0){this._buffer=zn(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return zn(this._view.slice())}get byteLength(){return this._view.byteLength}read(t){let r=this._view.subarray(0,t);return this._view=this._view.subarray(t),r.slice().buffer}readUint8(){let t=this._view[0];return this._view=this._view.subarray(1),t}write(t){let r=new Uint8Array(t),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(t){let r=new ArrayBuffer((this._buffer.byteLength+t)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+t);n.set(this._view),this._buffer=r,this._view=n}}});function $h(e){let r=new TextEncoder().encode(e),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function Fe(e){if(/^_\d+_$/.test(e)||/^_0x[0-9a-fA-F]+_$/.test(e)){let t=+e.slice(1,-1);if(Number.isSafeInteger(t)&&t>=0&&t<2**32)return t}return $h(e)}var Jo=ht(()=>{});function wu(){throw new Error("unexpected end of buffer")}function Er(e,t){return e.byteLength<t&&wu(),e.read(t)}function _r(e){let t=e.readUint8();return t===void 0&&wu(),t}function Pt(e){if(typeof e=="number"&&(e=BigInt(e)),e<BigInt(0))throw new Error("Cannot leb encode negative values.");let t=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,r=new Oe(new ArrayBuffer(t),0);for(;;){let n=Number(e&BigInt(127));if(e/=BigInt(128),e===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}function Gt(e){let t=BigInt(1),r=BigInt(0),n;do n=_r(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}function zt(e){typeof e=="number"&&(e=BigInt(e));let t=e<BigInt(0);t&&(e=-e-BigInt(1));let r=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,n=new Oe(new ArrayBuffer(r),0);for(;;){let s=i(e);if(e/=BigInt(128),t&&e===BigInt(0)&&(s&64)!==0||!t&&e===BigInt(0)&&(s&64)===0){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let o=s%BigInt(128);return Number(t?BigInt(128)-o-BigInt(1):o)}return n.buffer}function or(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if((t[r]&64)===0)return Gt(e);break}let n=new Uint8Array(Er(e,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)}function bu(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return Qo(e,t)}function Qo(e,t){e=BigInt(e);let r=new Oe(new ArrayBuffer(Math.min(1,t)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(e%i);for(r.write(new Uint8Array([o]));++n<t;)e<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((e/i-s)%BigInt(256)),r.write(new Uint8Array([o])),i*=BigInt(256);return r.buffer}function Lo(e,t){let r=BigInt(_r(e)),n=BigInt(1),i=0;for(;++i<t;){n*=BigInt(256);let s=BigInt(_r(e));r=r+n*s}return r}function xu(e,t){let r=Lo(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}var Do=ht(()=>{ji()});function Hi(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}var _u=ht(()=>{});var Br={};qn(Br,{Bool:()=>Au,BoolClass:()=>Wi,ConstructType:()=>Ze,Empty:()=>vu,EmptyClass:()=>Yi,FixedIntClass:()=>ar,FixedNatClass:()=>We,Float32:()=>Ou,Float64:()=>Fu,FloatClass:()=>Kn,Func:()=>Wu,FuncClass:()=>Zn,Int:()=>Nu,Int16:()=>Iu,Int32:()=>Pu,Int64:()=>ku,Int8:()=>Uu,IntClass:()=>Ji,Nat:()=>Ru,Nat16:()=>Cu,Nat32:()=>qu,Nat64:()=>Vu,Nat8:()=>Mu,NatClass:()=>Qi,Null:()=>Tu,NullClass:()=>Zi,Opt:()=>Gu,OptClass:()=>yn,PrimitiveType:()=>pe,Principal:()=>$u,PrincipalClass:()=>es,Rec:()=>Ku,RecClass:()=>vr,Record:()=>zu,RecordClass:()=>Wn,Reserved:()=>Bu,ReservedClass:()=>mn,Service:()=>Zu,ServiceClass:()=>rs,Text:()=>Su,TextClass:()=>Xi,Tuple:()=>ju,TupleClass:()=>Di,Type:()=>pn,Unknown:()=>Gh,UnknownClass:()=>Ki,Variant:()=>Yu,VariantClass:()=>ts,Vec:()=>Hu,VecClass:()=>Li,Visitor:()=>zi,decode:()=>Hh,encode:()=>jh});function Yn(e,t,r){return e.map((n,i)=>r(n,t[i]))}function ea(e){if(_r(e)!==1)throw new Error("Cannot decode principal");let r=Number(Gt(e));return dt.fromUint8Array(new Uint8Array(Er(e,r)))}function Ct(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>Eu?t.substring(0,Eu-3)+"...":t}function jh(e,t){if(t.length<e.length)throw Error("Wrong number of message arguments");let r=new ta;e.forEach(c=>c.buildTypeTable(r));let n=new TextEncoder().encode(Gi),i=r.encode(),s=Pt(t.length),o=Et(...e.map(c=>c.encodeType(r))),a=Et(...Yn(e,t,(c,l)=>{try{c.covariant(l)}catch(h){throw new Error(h.message+`
2
-
3
- `)}return c.encodeValue(l)}));return Et(n,i,s,o,a)}function Hh(e,t){let r=new Oe(t);if(t.byteLength<Gi.length)throw new Error("Message length smaller than magic number");let n=Er(r,Gi.length),i=new TextDecoder().decode(n);if(i!==Gi)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(w){let f=[],O=Number(Gt(w));for(let j=0;j<O;j++){let S=Number(or(w));switch(S){case-18:case-19:{let K=Number(or(w));f.push([S,K]);break}case-20:case-21:{let K=[],_=Number(Gt(w)),$;for(;_--;){let z=Number(Gt(w));if(z>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof $=="number"&&$>=z)throw new Error("field id collision or not sorted");$=z;let Y=Number(or(w));K.push([z,Y])}f.push([S,K]);break}case-22:{let K=[],_=Number(Gt(w));for(;_--;)K.push(Number(or(w)));let $=[],z=Number(Gt(w));for(;z--;)$.push(Number(or(w)));let Y=[],M=Number(Gt(w));for(;M--;)switch(Number(Gt(w))){case 1:{Y.push("query");break}case 2:{Y.push("oneway");break}case 3:{Y.push("composite_query");break}default:throw new Error("unknown annotation")}f.push([S,[K,$,Y]]);break}case-23:{let K=Number(Gt(w)),_=[];for(;K--;){let $=Number(Gt(w)),z=new TextDecoder().decode(Er(w,$)),Y=or(w);_.push([z,Y])}f.push([S,_]);break}default:throw new Error("Illegal op_code: "+S)}}let N=[],F=Number(Gt(w));for(let j=0;j<F;j++)N.push(Number(or(w)));return[f,N]}let[o,a]=s(r);if(a.length<e.length)throw new Error("Wrong number of return values");let c=o.map(w=>Ku());function l(w){if(w<-24)throw new Error("future value not supported");if(w<0)switch(w){case-1:return Tu;case-2:return Au;case-3:return Ru;case-4:return Nu;case-5:return Mu;case-6:return Cu;case-7:return qu;case-8:return Vu;case-9:return Uu;case-10:return Iu;case-11:return Pu;case-12:return ku;case-13:return Ou;case-14:return Fu;case-15:return Su;case-16:return Bu;case-17:return vu;case-24:return $u;default:throw new Error("Illegal op_code: "+w)}if(w>=o.length)throw new Error("type index out of range");return c[w]}function h(w){switch(w[0]){case-19:{let f=l(w[1]);return Hu(f)}case-18:{let f=l(w[1]);return Gu(f)}case-20:{let f={};for(let[F,j]of w[1]){let S=`_${F}_`;f[S]=l(j)}let O=zu(f),N=O.tryAsTuple();return Array.isArray(N)?ju(...N):O}case-21:{let f={};for(let[O,N]of w[1]){let F=`_${O}_`;f[F]=l(N)}return Yu(f)}case-22:{let[f,O,N]=w[1];return Wu(f.map(F=>l(F)),O.map(F=>l(F)),N)}case-23:{let f={},O=w[1];for(let[N,F]of O){let j=l(F);if(j instanceof vr&&(j=j.getType()),!(j instanceof Zn))throw new Error("Illegal service definition: services can only contain functions");f[N]=j}return Zu(f)}default:throw new Error("Illegal op_code: "+w[0])}}o.forEach((w,f)=>{if(w[0]===-22){let O=h(w);c[f].fill(O)}}),o.forEach((w,f)=>{if(w[0]!==-22){let O=h(w);c[f].fill(O)}});let d=a.map(w=>l(w)),g=e.map((w,f)=>w.decodeValue(r,d[f]));for(let w=e.length;w<d.length;w++)d[w].decodeValue(r,d[w]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return g}function ju(...e){return new Di(e)}function Hu(e){return new Li(e)}function Gu(e){return new yn(e)}function zu(e){return new Wn(e)}function Yu(e){return new ts(e)}function Ku(){return new vr}function Wu(e,t,r=[]){return new Zn(e,t,r)}function Zu(e){return new rs(e)}var Gi,Eu,ta,zi,pn,pe,Ze,Yi,Ki,Wi,Zi,mn,Xi,Ji,Qi,Kn,ar,We,Li,yn,Wn,Di,ts,vr,es,Zn,rs,vu,Bu,Gh,Au,Tu,Su,Nu,Ru,Ou,Fu,Uu,Iu,Pu,ku,Mu,Cu,qu,Vu,$u,ra=ht(()=>{we();ji();Jo();Do();_u();Gi="DIDL",Eu=400;ta=class{constructor(){this._typs=[],this._idx=new Map}has(t){return this._idx.has(t.name)}add(t,r){let n=this._typs.length;this._idx.set(t.name,n),this._typs.push(r)}merge(t,r){let n=this._idx.get(t.name),i=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+t);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 t=Pt(this._typs.length),r=Et(...this._typs);return Et(t,r)}indexOf(t){if(!this._idx.has(t))throw new Error("Missing type index for "+t);return zt(this._idx.get(t)||0)}},zi=class{visitType(t,r){throw new Error("Not implemented")}visitPrimitive(t,r){return this.visitType(t,r)}visitEmpty(t,r){return this.visitPrimitive(t,r)}visitBool(t,r){return this.visitPrimitive(t,r)}visitNull(t,r){return this.visitPrimitive(t,r)}visitReserved(t,r){return this.visitPrimitive(t,r)}visitText(t,r){return this.visitPrimitive(t,r)}visitNumber(t,r){return this.visitPrimitive(t,r)}visitInt(t,r){return this.visitNumber(t,r)}visitNat(t,r){return this.visitNumber(t,r)}visitFloat(t,r){return this.visitPrimitive(t,r)}visitFixedInt(t,r){return this.visitNumber(t,r)}visitFixedNat(t,r){return this.visitNumber(t,r)}visitPrincipal(t,r){return this.visitPrimitive(t,r)}visitConstruct(t,r){return this.visitType(t,r)}visitVec(t,r,n){return this.visitConstruct(t,n)}visitOpt(t,r,n){return this.visitConstruct(t,n)}visitRecord(t,r,n){return this.visitConstruct(t,n)}visitTuple(t,r,n){let i=r.map((s,o)=>[`_${o}_`,s]);return this.visitRecord(t,i,n)}visitVariant(t,r,n){return this.visitConstruct(t,n)}visitRec(t,r,n){return this.visitConstruct(r,n)}visitFunc(t,r){return this.visitConstruct(t,r)}visitService(t,r){return this.visitConstruct(t,r)}},pn=class{display(){return this.name}valueToString(t){return Ct(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}},pe=class extends pn{checkType(t){if(this.name!==t.name)throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`);return t}_buildTypeTableImpl(t){}},Ze=class extends pn{checkType(t){if(t instanceof vr){let r=t.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`)}encodeType(t){return t.indexOf(this.name)}},Yi=class extends pe{accept(t,r){return t.visitEmpty(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return zt(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},Ki=class extends pn{checkType(t){throw new Error("Method not implemented for unknown.")}accept(t,r){throw t.visitType(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}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(t,r){let n=r.decodeValue(t,r);Object(n)!==n&&(n=Object(n));let i;return r instanceof vr?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"}},Wi=class extends pe{accept(t,r){return t.visitBool(this,r)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return zt(-2)}decodeValue(t,r){switch(this.checkType(r),_r(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},Zi=class extends pe{accept(t,r){return t.visitNull(this,r)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return zt(-1)}decodeValue(t,r){return this.checkType(r),null}get name(){return"null"}},mn=class extends pe{accept(t,r){return t.visitReserved(this,r)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return zt(-16)}decodeValue(t,r){return r.name!==this.name&&r.decodeValue(t,r),null}get name(){return"reserved"}},Xi=class extends pe{accept(t,r){return t.visitText(this,r)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue(t){let r=new TextEncoder().encode(t),n=Pt(r.byteLength);return Et(n,r)}encodeType(){return zt(-15)}decodeValue(t,r){this.checkType(r);let n=Gt(t),i=Er(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(t){return'"'+t+'"'}},Ji=class extends pe{accept(t,r){return t.visitInt(this,r)}covariant(t){if(typeof t=="bigint"||Number.isInteger(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue(t){return zt(t)}encodeType(){return zt(-4)}decodeValue(t,r){return this.checkType(r),or(t)}get name(){return"int"}valueToString(t){return t.toString()}},Qi=class extends pe{accept(t,r){return t.visitNat(this,r)}covariant(t){if(typeof t=="bigint"&&t>=BigInt(0)||Number.isInteger(t)&&t>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue(t){return Pt(t)}encodeType(){return zt(-3)}decodeValue(t,r){return this.checkType(r),Gt(t)}get name(){return"nat"}valueToString(t){return t.toString()}},Kn=class extends pe{constructor(t){if(super(),this._bits=t,t!==32&&t!==64)throw new Error("not a valid float type")}accept(t,r){return t.visitFloat(this,r)}covariant(t){if(typeof t=="number"||t instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue(t){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,t,!0):n.setFloat64(0,t,!0),r}encodeType(){let t=this._bits===32?-13:-14;return zt(t)}decodeValue(t,r){this.checkType(r);let n=Er(t,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(t){return t.toString()}},ar=class extends pe{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedInt(this,r)}covariant(t){let r=Hi(this._bits-1)*BigInt(-1),n=Hi(this._bits-1)-BigInt(1),i=!1;if(typeof t=="bigint")i=t>=r&&t<=n;else if(Number.isInteger(t)){let s=BigInt(t);i=s>=r&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue(t){return Qo(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return zt(-9-t)}decodeValue(t,r){this.checkType(r);let n=xu(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}},We=class extends pe{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedNat(this,r)}covariant(t){let r=Hi(this._bits),n=!1;if(typeof t=="bigint"&&t>=BigInt(0)?n=t<r:Number.isInteger(t)&&t>=0?n=BigInt(t)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue(t){return bu(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return zt(-5-t)}decodeValue(t,r){this.checkType(r);let n=Lo(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}},Li=class e extends Ze{constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof We&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof We?this._type._bits:this._type instanceof ar?this._type._bits:0;if(ArrayBuffer.isView(t)&&r==t.BYTES_PER_ELEMENT*8||Array.isArray(t)&&t.every((n,i)=>{try{return this._type.covariant(n)}catch(s){throw new Error(`Invalid ${this.display()} argument:
4
-
5
- index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue(t){let r=Pt(t.length);if(this._blobOptimization)return Et(r,new Uint8Array(t));if(ArrayBuffer.isView(t))return Et(r,new Uint8Array(t.buffer));let n=new Oe(new ArrayBuffer(r.byteLength+t.length),0);n.write(r);for(let i of t){let s=this._type.encodeValue(i);n.write(new Uint8Array(s))}return n.buffer}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=zt(-19),n=this._type.encodeType(t);t.add(this,Et(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a vector type");let i=Number(Gt(t));if(this._type instanceof We){if(this._type._bits==8)return new Uint8Array(t.read(i));if(this._type._bits==16)return new Uint16Array(t.read(i*2));if(this._type._bits==32)return new Uint32Array(t.read(i*4));if(this._type._bits==64)return new BigUint64Array(t.read(i*8))}if(this._type instanceof ar){if(this._type._bits==8)return new Int8Array(t.read(i));if(this._type._bits==16)return new Int16Array(t.read(i*2));if(this._type._bits==32)return new Int32Array(t.read(i*4));if(this._type._bits==64)return new BigInt64Array(t.read(i*8))}let s=[];for(let o=0;o<i;o++)s.push(this._type.decodeValue(t,n._type));return s}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(t){return"vec {"+t.map(n=>this._type.valueToString(n)).join("; ")+"}"}},yn=class e extends Ze{constructor(t){super(),this._type=t}accept(t,r){return t.visitOpt(this,this._type,r)}covariant(t){try{if(Array.isArray(t)&&(t.length===0||t.length===1&&this._type.covariant(t[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}
6
-
7
- -> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue(t){return t.length===0?new Uint8Array([0]):Et(new Uint8Array([1]),this._type.encodeValue(t[0]))}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=zt(-18),n=this._type.encodeType(t);t.add(this,Et(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not an option type");switch(_r(t)){case 0:return[];case 1:return[this._type.decodeValue(t,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(t){return t.length===0?"null":`opt ${this._type.valueToString(t[0])}`}},Wn=class e extends Ze{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>Fe(r[0])-Fe(n[0]))}accept(t,r){return t.visitRecord(this,this._fields,r)}tryAsTuple(){let t=[];for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(n!==`_${r}_`)return null;t.push(i)}return t}covariant(t){if(typeof t=="object"&&this._fields.every(([r,n])=>{if(!t.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(t[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
8
-
9
- field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue(t){let r=this._fields.map(([i])=>t[i]),n=Yn(this._fields,r,([,i],s)=>i.encodeValue(s));return Et(...n)}_buildTypeTableImpl(t){this._fields.forEach(([s,o])=>o.buildTypeTable(t));let r=zt(-20),n=Pt(this._fields.length),i=this._fields.map(([s,o])=>Et(Pt(Fe(s)),o.encodeType(t)));t.add(this,Et(r,n,Et(...i)))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a record type");let i={},s=0,o=0;for(;o<n._fields.length;){let[a,c]=n._fields[o];if(s>=this._fields.length){c.decodeValue(t,c),o++;continue}let[l,h]=this._fields[s],d=Fe(this._fields[s][0]),g=Fe(a);if(d===g)i[l]=h.decodeValue(t,c),s++,o++;else if(g>d)if(h instanceof yn||h instanceof mn)i[l]=[],s++;else throw new Error("Cannot find required field "+l);else c.decodeValue(t,c),o++}for(let[a,c]of this._fields.slice(s))if(c instanceof yn||c instanceof mn)i[a]=[];else throw new Error("Cannot find required field "+a);return i}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(t){let r=this._fields.map(([i])=>t[i]);return`record {${Yn(this._fields,r,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}},Di=class e extends Wn{constructor(t){let r={};t.forEach((n,i)=>r["_"+i+"_"]=n),super(r),this._components=t}accept(t,r){return t.visitTuple(this,this._components,r)}covariant(t){if(Array.isArray(t)&&t.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(t[n])}catch(i){throw new Error(`Invalid ${this.display()} argument:
10
-
11
- index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue(t){let r=Yn(this._components,t,(n,i)=>n.encodeValue(i));return Et(...r)}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))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(t,o):i.push(this._components[s].decodeValue(t,o));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(t){return`record {${Yn(this._components,t,(n,i)=>n.valueToString(i)).join("; ")}}`}},ts=class e extends Ze{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>Fe(r[0])-Fe(n[0]))}accept(t,r){return t.visitVariant(this,this._fields,r)}covariant(t){if(typeof t=="object"&&Object.entries(t).length===1&&this._fields.every(([r,n])=>{try{return!t.hasOwnProperty(r)||n.covariant(t[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
12
-
13
- variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue(t){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(t.hasOwnProperty(n)){let s=Pt(r),o=i.encodeValue(t[n]);return Et(s,o)}}throw Error("Variant has no data: "+t)}_buildTypeTableImpl(t){this._fields.forEach(([,s])=>{s.buildTypeTable(t)});let r=zt(-21),n=Pt(this._fields.length),i=this._fields.map(([s,o])=>Et(Pt(Fe(s)),o.encodeType(t)));t.add(this,Et(r,n,...i))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a variant type");let i=Number(Gt(t));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,o]=n._fields[i];for(let[a,c]of this._fields)if(Fe(s)===Fe(a)){let l=c.decodeValue(t,o);return{[a]: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(t){for(let[r,n]of this._fields)if(t.hasOwnProperty(r)){let i=n.valueToString(t[r]);return i==="null"?`variant {${r}}`:`variant {${r}=${i}}`}throw new Error("Variant has no data: "+t)}},vr=class e extends Ze{constructor(){super(...arguments),this._id=e._counter++,this._type=void 0}accept(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return t.visitRec(this,this._type,r)}fill(t){this._type=t}getType(){return this._type}covariant(t){if(this._type&&this._type.covariant(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(t)}_buildTypeTableImpl(t){if(!this._type)throw Error("Recursive type uninitialized.");t.add(this,new Uint8Array([])),this._type.buildTypeTable(t),t.merge(this,this._type.name)}decodeValue(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(t,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(t)}};vr._counter=0;es=class extends pe{accept(t,r){return t.visitPrincipal(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=Pt(r.byteLength);return Et(new Uint8Array([1]),n,r)}encodeType(){return zt(-24)}decodeValue(t,r){return this.checkType(r),ea(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}},Zn=class extends Ze{constructor(t,r,n=[]){super(),this.argTypes=t,this.retTypes=r,this.annotations=n}static argsToString(t,r){if(t.length!==r.length)throw new Error("arity mismatch");return"("+t.map((n,i)=>n.valueToString(r[i])).join(", ")+")"}accept(t,r){return t.visitFunc(this,r)}covariant(t){if(Array.isArray(t)&&t.length===2&&t[0]&&t[0]._isPrincipal&&typeof t[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue([t,r]){let n=t.toUint8Array(),i=Pt(n.byteLength),s=Et(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),a=Pt(o.byteLength);return Et(new Uint8Array([1]),s,a,o)}_buildTypeTableImpl(t){this.argTypes.forEach(l=>l.buildTypeTable(t)),this.retTypes.forEach(l=>l.buildTypeTable(t));let r=zt(-22),n=Pt(this.argTypes.length),i=Et(...this.argTypes.map(l=>l.encodeType(t))),s=Pt(this.retTypes.length),o=Et(...this.retTypes.map(l=>l.encodeType(t))),a=Pt(this.annotations.length),c=Et(...this.annotations.map(l=>this.encodeAnnotation(l)));t.add(this,Et(r,n,i,s,o,a,c))}decodeValue(t){if(_r(t)!==1)throw new Error("Cannot decode function reference");let n=ea(t),i=Number(Gt(t)),s=Er(t,i),a=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,a]}get name(){let t=this.argTypes.map(i=>i.name).join(", "),r=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${t}) -> (${r})${n}`}valueToString([t,r]){return`func "${t.toText()}".${r}`}display(){let t=this.argTypes.map(i=>i.display()).join(", "),r=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${t}) \u2192 (${r})${n}`}encodeAnnotation(t){if(t==="query")return new Uint8Array([1]);if(t==="oneway")return new Uint8Array([2]);if(t==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}},rs=class extends Ze{constructor(t){super(),this._fields=Object.entries(t).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(t,r){return t.visitService(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ct(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=Pt(r.length);return Et(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([s,o])=>o.buildTypeTable(t));let r=zt(-23),n=Pt(this._fields.length),i=this._fields.map(([s,o])=>{let a=new TextEncoder().encode(s),c=Pt(a.length);return Et(c,a,o.encodeType(t))});t.add(this,Et(r,n,...i))}decodeValue(t){return ea(t)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(t){return`service "${t.toText()}"`}};vu=new Yi,Bu=new mn,Gh=new Ki,Au=new Wi,Tu=new Zi,Su=new Xi,Nu=new Ji,Ru=new Qi,Ou=new Kn(32),Fu=new Kn(64),Uu=new ar(8),Iu=new ar(16),Pu=new ar(32),ku=new ar(64),Mu=new We(8),Cu=new We(16),qu=new We(32),Vu=new We(64),$u=new es});var na=ht(()=>{});var Xu=ht(()=>{ra();we();na()});var Ju=ht(()=>{});var Xn=ht(()=>{Xu();na();ra();Jo();Do();ji();Ju()});var gf={};qn(gf,{Buffer:()=>X,INSPECT_MAX_BYTES:()=>nf,SlowBuffer:()=>ed,isBuffer:()=>mf,kMaxLength:()=>Jh});function tf(){sa=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t<r;++t)Xe[t]=e[t],Be[e.charCodeAt(t)]=t;Be[45]=62,Be[95]=63}function Kh(e){sa||tf();var t,r,n,i,s,o,a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s=e[a-2]==="="?2:e[a-1]==="="?1:0,o=new Yh(a*3/4-s),n=s>0?a-4:a;var c=0;for(t=0,r=0;t<n;t+=4,r+=3)i=Be[e.charCodeAt(t)]<<18|Be[e.charCodeAt(t+1)]<<12|Be[e.charCodeAt(t+2)]<<6|Be[e.charCodeAt(t+3)],o[c++]=i>>16&255,o[c++]=i>>8&255,o[c++]=i&255;return s===2?(i=Be[e.charCodeAt(t)]<<2|Be[e.charCodeAt(t+1)]>>4,o[c++]=i&255):s===1&&(i=Be[e.charCodeAt(t)]<<10|Be[e.charCodeAt(t+1)]<<4|Be[e.charCodeAt(t+2)]>>2,o[c++]=i>>8&255,o[c++]=i&255),o}function Wh(e){return Xe[e>>18&63]+Xe[e>>12&63]+Xe[e>>6&63]+Xe[e&63]}function Zh(e,t,r){for(var n,i=[],s=t;s<r;s+=3)n=(e[s]<<16)+(e[s+1]<<8)+e[s+2],i.push(Wh(n));return i.join("")}function Qu(e){sa||tf();for(var t,r=e.length,n=r%3,i="",s=[],o=16383,a=0,c=r-n;a<c;a+=o)s.push(Zh(e,a,a+o>c?c:a+o));return n===1?(t=e[r-1],i+=Xe[t>>2],i+=Xe[t<<4&63],i+="=="):n===2&&(t=(e[r-2]<<8)+e[r-1],i+=Xe[t>>10],i+=Xe[t>>4&63],i+=Xe[t<<2&63],i+="="),s.push(i),s.join("")}function ss(e,t,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,l=c>>1,h=-7,d=r?i-1:0,g=r?-1:1,w=e[t+d];for(d+=g,s=w&(1<<-h)-1,w>>=-h,h+=a;h>0;s=s*256+e[t+d],d+=g,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=o*256+e[t+d],d+=g,h-=8);if(s===0)s=1-l;else{if(s===c)return o?NaN:(w?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-l}return(w?-1:1)*o*Math.pow(2,s-n)}function ef(e,t,r,n,i,s){var o,a,c,l=s*8-i-1,h=(1<<l)-1,d=h>>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=n?0:s-1,f=n?1:-1,O=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+d>=1?t+=g/c:t+=g*Math.pow(2,1-d),t*c>=2&&(o++,c/=2),o+d>=h?(a=0,o=h):o+d>=1?(a=(t*c-1)*Math.pow(2,i),o=o+d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;e[r+w]=a&255,w+=f,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;e[r+w]=o&255,w+=f,o/=256,l-=8);e[r+w-f]|=O*128}function ns(){return X.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function cr(e,t){if(ns()<t)throw new RangeError("Invalid typed array length");return X.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t),e.__proto__=X.prototype):(e===null&&(e=new X(t)),e.length=t),e}function X(e,t,r){if(!X.TYPED_ARRAY_SUPPORT&&!(this instanceof X))return new X(e,t,r);if(typeof e=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return oa(this,e)}return sf(this,e,t,r)}function sf(e,t,r,n){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer?Dh(e,t,r,n):typeof t=="string"?Lh(e,t,r):td(e,t)}function of(e){if(typeof e!="number")throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function Qh(e,t,r,n){return of(t),t<=0?cr(e,t):r!==void 0?typeof n=="string"?cr(e,t).fill(r,n):cr(e,t).fill(r):cr(e,t)}function oa(e,t){if(of(t),e=cr(e,t<0?0:aa(t)|0),!X.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function Lh(e,t,r){if((typeof r!="string"||r==="")&&(r="utf8"),!X.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=af(t,r)|0;e=cr(e,n);var i=e.write(t,r);return i!==n&&(e=e.slice(0,i)),e}function ia(e,t){var r=t.length<0?0:aa(t.length)|0;e=cr(e,r);for(var n=0;n<r;n+=1)e[n]=t[n]&255;return e}function Dh(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return r===void 0&&n===void 0?t=new Uint8Array(t):n===void 0?t=new Uint8Array(t,r):t=new Uint8Array(t,r,n),X.TYPED_ARRAY_SUPPORT?(e=t,e.__proto__=X.prototype):e=ia(e,t),e}function td(e,t){if(Je(t)){var r=aa(t.length)|0;return e=cr(e,r),e.length===0||t.copy(e,0,0,r),e}if(t){if(typeof ArrayBuffer<"u"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||xd(t.length)?cr(e,0):ia(e,t);if(t.type==="Buffer"&&rf(t.data))return ia(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function aa(e){if(e>=ns())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ns().toString(16)+" bytes");return e|0}function ed(e){return+e!=e&&(e=0),X.alloc(+e)}function Je(e){return!!(e!=null&&e._isBuffer)}function af(e,t){if(Je(e))return e.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;typeof e!="string"&&(e=""+e);var r=e.length;if(r===0)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return is(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return pf(e).length;default:if(n)return is(e).length;t=(""+t).toLowerCase(),n=!0}}function rd(e,t,r){var n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return hd(this,t,r);case"utf8":case"utf-8":return ff(this,t,r);case"ascii":return fd(this,t,r);case"latin1":case"binary":return ld(this,t,r);case"base64":return cd(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return dd(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Yr(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function cf(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=X.from(t,n)),Je(t))return t.length===0?-1:Lu(e,t,r,n,i);if(typeof t=="number")return t=t&255,X.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Lu(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Lu(e,t,r,n,i){var s=1,o=e.length,a=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(w,f){return s===1?w[f]:w.readUInt16BE(f*s)}var l;if(i){var h=-1;for(l=r;l<o;l++)if(c(e,l)===c(t,h===-1?0:l-h)){if(h===-1&&(h=l),l-h+1===a)return h*s}else h!==-1&&(l-=l-h),h=-1}else for(r+a>o&&(r=o-a),l=r;l>=0;l--){for(var d=!0,g=0;g<a;g++)if(c(e,l+g)!==c(t,g)){d=!1;break}if(d)return l}return-1}function nd(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var s=t.length;if(s%2!==0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var a=parseInt(t.substr(o*2,2),16);if(isNaN(a))return o;e[r+o]=a}return o}function id(e,t,r,n){return cs(is(t,e.length-r),e,r,n)}function uf(e,t,r,n){return cs(wd(t),e,r,n)}function sd(e,t,r,n){return uf(e,t,r,n)}function od(e,t,r,n){return cs(pf(t),e,r,n)}function ad(e,t,r,n){return cs(bd(t,e.length-r),e,r,n)}function cd(e,t,r){return t===0&&r===e.length?Qu(e):Qu(e.slice(t,r))}function ff(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var s=e[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){var c,l,h,d;switch(a){case 1:s<128&&(o=s);break;case 2:c=e[i+1],(c&192)===128&&(d=(s&31)<<6|c&63,d>127&&(o=d));break;case 3:c=e[i+1],l=e[i+2],(c&192)===128&&(l&192)===128&&(d=(s&15)<<12|(c&63)<<6|l&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:c=e[i+1],l=e[i+2],h=e[i+3],(c&192)===128&&(l&192)===128&&(h&192)===128&&(d=(s&15)<<18|(c&63)<<12|(l&63)<<6|h&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return ud(n)}function ud(e){var t=e.length;if(t<=Du)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Du));return r}function fd(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function ld(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function hd(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=t;s<r;++s)i+=gd(e[s]);return i}function dd(e,t,r){for(var n=e.slice(t,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}function Lt(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function me(e,t,r,n,i,s){if(!Je(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function os(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-r,2);i<s;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}function as(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-r,4);i<s;++i)e[r+i]=t>>>(n?i:3-i)*8&255}function lf(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function hf(e,t,r,n,i){return i||lf(e,t,r,4),ef(e,t,r,n,23,4),r+4}function df(e,t,r,n,i){return i||lf(e,t,r,8),ef(e,t,r,n,52,8),r+8}function md(e){if(e=yd(e).replace(pd,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function yd(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function gd(e){return e<16?"0"+e.toString(16):e.toString(16)}function is(e,t){t=t||1/0;for(var r,n=e.length,i=null,s=[],o=0;o<n;++o){if(r=e.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=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 wd(e){for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function bd(e,t){for(var r,n,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)r=e.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function pf(e){return Kh(md(e))}function cs(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function xd(e){return e!==e}function mf(e){return e!=null&&(!!e._isBuffer||yf(e)||_d(e))}function yf(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function _d(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&yf(e.slice(0,0))}var Xe,Be,Yh,sa,Xh,rf,nf,Jh,Du,pd,wf=ht(()=>{Xe=[],Be=[],Yh=typeof Uint8Array<"u"?Uint8Array:Array,sa=!1;Xh={}.toString,rf=Array.isArray||function(e){return Xh.call(e)=="[object Array]"};nf=50;X.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;Jh=ns();X.poolSize=8192;X._augment=function(e){return e.__proto__=X.prototype,e};X.from=function(e,t,r){return sf(null,e,t,r)};X.TYPED_ARRAY_SUPPORT&&(X.prototype.__proto__=Uint8Array.prototype,X.__proto__=Uint8Array);X.alloc=function(e,t,r){return Qh(null,e,t,r)};X.allocUnsafe=function(e){return oa(null,e)};X.allocUnsafeSlow=function(e){return oa(null,e)};X.isBuffer=mf;X.compare=function(t,r){if(!Je(t)||!Je(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var n=t.length,i=r.length,s=0,o=Math.min(n,i);s<o;++s)if(t[s]!==r[s]){n=t[s],i=r[s];break}return n<i?-1:i<n?1:0};X.isEncoding=function(t){switch(String(t).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}};X.concat=function(t,r){if(!rf(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return X.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;var i=X.allocUnsafe(r),s=0;for(n=0;n<t.length;++n){var o=t[n];if(!Je(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,s),s+=o.length}return i};X.byteLength=af;X.prototype._isBuffer=!0;X.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)Yr(this,r,r+1);return this};X.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)Yr(this,r,r+3),Yr(this,r+1,r+2);return this};X.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)Yr(this,r,r+7),Yr(this,r+1,r+6),Yr(this,r+2,r+5),Yr(this,r+3,r+4);return this};X.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?ff(this,0,t):rd.apply(this,arguments)};X.prototype.equals=function(t){if(!Je(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:X.compare(this,t)===0};X.prototype.inspect=function(){var t="",r=nf;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"};X.prototype.compare=function(t,r,n,i,s){if(!Je(t))throw new TypeError("Argument must be a Buffer");if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>t.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===t)return 0;for(var o=s-i,a=n-r,c=Math.min(o,a),l=this.slice(i,s),h=t.slice(r,n),d=0;d<c;++d)if(l[d]!==h[d]){o=l[d],a=h[d];break}return o<a?-1:a<o?1:0};X.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};X.prototype.indexOf=function(t,r,n){return cf(this,t,r,n,!0)};X.prototype.lastIndexOf=function(t,r,n){return cf(this,t,r,n,!1)};X.prototype.write=function(t,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");var s=this.length-r;if((n===void 0||n>s)&&(n=s),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return nd(this,t,r,n);case"utf8":case"utf-8":return id(this,t,r,n);case"ascii":return uf(this,t,r,n);case"latin1":case"binary":return sd(this,t,r,n);case"base64":return od(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ad(this,t,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};X.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};Du=4096;X.prototype.slice=function(t,r){var n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);var i;if(X.TYPED_ARRAY_SUPPORT)i=this.subarray(t,r),i.__proto__=X.prototype;else{var s=r-t;i=new X(s,void 0);for(var o=0;o<s;++o)i[o]=this[o+t]}return i};X.prototype.readUIntLE=function(t,r,n){t=t|0,r=r|0,n||Lt(t,r,this.length);for(var i=this[t],s=1,o=0;++o<r&&(s*=256);)i+=this[t+o]*s;return i};X.prototype.readUIntBE=function(t,r,n){t=t|0,r=r|0,n||Lt(t,r,this.length);for(var i=this[t+--r],s=1;r>0&&(s*=256);)i+=this[t+--r]*s;return i};X.prototype.readUInt8=function(t,r){return r||Lt(t,1,this.length),this[t]};X.prototype.readUInt16LE=function(t,r){return r||Lt(t,2,this.length),this[t]|this[t+1]<<8};X.prototype.readUInt16BE=function(t,r){return r||Lt(t,2,this.length),this[t]<<8|this[t+1]};X.prototype.readUInt32LE=function(t,r){return r||Lt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};X.prototype.readUInt32BE=function(t,r){return r||Lt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};X.prototype.readIntLE=function(t,r,n){t=t|0,r=r|0,n||Lt(t,r,this.length);for(var i=this[t],s=1,o=0;++o<r&&(s*=256);)i+=this[t+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};X.prototype.readIntBE=function(t,r,n){t=t|0,r=r|0,n||Lt(t,r,this.length);for(var i=r,s=1,o=this[t+--i];i>0&&(s*=256);)o+=this[t+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};X.prototype.readInt8=function(t,r){return r||Lt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};X.prototype.readInt16LE=function(t,r){r||Lt(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};X.prototype.readInt16BE=function(t,r){r||Lt(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};X.prototype.readInt32LE=function(t,r){return r||Lt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};X.prototype.readInt32BE=function(t,r){return r||Lt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};X.prototype.readFloatLE=function(t,r){return r||Lt(t,4,this.length),ss(this,t,!0,23,4)};X.prototype.readFloatBE=function(t,r){return r||Lt(t,4,this.length),ss(this,t,!1,23,4)};X.prototype.readDoubleLE=function(t,r){return r||Lt(t,8,this.length),ss(this,t,!0,52,8)};X.prototype.readDoubleBE=function(t,r){return r||Lt(t,8,this.length),ss(this,t,!1,52,8)};X.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r|0,n=n|0,!i){var s=Math.pow(2,8*n)-1;me(this,t,r,n,s,0)}var o=1,a=0;for(this[r]=t&255;++a<n&&(o*=256);)this[r+a]=t/o&255;return r+n};X.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r|0,n=n|0,!i){var s=Math.pow(2,8*n)-1;me(this,t,r,n,s,0)}var o=n-1,a=1;for(this[r+o]=t&255;--o>=0&&(a*=256);)this[r+o]=t/a&255;return r+n};X.prototype.writeUInt8=function(t,r,n){return t=+t,r=r|0,n||me(this,t,r,1,255,0),X.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=t&255,r+1};X.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r|0,n||me(this,t,r,2,65535,0),X.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):os(this,t,r,!0),r+2};X.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r|0,n||me(this,t,r,2,65535,0),X.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):os(this,t,r,!1),r+2};X.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r|0,n||me(this,t,r,4,4294967295,0),X.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255):as(this,t,r,!0),r+4};X.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r|0,n||me(this,t,r,4,4294967295,0),X.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):as(this,t,r,!1),r+4};X.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r|0,!i){var s=Math.pow(2,8*n-1);me(this,t,r,n,s-1,-s)}var o=0,a=1,c=0;for(this[r]=t&255;++o<n&&(a*=256);)t<0&&c===0&&this[r+o-1]!==0&&(c=1),this[r+o]=(t/a>>0)-c&255;return r+n};X.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r|0,!i){var s=Math.pow(2,8*n-1);me(this,t,r,n,s-1,-s)}var o=n-1,a=1,c=0;for(this[r+o]=t&255;--o>=0&&(a*=256);)t<0&&c===0&&this[r+o+1]!==0&&(c=1),this[r+o]=(t/a>>0)-c&255;return r+n};X.prototype.writeInt8=function(t,r,n){return t=+t,r=r|0,n||me(this,t,r,1,127,-128),X.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=t&255,r+1};X.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r|0,n||me(this,t,r,2,32767,-32768),X.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):os(this,t,r,!0),r+2};X.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r|0,n||me(this,t,r,2,32767,-32768),X.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):os(this,t,r,!1),r+2};X.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r|0,n||me(this,t,r,4,2147483647,-2147483648),X.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):as(this,t,r,!0),r+4};X.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r|0,n||me(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),X.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):as(this,t,r,!1),r+4};X.prototype.writeFloatLE=function(t,r,n){return hf(this,t,r,!0,n)};X.prototype.writeFloatBE=function(t,r,n){return hf(this,t,r,!1,n)};X.prototype.writeDoubleLE=function(t,r,n){return df(this,t,r,!0,n)};X.prototype.writeDoubleBE=function(t,r,n){return df(this,t,r,!1,n)};X.prototype.copy=function(t,r,n,i){if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.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("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r<i-n&&(i=t.length-r+n);var s=i-n,o;if(this===t&&n<r&&r<i)for(o=s-1;o>=0;--o)t[o+r]=this[o+n];else if(s<1e3||!X.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)t[o+r]=this[o+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+s),r);return s};X.prototype.fill=function(t,r,n,i){if(typeof t=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),t.length===1){var s=t.charCodeAt(0);s<256&&(t=s)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!X.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof t=="number"&&(t=t&255);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,t||(t=0);var o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{var a=Je(t)?t:is(new X(t,i).toString()),c=a.length;for(o=0;o<n-r;++o)this[o+r]=a[o%c]}return this};pd=/[^+\/0-9A-Za-z-_]/g});var Jn=Ht((vy,us)=>{var Kr=(wf(),Ll(gf));if(Kr&&Kr.default){us.exports=Kr.default;for(let e in Kr)us.exports[e]=Kr[e]}else Kr&&(us.exports=Kr)});var Qn=Ht((bf,fs)=>{(function(e){"use strict";var t,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",a=1e14,c=14,l=9007199254740991,h=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],d=1e7,g=1e9;function w(_){var $,z,Y,M=k.prototype={constructor:k,toString:null,valueOf:null},it=new k(1),et=20,rt=4,b=-7,B=21,V=-1e7,U=1e7,I=!1,G=1,J=0,lt={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},ct="0123456789abcdefghijklmnopqrstuvwxyz",Z=!0;function k(u,p){var y,T,v,A,q,x,R,C,P=this;if(!(P instanceof k))return new k(u,p);if(p==null){if(u&&u._isBigNumber===!0){P.s=u.s,!u.c||u.e>U?P.c=P.e=null:u.e<V?P.c=[P.e=0]:(P.e=u.e,P.c=u.c.slice());return}if((x=typeof u=="number")&&u*0==0){if(P.s=1/u<0?(u=-u,-1):1,u===~~u){for(A=0,q=u;q>=10;q/=10,A++);A>U?P.c=P.e=null:(P.e=A,P.c=[u]);return}C=String(u)}else{if(!r.test(C=String(u)))return Y(P,C,x);P.s=C.charCodeAt(0)==45?(C=C.slice(1),-1):1}(A=C.indexOf("."))>-1&&(C=C.replace(".","")),(q=C.search(/e/i))>0?(A<0&&(A=q),A+=+C.slice(q+1),C=C.substring(0,q)):A<0&&(A=C.length)}else{if(F(p,2,ct.length,"Base"),p==10&&Z)return P=new k(u),ut(P,et+P.e+1,rt);if(C=String(u),x=typeof u=="number"){if(u*0!=0)return Y(P,C,x,p);if(P.s=1/u<0?(C=C.slice(1),-1):1,k.DEBUG&&C.replace(/^0\.0*|\./,"").length>15)throw Error(o+u)}else P.s=C.charCodeAt(0)===45?(C=C.slice(1),-1):1;for(y=ct.slice(0,p),A=q=0,R=C.length;q<R;q++)if(y.indexOf(T=C.charAt(q))<0){if(T=="."){if(q>A){A=R;continue}}else if(!v&&(C==C.toUpperCase()&&(C=C.toLowerCase())||C==C.toLowerCase()&&(C=C.toUpperCase()))){v=!0,q=-1,A=0;continue}return Y(P,String(u),x,p)}x=!1,C=z(C,p,10,P.s),(A=C.indexOf("."))>-1?C=C.replace(".",""):A=C.length}for(q=0;C.charCodeAt(q)===48;q++);for(R=C.length;C.charCodeAt(--R)===48;);if(C=C.slice(q,++R)){if(R-=q,x&&k.DEBUG&&R>15&&(u>l||u!==i(u)))throw Error(o+P.s*u);if((A=A-q-1)>U)P.c=P.e=null;else if(A<V)P.c=[P.e=0];else{if(P.e=A,P.c=[],q=(A+1)%c,A<0&&(q+=c),q<R){for(q&&P.c.push(+C.slice(0,q)),R-=c;q<R;)P.c.push(+C.slice(q,q+=c));q=c-(C=C.slice(q)).length}else q-=R;for(;q--;C+="0");P.c.push(+C)}}else P.c=[P.e=0]}k.clone=w,k.ROUND_UP=0,k.ROUND_DOWN=1,k.ROUND_CEIL=2,k.ROUND_FLOOR=3,k.ROUND_HALF_UP=4,k.ROUND_HALF_DOWN=5,k.ROUND_HALF_EVEN=6,k.ROUND_HALF_CEIL=7,k.ROUND_HALF_FLOOR=8,k.EUCLID=9,k.config=k.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,g,p),et=y),u.hasOwnProperty(p="ROUNDING_MODE")&&(y=u[p],F(y,0,8,p),rt=y),u.hasOwnProperty(p="EXPONENTIAL_AT")&&(y=u[p],y&&y.pop?(F(y[0],-g,0,p),F(y[1],0,g,p),b=y[0],B=y[1]):(F(y,-g,g,p),b=-(B=y<0?-y:y))),u.hasOwnProperty(p="RANGE"))if(y=u[p],y&&y.pop)F(y[0],-g,-1,p),F(y[1],1,g,p),V=y[0],U=y[1];else if(F(y,-g,g,p),y)V=-(U=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),G=y),u.hasOwnProperty(p="POW_PRECISION")&&(y=u[p],F(y,0,g,p),J=y),u.hasOwnProperty(p="FORMAT"))if(y=u[p],typeof y=="object")lt=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",ct=y;else throw Error(s+p+" invalid: "+y)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:et,ROUNDING_MODE:rt,EXPONENTIAL_AT:[b,B],RANGE:[V,U],CRYPTO:I,MODULO_MODE:G,POW_PRECISION:J,FORMAT:lt,ALPHABET:ct}},k.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!k.DEBUG)return!0;var p,y,T=u.c,v=u.e,A=u.s;t:if({}.toString.call(T)=="[object Array]"){if((A===1||A===-1)&&v>=-g&&v<=g&&v===i(v)){if(T[0]===0){if(v===0&&T.length===1)return!0;break t}if(p=(v+1)%c,p<1&&(p+=c),String(T[0]).length==p){for(p=0;p<T.length;p++)if(y=T[p],y<0||y>=a||y!==i(y))break t;if(y!==0)return!0}}}else if(T===null&&v===null&&(A===null||A===1||A===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},k.maximum=k.max=function(){return tt(arguments,-1)},k.minimum=k.min=function(){return tt(arguments,1)},k.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 T,v,A,q,x,R=0,C=[],P=new k(it);if(y==null?y=et:F(y,0,g),q=n(y/c),I)if(crypto.getRandomValues){for(T=crypto.getRandomValues(new Uint32Array(q*=2));R<q;)x=T[R]*131072+(T[R+1]>>>11),x>=9e15?(v=crypto.getRandomValues(new Uint32Array(2)),T[R]=v[0],T[R+1]=v[1]):(C.push(x%1e14),R+=2);R=q/2}else if(crypto.randomBytes){for(T=crypto.randomBytes(q*=7);R<q;)x=(T[R]&31)*281474976710656+T[R+1]*1099511627776+T[R+2]*4294967296+T[R+3]*16777216+(T[R+4]<<16)+(T[R+5]<<8)+T[R+6],x>=9e15?crypto.randomBytes(7).copy(T,R):(C.push(x%1e14),R+=7);R=q/7}else throw I=!1,Error(s+"crypto unavailable");if(!I)for(;R<q;)x=p(),x<9e15&&(C[R++]=x%1e14);for(q=C[--R],y%=c,q&&y&&(x=h[c-y],C[R]=i(q/x)*x);C[R]===0;C.pop(),R--);if(R<0)C=[A=0];else{for(A=-1;C[0]===0;C.splice(0,1),A-=c);for(R=1,x=C[0];x>=10;x/=10,R++);R<c&&(A-=c-R)}return P.e=A,P.c=C,P}}(),k.sum=function(){for(var u=1,p=arguments,y=new k(p[0]);u<p.length;)y=y.plus(p[u++]);return y},z=function(){var u="0123456789";function p(y,T,v,A){for(var q,x=[0],R,C=0,P=y.length;C<P;){for(R=x.length;R--;x[R]*=T);for(x[0]+=A.indexOf(y.charAt(C++)),q=0;q<x.length;q++)x[q]>v-1&&(x[q+1]==null&&(x[q+1]=0),x[q+1]+=x[q]/v|0,x[q]%=v)}return x.reverse()}return function(y,T,v,A,q){var x,R,C,P,W,Q,ot,yt,vt=y.indexOf("."),Nt=et,pt=rt;for(vt>=0&&(P=J,J=0,y=y.replace(".",""),yt=new k(T),Q=yt.pow(y.length-vt),J=P,yt.c=p(K(O(Q.c),Q.e,"0"),10,v,u),yt.e=yt.c.length),ot=p(y,T,v,q?(x=ct,u):(x=u,ct)),C=P=ot.length;ot[--P]==0;ot.pop());if(!ot[0])return x.charAt(0);if(vt<0?--C:(Q.c=ot,Q.e=C,Q.s=A,Q=$(Q,yt,Nt,pt,v),ot=Q.c,W=Q.r,C=Q.e),R=C+Nt+1,vt=ot[R],P=v/2,W=W||R<0||ot[R+1]!=null,W=pt<4?(vt!=null||W)&&(pt==0||pt==(Q.s<0?3:2)):vt>P||vt==P&&(pt==4||W||pt==6&&ot[R-1]&1||pt==(Q.s<0?8:7)),R<1||!ot[0])y=W?K(x.charAt(1),-Nt,x.charAt(0)):x.charAt(0);else{if(ot.length=R,W)for(--v;++ot[--R]>v;)ot[R]=0,R||(++C,ot=[1].concat(ot));for(P=ot.length;!ot[--P];);for(vt=0,y="";vt<=P;y+=x.charAt(ot[vt++]));y=K(y,C,x.charAt(0))}return y}}(),$=function(){function u(T,v,A){var q,x,R,C,P=0,W=T.length,Q=v%d,ot=v/d|0;for(T=T.slice();W--;)R=T[W]%d,C=T[W]/d|0,q=ot*R+C*Q,x=Q*R+q%d*d+P,P=(x/A|0)+(q/d|0)+ot*C,T[W]=x%A;return P&&(T=[P].concat(T)),T}function p(T,v,A,q){var x,R;if(A!=q)R=A>q?1:-1;else for(x=R=0;x<A;x++)if(T[x]!=v[x]){R=T[x]>v[x]?1:-1;break}return R}function y(T,v,A,q){for(var x=0;A--;)T[A]-=x,x=T[A]<v[A]?1:0,T[A]=x*q+T[A]-v[A];for(;!T[0]&&T.length>1;T.splice(0,1));}return function(T,v,A,q,x){var R,C,P,W,Q,ot,yt,vt,Nt,pt,at,Mt,ze,nr,ir,le,_t,ee=T.s==v.s?1:-1,Kt=T.c,Rt=v.c;if(!Kt||!Kt[0]||!Rt||!Rt[0])return new k(!T.s||!v.s||(Kt?Rt&&Kt[0]==Rt[0]:!Rt)?NaN:Kt&&Kt[0]==0||!Rt?ee*0:ee/0);for(vt=new k(ee),Nt=vt.c=[],C=T.e-v.e,ee=A+C+1,x||(x=a,C=f(T.e/c)-f(v.e/c),ee=ee/c|0),P=0;Rt[P]==(Kt[P]||0);P++);if(Rt[P]>(Kt[P]||0)&&C--,ee<0)Nt.push(1),W=!0;else{for(nr=Kt.length,le=Rt.length,P=0,ee+=2,Q=i(x/(Rt[0]+1)),Q>1&&(Rt=u(Rt,Q,x),Kt=u(Kt,Q,x),le=Rt.length,nr=Kt.length),ze=le,pt=Kt.slice(0,le),at=pt.length;at<le;pt[at++]=0);_t=Rt.slice(),_t=[0].concat(_t),ir=Rt[0],Rt[1]>=x/2&&ir++;do{if(Q=0,R=p(Rt,pt,le,at),R<0){if(Mt=pt[0],le!=at&&(Mt=Mt*x+(pt[1]||0)),Q=i(Mt/ir),Q>1)for(Q>=x&&(Q=x-1),ot=u(Rt,Q,x),yt=ot.length,at=pt.length;p(ot,pt,yt,at)==1;)Q--,y(ot,le<yt?_t:Rt,yt,x),yt=ot.length,R=1;else Q==0&&(R=Q=1),ot=Rt.slice(),yt=ot.length;if(yt<at&&(ot=[0].concat(ot)),y(pt,ot,at,x),at=pt.length,R==-1)for(;p(Rt,pt,le,at)<1;)Q++,y(pt,le<at?_t:Rt,at,x),at=pt.length}else R===0&&(Q++,pt=[0]);Nt[P++]=Q,pt[0]?pt[at++]=Kt[ze]||0:(pt=[Kt[ze]],at=1)}while((ze++<nr||pt[0]!=null)&&ee--);W=pt[0]!=null,Nt[0]||Nt.splice(0,1)}if(x==a){for(P=1,ee=Nt[0];ee>=10;ee/=10,P++);ut(vt,A+(vt.e=P+C*c-1)+1,q,W)}else vt.e=C,vt.r=+W;return vt}}();function m(u,p,y,T){var v,A,q,x,R;if(y==null?y=rt:F(y,0,8),!u.c)return u.toString();if(v=u.c[0],q=u.e,p==null)R=O(u.c),R=T==1||T==2&&(q<=b||q>=B)?S(R,q):K(R,q,"0");else if(u=ut(new k(u),p,y),A=u.e,R=O(u.c),x=R.length,T==1||T==2&&(p<=A||A<=b)){for(;x<p;R+="0",x++);R=S(R,A)}else if(p-=q,R=K(R,A,"0"),A+1>x){if(--p>0)for(R+=".";p--;R+="0");}else if(p+=A-x,p>0)for(A+1==x&&(R+=".");p--;R+="0");return u.s<0&&v?"-"+R:R}function tt(u,p){for(var y,T,v=1,A=new k(u[0]);v<u.length;v++)T=new k(u[v]),(!T.s||(y=N(A,T))===p||y===0&&A.s===p)&&(A=T);return A}function nt(u,p,y){for(var T=1,v=p.length;!p[--v];p.pop());for(v=p[0];v>=10;v/=10,T++);return(y=T+y*c-1)>U?u.c=u.e=null:y<V?u.c=[u.e=0]:(u.e=y,u.c=p),u}Y=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,p=/^([^.]+)\.$/,y=/^\.([^.]+)$/,T=/^-?(Infinity|NaN)$/,v=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(A,q,x,R){var C,P=x?q:q.replace(v,"");if(T.test(P))A.s=isNaN(P)?null:P<0?-1:1;else{if(!x&&(P=P.replace(u,function(W,Q,ot){return C=(ot=ot.toLowerCase())=="x"?16:ot=="b"?2:8,!R||R==C?Q:W}),R&&(C=R,P=P.replace(p,"$1").replace(y,"0.$1")),q!=P))return new k(P,C);if(k.DEBUG)throw Error(s+"Not a"+(R?" base "+R:"")+" number: "+q);A.s=null}A.c=A.e=null}}();function ut(u,p,y,T){var v,A,q,x,R,C,P,W=u.c,Q=h;if(W){t:{for(v=1,x=W[0];x>=10;x/=10,v++);if(A=p-v,A<0)A+=c,q=p,R=W[C=0],P=i(R/Q[v-q-1]%10);else if(C=n((A+1)/c),C>=W.length)if(T){for(;W.length<=C;W.push(0));R=P=0,v=1,A%=c,q=A-c+1}else break t;else{for(R=x=W[C],v=1;x>=10;x/=10,v++);A%=c,q=A-c+v,P=q<0?0:i(R/Q[v-q-1]%10)}if(T=T||p<0||W[C+1]!=null||(q<0?R:R%Q[v-q-1]),T=y<4?(P||T)&&(y==0||y==(u.s<0?3:2)):P>5||P==5&&(y==4||T||y==6&&(A>0?q>0?R/Q[v-q]:0:W[C-1])%10&1||y==(u.s<0?8:7)),p<1||!W[0])return W.length=0,T?(p-=u.e+1,W[0]=Q[(c-p%c)%c],u.e=-p||0):W[0]=u.e=0,u;if(A==0?(W.length=C,x=1,C--):(W.length=C+1,x=Q[c-A],W[C]=q>0?i(R/Q[v-q]%Q[q])*x:0),T)for(;;)if(C==0){for(A=1,q=W[0];q>=10;q/=10,A++);for(q=W[0]+=x,x=1;q>=10;q/=10,x++);A!=x&&(u.e++,W[0]==a&&(W[0]=1));break}else{if(W[C]+=x,W[C]!=a)break;W[C--]=0,x=1}for(A=W.length;W[--A]===0;W.pop());}u.e>U?u.c=u.e=null:u.e<V&&(u.c=[u.e=0])}return u}function L(u){var p,y=u.e;return y===null?u.toString():(p=O(u.c),p=y<=b||y>=B?S(p,y):K(p,y,"0"),u.s<0?"-"+p:p)}return M.absoluteValue=M.abs=function(){var u=new k(this);return u.s<0&&(u.s=1),u},M.comparedTo=function(u,p){return N(this,new k(u,p))},M.decimalPlaces=M.dp=function(u,p){var y,T,v,A=this;if(u!=null)return F(u,0,g),p==null?p=rt:F(p,0,8),ut(new k(A),u+A.e+1,p);if(!(y=A.c))return null;if(T=((v=y.length-1)-f(this.e/c))*c,v=y[v])for(;v%10==0;v/=10,T--);return T<0&&(T=0),T},M.dividedBy=M.div=function(u,p){return $(this,new k(u,p),et,rt)},M.dividedToIntegerBy=M.idiv=function(u,p){return $(this,new k(u,p),0,1)},M.exponentiatedBy=M.pow=function(u,p){var y,T,v,A,q,x,R,C,P,W=this;if(u=new k(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+L(u));if(p!=null&&(p=new k(p)),x=u.e>14,!W.c||!W.c[0]||W.c[0]==1&&!W.e&&W.c.length==1||!u.c||!u.c[0])return P=new k(Math.pow(+L(W),x?u.s*(2-j(u)):+L(u))),p?P.mod(p):P;if(R=u.s<0,p){if(p.c?!p.c[0]:!p.s)return new k(NaN);T=!R&&W.isInteger()&&p.isInteger(),T&&(W=W.mod(p))}else{if(u.e>9&&(W.e>0||W.e<-1||(W.e==0?W.c[0]>1||x&&W.c[1]>=24e7:W.c[0]<8e13||x&&W.c[0]<=9999975e7)))return A=W.s<0&&j(u)?-0:0,W.e>-1&&(A=1/A),new k(R?1/A:A);J&&(A=n(J/c+2))}for(x?(y=new k(.5),R&&(u.s=1),C=j(u)):(v=Math.abs(+L(u)),C=v%2),P=new k(it);;){if(C){if(P=P.times(W),!P.c)break;A?P.c.length>A&&(P.c.length=A):T&&(P=P.mod(p))}if(v){if(v=i(v/2),v===0)break;C=v%2}else if(u=u.times(y),ut(u,u.e+1,1),u.e>14)C=j(u);else{if(v=+L(u),v===0)break;C=v%2}W=W.times(W),A?W.c&&W.c.length>A&&(W.c.length=A):T&&(W=W.mod(p))}return T?P:(R&&(P=it.div(P)),p?P.mod(p):A?ut(P,J,rt,q):P)},M.integerValue=function(u){var p=new k(this);return u==null?u=rt:F(u,0,8),ut(p,p.e+1,u)},M.isEqualTo=M.eq=function(u,p){return N(this,new k(u,p))===0},M.isFinite=function(){return!!this.c},M.isGreaterThan=M.gt=function(u,p){return N(this,new k(u,p))>0},M.isGreaterThanOrEqualTo=M.gte=function(u,p){return(p=N(this,new k(u,p)))===1||p===0},M.isInteger=function(){return!!this.c&&f(this.e/c)>this.c.length-2},M.isLessThan=M.lt=function(u,p){return N(this,new k(u,p))<0},M.isLessThanOrEqualTo=M.lte=function(u,p){return(p=N(this,new k(u,p)))===-1||p===0},M.isNaN=function(){return!this.s},M.isNegative=function(){return this.s<0},M.isPositive=function(){return this.s>0},M.isZero=function(){return!!this.c&&this.c[0]==0},M.minus=function(u,p){var y,T,v,A,q=this,x=q.s;if(u=new k(u,p),p=u.s,!x||!p)return new k(NaN);if(x!=p)return u.s=-p,q.plus(u);var R=q.e/c,C=u.e/c,P=q.c,W=u.c;if(!R||!C){if(!P||!W)return P?(u.s=-p,u):new k(W?q:NaN);if(!P[0]||!W[0])return W[0]?(u.s=-p,u):new k(P[0]?q:rt==3?-0:0)}if(R=f(R),C=f(C),P=P.slice(),x=R-C){for((A=x<0)?(x=-x,v=P):(C=R,v=W),v.reverse(),p=x;p--;v.push(0));v.reverse()}else for(T=(A=(x=P.length)<(p=W.length))?x:p,x=p=0;p<T;p++)if(P[p]!=W[p]){A=P[p]<W[p];break}if(A&&(v=P,P=W,W=v,u.s=-u.s),p=(T=W.length)-(y=P.length),p>0)for(;p--;P[y++]=0);for(p=a-1;T>x;){if(P[--T]<W[T]){for(y=T;y&&!P[--y];P[y]=p);--P[y],P[T]+=a}P[T]-=W[T]}for(;P[0]==0;P.splice(0,1),--C);return P[0]?nt(u,P,C):(u.s=rt==3?-1:1,u.c=[u.e=0],u)},M.modulo=M.mod=function(u,p){var y,T,v=this;return u=new k(u,p),!v.c||!u.s||u.c&&!u.c[0]?new k(NaN):!u.c||v.c&&!v.c[0]?new k(v):(G==9?(T=u.s,u.s=1,y=$(v,u,0,3),u.s=T,y.s*=T):y=$(v,u,0,G),u=v.minus(y.times(u)),!u.c[0]&&G==1&&(u.s=v.s),u)},M.multipliedBy=M.times=function(u,p){var y,T,v,A,q,x,R,C,P,W,Q,ot,yt,vt,Nt,pt=this,at=pt.c,Mt=(u=new k(u,p)).c;if(!at||!Mt||!at[0]||!Mt[0])return!pt.s||!u.s||at&&!at[0]&&!Mt||Mt&&!Mt[0]&&!at?u.c=u.e=u.s=null:(u.s*=pt.s,!at||!Mt?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(T=f(pt.e/c)+f(u.e/c),u.s*=pt.s,R=at.length,W=Mt.length,R<W&&(yt=at,at=Mt,Mt=yt,v=R,R=W,W=v),v=R+W,yt=[];v--;yt.push(0));for(vt=a,Nt=d,v=W;--v>=0;){for(y=0,Q=Mt[v]%Nt,ot=Mt[v]/Nt|0,q=R,A=v+q;A>v;)C=at[--q]%Nt,P=at[q]/Nt|0,x=ot*C+P*Q,C=Q*C+x%Nt*Nt+yt[A]+y,y=(C/vt|0)+(x/Nt|0)+ot*P,yt[A--]=C%vt;yt[A]=y}return y?++T:yt.splice(0,1),nt(u,yt,T)},M.negated=function(){var u=new k(this);return u.s=-u.s||null,u},M.plus=function(u,p){var y,T=this,v=T.s;if(u=new k(u,p),p=u.s,!v||!p)return new k(NaN);if(v!=p)return u.s=-p,T.minus(u);var A=T.e/c,q=u.e/c,x=T.c,R=u.c;if(!A||!q){if(!x||!R)return new k(v/0);if(!x[0]||!R[0])return R[0]?u:new k(x[0]?T:v*0)}if(A=f(A),q=f(q),x=x.slice(),v=A-q){for(v>0?(q=A,y=R):(v=-v,y=x),y.reverse();v--;y.push(0));y.reverse()}for(v=x.length,p=R.length,v-p<0&&(y=R,R=x,x=y,p=v),v=0;p;)v=(x[--p]=x[p]+R[p]+v)/a|0,x[p]=a===x[p]?0:x[p]%a;return v&&(x=[v].concat(x),++q),nt(u,x,q)},M.precision=M.sd=function(u,p){var y,T,v,A=this;if(u!=null&&u!==!!u)return F(u,1,g),p==null?p=rt:F(p,0,8),ut(new k(A),u,p);if(!(y=A.c))return null;if(v=y.length-1,T=v*c+1,v=y[v]){for(;v%10==0;v/=10,T--);for(v=y[0];v>=10;v/=10,T++);}return u&&A.e+1>T&&(T=A.e+1),T},M.shiftedBy=function(u){return F(u,-l,l),this.times("1e"+u)},M.squareRoot=M.sqrt=function(){var u,p,y,T,v,A=this,q=A.c,x=A.s,R=A.e,C=et+4,P=new k("0.5");if(x!==1||!q||!q[0])return new k(!x||x<0&&(!q||q[0])?NaN:q?A:1/0);if(x=Math.sqrt(+L(A)),x==0||x==1/0?(p=O(q),(p.length+R)%2==0&&(p+="0"),x=Math.sqrt(+p),R=f((R+1)/2)-(R<0||R%2),x==1/0?p="5e"+R:(p=x.toExponential(),p=p.slice(0,p.indexOf("e")+1)+R),y=new k(p)):y=new k(x+""),y.c[0]){for(R=y.e,x=R+C,x<3&&(x=0);;)if(v=y,y=P.times(v.plus($(A,v,C,1))),O(v.c).slice(0,x)===(p=O(y.c)).slice(0,x))if(y.e<R&&--x,p=p.slice(x-3,x+1),p=="9999"||!T&&p=="4999"){if(!T&&(ut(v,v.e+et+2,0),v.times(v).eq(A))){y=v;break}C+=4,x+=4,T=1}else{(!+p||!+p.slice(1)&&p.charAt(0)=="5")&&(ut(y,y.e+et+2,1),u=!y.times(y).eq(A));break}}return ut(y,y.e+et+1,rt,u)},M.toExponential=function(u,p){return u!=null&&(F(u,0,g),u++),m(this,u,p,1)},M.toFixed=function(u,p){return u!=null&&(F(u,0,g),u=u+this.e+1),m(this,u,p)},M.toFormat=function(u,p,y){var T,v=this;if(y==null)u!=null&&p&&typeof p=="object"?(y=p,p=null):u&&typeof u=="object"?(y=u,u=p=null):y=lt;else if(typeof y!="object")throw Error(s+"Argument not an object: "+y);if(T=v.toFixed(u,p),v.c){var A,q=T.split("."),x=+y.groupSize,R=+y.secondaryGroupSize,C=y.groupSeparator||"",P=q[0],W=q[1],Q=v.s<0,ot=Q?P.slice(1):P,yt=ot.length;if(R&&(A=x,x=R,R=A,yt-=A),x>0&&yt>0){for(A=yt%x||x,P=ot.substr(0,A);A<yt;A+=x)P+=C+ot.substr(A,x);R>0&&(P+=C+ot.slice(A)),Q&&(P="-"+P)}T=W?P+(y.decimalSeparator||"")+((R=+y.fractionGroupSize)?W.replace(new RegExp("\\d{"+R+"}\\B","g"),"$&"+(y.fractionGroupSeparator||"")):W):P}return(y.prefix||"")+T+(y.suffix||"")},M.toFraction=function(u){var p,y,T,v,A,q,x,R,C,P,W,Q,ot=this,yt=ot.c;if(u!=null&&(x=new k(u),!x.isInteger()&&(x.c||x.s!==1)||x.lt(it)))throw Error(s+"Argument "+(x.isInteger()?"out of range: ":"not an integer: ")+L(x));if(!yt)return new k(ot);for(p=new k(it),C=y=new k(it),T=R=new k(it),Q=O(yt),A=p.e=Q.length-ot.e-1,p.c[0]=h[(q=A%c)<0?c+q:q],u=!u||x.comparedTo(p)>0?A>0?p:C:x,q=U,U=1/0,x=new k(Q),R.c[0]=0;P=$(x,p,0,1),v=y.plus(P.times(T)),v.comparedTo(u)!=1;)y=T,T=v,C=R.plus(P.times(v=C)),R=v,p=x.minus(P.times(v=p)),x=v;return v=$(u.minus(y),T,0,1),R=R.plus(v.times(C)),y=y.plus(v.times(T)),R.s=C.s=ot.s,A=A*2,W=$(C,T,A,rt).minus(ot).abs().comparedTo($(R,y,A,rt).minus(ot).abs())<1?[C,T]:[R,y],U=q,W},M.toNumber=function(){return+L(this)},M.toPrecision=function(u,p){return u!=null&&F(u,1,g),m(this,u,p,2)},M.toString=function(u){var p,y=this,T=y.s,v=y.e;return v===null?T?(p="Infinity",T<0&&(p="-"+p)):p="NaN":(u==null?p=v<=b||v>=B?S(O(y.c),v):K(O(y.c),v,"0"):u===10&&Z?(y=ut(new k(y),et+v+1,rt),p=K(O(y.c),y.e,"0")):(F(u,2,ct.length,"Base"),p=z(K(O(y.c),v,"0"),10,u,T,!0)),T<0&&y.c[0]&&(p="-"+p)),p},M.valueOf=M.toJSON=function(){return L(this)},M._isBigNumber=!0,_!=null&&k.set(_),k}function f(_){var $=_|0;return _>0||_===$?$:$-1}function O(_){for(var $,z,Y=1,M=_.length,it=_[0]+"";Y<M;){for($=_[Y++]+"",z=c-$.length;z--;$="0"+$);it+=$}for(M=it.length;it.charCodeAt(--M)===48;);return it.slice(0,M+1||1)}function N(_,$){var z,Y,M=_.c,it=$.c,et=_.s,rt=$.s,b=_.e,B=$.e;if(!et||!rt)return null;if(z=M&&!M[0],Y=it&&!it[0],z||Y)return z?Y?0:-rt:et;if(et!=rt)return et;if(z=et<0,Y=b==B,!M||!it)return Y?0:!M^z?1:-1;if(!Y)return b>B^z?1:-1;for(rt=(b=M.length)<(B=it.length)?b:B,et=0;et<rt;et++)if(M[et]!=it[et])return M[et]>it[et]^z?1:-1;return b==B?0:b>B^z?1:-1}function F(_,$,z,Y){if(_<$||_>z||_!==i(_))throw Error(s+(Y||"Argument")+(typeof _=="number"?_<$||_>z?" out of range: ":" not an integer: ":" not a primitive number: ")+String(_))}function j(_){var $=_.c.length-1;return f(_.e/c)==$&&_.c[$]%2!=0}function S(_,$){return(_.length>1?_.charAt(0)+"."+_.slice(1):_)+($<0?"e":"e+")+$}function K(_,$,z){var Y,M;if($<0){for(M=z+".";++$;M+=z);_=M+_}else if(Y=_.length,++$>Y){for(M=z,$-=Y;--$;M+=z);_+=M}else $<Y&&(_=_.slice(0,$)+"."+_.slice($));return _}t=w(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd?define(function(){return t}):typeof fs<"u"&&fs.exports?fs.exports=t:(e||(e=typeof self<"u"&&self?self:window),e.BigNumber=t)})(bf)});var _f=Ht((By,xf)=>{xf.exports=function(t,r,n){var i=new t.Uint8Array(n),s=r.pushInt,o=r.pushInt32,a=r.pushInt32Neg,c=r.pushInt64,l=r.pushInt64Neg,h=r.pushFloat,d=r.pushFloatSingle,g=r.pushFloatDouble,w=r.pushTrue,f=r.pushFalse,O=r.pushUndefined,N=r.pushNull,F=r.pushInfinity,j=r.pushInfinityNeg,S=r.pushNaN,K=r.pushNaNNeg,_=r.pushArrayStart,$=r.pushArrayStartFixed,z=r.pushArrayStartFixed32,Y=r.pushArrayStartFixed64,M=r.pushObjectStart,it=r.pushObjectStartFixed,et=r.pushObjectStartFixed32,rt=r.pushObjectStartFixed64,b=r.pushByteString,B=r.pushByteStringStart,V=r.pushUtf8String,U=r.pushUtf8StringStart,I=r.pushSimpleUnassigned,G=r.pushTagStart,J=r.pushTagStart4,lt=r.pushTagStart8,ct=r.pushTagUnassigned,Z=r.pushBreak,k=t.Math.pow,m=0,tt=0,nt=0;function ut(E){for(E=E|0,m=0,tt=E;(m|0)<(tt|0)&&(nt=Kl[i[m]&255](i[m]|0)|0,!((nt|0)>0)););return nt|0}function L(E){return E=E|0,((m|0)+(E|0)|0)<(tt|0)?0:1}function u(E){return E=E|0,i[E|0]<<8|i[E+1|0]|0}function p(E){return E=E|0,i[E|0]<<24|i[E+1|0]<<16|i[E+2|0]<<8|i[E+3|0]|0}function y(E){return E=E|0,s(E|0),m=m+1|0,0}function T(E){return E=E|0,L(1)|0?1:(s(i[m+1|0]|0),m=m+2|0,0)}function v(E){return E=E|0,L(2)|0?1:(s(u(m+1|0)|0),m=m+3|0,0)}function A(E){return E=E|0,L(4)|0?1:(o(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function q(E){return E=E|0,L(8)|0?1:(c(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function x(E){return E=E|0,s(-1-(E-32|0)|0),m=m+1|0,0}function R(E){return E=E|0,L(1)|0?1:(s(-1-(i[m+1|0]|0)|0),m=m+2|0,0)}function C(E){E=E|0;var bt=0;return L(2)|0?1:(bt=u(m+1|0)|0,s(-1-(bt|0)|0),m=m+3|0,0)}function P(E){return E=E|0,L(4)|0?1:(a(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function W(E){return E=E|0,L(8)|0?1:(l(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function Q(E){E=E|0;var bt=0,xt=0,gt=0;return gt=E-64|0,L(gt|0)|0?1:(bt=m+1|0,xt=(m+1|0)+(gt|0)|0,b(bt|0,xt|0),m=xt|0,0)}function ot(E){E=E|0;var bt=0,xt=0,gt=0;return L(1)|0||(gt=i[m+1|0]|0,bt=m+2|0,xt=(m+2|0)+(gt|0)|0,L(gt+1|0)|0)?1:(b(bt|0,xt|0),m=xt|0,0)}function yt(E){E=E|0;var bt=0,xt=0,gt=0;return L(2)|0||(gt=u(m+1|0)|0,bt=m+3|0,xt=(m+3|0)+(gt|0)|0,L(gt+2|0)|0)?1:(b(bt|0,xt|0),m=xt|0,0)}function vt(E){E=E|0;var bt=0,xt=0,gt=0;return L(4)|0||(gt=p(m+1|0)|0,bt=m+5|0,xt=(m+5|0)+(gt|0)|0,L(gt+4|0)|0)?1:(b(bt|0,xt|0),m=xt|0,0)}function Nt(E){return E=E|0,1}function pt(E){return E=E|0,B(),m=m+1|0,0}function at(E){E=E|0;var bt=0,xt=0,gt=0;return gt=E-96|0,L(gt|0)|0?1:(bt=m+1|0,xt=(m+1|0)+(gt|0)|0,V(bt|0,xt|0),m=xt|0,0)}function Mt(E){E=E|0;var bt=0,xt=0,gt=0;return L(1)|0||(gt=i[m+1|0]|0,bt=m+2|0,xt=(m+2|0)+(gt|0)|0,L(gt+1|0)|0)?1:(V(bt|0,xt|0),m=xt|0,0)}function ze(E){E=E|0;var bt=0,xt=0,gt=0;return L(2)|0||(gt=u(m+1|0)|0,bt=m+3|0,xt=(m+3|0)+(gt|0)|0,L(gt+2|0)|0)?1:(V(bt|0,xt|0),m=xt|0,0)}function nr(E){E=E|0;var bt=0,xt=0,gt=0;return L(4)|0||(gt=p(m+1|0)|0,bt=m+5|0,xt=(m+5|0)+(gt|0)|0,L(gt+4|0)|0)?1:(V(bt|0,xt|0),m=xt|0,0)}function ir(E){return E=E|0,1}function le(E){return E=E|0,U(),m=m+1|0,0}function _t(E){return E=E|0,$(E-128|0),m=m+1|0,0}function ee(E){return E=E|0,L(1)|0?1:($(i[m+1|0]|0),m=m+2|0,0)}function Kt(E){return E=E|0,L(2)|0?1:($(u(m+1|0)|0),m=m+3|0,0)}function Rt(E){return E=E|0,L(4)|0?1:(z(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function Eo(E){return E=E|0,L(8)|0?1:(Y(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function vo(E){return E=E|0,_(),m=m+1|0,0}function Ot(E){E=E|0;var bt=0;return bt=E-160|0,L(bt|0)|0?1:(it(bt|0),m=m+1|0,0)}function Bo(E){return E=E|0,L(1)|0?1:(it(i[m+1|0]|0),m=m+2|0,0)}function Ao(E){return E=E|0,L(2)|0?1:(it(u(m+1|0)|0),m=m+3|0,0)}function To(E){return E=E|0,L(4)|0?1:(et(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function So(E){return E=E|0,L(8)|0?1:(rt(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function No(E){return E=E|0,M(),m=m+1|0,0}function gr(E){return E=E|0,G(E-192|0|0),m=m+1|0,0}function hm(E){return E=E|0,G(E|0),m=m+1|0,0}function dm(E){return E=E|0,G(E|0),m=m+1|0,0}function pm(E){return E=E|0,G(E|0),m=m+1|0,0}function mm(E){return E=E|0,G(E|0),m=m+1|0,0}function Jt(E){return E=E|0,G(E-192|0|0),m=m+1|0,0}function ym(E){return E=E|0,G(E|0),m=m+1|0,0}function gm(E){return E=E|0,G(E|0),m=m+1|0,0}function wm(E){return E=E|0,G(E|0),m=m+1|0,0}function Il(E){return E=E|0,L(1)|0?1:(G(i[m+1|0]|0),m=m+2|0,0)}function Pl(E){return E=E|0,L(2)|0?1:(G(u(m+1|0)|0),m=m+3|0,0)}function kl(E){return E=E|0,L(4)|0?1:(J(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function Ml(E){return E=E|0,L(8)|0?1:(lt(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function jt(E){return E=E|0,I((E|0)-224|0),m=m+1|0,0}function Cl(E){return E=E|0,f(),m=m+1|0,0}function ql(E){return E=E|0,w(),m=m+1|0,0}function Vl(E){return E=E|0,N(),m=m+1|0,0}function $l(E){return E=E|0,O(),m=m+1|0,0}function jl(E){return E=E|0,L(1)|0?1:(I(i[m+1|0]|0),m=m+2|0,0)}function Hl(E){E=E|0;var bt=0,xt=0,gt=1,Ri=0,Cn=0,bm=0;return L(2)|0?1:(bt=i[m+1|0]|0,xt=i[m+2|0]|0,(bt|0)&128&&(gt=-1),Ri=+(((bt|0)&124)>>2),Cn=+(((bt|0)&3)<<8|xt),+Ri==0?h(+(+gt*5960464477539063e-23*+Cn)):+Ri==31?+gt==1?+Cn>0?S():F():+Cn>0?K():j():h(+(+gt*k(2,+(+Ri-25))*+(1024+Cn))),m=m+3|0,0)}function Gl(E){return E=E|0,L(4)|0?1:(d(i[m+1|0]|0,i[m+2|0]|0,i[m+3|0]|0,i[m+4|0]|0),m=m+5|0,0)}function zl(E){return E=E|0,L(8)|0?1:(g(i[m+1|0]|0,i[m+2|0]|0,i[m+3|0]|0,i[m+4|0]|0,i[m+5|0]|0,i[m+6|0]|0,i[m+7|0]|0,i[m+8|0]|0),m=m+9|0,0)}function Tt(E){return E=E|0,1}function Yl(E){return E=E|0,Z(),m=m+1|0,0}var Kl=[y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,T,v,A,q,Tt,Tt,Tt,Tt,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,R,C,P,W,Tt,Tt,Tt,Tt,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,ot,yt,vt,Nt,Tt,Tt,Tt,pt,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,Mt,ze,nr,ir,Tt,Tt,Tt,le,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,ee,Kt,Rt,Eo,Tt,Tt,Tt,vo,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Ot,Bo,Ao,To,So,Tt,Tt,Tt,No,gr,gr,gr,gr,gr,gr,Jt,Jt,Jt,Jt,Jt,Jt,Jt,Jt,Jt,Jt,Jt,Jt,Jt,Jt,Jt,Jt,Jt,Jt,Il,Pl,kl,Ml,Tt,Tt,Tt,Tt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,Cl,ql,Vl,$l,jl,Hl,Gl,zl,Tt,Tt,Tt,Yl];return{parse:ut}}});var Ln=Ht(be=>{"use strict";var ca=Qn().BigNumber;be.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};be.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};be.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};be.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};be.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};be.SHIFT32=Math.pow(2,32);be.SHIFT16=Math.pow(2,16);be.MAX_SAFE_HIGH=2097151;be.NEG_ONE=new ca(-1);be.TEN=new ca(10);be.TWO=new ca(2);be.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var ls=Ht(Ae=>{"use strict";var{Buffer:Ed}=Jn(),vf=Qn().BigNumber,Bf=Ln(),Ef=Bf.SHIFT32,vd=Bf.SHIFT16,Bd=2097151;Ae.parseHalf=function(t){var r,n,i;return i=t[0]&128?-1:1,r=(t[0]&124)>>2,n=(t[0]&3)<<8|t[1],r?r===31?i*(n?NaN:1/0):i*Math.pow(2,r-25)*(1024+n):i*5960464477539063e-23*n};function Ad(e){return e<16?"0"+e.toString(16):e.toString(16)}Ae.arrayBufferToBignumber=function(e){let t=e.byteLength,r="";for(let n=0;n<t;n++)r+=Ad(e[n]);return new vf(r,16)};Ae.buildMap=e=>{let t=new Map,r=Object.keys(e),n=r.length;for(let i=0;i<n;i++)t.set(r[i],e[r[i]]);return t};Ae.buildInt32=(e,t)=>e*vd+t;Ae.buildInt64=(e,t,r,n)=>{let i=Ae.buildInt32(e,t),s=Ae.buildInt32(r,n);return i>Bd?new vf(i).times(Ef).plus(s):i*Ef+s};Ae.writeHalf=function(t,r){let n=Ed.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if((i&8191)!==0)return!1;var s=i>>16&32768;let o=i>>23&255,a=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(a>>13);else if(o>=103&&o<113){if(a&(1<<126-o)-1)return!1;s+=a+8388608>>126-o}else return!1;return t.writeUInt16BE(s,0),!0};Ae.keySorter=function(e,t){var r=e[0].byteLength,n=t[0].byteLength;return r>n?1:n>r?-1:e[0].compare(t[0])};Ae.isNegativeZero=e=>e===0&&1/e<0;Ae.nextPowerOf2=e=>{let t=0;if(e&&!(e&e-1))return e;for(;e!==0;)e>>=1,t+=1;return 1<<t}});var ha=Ht((Sy,Af)=>{"use strict";var la=Ln(),Td=la.MT,hs=la.SIMPLE,ua=la.SYMS,fa=class e{constructor(t){if(typeof t!="number")throw new Error("Invalid Simple type: "+typeof t);if(t<0||t>255||(t|0)!==t)throw new Error("value must be a small positive integer: "+t);this.value=t}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(t){return t._pushInt(this.value,Td.SIMPLE_FLOAT)}static isSimple(t){return t instanceof e}static decode(t,r){switch(r==null&&(r=!0),t){case hs.FALSE:return!1;case hs.TRUE:return!0;case hs.NULL:return r?null:ua.NULL;case hs.UNDEFINED:return r?void 0:ua.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return ua.BREAK;default:return new e(t)}}};Af.exports=fa});var pa=Ht((Ny,Tf)=>{"use strict";var da=class e{constructor(t,r,n){if(this.tag=t,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(t){return t._pushTag(this.tag),t.pushAny(this.value)}convert(t){var r,n;if(n=t?.[this.tag],typeof n!="function"&&(n=e["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(e,this.value)}catch(i){return r=i,this.err=r,this}}};Tf.exports=da});var ga=Ht((Ry,Nf)=>{"use strict";var Sf=self.location?self.location.protocol+"//"+self.location.host:"",ma=self.URL,ya=class{constructor(t="",r=Sf){this.super=new ma(t,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}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(t){this.super.hash=t}set host(t){this.super.host=t}set hostname(t){this.super.hostname=t}set href(t){this.super.href=t}set origin(t){this.super.origin=t}set password(t){this.super.password=t}set pathname(t){this.super.pathname=t}set port(t){this.super.port=t}set protocol(t){this.super.protocol=t}set search(t){this.super.search=t}set searchParams(t){this.super.searchParams=t}set username(t){this.super.username=t}createObjectURL(t){return this.super.createObjectURL(t)}revokeObjectURL(t){this.super.revokeObjectURL(t)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function Sd(e){if(typeof e=="string")return new ma(e).toString();if(!(e instanceof ma)){let t=e.username&&e.password?`${e.username}:${e.password}@`:"",r=e.auth?e.auth+"@":"",n=e.port?":"+e.port:"",i=e.protocol?e.protocol+"//":"",s=e.host||"",o=e.hostname||"",a=e.search||(e.query?"?"+e.query:""),c=e.hash||"",l=e.pathname||"",h=e.path||l+a;return`${i}${t||r}${s||o+n}${h}${c}`}}Nf.exports={URLWithLegacySupport:ya,URLSearchParams:self.URLSearchParams,defaultBase:Sf,format:Sd}});var Ff=Ht((Oy,Of)=>{"use strict";var{URLWithLegacySupport:Rf,format:Nd}=ga();Of.exports=(e,t={},r={},n)=>{let i=t.protocol?t.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new Rf(e)}catch{s={}}let o=Object.assign({},t,{protocol:i||s.protocol,host:t.host||s.host});return new Rf(e,Nd(o)).toString()}});var wa=Ht((Fy,Uf)=>{"use strict";var{URLWithLegacySupport:Rd,format:Od,URLSearchParams:Fd,defaultBase:Ud}=ga(),Id=Ff();Uf.exports={URL:Rd,URLSearchParams:Fd,format:Od,relative:Id,defaultBase:Ud}});var ba=Ht((Uy,Pf)=>{"use strict";var{Buffer:gn}=Jn(),If=Co(),Pd=Qn().BigNumber,kd=_f(),ae=ls(),At=Ln(),Md=ha(),Cd=pa(),{URL:qd}=wa(),Dn=class e{constructor(t){t=t||{},!t.size||t.size<65536?t.size=65536:t.size=ae.nextPowerOf2(t.size),this._heap=new ArrayBuffer(t.size),this._heap8=new Uint8Array(this._heap),this._buffer=gn.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>ae.arrayBufferToBignumber(r),3:r=>At.NEG_ONE.minus(ae.arrayBufferToBignumber(r)),4:r=>At.TEN.pow(r[0]).times(r[1]),5:r=>At.TWO.pow(r[0]).times(r[1]),32:r=>new qd(r),35:r=>new RegExp(r)},t.tags),this.parser=kd(globalThis,{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 t=this._parents.pop();if(t.length>0)throw new Error(`Missing ${t.length} elements`);switch(t.type){case At.PARENT.TAG:this._push(this.createTag(t.ref[0],t.ref[1]));break;case At.PARENT.BYTE_STRING:this._push(this.createByteString(t.ref,t.length));break;case At.PARENT.UTF8_STRING:this._push(this.createUtf8String(t.ref,t.length));break;case At.PARENT.MAP:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(t.ref,t.length));break;case At.PARENT.OBJECT:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(t.ref,t.length));break;case At.PARENT.ARRAY:this._push(this.createArray(t.ref,t.length));break;default:break}this._currentParent&&this._currentParent.type===At.PARENT.TAG&&this._dec()}_dec(){let t=this._currentParent;t.length<0||(t.length--,t.length===0&&this._closeParent())}_push(t,r){let n=this._currentParent;switch(n.values++,n.type){case At.PARENT.ARRAY:case At.PARENT.BYTE_STRING:case At.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=t:this._ref.push(t),this._dec();break;case At.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=t,n.tmpKey=null,this._dec()):(n.tmpKey=t,typeof n.tmpKey!="string"&&(n.type=At.PARENT.MAP,n.ref=ae.buildMap(n.ref)));break;case At.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,t),n.tmpKey=null,this._dec()):n.tmpKey=t;break;case At.PARENT.TAG:this._ref.push(t),r||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(t,r,n){this._parents[this._depth]={type:r,length:n,ref:t,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:At.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(t,r){let n=this._knownTags[t];return n?n(r):new Cd(t,r)}createMap(t,r){return t}createObject(t,r){return t}createArray(t,r){return t}createByteString(t,r){return gn.concat(t)}createByteStringFromHeap(t,r){return t===r?gn.alloc(0):gn.from(this._heap.slice(t,r))}createInt(t){return t}createInt32(t,r){return ae.buildInt32(t,r)}createInt64(t,r,n,i){return ae.buildInt64(t,r,n,i)}createFloat(t){return t}createFloatSingle(t,r,n,i){return If.read([t,r,n,i],0,!1,23,4)}createFloatDouble(t,r,n,i,s,o,a,c){return If.read([t,r,n,i,s,o,a,c],0,!1,52,8)}createInt32Neg(t,r){return-1-ae.buildInt32(t,r)}createInt64Neg(t,r,n,i){let s=ae.buildInt32(t,r),o=ae.buildInt32(n,i);return s>At.MAX_SAFE_HIGH?At.NEG_ONE.minus(new Pd(s).times(At.SHIFT32).plus(o)):-1-(s*At.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(t,r){return t.join("")}createUtf8StringFromHeap(t,r){return t===r?"":this._buffer.toString("utf8",t,r)}createSimpleUnassigned(t){return new Md(t)}pushInt(t){this._push(this.createInt(t))}pushInt32(t,r){this._push(this.createInt32(t,r))}pushInt64(t,r,n,i){this._push(this.createInt64(t,r,n,i))}pushFloat(t){this._push(this.createFloat(t))}pushFloatSingle(t,r,n,i){this._push(this.createFloatSingle(t,r,n,i))}pushFloatDouble(t,r,n,i,s,o,a,c){this._push(this.createFloatDouble(t,r,n,i,s,o,a,c))}pushInt32Neg(t,r){this._push(this.createInt32Neg(t,r))}pushInt64Neg(t,r,n,i){this._push(this.createInt64Neg(t,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([],At.PARENT.ARRAY,-1)}pushArrayStartFixed(t){this._createArrayStartFixed(t)}pushArrayStartFixed32(t,r){let n=ae.buildInt32(t,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(t,r,n,i){let s=ae.buildInt64(t,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(t){this._createObjectStartFixed(t)}pushObjectStartFixed32(t,r){let n=ae.buildInt32(t,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(t,r,n,i){let s=ae.buildInt64(t,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:At.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(t,r){this._push(this.createByteStringFromHeap(t,r))}pushUtf8StringStart(){this._parents[this._depth]={type:At.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(t,r){this._push(this.createUtf8StringFromHeap(t,r))}pushSimpleUnassigned(t){this._push(this.createSimpleUnassigned(t))}pushTagStart(t){this._parents[this._depth]={type:At.PARENT.TAG,length:1,ref:[t]}}pushTagStart4(t,r){this.pushTagStart(ae.buildInt32(t,r))}pushTagStart8(t,r,n,i){this.pushTagStart(ae.buildInt64(t,r,n,i))}pushTagUnassigned(t){this._push(this.createTag(t))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(t){if(t===0){this._push(this.createObject({}));return}this._createParent({},At.PARENT.OBJECT,t)}_createArrayStartFixed(t){if(t===0){this._push(this.createArray([]));return}this._createParent(new Array(t),At.PARENT.ARRAY,t)}_decode(t){if(t.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(t);let r=this.parser.parse(t.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(t){return this._decode(t),this._res[0]}decodeAll(t){return this._decode(t),this._res}static decode(t,r){return typeof t=="string"&&(t=gn.from(t,r||"hex")),new e({size:t.length}).decodeFirst(t)}static decodeAll(t,r){return typeof t=="string"&&(t=gn.from(t,r||"hex")),new e({size:t.length}).decodeAll(t)}};Dn.decodeFirst=Dn.decode;Pf.exports=Dn});var Cf=Ht((Iy,Mf)=>{"use strict";var{Buffer:xa}=Jn(),Vd=ba(),$d=ls(),_a=class e extends Vd{createTag(t,r){return`${t}(${r})`}createInt(t){return super.createInt(t).toString()}createInt32(t,r){return super.createInt32(t,r).toString()}createInt64(t,r,n,i){return super.createInt64(t,r,n,i).toString()}createInt32Neg(t,r){return super.createInt32Neg(t,r).toString()}createInt64Neg(t,r,n,i){return super.createInt64Neg(t,r,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(t){let r=super.createFloat(t);return $d.isNegativeZero(t)?"-0_1":`${r}_1`}createFloatSingle(t,r,n,i){return`${super.createFloatSingle(t,r,n,i)}_2`}createFloatDouble(t,r,n,i,s,o,a,c){return`${super.createFloatDouble(t,r,n,i,s,o,a,c)}_3`}createByteString(t,r){let n=t.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(t,r){return`h'${xa.from(super.createByteStringFromHeap(t,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(t){return`simple(${t})`}createArray(t,r){let n=super.createArray(t,r);return r===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(t,r){let n=super.createMap(t),i=Array.from(n.keys()).reduce(kf(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(t,r){let n=super.createObject(t),i=Object.keys(n).reduce(kf(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(t,r){let n=t.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(t,r){return`"${xa.from(super.createUtf8StringFromHeap(t,r)).toString("utf8")}"`}static diagnose(t,r){return typeof t=="string"&&(t=xa.from(t,r||"hex")),new e().decodeFirst(t)}};Mf.exports=_a;function kf(e){return(t,r)=>t?`${t}, ${r}: ${e[r]}`:`${r}: ${e[r]}`}});var Hf=Ht((Py,jf)=>{"use strict";var{Buffer:Qe}=Jn(),{URL:jd}=wa(),va=Qn().BigNumber,Ea=ls(),Wt=Ln(),Ue=Wt.MT,ds=Wt.NUMBYTES,qf=Wt.SHIFT32,Vf=Wt.SYMS,wn=Wt.TAG,Hd=Wt.MT.SIMPLE_FLOAT<<5|Wt.NUMBYTES.TWO,Gd=Wt.MT.SIMPLE_FLOAT<<5|Wt.NUMBYTES.FOUR,zd=Wt.MT.SIMPLE_FLOAT<<5|Wt.NUMBYTES.EIGHT,Yd=Wt.MT.SIMPLE_FLOAT<<5|Wt.SIMPLE.TRUE,Kd=Wt.MT.SIMPLE_FLOAT<<5|Wt.SIMPLE.FALSE,Wd=Wt.MT.SIMPLE_FLOAT<<5|Wt.SIMPLE.UNDEFINED,$f=Wt.MT.SIMPLE_FLOAT<<5|Wt.SIMPLE.NULL,Zd=new va("0x20000000000000"),Xd=Qe.from("f97e00","hex"),Jd=Qe.from("f9fc00","hex"),Qd=Qe.from("f97c00","hex");function Ld(e){return{}.toString.call(e).slice(8,-1)}var Ba=class e{constructor(t){t=t||{},this.streaming=typeof t.stream=="function",this.onData=t.stream,this.semanticTypes=[[jd,this._pushUrl],[va,this._pushBigNumber]];let r=t.genTypes||[],n=r.length;for(let i=0;i<n;i++)this.addSemanticType(r[i][0],r[i][1]);this._reset()}addSemanticType(t,r){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===t){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,o}return this.semanticTypes.push([t,r]),null}push(t){return t&&(this.result[this.offset]=t,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=t.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(t,r,n){return this.result[this.offset]=t,this.resultMethod[this.offset]=r,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(t){return this.pushWrite(t,1,1)}_pushUInt16BE(t){return this.pushWrite(t,2,2)}_pushUInt32BE(t){return this.pushWrite(t,3,4)}_pushDoubleBE(t){return this.pushWrite(t,4,8)}_pushNaN(){return this.push(Xd)}_pushInfinity(t){let r=t<0?Jd:Qd;return this.push(r)}_pushFloat(t){let r=Qe.allocUnsafe(2);if(Ea.writeHalf(r,t)&&Ea.parseHalf(r)===t)return this._pushUInt8(Hd)&&this.push(r);let n=Qe.allocUnsafe(4);return n.writeFloatBE(t,0),n.readFloatBE(0)===t?this._pushUInt8(Gd)&&this.push(n):this._pushUInt8(zd)&&this._pushDoubleBE(t)}_pushInt(t,r,n){let i=r<<5;return t<24?this._pushUInt8(i|t):t<=255?this._pushUInt8(i|ds.ONE)&&this._pushUInt8(t):t<=65535?this._pushUInt8(i|ds.TWO)&&this._pushUInt16BE(t):t<=4294967295?this._pushUInt8(i|ds.FOUR)&&this._pushUInt32BE(t):t<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|ds.EIGHT)&&this._pushUInt32BE(Math.floor(t/qf))&&this._pushUInt32BE(t%qf):r===Ue.NEG_INT?this._pushFloat(n):this._pushFloat(t)}_pushIntNum(t){return t<0?this._pushInt(-t-1,Ue.NEG_INT,t):this._pushInt(t,Ue.POS_INT)}_pushNumber(t){switch(!1){case t===t:return this._pushNaN(t);case isFinite(t):return this._pushInfinity(t);case t%1!==0:return this._pushIntNum(t);default:return this._pushFloat(t)}}_pushString(t){let r=Qe.byteLength(t,"utf8");return this._pushInt(r,Ue.UTF8_STRING)&&this.pushWrite(t,5,r)}_pushBoolean(t){return this._pushUInt8(t?Yd:Kd)}_pushUndefined(t){return this._pushUInt8(Wd)}_pushArray(t,r){let n=r.length;if(!t._pushInt(n,Ue.ARRAY))return!1;for(let i=0;i<n;i++)if(!t.pushAny(r[i]))return!1;return!0}_pushTag(t){return this._pushInt(t,Ue.TAG)}_pushDate(t,r){return t._pushTag(wn.DATE_EPOCH)&&t.pushAny(Math.round(r/1e3))}_pushBuffer(t,r){return t._pushInt(r.length,Ue.BYTE_STRING)&&t.push(r)}_pushNoFilter(t,r){return t._pushBuffer(t,r.slice())}_pushRegexp(t,r){return t._pushTag(wn.REGEXP)&&t.pushAny(r.source)}_pushSet(t,r){if(!t._pushInt(r.size,Ue.ARRAY))return!1;for(let n of r)if(!t.pushAny(n))return!1;return!0}_pushUrl(t,r){return t._pushTag(wn.URI)&&t.pushAny(r.format())}_pushBigint(t){let r=wn.POS_BIGINT;t.isNegative()&&(t=t.negated().minus(1),r=wn.NEG_BIGINT);let n=t.toString(16);n.length%2&&(n="0"+n);let i=Qe.from(n,"hex");return this._pushTag(r)&&this._pushBuffer(this,i)}_pushBigNumber(t,r){if(r.isNaN())return t._pushNaN();if(!r.isFinite())return t._pushInfinity(r.isNegative()?-1/0:1/0);if(r.isInteger())return t._pushBigint(r);if(!(t._pushTag(wn.DECIMAL_FRAC)&&t._pushInt(2,Ue.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new va(10).pow(n));return t._pushIntNum(-n)?i.abs().isLessThan(Zd)?t._pushIntNum(i.toNumber()):t._pushBigint(i):!1}_pushMap(t,r){return t._pushInt(r.size,Ue.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(t){if(!t)return this._pushUInt8($f);for(var r=this.semanticTypes.length,n=0;n<r;n++)if(t instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(t,this,t);var i=t.encodeCBOR;if(typeof i=="function")return i.call(t,this);var s=Object.keys(t),o=s.length;return this._pushInt(o,Ue.MAP)?this._pushRawMap(o,s.map(a=>[a,t[a]])):!1}_pushRawMap(t,r){r=r.map(function(i){return i[0]=e.encode(i[0]),i}).sort(Ea.keySorter);for(var n=0;n<t;n++)if(!this.push(r[n][0])||!this.pushAny(r[n][1]))return!1;return!0}write(t){return this.pushAny(t)}pushAny(t){var r=Ld(t);switch(r){case"Number":return this._pushNumber(t);case"String":return this._pushString(t);case"Boolean":return this._pushBoolean(t);case"Object":return this._pushObject(t);case"Array":return this._pushArray(this,t);case"Uint8Array":return this._pushBuffer(this,Qe.isBuffer(t)?t:Qe.from(t));case"Null":return this._pushUInt8($f);case"Undefined":return this._pushUndefined(t);case"Map":return this._pushMap(this,t);case"Set":return this._pushSet(this,t);case"URL":return this._pushUrl(this,t);case"BigNumber":return this._pushBigNumber(this,t);case"Date":return this._pushDate(this,t);case"RegExp":return this._pushRegexp(this,t);case"Symbol":switch(t){case Vf.NULL:return this._pushObject(null);case Vf.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+t.toString())}default:throw new Error("Unknown type: "+typeof t+", "+(t?t.toString():""))}}finalize(){if(this.offset===0)return null;for(var t=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=r[o];var a=Qe.allocUnsafe(s),c=0,l=0;for(o=0;o<i;o++){switch(l=r[o],n[o]){case 0:t[o].copy(a,c);break;case 1:a.writeUInt8(t[o],c,!0);break;case 2:a.writeUInt16BE(t[o],c,!0);break;case 3:a.writeUInt32BE(t[o],c,!0);break;case 4:a.writeDoubleBE(t[o],c,!0);break;case 5:a.write(t[o],c,l,"utf8");break;default:throw new Error("unkown method")}c+=l}var h=a;return this._reset(),h}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(t){let r=new e;if(!r.pushAny(t))throw new Error("Failed to encode input");return r.finalize()}};jf.exports=Ba});var Aa=Ht(Zt=>{"use strict";Zt.Diagnose=Cf();Zt.Decoder=ba();Zt.Encoder=Hf();Zt.Simple=ha();Zt.Tagged=pa();Zt.decodeAll=Zt.Decoder.decodeAll;Zt.decodeFirst=Zt.Decoder.decodeFirst;Zt.diagnose=Zt.Diagnose.diagnose;Zt.encode=Zt.Encoder.encode;Zt.decode=Zt.Decoder.decode;Zt.leveldb={decode:Zt.Decoder.decodeAll,encode:Zt.Encoder.encode,buffer:!0,name:"cbor"}});function Te(e){return Gn($n.create().update(new Uint8Array(e)).digest())}function ps(e){if(e instanceof Gf.default.Tagged)return ps(e.value);if(typeof e=="string")return zf(e);if(typeof e=="number")return Te(Pt(e));if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return Te(e);if(Array.isArray(e)){let t=e.map(ps);return Te(oe(...t))}else{if(e&&typeof e=="object"&&e._isPrincipal)return Te(e.toUint8Array());if(typeof e=="object"&&e!==null&&typeof e.toHash=="function")return ps(e.toHash());if(typeof e=="object")return ti(e);if(typeof e=="bigint")return Te(Pt(e))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${e}`),{value:e})}function ms(e){return ti(e)}function ti(e){let n=Object.entries(e).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=zf(o),l=ps(a);return[c,l]}).sort(([o],[a])=>Wo(o,a)),i=oe(...n.map(o=>oe(...o)));return Te(i)}var Gf,zf,ei=ht(()=>{Xn();Gf=sn(Aa());Mi();de();zf=e=>{let t=new TextEncoder().encode(e);return Te(t)}});var Gy,Ar,Ta=ht(()=>{we();ei();de();Gy=new TextEncoder().encode(`
14
- ic-request`),Ar=class{getPrincipal(){return dt.anonymous()}async transformRequest(t){return Object.assign(Object.assign({},t),{body:{content:t.body}})}}});var Ra=Ht(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});var Dd=9007199254740992;function ur(e,...t){let r=new Uint8Array(e.byteLength+t.reduce((i,s)=>i+s.byteLength,0));r.set(new Uint8Array(e),0);let n=e.byteLength;for(let i of t)r.set(new Uint8Array(i),n),n+=i.byteLength;return r.buffer}function Ie(e,t,r){r=r.replace(/[^0-9a-fA-F]/g,"");let n=2**(t-24);r=r.slice(-n*2).padStart(n*2,"0");let i=[(e<<5)+t].concat(r.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function ys(e,t){if(t<24)return new Uint8Array([(e<<5)+t]).buffer;{let r=t<=255?24:t<=65535?25:t<=4294967295?26:27;return Ie(e,r,t.toString(16))}}function Yf(e){let t=[];for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);n<128?t.push(n):n<2048?t.push(192|n>>6,128|n&63):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|n&63):(r++,n=(n&1023)<<10|e.charCodeAt(r)&1023,t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return ur(new Uint8Array(ys(3,e.length)),new Uint8Array(t))}function tp(e,t){if(e==14277111)return ur(new Uint8Array([217,217,247]),t);if(e<24)return ur(new Uint8Array([192+e]),t);{let r=e<=255?24:e<=65535?25:e<=4294967295?26:27,n=2**(r-24),i=e.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}}Ut.tagged=tp;function ri(e){return new Uint8Array(e).buffer}Ut.raw=ri;function Sa(e){if(isNaN(e))throw new RangeError("Invalid number.");e=Math.min(Math.max(0,e),23);let t=[0+e];return new Uint8Array(t).buffer}Ut.uSmall=Sa;function Kf(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),255),e=e.toString(16),Ie(0,24,e)}Ut.u8=Kf;function Wf(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),65535),e=e.toString(16),Ie(0,25,e)}Ut.u16=Wf;function Zf(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),4294967295),e=e.toString(16),Ie(0,26,e)}Ut.u32=Zf;function Na(e,t){if(typeof e=="string"&&t==16){if(e.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return Ie(0,27,e)}if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),Dd),e=e.toString(16),Ie(0,27,e)}Ut.u64=Na;function Xf(e){if(isNaN(e))throw new RangeError("Invalid number.");if(e===0)return Sa(0);e=Math.min(Math.max(0,-e),24)-1;let t=[32+e];return new Uint8Array(t).buffer}Ut.iSmall=Xf;function Jf(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),255),e=e.toString(16),Ie(1,24,e)}Ut.i8=Jf;function Qf(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),65535),e=e.toString(16),Ie(1,25,e)}Ut.i16=Qf;function Lf(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),4294967295),e=e.toString(16),Ie(1,26,e)}Ut.i32=Lf;function Df(e,t){if(typeof e=="string"&&t==16){if(e.startsWith("-")?e=e.slice(1):e="0",e.match(/[^0-9a-fA-F]/)||e.length>16)throw new RangeError("Invalid number.");let r=!1,n=e.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?Ie(1,27,n):Na(0)}if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),9007199254740992),e=e.toString(16),Ie(1,27,e)}Ut.i64=Df;function ep(e){return e>=0?e<24?Sa(e):e<=255?Kf(e):e<=65535?Wf(e):e<=4294967295?Zf(e):Na(e):e>=-24?Xf(e):e>=-255?Jf(e):e>=-65535?Qf(e):e>=-4294967295?Lf(e):Df(e)}Ut.number=ep;function rp(e){return ur(ys(2,e.byteLength),e)}Ut.bytes=rp;function np(e){return Yf(e)}Ut.string=np;function ip(e){return ur(ys(4,e.length),...e)}Ut.array=ip;function sp(e,t=!1){e instanceof Map||(e=new Map(Object.entries(e)));let r=Array.from(e.entries());return t&&(r=r.sort(([n],[i])=>n.localeCompare(i))),ur(ys(5,e.size),...r.map(([n,i])=>ur(Yf(n),i)))}Ut.map=sp;function op(e){let t=new Float32Array([e]);return ur(new Uint8Array([250]),new Uint8Array(t.buffer))}Ut.singleFloat=op;function ap(e){let t=new Float64Array([e]);return ur(new Uint8Array([251]),new Uint8Array(t.buffer))}Ut.doubleFloat=ap;function cp(e){return e?t0():e0()}Ut.bool=cp;function t0(){return ri(new Uint8Array([245]))}Ut.true_=t0;function e0(){return ri(new Uint8Array([244]))}Ut.false_=e0;function up(){return ri(new Uint8Array([246]))}Ut.null_=up;function fp(){return ri(new Uint8Array([247]))}Ut.undefined_=fp});var r0=Ht(Tr=>{"use strict";var lp=Tr&&Tr.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(Tr,"__esModule",{value:!0});var Pe=lp(Ra()),hp=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],gs=class{constructor(t,r=!1){this._serializer=t,this._stable=r,this.name="jsonDefault",this.priority=-100}match(t){return["undefined","boolean","number","string","object"].indexOf(typeof t)!=-1}encode(t){switch(typeof t){case"undefined":return Pe.undefined_();case"boolean":return Pe.bool(t);case"number":return Math.floor(t)===t?Pe.number(t):Pe.doubleFloat(t);case"string":return Pe.string(t);case"object":if(t===null)return Pe.null_();if(Array.isArray(t))return Pe.array(t.map(r=>this._serializer.serializeValue(r)));if(hp.find(r=>t instanceof r))return Pe.bytes(t.buffer);if(Object.getOwnPropertyNames(t).indexOf("toJSON")!==-1)return this.encode(t.toJSON());if(t instanceof Map){let r=new Map;for(let[n,i]of t.entries())r.set(n,this._serializer.serializeValue(i));return Pe.map(r,this._stable)}else{let r=new Map;for(let[n,i]of Object.entries(t))r.set(n,this._serializer.serializeValue(i));return Pe.map(r,this._stable)}default:throw new Error("Invalid value.")}}};Tr.JsonDefaultCborEncoder=gs;var ws=class{constructor(){this.name="cborEncoder",this.priority=-90}match(t){return typeof t=="object"&&typeof t.toCBOR=="function"}encode(t){return t.toCBOR()}};Tr.ToCborEncoder=ws;var bs=class{constructor(){this._encoders=new Set}static withDefaultEncoders(t=!1){let r=new this;return r.addEncoder(new gs(r,t)),r.addEncoder(new ws),r}removeEncoder(t){for(let r of this._encoders.values())r.name==t&&this._encoders.delete(r)}addEncoder(t){this._encoders.add(t)}getEncoderFor(t){let r=null;for(let n of this._encoders)(!r||n.priority>r.priority)&&n.match(t)&&(r=n);if(r===null)throw new Error("Could not find an encoder for value.");return r}serializeValue(t){return this.getEncoderFor(t).encode(t)}serialize(t){return this.serializeValue(t)}};Tr.CborSerializer=bs;var Oa=class extends bs{serialize(t){return Pe.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(t))]))}};Tr.SelfDescribeCborSerializer=Oa});var xs=Ht(Wr=>{"use strict";function dp(e){for(var t in e)Wr.hasOwnProperty(t)||(Wr[t]=e[t])}var pp=Wr&&Wr.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(Wr,"__esModule",{value:!0});dp(r0());var mp=pp(Ra());Wr.value=mp});function Es(e){return _s.serialize(e)}function n0(e){let t=e.byteLength,r=BigInt(0);for(let n=0;n<t;n++)r=r*BigInt(256)+BigInt(e[n]);return r}function Se(e){let t=new Uint8Array(e),r=new ka({size:t.byteLength,tags:{2:n=>n0(n),3:n=>-n0(n),[Pa.Semantic]:n=>n}});try{return r.decodeFirst(t)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${Bt(t)}`)}}var i0,Zr,s0,Fa,Ua,Ia,_s,Pa,ka,ni=ht(()=>{i0=sn(Aa()),Zr=sn(xs()),s0=sn(xs());de();Fa=class{get name(){return"Principal"}get priority(){return 0}match(t){return t&&t._isPrincipal===!0}encode(t){return Zr.value.bytes(t.toUint8Array())}},Ua=class{get name(){return"Buffer"}get priority(){return 1}match(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)}encode(t){return Zr.value.bytes(new Uint8Array(t))}},Ia=class{get name(){return"BigInt"}get priority(){return 1}match(t){return typeof t=="bigint"}encode(t){return t>BigInt(0)?Zr.value.tagged(2,Zr.value.bytes(Gr(t.toString(16)))):Zr.value.tagged(3,Zr.value.bytes(Gr((BigInt("-1")*t).toString(16))))}},_s=s0.SelfDescribeCborSerializer.withDefaultEncoders(!0);_s.addEncoder(new Fa);_s.addEncoder(new Ua);_s.addEncoder(new Ia);(function(e){e[e.Uint64LittleEndian=71]="Uint64LittleEndian",e[e.Semantic=55799]="Semantic"})(Pa||(Pa={}));ka=class extends i0.default.Decoder{createByteString(t){return oe(...t)}createByteStringFromHeap(t,r){return t===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(t,r))}}});var ii,Ma=ht(()=>{ii=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let e=new Uint32Array(1);return window.crypto.getRandomValues(e),e[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let e=new Uint32Array(1);return crypto.getRandomValues(e),e[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)}});function bn(){let e=new ArrayBuffer(16),t=new DataView(e),r=ii(),n=ii(),i=ii(),s=ii();return t.setUint32(0,r),t.setUint32(4,n),t.setUint32(8,i),t.setUint32(12,s),e}var Bs,si=ht(()=>{Ma();(function(e){e.Call="call"})(Bs||(Bs={}))});function Ca(e=bn){return async t=>{let r=t.request.headers;t.request.headers=r,t.endpoint==="call"&&(t.body.nonce=e())}}function xn(e){let t=[];return e.forEach((r,n)=>{t.push([n,r])}),t}var a0,o0,yp,Xr,As=ht(()=>{Xn();a0=sn(xs());si();o0=BigInt(1e6),yp=60*1e3,Xr=class{constructor(t){if(t<90*1e3){let a=BigInt(Date.now()+t)*o0/BigInt(1e9);this._value=a*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+t-yp))*o0/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return a0.value.u64(this._value.toString(16),16)}toHash(){return Pt(this._value)}}});var _n,Ts,Ss,Ns,Rs=ht(()=>{dn();_n=class extends Ft{constructor(t,r){super(t),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}},Ts=class extends Ft{constructor(t,r,n,i,s,o){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentCallError",Object.setPrototypeOf(this,new.target.prototype)}},Ss=class extends Ft{constructor(t,r,n,i,s,o){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentQueryError",Object.setPrototypeOf(this,new.target.prototype)}},Ns=class extends Ft{constructor(t,r,n,i,s,o){super(t),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentReadStateError",Object.setPrototypeOf(this,new.target.prototype)}}});var Is={};qn(Is,{aInRange:()=>Ce,abool:()=>Sr,abytes:()=>ke,bitGet:()=>Ga,bitLen:()=>lr,bitMask:()=>Rr,bitSet:()=>_p,bytesToHex:()=>Me,bytesToNumberBE:()=>re,bytesToNumberLE:()=>Nr,concatBytes:()=>St,createHmacDrbg:()=>f0,ensureBytes:()=>Yt,equalBytes:()=>xp,hexToBytes:()=>oi,hexToNumber:()=>Ha,inRange:()=>Fs,isBytes:()=>En,memoized:()=>hr,notImplemented:()=>Us,numberToBytesBE:()=>qt,numberToBytesLE:()=>Jr,numberToHexUnpadded:()=>ja,numberToVarBytesBE:()=>bp,utf8ToBytes:()=>ai,validateObject:()=>qe});function En(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function ke(e){if(!En(e))throw new Error("Uint8Array expected")}function Sr(e,t){if(typeof t!="boolean")throw new Error(`${e} must be valid boolean, got "${t}".`)}function Me(e){ke(e);let t="";for(let r=0;r<e.length;r++)t+=wp[e[r]];return t}function ja(e){let t=e.toString(16);return t.length&1?`0${t}`:t}function Ha(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}function c0(e){if(e>=fr._0&&e<=fr._9)return e-fr._0;if(e>=fr._A&&e<=fr._F)return e-(fr._A-10);if(e>=fr._a&&e<=fr._f)return e-(fr._a-10)}function oi(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=c0(e.charCodeAt(s)),a=c0(e.charCodeAt(s+1));if(o===void 0||a===void 0){let c=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function re(e){return Ha(Me(e))}function Nr(e){return ke(e),Ha(Me(Uint8Array.from(e).reverse()))}function qt(e,t){return oi(e.toString(16).padStart(t*2,"0"))}function Jr(e,t){return qt(e,t).reverse()}function bp(e){return oi(ja(e))}function Yt(e,t,r){let n;if(typeof t=="string")try{n=oi(t)}catch(s){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${s}`)}else if(En(t))n=Uint8Array.from(t);else throw new Error(`${e} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${e} expected ${r} bytes, got ${i}`);return n}function St(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];ke(i),t+=i.length}let r=new Uint8Array(t);for(let n=0,i=0;n<e.length;n++){let s=e[n];r.set(s,i),i+=s.length}return r}function xp(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function ai(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Fs(e,t,r){return qa(e)&&qa(t)&&qa(r)&&t<=e&&e<r}function Ce(e,t,r,n){if(!Fs(t,r,n))throw new Error(`expected valid ${e}: ${r} <= n < ${n}, got ${typeof t} ${t}`)}function lr(e){let t;for(t=0;e>$a;e>>=Os,t+=1);return t}function Ga(e,t){return e>>BigInt(t)&Os}function _p(e,t,r){return e|(r?Os:$a)<<BigInt(t)}function f0(e,t,r){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=Va(e),i=Va(e),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...d)=>r(i,n,...d),c=(d=Va())=>{i=a(u0([0]),d),n=a(),d.length!==0&&(i=a(u0([1]),d),n=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let d=0,g=[];for(;d<t;){n=a();let w=n.slice();g.push(w),d+=n.length}return St(...g)};return(d,g)=>{o(),c(d);let w;for(;!(w=g(l()));)c();return o(),w}}function qe(e,t,r={}){let n=(i,s,o)=>{let a=Ep[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=e[i];if(!(o&&c===void 0)&&!a(c,e))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(t))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return e}function hr(e){let t=new WeakMap;return(r,...n)=>{let i=t.get(r);if(i!==void 0)return i;let s=e(r,...n);return t.set(r,s),s}}var $a,Os,gp,wp,fr,qa,Rr,Va,u0,Ep,Us,Ve=ht(()=>{$a=BigInt(0),Os=BigInt(1),gp=BigInt(2);wp=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));fr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};qa=e=>typeof e=="bigint"&&$a<=e;Rr=e=>(gp<<BigInt(e-1))-Os,Va=e=>new Uint8Array(e),u0=e=>Uint8Array.from(e);Ep={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||En(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};Us=()=>{throw new Error("not implemented")}});function It(e,t){let r=e%t;return r>=Xt?r:t+r}function Tp(e,t,r){if(r<=Xt||t<Xt)throw new Error("Expected power/modulo > 0");if(r===kt)return Xt;let n=kt;for(;t>Xt;)t&kt&&(n=n*e%r),e=e*e%r,t>>=kt;return n}function $e(e,t,r){let n=e;for(;t-- >Xt;)n*=n,n%=r;return n}function Ya(e,t){if(e===Xt||t<=Xt)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=It(e,t),n=t,i=Xt,s=kt,o=kt,a=Xt;for(;r!==Xt;){let l=n/r,h=n%r,d=i-o*l,g=s-a*l;n=r,r=h,i=o,s=a,o=d,a=g}if(n!==kt)throw new Error("invert: does not exist");return It(i,t)}function Sp(e){let t=(e-kt)/Or,r,n,i;for(r=e-kt,n=0;r%Or===Xt;r/=Or,n++);for(i=Or;i<e&&Tp(i,t,e)!==e-kt;i++);if(n===1){let o=(e+kt)/za;return function(c,l){let h=c.pow(l,o);if(!c.eql(c.sqr(h),l))throw new Error("Cannot find square root");return h}}let s=(r+kt)/Or;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,h=a.pow(a.mul(a.ONE,i),r),d=a.pow(c,s),g=a.pow(c,r);for(;!a.eql(g,a.ONE);){if(a.eql(g,a.ZERO))return a.ZERO;let w=1;for(let O=a.sqr(g);w<l&&!a.eql(O,a.ONE);w++)O=a.sqr(O);let f=a.pow(h,kt<<BigInt(l-w-1));h=a.sqr(f),d=a.mul(d,f),g=a.mul(g,h),l=w}return d}}function Np(e){if(e%za===vp){let t=(e+kt)/za;return function(n,i){let s=n.pow(i,t);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(e%h0===l0){let t=(e-l0)/h0;return function(n,i){let s=n.mul(i,Or),o=n.pow(s,t),a=n.mul(i,o),c=n.mul(n.mul(a,Or),o),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),i))throw new Error("Cannot find square root");return l}}return e%Ap,Sp(e)}function Ps(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Rp.reduce((n,i)=>(n[i]="function",n),t);return qe(e,r)}function ci(e,t,r){if(r<Xt)throw new Error("Expected power > 0");if(r===Xt)return e.ONE;if(r===kt)return t;let n=e.ONE,i=t;for(;r>Xt;)r&kt&&(n=e.mul(n,i)),i=e.sqr(i),r>>=kt;return n}function ui(e,t){let r=new Array(t.length),n=t.reduce((s,o,a)=>e.is0(o)?s:(r[a]=s,e.mul(s,o)),e.ONE),i=e.inv(n);return t.reduceRight((s,o,a)=>e.is0(o)?s:(r[a]=e.mul(s,r[a]),e.mul(s,o)),i),r}function p0(e){let t=(e-kt)/Or;return(r,n)=>r.pow(n,t)}function Ka(e,t){let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Le(e,t,r=!1,n={}){if(e<=Xt)throw new Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:i,nByteLength:s}=Ka(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=Np(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:s,MASK:Rr(i),ZERO:Xt,ONE:kt,create:c=>It(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return Xt<=c&&c<e},is0:c=>c===Xt,isOdd:c=>(c&kt)===kt,neg:c=>It(-c,e),eql:(c,l)=>c===l,sqr:c=>It(c*c,e),add:(c,l)=>It(c+l,e),sub:(c,l)=>It(c-l,e),mul:(c,l)=>It(c*l,e),pow:(c,l)=>ci(a,c,l),div:(c,l)=>It(c*Ya(l,e),e),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Ya(c,e),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>ui(a,c),cmov:(c,l,h)=>h?l:c,toBytes:c=>r?Jr(c,s):qt(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?Nr(c):re(c)}});return Object.freeze(a)}function m0(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function ks(e){let t=m0(e);return t+Math.ceil(t/2)}function Wa(e,t,r=!1){let n=e.length,i=m0(t),s=ks(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?re(e):Nr(e),a=It(o,t-kt)+kt;return r?Jr(a,i):qt(a,i)}var Xt,kt,Or,vp,za,l0,h0,Bp,Ap,d0,Rp,dr=ht(()=>{Ve();Xt=BigInt(0),kt=BigInt(1),Or=BigInt(2),vp=BigInt(3),za=BigInt(4),l0=BigInt(5),h0=BigInt(8),Bp=BigInt(9),Ap=BigInt(16);d0=(e,t)=>(It(e,t)&kt)===kt,Rp=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"]});function Fr(e,t){if(fi(e),fi(t),e<0||e>=1<<8*t)throw new Error(`bad I2OSP call: value=${e} length=${t}`);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function Fp(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function fi(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function Up(e,t,r,n){ke(e),ke(t),fi(r),t.length>255&&(t=n(St(ai("H2C-OVERSIZE-DST-"),t)));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 a=St(t,Fr(t.length,1)),c=Fr(0,s),l=Fr(r,2),h=new Array(o),d=n(St(c,e,l,Fr(0,1),a));h[0]=n(St(d,Fr(1,1),a));for(let w=1;w<=o;w++){let f=[Fp(d,h[w-1]),Fr(w+1,1),a];h[w]=n(St(...f))}return St(...h).slice(0,r)}function Ip(e,t,r,n,i){if(ke(e),ke(t),fi(r),t.length>255){let s=Math.ceil(2*n/8);t=i.create({dkLen:s}).update(ai("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(e).update(Fr(r,2)).update(t).update(Fr(t.length,1)).digest()}function y0(e,t,r){qe(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:a,DST:c}=r;ke(e),fi(t);let l=typeof c=="string"?ai(c):c,h=n.toString(2).length,d=Math.ceil((h+i)/8),g=t*s*d,w;if(a==="xmd")w=Up(e,l,g,o);else if(a==="xof")w=Ip(e,l,g,i,o);else if(a==="_internal_pass")w=e;else throw new Error('expand must be "xmd" or "xof"');let f=new Array(t);for(let O=0;O<t;O++){let N=new Array(s);for(let F=0;F<s;F++){let j=d*(F+O*s),S=w.subarray(j,j+d);N[F]=It(Op(S),n)}f[O]=N}return f}function Xa(e,t){let r=t.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,a,c]=r.map(l=>l.reduce((h,d)=>e.add(e.mul(h,n),d)));return n=e.div(s,o),i=e.mul(i,e.div(a,c)),{x:n,y:i}}}function Ja(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=y0(n,2,{...r,DST:r.DST,...i}),o=e.fromAffine(t(s[0])),a=e.fromAffine(t(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=y0(n,1,{...r,DST:r.encodeDST,...i}),o=e.fromAffine(t(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=e.fromAffine(t(n)).clearCofactor();return i.assertValidity(),i}}}var Op,Qa=ht(()=>{dr();Ve();Op=re});function Ms(e,t){let r=(s,o)=>{let a=o.negate();return s?a:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error(`Wrong window size=${s}, should be [1..${t}]`)},i=s=>{n(s);let o=Math.ceil(t/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:r,unsafeLadder(s,o){let a=e.ZERO,c=s;for(;o>Pp;)o&La&&(a=a.add(c)),c=c.double(),o>>=La;return a},precomputeWindow(s,o){let{windows:a,windowSize:c}=i(o),l=[],h=s,d=h;for(let g=0;g<a;g++){d=h,l.push(d);for(let w=1;w<c;w++)d=d.add(h),l.push(d);h=d.double()}return l},wNAF(s,o,a){let{windows:c,windowSize:l}=i(s),h=e.ZERO,d=e.BASE,g=BigInt(2**s-1),w=2**s,f=BigInt(s);for(let O=0;O<c;O++){let N=O*l,F=Number(a&g);a>>=f,F>l&&(F-=w,a+=La);let j=N,S=N+Math.abs(F)-1,K=O%2!==0,_=F<0;F===0?d=d.add(r(K,o[j])):h=h.add(r(_,o[S]))}return{p:h,f:d}},wNAFCached(s,o,a){let c=g0.get(s)||1,l=Da.get(s);return l||(l=this.precomputeWindow(s,c),c!==1&&Da.set(s,a(l))),this.wNAF(c,l,o)},setWindowSize(s,o){n(o),g0.set(s,o),Da.delete(s)}}}function Cs(e,t,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((h,d)=>{if(!t.isValid(h))throw new Error(`wrong scalar at index ${d}`)}),r.forEach((h,d)=>{if(!(h instanceof e))throw new Error(`wrong point at index ${d}`)});let i=lr(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<<s)-1,a=new Array(o+1).fill(e.ZERO),c=Math.floor((t.BITS-1)/s)*s,l=e.ZERO;for(let h=c;h>=0;h-=s){a.fill(e.ZERO);for(let g=0;g<n.length;g++){let w=n[g],f=Number(w>>BigInt(h)&BigInt(o));a[f]=a[f].add(r[g])}let d=e.ZERO;for(let g=a.length-1,w=e.ZERO;g>0;g--)w=w.add(a[g]),d=d.add(w);if(l=l.add(d),h!==0)for(let g=0;g<s;g++)l=l.double()}return l}function qs(e){return Ps(e.Fp),qe(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ka(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}var Pp,La,Da,g0,tc=ht(()=>{dr();Ve();Pp=BigInt(0),La=BigInt(1),Da=new WeakMap,g0=new WeakMap});function kp(e){let t=qs(e);qe(t,{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}=t;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({...t})}function ec(e){let t=kp(e),{Fp:r}=t,n=Le(t.n,t.nBitLength),i=t.toBytes||((O,N,F)=>{let j=N.toAffine();return St(Uint8Array.from([4]),r.toBytes(j.x),r.toBytes(j.y))}),s=t.fromBytes||(O=>{let N=O.subarray(1),F=r.fromBytes(N.subarray(0,r.BYTES)),j=r.fromBytes(N.subarray(r.BYTES,2*r.BYTES));return{x:F,y:j}});function o(O){let{a:N,b:F}=t,j=r.sqr(O),S=r.mul(j,O);return r.add(r.add(S,r.mul(O,N)),F)}if(!r.eql(r.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function a(O){return Fs(O,Vt,t.n)}function c(O){let{allowedPrivateKeyLengths:N,nByteLength:F,wrapPrivateKey:j,n:S}=t;if(N&&typeof O!="bigint"){if(En(O)&&(O=Me(O)),typeof O!="string"||!N.includes(O.length))throw new Error("Invalid key");O=O.padStart(F*2,"0")}let K;try{K=typeof O=="bigint"?O:re(Yt("private key",O,F))}catch{throw new Error(`private key must be ${F} bytes, hex or bigint, not ${typeof O}`)}return j&&(K=It(K,S)),Ce("private key",K,Vt,S),K}function l(O){if(!(O instanceof g))throw new Error("ProjectivePoint expected")}let h=hr((O,N)=>{let{px:F,py:j,pz:S}=O;if(r.eql(S,r.ONE))return{x:F,y:j};let K=O.is0();N==null&&(N=K?r.ONE:r.inv(S));let _=r.mul(F,N),$=r.mul(j,N),z=r.mul(S,N);if(K)return{x:r.ZERO,y:r.ZERO};if(!r.eql(z,r.ONE))throw new Error("invZ was invalid");return{x:_,y:$}}),d=hr(O=>{if(O.is0()){if(t.allowInfinityPoint&&!r.is0(O.py))return;throw new Error("bad point: ZERO")}let{x:N,y:F}=O.toAffine();if(!r.isValid(N)||!r.isValid(F))throw new Error("bad point: x or y not FE");let j=r.sqr(F),S=o(N);if(!r.eql(j,S))throw new Error("bad point: equation left != right");if(!O.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class g{constructor(N,F,j){if(this.px=N,this.py=F,this.pz=j,N==null||!r.isValid(N))throw new Error("x required");if(F==null||!r.isValid(F))throw new Error("y required");if(j==null||!r.isValid(j))throw new Error("z required");Object.freeze(this)}static fromAffine(N){let{x:F,y:j}=N||{};if(!N||!r.isValid(F)||!r.isValid(j))throw new Error("invalid affine point");if(N instanceof g)throw new Error("projective point not allowed");let S=K=>r.eql(K,r.ZERO);return S(F)&&S(j)?g.ZERO:new g(F,j,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(N){let F=r.invertBatch(N.map(j=>j.pz));return N.map((j,S)=>j.toAffine(F[S])).map(g.fromAffine)}static fromHex(N){let F=g.fromAffine(s(Yt("pointHex",N)));return F.assertValidity(),F}static fromPrivateKey(N){return g.BASE.multiply(c(N))}static msm(N,F){return Cs(g,n,N,F)}_setWindowSize(N){f.setWindowSize(this,N)}assertValidity(){d(this)}hasEvenY(){let{y:N}=this.toAffine();if(r.isOdd)return!r.isOdd(N);throw new Error("Field doesn't support isOdd")}equals(N){l(N);let{px:F,py:j,pz:S}=this,{px:K,py:_,pz:$}=N,z=r.eql(r.mul(F,$),r.mul(K,S)),Y=r.eql(r.mul(j,$),r.mul(_,S));return z&&Y}negate(){return new g(this.px,r.neg(this.py),this.pz)}double(){let{a:N,b:F}=t,j=r.mul(F,Vs),{px:S,py:K,pz:_}=this,$=r.ZERO,z=r.ZERO,Y=r.ZERO,M=r.mul(S,S),it=r.mul(K,K),et=r.mul(_,_),rt=r.mul(S,K);return rt=r.add(rt,rt),Y=r.mul(S,_),Y=r.add(Y,Y),$=r.mul(N,Y),z=r.mul(j,et),z=r.add($,z),$=r.sub(it,z),z=r.add(it,z),z=r.mul($,z),$=r.mul(rt,$),Y=r.mul(j,Y),et=r.mul(N,et),rt=r.sub(M,et),rt=r.mul(N,rt),rt=r.add(rt,Y),Y=r.add(M,M),M=r.add(Y,M),M=r.add(M,et),M=r.mul(M,rt),z=r.add(z,M),et=r.mul(K,_),et=r.add(et,et),M=r.mul(et,rt),$=r.sub($,M),Y=r.mul(et,it),Y=r.add(Y,Y),Y=r.add(Y,Y),new g($,z,Y)}add(N){l(N);let{px:F,py:j,pz:S}=this,{px:K,py:_,pz:$}=N,z=r.ZERO,Y=r.ZERO,M=r.ZERO,it=t.a,et=r.mul(t.b,Vs),rt=r.mul(F,K),b=r.mul(j,_),B=r.mul(S,$),V=r.add(F,j),U=r.add(K,_);V=r.mul(V,U),U=r.add(rt,b),V=r.sub(V,U),U=r.add(F,S);let I=r.add(K,$);return U=r.mul(U,I),I=r.add(rt,B),U=r.sub(U,I),I=r.add(j,S),z=r.add(_,$),I=r.mul(I,z),z=r.add(b,B),I=r.sub(I,z),M=r.mul(it,U),z=r.mul(et,B),M=r.add(z,M),z=r.sub(b,M),M=r.add(b,M),Y=r.mul(z,M),b=r.add(rt,rt),b=r.add(b,rt),B=r.mul(it,B),U=r.mul(et,U),b=r.add(b,B),B=r.sub(rt,B),B=r.mul(it,B),U=r.add(U,B),rt=r.mul(b,U),Y=r.add(Y,rt),rt=r.mul(I,U),z=r.mul(V,z),z=r.sub(z,rt),rt=r.mul(V,b),M=r.mul(I,M),M=r.add(M,rt),new g(z,Y,M)}subtract(N){return this.add(N.negate())}is0(){return this.equals(g.ZERO)}wNAF(N){return f.wNAFCached(this,N,g.normalizeZ)}multiplyUnsafe(N){Ce("scalar",N,Qr,t.n);let F=g.ZERO;if(N===Qr)return F;if(N===Vt)return this;let{endo:j}=t;if(!j)return f.unsafeLadder(this,N);let{k1neg:S,k1:K,k2neg:_,k2:$}=j.splitScalar(N),z=F,Y=F,M=this;for(;K>Qr||$>Qr;)K&Vt&&(z=z.add(M)),$&Vt&&(Y=Y.add(M)),M=M.double(),K>>=Vt,$>>=Vt;return S&&(z=z.negate()),_&&(Y=Y.negate()),Y=new g(r.mul(Y.px,j.beta),Y.py,Y.pz),z.add(Y)}multiply(N){let{endo:F,n:j}=t;Ce("scalar",N,Vt,j);let S,K;if(F){let{k1neg:_,k1:$,k2neg:z,k2:Y}=F.splitScalar(N),{p:M,f:it}=this.wNAF($),{p:et,f:rt}=this.wNAF(Y);M=f.constTimeNegate(_,M),et=f.constTimeNegate(z,et),et=new g(r.mul(et.px,F.beta),et.py,et.pz),S=M.add(et),K=it.add(rt)}else{let{p:_,f:$}=this.wNAF(N);S=_,K=$}return g.normalizeZ([S,K])[0]}multiplyAndAddUnsafe(N,F,j){let S=g.BASE,K=($,z)=>z===Qr||z===Vt||!$.equals(S)?$.multiplyUnsafe(z):$.multiply(z),_=K(this,F).add(K(N,j));return _.is0()?void 0:_}toAffine(N){return h(this,N)}isTorsionFree(){let{h:N,isTorsionFree:F}=t;if(N===Vt)return!0;if(F)return F(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:N,clearCofactor:F}=t;return N===Vt?this:F?F(g,this):this.multiplyUnsafe(t.h)}toRawBytes(N=!0){return Sr("isCompressed",N),this.assertValidity(),i(g,this,N)}toHex(N=!0){return Sr("isCompressed",N),Me(this.toRawBytes(N))}}g.BASE=new g(t.Gx,t.Gy,r.ONE),g.ZERO=new g(r.ZERO,r.ONE,r.ZERO);let w=t.nBitLength,f=Ms(g,t.endo?Math.ceil(w/2):w);return{CURVE:t,ProjectivePoint:g,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function Mp(e,t){let r=e.ORDER,n=Qr;for(let f=r-Vt;f%Ur===Qr;f/=Ur)n+=Vt;let i=n,s=Ur<<i-Vt-Vt,o=s*Ur,a=(r-Vt)/o,c=(a-Vt)/Ur,l=o-Vt,h=s,d=e.pow(t,a),g=e.pow(t,(a+Vt)/Ur),w=(f,O)=>{let N=d,F=e.pow(O,l),j=e.sqr(F);j=e.mul(j,O);let S=e.mul(f,j);S=e.pow(S,c),S=e.mul(S,F),F=e.mul(S,O),j=e.mul(S,f);let K=e.mul(j,F);S=e.pow(K,h);let _=e.eql(S,e.ONE);F=e.mul(j,g),S=e.mul(K,N),j=e.cmov(F,j,_),K=e.cmov(S,K,_);for(let $=i;$>Vt;$--){let z=$-Ur;z=Ur<<z-Vt;let Y=e.pow(K,z),M=e.eql(Y,e.ONE);F=e.mul(j,N),N=e.mul(N,N),Y=e.mul(K,N),j=e.cmov(F,j,M),K=e.cmov(Y,K,M)}return{isValid:_,value:j}};if(e.ORDER%w0===Vs){let f=(e.ORDER-Vs)/w0,O=e.sqrt(e.neg(t));w=(N,F)=>{let j=e.sqr(F),S=e.mul(N,F);j=e.mul(j,S);let K=e.pow(j,f);K=e.mul(K,S);let _=e.mul(K,O),$=e.mul(e.sqr(K),F),z=e.eql($,N),Y=e.cmov(_,K,z);return{isValid:z,value:Y}}}return w}function rc(e,t){if(Ps(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=Mp(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,a,c,l,h,d;i=e.sqr(n),i=e.mul(i,t.Z),s=e.sqr(i),s=e.add(s,i),o=e.add(s,e.ONE),o=e.mul(o,t.B),a=e.cmov(t.Z,e.neg(s),!e.eql(s,e.ZERO)),a=e.mul(a,t.A),s=e.sqr(o),l=e.sqr(a),c=e.mul(l,t.A),s=e.add(s,c),s=e.mul(s,o),l=e.mul(l,a),c=e.mul(l,t.B),s=e.add(s,c),h=e.mul(i,o);let{isValid:g,value:w}=r(s,l);d=e.mul(i,n),d=e.mul(d,w),h=e.cmov(h,o,g),d=e.cmov(d,w,g);let f=e.isOdd(n)===e.isOdd(d);return d=e.cmov(e.neg(d),d,f),h=e.div(h,a),{x:h,y:d}}}var hg,dg,Qr,Vt,Ur,Vs,w0,nc=ht(()=>{tc();dr();Ve();Ve();({bytesToNumberBE:hg,hexToBytes:dg}=Is),Qr=BigInt(0),Vt=BigInt(1),Ur=BigInt(2),Vs=BigInt(3),w0=BigInt(4)});function qp(e){let t=[];for(;e>$s;e>>=$s)(e&$s)===Cp?t.unshift(0):(e&vn)===vn?(t.unshift(-1),e+=$s):t.unshift(1);return t}function x0(e){let{Fp:t,Fr:r,Fp2:n,Fp6:i,Fp12:s}=e.fields,o=e.params.xNegative,a=e.params.twistType,c=ec({n:r.ORDER,...e.G1}),l=Object.assign(c,Ja(c.ProjectivePoint,e.G1.mapToCurve,{...e.htfDefaults,...e.G1.htfDefaults})),h=ec({n:r.ORDER,...e.G2}),d=Object.assign(h,Ja(h.ProjectivePoint,e.G2.mapToCurve,{...e.htfDefaults,...e.G2.htfDefaults})),g;if(a==="multiplicative")g=(Z,k,m,tt,nt,ut)=>s.mul014(tt,Z,n.mul(k,nt),n.mul(m,ut));else if(a==="divisive")g=(Z,k,m,tt,nt,ut)=>s.mul034(tt,n.mul(m,ut),n.mul(k,nt),Z);else throw new Error("bls: unknown twist type");let w=n.div(n.ONE,n.mul(n.ONE,b0));function f(Z,k,m,tt){let nt=n.sqr(m),ut=n.sqr(tt),L=n.mulByB(n.mul(ut,vn)),u=n.mul(L,vn),p=n.sub(n.sub(n.sqr(n.add(m,tt)),ut),nt),y=n.sub(L,nt),T=n.mul(n.sqr(k),vn),v=n.neg(p);return Z.push([y,T,v]),k=n.mul(n.mul(n.mul(n.sub(nt,u),k),m),w),m=n.sub(n.sqr(n.mul(n.add(nt,u),w)),n.mul(n.sqr(L),vn)),tt=n.mul(nt,p),{Rx:k,Ry:m,Rz:tt}}function O(Z,k,m,tt,nt,ut){let L=n.sub(m,n.mul(ut,tt)),u=n.sub(k,n.mul(nt,tt)),p=n.sub(n.mul(L,nt),n.mul(u,ut)),y=n.neg(L),T=u;Z.push([p,y,T]);let v=n.sqr(u),A=n.mul(v,u),q=n.mul(v,k),x=n.add(n.sub(A,n.mul(q,b0)),n.mul(n.sqr(L),tt));return k=n.mul(u,x),m=n.sub(n.mul(n.sub(q,x),L),n.mul(A,m)),tt=n.mul(tt,A),{Rx:k,Ry:m,Rz:tt}}let N=qp(e.params.ateLoopSize),F=hr(Z=>{let k=Z,{x:m,y:tt}=k.toAffine(),nt=m,ut=tt,L=n.neg(tt),u=nt,p=ut,y=n.ONE,T=[];for(let v of N){let A=[];({Rx:u,Ry:p,Rz:y}=f(A,u,p,y)),v&&({Rx:u,Ry:p,Rz:y}=O(A,u,p,y,nt,v===-1?L:ut)),T.push(A)}if(e.postPrecompute){let v=T[T.length-1];e.postPrecompute(u,p,y,nt,ut,O.bind(null,v))}return T});function j(Z,k=!1){let m=s.ONE;if(Z.length){let tt=Z[0][0].length;for(let nt=0;nt<tt;nt++){m=s.sqr(m);for(let[ut,L,u]of Z)for(let[p,y,T]of ut[nt])m=g(p,y,T,m,L,u)}}return o&&(m=s.conjugate(m)),k?s.finalExponentiate(m):m}function S(Z,k=!0){let m=[];l.ProjectivePoint.normalizeZ(Z.map(({g1:tt})=>tt)),d.ProjectivePoint.normalizeZ(Z.map(({g2:tt})=>tt));for(let{g1:tt,g2:nt}of Z){if(tt.equals(l.ProjectivePoint.ZERO)||nt.equals(d.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");tt.assertValidity(),nt.assertValidity();let ut=tt.toAffine();m.push([F(nt),ut.x,ut.y])}return j(m,k)}function K(Z,k,m=!0){return S([{g1:Z,g2:k}],m)}let _={randomPrivateKey:()=>{let Z=ks(r.ORDER);return Wa(e.randomBytes(Z),r.ORDER)},calcPairingPrecomputes:F},{ShortSignature:$}=e.G1,{Signature:z}=e.G2;function Y(Z){return Z instanceof l.ProjectivePoint?Z:l.ProjectivePoint.fromHex(Z)}function M(Z,k){return Z instanceof l.ProjectivePoint?Z:l.hashToCurve(Yt("point",Z),k)}function it(Z){return Z instanceof d.ProjectivePoint?Z:z.fromHex(Z)}function et(Z,k){return Z instanceof d.ProjectivePoint?Z:d.hashToCurve(Yt("point",Z),k)}function rt(Z){return l.ProjectivePoint.fromPrivateKey(Z).toRawBytes(!0)}function b(Z){return d.ProjectivePoint.fromPrivateKey(Z).toRawBytes(!0)}function B(Z,k,m){let tt=et(Z,m);tt.assertValidity();let nt=tt.multiply(l.normPrivateKeyToScalar(k));return Z instanceof d.ProjectivePoint?nt:z.toRawBytes(nt)}function V(Z,k,m){let tt=M(Z,m);tt.assertValidity();let nt=tt.multiply(l.normPrivateKeyToScalar(k));return Z instanceof l.ProjectivePoint?nt:$.toRawBytes(nt)}function U(Z,k,m,tt){let nt=Y(m),ut=et(k,tt),L=l.ProjectivePoint.BASE,u=it(Z),p=S([{g1:nt.negate(),g2:ut},{g1:L,g2:u}]);return s.eql(p,s.ONE)}function I(Z,k,m,tt){let nt=it(m),ut=M(k,tt),L=d.ProjectivePoint.BASE,u=Y(Z),p=S([{g1:ut,g2:nt},{g1:u,g2:L.negate()}]);return s.eql(p,s.ONE)}function G(Z){if(!Z.length)throw new Error("Expected non-empty array");let m=Z.map(Y).reduce((tt,nt)=>tt.add(nt),l.ProjectivePoint.ZERO);return Z[0]instanceof l.ProjectivePoint?(m.assertValidity(),m):m.toRawBytes(!0)}function J(Z){if(!Z.length)throw new Error("Expected non-empty array");let m=Z.map(it).reduce((tt,nt)=>tt.add(nt),d.ProjectivePoint.ZERO);return Z[0]instanceof d.ProjectivePoint?(m.assertValidity(),m):z.toRawBytes(m)}function lt(Z){if(!Z.length)throw new Error("Expected non-empty array");let m=Z.map(Y).reduce((tt,nt)=>tt.add(nt),l.ProjectivePoint.ZERO);return Z[0]instanceof l.ProjectivePoint?(m.assertValidity(),m):$.toRawBytes(m)}function ct(Z,k,m,tt){if(!k.length)throw new Error("Expected non-empty messages array");if(m.length!==k.length)throw new Error("Pubkey count should equal msg count");let nt=it(Z),ut=k.map(y=>et(y,tt)),L=m.map(Y),u=new Map;for(let y=0;y<L.length;y++){let T=L[y],v=ut[y],A=u.get(v);A===void 0&&(A=[],u.set(v,A)),A.push(T)}let p=[];try{for(let[y,T]of u){let v=T.reduce((A,q)=>A.add(q));p.push({g1:v,g2:y})}return p.push({g1:l.ProjectivePoint.BASE.negate(),g2:nt}),s.eql(S(p),s.ONE)}catch{return!1}}return l.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:rt,getPublicKeyForShortSignatures:b,sign:B,signShortSignature:V,verify:U,verifyBatch:ct,verifyShortSignature:I,aggregatePublicKeys:G,aggregateSignatures:J,aggregateShortSignatures:lt,millerLoopBatch:j,pairing:K,pairingBatch:S,G1:l,G2:d,Signature:z,ShortSignature:$,fields:{Fr:r,Fp:t,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:e.params.ateLoopSize,r:e.params.r,G1b:e.G1.b,G2b:e.G2.b},utils:_}}var Cp,$s,b0,vn,_0=ht(()=>{dr();Ve();Qa();nc();Cp=BigInt(0),$s=BigInt(1),b0=BigInt(2),vn=BigInt(3)});function ic(e,t,r,n,i=1,s){let o=BigInt(s===void 0?n:s),a=r**BigInt(n),c=[];for(let l=0;l<i;l++){let h=BigInt(l+1),d=[];for(let g=0,w=Bn;g<n;g++){let f=(h*w-h)/o%a;d.push(e.pow(t,f)),w*=r}c.push(d)}return c}function v0(e,t,r){let n=t.pow(r,(e.ORDER-Bn)/E0),i=t.pow(r,(e.ORDER-Bn)/pr);function s(g,w){let f=t.mul(t.frobeniusMap(g,1),n),O=t.mul(t.frobeniusMap(w,1),i);return[f,O]}let o=t.pow(r,(e.ORDER**pr-Bn)/E0),a=t.pow(r,(e.ORDER**pr-Bn)/pr);if(!t.eql(a,t.neg(t.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(g,w){return[t.mul(g,o),t.neg(w)]}let l=g=>(w,f)=>{let O=f.toAffine(),N=g(O.x,O.y);return w.fromAffine({x:N[0],y:N[1]})},h=l(s),d=l(c);return{psi:s,psi2:c,G2psi:h,G2psi2:d,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:a}}function B0(e){let{ORDER:t}=e,r=Le(t),n=r.create(e.NONRESIDUE||BigInt(-1)),i=p0(t),s=r.div(r.ONE,pr),o=ic(r,n,r.ORDER,2)[0],a=({c0:b,c1:B},{c0:V,c1:U})=>({c0:r.add(b,V),c1:r.add(B,U)}),c=({c0:b,c1:B},{c0:V,c1:U})=>({c0:r.sub(b,V),c1:r.sub(B,U)}),l=({c0:b,c1:B},V)=>{if(typeof V=="bigint")return{c0:r.mul(b,V),c1:r.mul(B,V)};let{c0:U,c1:I}=V,G=r.mul(b,U),J=r.mul(B,I),lt=r.sub(G,J),ct=r.sub(r.mul(r.add(b,B),r.add(U,I)),r.add(G,J));return{c0:lt,c1:ct}},h=({c0:b,c1:B})=>{let V=r.add(b,B),U=r.sub(b,B),I=r.add(b,b);return{c0:r.mul(V,U),c1:r.mul(I,B)}},d=b=>{if(b.length!==2)throw new Error("Invalid tuple");let B=b.map(V=>r.create(V));return{c0:B[0],c1:B[1]}},g=t*t,w=d(e.FP2_NONRESIDUE),f={ORDER:g,NONRESIDUE:w,BITS:lr(g),BYTES:Math.ceil(lr(g)/8),MASK:Rr(lr(g)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:b=>b,isValid:({c0:b,c1:B})=>typeof b=="bigint"&&typeof B=="bigint",is0:({c0:b,c1:B})=>r.is0(b)&&r.is0(B),eql:({c0:b,c1:B},{c0:V,c1:U})=>r.eql(b,V)&&r.eql(B,U),neg:({c0:b,c1:B})=>({c0:r.neg(b),c1:r.neg(B)}),pow:(b,B)=>ci(f,b,B),invertBatch:b=>ui(f,b),add:a,sub:c,mul:l,sqr:h,addN:a,subN:c,mulN:l,sqrN:h,div:(b,B)=>f.mul(b,typeof B=="bigint"?r.inv(r.create(B)):f.inv(B)),inv:({c0:b,c1:B})=>{let V=r.inv(r.create(b*b+B*B));return{c0:r.mul(V,r.create(b)),c1:r.mul(V,r.create(-B))}},sqrt:b=>{if(e.Fp2sqrt)return e.Fp2sqrt(b);let{c0:B,c1:V}=b;if(r.is0(V))return r.eql(i(r,B),r.ONE)?f.create({c0:r.sqrt(B),c1:r.ZERO}):f.create({c0:r.ZERO,c1:r.sqrt(r.div(B,n))});let U=r.sqrt(r.sub(r.sqr(B),r.mul(r.sqr(V),n))),I=r.mul(r.add(U,B),s),G=i(r,I);!r.is0(G)&&!r.eql(G,r.ONE)&&(I=r.sub(I,U));let J=r.sqrt(I),lt=f.create({c0:J,c1:r.div(r.mul(V,s),J)});if(!f.eql(f.sqr(lt),b))throw new Error("Cannot find square root");let ct=lt,Z=f.neg(ct),{re:k,im:m}=f.reim(ct),{re:tt,im:nt}=f.reim(Z);return m>nt||m===nt&&k>tt?ct:Z},isOdd:b=>{let{re:B,im:V}=f.reim(b),U=B%pr,I=B===Vp,G=V%pr;return BigInt(U||I&&G)==Bn},fromBytes(b){if(b.length!==f.BYTES)throw new Error(`fromBytes wrong length=${b.length}`);return{c0:r.fromBytes(b.subarray(0,r.BYTES)),c1:r.fromBytes(b.subarray(r.BYTES))}},toBytes:({c0:b,c1:B})=>St(r.toBytes(b),r.toBytes(B)),cmov:({c0:b,c1:B},{c0:V,c1:U},I)=>({c0:r.cmov(b,V,I),c1:r.cmov(B,U,I)}),reim:({c0:b,c1:B})=>({re:b,im:B}),mulByNonresidue:({c0:b,c1:B})=>f.mul({c0:b,c1:B},w),mulByB:e.Fp2mulByB,fromBigTuple:d,frobeniusMap:({c0:b,c1:B},V)=>({c0:b,c1:r.mul(B,o[V%2])})},O=({c0:b,c1:B,c2:V},{c0:U,c1:I,c2:G})=>({c0:f.add(b,U),c1:f.add(B,I),c2:f.add(V,G)}),N=({c0:b,c1:B,c2:V},{c0:U,c1:I,c2:G})=>({c0:f.sub(b,U),c1:f.sub(B,I),c2:f.sub(V,G)}),F=({c0:b,c1:B,c2:V},U)=>{if(typeof U=="bigint")return{c0:f.mul(b,U),c1:f.mul(B,U),c2:f.mul(V,U)};let{c0:I,c1:G,c2:J}=U,lt=f.mul(b,I),ct=f.mul(B,G),Z=f.mul(V,J);return{c0:f.add(lt,f.mulByNonresidue(f.sub(f.mul(f.add(B,V),f.add(G,J)),f.add(ct,Z)))),c1:f.add(f.sub(f.mul(f.add(b,B),f.add(I,G)),f.add(lt,ct)),f.mulByNonresidue(Z)),c2:f.sub(f.add(ct,f.mul(f.add(b,V),f.add(I,J))),f.add(lt,Z))}},j=({c0:b,c1:B,c2:V})=>{let U=f.sqr(b),I=f.mul(f.mul(b,B),pr),G=f.mul(f.mul(B,V),pr),J=f.sqr(V);return{c0:f.add(f.mulByNonresidue(G),U),c1:f.add(f.mulByNonresidue(J),I),c2:f.sub(f.sub(f.add(f.add(I,f.sqr(f.add(f.sub(b,B),V))),G),U),J)}},[S,K]=ic(f,w,r.ORDER,6,2,3),_={ORDER:f.ORDER,BITS:3*f.BITS,BYTES:3*f.BYTES,MASK:Rr(3*f.BITS),ZERO:{c0:f.ZERO,c1:f.ZERO,c2:f.ZERO},ONE:{c0:f.ONE,c1:f.ZERO,c2:f.ZERO},create:b=>b,isValid:({c0:b,c1:B,c2:V})=>f.isValid(b)&&f.isValid(B)&&f.isValid(V),is0:({c0:b,c1:B,c2:V})=>f.is0(b)&&f.is0(B)&&f.is0(V),neg:({c0:b,c1:B,c2:V})=>({c0:f.neg(b),c1:f.neg(B),c2:f.neg(V)}),eql:({c0:b,c1:B,c2:V},{c0:U,c1:I,c2:G})=>f.eql(b,U)&&f.eql(B,I)&&f.eql(V,G),sqrt:Us,div:(b,B)=>_.mul(b,typeof B=="bigint"?r.inv(r.create(B)):_.inv(B)),pow:(b,B)=>ci(_,b,B),invertBatch:b=>ui(_,b),add:O,sub:N,mul:F,sqr:j,addN:O,subN:N,mulN:F,sqrN:j,inv:({c0:b,c1:B,c2:V})=>{let U=f.sub(f.sqr(b),f.mulByNonresidue(f.mul(V,B))),I=f.sub(f.mulByNonresidue(f.sqr(V)),f.mul(b,B)),G=f.sub(f.sqr(B),f.mul(b,V)),J=f.inv(f.add(f.mulByNonresidue(f.add(f.mul(V,I),f.mul(B,G))),f.mul(b,U)));return{c0:f.mul(J,U),c1:f.mul(J,I),c2:f.mul(J,G)}},fromBytes:b=>{if(b.length!==_.BYTES)throw new Error(`fromBytes wrong length=${b.length}`);return{c0:f.fromBytes(b.subarray(0,f.BYTES)),c1:f.fromBytes(b.subarray(f.BYTES,2*f.BYTES)),c2:f.fromBytes(b.subarray(2*f.BYTES))}},toBytes:({c0:b,c1:B,c2:V})=>St(f.toBytes(b),f.toBytes(B),f.toBytes(V)),cmov:({c0:b,c1:B,c2:V},{c0:U,c1:I,c2:G},J)=>({c0:f.cmov(b,U,J),c1:f.cmov(B,I,J),c2:f.cmov(V,G,J)}),fromBigSix:b=>{if(!Array.isArray(b)||b.length!==6)throw new Error("Invalid Fp6 usage");return{c0:f.fromBigTuple(b.slice(0,2)),c1:f.fromBigTuple(b.slice(2,4)),c2:f.fromBigTuple(b.slice(4,6))}},frobeniusMap:({c0:b,c1:B,c2:V},U)=>({c0:f.frobeniusMap(b,U),c1:f.mul(f.frobeniusMap(B,U),S[U%6]),c2:f.mul(f.frobeniusMap(V,U),K[U%6])}),mulByFp2:({c0:b,c1:B,c2:V},U)=>({c0:f.mul(b,U),c1:f.mul(B,U),c2:f.mul(V,U)}),mulByNonresidue:({c0:b,c1:B,c2:V})=>({c0:f.mulByNonresidue(V),c1:b,c2:B}),mul1:({c0:b,c1:B,c2:V},U)=>({c0:f.mulByNonresidue(f.mul(V,U)),c1:f.mul(b,U),c2:f.mul(B,U)}),mul01({c0:b,c1:B,c2:V},U,I){let G=f.mul(b,U),J=f.mul(B,I);return{c0:f.add(f.mulByNonresidue(f.sub(f.mul(f.add(B,V),I),J)),G),c1:f.sub(f.sub(f.mul(f.add(U,I),f.add(b,B)),G),J),c2:f.add(f.sub(f.mul(f.add(b,V),U),G),J)}}},$=ic(f,w,r.ORDER,12,1,6)[0],z=({c0:b,c1:B},{c0:V,c1:U})=>({c0:_.add(b,V),c1:_.add(B,U)}),Y=({c0:b,c1:B},{c0:V,c1:U})=>({c0:_.sub(b,V),c1:_.sub(B,U)}),M=({c0:b,c1:B},V)=>{if(typeof V=="bigint")return{c0:_.mul(b,V),c1:_.mul(B,V)};let{c0:U,c1:I}=V,G=_.mul(b,U),J=_.mul(B,I);return{c0:_.add(G,_.mulByNonresidue(J)),c1:_.sub(_.mul(_.add(b,B),_.add(U,I)),_.add(G,J))}},it=({c0:b,c1:B})=>{let V=_.mul(b,B);return{c0:_.sub(_.sub(_.mul(_.add(_.mulByNonresidue(B),b),_.add(b,B)),V),_.mulByNonresidue(V)),c1:_.add(V,V)}};function et(b,B){let V=f.sqr(b),U=f.sqr(B);return{first:f.add(f.mulByNonresidue(U),V),second:f.sub(f.sub(f.sqr(f.add(b,B)),V),U)}}let rt={ORDER:f.ORDER,BITS:2*f.BITS,BYTES:2*f.BYTES,MASK:Rr(2*f.BITS),ZERO:{c0:_.ZERO,c1:_.ZERO},ONE:{c0:_.ONE,c1:_.ZERO},create:b=>b,isValid:({c0:b,c1:B})=>_.isValid(b)&&_.isValid(B),is0:({c0:b,c1:B})=>_.is0(b)&&_.is0(B),neg:({c0:b,c1:B})=>({c0:_.neg(b),c1:_.neg(B)}),eql:({c0:b,c1:B},{c0:V,c1:U})=>_.eql(b,V)&&_.eql(B,U),sqrt:Us,inv:({c0:b,c1:B})=>{let V=_.inv(_.sub(_.sqr(b),_.mulByNonresidue(_.sqr(B))));return{c0:_.mul(b,V),c1:_.neg(_.mul(B,V))}},div:(b,B)=>rt.mul(b,typeof B=="bigint"?r.inv(r.create(B)):rt.inv(B)),pow:(b,B)=>ci(rt,b,B),invertBatch:b=>ui(rt,b),add:z,sub:Y,mul:M,sqr:it,addN:z,subN:Y,mulN:M,sqrN:it,fromBytes:b=>{if(b.length!==rt.BYTES)throw new Error(`fromBytes wrong length=${b.length}`);return{c0:_.fromBytes(b.subarray(0,_.BYTES)),c1:_.fromBytes(b.subarray(_.BYTES))}},toBytes:({c0:b,c1:B})=>St(_.toBytes(b),_.toBytes(B)),cmov:({c0:b,c1:B},{c0:V,c1:U},I)=>({c0:_.cmov(b,V,I),c1:_.cmov(B,U,I)}),fromBigTwelve:b=>({c0:_.fromBigSix(b.slice(0,6)),c1:_.fromBigSix(b.slice(6,12))}),frobeniusMap(b,B){let{c0:V,c1:U,c2:I}=_.frobeniusMap(b.c1,B),G=$[B%12];return{c0:_.frobeniusMap(b.c0,B),c1:_.create({c0:f.mul(V,G),c1:f.mul(U,G),c2:f.mul(I,G)})}},mulByFp2:({c0:b,c1:B},V)=>({c0:_.mulByFp2(b,V),c1:_.mulByFp2(B,V)}),conjugate:({c0:b,c1:B})=>({c0:b,c1:_.neg(B)}),mul014:({c0:b,c1:B},V,U,I)=>{let G=_.mul01(b,V,U),J=_.mul1(B,I);return{c0:_.add(_.mulByNonresidue(J),G),c1:_.sub(_.sub(_.mul01(_.add(B,b),V,f.add(U,I)),G),J)}},mul034:({c0:b,c1:B},V,U,I)=>{let G=_.create({c0:f.mul(b.c0,V),c1:f.mul(b.c1,V),c2:f.mul(b.c2,V)}),J=_.mul01(B,U,I),lt=_.mul01(_.add(b,B),f.add(V,U),I);return{c0:_.add(_.mulByNonresidue(J),G),c1:_.sub(lt,_.add(G,J))}},_cyclotomicSquare:e.Fp12cyclotomicSquare,_cyclotomicExp:e.Fp12cyclotomicExp,finalExponentiate:e.Fp12finalExponentiate};return{Fp:r,Fp2:f,Fp6:_,Fp4Square:et,Fp12:rt}}var Vp,Bn,pr,E0,A0=ht(()=>{dr();Ve();Vp=BigInt(0),Bn=BigInt(1),pr=BigInt(2),E0=BigInt(3)});function Hs(e){e=e.slice();let t=e[0]&224,r=!!(t>>7&1),n=!!(t>>6&1),i=!!(t>>5&1);return e[0]&=31,{compressed:r,infinity:n,sort:i,value:e}}function hi(e,t){if(e[0]&224)throw new Error("setMask: non-empty mask");return t.compressed&&(e[0]|=128),t.infinity&&(e[0]|=64),t.sort&&(e[0]|=32),e}function N0(e){e.assertValidity();let t=e.equals(xe.G1.ProjectivePoint.ZERO),{x:r,y:n}=e.toAffine();if(t)return zs.slice();let i=st.ORDER,s=!!(n*Dt/i);return hi(qt(r,st.BYTES),{compressed:!0,sort:s})}function R0(e){e.assertValidity();let t=st.BYTES;if(e.equals(xe.G2.ProjectivePoint.ZERO))return St(zs,qt(ce,t));let{x:r,y:n}=e.toAffine(),{re:i,im:s}=ft.reim(r),{re:o,im:a}=ft.reim(n),l=!!((a>ce?a*Dt:o*Dt)/st.ORDER&Gs),h=i;return St(hi(qt(s,t),{sort:l,compressed:!0}),qt(h,t))}var ce,Gs,Dt,js,li,Ir,$p,st,ft,ac,sc,wt,T0,jp,Hp,Gp,zp,S0,Yp,oc,zs,xe,O0=ht(()=>{Mi();an();_0();dr();Ve();Qa();nc();A0();ce=BigInt(0),Gs=BigInt(1),Dt=BigInt(2),js=BigInt(3),li=BigInt(4),Ir=BigInt("0xd201000000010000"),$p=lr(Ir),{Fp:st,Fp2:ft,Fp6:ac,Fp4Square:sc,Fp12:wt}=B0({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[Gs,Gs],Fp2mulByB:({c0:e,c1:t})=>{let r=st.mul(e,li),n=st.mul(t,li);return{c0:st.sub(r,n),c1:st.add(r,n)}},Fp12cyclotomicSquare:({c0:e,c1:t})=>{let{c0:r,c1:n,c2:i}=e,{c0:s,c1:o,c2:a}=t,{first:c,second:l}=sc(r,o),{first:h,second:d}=sc(s,i),{first:g,second:w}=sc(n,a),f=ft.mulByNonresidue(w);return{c0:ac.create({c0:ft.add(ft.mul(ft.sub(c,r),Dt),c),c1:ft.add(ft.mul(ft.sub(h,n),Dt),h),c2:ft.add(ft.mul(ft.sub(g,i),Dt),g)}),c1:ac.create({c0:ft.add(ft.mul(ft.add(f,s),Dt),f),c1:ft.add(ft.mul(ft.add(l,o),Dt),l),c2:ft.add(ft.mul(ft.add(d,a),Dt),d)})}},Fp12cyclotomicExp(e,t){let r=wt.ONE;for(let n=$p-1;n>=0;n--)r=wt._cyclotomicSquare(r),Ga(t,n)&&(r=wt.mul(r,e));return r},Fp12finalExponentiate:e=>{let t=Ir,r=wt.div(wt.frobeniusMap(e,6),e),n=wt.mul(wt.frobeniusMap(r,2),r),i=wt.conjugate(wt._cyclotomicExp(n,t)),s=wt.mul(wt.conjugate(wt._cyclotomicSquare(n)),i),o=wt.conjugate(wt._cyclotomicExp(s,t)),a=wt.conjugate(wt._cyclotomicExp(o,t)),c=wt.mul(wt.conjugate(wt._cyclotomicExp(a,t)),wt._cyclotomicSquare(i)),l=wt.conjugate(wt._cyclotomicExp(c,t)),h=wt.frobeniusMap(wt.mul(i,a),2),d=wt.frobeniusMap(wt.mul(o,n),3),g=wt.frobeniusMap(wt.mul(c,wt.conjugate(n)),1),w=wt.mul(wt.mul(l,wt.conjugate(s)),n);return wt.mul(wt.mul(wt.mul(h,d),g),w)}}),T0=Le(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),jp=Xa(ft,[[["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(e=>e.map(t=>ft.fromBigTuple(t.map(BigInt))))),Hp=Xa(st,[["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(e=>e.map(t=>BigInt(t)))),Gp=rc(ft,{A:ft.create({c0:st.create(ce),c1:st.create(BigInt(240))}),B:ft.create({c0:st.create(BigInt(1012)),c1:st.create(BigInt(1012))}),Z:ft.create({c0:st.create(BigInt(-2)),c1:st.create(BigInt(-1))})}),zp=rc(st,{A:st.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:st.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:st.create(BigInt(11))}),{G2psi:S0,G2psi2:Yp}=v0(st,ft,ft.div(ft.ONE,ft.NONRESIDUE)),oc=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:st.ORDER,m:2,k:128,expand:"xmd",hash:$n}),zs=hi(st.toBytes(ce),{infinity:!0,compressed:!0});xe=x0({fields:{Fp:st,Fp2:ft,Fp6:ac,Fp12:wt,Fr:T0},G1:{Fp:st,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:st.ZERO,b:li,htfDefaults:{...oc,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(e,t)=>{let r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new e(st.mul(t.px,r),t.py,t.pz);return t.multiplyUnsafe(Ir).negate().multiplyUnsafe(Ir).equals(n)},clearCofactor:(e,t)=>t.multiplyUnsafe(Ir).add(t),mapToCurve:e=>{let{x:t,y:r}=zp(st.create(e[0]));return Hp(t,r)},fromBytes:e=>{let{compressed:t,infinity:r,sort:n,value:i}=Hs(e);if(i.length===48&&t){let s=st.ORDER,o=re(i),a=st.create(o&st.MASK);if(r){if(a!==ce)throw new Error("G1: non-empty compressed point at infinity");return{x:ce,y:ce}}let c=st.add(st.pow(a,js),st.create(xe.params.G1b)),l=st.sqrt(c);if(!l)throw new Error("Invalid compressed G1 point");return l*Dt/s!==BigInt(n)&&(l=st.neg(l)),{x:st.create(a),y:st.create(l)}}else if(i.length===96&&!t){let s=re(i.subarray(0,st.BYTES)),o=re(i.subarray(st.BYTES));if(r){if(s!==ce||o!==ce)throw new Error("G1: non-empty point at infinity");return xe.G1.ProjectivePoint.ZERO.toAffine()}return{x:st.create(s),y:st.create(o)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(e,t,r)=>{let n=t.equals(e.ZERO),{x:i,y:s}=t.toAffine();if(r){if(n)return zs.slice();let o=st.ORDER,a=!!(s*Dt/o);return hi(qt(i,st.BYTES),{compressed:!0,sort:a})}else return n?St(new Uint8Array([64]),new Uint8Array(2*st.BYTES-1)):St(qt(i,st.BYTES),qt(s,st.BYTES))},ShortSignature:{fromHex(e){let{infinity:t,sort:r,value:n}=Hs(Yt("signatureHex",e,48)),i=st.ORDER,s=re(n);if(t)return xe.G1.ProjectivePoint.ZERO;let o=st.create(s&st.MASK),a=st.add(st.pow(o,js),st.create(xe.params.G1b)),c=st.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let l=BigInt(r);c*Dt/i!==l&&(c=st.neg(c));let h=xe.G1.ProjectivePoint.fromAffine({x:o,y:c});return h.assertValidity(),h},toRawBytes(e){return N0(e)},toHex(e){return Me(N0(e))}}},G2:{Fp:ft,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:ft.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:ft.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:ft.ZERO,b:ft.fromBigTuple([li,li]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...oc},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:e=>{let{x:t,y:r}=Gp(ft.fromBigTuple(e));return jp(t,r)},isTorsionFree:(e,t)=>t.multiplyUnsafe(Ir).negate().equals(S0(e,t)),clearCofactor:(e,t)=>{let r=Ir,n=t.multiplyUnsafe(r).negate(),i=S0(e,t),s=t.double();return s=Yp(e,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),s=s.add(i),s=s.subtract(n),s.subtract(t)},fromBytes:e=>{let{compressed:t,infinity:r,sort:n,value:i}=Hs(e);if(!t&&!r&&n||!t&&r&&n||n&&r&&t)throw new Error("Invalid encoding flag: "+(e[0]&224));let s=st.BYTES,o=(a,c,l)=>re(a.slice(c,l));if(i.length===96&&t){let a=xe.params.G2b,c=st.ORDER;if(r){if(i.reduce((O,N)=>O!==0?N+1:N,0)>0)throw new Error("Invalid compressed G2 point");return{x:ft.ZERO,y:ft.ZERO}}let l=o(i,0,s),h=o(i,s,2*s),d=ft.create({c0:st.create(h),c1:st.create(l)}),g=ft.add(ft.pow(d,js),a),w=ft.sqrt(g),f=w.c1===ce?w.c0*Dt/c:w.c1*Dt/c?Gs:ce;return w=n&&f>0?w:ft.neg(w),{x:d,y:w}}else if(i.length===192&&!t){if(r){if(i.reduce((d,g)=>d!==0?g+1:g,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:ft.ZERO,y:ft.ZERO}}let a=o(i,0,s),c=o(i,s,2*s),l=o(i,2*s,3*s),h=o(i,3*s,4*s);return{x:ft.fromBigTuple([c,a]),y:ft.fromBigTuple([h,l])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(e,t,r)=>{let{BYTES:n,ORDER:i}=st,s=t.equals(e.ZERO),{x:o,y:a}=t.toAffine();if(r){if(s)return St(zs,qt(ce,n));let c=!!(a.c1===ce?a.c0*Dt/i:a.c1*Dt/i);return St(hi(qt(o.c1,n),{compressed:!0,sort:c}),qt(o.c0,n))}else{if(s)return St(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:l}=ft.reim(o),{re:h,im:d}=ft.reim(a);return St(qt(l,n),qt(c,n),qt(d,n),qt(h,n))}},Signature:{fromHex(e){let{infinity:t,sort:r,value:n}=Hs(Yt("signatureHex",e)),i=st.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=re(n.slice(0,s)),a=re(n.slice(s));if(t)return xe.G2.ProjectivePoint.ZERO;let c=st.create(o&st.MASK),l=st.create(a),h=ft.create({c0:l,c1:c}),d=ft.add(ft.pow(h,js),xe.params.G2b),g=ft.sqrt(d);if(!g)throw new Error("Failed to find a square root");let{re:w,im:f}=ft.reim(g),O=BigInt(r),N=f>ce&&f*Dt/i!==O,F=f===ce&&w*Dt/i!==O;(N||F)&&(g=ft.neg(g));let j=xe.G2.ProjectivePoint.fromAffine({x:h,y:g});return j.assertValidity(),j},toRawBytes(e){return R0(e)},toHex(e){return Me(R0(e))}}},params:{ateLoopSize:Ir,r:T0.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:oc,hash:$n,randomBytes:Pi})});function F0(e,t,r){let n=typeof e=="string"?e:Bt(e),i=typeof t=="string"?t:Bt(t),s=typeof r=="string"?r:Bt(r);return xe.verifyShortSignature(i,s,n)}var cc=ht(()=>{O0();de()});var uc,An,Ys=ht(()=>{Xn();uc=e=>Gt(new Oe(e)),An=e=>{let t=uc(e);return new Date(Number(t)/1e6)}});function Xp(e,t){let r=new Uint8Array(e),n=new Uint8Array(t);for(let i=0;i<r.length;i++)if(r[i]>n[i])return!0;return!1}function Qp(e){let t=di.byteLength+Jp;if(e.byteLength!==t)throw new TypeError(`BLS DER-encoded public key must be ${t} bytes long`);let r=e.slice(0,di.byteLength);if(!zr(r,di))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${di}, but get ${r}`);return e.slice(di.byteLength)}function ue(e){if(e.status===$t.Found){if(e.value instanceof ArrayBuffer)return e.value;if(e.value instanceof Uint8Array)return e.value.buffer}}async function Ws(e){switch(e[0]){case Ee.Empty:return Te(pi("ic-hashtree-empty"));case Ee.Pruned:return e[1];case Ee.Leaf:return Te(oe(pi("ic-hashtree-leaf"),e[1]));case Ee.Labeled:return Te(oe(pi("ic-hashtree-labeled"),e[1],await Ws(e[2])));case Ee.Fork:return Te(oe(pi("ic-hashtree-fork"),await Ws(e[1]),await Ws(e[2])));default:throw new Error("unreachable")}}function pi(e){let t=new Uint8Array([e.length]),r=new TextEncoder().encode(e);return oe(t,r)}function kr(e,t){if(e.length===0)switch(t[0]){case Ee.Leaf:{if(!t[1])throw new Error("Invalid tree structure for leaf");return t[1]instanceof ArrayBuffer?{status:$t.Found,value:t[1]}:t[1]instanceof Uint8Array?{status:$t.Found,value:t[1].buffer}:{status:$t.Found,value:t[1]}}default:return{status:$t.Found,value:t}}let r=typeof e[0]=="string"?new TextEncoder().encode(e[0]):e[0],n=Zs(r,t);switch(n.status){case $t.Found:return kr(e.slice(1),n.value);case mr.Greater:case mr.Less:return{status:$t.Absent};default:return n}}function Xs(e){switch(e[0]){case Ee.Empty:return[];case Ee.Fork:return Xs(e[1]).concat(Xs(e[2]));default:return[e]}}function Zs(e,t){switch(t[0]){case Ee.Labeled:return Xp(e,t[1])?{status:mr.Greater}:zr(e,t[1])?{status:$t.Found,value:t[2]}:{status:mr.Less};case Ee.Fork:let r=Zs(e,t[1]);switch(r.status){case mr.Greater:{let n=Zs(e,t[2]);return n.status===mr.Less?{status:$t.Absent}:n}case $t.Unknown:{let n=Zs(e,t[2]);return n.status===mr.Less?{status:$t.Unknown}:n}default:return r}case Ee.Pruned:return{status:$t.Unknown};default:return{status:$t.Absent}}}function fc(e){let{canisterId:t,subnetId:r,tree:n}=e,i=kr(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==$t.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return Se(i.value).map(c=>[dt.fromUint8Array(c[0]),dt.fromUint8Array(c[1])]).some(c=>c[0].ltEq(t)&&c[1].gtEq(t))}var Wp,Zp,Ks,_e,Ee,Pr,di,Jp,$t,mr,Tn=ht(()=>{ni();dn();ei();de();we();cc();Ys();mi();Wp=function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},Zp=function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},_e=class extends Ft{constructor(t){super(`Invalid certificate: ${t}`)}};(function(e){e[e.Empty=0]="Empty",e[e.Fork=1]="Fork",e[e.Labeled=2]="Labeled",e[e.Leaf=3]="Leaf",e[e.Pruned=4]="Pruned"})(Ee||(Ee={}));Pr=class e{constructor(t,r,n,i,s=5,o=!1){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,Ks.set(this,!1),Wp(this,Ks,o,"f"),this.cert=Se(new Uint8Array(t))}static async create(t){let r=e.createUnverified(t);return await r.verify(),r}static createUnverified(t){let r=t.blsVerify;return r||(r=F0),new e(t.certificate,t.rootKey,t.canisterId,r,t.maxAgeInMinutes,t.disableTimeVerification)}lookup(t){return kr(t,this.cert.tree)}lookup_label(t){return this.lookup([t])}async verify(){let t=await Ws(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=Qp(r),s=oe(pi("ic-state-root"),t),o=!1,a=ue(this.lookup(["time"]));if(!a)throw new _e("Certificate does not contain a time");if(!Zp(this,Ks,"f")){let l=this._maxAgeInMinutes*60*1e3,h=Date.now(),d=h-l,g=h+3e5,w=An(a);if(w.getTime()<d)throw new _e(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+w.toISOString()+" Current time: "+new Date(h).toISOString());if(w.getTime()>g)throw new _e("Certificate is signed more than 5 minutes in the future. Certificate time: "+w.toISOString()+" Current time: "+new Date(h).toISOString())}try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new _e("Signature verification failed")}async _checkDelegationAndGetKey(t){if(!t)return this._rootKey;let r=await e.createUnverified({certificate:t.certificate,rootKey:this._rootKey,canisterId:this._canisterId,blsVerify:this._blsVerify,maxAgeInMinutes:1/0});if(r.cert.delegation)throw new _e("Delegation certificates cannot be nested");if(await r.verify(),this._canisterId.toString()!==U0&&!fc({canisterId:this._canisterId,subnetId:dt.fromUint8Array(new Uint8Array(t.subnet_id)),tree:r.cert.tree}))throw new _e(`Canister ${this._canisterId} not in range of delegations for subnet 0x${Bt(t.subnet_id)}`);let n=ue(r.lookup(["subnet",t.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${Bt(t.subnet_id)}`);return n}};Ks=new WeakMap;di=Gr("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Jp=96;(function(e){e.Unknown="unknown",e.Absent="absent",e.Found="found"})($t||($t={}));(function(e){e.Less="less",e.Greater="greater"})(mr||(mr={}))});var Qs={};qn(Qs,{CustomPath:()=>lc,encodePath:()=>hc,fetchNodeKeys:()=>P0,request:()=>Js});var lc,Js,P0,hc,I0,k0,Lp,Dp,yi=ht(()=>{we();dn();Tn();de();ni();Ys();lc=class{constructor(t,r,n){this.key=t,this.path=r,this.decodeStrategy=n}},Js=async e=>{let{agent:t,paths:r}=e,n=dt.from(e.canisterId),i=[...new Set(r)],s=i.map(c=>hc(c,n)),o=new Map,a=i.map((c,l)=>(async()=>{var h;try{let d=await t.readState(n,{paths:[s[l]]});if(t.rootKey==null)throw new Error("Agent is missing root key");let g=await Pr.create({certificate:d.certificate,rootKey:t.rootKey,canisterId:n,disableTimeVerification:!0}),w=(N,F)=>{if(F==="subnet"){if(t.rootKey==null)throw new Error("Agent is missing root key");let j=P0(d.certificate,n,t.rootKey);return{path:F,data:j}}else return{path:F,data:ue(N.lookup(hc(F,n)))}},{path:f,data:O}=w(g,i[l]);if(!O)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,An(O));break}case"controllers":{o.set(f,Dp(O));break}case"module_hash":{o.set(f,I0(O));break}case"subnet":{o.set(f,O);break}case"candid":{o.set(f,new TextDecoder().decode(O));break}default:if(typeof f!="string"&&"key"in f&&"path"in f)switch(f.decodeStrategy){case"raw":o.set(f.key,O);break;case"leb128":{o.set(f.key,uc(O));break}case"cbor":{o.set(f.key,k0(O));break}case"hex":{o.set(f.key,I0(O));break}case"utf-8":o.set(f.key,Lp(O))}}}catch(d){if(!((h=d?.message)===null||h===void 0)&&h.includes("Invalid certificate"))throw new Ft(d.message);typeof c!="string"&&"key"in c&&"path"in c?o.set(c.key,null):o.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(d),console.groupEnd()}})());return await Promise.all(a),o},P0=(e,t,r)=>{if(!t._isPrincipal)throw new Error("Invalid canisterId");let n=Se(new Uint8Array(e)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=dt.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=dt.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=dt.selfAuthenticating(dt.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!fc({canisterId:t,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=kr(["subnet",s.subnet_id,"node"],i);if(c.status!==$t.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let l=Xs(c.value),h=new Map;return l.forEach(d=>{let g=dt.from(new Uint8Array(d[1])).toText(),w=kr(["public_key"],d[2]);if(w.status!==$t.Found)throw new Error("Public key not found");let f=w.value;if(f.byteLength!==44)throw new Error("Invalid public key length");h.set(g,f)}),{subnetId:dt.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:h}},hc=(e,t)=>{let r=new TextEncoder,n=s=>new DataView(r.encode(s).buffer).buffer,i=new DataView(t.toUint8Array().buffer).buffer;switch(e){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 e&&"path"in e)if(typeof e.path=="string"||e.path instanceof ArrayBuffer){let s=e.path,o=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),o]}else return e.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${e} was formatted correctly.`)},I0=e=>Bt(e),k0=e=>Se(e),Lp=e=>new TextDecoder().decode(e),Dp=e=>k0(e).map(r=>dt.fromUint8Array(new Uint8Array(r)))});function M0(e,t=!1){return t?{h:Number(e&Ls),l:Number(e>>dc&Ls)}:{h:Number(e>>dc&Ls)|0,l:Number(e&Ls)|0}}function t1(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:s,l:o}=M0(e[i],t);[r[i],n[i]]=[s,o]}return[r,n]}function p1(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var Ls,dc,e1,r1,n1,i1,s1,o1,a1,c1,u1,f1,l1,h1,d1,m1,y1,g1,w1,b1,x1,_1,mt,C0=ht(()=>{Ls=BigInt(4294967295),dc=BigInt(32);e1=(e,t)=>BigInt(e>>>0)<<dc|BigInt(t>>>0),r1=(e,t,r)=>e>>>r,n1=(e,t,r)=>e<<32-r|t>>>r,i1=(e,t,r)=>e>>>r|t<<32-r,s1=(e,t,r)=>e<<32-r|t>>>r,o1=(e,t,r)=>e<<64-r|t>>>r-32,a1=(e,t,r)=>e>>>r-32|t<<64-r,c1=(e,t)=>t,u1=(e,t)=>e,f1=(e,t,r)=>e<<r|t>>>32-r,l1=(e,t,r)=>t<<r|e>>>32-r,h1=(e,t,r)=>t<<r-32|e>>>64-r,d1=(e,t,r)=>e<<r-32|t>>>64-r;m1=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),y1=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,g1=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),w1=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,b1=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),x1=(e,t,r,n,i,s)=>t+r+n+i+s+(e/2**32|0)|0,_1={fromBig:M0,split:t1,toBig:e1,shrSH:r1,shrSL:n1,rotrSH:i1,rotrSL:s1,rotrBH:o1,rotrBL:a1,rotr32H:c1,rotr32L:u1,rotlSH:f1,rotlSL:l1,rotlBH:h1,rotlBL:d1,add:p1,add3L:m1,add3H:y1,add4L:g1,add4H:w1,add5H:x1,add5L:b1},mt=_1});var E1,v1,Mr,Cr,pc,q0,V0=ht(()=>{Io();C0();an();[E1,v1]=mt.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(e=>BigInt(e))),Mr=new Uint32Array(80),Cr=new Uint32Array(80),pc=class extends cn{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:t,Al:r,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:l,El:h,Fh:d,Fl:g,Gh:w,Gl:f,Hh:O,Hl:N}=this;return[t,r,n,i,s,o,a,c,l,h,d,g,w,f,O,N]}set(t,r,n,i,s,o,a,c,l,h,d,g,w,f,O,N){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=h|0,this.Fh=d|0,this.Fl=g|0,this.Gh=w|0,this.Gl=f|0,this.Hh=O|0,this.Hl=N|0}process(t,r){for(let S=0;S<16;S++,r+=4)Mr[S]=t.getUint32(r),Cr[S]=t.getUint32(r+=4);for(let S=16;S<80;S++){let K=Mr[S-15]|0,_=Cr[S-15]|0,$=mt.rotrSH(K,_,1)^mt.rotrSH(K,_,8)^mt.shrSH(K,_,7),z=mt.rotrSL(K,_,1)^mt.rotrSL(K,_,8)^mt.shrSL(K,_,7),Y=Mr[S-2]|0,M=Cr[S-2]|0,it=mt.rotrSH(Y,M,19)^mt.rotrBH(Y,M,61)^mt.shrSH(Y,M,6),et=mt.rotrSL(Y,M,19)^mt.rotrBL(Y,M,61)^mt.shrSL(Y,M,6),rt=mt.add4L(z,et,Cr[S-7],Cr[S-16]),b=mt.add4H(rt,$,it,Mr[S-7],Mr[S-16]);Mr[S]=b|0,Cr[S]=rt|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:l,Dl:h,Eh:d,El:g,Fh:w,Fl:f,Gh:O,Gl:N,Hh:F,Hl:j}=this;for(let S=0;S<80;S++){let K=mt.rotrSH(d,g,14)^mt.rotrSH(d,g,18)^mt.rotrBH(d,g,41),_=mt.rotrSL(d,g,14)^mt.rotrSL(d,g,18)^mt.rotrBL(d,g,41),$=d&w^~d&O,z=g&f^~g&N,Y=mt.add5L(j,_,z,v1[S],Cr[S]),M=mt.add5H(Y,F,K,$,E1[S],Mr[S]),it=Y|0,et=mt.rotrSH(n,i,28)^mt.rotrBH(n,i,34)^mt.rotrBH(n,i,39),rt=mt.rotrSL(n,i,28)^mt.rotrBL(n,i,34)^mt.rotrBL(n,i,39),b=n&s^n&a^s&a,B=i&o^i&c^o&c;F=O|0,j=N|0,O=w|0,N=f|0,w=d|0,f=g|0,{h:d,l:g}=mt.add(l|0,h|0,M|0,it|0),l=a|0,h=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let V=mt.add3L(it,rt,B);n=mt.add3H(V,M,et,b),i=V|0}({h:n,l:i}=mt.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=mt.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=mt.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:h}=mt.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:d,l:g}=mt.add(this.Eh|0,this.El|0,d|0,g|0),{h:w,l:f}=mt.add(this.Fh|0,this.Fl|0,w|0,f|0),{h:O,l:N}=mt.add(this.Gh|0,this.Gl|0,O|0,N|0),{h:F,l:j}=mt.add(this.Hh|0,this.Hl|0,F|0,j|0),this.set(n,i,s,o,a,c,l,h,d,g,w,f,O,N,F,j)}roundClean(){Mr.fill(0),Cr.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)}},q0=Vn(()=>new pc)});function T1(e){let t=qs(e);return qe(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function $0(e){let t=T1(e),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=t,l=Ds<<BigInt(a*8)-ye,h=r.create,d=Le(t.n,t.nBitLength),g=t.uvRatio||((U,I)=>{try{return{isValid:!0,value:r.sqrt(U*r.inv(I))}}catch{return{isValid:!1,value:je}}}),w=t.adjustScalarBytes||(U=>U),f=t.domain||((U,I,G)=>{if(Sr("phflag",G),I.length||G)throw new Error("Contexts/pre-hash are not supported");return U});function O(U,I){Ce("coordinate "+U,I,je,l)}function N(U){if(!(U instanceof S))throw new Error("ExtendedPoint expected")}let F=hr((U,I)=>{let{ex:G,ey:J,ez:lt}=U,ct=U.is0();I==null&&(I=ct?B1:r.inv(lt));let Z=h(G*I),k=h(J*I),m=h(lt*I);if(ct)return{x:je,y:ye};if(m!==ye)throw new Error("invZ was invalid");return{x:Z,y:k}}),j=hr(U=>{let{a:I,d:G}=t;if(U.is0())throw new Error("bad point: ZERO");let{ex:J,ey:lt,ez:ct,et:Z}=U,k=h(J*J),m=h(lt*lt),tt=h(ct*ct),nt=h(tt*tt),ut=h(k*I),L=h(tt*h(ut+m)),u=h(nt+h(G*h(k*m)));if(L!==u)throw new Error("bad point: equation left != right (1)");let p=h(J*lt),y=h(ct*Z);if(p!==y)throw new Error("bad point: equation left != right (2)");return!0});class S{constructor(I,G,J,lt){this.ex=I,this.ey=G,this.ez=J,this.et=lt,O("x",I),O("y",G),O("z",J),O("t",lt),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(I){if(I instanceof S)throw new Error("extended point not allowed");let{x:G,y:J}=I||{};return O("x",G),O("y",J),new S(G,J,ye,h(G*J))}static normalizeZ(I){let G=r.invertBatch(I.map(J=>J.ez));return I.map((J,lt)=>J.toAffine(G[lt])).map(S.fromAffine)}static msm(I,G){return Cs(S,d,I,G)}_setWindowSize(I){$.setWindowSize(this,I)}assertValidity(){j(this)}equals(I){N(I);let{ex:G,ey:J,ez:lt}=this,{ex:ct,ey:Z,ez:k}=I,m=h(G*k),tt=h(ct*lt),nt=h(J*k),ut=h(Z*lt);return m===tt&&nt===ut}is0(){return this.equals(S.ZERO)}negate(){return new S(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){let{a:I}=t,{ex:G,ey:J,ez:lt}=this,ct=h(G*G),Z=h(J*J),k=h(Ds*h(lt*lt)),m=h(I*ct),tt=G+J,nt=h(h(tt*tt)-ct-Z),ut=m+Z,L=ut-k,u=m-Z,p=h(nt*L),y=h(ut*u),T=h(nt*u),v=h(L*ut);return new S(p,y,v,T)}add(I){N(I);let{a:G,d:J}=t,{ex:lt,ey:ct,ez:Z,et:k}=this,{ex:m,ey:tt,ez:nt,et:ut}=I;if(G===BigInt(-1)){let W=h((ct-lt)*(tt+m)),Q=h((ct+lt)*(tt-m)),ot=h(Q-W);if(ot===je)return this.double();let yt=h(Z*Ds*ut),vt=h(k*Ds*nt),Nt=vt+yt,pt=Q+W,at=vt-yt,Mt=h(Nt*ot),ze=h(pt*at),nr=h(Nt*at),ir=h(ot*pt);return new S(Mt,ze,ir,nr)}let L=h(lt*m),u=h(ct*tt),p=h(k*J*ut),y=h(Z*nt),T=h((lt+ct)*(m+tt)-L-u),v=y-p,A=y+p,q=h(u-G*L),x=h(T*v),R=h(A*q),C=h(T*q),P=h(v*A);return new S(x,R,P,C)}subtract(I){return this.add(I.negate())}wNAF(I){return $.wNAFCached(this,I,S.normalizeZ)}multiply(I){let G=I;Ce("scalar",G,ye,n);let{p:J,f:lt}=this.wNAF(G);return S.normalizeZ([J,lt])[0]}multiplyUnsafe(I){let G=I;return Ce("scalar",G,je,n),G===je?_:this.equals(_)||G===ye?this:this.equals(K)?this.wNAF(G).p:$.unsafeLadder(this,G)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return $.unsafeLadder(this,n).is0()}toAffine(I){return F(this,I)}clearCofactor(){let{h:I}=t;return I===ye?this:this.multiplyUnsafe(I)}static fromHex(I,G=!1){let{d:J,a:lt}=t,ct=r.BYTES;I=Yt("pointHex",I,ct),Sr("zip215",G);let Z=I.slice(),k=I[ct-1];Z[ct-1]=k&-129;let m=Nr(Z),tt=G?l:r.ORDER;Ce("pointHex.y",m,je,tt);let nt=h(m*m),ut=h(nt-ye),L=h(J*nt-lt),{isValid:u,value:p}=g(ut,L);if(!u)throw new Error("Point.fromHex: invalid y coordinate");let y=(p&ye)===ye,T=(k&128)!==0;if(!G&&p===je&&T)throw new Error("Point.fromHex: x=0 and x_0=1");return T!==y&&(p=h(-p)),S.fromAffine({x:p,y:m})}static fromPrivateKey(I){return M(I).point}toRawBytes(){let{x:I,y:G}=this.toAffine(),J=Jr(G,r.BYTES);return J[J.length-1]|=I&ye?128:0,J}toHex(){return Me(this.toRawBytes())}}S.BASE=new S(t.Gx,t.Gy,ye,h(t.Gx*t.Gy)),S.ZERO=new S(je,ye,ye,je);let{BASE:K,ZERO:_}=S,$=Ms(S,a*8);function z(U){return It(U,n)}function Y(U){return z(Nr(U))}function M(U){let I=a;U=Yt("private key",U,I);let G=Yt("hashed private key",s(U),2*I),J=w(G.slice(0,I)),lt=G.slice(I,2*I),ct=Y(J),Z=K.multiply(ct),k=Z.toRawBytes();return{head:J,prefix:lt,scalar:ct,point:Z,pointBytes:k}}function it(U){return M(U).pointBytes}function et(U=new Uint8Array,...I){let G=St(...I);return Y(s(f(G,Yt("context",U),!!i)))}function rt(U,I,G={}){U=Yt("message",U),i&&(U=i(U));let{prefix:J,scalar:lt,pointBytes:ct}=M(I),Z=et(G.context,J,U),k=K.multiply(Z).toRawBytes(),m=et(G.context,k,ct,U),tt=z(Z+m*lt);Ce("signature.s",tt,je,n);let nt=St(k,Jr(tt,r.BYTES));return Yt("result",nt,a*2)}let b=A1;function B(U,I,G,J=b){let{context:lt,zip215:ct}=J,Z=r.BYTES;U=Yt("signature",U,2*Z),I=Yt("message",I),ct!==void 0&&Sr("zip215",ct),i&&(I=i(I));let k=Nr(U.slice(Z,2*Z)),m,tt,nt;try{m=S.fromHex(G,ct),tt=S.fromHex(U.slice(0,Z),ct),nt=K.multiplyUnsafe(k)}catch{return!1}if(!ct&&m.isSmallOrder())return!1;let ut=et(lt,tt.toRawBytes(),m.toRawBytes(),I);return tt.add(m.multiplyUnsafe(ut)).subtract(nt).clearCofactor().equals(S.ZERO)}return K._setWindowSize(8),{CURVE:t,getPublicKey:it,sign:rt,verify:B,ExtendedPoint:S,utils:{getExtendedPublicKey:M,randomPrivateKey:()=>o(r.BYTES),precompute(U=8,I=S.BASE){return I._setWindowSize(U),I.multiply(BigInt(3)),I}}}}var je,ye,Ds,B1,A1,j0=ht(()=>{tc();dr();Ve();Ve();je=BigInt(0),ye=BigInt(1),Ds=BigInt(2),B1=BigInt(8),A1={zip215:!0}});function O1(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=mc,a=e*e%s*e%s,c=$e(a,G0,s)*a%s,l=$e(c,S1,s)*e%s,h=$e(l,N1,s)*l%s,d=$e(h,t,s)*h%s,g=$e(d,r,s)*d%s,w=$e(g,n,s)*g%s,f=$e(w,i,s)*w%s,O=$e(f,i,s)*w%s,N=$e(O,t,s)*h%s;return{pow_p_5_8:$e(N,G0,s)*e%s,b2:a}}function F1(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function U1(e,t){let r=mc,n=It(t*t*t,r),i=It(n*n*t,r),s=O1(e*i).pow_p_5_8,o=It(e*n*s,r),a=It(t*o*o,r),c=o,l=It(o*H0,r),h=a===e,d=a===It(-e,r),g=a===It(-e*H0,r);return h&&(o=c),(d||g)&&(o=l),d0(o,r)&&(o=It(-o,r)),{isValid:h||d,value:o}}var mc,H0,aw,S1,G0,cw,N1,R1,I1,P1,z0,Y0=ht(()=>{V0();an();j0();dr();mc=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),H0=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),aw=BigInt(0),S1=BigInt(1),G0=BigInt(2),cw=BigInt(3),N1=BigInt(5),R1=BigInt(8);I1=Le(mc,void 0,!0),P1={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:I1,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:R1,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:q0,randomBytes:Pi,adjustScalarBytes:F1,uvRatio:U1},z0=$0(P1)});var K0,fe,ne,gi,W0,Z0,to,X0=ht(()=>{K0=function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},fe=function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},to=class{constructor(t={}){ne.set(this,void 0),gi.set(this,void 0),this[W0]=this.entries.bind(this),this[Z0]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=t,i=Date.now();K0(this,ne,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),K0(this,gi,n,"f")}prune(){let t=Date.now();for(let[r,n]of fe(this,ne,"f").entries())t-n.timestamp>fe(this,gi,"f")&&fe(this,ne,"f").delete(r);return this}set(t,r){this.prune();let n={value:r,timestamp:Date.now()};return fe(this,ne,"f").set(t,n),this}get(t){let r=fe(this,ne,"f").get(t);if(r!==void 0){if(Date.now()-r.timestamp>fe(this,gi,"f")){fe(this,ne,"f").delete(t);return}return r.value}}clear(){fe(this,ne,"f").clear()}entries(){let t=fe(this,ne,"f").entries();return function*(){for(let[n,i]of t)yield[n,i.value]}()}values(){let t=fe(this,ne,"f").values();return function*(){for(let n of t)yield n.value}()}keys(){return fe(this,ne,"f").keys()}forEach(t,r){for(let[n,i]of fe(this,ne,"f").entries())t.call(r,i.value,n,this)}has(t){return fe(this,ne,"f").has(t)}delete(t){return fe(this,ne,"f").delete(t)}get size(){return fe(this,ne,"f").size}};ne=new WeakMap,gi=new WeakMap,W0=Symbol.iterator,Z0=Symbol.toStringTag});function L0(e,t){let r=2+J0(e.byteLength+1),n=t.byteLength+r+e.byteLength,i=0,s=new Uint8Array(1+J0(n)+n);return s[i++]=48,i+=Q0(s,i,n),s.set(t,i),i+=t.byteLength,s[i++]=3,i+=Q0(s,i,e.byteLength+1),s[i++]=0,s.set(new Uint8Array(e),i),s}var J0,Q0,yc,k1,hw,gc,dw,D0,wc=ht(()=>{de();J0=e=>{if(e<=127)return 1;if(e<=255)return 2;if(e<=65535)return 3;if(e<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},Q0=(e,t,r)=>{if(r<=127)return e[t]=r,1;if(r<=255)return e[t]=129,e[t+1]=r,2;if(r<=65535)return e[t]=130,e[t+1]=r>>8,e[t+2]=r,3;if(r<=16777215)return e[t]=131,e[t+1]=r>>16,e[t+2]=r>>8,e[t+3]=r,4;throw new Error("Length too long (> 4 bytes)")},yc=(e,t)=>{if(e[t]<128)return 1;if(e[t]===128)throw new Error("Invalid length 0");if(e[t]===129)return 2;if(e[t]===130)return 3;if(e[t]===131)return 4;throw new Error("Length too long (> 4 bytes)")},k1=(e,t)=>{let r=yc(e,t);if(r===1)return e[t];if(r===2)return e[t+1];if(r===3)return(e[t+1]<<8)+e[t+2];if(r===4)return(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];throw new Error("Length too long (> 4 bytes)")},hw=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),gc=Uint8Array.from([48,5,6,3,43,101,112]),dw=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);D0=(e,t)=>{let r=0,n=(a,c)=>{if(i[r++]!==a)throw new Error("Expected: "+c)},i=new Uint8Array(e);if(n(48,"sequence"),r+=yc(i,r),!zr(i.slice(r,r+t.byteLength),t))throw new Error("Not the expected OID.");r+=t.byteLength,n(3,"bit string");let s=k1(i,r)-1;r+=yc(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}});var tl,el,eo,ro,wi,bc=ht(()=>{wc();tl=function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},el=function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},wi=class e{constructor(t){if(eo.set(this,void 0),ro.set(this,void 0),t.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");tl(this,eo,t,"f"),tl(this,ro,e.derEncode(t),"f")}static from(t){return this.fromDer(t.toDer())}static fromRaw(t){return new e(t)}static fromDer(t){return new e(this.derDecode(t))}static derEncode(t){return L0(t,gc).buffer}static derDecode(t){let r=D0(t,gc);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return el(this,eo,"f")}get derKey(){return el(this,ro,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};eo=new WeakMap,ro=new WeakMap;wi.RAW_KEY_LENGTH=32});var xc,no,_c=ht(()=>{xc=class{constructor(){this.observers=[]}subscribe(t){this.observers.push(t)}unsubscribe(t){this.observers=this.observers.filter(r=>r!==t)}notify(t,...r){this.observers.forEach(n=>n(t,...r))}},no=class extends xc{constructor(){super()}print(t,...r){this.notify({message:t,level:"info"},...r)}warn(t,...r){this.notify({message:t,level:"warn"},...r)}error(t,r,...n){this.notify({message:t,level:"error",error:r},...n)}}});var De,ie,tr,io,so,oo,ao,co,uo,fo,Sn,bi,rl=ht(()=>{De=function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},ie=function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},bi=class e{constructor(t=e.default){tr.set(this,void 0),io.set(this,void 0),so.set(this,void 0),oo.set(this,void 0),ao.set(this,void 0),co.set(this,void 0),uo.set(this,void 0),fo.set(this,void 0),Sn.set(this,0);let{initialInterval:r=500,randomizationFactor:n=.5,multiplier:i=1.5,maxInterval:s=6e4,maxElapsedTime:o=9e5,maxIterations:a=10,date:c=Date}=t;De(this,tr,r,"f"),De(this,io,n,"f"),De(this,so,i,"f"),De(this,oo,s,"f"),De(this,fo,c,"f"),De(this,ao,c.now(),"f"),De(this,co,o,"f"),De(this,uo,a,"f")}get ellapsedTimeInMsec(){return ie(this,fo,"f").now()-ie(this,ao,"f")}get currentInterval(){return ie(this,tr,"f")}get count(){return ie(this,Sn,"f")}get randomValueFromInterval(){let t=ie(this,io,"f")*ie(this,tr,"f"),r=ie(this,tr,"f")-t,n=ie(this,tr,"f")+t;return Math.random()*(n-r)+r}incrementCurrentInterval(){var t;return De(this,tr,Math.min(ie(this,tr,"f")*ie(this,so,"f"),ie(this,oo,"f")),"f"),De(this,Sn,(t=ie(this,Sn,"f"),t++,t),"f"),ie(this,tr,"f")}next(){return this.ellapsedTimeInMsec>=ie(this,co,"f")||ie(this,Sn,"f")>=ie(this,uo,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};tr=new WeakMap,io=new WeakMap,so=new WeakMap,oo=new WeakMap,ao=new WeakMap,co=new WeakMap,uo=new WeakMap,fo=new WeakMap,Sn=new WeakMap;bi.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date}});function G1(){let e;if(typeof window<"u")if(window.fetch)e=window.fetch.bind(window);else throw new Ei("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof globalThis<"u")if(globalThis.fetch)e=globalThis.fetch.bind(globalThis);else throw new Ei("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&&(e=self.fetch.bind(self));if(e)return e;throw new Ei("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function z1(e){let t;if(e!==void 0)!e.match(/^[a-z]+:/)&&typeof window<"u"?t=new URL(window.location.protocol+"//"+e):t=new URL(e);else{let r=["ic0.app","icp0.io","127.0.0.1","localhost"],n=[".github.dev",".gitpod.io"],i=typeof window<"u"?window.location:void 0,s=i?.hostname,o;s&&typeof s=="string"&&(n.some(a=>s.endsWith(a))?o=s:o=r.find(a=>s.endsWith(a))),i&&o?t=new URL(`${i.protocol}//${o}${i.port?":"+i.port:""}`):t=new URL("https://icp-api.io")}return t.toString()}var te,D,se,Lr,In,er,yr,Fn,xi,Nn,He,Ge,Dr,tn,_i,Rn,On,en,nn,nl,ho,po,rn,rr,lo,M1,U0,C1,q1,V1,$1,j1,H1,Ei,Un,Pn,Ec=ht(()=>{we();dn();Ta();ni();ei();de();As();si();Rs();yi();Tn();Y0();X0();bc();Ys();_c();rl();As();Rs();si();te=function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},D=function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)};(function(e){e.Received="received",e.Processing="processing",e.Replied="replied",e.Rejected="rejected",e.Unknown="unknown",e.Done="done"})(rr||(rr={}));lo=60*1e3,M1="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae",U0="aaaaa-aa",C1="ic0.app",q1=".ic0.app",V1="icp0.io",$1=".icp0.io",j1="icp-api.io",H1=".icp-api.io",Ei=class extends Ft{constructor(t){super(t),this.message=t}},Un=class extends Ft{constructor(t){super(t),this.message=t}};Pn=class e{constructor(t={}){var r,n;se.add(this),Lr.set(this,null),In.set(this,!1),er.set(this,void 0),yr.set(this,void 0),Fn.set(this,void 0),xi.set(this,void 0),Nn.set(this,0),He.set(this,void 0),Ge.set(this,void 0),Dr.set(this,void 0),tn.set(this,void 0),this._isAgent=!0,this.config={},_i.set(this,0),this.log=new no,Rn.set(this,[]),On.set(this,[]),en.set(this,new to({expirationTime:5*60*1e3})),nn.set(this,!0),po.set(this,(o,a)=>{if(D(this,nn,"f")===!1)return o;if(!a)throw new _e("Invalid signature from replica signed query: no matching node key found.");let{status:c,signatures:l=[],requestId:h}=o,d=new TextEncoder().encode("\vic-response");for(let g of l){let{timestamp:w,identity:f}=g,O=dt.fromUint8Array(f).toText(),N;if(c==="replied"){let{reply:_}=o;N=ti({status:c,reply:_,timestamp:BigInt(w),request_id:h})}else if(c==="rejected"){let{reject_code:_,reject_message:$,error_code:z}=o;N=ti({status:c,reject_code:_,reject_message:$,error_code:z,timestamp:BigInt(w),request_id:h})}else throw new Error(`Unknown status: ${c}`);let F=oe(d,new Uint8Array(N)),j=a?.nodeKeys.get(O);if(!j)throw new _e("Invalid signature from replica signed query: no matching node key found.");let S=wi.fromDer(j).rawKey;if(z0.verify(g.signature,new Uint8Array(F),new Uint8Array(S)))return o;throw new _e(`Invalid signature from replica ${O} signed query.`)}return o}),this.config=t,te(this,yr,t.fetch||G1()||fetch.bind(globalThis),"f"),te(this,Fn,t.fetchOptions,"f"),te(this,xi,t.callOptions,"f"),te(this,In,(r=t.shouldFetchRootKey)!==null&&r!==void 0?r:!1,"f"),t.rootKey?this.rootKey=t.rootKey:D(this,In,"f")?this.rootKey=null:this.rootKey=Gr(M1);let i=z1(t.host);this.host=new URL(i),t.verifyQuerySignatures!==void 0&&te(this,nn,t.verifyQuerySignatures,"f"),te(this,Ge,(n=t.retryTimes)!==null&&n!==void 0?n:3,"f");let s=()=>new bi({maxIterations:D(this,Ge,"f")});if(te(this,Dr,t.backoffStrategy||s,"f"),this.host.hostname.endsWith(q1)?this.host.hostname=C1:this.host.hostname.endsWith($1)?this.host.hostname=V1:this.host.hostname.endsWith(H1)&&(this.host.hostname=j1),t.credentials){let{name:o,password:a}=t.credentials;te(this,He,`${o}${a?":"+a:""}`,"f")}if(te(this,er,Promise.resolve(t.identity||new Ar),"f"),t.ingressExpiryInMinutes&&t.ingressExpiryInMinutes>5)throw new Ft(`The maximum ingress expiry time is 5 minutes. Provided ingress expiry time is ${t.ingressExpiryInMinutes} minutes.`);if(t.ingressExpiryInMinutes&&t.ingressExpiryInMinutes<=0)throw new Ft(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${t.ingressExpiryInMinutes} minutes.`);te(this,tn,t.ingressExpiryInMinutes||5,"f"),this.addTransform("update",Ca(bn)),t.useQueryNonces&&this.addTransform("query",Ca(bn)),t.logToConsole&&this.log.subscribe(o=>{o.level==="error"?console.error(o.message):o.level==="warn"?console.warn(o.message):console.log(o.message)})}get waterMark(){return D(this,_i,"f")}static createSync(t={}){return new this(Object.assign({},t))}static async create(t={shouldFetchRootKey:!1}){let r=e.createSync(t),n=[r.syncTime()];return r.host.toString()!=="https://icp-api.io"&&t.shouldFetchRootKey&&n.push(r.fetchRootKey()),await Promise.all(n),r}static async from(t){var r;try{return"config"in t?await e.create(t.config):await e.create({fetch:t._fetch,fetchOptions:t._fetchOptions,callOptions:t._callOptions,host:t._host.toString(),identity:(r=t._identity)!==null&&r!==void 0?r:void 0})}catch{throw new Ft("Failed to create agent from provided agent")}}isLocal(){let t=this.host.hostname;return t==="127.0.0.1"||t.endsWith("127.0.0.1")}addTransform(t,r,n=r.priority||0){if(t==="update"){let i=D(this,On,"f").findIndex(s=>(s.priority||0)<n);D(this,On,"f").splice(i>=0?i:D(this,On,"f").length,0,Object.assign(r,{priority:n}))}else if(t==="query"){let i=D(this,Rn,"f").findIndex(s=>(s.priority||0)<n);D(this,Rn,"f").splice(i>=0?i:D(this,Rn,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!D(this,er,"f"))throw new Un("This identity has expired due this application's security policy. Please refresh your authentication.");return(await D(this,er,"f")).getPrincipal()}async call(t,r,n){var i,s;await D(this,se,"m",rn).call(this);let o=(i=r.callSync)!==null&&i!==void 0?i:!0,a=await(n!==void 0?await n:await D(this,er,"f"));if(!a)throw new Un("This identity has expired due this application's security policy. Please refresh your authentication.");let c=dt.from(t),l=r.effectiveCanisterId?dt.from(r.effectiveCanisterId):c,h=a.getPrincipal()||dt.anonymous(),d=new Xr(D(this,tn,"f")*lo);Math.abs(D(this,Nn,"f"))>1e3*30&&(d=new Xr(D(this,tn,"f")*lo+D(this,Nn,"f")));let g={request_type:Bs.Call,canister_id:c,method_name:r.methodName,arg:r.arg,sender:h,ingress_expiry:d},w=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},D(this,He,"f")?{Authorization:"Basic "+btoa(D(this,He,"f"))}:{})},endpoint:"call",body:g}),f=w.body.nonce?O(w.body.nonce):void 0;g.nonce=f;function O(S){return new Uint8Array(S)}w=await a.transformRequest(w);let N=Es(w.body),F=D(this,Dr,"f").call(this),j=ms(g);try{let S=()=>(this.log.print(`fetching "/api/v3/canister/${l.toText()}/call" with request:`,w),D(this,yr,"f").call(this,""+new URL(`/api/v3/canister/${l.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},D(this,xi,"f")),w.request),{body:N}))),K=()=>(this.log.print(`fetching "/api/v2/canister/${l.toText()}/call" with request:`,w),D(this,yr,"f").call(this,""+new URL(`/api/v2/canister/${l.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},D(this,xi,"f")),w.request),{body:N}))),$=await D(this,se,"m",ho).call(this,{request:o?S:K,backoff:F,tries:0}),z=await $.arrayBuffer(),Y=$.status===200&&z.byteLength>0?Se(z):null;if(Y&&"certificate"in Y){let M=await this.parseTimeFromResponse({certificate:Y.certificate});te(this,_i,M,"f")}return{requestId:j,response:{ok:$.ok,status:$.status,statusText:$.statusText,body:Y,headers:xn($.headers)},requestDetails:g}}catch(S){if(S.message.includes("v3 api not supported."))return this.log.warn("v3 api not supported. Fall back to v2"),this.call(t,Object.assign(Object.assign({},r),{callSync:!1}),n);let K=`Error while making call: ${(s=S.message)!==null&&s!==void 0?s:String(S)}`,_=new Ts(K,S,Bt(j),Bt(w.body.sender_pubkey),Bt(w.body.sender_sig),String(w.body.content.ingress_expiry._value));throw this.log.error(K,_),_}}async query(t,r,n){var i,s,o,a;await D(this,se,"m",rn).call(this);let c=D(this,Dr,"f").call(this),l=r.effectiveCanisterId?dt.from(r.effectiveCanisterId):dt.from(t);this.log.print(`ecid ${l.toString()}`),this.log.print(`canisterId ${t.toString()}`);let h,d,g=await(n!==void 0?n:D(this,er,"f"));if(!g)throw new Un("This identity has expired due this application's security policy. Please refresh your authentication.");let w=dt.from(t),f=g?.getPrincipal()||dt.anonymous(),O={request_type:"query",canister_id:w,method_name:r.methodName,arg:r.arg,sender:f,ingress_expiry:new Xr(D(this,tn,"f")*lo)},N=ms(O);h=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},D(this,He,"f")?{Authorization:"Basic "+btoa(D(this,He,"f"))}:{})},endpoint:"read",body:O}),h=await g?.transformRequest(h);let F=Es(h.body),j={canister:w.toText(),ecid:l,transformedRequest:h,body:F,requestId:N,backoff:c,tries:0},S=async()=>({requestDetails:O,query:await D(this,se,"m",nl).call(this,j)}),K=async()=>{if(!D(this,nn,"f"))return;let _=D(this,en,"f").get(l.toString());return _||(await this.fetchSubnetKeys(l.toString()),D(this,en,"f").get(l.toString()))};try{let[_,$]=await Promise.all([S(),K()]);d=_;let{requestDetails:z,query:Y}=d,M=Object.assign(Object.assign({},Y),{requestDetails:z});if(this.log.print("Query response:",M),!D(this,nn,"f"))return M;try{return D(this,po,"f").call(this,M,$)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),D(this,en,"f").delete(t.toString()),await this.fetchSubnetKeys(l.toString());let et=D(this,en,"f").get(t.toString());if(!et)throw new _e("Invalid signature from replica signed query: no matching node key found.");return D(this,po,"f").call(this,M,et)}}catch(_){let $=`Error while making call: ${(i=_.message)!==null&&i!==void 0?i:String(_)}`,z=new Ss($,_,String(N),Bt((s=h?.body)===null||s===void 0?void 0:s.sender_pubkey),Bt((o=h?.body)===null||o===void 0?void 0:o.sender_sig),String((a=h?.body)===null||a===void 0?void 0:a.content.ingress_expiry._value));throw this.log.error($,z),z}}async createReadStateRequest(t,r){await D(this,se,"m",rn).call(this);let n=await(r!==void 0?await r:await D(this,er,"f"));if(!n)throw new Un("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||dt.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},D(this,He,"f")?{Authorization:"Basic "+btoa(D(this,He,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:t.paths,sender:i,ingress_expiry:new Xr(D(this,tn,"f")*lo)}});return n?.transformRequest(s)}async readState(t,r,n,i){var s,o,a,c;function l(O){for(let N of O.paths){let[F,j]=N,S=new TextEncoder().encode("request_status");if(zr(F,S))return j}}let h=l(r);await D(this,se,"m",rn).call(this);let d=typeof t=="string"?dt.fromText(t):t,g=i??await this.createReadStateRequest(r,n),w=Es(g.body);this.log.print(`fetching "/api/v2/canister/${d}/read_state" with request:`,g);let f=D(this,Dr,"f").call(this);try{let O=await D(this,se,"m",ho).call(this,{request:()=>D(this,yr,"f").call(this,""+new URL(`/api/v2/canister/${d.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},D(this,Fn,"f")),g.request),{body:w})),backoff:f,tries:0});if(!O.ok)throw new Error(`Server returned an error:
15
- Code: ${O.status} (${O.statusText})
16
- Body: ${await O.text()}
17
- `);let N=Se(await O.arrayBuffer());this.log.print("Read state response:",N);let F=await this.parseTimeFromResponse(N);return F>0&&(this.log.print("Read state response time:",F),te(this,_i,F,"f")),N}catch(O){let N=`Caught exception while attempting to read state: ${(s=O.message)!==null&&s!==void 0?s:String(O)}`,F=new Ns(N,O,String(h),Bt((o=g?.body)===null||o===void 0?void 0:o.sender_pubkey),Bt((a=g?.body)===null||a===void 0?void 0:a.sender_sig),String((c=g?.body)===null||c===void 0?void 0:c.content.ingress_expiry._value));throw this.log.error(N,F),F}}async parseTimeFromResponse(t){let r;if(t.certificate){let n=Se(t.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=kr(["time"],r);if(i.status!==$t.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=An(Zo(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(t){await D(this,se,"m",rn).call(this);let r=await Promise.resolve().then(()=>(yi(),Qs)),n=Date.now();try{t||this.log.print("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let i=e.createSync({identity:new Ar,host:this.host.toString(),fetch:D(this,yr,"f"),retryTimes:0}),o=(await r.request({canisterId:t??dt.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:i,paths:["time"]})).get("time");o&&(te(this,Nn,Number(o)-Number(n),"f"),this.log.notify({message:`Syncing time: offset of ${D(this,Nn,"f")}`,level:"info"}))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let t=D(this,He,"f")?{Authorization:"Basic "+btoa(D(this,He,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=D(this,Dr,"f").call(this),n=await D(this,se,"m",ho).call(this,{backoff:r,request:()=>D(this,yr,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:t},D(this,Fn,"f"))),tries:0});return Se(await n.arrayBuffer())}async fetchRootKey(){let t;return D(this,Lr,"f")?t=await D(this,Lr,"f"):(te(this,Lr,new Promise((r,n)=>{this.status().then(i=>{let s=i.root_key;this.rootKey=s,r(s)}).catch(n)}),"f"),t=await D(this,Lr,"f")),te(this,Lr,null,"f"),t}invalidateIdentity(){te(this,er,null,"f")}replaceIdentity(t){te(this,er,Promise.resolve(t),"f")}async fetchSubnetKeys(t){await D(this,se,"m",rn).call(this);let r=dt.from(t),i=(await Js({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return D(this,en,"f").set(r.toText(),i),i}_transform(t){let r=Promise.resolve(t);if(t.endpoint==="call")for(let n of D(this,On,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of D(this,Rn,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};Lr=new WeakMap,In=new WeakMap,er=new WeakMap,yr=new WeakMap,Fn=new WeakMap,xi=new WeakMap,Nn=new WeakMap,He=new WeakMap,Ge=new WeakMap,Dr=new WeakMap,tn=new WeakMap,_i=new WeakMap,Rn=new WeakMap,On=new WeakMap,en=new WeakMap,nn=new WeakMap,po=new WeakMap,se=new WeakSet,nl=async function e(t){var r,n;let{ecid:i,transformedRequest:s,body:o,requestId:a,backoff:c,tries:l}=t,h=l===0?0:c.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:l,backoff:c,delay:h}),h===null)throw new Ft(`Timestamp failed to pass the watermark after retrying the configured ${D(this,Ge,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);h>0&&await new Promise(f=>setTimeout(f,h));let d;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let f=await D(this,yr,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},D(this,Fn,"f")),s.request),{body:o}));if(f.status===200){let O=Se(await f.arrayBuffer());d=Object.assign(Object.assign({},O),{httpDetails:{ok:f.ok,status:f.status,statusText:f.statusText,headers:xn(f.headers)},requestId:a})}else throw new _n(`Gateway returned an error:
18
- Code: ${f.status} (${f.statusText})
19
- Body: ${await f.text()}
20
- `,{ok:f.ok,status:f.status,statusText:f.statusText,headers:xn(f.headers)})}catch(f){if(l<D(this,Ge,"f"))return this.log.warn(`Caught exception while attempting to make query:
21
- ${f}
22
- Retrying query.`),await D(this,se,"m",e).call(this,Object.assign(Object.assign({},t),{tries:l+1}));throw f}let g=(n=(r=d.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!D(this,nn,"f"))return d;if(!g)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let w=Number(BigInt(g)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:w}),Number(this.waterMark)>w){let f=new Ft("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",f,{timestamp:g,waterMark:this.waterMark}),l<D(this,Ge,"f"))return await D(this,se,"m",e).call(this,Object.assign(Object.assign({},t),{tries:l+1}));throw new Ft(`Timestamp failed to pass the watermark after retrying the configured ${D(this,Ge,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return d},ho=async function e(t){let{request:r,backoff:n,tries:i}=t,s=i===0?0:n.next();if(s===null)throw new Ft(`Timestamp failed to pass the watermark after retrying the configured ${D(this,Ge,"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(D(this,Ge,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
23
- ${l}
24
- Retrying request.`),await D(this,se,"m",e).call(this,{request:r,backoff:n,tries:i+1});throw l}if(o.ok)return o;let a=await o.clone().text(),c=`Server returned an error:
25
- Code: ${o.status} (${o.statusText})
26
- Body: ${a}
27
- `;if(o.status===404&&o.url.includes("api/v3"))throw new _n("v3 api not supported. Fall back to v2",{ok:o.ok,status:o.status,statusText:o.statusText,headers:xn(o.headers)});if(i<D(this,Ge,"f"))return await D(this,se,"m",e).call(this,{request:r,backoff:n,tries:i+1});throw new _n(c,{ok:o.ok,status:o.status,statusText:o.statusText,headers:xn(o.headers)})},rn=async function(){if(!this.rootKey)if(this.rootKey===null&&D(this,In,"f"))await this.fetchRootKey();else throw new Ft(`Invalid root key detected. The root key for this agent is ${this.rootKey} and the shouldFetchRootKey value is set to ${D(this,In,"f")}. The root key should only be unknown if you are in local development. Otherwise you should avoid fetching and use the default IC Root Key or the known root key of your environment.`)}});var il,sl=ht(()=>{we();(function(e){e.Error="err",e.GetPrincipal="gp",e.GetPrincipalResponse="gpr",e.Query="q",e.QueryResponse="qr",e.Call="c",e.CallResponse="cr",e.ReadState="rs",e.ReadStateResponse="rsr",e.Status="s",e.StatusResponse="sr"})(il||(il={}))});function vc(){let e=typeof window>"u"?typeof globalThis>"u"?typeof self>"u"?void 0:self.ic.agent:globalThis.ic.agent:window.ic.agent;if(!e)throw new Error("No Agent could be found.");return e}var mi=ht(()=>{Ko();Ec();Rs();sl()});we();var dl=sn(gu());mi();dn();Xn();mi();Tn();de();var yo={};qn(yo,{backoff:()=>ul,chain:()=>fl,conditionalDelay:()=>al,defaultStrategy:()=>mo,maxAttempts:()=>K1,once:()=>ol,throttle:()=>W1,timeout:()=>cl});de();var Y1=5*60*1e3;function mo(){return fl(al(ol(),1e3),ul(1e3,1.2),cl(Y1))}function ol(){let e=!0;return async()=>e?(e=!1,!0):!1}function al(e,t){return async(r,n,i)=>{if(await e(r,n,i))return new Promise(s=>setTimeout(s,t))}}function K1(e){let t=e;return async(r,n,i)=>{if(--t<=0)throw new Error(`Failed to retrieve a reply for request after ${e} attempts:
28
- Request ID: ${Bt(n)}
29
- Request status: ${i}
30
- `)}}function W1(e){return()=>new Promise(t=>setTimeout(t,e))}function cl(e){let t=Date.now()+e;return async(r,n,i)=>{if(Date.now()>t)throw new Error(`Request timed out after ${e} msec:
31
- Request ID: ${Bt(n)}
32
- Request status: ${i}
33
- `)}}function ul(e,t){let r=e;return()=>new Promise(n=>setTimeout(()=>{r*=t,n()},r))}function fl(...e){return async(t,r,n)=>{for(let i of e)await i(t,r,n)}}async function Bc(e,t,r,n=mo(),i,s){var o;let a=[new TextEncoder().encode("request_status"),r],c=i??await((o=e.createReadStateRequest)===null||o===void 0?void 0:o.call(e,{paths:[a]})),l=await e.readState(t,{paths:[a]},void 0,c);if(e.rootKey==null)throw new Error("Agent root key not initialized before polling");let h=await Pr.create({certificate:l.certificate,rootKey:e.rootKey,canisterId:t,blsVerify:s}),d=ue(h.lookup([...a,new TextEncoder().encode("status")])),g;switch(typeof d>"u"?g=rr.Unknown:g=new TextDecoder().decode(d),g){case rr.Replied:return{reply:ue(h.lookup([...a,"reply"])),certificate:h};case rr.Received:case rr.Unknown:case rr.Processing:return await n(t,r,g),Bc(e,t,r,n,c,s);case rr.Rejected:{let w=new Uint8Array(ue(h.lookup([...a,"reject_code"])))[0],f=new TextDecoder().decode(ue(h.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
34
- Request ID: ${Bt(r)}
35
- Reject code: ${w}
36
- Reject text: ${f}
37
- `)}case rr.Done:throw new Error(`Call was marked as done but we never saw the reply:
38
- Request ID: ${Bt(r)}
39
- `)}throw new Error("unreachable")}we();de();Tn();var ll=({IDL:e})=>{let t=e.Variant({mainnet:e.Null,testnet:e.Null}),r=e.Text,n=e.Record({network:t,address:r,min_confirmations:e.Opt(e.Nat32)}),i=e.Nat64,s=i,o=e.Nat32,a=e.Record({start_height:o,end_height:e.Opt(o),network:t}),c=e.Vec(e.Nat8),l=e.Record({tip_height:o,block_headers:e.Vec(c)}),h=e.Record({network:t}),d=e.Nat64,g=e.Vec(d),w=e.Record({network:t,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:r}),f=e.Vec(e.Nat8),O=e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32}),N=e.Record({height:e.Nat32,value:i,outpoint:O}),F=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:o,tip_block_hash:f,utxos:e.Vec(N)}),j=e.Record({transaction:e.Vec(e.Nat8),network:t}),S=e.Principal,K=e.Record({canister_id:S,num_requested_changes:e.Opt(e.Nat64)}),_=e.Variant({from_user:e.Record({user_id:e.Principal}),from_canister:e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal})}),$=e.Vec(e.Nat8),z=e.Variant({creation:e.Record({controllers:e.Vec(e.Principal)}),code_deployment:e.Record({mode:e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),module_hash:e.Vec(e.Nat8)}),load_snapshot:e.Record({canister_version:e.Nat64,taken_at_timestamp:e.Nat64,snapshot_id:$}),controllers_change:e.Record({controllers:e.Vec(e.Principal)}),code_uninstall:e.Null}),Y=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:_,details:z}),M=e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec(Y),total_num_changes:e.Nat64}),it=e.Record({canister_id:S}),et=e.Variant({controllers:e.Null,public:e.Null,allowed_viewers:e.Vec(e.Principal)}),rt=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),reserved_cycles_limit:e.Nat,log_visibility:et,wasm_memory_limit:e.Nat,memory_allocation:e.Nat,compute_allocation:e.Nat}),b=e.Record({status:e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),memory_size:e.Nat,cycles:e.Nat,settings:rt,query_stats:e.Record({response_payload_bytes_total:e.Nat,num_instructions_total:e.Nat,num_calls_total:e.Nat,request_payload_bytes_total:e.Nat}),idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8)),reserved_cycles:e.Nat}),B=e.Record({canister_id:S}),V=e.Record({freezing_threshold:e.Opt(e.Nat),controllers:e.Opt(e.Vec(e.Principal)),reserved_cycles_limit:e.Opt(e.Nat),log_visibility:e.Opt(et),wasm_memory_limit:e.Opt(e.Nat),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),U=e.Record({settings:e.Opt(V),sender_canister_version:e.Opt(e.Nat64)}),I=e.Record({canister_id:S}),G=e.Record({canister_id:S}),J=e.Record({canister_id:S,snapshot_id:$}),lt=e.Record({canister_id:S}),ct=e.Variant({secp256k1:e.Null}),Z=e.Record({key_id:e.Record({name:e.Text,curve:ct}),canister_id:e.Opt(S),derivation_path:e.Vec(e.Vec(e.Nat8))}),k=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),m=e.Record({canister_id:S}),tt=e.Record({idx:e.Nat64,timestamp_nanos:e.Nat64,content:e.Vec(e.Nat8)}),nt=e.Record({canister_log_records:e.Vec(tt)}),ut=e.Record({value:e.Text,name:e.Text}),L=e.Record({status:e.Nat,body:e.Vec(e.Nat8),headers:e.Vec(ut)}),u=e.Record({url:e.Text,method:e.Variant({get:e.Null,head:e.Null,post:e.Null}),max_response_bytes:e.Opt(e.Nat64),body:e.Opt(e.Vec(e.Nat8)),transform:e.Opt(e.Record({function:e.Func([e.Record({context:e.Vec(e.Nat8),response:L})],[L],["query"]),context:e.Vec(e.Nat8)})),headers:e.Vec(ut)}),p=e.Variant({reinstall:e.Null,upgrade:e.Opt(e.Record({wasm_memory_persistence:e.Opt(e.Variant({keep:e.Null,replace:e.Null})),skip_pre_upgrade:e.Opt(e.Bool)})),install:e.Null}),y=e.Record({hash:e.Vec(e.Nat8)}),T=e.Record({arg:e.Vec(e.Nat8),wasm_module_hash:e.Vec(e.Nat8),mode:p,chunk_hashes_list:e.Vec(y),target_canister:S,store_canister:e.Opt(S),sender_canister_version:e.Opt(e.Nat64)}),v=e.Vec(e.Nat8),A=e.Record({arg:e.Vec(e.Nat8),wasm_module:v,mode:p,canister_id:S,sender_canister_version:e.Opt(e.Nat64)}),q=e.Record({canister_id:S}),x=e.Record({id:$,total_size:e.Nat64,taken_at_timestamp:e.Nat64}),R=e.Vec(x),C=e.Record({canister_id:S,sender_canister_version:e.Opt(e.Nat64),snapshot_id:$}),P=e.Record({start_at_timestamp_nanos:e.Nat64,subnet_id:e.Principal}),W=e.Record({num_block_failures_total:e.Nat64,node_id:e.Principal,num_blocks_proposed_total:e.Nat64}),Q=e.Vec(e.Record({timestamp_nanos:e.Nat64,node_metrics:e.Vec(W)})),ot=e.Record({settings:e.Opt(V),specified_id:e.Opt(S),amount:e.Opt(e.Nat),sender_canister_version:e.Opt(e.Nat64)}),yt=e.Record({canister_id:S}),vt=e.Record({canister_id:S,amount:e.Nat}),Nt=e.Vec(e.Nat8),pt=e.Variant({ed25519:e.Null,bip340secp256k1:e.Null}),at=e.Record({key_id:e.Record({algorithm:pt,name:e.Text}),canister_id:e.Opt(S),derivation_path:e.Vec(e.Vec(e.Nat8))}),Mt=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),ze=e.Record({key_id:e.Record({name:e.Text,curve:ct}),derivation_path:e.Vec(e.Vec(e.Nat8)),message_hash:e.Vec(e.Nat8)}),nr=e.Record({signature:e.Vec(e.Nat8)}),ir=e.Variant({bip341:e.Record({merkle_root_hash:e.Vec(e.Nat8)})}),le=e.Record({aux:e.Opt(ir),key_id:e.Record({algorithm:pt,name:e.Text}),derivation_path:e.Vec(e.Vec(e.Nat8)),message:e.Vec(e.Nat8)}),_t=e.Record({signature:e.Vec(e.Nat8)}),ee=e.Record({canister_id:S}),Kt=e.Record({canister_id:S}),Rt=e.Record({canister_id:S}),Eo=e.Vec(y),vo=e.Record({subnet_id:e.Principal}),Ot=e.Record({replica_version:e.Text}),Bo=e.Record({replace_snapshot:e.Opt($),canister_id:S}),Ao=x,To=e.Record({canister_id:S,sender_canister_version:e.Opt(e.Nat64)}),So=e.Record({canister_id:e.Principal,settings:V,sender_canister_version:e.Opt(e.Nat64)}),No=e.Record({chunk:e.Vec(e.Nat8),canister_id:e.Principal}),gr=y;return e.Service({bitcoin_get_balance:e.Func([n],[s],[]),bitcoin_get_block_headers:e.Func([a],[l],[]),bitcoin_get_current_fee_percentiles:e.Func([h],[g],[]),bitcoin_get_utxos:e.Func([w],[F],[]),bitcoin_send_transaction:e.Func([j],[],[]),canister_info:e.Func([K],[M],[]),canister_status:e.Func([it],[b],[]),clear_chunk_store:e.Func([B],[],[]),create_canister:e.Func([U],[I],[]),delete_canister:e.Func([G],[],[]),delete_canister_snapshot:e.Func([J],[],[]),deposit_cycles:e.Func([lt],[],[]),ecdsa_public_key:e.Func([Z],[k],[]),fetch_canister_logs:e.Func([m],[nt],["query"]),http_request:e.Func([u],[L],[]),install_chunked_code:e.Func([T],[],[]),install_code:e.Func([A],[],[]),list_canister_snapshots:e.Func([q],[R],[]),load_canister_snapshot:e.Func([C],[],[]),node_metrics_history:e.Func([P],[Q],[]),provisional_create_canister_with_cycles:e.Func([ot],[yt],[]),provisional_top_up_canister:e.Func([vt],[],[]),raw_rand:e.Func([],[Nt],[]),schnorr_public_key:e.Func([at],[Mt],[]),sign_with_ecdsa:e.Func([ze],[nr],[]),sign_with_schnorr:e.Func([le],[_t],[]),start_canister:e.Func([ee],[],[]),stop_canister:e.Func([Kt],[],[]),stored_chunks:e.Func([Rt],[Eo],[]),subnet_info:e.Func([vo],[Ot],[]),take_canister_snapshot:e.Func([Bo],[Ao],[]),uninstall_code:e.Func([To],[],[]),update_settings:e.Func([So],[],[]),upload_chunk:e.Func([No],[gr],[])})};var go=class extends Ft{constructor(t,r,n,i){super(["Call failed:",` Canister: ${t.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(s=>` "${s}": ${JSON.stringify(i[s])}`)].join(`
40
- `)),this.canisterId=t,this.methodName=r,this.type=n,this.props=i}},Ac=class extends go{constructor(t,r,n){var i;super(t,r,"query",{Status:n.status,Code:(i=Hn[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},wo=class extends go{constructor(t,r,n,i,s,o,a){super(t,r,"update",Object.assign({"Request ID":Bt(n)},i.body?Object.assign(Object.assign({},a?{"Error code":a}:{}),{"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=a}},Ne=Symbol.for("ic-agent-metadata"),qr=class e{constructor(t){this[Ne]=Object.freeze(t)}static agentOf(t){return t[Ne].config.agent}static interfaceOf(t){return t[Ne].service}static canisterIdOf(t){return dt.from(t[Ne].config.canisterId)}static async install(t,r){let n=t.mode===void 0?{install:null}:t.mode,i=t.arg?[...new Uint8Array(t.arg)]:[],s=[...new Uint8Array(t.module)],o=typeof r.canisterId=="string"?dt.fromText(r.canisterId):r.canisterId;await hl(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(t,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await hl(t||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(t,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(t,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(t,r){let n=t({IDL:Br});class i extends e{constructor(o){if(!o.canisterId)throw new Ft(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof o.canisterId=="string"?dt.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},pl),o),{canisterId:a}),service:n});for(let[c,l]of n._fields)r?.httpDetails&&l.annotations.push(Tc),r?.certificate&&l.annotations.push(ml),this[c]=X1(this,c,l,o.blsVerify)}}return i}static createActor(t,r){if(!r.canisterId)throw new Ft(`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(t))(r)}static createActorWithHttpDetails(t,r){return new(this.createActorClass(t,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(t,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(t,n))(r)}};function kn(e,t){let r=Br.decode(e,dl.Buffer.from(t));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var pl={pollingStrategyFactory:yo.defaultStrategy},Tc="http-details",ml="certificate";function X1(e,t,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,l;o=Object.assign(Object.assign({},o),(l=(c=e[Ne].config).queryTransform)===null||l===void 0?void 0:l.call(c,t,a,Object.assign(Object.assign({},e[Ne].config),o)));let h=o.agent||e[Ne].config.agent||vc(),d=dt.from(o.canisterId||e[Ne].config.canisterId),g=Br.encode(r.argTypes,a),w=await h.query(d,{methodName:t,arg:g,effectiveCanisterId:o.effectiveCanisterId}),f=Object.assign(Object.assign({},w.httpDetails),{requestDetails:w.requestDetails});switch(w.status){case"rejected":throw new Ac(d,t,w);case"replied":return r.annotations.includes(Tc)?{httpDetails:f,result:kn(r.retTypes,w.reply.arg)}:kn(r.retTypes,w.reply.arg)}}:i=async(o,...a)=>{var c,l;o=Object.assign(Object.assign({},o),(l=(c=e[Ne].config).callTransform)===null||l===void 0?void 0:l.call(c,t,a,Object.assign(Object.assign({},e[Ne].config),o)));let h=o.agent||e[Ne].config.agent||vc(),{canisterId:d,effectiveCanisterId:g,pollingStrategyFactory:w}=Object.assign(Object.assign(Object.assign({},pl),e[Ne].config),o),f=dt.from(d),O=g!==void 0?dt.from(g):f,N=Br.encode(r.argTypes,a),{requestId:F,response:j,requestDetails:S}=await h.call(f,{methodName:t,arg:N,effectiveCanisterId:O}),K,_;if(j.body&&j.body.certificate){if(h.rootKey==null)throw new Error("Agent is missing root key");let M=j.body.certificate;_=await Pr.create({certificate:zn(M),rootKey:h.rootKey,canisterId:dt.from(d),blsVerify:n});let it=[new TextEncoder().encode("request_status"),F];switch(new TextDecoder().decode(ue(_.lookup([...it,"status"])))){case"replied":K=ue(_.lookup([...it,"reply"]));break;case"rejected":{let rt=new Uint8Array(ue(_.lookup([...it,"reject_code"])))[0],b=new TextDecoder().decode(ue(_.lookup([...it,"reject_message"]))),B=ue(_.lookup([...it,"error_code"])),V=B?new TextDecoder().decode(B):void 0;throw new wo(f,t,F,j,rt,b,V)}}}else if(j.body&&"reject_message"in j.body){let{reject_code:M,reject_message:it,error_code:et}=j.body;throw new wo(f,t,F,j,M,it,et)}if(j.status===202){let M=w(),it=await Bc(h,O,F,M,n);_=it.certificate,K=it.reply}let $=r.annotations.includes(Tc),z=r.annotations.includes(ml),Y=Object.assign(Object.assign({},j),{requestDetails:S});if(K!==void 0)return $&&z?{httpDetails:Y,certificate:_,result:kn(r.retTypes,K)}:z?{certificate:_,result:kn(r.retTypes,K)}:$?{httpDetails:Y,result:kn(r.retTypes,K)}:kn(r.retTypes,K);if(r.retTypes.length===0)return $?{httpDetails:j,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...o)=>i({},...o);return s.withOptions=o=>(...a)=>i(o,...a),s}function hl(e){function t(r,n){if(e.effectiveCanisterId)return{effectiveCanisterId:dt.from(e.effectiveCanisterId)};let i=n[0],s=dt.fromHex("");return i&&typeof i=="object"&&i.target_canister&&r==="install_chunked_code"&&(s=dt.from(i.target_canister)),i&&typeof i=="object"&&i.canister_id&&(s=dt.from(i.canister_id)),{effectiveCanisterId:s}}return qr.createActor(ll,Object.assign(Object.assign(Object.assign({},e),{canisterId:dt.fromHex("")}),{callTransform:t,queryTransform:t}))}mi();As();si();Ta();Tn();wc();we();yi();Ec();_c();bc();ei();cc();de();Ma();yi();ni();we();var J1=(e=>(e[e.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",e[e.InvalidFormat=1]="InvalidFormat",e[e.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",e))(J1||{}),P2=BigInt(1e8);var Mn=e=>e==null,Vr=e=>!Mn(e);var Q1=class extends Error{},Sc=(e,t)=>{if(e==null)throw new Q1(t)};var yl="abcdefghijklmnopqrstuvwxyz234567",vi=Object.create(null);for(let e=0;e<yl.length;e++)vi[yl[e]]=e;vi[0]=vi.o;vi[1]=vi.i;var C2=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]);var Nc=(e,t)=>{let r;return(...n)=>{let i=()=>e(...n);r&&clearTimeout(r),r=setTimeout(i,t!==void 0&&t>0?t:300)}};var L1=" daum[ /]| deusu/| yadirectfetcher|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\btime/|\\||^<|^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^active|^ad muncher|^amaya|^avsdevicesdk/|^biglotron|^bot|^bw/|^clamav[ /]|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^email|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^igetter/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d\\s[\\w\\.-]+$|^mozilla/\\d\\.\\d\\s\\(compatible;?(?:\\s\\w+\\/\\d+\\.\\d+)?\\)$|^navermailapp|^netsurf|^offline|^openai/|^owler|^php|^postman|^python|^rank|^read|^reed|^rest|^rss|^snapchat|^space bison|^svn|^swcd |^taringa|^thumbor/|^track|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|^{{.*}}$|adscanner/|analyzer|archive|ask jeeves/teoma|audit|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|convertify|cookiehubscan|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|exaleadcloudview|feed|firephp|functionize|gomezagent|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|infrawatch|insight|inspect|iplabel|ips-agent|java(?!;)|jsjcw_scanner|library|linkcheck|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|optimize|pageburst|pagespeed|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|retriever|rexx;|rigor|rss\\b|scanner\\.|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|webglance|webkit2png|whatcms/|zgrab",D1=/bot|crawl|http|lighthouse|scan|search|spider/i,Bi;function tm(){if(Bi instanceof RegExp)return Bi;try{Bi=new RegExp(L1,"i")}catch{Bi=D1}return Bi}function gl(e){return!!e&&tm().test(e)}var wl=({IDL:e})=>{let t=e.Record({controllers:e.Vec(e.Principal)}),r=e.Variant({Write:e.Null,Admin:e.Null}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:r,expires_at:e.Opt(e.Nat64)}),i=e.Record({version:e.Opt(e.Nat64)}),s=e.Record({cycles:e.Nat,destination_id:e.Principal}),o=e.Record({to:e.Opt(e.Nat64),from:e.Opt(e.Nat64),satellite_id:e.Opt(e.Principal)}),a=e.Record({key:e.Text,collected_at:e.Nat64}),c=e.Record({inner_height:e.Nat16,inner_width:e.Nat16}),l=e.Record({title:e.Text,updated_at:e.Nat64,referrer:e.Opt(e.Text),time_zone:e.Text,session_id:e.Text,href:e.Text,created_at:e.Nat64,satellite_id:e.Principal,device:c,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),h=e.Record({safari:e.Float64,opera:e.Float64,others:e.Float64,firefox:e.Float64,chrome:e.Float64}),d=e.Record({desktop:e.Float64,others:e.Float64,mobile:e.Float64}),g=e.Record({browsers:h,devices:d}),w=e.Record({day:e.Nat8,month:e.Nat8,year:e.Int32}),f=e.Record({bounce_rate:e.Float64,average_page_views_per_session:e.Float64,daily_total_page_views:e.Vec(e.Tuple(w,e.Nat32)),total_page_views:e.Nat32,unique_page_views:e.Nat64,unique_sessions:e.Nat64}),O=e.Record({referrers:e.Vec(e.Tuple(e.Text,e.Nat32)),pages:e.Vec(e.Tuple(e.Text,e.Nat32))}),N=e.Variant({Navigate:e.Null,Restore:e.Null,Reload:e.Null,BackForward:e.Null,BackForwardCache:e.Null,Prerender:e.Null}),F=e.Record({id:e.Text,value:e.Float64,navigation_type:e.Opt(N),delta:e.Float64}),j=e.Variant({WebVitalsMetric:F}),S=e.Variant({CLS:e.Null,FCP:e.Null,INP:e.Null,LCP:e.Null,TTFB:e.Null}),K=e.Record({updated_at:e.Nat64,session_id:e.Text,data:j,href:e.Text,metric_name:S,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),_=e.Record({cls:e.Opt(e.Float64),fcp:e.Opt(e.Float64),inp:e.Opt(e.Float64),lcp:e.Opt(e.Float64),ttfb:e.Opt(e.Float64)}),$=e.Record({overall:_,pages:e.Vec(e.Tuple(e.Text,_))}),z=e.Record({updated_at:e.Nat64,session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),Y=e.Record({total:e.Vec(e.Tuple(e.Text,e.Nat32))}),M=e.Record({performance_metrics:e.Bool,track_events:e.Bool,page_views:e.Bool}),it=e.Record({updated_at:e.Nat64,features:e.Opt(M),created_at:e.Nat64,version:e.Opt(e.Nat64)}),et=e.Record({stable:e.Nat64,heap:e.Nat64}),rt=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:r,expires_at:e.Opt(e.Nat64)}),b=e.Record({controller:rt,controllers:e.Vec(e.Principal)}),B=e.Record({title:e.Text,updated_at:e.Opt(e.Nat64),referrer:e.Opt(e.Text),time_zone:e.Text,session_id:e.Text,href:e.Text,satellite_id:e.Principal,device:c,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),V=e.Variant({Ok:l,Err:e.Text}),U=e.Variant({Ok:e.Null,Err:e.Vec(e.Tuple(a,e.Text))}),I=e.Record({session_id:e.Text,data:j,href:e.Text,metric_name:S,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),G=e.Variant({Ok:K,Err:e.Text}),J=e.Record({features:e.Opt(M),version:e.Opt(e.Nat64)}),lt=e.Record({updated_at:e.Opt(e.Nat64),session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),ct=e.Variant({Ok:z,Err:e.Text});return e.Service({del_controllers:e.Func([t],[e.Vec(e.Tuple(e.Principal,n))],[]),del_satellite_config:e.Func([e.Principal,i],[],[]),deposit_cycles:e.Func([s],[],[]),get_page_views:e.Func([o],[e.Vec(e.Tuple(a,l))],["query"]),get_page_views_analytics_clients:e.Func([o],[g],["query"]),get_page_views_analytics_metrics:e.Func([o],[f],["query"]),get_page_views_analytics_top_10:e.Func([o],[O],["query"]),get_performance_metrics:e.Func([o],[e.Vec(e.Tuple(a,K))],["query"]),get_performance_metrics_analytics_web_vitals:e.Func([o],[$],["query"]),get_track_events:e.Func([o],[e.Vec(e.Tuple(a,z))],["query"]),get_track_events_analytics:e.Func([o],[Y],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_satellite_configs:e.Func([],[e.Vec(e.Tuple(e.Principal,it))],["query"]),memory_size:e.Func([],[et],["query"]),set_controllers:e.Func([b],[e.Vec(e.Tuple(e.Principal,n))],[]),set_page_view:e.Func([a,B],[V],[]),set_page_views:e.Func([e.Vec(e.Tuple(a,B))],[U],[]),set_performance_metric:e.Func([a,I],[G],[]),set_performance_metrics:e.Func([e.Vec(e.Tuple(a,I))],[U],[]),set_satellite_configs:e.Func([e.Vec(e.Tuple(e.Principal,J))],[e.Vec(e.Tuple(e.Principal,it))],[]),set_track_event:e.Func([a,lt],[ct],[]),set_track_events:e.Func([e.Vec(e.Tuple(a,lt))],[U],[]),version:e.Func([],[e.Text],["query"])})};var bl=async({orbiterId:e,idlFactory:t,container:r})=>{let n=Vr(r)&&r!==!1,i=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io",s=await Pn.create({identity:new Ar,host:i,shouldFetchRootKey:n});return qr.createActor(t,{agent:s,canisterId:e})};var bo=e=>bl({idlFactory:wl,...e});function Ai(e){return new Promise((t,r)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>r(e.error)})}function Ti(e,t){let r=indexedDB.open(e);r.onupgradeneeded=()=>r.result.createObjectStore(t);let n=Ai(r);return(i,s)=>n.then(o=>s(o.transaction(t,i).objectStore(t)))}var Rc;function xl(){return Rc||(Rc=Ti("keyval-store","keyval")),Rc}function xo(e,t=xl()){return t("readwrite",r=>(e.forEach(n=>r.delete(n)),Ai(r.transaction)))}function em(e,t){return e.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},Ai(e.transaction)}function _o(e=xl()){return e("readonly",t=>{if(t.getAll&&t.getAllKeys)return Promise.all([Ai(t.getAllKeys()),Ai(t.getAll())]).then(([n,i])=>n.map((s,o)=>[s,i[o]]));let r=[];return e("readonly",n=>em(n,i=>r.push([i.key,i.value])).then(()=>r))})}var _l=Ti("juno-views","views"),El=Ti("juno-events","events"),vl=Ti("juno-metrics","metrics");var Bl=()=>_o(_l),Al=e=>xo(e,_l);var Tl=()=>_o(El),Sl=e=>xo(e,El);var Nl=()=>_o(vl),Rl=e=>xo(e,vl);onmessage=async({data:e})=>{let{msg:t,data:r}=e;switch(t){case"junoInitEnvironment":im(r);return;case"junoTrackPageView":fm();return;case"junoTrackEvent":lm();return;case"junoStartTrackTimer":await om();return;case"junoStopTracker":await sm();return}};var rm="Analytics worker not initialized. Did you set `satelliteId`?",nm="Analytics worker not initialized. Did you set `orbiterId`?",ge,im=e=>{let{orbiterId:t,satelliteId:r}=e;Sc(t,nm),Sc(r,rm),ge=e},Si,Ic=async()=>await Promise.all([Ol(),Fl(),um()]),sm=async()=>{await Ic(),Vr(Si)&&(clearInterval(Si),Si=void 0),self.close()},om=async()=>{Vr(Si)||(await Ic(),Si=setInterval(Ic,ge?.worker?.timerInterval??1e3))},Oc=!1,Fc=!1,Uc=!1,Ol=async()=>{if(!Ni(ge)||Oc)return;let e=await Bl();if(!(Mn(e)||e.length===0)){Oc=!0;try{let r=await(await bo(ge)).set_page_views(e.map(([n,{collected_at:i,...s}])=>[Pc({key:n,collected_at:i}),{...s,...kc(ge)}]));await Al(e.map(([n,i])=>n)),Mc(r)}catch(t){console.error(t)}Oc=!1}},am=Nc(async()=>await Ol(),100),Fl=async()=>{if(!Ni(ge)||Fc)return;let e=await Tl();if(!(Mn(e)||e.length===0)){Fc=!0;try{let t=await bo(ge),r=({metadata:i,...s})=>({metadata:Mn(i)?[]:[Object.entries(i??{})],...s,...kc(ge)}),n=await t.set_track_events(e.map(([i,{collected_at:s,...o}])=>[Pc({key:i,collected_at:s}),r(o)]));await Sl(e.map(([i,s])=>i)),Mc(n)}catch(t){console.error(t)}Fc=!1}},cm=Nc(async()=>await Fl(),250),um=async()=>{if(!Ni(ge)||ge?.options?.performance===!1||Uc)return;let e=await Nl();if(!(Mn(e)||e.length===0)){Uc=!0;try{let r=await(await bo(ge)).set_performance_metrics(e.map(([n,{collected_at:i,...s}])=>[Pc({key:n,collected_at:i}),{...s,...kc(ge)}]));await Rl(e.map(([n,i])=>n)),Mc(r)}catch(t){console.error(t)}Uc=!1}},fm=()=>{Ni(ge)&&(Ul()||am())},lm=()=>{Ni(ge)&&(Ul()||cm())},Pc=({key:e,collected_at:t})=>({collected_at:t,key:e}),kc=e=>({satellite_id:dt.fromText(e.satelliteId)}),Ul=()=>{let{userAgent:e}=navigator;return Vr(e)?gl(e):!1},Ni=e=>e!=null&&Vr(e.orbiterId)&&Vr(e.satelliteId),Mc=e=>{"Ok"in e||e.Err.forEach(([t,r])=>console.warn(`${r} [Key: ${t.key}]`))};})();
41
- /*!
42
- * The buffer module from node.js, for the browser.
43
- *
44
- * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
45
- * @license MIT
46
- */
47
- /*! Bundled license information:
48
-
49
- @noble/hashes/esm/utils.js:
50
- (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
51
-
52
- ieee754/index.js:
53
- (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
54
-
55
- buffer/index.js:
56
- (*!
57
- * The buffer module from node.js, for the browser.
58
- *
59
- * @author Feross Aboukhadijeh <https://feross.org>
60
- * @license MIT
61
- *)
62
-
63
- @noble/curves/esm/abstract/utils.js:
64
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
65
-
66
- @noble/curves/esm/abstract/modular.js:
67
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
68
-
69
- @noble/curves/esm/abstract/curve.js:
70
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
71
-
72
- @noble/curves/esm/abstract/weierstrass.js:
73
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
74
-
75
- @noble/curves/esm/abstract/bls.js:
76
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
77
-
78
- @noble/curves/esm/abstract/tower.js:
79
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
80
-
81
- @noble/curves/esm/bls12-381.js:
82
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
83
-
84
- @noble/curves/esm/abstract/edwards.js:
85
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
86
-
87
- @noble/curves/esm/ed25519.js:
88
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
89
- */