@dfinity/nns 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/candid/payloads.did +52 -19
- package/dist/candid/payloads.idl.d.ts +10 -4
- package/dist/candid/payloads.idl.js +41 -10
- package/dist/cjs/index.cjs.js +21 -21
- package/dist/cjs/index.cjs.js.map +2 -2
- package/dist/esm/{chunk-KUIJF2IJ.js → chunk-BCUFAIRO.js} +2 -2
- package/dist/esm/{chunk-KUIJF2IJ.js.map → chunk-BCUFAIRO.js.map} +0 -0
- package/dist/esm/{chunk-E6UFXMWU.js → chunk-BVNLDI2R.js} +2 -2
- package/dist/esm/{chunk-E6UFXMWU.js.map → chunk-BVNLDI2R.js.map} +1 -1
- package/dist/esm/{chunk-NOBP3Q32.js → chunk-FZYDRSYR.js} +5 -5
- package/dist/esm/{chunk-NOBP3Q32.js.map → chunk-FZYDRSYR.js.map} +2 -2
- package/dist/esm/{chunk-HPCMNLTU.js → chunk-PTMKC5FF.js} +2 -2
- package/dist/esm/{chunk-HPCMNLTU.js.map → chunk-PTMKC5FF.js.map} +0 -0
- package/dist/esm/{chunk-DRE7O6A5.js → chunk-Z667VRMY.js} +2 -2
- package/dist/esm/{chunk-DRE7O6A5.js.map → chunk-Z667VRMY.js.map} +0 -0
- package/dist/esm/genesis_token.js +1 -1
- package/dist/esm/governance.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/ledger.js +1 -1
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as n}from"./chunk-
|
|
1
|
+
import{c as n}from"./chunk-BVNLDI2R.js";var u=async({agent:s,canisterId:t,methodName:r,arg:a})=>{let e=await s.call(t,{methodName:r,arg:a,effectiveCanisterId:t});if(!e.response.ok)throw new Error(["Call failed:",` Method: ${r}`,` Canister ID: ${t}`,` Request ID: ${e.requestId}`,` HTTP status code: ${e.response.status}`,` HTTP status text: ${e.response.statusText}`].join(`
|
|
2
2
|
`));let o=await n.pollForResponse(s,t,e.requestId,n.defaultStrategy());return new Uint8Array(o)},p=async({agent:s,canisterId:t,methodName:r,arg:a})=>{let e=await s.query(t,{methodName:r,arg:a});if(e.status=="rejected")throw new Error(["Call failed:",` Method: ${r}`,` Canister ID: ${t}`,` HTTP status code: ${e.reject_code}`,` HTTP status text: ${e.reject_message}`].join(`
|
|
3
3
|
`));return new Uint8Array(e.reply.arg)};export{u as a,p as b};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
//# sourceMappingURL=chunk-BCUFAIRO.js.map
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{a as Nr,b as sB,c as br,d as oB}from"./chunk-KXYKDST6.js";import{a as lA,b as Jt,c as zA}from"./chunk-ONAVPXOT.js";var Ve=lA(xe=>{"use strict";var Zt=sB(),Fe=br(),ui=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;xe.Buffer=G;xe.SlowBuffer=dB;xe.INSPECT_MAX_BYTES=50;var lt=2147483647;xe.kMaxLength=lt;G.TYPED_ARRAY_SUPPORT=fB();!G.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function fB(){try{var t=new Uint8Array(1),A={foo:function(){return 42}};return Object.setPrototypeOf(A,Uint8Array.prototype),Object.setPrototypeOf(t,A),t.foo()===42}catch{return!1}}Object.defineProperty(G.prototype,"parent",{enumerable:!0,get:function(){if(!!G.isBuffer(this))return this.buffer}});Object.defineProperty(G.prototype,"offset",{enumerable:!0,get:function(){if(!!G.isBuffer(this))return this.byteOffset}});function ee(t){if(t>lt)throw new RangeError('The value "'+t+'" is invalid for option "size"');var A=new Uint8Array(t);return Object.setPrototypeOf(A,G.prototype),A}function G(t,A,e){if(typeof t=="number"){if(typeof A=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Vt(t)}return li(t,A,e)}G.poolSize=8192;function li(t,A,e){if(typeof t=="string")return wB(t,A);if(ArrayBuffer.isView(t))return pB(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(PA(t,ArrayBuffer)||t&&PA(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(PA(t,SharedArrayBuffer)||t&&PA(t.buffer,SharedArrayBuffer)))return Kt(t,A,e);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var r=t.valueOf&&t.valueOf();if(r!=null&&r!==t)return G.from(r,A,e);var i=GB(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return G.from(t[Symbol.toPrimitive]("string"),A,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}G.from=function(t,A,e){return li(t,A,e)};Object.setPrototypeOf(G.prototype,Uint8Array.prototype);Object.setPrototypeOf(G,Uint8Array);function wi(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function lB(t,A,e){return wi(t),t<=0?ee(t):A!==void 0?typeof e=="string"?ee(t).fill(A,e):ee(t).fill(A):ee(t)}G.alloc=function(t,A,e){return lB(t,A,e)};function Vt(t){return wi(t),ee(t<0?0:Pt(t)|0)}G.allocUnsafe=function(t){return Vt(t)};G.allocUnsafeSlow=function(t){return Vt(t)};function wB(t,A){if((typeof A!="string"||A==="")&&(A="utf8"),!G.isEncoding(A))throw new TypeError("Unknown encoding: "+A);var e=pi(t,A)|0,r=ee(e),i=r.write(t,A);return i!==e&&(r=r.slice(0,i)),r}function Ot(t){for(var A=t.length<0?0:Pt(t.length)|0,e=ee(A),r=0;r<A;r+=1)e[r]=t[r]&255;return e}function pB(t){if(PA(t,Uint8Array)){var A=new Uint8Array(t);return Kt(A.buffer,A.byteOffset,A.byteLength)}return Ot(t)}function Kt(t,A,e){if(A<0||t.byteLength<A)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<A+(e||0))throw new RangeError('"length" is outside of buffer bounds');var r;return A===void 0&&e===void 0?r=new Uint8Array(t):e===void 0?r=new Uint8Array(t,A):r=new Uint8Array(t,A,e),Object.setPrototypeOf(r,G.prototype),r}function GB(t){if(G.isBuffer(t)){var A=Pt(t.length)|0,e=ee(A);return e.length===0||t.copy(e,0,0,A),e}if(t.length!==void 0)return typeof t.length!="number"||Wt(t.length)?ee(0):Ot(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Ot(t.data)}function Pt(t){if(t>=lt)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+lt.toString(16)+" bytes");return t|0}function dB(t){return+t!=t&&(t=0),G.alloc(+t)}G.isBuffer=function(A){return A!=null&&A._isBuffer===!0&&A!==G.prototype};G.compare=function(A,e){if(PA(A,Uint8Array)&&(A=G.from(A,A.offset,A.byteLength)),PA(e,Uint8Array)&&(e=G.from(e,e.offset,e.byteLength)),!G.isBuffer(A)||!G.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(A===e)return 0;for(var r=A.length,i=e.length,B=0,s=Math.min(r,i);B<s;++B)if(A[B]!==e[B]){r=A[B],i=e[B];break}return r<i?-1:i<r?1:0};G.isEncoding=function(A){switch(String(A).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};G.concat=function(A,e){if(!Array.isArray(A))throw new TypeError('"list" argument must be an Array of Buffers');if(A.length===0)return G.alloc(0);var r;if(e===void 0)for(e=0,r=0;r<A.length;++r)e+=A[r].length;var i=G.allocUnsafe(e),B=0;for(r=0;r<A.length;++r){var s=A[r];if(PA(s,Uint8Array))B+s.length>i.length?G.from(s).copy(i,B):Uint8Array.prototype.set.call(i,s,B);else if(G.isBuffer(s))s.copy(i,B);else throw new TypeError('"list" argument must be an Array of Buffers');B+=s.length}return i};function pi(t,A){if(G.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||PA(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var e=t.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&e===0)return 0;for(var i=!1;;)switch(A){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return jt(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return qi(t).length;default:if(i)return r?-1:jt(t).length;A=(""+A).toLowerCase(),i=!0}}G.byteLength=pi;function yB(t,A,e){var r=!1;if((A===void 0||A<0)&&(A=0),A>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,A>>>=0,e<=A))return"";for(t||(t="utf8");;)switch(t){case"hex":return UB(this,A,e);case"utf8":case"utf-8":return di(this,A,e);case"ascii":return NB(this,A,e);case"latin1":case"binary":return bB(this,A,e);case"base64":return SB(this,A,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return MB(this,A,e);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}G.prototype._isBuffer=!0;function Qe(t,A,e){var r=t[A];t[A]=t[e],t[e]=r}G.prototype.swap16=function(){var A=this.length;if(A%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<A;e+=2)Qe(this,e,e+1);return this};G.prototype.swap32=function(){var A=this.length;if(A%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<A;e+=4)Qe(this,e,e+3),Qe(this,e+1,e+2);return this};G.prototype.swap64=function(){var A=this.length;if(A%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<A;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};G.prototype.toString=function(){var A=this.length;return A===0?"":arguments.length===0?di(this,0,A):yB.apply(this,arguments)};G.prototype.toLocaleString=G.prototype.toString;G.prototype.equals=function(A){if(!G.isBuffer(A))throw new TypeError("Argument must be a Buffer");return this===A?!0:G.compare(this,A)===0};G.prototype.inspect=function(){var A="",e=xe.INSPECT_MAX_BYTES;return A=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(A+=" ... "),"<Buffer "+A+">"};ui&&(G.prototype[ui]=G.prototype.inspect);G.prototype.compare=function(A,e,r,i,B){if(PA(A,Uint8Array)&&(A=G.from(A,A.offset,A.byteLength)),!G.isBuffer(A))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof A);if(e===void 0&&(e=0),r===void 0&&(r=A?A.length:0),i===void 0&&(i=0),B===void 0&&(B=this.length),e<0||r>A.length||i<0||B>this.length)throw new RangeError("out of range index");if(i>=B&&e>=r)return 0;if(i>=B)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,i>>>=0,B>>>=0,this===A)return 0;for(var s=B-i,w=r-e,f=Math.min(s,w),y=this.slice(i,B),b=A.slice(e,r),x=0;x<f;++x)if(y[x]!==b[x]){s=y[x],w=b[x];break}return s<w?-1:w<s?1:0};function Gi(t,A,e,r,i){if(t.length===0)return-1;if(typeof e=="string"?(r=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Wt(e)&&(e=i?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(i)return-1;e=t.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof A=="string"&&(A=G.from(A,r)),G.isBuffer(A))return A.length===0?-1:Ci(t,A,e,r,i);if(typeof A=="number")return A=A&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,A,e):Uint8Array.prototype.lastIndexOf.call(t,A,e):Ci(t,[A],e,r,i);throw new TypeError("val must be string, number or Buffer")}function Ci(t,A,e,r,i){var B=1,s=t.length,w=A.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(t.length<2||A.length<2)return-1;B=2,s/=2,w/=2,e/=2}function f(F,H){return B===1?F[H]:F.readUInt16BE(H*B)}var y;if(i){var b=-1;for(y=e;y<s;y++)if(f(t,y)===f(A,b===-1?0:y-b)){if(b===-1&&(b=y),y-b+1===w)return b*B}else b!==-1&&(y-=y-b),b=-1}else for(e+w>s&&(e=s-w),y=e;y>=0;y--){for(var x=!0,R=0;R<w;R++)if(f(t,y+R)!==f(A,R)){x=!1;break}if(x)return y}return-1}G.prototype.includes=function(A,e,r){return this.indexOf(A,e,r)!==-1};G.prototype.indexOf=function(A,e,r){return Gi(this,A,e,r,!0)};G.prototype.lastIndexOf=function(A,e,r){return Gi(this,A,e,r,!1)};function kB(t,A,e,r){e=Number(e)||0;var i=t.length-e;r?(r=Number(r),r>i&&(r=i)):r=i;var B=A.length;r>B/2&&(r=B/2);for(var s=0;s<r;++s){var w=parseInt(A.substr(s*2,2),16);if(Wt(w))return s;t[e+s]=w}return s}function mB(t,A,e,r){return wt(jt(A,t.length-e),t,e,r)}function qB(t,A,e,r){return wt(RB(A),t,e,r)}function FB(t,A,e,r){return wt(qi(A),t,e,r)}function xB(t,A,e,r){return wt(JB(A,t.length-e),t,e,r)}G.prototype.write=function(A,e,r,i){if(e===void 0)i="utf8",r=this.length,e=0;else if(r===void 0&&typeof e=="string")i=e,r=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(r)?(r=r>>>0,i===void 0&&(i="utf8")):(i=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var B=this.length-e;if((r===void 0||r>B)&&(r=B),A.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return kB(this,A,e,r);case"utf8":case"utf-8":return mB(this,A,e,r);case"ascii":case"latin1":case"binary":return qB(this,A,e,r);case"base64":return FB(this,A,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xB(this,A,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};G.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function SB(t,A,e){return A===0&&e===t.length?Zt.fromByteArray(t):Zt.fromByteArray(t.slice(A,e))}function di(t,A,e){e=Math.min(t.length,e);for(var r=[],i=A;i<e;){var B=t[i],s=null,w=B>239?4:B>223?3:B>191?2:1;if(i+w<=e){var f,y,b,x;switch(w){case 1:B<128&&(s=B);break;case 2:f=t[i+1],(f&192)===128&&(x=(B&31)<<6|f&63,x>127&&(s=x));break;case 3:f=t[i+1],y=t[i+2],(f&192)===128&&(y&192)===128&&(x=(B&15)<<12|(f&63)<<6|y&63,x>2047&&(x<55296||x>57343)&&(s=x));break;case 4:f=t[i+1],y=t[i+2],b=t[i+3],(f&192)===128&&(y&192)===128&&(b&192)===128&&(x=(B&15)<<18|(f&63)<<12|(y&63)<<6|b&63,x>65535&&x<1114112&&(s=x))}}s===null?(s=65533,w=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),i+=w}return DB(r)}var fi=4096;function DB(t){var A=t.length;if(A<=fi)return String.fromCharCode.apply(String,t);for(var e="",r=0;r<A;)e+=String.fromCharCode.apply(String,t.slice(r,r+=fi));return e}function NB(t,A,e){var r="";e=Math.min(t.length,e);for(var i=A;i<e;++i)r+=String.fromCharCode(t[i]&127);return r}function bB(t,A,e){var r="";e=Math.min(t.length,e);for(var i=A;i<e;++i)r+=String.fromCharCode(t[i]);return r}function UB(t,A,e){var r=t.length;(!A||A<0)&&(A=0),(!e||e<0||e>r)&&(e=r);for(var i="",B=A;B<e;++B)i+=_B[t[B]];return i}function MB(t,A,e){for(var r=t.slice(A,e),i="",B=0;B<r.length-1;B+=2)i+=String.fromCharCode(r[B]+r[B+1]*256);return i}G.prototype.slice=function(A,e){var r=this.length;A=~~A,e=e===void 0?r:~~e,A<0?(A+=r,A<0&&(A=0)):A>r&&(A=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),e<A&&(e=A);var i=this.subarray(A,e);return Object.setPrototypeOf(i,G.prototype),i};function wA(t,A,e){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+A>e)throw new RangeError("Trying to access beyond buffer length")}G.prototype.readUintLE=G.prototype.readUIntLE=function(A,e,r){A=A>>>0,e=e>>>0,r||wA(A,e,this.length);for(var i=this[A],B=1,s=0;++s<e&&(B*=256);)i+=this[A+s]*B;return i};G.prototype.readUintBE=G.prototype.readUIntBE=function(A,e,r){A=A>>>0,e=e>>>0,r||wA(A,e,this.length);for(var i=this[A+--e],B=1;e>0&&(B*=256);)i+=this[A+--e]*B;return i};G.prototype.readUint8=G.prototype.readUInt8=function(A,e){return A=A>>>0,e||wA(A,1,this.length),this[A]};G.prototype.readUint16LE=G.prototype.readUInt16LE=function(A,e){return A=A>>>0,e||wA(A,2,this.length),this[A]|this[A+1]<<8};G.prototype.readUint16BE=G.prototype.readUInt16BE=function(A,e){return A=A>>>0,e||wA(A,2,this.length),this[A]<<8|this[A+1]};G.prototype.readUint32LE=G.prototype.readUInt32LE=function(A,e){return A=A>>>0,e||wA(A,4,this.length),(this[A]|this[A+1]<<8|this[A+2]<<16)+this[A+3]*16777216};G.prototype.readUint32BE=G.prototype.readUInt32BE=function(A,e){return A=A>>>0,e||wA(A,4,this.length),this[A]*16777216+(this[A+1]<<16|this[A+2]<<8|this[A+3])};G.prototype.readIntLE=function(A,e,r){A=A>>>0,e=e>>>0,r||wA(A,e,this.length);for(var i=this[A],B=1,s=0;++s<e&&(B*=256);)i+=this[A+s]*B;return B*=128,i>=B&&(i-=Math.pow(2,8*e)),i};G.prototype.readIntBE=function(A,e,r){A=A>>>0,e=e>>>0,r||wA(A,e,this.length);for(var i=e,B=1,s=this[A+--i];i>0&&(B*=256);)s+=this[A+--i]*B;return B*=128,s>=B&&(s-=Math.pow(2,8*e)),s};G.prototype.readInt8=function(A,e){return A=A>>>0,e||wA(A,1,this.length),this[A]&128?(255-this[A]+1)*-1:this[A]};G.prototype.readInt16LE=function(A,e){A=A>>>0,e||wA(A,2,this.length);var r=this[A]|this[A+1]<<8;return r&32768?r|4294901760:r};G.prototype.readInt16BE=function(A,e){A=A>>>0,e||wA(A,2,this.length);var r=this[A+1]|this[A]<<8;return r&32768?r|4294901760:r};G.prototype.readInt32LE=function(A,e){return A=A>>>0,e||wA(A,4,this.length),this[A]|this[A+1]<<8|this[A+2]<<16|this[A+3]<<24};G.prototype.readInt32BE=function(A,e){return A=A>>>0,e||wA(A,4,this.length),this[A]<<24|this[A+1]<<16|this[A+2]<<8|this[A+3]};G.prototype.readFloatLE=function(A,e){return A=A>>>0,e||wA(A,4,this.length),Fe.read(this,A,!0,23,4)};G.prototype.readFloatBE=function(A,e){return A=A>>>0,e||wA(A,4,this.length),Fe.read(this,A,!1,23,4)};G.prototype.readDoubleLE=function(A,e){return A=A>>>0,e||wA(A,8,this.length),Fe.read(this,A,!0,52,8)};G.prototype.readDoubleBE=function(A,e){return A=A>>>0,e||wA(A,8,this.length),Fe.read(this,A,!1,52,8)};function FA(t,A,e,r,i,B){if(!G.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(A>i||A<B)throw new RangeError('"value" argument is out of bounds');if(e+r>t.length)throw new RangeError("Index out of range")}G.prototype.writeUintLE=G.prototype.writeUIntLE=function(A,e,r,i){if(A=+A,e=e>>>0,r=r>>>0,!i){var B=Math.pow(2,8*r)-1;FA(this,A,e,r,B,0)}var s=1,w=0;for(this[e]=A&255;++w<r&&(s*=256);)this[e+w]=A/s&255;return e+r};G.prototype.writeUintBE=G.prototype.writeUIntBE=function(A,e,r,i){if(A=+A,e=e>>>0,r=r>>>0,!i){var B=Math.pow(2,8*r)-1;FA(this,A,e,r,B,0)}var s=r-1,w=1;for(this[e+s]=A&255;--s>=0&&(w*=256);)this[e+s]=A/w&255;return e+r};G.prototype.writeUint8=G.prototype.writeUInt8=function(A,e,r){return A=+A,e=e>>>0,r||FA(this,A,e,1,255,0),this[e]=A&255,e+1};G.prototype.writeUint16LE=G.prototype.writeUInt16LE=function(A,e,r){return A=+A,e=e>>>0,r||FA(this,A,e,2,65535,0),this[e]=A&255,this[e+1]=A>>>8,e+2};G.prototype.writeUint16BE=G.prototype.writeUInt16BE=function(A,e,r){return A=+A,e=e>>>0,r||FA(this,A,e,2,65535,0),this[e]=A>>>8,this[e+1]=A&255,e+2};G.prototype.writeUint32LE=G.prototype.writeUInt32LE=function(A,e,r){return A=+A,e=e>>>0,r||FA(this,A,e,4,4294967295,0),this[e+3]=A>>>24,this[e+2]=A>>>16,this[e+1]=A>>>8,this[e]=A&255,e+4};G.prototype.writeUint32BE=G.prototype.writeUInt32BE=function(A,e,r){return A=+A,e=e>>>0,r||FA(this,A,e,4,4294967295,0),this[e]=A>>>24,this[e+1]=A>>>16,this[e+2]=A>>>8,this[e+3]=A&255,e+4};G.prototype.writeIntLE=function(A,e,r,i){if(A=+A,e=e>>>0,!i){var B=Math.pow(2,8*r-1);FA(this,A,e,r,B-1,-B)}var s=0,w=1,f=0;for(this[e]=A&255;++s<r&&(w*=256);)A<0&&f===0&&this[e+s-1]!==0&&(f=1),this[e+s]=(A/w>>0)-f&255;return e+r};G.prototype.writeIntBE=function(A,e,r,i){if(A=+A,e=e>>>0,!i){var B=Math.pow(2,8*r-1);FA(this,A,e,r,B-1,-B)}var s=r-1,w=1,f=0;for(this[e+s]=A&255;--s>=0&&(w*=256);)A<0&&f===0&&this[e+s+1]!==0&&(f=1),this[e+s]=(A/w>>0)-f&255;return e+r};G.prototype.writeInt8=function(A,e,r){return A=+A,e=e>>>0,r||FA(this,A,e,1,127,-128),A<0&&(A=255+A+1),this[e]=A&255,e+1};G.prototype.writeInt16LE=function(A,e,r){return A=+A,e=e>>>0,r||FA(this,A,e,2,32767,-32768),this[e]=A&255,this[e+1]=A>>>8,e+2};G.prototype.writeInt16BE=function(A,e,r){return A=+A,e=e>>>0,r||FA(this,A,e,2,32767,-32768),this[e]=A>>>8,this[e+1]=A&255,e+2};G.prototype.writeInt32LE=function(A,e,r){return A=+A,e=e>>>0,r||FA(this,A,e,4,2147483647,-2147483648),this[e]=A&255,this[e+1]=A>>>8,this[e+2]=A>>>16,this[e+3]=A>>>24,e+4};G.prototype.writeInt32BE=function(A,e,r){return A=+A,e=e>>>0,r||FA(this,A,e,4,2147483647,-2147483648),A<0&&(A=4294967295+A+1),this[e]=A>>>24,this[e+1]=A>>>16,this[e+2]=A>>>8,this[e+3]=A&255,e+4};function yi(t,A,e,r,i,B){if(e+r>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function ki(t,A,e,r,i){return A=+A,e=e>>>0,i||yi(t,A,e,4,34028234663852886e22,-34028234663852886e22),Fe.write(t,A,e,r,23,4),e+4}G.prototype.writeFloatLE=function(A,e,r){return ki(this,A,e,!0,r)};G.prototype.writeFloatBE=function(A,e,r){return ki(this,A,e,!1,r)};function mi(t,A,e,r,i){return A=+A,e=e>>>0,i||yi(t,A,e,8,17976931348623157e292,-17976931348623157e292),Fe.write(t,A,e,r,52,8),e+8}G.prototype.writeDoubleLE=function(A,e,r){return mi(this,A,e,!0,r)};G.prototype.writeDoubleBE=function(A,e,r){return mi(this,A,e,!1,r)};G.prototype.copy=function(A,e,r,i){if(!G.isBuffer(A))throw new TypeError("argument should be a Buffer");if(r||(r=0),!i&&i!==0&&(i=this.length),e>=A.length&&(e=A.length),e||(e=0),i>0&&i<r&&(i=r),i===r||A.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=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),A.length-e<i-r&&(i=A.length-e+r);var B=i-r;return this===A&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,r,i):Uint8Array.prototype.set.call(A,this.subarray(r,i),e),B};G.prototype.fill=function(A,e,r,i){if(typeof A=="string"){if(typeof e=="string"?(i=e,e=0,r=this.length):typeof r=="string"&&(i=r,r=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!G.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(A.length===1){var B=A.charCodeAt(0);(i==="utf8"&&B<128||i==="latin1")&&(A=B)}}else typeof A=="number"?A=A&255:typeof A=="boolean"&&(A=Number(A));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;e=e>>>0,r=r===void 0?this.length:r>>>0,A||(A=0);var s;if(typeof A=="number")for(s=e;s<r;++s)this[s]=A;else{var w=G.isBuffer(A)?A:G.from(A,i),f=w.length;if(f===0)throw new TypeError('The value "'+A+'" is invalid for argument "value"');for(s=0;s<r-e;++s)this[s+e]=w[s%f]}return this};var HB=/[^+/0-9A-Za-z-_]/g;function YB(t){if(t=t.split("=")[0],t=t.trim().replace(HB,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function jt(t,A){A=A||1/0;for(var e,r=t.length,i=null,B=[],s=0;s<r;++s){if(e=t.charCodeAt(s),e>55295&&e<57344){if(!i){if(e>56319){(A-=3)>-1&&B.push(239,191,189);continue}else if(s+1===r){(A-=3)>-1&&B.push(239,191,189);continue}i=e;continue}if(e<56320){(A-=3)>-1&&B.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(A-=3)>-1&&B.push(239,191,189);if(i=null,e<128){if((A-=1)<0)break;B.push(e)}else if(e<2048){if((A-=2)<0)break;B.push(e>>6|192,e&63|128)}else if(e<65536){if((A-=3)<0)break;B.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((A-=4)<0)break;B.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return B}function RB(t){for(var A=[],e=0;e<t.length;++e)A.push(t.charCodeAt(e)&255);return A}function JB(t,A){for(var e,r,i,B=[],s=0;s<t.length&&!((A-=2)<0);++s)e=t.charCodeAt(s),r=e>>8,i=e%256,B.push(i),B.push(r);return B}function qi(t){return Zt.toByteArray(YB(t))}function wt(t,A,e,r){for(var i=0;i<r&&!(i+e>=A.length||i>=t.length);++i)A[i+e]=t[i];return i}function PA(t,A){return t instanceof A||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===A.name}function Wt(t){return t!==t}var _B=function(){for(var t="0123456789abcdef",A=new Array(256),e=0;e<16;++e)for(var r=e*16,i=0;i<16;++i)A[r+i]=t[e]+t[i];return A}()});var Pe=lA((Fi,pt)=>{(function(t){"use strict";var A,e=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,r=Math.ceil,i=Math.floor,B="[BigNumber Error] ",s=B+"Number primitive has more than 15 significant digits: ",w=1e14,f=14,y=9007199254740991,b=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],x=1e7,R=1e9;function F(U){var S,v,K,q=k.prototype={constructor:k,toString:null,valueOf:null},eA=new k(1),z=20,tA=4,EA=-7,dA=21,bA=-1e7,xA=1e7,vA=!1,pA=1,ZA=0,_e={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},ie="0123456789abcdefghijklmnopqrstuvwxyz",Te=!0;function k(n,o){var a,C,Q,h,p,I,c,l,u=this;if(!(u instanceof k))return new k(n,o);if(o==null){if(n&&n._isBigNumber===!0){u.s=n.s,!n.c||n.e>xA?u.c=u.e=null:n.e<bA?u.c=[u.e=0]:(u.e=n.e,u.c=n.c.slice());return}if((I=typeof n=="number")&&n*0==0){if(u.s=1/n<0?(n=-n,-1):1,n===~~n){for(h=0,p=n;p>=10;p/=10,h++);h>xA?u.c=u.e=null:(u.e=h,u.c=[n]);return}l=String(n)}else{if(!e.test(l=String(n)))return K(u,l,I);u.s=l.charCodeAt(0)==45?(l=l.slice(1),-1):1}(h=l.indexOf("."))>-1&&(l=l.replace(".","")),(p=l.search(/e/i))>0?(h<0&&(h=p),h+=+l.slice(p+1),l=l.substring(0,p)):h<0&&(h=l.length)}else{if(Y(o,2,ie.length,"Base"),o==10&&Te)return u=new k(n),kA(u,z+u.e+1,tA);if(l=String(n),I=typeof n=="number"){if(n*0!=0)return K(u,l,I,o);if(u.s=1/n<0?(l=l.slice(1),-1):1,k.DEBUG&&l.replace(/^0\.0*|\./,"").length>15)throw Error(s+n)}else u.s=l.charCodeAt(0)===45?(l=l.slice(1),-1):1;for(a=ie.slice(0,o),h=p=0,c=l.length;p<c;p++)if(a.indexOf(C=l.charAt(p))<0){if(C=="."){if(p>h){h=c;continue}}else if(!Q&&(l==l.toUpperCase()&&(l=l.toLowerCase())||l==l.toLowerCase()&&(l=l.toUpperCase()))){Q=!0,p=-1,h=0;continue}return K(u,String(n),I,o)}I=!1,l=v(l,o,10,u.s),(h=l.indexOf("."))>-1?l=l.replace(".",""):h=l.length}for(p=0;l.charCodeAt(p)===48;p++);for(c=l.length;l.charCodeAt(--c)===48;);if(l=l.slice(p,++c)){if(c-=p,I&&k.DEBUG&&c>15&&(n>y||n!==i(n)))throw Error(s+u.s*n);if((h=h-p-1)>xA)u.c=u.e=null;else if(h<bA)u.c=[u.e=0];else{if(u.e=h,u.c=[],p=(h+1)%f,h<0&&(p+=f),p<c){for(p&&u.c.push(+l.slice(0,p)),c-=f;p<c;)u.c.push(+l.slice(p,p+=f));p=f-(l=l.slice(p)).length}else p-=c;for(;p--;l+="0");u.c.push(+l)}}else u.c=[u.e=0]}k.clone=F,k.ROUND_UP=0,k.ROUND_DOWN=1,k.ROUND_CEIL=2,k.ROUND_FLOOR=3,k.ROUND_HALF_UP=4,k.ROUND_HALF_DOWN=5,k.ROUND_HALF_EVEN=6,k.ROUND_HALF_CEIL=7,k.ROUND_HALF_FLOOR=8,k.EUCLID=9,k.config=k.set=function(n){var o,a;if(n!=null)if(typeof n=="object"){if(n.hasOwnProperty(o="DECIMAL_PLACES")&&(a=n[o],Y(a,0,R,o),z=a),n.hasOwnProperty(o="ROUNDING_MODE")&&(a=n[o],Y(a,0,8,o),tA=a),n.hasOwnProperty(o="EXPONENTIAL_AT")&&(a=n[o],a&&a.pop?(Y(a[0],-R,0,o),Y(a[1],0,R,o),EA=a[0],dA=a[1]):(Y(a,-R,R,o),EA=-(dA=a<0?-a:a))),n.hasOwnProperty(o="RANGE"))if(a=n[o],a&&a.pop)Y(a[0],-R,-1,o),Y(a[1],1,R,o),bA=a[0],xA=a[1];else if(Y(a,-R,R,o),a)bA=-(xA=a<0?-a:a);else throw Error(B+o+" cannot be zero: "+a);if(n.hasOwnProperty(o="CRYPTO"))if(a=n[o],a===!!a)if(a)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))vA=a;else throw vA=!a,Error(B+"crypto unavailable");else vA=a;else throw Error(B+o+" not true or false: "+a);if(n.hasOwnProperty(o="MODULO_MODE")&&(a=n[o],Y(a,0,9,o),pA=a),n.hasOwnProperty(o="POW_PRECISION")&&(a=n[o],Y(a,0,R,o),ZA=a),n.hasOwnProperty(o="FORMAT"))if(a=n[o],typeof a=="object")_e=a;else throw Error(B+o+" not an object: "+a);if(n.hasOwnProperty(o="ALPHABET"))if(a=n[o],typeof a=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(a))Te=a.slice(0,10)=="0123456789",ie=a;else throw Error(B+o+" invalid: "+a)}else throw Error(B+"Object expected: "+n);return{DECIMAL_PLACES:z,ROUNDING_MODE:tA,EXPONENTIAL_AT:[EA,dA],RANGE:[bA,xA],CRYPTO:vA,MODULO_MODE:pA,POW_PRECISION:ZA,FORMAT:_e,ALPHABET:ie}},k.isBigNumber=function(n){if(!n||n._isBigNumber!==!0)return!1;if(!k.DEBUG)return!0;var o,a,C=n.c,Q=n.e,h=n.s;A:if({}.toString.call(C)=="[object Array]"){if((h===1||h===-1)&&Q>=-R&&Q<=R&&Q===i(Q)){if(C[0]===0){if(Q===0&&C.length===1)return!0;break A}if(o=(Q+1)%f,o<1&&(o+=f),String(C[0]).length==o){for(o=0;o<C.length;o++)if(a=C[o],a<0||a>=w||a!==i(a))break A;if(a!==0)return!0}}}else if(C===null&&Q===null&&(h===null||h===1||h===-1))return!0;throw Error(B+"Invalid BigNumber: "+n)},k.maximum=k.max=function(){return le(arguments,q.lt)},k.minimum=k.min=function(){return le(arguments,q.gt)},k.random=function(){var n=9007199254740992,o=Math.random()*n&2097151?function(){return i(Math.random()*n)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(a){var C,Q,h,p,I,c=0,l=[],u=new k(eA);if(a==null?a=z:Y(a,0,R),p=r(a/f),vA)if(crypto.getRandomValues){for(C=crypto.getRandomValues(new Uint32Array(p*=2));c<p;)I=C[c]*131072+(C[c+1]>>>11),I>=9e15?(Q=crypto.getRandomValues(new Uint32Array(2)),C[c]=Q[0],C[c+1]=Q[1]):(l.push(I%1e14),c+=2);c=p/2}else if(crypto.randomBytes){for(C=crypto.randomBytes(p*=7);c<p;)I=(C[c]&31)*281474976710656+C[c+1]*1099511627776+C[c+2]*4294967296+C[c+3]*16777216+(C[c+4]<<16)+(C[c+5]<<8)+C[c+6],I>=9e15?crypto.randomBytes(7).copy(C,c):(l.push(I%1e14),c+=7);c=p/7}else throw vA=!1,Error(B+"crypto unavailable");if(!vA)for(;c<p;)I=o(),I<9e15&&(l[c++]=I%1e14);for(p=l[--c],a%=f,p&&a&&(I=b[f-a],l[c]=i(p/I)*I);l[c]===0;l.pop(),c--);if(c<0)l=[h=0];else{for(h=-1;l[0]===0;l.splice(0,1),h-=f);for(c=1,I=l[0];I>=10;I/=10,c++);c<f&&(h-=f-c)}return u.e=h,u.c=l,u}}(),k.sum=function(){for(var n=1,o=arguments,a=new k(o[0]);n<o.length;)a=a.plus(o[n++]);return a},v=function(){var n="0123456789";function o(a,C,Q,h){for(var p,I=[0],c,l=0,u=a.length;l<u;){for(c=I.length;c--;I[c]*=C);for(I[0]+=h.indexOf(a.charAt(l++)),p=0;p<I.length;p++)I[p]>Q-1&&(I[p+1]==null&&(I[p+1]=0),I[p+1]+=I[p]/Q|0,I[p]%=Q)}return I.reverse()}return function(a,C,Q,h,p){var I,c,l,u,d,m,D,Z,rA=a.indexOf("."),aA=z,T=tA;for(rA>=0&&(u=ZA,ZA=0,a=a.replace(".",""),Z=new k(C),m=Z.pow(a.length-rA),ZA=u,Z.c=o(oA(P(m.c),m.e,"0"),10,Q,n),Z.e=Z.c.length),D=o(a,C,Q,p?(I=ie,n):(I=n,ie)),l=u=D.length;D[--u]==0;D.pop());if(!D[0])return I.charAt(0);if(rA<0?--l:(m.c=D,m.e=l,m.s=h,m=S(m,Z,aA,T,Q),D=m.c,d=m.r,l=m.e),c=l+aA+1,rA=D[c],u=Q/2,d=d||c<0||D[c+1]!=null,d=T<4?(rA!=null||d)&&(T==0||T==(m.s<0?3:2)):rA>u||rA==u&&(T==4||d||T==6&&D[c-1]&1||T==(m.s<0?8:7)),c<1||!D[0])a=d?oA(I.charAt(1),-aA,I.charAt(0)):I.charAt(0);else{if(D.length=c,d)for(--Q;++D[--c]>Q;)D[c]=0,c||(++l,D=[1].concat(D));for(u=D.length;!D[--u];);for(rA=0,a="";rA<=u;a+=I.charAt(D[rA++]));a=oA(a,l,I.charAt(0))}return a}}(),S=function(){function n(C,Q,h){var p,I,c,l,u=0,d=C.length,m=Q%x,D=Q/x|0;for(C=C.slice();d--;)c=C[d]%x,l=C[d]/x|0,p=D*c+l*m,I=m*c+p%x*x+u,u=(I/h|0)+(p/x|0)+D*l,C[d]=I%h;return u&&(C=[u].concat(C)),C}function o(C,Q,h,p){var I,c;if(h!=p)c=h>p?1:-1;else for(I=c=0;I<h;I++)if(C[I]!=Q[I]){c=C[I]>Q[I]?1:-1;break}return c}function a(C,Q,h,p){for(var I=0;h--;)C[h]-=I,I=C[h]<Q[h]?1:0,C[h]=I*p+C[h]-Q[h];for(;!C[0]&&C.length>1;C.splice(0,1));}return function(C,Q,h,p,I){var c,l,u,d,m,D,Z,rA,aA,T,N,CA,we,Le,ve,UA,j,mA=C.s==Q.s?1:-1,GA=C.c,iA=Q.c;if(!GA||!GA[0]||!iA||!iA[0])return new k(!C.s||!Q.s||(GA?iA&&GA[0]==iA[0]:!iA)?NaN:GA&&GA[0]==0||!iA?mA*0:mA/0);for(rA=new k(mA),aA=rA.c=[],l=C.e-Q.e,mA=h+l+1,I||(I=w,l=H(C.e/f)-H(Q.e/f),mA=mA/f|0),u=0;iA[u]==(GA[u]||0);u++);if(iA[u]>(GA[u]||0)&&l--,mA<0)aA.push(1),d=!0;else{for(Le=GA.length,UA=iA.length,u=0,mA+=2,m=i(I/(iA[0]+1)),m>1&&(iA=n(iA,m,I),GA=n(GA,m,I),UA=iA.length,Le=GA.length),we=UA,T=GA.slice(0,UA),N=T.length;N<UA;T[N++]=0);j=iA.slice(),j=[0].concat(j),ve=iA[0],iA[1]>=I/2&&ve++;do{if(m=0,c=o(iA,T,UA,N),c<0){if(CA=T[0],UA!=N&&(CA=CA*I+(T[1]||0)),m=i(CA/ve),m>1)for(m>=I&&(m=I-1),D=n(iA,m,I),Z=D.length,N=T.length;o(D,T,Z,N)==1;)m--,a(D,UA<Z?j:iA,Z,I),Z=D.length,c=1;else m==0&&(c=m=1),D=iA.slice(),Z=D.length;if(Z<N&&(D=[0].concat(D)),a(T,D,N,I),N=T.length,c==-1)for(;o(iA,T,UA,N)<1;)m++,a(T,UA<N?j:iA,N,I),N=T.length}else c===0&&(m++,T=[0]);aA[u++]=m,T[0]?T[N++]=GA[we]||0:(T=[GA[we]],N=1)}while((we++<Le||T[0]!=null)&&mA--);d=T[0]!=null,aA[0]||aA.splice(0,1)}if(I==w){for(u=1,mA=aA[0];mA>=10;mA/=10,u++);kA(rA,h+(rA.e=u+l*f-1)+1,p,d)}else rA.e=l,rA.r=+d;return rA}}();function E(n,o,a,C){var Q,h,p,I,c;if(a==null?a=tA:Y(a,0,8),!n.c)return n.toString();if(Q=n.c[0],p=n.e,o==null)c=P(n.c),c=C==1||C==2&&(p<=EA||p>=dA)?uA(c,p):oA(c,p,"0");else if(n=kA(new k(n),o,a),h=n.e,c=P(n.c),I=c.length,C==1||C==2&&(o<=h||h<=EA)){for(;I<o;c+="0",I++);c=uA(c,h)}else if(o-=p,c=oA(c,h,"0"),h+1>I){if(--o>0)for(c+=".";o--;c+="0");}else if(o+=h-I,o>0)for(h+1==I&&(c+=".");o--;c+="0");return n.s<0&&Q?"-"+c:c}function le(n,o){for(var a,C=1,Q=new k(n[0]);C<n.length;C++)if(a=new k(n[C]),a.s)o.call(Q,a)&&(Q=a);else{Q=a;break}return Q}function Ie(n,o,a){for(var C=1,Q=o.length;!o[--Q];o.pop());for(Q=o[0];Q>=10;Q/=10,C++);return(a=C+a*f-1)>xA?n.c=n.e=null:a<bA?n.c=[n.e=0]:(n.e=a,n.c=o),n}K=function(){var n=/^(-?)0([xbo])(?=\w[\w.]*$)/i,o=/^([^.]+)\.$/,a=/^\.([^.]+)$/,C=/^-?(Infinity|NaN)$/,Q=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(h,p,I,c){var l,u=I?p:p.replace(Q,"");if(C.test(u))h.s=isNaN(u)?null:u<0?-1:1;else{if(!I&&(u=u.replace(n,function(d,m,D){return l=(D=D.toLowerCase())=="x"?16:D=="b"?2:8,!c||c==l?m:d}),c&&(l=c,u=u.replace(o,"$1").replace(a,"0.$1")),p!=u))return new k(u,l);if(k.DEBUG)throw Error(B+"Not a"+(c?" base "+c:"")+" number: "+p);h.s=null}h.c=h.e=null}}();function kA(n,o,a,C){var Q,h,p,I,c,l,u,d=n.c,m=b;if(d){A:{for(Q=1,I=d[0];I>=10;I/=10,Q++);if(h=o-Q,h<0)h+=f,p=o,c=d[l=0],u=c/m[Q-p-1]%10|0;else if(l=r((h+1)/f),l>=d.length)if(C){for(;d.length<=l;d.push(0));c=u=0,Q=1,h%=f,p=h-f+1}else break A;else{for(c=I=d[l],Q=1;I>=10;I/=10,Q++);h%=f,p=h-f+Q,u=p<0?0:c/m[Q-p-1]%10|0}if(C=C||o<0||d[l+1]!=null||(p<0?c:c%m[Q-p-1]),C=a<4?(u||C)&&(a==0||a==(n.s<0?3:2)):u>5||u==5&&(a==4||C||a==6&&(h>0?p>0?c/m[Q-p]:0:d[l-1])%10&1||a==(n.s<0?8:7)),o<1||!d[0])return d.length=0,C?(o-=n.e+1,d[0]=m[(f-o%f)%f],n.e=-o||0):d[0]=n.e=0,n;if(h==0?(d.length=l,I=1,l--):(d.length=l+1,I=m[f-h],d[l]=p>0?i(c/m[Q-p]%m[p])*I:0),C)for(;;)if(l==0){for(h=1,p=d[0];p>=10;p/=10,h++);for(p=d[0]+=I,I=1;p>=10;p/=10,I++);h!=I&&(n.e++,d[0]==w&&(d[0]=1));break}else{if(d[l]+=I,d[l]!=w)break;d[l--]=0,I=1}for(h=d.length;d[--h]===0;d.pop());}n.e>xA?n.c=n.e=null:n.e<bA&&(n.c=[n.e=0])}return n}function M(n){var o,a=n.e;return a===null?n.toString():(o=P(n.c),o=a<=EA||a>=dA?uA(o,a):oA(o,a,"0"),n.s<0?"-"+o:o)}return q.absoluteValue=q.abs=function(){var n=new k(this);return n.s<0&&(n.s=1),n},q.comparedTo=function(n,o){return BA(this,new k(n,o))},q.decimalPlaces=q.dp=function(n,o){var a,C,Q,h=this;if(n!=null)return Y(n,0,R),o==null?o=tA:Y(o,0,8),kA(new k(h),n+h.e+1,o);if(!(a=h.c))return null;if(C=((Q=a.length-1)-H(this.e/f))*f,Q=a[Q])for(;Q%10==0;Q/=10,C--);return C<0&&(C=0),C},q.dividedBy=q.div=function(n,o){return S(this,new k(n,o),z,tA)},q.dividedToIntegerBy=q.idiv=function(n,o){return S(this,new k(n,o),0,1)},q.exponentiatedBy=q.pow=function(n,o){var a,C,Q,h,p,I,c,l,u,d=this;if(n=new k(n),n.c&&!n.isInteger())throw Error(B+"Exponent not an integer: "+M(n));if(o!=null&&(o=new k(o)),I=n.e>14,!d.c||!d.c[0]||d.c[0]==1&&!d.e&&d.c.length==1||!n.c||!n.c[0])return u=new k(Math.pow(+M(d),I?2-sA(n):+M(n))),o?u.mod(o):u;if(c=n.s<0,o){if(o.c?!o.c[0]:!o.s)return new k(NaN);C=!c&&d.isInteger()&&o.isInteger(),C&&(d=d.mod(o))}else{if(n.e>9&&(d.e>0||d.e<-1||(d.e==0?d.c[0]>1||I&&d.c[1]>=24e7:d.c[0]<8e13||I&&d.c[0]<=9999975e7)))return h=d.s<0&&sA(n)?-0:0,d.e>-1&&(h=1/h),new k(c?1/h:h);ZA&&(h=r(ZA/f+2))}for(I?(a=new k(.5),c&&(n.s=1),l=sA(n)):(Q=Math.abs(+M(n)),l=Q%2),u=new k(eA);;){if(l){if(u=u.times(d),!u.c)break;h?u.c.length>h&&(u.c.length=h):C&&(u=u.mod(o))}if(Q){if(Q=i(Q/2),Q===0)break;l=Q%2}else if(n=n.times(a),kA(n,n.e+1,1),n.e>14)l=sA(n);else{if(Q=+M(n),Q===0)break;l=Q%2}d=d.times(d),h?d.c&&d.c.length>h&&(d.c.length=h):C&&(d=d.mod(o))}return C?u:(c&&(u=eA.div(u)),o?u.mod(o):h?kA(u,ZA,tA,p):u)},q.integerValue=function(n){var o=new k(this);return n==null?n=tA:Y(n,0,8),kA(o,o.e+1,n)},q.isEqualTo=q.eq=function(n,o){return BA(this,new k(n,o))===0},q.isFinite=function(){return!!this.c},q.isGreaterThan=q.gt=function(n,o){return BA(this,new k(n,o))>0},q.isGreaterThanOrEqualTo=q.gte=function(n,o){return(o=BA(this,new k(n,o)))===1||o===0},q.isInteger=function(){return!!this.c&&H(this.e/f)>this.c.length-2},q.isLessThan=q.lt=function(n,o){return BA(this,new k(n,o))<0},q.isLessThanOrEqualTo=q.lte=function(n,o){return(o=BA(this,new k(n,o)))===-1||o===0},q.isNaN=function(){return!this.s},q.isNegative=function(){return this.s<0},q.isPositive=function(){return this.s>0},q.isZero=function(){return!!this.c&&this.c[0]==0},q.minus=function(n,o){var a,C,Q,h,p=this,I=p.s;if(n=new k(n,o),o=n.s,!I||!o)return new k(NaN);if(I!=o)return n.s=-o,p.plus(n);var c=p.e/f,l=n.e/f,u=p.c,d=n.c;if(!c||!l){if(!u||!d)return u?(n.s=-o,n):new k(d?p:NaN);if(!u[0]||!d[0])return d[0]?(n.s=-o,n):new k(u[0]?p:tA==3?-0:0)}if(c=H(c),l=H(l),u=u.slice(),I=c-l){for((h=I<0)?(I=-I,Q=u):(l=c,Q=d),Q.reverse(),o=I;o--;Q.push(0));Q.reverse()}else for(C=(h=(I=u.length)<(o=d.length))?I:o,I=o=0;o<C;o++)if(u[o]!=d[o]){h=u[o]<d[o];break}if(h&&(Q=u,u=d,d=Q,n.s=-n.s),o=(C=d.length)-(a=u.length),o>0)for(;o--;u[a++]=0);for(o=w-1;C>I;){if(u[--C]<d[C]){for(a=C;a&&!u[--a];u[a]=o);--u[a],u[C]+=w}u[C]-=d[C]}for(;u[0]==0;u.splice(0,1),--l);return u[0]?Ie(n,u,l):(n.s=tA==3?-1:1,n.c=[n.e=0],n)},q.modulo=q.mod=function(n,o){var a,C,Q=this;return n=new k(n,o),!Q.c||!n.s||n.c&&!n.c[0]?new k(NaN):!n.c||Q.c&&!Q.c[0]?new k(Q):(pA==9?(C=n.s,n.s=1,a=S(Q,n,0,3),n.s=C,a.s*=C):a=S(Q,n,0,pA),n=Q.minus(a.times(n)),!n.c[0]&&pA==1&&(n.s=Q.s),n)},q.multipliedBy=q.times=function(n,o){var a,C,Q,h,p,I,c,l,u,d,m,D,Z,rA,aA,T=this,N=T.c,CA=(n=new k(n,o)).c;if(!N||!CA||!N[0]||!CA[0])return!T.s||!n.s||N&&!N[0]&&!CA||CA&&!CA[0]&&!N?n.c=n.e=n.s=null:(n.s*=T.s,!N||!CA?n.c=n.e=null:(n.c=[0],n.e=0)),n;for(C=H(T.e/f)+H(n.e/f),n.s*=T.s,c=N.length,d=CA.length,c<d&&(Z=N,N=CA,CA=Z,Q=c,c=d,d=Q),Q=c+d,Z=[];Q--;Z.push(0));for(rA=w,aA=x,Q=d;--Q>=0;){for(a=0,m=CA[Q]%aA,D=CA[Q]/aA|0,p=c,h=Q+p;h>Q;)l=N[--p]%aA,u=N[p]/aA|0,I=D*l+u*m,l=m*l+I%aA*aA+Z[h]+a,a=(l/rA|0)+(I/aA|0)+D*u,Z[h--]=l%rA;Z[h]=a}return a?++C:Z.splice(0,1),Ie(n,Z,C)},q.negated=function(){var n=new k(this);return n.s=-n.s||null,n},q.plus=function(n,o){var a,C=this,Q=C.s;if(n=new k(n,o),o=n.s,!Q||!o)return new k(NaN);if(Q!=o)return n.s=-o,C.minus(n);var h=C.e/f,p=n.e/f,I=C.c,c=n.c;if(!h||!p){if(!I||!c)return new k(Q/0);if(!I[0]||!c[0])return c[0]?n:new k(I[0]?C:Q*0)}if(h=H(h),p=H(p),I=I.slice(),Q=h-p){for(Q>0?(p=h,a=c):(Q=-Q,a=I),a.reverse();Q--;a.push(0));a.reverse()}for(Q=I.length,o=c.length,Q-o<0&&(a=c,c=I,I=a,o=Q),Q=0;o;)Q=(I[--o]=I[o]+c[o]+Q)/w|0,I[o]=w===I[o]?0:I[o]%w;return Q&&(I=[Q].concat(I),++p),Ie(n,I,p)},q.precision=q.sd=function(n,o){var a,C,Q,h=this;if(n!=null&&n!==!!n)return Y(n,1,R),o==null?o=tA:Y(o,0,8),kA(new k(h),n,o);if(!(a=h.c))return null;if(Q=a.length-1,C=Q*f+1,Q=a[Q]){for(;Q%10==0;Q/=10,C--);for(Q=a[0];Q>=10;Q/=10,C++);}return n&&h.e+1>C&&(C=h.e+1),C},q.shiftedBy=function(n){return Y(n,-y,y),this.times("1e"+n)},q.squareRoot=q.sqrt=function(){var n,o,a,C,Q,h=this,p=h.c,I=h.s,c=h.e,l=z+4,u=new k("0.5");if(I!==1||!p||!p[0])return new k(!I||I<0&&(!p||p[0])?NaN:p?h:1/0);if(I=Math.sqrt(+M(h)),I==0||I==1/0?(o=P(p),(o.length+c)%2==0&&(o+="0"),I=Math.sqrt(+o),c=H((c+1)/2)-(c<0||c%2),I==1/0?o="5e"+c:(o=I.toExponential(),o=o.slice(0,o.indexOf("e")+1)+c),a=new k(o)):a=new k(I+""),a.c[0]){for(c=a.e,I=c+l,I<3&&(I=0);;)if(Q=a,a=u.times(Q.plus(S(h,Q,l,1))),P(Q.c).slice(0,I)===(o=P(a.c)).slice(0,I))if(a.e<c&&--I,o=o.slice(I-3,I+1),o=="9999"||!C&&o=="4999"){if(!C&&(kA(Q,Q.e+z+2,0),Q.times(Q).eq(h))){a=Q;break}l+=4,I+=4,C=1}else{(!+o||!+o.slice(1)&&o.charAt(0)=="5")&&(kA(a,a.e+z+2,1),n=!a.times(a).eq(h));break}}return kA(a,a.e+z+1,tA,n)},q.toExponential=function(n,o){return n!=null&&(Y(n,0,R),n++),E(this,n,o,1)},q.toFixed=function(n,o){return n!=null&&(Y(n,0,R),n=n+this.e+1),E(this,n,o)},q.toFormat=function(n,o,a){var C,Q=this;if(a==null)n!=null&&o&&typeof o=="object"?(a=o,o=null):n&&typeof n=="object"?(a=n,n=o=null):a=_e;else if(typeof a!="object")throw Error(B+"Argument not an object: "+a);if(C=Q.toFixed(n,o),Q.c){var h,p=C.split("."),I=+a.groupSize,c=+a.secondaryGroupSize,l=a.groupSeparator||"",u=p[0],d=p[1],m=Q.s<0,D=m?u.slice(1):u,Z=D.length;if(c&&(h=I,I=c,c=h,Z-=h),I>0&&Z>0){for(h=Z%I||I,u=D.substr(0,h);h<Z;h+=I)u+=l+D.substr(h,I);c>0&&(u+=l+D.slice(h)),m&&(u="-"+u)}C=d?u+(a.decimalSeparator||"")+((c=+a.fractionGroupSize)?d.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(a.fractionGroupSeparator||"")):d):u}return(a.prefix||"")+C+(a.suffix||"")},q.toFraction=function(n){var o,a,C,Q,h,p,I,c,l,u,d,m,D=this,Z=D.c;if(n!=null&&(I=new k(n),!I.isInteger()&&(I.c||I.s!==1)||I.lt(eA)))throw Error(B+"Argument "+(I.isInteger()?"out of range: ":"not an integer: ")+M(I));if(!Z)return new k(D);for(o=new k(eA),l=a=new k(eA),C=c=new k(eA),m=P(Z),h=o.e=m.length-D.e-1,o.c[0]=b[(p=h%f)<0?f+p:p],n=!n||I.comparedTo(o)>0?h>0?o:l:I,p=xA,xA=1/0,I=new k(m),c.c[0]=0;u=S(I,o,0,1),Q=a.plus(u.times(C)),Q.comparedTo(n)!=1;)a=C,C=Q,l=c.plus(u.times(Q=l)),c=Q,o=I.minus(u.times(Q=o)),I=Q;return Q=S(n.minus(a),C,0,1),c=c.plus(Q.times(l)),a=a.plus(Q.times(C)),c.s=l.s=D.s,h=h*2,d=S(l,C,h,tA).minus(D).abs().comparedTo(S(c,a,h,tA).minus(D).abs())<1?[l,C]:[c,a],xA=p,d},q.toNumber=function(){return+M(this)},q.toPrecision=function(n,o){return n!=null&&Y(n,1,R),E(this,n,o,2)},q.toString=function(n){var o,a=this,C=a.s,Q=a.e;return Q===null?C?(o="Infinity",C<0&&(o="-"+o)):o="NaN":(n==null?o=Q<=EA||Q>=dA?uA(P(a.c),Q):oA(P(a.c),Q,"0"):n===10&&Te?(a=kA(new k(a),z+Q+1,tA),o=oA(P(a.c),a.e,"0")):(Y(n,2,ie.length,"Base"),o=v(oA(P(a.c),Q,"0"),10,n,C,!0)),C<0&&a.c[0]&&(o="-"+o)),o},q.valueOf=q.toJSON=function(){return M(this)},q._isBigNumber=!0,U!=null&&k.set(U),k}function H(U){var S=U|0;return U>0||U===S?S:S-1}function P(U){for(var S,v,K=1,q=U.length,eA=U[0]+"";K<q;){for(S=U[K++]+"",v=f-S.length;v--;S="0"+S);eA+=S}for(q=eA.length;eA.charCodeAt(--q)===48;);return eA.slice(0,q+1||1)}function BA(U,S){var v,K,q=U.c,eA=S.c,z=U.s,tA=S.s,EA=U.e,dA=S.e;if(!z||!tA)return null;if(v=q&&!q[0],K=eA&&!eA[0],v||K)return v?K?0:-tA:z;if(z!=tA)return z;if(v=z<0,K=EA==dA,!q||!eA)return K?0:!q^v?1:-1;if(!K)return EA>dA^v?1:-1;for(tA=(EA=q.length)<(dA=eA.length)?EA:dA,z=0;z<tA;z++)if(q[z]!=eA[z])return q[z]>eA[z]^v?1:-1;return EA==dA?0:EA>dA^v?1:-1}function Y(U,S,v,K){if(U<S||U>v||U!==i(U))throw Error(B+(K||"Argument")+(typeof U=="number"?U<S||U>v?" out of range: ":" not an integer: ":" not a primitive number: ")+String(U))}function sA(U){var S=U.c.length-1;return H(U.e/f)==S&&U.c[S]%2!=0}function uA(U,S){return(U.length>1?U.charAt(0)+"."+U.slice(1):U)+(S<0?"e":"e+")+S}function oA(U,S,v){var K,q;if(S<0){for(q=v+".";++S;q+=v);U=q+U}else if(K=U.length,++S>K){for(q=v,S-=K;--S;q+=v);U+=q}else S<K&&(U=U.slice(0,S)+"."+U.slice(S));return U}A=F(),A.default=A.BigNumber=A,typeof define=="function"&&define.amd?define(function(){return A}):typeof pt<"u"&&pt.exports?pt.exports=A:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=A)})(Fi)});var Si=lA((Lo,xi)=>{xi.exports=function(A,e,r){var i=new A.Uint8Array(r),B=e.pushInt,s=e.pushInt32,w=e.pushInt32Neg,f=e.pushInt64,y=e.pushInt64Neg,b=e.pushFloat,x=e.pushFloatSingle,R=e.pushFloatDouble,F=e.pushTrue,H=e.pushFalse,P=e.pushUndefined,BA=e.pushNull,Y=e.pushInfinity,sA=e.pushInfinityNeg,uA=e.pushNaN,oA=e.pushNaNNeg,U=e.pushArrayStart,S=e.pushArrayStartFixed,v=e.pushArrayStartFixed32,K=e.pushArrayStartFixed64,q=e.pushObjectStart,eA=e.pushObjectStartFixed,z=e.pushObjectStartFixed32,tA=e.pushObjectStartFixed64,EA=e.pushByteString,dA=e.pushByteStringStart,bA=e.pushUtf8String,xA=e.pushUtf8StringStart,vA=e.pushSimpleUnassigned,pA=e.pushTagStart,ZA=e.pushTagStart4,_e=e.pushTagStart8,ie=e.pushTagUnassigned,Te=e.pushBreak,k=A.Math.pow,E=0,le=0,Ie=0;function kA(g){for(g=g|0,E=0,le=g;(E|0)<(le|0)&&(Ie=BB[i[E]&255](i[E]|0)|0,!((Ie|0)>0)););return Ie|0}function M(g){return g=g|0,((E|0)+(g|0)|0)<(le|0)?0:1}function n(g){return g=g|0,i[g|0]<<8|i[g+1|0]|0}function o(g){return g=g|0,i[g|0]<<24|i[g+1|0]<<16|i[g+2|0]<<8|i[g+3|0]|0}function a(g){return g=g|0,B(g|0),E=E+1|0,0}function C(g){return g=g|0,M(1)|0?1:(B(i[E+1|0]|0),E=E+2|0,0)}function Q(g){return g=g|0,M(2)|0?1:(B(n(E+1|0)|0),E=E+3|0,0)}function h(g){return g=g|0,M(4)|0?1:(s(n(E+1|0)|0,n(E+3|0)|0),E=E+5|0,0)}function p(g){return g=g|0,M(8)|0?1:(f(n(E+1|0)|0,n(E+3|0)|0,n(E+5|0)|0,n(E+7|0)|0),E=E+9|0,0)}function I(g){return g=g|0,B(-1-(g-32|0)|0),E=E+1|0,0}function c(g){return g=g|0,M(1)|0?1:(B(-1-(i[E+1|0]|0)|0),E=E+2|0,0)}function l(g){g=g|0;var L=0;return M(2)|0?1:(L=n(E+1|0)|0,B(-1-(L|0)|0),E=E+3|0,0)}function u(g){return g=g|0,M(4)|0?1:(w(n(E+1|0)|0,n(E+3|0)|0),E=E+5|0,0)}function d(g){return g=g|0,M(8)|0?1:(y(n(E+1|0)|0,n(E+3|0)|0,n(E+5|0)|0,n(E+7|0)|0),E=E+9|0,0)}function m(g){g=g|0;var L=0,O=0,J=0;return J=g-64|0,M(J|0)|0?1:(L=E+1|0,O=(E+1|0)+(J|0)|0,EA(L|0,O|0),E=O|0,0)}function D(g){g=g|0;var L=0,O=0,J=0;return M(1)|0||(J=i[E+1|0]|0,L=E+2|0,O=(E+2|0)+(J|0)|0,M(J+1|0)|0)?1:(EA(L|0,O|0),E=O|0,0)}function Z(g){g=g|0;var L=0,O=0,J=0;return M(2)|0||(J=n(E+1|0)|0,L=E+3|0,O=(E+3|0)+(J|0)|0,M(J+2|0)|0)?1:(EA(L|0,O|0),E=O|0,0)}function rA(g){g=g|0;var L=0,O=0,J=0;return M(4)|0||(J=o(E+1|0)|0,L=E+5|0,O=(E+5|0)+(J|0)|0,M(J+4|0)|0)?1:(EA(L|0,O|0),E=O|0,0)}function aA(g){return g=g|0,1}function T(g){return g=g|0,dA(),E=E+1|0,0}function N(g){g=g|0;var L=0,O=0,J=0;return J=g-96|0,M(J|0)|0?1:(L=E+1|0,O=(E+1|0)+(J|0)|0,bA(L|0,O|0),E=O|0,0)}function CA(g){g=g|0;var L=0,O=0,J=0;return M(1)|0||(J=i[E+1|0]|0,L=E+2|0,O=(E+2|0)+(J|0)|0,M(J+1|0)|0)?1:(bA(L|0,O|0),E=O|0,0)}function we(g){g=g|0;var L=0,O=0,J=0;return M(2)|0||(J=n(E+1|0)|0,L=E+3|0,O=(E+3|0)+(J|0)|0,M(J+2|0)|0)?1:(bA(L|0,O|0),E=O|0,0)}function Le(g){g=g|0;var L=0,O=0,J=0;return M(4)|0||(J=o(E+1|0)|0,L=E+5|0,O=(E+5|0)+(J|0)|0,M(J+4|0)|0)?1:(bA(L|0,O|0),E=O|0,0)}function ve(g){return g=g|0,1}function UA(g){return g=g|0,xA(),E=E+1|0,0}function j(g){return g=g|0,S(g-128|0),E=E+1|0,0}function mA(g){return g=g|0,M(1)|0?1:(S(i[E+1|0]|0),E=E+2|0,0)}function GA(g){return g=g|0,M(2)|0?1:(S(n(E+1|0)|0),E=E+3|0,0)}function iA(g){return g=g|0,M(4)|0?1:(v(n(E+1|0)|0,n(E+3|0)|0),E=E+5|0,0)}function _n(g){return g=g|0,M(8)|0?1:(K(n(E+1|0)|0,n(E+3|0)|0,n(E+5|0)|0,n(E+7|0)|0),E=E+9|0,0)}function Tn(g){return g=g|0,U(),E=E+1|0,0}function nA(g){g=g|0;var L=0;return L=g-160|0,M(L|0)|0?1:(eA(L|0),E=E+1|0,0)}function Ln(g){return g=g|0,M(1)|0?1:(eA(i[E+1|0]|0),E=E+2|0,0)}function vn(g){return g=g|0,M(2)|0?1:(eA(n(E+1|0)|0),E=E+3|0,0)}function Zn(g){return g=g|0,M(4)|0?1:(z(n(E+1|0)|0,n(E+3|0)|0),E=E+5|0,0)}function On(g){return g=g|0,M(8)|0?1:(tA(n(E+1|0)|0,n(E+3|0)|0,n(E+5|0)|0,n(E+7|0)|0),E=E+9|0,0)}function Kn(g){return g=g|0,q(),E=E+1|0,0}function pe(g){return g=g|0,pA(g-192|0|0),E=E+1|0,0}function Ao(g){return g=g|0,pA(g|0),E=E+1|0,0}function eo(g){return g=g|0,pA(g|0),E=E+1|0,0}function to(g){return g=g|0,pA(g|0),E=E+1|0,0}function ro(g){return g=g|0,pA(g|0),E=E+1|0,0}function fA(g){return g=g|0,pA(g-192|0|0),E=E+1|0,0}function io(g){return g=g|0,pA(g|0),E=E+1|0,0}function no(g){return g=g|0,pA(g|0),E=E+1|0,0}function Bo(g){return g=g|0,pA(g|0),E=E+1|0,0}function jn(g){return g=g|0,M(1)|0?1:(pA(i[E+1|0]|0),E=E+2|0,0)}function Vn(g){return g=g|0,M(2)|0?1:(pA(n(E+1|0)|0),E=E+3|0,0)}function Pn(g){return g=g|0,M(4)|0?1:(ZA(n(E+1|0)|0,n(E+3|0)|0),E=E+5|0,0)}function Wn(g){return g=g|0,M(8)|0?1:(_e(n(E+1|0)|0,n(E+3|0)|0,n(E+5|0)|0,n(E+7|0)|0),E=E+9|0,0)}function gA(g){return g=g|0,vA((g|0)-224|0),E=E+1|0,0}function Xn(g){return g=g|0,H(),E=E+1|0,0}function zn(g){return g=g|0,F(),E=E+1|0,0}function $n(g){return g=g|0,BA(),E=E+1|0,0}function AB(g){return g=g|0,P(),E=E+1|0,0}function eB(g){return g=g|0,M(1)|0?1:(vA(i[E+1|0]|0),E=E+2|0,0)}function tB(g){g=g|0;var L=0,O=0,J=1,nt=0,Ze=0,so=0;return M(2)|0?1:(L=i[E+1|0]|0,O=i[E+2|0]|0,(L|0)&128&&(J=-1),nt=+(((L|0)&124)>>2),Ze=+(((L|0)&3)<<8|O),+nt==0?b(+(+J*5960464477539063e-23*+Ze)):+nt==31?+J==1?+Ze>0?uA():Y():+Ze>0?oA():sA():b(+(+J*k(2,+(+nt-25))*+(1024+Ze))),E=E+3|0,0)}function rB(g){return g=g|0,M(4)|0?1:(x(i[E+1|0]|0,i[E+2|0]|0,i[E+3|0]|0,i[E+4|0]|0),E=E+5|0,0)}function iB(g){return g=g|0,M(8)|0?1:(R(i[E+1|0]|0,i[E+2|0]|0,i[E+3|0]|0,i[E+4|0]|0,i[E+5|0]|0,i[E+6|0]|0,i[E+7|0]|0,i[E+8|0]|0),E=E+9|0,0)}function X(g){return g=g|0,1}function nB(g){return g=g|0,Te(),E=E+1|0,0}var BB=[a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,C,Q,h,p,X,X,X,X,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,c,l,u,d,X,X,X,X,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,D,Z,rA,aA,X,X,X,T,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,CA,we,Le,ve,X,X,X,UA,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,mA,GA,iA,_n,X,X,X,Tn,nA,nA,nA,nA,nA,nA,nA,nA,nA,nA,nA,nA,nA,nA,nA,nA,nA,nA,nA,nA,nA,nA,nA,nA,Ln,vn,Zn,On,X,X,X,Kn,pe,pe,pe,pe,pe,pe,fA,fA,fA,fA,fA,fA,fA,fA,fA,fA,fA,fA,fA,fA,fA,fA,fA,fA,jn,Vn,Pn,Wn,X,X,X,X,gA,gA,gA,gA,gA,gA,gA,gA,gA,gA,gA,gA,gA,gA,gA,gA,gA,gA,gA,gA,Xn,zn,$n,AB,eB,tB,rB,iB,X,X,X,nB];return{parse:kA}}});var We=lA(DA=>{"use strict";var Xt=Pe().BigNumber;DA.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};DA.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};DA.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};DA.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};DA.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};DA.SHIFT32=Math.pow(2,32);DA.SHIFT16=Math.pow(2,16);DA.MAX_SAFE_HIGH=2097151;DA.NEG_ONE=new Xt(-1);DA.TEN=new Xt(10);DA.TWO=new Xt(2);DA.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Gt=lA(MA=>{"use strict";var{Buffer:TB}=Ve(),Ni=Pe().BigNumber,bi=We(),Di=bi.SHIFT32,LB=bi.SHIFT16,vB=2097151;MA.parseHalf=function(A){var e,r,i;return i=A[0]&128?-1:1,e=(A[0]&124)>>2,r=(A[0]&3)<<8|A[1],e?e===31?i*(r?0/0:1/0):i*Math.pow(2,e-25)*(1024+r):i*5960464477539063e-23*r};function ZB(t){return t<16?"0"+t.toString(16):t.toString(16)}MA.arrayBufferToBignumber=function(t){let A=t.byteLength,e="";for(let r=0;r<A;r++)e+=ZB(t[r]);return new Ni(e,16)};MA.buildMap=t=>{let A=new Map,e=Object.keys(t),r=e.length;for(let i=0;i<r;i++)A.set(e[i],t[e[i]]);return A};MA.buildInt32=(t,A)=>t*LB+A;MA.buildInt64=(t,A,e,r)=>{let i=MA.buildInt32(t,A),B=MA.buildInt32(e,r);return i>vB?new Ni(i).times(Di).plus(B):i*Di+B};MA.writeHalf=function(A,e){let r=TB.allocUnsafe(4);r.writeFloatBE(e,0);let i=r.readUInt32BE(0);if((i&8191)!==0)return!1;var B=i>>16&32768;let s=i>>23&255,w=i&8388607;if(s>=113&&s<=142)B+=(s-112<<10)+(w>>13);else if(s>=103&&s<113){if(w&(1<<126-s)-1)return!1;B+=w+8388608>>126-s}else return!1;return A.writeUInt16BE(B,0),!0};MA.keySorter=function(t,A){var e=t[0].byteLength,r=A[0].byteLength;return e>r?1:r>e?-1:t[0].compare(A[0])};MA.isNegativeZero=t=>t===0&&1/t<0;MA.nextPowerOf2=t=>{let A=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,A+=1;return 1<<A}});var Ar=lA((Oo,Ui)=>{"use strict";var $t=We(),OB=$t.MT,dt=$t.SIMPLE,zt=$t.SYMS,Se=class{constructor(A){if(typeof A!="number")throw new Error("Invalid Simple type: "+typeof A);if(A<0||A>255||(A|0)!==A)throw new Error("value must be a small positive integer: "+A);this.value=A}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(A){return A._pushInt(this.value,OB.SIMPLE_FLOAT)}static isSimple(A){return A instanceof Se}static decode(A,e){switch(e==null&&(e=!0),A){case dt.FALSE:return!1;case dt.TRUE:return!0;case dt.NULL:return e?null:zt.NULL;case dt.UNDEFINED:return e?void 0:zt.UNDEFINED;case-1:if(!e)throw new Error("Invalid BREAK");return zt.BREAK;default:return new Se(A)}}};Ui.exports=Se});var er=lA((Ko,Mi)=>{"use strict";var De=class{constructor(A,e,r){if(this.tag=A,this.value=e,this.err=r,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(A){return A._pushTag(this.tag),A.pushAny(this.value)}convert(A){var e,r;if(r=A?.[this.tag],typeof r!="function"&&(r=De["_tag"+this.tag],typeof r!="function"))return this;try{return r.call(De,this.value)}catch(i){return e=i,this.err=e,this}}};Mi.exports=De});var ir=lA((jo,Yi)=>{"use strict";var Hi=self.location?self.location.protocol+"//"+self.location.host:"",tr=self.URL,rr=class{constructor(A="",e=Hi){this.super=new tr(A,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(A){this.super.hash=A}set host(A){this.super.host=A}set hostname(A){this.super.hostname=A}set href(A){this.super.href=A}set origin(A){this.super.origin=A}set password(A){this.super.password=A}set pathname(A){this.super.pathname=A}set port(A){this.super.port=A}set protocol(A){this.super.protocol=A}set search(A){this.super.search=A}set searchParams(A){this.super.searchParams=A}set username(A){this.super.username=A}createObjectURL(A){return this.super.createObjectURL(A)}revokeObjectURL(A){this.super.revokeObjectURL(A)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function KB(t){if(typeof t=="string")return new tr(t).toString();if(!(t instanceof tr)){let A=t.username&&t.password?`${t.username}:${t.password}@`:"",e=t.auth?t.auth+"@":"",r=t.port?":"+t.port:"",i=t.protocol?t.protocol+"//":"",B=t.host||"",s=t.hostname||"",w=t.search||(t.query?"?"+t.query:""),f=t.hash||"",y=t.pathname||"",b=t.path||y+w;return`${i}${A||e}${B||s+r}${b}${f}`}}Yi.exports={URLWithLegacySupport:rr,URLSearchParams:self.URLSearchParams,defaultBase:Hi,format:KB}});var _i=lA((Vo,Ji)=>{"use strict";var{URLWithLegacySupport:Ri,format:jB}=ir();Ji.exports=(t,A={},e={},r)=>{let i=A.protocol?A.protocol.replace(":",""):"http";i=(e[i]||r||i)+":";let B;try{B=new Ri(t)}catch{B={}}let s=Object.assign({},A,{protocol:i||B.protocol,host:A.host||B.host});return new Ri(t,jB(s)).toString()}});var nr=lA((Po,Ti)=>{"use strict";var{URLWithLegacySupport:VB,format:PB,URLSearchParams:WB,defaultBase:XB}=ir(),zB=_i();Ti.exports={URL:VB,URLSearchParams:WB,format:PB,relative:zB,defaultBase:XB}});var Br=lA((Wo,vi)=>{"use strict";var{Buffer:Ne}=Ve(),Li=br(),$B=Pe().BigNumber,As=Si(),yA=Gt(),W=We(),es=Ar(),ts=er(),{URL:rs}=nr(),ae=class{constructor(A){A=A||{},!A.size||A.size<65536?A.size=65536:A.size=yA.nextPowerOf2(A.size),this._heap=new ArrayBuffer(A.size),this._heap8=new Uint8Array(this._heap),this._buffer=Ne.from(this._heap),this._reset(),this._knownTags=Object.assign({0:e=>new Date(e),1:e=>new Date(e*1e3),2:e=>yA.arrayBufferToBignumber(e),3:e=>W.NEG_ONE.minus(yA.arrayBufferToBignumber(e)),4:e=>W.TEN.pow(e[0]).times(e[1]),5:e=>W.TWO.pow(e[0]).times(e[1]),32:e=>new rs(e),35:e=>new RegExp(e)},A.tags),this.parser=As(window,{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 A=this._parents.pop();if(A.length>0)throw new Error(`Missing ${A.length} elements`);switch(A.type){case W.PARENT.TAG:this._push(this.createTag(A.ref[0],A.ref[1]));break;case W.PARENT.BYTE_STRING:this._push(this.createByteString(A.ref,A.length));break;case W.PARENT.UTF8_STRING:this._push(this.createUtf8String(A.ref,A.length));break;case W.PARENT.MAP:if(A.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(A.ref,A.length));break;case W.PARENT.OBJECT:if(A.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(A.ref,A.length));break;case W.PARENT.ARRAY:this._push(this.createArray(A.ref,A.length));break;default:break}this._currentParent&&this._currentParent.type===W.PARENT.TAG&&this._dec()}_dec(){let A=this._currentParent;A.length<0||(A.length--,A.length===0&&this._closeParent())}_push(A,e){let r=this._currentParent;switch(r.values++,r.type){case W.PARENT.ARRAY:case W.PARENT.BYTE_STRING:case W.PARENT.UTF8_STRING:r.length>-1?this._ref[this._ref.length-r.length]=A:this._ref.push(A),this._dec();break;case W.PARENT.OBJECT:r.tmpKey!=null?(this._ref[r.tmpKey]=A,r.tmpKey=null,this._dec()):(r.tmpKey=A,typeof r.tmpKey!="string"&&(r.type=W.PARENT.MAP,r.ref=yA.buildMap(r.ref)));break;case W.PARENT.MAP:r.tmpKey!=null?(this._ref.set(r.tmpKey,A),r.tmpKey=null,this._dec()):r.tmpKey=A;break;case W.PARENT.TAG:this._ref.push(A),e||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(A,e,r){this._parents[this._depth]={type:e,length:r,ref:A,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:W.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(A,e){let r=this._knownTags[A];return r?r(e):new ts(A,e)}createMap(A,e){return A}createObject(A,e){return A}createArray(A,e){return A}createByteString(A,e){return Ne.concat(A)}createByteStringFromHeap(A,e){return A===e?Ne.alloc(0):Ne.from(this._heap.slice(A,e))}createInt(A){return A}createInt32(A,e){return yA.buildInt32(A,e)}createInt64(A,e,r,i){return yA.buildInt64(A,e,r,i)}createFloat(A){return A}createFloatSingle(A,e,r,i){return Li.read([A,e,r,i],0,!1,23,4)}createFloatDouble(A,e,r,i,B,s,w,f){return Li.read([A,e,r,i,B,s,w,f],0,!1,52,8)}createInt32Neg(A,e){return-1-yA.buildInt32(A,e)}createInt64Neg(A,e,r,i){let B=yA.buildInt32(A,e),s=yA.buildInt32(r,i);return B>W.MAX_SAFE_HIGH?W.NEG_ONE.minus(new $B(B).times(W.SHIFT32).plus(s)):-1-(B*W.SHIFT32+s)}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(A,e){return A.join("")}createUtf8StringFromHeap(A,e){return A===e?"":this._buffer.toString("utf8",A,e)}createSimpleUnassigned(A){return new es(A)}pushInt(A){this._push(this.createInt(A))}pushInt32(A,e){this._push(this.createInt32(A,e))}pushInt64(A,e,r,i){this._push(this.createInt64(A,e,r,i))}pushFloat(A){this._push(this.createFloat(A))}pushFloatSingle(A,e,r,i){this._push(this.createFloatSingle(A,e,r,i))}pushFloatDouble(A,e,r,i,B,s,w,f){this._push(this.createFloatDouble(A,e,r,i,B,s,w,f))}pushInt32Neg(A,e){this._push(this.createInt32Neg(A,e))}pushInt64Neg(A,e,r,i){this._push(this.createInt64Neg(A,e,r,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([],W.PARENT.ARRAY,-1)}pushArrayStartFixed(A){this._createArrayStartFixed(A)}pushArrayStartFixed32(A,e){let r=yA.buildInt32(A,e);this._createArrayStartFixed(r)}pushArrayStartFixed64(A,e,r,i){let B=yA.buildInt64(A,e,r,i);this._createArrayStartFixed(B)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(A){this._createObjectStartFixed(A)}pushObjectStartFixed32(A,e){let r=yA.buildInt32(A,e);this._createObjectStartFixed(r)}pushObjectStartFixed64(A,e,r,i){let B=yA.buildInt64(A,e,r,i);this._createObjectStartFixed(B)}pushByteStringStart(){this._parents[this._depth]={type:W.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(A,e){this._push(this.createByteStringFromHeap(A,e))}pushUtf8StringStart(){this._parents[this._depth]={type:W.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(A,e){this._push(this.createUtf8StringFromHeap(A,e))}pushSimpleUnassigned(A){this._push(this.createSimpleUnassigned(A))}pushTagStart(A){this._parents[this._depth]={type:W.PARENT.TAG,length:1,ref:[A]}}pushTagStart4(A,e){this.pushTagStart(yA.buildInt32(A,e))}pushTagStart8(A,e,r,i){this.pushTagStart(yA.buildInt64(A,e,r,i))}pushTagUnassigned(A){this._push(this.createTag(A))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(A){if(A===0){this._push(this.createObject({}));return}this._createParent({},W.PARENT.OBJECT,A)}_createArrayStartFixed(A){if(A===0){this._push(this.createArray([]));return}this._createParent(new Array(A),W.PARENT.ARRAY,A)}_decode(A){if(A.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(A);let e=this.parser.parse(A.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(A){return this._decode(A),this._res[0]}decodeAll(A){return this._decode(A),this._res}static decode(A,e){return typeof A=="string"&&(A=Ne.from(A,e||"hex")),new ae({size:A.length}).decodeFirst(A)}static decodeAll(A,e){return typeof A=="string"&&(A=Ne.from(A,e||"hex")),new ae({size:A.length}).decodeAll(A)}};ae.decodeFirst=ae.decode;vi.exports=ae});var Ki=lA((Xo,Oi)=>{"use strict";var{Buffer:sr}=Ve(),is=Br(),ns=Gt(),Xe=class extends is{createTag(A,e){return`${A}(${e})`}createInt(A){return super.createInt(A).toString()}createInt32(A,e){return super.createInt32(A,e).toString()}createInt64(A,e,r,i){return super.createInt64(A,e,r,i).toString()}createInt32Neg(A,e){return super.createInt32Neg(A,e).toString()}createInt64Neg(A,e,r,i){return super.createInt64Neg(A,e,r,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(A){let e=super.createFloat(A);return ns.isNegativeZero(A)?"-0_1":`${e}_1`}createFloatSingle(A,e,r,i){return`${super.createFloatSingle(A,e,r,i)}_2`}createFloatDouble(A,e,r,i,B,s,w,f){return`${super.createFloatDouble(A,e,r,i,B,s,w,f)}_3`}createByteString(A,e){let r=A.join(", ");return e===-1?`(_ ${r})`:`h'${r}`}createByteStringFromHeap(A,e){return`h'${sr.from(super.createByteStringFromHeap(A,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(A){return`simple(${A})`}createArray(A,e){let r=super.createArray(A,e);return e===-1?`[_ ${r.join(", ")}]`:`[${r.join(", ")}]`}createMap(A,e){let r=super.createMap(A),i=Array.from(r.keys()).reduce(Zi(r),"");return e===-1?`{_ ${i}}`:`{${i}}`}createObject(A,e){let r=super.createObject(A),i=Object.keys(r).reduce(Zi(r),"");return e===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(A,e){let r=A.join(", ");return e===-1?`(_ ${r})`:`"${r}"`}createUtf8StringFromHeap(A,e){return`"${sr.from(super.createUtf8StringFromHeap(A,e)).toString("utf8")}"`}static diagnose(A,e){return typeof A=="string"&&(A=sr.from(A,e||"hex")),new Xe().decodeFirst(A)}};Oi.exports=Xe;function Zi(t){return(A,e)=>A?`${A}, ${e}: ${t[e]}`:`${e}: ${t[e]}`}});var Xi=lA((zo,Wi)=>{"use strict";var{Buffer:WA}=Ve(),{URL:Bs}=nr(),ar=Pe().BigNumber,or=Gt(),cA=We(),_A=cA.MT,yt=cA.NUMBYTES,ji=cA.SHIFT32,Vi=cA.SYMS,be=cA.TAG,ss=cA.MT.SIMPLE_FLOAT<<5|cA.NUMBYTES.TWO,os=cA.MT.SIMPLE_FLOAT<<5|cA.NUMBYTES.FOUR,as=cA.MT.SIMPLE_FLOAT<<5|cA.NUMBYTES.EIGHT,gs=cA.MT.SIMPLE_FLOAT<<5|cA.SIMPLE.TRUE,Is=cA.MT.SIMPLE_FLOAT<<5|cA.SIMPLE.FALSE,Es=cA.MT.SIMPLE_FLOAT<<5|cA.SIMPLE.UNDEFINED,Pi=cA.MT.SIMPLE_FLOAT<<5|cA.SIMPLE.NULL,Qs=new ar("0x20000000000000"),cs=WA.from("f97e00","hex"),hs=WA.from("f9fc00","hex"),us=WA.from("f97c00","hex");function Cs(t){return{}.toString.call(t).slice(8,-1)}var Ue=class{constructor(A){A=A||{},this.streaming=typeof A.stream=="function",this.onData=A.stream,this.semanticTypes=[[Bs,this._pushUrl],[ar,this._pushBigNumber]];let e=A.genTypes||[],r=e.length;for(let i=0;i<r;i++)this.addSemanticType(e[i][0],e[i][1]);this._reset()}addSemanticType(A,e){let r=this.semanticTypes.length;for(let i=0;i<r;i++)if(this.semanticTypes[i][0]===A){let s=this.semanticTypes[i][1];return this.semanticTypes[i][1]=e,s}return this.semanticTypes.push([A,e]),null}push(A){return A&&(this.result[this.offset]=A,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=A.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(A,e,r){return this.result[this.offset]=A,this.resultMethod[this.offset]=e,this.resultLength[this.offset]=r,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(A){return this.pushWrite(A,1,1)}_pushUInt16BE(A){return this.pushWrite(A,2,2)}_pushUInt32BE(A){return this.pushWrite(A,3,4)}_pushDoubleBE(A){return this.pushWrite(A,4,8)}_pushNaN(){return this.push(cs)}_pushInfinity(A){let e=A<0?hs:us;return this.push(e)}_pushFloat(A){let e=WA.allocUnsafe(2);if(or.writeHalf(e,A)&&or.parseHalf(e)===A)return this._pushUInt8(ss)&&this.push(e);let r=WA.allocUnsafe(4);return r.writeFloatBE(A,0),r.readFloatBE(0)===A?this._pushUInt8(os)&&this.push(r):this._pushUInt8(as)&&this._pushDoubleBE(A)}_pushInt(A,e,r){let i=e<<5;return A<24?this._pushUInt8(i|A):A<=255?this._pushUInt8(i|yt.ONE)&&this._pushUInt8(A):A<=65535?this._pushUInt8(i|yt.TWO)&&this._pushUInt16BE(A):A<=4294967295?this._pushUInt8(i|yt.FOUR)&&this._pushUInt32BE(A):A<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|yt.EIGHT)&&this._pushUInt32BE(Math.floor(A/ji))&&this._pushUInt32BE(A%ji):e===_A.NEG_INT?this._pushFloat(r):this._pushFloat(A)}_pushIntNum(A){return A<0?this._pushInt(-A-1,_A.NEG_INT,A):this._pushInt(A,_A.POS_INT)}_pushNumber(A){switch(!1){case A===A:return this._pushNaN(A);case isFinite(A):return this._pushInfinity(A);case A%1!==0:return this._pushIntNum(A);default:return this._pushFloat(A)}}_pushString(A){let e=WA.byteLength(A,"utf8");return this._pushInt(e,_A.UTF8_STRING)&&this.pushWrite(A,5,e)}_pushBoolean(A){return this._pushUInt8(A?gs:Is)}_pushUndefined(A){return this._pushUInt8(Es)}_pushArray(A,e){let r=e.length;if(!A._pushInt(r,_A.ARRAY))return!1;for(let i=0;i<r;i++)if(!A.pushAny(e[i]))return!1;return!0}_pushTag(A){return this._pushInt(A,_A.TAG)}_pushDate(A,e){return A._pushTag(be.DATE_EPOCH)&&A.pushAny(Math.round(e/1e3))}_pushBuffer(A,e){return A._pushInt(e.length,_A.BYTE_STRING)&&A.push(e)}_pushNoFilter(A,e){return A._pushBuffer(A,e.slice())}_pushRegexp(A,e){return A._pushTag(be.REGEXP)&&A.pushAny(e.source)}_pushSet(A,e){if(!A._pushInt(e.size,_A.ARRAY))return!1;for(let r of e)if(!A.pushAny(r))return!1;return!0}_pushUrl(A,e){return A._pushTag(be.URI)&&A.pushAny(e.format())}_pushBigint(A){let e=be.POS_BIGINT;A.isNegative()&&(A=A.negated().minus(1),e=be.NEG_BIGINT);let r=A.toString(16);r.length%2&&(r="0"+r);let i=WA.from(r,"hex");return this._pushTag(e)&&this._pushBuffer(this,i)}_pushBigNumber(A,e){if(e.isNaN())return A._pushNaN();if(!e.isFinite())return A._pushInfinity(e.isNegative()?-1/0:1/0);if(e.isInteger())return A._pushBigint(e);if(!(A._pushTag(be.DECIMAL_FRAC)&&A._pushInt(2,_A.ARRAY)))return!1;let r=e.decimalPlaces(),i=e.multipliedBy(new ar(10).pow(r));return A._pushIntNum(-r)?i.abs().isLessThan(Qs)?A._pushIntNum(i.toNumber()):A._pushBigint(i):!1}_pushMap(A,e){return A._pushInt(e.size,_A.MAP)?this._pushRawMap(e.size,Array.from(e)):!1}_pushObject(A){if(!A)return this._pushUInt8(Pi);for(var e=this.semanticTypes.length,r=0;r<e;r++)if(A instanceof this.semanticTypes[r][0])return this.semanticTypes[r][1].call(A,this,A);var i=A.encodeCBOR;if(typeof i=="function")return i.call(A,this);var B=Object.keys(A),s=B.length;return this._pushInt(s,_A.MAP)?this._pushRawMap(s,B.map(w=>[w,A[w]])):!1}_pushRawMap(A,e){e=e.map(function(i){return i[0]=Ue.encode(i[0]),i}).sort(or.keySorter);for(var r=0;r<A;r++)if(!this.push(e[r][0])||!this.pushAny(e[r][1]))return!1;return!0}write(A){return this.pushAny(A)}pushAny(A){var e=Cs(A);switch(e){case"Number":return this._pushNumber(A);case"String":return this._pushString(A);case"Boolean":return this._pushBoolean(A);case"Object":return this._pushObject(A);case"Array":return this._pushArray(this,A);case"Uint8Array":return this._pushBuffer(this,WA.isBuffer(A)?A:WA.from(A));case"Null":return this._pushUInt8(Pi);case"Undefined":return this._pushUndefined(A);case"Map":return this._pushMap(this,A);case"Set":return this._pushSet(this,A);case"URL":return this._pushUrl(this,A);case"BigNumber":return this._pushBigNumber(this,A);case"Date":return this._pushDate(this,A);case"RegExp":return this._pushRegexp(this,A);case"Symbol":switch(A){case Vi.NULL:return this._pushObject(null);case Vi.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+A.toString())}default:throw new Error("Unknown type: "+typeof A+", "+(A?A.toString():""))}}finalize(){if(this.offset===0)return null;for(var A=this.result,e=this.resultLength,r=this.resultMethod,i=this.offset,B=0,s=0;s<i;s++)B+=e[s];var w=WA.allocUnsafe(B),f=0,y=0;for(s=0;s<i;s++){switch(y=e[s],r[s]){case 0:A[s].copy(w,f);break;case 1:w.writeUInt8(A[s],f,!0);break;case 2:w.writeUInt16BE(A[s],f,!0);break;case 3:w.writeUInt32BE(A[s],f,!0);break;case 4:w.writeDoubleBE(A[s],f,!0);break;case 5:w.write(A[s],f,y,"utf8");break;default:throw new Error("unkown method")}f+=y}var b=w;return this._reset(),b}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(A){let e=new Ue;if(!e.pushAny(A))throw new Error("Failed to encode input");return e.finalize()}};Wi.exports=Ue});var gr=lA(hA=>{"use strict";hA.Diagnose=Ki();hA.Decoder=Br();hA.Encoder=Xi();hA.Simple=Ar();hA.Tagged=er();hA.decodeAll=hA.Decoder.decodeAll;hA.decodeFirst=hA.Decoder.decodeFirst;hA.diagnose=hA.Diagnose.diagnose;hA.encode=hA.Encoder.encode;hA.decode=hA.Decoder.decode;hA.leveldb={decode:hA.Decoder.decodeAll,encode:hA.Encoder.encode,buffer:!0,name:"cbor"}});var cr=lA($=>{"use strict";Object.defineProperty($,"__esModule",{value:!0});var ls=9007199254740992;function te(t,...A){let e=new Uint8Array(t.byteLength+A.reduce((i,B)=>i+B.byteLength,0));e.set(new Uint8Array(t),0);let r=t.byteLength;for(let i of A)e.set(new Uint8Array(i),r),r+=i.byteLength;return e.buffer}function TA(t,A,e){e=e.replace(/[^0-9a-fA-F]/g,"");let r=2**(A-24);e=e.slice(-r*2).padStart(r*2,"0");let i=[(t<<5)+A].concat(e.match(/../g).map(B=>parseInt(B,16)));return new Uint8Array(i).buffer}function mt(t,A){if(A<24)return new Uint8Array([(t<<5)+A]).buffer;{let e=A<=255?24:A<=65535?25:A<=4294967295?26:27;return TA(t,e,A.toString(16))}}function tn(t){let A=[];for(let e=0;e<t.length;e++){let r=t.charCodeAt(e);r<128?A.push(r):r<2048?A.push(192|r>>6,128|r&63):r<55296||r>=57344?A.push(224|r>>12,128|r>>6&63,128|r&63):(e++,r=(r&1023)<<10|t.charCodeAt(e)&1023,A.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63))}return te(new Uint8Array(mt(3,t.length)),new Uint8Array(A))}function ws(t,A){if(t==14277111)return te(new Uint8Array([217,217,247]),A);if(t<24)return te(new Uint8Array([(6<<5)+t]),A);{let e=t<=255?24:t<=65535?25:t<=4294967295?26:27,r=2**(e-24),i=t.toString(16).slice(-r*2).padStart(r*2,"0"),B=[(6<<5)+e].concat(i.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(B).buffer}}$.tagged=ws;function ze(t){return new Uint8Array(t).buffer}$.raw=ze;function Er(t){if(isNaN(t))throw new RangeError("Invalid number.");t=Math.min(Math.max(0,t),23);let A=[(0<<5)+t];return new Uint8Array(A).buffer}$.uSmall=Er;function rn(t,A){if(t=parseInt(""+t,A),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),255),t=t.toString(16),TA(0,24,t)}$.u8=rn;function nn(t,A){if(t=parseInt(""+t,A),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),65535),t=t.toString(16),TA(0,25,t)}$.u16=nn;function Bn(t,A){if(t=parseInt(""+t,A),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),4294967295),t=t.toString(16),TA(0,26,t)}$.u32=Bn;function Qr(t,A){if(typeof t=="string"&&A==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return TA(0,27,t)}if(t=parseInt(""+t,A),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),ls),t=t.toString(16),TA(0,27,t)}$.u64=Qr;function sn(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return Er(0);t=Math.min(Math.max(0,-t),24)-1;let A=[(1<<5)+t];return new Uint8Array(A).buffer}$.iSmall=sn;function on(t,A){if(t=parseInt(""+t,A),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),255),t=t.toString(16),TA(1,24,t)}$.i8=on;function an(t,A){if(t=parseInt(""+t,A),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),65535),t=t.toString(16),TA(1,25,t)}$.i16=an;function gn(t,A){if(t=parseInt(""+t,A),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),4294967295),t=t.toString(16),TA(1,26,t)}$.i32=gn;function In(t,A){if(typeof t=="string"&&A==16){if(t.startsWith("-")?t=t.slice(1):t="0",t.match(/[^0-9a-fA-F]/)||t.length>16)throw new RangeError("Invalid number.");let e=!1,r=t.split("").reduceRight((i,B)=>{if(e)return B+i;let s=parseInt(B,16)-1;return s>=0?(e=!0,s.toString(16)+i):"f"+i},"");return e?TA(1,27,r):Qr(0)}if(t=parseInt(""+t,A),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),9007199254740992),t=t.toString(16),TA(1,27,t)}$.i64=In;function ps(t){return t>=0?t<24?Er(t):t<=255?rn(t):t<=65535?nn(t):t<=4294967295?Bn(t):Qr(t):t>=-24?sn(t):t>=-255?on(t):t>=-65535?an(t):t>=-4294967295?gn(t):In(t)}$.number=ps;function Gs(t){return te(mt(2,t.byteLength),t)}$.bytes=Gs;function ds(t){return tn(t)}$.string=ds;function ys(t){return te(mt(4,t.length),...t)}$.array=ys;function ks(t,A=!1){t instanceof Map||(t=new Map(Object.entries(t)));let e=Array.from(t.entries());return A&&(e=e.sort(([r],[i])=>r.localeCompare(i))),te(mt(5,t.size),...e.map(([r,i])=>te(tn(r),i)))}$.map=ks;function ms(t){let A=new Float32Array([t]);return te(new Uint8Array([(7<<5)+26]),new Uint8Array(A.buffer))}$.singleFloat=ms;function qs(t){let A=new Float64Array([t]);return te(new Uint8Array([(7<<5)+27]),new Uint8Array(A.buffer))}$.doubleFloat=qs;function Fs(t){return t?En():Qn()}$.bool=Fs;function En(){return ze(new Uint8Array([(7<<5)+21]))}$.true_=En;function Qn(){return ze(new Uint8Array([(7<<5)+20]))}$.false_=Qn;function xs(){return ze(new Uint8Array([(7<<5)+22]))}$.null_=xs;function Ss(){return ze(new Uint8Array([(7<<5)+23]))}$.undefined_=Ss});var cn=lA(ge=>{"use strict";var Ds=ge&&ge.__importStar||function(t){if(t&&t.__esModule)return t;var A={};if(t!=null)for(var e in t)Object.hasOwnProperty.call(t,e)&&(A[e]=t[e]);return A.default=t,A};Object.defineProperty(ge,"__esModule",{value:!0});var LA=Ds(cr()),Ns=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],qt=class{constructor(A,e=!1){this._serializer=A,this._stable=e,this.name="jsonDefault",this.priority=-100}match(A){return["undefined","boolean","number","string","object"].indexOf(typeof A)!=-1}encode(A){switch(typeof A){case"undefined":return LA.undefined_();case"boolean":return LA.bool(A);case"number":return Math.floor(A)===A?LA.number(A):LA.doubleFloat(A);case"string":return LA.string(A);case"object":if(A===null)return LA.null_();if(Array.isArray(A))return LA.array(A.map(e=>this._serializer.serializeValue(e)));if(Ns.find(e=>A instanceof e))return LA.bytes(A.buffer);if(Object.getOwnPropertyNames(A).indexOf("toJSON")!==-1)return this.encode(A.toJSON());if(A instanceof Map){let e=new Map;for(let[r,i]of A.entries())e.set(r,this._serializer.serializeValue(i));return LA.map(e,this._stable)}else{let e=new Map;for(let[r,i]of Object.entries(A))e.set(r,this._serializer.serializeValue(i));return LA.map(e,this._stable)}default:throw new Error("Invalid value.")}}};ge.JsonDefaultCborEncoder=qt;var Ft=class{constructor(){this.name="cborEncoder",this.priority=-90}match(A){return typeof A=="object"&&typeof A.toCBOR=="function"}encode(A){return A.toCBOR()}};ge.ToCborEncoder=Ft;var xt=class{constructor(){this._encoders=new Set}static withDefaultEncoders(A=!1){let e=new this;return e.addEncoder(new qt(e,A)),e.addEncoder(new Ft),e}removeEncoder(A){for(let e of this._encoders.values())e.name==A&&this._encoders.delete(e)}addEncoder(A){this._encoders.add(A)}getEncoderFor(A){let e=null;for(let r of this._encoders)(!e||r.priority>e.priority)&&r.match(A)&&(e=r);if(e===null)throw new Error("Could not find an encoder for value.");return e}serializeValue(A){return this.getEncoderFor(A).encode(A)}serialize(A){return this.serializeValue(A)}};ge.CborSerializer=xt;var hr=class extends xt{serialize(A){return LA.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(A))]))}};ge.SelfDescribeCborSerializer=hr});var St=lA(he=>{"use strict";function bs(t){for(var A in t)he.hasOwnProperty(A)||(he[A]=t[A])}var Us=he&&he.__importStar||function(t){if(t&&t.__esModule)return t;var A={};if(t!=null)for(var e in t)Object.hasOwnProperty.call(t,e)&&(A[e]=t[e]);return A.default=t,A};Object.defineProperty(he,"__esModule",{value:!0});bs(cn());var Ms=Us(cr());he.value=Ms});var Gn=lA(dr=>{(function(){"use strict";for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",A=new Uint8Array(256),e=0;e<t.length;e++)A[t.charCodeAt(e)]=e;dr.encode=function(r){var i=new Uint8Array(r),B,s=i.length,w="";for(B=0;B<s;B+=3)w+=t[i[B]>>2],w+=t[(i[B]&3)<<4|i[B+1]>>4],w+=t[(i[B+1]&15)<<2|i[B+2]>>6],w+=t[i[B+2]&63];return s%3===2?w=w.substring(0,w.length-1)+"=":s%3===1&&(w=w.substring(0,w.length-2)+"=="),w},dr.decode=function(r){var i=r.length*.75,B=r.length,s,w=0,f,y,b,x;r[r.length-1]==="="&&(i--,r[r.length-2]==="="&&i--);var R=new ArrayBuffer(i),F=new Uint8Array(R);for(s=0;s<B;s+=4)f=A[r.charCodeAt(s)],y=A[r.charCodeAt(s+1)],b=A[r.charCodeAt(s+2)],x=A[r.charCodeAt(s+3)],F[w++]=f<<2|y>>4,F[w++]=(y&15)<<4|b>>2,F[w++]=(b&3)<<6|x&63;return R}})()});var Rn=zA(oB());var Bt;(function(t){t[t.SysFatal=1]="SysFatal",t[t.SysTransient=2]="SysTransient",t[t.DestinationInvalid=3]="DestinationInvalid",t[t.CanisterReject=4]="CanisterReject",t[t.CanisterError=5]="CanisterError"})(Bt||(Bt={}));var st="abcdefghijklmnopqrstuvwxyz234567",Ge=Object.create(null);for(let t=0;t<st.length;t++)Ge[st[t]]=t;Ge["0"]=Ge.o;Ge["1"]=Ge.i;function Ur(t){let A=0,e=0,r="";function i(B){return A<0?e|=B>>-A:e=B<<A&248,A>3?(A-=8,1):(A<4&&(r+=st[e>>3],A+=5),0)}for(let B=0;B<t.length;)B+=i(t[B]);return r+(A<0?st[e>>3]:"")}function Mr(t){let A=0,e=0,r=new Uint8Array(t.length*4/3|0),i=0;function B(s){let w=Ge[s.toLowerCase()];if(w===void 0)throw new Error(`Invalid character: ${JSON.stringify(s)}`);w<<=3,e|=w>>>A,A+=5,A>=8&&(r[i++]=e,A-=8,A>0?e=w<<5-A&255:e=0)}for(let s of t)B(s);return r.slice(0,i)}var aB=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 Hr(t){let A=new Uint8Array(t),e=-1;for(let r=0;r<A.length;r++){let B=(A[r]^e)&255;e=aB[B]^e>>>8}return(e^-1)>>>0}var Yr=zA(Nr());function Rr(t){let A=Yr.sha224.create();return A.update(t),new Uint8Array(A.array())}var gB=2,Jr=4,IB=t=>{var A;return new Uint8Array(((A=t.match(/.{1,2}/g))!==null&&A!==void 0?A:[]).map(e=>parseInt(e,16)))},EB=t=>t.reduce((A,e)=>A+e.toString(16).padStart(2,"0"),""),_=class{constructor(A){this._arr=A,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Jr]))}static selfAuthenticating(A){let e=Rr(A);return new this(new Uint8Array([...e,gB]))}static from(A){if(typeof A=="string")return _.fromText(A);if(typeof A=="object"&&A!==null&&A._isPrincipal===!0)return new _(A._arr);throw new Error(`Impossible to convert ${JSON.stringify(A)} to Principal.`)}static fromHex(A){return new this(IB(A))}static fromText(A){let e=A.toLowerCase().replace(/-/g,""),r=Mr(e);r=r.slice(4,r.length);let i=new this(r);if(i.toText()!==A)throw new Error(`Principal "${i.toText()}" does not have a valid checksum (original value "${A}" may not be a valid Principal ID).`);return i}static fromUint8Array(A){return new this(A)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===Jr}toUint8Array(){return this._arr}toHex(){return EB(this._arr).toUpperCase()}toText(){let A=new ArrayBuffer(4);new DataView(A).setUint32(0,Hr(this._arr));let r=new Uint8Array(A),i=Uint8Array.from(this._arr),B=new Uint8Array([...r,...i]),w=Ur(B).match(/.{1,5}/g);if(!w)throw new Error;return w.join("-")}toString(){return this.toText()}};var JA=class extends Error{constructor(A){super(A),this.message=A,Object.setPrototypeOf(this,JA.prototype)}};var oe={};Jt(oe,{Bool:()=>Kr,BoolClass:()=>Et,ConstructType:()=>jA,Empty:()=>Zr,EmptyClass:()=>gt,FixedIntClass:()=>Ae,FixedNatClass:()=>KA,Float32:()=>Xr,Float64:()=>zr,FloatClass:()=>Ke,Func:()=>ci,FuncClass:()=>je,Int:()=>Pr,Int16:()=>Ai,Int32:()=>ei,Int64:()=>ti,Int8:()=>$r,IntClass:()=>ht,Nat:()=>Wr,Nat16:()=>ii,Nat32:()=>ni,Nat64:()=>Bi,Nat8:()=>ri,NatClass:()=>ut,Null:()=>jr,NullClass:()=>Qt,Opt:()=>gi,OptClass:()=>se,PrimitiveType:()=>qA,Principal:()=>si,PrincipalClass:()=>Ct,Rec:()=>Qi,RecClass:()=>VA,Record:()=>Ii,RecordClass:()=>Ee,Reserved:()=>Or,ReservedClass:()=>ye,Service:()=>hi,ServiceClass:()=>ft,Text:()=>Vr,TextClass:()=>ct,Tuple:()=>oi,TupleClass:()=>me,Type:()=>de,Unknown:()=>uB,UnknownClass:()=>It,Variant:()=>Ei,VariantClass:()=>qe,Vec:()=>ai,VecClass:()=>ke,Visitor:()=>at,decode:()=>hB,encode:()=>cB});function V(...t){let A=new Uint8Array(t.reduce((r,i)=>r+i.byteLength,0)),e=0;for(let r of t)A.set(new Uint8Array(r),e),e+=r.byteLength;return A}var OA=class{constructor(A,e=A?.byteLength||0){this._buffer=A||new ArrayBuffer(0),this._view=new Uint8Array(this._buffer,0,e)}get buffer(){return this._view.slice()}get byteLength(){return this._view.byteLength}read(A){let e=this._view.subarray(0,A);return this._view=this._view.subarray(A),e.slice().buffer}readUint8(){let A=this._view[0];return this._view=this._view.subarray(1),A}write(A){let e=new Uint8Array(A),r=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,r)}get end(){return this._view.byteLength===0}alloc(A){let e=new ArrayBuffer((this._buffer.byteLength+A)*1.2|0),r=new Uint8Array(e,0,this._view.byteLength+A);r.set(this._view),this._buffer=e,this._view=r}};function QB(t){let e=new TextEncoder().encode(t),r=0;for(let i of e)r=(r*223+i)%2**32;return r}function SA(t){if(/^_\d+_$/.test(t)||/^_0x[0-9a-fA-F]+_$/.test(t)){let A=+t.slice(1,-1);if(Number.isSafeInteger(A)&&A>=0&&A<2**32)return A}return QB(t)}function _r(){throw new Error("unexpected end of buffer")}function Be(t,A){return t.byteLength<A&&_r(),t.read(A)}function ne(t){let A=t.readUint8();return A===void 0&&_r(),A}function AA(t){if(typeof t=="number"&&(t=BigInt(t)),t<BigInt(0))throw new Error("Cannot leb encode negative values.");let A=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,e=new OA(new ArrayBuffer(A),0);for(;;){let r=Number(t&BigInt(127));if(t/=BigInt(128),t===BigInt(0)){e.write(new Uint8Array([r]));break}else e.write(new Uint8Array([r|128]))}return e.buffer}function QA(t){let A=BigInt(1),e=BigInt(0),r;do r=ne(t),e+=BigInt(r&127).valueOf()*A,A*=BigInt(128);while(r>=128);return e}function IA(t){typeof t=="number"&&(t=BigInt(t));let A=t<BigInt(0);A&&(t=-t-BigInt(1));let e=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,r=new OA(new ArrayBuffer(e),0);for(;;){let B=i(t);if(t/=BigInt(128),A&&t===BigInt(0)&&(B&64)!==0||!A&&t===BigInt(0)&&(B&64)===0){r.write(new Uint8Array([B]));break}else r.write(new Uint8Array([B|128]))}function i(B){let s=B%BigInt(128);return Number(A?BigInt(128)-s-BigInt(1):s)}return r.buffer}function $A(t){let A=new Uint8Array(t.buffer),e=0;for(;e<A.byteLength;e++)if(A[e]<128){if((A[e]&64)===0)return QA(t);break}let r=new Uint8Array(Be(t,e+1)),i=BigInt(0);for(let B=r.byteLength-1;B>=0;B--)i=i*BigInt(128)+BigInt(128-(r[B]&127)-1);return-i-BigInt(1)}function Tr(t,A){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return _t(t,A)}function _t(t,A){t=BigInt(t);let e=new OA(new ArrayBuffer(Math.min(1,A)),0),r=0,i=BigInt(256),B=BigInt(0),s=Number(t%i);for(e.write(new Uint8Array([s]));++r<A;)t<0&&B===BigInt(0)&&s!==0&&(B=BigInt(1)),s=Number((t/i-B)%BigInt(256)),e.write(new Uint8Array([s])),i*=BigInt(256);return e.buffer}function Tt(t,A){let e=BigInt(ne(t)),r=BigInt(1),i=0;for(;++i<A;){r*=BigInt(256);let B=BigInt(ne(t));e=e+r*B}return e}function Lr(t,A){let e=Tt(t,A),r=BigInt(2)**(BigInt(8)*BigInt(A-1)+BigInt(7));return e>=r&&(e-=r*BigInt(2)),e}var ot="DIDL";function Oe(t,A,e){return t.map((r,i)=>e(r,A[i]))}var Lt=class{constructor(){this._typs=[],this._idx=new Map}has(A){return this._idx.has(A.name)}add(A,e){let r=this._typs.length;this._idx.set(A.name,r),this._typs.push(e)}merge(A,e){let r=this._idx.get(A.name),i=this._idx.get(e);if(r===void 0)throw new Error("Missing type index for "+A);if(i===void 0)throw new Error("Missing type index for "+e);this._typs[r]=this._typs[i],this._typs.splice(i,1),this._idx.delete(e)}encode(){let A=AA(this._typs.length),e=V(...this._typs);return V(A,e)}indexOf(A){if(!this._idx.has(A))throw new Error("Missing type index for "+A);return IA(this._idx.get(A)||0)}},at=class{visitType(A,e){throw new Error("Not implemented")}visitPrimitive(A,e){return this.visitType(A,e)}visitEmpty(A,e){return this.visitPrimitive(A,e)}visitBool(A,e){return this.visitPrimitive(A,e)}visitNull(A,e){return this.visitPrimitive(A,e)}visitReserved(A,e){return this.visitPrimitive(A,e)}visitText(A,e){return this.visitPrimitive(A,e)}visitNumber(A,e){return this.visitPrimitive(A,e)}visitInt(A,e){return this.visitNumber(A,e)}visitNat(A,e){return this.visitNumber(A,e)}visitFloat(A,e){return this.visitPrimitive(A,e)}visitFixedInt(A,e){return this.visitNumber(A,e)}visitFixedNat(A,e){return this.visitNumber(A,e)}visitPrincipal(A,e){return this.visitPrimitive(A,e)}visitConstruct(A,e){return this.visitType(A,e)}visitVec(A,e,r){return this.visitConstruct(A,r)}visitOpt(A,e,r){return this.visitConstruct(A,r)}visitRecord(A,e,r){return this.visitConstruct(A,r)}visitTuple(A,e,r){let i=e.map((B,s)=>[`_${s}_`,B]);return this.visitRecord(A,i,r)}visitVariant(A,e,r){return this.visitConstruct(A,r)}visitRec(A,e,r){return this.visitConstruct(e,r)}visitFunc(A,e){return this.visitConstruct(A,e)}visitService(A,e){return this.visitConstruct(A,e)}},de=class{display(){return this.name}valueToString(A){return vr(A)}buildTypeTable(A){A.has(this)||this._buildTypeTableImpl(A)}},qA=class extends de{checkType(A){if(this.name!==A.name)throw new Error(`type mismatch: type on the wire ${A.name}, expect type ${this.name}`);return A}_buildTypeTableImpl(A){}},jA=class extends de{checkType(A){if(A instanceof VA){let e=A.getType();if(typeof e>"u")throw new Error("type mismatch with uninitialized type");return e}throw new Error(`type mismatch: type on the wire ${A.name}, expect type ${this.name}`)}encodeType(A){return A.indexOf(this.name)}},gt=class extends qA{accept(A,e){return A.visitEmpty(this,e)}covariant(A){return!1}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return IA(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},It=class extends de{checkType(A){throw new Error("Method not implemented for unknown.")}accept(A,e){throw A.visitType(this,e)}covariant(A){return!1}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(A,e){let r=e.decodeValue(A,e);Object(r)!==r&&(r=Object(r));let i;return e instanceof VA?i=()=>e.getType():i=()=>e,Object.defineProperty(r,"type",{value:i,writable:!0,enumerable:!1,configurable:!0}),r}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}},Et=class extends qA{accept(A,e){return A.visitBool(this,e)}covariant(A){return typeof A=="boolean"}encodeValue(A){return new Uint8Array([A?1:0])}encodeType(){return IA(-2)}decodeValue(A,e){switch(this.checkType(e),ne(A)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},Qt=class extends qA{accept(A,e){return A.visitNull(this,e)}covariant(A){return A===null}encodeValue(){return new ArrayBuffer(0)}encodeType(){return IA(-1)}decodeValue(A,e){return this.checkType(e),null}get name(){return"null"}},ye=class extends qA{accept(A,e){return A.visitReserved(this,e)}covariant(A){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return IA(-16)}decodeValue(A,e){return e.name!==this.name&&e.decodeValue(A,e),null}get name(){return"reserved"}},ct=class extends qA{accept(A,e){return A.visitText(this,e)}covariant(A){return typeof A=="string"}encodeValue(A){let e=new TextEncoder().encode(A),r=AA(e.byteLength);return V(r,e)}encodeType(){return IA(-15)}decodeValue(A,e){this.checkType(e);let r=QA(A),i=Be(A,Number(r));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(A){return'"'+A+'"'}},ht=class extends qA{accept(A,e){return A.visitInt(this,e)}covariant(A){return typeof A=="bigint"||Number.isInteger(A)}encodeValue(A){return IA(A)}encodeType(){return IA(-4)}decodeValue(A,e){return this.checkType(e),$A(A)}get name(){return"int"}valueToString(A){return A.toString()}},ut=class extends qA{accept(A,e){return A.visitNat(this,e)}covariant(A){return typeof A=="bigint"&&A>=BigInt(0)||Number.isInteger(A)&&A>=0}encodeValue(A){return AA(A)}encodeType(){return IA(-3)}decodeValue(A,e){return this.checkType(e),QA(A)}get name(){return"nat"}valueToString(A){return A.toString()}},Ke=class extends qA{constructor(A){if(super(),this._bits=A,A!==32&&A!==64)throw new Error("not a valid float type")}accept(A,e){return A.visitFloat(this,e)}covariant(A){return typeof A=="number"||A instanceof Number}encodeValue(A){let e=new ArrayBuffer(this._bits/8),r=new DataView(e);return this._bits===32?r.setFloat32(0,A,!0):r.setFloat64(0,A,!0),e}encodeType(){let A=this._bits===32?-13:-14;return IA(A)}decodeValue(A,e){this.checkType(e);let r=Be(A,this._bits/8),i=new DataView(r);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(A){return A.toString()}},Ae=class extends qA{constructor(A){super(),this._bits=A}accept(A,e){return A.visitFixedInt(this,e)}covariant(A){let e=BigInt(2)**BigInt(this._bits-1)*BigInt(-1),r=BigInt(2)**BigInt(this._bits-1)-BigInt(1);if(typeof A=="bigint")return A>=e&&A<=r;if(Number.isInteger(A)){let i=BigInt(A);return i>=e&&i<=r}else return!1}encodeValue(A){return _t(A,this._bits/8)}encodeType(){let A=Math.log2(this._bits)-3;return IA(-9-A)}decodeValue(A,e){this.checkType(e);let r=Lr(A,this._bits/8);return this._bits<=32?Number(r):r}get name(){return`int${this._bits}`}valueToString(A){return A.toString()}},KA=class extends qA{constructor(A){super(),this.bits=A}accept(A,e){return A.visitFixedNat(this,e)}covariant(A){let e=BigInt(2)**BigInt(this.bits);return typeof A=="bigint"&&A>=BigInt(0)?A<e:Number.isInteger(A)&&A>=0?BigInt(A)<e:!1}encodeValue(A){return Tr(A,this.bits/8)}encodeType(){let A=Math.log2(this.bits)-3;return IA(-5-A)}decodeValue(A,e){this.checkType(e);let r=Tt(A,this.bits/8);return this.bits<=32?Number(r):r}get name(){return`nat${this.bits}`}valueToString(A){return A.toString()}},ke=class extends jA{constructor(A){super(),this._type=A,this._blobOptimization=!1,A instanceof KA&&A.bits===8&&(this._blobOptimization=!0)}accept(A,e){return A.visitVec(this,this._type,e)}covariant(A){let e=this._type instanceof KA?this._type.bits:this._type instanceof Ae?this._type._bits:0;return ArrayBuffer.isView(A)&&e==A.BYTES_PER_ELEMENT*8||Array.isArray(A)&&A.every(r=>this._type.covariant(r))}encodeValue(A){let e=AA(A.length);if(this._blobOptimization)return V(e,new Uint8Array(A));if(ArrayBuffer.isView(A))return V(e,new Uint8Array(A.buffer));let r=new OA(new ArrayBuffer(e.byteLength+A.length),0);r.write(e);for(let i of A){let B=this._type.encodeValue(i);r.write(new Uint8Array(B))}return r.buffer}_buildTypeTableImpl(A){this._type.buildTypeTable(A);let e=IA(-19),r=this._type.encodeType(A);A.add(this,V(e,r))}decodeValue(A,e){let r=this.checkType(e);if(!(r instanceof ke))throw new Error("Not a vector type");let i=Number(QA(A));if(this._type instanceof KA){if(this._type.bits==8)return new Uint8Array(A.read(i));if(this._type.bits==16)return new Uint16Array(A.read(i*2));if(this._type.bits==32)return new Uint32Array(A.read(i*4));if(this._type.bits==64)return new BigUint64Array(A.read(i*8))}if(this._type instanceof Ae){if(this._type._bits==8)return new Int8Array(A.read(i));if(this._type._bits==16)return new Int16Array(A.read(i*2));if(this._type._bits==32)return new Int32Array(A.read(i*4));if(this._type._bits==64)return new BigInt64Array(A.read(i*8))}let B=[];for(let s=0;s<i;s++)B.push(this._type.decodeValue(A,r._type));return B}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(A){let e=A.map(r=>this._type.valueToString(r));return"vec {"+e.join("; ")+"}"}},se=class extends jA{constructor(A){super(),this._type=A}accept(A,e){return A.visitOpt(this,this._type,e)}covariant(A){return Array.isArray(A)&&(A.length===0||A.length===1&&this._type.covariant(A[0]))}encodeValue(A){return A.length===0?new Uint8Array([0]):V(new Uint8Array([1]),this._type.encodeValue(A[0]))}_buildTypeTableImpl(A){this._type.buildTypeTable(A);let e=IA(-18),r=this._type.encodeType(A);A.add(this,V(e,r))}decodeValue(A,e){let r=this.checkType(e);if(!(r instanceof se))throw new Error("Not an option type");switch(ne(A)){case 0:return[];case 1:return[this._type.decodeValue(A,r._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(A){return A.length===0?"null":`opt ${this._type.valueToString(A[0])}`}},Ee=class extends jA{constructor(A={}){super(),this._fields=Object.entries(A).sort((e,r)=>SA(e[0])-SA(r[0]))}accept(A,e){return A.visitRecord(this,this._fields,e)}tryAsTuple(){let A=[];for(let e=0;e<this._fields.length;e++){let[r,i]=this._fields[e];if(r!==`_${e}_`)return null;A.push(i)}return A}covariant(A){return typeof A=="object"&&this._fields.every(([e,r])=>{if(!A.hasOwnProperty(e))throw new Error(`Record is missing key "${e}".`);return r.covariant(A[e])})}encodeValue(A){let e=this._fields.map(([i])=>A[i]),r=Oe(this._fields,e,([,i],B)=>i.encodeValue(B));return V(...r)}_buildTypeTableImpl(A){this._fields.forEach(([B,s])=>s.buildTypeTable(A));let e=IA(-20),r=AA(this._fields.length),i=this._fields.map(([B,s])=>V(AA(SA(B)),s.encodeType(A)));A.add(this,V(e,r,V(...i)))}decodeValue(A,e){let r=this.checkType(e);if(!(r instanceof Ee))throw new Error("Not a record type");let i={},B=0,s=0;for(;s<r._fields.length;){let[w,f]=r._fields[s];if(B>=this._fields.length){f.decodeValue(A,f),s++;continue}let[y,b]=this._fields[B];if(SA(this._fields[B][0])!==SA(w)){if(b instanceof se||b instanceof ye){i[y]=[],B++;continue}f.decodeValue(A,f),s++;continue}i[y]=b.decodeValue(A,f),B++,s++}for(let[w,f]of this._fields.slice(B))if(f instanceof se||f instanceof ye)i[w]=[];else throw new Error("Cannot find required field "+w);return i}get name(){return`record {${this._fields.map(([e,r])=>e+":"+r.name).join("; ")}}`}display(){return`record {${this._fields.map(([e,r])=>e+":"+r.display()).join("; ")}}`}valueToString(A){let e=this._fields.map(([i])=>A[i]);return`record {${Oe(this._fields,e,([i,B],s)=>i+"="+B.valueToString(s)).join("; ")}}`}},me=class extends Ee{constructor(A){let e={};A.forEach((r,i)=>e["_"+i+"_"]=r),super(e),this._components=A}accept(A,e){return A.visitTuple(this,this._components,e)}covariant(A){return Array.isArray(A)&&A.length>=this._fields.length&&this._components.every((e,r)=>e.covariant(A[r]))}encodeValue(A){let e=Oe(this._components,A,(r,i)=>r.encodeValue(i));return V(...e)}decodeValue(A,e){let r=this.checkType(e);if(!(r instanceof me))throw new Error("not a tuple type");if(r._components.length<this._components.length)throw new Error("tuple mismatch");let i=[];for(let[B,s]of r._components.entries())B>=this._components.length?s.decodeValue(A,s):i.push(this._components[B].decodeValue(A,s));return i}display(){return`record {${this._components.map(e=>e.display()).join("; ")}}`}valueToString(A){return`record {${Oe(this._components,A,(r,i)=>r.valueToString(i)).join("; ")}}`}},qe=class extends jA{constructor(A={}){super(),this._fields=Object.entries(A).sort((e,r)=>SA(e[0])-SA(r[0]))}accept(A,e){return A.visitVariant(this,this._fields,e)}covariant(A){return typeof A=="object"&&Object.entries(A).length===1&&this._fields.every(([e,r])=>!A.hasOwnProperty(e)||r.covariant(A[e]))}encodeValue(A){for(let e=0;e<this._fields.length;e++){let[r,i]=this._fields[e];if(A.hasOwnProperty(r)){let B=AA(e),s=i.encodeValue(A[r]);return V(B,s)}}throw Error("Variant has no data: "+A)}_buildTypeTableImpl(A){this._fields.forEach(([,B])=>{B.buildTypeTable(A)});let e=IA(-21),r=AA(this._fields.length),i=this._fields.map(([B,s])=>V(AA(SA(B)),s.encodeType(A)));A.add(this,V(e,r,...i))}decodeValue(A,e){let r=this.checkType(e);if(!(r instanceof qe))throw new Error("Not a variant type");let i=Number(QA(A));if(i>=r._fields.length)throw Error("Invalid variant index: "+i);let[B,s]=r._fields[i];for(let[w,f]of this._fields)if(SA(B)===SA(w)){let y=f.decodeValue(A,s);return{[w]:y}}throw new Error("Cannot find field hash "+B)}get name(){return`variant {${this._fields.map(([e,r])=>e+":"+r.name).join("; ")}}`}display(){return`variant {${this._fields.map(([e,r])=>e+(r.name==="null"?"":`:${r.display()}`)).join("; ")}}`}valueToString(A){for(let[e,r]of this._fields)if(A.hasOwnProperty(e)){let i=r.valueToString(A[e]);return i==="null"?`variant {${e}}`:`variant {${e}=${i}}`}throw new Error("Variant has no data: "+A)}},VA=class extends jA{constructor(){super(...arguments),this._id=VA._counter++,this._type=void 0}accept(A,e){if(!this._type)throw Error("Recursive type uninitialized.");return A.visitRec(this,this._type,e)}fill(A){this._type=A}getType(){return this._type}covariant(A){return this._type?this._type.covariant(A):!1}encodeValue(A){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(A)}_buildTypeTableImpl(A){if(!this._type)throw Error("Recursive type uninitialized.");A.add(this,new Uint8Array([])),this._type.buildTypeTable(A),A.merge(this,this._type.name)}decodeValue(A,e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(A,e)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(A){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(A)}};VA._counter=0;function vt(t){if(ne(t)!==1)throw new Error("Cannot decode principal");let e=Number(QA(t));return _.fromUint8Array(new Uint8Array(Be(t,e)))}var Ct=class extends qA{accept(A,e){return A.visitPrincipal(this,e)}covariant(A){return A&&A._isPrincipal}encodeValue(A){let e=A.toUint8Array(),r=AA(e.byteLength);return V(new Uint8Array([1]),r,e)}encodeType(){return IA(-24)}decodeValue(A,e){return this.checkType(e),vt(A)}get name(){return"principal"}valueToString(A){return`${this.name} "${A.toText()}"`}},je=class extends jA{constructor(A,e,r=[]){super(),this.argTypes=A,this.retTypes=e,this.annotations=r}static argsToString(A,e){if(A.length!==e.length)throw new Error("arity mismatch");return"("+A.map((r,i)=>r.valueToString(e[i])).join(", ")+")"}accept(A,e){return A.visitFunc(this,e)}covariant(A){return Array.isArray(A)&&A.length===2&&A[0]&&A[0]._isPrincipal&&typeof A[1]=="string"}encodeValue([A,e]){let r=A.toUint8Array(),i=AA(r.byteLength),B=V(new Uint8Array([1]),i,r),s=new TextEncoder().encode(e),w=AA(s.byteLength);return V(new Uint8Array([1]),B,w,s)}_buildTypeTableImpl(A){this.argTypes.forEach(y=>y.buildTypeTable(A)),this.retTypes.forEach(y=>y.buildTypeTable(A));let e=IA(-22),r=AA(this.argTypes.length),i=V(...this.argTypes.map(y=>y.encodeType(A))),B=AA(this.retTypes.length),s=V(...this.retTypes.map(y=>y.encodeType(A))),w=AA(this.annotations.length),f=V(...this.annotations.map(y=>this.encodeAnnotation(y)));A.add(this,V(e,r,i,B,s,w,f))}decodeValue(A){if(ne(A)!==1)throw new Error("Cannot decode function reference");let r=vt(A),i=Number(QA(A)),B=Be(A,i),w=new TextDecoder("utf8",{fatal:!0}).decode(B);return[r,w]}get name(){let A=this.argTypes.map(i=>i.name).join(", "),e=this.retTypes.map(i=>i.name).join(", "),r=" "+this.annotations.join(" ");return`(${A}) -> (${e})${r}`}valueToString([A,e]){return`func "${A.toText()}".${e}`}display(){let A=this.argTypes.map(i=>i.display()).join(", "),e=this.retTypes.map(i=>i.display()).join(", "),r=" "+this.annotations.join(" ");return`(${A}) \u2192 (${e})${r}`}encodeAnnotation(A){if(A==="query")return new Uint8Array([1]);if(A==="oneway")return new Uint8Array([2]);throw new Error("Illegal function annotation")}},ft=class extends jA{constructor(A){super(),this._fields=Object.entries(A).sort((e,r)=>SA(e[0])-SA(r[0]))}accept(A,e){return A.visitService(this,e)}covariant(A){return A&&A._isPrincipal}encodeValue(A){let e=A.toUint8Array(),r=AA(e.length);return V(new Uint8Array([1]),r,e)}_buildTypeTableImpl(A){this._fields.forEach(([B,s])=>s.buildTypeTable(A));let e=IA(-23),r=AA(this._fields.length),i=this._fields.map(([B,s])=>{let w=new TextEncoder().encode(B),f=AA(w.length);return V(f,w,s.encodeType(A))});A.add(this,V(e,r,...i))}decodeValue(A){return vt(A)}get name(){return`service {${this._fields.map(([e,r])=>e+":"+r.name).join("; ")}}`}valueToString(A){return`service "${A.toText()}"`}};function vr(t){return JSON.stringify(t,(A,e)=>typeof e=="bigint"?`BigInt(${e})`:e)}function cB(t,A){if(A.length<t.length)throw Error("Wrong number of message arguments");let e=new Lt;t.forEach(f=>f.buildTypeTable(e));let r=new TextEncoder().encode(ot),i=e.encode(),B=AA(A.length),s=V(...t.map(f=>f.encodeType(e))),w=V(...Oe(t,A,(f,y)=>{if(!f.covariant(y))throw new Error(`Invalid ${f.display()} argument: ${vr(y)}`);return f.encodeValue(y)}));return V(r,i,B,s,w)}function hB(t,A){let e=new OA(A);if(A.byteLength<ot.length)throw new Error("Message length smaller than magic number");let r=Be(e,ot.length),i=new TextDecoder().decode(r);if(i!==ot)throw new Error("Wrong magic number: "+JSON.stringify(i));function B(F){let H=[],P=Number(QA(F));for(let sA=0;sA<P;sA++){let uA=Number($A(F));switch(uA){case-18:case-19:{let oA=Number($A(F));H.push([uA,oA]);break}case-20:case-21:{let oA=[],U=Number(QA(F)),S;for(;U--;){let v=Number(QA(F));if(v>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof S=="number"&&S>=v)throw new Error("field id collision or not sorted");S=v;let K=Number($A(F));oA.push([v,K])}H.push([uA,oA]);break}case-22:{let oA=[],U=Number(QA(F));for(;U--;)oA.push(Number($A(F)));let S=[],v=Number(QA(F));for(;v--;)S.push(Number($A(F)));let K=[],q=Number(QA(F));for(;q--;)switch(Number(QA(F))){case 1:{K.push("query");break}case 2:{K.push("oneway");break}default:throw new Error("unknown annotation")}H.push([uA,[oA,S,K]]);break}case-23:{let oA=Number(QA(F)),U=[];for(;oA--;){let S=Number(QA(F)),v=new TextDecoder().decode(Be(F,S)),K=$A(F);U.push([v,K])}H.push([uA,U]);break}default:throw new Error("Illegal op_code: "+uA)}}let BA=[],Y=Number(QA(F));for(let sA=0;sA<Y;sA++)BA.push(Number($A(F)));return[H,BA]}let[s,w]=B(e);if(w.length<t.length)throw new Error("Wrong number of return values");let f=s.map(F=>Qi());function y(F){if(F<-24)throw new Error("future value not supported");if(F<0)switch(F){case-1:return jr;case-2:return Kr;case-3:return Wr;case-4:return Pr;case-5:return ri;case-6:return ii;case-7:return ni;case-8:return Bi;case-9:return $r;case-10:return Ai;case-11:return ei;case-12:return ti;case-13:return Xr;case-14:return zr;case-15:return Vr;case-16:return Or;case-17:return Zr;case-24:return si;default:throw new Error("Illegal op_code: "+F)}if(F>=s.length)throw new Error("type index out of range");return f[F]}function b(F){switch(F[0]){case-19:{let H=y(F[1]);return ai(H)}case-18:{let H=y(F[1]);return gi(H)}case-20:{let H={};for(let[Y,sA]of F[1]){let uA=`_${Y}_`;H[uA]=y(sA)}let P=Ii(H),BA=P.tryAsTuple();return Array.isArray(BA)?oi(...BA):P}case-21:{let H={};for(let[P,BA]of F[1]){let Y=`_${P}_`;H[Y]=y(BA)}return Ei(H)}case-22:{let[H,P,BA]=F[1];return ci(H.map(Y=>y(Y)),P.map(Y=>y(Y)),BA)}case-23:{let H={},P=F[1];for(let[BA,Y]of P){let sA=y(Y);if(sA instanceof VA&&(sA=sA.getType()),!(sA instanceof je))throw new Error("Illegal service definition: services can only contain functions");H[BA]=sA}return hi(H)}default:throw new Error("Illegal op_code: "+F[0])}}s.forEach((F,H)=>{let P=b(F);f[H].fill(P)});let x=w.map(F=>y(F)),R=t.map((F,H)=>F.decodeValue(e,x[H]));for(let F=t.length;F<x.length;F++)x[F].decodeValue(e,x[F]);if(e.byteLength>0)throw new Error("decode: Left-over bytes");return R}var Zr=new gt,Or=new ye,uB=new It,Kr=new Et,jr=new Qt,Vr=new ct,Pr=new ht,Wr=new ut,Xr=new Ke(32),zr=new Ke(64),$r=new Ae(8),Ai=new Ae(16),ei=new Ae(32),ti=new Ae(64),ri=new KA(8),ii=new KA(16),ni=new KA(32),Bi=new KA(64),si=new Ct;function oi(...t){return new me(t)}function ai(t){return new ke(t)}function gi(t){return new se(t)}function Ii(t){return new Ee(t)}function Ei(t){return new qe(t)}function Qi(){return new VA}function ci(t,A,e=[]){return new je(t,A,e)}function hi(t){return new ft(t)}var $i=zA(gr()),An=zA(Nr());function NA(...t){let A=new Uint8Array(t.reduce((r,i)=>r+i.byteLength,0)),e=0;for(let r of t)A.set(new Uint8Array(r),e),e+=r.byteLength;return A.buffer}function HA(t){return[...new Uint8Array(t)].map(A=>A.toString(16).padStart(2,"0")).join("")}var fs=new RegExp(/^([0-9A-F]{2})*$/i);function ce(t){if(!fs.test(t))throw new Error("Invalid hexadecimal string.");let A=[...t].reduce((e,r,i)=>(e[i/2|0]=(e[i/2|0]||"")+r,e),[]).map(e=>Number.parseInt(e,16));return new Uint8Array(A).buffer}function zi(t,A){if(t.byteLength!==A.byteLength)return t.byteLength-A.byteLength;let e=new Uint8Array(t),r=new Uint8Array(A);for(let i=0;i<e.length;i++)if(e[i]!==r[i])return e[i]-r[i];return 0}function YA(t){return An.sha256.create().update(new Uint8Array(t)).arrayBuffer()}function kt(t){if(t instanceof $i.default.Tagged)return kt(t.value);if(typeof t=="string")return en(t);if(typeof t=="number")return YA(AA(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return YA(t);if(Array.isArray(t)){let A=t.map(kt);return YA(NA(...A))}else{if(t&&typeof t=="object"&&t._isPrincipal)return YA(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return kt(t.toHash());if(typeof t=="bigint")return YA(AA(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}var en=t=>{let A=new TextEncoder().encode(t);return YA(A)};function Ir(t){let r=Object.entries(t).filter(([,s])=>s!==void 0).map(([s,w])=>{let f=en(s),y=kt(w);return[f,y]}).sort(([s],[w])=>zi(s,w)),i=NA(...r.map(s=>NA(...s)));return YA(i)}var sa=new TextEncoder().encode(`
|
|
2
|
-
ic-request`);var Me=class{getPrincipal(){return _.anonymous()}async transformRequest(A){return Object.assign(Object.assign({},A),{body:{content:A.body}})}};var un=zA(gr()),ue=zA(St()),Cn=zA(St());var ur=class{get name(){return"Principal"}get priority(){return 0}match(A){return A&&A._isPrincipal===!0}encode(A){return ue.value.bytes(A.toUint8Array())}},Cr=class{get name(){return"Buffer"}get priority(){return 1}match(A){return A instanceof ArrayBuffer||ArrayBuffer.isView(A)}encode(A){return ue.value.bytes(new Uint8Array(A))}},fr=class{get name(){return"BigInt"}get priority(){return 1}match(A){return typeof A=="bigint"}encode(A){return A>BigInt(0)?ue.value.tagged(2,ue.value.bytes(ce(A.toString(16)))):ue.value.tagged(3,ue.value.bytes(ce((BigInt("-1")*A).toString(16))))}},Dt=Cn.SelfDescribeCborSerializer.withDefaultEncoders(!0);Dt.addEncoder(new ur);Dt.addEncoder(new Cr);Dt.addEncoder(new fr);var lr;(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(lr||(lr={}));function Nt(t){return Dt.serialize(t)}function hn(t){let A=t.byteLength,e=BigInt(0);for(let r=0;r<A;r++)e=e*BigInt(256)+BigInt(t[r]);return e}var wr=class extends un.default.Decoder{createByteString(A){return NA(...A)}createByteStringFromHeap(A,e){return A===e?new ArrayBuffer(0):new Uint8Array(this._heap.slice(A,e))}};function He(t){let A=new Uint8Array(t);return new wr({size:A.byteLength,tags:{2:r=>hn(r),3:r=>-hn(r),[lr.Semantic]:r=>r}}).decodeFirst(A)}var fn=zA(St());var Ut;(function(t){t.Call="call"})(Ut||(Ut={}));function $e(){let t=new ArrayBuffer(16),A=new DataView(t),e=BigInt(+Date.now()),r=Math.floor(Math.random()*4294967295),i=Math.floor(Math.random()*4294967295);
|
|
2
|
+
ic-request`);var Me=class{getPrincipal(){return _.anonymous()}async transformRequest(A){return Object.assign(Object.assign({},A),{body:{content:A.body}})}};var un=zA(gr()),ue=zA(St()),Cn=zA(St());var ur=class{get name(){return"Principal"}get priority(){return 0}match(A){return A&&A._isPrincipal===!0}encode(A){return ue.value.bytes(A.toUint8Array())}},Cr=class{get name(){return"Buffer"}get priority(){return 1}match(A){return A instanceof ArrayBuffer||ArrayBuffer.isView(A)}encode(A){return ue.value.bytes(new Uint8Array(A))}},fr=class{get name(){return"BigInt"}get priority(){return 1}match(A){return typeof A=="bigint"}encode(A){return A>BigInt(0)?ue.value.tagged(2,ue.value.bytes(ce(A.toString(16)))):ue.value.tagged(3,ue.value.bytes(ce((BigInt("-1")*A).toString(16))))}},Dt=Cn.SelfDescribeCborSerializer.withDefaultEncoders(!0);Dt.addEncoder(new ur);Dt.addEncoder(new Cr);Dt.addEncoder(new fr);var lr;(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(lr||(lr={}));function Nt(t){return Dt.serialize(t)}function hn(t){let A=t.byteLength,e=BigInt(0);for(let r=0;r<A;r++)e=e*BigInt(256)+BigInt(t[r]);return e}var wr=class extends un.default.Decoder{createByteString(A){return NA(...A)}createByteStringFromHeap(A,e){return A===e?new ArrayBuffer(0):new Uint8Array(this._heap.slice(A,e))}};function He(t){let A=new Uint8Array(t);return new wr({size:A.byteLength,tags:{2:r=>hn(r),3:r=>-hn(r),[lr.Semantic]:r=>r}}).decodeFirst(A)}var fn=zA(St());var Ut;(function(t){t.Call="call"})(Ut||(Ut={}));function $e(){let t=new ArrayBuffer(16),A=new DataView(t),e=BigInt(+Date.now()),r=Math.floor(Math.random()*4294967295),i=Math.floor(Math.random()*4294967295);if(typeof A.setBigUint64=="function")A.setBigUint64(0,e);else{let B=BigInt(1)<<BigInt(32);A.setUint32(0,Number(e>>BigInt(32))),A.setUint32(4,Number(e%B))}return A.setUint32(8,r),A.setUint32(12,i),t}var Hs=BigInt(1e6),Ys=BigInt(60*1e3),Ye=class{constructor(A){this._value=(BigInt(Date.now())+BigInt(A)-Ys)*Hs}toCBOR(){return fn.value.u64(this._value.toString(16),16)}toHash(){return AA(this._value)}};function ln(t=$e){return async A=>{A.endpoint==="call"&&(A.body.nonce=t())}}var XA;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(XA||(XA={}));var pr=5*60*1e3,Rs="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae",Js="ic0.app",_s=".ic0.app",At=class extends JA{constructor(A){super(A),this.message=A}},Re=class extends JA{constructor(A){super(A),this.message=A}};function Ts(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new At("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new At("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(t=self.fetch.bind(self));if(t)return t;throw new At("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var Je=class{constructor(A={}){if(this.rootKey=ce(Rs),this._pipeline=[],this._rootKeyFetched=!1,A.source){if(!(A.source instanceof Je))throw new Error("An Agent's source can only be another HttpAgent");this._pipeline=[...A.source._pipeline],this._identity=A.source._identity,this._fetch=A.source._fetch,this._host=A.source._host,this._credentials=A.source._credentials}else this._fetch=A.fetch||Ts()||fetch.bind(window);if(A.host!==void 0)!A.host.match(/^[a-z]+:/)&&typeof window<"u"?this._host=new URL(window.location.protocol+"//"+A.host):this._host=new URL(A.host);else if(A.source!==void 0)this._host=A.source._host;else{let e=typeof window<"u"?window.location:void 0;if(!e)throw new Error("Must specify a host to connect to.");this._host=new URL(e+"")}if(this._host.hostname.endsWith(_s)&&(this._host.hostname=Js),A.credentials){let{name:e,password:r}=A.credentials;this._credentials=`${e}${r?":"+r:""}`}this._identity=Promise.resolve(A.identity||new Me),A.disableNonce||this.addTransform(ln($e))}addTransform(A,e=A.priority||0){let r=this._pipeline.findIndex(i=>(i.priority||0)<e);this._pipeline.splice(r>=0?r:this._pipeline.length,0,Object.assign(A,{priority:e}))}async getPrincipal(){if(!this._identity)throw new Re("This identity has expired due this application's security policy. Please refresh your authentication.");return(await this._identity).getPrincipal()}async call(A,e,r){let i=await(r!==void 0?await r:await this._identity);if(!i)throw new Re("This identity has expired due this application's security policy. Please refresh your authentication.");let B=_.from(A),s=e.effectiveCanisterId?_.from(e.effectiveCanisterId):B,w=i.getPrincipal()||_.anonymous(),f={request_type:Ut.Call,canister_id:B,method_name:e.methodName,arg:e.arg,sender:w,ingress_expiry:new Ye(pr)},y=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"call",body:f});y=await i.transformRequest(y);let b=Nt(y.body),[x,R]=await Promise.all([this._fetch(""+new URL(`/api/v2/canister/${s.toText()}/call`,this._host),Object.assign(Object.assign({},y.request),{body:b})),Ir(f)]);if(!x.ok)throw new Error(`Server returned an error:
|
|
3
3
|
Code: ${x.status} (${x.statusText})
|
|
4
4
|
Body: ${await x.text()}
|
|
5
5
|
`);return{requestId:R,response:{ok:x.ok,status:x.status,statusText:x.statusText}}}async query(A,e,r){let i=await(r!==void 0?await r:await this._identity);if(!i)throw new Re("This identity has expired due this application's security policy. Please refresh your authentication.");let B=typeof A=="string"?_.fromText(A):A,s=i?.getPrincipal()||_.anonymous(),w={request_type:"query",canister_id:B,method_name:e.methodName,arg:e.arg,sender:s,ingress_expiry:new Ye(pr)},f=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read",body:w});f=await i?.transformRequest(f);let y=Nt(f.body),b=await this._fetch(""+new URL(`/api/v2/canister/${B.toText()}/query`,this._host),Object.assign(Object.assign({},f.request),{body:y}));if(!b.ok)throw new Error(`Server returned an error:
|
|
@@ -828,4 +828,4 @@ ic-request`);var Me=class{getPrincipal(){return _.anonymous()}async transformReq
|
|
|
828
828
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
829
829
|
* @license MIT
|
|
830
830
|
*/
|
|
831
|
-
//# sourceMappingURL=chunk-
|
|
831
|
+
//# sourceMappingURL=chunk-BVNLDI2R.js.map
|