@junobuild/core-standalone 0.1.16 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +5 -5
- package/dist/browser/index.js.map +3 -3
- package/dist/node/index.mjs +23 -23
- package/dist/node/index.mjs.map +3 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/services/auth.services.d.ts +13 -0
- package/dist/types/services/storage.services.d.ts +24 -7
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { createRequire as topLevelCreateRequire } from 'module';
|
|
2
2
|
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
-
var Q_=Object.create;var io=Object.defineProperty;var L_=Object.getOwnPropertyDescriptor;var eg=Object.getOwnPropertyNames;var tg=Object.getPrototypeOf,rg=Object.prototype.hasOwnProperty;var ai=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Zf=(t,e)=>()=>(t&&(e=t(t=0)),e);var ee=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ng=(t,e)=>{for(var r in e)io(t,r,{get:e[r],enumerable:!0})},Xf=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of eg(e))!rg.call(t,i)&&i!==r&&io(t,i,{get:()=>e[i],enumerable:!(n=L_(e,i))||n.enumerable});return t};var Je=(t,e,r)=>(r=t!=null?Q_(tg(t)):{},Xf(e||!t||!t.__esModule?io(r,"default",{value:t,enumerable:!0}):r,t)),ig=t=>Xf(io({},"__esModule",{value:!0}),t);var ed=ee(so=>{"use strict";so.byteLength=og;so.toByteArray=cg;so.fromByteArray=fg;var Tr=[],tr=[],sg=typeof Uint8Array<"u"?Uint8Array:Array,Rc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(qn=0,Qf=Rc.length;qn<Qf;++qn)Tr[qn]=Rc[qn],tr[Rc.charCodeAt(qn)]=qn;var qn,Qf;tr[45]=62;tr[95]=63;function Lf(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function og(t){var e=Lf(t),r=e[0],n=e[1];return(r+n)*3/4-n}function ag(t,e,r){return(e+r)*3/4-r}function cg(t){var e,r=Lf(t),n=r[0],i=r[1],s=new sg(ag(t,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=tr[t.charCodeAt(c)]<<18|tr[t.charCodeAt(c+1)]<<12|tr[t.charCodeAt(c+2)]<<6|tr[t.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=tr[t.charCodeAt(c)]<<2|tr[t.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=tr[t.charCodeAt(c)]<<10|tr[t.charCodeAt(c+1)]<<4|tr[t.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function ug(t){return Tr[t>>18&63]+Tr[t>>12&63]+Tr[t>>6&63]+Tr[t&63]}function lg(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push(ug(n));return i.join("")}function fg(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(lg(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(Tr[e>>2]+Tr[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(Tr[e>>10]+Tr[e>>4&63]+Tr[e<<2&63]+"=")),i.join("")}});var Pc=ee(Bc=>{Bc.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,f=c>>1,d=-7,h=r?i-1:0,g=r?-1:1,b=t[e+h];for(h+=g,s=b&(1<<-d)-1,b>>=-d,d+=a;d>0;s=s*256+t[e+h],h+=g,d-=8);for(o=s&(1<<-d)-1,s>>=-d,d+=n;d>0;o=o*256+t[e+h],h+=g,d-=8);if(s===0)s=1-f;else{if(s===c)return o?NaN:(b?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-f}return(b?-1:1)*o*Math.pow(2,s-n)};Bc.write=function(t,e,r,n,i,s){var o,a,c,f=s*8-i-1,d=(1<<f)-1,h=d>>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=n?0:s-1,l=n?1:-1,N=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=d):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+h>=1?e+=g/c:e+=g*Math.pow(2,1-h),e*c>=2&&(o++,c/=2),o+h>=d?(a=0,o=d):o+h>=1?(a=(e*c-1)*Math.pow(2,i),o=o+h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+b]=a&255,b+=l,a/=256,i-=8);for(o=o<<i|a,f+=i;f>0;t[r+b]=o&255,b+=l,o/=256,f-=8);t[r+b-l]|=N*128}});var gd=ee(fi=>{"use strict";var Uc=ed(),ui=Pc(),td=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;fi.Buffer=Y;fi.SlowBuffer=gg;fi.INSPECT_MAX_BYTES=50;var oo=2147483647;fi.kMaxLength=oo;Y.TYPED_ARRAY_SUPPORT=dg();!Y.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 dg(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(Y.prototype,"parent",{enumerable:!0,get:function(){if(Y.isBuffer(this))return this.buffer}});Object.defineProperty(Y.prototype,"offset",{enumerable:!0,get:function(){if(Y.isBuffer(this))return this.byteOffset}});function Jr(t){if(t>oo)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,Y.prototype),e}function Y(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Mc(t)}return sd(t,e,r)}Y.poolSize=8192;function sd(t,e,r){if(typeof t=="string")return pg(t,e);if(ArrayBuffer.isView(t))return yg(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Ar(t,ArrayBuffer)||t&&Ar(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ar(t,SharedArrayBuffer)||t&&Ar(t.buffer,SharedArrayBuffer)))return Cc(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return Y.from(n,e,r);let i=_g(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return Y.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}Y.from=function(t,e,r){return sd(t,e,r)};Object.setPrototypeOf(Y.prototype,Uint8Array.prototype);Object.setPrototypeOf(Y,Uint8Array);function od(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function hg(t,e,r){return od(t),t<=0?Jr(t):e!==void 0?typeof r=="string"?Jr(t).fill(e,r):Jr(t).fill(e):Jr(t)}Y.alloc=function(t,e,r){return hg(t,e,r)};function Mc(t){return od(t),Jr(t<0?0:qc(t)|0)}Y.allocUnsafe=function(t){return Mc(t)};Y.allocUnsafeSlow=function(t){return Mc(t)};function pg(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!Y.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=ad(t,e)|0,n=Jr(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Ic(t){let e=t.length<0?0:qc(t.length)|0,r=Jr(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function yg(t){if(Ar(t,Uint8Array)){let e=new Uint8Array(t);return Cc(e.buffer,e.byteOffset,e.byteLength)}return Ic(t)}function Cc(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,Y.prototype),n}function _g(t){if(Y.isBuffer(t)){let e=qc(t.length)|0,r=Jr(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||kc(t.length)?Jr(0):Ic(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Ic(t.data)}function qc(t){if(t>=oo)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+oo.toString(16)+" bytes");return t|0}function gg(t){return+t!=t&&(t=0),Y.alloc(+t)}Y.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==Y.prototype};Y.compare=function(e,r){if(Ar(e,Uint8Array)&&(e=Y.from(e,e.offset,e.byteLength)),Ar(r,Uint8Array)&&(r=Y.from(r,r.offset,r.byteLength)),!Y.isBuffer(e)||!Y.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};Y.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};Y.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return Y.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=Y.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(Ar(o,Uint8Array))s+o.length>i.length?(Y.isBuffer(o)||(o=Y.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(Y.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function ad(t,e){if(Y.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Ar(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Fc(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return _d(t).length;default:if(i)return n?-1:Fc(t).length;e=(""+e).toLowerCase(),i=!0}}Y.byteLength=ad;function mg(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Ng(this,e,r);case"utf8":case"utf-8":return ud(this,e,r);case"ascii":return Og(this,e,r);case"latin1":case"binary":return Sg(this,e,r);case"base64":return Tg(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rg(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}Y.prototype._isBuffer=!0;function jn(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}Y.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)jn(this,r,r+1);return this};Y.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)jn(this,r,r+3),jn(this,r+1,r+2);return this};Y.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)jn(this,r,r+7),jn(this,r+1,r+6),jn(this,r+2,r+5),jn(this,r+3,r+4);return this};Y.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?ud(this,0,e):mg.apply(this,arguments)};Y.prototype.toLocaleString=Y.prototype.toString;Y.prototype.equals=function(e){if(!Y.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:Y.compare(this,e)===0};Y.prototype.inspect=function(){let e="",r=fi.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};td&&(Y.prototype[td]=Y.prototype.inspect);Y.prototype.compare=function(e,r,n,i,s){if(Ar(e,Uint8Array)&&(e=Y.from(e,e.offset,e.byteLength)),!Y.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,a=n-r,c=Math.min(o,a),f=this.slice(i,s),d=e.slice(r,n);for(let h=0;h<c;++h)if(f[h]!==d[h]){o=f[h],a=d[h];break}return o<a?-1:a<o?1:0};function cd(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,kc(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=Y.from(e,n)),Y.isBuffer(e))return e.length===0?-1:rd(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):rd(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function rd(t,e,r,n,i){let s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(d,h){return s===1?d[h]:d.readUInt16BE(h*s)}let f;if(i){let d=-1;for(f=r;f<o;f++)if(c(t,f)===c(e,d===-1?0:f-d)){if(d===-1&&(d=f),f-d+1===a)return d*s}else d!==-1&&(f-=f-d),d=-1}else for(r+a>o&&(r=o-a),f=r;f>=0;f--){let d=!0;for(let h=0;h<a;h++)if(c(t,f+h)!==c(e,h)){d=!1;break}if(d)return f}return-1}Y.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};Y.prototype.indexOf=function(e,r,n){return cd(this,e,r,n,!0)};Y.prototype.lastIndexOf=function(e,r,n){return cd(this,e,r,n,!1)};function bg(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(e.substr(o*2,2),16);if(kc(a))return o;t[r+o]=a}return o}function wg(t,e,r,n){return ao(Fc(e,t.length-r),t,r,n)}function Eg(t,e,r,n){return ao(Ig(e),t,r,n)}function xg(t,e,r,n){return ao(_d(e),t,r,n)}function vg(t,e,r,n){return ao(Cg(e,t.length-r),t,r,n)}Y.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return bg(this,e,r,n);case"utf8":case"utf-8":return wg(this,e,r,n);case"ascii":case"latin1":case"binary":return Eg(this,e,r,n);case"base64":return xg(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return vg(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tg(t,e,r){return e===0&&r===t.length?Uc.fromByteArray(t):Uc.fromByteArray(t.slice(e,r))}function ud(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,f,d,h;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)===128&&(h=(s&31)<<6|c&63,h>127&&(o=h));break;case 3:c=t[i+1],f=t[i+2],(c&192)===128&&(f&192)===128&&(h=(s&15)<<12|(c&63)<<6|f&63,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:c=t[i+1],f=t[i+2],d=t[i+3],(c&192)===128&&(f&192)===128&&(d&192)===128&&(h=(s&15)<<18|(c&63)<<12|(f&63)<<6|d&63,h>65535&&h<1114112&&(o=h))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return Ag(n)}var nd=4096;function Ag(t){let e=t.length;if(e<=nd)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=nd));return r}function Og(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Sg(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Ng(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=e;s<r;++s)i+=Fg[t[s]];return i}function Rg(t,e,r){let n=t.slice(e,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}Y.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,Y.prototype),i};function dt(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}Y.prototype.readUintLE=Y.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||dt(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};Y.prototype.readUintBE=Y.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||dt(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};Y.prototype.readUint8=Y.prototype.readUInt8=function(e,r){return e=e>>>0,r||dt(e,1,this.length),this[e]};Y.prototype.readUint16LE=Y.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||dt(e,2,this.length),this[e]|this[e+1]<<8};Y.prototype.readUint16BE=Y.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||dt(e,2,this.length),this[e]<<8|this[e+1]};Y.prototype.readUint32LE=Y.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};Y.prototype.readUint32BE=Y.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};Y.prototype.readBigUInt64LE=cn(function(e){e=e>>>0,li(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xi(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});Y.prototype.readBigUInt64BE=cn(function(e){e=e>>>0,li(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xi(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});Y.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||dt(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};Y.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||dt(e,r,this.length);let i=r,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};Y.prototype.readInt8=function(e,r){return e=e>>>0,r||dt(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};Y.prototype.readInt16LE=function(e,r){e=e>>>0,r||dt(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};Y.prototype.readInt16BE=function(e,r){e=e>>>0,r||dt(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};Y.prototype.readInt32LE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};Y.prototype.readInt32BE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};Y.prototype.readBigInt64LE=cn(function(e){e=e>>>0,li(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xi(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});Y.prototype.readBigInt64BE=cn(function(e){e=e>>>0,li(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xi(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});Y.prototype.readFloatLE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),ui.read(this,e,!0,23,4)};Y.prototype.readFloatBE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),ui.read(this,e,!1,23,4)};Y.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||dt(e,8,this.length),ui.read(this,e,!0,52,8)};Y.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||dt(e,8,this.length),ui.read(this,e,!1,52,8)};function Vt(t,e,r,n,i,s){if(!Y.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}Y.prototype.writeUintLE=Y.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Vt(this,e,r,n,a,0)}let s=1,o=0;for(this[r]=e&255;++o<n&&(s*=256);)this[r+o]=e/s&255;return r+n};Y.prototype.writeUintBE=Y.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Vt(this,e,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=e&255;--s>=0&&(o*=256);)this[r+s]=e/o&255;return r+n};Y.prototype.writeUint8=Y.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,1,255,0),this[r]=e&255,r+1};Y.prototype.writeUint16LE=Y.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};Y.prototype.writeUint16BE=Y.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};Y.prototype.writeUint32LE=Y.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};Y.prototype.writeUint32BE=Y.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function ld(t,e,r,n,i){yd(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,r}function fd(t,e,r,n,i){yd(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s=s>>8,t[r+6]=s,s=s>>8,t[r+5]=s,s=s>>8,t[r+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o=o>>8,t[r+2]=o,o=o>>8,t[r+1]=o,o=o>>8,t[r]=o,r+8}Y.prototype.writeBigUInt64LE=cn(function(e,r=0){return ld(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});Y.prototype.writeBigUInt64BE=cn(function(e,r=0){return fd(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});Y.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Vt(this,e,r,n,c-1,-c)}let s=0,o=1,a=0;for(this[r]=e&255;++s<n&&(o*=256);)e<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};Y.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Vt(this,e,r,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[r+s]=e&255;--s>=0&&(o*=256);)e<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};Y.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};Y.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};Y.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};Y.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};Y.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};Y.prototype.writeBigInt64LE=cn(function(e,r=0){return ld(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});Y.prototype.writeBigInt64BE=cn(function(e,r=0){return fd(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function dd(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function hd(t,e,r,n,i){return e=+e,r=r>>>0,i||dd(t,e,r,4,34028234663852886e22,-34028234663852886e22),ui.write(t,e,r,n,23,4),r+4}Y.prototype.writeFloatLE=function(e,r,n){return hd(this,e,r,!0,n)};Y.prototype.writeFloatBE=function(e,r,n){return hd(this,e,r,!1,n)};function pd(t,e,r,n,i){return e=+e,r=r>>>0,i||dd(t,e,r,8,17976931348623157e292,-17976931348623157e292),ui.write(t,e,r,n,52,8),r+8}Y.prototype.writeDoubleLE=function(e,r,n){return pd(this,e,r,!0,n)};Y.prototype.writeDoubleBE=function(e,r,n){return pd(this,e,r,!1,n)};Y.prototype.copy=function(e,r,n,i){if(!Y.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),s};Y.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!Y.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=r;s<n;++s)this[s]=e;else{let o=Y.isBuffer(e)?e:Y.from(e,i),a=o.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var ci={};function jc(t,e,r){ci[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}jc("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);jc("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);jc("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=id(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=id(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function id(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function Bg(t,e,r){li(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Xi(e,t.length-(r+1))}function yd(t,e,r,n,i,s){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",a;throw s>3?e===0||e===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${e}${o} and <= ${r}${o}`,new ci.ERR_OUT_OF_RANGE("value",a,t)}Bg(n,i,s)}function li(t,e){if(typeof t!="number")throw new ci.ERR_INVALID_ARG_TYPE(e,"number",t)}function Xi(t,e,r){throw Math.floor(t)!==t?(li(t,r),new ci.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new ci.ERR_BUFFER_OUT_OF_BOUNDS:new ci.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Pg=/[^+/0-9A-Za-z-_]/g;function Ug(t){if(t=t.split("=")[0],t=t.trim().replace(Pg,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Fc(t,e){e=e||1/0;let r,n=t.length,i=null,s=[];for(let o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function Ig(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Cg(t,e){let r,n,i,s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function _d(t){return Uc.toByteArray(Ug(t))}function ao(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Ar(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function kc(t){return t!==t}var Fg=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function cn(t){return typeof BigInt>"u"?Mg:t}function Mg(){throw new Error("BigInt not supported")}});var Vc=ee(Qi=>{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});Qi.ReplicaRejectCode=void 0;var qg;(function(t){t[t.SysFatal=1]="SysFatal",t[t.SysTransient=2]="SysTransient",t[t.DestinationInvalid=3]="DestinationInvalid",t[t.CanisterReject=4]="CanisterReject",t[t.CanisterError=5]="CanisterError"})(qg=Qi.ReplicaRejectCode||(Qi.ReplicaRejectCode={}))});var md=ee(hi=>{"use strict";Object.defineProperty(hi,"__esModule",{value:!0});hi.decode=hi.encode=void 0;var co="abcdefghijklmnopqrstuvwxyz234567",di=Object.create(null);for(let t=0;t<co.length;t++)di[co[t]]=t;di[0]=di.o;di[1]=di.i;function jg(t){let e=0,r=0,n="";function i(s){return e<0?r|=s>>-e:r=s<<e&248,e>3?(e-=8,1):(e<4&&(n+=co[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?co[r>>3]:"")}hi.encode=jg;function kg(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=di[o.toLowerCase()];if(a===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);a<<=3,r|=a>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=a<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}hi.decode=kg});var bd=ee(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.getCrc32=void 0;var Vg=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 Hg(t){let e=new Uint8Array(t),r=-1;for(let n=0;n<e.length;n++){let s=(e[n]^r)&255;r=Vg[s]^r>>>8}return(r^-1)>>>0}uo.getCrc32=Hg});var $c=ee(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0});Or.isBytes=Ed;Or.number=lo;Or.bool=wd;Or.bytes=Hc;Or.hash=xd;Or.exists=vd;Or.output=Td;function lo(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function wd(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function Ed(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Hc(t,...e){if(!Ed(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function xd(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");lo(t.outputLen),lo(t.blockLen)}function vd(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Td(t,e){Hc(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var $g={number:lo,bool:wd,bytes:Hc,hash:xd,exists:vd,output:Td};Or.default=$g});var Ad=ee(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.crypto=void 0;var un=ai("node:crypto");fo.crypto=un&&typeof un=="object"&&"webcrypto"in un?un.webcrypto:un&&typeof un=="object"&&"randomBytes"in un?un:void 0});var kn=ee(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.Hash=we.nextTick=we.byteSwapIfBE=we.byteSwap=we.isLE=we.rotl=we.rotr=we.createView=we.u32=we.u8=void 0;we.isBytes=Kg;we.byteSwap32=Zg;we.bytesToHex=Qg;we.hexToBytes=Lg;we.asyncLoop=tm;we.utf8ToBytes=Sd;we.toBytes=ho;we.concatBytes=rm;we.checkOpts=im;we.wrapConstructor=sm;we.wrapConstructorWithOpts=om;we.wrapXOFConstructorWithOpts=am;we.randomBytes=cm;var pi=Ad(),Gc=$c();function Kg(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var Gg=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);we.u8=Gg;var Yg=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));we.u32=Yg;var Wg=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);we.createView=Wg;var zg=(t,e)=>t<<32-e|t>>>e;we.rotr=zg;var Dg=(t,e)=>t<<e|t>>>32-e>>>0;we.rotl=Dg;we.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var Jg=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;we.byteSwap=Jg;we.byteSwapIfBE=we.isLE?t=>t:t=>(0,we.byteSwap)(t);function Zg(t){for(let e=0;e<t.length;e++)t[e]=(0,we.byteSwap)(t[e])}var Xg=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Qg(t){(0,Gc.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=Xg[t[r]];return e}var Zr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Od(t){if(t>=Zr._0&&t<=Zr._9)return t-Zr._0;if(t>=Zr._A&&t<=Zr._F)return t-(Zr._A-10);if(t>=Zr._a&&t<=Zr._f)return t-(Zr._a-10)}function Lg(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=Od(t.charCodeAt(s)),a=Od(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}var em=async()=>{};we.nextTick=em;async function tm(t,e,r){let n=Date.now();for(let i=0;i<t;i++){r(i);let s=Date.now()-n;s>=0&&s<e||(await(0,we.nextTick)(),n+=s)}}function Sd(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function ho(t){return typeof t=="string"&&(t=Sd(t)),(0,Gc.bytes)(t),t}function rm(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];(0,Gc.bytes)(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}var Kc=class{clone(){return this._cloneInto()}};we.Hash=Kc;var nm={}.toString;function im(t,e){if(e!==void 0&&nm.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function sm(t){let e=n=>t().update(ho(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function om(t){let e=(n,i)=>t(i).update(ho(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}function am(t){let e=(n,i)=>t(i).update(ho(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}function cm(t=32){if(pi.crypto&&typeof pi.crypto.getRandomValues=="function")return pi.crypto.getRandomValues(new Uint8Array(t));if(pi.crypto&&typeof pi.crypto.randomBytes=="function")return pi.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}});var zc=ee(ln=>{"use strict";Object.defineProperty(ln,"__esModule",{value:!0});ln.HashMD=ln.Maj=ln.Chi=void 0;var Yc=$c(),Li=kn();function um(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,f=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+f,a,n)}var lm=(t,e,r)=>t&e^~t&r;ln.Chi=lm;var fm=(t,e,r)=>t&e^t&r^e&r;ln.Maj=fm;var Wc=class extends Li.Hash{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,Li.createView)(this.buffer)}update(e){(0,Yc.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,Li.toBytes)(e);let s=e.length;for(let o=0;o<s;){let a=Math.min(i-this.pos,s-o);if(a===i){let c=(0,Li.createView)(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,Yc.exists)(this),(0,Yc.output)(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let h=o;h<i;h++)r[h]=0;um(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=(0,Li.createView)(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,d=this.get();if(f>d.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<f;h++)a.setUint32(4*h,d[h],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}};ln.HashMD=Wc});var po=ee(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});hn.sha224=hn.sha256=hn.SHA256=void 0;var Dc=zc(),rr=kn(),dm=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]),fn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),dn=new Uint32Array(64),es=class extends Dc.HashMD{constructor(){super(64,32,8,!1),this.A=fn[0]|0,this.B=fn[1]|0,this.C=fn[2]|0,this.D=fn[3]|0,this.E=fn[4]|0,this.F=fn[5]|0,this.G=fn[6]|0,this.H=fn[7]|0}get(){let{A:e,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[e,r,n,i,s,o,a,c]}set(e,r,n,i,s,o,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let h=0;h<16;h++,r+=4)dn[h]=e.getUint32(r,!1);for(let h=16;h<64;h++){let g=dn[h-15],b=dn[h-2],l=(0,rr.rotr)(g,7)^(0,rr.rotr)(g,18)^g>>>3,N=(0,rr.rotr)(b,17)^(0,rr.rotr)(b,19)^b>>>10;dn[h]=N+dn[h-7]+l+dn[h-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:f,H:d}=this;for(let h=0;h<64;h++){let g=(0,rr.rotr)(a,6)^(0,rr.rotr)(a,11)^(0,rr.rotr)(a,25),b=d+g+(0,Dc.Chi)(a,c,f)+dm[h]+dn[h]|0,N=((0,rr.rotr)(n,2)^(0,rr.rotr)(n,13)^(0,rr.rotr)(n,22))+(0,Dc.Maj)(n,i,s)|0;d=f,f=c,c=a,a=o+b|0,o=s,s=i,i=n,n=b+N|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,d=d+this.H|0,this.set(n,i,s,o,a,c,f,d)}roundClean(){dn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};hn.SHA256=es;var Jc=class extends es{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};hn.sha256=(0,rr.wrapConstructor)(()=>new es);hn.sha224=(0,rr.wrapConstructor)(()=>new Jc)});var Nd=ee(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.sha224=void 0;var hm=po();function pm(t){return hm.sha224.create().update(new Uint8Array(t)).digest()}yo.sha224=pm});var It=ee(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.Principal=Sr.JSON_KEY_PRINCIPAL=void 0;var Rd=md(),ym=bd(),_m=Nd();Sr.JSON_KEY_PRINCIPAL="__principal__";var gm=2,Bd=4,mm="aaaaa-aa",bm=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},wm=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),Zc=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Bd]))}static managementCanister(){return this.fromHex(mm)}static selfAuthenticating(e){let r=(0,_m.sha224)(e);return new this(new Uint8Array([...r,gm]))}static from(e){if(typeof e=="string")return t.fromText(e);if(Object.getPrototypeOf(e)===Uint8Array.prototype)return new t(e);if(typeof e=="object"&&e!==null&&e._isPrincipal===!0)return new t(e._arr);throw new Error(`Impossible to convert ${JSON.stringify(e)} to Principal.`)}static fromHex(e){return new this(bm(e))}static fromText(e){let r=e;if(e.includes(Sr.JSON_KEY_PRINCIPAL)){let o=JSON.parse(e);Sr.JSON_KEY_PRINCIPAL in o&&(r=o[Sr.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,Rd.decode)(n);i=i.slice(4,i.length);let s=new this(i);if(s.toText()!==r)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${r}" may not be a valid Principal ID).`);return s}static fromUint8Array(e){return new this(e)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===Bd}toUint8Array(){return this._arr}toHex(){return wm(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,(0,ym.getCrc32)(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),a=(0,Rd.encode)(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[Sr.JSON_KEY_PRINCIPAL]:this.toText()}}compareTo(e){for(let r=0;r<Math.min(this._arr.length,e._arr.length);r++){if(this._arr[r]<e._arr[r])return"lt";if(this._arr[r]>e._arr[r])return"gt"}return this._arr.length<e._arr.length?"lt":this._arr.length>e._arr.length?"gt":"eq"}ltEq(e){let r=this.compareTo(e);return r=="lt"||r=="eq"}gtEq(e){let r=this.compareTo(e);return r=="gt"||r=="eq"}};Sr.Principal=Zc});var Ht=ee(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.bufFromBufLike=At.uint8ToBuf=At.bufEquals=At.compare=At.fromHex=At.toHex=At.concat=void 0;function Em(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e.buffer}At.concat=Em;function xm(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}At.toHex=xm;var vm=new RegExp(/^[0-9a-fA-F]+$/);function Tm(t){if(!vm.test(t))throw new Error("Invalid hexadecimal string.");let e=[...t].reduce((r,n,i)=>(r[i/2|0]=(r[i/2|0]||"")+n,r),[]).map(r=>Number.parseInt(r,16));return new Uint8Array(e).buffer}At.fromHex=Tm;function Pd(t,e){if(t.byteLength!==e.byteLength)return t.byteLength-e.byteLength;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return r[i]-n[i];return 0}At.compare=Pd;function Am(t,e){return Pd(t,e)===0}At.bufEquals=Am;function _o(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}At.uint8ToBuf=_o;function Ud(t){return t instanceof Uint8Array?_o(t):t instanceof ArrayBuffer?t:Array.isArray(t)?_o(new Uint8Array(t)):"buffer"in t?Ud(t.buffer):_o(new Uint8Array(t))}At.bufFromBufLike=Ud});var yi=ee(Nr=>{"use strict";Object.defineProperty(Nr,"__esModule",{value:!0});Nr.UpdateCallRejectedError=Nr.QueryCallRejectedError=Nr.ActorCallError=Nr.AgentError=void 0;var Lc=It(),Om=Vc(),Sm=Ht(),go=class t extends Error{constructor(e){super(e),this.message=e,this.name="AgentError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Nr.AgentError=go;var ts=class t extends go{constructor(e,r,n,i){let s=Lc.Principal.from(e);super(["Call failed:",` Canister: ${s.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(o=>` "${o}": ${JSON.stringify(i[o])}`)].join(`
|
|
4
|
-
`)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i,this.name="ActorCallError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Nr.ActorCallError=ts;var Xc=class t extends ts{constructor(e,r,n){var i;let s=Lc.Principal.from(e);super(s,r,"query",{Status:n.status,Code:(i=Om.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n,this.name="QueryCallRejectedError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Nr.QueryCallRejectedError=Xc;var Qc=class t extends ts{constructor(e,r,n,i){let s=Lc.Principal.from(e);super(s,r,"update",Object.assign({"Request ID":(0,Sm.toHex)(n)},i.body?Object.assign(Object.assign({},i.body.error_code?{"Error code":i.body.error_code}:{}),{"Reject code":String(i.body.reject_code),"Reject message":i.body.reject_message}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.name="UpdateCallRejectedError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Nr.UpdateCallRejectedError=Qc});var wo=ee($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.bufFromBufLike=$t.uint8ToBuf=$t.PipeArrayBuffer=$t.fromHexString=$t.toHexString=$t.concat=void 0;function Nm(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e}$t.concat=Nm;function Rm(t){return new Uint8Array(t).reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}$t.toHexString=Rm;function Bm(t){var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))}$t.fromHexString=Bm;var eu=class{constructor(e,r=e?.byteLength||0){this._buffer=bo(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return bo(this._view.slice())}get byteLength(){return this._view.byteLength}read(e){let r=this._view.subarray(0,e);return this._view=this._view.subarray(e),r.slice().buffer}readUint8(){let e=this._view[0];return this._view=this._view.subarray(1),e}write(e){let r=new Uint8Array(e),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+r.byteLength>=this._buffer.byteLength?this.alloc(r.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+r.byteLength),this._view.set(r,n)}get end(){return this._view.byteLength===0}alloc(e){let r=new ArrayBuffer((this._buffer.byteLength+e)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+e);n.set(this._view),this._buffer=r,this._view=n}};$t.PipeArrayBuffer=eu;function mo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}$t.uint8ToBuf=mo;function bo(t){return t instanceof Uint8Array?mo(t):t instanceof ArrayBuffer?t:Array.isArray(t)?mo(new Uint8Array(t)):"buffer"in t?bo(t.buffer):mo(new Uint8Array(t))}$t.bufFromBufLike=bo});var tu=ee(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});Eo.idlLabelToId=void 0;function Pm(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function Um(t){if(/^_\d+_$/.test(t)||/^_0x[0-9a-fA-F]+_$/.test(t)){let e=+t.slice(1,-1);if(Number.isSafeInteger(e)&&e>=0&&e<2**32)return e}return Pm(t)}Eo.idlLabelToId=Um});var nu=ee(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.readIntLE=Xe.readUIntLE=Xe.writeIntLE=Xe.writeUIntLE=Xe.slebDecode=Xe.slebEncode=Xe.lebDecode=Xe.lebEncode=Xe.safeReadUint8=Xe.safeRead=void 0;var ru=wo();function Id(){throw new Error("unexpected end of buffer")}function Cd(t,e){return t.byteLength<e&&Id(),t.read(e)}Xe.safeRead=Cd;function xo(t){let e=t.readUint8();return e===void 0&&Id(),e}Xe.safeReadUint8=xo;function Im(t){if(typeof t=="number"&&(t=BigInt(t)),t<BigInt(0))throw new Error("Cannot leb encode negative values.");let e=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,r=new ru.PipeArrayBuffer(new ArrayBuffer(e),0);for(;;){let n=Number(t&BigInt(127));if(t/=BigInt(128),t===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}Xe.lebEncode=Im;function Fd(t){let e=BigInt(1),r=BigInt(0),n;do n=xo(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}Xe.lebDecode=Fd;function Cm(t){typeof t=="number"&&(t=BigInt(t));let e=t<BigInt(0);e&&(t=-t-BigInt(1));let r=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,n=new ru.PipeArrayBuffer(new ArrayBuffer(r),0);for(;;){let s=i(t);if(t/=BigInt(128),e&&t===BigInt(0)&&(s&64)!==0||!e&&t===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(e?BigInt(128)-o-BigInt(1):o)}return n.buffer}Xe.slebEncode=Cm;function Fm(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if((e[r]&64)===0)return Fd(t);break}let n=new Uint8Array(Cd(t,r+1)),i=BigInt(0);for(let s=n.byteLength-1;s>=0;s--)i=i*BigInt(128)+BigInt(128-(n[s]&127)-1);return-i-BigInt(1)}Xe.slebDecode=Fm;function Mm(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return Md(t,e)}Xe.writeUIntLE=Mm;function Md(t,e){t=BigInt(t);let r=new ru.PipeArrayBuffer(new ArrayBuffer(Math.min(1,e)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(t%i);for(r.write(new Uint8Array([o]));++n<e;)t<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((t/i-s)%BigInt(256)),r.write(new Uint8Array([o])),i*=BigInt(256);return r.buffer}Xe.writeIntLE=Md;function qd(t,e){let r=BigInt(xo(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(xo(t));r=r+n*s}return r}Xe.readUIntLE=qd;function qm(t,e){let r=qd(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}Xe.readIntLE=qm});var jd=ee(_i=>{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});_i.iexp2=_i.ilog2=void 0;function jm(t){let e=BigInt(t);if(t<=0)throw new RangeError("Input must be positive");return e.toString(2).length-1}_i.ilog2=jm;function km(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}_i.iexp2=km});var cu=ee(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.Variant=W.Record=W.Opt=W.Vec=W.Tuple=W.Principal=W.Nat64=W.Nat32=W.Nat16=W.Nat8=W.Int64=W.Int32=W.Int16=W.Int8=W.Float64=W.Float32=W.Nat=W.Int=W.Text=W.Null=W.Bool=W.Unknown=W.Reserved=W.Empty=W.decode=W.encode=W.ServiceClass=W.FuncClass=W.PrincipalClass=W.RecClass=W.VariantClass=W.TupleClass=W.RecordClass=W.OptClass=W.VecClass=W.FixedNatClass=W.FixedIntClass=W.FloatClass=W.NatClass=W.IntClass=W.TextClass=W.ReservedClass=W.NullClass=W.BoolClass=W.UnknownClass=W.EmptyClass=W.ConstructType=W.PrimitiveType=W.Type=W.Visitor=void 0;W.Service=W.Func=W.Rec=void 0;var Vm=It(),Ue=wo(),Rr=tu(),se=nu(),iu=jd(),vo="DIDL",kd=400;function rs(t,e,r){return t.map((n,i)=>r(n,e[i]))}var su=class{constructor(){this._typs=[],this._idx=new Map}has(e){return this._idx.has(e.name)}add(e,r){let n=this._typs.length;this._idx.set(e.name,n),this._typs.push(r)}merge(e,r){let n=this._idx.get(e.name),i=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+e);if(i===void 0)throw new Error("Missing type index for "+r);this._typs[n]=this._typs[i],this._typs.splice(i,1),this._idx.delete(r)}encode(){let e=(0,se.lebEncode)(this._typs.length),r=(0,Ue.concat)(...this._typs);return(0,Ue.concat)(e,r)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return(0,se.slebEncode)(this._idx.get(e)||0)}},ou=class{visitType(e,r){throw new Error("Not implemented")}visitPrimitive(e,r){return this.visitType(e,r)}visitEmpty(e,r){return this.visitPrimitive(e,r)}visitBool(e,r){return this.visitPrimitive(e,r)}visitNull(e,r){return this.visitPrimitive(e,r)}visitReserved(e,r){return this.visitPrimitive(e,r)}visitText(e,r){return this.visitPrimitive(e,r)}visitNumber(e,r){return this.visitPrimitive(e,r)}visitInt(e,r){return this.visitNumber(e,r)}visitNat(e,r){return this.visitNumber(e,r)}visitFloat(e,r){return this.visitPrimitive(e,r)}visitFixedInt(e,r){return this.visitNumber(e,r)}visitFixedNat(e,r){return this.visitNumber(e,r)}visitPrincipal(e,r){return this.visitPrimitive(e,r)}visitConstruct(e,r){return this.visitType(e,r)}visitVec(e,r,n){return this.visitConstruct(e,n)}visitOpt(e,r,n){return this.visitConstruct(e,n)}visitRecord(e,r,n){return this.visitConstruct(e,n)}visitTuple(e,r,n){let i=r.map((s,o)=>[`_${o}_`,s]);return this.visitRecord(e,i,n)}visitVariant(e,r,n){return this.visitConstruct(e,n)}visitRec(e,r,n){return this.visitConstruct(r,n)}visitFunc(e,r){return this.visitConstruct(e,r)}visitService(e,r){return this.visitConstruct(e,r)}};W.Visitor=ou;var gi=class{display(){return this.name}valueToString(e){return tt(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}};W.Type=gi;var Kt=class extends gi{checkType(e){if(this.name!==e.name)throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`);return e}_buildTypeTableImpl(e){}};W.PrimitiveType=Kt;var Pr=class extends gi{checkType(e){if(e instanceof pn){let r=e.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`)}encodeType(e){return e.indexOf(this.name)}};W.ConstructType=Pr;var To=class extends Kt{accept(e,r){return e.visitEmpty(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return(0,se.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};W.EmptyClass=To;var Ao=class extends gi{checkType(e){throw new Error("Method not implemented for unknown.")}accept(e,r){throw e.visitType(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(e,r){let n=r.decodeValue(e,r);Object(n)!==n&&(n=Object(n));let i;return r instanceof pn?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"}};W.UnknownClass=Ao;var Oo=class extends Kt{accept(e,r){return e.visitBool(this,r)}covariant(e){if(typeof e=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return(0,se.slebEncode)(-2)}decodeValue(e,r){switch(this.checkType(r),(0,se.safeReadUint8)(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};W.BoolClass=Oo;var So=class extends Kt{accept(e,r){return e.visitNull(this,r)}covariant(e){if(e===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,se.slebEncode)(-1)}decodeValue(e,r){return this.checkType(r),null}get name(){return"null"}};W.NullClass=So;var mi=class extends Kt{accept(e,r){return e.visitReserved(this,r)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,se.slebEncode)(-16)}decodeValue(e,r){return r.name!==this.name&&r.decodeValue(e,r),null}get name(){return"reserved"}};W.ReservedClass=mi;var No=class extends Kt{accept(e,r){return e.visitText(this,r)}covariant(e){if(typeof e=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=new TextEncoder().encode(e),n=(0,se.lebEncode)(r.byteLength);return(0,Ue.concat)(n,r)}encodeType(){return(0,se.slebEncode)(-15)}decodeValue(e,r){this.checkType(r);let n=(0,se.lebDecode)(e),i=(0,se.safeRead)(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}};W.TextClass=No;var Ro=class extends Kt{accept(e,r){return e.visitInt(this,r)}covariant(e){if(typeof e=="bigint"||Number.isInteger(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,se.slebEncode)(e)}encodeType(){return(0,se.slebEncode)(-4)}decodeValue(e,r){return this.checkType(r),(0,se.slebDecode)(e)}get name(){return"int"}valueToString(e){return e.toString()}};W.IntClass=Ro;var Bo=class extends Kt{accept(e,r){return e.visitNat(this,r)}covariant(e){if(typeof e=="bigint"&&e>=BigInt(0)||Number.isInteger(e)&&e>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,se.lebEncode)(e)}encodeType(){return(0,se.slebEncode)(-3)}decodeValue(e,r){return this.checkType(r),(0,se.lebDecode)(e)}get name(){return"nat"}valueToString(e){return e.toString()}};W.NatClass=Bo;var ns=class extends Kt{constructor(e){if(super(),this._bits=e,e!==32&&e!==64)throw new Error("not a valid float type")}accept(e,r){return e.visitFloat(this,r)}covariant(e){if(typeof e=="number"||e instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,e,!0):n.setFloat64(0,e,!0),r}encodeType(){let e=this._bits===32?-13:-14;return(0,se.slebEncode)(e)}decodeValue(e,r){this.checkType(r);let n=(0,se.safeRead)(e,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(e){return e.toString()}};W.FloatClass=ns;var Xr=class extends Kt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=(0,iu.iexp2)(this._bits-1)*BigInt(-1),n=(0,iu.iexp2)(this._bits-1)-BigInt(1),i=!1;if(typeof e=="bigint")i=e>=r&&e<=n;else if(Number.isInteger(e)){let s=BigInt(e);i=s>=r&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,se.writeIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,se.slebEncode)(-9-e)}decodeValue(e,r){this.checkType(r);let n=(0,se.readIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}};W.FixedIntClass=Xr;var Br=class extends Kt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=(0,iu.iexp2)(this._bits),n=!1;if(typeof e=="bigint"&&e>=BigInt(0)?n=e<r:Number.isInteger(e)&&e>=0?n=BigInt(e)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,se.writeUIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,se.slebEncode)(-5-e)}decodeValue(e,r){this.checkType(r);let n=(0,se.readUIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}};W.FixedNatClass=Br;var Po=class t extends Pr{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof Br&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof Br?this._type._bits:this._type instanceof Xr?this._type._bits:0;if(ArrayBuffer.isView(e)&&r==e.BYTES_PER_ELEMENT*8||Array.isArray(e)&&e.every((n,i)=>{try{return this._type.covariant(n)}catch(s){throw new Error(`Invalid ${this.display()} argument:
|
|
3
|
+
var Q_=Object.create;var io=Object.defineProperty;var L_=Object.getOwnPropertyDescriptor;var eg=Object.getOwnPropertyNames;var tg=Object.getPrototypeOf,rg=Object.prototype.hasOwnProperty;var ai=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Xf=(t,e)=>()=>(t&&(e=t(t=0)),e);var ee=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ng=(t,e)=>{for(var r in e)io(t,r,{get:e[r],enumerable:!0})},Qf=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of eg(e))!rg.call(t,i)&&i!==r&&io(t,i,{get:()=>e[i],enumerable:!(n=L_(e,i))||n.enumerable});return t};var Je=(t,e,r)=>(r=t!=null?Q_(tg(t)):{},Qf(e||!t||!t.__esModule?io(r,"default",{value:t,enumerable:!0}):r,t)),ig=t=>Qf(io({},"__esModule",{value:!0}),t);var td=ee(so=>{"use strict";so.byteLength=og;so.toByteArray=cg;so.fromByteArray=fg;var Ar=[],tr=[],sg=typeof Uint8Array<"u"?Uint8Array:Array,Rc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(qn=0,Lf=Rc.length;qn<Lf;++qn)Ar[qn]=Rc[qn],tr[Rc.charCodeAt(qn)]=qn;var qn,Lf;tr[45]=62;tr[95]=63;function ed(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function og(t){var e=ed(t),r=e[0],n=e[1];return(r+n)*3/4-n}function ag(t,e,r){return(e+r)*3/4-r}function cg(t){var e,r=ed(t),n=r[0],i=r[1],s=new sg(ag(t,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=tr[t.charCodeAt(c)]<<18|tr[t.charCodeAt(c+1)]<<12|tr[t.charCodeAt(c+2)]<<6|tr[t.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=tr[t.charCodeAt(c)]<<2|tr[t.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=tr[t.charCodeAt(c)]<<10|tr[t.charCodeAt(c+1)]<<4|tr[t.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function ug(t){return Ar[t>>18&63]+Ar[t>>12&63]+Ar[t>>6&63]+Ar[t&63]}function lg(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push(ug(n));return i.join("")}function fg(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(lg(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(Ar[e>>2]+Ar[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(Ar[e>>10]+Ar[e>>4&63]+Ar[e<<2&63]+"=")),i.join("")}});var Pc=ee(Bc=>{Bc.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,f=c>>1,d=-7,h=r?i-1:0,g=r?-1:1,b=t[e+h];for(h+=g,s=b&(1<<-d)-1,b>>=-d,d+=a;d>0;s=s*256+t[e+h],h+=g,d-=8);for(o=s&(1<<-d)-1,s>>=-d,d+=n;d>0;o=o*256+t[e+h],h+=g,d-=8);if(s===0)s=1-f;else{if(s===c)return o?NaN:(b?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-f}return(b?-1:1)*o*Math.pow(2,s-n)};Bc.write=function(t,e,r,n,i,s){var o,a,c,f=s*8-i-1,d=(1<<f)-1,h=d>>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=n?0:s-1,l=n?1:-1,N=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=d):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+h>=1?e+=g/c:e+=g*Math.pow(2,1-h),e*c>=2&&(o++,c/=2),o+h>=d?(a=0,o=d):o+h>=1?(a=(e*c-1)*Math.pow(2,i),o=o+h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+b]=a&255,b+=l,a/=256,i-=8);for(o=o<<i|a,f+=i;f>0;t[r+b]=o&255,b+=l,o/=256,f-=8);t[r+b-l]|=N*128}});var md=ee(fi=>{"use strict";var Uc=td(),ui=Pc(),rd=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;fi.Buffer=Y;fi.SlowBuffer=gg;fi.INSPECT_MAX_BYTES=50;var oo=2147483647;fi.kMaxLength=oo;Y.TYPED_ARRAY_SUPPORT=dg();!Y.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 dg(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(Y.prototype,"parent",{enumerable:!0,get:function(){if(Y.isBuffer(this))return this.buffer}});Object.defineProperty(Y.prototype,"offset",{enumerable:!0,get:function(){if(Y.isBuffer(this))return this.byteOffset}});function Zr(t){if(t>oo)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,Y.prototype),e}function Y(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Mc(t)}return od(t,e,r)}Y.poolSize=8192;function od(t,e,r){if(typeof t=="string")return pg(t,e);if(ArrayBuffer.isView(t))return yg(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Or(t,ArrayBuffer)||t&&Or(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Or(t,SharedArrayBuffer)||t&&Or(t.buffer,SharedArrayBuffer)))return Cc(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return Y.from(n,e,r);let i=_g(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return Y.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}Y.from=function(t,e,r){return od(t,e,r)};Object.setPrototypeOf(Y.prototype,Uint8Array.prototype);Object.setPrototypeOf(Y,Uint8Array);function ad(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function hg(t,e,r){return ad(t),t<=0?Zr(t):e!==void 0?typeof r=="string"?Zr(t).fill(e,r):Zr(t).fill(e):Zr(t)}Y.alloc=function(t,e,r){return hg(t,e,r)};function Mc(t){return ad(t),Zr(t<0?0:qc(t)|0)}Y.allocUnsafe=function(t){return Mc(t)};Y.allocUnsafeSlow=function(t){return Mc(t)};function pg(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!Y.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=cd(t,e)|0,n=Zr(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Ic(t){let e=t.length<0?0:qc(t.length)|0,r=Zr(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function yg(t){if(Or(t,Uint8Array)){let e=new Uint8Array(t);return Cc(e.buffer,e.byteOffset,e.byteLength)}return Ic(t)}function Cc(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,Y.prototype),n}function _g(t){if(Y.isBuffer(t)){let e=qc(t.length)|0,r=Zr(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||kc(t.length)?Zr(0):Ic(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Ic(t.data)}function qc(t){if(t>=oo)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+oo.toString(16)+" bytes");return t|0}function gg(t){return+t!=t&&(t=0),Y.alloc(+t)}Y.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==Y.prototype};Y.compare=function(e,r){if(Or(e,Uint8Array)&&(e=Y.from(e,e.offset,e.byteLength)),Or(r,Uint8Array)&&(r=Y.from(r,r.offset,r.byteLength)),!Y.isBuffer(e)||!Y.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};Y.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};Y.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return Y.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=Y.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(Or(o,Uint8Array))s+o.length>i.length?(Y.isBuffer(o)||(o=Y.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(Y.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function cd(t,e){if(Y.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Or(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Fc(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return gd(t).length;default:if(i)return n?-1:Fc(t).length;e=(""+e).toLowerCase(),i=!0}}Y.byteLength=cd;function mg(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Ng(this,e,r);case"utf8":case"utf-8":return ld(this,e,r);case"ascii":return Og(this,e,r);case"latin1":case"binary":return Sg(this,e,r);case"base64":return Tg(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rg(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}Y.prototype._isBuffer=!0;function jn(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}Y.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)jn(this,r,r+1);return this};Y.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)jn(this,r,r+3),jn(this,r+1,r+2);return this};Y.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)jn(this,r,r+7),jn(this,r+1,r+6),jn(this,r+2,r+5),jn(this,r+3,r+4);return this};Y.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?ld(this,0,e):mg.apply(this,arguments)};Y.prototype.toLocaleString=Y.prototype.toString;Y.prototype.equals=function(e){if(!Y.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:Y.compare(this,e)===0};Y.prototype.inspect=function(){let e="",r=fi.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};rd&&(Y.prototype[rd]=Y.prototype.inspect);Y.prototype.compare=function(e,r,n,i,s){if(Or(e,Uint8Array)&&(e=Y.from(e,e.offset,e.byteLength)),!Y.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,a=n-r,c=Math.min(o,a),f=this.slice(i,s),d=e.slice(r,n);for(let h=0;h<c;++h)if(f[h]!==d[h]){o=f[h],a=d[h];break}return o<a?-1:a<o?1:0};function ud(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,kc(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=Y.from(e,n)),Y.isBuffer(e))return e.length===0?-1:nd(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):nd(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function nd(t,e,r,n,i){let s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(d,h){return s===1?d[h]:d.readUInt16BE(h*s)}let f;if(i){let d=-1;for(f=r;f<o;f++)if(c(t,f)===c(e,d===-1?0:f-d)){if(d===-1&&(d=f),f-d+1===a)return d*s}else d!==-1&&(f-=f-d),d=-1}else for(r+a>o&&(r=o-a),f=r;f>=0;f--){let d=!0;for(let h=0;h<a;h++)if(c(t,f+h)!==c(e,h)){d=!1;break}if(d)return f}return-1}Y.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};Y.prototype.indexOf=function(e,r,n){return ud(this,e,r,n,!0)};Y.prototype.lastIndexOf=function(e,r,n){return ud(this,e,r,n,!1)};function bg(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(e.substr(o*2,2),16);if(kc(a))return o;t[r+o]=a}return o}function wg(t,e,r,n){return ao(Fc(e,t.length-r),t,r,n)}function Eg(t,e,r,n){return ao(Ig(e),t,r,n)}function xg(t,e,r,n){return ao(gd(e),t,r,n)}function vg(t,e,r,n){return ao(Cg(e,t.length-r),t,r,n)}Y.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return bg(this,e,r,n);case"utf8":case"utf-8":return wg(this,e,r,n);case"ascii":case"latin1":case"binary":return Eg(this,e,r,n);case"base64":return xg(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return vg(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tg(t,e,r){return e===0&&r===t.length?Uc.fromByteArray(t):Uc.fromByteArray(t.slice(e,r))}function ld(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,f,d,h;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)===128&&(h=(s&31)<<6|c&63,h>127&&(o=h));break;case 3:c=t[i+1],f=t[i+2],(c&192)===128&&(f&192)===128&&(h=(s&15)<<12|(c&63)<<6|f&63,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:c=t[i+1],f=t[i+2],d=t[i+3],(c&192)===128&&(f&192)===128&&(d&192)===128&&(h=(s&15)<<18|(c&63)<<12|(f&63)<<6|d&63,h>65535&&h<1114112&&(o=h))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return Ag(n)}var id=4096;function Ag(t){let e=t.length;if(e<=id)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=id));return r}function Og(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Sg(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Ng(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=e;s<r;++s)i+=Fg[t[s]];return i}function Rg(t,e,r){let n=t.slice(e,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}Y.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,Y.prototype),i};function dt(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}Y.prototype.readUintLE=Y.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||dt(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};Y.prototype.readUintBE=Y.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||dt(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};Y.prototype.readUint8=Y.prototype.readUInt8=function(e,r){return e=e>>>0,r||dt(e,1,this.length),this[e]};Y.prototype.readUint16LE=Y.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||dt(e,2,this.length),this[e]|this[e+1]<<8};Y.prototype.readUint16BE=Y.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||dt(e,2,this.length),this[e]<<8|this[e+1]};Y.prototype.readUint32LE=Y.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};Y.prototype.readUint32BE=Y.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};Y.prototype.readBigUInt64LE=cn(function(e){e=e>>>0,li(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xi(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});Y.prototype.readBigUInt64BE=cn(function(e){e=e>>>0,li(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xi(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});Y.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||dt(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};Y.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||dt(e,r,this.length);let i=r,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};Y.prototype.readInt8=function(e,r){return e=e>>>0,r||dt(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};Y.prototype.readInt16LE=function(e,r){e=e>>>0,r||dt(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};Y.prototype.readInt16BE=function(e,r){e=e>>>0,r||dt(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};Y.prototype.readInt32LE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};Y.prototype.readInt32BE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};Y.prototype.readBigInt64LE=cn(function(e){e=e>>>0,li(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xi(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});Y.prototype.readBigInt64BE=cn(function(e){e=e>>>0,li(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xi(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});Y.prototype.readFloatLE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),ui.read(this,e,!0,23,4)};Y.prototype.readFloatBE=function(e,r){return e=e>>>0,r||dt(e,4,this.length),ui.read(this,e,!1,23,4)};Y.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||dt(e,8,this.length),ui.read(this,e,!0,52,8)};Y.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||dt(e,8,this.length),ui.read(this,e,!1,52,8)};function Vt(t,e,r,n,i,s){if(!Y.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}Y.prototype.writeUintLE=Y.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Vt(this,e,r,n,a,0)}let s=1,o=0;for(this[r]=e&255;++o<n&&(s*=256);)this[r+o]=e/s&255;return r+n};Y.prototype.writeUintBE=Y.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Vt(this,e,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=e&255;--s>=0&&(o*=256);)this[r+s]=e/o&255;return r+n};Y.prototype.writeUint8=Y.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,1,255,0),this[r]=e&255,r+1};Y.prototype.writeUint16LE=Y.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};Y.prototype.writeUint16BE=Y.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};Y.prototype.writeUint32LE=Y.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};Y.prototype.writeUint32BE=Y.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function fd(t,e,r,n,i){_d(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,r}function dd(t,e,r,n,i){_d(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s=s>>8,t[r+6]=s,s=s>>8,t[r+5]=s,s=s>>8,t[r+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o=o>>8,t[r+2]=o,o=o>>8,t[r+1]=o,o=o>>8,t[r]=o,r+8}Y.prototype.writeBigUInt64LE=cn(function(e,r=0){return fd(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});Y.prototype.writeBigUInt64BE=cn(function(e,r=0){return dd(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});Y.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Vt(this,e,r,n,c-1,-c)}let s=0,o=1,a=0;for(this[r]=e&255;++s<n&&(o*=256);)e<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};Y.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Vt(this,e,r,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[r+s]=e&255;--s>=0&&(o*=256);)e<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};Y.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};Y.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};Y.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};Y.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};Y.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Vt(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};Y.prototype.writeBigInt64LE=cn(function(e,r=0){return fd(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});Y.prototype.writeBigInt64BE=cn(function(e,r=0){return dd(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function hd(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function pd(t,e,r,n,i){return e=+e,r=r>>>0,i||hd(t,e,r,4,34028234663852886e22,-34028234663852886e22),ui.write(t,e,r,n,23,4),r+4}Y.prototype.writeFloatLE=function(e,r,n){return pd(this,e,r,!0,n)};Y.prototype.writeFloatBE=function(e,r,n){return pd(this,e,r,!1,n)};function yd(t,e,r,n,i){return e=+e,r=r>>>0,i||hd(t,e,r,8,17976931348623157e292,-17976931348623157e292),ui.write(t,e,r,n,52,8),r+8}Y.prototype.writeDoubleLE=function(e,r,n){return yd(this,e,r,!0,n)};Y.prototype.writeDoubleBE=function(e,r,n){return yd(this,e,r,!1,n)};Y.prototype.copy=function(e,r,n,i){if(!Y.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),s};Y.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!Y.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=r;s<n;++s)this[s]=e;else{let o=Y.isBuffer(e)?e:Y.from(e,i),a=o.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var ci={};function jc(t,e,r){ci[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}jc("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);jc("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);jc("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=sd(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=sd(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function sd(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function Bg(t,e,r){li(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Xi(e,t.length-(r+1))}function _d(t,e,r,n,i,s){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",a;throw s>3?e===0||e===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${e}${o} and <= ${r}${o}`,new ci.ERR_OUT_OF_RANGE("value",a,t)}Bg(n,i,s)}function li(t,e){if(typeof t!="number")throw new ci.ERR_INVALID_ARG_TYPE(e,"number",t)}function Xi(t,e,r){throw Math.floor(t)!==t?(li(t,r),new ci.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new ci.ERR_BUFFER_OUT_OF_BOUNDS:new ci.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Pg=/[^+/0-9A-Za-z-_]/g;function Ug(t){if(t=t.split("=")[0],t=t.trim().replace(Pg,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Fc(t,e){e=e||1/0;let r,n=t.length,i=null,s=[];for(let o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function Ig(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Cg(t,e){let r,n,i,s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function gd(t){return Uc.toByteArray(Ug(t))}function ao(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Or(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function kc(t){return t!==t}var Fg=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function cn(t){return typeof BigInt>"u"?Mg:t}function Mg(){throw new Error("BigInt not supported")}});var Vc=ee(Qi=>{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});Qi.ReplicaRejectCode=void 0;var qg;(function(t){t[t.SysFatal=1]="SysFatal",t[t.SysTransient=2]="SysTransient",t[t.DestinationInvalid=3]="DestinationInvalid",t[t.CanisterReject=4]="CanisterReject",t[t.CanisterError=5]="CanisterError"})(qg=Qi.ReplicaRejectCode||(Qi.ReplicaRejectCode={}))});var bd=ee(hi=>{"use strict";Object.defineProperty(hi,"__esModule",{value:!0});hi.decode=hi.encode=void 0;var co="abcdefghijklmnopqrstuvwxyz234567",di=Object.create(null);for(let t=0;t<co.length;t++)di[co[t]]=t;di[0]=di.o;di[1]=di.i;function jg(t){let e=0,r=0,n="";function i(s){return e<0?r|=s>>-e:r=s<<e&248,e>3?(e-=8,1):(e<4&&(n+=co[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?co[r>>3]:"")}hi.encode=jg;function kg(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=di[o.toLowerCase()];if(a===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);a<<=3,r|=a>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=a<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}hi.decode=kg});var wd=ee(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.getCrc32=void 0;var Vg=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 Hg(t){let e=new Uint8Array(t),r=-1;for(let n=0;n<e.length;n++){let s=(e[n]^r)&255;r=Vg[s]^r>>>8}return(r^-1)>>>0}uo.getCrc32=Hg});var $c=ee(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.isBytes=xd;Sr.number=lo;Sr.bool=Ed;Sr.bytes=Hc;Sr.hash=vd;Sr.exists=Td;Sr.output=Ad;function lo(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function Ed(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function xd(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Hc(t,...e){if(!xd(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function vd(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");lo(t.outputLen),lo(t.blockLen)}function Td(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ad(t,e){Hc(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var $g={number:lo,bool:Ed,bytes:Hc,hash:vd,exists:Td,output:Ad};Sr.default=$g});var Od=ee(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.crypto=void 0;var un=ai("node:crypto");fo.crypto=un&&typeof un=="object"&&"webcrypto"in un?un.webcrypto:un&&typeof un=="object"&&"randomBytes"in un?un:void 0});var kn=ee(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.Hash=we.nextTick=we.byteSwapIfBE=we.byteSwap=we.isLE=we.rotl=we.rotr=we.createView=we.u32=we.u8=void 0;we.isBytes=Kg;we.byteSwap32=Zg;we.bytesToHex=Qg;we.hexToBytes=Lg;we.asyncLoop=tm;we.utf8ToBytes=Nd;we.toBytes=ho;we.concatBytes=rm;we.checkOpts=im;we.wrapConstructor=sm;we.wrapConstructorWithOpts=om;we.wrapXOFConstructorWithOpts=am;we.randomBytes=cm;var pi=Od(),Gc=$c();function Kg(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var Gg=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);we.u8=Gg;var Yg=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));we.u32=Yg;var Wg=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);we.createView=Wg;var zg=(t,e)=>t<<32-e|t>>>e;we.rotr=zg;var Dg=(t,e)=>t<<e|t>>>32-e>>>0;we.rotl=Dg;we.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var Jg=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;we.byteSwap=Jg;we.byteSwapIfBE=we.isLE?t=>t:t=>(0,we.byteSwap)(t);function Zg(t){for(let e=0;e<t.length;e++)t[e]=(0,we.byteSwap)(t[e])}var Xg=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Qg(t){(0,Gc.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=Xg[t[r]];return e}var Xr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Sd(t){if(t>=Xr._0&&t<=Xr._9)return t-Xr._0;if(t>=Xr._A&&t<=Xr._F)return t-(Xr._A-10);if(t>=Xr._a&&t<=Xr._f)return t-(Xr._a-10)}function Lg(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=Sd(t.charCodeAt(s)),a=Sd(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}var em=async()=>{};we.nextTick=em;async function tm(t,e,r){let n=Date.now();for(let i=0;i<t;i++){r(i);let s=Date.now()-n;s>=0&&s<e||(await(0,we.nextTick)(),n+=s)}}function Nd(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function ho(t){return typeof t=="string"&&(t=Nd(t)),(0,Gc.bytes)(t),t}function rm(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];(0,Gc.bytes)(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}var Kc=class{clone(){return this._cloneInto()}};we.Hash=Kc;var nm={}.toString;function im(t,e){if(e!==void 0&&nm.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function sm(t){let e=n=>t().update(ho(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function om(t){let e=(n,i)=>t(i).update(ho(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}function am(t){let e=(n,i)=>t(i).update(ho(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}function cm(t=32){if(pi.crypto&&typeof pi.crypto.getRandomValues=="function")return pi.crypto.getRandomValues(new Uint8Array(t));if(pi.crypto&&typeof pi.crypto.randomBytes=="function")return pi.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}});var zc=ee(ln=>{"use strict";Object.defineProperty(ln,"__esModule",{value:!0});ln.HashMD=ln.Maj=ln.Chi=void 0;var Yc=$c(),Li=kn();function um(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,f=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+f,a,n)}var lm=(t,e,r)=>t&e^~t&r;ln.Chi=lm;var fm=(t,e,r)=>t&e^t&r^e&r;ln.Maj=fm;var Wc=class extends Li.Hash{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,Li.createView)(this.buffer)}update(e){(0,Yc.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,Li.toBytes)(e);let s=e.length;for(let o=0;o<s;){let a=Math.min(i-this.pos,s-o);if(a===i){let c=(0,Li.createView)(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,Yc.exists)(this),(0,Yc.output)(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let h=o;h<i;h++)r[h]=0;um(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=(0,Li.createView)(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,d=this.get();if(f>d.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<f;h++)a.setUint32(4*h,d[h],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}};ln.HashMD=Wc});var po=ee(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});hn.sha224=hn.sha256=hn.SHA256=void 0;var Dc=zc(),rr=kn(),dm=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]),fn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),dn=new Uint32Array(64),es=class extends Dc.HashMD{constructor(){super(64,32,8,!1),this.A=fn[0]|0,this.B=fn[1]|0,this.C=fn[2]|0,this.D=fn[3]|0,this.E=fn[4]|0,this.F=fn[5]|0,this.G=fn[6]|0,this.H=fn[7]|0}get(){let{A:e,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[e,r,n,i,s,o,a,c]}set(e,r,n,i,s,o,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let h=0;h<16;h++,r+=4)dn[h]=e.getUint32(r,!1);for(let h=16;h<64;h++){let g=dn[h-15],b=dn[h-2],l=(0,rr.rotr)(g,7)^(0,rr.rotr)(g,18)^g>>>3,N=(0,rr.rotr)(b,17)^(0,rr.rotr)(b,19)^b>>>10;dn[h]=N+dn[h-7]+l+dn[h-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:f,H:d}=this;for(let h=0;h<64;h++){let g=(0,rr.rotr)(a,6)^(0,rr.rotr)(a,11)^(0,rr.rotr)(a,25),b=d+g+(0,Dc.Chi)(a,c,f)+dm[h]+dn[h]|0,N=((0,rr.rotr)(n,2)^(0,rr.rotr)(n,13)^(0,rr.rotr)(n,22))+(0,Dc.Maj)(n,i,s)|0;d=f,f=c,c=a,a=o+b|0,o=s,s=i,i=n,n=b+N|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,d=d+this.H|0,this.set(n,i,s,o,a,c,f,d)}roundClean(){dn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};hn.SHA256=es;var Jc=class extends es{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};hn.sha256=(0,rr.wrapConstructor)(()=>new es);hn.sha224=(0,rr.wrapConstructor)(()=>new Jc)});var Rd=ee(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.sha224=void 0;var hm=po();function pm(t){return hm.sha224.create().update(new Uint8Array(t)).digest()}yo.sha224=pm});var It=ee(Nr=>{"use strict";Object.defineProperty(Nr,"__esModule",{value:!0});Nr.Principal=Nr.JSON_KEY_PRINCIPAL=void 0;var Bd=bd(),ym=wd(),_m=Rd();Nr.JSON_KEY_PRINCIPAL="__principal__";var gm=2,Pd=4,mm="aaaaa-aa",bm=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},wm=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),Zc=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Pd]))}static managementCanister(){return this.fromHex(mm)}static selfAuthenticating(e){let r=(0,_m.sha224)(e);return new this(new Uint8Array([...r,gm]))}static from(e){if(typeof e=="string")return t.fromText(e);if(Object.getPrototypeOf(e)===Uint8Array.prototype)return new t(e);if(typeof e=="object"&&e!==null&&e._isPrincipal===!0)return new t(e._arr);throw new Error(`Impossible to convert ${JSON.stringify(e)} to Principal.`)}static fromHex(e){return new this(bm(e))}static fromText(e){let r=e;if(e.includes(Nr.JSON_KEY_PRINCIPAL)){let o=JSON.parse(e);Nr.JSON_KEY_PRINCIPAL in o&&(r=o[Nr.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,Bd.decode)(n);i=i.slice(4,i.length);let s=new this(i);if(s.toText()!==r)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${r}" may not be a valid Principal ID).`);return s}static fromUint8Array(e){return new this(e)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===Pd}toUint8Array(){return this._arr}toHex(){return wm(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,(0,ym.getCrc32)(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),a=(0,Bd.encode)(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[Nr.JSON_KEY_PRINCIPAL]:this.toText()}}compareTo(e){for(let r=0;r<Math.min(this._arr.length,e._arr.length);r++){if(this._arr[r]<e._arr[r])return"lt";if(this._arr[r]>e._arr[r])return"gt"}return this._arr.length<e._arr.length?"lt":this._arr.length>e._arr.length?"gt":"eq"}ltEq(e){let r=this.compareTo(e);return r=="lt"||r=="eq"}gtEq(e){let r=this.compareTo(e);return r=="gt"||r=="eq"}};Nr.Principal=Zc});var Ht=ee(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.bufFromBufLike=At.uint8ToBuf=At.bufEquals=At.compare=At.fromHex=At.toHex=At.concat=void 0;function Em(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e.buffer}At.concat=Em;function xm(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}At.toHex=xm;var vm=new RegExp(/^[0-9a-fA-F]+$/);function Tm(t){if(!vm.test(t))throw new Error("Invalid hexadecimal string.");let e=[...t].reduce((r,n,i)=>(r[i/2|0]=(r[i/2|0]||"")+n,r),[]).map(r=>Number.parseInt(r,16));return new Uint8Array(e).buffer}At.fromHex=Tm;function Ud(t,e){if(t.byteLength!==e.byteLength)return t.byteLength-e.byteLength;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return r[i]-n[i];return 0}At.compare=Ud;function Am(t,e){return Ud(t,e)===0}At.bufEquals=Am;function _o(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}At.uint8ToBuf=_o;function Id(t){return t instanceof Uint8Array?_o(t):t instanceof ArrayBuffer?t:Array.isArray(t)?_o(new Uint8Array(t)):"buffer"in t?Id(t.buffer):_o(new Uint8Array(t))}At.bufFromBufLike=Id});var yi=ee(Rr=>{"use strict";Object.defineProperty(Rr,"__esModule",{value:!0});Rr.UpdateCallRejectedError=Rr.QueryCallRejectedError=Rr.ActorCallError=Rr.AgentError=void 0;var Lc=It(),Om=Vc(),Sm=Ht(),go=class t extends Error{constructor(e){super(e),this.message=e,this.name="AgentError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Rr.AgentError=go;var ts=class t extends go{constructor(e,r,n,i){let s=Lc.Principal.from(e);super(["Call failed:",` Canister: ${s.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(o=>` "${o}": ${JSON.stringify(i[o])}`)].join(`
|
|
4
|
+
`)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i,this.name="ActorCallError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Rr.ActorCallError=ts;var Xc=class t extends ts{constructor(e,r,n){var i;let s=Lc.Principal.from(e);super(s,r,"query",{Status:n.status,Code:(i=Om.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n,this.name="QueryCallRejectedError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Rr.QueryCallRejectedError=Xc;var Qc=class t extends ts{constructor(e,r,n,i){let s=Lc.Principal.from(e);super(s,r,"update",Object.assign({"Request ID":(0,Sm.toHex)(n)},i.body?Object.assign(Object.assign({},i.body.error_code?{"Error code":i.body.error_code}:{}),{"Reject code":String(i.body.reject_code),"Reject message":i.body.reject_message}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.name="UpdateCallRejectedError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Rr.UpdateCallRejectedError=Qc});var wo=ee($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.bufFromBufLike=$t.uint8ToBuf=$t.PipeArrayBuffer=$t.fromHexString=$t.toHexString=$t.concat=void 0;function Nm(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e}$t.concat=Nm;function Rm(t){return new Uint8Array(t).reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}$t.toHexString=Rm;function Bm(t){var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))}$t.fromHexString=Bm;var eu=class{constructor(e,r=e?.byteLength||0){this._buffer=bo(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return bo(this._view.slice())}get byteLength(){return this._view.byteLength}read(e){let r=this._view.subarray(0,e);return this._view=this._view.subarray(e),r.slice().buffer}readUint8(){let e=this._view[0];return this._view=this._view.subarray(1),e}write(e){let r=new Uint8Array(e),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+r.byteLength>=this._buffer.byteLength?this.alloc(r.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+r.byteLength),this._view.set(r,n)}get end(){return this._view.byteLength===0}alloc(e){let r=new ArrayBuffer((this._buffer.byteLength+e)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+e);n.set(this._view),this._buffer=r,this._view=n}};$t.PipeArrayBuffer=eu;function mo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}$t.uint8ToBuf=mo;function bo(t){return t instanceof Uint8Array?mo(t):t instanceof ArrayBuffer?t:Array.isArray(t)?mo(new Uint8Array(t)):"buffer"in t?bo(t.buffer):mo(new Uint8Array(t))}$t.bufFromBufLike=bo});var tu=ee(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});Eo.idlLabelToId=void 0;function Pm(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function Um(t){if(/^_\d+_$/.test(t)||/^_0x[0-9a-fA-F]+_$/.test(t)){let e=+t.slice(1,-1);if(Number.isSafeInteger(e)&&e>=0&&e<2**32)return e}return Pm(t)}Eo.idlLabelToId=Um});var nu=ee(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.readIntLE=Xe.readUIntLE=Xe.writeIntLE=Xe.writeUIntLE=Xe.slebDecode=Xe.slebEncode=Xe.lebDecode=Xe.lebEncode=Xe.safeReadUint8=Xe.safeRead=void 0;var ru=wo();function Cd(){throw new Error("unexpected end of buffer")}function Fd(t,e){return t.byteLength<e&&Cd(),t.read(e)}Xe.safeRead=Fd;function xo(t){let e=t.readUint8();return e===void 0&&Cd(),e}Xe.safeReadUint8=xo;function Im(t){if(typeof t=="number"&&(t=BigInt(t)),t<BigInt(0))throw new Error("Cannot leb encode negative values.");let e=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,r=new ru.PipeArrayBuffer(new ArrayBuffer(e),0);for(;;){let n=Number(t&BigInt(127));if(t/=BigInt(128),t===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}Xe.lebEncode=Im;function Md(t){let e=BigInt(1),r=BigInt(0),n;do n=xo(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}Xe.lebDecode=Md;function Cm(t){typeof t=="number"&&(t=BigInt(t));let e=t<BigInt(0);e&&(t=-t-BigInt(1));let r=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,n=new ru.PipeArrayBuffer(new ArrayBuffer(r),0);for(;;){let s=i(t);if(t/=BigInt(128),e&&t===BigInt(0)&&(s&64)!==0||!e&&t===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(e?BigInt(128)-o-BigInt(1):o)}return n.buffer}Xe.slebEncode=Cm;function Fm(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if((e[r]&64)===0)return Md(t);break}let n=new Uint8Array(Fd(t,r+1)),i=BigInt(0);for(let s=n.byteLength-1;s>=0;s--)i=i*BigInt(128)+BigInt(128-(n[s]&127)-1);return-i-BigInt(1)}Xe.slebDecode=Fm;function Mm(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return qd(t,e)}Xe.writeUIntLE=Mm;function qd(t,e){t=BigInt(t);let r=new ru.PipeArrayBuffer(new ArrayBuffer(Math.min(1,e)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(t%i);for(r.write(new Uint8Array([o]));++n<e;)t<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((t/i-s)%BigInt(256)),r.write(new Uint8Array([o])),i*=BigInt(256);return r.buffer}Xe.writeIntLE=qd;function jd(t,e){let r=BigInt(xo(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(xo(t));r=r+n*s}return r}Xe.readUIntLE=jd;function qm(t,e){let r=jd(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}Xe.readIntLE=qm});var kd=ee(_i=>{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});_i.iexp2=_i.ilog2=void 0;function jm(t){let e=BigInt(t);if(t<=0)throw new RangeError("Input must be positive");return e.toString(2).length-1}_i.ilog2=jm;function km(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}_i.iexp2=km});var cu=ee(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.Variant=W.Record=W.Opt=W.Vec=W.Tuple=W.Principal=W.Nat64=W.Nat32=W.Nat16=W.Nat8=W.Int64=W.Int32=W.Int16=W.Int8=W.Float64=W.Float32=W.Nat=W.Int=W.Text=W.Null=W.Bool=W.Unknown=W.Reserved=W.Empty=W.decode=W.encode=W.ServiceClass=W.FuncClass=W.PrincipalClass=W.RecClass=W.VariantClass=W.TupleClass=W.RecordClass=W.OptClass=W.VecClass=W.FixedNatClass=W.FixedIntClass=W.FloatClass=W.NatClass=W.IntClass=W.TextClass=W.ReservedClass=W.NullClass=W.BoolClass=W.UnknownClass=W.EmptyClass=W.ConstructType=W.PrimitiveType=W.Type=W.Visitor=void 0;W.Service=W.Func=W.Rec=void 0;var Vm=It(),Ue=wo(),Br=tu(),se=nu(),iu=kd(),vo="DIDL",Vd=400;function rs(t,e,r){return t.map((n,i)=>r(n,e[i]))}var su=class{constructor(){this._typs=[],this._idx=new Map}has(e){return this._idx.has(e.name)}add(e,r){let n=this._typs.length;this._idx.set(e.name,n),this._typs.push(r)}merge(e,r){let n=this._idx.get(e.name),i=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+e);if(i===void 0)throw new Error("Missing type index for "+r);this._typs[n]=this._typs[i],this._typs.splice(i,1),this._idx.delete(r)}encode(){let e=(0,se.lebEncode)(this._typs.length),r=(0,Ue.concat)(...this._typs);return(0,Ue.concat)(e,r)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return(0,se.slebEncode)(this._idx.get(e)||0)}},ou=class{visitType(e,r){throw new Error("Not implemented")}visitPrimitive(e,r){return this.visitType(e,r)}visitEmpty(e,r){return this.visitPrimitive(e,r)}visitBool(e,r){return this.visitPrimitive(e,r)}visitNull(e,r){return this.visitPrimitive(e,r)}visitReserved(e,r){return this.visitPrimitive(e,r)}visitText(e,r){return this.visitPrimitive(e,r)}visitNumber(e,r){return this.visitPrimitive(e,r)}visitInt(e,r){return this.visitNumber(e,r)}visitNat(e,r){return this.visitNumber(e,r)}visitFloat(e,r){return this.visitPrimitive(e,r)}visitFixedInt(e,r){return this.visitNumber(e,r)}visitFixedNat(e,r){return this.visitNumber(e,r)}visitPrincipal(e,r){return this.visitPrimitive(e,r)}visitConstruct(e,r){return this.visitType(e,r)}visitVec(e,r,n){return this.visitConstruct(e,n)}visitOpt(e,r,n){return this.visitConstruct(e,n)}visitRecord(e,r,n){return this.visitConstruct(e,n)}visitTuple(e,r,n){let i=r.map((s,o)=>[`_${o}_`,s]);return this.visitRecord(e,i,n)}visitVariant(e,r,n){return this.visitConstruct(e,n)}visitRec(e,r,n){return this.visitConstruct(r,n)}visitFunc(e,r){return this.visitConstruct(e,r)}visitService(e,r){return this.visitConstruct(e,r)}};W.Visitor=ou;var gi=class{display(){return this.name}valueToString(e){return tt(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}};W.Type=gi;var Kt=class extends gi{checkType(e){if(this.name!==e.name)throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`);return e}_buildTypeTableImpl(e){}};W.PrimitiveType=Kt;var Ur=class extends gi{checkType(e){if(e instanceof pn){let r=e.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`)}encodeType(e){return e.indexOf(this.name)}};W.ConstructType=Ur;var To=class extends Kt{accept(e,r){return e.visitEmpty(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return(0,se.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};W.EmptyClass=To;var Ao=class extends gi{checkType(e){throw new Error("Method not implemented for unknown.")}accept(e,r){throw e.visitType(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(e,r){let n=r.decodeValue(e,r);Object(n)!==n&&(n=Object(n));let i;return r instanceof pn?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"}};W.UnknownClass=Ao;var Oo=class extends Kt{accept(e,r){return e.visitBool(this,r)}covariant(e){if(typeof e=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return(0,se.slebEncode)(-2)}decodeValue(e,r){switch(this.checkType(r),(0,se.safeReadUint8)(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};W.BoolClass=Oo;var So=class extends Kt{accept(e,r){return e.visitNull(this,r)}covariant(e){if(e===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,se.slebEncode)(-1)}decodeValue(e,r){return this.checkType(r),null}get name(){return"null"}};W.NullClass=So;var mi=class extends Kt{accept(e,r){return e.visitReserved(this,r)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,se.slebEncode)(-16)}decodeValue(e,r){return r.name!==this.name&&r.decodeValue(e,r),null}get name(){return"reserved"}};W.ReservedClass=mi;var No=class extends Kt{accept(e,r){return e.visitText(this,r)}covariant(e){if(typeof e=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=new TextEncoder().encode(e),n=(0,se.lebEncode)(r.byteLength);return(0,Ue.concat)(n,r)}encodeType(){return(0,se.slebEncode)(-15)}decodeValue(e,r){this.checkType(r);let n=(0,se.lebDecode)(e),i=(0,se.safeRead)(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}};W.TextClass=No;var Ro=class extends Kt{accept(e,r){return e.visitInt(this,r)}covariant(e){if(typeof e=="bigint"||Number.isInteger(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,se.slebEncode)(e)}encodeType(){return(0,se.slebEncode)(-4)}decodeValue(e,r){return this.checkType(r),(0,se.slebDecode)(e)}get name(){return"int"}valueToString(e){return e.toString()}};W.IntClass=Ro;var Bo=class extends Kt{accept(e,r){return e.visitNat(this,r)}covariant(e){if(typeof e=="bigint"&&e>=BigInt(0)||Number.isInteger(e)&&e>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,se.lebEncode)(e)}encodeType(){return(0,se.slebEncode)(-3)}decodeValue(e,r){return this.checkType(r),(0,se.lebDecode)(e)}get name(){return"nat"}valueToString(e){return e.toString()}};W.NatClass=Bo;var ns=class extends Kt{constructor(e){if(super(),this._bits=e,e!==32&&e!==64)throw new Error("not a valid float type")}accept(e,r){return e.visitFloat(this,r)}covariant(e){if(typeof e=="number"||e instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,e,!0):n.setFloat64(0,e,!0),r}encodeType(){let e=this._bits===32?-13:-14;return(0,se.slebEncode)(e)}decodeValue(e,r){this.checkType(r);let n=(0,se.safeRead)(e,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(e){return e.toString()}};W.FloatClass=ns;var Qr=class extends Kt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=(0,iu.iexp2)(this._bits-1)*BigInt(-1),n=(0,iu.iexp2)(this._bits-1)-BigInt(1),i=!1;if(typeof e=="bigint")i=e>=r&&e<=n;else if(Number.isInteger(e)){let s=BigInt(e);i=s>=r&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,se.writeIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,se.slebEncode)(-9-e)}decodeValue(e,r){this.checkType(r);let n=(0,se.readIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}};W.FixedIntClass=Qr;var Pr=class extends Kt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=(0,iu.iexp2)(this._bits),n=!1;if(typeof e=="bigint"&&e>=BigInt(0)?n=e<r:Number.isInteger(e)&&e>=0?n=BigInt(e)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return(0,se.writeUIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,se.slebEncode)(-5-e)}decodeValue(e,r){this.checkType(r);let n=(0,se.readUIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}};W.FixedNatClass=Pr;var Po=class t extends Ur{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof Pr&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof Pr?this._type._bits:this._type instanceof Qr?this._type._bits:0;if(ArrayBuffer.isView(e)&&r==e.BYTES_PER_ELEMENT*8||Array.isArray(e)&&e.every((n,i)=>{try{return this._type.covariant(n)}catch(s){throw new Error(`Invalid ${this.display()} argument:
|
|
5
5
|
|
|
6
|
-
index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=(0,se.lebEncode)(e.length);if(this._blobOptimization)return(0,Ue.concat)(r,new Uint8Array(e));if(ArrayBuffer.isView(e))return(0,Ue.concat)(r,new Uint8Array(e.buffer));let n=new Ue.PipeArrayBuffer(new ArrayBuffer(r.byteLength+e.length),0);n.write(r);for(let i of e){let s=this._type.encodeValue(i);n.write(new Uint8Array(s))}return n.buffer}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=(0,se.slebEncode)(-19),n=this._type.encodeType(e);e.add(this,(0,Ue.concat)(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a vector type");let i=Number((0,se.lebDecode)(e));if(this._type instanceof
|
|
6
|
+
index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=(0,se.lebEncode)(e.length);if(this._blobOptimization)return(0,Ue.concat)(r,new Uint8Array(e));if(ArrayBuffer.isView(e))return(0,Ue.concat)(r,new Uint8Array(e.buffer));let n=new Ue.PipeArrayBuffer(new ArrayBuffer(r.byteLength+e.length),0);n.write(r);for(let i of e){let s=this._type.encodeValue(i);n.write(new Uint8Array(s))}return n.buffer}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=(0,se.slebEncode)(-19),n=this._type.encodeType(e);e.add(this,(0,Ue.concat)(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a vector type");let i=Number((0,se.lebDecode)(e));if(this._type instanceof Pr){if(this._type._bits==8)return new Uint8Array(e.read(i));if(this._type._bits==16)return new Uint16Array(e.read(i*2));if(this._type._bits==32)return new Uint32Array(e.read(i*4));if(this._type._bits==64)return new BigUint64Array(e.read(i*8))}if(this._type instanceof Qr){if(this._type._bits==8)return new Int8Array(e.read(i));if(this._type._bits==16)return new Int16Array(e.read(i*2));if(this._type._bits==32)return new Int32Array(e.read(i*4));if(this._type._bits==64)return new BigInt64Array(e.read(i*8))}let s=[];for(let o=0;o<i;o++)s.push(this._type.decodeValue(e,n._type));return s}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(e){return"vec {"+e.map(n=>this._type.valueToString(n)).join("; ")+"}"}};W.VecClass=Po;var bi=class t extends Ur{constructor(e){super(),this._type=e}accept(e,r){return e.visitOpt(this,this._type,r)}covariant(e){try{if(Array.isArray(e)&&(e.length===0||e.length===1&&this._type.covariant(e[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${tt(e)}
|
|
7
7
|
|
|
8
|
-
-> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return e.length===0?new Uint8Array([0]):(0,Ue.concat)(new Uint8Array([1]),this._type.encodeValue(e[0]))}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=(0,se.slebEncode)(-18),n=this._type.encodeType(e);e.add(this,(0,Ue.concat)(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not an option type");switch((0,se.safeReadUint8)(e)){case 0:return[];case 1:return[this._type.decodeValue(e,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(e){return e.length===0?"null":`opt ${this._type.valueToString(e[0])}`}};W.OptClass=bi;var is=class t extends
|
|
8
|
+
-> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){return e.length===0?new Uint8Array([0]):(0,Ue.concat)(new Uint8Array([1]),this._type.encodeValue(e[0]))}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=(0,se.slebEncode)(-18),n=this._type.encodeType(e);e.add(this,(0,Ue.concat)(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not an option type");switch((0,se.safeReadUint8)(e)){case 0:return[];case 1:return[this._type.decodeValue(e,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(e){return e.length===0?"null":`opt ${this._type.valueToString(e[0])}`}};W.OptClass=bi;var is=class t extends Ur{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,Br.idlLabelToId)(r[0])-(0,Br.idlLabelToId)(n[0]))}accept(e,r){return e.visitRecord(this,this._fields,r)}tryAsTuple(){let e=[];for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(n!==`_${r}_`)return null;e.push(i)}return e}covariant(e){if(typeof e=="object"&&this._fields.every(([r,n])=>{if(!e.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
|
|
9
9
|
|
|
10
|
-
field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=this._fields.map(([i])=>e[i]),n=rs(this._fields,r,([,i],s)=>i.encodeValue(s));return(0,Ue.concat)(...n)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,se.slebEncode)(-20),n=(0,se.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Ue.concat)((0,se.lebEncode)((0,
|
|
10
|
+
field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=this._fields.map(([i])=>e[i]),n=rs(this._fields,r,([,i],s)=>i.encodeValue(s));return(0,Ue.concat)(...n)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,se.slebEncode)(-20),n=(0,se.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Ue.concat)((0,se.lebEncode)((0,Br.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Ue.concat)(r,n,(0,Ue.concat)(...i)))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a record type");let i={},s=0,o=0;for(;o<n._fields.length;){let[a,c]=n._fields[o];if(s>=this._fields.length){c.decodeValue(e,c),o++;continue}let[f,d]=this._fields[s],h=(0,Br.idlLabelToId)(this._fields[s][0]),g=(0,Br.idlLabelToId)(a);if(h===g)i[f]=d.decodeValue(e,c),s++,o++;else if(g>h)if(d instanceof bi||d instanceof mi)i[f]=[],s++;else throw new Error("Cannot find required field "+f);else c.decodeValue(e,c),o++}for(let[a,c]of this._fields.slice(s))if(c instanceof bi||c instanceof mi)i[a]=[];else throw new Error("Cannot find required field "+a);return i}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(e){let r=this._fields.map(([i])=>e[i]);return`record {${rs(this._fields,r,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}};W.RecordClass=is;var Uo=class t extends is{constructor(e){let r={};e.forEach((n,i)=>r["_"+i+"_"]=n),super(r),this._components=e}accept(e,r){return e.visitTuple(this,this._components,r)}covariant(e){if(Array.isArray(e)&&e.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(e[n])}catch(i){throw new Error(`Invalid ${this.display()} argument:
|
|
11
11
|
|
|
12
|
-
index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=rs(this._components,e,(n,i)=>n.encodeValue(i));return(0,Ue.concat)(...r)}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let i=[];for(let[s,o]of n._components.entries())s>=this._components.length?o.decodeValue(e,o):i.push(this._components[s].decodeValue(e,o));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(e){return`record {${rs(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}};W.TupleClass=Uo;var Io=class t extends
|
|
12
|
+
index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=rs(this._components,e,(n,i)=>n.encodeValue(i));return(0,Ue.concat)(...r)}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let i=[];for(let[s,o]of n._components.entries())s>=this._components.length?o.decodeValue(e,o):i.push(this._components[s].decodeValue(e,o));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(e){return`record {${rs(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}};W.TupleClass=Uo;var Io=class t extends Ur{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,Br.idlLabelToId)(r[0])-(0,Br.idlLabelToId)(n[0]))}accept(e,r){return e.visitVariant(this,this._fields,r)}covariant(e){if(typeof e=="object"&&Object.entries(e).length===1&&this._fields.every(([r,n])=>{try{return!e.hasOwnProperty(r)||n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
|
|
13
13
|
|
|
14
|
-
variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(e.hasOwnProperty(n)){let s=(0,se.lebEncode)(r),o=i.encodeValue(e[n]);return(0,Ue.concat)(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let r=(0,se.slebEncode)(-21),n=(0,se.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Ue.concat)((0,se.lebEncode)((0,
|
|
14
|
+
variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(e.hasOwnProperty(n)){let s=(0,se.lebEncode)(r),o=i.encodeValue(e[n]);return(0,Ue.concat)(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let r=(0,se.slebEncode)(-21),n=(0,se.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Ue.concat)((0,se.lebEncode)((0,Br.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Ue.concat)(r,n,...i))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a variant type");let i=Number((0,se.lebDecode)(e));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,o]=n._fields[i];for(let[a,c]of this._fields)if((0,Br.idlLabelToId)(s)===(0,Br.idlLabelToId)(a)){let f=c.decodeValue(e,o);return{[a]:f}}throw new Error("Cannot find field hash "+s)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(e){for(let[r,n]of this._fields)if(e.hasOwnProperty(r)){let i=n.valueToString(e[r]);return i==="null"?`variant {${r}}`:`variant {${r}=${i}}`}throw new Error("Variant has no data: "+e)}};W.VariantClass=Io;var pn=class t extends Ur{constructor(){super(...arguments),this._id=t._counter++,this._type=void 0}accept(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return e.visitRec(this,this._type,r)}fill(e){this._type=e}getType(){return this._type}covariant(e){if(this._type&&this._type.covariant(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(e)}_buildTypeTableImpl(e){if(!this._type)throw Error("Recursive type uninitialized.");e.add(this,new Uint8Array([])),this._type.buildTypeTable(e),e.merge(this,this._type.name)}decodeValue(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(e,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(e)}};W.RecClass=pn;pn._counter=0;function au(t){if((0,se.safeReadUint8)(t)!==1)throw new Error("Cannot decode principal");let r=Number((0,se.lebDecode)(t));return Vm.Principal.fromUint8Array(new Uint8Array((0,se.safeRead)(t,r)))}var Co=class extends Kt{accept(e,r){return e.visitPrincipal(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=(0,se.lebEncode)(r.byteLength);return(0,Ue.concat)(new Uint8Array([1]),n,r)}encodeType(){return(0,se.slebEncode)(-24)}decodeValue(e,r){return this.checkType(r),au(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}};W.PrincipalClass=Co;var ss=class extends Ur{constructor(e,r,n=[]){super(),this.argTypes=e,this.retTypes=r,this.annotations=n}static argsToString(e,r){if(e.length!==r.length)throw new Error("arity mismatch");return"("+e.map((n,i)=>n.valueToString(r[i])).join(", ")+")"}accept(e,r){return e.visitFunc(this,r)}covariant(e){if(Array.isArray(e)&&e.length===2&&e[0]&&e[0]._isPrincipal&&typeof e[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue([e,r]){let n=e.toUint8Array(),i=(0,se.lebEncode)(n.byteLength),s=(0,Ue.concat)(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),a=(0,se.lebEncode)(o.byteLength);return(0,Ue.concat)(new Uint8Array([1]),s,a,o)}_buildTypeTableImpl(e){this.argTypes.forEach(f=>f.buildTypeTable(e)),this.retTypes.forEach(f=>f.buildTypeTable(e));let r=(0,se.slebEncode)(-22),n=(0,se.lebEncode)(this.argTypes.length),i=(0,Ue.concat)(...this.argTypes.map(f=>f.encodeType(e))),s=(0,se.lebEncode)(this.retTypes.length),o=(0,Ue.concat)(...this.retTypes.map(f=>f.encodeType(e))),a=(0,se.lebEncode)(this.annotations.length),c=(0,Ue.concat)(...this.annotations.map(f=>this.encodeAnnotation(f)));e.add(this,(0,Ue.concat)(r,n,i,s,o,a,c))}decodeValue(e){if((0,se.safeReadUint8)(e)!==1)throw new Error("Cannot decode function reference");let n=au(e),i=Number((0,se.lebDecode)(e)),s=(0,se.safeRead)(e,i),a=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,a]}get name(){let e=this.argTypes.map(i=>i.name).join(", "),r=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${e}) -> (${r})${n}`}valueToString([e,r]){return`func "${e.toText()}".${r}`}display(){let e=this.argTypes.map(i=>i.display()).join(", "),r=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${e}) \u2192 (${r})${n}`}encodeAnnotation(e){if(e==="query")return new Uint8Array([1]);if(e==="oneway")return new Uint8Array([2]);if(e==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}};W.FuncClass=ss;var Fo=class extends Ur{constructor(e){super(),this._fields=Object.entries(e).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(e,r){return e.visitService(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${tt(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=(0,se.lebEncode)(r.length);return(0,Ue.concat)(new Uint8Array([1]),n,r)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,se.slebEncode)(-23),n=(0,se.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>{let a=new TextEncoder().encode(s),c=(0,se.lebEncode)(a.length);return(0,Ue.concat)(c,a,o.encodeType(e))});e.add(this,(0,Ue.concat)(r,n,...i))}decodeValue(e){return au(e)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};W.ServiceClass=Fo;function tt(t){let e=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>Vd?e.substring(0,Vd-3)+"...":e}function Hm(t,e){if(e.length<t.length)throw Error("Wrong number of message arguments");let r=new su;t.forEach(c=>c.buildTypeTable(r));let n=new TextEncoder().encode(vo),i=r.encode(),s=(0,se.lebEncode)(e.length),o=(0,Ue.concat)(...t.map(c=>c.encodeType(r))),a=(0,Ue.concat)(...rs(t,e,(c,f)=>{try{c.covariant(f)}catch(d){throw new Error(d.message+`
|
|
15
15
|
|
|
16
|
-
`)}return c.encodeValue(f)}));return(0,Ue.concat)(n,i,s,o,a)}W.encode=Hm;function $m(t,e){let r=new Ue.PipeArrayBuffer(e);if(e.byteLength<vo.length)throw new Error("Message length smaller than magic number");let n=(0,se.safeRead)(r,vo.length),i=new TextDecoder().decode(n);if(i!==vo)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(b){let l=[],N=Number((0,se.lebDecode)(b));for(let M=0;M<N;M++){let A=Number((0,se.slebDecode)(b));switch(A){case-18:case-19:{let K=Number((0,se.slebDecode)(b));l.push([A,K]);break}case-20:case-21:{let K=[],E=Number((0,se.lebDecode)(b)),k;for(;E--;){let G=Number((0,se.lebDecode)(b));if(G>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof k=="number"&&k>=G)throw new Error("field id collision or not sorted");k=G;let z=Number((0,se.slebDecode)(b));K.push([G,z])}l.push([A,K]);break}case-22:{let K=[],E=Number((0,se.lebDecode)(b));for(;E--;)K.push(Number((0,se.slebDecode)(b)));let k=[],G=Number((0,se.lebDecode)(b));for(;G--;)k.push(Number((0,se.slebDecode)(b)));let z=[],q=Number((0,se.lebDecode)(b));for(;q--;)switch(Number((0,se.lebDecode)(b))){case 1:{z.push("query");break}case 2:{z.push("oneway");break}case 3:{z.push("composite_query");break}default:throw new Error("unknown annotation")}l.push([A,[K,k,z]]);break}case-23:{let K=Number((0,se.lebDecode)(b)),E=[];for(;K--;){let k=Number((0,se.lebDecode)(b)),G=new TextDecoder().decode((0,se.safeRead)(b,k)),z=(0,se.slebDecode)(b);E.push([G,z])}l.push([A,E]);break}default:throw new Error("Illegal op_code: "+A)}}let O=[],I=Number((0,se.lebDecode)(b));for(let M=0;M<I;M++)O.push(Number((0,se.slebDecode)(b)));return[l,O]}let[o,a]=s(r);if(a.length<t.length)throw new Error("Wrong number of return values");let c=o.map(b=>Yd());function f(b){if(b<-24)throw new Error("future value not supported");if(b<0)switch(b){case-1:return W.Null;case-2:return W.Bool;case-3:return W.Nat;case-4:return W.Int;case-5:return W.Nat8;case-6:return W.Nat16;case-7:return W.Nat32;case-8:return W.Nat64;case-9:return W.Int8;case-10:return W.Int16;case-11:return W.Int32;case-12:return W.Int64;case-13:return W.Float32;case-14:return W.Float64;case-15:return W.Text;case-16:return W.Reserved;case-17:return W.Empty;case-24:return W.Principal;default:throw new Error("Illegal op_code: "+b)}if(b>=o.length)throw new Error("type index out of range");return c[b]}function d(b){switch(b[0]){case-19:{let l=f(b[1]);return Hd(l)}case-18:{let l=f(b[1]);return $d(l)}case-20:{let l={};for(let[I,M]of b[1]){let A=`_${I}_`;l[A]=f(M)}let N=Kd(l),O=N.tryAsTuple();return Array.isArray(O)?Vd(...O):N}case-21:{let l={};for(let[N,O]of b[1]){let I=`_${N}_`;l[I]=f(O)}return Gd(l)}case-22:{let[l,N,O]=b[1];return Wd(l.map(I=>f(I)),N.map(I=>f(I)),O)}case-23:{let l={},N=b[1];for(let[O,I]of N){let M=f(I);if(M instanceof pn&&(M=M.getType()),!(M instanceof ss))throw new Error("Illegal service definition: services can only contain functions");l[O]=M}return zd(l)}default:throw new Error("Illegal op_code: "+b[0])}}o.forEach((b,l)=>{if(b[0]===-22){let N=d(b);c[l].fill(N)}}),o.forEach((b,l)=>{if(b[0]!==-22){let N=d(b);c[l].fill(N)}});let h=a.map(b=>f(b)),g=t.map((b,l)=>b.decodeValue(r,h[l]));for(let b=t.length;b<h.length;b++)h[b].decodeValue(r,h[b]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return g}W.decode=$m;W.Empty=new To;W.Reserved=new mi;W.Unknown=new Ao;W.Bool=new Oo;W.Null=new So;W.Text=new No;W.Int=new Ro;W.Nat=new Bo;W.Float32=new ns(32);W.Float64=new ns(64);W.Int8=new Xr(8);W.Int16=new Xr(16);W.Int32=new Xr(32);W.Int64=new Xr(64);W.Nat8=new Br(8);W.Nat16=new Br(16);W.Nat32=new Br(32);W.Nat64=new Br(64);W.Principal=new Co;function Vd(...t){return new Uo(t)}W.Tuple=Vd;function Hd(t){return new Po(t)}W.Vec=Hd;function $d(t){return new bi(t)}W.Opt=$d;function Kd(t){return new is(t)}W.Record=Kd;function Gd(t){return new Io(t)}W.Variant=Gd;function Yd(){return new pn}W.Rec=Yd;function Wd(t,e,r=[]){return new ss(t,e,r)}W.Func=Wd;function zd(t){return new Fo(t)}W.Service=zd});var yu=ee(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.VecForm=Ot.OptionForm=Ot.VariantForm=Ot.TupleForm=Ot.RecordForm=Ot.InputForm=Ot.InputBox=void 0;var uu=class{constructor(e,r){this.idl=e,this.ui=r,this.label=null,this.value=void 0;let n=document.createElement("span");n.className="status",this.status=n,r.input&&(r.input.addEventListener("blur",()=>{r.input.value!==""&&this.parse()}),r.input.addEventListener("input",()=>{n.style.display="none",r.input.classList.remove("reject")}))}isRejected(){return this.value===void 0}parse(e={}){if(this.ui.form){let r=this.ui.form.parse(e);return this.value=r,r}if(this.ui.input){let r=this.ui.input;try{let n=this.ui.parse(this.idl,e,r.value);if(!this.idl.covariant(n))throw new Error(`${r.value} is not of type ${this.idl.display()}`);return this.status.style.display="none",this.value=n,n}catch(n){r.classList.add("reject"),this.status.style.display="block",this.status.innerHTML="InputError: "+n.message,this.value=void 0;return}}return null}render(e){let r=document.createElement("span");if(this.label){let n=document.createElement("label");n.innerText=this.label,r.appendChild(n)}this.ui.input&&(r.appendChild(this.ui.input),r.appendChild(this.status)),this.ui.form&&this.ui.form.render(r),e.appendChild(r)}};Ot.InputBox=uu;var yn=class{constructor(e){this.ui=e,this.form=[]}renderForm(e){this.ui.container?(this.form.forEach(r=>r.render(this.ui.container)),e.appendChild(this.ui.container)):this.form.forEach(r=>r.render(e))}render(e){if(this.ui.open&&this.ui.event){e.appendChild(this.ui.open);let r=this;r.ui.open.addEventListener(r.ui.event,()=>{if(r.ui.container)r.ui.container.innerHTML="";else{let n=r.ui.open.nextElementSibling;n&&n.parentNode.removeChild(n)}r.generateForm(),r.renderForm(e)})}else this.generateForm(),this.renderForm(e)}};Ot.InputForm=yn;var lu=class extends yn{constructor(e,r){super(r),this.fields=e,this.ui=r}generateForm(){this.form=this.fields.map(([e,r])=>{let n=this.ui.render(r);return this.ui.labelMap&&this.ui.labelMap.hasOwnProperty(e)?n.label=this.ui.labelMap[e]+" ":n.label=e+" ",n})}parse(e){let r={};if(this.fields.forEach(([n,i],s)=>{let o=this.form[s].parse(e);r[n]=o}),!this.form.some(n=>n.isRejected()))return r}};Ot.RecordForm=lu;var fu=class extends yn{constructor(e,r){super(r),this.components=e,this.ui=r}generateForm(){this.form=this.components.map(e=>this.ui.render(e))}parse(e){let r=[];if(this.components.forEach((n,i)=>{let s=this.form[i].parse(e);r.push(s)}),!this.form.some(n=>n.isRejected()))return r}};Ot.TupleForm=fu;var du=class extends yn{constructor(e,r){super(r),this.fields=e,this.ui=r}generateForm(){let e=this.ui.open.selectedIndex,[r,n]=this.fields[e],i=this.ui.render(n);this.form=[i]}parse(e){let r=this.ui.open,n=r.options[r.selectedIndex].value,i=this.form[0].parse(e);if(i===void 0)return;let s={};return s[n]=i,s}};Ot.VariantForm=du;var hu=class extends yn{constructor(e,r){super(r),this.ty=e,this.ui=r}generateForm(){if(this.ui.open.checked){let e=this.ui.render(this.ty);this.form=[e]}else this.form=[]}parse(e){if(this.form.length===0)return[];{let r=this.form[0].parse(e);return r===void 0?void 0:[r]}}};Ot.OptionForm=hu;var pu=class extends yn{constructor(e,r){super(r),this.ty=e,this.ui=r}generateForm(){let e=+this.ui.open.value;this.form=[];for(let r=0;r<e;r++){let n=this.ui.render(this.ty);this.form.push(n)}}parse(e){let r=this.form.map(n=>n.parse(e));if(!this.form.some(n=>n.isRejected()))return r}};Ot.VecForm=pu});var Jd=ee(Ee=>{"use strict";var Km=Ee&&Ee.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Gm=Ee&&Ee.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Dd=Ee&&Ee.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Km(e,t,r);return Gm(e,t),e};Object.defineProperty(Ee,"__esModule",{value:!0});Ee.renderValue=Ee.renderInput=Ee.Render=Ee.vecForm=Ee.optForm=Ee.variantForm=Ee.tupleForm=Ee.recordForm=Ee.inputBox=void 0;var qo=Dd(cu()),_u=It(),wi=Dd(yu()),Ym={parse:Qm},os={render:wu},Wm=(t,e)=>new wi.InputBox(t,Object.assign(Object.assign({},Ym),e));Ee.inputBox=Wm;var zm=(t,e)=>new wi.RecordForm(t,Object.assign(Object.assign({},os),e));Ee.recordForm=zm;var Dm=(t,e)=>new wi.TupleForm(t,Object.assign(Object.assign({},os),e));Ee.tupleForm=Dm;var Jm=(t,e)=>new wi.VariantForm(t,Object.assign(Object.assign({},os),e));Ee.variantForm=Jm;var Zm=(t,e)=>new wi.OptionForm(t,Object.assign(Object.assign({},os),e));Ee.optForm=Zm;var Xm=(t,e)=>new wi.VecForm(t,Object.assign(Object.assign({},os),e));Ee.vecForm=Xm;var Mo=class extends qo.Visitor{visitType(e,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=e.display(),(0,Ee.inputBox)(e,{input:n})}visitNull(e,r){return(0,Ee.inputBox)(e,{})}visitRecord(e,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.recordForm)(r,i);return(0,Ee.inputBox)(e,{form:s})}visitTuple(e,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.tupleForm)(r,i);return(0,Ee.inputBox)(e,{form:s})}visitVariant(e,r,n){let i=document.createElement("select");for(let[a,c]of r){let f=new Option(a);i.add(f)}i.selectedIndex=-1,i.classList.add("open");let s={open:i,event:"change"},o=(0,Ee.variantForm)(r,s);return(0,Ee.inputBox)(e,{form:o})}visitOpt(e,r,n){let i=document.createElement("input");i.type="checkbox",i.classList.add("open");let s=(0,Ee.optForm)(r,{open:i,event:"change"});return(0,Ee.inputBox)(e,{form:s})}visitVec(e,r,n){let i=document.createElement("input");i.type="number",i.min="0",i.max="100",i.style.width="8rem",i.placeholder="len",i.classList.add("open");let s=document.createElement("div");s.classList.add("popup-form");let o=(0,Ee.vecForm)(r,{open:i,event:"change",container:s});return(0,Ee.inputBox)(e,{form:o})}visitRec(e,r,n){return wu(r)}};Ee.Render=Mo;var gu=class extends qo.Visitor{visitNull(e,r){return null}visitBool(e,r){if(r==="true")return!0;if(r==="false")return!1;throw new Error(`Cannot parse ${r} as boolean`)}visitText(e,r){return r}visitFloat(e,r){return parseFloat(r)}visitFixedInt(e,r){return e._bits<=32?parseInt(r,10):BigInt(r)}visitFixedNat(e,r){return e._bits<=32?parseInt(r,10):BigInt(r)}visitNumber(e,r){return BigInt(r)}visitPrincipal(e,r){return _u.Principal.fromText(r)}visitService(e,r){return _u.Principal.fromText(r)}visitFunc(e,r){let n=r.split(".",2);return[_u.Principal.fromText(n[0]),n[1]]}},mu=class extends qo.Visitor{visitNull(e,r){return null}visitBool(e,r){return Math.random()<.5}visitText(e,r){return Math.random().toString(36).substring(6)}visitFloat(e,r){return Math.random()}visitInt(e,r){return BigInt(this.generateNumber(!0))}visitNat(e,r){return BigInt(this.generateNumber(!1))}visitFixedInt(e,r){let n=this.generateNumber(!0);return e._bits<=32?n:BigInt(r)}visitFixedNat(e,r){let n=this.generateNumber(!1);return e._bits<=32?n:BigInt(r)}generateNumber(e){let r=Math.floor(Math.random()*100);return e&&Math.random()<.5?-r:r}};function Qm(t,e,r){return e.random&&r===""?t.accept(new mu,r):t.accept(new gu,r)}function wu(t){return t.accept(new Mo,null)}Ee.renderInput=wu;function Vn(t,e,r){return t.accept(new bu,{input:e,value:r})}Ee.renderValue=Vn;var bu=class extends qo.Visitor{visitType(e,r){r.input.ui.input.value=e.valueToString(r.value)}visitNull(e,r){}visitText(e,r){r.input.ui.input.value=r.value}visitRec(e,r,n){Vn(r,n.input,n.value)}visitOpt(e,r,n){if(n.value.length!==0){let i=n.input.ui.form,s=i.ui.open;s.checked=!0,s.dispatchEvent(new Event(i.ui.event)),Vn(r,i.form[0],n.value[0])}}visitRecord(e,r,n){let i=n.input.ui.form;r.forEach(([s,o],a)=>{Vn(o,i.form[a],n.value[s])})}visitTuple(e,r,n){let i=n.input.ui.form;r.forEach((s,o)=>{Vn(s,i.form[o],n.value[o])})}visitVariant(e,r,n){let i=n.input.ui.form,s=Object.entries(n.value)[0];r.forEach(([o,a],c)=>{if(o===s[0]){let f=i.ui.open;f.selectedIndex=c,f.dispatchEvent(new Event(i.ui.event)),Vn(a,i.form[0],s[1])}})}visitVec(e,r,n){let i=n.input.ui.form,s=n.value.length,o=i.ui.open;o.value=s,o.dispatchEvent(new Event(i.ui.event)),n.value.forEach((a,c)=>{Vn(r,i.form[c],a)})}}});var Xd=ee(Zd=>{"use strict";Object.defineProperty(Zd,"__esModule",{value:!0})});var xi=ee(ht=>{"use strict";var Qd=ht&&ht.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Lm=ht&&ht.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ei=ht&&ht.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Qd(e,t,r)},eb=ht&&ht.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Qd(e,t,r);return Lm(e,t),e};Object.defineProperty(ht,"__esModule",{value:!0});ht.IDL=void 0;Ei(Jd(),ht);Ei(yu(),ht);ht.IDL=eb(cu());Ei(tu(),ht);Ei(nu(),ht);Ei(wo(),ht);Ei(Xd(),ht)});var as=ee((Ld,jo)=>{(function(t){"use strict";var e,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",a=1e14,c=14,f=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],h=1e7,g=1e9;function b(E){var k,G,z,q=F.prototype={constructor:F,toString:null,valueOf:null},oe=new F(1),Q=20,ie=4,w=-7,m=21,R=-1e7,S=1e7,B=!1,V=1,J=0,ae={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},ce="0123456789abcdefghijklmnopqrstuvwxyz",D=!0;function F(u,y){var _,U,T,P,H,x,C,$,j=this;if(!(j instanceof F))return new F(u,y);if(y==null){if(u&&u._isBigNumber===!0){j.s=u.s,!u.c||u.e>S?j.c=j.e=null:u.e<R?j.c=[j.e=0]:(j.e=u.e,j.c=u.c.slice());return}if((x=typeof u=="number")&&u*0==0){if(j.s=1/u<0?(u=-u,-1):1,u===~~u){for(P=0,H=u;H>=10;H/=10,P++);P>S?j.c=j.e=null:(j.e=P,j.c=[u]);return}$=String(u)}else{if(!r.test($=String(u)))return z(j,$,x);j.s=$.charCodeAt(0)==45?($=$.slice(1),-1):1}(P=$.indexOf("."))>-1&&($=$.replace(".","")),(H=$.search(/e/i))>0?(P<0&&(P=H),P+=+$.slice(H+1),$=$.substring(0,H)):P<0&&(P=$.length)}else{if(I(y,2,ce.length,"Base"),y==10&&D)return j=new F(u),le(j,Q+j.e+1,ie);if($=String(u),x=typeof u=="number"){if(u*0!=0)return z(j,$,x,y);if(j.s=1/u<0?($=$.slice(1),-1):1,F.DEBUG&&$.replace(/^0\.0*|\./,"").length>15)throw Error(o+u)}else j.s=$.charCodeAt(0)===45?($=$.slice(1),-1):1;for(_=ce.slice(0,y),P=H=0,C=$.length;H<C;H++)if(_.indexOf(U=$.charAt(H))<0){if(U=="."){if(H>P){P=C;continue}}else if(!T&&($==$.toUpperCase()&&($=$.toLowerCase())||$==$.toLowerCase()&&($=$.toUpperCase()))){T=!0,H=-1,P=0;continue}return z(j,String(u),x,y)}x=!1,$=G($,y,10,j.s),(P=$.indexOf("."))>-1?$=$.replace(".",""):P=$.length}for(H=0;$.charCodeAt(H)===48;H++);for(C=$.length;$.charCodeAt(--C)===48;);if($=$.slice(H,++C)){if(C-=H,x&&F.DEBUG&&C>15&&(u>f||u!==i(u)))throw Error(o+j.s*u);if((P=P-H-1)>S)j.c=j.e=null;else if(P<R)j.c=[j.e=0];else{if(j.e=P,j.c=[],H=(P+1)%c,P<0&&(H+=c),H<C){for(H&&j.c.push(+$.slice(0,H)),C-=c;H<C;)j.c.push(+$.slice(H,H+=c));H=c-($=$.slice(H)).length}else H-=C;for(;H--;$+="0");j.c.push(+$)}}else j.c=[j.e=0]}F.clone=b,F.ROUND_UP=0,F.ROUND_DOWN=1,F.ROUND_CEIL=2,F.ROUND_FLOOR=3,F.ROUND_HALF_UP=4,F.ROUND_HALF_DOWN=5,F.ROUND_HALF_EVEN=6,F.ROUND_HALF_CEIL=7,F.ROUND_HALF_FLOOR=8,F.EUCLID=9,F.config=F.set=function(u){var y,_;if(u!=null)if(typeof u=="object"){if(u.hasOwnProperty(y="DECIMAL_PLACES")&&(_=u[y],I(_,0,g,y),Q=_),u.hasOwnProperty(y="ROUNDING_MODE")&&(_=u[y],I(_,0,8,y),ie=_),u.hasOwnProperty(y="EXPONENTIAL_AT")&&(_=u[y],_&&_.pop?(I(_[0],-g,0,y),I(_[1],0,g,y),w=_[0],m=_[1]):(I(_,-g,g,y),w=-(m=_<0?-_:_))),u.hasOwnProperty(y="RANGE"))if(_=u[y],_&&_.pop)I(_[0],-g,-1,y),I(_[1],1,g,y),R=_[0],S=_[1];else if(I(_,-g,g,y),_)R=-(S=_<0?-_:_);else throw Error(s+y+" cannot be zero: "+_);if(u.hasOwnProperty(y="CRYPTO"))if(_=u[y],_===!!_)if(_)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))B=_;else throw B=!_,Error(s+"crypto unavailable");else B=_;else throw Error(s+y+" not true or false: "+_);if(u.hasOwnProperty(y="MODULO_MODE")&&(_=u[y],I(_,0,9,y),V=_),u.hasOwnProperty(y="POW_PRECISION")&&(_=u[y],I(_,0,g,y),J=_),u.hasOwnProperty(y="FORMAT"))if(_=u[y],typeof _=="object")ae=_;else throw Error(s+y+" not an object: "+_);if(u.hasOwnProperty(y="ALPHABET"))if(_=u[y],typeof _=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(_))D=_.slice(0,10)=="0123456789",ce=_;else throw Error(s+y+" invalid: "+_)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:Q,ROUNDING_MODE:ie,EXPONENTIAL_AT:[w,m],RANGE:[R,S],CRYPTO:B,MODULO_MODE:V,POW_PRECISION:J,FORMAT:ae,ALPHABET:ce}},F.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!F.DEBUG)return!0;var y,_,U=u.c,T=u.e,P=u.s;e:if({}.toString.call(U)=="[object Array]"){if((P===1||P===-1)&&T>=-g&&T<=g&&T===i(T)){if(U[0]===0){if(T===0&&U.length===1)return!0;break e}if(y=(T+1)%c,y<1&&(y+=c),String(U[0]).length==y){for(y=0;y<U.length;y++)if(_=U[y],_<0||_>=a||_!==i(_))break e;if(_!==0)return!0}}}else if(U===null&&T===null&&(P===null||P===1||P===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},F.maximum=F.max=function(){return L(arguments,-1)},F.minimum=F.min=function(){return L(arguments,1)},F.random=function(){var u=9007199254740992,y=Math.random()*u&2097151?function(){return i(Math.random()*u)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(_){var U,T,P,H,x,C=0,$=[],j=new F(oe);if(_==null?_=Q:I(_,0,g),H=n(_/c),B)if(crypto.getRandomValues){for(U=crypto.getRandomValues(new Uint32Array(H*=2));C<H;)x=U[C]*131072+(U[C+1]>>>11),x>=9e15?(T=crypto.getRandomValues(new Uint32Array(2)),U[C]=T[0],U[C+1]=T[1]):($.push(x%1e14),C+=2);C=H/2}else if(crypto.randomBytes){for(U=crypto.randomBytes(H*=7);C<H;)x=(U[C]&31)*281474976710656+U[C+1]*1099511627776+U[C+2]*4294967296+U[C+3]*16777216+(U[C+4]<<16)+(U[C+5]<<8)+U[C+6],x>=9e15?crypto.randomBytes(7).copy(U,C):($.push(x%1e14),C+=7);C=H/7}else throw B=!1,Error(s+"crypto unavailable");if(!B)for(;C<H;)x=y(),x<9e15&&($[C++]=x%1e14);for(H=$[--C],_%=c,H&&_&&(x=d[c-_],$[C]=i(H/x)*x);$[C]===0;$.pop(),C--);if(C<0)$=[P=0];else{for(P=-1;$[0]===0;$.splice(0,1),P-=c);for(C=1,x=$[0];x>=10;x/=10,C++);C<c&&(P-=c-C)}return j.e=P,j.c=$,j}}(),F.sum=function(){for(var u=1,y=arguments,_=new F(y[0]);u<y.length;)_=_.plus(y[u++]);return _},G=function(){var u="0123456789";function y(_,U,T,P){for(var H,x=[0],C,$=0,j=_.length;$<j;){for(C=x.length;C--;x[C]*=U);for(x[0]+=P.indexOf(_.charAt($++)),H=0;H<x.length;H++)x[H]>T-1&&(x[H+1]==null&&(x[H+1]=0),x[H+1]+=x[H]/T|0,x[H]%=T)}return x.reverse()}return function(_,U,T,P,H){var x,C,$,j,Z,te,fe,me,Re=_.indexOf("."),Me=Q,ye=ie;for(Re>=0&&(j=J,J=0,_=_.replace(".",""),me=new F(U),te=me.pow(_.length-Re),J=j,me.c=y(K(N(te.c),te.e,"0"),10,T,u),me.e=me.c.length),fe=y(_,U,T,H?(x=ce,u):(x=u,ce)),$=j=fe.length;fe[--j]==0;fe.pop());if(!fe[0])return x.charAt(0);if(Re<0?--$:(te.c=fe,te.e=$,te.s=P,te=k(te,me,Me,ye,T),fe=te.c,Z=te.r,$=te.e),C=$+Me+1,Re=fe[C],j=T/2,Z=Z||C<0||fe[C+1]!=null,Z=ye<4?(Re!=null||Z)&&(ye==0||ye==(te.s<0?3:2)):Re>j||Re==j&&(ye==4||Z||ye==6&&fe[C-1]&1||ye==(te.s<0?8:7)),C<1||!fe[0])_=Z?K(x.charAt(1),-Me,x.charAt(0)):x.charAt(0);else{if(fe.length=C,Z)for(--T;++fe[--C]>T;)fe[C]=0,C||(++$,fe=[1].concat(fe));for(j=fe.length;!fe[--j];);for(Re=0,_="";Re<=j;_+=x.charAt(fe[Re++]));_=K(_,$,x.charAt(0))}return _}}(),k=function(){function u(U,T,P){var H,x,C,$,j=0,Z=U.length,te=T%h,fe=T/h|0;for(U=U.slice();Z--;)C=U[Z]%h,$=U[Z]/h|0,H=fe*C+$*te,x=te*C+H%h*h+j,j=(x/P|0)+(H/h|0)+fe*$,U[Z]=x%P;return j&&(U=[j].concat(U)),U}function y(U,T,P,H){var x,C;if(P!=H)C=P>H?1:-1;else for(x=C=0;x<P;x++)if(U[x]!=T[x]){C=U[x]>T[x]?1:-1;break}return C}function _(U,T,P,H){for(var x=0;P--;)U[P]-=x,x=U[P]<T[P]?1:0,U[P]=x*H+U[P]-T[P];for(;!U[0]&&U.length>1;U.splice(0,1));}return function(U,T,P,H,x){var C,$,j,Z,te,fe,me,Re,Me,ye,he,Ze,vr,zr,Dr,kt,Be,Tt=U.s==T.s?1:-1,st=U.c,$e=T.c;if(!st||!st[0]||!$e||!$e[0])return new F(!U.s||!T.s||(st?$e&&st[0]==$e[0]:!$e)?NaN:st&&st[0]==0||!$e?Tt*0:Tt/0);for(Re=new F(Tt),Me=Re.c=[],$=U.e-T.e,Tt=P+$+1,x||(x=a,$=l(U.e/c)-l(T.e/c),Tt=Tt/c|0),j=0;$e[j]==(st[j]||0);j++);if($e[j]>(st[j]||0)&&$--,Tt<0)Me.push(1),Z=!0;else{for(zr=st.length,kt=$e.length,j=0,Tt+=2,te=i(x/($e[0]+1)),te>1&&($e=u($e,te,x),st=u(st,te,x),kt=$e.length,zr=st.length),vr=kt,ye=st.slice(0,kt),he=ye.length;he<kt;ye[he++]=0);Be=$e.slice(),Be=[0].concat(Be),Dr=$e[0],$e[1]>=x/2&&Dr++;do{if(te=0,C=y($e,ye,kt,he),C<0){if(Ze=ye[0],kt!=he&&(Ze=Ze*x+(ye[1]||0)),te=i(Ze/Dr),te>1)for(te>=x&&(te=x-1),fe=u($e,te,x),me=fe.length,he=ye.length;y(fe,ye,me,he)==1;)te--,_(fe,kt<me?Be:$e,me,x),me=fe.length,C=1;else te==0&&(C=te=1),fe=$e.slice(),me=fe.length;if(me<he&&(fe=[0].concat(fe)),_(ye,fe,he,x),he=ye.length,C==-1)for(;y($e,ye,kt,he)<1;)te++,_(ye,kt<he?Be:$e,he,x),he=ye.length}else C===0&&(te++,ye=[0]);Me[j++]=te,ye[0]?ye[he++]=st[vr]||0:(ye=[st[vr]],he=1)}while((vr++<zr||ye[0]!=null)&&Tt--);Z=ye[0]!=null,Me[0]||Me.splice(0,1)}if(x==a){for(j=1,Tt=Me[0];Tt>=10;Tt/=10,j++);le(Re,P+(Re.e=j+$*c-1)+1,H,Z)}else Re.e=$,Re.r=+Z;return Re}}();function p(u,y,_,U){var T,P,H,x,C;if(_==null?_=ie:I(_,0,8),!u.c)return u.toString();if(T=u.c[0],H=u.e,y==null)C=N(u.c),C=U==1||U==2&&(H<=w||H>=m)?A(C,H):K(C,H,"0");else if(u=le(new F(u),y,_),P=u.e,C=N(u.c),x=C.length,U==1||U==2&&(y<=P||P<=w)){for(;x<y;C+="0",x++);C=A(C,P)}else if(y-=H,C=K(C,P,"0"),P+1>x){if(--y>0)for(C+=".";y--;C+="0");}else if(y+=P-x,y>0)for(P+1==x&&(C+=".");y--;C+="0");return u.s<0&&T?"-"+C:C}function L(u,y){for(var _,U,T=1,P=new F(u[0]);T<u.length;T++)U=new F(u[T]),(!U.s||(_=O(P,U))===y||_===0&&P.s===y)&&(P=U);return P}function re(u,y,_){for(var U=1,T=y.length;!y[--T];y.pop());for(T=y[0];T>=10;T/=10,U++);return(_=U+_*c-1)>S?u.c=u.e=null:_<R?u.c=[u.e=0]:(u.e=_,u.c=y),u}z=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,y=/^([^.]+)\.$/,_=/^\.([^.]+)$/,U=/^-?(Infinity|NaN)$/,T=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(P,H,x,C){var $,j=x?H:H.replace(T,"");if(U.test(j))P.s=isNaN(j)?null:j<0?-1:1;else{if(!x&&(j=j.replace(u,function(Z,te,fe){return $=(fe=fe.toLowerCase())=="x"?16:fe=="b"?2:8,!C||C==$?te:Z}),C&&($=C,j=j.replace(y,"$1").replace(_,"0.$1")),H!=j))return new F(j,$);if(F.DEBUG)throw Error(s+"Not a"+(C?" base "+C:"")+" number: "+H);P.s=null}P.c=P.e=null}}();function le(u,y,_,U){var T,P,H,x,C,$,j,Z=u.c,te=d;if(Z){e:{for(T=1,x=Z[0];x>=10;x/=10,T++);if(P=y-T,P<0)P+=c,H=y,C=Z[$=0],j=i(C/te[T-H-1]%10);else if($=n((P+1)/c),$>=Z.length)if(U){for(;Z.length<=$;Z.push(0));C=j=0,T=1,P%=c,H=P-c+1}else break e;else{for(C=x=Z[$],T=1;x>=10;x/=10,T++);P%=c,H=P-c+T,j=H<0?0:i(C/te[T-H-1]%10)}if(U=U||y<0||Z[$+1]!=null||(H<0?C:C%te[T-H-1]),U=_<4?(j||U)&&(_==0||_==(u.s<0?3:2)):j>5||j==5&&(_==4||U||_==6&&(P>0?H>0?C/te[T-H]:0:Z[$-1])%10&1||_==(u.s<0?8:7)),y<1||!Z[0])return Z.length=0,U?(y-=u.e+1,Z[0]=te[(c-y%c)%c],u.e=-y||0):Z[0]=u.e=0,u;if(P==0?(Z.length=$,x=1,$--):(Z.length=$+1,x=te[c-P],Z[$]=H>0?i(C/te[T-H]%te[H])*x:0),U)for(;;)if($==0){for(P=1,H=Z[0];H>=10;H/=10,P++);for(H=Z[0]+=x,x=1;H>=10;H/=10,x++);P!=x&&(u.e++,Z[0]==a&&(Z[0]=1));break}else{if(Z[$]+=x,Z[$]!=a)break;Z[$--]=0,x=1}for(P=Z.length;Z[--P]===0;Z.pop());}u.e>S?u.c=u.e=null:u.e<R&&(u.c=[u.e=0])}return u}function X(u){var y,_=u.e;return _===null?u.toString():(y=N(u.c),y=_<=w||_>=m?A(y,_):K(y,_,"0"),u.s<0?"-"+y:y)}return q.absoluteValue=q.abs=function(){var u=new F(this);return u.s<0&&(u.s=1),u},q.comparedTo=function(u,y){return O(this,new F(u,y))},q.decimalPlaces=q.dp=function(u,y){var _,U,T,P=this;if(u!=null)return I(u,0,g),y==null?y=ie:I(y,0,8),le(new F(P),u+P.e+1,y);if(!(_=P.c))return null;if(U=((T=_.length-1)-l(this.e/c))*c,T=_[T])for(;T%10==0;T/=10,U--);return U<0&&(U=0),U},q.dividedBy=q.div=function(u,y){return k(this,new F(u,y),Q,ie)},q.dividedToIntegerBy=q.idiv=function(u,y){return k(this,new F(u,y),0,1)},q.exponentiatedBy=q.pow=function(u,y){var _,U,T,P,H,x,C,$,j,Z=this;if(u=new F(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+X(u));if(y!=null&&(y=new F(y)),x=u.e>14,!Z.c||!Z.c[0]||Z.c[0]==1&&!Z.e&&Z.c.length==1||!u.c||!u.c[0])return j=new F(Math.pow(+X(Z),x?u.s*(2-M(u)):+X(u))),y?j.mod(y):j;if(C=u.s<0,y){if(y.c?!y.c[0]:!y.s)return new F(NaN);U=!C&&Z.isInteger()&&y.isInteger(),U&&(Z=Z.mod(y))}else{if(u.e>9&&(Z.e>0||Z.e<-1||(Z.e==0?Z.c[0]>1||x&&Z.c[1]>=24e7:Z.c[0]<8e13||x&&Z.c[0]<=9999975e7)))return P=Z.s<0&&M(u)?-0:0,Z.e>-1&&(P=1/P),new F(C?1/P:P);J&&(P=n(J/c+2))}for(x?(_=new F(.5),C&&(u.s=1),$=M(u)):(T=Math.abs(+X(u)),$=T%2),j=new F(oe);;){if($){if(j=j.times(Z),!j.c)break;P?j.c.length>P&&(j.c.length=P):U&&(j=j.mod(y))}if(T){if(T=i(T/2),T===0)break;$=T%2}else if(u=u.times(_),le(u,u.e+1,1),u.e>14)$=M(u);else{if(T=+X(u),T===0)break;$=T%2}Z=Z.times(Z),P?Z.c&&Z.c.length>P&&(Z.c.length=P):U&&(Z=Z.mod(y))}return U?j:(C&&(j=oe.div(j)),y?j.mod(y):P?le(j,J,ie,H):j)},q.integerValue=function(u){var y=new F(this);return u==null?u=ie:I(u,0,8),le(y,y.e+1,u)},q.isEqualTo=q.eq=function(u,y){return O(this,new F(u,y))===0},q.isFinite=function(){return!!this.c},q.isGreaterThan=q.gt=function(u,y){return O(this,new F(u,y))>0},q.isGreaterThanOrEqualTo=q.gte=function(u,y){return(y=O(this,new F(u,y)))===1||y===0},q.isInteger=function(){return!!this.c&&l(this.e/c)>this.c.length-2},q.isLessThan=q.lt=function(u,y){return O(this,new F(u,y))<0},q.isLessThanOrEqualTo=q.lte=function(u,y){return(y=O(this,new F(u,y)))===-1||y===0},q.isNaN=function(){return!this.s},q.isNegative=function(){return this.s<0},q.isPositive=function(){return this.s>0},q.isZero=function(){return!!this.c&&this.c[0]==0},q.minus=function(u,y){var _,U,T,P,H=this,x=H.s;if(u=new F(u,y),y=u.s,!x||!y)return new F(NaN);if(x!=y)return u.s=-y,H.plus(u);var C=H.e/c,$=u.e/c,j=H.c,Z=u.c;if(!C||!$){if(!j||!Z)return j?(u.s=-y,u):new F(Z?H:NaN);if(!j[0]||!Z[0])return Z[0]?(u.s=-y,u):new F(j[0]?H:ie==3?-0:0)}if(C=l(C),$=l($),j=j.slice(),x=C-$){for((P=x<0)?(x=-x,T=j):($=C,T=Z),T.reverse(),y=x;y--;T.push(0));T.reverse()}else for(U=(P=(x=j.length)<(y=Z.length))?x:y,x=y=0;y<U;y++)if(j[y]!=Z[y]){P=j[y]<Z[y];break}if(P&&(T=j,j=Z,Z=T,u.s=-u.s),y=(U=Z.length)-(_=j.length),y>0)for(;y--;j[_++]=0);for(y=a-1;U>x;){if(j[--U]<Z[U]){for(_=U;_&&!j[--_];j[_]=y);--j[_],j[U]+=a}j[U]-=Z[U]}for(;j[0]==0;j.splice(0,1),--$);return j[0]?re(u,j,$):(u.s=ie==3?-1:1,u.c=[u.e=0],u)},q.modulo=q.mod=function(u,y){var _,U,T=this;return u=new F(u,y),!T.c||!u.s||u.c&&!u.c[0]?new F(NaN):!u.c||T.c&&!T.c[0]?new F(T):(V==9?(U=u.s,u.s=1,_=k(T,u,0,3),u.s=U,_.s*=U):_=k(T,u,0,V),u=T.minus(_.times(u)),!u.c[0]&&V==1&&(u.s=T.s),u)},q.multipliedBy=q.times=function(u,y){var _,U,T,P,H,x,C,$,j,Z,te,fe,me,Re,Me,ye=this,he=ye.c,Ze=(u=new F(u,y)).c;if(!he||!Ze||!he[0]||!Ze[0])return!ye.s||!u.s||he&&!he[0]&&!Ze||Ze&&!Ze[0]&&!he?u.c=u.e=u.s=null:(u.s*=ye.s,!he||!Ze?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(U=l(ye.e/c)+l(u.e/c),u.s*=ye.s,C=he.length,Z=Ze.length,C<Z&&(me=he,he=Ze,Ze=me,T=C,C=Z,Z=T),T=C+Z,me=[];T--;me.push(0));for(Re=a,Me=h,T=Z;--T>=0;){for(_=0,te=Ze[T]%Me,fe=Ze[T]/Me|0,H=C,P=T+H;P>T;)$=he[--H]%Me,j=he[H]/Me|0,x=fe*$+j*te,$=te*$+x%Me*Me+me[P]+_,_=($/Re|0)+(x/Me|0)+fe*j,me[P--]=$%Re;me[P]=_}return _?++U:me.splice(0,1),re(u,me,U)},q.negated=function(){var u=new F(this);return u.s=-u.s||null,u},q.plus=function(u,y){var _,U=this,T=U.s;if(u=new F(u,y),y=u.s,!T||!y)return new F(NaN);if(T!=y)return u.s=-y,U.minus(u);var P=U.e/c,H=u.e/c,x=U.c,C=u.c;if(!P||!H){if(!x||!C)return new F(T/0);if(!x[0]||!C[0])return C[0]?u:new F(x[0]?U:T*0)}if(P=l(P),H=l(H),x=x.slice(),T=P-H){for(T>0?(H=P,_=C):(T=-T,_=x),_.reverse();T--;_.push(0));_.reverse()}for(T=x.length,y=C.length,T-y<0&&(_=C,C=x,x=_,y=T),T=0;y;)T=(x[--y]=x[y]+C[y]+T)/a|0,x[y]=a===x[y]?0:x[y]%a;return T&&(x=[T].concat(x),++H),re(u,x,H)},q.precision=q.sd=function(u,y){var _,U,T,P=this;if(u!=null&&u!==!!u)return I(u,1,g),y==null?y=ie:I(y,0,8),le(new F(P),u,y);if(!(_=P.c))return null;if(T=_.length-1,U=T*c+1,T=_[T]){for(;T%10==0;T/=10,U--);for(T=_[0];T>=10;T/=10,U++);}return u&&P.e+1>U&&(U=P.e+1),U},q.shiftedBy=function(u){return I(u,-f,f),this.times("1e"+u)},q.squareRoot=q.sqrt=function(){var u,y,_,U,T,P=this,H=P.c,x=P.s,C=P.e,$=Q+4,j=new F("0.5");if(x!==1||!H||!H[0])return new F(!x||x<0&&(!H||H[0])?NaN:H?P:1/0);if(x=Math.sqrt(+X(P)),x==0||x==1/0?(y=N(H),(y.length+C)%2==0&&(y+="0"),x=Math.sqrt(+y),C=l((C+1)/2)-(C<0||C%2),x==1/0?y="5e"+C:(y=x.toExponential(),y=y.slice(0,y.indexOf("e")+1)+C),_=new F(y)):_=new F(x+""),_.c[0]){for(C=_.e,x=C+$,x<3&&(x=0);;)if(T=_,_=j.times(T.plus(k(P,T,$,1))),N(T.c).slice(0,x)===(y=N(_.c)).slice(0,x))if(_.e<C&&--x,y=y.slice(x-3,x+1),y=="9999"||!U&&y=="4999"){if(!U&&(le(T,T.e+Q+2,0),T.times(T).eq(P))){_=T;break}$+=4,x+=4,U=1}else{(!+y||!+y.slice(1)&&y.charAt(0)=="5")&&(le(_,_.e+Q+2,1),u=!_.times(_).eq(P));break}}return le(_,_.e+Q+1,ie,u)},q.toExponential=function(u,y){return u!=null&&(I(u,0,g),u++),p(this,u,y,1)},q.toFixed=function(u,y){return u!=null&&(I(u,0,g),u=u+this.e+1),p(this,u,y)},q.toFormat=function(u,y,_){var U,T=this;if(_==null)u!=null&&y&&typeof y=="object"?(_=y,y=null):u&&typeof u=="object"?(_=u,u=y=null):_=ae;else if(typeof _!="object")throw Error(s+"Argument not an object: "+_);if(U=T.toFixed(u,y),T.c){var P,H=U.split("."),x=+_.groupSize,C=+_.secondaryGroupSize,$=_.groupSeparator||"",j=H[0],Z=H[1],te=T.s<0,fe=te?j.slice(1):j,me=fe.length;if(C&&(P=x,x=C,C=P,me-=P),x>0&&me>0){for(P=me%x||x,j=fe.substr(0,P);P<me;P+=x)j+=$+fe.substr(P,x);C>0&&(j+=$+fe.slice(P)),te&&(j="-"+j)}U=Z?j+(_.decimalSeparator||"")+((C=+_.fractionGroupSize)?Z.replace(new RegExp("\\d{"+C+"}\\B","g"),"$&"+(_.fractionGroupSeparator||"")):Z):j}return(_.prefix||"")+U+(_.suffix||"")},q.toFraction=function(u){var y,_,U,T,P,H,x,C,$,j,Z,te,fe=this,me=fe.c;if(u!=null&&(x=new F(u),!x.isInteger()&&(x.c||x.s!==1)||x.lt(oe)))throw Error(s+"Argument "+(x.isInteger()?"out of range: ":"not an integer: ")+X(x));if(!me)return new F(fe);for(y=new F(oe),$=_=new F(oe),U=C=new F(oe),te=N(me),P=y.e=te.length-fe.e-1,y.c[0]=d[(H=P%c)<0?c+H:H],u=!u||x.comparedTo(y)>0?P>0?y:$:x,H=S,S=1/0,x=new F(te),C.c[0]=0;j=k(x,y,0,1),T=_.plus(j.times(U)),T.comparedTo(u)!=1;)_=U,U=T,$=C.plus(j.times(T=$)),C=T,y=x.minus(j.times(T=y)),x=T;return T=k(u.minus(_),U,0,1),C=C.plus(T.times($)),_=_.plus(T.times(U)),C.s=$.s=fe.s,P=P*2,Z=k($,U,P,ie).minus(fe).abs().comparedTo(k(C,_,P,ie).minus(fe).abs())<1?[$,U]:[C,_],S=H,Z},q.toNumber=function(){return+X(this)},q.toPrecision=function(u,y){return u!=null&&I(u,1,g),p(this,u,y,2)},q.toString=function(u){var y,_=this,U=_.s,T=_.e;return T===null?U?(y="Infinity",U<0&&(y="-"+y)):y="NaN":(u==null?y=T<=w||T>=m?A(N(_.c),T):K(N(_.c),T,"0"):u===10&&D?(_=le(new F(_),Q+T+1,ie),y=K(N(_.c),_.e,"0")):(I(u,2,ce.length,"Base"),y=G(K(N(_.c),T,"0"),10,u,U,!0)),U<0&&_.c[0]&&(y="-"+y)),y},q.valueOf=q.toJSON=function(){return X(this)},q._isBigNumber=!0,E!=null&&F.set(E),F}function l(E){var k=E|0;return E>0||E===k?k:k-1}function N(E){for(var k,G,z=1,q=E.length,oe=E[0]+"";z<q;){for(k=E[z++]+"",G=c-k.length;G--;k="0"+k);oe+=k}for(q=oe.length;oe.charCodeAt(--q)===48;);return oe.slice(0,q+1||1)}function O(E,k){var G,z,q=E.c,oe=k.c,Q=E.s,ie=k.s,w=E.e,m=k.e;if(!Q||!ie)return null;if(G=q&&!q[0],z=oe&&!oe[0],G||z)return G?z?0:-ie:Q;if(Q!=ie)return Q;if(G=Q<0,z=w==m,!q||!oe)return z?0:!q^G?1:-1;if(!z)return w>m^G?1:-1;for(ie=(w=q.length)<(m=oe.length)?w:m,Q=0;Q<ie;Q++)if(q[Q]!=oe[Q])return q[Q]>oe[Q]^G?1:-1;return w==m?0:w>m^G?1:-1}function I(E,k,G,z){if(E<k||E>G||E!==i(E))throw Error(s+(z||"Argument")+(typeof E=="number"?E<k||E>G?" out of range: ":" not an integer: ":" not a primitive number: ")+String(E))}function M(E){var k=E.c.length-1;return l(E.e/c)==k&&E.c[k]%2!=0}function A(E,k){return(E.length>1?E.charAt(0)+"."+E.slice(1):E)+(k<0?"e":"e+")+k}function K(E,k,G){var z,q;if(k<0){for(q=G+".";++k;q+=G);E=q+E}else if(z=E.length,++k>z){for(q=G,k-=z;--k;q+=G);E+=q}else k<z&&(E=E.slice(0,k)+"."+E.slice(k));return E}e=b(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof jo<"u"&&jo.exports?jo.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(Ld)});var t0=ee((dv,e0)=>{e0.exports=function(e,r,n){var i=new e.Uint8Array(n),s=r.pushInt,o=r.pushInt32,a=r.pushInt32Neg,c=r.pushInt64,f=r.pushInt64Neg,d=r.pushFloat,h=r.pushFloatSingle,g=r.pushFloatDouble,b=r.pushTrue,l=r.pushFalse,N=r.pushUndefined,O=r.pushNull,I=r.pushInfinity,M=r.pushInfinityNeg,A=r.pushNaN,K=r.pushNaNNeg,E=r.pushArrayStart,k=r.pushArrayStartFixed,G=r.pushArrayStartFixed32,z=r.pushArrayStartFixed64,q=r.pushObjectStart,oe=r.pushObjectStartFixed,Q=r.pushObjectStartFixed32,ie=r.pushObjectStartFixed64,w=r.pushByteString,m=r.pushByteStringStart,R=r.pushUtf8String,S=r.pushUtf8StringStart,B=r.pushSimpleUnassigned,V=r.pushTagStart,J=r.pushTagStart4,ae=r.pushTagStart8,ce=r.pushTagUnassigned,D=r.pushBreak,F=e.Math.pow,p=0,L=0,re=0;function le(v){for(v=v|0,p=0,L=v;(p|0)<(L|0)&&(re=X_[i[p]&255](i[p]|0)|0,!((re|0)>0)););return re|0}function X(v){return v=v|0,((p|0)+(v|0)|0)<(L|0)?0:1}function u(v){return v=v|0,i[v|0]<<8|i[v+1|0]|0}function y(v){return v=v|0,i[v|0]<<24|i[v+1|0]<<16|i[v+2|0]<<8|i[v+3|0]|0}function _(v){return v=v|0,s(v|0),p=p+1|0,0}function U(v){return v=v|0,X(1)|0?1:(s(i[p+1|0]|0),p=p+2|0,0)}function T(v){return v=v|0,X(2)|0?1:(s(u(p+1|0)|0),p=p+3|0,0)}function P(v){return v=v|0,X(4)|0?1:(o(u(p+1|0)|0,u(p+3|0)|0),p=p+5|0,0)}function H(v){return v=v|0,X(8)|0?1:(c(u(p+1|0)|0,u(p+3|0)|0,u(p+5|0)|0,u(p+7|0)|0),p=p+9|0,0)}function x(v){return v=v|0,s(-1-(v-32|0)|0),p=p+1|0,0}function C(v){return v=v|0,X(1)|0?1:(s(-1-(i[p+1|0]|0)|0),p=p+2|0,0)}function $(v){v=v|0;var Ae=0;return X(2)|0?1:(Ae=u(p+1|0)|0,s(-1-(Ae|0)|0),p=p+3|0,0)}function j(v){return v=v|0,X(4)|0?1:(a(u(p+1|0)|0,u(p+3|0)|0),p=p+5|0,0)}function Z(v){return v=v|0,X(8)|0?1:(f(u(p+1|0)|0,u(p+3|0)|0,u(p+5|0)|0,u(p+7|0)|0),p=p+9|0,0)}function te(v){v=v|0;var Ae=0,Ne=0,xe=0;return xe=v-64|0,X(xe|0)|0?1:(Ae=p+1|0,Ne=(p+1|0)+(xe|0)|0,w(Ae|0,Ne|0),p=Ne|0,0)}function fe(v){v=v|0;var Ae=0,Ne=0,xe=0;return X(1)|0||(xe=i[p+1|0]|0,Ae=p+2|0,Ne=(p+2|0)+(xe|0)|0,X(xe+1|0)|0)?1:(w(Ae|0,Ne|0),p=Ne|0,0)}function me(v){v=v|0;var Ae=0,Ne=0,xe=0;return X(2)|0||(xe=u(p+1|0)|0,Ae=p+3|0,Ne=(p+3|0)+(xe|0)|0,X(xe+2|0)|0)?1:(w(Ae|0,Ne|0),p=Ne|0,0)}function Re(v){v=v|0;var Ae=0,Ne=0,xe=0;return X(4)|0||(xe=y(p+1|0)|0,Ae=p+5|0,Ne=(p+5|0)+(xe|0)|0,X(xe+4|0)|0)?1:(w(Ae|0,Ne|0),p=Ne|0,0)}function Me(v){return v=v|0,1}function ye(v){return v=v|0,m(),p=p+1|0,0}function he(v){v=v|0;var Ae=0,Ne=0,xe=0;return xe=v-96|0,X(xe|0)|0?1:(Ae=p+1|0,Ne=(p+1|0)+(xe|0)|0,R(Ae|0,Ne|0),p=Ne|0,0)}function Ze(v){v=v|0;var Ae=0,Ne=0,xe=0;return X(1)|0||(xe=i[p+1|0]|0,Ae=p+2|0,Ne=(p+2|0)+(xe|0)|0,X(xe+1|0)|0)?1:(R(Ae|0,Ne|0),p=Ne|0,0)}function vr(v){v=v|0;var Ae=0,Ne=0,xe=0;return X(2)|0||(xe=u(p+1|0)|0,Ae=p+3|0,Ne=(p+3|0)+(xe|0)|0,X(xe+2|0)|0)?1:(R(Ae|0,Ne|0),p=Ne|0,0)}function zr(v){v=v|0;var Ae=0,Ne=0,xe=0;return X(4)|0||(xe=y(p+1|0)|0,Ae=p+5|0,Ne=(p+5|0)+(xe|0)|0,X(xe+4|0)|0)?1:(R(Ae|0,Ne|0),p=Ne|0,0)}function Dr(v){return v=v|0,1}function kt(v){return v=v|0,S(),p=p+1|0,0}function Be(v){return v=v|0,k(v-128|0),p=p+1|0,0}function Tt(v){return v=v|0,X(1)|0?1:(k(i[p+1|0]|0),p=p+2|0,0)}function st(v){return v=v|0,X(2)|0?1:(k(u(p+1|0)|0),p=p+3|0,0)}function $e(v){return v=v|0,X(4)|0?1:(G(u(p+1|0)|0,u(p+3|0)|0),p=p+5|0,0)}function xc(v){return v=v|0,X(8)|0?1:(z(u(p+1|0)|0,u(p+3|0)|0,u(p+5|0)|0,u(p+7|0)|0),p=p+9|0,0)}function vc(v){return v=v|0,E(),p=p+1|0,0}function Ke(v){v=v|0;var Ae=0;return Ae=v-160|0,X(Ae|0)|0?1:(oe(Ae|0),p=p+1|0,0)}function Tc(v){return v=v|0,X(1)|0?1:(oe(i[p+1|0]|0),p=p+2|0,0)}function Ac(v){return v=v|0,X(2)|0?1:(oe(u(p+1|0)|0),p=p+3|0,0)}function Oc(v){return v=v|0,X(4)|0?1:(Q(u(p+1|0)|0,u(p+3|0)|0),p=p+5|0,0)}function Sc(v){return v=v|0,X(8)|0?1:(ie(u(p+1|0)|0,u(p+3|0)|0,u(p+5|0)|0,u(p+7|0)|0),p=p+9|0,0)}function Nc(v){return v=v|0,q(),p=p+1|0,0}function an(v){return v=v|0,V(v-192|0|0),p=p+1|0,0}function U8(v){return v=v|0,V(v|0),p=p+1|0,0}function I8(v){return v=v|0,V(v|0),p=p+1|0,0}function C8(v){return v=v|0,V(v|0),p=p+1|0,0}function F8(v){return v=v|0,V(v|0),p=p+1|0,0}function ft(v){return v=v|0,V(v-192|0|0),p=p+1|0,0}function M8(v){return v=v|0,V(v|0),p=p+1|0,0}function q8(v){return v=v|0,V(v|0),p=p+1|0,0}function j8(v){return v=v|0,V(v|0),p=p+1|0,0}function j_(v){return v=v|0,X(1)|0?1:(V(i[p+1|0]|0),p=p+2|0,0)}function k_(v){return v=v|0,X(2)|0?1:(V(u(p+1|0)|0),p=p+3|0,0)}function V_(v){return v=v|0,X(4)|0?1:(J(u(p+1|0)|0,u(p+3|0)|0),p=p+5|0,0)}function H_(v){return v=v|0,X(8)|0?1:(ae(u(p+1|0)|0,u(p+3|0)|0,u(p+5|0)|0,u(p+7|0)|0),p=p+9|0,0)}function rt(v){return v=v|0,B((v|0)-224|0),p=p+1|0,0}function $_(v){return v=v|0,l(),p=p+1|0,0}function K_(v){return v=v|0,b(),p=p+1|0,0}function G_(v){return v=v|0,O(),p=p+1|0,0}function Y_(v){return v=v|0,N(),p=p+1|0,0}function W_(v){return v=v|0,X(1)|0?1:(B(i[p+1|0]|0),p=p+2|0,0)}function z_(v){v=v|0;var Ae=0,Ne=0,xe=1,no=0,Zi=0,k8=0;return X(2)|0?1:(Ae=i[p+1|0]|0,Ne=i[p+2|0]|0,(Ae|0)&128&&(xe=-1),no=+(((Ae|0)&124)>>2),Zi=+(((Ae|0)&3)<<8|Ne),+no==0?d(+(+xe*5960464477539063e-23*+Zi)):+no==31?+xe==1?+Zi>0?A():I():+Zi>0?K():M():d(+(+xe*F(2,+(+no-25))*+(1024+Zi))),p=p+3|0,0)}function D_(v){return v=v|0,X(4)|0?1:(h(i[p+1|0]|0,i[p+2|0]|0,i[p+3|0]|0,i[p+4|0]|0),p=p+5|0,0)}function J_(v){return v=v|0,X(8)|0?1:(g(i[p+1|0]|0,i[p+2|0]|0,i[p+3|0]|0,i[p+4|0]|0,i[p+5|0]|0,i[p+6|0]|0,i[p+7|0]|0,i[p+8|0]|0),p=p+9|0,0)}function Ve(v){return v=v|0,1}function Z_(v){return v=v|0,D(),p=p+1|0,0}var X_=[_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,U,T,P,H,Ve,Ve,Ve,Ve,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,C,$,j,Z,Ve,Ve,Ve,Ve,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,fe,me,Re,Me,Ve,Ve,Ve,ye,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,Ze,vr,zr,Dr,Ve,Ve,Ve,kt,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Tt,st,$e,xc,Ve,Ve,Ve,vc,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Tc,Ac,Oc,Sc,Ve,Ve,Ve,Nc,an,an,an,an,an,an,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,j_,k_,V_,H_,Ve,Ve,Ve,Ve,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,$_,K_,G_,Y_,W_,z_,D_,J_,Ve,Ve,Ve,Z_];return{parse:le}}});var cs=ee(zt=>{"use strict";var Eu=as().BigNumber;zt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};zt.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};zt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};zt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};zt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};zt.SHIFT32=Math.pow(2,32);zt.SHIFT16=Math.pow(2,16);zt.MAX_SAFE_HIGH=2097151;zt.NEG_ONE=new Eu(-1);zt.TEN=new Eu(10);zt.TWO=new Eu(2);zt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var ko=ee(nr=>{"use strict";var{Buffer:tb}=ai("buffer"),n0=as().BigNumber,i0=cs(),r0=i0.SHIFT32,rb=i0.SHIFT16,nb=2097151;nr.parseHalf=function(e){var r,n,i;return i=e[0]&128?-1:1,r=(e[0]&124)>>2,n=(e[0]&3)<<8|e[1],r?r===31?i*(n?NaN:1/0):i*Math.pow(2,r-25)*(1024+n):i*5960464477539063e-23*n};function ib(t){return t<16?"0"+t.toString(16):t.toString(16)}nr.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=ib(t[n]);return new n0(r,16)};nr.buildMap=t=>{let e=new Map,r=Object.keys(t),n=r.length;for(let i=0;i<n;i++)e.set(r[i],t[r[i]]);return e};nr.buildInt32=(t,e)=>t*rb+e;nr.buildInt64=(t,e,r,n)=>{let i=nr.buildInt32(t,e),s=nr.buildInt32(r,n);return i>nb?new n0(i).times(r0).plus(s):i*r0+s};nr.writeHalf=function(e,r){let n=tb.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 e.writeUInt16BE(s,0),!0};nr.keySorter=function(t,e){var r=t[0].byteLength,n=e[0].byteLength;return r>n?1:n>r?-1:t[0].compare(e[0])};nr.isNegativeZero=t=>t===0&&1/t<0;nr.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var Au=ee((yv,s0)=>{"use strict";var Tu=cs(),sb=Tu.MT,Vo=Tu.SIMPLE,xu=Tu.SYMS,vu=class t{constructor(e){if(typeof e!="number")throw new Error("Invalid Simple type: "+typeof e);if(e<0||e>255||(e|0)!==e)throw new Error("value must be a small positive integer: "+e);this.value=e}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,sb.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case Vo.FALSE:return!1;case Vo.TRUE:return!0;case Vo.NULL:return r?null:xu.NULL;case Vo.UNDEFINED:return r?void 0:xu.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return xu.BREAK;default:return new t(e)}}};s0.exports=vu});var Su=ee((_v,o0)=>{"use strict";var Ou=class t{constructor(e,r,n){if(this.tag=e,this.value=r,this.err=n,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(e){return e._pushTag(this.tag),e.pushAny(this.value)}convert(e){var r,n;if(n=e?.[this.tag],typeof n!="function"&&(n=t["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(t,this.value)}catch(i){return r=i,this.err=r,this}}};o0.exports=Ou});var Ru=ee((gv,c0)=>{"use strict";var{URL:ob,URLSearchParams:ab,format:cb}=ai("url"),a0="http://localhost",Nu=class extends ob{constructor(e="",r=a0){super(e,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}format(){return this.toString()}};c0.exports={URLWithLegacySupport:Nu,URLSearchParams:ab,format:cb,defaultBase:a0}});var f0=ee((mv,l0)=>{"use strict";var{URLWithLegacySupport:u0,format:ub}=Ru();l0.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new u0(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new u0(t,ub(o)).toString()}});var Bu=ee((bv,d0)=>{"use strict";var{URLWithLegacySupport:lb,format:fb,URLSearchParams:db,defaultBase:hb}=Ru(),pb=f0();d0.exports={URL:lb,URLSearchParams:db,format:fb,relative:pb,defaultBase:hb}});var Pu=ee((wv,p0)=>{"use strict";var{Buffer:vi}=ai("buffer"),h0=Pc(),yb=as().BigNumber,_b=t0(),Ct=ko(),qe=cs(),gb=Au(),mb=Su(),{URL:bb}=Bu(),us=class t{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=Ct.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=vi.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>Ct.arrayBufferToBignumber(r),3:r=>qe.NEG_ONE.minus(Ct.arrayBufferToBignumber(r)),4:r=>qe.TEN.pow(r[0]).times(r[1]),5:r=>qe.TWO.pow(r[0]).times(r[1]),32:r=>new bb(r),35:r=>new RegExp(r)},e.tags),this.parser=_b(global,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var e=this._parents.pop();if(e.length>0)throw new Error(`Missing ${e.length} elements`);switch(e.type){case qe.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case qe.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case qe.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case qe.PARENT.MAP:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(e.ref,e.length));break;case qe.PARENT.OBJECT:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(e.ref,e.length));break;case qe.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===qe.PARENT.TAG&&this._dec()}_dec(){let e=this._currentParent;e.length<0||(e.length--,e.length===0&&this._closeParent())}_push(e,r){let n=this._currentParent;switch(n.values++,n.type){case qe.PARENT.ARRAY:case qe.PARENT.BYTE_STRING:case qe.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case qe.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=qe.PARENT.MAP,n.ref=Ct.buildMap(n.ref)));break;case qe.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case qe.PARENT.TAG:this._ref.push(e),r||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(e,r,n){this._parents[this._depth]={type:r,length:n,ref:e,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:qe.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,r){let n=this._knownTags[e];return n?n(r):new mb(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return vi.concat(e)}createByteStringFromHeap(e,r){return e===r?vi.alloc(0):vi.from(this._heap.slice(e,r))}createInt(e){return e}createInt32(e,r){return Ct.buildInt32(e,r)}createInt64(e,r,n,i){return Ct.buildInt64(e,r,n,i)}createFloat(e){return e}createFloatSingle(e,r,n,i){return h0.read([e,r,n,i],0,!1,23,4)}createFloatDouble(e,r,n,i,s,o,a,c){return h0.read([e,r,n,i,s,o,a,c],0,!1,52,8)}createInt32Neg(e,r){return-1-Ct.buildInt32(e,r)}createInt64Neg(e,r,n,i){let s=Ct.buildInt32(e,r),o=Ct.buildInt32(n,i);return s>qe.MAX_SAFE_HIGH?qe.NEG_ONE.minus(new yb(s).times(qe.SHIFT32).plus(o)):-1-(s*qe.SHIFT32+o)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(e,r){return e.join("")}createUtf8StringFromHeap(e,r){return e===r?"":this._buffer.toString("utf8",e,r)}createSimpleUnassigned(e){return new gb(e)}pushInt(e){this._push(this.createInt(e))}pushInt32(e,r){this._push(this.createInt32(e,r))}pushInt64(e,r,n,i){this._push(this.createInt64(e,r,n,i))}pushFloat(e){this._push(this.createFloat(e))}pushFloatSingle(e,r,n,i){this._push(this.createFloatSingle(e,r,n,i))}pushFloatDouble(e,r,n,i,s,o,a,c){this._push(this.createFloatDouble(e,r,n,i,s,o,a,c))}pushInt32Neg(e,r){this._push(this.createInt32Neg(e,r))}pushInt64Neg(e,r,n,i){this._push(this.createInt64Neg(e,r,n,i))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],qe.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,r){let n=Ct.buildInt32(e,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,r,n,i){let s=Ct.buildInt64(e,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,r){let n=Ct.buildInt32(e,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,r,n,i){let s=Ct.buildInt64(e,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:qe.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(e,r){this._push(this.createByteStringFromHeap(e,r))}pushUtf8StringStart(){this._parents[this._depth]={type:qe.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(e,r){this._push(this.createUtf8StringFromHeap(e,r))}pushSimpleUnassigned(e){this._push(this.createSimpleUnassigned(e))}pushTagStart(e){this._parents[this._depth]={type:qe.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,r){this.pushTagStart(Ct.buildInt32(e,r))}pushTagStart8(e,r,n,i){this.pushTagStart(Ct.buildInt64(e,r,n,i))}pushTagUnassigned(e){this._push(this.createTag(e))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(e){if(e===0){this._push(this.createObject({}));return}this._createParent({},qe.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),qe.PARENT.ARRAY,e)}_decode(e){if(e.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(e);let r=this.parser.parse(e.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(r>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(e){return this._decode(e),this._res[0]}decodeAll(e){return this._decode(e),this._res}static decode(e,r){return typeof e=="string"&&(e=vi.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=vi.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};us.decodeFirst=us.decode;p0.exports=us});var g0=ee((Ev,_0)=>{"use strict";var{Buffer:Uu}=ai("buffer"),wb=Pu(),Eb=ko(),Iu=class t extends wb{createTag(e,r){return`${e}(${r})`}createInt(e){return super.createInt(e).toString()}createInt32(e,r){return super.createInt32(e,r).toString()}createInt64(e,r,n,i){return super.createInt64(e,r,n,i).toString()}createInt32Neg(e,r){return super.createInt32Neg(e,r).toString()}createInt64Neg(e,r,n,i){return super.createInt64Neg(e,r,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(e){let r=super.createFloat(e);return Eb.isNegativeZero(e)?"-0_1":`${r}_1`}createFloatSingle(e,r,n,i){return`${super.createFloatSingle(e,r,n,i)}_2`}createFloatDouble(e,r,n,i,s,o,a,c){return`${super.createFloatDouble(e,r,n,i,s,o,a,c)}_3`}createByteString(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(e,r){return`h'${Uu.from(super.createByteStringFromHeap(e,r)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(e){return`simple(${e})`}createArray(e,r){let n=super.createArray(e,r);return r===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(e,r){let n=super.createMap(e),i=Array.from(n.keys()).reduce(y0(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(e,r){let n=super.createObject(e),i=Object.keys(n).reduce(y0(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,r){return`"${Uu.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=Uu.from(e,r||"hex")),new t().decodeFirst(e)}};_0.exports=Iu;function y0(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var x0=ee((xv,E0)=>{"use strict";var{Buffer:Ur}=ai("buffer"),{URL:xb}=Bu(),Fu=as().BigNumber,Cu=ko(),ot=cs(),lr=ot.MT,Ho=ot.NUMBYTES,m0=ot.SHIFT32,b0=ot.SYMS,Ti=ot.TAG,vb=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.TWO,Tb=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.FOUR,Ab=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.EIGHT,Ob=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.TRUE,Sb=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.FALSE,Nb=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.UNDEFINED,w0=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.NULL,Rb=new Fu("0x20000000000000"),Bb=Ur.from("f97e00","hex"),Pb=Ur.from("f9fc00","hex"),Ub=Ur.from("f97c00","hex");function Ib(t){return{}.toString.call(t).slice(8,-1)}var Mu=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[xb,this._pushUrl],[Fu,this._pushBigNumber]];let r=e.genTypes||[],n=r.length;for(let i=0;i<n;i++)this.addSemanticType(r[i][0],r[i][1]);this._reset()}addSemanticType(e,r){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===e){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,o}return this.semanticTypes.push([e,r]),null}push(e){return e&&(this.result[this.offset]=e,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=e.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(e,r,n){return this.result[this.offset]=e,this.resultMethod[this.offset]=r,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(e){return this.pushWrite(e,1,1)}_pushUInt16BE(e){return this.pushWrite(e,2,2)}_pushUInt32BE(e){return this.pushWrite(e,3,4)}_pushDoubleBE(e){return this.pushWrite(e,4,8)}_pushNaN(){return this.push(Bb)}_pushInfinity(e){let r=e<0?Pb:Ub;return this.push(r)}_pushFloat(e){let r=Ur.allocUnsafe(2);if(Cu.writeHalf(r,e)&&Cu.parseHalf(r)===e)return this._pushUInt8(vb)&&this.push(r);let n=Ur.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(Tb)&&this.push(n):this._pushUInt8(Ab)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|Ho.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|Ho.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|Ho.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|Ho.EIGHT)&&this._pushUInt32BE(Math.floor(e/m0))&&this._pushUInt32BE(e%m0):r===lr.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,lr.NEG_INT,e):this._pushInt(e,lr.POS_INT)}_pushNumber(e){switch(!1){case e===e:return this._pushNaN(e);case isFinite(e):return this._pushInfinity(e);case e%1!==0:return this._pushIntNum(e);default:return this._pushFloat(e)}}_pushString(e){let r=Ur.byteLength(e,"utf8");return this._pushInt(r,lr.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?Ob:Sb)}_pushUndefined(e){return this._pushUInt8(Nb)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,lr.ARRAY))return!1;for(let i=0;i<n;i++)if(!e.pushAny(r[i]))return!1;return!0}_pushTag(e){return this._pushInt(e,lr.TAG)}_pushDate(e,r){return e._pushTag(Ti.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,lr.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(Ti.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,lr.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(Ti.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=Ti.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=Ti.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=Ur.from(n,"hex");return this._pushTag(r)&&this._pushBuffer(this,i)}_pushBigNumber(e,r){if(r.isNaN())return e._pushNaN();if(!r.isFinite())return e._pushInfinity(r.isNegative()?-1/0:1/0);if(r.isInteger())return e._pushBigint(r);if(!(e._pushTag(Ti.DECIMAL_FRAC)&&e._pushInt(2,lr.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new Fu(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(Rb)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,lr.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(e){if(!e)return this._pushUInt8(w0);for(var r=this.semanticTypes.length,n=0;n<r;n++)if(e instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(e,this,e);var i=e.encodeCBOR;if(typeof i=="function")return i.call(e,this);var s=Object.keys(e),o=s.length;return this._pushInt(o,lr.MAP)?this._pushRawMap(o,s.map(a=>[a,e[a]])):!1}_pushRawMap(e,r){r=r.map(function(i){return i[0]=t.encode(i[0]),i}).sort(Cu.keySorter);for(var n=0;n<e;n++)if(!this.push(r[n][0])||!this.pushAny(r[n][1]))return!1;return!0}write(e){return this.pushAny(e)}pushAny(e){var r=Ib(e);switch(r){case"Number":return this._pushNumber(e);case"String":return this._pushString(e);case"Boolean":return this._pushBoolean(e);case"Object":return this._pushObject(e);case"Array":return this._pushArray(this,e);case"Uint8Array":return this._pushBuffer(this,Ur.isBuffer(e)?e:Ur.from(e));case"Null":return this._pushUInt8(w0);case"Undefined":return this._pushUndefined(e);case"Map":return this._pushMap(this,e);case"Set":return this._pushSet(this,e);case"URL":return this._pushUrl(this,e);case"BigNumber":return this._pushBigNumber(this,e);case"Date":return this._pushDate(this,e);case"RegExp":return this._pushRegexp(this,e);case"Symbol":switch(e){case b0.NULL:return this._pushObject(null);case b0.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+e.toString())}default:throw new Error("Unknown type: "+typeof e+", "+(e?e.toString():""))}}finalize(){if(this.offset===0)return null;for(var e=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=r[o];var a=Ur.allocUnsafe(s),c=0,f=0;for(o=0;o<i;o++){switch(f=r[o],n[o]){case 0:e[o].copy(a,c);break;case 1:a.writeUInt8(e[o],c,!0);break;case 2:a.writeUInt16BE(e[o],c,!0);break;case 3:a.writeUInt32BE(e[o],c,!0);break;case 4:a.writeDoubleBE(e[o],c,!0);break;case 5:a.write(e[o],c,f,"utf8");break;default:throw new Error("unkown method")}c+=f}var d=a;return this._reset(),d}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(e){let r=new t;if(!r.pushAny(e))throw new Error("Failed to encode input");return r.finalize()}};E0.exports=Mu});var $o=ee(at=>{"use strict";at.Diagnose=g0();at.Decoder=Pu();at.Encoder=x0();at.Simple=Au();at.Tagged=Su();at.decodeAll=at.Decoder.decodeAll;at.decodeFirst=at.Decoder.decodeFirst;at.diagnose=at.Diagnose.diagnose;at.encode=at.Encoder.encode;at.decode=at.Decoder.decode;at.leveldb={decode:at.Decoder.decodeAll,encode:at.Encoder.encode,buffer:!0,name:"cbor"}});var ds=ee(ir=>{"use strict";var Cb=ir&&ir.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ir,"__esModule",{value:!0});ir.hashOfMap=ir.requestIdOf=ir.hashValue=ir.hash=void 0;var v0=xi(),Fb=Cb($o()),Mb=po(),ls=Ht();function _n(t){return(0,ls.uint8ToBuf)(Mb.sha256.create().update(new Uint8Array(t)).digest())}ir.hash=_n;function fs(t){if(t instanceof Fb.default.Tagged)return fs(t.value);if(typeof t=="string")return T0(t);if(typeof t=="number")return _n((0,v0.lebEncode)(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return _n(t);if(Array.isArray(t)){let e=t.map(fs);return _n((0,ls.concat)(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return _n(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return fs(t.toHash());if(typeof t=="object")return qu(t);if(typeof t=="bigint")return _n((0,v0.lebEncode)(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}ir.hashValue=fs;var T0=t=>{let e=new TextEncoder().encode(t);return _n(e)};function qb(t){return qu(t)}ir.requestIdOf=qb;function qu(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=T0(o),f=fs(a);return[c,f]}).sort(([o],[a])=>(0,ls.compare)(o,a)),i=(0,ls.concat)(...n.map(o=>(0,ls.concat)(...o)));return _n(i)}ir.hashOfMap=qu});var Vu=ee(Ir=>{"use strict";var jb=Ir&&Ir.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};Object.defineProperty(Ir,"__esModule",{value:!0});Ir.createIdentityDescriptor=Ir.AnonymousIdentity=Ir.SignIdentity=void 0;var A0=It(),kb=ds(),O0=Ht(),Vb=new TextEncoder().encode(`
|
|
17
|
-
ic-request`),ju=class{getPrincipal(){return this._principal||(this._principal=A0.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=jb(e,["body"]),i=(0,kb.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,O0.concat)(Vb,i))}})}};Ir.SignIdentity=ju;var ku=class{getPrincipal(){return A0.Principal.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};Ir.AnonymousIdentity=ku;function Hb(t){return"getPublicKey"in t?{type:"PublicKeyIdentity",publicKey:(0,O0.toHex)(t.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}Ir.createIdentityDescriptor=Hb});var Ku=ee(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});var $b=9007199254740992;function Qr(t,...e){let r=new Uint8Array(t.byteLength+e.reduce((i,s)=>i+s.byteLength,0));r.set(new Uint8Array(t),0);let n=t.byteLength;for(let i of e)r.set(new Uint8Array(i),n),n+=i.byteLength;return r.buffer}function fr(t,e,r){r=r.replace(/[^0-9a-fA-F]/g,"");let n=2**(e-24);r=r.slice(-n*2).padStart(n*2,"0");let i=[(t<<5)+e].concat(r.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function Ko(t,e){if(e<24)return new Uint8Array([(t<<5)+e]).buffer;{let r=e<=255?24:e<=65535?25:e<=4294967295?26:27;return fr(t,r,e.toString(16))}}function S0(t){let e=[];for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);n<128?e.push(n):n<2048?e.push(192|n>>6,128|n&63):n<55296||n>=57344?e.push(224|n>>12,128|n>>6&63,128|n&63):(r++,n=(n&1023)<<10|t.charCodeAt(r)&1023,e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return Qr(new Uint8Array(Ko(3,t.length)),new Uint8Array(e))}function Kb(t,e){if(t==14277111)return Qr(new Uint8Array([217,217,247]),e);if(t<24)return Qr(new Uint8Array([192+t]),e);{let r=t<=255?24:t<=65535?25:t<=4294967295?26:27,n=2**(r-24),i=t.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+r].concat(i.match(/../g).map(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}Ge.tagged=Kb;function hs(t){return new Uint8Array(t).buffer}Ge.raw=hs;function Hu(t){if(isNaN(t))throw new RangeError("Invalid number.");t=Math.min(Math.max(0,t),23);let e=[0+t];return new Uint8Array(e).buffer}Ge.uSmall=Hu;function N0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),255),t=t.toString(16),fr(0,24,t)}Ge.u8=N0;function R0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),65535),t=t.toString(16),fr(0,25,t)}Ge.u16=R0;function B0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),4294967295),t=t.toString(16),fr(0,26,t)}Ge.u32=B0;function $u(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return fr(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),$b),t=t.toString(16),fr(0,27,t)}Ge.u64=$u;function P0(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return Hu(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}Ge.iSmall=P0;function U0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),255),t=t.toString(16),fr(1,24,t)}Ge.i8=U0;function I0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),65535),t=t.toString(16),fr(1,25,t)}Ge.i16=I0;function C0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),4294967295),t=t.toString(16),fr(1,26,t)}Ge.i32=C0;function F0(t,e){if(typeof t=="string"&&e==16){if(t.startsWith("-")?t=t.slice(1):t="0",t.match(/[^0-9a-fA-F]/)||t.length>16)throw new RangeError("Invalid number.");let r=!1,n=t.split("").reduceRight((i,s)=>{if(r)return s+i;let o=parseInt(s,16)-1;return o>=0?(r=!0,o.toString(16)+i):"f"+i},"");return r?fr(1,27,n):$u(0)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),9007199254740992),t=t.toString(16),fr(1,27,t)}Ge.i64=F0;function Gb(t){return t>=0?t<24?Hu(t):t<=255?N0(t):t<=65535?R0(t):t<=4294967295?B0(t):$u(t):t>=-24?P0(t):t>=-255?U0(t):t>=-65535?I0(t):t>=-4294967295?C0(t):F0(t)}Ge.number=Gb;function Yb(t){return Qr(Ko(2,t.byteLength),t)}Ge.bytes=Yb;function Wb(t){return S0(t)}Ge.string=Wb;function zb(t){return Qr(Ko(4,t.length),...t)}Ge.array=zb;function Db(t,e=!1){t instanceof Map||(t=new Map(Object.entries(t)));let r=Array.from(t.entries());return e&&(r=r.sort(([n],[i])=>n.localeCompare(i))),Qr(Ko(5,t.size),...r.map(([n,i])=>Qr(S0(n),i)))}Ge.map=Db;function Jb(t){let e=new Float32Array([t]);return Qr(new Uint8Array([250]),new Uint8Array(e.buffer))}Ge.singleFloat=Jb;function Zb(t){let e=new Float64Array([t]);return Qr(new Uint8Array([251]),new Uint8Array(e.buffer))}Ge.doubleFloat=Zb;function Xb(t){return t?M0():q0()}Ge.bool=Xb;function M0(){return hs(new Uint8Array([245]))}Ge.true_=M0;function q0(){return hs(new Uint8Array([244]))}Ge.false_=q0;function Qb(){return hs(new Uint8Array([246]))}Ge.null_=Qb;function Lb(){return hs(new Uint8Array([247]))}Ge.undefined_=Lb});var j0=ee(gn=>{"use strict";var e1=gn&&gn.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(gn,"__esModule",{value:!0});var dr=e1(Ku()),t1=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],Go=class{constructor(e,r=!1){this._serializer=e,this._stable=r,this.name="jsonDefault",this.priority=-100}match(e){return["undefined","boolean","number","string","object"].indexOf(typeof e)!=-1}encode(e){switch(typeof e){case"undefined":return dr.undefined_();case"boolean":return dr.bool(e);case"number":return Math.floor(e)===e?dr.number(e):dr.doubleFloat(e);case"string":return dr.string(e);case"object":if(e===null)return dr.null_();if(Array.isArray(e))return dr.array(e.map(r=>this._serializer.serializeValue(r)));if(t1.find(r=>e instanceof r))return dr.bytes(e.buffer);if(Object.getOwnPropertyNames(e).indexOf("toJSON")!==-1)return this.encode(e.toJSON());if(e instanceof Map){let r=new Map;for(let[n,i]of e.entries())r.set(n,this._serializer.serializeValue(i));return dr.map(r,this._stable)}else{let r=new Map;for(let[n,i]of Object.entries(e))r.set(n,this._serializer.serializeValue(i));return dr.map(r,this._stable)}default:throw new Error("Invalid value.")}}};gn.JsonDefaultCborEncoder=Go;var Yo=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};gn.ToCborEncoder=Yo;var Wo=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new Go(r,e)),r.addEncoder(new Yo),r}removeEncoder(e){for(let r of this._encoders.values())r.name==e&&this._encoders.delete(r)}addEncoder(e){this._encoders.add(e)}getEncoderFor(e){let r=null;for(let n of this._encoders)(!r||n.priority>r.priority)&&n.match(e)&&(r=n);if(r===null)throw new Error("Could not find an encoder for value.");return r}serializeValue(e){return this.getEncoderFor(e).encode(e)}serialize(e){return this.serializeValue(e)}};gn.CborSerializer=Wo;var Gu=class extends Wo{serialize(e){return dr.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};gn.SelfDescribeCborSerializer=Gu});var ps=ee(Hn=>{"use strict";function r1(t){for(var e in t)Hn.hasOwnProperty(e)||(Hn[e]=t[e])}var n1=Hn&&Hn.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(Hn,"__esModule",{value:!0});r1(j0());var i1=n1(Ku());Hn.value=i1});var ys=ee(mt=>{"use strict";var s1=mt&&mt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),o1=mt&&mt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a1=mt&&mt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&s1(e,t,r);return o1(e,t),e},c1=mt&&mt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(mt,"__esModule",{value:!0});mt.decode=mt.encode=mt.CborTag=void 0;var u1=c1($o()),Ai=a1(ps()),l1=ps(),zo=Ht(),Yu=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return Ai.value.bytes(e.toUint8Array())}},Wu=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return Ai.value.bytes(new Uint8Array(e))}},zu=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?Ai.value.tagged(2,Ai.value.bytes((0,zo.fromHex)(e.toString(16)))):Ai.value.tagged(3,Ai.value.bytes((0,zo.fromHex)((BigInt("-1")*e).toString(16))))}},Do=l1.SelfDescribeCborSerializer.withDefaultEncoders(!0);Do.addEncoder(new Yu);Do.addEncoder(new Wu);Do.addEncoder(new zu);var V0;(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(V0=mt.CborTag||(mt.CborTag={}));function f1(t){return Do.serialize(t)}mt.encode=f1;function k0(t){let e=t.byteLength,r=BigInt(0);for(let n=0;n<e;n++)r=r*BigInt(256)+BigInt(t[n]);return r}var Du=class extends u1.default.Decoder{createByteString(e){return(0,zo.concat)(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}};function d1(t){let e=new Uint8Array(t),r=new Du({size:e.byteLength,tags:{2:n=>k0(n),3:n=>-k0(n),[V0.Semantic]:n=>n}});try{return r.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,zo.toHex)(e)}`)}}mt.decode=d1});var Ju=ee(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.randomNumber=void 0;var h1=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let t=new Uint32Array(1);return window.crypto.getRandomValues(t),t[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let t=new Uint32Array(1);return crypto.getRandomValues(t),t[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};Jo.randomNumber=h1});var _s=ee($n=>{"use strict";Object.defineProperty($n,"__esModule",{value:!0});$n.makeNonce=$n.SubmitRequestType=void 0;var Zo=Ju(),p1;(function(t){t.Call="call"})(p1=$n.SubmitRequestType||($n.SubmitRequestType={}));function y1(){let t=new ArrayBuffer(16),e=new DataView(t),r=(0,Zo.randomNumber)(),n=(0,Zo.randomNumber)(),i=(0,Zo.randomNumber)(),s=(0,Zo.randomNumber)();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}$n.makeNonce=y1});var Qo=ee(St=>{"use strict";var _1=St&&St.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),g1=St&&St.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),m1=St&&St.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&_1(e,t,r);return g1(e,t),e};Object.defineProperty(St,"__esModule",{value:!0});St.httpHeadersTransform=St.makeExpiryTransform=St.makeNonceTransform=St.Expiry=void 0;var b1=xi(),w1=m1(ps()),E1=_s(),H0=BigInt(1e6),x1=60*1e3,Xo=class{constructor(e){if(e<90*1e3){let a=BigInt(Date.now()+e)*H0/BigInt(1e9);this._value=a*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+e-x1))*H0/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return w1.value.u64(this._value.toString(16),16)}toHash(){return(0,b1.lebEncode)(this._value)}};St.Expiry=Xo;function v1(t=E1.makeNonce){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}St.makeNonceTransform=v1;function T1(t){return async e=>{e.body.ingress_expiry=new Xo(t)}}St.makeExpiryTransform=T1;function A1(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}St.httpHeadersTransform=A1});var ea=ee(Cr=>{"use strict";Object.defineProperty(Cr,"__esModule",{value:!0});Cr.AgentReadStateError=Cr.AgentQueryError=Cr.AgentCallError=Cr.AgentHTTPResponseError=void 0;var Lo=yi(),Zu=class extends Lo.AgentError{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Cr.AgentHTTPResponseError=Zu;var Xu=class extends Lo.AgentError{constructor(e,r,n,i,s,o){super(e),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentCallError",Object.setPrototypeOf(this,new.target.prototype)}};Cr.AgentCallError=Xu;var Qu=class extends Lo.AgentError{constructor(e,r,n,i,s,o){super(e),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentQueryError",Object.setPrototypeOf(this,new.target.prototype)}};Cr.AgentQueryError=Qu;var Lu=class extends Lo.AgentError{constructor(e,r,n,i,s,o){super(e),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentReadStateError",Object.setPrototypeOf(this,new.target.prototype)}};Cr.AgentReadStateError=Lu});var Dt=ee(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.notImplemented=Ie.bitMask=void 0;Ie.isBytes=ra;Ie.abytes=na;Ie.abool=S1;Ie.bytesToHex=nl;Ie.numberToHexUnpadded=G0;Ie.hexToNumber=il;Ie.hexToBytes=ia;Ie.bytesToNumberBE=R1;Ie.bytesToNumberLE=B1;Ie.numberToBytesBE=Y0;Ie.numberToBytesLE=P1;Ie.numberToVarBytesBE=U1;Ie.ensureBytes=I1;Ie.concatBytes=W0;Ie.equalBytes=C1;Ie.utf8ToBytes=F1;Ie.inRange=z0;Ie.aInRange=M1;Ie.bitLen=q1;Ie.bitGet=j1;Ie.bitSet=k1;Ie.createHmacDrbg=H1;Ie.validateObject=K1;Ie.memoized=Y1;var rl=BigInt(0),ta=BigInt(1),O1=BigInt(2);function ra(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function na(t){if(!ra(t))throw new Error("Uint8Array expected")}function S1(t,e){if(typeof e!="boolean")throw new Error(`${t} must be valid boolean, got "${e}".`)}var N1=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function nl(t){na(t);let e="";for(let r=0;r<t.length;r++)e+=N1[t[r]];return e}function G0(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function il(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var Lr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function $0(t){if(t>=Lr._0&&t<=Lr._9)return t-Lr._0;if(t>=Lr._A&&t<=Lr._F)return t-(Lr._A-10);if(t>=Lr._a&&t<=Lr._f)return t-(Lr._a-10)}function ia(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=$0(t.charCodeAt(s)),a=$0(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function R1(t){return il(nl(t))}function B1(t){return na(t),il(nl(Uint8Array.from(t).reverse()))}function Y0(t,e){return ia(t.toString(16).padStart(e*2,"0"))}function P1(t,e){return Y0(t,e).reverse()}function U1(t){return ia(G0(t))}function I1(t,e,r){let n;if(typeof e=="string")try{n=ia(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(ra(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function W0(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];na(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}function C1(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function F1(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}var el=t=>typeof t=="bigint"&&rl<=t;function z0(t,e,r){return el(t)&&el(e)&&el(r)&&e<=t&&t<r}function M1(t,e,r,n){if(!z0(e,r,n))throw new Error(`expected valid ${t}: ${r} <= n < ${n}, got ${typeof e} ${e}`)}function q1(t){let e;for(e=0;t>rl;t>>=ta,e+=1);return e}function j1(t,e){return t>>BigInt(e)&ta}function k1(t,e,r){return t|(r?ta:rl)<<BigInt(e)}var V1=t=>(O1<<BigInt(t-1))-ta;Ie.bitMask=V1;var tl=t=>new Uint8Array(t),K0=t=>Uint8Array.from(t);function H1(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=tl(t),i=tl(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...h)=>r(i,n,...h),c=(h=tl())=>{i=a(K0([0]),h),n=a(),h.length!==0&&(i=a(K0([1]),h),n=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0,g=[];for(;h<e;){n=a();let b=n.slice();g.push(b),h+=n.length}return W0(...g)};return(h,g)=>{o(),c(h);let b;for(;!(b=g(f()));)c();return o(),b}}var $1={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||ra(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function K1(t,e,r={}){let n=(i,s,o)=>{let a=$1[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return t}var G1=()=>{throw new Error("not implemented")};Ie.notImplemented=G1;function Y1(t){let e=new WeakMap;return(r,...n)=>{let i=e.get(r);if(i!==void 0)return i;let s=t(r,...n);return e.set(r,s),s}}});var Fr=ee(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.isNegativeLE=void 0;ze.mod=Jt;ze.pow=Z0;ze.pow2=J1;ze.invert=sa;ze.tonelliShanks=X0;ze.FpSqrt=Q0;ze.validateField=Q1;ze.FpPow=L0;ze.FpInvertBatch=eh;ze.FpDiv=L1;ze.FpLegendre=th;ze.FpIsSquare=ew;ze.nLength=ol;ze.Field=tw;ze.FpSqrtOdd=rw;ze.FpSqrtEven=nw;ze.hashToPrivateScalar=iw;ze.getFieldBytesLength=al;ze.getMinHashLength=rh;ze.mapHashToField=sw;var Zt=Dt(),ct=BigInt(0),He=BigInt(1),mn=BigInt(2),W1=BigInt(3),sl=BigInt(4),D0=BigInt(5),J0=BigInt(8),z1=BigInt(9),D1=BigInt(16);function Jt(t,e){let r=t%e;return r>=ct?r:e+r}function Z0(t,e,r){if(r<=ct||e<ct)throw new Error("Expected power/modulo > 0");if(r===He)return ct;let n=He;for(;e>ct;)e&He&&(n=n*t%r),t=t*t%r,e>>=He;return n}function J1(t,e,r){let n=t;for(;e-- >ct;)n*=n,n%=r;return n}function sa(t,e){if(t===ct||e<=ct)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Jt(t,e),n=e,i=ct,s=He,o=He,a=ct;for(;r!==ct;){let f=n/r,d=n%r,h=i-o*f,g=s-a*f;n=r,r=d,i=o,s=a,o=h,a=g}if(n!==He)throw new Error("invert: does not exist");return Jt(i,e)}function X0(t){let e=(t-He)/mn,r,n,i;for(r=t-He,n=0;r%mn===ct;r/=mn,n++);for(i=mn;i<t&&Z0(i,e,t)!==t-He;i++);if(n===1){let o=(t+He)/sl;return function(c,f){let d=c.pow(f,o);if(!c.eql(c.sqr(d),f))throw new Error("Cannot find square root");return d}}let s=(r+He)/mn;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,d=a.pow(a.mul(a.ONE,i),r),h=a.pow(c,s),g=a.pow(c,r);for(;!a.eql(g,a.ONE);){if(a.eql(g,a.ZERO))return a.ZERO;let b=1;for(let N=a.sqr(g);b<f&&!a.eql(N,a.ONE);b++)N=a.sqr(N);let l=a.pow(d,He<<BigInt(f-b-1));d=a.sqr(l),h=a.mul(h,l),g=a.mul(g,d),f=b}return h}}function Q0(t){if(t%sl===W1){let e=(t+He)/sl;return function(n,i){let s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(t%J0===D0){let e=(t-D0)/J0;return function(n,i){let s=n.mul(i,mn),o=n.pow(s,e),a=n.mul(i,o),c=n.mul(n.mul(a,mn),o),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),i))throw new Error("Cannot find square root");return f}}return t%D1,X0(t)}var Z1=(t,e)=>(Jt(t,e)&He)===He;ze.isNegativeLE=Z1;var X1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Q1(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=X1.reduce((n,i)=>(n[i]="function",n),e);return(0,Zt.validateObject)(t,r)}function L0(t,e,r){if(r<ct)throw new Error("Expected power > 0");if(r===ct)return t.ONE;if(r===He)return e;let n=t.ONE,i=e;for(;r>ct;)r&He&&(n=t.mul(n,i)),i=t.sqr(i),r>>=He;return n}function eh(t,e){let r=new Array(e.length),n=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),i=t.inv(n);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),i),r}function L1(t,e,r){return t.mul(e,typeof r=="bigint"?sa(r,t.ORDER):t.inv(r))}function th(t){let e=(t-He)/mn;return(r,n)=>r.pow(n,e)}function ew(t){let e=th(t.ORDER);return r=>{let n=e(t,r);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}}function ol(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function tw(t,e,r=!1,n={}){if(t<=ct)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=ol(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=Q0(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:(0,Zt.bitMask)(i),ZERO:ct,ONE:He,create:c=>Jt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ct<=c&&c<t},is0:c=>c===ct,isOdd:c=>(c&He)===He,neg:c=>Jt(-c,t),eql:(c,f)=>c===f,sqr:c=>Jt(c*c,t),add:(c,f)=>Jt(c+f,t),sub:(c,f)=>Jt(c-f,t),mul:(c,f)=>Jt(c*f,t),pow:(c,f)=>L0(a,c,f),div:(c,f)=>Jt(c*sa(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>sa(c,t),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>eh(a,c),cmov:(c,f,d)=>d?f:c,toBytes:c=>r?(0,Zt.numberToBytesLE)(c,s):(0,Zt.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,Zt.bytesToNumberLE)(c):(0,Zt.bytesToNumberBE)(c)}});return Object.freeze(a)}function rw(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?r:t.neg(r)}function nw(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function iw(t,e,r=!1){t=(0,Zt.ensureBytes)("privateHash",t);let n=t.length,i=ol(e).nByteLength+8;if(i<24||n<i||n>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${n}`);let s=r?(0,Zt.bytesToNumberLE)(t):(0,Zt.bytesToNumberBE)(t);return Jt(s,e-He)+He}function al(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function rh(t){let e=al(t);return e+Math.ceil(e/2)}function sw(t,e,r=!1){let n=t.length,i=al(e),s=rh(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?(0,Zt.bytesToNumberBE)(t):(0,Zt.bytesToNumberLE)(t),a=Jt(o,e-He)+He;return r?(0,Zt.numberToBytesLE)(a,i):(0,Zt.numberToBytesBE)(a,i)}});var oa=ee(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});Kn.expand_message_xmd=nh;Kn.expand_message_xof=ih;Kn.hash_to_field=cl;Kn.isogenyMap=uw;Kn.createHasher=lw;var ow=Fr(),Nt=Dt(),aw=Nt.bytesToNumberBE;function bn(t,e){if(gs(t),gs(e),t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);let r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=t&255,t>>>=8;return new Uint8Array(r)}function cw(t,e){let r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function gs(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function nh(t,e,r,n){(0,Nt.abytes)(t),(0,Nt.abytes)(e),gs(r),e.length>255&&(e=n((0,Nt.concatBytes)((0,Nt.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(r/i);if(r>65535||o>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=(0,Nt.concatBytes)(e,bn(e.length,1)),c=bn(0,s),f=bn(r,2),d=new Array(o),h=n((0,Nt.concatBytes)(c,t,f,bn(0,1),a));d[0]=n((0,Nt.concatBytes)(h,bn(1,1),a));for(let b=1;b<=o;b++){let l=[cw(h,d[b-1]),bn(b+1,1),a];d[b]=n((0,Nt.concatBytes)(...l))}return(0,Nt.concatBytes)(...d).slice(0,r)}function ih(t,e,r,n,i){if((0,Nt.abytes)(t),(0,Nt.abytes)(e),gs(r),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update((0,Nt.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(t).update(bn(r,2)).update(e).update(bn(e.length,1)).digest()}function cl(t,e,r){(0,Nt.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:a,DST:c}=r;(0,Nt.abytes)(t),gs(e);let f=typeof c=="string"?(0,Nt.utf8ToBytes)(c):c,d=n.toString(2).length,h=Math.ceil((d+i)/8),g=e*s*h,b;if(a==="xmd")b=nh(t,f,g,o);else if(a==="xof")b=ih(t,f,g,i,o);else if(a==="_internal_pass")b=t;else throw new Error('expand must be "xmd" or "xof"');let l=new Array(e);for(let N=0;N<e;N++){let O=new Array(s);for(let I=0;I<s;I++){let M=h*(I+N*s),A=b.subarray(M,M+h);O[I]=(0,ow.mod)(aw(A),n)}l[N]=O}return l}function uw(t,e){let r=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,a,c]=r.map(f=>f.reduce((d,h)=>t.add(t.mul(d,n),h)));return n=t.div(s,o),i=t.mul(i,t.div(a,c)),{x:n,y:i}}}function lw(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=cl(n,2,{...r,DST:r.DST,...i}),o=t.fromAffine(e(s[0])),a=t.fromAffine(e(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=cl(n,1,{...r,DST:r.encodeDST,...i}),o=t.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(let s of n)if(typeof s!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${s} in array`);let i=t.fromAffine(e(n)).clearCofactor();return i.assertValidity(),i}}}});var fl=ee(ms=>{"use strict";Object.defineProperty(ms,"__esModule",{value:!0});ms.wNAF=dw;ms.pippenger=hw;ms.validateBasic=pw;var sh=Fr(),ah=Dt(),fw=BigInt(0),ul=BigInt(1),ll=new WeakMap,oh=new WeakMap;function dw(t,e){let r=(s,o)=>{let a=o.negate();return s?a:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error(`Wrong window size=${s}, should be [1..${e}]`)},i=s=>{n(s);let o=Math.ceil(e/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:r,unsafeLadder(s,o){let a=t.ZERO,c=s;for(;o>fw;)o&ul&&(a=a.add(c)),c=c.double(),o>>=ul;return a},precomputeWindow(s,o){let{windows:a,windowSize:c}=i(o),f=[],d=s,h=d;for(let g=0;g<a;g++){h=d,f.push(h);for(let b=1;b<c;b++)h=h.add(d),f.push(h);d=h.double()}return f},wNAF(s,o,a){let{windows:c,windowSize:f}=i(s),d=t.ZERO,h=t.BASE,g=BigInt(2**s-1),b=2**s,l=BigInt(s);for(let N=0;N<c;N++){let O=N*f,I=Number(a&g);a>>=l,I>f&&(I-=b,a+=ul);let M=O,A=O+Math.abs(I)-1,K=N%2!==0,E=I<0;I===0?h=h.add(r(K,o[M])):d=d.add(r(E,o[A]))}return{p:d,f:h}},wNAFCached(s,o,a){let c=oh.get(s)||1,f=ll.get(s);return f||(f=this.precomputeWindow(s,c),c!==1&&ll.set(s,a(f))),this.wNAF(c,f,o)},setWindowSize(s,o){n(o),oh.set(s,o),ll.delete(s)}}}function hw(t,e,r,n){if(!Array.isArray(r)||!Array.isArray(n)||n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((d,h)=>{if(!e.isValid(d))throw new Error(`wrong scalar at index ${h}`)}),r.forEach((d,h)=>{if(!(d instanceof t))throw new Error(`wrong point at index ${h}`)});let i=(0,ah.bitLen)(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(t.ZERO),c=Math.floor((e.BITS-1)/s)*s,f=t.ZERO;for(let d=c;d>=0;d-=s){a.fill(t.ZERO);for(let g=0;g<n.length;g++){let b=n[g],l=Number(b>>BigInt(d)&BigInt(o));a[l]=a[l].add(r[g])}let h=t.ZERO;for(let g=a.length-1,b=t.ZERO;g>0;g--)b=b.add(a[g]),h=h.add(b);if(f=f.add(h),d!==0)for(let g=0;g<s;g++)f=f.double()}return f}function pw(t){return(0,sh.validateField)(t.Fp),(0,ah.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,sh.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}});var dl=ee(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.DER=void 0;wt.weierstrassPoints=lh;wt.weierstrass=bw;wt.SWUFpSqrtRatio=fh;wt.mapToCurveSimpleSWU=ww;var aa=fl(),Gn=Fr(),Oe=Dt(),bt=Dt();function ch(t){t.lowS!==void 0&&(0,bt.abool)("lowS",t.lowS),t.prehash!==void 0&&(0,bt.abool)("prehash",t.prehash)}function yw(t){let e=(0,aa.validateBasic)(t);Oe.validateObject(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:_w,hexToBytes:gw}=Oe;wt.DER={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(t,e)=>{let{Err:r}=wt.DER;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,i=Oe.numberToHexUnpadded(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?Oe.numberToHexUnpadded(i.length/2|128):"";return`${Oe.numberToHexUnpadded(t)}${s}${i}${e}`},decode(t,e){let{Err:r}=wt.DER,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let i=e[n++],s=!!(i&128),o=0;if(!s)o=i;else{let c=i&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+c);if(f.length!==c)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of f)o=o<<8|d;if(n+=c,o<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+o)}}},_int:{encode(t){let{Err:e}=wt.DER;if(t<hr)throw new e("integer: negative integers are not allowed");let r=Oe.numberToHexUnpadded(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected assertion");return r},decode(t){let{Err:e}=wt.DER;if(t[0]&128)throw new e("Invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return _w(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=wt.DER,i=typeof t=="string"?gw(t):t;Oe.abytes(i);let{v:s,l:o}=n.decode(48,i);if(o.length)throw new e("Invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,s),{v:f,l:d}=n.decode(2,c);if(d.length)throw new e("Invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(f)}},hexFromSig(t){let{_tlv:e,_int:r}=wt.DER,n=`${e.encode(2,r.encode(t.r))}${e.encode(2,r.encode(t.s))}`;return e.encode(48,n)}};var hr=BigInt(0),je=BigInt(1),wn=BigInt(2),ca=BigInt(3),uh=BigInt(4);function lh(t){let e=yw(t),{Fp:r}=e,n=Gn.Field(e.n,e.nBitLength),i=e.toBytes||((N,O,I)=>{let M=O.toAffine();return Oe.concatBytes(Uint8Array.from([4]),r.toBytes(M.x),r.toBytes(M.y))}),s=e.fromBytes||(N=>{let O=N.subarray(1),I=r.fromBytes(O.subarray(0,r.BYTES)),M=r.fromBytes(O.subarray(r.BYTES,2*r.BYTES));return{x:I,y:M}});function o(N){let{a:O,b:I}=e,M=r.sqr(N),A=r.mul(M,N);return r.add(r.add(A,r.mul(N,O)),I)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(N){return Oe.inRange(N,je,e.n)}function c(N){let{allowedPrivateKeyLengths:O,nByteLength:I,wrapPrivateKey:M,n:A}=e;if(O&&typeof N!="bigint"){if(Oe.isBytes(N)&&(N=Oe.bytesToHex(N)),typeof N!="string"||!O.includes(N.length))throw new Error("Invalid key");N=N.padStart(I*2,"0")}let K;try{K=typeof N=="bigint"?N:Oe.bytesToNumberBE((0,bt.ensureBytes)("private key",N,I))}catch{throw new Error(`private key must be ${I} bytes, hex or bigint, not ${typeof N}`)}return M&&(K=Gn.mod(K,A)),Oe.aInRange("private key",K,je,A),K}function f(N){if(!(N instanceof g))throw new Error("ProjectivePoint expected")}let d=(0,bt.memoized)((N,O)=>{let{px:I,py:M,pz:A}=N;if(r.eql(A,r.ONE))return{x:I,y:M};let K=N.is0();O==null&&(O=K?r.ONE:r.inv(A));let E=r.mul(I,O),k=r.mul(M,O),G=r.mul(A,O);if(K)return{x:r.ZERO,y:r.ZERO};if(!r.eql(G,r.ONE))throw new Error("invZ was invalid");return{x:E,y:k}}),h=(0,bt.memoized)(N=>{if(N.is0()){if(e.allowInfinityPoint&&!r.is0(N.py))return;throw new Error("bad point: ZERO")}let{x:O,y:I}=N.toAffine();if(!r.isValid(O)||!r.isValid(I))throw new Error("bad point: x or y not FE");let M=r.sqr(I),A=o(O);if(!r.eql(M,A))throw new Error("bad point: equation left != right");if(!N.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class g{constructor(O,I,M){if(this.px=O,this.py=I,this.pz=M,O==null||!r.isValid(O))throw new Error("x required");if(I==null||!r.isValid(I))throw new Error("y required");if(M==null||!r.isValid(M))throw new Error("z required");Object.freeze(this)}static fromAffine(O){let{x:I,y:M}=O||{};if(!O||!r.isValid(I)||!r.isValid(M))throw new Error("invalid affine point");if(O instanceof g)throw new Error("projective point not allowed");let A=K=>r.eql(K,r.ZERO);return A(I)&&A(M)?g.ZERO:new g(I,M,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(O){let I=r.invertBatch(O.map(M=>M.pz));return O.map((M,A)=>M.toAffine(I[A])).map(g.fromAffine)}static fromHex(O){let I=g.fromAffine(s((0,bt.ensureBytes)("pointHex",O)));return I.assertValidity(),I}static fromPrivateKey(O){return g.BASE.multiply(c(O))}static msm(O,I){return(0,aa.pippenger)(g,n,O,I)}_setWindowSize(O){l.setWindowSize(this,O)}assertValidity(){h(this)}hasEvenY(){let{y:O}=this.toAffine();if(r.isOdd)return!r.isOdd(O);throw new Error("Field doesn't support isOdd")}equals(O){f(O);let{px:I,py:M,pz:A}=this,{px:K,py:E,pz:k}=O,G=r.eql(r.mul(I,k),r.mul(K,A)),z=r.eql(r.mul(M,k),r.mul(E,A));return G&&z}negate(){return new g(this.px,r.neg(this.py),this.pz)}double(){let{a:O,b:I}=e,M=r.mul(I,ca),{px:A,py:K,pz:E}=this,k=r.ZERO,G=r.ZERO,z=r.ZERO,q=r.mul(A,A),oe=r.mul(K,K),Q=r.mul(E,E),ie=r.mul(A,K);return ie=r.add(ie,ie),z=r.mul(A,E),z=r.add(z,z),k=r.mul(O,z),G=r.mul(M,Q),G=r.add(k,G),k=r.sub(oe,G),G=r.add(oe,G),G=r.mul(k,G),k=r.mul(ie,k),z=r.mul(M,z),Q=r.mul(O,Q),ie=r.sub(q,Q),ie=r.mul(O,ie),ie=r.add(ie,z),z=r.add(q,q),q=r.add(z,q),q=r.add(q,Q),q=r.mul(q,ie),G=r.add(G,q),Q=r.mul(K,E),Q=r.add(Q,Q),q=r.mul(Q,ie),k=r.sub(k,q),z=r.mul(Q,oe),z=r.add(z,z),z=r.add(z,z),new g(k,G,z)}add(O){f(O);let{px:I,py:M,pz:A}=this,{px:K,py:E,pz:k}=O,G=r.ZERO,z=r.ZERO,q=r.ZERO,oe=e.a,Q=r.mul(e.b,ca),ie=r.mul(I,K),w=r.mul(M,E),m=r.mul(A,k),R=r.add(I,M),S=r.add(K,E);R=r.mul(R,S),S=r.add(ie,w),R=r.sub(R,S),S=r.add(I,A);let B=r.add(K,k);return S=r.mul(S,B),B=r.add(ie,m),S=r.sub(S,B),B=r.add(M,A),G=r.add(E,k),B=r.mul(B,G),G=r.add(w,m),B=r.sub(B,G),q=r.mul(oe,S),G=r.mul(Q,m),q=r.add(G,q),G=r.sub(w,q),q=r.add(w,q),z=r.mul(G,q),w=r.add(ie,ie),w=r.add(w,ie),m=r.mul(oe,m),S=r.mul(Q,S),w=r.add(w,m),m=r.sub(ie,m),m=r.mul(oe,m),S=r.add(S,m),ie=r.mul(w,S),z=r.add(z,ie),ie=r.mul(B,S),G=r.mul(R,G),G=r.sub(G,ie),ie=r.mul(R,w),q=r.mul(B,q),q=r.add(q,ie),new g(G,z,q)}subtract(O){return this.add(O.negate())}is0(){return this.equals(g.ZERO)}wNAF(O){return l.wNAFCached(this,O,g.normalizeZ)}multiplyUnsafe(O){Oe.aInRange("scalar",O,hr,e.n);let I=g.ZERO;if(O===hr)return I;if(O===je)return this;let{endo:M}=e;if(!M)return l.unsafeLadder(this,O);let{k1neg:A,k1:K,k2neg:E,k2:k}=M.splitScalar(O),G=I,z=I,q=this;for(;K>hr||k>hr;)K&je&&(G=G.add(q)),k&je&&(z=z.add(q)),q=q.double(),K>>=je,k>>=je;return A&&(G=G.negate()),E&&(z=z.negate()),z=new g(r.mul(z.px,M.beta),z.py,z.pz),G.add(z)}multiply(O){let{endo:I,n:M}=e;Oe.aInRange("scalar",O,je,M);let A,K;if(I){let{k1neg:E,k1:k,k2neg:G,k2:z}=I.splitScalar(O),{p:q,f:oe}=this.wNAF(k),{p:Q,f:ie}=this.wNAF(z);q=l.constTimeNegate(E,q),Q=l.constTimeNegate(G,Q),Q=new g(r.mul(Q.px,I.beta),Q.py,Q.pz),A=q.add(Q),K=oe.add(ie)}else{let{p:E,f:k}=this.wNAF(O);A=E,K=k}return g.normalizeZ([A,K])[0]}multiplyAndAddUnsafe(O,I,M){let A=g.BASE,K=(k,G)=>G===hr||G===je||!k.equals(A)?k.multiplyUnsafe(G):k.multiply(G),E=K(this,I).add(K(O,M));return E.is0()?void 0:E}toAffine(O){return d(this,O)}isTorsionFree(){let{h:O,isTorsionFree:I}=e;if(O===je)return!0;if(I)return I(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:O,clearCofactor:I}=e;return O===je?this:I?I(g,this):this.multiplyUnsafe(e.h)}toRawBytes(O=!0){return(0,bt.abool)("isCompressed",O),this.assertValidity(),i(g,this,O)}toHex(O=!0){return(0,bt.abool)("isCompressed",O),Oe.bytesToHex(this.toRawBytes(O))}}g.BASE=new g(e.Gx,e.Gy,r.ONE),g.ZERO=new g(r.ZERO,r.ONE,r.ZERO);let b=e.nBitLength,l=(0,aa.wNAF)(g,e.endo?Math.ceil(b/2):b);return{CURVE:e,ProjectivePoint:g,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function mw(t){let e=(0,aa.validateBasic)(t);return Oe.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function bw(t){let e=mw(t),{Fp:r,n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function o(m){return Gn.mod(m,n)}function a(m){return Gn.invert(m,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:d,isWithinCurveOrder:h}=lh({...e,toBytes(m,R,S){let B=R.toAffine(),V=r.toBytes(B.x),J=Oe.concatBytes;return(0,bt.abool)("isCompressed",S),S?J(Uint8Array.from([R.hasEvenY()?2:3]),V):J(Uint8Array.from([4]),V,r.toBytes(B.y))},fromBytes(m){let R=m.length,S=m[0],B=m.subarray(1);if(R===i&&(S===2||S===3)){let V=Oe.bytesToNumberBE(B);if(!Oe.inRange(V,je,r.ORDER))throw new Error("Point is not on curve");let J=d(V),ae;try{ae=r.sqrt(J)}catch(F){let p=F instanceof Error?": "+F.message:"";throw new Error("Point is not on curve"+p)}let ce=(ae&je)===je;return(S&1)===1!==ce&&(ae=r.neg(ae)),{x:V,y:ae}}else if(R===s&&S===4){let V=r.fromBytes(B.subarray(0,r.BYTES)),J=r.fromBytes(B.subarray(r.BYTES,2*r.BYTES));return{x:V,y:J}}else throw new Error(`Point of length ${R} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),g=m=>Oe.bytesToHex(Oe.numberToBytesBE(m,e.nByteLength));function b(m){let R=n>>je;return m>R}function l(m){return b(m)?o(-m):m}let N=(m,R,S)=>Oe.bytesToNumberBE(m.slice(R,S));class O{constructor(R,S,B){this.r=R,this.s=S,this.recovery=B,this.assertValidity()}static fromCompact(R){let S=e.nByteLength;return R=(0,bt.ensureBytes)("compactSignature",R,S*2),new O(N(R,0,S),N(R,S,2*S))}static fromDER(R){let{r:S,s:B}=wt.DER.toSig((0,bt.ensureBytes)("DER",R));return new O(S,B)}assertValidity(){Oe.aInRange("r",this.r,je,n),Oe.aInRange("s",this.s,je,n)}addRecoveryBit(R){return new O(this.r,this.s,R)}recoverPublicKey(R){let{r:S,s:B,recovery:V}=this,J=k((0,bt.ensureBytes)("msgHash",R));if(V==null||![0,1,2,3].includes(V))throw new Error("recovery id invalid");let ae=V===2||V===3?S+e.n:S;if(ae>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let ce=(V&1)===0?"02":"03",D=c.fromHex(ce+g(ae)),F=a(ae),p=o(-J*F),L=o(B*F),re=c.BASE.multiplyAndAddUnsafe(D,p,L);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new O(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Oe.hexToBytes(this.toDERHex())}toDERHex(){return wt.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Oe.hexToBytes(this.toCompactHex())}toCompactHex(){return g(this.r)+g(this.s)}}let I={isValidPrivateKey(m){try{return f(m),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let m=Gn.getMinHashLength(e.n);return Gn.mapHashToField(e.randomBytes(m),e.n)},precompute(m=8,R=c.BASE){return R._setWindowSize(m),R.multiply(BigInt(3)),R}};function M(m,R=!0){return c.fromPrivateKey(m).toRawBytes(R)}function A(m){let R=Oe.isBytes(m),S=typeof m=="string",B=(R||S)&&m.length;return R?B===i||B===s:S?B===2*i||B===2*s:m instanceof c}function K(m,R,S=!0){if(A(m))throw new Error("first arg must be private key");if(!A(R))throw new Error("second arg must be public key");return c.fromHex(R).multiply(f(m)).toRawBytes(S)}let E=e.bits2int||function(m){let R=Oe.bytesToNumberBE(m),S=m.length*8-e.nBitLength;return S>0?R>>BigInt(S):R},k=e.bits2int_modN||function(m){return o(E(m))},G=Oe.bitMask(e.nBitLength);function z(m){return Oe.aInRange(`num < 2^${e.nBitLength}`,m,hr,G),Oe.numberToBytesBE(m,e.nByteLength)}function q(m,R,S=oe){if(["recovered","canonical"].some(X=>X in S))throw new Error("sign() legacy options not supported");let{hash:B,randomBytes:V}=e,{lowS:J,prehash:ae,extraEntropy:ce}=S;J==null&&(J=!0),m=(0,bt.ensureBytes)("msgHash",m),ch(S),ae&&(m=(0,bt.ensureBytes)("prehashed msgHash",B(m)));let D=k(m),F=f(R),p=[z(F),z(D)];if(ce!=null&&ce!==!1){let X=ce===!0?V(r.BYTES):ce;p.push((0,bt.ensureBytes)("extraEntropy",X))}let L=Oe.concatBytes(...p),re=D;function le(X){let u=E(X);if(!h(u))return;let y=a(u),_=c.BASE.multiply(u).toAffine(),U=o(_.x);if(U===hr)return;let T=o(y*o(re+U*F));if(T===hr)return;let P=(_.x===U?0:2)|Number(_.y&je),H=T;return J&&b(T)&&(H=l(T),P^=1),new O(U,H,P)}return{seed:L,k2sig:le}}let oe={lowS:e.lowS,prehash:!1},Q={lowS:e.lowS,prehash:!1};function ie(m,R,S=oe){let{seed:B,k2sig:V}=q(m,R,S),J=e;return Oe.createHmacDrbg(J.hash.outputLen,J.nByteLength,J.hmac)(B,V)}c.BASE._setWindowSize(8);function w(m,R,S,B=Q){let V=m;if(R=(0,bt.ensureBytes)("msgHash",R),S=(0,bt.ensureBytes)("publicKey",S),"strict"in B)throw new Error("options.strict was renamed to lowS");ch(B);let{lowS:J,prehash:ae}=B,ce,D;try{if(typeof V=="string"||Oe.isBytes(V))try{ce=O.fromDER(V)}catch(_){if(!(_ instanceof wt.DER.Err))throw _;ce=O.fromCompact(V)}else if(typeof V=="object"&&typeof V.r=="bigint"&&typeof V.s=="bigint"){let{r:_,s:U}=V;ce=new O(_,U)}else throw new Error("PARSE");D=c.fromHex(S)}catch(_){if(_.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(J&&ce.hasHighS())return!1;ae&&(R=e.hash(R));let{r:F,s:p}=ce,L=k(R),re=a(p),le=o(L*re),X=o(F*re),u=c.BASE.multiplyAndAddUnsafe(D,le,X)?.toAffine();return u?o(u.x)===F:!1}return{CURVE:e,getPublicKey:M,getSharedSecret:K,sign:ie,verify:w,ProjectivePoint:c,Signature:O,utils:I}}function fh(t,e){let r=t.ORDER,n=hr;for(let l=r-je;l%wn===hr;l/=wn)n+=je;let i=n,s=wn<<i-je-je,o=s*wn,a=(r-je)/o,c=(a-je)/wn,f=o-je,d=s,h=t.pow(e,a),g=t.pow(e,(a+je)/wn),b=(l,N)=>{let O=h,I=t.pow(N,f),M=t.sqr(I);M=t.mul(M,N);let A=t.mul(l,M);A=t.pow(A,c),A=t.mul(A,I),I=t.mul(A,N),M=t.mul(A,l);let K=t.mul(M,I);A=t.pow(K,d);let E=t.eql(A,t.ONE);I=t.mul(M,g),A=t.mul(K,O),M=t.cmov(I,M,E),K=t.cmov(A,K,E);for(let k=i;k>je;k--){let G=k-wn;G=wn<<G-je;let z=t.pow(K,G),q=t.eql(z,t.ONE);I=t.mul(M,O),O=t.mul(O,O),z=t.mul(K,O),M=t.cmov(I,M,q),K=t.cmov(z,K,q)}return{isValid:E,value:M}};if(t.ORDER%uh===ca){let l=(t.ORDER-ca)/uh,N=t.sqrt(t.neg(e));b=(O,I)=>{let M=t.sqr(I),A=t.mul(O,I);M=t.mul(M,A);let K=t.pow(M,l);K=t.mul(K,A);let E=t.mul(K,N),k=t.mul(t.sqr(K),I),G=t.eql(k,O),z=t.cmov(E,K,G);return{isValid:G,value:z}}}return b}function ww(t,e){if(Gn.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=fh(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,a,c,f,d,h;i=t.sqr(n),i=t.mul(i,e.Z),s=t.sqr(i),s=t.add(s,i),o=t.add(s,t.ONE),o=t.mul(o,e.B),a=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),a=t.mul(a,e.A),s=t.sqr(o),f=t.sqr(a),c=t.mul(f,e.A),s=t.add(s,c),s=t.mul(s,o),f=t.mul(f,a),c=t.mul(f,e.B),s=t.add(s,c),d=t.mul(i,o);let{isValid:g,value:b}=r(s,f);h=t.mul(i,n),h=t.mul(h,b),d=t.cmov(d,o,g),h=t.cmov(h,b,g);let l=t.isOdd(n)===t.isOdd(h);return h=t.cmov(t.neg(h),h,l),d=t.div(d,a),{x:d,y:h}}}});var _h=ee(pl=>{"use strict";Object.defineProperty(pl,"__esModule",{value:!0});pl.bls=vw;var dh=Fr(),hl=Dt(),hh=oa(),ph=dl(),Ew=BigInt(0),ua=BigInt(1),yh=BigInt(2),Oi=BigInt(3);function xw(t){let e=[];for(;t>ua;t>>=ua)(t&ua)===Ew?e.unshift(0):(t&Oi)===Oi?(e.unshift(-1),t+=ua):e.unshift(1);return e}function vw(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=t.params.xNegative,a=t.params.twistType,c=(0,ph.weierstrassPoints)({n:r.ORDER,...t.G1}),f=Object.assign(c,(0,hh.createHasher)(c.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults})),d=(0,ph.weierstrassPoints)({n:r.ORDER,...t.G2}),h=Object.assign(d,(0,hh.createHasher)(d.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),g;if(a==="multiplicative")g=(D,F,p,L,re,le)=>s.mul014(L,D,n.mul(F,re),n.mul(p,le));else if(a==="divisive")g=(D,F,p,L,re,le)=>s.mul034(L,n.mul(p,le),n.mul(F,re),D);else throw new Error("bls: unknown twist type");let b=n.div(n.ONE,n.mul(n.ONE,yh));function l(D,F,p,L){let re=n.sqr(p),le=n.sqr(L),X=n.mulByB(n.mul(le,Oi)),u=n.mul(X,Oi),y=n.sub(n.sub(n.sqr(n.add(p,L)),le),re),_=n.sub(X,re),U=n.mul(n.sqr(F),Oi),T=n.neg(y);return D.push([_,U,T]),F=n.mul(n.mul(n.mul(n.sub(re,u),F),p),b),p=n.sub(n.sqr(n.mul(n.add(re,u),b)),n.mul(n.sqr(X),Oi)),L=n.mul(re,y),{Rx:F,Ry:p,Rz:L}}function N(D,F,p,L,re,le){let X=n.sub(p,n.mul(le,L)),u=n.sub(F,n.mul(re,L)),y=n.sub(n.mul(X,re),n.mul(u,le)),_=n.neg(X),U=u;D.push([y,_,U]);let T=n.sqr(u),P=n.mul(T,u),H=n.mul(T,F),x=n.add(n.sub(P,n.mul(H,yh)),n.mul(n.sqr(X),L));return F=n.mul(u,x),p=n.sub(n.mul(n.sub(H,x),X),n.mul(P,p)),L=n.mul(L,P),{Rx:F,Ry:p,Rz:L}}let O=xw(t.params.ateLoopSize),I=(0,hl.memoized)(D=>{let F=D,{x:p,y:L}=F.toAffine(),re=p,le=L,X=n.neg(L),u=re,y=le,_=n.ONE,U=[];for(let T of O){let P=[];({Rx:u,Ry:y,Rz:_}=l(P,u,y,_)),T&&({Rx:u,Ry:y,Rz:_}=N(P,u,y,_,re,T===-1?X:le)),U.push(P)}if(t.postPrecompute){let T=U[U.length-1];t.postPrecompute(u,y,_,re,le,N.bind(null,T))}return U});function M(D,F=!1){let p=s.ONE;if(D.length){let L=D[0][0].length;for(let re=0;re<L;re++){p=s.sqr(p);for(let[le,X,u]of D)for(let[y,_,U]of le[re])p=g(y,_,U,p,X,u)}}return o&&(p=s.conjugate(p)),F?s.finalExponentiate(p):p}function A(D,F=!0){let p=[];f.ProjectivePoint.normalizeZ(D.map(({g1:L})=>L)),h.ProjectivePoint.normalizeZ(D.map(({g2:L})=>L));for(let{g1:L,g2:re}of D){if(L.equals(f.ProjectivePoint.ZERO)||re.equals(h.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");L.assertValidity(),re.assertValidity();let le=L.toAffine();p.push([I(re),le.x,le.y])}return M(p,F)}function K(D,F,p=!0){return A([{g1:D,g2:F}],p)}let E={randomPrivateKey:()=>{let D=(0,dh.getMinHashLength)(r.ORDER);return(0,dh.mapHashToField)(t.randomBytes(D),r.ORDER)},calcPairingPrecomputes:I},{ShortSignature:k}=t.G1,{Signature:G}=t.G2;function z(D){return D instanceof f.ProjectivePoint?D:f.ProjectivePoint.fromHex(D)}function q(D,F){return D instanceof f.ProjectivePoint?D:f.hashToCurve((0,hl.ensureBytes)("point",D),F)}function oe(D){return D instanceof h.ProjectivePoint?D:G.fromHex(D)}function Q(D,F){return D instanceof h.ProjectivePoint?D:h.hashToCurve((0,hl.ensureBytes)("point",D),F)}function ie(D){return f.ProjectivePoint.fromPrivateKey(D).toRawBytes(!0)}function w(D){return h.ProjectivePoint.fromPrivateKey(D).toRawBytes(!0)}function m(D,F,p){let L=Q(D,p);L.assertValidity();let re=L.multiply(f.normPrivateKeyToScalar(F));return D instanceof h.ProjectivePoint?re:G.toRawBytes(re)}function R(D,F,p){let L=q(D,p);L.assertValidity();let re=L.multiply(f.normPrivateKeyToScalar(F));return D instanceof f.ProjectivePoint?re:k.toRawBytes(re)}function S(D,F,p,L){let re=z(p),le=Q(F,L),X=f.ProjectivePoint.BASE,u=oe(D),y=A([{g1:re.negate(),g2:le},{g1:X,g2:u}]);return s.eql(y,s.ONE)}function B(D,F,p,L){let re=oe(p),le=q(F,L),X=h.ProjectivePoint.BASE,u=z(D),y=A([{g1:le,g2:re},{g1:u,g2:X.negate()}]);return s.eql(y,s.ONE)}function V(D){if(!D.length)throw new Error("Expected non-empty array");let p=D.map(z).reduce((L,re)=>L.add(re),f.ProjectivePoint.ZERO);return D[0]instanceof f.ProjectivePoint?(p.assertValidity(),p):p.toRawBytes(!0)}function J(D){if(!D.length)throw new Error("Expected non-empty array");let p=D.map(oe).reduce((L,re)=>L.add(re),h.ProjectivePoint.ZERO);return D[0]instanceof h.ProjectivePoint?(p.assertValidity(),p):G.toRawBytes(p)}function ae(D){if(!D.length)throw new Error("Expected non-empty array");let p=D.map(z).reduce((L,re)=>L.add(re),f.ProjectivePoint.ZERO);return D[0]instanceof f.ProjectivePoint?(p.assertValidity(),p):k.toRawBytes(p)}function ce(D,F,p,L){if(!F.length)throw new Error("Expected non-empty messages array");if(p.length!==F.length)throw new Error("Pubkey count should equal msg count");let re=oe(D),le=F.map(_=>Q(_,L)),X=p.map(z),u=new Map;for(let _=0;_<X.length;_++){let U=X[_],T=le[_],P=u.get(T);P===void 0&&(P=[],u.set(T,P)),P.push(U)}let y=[];try{for(let[_,U]of u){let T=U.reduce((P,H)=>P.add(H));y.push({g1:T,g2:_})}return y.push({g1:f.ProjectivePoint.BASE.negate(),g2:re}),s.eql(A(y),s.ONE)}catch{return!1}}return f.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:ie,getPublicKeyForShortSignatures:w,sign:m,signShortSignature:R,verify:S,verifyBatch:ce,verifyShortSignature:B,aggregatePublicKeys:V,aggregateSignatures:J,aggregateShortSignatures:ae,millerLoopBatch:M,pairing:K,pairingBatch:A,G1:f,G2:h,Signature:G,ShortSignature:k,fields:{Fr:r,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:t.params.ateLoopSize,r:t.params.r,G1b:t.G1.b,G2b:t.G2.b},utils:E}}});var mh=ee(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.psiFrobenius=Aw;la.tower12=Ow;var En=Fr(),pr=Dt(),Tw=BigInt(0),Si=BigInt(1),en=BigInt(2),gh=BigInt(3);function yl(t,e,r,n,i=1,s){let o=BigInt(s===void 0?n:s),a=r**BigInt(n),c=[];for(let f=0;f<i;f++){let d=BigInt(f+1),h=[];for(let g=0,b=Si;g<n;g++){let l=(d*b-d)/o%a;h.push(t.pow(e,l)),b*=r}c.push(h)}return c}function Aw(t,e,r){let n=e.pow(r,(t.ORDER-Si)/gh),i=e.pow(r,(t.ORDER-Si)/en);function s(g,b){let l=e.mul(e.frobeniusMap(g,1),n),N=e.mul(e.frobeniusMap(b,1),i);return[l,N]}let o=e.pow(r,(t.ORDER**en-Si)/gh),a=e.pow(r,(t.ORDER**en-Si)/en);if(!e.eql(a,e.neg(e.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(g,b){return[e.mul(g,o),e.neg(b)]}let f=g=>(b,l)=>{let N=l.toAffine(),O=g(N.x,N.y);return b.fromAffine({x:O[0],y:O[1]})},d=f(s),h=f(c);return{psi:s,psi2:c,G2psi:d,G2psi2:h,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:a}}function Ow(t){let{ORDER:e}=t,r=En.Field(e),n=r.create(t.NONRESIDUE||BigInt(-1)),i=En.FpLegendre(e),s=r.div(r.ONE,en),o=yl(r,n,r.ORDER,2)[0],a=({c0:w,c1:m},{c0:R,c1:S})=>({c0:r.add(w,R),c1:r.add(m,S)}),c=({c0:w,c1:m},{c0:R,c1:S})=>({c0:r.sub(w,R),c1:r.sub(m,S)}),f=({c0:w,c1:m},R)=>{if(typeof R=="bigint")return{c0:r.mul(w,R),c1:r.mul(m,R)};let{c0:S,c1:B}=R,V=r.mul(w,S),J=r.mul(m,B),ae=r.sub(V,J),ce=r.sub(r.mul(r.add(w,m),r.add(S,B)),r.add(V,J));return{c0:ae,c1:ce}},d=({c0:w,c1:m})=>{let R=r.add(w,m),S=r.sub(w,m),B=r.add(w,w);return{c0:r.mul(R,S),c1:r.mul(B,m)}},h=w=>{if(w.length!==2)throw new Error("Invalid tuple");let m=w.map(R=>r.create(R));return{c0:m[0],c1:m[1]}},g=e*e,b=h(t.FP2_NONRESIDUE),l={ORDER:g,NONRESIDUE:b,BITS:(0,pr.bitLen)(g),BYTES:Math.ceil((0,pr.bitLen)(g)/8),MASK:(0,pr.bitMask)((0,pr.bitLen)(g)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:w=>w,isValid:({c0:w,c1:m})=>typeof w=="bigint"&&typeof m=="bigint",is0:({c0:w,c1:m})=>r.is0(w)&&r.is0(m),eql:({c0:w,c1:m},{c0:R,c1:S})=>r.eql(w,R)&&r.eql(m,S),neg:({c0:w,c1:m})=>({c0:r.neg(w),c1:r.neg(m)}),pow:(w,m)=>En.FpPow(l,w,m),invertBatch:w=>En.FpInvertBatch(l,w),add:a,sub:c,mul:f,sqr:d,addN:a,subN:c,mulN:f,sqrN:d,div:(w,m)=>l.mul(w,typeof m=="bigint"?r.inv(r.create(m)):l.inv(m)),inv:({c0:w,c1:m})=>{let R=r.inv(r.create(w*w+m*m));return{c0:r.mul(R,r.create(w)),c1:r.mul(R,r.create(-m))}},sqrt:w=>{if(t.Fp2sqrt)return t.Fp2sqrt(w);let{c0:m,c1:R}=w;if(r.is0(R))return r.eql(i(r,m),r.ONE)?l.create({c0:r.sqrt(m),c1:r.ZERO}):l.create({c0:r.ZERO,c1:r.sqrt(r.div(m,n))});let S=r.sqrt(r.sub(r.sqr(m),r.mul(r.sqr(R),n))),B=r.mul(r.add(S,m),s),V=i(r,B);!r.is0(V)&&!r.eql(V,r.ONE)&&(B=r.sub(B,S));let J=r.sqrt(B),ae=l.create({c0:J,c1:r.div(r.mul(R,s),J)});if(!l.eql(l.sqr(ae),w))throw new Error("Cannot find square root");let ce=ae,D=l.neg(ce),{re:F,im:p}=l.reim(ce),{re:L,im:re}=l.reim(D);return p>re||p===re&&F>L?ce:D},isOdd:w=>{let{re:m,im:R}=l.reim(w),S=m%en,B=m===Tw,V=R%en;return BigInt(S||B&&V)==Si},fromBytes(w){if(w.length!==l.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:r.fromBytes(w.subarray(0,r.BYTES)),c1:r.fromBytes(w.subarray(r.BYTES))}},toBytes:({c0:w,c1:m})=>(0,pr.concatBytes)(r.toBytes(w),r.toBytes(m)),cmov:({c0:w,c1:m},{c0:R,c1:S},B)=>({c0:r.cmov(w,R,B),c1:r.cmov(m,S,B)}),reim:({c0:w,c1:m})=>({re:w,im:m}),mulByNonresidue:({c0:w,c1:m})=>l.mul({c0:w,c1:m},b),mulByB:t.Fp2mulByB,fromBigTuple:h,frobeniusMap:({c0:w,c1:m},R)=>({c0:w,c1:r.mul(m,o[R%2])})},N=({c0:w,c1:m,c2:R},{c0:S,c1:B,c2:V})=>({c0:l.add(w,S),c1:l.add(m,B),c2:l.add(R,V)}),O=({c0:w,c1:m,c2:R},{c0:S,c1:B,c2:V})=>({c0:l.sub(w,S),c1:l.sub(m,B),c2:l.sub(R,V)}),I=({c0:w,c1:m,c2:R},S)=>{if(typeof S=="bigint")return{c0:l.mul(w,S),c1:l.mul(m,S),c2:l.mul(R,S)};let{c0:B,c1:V,c2:J}=S,ae=l.mul(w,B),ce=l.mul(m,V),D=l.mul(R,J);return{c0:l.add(ae,l.mulByNonresidue(l.sub(l.mul(l.add(m,R),l.add(V,J)),l.add(ce,D)))),c1:l.add(l.sub(l.mul(l.add(w,m),l.add(B,V)),l.add(ae,ce)),l.mulByNonresidue(D)),c2:l.sub(l.add(ce,l.mul(l.add(w,R),l.add(B,J))),l.add(ae,D))}},M=({c0:w,c1:m,c2:R})=>{let S=l.sqr(w),B=l.mul(l.mul(w,m),en),V=l.mul(l.mul(m,R),en),J=l.sqr(R);return{c0:l.add(l.mulByNonresidue(V),S),c1:l.add(l.mulByNonresidue(J),B),c2:l.sub(l.sub(l.add(l.add(B,l.sqr(l.add(l.sub(w,m),R))),V),S),J)}},[A,K]=yl(l,b,r.ORDER,6,2,3),E={ORDER:l.ORDER,BITS:3*l.BITS,BYTES:3*l.BYTES,MASK:(0,pr.bitMask)(3*l.BITS),ZERO:{c0:l.ZERO,c1:l.ZERO,c2:l.ZERO},ONE:{c0:l.ONE,c1:l.ZERO,c2:l.ZERO},create:w=>w,isValid:({c0:w,c1:m,c2:R})=>l.isValid(w)&&l.isValid(m)&&l.isValid(R),is0:({c0:w,c1:m,c2:R})=>l.is0(w)&&l.is0(m)&&l.is0(R),neg:({c0:w,c1:m,c2:R})=>({c0:l.neg(w),c1:l.neg(m),c2:l.neg(R)}),eql:({c0:w,c1:m,c2:R},{c0:S,c1:B,c2:V})=>l.eql(w,S)&&l.eql(m,B)&&l.eql(R,V),sqrt:pr.notImplemented,div:(w,m)=>E.mul(w,typeof m=="bigint"?r.inv(r.create(m)):E.inv(m)),pow:(w,m)=>En.FpPow(E,w,m),invertBatch:w=>En.FpInvertBatch(E,w),add:N,sub:O,mul:I,sqr:M,addN:N,subN:O,mulN:I,sqrN:M,inv:({c0:w,c1:m,c2:R})=>{let S=l.sub(l.sqr(w),l.mulByNonresidue(l.mul(R,m))),B=l.sub(l.mulByNonresidue(l.sqr(R)),l.mul(w,m)),V=l.sub(l.sqr(m),l.mul(w,R)),J=l.inv(l.add(l.mulByNonresidue(l.add(l.mul(R,B),l.mul(m,V))),l.mul(w,S)));return{c0:l.mul(J,S),c1:l.mul(J,B),c2:l.mul(J,V)}},fromBytes:w=>{if(w.length!==E.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:l.fromBytes(w.subarray(0,l.BYTES)),c1:l.fromBytes(w.subarray(l.BYTES,2*l.BYTES)),c2:l.fromBytes(w.subarray(2*l.BYTES))}},toBytes:({c0:w,c1:m,c2:R})=>(0,pr.concatBytes)(l.toBytes(w),l.toBytes(m),l.toBytes(R)),cmov:({c0:w,c1:m,c2:R},{c0:S,c1:B,c2:V},J)=>({c0:l.cmov(w,S,J),c1:l.cmov(m,B,J),c2:l.cmov(R,V,J)}),fromBigSix:w=>{if(!Array.isArray(w)||w.length!==6)throw new Error("Invalid Fp6 usage");return{c0:l.fromBigTuple(w.slice(0,2)),c1:l.fromBigTuple(w.slice(2,4)),c2:l.fromBigTuple(w.slice(4,6))}},frobeniusMap:({c0:w,c1:m,c2:R},S)=>({c0:l.frobeniusMap(w,S),c1:l.mul(l.frobeniusMap(m,S),A[S%6]),c2:l.mul(l.frobeniusMap(R,S),K[S%6])}),mulByFp2:({c0:w,c1:m,c2:R},S)=>({c0:l.mul(w,S),c1:l.mul(m,S),c2:l.mul(R,S)}),mulByNonresidue:({c0:w,c1:m,c2:R})=>({c0:l.mulByNonresidue(R),c1:w,c2:m}),mul1:({c0:w,c1:m,c2:R},S)=>({c0:l.mulByNonresidue(l.mul(R,S)),c1:l.mul(w,S),c2:l.mul(m,S)}),mul01({c0:w,c1:m,c2:R},S,B){let V=l.mul(w,S),J=l.mul(m,B);return{c0:l.add(l.mulByNonresidue(l.sub(l.mul(l.add(m,R),B),J)),V),c1:l.sub(l.sub(l.mul(l.add(S,B),l.add(w,m)),V),J),c2:l.add(l.sub(l.mul(l.add(w,R),S),V),J)}}},k=yl(l,b,r.ORDER,12,1,6)[0],G=({c0:w,c1:m},{c0:R,c1:S})=>({c0:E.add(w,R),c1:E.add(m,S)}),z=({c0:w,c1:m},{c0:R,c1:S})=>({c0:E.sub(w,R),c1:E.sub(m,S)}),q=({c0:w,c1:m},R)=>{if(typeof R=="bigint")return{c0:E.mul(w,R),c1:E.mul(m,R)};let{c0:S,c1:B}=R,V=E.mul(w,S),J=E.mul(m,B);return{c0:E.add(V,E.mulByNonresidue(J)),c1:E.sub(E.mul(E.add(w,m),E.add(S,B)),E.add(V,J))}},oe=({c0:w,c1:m})=>{let R=E.mul(w,m);return{c0:E.sub(E.sub(E.mul(E.add(E.mulByNonresidue(m),w),E.add(w,m)),R),E.mulByNonresidue(R)),c1:E.add(R,R)}};function Q(w,m){let R=l.sqr(w),S=l.sqr(m);return{first:l.add(l.mulByNonresidue(S),R),second:l.sub(l.sub(l.sqr(l.add(w,m)),R),S)}}let ie={ORDER:l.ORDER,BITS:2*l.BITS,BYTES:2*l.BYTES,MASK:(0,pr.bitMask)(2*l.BITS),ZERO:{c0:E.ZERO,c1:E.ZERO},ONE:{c0:E.ONE,c1:E.ZERO},create:w=>w,isValid:({c0:w,c1:m})=>E.isValid(w)&&E.isValid(m),is0:({c0:w,c1:m})=>E.is0(w)&&E.is0(m),neg:({c0:w,c1:m})=>({c0:E.neg(w),c1:E.neg(m)}),eql:({c0:w,c1:m},{c0:R,c1:S})=>E.eql(w,R)&&E.eql(m,S),sqrt:pr.notImplemented,inv:({c0:w,c1:m})=>{let R=E.inv(E.sub(E.sqr(w),E.mulByNonresidue(E.sqr(m))));return{c0:E.mul(w,R),c1:E.neg(E.mul(m,R))}},div:(w,m)=>ie.mul(w,typeof m=="bigint"?r.inv(r.create(m)):ie.inv(m)),pow:(w,m)=>En.FpPow(ie,w,m),invertBatch:w=>En.FpInvertBatch(ie,w),add:G,sub:z,mul:q,sqr:oe,addN:G,subN:z,mulN:q,sqrN:oe,fromBytes:w=>{if(w.length!==ie.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:E.fromBytes(w.subarray(0,E.BYTES)),c1:E.fromBytes(w.subarray(E.BYTES))}},toBytes:({c0:w,c1:m})=>(0,pr.concatBytes)(E.toBytes(w),E.toBytes(m)),cmov:({c0:w,c1:m},{c0:R,c1:S},B)=>({c0:E.cmov(w,R,B),c1:E.cmov(m,S,B)}),fromBigTwelve:w=>({c0:E.fromBigSix(w.slice(0,6)),c1:E.fromBigSix(w.slice(6,12))}),frobeniusMap(w,m){let{c0:R,c1:S,c2:B}=E.frobeniusMap(w.c1,m),V=k[m%12];return{c0:E.frobeniusMap(w.c0,m),c1:E.create({c0:l.mul(R,V),c1:l.mul(S,V),c2:l.mul(B,V)})}},mulByFp2:({c0:w,c1:m},R)=>({c0:E.mulByFp2(w,R),c1:E.mulByFp2(m,R)}),conjugate:({c0:w,c1:m})=>({c0:w,c1:E.neg(m)}),mul014:({c0:w,c1:m},R,S,B)=>{let V=E.mul01(w,R,S),J=E.mul1(m,B);return{c0:E.add(E.mulByNonresidue(J),V),c1:E.sub(E.sub(E.mul01(E.add(m,w),R,l.add(S,B)),V),J)}},mul034:({c0:w,c1:m},R,S,B)=>{let V=E.create({c0:l.mul(w.c0,R),c1:l.mul(w.c1,R),c2:l.mul(w.c2,R)}),J=E.mul01(m,S,B),ae=E.mul01(E.add(w,m),l.add(R,S),B);return{c0:E.add(E.mulByNonresidue(J),V),c1:E.sub(ae,E.add(V,J))}},_cyclotomicSquare:t.Fp12cyclotomicSquare,_cyclotomicExp:t.Fp12cyclotomicExp,finalExponentiate:t.Fp12finalExponentiate};return{Fp:r,Fp2:l,Fp6:E,Fp4Square:Q,Fp12:ie}}});var Sh=ee(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.bls12_381=void 0;var vh=po(),Sw=kn(),Nw=_h(),Rw=Fr(),Se=Dt(),Th=oa(),Ah=dl(),Oh=mh(),Ft=BigInt(0),ha=BigInt(1),pt=BigInt(2),fa=BigInt(3),bs=BigInt(4),xn=BigInt("0xd201000000010000"),Bw=(0,Se.bitLen)(xn),{Fp:de,Fp2:pe,Fp6:ml,Fp4Square:_l,Fp12:ve}=(0,Oh.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[ha,ha],Fp2mulByB:({c0:t,c1:e})=>{let r=de.mul(t,bs),n=de.mul(e,bs);return{c0:de.sub(r,n),c1:de.add(r,n)}},Fp12cyclotomicSquare:({c0:t,c1:e})=>{let{c0:r,c1:n,c2:i}=t,{c0:s,c1:o,c2:a}=e,{first:c,second:f}=_l(r,o),{first:d,second:h}=_l(s,i),{first:g,second:b}=_l(n,a),l=pe.mulByNonresidue(b);return{c0:ml.create({c0:pe.add(pe.mul(pe.sub(c,r),pt),c),c1:pe.add(pe.mul(pe.sub(d,n),pt),d),c2:pe.add(pe.mul(pe.sub(g,i),pt),g)}),c1:ml.create({c0:pe.add(pe.mul(pe.add(l,s),pt),l),c1:pe.add(pe.mul(pe.add(f,o),pt),f),c2:pe.add(pe.mul(pe.add(h,a),pt),h)})}},Fp12cyclotomicExp(t,e){let r=ve.ONE;for(let n=Bw-1;n>=0;n--)r=ve._cyclotomicSquare(r),(0,Se.bitGet)(e,n)&&(r=ve.mul(r,t));return r},Fp12finalExponentiate:t=>{let e=xn,r=ve.div(ve.frobeniusMap(t,6),t),n=ve.mul(ve.frobeniusMap(r,2),r),i=ve.conjugate(ve._cyclotomicExp(n,e)),s=ve.mul(ve.conjugate(ve._cyclotomicSquare(n)),i),o=ve.conjugate(ve._cyclotomicExp(s,e)),a=ve.conjugate(ve._cyclotomicExp(o,e)),c=ve.mul(ve.conjugate(ve._cyclotomicExp(a,e)),ve._cyclotomicSquare(i)),f=ve.conjugate(ve._cyclotomicExp(c,e)),d=ve.frobeniusMap(ve.mul(i,a),2),h=ve.frobeniusMap(ve.mul(o,n),3),g=ve.frobeniusMap(ve.mul(c,ve.conjugate(n)),1),b=ve.mul(ve.mul(f,ve.conjugate(s)),n);return ve.mul(ve.mul(ve.mul(d,h),g),b)}}),bh=Rw.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),Pw=(0,Th.isogenyMap)(pe,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(t=>t.map(e=>pe.fromBigTuple(e.map(BigInt))))),Uw=(0,Th.isogenyMap)(de,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(e=>BigInt(e)))),Iw=(0,Ah.mapToCurveSimpleSWU)(pe,{A:pe.create({c0:de.create(Ft),c1:de.create(BigInt(240))}),B:pe.create({c0:de.create(BigInt(1012)),c1:de.create(BigInt(1012))}),Z:pe.create({c0:de.create(BigInt(-2)),c1:de.create(BigInt(-1))})}),Cw=(0,Ah.mapToCurveSimpleSWU)(de,{A:de.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:de.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:de.create(BigInt(11))}),{G2psi:wh,G2psi2:Fw}=(0,Oh.psiFrobenius)(de,pe,pe.div(pe.ONE,pe.NONRESIDUE)),gl=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:de.ORDER,m:2,k:128,expand:"xmd",hash:vh.sha256}),pa=ws(de.toBytes(Ft),{infinity:!0,compressed:!0});function da(t){t=t.slice();let e=t[0]&224,r=!!(e>>7&1),n=!!(e>>6&1),i=!!(e>>5&1);return t[0]&=31,{compressed:r,infinity:n,sort:i,value:t}}function ws(t,e){if(t[0]&224)throw new Error("setMask: non-empty mask");return e.compressed&&(t[0]|=128),e.infinity&&(t[0]|=64),e.sort&&(t[0]|=32),t}function Eh(t){t.assertValidity();let e=t.equals(Mt.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return pa.slice();let i=de.ORDER,s=!!(n*pt/i);return ws((0,Se.numberToBytesBE)(r,de.BYTES),{compressed:!0,sort:s})}function xh(t){t.assertValidity();let e=de.BYTES;if(t.equals(Mt.bls12_381.G2.ProjectivePoint.ZERO))return(0,Se.concatBytes)(pa,(0,Se.numberToBytesBE)(Ft,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=pe.reim(r),{re:o,im:a}=pe.reim(n),f=!!((a>Ft?a*pt:o*pt)/de.ORDER&ha),d=i;return(0,Se.concatBytes)(ws((0,Se.numberToBytesBE)(s,e),{sort:f,compressed:!0}),(0,Se.numberToBytesBE)(d,e))}Mt.bls12_381=(0,Nw.bls)({fields:{Fp:de,Fp2:pe,Fp6:ml,Fp12:ve,Fr:bh},G1:{Fp:de,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:de.ZERO,b:bs,htfDefaults:{...gl,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(t,e)=>{let r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new t(de.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(xn).negate().multiplyUnsafe(xn).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(xn).add(e),mapToCurve:t=>{let{x:e,y:r}=Cw(de.create(t[0]));return Uw(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=da(t);if(i.length===48&&e){let s=de.ORDER,o=(0,Se.bytesToNumberBE)(i),a=de.create(o&de.MASK);if(r){if(a!==Ft)throw new Error("G1: non-empty compressed point at infinity");return{x:Ft,y:Ft}}let c=de.add(de.pow(a,fa),de.create(Mt.bls12_381.params.G1b)),f=de.sqrt(c);if(!f)throw new Error("Invalid compressed G1 point");return f*pt/s!==BigInt(n)&&(f=de.neg(f)),{x:de.create(a),y:de.create(f)}}else if(i.length===96&&!e){let s=(0,Se.bytesToNumberBE)(i.subarray(0,de.BYTES)),o=(0,Se.bytesToNumberBE)(i.subarray(de.BYTES));if(r){if(s!==Ft||o!==Ft)throw new Error("G1: non-empty point at infinity");return Mt.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:de.create(s),y:de.create(o)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(t,e,r)=>{let n=e.equals(t.ZERO),{x:i,y:s}=e.toAffine();if(r){if(n)return pa.slice();let o=de.ORDER,a=!!(s*pt/o);return ws((0,Se.numberToBytesBE)(i,de.BYTES),{compressed:!0,sort:a})}else return n?(0,Se.concatBytes)(new Uint8Array([64]),new Uint8Array(2*de.BYTES-1)):(0,Se.concatBytes)((0,Se.numberToBytesBE)(i,de.BYTES),(0,Se.numberToBytesBE)(s,de.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=da((0,Se.ensureBytes)("signatureHex",t,48)),i=de.ORDER,s=(0,Se.bytesToNumberBE)(n);if(e)return Mt.bls12_381.G1.ProjectivePoint.ZERO;let o=de.create(s&de.MASK),a=de.add(de.pow(o,fa),de.create(Mt.bls12_381.params.G1b)),c=de.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let f=BigInt(r);c*pt/i!==f&&(c=de.neg(c));let d=Mt.bls12_381.G1.ProjectivePoint.fromAffine({x:o,y:c});return d.assertValidity(),d},toRawBytes(t){return Eh(t)},toHex(t){return(0,Se.bytesToHex)(Eh(t))}}},G2:{Fp:pe,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:pe.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:pe.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:pe.ZERO,b:pe.fromBigTuple([bs,bs]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...gl},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=Iw(pe.fromBigTuple(t));return Pw(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(xn).negate().equals(wh(t,e)),clearCofactor:(t,e)=>{let r=xn,n=e.multiplyUnsafe(r).negate(),i=wh(t,e),s=e.double();return s=Fw(t,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),s=s.add(i),s=s.subtract(n),s.subtract(e)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=da(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=de.BYTES,o=(a,c,f)=>(0,Se.bytesToNumberBE)(a.slice(c,f));if(i.length===96&&e){let a=Mt.bls12_381.params.G2b,c=de.ORDER;if(r){if(i.reduce((N,O)=>N!==0?O+1:O,0)>0)throw new Error("Invalid compressed G2 point");return{x:pe.ZERO,y:pe.ZERO}}let f=o(i,0,s),d=o(i,s,2*s),h=pe.create({c0:de.create(d),c1:de.create(f)}),g=pe.add(pe.pow(h,fa),a),b=pe.sqrt(g),l=b.c1===Ft?b.c0*pt/c:b.c1*pt/c?ha:Ft;return b=n&&l>0?b:pe.neg(b),{x:h,y:b}}else if(i.length===192&&!e){if(r){if(i.reduce((h,g)=>h!==0?g+1:g,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:pe.ZERO,y:pe.ZERO}}let a=o(i,0,s),c=o(i,s,2*s),f=o(i,2*s,3*s),d=o(i,3*s,4*s);return{x:pe.fromBigTuple([c,a]),y:pe.fromBigTuple([d,f])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(t,e,r)=>{let{BYTES:n,ORDER:i}=de,s=e.equals(t.ZERO),{x:o,y:a}=e.toAffine();if(r){if(s)return(0,Se.concatBytes)(pa,(0,Se.numberToBytesBE)(Ft,n));let c=!!(a.c1===Ft?a.c0*pt/i:a.c1*pt/i);return(0,Se.concatBytes)(ws((0,Se.numberToBytesBE)(o.c1,n),{compressed:!0,sort:c}),(0,Se.numberToBytesBE)(o.c0,n))}else{if(s)return(0,Se.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:f}=pe.reim(o),{re:d,im:h}=pe.reim(a);return(0,Se.concatBytes)((0,Se.numberToBytesBE)(f,n),(0,Se.numberToBytesBE)(c,n),(0,Se.numberToBytesBE)(h,n),(0,Se.numberToBytesBE)(d,n))}},Signature:{fromHex(t){let{infinity:e,sort:r,value:n}=da((0,Se.ensureBytes)("signatureHex",t)),i=de.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=(0,Se.bytesToNumberBE)(n.slice(0,s)),a=(0,Se.bytesToNumberBE)(n.slice(s));if(e)return Mt.bls12_381.G2.ProjectivePoint.ZERO;let c=de.create(o&de.MASK),f=de.create(a),d=pe.create({c0:f,c1:c}),h=pe.add(pe.pow(d,fa),Mt.bls12_381.params.G2b),g=pe.sqrt(h);if(!g)throw new Error("Failed to find a square root");let{re:b,im:l}=pe.reim(g),N=BigInt(r),O=l>Ft&&l*pt/i!==N,I=l===Ft&&b*pt/i!==N;(O||I)&&(g=pe.neg(g));let M=Mt.bls12_381.G2.ProjectivePoint.fromAffine({x:d,y:g});return M.assertValidity(),M},toRawBytes(t){return xh(t)},toHex(t){return(0,Se.bytesToHex)(xh(t))}}},params:{ateLoopSize:xn,r:bh.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:gl,hash:vh.sha256,randomBytes:Sw.randomBytes})});var wl=ee(Es=>{"use strict";Object.defineProperty(Es,"__esModule",{value:!0});Es.blsVerify=Es.verify=void 0;var Mw=Sh(),bl=Ht();function qw(t,e,r){let n=typeof t=="string"?t:(0,bl.toHex)(t),i=typeof e=="string"?e:(0,bl.toHex)(e),s=typeof r=="string"?r:(0,bl.toHex)(r);return Mw.bls12_381.verifyShortSignature(i,s,n)}Es.blsVerify=qw});var ya=ee(Yn=>{"use strict";Object.defineProperty(Yn,"__esModule",{value:!0});Yn.decodeTime=Yn.decodeLeb128=void 0;var Nh=xi(),jw=t=>(0,Nh.lebDecode)(new Nh.PipeArrayBuffer(t));Yn.decodeLeb128=jw;var kw=t=>{let e=(0,Yn.decodeLeb128)(t);return new Date(Number(e)/1e6)};Yn.decodeTime=kw});var Ni=ee(Te=>{"use strict";var Vw=Te&&Te.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Hw=Te&&Te.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Rh=Te&&Te.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Vw(e,t,r);return Hw(e,t),e},$w=Te&&Te.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Kw=Te&&Te.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ga;Object.defineProperty(Te,"__esModule",{value:!0});Te.check_canister_ranges=Te.find_label=Te.flatten_forks=Te.lookup_path=Te.LookupStatus=Te.reconstruct=Te.lookupResultToBuffer=Te.Certificate=Te.hashTreeToString=Te.NodeType=Te.CertificateVerificationError=void 0;var Bh=Rh(ys()),Gw=yi(),_a=ds(),yr=Ht(),El=It(),Yw=Rh(wl()),Ww=ya(),zw=Os(),tn=class extends Gw.AgentError{constructor(e){super(`Invalid certificate: ${e}`)}};Te.CertificateVerificationError=tn;var Et;(function(t){t[t.Empty=0]="Empty",t[t.Fork=1]="Fork",t[t.Labeled=2]="Labeled",t[t.Leaf=3]="Leaf",t[t.Pruned=4]="Pruned"})(Et=Te.NodeType||(Te.NodeType={}));function ma(t){let e=n=>n.split(`
|
|
16
|
+
`)}return c.encodeValue(f)}));return(0,Ue.concat)(n,i,s,o,a)}W.encode=Hm;function $m(t,e){let r=new Ue.PipeArrayBuffer(e);if(e.byteLength<vo.length)throw new Error("Message length smaller than magic number");let n=(0,se.safeRead)(r,vo.length),i=new TextDecoder().decode(n);if(i!==vo)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(b){let l=[],N=Number((0,se.lebDecode)(b));for(let M=0;M<N;M++){let A=Number((0,se.slebDecode)(b));switch(A){case-18:case-19:{let K=Number((0,se.slebDecode)(b));l.push([A,K]);break}case-20:case-21:{let K=[],E=Number((0,se.lebDecode)(b)),k;for(;E--;){let G=Number((0,se.lebDecode)(b));if(G>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof k=="number"&&k>=G)throw new Error("field id collision or not sorted");k=G;let z=Number((0,se.slebDecode)(b));K.push([G,z])}l.push([A,K]);break}case-22:{let K=[],E=Number((0,se.lebDecode)(b));for(;E--;)K.push(Number((0,se.slebDecode)(b)));let k=[],G=Number((0,se.lebDecode)(b));for(;G--;)k.push(Number((0,se.slebDecode)(b)));let z=[],q=Number((0,se.lebDecode)(b));for(;q--;)switch(Number((0,se.lebDecode)(b))){case 1:{z.push("query");break}case 2:{z.push("oneway");break}case 3:{z.push("composite_query");break}default:throw new Error("unknown annotation")}l.push([A,[K,k,z]]);break}case-23:{let K=Number((0,se.lebDecode)(b)),E=[];for(;K--;){let k=Number((0,se.lebDecode)(b)),G=new TextDecoder().decode((0,se.safeRead)(b,k)),z=(0,se.slebDecode)(b);E.push([G,z])}l.push([A,E]);break}default:throw new Error("Illegal op_code: "+A)}}let O=[],I=Number((0,se.lebDecode)(b));for(let M=0;M<I;M++)O.push(Number((0,se.slebDecode)(b)));return[l,O]}let[o,a]=s(r);if(a.length<t.length)throw new Error("Wrong number of return values");let c=o.map(b=>Wd());function f(b){if(b<-24)throw new Error("future value not supported");if(b<0)switch(b){case-1:return W.Null;case-2:return W.Bool;case-3:return W.Nat;case-4:return W.Int;case-5:return W.Nat8;case-6:return W.Nat16;case-7:return W.Nat32;case-8:return W.Nat64;case-9:return W.Int8;case-10:return W.Int16;case-11:return W.Int32;case-12:return W.Int64;case-13:return W.Float32;case-14:return W.Float64;case-15:return W.Text;case-16:return W.Reserved;case-17:return W.Empty;case-24:return W.Principal;default:throw new Error("Illegal op_code: "+b)}if(b>=o.length)throw new Error("type index out of range");return c[b]}function d(b){switch(b[0]){case-19:{let l=f(b[1]);return $d(l)}case-18:{let l=f(b[1]);return Kd(l)}case-20:{let l={};for(let[I,M]of b[1]){let A=`_${I}_`;l[A]=f(M)}let N=Gd(l),O=N.tryAsTuple();return Array.isArray(O)?Hd(...O):N}case-21:{let l={};for(let[N,O]of b[1]){let I=`_${N}_`;l[I]=f(O)}return Yd(l)}case-22:{let[l,N,O]=b[1];return zd(l.map(I=>f(I)),N.map(I=>f(I)),O)}case-23:{let l={},N=b[1];for(let[O,I]of N){let M=f(I);if(M instanceof pn&&(M=M.getType()),!(M instanceof ss))throw new Error("Illegal service definition: services can only contain functions");l[O]=M}return Dd(l)}default:throw new Error("Illegal op_code: "+b[0])}}o.forEach((b,l)=>{if(b[0]===-22){let N=d(b);c[l].fill(N)}}),o.forEach((b,l)=>{if(b[0]!==-22){let N=d(b);c[l].fill(N)}});let h=a.map(b=>f(b)),g=t.map((b,l)=>b.decodeValue(r,h[l]));for(let b=t.length;b<h.length;b++)h[b].decodeValue(r,h[b]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return g}W.decode=$m;W.Empty=new To;W.Reserved=new mi;W.Unknown=new Ao;W.Bool=new Oo;W.Null=new So;W.Text=new No;W.Int=new Ro;W.Nat=new Bo;W.Float32=new ns(32);W.Float64=new ns(64);W.Int8=new Qr(8);W.Int16=new Qr(16);W.Int32=new Qr(32);W.Int64=new Qr(64);W.Nat8=new Pr(8);W.Nat16=new Pr(16);W.Nat32=new Pr(32);W.Nat64=new Pr(64);W.Principal=new Co;function Hd(...t){return new Uo(t)}W.Tuple=Hd;function $d(t){return new Po(t)}W.Vec=$d;function Kd(t){return new bi(t)}W.Opt=Kd;function Gd(t){return new is(t)}W.Record=Gd;function Yd(t){return new Io(t)}W.Variant=Yd;function Wd(){return new pn}W.Rec=Wd;function zd(t,e,r=[]){return new ss(t,e,r)}W.Func=zd;function Dd(t){return new Fo(t)}W.Service=Dd});var yu=ee(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.VecForm=Ot.OptionForm=Ot.VariantForm=Ot.TupleForm=Ot.RecordForm=Ot.InputForm=Ot.InputBox=void 0;var uu=class{constructor(e,r){this.idl=e,this.ui=r,this.label=null,this.value=void 0;let n=document.createElement("span");n.className="status",this.status=n,r.input&&(r.input.addEventListener("blur",()=>{r.input.value!==""&&this.parse()}),r.input.addEventListener("input",()=>{n.style.display="none",r.input.classList.remove("reject")}))}isRejected(){return this.value===void 0}parse(e={}){if(this.ui.form){let r=this.ui.form.parse(e);return this.value=r,r}if(this.ui.input){let r=this.ui.input;try{let n=this.ui.parse(this.idl,e,r.value);if(!this.idl.covariant(n))throw new Error(`${r.value} is not of type ${this.idl.display()}`);return this.status.style.display="none",this.value=n,n}catch(n){r.classList.add("reject"),this.status.style.display="block",this.status.innerHTML="InputError: "+n.message,this.value=void 0;return}}return null}render(e){let r=document.createElement("span");if(this.label){let n=document.createElement("label");n.innerText=this.label,r.appendChild(n)}this.ui.input&&(r.appendChild(this.ui.input),r.appendChild(this.status)),this.ui.form&&this.ui.form.render(r),e.appendChild(r)}};Ot.InputBox=uu;var yn=class{constructor(e){this.ui=e,this.form=[]}renderForm(e){this.ui.container?(this.form.forEach(r=>r.render(this.ui.container)),e.appendChild(this.ui.container)):this.form.forEach(r=>r.render(e))}render(e){if(this.ui.open&&this.ui.event){e.appendChild(this.ui.open);let r=this;r.ui.open.addEventListener(r.ui.event,()=>{if(r.ui.container)r.ui.container.innerHTML="";else{let n=r.ui.open.nextElementSibling;n&&n.parentNode.removeChild(n)}r.generateForm(),r.renderForm(e)})}else this.generateForm(),this.renderForm(e)}};Ot.InputForm=yn;var lu=class extends yn{constructor(e,r){super(r),this.fields=e,this.ui=r}generateForm(){this.form=this.fields.map(([e,r])=>{let n=this.ui.render(r);return this.ui.labelMap&&this.ui.labelMap.hasOwnProperty(e)?n.label=this.ui.labelMap[e]+" ":n.label=e+" ",n})}parse(e){let r={};if(this.fields.forEach(([n,i],s)=>{let o=this.form[s].parse(e);r[n]=o}),!this.form.some(n=>n.isRejected()))return r}};Ot.RecordForm=lu;var fu=class extends yn{constructor(e,r){super(r),this.components=e,this.ui=r}generateForm(){this.form=this.components.map(e=>this.ui.render(e))}parse(e){let r=[];if(this.components.forEach((n,i)=>{let s=this.form[i].parse(e);r.push(s)}),!this.form.some(n=>n.isRejected()))return r}};Ot.TupleForm=fu;var du=class extends yn{constructor(e,r){super(r),this.fields=e,this.ui=r}generateForm(){let e=this.ui.open.selectedIndex,[r,n]=this.fields[e],i=this.ui.render(n);this.form=[i]}parse(e){let r=this.ui.open,n=r.options[r.selectedIndex].value,i=this.form[0].parse(e);if(i===void 0)return;let s={};return s[n]=i,s}};Ot.VariantForm=du;var hu=class extends yn{constructor(e,r){super(r),this.ty=e,this.ui=r}generateForm(){if(this.ui.open.checked){let e=this.ui.render(this.ty);this.form=[e]}else this.form=[]}parse(e){if(this.form.length===0)return[];{let r=this.form[0].parse(e);return r===void 0?void 0:[r]}}};Ot.OptionForm=hu;var pu=class extends yn{constructor(e,r){super(r),this.ty=e,this.ui=r}generateForm(){let e=+this.ui.open.value;this.form=[];for(let r=0;r<e;r++){let n=this.ui.render(this.ty);this.form.push(n)}}parse(e){let r=this.form.map(n=>n.parse(e));if(!this.form.some(n=>n.isRejected()))return r}};Ot.VecForm=pu});var Zd=ee(Ee=>{"use strict";var Km=Ee&&Ee.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Gm=Ee&&Ee.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Jd=Ee&&Ee.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Km(e,t,r);return Gm(e,t),e};Object.defineProperty(Ee,"__esModule",{value:!0});Ee.renderValue=Ee.renderInput=Ee.Render=Ee.vecForm=Ee.optForm=Ee.variantForm=Ee.tupleForm=Ee.recordForm=Ee.inputBox=void 0;var qo=Jd(cu()),_u=It(),wi=Jd(yu()),Ym={parse:Qm},os={render:wu},Wm=(t,e)=>new wi.InputBox(t,Object.assign(Object.assign({},Ym),e));Ee.inputBox=Wm;var zm=(t,e)=>new wi.RecordForm(t,Object.assign(Object.assign({},os),e));Ee.recordForm=zm;var Dm=(t,e)=>new wi.TupleForm(t,Object.assign(Object.assign({},os),e));Ee.tupleForm=Dm;var Jm=(t,e)=>new wi.VariantForm(t,Object.assign(Object.assign({},os),e));Ee.variantForm=Jm;var Zm=(t,e)=>new wi.OptionForm(t,Object.assign(Object.assign({},os),e));Ee.optForm=Zm;var Xm=(t,e)=>new wi.VecForm(t,Object.assign(Object.assign({},os),e));Ee.vecForm=Xm;var Mo=class extends qo.Visitor{visitType(e,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=e.display(),(0,Ee.inputBox)(e,{input:n})}visitNull(e,r){return(0,Ee.inputBox)(e,{})}visitRecord(e,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.recordForm)(r,i);return(0,Ee.inputBox)(e,{form:s})}visitTuple(e,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.tupleForm)(r,i);return(0,Ee.inputBox)(e,{form:s})}visitVariant(e,r,n){let i=document.createElement("select");for(let[a,c]of r){let f=new Option(a);i.add(f)}i.selectedIndex=-1,i.classList.add("open");let s={open:i,event:"change"},o=(0,Ee.variantForm)(r,s);return(0,Ee.inputBox)(e,{form:o})}visitOpt(e,r,n){let i=document.createElement("input");i.type="checkbox",i.classList.add("open");let s=(0,Ee.optForm)(r,{open:i,event:"change"});return(0,Ee.inputBox)(e,{form:s})}visitVec(e,r,n){let i=document.createElement("input");i.type="number",i.min="0",i.max="100",i.style.width="8rem",i.placeholder="len",i.classList.add("open");let s=document.createElement("div");s.classList.add("popup-form");let o=(0,Ee.vecForm)(r,{open:i,event:"change",container:s});return(0,Ee.inputBox)(e,{form:o})}visitRec(e,r,n){return wu(r)}};Ee.Render=Mo;var gu=class extends qo.Visitor{visitNull(e,r){return null}visitBool(e,r){if(r==="true")return!0;if(r==="false")return!1;throw new Error(`Cannot parse ${r} as boolean`)}visitText(e,r){return r}visitFloat(e,r){return parseFloat(r)}visitFixedInt(e,r){return e._bits<=32?parseInt(r,10):BigInt(r)}visitFixedNat(e,r){return e._bits<=32?parseInt(r,10):BigInt(r)}visitNumber(e,r){return BigInt(r)}visitPrincipal(e,r){return _u.Principal.fromText(r)}visitService(e,r){return _u.Principal.fromText(r)}visitFunc(e,r){let n=r.split(".",2);return[_u.Principal.fromText(n[0]),n[1]]}},mu=class extends qo.Visitor{visitNull(e,r){return null}visitBool(e,r){return Math.random()<.5}visitText(e,r){return Math.random().toString(36).substring(6)}visitFloat(e,r){return Math.random()}visitInt(e,r){return BigInt(this.generateNumber(!0))}visitNat(e,r){return BigInt(this.generateNumber(!1))}visitFixedInt(e,r){let n=this.generateNumber(!0);return e._bits<=32?n:BigInt(r)}visitFixedNat(e,r){let n=this.generateNumber(!1);return e._bits<=32?n:BigInt(r)}generateNumber(e){let r=Math.floor(Math.random()*100);return e&&Math.random()<.5?-r:r}};function Qm(t,e,r){return e.random&&r===""?t.accept(new mu,r):t.accept(new gu,r)}function wu(t){return t.accept(new Mo,null)}Ee.renderInput=wu;function Vn(t,e,r){return t.accept(new bu,{input:e,value:r})}Ee.renderValue=Vn;var bu=class extends qo.Visitor{visitType(e,r){r.input.ui.input.value=e.valueToString(r.value)}visitNull(e,r){}visitText(e,r){r.input.ui.input.value=r.value}visitRec(e,r,n){Vn(r,n.input,n.value)}visitOpt(e,r,n){if(n.value.length!==0){let i=n.input.ui.form,s=i.ui.open;s.checked=!0,s.dispatchEvent(new Event(i.ui.event)),Vn(r,i.form[0],n.value[0])}}visitRecord(e,r,n){let i=n.input.ui.form;r.forEach(([s,o],a)=>{Vn(o,i.form[a],n.value[s])})}visitTuple(e,r,n){let i=n.input.ui.form;r.forEach((s,o)=>{Vn(s,i.form[o],n.value[o])})}visitVariant(e,r,n){let i=n.input.ui.form,s=Object.entries(n.value)[0];r.forEach(([o,a],c)=>{if(o===s[0]){let f=i.ui.open;f.selectedIndex=c,f.dispatchEvent(new Event(i.ui.event)),Vn(a,i.form[0],s[1])}})}visitVec(e,r,n){let i=n.input.ui.form,s=n.value.length,o=i.ui.open;o.value=s,o.dispatchEvent(new Event(i.ui.event)),n.value.forEach((a,c)=>{Vn(r,i.form[c],a)})}}});var Qd=ee(Xd=>{"use strict";Object.defineProperty(Xd,"__esModule",{value:!0})});var xi=ee(ht=>{"use strict";var Ld=ht&&ht.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Lm=ht&&ht.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ei=ht&&ht.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Ld(e,t,r)},eb=ht&&ht.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Ld(e,t,r);return Lm(e,t),e};Object.defineProperty(ht,"__esModule",{value:!0});ht.IDL=void 0;Ei(Zd(),ht);Ei(yu(),ht);ht.IDL=eb(cu());Ei(tu(),ht);Ei(nu(),ht);Ei(wo(),ht);Ei(Qd(),ht)});var as=ee((e0,jo)=>{(function(t){"use strict";var e,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",a=1e14,c=14,f=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],h=1e7,g=1e9;function b(E){var k,G,z,q=F.prototype={constructor:F,toString:null,valueOf:null},oe=new F(1),Q=20,ie=4,w=-7,m=21,R=-1e7,S=1e7,B=!1,V=1,J=0,ae={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},ce="0123456789abcdefghijklmnopqrstuvwxyz",D=!0;function F(u,y){var _,U,T,P,H,x,C,$,j=this;if(!(j instanceof F))return new F(u,y);if(y==null){if(u&&u._isBigNumber===!0){j.s=u.s,!u.c||u.e>S?j.c=j.e=null:u.e<R?j.c=[j.e=0]:(j.e=u.e,j.c=u.c.slice());return}if((x=typeof u=="number")&&u*0==0){if(j.s=1/u<0?(u=-u,-1):1,u===~~u){for(P=0,H=u;H>=10;H/=10,P++);P>S?j.c=j.e=null:(j.e=P,j.c=[u]);return}$=String(u)}else{if(!r.test($=String(u)))return z(j,$,x);j.s=$.charCodeAt(0)==45?($=$.slice(1),-1):1}(P=$.indexOf("."))>-1&&($=$.replace(".","")),(H=$.search(/e/i))>0?(P<0&&(P=H),P+=+$.slice(H+1),$=$.substring(0,H)):P<0&&(P=$.length)}else{if(I(y,2,ce.length,"Base"),y==10&&D)return j=new F(u),le(j,Q+j.e+1,ie);if($=String(u),x=typeof u=="number"){if(u*0!=0)return z(j,$,x,y);if(j.s=1/u<0?($=$.slice(1),-1):1,F.DEBUG&&$.replace(/^0\.0*|\./,"").length>15)throw Error(o+u)}else j.s=$.charCodeAt(0)===45?($=$.slice(1),-1):1;for(_=ce.slice(0,y),P=H=0,C=$.length;H<C;H++)if(_.indexOf(U=$.charAt(H))<0){if(U=="."){if(H>P){P=C;continue}}else if(!T&&($==$.toUpperCase()&&($=$.toLowerCase())||$==$.toLowerCase()&&($=$.toUpperCase()))){T=!0,H=-1,P=0;continue}return z(j,String(u),x,y)}x=!1,$=G($,y,10,j.s),(P=$.indexOf("."))>-1?$=$.replace(".",""):P=$.length}for(H=0;$.charCodeAt(H)===48;H++);for(C=$.length;$.charCodeAt(--C)===48;);if($=$.slice(H,++C)){if(C-=H,x&&F.DEBUG&&C>15&&(u>f||u!==i(u)))throw Error(o+j.s*u);if((P=P-H-1)>S)j.c=j.e=null;else if(P<R)j.c=[j.e=0];else{if(j.e=P,j.c=[],H=(P+1)%c,P<0&&(H+=c),H<C){for(H&&j.c.push(+$.slice(0,H)),C-=c;H<C;)j.c.push(+$.slice(H,H+=c));H=c-($=$.slice(H)).length}else H-=C;for(;H--;$+="0");j.c.push(+$)}}else j.c=[j.e=0]}F.clone=b,F.ROUND_UP=0,F.ROUND_DOWN=1,F.ROUND_CEIL=2,F.ROUND_FLOOR=3,F.ROUND_HALF_UP=4,F.ROUND_HALF_DOWN=5,F.ROUND_HALF_EVEN=6,F.ROUND_HALF_CEIL=7,F.ROUND_HALF_FLOOR=8,F.EUCLID=9,F.config=F.set=function(u){var y,_;if(u!=null)if(typeof u=="object"){if(u.hasOwnProperty(y="DECIMAL_PLACES")&&(_=u[y],I(_,0,g,y),Q=_),u.hasOwnProperty(y="ROUNDING_MODE")&&(_=u[y],I(_,0,8,y),ie=_),u.hasOwnProperty(y="EXPONENTIAL_AT")&&(_=u[y],_&&_.pop?(I(_[0],-g,0,y),I(_[1],0,g,y),w=_[0],m=_[1]):(I(_,-g,g,y),w=-(m=_<0?-_:_))),u.hasOwnProperty(y="RANGE"))if(_=u[y],_&&_.pop)I(_[0],-g,-1,y),I(_[1],1,g,y),R=_[0],S=_[1];else if(I(_,-g,g,y),_)R=-(S=_<0?-_:_);else throw Error(s+y+" cannot be zero: "+_);if(u.hasOwnProperty(y="CRYPTO"))if(_=u[y],_===!!_)if(_)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))B=_;else throw B=!_,Error(s+"crypto unavailable");else B=_;else throw Error(s+y+" not true or false: "+_);if(u.hasOwnProperty(y="MODULO_MODE")&&(_=u[y],I(_,0,9,y),V=_),u.hasOwnProperty(y="POW_PRECISION")&&(_=u[y],I(_,0,g,y),J=_),u.hasOwnProperty(y="FORMAT"))if(_=u[y],typeof _=="object")ae=_;else throw Error(s+y+" not an object: "+_);if(u.hasOwnProperty(y="ALPHABET"))if(_=u[y],typeof _=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(_))D=_.slice(0,10)=="0123456789",ce=_;else throw Error(s+y+" invalid: "+_)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:Q,ROUNDING_MODE:ie,EXPONENTIAL_AT:[w,m],RANGE:[R,S],CRYPTO:B,MODULO_MODE:V,POW_PRECISION:J,FORMAT:ae,ALPHABET:ce}},F.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!F.DEBUG)return!0;var y,_,U=u.c,T=u.e,P=u.s;e:if({}.toString.call(U)=="[object Array]"){if((P===1||P===-1)&&T>=-g&&T<=g&&T===i(T)){if(U[0]===0){if(T===0&&U.length===1)return!0;break e}if(y=(T+1)%c,y<1&&(y+=c),String(U[0]).length==y){for(y=0;y<U.length;y++)if(_=U[y],_<0||_>=a||_!==i(_))break e;if(_!==0)return!0}}}else if(U===null&&T===null&&(P===null||P===1||P===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},F.maximum=F.max=function(){return L(arguments,-1)},F.minimum=F.min=function(){return L(arguments,1)},F.random=function(){var u=9007199254740992,y=Math.random()*u&2097151?function(){return i(Math.random()*u)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(_){var U,T,P,H,x,C=0,$=[],j=new F(oe);if(_==null?_=Q:I(_,0,g),H=n(_/c),B)if(crypto.getRandomValues){for(U=crypto.getRandomValues(new Uint32Array(H*=2));C<H;)x=U[C]*131072+(U[C+1]>>>11),x>=9e15?(T=crypto.getRandomValues(new Uint32Array(2)),U[C]=T[0],U[C+1]=T[1]):($.push(x%1e14),C+=2);C=H/2}else if(crypto.randomBytes){for(U=crypto.randomBytes(H*=7);C<H;)x=(U[C]&31)*281474976710656+U[C+1]*1099511627776+U[C+2]*4294967296+U[C+3]*16777216+(U[C+4]<<16)+(U[C+5]<<8)+U[C+6],x>=9e15?crypto.randomBytes(7).copy(U,C):($.push(x%1e14),C+=7);C=H/7}else throw B=!1,Error(s+"crypto unavailable");if(!B)for(;C<H;)x=y(),x<9e15&&($[C++]=x%1e14);for(H=$[--C],_%=c,H&&_&&(x=d[c-_],$[C]=i(H/x)*x);$[C]===0;$.pop(),C--);if(C<0)$=[P=0];else{for(P=-1;$[0]===0;$.splice(0,1),P-=c);for(C=1,x=$[0];x>=10;x/=10,C++);C<c&&(P-=c-C)}return j.e=P,j.c=$,j}}(),F.sum=function(){for(var u=1,y=arguments,_=new F(y[0]);u<y.length;)_=_.plus(y[u++]);return _},G=function(){var u="0123456789";function y(_,U,T,P){for(var H,x=[0],C,$=0,j=_.length;$<j;){for(C=x.length;C--;x[C]*=U);for(x[0]+=P.indexOf(_.charAt($++)),H=0;H<x.length;H++)x[H]>T-1&&(x[H+1]==null&&(x[H+1]=0),x[H+1]+=x[H]/T|0,x[H]%=T)}return x.reverse()}return function(_,U,T,P,H){var x,C,$,j,Z,te,fe,me,Re=_.indexOf("."),Me=Q,ye=ie;for(Re>=0&&(j=J,J=0,_=_.replace(".",""),me=new F(U),te=me.pow(_.length-Re),J=j,me.c=y(K(N(te.c),te.e,"0"),10,T,u),me.e=me.c.length),fe=y(_,U,T,H?(x=ce,u):(x=u,ce)),$=j=fe.length;fe[--j]==0;fe.pop());if(!fe[0])return x.charAt(0);if(Re<0?--$:(te.c=fe,te.e=$,te.s=P,te=k(te,me,Me,ye,T),fe=te.c,Z=te.r,$=te.e),C=$+Me+1,Re=fe[C],j=T/2,Z=Z||C<0||fe[C+1]!=null,Z=ye<4?(Re!=null||Z)&&(ye==0||ye==(te.s<0?3:2)):Re>j||Re==j&&(ye==4||Z||ye==6&&fe[C-1]&1||ye==(te.s<0?8:7)),C<1||!fe[0])_=Z?K(x.charAt(1),-Me,x.charAt(0)):x.charAt(0);else{if(fe.length=C,Z)for(--T;++fe[--C]>T;)fe[C]=0,C||(++$,fe=[1].concat(fe));for(j=fe.length;!fe[--j];);for(Re=0,_="";Re<=j;_+=x.charAt(fe[Re++]));_=K(_,$,x.charAt(0))}return _}}(),k=function(){function u(U,T,P){var H,x,C,$,j=0,Z=U.length,te=T%h,fe=T/h|0;for(U=U.slice();Z--;)C=U[Z]%h,$=U[Z]/h|0,H=fe*C+$*te,x=te*C+H%h*h+j,j=(x/P|0)+(H/h|0)+fe*$,U[Z]=x%P;return j&&(U=[j].concat(U)),U}function y(U,T,P,H){var x,C;if(P!=H)C=P>H?1:-1;else for(x=C=0;x<P;x++)if(U[x]!=T[x]){C=U[x]>T[x]?1:-1;break}return C}function _(U,T,P,H){for(var x=0;P--;)U[P]-=x,x=U[P]<T[P]?1:0,U[P]=x*H+U[P]-T[P];for(;!U[0]&&U.length>1;U.splice(0,1));}return function(U,T,P,H,x){var C,$,j,Z,te,fe,me,Re,Me,ye,he,Ze,Tr,Dr,Jr,kt,Be,Tt=U.s==T.s?1:-1,st=U.c,$e=T.c;if(!st||!st[0]||!$e||!$e[0])return new F(!U.s||!T.s||(st?$e&&st[0]==$e[0]:!$e)?NaN:st&&st[0]==0||!$e?Tt*0:Tt/0);for(Re=new F(Tt),Me=Re.c=[],$=U.e-T.e,Tt=P+$+1,x||(x=a,$=l(U.e/c)-l(T.e/c),Tt=Tt/c|0),j=0;$e[j]==(st[j]||0);j++);if($e[j]>(st[j]||0)&&$--,Tt<0)Me.push(1),Z=!0;else{for(Dr=st.length,kt=$e.length,j=0,Tt+=2,te=i(x/($e[0]+1)),te>1&&($e=u($e,te,x),st=u(st,te,x),kt=$e.length,Dr=st.length),Tr=kt,ye=st.slice(0,kt),he=ye.length;he<kt;ye[he++]=0);Be=$e.slice(),Be=[0].concat(Be),Jr=$e[0],$e[1]>=x/2&&Jr++;do{if(te=0,C=y($e,ye,kt,he),C<0){if(Ze=ye[0],kt!=he&&(Ze=Ze*x+(ye[1]||0)),te=i(Ze/Jr),te>1)for(te>=x&&(te=x-1),fe=u($e,te,x),me=fe.length,he=ye.length;y(fe,ye,me,he)==1;)te--,_(fe,kt<me?Be:$e,me,x),me=fe.length,C=1;else te==0&&(C=te=1),fe=$e.slice(),me=fe.length;if(me<he&&(fe=[0].concat(fe)),_(ye,fe,he,x),he=ye.length,C==-1)for(;y($e,ye,kt,he)<1;)te++,_(ye,kt<he?Be:$e,he,x),he=ye.length}else C===0&&(te++,ye=[0]);Me[j++]=te,ye[0]?ye[he++]=st[Tr]||0:(ye=[st[Tr]],he=1)}while((Tr++<Dr||ye[0]!=null)&&Tt--);Z=ye[0]!=null,Me[0]||Me.splice(0,1)}if(x==a){for(j=1,Tt=Me[0];Tt>=10;Tt/=10,j++);le(Re,P+(Re.e=j+$*c-1)+1,H,Z)}else Re.e=$,Re.r=+Z;return Re}}();function p(u,y,_,U){var T,P,H,x,C;if(_==null?_=ie:I(_,0,8),!u.c)return u.toString();if(T=u.c[0],H=u.e,y==null)C=N(u.c),C=U==1||U==2&&(H<=w||H>=m)?A(C,H):K(C,H,"0");else if(u=le(new F(u),y,_),P=u.e,C=N(u.c),x=C.length,U==1||U==2&&(y<=P||P<=w)){for(;x<y;C+="0",x++);C=A(C,P)}else if(y-=H,C=K(C,P,"0"),P+1>x){if(--y>0)for(C+=".";y--;C+="0");}else if(y+=P-x,y>0)for(P+1==x&&(C+=".");y--;C+="0");return u.s<0&&T?"-"+C:C}function L(u,y){for(var _,U,T=1,P=new F(u[0]);T<u.length;T++)U=new F(u[T]),(!U.s||(_=O(P,U))===y||_===0&&P.s===y)&&(P=U);return P}function re(u,y,_){for(var U=1,T=y.length;!y[--T];y.pop());for(T=y[0];T>=10;T/=10,U++);return(_=U+_*c-1)>S?u.c=u.e=null:_<R?u.c=[u.e=0]:(u.e=_,u.c=y),u}z=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,y=/^([^.]+)\.$/,_=/^\.([^.]+)$/,U=/^-?(Infinity|NaN)$/,T=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(P,H,x,C){var $,j=x?H:H.replace(T,"");if(U.test(j))P.s=isNaN(j)?null:j<0?-1:1;else{if(!x&&(j=j.replace(u,function(Z,te,fe){return $=(fe=fe.toLowerCase())=="x"?16:fe=="b"?2:8,!C||C==$?te:Z}),C&&($=C,j=j.replace(y,"$1").replace(_,"0.$1")),H!=j))return new F(j,$);if(F.DEBUG)throw Error(s+"Not a"+(C?" base "+C:"")+" number: "+H);P.s=null}P.c=P.e=null}}();function le(u,y,_,U){var T,P,H,x,C,$,j,Z=u.c,te=d;if(Z){e:{for(T=1,x=Z[0];x>=10;x/=10,T++);if(P=y-T,P<0)P+=c,H=y,C=Z[$=0],j=i(C/te[T-H-1]%10);else if($=n((P+1)/c),$>=Z.length)if(U){for(;Z.length<=$;Z.push(0));C=j=0,T=1,P%=c,H=P-c+1}else break e;else{for(C=x=Z[$],T=1;x>=10;x/=10,T++);P%=c,H=P-c+T,j=H<0?0:i(C/te[T-H-1]%10)}if(U=U||y<0||Z[$+1]!=null||(H<0?C:C%te[T-H-1]),U=_<4?(j||U)&&(_==0||_==(u.s<0?3:2)):j>5||j==5&&(_==4||U||_==6&&(P>0?H>0?C/te[T-H]:0:Z[$-1])%10&1||_==(u.s<0?8:7)),y<1||!Z[0])return Z.length=0,U?(y-=u.e+1,Z[0]=te[(c-y%c)%c],u.e=-y||0):Z[0]=u.e=0,u;if(P==0?(Z.length=$,x=1,$--):(Z.length=$+1,x=te[c-P],Z[$]=H>0?i(C/te[T-H]%te[H])*x:0),U)for(;;)if($==0){for(P=1,H=Z[0];H>=10;H/=10,P++);for(H=Z[0]+=x,x=1;H>=10;H/=10,x++);P!=x&&(u.e++,Z[0]==a&&(Z[0]=1));break}else{if(Z[$]+=x,Z[$]!=a)break;Z[$--]=0,x=1}for(P=Z.length;Z[--P]===0;Z.pop());}u.e>S?u.c=u.e=null:u.e<R&&(u.c=[u.e=0])}return u}function X(u){var y,_=u.e;return _===null?u.toString():(y=N(u.c),y=_<=w||_>=m?A(y,_):K(y,_,"0"),u.s<0?"-"+y:y)}return q.absoluteValue=q.abs=function(){var u=new F(this);return u.s<0&&(u.s=1),u},q.comparedTo=function(u,y){return O(this,new F(u,y))},q.decimalPlaces=q.dp=function(u,y){var _,U,T,P=this;if(u!=null)return I(u,0,g),y==null?y=ie:I(y,0,8),le(new F(P),u+P.e+1,y);if(!(_=P.c))return null;if(U=((T=_.length-1)-l(this.e/c))*c,T=_[T])for(;T%10==0;T/=10,U--);return U<0&&(U=0),U},q.dividedBy=q.div=function(u,y){return k(this,new F(u,y),Q,ie)},q.dividedToIntegerBy=q.idiv=function(u,y){return k(this,new F(u,y),0,1)},q.exponentiatedBy=q.pow=function(u,y){var _,U,T,P,H,x,C,$,j,Z=this;if(u=new F(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+X(u));if(y!=null&&(y=new F(y)),x=u.e>14,!Z.c||!Z.c[0]||Z.c[0]==1&&!Z.e&&Z.c.length==1||!u.c||!u.c[0])return j=new F(Math.pow(+X(Z),x?u.s*(2-M(u)):+X(u))),y?j.mod(y):j;if(C=u.s<0,y){if(y.c?!y.c[0]:!y.s)return new F(NaN);U=!C&&Z.isInteger()&&y.isInteger(),U&&(Z=Z.mod(y))}else{if(u.e>9&&(Z.e>0||Z.e<-1||(Z.e==0?Z.c[0]>1||x&&Z.c[1]>=24e7:Z.c[0]<8e13||x&&Z.c[0]<=9999975e7)))return P=Z.s<0&&M(u)?-0:0,Z.e>-1&&(P=1/P),new F(C?1/P:P);J&&(P=n(J/c+2))}for(x?(_=new F(.5),C&&(u.s=1),$=M(u)):(T=Math.abs(+X(u)),$=T%2),j=new F(oe);;){if($){if(j=j.times(Z),!j.c)break;P?j.c.length>P&&(j.c.length=P):U&&(j=j.mod(y))}if(T){if(T=i(T/2),T===0)break;$=T%2}else if(u=u.times(_),le(u,u.e+1,1),u.e>14)$=M(u);else{if(T=+X(u),T===0)break;$=T%2}Z=Z.times(Z),P?Z.c&&Z.c.length>P&&(Z.c.length=P):U&&(Z=Z.mod(y))}return U?j:(C&&(j=oe.div(j)),y?j.mod(y):P?le(j,J,ie,H):j)},q.integerValue=function(u){var y=new F(this);return u==null?u=ie:I(u,0,8),le(y,y.e+1,u)},q.isEqualTo=q.eq=function(u,y){return O(this,new F(u,y))===0},q.isFinite=function(){return!!this.c},q.isGreaterThan=q.gt=function(u,y){return O(this,new F(u,y))>0},q.isGreaterThanOrEqualTo=q.gte=function(u,y){return(y=O(this,new F(u,y)))===1||y===0},q.isInteger=function(){return!!this.c&&l(this.e/c)>this.c.length-2},q.isLessThan=q.lt=function(u,y){return O(this,new F(u,y))<0},q.isLessThanOrEqualTo=q.lte=function(u,y){return(y=O(this,new F(u,y)))===-1||y===0},q.isNaN=function(){return!this.s},q.isNegative=function(){return this.s<0},q.isPositive=function(){return this.s>0},q.isZero=function(){return!!this.c&&this.c[0]==0},q.minus=function(u,y){var _,U,T,P,H=this,x=H.s;if(u=new F(u,y),y=u.s,!x||!y)return new F(NaN);if(x!=y)return u.s=-y,H.plus(u);var C=H.e/c,$=u.e/c,j=H.c,Z=u.c;if(!C||!$){if(!j||!Z)return j?(u.s=-y,u):new F(Z?H:NaN);if(!j[0]||!Z[0])return Z[0]?(u.s=-y,u):new F(j[0]?H:ie==3?-0:0)}if(C=l(C),$=l($),j=j.slice(),x=C-$){for((P=x<0)?(x=-x,T=j):($=C,T=Z),T.reverse(),y=x;y--;T.push(0));T.reverse()}else for(U=(P=(x=j.length)<(y=Z.length))?x:y,x=y=0;y<U;y++)if(j[y]!=Z[y]){P=j[y]<Z[y];break}if(P&&(T=j,j=Z,Z=T,u.s=-u.s),y=(U=Z.length)-(_=j.length),y>0)for(;y--;j[_++]=0);for(y=a-1;U>x;){if(j[--U]<Z[U]){for(_=U;_&&!j[--_];j[_]=y);--j[_],j[U]+=a}j[U]-=Z[U]}for(;j[0]==0;j.splice(0,1),--$);return j[0]?re(u,j,$):(u.s=ie==3?-1:1,u.c=[u.e=0],u)},q.modulo=q.mod=function(u,y){var _,U,T=this;return u=new F(u,y),!T.c||!u.s||u.c&&!u.c[0]?new F(NaN):!u.c||T.c&&!T.c[0]?new F(T):(V==9?(U=u.s,u.s=1,_=k(T,u,0,3),u.s=U,_.s*=U):_=k(T,u,0,V),u=T.minus(_.times(u)),!u.c[0]&&V==1&&(u.s=T.s),u)},q.multipliedBy=q.times=function(u,y){var _,U,T,P,H,x,C,$,j,Z,te,fe,me,Re,Me,ye=this,he=ye.c,Ze=(u=new F(u,y)).c;if(!he||!Ze||!he[0]||!Ze[0])return!ye.s||!u.s||he&&!he[0]&&!Ze||Ze&&!Ze[0]&&!he?u.c=u.e=u.s=null:(u.s*=ye.s,!he||!Ze?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(U=l(ye.e/c)+l(u.e/c),u.s*=ye.s,C=he.length,Z=Ze.length,C<Z&&(me=he,he=Ze,Ze=me,T=C,C=Z,Z=T),T=C+Z,me=[];T--;me.push(0));for(Re=a,Me=h,T=Z;--T>=0;){for(_=0,te=Ze[T]%Me,fe=Ze[T]/Me|0,H=C,P=T+H;P>T;)$=he[--H]%Me,j=he[H]/Me|0,x=fe*$+j*te,$=te*$+x%Me*Me+me[P]+_,_=($/Re|0)+(x/Me|0)+fe*j,me[P--]=$%Re;me[P]=_}return _?++U:me.splice(0,1),re(u,me,U)},q.negated=function(){var u=new F(this);return u.s=-u.s||null,u},q.plus=function(u,y){var _,U=this,T=U.s;if(u=new F(u,y),y=u.s,!T||!y)return new F(NaN);if(T!=y)return u.s=-y,U.minus(u);var P=U.e/c,H=u.e/c,x=U.c,C=u.c;if(!P||!H){if(!x||!C)return new F(T/0);if(!x[0]||!C[0])return C[0]?u:new F(x[0]?U:T*0)}if(P=l(P),H=l(H),x=x.slice(),T=P-H){for(T>0?(H=P,_=C):(T=-T,_=x),_.reverse();T--;_.push(0));_.reverse()}for(T=x.length,y=C.length,T-y<0&&(_=C,C=x,x=_,y=T),T=0;y;)T=(x[--y]=x[y]+C[y]+T)/a|0,x[y]=a===x[y]?0:x[y]%a;return T&&(x=[T].concat(x),++H),re(u,x,H)},q.precision=q.sd=function(u,y){var _,U,T,P=this;if(u!=null&&u!==!!u)return I(u,1,g),y==null?y=ie:I(y,0,8),le(new F(P),u,y);if(!(_=P.c))return null;if(T=_.length-1,U=T*c+1,T=_[T]){for(;T%10==0;T/=10,U--);for(T=_[0];T>=10;T/=10,U++);}return u&&P.e+1>U&&(U=P.e+1),U},q.shiftedBy=function(u){return I(u,-f,f),this.times("1e"+u)},q.squareRoot=q.sqrt=function(){var u,y,_,U,T,P=this,H=P.c,x=P.s,C=P.e,$=Q+4,j=new F("0.5");if(x!==1||!H||!H[0])return new F(!x||x<0&&(!H||H[0])?NaN:H?P:1/0);if(x=Math.sqrt(+X(P)),x==0||x==1/0?(y=N(H),(y.length+C)%2==0&&(y+="0"),x=Math.sqrt(+y),C=l((C+1)/2)-(C<0||C%2),x==1/0?y="5e"+C:(y=x.toExponential(),y=y.slice(0,y.indexOf("e")+1)+C),_=new F(y)):_=new F(x+""),_.c[0]){for(C=_.e,x=C+$,x<3&&(x=0);;)if(T=_,_=j.times(T.plus(k(P,T,$,1))),N(T.c).slice(0,x)===(y=N(_.c)).slice(0,x))if(_.e<C&&--x,y=y.slice(x-3,x+1),y=="9999"||!U&&y=="4999"){if(!U&&(le(T,T.e+Q+2,0),T.times(T).eq(P))){_=T;break}$+=4,x+=4,U=1}else{(!+y||!+y.slice(1)&&y.charAt(0)=="5")&&(le(_,_.e+Q+2,1),u=!_.times(_).eq(P));break}}return le(_,_.e+Q+1,ie,u)},q.toExponential=function(u,y){return u!=null&&(I(u,0,g),u++),p(this,u,y,1)},q.toFixed=function(u,y){return u!=null&&(I(u,0,g),u=u+this.e+1),p(this,u,y)},q.toFormat=function(u,y,_){var U,T=this;if(_==null)u!=null&&y&&typeof y=="object"?(_=y,y=null):u&&typeof u=="object"?(_=u,u=y=null):_=ae;else if(typeof _!="object")throw Error(s+"Argument not an object: "+_);if(U=T.toFixed(u,y),T.c){var P,H=U.split("."),x=+_.groupSize,C=+_.secondaryGroupSize,$=_.groupSeparator||"",j=H[0],Z=H[1],te=T.s<0,fe=te?j.slice(1):j,me=fe.length;if(C&&(P=x,x=C,C=P,me-=P),x>0&&me>0){for(P=me%x||x,j=fe.substr(0,P);P<me;P+=x)j+=$+fe.substr(P,x);C>0&&(j+=$+fe.slice(P)),te&&(j="-"+j)}U=Z?j+(_.decimalSeparator||"")+((C=+_.fractionGroupSize)?Z.replace(new RegExp("\\d{"+C+"}\\B","g"),"$&"+(_.fractionGroupSeparator||"")):Z):j}return(_.prefix||"")+U+(_.suffix||"")},q.toFraction=function(u){var y,_,U,T,P,H,x,C,$,j,Z,te,fe=this,me=fe.c;if(u!=null&&(x=new F(u),!x.isInteger()&&(x.c||x.s!==1)||x.lt(oe)))throw Error(s+"Argument "+(x.isInteger()?"out of range: ":"not an integer: ")+X(x));if(!me)return new F(fe);for(y=new F(oe),$=_=new F(oe),U=C=new F(oe),te=N(me),P=y.e=te.length-fe.e-1,y.c[0]=d[(H=P%c)<0?c+H:H],u=!u||x.comparedTo(y)>0?P>0?y:$:x,H=S,S=1/0,x=new F(te),C.c[0]=0;j=k(x,y,0,1),T=_.plus(j.times(U)),T.comparedTo(u)!=1;)_=U,U=T,$=C.plus(j.times(T=$)),C=T,y=x.minus(j.times(T=y)),x=T;return T=k(u.minus(_),U,0,1),C=C.plus(T.times($)),_=_.plus(T.times(U)),C.s=$.s=fe.s,P=P*2,Z=k($,U,P,ie).minus(fe).abs().comparedTo(k(C,_,P,ie).minus(fe).abs())<1?[$,U]:[C,_],S=H,Z},q.toNumber=function(){return+X(this)},q.toPrecision=function(u,y){return u!=null&&I(u,1,g),p(this,u,y,2)},q.toString=function(u){var y,_=this,U=_.s,T=_.e;return T===null?U?(y="Infinity",U<0&&(y="-"+y)):y="NaN":(u==null?y=T<=w||T>=m?A(N(_.c),T):K(N(_.c),T,"0"):u===10&&D?(_=le(new F(_),Q+T+1,ie),y=K(N(_.c),_.e,"0")):(I(u,2,ce.length,"Base"),y=G(K(N(_.c),T,"0"),10,u,U,!0)),U<0&&_.c[0]&&(y="-"+y)),y},q.valueOf=q.toJSON=function(){return X(this)},q._isBigNumber=!0,E!=null&&F.set(E),F}function l(E){var k=E|0;return E>0||E===k?k:k-1}function N(E){for(var k,G,z=1,q=E.length,oe=E[0]+"";z<q;){for(k=E[z++]+"",G=c-k.length;G--;k="0"+k);oe+=k}for(q=oe.length;oe.charCodeAt(--q)===48;);return oe.slice(0,q+1||1)}function O(E,k){var G,z,q=E.c,oe=k.c,Q=E.s,ie=k.s,w=E.e,m=k.e;if(!Q||!ie)return null;if(G=q&&!q[0],z=oe&&!oe[0],G||z)return G?z?0:-ie:Q;if(Q!=ie)return Q;if(G=Q<0,z=w==m,!q||!oe)return z?0:!q^G?1:-1;if(!z)return w>m^G?1:-1;for(ie=(w=q.length)<(m=oe.length)?w:m,Q=0;Q<ie;Q++)if(q[Q]!=oe[Q])return q[Q]>oe[Q]^G?1:-1;return w==m?0:w>m^G?1:-1}function I(E,k,G,z){if(E<k||E>G||E!==i(E))throw Error(s+(z||"Argument")+(typeof E=="number"?E<k||E>G?" out of range: ":" not an integer: ":" not a primitive number: ")+String(E))}function M(E){var k=E.c.length-1;return l(E.e/c)==k&&E.c[k]%2!=0}function A(E,k){return(E.length>1?E.charAt(0)+"."+E.slice(1):E)+(k<0?"e":"e+")+k}function K(E,k,G){var z,q;if(k<0){for(q=G+".";++k;q+=G);E=q+E}else if(z=E.length,++k>z){for(q=G,k-=z;--k;q+=G);E+=q}else k<z&&(E=E.slice(0,k)+"."+E.slice(k));return E}e=b(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof jo<"u"&&jo.exports?jo.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(e0)});var r0=ee((hv,t0)=>{t0.exports=function(e,r,n){var i=new e.Uint8Array(n),s=r.pushInt,o=r.pushInt32,a=r.pushInt32Neg,c=r.pushInt64,f=r.pushInt64Neg,d=r.pushFloat,h=r.pushFloatSingle,g=r.pushFloatDouble,b=r.pushTrue,l=r.pushFalse,N=r.pushUndefined,O=r.pushNull,I=r.pushInfinity,M=r.pushInfinityNeg,A=r.pushNaN,K=r.pushNaNNeg,E=r.pushArrayStart,k=r.pushArrayStartFixed,G=r.pushArrayStartFixed32,z=r.pushArrayStartFixed64,q=r.pushObjectStart,oe=r.pushObjectStartFixed,Q=r.pushObjectStartFixed32,ie=r.pushObjectStartFixed64,w=r.pushByteString,m=r.pushByteStringStart,R=r.pushUtf8String,S=r.pushUtf8StringStart,B=r.pushSimpleUnassigned,V=r.pushTagStart,J=r.pushTagStart4,ae=r.pushTagStart8,ce=r.pushTagUnassigned,D=r.pushBreak,F=e.Math.pow,p=0,L=0,re=0;function le(v){for(v=v|0,p=0,L=v;(p|0)<(L|0)&&(re=X_[i[p]&255](i[p]|0)|0,!((re|0)>0)););return re|0}function X(v){return v=v|0,((p|0)+(v|0)|0)<(L|0)?0:1}function u(v){return v=v|0,i[v|0]<<8|i[v+1|0]|0}function y(v){return v=v|0,i[v|0]<<24|i[v+1|0]<<16|i[v+2|0]<<8|i[v+3|0]|0}function _(v){return v=v|0,s(v|0),p=p+1|0,0}function U(v){return v=v|0,X(1)|0?1:(s(i[p+1|0]|0),p=p+2|0,0)}function T(v){return v=v|0,X(2)|0?1:(s(u(p+1|0)|0),p=p+3|0,0)}function P(v){return v=v|0,X(4)|0?1:(o(u(p+1|0)|0,u(p+3|0)|0),p=p+5|0,0)}function H(v){return v=v|0,X(8)|0?1:(c(u(p+1|0)|0,u(p+3|0)|0,u(p+5|0)|0,u(p+7|0)|0),p=p+9|0,0)}function x(v){return v=v|0,s(-1-(v-32|0)|0),p=p+1|0,0}function C(v){return v=v|0,X(1)|0?1:(s(-1-(i[p+1|0]|0)|0),p=p+2|0,0)}function $(v){v=v|0;var Ae=0;return X(2)|0?1:(Ae=u(p+1|0)|0,s(-1-(Ae|0)|0),p=p+3|0,0)}function j(v){return v=v|0,X(4)|0?1:(a(u(p+1|0)|0,u(p+3|0)|0),p=p+5|0,0)}function Z(v){return v=v|0,X(8)|0?1:(f(u(p+1|0)|0,u(p+3|0)|0,u(p+5|0)|0,u(p+7|0)|0),p=p+9|0,0)}function te(v){v=v|0;var Ae=0,Ne=0,xe=0;return xe=v-64|0,X(xe|0)|0?1:(Ae=p+1|0,Ne=(p+1|0)+(xe|0)|0,w(Ae|0,Ne|0),p=Ne|0,0)}function fe(v){v=v|0;var Ae=0,Ne=0,xe=0;return X(1)|0||(xe=i[p+1|0]|0,Ae=p+2|0,Ne=(p+2|0)+(xe|0)|0,X(xe+1|0)|0)?1:(w(Ae|0,Ne|0),p=Ne|0,0)}function me(v){v=v|0;var Ae=0,Ne=0,xe=0;return X(2)|0||(xe=u(p+1|0)|0,Ae=p+3|0,Ne=(p+3|0)+(xe|0)|0,X(xe+2|0)|0)?1:(w(Ae|0,Ne|0),p=Ne|0,0)}function Re(v){v=v|0;var Ae=0,Ne=0,xe=0;return X(4)|0||(xe=y(p+1|0)|0,Ae=p+5|0,Ne=(p+5|0)+(xe|0)|0,X(xe+4|0)|0)?1:(w(Ae|0,Ne|0),p=Ne|0,0)}function Me(v){return v=v|0,1}function ye(v){return v=v|0,m(),p=p+1|0,0}function he(v){v=v|0;var Ae=0,Ne=0,xe=0;return xe=v-96|0,X(xe|0)|0?1:(Ae=p+1|0,Ne=(p+1|0)+(xe|0)|0,R(Ae|0,Ne|0),p=Ne|0,0)}function Ze(v){v=v|0;var Ae=0,Ne=0,xe=0;return X(1)|0||(xe=i[p+1|0]|0,Ae=p+2|0,Ne=(p+2|0)+(xe|0)|0,X(xe+1|0)|0)?1:(R(Ae|0,Ne|0),p=Ne|0,0)}function Tr(v){v=v|0;var Ae=0,Ne=0,xe=0;return X(2)|0||(xe=u(p+1|0)|0,Ae=p+3|0,Ne=(p+3|0)+(xe|0)|0,X(xe+2|0)|0)?1:(R(Ae|0,Ne|0),p=Ne|0,0)}function Dr(v){v=v|0;var Ae=0,Ne=0,xe=0;return X(4)|0||(xe=y(p+1|0)|0,Ae=p+5|0,Ne=(p+5|0)+(xe|0)|0,X(xe+4|0)|0)?1:(R(Ae|0,Ne|0),p=Ne|0,0)}function Jr(v){return v=v|0,1}function kt(v){return v=v|0,S(),p=p+1|0,0}function Be(v){return v=v|0,k(v-128|0),p=p+1|0,0}function Tt(v){return v=v|0,X(1)|0?1:(k(i[p+1|0]|0),p=p+2|0,0)}function st(v){return v=v|0,X(2)|0?1:(k(u(p+1|0)|0),p=p+3|0,0)}function $e(v){return v=v|0,X(4)|0?1:(G(u(p+1|0)|0,u(p+3|0)|0),p=p+5|0,0)}function xc(v){return v=v|0,X(8)|0?1:(z(u(p+1|0)|0,u(p+3|0)|0,u(p+5|0)|0,u(p+7|0)|0),p=p+9|0,0)}function vc(v){return v=v|0,E(),p=p+1|0,0}function Ke(v){v=v|0;var Ae=0;return Ae=v-160|0,X(Ae|0)|0?1:(oe(Ae|0),p=p+1|0,0)}function Tc(v){return v=v|0,X(1)|0?1:(oe(i[p+1|0]|0),p=p+2|0,0)}function Ac(v){return v=v|0,X(2)|0?1:(oe(u(p+1|0)|0),p=p+3|0,0)}function Oc(v){return v=v|0,X(4)|0?1:(Q(u(p+1|0)|0,u(p+3|0)|0),p=p+5|0,0)}function Sc(v){return v=v|0,X(8)|0?1:(ie(u(p+1|0)|0,u(p+3|0)|0,u(p+5|0)|0,u(p+7|0)|0),p=p+9|0,0)}function Nc(v){return v=v|0,q(),p=p+1|0,0}function an(v){return v=v|0,V(v-192|0|0),p=p+1|0,0}function I8(v){return v=v|0,V(v|0),p=p+1|0,0}function C8(v){return v=v|0,V(v|0),p=p+1|0,0}function F8(v){return v=v|0,V(v|0),p=p+1|0,0}function M8(v){return v=v|0,V(v|0),p=p+1|0,0}function ft(v){return v=v|0,V(v-192|0|0),p=p+1|0,0}function q8(v){return v=v|0,V(v|0),p=p+1|0,0}function j8(v){return v=v|0,V(v|0),p=p+1|0,0}function k8(v){return v=v|0,V(v|0),p=p+1|0,0}function j_(v){return v=v|0,X(1)|0?1:(V(i[p+1|0]|0),p=p+2|0,0)}function k_(v){return v=v|0,X(2)|0?1:(V(u(p+1|0)|0),p=p+3|0,0)}function V_(v){return v=v|0,X(4)|0?1:(J(u(p+1|0)|0,u(p+3|0)|0),p=p+5|0,0)}function H_(v){return v=v|0,X(8)|0?1:(ae(u(p+1|0)|0,u(p+3|0)|0,u(p+5|0)|0,u(p+7|0)|0),p=p+9|0,0)}function rt(v){return v=v|0,B((v|0)-224|0),p=p+1|0,0}function $_(v){return v=v|0,l(),p=p+1|0,0}function K_(v){return v=v|0,b(),p=p+1|0,0}function G_(v){return v=v|0,O(),p=p+1|0,0}function Y_(v){return v=v|0,N(),p=p+1|0,0}function W_(v){return v=v|0,X(1)|0?1:(B(i[p+1|0]|0),p=p+2|0,0)}function z_(v){v=v|0;var Ae=0,Ne=0,xe=1,no=0,Zi=0,V8=0;return X(2)|0?1:(Ae=i[p+1|0]|0,Ne=i[p+2|0]|0,(Ae|0)&128&&(xe=-1),no=+(((Ae|0)&124)>>2),Zi=+(((Ae|0)&3)<<8|Ne),+no==0?d(+(+xe*5960464477539063e-23*+Zi)):+no==31?+xe==1?+Zi>0?A():I():+Zi>0?K():M():d(+(+xe*F(2,+(+no-25))*+(1024+Zi))),p=p+3|0,0)}function D_(v){return v=v|0,X(4)|0?1:(h(i[p+1|0]|0,i[p+2|0]|0,i[p+3|0]|0,i[p+4|0]|0),p=p+5|0,0)}function J_(v){return v=v|0,X(8)|0?1:(g(i[p+1|0]|0,i[p+2|0]|0,i[p+3|0]|0,i[p+4|0]|0,i[p+5|0]|0,i[p+6|0]|0,i[p+7|0]|0,i[p+8|0]|0),p=p+9|0,0)}function Ve(v){return v=v|0,1}function Z_(v){return v=v|0,D(),p=p+1|0,0}var X_=[_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,U,T,P,H,Ve,Ve,Ve,Ve,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,C,$,j,Z,Ve,Ve,Ve,Ve,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,fe,me,Re,Me,Ve,Ve,Ve,ye,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,Ze,Tr,Dr,Jr,Ve,Ve,Ve,kt,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Tt,st,$e,xc,Ve,Ve,Ve,vc,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Ke,Tc,Ac,Oc,Sc,Ve,Ve,Ve,Nc,an,an,an,an,an,an,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,ft,j_,k_,V_,H_,Ve,Ve,Ve,Ve,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,$_,K_,G_,Y_,W_,z_,D_,J_,Ve,Ve,Ve,Z_];return{parse:le}}});var cs=ee(zt=>{"use strict";var Eu=as().BigNumber;zt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};zt.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};zt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};zt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};zt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};zt.SHIFT32=Math.pow(2,32);zt.SHIFT16=Math.pow(2,16);zt.MAX_SAFE_HIGH=2097151;zt.NEG_ONE=new Eu(-1);zt.TEN=new Eu(10);zt.TWO=new Eu(2);zt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var ko=ee(nr=>{"use strict";var{Buffer:tb}=ai("buffer"),i0=as().BigNumber,s0=cs(),n0=s0.SHIFT32,rb=s0.SHIFT16,nb=2097151;nr.parseHalf=function(e){var r,n,i;return i=e[0]&128?-1:1,r=(e[0]&124)>>2,n=(e[0]&3)<<8|e[1],r?r===31?i*(n?NaN:1/0):i*Math.pow(2,r-25)*(1024+n):i*5960464477539063e-23*n};function ib(t){return t<16?"0"+t.toString(16):t.toString(16)}nr.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=ib(t[n]);return new i0(r,16)};nr.buildMap=t=>{let e=new Map,r=Object.keys(t),n=r.length;for(let i=0;i<n;i++)e.set(r[i],t[r[i]]);return e};nr.buildInt32=(t,e)=>t*rb+e;nr.buildInt64=(t,e,r,n)=>{let i=nr.buildInt32(t,e),s=nr.buildInt32(r,n);return i>nb?new i0(i).times(n0).plus(s):i*n0+s};nr.writeHalf=function(e,r){let n=tb.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 e.writeUInt16BE(s,0),!0};nr.keySorter=function(t,e){var r=t[0].byteLength,n=e[0].byteLength;return r>n?1:n>r?-1:t[0].compare(e[0])};nr.isNegativeZero=t=>t===0&&1/t<0;nr.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var Au=ee((_v,o0)=>{"use strict";var Tu=cs(),sb=Tu.MT,Vo=Tu.SIMPLE,xu=Tu.SYMS,vu=class t{constructor(e){if(typeof e!="number")throw new Error("Invalid Simple type: "+typeof e);if(e<0||e>255||(e|0)!==e)throw new Error("value must be a small positive integer: "+e);this.value=e}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,sb.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case Vo.FALSE:return!1;case Vo.TRUE:return!0;case Vo.NULL:return r?null:xu.NULL;case Vo.UNDEFINED:return r?void 0:xu.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return xu.BREAK;default:return new t(e)}}};o0.exports=vu});var Su=ee((gv,a0)=>{"use strict";var Ou=class t{constructor(e,r,n){if(this.tag=e,this.value=r,this.err=n,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(e){return e._pushTag(this.tag),e.pushAny(this.value)}convert(e){var r,n;if(n=e?.[this.tag],typeof n!="function"&&(n=t["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(t,this.value)}catch(i){return r=i,this.err=r,this}}};a0.exports=Ou});var Ru=ee((mv,u0)=>{"use strict";var{URL:ob,URLSearchParams:ab,format:cb}=ai("url"),c0="http://localhost",Nu=class extends ob{constructor(e="",r=c0){super(e,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}format(){return this.toString()}};u0.exports={URLWithLegacySupport:Nu,URLSearchParams:ab,format:cb,defaultBase:c0}});var d0=ee((bv,f0)=>{"use strict";var{URLWithLegacySupport:l0,format:ub}=Ru();f0.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new l0(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new l0(t,ub(o)).toString()}});var Bu=ee((wv,h0)=>{"use strict";var{URLWithLegacySupport:lb,format:fb,URLSearchParams:db,defaultBase:hb}=Ru(),pb=d0();h0.exports={URL:lb,URLSearchParams:db,format:fb,relative:pb,defaultBase:hb}});var Pu=ee((Ev,y0)=>{"use strict";var{Buffer:vi}=ai("buffer"),p0=Pc(),yb=as().BigNumber,_b=r0(),Ct=ko(),qe=cs(),gb=Au(),mb=Su(),{URL:bb}=Bu(),us=class t{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=Ct.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=vi.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>Ct.arrayBufferToBignumber(r),3:r=>qe.NEG_ONE.minus(Ct.arrayBufferToBignumber(r)),4:r=>qe.TEN.pow(r[0]).times(r[1]),5:r=>qe.TWO.pow(r[0]).times(r[1]),32:r=>new bb(r),35:r=>new RegExp(r)},e.tags),this.parser=_b(global,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var e=this._parents.pop();if(e.length>0)throw new Error(`Missing ${e.length} elements`);switch(e.type){case qe.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case qe.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case qe.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case qe.PARENT.MAP:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(e.ref,e.length));break;case qe.PARENT.OBJECT:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(e.ref,e.length));break;case qe.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===qe.PARENT.TAG&&this._dec()}_dec(){let e=this._currentParent;e.length<0||(e.length--,e.length===0&&this._closeParent())}_push(e,r){let n=this._currentParent;switch(n.values++,n.type){case qe.PARENT.ARRAY:case qe.PARENT.BYTE_STRING:case qe.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case qe.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=qe.PARENT.MAP,n.ref=Ct.buildMap(n.ref)));break;case qe.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case qe.PARENT.TAG:this._ref.push(e),r||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(e,r,n){this._parents[this._depth]={type:r,length:n,ref:e,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:qe.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,r){let n=this._knownTags[e];return n?n(r):new mb(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return vi.concat(e)}createByteStringFromHeap(e,r){return e===r?vi.alloc(0):vi.from(this._heap.slice(e,r))}createInt(e){return e}createInt32(e,r){return Ct.buildInt32(e,r)}createInt64(e,r,n,i){return Ct.buildInt64(e,r,n,i)}createFloat(e){return e}createFloatSingle(e,r,n,i){return p0.read([e,r,n,i],0,!1,23,4)}createFloatDouble(e,r,n,i,s,o,a,c){return p0.read([e,r,n,i,s,o,a,c],0,!1,52,8)}createInt32Neg(e,r){return-1-Ct.buildInt32(e,r)}createInt64Neg(e,r,n,i){let s=Ct.buildInt32(e,r),o=Ct.buildInt32(n,i);return s>qe.MAX_SAFE_HIGH?qe.NEG_ONE.minus(new yb(s).times(qe.SHIFT32).plus(o)):-1-(s*qe.SHIFT32+o)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(e,r){return e.join("")}createUtf8StringFromHeap(e,r){return e===r?"":this._buffer.toString("utf8",e,r)}createSimpleUnassigned(e){return new gb(e)}pushInt(e){this._push(this.createInt(e))}pushInt32(e,r){this._push(this.createInt32(e,r))}pushInt64(e,r,n,i){this._push(this.createInt64(e,r,n,i))}pushFloat(e){this._push(this.createFloat(e))}pushFloatSingle(e,r,n,i){this._push(this.createFloatSingle(e,r,n,i))}pushFloatDouble(e,r,n,i,s,o,a,c){this._push(this.createFloatDouble(e,r,n,i,s,o,a,c))}pushInt32Neg(e,r){this._push(this.createInt32Neg(e,r))}pushInt64Neg(e,r,n,i){this._push(this.createInt64Neg(e,r,n,i))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],qe.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,r){let n=Ct.buildInt32(e,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,r,n,i){let s=Ct.buildInt64(e,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,r){let n=Ct.buildInt32(e,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,r,n,i){let s=Ct.buildInt64(e,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:qe.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(e,r){this._push(this.createByteStringFromHeap(e,r))}pushUtf8StringStart(){this._parents[this._depth]={type:qe.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(e,r){this._push(this.createUtf8StringFromHeap(e,r))}pushSimpleUnassigned(e){this._push(this.createSimpleUnassigned(e))}pushTagStart(e){this._parents[this._depth]={type:qe.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,r){this.pushTagStart(Ct.buildInt32(e,r))}pushTagStart8(e,r,n,i){this.pushTagStart(Ct.buildInt64(e,r,n,i))}pushTagUnassigned(e){this._push(this.createTag(e))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(e){if(e===0){this._push(this.createObject({}));return}this._createParent({},qe.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),qe.PARENT.ARRAY,e)}_decode(e){if(e.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(e);let r=this.parser.parse(e.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(r>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(e){return this._decode(e),this._res[0]}decodeAll(e){return this._decode(e),this._res}static decode(e,r){return typeof e=="string"&&(e=vi.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=vi.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};us.decodeFirst=us.decode;y0.exports=us});var m0=ee((xv,g0)=>{"use strict";var{Buffer:Uu}=ai("buffer"),wb=Pu(),Eb=ko(),Iu=class t extends wb{createTag(e,r){return`${e}(${r})`}createInt(e){return super.createInt(e).toString()}createInt32(e,r){return super.createInt32(e,r).toString()}createInt64(e,r,n,i){return super.createInt64(e,r,n,i).toString()}createInt32Neg(e,r){return super.createInt32Neg(e,r).toString()}createInt64Neg(e,r,n,i){return super.createInt64Neg(e,r,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(e){let r=super.createFloat(e);return Eb.isNegativeZero(e)?"-0_1":`${r}_1`}createFloatSingle(e,r,n,i){return`${super.createFloatSingle(e,r,n,i)}_2`}createFloatDouble(e,r,n,i,s,o,a,c){return`${super.createFloatDouble(e,r,n,i,s,o,a,c)}_3`}createByteString(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(e,r){return`h'${Uu.from(super.createByteStringFromHeap(e,r)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(e){return`simple(${e})`}createArray(e,r){let n=super.createArray(e,r);return r===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(e,r){let n=super.createMap(e),i=Array.from(n.keys()).reduce(_0(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(e,r){let n=super.createObject(e),i=Object.keys(n).reduce(_0(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,r){return`"${Uu.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=Uu.from(e,r||"hex")),new t().decodeFirst(e)}};g0.exports=Iu;function _0(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var v0=ee((vv,x0)=>{"use strict";var{Buffer:Ir}=ai("buffer"),{URL:xb}=Bu(),Fu=as().BigNumber,Cu=ko(),ot=cs(),fr=ot.MT,Ho=ot.NUMBYTES,b0=ot.SHIFT32,w0=ot.SYMS,Ti=ot.TAG,vb=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.TWO,Tb=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.FOUR,Ab=ot.MT.SIMPLE_FLOAT<<5|ot.NUMBYTES.EIGHT,Ob=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.TRUE,Sb=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.FALSE,Nb=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.UNDEFINED,E0=ot.MT.SIMPLE_FLOAT<<5|ot.SIMPLE.NULL,Rb=new Fu("0x20000000000000"),Bb=Ir.from("f97e00","hex"),Pb=Ir.from("f9fc00","hex"),Ub=Ir.from("f97c00","hex");function Ib(t){return{}.toString.call(t).slice(8,-1)}var Mu=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[xb,this._pushUrl],[Fu,this._pushBigNumber]];let r=e.genTypes||[],n=r.length;for(let i=0;i<n;i++)this.addSemanticType(r[i][0],r[i][1]);this._reset()}addSemanticType(e,r){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===e){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,o}return this.semanticTypes.push([e,r]),null}push(e){return e&&(this.result[this.offset]=e,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=e.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(e,r,n){return this.result[this.offset]=e,this.resultMethod[this.offset]=r,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(e){return this.pushWrite(e,1,1)}_pushUInt16BE(e){return this.pushWrite(e,2,2)}_pushUInt32BE(e){return this.pushWrite(e,3,4)}_pushDoubleBE(e){return this.pushWrite(e,4,8)}_pushNaN(){return this.push(Bb)}_pushInfinity(e){let r=e<0?Pb:Ub;return this.push(r)}_pushFloat(e){let r=Ir.allocUnsafe(2);if(Cu.writeHalf(r,e)&&Cu.parseHalf(r)===e)return this._pushUInt8(vb)&&this.push(r);let n=Ir.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(Tb)&&this.push(n):this._pushUInt8(Ab)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|Ho.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|Ho.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|Ho.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|Ho.EIGHT)&&this._pushUInt32BE(Math.floor(e/b0))&&this._pushUInt32BE(e%b0):r===fr.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,fr.NEG_INT,e):this._pushInt(e,fr.POS_INT)}_pushNumber(e){switch(!1){case e===e:return this._pushNaN(e);case isFinite(e):return this._pushInfinity(e);case e%1!==0:return this._pushIntNum(e);default:return this._pushFloat(e)}}_pushString(e){let r=Ir.byteLength(e,"utf8");return this._pushInt(r,fr.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?Ob:Sb)}_pushUndefined(e){return this._pushUInt8(Nb)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,fr.ARRAY))return!1;for(let i=0;i<n;i++)if(!e.pushAny(r[i]))return!1;return!0}_pushTag(e){return this._pushInt(e,fr.TAG)}_pushDate(e,r){return e._pushTag(Ti.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,fr.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(Ti.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,fr.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(Ti.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=Ti.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=Ti.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=Ir.from(n,"hex");return this._pushTag(r)&&this._pushBuffer(this,i)}_pushBigNumber(e,r){if(r.isNaN())return e._pushNaN();if(!r.isFinite())return e._pushInfinity(r.isNegative()?-1/0:1/0);if(r.isInteger())return e._pushBigint(r);if(!(e._pushTag(Ti.DECIMAL_FRAC)&&e._pushInt(2,fr.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new Fu(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(Rb)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,fr.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(e){if(!e)return this._pushUInt8(E0);for(var r=this.semanticTypes.length,n=0;n<r;n++)if(e instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(e,this,e);var i=e.encodeCBOR;if(typeof i=="function")return i.call(e,this);var s=Object.keys(e),o=s.length;return this._pushInt(o,fr.MAP)?this._pushRawMap(o,s.map(a=>[a,e[a]])):!1}_pushRawMap(e,r){r=r.map(function(i){return i[0]=t.encode(i[0]),i}).sort(Cu.keySorter);for(var n=0;n<e;n++)if(!this.push(r[n][0])||!this.pushAny(r[n][1]))return!1;return!0}write(e){return this.pushAny(e)}pushAny(e){var r=Ib(e);switch(r){case"Number":return this._pushNumber(e);case"String":return this._pushString(e);case"Boolean":return this._pushBoolean(e);case"Object":return this._pushObject(e);case"Array":return this._pushArray(this,e);case"Uint8Array":return this._pushBuffer(this,Ir.isBuffer(e)?e:Ir.from(e));case"Null":return this._pushUInt8(E0);case"Undefined":return this._pushUndefined(e);case"Map":return this._pushMap(this,e);case"Set":return this._pushSet(this,e);case"URL":return this._pushUrl(this,e);case"BigNumber":return this._pushBigNumber(this,e);case"Date":return this._pushDate(this,e);case"RegExp":return this._pushRegexp(this,e);case"Symbol":switch(e){case w0.NULL:return this._pushObject(null);case w0.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+e.toString())}default:throw new Error("Unknown type: "+typeof e+", "+(e?e.toString():""))}}finalize(){if(this.offset===0)return null;for(var e=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=r[o];var a=Ir.allocUnsafe(s),c=0,f=0;for(o=0;o<i;o++){switch(f=r[o],n[o]){case 0:e[o].copy(a,c);break;case 1:a.writeUInt8(e[o],c,!0);break;case 2:a.writeUInt16BE(e[o],c,!0);break;case 3:a.writeUInt32BE(e[o],c,!0);break;case 4:a.writeDoubleBE(e[o],c,!0);break;case 5:a.write(e[o],c,f,"utf8");break;default:throw new Error("unkown method")}c+=f}var d=a;return this._reset(),d}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(e){let r=new t;if(!r.pushAny(e))throw new Error("Failed to encode input");return r.finalize()}};x0.exports=Mu});var $o=ee(at=>{"use strict";at.Diagnose=m0();at.Decoder=Pu();at.Encoder=v0();at.Simple=Au();at.Tagged=Su();at.decodeAll=at.Decoder.decodeAll;at.decodeFirst=at.Decoder.decodeFirst;at.diagnose=at.Diagnose.diagnose;at.encode=at.Encoder.encode;at.decode=at.Decoder.decode;at.leveldb={decode:at.Decoder.decodeAll,encode:at.Encoder.encode,buffer:!0,name:"cbor"}});var ds=ee(ir=>{"use strict";var Cb=ir&&ir.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ir,"__esModule",{value:!0});ir.hashOfMap=ir.requestIdOf=ir.hashValue=ir.hash=void 0;var T0=xi(),Fb=Cb($o()),Mb=po(),ls=Ht();function _n(t){return(0,ls.uint8ToBuf)(Mb.sha256.create().update(new Uint8Array(t)).digest())}ir.hash=_n;function fs(t){if(t instanceof Fb.default.Tagged)return fs(t.value);if(typeof t=="string")return A0(t);if(typeof t=="number")return _n((0,T0.lebEncode)(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return _n(t);if(Array.isArray(t)){let e=t.map(fs);return _n((0,ls.concat)(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return _n(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return fs(t.toHash());if(typeof t=="object")return qu(t);if(typeof t=="bigint")return _n((0,T0.lebEncode)(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}ir.hashValue=fs;var A0=t=>{let e=new TextEncoder().encode(t);return _n(e)};function qb(t){return qu(t)}ir.requestIdOf=qb;function qu(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=A0(o),f=fs(a);return[c,f]}).sort(([o],[a])=>(0,ls.compare)(o,a)),i=(0,ls.concat)(...n.map(o=>(0,ls.concat)(...o)));return _n(i)}ir.hashOfMap=qu});var Vu=ee(Cr=>{"use strict";var jb=Cr&&Cr.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};Object.defineProperty(Cr,"__esModule",{value:!0});Cr.createIdentityDescriptor=Cr.AnonymousIdentity=Cr.SignIdentity=void 0;var O0=It(),kb=ds(),S0=Ht(),Vb=new TextEncoder().encode(`
|
|
17
|
+
ic-request`),ju=class{getPrincipal(){return this._principal||(this._principal=O0.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=jb(e,["body"]),i=(0,kb.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,S0.concat)(Vb,i))}})}};Cr.SignIdentity=ju;var ku=class{getPrincipal(){return O0.Principal.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};Cr.AnonymousIdentity=ku;function Hb(t){return"getPublicKey"in t?{type:"PublicKeyIdentity",publicKey:(0,S0.toHex)(t.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}Cr.createIdentityDescriptor=Hb});var Ku=ee(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});var $b=9007199254740992;function Lr(t,...e){let r=new Uint8Array(t.byteLength+e.reduce((i,s)=>i+s.byteLength,0));r.set(new Uint8Array(t),0);let n=t.byteLength;for(let i of e)r.set(new Uint8Array(i),n),n+=i.byteLength;return r.buffer}function dr(t,e,r){r=r.replace(/[^0-9a-fA-F]/g,"");let n=2**(e-24);r=r.slice(-n*2).padStart(n*2,"0");let i=[(t<<5)+e].concat(r.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function Ko(t,e){if(e<24)return new Uint8Array([(t<<5)+e]).buffer;{let r=e<=255?24:e<=65535?25:e<=4294967295?26:27;return dr(t,r,e.toString(16))}}function N0(t){let e=[];for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);n<128?e.push(n):n<2048?e.push(192|n>>6,128|n&63):n<55296||n>=57344?e.push(224|n>>12,128|n>>6&63,128|n&63):(r++,n=(n&1023)<<10|t.charCodeAt(r)&1023,e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return Lr(new Uint8Array(Ko(3,t.length)),new Uint8Array(e))}function Kb(t,e){if(t==14277111)return Lr(new Uint8Array([217,217,247]),e);if(t<24)return Lr(new Uint8Array([192+t]),e);{let r=t<=255?24:t<=65535?25:t<=4294967295?26:27,n=2**(r-24),i=t.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+r].concat(i.match(/../g).map(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}Ge.tagged=Kb;function hs(t){return new Uint8Array(t).buffer}Ge.raw=hs;function Hu(t){if(isNaN(t))throw new RangeError("Invalid number.");t=Math.min(Math.max(0,t),23);let e=[0+t];return new Uint8Array(e).buffer}Ge.uSmall=Hu;function R0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),255),t=t.toString(16),dr(0,24,t)}Ge.u8=R0;function B0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),65535),t=t.toString(16),dr(0,25,t)}Ge.u16=B0;function P0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),4294967295),t=t.toString(16),dr(0,26,t)}Ge.u32=P0;function $u(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return dr(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),$b),t=t.toString(16),dr(0,27,t)}Ge.u64=$u;function U0(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return Hu(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}Ge.iSmall=U0;function I0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),255),t=t.toString(16),dr(1,24,t)}Ge.i8=I0;function C0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),65535),t=t.toString(16),dr(1,25,t)}Ge.i16=C0;function F0(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),4294967295),t=t.toString(16),dr(1,26,t)}Ge.i32=F0;function M0(t,e){if(typeof t=="string"&&e==16){if(t.startsWith("-")?t=t.slice(1):t="0",t.match(/[^0-9a-fA-F]/)||t.length>16)throw new RangeError("Invalid number.");let r=!1,n=t.split("").reduceRight((i,s)=>{if(r)return s+i;let o=parseInt(s,16)-1;return o>=0?(r=!0,o.toString(16)+i):"f"+i},"");return r?dr(1,27,n):$u(0)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),9007199254740992),t=t.toString(16),dr(1,27,t)}Ge.i64=M0;function Gb(t){return t>=0?t<24?Hu(t):t<=255?R0(t):t<=65535?B0(t):t<=4294967295?P0(t):$u(t):t>=-24?U0(t):t>=-255?I0(t):t>=-65535?C0(t):t>=-4294967295?F0(t):M0(t)}Ge.number=Gb;function Yb(t){return Lr(Ko(2,t.byteLength),t)}Ge.bytes=Yb;function Wb(t){return N0(t)}Ge.string=Wb;function zb(t){return Lr(Ko(4,t.length),...t)}Ge.array=zb;function Db(t,e=!1){t instanceof Map||(t=new Map(Object.entries(t)));let r=Array.from(t.entries());return e&&(r=r.sort(([n],[i])=>n.localeCompare(i))),Lr(Ko(5,t.size),...r.map(([n,i])=>Lr(N0(n),i)))}Ge.map=Db;function Jb(t){let e=new Float32Array([t]);return Lr(new Uint8Array([250]),new Uint8Array(e.buffer))}Ge.singleFloat=Jb;function Zb(t){let e=new Float64Array([t]);return Lr(new Uint8Array([251]),new Uint8Array(e.buffer))}Ge.doubleFloat=Zb;function Xb(t){return t?q0():j0()}Ge.bool=Xb;function q0(){return hs(new Uint8Array([245]))}Ge.true_=q0;function j0(){return hs(new Uint8Array([244]))}Ge.false_=j0;function Qb(){return hs(new Uint8Array([246]))}Ge.null_=Qb;function Lb(){return hs(new Uint8Array([247]))}Ge.undefined_=Lb});var k0=ee(gn=>{"use strict";var e1=gn&&gn.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(gn,"__esModule",{value:!0});var hr=e1(Ku()),t1=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],Go=class{constructor(e,r=!1){this._serializer=e,this._stable=r,this.name="jsonDefault",this.priority=-100}match(e){return["undefined","boolean","number","string","object"].indexOf(typeof e)!=-1}encode(e){switch(typeof e){case"undefined":return hr.undefined_();case"boolean":return hr.bool(e);case"number":return Math.floor(e)===e?hr.number(e):hr.doubleFloat(e);case"string":return hr.string(e);case"object":if(e===null)return hr.null_();if(Array.isArray(e))return hr.array(e.map(r=>this._serializer.serializeValue(r)));if(t1.find(r=>e instanceof r))return hr.bytes(e.buffer);if(Object.getOwnPropertyNames(e).indexOf("toJSON")!==-1)return this.encode(e.toJSON());if(e instanceof Map){let r=new Map;for(let[n,i]of e.entries())r.set(n,this._serializer.serializeValue(i));return hr.map(r,this._stable)}else{let r=new Map;for(let[n,i]of Object.entries(e))r.set(n,this._serializer.serializeValue(i));return hr.map(r,this._stable)}default:throw new Error("Invalid value.")}}};gn.JsonDefaultCborEncoder=Go;var Yo=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};gn.ToCborEncoder=Yo;var Wo=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new Go(r,e)),r.addEncoder(new Yo),r}removeEncoder(e){for(let r of this._encoders.values())r.name==e&&this._encoders.delete(r)}addEncoder(e){this._encoders.add(e)}getEncoderFor(e){let r=null;for(let n of this._encoders)(!r||n.priority>r.priority)&&n.match(e)&&(r=n);if(r===null)throw new Error("Could not find an encoder for value.");return r}serializeValue(e){return this.getEncoderFor(e).encode(e)}serialize(e){return this.serializeValue(e)}};gn.CborSerializer=Wo;var Gu=class extends Wo{serialize(e){return hr.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};gn.SelfDescribeCborSerializer=Gu});var ps=ee(Hn=>{"use strict";function r1(t){for(var e in t)Hn.hasOwnProperty(e)||(Hn[e]=t[e])}var n1=Hn&&Hn.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(Hn,"__esModule",{value:!0});r1(k0());var i1=n1(Ku());Hn.value=i1});var ys=ee(mt=>{"use strict";var s1=mt&&mt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),o1=mt&&mt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a1=mt&&mt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&s1(e,t,r);return o1(e,t),e},c1=mt&&mt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(mt,"__esModule",{value:!0});mt.decode=mt.encode=mt.CborTag=void 0;var u1=c1($o()),Ai=a1(ps()),l1=ps(),zo=Ht(),Yu=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return Ai.value.bytes(e.toUint8Array())}},Wu=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return Ai.value.bytes(new Uint8Array(e))}},zu=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?Ai.value.tagged(2,Ai.value.bytes((0,zo.fromHex)(e.toString(16)))):Ai.value.tagged(3,Ai.value.bytes((0,zo.fromHex)((BigInt("-1")*e).toString(16))))}},Do=l1.SelfDescribeCborSerializer.withDefaultEncoders(!0);Do.addEncoder(new Yu);Do.addEncoder(new Wu);Do.addEncoder(new zu);var H0;(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(H0=mt.CborTag||(mt.CborTag={}));function f1(t){return Do.serialize(t)}mt.encode=f1;function V0(t){let e=t.byteLength,r=BigInt(0);for(let n=0;n<e;n++)r=r*BigInt(256)+BigInt(t[n]);return r}var Du=class extends u1.default.Decoder{createByteString(e){return(0,zo.concat)(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}};function d1(t){let e=new Uint8Array(t),r=new Du({size:e.byteLength,tags:{2:n=>V0(n),3:n=>-V0(n),[H0.Semantic]:n=>n}});try{return r.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,zo.toHex)(e)}`)}}mt.decode=d1});var Ju=ee(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.randomNumber=void 0;var h1=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let t=new Uint32Array(1);return window.crypto.getRandomValues(t),t[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let t=new Uint32Array(1);return crypto.getRandomValues(t),t[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};Jo.randomNumber=h1});var _s=ee($n=>{"use strict";Object.defineProperty($n,"__esModule",{value:!0});$n.makeNonce=$n.SubmitRequestType=void 0;var Zo=Ju(),p1;(function(t){t.Call="call"})(p1=$n.SubmitRequestType||($n.SubmitRequestType={}));function y1(){let t=new ArrayBuffer(16),e=new DataView(t),r=(0,Zo.randomNumber)(),n=(0,Zo.randomNumber)(),i=(0,Zo.randomNumber)(),s=(0,Zo.randomNumber)();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}$n.makeNonce=y1});var Qo=ee(St=>{"use strict";var _1=St&&St.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),g1=St&&St.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),m1=St&&St.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&_1(e,t,r);return g1(e,t),e};Object.defineProperty(St,"__esModule",{value:!0});St.httpHeadersTransform=St.makeExpiryTransform=St.makeNonceTransform=St.Expiry=void 0;var b1=xi(),w1=m1(ps()),E1=_s(),$0=BigInt(1e6),x1=60*1e3,Xo=class{constructor(e){if(e<90*1e3){let a=BigInt(Date.now()+e)*$0/BigInt(1e9);this._value=a*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+e-x1))*$0/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return w1.value.u64(this._value.toString(16),16)}toHash(){return(0,b1.lebEncode)(this._value)}};St.Expiry=Xo;function v1(t=E1.makeNonce){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}St.makeNonceTransform=v1;function T1(t){return async e=>{e.body.ingress_expiry=new Xo(t)}}St.makeExpiryTransform=T1;function A1(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}St.httpHeadersTransform=A1});var ea=ee(Fr=>{"use strict";Object.defineProperty(Fr,"__esModule",{value:!0});Fr.AgentReadStateError=Fr.AgentQueryError=Fr.AgentCallError=Fr.AgentHTTPResponseError=void 0;var Lo=yi(),Zu=class extends Lo.AgentError{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Fr.AgentHTTPResponseError=Zu;var Xu=class extends Lo.AgentError{constructor(e,r,n,i,s,o){super(e),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentCallError",Object.setPrototypeOf(this,new.target.prototype)}};Fr.AgentCallError=Xu;var Qu=class extends Lo.AgentError{constructor(e,r,n,i,s,o){super(e),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentQueryError",Object.setPrototypeOf(this,new.target.prototype)}};Fr.AgentQueryError=Qu;var Lu=class extends Lo.AgentError{constructor(e,r,n,i,s,o){super(e),this.response=r,this.requestId=n,this.senderPubkey=i,this.senderSig=s,this.ingressExpiry=o,this.name="AgentReadStateError",Object.setPrototypeOf(this,new.target.prototype)}};Fr.AgentReadStateError=Lu});var Dt=ee(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.notImplemented=Ie.bitMask=void 0;Ie.isBytes=ra;Ie.abytes=na;Ie.abool=S1;Ie.bytesToHex=nl;Ie.numberToHexUnpadded=Y0;Ie.hexToNumber=il;Ie.hexToBytes=ia;Ie.bytesToNumberBE=R1;Ie.bytesToNumberLE=B1;Ie.numberToBytesBE=W0;Ie.numberToBytesLE=P1;Ie.numberToVarBytesBE=U1;Ie.ensureBytes=I1;Ie.concatBytes=z0;Ie.equalBytes=C1;Ie.utf8ToBytes=F1;Ie.inRange=D0;Ie.aInRange=M1;Ie.bitLen=q1;Ie.bitGet=j1;Ie.bitSet=k1;Ie.createHmacDrbg=H1;Ie.validateObject=K1;Ie.memoized=Y1;var rl=BigInt(0),ta=BigInt(1),O1=BigInt(2);function ra(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function na(t){if(!ra(t))throw new Error("Uint8Array expected")}function S1(t,e){if(typeof e!="boolean")throw new Error(`${t} must be valid boolean, got "${e}".`)}var N1=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function nl(t){na(t);let e="";for(let r=0;r<t.length;r++)e+=N1[t[r]];return e}function Y0(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function il(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var en={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function K0(t){if(t>=en._0&&t<=en._9)return t-en._0;if(t>=en._A&&t<=en._F)return t-(en._A-10);if(t>=en._a&&t<=en._f)return t-(en._a-10)}function ia(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=K0(t.charCodeAt(s)),a=K0(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function R1(t){return il(nl(t))}function B1(t){return na(t),il(nl(Uint8Array.from(t).reverse()))}function W0(t,e){return ia(t.toString(16).padStart(e*2,"0"))}function P1(t,e){return W0(t,e).reverse()}function U1(t){return ia(Y0(t))}function I1(t,e,r){let n;if(typeof e=="string")try{n=ia(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(ra(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function z0(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];na(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}function C1(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function F1(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}var el=t=>typeof t=="bigint"&&rl<=t;function D0(t,e,r){return el(t)&&el(e)&&el(r)&&e<=t&&t<r}function M1(t,e,r,n){if(!D0(e,r,n))throw new Error(`expected valid ${t}: ${r} <= n < ${n}, got ${typeof e} ${e}`)}function q1(t){let e;for(e=0;t>rl;t>>=ta,e+=1);return e}function j1(t,e){return t>>BigInt(e)&ta}function k1(t,e,r){return t|(r?ta:rl)<<BigInt(e)}var V1=t=>(O1<<BigInt(t-1))-ta;Ie.bitMask=V1;var tl=t=>new Uint8Array(t),G0=t=>Uint8Array.from(t);function H1(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=tl(t),i=tl(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...h)=>r(i,n,...h),c=(h=tl())=>{i=a(G0([0]),h),n=a(),h.length!==0&&(i=a(G0([1]),h),n=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0,g=[];for(;h<e;){n=a();let b=n.slice();g.push(b),h+=n.length}return z0(...g)};return(h,g)=>{o(),c(h);let b;for(;!(b=g(f()));)c();return o(),b}}var $1={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||ra(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function K1(t,e,r={}){let n=(i,s,o)=>{let a=$1[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return t}var G1=()=>{throw new Error("not implemented")};Ie.notImplemented=G1;function Y1(t){let e=new WeakMap;return(r,...n)=>{let i=e.get(r);if(i!==void 0)return i;let s=t(r,...n);return e.set(r,s),s}}});var Mr=ee(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.isNegativeLE=void 0;ze.mod=Jt;ze.pow=X0;ze.pow2=J1;ze.invert=sa;ze.tonelliShanks=Q0;ze.FpSqrt=L0;ze.validateField=Q1;ze.FpPow=eh;ze.FpInvertBatch=th;ze.FpDiv=L1;ze.FpLegendre=rh;ze.FpIsSquare=ew;ze.nLength=ol;ze.Field=tw;ze.FpSqrtOdd=rw;ze.FpSqrtEven=nw;ze.hashToPrivateScalar=iw;ze.getFieldBytesLength=al;ze.getMinHashLength=nh;ze.mapHashToField=sw;var Zt=Dt(),ct=BigInt(0),He=BigInt(1),mn=BigInt(2),W1=BigInt(3),sl=BigInt(4),J0=BigInt(5),Z0=BigInt(8),z1=BigInt(9),D1=BigInt(16);function Jt(t,e){let r=t%e;return r>=ct?r:e+r}function X0(t,e,r){if(r<=ct||e<ct)throw new Error("Expected power/modulo > 0");if(r===He)return ct;let n=He;for(;e>ct;)e&He&&(n=n*t%r),t=t*t%r,e>>=He;return n}function J1(t,e,r){let n=t;for(;e-- >ct;)n*=n,n%=r;return n}function sa(t,e){if(t===ct||e<=ct)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Jt(t,e),n=e,i=ct,s=He,o=He,a=ct;for(;r!==ct;){let f=n/r,d=n%r,h=i-o*f,g=s-a*f;n=r,r=d,i=o,s=a,o=h,a=g}if(n!==He)throw new Error("invert: does not exist");return Jt(i,e)}function Q0(t){let e=(t-He)/mn,r,n,i;for(r=t-He,n=0;r%mn===ct;r/=mn,n++);for(i=mn;i<t&&X0(i,e,t)!==t-He;i++);if(n===1){let o=(t+He)/sl;return function(c,f){let d=c.pow(f,o);if(!c.eql(c.sqr(d),f))throw new Error("Cannot find square root");return d}}let s=(r+He)/mn;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,d=a.pow(a.mul(a.ONE,i),r),h=a.pow(c,s),g=a.pow(c,r);for(;!a.eql(g,a.ONE);){if(a.eql(g,a.ZERO))return a.ZERO;let b=1;for(let N=a.sqr(g);b<f&&!a.eql(N,a.ONE);b++)N=a.sqr(N);let l=a.pow(d,He<<BigInt(f-b-1));d=a.sqr(l),h=a.mul(h,l),g=a.mul(g,d),f=b}return h}}function L0(t){if(t%sl===W1){let e=(t+He)/sl;return function(n,i){let s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(t%Z0===J0){let e=(t-J0)/Z0;return function(n,i){let s=n.mul(i,mn),o=n.pow(s,e),a=n.mul(i,o),c=n.mul(n.mul(a,mn),o),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),i))throw new Error("Cannot find square root");return f}}return t%D1,Q0(t)}var Z1=(t,e)=>(Jt(t,e)&He)===He;ze.isNegativeLE=Z1;var X1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Q1(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=X1.reduce((n,i)=>(n[i]="function",n),e);return(0,Zt.validateObject)(t,r)}function eh(t,e,r){if(r<ct)throw new Error("Expected power > 0");if(r===ct)return t.ONE;if(r===He)return e;let n=t.ONE,i=e;for(;r>ct;)r&He&&(n=t.mul(n,i)),i=t.sqr(i),r>>=He;return n}function th(t,e){let r=new Array(e.length),n=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),i=t.inv(n);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),i),r}function L1(t,e,r){return t.mul(e,typeof r=="bigint"?sa(r,t.ORDER):t.inv(r))}function rh(t){let e=(t-He)/mn;return(r,n)=>r.pow(n,e)}function ew(t){let e=rh(t.ORDER);return r=>{let n=e(t,r);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}}function ol(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function tw(t,e,r=!1,n={}){if(t<=ct)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=ol(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=L0(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:(0,Zt.bitMask)(i),ZERO:ct,ONE:He,create:c=>Jt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ct<=c&&c<t},is0:c=>c===ct,isOdd:c=>(c&He)===He,neg:c=>Jt(-c,t),eql:(c,f)=>c===f,sqr:c=>Jt(c*c,t),add:(c,f)=>Jt(c+f,t),sub:(c,f)=>Jt(c-f,t),mul:(c,f)=>Jt(c*f,t),pow:(c,f)=>eh(a,c,f),div:(c,f)=>Jt(c*sa(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>sa(c,t),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>th(a,c),cmov:(c,f,d)=>d?f:c,toBytes:c=>r?(0,Zt.numberToBytesLE)(c,s):(0,Zt.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,Zt.bytesToNumberLE)(c):(0,Zt.bytesToNumberBE)(c)}});return Object.freeze(a)}function rw(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?r:t.neg(r)}function nw(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function iw(t,e,r=!1){t=(0,Zt.ensureBytes)("privateHash",t);let n=t.length,i=ol(e).nByteLength+8;if(i<24||n<i||n>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${n}`);let s=r?(0,Zt.bytesToNumberLE)(t):(0,Zt.bytesToNumberBE)(t);return Jt(s,e-He)+He}function al(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function nh(t){let e=al(t);return e+Math.ceil(e/2)}function sw(t,e,r=!1){let n=t.length,i=al(e),s=nh(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?(0,Zt.bytesToNumberBE)(t):(0,Zt.bytesToNumberLE)(t),a=Jt(o,e-He)+He;return r?(0,Zt.numberToBytesLE)(a,i):(0,Zt.numberToBytesBE)(a,i)}});var oa=ee(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});Kn.expand_message_xmd=ih;Kn.expand_message_xof=sh;Kn.hash_to_field=cl;Kn.isogenyMap=uw;Kn.createHasher=lw;var ow=Mr(),Nt=Dt(),aw=Nt.bytesToNumberBE;function bn(t,e){if(gs(t),gs(e),t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);let r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=t&255,t>>>=8;return new Uint8Array(r)}function cw(t,e){let r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function gs(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function ih(t,e,r,n){(0,Nt.abytes)(t),(0,Nt.abytes)(e),gs(r),e.length>255&&(e=n((0,Nt.concatBytes)((0,Nt.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(r/i);if(r>65535||o>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=(0,Nt.concatBytes)(e,bn(e.length,1)),c=bn(0,s),f=bn(r,2),d=new Array(o),h=n((0,Nt.concatBytes)(c,t,f,bn(0,1),a));d[0]=n((0,Nt.concatBytes)(h,bn(1,1),a));for(let b=1;b<=o;b++){let l=[cw(h,d[b-1]),bn(b+1,1),a];d[b]=n((0,Nt.concatBytes)(...l))}return(0,Nt.concatBytes)(...d).slice(0,r)}function sh(t,e,r,n,i){if((0,Nt.abytes)(t),(0,Nt.abytes)(e),gs(r),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update((0,Nt.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(t).update(bn(r,2)).update(e).update(bn(e.length,1)).digest()}function cl(t,e,r){(0,Nt.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:a,DST:c}=r;(0,Nt.abytes)(t),gs(e);let f=typeof c=="string"?(0,Nt.utf8ToBytes)(c):c,d=n.toString(2).length,h=Math.ceil((d+i)/8),g=e*s*h,b;if(a==="xmd")b=ih(t,f,g,o);else if(a==="xof")b=sh(t,f,g,i,o);else if(a==="_internal_pass")b=t;else throw new Error('expand must be "xmd" or "xof"');let l=new Array(e);for(let N=0;N<e;N++){let O=new Array(s);for(let I=0;I<s;I++){let M=h*(I+N*s),A=b.subarray(M,M+h);O[I]=(0,ow.mod)(aw(A),n)}l[N]=O}return l}function uw(t,e){let r=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,a,c]=r.map(f=>f.reduce((d,h)=>t.add(t.mul(d,n),h)));return n=t.div(s,o),i=t.mul(i,t.div(a,c)),{x:n,y:i}}}function lw(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=cl(n,2,{...r,DST:r.DST,...i}),o=t.fromAffine(e(s[0])),a=t.fromAffine(e(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=cl(n,1,{...r,DST:r.encodeDST,...i}),o=t.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(let s of n)if(typeof s!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${s} in array`);let i=t.fromAffine(e(n)).clearCofactor();return i.assertValidity(),i}}}});var fl=ee(ms=>{"use strict";Object.defineProperty(ms,"__esModule",{value:!0});ms.wNAF=dw;ms.pippenger=hw;ms.validateBasic=pw;var oh=Mr(),ch=Dt(),fw=BigInt(0),ul=BigInt(1),ll=new WeakMap,ah=new WeakMap;function dw(t,e){let r=(s,o)=>{let a=o.negate();return s?a:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error(`Wrong window size=${s}, should be [1..${e}]`)},i=s=>{n(s);let o=Math.ceil(e/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:r,unsafeLadder(s,o){let a=t.ZERO,c=s;for(;o>fw;)o&ul&&(a=a.add(c)),c=c.double(),o>>=ul;return a},precomputeWindow(s,o){let{windows:a,windowSize:c}=i(o),f=[],d=s,h=d;for(let g=0;g<a;g++){h=d,f.push(h);for(let b=1;b<c;b++)h=h.add(d),f.push(h);d=h.double()}return f},wNAF(s,o,a){let{windows:c,windowSize:f}=i(s),d=t.ZERO,h=t.BASE,g=BigInt(2**s-1),b=2**s,l=BigInt(s);for(let N=0;N<c;N++){let O=N*f,I=Number(a&g);a>>=l,I>f&&(I-=b,a+=ul);let M=O,A=O+Math.abs(I)-1,K=N%2!==0,E=I<0;I===0?h=h.add(r(K,o[M])):d=d.add(r(E,o[A]))}return{p:d,f:h}},wNAFCached(s,o,a){let c=ah.get(s)||1,f=ll.get(s);return f||(f=this.precomputeWindow(s,c),c!==1&&ll.set(s,a(f))),this.wNAF(c,f,o)},setWindowSize(s,o){n(o),ah.set(s,o),ll.delete(s)}}}function hw(t,e,r,n){if(!Array.isArray(r)||!Array.isArray(n)||n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((d,h)=>{if(!e.isValid(d))throw new Error(`wrong scalar at index ${h}`)}),r.forEach((d,h)=>{if(!(d instanceof t))throw new Error(`wrong point at index ${h}`)});let i=(0,ch.bitLen)(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(t.ZERO),c=Math.floor((e.BITS-1)/s)*s,f=t.ZERO;for(let d=c;d>=0;d-=s){a.fill(t.ZERO);for(let g=0;g<n.length;g++){let b=n[g],l=Number(b>>BigInt(d)&BigInt(o));a[l]=a[l].add(r[g])}let h=t.ZERO;for(let g=a.length-1,b=t.ZERO;g>0;g--)b=b.add(a[g]),h=h.add(b);if(f=f.add(h),d!==0)for(let g=0;g<s;g++)f=f.double()}return f}function pw(t){return(0,oh.validateField)(t.Fp),(0,ch.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,oh.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}});var dl=ee(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.DER=void 0;wt.weierstrassPoints=fh;wt.weierstrass=bw;wt.SWUFpSqrtRatio=dh;wt.mapToCurveSimpleSWU=ww;var aa=fl(),Gn=Mr(),Oe=Dt(),bt=Dt();function uh(t){t.lowS!==void 0&&(0,bt.abool)("lowS",t.lowS),t.prehash!==void 0&&(0,bt.abool)("prehash",t.prehash)}function yw(t){let e=(0,aa.validateBasic)(t);Oe.validateObject(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:_w,hexToBytes:gw}=Oe;wt.DER={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(t,e)=>{let{Err:r}=wt.DER;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,i=Oe.numberToHexUnpadded(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?Oe.numberToHexUnpadded(i.length/2|128):"";return`${Oe.numberToHexUnpadded(t)}${s}${i}${e}`},decode(t,e){let{Err:r}=wt.DER,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let i=e[n++],s=!!(i&128),o=0;if(!s)o=i;else{let c=i&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+c);if(f.length!==c)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of f)o=o<<8|d;if(n+=c,o<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+o)}}},_int:{encode(t){let{Err:e}=wt.DER;if(t<pr)throw new e("integer: negative integers are not allowed");let r=Oe.numberToHexUnpadded(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected assertion");return r},decode(t){let{Err:e}=wt.DER;if(t[0]&128)throw new e("Invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return _w(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=wt.DER,i=typeof t=="string"?gw(t):t;Oe.abytes(i);let{v:s,l:o}=n.decode(48,i);if(o.length)throw new e("Invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,s),{v:f,l:d}=n.decode(2,c);if(d.length)throw new e("Invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(f)}},hexFromSig(t){let{_tlv:e,_int:r}=wt.DER,n=`${e.encode(2,r.encode(t.r))}${e.encode(2,r.encode(t.s))}`;return e.encode(48,n)}};var pr=BigInt(0),je=BigInt(1),wn=BigInt(2),ca=BigInt(3),lh=BigInt(4);function fh(t){let e=yw(t),{Fp:r}=e,n=Gn.Field(e.n,e.nBitLength),i=e.toBytes||((N,O,I)=>{let M=O.toAffine();return Oe.concatBytes(Uint8Array.from([4]),r.toBytes(M.x),r.toBytes(M.y))}),s=e.fromBytes||(N=>{let O=N.subarray(1),I=r.fromBytes(O.subarray(0,r.BYTES)),M=r.fromBytes(O.subarray(r.BYTES,2*r.BYTES));return{x:I,y:M}});function o(N){let{a:O,b:I}=e,M=r.sqr(N),A=r.mul(M,N);return r.add(r.add(A,r.mul(N,O)),I)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(N){return Oe.inRange(N,je,e.n)}function c(N){let{allowedPrivateKeyLengths:O,nByteLength:I,wrapPrivateKey:M,n:A}=e;if(O&&typeof N!="bigint"){if(Oe.isBytes(N)&&(N=Oe.bytesToHex(N)),typeof N!="string"||!O.includes(N.length))throw new Error("Invalid key");N=N.padStart(I*2,"0")}let K;try{K=typeof N=="bigint"?N:Oe.bytesToNumberBE((0,bt.ensureBytes)("private key",N,I))}catch{throw new Error(`private key must be ${I} bytes, hex or bigint, not ${typeof N}`)}return M&&(K=Gn.mod(K,A)),Oe.aInRange("private key",K,je,A),K}function f(N){if(!(N instanceof g))throw new Error("ProjectivePoint expected")}let d=(0,bt.memoized)((N,O)=>{let{px:I,py:M,pz:A}=N;if(r.eql(A,r.ONE))return{x:I,y:M};let K=N.is0();O==null&&(O=K?r.ONE:r.inv(A));let E=r.mul(I,O),k=r.mul(M,O),G=r.mul(A,O);if(K)return{x:r.ZERO,y:r.ZERO};if(!r.eql(G,r.ONE))throw new Error("invZ was invalid");return{x:E,y:k}}),h=(0,bt.memoized)(N=>{if(N.is0()){if(e.allowInfinityPoint&&!r.is0(N.py))return;throw new Error("bad point: ZERO")}let{x:O,y:I}=N.toAffine();if(!r.isValid(O)||!r.isValid(I))throw new Error("bad point: x or y not FE");let M=r.sqr(I),A=o(O);if(!r.eql(M,A))throw new Error("bad point: equation left != right");if(!N.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class g{constructor(O,I,M){if(this.px=O,this.py=I,this.pz=M,O==null||!r.isValid(O))throw new Error("x required");if(I==null||!r.isValid(I))throw new Error("y required");if(M==null||!r.isValid(M))throw new Error("z required");Object.freeze(this)}static fromAffine(O){let{x:I,y:M}=O||{};if(!O||!r.isValid(I)||!r.isValid(M))throw new Error("invalid affine point");if(O instanceof g)throw new Error("projective point not allowed");let A=K=>r.eql(K,r.ZERO);return A(I)&&A(M)?g.ZERO:new g(I,M,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(O){let I=r.invertBatch(O.map(M=>M.pz));return O.map((M,A)=>M.toAffine(I[A])).map(g.fromAffine)}static fromHex(O){let I=g.fromAffine(s((0,bt.ensureBytes)("pointHex",O)));return I.assertValidity(),I}static fromPrivateKey(O){return g.BASE.multiply(c(O))}static msm(O,I){return(0,aa.pippenger)(g,n,O,I)}_setWindowSize(O){l.setWindowSize(this,O)}assertValidity(){h(this)}hasEvenY(){let{y:O}=this.toAffine();if(r.isOdd)return!r.isOdd(O);throw new Error("Field doesn't support isOdd")}equals(O){f(O);let{px:I,py:M,pz:A}=this,{px:K,py:E,pz:k}=O,G=r.eql(r.mul(I,k),r.mul(K,A)),z=r.eql(r.mul(M,k),r.mul(E,A));return G&&z}negate(){return new g(this.px,r.neg(this.py),this.pz)}double(){let{a:O,b:I}=e,M=r.mul(I,ca),{px:A,py:K,pz:E}=this,k=r.ZERO,G=r.ZERO,z=r.ZERO,q=r.mul(A,A),oe=r.mul(K,K),Q=r.mul(E,E),ie=r.mul(A,K);return ie=r.add(ie,ie),z=r.mul(A,E),z=r.add(z,z),k=r.mul(O,z),G=r.mul(M,Q),G=r.add(k,G),k=r.sub(oe,G),G=r.add(oe,G),G=r.mul(k,G),k=r.mul(ie,k),z=r.mul(M,z),Q=r.mul(O,Q),ie=r.sub(q,Q),ie=r.mul(O,ie),ie=r.add(ie,z),z=r.add(q,q),q=r.add(z,q),q=r.add(q,Q),q=r.mul(q,ie),G=r.add(G,q),Q=r.mul(K,E),Q=r.add(Q,Q),q=r.mul(Q,ie),k=r.sub(k,q),z=r.mul(Q,oe),z=r.add(z,z),z=r.add(z,z),new g(k,G,z)}add(O){f(O);let{px:I,py:M,pz:A}=this,{px:K,py:E,pz:k}=O,G=r.ZERO,z=r.ZERO,q=r.ZERO,oe=e.a,Q=r.mul(e.b,ca),ie=r.mul(I,K),w=r.mul(M,E),m=r.mul(A,k),R=r.add(I,M),S=r.add(K,E);R=r.mul(R,S),S=r.add(ie,w),R=r.sub(R,S),S=r.add(I,A);let B=r.add(K,k);return S=r.mul(S,B),B=r.add(ie,m),S=r.sub(S,B),B=r.add(M,A),G=r.add(E,k),B=r.mul(B,G),G=r.add(w,m),B=r.sub(B,G),q=r.mul(oe,S),G=r.mul(Q,m),q=r.add(G,q),G=r.sub(w,q),q=r.add(w,q),z=r.mul(G,q),w=r.add(ie,ie),w=r.add(w,ie),m=r.mul(oe,m),S=r.mul(Q,S),w=r.add(w,m),m=r.sub(ie,m),m=r.mul(oe,m),S=r.add(S,m),ie=r.mul(w,S),z=r.add(z,ie),ie=r.mul(B,S),G=r.mul(R,G),G=r.sub(G,ie),ie=r.mul(R,w),q=r.mul(B,q),q=r.add(q,ie),new g(G,z,q)}subtract(O){return this.add(O.negate())}is0(){return this.equals(g.ZERO)}wNAF(O){return l.wNAFCached(this,O,g.normalizeZ)}multiplyUnsafe(O){Oe.aInRange("scalar",O,pr,e.n);let I=g.ZERO;if(O===pr)return I;if(O===je)return this;let{endo:M}=e;if(!M)return l.unsafeLadder(this,O);let{k1neg:A,k1:K,k2neg:E,k2:k}=M.splitScalar(O),G=I,z=I,q=this;for(;K>pr||k>pr;)K&je&&(G=G.add(q)),k&je&&(z=z.add(q)),q=q.double(),K>>=je,k>>=je;return A&&(G=G.negate()),E&&(z=z.negate()),z=new g(r.mul(z.px,M.beta),z.py,z.pz),G.add(z)}multiply(O){let{endo:I,n:M}=e;Oe.aInRange("scalar",O,je,M);let A,K;if(I){let{k1neg:E,k1:k,k2neg:G,k2:z}=I.splitScalar(O),{p:q,f:oe}=this.wNAF(k),{p:Q,f:ie}=this.wNAF(z);q=l.constTimeNegate(E,q),Q=l.constTimeNegate(G,Q),Q=new g(r.mul(Q.px,I.beta),Q.py,Q.pz),A=q.add(Q),K=oe.add(ie)}else{let{p:E,f:k}=this.wNAF(O);A=E,K=k}return g.normalizeZ([A,K])[0]}multiplyAndAddUnsafe(O,I,M){let A=g.BASE,K=(k,G)=>G===pr||G===je||!k.equals(A)?k.multiplyUnsafe(G):k.multiply(G),E=K(this,I).add(K(O,M));return E.is0()?void 0:E}toAffine(O){return d(this,O)}isTorsionFree(){let{h:O,isTorsionFree:I}=e;if(O===je)return!0;if(I)return I(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:O,clearCofactor:I}=e;return O===je?this:I?I(g,this):this.multiplyUnsafe(e.h)}toRawBytes(O=!0){return(0,bt.abool)("isCompressed",O),this.assertValidity(),i(g,this,O)}toHex(O=!0){return(0,bt.abool)("isCompressed",O),Oe.bytesToHex(this.toRawBytes(O))}}g.BASE=new g(e.Gx,e.Gy,r.ONE),g.ZERO=new g(r.ZERO,r.ONE,r.ZERO);let b=e.nBitLength,l=(0,aa.wNAF)(g,e.endo?Math.ceil(b/2):b);return{CURVE:e,ProjectivePoint:g,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function mw(t){let e=(0,aa.validateBasic)(t);return Oe.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function bw(t){let e=mw(t),{Fp:r,n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function o(m){return Gn.mod(m,n)}function a(m){return Gn.invert(m,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:d,isWithinCurveOrder:h}=fh({...e,toBytes(m,R,S){let B=R.toAffine(),V=r.toBytes(B.x),J=Oe.concatBytes;return(0,bt.abool)("isCompressed",S),S?J(Uint8Array.from([R.hasEvenY()?2:3]),V):J(Uint8Array.from([4]),V,r.toBytes(B.y))},fromBytes(m){let R=m.length,S=m[0],B=m.subarray(1);if(R===i&&(S===2||S===3)){let V=Oe.bytesToNumberBE(B);if(!Oe.inRange(V,je,r.ORDER))throw new Error("Point is not on curve");let J=d(V),ae;try{ae=r.sqrt(J)}catch(F){let p=F instanceof Error?": "+F.message:"";throw new Error("Point is not on curve"+p)}let ce=(ae&je)===je;return(S&1)===1!==ce&&(ae=r.neg(ae)),{x:V,y:ae}}else if(R===s&&S===4){let V=r.fromBytes(B.subarray(0,r.BYTES)),J=r.fromBytes(B.subarray(r.BYTES,2*r.BYTES));return{x:V,y:J}}else throw new Error(`Point of length ${R} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),g=m=>Oe.bytesToHex(Oe.numberToBytesBE(m,e.nByteLength));function b(m){let R=n>>je;return m>R}function l(m){return b(m)?o(-m):m}let N=(m,R,S)=>Oe.bytesToNumberBE(m.slice(R,S));class O{constructor(R,S,B){this.r=R,this.s=S,this.recovery=B,this.assertValidity()}static fromCompact(R){let S=e.nByteLength;return R=(0,bt.ensureBytes)("compactSignature",R,S*2),new O(N(R,0,S),N(R,S,2*S))}static fromDER(R){let{r:S,s:B}=wt.DER.toSig((0,bt.ensureBytes)("DER",R));return new O(S,B)}assertValidity(){Oe.aInRange("r",this.r,je,n),Oe.aInRange("s",this.s,je,n)}addRecoveryBit(R){return new O(this.r,this.s,R)}recoverPublicKey(R){let{r:S,s:B,recovery:V}=this,J=k((0,bt.ensureBytes)("msgHash",R));if(V==null||![0,1,2,3].includes(V))throw new Error("recovery id invalid");let ae=V===2||V===3?S+e.n:S;if(ae>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let ce=(V&1)===0?"02":"03",D=c.fromHex(ce+g(ae)),F=a(ae),p=o(-J*F),L=o(B*F),re=c.BASE.multiplyAndAddUnsafe(D,p,L);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new O(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Oe.hexToBytes(this.toDERHex())}toDERHex(){return wt.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Oe.hexToBytes(this.toCompactHex())}toCompactHex(){return g(this.r)+g(this.s)}}let I={isValidPrivateKey(m){try{return f(m),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let m=Gn.getMinHashLength(e.n);return Gn.mapHashToField(e.randomBytes(m),e.n)},precompute(m=8,R=c.BASE){return R._setWindowSize(m),R.multiply(BigInt(3)),R}};function M(m,R=!0){return c.fromPrivateKey(m).toRawBytes(R)}function A(m){let R=Oe.isBytes(m),S=typeof m=="string",B=(R||S)&&m.length;return R?B===i||B===s:S?B===2*i||B===2*s:m instanceof c}function K(m,R,S=!0){if(A(m))throw new Error("first arg must be private key");if(!A(R))throw new Error("second arg must be public key");return c.fromHex(R).multiply(f(m)).toRawBytes(S)}let E=e.bits2int||function(m){let R=Oe.bytesToNumberBE(m),S=m.length*8-e.nBitLength;return S>0?R>>BigInt(S):R},k=e.bits2int_modN||function(m){return o(E(m))},G=Oe.bitMask(e.nBitLength);function z(m){return Oe.aInRange(`num < 2^${e.nBitLength}`,m,pr,G),Oe.numberToBytesBE(m,e.nByteLength)}function q(m,R,S=oe){if(["recovered","canonical"].some(X=>X in S))throw new Error("sign() legacy options not supported");let{hash:B,randomBytes:V}=e,{lowS:J,prehash:ae,extraEntropy:ce}=S;J==null&&(J=!0),m=(0,bt.ensureBytes)("msgHash",m),uh(S),ae&&(m=(0,bt.ensureBytes)("prehashed msgHash",B(m)));let D=k(m),F=f(R),p=[z(F),z(D)];if(ce!=null&&ce!==!1){let X=ce===!0?V(r.BYTES):ce;p.push((0,bt.ensureBytes)("extraEntropy",X))}let L=Oe.concatBytes(...p),re=D;function le(X){let u=E(X);if(!h(u))return;let y=a(u),_=c.BASE.multiply(u).toAffine(),U=o(_.x);if(U===pr)return;let T=o(y*o(re+U*F));if(T===pr)return;let P=(_.x===U?0:2)|Number(_.y&je),H=T;return J&&b(T)&&(H=l(T),P^=1),new O(U,H,P)}return{seed:L,k2sig:le}}let oe={lowS:e.lowS,prehash:!1},Q={lowS:e.lowS,prehash:!1};function ie(m,R,S=oe){let{seed:B,k2sig:V}=q(m,R,S),J=e;return Oe.createHmacDrbg(J.hash.outputLen,J.nByteLength,J.hmac)(B,V)}c.BASE._setWindowSize(8);function w(m,R,S,B=Q){let V=m;if(R=(0,bt.ensureBytes)("msgHash",R),S=(0,bt.ensureBytes)("publicKey",S),"strict"in B)throw new Error("options.strict was renamed to lowS");uh(B);let{lowS:J,prehash:ae}=B,ce,D;try{if(typeof V=="string"||Oe.isBytes(V))try{ce=O.fromDER(V)}catch(_){if(!(_ instanceof wt.DER.Err))throw _;ce=O.fromCompact(V)}else if(typeof V=="object"&&typeof V.r=="bigint"&&typeof V.s=="bigint"){let{r:_,s:U}=V;ce=new O(_,U)}else throw new Error("PARSE");D=c.fromHex(S)}catch(_){if(_.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(J&&ce.hasHighS())return!1;ae&&(R=e.hash(R));let{r:F,s:p}=ce,L=k(R),re=a(p),le=o(L*re),X=o(F*re),u=c.BASE.multiplyAndAddUnsafe(D,le,X)?.toAffine();return u?o(u.x)===F:!1}return{CURVE:e,getPublicKey:M,getSharedSecret:K,sign:ie,verify:w,ProjectivePoint:c,Signature:O,utils:I}}function dh(t,e){let r=t.ORDER,n=pr;for(let l=r-je;l%wn===pr;l/=wn)n+=je;let i=n,s=wn<<i-je-je,o=s*wn,a=(r-je)/o,c=(a-je)/wn,f=o-je,d=s,h=t.pow(e,a),g=t.pow(e,(a+je)/wn),b=(l,N)=>{let O=h,I=t.pow(N,f),M=t.sqr(I);M=t.mul(M,N);let A=t.mul(l,M);A=t.pow(A,c),A=t.mul(A,I),I=t.mul(A,N),M=t.mul(A,l);let K=t.mul(M,I);A=t.pow(K,d);let E=t.eql(A,t.ONE);I=t.mul(M,g),A=t.mul(K,O),M=t.cmov(I,M,E),K=t.cmov(A,K,E);for(let k=i;k>je;k--){let G=k-wn;G=wn<<G-je;let z=t.pow(K,G),q=t.eql(z,t.ONE);I=t.mul(M,O),O=t.mul(O,O),z=t.mul(K,O),M=t.cmov(I,M,q),K=t.cmov(z,K,q)}return{isValid:E,value:M}};if(t.ORDER%lh===ca){let l=(t.ORDER-ca)/lh,N=t.sqrt(t.neg(e));b=(O,I)=>{let M=t.sqr(I),A=t.mul(O,I);M=t.mul(M,A);let K=t.pow(M,l);K=t.mul(K,A);let E=t.mul(K,N),k=t.mul(t.sqr(K),I),G=t.eql(k,O),z=t.cmov(E,K,G);return{isValid:G,value:z}}}return b}function ww(t,e){if(Gn.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=dh(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,a,c,f,d,h;i=t.sqr(n),i=t.mul(i,e.Z),s=t.sqr(i),s=t.add(s,i),o=t.add(s,t.ONE),o=t.mul(o,e.B),a=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),a=t.mul(a,e.A),s=t.sqr(o),f=t.sqr(a),c=t.mul(f,e.A),s=t.add(s,c),s=t.mul(s,o),f=t.mul(f,a),c=t.mul(f,e.B),s=t.add(s,c),d=t.mul(i,o);let{isValid:g,value:b}=r(s,f);h=t.mul(i,n),h=t.mul(h,b),d=t.cmov(d,o,g),h=t.cmov(h,b,g);let l=t.isOdd(n)===t.isOdd(h);return h=t.cmov(t.neg(h),h,l),d=t.div(d,a),{x:d,y:h}}}});var gh=ee(pl=>{"use strict";Object.defineProperty(pl,"__esModule",{value:!0});pl.bls=vw;var hh=Mr(),hl=Dt(),ph=oa(),yh=dl(),Ew=BigInt(0),ua=BigInt(1),_h=BigInt(2),Oi=BigInt(3);function xw(t){let e=[];for(;t>ua;t>>=ua)(t&ua)===Ew?e.unshift(0):(t&Oi)===Oi?(e.unshift(-1),t+=ua):e.unshift(1);return e}function vw(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=t.params.xNegative,a=t.params.twistType,c=(0,yh.weierstrassPoints)({n:r.ORDER,...t.G1}),f=Object.assign(c,(0,ph.createHasher)(c.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults})),d=(0,yh.weierstrassPoints)({n:r.ORDER,...t.G2}),h=Object.assign(d,(0,ph.createHasher)(d.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),g;if(a==="multiplicative")g=(D,F,p,L,re,le)=>s.mul014(L,D,n.mul(F,re),n.mul(p,le));else if(a==="divisive")g=(D,F,p,L,re,le)=>s.mul034(L,n.mul(p,le),n.mul(F,re),D);else throw new Error("bls: unknown twist type");let b=n.div(n.ONE,n.mul(n.ONE,_h));function l(D,F,p,L){let re=n.sqr(p),le=n.sqr(L),X=n.mulByB(n.mul(le,Oi)),u=n.mul(X,Oi),y=n.sub(n.sub(n.sqr(n.add(p,L)),le),re),_=n.sub(X,re),U=n.mul(n.sqr(F),Oi),T=n.neg(y);return D.push([_,U,T]),F=n.mul(n.mul(n.mul(n.sub(re,u),F),p),b),p=n.sub(n.sqr(n.mul(n.add(re,u),b)),n.mul(n.sqr(X),Oi)),L=n.mul(re,y),{Rx:F,Ry:p,Rz:L}}function N(D,F,p,L,re,le){let X=n.sub(p,n.mul(le,L)),u=n.sub(F,n.mul(re,L)),y=n.sub(n.mul(X,re),n.mul(u,le)),_=n.neg(X),U=u;D.push([y,_,U]);let T=n.sqr(u),P=n.mul(T,u),H=n.mul(T,F),x=n.add(n.sub(P,n.mul(H,_h)),n.mul(n.sqr(X),L));return F=n.mul(u,x),p=n.sub(n.mul(n.sub(H,x),X),n.mul(P,p)),L=n.mul(L,P),{Rx:F,Ry:p,Rz:L}}let O=xw(t.params.ateLoopSize),I=(0,hl.memoized)(D=>{let F=D,{x:p,y:L}=F.toAffine(),re=p,le=L,X=n.neg(L),u=re,y=le,_=n.ONE,U=[];for(let T of O){let P=[];({Rx:u,Ry:y,Rz:_}=l(P,u,y,_)),T&&({Rx:u,Ry:y,Rz:_}=N(P,u,y,_,re,T===-1?X:le)),U.push(P)}if(t.postPrecompute){let T=U[U.length-1];t.postPrecompute(u,y,_,re,le,N.bind(null,T))}return U});function M(D,F=!1){let p=s.ONE;if(D.length){let L=D[0][0].length;for(let re=0;re<L;re++){p=s.sqr(p);for(let[le,X,u]of D)for(let[y,_,U]of le[re])p=g(y,_,U,p,X,u)}}return o&&(p=s.conjugate(p)),F?s.finalExponentiate(p):p}function A(D,F=!0){let p=[];f.ProjectivePoint.normalizeZ(D.map(({g1:L})=>L)),h.ProjectivePoint.normalizeZ(D.map(({g2:L})=>L));for(let{g1:L,g2:re}of D){if(L.equals(f.ProjectivePoint.ZERO)||re.equals(h.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");L.assertValidity(),re.assertValidity();let le=L.toAffine();p.push([I(re),le.x,le.y])}return M(p,F)}function K(D,F,p=!0){return A([{g1:D,g2:F}],p)}let E={randomPrivateKey:()=>{let D=(0,hh.getMinHashLength)(r.ORDER);return(0,hh.mapHashToField)(t.randomBytes(D),r.ORDER)},calcPairingPrecomputes:I},{ShortSignature:k}=t.G1,{Signature:G}=t.G2;function z(D){return D instanceof f.ProjectivePoint?D:f.ProjectivePoint.fromHex(D)}function q(D,F){return D instanceof f.ProjectivePoint?D:f.hashToCurve((0,hl.ensureBytes)("point",D),F)}function oe(D){return D instanceof h.ProjectivePoint?D:G.fromHex(D)}function Q(D,F){return D instanceof h.ProjectivePoint?D:h.hashToCurve((0,hl.ensureBytes)("point",D),F)}function ie(D){return f.ProjectivePoint.fromPrivateKey(D).toRawBytes(!0)}function w(D){return h.ProjectivePoint.fromPrivateKey(D).toRawBytes(!0)}function m(D,F,p){let L=Q(D,p);L.assertValidity();let re=L.multiply(f.normPrivateKeyToScalar(F));return D instanceof h.ProjectivePoint?re:G.toRawBytes(re)}function R(D,F,p){let L=q(D,p);L.assertValidity();let re=L.multiply(f.normPrivateKeyToScalar(F));return D instanceof f.ProjectivePoint?re:k.toRawBytes(re)}function S(D,F,p,L){let re=z(p),le=Q(F,L),X=f.ProjectivePoint.BASE,u=oe(D),y=A([{g1:re.negate(),g2:le},{g1:X,g2:u}]);return s.eql(y,s.ONE)}function B(D,F,p,L){let re=oe(p),le=q(F,L),X=h.ProjectivePoint.BASE,u=z(D),y=A([{g1:le,g2:re},{g1:u,g2:X.negate()}]);return s.eql(y,s.ONE)}function V(D){if(!D.length)throw new Error("Expected non-empty array");let p=D.map(z).reduce((L,re)=>L.add(re),f.ProjectivePoint.ZERO);return D[0]instanceof f.ProjectivePoint?(p.assertValidity(),p):p.toRawBytes(!0)}function J(D){if(!D.length)throw new Error("Expected non-empty array");let p=D.map(oe).reduce((L,re)=>L.add(re),h.ProjectivePoint.ZERO);return D[0]instanceof h.ProjectivePoint?(p.assertValidity(),p):G.toRawBytes(p)}function ae(D){if(!D.length)throw new Error("Expected non-empty array");let p=D.map(z).reduce((L,re)=>L.add(re),f.ProjectivePoint.ZERO);return D[0]instanceof f.ProjectivePoint?(p.assertValidity(),p):k.toRawBytes(p)}function ce(D,F,p,L){if(!F.length)throw new Error("Expected non-empty messages array");if(p.length!==F.length)throw new Error("Pubkey count should equal msg count");let re=oe(D),le=F.map(_=>Q(_,L)),X=p.map(z),u=new Map;for(let _=0;_<X.length;_++){let U=X[_],T=le[_],P=u.get(T);P===void 0&&(P=[],u.set(T,P)),P.push(U)}let y=[];try{for(let[_,U]of u){let T=U.reduce((P,H)=>P.add(H));y.push({g1:T,g2:_})}return y.push({g1:f.ProjectivePoint.BASE.negate(),g2:re}),s.eql(A(y),s.ONE)}catch{return!1}}return f.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:ie,getPublicKeyForShortSignatures:w,sign:m,signShortSignature:R,verify:S,verifyBatch:ce,verifyShortSignature:B,aggregatePublicKeys:V,aggregateSignatures:J,aggregateShortSignatures:ae,millerLoopBatch:M,pairing:K,pairingBatch:A,G1:f,G2:h,Signature:G,ShortSignature:k,fields:{Fr:r,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:t.params.ateLoopSize,r:t.params.r,G1b:t.G1.b,G2b:t.G2.b},utils:E}}});var bh=ee(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.psiFrobenius=Aw;la.tower12=Ow;var En=Mr(),yr=Dt(),Tw=BigInt(0),Si=BigInt(1),tn=BigInt(2),mh=BigInt(3);function yl(t,e,r,n,i=1,s){let o=BigInt(s===void 0?n:s),a=r**BigInt(n),c=[];for(let f=0;f<i;f++){let d=BigInt(f+1),h=[];for(let g=0,b=Si;g<n;g++){let l=(d*b-d)/o%a;h.push(t.pow(e,l)),b*=r}c.push(h)}return c}function Aw(t,e,r){let n=e.pow(r,(t.ORDER-Si)/mh),i=e.pow(r,(t.ORDER-Si)/tn);function s(g,b){let l=e.mul(e.frobeniusMap(g,1),n),N=e.mul(e.frobeniusMap(b,1),i);return[l,N]}let o=e.pow(r,(t.ORDER**tn-Si)/mh),a=e.pow(r,(t.ORDER**tn-Si)/tn);if(!e.eql(a,e.neg(e.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(g,b){return[e.mul(g,o),e.neg(b)]}let f=g=>(b,l)=>{let N=l.toAffine(),O=g(N.x,N.y);return b.fromAffine({x:O[0],y:O[1]})},d=f(s),h=f(c);return{psi:s,psi2:c,G2psi:d,G2psi2:h,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:a}}function Ow(t){let{ORDER:e}=t,r=En.Field(e),n=r.create(t.NONRESIDUE||BigInt(-1)),i=En.FpLegendre(e),s=r.div(r.ONE,tn),o=yl(r,n,r.ORDER,2)[0],a=({c0:w,c1:m},{c0:R,c1:S})=>({c0:r.add(w,R),c1:r.add(m,S)}),c=({c0:w,c1:m},{c0:R,c1:S})=>({c0:r.sub(w,R),c1:r.sub(m,S)}),f=({c0:w,c1:m},R)=>{if(typeof R=="bigint")return{c0:r.mul(w,R),c1:r.mul(m,R)};let{c0:S,c1:B}=R,V=r.mul(w,S),J=r.mul(m,B),ae=r.sub(V,J),ce=r.sub(r.mul(r.add(w,m),r.add(S,B)),r.add(V,J));return{c0:ae,c1:ce}},d=({c0:w,c1:m})=>{let R=r.add(w,m),S=r.sub(w,m),B=r.add(w,w);return{c0:r.mul(R,S),c1:r.mul(B,m)}},h=w=>{if(w.length!==2)throw new Error("Invalid tuple");let m=w.map(R=>r.create(R));return{c0:m[0],c1:m[1]}},g=e*e,b=h(t.FP2_NONRESIDUE),l={ORDER:g,NONRESIDUE:b,BITS:(0,yr.bitLen)(g),BYTES:Math.ceil((0,yr.bitLen)(g)/8),MASK:(0,yr.bitMask)((0,yr.bitLen)(g)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:w=>w,isValid:({c0:w,c1:m})=>typeof w=="bigint"&&typeof m=="bigint",is0:({c0:w,c1:m})=>r.is0(w)&&r.is0(m),eql:({c0:w,c1:m},{c0:R,c1:S})=>r.eql(w,R)&&r.eql(m,S),neg:({c0:w,c1:m})=>({c0:r.neg(w),c1:r.neg(m)}),pow:(w,m)=>En.FpPow(l,w,m),invertBatch:w=>En.FpInvertBatch(l,w),add:a,sub:c,mul:f,sqr:d,addN:a,subN:c,mulN:f,sqrN:d,div:(w,m)=>l.mul(w,typeof m=="bigint"?r.inv(r.create(m)):l.inv(m)),inv:({c0:w,c1:m})=>{let R=r.inv(r.create(w*w+m*m));return{c0:r.mul(R,r.create(w)),c1:r.mul(R,r.create(-m))}},sqrt:w=>{if(t.Fp2sqrt)return t.Fp2sqrt(w);let{c0:m,c1:R}=w;if(r.is0(R))return r.eql(i(r,m),r.ONE)?l.create({c0:r.sqrt(m),c1:r.ZERO}):l.create({c0:r.ZERO,c1:r.sqrt(r.div(m,n))});let S=r.sqrt(r.sub(r.sqr(m),r.mul(r.sqr(R),n))),B=r.mul(r.add(S,m),s),V=i(r,B);!r.is0(V)&&!r.eql(V,r.ONE)&&(B=r.sub(B,S));let J=r.sqrt(B),ae=l.create({c0:J,c1:r.div(r.mul(R,s),J)});if(!l.eql(l.sqr(ae),w))throw new Error("Cannot find square root");let ce=ae,D=l.neg(ce),{re:F,im:p}=l.reim(ce),{re:L,im:re}=l.reim(D);return p>re||p===re&&F>L?ce:D},isOdd:w=>{let{re:m,im:R}=l.reim(w),S=m%tn,B=m===Tw,V=R%tn;return BigInt(S||B&&V)==Si},fromBytes(w){if(w.length!==l.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:r.fromBytes(w.subarray(0,r.BYTES)),c1:r.fromBytes(w.subarray(r.BYTES))}},toBytes:({c0:w,c1:m})=>(0,yr.concatBytes)(r.toBytes(w),r.toBytes(m)),cmov:({c0:w,c1:m},{c0:R,c1:S},B)=>({c0:r.cmov(w,R,B),c1:r.cmov(m,S,B)}),reim:({c0:w,c1:m})=>({re:w,im:m}),mulByNonresidue:({c0:w,c1:m})=>l.mul({c0:w,c1:m},b),mulByB:t.Fp2mulByB,fromBigTuple:h,frobeniusMap:({c0:w,c1:m},R)=>({c0:w,c1:r.mul(m,o[R%2])})},N=({c0:w,c1:m,c2:R},{c0:S,c1:B,c2:V})=>({c0:l.add(w,S),c1:l.add(m,B),c2:l.add(R,V)}),O=({c0:w,c1:m,c2:R},{c0:S,c1:B,c2:V})=>({c0:l.sub(w,S),c1:l.sub(m,B),c2:l.sub(R,V)}),I=({c0:w,c1:m,c2:R},S)=>{if(typeof S=="bigint")return{c0:l.mul(w,S),c1:l.mul(m,S),c2:l.mul(R,S)};let{c0:B,c1:V,c2:J}=S,ae=l.mul(w,B),ce=l.mul(m,V),D=l.mul(R,J);return{c0:l.add(ae,l.mulByNonresidue(l.sub(l.mul(l.add(m,R),l.add(V,J)),l.add(ce,D)))),c1:l.add(l.sub(l.mul(l.add(w,m),l.add(B,V)),l.add(ae,ce)),l.mulByNonresidue(D)),c2:l.sub(l.add(ce,l.mul(l.add(w,R),l.add(B,J))),l.add(ae,D))}},M=({c0:w,c1:m,c2:R})=>{let S=l.sqr(w),B=l.mul(l.mul(w,m),tn),V=l.mul(l.mul(m,R),tn),J=l.sqr(R);return{c0:l.add(l.mulByNonresidue(V),S),c1:l.add(l.mulByNonresidue(J),B),c2:l.sub(l.sub(l.add(l.add(B,l.sqr(l.add(l.sub(w,m),R))),V),S),J)}},[A,K]=yl(l,b,r.ORDER,6,2,3),E={ORDER:l.ORDER,BITS:3*l.BITS,BYTES:3*l.BYTES,MASK:(0,yr.bitMask)(3*l.BITS),ZERO:{c0:l.ZERO,c1:l.ZERO,c2:l.ZERO},ONE:{c0:l.ONE,c1:l.ZERO,c2:l.ZERO},create:w=>w,isValid:({c0:w,c1:m,c2:R})=>l.isValid(w)&&l.isValid(m)&&l.isValid(R),is0:({c0:w,c1:m,c2:R})=>l.is0(w)&&l.is0(m)&&l.is0(R),neg:({c0:w,c1:m,c2:R})=>({c0:l.neg(w),c1:l.neg(m),c2:l.neg(R)}),eql:({c0:w,c1:m,c2:R},{c0:S,c1:B,c2:V})=>l.eql(w,S)&&l.eql(m,B)&&l.eql(R,V),sqrt:yr.notImplemented,div:(w,m)=>E.mul(w,typeof m=="bigint"?r.inv(r.create(m)):E.inv(m)),pow:(w,m)=>En.FpPow(E,w,m),invertBatch:w=>En.FpInvertBatch(E,w),add:N,sub:O,mul:I,sqr:M,addN:N,subN:O,mulN:I,sqrN:M,inv:({c0:w,c1:m,c2:R})=>{let S=l.sub(l.sqr(w),l.mulByNonresidue(l.mul(R,m))),B=l.sub(l.mulByNonresidue(l.sqr(R)),l.mul(w,m)),V=l.sub(l.sqr(m),l.mul(w,R)),J=l.inv(l.add(l.mulByNonresidue(l.add(l.mul(R,B),l.mul(m,V))),l.mul(w,S)));return{c0:l.mul(J,S),c1:l.mul(J,B),c2:l.mul(J,V)}},fromBytes:w=>{if(w.length!==E.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:l.fromBytes(w.subarray(0,l.BYTES)),c1:l.fromBytes(w.subarray(l.BYTES,2*l.BYTES)),c2:l.fromBytes(w.subarray(2*l.BYTES))}},toBytes:({c0:w,c1:m,c2:R})=>(0,yr.concatBytes)(l.toBytes(w),l.toBytes(m),l.toBytes(R)),cmov:({c0:w,c1:m,c2:R},{c0:S,c1:B,c2:V},J)=>({c0:l.cmov(w,S,J),c1:l.cmov(m,B,J),c2:l.cmov(R,V,J)}),fromBigSix:w=>{if(!Array.isArray(w)||w.length!==6)throw new Error("Invalid Fp6 usage");return{c0:l.fromBigTuple(w.slice(0,2)),c1:l.fromBigTuple(w.slice(2,4)),c2:l.fromBigTuple(w.slice(4,6))}},frobeniusMap:({c0:w,c1:m,c2:R},S)=>({c0:l.frobeniusMap(w,S),c1:l.mul(l.frobeniusMap(m,S),A[S%6]),c2:l.mul(l.frobeniusMap(R,S),K[S%6])}),mulByFp2:({c0:w,c1:m,c2:R},S)=>({c0:l.mul(w,S),c1:l.mul(m,S),c2:l.mul(R,S)}),mulByNonresidue:({c0:w,c1:m,c2:R})=>({c0:l.mulByNonresidue(R),c1:w,c2:m}),mul1:({c0:w,c1:m,c2:R},S)=>({c0:l.mulByNonresidue(l.mul(R,S)),c1:l.mul(w,S),c2:l.mul(m,S)}),mul01({c0:w,c1:m,c2:R},S,B){let V=l.mul(w,S),J=l.mul(m,B);return{c0:l.add(l.mulByNonresidue(l.sub(l.mul(l.add(m,R),B),J)),V),c1:l.sub(l.sub(l.mul(l.add(S,B),l.add(w,m)),V),J),c2:l.add(l.sub(l.mul(l.add(w,R),S),V),J)}}},k=yl(l,b,r.ORDER,12,1,6)[0],G=({c0:w,c1:m},{c0:R,c1:S})=>({c0:E.add(w,R),c1:E.add(m,S)}),z=({c0:w,c1:m},{c0:R,c1:S})=>({c0:E.sub(w,R),c1:E.sub(m,S)}),q=({c0:w,c1:m},R)=>{if(typeof R=="bigint")return{c0:E.mul(w,R),c1:E.mul(m,R)};let{c0:S,c1:B}=R,V=E.mul(w,S),J=E.mul(m,B);return{c0:E.add(V,E.mulByNonresidue(J)),c1:E.sub(E.mul(E.add(w,m),E.add(S,B)),E.add(V,J))}},oe=({c0:w,c1:m})=>{let R=E.mul(w,m);return{c0:E.sub(E.sub(E.mul(E.add(E.mulByNonresidue(m),w),E.add(w,m)),R),E.mulByNonresidue(R)),c1:E.add(R,R)}};function Q(w,m){let R=l.sqr(w),S=l.sqr(m);return{first:l.add(l.mulByNonresidue(S),R),second:l.sub(l.sub(l.sqr(l.add(w,m)),R),S)}}let ie={ORDER:l.ORDER,BITS:2*l.BITS,BYTES:2*l.BYTES,MASK:(0,yr.bitMask)(2*l.BITS),ZERO:{c0:E.ZERO,c1:E.ZERO},ONE:{c0:E.ONE,c1:E.ZERO},create:w=>w,isValid:({c0:w,c1:m})=>E.isValid(w)&&E.isValid(m),is0:({c0:w,c1:m})=>E.is0(w)&&E.is0(m),neg:({c0:w,c1:m})=>({c0:E.neg(w),c1:E.neg(m)}),eql:({c0:w,c1:m},{c0:R,c1:S})=>E.eql(w,R)&&E.eql(m,S),sqrt:yr.notImplemented,inv:({c0:w,c1:m})=>{let R=E.inv(E.sub(E.sqr(w),E.mulByNonresidue(E.sqr(m))));return{c0:E.mul(w,R),c1:E.neg(E.mul(m,R))}},div:(w,m)=>ie.mul(w,typeof m=="bigint"?r.inv(r.create(m)):ie.inv(m)),pow:(w,m)=>En.FpPow(ie,w,m),invertBatch:w=>En.FpInvertBatch(ie,w),add:G,sub:z,mul:q,sqr:oe,addN:G,subN:z,mulN:q,sqrN:oe,fromBytes:w=>{if(w.length!==ie.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:E.fromBytes(w.subarray(0,E.BYTES)),c1:E.fromBytes(w.subarray(E.BYTES))}},toBytes:({c0:w,c1:m})=>(0,yr.concatBytes)(E.toBytes(w),E.toBytes(m)),cmov:({c0:w,c1:m},{c0:R,c1:S},B)=>({c0:E.cmov(w,R,B),c1:E.cmov(m,S,B)}),fromBigTwelve:w=>({c0:E.fromBigSix(w.slice(0,6)),c1:E.fromBigSix(w.slice(6,12))}),frobeniusMap(w,m){let{c0:R,c1:S,c2:B}=E.frobeniusMap(w.c1,m),V=k[m%12];return{c0:E.frobeniusMap(w.c0,m),c1:E.create({c0:l.mul(R,V),c1:l.mul(S,V),c2:l.mul(B,V)})}},mulByFp2:({c0:w,c1:m},R)=>({c0:E.mulByFp2(w,R),c1:E.mulByFp2(m,R)}),conjugate:({c0:w,c1:m})=>({c0:w,c1:E.neg(m)}),mul014:({c0:w,c1:m},R,S,B)=>{let V=E.mul01(w,R,S),J=E.mul1(m,B);return{c0:E.add(E.mulByNonresidue(J),V),c1:E.sub(E.sub(E.mul01(E.add(m,w),R,l.add(S,B)),V),J)}},mul034:({c0:w,c1:m},R,S,B)=>{let V=E.create({c0:l.mul(w.c0,R),c1:l.mul(w.c1,R),c2:l.mul(w.c2,R)}),J=E.mul01(m,S,B),ae=E.mul01(E.add(w,m),l.add(R,S),B);return{c0:E.add(E.mulByNonresidue(J),V),c1:E.sub(ae,E.add(V,J))}},_cyclotomicSquare:t.Fp12cyclotomicSquare,_cyclotomicExp:t.Fp12cyclotomicExp,finalExponentiate:t.Fp12finalExponentiate};return{Fp:r,Fp2:l,Fp6:E,Fp4Square:Q,Fp12:ie}}});var Nh=ee(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.bls12_381=void 0;var Th=po(),Sw=kn(),Nw=gh(),Rw=Mr(),Se=Dt(),Ah=oa(),Oh=dl(),Sh=bh(),Ft=BigInt(0),ha=BigInt(1),pt=BigInt(2),fa=BigInt(3),bs=BigInt(4),xn=BigInt("0xd201000000010000"),Bw=(0,Se.bitLen)(xn),{Fp:de,Fp2:pe,Fp6:ml,Fp4Square:_l,Fp12:ve}=(0,Sh.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[ha,ha],Fp2mulByB:({c0:t,c1:e})=>{let r=de.mul(t,bs),n=de.mul(e,bs);return{c0:de.sub(r,n),c1:de.add(r,n)}},Fp12cyclotomicSquare:({c0:t,c1:e})=>{let{c0:r,c1:n,c2:i}=t,{c0:s,c1:o,c2:a}=e,{first:c,second:f}=_l(r,o),{first:d,second:h}=_l(s,i),{first:g,second:b}=_l(n,a),l=pe.mulByNonresidue(b);return{c0:ml.create({c0:pe.add(pe.mul(pe.sub(c,r),pt),c),c1:pe.add(pe.mul(pe.sub(d,n),pt),d),c2:pe.add(pe.mul(pe.sub(g,i),pt),g)}),c1:ml.create({c0:pe.add(pe.mul(pe.add(l,s),pt),l),c1:pe.add(pe.mul(pe.add(f,o),pt),f),c2:pe.add(pe.mul(pe.add(h,a),pt),h)})}},Fp12cyclotomicExp(t,e){let r=ve.ONE;for(let n=Bw-1;n>=0;n--)r=ve._cyclotomicSquare(r),(0,Se.bitGet)(e,n)&&(r=ve.mul(r,t));return r},Fp12finalExponentiate:t=>{let e=xn,r=ve.div(ve.frobeniusMap(t,6),t),n=ve.mul(ve.frobeniusMap(r,2),r),i=ve.conjugate(ve._cyclotomicExp(n,e)),s=ve.mul(ve.conjugate(ve._cyclotomicSquare(n)),i),o=ve.conjugate(ve._cyclotomicExp(s,e)),a=ve.conjugate(ve._cyclotomicExp(o,e)),c=ve.mul(ve.conjugate(ve._cyclotomicExp(a,e)),ve._cyclotomicSquare(i)),f=ve.conjugate(ve._cyclotomicExp(c,e)),d=ve.frobeniusMap(ve.mul(i,a),2),h=ve.frobeniusMap(ve.mul(o,n),3),g=ve.frobeniusMap(ve.mul(c,ve.conjugate(n)),1),b=ve.mul(ve.mul(f,ve.conjugate(s)),n);return ve.mul(ve.mul(ve.mul(d,h),g),b)}}),wh=Rw.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),Pw=(0,Ah.isogenyMap)(pe,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(t=>t.map(e=>pe.fromBigTuple(e.map(BigInt))))),Uw=(0,Ah.isogenyMap)(de,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(e=>BigInt(e)))),Iw=(0,Oh.mapToCurveSimpleSWU)(pe,{A:pe.create({c0:de.create(Ft),c1:de.create(BigInt(240))}),B:pe.create({c0:de.create(BigInt(1012)),c1:de.create(BigInt(1012))}),Z:pe.create({c0:de.create(BigInt(-2)),c1:de.create(BigInt(-1))})}),Cw=(0,Oh.mapToCurveSimpleSWU)(de,{A:de.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:de.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:de.create(BigInt(11))}),{G2psi:Eh,G2psi2:Fw}=(0,Sh.psiFrobenius)(de,pe,pe.div(pe.ONE,pe.NONRESIDUE)),gl=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:de.ORDER,m:2,k:128,expand:"xmd",hash:Th.sha256}),pa=ws(de.toBytes(Ft),{infinity:!0,compressed:!0});function da(t){t=t.slice();let e=t[0]&224,r=!!(e>>7&1),n=!!(e>>6&1),i=!!(e>>5&1);return t[0]&=31,{compressed:r,infinity:n,sort:i,value:t}}function ws(t,e){if(t[0]&224)throw new Error("setMask: non-empty mask");return e.compressed&&(t[0]|=128),e.infinity&&(t[0]|=64),e.sort&&(t[0]|=32),t}function xh(t){t.assertValidity();let e=t.equals(Mt.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return pa.slice();let i=de.ORDER,s=!!(n*pt/i);return ws((0,Se.numberToBytesBE)(r,de.BYTES),{compressed:!0,sort:s})}function vh(t){t.assertValidity();let e=de.BYTES;if(t.equals(Mt.bls12_381.G2.ProjectivePoint.ZERO))return(0,Se.concatBytes)(pa,(0,Se.numberToBytesBE)(Ft,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=pe.reim(r),{re:o,im:a}=pe.reim(n),f=!!((a>Ft?a*pt:o*pt)/de.ORDER&ha),d=i;return(0,Se.concatBytes)(ws((0,Se.numberToBytesBE)(s,e),{sort:f,compressed:!0}),(0,Se.numberToBytesBE)(d,e))}Mt.bls12_381=(0,Nw.bls)({fields:{Fp:de,Fp2:pe,Fp6:ml,Fp12:ve,Fr:wh},G1:{Fp:de,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:de.ZERO,b:bs,htfDefaults:{...gl,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(t,e)=>{let r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new t(de.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(xn).negate().multiplyUnsafe(xn).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(xn).add(e),mapToCurve:t=>{let{x:e,y:r}=Cw(de.create(t[0]));return Uw(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=da(t);if(i.length===48&&e){let s=de.ORDER,o=(0,Se.bytesToNumberBE)(i),a=de.create(o&de.MASK);if(r){if(a!==Ft)throw new Error("G1: non-empty compressed point at infinity");return{x:Ft,y:Ft}}let c=de.add(de.pow(a,fa),de.create(Mt.bls12_381.params.G1b)),f=de.sqrt(c);if(!f)throw new Error("Invalid compressed G1 point");return f*pt/s!==BigInt(n)&&(f=de.neg(f)),{x:de.create(a),y:de.create(f)}}else if(i.length===96&&!e){let s=(0,Se.bytesToNumberBE)(i.subarray(0,de.BYTES)),o=(0,Se.bytesToNumberBE)(i.subarray(de.BYTES));if(r){if(s!==Ft||o!==Ft)throw new Error("G1: non-empty point at infinity");return Mt.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:de.create(s),y:de.create(o)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(t,e,r)=>{let n=e.equals(t.ZERO),{x:i,y:s}=e.toAffine();if(r){if(n)return pa.slice();let o=de.ORDER,a=!!(s*pt/o);return ws((0,Se.numberToBytesBE)(i,de.BYTES),{compressed:!0,sort:a})}else return n?(0,Se.concatBytes)(new Uint8Array([64]),new Uint8Array(2*de.BYTES-1)):(0,Se.concatBytes)((0,Se.numberToBytesBE)(i,de.BYTES),(0,Se.numberToBytesBE)(s,de.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=da((0,Se.ensureBytes)("signatureHex",t,48)),i=de.ORDER,s=(0,Se.bytesToNumberBE)(n);if(e)return Mt.bls12_381.G1.ProjectivePoint.ZERO;let o=de.create(s&de.MASK),a=de.add(de.pow(o,fa),de.create(Mt.bls12_381.params.G1b)),c=de.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let f=BigInt(r);c*pt/i!==f&&(c=de.neg(c));let d=Mt.bls12_381.G1.ProjectivePoint.fromAffine({x:o,y:c});return d.assertValidity(),d},toRawBytes(t){return xh(t)},toHex(t){return(0,Se.bytesToHex)(xh(t))}}},G2:{Fp:pe,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:pe.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:pe.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:pe.ZERO,b:pe.fromBigTuple([bs,bs]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...gl},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=Iw(pe.fromBigTuple(t));return Pw(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(xn).negate().equals(Eh(t,e)),clearCofactor:(t,e)=>{let r=xn,n=e.multiplyUnsafe(r).negate(),i=Eh(t,e),s=e.double();return s=Fw(t,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),s=s.add(i),s=s.subtract(n),s.subtract(e)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=da(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=de.BYTES,o=(a,c,f)=>(0,Se.bytesToNumberBE)(a.slice(c,f));if(i.length===96&&e){let a=Mt.bls12_381.params.G2b,c=de.ORDER;if(r){if(i.reduce((N,O)=>N!==0?O+1:O,0)>0)throw new Error("Invalid compressed G2 point");return{x:pe.ZERO,y:pe.ZERO}}let f=o(i,0,s),d=o(i,s,2*s),h=pe.create({c0:de.create(d),c1:de.create(f)}),g=pe.add(pe.pow(h,fa),a),b=pe.sqrt(g),l=b.c1===Ft?b.c0*pt/c:b.c1*pt/c?ha:Ft;return b=n&&l>0?b:pe.neg(b),{x:h,y:b}}else if(i.length===192&&!e){if(r){if(i.reduce((h,g)=>h!==0?g+1:g,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:pe.ZERO,y:pe.ZERO}}let a=o(i,0,s),c=o(i,s,2*s),f=o(i,2*s,3*s),d=o(i,3*s,4*s);return{x:pe.fromBigTuple([c,a]),y:pe.fromBigTuple([d,f])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(t,e,r)=>{let{BYTES:n,ORDER:i}=de,s=e.equals(t.ZERO),{x:o,y:a}=e.toAffine();if(r){if(s)return(0,Se.concatBytes)(pa,(0,Se.numberToBytesBE)(Ft,n));let c=!!(a.c1===Ft?a.c0*pt/i:a.c1*pt/i);return(0,Se.concatBytes)(ws((0,Se.numberToBytesBE)(o.c1,n),{compressed:!0,sort:c}),(0,Se.numberToBytesBE)(o.c0,n))}else{if(s)return(0,Se.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:f}=pe.reim(o),{re:d,im:h}=pe.reim(a);return(0,Se.concatBytes)((0,Se.numberToBytesBE)(f,n),(0,Se.numberToBytesBE)(c,n),(0,Se.numberToBytesBE)(h,n),(0,Se.numberToBytesBE)(d,n))}},Signature:{fromHex(t){let{infinity:e,sort:r,value:n}=da((0,Se.ensureBytes)("signatureHex",t)),i=de.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=(0,Se.bytesToNumberBE)(n.slice(0,s)),a=(0,Se.bytesToNumberBE)(n.slice(s));if(e)return Mt.bls12_381.G2.ProjectivePoint.ZERO;let c=de.create(o&de.MASK),f=de.create(a),d=pe.create({c0:f,c1:c}),h=pe.add(pe.pow(d,fa),Mt.bls12_381.params.G2b),g=pe.sqrt(h);if(!g)throw new Error("Failed to find a square root");let{re:b,im:l}=pe.reim(g),N=BigInt(r),O=l>Ft&&l*pt/i!==N,I=l===Ft&&b*pt/i!==N;(O||I)&&(g=pe.neg(g));let M=Mt.bls12_381.G2.ProjectivePoint.fromAffine({x:d,y:g});return M.assertValidity(),M},toRawBytes(t){return vh(t)},toHex(t){return(0,Se.bytesToHex)(vh(t))}}},params:{ateLoopSize:xn,r:wh.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:gl,hash:Th.sha256,randomBytes:Sw.randomBytes})});var wl=ee(Es=>{"use strict";Object.defineProperty(Es,"__esModule",{value:!0});Es.blsVerify=Es.verify=void 0;var Mw=Nh(),bl=Ht();function qw(t,e,r){let n=typeof t=="string"?t:(0,bl.toHex)(t),i=typeof e=="string"?e:(0,bl.toHex)(e),s=typeof r=="string"?r:(0,bl.toHex)(r);return Mw.bls12_381.verifyShortSignature(i,s,n)}Es.blsVerify=qw});var ya=ee(Yn=>{"use strict";Object.defineProperty(Yn,"__esModule",{value:!0});Yn.decodeTime=Yn.decodeLeb128=void 0;var Rh=xi(),jw=t=>(0,Rh.lebDecode)(new Rh.PipeArrayBuffer(t));Yn.decodeLeb128=jw;var kw=t=>{let e=(0,Yn.decodeLeb128)(t);return new Date(Number(e)/1e6)};Yn.decodeTime=kw});var Ni=ee(Te=>{"use strict";var Vw=Te&&Te.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Hw=Te&&Te.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Bh=Te&&Te.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Vw(e,t,r);return Hw(e,t),e},$w=Te&&Te.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Kw=Te&&Te.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ga;Object.defineProperty(Te,"__esModule",{value:!0});Te.check_canister_ranges=Te.find_label=Te.flatten_forks=Te.lookup_path=Te.LookupStatus=Te.reconstruct=Te.lookupResultToBuffer=Te.Certificate=Te.hashTreeToString=Te.NodeType=Te.CertificateVerificationError=void 0;var Ph=Bh(ys()),Gw=yi(),_a=ds(),_r=Ht(),El=It(),Yw=Bh(wl()),Ww=ya(),zw=Os(),rn=class extends Gw.AgentError{constructor(e){super(`Invalid certificate: ${e}`)}};Te.CertificateVerificationError=rn;var Et;(function(t){t[t.Empty=0]="Empty",t[t.Fork=1]="Fork",t[t.Labeled=2]="Labeled",t[t.Leaf=3]="Leaf",t[t.Pruned=4]="Pruned"})(Et=Te.NodeType||(Te.NodeType={}));function ma(t){let e=n=>n.split(`
|
|
18
18
|
`).map(i=>" "+i).join(`
|
|
19
19
|
`);function r(n){let i=new TextDecoder(void 0,{fatal:!0});try{return JSON.stringify(i.decode(n))}catch{return`data(...${n.byteLength} bytes)`}}switch(t[0]){case Et.Empty:return"()";case Et.Fork:if(t[1]instanceof Array&&t[2]instanceof ArrayBuffer){let n=ma(t[1]),i=ma(t[2]);return`sub(
|
|
20
20
|
left:
|
|
@@ -27,34 +27,34 @@ ${e(i)}
|
|
|
27
27
|
${e(n)}
|
|
28
28
|
sub:
|
|
29
29
|
${e(i)}
|
|
30
|
-
)`}else throw new Error("Invalid tree structure for labeled");case Et.Leaf:{if(t[1]){if(Array.isArray(t[1]))return JSON.stringify(t[1])}else throw new Error("Invalid tree structure for leaf");return`leaf(...${t[1].byteLength} bytes)`}case Et.Pruned:{if(t[1]){if(Array.isArray(t[1]))return JSON.stringify(t[1])}else throw new Error("Invalid tree structure for pruned");return`pruned(${(0,yr.toHex)(new Uint8Array(t[1]))}`}default:return`unknown(${JSON.stringify(t[0])})`}}Te.hashTreeToString=ma;function Dw(t,e){let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]>n[i])return!0;return!1}var xl=class t{constructor(e,r,n,i,s=5,o=!1){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,ga.set(this,!1),$w(this,ga,o,"f"),this.cert=Bh.decode(new Uint8Array(e))}static async create(e){let r=t.createUnverified(e);return await r.verify(),r}static createUnverified(e){let r=e.blsVerify;return r||(r=Yw.blsVerify),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes,e.disableTimeVerification)}lookup(e){return ba(e,this.cert.tree)}lookup_label(e){return this.lookup([e])}async verify(){let e=await Ts(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=Zw(r),s=(0,yr.concat)(vs("ic-state-root"),e),o=!1,a=vl(this.lookup(["time"]));if(!a)throw new tn("Certificate does not contain a time");if(!Kw(this,ga,"f")){let f=this._maxAgeInMinutes*60*1e3,d=Date.now(),h=d-f,g=d+3e5,b=(0,Ww.decodeTime)(a);if(b.getTime()<h)throw new tn(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+b.toISOString()+" Current time: "+new Date(d).toISOString());if(b.getTime()>g)throw new tn("Certificate is signed more than 5 minutes in the future. Certificate time: "+b.toISOString()+" Current time: "+new Date(d).toISOString())}try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new tn("Signature verification failed")}async _checkDelegationAndGetKey(e){if(!e)return this._rootKey;let r=await t.createUnverified({certificate:e.certificate,rootKey:this._rootKey,canisterId:this._canisterId,blsVerify:this._blsVerify,maxAgeInMinutes:1/0});if(r.cert.delegation)throw new tn("Delegation certificates cannot be nested");if(await r.verify(),this._canisterId.toString()!==zw.MANAGEMENT_CANISTER_ID&&!Ph({canisterId:this._canisterId,subnetId:El.Principal.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new tn(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,yr.toHex)(e.subnet_id)}`);let n=vl(r.lookup(["subnet",e.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${(0,yr.toHex)(e.subnet_id)}`);return n}};Te.Certificate=xl;ga=new WeakMap;var xs=(0,yr.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Jw=96;function Zw(t){let e=xs.byteLength+Jw;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,xs.byteLength);if(!(0,yr.bufEquals)(r,xs))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${xs}, but get ${r}`);return t.slice(xs.byteLength)}function vl(t){if(t.status===qt.Found){if(t.value instanceof ArrayBuffer)return t.value;if(t.value instanceof Uint8Array)return t.value.buffer}}Te.lookupResultToBuffer=vl;async function Ts(t){switch(t[0]){case Et.Empty:return(0,_a.hash)(vs("ic-hashtree-empty"));case Et.Pruned:return t[1];case Et.Leaf:return(0,_a.hash)((0,yr.concat)(vs("ic-hashtree-leaf"),t[1]));case Et.Labeled:return(0,_a.hash)((0,yr.concat)(vs("ic-hashtree-labeled"),t[1],await Ts(t[2])));case Et.Fork:return(0,_a.hash)((0,yr.concat)(vs("ic-hashtree-fork"),await Ts(t[1]),await Ts(t[2])));default:throw new Error("unreachable")}}Te.reconstruct=Ts;function vs(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return(0,yr.concat)(e,r)}var qt;(function(t){t.Unknown="unknown",t.Absent="absent",t.Found="found"})(qt=Te.LookupStatus||(Te.LookupStatus={}));var rn;(function(t){t.Less="less",t.Greater="greater"})(rn||(rn={}));function ba(t,e){if(t.length===0)switch(e[0]){case Et.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?{status:qt.Found,value:e[1]}:e[1]instanceof Uint8Array?{status:qt.Found,value:e[1].buffer}:{status:qt.Found,value:e[1]}}default:return{status:qt.Found,value:e}}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=As(r,e);switch(n.status){case qt.Found:return ba(t.slice(1),n.value);case rn.Greater:case rn.Less:return{status:qt.Absent};default:return n}}Te.lookup_path=ba;function Tl(t){switch(t[0]){case Et.Empty:return[];case Et.Fork:return Tl(t[1]).concat(Tl(t[2]));default:return[t]}}Te.flatten_forks=Tl;function As(t,e){switch(e[0]){case Et.Labeled:return Dw(t,e[1])?{status:rn.Greater}:(0,yr.bufEquals)(t,e[1])?{status:qt.Found,value:e[2]}:{status:rn.Less};case Et.Fork:let r=As(t,e[1]);switch(r.status){case rn.Greater:{let n=As(t,e[2]);return n.status===rn.Less?{status:qt.Absent}:n}case qt.Unknown:{let n=As(t,e[2]);return n.status===rn.Less?{status:qt.Unknown}:n}default:return r}case Et.Pruned:return{status:qt.Unknown};default:return{status:qt.Absent}}}Te.find_label=As;function Ph(t){let{canisterId:e,subnetId:r,tree:n}=t,i=ba(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==qt.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return Bh.decode(i.value).map(c=>[El.Principal.fromUint8Array(c[0]),El.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}Te.check_canister_ranges=Ph});var Ss=ee(ut=>{"use strict";var Xw=ut&&ut.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Qw=ut&&ut.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Lw=ut&&ut.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Xw(e,t,r);return Qw(e,t),e};Object.defineProperty(ut,"__esModule",{value:!0});ut.encodePath=ut.fetchNodeKeys=ut.request=ut.CustomPath=void 0;var vn=It(),e2=yi(),Tn=Ni(),t2=Ht(),Ch=Lw(ys()),Uh=ya(),Al=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}};ut.CustomPath=Al;var r2=async t=>{let{agent:e,paths:r}=t,n=vn.Principal.from(t.canisterId),i=[...new Set(r)],s=i.map(c=>(0,ut.encodePath)(c,n)),o=new Map,a=i.map((c,f)=>(async()=>{var d;try{let h=await e.readState(n,{paths:[s[f]]});if(e.rootKey==null)throw new Error("Agent is missing root key");let g=await Tn.Certificate.create({certificate:h.certificate,rootKey:e.rootKey,canisterId:n,disableTimeVerification:!0}),b=(O,I)=>{if(I==="subnet"){if(e.rootKey==null)throw new Error("Agent is missing root key");let M=(0,ut.fetchNodeKeys)(h.certificate,n,e.rootKey);return{path:I,data:M}}else return{path:I,data:(0,Tn.lookupResultToBuffer)(O.lookup((0,ut.encodePath)(I,n)))}},{path:l,data:N}=b(g,i[f]);if(!N)console.warn(`Expected to find result for path ${l}, but instead found nothing.`),typeof l=="string"?o.set(l,null):o.set(l.key,null);else switch(l){case"time":{o.set(l,(0,Uh.decodeTime)(N));break}case"controllers":{o.set(l,o2(N));break}case"module_hash":{o.set(l,Ih(N));break}case"subnet":{o.set(l,N);break}case"candid":{o.set(l,new TextDecoder().decode(N));break}default:if(typeof l!="string"&&"key"in l&&"path"in l)switch(l.decodeStrategy){case"raw":o.set(l.key,N);break;case"leb128":{o.set(l.key,(0,Uh.decodeLeb128)(N));break}case"cbor":{o.set(l.key,Fh(N));break}case"hex":{o.set(l.key,Ih(N));break}case"utf-8":o.set(l.key,s2(N))}}}catch(h){if(!((d=h?.message)===null||d===void 0)&&d.includes("Invalid certificate"))throw new e2.AgentError(h.message);typeof c!="string"&&"key"in c&&"path"in c?o.set(c.key,null):o.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(h),console.groupEnd()}})());return await Promise.all(a),o};ut.request=r2;var n2=(t,e,r)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=Ch.decode(new Uint8Array(t)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=vn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=vn.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=vn.Principal.selfAuthenticating(vn.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,Tn.check_canister_ranges)({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=(0,Tn.lookup_path)(["subnet",s.subnet_id,"node"],i);if(c.status!==Tn.LookupStatus.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let f=(0,Tn.flatten_forks)(c.value),d=new Map;return f.forEach(h=>{let g=vn.Principal.from(new Uint8Array(h[1])).toText(),b=(0,Tn.lookup_path)(["public_key"],h[2]);if(b.status!==Tn.LookupStatus.Found)throw new Error("Public key not found");let l=b.value;if(l.byteLength!==44)throw new Error("Invalid public key length");d.set(g,l)}),{subnetId:vn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:d}};ut.fetchNodeKeys=n2;var i2=(t,e)=>{let r=new TextEncoder,n=s=>new DataView(r.encode(s).buffer).buffer,i=new DataView(e.toUint8Array().buffer).buffer;switch(t){case"time":return[n("time")];case"controllers":return[n("canister"),i,n("controllers")];case"module_hash":return[n("canister"),i,n("module_hash")];case"subnet":return[n("subnet")];case"candid":return[n("canister"),i,n("metadata"),n("candid:service")];default:if("key"in t&&"path"in t)if(typeof t.path=="string"||t.path instanceof ArrayBuffer){let s=t.path,o=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),o]}else return t.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${t} was formatted correctly.`)};ut.encodePath=i2;var Ih=t=>(0,t2.toHex)(t),Fh=t=>Ch.decode(t),s2=t=>new TextDecoder().decode(t),o2=t=>Fh(t).map(r=>vn.Principal.fromUint8Array(new Uint8Array(r)))});var np=ee(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.add5L=_e.add5H=_e.add4H=_e.add4L=_e.add3H=_e.add3L=_e.rotlBL=_e.rotlBH=_e.rotlSL=_e.rotlSH=_e.rotr32L=_e.rotr32H=_e.rotrBL=_e.rotrBH=_e.rotrSL=_e.rotrSH=_e.shrSL=_e.shrSH=_e.toBig=void 0;_e.fromBig=Sl;_e.split=Mh;_e.add=Zh;var wa=BigInt(2**32-1),Ol=BigInt(32);function Sl(t,e=!1){return e?{h:Number(t&wa),l:Number(t>>Ol&wa)}:{h:Number(t>>Ol&wa)|0,l:Number(t&wa)|0}}function Mh(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:s,l:o}=Sl(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}var qh=(t,e)=>BigInt(t>>>0)<<Ol|BigInt(e>>>0);_e.toBig=qh;var jh=(t,e,r)=>t>>>r;_e.shrSH=jh;var kh=(t,e,r)=>t<<32-r|e>>>r;_e.shrSL=kh;var Vh=(t,e,r)=>t>>>r|e<<32-r;_e.rotrSH=Vh;var Hh=(t,e,r)=>t<<32-r|e>>>r;_e.rotrSL=Hh;var $h=(t,e,r)=>t<<64-r|e>>>r-32;_e.rotrBH=$h;var Kh=(t,e,r)=>t>>>r-32|e<<64-r;_e.rotrBL=Kh;var Gh=(t,e)=>e;_e.rotr32H=Gh;var Yh=(t,e)=>t;_e.rotr32L=Yh;var Wh=(t,e,r)=>t<<r|e>>>32-r;_e.rotlSH=Wh;var zh=(t,e,r)=>e<<r|t>>>32-r;_e.rotlSL=zh;var Dh=(t,e,r)=>e<<r-32|t>>>64-r;_e.rotlBH=Dh;var Jh=(t,e,r)=>t<<r-32|e>>>64-r;_e.rotlBL=Jh;function Zh(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var Xh=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);_e.add3L=Xh;var Qh=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;_e.add3H=Qh;var Lh=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);_e.add4L=Lh;var ep=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;_e.add4H=ep;var tp=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);_e.add5L=tp;var rp=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;_e.add5H=rp;var a2={fromBig:Sl,split:Mh,toBig:qh,shrSH:jh,shrSL:kh,rotrSH:Vh,rotrSL:Hh,rotrBH:$h,rotrBL:Kh,rotr32H:Gh,rotr32L:Yh,rotlSH:Wh,rotlSL:zh,rotlBH:Dh,rotlBL:Jh,add:Zh,add3L:Xh,add3H:Qh,add4L:Lh,add4H:ep,add5H:rp,add5L:tp};_e.default=a2});var ip=ee(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.sha384=yt.sha512_256=yt.sha512_224=yt.sha512=yt.SHA384=yt.SHA512_256=yt.SHA512_224=yt.SHA512=void 0;var c2=zc(),be=np(),Ta=kn(),[u2,l2]=be.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),An=new Uint32Array(80),On=new Uint32Array(80),Wn=class extends c2.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:f,El:d,Fh:h,Fl:g,Gh:b,Gl:l,Hh:N,Hl:O}=this;return[e,r,n,i,s,o,a,c,f,d,h,g,b,l,N,O]}set(e,r,n,i,s,o,a,c,f,d,h,g,b,l,N,O){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=d|0,this.Fh=h|0,this.Fl=g|0,this.Gh=b|0,this.Gl=l|0,this.Hh=N|0,this.Hl=O|0}process(e,r){for(let A=0;A<16;A++,r+=4)An[A]=e.getUint32(r),On[A]=e.getUint32(r+=4);for(let A=16;A<80;A++){let K=An[A-15]|0,E=On[A-15]|0,k=be.default.rotrSH(K,E,1)^be.default.rotrSH(K,E,8)^be.default.shrSH(K,E,7),G=be.default.rotrSL(K,E,1)^be.default.rotrSL(K,E,8)^be.default.shrSL(K,E,7),z=An[A-2]|0,q=On[A-2]|0,oe=be.default.rotrSH(z,q,19)^be.default.rotrBH(z,q,61)^be.default.shrSH(z,q,6),Q=be.default.rotrSL(z,q,19)^be.default.rotrBL(z,q,61)^be.default.shrSL(z,q,6),ie=be.default.add4L(G,Q,On[A-7],On[A-16]),w=be.default.add4H(ie,k,oe,An[A-7],An[A-16]);An[A]=w|0,On[A]=ie|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:f,Dl:d,Eh:h,El:g,Fh:b,Fl:l,Gh:N,Gl:O,Hh:I,Hl:M}=this;for(let A=0;A<80;A++){let K=be.default.rotrSH(h,g,14)^be.default.rotrSH(h,g,18)^be.default.rotrBH(h,g,41),E=be.default.rotrSL(h,g,14)^be.default.rotrSL(h,g,18)^be.default.rotrBL(h,g,41),k=h&b^~h&N,G=g&l^~g&O,z=be.default.add5L(M,E,G,l2[A],On[A]),q=be.default.add5H(z,I,K,k,u2[A],An[A]),oe=z|0,Q=be.default.rotrSH(n,i,28)^be.default.rotrBH(n,i,34)^be.default.rotrBH(n,i,39),ie=be.default.rotrSL(n,i,28)^be.default.rotrBL(n,i,34)^be.default.rotrBL(n,i,39),w=n&s^n&a^s&a,m=i&o^i&c^o&c;I=N|0,M=O|0,N=b|0,O=l|0,b=h|0,l=g|0,{h,l:g}=be.default.add(f|0,d|0,q|0,oe|0),f=a|0,d=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let R=be.default.add3L(oe,ie,m);n=be.default.add3H(R,q,Q,w),i=R|0}({h:n,l:i}=be.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=be.default.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=be.default.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:d}=be.default.add(this.Dh|0,this.Dl|0,f|0,d|0),{h,l:g}=be.default.add(this.Eh|0,this.El|0,h|0,g|0),{h:b,l}=be.default.add(this.Fh|0,this.Fl|0,b|0,l|0),{h:N,l:O}=be.default.add(this.Gh|0,this.Gl|0,N|0,O|0),{h:I,l:M}=be.default.add(this.Hh|0,this.Hl|0,I|0,M|0),this.set(n,i,s,o,a,c,f,d,h,g,b,l,N,O,I,M)}roundClean(){An.fill(0),On.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};yt.SHA512=Wn;var Ea=class extends Wn{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}};yt.SHA512_224=Ea;var xa=class extends Wn{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}};yt.SHA512_256=xa;var va=class extends Wn{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};yt.SHA384=va;yt.sha512=(0,Ta.wrapConstructor)(()=>new Wn);yt.sha512_224=(0,Ta.wrapConstructor)(()=>new Ea);yt.sha512_256=(0,Ta.wrapConstructor)(()=>new xa);yt.sha384=(0,Ta.wrapConstructor)(()=>new va)});var op=ee(Rl=>{"use strict";Object.defineProperty(Rl,"__esModule",{value:!0});Rl.twistedEdwards=p2;var Nl=fl(),sp=Fr(),Yt=Dt(),Xt=Dt(),_r=BigInt(0),Gt=BigInt(1),Aa=BigInt(2),f2=BigInt(8),d2={zip215:!0};function h2(t){let e=(0,Nl.validateBasic)(t);return Yt.validateObject(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function p2(t){let e=h2(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,f=Aa<<BigInt(a*8)-Gt,d=r.create,h=(0,sp.Field)(e.n,e.nBitLength),g=e.uvRatio||((S,B)=>{try{return{isValid:!0,value:r.sqrt(S*r.inv(B))}}catch{return{isValid:!1,value:_r}}}),b=e.adjustScalarBytes||(S=>S),l=e.domain||((S,B,V)=>{if((0,Xt.abool)("phflag",V),B.length||V)throw new Error("Contexts/pre-hash are not supported");return S});function N(S,B){Yt.aInRange("coordinate "+S,B,_r,f)}function O(S){if(!(S instanceof A))throw new Error("ExtendedPoint expected")}let I=(0,Xt.memoized)((S,B)=>{let{ex:V,ey:J,ez:ae}=S,ce=S.is0();B==null&&(B=ce?f2:r.inv(ae));let D=d(V*B),F=d(J*B),p=d(ae*B);if(ce)return{x:_r,y:Gt};if(p!==Gt)throw new Error("invZ was invalid");return{x:D,y:F}}),M=(0,Xt.memoized)(S=>{let{a:B,d:V}=e;if(S.is0())throw new Error("bad point: ZERO");let{ex:J,ey:ae,ez:ce,et:D}=S,F=d(J*J),p=d(ae*ae),L=d(ce*ce),re=d(L*L),le=d(F*B),X=d(L*d(le+p)),u=d(re+d(V*d(F*p)));if(X!==u)throw new Error("bad point: equation left != right (1)");let y=d(J*ae),_=d(ce*D);if(y!==_)throw new Error("bad point: equation left != right (2)");return!0});class A{constructor(B,V,J,ae){this.ex=B,this.ey=V,this.ez=J,this.et=ae,N("x",B),N("y",V),N("z",J),N("t",ae),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(B){if(B instanceof A)throw new Error("extended point not allowed");let{x:V,y:J}=B||{};return N("x",V),N("y",J),new A(V,J,Gt,d(V*J))}static normalizeZ(B){let V=r.invertBatch(B.map(J=>J.ez));return B.map((J,ae)=>J.toAffine(V[ae])).map(A.fromAffine)}static msm(B,V){return(0,Nl.pippenger)(A,h,B,V)}_setWindowSize(B){k.setWindowSize(this,B)}assertValidity(){M(this)}equals(B){O(B);let{ex:V,ey:J,ez:ae}=this,{ex:ce,ey:D,ez:F}=B,p=d(V*F),L=d(ce*ae),re=d(J*F),le=d(D*ae);return p===L&&re===le}is0(){return this.equals(A.ZERO)}negate(){return new A(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){let{a:B}=e,{ex:V,ey:J,ez:ae}=this,ce=d(V*V),D=d(J*J),F=d(Aa*d(ae*ae)),p=d(B*ce),L=V+J,re=d(d(L*L)-ce-D),le=p+D,X=le-F,u=p-D,y=d(re*X),_=d(le*u),U=d(re*u),T=d(X*le);return new A(y,_,T,U)}add(B){O(B);let{a:V,d:J}=e,{ex:ae,ey:ce,ez:D,et:F}=this,{ex:p,ey:L,ez:re,et:le}=B;if(V===BigInt(-1)){let Z=d((ce-ae)*(L+p)),te=d((ce+ae)*(L-p)),fe=d(te-Z);if(fe===_r)return this.double();let me=d(D*Aa*le),Re=d(F*Aa*re),Me=Re+me,ye=te+Z,he=Re-me,Ze=d(Me*fe),vr=d(ye*he),zr=d(Me*he),Dr=d(fe*ye);return new A(Ze,vr,Dr,zr)}let X=d(ae*p),u=d(ce*L),y=d(F*J*le),_=d(D*re),U=d((ae+ce)*(p+L)-X-u),T=_-y,P=_+y,H=d(u-V*X),x=d(U*T),C=d(P*H),$=d(U*H),j=d(T*P);return new A(x,C,j,$)}subtract(B){return this.add(B.negate())}wNAF(B){return k.wNAFCached(this,B,A.normalizeZ)}multiply(B){let V=B;Yt.aInRange("scalar",V,Gt,n);let{p:J,f:ae}=this.wNAF(V);return A.normalizeZ([J,ae])[0]}multiplyUnsafe(B){let V=B;return Yt.aInRange("scalar",V,_r,n),V===_r?E:this.equals(E)||V===Gt?this:this.equals(K)?this.wNAF(V).p:k.unsafeLadder(this,V)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return k.unsafeLadder(this,n).is0()}toAffine(B){return I(this,B)}clearCofactor(){let{h:B}=e;return B===Gt?this:this.multiplyUnsafe(B)}static fromHex(B,V=!1){let{d:J,a:ae}=e,ce=r.BYTES;B=(0,Xt.ensureBytes)("pointHex",B,ce),(0,Xt.abool)("zip215",V);let D=B.slice(),F=B[ce-1];D[ce-1]=F&-129;let p=Yt.bytesToNumberLE(D),L=V?f:r.ORDER;Yt.aInRange("pointHex.y",p,_r,L);let re=d(p*p),le=d(re-Gt),X=d(J*re-ae),{isValid:u,value:y}=g(le,X);if(!u)throw new Error("Point.fromHex: invalid y coordinate");let _=(y&Gt)===Gt,U=(F&128)!==0;if(!V&&y===_r&&U)throw new Error("Point.fromHex: x=0 and x_0=1");return U!==_&&(y=d(-y)),A.fromAffine({x:y,y:p})}static fromPrivateKey(B){return q(B).point}toRawBytes(){let{x:B,y:V}=this.toAffine(),J=Yt.numberToBytesLE(V,r.BYTES);return J[J.length-1]|=B&Gt?128:0,J}toHex(){return Yt.bytesToHex(this.toRawBytes())}}A.BASE=new A(e.Gx,e.Gy,Gt,d(e.Gx*e.Gy)),A.ZERO=new A(_r,Gt,Gt,_r);let{BASE:K,ZERO:E}=A,k=(0,Nl.wNAF)(A,a*8);function G(S){return(0,sp.mod)(S,n)}function z(S){return G(Yt.bytesToNumberLE(S))}function q(S){let B=a;S=(0,Xt.ensureBytes)("private key",S,B);let V=(0,Xt.ensureBytes)("hashed private key",s(S),2*B),J=b(V.slice(0,B)),ae=V.slice(B,2*B),ce=z(J),D=K.multiply(ce),F=D.toRawBytes();return{head:J,prefix:ae,scalar:ce,point:D,pointBytes:F}}function oe(S){return q(S).pointBytes}function Q(S=new Uint8Array,...B){let V=Yt.concatBytes(...B);return z(s(l(V,(0,Xt.ensureBytes)("context",S),!!i)))}function ie(S,B,V={}){S=(0,Xt.ensureBytes)("message",S),i&&(S=i(S));let{prefix:J,scalar:ae,pointBytes:ce}=q(B),D=Q(V.context,J,S),F=K.multiply(D).toRawBytes(),p=Q(V.context,F,ce,S),L=G(D+p*ae);Yt.aInRange("signature.s",L,_r,n);let re=Yt.concatBytes(F,Yt.numberToBytesLE(L,r.BYTES));return(0,Xt.ensureBytes)("result",re,a*2)}let w=d2;function m(S,B,V,J=w){let{context:ae,zip215:ce}=J,D=r.BYTES;S=(0,Xt.ensureBytes)("signature",S,2*D),B=(0,Xt.ensureBytes)("message",B),ce!==void 0&&(0,Xt.abool)("zip215",ce),i&&(B=i(B));let F=Yt.bytesToNumberLE(S.slice(D,2*D)),p,L,re;try{p=A.fromHex(V,ce),L=A.fromHex(S.slice(0,D),ce),re=K.multiplyUnsafe(F)}catch{return!1}if(!ce&&p.isSmallOrder())return!1;let le=Q(ae,L.toRawBytes(),p.toRawBytes(),B);return L.add(p.multiplyUnsafe(le)).subtract(re).clearCofactor().equals(A.ZERO)}return K._setWindowSize(8),{CURVE:e,getPublicKey:oe,sign:ie,verify:m,ExtendedPoint:A,utils:{getExtendedPublicKey:q,randomPrivateKey:()=>o(r.BYTES),precompute(S=8,B=A.BASE){return B._setWindowSize(S),B.multiply(BigInt(3)),B}}}}});var cp=ee(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});Pl.montgomery=_2;var ap=Fr(),Sn=Dt(),Ri=BigInt(0),Bl=BigInt(1);function y2(t){return(0,Sn.validateObject)(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function _2(t){let e=y2(t),{P:r}=e,n=M=>(0,ap.mod)(M,r),i=e.montgomeryBits,s=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(M=>M),c=e.powPminus2||(M=>(0,ap.pow)(M,r-BigInt(2),r));function f(M,A,K){let E=n(M*(A-K));return A=n(A-E),K=n(K+E),[A,K]}let d=(e.a-BigInt(2))/BigInt(4);function h(M,A){(0,Sn.aInRange)("u",M,Ri,r),(0,Sn.aInRange)("scalar",A,Ri,r);let K=A,E=M,k=Bl,G=Ri,z=M,q=Bl,oe=Ri,Q;for(let w=BigInt(i-1);w>=Ri;w--){let m=K>>w&Bl;oe^=m,Q=f(oe,k,z),k=Q[0],z=Q[1],Q=f(oe,G,q),G=Q[0],q=Q[1],oe=m;let R=k+G,S=n(R*R),B=k-G,V=n(B*B),J=S-V,ae=z+q,ce=z-q,D=n(ce*R),F=n(ae*B),p=D+F,L=D-F;z=n(p*p),q=n(E*n(L*L)),k=n(S*V),G=n(J*(S+n(d*J)))}Q=f(oe,k,z),k=Q[0],z=Q[1],Q=f(oe,G,q),G=Q[0],q=Q[1];let ie=c(G);return n(k*ie)}function g(M){return(0,Sn.numberToBytesLE)(n(M),s)}function b(M){let A=(0,Sn.ensureBytes)("u coordinate",M,s);return o===32&&(A[31]&=127),(0,Sn.bytesToNumberLE)(A)}function l(M){let A=(0,Sn.ensureBytes)("scalar",M),K=A.length;if(K!==s&&K!==o)throw new Error(`Expected ${s} or ${o} bytes, got ${K}`);return(0,Sn.bytesToNumberLE)(a(A))}function N(M,A){let K=b(A),E=l(M),k=h(K,E);if(k===Ri)throw new Error("Invalid private or public key received");return g(k)}let O=g(e.Gu);function I(M){return N(M,O)}return{scalarMult:N,scalarMultBase:I,getSharedSecret:(M,A)=>N(M,A),getPublicKey:M=>I(M),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:O}}});var kl=ee(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.hash_to_ristretto255=ge.hashToRistretto255=ge.RistrettoPoint=ge.encodeToCurve=ge.hashToCurve=ge.edwardsToMontgomery=ge.x25519=ge.ed25519ph=ge.ed25519ctx=ge.ed25519=ge.ED25519_TORSION_SUBGROUP=void 0;ge.edwardsToMontgomeryPub=mp;ge.edwardsToMontgomeryPriv=b2;var Sa=ip(),Ns=kn(),Ml=op(),dp=oa(),Ce=Fr(),g2=cp(),zn=Dt(),Rs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Cl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),m2=BigInt(0),Mr=BigInt(1),Oa=BigInt(2),hp=BigInt(3),pp=BigInt(5),ql=BigInt(8);function yp(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=Rs,a=t*t%s*t%s,c=(0,Ce.pow2)(a,Oa,s)*a%s,f=(0,Ce.pow2)(c,Mr,s)*t%s,d=(0,Ce.pow2)(f,pp,s)*f%s,h=(0,Ce.pow2)(d,e,s)*d%s,g=(0,Ce.pow2)(h,r,s)*h%s,b=(0,Ce.pow2)(g,n,s)*g%s,l=(0,Ce.pow2)(b,i,s)*b%s,N=(0,Ce.pow2)(l,i,s)*b%s,O=(0,Ce.pow2)(N,e,s)*d%s;return{pow_p_5_8:(0,Ce.pow2)(O,Oa,s)*t%s,b2:a}}function _p(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function jl(t,e){let r=Rs,n=(0,Ce.mod)(e*e*e,r),i=(0,Ce.mod)(n*n*e,r),s=yp(t*i).pow_p_5_8,o=(0,Ce.mod)(t*n*s,r),a=(0,Ce.mod)(e*o*o,r),c=o,f=(0,Ce.mod)(o*Cl,r),d=a===t,h=a===(0,Ce.mod)(-t,r),g=a===(0,Ce.mod)(-t*Cl,r);return d&&(o=c),(h||g)&&(o=f),(0,Ce.isNegativeLE)(o,r)&&(o=(0,Ce.mod)(-o,r)),{isValid:d||h,value:o}}ge.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var ue=(0,Ce.Field)(Rs,void 0,!0),Bs={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ue,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:ql,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Sa.sha512,randomBytes:Ns.randomBytes,adjustScalarBytes:_p,uvRatio:jl};ge.ed25519=(0,Ml.twistedEdwards)(Bs);function gp(t,e,r){if(e.length>255)throw new Error("Context is too big");return(0,Ns.concatBytes)((0,Ns.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}ge.ed25519ctx=(0,Ml.twistedEdwards)({...Bs,domain:gp});ge.ed25519ph=(0,Ml.twistedEdwards)(Object.assign({},Bs,{domain:gp,prehash:Sa.sha512}));ge.x25519=(0,g2.montgomery)({P:Rs,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=Rs,{pow_p_5_8:r,b2:n}=yp(t);return(0,Ce.mod)((0,Ce.pow2)(r,hp,e)*n,e)},adjustScalarBytes:_p,randomBytes:Ns.randomBytes});function mp(t){let{y:e}=ge.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return ue.toBytes(ue.create((r+e)*ue.inv(r-e)))}ge.edwardsToMontgomery=mp;function b2(t){let e=Bs.hash(t.subarray(0,32));return Bs.adjustScalarBytes(e).subarray(0,32)}var w2=(ue.ORDER+hp)/ql,E2=ue.pow(Oa,w2),up=ue.sqrt(ue.neg(ue.ONE));function x2(t){let e=(ue.ORDER-pp)/ql,r=BigInt(486662),n=ue.sqr(t);n=ue.mul(n,Oa);let i=ue.add(n,ue.ONE),s=ue.neg(r),o=ue.sqr(i),a=ue.mul(o,i),c=ue.mul(n,r);c=ue.mul(c,s),c=ue.add(c,o),c=ue.mul(c,s);let f=ue.sqr(a);o=ue.sqr(f),f=ue.mul(f,a),f=ue.mul(f,c),o=ue.mul(o,f);let d=ue.pow(o,e);d=ue.mul(d,f);let h=ue.mul(d,up);o=ue.sqr(d),o=ue.mul(o,a);let g=ue.eql(o,c),b=ue.cmov(h,d,g),l=ue.mul(s,n),N=ue.mul(d,t);N=ue.mul(N,E2);let O=ue.mul(N,up),I=ue.mul(c,n);o=ue.sqr(N),o=ue.mul(o,a);let M=ue.eql(o,I),A=ue.cmov(O,N,M);o=ue.sqr(b),o=ue.mul(o,a);let K=ue.eql(o,c),E=ue.cmov(l,s,K),k=ue.cmov(A,b,K),G=ue.isOdd(k);return k=ue.cmov(k,ue.neg(k),K!==G),{xMn:E,xMd:i,yMn:k,yMd:Mr}}var v2=(0,Ce.FpSqrtEven)(ue,ue.neg(BigInt(486664)));function T2(t){let{xMn:e,xMd:r,yMn:n,yMd:i}=x2(t),s=ue.mul(e,i);s=ue.mul(s,v2);let o=ue.mul(r,n),a=ue.sub(e,r),c=ue.add(e,r),f=ue.mul(o,c),d=ue.eql(f,ue.ZERO);s=ue.cmov(s,ue.ZERO,d),o=ue.cmov(o,ue.ONE,d),a=ue.cmov(a,ue.ONE,d),c=ue.cmov(c,ue.ONE,d);let h=ue.invertBatch([o,c]);return{x:ue.mul(s,h[0]),y:ue.mul(a,h[1])}}var bp=(0,dp.createHasher)(ge.ed25519.ExtendedPoint,t=>T2(t[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:ue.ORDER,m:1,k:128,expand:"xmd",hash:Sa.sha512});ge.hashToCurve=bp.hashToCurve;ge.encodeToCurve=bp.encodeToCurve;function Ul(t){if(!(t instanceof gr))throw new Error("RistrettoPoint expected")}var Fl=Cl,A2=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),O2=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),S2=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),N2=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),lp=t=>jl(Mr,t),R2=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Il=t=>ge.ed25519.CURVE.Fp.create((0,zn.bytesToNumberLE)(t)&R2);function fp(t){let{d:e}=ge.ed25519.CURVE,r=ge.ed25519.CURVE.Fp.ORDER,n=ge.ed25519.CURVE.Fp.create,i=n(Fl*t*t),s=n((i+Mr)*S2),o=BigInt(-1),a=n((o-e*i)*n(i+e)),{isValid:c,value:f}=jl(s,a),d=n(f*t);(0,Ce.isNegativeLE)(d,r)||(d=n(-d)),c||(f=d),c||(o=i);let h=n(o*(i-Mr)*N2-a),g=f*f,b=n((f+f)*a),l=n(h*A2),N=n(Mr-g),O=n(Mr+g);return new ge.ed25519.ExtendedPoint(n(b*O),n(N*l),n(l*O),n(b*N))}var gr=class t{constructor(e){this.ep=e}static fromAffine(e){return new t(ge.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,zn.ensureBytes)("ristrettoHash",e,64);let r=Il(e.slice(0,32)),n=fp(r),i=Il(e.slice(32,64)),s=fp(i);return new t(n.add(s))}static fromHex(e){e=(0,zn.ensureBytes)("ristrettoHex",e,32);let{a:r,d:n}=ge.ed25519.CURVE,i=ge.ed25519.CURVE.Fp.ORDER,s=ge.ed25519.CURVE.Fp.create,o="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=Il(e);if(!(0,zn.equalBytes)((0,zn.numberToBytesLE)(a,32),e)||(0,Ce.isNegativeLE)(a,i))throw new Error(o);let c=s(a*a),f=s(Mr+r*c),d=s(Mr-r*c),h=s(f*f),g=s(d*d),b=s(r*n*h-g),{isValid:l,value:N}=lp(s(b*g)),O=s(N*d),I=s(N*O*b),M=s((a+a)*O);(0,Ce.isNegativeLE)(M,i)&&(M=s(-M));let A=s(f*I),K=s(M*A);if(!l||(0,Ce.isNegativeLE)(K,i)||A===m2)throw new Error(o);return new t(new ge.ed25519.ExtendedPoint(M,A,Mr,K))}toRawBytes(){let{ex:e,ey:r,ez:n,et:i}=this.ep,s=ge.ed25519.CURVE.Fp.ORDER,o=ge.ed25519.CURVE.Fp.create,a=o(o(n+r)*o(n-r)),c=o(e*r),f=o(c*c),{value:d}=lp(o(a*f)),h=o(d*a),g=o(d*c),b=o(h*g*i),l;if((0,Ce.isNegativeLE)(i*b,s)){let O=o(r*Fl),I=o(e*Fl);e=O,r=I,l=o(h*O2)}else l=g;(0,Ce.isNegativeLE)(e*b,s)&&(r=o(-r));let N=o((n-r)*l);return(0,Ce.isNegativeLE)(N,s)&&(N=o(-N)),(0,zn.numberToBytesLE)(N,32)}toHex(){return(0,zn.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){Ul(e);let{ex:r,ey:n}=this.ep,{ex:i,ey:s}=e.ep,o=ge.ed25519.CURVE.Fp.create,a=o(r*s)===o(n*i),c=o(n*s)===o(r*i);return a||c}add(e){return Ul(e),new t(this.ep.add(e.ep))}subtract(e){return Ul(e),new t(this.ep.subtract(e.ep))}multiply(e){return new t(this.ep.multiply(e))}multiplyUnsafe(e){return new t(this.ep.multiplyUnsafe(e))}double(){return new t(this.ep.double())}negate(){return new t(this.ep.negate())}};ge.RistrettoPoint=(gr.BASE||(gr.BASE=new gr(ge.ed25519.ExtendedPoint.BASE)),gr.ZERO||(gr.ZERO=new gr(ge.ed25519.ExtendedPoint.ZERO)),gr);var B2=(t,e)=>{let r=e.DST,n=typeof r=="string"?(0,Ns.utf8ToBytes)(r):r,i=(0,dp.expand_message_xmd)(t,n,64,Sa.sha512);return gr.hashToCurve(i)};ge.hashToRistretto255=B2;ge.hash_to_ristretto255=ge.hashToRistretto255});var vp=ee(Nn=>{"use strict";var wp=Nn&&Nn.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},jt=Nn&&Nn.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Rt,Ps,Ep,xp;Object.defineProperty(Nn,"__esModule",{value:!0});Nn.ExpirableMap=void 0;var Vl=class{constructor(e={}){Rt.set(this,void 0),Ps.set(this,void 0),this[Ep]=this.entries.bind(this),this[xp]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();wp(this,Rt,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),wp(this,Ps,n,"f")}prune(){let e=Date.now();for(let[r,n]of jt(this,Rt,"f").entries())e-n.timestamp>jt(this,Ps,"f")&&jt(this,Rt,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return jt(this,Rt,"f").set(e,n),this}get(e){let r=jt(this,Rt,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>jt(this,Ps,"f")){jt(this,Rt,"f").delete(e);return}return r.value}}clear(){jt(this,Rt,"f").clear()}entries(){let e=jt(this,Rt,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=jt(this,Rt,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return jt(this,Rt,"f").keys()}forEach(e,r){for(let[n,i]of jt(this,Rt,"f").entries())e.call(r,i.value,n,this)}has(e){return jt(this,Rt,"f").has(e)}delete(e){return jt(this,Rt,"f").delete(e)}get size(){return jt(this,Rt,"f").size}};Nn.ExpirableMap=Vl;Rt=new WeakMap,Ps=new WeakMap,Ep=Symbol.iterator,xp=Symbol.toStringTag});var Hl=ee(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});ke.unwrapDER=ke.wrapDER=ke.SECP256K1_OID=ke.ED25519_OID=ke.DER_COSE_OID=ke.decodeLen=ke.decodeLenBytes=ke.encodeLen=ke.encodeLenBytes=void 0;var P2=Ht(),U2=t=>{if(t<=127)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")};ke.encodeLenBytes=U2;var I2=(t,e,r)=>{if(r<=127)return t[e]=r,1;if(r<=255)return t[e]=129,t[e+1]=r,2;if(r<=65535)return t[e]=130,t[e+1]=r>>8,t[e+2]=r,3;if(r<=16777215)return t[e]=131,t[e+1]=r>>16,t[e+2]=r>>8,t[e+3]=r,4;throw new Error("Length too long (> 4 bytes)")};ke.encodeLen=I2;var C2=(t,e)=>{if(t[e]<128)return 1;if(t[e]===128)throw new Error("Invalid length 0");if(t[e]===129)return 2;if(t[e]===130)return 3;if(t[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")};ke.decodeLenBytes=C2;var F2=(t,e)=>{let r=(0,ke.decodeLenBytes)(t,e);if(r===1)return t[e];if(r===2)return t[e+1];if(r===3)return(t[e+1]<<8)+t[e+2];if(r===4)return(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];throw new Error("Length too long (> 4 bytes)")};ke.decodeLen=F2;ke.DER_COSE_OID=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]);ke.ED25519_OID=Uint8Array.from([48,5,6,3,43,101,112]);ke.SECP256K1_OID=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function M2(t,e){let r=2+(0,ke.encodeLenBytes)(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,s=new Uint8Array(1+(0,ke.encodeLenBytes)(n)+n);return s[i++]=48,i+=(0,ke.encodeLen)(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=(0,ke.encodeLen)(s,i,t.byteLength+1),s[i++]=0,s.set(new Uint8Array(t),i),s}ke.wrapDER=M2;var q2=(t,e)=>{let r=0,n=(a,c)=>{if(i[r++]!==a)throw new Error("Expected: "+c)},i=new Uint8Array(t);if(n(48,"sequence"),r+=(0,ke.decodeLenBytes)(i,r),!(0,P2.bufEquals)(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let s=(0,ke.decodeLen)(i,r)-1;r+=(0,ke.decodeLenBytes)(i,r),n(0,"0 padding");let o=i.slice(r);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o};ke.unwrapDER=q2});var $l=ee(Rn=>{"use strict";var Tp=Rn&&Rn.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ap=Rn&&Rn.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ra,Ba;Object.defineProperty(Rn,"__esModule",{value:!0});Rn.Ed25519PublicKey=void 0;var Na=Hl(),Pa=class t{constructor(e){if(Ra.set(this,void 0),Ba.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Tp(this,Ra,e,"f"),Tp(this,Ba,t.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){return(0,Na.wrapDER)(e,Na.ED25519_OID).buffer}static derDecode(e){let r=(0,Na.unwrapDER)(e,Na.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Ap(this,Ra,"f")}get derKey(){return Ap(this,Ba,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Rn.Ed25519PublicKey=Pa;Ra=new WeakMap,Ba=new WeakMap;Pa.RAW_KEY_LENGTH=32});var Gl=ee(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.ObservableLog=Bi.Observable=void 0;var Ua=class{constructor(){this.observers=[]}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e,...r){this.observers.forEach(n=>n(e,...r))}};Bi.Observable=Ua;var Kl=class extends Ua{constructor(){super()}print(e,...r){this.notify({message:e,level:"info"},...r)}warn(e,...r){this.notify({message:e,level:"warn"},...r)}error(e,r,...n){this.notify({message:e,level:"error",error:r},...n)}};Bi.ObservableLog=Kl});var Up=ee(kr=>{"use strict";var qr=kr&&kr.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Bt=kr&&kr.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},jr,Ia,Ca,Fa,Ma,qa,ja,ka,Pi;Object.defineProperty(kr,"__esModule",{value:!0});kr.exponentialBackoff=kr.ExponentialBackoff=void 0;var Op=.5,Sp=1.5,Np=500,Rp=6e4,Bp=9e5,Pp=10,Ui=class t{constructor(e=t.default){jr.set(this,void 0),Ia.set(this,void 0),Ca.set(this,void 0),Fa.set(this,void 0),Ma.set(this,void 0),qa.set(this,void 0),ja.set(this,void 0),ka.set(this,void 0),Pi.set(this,0);let{initialInterval:r=Np,randomizationFactor:n=Op,multiplier:i=Sp,maxInterval:s=Rp,maxElapsedTime:o=Bp,maxIterations:a=Pp,date:c=Date}=e;qr(this,jr,r,"f"),qr(this,Ia,n,"f"),qr(this,Ca,i,"f"),qr(this,Fa,s,"f"),qr(this,ka,c,"f"),qr(this,Ma,c.now(),"f"),qr(this,qa,o,"f"),qr(this,ja,a,"f")}get ellapsedTimeInMsec(){return Bt(this,ka,"f").now()-Bt(this,Ma,"f")}get currentInterval(){return Bt(this,jr,"f")}get count(){return Bt(this,Pi,"f")}get randomValueFromInterval(){let e=Bt(this,Ia,"f")*Bt(this,jr,"f"),r=Bt(this,jr,"f")-e,n=Bt(this,jr,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return qr(this,jr,Math.min(Bt(this,jr,"f")*Bt(this,Ca,"f"),Bt(this,Fa,"f")),"f"),qr(this,Pi,(e=Bt(this,Pi,"f"),e++,e),"f"),Bt(this,jr,"f")}next(){return this.ellapsedTimeInMsec>=Bt(this,qa,"f")||Bt(this,Pi,"f")>=Bt(this,ja,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};kr.ExponentialBackoff=Ui;jr=new WeakMap,Ia=new WeakMap,Ca=new WeakMap,Fa=new WeakMap,Ma=new WeakMap,qa=new WeakMap,ja=new WeakMap,ka=new WeakMap,Pi=new WeakMap;Ui.default={initialInterval:Np,randomizationFactor:Op,multiplier:Sp,maxInterval:Rp,maxElapsedTime:Bp,maxIterations:Pp,date:Date};function*j2(t=Ui.default){let e=new Ui(t),r=e.next();for(;r;)yield r,r=e.next()}kr.exponentialBackoff=j2});var zl=ee(Fe=>{"use strict";var Cp=Fe&&Fe.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),k2=Fe&&Fe.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Fp=Fe&&Fe.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Cp(e,t,r);return k2(e,t),e},Mp=Fe&&Fe.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Cp(e,t,r)},xt=Fe&&Fe.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ne=Fe&&Fe.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Pt,Dn,ji,Vr,nn,qi,Us,Ci,br,wr,Jn,Zn,Is,Fi,Mi,Xn,Ln,qp,$a,Ka,Qn;Object.defineProperty(Fe,"__esModule",{value:!0});Fe.HttpAgent=Fe.IdentityInvalidError=Fe.MANAGEMENT_CANISTER_ID=Fe.IC_ROOT_KEY=Fe.RequestStatusResponseStatus=Fe.makeNonce=void 0;var sr=It(),Hr=yi(),Ip=Vu(),Bn=Fp(ys()),Va=ds(),mr=Ht(),Er=Qo(),Yl=_s(),ki=ea(),V2=Ss(),Ii=Ni(),H2=kl(),$2=vp(),K2=$l(),G2=ya(),Y2=Gl(),W2=Up();Mp(Qo(),Fe);Mp(ea(),Fe);var z2=_s();Object.defineProperty(Fe,"makeNonce",{enumerable:!0,get:function(){return z2.makeNonce}});var D2;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(D2=Fe.RequestStatusResponseStatus||(Fe.RequestStatusResponseStatus={}));var Ha=60*1e3;Fe.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";Fe.MANAGEMENT_CANISTER_ID="aaaaa-aa";var J2="ic0.app",Z2=".ic0.app",X2="icp0.io",Q2=".icp0.io",L2="icp-api.io",eE=".icp-api.io",Cs=class extends Hr.AgentError{constructor(e){super(e),this.message=e}},ei=class extends Hr.AgentError{constructor(e){super(e),this.message=e}};Fe.IdentityInvalidError=ei;function tE(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new Cs("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof global<"u")if(global.fetch)t=global.fetch.bind(global);else throw new Cs("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(t=self.fetch.bind(self));if(t)return t;throw new Cs("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function rE(t){let e;if(t!==void 0)!t.match(/^[a-z]+:/)&&typeof window<"u"?e=new URL(window.location.protocol+"//"+t):e=new URL(t);else{let r=["ic0.app","icp0.io","127.0.0.1","localhost"],n=[".github.dev",".gitpod.io"],i=typeof window<"u"?window.location:void 0,s=i?.hostname,o;s&&typeof s=="string"&&(n.some(a=>s.endsWith(a))?o=s:o=r.find(a=>s.endsWith(a))),i&&o?e=new URL(`${i.protocol}//${o}${i.port?":"+i.port:""}`):e=new URL("https://icp-api.io")}return e.toString()}var Wl=class t{constructor(e={}){var r,n;Pt.add(this),Dn.set(this,null),ji.set(this,!1),Vr.set(this,void 0),nn.set(this,void 0),qi.set(this,void 0),Us.set(this,void 0),Ci.set(this,0),br.set(this,void 0),wr.set(this,void 0),Jn.set(this,void 0),Zn.set(this,void 0),this._isAgent=!0,this.config={},Is.set(this,0),this.log=new Y2.ObservableLog,Fi.set(this,[]),Mi.set(this,[]),Xn.set(this,new $2.ExpirableMap({expirationTime:5*60*1e3})),Ln.set(this,!0),Ka.set(this,(o,a)=>{if(ne(this,Ln,"f")===!1)return o;if(!a)throw new Ii.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:c,signatures:f=[],requestId:d}=o,h=new TextEncoder().encode("\vic-response");for(let g of f){let{timestamp:b,identity:l}=g,N=sr.Principal.fromUint8Array(l).toText(),O;if(c==="replied"){let{reply:E}=o;O=(0,Va.hashOfMap)({status:c,reply:E,timestamp:BigInt(b),request_id:d})}else if(c==="rejected"){let{reject_code:E,reject_message:k,error_code:G}=o;O=(0,Va.hashOfMap)({status:c,reject_code:E,reject_message:k,error_code:G,timestamp:BigInt(b),request_id:d})}else throw new Error(`Unknown status: ${c}`);let I=(0,mr.concat)(h,new Uint8Array(O)),M=a?.nodeKeys.get(N);if(!M)throw new Ii.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let A=K2.Ed25519PublicKey.fromDer(M).rawKey;if(H2.ed25519.verify(g.signature,new Uint8Array(I),new Uint8Array(A)))return o;throw new Ii.CertificateVerificationError(`Invalid signature from replica ${N} signed query.`)}return o}),this.config=e,xt(this,nn,e.fetch||tE()||fetch.bind(global),"f"),xt(this,qi,e.fetchOptions,"f"),xt(this,Us,e.callOptions,"f"),xt(this,ji,(r=e.shouldFetchRootKey)!==null&&r!==void 0?r:!1,"f"),e.rootKey?this.rootKey=e.rootKey:ne(this,ji,"f")?this.rootKey=null:this.rootKey=(0,mr.fromHex)(Fe.IC_ROOT_KEY);let i=rE(e.host);this.host=new URL(i),e.verifyQuerySignatures!==void 0&&xt(this,Ln,e.verifyQuerySignatures,"f"),xt(this,wr,(n=e.retryTimes)!==null&&n!==void 0?n:3,"f");let s=()=>new W2.ExponentialBackoff({maxIterations:ne(this,wr,"f")});if(xt(this,Jn,e.backoffStrategy||s,"f"),this.host.hostname.endsWith(Z2)?this.host.hostname=J2:this.host.hostname.endsWith(Q2)?this.host.hostname=X2:this.host.hostname.endsWith(eE)&&(this.host.hostname=L2),e.credentials){let{name:o,password:a}=e.credentials;xt(this,br,`${o}${a?":"+a:""}`,"f")}if(xt(this,Vr,Promise.resolve(e.identity||new Ip.AnonymousIdentity),"f"),e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes>5)throw new Hr.AgentError(`The maximum ingress expiry time is 5 minutes. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);if(e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes<=0)throw new Hr.AgentError(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);xt(this,Zn,e.ingressExpiryInMinutes||5,"f"),this.addTransform("update",(0,Er.makeNonceTransform)(Yl.makeNonce)),e.useQueryNonces&&this.addTransform("query",(0,Er.makeNonceTransform)(Yl.makeNonce)),e.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 ne(this,Is,"f")}static createSync(e={}){return new this(Object.assign({},e))}static async create(e={shouldFetchRootKey:!1}){let r=t.createSync(e),n=[r.syncTime()];return r.host.toString()!=="https://icp-api.io"&&e.shouldFetchRootKey&&n.push(r.fetchRootKey()),await Promise.all(n),r}static async from(e){var r;try{return"config"in e?await t.create(e.config):await t.create({fetch:e._fetch,fetchOptions:e._fetchOptions,callOptions:e._callOptions,host:e._host.toString(),identity:(r=e._identity)!==null&&r!==void 0?r:void 0})}catch{throw new Hr.AgentError("Failed to create agent from provided agent")}}isLocal(){let e=this.host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,r,n=r.priority||0){if(e==="update"){let i=ne(this,Mi,"f").findIndex(s=>(s.priority||0)<n);ne(this,Mi,"f").splice(i>=0?i:ne(this,Mi,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=ne(this,Fi,"f").findIndex(s=>(s.priority||0)<n);ne(this,Fi,"f").splice(i>=0?i:ne(this,Fi,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!ne(this,Vr,"f"))throw new ei("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ne(this,Vr,"f")).getPrincipal()}async call(e,r,n){var i,s;await ne(this,Pt,"m",Qn).call(this);let o=(i=r.callSync)!==null&&i!==void 0?i:!0,a=await(n!==void 0?await n:await ne(this,Vr,"f"));if(!a)throw new ei("This identity has expired due this application's security policy. Please refresh your authentication.");let c=sr.Principal.from(e),f=r.effectiveCanisterId?sr.Principal.from(r.effectiveCanisterId):c,d=a.getPrincipal()||sr.Principal.anonymous(),h=new Er.Expiry(ne(this,Zn,"f")*Ha);Math.abs(ne(this,Ci,"f"))>1e3*30&&(h=new Er.Expiry(ne(this,Zn,"f")*Ha+ne(this,Ci,"f")));let g={request_type:Yl.SubmitRequestType.Call,canister_id:c,method_name:r.methodName,arg:r.arg,sender:d,ingress_expiry:h},b=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,br,"f")?{Authorization:"Basic "+btoa(ne(this,br,"f"))}:{})},endpoint:"call",body:g}),l=b.body.nonce?N(b.body.nonce):void 0;g.nonce=l;function N(A){return new Uint8Array(A)}b=await a.transformRequest(b);let O=Bn.encode(b.body),I=ne(this,Jn,"f").call(this),M=(0,Va.requestIdOf)(g);try{let A=()=>(this.log.print(`fetching "/api/v3/canister/${f.toText()}/call" with request:`,b),ne(this,nn,"f").call(this,""+new URL(`/api/v3/canister/${f.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,Us,"f")),b.request),{body:O}))),K=()=>(this.log.print(`fetching "/api/v2/canister/${f.toText()}/call" with request:`,b),ne(this,nn,"f").call(this,""+new URL(`/api/v2/canister/${f.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,Us,"f")),b.request),{body:O}))),k=await ne(this,Pt,"m",$a).call(this,{request:o?A:K,backoff:I,tries:0}),G=await k.arrayBuffer(),z=k.status===200&&G.byteLength>0?Bn.decode(G):null;if(z&&"certificate"in z){let q=await this.parseTimeFromResponse({certificate:z.certificate});xt(this,Is,q,"f")}return{requestId:M,response:{ok:k.ok,status:k.status,statusText:k.statusText,body:z,headers:(0,Er.httpHeadersTransform)(k.headers)},requestDetails:g}}catch(A){if(A.message.includes("v3 api not supported."))return this.log.warn("v3 api not supported. Fall back to v2"),this.call(e,Object.assign(Object.assign({},r),{callSync:!1}),n);let K=`Error while making call: ${(s=A.message)!==null&&s!==void 0?s:String(A)}`,E=new ki.AgentCallError(K,A,(0,mr.toHex)(M),(0,mr.toHex)(b.body.sender_pubkey),(0,mr.toHex)(b.body.sender_sig),String(b.body.content.ingress_expiry._value));throw this.log.error(K,E),E}}async query(e,r,n){var i,s,o,a;await ne(this,Pt,"m",Qn).call(this);let c=ne(this,Jn,"f").call(this),f=r.effectiveCanisterId?sr.Principal.from(r.effectiveCanisterId):sr.Principal.from(e);this.log.print(`ecid ${f.toString()}`),this.log.print(`canisterId ${e.toString()}`);let d,h,g=await(n!==void 0?n:ne(this,Vr,"f"));if(!g)throw new ei("This identity has expired due this application's security policy. Please refresh your authentication.");let b=sr.Principal.from(e),l=g?.getPrincipal()||sr.Principal.anonymous(),N={request_type:"query",canister_id:b,method_name:r.methodName,arg:r.arg,sender:l,ingress_expiry:new Er.Expiry(ne(this,Zn,"f")*Ha)},O=(0,Va.requestIdOf)(N);d=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,br,"f")?{Authorization:"Basic "+btoa(ne(this,br,"f"))}:{})},endpoint:"read",body:N}),d=await g?.transformRequest(d);let I=Bn.encode(d.body),M={canister:b.toText(),ecid:f,transformedRequest:d,body:I,requestId:O,backoff:c,tries:0},A=async()=>({requestDetails:N,query:await ne(this,Pt,"m",qp).call(this,M)}),K=async()=>{if(!ne(this,Ln,"f"))return;let E=ne(this,Xn,"f").get(f.toString());return E||(await this.fetchSubnetKeys(f.toString()),ne(this,Xn,"f").get(f.toString()))};try{let[E,k]=await Promise.all([A(),K()]);h=E;let{requestDetails:G,query:z}=h,q=Object.assign(Object.assign({},z),{requestDetails:G});if(this.log.print("Query response:",q),!ne(this,Ln,"f"))return q;try{return ne(this,Ka,"f").call(this,q,k)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ne(this,Xn,"f").delete(e.toString()),await this.fetchSubnetKeys(f.toString());let Q=ne(this,Xn,"f").get(e.toString());if(!Q)throw new Ii.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return ne(this,Ka,"f").call(this,q,Q)}}catch(E){let k=`Error while making call: ${(i=E.message)!==null&&i!==void 0?i:String(E)}`,G=new ki.AgentQueryError(k,E,String(O),(0,mr.toHex)((s=d?.body)===null||s===void 0?void 0:s.sender_pubkey),(0,mr.toHex)((o=d?.body)===null||o===void 0?void 0:o.sender_sig),String((a=d?.body)===null||a===void 0?void 0:a.content.ingress_expiry._value));throw this.log.error(k,G),G}}async createReadStateRequest(e,r){await ne(this,Pt,"m",Qn).call(this);let n=await(r!==void 0?await r:await ne(this,Vr,"f"));if(!n)throw new ei("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||sr.Principal.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,br,"f")?{Authorization:"Basic "+btoa(ne(this,br,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Er.Expiry(ne(this,Zn,"f")*Ha)}});return n?.transformRequest(s)}async readState(e,r,n,i){var s,o,a,c;function f(N){for(let O of N.paths){let[I,M]=O,A=new TextEncoder().encode("request_status");if((0,mr.bufEquals)(I,A))return M}}let d=f(r);await ne(this,Pt,"m",Qn).call(this);let h=typeof e=="string"?sr.Principal.fromText(e):e,g=i??await this.createReadStateRequest(r,n),b=Bn.encode(g.body);this.log.print(`fetching "/api/v2/canister/${h}/read_state" with request:`,g);let l=ne(this,Jn,"f").call(this);try{let N=await ne(this,Pt,"m",$a).call(this,{request:()=>ne(this,nn,"f").call(this,""+new URL(`/api/v2/canister/${h.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,qi,"f")),g.request),{body:b})),backoff:l,tries:0});if(!N.ok)throw new Error(`Server returned an error:
|
|
30
|
+
)`}else throw new Error("Invalid tree structure for labeled");case Et.Leaf:{if(t[1]){if(Array.isArray(t[1]))return JSON.stringify(t[1])}else throw new Error("Invalid tree structure for leaf");return`leaf(...${t[1].byteLength} bytes)`}case Et.Pruned:{if(t[1]){if(Array.isArray(t[1]))return JSON.stringify(t[1])}else throw new Error("Invalid tree structure for pruned");return`pruned(${(0,_r.toHex)(new Uint8Array(t[1]))}`}default:return`unknown(${JSON.stringify(t[0])})`}}Te.hashTreeToString=ma;function Dw(t,e){let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]>n[i])return!0;return!1}var xl=class t{constructor(e,r,n,i,s=5,o=!1){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,ga.set(this,!1),$w(this,ga,o,"f"),this.cert=Ph.decode(new Uint8Array(e))}static async create(e){let r=t.createUnverified(e);return await r.verify(),r}static createUnverified(e){let r=e.blsVerify;return r||(r=Yw.blsVerify),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes,e.disableTimeVerification)}lookup(e){return ba(e,this.cert.tree)}lookup_label(e){return this.lookup([e])}async verify(){let e=await Ts(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=Zw(r),s=(0,_r.concat)(vs("ic-state-root"),e),o=!1,a=vl(this.lookup(["time"]));if(!a)throw new rn("Certificate does not contain a time");if(!Kw(this,ga,"f")){let f=this._maxAgeInMinutes*60*1e3,d=Date.now(),h=d-f,g=d+3e5,b=(0,Ww.decodeTime)(a);if(b.getTime()<h)throw new rn(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+b.toISOString()+" Current time: "+new Date(d).toISOString());if(b.getTime()>g)throw new rn("Certificate is signed more than 5 minutes in the future. Certificate time: "+b.toISOString()+" Current time: "+new Date(d).toISOString())}try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new rn("Signature verification failed")}async _checkDelegationAndGetKey(e){if(!e)return this._rootKey;let r=await t.createUnverified({certificate:e.certificate,rootKey:this._rootKey,canisterId:this._canisterId,blsVerify:this._blsVerify,maxAgeInMinutes:1/0});if(r.cert.delegation)throw new rn("Delegation certificates cannot be nested");if(await r.verify(),this._canisterId.toString()!==zw.MANAGEMENT_CANISTER_ID&&!Uh({canisterId:this._canisterId,subnetId:El.Principal.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new rn(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,_r.toHex)(e.subnet_id)}`);let n=vl(r.lookup(["subnet",e.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${(0,_r.toHex)(e.subnet_id)}`);return n}};Te.Certificate=xl;ga=new WeakMap;var xs=(0,_r.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Jw=96;function Zw(t){let e=xs.byteLength+Jw;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,xs.byteLength);if(!(0,_r.bufEquals)(r,xs))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${xs}, but get ${r}`);return t.slice(xs.byteLength)}function vl(t){if(t.status===qt.Found){if(t.value instanceof ArrayBuffer)return t.value;if(t.value instanceof Uint8Array)return t.value.buffer}}Te.lookupResultToBuffer=vl;async function Ts(t){switch(t[0]){case Et.Empty:return(0,_a.hash)(vs("ic-hashtree-empty"));case Et.Pruned:return t[1];case Et.Leaf:return(0,_a.hash)((0,_r.concat)(vs("ic-hashtree-leaf"),t[1]));case Et.Labeled:return(0,_a.hash)((0,_r.concat)(vs("ic-hashtree-labeled"),t[1],await Ts(t[2])));case Et.Fork:return(0,_a.hash)((0,_r.concat)(vs("ic-hashtree-fork"),await Ts(t[1]),await Ts(t[2])));default:throw new Error("unreachable")}}Te.reconstruct=Ts;function vs(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return(0,_r.concat)(e,r)}var qt;(function(t){t.Unknown="unknown",t.Absent="absent",t.Found="found"})(qt=Te.LookupStatus||(Te.LookupStatus={}));var nn;(function(t){t.Less="less",t.Greater="greater"})(nn||(nn={}));function ba(t,e){if(t.length===0)switch(e[0]){case Et.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?{status:qt.Found,value:e[1]}:e[1]instanceof Uint8Array?{status:qt.Found,value:e[1].buffer}:{status:qt.Found,value:e[1]}}default:return{status:qt.Found,value:e}}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=As(r,e);switch(n.status){case qt.Found:return ba(t.slice(1),n.value);case nn.Greater:case nn.Less:return{status:qt.Absent};default:return n}}Te.lookup_path=ba;function Tl(t){switch(t[0]){case Et.Empty:return[];case Et.Fork:return Tl(t[1]).concat(Tl(t[2]));default:return[t]}}Te.flatten_forks=Tl;function As(t,e){switch(e[0]){case Et.Labeled:return Dw(t,e[1])?{status:nn.Greater}:(0,_r.bufEquals)(t,e[1])?{status:qt.Found,value:e[2]}:{status:nn.Less};case Et.Fork:let r=As(t,e[1]);switch(r.status){case nn.Greater:{let n=As(t,e[2]);return n.status===nn.Less?{status:qt.Absent}:n}case qt.Unknown:{let n=As(t,e[2]);return n.status===nn.Less?{status:qt.Unknown}:n}default:return r}case Et.Pruned:return{status:qt.Unknown};default:return{status:qt.Absent}}}Te.find_label=As;function Uh(t){let{canisterId:e,subnetId:r,tree:n}=t,i=ba(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==qt.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return Ph.decode(i.value).map(c=>[El.Principal.fromUint8Array(c[0]),El.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}Te.check_canister_ranges=Uh});var Ss=ee(ut=>{"use strict";var Xw=ut&&ut.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Qw=ut&&ut.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Lw=ut&&ut.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Xw(e,t,r);return Qw(e,t),e};Object.defineProperty(ut,"__esModule",{value:!0});ut.encodePath=ut.fetchNodeKeys=ut.request=ut.CustomPath=void 0;var vn=It(),e2=yi(),Tn=Ni(),t2=Ht(),Fh=Lw(ys()),Ih=ya(),Al=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}};ut.CustomPath=Al;var r2=async t=>{let{agent:e,paths:r}=t,n=vn.Principal.from(t.canisterId),i=[...new Set(r)],s=i.map(c=>(0,ut.encodePath)(c,n)),o=new Map,a=i.map((c,f)=>(async()=>{var d;try{let h=await e.readState(n,{paths:[s[f]]});if(e.rootKey==null)throw new Error("Agent is missing root key");let g=await Tn.Certificate.create({certificate:h.certificate,rootKey:e.rootKey,canisterId:n,disableTimeVerification:!0}),b=(O,I)=>{if(I==="subnet"){if(e.rootKey==null)throw new Error("Agent is missing root key");let M=(0,ut.fetchNodeKeys)(h.certificate,n,e.rootKey);return{path:I,data:M}}else return{path:I,data:(0,Tn.lookupResultToBuffer)(O.lookup((0,ut.encodePath)(I,n)))}},{path:l,data:N}=b(g,i[f]);if(!N)console.warn(`Expected to find result for path ${l}, but instead found nothing.`),typeof l=="string"?o.set(l,null):o.set(l.key,null);else switch(l){case"time":{o.set(l,(0,Ih.decodeTime)(N));break}case"controllers":{o.set(l,o2(N));break}case"module_hash":{o.set(l,Ch(N));break}case"subnet":{o.set(l,N);break}case"candid":{o.set(l,new TextDecoder().decode(N));break}default:if(typeof l!="string"&&"key"in l&&"path"in l)switch(l.decodeStrategy){case"raw":o.set(l.key,N);break;case"leb128":{o.set(l.key,(0,Ih.decodeLeb128)(N));break}case"cbor":{o.set(l.key,Mh(N));break}case"hex":{o.set(l.key,Ch(N));break}case"utf-8":o.set(l.key,s2(N))}}}catch(h){if(!((d=h?.message)===null||d===void 0)&&d.includes("Invalid certificate"))throw new e2.AgentError(h.message);typeof c!="string"&&"key"in c&&"path"in c?o.set(c.key,null):o.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(h),console.groupEnd()}})());return await Promise.all(a),o};ut.request=r2;var n2=(t,e,r)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=Fh.decode(new Uint8Array(t)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=vn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=vn.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=vn.Principal.selfAuthenticating(vn.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,Tn.check_canister_ranges)({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=(0,Tn.lookup_path)(["subnet",s.subnet_id,"node"],i);if(c.status!==Tn.LookupStatus.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let f=(0,Tn.flatten_forks)(c.value),d=new Map;return f.forEach(h=>{let g=vn.Principal.from(new Uint8Array(h[1])).toText(),b=(0,Tn.lookup_path)(["public_key"],h[2]);if(b.status!==Tn.LookupStatus.Found)throw new Error("Public key not found");let l=b.value;if(l.byteLength!==44)throw new Error("Invalid public key length");d.set(g,l)}),{subnetId:vn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:d}};ut.fetchNodeKeys=n2;var i2=(t,e)=>{let r=new TextEncoder,n=s=>new DataView(r.encode(s).buffer).buffer,i=new DataView(e.toUint8Array().buffer).buffer;switch(t){case"time":return[n("time")];case"controllers":return[n("canister"),i,n("controllers")];case"module_hash":return[n("canister"),i,n("module_hash")];case"subnet":return[n("subnet")];case"candid":return[n("canister"),i,n("metadata"),n("candid:service")];default:if("key"in t&&"path"in t)if(typeof t.path=="string"||t.path instanceof ArrayBuffer){let s=t.path,o=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),o]}else return t.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${t} was formatted correctly.`)};ut.encodePath=i2;var Ch=t=>(0,t2.toHex)(t),Mh=t=>Fh.decode(t),s2=t=>new TextDecoder().decode(t),o2=t=>Mh(t).map(r=>vn.Principal.fromUint8Array(new Uint8Array(r)))});var ip=ee(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.add5L=_e.add5H=_e.add4H=_e.add4L=_e.add3H=_e.add3L=_e.rotlBL=_e.rotlBH=_e.rotlSL=_e.rotlSH=_e.rotr32L=_e.rotr32H=_e.rotrBL=_e.rotrBH=_e.rotrSL=_e.rotrSH=_e.shrSL=_e.shrSH=_e.toBig=void 0;_e.fromBig=Sl;_e.split=qh;_e.add=Xh;var wa=BigInt(2**32-1),Ol=BigInt(32);function Sl(t,e=!1){return e?{h:Number(t&wa),l:Number(t>>Ol&wa)}:{h:Number(t>>Ol&wa)|0,l:Number(t&wa)|0}}function qh(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:s,l:o}=Sl(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}var jh=(t,e)=>BigInt(t>>>0)<<Ol|BigInt(e>>>0);_e.toBig=jh;var kh=(t,e,r)=>t>>>r;_e.shrSH=kh;var Vh=(t,e,r)=>t<<32-r|e>>>r;_e.shrSL=Vh;var Hh=(t,e,r)=>t>>>r|e<<32-r;_e.rotrSH=Hh;var $h=(t,e,r)=>t<<32-r|e>>>r;_e.rotrSL=$h;var Kh=(t,e,r)=>t<<64-r|e>>>r-32;_e.rotrBH=Kh;var Gh=(t,e,r)=>t>>>r-32|e<<64-r;_e.rotrBL=Gh;var Yh=(t,e)=>e;_e.rotr32H=Yh;var Wh=(t,e)=>t;_e.rotr32L=Wh;var zh=(t,e,r)=>t<<r|e>>>32-r;_e.rotlSH=zh;var Dh=(t,e,r)=>e<<r|t>>>32-r;_e.rotlSL=Dh;var Jh=(t,e,r)=>e<<r-32|t>>>64-r;_e.rotlBH=Jh;var Zh=(t,e,r)=>t<<r-32|e>>>64-r;_e.rotlBL=Zh;function Xh(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var Qh=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);_e.add3L=Qh;var Lh=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;_e.add3H=Lh;var ep=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);_e.add4L=ep;var tp=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;_e.add4H=tp;var rp=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);_e.add5L=rp;var np=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;_e.add5H=np;var a2={fromBig:Sl,split:qh,toBig:jh,shrSH:kh,shrSL:Vh,rotrSH:Hh,rotrSL:$h,rotrBH:Kh,rotrBL:Gh,rotr32H:Yh,rotr32L:Wh,rotlSH:zh,rotlSL:Dh,rotlBH:Jh,rotlBL:Zh,add:Xh,add3L:Qh,add3H:Lh,add4L:ep,add4H:tp,add5H:np,add5L:rp};_e.default=a2});var sp=ee(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.sha384=yt.sha512_256=yt.sha512_224=yt.sha512=yt.SHA384=yt.SHA512_256=yt.SHA512_224=yt.SHA512=void 0;var c2=zc(),be=ip(),Ta=kn(),[u2,l2]=be.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),An=new Uint32Array(80),On=new Uint32Array(80),Wn=class extends c2.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:f,El:d,Fh:h,Fl:g,Gh:b,Gl:l,Hh:N,Hl:O}=this;return[e,r,n,i,s,o,a,c,f,d,h,g,b,l,N,O]}set(e,r,n,i,s,o,a,c,f,d,h,g,b,l,N,O){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=d|0,this.Fh=h|0,this.Fl=g|0,this.Gh=b|0,this.Gl=l|0,this.Hh=N|0,this.Hl=O|0}process(e,r){for(let A=0;A<16;A++,r+=4)An[A]=e.getUint32(r),On[A]=e.getUint32(r+=4);for(let A=16;A<80;A++){let K=An[A-15]|0,E=On[A-15]|0,k=be.default.rotrSH(K,E,1)^be.default.rotrSH(K,E,8)^be.default.shrSH(K,E,7),G=be.default.rotrSL(K,E,1)^be.default.rotrSL(K,E,8)^be.default.shrSL(K,E,7),z=An[A-2]|0,q=On[A-2]|0,oe=be.default.rotrSH(z,q,19)^be.default.rotrBH(z,q,61)^be.default.shrSH(z,q,6),Q=be.default.rotrSL(z,q,19)^be.default.rotrBL(z,q,61)^be.default.shrSL(z,q,6),ie=be.default.add4L(G,Q,On[A-7],On[A-16]),w=be.default.add4H(ie,k,oe,An[A-7],An[A-16]);An[A]=w|0,On[A]=ie|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:f,Dl:d,Eh:h,El:g,Fh:b,Fl:l,Gh:N,Gl:O,Hh:I,Hl:M}=this;for(let A=0;A<80;A++){let K=be.default.rotrSH(h,g,14)^be.default.rotrSH(h,g,18)^be.default.rotrBH(h,g,41),E=be.default.rotrSL(h,g,14)^be.default.rotrSL(h,g,18)^be.default.rotrBL(h,g,41),k=h&b^~h&N,G=g&l^~g&O,z=be.default.add5L(M,E,G,l2[A],On[A]),q=be.default.add5H(z,I,K,k,u2[A],An[A]),oe=z|0,Q=be.default.rotrSH(n,i,28)^be.default.rotrBH(n,i,34)^be.default.rotrBH(n,i,39),ie=be.default.rotrSL(n,i,28)^be.default.rotrBL(n,i,34)^be.default.rotrBL(n,i,39),w=n&s^n&a^s&a,m=i&o^i&c^o&c;I=N|0,M=O|0,N=b|0,O=l|0,b=h|0,l=g|0,{h,l:g}=be.default.add(f|0,d|0,q|0,oe|0),f=a|0,d=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let R=be.default.add3L(oe,ie,m);n=be.default.add3H(R,q,Q,w),i=R|0}({h:n,l:i}=be.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=be.default.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=be.default.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:d}=be.default.add(this.Dh|0,this.Dl|0,f|0,d|0),{h,l:g}=be.default.add(this.Eh|0,this.El|0,h|0,g|0),{h:b,l}=be.default.add(this.Fh|0,this.Fl|0,b|0,l|0),{h:N,l:O}=be.default.add(this.Gh|0,this.Gl|0,N|0,O|0),{h:I,l:M}=be.default.add(this.Hh|0,this.Hl|0,I|0,M|0),this.set(n,i,s,o,a,c,f,d,h,g,b,l,N,O,I,M)}roundClean(){An.fill(0),On.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};yt.SHA512=Wn;var Ea=class extends Wn{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}};yt.SHA512_224=Ea;var xa=class extends Wn{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}};yt.SHA512_256=xa;var va=class extends Wn{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};yt.SHA384=va;yt.sha512=(0,Ta.wrapConstructor)(()=>new Wn);yt.sha512_224=(0,Ta.wrapConstructor)(()=>new Ea);yt.sha512_256=(0,Ta.wrapConstructor)(()=>new xa);yt.sha384=(0,Ta.wrapConstructor)(()=>new va)});var ap=ee(Rl=>{"use strict";Object.defineProperty(Rl,"__esModule",{value:!0});Rl.twistedEdwards=p2;var Nl=fl(),op=Mr(),Yt=Dt(),Xt=Dt(),gr=BigInt(0),Gt=BigInt(1),Aa=BigInt(2),f2=BigInt(8),d2={zip215:!0};function h2(t){let e=(0,Nl.validateBasic)(t);return Yt.validateObject(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function p2(t){let e=h2(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,f=Aa<<BigInt(a*8)-Gt,d=r.create,h=(0,op.Field)(e.n,e.nBitLength),g=e.uvRatio||((S,B)=>{try{return{isValid:!0,value:r.sqrt(S*r.inv(B))}}catch{return{isValid:!1,value:gr}}}),b=e.adjustScalarBytes||(S=>S),l=e.domain||((S,B,V)=>{if((0,Xt.abool)("phflag",V),B.length||V)throw new Error("Contexts/pre-hash are not supported");return S});function N(S,B){Yt.aInRange("coordinate "+S,B,gr,f)}function O(S){if(!(S instanceof A))throw new Error("ExtendedPoint expected")}let I=(0,Xt.memoized)((S,B)=>{let{ex:V,ey:J,ez:ae}=S,ce=S.is0();B==null&&(B=ce?f2:r.inv(ae));let D=d(V*B),F=d(J*B),p=d(ae*B);if(ce)return{x:gr,y:Gt};if(p!==Gt)throw new Error("invZ was invalid");return{x:D,y:F}}),M=(0,Xt.memoized)(S=>{let{a:B,d:V}=e;if(S.is0())throw new Error("bad point: ZERO");let{ex:J,ey:ae,ez:ce,et:D}=S,F=d(J*J),p=d(ae*ae),L=d(ce*ce),re=d(L*L),le=d(F*B),X=d(L*d(le+p)),u=d(re+d(V*d(F*p)));if(X!==u)throw new Error("bad point: equation left != right (1)");let y=d(J*ae),_=d(ce*D);if(y!==_)throw new Error("bad point: equation left != right (2)");return!0});class A{constructor(B,V,J,ae){this.ex=B,this.ey=V,this.ez=J,this.et=ae,N("x",B),N("y",V),N("z",J),N("t",ae),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(B){if(B instanceof A)throw new Error("extended point not allowed");let{x:V,y:J}=B||{};return N("x",V),N("y",J),new A(V,J,Gt,d(V*J))}static normalizeZ(B){let V=r.invertBatch(B.map(J=>J.ez));return B.map((J,ae)=>J.toAffine(V[ae])).map(A.fromAffine)}static msm(B,V){return(0,Nl.pippenger)(A,h,B,V)}_setWindowSize(B){k.setWindowSize(this,B)}assertValidity(){M(this)}equals(B){O(B);let{ex:V,ey:J,ez:ae}=this,{ex:ce,ey:D,ez:F}=B,p=d(V*F),L=d(ce*ae),re=d(J*F),le=d(D*ae);return p===L&&re===le}is0(){return this.equals(A.ZERO)}negate(){return new A(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){let{a:B}=e,{ex:V,ey:J,ez:ae}=this,ce=d(V*V),D=d(J*J),F=d(Aa*d(ae*ae)),p=d(B*ce),L=V+J,re=d(d(L*L)-ce-D),le=p+D,X=le-F,u=p-D,y=d(re*X),_=d(le*u),U=d(re*u),T=d(X*le);return new A(y,_,T,U)}add(B){O(B);let{a:V,d:J}=e,{ex:ae,ey:ce,ez:D,et:F}=this,{ex:p,ey:L,ez:re,et:le}=B;if(V===BigInt(-1)){let Z=d((ce-ae)*(L+p)),te=d((ce+ae)*(L-p)),fe=d(te-Z);if(fe===gr)return this.double();let me=d(D*Aa*le),Re=d(F*Aa*re),Me=Re+me,ye=te+Z,he=Re-me,Ze=d(Me*fe),Tr=d(ye*he),Dr=d(Me*he),Jr=d(fe*ye);return new A(Ze,Tr,Jr,Dr)}let X=d(ae*p),u=d(ce*L),y=d(F*J*le),_=d(D*re),U=d((ae+ce)*(p+L)-X-u),T=_-y,P=_+y,H=d(u-V*X),x=d(U*T),C=d(P*H),$=d(U*H),j=d(T*P);return new A(x,C,j,$)}subtract(B){return this.add(B.negate())}wNAF(B){return k.wNAFCached(this,B,A.normalizeZ)}multiply(B){let V=B;Yt.aInRange("scalar",V,Gt,n);let{p:J,f:ae}=this.wNAF(V);return A.normalizeZ([J,ae])[0]}multiplyUnsafe(B){let V=B;return Yt.aInRange("scalar",V,gr,n),V===gr?E:this.equals(E)||V===Gt?this:this.equals(K)?this.wNAF(V).p:k.unsafeLadder(this,V)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return k.unsafeLadder(this,n).is0()}toAffine(B){return I(this,B)}clearCofactor(){let{h:B}=e;return B===Gt?this:this.multiplyUnsafe(B)}static fromHex(B,V=!1){let{d:J,a:ae}=e,ce=r.BYTES;B=(0,Xt.ensureBytes)("pointHex",B,ce),(0,Xt.abool)("zip215",V);let D=B.slice(),F=B[ce-1];D[ce-1]=F&-129;let p=Yt.bytesToNumberLE(D),L=V?f:r.ORDER;Yt.aInRange("pointHex.y",p,gr,L);let re=d(p*p),le=d(re-Gt),X=d(J*re-ae),{isValid:u,value:y}=g(le,X);if(!u)throw new Error("Point.fromHex: invalid y coordinate");let _=(y&Gt)===Gt,U=(F&128)!==0;if(!V&&y===gr&&U)throw new Error("Point.fromHex: x=0 and x_0=1");return U!==_&&(y=d(-y)),A.fromAffine({x:y,y:p})}static fromPrivateKey(B){return q(B).point}toRawBytes(){let{x:B,y:V}=this.toAffine(),J=Yt.numberToBytesLE(V,r.BYTES);return J[J.length-1]|=B&Gt?128:0,J}toHex(){return Yt.bytesToHex(this.toRawBytes())}}A.BASE=new A(e.Gx,e.Gy,Gt,d(e.Gx*e.Gy)),A.ZERO=new A(gr,Gt,Gt,gr);let{BASE:K,ZERO:E}=A,k=(0,Nl.wNAF)(A,a*8);function G(S){return(0,op.mod)(S,n)}function z(S){return G(Yt.bytesToNumberLE(S))}function q(S){let B=a;S=(0,Xt.ensureBytes)("private key",S,B);let V=(0,Xt.ensureBytes)("hashed private key",s(S),2*B),J=b(V.slice(0,B)),ae=V.slice(B,2*B),ce=z(J),D=K.multiply(ce),F=D.toRawBytes();return{head:J,prefix:ae,scalar:ce,point:D,pointBytes:F}}function oe(S){return q(S).pointBytes}function Q(S=new Uint8Array,...B){let V=Yt.concatBytes(...B);return z(s(l(V,(0,Xt.ensureBytes)("context",S),!!i)))}function ie(S,B,V={}){S=(0,Xt.ensureBytes)("message",S),i&&(S=i(S));let{prefix:J,scalar:ae,pointBytes:ce}=q(B),D=Q(V.context,J,S),F=K.multiply(D).toRawBytes(),p=Q(V.context,F,ce,S),L=G(D+p*ae);Yt.aInRange("signature.s",L,gr,n);let re=Yt.concatBytes(F,Yt.numberToBytesLE(L,r.BYTES));return(0,Xt.ensureBytes)("result",re,a*2)}let w=d2;function m(S,B,V,J=w){let{context:ae,zip215:ce}=J,D=r.BYTES;S=(0,Xt.ensureBytes)("signature",S,2*D),B=(0,Xt.ensureBytes)("message",B),ce!==void 0&&(0,Xt.abool)("zip215",ce),i&&(B=i(B));let F=Yt.bytesToNumberLE(S.slice(D,2*D)),p,L,re;try{p=A.fromHex(V,ce),L=A.fromHex(S.slice(0,D),ce),re=K.multiplyUnsafe(F)}catch{return!1}if(!ce&&p.isSmallOrder())return!1;let le=Q(ae,L.toRawBytes(),p.toRawBytes(),B);return L.add(p.multiplyUnsafe(le)).subtract(re).clearCofactor().equals(A.ZERO)}return K._setWindowSize(8),{CURVE:e,getPublicKey:oe,sign:ie,verify:m,ExtendedPoint:A,utils:{getExtendedPublicKey:q,randomPrivateKey:()=>o(r.BYTES),precompute(S=8,B=A.BASE){return B._setWindowSize(S),B.multiply(BigInt(3)),B}}}}});var up=ee(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});Pl.montgomery=_2;var cp=Mr(),Sn=Dt(),Ri=BigInt(0),Bl=BigInt(1);function y2(t){return(0,Sn.validateObject)(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function _2(t){let e=y2(t),{P:r}=e,n=M=>(0,cp.mod)(M,r),i=e.montgomeryBits,s=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(M=>M),c=e.powPminus2||(M=>(0,cp.pow)(M,r-BigInt(2),r));function f(M,A,K){let E=n(M*(A-K));return A=n(A-E),K=n(K+E),[A,K]}let d=(e.a-BigInt(2))/BigInt(4);function h(M,A){(0,Sn.aInRange)("u",M,Ri,r),(0,Sn.aInRange)("scalar",A,Ri,r);let K=A,E=M,k=Bl,G=Ri,z=M,q=Bl,oe=Ri,Q;for(let w=BigInt(i-1);w>=Ri;w--){let m=K>>w&Bl;oe^=m,Q=f(oe,k,z),k=Q[0],z=Q[1],Q=f(oe,G,q),G=Q[0],q=Q[1],oe=m;let R=k+G,S=n(R*R),B=k-G,V=n(B*B),J=S-V,ae=z+q,ce=z-q,D=n(ce*R),F=n(ae*B),p=D+F,L=D-F;z=n(p*p),q=n(E*n(L*L)),k=n(S*V),G=n(J*(S+n(d*J)))}Q=f(oe,k,z),k=Q[0],z=Q[1],Q=f(oe,G,q),G=Q[0],q=Q[1];let ie=c(G);return n(k*ie)}function g(M){return(0,Sn.numberToBytesLE)(n(M),s)}function b(M){let A=(0,Sn.ensureBytes)("u coordinate",M,s);return o===32&&(A[31]&=127),(0,Sn.bytesToNumberLE)(A)}function l(M){let A=(0,Sn.ensureBytes)("scalar",M),K=A.length;if(K!==s&&K!==o)throw new Error(`Expected ${s} or ${o} bytes, got ${K}`);return(0,Sn.bytesToNumberLE)(a(A))}function N(M,A){let K=b(A),E=l(M),k=h(K,E);if(k===Ri)throw new Error("Invalid private or public key received");return g(k)}let O=g(e.Gu);function I(M){return N(M,O)}return{scalarMult:N,scalarMultBase:I,getSharedSecret:(M,A)=>N(M,A),getPublicKey:M=>I(M),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:O}}});var kl=ee(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.hash_to_ristretto255=ge.hashToRistretto255=ge.RistrettoPoint=ge.encodeToCurve=ge.hashToCurve=ge.edwardsToMontgomery=ge.x25519=ge.ed25519ph=ge.ed25519ctx=ge.ed25519=ge.ED25519_TORSION_SUBGROUP=void 0;ge.edwardsToMontgomeryPub=bp;ge.edwardsToMontgomeryPriv=b2;var Sa=sp(),Ns=kn(),Ml=ap(),hp=oa(),Ce=Mr(),g2=up(),zn=Dt(),Rs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Cl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),m2=BigInt(0),qr=BigInt(1),Oa=BigInt(2),pp=BigInt(3),yp=BigInt(5),ql=BigInt(8);function _p(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=Rs,a=t*t%s*t%s,c=(0,Ce.pow2)(a,Oa,s)*a%s,f=(0,Ce.pow2)(c,qr,s)*t%s,d=(0,Ce.pow2)(f,yp,s)*f%s,h=(0,Ce.pow2)(d,e,s)*d%s,g=(0,Ce.pow2)(h,r,s)*h%s,b=(0,Ce.pow2)(g,n,s)*g%s,l=(0,Ce.pow2)(b,i,s)*b%s,N=(0,Ce.pow2)(l,i,s)*b%s,O=(0,Ce.pow2)(N,e,s)*d%s;return{pow_p_5_8:(0,Ce.pow2)(O,Oa,s)*t%s,b2:a}}function gp(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function jl(t,e){let r=Rs,n=(0,Ce.mod)(e*e*e,r),i=(0,Ce.mod)(n*n*e,r),s=_p(t*i).pow_p_5_8,o=(0,Ce.mod)(t*n*s,r),a=(0,Ce.mod)(e*o*o,r),c=o,f=(0,Ce.mod)(o*Cl,r),d=a===t,h=a===(0,Ce.mod)(-t,r),g=a===(0,Ce.mod)(-t*Cl,r);return d&&(o=c),(h||g)&&(o=f),(0,Ce.isNegativeLE)(o,r)&&(o=(0,Ce.mod)(-o,r)),{isValid:d||h,value:o}}ge.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var ue=(0,Ce.Field)(Rs,void 0,!0),Bs={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ue,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:ql,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Sa.sha512,randomBytes:Ns.randomBytes,adjustScalarBytes:gp,uvRatio:jl};ge.ed25519=(0,Ml.twistedEdwards)(Bs);function mp(t,e,r){if(e.length>255)throw new Error("Context is too big");return(0,Ns.concatBytes)((0,Ns.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}ge.ed25519ctx=(0,Ml.twistedEdwards)({...Bs,domain:mp});ge.ed25519ph=(0,Ml.twistedEdwards)(Object.assign({},Bs,{domain:mp,prehash:Sa.sha512}));ge.x25519=(0,g2.montgomery)({P:Rs,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=Rs,{pow_p_5_8:r,b2:n}=_p(t);return(0,Ce.mod)((0,Ce.pow2)(r,pp,e)*n,e)},adjustScalarBytes:gp,randomBytes:Ns.randomBytes});function bp(t){let{y:e}=ge.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return ue.toBytes(ue.create((r+e)*ue.inv(r-e)))}ge.edwardsToMontgomery=bp;function b2(t){let e=Bs.hash(t.subarray(0,32));return Bs.adjustScalarBytes(e).subarray(0,32)}var w2=(ue.ORDER+pp)/ql,E2=ue.pow(Oa,w2),lp=ue.sqrt(ue.neg(ue.ONE));function x2(t){let e=(ue.ORDER-yp)/ql,r=BigInt(486662),n=ue.sqr(t);n=ue.mul(n,Oa);let i=ue.add(n,ue.ONE),s=ue.neg(r),o=ue.sqr(i),a=ue.mul(o,i),c=ue.mul(n,r);c=ue.mul(c,s),c=ue.add(c,o),c=ue.mul(c,s);let f=ue.sqr(a);o=ue.sqr(f),f=ue.mul(f,a),f=ue.mul(f,c),o=ue.mul(o,f);let d=ue.pow(o,e);d=ue.mul(d,f);let h=ue.mul(d,lp);o=ue.sqr(d),o=ue.mul(o,a);let g=ue.eql(o,c),b=ue.cmov(h,d,g),l=ue.mul(s,n),N=ue.mul(d,t);N=ue.mul(N,E2);let O=ue.mul(N,lp),I=ue.mul(c,n);o=ue.sqr(N),o=ue.mul(o,a);let M=ue.eql(o,I),A=ue.cmov(O,N,M);o=ue.sqr(b),o=ue.mul(o,a);let K=ue.eql(o,c),E=ue.cmov(l,s,K),k=ue.cmov(A,b,K),G=ue.isOdd(k);return k=ue.cmov(k,ue.neg(k),K!==G),{xMn:E,xMd:i,yMn:k,yMd:qr}}var v2=(0,Ce.FpSqrtEven)(ue,ue.neg(BigInt(486664)));function T2(t){let{xMn:e,xMd:r,yMn:n,yMd:i}=x2(t),s=ue.mul(e,i);s=ue.mul(s,v2);let o=ue.mul(r,n),a=ue.sub(e,r),c=ue.add(e,r),f=ue.mul(o,c),d=ue.eql(f,ue.ZERO);s=ue.cmov(s,ue.ZERO,d),o=ue.cmov(o,ue.ONE,d),a=ue.cmov(a,ue.ONE,d),c=ue.cmov(c,ue.ONE,d);let h=ue.invertBatch([o,c]);return{x:ue.mul(s,h[0]),y:ue.mul(a,h[1])}}var wp=(0,hp.createHasher)(ge.ed25519.ExtendedPoint,t=>T2(t[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:ue.ORDER,m:1,k:128,expand:"xmd",hash:Sa.sha512});ge.hashToCurve=wp.hashToCurve;ge.encodeToCurve=wp.encodeToCurve;function Ul(t){if(!(t instanceof mr))throw new Error("RistrettoPoint expected")}var Fl=Cl,A2=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),O2=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),S2=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),N2=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),fp=t=>jl(qr,t),R2=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Il=t=>ge.ed25519.CURVE.Fp.create((0,zn.bytesToNumberLE)(t)&R2);function dp(t){let{d:e}=ge.ed25519.CURVE,r=ge.ed25519.CURVE.Fp.ORDER,n=ge.ed25519.CURVE.Fp.create,i=n(Fl*t*t),s=n((i+qr)*S2),o=BigInt(-1),a=n((o-e*i)*n(i+e)),{isValid:c,value:f}=jl(s,a),d=n(f*t);(0,Ce.isNegativeLE)(d,r)||(d=n(-d)),c||(f=d),c||(o=i);let h=n(o*(i-qr)*N2-a),g=f*f,b=n((f+f)*a),l=n(h*A2),N=n(qr-g),O=n(qr+g);return new ge.ed25519.ExtendedPoint(n(b*O),n(N*l),n(l*O),n(b*N))}var mr=class t{constructor(e){this.ep=e}static fromAffine(e){return new t(ge.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,zn.ensureBytes)("ristrettoHash",e,64);let r=Il(e.slice(0,32)),n=dp(r),i=Il(e.slice(32,64)),s=dp(i);return new t(n.add(s))}static fromHex(e){e=(0,zn.ensureBytes)("ristrettoHex",e,32);let{a:r,d:n}=ge.ed25519.CURVE,i=ge.ed25519.CURVE.Fp.ORDER,s=ge.ed25519.CURVE.Fp.create,o="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=Il(e);if(!(0,zn.equalBytes)((0,zn.numberToBytesLE)(a,32),e)||(0,Ce.isNegativeLE)(a,i))throw new Error(o);let c=s(a*a),f=s(qr+r*c),d=s(qr-r*c),h=s(f*f),g=s(d*d),b=s(r*n*h-g),{isValid:l,value:N}=fp(s(b*g)),O=s(N*d),I=s(N*O*b),M=s((a+a)*O);(0,Ce.isNegativeLE)(M,i)&&(M=s(-M));let A=s(f*I),K=s(M*A);if(!l||(0,Ce.isNegativeLE)(K,i)||A===m2)throw new Error(o);return new t(new ge.ed25519.ExtendedPoint(M,A,qr,K))}toRawBytes(){let{ex:e,ey:r,ez:n,et:i}=this.ep,s=ge.ed25519.CURVE.Fp.ORDER,o=ge.ed25519.CURVE.Fp.create,a=o(o(n+r)*o(n-r)),c=o(e*r),f=o(c*c),{value:d}=fp(o(a*f)),h=o(d*a),g=o(d*c),b=o(h*g*i),l;if((0,Ce.isNegativeLE)(i*b,s)){let O=o(r*Fl),I=o(e*Fl);e=O,r=I,l=o(h*O2)}else l=g;(0,Ce.isNegativeLE)(e*b,s)&&(r=o(-r));let N=o((n-r)*l);return(0,Ce.isNegativeLE)(N,s)&&(N=o(-N)),(0,zn.numberToBytesLE)(N,32)}toHex(){return(0,zn.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){Ul(e);let{ex:r,ey:n}=this.ep,{ex:i,ey:s}=e.ep,o=ge.ed25519.CURVE.Fp.create,a=o(r*s)===o(n*i),c=o(n*s)===o(r*i);return a||c}add(e){return Ul(e),new t(this.ep.add(e.ep))}subtract(e){return Ul(e),new t(this.ep.subtract(e.ep))}multiply(e){return new t(this.ep.multiply(e))}multiplyUnsafe(e){return new t(this.ep.multiplyUnsafe(e))}double(){return new t(this.ep.double())}negate(){return new t(this.ep.negate())}};ge.RistrettoPoint=(mr.BASE||(mr.BASE=new mr(ge.ed25519.ExtendedPoint.BASE)),mr.ZERO||(mr.ZERO=new mr(ge.ed25519.ExtendedPoint.ZERO)),mr);var B2=(t,e)=>{let r=e.DST,n=typeof r=="string"?(0,Ns.utf8ToBytes)(r):r,i=(0,hp.expand_message_xmd)(t,n,64,Sa.sha512);return mr.hashToCurve(i)};ge.hashToRistretto255=B2;ge.hash_to_ristretto255=ge.hashToRistretto255});var Tp=ee(Nn=>{"use strict";var Ep=Nn&&Nn.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},jt=Nn&&Nn.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Rt,Ps,xp,vp;Object.defineProperty(Nn,"__esModule",{value:!0});Nn.ExpirableMap=void 0;var Vl=class{constructor(e={}){Rt.set(this,void 0),Ps.set(this,void 0),this[xp]=this.entries.bind(this),this[vp]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();Ep(this,Rt,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),Ep(this,Ps,n,"f")}prune(){let e=Date.now();for(let[r,n]of jt(this,Rt,"f").entries())e-n.timestamp>jt(this,Ps,"f")&&jt(this,Rt,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return jt(this,Rt,"f").set(e,n),this}get(e){let r=jt(this,Rt,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>jt(this,Ps,"f")){jt(this,Rt,"f").delete(e);return}return r.value}}clear(){jt(this,Rt,"f").clear()}entries(){let e=jt(this,Rt,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=jt(this,Rt,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return jt(this,Rt,"f").keys()}forEach(e,r){for(let[n,i]of jt(this,Rt,"f").entries())e.call(r,i.value,n,this)}has(e){return jt(this,Rt,"f").has(e)}delete(e){return jt(this,Rt,"f").delete(e)}get size(){return jt(this,Rt,"f").size}};Nn.ExpirableMap=Vl;Rt=new WeakMap,Ps=new WeakMap,xp=Symbol.iterator,vp=Symbol.toStringTag});var Hl=ee(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});ke.unwrapDER=ke.wrapDER=ke.SECP256K1_OID=ke.ED25519_OID=ke.DER_COSE_OID=ke.decodeLen=ke.decodeLenBytes=ke.encodeLen=ke.encodeLenBytes=void 0;var P2=Ht(),U2=t=>{if(t<=127)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")};ke.encodeLenBytes=U2;var I2=(t,e,r)=>{if(r<=127)return t[e]=r,1;if(r<=255)return t[e]=129,t[e+1]=r,2;if(r<=65535)return t[e]=130,t[e+1]=r>>8,t[e+2]=r,3;if(r<=16777215)return t[e]=131,t[e+1]=r>>16,t[e+2]=r>>8,t[e+3]=r,4;throw new Error("Length too long (> 4 bytes)")};ke.encodeLen=I2;var C2=(t,e)=>{if(t[e]<128)return 1;if(t[e]===128)throw new Error("Invalid length 0");if(t[e]===129)return 2;if(t[e]===130)return 3;if(t[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")};ke.decodeLenBytes=C2;var F2=(t,e)=>{let r=(0,ke.decodeLenBytes)(t,e);if(r===1)return t[e];if(r===2)return t[e+1];if(r===3)return(t[e+1]<<8)+t[e+2];if(r===4)return(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];throw new Error("Length too long (> 4 bytes)")};ke.decodeLen=F2;ke.DER_COSE_OID=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]);ke.ED25519_OID=Uint8Array.from([48,5,6,3,43,101,112]);ke.SECP256K1_OID=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function M2(t,e){let r=2+(0,ke.encodeLenBytes)(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,s=new Uint8Array(1+(0,ke.encodeLenBytes)(n)+n);return s[i++]=48,i+=(0,ke.encodeLen)(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=(0,ke.encodeLen)(s,i,t.byteLength+1),s[i++]=0,s.set(new Uint8Array(t),i),s}ke.wrapDER=M2;var q2=(t,e)=>{let r=0,n=(a,c)=>{if(i[r++]!==a)throw new Error("Expected: "+c)},i=new Uint8Array(t);if(n(48,"sequence"),r+=(0,ke.decodeLenBytes)(i,r),!(0,P2.bufEquals)(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let s=(0,ke.decodeLen)(i,r)-1;r+=(0,ke.decodeLenBytes)(i,r),n(0,"0 padding");let o=i.slice(r);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o};ke.unwrapDER=q2});var $l=ee(Rn=>{"use strict";var Ap=Rn&&Rn.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Op=Rn&&Rn.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ra,Ba;Object.defineProperty(Rn,"__esModule",{value:!0});Rn.Ed25519PublicKey=void 0;var Na=Hl(),Pa=class t{constructor(e){if(Ra.set(this,void 0),Ba.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Ap(this,Ra,e,"f"),Ap(this,Ba,t.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){return(0,Na.wrapDER)(e,Na.ED25519_OID).buffer}static derDecode(e){let r=(0,Na.unwrapDER)(e,Na.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Op(this,Ra,"f")}get derKey(){return Op(this,Ba,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Rn.Ed25519PublicKey=Pa;Ra=new WeakMap,Ba=new WeakMap;Pa.RAW_KEY_LENGTH=32});var Gl=ee(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.ObservableLog=Bi.Observable=void 0;var Ua=class{constructor(){this.observers=[]}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e,...r){this.observers.forEach(n=>n(e,...r))}};Bi.Observable=Ua;var Kl=class extends Ua{constructor(){super()}print(e,...r){this.notify({message:e,level:"info"},...r)}warn(e,...r){this.notify({message:e,level:"warn"},...r)}error(e,r,...n){this.notify({message:e,level:"error",error:r},...n)}};Bi.ObservableLog=Kl});var Ip=ee(Vr=>{"use strict";var jr=Vr&&Vr.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Bt=Vr&&Vr.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},kr,Ia,Ca,Fa,Ma,qa,ja,ka,Pi;Object.defineProperty(Vr,"__esModule",{value:!0});Vr.exponentialBackoff=Vr.ExponentialBackoff=void 0;var Sp=.5,Np=1.5,Rp=500,Bp=6e4,Pp=9e5,Up=10,Ui=class t{constructor(e=t.default){kr.set(this,void 0),Ia.set(this,void 0),Ca.set(this,void 0),Fa.set(this,void 0),Ma.set(this,void 0),qa.set(this,void 0),ja.set(this,void 0),ka.set(this,void 0),Pi.set(this,0);let{initialInterval:r=Rp,randomizationFactor:n=Sp,multiplier:i=Np,maxInterval:s=Bp,maxElapsedTime:o=Pp,maxIterations:a=Up,date:c=Date}=e;jr(this,kr,r,"f"),jr(this,Ia,n,"f"),jr(this,Ca,i,"f"),jr(this,Fa,s,"f"),jr(this,ka,c,"f"),jr(this,Ma,c.now(),"f"),jr(this,qa,o,"f"),jr(this,ja,a,"f")}get ellapsedTimeInMsec(){return Bt(this,ka,"f").now()-Bt(this,Ma,"f")}get currentInterval(){return Bt(this,kr,"f")}get count(){return Bt(this,Pi,"f")}get randomValueFromInterval(){let e=Bt(this,Ia,"f")*Bt(this,kr,"f"),r=Bt(this,kr,"f")-e,n=Bt(this,kr,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return jr(this,kr,Math.min(Bt(this,kr,"f")*Bt(this,Ca,"f"),Bt(this,Fa,"f")),"f"),jr(this,Pi,(e=Bt(this,Pi,"f"),e++,e),"f"),Bt(this,kr,"f")}next(){return this.ellapsedTimeInMsec>=Bt(this,qa,"f")||Bt(this,Pi,"f")>=Bt(this,ja,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Vr.ExponentialBackoff=Ui;kr=new WeakMap,Ia=new WeakMap,Ca=new WeakMap,Fa=new WeakMap,Ma=new WeakMap,qa=new WeakMap,ja=new WeakMap,ka=new WeakMap,Pi=new WeakMap;Ui.default={initialInterval:Rp,randomizationFactor:Sp,multiplier:Np,maxInterval:Bp,maxElapsedTime:Pp,maxIterations:Up,date:Date};function*j2(t=Ui.default){let e=new Ui(t),r=e.next();for(;r;)yield r,r=e.next()}Vr.exponentialBackoff=j2});var zl=ee(Fe=>{"use strict";var Fp=Fe&&Fe.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),k2=Fe&&Fe.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Mp=Fe&&Fe.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Fp(e,t,r);return k2(e,t),e},qp=Fe&&Fe.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Fp(e,t,r)},xt=Fe&&Fe.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ne=Fe&&Fe.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Pt,Dn,ji,Hr,sn,qi,Us,Ci,wr,Er,Jn,Zn,Is,Fi,Mi,Xn,Ln,jp,$a,Ka,Qn;Object.defineProperty(Fe,"__esModule",{value:!0});Fe.HttpAgent=Fe.IdentityInvalidError=Fe.MANAGEMENT_CANISTER_ID=Fe.IC_ROOT_KEY=Fe.RequestStatusResponseStatus=Fe.makeNonce=void 0;var sr=It(),$r=yi(),Cp=Vu(),Bn=Mp(ys()),Va=ds(),br=Ht(),xr=Qo(),Yl=_s(),ki=ea(),V2=Ss(),Ii=Ni(),H2=kl(),$2=Tp(),K2=$l(),G2=ya(),Y2=Gl(),W2=Ip();qp(Qo(),Fe);qp(ea(),Fe);var z2=_s();Object.defineProperty(Fe,"makeNonce",{enumerable:!0,get:function(){return z2.makeNonce}});var D2;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(D2=Fe.RequestStatusResponseStatus||(Fe.RequestStatusResponseStatus={}));var Ha=60*1e3;Fe.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";Fe.MANAGEMENT_CANISTER_ID="aaaaa-aa";var J2="ic0.app",Z2=".ic0.app",X2="icp0.io",Q2=".icp0.io",L2="icp-api.io",eE=".icp-api.io",Cs=class extends $r.AgentError{constructor(e){super(e),this.message=e}},ei=class extends $r.AgentError{constructor(e){super(e),this.message=e}};Fe.IdentityInvalidError=ei;function tE(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new Cs("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof global<"u")if(global.fetch)t=global.fetch.bind(global);else throw new Cs("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(t=self.fetch.bind(self));if(t)return t;throw new Cs("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function rE(t){let e;if(t!==void 0)!t.match(/^[a-z]+:/)&&typeof window<"u"?e=new URL(window.location.protocol+"//"+t):e=new URL(t);else{let r=["ic0.app","icp0.io","127.0.0.1","localhost"],n=[".github.dev",".gitpod.io"],i=typeof window<"u"?window.location:void 0,s=i?.hostname,o;s&&typeof s=="string"&&(n.some(a=>s.endsWith(a))?o=s:o=r.find(a=>s.endsWith(a))),i&&o?e=new URL(`${i.protocol}//${o}${i.port?":"+i.port:""}`):e=new URL("https://icp-api.io")}return e.toString()}var Wl=class t{constructor(e={}){var r,n;Pt.add(this),Dn.set(this,null),ji.set(this,!1),Hr.set(this,void 0),sn.set(this,void 0),qi.set(this,void 0),Us.set(this,void 0),Ci.set(this,0),wr.set(this,void 0),Er.set(this,void 0),Jn.set(this,void 0),Zn.set(this,void 0),this._isAgent=!0,this.config={},Is.set(this,0),this.log=new Y2.ObservableLog,Fi.set(this,[]),Mi.set(this,[]),Xn.set(this,new $2.ExpirableMap({expirationTime:5*60*1e3})),Ln.set(this,!0),Ka.set(this,(o,a)=>{if(ne(this,Ln,"f")===!1)return o;if(!a)throw new Ii.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:c,signatures:f=[],requestId:d}=o,h=new TextEncoder().encode("\vic-response");for(let g of f){let{timestamp:b,identity:l}=g,N=sr.Principal.fromUint8Array(l).toText(),O;if(c==="replied"){let{reply:E}=o;O=(0,Va.hashOfMap)({status:c,reply:E,timestamp:BigInt(b),request_id:d})}else if(c==="rejected"){let{reject_code:E,reject_message:k,error_code:G}=o;O=(0,Va.hashOfMap)({status:c,reject_code:E,reject_message:k,error_code:G,timestamp:BigInt(b),request_id:d})}else throw new Error(`Unknown status: ${c}`);let I=(0,br.concat)(h,new Uint8Array(O)),M=a?.nodeKeys.get(N);if(!M)throw new Ii.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let A=K2.Ed25519PublicKey.fromDer(M).rawKey;if(H2.ed25519.verify(g.signature,new Uint8Array(I),new Uint8Array(A)))return o;throw new Ii.CertificateVerificationError(`Invalid signature from replica ${N} signed query.`)}return o}),this.config=e,xt(this,sn,e.fetch||tE()||fetch.bind(global),"f"),xt(this,qi,e.fetchOptions,"f"),xt(this,Us,e.callOptions,"f"),xt(this,ji,(r=e.shouldFetchRootKey)!==null&&r!==void 0?r:!1,"f"),e.rootKey?this.rootKey=e.rootKey:ne(this,ji,"f")?this.rootKey=null:this.rootKey=(0,br.fromHex)(Fe.IC_ROOT_KEY);let i=rE(e.host);this.host=new URL(i),e.verifyQuerySignatures!==void 0&&xt(this,Ln,e.verifyQuerySignatures,"f"),xt(this,Er,(n=e.retryTimes)!==null&&n!==void 0?n:3,"f");let s=()=>new W2.ExponentialBackoff({maxIterations:ne(this,Er,"f")});if(xt(this,Jn,e.backoffStrategy||s,"f"),this.host.hostname.endsWith(Z2)?this.host.hostname=J2:this.host.hostname.endsWith(Q2)?this.host.hostname=X2:this.host.hostname.endsWith(eE)&&(this.host.hostname=L2),e.credentials){let{name:o,password:a}=e.credentials;xt(this,wr,`${o}${a?":"+a:""}`,"f")}if(xt(this,Hr,Promise.resolve(e.identity||new Cp.AnonymousIdentity),"f"),e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes>5)throw new $r.AgentError(`The maximum ingress expiry time is 5 minutes. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);if(e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes<=0)throw new $r.AgentError(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);xt(this,Zn,e.ingressExpiryInMinutes||5,"f"),this.addTransform("update",(0,xr.makeNonceTransform)(Yl.makeNonce)),e.useQueryNonces&&this.addTransform("query",(0,xr.makeNonceTransform)(Yl.makeNonce)),e.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 ne(this,Is,"f")}static createSync(e={}){return new this(Object.assign({},e))}static async create(e={shouldFetchRootKey:!1}){let r=t.createSync(e),n=[r.syncTime()];return r.host.toString()!=="https://icp-api.io"&&e.shouldFetchRootKey&&n.push(r.fetchRootKey()),await Promise.all(n),r}static async from(e){var r;try{return"config"in e?await t.create(e.config):await t.create({fetch:e._fetch,fetchOptions:e._fetchOptions,callOptions:e._callOptions,host:e._host.toString(),identity:(r=e._identity)!==null&&r!==void 0?r:void 0})}catch{throw new $r.AgentError("Failed to create agent from provided agent")}}isLocal(){let e=this.host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,r,n=r.priority||0){if(e==="update"){let i=ne(this,Mi,"f").findIndex(s=>(s.priority||0)<n);ne(this,Mi,"f").splice(i>=0?i:ne(this,Mi,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=ne(this,Fi,"f").findIndex(s=>(s.priority||0)<n);ne(this,Fi,"f").splice(i>=0?i:ne(this,Fi,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!ne(this,Hr,"f"))throw new ei("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ne(this,Hr,"f")).getPrincipal()}async call(e,r,n){var i,s;await ne(this,Pt,"m",Qn).call(this);let o=(i=r.callSync)!==null&&i!==void 0?i:!0,a=await(n!==void 0?await n:await ne(this,Hr,"f"));if(!a)throw new ei("This identity has expired due this application's security policy. Please refresh your authentication.");let c=sr.Principal.from(e),f=r.effectiveCanisterId?sr.Principal.from(r.effectiveCanisterId):c,d=a.getPrincipal()||sr.Principal.anonymous(),h=new xr.Expiry(ne(this,Zn,"f")*Ha);Math.abs(ne(this,Ci,"f"))>1e3*30&&(h=new xr.Expiry(ne(this,Zn,"f")*Ha+ne(this,Ci,"f")));let g={request_type:Yl.SubmitRequestType.Call,canister_id:c,method_name:r.methodName,arg:r.arg,sender:d,ingress_expiry:h},b=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,wr,"f")?{Authorization:"Basic "+btoa(ne(this,wr,"f"))}:{})},endpoint:"call",body:g}),l=b.body.nonce?N(b.body.nonce):void 0;g.nonce=l;function N(A){return new Uint8Array(A)}b=await a.transformRequest(b);let O=Bn.encode(b.body),I=ne(this,Jn,"f").call(this),M=(0,Va.requestIdOf)(g);try{let A=()=>(this.log.print(`fetching "/api/v3/canister/${f.toText()}/call" with request:`,b),ne(this,sn,"f").call(this,""+new URL(`/api/v3/canister/${f.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,Us,"f")),b.request),{body:O}))),K=()=>(this.log.print(`fetching "/api/v2/canister/${f.toText()}/call" with request:`,b),ne(this,sn,"f").call(this,""+new URL(`/api/v2/canister/${f.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,Us,"f")),b.request),{body:O}))),k=await ne(this,Pt,"m",$a).call(this,{request:o?A:K,backoff:I,tries:0}),G=await k.arrayBuffer(),z=k.status===200&&G.byteLength>0?Bn.decode(G):null;if(z&&"certificate"in z){let q=await this.parseTimeFromResponse({certificate:z.certificate});xt(this,Is,q,"f")}return{requestId:M,response:{ok:k.ok,status:k.status,statusText:k.statusText,body:z,headers:(0,xr.httpHeadersTransform)(k.headers)},requestDetails:g}}catch(A){if(A.message.includes("v3 api not supported."))return this.log.warn("v3 api not supported. Fall back to v2"),this.call(e,Object.assign(Object.assign({},r),{callSync:!1}),n);let K=`Error while making call: ${(s=A.message)!==null&&s!==void 0?s:String(A)}`,E=new ki.AgentCallError(K,A,(0,br.toHex)(M),(0,br.toHex)(b.body.sender_pubkey),(0,br.toHex)(b.body.sender_sig),String(b.body.content.ingress_expiry._value));throw this.log.error(K,E),E}}async query(e,r,n){var i,s,o,a;await ne(this,Pt,"m",Qn).call(this);let c=ne(this,Jn,"f").call(this),f=r.effectiveCanisterId?sr.Principal.from(r.effectiveCanisterId):sr.Principal.from(e);this.log.print(`ecid ${f.toString()}`),this.log.print(`canisterId ${e.toString()}`);let d,h,g=await(n!==void 0?n:ne(this,Hr,"f"));if(!g)throw new ei("This identity has expired due this application's security policy. Please refresh your authentication.");let b=sr.Principal.from(e),l=g?.getPrincipal()||sr.Principal.anonymous(),N={request_type:"query",canister_id:b,method_name:r.methodName,arg:r.arg,sender:l,ingress_expiry:new xr.Expiry(ne(this,Zn,"f")*Ha)},O=(0,Va.requestIdOf)(N);d=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,wr,"f")?{Authorization:"Basic "+btoa(ne(this,wr,"f"))}:{})},endpoint:"read",body:N}),d=await g?.transformRequest(d);let I=Bn.encode(d.body),M={canister:b.toText(),ecid:f,transformedRequest:d,body:I,requestId:O,backoff:c,tries:0},A=async()=>({requestDetails:N,query:await ne(this,Pt,"m",jp).call(this,M)}),K=async()=>{if(!ne(this,Ln,"f"))return;let E=ne(this,Xn,"f").get(f.toString());return E||(await this.fetchSubnetKeys(f.toString()),ne(this,Xn,"f").get(f.toString()))};try{let[E,k]=await Promise.all([A(),K()]);h=E;let{requestDetails:G,query:z}=h,q=Object.assign(Object.assign({},z),{requestDetails:G});if(this.log.print("Query response:",q),!ne(this,Ln,"f"))return q;try{return ne(this,Ka,"f").call(this,q,k)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ne(this,Xn,"f").delete(e.toString()),await this.fetchSubnetKeys(f.toString());let Q=ne(this,Xn,"f").get(e.toString());if(!Q)throw new Ii.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return ne(this,Ka,"f").call(this,q,Q)}}catch(E){let k=`Error while making call: ${(i=E.message)!==null&&i!==void 0?i:String(E)}`,G=new ki.AgentQueryError(k,E,String(O),(0,br.toHex)((s=d?.body)===null||s===void 0?void 0:s.sender_pubkey),(0,br.toHex)((o=d?.body)===null||o===void 0?void 0:o.sender_sig),String((a=d?.body)===null||a===void 0?void 0:a.content.ingress_expiry._value));throw this.log.error(k,G),G}}async createReadStateRequest(e,r){await ne(this,Pt,"m",Qn).call(this);let n=await(r!==void 0?await r:await ne(this,Hr,"f"));if(!n)throw new ei("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||sr.Principal.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ne(this,wr,"f")?{Authorization:"Basic "+btoa(ne(this,wr,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new xr.Expiry(ne(this,Zn,"f")*Ha)}});return n?.transformRequest(s)}async readState(e,r,n,i){var s,o,a,c;function f(N){for(let O of N.paths){let[I,M]=O,A=new TextEncoder().encode("request_status");if((0,br.bufEquals)(I,A))return M}}let d=f(r);await ne(this,Pt,"m",Qn).call(this);let h=typeof e=="string"?sr.Principal.fromText(e):e,g=i??await this.createReadStateRequest(r,n),b=Bn.encode(g.body);this.log.print(`fetching "/api/v2/canister/${h}/read_state" with request:`,g);let l=ne(this,Jn,"f").call(this);try{let N=await ne(this,Pt,"m",$a).call(this,{request:()=>ne(this,sn,"f").call(this,""+new URL(`/api/v2/canister/${h.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,qi,"f")),g.request),{body:b})),backoff:l,tries:0});if(!N.ok)throw new Error(`Server returned an error:
|
|
31
31
|
Code: ${N.status} (${N.statusText})
|
|
32
32
|
Body: ${await N.text()}
|
|
33
|
-
`);let O=Bn.decode(await N.arrayBuffer());this.log.print("Read state response:",O);let I=await this.parseTimeFromResponse(O);return I>0&&(this.log.print("Read state response time:",I),xt(this,Is,I,"f")),O}catch(N){let O=`Caught exception while attempting to read state: ${(s=N.message)!==null&&s!==void 0?s:String(N)}`,I=new ki.AgentReadStateError(O,N,String(d),(0,
|
|
33
|
+
`);let O=Bn.decode(await N.arrayBuffer());this.log.print("Read state response:",O);let I=await this.parseTimeFromResponse(O);return I>0&&(this.log.print("Read state response time:",I),xt(this,Is,I,"f")),O}catch(N){let O=`Caught exception while attempting to read state: ${(s=N.message)!==null&&s!==void 0?s:String(N)}`,I=new ki.AgentReadStateError(O,N,String(d),(0,br.toHex)((o=g?.body)===null||o===void 0?void 0:o.sender_pubkey),(0,br.toHex)((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(O,I),I}}async parseTimeFromResponse(e){let r;if(e.certificate){let n=Bn.decode(e.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=(0,Ii.lookup_path)(["time"],r);if(i.status!==Ii.LookupStatus.Found)throw new Error("Time was not found in the response or was not in its expected format.");if(!(i.value instanceof ArrayBuffer)&&!ArrayBuffer.isView(i))throw new Error("Time was not found in the response or was not in its expected format.");let s=(0,G2.decodeTime)((0,br.bufFromBufLike)(i.value));return this.log.print("Time from response:",s),this.log.print("Time from response in milliseconds:",Number(s)),Number(s)}else this.log.warn("No certificate found in response");return 0}async syncTime(e){await ne(this,Pt,"m",Qn).call(this);let r=await Promise.resolve().then(()=>Mp(Ss())),n=Date.now();try{e||this.log.print("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let i=t.createSync({identity:new Cp.AnonymousIdentity,host:this.host.toString(),fetch:ne(this,sn,"f"),retryTimes:0}),o=(await r.request({canisterId:e??sr.Principal.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:i,paths:["time"]})).get("time");o&&(xt(this,Ci,Number(o)-Number(n),"f"),this.log.notify({message:`Syncing time: offset of ${ne(this,Ci,"f")}`,level:"info"}))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=ne(this,wr,"f")?{Authorization:"Basic "+btoa(ne(this,wr,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=ne(this,Jn,"f").call(this),n=await ne(this,Pt,"m",$a).call(this,{backoff:r,request:()=>ne(this,sn,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:e},ne(this,qi,"f"))),tries:0});return Bn.decode(await n.arrayBuffer())}async fetchRootKey(){let e;return ne(this,Dn,"f")?e=await ne(this,Dn,"f"):(xt(this,Dn,new Promise((r,n)=>{this.status().then(i=>{let s=i.root_key;this.rootKey=s,r(s)}).catch(n)}),"f"),e=await ne(this,Dn,"f")),xt(this,Dn,null,"f"),e}invalidateIdentity(){xt(this,Hr,null,"f")}replaceIdentity(e){xt(this,Hr,Promise.resolve(e),"f")}async fetchSubnetKeys(e){await ne(this,Pt,"m",Qn).call(this);let r=sr.Principal.from(e),i=(await(0,V2.request)({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return ne(this,Xn,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of ne(this,Mi,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of ne(this,Fi,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};Fe.HttpAgent=Wl;Dn=new WeakMap,ji=new WeakMap,Hr=new WeakMap,sn=new WeakMap,qi=new WeakMap,Us=new WeakMap,Ci=new WeakMap,wr=new WeakMap,Er=new WeakMap,Jn=new WeakMap,Zn=new WeakMap,Is=new WeakMap,Fi=new WeakMap,Mi=new WeakMap,Xn=new WeakMap,Ln=new WeakMap,Ka=new WeakMap,Pt=new WeakSet,jp=async function t(e){var r,n;let{ecid:i,transformedRequest:s,body:o,requestId:a,backoff:c,tries:f}=e,d=f===0?0:c.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:f,backoff:c,delay:d}),d===null)throw new $r.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ne(this,Er,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);d>0&&await new Promise(l=>setTimeout(l,d));let h;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let l=await ne(this,sn,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},ne(this,qi,"f")),s.request),{body:o}));if(l.status===200){let N=Bn.decode(await l.arrayBuffer());h=Object.assign(Object.assign({},N),{httpDetails:{ok:l.ok,status:l.status,statusText:l.statusText,headers:(0,xr.httpHeadersTransform)(l.headers)},requestId:a})}else throw new ki.AgentHTTPResponseError(`Gateway returned an error:
|
|
34
34
|
Code: ${l.status} (${l.statusText})
|
|
35
35
|
Body: ${await l.text()}
|
|
36
|
-
`,{ok:l.ok,status:l.status,statusText:l.statusText,headers:(0,
|
|
36
|
+
`,{ok:l.ok,status:l.status,statusText:l.statusText,headers:(0,xr.httpHeadersTransform)(l.headers)})}catch(l){if(f<ne(this,Er,"f"))return this.log.warn(`Caught exception while attempting to make query:
|
|
37
37
|
${l}
|
|
38
|
-
Retrying query.`),await ne(this,Pt,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw l}let g=(n=(r=h.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!ne(this,Ln,"f"))return h;if(!g)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let b=Number(BigInt(g)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:b}),Number(this.waterMark)>b){let l=new
|
|
38
|
+
Retrying query.`),await ne(this,Pt,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw l}let g=(n=(r=h.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!ne(this,Ln,"f"))return h;if(!g)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let b=Number(BigInt(g)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:b}),Number(this.waterMark)>b){let l=new $r.AgentError("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",l,{timestamp:g,waterMark:this.waterMark}),f<ne(this,Er,"f"))return await ne(this,Pt,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw new $r.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ne(this,Er,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return h},$a=async function t(e){let{request:r,backoff:n,tries:i}=e,s=i===0?0:n.next();if(s===null)throw new $r.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ne(this,Er,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(f=>setTimeout(f,s));let o;try{o=await r()}catch(f){if(ne(this,Er,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
|
|
39
39
|
${f}
|
|
40
40
|
Retrying request.`),await ne(this,Pt,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw f}if(o.ok)return o;let a=await o.clone().text(),c=`Server returned an error:
|
|
41
41
|
Code: ${o.status} (${o.statusText})
|
|
42
42
|
Body: ${a}
|
|
43
|
-
`;if(o.status===404&&o.url.includes("api/v3"))throw new ki.AgentHTTPResponseError("v3 api not supported. Fall back to v2",{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,
|
|
44
|
-
Request ID: ${(0,
|
|
43
|
+
`;if(o.status===404&&o.url.includes("api/v3"))throw new ki.AgentHTTPResponseError("v3 api not supported. Fall back to v2",{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,xr.httpHeadersTransform)(o.headers)});if(i<ne(this,Er,"f"))return await ne(this,Pt,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw new ki.AgentHTTPResponseError(c,{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,xr.httpHeadersTransform)(o.headers)})},Qn=async function(){if(!this.rootKey)if(this.rootKey===null&&ne(this,ji,"f"))await this.fetchRootKey();else throw new $r.AgentError(`Invalid root key detected. The root key for this agent is ${this.rootKey} and the shouldFetchRootKey value is set to ${ne(this,ji,"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 kp=ee(on=>{"use strict";Object.defineProperty(on,"__esModule",{value:!0});on.ProxyAgent=on.ProxyStubAgent=on.ProxyMessageKind=void 0;var nE=It(),Qe;(function(t){t.Error="err",t.GetPrincipal="gp",t.GetPrincipalResponse="gpr",t.Query="q",t.QueryResponse="qr",t.Call="c",t.CallResponse="cr",t.ReadState="rs",t.ReadStateResponse="rsr",t.Status="s",t.StatusResponse="sr"})(Qe=on.ProxyMessageKind||(on.ProxyMessageKind={}));var Dl=class{constructor(e,r){this._frontend=e,this._agent=r}onmessage(e){switch(e.type){case Qe.GetPrincipal:this._agent.getPrincipal().then(r=>{this._frontend({id:e.id,type:Qe.GetPrincipalResponse,response:r.toText()})});break;case Qe.Query:this._agent.query(...e.args).then(r=>{this._frontend({id:e.id,type:Qe.QueryResponse,response:r})});break;case Qe.Call:this._agent.call(...e.args).then(r=>{this._frontend({id:e.id,type:Qe.CallResponse,response:r})});break;case Qe.ReadState:this._agent.readState(...e.args).then(r=>{this._frontend({id:e.id,type:Qe.ReadStateResponse,response:r})});break;case Qe.Status:this._agent.status().then(r=>{this._frontend({id:e.id,type:Qe.StatusResponse,response:r})});break;default:throw new Error(`Invalid message received: ${JSON.stringify(e)}`)}}};on.ProxyStubAgent=Dl;var Jl=class{constructor(e){this._backend=e,this._nextId=0,this._pendingCalls=new Map,this.rootKey=null}onmessage(e){let r=e.id,n=this._pendingCalls.get(r);if(!n)throw new Error("A proxy get the same message twice...");this._pendingCalls.delete(r);let[i,s]=n;switch(e.type){case Qe.Error:return s(e.error);case Qe.GetPrincipalResponse:case Qe.CallResponse:case Qe.QueryResponse:case Qe.ReadStateResponse:case Qe.StatusResponse:return i(e.response);default:throw new Error(`Invalid message being sent to ProxyAgent: ${JSON.stringify(e)}`)}}async getPrincipal(){return this._sendAndWait({id:this._nextId++,type:Qe.GetPrincipal}).then(e=>{if(typeof e!="string")throw new Error("Invalid principal received.");return nE.Principal.fromText(e)})}readState(e,r){return this._sendAndWait({id:this._nextId++,type:Qe.ReadState,args:[e.toString(),r]})}call(e,r){return this._sendAndWait({id:this._nextId++,type:Qe.Call,args:[e.toString(),r]})}status(){return this._sendAndWait({id:this._nextId++,type:Qe.Status})}query(e,r){return this._sendAndWait({id:this._nextId++,type:Qe.Query,args:[e.toString(),r]})}async _sendAndWait(e){return new Promise((r,n)=>{this._pendingCalls.set(e.id,[r,n]),this._backend(e)})}async fetchRootKey(){let e=(await this.status()).root_key;return this.rootKey=e,e}};on.ProxyAgent=Jl});var Os=ee(or=>{"use strict";var iE=or&&or.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Ga=or&&or.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&iE(e,t,r)};Object.defineProperty(or,"__esModule",{value:!0});or.getDefaultAgent=void 0;Ga(Vc(),or);Ga(zl(),or);Ga(ea(),or);Ga(kp(),or);function sE(){let t=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.ic.agent:global.ic.agent:window.ic.agent;if(!t)throw new Error("No Agent could be found.");return t}or.getDefaultAgent=sE});var Ya=ee(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.chain=_t.backoff=_t.timeout=_t.throttle=_t.maxAttempts=_t.conditionalDelay=_t.once=_t.defaultStrategy=void 0;var Vp=Ht(),oE=5*60*1e3;function aE(){return Yp($p(Hp(),1e3),Gp(1e3,1.2),Kp(oE))}_t.defaultStrategy=aE;function Hp(){let t=!0;return async()=>t?(t=!1,!0):!1}_t.once=Hp;function $p(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(s=>setTimeout(s,e))}}_t.conditionalDelay=$p;function cE(t){let e=t;return async(r,n,i)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${t} attempts:
|
|
44
|
+
Request ID: ${(0,Vp.toHex)(n)}
|
|
45
45
|
Request status: ${i}
|
|
46
|
-
`)}}_t.maxAttempts=cE;function uE(t){return()=>new Promise(e=>setTimeout(e,t))}_t.throttle=uE;function
|
|
47
|
-
Request ID: ${(0,
|
|
46
|
+
`)}}_t.maxAttempts=cE;function uE(t){return()=>new Promise(e=>setTimeout(e,t))}_t.throttle=uE;function Kp(t){let e=Date.now()+t;return async(r,n,i)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
|
|
47
|
+
Request ID: ${(0,Vp.toHex)(n)}
|
|
48
48
|
Request status: ${i}
|
|
49
|
-
`)}}_t.timeout
|
|
50
|
-
Request ID: ${(0,
|
|
49
|
+
`)}}_t.timeout=Kp;function Gp(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}_t.backoff=Gp;function Yp(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}_t.chain=Yp});var Wa=ee(Wt=>{"use strict";var lE=Wt&&Wt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),fE=Wt&&Wt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),dE=Wt&&Wt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&lE(e,t,r);return fE(e,t),e};Object.defineProperty(Wt,"__esModule",{value:!0});Wt.pollForResponse=Wt.defaultStrategy=Wt.strategy=void 0;var ti=Os(),Fs=Ni(),Wp=Ht();Wt.strategy=dE(Ya());var hE=Ya(),pE=Ya();Object.defineProperty(Wt,"defaultStrategy",{enumerable:!0,get:function(){return pE.defaultStrategy}});async function zp(t,e,r,n=(0,hE.defaultStrategy)(),i,s){var o;let a=[new TextEncoder().encode("request_status"),r],c=i??await((o=t.createReadStateRequest)===null||o===void 0?void 0:o.call(t,{paths:[a]})),f=await t.readState(e,{paths:[a]},void 0,c);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let d=await Fs.Certificate.create({certificate:f.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:s}),h=(0,Fs.lookupResultToBuffer)(d.lookup([...a,new TextEncoder().encode("status")])),g;switch(typeof h>"u"?g=ti.RequestStatusResponseStatus.Unknown:g=new TextDecoder().decode(h),g){case ti.RequestStatusResponseStatus.Replied:return{reply:(0,Fs.lookupResultToBuffer)(d.lookup([...a,"reply"])),certificate:d};case ti.RequestStatusResponseStatus.Received:case ti.RequestStatusResponseStatus.Unknown:case ti.RequestStatusResponseStatus.Processing:return await n(e,r,g),zp(t,e,r,n,c,s);case ti.RequestStatusResponseStatus.Rejected:{let b=new Uint8Array((0,Fs.lookupResultToBuffer)(d.lookup([...a,"reject_code"])))[0],l=new TextDecoder().decode((0,Fs.lookupResultToBuffer)(d.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
|
|
50
|
+
Request ID: ${(0,Wp.toHex)(r)}
|
|
51
51
|
Reject code: ${b}
|
|
52
52
|
Reject text: ${l}
|
|
53
53
|
`)}case ti.RequestStatusResponseStatus.Done:throw new Error(`Call was marked as done but we never saw the reply:
|
|
54
|
-
Request ID: ${(0,
|
|
55
|
-
`)}throw new Error("unreachable")}Wt.pollForResponse=
|
|
56
|
-
`)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}};Ye.ActorCallError=qs;var za=class extends qs{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=Xl.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};Ye.QueryCallRejectedError=za;var js=class extends qs{constructor(e,r,n,i,s,o,a){super(e,r,"update",Object.assign({"Request ID":(0,gE.toHex)(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}};Ye.UpdateCallRejectedError=js;var ar=Symbol.for("ic-agent-metadata"),ks=class t{constructor(e){this[ar]=Object.freeze(e)}static agentOf(e){return e[ar].config.agent}static interfaceOf(e){return e[ar].service}static canisterIdOf(e){return cr.Principal.from(e[ar].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],s=[...new Uint8Array(e.module)],o=typeof r.canisterId=="string"?cr.Principal.fromText(r.canisterId):r.canisterId;await Ll(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(e,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await Ll(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:Ms.IDL});class i extends t{constructor(o){if(!o.canisterId)throw new Ql.AgentError(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof o.canisterId=="string"?cr.Principal.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Jp),o),{canisterId:a}),service:n});for(let[c,f]of n._fields)r?.httpDetails&&f.annotations.push(Ye.ACTOR_METHOD_WITH_HTTP_DETAILS),r?.certificate&&f.annotations.push(Ye.ACTOR_METHOD_WITH_CERTIFICATE),this[c]=bE(this,c,f,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Ql.AgentError(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(e,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(e,n))(r)}};Ye.Actor=ks;function Hi(t,e){let r=Ms.IDL.decode(t,_E.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var Jp={pollingStrategyFactory:Dp.strategy.defaultStrategy};Ye.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";Ye.ACTOR_METHOD_WITH_CERTIFICATE="certificate";function bE(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ar].config).queryTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ar].config),o)));let d=o.agent||t[ar].config.agent||(0,Xl.getDefaultAgent)(),h=cr.Principal.from(o.canisterId||t[ar].config.canisterId),g=Ms.IDL.encode(r.argTypes,a),b=await d.query(h,{methodName:e,arg:g,effectiveCanisterId:o.effectiveCanisterId}),l=Object.assign(Object.assign({},b.httpDetails),{requestDetails:b.requestDetails});switch(b.status){case"rejected":throw new za(h,e,b);case"replied":return r.annotations.includes(Ye.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:l,result:Hi(r.retTypes,b.reply.arg)}:Hi(r.retTypes,b.reply.arg)}}:i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ar].config).callTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ar].config),o)));let d=o.agent||t[ar].config.agent||(0,Xl.getDefaultAgent)(),{canisterId:h,effectiveCanisterId:g,pollingStrategyFactory:b}=Object.assign(Object.assign(Object.assign({},Jp),t[ar].config),o),l=cr.Principal.from(h),N=g!==void 0?cr.Principal.from(g):l,O=Ms.IDL.encode(r.argTypes,a),{requestId:I,response:M,requestDetails:A}=await d.call(l,{methodName:e,arg:O,effectiveCanisterId:N}),K,E;if(M.body&&M.body.certificate){if(d.rootKey==null)throw new Error("Agent is missing root key");let q=M.body.certificate;E=await Vi.Certificate.create({certificate:(0,Ms.bufFromBufLike)(q),rootKey:d.rootKey,canisterId:cr.Principal.from(h),blsVerify:n});let oe=[new TextEncoder().encode("request_status"),I];switch(new TextDecoder().decode((0,Vi.lookupResultToBuffer)(E.lookup([...oe,"status"])))){case"replied":K=(0,Vi.lookupResultToBuffer)(E.lookup([...oe,"reply"]));break;case"rejected":{let ie=new Uint8Array((0,Vi.lookupResultToBuffer)(E.lookup([...oe,"reject_code"])))[0],w=new TextDecoder().decode((0,Vi.lookupResultToBuffer)(E.lookup([...oe,"reject_message"]))),m=(0,Vi.lookupResultToBuffer)(E.lookup([...oe,"error_code"])),R=m?new TextDecoder().decode(m):void 0;throw new js(l,e,I,M,ie,w,R)}}}else if(M.body&&"reject_message"in M.body){let{reject_code:q,reject_message:oe,error_code:Q}=M.body;throw new js(l,e,I,M,q,oe,Q)}if(M.status===202){let q=b(),oe=await(0,Dp.pollForResponse)(d,N,I,q,n);E=oe.certificate,K=oe.reply}let k=r.annotations.includes(Ye.ACTOR_METHOD_WITH_HTTP_DETAILS),G=r.annotations.includes(Ye.ACTOR_METHOD_WITH_CERTIFICATE),z=Object.assign(Object.assign({},M),{requestDetails:A});if(K!==void 0)return k&&G?{httpDetails:z,certificate:E,result:Hi(r.retTypes,K)}:G?{certificate:E,result:Hi(r.retTypes,K)}:k?{httpDetails:z,result:Hi(r.retTypes,K)}:Hi(r.retTypes,K);if(r.retTypes.length===0)return k?{httpDetails:M,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 Ll(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:cr.Principal.from(t.effectiveCanisterId)};let i=n[0],s=cr.Principal.fromHex("");return i&&typeof i=="object"&&i.target_canister&&r==="install_chunked_code"&&(s=cr.Principal.from(i.target_canister)),i&&typeof i=="object"&&i.canister_id&&(s=cr.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return ks.createActor(mE.default,Object.assign(Object.assign(Object.assign({},t),{canisterId:cr.Principal.fromHex("")}),{callTransform:e,queryTransform:e}))}Ye.getManagementCanister=Ll;var ef=class extends ks{constructor(e){super(e)}};Ye.AdvancedActor=ef});var Zp=ee(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});tf.default=({IDL:t})=>t.Service({retrieve:t.Func([t.Text],[t.Vec(t.Nat8)],["query"]),store:t.Func([t.Text,t.Vec(t.Nat8)],[],[])})});var Xp=ee($i=>{"use strict";var wE=$i&&$i.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty($i,"__esModule",{value:!0});$i.createAssetCanisterActor=void 0;var EE=Da(),xE=wE(Zp());function vE(t){return EE.Actor.createActor(xE.default,t)}$i.createAssetCanisterActor=vE});var Qp=ee($r=>{"use strict";var TE=$r&&$r.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),AE=$r&&$r.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),OE=$r&&$r.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&TE(e,t,r);return AE(e,t),e};Object.defineProperty($r,"__esModule",{value:!0});$r.fetchCandid=void 0;var SE=It(),NE=OE(Ss()),RE=zl(),BE=Da();async function PE(t,e){e||(e=await RE.HttpAgent.create());let n=(await NE.request({agent:e,canisterId:SE.Principal.fromText(t),paths:["candid"]})).get("candid");if(n)return n;let i=({IDL:o})=>o.Service({__get_candid_interface_tmp_hack:o.Func([],[o.Text],["query"])});return await BE.Actor.createActor(i,{agent:e,canisterId:t}).__get_candid_interface_tmp_hack()}$r.fetchCandid=PE});var Qt=ee(Pe=>{"use strict";var Lp=Pe&&Pe.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),UE=Pe&&Pe.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ut=Pe&&Pe.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Lp(e,t,r)},rf=Pe&&Pe.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Lp(e,t,r);return UE(e,t),e};Object.defineProperty(Pe,"__esModule",{value:!0});Pe.Cbor=Pe.CanisterStatus=Pe.polling=void 0;Ut(Da(),Pe);Ut(Os(),Pe);Ut(Qo(),Pe);Ut(_s(),Pe);Ut(Vu(),Pe);Ut(Xp(),Pe);Ut(Ni(),Pe);Ut(Hl(),Pe);Ut(Qp(),Pe);Ut(Gl(),Pe);Ut($l(),Pe);Ut(ds(),Pe);Ut(wl(),Pe);Ut(Ht(),Pe);Ut(Ju(),Pe);Pe.polling=rf(Wa());Pe.CanisterStatus=rf(Ss());Pe.Cbor=rf(ys());Ut(Wa(),Pe)});var gt=ee((pT,my)=>{"use strict";var cf=Object.defineProperty,IE=Object.getOwnPropertyDescriptor,CE=Object.getOwnPropertyNames,FE=Object.prototype.hasOwnProperty,ME=(t,e)=>{for(var r in e)cf(t,r,{get:e[r],enumerable:!0})},qE=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of CE(e))!FE.call(t,i)&&i!==r&&cf(t,i,{get:()=>e[i],enumerable:!(n=IE(e,i))||n.enumerable});return t},jE=t=>qE(cf({},"__esModule",{value:!0}),t),ny={};ME(ny,{AgentManager:()=>DE,Canister:()=>YE,FromStringToTokenError:()=>iy,ICPToken:()=>$E,InvalidPercentageError:()=>ly,NullishError:()=>fy,TokenAmount:()=>KE,TokenAmountV2:()=>GE,arrayBufferToUint8Array:()=>tx,arrayOfNumberToUint8Array:()=>nx,asNonNullish:()=>ZE,asciiStringToByteArray:()=>ix,assertNonNullish:()=>Gs,assertPercentageNumber:()=>XE,base64ToUint8Array:()=>lx,bigEndianCrc32:()=>hx,bigIntToUint8Array:()=>LE,candidNumberArrayToBigInt:()=>ox,convertStringToE8s:()=>sy,createAgent:()=>cy,createServices:()=>JE,debounce:()=>Ex,decodeBase32:()=>cx,defaultAgent:()=>ay,encodeBase32:()=>ax,fromDefinedNullable:()=>vx,fromNullable:()=>uf,fromNullishNullable:()=>Tx,hashObject:()=>yx,hashText:()=>yy,hexStringToUint8Array:()=>sx,isEmptyString:()=>WE,isNullish:()=>Ks,jsonReplacer:()=>py,jsonReviver:()=>px,nonNullish:()=>Kr,notEmptyString:()=>oy,nowInBigIntNanoSeconds:()=>bx,numberToUint8Array:()=>ex,principalToSubAccount:()=>Ax,queryAndUpdate:()=>zE,secondsToDuration:()=>gx,smallerVersion:()=>Ox,toBigIntNanoSeconds:()=>wx,toNullable:()=>xx,uint8ArrayToArrayOfNumber:()=>rx,uint8ArrayToBase64:()=>ux,uint8ArrayToBigInt:()=>QE,uint8ArrayToHexString:()=>dy});my.exports=jE(ny);var iy=(t=>(t[t.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",t[t.InvalidFormat=1]="InvalidFormat",t[t.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",t))(iy||{}),kE=BigInt(1e8),VE=8,sy=t=>{let e=t.includes("e")?Number(t).toLocaleString("en",{useGrouping:!1,maximumFractionDigits:20}):t;e=e.trim().replace(/[,']/g,"");let r=e.match(/\d*(\.\d*)?/);if(!r||r[0]!==e)return 1;let[n,i]=e.split("."),s=BigInt(0);if(n)try{s+=BigInt(n)*kE}catch{return 1}if(i){if(i.length>8)return 0;try{s+=BigInt(i.padEnd(8,"0"))}catch{return 1}}return s},HE=({amount:t,decimals:e})=>{t=t.trim().replace(/[,']/g,"");let r=t.match(/\d*(\.\d*)?/);if(!r||r[0]!==t)return 1;let[n,i]=t.split("."),s=0n,o=10n**BigInt(e);if(n)try{s+=BigInt(n)*o}catch{return 1}if(i){if(i.length>e)return 2;try{s+=BigInt(i.padEnd(e,"0"))}catch{return 1}}return s},$E={symbol:"ICP",name:"Internet Computer",decimals:8},KE=class Hs{constructor(e,r){if(this.e8s=e,this.token=r,r.decimals!==8)throw new Error("Use TokenAmountV2 for number of decimals other than 8")}static fromE8s({amount:e,token:r}){return new Hs(e,r)}static fromString({amount:e,token:r}){if(r.decimals!==8)throw new Error("Use TokenAmountV2 for number of decimals other than 8");let n=sy(e);return typeof n=="bigint"?new Hs(n,r):n}static fromNumber({amount:e,token:r}){let n=Hs.fromString({amount:e.toString(),token:r});if(n instanceof Hs)return n;throw n===0?new Error(`Number ${e} has more than 8 decimals`):new Error(`Invalid number ${e}`)}toE8s(){return this.e8s}},GE=class $s{constructor(e,r){this.ulps=e,this.token=r}static fromUlps({amount:e,token:r}){return new $s(e,r)}static fromString({amount:e,token:r}){let n=HE({amount:e,decimals:r.decimals});return typeof n=="bigint"?new $s(n,r):n}static fromNumber({amount:e,token:r}){let n=$s.fromString({amount:e.toFixed(Math.min(VE,r.decimals)),token:r});if(n instanceof $s)return n;throw n===2?new Error(`Number ${e} has more than ${r.decimals} decimals`):new Error(`Invalid number ${e}`)}toUlps(){return this.ulps}toE8s(){return this.token.decimals<8?this.ulps*10n**BigInt(8-this.token.decimals):this.token.decimals===8?this.ulps:this.ulps/10n**BigInt(this.token.decimals-8)}},YE=class{constructor(t,e,r){this.id=t,this.service=e,this.certifiedService=r,this.caller=({certified:n=!0})=>n?this.certifiedService:this.service}get canisterId(){return this.id}},Ks=t=>t==null,Kr=t=>!Ks(t),oy=t=>Kr(t)&&t!=="",WE=t=>!oy(t),zE=async({request:t,onLoad:e,onQueryError:r,onUpdateError:n,strategy:i="query_and_update",identity:s,resolution:o="race"})=>{let a=!1,c=d=>t({certified:d,identity:s}).then(h=>{a||e({certified:d,response:h})}).catch(h=>{d||r==null||r({error:h,identity:s}),!a&&(Ks(n)||(console.error(h),d&&n({error:h,identity:s})))}).finally(()=>a=a||d),f=i==="query"?[c(!1)]:i==="update"?[c(!0)]:[c(!1),c(!0)];await(o==="all_settled"?Promise.allSettled(f):Promise.race(f))},ey=Qt(),nf=Qt(),ay=()=>nf.HttpAgent.createSync({host:"https://icp-api.io",identity:new nf.AnonymousIdentity}),cy=async({identity:t,host:e,fetchRootKey:r=!1,verifyQuerySignatures:n=!1,retryTimes:i})=>await nf.HttpAgent.create({identity:t,...Kr(e)&&{host:e},verifyQuerySignatures:n,...Kr(i)&&{retryTimes:i},shouldFetchRootKey:r}),DE=class uy{constructor(e){this.config=e,this.agents=void 0,this.getAgent=async({identity:r})=>{let n=r.getPrincipal().toText();if(Ks(this.agents)||Ks(this.agents[n])){let i=await cy({identity:r,fetchRootKey:this.config.fetchRootKey,host:this.config.host,verifyQuerySignatures:!0});return this.agents={...this.agents??{},[n]:i},i}return this.agents[n]},this.clearAgents=()=>{this.agents=null}}static create(e){return new uy(e)}},JE=({options:{canisterId:t,serviceOverride:e,certifiedServiceOverride:r,agent:n,callTransform:i,queryTransform:s},idlFactory:o,certifiedIdlFactory:a})=>{let c=n??ay(),f=e??ey.Actor.createActor(o,{agent:c,canisterId:t,callTransform:i,queryTransform:s}),d=r??ey.Actor.createActor(a,{agent:c,canisterId:t,callTransform:i,queryTransform:s});return{service:f,certifiedService:d,agent:c,canisterId:t}},ly=class extends Error{},fy=class extends Error{},Gs=(t,e)=>{if(t==null)throw new fy(e)},ZE=(t,e)=>(Gs(t,e),t),XE=t=>{if(t<0||t>100)throw new ly(`${t} is not a valid percentage number.`)},QE=t=>{let e=new DataView(t.buffer,t.byteOffset,t.byteLength);if(typeof e.getBigUint64=="function")return e.getBigUint64(0);{let r=BigInt(e.getUint32(0)),n=BigInt(e.getUint32(4));return(r<<BigInt(32))+n}},LE=t=>{let e=new ArrayBuffer(8),r=new DataView(e);if(typeof r.setBigUint64=="function")r.setBigUint64(0,t);else{let n=Number(t>>BigInt(32)),i=Number(t&BigInt(4294967295));r.setUint32(0,n),r.setUint32(4,i)}return new Uint8Array(e)},ex=t=>{let e=new DataView(new ArrayBuffer(8));for(let r=7;r>=0;--r)e.setUint8(r,t%256),t=t>>8;return new Uint8Array(e.buffer)},tx=t=>new Uint8Array(t),rx=t=>Array.from(t),nx=t=>new Uint8Array(t),ix=t=>Array.from(t).map(e=>e.charCodeAt(0)),sx=t=>{let e=t.match(/.{1,2}/g);return Gs(e,"Invalid hex string."),Uint8Array.from(e.map(r=>parseInt(r,16)))},dy=t=>(t instanceof Uint8Array||(t=Uint8Array.from(t)),t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")),ox=t=>{let e=0n;for(let r=t.length-1;r>=0;r--)e=(e<<32n)+BigInt(t[r]);return e},Ja="abcdefghijklmnopqrstuvwxyz234567",Ki=Object.create(null);for(let t=0;t<Ja.length;t++)Ki[Ja[t]]=t;Ki[0]=Ki.o;Ki[1]=Ki.i;var ax=t=>{let e=0,r=0,n="";function i(s){return e<0?r|=s>>-e:r=s<<e&248,e>3?(e-=8,1):(e<4&&(n+=Ja[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?Ja[r>>3]:"")};function cx(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=Ki[o.toLowerCase()];Gs(a,`Invalid character: ${JSON.stringify(o)}`),a<<=3,r|=a>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=a<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}var ux=t=>btoa(String.fromCharCode(...new Uint8Array(t))),lx=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0)),fx=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]),dx=t=>{let e=-1;for(let r=0;r<t.length;r++){let n=(t[r]^e)&255;e=fx[n]^e>>>8}return(e^-1)>>>0},hx=t=>{let e=new ArrayBuffer(4);return new DataView(e).setUint32(0,dx(t),!1),new Uint8Array(e)},hy=It(),sf="__bigint__",of="__principal__",af="__uint8array__",py=(t,e)=>typeof e=="bigint"?{[sf]:`${e}`}:Kr(e)&&e instanceof hy.Principal?{[of]:e.toText()}:Kr(e)&&e instanceof Uint8Array?{[af]:Array.from(e)}:e,px=(t,e)=>{let r=n=>e[n];return Kr(e)&&typeof e=="object"&&sf in e?BigInt(r(sf)):Kr(e)&&typeof e=="object"&&of in e?hy.Principal.fromText(r(of)):Kr(e)&&typeof e=="object"&&af in e?Uint8Array.from(r(af)):e},yx=async t=>{let e=JSON.stringify(t,py);return await yy(e)},yy=async t=>{let e=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",e);return dy(new Uint8Array(r))},_x={year:"year",year_plural:"years",month:"month",month_plural:"months",day:"day",day_plural:"days",hour:"hour",hour_plural:"hours",minute:"minute",minute_plural:"minutes",second:"second",second_plural:"seconds"},gx=({seconds:t,i18n:e=_x})=>{let r=t/BigInt(60),n=r/BigInt(60);r-=n*BigInt(60);let i=n/BigInt(24);n-=i*BigInt(24);let s=mx(i);return i-=_y(s),[Vs("year",s),Vs("day",i),Vs("hour",n),Vs("minute",r),...t>BigInt(0)&&t<BigInt(60)?[Vs("second",t)]:[]].filter(({amount:o})=>o>0).slice(0,2).map(o=>`${o.amount} ${o.amount===1?e[o.labelKey]:e[`${o.labelKey}_plural`]}`).join(", ")},mx=t=>{let e=t/BigInt(365);for(;_y(e)>t;)e--;return e},_y=t=>{let e=t/BigInt(4);return t*BigInt(365)+e},Vs=(t,e)=>({labelKey:t,amount:Number(e)}),gy=1000000n,bx=()=>BigInt(Date.now())*gy,wx=t=>BigInt(t.getTime())*gy,Ex=(t,e)=>{let r;return(...n)=>{let i=()=>t(...n);r&&clearTimeout(r),r=setTimeout(i,e!==void 0&&e>0?e:300)}},xx=t=>Kr(t)?[t]:[],uf=t=>t?.[0],vx=t=>{let e=uf(t);return Gs(e),e},Tx=t=>uf(t??[]),Ax=t=>{let e=t.toUint8Array(),r=new Uint8Array(32);return r[0]=e.length,r.set(e,1),r},ty=(t,e)=>e>t.length?[...t,...[...Array(e-t.length).keys()].map(()=>0)]:t,ry=t=>{if(!Number.isNaN(Number(t)))return Number(t);let e=t.split("").reduce((r,n)=>Number.isNaN(Number(n))?r:r+n,"");return Number(e)},Ox=({minVersion:t,currentVersion:e})=>{let r=ty(t.split(".").map(ry),3).join(".");return ty(e.split(".").map(ry),3).join(".").localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})<0}});var wy=ee(Gr=>{"use strict";var Qa=Gr&&Gr.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Pn=Gr&&Gr.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Za,Xa,Yi,Wi;Object.defineProperty(Gr,"__esModule",{value:!0});Gr.Ed25519KeyIdentity=Gr.Ed25519PublicKey=void 0;var Sx=Qt(),Lt=Qt(),Ys=kl();function by(t){return t!==null&&typeof t=="object"}var ri=class t{constructor(e){if(Za.set(this,void 0),Xa.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Qa(this,Za,e,"f"),Qa(this,Xa,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=(0,Lt.fromHex)(e);return this.fromRaw(r)}else if(by(e)){let r=e;if(by(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,Lt.bufFromBufLike)(n.buffer))}else{if(r instanceof ArrayBuffer)return this.fromRaw(r);if("rawKey"in r)return this.fromRaw(r.rawKey);if("derKey"in r)return this.fromDer(r.derKey);if("toDer"in r)return this.fromDer(r.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){let r=(0,Lt.wrapDER)(e,Lt.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=(0,Lt.unwrapDER)(e,Lt.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Pn(this,Za,"f")}get derKey(){return Pn(this,Xa,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Gr.Ed25519PublicKey=ri;Za=new WeakMap,Xa=new WeakMap;ri.RAW_KEY_LENGTH=32;var ff=class t extends Lt.SignIdentity{constructor(e,r){super(),Yi.set(this,void 0),Wi.set(this,void 0),Qa(this,Yi,ri.from(e),"f"),Qa(this,Wi,new Uint8Array(r),"f")}static generate(e){if(e&&e.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");e||(e=Ys.ed25519.utils.randomPrivateKey()),(0,Sx.bufEquals)(e,new Uint8Array(new Array(32).fill(0)))&&console.warn("Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.");let r=new Uint8Array(32);for(let i=0;i<32;i++)r[i]=new Uint8Array(e)[i];let n=Ys.ed25519.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(ri.fromDer((0,Lt.fromHex)(r)),(0,Lt.fromHex)(n))}static fromJSON(e){let r=JSON.parse(e);if(Array.isArray(r)){if(typeof r[0]=="string"&&typeof r[1]=="string")return this.fromParsedJson([r[0],r[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(e)}`)}static fromKeyPair(e,r){return new t(ri.fromRaw(e),r)}static fromSecretKey(e){let r=Ys.ed25519.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[(0,Lt.toHex)(Pn(this,Yi,"f").toDer()),(0,Lt.toHex)(Pn(this,Wi,"f"))]}getKeyPair(){return{secretKey:Pn(this,Wi,"f"),publicKey:Pn(this,Yi,"f")}}getPublicKey(){return Pn(this,Yi,"f")}async sign(e){let r=new Uint8Array(e),n=(0,Lt.uint8ToBuf)(Ys.ed25519.sign(r,Pn(this,Wi,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(e,r,n){let[i,s,o]=[e,r,n].map(a=>(typeof a=="string"&&(a=(0,Lt.fromHex)(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return Ys.ed25519.verify(s,i,o)}};Gr.Ed25519KeyIdentity=ff;Yi=new WeakMap,Wi=new WeakMap});var xy=ee(ni=>{"use strict";Object.defineProperty(ni,"__esModule",{value:!0});ni.ECDSAKeyIdentity=ni.CryptoError=void 0;var Nx=Qt(),La=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};ni.CryptoError=La;function Ey(t){if(typeof global<"u"&&global.crypto&&global.crypto.subtle)return global.crypto.subtle;if(t)return t;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new La("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var ec=class t extends Nx.SignIdentity{constructor(e,r,n){super(),this._keyPair=e,this._derKey=r,this._subtleCrypto=n}static async generate(e){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=e??{},s=Ey(i),o=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await s.exportKey("spki",o.publicKey);return new this(o,a,s)}static async fromKeyPair(e,r){let n=Ey(r),i=await n.exportKey("spki",e.publicKey);return new t(e,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let e=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return e},r}async sign(e){let r={name:"ECDSA",hash:{name:"SHA-256"}};return await this._subtleCrypto.sign(r,this._keyPair.privateKey,e)}};ni.ECDSAKeyIdentity=ec;ni.default=ec});var hf=ee(In=>{"use strict";var Rx=In&&In.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ws=In&&In.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Un;Object.defineProperty(In,"__esModule",{value:!0});In.PartialIdentity=void 0;var Bx=It(),df=class{constructor(e){Un.set(this,void 0),Rx(this,Un,e,"f")}get rawKey(){return Ws(this,Un,"f").rawKey}get derKey(){return Ws(this,Un,"f").derKey}toDer(){return Ws(this,Un,"f").toDer()}getPublicKey(){return Ws(this,Un,"f")}getPrincipal(){return Bx.Principal.from(Ws(this,Un,"f").rawKey)}transformRequest(){return Promise.reject("Not implemented. You are attempting to use a partial identity to sign calls, but this identity only has access to the public key.To sign calls, use a DelegationIdentity instead.")}};In.PartialIdentity=df;Un=new WeakMap});var vy=ee(De=>{"use strict";var Px=De&&De.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Ux=De&&De.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ix=De&&De.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Px(e,t,r);return Ux(e,t),e},Cx=De&&De.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Fx=De&&De.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Mx=De&&De.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},tc;Object.defineProperty(De,"__esModule",{value:!0});De.isDelegationValid=De.PartialDelegationIdentity=De.DelegationIdentity=De.DelegationChain=De.Delegation=void 0;var Cn=Qt(),yf=It(),zs=Ix(ps()),qx=hf(),jx=new TextEncoder().encode("ic-request-auth-delegation"),kx=new TextEncoder().encode(`
|
|
57
|
-
ic-request`);function pf(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return(0,Cn.fromHex)(t)}var Ds=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return zs.value.map(Object.assign({pubkey:zs.value.bytes(this.pubkey),expiration:zs.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:zs.value.array(this.targets.map(e=>zs.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,Cn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};De.Delegation=Ds;async function Vx(t,e,r,n){let i=new Ds(e.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...jx,...new Uint8Array((0,Cn.requestIdOf)(Object.assign({},i)))]),o=await t.sign(s);return{delegation:i,signature:o}}var _f=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+15*60*1e3),i={}){var s,o;let a=await Vx(e,r,n,i.targets);return new t([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],a],((o=i.previous)===null||o===void 0?void 0:o.publicKey)||e.getPublicKey().toDer())}static fromJSON(e){let{publicKey:r,delegations:n}=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:o,signature:a}=s,{pubkey:c,expiration:f,targets:d}=o;if(d!==void 0&&!Array.isArray(d))throw new Error("Invalid targets.");return{delegation:new Ds(pf(c),BigInt("0x"+f),d&&d.map(h=>{if(typeof h!="string")throw new Error("Invalid target.");return yf.Principal.fromHex(h)})),signature:pf(a)}});return new this(i,pf(r))}static fromDelegations(e,r){return new this(e,r)}toJSON(){return{delegations:this.delegations.map(e=>{let{delegation:r,signature:n}=e,{targets:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:(0,Cn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,Cn.toHex)(n)}}),publicKey:(0,Cn.toHex)(this.publicKey)}}};De.DelegationChain=_f;var gf=class extends Cn.SignIdentity{constructor(e,r){super(),this._inner=e,this._delegation=r}static fromDelegation(e,r){return new this(e,r)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(e){return this._inner.sign(e)}async transformRequest(e){let{body:r}=e,n=Mx(e,["body"]),i=await(0,Cn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...kx,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};De.DelegationIdentity=gf;var mf=class t extends qx.PartialIdentity{constructor(e,r){super(e),tc.set(this,void 0),Cx(this,tc,r,"f")}get delegation(){return Fx(this,tc,"f")}static fromDelegation(e,r){return new t(e,r)}};De.PartialDelegationIdentity=mf;tc=new WeakMap;function Hx(t,e){for(let{delegation:i}of t.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?yf.Principal.fromText(i):i)):r.push(typeof n=="string"?yf.Principal.fromText(n):n));for(let i of r){let s=i.toText();for(let{delegation:o}of t.delegations){if(o.targets===void 0)continue;let a=!0;for(let c of o.targets)if(c.toText()===s){a=!1;break}if(a)return!1}}return!0}De.isDelegationValid=Hx});var Ty=ee(Fn=>{"use strict";var $x=Fn&&Fn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Fn,"__esModule",{value:!0});Fn.WebAuthnIdentity=Fn.CosePublicKey=void 0;var ii=Qt(),bf=$x($o()),Kx=kn(),Gx=xi();function Yx(t){return(0,ii.wrapDER)(t,ii.DER_COSE_OID).buffer}function Wx(t){let e=new DataView(new ArrayBuffer(2)),r=t.slice(53,55);[...new Uint8Array(r)].forEach((i,s)=>e.setUint8(s,i));let n=e.getUint16(0);return t.slice(55+n)}var rc=class{constructor(e){this._cose=e,this._encodedKey=Yx(e)}toDer(){return this._encodedKey}getCose(){return this._cose}};Fn.CosePublicKey=rc;function zx(t="<ic0.app>"){return typeof t=="string"?Uint8Array.from(t,e=>e.charCodeAt(0)):t}async function Dx(t){let e=await navigator.credentials.create(t??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:zx(),pubKeyCredParams:[{type:"public-key",alg:wf.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,Kx.randomBytes)(16),name:"Internet Identity",displayName:"Internet Identity"}}});return e===null?null:{id:e.id,response:e.response,type:e.type,authenticatorAttachment:e.authenticatorAttachment,getClientExtensionResults:e.getClientExtensionResults,rawId:(0,Gx.bufFromBufLike)(e.rawId)}}var wf;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(wf||(wf={}));var Ef=class extends ii.SignIdentity{constructor(e,r,n){super(),this.rawId=e,this.authenticatorAttachment=n,this._publicKey=new rc(r)}static fromJSON(e){let{publicKey:r,rawId:n}=JSON.parse(e);if(typeof r!="string"||typeof n!="string")throw new Error("Invalid JSON string.");return new this((0,ii.fromHex)(n),(0,ii.fromHex)(r),void 0)}static async create(e){var r;let n=await Dx(e);if(!n||n.type!=="public-key")throw new Error("Could not create credentials.");let i=n.response;if(i.attestationObject===void 0)throw new Error("Was expecting an attestation response.");let s=bf.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,Wx(s.authData),(r=n.authenticatorAttachment)!==null&&r!==void 0?r:void 0)}getPublicKey(){return this._publicKey}getAuthenticatorAttachment(){return this.authenticatorAttachment}async sign(e){let r=await navigator.credentials.get({publicKey:{allowCredentials:[{type:"public-key",id:this.rawId}],challenge:e,userVerification:"preferred"}});r.authenticatorAttachment!==null&&(this.authenticatorAttachment=r.authenticatorAttachment);let n=r.response,i=bf.default.encode(new bf.default.Tagged(55799,{authenticator_data:new Uint8Array(n.authenticatorData),client_data_json:new TextDecoder().decode(n.clientDataJSON),signature:new Uint8Array(n.signature)}));if(!i)throw new Error("failed to encode cbor");return i.buffer}toJSON(){return{publicKey:(0,ii.toHex)(this._publicKey.getCose()),rawId:(0,ii.toHex)(this.rawId)}}};Fn.WebAuthnIdentity=Ef});var Oy=ee(We=>{"use strict";var Jx=We&&We.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),vf=We&&We.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Jx(e,t,r)};Object.defineProperty(We,"__esModule",{value:!0});We.Secp256k1KeyIdentity=We.ED25519_OID=We.DER_COSE_OID=We.unwrapDER=We.wrapDER=We.WebAuthnIdentity=We.Ed25519PublicKey=We.Ed25519KeyIdentity=void 0;var Ay=wy();Object.defineProperty(We,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return Ay.Ed25519KeyIdentity}});Object.defineProperty(We,"Ed25519PublicKey",{enumerable:!0,get:function(){return Ay.Ed25519PublicKey}});vf(xy(),We);vf(vy(),We);vf(hf(),We);var Zx=Ty();Object.defineProperty(We,"WebAuthnIdentity",{enumerable:!0,get:function(){return Zx.WebAuthnIdentity}});var nc=Qt();Object.defineProperty(We,"wrapDER",{enumerable:!0,get:function(){return nc.wrapDER}});Object.defineProperty(We,"unwrapDER",{enumerable:!0,get:function(){return nc.unwrapDER}});Object.defineProperty(We,"DER_COSE_OID",{enumerable:!0,get:function(){return nc.DER_COSE_OID}});Object.defineProperty(We,"ED25519_OID",{enumerable:!0,get:function(){return nc.ED25519_OID}});var xf=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};We.Secp256k1KeyIdentity=xf});var Af=ee(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.IdleManager=void 0;var Sy=["mousedown","mousemove","keydown","touchstart","wheel"],Tf=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let s=this._resetTimer.bind(this);window.addEventListener("load",s,!0),Sy.forEach(function(a){document.addEventListener(a,s,!0)});let o=(a,c)=>{let f;return(...d)=>{let h=this,g=function(){f=void 0,a.apply(h,d)};clearTimeout(f),f=window.setTimeout(g,c)}};if(e?.captureScroll){let a=o(s,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}s()}static create(e={}){return new this(e)}registerCallback(e){this.callbacks.push(e)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let e=this._resetTimer.bind(this);Sy.forEach(function(r){document.removeEventListener(r,e,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let e=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(e,this.idleTimeout)}};ic.IdleManager=Tf});function Qx(){return Ny||(Ny=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Lx(){return Ry||(Ry=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function e8(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{r(ur(t.result)),i()},o=()=>{n(t.error),i()};t.addEventListener("success",s),t.addEventListener("error",o)});return e.then(r=>{r instanceof IDBCursor&&By.set(r,t)}).catch(()=>{}),Rf.set(e,t),e}function t8(t){if(Sf.has(t))return;let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",o),t.removeEventListener("abort",o)},s=()=>{r(),i()},o=()=>{n(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",s),t.addEventListener("error",o),t.addEventListener("abort",o)});Sf.set(t,e)}function Uy(t){Nf=t(Nf)}function r8(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Js(this),e,...r);return Py.set(n,e.sort?e.sort():[e]),ur(n)}:Lx().includes(t)?function(...e){return t.apply(Js(this),e),ur(By.get(this))}:function(...e){return ur(t.apply(Js(this),e))}}function n8(t){return typeof t=="function"?r8(t):(t instanceof IDBTransaction&&t8(t),Xx(t,Qx())?new Proxy(t,Nf):t)}function ur(t){if(t instanceof IDBRequest)return e8(t);if(Of.has(t))return Of.get(t);let e=n8(t);return e!==t&&(Of.set(t,e),Rf.set(e,t)),e}var Xx,Ny,Ry,By,Sf,Py,Of,Rf,Nf,Js,Bf=Zf(()=>{Xx=(t,e)=>e.some(r=>t instanceof r);By=new WeakMap,Sf=new WeakMap,Py=new WeakMap,Of=new WeakMap,Rf=new WeakMap;Nf={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return Sf.get(t);if(e==="objectStoreNames")return t.objectStoreNames||Py.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return ur(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};Js=t=>Rf.get(t)});var Cy={};ng(Cy,{deleteDB:()=>s8,openDB:()=>i8,unwrap:()=>Js,wrap:()=>ur});function i8(t,e,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(t,e),a=ur(o);return n&&o.addEventListener("upgradeneeded",c=>{n(ur(o.result),c.oldVersion,c.newVersion,ur(o.transaction),c)}),r&&o.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",f=>i(f.oldVersion,f.newVersion,f))}).catch(()=>{}),a}function s8(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),ur(r).then(()=>{})}function Iy(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Pf.get(e))return Pf.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=a8.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||o8.includes(r)))return;let s=async function(o,...a){let c=this.transaction(o,i?"readwrite":"readonly"),f=c.store;return n&&(f=f.index(a.shift())),(await Promise.all([f[r](...a),i&&c.done]))[0]};return Pf.set(e,s),s}var o8,a8,Pf,Fy=Zf(()=>{Bf();Bf();o8=["get","getKey","getAll","getAllKeys","count"],a8=["put","add","delete","clear"],Pf=new Map;Uy(t=>({...t,get:(e,r,n)=>Iy(e,r)||t.get(e,r,n),has:(e,r)=>!!Iy(e,r)||t.has(e,r)}))});var If=ee(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.IdbKeyVal=void 0;var c8=(Fy(),ig(Cy)),Zs=oc(),My="auth-client-db",qy="ic-keyval",u8=async(t=My,e=qy,r)=>(Zs.isBrowser&&(localStorage!=null&&localStorage.getItem(Zs.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(Zs.KEY_STORAGE_DELEGATION),localStorage.removeItem(Zs.KEY_STORAGE_KEY)),await(0,c8.openDB)(t,r,{upgrade:n=>{n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function l8(t,e,r){return await t.get(e,r)}async function f8(t,e,r,n){return await t.put(e,n,r)}async function d8(t,e,r){return await t.delete(e,r)}var Uf=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=My,storeName:n=qy,version:i=Zs.DB_VERSION}=e??{},s=await u8(r,n,i);return new t(s,n)}async set(e,r){return await f8(this._db,this._storeName,e,r)}async get(e){var r;return(r=await l8(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await d8(this._db,this._storeName,e)}};sc.IdbKeyVal=Uf});var oc=ee(nt=>{"use strict";var h8=nt&&nt.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},p8=nt&&nt.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ac;Object.defineProperty(nt,"__esModule",{value:!0});nt.IdbStorage=nt.LocalStorage=nt.isBrowser=nt.DB_VERSION=nt.KEY_VECTOR=nt.KEY_STORAGE_DELEGATION=nt.KEY_STORAGE_KEY=void 0;var y8=If();nt.KEY_STORAGE_KEY="identity";nt.KEY_STORAGE_DELEGATION="delegation";nt.KEY_VECTOR="iv";nt.DB_VERSION=1;nt.isBrowser=typeof window<"u";var Cf=class{constructor(e="ic-",r){this.prefix=e,this._localStorage=r}get(e){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+e))}set(e,r){return this._getLocalStorage().setItem(this.prefix+e,r),Promise.resolve()}remove(e){return this._getLocalStorage().removeItem(this.prefix+e),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let e=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!e)throw new Error("Could not find local storage.");return e}};nt.LocalStorage=Cf;var Ff=class{constructor(e){ac.set(this,void 0),h8(this,ac,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}y8.IdbKeyVal.create(p8(this,ac,"f")).then(r=>{this.initializedDb=r,e(r)})})}async get(e){return await(await this._db).get(e)}async set(e,r){await(await this._db).set(e,r)}async remove(e){await(await this._db).remove(e)}};nt.IdbStorage=Ff;ac=new WeakMap});var Vf=ee(Le=>{"use strict";var _8=Le&&Le.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),g8=Le&&Le.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&_8(e,t,r)};Object.defineProperty(Le,"__esModule",{value:!0});Le.AuthClient=Le.ERROR_USER_INTERRUPT=Le.IdbKeyVal=Le.KEY_STORAGE_KEY=Le.KEY_STORAGE_DELEGATION=Le.LocalStorage=Le.IdbStorage=void 0;var jy=Qt(),er=Oy(),ky=Af(),vt=oc(),cc=oc();Object.defineProperty(Le,"IdbStorage",{enumerable:!0,get:function(){return cc.IdbStorage}});Object.defineProperty(Le,"LocalStorage",{enumerable:!0,get:function(){return cc.LocalStorage}});Object.defineProperty(Le,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return cc.KEY_STORAGE_DELEGATION}});Object.defineProperty(Le,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return cc.KEY_STORAGE_KEY}});var m8=If();Object.defineProperty(Le,"IdbKeyVal",{enumerable:!0,get:function(){return m8.IdbKeyVal}});var b8="https://identity.ic0.app",w8="#authorize",Mf="ECDSA",qf="Ed25519",E8=500;Le.ERROR_USER_INTERRUPT="UserInterrupt";g8(Af(),Le);var kf=class{constructor(e,r,n,i,s,o,a,c){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=o,this._idpWindow=a,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let s=(r=e.storage)!==null&&r!==void 0?r:new vt.IdbStorage,o=(n=e.keyType)!==null&&n!==void 0?n:Mf,a=null;if(e.identity)a=e.identity;else{let h=await s.get(vt.KEY_STORAGE_KEY);if(!h&&vt.isBrowser)try{let g=new vt.LocalStorage,b=await g.get(vt.KEY_STORAGE_DELEGATION),l=await g.get(vt.KEY_STORAGE_KEY);b&&l&&o===Mf&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(vt.KEY_STORAGE_DELEGATION,b),await s.set(vt.KEY_STORAGE_KEY,l),h=b,await g.remove(vt.KEY_STORAGE_DELEGATION),await g.remove(vt.KEY_STORAGE_KEY))}catch(g){console.error("error while attempting to recover localstorage: "+g)}if(h)try{typeof h=="object"?o===qf&&typeof h=="string"?a=await er.Ed25519KeyIdentity.fromJSON(h):a=await er.ECDSAKeyIdentity.fromKeyPair(h):typeof h=="string"&&(a=er.Ed25519KeyIdentity.fromJSON(h))}catch{}}let c=new jy.AnonymousIdentity,f=null;if(a)try{let h=await s.get(vt.KEY_STORAGE_DELEGATION);if(typeof h=="object"&&h!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?c=e.identity:h&&(f=er.DelegationChain.fromJSON(h),(0,er.isDelegationValid)(f)?"toDer"in a?c=er.PartialDelegationIdentity.fromDelegation(a,f):c=er.DelegationIdentity.fromDelegation(a,f):(await jf(s),a=null))}catch(h){console.error(h),await jf(s),a=null}let d;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?d=void 0:(f||e.identity)&&(d=ky.IdleManager.create(e.idleOptions)),a||(o===qf?(a=await er.Ed25519KeyIdentity.generate(),await s.set(vt.KEY_STORAGE_KEY,JSON.stringify(a.toJSON()))):(e.storage&&o===Mf&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${qf}' as the key type, as it can serialize to a string`),a=await er.ECDSAKeyIdentity.generate(),await s.set(vt.KEY_STORAGE_KEY,a.getKeyPair()))),new this(c,a,f,s,d,e)}_registerDefaultIdleCallback(){var e,r;let n=(e=this._createOptions)===null||e===void 0?void 0:e.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(e,r){var n,i;let s=e.delegations.map(f=>({delegation:new er.Delegation(f.delegation.pubkey,f.delegation.expiration,f.delegation.targets),signature:f.signature.buffer})),o=er.DelegationChain.fromDelegations(s,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=o,"toDer"in a?this._identity=er.PartialDelegationIdentity.fromDelegation(a,this._chain):this._identity=er.DelegationIdentity.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=ky.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(vt.KEY_STORAGE_DELEGATION,JSON.stringify(this._chain.toJSON())),r?.(e)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(e){var r,n,i,s;let o=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||b8);a.hash=w8,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=e?.maxTimeToLive)!==null&&i!==void 0?i:o},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Le.ERROR_USER_INTERRUPT,e?.onError):setTimeout(c,E8))};c()}_getEventHandler(e,r){return async n=>{var i,s,o;if(n.origin!==e.origin)return;let a=n.data;switch(a.kind){case"authorize-ready":{let c=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(s=r?.derivationOrigin)===null||s===void 0?void 0:s.toString()},r?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(c,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.text,r?.onError);break;default:break}}}_handleFailure(e,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(e),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(e={}){if(await jf(this._storage),this._identity=new jy.AnonymousIdentity,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};Le.AuthClient=kf;async function jf(t){await t.remove(vt.KEY_STORAGE_KEY),await t.remove(vt.KEY_STORAGE_DELEGATION),await t.remove(vt.KEY_VECTOR)}});var q_=Je(gt(),1);var E_=Je(gt(),1);var Gi=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:r})=>r(e))}subscribe(e){let r=Symbol();return this.callbacks.push({id:r,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var on=class t extends Gi{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let r=super.subscribe(e);return e(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var lf=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var b_=Je(Vf(),1),w_=Je(gt(),1);var Vy=BigInt(144e11),Hy=!1,$y={width:576,height:576},Ky={width:505,height:705},Gy="internetcomputer.org";var Xs=Je(gt(),1);var zi="http://127.0.0.1:5987",Yy="rdmx6-jaaaa-aaaaa-aaadq-cai";var Yr=class t extends Gi{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var Hf=Je(gt(),1);var uc=Je(gt(),1),Wy=async t=>{let e=new Blob([JSON.stringify(t,uc.jsonReplacer)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},lc=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),uc.jsonReviver)},fc=()=>typeof window<"u";var $f=({width:t,height:e})=>{if(!fc()||(0,Hf.isNullish)(window)||(0,Hf.isNullish)(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-e/2,s=r/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${s}`};var dc=class{#e;constructor({domain:e}){this.#e=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=Yr.getInstance().get()?.container;if((0,Xs.isNullish)(n)||n===!1)return`https://identity.${this.#e??Gy}`;let i=Yr.getInstance().get(),s=(0,Xs.nonNullish)(i)&&(0,Xs.nonNullish)(i?.internetIdentityId)?i.internetIdentityId:Yy,{host:o,protocol:a}=new URL(n===!0?zi:n);return/apple/i.test(navigator?.vendor)?`${a}//${o}?canisterId=${s}`:`${a}//${s}.${o.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:$f($y)},identityProvider:r()}}},zy=class{#e;#t;constructor({appName:e,logoUrl:r}){this.#e=e,this.#t=r}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:$f(Ky)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var Jy=Je(Qt(),1),hc=Je(gt(),1);var Dy=Je(Qt(),1),si=Je(gt(),1);var Di=class t{static instance;#e=void 0;constructor(){}static getInstance(){return(0,si.isNullish)(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...r}){let n=e.getPrincipal().toText();if((0,si.isNullish)(this.#e)||(0,si.isNullish)(this.#e[n])){let i=await this.createAgent({identity:e,...r});return this.#e={...this.#e??{},[n]:i},i}return this.#e[n]}reset(){this.#e=null}async createAgent({identity:e,container:r}){let i=(0,si.nonNullish)(r)&&r!==!1?r===!0?zi:r:"https://icp-api.io",s=(0,si.nonNullish)(r);return await Dy.HttpAgent.create({identity:e,shouldFetchRootKey:s,host:i})}};var Ji=class t{static instance;#e=void 0;constructor(){}static getInstance(){return(0,hc.isNullish)(t.instance)&&(t.instance=new t),t.instance}async getActor({satelliteId:e,identity:r,buildType:n,...i}){let s=`${n}#${r.getPrincipal().toText()}#${e};`;if((0,hc.isNullish)(this.#e)||(0,hc.isNullish)(this.#e[s])){let o=await this.createActor({satelliteId:e,identity:r,...i});return this.#e={...this.#e??{},[s]:o},o}return this.#e[s]}reset(){this.#e=null}async createActor({idlFactory:e,satelliteId:r,...n}){let i=await Di.getInstance().getAgent(n);return Jy.Actor.createActor(e,{agent:i,canisterId:r})}};var pc=class extends Error{},yc=class extends Error{},_c=class extends Error{},gc=class extends Error{},mc=class extends Error{};var Zy=Je(Vf(),1),bc=()=>Zy.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Ls=Je(gt(),1);var Kf=({error:t,type:e})=>typeof t=="string"?t.includes(e):t instanceof Error?t.message.includes(e):!1;var Xy="juno.datastore.error.user.cannot_update";var xr=Je(gt(),1);var Qy=async({data:t})=>{try{return await lc(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var oi=Je(gt(),1);var Gf=async t=>{let{data:e,version:r,description:n}=t;return{description:(0,oi.toNullable)(n),data:await Wy(e),version:(0,oi.toNullable)(r)}},Yf=t=>{let{version:e}=t;return{version:(0,oi.toNullable)(e)}},Qs=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:s,...o}=t;return{key:e,description:(0,oi.fromNullable)(i),owner:r.toText(),data:await lc(s),version:(0,oi.fromNullable)(n),...o}};var e_=Je(It(),1),it=Je(gt(),1);var Ly=t=>{if((0,it.isNullish)(t))return(0,it.toNullable)();switch(t.matcher){case"equal":return(0,it.toNullable)({Equal:t.timestamp});case"greaterThan":return(0,it.toNullable)({GreaterThan:t.timestamp});case"lessThan":return(0,it.toNullable)({LessThan:t.timestamp});case"between":return(0,it.toNullable)({Between:[t.timestamps.start,t.timestamps.end]});default:throw new mc("Invalid list matcher for timestamp",t)}},Mn=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:(0,it.isNullish)(t)?[]:[{key:(0,it.toNullable)(t.key),description:(0,it.toNullable)(t.description),created_at:Ly(t.createdAt),updated_at:Ly(t.updatedAt)}],paginate:(0,it.toNullable)((0,it.isNullish)(e)?void 0:{start_after:(0,it.toNullable)(e.startAfter),limit:(0,it.toNullable)((0,it.isNullish)(e.limit)?void 0:BigInt(e.limit))}),order:(0,it.toNullable)((0,it.isNullish)(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:(0,it.toNullable)((0,it.isNullish)(n)?void 0:typeof n=="string"?e_.Principal.fromText(n):n)});var n_=Je(gt(),1);var t_=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({sha256:t.Vec(t.Nat8),proposal_id:t.Nat}),n=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),i=t.Record({field:n,desc:t.Bool}),s=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),o=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(s),description:t.Opt(t.Text),created_at:t.Opt(s)}),a=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),c=t.Record({order:t.Opt(i),owner:t.Opt(t.Principal),matcher:t.Opt(o),paginate:t.Opt(a)}),f=t.Record({controllers:t.Vec(t.Principal)}),d=t.Variant({Write:t.Null,Admin:t.Null,Submit:t.Null}),h=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:d,expires_at:t.Opt(t.Nat64)}),g=t.Record({version:t.Opt(t.Nat64)}),b=t.Variant({Db:t.Null,Storage:t.Null}),l=t.Record({version:t.Opt(t.Nat64)}),N=t.Record({proposal_ids:t.Vec(t.Nat)}),O=t.Record({cycles:t.Nat,destination_id:t.Principal}),I=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),M=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),A=t.Record({key:I,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,M)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),K=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),E=t.Record({internet_identity:t.Opt(K)}),k=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),G=t.Record({max_memory_size:t.Opt(k)}),z=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),q=t.Variant({Deny:t.Null,Allow:t.Null}),oe=t.Record({status_code:t.Nat16,location:t.Text}),Q=t.Record({iframe:t.Opt(z),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(k),raw_access:t.Opt(q),redirects:t.Opt(t.Vec(t.Tuple(t.Text,oe)))}),ie=t.Record({db:t.Opt(G),authentication:t.Opt(E),storage:Q}),w=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),m=t.Variant({Initialized:t.Null,Failed:t.Null,Open:t.Null,Rejected:t.Null,Executed:t.Null,Accepted:t.Null}),R=t.Record({clear_existing_assets:t.Opt(t.Bool)}),S=t.Record({orbiter:t.Opt(t.Text),mission_control_version:t.Opt(t.Text),satellite_version:t.Opt(t.Text)}),B=t.Variant({AssetsUpgrade:R,SegmentsDeployment:S}),V=t.Record({status:m,updated_at:t.Nat64,sha256:t.Opt(t.Vec(t.Nat8)),executed_at:t.Opt(t.Nat64),owner:t.Principal,created_at:t.Nat64,version:t.Opt(t.Nat64),proposal_type:B}),J=t.Variant({Heap:t.Null,Stable:t.Null}),ae=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),ce=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),D=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(J),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:ae,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(ce),write:ae,max_changes_per_user:t.Opt(t.Nat32)}),F=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),p=t.Record({memory:J,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),L=t.Variant({Callback:t.Record({token:p,callback:t.Func([],[],["query"])})}),re=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(L),status_code:t.Nat16}),le=t.Record({token:t.Opt(p),body:t.Vec(t.Nat8)}),X=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),u=t.Record({batch_id:t.Nat}),y=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,A)),items_length:t.Nat64}),_=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),U=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,w)),items_length:t.Nat64}),T=t.Record({desc:t.Bool}),P=t.Record({start_after:t.Opt(t.Nat),limit:t.Opt(t.Nat)}),H=t.Record({order:t.Opt(T),paginate:t.Opt(P)}),x=t.Record({proposal_id:t.Nat}),C=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(x,V)),items_length:t.Nat64}),$=t.Record({include_system:t.Bool}),j=t.Record({matcher:t.Opt($)}),Z=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(t.Text,D)),items_length:t.Nat64}),te=t.Record({stable:t.Nat64,heap:t.Nat64}),fe=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:d,expires_at:t.Opt(t.Nat64)}),me=t.Record({controller:fe,controllers:t.Vec(t.Principal)}),Re=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),Me=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(J),max_size:t.Opt(t.Nat),read:ae,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(ce),write:ae,max_changes_per_user:t.Opt(t.Nat32)}),ye=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),he=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),commit_proposal:t.Func([r],[t.Null],[]),commit_proposal_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,c],[t.Nat64],["query"]),count_collection_assets:t.Func([t.Text],[t.Nat64],["query"]),count_collection_docs:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text,c],[t.Nat64],["query"]),count_proposals:t.Func([],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([f],[t.Vec(t.Tuple(t.Principal,h))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,g],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,c],[],[]),del_filtered_docs:t.Func([t.Text,c],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,g))],[],[]),del_rule:t.Func([b,t.Text,l],[],[]),delete_proposal_assets:t.Func([N],[],[]),deposit_cycles:t.Func([O],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(A)],["query"]),get_auth_config:t.Func([],[t.Opt(E)],["query"]),get_config:t.Func([],[ie],[]),get_db_config:t.Func([],[t.Opt(G)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(w)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(A)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(w)))],["query"]),get_proposal:t.Func([t.Nat],[t.Opt(V)],["query"]),get_rule:t.Func([b,t.Text],[t.Opt(D)],["query"]),get_storage_config:t.Func([],[Q],["query"]),http_request:t.Func([F],[re],["query"]),http_request_streaming_callback:t.Func([p],[le],["query"]),init_asset_upload:t.Func([X],[u],[]),init_proposal:t.Func([B],[t.Nat,V],[]),init_proposal_asset_upload:t.Func([X,t.Nat],[u],[]),list_assets:t.Func([t.Text,c],[y],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,h))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,_))],["query"]),list_docs:t.Func([t.Text,c],[U],["query"]),list_proposals:t.Func([H],[C],["query"]),list_rules:t.Func([b,j],[Z],["query"]),memory_size:t.Func([],[te],["query"]),reject_proposal:t.Func([r],[t.Null],[]),set_auth_config:t.Func([E],[],[]),set_controllers:t.Func([me],[t.Vec(t.Tuple(t.Principal,h))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([G],[],[]),set_doc:t.Func([t.Text,t.Text,Re],[w],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,Re))],[t.Vec(t.Tuple(t.Text,w))],[]),set_rule:t.Func([b,t.Text,Me],[D],[]),set_storage_config:t.Func([Q],[],[]),submit_proposal:t.Func([t.Nat],[t.Nat,V],[]),upload_asset_chunk:t.Func([ye],[he],[]),upload_proposal_asset_chunk:t.Func([ye],[he],[])})};var wc=Je(gt(),1);var r_=({satelliteId:t,container:e})=>{let{satelliteId:r}=Wf({satelliteId:t}),{container:n}=zf({container:e});if((0,wc.nonNullish)(n)&&n!==!1){let{host:i,protocol:s}=new URL(n===!0?zi:n);return`${s}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},Wf=({satelliteId:t})=>(0,wc.nonNullish)(t)?{satelliteId:t}:Yr.getInstance().get()??{satelliteId:void 0},zf=({container:t})=>(0,wc.nonNullish)(t)?{container:t}:Yr.getInstance().get()??{container:void 0};var lt=t=>s_({idlFactory:t_,buildType:"stock",...t}),i_=({idlFactory:t,...e})=>s_({idlFactory:t,buildType:"extended",...e}),s_=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=Wf({satelliteId:t});(0,n_.assertNonNullish)(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=zf({container:e});return await Ji.getInstance().getActor({satelliteId:n,container:i,...r})};var o_=async({collection:t,key:e,satellite:r})=>{let{get_doc:n}=await lt(r),i=(0,xr.fromNullable)(await n(t,e));if(!(0,xr.isNullish)(i))return Qs({doc:i,key:e})},a_=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await lt(e),n=t.map(({collection:o,key:a})=>[o,a]),i=await r(n),s=[];for(let[o,a]of i){let c=(0,xr.fromNullable)(a);s.push((0,xr.nonNullish)(c)?await Qs({key:o,doc:c}):void 0)}return s},c_=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await lt(r),{key:i}=e,s=await Gf(e),o=await n(t,i,s);return await Qs({key:i,doc:o})},u_=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await lt(e),n=[];for(let{collection:o,doc:a}of t){let{key:c}=a;n.push([o,c,await Gf(a)])}let i=await r(n),s=[];for(let[o,a]of i)s.push(await Qs({key:o,doc:a}));return s},l_=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await lt(r),{key:i}=e;return n(t,i,Yf(e))},f_=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await lt(e),n=t.map(({collection:i,doc:s})=>[i,s.key,Yf(s)]);await r(n)},d_=async({collection:t,filter:e,satellite:r})=>{let{del_filtered_docs:n}=await lt(r);return n(t,Mn(e))},h_=async({collection:t,filter:e,satellite:r})=>{let{list_docs:n}=await lt(r),{items:i,items_page:s,items_length:o,matches_length:a,matches_pages:c}=await n(t,Mn(e)),f=[];for(let[d,h]of i){let{data:g,owner:b,description:l,version:N,...O}=h;f.push({key:d,description:(0,xr.fromNullable)(l),owner:b.toText(),data:await Qy({data:g}),version:(0,xr.fromNullable)(N),...O})}return{items:f,items_length:o,items_page:(0,xr.fromNullable)(s),matches_length:a,matches_pages:(0,xr.fromNullable)(c)}},p_=async({collection:t,filter:e,satellite:r})=>{let{count_docs:n}=await lt(r);return n(t,Mn(e))};var y_=Je(Qt(),1);var et=t=>t!==void 0?t:Ec()??new y_.AnonymousIdentity;var __=async({satellite:t,...e})=>{let r=et(t?.identity);return await o_({...e,satellite:{...t,identity:r}})},A3=async({satellite:t,...e})=>{let r=et(t?.identity);return await a_({...e,satellite:{...t,identity:r}})},g_=async({satellite:t,...e})=>{let r=et(t?.identity);return await c_({...e,satellite:{...t,identity:r}})},O3=async({satellite:t,...e})=>{let r=et(t?.identity);return await u_({...e,satellite:{...t,identity:r}})},S3=async({satellite:t,...e})=>{let r=et(t?.identity);return await l_({...e,satellite:{...t,identity:r}})},N3=async({satellite:t,...e})=>{let r=et(t?.identity);return await f_({...e,satellite:{...t,identity:r}})},R3=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await d_({...r,filter:e??{},satellite:{...t,identity:n}})},B3=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await h_({...r,filter:e??{},satellite:{...t,identity:n}})},P3=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await p_({...r,filter:e??{},satellite:{...t,identity:n}})};var m_=async t=>{let e=Ec();if((0,Ls.isNullish)(e))throw new gc("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=()=>__({collection:"#user",key:r}),i=await n();if((0,Ls.nonNullish)(i))return i;try{return await x8({userId:r,provider:t})}catch(s){if(Kf({error:s,type:Xy})){let o=await n();if((0,Ls.nonNullish)(o))return o}throw s}},x8=({userId:t,...e})=>g_({collection:"#user",doc:{key:t,data:e}});var Wr,Df=async t=>{if(Wr=Wr??await bc(),!(await Wr?.isAuthenticated()??!1))return;let r=await m_(t);on.getInstance().set(r)},v8=t=>new Promise(async(e,r)=>{if((0,w_.isNullish)(Wr)){r(new yc("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let n=t?.provider??new dc({});await Wr.login({onSuccess:async()=>{await Df(n.id),e()},onError:i=>{if(i===b_.ERROR_USER_INTERRUPT){r(new _c(i));return}r(new pc(i))},maxTimeToLive:t?.maxTimeToLive??Vy,allowPinAuthentication:t?.allowPin??Hy,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),Jf=async()=>{await Wr?.logout(),Wr=null,on.getInstance().reset(),Ji.getInstance().reset(),Di.getInstance().reset(),Wr=await bc()},Ec=()=>Wr?.getIdentity(),T8=async()=>(Wr??await bc()).getIdentity();var x_=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{lf({message:"junoSignOutAuthTimer"}),await Jf()};return r.onmessage=async({data:i})=>{let{msg:s,data:o}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":lf({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},on.getInstance().subscribe(i=>{if((0,E_.isNullish)(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var v_=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},T_=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};var e6=async({idlFactory:t,satellite:e})=>{let r=et(e?.identity);return await i_({idlFactory:t,...e,identity:r})};var ro=Je(gt(),1);var to=Je(gt(),1);var eo=Je(gt(),1);var A_=async({asset:{data:t,headers:e,...r},actor:n})=>{let{init_asset_upload:i,upload_asset_chunk:s,commit_asset_upload:o}=n,{batch_id:a}=await i(A8(r)),{chunkIds:c}=await S8({data:t,uploadFn:s,batchId:a});await O8({commitFn:o,batchId:a,data:t,headers:e,chunkIds:c})};var A8=({filename:t,collection:e,token:r,fullPath:n,encoding:i,description:s})=>({collection:e,full_path:n,name:t,token:(0,eo.toNullable)(r),encoding_type:(0,eo.toNullable)(i),description:(0,eo.toNullable)(s)}),O8=async({commitFn:t,batchId:e,chunkIds:r,headers:n,data:i})=>{let s=n.find(([o,a])=>o.toLowerCase()==="content-type")===void 0&&i.type!==void 0&&i.type!==""?[["Content-Type",i.type]]:void 0;await t({batch_id:e,chunk_ids:r.map(({chunk_id:o})=>o),headers:[...n,...s??[]]})},S8=async({data:t,uploadFn:e,batchId:r})=>{let n=[],i=fc()?new Blob([await t.arrayBuffer()]):t,s=0n;for(let a=0;a<i.size;a+=19e5){let c=i.slice(a,a+19e5);n.push({batchId:r,chunk:c,uploadFn:e,orderId:s}),s++}let o=[];for await(let a of N8({uploadChunks:n}))o=[...o,...a];return{chunkIds:o}};async function*N8({uploadChunks:t,limit:e=12}){for(let r=0;r<t.length;r=r+e){let n=t.slice(r,r+e);yield await Promise.all(n.map(i=>R8(i)))}}var R8=async({batchId:t,chunk:e,uploadFn:r,orderId:n})=>r({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:(0,eo.toNullable)(n)});var O_=async({satellite:t,...e})=>{let r=await lt(t);await A_({actor:r,asset:e})},S_=async({collection:t,satellite:e,filter:r})=>{let{list_assets:n}=await lt(e),{items:i,items_length:s,items_page:o,matches_length:a,matches_pages:c}=await n(t,Mn(r));return{items:i.map(([f,d])=>d),items_length:s,items_page:(0,to.fromNullable)(o),matches_length:a,matches_pages:(0,to.fromNullable)(c)}},N_=async({collection:t,satellite:e,filter:r})=>{let{count_assets:n}=await lt(e);return n(t,Mn(r))},R_=async({collection:t,fullPath:e,satellite:r})=>(await lt(r)).del_asset(t,e),B_=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await lt(e),n=t.map(({collection:i,fullPath:s})=>[i,s]);await r(n)},P_=async({collection:t,satellite:e,filter:r})=>{let{del_filtered_assets:n}=await lt(e);return n(t,Mn(r))},U_=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await lt(r);return(0,to.fromNullable)(await n(t,e))},I_=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await lt(e),n=t.map(({collection:s,fullPath:o})=>[s,o]);return(await r(n)).map(([s,o])=>(0,to.fromNullable)(o))};var C_=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var h6=t=>F_(t),p6=t=>F_({filename:t.data.name,...t}),F_=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:s,satellite:o,encoding:a,description:c})=>{let f=et(o?.identity),d=decodeURI(t),h=i??`/${r}/${d}`,g={...o,identity:f};return await O_({data:e,filename:d,collection:r,token:s,headers:n,fullPath:h,encoding:a,satellite:g,description:c}),{downloadUrl:M_({satellite:g,assetKey:{fullPath:h,token:s}}),fullPath:h,name:d}},y6=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)},{items:i,...s}=await S_({collection:t,satellite:n,filter:r??{}}),o=i.map(({key:{full_path:a,token:c,name:f,owner:d,description:h},headers:g,encodings:b,created_at:l,updated_at:N})=>{let O=(0,ro.fromNullable)(c);return{fullPath:a,description:(0,ro.fromNullable)(h),name:f,downloadUrl:M_({satellite:n,assetKey:{fullPath:a,token:O}}),token:O,headers:g,encodings:b.reduce((I,[M,{modified:A,sha256:K,total_length:E}])=>({...I,[M]:{modified:A,sha256:C_(K),total_length:E}}),{}),owner:d.toText(),created_at:l,updated_at:N}});return{items:o,assets:o,...s}},_6=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await N_({collection:t,satellite:n,filter:r??{}})},g6=({collection:t,fullPath:e,satellite:r})=>R_({collection:t,fullPath:e,satellite:{...r,identity:et(r?.identity)}}),m6=({assets:t,satellite:e})=>B_({assets:t,satellite:{...e,identity:et(e?.identity)}}),b6=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await P_({collection:t,satellite:n,filter:r??{}})},w6=async({satellite:t,...e})=>{let r=et(t?.identity);return await U_({...e,satellite:{...t,identity:r}})},E6=async({satellite:t,...e})=>{let r=et(t?.identity);return await I_({...e,satellite:{...t,identity:r}})},M_=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:et(r?.identity)};return`${r_(n)}${t}${(0,ro.nonNullish)(e)?`?token=${e}`:""}`};var B8=t=>{let e=t?.satelliteId??v_();(0,q_.assertNonNullish)(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??T_();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},N6=t=>P8(t),P8=async t=>{let e=B8(t);Yr.getInstance().set(e),await Df();let r=e.workers?.auth!==void 0?x_(e.workers.auth):void 0;return[...r?[r]:[]]},R6=t=>on.getInstance().subscribe(t);export{gc as InitError,dc as InternetIdentityProvider,mc as ListError,zy as NFIDProvider,pc as SignInError,yc as SignInInitError,_c as SignInUserInterruptError,R6 as authSubscribe,_6 as countAssets,P3 as countDocs,g6 as deleteAsset,S3 as deleteDoc,b6 as deleteFilteredAssets,R3 as deleteFilteredDocs,m6 as deleteManyAssets,N3 as deleteManyDocs,M_ as downloadUrl,w6 as getAsset,__ as getDoc,E6 as getManyAssets,A3 as getManyDocs,e6 as getSatelliteExtendedActor,N6 as initJuno,P8 as initSatellite,y6 as listAssets,B3 as listDocs,g_ as setDoc,O3 as setManyDocs,v8 as signIn,Jf as signOut,T8 as unsafeIdentity,h6 as uploadBlob,p6 as uploadFile};
|
|
54
|
+
Request ID: ${(0,Wp.toHex)(r)}
|
|
55
|
+
`)}throw new Error("unreachable")}Wt.pollForResponse=zp});var Dp=ee(Zl=>{"use strict";Object.defineProperty(Zl,"__esModule",{value:!0});Zl.default=({IDL:t})=>{let e=t.Variant({mainnet:t.Null,testnet:t.Null}),r=t.Text,n=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,s=i,o=t.Nat32,a=t.Record({start_height:o,end_height:t.Opt(o),network:e}),c=t.Vec(t.Nat8),f=t.Record({tip_height:o,block_headers:t.Vec(c)}),d=t.Record({network:e}),h=t.Nat64,g=t.Vec(h),b=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),l=t.Vec(t.Nat8),N=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),O=t.Record({height:t.Nat32,value:i,outpoint:N}),I=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:o,tip_block_hash:l,utxos:t.Vec(O)}),M=t.Record({transaction:t.Vec(t.Nat8),network:e}),A=t.Principal,K=t.Record({canister_id:A,num_requested_changes:t.Opt(t.Nat64)}),E=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),k=t.Vec(t.Nat8),G=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),load_snapshot:t.Record({canister_version:t.Nat64,taken_at_timestamp:t.Nat64,snapshot_id:k}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),z=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:E,details:G}),q=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(z),total_num_changes:t.Nat64}),oe=t.Record({canister_id:A}),Q=t.Variant({controllers:t.Null,public:t.Null,allowed_viewers:t.Vec(t.Principal)}),ie=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:Q,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),w=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:ie,query_stats:t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),m=t.Record({canister_id:A}),R=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(Q),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),S=t.Record({settings:t.Opt(R),sender_canister_version:t.Opt(t.Nat64)}),B=t.Record({canister_id:A}),V=t.Record({canister_id:A}),J=t.Record({canister_id:A,snapshot_id:k}),ae=t.Record({canister_id:A}),ce=t.Variant({secp256k1:t.Null}),D=t.Record({key_id:t.Record({name:t.Text,curve:ce}),canister_id:t.Opt(A),derivation_path:t.Vec(t.Vec(t.Nat8))}),F=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),p=t.Record({canister_id:A}),L=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),re=t.Record({canister_log_records:t.Vec(L)}),le=t.Record({value:t.Text,name:t.Text}),X=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(le)}),u=t.Record({url:t.Text,method:t.Variant({get:t.Null,head:t.Null,post:t.Null}),max_response_bytes:t.Opt(t.Nat64),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Record({function:t.Func([t.Record({context:t.Vec(t.Nat8),response:X})],[X],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(le)}),y=t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({wasm_memory_persistence:t.Opt(t.Variant({keep:t.Null,replace:t.Null})),skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),_=t.Record({hash:t.Vec(t.Nat8)}),U=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:y,chunk_hashes_list:t.Vec(_),target_canister:A,store_canister:t.Opt(A),sender_canister_version:t.Opt(t.Nat64)}),T=t.Vec(t.Nat8),P=t.Record({arg:t.Vec(t.Nat8),wasm_module:T,mode:y,canister_id:A,sender_canister_version:t.Opt(t.Nat64)}),H=t.Record({canister_id:A}),x=t.Record({id:k,total_size:t.Nat64,taken_at_timestamp:t.Nat64}),C=t.Vec(x),$=t.Record({canister_id:A,sender_canister_version:t.Opt(t.Nat64),snapshot_id:k}),j=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),Z=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_proposed_total:t.Nat64}),te=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(Z)})),fe=t.Record({settings:t.Opt(R),specified_id:t.Opt(A),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),me=t.Record({canister_id:A}),Re=t.Record({canister_id:A,amount:t.Nat}),Me=t.Vec(t.Nat8),ye=t.Variant({ed25519:t.Null,bip340secp256k1:t.Null}),he=t.Record({key_id:t.Record({algorithm:ye,name:t.Text}),canister_id:t.Opt(A),derivation_path:t.Vec(t.Vec(t.Nat8))}),Ze=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),Tr=t.Record({key_id:t.Record({name:t.Text,curve:ce}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),Dr=t.Record({signature:t.Vec(t.Nat8)}),Jr=t.Variant({bip341:t.Record({merkle_root_hash:t.Vec(t.Nat8)})}),kt=t.Record({aux:t.Opt(Jr),key_id:t.Record({algorithm:ye,name:t.Text}),derivation_path:t.Vec(t.Vec(t.Nat8)),message:t.Vec(t.Nat8)}),Be=t.Record({signature:t.Vec(t.Nat8)}),Tt=t.Record({canister_id:A}),st=t.Record({canister_id:A}),$e=t.Record({canister_id:A}),xc=t.Vec(_),vc=t.Record({subnet_id:t.Principal}),Ke=t.Record({replica_version:t.Text}),Tc=t.Record({replace_snapshot:t.Opt(k),canister_id:A}),Ac=x,Oc=t.Record({canister_id:A,sender_canister_version:t.Opt(t.Nat64)}),Sc=t.Record({canister_id:t.Principal,settings:R,sender_canister_version:t.Opt(t.Nat64)}),Nc=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),an=_;return t.Service({bitcoin_get_balance:t.Func([n],[s],[]),bitcoin_get_block_headers:t.Func([a],[f],[]),bitcoin_get_current_fee_percentiles:t.Func([d],[g],[]),bitcoin_get_utxos:t.Func([b],[I],[]),bitcoin_send_transaction:t.Func([M],[],[]),canister_info:t.Func([K],[q],[]),canister_status:t.Func([oe],[w],[]),clear_chunk_store:t.Func([m],[],[]),create_canister:t.Func([S],[B],[]),delete_canister:t.Func([V],[],[]),delete_canister_snapshot:t.Func([J],[],[]),deposit_cycles:t.Func([ae],[],[]),ecdsa_public_key:t.Func([D],[F],[]),fetch_canister_logs:t.Func([p],[re],["query"]),http_request:t.Func([u],[X],[]),install_chunked_code:t.Func([U],[],[]),install_code:t.Func([P],[],[]),list_canister_snapshots:t.Func([H],[C],[]),load_canister_snapshot:t.Func([$],[],[]),node_metrics_history:t.Func([j],[te],[]),provisional_create_canister_with_cycles:t.Func([fe],[me],[]),provisional_top_up_canister:t.Func([Re],[],[]),raw_rand:t.Func([],[Me],[]),schnorr_public_key:t.Func([he],[Ze],[]),sign_with_ecdsa:t.Func([Tr],[Dr],[]),sign_with_schnorr:t.Func([kt],[Be],[]),start_canister:t.Func([Tt],[],[]),stop_canister:t.Func([st],[],[]),stored_chunks:t.Func([$e],[xc],[]),subnet_info:t.Func([vc],[Ke],[]),take_canister_snapshot:t.Func([Tc],[Ac],[]),uninstall_code:t.Func([Oc],[],[]),update_settings:t.Func([Sc],[],[]),upload_chunk:t.Func([Nc],[an],[])})}});var Da=ee(Ye=>{"use strict";var yE=Ye&&Ye.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.AdvancedActor=Ye.getManagementCanister=Ye.ACTOR_METHOD_WITH_CERTIFICATE=Ye.ACTOR_METHOD_WITH_HTTP_DETAILS=Ye.Actor=Ye.UpdateCallRejectedError=Ye.QueryCallRejectedError=Ye.ActorCallError=void 0;var _E=md(),Xl=Os(),Ql=yi(),Ms=xi(),Jp=Wa(),cr=It(),gE=Ht(),Vi=Ni(),mE=yE(Dp()),qs=class extends Ql.AgentError{constructor(e,r,n,i){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(s=>` "${s}": ${JSON.stringify(i[s])}`)].join(`
|
|
56
|
+
`)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}};Ye.ActorCallError=qs;var za=class extends qs{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=Xl.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};Ye.QueryCallRejectedError=za;var js=class extends qs{constructor(e,r,n,i,s,o,a){super(e,r,"update",Object.assign({"Request ID":(0,gE.toHex)(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}};Ye.UpdateCallRejectedError=js;var ar=Symbol.for("ic-agent-metadata"),ks=class t{constructor(e){this[ar]=Object.freeze(e)}static agentOf(e){return e[ar].config.agent}static interfaceOf(e){return e[ar].service}static canisterIdOf(e){return cr.Principal.from(e[ar].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],s=[...new Uint8Array(e.module)],o=typeof r.canisterId=="string"?cr.Principal.fromText(r.canisterId):r.canisterId;await Ll(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(e,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await Ll(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:Ms.IDL});class i extends t{constructor(o){if(!o.canisterId)throw new Ql.AgentError(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof o.canisterId=="string"?cr.Principal.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Zp),o),{canisterId:a}),service:n});for(let[c,f]of n._fields)r?.httpDetails&&f.annotations.push(Ye.ACTOR_METHOD_WITH_HTTP_DETAILS),r?.certificate&&f.annotations.push(Ye.ACTOR_METHOD_WITH_CERTIFICATE),this[c]=bE(this,c,f,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Ql.AgentError(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(e,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(e,n))(r)}};Ye.Actor=ks;function Hi(t,e){let r=Ms.IDL.decode(t,_E.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var Zp={pollingStrategyFactory:Jp.strategy.defaultStrategy};Ye.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";Ye.ACTOR_METHOD_WITH_CERTIFICATE="certificate";function bE(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ar].config).queryTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ar].config),o)));let d=o.agent||t[ar].config.agent||(0,Xl.getDefaultAgent)(),h=cr.Principal.from(o.canisterId||t[ar].config.canisterId),g=Ms.IDL.encode(r.argTypes,a),b=await d.query(h,{methodName:e,arg:g,effectiveCanisterId:o.effectiveCanisterId}),l=Object.assign(Object.assign({},b.httpDetails),{requestDetails:b.requestDetails});switch(b.status){case"rejected":throw new za(h,e,b);case"replied":return r.annotations.includes(Ye.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:l,result:Hi(r.retTypes,b.reply.arg)}:Hi(r.retTypes,b.reply.arg)}}:i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ar].config).callTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ar].config),o)));let d=o.agent||t[ar].config.agent||(0,Xl.getDefaultAgent)(),{canisterId:h,effectiveCanisterId:g,pollingStrategyFactory:b}=Object.assign(Object.assign(Object.assign({},Zp),t[ar].config),o),l=cr.Principal.from(h),N=g!==void 0?cr.Principal.from(g):l,O=Ms.IDL.encode(r.argTypes,a),{requestId:I,response:M,requestDetails:A}=await d.call(l,{methodName:e,arg:O,effectiveCanisterId:N}),K,E;if(M.body&&M.body.certificate){if(d.rootKey==null)throw new Error("Agent is missing root key");let q=M.body.certificate;E=await Vi.Certificate.create({certificate:(0,Ms.bufFromBufLike)(q),rootKey:d.rootKey,canisterId:cr.Principal.from(h),blsVerify:n});let oe=[new TextEncoder().encode("request_status"),I];switch(new TextDecoder().decode((0,Vi.lookupResultToBuffer)(E.lookup([...oe,"status"])))){case"replied":K=(0,Vi.lookupResultToBuffer)(E.lookup([...oe,"reply"]));break;case"rejected":{let ie=new Uint8Array((0,Vi.lookupResultToBuffer)(E.lookup([...oe,"reject_code"])))[0],w=new TextDecoder().decode((0,Vi.lookupResultToBuffer)(E.lookup([...oe,"reject_message"]))),m=(0,Vi.lookupResultToBuffer)(E.lookup([...oe,"error_code"])),R=m?new TextDecoder().decode(m):void 0;throw new js(l,e,I,M,ie,w,R)}}}else if(M.body&&"reject_message"in M.body){let{reject_code:q,reject_message:oe,error_code:Q}=M.body;throw new js(l,e,I,M,q,oe,Q)}if(M.status===202){let q=b(),oe=await(0,Jp.pollForResponse)(d,N,I,q,n);E=oe.certificate,K=oe.reply}let k=r.annotations.includes(Ye.ACTOR_METHOD_WITH_HTTP_DETAILS),G=r.annotations.includes(Ye.ACTOR_METHOD_WITH_CERTIFICATE),z=Object.assign(Object.assign({},M),{requestDetails:A});if(K!==void 0)return k&&G?{httpDetails:z,certificate:E,result:Hi(r.retTypes,K)}:G?{certificate:E,result:Hi(r.retTypes,K)}:k?{httpDetails:z,result:Hi(r.retTypes,K)}:Hi(r.retTypes,K);if(r.retTypes.length===0)return k?{httpDetails:M,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 Ll(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:cr.Principal.from(t.effectiveCanisterId)};let i=n[0],s=cr.Principal.fromHex("");return i&&typeof i=="object"&&i.target_canister&&r==="install_chunked_code"&&(s=cr.Principal.from(i.target_canister)),i&&typeof i=="object"&&i.canister_id&&(s=cr.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return ks.createActor(mE.default,Object.assign(Object.assign(Object.assign({},t),{canisterId:cr.Principal.fromHex("")}),{callTransform:e,queryTransform:e}))}Ye.getManagementCanister=Ll;var ef=class extends ks{constructor(e){super(e)}};Ye.AdvancedActor=ef});var Xp=ee(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});tf.default=({IDL:t})=>t.Service({retrieve:t.Func([t.Text],[t.Vec(t.Nat8)],["query"]),store:t.Func([t.Text,t.Vec(t.Nat8)],[],[])})});var Qp=ee($i=>{"use strict";var wE=$i&&$i.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty($i,"__esModule",{value:!0});$i.createAssetCanisterActor=void 0;var EE=Da(),xE=wE(Xp());function vE(t){return EE.Actor.createActor(xE.default,t)}$i.createAssetCanisterActor=vE});var Lp=ee(Kr=>{"use strict";var TE=Kr&&Kr.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),AE=Kr&&Kr.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),OE=Kr&&Kr.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&TE(e,t,r);return AE(e,t),e};Object.defineProperty(Kr,"__esModule",{value:!0});Kr.fetchCandid=void 0;var SE=It(),NE=OE(Ss()),RE=zl(),BE=Da();async function PE(t,e){e||(e=await RE.HttpAgent.create());let n=(await NE.request({agent:e,canisterId:SE.Principal.fromText(t),paths:["candid"]})).get("candid");if(n)return n;let i=({IDL:o})=>o.Service({__get_candid_interface_tmp_hack:o.Func([],[o.Text],["query"])});return await BE.Actor.createActor(i,{agent:e,canisterId:t}).__get_candid_interface_tmp_hack()}Kr.fetchCandid=PE});var Qt=ee(Pe=>{"use strict";var ey=Pe&&Pe.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),UE=Pe&&Pe.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ut=Pe&&Pe.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&ey(e,t,r)},rf=Pe&&Pe.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&ey(e,t,r);return UE(e,t),e};Object.defineProperty(Pe,"__esModule",{value:!0});Pe.Cbor=Pe.CanisterStatus=Pe.polling=void 0;Ut(Da(),Pe);Ut(Os(),Pe);Ut(Qo(),Pe);Ut(_s(),Pe);Ut(Vu(),Pe);Ut(Qp(),Pe);Ut(Ni(),Pe);Ut(Hl(),Pe);Ut(Lp(),Pe);Ut(Gl(),Pe);Ut($l(),Pe);Ut(ds(),Pe);Ut(wl(),Pe);Ut(Ht(),Pe);Ut(Ju(),Pe);Pe.polling=rf(Wa());Pe.CanisterStatus=rf(Ss());Pe.Cbor=rf(ys());Ut(Wa(),Pe)});var gt=ee((yT,by)=>{"use strict";var cf=Object.defineProperty,IE=Object.getOwnPropertyDescriptor,CE=Object.getOwnPropertyNames,FE=Object.prototype.hasOwnProperty,ME=(t,e)=>{for(var r in e)cf(t,r,{get:e[r],enumerable:!0})},qE=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of CE(e))!FE.call(t,i)&&i!==r&&cf(t,i,{get:()=>e[i],enumerable:!(n=IE(e,i))||n.enumerable});return t},jE=t=>qE(cf({},"__esModule",{value:!0}),t),iy={};ME(iy,{AgentManager:()=>DE,Canister:()=>YE,FromStringToTokenError:()=>sy,ICPToken:()=>$E,InvalidPercentageError:()=>fy,NullishError:()=>dy,TokenAmount:()=>KE,TokenAmountV2:()=>GE,arrayBufferToUint8Array:()=>tx,arrayOfNumberToUint8Array:()=>nx,asNonNullish:()=>ZE,asciiStringToByteArray:()=>ix,assertNonNullish:()=>Gs,assertPercentageNumber:()=>XE,base64ToUint8Array:()=>lx,bigEndianCrc32:()=>hx,bigIntToUint8Array:()=>LE,candidNumberArrayToBigInt:()=>ox,convertStringToE8s:()=>oy,createAgent:()=>uy,createServices:()=>JE,debounce:()=>Ex,decodeBase32:()=>cx,defaultAgent:()=>cy,encodeBase32:()=>ax,fromDefinedNullable:()=>vx,fromNullable:()=>uf,fromNullishNullable:()=>Tx,hashObject:()=>yx,hashText:()=>_y,hexStringToUint8Array:()=>sx,isEmptyString:()=>WE,isNullish:()=>Ks,jsonReplacer:()=>yy,jsonReviver:()=>px,nonNullish:()=>Gr,notEmptyString:()=>ay,nowInBigIntNanoSeconds:()=>bx,numberToUint8Array:()=>ex,principalToSubAccount:()=>Ax,queryAndUpdate:()=>zE,secondsToDuration:()=>gx,smallerVersion:()=>Ox,toBigIntNanoSeconds:()=>wx,toNullable:()=>xx,uint8ArrayToArrayOfNumber:()=>rx,uint8ArrayToBase64:()=>ux,uint8ArrayToBigInt:()=>QE,uint8ArrayToHexString:()=>hy});by.exports=jE(iy);var sy=(t=>(t[t.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",t[t.InvalidFormat=1]="InvalidFormat",t[t.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",t))(sy||{}),kE=BigInt(1e8),VE=8,oy=t=>{let e=t.includes("e")?Number(t).toLocaleString("en",{useGrouping:!1,maximumFractionDigits:20}):t;e=e.trim().replace(/[,']/g,"");let r=e.match(/\d*(\.\d*)?/);if(!r||r[0]!==e)return 1;let[n,i]=e.split("."),s=BigInt(0);if(n)try{s+=BigInt(n)*kE}catch{return 1}if(i){if(i.length>8)return 0;try{s+=BigInt(i.padEnd(8,"0"))}catch{return 1}}return s},HE=({amount:t,decimals:e})=>{t=t.trim().replace(/[,']/g,"");let r=t.match(/\d*(\.\d*)?/);if(!r||r[0]!==t)return 1;let[n,i]=t.split("."),s=0n,o=10n**BigInt(e);if(n)try{s+=BigInt(n)*o}catch{return 1}if(i){if(i.length>e)return 2;try{s+=BigInt(i.padEnd(e,"0"))}catch{return 1}}return s},$E={symbol:"ICP",name:"Internet Computer",decimals:8},KE=class Hs{constructor(e,r){if(this.e8s=e,this.token=r,r.decimals!==8)throw new Error("Use TokenAmountV2 for number of decimals other than 8")}static fromE8s({amount:e,token:r}){return new Hs(e,r)}static fromString({amount:e,token:r}){if(r.decimals!==8)throw new Error("Use TokenAmountV2 for number of decimals other than 8");let n=oy(e);return typeof n=="bigint"?new Hs(n,r):n}static fromNumber({amount:e,token:r}){let n=Hs.fromString({amount:e.toString(),token:r});if(n instanceof Hs)return n;throw n===0?new Error(`Number ${e} has more than 8 decimals`):new Error(`Invalid number ${e}`)}toE8s(){return this.e8s}},GE=class $s{constructor(e,r){this.ulps=e,this.token=r}static fromUlps({amount:e,token:r}){return new $s(e,r)}static fromString({amount:e,token:r}){let n=HE({amount:e,decimals:r.decimals});return typeof n=="bigint"?new $s(n,r):n}static fromNumber({amount:e,token:r}){let n=$s.fromString({amount:e.toFixed(Math.min(VE,r.decimals)),token:r});if(n instanceof $s)return n;throw n===2?new Error(`Number ${e} has more than ${r.decimals} decimals`):new Error(`Invalid number ${e}`)}toUlps(){return this.ulps}toE8s(){return this.token.decimals<8?this.ulps*10n**BigInt(8-this.token.decimals):this.token.decimals===8?this.ulps:this.ulps/10n**BigInt(this.token.decimals-8)}},YE=class{constructor(t,e,r){this.id=t,this.service=e,this.certifiedService=r,this.caller=({certified:n=!0})=>n?this.certifiedService:this.service}get canisterId(){return this.id}},Ks=t=>t==null,Gr=t=>!Ks(t),ay=t=>Gr(t)&&t!=="",WE=t=>!ay(t),zE=async({request:t,onLoad:e,onQueryError:r,onUpdateError:n,strategy:i="query_and_update",identity:s,resolution:o="race"})=>{let a=!1,c=d=>t({certified:d,identity:s}).then(h=>{a||e({certified:d,response:h})}).catch(h=>{d||r==null||r({error:h,identity:s}),!a&&(Ks(n)||(console.error(h),d&&n({error:h,identity:s})))}).finally(()=>a=a||d),f=i==="query"?[c(!1)]:i==="update"?[c(!0)]:[c(!1),c(!0)];await(o==="all_settled"?Promise.allSettled(f):Promise.race(f))},ty=Qt(),nf=Qt(),cy=()=>nf.HttpAgent.createSync({host:"https://icp-api.io",identity:new nf.AnonymousIdentity}),uy=async({identity:t,host:e,fetchRootKey:r=!1,verifyQuerySignatures:n=!1,retryTimes:i})=>await nf.HttpAgent.create({identity:t,...Gr(e)&&{host:e},verifyQuerySignatures:n,...Gr(i)&&{retryTimes:i},shouldFetchRootKey:r}),DE=class ly{constructor(e){this.config=e,this.agents=void 0,this.getAgent=async({identity:r})=>{let n=r.getPrincipal().toText();if(Ks(this.agents)||Ks(this.agents[n])){let i=await uy({identity:r,fetchRootKey:this.config.fetchRootKey,host:this.config.host,verifyQuerySignatures:!0});return this.agents={...this.agents??{},[n]:i},i}return this.agents[n]},this.clearAgents=()=>{this.agents=null}}static create(e){return new ly(e)}},JE=({options:{canisterId:t,serviceOverride:e,certifiedServiceOverride:r,agent:n,callTransform:i,queryTransform:s},idlFactory:o,certifiedIdlFactory:a})=>{let c=n??cy(),f=e??ty.Actor.createActor(o,{agent:c,canisterId:t,callTransform:i,queryTransform:s}),d=r??ty.Actor.createActor(a,{agent:c,canisterId:t,callTransform:i,queryTransform:s});return{service:f,certifiedService:d,agent:c,canisterId:t}},fy=class extends Error{},dy=class extends Error{},Gs=(t,e)=>{if(t==null)throw new dy(e)},ZE=(t,e)=>(Gs(t,e),t),XE=t=>{if(t<0||t>100)throw new fy(`${t} is not a valid percentage number.`)},QE=t=>{let e=new DataView(t.buffer,t.byteOffset,t.byteLength);if(typeof e.getBigUint64=="function")return e.getBigUint64(0);{let r=BigInt(e.getUint32(0)),n=BigInt(e.getUint32(4));return(r<<BigInt(32))+n}},LE=t=>{let e=new ArrayBuffer(8),r=new DataView(e);if(typeof r.setBigUint64=="function")r.setBigUint64(0,t);else{let n=Number(t>>BigInt(32)),i=Number(t&BigInt(4294967295));r.setUint32(0,n),r.setUint32(4,i)}return new Uint8Array(e)},ex=t=>{let e=new DataView(new ArrayBuffer(8));for(let r=7;r>=0;--r)e.setUint8(r,t%256),t=t>>8;return new Uint8Array(e.buffer)},tx=t=>new Uint8Array(t),rx=t=>Array.from(t),nx=t=>new Uint8Array(t),ix=t=>Array.from(t).map(e=>e.charCodeAt(0)),sx=t=>{let e=t.match(/.{1,2}/g);return Gs(e,"Invalid hex string."),Uint8Array.from(e.map(r=>parseInt(r,16)))},hy=t=>(t instanceof Uint8Array||(t=Uint8Array.from(t)),t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")),ox=t=>{let e=0n;for(let r=t.length-1;r>=0;r--)e=(e<<32n)+BigInt(t[r]);return e},Ja="abcdefghijklmnopqrstuvwxyz234567",Ki=Object.create(null);for(let t=0;t<Ja.length;t++)Ki[Ja[t]]=t;Ki[0]=Ki.o;Ki[1]=Ki.i;var ax=t=>{let e=0,r=0,n="";function i(s){return e<0?r|=s>>-e:r=s<<e&248,e>3?(e-=8,1):(e<4&&(n+=Ja[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?Ja[r>>3]:"")};function cx(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=Ki[o.toLowerCase()];Gs(a,`Invalid character: ${JSON.stringify(o)}`),a<<=3,r|=a>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=a<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}var ux=t=>btoa(String.fromCharCode(...new Uint8Array(t))),lx=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0)),fx=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]),dx=t=>{let e=-1;for(let r=0;r<t.length;r++){let n=(t[r]^e)&255;e=fx[n]^e>>>8}return(e^-1)>>>0},hx=t=>{let e=new ArrayBuffer(4);return new DataView(e).setUint32(0,dx(t),!1),new Uint8Array(e)},py=It(),sf="__bigint__",of="__principal__",af="__uint8array__",yy=(t,e)=>typeof e=="bigint"?{[sf]:`${e}`}:Gr(e)&&e instanceof py.Principal?{[of]:e.toText()}:Gr(e)&&e instanceof Uint8Array?{[af]:Array.from(e)}:e,px=(t,e)=>{let r=n=>e[n];return Gr(e)&&typeof e=="object"&&sf in e?BigInt(r(sf)):Gr(e)&&typeof e=="object"&&of in e?py.Principal.fromText(r(of)):Gr(e)&&typeof e=="object"&&af in e?Uint8Array.from(r(af)):e},yx=async t=>{let e=JSON.stringify(t,yy);return await _y(e)},_y=async t=>{let e=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",e);return hy(new Uint8Array(r))},_x={year:"year",year_plural:"years",month:"month",month_plural:"months",day:"day",day_plural:"days",hour:"hour",hour_plural:"hours",minute:"minute",minute_plural:"minutes",second:"second",second_plural:"seconds"},gx=({seconds:t,i18n:e=_x})=>{let r=t/BigInt(60),n=r/BigInt(60);r-=n*BigInt(60);let i=n/BigInt(24);n-=i*BigInt(24);let s=mx(i);return i-=gy(s),[Vs("year",s),Vs("day",i),Vs("hour",n),Vs("minute",r),...t>BigInt(0)&&t<BigInt(60)?[Vs("second",t)]:[]].filter(({amount:o})=>o>0).slice(0,2).map(o=>`${o.amount} ${o.amount===1?e[o.labelKey]:e[`${o.labelKey}_plural`]}`).join(", ")},mx=t=>{let e=t/BigInt(365);for(;gy(e)>t;)e--;return e},gy=t=>{let e=t/BigInt(4);return t*BigInt(365)+e},Vs=(t,e)=>({labelKey:t,amount:Number(e)}),my=1000000n,bx=()=>BigInt(Date.now())*my,wx=t=>BigInt(t.getTime())*my,Ex=(t,e)=>{let r;return(...n)=>{let i=()=>t(...n);r&&clearTimeout(r),r=setTimeout(i,e!==void 0&&e>0?e:300)}},xx=t=>Gr(t)?[t]:[],uf=t=>t?.[0],vx=t=>{let e=uf(t);return Gs(e),e},Tx=t=>uf(t??[]),Ax=t=>{let e=t.toUint8Array(),r=new Uint8Array(32);return r[0]=e.length,r.set(e,1),r},ry=(t,e)=>e>t.length?[...t,...[...Array(e-t.length).keys()].map(()=>0)]:t,ny=t=>{if(!Number.isNaN(Number(t)))return Number(t);let e=t.split("").reduce((r,n)=>Number.isNaN(Number(n))?r:r+n,"");return Number(e)},Ox=({minVersion:t,currentVersion:e})=>{let r=ry(t.split(".").map(ny),3).join(".");return ry(e.split(".").map(ny),3).join(".").localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})<0}});var Ey=ee(Wr=>{"use strict";var Qa=Wr&&Wr.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Pn=Wr&&Wr.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Za,Xa,Yi,Wi;Object.defineProperty(Wr,"__esModule",{value:!0});Wr.Ed25519KeyIdentity=Wr.Ed25519PublicKey=void 0;var Sx=Qt(),Lt=Qt(),Ys=kl();function wy(t){return t!==null&&typeof t=="object"}var ri=class t{constructor(e){if(Za.set(this,void 0),Xa.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Qa(this,Za,e,"f"),Qa(this,Xa,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=(0,Lt.fromHex)(e);return this.fromRaw(r)}else if(wy(e)){let r=e;if(wy(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,Lt.bufFromBufLike)(n.buffer))}else{if(r instanceof ArrayBuffer)return this.fromRaw(r);if("rawKey"in r)return this.fromRaw(r.rawKey);if("derKey"in r)return this.fromDer(r.derKey);if("toDer"in r)return this.fromDer(r.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){let r=(0,Lt.wrapDER)(e,Lt.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=(0,Lt.unwrapDER)(e,Lt.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Pn(this,Za,"f")}get derKey(){return Pn(this,Xa,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Wr.Ed25519PublicKey=ri;Za=new WeakMap,Xa=new WeakMap;ri.RAW_KEY_LENGTH=32;var ff=class t extends Lt.SignIdentity{constructor(e,r){super(),Yi.set(this,void 0),Wi.set(this,void 0),Qa(this,Yi,ri.from(e),"f"),Qa(this,Wi,new Uint8Array(r),"f")}static generate(e){if(e&&e.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");e||(e=Ys.ed25519.utils.randomPrivateKey()),(0,Sx.bufEquals)(e,new Uint8Array(new Array(32).fill(0)))&&console.warn("Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.");let r=new Uint8Array(32);for(let i=0;i<32;i++)r[i]=new Uint8Array(e)[i];let n=Ys.ed25519.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(ri.fromDer((0,Lt.fromHex)(r)),(0,Lt.fromHex)(n))}static fromJSON(e){let r=JSON.parse(e);if(Array.isArray(r)){if(typeof r[0]=="string"&&typeof r[1]=="string")return this.fromParsedJson([r[0],r[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(e)}`)}static fromKeyPair(e,r){return new t(ri.fromRaw(e),r)}static fromSecretKey(e){let r=Ys.ed25519.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[(0,Lt.toHex)(Pn(this,Yi,"f").toDer()),(0,Lt.toHex)(Pn(this,Wi,"f"))]}getKeyPair(){return{secretKey:Pn(this,Wi,"f"),publicKey:Pn(this,Yi,"f")}}getPublicKey(){return Pn(this,Yi,"f")}async sign(e){let r=new Uint8Array(e),n=(0,Lt.uint8ToBuf)(Ys.ed25519.sign(r,Pn(this,Wi,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(e,r,n){let[i,s,o]=[e,r,n].map(a=>(typeof a=="string"&&(a=(0,Lt.fromHex)(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return Ys.ed25519.verify(s,i,o)}};Wr.Ed25519KeyIdentity=ff;Yi=new WeakMap,Wi=new WeakMap});var vy=ee(ni=>{"use strict";Object.defineProperty(ni,"__esModule",{value:!0});ni.ECDSAKeyIdentity=ni.CryptoError=void 0;var Nx=Qt(),La=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};ni.CryptoError=La;function xy(t){if(typeof global<"u"&&global.crypto&&global.crypto.subtle)return global.crypto.subtle;if(t)return t;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new La("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var ec=class t extends Nx.SignIdentity{constructor(e,r,n){super(),this._keyPair=e,this._derKey=r,this._subtleCrypto=n}static async generate(e){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=e??{},s=xy(i),o=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await s.exportKey("spki",o.publicKey);return new this(o,a,s)}static async fromKeyPair(e,r){let n=xy(r),i=await n.exportKey("spki",e.publicKey);return new t(e,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let e=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return e},r}async sign(e){let r={name:"ECDSA",hash:{name:"SHA-256"}};return await this._subtleCrypto.sign(r,this._keyPair.privateKey,e)}};ni.ECDSAKeyIdentity=ec;ni.default=ec});var hf=ee(In=>{"use strict";var Rx=In&&In.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ws=In&&In.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Un;Object.defineProperty(In,"__esModule",{value:!0});In.PartialIdentity=void 0;var Bx=It(),df=class{constructor(e){Un.set(this,void 0),Rx(this,Un,e,"f")}get rawKey(){return Ws(this,Un,"f").rawKey}get derKey(){return Ws(this,Un,"f").derKey}toDer(){return Ws(this,Un,"f").toDer()}getPublicKey(){return Ws(this,Un,"f")}getPrincipal(){return Bx.Principal.from(Ws(this,Un,"f").rawKey)}transformRequest(){return Promise.reject("Not implemented. You are attempting to use a partial identity to sign calls, but this identity only has access to the public key.To sign calls, use a DelegationIdentity instead.")}};In.PartialIdentity=df;Un=new WeakMap});var Ty=ee(De=>{"use strict";var Px=De&&De.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Ux=De&&De.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ix=De&&De.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Px(e,t,r);return Ux(e,t),e},Cx=De&&De.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Fx=De&&De.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Mx=De&&De.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},tc;Object.defineProperty(De,"__esModule",{value:!0});De.isDelegationValid=De.PartialDelegationIdentity=De.DelegationIdentity=De.DelegationChain=De.Delegation=void 0;var Cn=Qt(),yf=It(),zs=Ix(ps()),qx=hf(),jx=new TextEncoder().encode("ic-request-auth-delegation"),kx=new TextEncoder().encode(`
|
|
57
|
+
ic-request`);function pf(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return(0,Cn.fromHex)(t)}var Ds=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return zs.value.map(Object.assign({pubkey:zs.value.bytes(this.pubkey),expiration:zs.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:zs.value.array(this.targets.map(e=>zs.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,Cn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};De.Delegation=Ds;async function Vx(t,e,r,n){let i=new Ds(e.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...jx,...new Uint8Array((0,Cn.requestIdOf)(Object.assign({},i)))]),o=await t.sign(s);return{delegation:i,signature:o}}var _f=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+15*60*1e3),i={}){var s,o;let a=await Vx(e,r,n,i.targets);return new t([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],a],((o=i.previous)===null||o===void 0?void 0:o.publicKey)||e.getPublicKey().toDer())}static fromJSON(e){let{publicKey:r,delegations:n}=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:o,signature:a}=s,{pubkey:c,expiration:f,targets:d}=o;if(d!==void 0&&!Array.isArray(d))throw new Error("Invalid targets.");return{delegation:new Ds(pf(c),BigInt("0x"+f),d&&d.map(h=>{if(typeof h!="string")throw new Error("Invalid target.");return yf.Principal.fromHex(h)})),signature:pf(a)}});return new this(i,pf(r))}static fromDelegations(e,r){return new this(e,r)}toJSON(){return{delegations:this.delegations.map(e=>{let{delegation:r,signature:n}=e,{targets:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:(0,Cn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,Cn.toHex)(n)}}),publicKey:(0,Cn.toHex)(this.publicKey)}}};De.DelegationChain=_f;var gf=class extends Cn.SignIdentity{constructor(e,r){super(),this._inner=e,this._delegation=r}static fromDelegation(e,r){return new this(e,r)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(e){return this._inner.sign(e)}async transformRequest(e){let{body:r}=e,n=Mx(e,["body"]),i=await(0,Cn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...kx,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};De.DelegationIdentity=gf;var mf=class t extends qx.PartialIdentity{constructor(e,r){super(e),tc.set(this,void 0),Cx(this,tc,r,"f")}get delegation(){return Fx(this,tc,"f")}static fromDelegation(e,r){return new t(e,r)}};De.PartialDelegationIdentity=mf;tc=new WeakMap;function Hx(t,e){for(let{delegation:i}of t.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?yf.Principal.fromText(i):i)):r.push(typeof n=="string"?yf.Principal.fromText(n):n));for(let i of r){let s=i.toText();for(let{delegation:o}of t.delegations){if(o.targets===void 0)continue;let a=!0;for(let c of o.targets)if(c.toText()===s){a=!1;break}if(a)return!1}}return!0}De.isDelegationValid=Hx});var Ay=ee(Fn=>{"use strict";var $x=Fn&&Fn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Fn,"__esModule",{value:!0});Fn.WebAuthnIdentity=Fn.CosePublicKey=void 0;var ii=Qt(),bf=$x($o()),Kx=kn(),Gx=xi();function Yx(t){return(0,ii.wrapDER)(t,ii.DER_COSE_OID).buffer}function Wx(t){let e=new DataView(new ArrayBuffer(2)),r=t.slice(53,55);[...new Uint8Array(r)].forEach((i,s)=>e.setUint8(s,i));let n=e.getUint16(0);return t.slice(55+n)}var rc=class{constructor(e){this._cose=e,this._encodedKey=Yx(e)}toDer(){return this._encodedKey}getCose(){return this._cose}};Fn.CosePublicKey=rc;function zx(t="<ic0.app>"){return typeof t=="string"?Uint8Array.from(t,e=>e.charCodeAt(0)):t}async function Dx(t){let e=await navigator.credentials.create(t??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:zx(),pubKeyCredParams:[{type:"public-key",alg:wf.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,Kx.randomBytes)(16),name:"Internet Identity",displayName:"Internet Identity"}}});return e===null?null:{id:e.id,response:e.response,type:e.type,authenticatorAttachment:e.authenticatorAttachment,getClientExtensionResults:e.getClientExtensionResults,rawId:(0,Gx.bufFromBufLike)(e.rawId)}}var wf;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(wf||(wf={}));var Ef=class extends ii.SignIdentity{constructor(e,r,n){super(),this.rawId=e,this.authenticatorAttachment=n,this._publicKey=new rc(r)}static fromJSON(e){let{publicKey:r,rawId:n}=JSON.parse(e);if(typeof r!="string"||typeof n!="string")throw new Error("Invalid JSON string.");return new this((0,ii.fromHex)(n),(0,ii.fromHex)(r),void 0)}static async create(e){var r;let n=await Dx(e);if(!n||n.type!=="public-key")throw new Error("Could not create credentials.");let i=n.response;if(i.attestationObject===void 0)throw new Error("Was expecting an attestation response.");let s=bf.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,Wx(s.authData),(r=n.authenticatorAttachment)!==null&&r!==void 0?r:void 0)}getPublicKey(){return this._publicKey}getAuthenticatorAttachment(){return this.authenticatorAttachment}async sign(e){let r=await navigator.credentials.get({publicKey:{allowCredentials:[{type:"public-key",id:this.rawId}],challenge:e,userVerification:"preferred"}});r.authenticatorAttachment!==null&&(this.authenticatorAttachment=r.authenticatorAttachment);let n=r.response,i=bf.default.encode(new bf.default.Tagged(55799,{authenticator_data:new Uint8Array(n.authenticatorData),client_data_json:new TextDecoder().decode(n.clientDataJSON),signature:new Uint8Array(n.signature)}));if(!i)throw new Error("failed to encode cbor");return i.buffer}toJSON(){return{publicKey:(0,ii.toHex)(this._publicKey.getCose()),rawId:(0,ii.toHex)(this.rawId)}}};Fn.WebAuthnIdentity=Ef});var Sy=ee(We=>{"use strict";var Jx=We&&We.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),vf=We&&We.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Jx(e,t,r)};Object.defineProperty(We,"__esModule",{value:!0});We.Secp256k1KeyIdentity=We.ED25519_OID=We.DER_COSE_OID=We.unwrapDER=We.wrapDER=We.WebAuthnIdentity=We.Ed25519PublicKey=We.Ed25519KeyIdentity=void 0;var Oy=Ey();Object.defineProperty(We,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return Oy.Ed25519KeyIdentity}});Object.defineProperty(We,"Ed25519PublicKey",{enumerable:!0,get:function(){return Oy.Ed25519PublicKey}});vf(vy(),We);vf(Ty(),We);vf(hf(),We);var Zx=Ay();Object.defineProperty(We,"WebAuthnIdentity",{enumerable:!0,get:function(){return Zx.WebAuthnIdentity}});var nc=Qt();Object.defineProperty(We,"wrapDER",{enumerable:!0,get:function(){return nc.wrapDER}});Object.defineProperty(We,"unwrapDER",{enumerable:!0,get:function(){return nc.unwrapDER}});Object.defineProperty(We,"DER_COSE_OID",{enumerable:!0,get:function(){return nc.DER_COSE_OID}});Object.defineProperty(We,"ED25519_OID",{enumerable:!0,get:function(){return nc.ED25519_OID}});var xf=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};We.Secp256k1KeyIdentity=xf});var Af=ee(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.IdleManager=void 0;var Ny=["mousedown","mousemove","keydown","touchstart","wheel"],Tf=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let s=this._resetTimer.bind(this);window.addEventListener("load",s,!0),Ny.forEach(function(a){document.addEventListener(a,s,!0)});let o=(a,c)=>{let f;return(...d)=>{let h=this,g=function(){f=void 0,a.apply(h,d)};clearTimeout(f),f=window.setTimeout(g,c)}};if(e?.captureScroll){let a=o(s,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}s()}static create(e={}){return new this(e)}registerCallback(e){this.callbacks.push(e)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let e=this._resetTimer.bind(this);Ny.forEach(function(r){document.removeEventListener(r,e,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let e=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(e,this.idleTimeout)}};ic.IdleManager=Tf});function Qx(){return Ry||(Ry=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Lx(){return By||(By=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function e8(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{r(ur(t.result)),i()},o=()=>{n(t.error),i()};t.addEventListener("success",s),t.addEventListener("error",o)});return e.then(r=>{r instanceof IDBCursor&&Py.set(r,t)}).catch(()=>{}),Rf.set(e,t),e}function t8(t){if(Sf.has(t))return;let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",o),t.removeEventListener("abort",o)},s=()=>{r(),i()},o=()=>{n(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",s),t.addEventListener("error",o),t.addEventListener("abort",o)});Sf.set(t,e)}function Iy(t){Nf=t(Nf)}function r8(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Js(this),e,...r);return Uy.set(n,e.sort?e.sort():[e]),ur(n)}:Lx().includes(t)?function(...e){return t.apply(Js(this),e),ur(Py.get(this))}:function(...e){return ur(t.apply(Js(this),e))}}function n8(t){return typeof t=="function"?r8(t):(t instanceof IDBTransaction&&t8(t),Xx(t,Qx())?new Proxy(t,Nf):t)}function ur(t){if(t instanceof IDBRequest)return e8(t);if(Of.has(t))return Of.get(t);let e=n8(t);return e!==t&&(Of.set(t,e),Rf.set(e,t)),e}var Xx,Ry,By,Py,Sf,Uy,Of,Rf,Nf,Js,Bf=Xf(()=>{Xx=(t,e)=>e.some(r=>t instanceof r);Py=new WeakMap,Sf=new WeakMap,Uy=new WeakMap,Of=new WeakMap,Rf=new WeakMap;Nf={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return Sf.get(t);if(e==="objectStoreNames")return t.objectStoreNames||Uy.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return ur(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};Js=t=>Rf.get(t)});var Fy={};ng(Fy,{deleteDB:()=>s8,openDB:()=>i8,unwrap:()=>Js,wrap:()=>ur});function i8(t,e,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(t,e),a=ur(o);return n&&o.addEventListener("upgradeneeded",c=>{n(ur(o.result),c.oldVersion,c.newVersion,ur(o.transaction),c)}),r&&o.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",f=>i(f.oldVersion,f.newVersion,f))}).catch(()=>{}),a}function s8(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),ur(r).then(()=>{})}function Cy(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Pf.get(e))return Pf.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=a8.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||o8.includes(r)))return;let s=async function(o,...a){let c=this.transaction(o,i?"readwrite":"readonly"),f=c.store;return n&&(f=f.index(a.shift())),(await Promise.all([f[r](...a),i&&c.done]))[0]};return Pf.set(e,s),s}var o8,a8,Pf,My=Xf(()=>{Bf();Bf();o8=["get","getKey","getAll","getAllKeys","count"],a8=["put","add","delete","clear"],Pf=new Map;Iy(t=>({...t,get:(e,r,n)=>Cy(e,r)||t.get(e,r,n),has:(e,r)=>!!Cy(e,r)||t.has(e,r)}))});var If=ee(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.IdbKeyVal=void 0;var c8=(My(),ig(Fy)),Zs=oc(),qy="auth-client-db",jy="ic-keyval",u8=async(t=qy,e=jy,r)=>(Zs.isBrowser&&(localStorage!=null&&localStorage.getItem(Zs.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(Zs.KEY_STORAGE_DELEGATION),localStorage.removeItem(Zs.KEY_STORAGE_KEY)),await(0,c8.openDB)(t,r,{upgrade:n=>{n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function l8(t,e,r){return await t.get(e,r)}async function f8(t,e,r,n){return await t.put(e,n,r)}async function d8(t,e,r){return await t.delete(e,r)}var Uf=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=qy,storeName:n=jy,version:i=Zs.DB_VERSION}=e??{},s=await u8(r,n,i);return new t(s,n)}async set(e,r){return await f8(this._db,this._storeName,e,r)}async get(e){var r;return(r=await l8(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await d8(this._db,this._storeName,e)}};sc.IdbKeyVal=Uf});var oc=ee(nt=>{"use strict";var h8=nt&&nt.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},p8=nt&&nt.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ac;Object.defineProperty(nt,"__esModule",{value:!0});nt.IdbStorage=nt.LocalStorage=nt.isBrowser=nt.DB_VERSION=nt.KEY_VECTOR=nt.KEY_STORAGE_DELEGATION=nt.KEY_STORAGE_KEY=void 0;var y8=If();nt.KEY_STORAGE_KEY="identity";nt.KEY_STORAGE_DELEGATION="delegation";nt.KEY_VECTOR="iv";nt.DB_VERSION=1;nt.isBrowser=typeof window<"u";var Cf=class{constructor(e="ic-",r){this.prefix=e,this._localStorage=r}get(e){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+e))}set(e,r){return this._getLocalStorage().setItem(this.prefix+e,r),Promise.resolve()}remove(e){return this._getLocalStorage().removeItem(this.prefix+e),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let e=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!e)throw new Error("Could not find local storage.");return e}};nt.LocalStorage=Cf;var Ff=class{constructor(e){ac.set(this,void 0),h8(this,ac,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}y8.IdbKeyVal.create(p8(this,ac,"f")).then(r=>{this.initializedDb=r,e(r)})})}async get(e){return await(await this._db).get(e)}async set(e,r){await(await this._db).set(e,r)}async remove(e){await(await this._db).remove(e)}};nt.IdbStorage=Ff;ac=new WeakMap});var Vf=ee(Le=>{"use strict";var _8=Le&&Le.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),g8=Le&&Le.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&_8(e,t,r)};Object.defineProperty(Le,"__esModule",{value:!0});Le.AuthClient=Le.ERROR_USER_INTERRUPT=Le.IdbKeyVal=Le.KEY_STORAGE_KEY=Le.KEY_STORAGE_DELEGATION=Le.LocalStorage=Le.IdbStorage=void 0;var ky=Qt(),er=Sy(),Vy=Af(),vt=oc(),cc=oc();Object.defineProperty(Le,"IdbStorage",{enumerable:!0,get:function(){return cc.IdbStorage}});Object.defineProperty(Le,"LocalStorage",{enumerable:!0,get:function(){return cc.LocalStorage}});Object.defineProperty(Le,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return cc.KEY_STORAGE_DELEGATION}});Object.defineProperty(Le,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return cc.KEY_STORAGE_KEY}});var m8=If();Object.defineProperty(Le,"IdbKeyVal",{enumerable:!0,get:function(){return m8.IdbKeyVal}});var b8="https://identity.ic0.app",w8="#authorize",Mf="ECDSA",qf="Ed25519",E8=500;Le.ERROR_USER_INTERRUPT="UserInterrupt";g8(Af(),Le);var kf=class{constructor(e,r,n,i,s,o,a,c){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=o,this._idpWindow=a,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let s=(r=e.storage)!==null&&r!==void 0?r:new vt.IdbStorage,o=(n=e.keyType)!==null&&n!==void 0?n:Mf,a=null;if(e.identity)a=e.identity;else{let h=await s.get(vt.KEY_STORAGE_KEY);if(!h&&vt.isBrowser)try{let g=new vt.LocalStorage,b=await g.get(vt.KEY_STORAGE_DELEGATION),l=await g.get(vt.KEY_STORAGE_KEY);b&&l&&o===Mf&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(vt.KEY_STORAGE_DELEGATION,b),await s.set(vt.KEY_STORAGE_KEY,l),h=b,await g.remove(vt.KEY_STORAGE_DELEGATION),await g.remove(vt.KEY_STORAGE_KEY))}catch(g){console.error("error while attempting to recover localstorage: "+g)}if(h)try{typeof h=="object"?o===qf&&typeof h=="string"?a=await er.Ed25519KeyIdentity.fromJSON(h):a=await er.ECDSAKeyIdentity.fromKeyPair(h):typeof h=="string"&&(a=er.Ed25519KeyIdentity.fromJSON(h))}catch{}}let c=new ky.AnonymousIdentity,f=null;if(a)try{let h=await s.get(vt.KEY_STORAGE_DELEGATION);if(typeof h=="object"&&h!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?c=e.identity:h&&(f=er.DelegationChain.fromJSON(h),(0,er.isDelegationValid)(f)?"toDer"in a?c=er.PartialDelegationIdentity.fromDelegation(a,f):c=er.DelegationIdentity.fromDelegation(a,f):(await jf(s),a=null))}catch(h){console.error(h),await jf(s),a=null}let d;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?d=void 0:(f||e.identity)&&(d=Vy.IdleManager.create(e.idleOptions)),a||(o===qf?(a=await er.Ed25519KeyIdentity.generate(),await s.set(vt.KEY_STORAGE_KEY,JSON.stringify(a.toJSON()))):(e.storage&&o===Mf&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${qf}' as the key type, as it can serialize to a string`),a=await er.ECDSAKeyIdentity.generate(),await s.set(vt.KEY_STORAGE_KEY,a.getKeyPair()))),new this(c,a,f,s,d,e)}_registerDefaultIdleCallback(){var e,r;let n=(e=this._createOptions)===null||e===void 0?void 0:e.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(e,r){var n,i;let s=e.delegations.map(f=>({delegation:new er.Delegation(f.delegation.pubkey,f.delegation.expiration,f.delegation.targets),signature:f.signature.buffer})),o=er.DelegationChain.fromDelegations(s,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=o,"toDer"in a?this._identity=er.PartialDelegationIdentity.fromDelegation(a,this._chain):this._identity=er.DelegationIdentity.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=Vy.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(vt.KEY_STORAGE_DELEGATION,JSON.stringify(this._chain.toJSON())),r?.(e)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(e){var r,n,i,s;let o=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||b8);a.hash=w8,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=e?.maxTimeToLive)!==null&&i!==void 0?i:o},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Le.ERROR_USER_INTERRUPT,e?.onError):setTimeout(c,E8))};c()}_getEventHandler(e,r){return async n=>{var i,s,o;if(n.origin!==e.origin)return;let a=n.data;switch(a.kind){case"authorize-ready":{let c=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(s=r?.derivationOrigin)===null||s===void 0?void 0:s.toString()},r?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(c,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.text,r?.onError);break;default:break}}}_handleFailure(e,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(e),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(e={}){if(await jf(this._storage),this._identity=new ky.AnonymousIdentity,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};Le.AuthClient=kf;async function jf(t){await t.remove(vt.KEY_STORAGE_KEY),await t.remove(vt.KEY_STORAGE_DELEGATION),await t.remove(vt.KEY_VECTOR)}});var q_=Je(gt(),1);var E_=Je(gt(),1);var Gi=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:r})=>r(e))}subscribe(e){let r=Symbol();return this.callbacks.push({id:r,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var Yr=class t extends Gi{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let r=super.subscribe(e);return e(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var lf=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var w_=Je(Vf(),1),Df=Je(gt(),1);var Hy=BigInt(144e11),$y=!1,Ky={width:576,height:576},Gy={width:505,height:705},Yy="internetcomputer.org";var Xs=Je(gt(),1);var zi="http://127.0.0.1:5987",Wy="rdmx6-jaaaa-aaaaa-aaadq-cai";var zr=class t extends Gi{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var Hf=Je(gt(),1);var uc=Je(gt(),1),zy=async t=>{let e=new Blob([JSON.stringify(t,uc.jsonReplacer)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},lc=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),uc.jsonReviver)},fc=()=>typeof window<"u";var $f=({width:t,height:e})=>{if(!fc()||(0,Hf.isNullish)(window)||(0,Hf.isNullish)(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-e/2,s=r/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${s}`};var dc=class{#e;constructor({domain:e}){this.#e=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=zr.getInstance().get()?.container;if((0,Xs.isNullish)(n)||n===!1)return`https://identity.${this.#e??Yy}`;let i=zr.getInstance().get(),s=(0,Xs.nonNullish)(i)&&(0,Xs.nonNullish)(i?.internetIdentityId)?i.internetIdentityId:Wy,{host:o,protocol:a}=new URL(n===!0?zi:n);return/apple/i.test(navigator?.vendor)?`${a}//${o}?canisterId=${s}`:`${a}//${s}.${o.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:$f(Ky)},identityProvider:r()}}},Dy=class{#e;#t;constructor({appName:e,logoUrl:r}){this.#e=e,this.#t=r}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:$f(Gy)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var Zy=Je(Qt(),1),hc=Je(gt(),1);var Jy=Je(Qt(),1),si=Je(gt(),1);var Di=class t{static instance;#e=void 0;constructor(){}static getInstance(){return(0,si.isNullish)(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...r}){let n=e.getPrincipal().toText();if((0,si.isNullish)(this.#e)||(0,si.isNullish)(this.#e[n])){let i=await this.createAgent({identity:e,...r});return this.#e={...this.#e??{},[n]:i},i}return this.#e[n]}reset(){this.#e=null}async createAgent({identity:e,container:r}){let i=(0,si.nonNullish)(r)&&r!==!1?r===!0?zi:r:"https://icp-api.io",s=(0,si.nonNullish)(r);return await Jy.HttpAgent.create({identity:e,shouldFetchRootKey:s,host:i})}};var Ji=class t{static instance;#e=void 0;constructor(){}static getInstance(){return(0,hc.isNullish)(t.instance)&&(t.instance=new t),t.instance}async getActor({satelliteId:e,identity:r,buildType:n,...i}){let s=`${n}#${r.getPrincipal().toText()}#${e};`;if((0,hc.isNullish)(this.#e)||(0,hc.isNullish)(this.#e[s])){let o=await this.createActor({satelliteId:e,identity:r,...i});return this.#e={...this.#e??{},[s]:o},o}return this.#e[s]}reset(){this.#e=null}async createActor({idlFactory:e,satelliteId:r,...n}){let i=await Di.getInstance().getAgent(n);return Zy.Actor.createActor(e,{agent:i,canisterId:r})}};var pc=class extends Error{},yc=class extends Error{},_c=class extends Error{},gc=class extends Error{},mc=class extends Error{};var Xy=Je(Vf(),1),bc=()=>Xy.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Ls=Je(gt(),1);var Kf=({error:t,type:e})=>typeof t=="string"?t.includes(e):t instanceof Error?t.message.includes(e):!1;var Qy="juno.datastore.error.user.cannot_update";var vr=Je(gt(),1);var Ly=async({data:t})=>{try{return await lc(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var oi=Je(gt(),1);var Gf=async t=>{let{data:e,version:r,description:n}=t;return{description:(0,oi.toNullable)(n),data:await zy(e),version:(0,oi.toNullable)(r)}},Yf=t=>{let{version:e}=t;return{version:(0,oi.toNullable)(e)}},Qs=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:s,...o}=t;return{key:e,description:(0,oi.fromNullable)(i),owner:r.toText(),data:await lc(s),version:(0,oi.fromNullable)(n),...o}};var t_=Je(It(),1),it=Je(gt(),1);var e_=t=>{if((0,it.isNullish)(t))return(0,it.toNullable)();switch(t.matcher){case"equal":return(0,it.toNullable)({Equal:t.timestamp});case"greaterThan":return(0,it.toNullable)({GreaterThan:t.timestamp});case"lessThan":return(0,it.toNullable)({LessThan:t.timestamp});case"between":return(0,it.toNullable)({Between:[t.timestamps.start,t.timestamps.end]});default:throw new mc("Invalid list matcher for timestamp",t)}},Mn=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:(0,it.isNullish)(t)?[]:[{key:(0,it.toNullable)(t.key),description:(0,it.toNullable)(t.description),created_at:e_(t.createdAt),updated_at:e_(t.updatedAt)}],paginate:(0,it.toNullable)((0,it.isNullish)(e)?void 0:{start_after:(0,it.toNullable)(e.startAfter),limit:(0,it.toNullable)((0,it.isNullish)(e.limit)?void 0:BigInt(e.limit))}),order:(0,it.toNullable)((0,it.isNullish)(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:(0,it.toNullable)((0,it.isNullish)(n)?void 0:typeof n=="string"?t_.Principal.fromText(n):n)});var i_=Je(gt(),1);var r_=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({sha256:t.Vec(t.Nat8),proposal_id:t.Nat}),n=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),i=t.Record({field:n,desc:t.Bool}),s=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),o=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(s),description:t.Opt(t.Text),created_at:t.Opt(s)}),a=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),c=t.Record({order:t.Opt(i),owner:t.Opt(t.Principal),matcher:t.Opt(o),paginate:t.Opt(a)}),f=t.Record({controllers:t.Vec(t.Principal)}),d=t.Variant({Write:t.Null,Admin:t.Null,Submit:t.Null}),h=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:d,expires_at:t.Opt(t.Nat64)}),g=t.Record({version:t.Opt(t.Nat64)}),b=t.Variant({Db:t.Null,Storage:t.Null}),l=t.Record({version:t.Opt(t.Nat64)}),N=t.Record({proposal_ids:t.Vec(t.Nat)}),O=t.Record({cycles:t.Nat,destination_id:t.Principal}),I=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),M=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),A=t.Record({key:I,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,M)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),K=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),E=t.Record({internet_identity:t.Opt(K)}),k=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),G=t.Record({max_memory_size:t.Opt(k)}),z=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),q=t.Variant({Deny:t.Null,Allow:t.Null}),oe=t.Record({status_code:t.Nat16,location:t.Text}),Q=t.Record({iframe:t.Opt(z),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(k),raw_access:t.Opt(q),redirects:t.Opt(t.Vec(t.Tuple(t.Text,oe)))}),ie=t.Record({db:t.Opt(G),authentication:t.Opt(E),storage:Q}),w=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),m=t.Variant({Initialized:t.Null,Failed:t.Null,Open:t.Null,Rejected:t.Null,Executed:t.Null,Accepted:t.Null}),R=t.Record({clear_existing_assets:t.Opt(t.Bool)}),S=t.Record({orbiter:t.Opt(t.Text),mission_control_version:t.Opt(t.Text),satellite_version:t.Opt(t.Text)}),B=t.Variant({AssetsUpgrade:R,SegmentsDeployment:S}),V=t.Record({status:m,updated_at:t.Nat64,sha256:t.Opt(t.Vec(t.Nat8)),executed_at:t.Opt(t.Nat64),owner:t.Principal,created_at:t.Nat64,version:t.Opt(t.Nat64),proposal_type:B}),J=t.Variant({Heap:t.Null,Stable:t.Null}),ae=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),ce=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),D=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(J),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:ae,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(ce),write:ae,max_changes_per_user:t.Opt(t.Nat32)}),F=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),p=t.Record({memory:J,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),L=t.Variant({Callback:t.Record({token:p,callback:t.Func([],[],["query"])})}),re=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(L),status_code:t.Nat16}),le=t.Record({token:t.Opt(p),body:t.Vec(t.Nat8)}),X=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),u=t.Record({batch_id:t.Nat}),y=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,A)),items_length:t.Nat64}),_=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),U=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,w)),items_length:t.Nat64}),T=t.Record({desc:t.Bool}),P=t.Record({start_after:t.Opt(t.Nat),limit:t.Opt(t.Nat)}),H=t.Record({order:t.Opt(T),paginate:t.Opt(P)}),x=t.Record({proposal_id:t.Nat}),C=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(x,V)),items_length:t.Nat64}),$=t.Record({include_system:t.Bool}),j=t.Record({matcher:t.Opt($)}),Z=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(t.Text,D)),items_length:t.Nat64}),te=t.Record({stable:t.Nat64,heap:t.Nat64}),fe=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:d,expires_at:t.Opt(t.Nat64)}),me=t.Record({controller:fe,controllers:t.Vec(t.Principal)}),Re=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),Me=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(J),max_size:t.Opt(t.Nat),read:ae,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(ce),write:ae,max_changes_per_user:t.Opt(t.Nat32)}),ye=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),he=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),commit_proposal:t.Func([r],[t.Null],[]),commit_proposal_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,c],[t.Nat64],["query"]),count_collection_assets:t.Func([t.Text],[t.Nat64],["query"]),count_collection_docs:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text,c],[t.Nat64],["query"]),count_proposals:t.Func([],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([f],[t.Vec(t.Tuple(t.Principal,h))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,g],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,c],[],[]),del_filtered_docs:t.Func([t.Text,c],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,g))],[],[]),del_rule:t.Func([b,t.Text,l],[],[]),delete_proposal_assets:t.Func([N],[],[]),deposit_cycles:t.Func([O],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(A)],["query"]),get_auth_config:t.Func([],[t.Opt(E)],["query"]),get_config:t.Func([],[ie],[]),get_db_config:t.Func([],[t.Opt(G)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(w)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(A)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(w)))],["query"]),get_proposal:t.Func([t.Nat],[t.Opt(V)],["query"]),get_rule:t.Func([b,t.Text],[t.Opt(D)],["query"]),get_storage_config:t.Func([],[Q],["query"]),http_request:t.Func([F],[re],["query"]),http_request_streaming_callback:t.Func([p],[le],["query"]),init_asset_upload:t.Func([X],[u],[]),init_proposal:t.Func([B],[t.Nat,V],[]),init_proposal_asset_upload:t.Func([X,t.Nat],[u],[]),list_assets:t.Func([t.Text,c],[y],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,h))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,_))],["query"]),list_docs:t.Func([t.Text,c],[U],["query"]),list_proposals:t.Func([H],[C],["query"]),list_rules:t.Func([b,j],[Z],["query"]),memory_size:t.Func([],[te],["query"]),reject_proposal:t.Func([r],[t.Null],[]),set_auth_config:t.Func([E],[],[]),set_controllers:t.Func([me],[t.Vec(t.Tuple(t.Principal,h))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([G],[],[]),set_doc:t.Func([t.Text,t.Text,Re],[w],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,Re))],[t.Vec(t.Tuple(t.Text,w))],[]),set_rule:t.Func([b,t.Text,Me],[D],[]),set_storage_config:t.Func([Q],[],[]),submit_proposal:t.Func([t.Nat],[t.Nat,V],[]),upload_asset_chunk:t.Func([ye],[he],[]),upload_proposal_asset_chunk:t.Func([ye],[he],[])})};var wc=Je(gt(),1);var n_=({satelliteId:t,container:e})=>{let{satelliteId:r}=Wf({satelliteId:t}),{container:n}=zf({container:e});if((0,wc.nonNullish)(n)&&n!==!1){let{host:i,protocol:s}=new URL(n===!0?zi:n);return`${s}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},Wf=({satelliteId:t})=>(0,wc.nonNullish)(t)?{satelliteId:t}:zr.getInstance().get()??{satelliteId:void 0},zf=({container:t})=>(0,wc.nonNullish)(t)?{container:t}:zr.getInstance().get()??{container:void 0};var lt=t=>o_({idlFactory:r_,buildType:"stock",...t}),s_=({idlFactory:t,...e})=>o_({idlFactory:t,buildType:"extended",...e}),o_=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=Wf({satelliteId:t});(0,i_.assertNonNullish)(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=zf({container:e});return await Ji.getInstance().getActor({satelliteId:n,container:i,...r})};var a_=async({collection:t,key:e,satellite:r})=>{let{get_doc:n}=await lt(r),i=(0,vr.fromNullable)(await n(t,e));if(!(0,vr.isNullish)(i))return Qs({doc:i,key:e})},c_=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await lt(e),n=t.map(({collection:o,key:a})=>[o,a]),i=await r(n),s=[];for(let[o,a]of i){let c=(0,vr.fromNullable)(a);s.push((0,vr.nonNullish)(c)?await Qs({key:o,doc:c}):void 0)}return s},u_=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await lt(r),{key:i}=e,s=await Gf(e),o=await n(t,i,s);return await Qs({key:i,doc:o})},l_=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await lt(e),n=[];for(let{collection:o,doc:a}of t){let{key:c}=a;n.push([o,c,await Gf(a)])}let i=await r(n),s=[];for(let[o,a]of i)s.push(await Qs({key:o,doc:a}));return s},f_=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await lt(r),{key:i}=e;return n(t,i,Yf(e))},d_=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await lt(e),n=t.map(({collection:i,doc:s})=>[i,s.key,Yf(s)]);await r(n)},h_=async({collection:t,filter:e,satellite:r})=>{let{del_filtered_docs:n}=await lt(r);return n(t,Mn(e))},p_=async({collection:t,filter:e,satellite:r})=>{let{list_docs:n}=await lt(r),{items:i,items_page:s,items_length:o,matches_length:a,matches_pages:c}=await n(t,Mn(e)),f=[];for(let[d,h]of i){let{data:g,owner:b,description:l,version:N,...O}=h;f.push({key:d,description:(0,vr.fromNullable)(l),owner:b.toText(),data:await Ly({data:g}),version:(0,vr.fromNullable)(N),...O})}return{items:f,items_length:o,items_page:(0,vr.fromNullable)(s),matches_length:a,matches_pages:(0,vr.fromNullable)(c)}},y_=async({collection:t,filter:e,satellite:r})=>{let{count_docs:n}=await lt(r);return n(t,Mn(e))};var __=Je(Qt(),1);var et=t=>t!==void 0?t:Ec()??new __.AnonymousIdentity;var g_=async({satellite:t,...e})=>{let r=et(t?.identity);return await a_({...e,satellite:{...t,identity:r}})},O3=async({satellite:t,...e})=>{let r=et(t?.identity);return await c_({...e,satellite:{...t,identity:r}})},m_=async({satellite:t,...e})=>{let r=et(t?.identity);return await u_({...e,satellite:{...t,identity:r}})},S3=async({satellite:t,...e})=>{let r=et(t?.identity);return await l_({...e,satellite:{...t,identity:r}})},N3=async({satellite:t,...e})=>{let r=et(t?.identity);return await f_({...e,satellite:{...t,identity:r}})},R3=async({satellite:t,...e})=>{let r=et(t?.identity);return await d_({...e,satellite:{...t,identity:r}})},B3=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await h_({...r,filter:e??{},satellite:{...t,identity:n}})},P3=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await p_({...r,filter:e??{},satellite:{...t,identity:n}})},U3=async({satellite:t,filter:e,...r})=>{let n=et(t?.identity);return await y_({...r,filter:e??{},satellite:{...t,identity:n}})};var b_=async t=>{let e=Ec();if((0,Ls.isNullish)(e))throw new gc("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=()=>g_({collection:"#user",key:r}),i=await n();if((0,Ls.nonNullish)(i))return i;try{return await x8({userId:r,provider:t})}catch(s){if(Kf({error:s,type:Qy})){let o=await n();if((0,Ls.nonNullish)(o))return o}throw s}},x8=({userId:t,...e})=>m_({collection:"#user",doc:{key:t,data:e}});var lr,Jf=async t=>{if(lr=lr??await bc(),!(await lr?.isAuthenticated()??!1))return;let r=await b_(t);Yr.getInstance().set(r)},v8=t=>new Promise(async(e,r)=>{if((0,Df.isNullish)(lr)){r(new yc("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let n=t?.provider??new dc({});await lr.login({onSuccess:async()=>{await Jf(n.id),e()},onError:i=>{if(i===w_.ERROR_USER_INTERRUPT){r(new _c(i));return}r(new pc(i))},maxTimeToLive:t?.maxTimeToLive??Hy,allowPinAuthentication:t?.allowPin??$y,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),Zf=async()=>{await lr?.logout(),lr=null,Yr.getInstance().reset(),Ji.getInstance().reset(),Di.getInstance().reset(),lr=await bc()},Ec=()=>lr?.getIdentity(),T8=async()=>(lr??await bc()).getIdentity(),A8=async()=>{let t=Yr.getInstance().get();return(0,Df.isNullish)(t)||!(await lr?.isAuthenticated()??!1)?null:lr?.getIdentity()??null};var x_=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{lf({message:"junoSignOutAuthTimer"}),await Zf()};return r.onmessage=async({data:i})=>{let{msg:s,data:o}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":lf({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},Yr.getInstance().subscribe(i=>{if((0,E_.isNullish)(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var v_=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},T_=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};var t6=async({idlFactory:t,satellite:e})=>{let r=et(e?.identity);return await s_({idlFactory:t,...e,identity:r})};var ro=Je(gt(),1);var to=Je(gt(),1);var eo=Je(gt(),1);var A_=async({asset:{data:t,headers:e,...r},actor:n})=>{let{init_asset_upload:i,upload_asset_chunk:s,commit_asset_upload:o}=n,{batch_id:a}=await i(O8(r)),{chunkIds:c}=await N8({data:t,uploadFn:s,batchId:a});await S8({commitFn:o,batchId:a,data:t,headers:e,chunkIds:c})};var O8=({filename:t,collection:e,token:r,fullPath:n,encoding:i,description:s})=>({collection:e,full_path:n,name:t,token:(0,eo.toNullable)(r),encoding_type:(0,eo.toNullable)(i),description:(0,eo.toNullable)(s)}),S8=async({commitFn:t,batchId:e,chunkIds:r,headers:n,data:i})=>{let s=n.find(([o,a])=>o.toLowerCase()==="content-type")===void 0&&i.type!==void 0&&i.type!==""?[["Content-Type",i.type]]:void 0;await t({batch_id:e,chunk_ids:r.map(({chunk_id:o})=>o),headers:[...n,...s??[]]})},N8=async({data:t,uploadFn:e,batchId:r})=>{let n=[],i=fc()?new Blob([await t.arrayBuffer()]):t,s=0n;for(let a=0;a<i.size;a+=19e5){let c=i.slice(a,a+19e5);n.push({batchId:r,chunk:c,uploadFn:e,orderId:s}),s++}let o=[];for await(let a of R8({uploadChunks:n}))o=[...o,...a];return{chunkIds:o}};async function*R8({uploadChunks:t,limit:e=12}){for(let r=0;r<t.length;r=r+e){let n=t.slice(r,r+e);yield await Promise.all(n.map(i=>B8(i)))}}var B8=async({batchId:t,chunk:e,uploadFn:r,orderId:n})=>r({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:(0,eo.toNullable)(n)});var O_=async({satellite:t,...e})=>{let r=await lt(t);await A_({actor:r,asset:e})},S_=async({collection:t,satellite:e,filter:r})=>{let{list_assets:n}=await lt(e),{items:i,items_length:s,items_page:o,matches_length:a,matches_pages:c}=await n(t,Mn(r));return{items:i.map(([f,d])=>d),items_length:s,items_page:(0,to.fromNullable)(o),matches_length:a,matches_pages:(0,to.fromNullable)(c)}},N_=async({collection:t,satellite:e,filter:r})=>{let{count_assets:n}=await lt(e);return n(t,Mn(r))},R_=async({collection:t,fullPath:e,satellite:r})=>(await lt(r)).del_asset(t,e),B_=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await lt(e),n=t.map(({collection:i,fullPath:s})=>[i,s]);await r(n)},P_=async({collection:t,satellite:e,filter:r})=>{let{del_filtered_assets:n}=await lt(e);return n(t,Mn(r))},U_=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await lt(r);return(0,to.fromNullable)(await n(t,e))},I_=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await lt(e),n=t.map(({collection:s,fullPath:o})=>[s,o]);return(await r(n)).map(([s,o])=>(0,to.fromNullable)(o))};var C_=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var p6=t=>F_(t),y6=t=>F_({filename:t.data.name,...t}),F_=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:s,satellite:o,encoding:a,description:c})=>{let f=et(o?.identity),d=decodeURI(t),h=i??`/${r}/${d}`,g={...o,identity:f};return await O_({data:e,filename:d,collection:r,token:s,headers:n,fullPath:h,encoding:a,satellite:g,description:c}),{downloadUrl:M_({satellite:g,assetKey:{fullPath:h,token:s}}),fullPath:h,name:d}},_6=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)},{items:i,...s}=await S_({collection:t,satellite:n,filter:r??{}}),o=i.map(({key:{full_path:a,token:c,name:f,owner:d,description:h},headers:g,encodings:b,created_at:l,updated_at:N})=>{let O=(0,ro.fromNullable)(c);return{fullPath:a,description:(0,ro.fromNullable)(h),name:f,downloadUrl:M_({satellite:n,assetKey:{fullPath:a,token:O}}),token:O,headers:g,encodings:b.reduce((I,[M,{modified:A,sha256:K,total_length:E}])=>({...I,[M]:{modified:A,sha256:C_(K),total_length:E}}),{}),owner:d.toText(),created_at:l,updated_at:N}});return{items:o,assets:o,...s}},g6=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await N_({collection:t,satellite:n,filter:r??{}})},m6=({collection:t,fullPath:e,satellite:r})=>R_({collection:t,fullPath:e,satellite:{...r,identity:et(r?.identity)}}),b6=({assets:t,satellite:e})=>B_({assets:t,satellite:{...e,identity:et(e?.identity)}}),w6=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:et(e?.identity)};return await P_({collection:t,satellite:n,filter:r??{}})},E6=async({satellite:t,...e})=>{let r=et(t?.identity);return await U_({...e,satellite:{...t,identity:r}})},x6=async({satellite:t,...e})=>{let r=et(t?.identity);return await I_({...e,satellite:{...t,identity:r}})},M_=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:et(r?.identity)};return`${n_(n)}${t}${(0,ro.nonNullish)(e)?`?token=${e}`:""}`};var P8=t=>{let e=t?.satelliteId??v_();(0,q_.assertNonNullish)(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??T_();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},R6=t=>U8(t),U8=async t=>{let e=P8(t);zr.getInstance().set(e),await Jf();let r=e.workers?.auth!==void 0?x_(e.workers.auth):void 0;return[...r?[r]:[]]},B6=t=>Yr.getInstance().subscribe(t);export{gc as InitError,dc as InternetIdentityProvider,mc as ListError,Dy as NFIDProvider,pc as SignInError,yc as SignInInitError,_c as SignInUserInterruptError,B6 as authSubscribe,g6 as countAssets,U3 as countDocs,m6 as deleteAsset,N3 as deleteDoc,w6 as deleteFilteredAssets,B3 as deleteFilteredDocs,b6 as deleteManyAssets,R3 as deleteManyDocs,M_ as downloadUrl,E6 as getAsset,g_ as getDoc,A8 as getIdentityOnce,x6 as getManyAssets,O3 as getManyDocs,t6 as getSatelliteExtendedActor,R6 as initJuno,U8 as initSatellite,_6 as listAssets,P3 as listDocs,m_ as setDoc,S3 as setManyDocs,v8 as signIn,Zf as signOut,T8 as unsafeIdentity,p6 as uploadBlob,y6 as uploadFile};
|
|
58
58
|
/*! Bundled license information:
|
|
59
59
|
|
|
60
60
|
ieee754/index.js:
|