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