@junobuild/analytics 0.0.31 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ import{c as a,d as b,e as c,f as d}from"./chunk-LVWHOONS.js";import"./chunk-TEDR2MDT.js";export{a as CustomPath,d as encodePath,c as fetchNodeKeys,b as request};
2
+ //# sourceMappingURL=canisterStatus-RRYZEM7X.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,48 @@
1
+ import{a as Ya,b as Me,c as hs,d as lr,e as za}from"./chunk-TEDR2MDT.js";var Hs={};hs(Hs,{Buffer:()=>q,INSPECT_MAX_BYTES:()=>Os,SlowBuffer:()=>pc,isBuffer:()=>Gs,kMaxLength:()=>uc});function Bs(){jn=!0;for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,t=r.length;e<t;++e)ht[e]=r[e],nt[r.charCodeAt(e)]=e;nt[45]=62,nt[95]=63}function sc(r){jn||Bs();var e,t,n,i,s,o,u=r.length;if(u%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s=r[u-2]==="="?2:r[u-1]==="="?1:0,o=new ic(u*3/4-s),n=s>0?u-4:u;var c=0;for(e=0,t=0;e<n;e+=4,t+=3)i=nt[r.charCodeAt(e)]<<18|nt[r.charCodeAt(e+1)]<<12|nt[r.charCodeAt(e+2)]<<6|nt[r.charCodeAt(e+3)],o[c++]=i>>16&255,o[c++]=i>>8&255,o[c++]=i&255;return s===2?(i=nt[r.charCodeAt(e)]<<2|nt[r.charCodeAt(e+1)]>>4,o[c++]=i&255):s===1&&(i=nt[r.charCodeAt(e)]<<10|nt[r.charCodeAt(e+1)]<<4|nt[r.charCodeAt(e+2)]>>2,o[c++]=i>>8&255,o[c++]=i&255),o}function oc(r){return ht[r>>18&63]+ht[r>>12&63]+ht[r>>6&63]+ht[r&63]}function ac(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(oc(n));return i.join("")}function As(r){jn||Bs();for(var e,t=r.length,n=t%3,i="",s=[],o=16383,u=0,c=t-n;u<c;u+=o)s.push(ac(r,u,u+o>c?c:u+o));return n===1?(e=r[t-1],i+=ht[e>>2],i+=ht[e<<4&63],i+="=="):n===2&&(e=(r[t-2]<<8)+r[t-1],i+=ht[e>>10],i+=ht[e>>4&63],i+=ht[e<<2&63],i+="="),s.push(i),s.join("")}function jr(r,e,t,n,i){var s,o,u=i*8-n-1,c=(1<<u)-1,g=c>>1,v=-7,y=t?i-1:0,S=t?-1:1,U=r[e+y];for(y+=S,s=U&(1<<-v)-1,U>>=-v,v+=u;v>0;s=s*256+r[e+y],y+=S,v-=8);for(o=s&(1<<-v)-1,s>>=-v,v+=n;v>0;o=o*256+r[e+y],y+=S,v-=8);if(s===0)s=1-g;else{if(s===c)return o?NaN:(U?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-g}return(U?-1:1)*o*Math.pow(2,s-n)}function Ns(r,e,t,n,i,s){var o,u,c,g=s*8-i-1,v=(1<<g)-1,y=v>>1,S=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,U=n?0:s-1,f=n?1:-1,D=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,o=v):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+y>=1?e+=S/c:e+=S*Math.pow(2,1-y),e*c>=2&&(o++,c/=2),o+y>=v?(u=0,o=v):o+y>=1?(u=(e*c-1)*Math.pow(2,i),o=o+y):(u=e*Math.pow(2,y-1)*Math.pow(2,i),o=0));i>=8;r[t+U]=u&255,U+=f,u/=256,i-=8);for(o=o<<i|u,g+=i;g>0;r[t+U]=o&255,U+=f,o/=256,g-=8);r[t+U-f]|=D*128}function Vr(){return q.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function wt(r,e){if(Vr()<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 Yn(this,r)}return Us(this,r,e,t)}function Us(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?hc(r,e,t,n):typeof e=="string"?lc(r,e,t):dc(r,e)}function Ps(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 fc(r,e,t,n){return Ps(e),e<=0?wt(r,e):t!==void 0?typeof n=="string"?wt(r,e).fill(t,n):wt(r,e).fill(t):wt(r,e)}function Yn(r,e){if(Ps(e),r=wt(r,e<0?0:zn(e)|0),!q.TYPED_ARRAY_SUPPORT)for(var t=0;t<e;++t)r[t]=0;return r}function lc(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=Fs(e,t)|0;r=wt(r,n);var i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function Hn(r,e){var t=e.length<0?0:zn(e.length)|0;r=wt(r,t);for(var n=0;n<t;n+=1)r[n]=e[n]&255;return r}function hc(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=Hn(r,e),r}function dc(r,e){if(dt(e)){var t=zn(e.length)|0;return r=wt(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"||Pc(e.length)?wt(r,0):Hn(r,e);if(e.type==="Buffer"&&Rs(e.data))return Hn(r,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function zn(r){if(r>=Vr())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Vr().toString(16)+" bytes");return r|0}function pc(r){return+r!=r&&(r=0),q.alloc(+r)}function dt(r){return!!(r!=null&&r._isBuffer)}function Fs(r,e){if(dt(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 Hr(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Cs(r).length;default:if(n)return Hr(r).length;e=(""+e).toLowerCase(),n=!0}}function mc(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 Ac(this,e,t);case"utf8":case"utf-8":return ks(this,e,t);case"ascii":return vc(this,e,t);case"latin1":case"binary":return Ic(this,e,t);case"base64":return _c(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Sc(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}function Dt(r,e,t){var n=r[e];r[e]=r[t],r[t]=n}function Ms(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)),dt(e))return e.length===0?-1:Ss(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):Ss(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}function Ss(r,e,t,n,i){var s=1,o=r.length,u=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,u/=2,t/=2}function c(U,f){return s===1?U[f]:U.readUInt16BE(f*s)}var g;if(i){var v=-1;for(g=t;g<o;g++)if(c(r,g)===c(e,v===-1?0:g-v)){if(v===-1&&(v=g),g-v+1===u)return v*s}else v!==-1&&(g-=g-v),v=-1}else for(t+u>o&&(t=o-u),g=t;g>=0;g--){for(var y=!0,S=0;S<u;S++)if(c(r,g+S)!==c(e,S)){y=!1;break}if(y)return g}return-1}function gc(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 u=parseInt(e.substr(o*2,2),16);if(isNaN(u))return o;r[t+o]=u}return o}function wc(r,e,t,n){return Kr(Hr(e,r.length-t),r,t,n)}function Ls(r,e,t,n){return Kr(Oc(e),r,t,n)}function yc(r,e,t,n){return Ls(r,e,t,n)}function bc(r,e,t,n){return Kr(Cs(e),r,t,n)}function xc(r,e,t,n){return Kr(Uc(e,r.length-t),r,t,n)}function _c(r,e,t){return e===0&&t===r.length?As(r):As(r.slice(e,t))}function ks(r,e,t){t=Math.min(r.length,t);for(var n=[],i=e;i<t;){var s=r[i],o=null,u=s>239?4:s>223?3:s>191?2:1;if(i+u<=t){var c,g,v,y;switch(u){case 1:s<128&&(o=s);break;case 2:c=r[i+1],(c&192)===128&&(y=(s&31)<<6|c&63,y>127&&(o=y));break;case 3:c=r[i+1],g=r[i+2],(c&192)===128&&(g&192)===128&&(y=(s&15)<<12|(c&63)<<6|g&63,y>2047&&(y<55296||y>57343)&&(o=y));break;case 4:c=r[i+1],g=r[i+2],v=r[i+3],(c&192)===128&&(g&192)===128&&(v&192)===128&&(y=(s&15)<<18|(c&63)<<12|(g&63)<<6|v&63,y>65535&&y<1114112&&(o=y))}}o===null?(o=65533,u=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=u}return Ec(n)}function Ec(r){var e=r.length;if(e<=Ts)return String.fromCharCode.apply(String,r);for(var t="",n=0;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Ts));return t}function vc(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 Ic(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 Ac(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+=Rc(r[s]);return i}function Sc(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 Le(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 je(r,e,t,n,i,s){if(!dt(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 Yr(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 Ds(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 qs(r,e,t,n,i){return i||Ds(r,e,t,4),Ns(r,e,t,n,23,4),t+4}function $s(r,e,t,n,i){return i||Ds(r,e,t,8),Ns(r,e,t,n,52,8),t+8}function Bc(r){if(r=Nc(r).replace(Tc,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Nc(r){return r.trim?r.trim():r.replace(/^\s+|\s+$/g,"")}function Rc(r){return r<16?"0"+r.toString(16):r.toString(16)}function Hr(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 Oc(r){for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function Uc(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 Cs(r){return sc(Bc(r))}function Kr(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 Pc(r){return r!==r}function Gs(r){return r!=null&&(!!r._isBuffer||Vs(r)||Fc(r))}function Vs(r){return!!r.constructor&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function Fc(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&Vs(r.slice(0,0))}var ht,nt,ic,jn,cc,Rs,Os,uc,Ts,Tc,js=Ya(()=>{ht=[],nt=[],ic=typeof Uint8Array<"u"?Uint8Array:Array,jn=!1;cc={}.toString,Rs=Array.isArray||function(r){return cc.call(r)=="[object Array]"};Os=50;q.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;uc=Vr();q.poolSize=8192;q._augment=function(r){return r.__proto__=q.prototype,r};q.from=function(r,e,t){return Us(null,r,e,t)};q.TYPED_ARRAY_SUPPORT&&(q.prototype.__proto__=Uint8Array.prototype,q.__proto__=Uint8Array);q.alloc=function(r,e,t){return fc(null,r,e,t)};q.allocUnsafe=function(r){return Yn(null,r)};q.allocUnsafeSlow=function(r){return Yn(null,r)};q.isBuffer=Gs;q.compare=function(e,t){if(!dt(e)||!dt(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(!Rs(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(!dt(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,s),s+=o.length}return i};q.byteLength=Fs;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)Dt(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)Dt(this,t,t+3),Dt(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)Dt(this,t,t+7),Dt(this,t+1,t+6),Dt(this,t+2,t+5),Dt(this,t+3,t+4);return this};q.prototype.toString=function(){var e=this.length|0;return e===0?"":arguments.length===0?ks(this,0,e):mc.apply(this,arguments)};q.prototype.equals=function(e){if(!dt(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=Os;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(!dt(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,u=n-t,c=Math.min(o,u),g=this.slice(i,s),v=e.slice(t,n),y=0;y<c;++y)if(g[y]!==v[y]){o=g[y],u=v[y];break}return o<u?-1:u<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 Ms(this,e,t,n,!0)};q.prototype.lastIndexOf=function(e,t,n){return Ms(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 gc(this,e,t,n);case"utf8":case"utf-8":return wc(this,e,t,n);case"ascii":return Ls(this,e,t,n);case"latin1":case"binary":return yc(this,e,t,n);case"base64":return bc(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xc(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)}};Ts=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||Le(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||Le(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||Le(e,1,this.length),this[e]};q.prototype.readUInt16LE=function(e,t){return t||Le(e,2,this.length),this[e]|this[e+1]<<8};q.prototype.readUInt16BE=function(e,t){return t||Le(e,2,this.length),this[e]<<8|this[e+1]};q.prototype.readUInt32LE=function(e,t){return t||Le(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||Le(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||Le(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||Le(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||Le(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};q.prototype.readInt16LE=function(e,t){t||Le(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||Le(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||Le(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||Le(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||Le(e,4,this.length),jr(this,e,!0,23,4)};q.prototype.readFloatBE=function(e,t){return t||Le(e,4,this.length),jr(this,e,!1,23,4)};q.prototype.readDoubleLE=function(e,t){return t||Le(e,8,this.length),jr(this,e,!0,52,8)};q.prototype.readDoubleBE=function(e,t){return t||Le(e,8,this.length),jr(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;je(this,e,t,n,s,0)}var o=1,u=0;for(this[t]=e&255;++u<n&&(o*=256);)this[t+u]=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;je(this,e,t,n,s,0)}var o=n-1,u=1;for(this[t+o]=e&255;--o>=0&&(u*=256);)this[t+o]=e/u&255;return t+n};q.prototype.writeUInt8=function(e,t,n){return e=+e,t=t|0,n||je(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||je(this,e,t,2,65535,0),q.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Yr(this,e,t,!0),t+2};q.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t|0,n||je(this,e,t,2,65535,0),q.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Yr(this,e,t,!1),t+2};q.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t|0,n||je(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||je(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);je(this,e,t,n,s-1,-s)}var o=0,u=1,c=0;for(this[t]=e&255;++o<n&&(u*=256);)e<0&&c===0&&this[t+o-1]!==0&&(c=1),this[t+o]=(e/u>>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);je(this,e,t,n,s-1,-s)}var o=n-1,u=1,c=0;for(this[t+o]=e&255;--o>=0&&(u*=256);)e<0&&c===0&&this[t+o+1]!==0&&(c=1),this[t+o]=(e/u>>0)-c&255;return t+n};q.prototype.writeInt8=function(e,t,n){return e=+e,t=t|0,n||je(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||je(this,e,t,2,32767,-32768),q.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Yr(this,e,t,!0),t+2};q.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t|0,n||je(this,e,t,2,32767,-32768),q.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Yr(this,e,t,!1),t+2};q.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t|0,n||je(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||je(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 qs(this,e,t,!0,n)};q.prototype.writeFloatBE=function(e,t,n){return qs(this,e,t,!1,n)};q.prototype.writeDoubleLE=function(e,t,n){return $s(this,e,t,!0,n)};q.prototype.writeDoubleBE=function(e,t,n){return $s(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 u=dt(e)?e:Hr(new q(e,i).toString()),c=u.length;for(o=0;o<n-t;++o)this[o+t]=u[o%c]}return this};Tc=/[^+\/0-9A-Za-z-_]/g});var pr=Me((y0,Wr)=>{var qt=(js(),za(Hs));if(qt&&qt.default){Wr.exports=qt.default;for(let r in qt)Wr.exports[r]=qt[r]}else qt&&(Wr.exports=qt)});var Ys=Me(Kn=>{Kn.read=function(r,e,t,n,i){var s,o,u=i*8-n-1,c=(1<<u)-1,g=c>>1,v=-7,y=t?i-1:0,S=t?-1:1,U=r[e+y];for(y+=S,s=U&(1<<-v)-1,U>>=-v,v+=u;v>0;s=s*256+r[e+y],y+=S,v-=8);for(o=s&(1<<-v)-1,s>>=-v,v+=n;v>0;o=o*256+r[e+y],y+=S,v-=8);if(s===0)s=1-g;else{if(s===c)return o?NaN:(U?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-g}return(U?-1:1)*o*Math.pow(2,s-n)};Kn.write=function(r,e,t,n,i,s){var o,u,c,g=s*8-i-1,v=(1<<g)-1,y=v>>1,S=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,U=n?0:s-1,f=n?1:-1,D=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,o=v):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+y>=1?e+=S/c:e+=S*Math.pow(2,1-y),e*c>=2&&(o++,c/=2),o+y>=v?(u=0,o=v):o+y>=1?(u=(e*c-1)*Math.pow(2,i),o=o+y):(u=e*Math.pow(2,y-1)*Math.pow(2,i),o=0));i>=8;r[t+U]=u&255,U+=f,u/=256,i-=8);for(o=o<<i|u,g+=i;g>0;r[t+U]=o&255,U+=f,o/=256,g-=8);r[t+U-f]|=D*128}});var mr=Me((zs,Zr)=>{(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: ",u=1e14,c=14,g=9007199254740991,v=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],y=1e7,S=1e9;function U(A){var $,C,j,M=R.prototype={constructor:R,toString:null,valueOf:null},oe=new R(1),ee=20,J=4,p=-7,x=21,O=-1e7,L=1e7,Y=!1,X=1,se=0,Ue={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},Te="0123456789abcdefghijklmnopqrstuvwxyz",H=!0;function R(a,l){var h,I,b,_,N,m,E,B,T=this;if(!(T instanceof R))return new R(a,l);if(l==null){if(a&&a._isBigNumber===!0){T.s=a.s,!a.c||a.e>L?T.c=T.e=null:a.e<O?T.c=[T.e=0]:(T.e=a.e,T.c=a.c.slice());return}if((m=typeof a=="number")&&a*0==0){if(T.s=1/a<0?(a=-a,-1):1,a===~~a){for(_=0,N=a;N>=10;N/=10,_++);_>L?T.c=T.e=null:(T.e=_,T.c=[a]);return}B=String(a)}else{if(!t.test(B=String(a)))return j(T,B,m);T.s=B.charCodeAt(0)==45?(B=B.slice(1),-1):1}(_=B.indexOf("."))>-1&&(B=B.replace(".","")),(N=B.search(/e/i))>0?(_<0&&(_=N),_+=+B.slice(N+1),B=B.substring(0,N)):_<0&&(_=B.length)}else{if(F(l,2,Te.length,"Base"),l==10&&H)return T=new R(a),ae(T,ee+T.e+1,J);if(B=String(a),m=typeof a=="number"){if(a*0!=0)return j(T,B,m,l);if(T.s=1/a<0?(B=B.slice(1),-1):1,R.DEBUG&&B.replace(/^0\.0*|\./,"").length>15)throw Error(o+a)}else T.s=B.charCodeAt(0)===45?(B=B.slice(1),-1):1;for(h=Te.slice(0,l),_=N=0,E=B.length;N<E;N++)if(h.indexOf(I=B.charAt(N))<0){if(I=="."){if(N>_){_=E;continue}}else if(!b&&(B==B.toUpperCase()&&(B=B.toLowerCase())||B==B.toLowerCase()&&(B=B.toUpperCase()))){b=!0,N=-1,_=0;continue}return j(T,String(a),m,l)}m=!1,B=C(B,l,10,T.s),(_=B.indexOf("."))>-1?B=B.replace(".",""):_=B.length}for(N=0;B.charCodeAt(N)===48;N++);for(E=B.length;B.charCodeAt(--E)===48;);if(B=B.slice(N,++E)){if(E-=N,m&&R.DEBUG&&E>15&&(a>g||a!==i(a)))throw Error(o+T.s*a);if((_=_-N-1)>L)T.c=T.e=null;else if(_<O)T.c=[T.e=0];else{if(T.e=_,T.c=[],N=(_+1)%c,_<0&&(N+=c),N<E){for(N&&T.c.push(+B.slice(0,N)),E-=c;N<E;)T.c.push(+B.slice(N,N+=c));N=c-(B=B.slice(N)).length}else N-=E;for(;N--;B+="0");T.c.push(+B)}}else T.c=[T.e=0]}R.clone=U,R.ROUND_UP=0,R.ROUND_DOWN=1,R.ROUND_CEIL=2,R.ROUND_FLOOR=3,R.ROUND_HALF_UP=4,R.ROUND_HALF_DOWN=5,R.ROUND_HALF_EVEN=6,R.ROUND_HALF_CEIL=7,R.ROUND_HALF_FLOOR=8,R.EUCLID=9,R.config=R.set=function(a){var l,h;if(a!=null)if(typeof a=="object"){if(a.hasOwnProperty(l="DECIMAL_PLACES")&&(h=a[l],F(h,0,S,l),ee=h),a.hasOwnProperty(l="ROUNDING_MODE")&&(h=a[l],F(h,0,8,l),J=h),a.hasOwnProperty(l="EXPONENTIAL_AT")&&(h=a[l],h&&h.pop?(F(h[0],-S,0,l),F(h[1],0,S,l),p=h[0],x=h[1]):(F(h,-S,S,l),p=-(x=h<0?-h:h))),a.hasOwnProperty(l="RANGE"))if(h=a[l],h&&h.pop)F(h[0],-S,-1,l),F(h[1],1,S,l),O=h[0],L=h[1];else if(F(h,-S,S,l),h)O=-(L=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))Y=h;else throw Y=!h,Error(s+"crypto unavailable");else Y=h;else throw Error(s+l+" not true or false: "+h);if(a.hasOwnProperty(l="MODULO_MODE")&&(h=a[l],F(h,0,9,l),X=h),a.hasOwnProperty(l="POW_PRECISION")&&(h=a[l],F(h,0,S,l),se=h),a.hasOwnProperty(l="FORMAT"))if(h=a[l],typeof h=="object")Ue=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",Te=h;else throw Error(s+l+" invalid: "+h)}else throw Error(s+"Object expected: "+a);return{DECIMAL_PLACES:ee,ROUNDING_MODE:J,EXPONENTIAL_AT:[p,x],RANGE:[O,L],CRYPTO:Y,MODULO_MODE:X,POW_PRECISION:se,FORMAT:Ue,ALPHABET:Te}},R.isBigNumber=function(a){if(!a||a._isBigNumber!==!0)return!1;if(!R.DEBUG)return!0;var l,h,I=a.c,b=a.e,_=a.s;e:if({}.toString.call(I)=="[object Array]"){if((_===1||_===-1)&&b>=-S&&b<=S&&b===i(b)){if(I[0]===0){if(b===0&&I.length===1)return!0;break e}if(l=(b+1)%c,l<1&&(l+=c),String(I[0]).length==l){for(l=0;l<I.length;l++)if(h=I[l],h<0||h>=u||h!==i(h))break e;if(h!==0)return!0}}}else if(I===null&&b===null&&(_===null||_===1||_===-1))return!0;throw Error(s+"Invalid BigNumber: "+a)},R.maximum=R.max=function(){return te(arguments,-1)},R.minimum=R.min=function(){return te(arguments,1)},R.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 I,b,_,N,m,E=0,B=[],T=new R(oe);if(h==null?h=ee:F(h,0,S),N=n(h/c),Y)if(crypto.getRandomValues){for(I=crypto.getRandomValues(new Uint32Array(N*=2));E<N;)m=I[E]*131072+(I[E+1]>>>11),m>=9e15?(b=crypto.getRandomValues(new Uint32Array(2)),I[E]=b[0],I[E+1]=b[1]):(B.push(m%1e14),E+=2);E=N/2}else if(crypto.randomBytes){for(I=crypto.randomBytes(N*=7);E<N;)m=(I[E]&31)*281474976710656+I[E+1]*1099511627776+I[E+2]*4294967296+I[E+3]*16777216+(I[E+4]<<16)+(I[E+5]<<8)+I[E+6],m>=9e15?crypto.randomBytes(7).copy(I,E):(B.push(m%1e14),E+=7);E=N/7}else throw Y=!1,Error(s+"crypto unavailable");if(!Y)for(;E<N;)m=l(),m<9e15&&(B[E++]=m%1e14);for(N=B[--E],h%=c,N&&h&&(m=v[c-h],B[E]=i(N/m)*m);B[E]===0;B.pop(),E--);if(E<0)B=[_=0];else{for(_=-1;B[0]===0;B.splice(0,1),_-=c);for(E=1,m=B[0];m>=10;m/=10,E++);E<c&&(_-=c-E)}return T.e=_,T.c=B,T}}(),R.sum=function(){for(var a=1,l=arguments,h=new R(l[0]);a<l.length;)h=h.plus(l[a++]);return h},C=function(){var a="0123456789";function l(h,I,b,_){for(var N,m=[0],E,B=0,T=h.length;B<T;){for(E=m.length;E--;m[E]*=I);for(m[0]+=_.indexOf(h.charAt(B++)),N=0;N<m.length;N++)m[N]>b-1&&(m[N+1]==null&&(m[N+1]=0),m[N+1]+=m[N]/b|0,m[N]%=b)}return m.reverse()}return function(h,I,b,_,N){var m,E,B,T,k,V,re,he,ye=h.indexOf("."),Ie=ee,fe=J;for(ye>=0&&(T=se,se=0,h=h.replace(".",""),he=new R(I),V=he.pow(h.length-ye),se=T,he.c=l(W(D(V.c),V.e,"0"),10,b,a),he.e=he.c.length),re=l(h,I,b,N?(m=Te,a):(m=a,Te)),B=T=re.length;re[--T]==0;re.pop());if(!re[0])return m.charAt(0);if(ye<0?--B:(V.c=re,V.e=B,V.s=_,V=$(V,he,Ie,fe,b),re=V.c,k=V.r,B=V.e),E=B+Ie+1,ye=re[E],T=b/2,k=k||E<0||re[E+1]!=null,k=fe<4?(ye!=null||k)&&(fe==0||fe==(V.s<0?3:2)):ye>T||ye==T&&(fe==4||k||fe==6&&re[E-1]&1||fe==(V.s<0?8:7)),E<1||!re[0])h=k?W(m.charAt(1),-Ie,m.charAt(0)):m.charAt(0);else{if(re.length=E,k)for(--b;++re[--E]>b;)re[E]=0,E||(++B,re=[1].concat(re));for(T=re.length;!re[--T];);for(ye=0,h="";ye<=T;h+=m.charAt(re[ye++]));h=W(h,B,m.charAt(0))}return h}}(),$=function(){function a(I,b,_){var N,m,E,B,T=0,k=I.length,V=b%y,re=b/y|0;for(I=I.slice();k--;)E=I[k]%y,B=I[k]/y|0,N=re*E+B*V,m=V*E+N%y*y+T,T=(m/_|0)+(N/y|0)+re*B,I[k]=m%_;return T&&(I=[T].concat(I)),I}function l(I,b,_,N){var m,E;if(_!=N)E=_>N?1:-1;else for(m=E=0;m<_;m++)if(I[m]!=b[m]){E=I[m]>b[m]?1:-1;break}return E}function h(I,b,_,N){for(var m=0;_--;)I[_]-=m,m=I[_]<b[_]?1:0,I[_]=m*N+I[_]-b[_];for(;!I[0]&&I.length>1;I.splice(0,1));}return function(I,b,_,N,m){var E,B,T,k,V,re,he,ye,Ie,fe,ie,Pe,jt,cr,ur,rt,pe,He=I.s==b.s?1:-1,qe=I.c,be=b.c;if(!qe||!qe[0]||!be||!be[0])return new R(!I.s||!b.s||(qe?be&&qe[0]==be[0]:!be)?NaN:qe&&qe[0]==0||!be?He*0:He/0);for(ye=new R(He),Ie=ye.c=[],B=I.e-b.e,He=_+B+1,m||(m=u,B=f(I.e/c)-f(b.e/c),He=He/c|0),T=0;be[T]==(qe[T]||0);T++);if(be[T]>(qe[T]||0)&&B--,He<0)Ie.push(1),k=!0;else{for(cr=qe.length,rt=be.length,T=0,He+=2,V=i(m/(be[0]+1)),V>1&&(be=a(be,V,m),qe=a(qe,V,m),rt=be.length,cr=qe.length),jt=rt,fe=qe.slice(0,rt),ie=fe.length;ie<rt;fe[ie++]=0);pe=be.slice(),pe=[0].concat(pe),ur=be[0],be[1]>=m/2&&ur++;do{if(V=0,E=l(be,fe,rt,ie),E<0){if(Pe=fe[0],rt!=ie&&(Pe=Pe*m+(fe[1]||0)),V=i(Pe/ur),V>1)for(V>=m&&(V=m-1),re=a(be,V,m),he=re.length,ie=fe.length;l(re,fe,he,ie)==1;)V--,h(re,rt<he?pe:be,he,m),he=re.length,E=1;else V==0&&(E=V=1),re=be.slice(),he=re.length;if(he<ie&&(re=[0].concat(re)),h(fe,re,ie,m),ie=fe.length,E==-1)for(;l(be,fe,rt,ie)<1;)V++,h(fe,rt<ie?pe:be,ie,m),ie=fe.length}else E===0&&(V++,fe=[0]);Ie[T++]=V,fe[0]?fe[ie++]=qe[jt]||0:(fe=[qe[jt]],ie=1)}while((jt++<cr||fe[0]!=null)&&He--);k=fe[0]!=null,Ie[0]||Ie.splice(0,1)}if(m==u){for(T=1,He=Ie[0];He>=10;He/=10,T++);ae(ye,_+(ye.e=T+B*c-1)+1,N,k)}else ye.e=B,ye.r=+k;return ye}}();function d(a,l,h,I){var b,_,N,m,E;if(h==null?h=J:F(h,0,8),!a.c)return a.toString();if(b=a.c[0],N=a.e,l==null)E=D(a.c),E=I==1||I==2&&(N<=p||N>=x)?K(E,N):W(E,N,"0");else if(a=ae(new R(a),l,h),_=a.e,E=D(a.c),m=E.length,I==1||I==2&&(l<=_||_<=p)){for(;m<l;E+="0",m++);E=K(E,_)}else if(l-=N,E=W(E,_,"0"),_+1>m){if(--l>0)for(E+=".";l--;E+="0");}else if(l+=_-m,l>0)for(_+1==m&&(E+=".");l--;E+="0");return a.s<0&&b?"-"+E:E}function te(a,l){for(var h,I,b=1,_=new R(a[0]);b<a.length;b++)I=new R(a[b]),(!I.s||(h=P(_,I))===l||h===0&&_.s===l)&&(_=I);return _}function ne(a,l,h){for(var I=1,b=l.length;!l[--b];l.pop());for(b=l[0];b>=10;b/=10,I++);return(h=I+h*c-1)>L?a.c=a.e=null:h<O?a.c=[a.e=0]:(a.e=h,a.c=l),a}j=function(){var a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,l=/^([^.]+)\.$/,h=/^\.([^.]+)$/,I=/^-?(Infinity|NaN)$/,b=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(_,N,m,E){var B,T=m?N:N.replace(b,"");if(I.test(T))_.s=isNaN(T)?null:T<0?-1:1;else{if(!m&&(T=T.replace(a,function(k,V,re){return B=(re=re.toLowerCase())=="x"?16:re=="b"?2:8,!E||E==B?V:k}),E&&(B=E,T=T.replace(l,"$1").replace(h,"0.$1")),N!=T))return new R(T,B);if(R.DEBUG)throw Error(s+"Not a"+(E?" base "+E:"")+" number: "+N);_.s=null}_.c=_.e=null}}();function ae(a,l,h,I){var b,_,N,m,E,B,T,k=a.c,V=v;if(k){e:{for(b=1,m=k[0];m>=10;m/=10,b++);if(_=l-b,_<0)_+=c,N=l,E=k[B=0],T=i(E/V[b-N-1]%10);else if(B=n((_+1)/c),B>=k.length)if(I){for(;k.length<=B;k.push(0));E=T=0,b=1,_%=c,N=_-c+1}else break e;else{for(E=m=k[B],b=1;m>=10;m/=10,b++);_%=c,N=_-c+b,T=N<0?0:i(E/V[b-N-1]%10)}if(I=I||l<0||k[B+1]!=null||(N<0?E:E%V[b-N-1]),I=h<4?(T||I)&&(h==0||h==(a.s<0?3:2)):T>5||T==5&&(h==4||I||h==6&&(_>0?N>0?E/V[b-N]:0:k[B-1])%10&1||h==(a.s<0?8:7)),l<1||!k[0])return k.length=0,I?(l-=a.e+1,k[0]=V[(c-l%c)%c],a.e=-l||0):k[0]=a.e=0,a;if(_==0?(k.length=B,m=1,B--):(k.length=B+1,m=V[c-_],k[B]=N>0?i(E/V[b-N]%V[N])*m:0),I)for(;;)if(B==0){for(_=1,N=k[0];N>=10;N/=10,_++);for(N=k[0]+=m,m=1;N>=10;N/=10,m++);_!=m&&(a.e++,k[0]==u&&(k[0]=1));break}else{if(k[B]+=m,k[B]!=u)break;k[B--]=0,m=1}for(_=k.length;k[--_]===0;k.pop());}a.e>L?a.c=a.e=null:a.e<O&&(a.c=[a.e=0])}return a}function z(a){var l,h=a.e;return h===null?a.toString():(l=D(a.c),l=h<=p||h>=x?K(l,h):W(l,h,"0"),a.s<0?"-"+l:l)}return M.absoluteValue=M.abs=function(){var a=new R(this);return a.s<0&&(a.s=1),a},M.comparedTo=function(a,l){return P(this,new R(a,l))},M.decimalPlaces=M.dp=function(a,l){var h,I,b,_=this;if(a!=null)return F(a,0,S),l==null?l=J:F(l,0,8),ae(new R(_),a+_.e+1,l);if(!(h=_.c))return null;if(I=((b=h.length-1)-f(this.e/c))*c,b=h[b])for(;b%10==0;b/=10,I--);return I<0&&(I=0),I},M.dividedBy=M.div=function(a,l){return $(this,new R(a,l),ee,J)},M.dividedToIntegerBy=M.idiv=function(a,l){return $(this,new R(a,l),0,1)},M.exponentiatedBy=M.pow=function(a,l){var h,I,b,_,N,m,E,B,T,k=this;if(a=new R(a),a.c&&!a.isInteger())throw Error(s+"Exponent not an integer: "+z(a));if(l!=null&&(l=new R(l)),m=a.e>14,!k.c||!k.c[0]||k.c[0]==1&&!k.e&&k.c.length==1||!a.c||!a.c[0])return T=new R(Math.pow(+z(k),m?a.s*(2-G(a)):+z(a))),l?T.mod(l):T;if(E=a.s<0,l){if(l.c?!l.c[0]:!l.s)return new R(NaN);I=!E&&k.isInteger()&&l.isInteger(),I&&(k=k.mod(l))}else{if(a.e>9&&(k.e>0||k.e<-1||(k.e==0?k.c[0]>1||m&&k.c[1]>=24e7:k.c[0]<8e13||m&&k.c[0]<=9999975e7)))return _=k.s<0&&G(a)?-0:0,k.e>-1&&(_=1/_),new R(E?1/_:_);se&&(_=n(se/c+2))}for(m?(h=new R(.5),E&&(a.s=1),B=G(a)):(b=Math.abs(+z(a)),B=b%2),T=new R(oe);;){if(B){if(T=T.times(k),!T.c)break;_?T.c.length>_&&(T.c.length=_):I&&(T=T.mod(l))}if(b){if(b=i(b/2),b===0)break;B=b%2}else if(a=a.times(h),ae(a,a.e+1,1),a.e>14)B=G(a);else{if(b=+z(a),b===0)break;B=b%2}k=k.times(k),_?k.c&&k.c.length>_&&(k.c.length=_):I&&(k=k.mod(l))}return I?T:(E&&(T=oe.div(T)),l?T.mod(l):_?ae(T,se,J,N):T)},M.integerValue=function(a){var l=new R(this);return a==null?a=J:F(a,0,8),ae(l,l.e+1,a)},M.isEqualTo=M.eq=function(a,l){return P(this,new R(a,l))===0},M.isFinite=function(){return!!this.c},M.isGreaterThan=M.gt=function(a,l){return P(this,new R(a,l))>0},M.isGreaterThanOrEqualTo=M.gte=function(a,l){return(l=P(this,new R(a,l)))===1||l===0},M.isInteger=function(){return!!this.c&&f(this.e/c)>this.c.length-2},M.isLessThan=M.lt=function(a,l){return P(this,new R(a,l))<0},M.isLessThanOrEqualTo=M.lte=function(a,l){return(l=P(this,new R(a,l)))===-1||l===0},M.isNaN=function(){return!this.s},M.isNegative=function(){return this.s<0},M.isPositive=function(){return this.s>0},M.isZero=function(){return!!this.c&&this.c[0]==0},M.minus=function(a,l){var h,I,b,_,N=this,m=N.s;if(a=new R(a,l),l=a.s,!m||!l)return new R(NaN);if(m!=l)return a.s=-l,N.plus(a);var E=N.e/c,B=a.e/c,T=N.c,k=a.c;if(!E||!B){if(!T||!k)return T?(a.s=-l,a):new R(k?N:NaN);if(!T[0]||!k[0])return k[0]?(a.s=-l,a):new R(T[0]?N:J==3?-0:0)}if(E=f(E),B=f(B),T=T.slice(),m=E-B){for((_=m<0)?(m=-m,b=T):(B=E,b=k),b.reverse(),l=m;l--;b.push(0));b.reverse()}else for(I=(_=(m=T.length)<(l=k.length))?m:l,m=l=0;l<I;l++)if(T[l]!=k[l]){_=T[l]<k[l];break}if(_&&(b=T,T=k,k=b,a.s=-a.s),l=(I=k.length)-(h=T.length),l>0)for(;l--;T[h++]=0);for(l=u-1;I>m;){if(T[--I]<k[I]){for(h=I;h&&!T[--h];T[h]=l);--T[h],T[I]+=u}T[I]-=k[I]}for(;T[0]==0;T.splice(0,1),--B);return T[0]?ne(a,T,B):(a.s=J==3?-1:1,a.c=[a.e=0],a)},M.modulo=M.mod=function(a,l){var h,I,b=this;return a=new R(a,l),!b.c||!a.s||a.c&&!a.c[0]?new R(NaN):!a.c||b.c&&!b.c[0]?new R(b):(X==9?(I=a.s,a.s=1,h=$(b,a,0,3),a.s=I,h.s*=I):h=$(b,a,0,X),a=b.minus(h.times(a)),!a.c[0]&&X==1&&(a.s=b.s),a)},M.multipliedBy=M.times=function(a,l){var h,I,b,_,N,m,E,B,T,k,V,re,he,ye,Ie,fe=this,ie=fe.c,Pe=(a=new R(a,l)).c;if(!ie||!Pe||!ie[0]||!Pe[0])return!fe.s||!a.s||ie&&!ie[0]&&!Pe||Pe&&!Pe[0]&&!ie?a.c=a.e=a.s=null:(a.s*=fe.s,!ie||!Pe?a.c=a.e=null:(a.c=[0],a.e=0)),a;for(I=f(fe.e/c)+f(a.e/c),a.s*=fe.s,E=ie.length,k=Pe.length,E<k&&(he=ie,ie=Pe,Pe=he,b=E,E=k,k=b),b=E+k,he=[];b--;he.push(0));for(ye=u,Ie=y,b=k;--b>=0;){for(h=0,V=Pe[b]%Ie,re=Pe[b]/Ie|0,N=E,_=b+N;_>b;)B=ie[--N]%Ie,T=ie[N]/Ie|0,m=re*B+T*V,B=V*B+m%Ie*Ie+he[_]+h,h=(B/ye|0)+(m/Ie|0)+re*T,he[_--]=B%ye;he[_]=h}return h?++I:he.splice(0,1),ne(a,he,I)},M.negated=function(){var a=new R(this);return a.s=-a.s||null,a},M.plus=function(a,l){var h,I=this,b=I.s;if(a=new R(a,l),l=a.s,!b||!l)return new R(NaN);if(b!=l)return a.s=-l,I.minus(a);var _=I.e/c,N=a.e/c,m=I.c,E=a.c;if(!_||!N){if(!m||!E)return new R(b/0);if(!m[0]||!E[0])return E[0]?a:new R(m[0]?I:b*0)}if(_=f(_),N=f(N),m=m.slice(),b=_-N){for(b>0?(N=_,h=E):(b=-b,h=m),h.reverse();b--;h.push(0));h.reverse()}for(b=m.length,l=E.length,b-l<0&&(h=E,E=m,m=h,l=b),b=0;l;)b=(m[--l]=m[l]+E[l]+b)/u|0,m[l]=u===m[l]?0:m[l]%u;return b&&(m=[b].concat(m),++N),ne(a,m,N)},M.precision=M.sd=function(a,l){var h,I,b,_=this;if(a!=null&&a!==!!a)return F(a,1,S),l==null?l=J:F(l,0,8),ae(new R(_),a,l);if(!(h=_.c))return null;if(b=h.length-1,I=b*c+1,b=h[b]){for(;b%10==0;b/=10,I--);for(b=h[0];b>=10;b/=10,I++);}return a&&_.e+1>I&&(I=_.e+1),I},M.shiftedBy=function(a){return F(a,-g,g),this.times("1e"+a)},M.squareRoot=M.sqrt=function(){var a,l,h,I,b,_=this,N=_.c,m=_.s,E=_.e,B=ee+4,T=new R("0.5");if(m!==1||!N||!N[0])return new R(!m||m<0&&(!N||N[0])?NaN:N?_:1/0);if(m=Math.sqrt(+z(_)),m==0||m==1/0?(l=D(N),(l.length+E)%2==0&&(l+="0"),m=Math.sqrt(+l),E=f((E+1)/2)-(E<0||E%2),m==1/0?l="5e"+E:(l=m.toExponential(),l=l.slice(0,l.indexOf("e")+1)+E),h=new R(l)):h=new R(m+""),h.c[0]){for(E=h.e,m=E+B,m<3&&(m=0);;)if(b=h,h=T.times(b.plus($(_,b,B,1))),D(b.c).slice(0,m)===(l=D(h.c)).slice(0,m))if(h.e<E&&--m,l=l.slice(m-3,m+1),l=="9999"||!I&&l=="4999"){if(!I&&(ae(b,b.e+ee+2,0),b.times(b).eq(_))){h=b;break}B+=4,m+=4,I=1}else{(!+l||!+l.slice(1)&&l.charAt(0)=="5")&&(ae(h,h.e+ee+2,1),a=!h.times(h).eq(_));break}}return ae(h,h.e+ee+1,J,a)},M.toExponential=function(a,l){return a!=null&&(F(a,0,S),a++),d(this,a,l,1)},M.toFixed=function(a,l){return a!=null&&(F(a,0,S),a=a+this.e+1),d(this,a,l)},M.toFormat=function(a,l,h){var I,b=this;if(h==null)a!=null&&l&&typeof l=="object"?(h=l,l=null):a&&typeof a=="object"?(h=a,a=l=null):h=Ue;else if(typeof h!="object")throw Error(s+"Argument not an object: "+h);if(I=b.toFixed(a,l),b.c){var _,N=I.split("."),m=+h.groupSize,E=+h.secondaryGroupSize,B=h.groupSeparator||"",T=N[0],k=N[1],V=b.s<0,re=V?T.slice(1):T,he=re.length;if(E&&(_=m,m=E,E=_,he-=_),m>0&&he>0){for(_=he%m||m,T=re.substr(0,_);_<he;_+=m)T+=B+re.substr(_,m);E>0&&(T+=B+re.slice(_)),V&&(T="-"+T)}I=k?T+(h.decimalSeparator||"")+((E=+h.fractionGroupSize)?k.replace(new RegExp("\\d{"+E+"}\\B","g"),"$&"+(h.fractionGroupSeparator||"")):k):T}return(h.prefix||"")+I+(h.suffix||"")},M.toFraction=function(a){var l,h,I,b,_,N,m,E,B,T,k,V,re=this,he=re.c;if(a!=null&&(m=new R(a),!m.isInteger()&&(m.c||m.s!==1)||m.lt(oe)))throw Error(s+"Argument "+(m.isInteger()?"out of range: ":"not an integer: ")+z(m));if(!he)return new R(re);for(l=new R(oe),B=h=new R(oe),I=E=new R(oe),V=D(he),_=l.e=V.length-re.e-1,l.c[0]=v[(N=_%c)<0?c+N:N],a=!a||m.comparedTo(l)>0?_>0?l:B:m,N=L,L=1/0,m=new R(V),E.c[0]=0;T=$(m,l,0,1),b=h.plus(T.times(I)),b.comparedTo(a)!=1;)h=I,I=b,B=E.plus(T.times(b=B)),E=b,l=m.minus(T.times(b=l)),m=b;return b=$(a.minus(h),I,0,1),E=E.plus(b.times(B)),h=h.plus(b.times(I)),E.s=B.s=re.s,_=_*2,k=$(B,I,_,J).minus(re).abs().comparedTo($(E,h,_,J).minus(re).abs())<1?[B,I]:[E,h],L=N,k},M.toNumber=function(){return+z(this)},M.toPrecision=function(a,l){return a!=null&&F(a,1,S),d(this,a,l,2)},M.toString=function(a){var l,h=this,I=h.s,b=h.e;return b===null?I?(l="Infinity",I<0&&(l="-"+l)):l="NaN":(a==null?l=b<=p||b>=x?K(D(h.c),b):W(D(h.c),b,"0"):a===10&&H?(h=ae(new R(h),ee+b+1,J),l=W(D(h.c),h.e,"0")):(F(a,2,Te.length,"Base"),l=C(W(D(h.c),b,"0"),10,a,I,!0)),I<0&&h.c[0]&&(l="-"+l)),l},M.valueOf=M.toJSON=function(){return z(this)},M._isBigNumber=!0,A!=null&&R.set(A),R}function f(A){var $=A|0;return A>0||A===$?$:$-1}function D(A){for(var $,C,j=1,M=A.length,oe=A[0]+"";j<M;){for($=A[j++]+"",C=c-$.length;C--;$="0"+$);oe+=$}for(M=oe.length;oe.charCodeAt(--M)===48;);return oe.slice(0,M+1||1)}function P(A,$){var C,j,M=A.c,oe=$.c,ee=A.s,J=$.s,p=A.e,x=$.e;if(!ee||!J)return null;if(C=M&&!M[0],j=oe&&!oe[0],C||j)return C?j?0:-J:ee;if(ee!=J)return ee;if(C=ee<0,j=p==x,!M||!oe)return j?0:!M^C?1:-1;if(!j)return p>x^C?1:-1;for(J=(p=M.length)<(x=oe.length)?p:x,ee=0;ee<J;ee++)if(M[ee]!=oe[ee])return M[ee]>oe[ee]^C?1:-1;return p==x?0:p>x^C?1:-1}function F(A,$,C,j){if(A<$||A>C||A!==i(A))throw Error(s+(j||"Argument")+(typeof A=="number"?A<$||A>C?" out of range: ":" not an integer: ":" not a primitive number: ")+String(A))}function G(A){var $=A.c.length-1;return f(A.e/c)==$&&A.c[$]%2!=0}function K(A,$){return(A.length>1?A.charAt(0)+"."+A.slice(1):A)+($<0?"e":"e+")+$}function W(A,$,C){var j,M;if($<0){for(M=C+".";++$;M+=C);A=M+A}else if(j=A.length,++$>j){for(M=C,$-=j;--$;M+=C);A+=M}else $<j&&(A=A.slice(0,$)+"."+A.slice($));return A}e=U(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof Zr<"u"&&Zr.exports?Zr.exports=e:(r||(r=typeof self<"u"&&self?self:window),r.BigNumber=e)})(zs)});var Ws=Me((x0,Ks)=>{Ks.exports=function(e,t,n){var i=new e.Uint8Array(n),s=t.pushInt,o=t.pushInt32,u=t.pushInt32Neg,c=t.pushInt64,g=t.pushInt64Neg,v=t.pushFloat,y=t.pushFloatSingle,S=t.pushFloatDouble,U=t.pushTrue,f=t.pushFalse,D=t.pushUndefined,P=t.pushNull,F=t.pushInfinity,G=t.pushInfinityNeg,K=t.pushNaN,W=t.pushNaNNeg,A=t.pushArrayStart,$=t.pushArrayStartFixed,C=t.pushArrayStartFixed32,j=t.pushArrayStartFixed64,M=t.pushObjectStart,oe=t.pushObjectStartFixed,ee=t.pushObjectStartFixed32,J=t.pushObjectStartFixed64,p=t.pushByteString,x=t.pushByteStringStart,O=t.pushUtf8String,L=t.pushUtf8StringStart,Y=t.pushSimpleUnassigned,X=t.pushTagStart,se=t.pushTagStart4,Ue=t.pushTagStart8,Te=t.pushTagUnassigned,H=t.pushBreak,R=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 z(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 I(w){return w=w|0,z(1)|0?1:(s(i[d+1|0]|0),d=d+2|0,0)}function b(w){return w=w|0,z(2)|0?1:(s(a(d+1|0)|0),d=d+3|0,0)}function _(w){return w=w|0,z(4)|0?1:(o(a(d+1|0)|0,a(d+3|0)|0),d=d+5|0,0)}function N(w){return w=w|0,z(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 m(w){return w=w|0,s(-1-(w-32|0)|0),d=d+1|0,0}function E(w){return w=w|0,z(1)|0?1:(s(-1-(i[d+1|0]|0)|0),d=d+2|0,0)}function B(w){w=w|0;var le=0;return z(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,z(4)|0?1:(u(a(d+1|0)|0,a(d+3|0)|0),d=d+5|0,0)}function k(w){return w=w|0,z(8)|0?1:(g(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 V(w){w=w|0;var le=0,de=0,ce=0;return ce=w-64|0,z(ce|0)|0?1:(le=d+1|0,de=(d+1|0)+(ce|0)|0,p(le|0,de|0),d=de|0,0)}function re(w){w=w|0;var le=0,de=0,ce=0;return z(1)|0||(ce=i[d+1|0]|0,le=d+2|0,de=(d+2|0)+(ce|0)|0,z(ce+1|0)|0)?1:(p(le|0,de|0),d=de|0,0)}function he(w){w=w|0;var le=0,de=0,ce=0;return z(2)|0||(ce=a(d+1|0)|0,le=d+3|0,de=(d+3|0)+(ce|0)|0,z(ce+2|0)|0)?1:(p(le|0,de|0),d=de|0,0)}function ye(w){w=w|0;var le=0,de=0,ce=0;return z(4)|0||(ce=l(d+1|0)|0,le=d+5|0,de=(d+5|0)+(ce|0)|0,z(ce+4|0)|0)?1:(p(le|0,de|0),d=de|0,0)}function Ie(w){return w=w|0,1}function fe(w){return w=w|0,x(),d=d+1|0,0}function ie(w){w=w|0;var le=0,de=0,ce=0;return ce=w-96|0,z(ce|0)|0?1:(le=d+1|0,de=(d+1|0)+(ce|0)|0,O(le|0,de|0),d=de|0,0)}function Pe(w){w=w|0;var le=0,de=0,ce=0;return z(1)|0||(ce=i[d+1|0]|0,le=d+2|0,de=(d+2|0)+(ce|0)|0,z(ce+1|0)|0)?1:(O(le|0,de|0),d=de|0,0)}function jt(w){w=w|0;var le=0,de=0,ce=0;return z(2)|0||(ce=a(d+1|0)|0,le=d+3|0,de=(d+3|0)+(ce|0)|0,z(ce+2|0)|0)?1:(O(le|0,de|0),d=de|0,0)}function cr(w){w=w|0;var le=0,de=0,ce=0;return z(4)|0||(ce=l(d+1|0)|0,le=d+5|0,de=(d+5|0)+(ce|0)|0,z(ce+4|0)|0)?1:(O(le|0,de|0),d=de|0,0)}function ur(w){return w=w|0,1}function rt(w){return w=w|0,L(),d=d+1|0,0}function pe(w){return w=w|0,$(w-128|0),d=d+1|0,0}function He(w){return w=w|0,z(1)|0?1:($(i[d+1|0]|0),d=d+2|0,0)}function qe(w){return w=w|0,z(2)|0?1:($(a(d+1|0)|0),d=d+3|0,0)}function be(w){return w=w|0,z(4)|0?1:(C(a(d+1|0)|0,a(d+3|0)|0),d=d+5|0,0)}function Aa(w){return w=w|0,z(8)|0?1:(j(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 Sa(w){return w=w|0,A(),d=d+1|0,0}function xe(w){w=w|0;var le=0;return le=w-160|0,z(le|0)|0?1:(oe(le|0),d=d+1|0,0)}function Ta(w){return w=w|0,z(1)|0?1:(oe(i[d+1|0]|0),d=d+2|0,0)}function Ba(w){return w=w|0,z(2)|0?1:(oe(a(d+1|0)|0),d=d+3|0,0)}function Na(w){return w=w|0,z(4)|0?1:(ee(a(d+1|0)|0,a(d+3|0)|0),d=d+5|0,0)}function Ra(w){return w=w|0,z(8)|0?1:(J(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 Oa(w){return w=w|0,M(),d=d+1|0,0}function Yt(w){return w=w|0,X(w-192|0|0),d=d+1|0,0}function kf(w){return w=w|0,X(w|0),d=d+1|0,0}function Df(w){return w=w|0,X(w|0),d=d+1|0,0}function qf(w){return w=w|0,X(w|0),d=d+1|0,0}function $f(w){return w=w|0,X(w|0),d=d+1|0,0}function Fe(w){return w=w|0,X(w-192|0|0),d=d+1|0,0}function Cf(w){return w=w|0,X(w|0),d=d+1|0,0}function Gf(w){return w=w|0,X(w|0),d=d+1|0,0}function Vf(w){return w=w|0,X(w|0),d=d+1|0,0}function Ua(w){return w=w|0,z(1)|0?1:(X(i[d+1|0]|0),d=d+2|0,0)}function Pa(w){return w=w|0,z(2)|0?1:(X(a(d+1|0)|0),d=d+3|0,0)}function Fa(w){return w=w|0,z(4)|0?1:(se(a(d+1|0)|0,a(d+3|0)|0),d=d+5|0,0)}function Ma(w){return w=w|0,z(8)|0?1:(Ue(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 Be(w){return w=w|0,Y((w|0)-224|0),d=d+1|0,0}function La(w){return w=w|0,f(),d=d+1|0,0}function ka(w){return w=w|0,U(),d=d+1|0,0}function Da(w){return w=w|0,P(),d=d+1|0,0}function qa(w){return w=w|0,D(),d=d+1|0,0}function $a(w){return w=w|0,z(1)|0?1:(Y(i[d+1|0]|0),d=d+2|0,0)}function Ca(w){w=w|0;var le=0,de=0,ce=1,Lr=0,fr=0,Hf=0;return z(2)|0?1:(le=i[d+1|0]|0,de=i[d+2|0]|0,(le|0)&128&&(ce=-1),Lr=+(((le|0)&124)>>2),fr=+(((le|0)&3)<<8|de),+Lr==0?v(+(+ce*5960464477539063e-23*+fr)):+Lr==31?+ce==1?+fr>0?K():F():+fr>0?W():G():v(+(+ce*R(2,+(+Lr-25))*+(1024+fr))),d=d+3|0,0)}function Ga(w){return w=w|0,z(4)|0?1:(y(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 Va(w){return w=w|0,z(8)|0?1:(S(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 ge(w){return w=w|0,1}function Ha(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,I,b,_,N,ge,ge,ge,ge,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,E,B,T,k,ge,ge,ge,ge,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,V,re,he,ye,Ie,ge,ge,ge,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,Pe,jt,cr,ur,ge,ge,ge,rt,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,He,qe,be,Aa,ge,ge,ge,Sa,xe,xe,xe,xe,xe,xe,xe,xe,xe,xe,xe,xe,xe,xe,xe,xe,xe,xe,xe,xe,xe,xe,xe,xe,Ta,Ba,Na,Ra,ge,ge,ge,Oa,Yt,Yt,Yt,Yt,Yt,Yt,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Ua,Pa,Fa,Ma,ge,ge,ge,ge,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,Be,La,ka,Da,qa,$a,Ca,Ga,Va,ge,ge,ge,Ha];return{parse:ae}}});var gr=Me(Ze=>{"use strict";var Wn=mr().BigNumber;Ze.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Ze.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};Ze.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Ze.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Ze.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Ze.SHIFT32=Math.pow(2,32);Ze.SHIFT16=Math.pow(2,16);Ze.MAX_SAFE_HIGH=2097151;Ze.NEG_ONE=new Wn(-1);Ze.TEN=new Wn(10);Ze.TWO=new Wn(2);Ze.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Xr=Me(it=>{"use strict";var{Buffer:Mc}=pr(),Xs=mr().BigNumber,Js=gr(),Zs=Js.SHIFT32,Lc=Js.SHIFT16,kc=2097151;it.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 Dc(r){return r<16?"0"+r.toString(16):r.toString(16)}it.arrayBufferToBignumber=function(r){let e=r.byteLength,t="";for(let n=0;n<e;n++)t+=Dc(r[n]);return new Xs(t,16)};it.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};it.buildInt32=(r,e)=>r*Lc+e;it.buildInt64=(r,e,t,n)=>{let i=it.buildInt32(r,e),s=it.buildInt32(t,n);return i>kc?new Xs(i).times(Zs).plus(s):i*Zs+s};it.writeHalf=function(e,t){let n=Mc.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,u=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(u>>13);else if(o>=103&&o<113){if(u&(1<<126-o)-1)return!1;s+=u+8388608>>126-o}else return!1;return e.writeUInt16BE(s,0),!0};it.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])};it.isNegativeZero=r=>r===0&&1/r<0;it.nextPowerOf2=r=>{let e=0;if(r&&!(r&r-1))return r;for(;r!==0;)r>>=1,e+=1;return 1<<e}});var Qn=Me((v0,Qs)=>{"use strict";var Jn=gr(),qc=Jn.MT,Jr=Jn.SIMPLE,Zn=Jn.SYMS,Xn=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,qc.SIMPLE_FLOAT)}static isSimple(e){return e instanceof r}static decode(e,t){switch(t==null&&(t=!0),e){case Jr.FALSE:return!1;case Jr.TRUE:return!0;case Jr.NULL:return t?null:Zn.NULL;case Jr.UNDEFINED:return t?void 0:Zn.UNDEFINED;case-1:if(!t)throw new Error("Invalid BREAK");return Zn.BREAK;default:return new r(e)}}};Qs.exports=Xn});var ti=Me((I0,eo)=>{"use strict";var ei=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}}};eo.exports=ei});var ii=Me((A0,ro)=>{"use strict";var to=self.location?self.location.protocol+"//"+self.location.host:"",ri=self.URL,ni=class{constructor(e="",t=to){this.super=new ri(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 $c(r){if(typeof r=="string")return new ri(r).toString();if(!(r instanceof ri)){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||"",u=r.search||(r.query?"?"+r.query:""),c=r.hash||"",g=r.pathname||"",v=r.path||g+u;return`${i}${e||t}${s||o+n}${v}${c}`}}ro.exports={URLWithLegacySupport:ni,URLSearchParams:self.URLSearchParams,defaultBase:to,format:$c}});var so=Me((S0,io)=>{"use strict";var{URLWithLegacySupport:no,format:Cc}=ii();io.exports=(r,e={},t={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(t[i]||n||i)+":";let s;try{s=new no(r)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new no(r,Cc(o)).toString()}});var si=Me((T0,oo)=>{"use strict";var{URLWithLegacySupport:Gc,format:Vc,URLSearchParams:Hc,defaultBase:jc}=ii(),Yc=so();oo.exports={URL:Gc,URLSearchParams:Hc,format:Vc,relative:Yc,defaultBase:jc}});var oi=Me((B0,co)=>{"use strict";var{Buffer:Wt}=pr(),ao=Ys(),zc=mr().BigNumber,Kc=Ws(),Ge=Xr(),me=gr(),Wc=Qn(),Zc=ti(),{URL:Xc}=si(),wr=class r{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=Ge.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=Wt.from(this._heap),this._reset(),this._knownTags=Object.assign({0:t=>new Date(t),1:t=>new Date(t*1e3),2:t=>Ge.arrayBufferToBignumber(t),3:t=>me.NEG_ONE.minus(Ge.arrayBufferToBignumber(t)),4:t=>me.TEN.pow(t[0]).times(t[1]),5:t=>me.TWO.pow(t[0]).times(t[1]),32:t=>new Xc(t),35:t=>new RegExp(t)},e.tags),this.parser=Kc(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 me.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case me.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case me.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case me.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 me.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 me.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===me.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 me.PARENT.ARRAY:case me.PARENT.BYTE_STRING:case me.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case me.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=me.PARENT.MAP,n.ref=Ge.buildMap(n.ref)));break;case me.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case me.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:me.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,t){let n=this._knownTags[e];return n?n(t):new Zc(e,t)}createMap(e,t){return e}createObject(e,t){return e}createArray(e,t){return e}createByteString(e,t){return Wt.concat(e)}createByteStringFromHeap(e,t){return e===t?Wt.alloc(0):Wt.from(this._heap.slice(e,t))}createInt(e){return e}createInt32(e,t){return Ge.buildInt32(e,t)}createInt64(e,t,n,i){return Ge.buildInt64(e,t,n,i)}createFloat(e){return e}createFloatSingle(e,t,n,i){return ao.read([e,t,n,i],0,!1,23,4)}createFloatDouble(e,t,n,i,s,o,u,c){return ao.read([e,t,n,i,s,o,u,c],0,!1,52,8)}createInt32Neg(e,t){return-1-Ge.buildInt32(e,t)}createInt64Neg(e,t,n,i){let s=Ge.buildInt32(e,t),o=Ge.buildInt32(n,i);return s>me.MAX_SAFE_HIGH?me.NEG_ONE.minus(new zc(s).times(me.SHIFT32).plus(o)):-1-(s*me.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 Wc(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,u,c){this._push(this.createFloatDouble(e,t,n,i,s,o,u,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([],me.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,t){let n=Ge.buildInt32(e,t);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,t,n,i){let s=Ge.buildInt64(e,t,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,t){let n=Ge.buildInt32(e,t);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,t,n,i){let s=Ge.buildInt64(e,t,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:me.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:me.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:me.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,t){this.pushTagStart(Ge.buildInt32(e,t))}pushTagStart8(e,t,n,i){this.pushTagStart(Ge.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({},me.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),me.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=Wt.from(e,t||"hex")),new r({size:e.length}).decodeFirst(e)}static decodeAll(e,t){return typeof e=="string"&&(e=Wt.from(e,t||"hex")),new r({size:e.length}).decodeAll(e)}};wr.decodeFirst=wr.decode;co.exports=wr});var lo=Me((N0,fo)=>{"use strict";var{Buffer:ai}=pr(),Jc=oi(),Qc=Xr(),ci=class r extends Jc{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 Qc.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,u,c){return`${super.createFloatDouble(e,t,n,i,s,o,u,c)}_3`}createByteString(e,t){let n=e.join(", ");return t===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(e,t){return`h'${ai.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(uo(n),"");return t===-1?`{_ ${i}}`:`{${i}}`}createObject(e,t){let n=super.createObject(e),i=Object.keys(n).reduce(uo(n),"");return t===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,t){let n=e.join(", ");return t===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,t){return`"${ai.from(super.createUtf8StringFromHeap(e,t)).toString("utf8")}"`}static diagnose(e,t){return typeof e=="string"&&(e=ai.from(e,t||"hex")),new r().decodeFirst(e)}};fo.exports=ci;function uo(r){return(e,t)=>e?`${e}, ${t}: ${r[t]}`:`${t}: ${r[t]}`}});var wo=Me((R0,go)=>{"use strict";var{Buffer:pt}=pr(),{URL:eu}=si(),fi=mr().BigNumber,ui=Xr(),Re=gr(),at=Re.MT,Qr=Re.NUMBYTES,ho=Re.SHIFT32,po=Re.SYMS,Zt=Re.TAG,tu=Re.MT.SIMPLE_FLOAT<<5|Re.NUMBYTES.TWO,ru=Re.MT.SIMPLE_FLOAT<<5|Re.NUMBYTES.FOUR,nu=Re.MT.SIMPLE_FLOAT<<5|Re.NUMBYTES.EIGHT,iu=Re.MT.SIMPLE_FLOAT<<5|Re.SIMPLE.TRUE,su=Re.MT.SIMPLE_FLOAT<<5|Re.SIMPLE.FALSE,ou=Re.MT.SIMPLE_FLOAT<<5|Re.SIMPLE.UNDEFINED,mo=Re.MT.SIMPLE_FLOAT<<5|Re.SIMPLE.NULL,au=new fi("0x20000000000000"),cu=pt.from("f97e00","hex"),uu=pt.from("f9fc00","hex"),fu=pt.from("f97c00","hex");function lu(r){return{}.toString.call(r).slice(8,-1)}var li=class r{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[eu,this._pushUrl],[fi,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(cu)}_pushInfinity(e){let t=e<0?uu:fu;return this.push(t)}_pushFloat(e){let t=pt.allocUnsafe(2);if(ui.writeHalf(t,e)&&ui.parseHalf(t)===e)return this._pushUInt8(tu)&&this.push(t);let n=pt.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(ru)&&this.push(n):this._pushUInt8(nu)&&this._pushDoubleBE(e)}_pushInt(e,t,n){let i=t<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|Qr.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|Qr.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|Qr.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|Qr.EIGHT)&&this._pushUInt32BE(Math.floor(e/ho))&&this._pushUInt32BE(e%ho):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=pt.byteLength(e,"utf8");return this._pushInt(t,at.UTF8_STRING)&&this.pushWrite(e,5,t)}_pushBoolean(e){return this._pushUInt8(e?iu:su)}_pushUndefined(e){return this._pushUInt8(ou)}_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(Zt.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(Zt.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(Zt.URI)&&e.pushAny(t.format())}_pushBigint(e){let t=Zt.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),t=Zt.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=pt.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(Zt.DECIMAL_FRAC)&&e._pushInt(2,at.ARRAY)))return!1;let n=t.decimalPlaces(),i=t.multipliedBy(new fi(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(au)?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(mo);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(u=>[u,e[u]])):!1}_pushRawMap(e,t){t=t.map(function(i){return i[0]=r.encode(i[0]),i}).sort(ui.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=lu(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,pt.isBuffer(e)?e:pt.from(e));case"Null":return this._pushUInt8(mo);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 po.NULL:return this._pushObject(null);case po.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 u=pt.allocUnsafe(s),c=0,g=0;for(o=0;o<i;o++){switch(g=t[o],n[o]){case 0:e[o].copy(u,c);break;case 1:u.writeUInt8(e[o],c,!0);break;case 2:u.writeUInt16BE(e[o],c,!0);break;case 3:u.writeUInt32BE(e[o],c,!0);break;case 4:u.writeDoubleBE(e[o],c,!0);break;case 5:u.write(e[o],c,g,"utf8");break;default:throw new Error("unkown method")}c+=g}var v=u;return this._reset(),v}_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()}};go.exports=li});var hi=Me(Oe=>{"use strict";Oe.Diagnose=lo();Oe.Decoder=oi();Oe.Encoder=wo();Oe.Simple=Qn();Oe.Tagged=ti();Oe.decodeAll=Oe.Decoder.decodeAll;Oe.decodeFirst=Oe.Decoder.decodeFirst;Oe.diagnose=Oe.Diagnose.diagnose;Oe.encode=Oe.Encoder.encode;Oe.decode=Oe.Decoder.decode;Oe.leveldb={decode:Oe.Decoder.decodeAll,encode:Oe.Encoder.encode,buffer:!0,name:"cbor"}});var mi=Me(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});var hu=9007199254740992;function yt(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 en(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 yo(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 yt(new Uint8Array(en(3,r.length)),new Uint8Array(e))}function du(r,e){if(r==14277111)return yt(new Uint8Array([217,217,247]),e);if(r<24)return yt(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=du;function yr(r){return new Uint8Array(r).buffer}we.raw=yr;function di(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=di;function bo(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=bo;function xo(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=xo;function _o(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=_o;function pi(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),hu),r=r.toString(16),ct(0,27,r)}we.u64=pi;function Eo(r){if(isNaN(r))throw new RangeError("Invalid number.");if(r===0)return di(0);r=Math.min(Math.max(0,-r),24)-1;let e=[32+r];return new Uint8Array(e).buffer}we.iSmall=Eo;function vo(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=vo;function Io(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=Io;function Ao(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=Ao;function So(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):pi(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=So;function pu(r){return r>=0?r<24?di(r):r<=255?bo(r):r<=65535?xo(r):r<=4294967295?_o(r):pi(r):r>=-24?Eo(r):r>=-255?vo(r):r>=-65535?Io(r):r>=-4294967295?Ao(r):So(r)}we.number=pu;function mu(r){return yt(en(2,r.byteLength),r)}we.bytes=mu;function gu(r){return yo(r)}we.string=gu;function wu(r){return yt(en(4,r.length),...r)}we.array=wu;function yu(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))),yt(en(5,r.size),...t.map(([n,i])=>yt(yo(n),i)))}we.map=yu;function bu(r){let e=new Float32Array([r]);return yt(new Uint8Array([250]),new Uint8Array(e.buffer))}we.singleFloat=bu;function xu(r){let e=new Float64Array([r]);return yt(new Uint8Array([251]),new Uint8Array(e.buffer))}we.doubleFloat=xu;function _u(r){return r?To():Bo()}we.bool=_u;function To(){return yr(new Uint8Array([245]))}we.true_=To;function Bo(){return yr(new Uint8Array([244]))}we.false_=Bo;function Eu(){return yr(new Uint8Array([246]))}we.null_=Eu;function vu(){return yr(new Uint8Array([247]))}we.undefined_=vu});var No=Me(Nt=>{"use strict";var Iu=Nt&&Nt.__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(Nt,"__esModule",{value:!0});var ut=Iu(mi()),Au=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],tn=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(Au.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.")}}};Nt.JsonDefaultCborEncoder=tn;var rn=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};Nt.ToCborEncoder=rn;var nn=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let t=new this;return t.addEncoder(new tn(t,e)),t.addEncoder(new rn),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)}};Nt.CborSerializer=nn;var gi=class extends nn{serialize(e){return ut.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};Nt.SelfDescribeCborSerializer=gi});var sn=Me($t=>{"use strict";function Su(r){for(var e in r)$t.hasOwnProperty(e)||($t[e]=r[e])}var Tu=$t&&$t.__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($t,"__esModule",{value:!0});Su(No());var Bu=Tu(mi());$t.value=Bu});var kr="abcdefghijklmnopqrstuvwxyz234567",zt=Object.create(null);for(let r=0;r<kr.length;r++)zt[kr[r]]=r;zt[0]=zt.o;zt[1]=zt.i;function ds(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+=kr[t>>3],e+=5),0)}for(let s=0;s<r.length;)s+=i(r[s]);return n+(e<0?kr[t>>3]:"")}function ps(r){let e=0,t=0,n=new Uint8Array(r.length*4/3|0),i=0;function s(o){let u=zt[o.toLowerCase()];if(u===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);u<<=3,t|=u>>>e,e+=5,e>=8&&(n[i++]=t,e-=8,e>0?t=u<<5-e&255:t=0)}for(let o of r)s(o);return n.slice(0,i)}var Ka=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 ms(r){let e=new Uint8Array(r),t=-1;for(let n=0;n<e.length;n++){let s=(e[n]^t)&255;t=Ka[s]^t>>>8}return(t^-1)>>>0}function Wa(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Dn(r,...e){if(!Wa(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 qn(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 gs(r,e){Dn(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var kt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var qr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),st=(r,e)=>r<<32-e|r>>>e;var Xf=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Za(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function $n(r){return typeof r=="string"&&(r=Za(r)),Dn(r),r}var Dr=class{clone(){return this._cloneInto()}},Jf={}.toString;function Cn(r){let e=n=>r().update($n(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function ws(r=32){if(kt&&typeof kt.getRandomValues=="function")return kt.getRandomValues(new Uint8Array(r));if(kt&&typeof kt.randomBytes=="function")return kt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Xa(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),u=Number(t&s),c=n?4:0,g=n?0:4;r.setUint32(e+c,o,n),r.setUint32(e+g,u,n)}var ys=(r,e,t)=>r&e^~r&t,bs=(r,e,t)=>r&e^r&t^e&t,$r=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=qr(this.buffer)}update(e){qn(this);let{view:t,buffer:n,blockLen:i}=this;e=$n(e);let s=e.length;for(let o=0;o<s;){let u=Math.min(i-this.pos,s-o);if(u===i){let c=qr(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+u),this.pos),this.pos+=u,o+=u,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){qn(this),gs(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 y=o;y<i;y++)t[y]=0;Xa(n,i-8,BigInt(this.length*8),s),this.process(n,0);let u=qr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let g=c/4,v=this.get();if(g>v.length)throw new Error("_sha2: outputLen bigger than state");for(let y=0;y<g;y++)u.setUint32(4*y,v[y],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:u}=this;return e.length=i,e.pos=u,e.finished=s,e.destroyed=o,i%t&&e.buffer.set(n),e}};var Ja=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]),Tt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Bt=new Uint32Array(64),Cr=class extends $r{constructor(){super(64,32,8,!1),this.A=Tt[0]|0,this.B=Tt[1]|0,this.C=Tt[2]|0,this.D=Tt[3]|0,this.E=Tt[4]|0,this.F=Tt[5]|0,this.G=Tt[6]|0,this.H=Tt[7]|0}get(){let{A:e,B:t,C:n,D:i,E:s,F:o,G:u,H:c}=this;return[e,t,n,i,s,o,u,c]}set(e,t,n,i,s,o,u,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=u|0,this.H=c|0}process(e,t){for(let y=0;y<16;y++,t+=4)Bt[y]=e.getUint32(t,!1);for(let y=16;y<64;y++){let S=Bt[y-15],U=Bt[y-2],f=st(S,7)^st(S,18)^S>>>3,D=st(U,17)^st(U,19)^U>>>10;Bt[y]=D+Bt[y-7]+f+Bt[y-16]|0}let{A:n,B:i,C:s,D:o,E:u,F:c,G:g,H:v}=this;for(let y=0;y<64;y++){let S=st(u,6)^st(u,11)^st(u,25),U=v+S+ys(u,c,g)+Ja[y]+Bt[y]|0,D=(st(n,2)^st(n,13)^st(n,22))+bs(n,i,s)|0;v=g,g=c,c=u,u=o+U|0,o=s,s=i,i=n,n=U+D|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,u=u+this.E|0,c=c+this.F|0,g=g+this.G|0,v=v+this.H|0,this.set(n,i,s,o,u,c,g,v)}roundClean(){Bt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Gn=class extends Cr{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}},hr=Cn(()=>new Cr),xs=Cn(()=>new Gn);function _s(r){return xs.create().update(new Uint8Array(r)).digest()}var Gr="__principal__",Qa=2,Es=4,ec="aaaaa-aa",tc=r=>{var e;return new Uint8Array(((e=r.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(t=>parseInt(t,16)))},rc=r=>r.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),""),ve=class r{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Es]))}static managementCanister(){return this.fromHex(ec)}static selfAuthenticating(e){let t=_s(e);return new this(new Uint8Array([...t,Qa]))}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(tc(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=ps(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]===Es}toUint8Array(){return this._arr}toHex(){return rc(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,ms(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),u=ds(s).match(/.{1,5}/g);if(!u)throw new Error;return u.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 Vn;(function(r){r[r.SysFatal=1]="SysFatal",r[r.SysTransient=2]="SysTransient",r[r.DestinationInvalid=3]="DestinationInvalid",r[r.CanisterReject=4]="CanisterReject",r[r.CanisterError=5]="CanisterError"})(Vn||(Vn={}));function ot(...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 Ke(r){return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,"0")).join("")}var nc=new RegExp(/^[0-9a-fA-F]+$/);function Kt(r){if(!nc.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 vs(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 dr(r,e){return vs(r,e)===0}function Is(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}var We=class r extends Error{constructor(e){super(e),this.message=e,this.name="AgentError",this.__proto__=r.prototype,Object.setPrototypeOf(this,r.prototype)}};var Oo=lr(hi()),Ct=lr(sn()),Uo=lr(sn());var wi=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return Ct.value.bytes(e.toUint8Array())}},yi=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return Ct.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)?Ct.value.tagged(2,Ct.value.bytes(Kt(e.toString(16)))):Ct.value.tagged(3,Ct.value.bytes(Kt((BigInt("-1")*e).toString(16))))}},Ei=Uo.SelfDescribeCborSerializer.withDefaultEncoders(!0);Ei.addEncoder(new wi);Ei.addEncoder(new yi);Ei.addEncoder(new bi);var xi;(function(r){r[r.Uint64LittleEndian=71]="Uint64LittleEndian",r[r.Semantic=55799]="Semantic"})(xi||(xi={}));function Ro(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 _i=class extends Oo.default.Decoder{createByteString(e){return ot(...e)}createByteStringFromHeap(e,t){return e===t?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,t))}};function Rt(r){let e=new Uint8Array(r),t=new _i({size:e.byteLength,tags:{2:n=>Ro(n),3:n=>-Ro(n),[xi.Semantic]:n=>n}});try{return t.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${Ke(e)}`)}}function Si(...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 bt=class{constructor(e,t=e?.byteLength||0){this._buffer=Ai(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,t)}get buffer(){return Ai(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 Ii(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}function Ai(r){return r instanceof Uint8Array?Ii(r):r instanceof ArrayBuffer?r:Array.isArray(r)?Ii(new Uint8Array(r)):"buffer"in r?Ai(r.buffer):Ii(new Uint8Array(r))}function Po(){throw new Error("unexpected end of buffer")}function br(r,e){return r.byteLength<e&&Po(),r.read(e)}function Xt(r){let e=r.readUint8();return e===void 0&&Po(),e}function Jt(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 bt(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 Gt(r){let e=BigInt(1),t=BigInt(0),n;do n=Xt(r),t+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return t}function Xe(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 bt(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 Fo(r){let e=new Uint8Array(r.buffer),t=0;for(;t<e.byteLength;t++)if(e[t]<128){if(!(e[t]&64))return Gt(r);break}let n=new Uint8Array(br(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 Mo(r,e){if(BigInt(r)<BigInt(0))throw new Error("Cannot write negative values.");return Ti(r,e)}function Ti(r,e){r=BigInt(r);let t=new bt(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 Bi(r,e){let t=BigInt(Xt(r)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(Xt(r));t=t+n*s}return t}function Lo(r,e){let t=Bi(r,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return t>=n&&(t-=n*BigInt(2)),t}function on(r){let e=BigInt(r);if(r<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}var ko=400;var xr=class{display(){return this.name}valueToString(e){return Qe(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}},Je=class extends xr{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){}},Ni=class extends xr{checkType(e){if(e instanceof _r){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)}},Ri=class extends Je{accept(e,t){return e.visitEmpty(this,t)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return Xe(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},Oi=class extends xr{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: ${Qe(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 _r?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"}},Ui=class extends Je{accept(e,t){return e.visitBool(this,t)}covariant(e){if(typeof e=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return Xe(-2)}decodeValue(e,t){switch(this.checkType(t),Xt(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},Pi=class extends Je{accept(e,t){return e.visitNull(this,t)}covariant(e){if(e===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return Xe(-1)}decodeValue(e,t){return this.checkType(t),null}get name(){return"null"}},Fi=class extends Je{accept(e,t){return e.visitReserved(this,t)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return Xe(-16)}decodeValue(e,t){return t.name!==this.name&&t.decodeValue(e,t),null}get name(){return"reserved"}},Mi=class extends Je{accept(e,t){return e.visitText(this,t)}covariant(e){if(typeof e=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){let t=new TextEncoder().encode(e),n=Jt(t.byteLength);return Si(n,t)}encodeType(){return Xe(-15)}decodeValue(e,t){this.checkType(t);let n=Gt(e),i=br(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}},Li=class extends Je{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: ${Qe(e)}`)}encodeValue(e){return Xe(e)}encodeType(){return Xe(-4)}decodeValue(e,t){return this.checkType(t),Fo(e)}get name(){return"int"}valueToString(e){return e.toString()}},ki=class extends Je{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: ${Qe(e)}`)}encodeValue(e){return Jt(e)}encodeType(){return Xe(-3)}decodeValue(e,t){return this.checkType(t),Gt(e)}get name(){return"nat"}valueToString(e){return e.toString()}},an=class extends Je{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: ${Qe(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 Xe(e)}decodeValue(e,t){this.checkType(t);let n=br(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()}},Qt=class extends Je{constructor(e){super(),this._bits=e}accept(e,t){return e.visitFixedInt(this,t)}covariant(e){let t=on(this._bits-1)*BigInt(-1),n=on(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: ${Qe(e)}`)}encodeValue(e){return Ti(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return Xe(-9-e)}decodeValue(e,t){this.checkType(t);let n=Lo(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}},er=class extends Je{constructor(e){super(),this._bits=e}accept(e,t){return e.visitFixedNat(this,t)}covariant(e){let t=on(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: ${Qe(e)}`)}encodeValue(e){return Mo(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return Xe(-5-e)}decodeValue(e,t){this.checkType(t);let n=Bi(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}};var _r=class r extends Ni{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: ${Qe(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)}};_r._counter=0;function Nu(r){if(Xt(r)!==1)throw new Error("Cannot decode principal");let t=Number(Gt(r));return ve.fromUint8Array(new Uint8Array(br(r,t)))}var Di=class extends Je{accept(e,t){return e.visitPrincipal(this,t)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){let t=e.toUint8Array(),n=Jt(t.byteLength);return Si(new Uint8Array([1]),n,t)}encodeType(){return Xe(-24)}decodeValue(e,t){return this.checkType(t),Nu(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}};function Qe(r){let e=JSON.stringify(r,(t,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>ko?e.substring(0,ko-3)+"...":e}var z0=new Ri,K0=new Fi,W0=new Oi,Z0=new Ui,X0=new Pi,J0=new Mi,Q0=new Li,el=new ki,tl=new an(32),rl=new an(64),nl=new Qt(8),il=new Qt(16),sl=new Qt(32),ol=new Qt(64),al=new er(8),cl=new er(16),ul=new er(32),fl=new er(64),ll=new Di;var Ou=lr(hi());function Er(r){return Is(hr.create().update(new Uint8Array(r)).digest())}var ji={};hs(ji,{aInRange:()=>Ar,abool:()=>un,abytes:()=>ft,bitGet:()=>Hi,bitLen:()=>Et,bitMask:()=>Ot,bitSet:()=>Lu,bytesToHex:()=>_t,bytesToNumberBE:()=>$e,bytesToNumberLE:()=>fn,concatBytes:()=>_e,createHmacDrbg:()=>Co,ensureBytes:()=>lt,equalBytes:()=>Mu,hexToBytes:()=>vr,hexToNumber:()=>Vi,inRange:()=>hn,isBytes:()=>tr,memoized:()=>rr,notImplemented:()=>dn,numberToBytesBE:()=>Ae,numberToBytesLE:()=>ln,numberToHexUnpadded:()=>Gi,numberToVarBytesBE:()=>Fu,utf8ToBytes:()=>Ir,validateObject:()=>vt});var Ci=BigInt(0),cn=BigInt(1),Uu=BigInt(2);function tr(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function ft(r){if(!tr(r))throw new Error("Uint8Array expected")}function un(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var Pu=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function _t(r){ft(r);let e="";for(let t=0;t<r.length;t++)e+=Pu[r[t]];return e}function Gi(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function Vi(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var xt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function qo(r){if(r>=xt._0&&r<=xt._9)return r-xt._0;if(r>=xt._A&&r<=xt._F)return r-(xt._A-10);if(r>=xt._a&&r<=xt._f)return r-(xt._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=qo(r.charCodeAt(s)),u=qo(r.charCodeAt(s+1));if(o===void 0||u===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+u}return n}function $e(r){return Vi(_t(r))}function fn(r){return ft(r),Vi(_t(Uint8Array.from(r).reverse()))}function Ae(r,e){return vr(r.toString(16).padStart(e*2,"0"))}function ln(r,e){return Ae(r,e).reverse()}function Fu(r){return vr(Gi(r))}function lt(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(tr(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 _e(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];ft(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 Mu(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 qi=r=>typeof r=="bigint"&&Ci<=r;function hn(r,e,t){return qi(r)&&qi(e)&&qi(t)&&e<=r&&r<t}function Ar(r,e,t,n){if(!hn(e,t,n))throw new Error(`expected valid ${r}: ${t} <= n < ${n}, got ${typeof e} ${e}`)}function Et(r){let e;for(e=0;r>Ci;r>>=cn,e+=1);return e}function Hi(r,e){return r>>BigInt(e)&cn}function Lu(r,e,t){return r|(t?cn:Ci)<<BigInt(e)}var Ot=r=>(Uu<<BigInt(r-1))-cn,$i=r=>new Uint8Array(r),$o=r=>Uint8Array.from(r);function Co(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=$i(r),i=$i(r),s=0,o=()=>{n.fill(1),i.fill(0),s=0},u=(...y)=>t(i,n,...y),c=(y=$i())=>{i=u($o([0]),y),n=u(),y.length!==0&&(i=u($o([1]),y),n=u())},g=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let y=0,S=[];for(;y<e;){n=u();let U=n.slice();S.push(U),y+=n.length}return _e(...S)};return(y,S)=>{o(),c(y);let U;for(;!(U=S(g()));)c();return o(),U}}var ku={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"||tr(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 vt(r,e,t={}){let n=(i,s,o)=>{let u=ku[s];if(typeof u!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=r[i];if(!(o&&c===void 0)&&!u(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 dn=()=>{throw new Error("not implemented")};function rr(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 ke=BigInt(0),Ee=BigInt(1),Ut=BigInt(2),Du=BigInt(3),Yi=BigInt(4),Go=BigInt(5),Vo=BigInt(8),qu=BigInt(9),$u=BigInt(16);function Ye(r,e){let t=r%e;return t>=ke?t:e+t}function Cu(r,e,t){if(t<=ke||e<ke)throw new Error("Expected power/modulo > 0");if(t===Ee)return ke;let n=Ee;for(;e>ke;)e&Ee&&(n=n*r%t),r=r*r%t,e>>=Ee;return n}function zi(r,e){if(r===ke||e<=ke)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Ye(r,e),n=e,i=ke,s=Ee,o=Ee,u=ke;for(;t!==ke;){let g=n/t,v=n%t,y=i-o*g,S=s-u*g;n=t,t=v,i=o,s=u,o=y,u=S}if(n!==Ee)throw new Error("invert: does not exist");return Ye(i,e)}function Gu(r){let e=(r-Ee)/Ut,t,n,i;for(t=r-Ee,n=0;t%Ut===ke;t/=Ut,n++);for(i=Ut;i<r&&Cu(i,e,r)!==r-Ee;i++);if(n===1){let o=(r+Ee)/Yi;return function(c,g){let v=c.pow(g,o);if(!c.eql(c.sqr(v),g))throw new Error("Cannot find square root");return v}}let s=(t+Ee)/Ut;return function(u,c){if(u.pow(c,e)===u.neg(u.ONE))throw new Error("Cannot find square root");let g=n,v=u.pow(u.mul(u.ONE,i),t),y=u.pow(c,s),S=u.pow(c,t);for(;!u.eql(S,u.ONE);){if(u.eql(S,u.ZERO))return u.ZERO;let U=1;for(let D=u.sqr(S);U<g&&!u.eql(D,u.ONE);U++)D=u.sqr(D);let f=u.pow(v,Ee<<BigInt(g-U-1));v=u.sqr(f),y=u.mul(y,f),S=u.mul(S,v),g=U}return y}}function Vu(r){if(r%Yi===Du){let e=(r+Ee)/Yi;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%Vo===Go){let e=(r-Go)/Vo;return function(n,i){let s=n.mul(i,Ut),o=n.pow(s,e),u=n.mul(i,o),c=n.mul(n.mul(u,Ut),o),g=n.mul(u,n.sub(c,n.ONE));if(!n.eql(n.sqr(g),i))throw new Error("Cannot find square root");return g}}return r%$u,Gu(r)}var Hu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function pn(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Hu.reduce((n,i)=>(n[i]="function",n),e);return vt(r,t)}function Sr(r,e,t){if(t<ke)throw new Error("Expected power > 0");if(t===ke)return r.ONE;if(t===Ee)return e;let n=r.ONE,i=e;for(;t>ke;)t&Ee&&(n=r.mul(n,i)),i=r.sqr(i),t>>=Ee;return n}function Tr(r,e){let t=new Array(e.length),n=e.reduce((s,o,u)=>r.is0(o)?s:(t[u]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return e.reduceRight((s,o,u)=>r.is0(o)?s:(t[u]=r.mul(s,t[u]),r.mul(s,o)),i),t}function Ho(r){let e=(r-Ee)/Ut;return(t,n)=>t.pow(n,e)}function Ki(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function nr(r,e,t=!1,n={}){if(r<=ke)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:i,nByteLength:s}=Ki(r,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=Vu(r),u=Object.freeze({ORDER:r,BITS:i,BYTES:s,MASK:Ot(i),ZERO:ke,ONE:Ee,create:c=>Ye(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ke<=c&&c<r},is0:c=>c===ke,isOdd:c=>(c&Ee)===Ee,neg:c=>Ye(-c,r),eql:(c,g)=>c===g,sqr:c=>Ye(c*c,r),add:(c,g)=>Ye(c+g,r),sub:(c,g)=>Ye(c-g,r),mul:(c,g)=>Ye(c*g,r),pow:(c,g)=>Sr(u,c,g),div:(c,g)=>Ye(c*zi(g,r),r),sqrN:c=>c*c,addN:(c,g)=>c+g,subN:(c,g)=>c-g,mulN:(c,g)=>c*g,inv:c=>zi(c,r),sqrt:n.sqrt||(c=>o(u,c)),invertBatch:c=>Tr(u,c),cmov:(c,g,v)=>v?g:c,toBytes:c=>t?ln(c,s):Ae(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return t?fn(c):$e(c)}});return Object.freeze(u)}function jo(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 mn(r){let e=jo(r);return e+Math.ceil(e/2)}function Wi(r,e,t=!1){let n=r.length,i=jo(e),s=mn(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=t?$e(r):fn(r),u=Ye(o,e-Ee)+Ee;return t?ln(u,i):Ae(u,i)}var ju=$e;function Pt(r,e){if(Br(r),Br(e),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 Yu(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 Br(r){if(!Number.isSafeInteger(r))throw new Error("number expected")}function zu(r,e,t,n){ft(r),ft(e),Br(t),e.length>255&&(e=n(_e(Ir("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(t/i);if(t>65535||o>255)throw new Error("expand_message_xmd: invalid lenInBytes");let u=_e(e,Pt(e.length,1)),c=Pt(0,s),g=Pt(t,2),v=new Array(o),y=n(_e(c,r,g,Pt(0,1),u));v[0]=n(_e(y,Pt(1,1),u));for(let U=1;U<=o;U++){let f=[Yu(y,v[U-1]),Pt(U+1,1),u];v[U]=n(_e(...f))}return _e(...v).slice(0,t)}function Ku(r,e,t,n,i){if(ft(r),ft(e),Br(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(Pt(t,2)).update(e).update(Pt(e.length,1)).digest()}function Yo(r,e,t){vt(t,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:u,DST:c}=t;ft(r),Br(e);let g=typeof c=="string"?Ir(c):c,v=n.toString(2).length,y=Math.ceil((v+i)/8),S=e*s*y,U;if(u==="xmd")U=zu(r,g,S,o);else if(u==="xof")U=Ku(r,g,S,i,o);else if(u==="_internal_pass")U=r;else throw new Error('expand must be "xmd" or "xof"');let f=new Array(e);for(let D=0;D<e;D++){let P=new Array(s);for(let F=0;F<s;F++){let G=y*(F+D*s),K=U.subarray(G,G+y);P[F]=Ye(ju(K),n)}f[D]=P}return f}function Xi(r,e){let t=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,u,c]=t.map(g=>g.reduce((v,y)=>r.add(r.mul(v,n),y)));return n=r.div(s,o),i=r.mul(i,r.div(u,c)),{x:n,y:i}}}function Ji(r,e,t){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=Yo(n,2,{...t,DST:t.DST,...i}),o=r.fromAffine(e(s[0])),u=r.fromAffine(e(s[1])),c=o.add(u).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=Yo(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 Wu=BigInt(0),Qi=BigInt(1),es=new WeakMap,zo=new WeakMap;function Ko(r,e){let t=(s,o)=>{let u=o.negate();return s?u: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,u=2**(s-1);return{windows:o,windowSize:u}};return{constTimeNegate:t,unsafeLadder(s,o){let u=r.ZERO,c=s;for(;o>Wu;)o&Qi&&(u=u.add(c)),c=c.double(),o>>=Qi;return u},precomputeWindow(s,o){let{windows:u,windowSize:c}=i(o),g=[],v=s,y=v;for(let S=0;S<u;S++){y=v,g.push(y);for(let U=1;U<c;U++)y=y.add(v),g.push(y);v=y.double()}return g},wNAF(s,o,u){let{windows:c,windowSize:g}=i(s),v=r.ZERO,y=r.BASE,S=BigInt(2**s-1),U=2**s,f=BigInt(s);for(let D=0;D<c;D++){let P=D*g,F=Number(u&S);u>>=f,F>g&&(F-=U,u+=Qi);let G=P,K=P+Math.abs(F)-1,W=D%2!==0,A=F<0;F===0?y=y.add(t(W,o[G])):v=v.add(t(A,o[K]))}return{p:v,f:y}},wNAFCached(s,o,u){let c=zo.get(s)||1,g=es.get(s);return g||(g=this.precomputeWindow(s,c),c!==1&&es.set(s,u(g))),this.wNAF(c,g,o)},setWindowSize(s,o){n(o),zo.set(s,o),es.delete(s)}}}function Wo(r,e,t,n){if(!Array.isArray(t)||!Array.isArray(n)||n.length!==t.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((v,y)=>{if(!e.isValid(v))throw new Error(`wrong scalar at index ${y}`)}),t.forEach((v,y)=>{if(!(v instanceof r))throw new Error(`wrong point at index ${y}`)});let i=Et(BigInt(t.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<<s)-1,u=new Array(o+1).fill(r.ZERO),c=Math.floor((e.BITS-1)/s)*s,g=r.ZERO;for(let v=c;v>=0;v-=s){u.fill(r.ZERO);for(let S=0;S<n.length;S++){let U=n[S],f=Number(U>>BigInt(v)&BigInt(o));u[f]=u[f].add(t[S])}let y=r.ZERO;for(let S=u.length-1,U=r.ZERO;S>0;S--)U=U.add(u[S]),y=y.add(U);if(g=g.add(y),v!==0)for(let S=0;S<s;S++)g=g.double()}return g}function Zo(r){return pn(r.Fp),vt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ki(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}function Zu(r){let e=Zo(r);vt(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:Cl,hexToBytes:Gl}=ji;var Vt=BigInt(0),Se=BigInt(1),Ft=BigInt(2),gn=BigInt(3),Xo=BigInt(4);function ts(r){let e=Zu(r),{Fp:t}=e,n=nr(e.n,e.nBitLength),i=e.toBytes||((D,P,F)=>{let G=P.toAffine();return _e(Uint8Array.from([4]),t.toBytes(G.x),t.toBytes(G.y))}),s=e.fromBytes||(D=>{let P=D.subarray(1),F=t.fromBytes(P.subarray(0,t.BYTES)),G=t.fromBytes(P.subarray(t.BYTES,2*t.BYTES));return{x:F,y:G}});function o(D){let{a:P,b:F}=e,G=t.sqr(D),K=t.mul(G,D);return t.add(t.add(K,t.mul(D,P)),F)}if(!t.eql(t.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function u(D){return hn(D,Se,e.n)}function c(D){let{allowedPrivateKeyLengths:P,nByteLength:F,wrapPrivateKey:G,n:K}=e;if(P&&typeof D!="bigint"){if(tr(D)&&(D=_t(D)),typeof D!="string"||!P.includes(D.length))throw new Error("Invalid key");D=D.padStart(F*2,"0")}let W;try{W=typeof D=="bigint"?D:$e(lt("private key",D,F))}catch{throw new Error(`private key must be ${F} bytes, hex or bigint, not ${typeof D}`)}return G&&(W=Ye(W,K)),Ar("private key",W,Se,K),W}function g(D){if(!(D instanceof S))throw new Error("ProjectivePoint expected")}let v=rr((D,P)=>{let{px:F,py:G,pz:K}=D;if(t.eql(K,t.ONE))return{x:F,y:G};let W=D.is0();P==null&&(P=W?t.ONE:t.inv(K));let A=t.mul(F,P),$=t.mul(G,P),C=t.mul(K,P);if(W)return{x:t.ZERO,y:t.ZERO};if(!t.eql(C,t.ONE))throw new Error("invZ was invalid");return{x:A,y:$}}),y=rr(D=>{if(D.is0()){if(e.allowInfinityPoint&&!t.is0(D.py))return;throw new Error("bad point: ZERO")}let{x:P,y:F}=D.toAffine();if(!t.isValid(P)||!t.isValid(F))throw new Error("bad point: x or y not FE");let G=t.sqr(F),K=o(P);if(!t.eql(G,K))throw new Error("bad point: equation left != right");if(!D.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class S{constructor(P,F,G){if(this.px=P,this.py=F,this.pz=G,P==null||!t.isValid(P))throw new Error("x required");if(F==null||!t.isValid(F))throw new Error("y required");if(G==null||!t.isValid(G))throw new Error("z required");Object.freeze(this)}static fromAffine(P){let{x:F,y:G}=P||{};if(!P||!t.isValid(F)||!t.isValid(G))throw new Error("invalid affine point");if(P instanceof S)throw new Error("projective point not allowed");let K=W=>t.eql(W,t.ZERO);return K(F)&&K(G)?S.ZERO:new S(F,G,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(P){let F=t.invertBatch(P.map(G=>G.pz));return P.map((G,K)=>G.toAffine(F[K])).map(S.fromAffine)}static fromHex(P){let F=S.fromAffine(s(lt("pointHex",P)));return F.assertValidity(),F}static fromPrivateKey(P){return S.BASE.multiply(c(P))}static msm(P,F){return Wo(S,n,P,F)}_setWindowSize(P){f.setWindowSize(this,P)}assertValidity(){y(this)}hasEvenY(){let{y:P}=this.toAffine();if(t.isOdd)return!t.isOdd(P);throw new Error("Field doesn't support isOdd")}equals(P){g(P);let{px:F,py:G,pz:K}=this,{px:W,py:A,pz:$}=P,C=t.eql(t.mul(F,$),t.mul(W,K)),j=t.eql(t.mul(G,$),t.mul(A,K));return C&&j}negate(){return new S(this.px,t.neg(this.py),this.pz)}double(){let{a:P,b:F}=e,G=t.mul(F,gn),{px:K,py:W,pz:A}=this,$=t.ZERO,C=t.ZERO,j=t.ZERO,M=t.mul(K,K),oe=t.mul(W,W),ee=t.mul(A,A),J=t.mul(K,W);return J=t.add(J,J),j=t.mul(K,A),j=t.add(j,j),$=t.mul(P,j),C=t.mul(G,ee),C=t.add($,C),$=t.sub(oe,C),C=t.add(oe,C),C=t.mul($,C),$=t.mul(J,$),j=t.mul(G,j),ee=t.mul(P,ee),J=t.sub(M,ee),J=t.mul(P,J),J=t.add(J,j),j=t.add(M,M),M=t.add(j,M),M=t.add(M,ee),M=t.mul(M,J),C=t.add(C,M),ee=t.mul(W,A),ee=t.add(ee,ee),M=t.mul(ee,J),$=t.sub($,M),j=t.mul(ee,oe),j=t.add(j,j),j=t.add(j,j),new S($,C,j)}add(P){g(P);let{px:F,py:G,pz:K}=this,{px:W,py:A,pz:$}=P,C=t.ZERO,j=t.ZERO,M=t.ZERO,oe=e.a,ee=t.mul(e.b,gn),J=t.mul(F,W),p=t.mul(G,A),x=t.mul(K,$),O=t.add(F,G),L=t.add(W,A);O=t.mul(O,L),L=t.add(J,p),O=t.sub(O,L),L=t.add(F,K);let Y=t.add(W,$);return L=t.mul(L,Y),Y=t.add(J,x),L=t.sub(L,Y),Y=t.add(G,K),C=t.add(A,$),Y=t.mul(Y,C),C=t.add(p,x),Y=t.sub(Y,C),M=t.mul(oe,L),C=t.mul(ee,x),M=t.add(C,M),C=t.sub(p,M),M=t.add(p,M),j=t.mul(C,M),p=t.add(J,J),p=t.add(p,J),x=t.mul(oe,x),L=t.mul(ee,L),p=t.add(p,x),x=t.sub(J,x),x=t.mul(oe,x),L=t.add(L,x),J=t.mul(p,L),j=t.add(j,J),J=t.mul(Y,L),C=t.mul(O,C),C=t.sub(C,J),J=t.mul(O,p),M=t.mul(Y,M),M=t.add(M,J),new S(C,j,M)}subtract(P){return this.add(P.negate())}is0(){return this.equals(S.ZERO)}wNAF(P){return f.wNAFCached(this,P,S.normalizeZ)}multiplyUnsafe(P){Ar("scalar",P,Vt,e.n);let F=S.ZERO;if(P===Vt)return F;if(P===Se)return this;let{endo:G}=e;if(!G)return f.unsafeLadder(this,P);let{k1neg:K,k1:W,k2neg:A,k2:$}=G.splitScalar(P),C=F,j=F,M=this;for(;W>Vt||$>Vt;)W&Se&&(C=C.add(M)),$&Se&&(j=j.add(M)),M=M.double(),W>>=Se,$>>=Se;return K&&(C=C.negate()),A&&(j=j.negate()),j=new S(t.mul(j.px,G.beta),j.py,j.pz),C.add(j)}multiply(P){let{endo:F,n:G}=e;Ar("scalar",P,Se,G);let K,W;if(F){let{k1neg:A,k1:$,k2neg:C,k2:j}=F.splitScalar(P),{p:M,f:oe}=this.wNAF($),{p:ee,f:J}=this.wNAF(j);M=f.constTimeNegate(A,M),ee=f.constTimeNegate(C,ee),ee=new S(t.mul(ee.px,F.beta),ee.py,ee.pz),K=M.add(ee),W=oe.add(J)}else{let{p:A,f:$}=this.wNAF(P);K=A,W=$}return S.normalizeZ([K,W])[0]}multiplyAndAddUnsafe(P,F,G){let K=S.BASE,W=($,C)=>C===Vt||C===Se||!$.equals(K)?$.multiplyUnsafe(C):$.multiply(C),A=W(this,F).add(W(P,G));return A.is0()?void 0:A}toAffine(P){return v(this,P)}isTorsionFree(){let{h:P,isTorsionFree:F}=e;if(P===Se)return!0;if(F)return F(S,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:P,clearCofactor:F}=e;return P===Se?this:F?F(S,this):this.multiplyUnsafe(e.h)}toRawBytes(P=!0){return un("isCompressed",P),this.assertValidity(),i(S,this,P)}toHex(P=!0){return un("isCompressed",P),_t(this.toRawBytes(P))}}S.BASE=new S(e.Gx,e.Gy,t.ONE),S.ZERO=new S(t.ZERO,t.ONE,t.ZERO);let U=e.nBitLength,f=Ko(S,e.endo?Math.ceil(U/2):U);return{CURVE:e,ProjectivePoint:S,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:u}}function Xu(r,e){let t=r.ORDER,n=Vt;for(let f=t-Se;f%Ft===Vt;f/=Ft)n+=Se;let i=n,s=Ft<<i-Se-Se,o=s*Ft,u=(t-Se)/o,c=(u-Se)/Ft,g=o-Se,v=s,y=r.pow(e,u),S=r.pow(e,(u+Se)/Ft),U=(f,D)=>{let P=y,F=r.pow(D,g),G=r.sqr(F);G=r.mul(G,D);let K=r.mul(f,G);K=r.pow(K,c),K=r.mul(K,F),F=r.mul(K,D),G=r.mul(K,f);let W=r.mul(G,F);K=r.pow(W,v);let A=r.eql(K,r.ONE);F=r.mul(G,S),K=r.mul(W,P),G=r.cmov(F,G,A),W=r.cmov(K,W,A);for(let $=i;$>Se;$--){let C=$-Ft;C=Ft<<C-Se;let j=r.pow(W,C),M=r.eql(j,r.ONE);F=r.mul(G,P),P=r.mul(P,P),j=r.mul(W,P),G=r.cmov(F,G,M),W=r.cmov(j,W,M)}return{isValid:A,value:G}};if(r.ORDER%Xo===gn){let f=(r.ORDER-gn)/Xo,D=r.sqrt(r.neg(e));U=(P,F)=>{let G=r.sqr(F),K=r.mul(P,F);G=r.mul(G,K);let W=r.pow(G,f);W=r.mul(W,K);let A=r.mul(W,D),$=r.mul(r.sqr(W),F),C=r.eql($,P),j=r.cmov(A,W,C);return{isValid:C,value:j}}}return U}function rs(r,e){if(pn(r),!r.isValid(e.A)||!r.isValid(e.B)||!r.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let t=Xu(r,e.Z);if(!r.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,u,c,g,v,y;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),u=r.cmov(e.Z,r.neg(s),!r.eql(s,r.ZERO)),u=r.mul(u,e.A),s=r.sqr(o),g=r.sqr(u),c=r.mul(g,e.A),s=r.add(s,c),s=r.mul(s,o),g=r.mul(g,u),c=r.mul(g,e.B),s=r.add(s,c),v=r.mul(i,o);let{isValid:S,value:U}=t(s,g);y=r.mul(i,n),y=r.mul(y,U),v=r.cmov(v,o,S),y=r.cmov(y,U,S);let f=r.isOdd(n)===r.isOdd(y);return y=r.cmov(r.neg(y),y,f),v=r.div(v,u),{x:v,y}}}var Ju=BigInt(0),wn=BigInt(1),Jo=BigInt(2),ir=BigInt(3);function Qu(r){let e=[];for(;r>wn;r>>=wn)(r&wn)===Ju?e.unshift(0):(r&ir)===ir?(e.unshift(-1),r+=wn):e.unshift(1);return e}function Qo(r){let{Fp:e,Fr:t,Fp2:n,Fp6:i,Fp12:s}=r.fields,o=r.params.xNegative,u=r.params.twistType,c=ts({n:t.ORDER,...r.G1}),g=Object.assign(c,Ji(c.ProjectivePoint,r.G1.mapToCurve,{...r.htfDefaults,...r.G1.htfDefaults})),v=ts({n:t.ORDER,...r.G2}),y=Object.assign(v,Ji(v.ProjectivePoint,r.G2.mapToCurve,{...r.htfDefaults,...r.G2.htfDefaults})),S;if(u==="multiplicative")S=(H,R,d,te,ne,ae)=>s.mul014(te,H,n.mul(R,ne),n.mul(d,ae));else if(u==="divisive")S=(H,R,d,te,ne,ae)=>s.mul034(te,n.mul(d,ae),n.mul(R,ne),H);else throw new Error("bls: unknown twist type");let U=n.div(n.ONE,n.mul(n.ONE,Jo));function f(H,R,d,te){let ne=n.sqr(d),ae=n.sqr(te),z=n.mulByB(n.mul(ae,ir)),a=n.mul(z,ir),l=n.sub(n.sub(n.sqr(n.add(d,te)),ae),ne),h=n.sub(z,ne),I=n.mul(n.sqr(R),ir),b=n.neg(l);return H.push([h,I,b]),R=n.mul(n.mul(n.mul(n.sub(ne,a),R),d),U),d=n.sub(n.sqr(n.mul(n.add(ne,a),U)),n.mul(n.sqr(z),ir)),te=n.mul(ne,l),{Rx:R,Ry:d,Rz:te}}function D(H,R,d,te,ne,ae){let z=n.sub(d,n.mul(ae,te)),a=n.sub(R,n.mul(ne,te)),l=n.sub(n.mul(z,ne),n.mul(a,ae)),h=n.neg(z),I=a;H.push([l,h,I]);let b=n.sqr(a),_=n.mul(b,a),N=n.mul(b,R),m=n.add(n.sub(_,n.mul(N,Jo)),n.mul(n.sqr(z),te));return R=n.mul(a,m),d=n.sub(n.mul(n.sub(N,m),z),n.mul(_,d)),te=n.mul(te,_),{Rx:R,Ry:d,Rz:te}}let P=Qu(r.params.ateLoopSize),F=rr(H=>{let R=H,{x:d,y:te}=R.toAffine(),ne=d,ae=te,z=n.neg(te),a=ne,l=ae,h=n.ONE,I=[];for(let b of P){let _=[];({Rx:a,Ry:l,Rz:h}=f(_,a,l,h)),b&&({Rx:a,Ry:l,Rz:h}=D(_,a,l,h,ne,b===-1?z:ae)),I.push(_)}if(r.postPrecompute){let b=I[I.length-1];r.postPrecompute(a,l,h,ne,ae,D.bind(null,b))}return I});function G(H,R=!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,z,a]of H)for(let[l,h,I]of ae[ne])d=S(l,h,I,d,z,a)}}return o&&(d=s.conjugate(d)),R?s.finalExponentiate(d):d}function K(H,R=!0){let d=[];g.ProjectivePoint.normalizeZ(H.map(({g1:te})=>te)),y.ProjectivePoint.normalizeZ(H.map(({g2:te})=>te));for(let{g1:te,g2:ne}of H){if(te.equals(g.ProjectivePoint.ZERO)||ne.equals(y.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");te.assertValidity(),ne.assertValidity();let ae=te.toAffine();d.push([F(ne),ae.x,ae.y])}return G(d,R)}function W(H,R,d=!0){return K([{g1:H,g2:R}],d)}let A={randomPrivateKey:()=>{let H=mn(t.ORDER);return Wi(r.randomBytes(H),t.ORDER)},calcPairingPrecomputes:F},{ShortSignature:$}=r.G1,{Signature:C}=r.G2;function j(H){return H instanceof g.ProjectivePoint?H:g.ProjectivePoint.fromHex(H)}function M(H,R){return H instanceof g.ProjectivePoint?H:g.hashToCurve(lt("point",H),R)}function oe(H){return H instanceof y.ProjectivePoint?H:C.fromHex(H)}function ee(H,R){return H instanceof y.ProjectivePoint?H:y.hashToCurve(lt("point",H),R)}function J(H){return g.ProjectivePoint.fromPrivateKey(H).toRawBytes(!0)}function p(H){return y.ProjectivePoint.fromPrivateKey(H).toRawBytes(!0)}function x(H,R,d){let te=ee(H,d);te.assertValidity();let ne=te.multiply(g.normPrivateKeyToScalar(R));return H instanceof y.ProjectivePoint?ne:C.toRawBytes(ne)}function O(H,R,d){let te=M(H,d);te.assertValidity();let ne=te.multiply(g.normPrivateKeyToScalar(R));return H instanceof g.ProjectivePoint?ne:$.toRawBytes(ne)}function L(H,R,d,te){let ne=j(d),ae=ee(R,te),z=g.ProjectivePoint.BASE,a=oe(H),l=K([{g1:ne.negate(),g2:ae},{g1:z,g2:a}]);return s.eql(l,s.ONE)}function Y(H,R,d,te){let ne=oe(d),ae=M(R,te),z=y.ProjectivePoint.BASE,a=j(H),l=K([{g1:ae,g2:ne},{g1:a,g2:z.negate()}]);return s.eql(l,s.ONE)}function X(H){if(!H.length)throw new Error("Expected non-empty array");let d=H.map(j).reduce((te,ne)=>te.add(ne),g.ProjectivePoint.ZERO);return H[0]instanceof g.ProjectivePoint?(d.assertValidity(),d):d.toRawBytes(!0)}function se(H){if(!H.length)throw new Error("Expected non-empty array");let d=H.map(oe).reduce((te,ne)=>te.add(ne),y.ProjectivePoint.ZERO);return H[0]instanceof y.ProjectivePoint?(d.assertValidity(),d):C.toRawBytes(d)}function Ue(H){if(!H.length)throw new Error("Expected non-empty array");let d=H.map(j).reduce((te,ne)=>te.add(ne),g.ProjectivePoint.ZERO);return H[0]instanceof g.ProjectivePoint?(d.assertValidity(),d):$.toRawBytes(d)}function Te(H,R,d,te){if(!R.length)throw new Error("Expected non-empty messages array");if(d.length!==R.length)throw new Error("Pubkey count should equal msg count");let ne=oe(H),ae=R.map(h=>ee(h,te)),z=d.map(j),a=new Map;for(let h=0;h<z.length;h++){let I=z[h],b=ae[h],_=a.get(b);_===void 0&&(_=[],a.set(b,_)),_.push(I)}let l=[];try{for(let[h,I]of a){let b=I.reduce((_,N)=>_.add(N));l.push({g1:b,g2:h})}return l.push({g1:g.ProjectivePoint.BASE.negate(),g2:ne}),s.eql(K(l),s.ONE)}catch{return!1}}return g.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:J,getPublicKeyForShortSignatures:p,sign:x,signShortSignature:O,verify:L,verifyBatch:Te,verifyShortSignature:Y,aggregatePublicKeys:X,aggregateSignatures:se,aggregateShortSignatures:Ue,millerLoopBatch:G,pairing:W,pairingBatch:K,G1:g,G2:y,Signature:C,ShortSignature:$,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:A}}var ef=BigInt(0),sr=BigInt(1),It=BigInt(2),ea=BigInt(3);function ns(r,e,t,n,i=1,s){let o=BigInt(s===void 0?n:s),u=t**BigInt(n),c=[];for(let g=0;g<i;g++){let v=BigInt(g+1),y=[];for(let S=0,U=sr;S<n;S++){let f=(v*U-v)/o%u;y.push(r.pow(e,f)),U*=t}c.push(y)}return c}function ta(r,e,t){let n=e.pow(t,(r.ORDER-sr)/ea),i=e.pow(t,(r.ORDER-sr)/It);function s(S,U){let f=e.mul(e.frobeniusMap(S,1),n),D=e.mul(e.frobeniusMap(U,1),i);return[f,D]}let o=e.pow(t,(r.ORDER**It-sr)/ea),u=e.pow(t,(r.ORDER**It-sr)/It);if(!e.eql(u,e.neg(e.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(S,U){return[e.mul(S,o),e.neg(U)]}let g=S=>(U,f)=>{let D=f.toAffine(),P=S(D.x,D.y);return U.fromAffine({x:P[0],y:P[1]})},v=g(s),y=g(c);return{psi:s,psi2:c,G2psi:v,G2psi2:y,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:u}}function ra(r){let{ORDER:e}=r,t=nr(e),n=t.create(r.NONRESIDUE||BigInt(-1)),i=Ho(e),s=t.div(t.ONE,It),o=ns(t,n,t.ORDER,2)[0],u=({c0:p,c1:x},{c0:O,c1:L})=>({c0:t.add(p,O),c1:t.add(x,L)}),c=({c0:p,c1:x},{c0:O,c1:L})=>({c0:t.sub(p,O),c1:t.sub(x,L)}),g=({c0:p,c1:x},O)=>{if(typeof O=="bigint")return{c0:t.mul(p,O),c1:t.mul(x,O)};let{c0:L,c1:Y}=O,X=t.mul(p,L),se=t.mul(x,Y),Ue=t.sub(X,se),Te=t.sub(t.mul(t.add(p,x),t.add(L,Y)),t.add(X,se));return{c0:Ue,c1:Te}},v=({c0:p,c1:x})=>{let O=t.add(p,x),L=t.sub(p,x),Y=t.add(p,p);return{c0:t.mul(O,L),c1:t.mul(Y,x)}},y=p=>{if(p.length!==2)throw new Error("Invalid tuple");let x=p.map(O=>t.create(O));return{c0:x[0],c1:x[1]}},S=e*e,U=y(r.FP2_NONRESIDUE),f={ORDER:S,NONRESIDUE:U,BITS:Et(S),BYTES:Math.ceil(Et(S)/8),MASK:Ot(Et(S)),ZERO:{c0:t.ZERO,c1:t.ZERO},ONE:{c0:t.ONE,c1:t.ZERO},create:p=>p,isValid:({c0:p,c1:x})=>typeof p=="bigint"&&typeof x=="bigint",is0:({c0:p,c1:x})=>t.is0(p)&&t.is0(x),eql:({c0:p,c1:x},{c0:O,c1:L})=>t.eql(p,O)&&t.eql(x,L),neg:({c0:p,c1:x})=>({c0:t.neg(p),c1:t.neg(x)}),pow:(p,x)=>Sr(f,p,x),invertBatch:p=>Tr(f,p),add:u,sub:c,mul:g,sqr:v,addN:u,subN:c,mulN:g,sqrN:v,div:(p,x)=>f.mul(p,typeof x=="bigint"?t.inv(t.create(x)):f.inv(x)),inv:({c0:p,c1:x})=>{let O=t.inv(t.create(p*p+x*x));return{c0:t.mul(O,t.create(p)),c1:t.mul(O,t.create(-x))}},sqrt:p=>{if(r.Fp2sqrt)return r.Fp2sqrt(p);let{c0:x,c1:O}=p;if(t.is0(O))return t.eql(i(t,x),t.ONE)?f.create({c0:t.sqrt(x),c1:t.ZERO}):f.create({c0:t.ZERO,c1:t.sqrt(t.div(x,n))});let L=t.sqrt(t.sub(t.sqr(x),t.mul(t.sqr(O),n))),Y=t.mul(t.add(L,x),s),X=i(t,Y);!t.is0(X)&&!t.eql(X,t.ONE)&&(Y=t.sub(Y,L));let se=t.sqrt(Y),Ue=f.create({c0:se,c1:t.div(t.mul(O,s),se)});if(!f.eql(f.sqr(Ue),p))throw new Error("Cannot find square root");let Te=Ue,H=f.neg(Te),{re:R,im:d}=f.reim(Te),{re:te,im:ne}=f.reim(H);return d>ne||d===ne&&R>te?Te:H},isOdd:p=>{let{re:x,im:O}=f.reim(p),L=x%It,Y=x===ef,X=O%It;return BigInt(L||Y&&X)==sr},fromBytes(p){if(p.length!==f.BYTES)throw new Error(`fromBytes wrong length=${p.length}`);return{c0:t.fromBytes(p.subarray(0,t.BYTES)),c1:t.fromBytes(p.subarray(t.BYTES))}},toBytes:({c0:p,c1:x})=>_e(t.toBytes(p),t.toBytes(x)),cmov:({c0:p,c1:x},{c0:O,c1:L},Y)=>({c0:t.cmov(p,O,Y),c1:t.cmov(x,L,Y)}),reim:({c0:p,c1:x})=>({re:p,im:x}),mulByNonresidue:({c0:p,c1:x})=>f.mul({c0:p,c1:x},U),mulByB:r.Fp2mulByB,fromBigTuple:y,frobeniusMap:({c0:p,c1:x},O)=>({c0:p,c1:t.mul(x,o[O%2])})},D=({c0:p,c1:x,c2:O},{c0:L,c1:Y,c2:X})=>({c0:f.add(p,L),c1:f.add(x,Y),c2:f.add(O,X)}),P=({c0:p,c1:x,c2:O},{c0:L,c1:Y,c2:X})=>({c0:f.sub(p,L),c1:f.sub(x,Y),c2:f.sub(O,X)}),F=({c0:p,c1:x,c2:O},L)=>{if(typeof L=="bigint")return{c0:f.mul(p,L),c1:f.mul(x,L),c2:f.mul(O,L)};let{c0:Y,c1:X,c2:se}=L,Ue=f.mul(p,Y),Te=f.mul(x,X),H=f.mul(O,se);return{c0:f.add(Ue,f.mulByNonresidue(f.sub(f.mul(f.add(x,O),f.add(X,se)),f.add(Te,H)))),c1:f.add(f.sub(f.mul(f.add(p,x),f.add(Y,X)),f.add(Ue,Te)),f.mulByNonresidue(H)),c2:f.sub(f.add(Te,f.mul(f.add(p,O),f.add(Y,se))),f.add(Ue,H))}},G=({c0:p,c1:x,c2:O})=>{let L=f.sqr(p),Y=f.mul(f.mul(p,x),It),X=f.mul(f.mul(x,O),It),se=f.sqr(O);return{c0:f.add(f.mulByNonresidue(X),L),c1:f.add(f.mulByNonresidue(se),Y),c2:f.sub(f.sub(f.add(f.add(Y,f.sqr(f.add(f.sub(p,x),O))),X),L),se)}},[K,W]=ns(f,U,t.ORDER,6,2,3),A={ORDER:f.ORDER,BITS:3*f.BITS,BYTES:3*f.BYTES,MASK:Ot(3*f.BITS),ZERO:{c0:f.ZERO,c1:f.ZERO,c2:f.ZERO},ONE:{c0:f.ONE,c1:f.ZERO,c2:f.ZERO},create:p=>p,isValid:({c0:p,c1:x,c2:O})=>f.isValid(p)&&f.isValid(x)&&f.isValid(O),is0:({c0:p,c1:x,c2:O})=>f.is0(p)&&f.is0(x)&&f.is0(O),neg:({c0:p,c1:x,c2:O})=>({c0:f.neg(p),c1:f.neg(x),c2:f.neg(O)}),eql:({c0:p,c1:x,c2:O},{c0:L,c1:Y,c2:X})=>f.eql(p,L)&&f.eql(x,Y)&&f.eql(O,X),sqrt:dn,div:(p,x)=>A.mul(p,typeof x=="bigint"?t.inv(t.create(x)):A.inv(x)),pow:(p,x)=>Sr(A,p,x),invertBatch:p=>Tr(A,p),add:D,sub:P,mul:F,sqr:G,addN:D,subN:P,mulN:F,sqrN:G,inv:({c0:p,c1:x,c2:O})=>{let L=f.sub(f.sqr(p),f.mulByNonresidue(f.mul(O,x))),Y=f.sub(f.mulByNonresidue(f.sqr(O)),f.mul(p,x)),X=f.sub(f.sqr(x),f.mul(p,O)),se=f.inv(f.add(f.mulByNonresidue(f.add(f.mul(O,Y),f.mul(x,X))),f.mul(p,L)));return{c0:f.mul(se,L),c1:f.mul(se,Y),c2:f.mul(se,X)}},fromBytes:p=>{if(p.length!==A.BYTES)throw new Error(`fromBytes wrong length=${p.length}`);return{c0:f.fromBytes(p.subarray(0,f.BYTES)),c1:f.fromBytes(p.subarray(f.BYTES,2*f.BYTES)),c2:f.fromBytes(p.subarray(2*f.BYTES))}},toBytes:({c0:p,c1:x,c2:O})=>_e(f.toBytes(p),f.toBytes(x),f.toBytes(O)),cmov:({c0:p,c1:x,c2:O},{c0:L,c1:Y,c2:X},se)=>({c0:f.cmov(p,L,se),c1:f.cmov(x,Y,se),c2:f.cmov(O,X,se)}),fromBigSix:p=>{if(!Array.isArray(p)||p.length!==6)throw new Error("Invalid Fp6 usage");return{c0:f.fromBigTuple(p.slice(0,2)),c1:f.fromBigTuple(p.slice(2,4)),c2:f.fromBigTuple(p.slice(4,6))}},frobeniusMap:({c0:p,c1:x,c2:O},L)=>({c0:f.frobeniusMap(p,L),c1:f.mul(f.frobeniusMap(x,L),K[L%6]),c2:f.mul(f.frobeniusMap(O,L),W[L%6])}),mulByFp2:({c0:p,c1:x,c2:O},L)=>({c0:f.mul(p,L),c1:f.mul(x,L),c2:f.mul(O,L)}),mulByNonresidue:({c0:p,c1:x,c2:O})=>({c0:f.mulByNonresidue(O),c1:p,c2:x}),mul1:({c0:p,c1:x,c2:O},L)=>({c0:f.mulByNonresidue(f.mul(O,L)),c1:f.mul(p,L),c2:f.mul(x,L)}),mul01({c0:p,c1:x,c2:O},L,Y){let X=f.mul(p,L),se=f.mul(x,Y);return{c0:f.add(f.mulByNonresidue(f.sub(f.mul(f.add(x,O),Y),se)),X),c1:f.sub(f.sub(f.mul(f.add(L,Y),f.add(p,x)),X),se),c2:f.add(f.sub(f.mul(f.add(p,O),L),X),se)}}},$=ns(f,U,t.ORDER,12,1,6)[0],C=({c0:p,c1:x},{c0:O,c1:L})=>({c0:A.add(p,O),c1:A.add(x,L)}),j=({c0:p,c1:x},{c0:O,c1:L})=>({c0:A.sub(p,O),c1:A.sub(x,L)}),M=({c0:p,c1:x},O)=>{if(typeof O=="bigint")return{c0:A.mul(p,O),c1:A.mul(x,O)};let{c0:L,c1:Y}=O,X=A.mul(p,L),se=A.mul(x,Y);return{c0:A.add(X,A.mulByNonresidue(se)),c1:A.sub(A.mul(A.add(p,x),A.add(L,Y)),A.add(X,se))}},oe=({c0:p,c1:x})=>{let O=A.mul(p,x);return{c0:A.sub(A.sub(A.mul(A.add(A.mulByNonresidue(x),p),A.add(p,x)),O),A.mulByNonresidue(O)),c1:A.add(O,O)}};function ee(p,x){let O=f.sqr(p),L=f.sqr(x);return{first:f.add(f.mulByNonresidue(L),O),second:f.sub(f.sub(f.sqr(f.add(p,x)),O),L)}}let J={ORDER:f.ORDER,BITS:2*f.BITS,BYTES:2*f.BYTES,MASK:Ot(2*f.BITS),ZERO:{c0:A.ZERO,c1:A.ZERO},ONE:{c0:A.ONE,c1:A.ZERO},create:p=>p,isValid:({c0:p,c1:x})=>A.isValid(p)&&A.isValid(x),is0:({c0:p,c1:x})=>A.is0(p)&&A.is0(x),neg:({c0:p,c1:x})=>({c0:A.neg(p),c1:A.neg(x)}),eql:({c0:p,c1:x},{c0:O,c1:L})=>A.eql(p,O)&&A.eql(x,L),sqrt:dn,inv:({c0:p,c1:x})=>{let O=A.inv(A.sub(A.sqr(p),A.mulByNonresidue(A.sqr(x))));return{c0:A.mul(p,O),c1:A.neg(A.mul(x,O))}},div:(p,x)=>J.mul(p,typeof x=="bigint"?t.inv(t.create(x)):J.inv(x)),pow:(p,x)=>Sr(J,p,x),invertBatch:p=>Tr(J,p),add:C,sub:j,mul:M,sqr:oe,addN:C,subN:j,mulN:M,sqrN:oe,fromBytes:p=>{if(p.length!==J.BYTES)throw new Error(`fromBytes wrong length=${p.length}`);return{c0:A.fromBytes(p.subarray(0,A.BYTES)),c1:A.fromBytes(p.subarray(A.BYTES))}},toBytes:({c0:p,c1:x})=>_e(A.toBytes(p),A.toBytes(x)),cmov:({c0:p,c1:x},{c0:O,c1:L},Y)=>({c0:A.cmov(p,O,Y),c1:A.cmov(x,L,Y)}),fromBigTwelve:p=>({c0:A.fromBigSix(p.slice(0,6)),c1:A.fromBigSix(p.slice(6,12))}),frobeniusMap(p,x){let{c0:O,c1:L,c2:Y}=A.frobeniusMap(p.c1,x),X=$[x%12];return{c0:A.frobeniusMap(p.c0,x),c1:A.create({c0:f.mul(O,X),c1:f.mul(L,X),c2:f.mul(Y,X)})}},mulByFp2:({c0:p,c1:x},O)=>({c0:A.mulByFp2(p,O),c1:A.mulByFp2(x,O)}),conjugate:({c0:p,c1:x})=>({c0:p,c1:A.neg(x)}),mul014:({c0:p,c1:x},O,L,Y)=>{let X=A.mul01(p,O,L),se=A.mul1(x,Y);return{c0:A.add(A.mulByNonresidue(se),X),c1:A.sub(A.sub(A.mul01(A.add(x,p),O,f.add(L,Y)),X),se)}},mul034:({c0:p,c1:x},O,L,Y)=>{let X=A.create({c0:f.mul(p.c0,O),c1:f.mul(p.c1,O),c2:f.mul(p.c2,O)}),se=A.mul01(x,L,Y),Ue=A.mul01(A.add(p,x),f.add(O,L),Y);return{c0:A.add(A.mulByNonresidue(se),X),c1:A.sub(Ue,A.add(X,se))}},_cyclotomicSquare:r.Fp12cyclotomicSquare,_cyclotomicExp:r.Fp12cyclotomicExp,finalExponentiate:r.Fp12finalExponentiate};return{Fp:t,Fp2:f,Fp6:A,Fp4Square:ee,Fp12:J}}var Ve=BigInt(0),xn=BigInt(1),De=BigInt(2),yn=BigInt(3),Nr=BigInt(4),Mt=BigInt("0xd201000000010000"),tf=Et(Mt),{Fp:Z,Fp2:Q,Fp6:os,Fp4Square:is,Fp12:ue}=ra({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[xn,xn],Fp2mulByB:({c0:r,c1:e})=>{let t=Z.mul(r,Nr),n=Z.mul(e,Nr);return{c0:Z.sub(t,n),c1:Z.add(t,n)}},Fp12cyclotomicSquare:({c0:r,c1:e})=>{let{c0:t,c1:n,c2:i}=r,{c0:s,c1:o,c2:u}=e,{first:c,second:g}=is(t,o),{first:v,second:y}=is(s,i),{first:S,second:U}=is(n,u),f=Q.mulByNonresidue(U);return{c0:os.create({c0:Q.add(Q.mul(Q.sub(c,t),De),c),c1:Q.add(Q.mul(Q.sub(v,n),De),v),c2:Q.add(Q.mul(Q.sub(S,i),De),S)}),c1:os.create({c0:Q.add(Q.mul(Q.add(f,s),De),f),c1:Q.add(Q.mul(Q.add(g,o),De),g),c2:Q.add(Q.mul(Q.add(y,u),De),y)})}},Fp12cyclotomicExp(r,e){let t=ue.ONE;for(let n=tf-1;n>=0;n--)t=ue._cyclotomicSquare(t),Hi(e,n)&&(t=ue.mul(t,r));return t},Fp12finalExponentiate:r=>{let e=Mt,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)),u=ue.conjugate(ue._cyclotomicExp(o,e)),c=ue.mul(ue.conjugate(ue._cyclotomicExp(u,e)),ue._cyclotomicSquare(i)),g=ue.conjugate(ue._cyclotomicExp(c,e)),v=ue.frobeniusMap(ue.mul(i,u),2),y=ue.frobeniusMap(ue.mul(o,n),3),S=ue.frobeniusMap(ue.mul(c,ue.conjugate(n)),1),U=ue.mul(ue.mul(g,ue.conjugate(s)),n);return ue.mul(ue.mul(ue.mul(v,y),S),U)}}),na=nr(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),rf=Xi(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))))),nf=Xi(Z,[["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)))),sf=rs(Q,{A:Q.create({c0:Z.create(Ve),c1:Z.create(BigInt(240))}),B:Q.create({c0:Z.create(BigInt(1012)),c1:Z.create(BigInt(1012))}),Z:Q.create({c0:Z.create(BigInt(-2)),c1:Z.create(BigInt(-1))})}),of=rs(Z,{A:Z.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:Z.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:Z.create(BigInt(11))}),{G2psi:ia,G2psi2:af}=ta(Z,Q,Q.div(Q.ONE,Q.NONRESIDUE)),ss=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:Z.ORDER,m:2,k:128,expand:"xmd",hash:hr}),_n=Rr(Z.toBytes(Ve),{infinity:!0,compressed:!0});function bn(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 Rr(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 sa(r){r.assertValidity();let e=r.equals(et.G1.ProjectivePoint.ZERO),{x:t,y:n}=r.toAffine();if(e)return _n.slice();let i=Z.ORDER,s=!!(n*De/i);return Rr(Ae(t,Z.BYTES),{compressed:!0,sort:s})}function oa(r){r.assertValidity();let e=Z.BYTES;if(r.equals(et.G2.ProjectivePoint.ZERO))return _e(_n,Ae(Ve,e));let{x:t,y:n}=r.toAffine(),{re:i,im:s}=Q.reim(t),{re:o,im:u}=Q.reim(n),g=!!((u>Ve?u*De:o*De)/Z.ORDER&xn),v=i;return _e(Rr(Ae(s,e),{sort:g,compressed:!0}),Ae(v,e))}var et=Qo({fields:{Fp:Z,Fp2:Q,Fp6:os,Fp12:ue,Fr:na},G1:{Fp:Z,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:Z.ZERO,b:Nr,htfDefaults:{...ss,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(Z.mul(e.px,t),e.py,e.pz);return e.multiplyUnsafe(Mt).negate().multiplyUnsafe(Mt).equals(n)},clearCofactor:(r,e)=>e.multiplyUnsafe(Mt).add(e),mapToCurve:r=>{let{x:e,y:t}=of(Z.create(r[0]));return nf(e,t)},fromBytes:r=>{let{compressed:e,infinity:t,sort:n,value:i}=bn(r);if(i.length===48&&e){let s=Z.ORDER,o=$e(i),u=Z.create(o&Z.MASK);if(t){if(u!==Ve)throw new Error("G1: non-empty compressed point at infinity");return{x:Ve,y:Ve}}let c=Z.add(Z.pow(u,yn),Z.create(et.params.G1b)),g=Z.sqrt(c);if(!g)throw new Error("Invalid compressed G1 point");return g*De/s!==BigInt(n)&&(g=Z.neg(g)),{x:Z.create(u),y:Z.create(g)}}else if(i.length===96&&!e){let s=$e(i.subarray(0,Z.BYTES)),o=$e(i.subarray(Z.BYTES));if(t){if(s!==Ve||o!==Ve)throw new Error("G1: non-empty point at infinity");return et.G1.ProjectivePoint.ZERO.toAffine()}return{x:Z.create(s),y:Z.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 _n.slice();let o=Z.ORDER,u=!!(s*De/o);return Rr(Ae(i,Z.BYTES),{compressed:!0,sort:u})}else return n?_e(new Uint8Array([64]),new Uint8Array(2*Z.BYTES-1)):_e(Ae(i,Z.BYTES),Ae(s,Z.BYTES))},ShortSignature:{fromHex(r){let{infinity:e,sort:t,value:n}=bn(lt("signatureHex",r,48)),i=Z.ORDER,s=$e(n);if(e)return et.G1.ProjectivePoint.ZERO;let o=Z.create(s&Z.MASK),u=Z.add(Z.pow(o,yn),Z.create(et.params.G1b)),c=Z.sqrt(u);if(!c)throw new Error("Invalid compressed G1 point");let g=BigInt(t);c*De/i!==g&&(c=Z.neg(c));let v=et.G1.ProjectivePoint.fromAffine({x:o,y:c});return v.assertValidity(),v},toRawBytes(r){return sa(r)},toHex(r){return _t(sa(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([Nr,Nr]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...ss},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:r=>{let{x:e,y:t}=sf(Q.fromBigTuple(r));return rf(e,t)},isTorsionFree:(r,e)=>e.multiplyUnsafe(Mt).negate().equals(ia(r,e)),clearCofactor:(r,e)=>{let t=Mt,n=e.multiplyUnsafe(t).negate(),i=ia(r,e),s=e.double();return s=af(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}=bn(r);if(!e&&!t&&n||!e&&t&&n||n&&t&&e)throw new Error("Invalid encoding flag: "+(r[0]&224));let s=Z.BYTES,o=(u,c,g)=>$e(u.slice(c,g));if(i.length===96&&e){let u=et.params.G2b,c=Z.ORDER;if(t){if(i.reduce((D,P)=>D!==0?P+1:P,0)>0)throw new Error("Invalid compressed G2 point");return{x:Q.ZERO,y:Q.ZERO}}let g=o(i,0,s),v=o(i,s,2*s),y=Q.create({c0:Z.create(v),c1:Z.create(g)}),S=Q.add(Q.pow(y,yn),u),U=Q.sqrt(S),f=U.c1===Ve?U.c0*De/c:U.c1*De/c?xn:Ve;return U=n&&f>0?U:Q.neg(U),{x:y,y:U}}else if(i.length===192&&!e){if(t){if(i.reduce((y,S)=>y!==0?S+1:S,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:Q.ZERO,y:Q.ZERO}}let u=o(i,0,s),c=o(i,s,2*s),g=o(i,2*s,3*s),v=o(i,3*s,4*s);return{x:Q.fromBigTuple([c,u]),y:Q.fromBigTuple([v,g])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(r,e,t)=>{let{BYTES:n,ORDER:i}=Z,s=e.equals(r.ZERO),{x:o,y:u}=e.toAffine();if(t){if(s)return _e(_n,Ae(Ve,n));let c=!!(u.c1===Ve?u.c0*De/i:u.c1*De/i);return _e(Rr(Ae(o.c1,n),{compressed:!0,sort:c}),Ae(o.c0,n))}else{if(s)return _e(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:g}=Q.reim(o),{re:v,im:y}=Q.reim(u);return _e(Ae(g,n),Ae(c,n),Ae(y,n),Ae(v,n))}},Signature:{fromHex(r){let{infinity:e,sort:t,value:n}=bn(lt("signatureHex",r)),i=Z.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=$e(n.slice(0,s)),u=$e(n.slice(s));if(e)return et.G2.ProjectivePoint.ZERO;let c=Z.create(o&Z.MASK),g=Z.create(u),v=Q.create({c0:g,c1:c}),y=Q.add(Q.pow(v,yn),et.params.G2b),S=Q.sqrt(y);if(!S)throw new Error("Failed to find a square root");let{re:U,im:f}=Q.reim(S),D=BigInt(t),P=f>Ve&&f*De/i!==D,F=f===Ve&&U*De/i!==D;(P||F)&&(S=Q.neg(S));let G=et.G2.ProjectivePoint.fromAffine({x:v,y:S});return G.assertValidity(),G},toRawBytes(r){return oa(r)},toHex(r){return _t(oa(r))}}},params:{ateLoopSize:Mt,r:na.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:ss,hash:hr,randomBytes:ws});function aa(r,e,t){let n=typeof r=="string"?r:Ke(r),i=typeof e=="string"?e:Ke(e),s=typeof t=="string"?t:Ke(t);return et.verifyShortSignature(i,s,n)}var as=r=>Gt(new bt(r)),Or=r=>{let e=as(r);return new Date(Number(e)/1e6)};var hh=new TextEncoder().encode(`
2
+ ic-request`);var ff=lr(sn());var cs;(function(r){r.Call="call"})(cs||(cs={}));var xh=BigInt(1e6),_h=60*1e3;function Ur(r){let e=[];return r.forEach((t,n)=>{e.push([n,t])}),e}var or=class extends We{constructor(e,t){super(e),this.response=t,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};var lf,hf,df,pf;lf=new WeakMap,hf=new WeakMap,df=Symbol.iterator,pf=Symbol.toStringTag;var ua=r=>{if(r<=127)return 1;if(r<=255)return 2;if(r<=65535)return 3;if(r<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},fa=(r,e,t)=>{if(t<=127)return r[e]=t,1;if(t<=255)return r[e]=129,r[e+1]=t,2;if(t<=65535)return r[e]=130,r[e+1]=t>>8,r[e+2]=t,3;if(t<=16777215)return r[e]=131,r[e+1]=t>>16,r[e+2]=t>>8,r[e+3]=t,4;throw new Error("Length too long (> 4 bytes)")},us=(r,e)=>{if(r[e]<128)return 1;if(r[e]===128)throw new Error("Invalid length 0");if(r[e]===129)return 2;if(r[e]===130)return 3;if(r[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")},mf=(r,e)=>{let t=us(r,e);if(t===1)return r[e];if(t===2)return r[e+1];if(t===3)return(r[e+1]<<8)+r[e+2];if(t===4)return(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];throw new Error("Length too long (> 4 bytes)")},Th=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),fs=Uint8Array.from([48,5,6,3,43,101,112]),Bh=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function la(r,e){let t=2+ua(r.byteLength+1),n=e.byteLength+t+r.byteLength,i=0,s=new Uint8Array(1+ua(n)+n);return s[i++]=48,i+=fa(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=fa(s,i,r.byteLength+1),s[i++]=0,s.set(new Uint8Array(r),i),s}var ha=(r,e)=>{let t=0,n=(u,c)=>{if(i[t++]!==u)throw new Error("Expected: "+c)},i=new Uint8Array(r);if(n(48,"sequence"),t+=us(i,t),!dr(i.slice(t,t+e.byteLength),e))throw new Error("Not the expected OID.");t+=e.byteLength,n(3,"bit string");let s=mf(i,t)-1;t+=us(i,t),n(0,"0 padding");let o=i.slice(t);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o};var da=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},pa=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},En,vn,In=class r{constructor(e){if(En.set(this,void 0),vn.set(this,void 0),e.byteLength!==r.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");da(this,En,e,"f"),da(this,vn,r.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new r(e)}static fromDer(e){return new r(this.derDecode(e))}static derEncode(e){return la(e,fs).buffer}static derDecode(e){let t=ha(e,fs);if(t.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return t}get rawKey(){return pa(this,En,"f")}get derKey(){return pa(this,vn,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};En=new WeakMap,vn=new WeakMap;In.RAW_KEY_LENGTH=32;var mt=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},Ce=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},gt,An,Sn,Tn,Bn,Nn,Rn,On,ar;var Un=class r{constructor(e=r.default){gt.set(this,void 0),An.set(this,void 0),Sn.set(this,void 0),Tn.set(this,void 0),Bn.set(this,void 0),Nn.set(this,void 0),Rn.set(this,void 0),On.set(this,void 0),ar.set(this,0);let{initialInterval:t=500,randomizationFactor:n=.5,multiplier:i=1.5,maxInterval:s=6e4,maxElapsedTime:o=9e5,maxIterations:u=10,date:c=Date}=e;mt(this,gt,t,"f"),mt(this,An,n,"f"),mt(this,Sn,i,"f"),mt(this,Tn,s,"f"),mt(this,On,c,"f"),mt(this,Bn,c.now(),"f"),mt(this,Nn,o,"f"),mt(this,Rn,u,"f")}get ellapsedTimeInMsec(){return Ce(this,On,"f").now()-Ce(this,Bn,"f")}get currentInterval(){return Ce(this,gt,"f")}get count(){return Ce(this,ar,"f")}get randomValueFromInterval(){let e=Ce(this,An,"f")*Ce(this,gt,"f"),t=Ce(this,gt,"f")-e,n=Ce(this,gt,"f")+e;return Math.random()*(n-t)+t}incrementCurrentInterval(){var e;return mt(this,gt,Math.min(Ce(this,gt,"f")*Ce(this,Sn,"f"),Ce(this,Tn,"f")),"f"),mt(this,ar,(e=Ce(this,ar,"f"),e++,e),"f"),Ce(this,gt,"f")}next(){return this.ellapsedTimeInMsec>=Ce(this,Nn,"f")||Ce(this,ar,"f")>=Ce(this,Rn,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};gt=new WeakMap,An=new WeakMap,Sn=new WeakMap,Tn=new WeakMap,Bn=new WeakMap,Nn=new WeakMap,Rn=new WeakMap,On=new WeakMap,ar=new WeakMap;Un.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date};var ze=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Pr,wf,ma,ga,yf,bf,xf,_f,Lt,Ef,vf,If,Af,Sf,Tf,wa,Bf,Nf,Rf,ya;(function(r){r.Received="received",r.Processing="processing",r.Replied="replied",r.Rejected="rejected",r.Unknown="unknown",r.Done="done"})(ya||(ya={}));var od=60*1e3;var ba="aaaaa-aa";wf=new WeakMap,ma=new WeakMap,ga=new WeakMap,yf=new WeakMap,bf=new WeakMap,xf=new WeakMap,_f=new WeakMap,Lt=new WeakMap,Ef=new WeakMap,vf=new WeakMap,If=new WeakMap,Af=new WeakMap,Sf=new WeakMap,Tf=new WeakMap,wa=new WeakMap,Rf=new WeakMap,Pr=new WeakSet,Bf=async function r(e){var t,n;let{ecid:i,transformedRequest:s,body:o,requestId:u,backoff:c,tries:g}=e,v=g===0?0:c.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:g,backoff:c,delay:v}),v===null)throw new We(`Timestamp failed to pass the watermark after retrying the configured ${ze(this,Lt,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);v>0&&await new Promise(f=>setTimeout(f,v));let y;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let f=await ze(this,ma,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},ze(this,ga,"f")),s.request),{body:o}));if(f.status===200){let D=Rt(await f.arrayBuffer());y=Object.assign(Object.assign({},D),{httpDetails:{ok:f.ok,status:f.status,statusText:f.statusText,headers:Ur(f.headers)},requestId:u})}else throw new or(`Gateway returned an error:
3
+ Code: ${f.status} (${f.statusText})
4
+ Body: ${await f.text()}
5
+ `,{ok:f.ok,status:f.status,statusText:f.statusText,headers:Ur(f.headers)})}catch(f){if(g<ze(this,Lt,"f"))return this.log.warn(`Caught exception while attempting to make query:
6
+ ${f}
7
+ Retrying query.`),await ze(this,Pr,"m",r).call(this,Object.assign(Object.assign({},e),{tries:g+1}));throw f}let S=(n=(t=y.signatures)===null||t===void 0?void 0:t[0])===null||n===void 0?void 0:n.timestamp;if(!ze(this,wa,"f"))return y;if(!S)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let U=Number(BigInt(S)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:U}),Number(this.waterMark)>U){let f=new We("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",f,{timestamp:S,waterMark:this.waterMark}),g<ze(this,Lt,"f"))return await ze(this,Pr,"m",r).call(this,Object.assign(Object.assign({},e),{tries:g+1}));throw new We(`Timestamp failed to pass the watermark after retrying the configured ${ze(this,Lt,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return y},Nf=async function r(e){let{request:t,backoff:n,tries:i}=e,s=i===0?0:n.next();if(s===null)throw new We(`Timestamp failed to pass the watermark after retrying the configured ${ze(this,Lt,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(g=>setTimeout(g,s));let o;try{o=await t()}catch(g){if(ze(this,Lt,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
8
+ ${g}
9
+ Retrying request.`),await ze(this,Pr,"m",r).call(this,{request:t,backoff:n,tries:i+1});throw g}if(o.ok)return o;let u=await o.clone().text(),c=`Server returned an error:
10
+ Code: ${o.status} (${o.statusText})
11
+ Body: ${u}
12
+ `;if(o.status===404&&o.url.includes("api/v3"))throw new or("v3 api not supported. Fall back to v2",{ok:o.ok,status:o.status,statusText:o.statusText,headers:Ur(o.headers)});if(i<ze(this,Lt,"f"))return await ze(this,Pr,"m",r).call(this,{request:t,backoff:n,tries:i+1});throw new or(c,{ok:o.ok,status:o.status,statusText:o.statusText,headers:Ur(o.headers)})};var xa;(function(r){r.Error="err",r.GetPrincipal="gp",r.GetPrincipalResponse="gpr",r.Query="q",r.QueryResponse="qr",r.Call="c",r.CallResponse="cr",r.ReadState="rs",r.ReadStateResponse="rsr",r.Status="s",r.StatusResponse="sr"})(xa||(xa={}));var At=class extends We{constructor(e){super(`Invalid certificate: ${e}`)}},tt;(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"})(tt||(tt={}));function Of(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 Mn=class r{constructor(e,t,n,i,s=5){this._rootKey=t,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=Rt(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=aa),new r(e.certificate,e.rootKey,e.canisterId,t,e.maxAgeInMinutes)}lookup(e){return Ht(e,this.cert.tree)}lookup_label(e){return this.lookup([e])}async verify(){let e=await Pn(this.cert.tree),t=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=Pf(t),s=ot(Mr("ic-state-root"),e),o=!1,u=Ln(this.lookup(["time"]));if(!u)throw new At("Certificate does not contain a time");let c=5*60*1e3,g=this._maxAgeInMinutes*60*1e3,v=Date.now(),y=v-g,S=v+c,U=Or(u);if(U.getTime()<y)throw new At(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+U.toISOString()+" Current time: "+new Date(v).toISOString());if(U.getTime()>S)throw new At("Certificate is signed more than 5 minutes in the future. Certificate time: "+U.toISOString()+" Current time: "+new Date(v).toISOString());try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new At("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 At("Delegation certificates cannot be nested");if(await t.verify(),this._canisterId.toString()!==ba&&!ls({canisterId:this._canisterId,subnetId:ve.fromUint8Array(new Uint8Array(e.subnet_id)),tree:t.cert.tree}))throw new At(`Canister ${this._canisterId} not in range of delegations for subnet 0x${Ke(e.subnet_id)}`);let n=Ln(t.lookup(["subnet",e.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${Ke(e.subnet_id)}`);return n}},Fr=Kt("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Uf=96;function Pf(r){let e=Fr.byteLength+Uf;if(r.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let t=r.slice(0,Fr.byteLength);if(!dr(t,Fr))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${Fr}, but get ${t}`);return r.slice(Fr.byteLength)}function Ln(r){if(r.status===Ne.Found){if(r.value instanceof ArrayBuffer)return r.value;if(r.value instanceof Uint8Array)return r.value.buffer}}async function Pn(r){switch(r[0]){case tt.Empty:return Er(Mr("ic-hashtree-empty"));case tt.Pruned:return r[1];case tt.Leaf:return Er(ot(Mr("ic-hashtree-leaf"),r[1]));case tt.Labeled:return Er(ot(Mr("ic-hashtree-labeled"),r[1],await Pn(r[2])));case tt.Fork:return Er(ot(Mr("ic-hashtree-fork"),await Pn(r[1]),await Pn(r[2])));default:throw new Error("unreachable")}}function Mr(r){let e=new Uint8Array([r.length]),t=new TextEncoder().encode(r);return ot(e,t)}var Ne;(function(r){r.Unknown="unknown",r.Absent="absent",r.Found="found"})(Ne||(Ne={}));var St;(function(r){r.Less="less",r.Greater="greater"})(St||(St={}));function Ht(r,e){if(r.length===0)switch(e[0]){case tt.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?{status:Ne.Found,value:e[1]}:e[1]instanceof Uint8Array?{status:Ne.Found,value:e[1].buffer}:{status:Ne.Found,value:e[1]}}default:return{status:Ne.Found,value:e}}let t=typeof r[0]=="string"?new TextEncoder().encode(r[0]):r[0],n=Fn(t,e);switch(n.status){case Ne.Found:return Ht(r.slice(1),n.value);case St.Greater:case St.Less:return{status:Ne.Absent};default:return n}}function kn(r){switch(r[0]){case tt.Empty:return[];case tt.Fork:return kn(r[1]).concat(kn(r[2]));default:return[r]}}function Fn(r,e){switch(e[0]){case tt.Labeled:return Of(r,e[1])?{status:St.Greater}:dr(r,e[1])?{status:Ne.Found,value:e[2]}:{status:St.Less};case tt.Fork:let t=Fn(r,e[1]);switch(t.status){case St.Greater:{let n=Fn(r,e[2]);return n.status===St.Less?{status:Ne.Absent}:n}case Ne.Unknown:{let n=Fn(r,e[2]);return n.status===St.Less?{status:Ne.Unknown}:n}default:return t}case tt.Pruned:return{status:Ne.Unknown};default:return{status:Ne.Absent}}}function ls(r){let{canisterId:e,subnetId:t,tree:n}=r,i=Ht(["subnet",t.toUint8Array(),"canister_ranges"],n);if(i.status!==Ne.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${t}`);return Rt(i.value).map(c=>[ve.fromUint8Array(c[0]),ve.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}var _a=class{constructor(e,t,n){this.key=e,this.path=t,this.decodeStrategy=n}},gf=async r=>{let{agent:e,paths:t}=r,n=ve.from(r.canisterId),i=[...new Set(t)],s=i.map(c=>Ea(c,n)),o=new Map,u=i.map((c,g)=>(async()=>{var v;try{let y=await e.readState(n,{paths:[s[g]]}),S=await Mn.create({certificate:y.certificate,rootKey:e.rootKey,canisterId:n}),U=(P,F)=>{if(F==="subnet"){let G=Ff(y.certificate,n,e.rootKey);return{path:F,data:G}}else return{path:F,data:Ln(P.lookup(Ea(F,n)))}},{path:f,data:D}=U(S,i[g]);if(!D)console.warn(`Expected to find result for path ${f}, but instead found nothing.`),typeof f=="string"?o.set(f,null):o.set(f.key,null);else switch(f){case"time":{o.set(f,Or(D));break}case"controllers":{o.set(f,Lf(D));break}case"module_hash":{o.set(f,va(D));break}case"subnet":{o.set(f,D);break}case"candid":{o.set(f,new TextDecoder().decode(D));break}default:if(typeof f!="string"&&"key"in f&&"path"in f)switch(f.decodeStrategy){case"raw":o.set(f.key,D);break;case"leb128":{o.set(f.key,as(D));break}case"cbor":{o.set(f.key,Ia(D));break}case"hex":{o.set(f.key,va(D));break}case"utf-8":o.set(f.key,Mf(D))}}}catch(y){if(!((v=y?.message)===null||v===void 0)&&v.includes("Invalid certificate"))throw new We(y.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(y),console.groupEnd()}})());return await Promise.all(u),o},Ff=(r,e,t)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=Rt(new Uint8Array(r)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=ve.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof t<"u"?(o=ve.selfAuthenticating(new Uint8Array(t)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=ve.selfAuthenticating(ve.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!ls({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=Ht(["subnet",s.subnet_id,"node"],i);if(c.status!==Ne.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let g=kn(c.value),v=new Map;return g.forEach(y=>{let S=ve.from(new Uint8Array(y[1])).toText(),U=Ht(["public_key"],y[2]);if(U.status!==Ne.Found)throw new Error("Public key not found");let f=U.value;if(f.byteLength!==44)throw new Error("Invalid public key length");v.set(S,f)}),{subnetId:ve.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:v}},Ea=(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.`)},va=r=>Ke(r),Ia=r=>Rt(r),Mf=r=>new TextDecoder().decode(r),Lf=r=>Ia(r).map(t=>ve.fromUint8Array(new Uint8Array(t)));export{Ys as a,Ke as b,_a as c,gf as d,Ff as e,Ea as f};
13
+ /*!
14
+ * The buffer module from node.js, for the browser.
15
+ *
16
+ * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
17
+ * @license MIT
18
+ */
19
+ /*! Bundled license information:
20
+
21
+ ieee754/index.js:
22
+ (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
23
+
24
+ @noble/hashes/esm/utils.js:
25
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
26
+
27
+ @noble/curves/esm/abstract/utils.js:
28
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
29
+
30
+ @noble/curves/esm/abstract/modular.js:
31
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
32
+
33
+ @noble/curves/esm/abstract/curve.js:
34
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
35
+
36
+ @noble/curves/esm/abstract/weierstrass.js:
37
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
38
+
39
+ @noble/curves/esm/abstract/bls.js:
40
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
41
+
42
+ @noble/curves/esm/abstract/tower.js:
43
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
44
+
45
+ @noble/curves/esm/bls12-381.js:
46
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
47
+ */
48
+ //# sourceMappingURL=chunk-LVWHOONS.js.map