@junobuild/core 0.0.61 → 0.0.62

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junobuild/core",
3
- "version": "0.0.61",
3
+ "version": "0.0.62",
4
4
  "description": "JavaScript core client for Juno",
5
5
  "author": "David Dal Busco (https://daviddalbusco.com)",
6
6
  "license": "MIT",
@@ -50,10 +50,10 @@
50
50
  ],
51
51
  "homepage": "https://juno.build",
52
52
  "dependencies": {
53
- "@dfinity/agent": "^2.0.0",
54
- "@dfinity/auth-client": "^2.0.0",
55
- "@dfinity/identity": "^2.0.0",
56
- "@dfinity/principal": "^2.0.0",
53
+ "@dfinity/agent": "^2.1.3",
54
+ "@dfinity/auth-client": "^2.1.3",
55
+ "@dfinity/identity": "^2.1.3",
56
+ "@dfinity/principal": "^2.1.3",
57
57
  "@junobuild/storage": "*",
58
58
  "@junobuild/utils": "*"
59
59
  }
@@ -1,2 +0,0 @@
1
- import{S as a,T as b,U as c,V as d}from"./chunk-3YVZN56F.js";export{a as CustomPath,d as encodePath,c as fetchNodeKeys,b as request};
2
- //# sourceMappingURL=canisterStatus-APCJZWVG.js.map
@@ -1,46 +0,0 @@
1
- var Qa=Object.create;var Fr=Object.defineProperty;var ec=Object.getOwnPropertyDescriptor;var tc=Object.getOwnPropertyNames;var rc=Object.getPrototypeOf,nc=Object.prototype.hasOwnProperty;var ic=(r,e)=>()=>(r&&(e=r(r=0)),e);var $e=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Cn=(r,e)=>{for(var t in e)Fr(r,t,{get:e[t],enumerable:!0})},os=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of tc(e))!nc.call(r,i)&&i!==t&&Fr(r,i,{get:()=>e[i],enumerable:!(n=ec(e,i))||n.enumerable});return r};var Pr=(r,e,t)=>(t=r!=null?Qa(rc(r)):{},os(e||!r||!r.__esModule?Fr(t,"default",{value:r,enumerable:!0}):t,r)),sc=r=>os(Fr({},"__esModule",{value:!0}),r);var Ms={};Cn(Ms,{Buffer:()=>q,INSPECT_MAX_BYTES:()=>vs,SlowBuffer:()=>Ac,isBuffer:()=>Ps,kMaxLength:()=>xc});function xs(){Kn=!0;for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,t=r.length;e<t;++e)mt[e]=r[e],rt[r.charCodeAt(e)]=e;rt[45]=62,rt[95]=63}function gc(r){Kn||xs();var e,t,n,i,s,o,f=r.length;if(f%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s=r[f-2]==="="?2:r[f-1]==="="?1:0,o=new mc(f*3/4-s),n=s>0?f-4:f;var c=0;for(e=0,t=0;e<n;e+=4,t+=3)i=rt[r.charCodeAt(e)]<<18|rt[r.charCodeAt(e+1)]<<12|rt[r.charCodeAt(e+2)]<<6|rt[r.charCodeAt(e+3)],o[c++]=i>>16&255,o[c++]=i>>8&255,o[c++]=i&255;return s===2?(i=rt[r.charCodeAt(e)]<<2|rt[r.charCodeAt(e+1)]>>4,o[c++]=i&255):s===1&&(i=rt[r.charCodeAt(e)]<<10|rt[r.charCodeAt(e+1)]<<4|rt[r.charCodeAt(e+2)]>>2,o[c++]=i>>8&255,o[c++]=i&255),o}function bc(r){return mt[r>>18&63]+mt[r>>12&63]+mt[r>>6&63]+mt[r&63]}function wc(r,e,t){for(var n,i=[],s=e;s<t;s+=3)n=(r[s]<<16)+(r[s+1]<<8)+r[s+2],i.push(bc(n));return i.join("")}function bs(r){Kn||xs();for(var e,t=r.length,n=t%3,i="",s=[],o=16383,f=0,c=t-n;f<c;f+=o)s.push(wc(r,f,f+o>c?c:f+o));return n===1?(e=r[t-1],i+=mt[e>>2],i+=mt[e<<4&63],i+="=="):n===2&&(e=(r[t-2]<<8)+r[t-1],i+=mt[e>>10],i+=mt[e>>4&63],i+=mt[e<<2&63],i+="="),s.push(i),s.join("")}function Yr(r,e,t,n,i){var s,o,f=i*8-n-1,c=(1<<f)-1,m=c>>1,S=-7,p=t?i-1:0,F=t?-1:1,v=r[e+p];for(p+=F,s=v&(1<<-S)-1,v>>=-S,S+=f;S>0;s=s*256+r[e+p],p+=F,S-=8);for(o=s&(1<<-S)-1,s>>=-S,S+=n;S>0;o=o*256+r[e+p],p+=F,S-=8);if(s===0)s=1-m;else{if(s===c)return o?NaN:(v?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-m}return(v?-1:1)*o*Math.pow(2,s-n)}function Es(r,e,t,n,i,s){var o,f,c,m=s*8-i-1,S=(1<<m)-1,p=S>>1,F=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,v=n?0:s-1,u=n?1:-1,B=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(f=isNaN(e)?1:0,o=S):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+p>=1?e+=F/c:e+=F*Math.pow(2,1-p),e*c>=2&&(o++,c/=2),o+p>=S?(f=0,o=S):o+p>=1?(f=(e*c-1)*Math.pow(2,i),o=o+p):(f=e*Math.pow(2,p-1)*Math.pow(2,i),o=0));i>=8;r[t+v]=f&255,v+=u,f/=256,i-=8);for(o=o<<i|f,m+=i;m>0;r[t+v]=o&255,v+=u,o/=256,m-=8);r[t+v-u]|=B*128}function Cr(){return q.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function xt(r,e){if(Cr()<e)throw new RangeError("Invalid typed array length");return q.TYPED_ARRAY_SUPPORT?(r=new Uint8Array(e),r.__proto__=q.prototype):(r===null&&(r=new q(e)),r.length=e),r}function q(r,e,t){if(!q.TYPED_ARRAY_SUPPORT&&!(this instanceof q))return new q(r,e,t);if(typeof r=="number"){if(typeof e=="string")throw new Error("If encoding is specified then the first argument must be a string");return Wn(this,r)}return Is(this,r,e,t)}function Is(r,e,t,n){if(typeof e=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer?vc(r,e,t,n):typeof e=="string"?_c(r,e,t):Ic(r,e)}function As(r){if(typeof r!="number")throw new TypeError('"size" argument must be a number');if(r<0)throw new RangeError('"size" argument must not be negative')}function Ec(r,e,t,n){return As(e),e<=0?xt(r,e):t!==void 0?typeof n=="string"?xt(r,e).fill(t,n):xt(r,e).fill(t):xt(r,e)}function Wn(r,e){if(As(e),r=xt(r,e<0?0:Xn(e)|0),!q.TYPED_ARRAY_SUPPORT)for(var t=0;t<e;++t)r[t]=0;return r}function _c(r,e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!q.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var n=Bs(e,t)|0;r=xt(r,n);var i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function Zn(r,e){var t=e.length<0?0:Xn(e.length)|0;r=xt(r,t);for(var n=0;n<t;n+=1)r[n]=e[n]&255;return r}function vc(r,e,t,n){if(e.byteLength,t<0||e.byteLength<t)throw new RangeError("'offset' is out of bounds");if(e.byteLength<t+(n||0))throw new RangeError("'length' is out of bounds");return t===void 0&&n===void 0?e=new Uint8Array(e):n===void 0?e=new Uint8Array(e,t):e=new Uint8Array(e,t,n),q.TYPED_ARRAY_SUPPORT?(r=e,r.__proto__=q.prototype):r=Zn(r,e),r}function Ic(r,e){if(gt(e)){var t=Xn(e.length)|0;return r=xt(r,t),r.length===0||e.copy(r,0,0,t),r}if(e){if(typeof ArrayBuffer<"u"&&e.buffer instanceof ArrayBuffer||"length"in e)return typeof e.length!="number"||Yc(e.length)?xt(r,0):Zn(r,e);if(e.type==="Buffer"&&_s(e.data))return Zn(r,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Xn(r){if(r>=Cr())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Cr().toString(16)+" bytes");return r|0}function Ac(r){return+r!=r&&(r=0),q.alloc(+r)}function gt(r){return!!(r!=null&&r._isBuffer)}function Bs(r,e){if(gt(r))return r.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(r)||r instanceof ArrayBuffer))return r.byteLength;typeof r!="string"&&(r=""+r);var t=r.length;if(t===0)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":case void 0:return Vr(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Fs(r).length;default:if(n)return Vr(r).length;e=(""+e).toLowerCase(),n=!0}}function Bc(r,e,t){var n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return Mc(this,e,t);case"utf8":case"utf-8":return Ns(this,e,t);case"ascii":return Pc(this,e,t);case"latin1":case"binary":return Lc(this,e,t);case"base64":return Oc(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Dc(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}function Gt(r,e,t){var n=r[e];r[e]=r[t],r[t]=n}function Ss(r,e,t,n,i){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,isNaN(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(i)return-1;t=r.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof e=="string"&&(e=q.from(e,n)),gt(e))return e.length===0?-1:ws(r,e,t,n,i);if(typeof e=="number")return e=e&255,q.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):ws(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}function ws(r,e,t,n,i){var s=1,o=r.length,f=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;s=2,o/=2,f/=2,t/=2}function c(v,u){return s===1?v[u]:v.readUInt16BE(u*s)}var m;if(i){var S=-1;for(m=t;m<o;m++)if(c(r,m)===c(e,S===-1?0:m-S)){if(S===-1&&(S=m),m-S+1===f)return S*s}else S!==-1&&(m-=m-S),S=-1}else for(t+f>o&&(t=o-f),m=t;m>=0;m--){for(var p=!0,F=0;F<f;F++)if(c(r,m+F)!==c(e,F)){p=!1;break}if(p)return m}return-1}function Sc(r,e,t,n){t=Number(t)||0;var i=r.length-t;n?(n=Number(n),n>i&&(n=i)):n=i;var s=e.length;if(s%2!==0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var f=parseInt(e.substr(o*2,2),16);if(isNaN(f))return o;r[t+o]=f}return o}function Tc(r,e,t,n){return jr(Vr(e,r.length-t),r,t,n)}function Ts(r,e,t,n){return jr(Cc(e),r,t,n)}function Nc(r,e,t,n){return Ts(r,e,t,n)}function Uc(r,e,t,n){return jr(Fs(e),r,t,n)}function Rc(r,e,t,n){return jr(Vc(e,r.length-t),r,t,n)}function Oc(r,e,t){return e===0&&t===r.length?bs(r):bs(r.slice(e,t))}function Ns(r,e,t){t=Math.min(r.length,t);for(var n=[],i=e;i<t;){var s=r[i],o=null,f=s>239?4:s>223?3:s>191?2:1;if(i+f<=t){var c,m,S,p;switch(f){case 1:s<128&&(o=s);break;case 2:c=r[i+1],(c&192)===128&&(p=(s&31)<<6|c&63,p>127&&(o=p));break;case 3:c=r[i+1],m=r[i+2],(c&192)===128&&(m&192)===128&&(p=(s&15)<<12|(c&63)<<6|m&63,p>2047&&(p<55296||p>57343)&&(o=p));break;case 4:c=r[i+1],m=r[i+2],S=r[i+3],(c&192)===128&&(m&192)===128&&(S&192)===128&&(p=(s&15)<<18|(c&63)<<12|(m&63)<<6|S&63,p>65535&&p<1114112&&(o=p))}}o===null?(o=65533,f=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=f}return Fc(n)}function Fc(r){var e=r.length;if(e<=ys)return String.fromCharCode.apply(String,r);for(var t="",n=0;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=ys));return t}function Pc(r,e,t){var n="";t=Math.min(r.length,t);for(var i=e;i<t;++i)n+=String.fromCharCode(r[i]&127);return n}function Lc(r,e,t){var n="";t=Math.min(r.length,t);for(var i=e;i<t;++i)n+=String.fromCharCode(r[i]);return n}function Mc(r,e,t){var n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);for(var i="",s=e;s<t;++s)i+=Gc(r[s]);return i}function Dc(r,e,t){for(var n=r.slice(e,t),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}function Ce(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}function We(r,e,t,n,i,s){if(!gt(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(t+n>r.length)throw new RangeError("Index out of range")}function Hr(r,e,t,n){e<0&&(e=65535+e+1);for(var i=0,s=Math.min(r.length-t,2);i<s;++i)r[t+i]=(e&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}function zr(r,e,t,n){e<0&&(e=4294967295+e+1);for(var i=0,s=Math.min(r.length-t,4);i<s;++i)r[t+i]=e>>>(n?i:3-i)*8&255}function Us(r,e,t,n,i,s){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Rs(r,e,t,n,i){return i||Us(r,e,t,4),Es(r,e,t,n,23,4),t+4}function Os(r,e,t,n,i){return i||Us(r,e,t,8),Es(r,e,t,n,52,8),t+8}function qc(r){if(r=$c(r).replace(kc,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function $c(r){return r.trim?r.trim():r.replace(/^\s+|\s+$/g,"")}function Gc(r){return r<16?"0"+r.toString(16):r.toString(16)}function Vr(r,e){e=e||1/0;for(var t,n=r.length,i=null,s=[],o=0;o<n;++o){if(t=r.charCodeAt(o),t>55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,t<128){if((e-=1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}function Cc(r){for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function Vc(r,e){for(var t,n,i,s=[],o=0;o<r.length&&!((e-=2)<0);++o)t=r.charCodeAt(o),n=t>>8,i=t%256,s.push(i),s.push(n);return s}function Fs(r){return gc(qc(r))}function jr(r,e,t,n){for(var i=0;i<n&&!(i+t>=e.length||i>=r.length);++i)e[i+t]=r[i];return i}function Yc(r){return r!==r}function Ps(r){return r!=null&&(!!r._isBuffer||Ls(r)||Hc(r))}function Ls(r){return!!r.constructor&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function Hc(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&Ls(r.slice(0,0))}var mt,rt,mc,Kn,yc,_s,vs,xc,ys,kc,Ds=ic(()=>{mt=[],rt=[],mc=typeof Uint8Array<"u"?Uint8Array:Array,Kn=!1;yc={}.toString,_s=Array.isArray||function(r){return yc.call(r)=="[object Array]"};vs=50;q.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;xc=Cr();q.poolSize=8192;q._augment=function(r){return r.__proto__=q.prototype,r};q.from=function(r,e,t){return Is(null,r,e,t)};q.TYPED_ARRAY_SUPPORT&&(q.prototype.__proto__=Uint8Array.prototype,q.__proto__=Uint8Array);q.alloc=function(r,e,t){return Ec(null,r,e,t)};q.allocUnsafe=function(r){return Wn(null,r)};q.allocUnsafeSlow=function(r){return Wn(null,r)};q.isBuffer=Ps;q.compare=function(e,t){if(!gt(e)||!gt(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,i=t.length,s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==t[s]){n=e[s],i=t[s];break}return n<i?-1:i<n?1:0};q.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};q.concat=function(e,t){if(!_s(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return q.alloc(0);var n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var i=q.allocUnsafe(t),s=0;for(n=0;n<e.length;++n){var o=e[n];if(!gt(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,s),s+=o.length}return i};q.byteLength=Bs;q.prototype._isBuffer=!0;q.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Gt(this,t,t+1);return this};q.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Gt(this,t,t+3),Gt(this,t+1,t+2);return this};q.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Gt(this,t,t+7),Gt(this,t+1,t+6),Gt(this,t+2,t+5),Gt(this,t+3,t+4);return this};q.prototype.toString=function(){var e=this.length|0;return e===0?"":arguments.length===0?Ns(this,0,e):Bc.apply(this,arguments)};q.prototype.equals=function(e){if(!gt(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:q.compare(this,e)===0};q.prototype.inspect=function(){var e="",t=vs;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"};q.prototype.compare=function(e,t,n,i,s){if(!gt(e))throw new TypeError("Argument must be a Buffer");if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),t<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&t>=n)return 0;if(i>=s)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;for(var o=s-i,f=n-t,c=Math.min(o,f),m=this.slice(i,s),S=e.slice(t,n),p=0;p<c;++p)if(m[p]!==S[p]){o=m[p],f=S[p];break}return o<f?-1:f<o?1:0};q.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};q.prototype.indexOf=function(e,t,n){return Ss(this,e,t,n,!0)};q.prototype.lastIndexOf=function(e,t,n){return Ss(this,e,t,n,!1)};q.prototype.write=function(e,t,n,i){if(t===void 0)i="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")i=t,n=this.length,t=0;else if(isFinite(t))t=t|0,isFinite(n)?(n=n|0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s=this.length-t;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return Sc(this,e,t,n);case"utf8":case"utf-8":return Tc(this,e,t,n);case"ascii":return Ts(this,e,t,n);case"latin1":case"binary":return Nc(this,e,t,n);case"base64":return Uc(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rc(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};q.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};ys=4096;q.prototype.slice=function(e,t){var n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);var i;if(q.TYPED_ARRAY_SUPPORT)i=this.subarray(e,t),i.__proto__=q.prototype;else{var s=t-e;i=new q(s,void 0);for(var o=0;o<s;++o)i[o]=this[o+e]}return i};q.prototype.readUIntLE=function(e,t,n){e=e|0,t=t|0,n||Ce(e,t,this.length);for(var i=this[e],s=1,o=0;++o<t&&(s*=256);)i+=this[e+o]*s;return i};q.prototype.readUIntBE=function(e,t,n){e=e|0,t=t|0,n||Ce(e,t,this.length);for(var i=this[e+--t],s=1;t>0&&(s*=256);)i+=this[e+--t]*s;return i};q.prototype.readUInt8=function(e,t){return t||Ce(e,1,this.length),this[e]};q.prototype.readUInt16LE=function(e,t){return t||Ce(e,2,this.length),this[e]|this[e+1]<<8};q.prototype.readUInt16BE=function(e,t){return t||Ce(e,2,this.length),this[e]<<8|this[e+1]};q.prototype.readUInt32LE=function(e,t){return t||Ce(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};q.prototype.readUInt32BE=function(e,t){return t||Ce(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};q.prototype.readIntLE=function(e,t,n){e=e|0,t=t|0,n||Ce(e,t,this.length);for(var i=this[e],s=1,o=0;++o<t&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*t)),i};q.prototype.readIntBE=function(e,t,n){e=e|0,t=t|0,n||Ce(e,t,this.length);for(var i=t,s=1,o=this[e+--i];i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*t)),o};q.prototype.readInt8=function(e,t){return t||Ce(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};q.prototype.readInt16LE=function(e,t){t||Ce(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};q.prototype.readInt16BE=function(e,t){t||Ce(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};q.prototype.readInt32LE=function(e,t){return t||Ce(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};q.prototype.readInt32BE=function(e,t){return t||Ce(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};q.prototype.readFloatLE=function(e,t){return t||Ce(e,4,this.length),Yr(this,e,!0,23,4)};q.prototype.readFloatBE=function(e,t){return t||Ce(e,4,this.length),Yr(this,e,!1,23,4)};q.prototype.readDoubleLE=function(e,t){return t||Ce(e,8,this.length),Yr(this,e,!0,52,8)};q.prototype.readDoubleBE=function(e,t){return t||Ce(e,8,this.length),Yr(this,e,!1,52,8)};q.prototype.writeUIntLE=function(e,t,n,i){if(e=+e,t=t|0,n=n|0,!i){var s=Math.pow(2,8*n)-1;We(this,e,t,n,s,0)}var o=1,f=0;for(this[t]=e&255;++f<n&&(o*=256);)this[t+f]=e/o&255;return t+n};q.prototype.writeUIntBE=function(e,t,n,i){if(e=+e,t=t|0,n=n|0,!i){var s=Math.pow(2,8*n)-1;We(this,e,t,n,s,0)}var o=n-1,f=1;for(this[t+o]=e&255;--o>=0&&(f*=256);)this[t+o]=e/f&255;return t+n};q.prototype.writeUInt8=function(e,t,n){return e=+e,t=t|0,n||We(this,e,t,1,255,0),q.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e&255,t+1};q.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t|0,n||We(this,e,t,2,65535,0),q.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Hr(this,e,t,!0),t+2};q.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t|0,n||We(this,e,t,2,65535,0),q.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Hr(this,e,t,!1),t+2};q.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t|0,n||We(this,e,t,4,4294967295,0),q.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255):zr(this,e,t,!0),t+4};q.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t|0,n||We(this,e,t,4,4294967295,0),q.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):zr(this,e,t,!1),t+4};q.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t=t|0,!i){var s=Math.pow(2,8*n-1);We(this,e,t,n,s-1,-s)}var o=0,f=1,c=0;for(this[t]=e&255;++o<n&&(f*=256);)e<0&&c===0&&this[t+o-1]!==0&&(c=1),this[t+o]=(e/f>>0)-c&255;return t+n};q.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t=t|0,!i){var s=Math.pow(2,8*n-1);We(this,e,t,n,s-1,-s)}var o=n-1,f=1,c=0;for(this[t+o]=e&255;--o>=0&&(f*=256);)e<0&&c===0&&this[t+o+1]!==0&&(c=1),this[t+o]=(e/f>>0)-c&255;return t+n};q.prototype.writeInt8=function(e,t,n){return e=+e,t=t|0,n||We(this,e,t,1,127,-128),q.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=e&255,t+1};q.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t|0,n||We(this,e,t,2,32767,-32768),q.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Hr(this,e,t,!0),t+2};q.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t|0,n||We(this,e,t,2,32767,-32768),q.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Hr(this,e,t,!1),t+2};q.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t|0,n||We(this,e,t,4,2147483647,-2147483648),q.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):zr(this,e,t,!0),t+4};q.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t|0,n||We(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),q.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):zr(this,e,t,!1),t+4};q.prototype.writeFloatLE=function(e,t,n){return Rs(this,e,t,!0,n)};q.prototype.writeFloatBE=function(e,t,n){return Rs(this,e,t,!1,n)};q.prototype.writeDoubleLE=function(e,t,n){return Os(this,e,t,!0,n)};q.prototype.writeDoubleBE=function(e,t,n){return Os(this,e,t,!1,n)};q.prototype.copy=function(e,t,n,i){if(n||(n=0),!i&&i!==0&&(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-n&&(i=e.length-t+n);var s=i-n,o;if(this===e&&n<t&&t<i)for(o=s-1;o>=0;--o)e[o+t]=this[o+n];else if(s<1e3||!q.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+s),t);return s};q.prototype.fill=function(e,t,n,i){if(typeof e=="string"){if(typeof t=="string"?(i=t,t=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),e.length===1){var s=e.charCodeAt(0);s<256&&(e=s)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!q.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof e=="number"&&(e=e&255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);var o;if(typeof e=="number")for(o=t;o<n;++o)this[o]=e;else{var f=gt(e)?e:Vr(new q(e,i).toString()),c=f.length;for(o=0;o<n-t;++o)this[o+t]=f[o%c]}return this};kc=/[^+\/0-9A-Za-z-_]/g});var hr=$e((a0,Zr)=>{var Ct=(Ds(),sc(Ms));if(Ct&&Ct.default){Zr.exports=Ct.default;for(let r in Ct)Zr.exports[r]=Ct[r]}else Ct&&(Zr.exports=Ct)});var ks=$e(Jn=>{Jn.read=function(r,e,t,n,i){var s,o,f=i*8-n-1,c=(1<<f)-1,m=c>>1,S=-7,p=t?i-1:0,F=t?-1:1,v=r[e+p];for(p+=F,s=v&(1<<-S)-1,v>>=-S,S+=f;S>0;s=s*256+r[e+p],p+=F,S-=8);for(o=s&(1<<-S)-1,s>>=-S,S+=n;S>0;o=o*256+r[e+p],p+=F,S-=8);if(s===0)s=1-m;else{if(s===c)return o?NaN:(v?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-m}return(v?-1:1)*o*Math.pow(2,s-n)};Jn.write=function(r,e,t,n,i,s){var o,f,c,m=s*8-i-1,S=(1<<m)-1,p=S>>1,F=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,v=n?0:s-1,u=n?1:-1,B=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(f=isNaN(e)?1:0,o=S):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+p>=1?e+=F/c:e+=F*Math.pow(2,1-p),e*c>=2&&(o++,c/=2),o+p>=S?(f=0,o=S):o+p>=1?(f=(e*c-1)*Math.pow(2,i),o=o+p):(f=e*Math.pow(2,p-1)*Math.pow(2,i),o=0));i>=8;r[t+v]=f&255,v+=u,f/=256,i-=8);for(o=o<<i|f,m+=i;m>0;r[t+v]=o&255,v+=u,o/=256,m-=8);r[t+v-u]|=B*128}});var dr=$e((qs,Kr)=>{(function(r){"use strict";var e,t=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",f=1e14,c=14,m=9007199254740991,S=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,F=1e9;function v(E){var L,C,V,$=O.prototype={constructor:O,toString:null,valueOf:null},ee=new O(1),J=20,oe=4,g=-7,_=21,R=-1e7,k=1e7,K=!1,X=1,se=0,De={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},Ne="0123456789abcdefghijklmnopqrstuvwxyz",H=!0;function O(a,l){var h,A,y,x,U,b,I,N,T=this;if(!(T instanceof O))return new O(a,l);if(l==null){if(a&&a._isBigNumber===!0){T.s=a.s,!a.c||a.e>k?T.c=T.e=null:a.e<R?T.c=[T.e=0]:(T.e=a.e,T.c=a.c.slice());return}if((b=typeof a=="number")&&a*0==0){if(T.s=1/a<0?(a=-a,-1):1,a===~~a){for(x=0,U=a;U>=10;U/=10,x++);x>k?T.c=T.e=null:(T.e=x,T.c=[a]);return}N=String(a)}else{if(!t.test(N=String(a)))return V(T,N,b);T.s=N.charCodeAt(0)==45?(N=N.slice(1),-1):1}(x=N.indexOf("."))>-1&&(N=N.replace(".","")),(U=N.search(/e/i))>0?(x<0&&(x=U),x+=+N.slice(U+1),N=N.substring(0,U)):x<0&&(x=N.length)}else{if(P(l,2,Ne.length,"Base"),l==10&&H)return T=new O(a),ae(T,J+T.e+1,oe);if(N=String(a),b=typeof a=="number"){if(a*0!=0)return V(T,N,b,l);if(T.s=1/a<0?(N=N.slice(1),-1):1,O.DEBUG&&N.replace(/^0\.0*|\./,"").length>15)throw Error(o+a)}else T.s=N.charCodeAt(0)===45?(N=N.slice(1),-1):1;for(h=Ne.slice(0,l),x=U=0,I=N.length;U<I;U++)if(h.indexOf(A=N.charAt(U))<0){if(A=="."){if(U>x){x=I;continue}}else if(!y&&(N==N.toUpperCase()&&(N=N.toLowerCase())||N==N.toLowerCase()&&(N=N.toUpperCase()))){y=!0,U=-1,x=0;continue}return V(T,String(a),b,l)}b=!1,N=C(N,l,10,T.s),(x=N.indexOf("."))>-1?N=N.replace(".",""):x=N.length}for(U=0;N.charCodeAt(U)===48;U++);for(I=N.length;N.charCodeAt(--I)===48;);if(N=N.slice(U,++I)){if(I-=U,b&&O.DEBUG&&I>15&&(a>m||a!==i(a)))throw Error(o+T.s*a);if((x=x-U-1)>k)T.c=T.e=null;else if(x<R)T.c=[T.e=0];else{if(T.e=x,T.c=[],U=(x+1)%c,x<0&&(U+=c),U<I){for(U&&T.c.push(+N.slice(0,U)),I-=c;U<I;)T.c.push(+N.slice(U,U+=c));U=c-(N=N.slice(U)).length}else U-=I;for(;U--;N+="0");T.c.push(+N)}}else T.c=[T.e=0]}O.clone=v,O.ROUND_UP=0,O.ROUND_DOWN=1,O.ROUND_CEIL=2,O.ROUND_FLOOR=3,O.ROUND_HALF_UP=4,O.ROUND_HALF_DOWN=5,O.ROUND_HALF_EVEN=6,O.ROUND_HALF_CEIL=7,O.ROUND_HALF_FLOOR=8,O.EUCLID=9,O.config=O.set=function(a){var l,h;if(a!=null)if(typeof a=="object"){if(a.hasOwnProperty(l="DECIMAL_PLACES")&&(h=a[l],P(h,0,F,l),J=h),a.hasOwnProperty(l="ROUNDING_MODE")&&(h=a[l],P(h,0,8,l),oe=h),a.hasOwnProperty(l="EXPONENTIAL_AT")&&(h=a[l],h&&h.pop?(P(h[0],-F,0,l),P(h[1],0,F,l),g=h[0],_=h[1]):(P(h,-F,F,l),g=-(_=h<0?-h:h))),a.hasOwnProperty(l="RANGE"))if(h=a[l],h&&h.pop)P(h[0],-F,-1,l),P(h[1],1,F,l),R=h[0],k=h[1];else if(P(h,-F,F,l),h)R=-(k=h<0?-h:h);else throw Error(s+l+" cannot be zero: "+h);if(a.hasOwnProperty(l="CRYPTO"))if(h=a[l],h===!!h)if(h)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))K=h;else throw K=!h,Error(s+"crypto unavailable");else K=h;else throw Error(s+l+" not true or false: "+h);if(a.hasOwnProperty(l="MODULO_MODE")&&(h=a[l],P(h,0,9,l),X=h),a.hasOwnProperty(l="POW_PRECISION")&&(h=a[l],P(h,0,F,l),se=h),a.hasOwnProperty(l="FORMAT"))if(h=a[l],typeof h=="object")De=h;else throw Error(s+l+" not an object: "+h);if(a.hasOwnProperty(l="ALPHABET"))if(h=a[l],typeof h=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(h))H=h.slice(0,10)=="0123456789",Ne=h;else throw Error(s+l+" invalid: "+h)}else throw Error(s+"Object expected: "+a);return{DECIMAL_PLACES:J,ROUNDING_MODE:oe,EXPONENTIAL_AT:[g,_],RANGE:[R,k],CRYPTO:K,MODULO_MODE:X,POW_PRECISION:se,FORMAT:De,ALPHABET:Ne}},O.isBigNumber=function(a){if(!a||a._isBigNumber!==!0)return!1;if(!O.DEBUG)return!0;var l,h,A=a.c,y=a.e,x=a.s;e:if({}.toString.call(A)=="[object Array]"){if((x===1||x===-1)&&y>=-F&&y<=F&&y===i(y)){if(A[0]===0){if(y===0&&A.length===1)return!0;break e}if(l=(y+1)%c,l<1&&(l+=c),String(A[0]).length==l){for(l=0;l<A.length;l++)if(h=A[l],h<0||h>=f||h!==i(h))break e;if(h!==0)return!0}}}else if(A===null&&y===null&&(x===null||x===1||x===-1))return!0;throw Error(s+"Invalid BigNumber: "+a)},O.maximum=O.max=function(){return te(arguments,-1)},O.minimum=O.min=function(){return te(arguments,1)},O.random=function(){var a=9007199254740992,l=Math.random()*a&2097151?function(){return i(Math.random()*a)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(h){var A,y,x,U,b,I=0,N=[],T=new O(ee);if(h==null?h=J:P(h,0,F),U=n(h/c),K)if(crypto.getRandomValues){for(A=crypto.getRandomValues(new Uint32Array(U*=2));I<U;)b=A[I]*131072+(A[I+1]>>>11),b>=9e15?(y=crypto.getRandomValues(new Uint32Array(2)),A[I]=y[0],A[I+1]=y[1]):(N.push(b%1e14),I+=2);I=U/2}else if(crypto.randomBytes){for(A=crypto.randomBytes(U*=7);I<U;)b=(A[I]&31)*281474976710656+A[I+1]*1099511627776+A[I+2]*4294967296+A[I+3]*16777216+(A[I+4]<<16)+(A[I+5]<<8)+A[I+6],b>=9e15?crypto.randomBytes(7).copy(A,I):(N.push(b%1e14),I+=7);I=U/7}else throw K=!1,Error(s+"crypto unavailable");if(!K)for(;I<U;)b=l(),b<9e15&&(N[I++]=b%1e14);for(U=N[--I],h%=c,U&&h&&(b=S[c-h],N[I]=i(U/b)*b);N[I]===0;N.pop(),I--);if(I<0)N=[x=0];else{for(x=-1;N[0]===0;N.splice(0,1),x-=c);for(I=1,b=N[0];b>=10;b/=10,I++);I<c&&(x-=c-I)}return T.e=x,T.c=N,T}}(),O.sum=function(){for(var a=1,l=arguments,h=new O(l[0]);a<l.length;)h=h.plus(l[a++]);return h},C=function(){var a="0123456789";function l(h,A,y,x){for(var U,b=[0],I,N=0,T=h.length;N<T;){for(I=b.length;I--;b[I]*=A);for(b[0]+=x.indexOf(h.charAt(N++)),U=0;U<b.length;U++)b[U]>y-1&&(b[U+1]==null&&(b[U+1]=0),b[U+1]+=b[U]/y|0,b[U]%=y)}return b.reverse()}return function(h,A,y,x,U){var b,I,N,T,M,Y,re,he,xe=h.indexOf("."),Ae=J,fe=oe;for(xe>=0&&(T=se,se=0,h=h.replace(".",""),he=new O(A),Y=he.pow(h.length-xe),se=T,he.c=l(Z(B(Y.c),Y.e,"0"),10,y,a),he.e=he.c.length),re=l(h,A,y,U?(b=Ne,a):(b=a,Ne)),N=T=re.length;re[--T]==0;re.pop());if(!re[0])return b.charAt(0);if(xe<0?--N:(Y.c=re,Y.e=N,Y.s=x,Y=L(Y,he,Ae,fe,y),re=Y.c,M=Y.r,N=Y.e),I=N+Ae+1,xe=re[I],T=y/2,M=M||I<0||re[I+1]!=null,M=fe<4?(xe!=null||M)&&(fe==0||fe==(Y.s<0?3:2)):xe>T||xe==T&&(fe==4||M||fe==6&&re[I-1]&1||fe==(Y.s<0?8:7)),I<1||!re[0])h=M?Z(b.charAt(1),-Ae,b.charAt(0)):b.charAt(0);else{if(re.length=I,M)for(--y;++re[--I]>y;)re[I]=0,I||(++N,re=[1].concat(re));for(T=re.length;!re[--T];);for(xe=0,h="";xe<=T;h+=b.charAt(re[xe++]));h=Z(h,N,b.charAt(0))}return h}}(),L=function(){function a(A,y,x){var U,b,I,N,T=0,M=A.length,Y=y%p,re=y/p|0;for(A=A.slice();M--;)I=A[M]%p,N=A[M]/p|0,U=re*I+N*Y,b=Y*I+U%p*p+T,T=(b/x|0)+(U/p|0)+re*N,A[M]=b%x;return T&&(A=[T].concat(A)),A}function l(A,y,x,U){var b,I;if(x!=U)I=x>U?1:-1;else for(b=I=0;b<x;b++)if(A[b]!=y[b]){I=A[b]>y[b]?1:-1;break}return I}function h(A,y,x,U){for(var b=0;x--;)A[x]-=b,b=A[x]<y[x]?1:0,A[x]=b*U+A[x]-y[x];for(;!A[0]&&A.length>1;A.splice(0,1));}return function(A,y,x,U,b){var I,N,T,M,Y,re,he,xe,Ae,fe,ie,ke,jt,cr,ur,tt,pe,Ke=A.s==y.s?1:-1,Ye=A.c,Ee=y.c;if(!Ye||!Ye[0]||!Ee||!Ee[0])return new O(!A.s||!y.s||(Ye?Ee&&Ye[0]==Ee[0]:!Ee)?NaN:Ye&&Ye[0]==0||!Ee?Ke*0:Ke/0);for(xe=new O(Ke),Ae=xe.c=[],N=A.e-y.e,Ke=x+N+1,b||(b=f,N=u(A.e/c)-u(y.e/c),Ke=Ke/c|0),T=0;Ee[T]==(Ye[T]||0);T++);if(Ee[T]>(Ye[T]||0)&&N--,Ke<0)Ae.push(1),M=!0;else{for(cr=Ye.length,tt=Ee.length,T=0,Ke+=2,Y=i(b/(Ee[0]+1)),Y>1&&(Ee=a(Ee,Y,b),Ye=a(Ye,Y,b),tt=Ee.length,cr=Ye.length),jt=tt,fe=Ye.slice(0,tt),ie=fe.length;ie<tt;fe[ie++]=0);pe=Ee.slice(),pe=[0].concat(pe),ur=Ee[0],Ee[1]>=b/2&&ur++;do{if(Y=0,I=l(Ee,fe,tt,ie),I<0){if(ke=fe[0],tt!=ie&&(ke=ke*b+(fe[1]||0)),Y=i(ke/ur),Y>1)for(Y>=b&&(Y=b-1),re=a(Ee,Y,b),he=re.length,ie=fe.length;l(re,fe,he,ie)==1;)Y--,h(re,tt<he?pe:Ee,he,b),he=re.length,I=1;else Y==0&&(I=Y=1),re=Ee.slice(),he=re.length;if(he<ie&&(re=[0].concat(re)),h(fe,re,ie,b),ie=fe.length,I==-1)for(;l(Ee,fe,tt,ie)<1;)Y++,h(fe,tt<ie?pe:Ee,ie,b),ie=fe.length}else I===0&&(Y++,fe=[0]);Ae[T++]=Y,fe[0]?fe[ie++]=Ye[jt]||0:(fe=[Ye[jt]],ie=1)}while((jt++<cr||fe[0]!=null)&&Ke--);M=fe[0]!=null,Ae[0]||Ae.splice(0,1)}if(b==f){for(T=1,Ke=Ae[0];Ke>=10;Ke/=10,T++);ae(xe,x+(xe.e=T+N*c-1)+1,U,M)}else xe.e=N,xe.r=+M;return xe}}();function d(a,l,h,A){var y,x,U,b,I;if(h==null?h=oe:P(h,0,8),!a.c)return a.toString();if(y=a.c[0],U=a.e,l==null)I=B(a.c),I=A==1||A==2&&(U<=g||U>=_)?z(I,U):Z(I,U,"0");else if(a=ae(new O(a),l,h),x=a.e,I=B(a.c),b=I.length,A==1||A==2&&(l<=x||x<=g)){for(;b<l;I+="0",b++);I=z(I,x)}else if(l-=U,I=Z(I,x,"0"),x+1>b){if(--l>0)for(I+=".";l--;I+="0");}else if(l+=x-b,l>0)for(x+1==b&&(I+=".");l--;I+="0");return a.s<0&&y?"-"+I:I}function te(a,l){for(var h,A,y=1,x=new O(a[0]);y<a.length;y++)A=new O(a[y]),(!A.s||(h=D(x,A))===l||h===0&&x.s===l)&&(x=A);return x}function ne(a,l,h){for(var A=1,y=l.length;!l[--y];l.pop());for(y=l[0];y>=10;y/=10,A++);return(h=A+h*c-1)>k?a.c=a.e=null:h<R?a.c=[a.e=0]:(a.e=h,a.c=l),a}V=function(){var a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,l=/^([^.]+)\.$/,h=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,y=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(x,U,b,I){var N,T=b?U:U.replace(y,"");if(A.test(T))x.s=isNaN(T)?null:T<0?-1:1;else{if(!b&&(T=T.replace(a,function(M,Y,re){return N=(re=re.toLowerCase())=="x"?16:re=="b"?2:8,!I||I==N?Y:M}),I&&(N=I,T=T.replace(l,"$1").replace(h,"0.$1")),U!=T))return new O(T,N);if(O.DEBUG)throw Error(s+"Not a"+(I?" base "+I:"")+" number: "+U);x.s=null}x.c=x.e=null}}();function ae(a,l,h,A){var y,x,U,b,I,N,T,M=a.c,Y=S;if(M){e:{for(y=1,b=M[0];b>=10;b/=10,y++);if(x=l-y,x<0)x+=c,U=l,I=M[N=0],T=i(I/Y[y-U-1]%10);else if(N=n((x+1)/c),N>=M.length)if(A){for(;M.length<=N;M.push(0));I=T=0,y=1,x%=c,U=x-c+1}else break e;else{for(I=b=M[N],y=1;b>=10;b/=10,y++);x%=c,U=x-c+y,T=U<0?0:i(I/Y[y-U-1]%10)}if(A=A||l<0||M[N+1]!=null||(U<0?I:I%Y[y-U-1]),A=h<4?(T||A)&&(h==0||h==(a.s<0?3:2)):T>5||T==5&&(h==4||A||h==6&&(x>0?U>0?I/Y[y-U]:0:M[N-1])%10&1||h==(a.s<0?8:7)),l<1||!M[0])return M.length=0,A?(l-=a.e+1,M[0]=Y[(c-l%c)%c],a.e=-l||0):M[0]=a.e=0,a;if(x==0?(M.length=N,b=1,N--):(M.length=N+1,b=Y[c-x],M[N]=U>0?i(I/Y[y-U]%Y[U])*b:0),A)for(;;)if(N==0){for(x=1,U=M[0];U>=10;U/=10,x++);for(U=M[0]+=b,b=1;U>=10;U/=10,b++);x!=b&&(a.e++,M[0]==f&&(M[0]=1));break}else{if(M[N]+=b,M[N]!=f)break;M[N--]=0,b=1}for(x=M.length;M[--x]===0;M.pop());}a.e>k?a.c=a.e=null:a.e<R&&(a.c=[a.e=0])}return a}function j(a){var l,h=a.e;return h===null?a.toString():(l=B(a.c),l=h<=g||h>=_?z(l,h):Z(l,h,"0"),a.s<0?"-"+l:l)}return $.absoluteValue=$.abs=function(){var a=new O(this);return a.s<0&&(a.s=1),a},$.comparedTo=function(a,l){return D(this,new O(a,l))},$.decimalPlaces=$.dp=function(a,l){var h,A,y,x=this;if(a!=null)return P(a,0,F),l==null?l=oe:P(l,0,8),ae(new O(x),a+x.e+1,l);if(!(h=x.c))return null;if(A=((y=h.length-1)-u(this.e/c))*c,y=h[y])for(;y%10==0;y/=10,A--);return A<0&&(A=0),A},$.dividedBy=$.div=function(a,l){return L(this,new O(a,l),J,oe)},$.dividedToIntegerBy=$.idiv=function(a,l){return L(this,new O(a,l),0,1)},$.exponentiatedBy=$.pow=function(a,l){var h,A,y,x,U,b,I,N,T,M=this;if(a=new O(a),a.c&&!a.isInteger())throw Error(s+"Exponent not an integer: "+j(a));if(l!=null&&(l=new O(l)),b=a.e>14,!M.c||!M.c[0]||M.c[0]==1&&!M.e&&M.c.length==1||!a.c||!a.c[0])return T=new O(Math.pow(+j(M),b?a.s*(2-G(a)):+j(a))),l?T.mod(l):T;if(I=a.s<0,l){if(l.c?!l.c[0]:!l.s)return new O(NaN);A=!I&&M.isInteger()&&l.isInteger(),A&&(M=M.mod(l))}else{if(a.e>9&&(M.e>0||M.e<-1||(M.e==0?M.c[0]>1||b&&M.c[1]>=24e7:M.c[0]<8e13||b&&M.c[0]<=9999975e7)))return x=M.s<0&&G(a)?-0:0,M.e>-1&&(x=1/x),new O(I?1/x:x);se&&(x=n(se/c+2))}for(b?(h=new O(.5),I&&(a.s=1),N=G(a)):(y=Math.abs(+j(a)),N=y%2),T=new O(ee);;){if(N){if(T=T.times(M),!T.c)break;x?T.c.length>x&&(T.c.length=x):A&&(T=T.mod(l))}if(y){if(y=i(y/2),y===0)break;N=y%2}else if(a=a.times(h),ae(a,a.e+1,1),a.e>14)N=G(a);else{if(y=+j(a),y===0)break;N=y%2}M=M.times(M),x?M.c&&M.c.length>x&&(M.c.length=x):A&&(M=M.mod(l))}return A?T:(I&&(T=ee.div(T)),l?T.mod(l):x?ae(T,se,oe,U):T)},$.integerValue=function(a){var l=new O(this);return a==null?a=oe:P(a,0,8),ae(l,l.e+1,a)},$.isEqualTo=$.eq=function(a,l){return D(this,new O(a,l))===0},$.isFinite=function(){return!!this.c},$.isGreaterThan=$.gt=function(a,l){return D(this,new O(a,l))>0},$.isGreaterThanOrEqualTo=$.gte=function(a,l){return(l=D(this,new O(a,l)))===1||l===0},$.isInteger=function(){return!!this.c&&u(this.e/c)>this.c.length-2},$.isLessThan=$.lt=function(a,l){return D(this,new O(a,l))<0},$.isLessThanOrEqualTo=$.lte=function(a,l){return(l=D(this,new O(a,l)))===-1||l===0},$.isNaN=function(){return!this.s},$.isNegative=function(){return this.s<0},$.isPositive=function(){return this.s>0},$.isZero=function(){return!!this.c&&this.c[0]==0},$.minus=function(a,l){var h,A,y,x,U=this,b=U.s;if(a=new O(a,l),l=a.s,!b||!l)return new O(NaN);if(b!=l)return a.s=-l,U.plus(a);var I=U.e/c,N=a.e/c,T=U.c,M=a.c;if(!I||!N){if(!T||!M)return T?(a.s=-l,a):new O(M?U:NaN);if(!T[0]||!M[0])return M[0]?(a.s=-l,a):new O(T[0]?U:oe==3?-0:0)}if(I=u(I),N=u(N),T=T.slice(),b=I-N){for((x=b<0)?(b=-b,y=T):(N=I,y=M),y.reverse(),l=b;l--;y.push(0));y.reverse()}else for(A=(x=(b=T.length)<(l=M.length))?b:l,b=l=0;l<A;l++)if(T[l]!=M[l]){x=T[l]<M[l];break}if(x&&(y=T,T=M,M=y,a.s=-a.s),l=(A=M.length)-(h=T.length),l>0)for(;l--;T[h++]=0);for(l=f-1;A>b;){if(T[--A]<M[A]){for(h=A;h&&!T[--h];T[h]=l);--T[h],T[A]+=f}T[A]-=M[A]}for(;T[0]==0;T.splice(0,1),--N);return T[0]?ne(a,T,N):(a.s=oe==3?-1:1,a.c=[a.e=0],a)},$.modulo=$.mod=function(a,l){var h,A,y=this;return a=new O(a,l),!y.c||!a.s||a.c&&!a.c[0]?new O(NaN):!a.c||y.c&&!y.c[0]?new O(y):(X==9?(A=a.s,a.s=1,h=L(y,a,0,3),a.s=A,h.s*=A):h=L(y,a,0,X),a=y.minus(h.times(a)),!a.c[0]&&X==1&&(a.s=y.s),a)},$.multipliedBy=$.times=function(a,l){var h,A,y,x,U,b,I,N,T,M,Y,re,he,xe,Ae,fe=this,ie=fe.c,ke=(a=new O(a,l)).c;if(!ie||!ke||!ie[0]||!ke[0])return!fe.s||!a.s||ie&&!ie[0]&&!ke||ke&&!ke[0]&&!ie?a.c=a.e=a.s=null:(a.s*=fe.s,!ie||!ke?a.c=a.e=null:(a.c=[0],a.e=0)),a;for(A=u(fe.e/c)+u(a.e/c),a.s*=fe.s,I=ie.length,M=ke.length,I<M&&(he=ie,ie=ke,ke=he,y=I,I=M,M=y),y=I+M,he=[];y--;he.push(0));for(xe=f,Ae=p,y=M;--y>=0;){for(h=0,Y=ke[y]%Ae,re=ke[y]/Ae|0,U=I,x=y+U;x>y;)N=ie[--U]%Ae,T=ie[U]/Ae|0,b=re*N+T*Y,N=Y*N+b%Ae*Ae+he[x]+h,h=(N/xe|0)+(b/Ae|0)+re*T,he[x--]=N%xe;he[x]=h}return h?++A:he.splice(0,1),ne(a,he,A)},$.negated=function(){var a=new O(this);return a.s=-a.s||null,a},$.plus=function(a,l){var h,A=this,y=A.s;if(a=new O(a,l),l=a.s,!y||!l)return new O(NaN);if(y!=l)return a.s=-l,A.minus(a);var x=A.e/c,U=a.e/c,b=A.c,I=a.c;if(!x||!U){if(!b||!I)return new O(y/0);if(!b[0]||!I[0])return I[0]?a:new O(b[0]?A:y*0)}if(x=u(x),U=u(U),b=b.slice(),y=x-U){for(y>0?(U=x,h=I):(y=-y,h=b),h.reverse();y--;h.push(0));h.reverse()}for(y=b.length,l=I.length,y-l<0&&(h=I,I=b,b=h,l=y),y=0;l;)y=(b[--l]=b[l]+I[l]+y)/f|0,b[l]=f===b[l]?0:b[l]%f;return y&&(b=[y].concat(b),++U),ne(a,b,U)},$.precision=$.sd=function(a,l){var h,A,y,x=this;if(a!=null&&a!==!!a)return P(a,1,F),l==null?l=oe:P(l,0,8),ae(new O(x),a,l);if(!(h=x.c))return null;if(y=h.length-1,A=y*c+1,y=h[y]){for(;y%10==0;y/=10,A--);for(y=h[0];y>=10;y/=10,A++);}return a&&x.e+1>A&&(A=x.e+1),A},$.shiftedBy=function(a){return P(a,-m,m),this.times("1e"+a)},$.squareRoot=$.sqrt=function(){var a,l,h,A,y,x=this,U=x.c,b=x.s,I=x.e,N=J+4,T=new O("0.5");if(b!==1||!U||!U[0])return new O(!b||b<0&&(!U||U[0])?NaN:U?x:1/0);if(b=Math.sqrt(+j(x)),b==0||b==1/0?(l=B(U),(l.length+I)%2==0&&(l+="0"),b=Math.sqrt(+l),I=u((I+1)/2)-(I<0||I%2),b==1/0?l="5e"+I:(l=b.toExponential(),l=l.slice(0,l.indexOf("e")+1)+I),h=new O(l)):h=new O(b+""),h.c[0]){for(I=h.e,b=I+N,b<3&&(b=0);;)if(y=h,h=T.times(y.plus(L(x,y,N,1))),B(y.c).slice(0,b)===(l=B(h.c)).slice(0,b))if(h.e<I&&--b,l=l.slice(b-3,b+1),l=="9999"||!A&&l=="4999"){if(!A&&(ae(y,y.e+J+2,0),y.times(y).eq(x))){h=y;break}N+=4,b+=4,A=1}else{(!+l||!+l.slice(1)&&l.charAt(0)=="5")&&(ae(h,h.e+J+2,1),a=!h.times(h).eq(x));break}}return ae(h,h.e+J+1,oe,a)},$.toExponential=function(a,l){return a!=null&&(P(a,0,F),a++),d(this,a,l,1)},$.toFixed=function(a,l){return a!=null&&(P(a,0,F),a=a+this.e+1),d(this,a,l)},$.toFormat=function(a,l,h){var A,y=this;if(h==null)a!=null&&l&&typeof l=="object"?(h=l,l=null):a&&typeof a=="object"?(h=a,a=l=null):h=De;else if(typeof h!="object")throw Error(s+"Argument not an object: "+h);if(A=y.toFixed(a,l),y.c){var x,U=A.split("."),b=+h.groupSize,I=+h.secondaryGroupSize,N=h.groupSeparator||"",T=U[0],M=U[1],Y=y.s<0,re=Y?T.slice(1):T,he=re.length;if(I&&(x=b,b=I,I=x,he-=x),b>0&&he>0){for(x=he%b||b,T=re.substr(0,x);x<he;x+=b)T+=N+re.substr(x,b);I>0&&(T+=N+re.slice(x)),Y&&(T="-"+T)}A=M?T+(h.decimalSeparator||"")+((I=+h.fractionGroupSize)?M.replace(new RegExp("\\d{"+I+"}\\B","g"),"$&"+(h.fractionGroupSeparator||"")):M):T}return(h.prefix||"")+A+(h.suffix||"")},$.toFraction=function(a){var l,h,A,y,x,U,b,I,N,T,M,Y,re=this,he=re.c;if(a!=null&&(b=new O(a),!b.isInteger()&&(b.c||b.s!==1)||b.lt(ee)))throw Error(s+"Argument "+(b.isInteger()?"out of range: ":"not an integer: ")+j(b));if(!he)return new O(re);for(l=new O(ee),N=h=new O(ee),A=I=new O(ee),Y=B(he),x=l.e=Y.length-re.e-1,l.c[0]=S[(U=x%c)<0?c+U:U],a=!a||b.comparedTo(l)>0?x>0?l:N:b,U=k,k=1/0,b=new O(Y),I.c[0]=0;T=L(b,l,0,1),y=h.plus(T.times(A)),y.comparedTo(a)!=1;)h=A,A=y,N=I.plus(T.times(y=N)),I=y,l=b.minus(T.times(y=l)),b=y;return y=L(a.minus(h),A,0,1),I=I.plus(y.times(N)),h=h.plus(y.times(A)),I.s=N.s=re.s,x=x*2,M=L(N,A,x,oe).minus(re).abs().comparedTo(L(I,h,x,oe).minus(re).abs())<1?[N,A]:[I,h],k=U,M},$.toNumber=function(){return+j(this)},$.toPrecision=function(a,l){return a!=null&&P(a,1,F),d(this,a,l,2)},$.toString=function(a){var l,h=this,A=h.s,y=h.e;return y===null?A?(l="Infinity",A<0&&(l="-"+l)):l="NaN":(a==null?l=y<=g||y>=_?z(B(h.c),y):Z(B(h.c),y,"0"):a===10&&H?(h=ae(new O(h),J+y+1,oe),l=Z(B(h.c),h.e,"0")):(P(a,2,Ne.length,"Base"),l=C(Z(B(h.c),y,"0"),10,a,A,!0)),A<0&&h.c[0]&&(l="-"+l)),l},$.valueOf=$.toJSON=function(){return j(this)},$._isBigNumber=!0,E!=null&&O.set(E),O}function u(E){var L=E|0;return E>0||E===L?L:L-1}function B(E){for(var L,C,V=1,$=E.length,ee=E[0]+"";V<$;){for(L=E[V++]+"",C=c-L.length;C--;L="0"+L);ee+=L}for($=ee.length;ee.charCodeAt(--$)===48;);return ee.slice(0,$+1||1)}function D(E,L){var C,V,$=E.c,ee=L.c,J=E.s,oe=L.s,g=E.e,_=L.e;if(!J||!oe)return null;if(C=$&&!$[0],V=ee&&!ee[0],C||V)return C?V?0:-oe:J;if(J!=oe)return J;if(C=J<0,V=g==_,!$||!ee)return V?0:!$^C?1:-1;if(!V)return g>_^C?1:-1;for(oe=(g=$.length)<(_=ee.length)?g:_,J=0;J<oe;J++)if($[J]!=ee[J])return $[J]>ee[J]^C?1:-1;return g==_?0:g>_^C?1:-1}function P(E,L,C,V){if(E<L||E>C||E!==i(E))throw Error(s+(V||"Argument")+(typeof E=="number"?E<L||E>C?" out of range: ":" not an integer: ":" not a primitive number: ")+String(E))}function G(E){var L=E.c.length-1;return u(E.e/c)==L&&E.c[L]%2!=0}function z(E,L){return(E.length>1?E.charAt(0)+"."+E.slice(1):E)+(L<0?"e":"e+")+L}function Z(E,L,C){var V,$;if(L<0){for($=C+".";++L;$+=C);E=$+E}else if(V=E.length,++L>V){for($=C,L-=V;--L;$+=C);E+=$}else L<V&&(E=E.slice(0,L)+"."+E.slice(L));return E}e=v(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof Kr<"u"&&Kr.exports?Kr.exports=e:(r||(r=typeof self<"u"&&self?self:window),r.BigNumber=e)})(qs)});var Gs=$e((u0,$s)=>{$s.exports=function(e,t,n){var i=new e.Uint8Array(n),s=t.pushInt,o=t.pushInt32,f=t.pushInt32Neg,c=t.pushInt64,m=t.pushInt64Neg,S=t.pushFloat,p=t.pushFloatSingle,F=t.pushFloatDouble,v=t.pushTrue,u=t.pushFalse,B=t.pushUndefined,D=t.pushNull,P=t.pushInfinity,G=t.pushInfinityNeg,z=t.pushNaN,Z=t.pushNaNNeg,E=t.pushArrayStart,L=t.pushArrayStartFixed,C=t.pushArrayStartFixed32,V=t.pushArrayStartFixed64,$=t.pushObjectStart,ee=t.pushObjectStartFixed,J=t.pushObjectStartFixed32,oe=t.pushObjectStartFixed64,g=t.pushByteString,_=t.pushByteStringStart,R=t.pushUtf8String,k=t.pushUtf8StringStart,K=t.pushSimpleUnassigned,X=t.pushTagStart,se=t.pushTagStart4,De=t.pushTagStart8,Ne=t.pushTagUnassigned,H=t.pushBreak,O=e.Math.pow,d=0,te=0,ne=0;function ae(w){for(w=w|0,d=0,te=w;(d|0)<(te|0)&&(ne=Ja[i[d]&255](i[d]|0)|0,!((ne|0)>0)););return ne|0}function j(w){return w=w|0,((d|0)+(w|0)|0)<(te|0)?0:1}function a(w){return w=w|0,i[w|0]<<8|i[w+1|0]|0}function l(w){return w=w|0,i[w|0]<<24|i[w+1|0]<<16|i[w+2|0]<<8|i[w+3|0]|0}function h(w){return w=w|0,s(w|0),d=d+1|0,0}function A(w){return w=w|0,j(1)|0?1:(s(i[d+1|0]|0),d=d+2|0,0)}function y(w){return w=w|0,j(2)|0?1:(s(a(d+1|0)|0),d=d+3|0,0)}function x(w){return w=w|0,j(4)|0?1:(o(a(d+1|0)|0,a(d+3|0)|0),d=d+5|0,0)}function U(w){return w=w|0,j(8)|0?1:(c(a(d+1|0)|0,a(d+3|0)|0,a(d+5|0)|0,a(d+7|0)|0),d=d+9|0,0)}function b(w){return w=w|0,s(-1-(w-32|0)|0),d=d+1|0,0}function I(w){return w=w|0,j(1)|0?1:(s(-1-(i[d+1|0]|0)|0),d=d+2|0,0)}function N(w){w=w|0;var le=0;return j(2)|0?1:(le=a(d+1|0)|0,s(-1-(le|0)|0),d=d+3|0,0)}function T(w){return w=w|0,j(4)|0?1:(f(a(d+1|0)|0,a(d+3|0)|0),d=d+5|0,0)}function M(w){return w=w|0,j(8)|0?1:(m(a(d+1|0)|0,a(d+3|0)|0,a(d+5|0)|0,a(d+7|0)|0),d=d+9|0,0)}function Y(w){w=w|0;var le=0,de=0,ce=0;return ce=w-64|0,j(ce|0)|0?1:(le=d+1|0,de=(d+1|0)+(ce|0)|0,g(le|0,de|0),d=de|0,0)}function re(w){w=w|0;var le=0,de=0,ce=0;return j(1)|0||(ce=i[d+1|0]|0,le=d+2|0,de=(d+2|0)+(ce|0)|0,j(ce+1|0)|0)?1:(g(le|0,de|0),d=de|0,0)}function he(w){w=w|0;var le=0,de=0,ce=0;return j(2)|0||(ce=a(d+1|0)|0,le=d+3|0,de=(d+3|0)+(ce|0)|0,j(ce+2|0)|0)?1:(g(le|0,de|0),d=de|0,0)}function xe(w){w=w|0;var le=0,de=0,ce=0;return j(4)|0||(ce=l(d+1|0)|0,le=d+5|0,de=(d+5|0)+(ce|0)|0,j(ce+4|0)|0)?1:(g(le|0,de|0),d=de|0,0)}function Ae(w){return w=w|0,1}function fe(w){return w=w|0,_(),d=d+1|0,0}function ie(w){w=w|0;var le=0,de=0,ce=0;return ce=w-96|0,j(ce|0)|0?1:(le=d+1|0,de=(d+1|0)+(ce|0)|0,R(le|0,de|0),d=de|0,0)}function ke(w){w=w|0;var le=0,de=0,ce=0;return j(1)|0||(ce=i[d+1|0]|0,le=d+2|0,de=(d+2|0)+(ce|0)|0,j(ce+1|0)|0)?1:(R(le|0,de|0),d=de|0,0)}function jt(w){w=w|0;var le=0,de=0,ce=0;return j(2)|0||(ce=a(d+1|0)|0,le=d+3|0,de=(d+3|0)+(ce|0)|0,j(ce+2|0)|0)?1:(R(le|0,de|0),d=de|0,0)}function cr(w){w=w|0;var le=0,de=0,ce=0;return j(4)|0||(ce=l(d+1|0)|0,le=d+5|0,de=(d+5|0)+(ce|0)|0,j(ce+4|0)|0)?1:(R(le|0,de|0),d=de|0,0)}function ur(w){return w=w|0,1}function tt(w){return w=w|0,k(),d=d+1|0,0}function pe(w){return w=w|0,L(w-128|0),d=d+1|0,0}function Ke(w){return w=w|0,j(1)|0?1:(L(i[d+1|0]|0),d=d+2|0,0)}function Ye(w){return w=w|0,j(2)|0?1:(L(a(d+1|0)|0),d=d+3|0,0)}function Ee(w){return w=w|0,j(4)|0?1:(C(a(d+1|0)|0,a(d+3|0)|0),d=d+5|0,0)}function Oa(w){return w=w|0,j(8)|0?1:(V(a(d+1|0)|0,a(d+3|0)|0,a(d+5|0)|0,a(d+7|0)|0),d=d+9|0,0)}function Fa(w){return w=w|0,E(),d=d+1|0,0}function _e(w){w=w|0;var le=0;return le=w-160|0,j(le|0)|0?1:(ee(le|0),d=d+1|0,0)}function Pa(w){return w=w|0,j(1)|0?1:(ee(i[d+1|0]|0),d=d+2|0,0)}function La(w){return w=w|0,j(2)|0?1:(ee(a(d+1|0)|0),d=d+3|0,0)}function Ma(w){return w=w|0,j(4)|0?1:(J(a(d+1|0)|0,a(d+3|0)|0),d=d+5|0,0)}function Da(w){return w=w|0,j(8)|0?1:(oe(a(d+1|0)|0,a(d+3|0)|0,a(d+5|0)|0,a(d+7|0)|0),d=d+9|0,0)}function ka(w){return w=w|0,$(),d=d+1|0,0}function Zt(w){return w=w|0,X(w-192|0|0),d=d+1|0,0}function Uf(w){return w=w|0,X(w|0),d=d+1|0,0}function Rf(w){return w=w|0,X(w|0),d=d+1|0,0}function Of(w){return w=w|0,X(w|0),d=d+1|0,0}function Ff(w){return w=w|0,X(w|0),d=d+1|0,0}function qe(w){return w=w|0,X(w-192|0|0),d=d+1|0,0}function Pf(w){return w=w|0,X(w|0),d=d+1|0,0}function Lf(w){return w=w|0,X(w|0),d=d+1|0,0}function Mf(w){return w=w|0,X(w|0),d=d+1|0,0}function qa(w){return w=w|0,j(1)|0?1:(X(i[d+1|0]|0),d=d+2|0,0)}function $a(w){return w=w|0,j(2)|0?1:(X(a(d+1|0)|0),d=d+3|0,0)}function Ga(w){return w=w|0,j(4)|0?1:(se(a(d+1|0)|0,a(d+3|0)|0),d=d+5|0,0)}function Ca(w){return w=w|0,j(8)|0?1:(De(a(d+1|0)|0,a(d+3|0)|0,a(d+5|0)|0,a(d+7|0)|0),d=d+9|0,0)}function Ue(w){return w=w|0,K((w|0)-224|0),d=d+1|0,0}function Va(w){return w=w|0,u(),d=d+1|0,0}function Ya(w){return w=w|0,v(),d=d+1|0,0}function Ha(w){return w=w|0,D(),d=d+1|0,0}function za(w){return w=w|0,B(),d=d+1|0,0}function ja(w){return w=w|0,j(1)|0?1:(K(i[d+1|0]|0),d=d+2|0,0)}function Za(w){w=w|0;var le=0,de=0,ce=1,Or=0,fr=0,Df=0;return j(2)|0?1:(le=i[d+1|0]|0,de=i[d+2|0]|0,(le|0)&128&&(ce=-1),Or=+(((le|0)&124)>>2),fr=+(((le|0)&3)<<8|de),+Or==0?S(+(+ce*5960464477539063e-23*+fr)):+Or==31?+ce==1?+fr>0?z():P():+fr>0?Z():G():S(+(+ce*O(2,+(+Or-25))*+(1024+fr))),d=d+3|0,0)}function Ka(w){return w=w|0,j(4)|0?1:(p(i[d+1|0]|0,i[d+2|0]|0,i[d+3|0]|0,i[d+4|0]|0),d=d+5|0,0)}function Wa(w){return w=w|0,j(8)|0?1:(F(i[d+1|0]|0,i[d+2|0]|0,i[d+3|0]|0,i[d+4|0]|0,i[d+5|0]|0,i[d+6|0]|0,i[d+7|0]|0,i[d+8|0]|0),d=d+9|0,0)}function be(w){return w=w|0,1}function Xa(w){return w=w|0,H(),d=d+1|0,0}var Ja=[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,A,y,x,U,be,be,be,be,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,I,N,T,M,be,be,be,be,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,re,he,xe,Ae,be,be,be,fe,ie,ie,ie,ie,ie,ie,ie,ie,ie,ie,ie,ie,ie,ie,ie,ie,ie,ie,ie,ie,ie,ie,ie,ie,ke,jt,cr,ur,be,be,be,tt,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,Ke,Ye,Ee,Oa,be,be,be,Fa,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,Pa,La,Ma,Da,be,be,be,ka,Zt,Zt,Zt,Zt,Zt,Zt,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qe,qa,$a,Ga,Ca,be,be,be,be,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Va,Ya,Ha,za,ja,Za,Ka,Wa,be,be,be,Xa];return{parse:ae}}});var pr=$e(Je=>{"use strict";var Qn=dr().BigNumber;Je.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Je.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};Je.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Je.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Je.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Je.SHIFT32=Math.pow(2,32);Je.SHIFT16=Math.pow(2,16);Je.MAX_SAFE_HIGH=2097151;Je.NEG_ONE=new Qn(-1);Je.TEN=new Qn(10);Je.TWO=new Qn(2);Je.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Wr=$e(nt=>{"use strict";var{Buffer:zc}=hr(),Vs=dr().BigNumber,Ys=pr(),Cs=Ys.SHIFT32,jc=Ys.SHIFT16,Zc=2097151;nt.parseHalf=function(e){var t,n,i;return i=e[0]&128?-1:1,t=(e[0]&124)>>2,n=(e[0]&3)<<8|e[1],t?t===31?i*(n?NaN:1/0):i*Math.pow(2,t-25)*(1024+n):i*5960464477539063e-23*n};function Kc(r){return r<16?"0"+r.toString(16):r.toString(16)}nt.arrayBufferToBignumber=function(r){let e=r.byteLength,t="";for(let n=0;n<e;n++)t+=Kc(r[n]);return new Vs(t,16)};nt.buildMap=r=>{let e=new Map,t=Object.keys(r),n=t.length;for(let i=0;i<n;i++)e.set(t[i],r[t[i]]);return e};nt.buildInt32=(r,e)=>r*jc+e;nt.buildInt64=(r,e,t,n)=>{let i=nt.buildInt32(r,e),s=nt.buildInt32(t,n);return i>Zc?new Vs(i).times(Cs).plus(s):i*Cs+s};nt.writeHalf=function(e,t){let n=zc.allocUnsafe(4);n.writeFloatBE(t,0);let i=n.readUInt32BE(0);if(i&8191)return!1;var s=i>>16&32768;let o=i>>23&255,f=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(f>>13);else if(o>=103&&o<113){if(f&(1<<126-o)-1)return!1;s+=f+8388608>>126-o}else return!1;return e.writeUInt16BE(s,0),!0};nt.keySorter=function(r,e){var t=r[0].byteLength,n=e[0].byteLength;return t>n?1:n>t?-1:r[0].compare(e[0])};nt.isNegativeZero=r=>r===0&&1/r<0;nt.nextPowerOf2=r=>{let e=0;if(r&&!(r&r-1))return r;for(;r!==0;)r>>=1,e+=1;return 1<<e}});var ni=$e((h0,Hs)=>{"use strict";var ri=pr(),Wc=ri.MT,Xr=ri.SIMPLE,ei=ri.SYMS,ti=class r{constructor(e){if(typeof e!="number")throw new Error("Invalid Simple type: "+typeof e);if(e<0||e>255||(e|0)!==e)throw new Error("value must be a small positive integer: "+e);this.value=e}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,Wc.SIMPLE_FLOAT)}static isSimple(e){return e instanceof r}static decode(e,t){switch(t==null&&(t=!0),e){case Xr.FALSE:return!1;case Xr.TRUE:return!0;case Xr.NULL:return t?null:ei.NULL;case Xr.UNDEFINED:return t?void 0:ei.UNDEFINED;case-1:if(!t)throw new Error("Invalid BREAK");return ei.BREAK;default:return new r(e)}}};Hs.exports=ti});var si=$e((d0,zs)=>{"use strict";var ii=class r{constructor(e,t,n){if(this.tag=e,this.value=t,this.err=n,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(e){return e._pushTag(this.tag),e.pushAny(this.value)}convert(e){var t,n;if(n=e?.[this.tag],typeof n!="function"&&(n=r["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(r,this.value)}catch(i){return t=i,this.err=t,this}}};zs.exports=ii});var ci=$e((p0,Zs)=>{"use strict";var js=self.location?self.location.protocol+"//"+self.location.host:"",oi=self.URL,ai=class{constructor(e="",t=js){this.super=new oi(e,t),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(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set origin(e){this.super.origin=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set searchParams(e){this.super.searchParams=e}set username(e){this.super.username=e}createObjectURL(e){return this.super.createObjectURL(e)}revokeObjectURL(e){this.super.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function Xc(r){if(typeof r=="string")return new oi(r).toString();if(!(r instanceof oi)){let e=r.username&&r.password?`${r.username}:${r.password}@`:"",t=r.auth?r.auth+"@":"",n=r.port?":"+r.port:"",i=r.protocol?r.protocol+"//":"",s=r.host||"",o=r.hostname||"",f=r.search||(r.query?"?"+r.query:""),c=r.hash||"",m=r.pathname||"",S=r.path||m+f;return`${i}${e||t}${s||o+n}${S}${c}`}}Zs.exports={URLWithLegacySupport:ai,URLSearchParams:self.URLSearchParams,defaultBase:js,format:Xc}});var Xs=$e((m0,Ws)=>{"use strict";var{URLWithLegacySupport:Ks,format:Jc}=ci();Ws.exports=(r,e={},t={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(t[i]||n||i)+":";let s;try{s=new Ks(r)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new Ks(r,Jc(o)).toString()}});var ui=$e((g0,Js)=>{"use strict";var{URLWithLegacySupport:Qc,format:eu,URLSearchParams:tu,defaultBase:ru}=ci(),nu=Xs();Js.exports={URL:Qc,URLSearchParams:tu,format:eu,relative:nu,defaultBase:ru}});var fi=$e((b0,eo)=>{"use strict";var{Buffer:Xt}=hr(),Qs=ks(),iu=dr().BigNumber,su=Gs(),ze=Wr(),ge=pr(),ou=ni(),au=si(),{URL:cu}=ui(),mr=class r{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=ze.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=Xt.from(this._heap),this._reset(),this._knownTags=Object.assign({0:t=>new Date(t),1:t=>new Date(t*1e3),2:t=>ze.arrayBufferToBignumber(t),3:t=>ge.NEG_ONE.minus(ze.arrayBufferToBignumber(t)),4:t=>ge.TEN.pow(t[0]).times(t[1]),5:t=>ge.TWO.pow(t[0]).times(t[1]),32:t=>new cu(t),35:t=>new RegExp(t)},e.tags),this.parser=su(globalThis,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var e=this._parents.pop();if(e.length>0)throw new Error(`Missing ${e.length} elements`);switch(e.type){case ge.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case ge.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case ge.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case ge.PARENT.MAP:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(e.ref,e.length));break;case ge.PARENT.OBJECT:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(e.ref,e.length));break;case ge.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===ge.PARENT.TAG&&this._dec()}_dec(){let e=this._currentParent;e.length<0||(e.length--,e.length===0&&this._closeParent())}_push(e,t){let n=this._currentParent;switch(n.values++,n.type){case ge.PARENT.ARRAY:case ge.PARENT.BYTE_STRING:case ge.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case ge.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=ge.PARENT.MAP,n.ref=ze.buildMap(n.ref)));break;case ge.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case ge.PARENT.TAG:this._ref.push(e),t||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(e,t,n){this._parents[this._depth]={type:t,length:n,ref:e,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:ge.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,t){let n=this._knownTags[e];return n?n(t):new au(e,t)}createMap(e,t){return e}createObject(e,t){return e}createArray(e,t){return e}createByteString(e,t){return Xt.concat(e)}createByteStringFromHeap(e,t){return e===t?Xt.alloc(0):Xt.from(this._heap.slice(e,t))}createInt(e){return e}createInt32(e,t){return ze.buildInt32(e,t)}createInt64(e,t,n,i){return ze.buildInt64(e,t,n,i)}createFloat(e){return e}createFloatSingle(e,t,n,i){return Qs.read([e,t,n,i],0,!1,23,4)}createFloatDouble(e,t,n,i,s,o,f,c){return Qs.read([e,t,n,i,s,o,f,c],0,!1,52,8)}createInt32Neg(e,t){return-1-ze.buildInt32(e,t)}createInt64Neg(e,t,n,i){let s=ze.buildInt32(e,t),o=ze.buildInt32(n,i);return s>ge.MAX_SAFE_HIGH?ge.NEG_ONE.minus(new iu(s).times(ge.SHIFT32).plus(o)):-1-(s*ge.SHIFT32+o)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(e,t){return e.join("")}createUtf8StringFromHeap(e,t){return e===t?"":this._buffer.toString("utf8",e,t)}createSimpleUnassigned(e){return new ou(e)}pushInt(e){this._push(this.createInt(e))}pushInt32(e,t){this._push(this.createInt32(e,t))}pushInt64(e,t,n,i){this._push(this.createInt64(e,t,n,i))}pushFloat(e){this._push(this.createFloat(e))}pushFloatSingle(e,t,n,i){this._push(this.createFloatSingle(e,t,n,i))}pushFloatDouble(e,t,n,i,s,o,f,c){this._push(this.createFloatDouble(e,t,n,i,s,o,f,c))}pushInt32Neg(e,t){this._push(this.createInt32Neg(e,t))}pushInt64Neg(e,t,n,i){this._push(this.createInt64Neg(e,t,n,i))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],ge.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,t){let n=ze.buildInt32(e,t);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,t,n,i){let s=ze.buildInt64(e,t,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,t){let n=ze.buildInt32(e,t);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,t,n,i){let s=ze.buildInt64(e,t,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:ge.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(e,t){this._push(this.createByteStringFromHeap(e,t))}pushUtf8StringStart(){this._parents[this._depth]={type:ge.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(e,t){this._push(this.createUtf8StringFromHeap(e,t))}pushSimpleUnassigned(e){this._push(this.createSimpleUnassigned(e))}pushTagStart(e){this._parents[this._depth]={type:ge.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,t){this.pushTagStart(ze.buildInt32(e,t))}pushTagStart8(e,t,n,i){this.pushTagStart(ze.buildInt64(e,t,n,i))}pushTagUnassigned(e){this._push(this.createTag(e))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(e){if(e===0){this._push(this.createObject({}));return}this._createParent({},ge.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),ge.PARENT.ARRAY,e)}_decode(e){if(e.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(e);let t=this.parser.parse(e.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(t>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(e){return this._decode(e),this._res[0]}decodeAll(e){return this._decode(e),this._res}static decode(e,t){return typeof e=="string"&&(e=Xt.from(e,t||"hex")),new r({size:e.length}).decodeFirst(e)}static decodeAll(e,t){return typeof e=="string"&&(e=Xt.from(e,t||"hex")),new r({size:e.length}).decodeAll(e)}};mr.decodeFirst=mr.decode;eo.exports=mr});var no=$e((w0,ro)=>{"use strict";var{Buffer:li}=hr(),uu=fi(),fu=Wr(),hi=class r extends uu{createTag(e,t){return`${e}(${t})`}createInt(e){return super.createInt(e).toString()}createInt32(e,t){return super.createInt32(e,t).toString()}createInt64(e,t,n,i){return super.createInt64(e,t,n,i).toString()}createInt32Neg(e,t){return super.createInt32Neg(e,t).toString()}createInt64Neg(e,t,n,i){return super.createInt64Neg(e,t,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(e){let t=super.createFloat(e);return fu.isNegativeZero(e)?"-0_1":`${t}_1`}createFloatSingle(e,t,n,i){return`${super.createFloatSingle(e,t,n,i)}_2`}createFloatDouble(e,t,n,i,s,o,f,c){return`${super.createFloatDouble(e,t,n,i,s,o,f,c)}_3`}createByteString(e,t){let n=e.join(", ");return t===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(e,t){return`h'${li.from(super.createByteStringFromHeap(e,t)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(e){return`simple(${e})`}createArray(e,t){let n=super.createArray(e,t);return t===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(e,t){let n=super.createMap(e),i=Array.from(n.keys()).reduce(to(n),"");return t===-1?`{_ ${i}}`:`{${i}}`}createObject(e,t){let n=super.createObject(e),i=Object.keys(n).reduce(to(n),"");return t===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,t){let n=e.join(", ");return t===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,t){return`"${li.from(super.createUtf8StringFromHeap(e,t)).toString("utf8")}"`}static diagnose(e,t){return typeof e=="string"&&(e=li.from(e,t||"hex")),new r().decodeFirst(e)}};ro.exports=hi;function to(r){return(e,t)=>e?`${e}, ${t}: ${r[t]}`:`${t}: ${r[t]}`}});var co=$e((y0,ao)=>{"use strict";var{Buffer:bt}=hr(),{URL:lu}=ui(),pi=dr().BigNumber,di=Wr(),Fe=pr(),at=Fe.MT,Jr=Fe.NUMBYTES,io=Fe.SHIFT32,so=Fe.SYMS,Jt=Fe.TAG,hu=Fe.MT.SIMPLE_FLOAT<<5|Fe.NUMBYTES.TWO,du=Fe.MT.SIMPLE_FLOAT<<5|Fe.NUMBYTES.FOUR,pu=Fe.MT.SIMPLE_FLOAT<<5|Fe.NUMBYTES.EIGHT,mu=Fe.MT.SIMPLE_FLOAT<<5|Fe.SIMPLE.TRUE,gu=Fe.MT.SIMPLE_FLOAT<<5|Fe.SIMPLE.FALSE,bu=Fe.MT.SIMPLE_FLOAT<<5|Fe.SIMPLE.UNDEFINED,oo=Fe.MT.SIMPLE_FLOAT<<5|Fe.SIMPLE.NULL,wu=new pi("0x20000000000000"),yu=bt.from("f97e00","hex"),xu=bt.from("f9fc00","hex"),Eu=bt.from("f97c00","hex");function _u(r){return{}.toString.call(r).slice(8,-1)}var mi=class r{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[lu,this._pushUrl],[pi,this._pushBigNumber]];let t=e.genTypes||[],n=t.length;for(let i=0;i<n;i++)this.addSemanticType(t[i][0],t[i][1]);this._reset()}addSemanticType(e,t){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===e){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=t,o}return this.semanticTypes.push([e,t]),null}push(e){return e&&(this.result[this.offset]=e,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=e.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(e,t,n){return this.result[this.offset]=e,this.resultMethod[this.offset]=t,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(e){return this.pushWrite(e,1,1)}_pushUInt16BE(e){return this.pushWrite(e,2,2)}_pushUInt32BE(e){return this.pushWrite(e,3,4)}_pushDoubleBE(e){return this.pushWrite(e,4,8)}_pushNaN(){return this.push(yu)}_pushInfinity(e){let t=e<0?xu:Eu;return this.push(t)}_pushFloat(e){let t=bt.allocUnsafe(2);if(di.writeHalf(t,e)&&di.parseHalf(t)===e)return this._pushUInt8(hu)&&this.push(t);let n=bt.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(du)&&this.push(n):this._pushUInt8(pu)&&this._pushDoubleBE(e)}_pushInt(e,t,n){let i=t<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|Jr.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|Jr.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|Jr.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|Jr.EIGHT)&&this._pushUInt32BE(Math.floor(e/io))&&this._pushUInt32BE(e%io):t===at.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,at.NEG_INT,e):this._pushInt(e,at.POS_INT)}_pushNumber(e){switch(!1){case e===e:return this._pushNaN(e);case isFinite(e):return this._pushInfinity(e);case e%1!==0:return this._pushIntNum(e);default:return this._pushFloat(e)}}_pushString(e){let t=bt.byteLength(e,"utf8");return this._pushInt(t,at.UTF8_STRING)&&this.pushWrite(e,5,t)}_pushBoolean(e){return this._pushUInt8(e?mu:gu)}_pushUndefined(e){return this._pushUInt8(bu)}_pushArray(e,t){let n=t.length;if(!e._pushInt(n,at.ARRAY))return!1;for(let i=0;i<n;i++)if(!e.pushAny(t[i]))return!1;return!0}_pushTag(e){return this._pushInt(e,at.TAG)}_pushDate(e,t){return e._pushTag(Jt.DATE_EPOCH)&&e.pushAny(Math.round(t/1e3))}_pushBuffer(e,t){return e._pushInt(t.length,at.BYTE_STRING)&&e.push(t)}_pushNoFilter(e,t){return e._pushBuffer(e,t.slice())}_pushRegexp(e,t){return e._pushTag(Jt.REGEXP)&&e.pushAny(t.source)}_pushSet(e,t){if(!e._pushInt(t.size,at.ARRAY))return!1;for(let n of t)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,t){return e._pushTag(Jt.URI)&&e.pushAny(t.format())}_pushBigint(e){let t=Jt.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),t=Jt.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=bt.from(n,"hex");return this._pushTag(t)&&this._pushBuffer(this,i)}_pushBigNumber(e,t){if(t.isNaN())return e._pushNaN();if(!t.isFinite())return e._pushInfinity(t.isNegative()?-1/0:1/0);if(t.isInteger())return e._pushBigint(t);if(!(e._pushTag(Jt.DECIMAL_FRAC)&&e._pushInt(2,at.ARRAY)))return!1;let n=t.decimalPlaces(),i=t.multipliedBy(new pi(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(wu)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,t){return e._pushInt(t.size,at.MAP)?this._pushRawMap(t.size,Array.from(t)):!1}_pushObject(e){if(!e)return this._pushUInt8(oo);for(var t=this.semanticTypes.length,n=0;n<t;n++)if(e instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(e,this,e);var i=e.encodeCBOR;if(typeof i=="function")return i.call(e,this);var s=Object.keys(e),o=s.length;return this._pushInt(o,at.MAP)?this._pushRawMap(o,s.map(f=>[f,e[f]])):!1}_pushRawMap(e,t){t=t.map(function(i){return i[0]=r.encode(i[0]),i}).sort(di.keySorter);for(var n=0;n<e;n++)if(!this.push(t[n][0])||!this.pushAny(t[n][1]))return!1;return!0}write(e){return this.pushAny(e)}pushAny(e){var t=_u(e);switch(t){case"Number":return this._pushNumber(e);case"String":return this._pushString(e);case"Boolean":return this._pushBoolean(e);case"Object":return this._pushObject(e);case"Array":return this._pushArray(this,e);case"Uint8Array":return this._pushBuffer(this,bt.isBuffer(e)?e:bt.from(e));case"Null":return this._pushUInt8(oo);case"Undefined":return this._pushUndefined(e);case"Map":return this._pushMap(this,e);case"Set":return this._pushSet(this,e);case"URL":return this._pushUrl(this,e);case"BigNumber":return this._pushBigNumber(this,e);case"Date":return this._pushDate(this,e);case"RegExp":return this._pushRegexp(this,e);case"Symbol":switch(e){case so.NULL:return this._pushObject(null);case so.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+e.toString())}default:throw new Error("Unknown type: "+typeof e+", "+(e?e.toString():""))}}finalize(){if(this.offset===0)return null;for(var e=this.result,t=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=t[o];var f=bt.allocUnsafe(s),c=0,m=0;for(o=0;o<i;o++){switch(m=t[o],n[o]){case 0:e[o].copy(f,c);break;case 1:f.writeUInt8(e[o],c,!0);break;case 2:f.writeUInt16BE(e[o],c,!0);break;case 3:f.writeUInt32BE(e[o],c,!0);break;case 4:f.writeDoubleBE(e[o],c,!0);break;case 5:f.write(e[o],c,m,"utf8");break;default:throw new Error("unkown method")}c+=m}var S=f;return this._reset(),S}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(e){let t=new r;if(!t.pushAny(e))throw new Error("Failed to encode input");return t.finalize()}};ao.exports=mi});var gi=$e(Pe=>{"use strict";Pe.Diagnose=no();Pe.Decoder=fi();Pe.Encoder=co();Pe.Simple=ni();Pe.Tagged=si();Pe.decodeAll=Pe.Decoder.decodeAll;Pe.decodeFirst=Pe.Decoder.decodeFirst;Pe.diagnose=Pe.Diagnose.diagnose;Pe.encode=Pe.Encoder.encode;Pe.decode=Pe.Decoder.decode;Pe.leveldb={decode:Pe.Decoder.decodeAll,encode:Pe.Encoder.encode,buffer:!0,name:"cbor"}});var yi=$e(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});var vu=9007199254740992;function Et(r,...e){let t=new Uint8Array(r.byteLength+e.reduce((i,s)=>i+s.byteLength,0));t.set(new Uint8Array(r),0);let n=r.byteLength;for(let i of e)t.set(new Uint8Array(i),n),n+=i.byteLength;return t.buffer}function ct(r,e,t){t=t.replace(/[^0-9a-fA-F]/g,"");let n=2**(e-24);t=t.slice(-n*2).padStart(n*2,"0");let i=[(r<<5)+e].concat(t.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function Qr(r,e){if(e<24)return new Uint8Array([(r<<5)+e]).buffer;{let t=e<=255?24:e<=65535?25:e<=4294967295?26:27;return ct(r,t,e.toString(16))}}function uo(r){let e=[];for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);n<128?e.push(n):n<2048?e.push(192|n>>6,128|n&63):n<55296||n>=57344?e.push(224|n>>12,128|n>>6&63,128|n&63):(t++,n=(n&1023)<<10|r.charCodeAt(t)&1023,e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return Et(new Uint8Array(Qr(3,r.length)),new Uint8Array(e))}function Iu(r,e){if(r==14277111)return Et(new Uint8Array([217,217,247]),e);if(r<24)return Et(new Uint8Array([192+r]),e);{let t=r<=255?24:r<=65535?25:r<=4294967295?26:27,n=2**(t-24),i=r.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+t].concat(i.match(/../g).map(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}we.tagged=Iu;function gr(r){return new Uint8Array(r).buffer}we.raw=gr;function bi(r){if(isNaN(r))throw new RangeError("Invalid number.");r=Math.min(Math.max(0,r),23);let e=[0+r];return new Uint8Array(e).buffer}we.uSmall=bi;function fo(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),255),r=r.toString(16),ct(0,24,r)}we.u8=fo;function lo(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),65535),r=r.toString(16),ct(0,25,r)}we.u16=lo;function ho(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),4294967295),r=r.toString(16),ct(0,26,r)}we.u32=ho;function wi(r,e){if(typeof r=="string"&&e==16){if(r.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return ct(0,27,r)}if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),vu),r=r.toString(16),ct(0,27,r)}we.u64=wi;function po(r){if(isNaN(r))throw new RangeError("Invalid number.");if(r===0)return bi(0);r=Math.min(Math.max(0,-r),24)-1;let e=[32+r];return new Uint8Array(e).buffer}we.iSmall=po;function mo(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),255),r=r.toString(16),ct(1,24,r)}we.i8=mo;function go(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),65535),r=r.toString(16),ct(1,25,r)}we.i16=go;function bo(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),4294967295),r=r.toString(16),ct(1,26,r)}we.i32=bo;function wo(r,e){if(typeof r=="string"&&e==16){if(r.startsWith("-")?r=r.slice(1):r="0",r.match(/[^0-9a-fA-F]/)||r.length>16)throw new RangeError("Invalid number.");let t=!1,n=r.split("").reduceRight((i,s)=>{if(t)return s+i;let o=parseInt(s,16)-1;return o>=0?(t=!0,o.toString(16)+i):"f"+i},"");return t?ct(1,27,n):wi(0)}if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),9007199254740992),r=r.toString(16),ct(1,27,r)}we.i64=wo;function Au(r){return r>=0?r<24?bi(r):r<=255?fo(r):r<=65535?lo(r):r<=4294967295?ho(r):wi(r):r>=-24?po(r):r>=-255?mo(r):r>=-65535?go(r):r>=-4294967295?bo(r):wo(r)}we.number=Au;function Bu(r){return Et(Qr(2,r.byteLength),r)}we.bytes=Bu;function Su(r){return uo(r)}we.string=Su;function Tu(r){return Et(Qr(4,r.length),...r)}we.array=Tu;function Nu(r,e=!1){r instanceof Map||(r=new Map(Object.entries(r)));let t=Array.from(r.entries());return e&&(t=t.sort(([n],[i])=>n.localeCompare(i))),Et(Qr(5,r.size),...t.map(([n,i])=>Et(uo(n),i)))}we.map=Nu;function Uu(r){let e=new Float32Array([r]);return Et(new Uint8Array([250]),new Uint8Array(e.buffer))}we.singleFloat=Uu;function Ru(r){let e=new Float64Array([r]);return Et(new Uint8Array([251]),new Uint8Array(e.buffer))}we.doubleFloat=Ru;function Ou(r){return r?yo():xo()}we.bool=Ou;function yo(){return gr(new Uint8Array([245]))}we.true_=yo;function xo(){return gr(new Uint8Array([244]))}we.false_=xo;function Fu(){return gr(new Uint8Array([246]))}we.null_=Fu;function Pu(){return gr(new Uint8Array([247]))}we.undefined_=Pu});var Eo=$e(Rt=>{"use strict";var Lu=Rt&&Rt.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e};Object.defineProperty(Rt,"__esModule",{value:!0});var ut=Lu(yi()),Mu=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],en=class{constructor(e,t=!1){this._serializer=e,this._stable=t,this.name="jsonDefault",this.priority=-100}match(e){return["undefined","boolean","number","string","object"].indexOf(typeof e)!=-1}encode(e){switch(typeof e){case"undefined":return ut.undefined_();case"boolean":return ut.bool(e);case"number":return Math.floor(e)===e?ut.number(e):ut.doubleFloat(e);case"string":return ut.string(e);case"object":if(e===null)return ut.null_();if(Array.isArray(e))return ut.array(e.map(t=>this._serializer.serializeValue(t)));if(Mu.find(t=>e instanceof t))return ut.bytes(e.buffer);if(Object.getOwnPropertyNames(e).indexOf("toJSON")!==-1)return this.encode(e.toJSON());if(e instanceof Map){let t=new Map;for(let[n,i]of e.entries())t.set(n,this._serializer.serializeValue(i));return ut.map(t,this._stable)}else{let t=new Map;for(let[n,i]of Object.entries(e))t.set(n,this._serializer.serializeValue(i));return ut.map(t,this._stable)}default:throw new Error("Invalid value.")}}};Rt.JsonDefaultCborEncoder=en;var tn=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};Rt.ToCborEncoder=tn;var rn=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let t=new this;return t.addEncoder(new en(t,e)),t.addEncoder(new tn),t}removeEncoder(e){for(let t of this._encoders.values())t.name==e&&this._encoders.delete(t)}addEncoder(e){this._encoders.add(e)}getEncoderFor(e){let t=null;for(let n of this._encoders)(!t||n.priority>t.priority)&&n.match(e)&&(t=n);if(t===null)throw new Error("Could not find an encoder for value.");return t}serializeValue(e){return this.getEncoderFor(e).encode(e)}serialize(e){return this.serializeValue(e)}};Rt.CborSerializer=rn;var xi=class extends rn{serialize(e){return ut.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};Rt.SelfDescribeCborSerializer=xi});var Ei=$e(Vt=>{"use strict";function Du(r){for(var e in r)Vt.hasOwnProperty(e)||(Vt[e]=r[e])}var ku=Vt&&Vt.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e};Object.defineProperty(Vt,"__esModule",{value:!0});Du(Eo());var qu=ku(yi());Vt.value=qu});var Lr="abcdefghijklmnopqrstuvwxyz234567",Kt=Object.create(null);for(let r=0;r<Lr.length;r++)Kt[Lr[r]]=r;Kt[0]=Kt.o;Kt[1]=Kt.i;function as(r){let e=0,t=0,n="";function i(s){return e<0?t|=s>>-e:t=s<<e&248,e>3?(e-=8,1):(e<4&&(n+=Lr[t>>3],e+=5),0)}for(let s=0;s<r.length;)s+=i(r[s]);return n+(e<0?Lr[t>>3]:"")}function cs(r){let e=0,t=0,n=new Uint8Array(r.length*4/3|0),i=0;function s(o){let f=Kt[o.toLowerCase()];if(f===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);f<<=3,t|=f>>>e,e+=5,e>=8&&(n[i++]=t,e-=8,e>0?t=f<<5-e&255:t=0)}for(let o of r)s(o);return n.slice(0,i)}var oc=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 us(r){let e=new Uint8Array(r),t=-1;for(let n=0;n<e.length;n++){let s=(e[n]^t)&255;t=oc[s]^t>>>8}return(t^-1)>>>0}function ac(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Vn(r,...e){if(!ac(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${r.length}`)}function Yn(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function fs(r,e){Vn(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var Mr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var kr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),ot=(r,e)=>r<<32-e|r>>>e;var Hf=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function cc(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Hn(r){return typeof r=="string"&&(r=cc(r)),Vn(r),r}var Dr=class{clone(){return this._cloneInto()}},zf={}.toString;function zn(r){let e=n=>r().update(Hn(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function ls(r=32){if(Mr&&typeof Mr.getRandomValues=="function")return Mr.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function uc(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(t>>i&s),f=Number(t&s),c=n?4:0,m=n?0:4;r.setUint32(e+c,o,n),r.setUint32(e+m,f,n)}var hs=(r,e,t)=>r&e^~r&t,ds=(r,e,t)=>r&e^r&t^e&t,qr=class extends Dr{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=kr(this.buffer)}update(e){Yn(this);let{view:t,buffer:n,blockLen:i}=this;e=Hn(e);let s=e.length;for(let o=0;o<s;){let f=Math.min(i-this.pos,s-o);if(f===i){let c=kr(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+f),this.pos),this.pos+=f,o+=f,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Yn(this),fs(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let p=o;p<i;p++)t[p]=0;uc(n,i-8,BigInt(this.length*8),s),this.process(n,0);let f=kr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let m=c/4,S=this.get();if(m>S.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<m;p++)f.setUint32(4*p,S[p],s)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:i,finished:s,destroyed:o,pos:f}=this;return e.length=i,e.pos=f,e.finished=s,e.destroyed=o,i%t&&e.buffer.set(n),e}};var fc=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Nt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ut=new Uint32Array(64),$r=class extends qr{constructor(){super(64,32,8,!1),this.A=Nt[0]|0,this.B=Nt[1]|0,this.C=Nt[2]|0,this.D=Nt[3]|0,this.E=Nt[4]|0,this.F=Nt[5]|0,this.G=Nt[6]|0,this.H=Nt[7]|0}get(){let{A:e,B:t,C:n,D:i,E:s,F:o,G:f,H:c}=this;return[e,t,n,i,s,o,f,c]}set(e,t,n,i,s,o,f,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=f|0,this.H=c|0}process(e,t){for(let p=0;p<16;p++,t+=4)Ut[p]=e.getUint32(t,!1);for(let p=16;p<64;p++){let F=Ut[p-15],v=Ut[p-2],u=ot(F,7)^ot(F,18)^F>>>3,B=ot(v,17)^ot(v,19)^v>>>10;Ut[p]=B+Ut[p-7]+u+Ut[p-16]|0}let{A:n,B:i,C:s,D:o,E:f,F:c,G:m,H:S}=this;for(let p=0;p<64;p++){let F=ot(f,6)^ot(f,11)^ot(f,25),v=S+F+hs(f,c,m)+fc[p]+Ut[p]|0,B=(ot(n,2)^ot(n,13)^ot(n,22))+ds(n,i,s)|0;S=m,m=c,c=f,f=o+v|0,o=s,s=i,i=n,n=v+B|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,f=f+this.E|0,c=c+this.F|0,m=m+this.G|0,S=S+this.H|0,this.set(n,i,s,o,f,c,m,S)}roundClean(){Ut.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},jn=class extends $r{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}},lr=zn(()=>new $r),ps=zn(()=>new jn);function ms(r){return ps.create().update(new Uint8Array(r)).digest()}var Gr="__principal__",lc=2,gs=4,hc="aaaaa-aa",dc=r=>{var e;return new Uint8Array(((e=r.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(t=>parseInt(t,16)))},pc=r=>r.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),""),Ge=class r{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([gs]))}static managementCanister(){return this.fromHex(hc)}static selfAuthenticating(e){let t=ms(e);return new this(new Uint8Array([...t,lc]))}static from(e){if(typeof e=="string")return r.fromText(e);if(Object.getPrototypeOf(e)===Uint8Array.prototype)return new r(e);if(typeof e=="object"&&e!==null&&e._isPrincipal===!0)return new r(e._arr);throw new Error(`Impossible to convert ${JSON.stringify(e)} to Principal.`)}static fromHex(e){return new this(dc(e))}static fromText(e){let t=e;if(e.includes(Gr)){let o=JSON.parse(e);Gr in o&&(t=o[Gr])}let n=t.toLowerCase().replace(/-/g,""),i=cs(n);i=i.slice(4,i.length);let s=new this(i);if(s.toText()!==t)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${t}" may not be a valid Principal ID).`);return s}static fromUint8Array(e){return new this(e)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===gs}toUint8Array(){return this._arr}toHex(){return pc(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,us(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),f=as(s).match(/.{1,5}/g);if(!f)throw new Error;return f.join("-")}toString(){return this.toText()}toJSON(){return{[Gr]:this.toText()}}compareTo(e){for(let t=0;t<Math.min(this._arr.length,e._arr.length);t++){if(this._arr[t]<e._arr[t])return"lt";if(this._arr[t]>e._arr[t])return"gt"}return this._arr.length<e._arr.length?"lt":this._arr.length>e._arr.length?"gt":"eq"}ltEq(e){let t=this.compareTo(e);return t=="lt"||t=="eq"}gtEq(e){let t=this.compareTo(e);return t=="gt"||t=="eq"}};var Wt=class r extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,r.prototype)}};var vo=Pr(gi()),Yt=Pr(Ei()),Io=Pr(Ei());function it(...r){let e=new Uint8Array(r.reduce((n,i)=>n+i.byteLength,0)),t=0;for(let n of r)e.set(new Uint8Array(n),t),t+=n.byteLength;return e.buffer}function ft(r){return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,"0")).join("")}var $u=new RegExp(/^[0-9a-fA-F]+$/);function wr(r){if(!$u.test(r))throw new Error("Invalid hexadecimal string.");let e=[...r].reduce((t,n,i)=>(t[i/2|0]=(t[i/2|0]||"")+n,t),[]).map(t=>Number.parseInt(t,16));return new Uint8Array(e).buffer}function _i(r,e){if(r.byteLength!==e.byteLength)return r.byteLength-e.byteLength;let t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<t.length;i++)if(t[i]!==n[i])return t[i]-n[i];return 0}function vi(r,e){return _i(r,e)===0}function br(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}function Gu(r){return r instanceof Uint8Array?br(r):r instanceof ArrayBuffer?r:Array.isArray(r)?br(new Uint8Array(r)):"buffer"in r?Gu(r.buffer):br(new Uint8Array(r))}var Ii=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return Yt.value.bytes(e.toUint8Array())}},Ai=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return Yt.value.bytes(new Uint8Array(e))}},Bi=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?Yt.value.tagged(2,Yt.value.bytes(wr(e.toString(16)))):Yt.value.tagged(3,Yt.value.bytes(wr((BigInt("-1")*e).toString(16))))}},nn=Io.SelfDescribeCborSerializer.withDefaultEncoders(!0);nn.addEncoder(new Ii);nn.addEncoder(new Ai);nn.addEncoder(new Bi);var Si;(function(r){r[r.Uint64LittleEndian=71]="Uint64LittleEndian",r[r.Semantic=55799]="Semantic"})(Si||(Si={}));function B0(r){return nn.serialize(r)}function _o(r){let e=r.byteLength,t=BigInt(0);for(let n=0;n<e;n++)t=t*BigInt(256)+BigInt(r[n]);return t}var Ti=class extends vo.default.Decoder{createByteString(e){return it(...e)}createByteStringFromHeap(e,t){return e===t?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,t))}};function Qt(r){let e=new Uint8Array(r),t=new Ti({size:e.byteLength,tags:{2:n=>_o(n),3:n=>-_o(n),[Si.Semantic]:n=>n}});try{return t.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${ft(e)}`)}}var Li={};Cn(Li,{Bool:()=>Oo,BoolClass:()=>fn,ConstructType:()=>yt,Empty:()=>Uo,EmptyClass:()=>cn,FixedIntClass:()=>vt,FixedNatClass:()=>wt,Float32:()=>Do,Float64:()=>ko,FloatClass:()=>xr,Func:()=>ea,FuncClass:()=>_r,Int:()=>Lo,Int16:()=>$o,Int32:()=>Go,Int64:()=>Co,Int8:()=>qo,IntClass:()=>dn,Nat:()=>Mo,Nat16:()=>Yo,Nat32:()=>Ho,Nat64:()=>zo,Nat8:()=>Vo,NatClass:()=>pn,Null:()=>Fo,NullClass:()=>ln,Opt:()=>Wo,OptClass:()=>rr,PrimitiveType:()=>Xe,Principal:()=>jo,PrincipalClass:()=>wn,Rec:()=>Qo,RecClass:()=>Pt,Record:()=>Xo,RecordClass:()=>Er,Reserved:()=>Ro,ReservedClass:()=>tr,Service:()=>ta,ServiceClass:()=>yn,Text:()=>Po,TextClass:()=>hn,Tuple:()=>Zo,TupleClass:()=>gn,Type:()=>er,Unknown:()=>Hu,UnknownClass:()=>un,Variant:()=>Jo,VariantClass:()=>bn,Vec:()=>Ko,VecClass:()=>mn,Visitor:()=>an,decode:()=>Yu,encode:()=>Vu});function me(...r){let e=new Uint8Array(r.reduce((n,i)=>n+i.byteLength,0)),t=0;for(let n of r)e.set(new Uint8Array(n),t),t+=n.byteLength;return e}var lt=class{constructor(e,t=e?.byteLength||0){this._buffer=Ui(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,t)}get buffer(){return Ui(this._view.slice())}get byteLength(){return this._view.byteLength}read(e){let t=this._view.subarray(0,e);return this._view=this._view.subarray(e),t.slice().buffer}readUint8(){let e=this._view[0];return this._view=this._view.subarray(1),e}write(e){let t=new Uint8Array(e),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+t.byteLength>=this._buffer.byteLength?this.alloc(t.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+t.byteLength),this._view.set(t,n)}get end(){return this._view.byteLength===0}alloc(e){let t=new ArrayBuffer((this._buffer.byteLength+e)*1.2|0),n=new Uint8Array(t,0,this._view.byteLength+e);n.set(this._view),this._buffer=t,this._view=n}};function Ni(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}function Ui(r){return r instanceof Uint8Array?Ni(r):r instanceof ArrayBuffer?r:Array.isArray(r)?Ni(new Uint8Array(r)):"buffer"in r?Ui(r.buffer):Ni(new Uint8Array(r))}function Cu(r){let t=new TextEncoder().encode(r),n=0;for(let i of t)n=(n*223+i)%2**32;return n}function ht(r){if(/^_\d+_$/.test(r)||/^_0x[0-9a-fA-F]+_$/.test(r)){let e=+r.slice(1,-1);if(Number.isSafeInteger(e)&&e>=0&&e<2**32)return e}return Cu(r)}function Bo(){throw new Error("unexpected end of buffer")}function Ft(r,e){return r.byteLength<e&&Bo(),r.read(e)}function Ot(r){let e=r.readUint8();return e===void 0&&Bo(),e}function Ie(r){if(typeof r=="number"&&(r=BigInt(r)),r<BigInt(0))throw new Error("Cannot leb encode negative values.");let e=(r===BigInt(0)?0:Math.ceil(Math.log2(Number(r))))+1,t=new lt(new ArrayBuffer(e),0);for(;;){let n=Number(r&BigInt(127));if(r/=BigInt(128),r===BigInt(0)){t.write(new Uint8Array([n]));break}else t.write(new Uint8Array([n|128]))}return t.buffer}function Re(r){let e=BigInt(1),t=BigInt(0),n;do n=Ot(r),t+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return t}function Oe(r){typeof r=="number"&&(r=BigInt(r));let e=r<BigInt(0);e&&(r=-r-BigInt(1));let t=(r===BigInt(0)?0:Math.ceil(Math.log2(Number(r))))+1,n=new lt(new ArrayBuffer(t),0);for(;;){let s=i(r);if(r/=BigInt(128),e&&r===BigInt(0)&&s&64||!e&&r===BigInt(0)&&!(s&64)){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let o=s%BigInt(128);return Number(e?BigInt(128)-o-BigInt(1):o)}return n.buffer}function _t(r){let e=new Uint8Array(r.buffer),t=0;for(;t<e.byteLength;t++)if(e[t]<128){if(!(e[t]&64))return Re(r);break}let n=new Uint8Array(Ft(r,t+1)),i=BigInt(0);for(let s=n.byteLength-1;s>=0;s--)i=i*BigInt(128)+BigInt(128-(n[s]&127)-1);return-i-BigInt(1)}function So(r,e){if(BigInt(r)<BigInt(0))throw new Error("Cannot write negative values.");return Ri(r,e)}function Ri(r,e){r=BigInt(r);let t=new lt(new ArrayBuffer(Math.min(1,e)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(r%i);for(t.write(new Uint8Array([o]));++n<e;)r<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((r/i-s)%BigInt(256)),t.write(new Uint8Array([o])),i*=BigInt(256);return t.buffer}function Oi(r,e){let t=BigInt(Ot(r)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(Ot(r));t=t+n*s}return t}function To(r,e){let t=Oi(r,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return t>=n&&(t-=n*BigInt(2)),t}function sn(r){let e=BigInt(r);if(r<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}var on="DIDL",No=400;function yr(r,e,t){return r.map((n,i)=>t(n,e[i]))}var Fi=class{constructor(){this._typs=[],this._idx=new Map}has(e){return this._idx.has(e.name)}add(e,t){let n=this._typs.length;this._idx.set(e.name,n),this._typs.push(t)}merge(e,t){let n=this._idx.get(e.name),i=this._idx.get(t);if(n===void 0)throw new Error("Missing type index for "+e);if(i===void 0)throw new Error("Missing type index for "+t);this._typs[n]=this._typs[i],this._typs.splice(i,1),this._idx.delete(t)}encode(){let e=Ie(this._typs.length),t=me(...this._typs);return me(e,t)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return Oe(this._idx.get(e)||0)}},an=class{visitType(e,t){throw new Error("Not implemented")}visitPrimitive(e,t){return this.visitType(e,t)}visitEmpty(e,t){return this.visitPrimitive(e,t)}visitBool(e,t){return this.visitPrimitive(e,t)}visitNull(e,t){return this.visitPrimitive(e,t)}visitReserved(e,t){return this.visitPrimitive(e,t)}visitText(e,t){return this.visitPrimitive(e,t)}visitNumber(e,t){return this.visitPrimitive(e,t)}visitInt(e,t){return this.visitNumber(e,t)}visitNat(e,t){return this.visitNumber(e,t)}visitFloat(e,t){return this.visitPrimitive(e,t)}visitFixedInt(e,t){return this.visitNumber(e,t)}visitFixedNat(e,t){return this.visitNumber(e,t)}visitPrincipal(e,t){return this.visitPrimitive(e,t)}visitConstruct(e,t){return this.visitType(e,t)}visitVec(e,t,n){return this.visitConstruct(e,n)}visitOpt(e,t,n){return this.visitConstruct(e,n)}visitRecord(e,t,n){return this.visitConstruct(e,n)}visitTuple(e,t,n){let i=t.map((s,o)=>[`_${o}_`,s]);return this.visitRecord(e,i,n)}visitVariant(e,t,n){return this.visitConstruct(e,n)}visitRec(e,t,n){return this.visitConstruct(t,n)}visitFunc(e,t){return this.visitConstruct(e,t)}visitService(e,t){return this.visitConstruct(e,t)}},er=class{display(){return this.name}valueToString(e){return Be(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}},Xe=class extends er{checkType(e){if(this.name!==e.name)throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`);return e}_buildTypeTableImpl(e){}},yt=class extends er{checkType(e){if(e instanceof Pt){let t=e.getType();if(typeof t>"u")throw new Error("type mismatch with uninitialized type");return t}throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`)}encodeType(e){return e.indexOf(this.name)}},cn=class extends Xe{accept(e,t){return e.visitEmpty(this,t)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return Oe(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},un=class extends er{checkType(e){throw new Error("Method not implemented for unknown.")}accept(e,t){throw e.visitType(this,t)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(e,t){let n=t.decodeValue(e,t);Object(n)!==n&&(n=Object(n));let i;return t instanceof Pt?i=()=>t.getType():i=()=>t,Object.defineProperty(n,"type",{value:i,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}},fn=class extends Xe{accept(e,t){return e.visitBool(this,t)}covariant(e){if(typeof e=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return Oe(-2)}decodeValue(e,t){switch(this.checkType(t),Ot(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},ln=class extends Xe{accept(e,t){return e.visitNull(this,t)}covariant(e){if(e===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return Oe(-1)}decodeValue(e,t){return this.checkType(t),null}get name(){return"null"}},tr=class extends Xe{accept(e,t){return e.visitReserved(this,t)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return Oe(-16)}decodeValue(e,t){return t.name!==this.name&&t.decodeValue(e,t),null}get name(){return"reserved"}},hn=class extends Xe{accept(e,t){return e.visitText(this,t)}covariant(e){if(typeof e=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(e){let t=new TextEncoder().encode(e),n=Ie(t.byteLength);return me(n,t)}encodeType(){return Oe(-15)}decodeValue(e,t){this.checkType(t);let n=Re(e),i=Ft(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}},dn=class extends Xe{accept(e,t){return e.visitInt(this,t)}covariant(e){if(typeof e=="bigint"||Number.isInteger(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(e){return Oe(e)}encodeType(){return Oe(-4)}decodeValue(e,t){return this.checkType(t),_t(e)}get name(){return"int"}valueToString(e){return e.toString()}},pn=class extends Xe{accept(e,t){return e.visitNat(this,t)}covariant(e){if(typeof e=="bigint"&&e>=BigInt(0)||Number.isInteger(e)&&e>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(e){return Ie(e)}encodeType(){return Oe(-3)}decodeValue(e,t){return this.checkType(t),Re(e)}get name(){return"nat"}valueToString(e){return e.toString()}},xr=class extends Xe{constructor(e){if(super(),this._bits=e,e!==32&&e!==64)throw new Error("not a valid float type")}accept(e,t){return e.visitFloat(this,t)}covariant(e){if(typeof e=="number"||e instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(e){let t=new ArrayBuffer(this._bits/8),n=new DataView(t);return this._bits===32?n.setFloat32(0,e,!0):n.setFloat64(0,e,!0),t}encodeType(){let e=this._bits===32?-13:-14;return Oe(e)}decodeValue(e,t){this.checkType(t);let n=Ft(e,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(e){return e.toString()}},vt=class extends Xe{constructor(e){super(),this._bits=e}accept(e,t){return e.visitFixedInt(this,t)}covariant(e){let t=sn(this._bits-1)*BigInt(-1),n=sn(this._bits-1)-BigInt(1),i=!1;if(typeof e=="bigint")i=e>=t&&e<=n;else if(Number.isInteger(e)){let s=BigInt(e);i=s>=t&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(e){return Ri(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return Oe(-9-e)}decodeValue(e,t){this.checkType(t);let n=To(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}},wt=class extends Xe{constructor(e){super(),this._bits=e}accept(e,t){return e.visitFixedNat(this,t)}covariant(e){let t=sn(this._bits),n=!1;if(typeof e=="bigint"&&e>=BigInt(0)?n=e<t:Number.isInteger(e)&&e>=0?n=BigInt(e)<t:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(e){return So(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return Oe(-5-e)}decodeValue(e,t){this.checkType(t);let n=Oi(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}},mn=class r extends yt{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof wt&&e._bits===8&&(this._blobOptimization=!0)}accept(e,t){return e.visitVec(this,this._type,t)}covariant(e){let t=this._type instanceof wt?this._type._bits:this._type instanceof vt?this._type._bits:0;if(ArrayBuffer.isView(e)&&t==e.BYTES_PER_ELEMENT*8||Array.isArray(e)&&e.every((n,i)=>{try{return this._type.covariant(n)}catch(s){throw new Error(`Invalid ${this.display()} argument:
2
-
3
- index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(e){let t=Ie(e.length);if(this._blobOptimization)return me(t,new Uint8Array(e));if(ArrayBuffer.isView(e))return me(t,new Uint8Array(e.buffer));let n=new lt(new ArrayBuffer(t.byteLength+e.length),0);n.write(t);for(let i of e){let s=this._type.encodeValue(i);n.write(new Uint8Array(s))}return n.buffer}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let t=Oe(-19),n=this._type.encodeType(e);e.add(this,me(t,n))}decodeValue(e,t){let n=this.checkType(t);if(!(n instanceof r))throw new Error("Not a vector type");let i=Number(Re(e));if(this._type instanceof wt){if(this._type._bits==8)return new Uint8Array(e.read(i));if(this._type._bits==16)return new Uint16Array(e.read(i*2));if(this._type._bits==32)return new Uint32Array(e.read(i*4));if(this._type._bits==64)return new BigUint64Array(e.read(i*8))}if(this._type instanceof vt){if(this._type._bits==8)return new Int8Array(e.read(i));if(this._type._bits==16)return new Int16Array(e.read(i*2));if(this._type._bits==32)return new Int32Array(e.read(i*4));if(this._type._bits==64)return new BigInt64Array(e.read(i*8))}let s=[];for(let o=0;o<i;o++)s.push(this._type.decodeValue(e,n._type));return s}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(e){return"vec {"+e.map(n=>this._type.valueToString(n)).join("; ")+"}"}},rr=class r extends yt{constructor(e){super(),this._type=e}accept(e,t){return e.visitOpt(this,this._type,t)}covariant(e){try{if(Array.isArray(e)&&(e.length===0||e.length===1&&this._type.covariant(e[0])))return!0}catch(t){throw new Error(`Invalid ${this.display()} argument: ${Be(e)}
4
-
5
- -> ${t.message}`)}throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(e){return e.length===0?new Uint8Array([0]):me(new Uint8Array([1]),this._type.encodeValue(e[0]))}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let t=Oe(-18),n=this._type.encodeType(e);e.add(this,me(t,n))}decodeValue(e,t){let n=this.checkType(t);if(!(n instanceof r))throw new Error("Not an option type");switch(Ot(e)){case 0:return[];case 1:return[this._type.decodeValue(e,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(e){return e.length===0?"null":`opt ${this._type.valueToString(e[0])}`}},Er=class r extends yt{constructor(e={}){super(),this._fields=Object.entries(e).sort((t,n)=>ht(t[0])-ht(n[0]))}accept(e,t){return e.visitRecord(this,this._fields,t)}tryAsTuple(){let e=[];for(let t=0;t<this._fields.length;t++){let[n,i]=this._fields[t];if(n!==`_${t}_`)return null;e.push(i)}return e}covariant(e){if(typeof e=="object"&&this._fields.every(([t,n])=>{if(!e.hasOwnProperty(t))throw new Error(`Record is missing key "${t}".`);try{return n.covariant(e[t])}catch(i){throw new Error(`Invalid ${this.display()} argument:
6
-
7
- field ${t} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(e){let t=this._fields.map(([i])=>e[i]),n=yr(this._fields,t,([,i],s)=>i.encodeValue(s));return me(...n)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let t=Oe(-20),n=Ie(this._fields.length),i=this._fields.map(([s,o])=>me(Ie(ht(s)),o.encodeType(e)));e.add(this,me(t,n,me(...i)))}decodeValue(e,t){let n=this.checkType(t);if(!(n instanceof r))throw new Error("Not a record type");let i={},s=0,o=0;for(;o<n._fields.length;){let[f,c]=n._fields[o];if(s>=this._fields.length){c.decodeValue(e,c),o++;continue}let[m,S]=this._fields[s],p=ht(this._fields[s][0]),F=ht(f);if(p===F)i[m]=S.decodeValue(e,c),s++,o++;else if(F>p)if(S instanceof rr||S instanceof tr)i[m]=[],s++;else throw new Error("Cannot find required field "+m);else c.decodeValue(e,c),o++}for(let[f,c]of this._fields.slice(s))if(c instanceof rr||c instanceof tr)i[f]=[];else throw new Error("Cannot find required field "+f);return i}get name(){return`record {${this._fields.map(([t,n])=>t+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([t,n])=>t+":"+n.display()).join("; ")}}`}valueToString(e){let t=this._fields.map(([i])=>e[i]);return`record {${yr(this._fields,t,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}},gn=class r extends Er{constructor(e){let t={};e.forEach((n,i)=>t["_"+i+"_"]=n),super(t),this._components=e}accept(e,t){return e.visitTuple(this,this._components,t)}covariant(e){if(Array.isArray(e)&&e.length>=this._fields.length&&this._components.every((t,n)=>{try{return t.covariant(e[n])}catch(i){throw new Error(`Invalid ${this.display()} argument:
8
-
9
- index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(e){let t=yr(this._components,e,(n,i)=>n.encodeValue(i));return me(...t)}decodeValue(e,t){let n=this.checkType(t);if(!(n instanceof r))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let i=[];for(let[s,o]of n._components.entries())s>=this._components.length?o.decodeValue(e,o):i.push(this._components[s].decodeValue(e,o));return i}display(){return`record {${this._components.map(t=>t.display()).join("; ")}}`}valueToString(e){return`record {${yr(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}},bn=class r extends yt{constructor(e={}){super(),this._fields=Object.entries(e).sort((t,n)=>ht(t[0])-ht(n[0]))}accept(e,t){return e.visitVariant(this,this._fields,t)}covariant(e){if(typeof e=="object"&&Object.entries(e).length===1&&this._fields.every(([t,n])=>{try{return!e.hasOwnProperty(t)||n.covariant(e[t])}catch(i){throw new Error(`Invalid ${this.display()} argument:
10
-
11
- variant ${t} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(e){for(let t=0;t<this._fields.length;t++){let[n,i]=this._fields[t];if(e.hasOwnProperty(n)){let s=Ie(t),o=i.encodeValue(e[n]);return me(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let t=Oe(-21),n=Ie(this._fields.length),i=this._fields.map(([s,o])=>me(Ie(ht(s)),o.encodeType(e)));e.add(this,me(t,n,...i))}decodeValue(e,t){let n=this.checkType(t);if(!(n instanceof r))throw new Error("Not a variant type");let i=Number(Re(e));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,o]=n._fields[i];for(let[f,c]of this._fields)if(ht(s)===ht(f)){let m=c.decodeValue(e,o);return{[f]:m}}throw new Error("Cannot find field hash "+s)}get name(){return`variant {${this._fields.map(([t,n])=>t+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([t,n])=>t+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(e){for(let[t,n]of this._fields)if(e.hasOwnProperty(t)){let i=n.valueToString(e[t]);return i==="null"?`variant {${t}}`:`variant {${t}=${i}}`}throw new Error("Variant has no data: "+e)}},Pt=class r extends yt{constructor(){super(...arguments),this._id=r._counter++,this._type=void 0}accept(e,t){if(!this._type)throw Error("Recursive type uninitialized.");return e.visitRec(this,this._type,t)}fill(e){this._type=e}getType(){return this._type}covariant(e){if(this._type&&this._type.covariant(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(e)}_buildTypeTableImpl(e){if(!this._type)throw Error("Recursive type uninitialized.");e.add(this,new Uint8Array([])),this._type.buildTypeTable(e),e.merge(this,this._type.name)}decodeValue(e,t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(e,t)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(e)}};Pt._counter=0;function Pi(r){if(Ot(r)!==1)throw new Error("Cannot decode principal");let t=Number(Re(r));return Ge.fromUint8Array(new Uint8Array(Ft(r,t)))}var wn=class extends Xe{accept(e,t){return e.visitPrincipal(this,t)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(e){let t=e.toUint8Array(),n=Ie(t.byteLength);return me(new Uint8Array([1]),n,t)}encodeType(){return Oe(-24)}decodeValue(e,t){return this.checkType(t),Pi(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}},_r=class extends yt{constructor(e,t,n=[]){super(),this.argTypes=e,this.retTypes=t,this.annotations=n}static argsToString(e,t){if(e.length!==t.length)throw new Error("arity mismatch");return"("+e.map((n,i)=>n.valueToString(t[i])).join(", ")+")"}accept(e,t){return e.visitFunc(this,t)}covariant(e){if(Array.isArray(e)&&e.length===2&&e[0]&&e[0]._isPrincipal&&typeof e[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue([e,t]){let n=e.toUint8Array(),i=Ie(n.byteLength),s=me(new Uint8Array([1]),i,n),o=new TextEncoder().encode(t),f=Ie(o.byteLength);return me(new Uint8Array([1]),s,f,o)}_buildTypeTableImpl(e){this.argTypes.forEach(m=>m.buildTypeTable(e)),this.retTypes.forEach(m=>m.buildTypeTable(e));let t=Oe(-22),n=Ie(this.argTypes.length),i=me(...this.argTypes.map(m=>m.encodeType(e))),s=Ie(this.retTypes.length),o=me(...this.retTypes.map(m=>m.encodeType(e))),f=Ie(this.annotations.length),c=me(...this.annotations.map(m=>this.encodeAnnotation(m)));e.add(this,me(t,n,i,s,o,f,c))}decodeValue(e){if(Ot(e)!==1)throw new Error("Cannot decode function reference");let n=Pi(e),i=Number(Re(e)),s=Ft(e,i),f=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,f]}get name(){let e=this.argTypes.map(i=>i.name).join(", "),t=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${e}) -> (${t})${n}`}valueToString([e,t]){return`func "${e.toText()}".${t}`}display(){let e=this.argTypes.map(i=>i.display()).join(", "),t=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${e}) \u2192 (${t})${n}`}encodeAnnotation(e){if(e==="query")return new Uint8Array([1]);if(e==="oneway")return new Uint8Array([2]);if(e==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}},yn=class extends yt{constructor(e){super(),this._fields=Object.entries(e).sort((t,n)=>t[0]<n[0]?-1:t[0]>n[0]?1:0)}accept(e,t){return e.visitService(this,t)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Be(e)}`)}encodeValue(e){let t=e.toUint8Array(),n=Ie(t.length);return me(new Uint8Array([1]),n,t)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let t=Oe(-23),n=Ie(this._fields.length),i=this._fields.map(([s,o])=>{let f=new TextEncoder().encode(s),c=Ie(f.length);return me(c,f,o.encodeType(e))});e.add(this,me(t,n,...i))}decodeValue(e){return Pi(e)}get name(){return`service {${this._fields.map(([t,n])=>t+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};function Be(r){let e=JSON.stringify(r,(t,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>No?e.substring(0,No-3)+"...":e}function Vu(r,e){if(e.length<r.length)throw Error("Wrong number of message arguments");let t=new Fi;r.forEach(c=>c.buildTypeTable(t));let n=new TextEncoder().encode(on),i=t.encode(),s=Ie(e.length),o=me(...r.map(c=>c.encodeType(t))),f=me(...yr(r,e,(c,m)=>{try{c.covariant(m)}catch(S){throw new Error(S.message+`
12
-
13
- `)}return c.encodeValue(m)}));return me(n,i,s,o,f)}function Yu(r,e){let t=new lt(e);if(e.byteLength<on.length)throw new Error("Message length smaller than magic number");let n=Ft(t,on.length),i=new TextDecoder().decode(n);if(i!==on)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(v){let u=[],B=Number(Re(v));for(let G=0;G<B;G++){let z=Number(_t(v));switch(z){case-18:case-19:{let Z=Number(_t(v));u.push([z,Z]);break}case-20:case-21:{let Z=[],E=Number(Re(v)),L;for(;E--;){let C=Number(Re(v));if(C>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof L=="number"&&L>=C)throw new Error("field id collision or not sorted");L=C;let V=Number(_t(v));Z.push([C,V])}u.push([z,Z]);break}case-22:{let Z=[],E=Number(Re(v));for(;E--;)Z.push(Number(_t(v)));let L=[],C=Number(Re(v));for(;C--;)L.push(Number(_t(v)));let V=[],$=Number(Re(v));for(;$--;)switch(Number(Re(v))){case 1:{V.push("query");break}case 2:{V.push("oneway");break}case 3:{V.push("composite_query");break}default:throw new Error("unknown annotation")}u.push([z,[Z,L,V]]);break}case-23:{let Z=Number(Re(v)),E=[];for(;Z--;){let L=Number(Re(v)),C=new TextDecoder().decode(Ft(v,L)),V=_t(v);E.push([C,V])}u.push([z,E]);break}default:throw new Error("Illegal op_code: "+z)}}let D=[],P=Number(Re(v));for(let G=0;G<P;G++)D.push(Number(_t(v)));return[u,D]}let[o,f]=s(t);if(f.length<r.length)throw new Error("Wrong number of return values");let c=o.map(v=>Qo());function m(v){if(v<-24)throw new Error("future value not supported");if(v<0)switch(v){case-1:return Fo;case-2:return Oo;case-3:return Mo;case-4:return Lo;case-5:return Vo;case-6:return Yo;case-7:return Ho;case-8:return zo;case-9:return qo;case-10:return $o;case-11:return Go;case-12:return Co;case-13:return Do;case-14:return ko;case-15:return Po;case-16:return Ro;case-17:return Uo;case-24:return jo;default:throw new Error("Illegal op_code: "+v)}if(v>=o.length)throw new Error("type index out of range");return c[v]}function S(v){switch(v[0]){case-19:{let u=m(v[1]);return Ko(u)}case-18:{let u=m(v[1]);return Wo(u)}case-20:{let u={};for(let[P,G]of v[1]){let z=`_${P}_`;u[z]=m(G)}let B=Xo(u),D=B.tryAsTuple();return Array.isArray(D)?Zo(...D):B}case-21:{let u={};for(let[B,D]of v[1]){let P=`_${B}_`;u[P]=m(D)}return Jo(u)}case-22:{let[u,B,D]=v[1];return ea(u.map(P=>m(P)),B.map(P=>m(P)),D)}case-23:{let u={},B=v[1];for(let[D,P]of B){let G=m(P);if(G instanceof Pt&&(G=G.getType()),!(G instanceof _r))throw new Error("Illegal service definition: services can only contain functions");u[D]=G}return ta(u)}default:throw new Error("Illegal op_code: "+v[0])}}o.forEach((v,u)=>{if(v[0]===-22){let B=S(v);c[u].fill(B)}}),o.forEach((v,u)=>{if(v[0]!==-22){let B=S(v);c[u].fill(B)}});let p=f.map(v=>m(v)),F=r.map((v,u)=>v.decodeValue(t,p[u]));for(let v=r.length;v<p.length;v++)p[v].decodeValue(t,p[v]);if(t.byteLength>0)throw new Error("decode: Left-over bytes");return F}var Uo=new cn,Ro=new tr,Hu=new un,Oo=new fn,Fo=new ln,Po=new hn,Lo=new dn,Mo=new pn,Do=new xr(32),ko=new xr(64),qo=new vt(8),$o=new vt(16),Go=new vt(32),Co=new vt(64),Vo=new wt(8),Yo=new wt(16),Ho=new wt(32),zo=new wt(64),jo=new wn;function Zo(...r){return new gn(r)}function Ko(r){return new mn(r)}function Wo(r){return new rr(r)}function Xo(r){return new Er(r)}function Jo(r){return new bn(r)}function Qo(){return new Pt}function ea(r,e,t=[]){return new _r(r,e,t)}function ta(r){return new yn(r)}var ra=Pr(gi());function st(r){return br(lr.create().update(new Uint8Array(r)).digest())}function xn(r){if(r instanceof ra.default.Tagged)return xn(r.value);if(typeof r=="string")return na(r);if(typeof r=="number")return st(Ie(r));if(r instanceof ArrayBuffer||ArrayBuffer.isView(r))return st(r);if(Array.isArray(r)){let e=r.map(xn);return st(it(...e))}else{if(r&&typeof r=="object"&&r._isPrincipal)return st(r.toUint8Array());if(typeof r=="object"&&r!==null&&typeof r.toHash=="function")return xn(r.toHash());if(typeof r=="object")return ia(r);if(typeof r=="bigint")return st(Ie(r))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${r}`),{value:r})}var na=r=>{let e=new TextEncoder().encode(r);return st(e)};function tl(r){return ia(r)}function ia(r){let n=Object.entries(r).filter(([,o])=>o!==void 0).map(([o,f])=>{let c=na(o),m=xn(f);return[c,m]}).sort(([o],[f])=>_i(o,f)),i=it(...n.map(o=>it(...o)));return st(i)}var Gi={};Cn(Gi,{aInRange:()=>Ar,abool:()=>_n,abytes:()=>dt,bitGet:()=>$i,bitLen:()=>Ht,bitMask:()=>Lt,bitSet:()=>Xu,bytesToHex:()=>At,bytesToNumberBE:()=>He,bytesToNumberLE:()=>vn,concatBytes:()=>ve,createHmacDrbg:()=>ca,ensureBytes:()=>pt,equalBytes:()=>Wu,hexToBytes:()=>vr,hexToNumber:()=>qi,inRange:()=>An,isBytes:()=>nr,memoized:()=>ir,notImplemented:()=>Bn,numberToBytesBE:()=>Se,numberToBytesLE:()=>In,numberToHexUnpadded:()=>aa,numberToVarBytesBE:()=>Ku,utf8ToBytes:()=>Ir,validateObject:()=>Bt});var ki=BigInt(0),En=BigInt(1),ju=BigInt(2);function nr(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function dt(r){if(!nr(r))throw new Error("Uint8Array expected")}function _n(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var Zu=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function At(r){dt(r);let e="";for(let t=0;t<r.length;t++)e+=Zu[r[t]];return e}function aa(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function qi(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var It={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function sa(r){if(r>=It._0&&r<=It._9)return r-It._0;if(r>=It._A&&r<=It._F)return r-(It._A-10);if(r>=It._a&&r<=It._f)return r-(It._a-10)}function vr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let i=0,s=0;i<t;i++,s+=2){let o=sa(r.charCodeAt(s)),f=sa(r.charCodeAt(s+1));if(o===void 0||f===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+f}return n}function He(r){return qi(At(r))}function vn(r){return dt(r),qi(At(Uint8Array.from(r).reverse()))}function Se(r,e){return vr(r.toString(16).padStart(e*2,"0"))}function In(r,e){return Se(r,e).reverse()}function Ku(r){return vr(aa(r))}function pt(r,e,t){let n;if(typeof e=="string")try{n=vr(e)}catch(s){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${s}`)}else if(nr(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let i=n.length;if(typeof t=="number"&&i!==t)throw new Error(`${r} expected ${t} bytes, got ${i}`);return n}function ve(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];dt(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let s=r[n];t.set(s,i),i+=s.length}return t}function Wu(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function Ir(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var Mi=r=>typeof r=="bigint"&&ki<=r;function An(r,e,t){return Mi(r)&&Mi(e)&&Mi(t)&&e<=r&&r<t}function Ar(r,e,t,n){if(!An(e,t,n))throw new Error(`expected valid ${r}: ${t} <= n < ${n}, got ${typeof e} ${e}`)}function Ht(r){let e;for(e=0;r>ki;r>>=En,e+=1);return e}function $i(r,e){return r>>BigInt(e)&En}function Xu(r,e,t){return r|(t?En:ki)<<BigInt(e)}var Lt=r=>(ju<<BigInt(r-1))-En,Di=r=>new Uint8Array(r),oa=r=>Uint8Array.from(r);function ca(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=Di(r),i=Di(r),s=0,o=()=>{n.fill(1),i.fill(0),s=0},f=(...p)=>t(i,n,...p),c=(p=Di())=>{i=f(oa([0]),p),n=f(),p.length!==0&&(i=f(oa([1]),p),n=f())},m=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let p=0,F=[];for(;p<e;){n=f();let v=n.slice();F.push(v),p+=n.length}return ve(...F)};return(p,F)=>{o(),c(p);let v;for(;!(v=F(m()));)c();return o(),v}}var Ju={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||nr(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Bt(r,e,t={}){let n=(i,s,o)=>{let f=Ju[s];if(typeof f!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=r[i];if(!(o&&c===void 0)&&!f(c,r))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(t))n(i,s,!0);return r}var Bn=()=>{throw new Error("not implemented")};function ir(r){let e=new WeakMap;return(t,...n)=>{let i=e.get(t);if(i!==void 0)return i;let s=r(t,...n);return e.set(t,s),s}}var Le=BigInt(0),ye=BigInt(1),Mt=BigInt(2),Qu=BigInt(3),Ci=BigInt(4),ua=BigInt(5),fa=BigInt(8),ef=BigInt(9),tf=BigInt(16);function je(r,e){let t=r%e;return t>=Le?t:e+t}function rf(r,e,t){if(t<=Le||e<Le)throw new Error("Expected power/modulo > 0");if(t===ye)return Le;let n=ye;for(;e>Le;)e&ye&&(n=n*r%t),r=r*r%t,e>>=ye;return n}function il(r,e,t){let n=r;for(;e-- >Le;)n*=n,n%=t;return n}function Vi(r,e){if(r===Le||e<=Le)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=je(r,e),n=e,i=Le,s=ye,o=ye,f=Le;for(;t!==Le;){let m=n/t,S=n%t,p=i-o*m,F=s-f*m;n=t,t=S,i=o,s=f,o=p,f=F}if(n!==ye)throw new Error("invert: does not exist");return je(i,e)}function nf(r){let e=(r-ye)/Mt,t,n,i;for(t=r-ye,n=0;t%Mt===Le;t/=Mt,n++);for(i=Mt;i<r&&rf(i,e,r)!==r-ye;i++);if(n===1){let o=(r+ye)/Ci;return function(c,m){let S=c.pow(m,o);if(!c.eql(c.sqr(S),m))throw new Error("Cannot find square root");return S}}let s=(t+ye)/Mt;return function(f,c){if(f.pow(c,e)===f.neg(f.ONE))throw new Error("Cannot find square root");let m=n,S=f.pow(f.mul(f.ONE,i),t),p=f.pow(c,s),F=f.pow(c,t);for(;!f.eql(F,f.ONE);){if(f.eql(F,f.ZERO))return f.ZERO;let v=1;for(let B=f.sqr(F);v<m&&!f.eql(B,f.ONE);v++)B=f.sqr(B);let u=f.pow(S,ye<<BigInt(m-v-1));S=f.sqr(u),p=f.mul(p,u),F=f.mul(F,S),m=v}return p}}function sf(r){if(r%Ci===Qu){let e=(r+ye)/Ci;return function(n,i){let s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(r%fa===ua){let e=(r-ua)/fa;return function(n,i){let s=n.mul(i,Mt),o=n.pow(s,e),f=n.mul(i,o),c=n.mul(n.mul(f,Mt),o),m=n.mul(f,n.sub(c,n.ONE));if(!n.eql(n.sqr(m),i))throw new Error("Cannot find square root");return m}}return r%tf,nf(r)}var sl=(r,e)=>(je(r,e)&ye)===ye,of=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Sn(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=of.reduce((n,i)=>(n[i]="function",n),e);return Bt(r,t)}function Br(r,e,t){if(t<Le)throw new Error("Expected power > 0");if(t===Le)return r.ONE;if(t===ye)return e;let n=r.ONE,i=e;for(;t>Le;)t&ye&&(n=r.mul(n,i)),i=r.sqr(i),t>>=ye;return n}function Sr(r,e){let t=new Array(e.length),n=e.reduce((s,o,f)=>r.is0(o)?s:(t[f]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return e.reduceRight((s,o,f)=>r.is0(o)?s:(t[f]=r.mul(s,t[f]),r.mul(s,o)),i),t}function la(r){let e=(r-ye)/Mt;return(t,n)=>t.pow(n,e)}function Yi(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Tn(r,e,t=!1,n={}){if(r<=Le)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:i,nByteLength:s}=Yi(r,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=sf(r),f=Object.freeze({ORDER:r,BITS:i,BYTES:s,MASK:Lt(i),ZERO:Le,ONE:ye,create:c=>je(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return Le<=c&&c<r},is0:c=>c===Le,isOdd:c=>(c&ye)===ye,neg:c=>je(-c,r),eql:(c,m)=>c===m,sqr:c=>je(c*c,r),add:(c,m)=>je(c+m,r),sub:(c,m)=>je(c-m,r),mul:(c,m)=>je(c*m,r),pow:(c,m)=>Br(f,c,m),div:(c,m)=>je(c*Vi(m,r),r),sqrN:c=>c*c,addN:(c,m)=>c+m,subN:(c,m)=>c-m,mulN:(c,m)=>c*m,inv:c=>Vi(c,r),sqrt:n.sqrt||(c=>o(f,c)),invertBatch:c=>Sr(f,c),cmov:(c,m,S)=>S?m:c,toBytes:c=>t?In(c,s):Se(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return t?vn(c):He(c)}});return Object.freeze(f)}function ha(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function Nn(r){let e=ha(r);return e+Math.ceil(e/2)}function Hi(r,e,t=!1){let n=r.length,i=ha(e),s=Nn(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=t?He(r):vn(r),f=je(o,e-ye)+ye;return t?In(f,i):Se(f,i)}var af=He;function Dt(r,e){if(r<0||r>=1<<8*e)throw new Error(`bad I2OSP call: value=${r} length=${e}`);let t=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)t[n]=r&255,r>>>=8;return new Uint8Array(t)}function cf(r,e){let t=new Uint8Array(r.length);for(let n=0;n<r.length;n++)t[n]=r[n]^e[n];return t}function ji(r){if(!Number.isSafeInteger(r))throw new Error("number expected")}function uf(r,e,t,n){dt(r),dt(e),ji(t),e.length>255&&(e=n(ve(Ir("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(t/i);if(o>255)throw new Error("Invalid xmd length");let f=ve(e,Dt(e.length,1)),c=Dt(0,s),m=Dt(t,2),S=new Array(o),p=n(ve(c,r,m,Dt(0,1),f));S[0]=n(ve(p,Dt(1,1),f));for(let v=1;v<=o;v++){let u=[cf(p,S[v-1]),Dt(v+1,1),f];S[v]=n(ve(...u))}return ve(...S).slice(0,t)}function ff(r,e,t,n,i){if(dt(r),dt(e),ji(t),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update(Ir("H2C-OVERSIZE-DST-")).update(e).digest()}if(t>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:t}).update(r).update(Dt(t,2)).update(e).update(Dt(e.length,1)).digest()}function da(r,e,t){Bt(t,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:f,DST:c}=t;dt(r),ji(e);let m=typeof c=="string"?Ir(c):c,S=n.toString(2).length,p=Math.ceil((S+i)/8),F=e*s*p,v;if(f==="xmd")v=uf(r,m,F,o);else if(f==="xof")v=ff(r,m,F,i,o);else if(f==="_internal_pass")v=r;else throw new Error('expand must be "xmd" or "xof"');let u=new Array(e);for(let B=0;B<e;B++){let D=new Array(s);for(let P=0;P<s;P++){let G=p*(P+B*s),z=v.subarray(G,G+p);D[P]=je(af(z),n)}u[B]=D}return u}function Zi(r,e){let t=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,f,c]=t.map(m=>m.reduce((S,p)=>r.add(r.mul(S,n),p)));return n=r.div(s,o),i=r.mul(i,r.div(f,c)),{x:n,y:i}}}function Ki(r,e,t){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=da(n,2,{...t,DST:t.DST,...i}),o=r.fromAffine(e(s[0])),f=r.fromAffine(e(s[1])),c=o.add(f).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=da(n,1,{...t,DST:t.encodeDST,...i}),o=r.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(let s of n)if(typeof s!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${s} in array`);let i=r.fromAffine(e(n)).clearCofactor();return i.assertValidity(),i}}}var lf=BigInt(0),Wi=BigInt(1),Xi=new WeakMap,pa=new WeakMap;function ma(r,e){let t=(s,o)=>{let f=o.negate();return s?f:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error(`Wrong window size=${s}, should be [1..${e}]`)},i=s=>{n(s);let o=Math.ceil(e/s)+1,f=2**(s-1);return{windows:o,windowSize:f}};return{constTimeNegate:t,unsafeLadder(s,o){let f=r.ZERO,c=s;for(;o>lf;)o&Wi&&(f=f.add(c)),c=c.double(),o>>=Wi;return f},precomputeWindow(s,o){let{windows:f,windowSize:c}=i(o),m=[],S=s,p=S;for(let F=0;F<f;F++){p=S,m.push(p);for(let v=1;v<c;v++)p=p.add(S),m.push(p);S=p.double()}return m},wNAF(s,o,f){let{windows:c,windowSize:m}=i(s),S=r.ZERO,p=r.BASE,F=BigInt(2**s-1),v=2**s,u=BigInt(s);for(let B=0;B<c;B++){let D=B*m,P=Number(f&F);f>>=u,P>m&&(P-=v,f+=Wi);let G=D,z=D+Math.abs(P)-1,Z=B%2!==0,E=P<0;P===0?p=p.add(t(Z,o[G])):S=S.add(t(E,o[z]))}return{p:S,f:p}},wNAFCached(s,o,f){let c=pa.get(s)||1,m=Xi.get(s);return m||(m=this.precomputeWindow(s,c),c!==1&&Xi.set(s,f(m))),this.wNAF(c,m,o)},setWindowSize(s,o){n(o),pa.set(s,o),Xi.delete(s)}}}function ga(r){return Sn(r.Fp),Bt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Yi(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}function hf(r){let e=ga(r);Bt(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:i}=e;if(t){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:pl,hexToBytes:ml}=Gi;var zt=BigInt(0),Te=BigInt(1),kt=BigInt(2),Un=BigInt(3),ba=BigInt(4);function Ji(r){let e=hf(r),{Fp:t}=e,n=e.toBytes||((u,B,D)=>{let P=B.toAffine();return ve(Uint8Array.from([4]),t.toBytes(P.x),t.toBytes(P.y))}),i=e.fromBytes||(u=>{let B=u.subarray(1),D=t.fromBytes(B.subarray(0,t.BYTES)),P=t.fromBytes(B.subarray(t.BYTES,2*t.BYTES));return{x:D,y:P}});function s(u){let{a:B,b:D}=e,P=t.sqr(u),G=t.mul(P,u);return t.add(t.add(G,t.mul(u,B)),D)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(u){return An(u,Te,e.n)}function f(u){let{allowedPrivateKeyLengths:B,nByteLength:D,wrapPrivateKey:P,n:G}=e;if(B&&typeof u!="bigint"){if(nr(u)&&(u=At(u)),typeof u!="string"||!B.includes(u.length))throw new Error("Invalid key");u=u.padStart(D*2,"0")}let z;try{z=typeof u=="bigint"?u:He(pt("private key",u,D))}catch{throw new Error(`private key must be ${D} bytes, hex or bigint, not ${typeof u}`)}return P&&(z=je(z,G)),Ar("private key",z,Te,G),z}function c(u){if(!(u instanceof p))throw new Error("ProjectivePoint expected")}let m=ir((u,B)=>{let{px:D,py:P,pz:G}=u;if(t.eql(G,t.ONE))return{x:D,y:P};let z=u.is0();B==null&&(B=z?t.ONE:t.inv(G));let Z=t.mul(D,B),E=t.mul(P,B),L=t.mul(G,B);if(z)return{x:t.ZERO,y:t.ZERO};if(!t.eql(L,t.ONE))throw new Error("invZ was invalid");return{x:Z,y:E}}),S=ir(u=>{if(u.is0()){if(e.allowInfinityPoint&&!t.is0(u.py))return;throw new Error("bad point: ZERO")}let{x:B,y:D}=u.toAffine();if(!t.isValid(B)||!t.isValid(D))throw new Error("bad point: x or y not FE");let P=t.sqr(D),G=s(B);if(!t.eql(P,G))throw new Error("bad point: equation left != right");if(!u.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class p{constructor(B,D,P){if(this.px=B,this.py=D,this.pz=P,B==null||!t.isValid(B))throw new Error("x required");if(D==null||!t.isValid(D))throw new Error("y required");if(P==null||!t.isValid(P))throw new Error("z required");Object.freeze(this)}static fromAffine(B){let{x:D,y:P}=B||{};if(!B||!t.isValid(D)||!t.isValid(P))throw new Error("invalid affine point");if(B instanceof p)throw new Error("projective point not allowed");let G=z=>t.eql(z,t.ZERO);return G(D)&&G(P)?p.ZERO:new p(D,P,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(B){let D=t.invertBatch(B.map(P=>P.pz));return B.map((P,G)=>P.toAffine(D[G])).map(p.fromAffine)}static fromHex(B){let D=p.fromAffine(i(pt("pointHex",B)));return D.assertValidity(),D}static fromPrivateKey(B){return p.BASE.multiply(f(B))}_setWindowSize(B){v.setWindowSize(this,B)}assertValidity(){S(this)}hasEvenY(){let{y:B}=this.toAffine();if(t.isOdd)return!t.isOdd(B);throw new Error("Field doesn't support isOdd")}equals(B){c(B);let{px:D,py:P,pz:G}=this,{px:z,py:Z,pz:E}=B,L=t.eql(t.mul(D,E),t.mul(z,G)),C=t.eql(t.mul(P,E),t.mul(Z,G));return L&&C}negate(){return new p(this.px,t.neg(this.py),this.pz)}double(){let{a:B,b:D}=e,P=t.mul(D,Un),{px:G,py:z,pz:Z}=this,E=t.ZERO,L=t.ZERO,C=t.ZERO,V=t.mul(G,G),$=t.mul(z,z),ee=t.mul(Z,Z),J=t.mul(G,z);return J=t.add(J,J),C=t.mul(G,Z),C=t.add(C,C),E=t.mul(B,C),L=t.mul(P,ee),L=t.add(E,L),E=t.sub($,L),L=t.add($,L),L=t.mul(E,L),E=t.mul(J,E),C=t.mul(P,C),ee=t.mul(B,ee),J=t.sub(V,ee),J=t.mul(B,J),J=t.add(J,C),C=t.add(V,V),V=t.add(C,V),V=t.add(V,ee),V=t.mul(V,J),L=t.add(L,V),ee=t.mul(z,Z),ee=t.add(ee,ee),V=t.mul(ee,J),E=t.sub(E,V),C=t.mul(ee,$),C=t.add(C,C),C=t.add(C,C),new p(E,L,C)}add(B){c(B);let{px:D,py:P,pz:G}=this,{px:z,py:Z,pz:E}=B,L=t.ZERO,C=t.ZERO,V=t.ZERO,$=e.a,ee=t.mul(e.b,Un),J=t.mul(D,z),oe=t.mul(P,Z),g=t.mul(G,E),_=t.add(D,P),R=t.add(z,Z);_=t.mul(_,R),R=t.add(J,oe),_=t.sub(_,R),R=t.add(D,G);let k=t.add(z,E);return R=t.mul(R,k),k=t.add(J,g),R=t.sub(R,k),k=t.add(P,G),L=t.add(Z,E),k=t.mul(k,L),L=t.add(oe,g),k=t.sub(k,L),V=t.mul($,R),L=t.mul(ee,g),V=t.add(L,V),L=t.sub(oe,V),V=t.add(oe,V),C=t.mul(L,V),oe=t.add(J,J),oe=t.add(oe,J),g=t.mul($,g),R=t.mul(ee,R),oe=t.add(oe,g),g=t.sub(J,g),g=t.mul($,g),R=t.add(R,g),J=t.mul(oe,R),C=t.add(C,J),J=t.mul(k,R),L=t.mul(_,L),L=t.sub(L,J),J=t.mul(_,oe),V=t.mul(k,V),V=t.add(V,J),new p(L,C,V)}subtract(B){return this.add(B.negate())}is0(){return this.equals(p.ZERO)}wNAF(B){return v.wNAFCached(this,B,p.normalizeZ)}multiplyUnsafe(B){Ar("scalar",B,zt,e.n);let D=p.ZERO;if(B===zt)return D;if(B===Te)return this;let{endo:P}=e;if(!P)return v.unsafeLadder(this,B);let{k1neg:G,k1:z,k2neg:Z,k2:E}=P.splitScalar(B),L=D,C=D,V=this;for(;z>zt||E>zt;)z&Te&&(L=L.add(V)),E&Te&&(C=C.add(V)),V=V.double(),z>>=Te,E>>=Te;return G&&(L=L.negate()),Z&&(C=C.negate()),C=new p(t.mul(C.px,P.beta),C.py,C.pz),L.add(C)}multiply(B){let{endo:D,n:P}=e;Ar("scalar",B,Te,P);let G,z;if(D){let{k1neg:Z,k1:E,k2neg:L,k2:C}=D.splitScalar(B),{p:V,f:$}=this.wNAF(E),{p:ee,f:J}=this.wNAF(C);V=v.constTimeNegate(Z,V),ee=v.constTimeNegate(L,ee),ee=new p(t.mul(ee.px,D.beta),ee.py,ee.pz),G=V.add(ee),z=$.add(J)}else{let{p:Z,f:E}=this.wNAF(B);G=Z,z=E}return p.normalizeZ([G,z])[0]}multiplyAndAddUnsafe(B,D,P){let G=p.BASE,z=(E,L)=>L===zt||L===Te||!E.equals(G)?E.multiplyUnsafe(L):E.multiply(L),Z=z(this,D).add(z(B,P));return Z.is0()?void 0:Z}toAffine(B){return m(this,B)}isTorsionFree(){let{h:B,isTorsionFree:D}=e;if(B===Te)return!0;if(D)return D(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:B,clearCofactor:D}=e;return B===Te?this:D?D(p,this):this.multiplyUnsafe(e.h)}toRawBytes(B=!0){return _n("isCompressed",B),this.assertValidity(),n(p,this,B)}toHex(B=!0){return _n("isCompressed",B),At(this.toRawBytes(B))}}p.BASE=new p(e.Gx,e.Gy,t.ONE),p.ZERO=new p(t.ZERO,t.ONE,t.ZERO);let F=e.nBitLength,v=ma(p,e.endo?Math.ceil(F/2):F);return{CURVE:e,ProjectivePoint:p,normPrivateKeyToScalar:f,weierstrassEquation:s,isWithinCurveOrder:o}}function df(r,e){let t=r.ORDER,n=zt;for(let u=t-Te;u%kt===zt;u/=kt)n+=Te;let i=n,s=kt<<i-Te-Te,o=s*kt,f=(t-Te)/o,c=(f-Te)/kt,m=o-Te,S=s,p=r.pow(e,f),F=r.pow(e,(f+Te)/kt),v=(u,B)=>{let D=p,P=r.pow(B,m),G=r.sqr(P);G=r.mul(G,B);let z=r.mul(u,G);z=r.pow(z,c),z=r.mul(z,P),P=r.mul(z,B),G=r.mul(z,u);let Z=r.mul(G,P);z=r.pow(Z,S);let E=r.eql(z,r.ONE);P=r.mul(G,F),z=r.mul(Z,D),G=r.cmov(P,G,E),Z=r.cmov(z,Z,E);for(let L=i;L>Te;L--){let C=L-kt;C=kt<<C-Te;let V=r.pow(Z,C),$=r.eql(V,r.ONE);P=r.mul(G,D),D=r.mul(D,D),V=r.mul(Z,D),G=r.cmov(P,G,$),Z=r.cmov(V,Z,$)}return{isValid:E,value:G}};if(r.ORDER%ba===Un){let u=(r.ORDER-Un)/ba,B=r.sqrt(r.neg(e));v=(D,P)=>{let G=r.sqr(P),z=r.mul(D,P);G=r.mul(G,z);let Z=r.pow(G,u);Z=r.mul(Z,z);let E=r.mul(Z,B),L=r.mul(r.sqr(Z),P),C=r.eql(L,D),V=r.cmov(E,Z,C);return{isValid:C,value:V}}}return v}function Qi(r,e){if(Sn(r),!r.isValid(e.A)||!r.isValid(e.B)||!r.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let t=df(r,e.Z);if(!r.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,f,c,m,S,p;i=r.sqr(n),i=r.mul(i,e.Z),s=r.sqr(i),s=r.add(s,i),o=r.add(s,r.ONE),o=r.mul(o,e.B),f=r.cmov(e.Z,r.neg(s),!r.eql(s,r.ZERO)),f=r.mul(f,e.A),s=r.sqr(o),m=r.sqr(f),c=r.mul(m,e.A),s=r.add(s,c),s=r.mul(s,o),m=r.mul(m,f),c=r.mul(m,e.B),s=r.add(s,c),S=r.mul(i,o);let{isValid:F,value:v}=t(s,m);p=r.mul(i,n),p=r.mul(p,v),S=r.cmov(S,o,F),p=r.cmov(p,v,F);let u=r.isOdd(n)===r.isOdd(p);return p=r.cmov(r.neg(p),p,u),S=r.div(S,f),{x:S,y:p}}}var pf=BigInt(0),Rn=BigInt(1),wa=BigInt(2),sr=BigInt(3);function mf(r){let e=[];for(;r>Rn;r>>=Rn)(r&Rn)===pf?e.unshift(0):(r&sr)===sr?(e.unshift(-1),r+=Rn):e.unshift(1);return e}function ya(r){let{Fp:e,Fr:t,Fp2:n,Fp6:i,Fp12:s}=r.fields,o=r.params.xNegative,f=r.params.twistType,c=Ji({n:t.ORDER,...r.G1}),m=Object.assign(c,Ki(c.ProjectivePoint,r.G1.mapToCurve,{...r.htfDefaults,...r.G1.htfDefaults})),S=Ji({n:t.ORDER,...r.G2}),p=Object.assign(S,Ki(S.ProjectivePoint,r.G2.mapToCurve,{...r.htfDefaults,...r.G2.htfDefaults})),F;if(f==="multiplicative")F=(H,O,d,te,ne,ae)=>s.mul014(te,H,n.mul(O,ne),n.mul(d,ae));else if(f==="divisive")F=(H,O,d,te,ne,ae)=>s.mul034(te,n.mul(d,ae),n.mul(O,ne),H);else throw new Error("bls: unknown twist type");let v=n.div(n.ONE,n.mul(n.ONE,wa));function u(H,O,d,te){let ne=n.sqr(d),ae=n.sqr(te),j=n.mulByB(n.mul(ae,sr)),a=n.mul(j,sr),l=n.sub(n.sub(n.sqr(n.add(d,te)),ae),ne),h=n.sub(j,ne),A=n.mul(n.sqr(O),sr),y=n.neg(l);return H.push([h,A,y]),O=n.mul(n.mul(n.mul(n.sub(ne,a),O),d),v),d=n.sub(n.sqr(n.mul(n.add(ne,a),v)),n.mul(n.sqr(j),sr)),te=n.mul(ne,l),{Rx:O,Ry:d,Rz:te}}function B(H,O,d,te,ne,ae){let j=n.sub(d,n.mul(ae,te)),a=n.sub(O,n.mul(ne,te)),l=n.sub(n.mul(j,ne),n.mul(a,ae)),h=n.neg(j),A=a;H.push([l,h,A]);let y=n.sqr(a),x=n.mul(y,a),U=n.mul(y,O),b=n.add(n.sub(x,n.mul(U,wa)),n.mul(n.sqr(j),te));return O=n.mul(a,b),d=n.sub(n.mul(n.sub(U,b),j),n.mul(x,d)),te=n.mul(te,x),{Rx:O,Ry:d,Rz:te}}let D=mf(r.params.ateLoopSize),P=ir(H=>{let O=H,{x:d,y:te}=O.toAffine(),ne=d,ae=te,j=n.neg(te),a=ne,l=ae,h=n.ONE,A=[];for(let y of D){let x=[];({Rx:a,Ry:l,Rz:h}=u(x,a,l,h)),y&&({Rx:a,Ry:l,Rz:h}=B(x,a,l,h,ne,y===-1?j:ae)),A.push(x)}if(r.postPrecompute){let y=A[A.length-1];r.postPrecompute(a,l,h,ne,ae,B.bind(null,y))}return A});function G(H,O=!1){let d=s.ONE;if(H.length){let te=H[0][0].length;for(let ne=0;ne<te;ne++){d=s.sqr(d);for(let[ae,j,a]of H)for(let[l,h,A]of ae[ne])d=F(l,h,A,d,j,a)}}return o&&(d=s.conjugate(d)),O?s.finalExponentiate(d):d}function z(H,O=!0){let d=[];m.ProjectivePoint.normalizeZ(H.map(({g1:te})=>te)),p.ProjectivePoint.normalizeZ(H.map(({g2:te})=>te));for(let{g1:te,g2:ne}of H){if(te.equals(m.ProjectivePoint.ZERO)||ne.equals(p.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");te.assertValidity(),ne.assertValidity();let ae=te.toAffine();d.push([P(ne),ae.x,ae.y])}return G(d,O)}function Z(H,O,d=!0){return z([{g1:H,g2:O}],d)}let E={randomPrivateKey:()=>{let H=Nn(t.ORDER);return Hi(r.randomBytes(H),t.ORDER)},calcPairingPrecomputes:P},{ShortSignature:L}=r.G1,{Signature:C}=r.G2;function V(H){return H instanceof m.ProjectivePoint?H:m.ProjectivePoint.fromHex(H)}function $(H,O){return H instanceof m.ProjectivePoint?H:m.hashToCurve(pt("point",H),O)}function ee(H){return H instanceof p.ProjectivePoint?H:C.fromHex(H)}function J(H,O){return H instanceof p.ProjectivePoint?H:p.hashToCurve(pt("point",H),O)}function oe(H){return m.ProjectivePoint.fromPrivateKey(H).toRawBytes(!0)}function g(H){return p.ProjectivePoint.fromPrivateKey(H).toRawBytes(!0)}function _(H,O,d){let te=J(H,d);te.assertValidity();let ne=te.multiply(m.normPrivateKeyToScalar(O));return H instanceof p.ProjectivePoint?ne:C.toRawBytes(ne)}function R(H,O,d){let te=$(H,d);te.assertValidity();let ne=te.multiply(m.normPrivateKeyToScalar(O));return H instanceof m.ProjectivePoint?ne:L.toRawBytes(ne)}function k(H,O,d,te){let ne=V(d),ae=J(O,te),j=m.ProjectivePoint.BASE,a=ee(H),l=z([{g1:ne.negate(),g2:ae},{g1:j,g2:a}]);return s.eql(l,s.ONE)}function K(H,O,d,te){let ne=ee(d),ae=$(O,te),j=p.ProjectivePoint.BASE,a=V(H),l=z([{g1:ae,g2:ne},{g1:a,g2:j.negate()}]);return s.eql(l,s.ONE)}function X(H){if(!H.length)throw new Error("Expected non-empty array");let d=H.map(V).reduce((te,ne)=>te.add(ne),m.ProjectivePoint.ZERO);return H[0]instanceof m.ProjectivePoint?(d.assertValidity(),d):d.toRawBytes(!0)}function se(H){if(!H.length)throw new Error("Expected non-empty array");let d=H.map(ee).reduce((te,ne)=>te.add(ne),p.ProjectivePoint.ZERO);return H[0]instanceof p.ProjectivePoint?(d.assertValidity(),d):C.toRawBytes(d)}function De(H){if(!H.length)throw new Error("Expected non-empty array");let d=H.map(V).reduce((te,ne)=>te.add(ne),m.ProjectivePoint.ZERO);return H[0]instanceof m.ProjectivePoint?(d.assertValidity(),d):L.toRawBytes(d)}function Ne(H,O,d,te){if(!O.length)throw new Error("Expected non-empty messages array");if(d.length!==O.length)throw new Error("Pubkey count should equal msg count");let ne=ee(H),ae=O.map(h=>J(h,te)),j=d.map(V),a=new Map;for(let h=0;h<j.length;h++){let A=j[h],y=ae[h],x=a.get(y);x===void 0&&(x=[],a.set(y,x)),x.push(A)}let l=[];try{for(let[h,A]of a){let y=A.reduce((x,U)=>x.add(U));l.push({g1:y,g2:h})}return l.push({g1:m.ProjectivePoint.BASE.negate(),g2:ne}),s.eql(z(l),s.ONE)}catch{return!1}}return m.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:oe,getPublicKeyForShortSignatures:g,sign:_,signShortSignature:R,verify:k,verifyBatch:Ne,verifyShortSignature:K,aggregatePublicKeys:X,aggregateSignatures:se,aggregateShortSignatures:De,millerLoopBatch:G,pairing:Z,pairingBatch:z,G1:m,G2:p,Signature:C,ShortSignature:L,fields:{Fr:t,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:r.params.ateLoopSize,r:r.params.r,G1b:r.G1.b,G2b:r.G2.b},utils:E}}var gf=BigInt(0),or=BigInt(1),St=BigInt(2),xa=BigInt(3);function es(r,e,t,n,i=1,s){let o=BigInt(s===void 0?n:s),f=t**BigInt(n),c=[];for(let m=0;m<i;m++){let S=BigInt(m+1),p=[];for(let F=0,v=or;F<n;F++){let u=(S*v-S)/o%f;p.push(r.pow(e,u)),v*=t}c.push(p)}return c}function Ea(r,e,t){let n=e.pow(t,(r.ORDER-or)/xa),i=e.pow(t,(r.ORDER-or)/St);function s(F,v){let u=e.mul(e.frobeniusMap(F,1),n),B=e.mul(e.frobeniusMap(v,1),i);return[u,B]}let o=e.pow(t,(r.ORDER**St-or)/xa),f=e.pow(t,(r.ORDER**St-or)/St);if(!e.eql(f,e.neg(e.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(F,v){return[e.mul(F,o),e.neg(v)]}let m=F=>(v,u)=>{let B=u.toAffine(),D=F(B.x,B.y);return v.fromAffine({x:D[0],y:D[1]})},S=m(s),p=m(c);return{psi:s,psi2:c,G2psi:S,G2psi2:p,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:f}}function _a(r){let{ORDER:e}=r,t=Tn(e),n=t.create(r.NONRESIDUE||BigInt(-1)),i=la(e),s=t.div(t.ONE,St),o=es(t,n,t.ORDER,2)[0],f=({c0:g,c1:_},{c0:R,c1:k})=>({c0:t.add(g,R),c1:t.add(_,k)}),c=({c0:g,c1:_},{c0:R,c1:k})=>({c0:t.sub(g,R),c1:t.sub(_,k)}),m=({c0:g,c1:_},R)=>{if(typeof R=="bigint")return{c0:t.mul(g,R),c1:t.mul(_,R)};let{c0:k,c1:K}=R,X=t.mul(g,k),se=t.mul(_,K),De=t.sub(X,se),Ne=t.sub(t.mul(t.add(g,_),t.add(k,K)),t.add(X,se));return{c0:De,c1:Ne}},S=({c0:g,c1:_})=>{let R=t.add(g,_),k=t.sub(g,_),K=t.add(g,g);return{c0:t.mul(R,k),c1:t.mul(K,_)}},p=g=>{if(g.length!==2)throw new Error("Invalid tuple");let _=g.map(R=>t.create(R));return{c0:_[0],c1:_[1]}},F=e*e,v=p(r.FP2_NONRESIDUE),u={ORDER:F,NONRESIDUE:v,BITS:Ht(F),BYTES:Math.ceil(Ht(F)/8),MASK:Lt(Ht(F)),ZERO:{c0:t.ZERO,c1:t.ZERO},ONE:{c0:t.ONE,c1:t.ZERO},create:g=>g,isValid:({c0:g,c1:_})=>typeof g=="bigint"&&typeof _=="bigint",is0:({c0:g,c1:_})=>t.is0(g)&&t.is0(_),eql:({c0:g,c1:_},{c0:R,c1:k})=>t.eql(g,R)&&t.eql(_,k),neg:({c0:g,c1:_})=>({c0:t.neg(g),c1:t.neg(_)}),pow:(g,_)=>Br(u,g,_),invertBatch:g=>Sr(u,g),add:f,sub:c,mul:m,sqr:S,addN:f,subN:c,mulN:m,sqrN:S,div:(g,_)=>u.mul(g,typeof _=="bigint"?t.inv(t.create(_)):u.inv(_)),inv:({c0:g,c1:_})=>{let R=t.inv(t.create(g*g+_*_));return{c0:t.mul(R,t.create(g)),c1:t.mul(R,t.create(-_))}},sqrt:g=>{if(r.Fp2sqrt)return r.Fp2sqrt(g);let{c0:_,c1:R}=g;if(t.is0(R))return t.eql(i(t,_),t.ONE)?u.create({c0:t.sqrt(_),c1:t.ZERO}):u.create({c0:t.ZERO,c1:t.sqrt(t.div(_,n))});let k=t.sqrt(t.sub(t.sqr(_),t.mul(t.sqr(R),n))),K=t.mul(t.add(k,_),s),X=i(t,K);!t.is0(X)&&!t.eql(X,t.ONE)&&(K=t.sub(K,k));let se=t.sqrt(K),De=u.create({c0:se,c1:t.div(t.mul(R,s),se)});if(!u.eql(u.sqr(De),g))throw new Error("Cannot find square root");let Ne=De,H=u.neg(Ne),{re:O,im:d}=u.reim(Ne),{re:te,im:ne}=u.reim(H);return d>ne||d===ne&&O>te?Ne:H},isOdd:g=>{let{re:_,im:R}=u.reim(g),k=_%St,K=_===gf,X=R%St;return BigInt(k||K&&X)==or},fromBytes(g){if(g.length!==u.BYTES)throw new Error(`fromBytes wrong length=${g.length}`);return{c0:t.fromBytes(g.subarray(0,t.BYTES)),c1:t.fromBytes(g.subarray(t.BYTES))}},toBytes:({c0:g,c1:_})=>ve(t.toBytes(g),t.toBytes(_)),cmov:({c0:g,c1:_},{c0:R,c1:k},K)=>({c0:t.cmov(g,R,K),c1:t.cmov(_,k,K)}),reim:({c0:g,c1:_})=>({re:g,im:_}),mulByNonresidue:({c0:g,c1:_})=>u.mul({c0:g,c1:_},v),mulByB:r.Fp2mulByB,fromBigTuple:p,frobeniusMap:({c0:g,c1:_},R)=>({c0:g,c1:t.mul(_,o[R%2])})},B=({c0:g,c1:_,c2:R},{c0:k,c1:K,c2:X})=>({c0:u.add(g,k),c1:u.add(_,K),c2:u.add(R,X)}),D=({c0:g,c1:_,c2:R},{c0:k,c1:K,c2:X})=>({c0:u.sub(g,k),c1:u.sub(_,K),c2:u.sub(R,X)}),P=({c0:g,c1:_,c2:R},k)=>{if(typeof k=="bigint")return{c0:u.mul(g,k),c1:u.mul(_,k),c2:u.mul(R,k)};let{c0:K,c1:X,c2:se}=k,De=u.mul(g,K),Ne=u.mul(_,X),H=u.mul(R,se);return{c0:u.add(De,u.mulByNonresidue(u.sub(u.mul(u.add(_,R),u.add(X,se)),u.add(Ne,H)))),c1:u.add(u.sub(u.mul(u.add(g,_),u.add(K,X)),u.add(De,Ne)),u.mulByNonresidue(H)),c2:u.sub(u.add(Ne,u.mul(u.add(g,R),u.add(K,se))),u.add(De,H))}},G=({c0:g,c1:_,c2:R})=>{let k=u.sqr(g),K=u.mul(u.mul(g,_),St),X=u.mul(u.mul(_,R),St),se=u.sqr(R);return{c0:u.add(u.mulByNonresidue(X),k),c1:u.add(u.mulByNonresidue(se),K),c2:u.sub(u.sub(u.add(u.add(K,u.sqr(u.add(u.sub(g,_),R))),X),k),se)}},[z,Z]=es(u,v,t.ORDER,6,2,3),E={ORDER:u.ORDER,BITS:3*u.BITS,BYTES:3*u.BYTES,MASK:Lt(3*u.BITS),ZERO:{c0:u.ZERO,c1:u.ZERO,c2:u.ZERO},ONE:{c0:u.ONE,c1:u.ZERO,c2:u.ZERO},create:g=>g,isValid:({c0:g,c1:_,c2:R})=>u.isValid(g)&&u.isValid(_)&&u.isValid(R),is0:({c0:g,c1:_,c2:R})=>u.is0(g)&&u.is0(_)&&u.is0(R),neg:({c0:g,c1:_,c2:R})=>({c0:u.neg(g),c1:u.neg(_),c2:u.neg(R)}),eql:({c0:g,c1:_,c2:R},{c0:k,c1:K,c2:X})=>u.eql(g,k)&&u.eql(_,K)&&u.eql(R,X),sqrt:Bn,div:(g,_)=>E.mul(g,typeof _=="bigint"?t.inv(t.create(_)):E.inv(_)),pow:(g,_)=>Br(E,g,_),invertBatch:g=>Sr(E,g),add:B,sub:D,mul:P,sqr:G,addN:B,subN:D,mulN:P,sqrN:G,inv:({c0:g,c1:_,c2:R})=>{let k=u.sub(u.sqr(g),u.mulByNonresidue(u.mul(R,_))),K=u.sub(u.mulByNonresidue(u.sqr(R)),u.mul(g,_)),X=u.sub(u.sqr(_),u.mul(g,R)),se=u.inv(u.add(u.mulByNonresidue(u.add(u.mul(R,K),u.mul(_,X))),u.mul(g,k)));return{c0:u.mul(se,k),c1:u.mul(se,K),c2:u.mul(se,X)}},fromBytes:g=>{if(g.length!==E.BYTES)throw new Error(`fromBytes wrong length=${g.length}`);return{c0:u.fromBytes(g.subarray(0,u.BYTES)),c1:u.fromBytes(g.subarray(u.BYTES,2*u.BYTES)),c2:u.fromBytes(g.subarray(2*u.BYTES))}},toBytes:({c0:g,c1:_,c2:R})=>ve(u.toBytes(g),u.toBytes(_),u.toBytes(R)),cmov:({c0:g,c1:_,c2:R},{c0:k,c1:K,c2:X},se)=>({c0:u.cmov(g,k,se),c1:u.cmov(_,K,se),c2:u.cmov(R,X,se)}),fromBigSix:g=>{if(!Array.isArray(g)||g.length!==6)throw new Error("Invalid Fp6 usage");return{c0:u.fromBigTuple(g.slice(0,2)),c1:u.fromBigTuple(g.slice(2,4)),c2:u.fromBigTuple(g.slice(4,6))}},frobeniusMap:({c0:g,c1:_,c2:R},k)=>({c0:u.frobeniusMap(g,k),c1:u.mul(u.frobeniusMap(_,k),z[k%6]),c2:u.mul(u.frobeniusMap(R,k),Z[k%6])}),mulByFp2:({c0:g,c1:_,c2:R},k)=>({c0:u.mul(g,k),c1:u.mul(_,k),c2:u.mul(R,k)}),mulByNonresidue:({c0:g,c1:_,c2:R})=>({c0:u.mulByNonresidue(R),c1:g,c2:_}),mul1:({c0:g,c1:_,c2:R},k)=>({c0:u.mulByNonresidue(u.mul(R,k)),c1:u.mul(g,k),c2:u.mul(_,k)}),mul01({c0:g,c1:_,c2:R},k,K){let X=u.mul(g,k),se=u.mul(_,K);return{c0:u.add(u.mulByNonresidue(u.sub(u.mul(u.add(_,R),K),se)),X),c1:u.sub(u.sub(u.mul(u.add(k,K),u.add(g,_)),X),se),c2:u.add(u.sub(u.mul(u.add(g,R),k),X),se)}}},L=es(u,v,t.ORDER,12,1,6)[0],C=({c0:g,c1:_},{c0:R,c1:k})=>({c0:E.add(g,R),c1:E.add(_,k)}),V=({c0:g,c1:_},{c0:R,c1:k})=>({c0:E.sub(g,R),c1:E.sub(_,k)}),$=({c0:g,c1:_},R)=>{if(typeof R=="bigint")return{c0:E.mul(g,R),c1:E.mul(_,R)};let{c0:k,c1:K}=R,X=E.mul(g,k),se=E.mul(_,K);return{c0:E.add(X,E.mulByNonresidue(se)),c1:E.sub(E.mul(E.add(g,_),E.add(k,K)),E.add(X,se))}},ee=({c0:g,c1:_})=>{let R=E.mul(g,_);return{c0:E.sub(E.sub(E.mul(E.add(E.mulByNonresidue(_),g),E.add(g,_)),R),E.mulByNonresidue(R)),c1:E.add(R,R)}};function J(g,_){let R=u.sqr(g),k=u.sqr(_);return{first:u.add(u.mulByNonresidue(k),R),second:u.sub(u.sub(u.sqr(u.add(g,_)),R),k)}}let oe={ORDER:u.ORDER,BITS:2*u.BITS,BYTES:2*u.BYTES,MASK:Lt(2*u.BITS),ZERO:{c0:E.ZERO,c1:E.ZERO},ONE:{c0:E.ONE,c1:E.ZERO},create:g=>g,isValid:({c0:g,c1:_})=>E.isValid(g)&&E.isValid(_),is0:({c0:g,c1:_})=>E.is0(g)&&E.is0(_),neg:({c0:g,c1:_})=>({c0:E.neg(g),c1:E.neg(_)}),eql:({c0:g,c1:_},{c0:R,c1:k})=>E.eql(g,R)&&E.eql(_,k),sqrt:Bn,inv:({c0:g,c1:_})=>{let R=E.inv(E.sub(E.sqr(g),E.mulByNonresidue(E.sqr(_))));return{c0:E.mul(g,R),c1:E.neg(E.mul(_,R))}},div:(g,_)=>oe.mul(g,typeof _=="bigint"?t.inv(t.create(_)):oe.inv(_)),pow:(g,_)=>Br(oe,g,_),invertBatch:g=>Sr(oe,g),add:C,sub:V,mul:$,sqr:ee,addN:C,subN:V,mulN:$,sqrN:ee,fromBytes:g=>{if(g.length!==oe.BYTES)throw new Error(`fromBytes wrong length=${g.length}`);return{c0:E.fromBytes(g.subarray(0,E.BYTES)),c1:E.fromBytes(g.subarray(E.BYTES))}},toBytes:({c0:g,c1:_})=>ve(E.toBytes(g),E.toBytes(_)),cmov:({c0:g,c1:_},{c0:R,c1:k},K)=>({c0:E.cmov(g,R,K),c1:E.cmov(_,k,K)}),fromBigTwelve:g=>({c0:E.fromBigSix(g.slice(0,6)),c1:E.fromBigSix(g.slice(6,12))}),frobeniusMap(g,_){let{c0:R,c1:k,c2:K}=E.frobeniusMap(g.c1,_),X=L[_%12];return{c0:E.frobeniusMap(g.c0,_),c1:E.create({c0:u.mul(R,X),c1:u.mul(k,X),c2:u.mul(K,X)})}},mulByFp2:({c0:g,c1:_},R)=>({c0:E.mulByFp2(g,R),c1:E.mulByFp2(_,R)}),conjugate:({c0:g,c1:_})=>({c0:g,c1:E.neg(_)}),mul014:({c0:g,c1:_},R,k,K)=>{let X=E.mul01(g,R,k),se=E.mul1(_,K);return{c0:E.add(E.mulByNonresidue(se),X),c1:E.sub(E.sub(E.mul01(E.add(_,g),R,u.add(k,K)),X),se)}},mul034:({c0:g,c1:_},R,k,K)=>{let X=E.create({c0:u.mul(g.c0,R),c1:u.mul(g.c1,R),c2:u.mul(g.c2,R)}),se=E.mul01(_,k,K),De=E.mul01(E.add(g,_),u.add(R,k),K);return{c0:E.add(E.mulByNonresidue(se),X),c1:E.sub(De,E.add(X,se))}},_cyclotomicSquare:r.Fp12cyclotomicSquare,_cyclotomicExp:r.Fp12cyclotomicExp,finalExponentiate:r.Fp12finalExponentiate};return{Fp:t,Fp2:u,Fp6:E,Fp4Square:J,Fp12:oe}}var Ze=BigInt(0),Pn=BigInt(1),Ve=BigInt(2),On=BigInt(3),Tr=BigInt(4),qt=BigInt("0xd201000000010000"),bf=Ht(qt),{Fp:W,Fp2:Q,Fp6:ns,Fp4Square:ts,Fp12:ue}=_a({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[Pn,Pn],Fp2mulByB:({c0:r,c1:e})=>{let t=W.mul(r,Tr),n=W.mul(e,Tr);return{c0:W.sub(t,n),c1:W.add(t,n)}},Fp12cyclotomicSquare:({c0:r,c1:e})=>{let{c0:t,c1:n,c2:i}=r,{c0:s,c1:o,c2:f}=e,{first:c,second:m}=ts(t,o),{first:S,second:p}=ts(s,i),{first:F,second:v}=ts(n,f),u=Q.mulByNonresidue(v);return{c0:ns.create({c0:Q.add(Q.mul(Q.sub(c,t),Ve),c),c1:Q.add(Q.mul(Q.sub(S,n),Ve),S),c2:Q.add(Q.mul(Q.sub(F,i),Ve),F)}),c1:ns.create({c0:Q.add(Q.mul(Q.add(u,s),Ve),u),c1:Q.add(Q.mul(Q.add(m,o),Ve),m),c2:Q.add(Q.mul(Q.add(p,f),Ve),p)})}},Fp12cyclotomicExp(r,e){let t=ue.ONE;for(let n=bf-1;n>=0;n--)t=ue._cyclotomicSquare(t),$i(e,n)&&(t=ue.mul(t,r));return t},Fp12finalExponentiate:r=>{let e=qt,t=ue.div(ue.frobeniusMap(r,6),r),n=ue.mul(ue.frobeniusMap(t,2),t),i=ue.conjugate(ue._cyclotomicExp(n,e)),s=ue.mul(ue.conjugate(ue._cyclotomicSquare(n)),i),o=ue.conjugate(ue._cyclotomicExp(s,e)),f=ue.conjugate(ue._cyclotomicExp(o,e)),c=ue.mul(ue.conjugate(ue._cyclotomicExp(f,e)),ue._cyclotomicSquare(i)),m=ue.conjugate(ue._cyclotomicExp(c,e)),S=ue.frobeniusMap(ue.mul(i,f),2),p=ue.frobeniusMap(ue.mul(o,n),3),F=ue.frobeniusMap(ue.mul(c,ue.conjugate(n)),1),v=ue.mul(ue.mul(m,ue.conjugate(s)),n);return ue.mul(ue.mul(ue.mul(S,p),F),v)}}),va=Tn(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),wf=Zi(Q,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(r=>r.map(e=>Q.fromBigTuple(e.map(BigInt))))),yf=Zi(W,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(r=>r.map(e=>BigInt(e)))),xf=Qi(Q,{A:Q.create({c0:W.create(Ze),c1:W.create(BigInt(240))}),B:Q.create({c0:W.create(BigInt(1012)),c1:W.create(BigInt(1012))}),Z:Q.create({c0:W.create(BigInt(-2)),c1:W.create(BigInt(-1))})}),Ef=Qi(W,{A:W.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:W.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:W.create(BigInt(11))}),{G2psi:Ia,G2psi2:_f}=Ea(W,Q,Q.div(Q.ONE,Q.NONRESIDUE)),rs=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:W.ORDER,m:2,k:128,expand:"xmd",hash:lr}),Ln=Nr(W.toBytes(Ze),{infinity:!0,compressed:!0});function Fn(r){r=r.slice();let e=r[0]&224,t=!!(e>>7&1),n=!!(e>>6&1),i=!!(e>>5&1);return r[0]&=31,{compressed:t,infinity:n,sort:i,value:r}}function Nr(r,e){if(r[0]&224)throw new Error("setMask: non-empty mask");return e.compressed&&(r[0]|=128),e.infinity&&(r[0]|=64),e.sort&&(r[0]|=32),r}function Aa(r){r.assertValidity();let e=r.equals(Qe.G1.ProjectivePoint.ZERO),{x:t,y:n}=r.toAffine();if(e)return Ln.slice();let i=W.ORDER,s=!!(n*Ve/i);return Nr(Se(t,W.BYTES),{compressed:!0,sort:s})}function Ba(r){r.assertValidity();let e=W.BYTES;if(r.equals(Qe.G2.ProjectivePoint.ZERO))return ve(Ln,Se(Ze,e));let{x:t,y:n}=r.toAffine(),{re:i,im:s}=Q.reim(t),{re:o,im:f}=Q.reim(n),m=!!((f>Ze?f*Ve:o*Ve)/W.ORDER&Pn),S=i;return ve(Nr(Se(s,e),{sort:m,compressed:!0}),Se(S,e))}var Qe=ya({fields:{Fp:W,Fp2:Q,Fp6:ns,Fp12:ue,Fr:va},G1:{Fp:W,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:W.ZERO,b:Tr,htfDefaults:{...rs,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(r,e)=>{let t=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new r(W.mul(e.px,t),e.py,e.pz);return e.multiplyUnsafe(qt).negate().multiplyUnsafe(qt).equals(n)},clearCofactor:(r,e)=>e.multiplyUnsafe(qt).add(e),mapToCurve:r=>{let{x:e,y:t}=Ef(W.create(r[0]));return yf(e,t)},fromBytes:r=>{let{compressed:e,infinity:t,sort:n,value:i}=Fn(r);if(i.length===48&&e){let s=W.ORDER,o=He(i),f=W.create(o&W.MASK);if(t){if(f!==Ze)throw new Error("G1: non-empty compressed point at infinity");return{x:Ze,y:Ze}}let c=W.add(W.pow(f,On),W.create(Qe.params.G1b)),m=W.sqrt(c);if(!m)throw new Error("Invalid compressed G1 point");return m*Ve/s!==BigInt(n)&&(m=W.neg(m)),{x:W.create(f),y:W.create(m)}}else if(i.length===96&&!e){let s=He(i.subarray(0,W.BYTES)),o=He(i.subarray(W.BYTES));if(t){if(s!==Ze||o!==Ze)throw new Error("G1: non-empty point at infinity");return Qe.G1.ProjectivePoint.ZERO.toAffine()}return{x:W.create(s),y:W.create(o)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(r,e,t)=>{let n=e.equals(r.ZERO),{x:i,y:s}=e.toAffine();if(t){if(n)return Ln.slice();let o=W.ORDER,f=!!(s*Ve/o);return Nr(Se(i,W.BYTES),{compressed:!0,sort:f})}else return n?ve(new Uint8Array([64]),new Uint8Array(2*W.BYTES-1)):ve(Se(i,W.BYTES),Se(s,W.BYTES))},ShortSignature:{fromHex(r){let{infinity:e,sort:t,value:n}=Fn(pt("signatureHex",r,48)),i=W.ORDER,s=He(n);if(e)return Qe.G1.ProjectivePoint.ZERO;let o=W.create(s&W.MASK),f=W.add(W.pow(o,On),W.create(Qe.params.G1b)),c=W.sqrt(f);if(!c)throw new Error("Invalid compressed G1 point");let m=BigInt(t);c*Ve/i!==m&&(c=W.neg(c));let S=Qe.G1.ProjectivePoint.fromAffine({x:o,y:c});return S.assertValidity(),S},toRawBytes(r){return Aa(r)},toHex(r){return At(Aa(r))}}},G2:{Fp:Q,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:Q.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:Q.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:Q.ZERO,b:Q.fromBigTuple([Tr,Tr]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...rs},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:r=>{let{x:e,y:t}=xf(Q.fromBigTuple(r));return wf(e,t)},isTorsionFree:(r,e)=>e.multiplyUnsafe(qt).negate().equals(Ia(r,e)),clearCofactor:(r,e)=>{let t=qt,n=e.multiplyUnsafe(t).negate(),i=Ia(r,e),s=e.double();return s=_f(r,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(t).negate(),s=s.add(i),s=s.subtract(n),s.subtract(e)},fromBytes:r=>{let{compressed:e,infinity:t,sort:n,value:i}=Fn(r);if(!e&&!t&&n||!e&&t&&n||n&&t&&e)throw new Error("Invalid encoding flag: "+(r[0]&224));let s=W.BYTES,o=(f,c,m)=>He(f.slice(c,m));if(i.length===96&&e){let f=Qe.params.G2b,c=W.ORDER;if(t){if(i.reduce((B,D)=>B!==0?D+1:D,0)>0)throw new Error("Invalid compressed G2 point");return{x:Q.ZERO,y:Q.ZERO}}let m=o(i,0,s),S=o(i,s,2*s),p=Q.create({c0:W.create(S),c1:W.create(m)}),F=Q.add(Q.pow(p,On),f),v=Q.sqrt(F),u=v.c1===Ze?v.c0*Ve/c:v.c1*Ve/c?Pn:Ze;return v=n&&u>0?v:Q.neg(v),{x:p,y:v}}else if(i.length===192&&!e){if(t){if(i.reduce((p,F)=>p!==0?F+1:F,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:Q.ZERO,y:Q.ZERO}}let f=o(i,0,s),c=o(i,s,2*s),m=o(i,2*s,3*s),S=o(i,3*s,4*s);return{x:Q.fromBigTuple([c,f]),y:Q.fromBigTuple([S,m])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(r,e,t)=>{let{BYTES:n,ORDER:i}=W,s=e.equals(r.ZERO),{x:o,y:f}=e.toAffine();if(t){if(s)return ve(Ln,Se(Ze,n));let c=!!(f.c1===Ze?f.c0*Ve/i:f.c1*Ve/i);return ve(Nr(Se(o.c1,n),{compressed:!0,sort:c}),Se(o.c0,n))}else{if(s)return ve(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:m}=Q.reim(o),{re:S,im:p}=Q.reim(f);return ve(Se(m,n),Se(c,n),Se(p,n),Se(S,n))}},Signature:{fromHex(r){let{infinity:e,sort:t,value:n}=Fn(pt("signatureHex",r)),i=W.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=He(n.slice(0,s)),f=He(n.slice(s));if(e)return Qe.G2.ProjectivePoint.ZERO;let c=W.create(o&W.MASK),m=W.create(f),S=Q.create({c0:m,c1:c}),p=Q.add(Q.pow(S,On),Qe.params.G2b),F=Q.sqrt(p);if(!F)throw new Error("Failed to find a square root");let{re:v,im:u}=Q.reim(F),B=BigInt(t),D=u>Ze&&u*Ve/i!==B,P=u===Ze&&v*Ve/i!==B;(D||P)&&(F=Q.neg(F));let G=Qe.G2.ProjectivePoint.fromAffine({x:S,y:F});return G.assertValidity(),G},toRawBytes(r){return Ba(r)},toHex(r){return At(Ba(r))}}},params:{ateLoopSize:qt,r:va.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:rs,hash:lr,randomBytes:ls});function Sa(r,e,t){let n=typeof r=="string"?r:ft(r),i=typeof e=="string"?e:ft(e),s=typeof t=="string"?t:ft(t);return Qe.verifyShortSignature(i,s,n)}var is=r=>Re(new lt(r)),Mn=r=>{let e=is(r);return new Date(Number(e)/1e6)};var $t=class extends Wt{constructor(e){super(`Invalid certificate: ${e}`)}},et;(function(r){r[r.Empty=0]="Empty",r[r.Fork=1]="Fork",r[r.Labeled=2]="Labeled",r[r.Leaf=3]="Leaf",r[r.Pruned=4]="Pruned"})(et||(et={}));function If(r,e){let t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<t.length;i++)if(t[i]>n[i])return!0;return!1}var qn=class r{constructor(e,t,n,i,s=5){this._rootKey=t,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=Qt(new Uint8Array(e))}static async create(e){let t=r.createUnverified(e);return await t.verify(),t}static createUnverified(e){let t=e.blsVerify;return t||(t=Sa),new r(e.certificate,e.rootKey,e.canisterId,t,e.maxAgeInMinutes)}lookup(e){return ar(e,this.cert.tree)}lookup_label(e){return this.lookup([e])}async verify(){let e=await Dn(this.cert.tree),t=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=Bf(t),s=it(Rr("ic-state-root"),e),o=!1,f=$n(this.lookup(["time"]));if(!f)throw new $t("Certificate does not contain a time");let c=5*60*1e3,m=this._maxAgeInMinutes*60*1e3,S=Date.now(),p=S-m,F=S+c,v=Mn(f);if(v.getTime()<p)throw new $t(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+v.toISOString()+" Current time: "+new Date(S).toISOString());if(v.getTime()>F)throw new $t("Certificate is signed more than 5 minutes in the future. Certificate time: "+v.toISOString()+" Current time: "+new Date(S).toISOString());try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new $t("Signature verification failed")}async _checkDelegationAndGetKey(e){if(!e)return this._rootKey;let t=await r.createUnverified({certificate:e.certificate,rootKey:this._rootKey,canisterId:this._canisterId,blsVerify:this._blsVerify,maxAgeInMinutes:1/0});if(t.cert.delegation)throw new $t("Delegation certificates cannot be nested");if(await t.verify(),!ss({canisterId:this._canisterId,subnetId:Ge.fromUint8Array(new Uint8Array(e.subnet_id)),tree:t.cert.tree}))throw new $t(`Canister ${this._canisterId} not in range of delegations for subnet 0x${ft(e.subnet_id)}`);let i=$n(t.lookup(["subnet",e.subnet_id,"public_key"]));if(!i)throw new Error(`Could not find subnet key for subnet 0x${ft(e.subnet_id)}`);return i}},Ur=wr("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Af=96;function Bf(r){let e=Ur.byteLength+Af;if(r.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let t=r.slice(0,Ur.byteLength);if(!vi(t,Ur))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${Ur}, but get ${t}`);return r.slice(Ur.byteLength)}function $n(r){if(r.status===Me.Found){if(r.value instanceof ArrayBuffer)return r.value;if(r.value instanceof Uint8Array)return r.value.buffer}}async function Dn(r){switch(r[0]){case et.Empty:return st(Rr("ic-hashtree-empty"));case et.Pruned:return r[1];case et.Leaf:return st(it(Rr("ic-hashtree-leaf"),r[1]));case et.Labeled:return st(it(Rr("ic-hashtree-labeled"),r[1],await Dn(r[2])));case et.Fork:return st(it(Rr("ic-hashtree-fork"),await Dn(r[1]),await Dn(r[2])));default:throw new Error("unreachable")}}function Rr(r){let e=new Uint8Array([r.length]),t=new TextEncoder().encode(r);return it(e,t)}var Me;(function(r){r.Unknown="unknown",r.Absent="absent",r.Found="found"})(Me||(Me={}));var Tt;(function(r){r.Less="less",r.Greater="greater"})(Tt||(Tt={}));function ar(r,e){if(r.length===0)switch(e[0]){case et.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?{status:Me.Found,value:e[1]}:e[1]instanceof Uint8Array?{status:Me.Found,value:e[1].buffer}:{status:Me.Found,value:e[1]}}default:return{status:Me.Found,value:e}}let t=typeof r[0]=="string"?new TextEncoder().encode(r[0]):r[0],n=kn(t,e);switch(n.status){case Me.Found:return ar(r.slice(1),n.value);case Tt.Greater:case Tt.Less:return{status:Me.Absent};default:return n}}function Gn(r){switch(r[0]){case et.Empty:return[];case et.Fork:return Gn(r[1]).concat(Gn(r[2]));default:return[r]}}function kn(r,e){switch(e[0]){case et.Labeled:return If(r,e[1])?{status:Tt.Greater}:vi(r,e[1])?{status:Me.Found,value:e[2]}:{status:Tt.Less};case et.Fork:let t=kn(r,e[1]);switch(t.status){case Tt.Greater:{let n=kn(r,e[2]);return n.status===Tt.Less?{status:Me.Absent}:n}case Me.Unknown:{let n=kn(r,e[2]);return n.status===Tt.Less?{status:Me.Unknown}:n}default:return t}case et.Pruned:return{status:Me.Unknown};default:return{status:Me.Absent}}}function ss(r){let{canisterId:e,subnetId:t,tree:n}=r,i=ar(["subnet",t.toUint8Array(),"canister_ranges"],n);if(i.status!==Me.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${t}`);return Qt(i.value).map(c=>[Ge.fromUint8Array(c[0]),Ge.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}var Ta=class{constructor(e,t,n){this.key=e,this.path=t,this.decodeStrategy=n}},jl=async r=>{let{agent:e,paths:t}=r,n=Ge.from(r.canisterId),i=[...new Set(t)],s=i.map(c=>Na(c,n)),o=new Map,f=i.map((c,m)=>(async()=>{var S;try{let p=await e.readState(n,{paths:[s[m]]}),F=await qn.create({certificate:p.certificate,rootKey:e.rootKey,canisterId:n}),v=(D,P)=>{if(P==="subnet"){let G=Sf(p.certificate,n,e.rootKey);return{path:P,data:G}}else return{path:P,data:$n(D.lookup(Na(P,n)))}},{path:u,data:B}=v(F,i[m]);if(!B)console.warn(`Expected to find result for path ${u}, but instead found nothing.`),typeof u=="string"?o.set(u,null):o.set(u.key,null);else switch(u){case"time":{o.set(u,Mn(B));break}case"controllers":{o.set(u,Nf(B));break}case"module_hash":{o.set(u,Ua(B));break}case"subnet":{o.set(u,B);break}case"candid":{o.set(u,new TextDecoder().decode(B));break}default:if(typeof u!="string"&&"key"in u&&"path"in u)switch(u.decodeStrategy){case"raw":o.set(u.key,B);break;case"leb128":{o.set(u.key,is(B));break}case"cbor":{o.set(u.key,Ra(B));break}case"hex":{o.set(u.key,Ua(B));break}case"utf-8":o.set(u.key,Tf(B))}}}catch(p){if(!((S=p?.message)===null||S===void 0)&&S.includes("Invalid certificate"))throw new Wt(p.message);typeof c!="string"&&"key"in c&&"path"in c?o.set(c.key,null):o.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(p),console.groupEnd()}})());return await Promise.all(f),o},Sf=(r,e,t)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=Qt(new Uint8Array(r)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=Ge.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof t<"u"?(o=Ge.selfAuthenticating(new Uint8Array(t)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=Ge.selfAuthenticating(Ge.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!ss({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=ar(["subnet",s.subnet_id,"node"],i);if(c.status!==Me.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let m=Gn(c.value),S=new Map;return m.forEach(p=>{let F=Ge.from(new Uint8Array(p[1])).toText(),v=ar(["public_key"],p[2]);if(v.status!==Me.Found)throw new Error("Public key not found");let u=v.value;if(u.byteLength!==44)throw new Error("Invalid public key length");S.set(F,u)}),{subnetId:Ge.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:S}},Na=(r,e)=>{let t=new TextEncoder,n=s=>new DataView(t.encode(s).buffer).buffer,i=new DataView(e.toUint8Array().buffer).buffer;switch(r){case"time":return[n("time")];case"controllers":return[n("canister"),i,n("controllers")];case"module_hash":return[n("canister"),i,n("module_hash")];case"subnet":return[n("subnet")];case"candid":return[n("canister"),i,n("metadata"),n("candid:service")];default:if("key"in r&&"path"in r)if(typeof r.path=="string"||r.path instanceof ArrayBuffer){let s=r.path,o=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),o]}else return r.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${r} was formatted correctly.`)},Ua=r=>ft(r),Ra=r=>Qt(r),Tf=r=>new TextDecoder().decode(r),Nf=r=>Ra(r).map(t=>Ge.fromUint8Array(new Uint8Array(t)));export{$e as a,Cn as b,Pr as c,zn as d,ls as e,qr as f,Ge as g,ks as h,Wt as i,Ie as j,Li as k,gi as l,it as m,ft as n,wr as o,vi as p,br as q,Gu as r,tl as s,ia as t,Ei as u,B0 as v,Qt as w,_n as x,At as y,vn as z,In as A,pt as B,ve as C,Ar as D,Bt as E,ir as F,je as G,il as H,sl as I,Tn as J,ma as K,ga as L,Mn as M,$t as N,qn as O,$n as P,Me as Q,ar as R,Ta as S,jl as T,Sf as U,Na as V};
14
- /*!
15
- * The buffer module from node.js, for the browser.
16
- *
17
- * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
18
- * @license MIT
19
- */
20
- /*! Bundled license information:
21
-
22
- ieee754/index.js:
23
- (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
24
-
25
- @noble/hashes/esm/utils.js:
26
- (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
27
-
28
- @noble/curves/esm/abstract/utils.js:
29
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
30
-
31
- @noble/curves/esm/abstract/modular.js:
32
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
33
-
34
- @noble/curves/esm/abstract/curve.js:
35
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
36
-
37
- @noble/curves/esm/abstract/weierstrass.js:
38
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
39
-
40
- @noble/curves/esm/abstract/bls.js:
41
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
42
-
43
- @noble/curves/esm/bls12-381.js:
44
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
45
- */
46
- //# sourceMappingURL=chunk-3YVZN56F.js.map