@junobuild/core-peer 0.0.27 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,22 @@
1
- "use strict";(()=>{var xu=Object.create;var li=Object.defineProperty;var _u=Object.getOwnPropertyDescriptor;var bu=Object.getOwnPropertyNames;var Eu=Object.getPrototypeOf,Au=Object.prototype.hasOwnProperty;var ct=(r,t)=>()=>(r&&(t=r(r=0)),t);var Bt=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),vu=(r,t)=>{for(var e in t)li(r,e,{get:t[e],enumerable:!0})},Tu=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of bu(t))!Au.call(r,i)&&i!==e&&li(r,i,{get:()=>t[i],enumerable:!(n=_u(t,i))||n.enumerable});return r};var Te=(r,t,e)=>(e=r!=null?xu(Eu(r)):{},Tu(t||!r||!r.__esModule?li(e,"default",{value:r,enumerable:!0}):e,r));var di=Bt(nn=>{"use strict";nn.byteLength=Bu;nn.toByteArray=Nu;nn.fromByteArray=Fu;var fe=[],Qt=[],Su=typeof Uint8Array<"u"?Uint8Array:Array,hi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ve=0,so=hi.length;Ve<so;++Ve)fe[Ve]=hi[Ve],Qt[hi.charCodeAt(Ve)]=Ve;var Ve,so;Qt[45]=62;Qt[95]=63;function oo(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");e===-1&&(e=t);var n=e===t?0:4-e%4;return[e,n]}function Bu(r){var t=oo(r),e=t[0],n=t[1];return(e+n)*3/4-n}function Iu(r,t,e){return(t+e)*3/4-e}function Nu(r){var t,e=oo(r),n=e[0],i=e[1],s=new Su(Iu(r,n,i)),o=0,c=i>0?n-4:n,u;for(u=0;u<c;u+=4)t=Qt[r.charCodeAt(u)]<<18|Qt[r.charCodeAt(u+1)]<<12|Qt[r.charCodeAt(u+2)]<<6|Qt[r.charCodeAt(u+3)],s[o++]=t>>16&255,s[o++]=t>>8&255,s[o++]=t&255;return i===2&&(t=Qt[r.charCodeAt(u)]<<2|Qt[r.charCodeAt(u+1)]>>4,s[o++]=t&255),i===1&&(t=Qt[r.charCodeAt(u)]<<10|Qt[r.charCodeAt(u+1)]<<4|Qt[r.charCodeAt(u+2)]>>2,s[o++]=t>>8&255,s[o++]=t&255),s}function Uu(r){return fe[r>>18&63]+fe[r>>12&63]+fe[r>>6&63]+fe[r&63]}function Ru(r,t,e){for(var n,i=[],s=t;s<e;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),i.push(Uu(n));return i.join("")}function Fu(r){for(var t,e=r.length,n=e%3,i=[],s=16383,o=0,c=e-n;o<c;o+=s)i.push(Ru(r,o,o+s>c?c:o+s));return n===1?(t=r[e-1],i.push(fe[t>>2]+fe[t<<4&63]+"==")):n===2&&(t=(r[e-2]<<8)+r[e-1],i.push(fe[t>>10]+fe[t>>4&63]+fe[t<<2&63]+"=")),i.join("")}});var sn=Bt(pi=>{pi.read=function(r,t,e,n,i){var s,o,c=i*8-n-1,u=(1<<c)-1,w=u>>1,y=-7,m=e?i-1:0,N=e?-1:1,M=r[t+m];for(m+=N,s=M&(1<<-y)-1,M>>=-y,y+=c;y>0;s=s*256+r[t+m],m+=N,y-=8);for(o=s&(1<<-y)-1,s>>=-y,y+=n;y>0;o=o*256+r[t+m],m+=N,y-=8);if(s===0)s=1-w;else{if(s===u)return o?NaN:(M?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-w}return(M?-1:1)*o*Math.pow(2,s-n)};pi.write=function(r,t,e,n,i,s){var o,c,u,w=s*8-i-1,y=(1<<w)-1,m=y>>1,N=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,M=n?0:s-1,O=n?1:-1,G=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,o=y):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+m>=1?t+=N/u:t+=N*Math.pow(2,1-m),t*u>=2&&(o++,u/=2),o+m>=y?(c=0,o=y):o+m>=1?(c=(t*u-1)*Math.pow(2,i),o=o+m):(c=t*Math.pow(2,m-1)*Math.pow(2,i),o=0));i>=8;r[e+M]=c&255,M+=O,c/=256,i-=8);for(o=o<<i|c,w+=i;w>0;r[e+M]=o&255,M+=O,o/=256,w-=8);r[e+M-O]|=G*128}});var vo=Bt(er=>{"use strict";var yi=di(),Qe=sn(),ao=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;er.Buffer=T;er.SlowBuffer=$u;er.INSPECT_MAX_BYTES=50;var on=2147483647;er.kMaxLength=on;T.TYPED_ARRAY_SUPPORT=Ou();!T.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 Ou(){try{let r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch{return!1}}Object.defineProperty(T.prototype,"parent",{enumerable:!0,get:function(){if(T.isBuffer(this))return this.buffer}});Object.defineProperty(T.prototype,"offset",{enumerable:!0,get:function(){if(T.isBuffer(this))return this.byteOffset}});function xe(r){if(r>on)throw new RangeError('The value "'+r+'" is invalid for option "size"');let t=new Uint8Array(r);return Object.setPrototypeOf(t,T.prototype),t}function T(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return xi(r)}return lo(r,t,e)}T.poolSize=8192;function lo(r,t,e){if(typeof r=="string")return ku(r,t);if(ArrayBuffer.isView(r))return Mu(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(le(r,ArrayBuffer)||r&&le(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(le(r,SharedArrayBuffer)||r&&le(r.buffer,SharedArrayBuffer)))return gi(r,t,e);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return T.from(n,t,e);let i=Cu(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return T.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}T.from=function(r,t,e){return lo(r,t,e)};Object.setPrototypeOf(T.prototype,Uint8Array.prototype);Object.setPrototypeOf(T,Uint8Array);function ho(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function Pu(r,t,e){return ho(r),r<=0?xe(r):t!==void 0?typeof e=="string"?xe(r).fill(t,e):xe(r).fill(t):xe(r)}T.alloc=function(r,t,e){return Pu(r,t,e)};function xi(r){return ho(r),xe(r<0?0:_i(r)|0)}T.allocUnsafe=function(r){return xi(r)};T.allocUnsafeSlow=function(r){return xi(r)};function ku(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!T.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=po(r,t)|0,n=xe(e),i=n.write(r,t);return i!==e&&(n=n.slice(0,i)),n}function wi(r){let t=r.length<0?0:_i(r.length)|0,e=xe(t);for(let n=0;n<t;n+=1)e[n]=r[n]&255;return e}function Mu(r){if(le(r,Uint8Array)){let t=new Uint8Array(r);return gi(t.buffer,t.byteOffset,t.byteLength)}return wi(r)}function gi(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&e===void 0?n=new Uint8Array(r):e===void 0?n=new Uint8Array(r,t):n=new Uint8Array(r,t,e),Object.setPrototypeOf(n,T.prototype),n}function Cu(r){if(T.isBuffer(r)){let t=_i(r.length)|0,e=xe(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||Ei(r.length)?xe(0):wi(r);if(r.type==="Buffer"&&Array.isArray(r.data))return wi(r.data)}function _i(r){if(r>=on)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+on.toString(16)+" bytes");return r|0}function $u(r){return+r!=r&&(r=0),T.alloc(+r)}T.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==T.prototype};T.compare=function(t,e){if(le(t,Uint8Array)&&(t=T.from(t,t.offset,t.byteLength)),le(e,Uint8Array)&&(e=T.from(e,e.offset,e.byteLength)),!T.isBuffer(t)||!T.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,i=e.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(t[s]!==e[s]){n=t[s],i=e[s];break}return n<i?-1:i<n?1:0};T.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};T.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return T.alloc(0);let n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;let i=T.allocUnsafe(e),s=0;for(n=0;n<t.length;++n){let o=t[n];if(le(o,Uint8Array))s+o.length>i.length?(T.isBuffer(o)||(o=T.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(T.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function po(r,t){if(T.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||le(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let e=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&e===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return mi(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Ao(r).length;default:if(i)return n?-1:mi(r).length;t=(""+t).toLowerCase(),i=!0}}T.byteLength=po;function Vu(r,t,e){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return Yu(this,t,e);case"utf8":case"utf-8":return wo(this,t,e);case"ascii":return Wu(this,t,e);case"latin1":case"binary":return zu(this,t,e);case"base64":return Du(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Xu(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}T.prototype._isBuffer=!0;function Le(r,t,e){let n=r[t];r[t]=r[e],r[e]=n}T.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)Le(this,e,e+1);return this};T.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)Le(this,e,e+3),Le(this,e+1,e+2);return this};T.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)Le(this,e,e+7),Le(this,e+1,e+6),Le(this,e+2,e+5),Le(this,e+3,e+4);return this};T.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?wo(this,0,t):Vu.apply(this,arguments)};T.prototype.toLocaleString=T.prototype.toString;T.prototype.equals=function(t){if(!T.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:T.compare(this,t)===0};T.prototype.inspect=function(){let t="",e=er.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};ao&&(T.prototype[ao]=T.prototype.inspect);T.prototype.compare=function(t,e,n,i,s){if(le(t,Uint8Array)&&(t=T.from(t,t.offset,t.byteLength)),!T.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),e<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&e>=n)return 0;if(i>=s)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;let o=s-i,c=n-e,u=Math.min(o,c),w=this.slice(i,s),y=t.slice(e,n);for(let m=0;m<u;++m)if(w[m]!==y[m]){o=w[m],c=y[m];break}return o<c?-1:c<o?1:0};function yo(r,t,e,n,i){if(r.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Ei(e)&&(e=i?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(i)return-1;e=r.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=T.from(t,n)),T.isBuffer(t))return t.length===0?-1:co(r,t,e,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):co(r,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function co(r,t,e,n,i){let s=1,o=r.length,c=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;s=2,o/=2,c/=2,e/=2}function u(y,m){return s===1?y[m]:y.readUInt16BE(m*s)}let w;if(i){let y=-1;for(w=e;w<o;w++)if(u(r,w)===u(t,y===-1?0:w-y)){if(y===-1&&(y=w),w-y+1===c)return y*s}else y!==-1&&(w-=w-y),y=-1}else for(e+c>o&&(e=o-c),w=e;w>=0;w--){let y=!0;for(let m=0;m<c;m++)if(u(r,w+m)!==u(t,m)){y=!1;break}if(y)return w}return-1}T.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1};T.prototype.indexOf=function(t,e,n){return yo(this,t,e,n,!0)};T.prototype.lastIndexOf=function(t,e,n){return yo(this,t,e,n,!1)};function Lu(r,t,e,n){e=Number(e)||0;let i=r.length-e;n?(n=Number(n),n>i&&(n=i)):n=i;let s=t.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let c=parseInt(t.substr(o*2,2),16);if(Ei(c))return o;r[e+o]=c}return o}function qu(r,t,e,n){return an(mi(t,r.length-e),r,e,n)}function Hu(r,t,e,n){return an(tf(t),r,e,n)}function Gu(r,t,e,n){return an(Ao(t),r,e,n)}function Ku(r,t,e,n){return an(ef(t,r.length-e),r,e,n)}T.prototype.write=function(t,e,n,i){if(e===void 0)i="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")i=e,n=this.length,e=0;else if(isFinite(e))e=e>>>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-e;if((n===void 0||n>s)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return Lu(this,t,e,n);case"utf8":case"utf-8":return qu(this,t,e,n);case"ascii":case"latin1":case"binary":return Hu(this,t,e,n);case"base64":return Gu(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ku(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};T.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Du(r,t,e){return t===0&&e===r.length?yi.fromByteArray(r):yi.fromByteArray(r.slice(t,e))}function wo(r,t,e){e=Math.min(r.length,e);let n=[],i=t;for(;i<e;){let s=r[i],o=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=e){let u,w,y,m;switch(c){case 1:s<128&&(o=s);break;case 2:u=r[i+1],(u&192)===128&&(m=(s&31)<<6|u&63,m>127&&(o=m));break;case 3:u=r[i+1],w=r[i+2],(u&192)===128&&(w&192)===128&&(m=(s&15)<<12|(u&63)<<6|w&63,m>2047&&(m<55296||m>57343)&&(o=m));break;case 4:u=r[i+1],w=r[i+2],y=r[i+3],(u&192)===128&&(w&192)===128&&(y&192)===128&&(m=(s&15)<<18|(u&63)<<12|(w&63)<<6|y&63,m>65535&&m<1114112&&(o=m))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=c}return ju(n)}var uo=4096;function ju(r){let t=r.length;if(t<=uo)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=uo));return e}function Wu(r,t,e){let n="";e=Math.min(r.length,e);for(let i=t;i<e;++i)n+=String.fromCharCode(r[i]&127);return n}function zu(r,t,e){let n="";e=Math.min(r.length,e);for(let i=t;i<e;++i)n+=String.fromCharCode(r[i]);return n}function Yu(r,t,e){let n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);let i="";for(let s=t;s<e;++s)i+=rf[r[s]];return i}function Xu(r,t,e){let n=r.slice(t,e),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}T.prototype.slice=function(t,e){let n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);let i=this.subarray(t,e);return Object.setPrototypeOf(i,T.prototype),i};function kt(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}T.prototype.readUintLE=T.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||kt(t,e,this.length);let i=this[t],s=1,o=0;for(;++o<e&&(s*=256);)i+=this[t+o]*s;return i};T.prototype.readUintBE=T.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||kt(t,e,this.length);let i=this[t+--e],s=1;for(;e>0&&(s*=256);)i+=this[t+--e]*s;return i};T.prototype.readUint8=T.prototype.readUInt8=function(t,e){return t=t>>>0,e||kt(t,1,this.length),this[t]};T.prototype.readUint16LE=T.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||kt(t,2,this.length),this[t]|this[t+1]<<8};T.prototype.readUint16BE=T.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||kt(t,2,this.length),this[t]<<8|this[t+1]};T.prototype.readUint32LE=T.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};T.prototype.readUint32BE=T.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};T.prototype.readBigUInt64LE=Se(function(t){t=t>>>0,tr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Ir(t,this.length-8);let i=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,s=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});T.prototype.readBigUInt64BE=Se(function(t){t=t>>>0,tr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Ir(t,this.length-8);let i=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],s=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});T.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||kt(t,e,this.length);let i=this[t],s=1,o=0;for(;++o<e&&(s*=256);)i+=this[t+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*e)),i};T.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||kt(t,e,this.length);let i=e,s=1,o=this[t+--i];for(;i>0&&(s*=256);)o+=this[t+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*e)),o};T.prototype.readInt8=function(t,e){return t=t>>>0,e||kt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};T.prototype.readInt16LE=function(t,e){t=t>>>0,e||kt(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};T.prototype.readInt16BE=function(t,e){t=t>>>0,e||kt(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};T.prototype.readInt32LE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};T.prototype.readInt32BE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};T.prototype.readBigInt64LE=Se(function(t){t=t>>>0,tr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Ir(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});T.prototype.readBigInt64BE=Se(function(t){t=t>>>0,tr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Ir(t,this.length-8);let i=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});T.prototype.readFloatLE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),Qe.read(this,t,!0,23,4)};T.prototype.readFloatBE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),Qe.read(this,t,!1,23,4)};T.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||kt(t,8,this.length),Qe.read(this,t,!0,52,8)};T.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||kt(t,8,this.length),Qe.read(this,t,!1,52,8)};function qt(r,t,e,n,i,s){if(!T.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}T.prototype.writeUintLE=T.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;qt(this,t,e,n,c,0)}let s=1,o=0;for(this[e]=t&255;++o<n&&(s*=256);)this[e+o]=t/s&255;return e+n};T.prototype.writeUintBE=T.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;qt(this,t,e,n,c,0)}let s=n-1,o=1;for(this[e+s]=t&255;--s>=0&&(o*=256);)this[e+s]=t/o&255;return e+n};T.prototype.writeUint8=T.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,1,255,0),this[e]=t&255,e+1};T.prototype.writeUint16LE=T.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};T.prototype.writeUint16BE=T.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};T.prototype.writeUint32LE=T.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4};T.prototype.writeUint32BE=T.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function go(r,t,e,n,i){Eo(t,n,i,r,e,7);let s=Number(t&BigInt(4294967295));r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return r[e++]=o,o=o>>8,r[e++]=o,o=o>>8,r[e++]=o,o=o>>8,r[e++]=o,e}function mo(r,t,e,n,i){Eo(t,n,i,r,e,7);let s=Number(t&BigInt(4294967295));r[e+7]=s,s=s>>8,r[e+6]=s,s=s>>8,r[e+5]=s,s=s>>8,r[e+4]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return r[e+3]=o,o=o>>8,r[e+2]=o,o=o>>8,r[e+1]=o,o=o>>8,r[e]=o,e+8}T.prototype.writeBigUInt64LE=Se(function(t,e=0){return go(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});T.prototype.writeBigUInt64BE=Se(function(t,e=0){return mo(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});T.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){let u=Math.pow(2,8*n-1);qt(this,t,e,n,u-1,-u)}let s=0,o=1,c=0;for(this[e]=t&255;++s<n&&(o*=256);)t<0&&c===0&&this[e+s-1]!==0&&(c=1),this[e+s]=(t/o>>0)-c&255;return e+n};T.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){let u=Math.pow(2,8*n-1);qt(this,t,e,n,u-1,-u)}let s=n-1,o=1,c=0;for(this[e+s]=t&255;--s>=0&&(o*=256);)t<0&&c===0&&this[e+s+1]!==0&&(c=1),this[e+s]=(t/o>>0)-c&255;return e+n};T.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};T.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};T.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};T.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4};T.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||qt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};T.prototype.writeBigInt64LE=Se(function(t,e=0){return go(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});T.prototype.writeBigInt64BE=Se(function(t,e=0){return mo(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function xo(r,t,e,n,i,s){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function _o(r,t,e,n,i){return t=+t,e=e>>>0,i||xo(r,t,e,4,34028234663852886e22,-34028234663852886e22),Qe.write(r,t,e,n,23,4),e+4}T.prototype.writeFloatLE=function(t,e,n){return _o(this,t,e,!0,n)};T.prototype.writeFloatBE=function(t,e,n){return _o(this,t,e,!1,n)};function bo(r,t,e,n,i){return t=+t,e=e>>>0,i||xo(r,t,e,8,17976931348623157e292,-17976931348623157e292),Qe.write(r,t,e,n,52,8),e+8}T.prototype.writeDoubleLE=function(t,e,n){return bo(this,t,e,!0,n)};T.prototype.writeDoubleBE=function(t,e,n){return bo(this,t,e,!1,n)};T.prototype.copy=function(t,e,n,i){if(!T.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);let s=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),e),s};T.prototype.fill=function(t,e,n,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=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"&&!T.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let o=t.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(t=o)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let s;if(typeof t=="number")for(s=e;s<n;++s)this[s]=t;else{let o=T.isBuffer(t)?t:T.from(t,i),c=o.length;if(c===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-e;++s)this[s+e]=o[s%c]}return this};var Ze={};function bi(r,t,e){Ze[r]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}bi("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);bi("ERR_INVALID_ARG_TYPE",function(r,t){return`The "${r}" argument must be of type number. Received type ${typeof t}`},TypeError);bi("ERR_OUT_OF_RANGE",function(r,t,e){let n=`The value of "${r}" is out of range.`,i=e;return Number.isInteger(e)&&Math.abs(e)>2**32?i=fo(String(e)):typeof e=="bigint"&&(i=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(i=fo(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function fo(r){let t="",e=r.length,n=r[0]==="-"?1:0;for(;e>=n+4;e-=3)t=`_${r.slice(e-3,e)}${t}`;return`${r.slice(0,e)}${t}`}function Ju(r,t,e){tr(t,"offset"),(r[t]===void 0||r[t+e]===void 0)&&Ir(t,r.length-(e+1))}function Eo(r,t,e,n,i,s){if(r>e||r<t){let o=typeof t=="bigint"?"n":"",c;throw s>3?t===0||t===BigInt(0)?c=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:c=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:c=`>= ${t}${o} and <= ${e}${o}`,new Ze.ERR_OUT_OF_RANGE("value",c,r)}Ju(n,i,s)}function tr(r,t){if(typeof r!="number")throw new Ze.ERR_INVALID_ARG_TYPE(t,"number",r)}function Ir(r,t,e){throw Math.floor(r)!==r?(tr(r,e),new Ze.ERR_OUT_OF_RANGE(e||"offset","an integer",r)):t<0?new Ze.ERR_BUFFER_OUT_OF_BOUNDS:new Ze.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,r)}var Zu=/[^+/0-9A-Za-z-_]/g;function Qu(r){if(r=r.split("=")[0],r=r.trim().replace(Zu,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function mi(r,t){t=t||1/0;let e,n=r.length,i=null,s=[];for(let o=0;o<n;++o){if(e=r.charCodeAt(o),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&s.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;s.push(e)}else if(e<2048){if((t-=2)<0)break;s.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;s.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;s.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return s}function tf(r){let t=[];for(let e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function ef(r,t){let e,n,i,s=[];for(let o=0;o<r.length&&!((t-=2)<0);++o)e=r.charCodeAt(o),n=e>>8,i=e%256,s.push(i),s.push(n);return s}function Ao(r){return yi.toByteArray(Qu(r))}function an(r,t,e,n){let i;for(i=0;i<n&&!(i+e>=t.length||i>=r.length);++i)t[i+e]=r[i];return i}function le(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function Ei(r){return r!==r}var rf=function(){let r="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){let n=e*16;for(let i=0;i<16;++i)t[n+i]=r[e]+r[i]}return t}();function Se(r){return typeof BigInt>"u"?nf:r}function nf(){throw new Error("BigInt not supported")}});function To(r){let t=0,e=0,n="";function i(s){return t<0?e|=s>>-t:e=s<<t&248,t>3?(t-=8,1):(t<4&&(n+=cn[e>>3],t+=5),0)}for(let s=0;s<r.length;)s+=i(r[s]);return n+(t<0?cn[e>>3]:"")}function So(r){let t=0,e=0,n=new Uint8Array(r.length*4/3|0),i=0;function s(o){let c=rr[o.toLowerCase()];if(c===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);c<<=3,e|=c>>>t,t+=5,t>=8&&(n[i++]=e,t-=8,t>0?e=c<<5-t&255:e=0)}for(let o of r)s(o);return n.slice(0,i)}var cn,rr,Bo=ct(()=>{cn="abcdefghijklmnopqrstuvwxyz234567",rr=Object.create(null);for(let r=0;r<cn.length;r++)rr[cn[r]]=r;rr[0]=rr.o;rr[1]=rr.i});function Io(r){let t=new Uint8Array(r),e=-1;for(let n=0;n<t.length;n++){let s=(t[n]^e)&255;e=sf[s]^e>>>8}return(e^-1)>>>0}var sf,No=ct(()=>{sf=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 of(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function vi(r,...t){if(!of(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function Ti(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Uo(r,t){vi(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var Si=ct(()=>{});var un,Ro=ct(()=>{un=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});function Fo(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Bi(r){return typeof r=="string"&&(r=Fo(r)),vi(r),r}function Nr(r){let t=n=>r().update(Bi(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Oo(r=32){if(un&&typeof un.getRandomValues=="function")return un.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}var ln,ne,cd,fn,ud,Ur=ct(()=>{Ro();Si();ln=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),ne=(r,t)=>r<<32-t|r>>>t,cd=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;fn=class{clone(){return this._cloneInto()}},ud={}.toString});function af(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(e>>i&s),c=Number(e&s),u=n?4:0,w=n?0:4;r.setUint32(t+u,o,n),r.setUint32(t+w,c,n)}var Po,ko,nr,Ii=ct(()=>{Si();Ur();Po=(r,t,e)=>r&t^~r&e,ko=(r,t,e)=>r&t^r&e^t&e,nr=class extends fn{constructor(t,e,n,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ln(this.buffer)}update(t){Ti(this);let{view:e,buffer:n,blockLen:i}=this;t=Bi(t);let s=t.length;for(let o=0;o<s;){let c=Math.min(i-this.pos,s-o);if(c===i){let u=ln(t);for(;i<=s-o;o+=i)this.process(u,o);continue}n.set(t.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ti(this),Uo(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let m=o;m<i;m++)e[m]=0;af(n,i-8,BigInt(this.length*8),s),this.process(n,0);let c=ln(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let w=u/4,y=this.get();if(w>y.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<w;m++)c.setUint32(4*m,y[m],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:i,finished:s,destroyed:o,pos:c}=this;return t.length=i,t.pos=c,t.finished=s,t.destroyed=o,i%e&&t.buffer.set(n),t}}});var cf,Be,Ie,hn,Ni,Mo,Co,Ui=ct(()=>{Ii();Ur();cf=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]),Be=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ie=new Uint32Array(64),hn=class extends nr{constructor(){super(64,32,8,!1),this.A=Be[0]|0,this.B=Be[1]|0,this.C=Be[2]|0,this.D=Be[3]|0,this.E=Be[4]|0,this.F=Be[5]|0,this.G=Be[6]|0,this.H=Be[7]|0}get(){let{A:t,B:e,C:n,D:i,E:s,F:o,G:c,H:u}=this;return[t,e,n,i,s,o,c,u]}set(t,e,n,i,s,o,c,u){this.A=t|0,this.B=e|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=c|0,this.H=u|0}process(t,e){for(let m=0;m<16;m++,e+=4)Ie[m]=t.getUint32(e,!1);for(let m=16;m<64;m++){let N=Ie[m-15],M=Ie[m-2],O=ne(N,7)^ne(N,18)^N>>>3,G=ne(M,17)^ne(M,19)^M>>>10;Ie[m]=G+Ie[m-7]+O+Ie[m-16]|0}let{A:n,B:i,C:s,D:o,E:c,F:u,G:w,H:y}=this;for(let m=0;m<64;m++){let N=ne(c,6)^ne(c,11)^ne(c,25),M=y+N+Po(c,u,w)+cf[m]+Ie[m]|0,G=(ne(n,2)^ne(n,13)^ne(n,22))+ko(n,i,s)|0;y=w,w=u,u=c,c=o+M|0,o=s,s=i,i=n,n=M+G|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,c=c+this.E|0,u=u+this.F|0,w=w+this.G|0,y=y+this.H|0,this.set(n,i,s,o,c,u,w,y)}roundClean(){Ie.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Ni=class extends hn{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}},Mo=Nr(()=>new hn),Co=Nr(()=>new Ni)});function $o(r){return Co.create().update(new Uint8Array(r)).digest()}var Vo=ct(()=>{Ui()});var dn,uf,Lo,ff,lf,hf,It,te=ct(()=>{Bo();No();Vo();dn="__principal__",uf=2,Lo=4,ff="aaaaa-aa",lf=r=>{var t;return new Uint8Array(((t=r.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(e=>parseInt(e,16)))},hf=r=>r.reduce((t,e)=>t+e.toString(16).padStart(2,"0"),""),It=class r{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Lo]))}static managementCanister(){return this.fromHex(ff)}static selfAuthenticating(t){let e=$o(t);return new this(new Uint8Array([...e,uf]))}static from(t){if(typeof t=="string")return r.fromText(t);if(Object.getPrototypeOf(t)===Uint8Array.prototype)return new r(t);if(typeof t=="object"&&t!==null&&t._isPrincipal===!0)return new r(t._arr);throw new Error(`Impossible to convert ${JSON.stringify(t)} to Principal.`)}static fromHex(t){return new this(lf(t))}static fromText(t){let e=t;if(t.includes(dn)){let o=JSON.parse(t);dn in o&&(e=o[dn])}let n=e.toLowerCase().replace(/-/g,""),i=So(n);i=i.slice(4,i.length);let s=new this(i);if(s.toText()!==e)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${e}" may not be a valid Principal ID).`);return s}static fromUint8Array(t){return new this(t)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===Lo}toUint8Array(){return this._arr}toHex(){return hf(this._arr).toUpperCase()}toText(){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,Io(this._arr));let n=new Uint8Array(t),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),c=To(s).match(/.{1,5}/g);if(!c)throw new Error;return c.join("-")}toString(){return this.toText()}toJSON(){return{[dn]:this.toText()}}compareTo(t){for(let e=0;e<Math.min(this._arr.length,t._arr.length);e++){if(this._arr[e]<t._arr[e])return"lt";if(this._arr[e]>t._arr[e])return"gt"}return this._arr.length<t._arr.length?"lt":this._arr.length>t._arr.length?"gt":"eq"}ltEq(t){let e=this.compareTo(t);return e=="lt"||e=="eq"}gtEq(t){let e=this.compareTo(t);return e=="gt"||e=="eq"}}});var ee,ir=ct(()=>{ee=class r extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,r.prototype)}}});function Fi(...r){let t=new Uint8Array(r.reduce((n,i)=>n+i.byteLength,0)),e=0;for(let n of r)t.set(new Uint8Array(n),e),e+=n.byteLength;return t}function Ri(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}function pn(r){return r instanceof Uint8Array?Ri(r):r instanceof ArrayBuffer?r:Array.isArray(r)?Ri(new Uint8Array(r)):"buffer"in r?pn(r.buffer):Ri(new Uint8Array(r))}var Ne,yn=ct(()=>{Ne=class{constructor(t,e=t?.byteLength||0){this._buffer=pn(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,e)}get buffer(){return pn(this._view.slice())}get byteLength(){return this._view.byteLength}read(t){let e=this._view.subarray(0,t);return this._view=this._view.subarray(t),e.slice().buffer}readUint8(){let t=this._view[0];return this._view=this._view.subarray(1),t}write(t){let e=new Uint8Array(t),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+e.byteLength>=this._buffer.byteLength?this.alloc(e.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+e.byteLength),this._view.set(e,n)}get end(){return this._view.byteLength===0}alloc(t){let e=new ArrayBuffer((this._buffer.byteLength+t)*1.2|0),n=new Uint8Array(e,0,this._view.byteLength+t);n.set(this._view),this._buffer=e,this._view=n}}});var Oi=ct(()=>{});function qo(){throw new Error("unexpected end of buffer")}function Rr(r,t){return r.byteLength<t&&qo(),r.read(t)}function sr(r){let t=r.readUint8();return t===void 0&&qo(),t}function Ue(r){if(typeof r=="number"&&(r=BigInt(r)),r<BigInt(0))throw new Error("Cannot leb encode negative values.");let t=(r===BigInt(0)?0:Math.ceil(Math.log2(Number(r))))+1,e=new Ne(new ArrayBuffer(t),0);for(;;){let n=Number(r&BigInt(127));if(r/=BigInt(128),r===BigInt(0)){e.write(new Uint8Array([n]));break}else e.write(new Uint8Array([n|128]))}return e.buffer}function or(r){let t=BigInt(1),e=BigInt(0),n;do n=sr(r),e+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return e}function jt(r){typeof r=="number"&&(r=BigInt(r));let t=r<BigInt(0);t&&(r=-r-BigInt(1));let e=(r===BigInt(0)?0:Math.ceil(Math.log2(Number(r))))+1,n=new Ne(new ArrayBuffer(e),0);for(;;){let s=i(r);if(r/=BigInt(128),t&&r===BigInt(0)&&s&64||!t&&r===BigInt(0)&&!(s&64)){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let o=s%BigInt(128);return Number(t?BigInt(128)-o-BigInt(1):o)}return n.buffer}function Ho(r){let t=new Uint8Array(r.buffer),e=0;for(;e<t.byteLength;e++)if(t[e]<128){if(!(t[e]&64))return or(r);break}let n=new Uint8Array(Rr(r,e+1)),i=BigInt(0);for(let s=n.byteLength-1;s>=0;s--)i=i*BigInt(128)+BigInt(128-(n[s]&127)-1);return-i-BigInt(1)}function Go(r,t){if(BigInt(r)<BigInt(0))throw new Error("Cannot write negative values.");return Pi(r,t)}function Pi(r,t){r=BigInt(r);let e=new Ne(new ArrayBuffer(Math.min(1,t)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(r%i);for(e.write(new Uint8Array([o]));++n<t;)r<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((r/i-s)%BigInt(256)),e.write(new Uint8Array([o])),i*=BigInt(256);return e.buffer}function ki(r,t){let e=BigInt(sr(r)),n=BigInt(1),i=0;for(;++i<t;){n*=BigInt(256);let s=BigInt(sr(r));e=e+n*s}return e}function Ko(r,t){let e=ki(r,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return e>=n&&(e-=n*BigInt(2)),e}var Mi=ct(()=>{yn()});function wn(r){let t=BigInt(r);if(r<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}var Do=ct(()=>{});function df(r){if(sr(r)!==1)throw new Error("Cannot decode principal");let e=Number(or(r));return It.fromUint8Array(new Uint8Array(Rr(r,e)))}function zt(r){let t=JSON.stringify(r,(e,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>jo?t.substring(0,jo-3)+"...":t}var jo,Fr,Wt,Ci,$i,Vi,Li,qi,Hi,Gi,Ki,Di,gn,ar,cr,Or,ji,kd,Md,Cd,$d,Vd,Ld,qd,Hd,Gd,Kd,Dd,jd,Wd,zd,Yd,Xd,Jd,Zd,Qd,zi=ct(()=>{te();yn();Oi();Mi();Do();jo=400,Fr=class{display(){return this.name}valueToString(t){return zt(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}},Wt=class extends Fr{checkType(t){if(this.name!==t.name)throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`);return t}_buildTypeTableImpl(t){}},Ci=class extends Fr{checkType(t){if(t instanceof Or){let e=t.getType();if(typeof e>"u")throw new Error("type mismatch with uninitialized type");return e}throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`)}encodeType(t){return t.indexOf(this.name)}},$i=class extends Wt{accept(t,e){return t.visitEmpty(this,e)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return jt(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},Vi=class extends Fr{checkType(t){throw new Error("Method not implemented for unknown.")}accept(t,e){throw t.visitType(this,e)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(t,e){let n=e.decodeValue(t,e);Object(n)!==n&&(n=Object(n));let i;return e instanceof Or?i=()=>e.getType():i=()=>e,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"}},Li=class extends Wt{accept(t,e){return t.visitBool(this,e)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return jt(-2)}decodeValue(t,e){switch(this.checkType(e),sr(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},qi=class extends Wt{accept(t,e){return t.visitNull(this,e)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return jt(-1)}decodeValue(t,e){return this.checkType(e),null}get name(){return"null"}},Hi=class extends Wt{accept(t,e){return t.visitReserved(this,e)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return jt(-16)}decodeValue(t,e){return e.name!==this.name&&e.decodeValue(t,e),null}get name(){return"reserved"}},Gi=class extends Wt{accept(t,e){return t.visitText(this,e)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){let e=new TextEncoder().encode(t),n=Ue(e.byteLength);return Fi(n,e)}encodeType(){return jt(-15)}decodeValue(t,e){this.checkType(e);let n=or(t),i=Rr(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(t){return'"'+t+'"'}},Ki=class extends Wt{accept(t,e){return t.visitInt(this,e)}covariant(t){if(typeof t=="bigint"||Number.isInteger(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){return jt(t)}encodeType(){return jt(-4)}decodeValue(t,e){return this.checkType(e),Ho(t)}get name(){return"int"}valueToString(t){return t.toString()}},Di=class extends Wt{accept(t,e){return t.visitNat(this,e)}covariant(t){if(typeof t=="bigint"&&t>=BigInt(0)||Number.isInteger(t)&&t>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){return Ue(t)}encodeType(){return jt(-3)}decodeValue(t,e){return this.checkType(e),or(t)}get name(){return"nat"}valueToString(t){return t.toString()}},gn=class extends Wt{constructor(t){if(super(),this._bits=t,t!==32&&t!==64)throw new Error("not a valid float type")}accept(t,e){return t.visitFloat(this,e)}covariant(t){if(typeof t=="number"||t instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){let e=new ArrayBuffer(this._bits/8),n=new DataView(e);return this._bits===32?n.setFloat32(0,t,!0):n.setFloat64(0,t,!0),e}encodeType(){let t=this._bits===32?-13:-14;return jt(t)}decodeValue(t,e){this.checkType(e);let n=Rr(t,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(t){return t.toString()}},ar=class extends Wt{constructor(t){super(),this._bits=t}accept(t,e){return t.visitFixedInt(this,e)}covariant(t){let e=wn(this._bits-1)*BigInt(-1),n=wn(this._bits-1)-BigInt(1),i=!1;if(typeof t=="bigint")i=t>=e&&t<=n;else if(Number.isInteger(t)){let s=BigInt(t);i=s>=e&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){return Pi(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return jt(-9-t)}decodeValue(t,e){this.checkType(e);let n=Ko(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}},cr=class extends Wt{constructor(t){super(),this._bits=t}accept(t,e){return t.visitFixedNat(this,e)}covariant(t){let e=wn(this._bits),n=!1;if(typeof t=="bigint"&&t>=BigInt(0)?n=t<e:Number.isInteger(t)&&t>=0?n=BigInt(t)<e:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){return Go(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return jt(-5-t)}decodeValue(t,e){this.checkType(e);let n=ki(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}},Or=class r extends Ci{constructor(){super(...arguments),this._id=r._counter++,this._type=void 0}accept(t,e){if(!this._type)throw Error("Recursive type uninitialized.");return t.visitRec(this,this._type,e)}fill(t){this._type=t}getType(){return this._type}covariant(t){if(this._type&&this._type.covariant(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(t)}_buildTypeTableImpl(t){if(!this._type)throw Error("Recursive type uninitialized.");t.add(this,new Uint8Array([])),this._type.buildTypeTable(t),t.merge(this,this._type.name)}decodeValue(t,e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(t,e)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(t)}};Or._counter=0;ji=class extends Wt{accept(t,e){return t.visitPrincipal(this,e)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${zt(t)}`)}encodeValue(t){let e=t.toUint8Array(),n=Ue(e.byteLength);return Fi(new Uint8Array([1]),n,e)}encodeType(){return jt(-24)}decodeValue(t,e){return this.checkType(e),df(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}};kd=new $i,Md=new Hi,Cd=new Vi,$d=new Li,Vd=new qi,Ld=new Gi,qd=new Ki,Hd=new Di,Gd=new gn(32),Kd=new gn(64),Dd=new ar(8),jd=new ar(16),Wd=new ar(32),zd=new ar(64),Yd=new cr(8),Xd=new cr(16),Jd=new cr(32),Zd=new cr(64),Qd=new ji});var Yi=ct(()=>{});var Wo=ct(()=>{zi();te();Yi()});var zo=ct(()=>{});var ur=ct(()=>{Wo();Yi();zi();Oi();Mi();yn();zo()});var Pr=Bt(lr=>{"use strict";var Xi=di(),fr=sn(),Yo=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;lr.Buffer=S;lr.SlowBuffer=_f;lr.INSPECT_MAX_BYTES=50;var mn=2147483647;lr.kMaxLength=mn;S.TYPED_ARRAY_SUPPORT=yf();!S.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 yf(){try{var r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch{return!1}}Object.defineProperty(S.prototype,"parent",{enumerable:!0,get:function(){if(S.isBuffer(this))return this.buffer}});Object.defineProperty(S.prototype,"offset",{enumerable:!0,get:function(){if(S.isBuffer(this))return this.byteOffset}});function _e(r){if(r>mn)throw new RangeError('The value "'+r+'" is invalid for option "size"');var t=new Uint8Array(r);return Object.setPrototypeOf(t,S.prototype),t}function S(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return ts(r)}return Zo(r,t,e)}S.poolSize=8192;function Zo(r,t,e){if(typeof r=="string")return gf(r,t);if(ArrayBuffer.isView(r))return mf(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(he(r,ArrayBuffer)||r&&he(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(he(r,SharedArrayBuffer)||r&&he(r.buffer,SharedArrayBuffer)))return Zi(r,t,e);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return S.from(n,t,e);var i=xf(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return S.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}S.from=function(r,t,e){return Zo(r,t,e)};Object.setPrototypeOf(S.prototype,Uint8Array.prototype);Object.setPrototypeOf(S,Uint8Array);function Qo(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function wf(r,t,e){return Qo(r),r<=0?_e(r):t!==void 0?typeof e=="string"?_e(r).fill(t,e):_e(r).fill(t):_e(r)}S.alloc=function(r,t,e){return wf(r,t,e)};function ts(r){return Qo(r),_e(r<0?0:es(r)|0)}S.allocUnsafe=function(r){return ts(r)};S.allocUnsafeSlow=function(r){return ts(r)};function gf(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!S.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=ta(r,t)|0,n=_e(e),i=n.write(r,t);return i!==e&&(n=n.slice(0,i)),n}function Ji(r){for(var t=r.length<0?0:es(r.length)|0,e=_e(t),n=0;n<t;n+=1)e[n]=r[n]&255;return e}function mf(r){if(he(r,Uint8Array)){var t=new Uint8Array(r);return Zi(t.buffer,t.byteOffset,t.byteLength)}return Ji(r)}function Zi(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var n;return t===void 0&&e===void 0?n=new Uint8Array(r):e===void 0?n=new Uint8Array(r,t):n=new Uint8Array(r,t,e),Object.setPrototypeOf(n,S.prototype),n}function xf(r){if(S.isBuffer(r)){var t=es(r.length)|0,e=_e(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||rs(r.length)?_e(0):Ji(r);if(r.type==="Buffer"&&Array.isArray(r.data))return Ji(r.data)}function es(r){if(r>=mn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+mn.toString(16)+" bytes");return r|0}function _f(r){return+r!=r&&(r=0),S.alloc(+r)}S.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==S.prototype};S.compare=function(t,e){if(he(t,Uint8Array)&&(t=S.from(t,t.offset,t.byteLength)),he(e,Uint8Array)&&(e=S.from(e,e.offset,e.byteLength)),!S.isBuffer(t)||!S.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var n=t.length,i=e.length,s=0,o=Math.min(n,i);s<o;++s)if(t[s]!==e[s]){n=t[s],i=e[s];break}return n<i?-1:i<n?1:0};S.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};S.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return S.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var i=S.allocUnsafe(e),s=0;for(n=0;n<t.length;++n){var o=t[n];if(he(o,Uint8Array))s+o.length>i.length?S.from(o).copy(i,s):Uint8Array.prototype.set.call(i,o,s);else if(S.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function ta(r,t){if(S.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||he(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);var e=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&e===0)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return Qi(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return oa(r).length;default:if(i)return n?-1:Qi(r).length;t=(""+t).toLowerCase(),i=!0}}S.byteLength=ta;function bf(r,t,e){var n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return Rf(this,t,e);case"utf8":case"utf-8":return ra(this,t,e);case"ascii":return Nf(this,t,e);case"latin1":case"binary":return Uf(this,t,e);case"base64":return Bf(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ff(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}S.prototype._isBuffer=!0;function qe(r,t,e){var n=r[t];r[t]=r[e],r[e]=n}S.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)qe(this,e,e+1);return this};S.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)qe(this,e,e+3),qe(this,e+1,e+2);return this};S.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)qe(this,e,e+7),qe(this,e+1,e+6),qe(this,e+2,e+5),qe(this,e+3,e+4);return this};S.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?ra(this,0,t):bf.apply(this,arguments)};S.prototype.toLocaleString=S.prototype.toString;S.prototype.equals=function(t){if(!S.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:S.compare(this,t)===0};S.prototype.inspect=function(){var t="",e=lr.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};Yo&&(S.prototype[Yo]=S.prototype.inspect);S.prototype.compare=function(t,e,n,i,s){if(he(t,Uint8Array)&&(t=S.from(t,t.offset,t.byteLength)),!S.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),e<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&e>=n)return 0;if(i>=s)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;for(var o=s-i,c=n-e,u=Math.min(o,c),w=this.slice(i,s),y=t.slice(e,n),m=0;m<u;++m)if(w[m]!==y[m]){o=w[m],c=y[m];break}return o<c?-1:c<o?1:0};function ea(r,t,e,n,i){if(r.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,rs(e)&&(e=i?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(i)return-1;e=r.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=S.from(t,n)),S.isBuffer(t))return t.length===0?-1:Xo(r,t,e,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):Xo(r,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function Xo(r,t,e,n,i){var s=1,o=r.length,c=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;s=2,o/=2,c/=2,e/=2}function u(M,O){return s===1?M[O]:M.readUInt16BE(O*s)}var w;if(i){var y=-1;for(w=e;w<o;w++)if(u(r,w)===u(t,y===-1?0:w-y)){if(y===-1&&(y=w),w-y+1===c)return y*s}else y!==-1&&(w-=w-y),y=-1}else for(e+c>o&&(e=o-c),w=e;w>=0;w--){for(var m=!0,N=0;N<c;N++)if(u(r,w+N)!==u(t,N)){m=!1;break}if(m)return w}return-1}S.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1};S.prototype.indexOf=function(t,e,n){return ea(this,t,e,n,!0)};S.prototype.lastIndexOf=function(t,e,n){return ea(this,t,e,n,!1)};function Ef(r,t,e,n){e=Number(e)||0;var i=r.length-e;n?(n=Number(n),n>i&&(n=i)):n=i;var s=t.length;n>s/2&&(n=s/2);for(var o=0;o<n;++o){var c=parseInt(t.substr(o*2,2),16);if(rs(c))return o;r[e+o]=c}return o}function Af(r,t,e,n){return xn(Qi(t,r.length-e),r,e,n)}function vf(r,t,e,n){return xn(kf(t),r,e,n)}function Tf(r,t,e,n){return xn(oa(t),r,e,n)}function Sf(r,t,e,n){return xn(Mf(t,r.length-e),r,e,n)}S.prototype.write=function(t,e,n,i){if(e===void 0)i="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")i=e,n=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s=this.length-e;if((n===void 0||n>s)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return Ef(this,t,e,n);case"utf8":case"utf-8":return Af(this,t,e,n);case"ascii":case"latin1":case"binary":return vf(this,t,e,n);case"base64":return Tf(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Sf(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};S.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Bf(r,t,e){return t===0&&e===r.length?Xi.fromByteArray(r):Xi.fromByteArray(r.slice(t,e))}function ra(r,t,e){e=Math.min(r.length,e);for(var n=[],i=t;i<e;){var s=r[i],o=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=e){var u,w,y,m;switch(c){case 1:s<128&&(o=s);break;case 2:u=r[i+1],(u&192)===128&&(m=(s&31)<<6|u&63,m>127&&(o=m));break;case 3:u=r[i+1],w=r[i+2],(u&192)===128&&(w&192)===128&&(m=(s&15)<<12|(u&63)<<6|w&63,m>2047&&(m<55296||m>57343)&&(o=m));break;case 4:u=r[i+1],w=r[i+2],y=r[i+3],(u&192)===128&&(w&192)===128&&(y&192)===128&&(m=(s&15)<<18|(u&63)<<12|(w&63)<<6|y&63,m>65535&&m<1114112&&(o=m))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=c}return If(n)}var Jo=4096;function If(r){var t=r.length;if(t<=Jo)return String.fromCharCode.apply(String,r);for(var e="",n=0;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=Jo));return e}function Nf(r,t,e){var n="";e=Math.min(r.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(r[i]&127);return n}function Uf(r,t,e){var n="";e=Math.min(r.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(r[i]);return n}function Rf(r,t,e){var n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);for(var i="",s=t;s<e;++s)i+=Cf[r[s]];return i}function Ff(r,t,e){for(var n=r.slice(t,e),i="",s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}S.prototype.slice=function(t,e){var n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);var i=this.subarray(t,e);return Object.setPrototypeOf(i,S.prototype),i};function Mt(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}S.prototype.readUintLE=S.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||Mt(t,e,this.length);for(var i=this[t],s=1,o=0;++o<e&&(s*=256);)i+=this[t+o]*s;return i};S.prototype.readUintBE=S.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||Mt(t,e,this.length);for(var i=this[t+--e],s=1;e>0&&(s*=256);)i+=this[t+--e]*s;return i};S.prototype.readUint8=S.prototype.readUInt8=function(t,e){return t=t>>>0,e||Mt(t,1,this.length),this[t]};S.prototype.readUint16LE=S.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||Mt(t,2,this.length),this[t]|this[t+1]<<8};S.prototype.readUint16BE=S.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||Mt(t,2,this.length),this[t]<<8|this[t+1]};S.prototype.readUint32LE=S.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||Mt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};S.prototype.readUint32BE=S.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||Mt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};S.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||Mt(t,e,this.length);for(var i=this[t],s=1,o=0;++o<e&&(s*=256);)i+=this[t+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*e)),i};S.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||Mt(t,e,this.length);for(var i=e,s=1,o=this[t+--i];i>0&&(s*=256);)o+=this[t+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*e)),o};S.prototype.readInt8=function(t,e){return t=t>>>0,e||Mt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};S.prototype.readInt16LE=function(t,e){t=t>>>0,e||Mt(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};S.prototype.readInt16BE=function(t,e){t=t>>>0,e||Mt(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};S.prototype.readInt32LE=function(t,e){return t=t>>>0,e||Mt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};S.prototype.readInt32BE=function(t,e){return t=t>>>0,e||Mt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};S.prototype.readFloatLE=function(t,e){return t=t>>>0,e||Mt(t,4,this.length),fr.read(this,t,!0,23,4)};S.prototype.readFloatBE=function(t,e){return t=t>>>0,e||Mt(t,4,this.length),fr.read(this,t,!1,23,4)};S.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||Mt(t,8,this.length),fr.read(this,t,!0,52,8)};S.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||Mt(t,8,this.length),fr.read(this,t,!1,52,8)};function Ht(r,t,e,n,i,s){if(!S.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}S.prototype.writeUintLE=S.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){var s=Math.pow(2,8*n)-1;Ht(this,t,e,n,s,0)}var o=1,c=0;for(this[e]=t&255;++c<n&&(o*=256);)this[e+c]=t/o&255;return e+n};S.prototype.writeUintBE=S.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){var s=Math.pow(2,8*n)-1;Ht(this,t,e,n,s,0)}var o=n-1,c=1;for(this[e+o]=t&255;--o>=0&&(c*=256);)this[e+o]=t/c&255;return e+n};S.prototype.writeUint8=S.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,1,255,0),this[e]=t&255,e+1};S.prototype.writeUint16LE=S.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};S.prototype.writeUint16BE=S.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};S.prototype.writeUint32LE=S.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4};S.prototype.writeUint32BE=S.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};S.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){var s=Math.pow(2,8*n-1);Ht(this,t,e,n,s-1,-s)}var o=0,c=1,u=0;for(this[e]=t&255;++o<n&&(c*=256);)t<0&&u===0&&this[e+o-1]!==0&&(u=1),this[e+o]=(t/c>>0)-u&255;return e+n};S.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){var s=Math.pow(2,8*n-1);Ht(this,t,e,n,s-1,-s)}var o=n-1,c=1,u=0;for(this[e+o]=t&255;--o>=0&&(c*=256);)t<0&&u===0&&this[e+o+1]!==0&&(u=1),this[e+o]=(t/c>>0)-u&255;return e+n};S.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};S.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};S.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};S.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4};S.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function na(r,t,e,n,i,s){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function ia(r,t,e,n,i){return t=+t,e=e>>>0,i||na(r,t,e,4,34028234663852886e22,-34028234663852886e22),fr.write(r,t,e,n,23,4),e+4}S.prototype.writeFloatLE=function(t,e,n){return ia(this,t,e,!0,n)};S.prototype.writeFloatBE=function(t,e,n){return ia(this,t,e,!1,n)};function sa(r,t,e,n,i){return t=+t,e=e>>>0,i||na(r,t,e,8,17976931348623157e292,-17976931348623157e292),fr.write(r,t,e,n,52,8),e+8}S.prototype.writeDoubleLE=function(t,e,n){return sa(this,t,e,!0,n)};S.prototype.writeDoubleBE=function(t,e,n){return sa(this,t,e,!1,n)};S.prototype.copy=function(t,e,n,i){if(!S.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);var s=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),e),s};S.prototype.fill=function(t,e,n,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=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"&&!S.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){var s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);var o;if(typeof t=="number")for(o=e;o<n;++o)this[o]=t;else{var c=S.isBuffer(t)?t:S.from(t,i),u=c.length;if(u===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-e;++o)this[o+e]=c[o%u]}return this};var Of=/[^+/0-9A-Za-z-_]/g;function Pf(r){if(r=r.split("=")[0],r=r.trim().replace(Of,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Qi(r,t){t=t||1/0;for(var e,n=r.length,i=null,s=[],o=0;o<n;++o){if(e=r.charCodeAt(o),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&s.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;s.push(e)}else if(e<2048){if((t-=2)<0)break;s.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;s.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;s.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return s}function kf(r){for(var t=[],e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function Mf(r,t){for(var e,n,i,s=[],o=0;o<r.length&&!((t-=2)<0);++o)e=r.charCodeAt(o),n=e>>8,i=e%256,s.push(i),s.push(n);return s}function oa(r){return Xi.toByteArray(Pf(r))}function xn(r,t,e,n){for(var i=0;i<n&&!(i+e>=t.length||i>=r.length);++i)t[i+e]=r[i];return i}function he(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function rs(r){return r!==r}var Cf=function(){for(var r="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var n=e*16,i=0;i<16;++i)t[n+i]=r[e]+r[i];return t}()});var kr=Bt((aa,_n)=>{(function(r){"use strict";var t,e=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",c=1e14,u=14,w=9007199254740991,y=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],m=1e7,N=1e9;function M(C){var H,nt,Y,R=B.prototype={constructor:B,toString:null,valueOf:null},it=new B(1),st=20,ot=4,wt=-7,Ot=21,V=-1e7,U=1e7,P=!1,L=1,K=0,J={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},tt="0123456789abcdefghijklmnopqrstuvwxyz",ut=!0;function B(a,f){var l,b,g,_,v,d,x,A,E=this;if(!(E instanceof B))return new B(a,f);if(f==null){if(a&&a._isBigNumber===!0){E.s=a.s,!a.c||a.e>U?E.c=E.e=null:a.e<V?E.c=[E.e=0]:(E.e=a.e,E.c=a.c.slice());return}if((d=typeof a=="number")&&a*0==0){if(E.s=1/a<0?(a=-a,-1):1,a===~~a){for(_=0,v=a;v>=10;v/=10,_++);_>U?E.c=E.e=null:(E.e=_,E.c=[a]);return}A=String(a)}else{if(!e.test(A=String(a)))return Y(E,A,d);E.s=A.charCodeAt(0)==45?(A=A.slice(1),-1):1}(_=A.indexOf("."))>-1&&(A=A.replace(".","")),(v=A.search(/e/i))>0?(_<0&&(_=v),_+=+A.slice(v+1),A=A.substring(0,v)):_<0&&(_=A.length)}else{if(j(f,2,tt.length,"Base"),f==10&&ut)return E=new B(a),gt(E,st+E.e+1,ot);if(A=String(a),d=typeof a=="number"){if(a*0!=0)return Y(E,A,d,f);if(E.s=1/a<0?(A=A.slice(1),-1):1,B.DEBUG&&A.replace(/^0\.0*|\./,"").length>15)throw Error(o+a)}else E.s=A.charCodeAt(0)===45?(A=A.slice(1),-1):1;for(l=tt.slice(0,f),_=v=0,x=A.length;v<x;v++)if(l.indexOf(b=A.charAt(v))<0){if(b=="."){if(v>_){_=x;continue}}else if(!g&&(A==A.toUpperCase()&&(A=A.toLowerCase())||A==A.toLowerCase()&&(A=A.toUpperCase()))){g=!0,v=-1,_=0;continue}return Y(E,String(a),d,f)}d=!1,A=nt(A,f,10,E.s),(_=A.indexOf("."))>-1?A=A.replace(".",""):_=A.length}for(v=0;A.charCodeAt(v)===48;v++);for(x=A.length;A.charCodeAt(--x)===48;);if(A=A.slice(v,++x)){if(x-=v,d&&B.DEBUG&&x>15&&(a>w||a!==i(a)))throw Error(o+E.s*a);if((_=_-v-1)>U)E.c=E.e=null;else if(_<V)E.c=[E.e=0];else{if(E.e=_,E.c=[],v=(_+1)%u,_<0&&(v+=u),v<x){for(v&&E.c.push(+A.slice(0,v)),x-=u;v<x;)E.c.push(+A.slice(v,v+=u));v=u-(A=A.slice(v)).length}else v-=x;for(;v--;A+="0");E.c.push(+A)}}else E.c=[E.e=0]}B.clone=M,B.ROUND_UP=0,B.ROUND_DOWN=1,B.ROUND_CEIL=2,B.ROUND_FLOOR=3,B.ROUND_HALF_UP=4,B.ROUND_HALF_DOWN=5,B.ROUND_HALF_EVEN=6,B.ROUND_HALF_CEIL=7,B.ROUND_HALF_FLOOR=8,B.EUCLID=9,B.config=B.set=function(a){var f,l;if(a!=null)if(typeof a=="object"){if(a.hasOwnProperty(f="DECIMAL_PLACES")&&(l=a[f],j(l,0,N,f),st=l),a.hasOwnProperty(f="ROUNDING_MODE")&&(l=a[f],j(l,0,8,f),ot=l),a.hasOwnProperty(f="EXPONENTIAL_AT")&&(l=a[f],l&&l.pop?(j(l[0],-N,0,f),j(l[1],0,N,f),wt=l[0],Ot=l[1]):(j(l,-N,N,f),wt=-(Ot=l<0?-l:l))),a.hasOwnProperty(f="RANGE"))if(l=a[f],l&&l.pop)j(l[0],-N,-1,f),j(l[1],1,N,f),V=l[0],U=l[1];else if(j(l,-N,N,f),l)V=-(U=l<0?-l:l);else throw Error(s+f+" cannot be zero: "+l);if(a.hasOwnProperty(f="CRYPTO"))if(l=a[f],l===!!l)if(l)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))P=l;else throw P=!l,Error(s+"crypto unavailable");else P=l;else throw Error(s+f+" not true or false: "+l);if(a.hasOwnProperty(f="MODULO_MODE")&&(l=a[f],j(l,0,9,f),L=l),a.hasOwnProperty(f="POW_PRECISION")&&(l=a[f],j(l,0,N,f),K=l),a.hasOwnProperty(f="FORMAT"))if(l=a[f],typeof l=="object")J=l;else throw Error(s+f+" not an object: "+l);if(a.hasOwnProperty(f="ALPHABET"))if(l=a[f],typeof l=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(l))ut=l.slice(0,10)=="0123456789",tt=l;else throw Error(s+f+" invalid: "+l)}else throw Error(s+"Object expected: "+a);return{DECIMAL_PLACES:st,ROUNDING_MODE:ot,EXPONENTIAL_AT:[wt,Ot],RANGE:[V,U],CRYPTO:P,MODULO_MODE:L,POW_PRECISION:K,FORMAT:J,ALPHABET:tt}},B.isBigNumber=function(a){if(!a||a._isBigNumber!==!0)return!1;if(!B.DEBUG)return!0;var f,l,b=a.c,g=a.e,_=a.s;t:if({}.toString.call(b)=="[object Array]"){if((_===1||_===-1)&&g>=-N&&g<=N&&g===i(g)){if(b[0]===0){if(g===0&&b.length===1)return!0;break t}if(f=(g+1)%u,f<1&&(f+=u),String(b[0]).length==f){for(f=0;f<b.length;f++)if(l=b[f],l<0||l>=c||l!==i(l))break t;if(l!==0)return!0}}}else if(b===null&&g===null&&(_===null||_===1||_===-1))return!0;throw Error(s+"Invalid BigNumber: "+a)},B.maximum=B.max=function(){return mt(arguments,-1)},B.minimum=B.min=function(){return mt(arguments,1)},B.random=function(){var a=9007199254740992,f=Math.random()*a&2097151?function(){return i(Math.random()*a)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(l){var b,g,_,v,d,x=0,A=[],E=new B(it);if(l==null?l=st:j(l,0,N),v=n(l/u),P)if(crypto.getRandomValues){for(b=crypto.getRandomValues(new Uint32Array(v*=2));x<v;)d=b[x]*131072+(b[x+1]>>>11),d>=9e15?(g=crypto.getRandomValues(new Uint32Array(2)),b[x]=g[0],b[x+1]=g[1]):(A.push(d%1e14),x+=2);x=v/2}else if(crypto.randomBytes){for(b=crypto.randomBytes(v*=7);x<v;)d=(b[x]&31)*281474976710656+b[x+1]*1099511627776+b[x+2]*4294967296+b[x+3]*16777216+(b[x+4]<<16)+(b[x+5]<<8)+b[x+6],d>=9e15?crypto.randomBytes(7).copy(b,x):(A.push(d%1e14),x+=7);x=v/7}else throw P=!1,Error(s+"crypto unavailable");if(!P)for(;x<v;)d=f(),d<9e15&&(A[x++]=d%1e14);for(v=A[--x],l%=u,v&&l&&(d=y[u-l],A[x]=i(v/d)*d);A[x]===0;A.pop(),x--);if(x<0)A=[_=0];else{for(_=-1;A[0]===0;A.splice(0,1),_-=u);for(x=1,d=A[0];d>=10;d/=10,x++);x<u&&(_-=u-x)}return E.e=_,E.c=A,E}}(),B.sum=function(){for(var a=1,f=arguments,l=new B(f[0]);a<f.length;)l=l.plus(f[a++]);return l},nt=function(){var a="0123456789";function f(l,b,g,_){for(var v,d=[0],x,A=0,E=l.length;A<E;){for(x=d.length;x--;d[x]*=b);for(d[0]+=_.indexOf(l.charAt(A++)),v=0;v<d.length;v++)d[v]>g-1&&(d[v+1]==null&&(d[v+1]=0),d[v+1]+=d[v]/g|0,d[v]%=g)}return d.reverse()}return function(l,b,g,_,v){var d,x,A,E,I,F,$,Z,ht=l.indexOf("."),xt=st,X=ot;for(ht>=0&&(E=K,K=0,l=l.replace(".",""),Z=new B(b),F=Z.pow(l.length-ht),K=E,Z.c=f(yt(G(F.c),F.e,"0"),10,g,a),Z.e=Z.c.length),$=f(l,b,g,v?(d=tt,a):(d=a,tt)),A=E=$.length;$[--E]==0;$.pop());if(!$[0])return d.charAt(0);if(ht<0?--A:(F.c=$,F.e=A,F.s=_,F=H(F,Z,xt,X,g),$=F.c,I=F.r,A=F.e),x=A+xt+1,ht=$[x],E=g/2,I=I||x<0||$[x+1]!=null,I=X<4?(ht!=null||I)&&(X==0||X==(F.s<0?3:2)):ht>E||ht==E&&(X==4||I||X==6&&$[x-1]&1||X==(F.s<0?8:7)),x<1||!$[0])l=I?yt(d.charAt(1),-xt,d.charAt(0)):d.charAt(0);else{if($.length=x,I)for(--g;++$[--x]>g;)$[x]=0,x||(++A,$=[1].concat($));for(E=$.length;!$[--E];);for(ht=0,l="";ht<=E;l+=d.charAt($[ht++]));l=yt(l,A,d.charAt(0))}return l}}(),H=function(){function a(b,g,_){var v,d,x,A,E=0,I=b.length,F=g%m,$=g/m|0;for(b=b.slice();I--;)x=b[I]%m,A=b[I]/m|0,v=$*x+A*F,d=F*x+v%m*m+E,E=(d/_|0)+(v/m|0)+$*A,b[I]=d%_;return E&&(b=[E].concat(b)),b}function f(b,g,_,v){var d,x;if(_!=v)x=_>v?1:-1;else for(d=x=0;d<_;d++)if(b[d]!=g[d]){x=b[d]>g[d]?1:-1;break}return x}function l(b,g,_,v){for(var d=0;_--;)b[_]-=d,d=b[_]<g[_]?1:0,b[_]=d*v+b[_]-g[_];for(;!b[0]&&b.length>1;b.splice(0,1));}return function(b,g,_,v,d){var x,A,E,I,F,$,Z,ht,xt,X,q,Tt,ve,$e,Sr,Zt,at,Lt=b.s==g.s?1:-1,Ct=b.c,_t=g.c;if(!Ct||!Ct[0]||!_t||!_t[0])return new B(!b.s||!g.s||(Ct?_t&&Ct[0]==_t[0]:!_t)?NaN:Ct&&Ct[0]==0||!_t?Lt*0:Lt/0);for(ht=new B(Lt),xt=ht.c=[],A=b.e-g.e,Lt=_+A+1,d||(d=c,A=O(b.e/u)-O(g.e/u),Lt=Lt/u|0),E=0;_t[E]==(Ct[E]||0);E++);if(_t[E]>(Ct[E]||0)&&A--,Lt<0)xt.push(1),I=!0;else{for($e=Ct.length,Zt=_t.length,E=0,Lt+=2,F=i(d/(_t[0]+1)),F>1&&(_t=a(_t,F,d),Ct=a(Ct,F,d),Zt=_t.length,$e=Ct.length),ve=Zt,X=Ct.slice(0,Zt),q=X.length;q<Zt;X[q++]=0);at=_t.slice(),at=[0].concat(at),Sr=_t[0],_t[1]>=d/2&&Sr++;do{if(F=0,x=f(_t,X,Zt,q),x<0){if(Tt=X[0],Zt!=q&&(Tt=Tt*d+(X[1]||0)),F=i(Tt/Sr),F>1)for(F>=d&&(F=d-1),$=a(_t,F,d),Z=$.length,q=X.length;f($,X,Z,q)==1;)F--,l($,Zt<Z?at:_t,Z,d),Z=$.length,x=1;else F==0&&(x=F=1),$=_t.slice(),Z=$.length;if(Z<q&&($=[0].concat($)),l(X,$,q,d),q=X.length,x==-1)for(;f(_t,X,Zt,q)<1;)F++,l(X,Zt<q?at:_t,q,d),q=X.length}else x===0&&(F++,X=[0]);xt[E++]=F,X[0]?X[q++]=Ct[ve]||0:(X=[Ct[ve]],q=1)}while((ve++<$e||X[0]!=null)&&Lt--);I=X[0]!=null,xt[0]||xt.splice(0,1)}if(d==c){for(E=1,Lt=xt[0];Lt>=10;Lt/=10,E++);gt(ht,_+(ht.e=E+A*u-1)+1,v,I)}else ht.e=A,ht.r=+I;return ht}}();function h(a,f,l,b){var g,_,v,d,x;if(l==null?l=ot:j(l,0,8),!a.c)return a.toString();if(g=a.c[0],v=a.e,f==null)x=G(a.c),x=b==1||b==2&&(v<=wt||v>=Ot)?z(x,v):yt(x,v,"0");else if(a=gt(new B(a),f,l),_=a.e,x=G(a.c),d=x.length,b==1||b==2&&(f<=_||_<=wt)){for(;d<f;x+="0",d++);x=z(x,_)}else if(f-=v,x=yt(x,_,"0"),_+1>d){if(--f>0)for(x+=".";f--;x+="0");}else if(f+=_-d,f>0)for(_+1==d&&(x+=".");f--;x+="0");return a.s<0&&g?"-"+x:x}function mt(a,f){for(var l,b,g=1,_=new B(a[0]);g<a.length;g++)b=new B(a[g]),(!b.s||(l=lt(_,b))===f||l===0&&_.s===f)&&(_=b);return _}function Et(a,f,l){for(var b=1,g=f.length;!f[--g];f.pop());for(g=f[0];g>=10;g/=10,b++);return(l=b+l*u-1)>U?a.c=a.e=null:l<V?a.c=[a.e=0]:(a.e=l,a.c=f),a}Y=function(){var a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,f=/^([^.]+)\.$/,l=/^\.([^.]+)$/,b=/^-?(Infinity|NaN)$/,g=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(_,v,d,x){var A,E=d?v:v.replace(g,"");if(b.test(E))_.s=isNaN(E)?null:E<0?-1:1;else{if(!d&&(E=E.replace(a,function(I,F,$){return A=($=$.toLowerCase())=="x"?16:$=="b"?2:8,!x||x==A?F:I}),x&&(A=x,E=E.replace(f,"$1").replace(l,"0.$1")),v!=E))return new B(E,A);if(B.DEBUG)throw Error(s+"Not a"+(x?" base "+x:"")+" number: "+v);_.s=null}_.c=_.e=null}}();function gt(a,f,l,b){var g,_,v,d,x,A,E,I=a.c,F=y;if(I){t:{for(g=1,d=I[0];d>=10;d/=10,g++);if(_=f-g,_<0)_+=u,v=f,x=I[A=0],E=i(x/F[g-v-1]%10);else if(A=n((_+1)/u),A>=I.length)if(b){for(;I.length<=A;I.push(0));x=E=0,g=1,_%=u,v=_-u+1}else break t;else{for(x=d=I[A],g=1;d>=10;d/=10,g++);_%=u,v=_-u+g,E=v<0?0:i(x/F[g-v-1]%10)}if(b=b||f<0||I[A+1]!=null||(v<0?x:x%F[g-v-1]),b=l<4?(E||b)&&(l==0||l==(a.s<0?3:2)):E>5||E==5&&(l==4||b||l==6&&(_>0?v>0?x/F[g-v]:0:I[A-1])%10&1||l==(a.s<0?8:7)),f<1||!I[0])return I.length=0,b?(f-=a.e+1,I[0]=F[(u-f%u)%u],a.e=-f||0):I[0]=a.e=0,a;if(_==0?(I.length=A,d=1,A--):(I.length=A+1,d=F[u-_],I[A]=v>0?i(x/F[g-v]%F[v])*d:0),b)for(;;)if(A==0){for(_=1,v=I[0];v>=10;v/=10,_++);for(v=I[0]+=d,d=1;v>=10;v/=10,d++);_!=d&&(a.e++,I[0]==c&&(I[0]=1));break}else{if(I[A]+=d,I[A]!=c)break;I[A--]=0,d=1}for(_=I.length;I[--_]===0;I.pop());}a.e>U?a.c=a.e=null:a.e<V&&(a.c=[a.e=0])}return a}function k(a){var f,l=a.e;return l===null?a.toString():(f=G(a.c),f=l<=wt||l>=Ot?z(f,l):yt(f,l,"0"),a.s<0?"-"+f:f)}return R.absoluteValue=R.abs=function(){var a=new B(this);return a.s<0&&(a.s=1),a},R.comparedTo=function(a,f){return lt(this,new B(a,f))},R.decimalPlaces=R.dp=function(a,f){var l,b,g,_=this;if(a!=null)return j(a,0,N),f==null?f=ot:j(f,0,8),gt(new B(_),a+_.e+1,f);if(!(l=_.c))return null;if(b=((g=l.length-1)-O(this.e/u))*u,g=l[g])for(;g%10==0;g/=10,b--);return b<0&&(b=0),b},R.dividedBy=R.div=function(a,f){return H(this,new B(a,f),st,ot)},R.dividedToIntegerBy=R.idiv=function(a,f){return H(this,new B(a,f),0,1)},R.exponentiatedBy=R.pow=function(a,f){var l,b,g,_,v,d,x,A,E,I=this;if(a=new B(a),a.c&&!a.isInteger())throw Error(s+"Exponent not an integer: "+k(a));if(f!=null&&(f=new B(f)),d=a.e>14,!I.c||!I.c[0]||I.c[0]==1&&!I.e&&I.c.length==1||!a.c||!a.c[0])return E=new B(Math.pow(+k(I),d?a.s*(2-W(a)):+k(a))),f?E.mod(f):E;if(x=a.s<0,f){if(f.c?!f.c[0]:!f.s)return new B(NaN);b=!x&&I.isInteger()&&f.isInteger(),b&&(I=I.mod(f))}else{if(a.e>9&&(I.e>0||I.e<-1||(I.e==0?I.c[0]>1||d&&I.c[1]>=24e7:I.c[0]<8e13||d&&I.c[0]<=9999975e7)))return _=I.s<0&&W(a)?-0:0,I.e>-1&&(_=1/_),new B(x?1/_:_);K&&(_=n(K/u+2))}for(d?(l=new B(.5),x&&(a.s=1),A=W(a)):(g=Math.abs(+k(a)),A=g%2),E=new B(it);;){if(A){if(E=E.times(I),!E.c)break;_?E.c.length>_&&(E.c.length=_):b&&(E=E.mod(f))}if(g){if(g=i(g/2),g===0)break;A=g%2}else if(a=a.times(l),gt(a,a.e+1,1),a.e>14)A=W(a);else{if(g=+k(a),g===0)break;A=g%2}I=I.times(I),_?I.c&&I.c.length>_&&(I.c.length=_):b&&(I=I.mod(f))}return b?E:(x&&(E=it.div(E)),f?E.mod(f):_?gt(E,K,ot,v):E)},R.integerValue=function(a){var f=new B(this);return a==null?a=ot:j(a,0,8),gt(f,f.e+1,a)},R.isEqualTo=R.eq=function(a,f){return lt(this,new B(a,f))===0},R.isFinite=function(){return!!this.c},R.isGreaterThan=R.gt=function(a,f){return lt(this,new B(a,f))>0},R.isGreaterThanOrEqualTo=R.gte=function(a,f){return(f=lt(this,new B(a,f)))===1||f===0},R.isInteger=function(){return!!this.c&&O(this.e/u)>this.c.length-2},R.isLessThan=R.lt=function(a,f){return lt(this,new B(a,f))<0},R.isLessThanOrEqualTo=R.lte=function(a,f){return(f=lt(this,new B(a,f)))===-1||f===0},R.isNaN=function(){return!this.s},R.isNegative=function(){return this.s<0},R.isPositive=function(){return this.s>0},R.isZero=function(){return!!this.c&&this.c[0]==0},R.minus=function(a,f){var l,b,g,_,v=this,d=v.s;if(a=new B(a,f),f=a.s,!d||!f)return new B(NaN);if(d!=f)return a.s=-f,v.plus(a);var x=v.e/u,A=a.e/u,E=v.c,I=a.c;if(!x||!A){if(!E||!I)return E?(a.s=-f,a):new B(I?v:NaN);if(!E[0]||!I[0])return I[0]?(a.s=-f,a):new B(E[0]?v:ot==3?-0:0)}if(x=O(x),A=O(A),E=E.slice(),d=x-A){for((_=d<0)?(d=-d,g=E):(A=x,g=I),g.reverse(),f=d;f--;g.push(0));g.reverse()}else for(b=(_=(d=E.length)<(f=I.length))?d:f,d=f=0;f<b;f++)if(E[f]!=I[f]){_=E[f]<I[f];break}if(_&&(g=E,E=I,I=g,a.s=-a.s),f=(b=I.length)-(l=E.length),f>0)for(;f--;E[l++]=0);for(f=c-1;b>d;){if(E[--b]<I[b]){for(l=b;l&&!E[--l];E[l]=f);--E[l],E[b]+=c}E[b]-=I[b]}for(;E[0]==0;E.splice(0,1),--A);return E[0]?Et(a,E,A):(a.s=ot==3?-1:1,a.c=[a.e=0],a)},R.modulo=R.mod=function(a,f){var l,b,g=this;return a=new B(a,f),!g.c||!a.s||a.c&&!a.c[0]?new B(NaN):!a.c||g.c&&!g.c[0]?new B(g):(L==9?(b=a.s,a.s=1,l=H(g,a,0,3),a.s=b,l.s*=b):l=H(g,a,0,L),a=g.minus(l.times(a)),!a.c[0]&&L==1&&(a.s=g.s),a)},R.multipliedBy=R.times=function(a,f){var l,b,g,_,v,d,x,A,E,I,F,$,Z,ht,xt,X=this,q=X.c,Tt=(a=new B(a,f)).c;if(!q||!Tt||!q[0]||!Tt[0])return!X.s||!a.s||q&&!q[0]&&!Tt||Tt&&!Tt[0]&&!q?a.c=a.e=a.s=null:(a.s*=X.s,!q||!Tt?a.c=a.e=null:(a.c=[0],a.e=0)),a;for(b=O(X.e/u)+O(a.e/u),a.s*=X.s,x=q.length,I=Tt.length,x<I&&(Z=q,q=Tt,Tt=Z,g=x,x=I,I=g),g=x+I,Z=[];g--;Z.push(0));for(ht=c,xt=m,g=I;--g>=0;){for(l=0,F=Tt[g]%xt,$=Tt[g]/xt|0,v=x,_=g+v;_>g;)A=q[--v]%xt,E=q[v]/xt|0,d=$*A+E*F,A=F*A+d%xt*xt+Z[_]+l,l=(A/ht|0)+(d/xt|0)+$*E,Z[_--]=A%ht;Z[_]=l}return l?++b:Z.splice(0,1),Et(a,Z,b)},R.negated=function(){var a=new B(this);return a.s=-a.s||null,a},R.plus=function(a,f){var l,b=this,g=b.s;if(a=new B(a,f),f=a.s,!g||!f)return new B(NaN);if(g!=f)return a.s=-f,b.minus(a);var _=b.e/u,v=a.e/u,d=b.c,x=a.c;if(!_||!v){if(!d||!x)return new B(g/0);if(!d[0]||!x[0])return x[0]?a:new B(d[0]?b:g*0)}if(_=O(_),v=O(v),d=d.slice(),g=_-v){for(g>0?(v=_,l=x):(g=-g,l=d),l.reverse();g--;l.push(0));l.reverse()}for(g=d.length,f=x.length,g-f<0&&(l=x,x=d,d=l,f=g),g=0;f;)g=(d[--f]=d[f]+x[f]+g)/c|0,d[f]=c===d[f]?0:d[f]%c;return g&&(d=[g].concat(d),++v),Et(a,d,v)},R.precision=R.sd=function(a,f){var l,b,g,_=this;if(a!=null&&a!==!!a)return j(a,1,N),f==null?f=ot:j(f,0,8),gt(new B(_),a,f);if(!(l=_.c))return null;if(g=l.length-1,b=g*u+1,g=l[g]){for(;g%10==0;g/=10,b--);for(g=l[0];g>=10;g/=10,b++);}return a&&_.e+1>b&&(b=_.e+1),b},R.shiftedBy=function(a){return j(a,-w,w),this.times("1e"+a)},R.squareRoot=R.sqrt=function(){var a,f,l,b,g,_=this,v=_.c,d=_.s,x=_.e,A=st+4,E=new B("0.5");if(d!==1||!v||!v[0])return new B(!d||d<0&&(!v||v[0])?NaN:v?_:1/0);if(d=Math.sqrt(+k(_)),d==0||d==1/0?(f=G(v),(f.length+x)%2==0&&(f+="0"),d=Math.sqrt(+f),x=O((x+1)/2)-(x<0||x%2),d==1/0?f="5e"+x:(f=d.toExponential(),f=f.slice(0,f.indexOf("e")+1)+x),l=new B(f)):l=new B(d+""),l.c[0]){for(x=l.e,d=x+A,d<3&&(d=0);;)if(g=l,l=E.times(g.plus(H(_,g,A,1))),G(g.c).slice(0,d)===(f=G(l.c)).slice(0,d))if(l.e<x&&--d,f=f.slice(d-3,d+1),f=="9999"||!b&&f=="4999"){if(!b&&(gt(g,g.e+st+2,0),g.times(g).eq(_))){l=g;break}A+=4,d+=4,b=1}else{(!+f||!+f.slice(1)&&f.charAt(0)=="5")&&(gt(l,l.e+st+2,1),a=!l.times(l).eq(_));break}}return gt(l,l.e+st+1,ot,a)},R.toExponential=function(a,f){return a!=null&&(j(a,0,N),a++),h(this,a,f,1)},R.toFixed=function(a,f){return a!=null&&(j(a,0,N),a=a+this.e+1),h(this,a,f)},R.toFormat=function(a,f,l){var b,g=this;if(l==null)a!=null&&f&&typeof f=="object"?(l=f,f=null):a&&typeof a=="object"?(l=a,a=f=null):l=J;else if(typeof l!="object")throw Error(s+"Argument not an object: "+l);if(b=g.toFixed(a,f),g.c){var _,v=b.split("."),d=+l.groupSize,x=+l.secondaryGroupSize,A=l.groupSeparator||"",E=v[0],I=v[1],F=g.s<0,$=F?E.slice(1):E,Z=$.length;if(x&&(_=d,d=x,x=_,Z-=_),d>0&&Z>0){for(_=Z%d||d,E=$.substr(0,_);_<Z;_+=d)E+=A+$.substr(_,d);x>0&&(E+=A+$.slice(_)),F&&(E="-"+E)}b=I?E+(l.decimalSeparator||"")+((x=+l.fractionGroupSize)?I.replace(new RegExp("\\d{"+x+"}\\B","g"),"$&"+(l.fractionGroupSeparator||"")):I):E}return(l.prefix||"")+b+(l.suffix||"")},R.toFraction=function(a){var f,l,b,g,_,v,d,x,A,E,I,F,$=this,Z=$.c;if(a!=null&&(d=new B(a),!d.isInteger()&&(d.c||d.s!==1)||d.lt(it)))throw Error(s+"Argument "+(d.isInteger()?"out of range: ":"not an integer: ")+k(d));if(!Z)return new B($);for(f=new B(it),A=l=new B(it),b=x=new B(it),F=G(Z),_=f.e=F.length-$.e-1,f.c[0]=y[(v=_%u)<0?u+v:v],a=!a||d.comparedTo(f)>0?_>0?f:A:d,v=U,U=1/0,d=new B(F),x.c[0]=0;E=H(d,f,0,1),g=l.plus(E.times(b)),g.comparedTo(a)!=1;)l=b,b=g,A=x.plus(E.times(g=A)),x=g,f=d.minus(E.times(g=f)),d=g;return g=H(a.minus(l),b,0,1),x=x.plus(g.times(A)),l=l.plus(g.times(b)),x.s=A.s=$.s,_=_*2,I=H(A,b,_,ot).minus($).abs().comparedTo(H(x,l,_,ot).minus($).abs())<1?[A,b]:[x,l],U=v,I},R.toNumber=function(){return+k(this)},R.toPrecision=function(a,f){return a!=null&&j(a,1,N),h(this,a,f,2)},R.toString=function(a){var f,l=this,b=l.s,g=l.e;return g===null?b?(f="Infinity",b<0&&(f="-"+f)):f="NaN":(a==null?f=g<=wt||g>=Ot?z(G(l.c),g):yt(G(l.c),g,"0"):a===10&&ut?(l=gt(new B(l),st+g+1,ot),f=yt(G(l.c),l.e,"0")):(j(a,2,tt.length,"Base"),f=nt(yt(G(l.c),g,"0"),10,a,b,!0)),b<0&&l.c[0]&&(f="-"+f)),f},R.valueOf=R.toJSON=function(){return k(this)},R._isBigNumber=!0,C!=null&&B.set(C),B}function O(C){var H=C|0;return C>0||C===H?H:H-1}function G(C){for(var H,nt,Y=1,R=C.length,it=C[0]+"";Y<R;){for(H=C[Y++]+"",nt=u-H.length;nt--;H="0"+H);it+=H}for(R=it.length;it.charCodeAt(--R)===48;);return it.slice(0,R+1||1)}function lt(C,H){var nt,Y,R=C.c,it=H.c,st=C.s,ot=H.s,wt=C.e,Ot=H.e;if(!st||!ot)return null;if(nt=R&&!R[0],Y=it&&!it[0],nt||Y)return nt?Y?0:-ot:st;if(st!=ot)return st;if(nt=st<0,Y=wt==Ot,!R||!it)return Y?0:!R^nt?1:-1;if(!Y)return wt>Ot^nt?1:-1;for(ot=(wt=R.length)<(Ot=it.length)?wt:Ot,st=0;st<ot;st++)if(R[st]!=it[st])return R[st]>it[st]^nt?1:-1;return wt==Ot?0:wt>Ot^nt?1:-1}function j(C,H,nt,Y){if(C<H||C>nt||C!==i(C))throw Error(s+(Y||"Argument")+(typeof C=="number"?C<H||C>nt?" out of range: ":" not an integer: ":" not a primitive number: ")+String(C))}function W(C){var H=C.c.length-1;return O(C.e/u)==H&&C.c[H]%2!=0}function z(C,H){return(C.length>1?C.charAt(0)+"."+C.slice(1):C)+(H<0?"e":"e+")+H}function yt(C,H,nt){var Y,R;if(H<0){for(R=nt+".";++H;R+=nt);C=R+C}else if(Y=C.length,++H>Y){for(R=nt,H-=Y;--H;R+=nt);C+=R}else H<Y&&(C=C.slice(0,H)+"."+C.slice(H));return C}t=M(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd?define(function(){return t}):typeof _n<"u"&&_n.exports?_n.exports=t:(r||(r=typeof self<"u"&&self?self:window),r.BigNumber=t)})(aa)});var ua=Bt((gp,ca)=>{ca.exports=function(t,e,n){var i=new t.Uint8Array(n),s=e.pushInt,o=e.pushInt32,c=e.pushInt32Neg,u=e.pushInt64,w=e.pushInt64Neg,y=e.pushFloat,m=e.pushFloatSingle,N=e.pushFloatDouble,M=e.pushTrue,O=e.pushFalse,G=e.pushUndefined,lt=e.pushNull,j=e.pushInfinity,W=e.pushInfinityNeg,z=e.pushNaN,yt=e.pushNaNNeg,C=e.pushArrayStart,H=e.pushArrayStartFixed,nt=e.pushArrayStartFixed32,Y=e.pushArrayStartFixed64,R=e.pushObjectStart,it=e.pushObjectStartFixed,st=e.pushObjectStartFixed32,ot=e.pushObjectStartFixed64,wt=e.pushByteString,Ot=e.pushByteStringStart,V=e.pushUtf8String,U=e.pushUtf8StringStart,P=e.pushSimpleUnassigned,L=e.pushTagStart,K=e.pushTagStart4,J=e.pushTagStart8,tt=e.pushTagUnassigned,ut=e.pushBreak,B=t.Math.pow,h=0,mt=0,Et=0;function gt(p){for(p=p|0,h=0,mt=p;(h|0)<(mt|0)&&(Et=mu[i[h]&255](i[h]|0)|0,!((Et|0)>0)););return Et|0}function k(p){return p=p|0,((h|0)+(p|0)|0)<(mt|0)?0:1}function a(p){return p=p|0,i[p|0]<<8|i[p+1|0]|0}function f(p){return p=p|0,i[p|0]<<24|i[p+1|0]<<16|i[p+2|0]<<8|i[p+3|0]|0}function l(p){return p=p|0,s(p|0),h=h+1|0,0}function b(p){return p=p|0,k(1)|0?1:(s(i[h+1|0]|0),h=h+2|0,0)}function g(p){return p=p|0,k(2)|0?1:(s(a(h+1|0)|0),h=h+3|0,0)}function _(p){return p=p|0,k(4)|0?1:(o(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function v(p){return p=p|0,k(8)|0?1:(u(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function d(p){return p=p|0,s(-1-(p-32|0)|0),h=h+1|0,0}function x(p){return p=p|0,k(1)|0?1:(s(-1-(i[h+1|0]|0)|0),h=h+2|0,0)}function A(p){p=p|0;var et=0;return k(2)|0?1:(et=a(h+1|0)|0,s(-1-(et|0)|0),h=h+3|0,0)}function E(p){return p=p|0,k(4)|0?1:(c(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function I(p){return p=p|0,k(8)|0?1:(w(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function F(p){p=p|0;var et=0,rt=0,Q=0;return Q=p-64|0,k(Q|0)|0?1:(et=h+1|0,rt=(h+1|0)+(Q|0)|0,wt(et|0,rt|0),h=rt|0,0)}function $(p){p=p|0;var et=0,rt=0,Q=0;return k(1)|0||(Q=i[h+1|0]|0,et=h+2|0,rt=(h+2|0)+(Q|0)|0,k(Q+1|0)|0)?1:(wt(et|0,rt|0),h=rt|0,0)}function Z(p){p=p|0;var et=0,rt=0,Q=0;return k(2)|0||(Q=a(h+1|0)|0,et=h+3|0,rt=(h+3|0)+(Q|0)|0,k(Q+2|0)|0)?1:(wt(et|0,rt|0),h=rt|0,0)}function ht(p){p=p|0;var et=0,rt=0,Q=0;return k(4)|0||(Q=f(h+1|0)|0,et=h+5|0,rt=(h+5|0)+(Q|0)|0,k(Q+4|0)|0)?1:(wt(et|0,rt|0),h=rt|0,0)}function xt(p){return p=p|0,1}function X(p){return p=p|0,Ot(),h=h+1|0,0}function q(p){p=p|0;var et=0,rt=0,Q=0;return Q=p-96|0,k(Q|0)|0?1:(et=h+1|0,rt=(h+1|0)+(Q|0)|0,V(et|0,rt|0),h=rt|0,0)}function Tt(p){p=p|0;var et=0,rt=0,Q=0;return k(1)|0||(Q=i[h+1|0]|0,et=h+2|0,rt=(h+2|0)+(Q|0)|0,k(Q+1|0)|0)?1:(V(et|0,rt|0),h=rt|0,0)}function ve(p){p=p|0;var et=0,rt=0,Q=0;return k(2)|0||(Q=a(h+1|0)|0,et=h+3|0,rt=(h+3|0)+(Q|0)|0,k(Q+2|0)|0)?1:(V(et|0,rt|0),h=rt|0,0)}function $e(p){p=p|0;var et=0,rt=0,Q=0;return k(4)|0||(Q=f(h+1|0)|0,et=h+5|0,rt=(h+5|0)+(Q|0)|0,k(Q+4|0)|0)?1:(V(et|0,rt|0),h=rt|0,0)}function Sr(p){return p=p|0,1}function Zt(p){return p=p|0,U(),h=h+1|0,0}function at(p){return p=p|0,H(p-128|0),h=h+1|0,0}function Lt(p){return p=p|0,k(1)|0?1:(H(i[h+1|0]|0),h=h+2|0,0)}function Ct(p){return p=p|0,k(2)|0?1:(H(a(h+1|0)|0),h=h+3|0,0)}function _t(p){return p=p|0,k(4)|0?1:(nt(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function Zc(p){return p=p|0,k(8)|0?1:(Y(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function Qc(p){return p=p|0,C(),h=h+1|0,0}function bt(p){p=p|0;var et=0;return et=p-160|0,k(et|0)|0?1:(it(et|0),h=h+1|0,0)}function tu(p){return p=p|0,k(1)|0?1:(it(i[h+1|0]|0),h=h+2|0,0)}function eu(p){return p=p|0,k(2)|0?1:(it(a(h+1|0)|0),h=h+3|0,0)}function ru(p){return p=p|0,k(4)|0?1:(st(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function nu(p){return p=p|0,k(8)|0?1:(ot(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function iu(p){return p=p|0,R(),h=h+1|0,0}function Je(p){return p=p|0,L(p-192|0|0),h=h+1|0,0}function H0(p){return p=p|0,L(p|0),h=h+1|0,0}function G0(p){return p=p|0,L(p|0),h=h+1|0,0}function K0(p){return p=p|0,L(p|0),h=h+1|0,0}function D0(p){return p=p|0,L(p|0),h=h+1|0,0}function Pt(p){return p=p|0,L(p-192|0|0),h=h+1|0,0}function j0(p){return p=p|0,L(p|0),h=h+1|0,0}function W0(p){return p=p|0,L(p|0),h=h+1|0,0}function z0(p){return p=p|0,L(p|0),h=h+1|0,0}function su(p){return p=p|0,k(1)|0?1:(L(i[h+1|0]|0),h=h+2|0,0)}function ou(p){return p=p|0,k(2)|0?1:(L(a(h+1|0)|0),h=h+3|0,0)}function au(p){return p=p|0,k(4)|0?1:(K(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function cu(p){return p=p|0,k(8)|0?1:(J(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function St(p){return p=p|0,P((p|0)-224|0),h=h+1|0,0}function uu(p){return p=p|0,O(),h=h+1|0,0}function fu(p){return p=p|0,M(),h=h+1|0,0}function lu(p){return p=p|0,lt(),h=h+1|0,0}function hu(p){return p=p|0,G(),h=h+1|0,0}function du(p){return p=p|0,k(1)|0?1:(P(i[h+1|0]|0),h=h+2|0,0)}function pu(p){p=p|0;var et=0,rt=0,Q=1,rn=0,Br=0,Y0=0;return k(2)|0?1:(et=i[h+1|0]|0,rt=i[h+2|0]|0,(et|0)&128&&(Q=-1),rn=+(((et|0)&124)>>2),Br=+(((et|0)&3)<<8|rt),+rn==0?y(+(+Q*5960464477539063e-23*+Br)):+rn==31?+Q==1?+Br>0?z():j():+Br>0?yt():W():y(+(+Q*B(2,+(+rn-25))*+(1024+Br))),h=h+3|0,0)}function yu(p){return p=p|0,k(4)|0?1:(m(i[h+1|0]|0,i[h+2|0]|0,i[h+3|0]|0,i[h+4|0]|0),h=h+5|0,0)}function wu(p){return p=p|0,k(8)|0?1:(N(i[h+1|0]|0,i[h+2|0]|0,i[h+3|0]|0,i[h+4|0]|0,i[h+5|0]|0,i[h+6|0]|0,i[h+7|0]|0,i[h+8|0]|0),h=h+9|0,0)}function dt(p){return p=p|0,1}function gu(p){return p=p|0,ut(),h=h+1|0,0}var mu=[l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,b,g,_,v,dt,dt,dt,dt,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,x,A,E,I,dt,dt,dt,dt,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,$,Z,ht,xt,dt,dt,dt,X,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,Tt,ve,$e,Sr,dt,dt,dt,Zt,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,Lt,Ct,_t,Zc,dt,dt,dt,Qc,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,bt,tu,eu,ru,nu,dt,dt,dt,iu,Je,Je,Je,Je,Je,Je,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,Pt,su,ou,au,cu,dt,dt,dt,dt,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,uu,fu,lu,hu,du,pu,yu,wu,dt,dt,dt,gu];return{parse:gt}}});var Mr=Bt(Yt=>{"use strict";var ns=kr().BigNumber;Yt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Yt.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};Yt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Yt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Yt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Yt.SHIFT32=Math.pow(2,32);Yt.SHIFT16=Math.pow(2,16);Yt.MAX_SAFE_HIGH=2097151;Yt.NEG_ONE=new ns(-1);Yt.TEN=new ns(10);Yt.TWO=new ns(2);Yt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var bn=Bt(re=>{"use strict";var{Buffer:$f}=Pr(),la=kr().BigNumber,ha=Mr(),fa=ha.SHIFT32,Vf=ha.SHIFT16,Lf=2097151;re.parseHalf=function(t){var e,n,i;return i=t[0]&128?-1:1,e=(t[0]&124)>>2,n=(t[0]&3)<<8|t[1],e?e===31?i*(n?NaN:1/0):i*Math.pow(2,e-25)*(1024+n):i*5960464477539063e-23*n};function qf(r){return r<16?"0"+r.toString(16):r.toString(16)}re.arrayBufferToBignumber=function(r){let t=r.byteLength,e="";for(let n=0;n<t;n++)e+=qf(r[n]);return new la(e,16)};re.buildMap=r=>{let t=new Map,e=Object.keys(r),n=e.length;for(let i=0;i<n;i++)t.set(e[i],r[e[i]]);return t};re.buildInt32=(r,t)=>r*Vf+t;re.buildInt64=(r,t,e,n)=>{let i=re.buildInt32(r,t),s=re.buildInt32(e,n);return i>Lf?new la(i).times(fa).plus(s):i*fa+s};re.writeHalf=function(t,e){let n=$f.allocUnsafe(4);n.writeFloatBE(e,0);let i=n.readUInt32BE(0);if(i&8191)return!1;var s=i>>16&32768;let o=i>>23&255,c=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(c>>13);else if(o>=103&&o<113){if(c&(1<<126-o)-1)return!1;s+=c+8388608>>126-o}else return!1;return t.writeUInt16BE(s,0),!0};re.keySorter=function(r,t){var e=r[0].byteLength,n=t[0].byteLength;return e>n?1:n>e?-1:r[0].compare(t[0])};re.isNegativeZero=r=>r===0&&1/r<0;re.nextPowerOf2=r=>{let t=0;if(r&&!(r&r-1))return r;for(;r!==0;)r>>=1,t+=1;return 1<<t}});var as=Bt((_p,da)=>{"use strict";var os=Mr(),Hf=os.MT,En=os.SIMPLE,is=os.SYMS,ss=class r{constructor(t){if(typeof t!="number")throw new Error("Invalid Simple type: "+typeof t);if(t<0||t>255||(t|0)!==t)throw new Error("value must be a small positive integer: "+t);this.value=t}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(t){return t._pushInt(this.value,Hf.SIMPLE_FLOAT)}static isSimple(t){return t instanceof r}static decode(t,e){switch(e==null&&(e=!0),t){case En.FALSE:return!1;case En.TRUE:return!0;case En.NULL:return e?null:is.NULL;case En.UNDEFINED:return e?void 0:is.UNDEFINED;case-1:if(!e)throw new Error("Invalid BREAK");return is.BREAK;default:return new r(t)}}};da.exports=ss});var us=Bt((bp,pa)=>{"use strict";var cs=class r{constructor(t,e,n){if(this.tag=t,this.value=e,this.err=n,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(t){return t._pushTag(this.tag),t.pushAny(this.value)}convert(t){var e,n;if(n=t?.[this.tag],typeof n!="function"&&(n=r["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(r,this.value)}catch(i){return e=i,this.err=e,this}}};pa.exports=cs});var hs=Bt((Ep,wa)=>{"use strict";var ya=self.location?self.location.protocol+"//"+self.location.host:"",fs=self.URL,ls=class{constructor(t="",e=ya){this.super=new fs(t,e),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(t){this.super.hash=t}set host(t){this.super.host=t}set hostname(t){this.super.hostname=t}set href(t){this.super.href=t}set origin(t){this.super.origin=t}set password(t){this.super.password=t}set pathname(t){this.super.pathname=t}set port(t){this.super.port=t}set protocol(t){this.super.protocol=t}set search(t){this.super.search=t}set searchParams(t){this.super.searchParams=t}set username(t){this.super.username=t}createObjectURL(t){return this.super.createObjectURL(t)}revokeObjectURL(t){this.super.revokeObjectURL(t)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function Gf(r){if(typeof r=="string")return new fs(r).toString();if(!(r instanceof fs)){let t=r.username&&r.password?`${r.username}:${r.password}@`:"",e=r.auth?r.auth+"@":"",n=r.port?":"+r.port:"",i=r.protocol?r.protocol+"//":"",s=r.host||"",o=r.hostname||"",c=r.search||(r.query?"?"+r.query:""),u=r.hash||"",w=r.pathname||"",y=r.path||w+c;return`${i}${t||e}${s||o+n}${y}${u}`}}wa.exports={URLWithLegacySupport:ls,URLSearchParams:self.URLSearchParams,defaultBase:ya,format:Gf}});var xa=Bt((Ap,ma)=>{"use strict";var{URLWithLegacySupport:ga,format:Kf}=hs();ma.exports=(r,t={},e={},n)=>{let i=t.protocol?t.protocol.replace(":",""):"http";i=(e[i]||n||i)+":";let s;try{s=new ga(r)}catch{s={}}let o=Object.assign({},t,{protocol:i||s.protocol,host:t.host||s.host});return new ga(r,Kf(o)).toString()}});var ds=Bt((vp,_a)=>{"use strict";var{URLWithLegacySupport:Df,format:jf,URLSearchParams:Wf,defaultBase:zf}=hs(),Yf=xa();_a.exports={URL:Df,URLSearchParams:Wf,format:jf,relative:Yf,defaultBase:zf}});var ps=Bt((Tp,Ea)=>{"use strict";var{Buffer:hr}=Pr(),ba=sn(),Xf=kr().BigNumber,Jf=ua(),Vt=bn(),ft=Mr(),Zf=as(),Qf=us(),{URL:tl}=ds(),Cr=class r{constructor(t){t=t||{},!t.size||t.size<65536?t.size=65536:t.size=Vt.nextPowerOf2(t.size),this._heap=new ArrayBuffer(t.size),this._heap8=new Uint8Array(this._heap),this._buffer=hr.from(this._heap),this._reset(),this._knownTags=Object.assign({0:e=>new Date(e),1:e=>new Date(e*1e3),2:e=>Vt.arrayBufferToBignumber(e),3:e=>ft.NEG_ONE.minus(Vt.arrayBufferToBignumber(e)),4:e=>ft.TEN.pow(e[0]).times(e[1]),5:e=>ft.TWO.pow(e[0]).times(e[1]),32:e=>new tl(e),35:e=>new RegExp(e)},t.tags),this.parser=Jf(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 t=this._parents.pop();if(t.length>0)throw new Error(`Missing ${t.length} elements`);switch(t.type){case ft.PARENT.TAG:this._push(this.createTag(t.ref[0],t.ref[1]));break;case ft.PARENT.BYTE_STRING:this._push(this.createByteString(t.ref,t.length));break;case ft.PARENT.UTF8_STRING:this._push(this.createUtf8String(t.ref,t.length));break;case ft.PARENT.MAP:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(t.ref,t.length));break;case ft.PARENT.OBJECT:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(t.ref,t.length));break;case ft.PARENT.ARRAY:this._push(this.createArray(t.ref,t.length));break;default:break}this._currentParent&&this._currentParent.type===ft.PARENT.TAG&&this._dec()}_dec(){let t=this._currentParent;t.length<0||(t.length--,t.length===0&&this._closeParent())}_push(t,e){let n=this._currentParent;switch(n.values++,n.type){case ft.PARENT.ARRAY:case ft.PARENT.BYTE_STRING:case ft.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=t:this._ref.push(t),this._dec();break;case ft.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=t,n.tmpKey=null,this._dec()):(n.tmpKey=t,typeof n.tmpKey!="string"&&(n.type=ft.PARENT.MAP,n.ref=Vt.buildMap(n.ref)));break;case ft.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,t),n.tmpKey=null,this._dec()):n.tmpKey=t;break;case ft.PARENT.TAG:this._ref.push(t),e||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(t,e,n){this._parents[this._depth]={type:e,length:n,ref:t,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:ft.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(t,e){let n=this._knownTags[t];return n?n(e):new Qf(t,e)}createMap(t,e){return t}createObject(t,e){return t}createArray(t,e){return t}createByteString(t,e){return hr.concat(t)}createByteStringFromHeap(t,e){return t===e?hr.alloc(0):hr.from(this._heap.slice(t,e))}createInt(t){return t}createInt32(t,e){return Vt.buildInt32(t,e)}createInt64(t,e,n,i){return Vt.buildInt64(t,e,n,i)}createFloat(t){return t}createFloatSingle(t,e,n,i){return ba.read([t,e,n,i],0,!1,23,4)}createFloatDouble(t,e,n,i,s,o,c,u){return ba.read([t,e,n,i,s,o,c,u],0,!1,52,8)}createInt32Neg(t,e){return-1-Vt.buildInt32(t,e)}createInt64Neg(t,e,n,i){let s=Vt.buildInt32(t,e),o=Vt.buildInt32(n,i);return s>ft.MAX_SAFE_HIGH?ft.NEG_ONE.minus(new Xf(s).times(ft.SHIFT32).plus(o)):-1-(s*ft.SHIFT32+o)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(t,e){return t.join("")}createUtf8StringFromHeap(t,e){return t===e?"":this._buffer.toString("utf8",t,e)}createSimpleUnassigned(t){return new Zf(t)}pushInt(t){this._push(this.createInt(t))}pushInt32(t,e){this._push(this.createInt32(t,e))}pushInt64(t,e,n,i){this._push(this.createInt64(t,e,n,i))}pushFloat(t){this._push(this.createFloat(t))}pushFloatSingle(t,e,n,i){this._push(this.createFloatSingle(t,e,n,i))}pushFloatDouble(t,e,n,i,s,o,c,u){this._push(this.createFloatDouble(t,e,n,i,s,o,c,u))}pushInt32Neg(t,e){this._push(this.createInt32Neg(t,e))}pushInt64Neg(t,e,n,i){this._push(this.createInt64Neg(t,e,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([],ft.PARENT.ARRAY,-1)}pushArrayStartFixed(t){this._createArrayStartFixed(t)}pushArrayStartFixed32(t,e){let n=Vt.buildInt32(t,e);this._createArrayStartFixed(n)}pushArrayStartFixed64(t,e,n,i){let s=Vt.buildInt64(t,e,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(t){this._createObjectStartFixed(t)}pushObjectStartFixed32(t,e){let n=Vt.buildInt32(t,e);this._createObjectStartFixed(n)}pushObjectStartFixed64(t,e,n,i){let s=Vt.buildInt64(t,e,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:ft.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(t,e){this._push(this.createByteStringFromHeap(t,e))}pushUtf8StringStart(){this._parents[this._depth]={type:ft.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(t,e){this._push(this.createUtf8StringFromHeap(t,e))}pushSimpleUnassigned(t){this._push(this.createSimpleUnassigned(t))}pushTagStart(t){this._parents[this._depth]={type:ft.PARENT.TAG,length:1,ref:[t]}}pushTagStart4(t,e){this.pushTagStart(Vt.buildInt32(t,e))}pushTagStart8(t,e,n,i){this.pushTagStart(Vt.buildInt64(t,e,n,i))}pushTagUnassigned(t){this._push(this.createTag(t))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(t){if(t===0){this._push(this.createObject({}));return}this._createParent({},ft.PARENT.OBJECT,t)}_createArrayStartFixed(t){if(t===0){this._push(this.createArray([]));return}this._createParent(new Array(t),ft.PARENT.ARRAY,t)}_decode(t){if(t.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(t);let e=this.parser.parse(t.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(e>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(t){return this._decode(t),this._res[0]}decodeAll(t){return this._decode(t),this._res}static decode(t,e){return typeof t=="string"&&(t=hr.from(t,e||"hex")),new r({size:t.length}).decodeFirst(t)}static decodeAll(t,e){return typeof t=="string"&&(t=hr.from(t,e||"hex")),new r({size:t.length}).decodeAll(t)}};Cr.decodeFirst=Cr.decode;Ea.exports=Cr});var Ta=Bt((Sp,va)=>{"use strict";var{Buffer:ys}=Pr(),el=ps(),rl=bn(),ws=class r extends el{createTag(t,e){return`${t}(${e})`}createInt(t){return super.createInt(t).toString()}createInt32(t,e){return super.createInt32(t,e).toString()}createInt64(t,e,n,i){return super.createInt64(t,e,n,i).toString()}createInt32Neg(t,e){return super.createInt32Neg(t,e).toString()}createInt64Neg(t,e,n,i){return super.createInt64Neg(t,e,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(t){let e=super.createFloat(t);return rl.isNegativeZero(t)?"-0_1":`${e}_1`}createFloatSingle(t,e,n,i){return`${super.createFloatSingle(t,e,n,i)}_2`}createFloatDouble(t,e,n,i,s,o,c,u){return`${super.createFloatDouble(t,e,n,i,s,o,c,u)}_3`}createByteString(t,e){let n=t.join(", ");return e===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(t,e){return`h'${ys.from(super.createByteStringFromHeap(t,e)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(t){return`simple(${t})`}createArray(t,e){let n=super.createArray(t,e);return e===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(t,e){let n=super.createMap(t),i=Array.from(n.keys()).reduce(Aa(n),"");return e===-1?`{_ ${i}}`:`{${i}}`}createObject(t,e){let n=super.createObject(t),i=Object.keys(n).reduce(Aa(n),"");return e===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(t,e){let n=t.join(", ");return e===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(t,e){return`"${ys.from(super.createUtf8StringFromHeap(t,e)).toString("utf8")}"`}static diagnose(t,e){return typeof t=="string"&&(t=ys.from(t,e||"hex")),new r().decodeFirst(t)}};va.exports=ws;function Aa(r){return(t,e)=>t?`${t}, ${e}: ${r[e]}`:`${e}: ${r[e]}`}});var Ua=Bt((Bp,Na)=>{"use strict";var{Buffer:de}=Pr(),{URL:nl}=ds(),ms=kr().BigNumber,gs=bn(),Ut=Mr(),ie=Ut.MT,An=Ut.NUMBYTES,Sa=Ut.SHIFT32,Ba=Ut.SYMS,dr=Ut.TAG,il=Ut.MT.SIMPLE_FLOAT<<5|Ut.NUMBYTES.TWO,sl=Ut.MT.SIMPLE_FLOAT<<5|Ut.NUMBYTES.FOUR,ol=Ut.MT.SIMPLE_FLOAT<<5|Ut.NUMBYTES.EIGHT,al=Ut.MT.SIMPLE_FLOAT<<5|Ut.SIMPLE.TRUE,cl=Ut.MT.SIMPLE_FLOAT<<5|Ut.SIMPLE.FALSE,ul=Ut.MT.SIMPLE_FLOAT<<5|Ut.SIMPLE.UNDEFINED,Ia=Ut.MT.SIMPLE_FLOAT<<5|Ut.SIMPLE.NULL,fl=new ms("0x20000000000000"),ll=de.from("f97e00","hex"),hl=de.from("f9fc00","hex"),dl=de.from("f97c00","hex");function pl(r){return{}.toString.call(r).slice(8,-1)}var xs=class r{constructor(t){t=t||{},this.streaming=typeof t.stream=="function",this.onData=t.stream,this.semanticTypes=[[nl,this._pushUrl],[ms,this._pushBigNumber]];let e=t.genTypes||[],n=e.length;for(let i=0;i<n;i++)this.addSemanticType(e[i][0],e[i][1]);this._reset()}addSemanticType(t,e){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===t){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=e,o}return this.semanticTypes.push([t,e]),null}push(t){return t&&(this.result[this.offset]=t,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=t.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(t,e,n){return this.result[this.offset]=t,this.resultMethod[this.offset]=e,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(t){return this.pushWrite(t,1,1)}_pushUInt16BE(t){return this.pushWrite(t,2,2)}_pushUInt32BE(t){return this.pushWrite(t,3,4)}_pushDoubleBE(t){return this.pushWrite(t,4,8)}_pushNaN(){return this.push(ll)}_pushInfinity(t){let e=t<0?hl:dl;return this.push(e)}_pushFloat(t){let e=de.allocUnsafe(2);if(gs.writeHalf(e,t)&&gs.parseHalf(e)===t)return this._pushUInt8(il)&&this.push(e);let n=de.allocUnsafe(4);return n.writeFloatBE(t,0),n.readFloatBE(0)===t?this._pushUInt8(sl)&&this.push(n):this._pushUInt8(ol)&&this._pushDoubleBE(t)}_pushInt(t,e,n){let i=e<<5;return t<24?this._pushUInt8(i|t):t<=255?this._pushUInt8(i|An.ONE)&&this._pushUInt8(t):t<=65535?this._pushUInt8(i|An.TWO)&&this._pushUInt16BE(t):t<=4294967295?this._pushUInt8(i|An.FOUR)&&this._pushUInt32BE(t):t<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|An.EIGHT)&&this._pushUInt32BE(Math.floor(t/Sa))&&this._pushUInt32BE(t%Sa):e===ie.NEG_INT?this._pushFloat(n):this._pushFloat(t)}_pushIntNum(t){return t<0?this._pushInt(-t-1,ie.NEG_INT,t):this._pushInt(t,ie.POS_INT)}_pushNumber(t){switch(!1){case t===t:return this._pushNaN(t);case isFinite(t):return this._pushInfinity(t);case t%1!==0:return this._pushIntNum(t);default:return this._pushFloat(t)}}_pushString(t){let e=de.byteLength(t,"utf8");return this._pushInt(e,ie.UTF8_STRING)&&this.pushWrite(t,5,e)}_pushBoolean(t){return this._pushUInt8(t?al:cl)}_pushUndefined(t){return this._pushUInt8(ul)}_pushArray(t,e){let n=e.length;if(!t._pushInt(n,ie.ARRAY))return!1;for(let i=0;i<n;i++)if(!t.pushAny(e[i]))return!1;return!0}_pushTag(t){return this._pushInt(t,ie.TAG)}_pushDate(t,e){return t._pushTag(dr.DATE_EPOCH)&&t.pushAny(Math.round(e/1e3))}_pushBuffer(t,e){return t._pushInt(e.length,ie.BYTE_STRING)&&t.push(e)}_pushNoFilter(t,e){return t._pushBuffer(t,e.slice())}_pushRegexp(t,e){return t._pushTag(dr.REGEXP)&&t.pushAny(e.source)}_pushSet(t,e){if(!t._pushInt(e.size,ie.ARRAY))return!1;for(let n of e)if(!t.pushAny(n))return!1;return!0}_pushUrl(t,e){return t._pushTag(dr.URI)&&t.pushAny(e.format())}_pushBigint(t){let e=dr.POS_BIGINT;t.isNegative()&&(t=t.negated().minus(1),e=dr.NEG_BIGINT);let n=t.toString(16);n.length%2&&(n="0"+n);let i=de.from(n,"hex");return this._pushTag(e)&&this._pushBuffer(this,i)}_pushBigNumber(t,e){if(e.isNaN())return t._pushNaN();if(!e.isFinite())return t._pushInfinity(e.isNegative()?-1/0:1/0);if(e.isInteger())return t._pushBigint(e);if(!(t._pushTag(dr.DECIMAL_FRAC)&&t._pushInt(2,ie.ARRAY)))return!1;let n=e.decimalPlaces(),i=e.multipliedBy(new ms(10).pow(n));return t._pushIntNum(-n)?i.abs().isLessThan(fl)?t._pushIntNum(i.toNumber()):t._pushBigint(i):!1}_pushMap(t,e){return t._pushInt(e.size,ie.MAP)?this._pushRawMap(e.size,Array.from(e)):!1}_pushObject(t){if(!t)return this._pushUInt8(Ia);for(var e=this.semanticTypes.length,n=0;n<e;n++)if(t instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(t,this,t);var i=t.encodeCBOR;if(typeof i=="function")return i.call(t,this);var s=Object.keys(t),o=s.length;return this._pushInt(o,ie.MAP)?this._pushRawMap(o,s.map(c=>[c,t[c]])):!1}_pushRawMap(t,e){e=e.map(function(i){return i[0]=r.encode(i[0]),i}).sort(gs.keySorter);for(var n=0;n<t;n++)if(!this.push(e[n][0])||!this.pushAny(e[n][1]))return!1;return!0}write(t){return this.pushAny(t)}pushAny(t){var e=pl(t);switch(e){case"Number":return this._pushNumber(t);case"String":return this._pushString(t);case"Boolean":return this._pushBoolean(t);case"Object":return this._pushObject(t);case"Array":return this._pushArray(this,t);case"Uint8Array":return this._pushBuffer(this,de.isBuffer(t)?t:de.from(t));case"Null":return this._pushUInt8(Ia);case"Undefined":return this._pushUndefined(t);case"Map":return this._pushMap(this,t);case"Set":return this._pushSet(this,t);case"URL":return this._pushUrl(this,t);case"BigNumber":return this._pushBigNumber(this,t);case"Date":return this._pushDate(this,t);case"RegExp":return this._pushRegexp(this,t);case"Symbol":switch(t){case Ba.NULL:return this._pushObject(null);case Ba.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+t.toString())}default:throw new Error("Unknown type: "+typeof t+", "+(t?t.toString():""))}}finalize(){if(this.offset===0)return null;for(var t=this.result,e=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=e[o];var c=de.allocUnsafe(s),u=0,w=0;for(o=0;o<i;o++){switch(w=e[o],n[o]){case 0:t[o].copy(c,u);break;case 1:c.writeUInt8(t[o],u,!0);break;case 2:c.writeUInt16BE(t[o],u,!0);break;case 3:c.writeUInt32BE(t[o],u,!0);break;case 4:c.writeDoubleBE(t[o],u,!0);break;case 5:c.write(t[o],u,w,"utf8");break;default:throw new Error("unkown method")}u+=w}var y=c;return this._reset(),y}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(t){let e=new r;if(!e.pushAny(t))throw new Error("Failed to encode input");return e.finalize()}};Na.exports=xs});var vn=Bt(Rt=>{"use strict";Rt.Diagnose=Ta();Rt.Decoder=ps();Rt.Encoder=Ua();Rt.Simple=as();Rt.Tagged=us();Rt.decodeAll=Rt.Decoder.decodeAll;Rt.decodeFirst=Rt.Decoder.decodeFirst;Rt.diagnose=Rt.Diagnose.diagnose;Rt.encode=Rt.Encoder.encode;Rt.decode=Rt.Decoder.decode;Rt.leveldb={decode:Rt.Decoder.decodeAll,encode:Rt.Encoder.encode,buffer:!0,name:"cbor"}});function pe(...r){let t=new Uint8Array(r.reduce((n,i)=>n+i.byteLength,0)),e=0;for(let n of r)t.set(new Uint8Array(n),e),e+=n.byteLength;return t.buffer}function Nt(r){return[...new Uint8Array(r)].map(t=>t.toString(16).padStart(2,"0")).join("")}function Gt(r){if(!yl.test(r))throw new Error("Invalid hexadecimal string.");let t=[...r].reduce((e,n,i)=>(e[i/2|0]=(e[i/2|0]||"")+n,e),[]).map(e=>Number.parseInt(e,16));return new Uint8Array(t).buffer}function _s(r,t){if(r.byteLength!==t.byteLength)return r.byteLength-t.byteLength;let e=new Uint8Array(r),n=new Uint8Array(t);for(let i=0;i<e.length;i++)if(e[i]!==n[i])return e[i]-n[i];return 0}function $r(r,t){return _s(r,t)===0}function He(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}function Tn(r){return r instanceof Uint8Array?He(r):r instanceof ArrayBuffer?r:Array.isArray(r)?He(new Uint8Array(r)):"buffer"in r?Tn(r.buffer):He(new Uint8Array(r))}var yl,Xt=ct(()=>{yl=new RegExp(/^[0-9a-fA-F]+$/)});function Re(r){return He(Mo.create().update(new Uint8Array(r)).digest())}function Sn(r){if(r instanceof Ra.default.Tagged)return Sn(r.value);if(typeof r=="string")return Fa(r);if(typeof r=="number")return Re(Ue(r));if(r instanceof ArrayBuffer||ArrayBuffer.isView(r))return Re(r);if(Array.isArray(r)){let t=r.map(Sn);return Re(pe(...t))}else{if(r&&typeof r=="object"&&r._isPrincipal)return Re(r.toUint8Array());if(typeof r=="object"&&r!==null&&typeof r.toHash=="function")return Sn(r.toHash());if(typeof r=="object")return bs(r);if(typeof r=="bigint")return Re(Ue(r))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${r}`),{value:r})}function pr(r){return bs(r)}function bs(r){let n=Object.entries(r).filter(([,o])=>o!==void 0).map(([o,c])=>{let u=Fa(o),w=Sn(c);return[u,w]}).sort(([o],[c])=>_s(o,c)),i=pe(...n.map(o=>pe(...o)));return Re(i)}var Ra,Fa,Vr=ct(()=>{ur();Ra=Te(vn());Ui();Xt();Fa=r=>{let t=new TextEncoder().encode(r);return Re(t)}});var vs=Bt(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});var ml=9007199254740992;function Ee(r,...t){let e=new Uint8Array(r.byteLength+t.reduce((i,s)=>i+s.byteLength,0));e.set(new Uint8Array(r),0);let n=r.byteLength;for(let i of t)e.set(new Uint8Array(i),n),n+=i.byteLength;return e.buffer}function se(r,t,e){e=e.replace(/[^0-9a-fA-F]/g,"");let n=2**(t-24);e=e.slice(-n*2).padStart(n*2,"0");let i=[(r<<5)+t].concat(e.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function Bn(r,t){if(t<24)return new Uint8Array([(r<<5)+t]).buffer;{let e=t<=255?24:t<=65535?25:t<=4294967295?26:27;return se(r,e,t.toString(16))}}function Oa(r){let t=[];for(let e=0;e<r.length;e++){let n=r.charCodeAt(e);n<128?t.push(n):n<2048?t.push(192|n>>6,128|n&63):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|n&63):(e++,n=(n&1023)<<10|r.charCodeAt(e)&1023,t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return Ee(new Uint8Array(Bn(3,r.length)),new Uint8Array(t))}function xl(r,t){if(r==14277111)return Ee(new Uint8Array([217,217,247]),t);if(r<24)return Ee(new Uint8Array([192+r]),t);{let e=r<=255?24:r<=65535?25:r<=4294967295?26:27,n=2**(e-24),i=r.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+e].concat(i.match(/../g).map(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}pt.tagged=xl;function Lr(r){return new Uint8Array(r).buffer}pt.raw=Lr;function Es(r){if(isNaN(r))throw new RangeError("Invalid number.");r=Math.min(Math.max(0,r),23);let t=[0+r];return new Uint8Array(t).buffer}pt.uSmall=Es;function Pa(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),255),r=r.toString(16),se(0,24,r)}pt.u8=Pa;function ka(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),65535),r=r.toString(16),se(0,25,r)}pt.u16=ka;function Ma(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),4294967295),r=r.toString(16),se(0,26,r)}pt.u32=Ma;function As(r,t){if(typeof r=="string"&&t==16){if(r.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return se(0,27,r)}if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),ml),r=r.toString(16),se(0,27,r)}pt.u64=As;function Ca(r){if(isNaN(r))throw new RangeError("Invalid number.");if(r===0)return Es(0);r=Math.min(Math.max(0,-r),24)-1;let t=[32+r];return new Uint8Array(t).buffer}pt.iSmall=Ca;function $a(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),255),r=r.toString(16),se(1,24,r)}pt.i8=$a;function Va(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),65535),r=r.toString(16),se(1,25,r)}pt.i16=Va;function La(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),4294967295),r=r.toString(16),se(1,26,r)}pt.i32=La;function qa(r,t){if(typeof r=="string"&&t==16){if(r.startsWith("-")?r=r.slice(1):r="0",r.match(/[^0-9a-fA-F]/)||r.length>16)throw new RangeError("Invalid number.");let e=!1,n=r.split("").reduceRight((i,s)=>{if(e)return s+i;let o=parseInt(s,16)-1;return o>=0?(e=!0,o.toString(16)+i):"f"+i},"");return e?se(1,27,n):As(0)}if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),9007199254740992),r=r.toString(16),se(1,27,r)}pt.i64=qa;function _l(r){return r>=0?r<24?Es(r):r<=255?Pa(r):r<=65535?ka(r):r<=4294967295?Ma(r):As(r):r>=-24?Ca(r):r>=-255?$a(r):r>=-65535?Va(r):r>=-4294967295?La(r):qa(r)}pt.number=_l;function bl(r){return Ee(Bn(2,r.byteLength),r)}pt.bytes=bl;function El(r){return Oa(r)}pt.string=El;function Al(r){return Ee(Bn(4,r.length),...r)}pt.array=Al;function vl(r,t=!1){r instanceof Map||(r=new Map(Object.entries(r)));let e=Array.from(r.entries());return t&&(e=e.sort(([n],[i])=>n.localeCompare(i))),Ee(Bn(5,r.size),...e.map(([n,i])=>Ee(Oa(n),i)))}pt.map=vl;function Tl(r){let t=new Float32Array([r]);return Ee(new Uint8Array([250]),new Uint8Array(t.buffer))}pt.singleFloat=Tl;function Sl(r){let t=new Float64Array([r]);return Ee(new Uint8Array([251]),new Uint8Array(t.buffer))}pt.doubleFloat=Sl;function Bl(r){return r?Ha():Ga()}pt.bool=Bl;function Ha(){return Lr(new Uint8Array([245]))}pt.true_=Ha;function Ga(){return Lr(new Uint8Array([244]))}pt.false_=Ga;function Il(){return Lr(new Uint8Array([246]))}pt.null_=Il;function Nl(){return Lr(new Uint8Array([247]))}pt.undefined_=Nl});var Ka=Bt(Fe=>{"use strict";var Ul=Fe&&Fe.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t};Object.defineProperty(Fe,"__esModule",{value:!0});var oe=Ul(vs()),Rl=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],In=class{constructor(t,e=!1){this._serializer=t,this._stable=e,this.name="jsonDefault",this.priority=-100}match(t){return["undefined","boolean","number","string","object"].indexOf(typeof t)!=-1}encode(t){switch(typeof t){case"undefined":return oe.undefined_();case"boolean":return oe.bool(t);case"number":return Math.floor(t)===t?oe.number(t):oe.doubleFloat(t);case"string":return oe.string(t);case"object":if(t===null)return oe.null_();if(Array.isArray(t))return oe.array(t.map(e=>this._serializer.serializeValue(e)));if(Rl.find(e=>t instanceof e))return oe.bytes(t.buffer);if(Object.getOwnPropertyNames(t).indexOf("toJSON")!==-1)return this.encode(t.toJSON());if(t instanceof Map){let e=new Map;for(let[n,i]of t.entries())e.set(n,this._serializer.serializeValue(i));return oe.map(e,this._stable)}else{let e=new Map;for(let[n,i]of Object.entries(t))e.set(n,this._serializer.serializeValue(i));return oe.map(e,this._stable)}default:throw new Error("Invalid value.")}}};Fe.JsonDefaultCborEncoder=In;var Nn=class{constructor(){this.name="cborEncoder",this.priority=-90}match(t){return typeof t=="object"&&typeof t.toCBOR=="function"}encode(t){return t.toCBOR()}};Fe.ToCborEncoder=Nn;var Un=class{constructor(){this._encoders=new Set}static withDefaultEncoders(t=!1){let e=new this;return e.addEncoder(new In(e,t)),e.addEncoder(new Nn),e}removeEncoder(t){for(let e of this._encoders.values())e.name==t&&this._encoders.delete(e)}addEncoder(t){this._encoders.add(t)}getEncoderFor(t){let e=null;for(let n of this._encoders)(!e||n.priority>e.priority)&&n.match(t)&&(e=n);if(e===null)throw new Error("Could not find an encoder for value.");return e}serializeValue(t){return this.getEncoderFor(t).encode(t)}serialize(t){return this.serializeValue(t)}};Fe.CborSerializer=Un;var Ts=class extends Un{serialize(t){return oe.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(t))]))}};Fe.SelfDescribeCborSerializer=Ts});var qr=Bt(Ge=>{"use strict";function Fl(r){for(var t in r)Ge.hasOwnProperty(t)||(Ge[t]=r[t])}var Ol=Ge&&Ge.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t};Object.defineProperty(Ge,"__esModule",{value:!0});Fl(Ka());var Pl=Ol(vs());Ge.value=Pl});function Da(r){let t=r.byteLength,e=BigInt(0);for(let n=0;n<t;n++)e=e*BigInt(256)+BigInt(r[n]);return e}function Rn(r){let t=new Uint8Array(r),e=new Us({size:t.byteLength,tags:{2:n=>Da(n),3:n=>-Da(n),[Ns.Semantic]:n=>n}});try{return e.decodeFirst(t)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${Nt(t)}`)}}var ja,Ke,Wa,Ss,Bs,Is,Rs,Ns,Us,Hr=ct(()=>{ja=Te(vn()),Ke=Te(qr()),Wa=Te(qr());Xt();Ss=class{get name(){return"Principal"}get priority(){return 0}match(t){return t&&t._isPrincipal===!0}encode(t){return Ke.value.bytes(t.toUint8Array())}},Bs=class{get name(){return"Buffer"}get priority(){return 1}match(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)}encode(t){return Ke.value.bytes(new Uint8Array(t))}},Is=class{get name(){return"BigInt"}get priority(){return 1}match(t){return typeof t=="bigint"}encode(t){return t>BigInt(0)?Ke.value.tagged(2,Ke.value.bytes(Gt(t.toString(16)))):Ke.value.tagged(3,Ke.value.bytes(Gt((BigInt("-1")*t).toString(16))))}},Rs=Wa.SelfDescribeCborSerializer.withDefaultEncoders(!0);Rs.addEncoder(new Ss);Rs.addEncoder(new Bs);Rs.addEncoder(new Is);(function(r){r[r.Uint64LittleEndian=71]="Uint64LittleEndian",r[r.Semantic=55799]="Semantic"})(Ns||(Ns={}));Us=class extends ja.default.Decoder{createByteString(t){return pe(...t)}createByteStringFromHeap(t,e){return t===e?new ArrayBuffer(0):new Uint8Array(this._heap.slice(t,e))}}});function Ps(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function ks(r){if(!Ps(r))throw new Error("Uint8Array expected")}function Pn(r,t){if(typeof t!="boolean")throw new Error(`${r} must be valid boolean, got "${t}".`)}function kn(r){ks(r);let t="";for(let e=0;e<r.length;e++)t+=Vl[r[e]];return t}function Xa(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}function Ya(r){if(r>=Ae._0&&r<=Ae._9)return r-Ae._0;if(r>=Ae._A&&r<=Ae._F)return r-(Ae._A-10);if(r>=Ae._a&&r<=Ae._f)return r-(Ae._a-10)}function Ja(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let i=0,s=0;i<e;i++,s+=2){let o=Ya(r.charCodeAt(s)),c=Ya(r.charCodeAt(s+1));if(o===void 0||c===void 0){let u=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+s)}n[i]=o*16+c}return n}function Za(r){return Xa(kn(r))}function wr(r){return ks(r),Xa(kn(Uint8Array.from(r).reverse()))}function Ms(r,t){return Ja(r.toString(16).padStart(t*2,"0"))}function Kr(r,t){return Ms(r,t).reverse()}function ye(r,t,e){let n;if(typeof t=="string")try{n=Ja(t)}catch(s){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${s}`)}else if(Ps(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let i=n.length;if(typeof e=="number"&&i!==e)throw new Error(`${r} expected ${e} bytes, got ${i}`);return n}function Cs(...r){let t=0;for(let n=0;n<r.length;n++){let i=r[n];ks(i),t+=i.length}let e=new Uint8Array(t);for(let n=0,i=0;n<r.length;n++){let s=r[n];e.set(s,i),i+=s.length}return e}function Ll(r,t,e){return Os(r)&&Os(t)&&Os(e)&&t<=r&&r<e}function gr(r,t,e,n){if(!Ll(t,e,n))throw new Error(`expected valid ${r}: ${e} <= n < ${n}, got ${typeof t} ${t}`)}function mr(r,t,e={}){let n=(i,s,o)=>{let c=ql[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);let u=r[i];if(!(o&&u===void 0)&&!c(u,r))throw new Error(`Invalid param ${String(i)}=${u} (${typeof u}), expected ${s}`)};for(let[i,s]of Object.entries(t))n(i,s,!1);for(let[i,s]of Object.entries(e))n(i,s,!0);return r}function $s(r){let t=new WeakMap;return(e,...n)=>{let i=t.get(e);if(i!==void 0)return i;let s=r(e,...n);return t.set(e,s),s}}var Ml,Cl,$l,Vl,Ae,Os,Qa,ql,Dr=ct(()=>{Ml=BigInt(0),Cl=BigInt(1),$l=BigInt(2);Vl=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));Ae={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};Os=r=>typeof r=="bigint"&&Ml<=r;Qa=r=>($l<<BigInt(r-1))-Cl,ql={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Ps(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)}});function vt(r,t){let e=r%t;return e>=Ft?e:t+e}function jl(r,t,e){if(e<=Ft||t<Ft)throw new Error("Expected power/modulo > 0");if(e===At)return Ft;let n=At;for(;t>Ft;)t&At&&(n=n*r%e),r=r*r%e,t>>=At;return n}function ae(r,t,e){let n=r;for(;t-- >Ft;)n*=n,n%=e;return n}function rc(r,t){if(r===Ft||t<=Ft)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=vt(r,t),n=t,i=Ft,s=At,o=At,c=Ft;for(;e!==Ft;){let w=n/e,y=n%e,m=i-o*w,N=s-c*w;n=e,e=y,i=o,s=c,o=m,c=N}if(n!==At)throw new Error("invert: does not exist");return vt(i,t)}function Wl(r){let t=(r-At)/De,e,n,i;for(e=r-At,n=0;e%De===Ft;e/=De,n++);for(i=De;i<r&&jl(i,t,r)!==r-At;i++);if(n===1){let o=(r+At)/Vs;return function(u,w){let y=u.pow(w,o);if(!u.eql(u.sqr(y),w))throw new Error("Cannot find square root");return y}}let s=(e+At)/De;return function(c,u){if(c.pow(u,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let w=n,y=c.pow(c.mul(c.ONE,i),e),m=c.pow(u,s),N=c.pow(u,e);for(;!c.eql(N,c.ONE);){if(c.eql(N,c.ZERO))return c.ZERO;let M=1;for(let G=c.sqr(N);M<w&&!c.eql(G,c.ONE);M++)G=c.sqr(G);let O=c.pow(y,At<<BigInt(w-M-1));y=c.sqr(O),m=c.mul(m,O),N=c.mul(N,y),w=M}return m}}function zl(r){if(r%Vs===Gl){let t=(r+At)/Vs;return function(n,i){let s=n.pow(i,t);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(r%ec===tc){let t=(r-tc)/ec;return function(n,i){let s=n.mul(i,De),o=n.pow(s,t),c=n.mul(i,o),u=n.mul(n.mul(c,De),o),w=n.mul(c,n.sub(u,n.ONE));if(!n.eql(n.sqr(w),i))throw new Error("Cannot find square root");return w}}return r%Dl,Wl(r)}function ic(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Yl.reduce((n,i)=>(n[i]="function",n),t);return mr(r,e)}function Xl(r,t,e){if(e<Ft)throw new Error("Expected power > 0");if(e===Ft)return r.ONE;if(e===At)return t;let n=r.ONE,i=t;for(;e>Ft;)e&At&&(n=r.mul(n,i)),i=r.sqr(i),e>>=At;return n}function Jl(r,t){let e=new Array(t.length),n=t.reduce((s,o,c)=>r.is0(o)?s:(e[c]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return t.reduceRight((s,o,c)=>r.is0(o)?s:(e[c]=r.mul(s,e[c]),r.mul(s,o)),i),e}function Ls(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function sc(r,t,e=!1,n={}){if(r<=Ft)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:i,nByteLength:s}=Ls(r,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=zl(r),c=Object.freeze({ORDER:r,BITS:i,BYTES:s,MASK:Qa(i),ZERO:Ft,ONE:At,create:u=>vt(u,r),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return Ft<=u&&u<r},is0:u=>u===Ft,isOdd:u=>(u&At)===At,neg:u=>vt(-u,r),eql:(u,w)=>u===w,sqr:u=>vt(u*u,r),add:(u,w)=>vt(u+w,r),sub:(u,w)=>vt(u-w,r),mul:(u,w)=>vt(u*w,r),pow:(u,w)=>Xl(c,u,w),div:(u,w)=>vt(u*rc(w,r),r),sqrN:u=>u*u,addN:(u,w)=>u+w,subN:(u,w)=>u-w,mulN:(u,w)=>u*w,inv:u=>rc(u,r),sqrt:n.sqrt||(u=>o(c,u)),invertBatch:u=>Jl(c,u),cmov:(u,w,y)=>y?w:u,toBytes:u=>e?Kr(u,s):Ms(u,s),fromBytes:u=>{if(u.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${u.length}`);return e?wr(u):Za(u)}});return Object.freeze(c)}var Ft,At,De,Gl,Vs,tc,ec,Kl,Dl,nc,Yl,Mn=ct(()=>{Dr();Ft=BigInt(0),At=BigInt(1),De=BigInt(2),Gl=BigInt(3),Vs=BigInt(4),tc=BigInt(5),ec=BigInt(8),Kl=BigInt(9),Dl=BigInt(16);nc=(r,t)=>(vt(r,t)&At)===At,Yl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"]});function ac(r,t){let e=(s,o)=>{let c=o.negate();return s?c:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error(`Wrong window size=${s}, should be [1..${t}]`)},i=s=>{n(s);let o=Math.ceil(t/s)+1,c=2**(s-1);return{windows:o,windowSize:c}};return{constTimeNegate:e,unsafeLadder(s,o){let c=r.ZERO,u=s;for(;o>Zl;)o&qs&&(c=c.add(u)),u=u.double(),o>>=qs;return c},precomputeWindow(s,o){let{windows:c,windowSize:u}=i(o),w=[],y=s,m=y;for(let N=0;N<c;N++){m=y,w.push(m);for(let M=1;M<u;M++)m=m.add(y),w.push(m);y=m.double()}return w},wNAF(s,o,c){let{windows:u,windowSize:w}=i(s),y=r.ZERO,m=r.BASE,N=BigInt(2**s-1),M=2**s,O=BigInt(s);for(let G=0;G<u;G++){let lt=G*w,j=Number(c&N);c>>=O,j>w&&(j-=M,c+=qs);let W=lt,z=lt+Math.abs(j)-1,yt=G%2!==0,C=j<0;j===0?m=m.add(e(yt,o[W])):y=y.add(e(C,o[z]))}return{p:y,f:m}},wNAFCached(s,o,c){let u=oc.get(s)||1,w=Hs.get(s);return w||(w=this.precomputeWindow(s,u),u!==1&&Hs.set(s,c(w))),this.wNAF(u,w,o)},setWindowSize(s,o){n(o),oc.set(s,o),Hs.delete(s)}}}function cc(r){return ic(r.Fp),mr(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ls(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Zl,qs,Hs,oc,uc=ct(()=>{Mn();Dr();Zl=BigInt(0),qs=BigInt(1),Hs=new WeakMap,oc=new WeakMap});var Gs=ct(()=>{Xt()});var Cn=ct(()=>{ur()});var fc,dy,$n,lc,jr=ct(()=>{Hr();ir();Vr();Xt();te();Gs();Cn();(function(r){r[r.Empty=0]="Empty",r[r.Fork=1]="Fork",r[r.Labeled=2]="Labeled",r[r.Leaf=3]="Leaf",r[r.Pruned=4]="Pruned"})(fc||(fc={}));dy=Gt("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100");(function(r){r.Unknown="unknown",r.Absent="absent",r.Found="found"})($n||($n={}));(function(r){r.Less="less",r.Greater="greater"})(lc||(lc={}))});var Vn=ct(()=>{te();ir();jr();Xt();Hr();Cn()});var a0=Te(vo());var Ai;(function(r){r[r.SysFatal=1]="SysFatal",r[r.SysTransient=2]="SysTransient",r[r.DestinationInvalid=3]="DestinationInvalid",r[r.CanisterReject=4]="CanisterReject",r[r.CanisterError=5]="CanisterError"})(Ai||(Ai={}));te();ir();te();Vr();Xt();var wl=function(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(e[n[i]]=r[n[i]]);return e},gl=new TextEncoder().encode(`
2
- ic-request`),be=class{getPrincipal(){return this._principal||(this._principal=It.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(t){let{body:e}=t,n=wl(t,["body"]),i=await pr(e);return Object.assign(Object.assign({},n),{body:{content:e,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(pe(gl,i))}})}},yr=class{getPrincipal(){return It.anonymous()}async transformRequest(t){return Object.assign(Object.assign({},t),{body:{content:t.body}})}};Hr();Vr();Xt();ur();var kl=Te(qr());var Fs;(function(r){r.Call="call"})(Fs||(Fs={}));var zp=BigInt(1e6),Yp=60*1e3;function On(r){let t=[];return r.forEach((e,n)=>{t.push([n,e])}),t}ir();var Gr=class extends ee{constructor(t,e){super(t),this.response=e,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Vn();jr();Ii();var Ln=BigInt(4294967295),Ks=BigInt(32);function pc(r,t=!1){return t?{h:Number(r&Ln),l:Number(r>>Ks&Ln)}:{h:Number(r>>Ks&Ln)|0,l:Number(r&Ln)|0}}function nh(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){let{h:s,l:o}=pc(r[i],t);[e[i],n[i]]=[s,o]}return[e,n]}var ih=(r,t)=>BigInt(r>>>0)<<Ks|BigInt(t>>>0),sh=(r,t,e)=>r>>>e,oh=(r,t,e)=>r<<32-e|t>>>e,ah=(r,t,e)=>r>>>e|t<<32-e,ch=(r,t,e)=>r<<32-e|t>>>e,uh=(r,t,e)=>r<<64-e|t>>>e-32,fh=(r,t,e)=>r>>>e-32|t<<64-e,lh=(r,t)=>t,hh=(r,t)=>r,dh=(r,t,e)=>r<<e|t>>>32-e,ph=(r,t,e)=>t<<e|r>>>32-e,yh=(r,t,e)=>t<<e-32|r>>>64-e,wh=(r,t,e)=>r<<e-32|t>>>64-e;function gh(r,t,e,n){let i=(t>>>0)+(n>>>0);return{h:r+e+(i/2**32|0)|0,l:i|0}}var mh=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),xh=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,_h=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),bh=(r,t,e,n,i)=>t+e+n+i+(r/2**32|0)|0,Eh=(r,t,e,n,i)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(i>>>0),Ah=(r,t,e,n,i,s)=>t+e+n+i+s+(r/2**32|0)|0;var vh={fromBig:pc,split:nh,toBig:ih,shrSH:sh,shrSL:oh,rotrSH:ah,rotrSL:ch,rotrBH:uh,rotrBL:fh,rotr32H:lh,rotr32L:hh,rotlSH:dh,rotlSL:ph,rotlBH:yh,rotlBL:wh,add:gh,add3L:mh,add3H:xh,add4L:_h,add4H:bh,add5H:Ah,add5L:Eh},D=vh;Ur();var[Th,Sh]=D.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(r=>BigInt(r))),Oe=new Uint32Array(80),Pe=new Uint32Array(80),Ds=class extends nr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:i,Ch:s,Cl:o,Dh:c,Dl:u,Eh:w,El:y,Fh:m,Fl:N,Gh:M,Gl:O,Hh:G,Hl:lt}=this;return[t,e,n,i,s,o,c,u,w,y,m,N,M,O,G,lt]}set(t,e,n,i,s,o,c,u,w,y,m,N,M,O,G,lt){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=c|0,this.Dl=u|0,this.Eh=w|0,this.El=y|0,this.Fh=m|0,this.Fl=N|0,this.Gh=M|0,this.Gl=O|0,this.Hh=G|0,this.Hl=lt|0}process(t,e){for(let z=0;z<16;z++,e+=4)Oe[z]=t.getUint32(e),Pe[z]=t.getUint32(e+=4);for(let z=16;z<80;z++){let yt=Oe[z-15]|0,C=Pe[z-15]|0,H=D.rotrSH(yt,C,1)^D.rotrSH(yt,C,8)^D.shrSH(yt,C,7),nt=D.rotrSL(yt,C,1)^D.rotrSL(yt,C,8)^D.shrSL(yt,C,7),Y=Oe[z-2]|0,R=Pe[z-2]|0,it=D.rotrSH(Y,R,19)^D.rotrBH(Y,R,61)^D.shrSH(Y,R,6),st=D.rotrSL(Y,R,19)^D.rotrBL(Y,R,61)^D.shrSL(Y,R,6),ot=D.add4L(nt,st,Pe[z-7],Pe[z-16]),wt=D.add4H(ot,H,it,Oe[z-7],Oe[z-16]);Oe[z]=wt|0,Pe[z]=ot|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:c,Cl:u,Dh:w,Dl:y,Eh:m,El:N,Fh:M,Fl:O,Gh:G,Gl:lt,Hh:j,Hl:W}=this;for(let z=0;z<80;z++){let yt=D.rotrSH(m,N,14)^D.rotrSH(m,N,18)^D.rotrBH(m,N,41),C=D.rotrSL(m,N,14)^D.rotrSL(m,N,18)^D.rotrBL(m,N,41),H=m&M^~m&G,nt=N&O^~N&lt,Y=D.add5L(W,C,nt,Sh[z],Pe[z]),R=D.add5H(Y,j,yt,H,Th[z],Oe[z]),it=Y|0,st=D.rotrSH(n,i,28)^D.rotrBH(n,i,34)^D.rotrBH(n,i,39),ot=D.rotrSL(n,i,28)^D.rotrBL(n,i,34)^D.rotrBL(n,i,39),wt=n&s^n&c^s&c,Ot=i&o^i&u^o&u;j=G|0,W=lt|0,G=M|0,lt=O|0,M=m|0,O=N|0,{h:m,l:N}=D.add(w|0,y|0,R|0,it|0),w=c|0,y=u|0,c=s|0,u=o|0,s=n|0,o=i|0;let V=D.add3L(it,ot,Ot);n=D.add3H(V,R,st,wt),i=V|0}({h:n,l:i}=D.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=D.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:c,l:u}=D.add(this.Ch|0,this.Cl|0,c|0,u|0),{h:w,l:y}=D.add(this.Dh|0,this.Dl|0,w|0,y|0),{h:m,l:N}=D.add(this.Eh|0,this.El|0,m|0,N|0),{h:M,l:O}=D.add(this.Fh|0,this.Fl|0,M|0,O|0),{h:G,l:lt}=D.add(this.Gh|0,this.Gl|0,G|0,lt|0),{h:j,l:W}=D.add(this.Hh|0,this.Hl|0,j|0,W|0),this.set(n,i,s,o,c,u,w,y,m,N,M,O,G,lt,j,W)}roundClean(){Oe.fill(0),Pe.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)}};var yc=Nr(()=>new Ds);Ur();uc();Mn();Dr();Dr();var ce=BigInt(0),Kt=BigInt(1),qn=BigInt(2),Bh=BigInt(8),Ih={zip215:!0};function Nh(r){let t=cc(r);return mr(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function wc(r){let t=Nh(r),{Fp:e,n,prehash:i,hash:s,randomBytes:o,nByteLength:c,h:u}=t,w=qn<<BigInt(c*8)-Kt,y=e.create,m=t.uvRatio||((V,U)=>{try{return{isValid:!0,value:e.sqrt(V*e.inv(U))}}catch{return{isValid:!1,value:ce}}}),N=t.adjustScalarBytes||(V=>V),M=t.domain||((V,U,P)=>{if(Pn("phflag",P),U.length||P)throw new Error("Contexts/pre-hash are not supported");return V});function O(V,U){gr("coordinate "+V,U,ce,w)}function G(V){if(!(V instanceof W))throw new Error("ExtendedPoint expected")}let lt=$s((V,U)=>{let{ex:P,ey:L,ez:K}=V,J=V.is0();U==null&&(U=J?Bh:e.inv(K));let tt=y(P*U),ut=y(L*U),B=y(K*U);if(J)return{x:ce,y:Kt};if(B!==Kt)throw new Error("invZ was invalid");return{x:tt,y:ut}}),j=$s(V=>{let{a:U,d:P}=t;if(V.is0())throw new Error("bad point: ZERO");let{ex:L,ey:K,ez:J,et:tt}=V,ut=y(L*L),B=y(K*K),h=y(J*J),mt=y(h*h),Et=y(ut*U),gt=y(h*y(Et+B)),k=y(mt+y(P*y(ut*B)));if(gt!==k)throw new Error("bad point: equation left != right (1)");let a=y(L*K),f=y(J*tt);if(a!==f)throw new Error("bad point: equation left != right (2)");return!0});class W{constructor(U,P,L,K){this.ex=U,this.ey=P,this.ez=L,this.et=K,O("x",U),O("y",P),O("z",L),O("t",K),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(U){if(U instanceof W)throw new Error("extended point not allowed");let{x:P,y:L}=U||{};return O("x",P),O("y",L),new W(P,L,Kt,y(P*L))}static normalizeZ(U){let P=e.invertBatch(U.map(L=>L.ez));return U.map((L,K)=>L.toAffine(P[K])).map(W.fromAffine)}_setWindowSize(U){C.setWindowSize(this,U)}assertValidity(){j(this)}equals(U){G(U);let{ex:P,ey:L,ez:K}=this,{ex:J,ey:tt,ez:ut}=U,B=y(P*ut),h=y(J*K),mt=y(L*ut),Et=y(tt*K);return B===h&&mt===Et}is0(){return this.equals(W.ZERO)}negate(){return new W(y(-this.ex),this.ey,this.ez,y(-this.et))}double(){let{a:U}=t,{ex:P,ey:L,ez:K}=this,J=y(P*P),tt=y(L*L),ut=y(qn*y(K*K)),B=y(U*J),h=P+L,mt=y(y(h*h)-J-tt),Et=B+tt,gt=Et-ut,k=B-tt,a=y(mt*gt),f=y(Et*k),l=y(mt*k),b=y(gt*Et);return new W(a,f,b,l)}add(U){G(U);let{a:P,d:L}=t,{ex:K,ey:J,ez:tt,et:ut}=this,{ex:B,ey:h,ez:mt,et:Et}=U;if(P===BigInt(-1)){let E=y((J-K)*(h+B)),I=y((J+K)*(h-B)),F=y(I-E);if(F===ce)return this.double();let $=y(tt*qn*Et),Z=y(ut*qn*mt),ht=Z+$,xt=I+E,X=Z-$,q=y(ht*F),Tt=y(xt*X),ve=y(ht*X),$e=y(F*xt);return new W(q,Tt,$e,ve)}let gt=y(K*B),k=y(J*h),a=y(ut*L*Et),f=y(tt*mt),l=y((K+J)*(B+h)-gt-k),b=f-a,g=f+a,_=y(k-P*gt),v=y(l*b),d=y(g*_),x=y(l*_),A=y(b*g);return new W(v,d,A,x)}subtract(U){return this.add(U.negate())}wNAF(U){return C.wNAFCached(this,U,W.normalizeZ)}multiply(U){let P=U;gr("scalar",P,Kt,n);let{p:L,f:K}=this.wNAF(P);return W.normalizeZ([L,K])[0]}multiplyUnsafe(U){let P=U;return gr("scalar",P,ce,n),P===ce?yt:this.equals(yt)||P===Kt?this:this.equals(z)?this.wNAF(P).p:C.unsafeLadder(this,P)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return C.unsafeLadder(this,n).is0()}toAffine(U){return lt(this,U)}clearCofactor(){let{h:U}=t;return U===Kt?this:this.multiplyUnsafe(U)}static fromHex(U,P=!1){let{d:L,a:K}=t,J=e.BYTES;U=ye("pointHex",U,J),Pn("zip215",P);let tt=U.slice(),ut=U[J-1];tt[J-1]=ut&-129;let B=wr(tt),h=P?w:e.ORDER;gr("pointHex.y",B,ce,h);let mt=y(B*B),Et=y(mt-Kt),gt=y(L*mt-K),{isValid:k,value:a}=m(Et,gt);if(!k)throw new Error("Point.fromHex: invalid y coordinate");let f=(a&Kt)===Kt,l=(ut&128)!==0;if(!P&&a===ce&&l)throw new Error("Point.fromHex: x=0 and x_0=1");return l!==f&&(a=y(-a)),W.fromAffine({x:a,y:B})}static fromPrivateKey(U){return Y(U).point}toRawBytes(){let{x:U,y:P}=this.toAffine(),L=Kr(P,e.BYTES);return L[L.length-1]|=U&Kt?128:0,L}toHex(){return kn(this.toRawBytes())}}W.BASE=new W(t.Gx,t.Gy,Kt,y(t.Gx*t.Gy)),W.ZERO=new W(ce,Kt,Kt,ce);let{BASE:z,ZERO:yt}=W,C=ac(W,c*8);function H(V){return vt(V,n)}function nt(V){return H(wr(V))}function Y(V){let U=c;V=ye("private key",V,U);let P=ye("hashed private key",s(V),2*U),L=N(P.slice(0,U)),K=P.slice(U,2*U),J=nt(L),tt=z.multiply(J),ut=tt.toRawBytes();return{head:L,prefix:K,scalar:J,point:tt,pointBytes:ut}}function R(V){return Y(V).pointBytes}function it(V=new Uint8Array,...U){let P=Cs(...U);return nt(s(M(P,ye("context",V),!!i)))}function st(V,U,P={}){V=ye("message",V),i&&(V=i(V));let{prefix:L,scalar:K,pointBytes:J}=Y(U),tt=it(P.context,L,V),ut=z.multiply(tt).toRawBytes(),B=it(P.context,ut,J,V),h=H(tt+B*K);gr("signature.s",h,ce,n);let mt=Cs(ut,Kr(h,e.BYTES));return ye("result",mt,c*2)}let ot=Ih;function wt(V,U,P,L=ot){let{context:K,zip215:J}=L,tt=e.BYTES;V=ye("signature",V,2*tt),U=ye("message",U),J!==void 0&&Pn("zip215",J),i&&(U=i(U));let ut=wr(V.slice(tt,2*tt)),B,h,mt;try{B=W.fromHex(P,J),h=W.fromHex(V.slice(0,tt),J),mt=z.multiplyUnsafe(ut)}catch{return!1}if(!J&&B.isSmallOrder())return!1;let Et=it(K,h.toRawBytes(),B.toRawBytes(),U);return h.add(B.multiplyUnsafe(Et)).subtract(mt).clearCofactor().equals(W.ZERO)}return z._setWindowSize(8),{CURVE:t,getPublicKey:R,sign:st,verify:wt,ExtendedPoint:W,utils:{getExtendedPublicKey:Y,randomPrivateKey:()=>o(e.BYTES),precompute(V=8,U=W.BASE){return U._setWindowSize(V),U.multiply(BigInt(3)),U}}}}Mn();var js=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),gc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),$y=BigInt(0),Uh=BigInt(1),mc=BigInt(2),Vy=BigInt(3),Rh=BigInt(5),Fh=BigInt(8);function Oh(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),i=BigInt(80),s=js,c=r*r%s*r%s,u=ae(c,mc,s)*c%s,w=ae(u,Uh,s)*r%s,y=ae(w,Rh,s)*w%s,m=ae(y,t,s)*y%s,N=ae(m,e,s)*m%s,M=ae(N,n,s)*N%s,O=ae(M,i,s)*M%s,G=ae(O,i,s)*M%s,lt=ae(G,t,s)*y%s;return{pow_p_5_8:ae(lt,mc,s)*r%s,b2:c}}function Ph(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function kh(r,t){let e=js,n=vt(t*t*t,e),i=vt(n*n*t,e),s=Oh(r*i).pow_p_5_8,o=vt(r*n*s,e),c=vt(t*o*o,e),u=o,w=vt(o*gc,e),y=c===r,m=c===vt(-r,e),N=c===vt(-r*gc,e);return y&&(o=u),(m||N)&&(o=w),nc(o,e)&&(o=vt(-o,e)),{isValid:y||m,value:o}}var Mh=sc(js,void 0,!0),Ch={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Mh,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Fh,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:yc,randomBytes:Oo,adjustScalarBytes:Ph,uvRatio:kh},xr=wc(Ch);var $h,Vh,Lh,qh;$h=new WeakMap,Vh=new WeakMap,Lh=Symbol.iterator,qh=Symbol.toStringTag;Xt();var xc=r=>{if(r<=127)return 1;if(r<=255)return 2;if(r<=65535)return 3;if(r<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},_c=(r,t,e)=>{if(e<=127)return r[t]=e,1;if(e<=255)return r[t]=129,r[t+1]=e,2;if(e<=65535)return r[t]=130,r[t+1]=e>>8,r[t+2]=e,3;if(e<=16777215)return r[t]=131,r[t+1]=e>>16,r[t+2]=e>>8,r[t+3]=e,4;throw new Error("Length too long (> 4 bytes)")},Ws=(r,t)=>{if(r[t]<128)return 1;if(r[t]===128)throw new Error("Invalid length 0");if(r[t]===129)return 2;if(r[t]===130)return 3;if(r[t]===131)return 4;throw new Error("Length too long (> 4 bytes)")},Hh=(r,t)=>{let e=Ws(r,t);if(e===1)return r[t];if(e===2)return r[t+1];if(e===3)return(r[t+1]<<8)+r[t+2];if(e===4)return(r[t+1]<<16)+(r[t+2]<<8)+r[t+3];throw new Error("Length too long (> 4 bytes)")},bc=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),je=Uint8Array.from([48,5,6,3,43,101,112]),Gy=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function _r(r,t){let e=2+xc(r.byteLength+1),n=t.byteLength+e+r.byteLength,i=0,s=new Uint8Array(1+xc(n)+n);return s[i++]=48,i+=_c(s,i,n),s.set(t,i),i+=t.byteLength,s[i++]=3,i+=_c(s,i,r.byteLength+1),s[i++]=0,s.set(new Uint8Array(r),i),s}var Wr=(r,t)=>{let e=0,n=(c,u)=>{if(i[e++]!==c)throw new Error("Expected: "+u)},i=new Uint8Array(r);if(n(48,"sequence"),e+=Ws(i,e),!$r(i.slice(e,e+t.byteLength),t))throw new Error("Not the expected OID.");e+=t.byteLength,n(3,"bit string");let s=Hh(i,e)-1;e+=Ws(i,e),n(0,"0 padding");let o=i.slice(e);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o};var Ec=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},Ac=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Hn,Gn,Kn=class r{constructor(t){if(Hn.set(this,void 0),Gn.set(this,void 0),t.byteLength!==r.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Ec(this,Hn,t,"f"),Ec(this,Gn,r.derEncode(t),"f")}static from(t){return this.fromDer(t.toDer())}static fromRaw(t){return new r(t)}static fromDer(t){return new r(this.derDecode(t))}static derEncode(t){return _r(t,je).buffer}static derDecode(t){let e=Wr(t,je);if(e.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return e}get rawKey(){return Ac(this,Hn,"f")}get derKey(){return Ac(this,Gn,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Hn=new WeakMap,Gn=new WeakMap;Kn.RAW_KEY_LENGTH=32;Cn();var we=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},$t=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},ge,Dn,jn,Wn,zn,Yn,Xn,Jn,br;var Zn=class r{constructor(t=r.default){ge.set(this,void 0),Dn.set(this,void 0),jn.set(this,void 0),Wn.set(this,void 0),zn.set(this,void 0),Yn.set(this,void 0),Xn.set(this,void 0),Jn.set(this,void 0),br.set(this,0);let{initialInterval:e=500,randomizationFactor:n=.5,multiplier:i=1.5,maxInterval:s=6e4,maxElapsedTime:o=9e5,maxIterations:c=10,date:u=Date}=t;we(this,ge,e,"f"),we(this,Dn,n,"f"),we(this,jn,i,"f"),we(this,Wn,s,"f"),we(this,Jn,u,"f"),we(this,zn,u.now(),"f"),we(this,Yn,o,"f"),we(this,Xn,c,"f")}get ellapsedTimeInMsec(){return $t(this,Jn,"f").now()-$t(this,zn,"f")}get currentInterval(){return $t(this,ge,"f")}get count(){return $t(this,br,"f")}get randomValueFromInterval(){let t=$t(this,Dn,"f")*$t(this,ge,"f"),e=$t(this,ge,"f")-t,n=$t(this,ge,"f")+t;return Math.random()*(n-e)+e}incrementCurrentInterval(){var t;return we(this,ge,Math.min($t(this,ge,"f")*$t(this,jn,"f"),$t(this,Wn,"f")),"f"),we(this,br,(t=$t(this,br,"f"),t++,t),"f"),$t(this,ge,"f")}next(){return this.ellapsedTimeInMsec>=$t(this,Yn,"f")||$t(this,br,"f")>=$t(this,Xn,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};ge=new WeakMap,Dn=new WeakMap,jn=new WeakMap,Wn=new WeakMap,zn=new WeakMap,Yn=new WeakMap,Xn=new WeakMap,Jn=new WeakMap,br=new WeakMap;Zn.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date};var Dt=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},zr,Kh,vc,Tc,Dh,jh,Wh,zh,ke,Yh,Xh,Jh,Zh,Qh,Sc,t0,e0,r0,zs;(function(r){r.Received="received",r.Processing="processing",r.Replied="replied",r.Rejected="rejected",r.Unknown="unknown",r.Done="done"})(zs||(zs={}));var ww=5*60*1e3;Kh=new WeakMap,vc=new WeakMap,Tc=new WeakMap,Dh=new WeakMap,jh=new WeakMap,Wh=new WeakMap,zh=new WeakMap,ke=new WeakMap,Yh=new WeakMap,Xh=new WeakMap,Jh=new WeakMap,Zh=new WeakMap,Qh=new WeakMap,Sc=new WeakMap,r0=new WeakMap,zr=new WeakSet,t0=async function r(t){var e,n;let{ecid:i,transformedRequest:s,body:o,requestId:c,backoff:u,tries:w}=t,y=w===0?0:u.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:w,backoff:u,delay:y}),y===null)throw new ee(`Timestamp failed to pass the watermark after retrying the configured ${Dt(this,ke,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);y>0&&await new Promise(O=>setTimeout(O,y));let m;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let O=await Dt(this,vc,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},Dt(this,Tc,"f")),s.request),{body:o}));if(O.status===200){let G=Rn(await O.arrayBuffer());m=Object.assign(Object.assign({},G),{httpDetails:{ok:O.ok,status:O.status,statusText:O.statusText,headers:On(O.headers)},requestId:c})}else throw new Gr(`Gateway returned an error:
1
+ "use strict";(()=>{var Gu=Object.create;var wi=Object.defineProperty;var Ku=Object.getOwnPropertyDescriptor;var Du=Object.getOwnPropertyNames;var Wu=Object.getPrototypeOf,zu=Object.prototype.hasOwnProperty;var K=(r,t)=>()=>(r&&(t=r(r=0)),t);var Bt=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Yu=(r,t)=>{for(var e in t)wi(r,e,{get:t[e],enumerable:!0})},Xu=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Du(t))!zu.call(r,i)&&i!==e&&wi(r,i,{get:()=>t[i],enumerable:!(n=Ku(t,i))||n.enumerable});return r};var Te=(r,t,e)=>(e=r!=null?Gu(Wu(r)):{},Xu(t||!r||!r.__esModule?wi(e,"default",{value:r,enumerable:!0}):e,r));var mi=Bt(un=>{"use strict";un.byteLength=Zu;un.toByteArray=tf;un.fromByteArray=nf;var fe=[],te=[],Ju=typeof Uint8Array<"u"?Uint8Array:Array,gi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(qe=0,xo=gi.length;qe<xo;++qe)fe[qe]=gi[qe],te[gi.charCodeAt(qe)]=qe;var qe,xo;te[45]=62;te[95]=63;function _o(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");e===-1&&(e=t);var n=e===t?0:4-e%4;return[e,n]}function Zu(r){var t=_o(r),e=t[0],n=t[1];return(e+n)*3/4-n}function Qu(r,t,e){return(t+e)*3/4-e}function tf(r){var t,e=_o(r),n=e[0],i=e[1],s=new Ju(Qu(r,n,i)),o=0,c=i>0?n-4:n,u;for(u=0;u<c;u+=4)t=te[r.charCodeAt(u)]<<18|te[r.charCodeAt(u+1)]<<12|te[r.charCodeAt(u+2)]<<6|te[r.charCodeAt(u+3)],s[o++]=t>>16&255,s[o++]=t>>8&255,s[o++]=t&255;return i===2&&(t=te[r.charCodeAt(u)]<<2|te[r.charCodeAt(u+1)]>>4,s[o++]=t&255),i===1&&(t=te[r.charCodeAt(u)]<<10|te[r.charCodeAt(u+1)]<<4|te[r.charCodeAt(u+2)]>>2,s[o++]=t>>8&255,s[o++]=t&255),s}function ef(r){return fe[r>>18&63]+fe[r>>12&63]+fe[r>>6&63]+fe[r&63]}function rf(r,t,e){for(var n,i=[],s=t;s<e;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),i.push(ef(n));return i.join("")}function nf(r){for(var t,e=r.length,n=e%3,i=[],s=16383,o=0,c=e-n;o<c;o+=s)i.push(rf(r,o,o+s>c?c:o+s));return n===1?(t=r[e-1],i.push(fe[t>>2]+fe[t<<4&63]+"==")):n===2&&(t=(r[e-2]<<8)+r[e-1],i.push(fe[t>>10]+fe[t>>4&63]+fe[t<<2&63]+"=")),i.join("")}});var fn=Bt(xi=>{xi.read=function(r,t,e,n,i){var s,o,c=i*8-n-1,u=(1<<c)-1,w=u>>1,y=-7,m=e?i-1:0,N=e?-1:1,k=r[t+m];for(m+=N,s=k&(1<<-y)-1,k>>=-y,y+=c;y>0;s=s*256+r[t+m],m+=N,y-=8);for(o=s&(1<<-y)-1,s>>=-y,y+=n;y>0;o=o*256+r[t+m],m+=N,y-=8);if(s===0)s=1-w;else{if(s===u)return o?NaN:(k?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-w}return(k?-1:1)*o*Math.pow(2,s-n)};xi.write=function(r,t,e,n,i,s){var o,c,u,w=s*8-i-1,y=(1<<w)-1,m=y>>1,N=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,k=n?0:s-1,O=n?1:-1,j=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,o=y):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+m>=1?t+=N/u:t+=N*Math.pow(2,1-m),t*u>=2&&(o++,u/=2),o+m>=y?(c=0,o=y):o+m>=1?(c=(t*u-1)*Math.pow(2,i),o=o+m):(c=t*Math.pow(2,m-1)*Math.pow(2,i),o=0));i>=8;r[e+k]=c&255,k+=O,c/=256,i-=8);for(o=o<<i|c,w+=i;w>0;r[e+k]=o&255,k+=O,o/=256,w-=8);r[e+k-O]|=j*128}});var Co=Bt(nr=>{"use strict";var _i=mi(),er=fn(),bo=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;nr.Buffer=T;nr.SlowBuffer=ff;nr.INSPECT_MAX_BYTES=50;var ln=2147483647;nr.kMaxLength=ln;T.TYPED_ARRAY_SUPPORT=sf();!T.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 sf(){try{let r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch{return!1}}Object.defineProperty(T.prototype,"parent",{enumerable:!0,get:function(){if(T.isBuffer(this))return this.buffer}});Object.defineProperty(T.prototype,"offset",{enumerable:!0,get:function(){if(T.isBuffer(this))return this.byteOffset}});function xe(r){if(r>ln)throw new RangeError('The value "'+r+'" is invalid for option "size"');let t=new Uint8Array(r);return Object.setPrototypeOf(t,T.prototype),t}function T(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return vi(r)}return To(r,t,e)}T.poolSize=8192;function To(r,t,e){if(typeof r=="string")return af(r,t);if(ArrayBuffer.isView(r))return cf(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(le(r,ArrayBuffer)||r&&le(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(le(r,SharedArrayBuffer)||r&&le(r.buffer,SharedArrayBuffer)))return Ei(r,t,e);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return T.from(n,t,e);let i=uf(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return T.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}T.from=function(r,t,e){return To(r,t,e)};Object.setPrototypeOf(T.prototype,Uint8Array.prototype);Object.setPrototypeOf(T,Uint8Array);function So(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function of(r,t,e){return So(r),r<=0?xe(r):t!==void 0?typeof e=="string"?xe(r).fill(t,e):xe(r).fill(t):xe(r)}T.alloc=function(r,t,e){return of(r,t,e)};function vi(r){return So(r),xe(r<0?0:Ti(r)|0)}T.allocUnsafe=function(r){return vi(r)};T.allocUnsafeSlow=function(r){return vi(r)};function af(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!T.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=Bo(r,t)|0,n=xe(e),i=n.write(r,t);return i!==e&&(n=n.slice(0,i)),n}function bi(r){let t=r.length<0?0:Ti(r.length)|0,e=xe(t);for(let n=0;n<t;n+=1)e[n]=r[n]&255;return e}function cf(r){if(le(r,Uint8Array)){let t=new Uint8Array(r);return Ei(t.buffer,t.byteOffset,t.byteLength)}return bi(r)}function Ei(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&e===void 0?n=new Uint8Array(r):e===void 0?n=new Uint8Array(r,t):n=new Uint8Array(r,t,e),Object.setPrototypeOf(n,T.prototype),n}function uf(r){if(T.isBuffer(r)){let t=Ti(r.length)|0,e=xe(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||Bi(r.length)?xe(0):bi(r);if(r.type==="Buffer"&&Array.isArray(r.data))return bi(r.data)}function Ti(r){if(r>=ln)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ln.toString(16)+" bytes");return r|0}function ff(r){return+r!=r&&(r=0),T.alloc(+r)}T.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==T.prototype};T.compare=function(t,e){if(le(t,Uint8Array)&&(t=T.from(t,t.offset,t.byteLength)),le(e,Uint8Array)&&(e=T.from(e,e.offset,e.byteLength)),!T.isBuffer(t)||!T.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,i=e.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(t[s]!==e[s]){n=t[s],i=e[s];break}return n<i?-1:i<n?1:0};T.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};T.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return T.alloc(0);let n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;let i=T.allocUnsafe(e),s=0;for(n=0;n<t.length;++n){let o=t[n];if(le(o,Uint8Array))s+o.length>i.length?(T.isBuffer(o)||(o=T.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(T.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function Bo(r,t){if(T.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||le(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let e=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&e===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return Ai(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Mo(r).length;default:if(i)return n?-1:Ai(r).length;t=(""+t).toLowerCase(),i=!0}}T.byteLength=Bo;function lf(r,t,e){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return bf(this,t,e);case"utf8":case"utf-8":return No(this,t,e);case"ascii":return xf(this,t,e);case"latin1":case"binary":return _f(this,t,e);case"base64":return gf(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ef(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}T.prototype._isBuffer=!0;function He(r,t,e){let n=r[t];r[t]=r[e],r[e]=n}T.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)He(this,e,e+1);return this};T.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)He(this,e,e+3),He(this,e+1,e+2);return this};T.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)He(this,e,e+7),He(this,e+1,e+6),He(this,e+2,e+5),He(this,e+3,e+4);return this};T.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?No(this,0,t):lf.apply(this,arguments)};T.prototype.toLocaleString=T.prototype.toString;T.prototype.equals=function(t){if(!T.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:T.compare(this,t)===0};T.prototype.inspect=function(){let t="",e=nr.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};bo&&(T.prototype[bo]=T.prototype.inspect);T.prototype.compare=function(t,e,n,i,s){if(le(t,Uint8Array)&&(t=T.from(t,t.offset,t.byteLength)),!T.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),e<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&e>=n)return 0;if(i>=s)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;let o=s-i,c=n-e,u=Math.min(o,c),w=this.slice(i,s),y=t.slice(e,n);for(let m=0;m<u;++m)if(w[m]!==y[m]){o=w[m],c=y[m];break}return o<c?-1:c<o?1:0};function Io(r,t,e,n,i){if(r.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Bi(e)&&(e=i?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(i)return-1;e=r.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=T.from(t,n)),T.isBuffer(t))return t.length===0?-1:Eo(r,t,e,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):Eo(r,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function Eo(r,t,e,n,i){let s=1,o=r.length,c=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;s=2,o/=2,c/=2,e/=2}function u(y,m){return s===1?y[m]:y.readUInt16BE(m*s)}let w;if(i){let y=-1;for(w=e;w<o;w++)if(u(r,w)===u(t,y===-1?0:w-y)){if(y===-1&&(y=w),w-y+1===c)return y*s}else y!==-1&&(w-=w-y),y=-1}else for(e+c>o&&(e=o-c),w=e;w>=0;w--){let y=!0;for(let m=0;m<c;m++)if(u(r,w+m)!==u(t,m)){y=!1;break}if(y)return w}return-1}T.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1};T.prototype.indexOf=function(t,e,n){return Io(this,t,e,n,!0)};T.prototype.lastIndexOf=function(t,e,n){return Io(this,t,e,n,!1)};function hf(r,t,e,n){e=Number(e)||0;let i=r.length-e;n?(n=Number(n),n>i&&(n=i)):n=i;let s=t.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let c=parseInt(t.substr(o*2,2),16);if(Bi(c))return o;r[e+o]=c}return o}function df(r,t,e,n){return hn(Ai(t,r.length-e),r,e,n)}function pf(r,t,e,n){return hn(Sf(t),r,e,n)}function yf(r,t,e,n){return hn(Mo(t),r,e,n)}function wf(r,t,e,n){return hn(Bf(t,r.length-e),r,e,n)}T.prototype.write=function(t,e,n,i){if(e===void 0)i="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")i=e,n=this.length,e=0;else if(isFinite(e))e=e>>>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-e;if((n===void 0||n>s)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return hf(this,t,e,n);case"utf8":case"utf-8":return df(this,t,e,n);case"ascii":case"latin1":case"binary":return pf(this,t,e,n);case"base64":return yf(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return wf(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};T.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function gf(r,t,e){return t===0&&e===r.length?_i.fromByteArray(r):_i.fromByteArray(r.slice(t,e))}function No(r,t,e){e=Math.min(r.length,e);let n=[],i=t;for(;i<e;){let s=r[i],o=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=e){let u,w,y,m;switch(c){case 1:s<128&&(o=s);break;case 2:u=r[i+1],(u&192)===128&&(m=(s&31)<<6|u&63,m>127&&(o=m));break;case 3:u=r[i+1],w=r[i+2],(u&192)===128&&(w&192)===128&&(m=(s&15)<<12|(u&63)<<6|w&63,m>2047&&(m<55296||m>57343)&&(o=m));break;case 4:u=r[i+1],w=r[i+2],y=r[i+3],(u&192)===128&&(w&192)===128&&(y&192)===128&&(m=(s&15)<<18|(u&63)<<12|(w&63)<<6|y&63,m>65535&&m<1114112&&(o=m))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=c}return mf(n)}var Ao=4096;function mf(r){let t=r.length;if(t<=Ao)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=Ao));return e}function xf(r,t,e){let n="";e=Math.min(r.length,e);for(let i=t;i<e;++i)n+=String.fromCharCode(r[i]&127);return n}function _f(r,t,e){let n="";e=Math.min(r.length,e);for(let i=t;i<e;++i)n+=String.fromCharCode(r[i]);return n}function bf(r,t,e){let n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);let i="";for(let s=t;s<e;++s)i+=If[r[s]];return i}function Ef(r,t,e){let n=r.slice(t,e),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}T.prototype.slice=function(t,e){let n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);let i=this.subarray(t,e);return Object.setPrototypeOf(i,T.prototype),i};function Ot(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}T.prototype.readUintLE=T.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||Ot(t,e,this.length);let i=this[t],s=1,o=0;for(;++o<e&&(s*=256);)i+=this[t+o]*s;return i};T.prototype.readUintBE=T.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||Ot(t,e,this.length);let i=this[t+--e],s=1;for(;e>0&&(s*=256);)i+=this[t+--e]*s;return i};T.prototype.readUint8=T.prototype.readUInt8=function(t,e){return t=t>>>0,e||Ot(t,1,this.length),this[t]};T.prototype.readUint16LE=T.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||Ot(t,2,this.length),this[t]|this[t+1]<<8};T.prototype.readUint16BE=T.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||Ot(t,2,this.length),this[t]<<8|this[t+1]};T.prototype.readUint32LE=T.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||Ot(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};T.prototype.readUint32BE=T.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||Ot(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};T.prototype.readBigUInt64LE=Se(function(t){t=t>>>0,rr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Rr(t,this.length-8);let i=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,s=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});T.prototype.readBigUInt64BE=Se(function(t){t=t>>>0,rr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Rr(t,this.length-8);let i=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],s=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});T.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||Ot(t,e,this.length);let i=this[t],s=1,o=0;for(;++o<e&&(s*=256);)i+=this[t+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*e)),i};T.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||Ot(t,e,this.length);let i=e,s=1,o=this[t+--i];for(;i>0&&(s*=256);)o+=this[t+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*e)),o};T.prototype.readInt8=function(t,e){return t=t>>>0,e||Ot(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};T.prototype.readInt16LE=function(t,e){t=t>>>0,e||Ot(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};T.prototype.readInt16BE=function(t,e){t=t>>>0,e||Ot(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};T.prototype.readInt32LE=function(t,e){return t=t>>>0,e||Ot(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};T.prototype.readInt32BE=function(t,e){return t=t>>>0,e||Ot(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};T.prototype.readBigInt64LE=Se(function(t){t=t>>>0,rr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Rr(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});T.prototype.readBigInt64BE=Se(function(t){t=t>>>0,rr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Rr(t,this.length-8);let i=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});T.prototype.readFloatLE=function(t,e){return t=t>>>0,e||Ot(t,4,this.length),er.read(this,t,!0,23,4)};T.prototype.readFloatBE=function(t,e){return t=t>>>0,e||Ot(t,4,this.length),er.read(this,t,!1,23,4)};T.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||Ot(t,8,this.length),er.read(this,t,!0,52,8)};T.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||Ot(t,8,this.length),er.read(this,t,!1,52,8)};function Ht(r,t,e,n,i,s){if(!T.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}T.prototype.writeUintLE=T.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;Ht(this,t,e,n,c,0)}let s=1,o=0;for(this[e]=t&255;++o<n&&(s*=256);)this[e+o]=t/s&255;return e+n};T.prototype.writeUintBE=T.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;Ht(this,t,e,n,c,0)}let s=n-1,o=1;for(this[e+s]=t&255;--s>=0&&(o*=256);)this[e+s]=t/o&255;return e+n};T.prototype.writeUint8=T.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,1,255,0),this[e]=t&255,e+1};T.prototype.writeUint16LE=T.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};T.prototype.writeUint16BE=T.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};T.prototype.writeUint32LE=T.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4};T.prototype.writeUint32BE=T.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function Uo(r,t,e,n,i){ko(t,n,i,r,e,7);let s=Number(t&BigInt(4294967295));r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return r[e++]=o,o=o>>8,r[e++]=o,o=o>>8,r[e++]=o,o=o>>8,r[e++]=o,e}function Ro(r,t,e,n,i){ko(t,n,i,r,e,7);let s=Number(t&BigInt(4294967295));r[e+7]=s,s=s>>8,r[e+6]=s,s=s>>8,r[e+5]=s,s=s>>8,r[e+4]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return r[e+3]=o,o=o>>8,r[e+2]=o,o=o>>8,r[e+1]=o,o=o>>8,r[e]=o,e+8}T.prototype.writeBigUInt64LE=Se(function(t,e=0){return Uo(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});T.prototype.writeBigUInt64BE=Se(function(t,e=0){return Ro(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});T.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){let u=Math.pow(2,8*n-1);Ht(this,t,e,n,u-1,-u)}let s=0,o=1,c=0;for(this[e]=t&255;++s<n&&(o*=256);)t<0&&c===0&&this[e+s-1]!==0&&(c=1),this[e+s]=(t/o>>0)-c&255;return e+n};T.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){let u=Math.pow(2,8*n-1);Ht(this,t,e,n,u-1,-u)}let s=n-1,o=1,c=0;for(this[e+s]=t&255;--s>=0&&(o*=256);)t<0&&c===0&&this[e+s+1]!==0&&(c=1),this[e+s]=(t/o>>0)-c&255;return e+n};T.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};T.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};T.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};T.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4};T.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||Ht(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};T.prototype.writeBigInt64LE=Se(function(t,e=0){return Uo(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});T.prototype.writeBigInt64BE=Se(function(t,e=0){return Ro(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Fo(r,t,e,n,i,s){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Oo(r,t,e,n,i){return t=+t,e=e>>>0,i||Fo(r,t,e,4,34028234663852886e22,-34028234663852886e22),er.write(r,t,e,n,23,4),e+4}T.prototype.writeFloatLE=function(t,e,n){return Oo(this,t,e,!0,n)};T.prototype.writeFloatBE=function(t,e,n){return Oo(this,t,e,!1,n)};function Po(r,t,e,n,i){return t=+t,e=e>>>0,i||Fo(r,t,e,8,17976931348623157e292,-17976931348623157e292),er.write(r,t,e,n,52,8),e+8}T.prototype.writeDoubleLE=function(t,e,n){return Po(this,t,e,!0,n)};T.prototype.writeDoubleBE=function(t,e,n){return Po(this,t,e,!1,n)};T.prototype.copy=function(t,e,n,i){if(!T.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);let s=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),e),s};T.prototype.fill=function(t,e,n,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=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"&&!T.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let o=t.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(t=o)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let s;if(typeof t=="number")for(s=e;s<n;++s)this[s]=t;else{let o=T.isBuffer(t)?t:T.from(t,i),c=o.length;if(c===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-e;++s)this[s+e]=o[s%c]}return this};var tr={};function Si(r,t,e){tr[r]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}Si("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Si("ERR_INVALID_ARG_TYPE",function(r,t){return`The "${r}" argument must be of type number. Received type ${typeof t}`},TypeError);Si("ERR_OUT_OF_RANGE",function(r,t,e){let n=`The value of "${r}" is out of range.`,i=e;return Number.isInteger(e)&&Math.abs(e)>2**32?i=vo(String(e)):typeof e=="bigint"&&(i=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(i=vo(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function vo(r){let t="",e=r.length,n=r[0]==="-"?1:0;for(;e>=n+4;e-=3)t=`_${r.slice(e-3,e)}${t}`;return`${r.slice(0,e)}${t}`}function Af(r,t,e){rr(t,"offset"),(r[t]===void 0||r[t+e]===void 0)&&Rr(t,r.length-(e+1))}function ko(r,t,e,n,i,s){if(r>e||r<t){let o=typeof t=="bigint"?"n":"",c;throw s>3?t===0||t===BigInt(0)?c=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:c=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:c=`>= ${t}${o} and <= ${e}${o}`,new tr.ERR_OUT_OF_RANGE("value",c,r)}Af(n,i,s)}function rr(r,t){if(typeof r!="number")throw new tr.ERR_INVALID_ARG_TYPE(t,"number",r)}function Rr(r,t,e){throw Math.floor(r)!==r?(rr(r,e),new tr.ERR_OUT_OF_RANGE(e||"offset","an integer",r)):t<0?new tr.ERR_BUFFER_OUT_OF_BOUNDS:new tr.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,r)}var vf=/[^+/0-9A-Za-z-_]/g;function Tf(r){if(r=r.split("=")[0],r=r.trim().replace(vf,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Ai(r,t){t=t||1/0;let e,n=r.length,i=null,s=[];for(let o=0;o<n;++o){if(e=r.charCodeAt(o),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&s.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;s.push(e)}else if(e<2048){if((t-=2)<0)break;s.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;s.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;s.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return s}function Sf(r){let t=[];for(let e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function Bf(r,t){let e,n,i,s=[];for(let o=0;o<r.length&&!((t-=2)<0);++o)e=r.charCodeAt(o),n=e>>8,i=e%256,s.push(i),s.push(n);return s}function Mo(r){return _i.toByteArray(Tf(r))}function hn(r,t,e,n){let i;for(i=0;i<n&&!(i+e>=t.length||i>=r.length);++i)t[i+e]=r[i];return i}function le(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function Bi(r){return r!==r}var If=function(){let r="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){let n=e*16;for(let i=0;i<16;++i)t[n+i]=r[e]+r[i]}return t}();function Se(r){return typeof BigInt>"u"?Nf:r}function Nf(){throw new Error("BigInt not supported")}});var dn,Ii=K(()=>{(function(r){r[r.SysFatal=1]="SysFatal",r[r.SysTransient=2]="SysTransient",r[r.DestinationInvalid=3]="DestinationInvalid",r[r.CanisterReject=4]="CanisterReject",r[r.CanisterError=5]="CanisterError"})(dn||(dn={}))});function $o(r){let t=0,e=0,n="";function i(s){return t<0?e|=s>>-t:e=s<<t&248,t>3?(t-=8,1):(t<4&&(n+=pn[e>>3],t+=5),0)}for(let s=0;s<r.length;)s+=i(r[s]);return n+(t<0?pn[e>>3]:"")}function Vo(r){let t=0,e=0,n=new Uint8Array(r.length*4/3|0),i=0;function s(o){let c=ir[o.toLowerCase()];if(c===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);c<<=3,e|=c>>>t,t+=5,t>=8&&(n[i++]=e,t-=8,t>0?e=c<<5-t&255:e=0)}for(let o of r)s(o);return n.slice(0,i)}var pn,ir,qo=K(()=>{pn="abcdefghijklmnopqrstuvwxyz234567",ir=Object.create(null);for(let r=0;r<pn.length;r++)ir[pn[r]]=r;ir[0]=ir.o;ir[1]=ir.i});function Ho(r){let t=new Uint8Array(r),e=-1;for(let n=0;n<t.length;n++){let s=(t[n]^e)&255;e=Uf[s]^e>>>8}return(e^-1)>>>0}var Uf,Lo=K(()=>{Uf=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 Rf(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Ni(r,...t){if(!Rf(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function Ui(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function jo(r,t){Ni(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var Ri=K(()=>{});var Le,Go=K(()=>{Le=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});function Ko(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Fi(r){return typeof r=="string"&&(r=Ko(r)),Ni(r),r}function Fr(r){let t=n=>r().update(Fi(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Do(r=32){if(Le&&typeof Le.getRandomValues=="function")return Le.getRandomValues(new Uint8Array(r));if(Le&&typeof Le.randomBytes=="function")return Le.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}var wn,ne,Fd,yn,Od,Or=K(()=>{Go();Ri();wn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),ne=(r,t)=>r<<32-t|r>>>t,Fd=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;yn=class{clone(){return this._cloneInto()}},Od={}.toString});function Ff(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(e>>i&s),c=Number(e&s),u=n?4:0,w=n?0:4;r.setUint32(t+u,o,n),r.setUint32(t+w,c,n)}var Wo,zo,sr,Oi=K(()=>{Ri();Or();Wo=(r,t,e)=>r&t^~r&e,zo=(r,t,e)=>r&t^r&e^t&e,sr=class extends yn{constructor(t,e,n,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=wn(this.buffer)}update(t){Ui(this);let{view:e,buffer:n,blockLen:i}=this;t=Fi(t);let s=t.length;for(let o=0;o<s;){let c=Math.min(i-this.pos,s-o);if(c===i){let u=wn(t);for(;i<=s-o;o+=i)this.process(u,o);continue}n.set(t.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ui(this),jo(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let m=o;m<i;m++)e[m]=0;Ff(n,i-8,BigInt(this.length*8),s),this.process(n,0);let c=wn(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let w=u/4,y=this.get();if(w>y.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<w;m++)c.setUint32(4*m,y[m],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:i,finished:s,destroyed:o,pos:c}=this;return t.length=i,t.pos=c,t.finished=s,t.destroyed=o,i%e&&t.buffer.set(n),t}}});var Of,Be,Ie,gn,Pi,Yo,Xo,ki=K(()=>{Oi();Or();Of=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]),Be=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ie=new Uint32Array(64),gn=class extends sr{constructor(){super(64,32,8,!1),this.A=Be[0]|0,this.B=Be[1]|0,this.C=Be[2]|0,this.D=Be[3]|0,this.E=Be[4]|0,this.F=Be[5]|0,this.G=Be[6]|0,this.H=Be[7]|0}get(){let{A:t,B:e,C:n,D:i,E:s,F:o,G:c,H:u}=this;return[t,e,n,i,s,o,c,u]}set(t,e,n,i,s,o,c,u){this.A=t|0,this.B=e|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=c|0,this.H=u|0}process(t,e){for(let m=0;m<16;m++,e+=4)Ie[m]=t.getUint32(e,!1);for(let m=16;m<64;m++){let N=Ie[m-15],k=Ie[m-2],O=ne(N,7)^ne(N,18)^N>>>3,j=ne(k,17)^ne(k,19)^k>>>10;Ie[m]=j+Ie[m-7]+O+Ie[m-16]|0}let{A:n,B:i,C:s,D:o,E:c,F:u,G:w,H:y}=this;for(let m=0;m<64;m++){let N=ne(c,6)^ne(c,11)^ne(c,25),k=y+N+Wo(c,u,w)+Of[m]+Ie[m]|0,j=(ne(n,2)^ne(n,13)^ne(n,22))+zo(n,i,s)|0;y=w,w=u,u=c,c=o+k|0,o=s,s=i,i=n,n=k+j|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,c=c+this.E|0,u=u+this.F|0,w=w+this.G|0,y=y+this.H|0,this.set(n,i,s,o,c,u,w,y)}roundClean(){Ie.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Pi=class extends gn{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}},Yo=Fr(()=>new gn),Xo=Fr(()=>new Pi)});function Jo(r){return Xo.create().update(new Uint8Array(r)).digest()}var Zo=K(()=>{ki()});var mn,Pf,Qo,kf,Mf,Cf,Et,Wt=K(()=>{qo();Lo();Zo();mn="__principal__",Pf=2,Qo=4,kf="aaaaa-aa",Mf=r=>{var t;return new Uint8Array(((t=r.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(e=>parseInt(e,16)))},Cf=r=>r.reduce((t,e)=>t+e.toString(16).padStart(2,"0"),""),Et=class r{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Qo]))}static managementCanister(){return this.fromHex(kf)}static selfAuthenticating(t){let e=Jo(t);return new this(new Uint8Array([...e,Pf]))}static from(t){if(typeof t=="string")return r.fromText(t);if(Object.getPrototypeOf(t)===Uint8Array.prototype)return new r(t);if(typeof t=="object"&&t!==null&&t._isPrincipal===!0)return new r(t._arr);throw new Error(`Impossible to convert ${JSON.stringify(t)} to Principal.`)}static fromHex(t){return new this(Mf(t))}static fromText(t){let e=t;if(t.includes(mn)){let o=JSON.parse(t);mn in o&&(e=o[mn])}let n=e.toLowerCase().replace(/-/g,""),i=Vo(n);i=i.slice(4,i.length);let s=new this(i);if(s.toText()!==e)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${e}" may not be a valid Principal ID).`);return s}static fromUint8Array(t){return new this(t)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===Qo}toUint8Array(){return this._arr}toHex(){return Cf(this._arr).toUpperCase()}toText(){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,Ho(this._arr));let n=new Uint8Array(t),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),c=$o(s).match(/.{1,5}/g);if(!c)throw new Error;return c.join("-")}toString(){return this.toText()}toJSON(){return{[mn]:this.toText()}}compareTo(t){for(let e=0;e<Math.min(this._arr.length,t._arr.length);e++){if(this._arr[e]<t._arr[e])return"lt";if(this._arr[e]>t._arr[e])return"gt"}return this._arr.length<t._arr.length?"lt":this._arr.length>t._arr.length?"gt":"eq"}ltEq(t){let e=this.compareTo(t);return e=="lt"||e=="eq"}gtEq(t){let e=this.compareTo(t);return e=="gt"||e=="eq"}}});function he(...r){let t=new Uint8Array(r.reduce((n,i)=>n+i.byteLength,0)),e=0;for(let n of r)t.set(new Uint8Array(n),e),e+=n.byteLength;return t.buffer}function At(r){return[...new Uint8Array(r)].map(t=>t.toString(16).padStart(2,"0")).join("")}function Lt(r){if(!$f.test(r))throw new Error("Invalid hexadecimal string.");let t=[...r].reduce((e,n,i)=>(e[i/2|0]=(e[i/2|0]||"")+n,e),[]).map(e=>Number.parseInt(e,16));return new Uint8Array(t).buffer}function Mi(r,t){if(r.byteLength!==t.byteLength)return r.byteLength-t.byteLength;let e=new Uint8Array(r),n=new Uint8Array(t);for(let i=0;i<e.length;i++)if(e[i]!==n[i])return e[i]-n[i];return 0}function Pr(r,t){return Mi(r,t)===0}function je(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}function xn(r){return r instanceof Uint8Array?je(r):r instanceof ArrayBuffer?r:Array.isArray(r)?je(new Uint8Array(r)):"buffer"in r?xn(r.buffer):je(new Uint8Array(r))}var $f,jt=K(()=>{$f=new RegExp(/^[0-9a-fA-F]+$/)});var ee,or=K(()=>{Wt();Ii();jt();ee=class r extends Error{constructor(t){super(t),this.message=t,this.name="AgentError",this.__proto__=r.prototype,Object.setPrototypeOf(this,r.prototype)}}});function $i(...r){let t=new Uint8Array(r.reduce((n,i)=>n+i.byteLength,0)),e=0;for(let n of r)t.set(new Uint8Array(n),e),e+=n.byteLength;return t}function Ci(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}function kr(r){return r instanceof Uint8Array?Ci(r):r instanceof ArrayBuffer?r:Array.isArray(r)?Ci(new Uint8Array(r)):"buffer"in r?kr(r.buffer):Ci(new Uint8Array(r))}var Ne,_n=K(()=>{Ne=class{constructor(t,e=t?.byteLength||0){this._buffer=kr(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,e)}get buffer(){return kr(this._view.slice())}get byteLength(){return this._view.byteLength}read(t){let e=this._view.subarray(0,t);return this._view=this._view.subarray(t),e.slice().buffer}readUint8(){let t=this._view[0];return this._view=this._view.subarray(1),t}write(t){let e=new Uint8Array(t),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+e.byteLength>=this._buffer.byteLength?this.alloc(e.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+e.byteLength),this._view.set(e,n)}get end(){return this._view.byteLength===0}alloc(t){let e=new ArrayBuffer((this._buffer.byteLength+t)*1.2|0),n=new Uint8Array(e,0,this._view.byteLength+t);n.set(this._view),this._buffer=e,this._view=n}}});var Vi=K(()=>{});function ta(){throw new Error("unexpected end of buffer")}function Mr(r,t){return r.byteLength<t&&ta(),r.read(t)}function ar(r){let t=r.readUint8();return t===void 0&&ta(),t}function Ue(r){if(typeof r=="number"&&(r=BigInt(r)),r<BigInt(0))throw new Error("Cannot leb encode negative values.");let t=(r===BigInt(0)?0:Math.ceil(Math.log2(Number(r))))+1,e=new Ne(new ArrayBuffer(t),0);for(;;){let n=Number(r&BigInt(127));if(r/=BigInt(128),r===BigInt(0)){e.write(new Uint8Array([n]));break}else e.write(new Uint8Array([n|128]))}return e.buffer}function cr(r){let t=BigInt(1),e=BigInt(0),n;do n=ar(r),e+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return e}function zt(r){typeof r=="number"&&(r=BigInt(r));let t=r<BigInt(0);t&&(r=-r-BigInt(1));let e=(r===BigInt(0)?0:Math.ceil(Math.log2(Number(r))))+1,n=new Ne(new ArrayBuffer(e),0);for(;;){let s=i(r);if(r/=BigInt(128),t&&r===BigInt(0)&&s&64||!t&&r===BigInt(0)&&!(s&64)){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let o=s%BigInt(128);return Number(t?BigInt(128)-o-BigInt(1):o)}return n.buffer}function ea(r){let t=new Uint8Array(r.buffer),e=0;for(;e<t.byteLength;e++)if(t[e]<128){if(!(t[e]&64))return cr(r);break}let n=new Uint8Array(Mr(r,e+1)),i=BigInt(0);for(let s=n.byteLength-1;s>=0;s--)i=i*BigInt(128)+BigInt(128-(n[s]&127)-1);return-i-BigInt(1)}function ra(r,t){if(BigInt(r)<BigInt(0))throw new Error("Cannot write negative values.");return qi(r,t)}function qi(r,t){r=BigInt(r);let e=new Ne(new ArrayBuffer(Math.min(1,t)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(r%i);for(e.write(new Uint8Array([o]));++n<t;)r<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((r/i-s)%BigInt(256)),e.write(new Uint8Array([o])),i*=BigInt(256);return e.buffer}function Hi(r,t){let e=BigInt(ar(r)),n=BigInt(1),i=0;for(;++i<t;){n*=BigInt(256);let s=BigInt(ar(r));e=e+n*s}return e}function na(r,t){let e=Hi(r,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return e>=n&&(e-=n*BigInt(2)),e}var Li=K(()=>{_n()});function bn(r){let t=BigInt(r);if(r<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}var ia=K(()=>{});function Vf(r){if(ar(r)!==1)throw new Error("Cannot decode principal");let e=Number(cr(r));return Et.fromUint8Array(new Uint8Array(Mr(r,e)))}function Xt(r){let t=JSON.stringify(r,(e,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>sa?t.substring(0,sa-3)+"...":t}var sa,Cr,Yt,ji,Gi,Ki,Di,Wi,zi,Yi,Xi,Ji,En,ur,fr,$r,Zi,up,fp,lp,hp,dp,pp,yp,wp,gp,mp,xp,_p,bp,Ep,Ap,vp,Tp,Sp,Bp,ts=K(()=>{Wt();_n();Vi();Li();ia();sa=400,Cr=class{display(){return this.name}valueToString(t){return Xt(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}},Yt=class extends Cr{checkType(t){if(this.name!==t.name)throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`);return t}_buildTypeTableImpl(t){}},ji=class extends Cr{checkType(t){if(t instanceof $r){let e=t.getType();if(typeof e>"u")throw new Error("type mismatch with uninitialized type");return e}throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`)}encodeType(t){return t.indexOf(this.name)}},Gi=class extends Yt{accept(t,e){return t.visitEmpty(this,e)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${Xt(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return zt(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},Ki=class extends Cr{checkType(t){throw new Error("Method not implemented for unknown.")}accept(t,e){throw t.visitType(this,e)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${Xt(t)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(t,e){let n=e.decodeValue(t,e);Object(n)!==n&&(n=Object(n));let i;return e instanceof $r?i=()=>e.getType():i=()=>e,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"}},Di=class extends Yt{accept(t,e){return t.visitBool(this,e)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${Xt(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return zt(-2)}decodeValue(t,e){switch(this.checkType(e),ar(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},Wi=class extends Yt{accept(t,e){return t.visitNull(this,e)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${Xt(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return zt(-1)}decodeValue(t,e){return this.checkType(e),null}get name(){return"null"}},zi=class extends Yt{accept(t,e){return t.visitReserved(this,e)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return zt(-16)}decodeValue(t,e){return e.name!==this.name&&e.decodeValue(t,e),null}get name(){return"reserved"}},Yi=class extends Yt{accept(t,e){return t.visitText(this,e)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Xt(t)}`)}encodeValue(t){let e=new TextEncoder().encode(t),n=Ue(e.byteLength);return $i(n,e)}encodeType(){return zt(-15)}decodeValue(t,e){this.checkType(e);let n=cr(t),i=Mr(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(t){return'"'+t+'"'}},Xi=class extends Yt{accept(t,e){return t.visitInt(this,e)}covariant(t){if(typeof t=="bigint"||Number.isInteger(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${Xt(t)}`)}encodeValue(t){return zt(t)}encodeType(){return zt(-4)}decodeValue(t,e){return this.checkType(e),ea(t)}get name(){return"int"}valueToString(t){return t.toString()}},Ji=class extends Yt{accept(t,e){return t.visitNat(this,e)}covariant(t){if(typeof t=="bigint"&&t>=BigInt(0)||Number.isInteger(t)&&t>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${Xt(t)}`)}encodeValue(t){return Ue(t)}encodeType(){return zt(-3)}decodeValue(t,e){return this.checkType(e),cr(t)}get name(){return"nat"}valueToString(t){return t.toString()}},En=class extends Yt{constructor(t){if(super(),this._bits=t,t!==32&&t!==64)throw new Error("not a valid float type")}accept(t,e){return t.visitFloat(this,e)}covariant(t){if(typeof t=="number"||t instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${Xt(t)}`)}encodeValue(t){let e=new ArrayBuffer(this._bits/8),n=new DataView(e);return this._bits===32?n.setFloat32(0,t,!0):n.setFloat64(0,t,!0),e}encodeType(){let t=this._bits===32?-13:-14;return zt(t)}decodeValue(t,e){this.checkType(e);let n=Mr(t,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(t){return t.toString()}},ur=class extends Yt{constructor(t){super(),this._bits=t}accept(t,e){return t.visitFixedInt(this,e)}covariant(t){let e=bn(this._bits-1)*BigInt(-1),n=bn(this._bits-1)-BigInt(1),i=!1;if(typeof t=="bigint")i=t>=e&&t<=n;else if(Number.isInteger(t)){let s=BigInt(t);i=s>=e&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${Xt(t)}`)}encodeValue(t){return qi(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return zt(-9-t)}decodeValue(t,e){this.checkType(e);let n=na(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}},fr=class extends Yt{constructor(t){super(),this._bits=t}accept(t,e){return t.visitFixedNat(this,e)}covariant(t){let e=bn(this._bits),n=!1;if(typeof t=="bigint"&&t>=BigInt(0)?n=t<e:Number.isInteger(t)&&t>=0?n=BigInt(t)<e:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${Xt(t)}`)}encodeValue(t){return ra(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return zt(-5-t)}decodeValue(t,e){this.checkType(e);let n=Hi(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}},$r=class r extends ji{constructor(){super(...arguments),this._id=r._counter++,this._type=void 0}accept(t,e){if(!this._type)throw Error("Recursive type uninitialized.");return t.visitRec(this,this._type,e)}fill(t){this._type=t}getType(){return this._type}covariant(t){if(this._type&&this._type.covariant(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${Xt(t)}`)}encodeValue(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(t)}_buildTypeTableImpl(t){if(!this._type)throw Error("Recursive type uninitialized.");t.add(this,new Uint8Array([])),this._type.buildTypeTable(t),t.merge(this,this._type.name)}decodeValue(t,e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(t,e)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(t)}};$r._counter=0;Zi=class extends Yt{accept(t,e){return t.visitPrincipal(this,e)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Xt(t)}`)}encodeValue(t){let e=t.toUint8Array(),n=Ue(e.byteLength);return $i(new Uint8Array([1]),n,e)}encodeType(){return zt(-24)}decodeValue(t,e){return this.checkType(e),Vf(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}};up=new Gi,fp=new zi,lp=new Ki,hp=new Di,dp=new Wi,pp=new Yi,yp=new Xi,wp=new Ji,gp=new En(32),mp=new En(64),xp=new ur(8),_p=new ur(16),bp=new ur(32),Ep=new ur(64),Ap=new fr(8),vp=new fr(16),Tp=new fr(32),Sp=new fr(64),Bp=new Zi});var es=K(()=>{});var oa=K(()=>{ts();Wt();es()});var aa=K(()=>{});var lr=K(()=>{oa();es();ts();Vi();Li();_n();aa()});var Vr=Bt(dr=>{"use strict";var rs=mi(),hr=fn(),ca=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;dr.Buffer=S;dr.SlowBuffer=Df;dr.INSPECT_MAX_BYTES=50;var An=2147483647;dr.kMaxLength=An;S.TYPED_ARRAY_SUPPORT=Hf();!S.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 Hf(){try{var r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch{return!1}}Object.defineProperty(S.prototype,"parent",{enumerable:!0,get:function(){if(S.isBuffer(this))return this.buffer}});Object.defineProperty(S.prototype,"offset",{enumerable:!0,get:function(){if(S.isBuffer(this))return this.byteOffset}});function _e(r){if(r>An)throw new RangeError('The value "'+r+'" is invalid for option "size"');var t=new Uint8Array(r);return Object.setPrototypeOf(t,S.prototype),t}function S(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return os(r)}return la(r,t,e)}S.poolSize=8192;function la(r,t,e){if(typeof r=="string")return jf(r,t);if(ArrayBuffer.isView(r))return Gf(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(de(r,ArrayBuffer)||r&&de(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(de(r,SharedArrayBuffer)||r&&de(r.buffer,SharedArrayBuffer)))return is(r,t,e);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return S.from(n,t,e);var i=Kf(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return S.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}S.from=function(r,t,e){return la(r,t,e)};Object.setPrototypeOf(S.prototype,Uint8Array.prototype);Object.setPrototypeOf(S,Uint8Array);function ha(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function Lf(r,t,e){return ha(r),r<=0?_e(r):t!==void 0?typeof e=="string"?_e(r).fill(t,e):_e(r).fill(t):_e(r)}S.alloc=function(r,t,e){return Lf(r,t,e)};function os(r){return ha(r),_e(r<0?0:as(r)|0)}S.allocUnsafe=function(r){return os(r)};S.allocUnsafeSlow=function(r){return os(r)};function jf(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!S.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=da(r,t)|0,n=_e(e),i=n.write(r,t);return i!==e&&(n=n.slice(0,i)),n}function ns(r){for(var t=r.length<0?0:as(r.length)|0,e=_e(t),n=0;n<t;n+=1)e[n]=r[n]&255;return e}function Gf(r){if(de(r,Uint8Array)){var t=new Uint8Array(r);return is(t.buffer,t.byteOffset,t.byteLength)}return ns(r)}function is(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var n;return t===void 0&&e===void 0?n=new Uint8Array(r):e===void 0?n=new Uint8Array(r,t):n=new Uint8Array(r,t,e),Object.setPrototypeOf(n,S.prototype),n}function Kf(r){if(S.isBuffer(r)){var t=as(r.length)|0,e=_e(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||cs(r.length)?_e(0):ns(r);if(r.type==="Buffer"&&Array.isArray(r.data))return ns(r.data)}function as(r){if(r>=An)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+An.toString(16)+" bytes");return r|0}function Df(r){return+r!=r&&(r=0),S.alloc(+r)}S.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==S.prototype};S.compare=function(t,e){if(de(t,Uint8Array)&&(t=S.from(t,t.offset,t.byteLength)),de(e,Uint8Array)&&(e=S.from(e,e.offset,e.byteLength)),!S.isBuffer(t)||!S.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var n=t.length,i=e.length,s=0,o=Math.min(n,i);s<o;++s)if(t[s]!==e[s]){n=t[s],i=e[s];break}return n<i?-1:i<n?1:0};S.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};S.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return S.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var i=S.allocUnsafe(e),s=0;for(n=0;n<t.length;++n){var o=t[n];if(de(o,Uint8Array))s+o.length>i.length?S.from(o).copy(i,s):Uint8Array.prototype.set.call(i,o,s);else if(S.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function da(r,t){if(S.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||de(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);var e=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&e===0)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return ss(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return xa(r).length;default:if(i)return n?-1:ss(r).length;t=(""+t).toLowerCase(),i=!0}}S.byteLength=da;function Wf(r,t,e){var n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return nl(this,t,e);case"utf8":case"utf-8":return ya(this,t,e);case"ascii":return el(this,t,e);case"latin1":case"binary":return rl(this,t,e);case"base64":return Qf(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return il(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}S.prototype._isBuffer=!0;function Ge(r,t,e){var n=r[t];r[t]=r[e],r[e]=n}S.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)Ge(this,e,e+1);return this};S.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)Ge(this,e,e+3),Ge(this,e+1,e+2);return this};S.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)Ge(this,e,e+7),Ge(this,e+1,e+6),Ge(this,e+2,e+5),Ge(this,e+3,e+4);return this};S.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?ya(this,0,t):Wf.apply(this,arguments)};S.prototype.toLocaleString=S.prototype.toString;S.prototype.equals=function(t){if(!S.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:S.compare(this,t)===0};S.prototype.inspect=function(){var t="",e=dr.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};ca&&(S.prototype[ca]=S.prototype.inspect);S.prototype.compare=function(t,e,n,i,s){if(de(t,Uint8Array)&&(t=S.from(t,t.offset,t.byteLength)),!S.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),e<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&e>=n)return 0;if(i>=s)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;for(var o=s-i,c=n-e,u=Math.min(o,c),w=this.slice(i,s),y=t.slice(e,n),m=0;m<u;++m)if(w[m]!==y[m]){o=w[m],c=y[m];break}return o<c?-1:c<o?1:0};function pa(r,t,e,n,i){if(r.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,cs(e)&&(e=i?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(i)return-1;e=r.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=S.from(t,n)),S.isBuffer(t))return t.length===0?-1:ua(r,t,e,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):ua(r,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function ua(r,t,e,n,i){var s=1,o=r.length,c=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;s=2,o/=2,c/=2,e/=2}function u(k,O){return s===1?k[O]:k.readUInt16BE(O*s)}var w;if(i){var y=-1;for(w=e;w<o;w++)if(u(r,w)===u(t,y===-1?0:w-y)){if(y===-1&&(y=w),w-y+1===c)return y*s}else y!==-1&&(w-=w-y),y=-1}else for(e+c>o&&(e=o-c),w=e;w>=0;w--){for(var m=!0,N=0;N<c;N++)if(u(r,w+N)!==u(t,N)){m=!1;break}if(m)return w}return-1}S.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1};S.prototype.indexOf=function(t,e,n){return pa(this,t,e,n,!0)};S.prototype.lastIndexOf=function(t,e,n){return pa(this,t,e,n,!1)};function zf(r,t,e,n){e=Number(e)||0;var i=r.length-e;n?(n=Number(n),n>i&&(n=i)):n=i;var s=t.length;n>s/2&&(n=s/2);for(var o=0;o<n;++o){var c=parseInt(t.substr(o*2,2),16);if(cs(c))return o;r[e+o]=c}return o}function Yf(r,t,e,n){return vn(ss(t,r.length-e),r,e,n)}function Xf(r,t,e,n){return vn(al(t),r,e,n)}function Jf(r,t,e,n){return vn(xa(t),r,e,n)}function Zf(r,t,e,n){return vn(cl(t,r.length-e),r,e,n)}S.prototype.write=function(t,e,n,i){if(e===void 0)i="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")i=e,n=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s=this.length-e;if((n===void 0||n>s)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return zf(this,t,e,n);case"utf8":case"utf-8":return Yf(this,t,e,n);case"ascii":case"latin1":case"binary":return Xf(this,t,e,n);case"base64":return Jf(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Zf(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};S.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Qf(r,t,e){return t===0&&e===r.length?rs.fromByteArray(r):rs.fromByteArray(r.slice(t,e))}function ya(r,t,e){e=Math.min(r.length,e);for(var n=[],i=t;i<e;){var s=r[i],o=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=e){var u,w,y,m;switch(c){case 1:s<128&&(o=s);break;case 2:u=r[i+1],(u&192)===128&&(m=(s&31)<<6|u&63,m>127&&(o=m));break;case 3:u=r[i+1],w=r[i+2],(u&192)===128&&(w&192)===128&&(m=(s&15)<<12|(u&63)<<6|w&63,m>2047&&(m<55296||m>57343)&&(o=m));break;case 4:u=r[i+1],w=r[i+2],y=r[i+3],(u&192)===128&&(w&192)===128&&(y&192)===128&&(m=(s&15)<<18|(u&63)<<12|(w&63)<<6|y&63,m>65535&&m<1114112&&(o=m))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=c}return tl(n)}var fa=4096;function tl(r){var t=r.length;if(t<=fa)return String.fromCharCode.apply(String,r);for(var e="",n=0;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=fa));return e}function el(r,t,e){var n="";e=Math.min(r.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(r[i]&127);return n}function rl(r,t,e){var n="";e=Math.min(r.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(r[i]);return n}function nl(r,t,e){var n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);for(var i="",s=t;s<e;++s)i+=ul[r[s]];return i}function il(r,t,e){for(var n=r.slice(t,e),i="",s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}S.prototype.slice=function(t,e){var n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);var i=this.subarray(t,e);return Object.setPrototypeOf(i,S.prototype),i};function Pt(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}S.prototype.readUintLE=S.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||Pt(t,e,this.length);for(var i=this[t],s=1,o=0;++o<e&&(s*=256);)i+=this[t+o]*s;return i};S.prototype.readUintBE=S.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||Pt(t,e,this.length);for(var i=this[t+--e],s=1;e>0&&(s*=256);)i+=this[t+--e]*s;return i};S.prototype.readUint8=S.prototype.readUInt8=function(t,e){return t=t>>>0,e||Pt(t,1,this.length),this[t]};S.prototype.readUint16LE=S.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||Pt(t,2,this.length),this[t]|this[t+1]<<8};S.prototype.readUint16BE=S.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||Pt(t,2,this.length),this[t]<<8|this[t+1]};S.prototype.readUint32LE=S.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||Pt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};S.prototype.readUint32BE=S.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||Pt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};S.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||Pt(t,e,this.length);for(var i=this[t],s=1,o=0;++o<e&&(s*=256);)i+=this[t+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*e)),i};S.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||Pt(t,e,this.length);for(var i=e,s=1,o=this[t+--i];i>0&&(s*=256);)o+=this[t+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*e)),o};S.prototype.readInt8=function(t,e){return t=t>>>0,e||Pt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};S.prototype.readInt16LE=function(t,e){t=t>>>0,e||Pt(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};S.prototype.readInt16BE=function(t,e){t=t>>>0,e||Pt(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};S.prototype.readInt32LE=function(t,e){return t=t>>>0,e||Pt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};S.prototype.readInt32BE=function(t,e){return t=t>>>0,e||Pt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};S.prototype.readFloatLE=function(t,e){return t=t>>>0,e||Pt(t,4,this.length),hr.read(this,t,!0,23,4)};S.prototype.readFloatBE=function(t,e){return t=t>>>0,e||Pt(t,4,this.length),hr.read(this,t,!1,23,4)};S.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||Pt(t,8,this.length),hr.read(this,t,!0,52,8)};S.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||Pt(t,8,this.length),hr.read(this,t,!1,52,8)};function Gt(r,t,e,n,i,s){if(!S.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}S.prototype.writeUintLE=S.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){var s=Math.pow(2,8*n)-1;Gt(this,t,e,n,s,0)}var o=1,c=0;for(this[e]=t&255;++c<n&&(o*=256);)this[e+c]=t/o&255;return e+n};S.prototype.writeUintBE=S.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){var s=Math.pow(2,8*n)-1;Gt(this,t,e,n,s,0)}var o=n-1,c=1;for(this[e+o]=t&255;--o>=0&&(c*=256);)this[e+o]=t/c&255;return e+n};S.prototype.writeUint8=S.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||Gt(this,t,e,1,255,0),this[e]=t&255,e+1};S.prototype.writeUint16LE=S.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||Gt(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};S.prototype.writeUint16BE=S.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||Gt(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};S.prototype.writeUint32LE=S.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||Gt(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4};S.prototype.writeUint32BE=S.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||Gt(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};S.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){var s=Math.pow(2,8*n-1);Gt(this,t,e,n,s-1,-s)}var o=0,c=1,u=0;for(this[e]=t&255;++o<n&&(c*=256);)t<0&&u===0&&this[e+o-1]!==0&&(u=1),this[e+o]=(t/c>>0)-u&255;return e+n};S.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){var s=Math.pow(2,8*n-1);Gt(this,t,e,n,s-1,-s)}var o=n-1,c=1,u=0;for(this[e+o]=t&255;--o>=0&&(c*=256);)t<0&&u===0&&this[e+o+1]!==0&&(u=1),this[e+o]=(t/c>>0)-u&255;return e+n};S.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||Gt(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};S.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||Gt(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};S.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||Gt(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};S.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||Gt(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4};S.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||Gt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function wa(r,t,e,n,i,s){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function ga(r,t,e,n,i){return t=+t,e=e>>>0,i||wa(r,t,e,4,34028234663852886e22,-34028234663852886e22),hr.write(r,t,e,n,23,4),e+4}S.prototype.writeFloatLE=function(t,e,n){return ga(this,t,e,!0,n)};S.prototype.writeFloatBE=function(t,e,n){return ga(this,t,e,!1,n)};function ma(r,t,e,n,i){return t=+t,e=e>>>0,i||wa(r,t,e,8,17976931348623157e292,-17976931348623157e292),hr.write(r,t,e,n,52,8),e+8}S.prototype.writeDoubleLE=function(t,e,n){return ma(this,t,e,!0,n)};S.prototype.writeDoubleBE=function(t,e,n){return ma(this,t,e,!1,n)};S.prototype.copy=function(t,e,n,i){if(!S.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);var s=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),e),s};S.prototype.fill=function(t,e,n,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=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"&&!S.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){var s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);var o;if(typeof t=="number")for(o=e;o<n;++o)this[o]=t;else{var c=S.isBuffer(t)?t:S.from(t,i),u=c.length;if(u===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-e;++o)this[o+e]=c[o%u]}return this};var sl=/[^+/0-9A-Za-z-_]/g;function ol(r){if(r=r.split("=")[0],r=r.trim().replace(sl,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function ss(r,t){t=t||1/0;for(var e,n=r.length,i=null,s=[],o=0;o<n;++o){if(e=r.charCodeAt(o),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&s.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;s.push(e)}else if(e<2048){if((t-=2)<0)break;s.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;s.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;s.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return s}function al(r){for(var t=[],e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function cl(r,t){for(var e,n,i,s=[],o=0;o<r.length&&!((t-=2)<0);++o)e=r.charCodeAt(o),n=e>>8,i=e%256,s.push(i),s.push(n);return s}function xa(r){return rs.toByteArray(ol(r))}function vn(r,t,e,n){for(var i=0;i<n&&!(i+e>=t.length||i>=r.length);++i)t[i+e]=r[i];return i}function de(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function cs(r){return r!==r}var ul=function(){for(var r="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var n=e*16,i=0;i<16;++i)t[n+i]=r[e]+r[i];return t}()});var qr=Bt((_a,Tn)=>{(function(r){"use strict";var t,e=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",c=1e14,u=14,w=9007199254740991,y=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],m=1e7,N=1e9;function k(V){var q,nt,Z,U=B.prototype={constructor:B,toString:null,valueOf:null},ot=new B(1),et=20,st=4,wt=-7,It=21,Ct=-1e7,L=1e7,R=!1,P=1,G=0,Y={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},z="0123456789abcdefghijklmnopqrstuvwxyz",it=!0;function B(a,f){var l,b,g,_,v,d,x,A,E=this;if(!(E instanceof B))return new B(a,f);if(f==null){if(a&&a._isBigNumber===!0){E.s=a.s,!a.c||a.e>L?E.c=E.e=null:a.e<Ct?E.c=[E.e=0]:(E.e=a.e,E.c=a.c.slice());return}if((d=typeof a=="number")&&a*0==0){if(E.s=1/a<0?(a=-a,-1):1,a===~~a){for(_=0,v=a;v>=10;v/=10,_++);_>L?E.c=E.e=null:(E.e=_,E.c=[a]);return}A=String(a)}else{if(!e.test(A=String(a)))return Z(E,A,d);E.s=A.charCodeAt(0)==45?(A=A.slice(1),-1):1}(_=A.indexOf("."))>-1&&(A=A.replace(".","")),(v=A.search(/e/i))>0?(_<0&&(_=v),_+=+A.slice(v+1),A=A.substring(0,v)):_<0&&(_=A.length)}else{if(W(f,2,z.length,"Base"),f==10&&it)return E=new B(a),ut(E,et+E.e+1,st);if(A=String(a),d=typeof a=="number"){if(a*0!=0)return Z(E,A,d,f);if(E.s=1/a<0?(A=A.slice(1),-1):1,B.DEBUG&&A.replace(/^0\.0*|\./,"").length>15)throw Error(o+a)}else E.s=A.charCodeAt(0)===45?(A=A.slice(1),-1):1;for(l=z.slice(0,f),_=v=0,x=A.length;v<x;v++)if(l.indexOf(b=A.charAt(v))<0){if(b=="."){if(v>_){_=x;continue}}else if(!g&&(A==A.toUpperCase()&&(A=A.toLowerCase())||A==A.toLowerCase()&&(A=A.toUpperCase()))){g=!0,v=-1,_=0;continue}return Z(E,String(a),d,f)}d=!1,A=nt(A,f,10,E.s),(_=A.indexOf("."))>-1?A=A.replace(".",""):_=A.length}for(v=0;A.charCodeAt(v)===48;v++);for(x=A.length;A.charCodeAt(--x)===48;);if(A=A.slice(v,++x)){if(x-=v,d&&B.DEBUG&&x>15&&(a>w||a!==i(a)))throw Error(o+E.s*a);if((_=_-v-1)>L)E.c=E.e=null;else if(_<Ct)E.c=[E.e=0];else{if(E.e=_,E.c=[],v=(_+1)%u,_<0&&(v+=u),v<x){for(v&&E.c.push(+A.slice(0,v)),x-=u;v<x;)E.c.push(+A.slice(v,v+=u));v=u-(A=A.slice(v)).length}else v-=x;for(;v--;A+="0");E.c.push(+A)}}else E.c=[E.e=0]}B.clone=k,B.ROUND_UP=0,B.ROUND_DOWN=1,B.ROUND_CEIL=2,B.ROUND_FLOOR=3,B.ROUND_HALF_UP=4,B.ROUND_HALF_DOWN=5,B.ROUND_HALF_EVEN=6,B.ROUND_HALF_CEIL=7,B.ROUND_HALF_FLOOR=8,B.EUCLID=9,B.config=B.set=function(a){var f,l;if(a!=null)if(typeof a=="object"){if(a.hasOwnProperty(f="DECIMAL_PLACES")&&(l=a[f],W(l,0,N,f),et=l),a.hasOwnProperty(f="ROUNDING_MODE")&&(l=a[f],W(l,0,8,f),st=l),a.hasOwnProperty(f="EXPONENTIAL_AT")&&(l=a[f],l&&l.pop?(W(l[0],-N,0,f),W(l[1],0,N,f),wt=l[0],It=l[1]):(W(l,-N,N,f),wt=-(It=l<0?-l:l))),a.hasOwnProperty(f="RANGE"))if(l=a[f],l&&l.pop)W(l[0],-N,-1,f),W(l[1],1,N,f),Ct=l[0],L=l[1];else if(W(l,-N,N,f),l)Ct=-(L=l<0?-l:l);else throw Error(s+f+" cannot be zero: "+l);if(a.hasOwnProperty(f="CRYPTO"))if(l=a[f],l===!!l)if(l)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))R=l;else throw R=!l,Error(s+"crypto unavailable");else R=l;else throw Error(s+f+" not true or false: "+l);if(a.hasOwnProperty(f="MODULO_MODE")&&(l=a[f],W(l,0,9,f),P=l),a.hasOwnProperty(f="POW_PRECISION")&&(l=a[f],W(l,0,N,f),G=l),a.hasOwnProperty(f="FORMAT"))if(l=a[f],typeof l=="object")Y=l;else throw Error(s+f+" not an object: "+l);if(a.hasOwnProperty(f="ALPHABET"))if(l=a[f],typeof l=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(l))it=l.slice(0,10)=="0123456789",z=l;else throw Error(s+f+" invalid: "+l)}else throw Error(s+"Object expected: "+a);return{DECIMAL_PLACES:et,ROUNDING_MODE:st,EXPONENTIAL_AT:[wt,It],RANGE:[Ct,L],CRYPTO:R,MODULO_MODE:P,POW_PRECISION:G,FORMAT:Y,ALPHABET:z}},B.isBigNumber=function(a){if(!a||a._isBigNumber!==!0)return!1;if(!B.DEBUG)return!0;var f,l,b=a.c,g=a.e,_=a.s;t:if({}.toString.call(b)=="[object Array]"){if((_===1||_===-1)&&g>=-N&&g<=N&&g===i(g)){if(b[0]===0){if(g===0&&b.length===1)return!0;break t}if(f=(g+1)%u,f<1&&(f+=u),String(b[0]).length==f){for(f=0;f<b.length;f++)if(l=b[f],l<0||l>=c||l!==i(l))break t;if(l!==0)return!0}}}else if(b===null&&g===null&&(_===null||_===1||_===-1))return!0;throw Error(s+"Invalid BigNumber: "+a)},B.maximum=B.max=function(){return ct(arguments,-1)},B.minimum=B.min=function(){return ct(arguments,1)},B.random=function(){var a=9007199254740992,f=Math.random()*a&2097151?function(){return i(Math.random()*a)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(l){var b,g,_,v,d,x=0,A=[],E=new B(ot);if(l==null?l=et:W(l,0,N),v=n(l/u),R)if(crypto.getRandomValues){for(b=crypto.getRandomValues(new Uint32Array(v*=2));x<v;)d=b[x]*131072+(b[x+1]>>>11),d>=9e15?(g=crypto.getRandomValues(new Uint32Array(2)),b[x]=g[0],b[x+1]=g[1]):(A.push(d%1e14),x+=2);x=v/2}else if(crypto.randomBytes){for(b=crypto.randomBytes(v*=7);x<v;)d=(b[x]&31)*281474976710656+b[x+1]*1099511627776+b[x+2]*4294967296+b[x+3]*16777216+(b[x+4]<<16)+(b[x+5]<<8)+b[x+6],d>=9e15?crypto.randomBytes(7).copy(b,x):(A.push(d%1e14),x+=7);x=v/7}else throw R=!1,Error(s+"crypto unavailable");if(!R)for(;x<v;)d=f(),d<9e15&&(A[x++]=d%1e14);for(v=A[--x],l%=u,v&&l&&(d=y[u-l],A[x]=i(v/d)*d);A[x]===0;A.pop(),x--);if(x<0)A=[_=0];else{for(_=-1;A[0]===0;A.splice(0,1),_-=u);for(x=1,d=A[0];d>=10;d/=10,x++);x<u&&(_-=u-x)}return E.e=_,E.c=A,E}}(),B.sum=function(){for(var a=1,f=arguments,l=new B(f[0]);a<f.length;)l=l.plus(f[a++]);return l},nt=function(){var a="0123456789";function f(l,b,g,_){for(var v,d=[0],x,A=0,E=l.length;A<E;){for(x=d.length;x--;d[x]*=b);for(d[0]+=_.indexOf(l.charAt(A++)),v=0;v<d.length;v++)d[v]>g-1&&(d[v+1]==null&&(d[v+1]=0),d[v+1]+=d[v]/g|0,d[v]%=g)}return d.reverse()}return function(l,b,g,_,v){var d,x,A,E,I,F,$,J,dt=l.indexOf("."),mt=et,X=st;for(dt>=0&&(E=G,G=0,l=l.replace(".",""),J=new B(b),F=J.pow(l.length-dt),G=E,J.c=f(lt(j(F.c),F.e,"0"),10,g,a),J.e=J.c.length),$=f(l,b,g,v?(d=z,a):(d=a,z)),A=E=$.length;$[--E]==0;$.pop());if(!$[0])return d.charAt(0);if(dt<0?--A:(F.c=$,F.e=A,F.s=_,F=q(F,J,mt,X,g),$=F.c,I=F.r,A=F.e),x=A+mt+1,dt=$[x],E=g/2,I=I||x<0||$[x+1]!=null,I=X<4?(dt!=null||I)&&(X==0||X==(F.s<0?3:2)):dt>E||dt==E&&(X==4||I||X==6&&$[x-1]&1||X==(F.s<0?8:7)),x<1||!$[0])l=I?lt(d.charAt(1),-mt,d.charAt(0)):d.charAt(0);else{if($.length=x,I)for(--g;++$[--x]>g;)$[x]=0,x||(++A,$=[1].concat($));for(E=$.length;!$[--E];);for(dt=0,l="";dt<=E;l+=d.charAt($[dt++]));l=lt(l,A,d.charAt(0))}return l}}(),q=function(){function a(b,g,_){var v,d,x,A,E=0,I=b.length,F=g%m,$=g/m|0;for(b=b.slice();I--;)x=b[I]%m,A=b[I]/m|0,v=$*x+A*F,d=F*x+v%m*m+E,E=(d/_|0)+(v/m|0)+$*A,b[I]=d%_;return E&&(b=[E].concat(b)),b}function f(b,g,_,v){var d,x;if(_!=v)x=_>v?1:-1;else for(d=x=0;d<_;d++)if(b[d]!=g[d]){x=b[d]>g[d]?1:-1;break}return x}function l(b,g,_,v){for(var d=0;_--;)b[_]-=d,d=b[_]<g[_]?1:0,b[_]=d*v+b[_]-g[_];for(;!b[0]&&b.length>1;b.splice(0,1));}return function(b,g,_,v,d){var x,A,E,I,F,$,J,dt,mt,X,H,Tt,ve,$e,Ve,Qt,at,qt=b.s==g.s?1:-1,kt=b.c,xt=g.c;if(!kt||!kt[0]||!xt||!xt[0])return new B(!b.s||!g.s||(kt?xt&&kt[0]==xt[0]:!xt)?NaN:kt&&kt[0]==0||!xt?qt*0:qt/0);for(dt=new B(qt),mt=dt.c=[],A=b.e-g.e,qt=_+A+1,d||(d=c,A=O(b.e/u)-O(g.e/u),qt=qt/u|0),E=0;xt[E]==(kt[E]||0);E++);if(xt[E]>(kt[E]||0)&&A--,qt<0)mt.push(1),I=!0;else{for($e=kt.length,Qt=xt.length,E=0,qt+=2,F=i(d/(xt[0]+1)),F>1&&(xt=a(xt,F,d),kt=a(kt,F,d),Qt=xt.length,$e=kt.length),ve=Qt,X=kt.slice(0,Qt),H=X.length;H<Qt;X[H++]=0);at=xt.slice(),at=[0].concat(at),Ve=xt[0],xt[1]>=d/2&&Ve++;do{if(F=0,x=f(xt,X,Qt,H),x<0){if(Tt=X[0],Qt!=H&&(Tt=Tt*d+(X[1]||0)),F=i(Tt/Ve),F>1)for(F>=d&&(F=d-1),$=a(xt,F,d),J=$.length,H=X.length;f($,X,J,H)==1;)F--,l($,Qt<J?at:xt,J,d),J=$.length,x=1;else F==0&&(x=F=1),$=xt.slice(),J=$.length;if(J<H&&($=[0].concat($)),l(X,$,H,d),H=X.length,x==-1)for(;f(xt,X,Qt,H)<1;)F++,l(X,Qt<H?at:xt,H,d),H=X.length}else x===0&&(F++,X=[0]);mt[E++]=F,X[0]?X[H++]=kt[ve]||0:(X=[kt[ve]],H=1)}while((ve++<$e||X[0]!=null)&&qt--);I=X[0]!=null,mt[0]||mt.splice(0,1)}if(d==c){for(E=1,qt=mt[0];qt>=10;qt/=10,E++);ut(dt,_+(dt.e=E+A*u-1)+1,v,I)}else dt.e=A,dt.r=+I;return dt}}();function h(a,f,l,b){var g,_,v,d,x;if(l==null?l=st:W(l,0,8),!a.c)return a.toString();if(g=a.c[0],v=a.e,f==null)x=j(a.c),x=b==1||b==2&&(v<=wt||v>=It)?C(x,v):lt(x,v,"0");else if(a=ut(new B(a),f,l),_=a.e,x=j(a.c),d=x.length,b==1||b==2&&(f<=_||_<=wt)){for(;d<f;x+="0",d++);x=C(x,_)}else if(f-=v,x=lt(x,_,"0"),_+1>d){if(--f>0)for(x+=".";f--;x+="0");}else if(f+=_-d,f>0)for(_+1==d&&(x+=".");f--;x+="0");return a.s<0&&g?"-"+x:x}function ct(a,f){for(var l,b,g=1,_=new B(a[0]);g<a.length;g++)b=new B(a[g]),(!b.s||(l=ft(_,b))===f||l===0&&_.s===f)&&(_=b);return _}function gt(a,f,l){for(var b=1,g=f.length;!f[--g];f.pop());for(g=f[0];g>=10;g/=10,b++);return(l=b+l*u-1)>L?a.c=a.e=null:l<Ct?a.c=[a.e=0]:(a.e=l,a.c=f),a}Z=function(){var a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,f=/^([^.]+)\.$/,l=/^\.([^.]+)$/,b=/^-?(Infinity|NaN)$/,g=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(_,v,d,x){var A,E=d?v:v.replace(g,"");if(b.test(E))_.s=isNaN(E)?null:E<0?-1:1;else{if(!d&&(E=E.replace(a,function(I,F,$){return A=($=$.toLowerCase())=="x"?16:$=="b"?2:8,!x||x==A?F:I}),x&&(A=x,E=E.replace(f,"$1").replace(l,"0.$1")),v!=E))return new B(E,A);if(B.DEBUG)throw Error(s+"Not a"+(x?" base "+x:"")+" number: "+v);_.s=null}_.c=_.e=null}}();function ut(a,f,l,b){var g,_,v,d,x,A,E,I=a.c,F=y;if(I){t:{for(g=1,d=I[0];d>=10;d/=10,g++);if(_=f-g,_<0)_+=u,v=f,x=I[A=0],E=i(x/F[g-v-1]%10);else if(A=n((_+1)/u),A>=I.length)if(b){for(;I.length<=A;I.push(0));x=E=0,g=1,_%=u,v=_-u+1}else break t;else{for(x=d=I[A],g=1;d>=10;d/=10,g++);_%=u,v=_-u+g,E=v<0?0:i(x/F[g-v-1]%10)}if(b=b||f<0||I[A+1]!=null||(v<0?x:x%F[g-v-1]),b=l<4?(E||b)&&(l==0||l==(a.s<0?3:2)):E>5||E==5&&(l==4||b||l==6&&(_>0?v>0?x/F[g-v]:0:I[A-1])%10&1||l==(a.s<0?8:7)),f<1||!I[0])return I.length=0,b?(f-=a.e+1,I[0]=F[(u-f%u)%u],a.e=-f||0):I[0]=a.e=0,a;if(_==0?(I.length=A,d=1,A--):(I.length=A+1,d=F[u-_],I[A]=v>0?i(x/F[g-v]%F[v])*d:0),b)for(;;)if(A==0){for(_=1,v=I[0];v>=10;v/=10,_++);for(v=I[0]+=d,d=1;v>=10;v/=10,d++);_!=d&&(a.e++,I[0]==c&&(I[0]=1));break}else{if(I[A]+=d,I[A]!=c)break;I[A--]=0,d=1}for(_=I.length;I[--_]===0;I.pop());}a.e>L?a.c=a.e=null:a.e<Ct&&(a.c=[a.e=0])}return a}function M(a){var f,l=a.e;return l===null?a.toString():(f=j(a.c),f=l<=wt||l>=It?C(f,l):lt(f,l,"0"),a.s<0?"-"+f:f)}return U.absoluteValue=U.abs=function(){var a=new B(this);return a.s<0&&(a.s=1),a},U.comparedTo=function(a,f){return ft(this,new B(a,f))},U.decimalPlaces=U.dp=function(a,f){var l,b,g,_=this;if(a!=null)return W(a,0,N),f==null?f=st:W(f,0,8),ut(new B(_),a+_.e+1,f);if(!(l=_.c))return null;if(b=((g=l.length-1)-O(this.e/u))*u,g=l[g])for(;g%10==0;g/=10,b--);return b<0&&(b=0),b},U.dividedBy=U.div=function(a,f){return q(this,new B(a,f),et,st)},U.dividedToIntegerBy=U.idiv=function(a,f){return q(this,new B(a,f),0,1)},U.exponentiatedBy=U.pow=function(a,f){var l,b,g,_,v,d,x,A,E,I=this;if(a=new B(a),a.c&&!a.isInteger())throw Error(s+"Exponent not an integer: "+M(a));if(f!=null&&(f=new B(f)),d=a.e>14,!I.c||!I.c[0]||I.c[0]==1&&!I.e&&I.c.length==1||!a.c||!a.c[0])return E=new B(Math.pow(+M(I),d?a.s*(2-Mt(a)):+M(a))),f?E.mod(f):E;if(x=a.s<0,f){if(f.c?!f.c[0]:!f.s)return new B(NaN);b=!x&&I.isInteger()&&f.isInteger(),b&&(I=I.mod(f))}else{if(a.e>9&&(I.e>0||I.e<-1||(I.e==0?I.c[0]>1||d&&I.c[1]>=24e7:I.c[0]<8e13||d&&I.c[0]<=9999975e7)))return _=I.s<0&&Mt(a)?-0:0,I.e>-1&&(_=1/_),new B(x?1/_:_);G&&(_=n(G/u+2))}for(d?(l=new B(.5),x&&(a.s=1),A=Mt(a)):(g=Math.abs(+M(a)),A=g%2),E=new B(ot);;){if(A){if(E=E.times(I),!E.c)break;_?E.c.length>_&&(E.c.length=_):b&&(E=E.mod(f))}if(g){if(g=i(g/2),g===0)break;A=g%2}else if(a=a.times(l),ut(a,a.e+1,1),a.e>14)A=Mt(a);else{if(g=+M(a),g===0)break;A=g%2}I=I.times(I),_?I.c&&I.c.length>_&&(I.c.length=_):b&&(I=I.mod(f))}return b?E:(x&&(E=ot.div(E)),f?E.mod(f):_?ut(E,G,st,v):E)},U.integerValue=function(a){var f=new B(this);return a==null?a=st:W(a,0,8),ut(f,f.e+1,a)},U.isEqualTo=U.eq=function(a,f){return ft(this,new B(a,f))===0},U.isFinite=function(){return!!this.c},U.isGreaterThan=U.gt=function(a,f){return ft(this,new B(a,f))>0},U.isGreaterThanOrEqualTo=U.gte=function(a,f){return(f=ft(this,new B(a,f)))===1||f===0},U.isInteger=function(){return!!this.c&&O(this.e/u)>this.c.length-2},U.isLessThan=U.lt=function(a,f){return ft(this,new B(a,f))<0},U.isLessThanOrEqualTo=U.lte=function(a,f){return(f=ft(this,new B(a,f)))===-1||f===0},U.isNaN=function(){return!this.s},U.isNegative=function(){return this.s<0},U.isPositive=function(){return this.s>0},U.isZero=function(){return!!this.c&&this.c[0]==0},U.minus=function(a,f){var l,b,g,_,v=this,d=v.s;if(a=new B(a,f),f=a.s,!d||!f)return new B(NaN);if(d!=f)return a.s=-f,v.plus(a);var x=v.e/u,A=a.e/u,E=v.c,I=a.c;if(!x||!A){if(!E||!I)return E?(a.s=-f,a):new B(I?v:NaN);if(!E[0]||!I[0])return I[0]?(a.s=-f,a):new B(E[0]?v:st==3?-0:0)}if(x=O(x),A=O(A),E=E.slice(),d=x-A){for((_=d<0)?(d=-d,g=E):(A=x,g=I),g.reverse(),f=d;f--;g.push(0));g.reverse()}else for(b=(_=(d=E.length)<(f=I.length))?d:f,d=f=0;f<b;f++)if(E[f]!=I[f]){_=E[f]<I[f];break}if(_&&(g=E,E=I,I=g,a.s=-a.s),f=(b=I.length)-(l=E.length),f>0)for(;f--;E[l++]=0);for(f=c-1;b>d;){if(E[--b]<I[b]){for(l=b;l&&!E[--l];E[l]=f);--E[l],E[b]+=c}E[b]-=I[b]}for(;E[0]==0;E.splice(0,1),--A);return E[0]?gt(a,E,A):(a.s=st==3?-1:1,a.c=[a.e=0],a)},U.modulo=U.mod=function(a,f){var l,b,g=this;return a=new B(a,f),!g.c||!a.s||a.c&&!a.c[0]?new B(NaN):!a.c||g.c&&!g.c[0]?new B(g):(P==9?(b=a.s,a.s=1,l=q(g,a,0,3),a.s=b,l.s*=b):l=q(g,a,0,P),a=g.minus(l.times(a)),!a.c[0]&&P==1&&(a.s=g.s),a)},U.multipliedBy=U.times=function(a,f){var l,b,g,_,v,d,x,A,E,I,F,$,J,dt,mt,X=this,H=X.c,Tt=(a=new B(a,f)).c;if(!H||!Tt||!H[0]||!Tt[0])return!X.s||!a.s||H&&!H[0]&&!Tt||Tt&&!Tt[0]&&!H?a.c=a.e=a.s=null:(a.s*=X.s,!H||!Tt?a.c=a.e=null:(a.c=[0],a.e=0)),a;for(b=O(X.e/u)+O(a.e/u),a.s*=X.s,x=H.length,I=Tt.length,x<I&&(J=H,H=Tt,Tt=J,g=x,x=I,I=g),g=x+I,J=[];g--;J.push(0));for(dt=c,mt=m,g=I;--g>=0;){for(l=0,F=Tt[g]%mt,$=Tt[g]/mt|0,v=x,_=g+v;_>g;)A=H[--v]%mt,E=H[v]/mt|0,d=$*A+E*F,A=F*A+d%mt*mt+J[_]+l,l=(A/dt|0)+(d/mt|0)+$*E,J[_--]=A%dt;J[_]=l}return l?++b:J.splice(0,1),gt(a,J,b)},U.negated=function(){var a=new B(this);return a.s=-a.s||null,a},U.plus=function(a,f){var l,b=this,g=b.s;if(a=new B(a,f),f=a.s,!g||!f)return new B(NaN);if(g!=f)return a.s=-f,b.minus(a);var _=b.e/u,v=a.e/u,d=b.c,x=a.c;if(!_||!v){if(!d||!x)return new B(g/0);if(!d[0]||!x[0])return x[0]?a:new B(d[0]?b:g*0)}if(_=O(_),v=O(v),d=d.slice(),g=_-v){for(g>0?(v=_,l=x):(g=-g,l=d),l.reverse();g--;l.push(0));l.reverse()}for(g=d.length,f=x.length,g-f<0&&(l=x,x=d,d=l,f=g),g=0;f;)g=(d[--f]=d[f]+x[f]+g)/c|0,d[f]=c===d[f]?0:d[f]%c;return g&&(d=[g].concat(d),++v),gt(a,d,v)},U.precision=U.sd=function(a,f){var l,b,g,_=this;if(a!=null&&a!==!!a)return W(a,1,N),f==null?f=st:W(f,0,8),ut(new B(_),a,f);if(!(l=_.c))return null;if(g=l.length-1,b=g*u+1,g=l[g]){for(;g%10==0;g/=10,b--);for(g=l[0];g>=10;g/=10,b++);}return a&&_.e+1>b&&(b=_.e+1),b},U.shiftedBy=function(a){return W(a,-w,w),this.times("1e"+a)},U.squareRoot=U.sqrt=function(){var a,f,l,b,g,_=this,v=_.c,d=_.s,x=_.e,A=et+4,E=new B("0.5");if(d!==1||!v||!v[0])return new B(!d||d<0&&(!v||v[0])?NaN:v?_:1/0);if(d=Math.sqrt(+M(_)),d==0||d==1/0?(f=j(v),(f.length+x)%2==0&&(f+="0"),d=Math.sqrt(+f),x=O((x+1)/2)-(x<0||x%2),d==1/0?f="5e"+x:(f=d.toExponential(),f=f.slice(0,f.indexOf("e")+1)+x),l=new B(f)):l=new B(d+""),l.c[0]){for(x=l.e,d=x+A,d<3&&(d=0);;)if(g=l,l=E.times(g.plus(q(_,g,A,1))),j(g.c).slice(0,d)===(f=j(l.c)).slice(0,d))if(l.e<x&&--d,f=f.slice(d-3,d+1),f=="9999"||!b&&f=="4999"){if(!b&&(ut(g,g.e+et+2,0),g.times(g).eq(_))){l=g;break}A+=4,d+=4,b=1}else{(!+f||!+f.slice(1)&&f.charAt(0)=="5")&&(ut(l,l.e+et+2,1),a=!l.times(l).eq(_));break}}return ut(l,l.e+et+1,st,a)},U.toExponential=function(a,f){return a!=null&&(W(a,0,N),a++),h(this,a,f,1)},U.toFixed=function(a,f){return a!=null&&(W(a,0,N),a=a+this.e+1),h(this,a,f)},U.toFormat=function(a,f,l){var b,g=this;if(l==null)a!=null&&f&&typeof f=="object"?(l=f,f=null):a&&typeof a=="object"?(l=a,a=f=null):l=Y;else if(typeof l!="object")throw Error(s+"Argument not an object: "+l);if(b=g.toFixed(a,f),g.c){var _,v=b.split("."),d=+l.groupSize,x=+l.secondaryGroupSize,A=l.groupSeparator||"",E=v[0],I=v[1],F=g.s<0,$=F?E.slice(1):E,J=$.length;if(x&&(_=d,d=x,x=_,J-=_),d>0&&J>0){for(_=J%d||d,E=$.substr(0,_);_<J;_+=d)E+=A+$.substr(_,d);x>0&&(E+=A+$.slice(_)),F&&(E="-"+E)}b=I?E+(l.decimalSeparator||"")+((x=+l.fractionGroupSize)?I.replace(new RegExp("\\d{"+x+"}\\B","g"),"$&"+(l.fractionGroupSeparator||"")):I):E}return(l.prefix||"")+b+(l.suffix||"")},U.toFraction=function(a){var f,l,b,g,_,v,d,x,A,E,I,F,$=this,J=$.c;if(a!=null&&(d=new B(a),!d.isInteger()&&(d.c||d.s!==1)||d.lt(ot)))throw Error(s+"Argument "+(d.isInteger()?"out of range: ":"not an integer: ")+M(d));if(!J)return new B($);for(f=new B(ot),A=l=new B(ot),b=x=new B(ot),F=j(J),_=f.e=F.length-$.e-1,f.c[0]=y[(v=_%u)<0?u+v:v],a=!a||d.comparedTo(f)>0?_>0?f:A:d,v=L,L=1/0,d=new B(F),x.c[0]=0;E=q(d,f,0,1),g=l.plus(E.times(b)),g.comparedTo(a)!=1;)l=b,b=g,A=x.plus(E.times(g=A)),x=g,f=d.minus(E.times(g=f)),d=g;return g=q(a.minus(l),b,0,1),x=x.plus(g.times(A)),l=l.plus(g.times(b)),x.s=A.s=$.s,_=_*2,I=q(A,b,_,st).minus($).abs().comparedTo(q(x,l,_,st).minus($).abs())<1?[A,b]:[x,l],L=v,I},U.toNumber=function(){return+M(this)},U.toPrecision=function(a,f){return a!=null&&W(a,1,N),h(this,a,f,2)},U.toString=function(a){var f,l=this,b=l.s,g=l.e;return g===null?b?(f="Infinity",b<0&&(f="-"+f)):f="NaN":(a==null?f=g<=wt||g>=It?C(j(l.c),g):lt(j(l.c),g,"0"):a===10&&it?(l=ut(new B(l),et+g+1,st),f=lt(j(l.c),l.e,"0")):(W(a,2,z.length,"Base"),f=nt(lt(j(l.c),g,"0"),10,a,b,!0)),b<0&&l.c[0]&&(f="-"+f)),f},U.valueOf=U.toJSON=function(){return M(this)},U._isBigNumber=!0,V!=null&&B.set(V),B}function O(V){var q=V|0;return V>0||V===q?q:q-1}function j(V){for(var q,nt,Z=1,U=V.length,ot=V[0]+"";Z<U;){for(q=V[Z++]+"",nt=u-q.length;nt--;q="0"+q);ot+=q}for(U=ot.length;ot.charCodeAt(--U)===48;);return ot.slice(0,U+1||1)}function ft(V,q){var nt,Z,U=V.c,ot=q.c,et=V.s,st=q.s,wt=V.e,It=q.e;if(!et||!st)return null;if(nt=U&&!U[0],Z=ot&&!ot[0],nt||Z)return nt?Z?0:-st:et;if(et!=st)return et;if(nt=et<0,Z=wt==It,!U||!ot)return Z?0:!U^nt?1:-1;if(!Z)return wt>It^nt?1:-1;for(st=(wt=U.length)<(It=ot.length)?wt:It,et=0;et<st;et++)if(U[et]!=ot[et])return U[et]>ot[et]^nt?1:-1;return wt==It?0:wt>It^nt?1:-1}function W(V,q,nt,Z){if(V<q||V>nt||V!==i(V))throw Error(s+(Z||"Argument")+(typeof V=="number"?V<q||V>nt?" out of range: ":" not an integer: ":" not a primitive number: ")+String(V))}function Mt(V){var q=V.c.length-1;return O(V.e/u)==q&&V.c[q]%2!=0}function C(V,q){return(V.length>1?V.charAt(0)+"."+V.slice(1):V)+(q<0?"e":"e+")+q}function lt(V,q,nt){var Z,U;if(q<0){for(U=nt+".";++q;U+=nt);V=U+V}else if(Z=V.length,++q>Z){for(U=nt,q-=Z;--q;U+=nt);V+=U}else q<Z&&(V=V.slice(0,q)+"."+V.slice(q));return V}t=k(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd?define(function(){return t}):typeof Tn<"u"&&Tn.exports?Tn.exports=t:(r||(r=typeof self<"u"&&self?self:window),r.BigNumber=t)})(_a)});var Ea=Bt((Kp,ba)=>{ba.exports=function(t,e,n){var i=new t.Uint8Array(n),s=e.pushInt,o=e.pushInt32,c=e.pushInt32Neg,u=e.pushInt64,w=e.pushInt64Neg,y=e.pushFloat,m=e.pushFloatSingle,N=e.pushFloatDouble,k=e.pushTrue,O=e.pushFalse,j=e.pushUndefined,ft=e.pushNull,W=e.pushInfinity,Mt=e.pushInfinityNeg,C=e.pushNaN,lt=e.pushNaNNeg,V=e.pushArrayStart,q=e.pushArrayStartFixed,nt=e.pushArrayStartFixed32,Z=e.pushArrayStartFixed64,U=e.pushObjectStart,ot=e.pushObjectStartFixed,et=e.pushObjectStartFixed32,st=e.pushObjectStartFixed64,wt=e.pushByteString,It=e.pushByteStringStart,Ct=e.pushUtf8String,L=e.pushUtf8StringStart,R=e.pushSimpleUnassigned,P=e.pushTagStart,G=e.pushTagStart4,Y=e.pushTagStart8,z=e.pushTagUnassigned,it=e.pushBreak,B=t.Math.pow,h=0,ct=0,gt=0;function ut(p){for(p=p|0,h=0,ct=p;(h|0)<(ct|0)&&(gt=ju[i[h]&255](i[h]|0)|0,!((gt|0)>0)););return gt|0}function M(p){return p=p|0,((h|0)+(p|0)|0)<(ct|0)?0:1}function a(p){return p=p|0,i[p|0]<<8|i[p+1|0]|0}function f(p){return p=p|0,i[p|0]<<24|i[p+1|0]<<16|i[p+2|0]<<8|i[p+3|0]|0}function l(p){return p=p|0,s(p|0),h=h+1|0,0}function b(p){return p=p|0,M(1)|0?1:(s(i[h+1|0]|0),h=h+2|0,0)}function g(p){return p=p|0,M(2)|0?1:(s(a(h+1|0)|0),h=h+3|0,0)}function _(p){return p=p|0,M(4)|0?1:(o(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function v(p){return p=p|0,M(8)|0?1:(u(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function d(p){return p=p|0,s(-1-(p-32|0)|0),h=h+1|0,0}function x(p){return p=p|0,M(1)|0?1:(s(-1-(i[h+1|0]|0)|0),h=h+2|0,0)}function A(p){p=p|0;var tt=0;return M(2)|0?1:(tt=a(h+1|0)|0,s(-1-(tt|0)|0),h=h+3|0,0)}function E(p){return p=p|0,M(4)|0?1:(c(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function I(p){return p=p|0,M(8)|0?1:(w(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function F(p){p=p|0;var tt=0,rt=0,Q=0;return Q=p-64|0,M(Q|0)|0?1:(tt=h+1|0,rt=(h+1|0)+(Q|0)|0,wt(tt|0,rt|0),h=rt|0,0)}function $(p){p=p|0;var tt=0,rt=0,Q=0;return M(1)|0||(Q=i[h+1|0]|0,tt=h+2|0,rt=(h+2|0)+(Q|0)|0,M(Q+1|0)|0)?1:(wt(tt|0,rt|0),h=rt|0,0)}function J(p){p=p|0;var tt=0,rt=0,Q=0;return M(2)|0||(Q=a(h+1|0)|0,tt=h+3|0,rt=(h+3|0)+(Q|0)|0,M(Q+2|0)|0)?1:(wt(tt|0,rt|0),h=rt|0,0)}function dt(p){p=p|0;var tt=0,rt=0,Q=0;return M(4)|0||(Q=f(h+1|0)|0,tt=h+5|0,rt=(h+5|0)+(Q|0)|0,M(Q+4|0)|0)?1:(wt(tt|0,rt|0),h=rt|0,0)}function mt(p){return p=p|0,1}function X(p){return p=p|0,It(),h=h+1|0,0}function H(p){p=p|0;var tt=0,rt=0,Q=0;return Q=p-96|0,M(Q|0)|0?1:(tt=h+1|0,rt=(h+1|0)+(Q|0)|0,Ct(tt|0,rt|0),h=rt|0,0)}function Tt(p){p=p|0;var tt=0,rt=0,Q=0;return M(1)|0||(Q=i[h+1|0]|0,tt=h+2|0,rt=(h+2|0)+(Q|0)|0,M(Q+1|0)|0)?1:(Ct(tt|0,rt|0),h=rt|0,0)}function ve(p){p=p|0;var tt=0,rt=0,Q=0;return M(2)|0||(Q=a(h+1|0)|0,tt=h+3|0,rt=(h+3|0)+(Q|0)|0,M(Q+2|0)|0)?1:(Ct(tt|0,rt|0),h=rt|0,0)}function $e(p){p=p|0;var tt=0,rt=0,Q=0;return M(4)|0||(Q=f(h+1|0)|0,tt=h+5|0,rt=(h+5|0)+(Q|0)|0,M(Q+4|0)|0)?1:(Ct(tt|0,rt|0),h=rt|0,0)}function Ve(p){return p=p|0,1}function Qt(p){return p=p|0,L(),h=h+1|0,0}function at(p){return p=p|0,q(p-128|0),h=h+1|0,0}function qt(p){return p=p|0,M(1)|0?1:(q(i[h+1|0]|0),h=h+2|0,0)}function kt(p){return p=p|0,M(2)|0?1:(q(a(h+1|0)|0),h=h+3|0,0)}function xt(p){return p=p|0,M(4)|0?1:(nt(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function Au(p){return p=p|0,M(8)|0?1:(Z(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function vu(p){return p=p|0,V(),h=h+1|0,0}function _t(p){p=p|0;var tt=0;return tt=p-160|0,M(tt|0)|0?1:(ot(tt|0),h=h+1|0,0)}function Tu(p){return p=p|0,M(1)|0?1:(ot(i[h+1|0]|0),h=h+2|0,0)}function Su(p){return p=p|0,M(2)|0?1:(ot(a(h+1|0)|0),h=h+3|0,0)}function Bu(p){return p=p|0,M(4)|0?1:(et(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function Iu(p){return p=p|0,M(8)|0?1:(st(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function Nu(p){return p=p|0,U(),h=h+1|0,0}function Qe(p){return p=p|0,P(p-192|0|0),h=h+1|0,0}function hd(p){return p=p|0,P(p|0),h=h+1|0,0}function dd(p){return p=p|0,P(p|0),h=h+1|0,0}function pd(p){return p=p|0,P(p|0),h=h+1|0,0}function yd(p){return p=p|0,P(p|0),h=h+1|0,0}function Ft(p){return p=p|0,P(p-192|0|0),h=h+1|0,0}function wd(p){return p=p|0,P(p|0),h=h+1|0,0}function gd(p){return p=p|0,P(p|0),h=h+1|0,0}function md(p){return p=p|0,P(p|0),h=h+1|0,0}function Uu(p){return p=p|0,M(1)|0?1:(P(i[h+1|0]|0),h=h+2|0,0)}function Ru(p){return p=p|0,M(2)|0?1:(P(a(h+1|0)|0),h=h+3|0,0)}function Fu(p){return p=p|0,M(4)|0?1:(G(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function Ou(p){return p=p|0,M(8)|0?1:(Y(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function St(p){return p=p|0,R((p|0)-224|0),h=h+1|0,0}function Pu(p){return p=p|0,O(),h=h+1|0,0}function ku(p){return p=p|0,k(),h=h+1|0,0}function Mu(p){return p=p|0,ft(),h=h+1|0,0}function Cu(p){return p=p|0,j(),h=h+1|0,0}function $u(p){return p=p|0,M(1)|0?1:(R(i[h+1|0]|0),h=h+2|0,0)}function Vu(p){p=p|0;var tt=0,rt=0,Q=1,cn=0,Ur=0,xd=0;return M(2)|0?1:(tt=i[h+1|0]|0,rt=i[h+2|0]|0,(tt|0)&128&&(Q=-1),cn=+(((tt|0)&124)>>2),Ur=+(((tt|0)&3)<<8|rt),+cn==0?y(+(+Q*5960464477539063e-23*+Ur)):+cn==31?+Q==1?+Ur>0?C():W():+Ur>0?lt():Mt():y(+(+Q*B(2,+(+cn-25))*+(1024+Ur))),h=h+3|0,0)}function qu(p){return p=p|0,M(4)|0?1:(m(i[h+1|0]|0,i[h+2|0]|0,i[h+3|0]|0,i[h+4|0]|0),h=h+5|0,0)}function Hu(p){return p=p|0,M(8)|0?1:(N(i[h+1|0]|0,i[h+2|0]|0,i[h+3|0]|0,i[h+4|0]|0,i[h+5|0]|0,i[h+6|0]|0,i[h+7|0]|0,i[h+8|0]|0),h=h+9|0,0)}function pt(p){return p=p|0,1}function Lu(p){return p=p|0,it(),h=h+1|0,0}var ju=[l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,b,g,_,v,pt,pt,pt,pt,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,x,A,E,I,pt,pt,pt,pt,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,$,J,dt,mt,pt,pt,pt,X,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,Tt,ve,$e,Ve,pt,pt,pt,Qt,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,qt,kt,xt,Au,pt,pt,pt,vu,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,Tu,Su,Bu,Iu,pt,pt,pt,Nu,Qe,Qe,Qe,Qe,Qe,Qe,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Uu,Ru,Fu,Ou,pt,pt,pt,pt,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,Pu,ku,Mu,Cu,$u,Vu,qu,Hu,pt,pt,pt,Lu];return{parse:ut}}});var Hr=Bt(Jt=>{"use strict";var us=qr().BigNumber;Jt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Jt.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};Jt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Jt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Jt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Jt.SHIFT32=Math.pow(2,32);Jt.SHIFT16=Math.pow(2,16);Jt.MAX_SAFE_HIGH=2097151;Jt.NEG_ONE=new us(-1);Jt.TEN=new us(10);Jt.TWO=new us(2);Jt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Sn=Bt(re=>{"use strict";var{Buffer:fl}=Vr(),va=qr().BigNumber,Ta=Hr(),Aa=Ta.SHIFT32,ll=Ta.SHIFT16,hl=2097151;re.parseHalf=function(t){var e,n,i;return i=t[0]&128?-1:1,e=(t[0]&124)>>2,n=(t[0]&3)<<8|t[1],e?e===31?i*(n?NaN:1/0):i*Math.pow(2,e-25)*(1024+n):i*5960464477539063e-23*n};function dl(r){return r<16?"0"+r.toString(16):r.toString(16)}re.arrayBufferToBignumber=function(r){let t=r.byteLength,e="";for(let n=0;n<t;n++)e+=dl(r[n]);return new va(e,16)};re.buildMap=r=>{let t=new Map,e=Object.keys(r),n=e.length;for(let i=0;i<n;i++)t.set(e[i],r[e[i]]);return t};re.buildInt32=(r,t)=>r*ll+t;re.buildInt64=(r,t,e,n)=>{let i=re.buildInt32(r,t),s=re.buildInt32(e,n);return i>hl?new va(i).times(Aa).plus(s):i*Aa+s};re.writeHalf=function(t,e){let n=fl.allocUnsafe(4);n.writeFloatBE(e,0);let i=n.readUInt32BE(0);if(i&8191)return!1;var s=i>>16&32768;let o=i>>23&255,c=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(c>>13);else if(o>=103&&o<113){if(c&(1<<126-o)-1)return!1;s+=c+8388608>>126-o}else return!1;return t.writeUInt16BE(s,0),!0};re.keySorter=function(r,t){var e=r[0].byteLength,n=t[0].byteLength;return e>n?1:n>e?-1:r[0].compare(t[0])};re.isNegativeZero=r=>r===0&&1/r<0;re.nextPowerOf2=r=>{let t=0;if(r&&!(r&r-1))return r;for(;r!==0;)r>>=1,t+=1;return 1<<t}});var ds=Bt((zp,Sa)=>{"use strict";var hs=Hr(),pl=hs.MT,Bn=hs.SIMPLE,fs=hs.SYMS,ls=class r{constructor(t){if(typeof t!="number")throw new Error("Invalid Simple type: "+typeof t);if(t<0||t>255||(t|0)!==t)throw new Error("value must be a small positive integer: "+t);this.value=t}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(t){return t._pushInt(this.value,pl.SIMPLE_FLOAT)}static isSimple(t){return t instanceof r}static decode(t,e){switch(e==null&&(e=!0),t){case Bn.FALSE:return!1;case Bn.TRUE:return!0;case Bn.NULL:return e?null:fs.NULL;case Bn.UNDEFINED:return e?void 0:fs.UNDEFINED;case-1:if(!e)throw new Error("Invalid BREAK");return fs.BREAK;default:return new r(t)}}};Sa.exports=ls});var ys=Bt((Yp,Ba)=>{"use strict";var ps=class r{constructor(t,e,n){if(this.tag=t,this.value=e,this.err=n,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(t){return t._pushTag(this.tag),t.pushAny(this.value)}convert(t){var e,n;if(n=t?.[this.tag],typeof n!="function"&&(n=r["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(r,this.value)}catch(i){return e=i,this.err=e,this}}};Ba.exports=ps});var ms=Bt((Xp,Na)=>{"use strict";var Ia=self.location?self.location.protocol+"//"+self.location.host:"",ws=self.URL,gs=class{constructor(t="",e=Ia){this.super=new ws(t,e),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(t){this.super.hash=t}set host(t){this.super.host=t}set hostname(t){this.super.hostname=t}set href(t){this.super.href=t}set origin(t){this.super.origin=t}set password(t){this.super.password=t}set pathname(t){this.super.pathname=t}set port(t){this.super.port=t}set protocol(t){this.super.protocol=t}set search(t){this.super.search=t}set searchParams(t){this.super.searchParams=t}set username(t){this.super.username=t}createObjectURL(t){return this.super.createObjectURL(t)}revokeObjectURL(t){this.super.revokeObjectURL(t)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function yl(r){if(typeof r=="string")return new ws(r).toString();if(!(r instanceof ws)){let t=r.username&&r.password?`${r.username}:${r.password}@`:"",e=r.auth?r.auth+"@":"",n=r.port?":"+r.port:"",i=r.protocol?r.protocol+"//":"",s=r.host||"",o=r.hostname||"",c=r.search||(r.query?"?"+r.query:""),u=r.hash||"",w=r.pathname||"",y=r.path||w+c;return`${i}${t||e}${s||o+n}${y}${u}`}}Na.exports={URLWithLegacySupport:gs,URLSearchParams:self.URLSearchParams,defaultBase:Ia,format:yl}});var Fa=Bt((Jp,Ra)=>{"use strict";var{URLWithLegacySupport:Ua,format:wl}=ms();Ra.exports=(r,t={},e={},n)=>{let i=t.protocol?t.protocol.replace(":",""):"http";i=(e[i]||n||i)+":";let s;try{s=new Ua(r)}catch{s={}}let o=Object.assign({},t,{protocol:i||s.protocol,host:t.host||s.host});return new Ua(r,wl(o)).toString()}});var xs=Bt((Zp,Oa)=>{"use strict";var{URLWithLegacySupport:gl,format:ml,URLSearchParams:xl,defaultBase:_l}=ms(),bl=Fa();Oa.exports={URL:gl,URLSearchParams:xl,format:ml,relative:bl,defaultBase:_l}});var _s=Bt((Qp,ka)=>{"use strict";var{Buffer:pr}=Vr(),Pa=fn(),El=qr().BigNumber,Al=Ea(),Vt=Sn(),ht=Hr(),vl=ds(),Tl=ys(),{URL:Sl}=xs(),Lr=class r{constructor(t){t=t||{},!t.size||t.size<65536?t.size=65536:t.size=Vt.nextPowerOf2(t.size),this._heap=new ArrayBuffer(t.size),this._heap8=new Uint8Array(this._heap),this._buffer=pr.from(this._heap),this._reset(),this._knownTags=Object.assign({0:e=>new Date(e),1:e=>new Date(e*1e3),2:e=>Vt.arrayBufferToBignumber(e),3:e=>ht.NEG_ONE.minus(Vt.arrayBufferToBignumber(e)),4:e=>ht.TEN.pow(e[0]).times(e[1]),5:e=>ht.TWO.pow(e[0]).times(e[1]),32:e=>new Sl(e),35:e=>new RegExp(e)},t.tags),this.parser=Al(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 t=this._parents.pop();if(t.length>0)throw new Error(`Missing ${t.length} elements`);switch(t.type){case ht.PARENT.TAG:this._push(this.createTag(t.ref[0],t.ref[1]));break;case ht.PARENT.BYTE_STRING:this._push(this.createByteString(t.ref,t.length));break;case ht.PARENT.UTF8_STRING:this._push(this.createUtf8String(t.ref,t.length));break;case ht.PARENT.MAP:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(t.ref,t.length));break;case ht.PARENT.OBJECT:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(t.ref,t.length));break;case ht.PARENT.ARRAY:this._push(this.createArray(t.ref,t.length));break;default:break}this._currentParent&&this._currentParent.type===ht.PARENT.TAG&&this._dec()}_dec(){let t=this._currentParent;t.length<0||(t.length--,t.length===0&&this._closeParent())}_push(t,e){let n=this._currentParent;switch(n.values++,n.type){case ht.PARENT.ARRAY:case ht.PARENT.BYTE_STRING:case ht.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=t:this._ref.push(t),this._dec();break;case ht.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=t,n.tmpKey=null,this._dec()):(n.tmpKey=t,typeof n.tmpKey!="string"&&(n.type=ht.PARENT.MAP,n.ref=Vt.buildMap(n.ref)));break;case ht.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,t),n.tmpKey=null,this._dec()):n.tmpKey=t;break;case ht.PARENT.TAG:this._ref.push(t),e||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(t,e,n){this._parents[this._depth]={type:e,length:n,ref:t,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:ht.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(t,e){let n=this._knownTags[t];return n?n(e):new Tl(t,e)}createMap(t,e){return t}createObject(t,e){return t}createArray(t,e){return t}createByteString(t,e){return pr.concat(t)}createByteStringFromHeap(t,e){return t===e?pr.alloc(0):pr.from(this._heap.slice(t,e))}createInt(t){return t}createInt32(t,e){return Vt.buildInt32(t,e)}createInt64(t,e,n,i){return Vt.buildInt64(t,e,n,i)}createFloat(t){return t}createFloatSingle(t,e,n,i){return Pa.read([t,e,n,i],0,!1,23,4)}createFloatDouble(t,e,n,i,s,o,c,u){return Pa.read([t,e,n,i,s,o,c,u],0,!1,52,8)}createInt32Neg(t,e){return-1-Vt.buildInt32(t,e)}createInt64Neg(t,e,n,i){let s=Vt.buildInt32(t,e),o=Vt.buildInt32(n,i);return s>ht.MAX_SAFE_HIGH?ht.NEG_ONE.minus(new El(s).times(ht.SHIFT32).plus(o)):-1-(s*ht.SHIFT32+o)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(t,e){return t.join("")}createUtf8StringFromHeap(t,e){return t===e?"":this._buffer.toString("utf8",t,e)}createSimpleUnassigned(t){return new vl(t)}pushInt(t){this._push(this.createInt(t))}pushInt32(t,e){this._push(this.createInt32(t,e))}pushInt64(t,e,n,i){this._push(this.createInt64(t,e,n,i))}pushFloat(t){this._push(this.createFloat(t))}pushFloatSingle(t,e,n,i){this._push(this.createFloatSingle(t,e,n,i))}pushFloatDouble(t,e,n,i,s,o,c,u){this._push(this.createFloatDouble(t,e,n,i,s,o,c,u))}pushInt32Neg(t,e){this._push(this.createInt32Neg(t,e))}pushInt64Neg(t,e,n,i){this._push(this.createInt64Neg(t,e,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([],ht.PARENT.ARRAY,-1)}pushArrayStartFixed(t){this._createArrayStartFixed(t)}pushArrayStartFixed32(t,e){let n=Vt.buildInt32(t,e);this._createArrayStartFixed(n)}pushArrayStartFixed64(t,e,n,i){let s=Vt.buildInt64(t,e,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(t){this._createObjectStartFixed(t)}pushObjectStartFixed32(t,e){let n=Vt.buildInt32(t,e);this._createObjectStartFixed(n)}pushObjectStartFixed64(t,e,n,i){let s=Vt.buildInt64(t,e,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:ht.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(t,e){this._push(this.createByteStringFromHeap(t,e))}pushUtf8StringStart(){this._parents[this._depth]={type:ht.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(t,e){this._push(this.createUtf8StringFromHeap(t,e))}pushSimpleUnassigned(t){this._push(this.createSimpleUnassigned(t))}pushTagStart(t){this._parents[this._depth]={type:ht.PARENT.TAG,length:1,ref:[t]}}pushTagStart4(t,e){this.pushTagStart(Vt.buildInt32(t,e))}pushTagStart8(t,e,n,i){this.pushTagStart(Vt.buildInt64(t,e,n,i))}pushTagUnassigned(t){this._push(this.createTag(t))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(t){if(t===0){this._push(this.createObject({}));return}this._createParent({},ht.PARENT.OBJECT,t)}_createArrayStartFixed(t){if(t===0){this._push(this.createArray([]));return}this._createParent(new Array(t),ht.PARENT.ARRAY,t)}_decode(t){if(t.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(t);let e=this.parser.parse(t.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(e>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(t){return this._decode(t),this._res[0]}decodeAll(t){return this._decode(t),this._res}static decode(t,e){return typeof t=="string"&&(t=pr.from(t,e||"hex")),new r({size:t.length}).decodeFirst(t)}static decodeAll(t,e){return typeof t=="string"&&(t=pr.from(t,e||"hex")),new r({size:t.length}).decodeAll(t)}};Lr.decodeFirst=Lr.decode;ka.exports=Lr});var $a=Bt((ty,Ca)=>{"use strict";var{Buffer:bs}=Vr(),Bl=_s(),Il=Sn(),Es=class r extends Bl{createTag(t,e){return`${t}(${e})`}createInt(t){return super.createInt(t).toString()}createInt32(t,e){return super.createInt32(t,e).toString()}createInt64(t,e,n,i){return super.createInt64(t,e,n,i).toString()}createInt32Neg(t,e){return super.createInt32Neg(t,e).toString()}createInt64Neg(t,e,n,i){return super.createInt64Neg(t,e,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(t){let e=super.createFloat(t);return Il.isNegativeZero(t)?"-0_1":`${e}_1`}createFloatSingle(t,e,n,i){return`${super.createFloatSingle(t,e,n,i)}_2`}createFloatDouble(t,e,n,i,s,o,c,u){return`${super.createFloatDouble(t,e,n,i,s,o,c,u)}_3`}createByteString(t,e){let n=t.join(", ");return e===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(t,e){return`h'${bs.from(super.createByteStringFromHeap(t,e)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(t){return`simple(${t})`}createArray(t,e){let n=super.createArray(t,e);return e===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(t,e){let n=super.createMap(t),i=Array.from(n.keys()).reduce(Ma(n),"");return e===-1?`{_ ${i}}`:`{${i}}`}createObject(t,e){let n=super.createObject(t),i=Object.keys(n).reduce(Ma(n),"");return e===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(t,e){let n=t.join(", ");return e===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(t,e){return`"${bs.from(super.createUtf8StringFromHeap(t,e)).toString("utf8")}"`}static diagnose(t,e){return typeof t=="string"&&(t=bs.from(t,e||"hex")),new r().decodeFirst(t)}};Ca.exports=Es;function Ma(r){return(t,e)=>t?`${t}, ${e}: ${r[e]}`:`${e}: ${r[e]}`}});var ja=Bt((ey,La)=>{"use strict";var{Buffer:pe}=Vr(),{URL:Nl}=xs(),vs=qr().BigNumber,As=Sn(),Nt=Hr(),ie=Nt.MT,In=Nt.NUMBYTES,Va=Nt.SHIFT32,qa=Nt.SYMS,yr=Nt.TAG,Ul=Nt.MT.SIMPLE_FLOAT<<5|Nt.NUMBYTES.TWO,Rl=Nt.MT.SIMPLE_FLOAT<<5|Nt.NUMBYTES.FOUR,Fl=Nt.MT.SIMPLE_FLOAT<<5|Nt.NUMBYTES.EIGHT,Ol=Nt.MT.SIMPLE_FLOAT<<5|Nt.SIMPLE.TRUE,Pl=Nt.MT.SIMPLE_FLOAT<<5|Nt.SIMPLE.FALSE,kl=Nt.MT.SIMPLE_FLOAT<<5|Nt.SIMPLE.UNDEFINED,Ha=Nt.MT.SIMPLE_FLOAT<<5|Nt.SIMPLE.NULL,Ml=new vs("0x20000000000000"),Cl=pe.from("f97e00","hex"),$l=pe.from("f9fc00","hex"),Vl=pe.from("f97c00","hex");function ql(r){return{}.toString.call(r).slice(8,-1)}var Ts=class r{constructor(t){t=t||{},this.streaming=typeof t.stream=="function",this.onData=t.stream,this.semanticTypes=[[Nl,this._pushUrl],[vs,this._pushBigNumber]];let e=t.genTypes||[],n=e.length;for(let i=0;i<n;i++)this.addSemanticType(e[i][0],e[i][1]);this._reset()}addSemanticType(t,e){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===t){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=e,o}return this.semanticTypes.push([t,e]),null}push(t){return t&&(this.result[this.offset]=t,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=t.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(t,e,n){return this.result[this.offset]=t,this.resultMethod[this.offset]=e,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(t){return this.pushWrite(t,1,1)}_pushUInt16BE(t){return this.pushWrite(t,2,2)}_pushUInt32BE(t){return this.pushWrite(t,3,4)}_pushDoubleBE(t){return this.pushWrite(t,4,8)}_pushNaN(){return this.push(Cl)}_pushInfinity(t){let e=t<0?$l:Vl;return this.push(e)}_pushFloat(t){let e=pe.allocUnsafe(2);if(As.writeHalf(e,t)&&As.parseHalf(e)===t)return this._pushUInt8(Ul)&&this.push(e);let n=pe.allocUnsafe(4);return n.writeFloatBE(t,0),n.readFloatBE(0)===t?this._pushUInt8(Rl)&&this.push(n):this._pushUInt8(Fl)&&this._pushDoubleBE(t)}_pushInt(t,e,n){let i=e<<5;return t<24?this._pushUInt8(i|t):t<=255?this._pushUInt8(i|In.ONE)&&this._pushUInt8(t):t<=65535?this._pushUInt8(i|In.TWO)&&this._pushUInt16BE(t):t<=4294967295?this._pushUInt8(i|In.FOUR)&&this._pushUInt32BE(t):t<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|In.EIGHT)&&this._pushUInt32BE(Math.floor(t/Va))&&this._pushUInt32BE(t%Va):e===ie.NEG_INT?this._pushFloat(n):this._pushFloat(t)}_pushIntNum(t){return t<0?this._pushInt(-t-1,ie.NEG_INT,t):this._pushInt(t,ie.POS_INT)}_pushNumber(t){switch(!1){case t===t:return this._pushNaN(t);case isFinite(t):return this._pushInfinity(t);case t%1!==0:return this._pushIntNum(t);default:return this._pushFloat(t)}}_pushString(t){let e=pe.byteLength(t,"utf8");return this._pushInt(e,ie.UTF8_STRING)&&this.pushWrite(t,5,e)}_pushBoolean(t){return this._pushUInt8(t?Ol:Pl)}_pushUndefined(t){return this._pushUInt8(kl)}_pushArray(t,e){let n=e.length;if(!t._pushInt(n,ie.ARRAY))return!1;for(let i=0;i<n;i++)if(!t.pushAny(e[i]))return!1;return!0}_pushTag(t){return this._pushInt(t,ie.TAG)}_pushDate(t,e){return t._pushTag(yr.DATE_EPOCH)&&t.pushAny(Math.round(e/1e3))}_pushBuffer(t,e){return t._pushInt(e.length,ie.BYTE_STRING)&&t.push(e)}_pushNoFilter(t,e){return t._pushBuffer(t,e.slice())}_pushRegexp(t,e){return t._pushTag(yr.REGEXP)&&t.pushAny(e.source)}_pushSet(t,e){if(!t._pushInt(e.size,ie.ARRAY))return!1;for(let n of e)if(!t.pushAny(n))return!1;return!0}_pushUrl(t,e){return t._pushTag(yr.URI)&&t.pushAny(e.format())}_pushBigint(t){let e=yr.POS_BIGINT;t.isNegative()&&(t=t.negated().minus(1),e=yr.NEG_BIGINT);let n=t.toString(16);n.length%2&&(n="0"+n);let i=pe.from(n,"hex");return this._pushTag(e)&&this._pushBuffer(this,i)}_pushBigNumber(t,e){if(e.isNaN())return t._pushNaN();if(!e.isFinite())return t._pushInfinity(e.isNegative()?-1/0:1/0);if(e.isInteger())return t._pushBigint(e);if(!(t._pushTag(yr.DECIMAL_FRAC)&&t._pushInt(2,ie.ARRAY)))return!1;let n=e.decimalPlaces(),i=e.multipliedBy(new vs(10).pow(n));return t._pushIntNum(-n)?i.abs().isLessThan(Ml)?t._pushIntNum(i.toNumber()):t._pushBigint(i):!1}_pushMap(t,e){return t._pushInt(e.size,ie.MAP)?this._pushRawMap(e.size,Array.from(e)):!1}_pushObject(t){if(!t)return this._pushUInt8(Ha);for(var e=this.semanticTypes.length,n=0;n<e;n++)if(t instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(t,this,t);var i=t.encodeCBOR;if(typeof i=="function")return i.call(t,this);var s=Object.keys(t),o=s.length;return this._pushInt(o,ie.MAP)?this._pushRawMap(o,s.map(c=>[c,t[c]])):!1}_pushRawMap(t,e){e=e.map(function(i){return i[0]=r.encode(i[0]),i}).sort(As.keySorter);for(var n=0;n<t;n++)if(!this.push(e[n][0])||!this.pushAny(e[n][1]))return!1;return!0}write(t){return this.pushAny(t)}pushAny(t){var e=ql(t);switch(e){case"Number":return this._pushNumber(t);case"String":return this._pushString(t);case"Boolean":return this._pushBoolean(t);case"Object":return this._pushObject(t);case"Array":return this._pushArray(this,t);case"Uint8Array":return this._pushBuffer(this,pe.isBuffer(t)?t:pe.from(t));case"Null":return this._pushUInt8(Ha);case"Undefined":return this._pushUndefined(t);case"Map":return this._pushMap(this,t);case"Set":return this._pushSet(this,t);case"URL":return this._pushUrl(this,t);case"BigNumber":return this._pushBigNumber(this,t);case"Date":return this._pushDate(this,t);case"RegExp":return this._pushRegexp(this,t);case"Symbol":switch(t){case qa.NULL:return this._pushObject(null);case qa.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+t.toString())}default:throw new Error("Unknown type: "+typeof t+", "+(t?t.toString():""))}}finalize(){if(this.offset===0)return null;for(var t=this.result,e=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=e[o];var c=pe.allocUnsafe(s),u=0,w=0;for(o=0;o<i;o++){switch(w=e[o],n[o]){case 0:t[o].copy(c,u);break;case 1:c.writeUInt8(t[o],u,!0);break;case 2:c.writeUInt16BE(t[o],u,!0);break;case 3:c.writeUInt32BE(t[o],u,!0);break;case 4:c.writeDoubleBE(t[o],u,!0);break;case 5:c.write(t[o],u,w,"utf8");break;default:throw new Error("unkown method")}u+=w}var y=c;return this._reset(),y}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(t){let e=new r;if(!e.pushAny(t))throw new Error("Failed to encode input");return e.finalize()}};La.exports=Ts});var Nn=Bt(Ut=>{"use strict";Ut.Diagnose=$a();Ut.Decoder=_s();Ut.Encoder=ja();Ut.Simple=ds();Ut.Tagged=ys();Ut.decodeAll=Ut.Decoder.decodeAll;Ut.decodeFirst=Ut.Decoder.decodeFirst;Ut.diagnose=Ut.Diagnose.diagnose;Ut.encode=Ut.Encoder.encode;Ut.decode=Ut.Decoder.decode;Ut.leveldb={decode:Ut.Decoder.decodeAll,encode:Ut.Encoder.encode,buffer:!0,name:"cbor"}});function Re(r){return je(Yo.create().update(new Uint8Array(r)).digest())}function Un(r){if(r instanceof Ga.default.Tagged)return Un(r.value);if(typeof r=="string")return Ka(r);if(typeof r=="number")return Re(Ue(r));if(r instanceof ArrayBuffer||ArrayBuffer.isView(r))return Re(r);if(Array.isArray(r)){let t=r.map(Un);return Re(he(...t))}else{if(r&&typeof r=="object"&&r._isPrincipal)return Re(r.toUint8Array());if(typeof r=="object"&&r!==null&&typeof r.toHash=="function")return Un(r.toHash());if(typeof r=="object")return Ss(r);if(typeof r=="bigint")return Re(Ue(r))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${r}`),{value:r})}function wr(r){return Ss(r)}function Ss(r){let n=Object.entries(r).filter(([,o])=>o!==void 0).map(([o,c])=>{let u=Ka(o),w=Un(c);return[u,w]}).sort(([o],[c])=>Mi(o,c)),i=he(...n.map(o=>he(...o)));return Re(i)}var Ga,Ka,jr=K(()=>{lr();Ga=Te(Nn());ki();jt();Ka=r=>{let t=new TextEncoder().encode(r);return Re(t)}});var Hl,Ll,be,gr,Bs=K(()=>{Wt();jr();jt();Hl=function(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(e[n[i]]=r[n[i]]);return e},Ll=new TextEncoder().encode(`
2
+ ic-request`),be=class{getPrincipal(){return this._principal||(this._principal=Et.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(t){let{body:e}=t,n=Hl(t,["body"]),i=await wr(e);return Object.assign(Object.assign({},n),{body:{content:e,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(he(Ll,i))}})}},gr=class{getPrincipal(){return Et.anonymous()}async transformRequest(t){return Object.assign(Object.assign({},t),{body:{content:t.body}})}}});var Us=Bt(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});var jl=9007199254740992;function Ee(r,...t){let e=new Uint8Array(r.byteLength+t.reduce((i,s)=>i+s.byteLength,0));e.set(new Uint8Array(r),0);let n=r.byteLength;for(let i of t)e.set(new Uint8Array(i),n),n+=i.byteLength;return e.buffer}function se(r,t,e){e=e.replace(/[^0-9a-fA-F]/g,"");let n=2**(t-24);e=e.slice(-n*2).padStart(n*2,"0");let i=[(r<<5)+t].concat(e.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function Rn(r,t){if(t<24)return new Uint8Array([(r<<5)+t]).buffer;{let e=t<=255?24:t<=65535?25:t<=4294967295?26:27;return se(r,e,t.toString(16))}}function Da(r){let t=[];for(let e=0;e<r.length;e++){let n=r.charCodeAt(e);n<128?t.push(n):n<2048?t.push(192|n>>6,128|n&63):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|n&63):(e++,n=(n&1023)<<10|r.charCodeAt(e)&1023,t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return Ee(new Uint8Array(Rn(3,r.length)),new Uint8Array(t))}function Gl(r,t){if(r==14277111)return Ee(new Uint8Array([217,217,247]),t);if(r<24)return Ee(new Uint8Array([192+r]),t);{let e=r<=255?24:r<=65535?25:r<=4294967295?26:27,n=2**(e-24),i=r.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+e].concat(i.match(/../g).map(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}yt.tagged=Gl;function Gr(r){return new Uint8Array(r).buffer}yt.raw=Gr;function Is(r){if(isNaN(r))throw new RangeError("Invalid number.");r=Math.min(Math.max(0,r),23);let t=[0+r];return new Uint8Array(t).buffer}yt.uSmall=Is;function Wa(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),255),r=r.toString(16),se(0,24,r)}yt.u8=Wa;function za(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),65535),r=r.toString(16),se(0,25,r)}yt.u16=za;function Ya(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),4294967295),r=r.toString(16),se(0,26,r)}yt.u32=Ya;function Ns(r,t){if(typeof r=="string"&&t==16){if(r.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return se(0,27,r)}if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),jl),r=r.toString(16),se(0,27,r)}yt.u64=Ns;function Xa(r){if(isNaN(r))throw new RangeError("Invalid number.");if(r===0)return Is(0);r=Math.min(Math.max(0,-r),24)-1;let t=[32+r];return new Uint8Array(t).buffer}yt.iSmall=Xa;function Ja(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),255),r=r.toString(16),se(1,24,r)}yt.i8=Ja;function Za(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),65535),r=r.toString(16),se(1,25,r)}yt.i16=Za;function Qa(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),4294967295),r=r.toString(16),se(1,26,r)}yt.i32=Qa;function tc(r,t){if(typeof r=="string"&&t==16){if(r.startsWith("-")?r=r.slice(1):r="0",r.match(/[^0-9a-fA-F]/)||r.length>16)throw new RangeError("Invalid number.");let e=!1,n=r.split("").reduceRight((i,s)=>{if(e)return s+i;let o=parseInt(s,16)-1;return o>=0?(e=!0,o.toString(16)+i):"f"+i},"");return e?se(1,27,n):Ns(0)}if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),9007199254740992),r=r.toString(16),se(1,27,r)}yt.i64=tc;function Kl(r){return r>=0?r<24?Is(r):r<=255?Wa(r):r<=65535?za(r):r<=4294967295?Ya(r):Ns(r):r>=-24?Xa(r):r>=-255?Ja(r):r>=-65535?Za(r):r>=-4294967295?Qa(r):tc(r)}yt.number=Kl;function Dl(r){return Ee(Rn(2,r.byteLength),r)}yt.bytes=Dl;function Wl(r){return Da(r)}yt.string=Wl;function zl(r){return Ee(Rn(4,r.length),...r)}yt.array=zl;function Yl(r,t=!1){r instanceof Map||(r=new Map(Object.entries(r)));let e=Array.from(r.entries());return t&&(e=e.sort(([n],[i])=>n.localeCompare(i))),Ee(Rn(5,r.size),...e.map(([n,i])=>Ee(Da(n),i)))}yt.map=Yl;function Xl(r){let t=new Float32Array([r]);return Ee(new Uint8Array([250]),new Uint8Array(t.buffer))}yt.singleFloat=Xl;function Jl(r){let t=new Float64Array([r]);return Ee(new Uint8Array([251]),new Uint8Array(t.buffer))}yt.doubleFloat=Jl;function Zl(r){return r?ec():rc()}yt.bool=Zl;function ec(){return Gr(new Uint8Array([245]))}yt.true_=ec;function rc(){return Gr(new Uint8Array([244]))}yt.false_=rc;function Ql(){return Gr(new Uint8Array([246]))}yt.null_=Ql;function th(){return Gr(new Uint8Array([247]))}yt.undefined_=th});var nc=Bt(Fe=>{"use strict";var eh=Fe&&Fe.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t};Object.defineProperty(Fe,"__esModule",{value:!0});var oe=eh(Us()),rh=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],Fn=class{constructor(t,e=!1){this._serializer=t,this._stable=e,this.name="jsonDefault",this.priority=-100}match(t){return["undefined","boolean","number","string","object"].indexOf(typeof t)!=-1}encode(t){switch(typeof t){case"undefined":return oe.undefined_();case"boolean":return oe.bool(t);case"number":return Math.floor(t)===t?oe.number(t):oe.doubleFloat(t);case"string":return oe.string(t);case"object":if(t===null)return oe.null_();if(Array.isArray(t))return oe.array(t.map(e=>this._serializer.serializeValue(e)));if(rh.find(e=>t instanceof e))return oe.bytes(t.buffer);if(Object.getOwnPropertyNames(t).indexOf("toJSON")!==-1)return this.encode(t.toJSON());if(t instanceof Map){let e=new Map;for(let[n,i]of t.entries())e.set(n,this._serializer.serializeValue(i));return oe.map(e,this._stable)}else{let e=new Map;for(let[n,i]of Object.entries(t))e.set(n,this._serializer.serializeValue(i));return oe.map(e,this._stable)}default:throw new Error("Invalid value.")}}};Fe.JsonDefaultCborEncoder=Fn;var On=class{constructor(){this.name="cborEncoder",this.priority=-90}match(t){return typeof t=="object"&&typeof t.toCBOR=="function"}encode(t){return t.toCBOR()}};Fe.ToCborEncoder=On;var Pn=class{constructor(){this._encoders=new Set}static withDefaultEncoders(t=!1){let e=new this;return e.addEncoder(new Fn(e,t)),e.addEncoder(new On),e}removeEncoder(t){for(let e of this._encoders.values())e.name==t&&this._encoders.delete(e)}addEncoder(t){this._encoders.add(t)}getEncoderFor(t){let e=null;for(let n of this._encoders)(!e||n.priority>e.priority)&&n.match(t)&&(e=n);if(e===null)throw new Error("Could not find an encoder for value.");return e}serializeValue(t){return this.getEncoderFor(t).encode(t)}serialize(t){return this.serializeValue(t)}};Fe.CborSerializer=Pn;var Rs=class extends Pn{serialize(t){return oe.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(t))]))}};Fe.SelfDescribeCborSerializer=Rs});var Kr=Bt(Ke=>{"use strict";function nh(r){for(var t in r)Ke.hasOwnProperty(t)||(Ke[t]=r[t])}var ih=Ke&&Ke.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t};Object.defineProperty(Ke,"__esModule",{value:!0});nh(nc());var sh=ih(Us());Ke.value=sh});function ic(r){let t=r.byteLength,e=BigInt(0);for(let n=0;n<t;n++)e=e*BigInt(256)+BigInt(r[n]);return e}function kn(r){let t=new Uint8Array(r),e=new Ms({size:t.byteLength,tags:{2:n=>ic(n),3:n=>-ic(n),[ks.Semantic]:n=>n}});try{return e.decodeFirst(t)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${At(t)}`)}}var sc,De,oc,Fs,Os,Ps,Cs,ks,Ms,Dr=K(()=>{sc=Te(Nn()),De=Te(Kr()),oc=Te(Kr());jt();Fs=class{get name(){return"Principal"}get priority(){return 0}match(t){return t&&t._isPrincipal===!0}encode(t){return De.value.bytes(t.toUint8Array())}},Os=class{get name(){return"Buffer"}get priority(){return 1}match(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)}encode(t){return De.value.bytes(new Uint8Array(t))}},Ps=class{get name(){return"BigInt"}get priority(){return 1}match(t){return typeof t=="bigint"}encode(t){return t>BigInt(0)?De.value.tagged(2,De.value.bytes(Lt(t.toString(16)))):De.value.tagged(3,De.value.bytes(Lt((BigInt("-1")*t).toString(16))))}},Cs=oc.SelfDescribeCborSerializer.withDefaultEncoders(!0);Cs.addEncoder(new Fs);Cs.addEncoder(new Os);Cs.addEncoder(new Ps);(function(r){r[r.Uint64LittleEndian=71]="Uint64LittleEndian",r[r.Semantic=55799]="Semantic"})(ks||(ks={}));Ms=class extends sc.default.Decoder{createByteString(t){return he(...t)}createByteStringFromHeap(t,e){return t===e?new ArrayBuffer(0):new Uint8Array(this._heap.slice(t,e))}}});var $s=K(()=>{});var Vs,Wr=K(()=>{$s();(function(r){r.Call="call"})(Vs||(Vs={}))});function zr(r){let t=[];return r.forEach((e,n)=>{t.push([n,e])}),t}var oh,by,Ey,Cn=K(()=>{lr();oh=Te(Kr());Wr();by=BigInt(1e6),Ey=60*1e3});var mr,qs=K(()=>{or();mr=class extends ee{constructor(t,e){super(t),this.response=e,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}}});function Ls(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function js(r){if(!Ls(r))throw new Error("Uint8Array expected")}function $n(r,t){if(typeof t!="boolean")throw new Error(`${r} must be valid boolean, got "${t}".`)}function Vn(r){js(r);let t="";for(let e=0;e<r.length;e++)t+=ch[r[e]];return t}function lc(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}function cc(r){if(r>=Ae._0&&r<=Ae._9)return r-Ae._0;if(r>=Ae._A&&r<=Ae._F)return r-(Ae._A-10);if(r>=Ae._a&&r<=Ae._f)return r-(Ae._a-10)}function hc(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let i=0,s=0;i<e;i++,s+=2){let o=cc(r.charCodeAt(s)),c=cc(r.charCodeAt(s+1));if(o===void 0||c===void 0){let u=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+s)}n[i]=o*16+c}return n}function dc(r){return lc(Vn(r))}function xr(r){return js(r),lc(Vn(Uint8Array.from(r).reverse()))}function Gs(r,t){return hc(r.toString(16).padStart(t*2,"0"))}function Yr(r,t){return Gs(r,t).reverse()}function ye(r,t,e){let n;if(typeof t=="string")try{n=hc(t)}catch(s){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${s}`)}else if(Ls(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let i=n.length;if(typeof e=="number"&&i!==e)throw new Error(`${r} expected ${e} bytes, got ${i}`);return n}function Ks(...r){let t=0;for(let n=0;n<r.length;n++){let i=r[n];js(i),t+=i.length}let e=new Uint8Array(t);for(let n=0,i=0;n<r.length;n++){let s=r[n];e.set(s,i),i+=s.length}return e}function uh(r,t,e){return Hs(r)&&Hs(t)&&Hs(e)&&t<=r&&r<e}function _r(r,t,e,n){if(!uh(t,e,n))throw new Error(`expected valid ${r}: ${e} <= n < ${n}, got ${typeof t} ${t}`)}function pc(r){let t;for(t=0;r>uc;r>>=fc,t+=1);return t}function br(r,t,e={}){let n=(i,s,o)=>{let c=fh[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);let u=r[i];if(!(o&&u===void 0)&&!c(u,r))throw new Error(`Invalid param ${String(i)}=${u} (${typeof u}), expected ${s}`)};for(let[i,s]of Object.entries(t))n(i,s,!1);for(let[i,s]of Object.entries(e))n(i,s,!0);return r}function Ds(r){let t=new WeakMap;return(e,...n)=>{let i=t.get(e);if(i!==void 0)return i;let s=r(e,...n);return t.set(e,s),s}}var uc,fc,ah,ch,Ae,Hs,yc,fh,Xr=K(()=>{uc=BigInt(0),fc=BigInt(1),ah=BigInt(2);ch=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));Ae={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};Hs=r=>typeof r=="bigint"&&uc<=r;yc=r=>(ah<<BigInt(r-1))-fc,fh={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Ls(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)}});function vt(r,t){let e=r%t;return e>=Rt?e:t+e}function yh(r,t,e){if(e<=Rt||t<Rt)throw new Error("Expected power/modulo > 0");if(e===bt)return Rt;let n=bt;for(;t>Rt;)t&bt&&(n=n*r%e),r=r*r%e,t>>=bt;return n}function ae(r,t,e){let n=r;for(;t-- >Rt;)n*=n,n%=e;return n}function mc(r,t){if(r===Rt||t<=Rt)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=vt(r,t),n=t,i=Rt,s=bt,o=bt,c=Rt;for(;e!==Rt;){let w=n/e,y=n%e,m=i-o*w,N=s-c*w;n=e,e=y,i=o,s=c,o=m,c=N}if(n!==bt)throw new Error("invert: does not exist");return vt(i,t)}function wh(r){let t=(r-bt)/We,e,n,i;for(e=r-bt,n=0;e%We===Rt;e/=We,n++);for(i=We;i<r&&yh(i,t,r)!==r-bt;i++);if(n===1){let o=(r+bt)/Ws;return function(u,w){let y=u.pow(w,o);if(!u.eql(u.sqr(y),w))throw new Error("Cannot find square root");return y}}let s=(e+bt)/We;return function(c,u){if(c.pow(u,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let w=n,y=c.pow(c.mul(c.ONE,i),e),m=c.pow(u,s),N=c.pow(u,e);for(;!c.eql(N,c.ONE);){if(c.eql(N,c.ZERO))return c.ZERO;let k=1;for(let j=c.sqr(N);k<w&&!c.eql(j,c.ONE);k++)j=c.sqr(j);let O=c.pow(y,bt<<BigInt(w-k-1));y=c.sqr(O),m=c.mul(m,O),N=c.mul(N,y),w=k}return m}}function gh(r){if(r%Ws===hh){let t=(r+bt)/Ws;return function(n,i){let s=n.pow(i,t);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(r%gc===wc){let t=(r-wc)/gc;return function(n,i){let s=n.mul(i,We),o=n.pow(s,t),c=n.mul(i,o),u=n.mul(n.mul(c,We),o),w=n.mul(c,n.sub(u,n.ONE));if(!n.eql(n.sqr(w),i))throw new Error("Cannot find square root");return w}}return r%ph,wh(r)}function _c(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=mh.reduce((n,i)=>(n[i]="function",n),t);return br(r,e)}function xh(r,t,e){if(e<Rt)throw new Error("Expected power > 0");if(e===Rt)return r.ONE;if(e===bt)return t;let n=r.ONE,i=t;for(;e>Rt;)e&bt&&(n=r.mul(n,i)),i=r.sqr(i),e>>=bt;return n}function _h(r,t){let e=new Array(t.length),n=t.reduce((s,o,c)=>r.is0(o)?s:(e[c]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return t.reduceRight((s,o,c)=>r.is0(o)?s:(e[c]=r.mul(s,e[c]),r.mul(s,o)),i),e}function zs(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function qn(r,t,e=!1,n={}){if(r<=Rt)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:i,nByteLength:s}=zs(r,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=gh(r),c=Object.freeze({ORDER:r,BITS:i,BYTES:s,MASK:yc(i),ZERO:Rt,ONE:bt,create:u=>vt(u,r),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return Rt<=u&&u<r},is0:u=>u===Rt,isOdd:u=>(u&bt)===bt,neg:u=>vt(-u,r),eql:(u,w)=>u===w,sqr:u=>vt(u*u,r),add:(u,w)=>vt(u+w,r),sub:(u,w)=>vt(u-w,r),mul:(u,w)=>vt(u*w,r),pow:(u,w)=>xh(c,u,w),div:(u,w)=>vt(u*mc(w,r),r),sqrN:u=>u*u,addN:(u,w)=>u+w,subN:(u,w)=>u-w,mulN:(u,w)=>u*w,inv:u=>mc(u,r),sqrt:n.sqrt||(u=>o(c,u)),invertBatch:u=>_h(c,u),cmov:(u,w,y)=>y?w:u,toBytes:u=>e?Yr(u,s):Gs(u,s),fromBytes:u=>{if(u.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${u.length}`);return e?xr(u):dc(u)}});return Object.freeze(c)}var Rt,bt,We,hh,Ws,wc,gc,dh,ph,xc,mh,Hn=K(()=>{Xr();Rt=BigInt(0),bt=BigInt(1),We=BigInt(2),hh=BigInt(3),Ws=BigInt(4),wc=BigInt(5),gc=BigInt(8),dh=BigInt(9),ph=BigInt(16);xc=(r,t)=>(vt(r,t)&bt)===bt,mh=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"]});function Ec(r,t){let e=(s,o)=>{let c=o.negate();return s?c:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error(`Wrong window size=${s}, should be [1..${t}]`)},i=s=>{n(s);let o=Math.ceil(t/s)+1,c=2**(s-1);return{windows:o,windowSize:c}};return{constTimeNegate:e,unsafeLadder(s,o){let c=r.ZERO,u=s;for(;o>bh;)o&Ys&&(c=c.add(u)),u=u.double(),o>>=Ys;return c},precomputeWindow(s,o){let{windows:c,windowSize:u}=i(o),w=[],y=s,m=y;for(let N=0;N<c;N++){m=y,w.push(m);for(let k=1;k<u;k++)m=m.add(y),w.push(m);y=m.double()}return w},wNAF(s,o,c){let{windows:u,windowSize:w}=i(s),y=r.ZERO,m=r.BASE,N=BigInt(2**s-1),k=2**s,O=BigInt(s);for(let j=0;j<u;j++){let ft=j*w,W=Number(c&N);c>>=O,W>w&&(W-=k,c+=Ys);let Mt=ft,C=ft+Math.abs(W)-1,lt=j%2!==0,V=W<0;W===0?m=m.add(e(lt,o[Mt])):y=y.add(e(V,o[C]))}return{p:y,f:m}},wNAFCached(s,o,c){let u=bc.get(s)||1,w=Xs.get(s);return w||(w=this.precomputeWindow(s,u),u!==1&&Xs.set(s,c(w))),this.wNAF(u,w,o)},setWindowSize(s,o){n(o),bc.set(s,o),Xs.delete(s)}}}function Ac(r,t,e,n){if(!Array.isArray(e)||!Array.isArray(n)||n.length!==e.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((y,m)=>{if(!t.isValid(y))throw new Error(`wrong scalar at index ${m}`)}),e.forEach((y,m)=>{if(!(y instanceof r))throw new Error(`wrong point at index ${m}`)});let i=pc(BigInt(e.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<<s)-1,c=new Array(o+1).fill(r.ZERO),u=Math.floor((t.BITS-1)/s)*s,w=r.ZERO;for(let y=u;y>=0;y-=s){c.fill(r.ZERO);for(let N=0;N<n.length;N++){let k=n[N],O=Number(k>>BigInt(y)&BigInt(o));c[O]=c[O].add(e[N])}let m=r.ZERO;for(let N=c.length-1,k=r.ZERO;N>0;N--)k=k.add(c[N]),m=m.add(k);if(w=w.add(m),y!==0)for(let N=0;N<s;N++)w=w.double()}return w}function vc(r){return _c(r.Fp),br(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...zs(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var bh,Ys,Xs,bc,Tc=K(()=>{Hn();Xr();bh=BigInt(0),Ys=BigInt(1),Xs=new WeakMap,bc=new WeakMap});var Js=K(()=>{jt()});var Ln=K(()=>{lr()});var Sc,Hy,jn,Bc,Er=K(()=>{Dr();or();jr();jt();Wt();Js();Ln();Jr();(function(r){r[r.Empty=0]="Empty",r[r.Fork=1]="Fork",r[r.Labeled=2]="Labeled",r[r.Leaf=3]="Leaf",r[r.Pruned=4]="Pruned"})(Sc||(Sc={}));Hy=Lt("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100");(function(r){r.Unknown="unknown",r.Absent="absent",r.Found="found"})(jn||(jn={}));(function(r){r.Less="less",r.Greater="greater"})(Bc||(Bc={}))});var Gn=K(()=>{Wt();or();Er();jt();Dr();Ln()});function Fc(r,t=!1){return t?{h:Number(r&Kn),l:Number(r>>Zs&Kn)}:{h:Number(r>>Zs&Kn)|0,l:Number(r&Kn)|0}}function vh(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){let{h:s,l:o}=Fc(r[i],t);[e[i],n[i]]=[s,o]}return[e,n]}function $h(r,t,e,n){let i=(t>>>0)+(n>>>0);return{h:r+e+(i/2**32|0)|0,l:i|0}}var Kn,Zs,Th,Sh,Bh,Ih,Nh,Uh,Rh,Fh,Oh,Ph,kh,Mh,Ch,Vh,qh,Hh,Lh,jh,Gh,Kh,D,Oc=K(()=>{Kn=BigInt(4294967295),Zs=BigInt(32);Th=(r,t)=>BigInt(r>>>0)<<Zs|BigInt(t>>>0),Sh=(r,t,e)=>r>>>e,Bh=(r,t,e)=>r<<32-e|t>>>e,Ih=(r,t,e)=>r>>>e|t<<32-e,Nh=(r,t,e)=>r<<32-e|t>>>e,Uh=(r,t,e)=>r<<64-e|t>>>e-32,Rh=(r,t,e)=>r>>>e-32|t<<64-e,Fh=(r,t)=>t,Oh=(r,t)=>r,Ph=(r,t,e)=>r<<e|t>>>32-e,kh=(r,t,e)=>t<<e|r>>>32-e,Mh=(r,t,e)=>t<<e-32|r>>>64-e,Ch=(r,t,e)=>r<<e-32|t>>>64-e;Vh=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),qh=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Hh=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Lh=(r,t,e,n,i)=>t+e+n+i+(r/2**32|0)|0,jh=(r,t,e,n,i)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(i>>>0),Gh=(r,t,e,n,i,s)=>t+e+n+i+s+(r/2**32|0)|0,Kh={fromBig:Fc,split:vh,toBig:Th,shrSH:Sh,shrSL:Bh,rotrSH:Ih,rotrSL:Nh,rotrBH:Uh,rotrBL:Rh,rotr32H:Fh,rotr32L:Oh,rotlSH:Ph,rotlSL:kh,rotlBH:Mh,rotlBL:Ch,add:$h,add3L:Vh,add3H:qh,add4L:Hh,add4H:Lh,add5H:Gh,add5L:jh},D=Kh});var Dh,Wh,Oe,Pe,Qs,Pc,kc=K(()=>{Oi();Oc();Or();[Dh,Wh]=D.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(r=>BigInt(r))),Oe=new Uint32Array(80),Pe=new Uint32Array(80),Qs=class extends sr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:i,Ch:s,Cl:o,Dh:c,Dl:u,Eh:w,El:y,Fh:m,Fl:N,Gh:k,Gl:O,Hh:j,Hl:ft}=this;return[t,e,n,i,s,o,c,u,w,y,m,N,k,O,j,ft]}set(t,e,n,i,s,o,c,u,w,y,m,N,k,O,j,ft){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=c|0,this.Dl=u|0,this.Eh=w|0,this.El=y|0,this.Fh=m|0,this.Fl=N|0,this.Gh=k|0,this.Gl=O|0,this.Hh=j|0,this.Hl=ft|0}process(t,e){for(let C=0;C<16;C++,e+=4)Oe[C]=t.getUint32(e),Pe[C]=t.getUint32(e+=4);for(let C=16;C<80;C++){let lt=Oe[C-15]|0,V=Pe[C-15]|0,q=D.rotrSH(lt,V,1)^D.rotrSH(lt,V,8)^D.shrSH(lt,V,7),nt=D.rotrSL(lt,V,1)^D.rotrSL(lt,V,8)^D.shrSL(lt,V,7),Z=Oe[C-2]|0,U=Pe[C-2]|0,ot=D.rotrSH(Z,U,19)^D.rotrBH(Z,U,61)^D.shrSH(Z,U,6),et=D.rotrSL(Z,U,19)^D.rotrBL(Z,U,61)^D.shrSL(Z,U,6),st=D.add4L(nt,et,Pe[C-7],Pe[C-16]),wt=D.add4H(st,q,ot,Oe[C-7],Oe[C-16]);Oe[C]=wt|0,Pe[C]=st|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:c,Cl:u,Dh:w,Dl:y,Eh:m,El:N,Fh:k,Fl:O,Gh:j,Gl:ft,Hh:W,Hl:Mt}=this;for(let C=0;C<80;C++){let lt=D.rotrSH(m,N,14)^D.rotrSH(m,N,18)^D.rotrBH(m,N,41),V=D.rotrSL(m,N,14)^D.rotrSL(m,N,18)^D.rotrBL(m,N,41),q=m&k^~m&j,nt=N&O^~N&ft,Z=D.add5L(Mt,V,nt,Wh[C],Pe[C]),U=D.add5H(Z,W,lt,q,Dh[C],Oe[C]),ot=Z|0,et=D.rotrSH(n,i,28)^D.rotrBH(n,i,34)^D.rotrBH(n,i,39),st=D.rotrSL(n,i,28)^D.rotrBL(n,i,34)^D.rotrBL(n,i,39),wt=n&s^n&c^s&c,It=i&o^i&u^o&u;W=j|0,Mt=ft|0,j=k|0,ft=O|0,k=m|0,O=N|0,{h:m,l:N}=D.add(w|0,y|0,U|0,ot|0),w=c|0,y=u|0,c=s|0,u=o|0,s=n|0,o=i|0;let Ct=D.add3L(ot,st,It);n=D.add3H(Ct,U,et,wt),i=Ct|0}({h:n,l:i}=D.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=D.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:c,l:u}=D.add(this.Ch|0,this.Cl|0,c|0,u|0),{h:w,l:y}=D.add(this.Dh|0,this.Dl|0,w|0,y|0),{h:m,l:N}=D.add(this.Eh|0,this.El|0,m|0,N|0),{h:k,l:O}=D.add(this.Fh|0,this.Fl|0,k|0,O|0),{h:j,l:ft}=D.add(this.Gh|0,this.Gl|0,j|0,ft|0),{h:W,l:Mt}=D.add(this.Hh|0,this.Hl|0,W|0,Mt|0),this.set(n,i,s,o,c,u,w,y,m,N,k,O,j,ft,W,Mt)}roundClean(){Oe.fill(0),Pe.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)}},Pc=Fr(()=>new Qs)});function Xh(r){let t=vc(r);return br(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Mc(r){let t=Xh(r),{Fp:e,n,prehash:i,hash:s,randomBytes:o,nByteLength:c,h:u}=t,w=Dn<<BigInt(c*8)-Kt,y=e.create,m=qn(t.n,t.nBitLength),N=t.uvRatio||((L,R)=>{try{return{isValid:!0,value:e.sqrt(L*e.inv(R))}}catch{return{isValid:!1,value:ce}}}),k=t.adjustScalarBytes||(L=>L),O=t.domain||((L,R,P)=>{if($n("phflag",P),R.length||P)throw new Error("Contexts/pre-hash are not supported");return L});function j(L,R){_r("coordinate "+L,R,ce,w)}function ft(L){if(!(L instanceof C))throw new Error("ExtendedPoint expected")}let W=Ds((L,R)=>{let{ex:P,ey:G,ez:Y}=L,z=L.is0();R==null&&(R=z?zh:e.inv(Y));let it=y(P*R),B=y(G*R),h=y(Y*R);if(z)return{x:ce,y:Kt};if(h!==Kt)throw new Error("invZ was invalid");return{x:it,y:B}}),Mt=Ds(L=>{let{a:R,d:P}=t;if(L.is0())throw new Error("bad point: ZERO");let{ex:G,ey:Y,ez:z,et:it}=L,B=y(G*G),h=y(Y*Y),ct=y(z*z),gt=y(ct*ct),ut=y(B*R),M=y(ct*y(ut+h)),a=y(gt+y(P*y(B*h)));if(M!==a)throw new Error("bad point: equation left != right (1)");let f=y(G*Y),l=y(z*it);if(f!==l)throw new Error("bad point: equation left != right (2)");return!0});class C{constructor(R,P,G,Y){this.ex=R,this.ey=P,this.ez=G,this.et=Y,j("x",R),j("y",P),j("z",G),j("t",Y),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(R){if(R instanceof C)throw new Error("extended point not allowed");let{x:P,y:G}=R||{};return j("x",P),j("y",G),new C(P,G,Kt,y(P*G))}static normalizeZ(R){let P=e.invertBatch(R.map(G=>G.ez));return R.map((G,Y)=>G.toAffine(P[Y])).map(C.fromAffine)}static msm(R,P){return Ac(C,m,R,P)}_setWindowSize(R){q.setWindowSize(this,R)}assertValidity(){Mt(this)}equals(R){ft(R);let{ex:P,ey:G,ez:Y}=this,{ex:z,ey:it,ez:B}=R,h=y(P*B),ct=y(z*Y),gt=y(G*B),ut=y(it*Y);return h===ct&&gt===ut}is0(){return this.equals(C.ZERO)}negate(){return new C(y(-this.ex),this.ey,this.ez,y(-this.et))}double(){let{a:R}=t,{ex:P,ey:G,ez:Y}=this,z=y(P*P),it=y(G*G),B=y(Dn*y(Y*Y)),h=y(R*z),ct=P+G,gt=y(y(ct*ct)-z-it),ut=h+it,M=ut-B,a=h-it,f=y(gt*M),l=y(ut*a),b=y(gt*a),g=y(M*ut);return new C(f,l,g,b)}add(R){ft(R);let{a:P,d:G}=t,{ex:Y,ey:z,ez:it,et:B}=this,{ex:h,ey:ct,ez:gt,et:ut}=R;if(P===BigInt(-1)){let I=y((z-Y)*(ct+h)),F=y((z+Y)*(ct-h)),$=y(F-I);if($===ce)return this.double();let J=y(it*Dn*ut),dt=y(B*Dn*gt),mt=dt+J,X=F+I,H=dt-J,Tt=y(mt*$),ve=y(X*H),$e=y(mt*H),Ve=y($*X);return new C(Tt,ve,Ve,$e)}let M=y(Y*h),a=y(z*ct),f=y(B*G*ut),l=y(it*gt),b=y((Y+z)*(h+ct)-M-a),g=l-f,_=l+f,v=y(a-P*M),d=y(b*g),x=y(_*v),A=y(b*v),E=y(g*_);return new C(d,x,E,A)}subtract(R){return this.add(R.negate())}wNAF(R){return q.wNAFCached(this,R,C.normalizeZ)}multiply(R){let P=R;_r("scalar",P,Kt,n);let{p:G,f:Y}=this.wNAF(P);return C.normalizeZ([G,Y])[0]}multiplyUnsafe(R){let P=R;return _r("scalar",P,ce,n),P===ce?V:this.equals(V)||P===Kt?this:this.equals(lt)?this.wNAF(P).p:q.unsafeLadder(this,P)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return q.unsafeLadder(this,n).is0()}toAffine(R){return W(this,R)}clearCofactor(){let{h:R}=t;return R===Kt?this:this.multiplyUnsafe(R)}static fromHex(R,P=!1){let{d:G,a:Y}=t,z=e.BYTES;R=ye("pointHex",R,z),$n("zip215",P);let it=R.slice(),B=R[z-1];it[z-1]=B&-129;let h=xr(it),ct=P?w:e.ORDER;_r("pointHex.y",h,ce,ct);let gt=y(h*h),ut=y(gt-Kt),M=y(G*gt-Y),{isValid:a,value:f}=N(ut,M);if(!a)throw new Error("Point.fromHex: invalid y coordinate");let l=(f&Kt)===Kt,b=(B&128)!==0;if(!P&&f===ce&&b)throw new Error("Point.fromHex: x=0 and x_0=1");return b!==l&&(f=y(-f)),C.fromAffine({x:f,y:h})}static fromPrivateKey(R){return U(R).point}toRawBytes(){let{x:R,y:P}=this.toAffine(),G=Yr(P,e.BYTES);return G[G.length-1]|=R&Kt?128:0,G}toHex(){return Vn(this.toRawBytes())}}C.BASE=new C(t.Gx,t.Gy,Kt,y(t.Gx*t.Gy)),C.ZERO=new C(ce,Kt,Kt,ce);let{BASE:lt,ZERO:V}=C,q=Ec(C,c*8);function nt(L){return vt(L,n)}function Z(L){return nt(xr(L))}function U(L){let R=c;L=ye("private key",L,R);let P=ye("hashed private key",s(L),2*R),G=k(P.slice(0,R)),Y=P.slice(R,2*R),z=Z(G),it=lt.multiply(z),B=it.toRawBytes();return{head:G,prefix:Y,scalar:z,point:it,pointBytes:B}}function ot(L){return U(L).pointBytes}function et(L=new Uint8Array,...R){let P=Ks(...R);return Z(s(O(P,ye("context",L),!!i)))}function st(L,R,P={}){L=ye("message",L),i&&(L=i(L));let{prefix:G,scalar:Y,pointBytes:z}=U(R),it=et(P.context,G,L),B=lt.multiply(it).toRawBytes(),h=et(P.context,B,z,L),ct=nt(it+h*Y);_r("signature.s",ct,ce,n);let gt=Ks(B,Yr(ct,e.BYTES));return ye("result",gt,c*2)}let wt=Yh;function It(L,R,P,G=wt){let{context:Y,zip215:z}=G,it=e.BYTES;L=ye("signature",L,2*it),R=ye("message",R),z!==void 0&&$n("zip215",z),i&&(R=i(R));let B=xr(L.slice(it,2*it)),h,ct,gt;try{h=C.fromHex(P,z),ct=C.fromHex(L.slice(0,it),z),gt=lt.multiplyUnsafe(B)}catch{return!1}if(!z&&h.isSmallOrder())return!1;let ut=et(Y,ct.toRawBytes(),h.toRawBytes(),R);return ct.add(h.multiplyUnsafe(ut)).subtract(gt).clearCofactor().equals(C.ZERO)}return lt._setWindowSize(8),{CURVE:t,getPublicKey:ot,sign:st,verify:It,ExtendedPoint:C,utils:{getExtendedPublicKey:U,randomPrivateKey:()=>o(e.BYTES),precompute(L=8,R=C.BASE){return R._setWindowSize(L),R.multiply(BigInt(3)),R}}}}var ce,Kt,Dn,zh,Yh,Cc=K(()=>{Tc();Hn();Xr();Xr();ce=BigInt(0),Kt=BigInt(1),Dn=BigInt(2),zh=BigInt(8),Yh={zip215:!0}});function t0(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),i=BigInt(80),s=to,c=r*r%s*r%s,u=ae(c,Vc,s)*c%s,w=ae(u,Jh,s)*r%s,y=ae(w,Zh,s)*w%s,m=ae(y,t,s)*y%s,N=ae(m,e,s)*m%s,k=ae(N,n,s)*N%s,O=ae(k,i,s)*k%s,j=ae(O,i,s)*k%s,ft=ae(j,t,s)*y%s;return{pow_p_5_8:ae(ft,Vc,s)*r%s,b2:c}}function e0(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function r0(r,t){let e=to,n=vt(t*t*t,e),i=vt(n*n*t,e),s=t0(r*i).pow_p_5_8,o=vt(r*n*s,e),c=vt(t*o*o,e),u=o,w=vt(o*$c,e),y=c===r,m=c===vt(-r,e),N=c===vt(-r*$c,e);return y&&(o=u),(m||N)&&(o=w),xc(o,e)&&(o=vt(-o,e)),{isValid:y||m,value:o}}var to,$c,dw,Jh,Vc,pw,Zh,Qh,n0,i0,Ar,qc=K(()=>{kc();Or();Cc();Hn();to=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),$c=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),dw=BigInt(0),Jh=BigInt(1),Vc=BigInt(2),pw=BigInt(3),Zh=BigInt(5),Qh=BigInt(8);n0=qn(to,void 0,!0),i0={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:n0,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Qh,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Pc,randomBytes:Do,adjustScalarBytes:e0,uvRatio:r0},Ar=Mc(i0)});var s0,o0,a0,c0,Hc=K(()=>{s0=new WeakMap,o0=new WeakMap,a0=Symbol.iterator,c0=Symbol.toStringTag});function vr(r,t){let e=2+Lc(r.byteLength+1),n=t.byteLength+e+r.byteLength,i=0,s=new Uint8Array(1+Lc(n)+n);return s[i++]=48,i+=jc(s,i,n),s.set(t,i),i+=t.byteLength,s[i++]=3,i+=jc(s,i,r.byteLength+1),s[i++]=0,s.set(new Uint8Array(r),i),s}var Lc,jc,eo,u0,Gc,ze,mw,Zr,ro=K(()=>{jt();Lc=r=>{if(r<=127)return 1;if(r<=255)return 2;if(r<=65535)return 3;if(r<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},jc=(r,t,e)=>{if(e<=127)return r[t]=e,1;if(e<=255)return r[t]=129,r[t+1]=e,2;if(e<=65535)return r[t]=130,r[t+1]=e>>8,r[t+2]=e,3;if(e<=16777215)return r[t]=131,r[t+1]=e>>16,r[t+2]=e>>8,r[t+3]=e,4;throw new Error("Length too long (> 4 bytes)")},eo=(r,t)=>{if(r[t]<128)return 1;if(r[t]===128)throw new Error("Invalid length 0");if(r[t]===129)return 2;if(r[t]===130)return 3;if(r[t]===131)return 4;throw new Error("Length too long (> 4 bytes)")},u0=(r,t)=>{let e=eo(r,t);if(e===1)return r[t];if(e===2)return r[t+1];if(e===3)return(r[t+1]<<8)+r[t+2];if(e===4)return(r[t+1]<<16)+(r[t+2]<<8)+r[t+3];throw new Error("Length too long (> 4 bytes)")},Gc=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),ze=Uint8Array.from([48,5,6,3,43,101,112]),mw=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);Zr=(r,t)=>{let e=0,n=(c,u)=>{if(i[e++]!==c)throw new Error("Expected: "+u)},i=new Uint8Array(r);if(n(48,"sequence"),e+=eo(i,e),!Pr(i.slice(e,e+t.byteLength),t))throw new Error("Not the expected OID.");e+=t.byteLength,n(3,"bit string");let s=u0(i,e)-1;e+=eo(i,e),n(0,"0 padding");let o=i.slice(e);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o}});var Kc,Dc,Wn,zn,Yn,no=K(()=>{ro();Kc=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},Dc=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Yn=class r{constructor(t){if(Wn.set(this,void 0),zn.set(this,void 0),t.byteLength!==r.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Kc(this,Wn,t,"f"),Kc(this,zn,r.derEncode(t),"f")}static from(t){return this.fromDer(t.toDer())}static fromRaw(t){return new r(t)}static fromDer(t){return new r(this.derDecode(t))}static derEncode(t){return vr(t,ze).buffer}static derDecode(t){let e=Zr(t,ze);if(e.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return e}get rawKey(){return Dc(this,Wn,"f")}get derKey(){return Dc(this,zn,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Wn=new WeakMap,zn=new WeakMap;Yn.RAW_KEY_LENGTH=32});var Wc=K(()=>{});var we,$t,ge,Xn,Jn,Zn,Qn,ti,ei,ri,Tr,ni,zc=K(()=>{we=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},$t=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},ni=class r{constructor(t=r.default){ge.set(this,void 0),Xn.set(this,void 0),Jn.set(this,void 0),Zn.set(this,void 0),Qn.set(this,void 0),ti.set(this,void 0),ei.set(this,void 0),ri.set(this,void 0),Tr.set(this,0);let{initialInterval:e=500,randomizationFactor:n=.5,multiplier:i=1.5,maxInterval:s=6e4,maxElapsedTime:o=9e5,maxIterations:c=10,date:u=Date}=t;we(this,ge,e,"f"),we(this,Xn,n,"f"),we(this,Jn,i,"f"),we(this,Zn,s,"f"),we(this,ri,u,"f"),we(this,Qn,u.now(),"f"),we(this,ti,o,"f"),we(this,ei,c,"f")}get ellapsedTimeInMsec(){return $t(this,ri,"f").now()-$t(this,Qn,"f")}get currentInterval(){return $t(this,ge,"f")}get count(){return $t(this,Tr,"f")}get randomValueFromInterval(){let t=$t(this,Xn,"f")*$t(this,ge,"f"),e=$t(this,ge,"f")-t,n=$t(this,ge,"f")+t;return Math.random()*(n-e)+e}incrementCurrentInterval(){var t;return we(this,ge,Math.min($t(this,ge,"f")*$t(this,Jn,"f"),$t(this,Zn,"f")),"f"),we(this,Tr,(t=$t(this,Tr,"f"),t++,t),"f"),$t(this,ge,"f")}next(){return this.ellapsedTimeInMsec>=$t(this,ti,"f")||$t(this,Tr,"f")>=$t(this,ei,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};ge=new WeakMap,Xn=new WeakMap,Jn=new WeakMap,Zn=new WeakMap,Qn=new WeakMap,ti=new WeakMap,ei=new WeakMap,ri=new WeakMap,Tr=new WeakMap;ni.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date}});var io=K(()=>{});var Dt,Qr,d0,Yc,Xc,p0,y0,w0,g0,ke,m0,x0,_0,b0,E0,A0,Jc,v0,T0,S0,so,Dw,oo=K(()=>{Wt();or();Bs();Dr();jr();jt();Cn();Wr();qs();Gn();Er();Hc();no();Ln();Wc();zc();io();Cn();Wr();Dt=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)};(function(r){r.Received="received",r.Processing="processing",r.Replied="replied",r.Rejected="rejected",r.Unknown="unknown",r.Done="done"})(so||(so={}));Dw=60*1e3;d0=new WeakMap,Yc=new WeakMap,Xc=new WeakMap,p0=new WeakMap,y0=new WeakMap,w0=new WeakMap,g0=new WeakMap,ke=new WeakMap,m0=new WeakMap,x0=new WeakMap,_0=new WeakMap,b0=new WeakMap,E0=new WeakMap,A0=new WeakMap,Jc=new WeakMap,S0=new WeakMap,Qr=new WeakSet,v0=async function r(t){var e,n;let{ecid:i,transformedRequest:s,body:o,requestId:c,backoff:u,tries:w}=t,y=w===0?0:u.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:w,backoff:u,delay:y}),y===null)throw new ee(`Timestamp failed to pass the watermark after retrying the configured ${Dt(this,ke,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);y>0&&await new Promise(O=>setTimeout(O,y));let m;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let O=await Dt(this,Yc,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},Dt(this,Xc,"f")),s.request),{body:o}));if(O.status===200){let j=kn(await O.arrayBuffer());m=Object.assign(Object.assign({},j),{httpDetails:{ok:O.ok,status:O.status,statusText:O.statusText,headers:zr(O.headers)},requestId:c})}else throw new mr(`Gateway returned an error:
3
3
  Code: ${O.status} (${O.statusText})
4
4
  Body: ${await O.text()}
5
- `,{ok:O.ok,status:O.status,statusText:O.statusText,headers:On(O.headers)})}catch(O){if(w<Dt(this,ke,"f"))return this.log.warn(`Caught exception while attempting to make query:
5
+ `,{ok:O.ok,status:O.status,statusText:O.statusText,headers:zr(O.headers)})}catch(O){if(w<Dt(this,ke,"f"))return this.log.warn(`Caught exception while attempting to make query:
6
6
  ${O}
7
- Retrying query.`),await Dt(this,zr,"m",r).call(this,Object.assign(Object.assign({},t),{tries:w+1}));throw O}let N=(n=(e=m.signatures)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.timestamp;if(!Dt(this,Sc,"f"))return m;if(!N)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let M=Number(BigInt(N)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:M}),Number(this.waterMark)>M){let O=new ee("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",O,{timestamp:N,waterMark:this.waterMark}),w<Dt(this,ke,"f"))return await Dt(this,zr,"m",r).call(this,Object.assign(Object.assign({},t),{tries:w+1}));throw new ee(`Timestamp failed to pass the watermark after retrying the configured ${Dt(this,ke,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return m},e0=async function r(t){let{request:e,backoff:n,tries:i}=t,s=i===0?0:n.next();if(s===null)throw new ee(`Timestamp failed to pass the watermark after retrying the configured ${Dt(this,ke,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(w=>setTimeout(w,s));let o;try{o=await e()}catch(w){if(Dt(this,ke,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
7
+ Retrying query.`),await Dt(this,Qr,"m",r).call(this,Object.assign(Object.assign({},t),{tries:w+1}));throw O}let N=(n=(e=m.signatures)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.timestamp;if(!Dt(this,Jc,"f"))return m;if(!N)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let k=Number(BigInt(N)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:k}),Number(this.waterMark)>k){let O=new ee("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",O,{timestamp:N,waterMark:this.waterMark}),w<Dt(this,ke,"f"))return await Dt(this,Qr,"m",r).call(this,Object.assign(Object.assign({},t),{tries:w+1}));throw new ee(`Timestamp failed to pass the watermark after retrying the configured ${Dt(this,ke,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return m},T0=async function r(t){let{request:e,backoff:n,tries:i}=t,s=i===0?0:n.next();if(s===null)throw new ee(`Timestamp failed to pass the watermark after retrying the configured ${Dt(this,ke,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(w=>setTimeout(w,s));let o;try{o=await e()}catch(w){if(Dt(this,ke,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
8
8
  ${w}
9
- Retrying request.`),await Dt(this,zr,"m",r).call(this,{request:e,backoff:n,tries:i+1});throw w}if(o.ok)return o;let c=await o.clone().text(),u=`Server returned an error:
9
+ Retrying request.`),await Dt(this,Qr,"m",r).call(this,{request:e,backoff:n,tries:i+1});throw w}if(o.ok)return o;let c=await o.clone().text(),u=`Server returned an error:
10
10
  Code: ${o.status} (${o.statusText})
11
11
  Body: ${c}
12
- `;if(i<Dt(this,ke,"f"))return await Dt(this,zr,"m",r).call(this,{request:e,backoff:n,tries:i+1});throw new Gr(u,{ok:o.ok,status:o.status,statusText:o.statusText,headers:On(o.headers)})};te();var Bc;(function(r){r.Error="err",r.GetPrincipal="gp",r.GetPrincipalResponse="gpr",r.Query="q",r.QueryResponse="qr",r.Call="c",r.CallResponse="cr",r.ReadState="rs",r.ReadStateResponse="rsr",r.Status="s",r.StatusResponse="sr"})(Bc||(Bc={}));ir();ur();jr();Xt();var Qn={};vu(Qn,{backoff:()=>Fc,chain:()=>Oc,conditionalDelay:()=>Uc,defaultStrategy:()=>Ic,maxAttempts:()=>i0,once:()=>Nc,throttle:()=>s0,timeout:()=>Rc});Xt();var n0=5*60*1e3;function Ic(){return Oc(Uc(Nc(),1e3),Fc(1e3,1.2),Rc(n0))}function Nc(){let r=!0;return async()=>r?(r=!1,!0):!1}function Uc(r,t){return async(e,n,i)=>{if(await r(e,n,i))return new Promise(s=>setTimeout(s,t))}}function i0(r){let t=r;return async(e,n,i)=>{if(--t<=0)throw new Error(`Failed to retrieve a reply for request after ${r} attempts:
13
- Request ID: ${Nt(n)}
12
+ `;if(o.status===404&&o.url.includes("api/v3"))throw new mr("v3 api not supported. Fall back to v2",{ok:o.ok,status:o.status,statusText:o.statusText,headers:zr(o.headers)});if(i<Dt(this,ke,"f"))return await Dt(this,Qr,"m",r).call(this,{request:e,backoff:n,tries:i+1});throw new mr(u,{ok:o.ok,status:o.status,statusText:o.statusText,headers:zr(o.headers)})}});var Zc,Qc=K(()=>{Wt();(function(r){r.Error="err",r.GetPrincipal="gp",r.GetPrincipalResponse="gpr",r.Query="q",r.QueryResponse="qr",r.Call="c",r.CallResponse="cr",r.ReadState="rs",r.ReadStateResponse="rsr",r.Status="s",r.StatusResponse="sr"})(Zc||(Zc={}))});var Jr=K(()=>{Ii();oo();qs();Qc()});var R0=Te(Co());Jr();or();lr();Jr();Er();jt();var ii={};Yu(ii,{backoff:()=>nu,chain:()=>iu,conditionalDelay:()=>eu,defaultStrategy:()=>ao,maxAttempts:()=>I0,once:()=>tu,throttle:()=>N0,timeout:()=>ru});jt();var B0=5*60*1e3;function ao(){return iu(eu(tu(),1e3),nu(1e3,1.2),ru(B0))}function tu(){let r=!0;return async()=>r?(r=!1,!0):!1}function eu(r,t){return async(e,n,i)=>{if(await r(e,n,i))return new Promise(s=>setTimeout(s,t))}}function I0(r){let t=r;return async(e,n,i)=>{if(--t<=0)throw new Error(`Failed to retrieve a reply for request after ${r} attempts:
13
+ Request ID: ${At(n)}
14
14
  Request status: ${i}
15
- `)}}function s0(r){return()=>new Promise(t=>setTimeout(t,r))}function Rc(r){let t=Date.now()+r;return async(e,n,i)=>{if(Date.now()>t)throw new Error(`Request timed out after ${r} msec:
16
- Request ID: ${Nt(n)}
15
+ `)}}function N0(r){return()=>new Promise(t=>setTimeout(t,r))}function ru(r){let t=Date.now()+r;return async(e,n,i)=>{if(Date.now()>t)throw new Error(`Request timed out after ${r} msec:
16
+ Request ID: ${At(n)}
17
17
  Request status: ${i}
18
- `)}}function Fc(r,t){let e=r;return()=>new Promise(n=>setTimeout(()=>{e*=t,n()},e))}function Oc(...r){return async(t,e,n)=>{for(let i of r)await i(t,e,n)}}te();Xt();var Gw=Symbol.for("ic-agent-metadata");var Kw={pollingStrategyFactory:Qn.defaultStrategy};jr();te();Vn();Vr();Gs();Xt();Vn();Hr();var ri=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},Me=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},ti,ei,Er,Ar;function Pc(r){return r!==null&&typeof r=="object"}var We=class r{constructor(t){if(ti.set(this,void 0),ei.set(this,void 0),t.byteLength!==r.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");ri(this,ti,t,"f"),ri(this,ei,r.derEncode(t),"f")}static from(t){if(typeof t=="string"){let e=Gt(t);return this.fromRaw(e)}else if(Pc(t)){let e=t;if(Pc(e)&&Object.hasOwnProperty.call(e,"__derEncodedPublicKey__"))return this.fromDer(e);if(ArrayBuffer.isView(e)){let n=e;return this.fromRaw(Tn(n.buffer))}else{if(e instanceof ArrayBuffer)return this.fromRaw(e);if("rawKey"in e)return this.fromRaw(e.rawKey);if("derKey"in e)return this.fromDer(e.derKey);if("toDer"in e)return this.fromDer(e.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(t){return new r(t)}static fromDer(t){return new r(this.derDecode(t))}static derEncode(t){let e=_r(t,je).buffer;return e.__derEncodedPublicKey__=void 0,e}static derDecode(t){let e=Wr(t,je);if(e.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return e}get rawKey(){return Me(this,ti,"f")}get derKey(){return Me(this,ei,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};ti=new WeakMap,ei=new WeakMap;We.RAW_KEY_LENGTH=32;var ze=class r extends be{constructor(t,e){super(),Er.set(this,void 0),Ar.set(this,void 0),ri(this,Er,We.from(t),"f"),ri(this,Ar,new Uint8Array(e),"f")}static generate(t){if(t&&t.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");t||(t=xr.utils.randomPrivateKey()),$r(t,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 e=new Uint8Array(32);for(let i=0;i<32;i++)e[i]=new Uint8Array(t)[i];let n=xr.getPublicKey(e);return r.fromKeyPair(n,e)}static fromParsedJson(t){let[e,n]=t;return new r(We.fromDer(Gt(e)),Gt(n))}static fromJSON(t){let e=JSON.parse(t);if(Array.isArray(e)){if(typeof e[0]=="string"&&typeof e[1]=="string")return this.fromParsedJson([e[0],e[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(t)}`)}static fromKeyPair(t,e){return new r(We.fromRaw(t),e)}static fromSecretKey(t){let e=xr.getPublicKey(new Uint8Array(t));return r.fromKeyPair(e,t)}toJSON(){return[Nt(Me(this,Er,"f").toDer()),Nt(Me(this,Ar,"f"))]}getKeyPair(){return{secretKey:Me(this,Ar,"f"),publicKey:Me(this,Er,"f")}}getPublicKey(){return Me(this,Er,"f")}async sign(t){let e=new Uint8Array(t),n=He(xr.sign(e,Me(this,Ar,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(t,e,n){let[i,s,o]=[t,e,n].map(c=>(typeof c=="string"&&(c=Gt(c)),c instanceof Uint8Array&&(c=c.buffer),new Uint8Array(c)));return xr.verify(s,i,o)}};Er=new WeakMap,Ar=new WeakMap;var Ys=class r extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,r.prototype)}};function kc(r){if(typeof global<"u"&&global.crypto&&global.crypto.subtle)return global.crypto.subtle;if(r)return r;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new Ys("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 Yr=class r extends be{constructor(t,e,n){super(),this._keyPair=t,this._derKey=e,this._subtleCrypto=n}static async generate(t){let{extractable:e=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=t??{},s=kc(i),o=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},e,n),c=await s.exportKey("spki",o.publicKey);return new this(o,c,s)}static async fromKeyPair(t,e){let n=kc(e),i=await n.exportKey("spki",t.publicKey);return new r(t,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let t=this._derKey,e=Object.create(this._keyPair.publicKey);return e.toDer=function(){return t},e}async sign(t){let e={name:"ECDSA",hash:{name:"SHA-256"}};return this._keyPair.privateKey,await this._subtleCrypto.sign(e,this._keyPair.privateKey,t)}};te();var vr=Te(qr());te();var u0=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},Xr=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Ce,ni=class{constructor(t){Ce.set(this,void 0),u0(this,Ce,t,"f")}get rawKey(){return Xr(this,Ce,"f").rawKey}get derKey(){return Xr(this,Ce,"f").derKey}toDer(){return Xr(this,Ce,"f").toDer()}getPublicKey(){return Xr(this,Ce,"f")}getPrincipal(){return It.from(Xr(this,Ce,"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.")}};Ce=new WeakMap;var f0=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},l0=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},h0=function(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(e[n[i]]=r[n[i]]);return e},ii,d0=new TextEncoder().encode("ic-request-auth-delegation"),p0=new TextEncoder().encode(`
19
- ic-request`);function Xs(r){if(typeof r!="string"||r.length<64)throw new Error("Invalid public key.");return Gt(r)}var Tr=class{constructor(t,e,n){this.pubkey=t,this.expiration=e,this.targets=n}toCBOR(){return vr.value.map(Object.assign({pubkey:vr.value.bytes(this.pubkey),expiration:vr.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:vr.value.array(this.targets.map(t=>vr.value.bytes(t.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:Nt(this.pubkey)},this.targets&&{targets:this.targets.map(t=>t.toHex())})}};async function y0(r,t,e,n){let i=new Tr(t.toDer(),BigInt(+e)*BigInt(1e6),n),s=new Uint8Array([...d0,...new Uint8Array(pr(i))]),o=await r.sign(s);return{delegation:i,signature:o}}var Ye=class r{constructor(t,e){this.delegations=t,this.publicKey=e}static async create(t,e,n=new Date(Date.now()+15*60*1e3),i={}){var s,o;let c=await y0(t,e,n,i.targets);return new r([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],c],((o=i.previous)===null||o===void 0?void 0:o.publicKey)||t.getPublicKey().toDer())}static fromJSON(t){let{publicKey:e,delegations:n}=typeof t=="string"?JSON.parse(t):t;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:o,signature:c}=s,{pubkey:u,expiration:w,targets:y}=o;if(y!==void 0&&!Array.isArray(y))throw new Error("Invalid targets.");return{delegation:new Tr(Xs(u),BigInt("0x"+w),y&&y.map(m=>{if(typeof m!="string")throw new Error("Invalid target.");return It.fromHex(m)})),signature:Xs(c)}});return new this(i,Xs(e))}static fromDelegations(t,e){return new this(t,e)}toJSON(){return{delegations:this.delegations.map(t=>{let{delegation:e,signature:n}=t,{targets:i}=e;return{delegation:Object.assign({expiration:e.expiration.toString(16),pubkey:Nt(e.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:Nt(n)}}),publicKey:Nt(this.publicKey)}}},Jr=class extends be{constructor(t,e){super(),this._inner=t,this._delegation=e}static fromDelegation(t,e){return new this(t,e)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(t){return this._inner.sign(t)}async transformRequest(t){let{body:e}=t,n=h0(t,["body"]),i=await pr(e);return Object.assign(Object.assign({},n),{body:{content:e,sender_sig:await this.sign(new Uint8Array([...p0,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},Zr=class r extends ni{constructor(t,e){super(t),ii.set(this,void 0),f0(this,ii,e,"f")}get delegation(){return l0(this,ii,"f")}static fromDelegation(t,e){return new r(t,e)}};ii=new WeakMap;function si(r,t){for(let{delegation:i}of r.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let e=[],n=t?.scope;n&&(Array.isArray(n)?e.push(...n.map(i=>typeof i=="string"?It.fromText(i):i)):e.push(typeof n=="string"?It.fromText(n):n));for(let i of e){let s=i.toText();for(let{delegation:o}of r.delegations){if(o.targets===void 0)continue;let c=!0;for(let u of o.targets)if(u.toText()===s){c=!1;break}if(c)return!1}}return!0}var w0=Te(vn());ur();var Mc;(function(r){r[r.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(Mc||(Mc={}));var Cc=["mousedown","mousemove","keydown","touchstart","wheel"],Qr=class{constructor(t={}){var e;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=t||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let s=this._resetTimer.bind(this);window.addEventListener("load",s,!0),Cc.forEach(function(c){document.addEventListener(c,s,!0)});let o=(c,u)=>{let w;return(...y)=>{let m=this,N=function(){w=void 0,c.apply(m,y)};clearTimeout(w),w=window.setTimeout(N,u)}};if(t?.captureScroll){let c=o(s,(e=t?.scrollDebounce)!==null&&e!==void 0?e:100);window.addEventListener("scroll",c,!0)}s()}static create(t={}){return new this(t)}registerCallback(t){this.callbacks.push(t)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let t=this._resetTimer.bind(this);Cc.forEach(function(e){document.removeEventListener(e,t,!0)}),this.callbacks.forEach(e=>e())}_resetTimer(){let t=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(t,this.idleTimeout)}};var g0=(r,t)=>t.some(e=>r instanceof e),$c,Vc;function m0(){return $c||($c=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function x0(){return Vc||(Vc=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Lc=new WeakMap,Zs=new WeakMap,qc=new WeakMap,Js=new WeakMap,to=new WeakMap;function _0(r){let t=new Promise((e,n)=>{let i=()=>{r.removeEventListener("success",s),r.removeEventListener("error",o)},s=()=>{e(me(r.result)),i()},o=()=>{n(r.error),i()};r.addEventListener("success",s),r.addEventListener("error",o)});return t.then(e=>{e instanceof IDBCursor&&Lc.set(e,r)}).catch(()=>{}),to.set(t,r),t}function b0(r){if(Zs.has(r))return;let t=new Promise((e,n)=>{let i=()=>{r.removeEventListener("complete",s),r.removeEventListener("error",o),r.removeEventListener("abort",o)},s=()=>{e(),i()},o=()=>{n(r.error||new DOMException("AbortError","AbortError")),i()};r.addEventListener("complete",s),r.addEventListener("error",o),r.addEventListener("abort",o)});Zs.set(r,t)}var Qs={get(r,t,e){if(r instanceof IDBTransaction){if(t==="done")return Zs.get(r);if(t==="objectStoreNames")return r.objectStoreNames||qc.get(r);if(t==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return me(r[t])},set(r,t,e){return r[t]=e,!0},has(r,t){return r instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in r}};function Hc(r){Qs=r(Qs)}function E0(r){return r===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...e){let n=r.call(oi(this),t,...e);return qc.set(n,t.sort?t.sort():[t]),me(n)}:x0().includes(r)?function(...t){return r.apply(oi(this),t),me(Lc.get(this))}:function(...t){return me(r.apply(oi(this),t))}}function A0(r){return typeof r=="function"?E0(r):(r instanceof IDBTransaction&&b0(r),g0(r,m0())?new Proxy(r,Qs):r)}function me(r){if(r instanceof IDBRequest)return _0(r);if(Js.has(r))return Js.get(r);let t=A0(r);return t!==r&&(Js.set(r,t),to.set(t,r)),t}var oi=r=>to.get(r);function Kc(r,t,{blocked:e,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(r,t),c=me(o);return n&&o.addEventListener("upgradeneeded",u=>{n(me(o.result),u.oldVersion,u.newVersion,me(o.transaction),u)}),e&&o.addEventListener("blocked",u=>e(u.oldVersion,u.newVersion,u)),c.then(u=>{s&&u.addEventListener("close",()=>s()),i&&u.addEventListener("versionchange",w=>i(w.oldVersion,w.newVersion,w))}).catch(()=>{}),c}var v0=["get","getKey","getAll","getAllKeys","count"],T0=["put","add","delete","clear"],eo=new Map;function Gc(r,t){if(!(r instanceof IDBDatabase&&!(t in r)&&typeof t=="string"))return;if(eo.get(t))return eo.get(t);let e=t.replace(/FromIndex$/,""),n=t!==e,i=T0.includes(e);if(!(e in(n?IDBIndex:IDBObjectStore).prototype)||!(i||v0.includes(e)))return;let s=async function(o,...c){let u=this.transaction(o,i?"readwrite":"readonly"),w=u.store;return n&&(w=w.index(c.shift())),(await Promise.all([w[e](...c),i&&u.done]))[0]};return eo.set(t,s),s}Hc(r=>({...r,get:(t,e,n)=>Gc(t,e)||r.get(t,e,n),has:(t,e)=>!!Gc(t,e)||r.has(t,e)}));var Dc="auth-client-db",jc="ic-keyval",S0=async(r=Dc,t=jc,e)=>(ai&&(localStorage!=null&&localStorage.getItem(Jt))&&(localStorage.removeItem(Jt),localStorage.removeItem(ue)),await Kc(r,e,{upgrade:n=>{n.objectStoreNames,n.objectStoreNames.contains(t)&&n.clear(t),n.createObjectStore(t)}}));async function B0(r,t,e){return await r.get(t,e)}async function I0(r,t,e,n){return await r.put(t,n,e)}async function N0(r,t,e){return await r.delete(t,e)}var tn=class r{constructor(t,e){this._db=t,this._storeName=e}static async create(t){let{dbName:e=Dc,storeName:n=jc,version:i=Wc}=t??{},s=await S0(e,n,i);return new r(s,n)}async set(t,e){return await I0(this._db,this._storeName,t,e)}async get(t){var e;return(e=await B0(this._db,this._storeName,t))!==null&&e!==void 0?e:null}async remove(t){return await N0(this._db,this._storeName,t)}};var U0=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},R0=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},ci,ue="identity",Jt="delegation",zc="iv",Wc=1,ai=typeof window<"u",en=class{constructor(t="ic-",e){this.prefix=t,this._localStorage=e}get(t){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+t))}set(t,e){return this._getLocalStorage().setItem(this.prefix+t,e),Promise.resolve()}remove(t){return this._getLocalStorage().removeItem(this.prefix+t),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let t=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!t)throw new Error("Could not find local storage.");return t}},Xe=class{constructor(t){ci.set(this,void 0),U0(this,ci,t??{},"f")}get _db(){return new Promise(t=>{if(this.initializedDb){t(this.initializedDb);return}tn.create(R0(this,ci,"f")).then(e=>{this.initializedDb=e,t(e)})})}async get(t){return await(await this._db).get(t)}async set(t,e){await(await this._db).set(t,e)}async remove(t){await(await this._db).remove(t)}};ci=new WeakMap;var F0="https://identity.ic0.app",O0="#authorize",ro="ECDSA",no="Ed25519",P0=500,k0="UserInterrupt",ui=class{constructor(t,e,n,i,s,o,c,u){this._identity=t,this._key=e,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=o,this._idpWindow=c,this._eventHandler=u,this._registerDefaultIdleCallback()}static async create(t={}){var e,n,i;let s=(e=t.storage)!==null&&e!==void 0?e:new Xe,o=(n=t.keyType)!==null&&n!==void 0?n:ro,c=null;if(t.identity)c=t.identity;else{let m=await s.get(ue);if(!m&&ai)try{let N=new en,M=await N.get(Jt),O=await N.get(ue);M&&O&&o===ro&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(Jt,M),await s.set(ue,O),m=M,await N.remove(Jt),await N.remove(ue))}catch(N){console.error("error while attempting to recover localstorage: "+N)}if(m)try{typeof m=="object"?o===no&&typeof m=="string"?c=await ze.fromJSON(m):c=await Yr.fromKeyPair(m):typeof m=="string"&&(c=ze.fromJSON(m))}catch{}}let u=new yr,w=null;if(c)try{let m=await s.get(Jt);if(typeof m=="object"&&m!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");t.identity?u=t.identity:m&&(w=Ye.fromJSON(m),si(w)?"toDer"in c?u=Zr.fromDelegation(c,w):u=Jr.fromDelegation(c,w):(await io(s),c=null))}catch(m){console.error(m),await io(s),c=null}let y;return!((i=t.idleOptions)===null||i===void 0)&&i.disableIdle?y=void 0:(w||t.identity)&&(y=Qr.create(t.idleOptions)),c||(o===no?(c=await ze.generate(),await s.set(ue,JSON.stringify(c.toJSON()))):(t.storage&&o===ro&&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 '${no}' as the key type, as it can serialize to a string`),c=await Yr.generate(),await s.set(ue,c.getKeyPair()))),new this(u,c,w,s,y,t)}_registerDefaultIdleCallback(){var t,e;let n=(t=this._createOptions)===null||t===void 0?void 0:t.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((e=this.idleManager)===null||e===void 0||e.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(t,e){var n,i;let s=t.delegations.map(w=>({delegation:new Tr(w.delegation.pubkey,w.delegation.expiration,w.delegation.targets),signature:w.signature.buffer})),o=Ye.fromDelegations(s,t.userPublicKey.buffer),c=this._key;if(!c)return;this._chain=o,"toDer"in c?this._identity=Zr.fromDelegation(c,this._chain):this._identity=Jr.fromDelegation(c,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let u=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!u?.disableIdle&&(this.idleManager=Qr.create(u),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(Jt,JSON.stringify(this._chain.toJSON())),e?.(t)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(t){var e,n,i,s;let o=BigInt(8)*BigInt(36e11),c=new URL(((e=t?.identityProvider)===null||e===void 0?void 0:e.toString())||F0);c.hash=O0,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(c,Object.assign({maxTimeToLive:(i=t?.maxTimeToLive)!==null&&i!==void 0?i:o},t)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(c.toString(),"idpWindow",t?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let u=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(k0,t?.onError):setTimeout(u,P0))};u()}_getEventHandler(t,e){return async n=>{var i,s,o;if(n.origin!==t.origin){console.warn(`WARNING: expected origin '${t.origin}', got '${n.origin}' (ignoring)`);return}let c=n.data;switch(c.kind){case"authorize-ready":{let u=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:e?.maxTimeToLive,allowPinAuthentication:e?.allowPinAuthentication,derivationOrigin:(s=e?.derivationOrigin)===null||s===void 0?void 0:s.toString()},e?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(u,t.origin);break}case"authorize-client-success":try{await this._handleSuccess(c,e?.onSuccess)}catch(u){this._handleFailure(u.message,e?.onError)}break;case"authorize-client-failure":this._handleFailure(c.text,e?.onError);break;default:break}}}_handleFailure(t,e){var n;(n=this._idpWindow)===null||n===void 0||n.close(),e?.(t),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(t={}){if(await io(this._storage),this._identity=new yr,this._chain=null,t.returnTo)try{window.history.pushState({},"",t.returnTo)}catch{window.location.href=t.returnTo}}};async function io(r){await r.remove(ue),await r.remove(Jt),await r.remove(zc)}var im=BigInt(144e11);var Yc=1e3;var Xc=()=>ui.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});onmessage=({data:r})=>{let{msg:t}=r;switch(t){case"junoStartAuthTimer":M0();return;case"junoStopAuthTimer":Jc();return}};var fi,M0=()=>fi=setInterval(async()=>await C0(),Yc),Jc=()=>{fi&&(clearInterval(fi),fi=void 0)},C0=async()=>{let[r,t]=await Promise.all([$0(),V0()]);if(r&&t.valid&&t.delegation!==null){q0(t.delegation);return}L0()},$0=async()=>(await Xc()).isAuthenticated(),V0=async()=>{let t=await new Xe().get(Jt),e=t!==null?Ye.fromJSON(t):null;return{valid:e!==null&&si(e),delegation:e}},L0=()=>{Jc(),postMessage({msg:"junoSignOutAuthTimer"})},q0=r=>{let t=r.delegations[0]?.delegation.expiration;if(t===void 0)return;let e=new Date(Number(t/BigInt(1e6))).getTime()-Date.now();postMessage({msg:"junoDelegationRemainingTime",data:{authRemainingTime:e}})};})();
18
+ `)}}function nu(r,t){let e=r;return()=>new Promise(n=>setTimeout(()=>{e*=t,n()},e))}function iu(...r){return async(t,e,n)=>{for(let i of r)await i(t,e,n)}}io();Wt();jt();Er();var Eg=Symbol.for("ic-agent-metadata");var Ag={pollingStrategyFactory:ii.defaultStrategy};Jr();Cn();Wr();Bs();Er();ro();Wt();Gn();oo();no();jr();Js();jt();$s();Gn();Dr();qc();var ai=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},Me=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},si,oi,Sr,Br;function su(r){return r!==null&&typeof r=="object"}var Ye=class r{constructor(t){if(si.set(this,void 0),oi.set(this,void 0),t.byteLength!==r.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");ai(this,si,t,"f"),ai(this,oi,r.derEncode(t),"f")}static from(t){if(typeof t=="string"){let e=Lt(t);return this.fromRaw(e)}else if(su(t)){let e=t;if(su(e)&&Object.hasOwnProperty.call(e,"__derEncodedPublicKey__"))return this.fromDer(e);if(ArrayBuffer.isView(e)){let n=e;return this.fromRaw(xn(n.buffer))}else{if(e instanceof ArrayBuffer)return this.fromRaw(e);if("rawKey"in e)return this.fromRaw(e.rawKey);if("derKey"in e)return this.fromDer(e.derKey);if("toDer"in e)return this.fromDer(e.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(t){return new r(t)}static fromDer(t){return new r(this.derDecode(t))}static derEncode(t){let e=vr(t,ze).buffer;return e.__derEncodedPublicKey__=void 0,e}static derDecode(t){let e=Zr(t,ze);if(e.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return e}get rawKey(){return Me(this,si,"f")}get derKey(){return Me(this,oi,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};si=new WeakMap,oi=new WeakMap;Ye.RAW_KEY_LENGTH=32;var Xe=class r extends be{constructor(t,e){super(),Sr.set(this,void 0),Br.set(this,void 0),ai(this,Sr,Ye.from(t),"f"),ai(this,Br,new Uint8Array(e),"f")}static generate(t){if(t&&t.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");t||(t=Ar.utils.randomPrivateKey()),Pr(t,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 e=new Uint8Array(32);for(let i=0;i<32;i++)e[i]=new Uint8Array(t)[i];let n=Ar.getPublicKey(e);return r.fromKeyPair(n,e)}static fromParsedJson(t){let[e,n]=t;return new r(Ye.fromDer(Lt(e)),Lt(n))}static fromJSON(t){let e=JSON.parse(t);if(Array.isArray(e)){if(typeof e[0]=="string"&&typeof e[1]=="string")return this.fromParsedJson([e[0],e[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(t)}`)}static fromKeyPair(t,e){return new r(Ye.fromRaw(t),e)}static fromSecretKey(t){let e=Ar.getPublicKey(new Uint8Array(t));return r.fromKeyPair(e,t)}toJSON(){return[At(Me(this,Sr,"f").toDer()),At(Me(this,Br,"f"))]}getKeyPair(){return{secretKey:Me(this,Br,"f"),publicKey:Me(this,Sr,"f")}}getPublicKey(){return Me(this,Sr,"f")}async sign(t){let e=new Uint8Array(t),n=je(Ar.sign(e,Me(this,Br,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(t,e,n){let[i,s,o]=[t,e,n].map(c=>(typeof c=="string"&&(c=Lt(c)),c instanceof Uint8Array&&(c=c.buffer),new Uint8Array(c)));return Ar.verify(s,i,o)}};Sr=new WeakMap,Br=new WeakMap;var co=class r extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,r.prototype)}};function ou(r){if(typeof global<"u"&&global.crypto&&global.crypto.subtle)return global.crypto.subtle;if(r)return r;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new co("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 tn=class r extends be{constructor(t,e,n){super(),this._keyPair=t,this._derKey=e,this._subtleCrypto=n}static async generate(t){let{extractable:e=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=t??{},s=ou(i),o=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},e,n),c=await s.exportKey("spki",o.publicKey);return new this(o,c,s)}static async fromKeyPair(t,e){let n=ou(e),i=await n.exportKey("spki",t.publicKey);return new r(t,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let t=this._derKey,e=Object.create(this._keyPair.publicKey);return e.toDer=function(){return t},e}async sign(t){let e={name:"ECDSA",hash:{name:"SHA-256"}};return await this._subtleCrypto.sign(e,this._keyPair.privateKey,t)}};Wt();var Ir=Te(Kr());Wt();var O0=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},en=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Ce,ci=class{constructor(t){Ce.set(this,void 0),O0(this,Ce,t,"f")}get rawKey(){return en(this,Ce,"f").rawKey}get derKey(){return en(this,Ce,"f").derKey}toDer(){return en(this,Ce,"f").toDer()}getPublicKey(){return en(this,Ce,"f")}getPrincipal(){return Et.from(en(this,Ce,"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.")}};Ce=new WeakMap;var P0=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},k0=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},M0=function(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(e[n[i]]=r[n[i]]);return e},ui,C0=new TextEncoder().encode("ic-request-auth-delegation"),$0=new TextEncoder().encode(`
19
+ ic-request`);function uo(r){if(typeof r!="string"||r.length<64)throw new Error("Invalid public key.");return Lt(r)}var Nr=class{constructor(t,e,n){this.pubkey=t,this.expiration=e,this.targets=n}toCBOR(){return Ir.value.map(Object.assign({pubkey:Ir.value.bytes(this.pubkey),expiration:Ir.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Ir.value.array(this.targets.map(t=>Ir.value.bytes(t.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:At(this.pubkey)},this.targets&&{targets:this.targets.map(t=>t.toHex())})}};async function V0(r,t,e,n){let i=new Nr(t.toDer(),BigInt(+e)*BigInt(1e6),n),s=new Uint8Array([...C0,...new Uint8Array(wr(i))]),o=await r.sign(s);return{delegation:i,signature:o}}var Je=class r{constructor(t,e){this.delegations=t,this.publicKey=e}static async create(t,e,n=new Date(Date.now()+15*60*1e3),i={}){var s,o;let c=await V0(t,e,n,i.targets);return new r([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],c],((o=i.previous)===null||o===void 0?void 0:o.publicKey)||t.getPublicKey().toDer())}static fromJSON(t){let{publicKey:e,delegations:n}=typeof t=="string"?JSON.parse(t):t;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:o,signature:c}=s,{pubkey:u,expiration:w,targets:y}=o;if(y!==void 0&&!Array.isArray(y))throw new Error("Invalid targets.");return{delegation:new Nr(uo(u),BigInt("0x"+w),y&&y.map(m=>{if(typeof m!="string")throw new Error("Invalid target.");return Et.fromHex(m)})),signature:uo(c)}});return new this(i,uo(e))}static fromDelegations(t,e){return new this(t,e)}toJSON(){return{delegations:this.delegations.map(t=>{let{delegation:e,signature:n}=t,{targets:i}=e;return{delegation:Object.assign({expiration:e.expiration.toString(16),pubkey:At(e.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:At(n)}}),publicKey:At(this.publicKey)}}},rn=class extends be{constructor(t,e){super(),this._inner=t,this._delegation=e}static fromDelegation(t,e){return new this(t,e)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(t){return this._inner.sign(t)}async transformRequest(t){let{body:e}=t,n=M0(t,["body"]),i=await wr(e);return Object.assign(Object.assign({},n),{body:{content:e,sender_sig:await this.sign(new Uint8Array([...$0,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},nn=class r extends ci{constructor(t,e){super(t),ui.set(this,void 0),P0(this,ui,e,"f")}get delegation(){return k0(this,ui,"f")}static fromDelegation(t,e){return new r(t,e)}};ui=new WeakMap;function fi(r,t){for(let{delegation:i}of r.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let e=[],n=t?.scope;n&&(Array.isArray(n)?e.push(...n.map(i=>typeof i=="string"?Et.fromText(i):i)):e.push(typeof n=="string"?Et.fromText(n):n));for(let i of e){let s=i.toText();for(let{delegation:o}of r.delegations){if(o.targets===void 0)continue;let c=!0;for(let u of o.targets)if(u.toText()===s){c=!1;break}if(c)return!1}}return!0}var q0=Te(Nn());lr();var au;(function(r){r[r.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(au||(au={}));var cu=["mousedown","mousemove","keydown","touchstart","wheel"],sn=class{constructor(t={}){var e;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=t||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let s=this._resetTimer.bind(this);window.addEventListener("load",s,!0),cu.forEach(function(c){document.addEventListener(c,s,!0)});let o=(c,u)=>{let w;return(...y)=>{let m=this,N=function(){w=void 0,c.apply(m,y)};clearTimeout(w),w=window.setTimeout(N,u)}};if(t?.captureScroll){let c=o(s,(e=t?.scrollDebounce)!==null&&e!==void 0?e:100);window.addEventListener("scroll",c,!0)}s()}static create(t={}){return new this(t)}registerCallback(t){this.callbacks.push(t)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let t=this._resetTimer.bind(this);cu.forEach(function(e){document.removeEventListener(e,t,!0)}),this.callbacks.forEach(e=>e())}_resetTimer(){let t=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(t,this.idleTimeout)}};var H0=(r,t)=>t.some(e=>r instanceof e),uu,fu;function L0(){return uu||(uu=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function j0(){return fu||(fu=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var lu=new WeakMap,lo=new WeakMap,hu=new WeakMap,fo=new WeakMap,po=new WeakMap;function G0(r){let t=new Promise((e,n)=>{let i=()=>{r.removeEventListener("success",s),r.removeEventListener("error",o)},s=()=>{e(me(r.result)),i()},o=()=>{n(r.error),i()};r.addEventListener("success",s),r.addEventListener("error",o)});return t.then(e=>{e instanceof IDBCursor&&lu.set(e,r)}).catch(()=>{}),po.set(t,r),t}function K0(r){if(lo.has(r))return;let t=new Promise((e,n)=>{let i=()=>{r.removeEventListener("complete",s),r.removeEventListener("error",o),r.removeEventListener("abort",o)},s=()=>{e(),i()},o=()=>{n(r.error||new DOMException("AbortError","AbortError")),i()};r.addEventListener("complete",s),r.addEventListener("error",o),r.addEventListener("abort",o)});lo.set(r,t)}var ho={get(r,t,e){if(r instanceof IDBTransaction){if(t==="done")return lo.get(r);if(t==="objectStoreNames")return r.objectStoreNames||hu.get(r);if(t==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return me(r[t])},set(r,t,e){return r[t]=e,!0},has(r,t){return r instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in r}};function du(r){ho=r(ho)}function D0(r){return r===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...e){let n=r.call(li(this),t,...e);return hu.set(n,t.sort?t.sort():[t]),me(n)}:j0().includes(r)?function(...t){return r.apply(li(this),t),me(lu.get(this))}:function(...t){return me(r.apply(li(this),t))}}function W0(r){return typeof r=="function"?D0(r):(r instanceof IDBTransaction&&K0(r),H0(r,L0())?new Proxy(r,ho):r)}function me(r){if(r instanceof IDBRequest)return G0(r);if(fo.has(r))return fo.get(r);let t=W0(r);return t!==r&&(fo.set(r,t),po.set(t,r)),t}var li=r=>po.get(r);function yu(r,t,{blocked:e,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(r,t),c=me(o);return n&&o.addEventListener("upgradeneeded",u=>{n(me(o.result),u.oldVersion,u.newVersion,me(o.transaction),u)}),e&&o.addEventListener("blocked",u=>e(u.oldVersion,u.newVersion,u)),c.then(u=>{s&&u.addEventListener("close",()=>s()),i&&u.addEventListener("versionchange",w=>i(w.oldVersion,w.newVersion,w))}).catch(()=>{}),c}var z0=["get","getKey","getAll","getAllKeys","count"],Y0=["put","add","delete","clear"],yo=new Map;function pu(r,t){if(!(r instanceof IDBDatabase&&!(t in r)&&typeof t=="string"))return;if(yo.get(t))return yo.get(t);let e=t.replace(/FromIndex$/,""),n=t!==e,i=Y0.includes(e);if(!(e in(n?IDBIndex:IDBObjectStore).prototype)||!(i||z0.includes(e)))return;let s=async function(o,...c){let u=this.transaction(o,i?"readwrite":"readonly"),w=u.store;return n&&(w=w.index(c.shift())),(await Promise.all([w[e](...c),i&&u.done]))[0]};return yo.set(t,s),s}du(r=>({...r,get:(t,e,n)=>pu(t,e)||r.get(t,e,n),has:(t,e)=>!!pu(t,e)||r.has(t,e)}));var wu="auth-client-db",gu="ic-keyval",X0=async(r=wu,t=gu,e)=>(hi&&(localStorage!=null&&localStorage.getItem(Zt))&&(localStorage.removeItem(Zt),localStorage.removeItem(ue)),await yu(r,e,{upgrade:n=>{n.objectStoreNames.contains(t)&&n.clear(t),n.createObjectStore(t)}}));async function J0(r,t,e){return await r.get(t,e)}async function Z0(r,t,e,n){return await r.put(t,n,e)}async function Q0(r,t,e){return await r.delete(t,e)}var on=class r{constructor(t,e){this._db=t,this._storeName=e}static async create(t){let{dbName:e=wu,storeName:n=gu,version:i=mu}=t??{},s=await X0(e,n,i);return new r(s,n)}async set(t,e){return await Z0(this._db,this._storeName,t,e)}async get(t){var e;return(e=await J0(this._db,this._storeName,t))!==null&&e!==void 0?e:null}async remove(t){return await Q0(this._db,this._storeName,t)}};var td=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},ed=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},di,ue="identity",Zt="delegation",xu="iv",mu=1,hi=typeof window<"u",an=class{constructor(t="ic-",e){this.prefix=t,this._localStorage=e}get(t){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+t))}set(t,e){return this._getLocalStorage().setItem(this.prefix+t,e),Promise.resolve()}remove(t){return this._getLocalStorage().removeItem(this.prefix+t),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let t=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!t)throw new Error("Could not find local storage.");return t}},Ze=class{constructor(t){di.set(this,void 0),td(this,di,t??{},"f")}get _db(){return new Promise(t=>{if(this.initializedDb){t(this.initializedDb);return}on.create(ed(this,di,"f")).then(e=>{this.initializedDb=e,t(e)})})}async get(t){return await(await this._db).get(t)}async set(t,e){await(await this._db).set(t,e)}async remove(t){await(await this._db).remove(t)}};di=new WeakMap;var rd="https://identity.ic0.app",nd="#authorize",wo="ECDSA",go="Ed25519",id=500,sd="UserInterrupt",pi=class{constructor(t,e,n,i,s,o,c,u){this._identity=t,this._key=e,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=o,this._idpWindow=c,this._eventHandler=u,this._registerDefaultIdleCallback()}static async create(t={}){var e,n,i;let s=(e=t.storage)!==null&&e!==void 0?e:new Ze,o=(n=t.keyType)!==null&&n!==void 0?n:wo,c=null;if(t.identity)c=t.identity;else{let m=await s.get(ue);if(!m&&hi)try{let N=new an,k=await N.get(Zt),O=await N.get(ue);k&&O&&o===wo&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(Zt,k),await s.set(ue,O),m=k,await N.remove(Zt),await N.remove(ue))}catch(N){console.error("error while attempting to recover localstorage: "+N)}if(m)try{typeof m=="object"?o===go&&typeof m=="string"?c=await Xe.fromJSON(m):c=await tn.fromKeyPair(m):typeof m=="string"&&(c=Xe.fromJSON(m))}catch{}}let u=new gr,w=null;if(c)try{let m=await s.get(Zt);if(typeof m=="object"&&m!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");t.identity?u=t.identity:m&&(w=Je.fromJSON(m),fi(w)?"toDer"in c?u=nn.fromDelegation(c,w):u=rn.fromDelegation(c,w):(await mo(s),c=null))}catch(m){console.error(m),await mo(s),c=null}let y;return!((i=t.idleOptions)===null||i===void 0)&&i.disableIdle?y=void 0:(w||t.identity)&&(y=sn.create(t.idleOptions)),c||(o===go?(c=await Xe.generate(),await s.set(ue,JSON.stringify(c.toJSON()))):(t.storage&&o===wo&&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 '${go}' as the key type, as it can serialize to a string`),c=await tn.generate(),await s.set(ue,c.getKeyPair()))),new this(u,c,w,s,y,t)}_registerDefaultIdleCallback(){var t,e;let n=(t=this._createOptions)===null||t===void 0?void 0:t.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((e=this.idleManager)===null||e===void 0||e.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(t,e){var n,i;let s=t.delegations.map(w=>({delegation:new Nr(w.delegation.pubkey,w.delegation.expiration,w.delegation.targets),signature:w.signature.buffer})),o=Je.fromDelegations(s,t.userPublicKey.buffer),c=this._key;if(!c)return;this._chain=o,"toDer"in c?this._identity=nn.fromDelegation(c,this._chain):this._identity=rn.fromDelegation(c,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let u=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!u?.disableIdle&&(this.idleManager=sn.create(u),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(Zt,JSON.stringify(this._chain.toJSON())),e?.(t)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(t){var e,n,i,s;let o=BigInt(8)*BigInt(36e11),c=new URL(((e=t?.identityProvider)===null||e===void 0?void 0:e.toString())||rd);c.hash=nd,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(c,Object.assign({maxTimeToLive:(i=t?.maxTimeToLive)!==null&&i!==void 0?i:o},t)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(c.toString(),"idpWindow",t?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let u=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(sd,t?.onError):setTimeout(u,id))};u()}_getEventHandler(t,e){return async n=>{var i,s,o;if(n.origin!==t.origin){console.warn(`WARNING: expected origin '${t.origin}', got '${n.origin}' (ignoring)`);return}let c=n.data;switch(c.kind){case"authorize-ready":{let u=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:e?.maxTimeToLive,allowPinAuthentication:e?.allowPinAuthentication,derivationOrigin:(s=e?.derivationOrigin)===null||s===void 0?void 0:s.toString()},e?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(u,t.origin);break}case"authorize-client-success":try{await this._handleSuccess(c,e?.onSuccess)}catch(u){this._handleFailure(u.message,e?.onError)}break;case"authorize-client-failure":this._handleFailure(c.text,e?.onError);break;default:break}}}_handleFailure(t,e){var n;(n=this._idpWindow)===null||n===void 0||n.close(),e?.(t),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(t={}){if(await mo(this._storage),this._identity=new gr,this._chain=null,t.returnTo)try{window.history.pushState({},"",t.returnTo)}catch{window.location.href=t.returnTo}}};async function mo(r){await r.remove(ue),await r.remove(Zt),await r.remove(xu)}var $m=BigInt(144e11);var _u=1e3;var bu=()=>pi.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});onmessage=({data:r})=>{let{msg:t}=r;switch(t){case"junoStartAuthTimer":od();return;case"junoStopAuthTimer":Eu();return}};var yi,od=()=>yi=setInterval(async()=>await ad(),_u),Eu=()=>{yi&&(clearInterval(yi),yi=void 0)},ad=async()=>{let[r,t]=await Promise.all([cd(),ud()]);if(r&&t.valid&&t.delegation!==null){ld(t.delegation);return}fd()},cd=async()=>(await bu()).isAuthenticated(),ud=async()=>{let t=await new Ze().get(Zt),e=t!==null?Je.fromJSON(t):null;return{valid:e!==null&&fi(e),delegation:e}},fd=()=>{Eu(),postMessage({msg:"junoSignOutAuthTimer"})},ld=r=>{let t=r.delegations[0]?.delegation.expiration;if(t===void 0)return;let e=new Date(Number(t/BigInt(1e6))).getTime()-Date.now();postMessage({msg:"junoDelegationRemainingTime",data:{authRemainingTime:e}})};})();
20
20
  /*! Bundled license information:
21
21
 
22
22
  ieee754/index.js: