@junobuild/core-standalone 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +67 -22
- package/dist/browser/index.js.map +4 -4
- package/dist/node/index.mjs +119 -55
- package/dist/node/index.mjs.map +4 -4
- package/dist/types/functions/services/functions.services.d.ts +1 -2
- package/dist/workers/auth.worker.js +12 -32
- package/dist/workers/auth.worker.js.map +4 -4
- package/package.json +8 -8
- package/dist/browser/canisterStatus-ENEUF6W6.js +0 -2
- package/dist/browser/canisterStatus-ENEUF6W6.js.map +0 -7
- package/dist/browser/chunk-GGU5IQIJ.js +0 -53
- package/dist/browser/chunk-GGU5IQIJ.js.map +0 -7
|
@@ -1,40 +1,20 @@
|
|
|
1
|
-
"use strict";(()=>{var Lu=Object.create;var gi=Object.defineProperty;var Wu=Object.getOwnPropertyDescriptor;var Du=Object.getOwnPropertyNames;var zu=Object.getPrototypeOf,Yu=Object.prototype.hasOwnProperty;var L=(r,t)=>()=>(r&&(t=r(r=0)),t);var Bt=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Xu=(r,t)=>{for(var e in t)gi(r,e,{get:t[e],enumerable:!0})},Ju=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Du(t))!Yu.call(r,i)&&i!==e&&gi(r,i,{get:()=>t[i],enumerable:!(n=Wu(t,i))||n.enumerable});return r};var Te=(r,t,e)=>(e=r!=null?Lu(zu(r)):{},Ju(t||!r||!r.__esModule?gi(e,"default",{value:r,enumerable:!0}):e,r));var xi=Bt(un=>{"use strict";un.byteLength=Qu;un.toByteArray=ef;un.fromByteArray=sf;var fe=[],ee=[],Zu=typeof Uint8Array<"u"?Uint8Array:Array,mi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(He=0,_o=mi.length;He<_o;++He)fe[He]=mi[He],ee[mi.charCodeAt(He)]=He;var He,_o;ee[45]=62;ee[95]=63;function bo(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");e===-1&&(e=t);var n=e===t?0:4-e%4;return[e,n]}function Qu(r){var t=bo(r),e=t[0],n=t[1];return(e+n)*3/4-n}function tf(r,t,e){return(t+e)*3/4-e}function ef(r){var t,e=bo(r),n=e[0],i=e[1],s=new Zu(tf(r,n,i)),o=0,c=i>0?n-4:n,u;for(u=0;u<c;u+=4)t=ee[r.charCodeAt(u)]<<18|ee[r.charCodeAt(u+1)]<<12|ee[r.charCodeAt(u+2)]<<6|ee[r.charCodeAt(u+3)],s[o++]=t>>16&255,s[o++]=t>>8&255,s[o++]=t&255;return i===2&&(t=ee[r.charCodeAt(u)]<<2|ee[r.charCodeAt(u+1)]>>4,s[o++]=t&255),i===1&&(t=ee[r.charCodeAt(u)]<<10|ee[r.charCodeAt(u+1)]<<4|ee[r.charCodeAt(u+2)]>>2,s[o++]=t>>8&255,s[o++]=t&255),s}function rf(r){return fe[r>>18&63]+fe[r>>12&63]+fe[r>>6&63]+fe[r&63]}function nf(r,t,e){for(var n,i=[],s=t;s<e;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),i.push(rf(n));return i.join("")}function sf(r){for(var t,e=r.length,n=e%3,i=[],s=16383,o=0,c=e-n;o<c;o+=s)i.push(nf(r,o,o+s>c?c:o+s));return n===1?(t=r[e-1],i.push(fe[t>>2]+fe[t<<4&63]+"==")):n===2&&(t=(r[e-2]<<8)+r[e-1],i.push(fe[t>>10]+fe[t>>4&63]+fe[t<<2&63]+"=")),i.join("")}});var fn=Bt(_i=>{_i.read=function(r,t,e,n,i){var s,o,c=i*8-n-1,u=(1<<c)-1,w=u>>1,y=-7,m=e?i-1:0,N=e?-1:1,P=r[t+m];for(m+=N,s=P&(1<<-y)-1,P>>=-y,y+=c;y>0;s=s*256+r[t+m],m+=N,y-=8);for(o=s&(1<<-y)-1,s>>=-y,y+=n;y>0;o=o*256+r[t+m],m+=N,y-=8);if(s===0)s=1-w;else{if(s===u)return o?NaN:(P?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-w}return(P?-1:1)*o*Math.pow(2,s-n)};_i.write=function(r,t,e,n,i,s){var o,c,u,w=s*8-i-1,y=(1<<w)-1,m=y>>1,N=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,P=n?0:s-1,O=n?1:-1,K=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,o=y):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+m>=1?t+=N/u:t+=N*Math.pow(2,1-m),t*u>=2&&(o++,u/=2),o+m>=y?(c=0,o=y):o+m>=1?(c=(t*u-1)*Math.pow(2,i),o=o+m):(c=t*Math.pow(2,m-1)*Math.pow(2,i),o=0));i>=8;r[e+P]=c&255,P+=O,c/=256,i-=8);for(o=o<<i|c,w+=i;w>0;r[e+P]=o&255,P+=O,o/=256,w-=8);r[e+P-O]|=K*128}});var $o=Bt(nr=>{"use strict";var bi=xi(),er=fn(),Eo=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;nr.Buffer=T;nr.SlowBuffer=lf;nr.INSPECT_MAX_BYTES=50;var ln=2147483647;nr.kMaxLength=ln;T.TYPED_ARRAY_SUPPORT=of();!T.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function of(){try{let r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch{return!1}}Object.defineProperty(T.prototype,"parent",{enumerable:!0,get:function(){if(T.isBuffer(this))return this.buffer}});Object.defineProperty(T.prototype,"offset",{enumerable:!0,get:function(){if(T.isBuffer(this))return this.byteOffset}});function xe(r){if(r>ln)throw new RangeError('The value "'+r+'" is invalid for option "size"');let t=new Uint8Array(r);return Object.setPrototypeOf(t,T.prototype),t}function T(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Ti(r)}return So(r,t,e)}T.poolSize=8192;function So(r,t,e){if(typeof r=="string")return cf(r,t);if(ArrayBuffer.isView(r))return uf(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(le(r,ArrayBuffer)||r&&le(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(le(r,SharedArrayBuffer)||r&&le(r.buffer,SharedArrayBuffer)))return vi(r,t,e);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return T.from(n,t,e);let i=ff(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return T.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}T.from=function(r,t,e){return So(r,t,e)};Object.setPrototypeOf(T.prototype,Uint8Array.prototype);Object.setPrototypeOf(T,Uint8Array);function Bo(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function af(r,t,e){return Bo(r),r<=0?xe(r):t!==void 0?typeof e=="string"?xe(r).fill(t,e):xe(r).fill(t):xe(r)}T.alloc=function(r,t,e){return af(r,t,e)};function Ti(r){return Bo(r),xe(r<0?0:Si(r)|0)}T.allocUnsafe=function(r){return Ti(r)};T.allocUnsafeSlow=function(r){return Ti(r)};function cf(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!T.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=Io(r,t)|0,n=xe(e),i=n.write(r,t);return i!==e&&(n=n.slice(0,i)),n}function Ei(r){let t=r.length<0?0:Si(r.length)|0,e=xe(t);for(let n=0;n<t;n+=1)e[n]=r[n]&255;return e}function uf(r){if(le(r,Uint8Array)){let t=new Uint8Array(r);return vi(t.buffer,t.byteOffset,t.byteLength)}return Ei(r)}function vi(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&e===void 0?n=new Uint8Array(r):e===void 0?n=new Uint8Array(r,t):n=new Uint8Array(r,t,e),Object.setPrototypeOf(n,T.prototype),n}function ff(r){if(T.isBuffer(r)){let t=Si(r.length)|0,e=xe(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||Ii(r.length)?xe(0):Ei(r);if(r.type==="Buffer"&&Array.isArray(r.data))return Ei(r.data)}function Si(r){if(r>=ln)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ln.toString(16)+" bytes");return r|0}function lf(r){return+r!=r&&(r=0),T.alloc(+r)}T.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==T.prototype};T.compare=function(t,e){if(le(t,Uint8Array)&&(t=T.from(t,t.offset,t.byteLength)),le(e,Uint8Array)&&(e=T.from(e,e.offset,e.byteLength)),!T.isBuffer(t)||!T.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,i=e.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(t[s]!==e[s]){n=t[s],i=e[s];break}return n<i?-1:i<n?1:0};T.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};T.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return T.alloc(0);let n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;let i=T.allocUnsafe(e),s=0;for(n=0;n<t.length;++n){let o=t[n];if(le(o,Uint8Array))s+o.length>i.length?(T.isBuffer(o)||(o=T.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(T.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function Io(r,t){if(T.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||le(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let e=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&e===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return Ai(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Co(r).length;default:if(i)return n?-1:Ai(r).length;t=(""+t).toLowerCase(),i=!0}}T.byteLength=Io;function hf(r,t,e){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return Ef(this,t,e);case"utf8":case"utf-8":return Ro(this,t,e);case"ascii":return _f(this,t,e);case"latin1":case"binary":return bf(this,t,e);case"base64":return mf(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return vf(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}T.prototype._isBuffer=!0;function je(r,t,e){let n=r[t];r[t]=r[e],r[e]=n}T.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)je(this,e,e+1);return this};T.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)je(this,e,e+3),je(this,e+1,e+2);return this};T.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)je(this,e,e+7),je(this,e+1,e+6),je(this,e+2,e+5),je(this,e+3,e+4);return this};T.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?Ro(this,0,t):hf.apply(this,arguments)};T.prototype.toLocaleString=T.prototype.toString;T.prototype.equals=function(t){if(!T.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:T.compare(this,t)===0};T.prototype.inspect=function(){let t="",e=nr.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};Eo&&(T.prototype[Eo]=T.prototype.inspect);T.prototype.compare=function(t,e,n,i,s){if(le(t,Uint8Array)&&(t=T.from(t,t.offset,t.byteLength)),!T.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),e<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&e>=n)return 0;if(i>=s)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;let o=s-i,c=n-e,u=Math.min(o,c),w=this.slice(i,s),y=t.slice(e,n);for(let m=0;m<u;++m)if(w[m]!==y[m]){o=w[m],c=y[m];break}return o<c?-1:c<o?1:0};function No(r,t,e,n,i){if(r.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Ii(e)&&(e=i?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(i)return-1;e=r.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=T.from(t,n)),T.isBuffer(t))return t.length===0?-1:vo(r,t,e,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):vo(r,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function vo(r,t,e,n,i){let s=1,o=r.length,c=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;s=2,o/=2,c/=2,e/=2}function u(y,m){return s===1?y[m]:y.readUInt16BE(m*s)}let w;if(i){let y=-1;for(w=e;w<o;w++)if(u(r,w)===u(t,y===-1?0:w-y)){if(y===-1&&(y=w),w-y+1===c)return y*s}else y!==-1&&(w-=w-y),y=-1}else for(e+c>o&&(e=o-c),w=e;w>=0;w--){let y=!0;for(let m=0;m<c;m++)if(u(r,w+m)!==u(t,m)){y=!1;break}if(y)return w}return-1}T.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1};T.prototype.indexOf=function(t,e,n){return No(this,t,e,n,!0)};T.prototype.lastIndexOf=function(t,e,n){return No(this,t,e,n,!1)};function df(r,t,e,n){e=Number(e)||0;let i=r.length-e;n?(n=Number(n),n>i&&(n=i)):n=i;let s=t.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let c=parseInt(t.substr(o*2,2),16);if(Ii(c))return o;r[e+o]=c}return o}function pf(r,t,e,n){return hn(Ai(t,r.length-e),r,e,n)}function yf(r,t,e,n){return hn(Bf(t),r,e,n)}function wf(r,t,e,n){return hn(Co(t),r,e,n)}function gf(r,t,e,n){return hn(If(t,r.length-e),r,e,n)}T.prototype.write=function(t,e,n,i){if(e===void 0)i="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")i=e,n=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-e;if((n===void 0||n>s)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return df(this,t,e,n);case"utf8":case"utf-8":return pf(this,t,e,n);case"ascii":case"latin1":case"binary":return yf(this,t,e,n);case"base64":return wf(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return gf(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};T.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function mf(r,t,e){return t===0&&e===r.length?bi.fromByteArray(r):bi.fromByteArray(r.slice(t,e))}function Ro(r,t,e){e=Math.min(r.length,e);let n=[],i=t;for(;i<e;){let s=r[i],o=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=e){let u,w,y,m;switch(c){case 1:s<128&&(o=s);break;case 2:u=r[i+1],(u&192)===128&&(m=(s&31)<<6|u&63,m>127&&(o=m));break;case 3:u=r[i+1],w=r[i+2],(u&192)===128&&(w&192)===128&&(m=(s&15)<<12|(u&63)<<6|w&63,m>2047&&(m<55296||m>57343)&&(o=m));break;case 4:u=r[i+1],w=r[i+2],y=r[i+3],(u&192)===128&&(w&192)===128&&(y&192)===128&&(m=(s&15)<<18|(u&63)<<12|(w&63)<<6|y&63,m>65535&&m<1114112&&(o=m))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=c}return xf(n)}var Ao=4096;function xf(r){let t=r.length;if(t<=Ao)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=Ao));return e}function _f(r,t,e){let n="";e=Math.min(r.length,e);for(let i=t;i<e;++i)n+=String.fromCharCode(r[i]&127);return n}function bf(r,t,e){let n="";e=Math.min(r.length,e);for(let i=t;i<e;++i)n+=String.fromCharCode(r[i]);return n}function Ef(r,t,e){let n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);let i="";for(let s=t;s<e;++s)i+=Nf[r[s]];return i}function vf(r,t,e){let n=r.slice(t,e),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}T.prototype.slice=function(t,e){let n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);let i=this.subarray(t,e);return Object.setPrototypeOf(i,T.prototype),i};function Ot(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}T.prototype.readUintLE=T.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||Ot(t,e,this.length);let i=this[t],s=1,o=0;for(;++o<e&&(s*=256);)i+=this[t+o]*s;return i};T.prototype.readUintBE=T.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||Ot(t,e,this.length);let i=this[t+--e],s=1;for(;e>0&&(s*=256);)i+=this[t+--e]*s;return i};T.prototype.readUint8=T.prototype.readUInt8=function(t,e){return t=t>>>0,e||Ot(t,1,this.length),this[t]};T.prototype.readUint16LE=T.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||Ot(t,2,this.length),this[t]|this[t+1]<<8};T.prototype.readUint16BE=T.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||Ot(t,2,this.length),this[t]<<8|this[t+1]};T.prototype.readUint32LE=T.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||Ot(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};T.prototype.readUint32BE=T.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||Ot(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};T.prototype.readBigUInt64LE=Se(function(t){t=t>>>0,rr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Fr(t,this.length-8);let i=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,s=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});T.prototype.readBigUInt64BE=Se(function(t){t=t>>>0,rr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Fr(t,this.length-8);let i=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],s=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});T.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||Ot(t,e,this.length);let i=this[t],s=1,o=0;for(;++o<e&&(s*=256);)i+=this[t+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*e)),i};T.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||Ot(t,e,this.length);let i=e,s=1,o=this[t+--i];for(;i>0&&(s*=256);)o+=this[t+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*e)),o};T.prototype.readInt8=function(t,e){return t=t>>>0,e||Ot(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};T.prototype.readInt16LE=function(t,e){t=t>>>0,e||Ot(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};T.prototype.readInt16BE=function(t,e){t=t>>>0,e||Ot(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};T.prototype.readInt32LE=function(t,e){return t=t>>>0,e||Ot(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};T.prototype.readInt32BE=function(t,e){return t=t>>>0,e||Ot(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};T.prototype.readBigInt64LE=Se(function(t){t=t>>>0,rr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Fr(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});T.prototype.readBigInt64BE=Se(function(t){t=t>>>0,rr(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&Fr(t,this.length-8);let i=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});T.prototype.readFloatLE=function(t,e){return t=t>>>0,e||Ot(t,4,this.length),er.read(this,t,!0,23,4)};T.prototype.readFloatBE=function(t,e){return t=t>>>0,e||Ot(t,4,this.length),er.read(this,t,!1,23,4)};T.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||Ot(t,8,this.length),er.read(this,t,!0,52,8)};T.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||Ot(t,8,this.length),er.read(this,t,!1,52,8)};function jt(r,t,e,n,i,s){if(!T.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}T.prototype.writeUintLE=T.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;jt(this,t,e,n,c,0)}let s=1,o=0;for(this[e]=t&255;++o<n&&(s*=256);)this[e+o]=t/s&255;return e+n};T.prototype.writeUintBE=T.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;jt(this,t,e,n,c,0)}let s=n-1,o=1;for(this[e+s]=t&255;--s>=0&&(o*=256);)this[e+s]=t/o&255;return e+n};T.prototype.writeUint8=T.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||jt(this,t,e,1,255,0),this[e]=t&255,e+1};T.prototype.writeUint16LE=T.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||jt(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};T.prototype.writeUint16BE=T.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||jt(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};T.prototype.writeUint32LE=T.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||jt(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4};T.prototype.writeUint32BE=T.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||jt(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function Uo(r,t,e,n,i){Mo(t,n,i,r,e,7);let s=Number(t&BigInt(4294967295));r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return r[e++]=o,o=o>>8,r[e++]=o,o=o>>8,r[e++]=o,o=o>>8,r[e++]=o,e}function Fo(r,t,e,n,i){Mo(t,n,i,r,e,7);let s=Number(t&BigInt(4294967295));r[e+7]=s,s=s>>8,r[e+6]=s,s=s>>8,r[e+5]=s,s=s>>8,r[e+4]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return r[e+3]=o,o=o>>8,r[e+2]=o,o=o>>8,r[e+1]=o,o=o>>8,r[e]=o,e+8}T.prototype.writeBigUInt64LE=Se(function(t,e=0){return Uo(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});T.prototype.writeBigUInt64BE=Se(function(t,e=0){return Fo(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});T.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){let u=Math.pow(2,8*n-1);jt(this,t,e,n,u-1,-u)}let s=0,o=1,c=0;for(this[e]=t&255;++s<n&&(o*=256);)t<0&&c===0&&this[e+s-1]!==0&&(c=1),this[e+s]=(t/o>>0)-c&255;return e+n};T.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){let u=Math.pow(2,8*n-1);jt(this,t,e,n,u-1,-u)}let s=n-1,o=1,c=0;for(this[e+s]=t&255;--s>=0&&(o*=256);)t<0&&c===0&&this[e+s+1]!==0&&(c=1),this[e+s]=(t/o>>0)-c&255;return e+n};T.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||jt(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};T.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||jt(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};T.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||jt(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};T.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||jt(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4};T.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||jt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};T.prototype.writeBigInt64LE=Se(function(t,e=0){return Uo(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});T.prototype.writeBigInt64BE=Se(function(t,e=0){return Fo(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Oo(r,t,e,n,i,s){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function ko(r,t,e,n,i){return t=+t,e=e>>>0,i||Oo(r,t,e,4,34028234663852886e22,-34028234663852886e22),er.write(r,t,e,n,23,4),e+4}T.prototype.writeFloatLE=function(t,e,n){return ko(this,t,e,!0,n)};T.prototype.writeFloatBE=function(t,e,n){return ko(this,t,e,!1,n)};function Po(r,t,e,n,i){return t=+t,e=e>>>0,i||Oo(r,t,e,8,17976931348623157e292,-17976931348623157e292),er.write(r,t,e,n,52,8),e+8}T.prototype.writeDoubleLE=function(t,e,n){return Po(this,t,e,!0,n)};T.prototype.writeDoubleBE=function(t,e,n){return Po(this,t,e,!1,n)};T.prototype.copy=function(t,e,n,i){if(!T.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);let s=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),e),s};T.prototype.fill=function(t,e,n,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!T.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let o=t.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(t=o)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let s;if(typeof t=="number")for(s=e;s<n;++s)this[s]=t;else{let o=T.isBuffer(t)?t:T.from(t,i),c=o.length;if(c===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-e;++s)this[s+e]=o[s%c]}return this};var tr={};function Bi(r,t,e){tr[r]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}Bi("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Bi("ERR_INVALID_ARG_TYPE",function(r,t){return`The "${r}" argument must be of type number. Received type ${typeof t}`},TypeError);Bi("ERR_OUT_OF_RANGE",function(r,t,e){let n=`The value of "${r}" is out of range.`,i=e;return Number.isInteger(e)&&Math.abs(e)>2**32?i=To(String(e)):typeof e=="bigint"&&(i=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(i=To(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function To(r){let t="",e=r.length,n=r[0]==="-"?1:0;for(;e>=n+4;e-=3)t=`_${r.slice(e-3,e)}${t}`;return`${r.slice(0,e)}${t}`}function Af(r,t,e){rr(t,"offset"),(r[t]===void 0||r[t+e]===void 0)&&Fr(t,r.length-(e+1))}function Mo(r,t,e,n,i,s){if(r>e||r<t){let o=typeof t=="bigint"?"n":"",c;throw s>3?t===0||t===BigInt(0)?c=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:c=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:c=`>= ${t}${o} and <= ${e}${o}`,new tr.ERR_OUT_OF_RANGE("value",c,r)}Af(n,i,s)}function rr(r,t){if(typeof r!="number")throw new tr.ERR_INVALID_ARG_TYPE(t,"number",r)}function Fr(r,t,e){throw Math.floor(r)!==r?(rr(r,e),new tr.ERR_OUT_OF_RANGE(e||"offset","an integer",r)):t<0?new tr.ERR_BUFFER_OUT_OF_BOUNDS:new tr.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,r)}var Tf=/[^+/0-9A-Za-z-_]/g;function Sf(r){if(r=r.split("=")[0],r=r.trim().replace(Tf,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Ai(r,t){t=t||1/0;let e,n=r.length,i=null,s=[];for(let o=0;o<n;++o){if(e=r.charCodeAt(o),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&s.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;s.push(e)}else if(e<2048){if((t-=2)<0)break;s.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;s.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;s.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return s}function Bf(r){let t=[];for(let e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function If(r,t){let e,n,i,s=[];for(let o=0;o<r.length&&!((t-=2)<0);++o)e=r.charCodeAt(o),n=e>>8,i=e%256,s.push(i),s.push(n);return s}function Co(r){return bi.toByteArray(Sf(r))}function hn(r,t,e,n){let i;for(i=0;i<n&&!(i+e>=t.length||i>=r.length);++i)t[i+e]=r[i];return i}function le(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function Ii(r){return r!==r}var Nf=function(){let r="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){let n=e*16;for(let i=0;i<16;++i)t[n+i]=r[e]+r[i]}return t}();function Se(r){return typeof BigInt>"u"?Rf:r}function Rf(){throw new Error("BigInt not supported")}});var dn,Ni=L(()=>{(function(r){r[r.SysFatal=1]="SysFatal",r[r.SysTransient=2]="SysTransient",r[r.DestinationInvalid=3]="DestinationInvalid",r[r.CanisterReject=4]="CanisterReject",r[r.CanisterError=5]="CanisterError"})(dn||(dn={}))});function Vo(r){let t=0,e=0,n="";function i(s){return t<0?e|=s>>-t:e=s<<t&248,t>3?(t-=8,1):(t<4&&(n+=pn[e>>3],t+=5),0)}for(let s=0;s<r.length;)s+=i(r[s]);return n+(t<0?pn[e>>3]:"")}function qo(r){let t=0,e=0,n=new Uint8Array(r.length*4/3|0),i=0;function s(o){let c=ir[o.toLowerCase()];if(c===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);c<<=3,e|=c>>>t,t+=5,t>=8&&(n[i++]=e,t-=8,t>0?e=c<<5-t&255:e=0)}for(let o of r)s(o);return n.slice(0,i)}var pn,ir,Ho=L(()=>{pn="abcdefghijklmnopqrstuvwxyz234567",ir=Object.create(null);for(let r=0;r<pn.length;r++)ir[pn[r]]=r;ir[0]=ir.o;ir[1]=ir.i});function jo(r){let t=new Uint8Array(r),e=-1;for(let n=0;n<t.length;n++){let s=(t[n]^e)&255;e=Uf[s]^e>>>8}return(e^-1)>>>0}var Uf,Ko=L(()=>{Uf=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117])});function Ff(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Ri(r,...t){if(!Ff(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function Ui(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Go(r,t){Ri(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var Fi=L(()=>{});var Ke,Lo=L(()=>{Ke=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});function Wo(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Oi(r){return typeof r=="string"&&(r=Wo(r)),Ri(r),r}function Or(r){let t=n=>r().update(Oi(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Do(r=32){if(Ke&&typeof Ke.getRandomValues=="function")return Ke.getRandomValues(new Uint8Array(r));if(Ke&&typeof Ke.randomBytes=="function")return Ke.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}var wn,ie,Od,yn,kd,kr=L(()=>{Lo();Fi();wn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),ie=(r,t)=>r<<32-t|r>>>t,Od=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;yn=class{clone(){return this._cloneInto()}},kd={}.toString});function Of(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(e>>i&s),c=Number(e&s),u=n?4:0,w=n?0:4;r.setUint32(t+u,o,n),r.setUint32(t+w,c,n)}var zo,Yo,sr,ki=L(()=>{Fi();kr();zo=(r,t,e)=>r&t^~r&e,Yo=(r,t,e)=>r&t^r&e^t&e,sr=class extends yn{constructor(t,e,n,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=wn(this.buffer)}update(t){Ui(this);let{view:e,buffer:n,blockLen:i}=this;t=Oi(t);let s=t.length;for(let o=0;o<s;){let c=Math.min(i-this.pos,s-o);if(c===i){let u=wn(t);for(;i<=s-o;o+=i)this.process(u,o);continue}n.set(t.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ui(this),Go(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let m=o;m<i;m++)e[m]=0;Of(n,i-8,BigInt(this.length*8),s),this.process(n,0);let c=wn(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let w=u/4,y=this.get();if(w>y.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<w;m++)c.setUint32(4*m,y[m],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:i,finished:s,destroyed:o,pos:c}=this;return t.length=i,t.pos=c,t.finished=s,t.destroyed=o,i%e&&t.buffer.set(n),t}}});var kf,Be,Ie,gn,Pi,Xo,Jo,Mi=L(()=>{ki();kr();kf=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Be=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ie=new Uint32Array(64),gn=class extends sr{constructor(){super(64,32,8,!1),this.A=Be[0]|0,this.B=Be[1]|0,this.C=Be[2]|0,this.D=Be[3]|0,this.E=Be[4]|0,this.F=Be[5]|0,this.G=Be[6]|0,this.H=Be[7]|0}get(){let{A:t,B:e,C:n,D:i,E:s,F:o,G:c,H:u}=this;return[t,e,n,i,s,o,c,u]}set(t,e,n,i,s,o,c,u){this.A=t|0,this.B=e|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=c|0,this.H=u|0}process(t,e){for(let m=0;m<16;m++,e+=4)Ie[m]=t.getUint32(e,!1);for(let m=16;m<64;m++){let N=Ie[m-15],P=Ie[m-2],O=ie(N,7)^ie(N,18)^N>>>3,K=ie(P,17)^ie(P,19)^P>>>10;Ie[m]=K+Ie[m-7]+O+Ie[m-16]|0}let{A:n,B:i,C:s,D:o,E:c,F:u,G:w,H:y}=this;for(let m=0;m<64;m++){let N=ie(c,6)^ie(c,11)^ie(c,25),P=y+N+zo(c,u,w)+kf[m]+Ie[m]|0,K=(ie(n,2)^ie(n,13)^ie(n,22))+Yo(n,i,s)|0;y=w,w=u,u=c,c=o+P|0,o=s,s=i,i=n,n=P+K|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,c=c+this.E|0,u=u+this.F|0,w=w+this.G|0,y=y+this.H|0,this.set(n,i,s,o,c,u,w,y)}roundClean(){Ie.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Pi=class extends gn{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}},Xo=Or(()=>new gn),Jo=Or(()=>new Pi)});function Zo(r){return Jo.create().update(new Uint8Array(r)).digest()}var Qo=L(()=>{Mi()});var mn,Pf,ta,Mf,Cf,$f,vt,Dt=L(()=>{Ho();Ko();Qo();mn="__principal__",Pf=2,ta=4,Mf="aaaaa-aa",Cf=r=>{var t;return new Uint8Array(((t=r.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(e=>parseInt(e,16)))},$f=r=>r.reduce((t,e)=>t+e.toString(16).padStart(2,"0"),""),vt=class r{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([ta]))}static managementCanister(){return this.fromHex(Mf)}static selfAuthenticating(t){let e=Zo(t);return new this(new Uint8Array([...e,Pf]))}static from(t){if(typeof t=="string")return r.fromText(t);if(Object.getPrototypeOf(t)===Uint8Array.prototype)return new r(t);if(typeof t=="object"&&t!==null&&t._isPrincipal===!0)return new r(t._arr);throw new Error(`Impossible to convert ${JSON.stringify(t)} to Principal.`)}static fromHex(t){return new this(Cf(t))}static fromText(t){let e=t;if(t.includes(mn)){let o=JSON.parse(t);mn in o&&(e=o[mn])}let n=e.toLowerCase().replace(/-/g,""),i=qo(n);i=i.slice(4,i.length);let s=new this(i);if(s.toText()!==e)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${e}" may not be a valid Principal ID).`);return s}static fromUint8Array(t){return new this(t)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===ta}toUint8Array(){return this._arr}toHex(){return $f(this._arr).toUpperCase()}toText(){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,jo(this._arr));let n=new Uint8Array(t),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),c=Vo(s).match(/.{1,5}/g);if(!c)throw new Error;return c.join("-")}toString(){return this.toText()}toJSON(){return{[mn]:this.toText()}}compareTo(t){for(let e=0;e<Math.min(this._arr.length,t._arr.length);e++){if(this._arr[e]<t._arr[e])return"lt";if(this._arr[e]>t._arr[e])return"gt"}return this._arr.length<t._arr.length?"lt":this._arr.length>t._arr.length?"gt":"eq"}ltEq(t){let e=this.compareTo(t);return e=="lt"||e=="eq"}gtEq(t){let e=this.compareTo(t);return e=="gt"||e=="eq"}}});function he(...r){let t=new Uint8Array(r.reduce((n,i)=>n+i.byteLength,0)),e=0;for(let n of r)t.set(new Uint8Array(n),e),e+=n.byteLength;return t.buffer}function bt(r){return[...new Uint8Array(r)].map(t=>t.toString(16).padStart(2,"0")).join("")}function Kt(r){if(!Vf.test(r))throw new Error("Invalid hexadecimal string.");let t=[...r].reduce((e,n,i)=>(e[i/2|0]=(e[i/2|0]||"")+n,e),[]).map(e=>Number.parseInt(e,16));return new Uint8Array(t).buffer}function Ci(r,t){if(r.byteLength!==t.byteLength)return r.byteLength-t.byteLength;let e=new Uint8Array(r),n=new Uint8Array(t);for(let i=0;i<e.length;i++)if(e[i]!==n[i])return e[i]-n[i];return 0}function or(r,t){return Ci(r,t)===0}function Ge(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}function xn(r){return r instanceof Uint8Array?Ge(r):r instanceof ArrayBuffer?r:Array.isArray(r)?Ge(new Uint8Array(r)):"buffer"in r?xn(r.buffer):Ge(new Uint8Array(r))}var Vf,Gt=L(()=>{Vf=new RegExp(/^[0-9a-fA-F]+$/)});var zt,ar=L(()=>{Dt();Ni();Gt();zt=class r extends Error{constructor(t){super(t),this.message=t,this.name="AgentError",this.__proto__=r.prototype,Object.setPrototypeOf(this,r.prototype)}}});function Vi(...r){let t=new Uint8Array(r.reduce((n,i)=>n+i.byteLength,0)),e=0;for(let n of r)t.set(new Uint8Array(n),e),e+=n.byteLength;return t}function $i(r){return new DataView(r.buffer,r.byteOffset,r.byteLength).buffer}function Pr(r){return r instanceof Uint8Array?$i(r):r instanceof ArrayBuffer?r:Array.isArray(r)?$i(new Uint8Array(r)):"buffer"in r?Pr(r.buffer):$i(new Uint8Array(r))}var Ne,_n=L(()=>{Ne=class{constructor(t,e=t?.byteLength||0){this._buffer=Pr(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,e)}get buffer(){return Pr(this._view.slice())}get byteLength(){return this._view.byteLength}read(t){let e=this._view.subarray(0,t);return this._view=this._view.subarray(t),e.slice().buffer}readUint8(){let t=this._view[0];return this._view=this._view.subarray(1),t}write(t){let e=new Uint8Array(t),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+e.byteLength>=this._buffer.byteLength?this.alloc(e.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+e.byteLength),this._view.set(e,n)}get end(){return this._view.byteLength===0}alloc(t){let e=new ArrayBuffer((this._buffer.byteLength+t)*1.2|0),n=new Uint8Array(e,0,this._view.byteLength+t);n.set(this._view),this._buffer=e,this._view=n}}});var qi=L(()=>{});function ea(){throw new Error("unexpected end of buffer")}function Mr(r,t){return r.byteLength<t&&ea(),r.read(t)}function cr(r){let t=r.readUint8();return t===void 0&&ea(),t}function Re(r){if(typeof r=="number"&&(r=BigInt(r)),r<BigInt(0))throw new Error("Cannot leb encode negative values.");let t=(r===BigInt(0)?0:Math.ceil(Math.log2(Number(r))))+1,e=new Ne(new ArrayBuffer(t),0);for(;;){let n=Number(r&BigInt(127));if(r/=BigInt(128),r===BigInt(0)){e.write(new Uint8Array([n]));break}else e.write(new Uint8Array([n|128]))}return e.buffer}function ur(r){let t=BigInt(1),e=BigInt(0),n;do n=cr(r),e+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return e}function Yt(r){typeof r=="number"&&(r=BigInt(r));let t=r<BigInt(0);t&&(r=-r-BigInt(1));let e=(r===BigInt(0)?0:Math.ceil(Math.log2(Number(r))))+1,n=new Ne(new ArrayBuffer(e),0);for(;;){let s=i(r);if(r/=BigInt(128),t&&r===BigInt(0)&&(s&64)!==0||!t&&r===BigInt(0)&&(s&64)===0){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let o=s%BigInt(128);return Number(t?BigInt(128)-o-BigInt(1):o)}return n.buffer}function ra(r){let t=new Uint8Array(r.buffer),e=0;for(;e<t.byteLength;e++)if(t[e]<128){if((t[e]&64)===0)return ur(r);break}let n=new Uint8Array(Mr(r,e+1)),i=BigInt(0);for(let s=n.byteLength-1;s>=0;s--)i=i*BigInt(128)+BigInt(128-(n[s]&127)-1);return-i-BigInt(1)}function na(r,t){if(BigInt(r)<BigInt(0))throw new Error("Cannot write negative values.");return Hi(r,t)}function Hi(r,t){r=BigInt(r);let e=new Ne(new ArrayBuffer(Math.min(1,t)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(r%i);for(e.write(new Uint8Array([o]));++n<t;)r<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((r/i-s)%BigInt(256)),e.write(new Uint8Array([o])),i*=BigInt(256);return e.buffer}function ji(r,t){let e=BigInt(cr(r)),n=BigInt(1),i=0;for(;++i<t;){n*=BigInt(256);let s=BigInt(cr(r));e=e+n*s}return e}function ia(r,t){let e=ji(r,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return e>=n&&(e-=n*BigInt(2)),e}var Ki=L(()=>{_n()});function bn(r){let t=BigInt(r);if(r<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}var sa=L(()=>{});function qf(r){if(cr(r)!==1)throw new Error("Cannot decode principal");let e=Number(ur(r));return vt.fromUint8Array(new Uint8Array(Mr(r,e)))}function Jt(r){let t=JSON.stringify(r,(e,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>oa?t.substring(0,oa-3)+"...":t}var oa,Cr,Xt,Gi,Li,Wi,Di,zi,Yi,Xi,Ji,Zi,En,fr,lr,$r,Qi,fp,lp,hp,dp,pp,yp,wp,gp,mp,xp,_p,bp,Ep,vp,Ap,Tp,Sp,Bp,Ip,es=L(()=>{Dt();_n();qi();Ki();sa();oa=400,Cr=class{display(){return this.name}valueToString(t){return Jt(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}},Xt=class extends Cr{checkType(t){if(this.name!==t.name)throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`);return t}_buildTypeTableImpl(t){}},Gi=class extends Cr{checkType(t){if(t instanceof $r){let e=t.getType();if(typeof e>"u")throw new Error("type mismatch with uninitialized type");return e}throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`)}encodeType(t){return t.indexOf(this.name)}},Li=class extends Xt{accept(t,e){return t.visitEmpty(this,e)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${Jt(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return Yt(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},Wi=class extends Cr{checkType(t){throw new Error("Method not implemented for unknown.")}accept(t,e){throw t.visitType(this,e)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${Jt(t)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(t,e){let n=e.decodeValue(t,e);Object(n)!==n&&(n=Object(n));let i;return e instanceof $r?i=()=>e.getType():i=()=>e,Object.defineProperty(n,"type",{value:i,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}},Di=class extends Xt{accept(t,e){return t.visitBool(this,e)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${Jt(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return Yt(-2)}decodeValue(t,e){switch(this.checkType(e),cr(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},zi=class extends Xt{accept(t,e){return t.visitNull(this,e)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${Jt(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return Yt(-1)}decodeValue(t,e){return this.checkType(e),null}get name(){return"null"}},Yi=class extends Xt{accept(t,e){return t.visitReserved(this,e)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return Yt(-16)}decodeValue(t,e){return e.name!==this.name&&e.decodeValue(t,e),null}get name(){return"reserved"}},Xi=class extends Xt{accept(t,e){return t.visitText(this,e)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Jt(t)}`)}encodeValue(t){let e=new TextEncoder().encode(t),n=Re(e.byteLength);return Vi(n,e)}encodeType(){return Yt(-15)}decodeValue(t,e){this.checkType(e);let n=ur(t),i=Mr(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(t){return'"'+t+'"'}},Ji=class extends Xt{accept(t,e){return t.visitInt(this,e)}covariant(t){if(typeof t=="bigint"||Number.isInteger(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${Jt(t)}`)}encodeValue(t){return Yt(t)}encodeType(){return Yt(-4)}decodeValue(t,e){return this.checkType(e),ra(t)}get name(){return"int"}valueToString(t){return t.toString()}},Zi=class extends Xt{accept(t,e){return t.visitNat(this,e)}covariant(t){if(typeof t=="bigint"&&t>=BigInt(0)||Number.isInteger(t)&&t>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${Jt(t)}`)}encodeValue(t){return Re(t)}encodeType(){return Yt(-3)}decodeValue(t,e){return this.checkType(e),ur(t)}get name(){return"nat"}valueToString(t){return t.toString()}},En=class extends Xt{constructor(t){if(super(),this._bits=t,t!==32&&t!==64)throw new Error("not a valid float type")}accept(t,e){return t.visitFloat(this,e)}covariant(t){if(typeof t=="number"||t instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${Jt(t)}`)}encodeValue(t){let e=new ArrayBuffer(this._bits/8),n=new DataView(e);return this._bits===32?n.setFloat32(0,t,!0):n.setFloat64(0,t,!0),e}encodeType(){let t=this._bits===32?-13:-14;return Yt(t)}decodeValue(t,e){this.checkType(e);let n=Mr(t,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(t){return t.toString()}},fr=class extends Xt{constructor(t){super(),this._bits=t}accept(t,e){return t.visitFixedInt(this,e)}covariant(t){let e=bn(this._bits-1)*BigInt(-1),n=bn(this._bits-1)-BigInt(1),i=!1;if(typeof t=="bigint")i=t>=e&&t<=n;else if(Number.isInteger(t)){let s=BigInt(t);i=s>=e&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${Jt(t)}`)}encodeValue(t){return Hi(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return Yt(-9-t)}decodeValue(t,e){this.checkType(e);let n=ia(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}},lr=class extends Xt{constructor(t){super(),this._bits=t}accept(t,e){return t.visitFixedNat(this,e)}covariant(t){let e=bn(this._bits),n=!1;if(typeof t=="bigint"&&t>=BigInt(0)?n=t<e:Number.isInteger(t)&&t>=0?n=BigInt(t)<e:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${Jt(t)}`)}encodeValue(t){return na(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return Yt(-5-t)}decodeValue(t,e){this.checkType(e);let n=ji(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}},$r=class r extends Gi{constructor(){super(...arguments),this._id=r._counter++,this._type=void 0}accept(t,e){if(!this._type)throw Error("Recursive type uninitialized.");return t.visitRec(this,this._type,e)}fill(t){this._type=t}getType(){return this._type}covariant(t){if(this._type&&this._type.covariant(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${Jt(t)}`)}encodeValue(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(t)}_buildTypeTableImpl(t){if(!this._type)throw Error("Recursive type uninitialized.");t.add(this,new Uint8Array([])),this._type.buildTypeTable(t),t.merge(this,this._type.name)}decodeValue(t,e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(t,e)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(t)}};$r._counter=0;Qi=class extends Xt{accept(t,e){return t.visitPrincipal(this,e)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Jt(t)}`)}encodeValue(t){let e=t.toUint8Array(),n=Re(e.byteLength);return Vi(new Uint8Array([1]),n,e)}encodeType(){return Yt(-24)}decodeValue(t,e){return this.checkType(e),qf(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}};fp=new Li,lp=new Yi,hp=new Wi,dp=new Di,pp=new zi,yp=new Xi,wp=new Ji,gp=new Zi,mp=new En(32),xp=new En(64),_p=new fr(8),bp=new fr(16),Ep=new fr(32),vp=new fr(64),Ap=new lr(8),Tp=new lr(16),Sp=new lr(32),Bp=new lr(64),Ip=new Qi});var rs=L(()=>{});var aa=L(()=>{es();Dt();rs()});var ca=L(()=>{});var hr=L(()=>{aa();rs();es();qi();Ki();_n();ca()});var Vr=Bt(pr=>{"use strict";var ns=xi(),dr=fn(),ua=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;pr.Buffer=S;pr.SlowBuffer=Df;pr.INSPECT_MAX_BYTES=50;var vn=2147483647;pr.kMaxLength=vn;S.TYPED_ARRAY_SUPPORT=jf();!S.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function jf(){try{var r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch{return!1}}Object.defineProperty(S.prototype,"parent",{enumerable:!0,get:function(){if(S.isBuffer(this))return this.buffer}});Object.defineProperty(S.prototype,"offset",{enumerable:!0,get:function(){if(S.isBuffer(this))return this.byteOffset}});function _e(r){if(r>vn)throw new RangeError('The value "'+r+'" is invalid for option "size"');var t=new Uint8Array(r);return Object.setPrototypeOf(t,S.prototype),t}function S(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return as(r)}return ha(r,t,e)}S.poolSize=8192;function ha(r,t,e){if(typeof r=="string")return Gf(r,t);if(ArrayBuffer.isView(r))return Lf(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(de(r,ArrayBuffer)||r&&de(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(de(r,SharedArrayBuffer)||r&&de(r.buffer,SharedArrayBuffer)))return ss(r,t,e);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return S.from(n,t,e);var i=Wf(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return S.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}S.from=function(r,t,e){return ha(r,t,e)};Object.setPrototypeOf(S.prototype,Uint8Array.prototype);Object.setPrototypeOf(S,Uint8Array);function da(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function Kf(r,t,e){return da(r),r<=0?_e(r):t!==void 0?typeof e=="string"?_e(r).fill(t,e):_e(r).fill(t):_e(r)}S.alloc=function(r,t,e){return Kf(r,t,e)};function as(r){return da(r),_e(r<0?0:cs(r)|0)}S.allocUnsafe=function(r){return as(r)};S.allocUnsafeSlow=function(r){return as(r)};function Gf(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!S.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=pa(r,t)|0,n=_e(e),i=n.write(r,t);return i!==e&&(n=n.slice(0,i)),n}function is(r){for(var t=r.length<0?0:cs(r.length)|0,e=_e(t),n=0;n<t;n+=1)e[n]=r[n]&255;return e}function Lf(r){if(de(r,Uint8Array)){var t=new Uint8Array(r);return ss(t.buffer,t.byteOffset,t.byteLength)}return is(r)}function ss(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var n;return t===void 0&&e===void 0?n=new Uint8Array(r):e===void 0?n=new Uint8Array(r,t):n=new Uint8Array(r,t,e),Object.setPrototypeOf(n,S.prototype),n}function Wf(r){if(S.isBuffer(r)){var t=cs(r.length)|0,e=_e(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||us(r.length)?_e(0):is(r);if(r.type==="Buffer"&&Array.isArray(r.data))return is(r.data)}function cs(r){if(r>=vn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+vn.toString(16)+" bytes");return r|0}function Df(r){return+r!=r&&(r=0),S.alloc(+r)}S.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==S.prototype};S.compare=function(t,e){if(de(t,Uint8Array)&&(t=S.from(t,t.offset,t.byteLength)),de(e,Uint8Array)&&(e=S.from(e,e.offset,e.byteLength)),!S.isBuffer(t)||!S.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var n=t.length,i=e.length,s=0,o=Math.min(n,i);s<o;++s)if(t[s]!==e[s]){n=t[s],i=e[s];break}return n<i?-1:i<n?1:0};S.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};S.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return S.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var i=S.allocUnsafe(e),s=0;for(n=0;n<t.length;++n){var o=t[n];if(de(o,Uint8Array))s+o.length>i.length?S.from(o).copy(i,s):Uint8Array.prototype.set.call(i,o,s);else if(S.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function pa(r,t){if(S.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||de(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);var e=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&e===0)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return os(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return _a(r).length;default:if(i)return n?-1:os(r).length;t=(""+t).toLowerCase(),i=!0}}S.byteLength=pa;function zf(r,t,e){var n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return il(this,t,e);case"utf8":case"utf-8":return wa(this,t,e);case"ascii":return rl(this,t,e);case"latin1":case"binary":return nl(this,t,e);case"base64":return tl(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return sl(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}S.prototype._isBuffer=!0;function Le(r,t,e){var n=r[t];r[t]=r[e],r[e]=n}S.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)Le(this,e,e+1);return this};S.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)Le(this,e,e+3),Le(this,e+1,e+2);return this};S.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)Le(this,e,e+7),Le(this,e+1,e+6),Le(this,e+2,e+5),Le(this,e+3,e+4);return this};S.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?wa(this,0,t):zf.apply(this,arguments)};S.prototype.toLocaleString=S.prototype.toString;S.prototype.equals=function(t){if(!S.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:S.compare(this,t)===0};S.prototype.inspect=function(){var t="",e=pr.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};ua&&(S.prototype[ua]=S.prototype.inspect);S.prototype.compare=function(t,e,n,i,s){if(de(t,Uint8Array)&&(t=S.from(t,t.offset,t.byteLength)),!S.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),e<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&e>=n)return 0;if(i>=s)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;for(var o=s-i,c=n-e,u=Math.min(o,c),w=this.slice(i,s),y=t.slice(e,n),m=0;m<u;++m)if(w[m]!==y[m]){o=w[m],c=y[m];break}return o<c?-1:c<o?1:0};function ya(r,t,e,n,i){if(r.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,us(e)&&(e=i?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(i)return-1;e=r.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=S.from(t,n)),S.isBuffer(t))return t.length===0?-1:fa(r,t,e,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):fa(r,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function fa(r,t,e,n,i){var s=1,o=r.length,c=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;s=2,o/=2,c/=2,e/=2}function u(P,O){return s===1?P[O]:P.readUInt16BE(O*s)}var w;if(i){var y=-1;for(w=e;w<o;w++)if(u(r,w)===u(t,y===-1?0:w-y)){if(y===-1&&(y=w),w-y+1===c)return y*s}else y!==-1&&(w-=w-y),y=-1}else for(e+c>o&&(e=o-c),w=e;w>=0;w--){for(var m=!0,N=0;N<c;N++)if(u(r,w+N)!==u(t,N)){m=!1;break}if(m)return w}return-1}S.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1};S.prototype.indexOf=function(t,e,n){return ya(this,t,e,n,!0)};S.prototype.lastIndexOf=function(t,e,n){return ya(this,t,e,n,!1)};function Yf(r,t,e,n){e=Number(e)||0;var i=r.length-e;n?(n=Number(n),n>i&&(n=i)):n=i;var s=t.length;n>s/2&&(n=s/2);for(var o=0;o<n;++o){var c=parseInt(t.substr(o*2,2),16);if(us(c))return o;r[e+o]=c}return o}function Xf(r,t,e,n){return An(os(t,r.length-e),r,e,n)}function Jf(r,t,e,n){return An(cl(t),r,e,n)}function Zf(r,t,e,n){return An(_a(t),r,e,n)}function Qf(r,t,e,n){return An(ul(t,r.length-e),r,e,n)}S.prototype.write=function(t,e,n,i){if(e===void 0)i="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")i=e,n=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s=this.length-e;if((n===void 0||n>s)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return Yf(this,t,e,n);case"utf8":case"utf-8":return Xf(this,t,e,n);case"ascii":case"latin1":case"binary":return Jf(this,t,e,n);case"base64":return Zf(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Qf(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};S.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function tl(r,t,e){return t===0&&e===r.length?ns.fromByteArray(r):ns.fromByteArray(r.slice(t,e))}function wa(r,t,e){e=Math.min(r.length,e);for(var n=[],i=t;i<e;){var s=r[i],o=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=e){var u,w,y,m;switch(c){case 1:s<128&&(o=s);break;case 2:u=r[i+1],(u&192)===128&&(m=(s&31)<<6|u&63,m>127&&(o=m));break;case 3:u=r[i+1],w=r[i+2],(u&192)===128&&(w&192)===128&&(m=(s&15)<<12|(u&63)<<6|w&63,m>2047&&(m<55296||m>57343)&&(o=m));break;case 4:u=r[i+1],w=r[i+2],y=r[i+3],(u&192)===128&&(w&192)===128&&(y&192)===128&&(m=(s&15)<<18|(u&63)<<12|(w&63)<<6|y&63,m>65535&&m<1114112&&(o=m))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=c}return el(n)}var la=4096;function el(r){var t=r.length;if(t<=la)return String.fromCharCode.apply(String,r);for(var e="",n=0;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=la));return e}function rl(r,t,e){var n="";e=Math.min(r.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(r[i]&127);return n}function nl(r,t,e){var n="";e=Math.min(r.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(r[i]);return n}function il(r,t,e){var n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);for(var i="",s=t;s<e;++s)i+=fl[r[s]];return i}function sl(r,t,e){for(var n=r.slice(t,e),i="",s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}S.prototype.slice=function(t,e){var n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);var i=this.subarray(t,e);return Object.setPrototypeOf(i,S.prototype),i};function kt(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}S.prototype.readUintLE=S.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||kt(t,e,this.length);for(var i=this[t],s=1,o=0;++o<e&&(s*=256);)i+=this[t+o]*s;return i};S.prototype.readUintBE=S.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||kt(t,e,this.length);for(var i=this[t+--e],s=1;e>0&&(s*=256);)i+=this[t+--e]*s;return i};S.prototype.readUint8=S.prototype.readUInt8=function(t,e){return t=t>>>0,e||kt(t,1,this.length),this[t]};S.prototype.readUint16LE=S.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||kt(t,2,this.length),this[t]|this[t+1]<<8};S.prototype.readUint16BE=S.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||kt(t,2,this.length),this[t]<<8|this[t+1]};S.prototype.readUint32LE=S.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};S.prototype.readUint32BE=S.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};S.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||kt(t,e,this.length);for(var i=this[t],s=1,o=0;++o<e&&(s*=256);)i+=this[t+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*e)),i};S.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||kt(t,e,this.length);for(var i=e,s=1,o=this[t+--i];i>0&&(s*=256);)o+=this[t+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*e)),o};S.prototype.readInt8=function(t,e){return t=t>>>0,e||kt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};S.prototype.readInt16LE=function(t,e){t=t>>>0,e||kt(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};S.prototype.readInt16BE=function(t,e){t=t>>>0,e||kt(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};S.prototype.readInt32LE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};S.prototype.readInt32BE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};S.prototype.readFloatLE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),dr.read(this,t,!0,23,4)};S.prototype.readFloatBE=function(t,e){return t=t>>>0,e||kt(t,4,this.length),dr.read(this,t,!1,23,4)};S.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||kt(t,8,this.length),dr.read(this,t,!0,52,8)};S.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||kt(t,8,this.length),dr.read(this,t,!1,52,8)};function Lt(r,t,e,n,i,s){if(!S.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}S.prototype.writeUintLE=S.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){var s=Math.pow(2,8*n)-1;Lt(this,t,e,n,s,0)}var o=1,c=0;for(this[e]=t&255;++c<n&&(o*=256);)this[e+c]=t/o&255;return e+n};S.prototype.writeUintBE=S.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){var s=Math.pow(2,8*n)-1;Lt(this,t,e,n,s,0)}var o=n-1,c=1;for(this[e+o]=t&255;--o>=0&&(c*=256);)this[e+o]=t/c&255;return e+n};S.prototype.writeUint8=S.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||Lt(this,t,e,1,255,0),this[e]=t&255,e+1};S.prototype.writeUint16LE=S.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||Lt(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};S.prototype.writeUint16BE=S.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||Lt(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};S.prototype.writeUint32LE=S.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||Lt(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4};S.prototype.writeUint32BE=S.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||Lt(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};S.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){var s=Math.pow(2,8*n-1);Lt(this,t,e,n,s-1,-s)}var o=0,c=1,u=0;for(this[e]=t&255;++o<n&&(c*=256);)t<0&&u===0&&this[e+o-1]!==0&&(u=1),this[e+o]=(t/c>>0)-u&255;return e+n};S.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){var s=Math.pow(2,8*n-1);Lt(this,t,e,n,s-1,-s)}var o=n-1,c=1,u=0;for(this[e+o]=t&255;--o>=0&&(c*=256);)t<0&&u===0&&this[e+o+1]!==0&&(u=1),this[e+o]=(t/c>>0)-u&255;return e+n};S.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||Lt(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};S.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||Lt(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};S.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||Lt(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};S.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||Lt(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4};S.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||Lt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function ga(r,t,e,n,i,s){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function ma(r,t,e,n,i){return t=+t,e=e>>>0,i||ga(r,t,e,4,34028234663852886e22,-34028234663852886e22),dr.write(r,t,e,n,23,4),e+4}S.prototype.writeFloatLE=function(t,e,n){return ma(this,t,e,!0,n)};S.prototype.writeFloatBE=function(t,e,n){return ma(this,t,e,!1,n)};function xa(r,t,e,n,i){return t=+t,e=e>>>0,i||ga(r,t,e,8,17976931348623157e292,-17976931348623157e292),dr.write(r,t,e,n,52,8),e+8}S.prototype.writeDoubleLE=function(t,e,n){return xa(this,t,e,!0,n)};S.prototype.writeDoubleBE=function(t,e,n){return xa(this,t,e,!1,n)};S.prototype.copy=function(t,e,n,i){if(!S.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);var s=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),e),s};S.prototype.fill=function(t,e,n,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!S.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){var s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);var o;if(typeof t=="number")for(o=e;o<n;++o)this[o]=t;else{var c=S.isBuffer(t)?t:S.from(t,i),u=c.length;if(u===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-e;++o)this[o+e]=c[o%u]}return this};var ol=/[^+/0-9A-Za-z-_]/g;function al(r){if(r=r.split("=")[0],r=r.trim().replace(ol,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function os(r,t){t=t||1/0;for(var e,n=r.length,i=null,s=[],o=0;o<n;++o){if(e=r.charCodeAt(o),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&s.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;s.push(e)}else if(e<2048){if((t-=2)<0)break;s.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;s.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;s.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return s}function cl(r){for(var t=[],e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function ul(r,t){for(var e,n,i,s=[],o=0;o<r.length&&!((t-=2)<0);++o)e=r.charCodeAt(o),n=e>>8,i=e%256,s.push(i),s.push(n);return s}function _a(r){return ns.toByteArray(al(r))}function An(r,t,e,n){for(var i=0;i<n&&!(i+e>=t.length||i>=r.length);++i)t[i+e]=r[i];return i}function de(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function us(r){return r!==r}var fl=function(){for(var r="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var n=e*16,i=0;i<16;++i)t[n+i]=r[e]+r[i];return t}()});var qr=Bt((ba,Tn)=>{(function(r){"use strict";var t,e=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",c=1e14,u=14,w=9007199254740991,y=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],m=1e7,N=1e9;function P(V){var q,nt,Z,R=B.prototype={constructor:B,toString:null,valueOf:null},ot=new B(1),et=20,st=4,wt=-7,It=21,Ct=-1e7,j=1e7,U=!1,k=1,G=0,Y={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},z="0123456789abcdefghijklmnopqrstuvwxyz",it=!0;function B(a,f){var l,b,g,_,A,d,x,v,E=this;if(!(E instanceof B))return new B(a,f);if(f==null){if(a&&a._isBigNumber===!0){E.s=a.s,!a.c||a.e>j?E.c=E.e=null:a.e<Ct?E.c=[E.e=0]:(E.e=a.e,E.c=a.c.slice());return}if((d=typeof a=="number")&&a*0==0){if(E.s=1/a<0?(a=-a,-1):1,a===~~a){for(_=0,A=a;A>=10;A/=10,_++);_>j?E.c=E.e=null:(E.e=_,E.c=[a]);return}v=String(a)}else{if(!e.test(v=String(a)))return Z(E,v,d);E.s=v.charCodeAt(0)==45?(v=v.slice(1),-1):1}(_=v.indexOf("."))>-1&&(v=v.replace(".","")),(A=v.search(/e/i))>0?(_<0&&(_=A),_+=+v.slice(A+1),v=v.substring(0,A)):_<0&&(_=v.length)}else{if(D(f,2,z.length,"Base"),f==10&&it)return E=new B(a),ut(E,et+E.e+1,st);if(v=String(a),d=typeof a=="number"){if(a*0!=0)return Z(E,v,d,f);if(E.s=1/a<0?(v=v.slice(1),-1):1,B.DEBUG&&v.replace(/^0\.0*|\./,"").length>15)throw Error(o+a)}else E.s=v.charCodeAt(0)===45?(v=v.slice(1),-1):1;for(l=z.slice(0,f),_=A=0,x=v.length;A<x;A++)if(l.indexOf(b=v.charAt(A))<0){if(b=="."){if(A>_){_=x;continue}}else if(!g&&(v==v.toUpperCase()&&(v=v.toLowerCase())||v==v.toLowerCase()&&(v=v.toUpperCase()))){g=!0,A=-1,_=0;continue}return Z(E,String(a),d,f)}d=!1,v=nt(v,f,10,E.s),(_=v.indexOf("."))>-1?v=v.replace(".",""):_=v.length}for(A=0;v.charCodeAt(A)===48;A++);for(x=v.length;v.charCodeAt(--x)===48;);if(v=v.slice(A,++x)){if(x-=A,d&&B.DEBUG&&x>15&&(a>w||a!==i(a)))throw Error(o+E.s*a);if((_=_-A-1)>j)E.c=E.e=null;else if(_<Ct)E.c=[E.e=0];else{if(E.e=_,E.c=[],A=(_+1)%u,_<0&&(A+=u),A<x){for(A&&E.c.push(+v.slice(0,A)),x-=u;A<x;)E.c.push(+v.slice(A,A+=u));A=u-(v=v.slice(A)).length}else A-=x;for(;A--;v+="0");E.c.push(+v)}}else E.c=[E.e=0]}B.clone=P,B.ROUND_UP=0,B.ROUND_DOWN=1,B.ROUND_CEIL=2,B.ROUND_FLOOR=3,B.ROUND_HALF_UP=4,B.ROUND_HALF_DOWN=5,B.ROUND_HALF_EVEN=6,B.ROUND_HALF_CEIL=7,B.ROUND_HALF_FLOOR=8,B.EUCLID=9,B.config=B.set=function(a){var f,l;if(a!=null)if(typeof a=="object"){if(a.hasOwnProperty(f="DECIMAL_PLACES")&&(l=a[f],D(l,0,N,f),et=l),a.hasOwnProperty(f="ROUNDING_MODE")&&(l=a[f],D(l,0,8,f),st=l),a.hasOwnProperty(f="EXPONENTIAL_AT")&&(l=a[f],l&&l.pop?(D(l[0],-N,0,f),D(l[1],0,N,f),wt=l[0],It=l[1]):(D(l,-N,N,f),wt=-(It=l<0?-l:l))),a.hasOwnProperty(f="RANGE"))if(l=a[f],l&&l.pop)D(l[0],-N,-1,f),D(l[1],1,N,f),Ct=l[0],j=l[1];else if(D(l,-N,N,f),l)Ct=-(j=l<0?-l:l);else throw Error(s+f+" cannot be zero: "+l);if(a.hasOwnProperty(f="CRYPTO"))if(l=a[f],l===!!l)if(l)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))U=l;else throw U=!l,Error(s+"crypto unavailable");else U=l;else throw Error(s+f+" not true or false: "+l);if(a.hasOwnProperty(f="MODULO_MODE")&&(l=a[f],D(l,0,9,f),k=l),a.hasOwnProperty(f="POW_PRECISION")&&(l=a[f],D(l,0,N,f),G=l),a.hasOwnProperty(f="FORMAT"))if(l=a[f],typeof l=="object")Y=l;else throw Error(s+f+" not an object: "+l);if(a.hasOwnProperty(f="ALPHABET"))if(l=a[f],typeof l=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(l))it=l.slice(0,10)=="0123456789",z=l;else throw Error(s+f+" invalid: "+l)}else throw Error(s+"Object expected: "+a);return{DECIMAL_PLACES:et,ROUNDING_MODE:st,EXPONENTIAL_AT:[wt,It],RANGE:[Ct,j],CRYPTO:U,MODULO_MODE:k,POW_PRECISION:G,FORMAT:Y,ALPHABET:z}},B.isBigNumber=function(a){if(!a||a._isBigNumber!==!0)return!1;if(!B.DEBUG)return!0;var f,l,b=a.c,g=a.e,_=a.s;t:if({}.toString.call(b)=="[object Array]"){if((_===1||_===-1)&&g>=-N&&g<=N&&g===i(g)){if(b[0]===0){if(g===0&&b.length===1)return!0;break t}if(f=(g+1)%u,f<1&&(f+=u),String(b[0]).length==f){for(f=0;f<b.length;f++)if(l=b[f],l<0||l>=c||l!==i(l))break t;if(l!==0)return!0}}}else if(b===null&&g===null&&(_===null||_===1||_===-1))return!0;throw Error(s+"Invalid BigNumber: "+a)},B.maximum=B.max=function(){return ct(arguments,-1)},B.minimum=B.min=function(){return ct(arguments,1)},B.random=function(){var a=9007199254740992,f=Math.random()*a&2097151?function(){return i(Math.random()*a)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(l){var b,g,_,A,d,x=0,v=[],E=new B(ot);if(l==null?l=et:D(l,0,N),A=n(l/u),U)if(crypto.getRandomValues){for(b=crypto.getRandomValues(new Uint32Array(A*=2));x<A;)d=b[x]*131072+(b[x+1]>>>11),d>=9e15?(g=crypto.getRandomValues(new Uint32Array(2)),b[x]=g[0],b[x+1]=g[1]):(v.push(d%1e14),x+=2);x=A/2}else if(crypto.randomBytes){for(b=crypto.randomBytes(A*=7);x<A;)d=(b[x]&31)*281474976710656+b[x+1]*1099511627776+b[x+2]*4294967296+b[x+3]*16777216+(b[x+4]<<16)+(b[x+5]<<8)+b[x+6],d>=9e15?crypto.randomBytes(7).copy(b,x):(v.push(d%1e14),x+=7);x=A/7}else throw U=!1,Error(s+"crypto unavailable");if(!U)for(;x<A;)d=f(),d<9e15&&(v[x++]=d%1e14);for(A=v[--x],l%=u,A&&l&&(d=y[u-l],v[x]=i(A/d)*d);v[x]===0;v.pop(),x--);if(x<0)v=[_=0];else{for(_=-1;v[0]===0;v.splice(0,1),_-=u);for(x=1,d=v[0];d>=10;d/=10,x++);x<u&&(_-=u-x)}return E.e=_,E.c=v,E}}(),B.sum=function(){for(var a=1,f=arguments,l=new B(f[0]);a<f.length;)l=l.plus(f[a++]);return l},nt=function(){var a="0123456789";function f(l,b,g,_){for(var A,d=[0],x,v=0,E=l.length;v<E;){for(x=d.length;x--;d[x]*=b);for(d[0]+=_.indexOf(l.charAt(v++)),A=0;A<d.length;A++)d[A]>g-1&&(d[A+1]==null&&(d[A+1]=0),d[A+1]+=d[A]/g|0,d[A]%=g)}return d.reverse()}return function(l,b,g,_,A){var d,x,v,E,I,F,$,J,dt=l.indexOf("."),mt=et,X=st;for(dt>=0&&(E=G,G=0,l=l.replace(".",""),J=new B(b),F=J.pow(l.length-dt),G=E,J.c=f(lt(K(F.c),F.e,"0"),10,g,a),J.e=J.c.length),$=f(l,b,g,A?(d=z,a):(d=a,z)),v=E=$.length;$[--E]==0;$.pop());if(!$[0])return d.charAt(0);if(dt<0?--v:(F.c=$,F.e=v,F.s=_,F=q(F,J,mt,X,g),$=F.c,I=F.r,v=F.e),x=v+mt+1,dt=$[x],E=g/2,I=I||x<0||$[x+1]!=null,I=X<4?(dt!=null||I)&&(X==0||X==(F.s<0?3:2)):dt>E||dt==E&&(X==4||I||X==6&&$[x-1]&1||X==(F.s<0?8:7)),x<1||!$[0])l=I?lt(d.charAt(1),-mt,d.charAt(0)):d.charAt(0);else{if($.length=x,I)for(--g;++$[--x]>g;)$[x]=0,x||(++v,$=[1].concat($));for(E=$.length;!$[--E];);for(dt=0,l="";dt<=E;l+=d.charAt($[dt++]));l=lt(l,v,d.charAt(0))}return l}}(),q=function(){function a(b,g,_){var A,d,x,v,E=0,I=b.length,F=g%m,$=g/m|0;for(b=b.slice();I--;)x=b[I]%m,v=b[I]/m|0,A=$*x+v*F,d=F*x+A%m*m+E,E=(d/_|0)+(A/m|0)+$*v,b[I]=d%_;return E&&(b=[E].concat(b)),b}function f(b,g,_,A){var d,x;if(_!=A)x=_>A?1:-1;else for(d=x=0;d<_;d++)if(b[d]!=g[d]){x=b[d]>g[d]?1:-1;break}return x}function l(b,g,_,A){for(var d=0;_--;)b[_]-=d,d=b[_]<g[_]?1:0,b[_]=d*A+b[_]-g[_];for(;!b[0]&&b.length>1;b.splice(0,1));}return function(b,g,_,A,d){var x,v,E,I,F,$,J,dt,mt,X,H,Tt,Ae,Ve,qe,te,at,Ht=b.s==g.s?1:-1,Pt=b.c,xt=g.c;if(!Pt||!Pt[0]||!xt||!xt[0])return new B(!b.s||!g.s||(Pt?xt&&Pt[0]==xt[0]:!xt)?NaN:Pt&&Pt[0]==0||!xt?Ht*0:Ht/0);for(dt=new B(Ht),mt=dt.c=[],v=b.e-g.e,Ht=_+v+1,d||(d=c,v=O(b.e/u)-O(g.e/u),Ht=Ht/u|0),E=0;xt[E]==(Pt[E]||0);E++);if(xt[E]>(Pt[E]||0)&&v--,Ht<0)mt.push(1),I=!0;else{for(Ve=Pt.length,te=xt.length,E=0,Ht+=2,F=i(d/(xt[0]+1)),F>1&&(xt=a(xt,F,d),Pt=a(Pt,F,d),te=xt.length,Ve=Pt.length),Ae=te,X=Pt.slice(0,te),H=X.length;H<te;X[H++]=0);at=xt.slice(),at=[0].concat(at),qe=xt[0],xt[1]>=d/2&&qe++;do{if(F=0,x=f(xt,X,te,H),x<0){if(Tt=X[0],te!=H&&(Tt=Tt*d+(X[1]||0)),F=i(Tt/qe),F>1)for(F>=d&&(F=d-1),$=a(xt,F,d),J=$.length,H=X.length;f($,X,J,H)==1;)F--,l($,te<J?at:xt,J,d),J=$.length,x=1;else F==0&&(x=F=1),$=xt.slice(),J=$.length;if(J<H&&($=[0].concat($)),l(X,$,H,d),H=X.length,x==-1)for(;f(xt,X,te,H)<1;)F++,l(X,te<H?at:xt,H,d),H=X.length}else x===0&&(F++,X=[0]);mt[E++]=F,X[0]?X[H++]=Pt[Ae]||0:(X=[Pt[Ae]],H=1)}while((Ae++<Ve||X[0]!=null)&&Ht--);I=X[0]!=null,mt[0]||mt.splice(0,1)}if(d==c){for(E=1,Ht=mt[0];Ht>=10;Ht/=10,E++);ut(dt,_+(dt.e=E+v*u-1)+1,A,I)}else dt.e=v,dt.r=+I;return dt}}();function h(a,f,l,b){var g,_,A,d,x;if(l==null?l=st:D(l,0,8),!a.c)return a.toString();if(g=a.c[0],A=a.e,f==null)x=K(a.c),x=b==1||b==2&&(A<=wt||A>=It)?C(x,A):lt(x,A,"0");else if(a=ut(new B(a),f,l),_=a.e,x=K(a.c),d=x.length,b==1||b==2&&(f<=_||_<=wt)){for(;d<f;x+="0",d++);x=C(x,_)}else if(f-=A,x=lt(x,_,"0"),_+1>d){if(--f>0)for(x+=".";f--;x+="0");}else if(f+=_-d,f>0)for(_+1==d&&(x+=".");f--;x+="0");return a.s<0&&g?"-"+x:x}function ct(a,f){for(var l,b,g=1,_=new B(a[0]);g<a.length;g++)b=new B(a[g]),(!b.s||(l=ft(_,b))===f||l===0&&_.s===f)&&(_=b);return _}function gt(a,f,l){for(var b=1,g=f.length;!f[--g];f.pop());for(g=f[0];g>=10;g/=10,b++);return(l=b+l*u-1)>j?a.c=a.e=null:l<Ct?a.c=[a.e=0]:(a.e=l,a.c=f),a}Z=function(){var a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,f=/^([^.]+)\.$/,l=/^\.([^.]+)$/,b=/^-?(Infinity|NaN)$/,g=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(_,A,d,x){var v,E=d?A:A.replace(g,"");if(b.test(E))_.s=isNaN(E)?null:E<0?-1:1;else{if(!d&&(E=E.replace(a,function(I,F,$){return v=($=$.toLowerCase())=="x"?16:$=="b"?2:8,!x||x==v?F:I}),x&&(v=x,E=E.replace(f,"$1").replace(l,"0.$1")),A!=E))return new B(E,v);if(B.DEBUG)throw Error(s+"Not a"+(x?" base "+x:"")+" number: "+A);_.s=null}_.c=_.e=null}}();function ut(a,f,l,b){var g,_,A,d,x,v,E,I=a.c,F=y;if(I){t:{for(g=1,d=I[0];d>=10;d/=10,g++);if(_=f-g,_<0)_+=u,A=f,x=I[v=0],E=i(x/F[g-A-1]%10);else if(v=n((_+1)/u),v>=I.length)if(b){for(;I.length<=v;I.push(0));x=E=0,g=1,_%=u,A=_-u+1}else break t;else{for(x=d=I[v],g=1;d>=10;d/=10,g++);_%=u,A=_-u+g,E=A<0?0:i(x/F[g-A-1]%10)}if(b=b||f<0||I[v+1]!=null||(A<0?x:x%F[g-A-1]),b=l<4?(E||b)&&(l==0||l==(a.s<0?3:2)):E>5||E==5&&(l==4||b||l==6&&(_>0?A>0?x/F[g-A]:0:I[v-1])%10&1||l==(a.s<0?8:7)),f<1||!I[0])return I.length=0,b?(f-=a.e+1,I[0]=F[(u-f%u)%u],a.e=-f||0):I[0]=a.e=0,a;if(_==0?(I.length=v,d=1,v--):(I.length=v+1,d=F[u-_],I[v]=A>0?i(x/F[g-A]%F[A])*d:0),b)for(;;)if(v==0){for(_=1,A=I[0];A>=10;A/=10,_++);for(A=I[0]+=d,d=1;A>=10;A/=10,d++);_!=d&&(a.e++,I[0]==c&&(I[0]=1));break}else{if(I[v]+=d,I[v]!=c)break;I[v--]=0,d=1}for(_=I.length;I[--_]===0;I.pop());}a.e>j?a.c=a.e=null:a.e<Ct&&(a.c=[a.e=0])}return a}function M(a){var f,l=a.e;return l===null?a.toString():(f=K(a.c),f=l<=wt||l>=It?C(f,l):lt(f,l,"0"),a.s<0?"-"+f:f)}return R.absoluteValue=R.abs=function(){var a=new B(this);return a.s<0&&(a.s=1),a},R.comparedTo=function(a,f){return ft(this,new B(a,f))},R.decimalPlaces=R.dp=function(a,f){var l,b,g,_=this;if(a!=null)return D(a,0,N),f==null?f=st:D(f,0,8),ut(new B(_),a+_.e+1,f);if(!(l=_.c))return null;if(b=((g=l.length-1)-O(this.e/u))*u,g=l[g])for(;g%10==0;g/=10,b--);return b<0&&(b=0),b},R.dividedBy=R.div=function(a,f){return q(this,new B(a,f),et,st)},R.dividedToIntegerBy=R.idiv=function(a,f){return q(this,new B(a,f),0,1)},R.exponentiatedBy=R.pow=function(a,f){var l,b,g,_,A,d,x,v,E,I=this;if(a=new B(a),a.c&&!a.isInteger())throw Error(s+"Exponent not an integer: "+M(a));if(f!=null&&(f=new B(f)),d=a.e>14,!I.c||!I.c[0]||I.c[0]==1&&!I.e&&I.c.length==1||!a.c||!a.c[0])return E=new B(Math.pow(+M(I),d?a.s*(2-Mt(a)):+M(a))),f?E.mod(f):E;if(x=a.s<0,f){if(f.c?!f.c[0]:!f.s)return new B(NaN);b=!x&&I.isInteger()&&f.isInteger(),b&&(I=I.mod(f))}else{if(a.e>9&&(I.e>0||I.e<-1||(I.e==0?I.c[0]>1||d&&I.c[1]>=24e7:I.c[0]<8e13||d&&I.c[0]<=9999975e7)))return _=I.s<0&&Mt(a)?-0:0,I.e>-1&&(_=1/_),new B(x?1/_:_);G&&(_=n(G/u+2))}for(d?(l=new B(.5),x&&(a.s=1),v=Mt(a)):(g=Math.abs(+M(a)),v=g%2),E=new B(ot);;){if(v){if(E=E.times(I),!E.c)break;_?E.c.length>_&&(E.c.length=_):b&&(E=E.mod(f))}if(g){if(g=i(g/2),g===0)break;v=g%2}else if(a=a.times(l),ut(a,a.e+1,1),a.e>14)v=Mt(a);else{if(g=+M(a),g===0)break;v=g%2}I=I.times(I),_?I.c&&I.c.length>_&&(I.c.length=_):b&&(I=I.mod(f))}return b?E:(x&&(E=ot.div(E)),f?E.mod(f):_?ut(E,G,st,A):E)},R.integerValue=function(a){var f=new B(this);return a==null?a=st:D(a,0,8),ut(f,f.e+1,a)},R.isEqualTo=R.eq=function(a,f){return ft(this,new B(a,f))===0},R.isFinite=function(){return!!this.c},R.isGreaterThan=R.gt=function(a,f){return ft(this,new B(a,f))>0},R.isGreaterThanOrEqualTo=R.gte=function(a,f){return(f=ft(this,new B(a,f)))===1||f===0},R.isInteger=function(){return!!this.c&&O(this.e/u)>this.c.length-2},R.isLessThan=R.lt=function(a,f){return ft(this,new B(a,f))<0},R.isLessThanOrEqualTo=R.lte=function(a,f){return(f=ft(this,new B(a,f)))===-1||f===0},R.isNaN=function(){return!this.s},R.isNegative=function(){return this.s<0},R.isPositive=function(){return this.s>0},R.isZero=function(){return!!this.c&&this.c[0]==0},R.minus=function(a,f){var l,b,g,_,A=this,d=A.s;if(a=new B(a,f),f=a.s,!d||!f)return new B(NaN);if(d!=f)return a.s=-f,A.plus(a);var x=A.e/u,v=a.e/u,E=A.c,I=a.c;if(!x||!v){if(!E||!I)return E?(a.s=-f,a):new B(I?A:NaN);if(!E[0]||!I[0])return I[0]?(a.s=-f,a):new B(E[0]?A:st==3?-0:0)}if(x=O(x),v=O(v),E=E.slice(),d=x-v){for((_=d<0)?(d=-d,g=E):(v=x,g=I),g.reverse(),f=d;f--;g.push(0));g.reverse()}else for(b=(_=(d=E.length)<(f=I.length))?d:f,d=f=0;f<b;f++)if(E[f]!=I[f]){_=E[f]<I[f];break}if(_&&(g=E,E=I,I=g,a.s=-a.s),f=(b=I.length)-(l=E.length),f>0)for(;f--;E[l++]=0);for(f=c-1;b>d;){if(E[--b]<I[b]){for(l=b;l&&!E[--l];E[l]=f);--E[l],E[b]+=c}E[b]-=I[b]}for(;E[0]==0;E.splice(0,1),--v);return E[0]?gt(a,E,v):(a.s=st==3?-1:1,a.c=[a.e=0],a)},R.modulo=R.mod=function(a,f){var l,b,g=this;return a=new B(a,f),!g.c||!a.s||a.c&&!a.c[0]?new B(NaN):!a.c||g.c&&!g.c[0]?new B(g):(k==9?(b=a.s,a.s=1,l=q(g,a,0,3),a.s=b,l.s*=b):l=q(g,a,0,k),a=g.minus(l.times(a)),!a.c[0]&&k==1&&(a.s=g.s),a)},R.multipliedBy=R.times=function(a,f){var l,b,g,_,A,d,x,v,E,I,F,$,J,dt,mt,X=this,H=X.c,Tt=(a=new B(a,f)).c;if(!H||!Tt||!H[0]||!Tt[0])return!X.s||!a.s||H&&!H[0]&&!Tt||Tt&&!Tt[0]&&!H?a.c=a.e=a.s=null:(a.s*=X.s,!H||!Tt?a.c=a.e=null:(a.c=[0],a.e=0)),a;for(b=O(X.e/u)+O(a.e/u),a.s*=X.s,x=H.length,I=Tt.length,x<I&&(J=H,H=Tt,Tt=J,g=x,x=I,I=g),g=x+I,J=[];g--;J.push(0));for(dt=c,mt=m,g=I;--g>=0;){for(l=0,F=Tt[g]%mt,$=Tt[g]/mt|0,A=x,_=g+A;_>g;)v=H[--A]%mt,E=H[A]/mt|0,d=$*v+E*F,v=F*v+d%mt*mt+J[_]+l,l=(v/dt|0)+(d/mt|0)+$*E,J[_--]=v%dt;J[_]=l}return l?++b:J.splice(0,1),gt(a,J,b)},R.negated=function(){var a=new B(this);return a.s=-a.s||null,a},R.plus=function(a,f){var l,b=this,g=b.s;if(a=new B(a,f),f=a.s,!g||!f)return new B(NaN);if(g!=f)return a.s=-f,b.minus(a);var _=b.e/u,A=a.e/u,d=b.c,x=a.c;if(!_||!A){if(!d||!x)return new B(g/0);if(!d[0]||!x[0])return x[0]?a:new B(d[0]?b:g*0)}if(_=O(_),A=O(A),d=d.slice(),g=_-A){for(g>0?(A=_,l=x):(g=-g,l=d),l.reverse();g--;l.push(0));l.reverse()}for(g=d.length,f=x.length,g-f<0&&(l=x,x=d,d=l,f=g),g=0;f;)g=(d[--f]=d[f]+x[f]+g)/c|0,d[f]=c===d[f]?0:d[f]%c;return g&&(d=[g].concat(d),++A),gt(a,d,A)},R.precision=R.sd=function(a,f){var l,b,g,_=this;if(a!=null&&a!==!!a)return D(a,1,N),f==null?f=st:D(f,0,8),ut(new B(_),a,f);if(!(l=_.c))return null;if(g=l.length-1,b=g*u+1,g=l[g]){for(;g%10==0;g/=10,b--);for(g=l[0];g>=10;g/=10,b++);}return a&&_.e+1>b&&(b=_.e+1),b},R.shiftedBy=function(a){return D(a,-w,w),this.times("1e"+a)},R.squareRoot=R.sqrt=function(){var a,f,l,b,g,_=this,A=_.c,d=_.s,x=_.e,v=et+4,E=new B("0.5");if(d!==1||!A||!A[0])return new B(!d||d<0&&(!A||A[0])?NaN:A?_:1/0);if(d=Math.sqrt(+M(_)),d==0||d==1/0?(f=K(A),(f.length+x)%2==0&&(f+="0"),d=Math.sqrt(+f),x=O((x+1)/2)-(x<0||x%2),d==1/0?f="5e"+x:(f=d.toExponential(),f=f.slice(0,f.indexOf("e")+1)+x),l=new B(f)):l=new B(d+""),l.c[0]){for(x=l.e,d=x+v,d<3&&(d=0);;)if(g=l,l=E.times(g.plus(q(_,g,v,1))),K(g.c).slice(0,d)===(f=K(l.c)).slice(0,d))if(l.e<x&&--d,f=f.slice(d-3,d+1),f=="9999"||!b&&f=="4999"){if(!b&&(ut(g,g.e+et+2,0),g.times(g).eq(_))){l=g;break}v+=4,d+=4,b=1}else{(!+f||!+f.slice(1)&&f.charAt(0)=="5")&&(ut(l,l.e+et+2,1),a=!l.times(l).eq(_));break}}return ut(l,l.e+et+1,st,a)},R.toExponential=function(a,f){return a!=null&&(D(a,0,N),a++),h(this,a,f,1)},R.toFixed=function(a,f){return a!=null&&(D(a,0,N),a=a+this.e+1),h(this,a,f)},R.toFormat=function(a,f,l){var b,g=this;if(l==null)a!=null&&f&&typeof f=="object"?(l=f,f=null):a&&typeof a=="object"?(l=a,a=f=null):l=Y;else if(typeof l!="object")throw Error(s+"Argument not an object: "+l);if(b=g.toFixed(a,f),g.c){var _,A=b.split("."),d=+l.groupSize,x=+l.secondaryGroupSize,v=l.groupSeparator||"",E=A[0],I=A[1],F=g.s<0,$=F?E.slice(1):E,J=$.length;if(x&&(_=d,d=x,x=_,J-=_),d>0&&J>0){for(_=J%d||d,E=$.substr(0,_);_<J;_+=d)E+=v+$.substr(_,d);x>0&&(E+=v+$.slice(_)),F&&(E="-"+E)}b=I?E+(l.decimalSeparator||"")+((x=+l.fractionGroupSize)?I.replace(new RegExp("\\d{"+x+"}\\B","g"),"$&"+(l.fractionGroupSeparator||"")):I):E}return(l.prefix||"")+b+(l.suffix||"")},R.toFraction=function(a){var f,l,b,g,_,A,d,x,v,E,I,F,$=this,J=$.c;if(a!=null&&(d=new B(a),!d.isInteger()&&(d.c||d.s!==1)||d.lt(ot)))throw Error(s+"Argument "+(d.isInteger()?"out of range: ":"not an integer: ")+M(d));if(!J)return new B($);for(f=new B(ot),v=l=new B(ot),b=x=new B(ot),F=K(J),_=f.e=F.length-$.e-1,f.c[0]=y[(A=_%u)<0?u+A:A],a=!a||d.comparedTo(f)>0?_>0?f:v:d,A=j,j=1/0,d=new B(F),x.c[0]=0;E=q(d,f,0,1),g=l.plus(E.times(b)),g.comparedTo(a)!=1;)l=b,b=g,v=x.plus(E.times(g=v)),x=g,f=d.minus(E.times(g=f)),d=g;return g=q(a.minus(l),b,0,1),x=x.plus(g.times(v)),l=l.plus(g.times(b)),x.s=v.s=$.s,_=_*2,I=q(v,b,_,st).minus($).abs().comparedTo(q(x,l,_,st).minus($).abs())<1?[v,b]:[x,l],j=A,I},R.toNumber=function(){return+M(this)},R.toPrecision=function(a,f){return a!=null&&D(a,1,N),h(this,a,f,2)},R.toString=function(a){var f,l=this,b=l.s,g=l.e;return g===null?b?(f="Infinity",b<0&&(f="-"+f)):f="NaN":(a==null?f=g<=wt||g>=It?C(K(l.c),g):lt(K(l.c),g,"0"):a===10&&it?(l=ut(new B(l),et+g+1,st),f=lt(K(l.c),l.e,"0")):(D(a,2,z.length,"Base"),f=nt(lt(K(l.c),g,"0"),10,a,b,!0)),b<0&&l.c[0]&&(f="-"+f)),f},R.valueOf=R.toJSON=function(){return M(this)},R._isBigNumber=!0,V!=null&&B.set(V),B}function O(V){var q=V|0;return V>0||V===q?q:q-1}function K(V){for(var q,nt,Z=1,R=V.length,ot=V[0]+"";Z<R;){for(q=V[Z++]+"",nt=u-q.length;nt--;q="0"+q);ot+=q}for(R=ot.length;ot.charCodeAt(--R)===48;);return ot.slice(0,R+1||1)}function ft(V,q){var nt,Z,R=V.c,ot=q.c,et=V.s,st=q.s,wt=V.e,It=q.e;if(!et||!st)return null;if(nt=R&&!R[0],Z=ot&&!ot[0],nt||Z)return nt?Z?0:-st:et;if(et!=st)return et;if(nt=et<0,Z=wt==It,!R||!ot)return Z?0:!R^nt?1:-1;if(!Z)return wt>It^nt?1:-1;for(st=(wt=R.length)<(It=ot.length)?wt:It,et=0;et<st;et++)if(R[et]!=ot[et])return R[et]>ot[et]^nt?1:-1;return wt==It?0:wt>It^nt?1:-1}function D(V,q,nt,Z){if(V<q||V>nt||V!==i(V))throw Error(s+(Z||"Argument")+(typeof V=="number"?V<q||V>nt?" out of range: ":" not an integer: ":" not a primitive number: ")+String(V))}function Mt(V){var q=V.c.length-1;return O(V.e/u)==q&&V.c[q]%2!=0}function C(V,q){return(V.length>1?V.charAt(0)+"."+V.slice(1):V)+(q<0?"e":"e+")+q}function lt(V,q,nt){var Z,R;if(q<0){for(R=nt+".";++q;R+=nt);V=R+V}else if(Z=V.length,++q>Z){for(R=nt,q-=Z;--q;R+=nt);V+=R}else q<Z&&(V=V.slice(0,q)+"."+V.slice(q));return V}t=P(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd?define(function(){return t}):typeof Tn<"u"&&Tn.exports?Tn.exports=t:(r||(r=typeof self<"u"&&self?self:window),r.BigNumber=t)})(ba)});var va=Bt((Wp,Ea)=>{Ea.exports=function(t,e,n){var i=new t.Uint8Array(n),s=e.pushInt,o=e.pushInt32,c=e.pushInt32Neg,u=e.pushInt64,w=e.pushInt64Neg,y=e.pushFloat,m=e.pushFloatSingle,N=e.pushFloatDouble,P=e.pushTrue,O=e.pushFalse,K=e.pushUndefined,ft=e.pushNull,D=e.pushInfinity,Mt=e.pushInfinityNeg,C=e.pushNaN,lt=e.pushNaNNeg,V=e.pushArrayStart,q=e.pushArrayStartFixed,nt=e.pushArrayStartFixed32,Z=e.pushArrayStartFixed64,R=e.pushObjectStart,ot=e.pushObjectStartFixed,et=e.pushObjectStartFixed32,st=e.pushObjectStartFixed64,wt=e.pushByteString,It=e.pushByteStringStart,Ct=e.pushUtf8String,j=e.pushUtf8StringStart,U=e.pushSimpleUnassigned,k=e.pushTagStart,G=e.pushTagStart4,Y=e.pushTagStart8,z=e.pushTagUnassigned,it=e.pushBreak,B=t.Math.pow,h=0,ct=0,gt=0;function ut(p){for(p=p|0,h=0,ct=p;(h|0)<(ct|0)&&(gt=Gu[i[h]&255](i[h]|0)|0,!((gt|0)>0)););return gt|0}function M(p){return p=p|0,((h|0)+(p|0)|0)<(ct|0)?0:1}function a(p){return p=p|0,i[p|0]<<8|i[p+1|0]|0}function f(p){return p=p|0,i[p|0]<<24|i[p+1|0]<<16|i[p+2|0]<<8|i[p+3|0]|0}function l(p){return p=p|0,s(p|0),h=h+1|0,0}function b(p){return p=p|0,M(1)|0?1:(s(i[h+1|0]|0),h=h+2|0,0)}function g(p){return p=p|0,M(2)|0?1:(s(a(h+1|0)|0),h=h+3|0,0)}function _(p){return p=p|0,M(4)|0?1:(o(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function A(p){return p=p|0,M(8)|0?1:(u(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function d(p){return p=p|0,s(-1-(p-32|0)|0),h=h+1|0,0}function x(p){return p=p|0,M(1)|0?1:(s(-1-(i[h+1|0]|0)|0),h=h+2|0,0)}function v(p){p=p|0;var tt=0;return M(2)|0?1:(tt=a(h+1|0)|0,s(-1-(tt|0)|0),h=h+3|0,0)}function E(p){return p=p|0,M(4)|0?1:(c(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function I(p){return p=p|0,M(8)|0?1:(w(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function F(p){p=p|0;var tt=0,rt=0,Q=0;return Q=p-64|0,M(Q|0)|0?1:(tt=h+1|0,rt=(h+1|0)+(Q|0)|0,wt(tt|0,rt|0),h=rt|0,0)}function $(p){p=p|0;var tt=0,rt=0,Q=0;return M(1)|0||(Q=i[h+1|0]|0,tt=h+2|0,rt=(h+2|0)+(Q|0)|0,M(Q+1|0)|0)?1:(wt(tt|0,rt|0),h=rt|0,0)}function J(p){p=p|0;var tt=0,rt=0,Q=0;return M(2)|0||(Q=a(h+1|0)|0,tt=h+3|0,rt=(h+3|0)+(Q|0)|0,M(Q+2|0)|0)?1:(wt(tt|0,rt|0),h=rt|0,0)}function dt(p){p=p|0;var tt=0,rt=0,Q=0;return M(4)|0||(Q=f(h+1|0)|0,tt=h+5|0,rt=(h+5|0)+(Q|0)|0,M(Q+4|0)|0)?1:(wt(tt|0,rt|0),h=rt|0,0)}function mt(p){return p=p|0,1}function X(p){return p=p|0,It(),h=h+1|0,0}function H(p){p=p|0;var tt=0,rt=0,Q=0;return Q=p-96|0,M(Q|0)|0?1:(tt=h+1|0,rt=(h+1|0)+(Q|0)|0,Ct(tt|0,rt|0),h=rt|0,0)}function Tt(p){p=p|0;var tt=0,rt=0,Q=0;return M(1)|0||(Q=i[h+1|0]|0,tt=h+2|0,rt=(h+2|0)+(Q|0)|0,M(Q+1|0)|0)?1:(Ct(tt|0,rt|0),h=rt|0,0)}function Ae(p){p=p|0;var tt=0,rt=0,Q=0;return M(2)|0||(Q=a(h+1|0)|0,tt=h+3|0,rt=(h+3|0)+(Q|0)|0,M(Q+2|0)|0)?1:(Ct(tt|0,rt|0),h=rt|0,0)}function Ve(p){p=p|0;var tt=0,rt=0,Q=0;return M(4)|0||(Q=f(h+1|0)|0,tt=h+5|0,rt=(h+5|0)+(Q|0)|0,M(Q+4|0)|0)?1:(Ct(tt|0,rt|0),h=rt|0,0)}function qe(p){return p=p|0,1}function te(p){return p=p|0,j(),h=h+1|0,0}function at(p){return p=p|0,q(p-128|0),h=h+1|0,0}function Ht(p){return p=p|0,M(1)|0?1:(q(i[h+1|0]|0),h=h+2|0,0)}function Pt(p){return p=p|0,M(2)|0?1:(q(a(h+1|0)|0),h=h+3|0,0)}function xt(p){return p=p|0,M(4)|0?1:(nt(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function Au(p){return p=p|0,M(8)|0?1:(Z(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function Tu(p){return p=p|0,V(),h=h+1|0,0}function _t(p){p=p|0;var tt=0;return tt=p-160|0,M(tt|0)|0?1:(ot(tt|0),h=h+1|0,0)}function Su(p){return p=p|0,M(1)|0?1:(ot(i[h+1|0]|0),h=h+2|0,0)}function Bu(p){return p=p|0,M(2)|0?1:(ot(a(h+1|0)|0),h=h+3|0,0)}function Iu(p){return p=p|0,M(4)|0?1:(et(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function Nu(p){return p=p|0,M(8)|0?1:(st(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function Ru(p){return p=p|0,R(),h=h+1|0,0}function Qe(p){return p=p|0,k(p-192|0|0),h=h+1|0,0}function dd(p){return p=p|0,k(p|0),h=h+1|0,0}function pd(p){return p=p|0,k(p|0),h=h+1|0,0}function yd(p){return p=p|0,k(p|0),h=h+1|0,0}function wd(p){return p=p|0,k(p|0),h=h+1|0,0}function Ft(p){return p=p|0,k(p-192|0|0),h=h+1|0,0}function gd(p){return p=p|0,k(p|0),h=h+1|0,0}function md(p){return p=p|0,k(p|0),h=h+1|0,0}function xd(p){return p=p|0,k(p|0),h=h+1|0,0}function Uu(p){return p=p|0,M(1)|0?1:(k(i[h+1|0]|0),h=h+2|0,0)}function Fu(p){return p=p|0,M(2)|0?1:(k(a(h+1|0)|0),h=h+3|0,0)}function Ou(p){return p=p|0,M(4)|0?1:(G(a(h+1|0)|0,a(h+3|0)|0),h=h+5|0,0)}function ku(p){return p=p|0,M(8)|0?1:(Y(a(h+1|0)|0,a(h+3|0)|0,a(h+5|0)|0,a(h+7|0)|0),h=h+9|0,0)}function St(p){return p=p|0,U((p|0)-224|0),h=h+1|0,0}function Pu(p){return p=p|0,O(),h=h+1|0,0}function Mu(p){return p=p|0,P(),h=h+1|0,0}function Cu(p){return p=p|0,ft(),h=h+1|0,0}function $u(p){return p=p|0,K(),h=h+1|0,0}function Vu(p){return p=p|0,M(1)|0?1:(U(i[h+1|0]|0),h=h+2|0,0)}function qu(p){p=p|0;var tt=0,rt=0,Q=1,cn=0,Ur=0,_d=0;return M(2)|0?1:(tt=i[h+1|0]|0,rt=i[h+2|0]|0,(tt|0)&128&&(Q=-1),cn=+(((tt|0)&124)>>2),Ur=+(((tt|0)&3)<<8|rt),+cn==0?y(+(+Q*5960464477539063e-23*+Ur)):+cn==31?+Q==1?+Ur>0?C():D():+Ur>0?lt():Mt():y(+(+Q*B(2,+(+cn-25))*+(1024+Ur))),h=h+3|0,0)}function Hu(p){return p=p|0,M(4)|0?1:(m(i[h+1|0]|0,i[h+2|0]|0,i[h+3|0]|0,i[h+4|0]|0),h=h+5|0,0)}function ju(p){return p=p|0,M(8)|0?1:(N(i[h+1|0]|0,i[h+2|0]|0,i[h+3|0]|0,i[h+4|0]|0,i[h+5|0]|0,i[h+6|0]|0,i[h+7|0]|0,i[h+8|0]|0),h=h+9|0,0)}function pt(p){return p=p|0,1}function Ku(p){return p=p|0,it(),h=h+1|0,0}var Gu=[l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,b,g,_,A,pt,pt,pt,pt,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,x,v,E,I,pt,pt,pt,pt,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,$,J,dt,mt,pt,pt,pt,X,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,Tt,Ae,Ve,qe,pt,pt,pt,te,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,at,Ht,Pt,xt,Au,pt,pt,pt,Tu,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,Su,Bu,Iu,Nu,pt,pt,pt,Ru,Qe,Qe,Qe,Qe,Qe,Qe,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Uu,Fu,Ou,ku,pt,pt,pt,pt,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,St,Pu,Mu,Cu,$u,Vu,qu,Hu,ju,pt,pt,pt,Ku];return{parse:ut}}});var Hr=Bt(Zt=>{"use strict";var fs=qr().BigNumber;Zt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Zt.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};Zt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Zt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Zt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Zt.SHIFT32=Math.pow(2,32);Zt.SHIFT16=Math.pow(2,16);Zt.MAX_SAFE_HIGH=2097151;Zt.NEG_ONE=new fs(-1);Zt.TEN=new fs(10);Zt.TWO=new fs(2);Zt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Sn=Bt(re=>{"use strict";var{Buffer:ll}=Vr(),Ta=qr().BigNumber,Sa=Hr(),Aa=Sa.SHIFT32,hl=Sa.SHIFT16,dl=2097151;re.parseHalf=function(t){var e,n,i;return i=t[0]&128?-1:1,e=(t[0]&124)>>2,n=(t[0]&3)<<8|t[1],e?e===31?i*(n?NaN:1/0):i*Math.pow(2,e-25)*(1024+n):i*5960464477539063e-23*n};function pl(r){return r<16?"0"+r.toString(16):r.toString(16)}re.arrayBufferToBignumber=function(r){let t=r.byteLength,e="";for(let n=0;n<t;n++)e+=pl(r[n]);return new Ta(e,16)};re.buildMap=r=>{let t=new Map,e=Object.keys(r),n=e.length;for(let i=0;i<n;i++)t.set(e[i],r[e[i]]);return t};re.buildInt32=(r,t)=>r*hl+t;re.buildInt64=(r,t,e,n)=>{let i=re.buildInt32(r,t),s=re.buildInt32(e,n);return i>dl?new Ta(i).times(Aa).plus(s):i*Aa+s};re.writeHalf=function(t,e){let n=ll.allocUnsafe(4);n.writeFloatBE(e,0);let i=n.readUInt32BE(0);if((i&8191)!==0)return!1;var s=i>>16&32768;let o=i>>23&255,c=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(c>>13);else if(o>=103&&o<113){if(c&(1<<126-o)-1)return!1;s+=c+8388608>>126-o}else return!1;return t.writeUInt16BE(s,0),!0};re.keySorter=function(r,t){var e=r[0].byteLength,n=t[0].byteLength;return e>n?1:n>e?-1:r[0].compare(t[0])};re.isNegativeZero=r=>r===0&&1/r<0;re.nextPowerOf2=r=>{let t=0;if(r&&!(r&r-1))return r;for(;r!==0;)r>>=1,t+=1;return 1<<t}});var ps=Bt((Yp,Ba)=>{"use strict";var ds=Hr(),yl=ds.MT,Bn=ds.SIMPLE,ls=ds.SYMS,hs=class r{constructor(t){if(typeof t!="number")throw new Error("Invalid Simple type: "+typeof t);if(t<0||t>255||(t|0)!==t)throw new Error("value must be a small positive integer: "+t);this.value=t}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(t){return t._pushInt(this.value,yl.SIMPLE_FLOAT)}static isSimple(t){return t instanceof r}static decode(t,e){switch(e==null&&(e=!0),t){case Bn.FALSE:return!1;case Bn.TRUE:return!0;case Bn.NULL:return e?null:ls.NULL;case Bn.UNDEFINED:return e?void 0:ls.UNDEFINED;case-1:if(!e)throw new Error("Invalid BREAK");return ls.BREAK;default:return new r(t)}}};Ba.exports=hs});var ws=Bt((Xp,Ia)=>{"use strict";var ys=class r{constructor(t,e,n){if(this.tag=t,this.value=e,this.err=n,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(t){return t._pushTag(this.tag),t.pushAny(this.value)}convert(t){var e,n;if(n=t?.[this.tag],typeof n!="function"&&(n=r["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(r,this.value)}catch(i){return e=i,this.err=e,this}}};Ia.exports=ys});var xs=Bt((Jp,Ra)=>{"use strict";var Na=self.location?self.location.protocol+"//"+self.location.host:"",gs=self.URL,ms=class{constructor(t="",e=Na){this.super=new gs(t,e),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(t){this.super.hash=t}set host(t){this.super.host=t}set hostname(t){this.super.hostname=t}set href(t){this.super.href=t}set origin(t){this.super.origin=t}set password(t){this.super.password=t}set pathname(t){this.super.pathname=t}set port(t){this.super.port=t}set protocol(t){this.super.protocol=t}set search(t){this.super.search=t}set searchParams(t){this.super.searchParams=t}set username(t){this.super.username=t}createObjectURL(t){return this.super.createObjectURL(t)}revokeObjectURL(t){this.super.revokeObjectURL(t)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function wl(r){if(typeof r=="string")return new gs(r).toString();if(!(r instanceof gs)){let t=r.username&&r.password?`${r.username}:${r.password}@`:"",e=r.auth?r.auth+"@":"",n=r.port?":"+r.port:"",i=r.protocol?r.protocol+"//":"",s=r.host||"",o=r.hostname||"",c=r.search||(r.query?"?"+r.query:""),u=r.hash||"",w=r.pathname||"",y=r.path||w+c;return`${i}${t||e}${s||o+n}${y}${u}`}}Ra.exports={URLWithLegacySupport:ms,URLSearchParams:self.URLSearchParams,defaultBase:Na,format:wl}});var Oa=Bt((Zp,Fa)=>{"use strict";var{URLWithLegacySupport:Ua,format:gl}=xs();Fa.exports=(r,t={},e={},n)=>{let i=t.protocol?t.protocol.replace(":",""):"http";i=(e[i]||n||i)+":";let s;try{s=new Ua(r)}catch{s={}}let o=Object.assign({},t,{protocol:i||s.protocol,host:t.host||s.host});return new Ua(r,gl(o)).toString()}});var _s=Bt((Qp,ka)=>{"use strict";var{URLWithLegacySupport:ml,format:xl,URLSearchParams:_l,defaultBase:bl}=xs(),El=Oa();ka.exports={URL:ml,URLSearchParams:_l,format:xl,relative:El,defaultBase:bl}});var bs=Bt((ty,Ma)=>{"use strict";var{Buffer:yr}=Vr(),Pa=fn(),vl=qr().BigNumber,Al=va(),qt=Sn(),ht=Hr(),Tl=ps(),Sl=ws(),{URL:Bl}=_s(),jr=class r{constructor(t){t=t||{},!t.size||t.size<65536?t.size=65536:t.size=qt.nextPowerOf2(t.size),this._heap=new ArrayBuffer(t.size),this._heap8=new Uint8Array(this._heap),this._buffer=yr.from(this._heap),this._reset(),this._knownTags=Object.assign({0:e=>new Date(e),1:e=>new Date(e*1e3),2:e=>qt.arrayBufferToBignumber(e),3:e=>ht.NEG_ONE.minus(qt.arrayBufferToBignumber(e)),4:e=>ht.TEN.pow(e[0]).times(e[1]),5:e=>ht.TWO.pow(e[0]).times(e[1]),32:e=>new Bl(e),35:e=>new RegExp(e)},t.tags),this.parser=Al(global,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var t=this._parents.pop();if(t.length>0)throw new Error(`Missing ${t.length} elements`);switch(t.type){case ht.PARENT.TAG:this._push(this.createTag(t.ref[0],t.ref[1]));break;case ht.PARENT.BYTE_STRING:this._push(this.createByteString(t.ref,t.length));break;case ht.PARENT.UTF8_STRING:this._push(this.createUtf8String(t.ref,t.length));break;case ht.PARENT.MAP:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(t.ref,t.length));break;case ht.PARENT.OBJECT:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(t.ref,t.length));break;case ht.PARENT.ARRAY:this._push(this.createArray(t.ref,t.length));break;default:break}this._currentParent&&this._currentParent.type===ht.PARENT.TAG&&this._dec()}_dec(){let t=this._currentParent;t.length<0||(t.length--,t.length===0&&this._closeParent())}_push(t,e){let n=this._currentParent;switch(n.values++,n.type){case ht.PARENT.ARRAY:case ht.PARENT.BYTE_STRING:case ht.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=t:this._ref.push(t),this._dec();break;case ht.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=t,n.tmpKey=null,this._dec()):(n.tmpKey=t,typeof n.tmpKey!="string"&&(n.type=ht.PARENT.MAP,n.ref=qt.buildMap(n.ref)));break;case ht.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,t),n.tmpKey=null,this._dec()):n.tmpKey=t;break;case ht.PARENT.TAG:this._ref.push(t),e||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(t,e,n){this._parents[this._depth]={type:e,length:n,ref:t,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:ht.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(t,e){let n=this._knownTags[t];return n?n(e):new Sl(t,e)}createMap(t,e){return t}createObject(t,e){return t}createArray(t,e){return t}createByteString(t,e){return yr.concat(t)}createByteStringFromHeap(t,e){return t===e?yr.alloc(0):yr.from(this._heap.slice(t,e))}createInt(t){return t}createInt32(t,e){return qt.buildInt32(t,e)}createInt64(t,e,n,i){return qt.buildInt64(t,e,n,i)}createFloat(t){return t}createFloatSingle(t,e,n,i){return Pa.read([t,e,n,i],0,!1,23,4)}createFloatDouble(t,e,n,i,s,o,c,u){return Pa.read([t,e,n,i,s,o,c,u],0,!1,52,8)}createInt32Neg(t,e){return-1-qt.buildInt32(t,e)}createInt64Neg(t,e,n,i){let s=qt.buildInt32(t,e),o=qt.buildInt32(n,i);return s>ht.MAX_SAFE_HIGH?ht.NEG_ONE.minus(new vl(s).times(ht.SHIFT32).plus(o)):-1-(s*ht.SHIFT32+o)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(t,e){return t.join("")}createUtf8StringFromHeap(t,e){return t===e?"":this._buffer.toString("utf8",t,e)}createSimpleUnassigned(t){return new Tl(t)}pushInt(t){this._push(this.createInt(t))}pushInt32(t,e){this._push(this.createInt32(t,e))}pushInt64(t,e,n,i){this._push(this.createInt64(t,e,n,i))}pushFloat(t){this._push(this.createFloat(t))}pushFloatSingle(t,e,n,i){this._push(this.createFloatSingle(t,e,n,i))}pushFloatDouble(t,e,n,i,s,o,c,u){this._push(this.createFloatDouble(t,e,n,i,s,o,c,u))}pushInt32Neg(t,e){this._push(this.createInt32Neg(t,e))}pushInt64Neg(t,e,n,i){this._push(this.createInt64Neg(t,e,n,i))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],ht.PARENT.ARRAY,-1)}pushArrayStartFixed(t){this._createArrayStartFixed(t)}pushArrayStartFixed32(t,e){let n=qt.buildInt32(t,e);this._createArrayStartFixed(n)}pushArrayStartFixed64(t,e,n,i){let s=qt.buildInt64(t,e,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(t){this._createObjectStartFixed(t)}pushObjectStartFixed32(t,e){let n=qt.buildInt32(t,e);this._createObjectStartFixed(n)}pushObjectStartFixed64(t,e,n,i){let s=qt.buildInt64(t,e,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:ht.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(t,e){this._push(this.createByteStringFromHeap(t,e))}pushUtf8StringStart(){this._parents[this._depth]={type:ht.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(t,e){this._push(this.createUtf8StringFromHeap(t,e))}pushSimpleUnassigned(t){this._push(this.createSimpleUnassigned(t))}pushTagStart(t){this._parents[this._depth]={type:ht.PARENT.TAG,length:1,ref:[t]}}pushTagStart4(t,e){this.pushTagStart(qt.buildInt32(t,e))}pushTagStart8(t,e,n,i){this.pushTagStart(qt.buildInt64(t,e,n,i))}pushTagUnassigned(t){this._push(this.createTag(t))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(t){if(t===0){this._push(this.createObject({}));return}this._createParent({},ht.PARENT.OBJECT,t)}_createArrayStartFixed(t){if(t===0){this._push(this.createArray([]));return}this._createParent(new Array(t),ht.PARENT.ARRAY,t)}_decode(t){if(t.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(t);let e=this.parser.parse(t.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(e>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(t){return this._decode(t),this._res[0]}decodeAll(t){return this._decode(t),this._res}static decode(t,e){return typeof t=="string"&&(t=yr.from(t,e||"hex")),new r({size:t.length}).decodeFirst(t)}static decodeAll(t,e){return typeof t=="string"&&(t=yr.from(t,e||"hex")),new r({size:t.length}).decodeAll(t)}};jr.decodeFirst=jr.decode;Ma.exports=jr});var Va=Bt((ey,$a)=>{"use strict";var{Buffer:Es}=Vr(),Il=bs(),Nl=Sn(),vs=class r extends Il{createTag(t,e){return`${t}(${e})`}createInt(t){return super.createInt(t).toString()}createInt32(t,e){return super.createInt32(t,e).toString()}createInt64(t,e,n,i){return super.createInt64(t,e,n,i).toString()}createInt32Neg(t,e){return super.createInt32Neg(t,e).toString()}createInt64Neg(t,e,n,i){return super.createInt64Neg(t,e,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(t){let e=super.createFloat(t);return Nl.isNegativeZero(t)?"-0_1":`${e}_1`}createFloatSingle(t,e,n,i){return`${super.createFloatSingle(t,e,n,i)}_2`}createFloatDouble(t,e,n,i,s,o,c,u){return`${super.createFloatDouble(t,e,n,i,s,o,c,u)}_3`}createByteString(t,e){let n=t.join(", ");return e===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(t,e){return`h'${Es.from(super.createByteStringFromHeap(t,e)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(t){return`simple(${t})`}createArray(t,e){let n=super.createArray(t,e);return e===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(t,e){let n=super.createMap(t),i=Array.from(n.keys()).reduce(Ca(n),"");return e===-1?`{_ ${i}}`:`{${i}}`}createObject(t,e){let n=super.createObject(t),i=Object.keys(n).reduce(Ca(n),"");return e===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(t,e){let n=t.join(", ");return e===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(t,e){return`"${Es.from(super.createUtf8StringFromHeap(t,e)).toString("utf8")}"`}static diagnose(t,e){return typeof t=="string"&&(t=Es.from(t,e||"hex")),new r().decodeFirst(t)}};$a.exports=vs;function Ca(r){return(t,e)=>t?`${t}, ${e}: ${r[e]}`:`${e}: ${r[e]}`}});var Ga=Bt((ry,Ka)=>{"use strict";var{Buffer:pe}=Vr(),{URL:Rl}=_s(),Ts=qr().BigNumber,As=Sn(),Nt=Hr(),se=Nt.MT,In=Nt.NUMBYTES,qa=Nt.SHIFT32,Ha=Nt.SYMS,wr=Nt.TAG,Ul=Nt.MT.SIMPLE_FLOAT<<5|Nt.NUMBYTES.TWO,Fl=Nt.MT.SIMPLE_FLOAT<<5|Nt.NUMBYTES.FOUR,Ol=Nt.MT.SIMPLE_FLOAT<<5|Nt.NUMBYTES.EIGHT,kl=Nt.MT.SIMPLE_FLOAT<<5|Nt.SIMPLE.TRUE,Pl=Nt.MT.SIMPLE_FLOAT<<5|Nt.SIMPLE.FALSE,Ml=Nt.MT.SIMPLE_FLOAT<<5|Nt.SIMPLE.UNDEFINED,ja=Nt.MT.SIMPLE_FLOAT<<5|Nt.SIMPLE.NULL,Cl=new Ts("0x20000000000000"),$l=pe.from("f97e00","hex"),Vl=pe.from("f9fc00","hex"),ql=pe.from("f97c00","hex");function Hl(r){return{}.toString.call(r).slice(8,-1)}var Ss=class r{constructor(t){t=t||{},this.streaming=typeof t.stream=="function",this.onData=t.stream,this.semanticTypes=[[Rl,this._pushUrl],[Ts,this._pushBigNumber]];let e=t.genTypes||[],n=e.length;for(let i=0;i<n;i++)this.addSemanticType(e[i][0],e[i][1]);this._reset()}addSemanticType(t,e){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===t){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=e,o}return this.semanticTypes.push([t,e]),null}push(t){return t&&(this.result[this.offset]=t,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=t.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(t,e,n){return this.result[this.offset]=t,this.resultMethod[this.offset]=e,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(t){return this.pushWrite(t,1,1)}_pushUInt16BE(t){return this.pushWrite(t,2,2)}_pushUInt32BE(t){return this.pushWrite(t,3,4)}_pushDoubleBE(t){return this.pushWrite(t,4,8)}_pushNaN(){return this.push($l)}_pushInfinity(t){let e=t<0?Vl:ql;return this.push(e)}_pushFloat(t){let e=pe.allocUnsafe(2);if(As.writeHalf(e,t)&&As.parseHalf(e)===t)return this._pushUInt8(Ul)&&this.push(e);let n=pe.allocUnsafe(4);return n.writeFloatBE(t,0),n.readFloatBE(0)===t?this._pushUInt8(Fl)&&this.push(n):this._pushUInt8(Ol)&&this._pushDoubleBE(t)}_pushInt(t,e,n){let i=e<<5;return t<24?this._pushUInt8(i|t):t<=255?this._pushUInt8(i|In.ONE)&&this._pushUInt8(t):t<=65535?this._pushUInt8(i|In.TWO)&&this._pushUInt16BE(t):t<=4294967295?this._pushUInt8(i|In.FOUR)&&this._pushUInt32BE(t):t<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|In.EIGHT)&&this._pushUInt32BE(Math.floor(t/qa))&&this._pushUInt32BE(t%qa):e===se.NEG_INT?this._pushFloat(n):this._pushFloat(t)}_pushIntNum(t){return t<0?this._pushInt(-t-1,se.NEG_INT,t):this._pushInt(t,se.POS_INT)}_pushNumber(t){switch(!1){case t===t:return this._pushNaN(t);case isFinite(t):return this._pushInfinity(t);case t%1!==0:return this._pushIntNum(t);default:return this._pushFloat(t)}}_pushString(t){let e=pe.byteLength(t,"utf8");return this._pushInt(e,se.UTF8_STRING)&&this.pushWrite(t,5,e)}_pushBoolean(t){return this._pushUInt8(t?kl:Pl)}_pushUndefined(t){return this._pushUInt8(Ml)}_pushArray(t,e){let n=e.length;if(!t._pushInt(n,se.ARRAY))return!1;for(let i=0;i<n;i++)if(!t.pushAny(e[i]))return!1;return!0}_pushTag(t){return this._pushInt(t,se.TAG)}_pushDate(t,e){return t._pushTag(wr.DATE_EPOCH)&&t.pushAny(Math.round(e/1e3))}_pushBuffer(t,e){return t._pushInt(e.length,se.BYTE_STRING)&&t.push(e)}_pushNoFilter(t,e){return t._pushBuffer(t,e.slice())}_pushRegexp(t,e){return t._pushTag(wr.REGEXP)&&t.pushAny(e.source)}_pushSet(t,e){if(!t._pushInt(e.size,se.ARRAY))return!1;for(let n of e)if(!t.pushAny(n))return!1;return!0}_pushUrl(t,e){return t._pushTag(wr.URI)&&t.pushAny(e.format())}_pushBigint(t){let e=wr.POS_BIGINT;t.isNegative()&&(t=t.negated().minus(1),e=wr.NEG_BIGINT);let n=t.toString(16);n.length%2&&(n="0"+n);let i=pe.from(n,"hex");return this._pushTag(e)&&this._pushBuffer(this,i)}_pushBigNumber(t,e){if(e.isNaN())return t._pushNaN();if(!e.isFinite())return t._pushInfinity(e.isNegative()?-1/0:1/0);if(e.isInteger())return t._pushBigint(e);if(!(t._pushTag(wr.DECIMAL_FRAC)&&t._pushInt(2,se.ARRAY)))return!1;let n=e.decimalPlaces(),i=e.multipliedBy(new Ts(10).pow(n));return t._pushIntNum(-n)?i.abs().isLessThan(Cl)?t._pushIntNum(i.toNumber()):t._pushBigint(i):!1}_pushMap(t,e){return t._pushInt(e.size,se.MAP)?this._pushRawMap(e.size,Array.from(e)):!1}_pushObject(t){if(!t)return this._pushUInt8(ja);for(var e=this.semanticTypes.length,n=0;n<e;n++)if(t instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(t,this,t);var i=t.encodeCBOR;if(typeof i=="function")return i.call(t,this);var s=Object.keys(t),o=s.length;return this._pushInt(o,se.MAP)?this._pushRawMap(o,s.map(c=>[c,t[c]])):!1}_pushRawMap(t,e){e=e.map(function(i){return i[0]=r.encode(i[0]),i}).sort(As.keySorter);for(var n=0;n<t;n++)if(!this.push(e[n][0])||!this.pushAny(e[n][1]))return!1;return!0}write(t){return this.pushAny(t)}pushAny(t){var e=Hl(t);switch(e){case"Number":return this._pushNumber(t);case"String":return this._pushString(t);case"Boolean":return this._pushBoolean(t);case"Object":return this._pushObject(t);case"Array":return this._pushArray(this,t);case"Uint8Array":return this._pushBuffer(this,pe.isBuffer(t)?t:pe.from(t));case"Null":return this._pushUInt8(ja);case"Undefined":return this._pushUndefined(t);case"Map":return this._pushMap(this,t);case"Set":return this._pushSet(this,t);case"URL":return this._pushUrl(this,t);case"BigNumber":return this._pushBigNumber(this,t);case"Date":return this._pushDate(this,t);case"RegExp":return this._pushRegexp(this,t);case"Symbol":switch(t){case Ha.NULL:return this._pushObject(null);case Ha.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+t.toString())}default:throw new Error("Unknown type: "+typeof t+", "+(t?t.toString():""))}}finalize(){if(this.offset===0)return null;for(var t=this.result,e=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=e[o];var c=pe.allocUnsafe(s),u=0,w=0;for(o=0;o<i;o++){switch(w=e[o],n[o]){case 0:t[o].copy(c,u);break;case 1:c.writeUInt8(t[o],u,!0);break;case 2:c.writeUInt16BE(t[o],u,!0);break;case 3:c.writeUInt32BE(t[o],u,!0);break;case 4:c.writeDoubleBE(t[o],u,!0);break;case 5:c.write(t[o],u,w,"utf8");break;default:throw new Error("unkown method")}u+=w}var y=c;return this._reset(),y}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(t){let e=new r;if(!e.pushAny(t))throw new Error("Failed to encode input");return e.finalize()}};Ka.exports=Ss});var Nn=Bt(Rt=>{"use strict";Rt.Diagnose=Va();Rt.Decoder=bs();Rt.Encoder=Ga();Rt.Simple=ps();Rt.Tagged=ws();Rt.decodeAll=Rt.Decoder.decodeAll;Rt.decodeFirst=Rt.Decoder.decodeFirst;Rt.diagnose=Rt.Diagnose.diagnose;Rt.encode=Rt.Encoder.encode;Rt.decode=Rt.Decoder.decode;Rt.leveldb={decode:Rt.Decoder.decodeAll,encode:Rt.Encoder.encode,buffer:!0,name:"cbor"}});function Ue(r){return Ge(Xo.create().update(new Uint8Array(r)).digest())}function Rn(r){if(r instanceof La.default.Tagged)return Rn(r.value);if(typeof r=="string")return Wa(r);if(typeof r=="number")return Ue(Re(r));if(r instanceof ArrayBuffer||ArrayBuffer.isView(r))return Ue(r);if(Array.isArray(r)){let t=r.map(Rn);return Ue(he(...t))}else{if(r&&typeof r=="object"&&r._isPrincipal)return Ue(r.toUint8Array());if(typeof r=="object"&&r!==null&&typeof r.toHash=="function")return Rn(r.toHash());if(typeof r=="object")return Bs(r);if(typeof r=="bigint")return Ue(Re(r))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${r}`),{value:r})}function gr(r){return Bs(r)}function Bs(r){let n=Object.entries(r).filter(([,o])=>o!==void 0).map(([o,c])=>{let u=Wa(o),w=Rn(c);return[u,w]}).sort(([o],[c])=>Ci(o,c)),i=he(...n.map(o=>he(...o)));return Ue(i)}var La,Wa,Kr=L(()=>{hr();La=Te(Nn());Mi();Gt();Wa=r=>{let t=new TextEncoder().encode(r);return Ue(t)}});var jl,Kl,be,mr,Is=L(()=>{Dt();Kr();Gt();jl=function(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(e[n[i]]=r[n[i]]);return e},Kl=new TextEncoder().encode(`
|
|
2
|
-
ic-request`),be=class{getPrincipal(){return this._principal||(this._principal=vt.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(t){let{body:e}=t,n=jl(t,["body"]),i=gr(e);return Object.assign(Object.assign({},n),{body:{content:e,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(he(Kl,i))}})}},mr=class{getPrincipal(){return vt.anonymous()}async transformRequest(t){return Object.assign(Object.assign({},t),{body:{content:t.body}})}}});var Us=Bt(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});var Gl=9007199254740992;function Ee(r,...t){let e=new Uint8Array(r.byteLength+t.reduce((i,s)=>i+s.byteLength,0));e.set(new Uint8Array(r),0);let n=r.byteLength;for(let i of t)e.set(new Uint8Array(i),n),n+=i.byteLength;return e.buffer}function oe(r,t,e){e=e.replace(/[^0-9a-fA-F]/g,"");let n=2**(t-24);e=e.slice(-n*2).padStart(n*2,"0");let i=[(r<<5)+t].concat(e.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function Un(r,t){if(t<24)return new Uint8Array([(r<<5)+t]).buffer;{let e=t<=255?24:t<=65535?25:t<=4294967295?26:27;return oe(r,e,t.toString(16))}}function Da(r){let t=[];for(let e=0;e<r.length;e++){let n=r.charCodeAt(e);n<128?t.push(n):n<2048?t.push(192|n>>6,128|n&63):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|n&63):(e++,n=(n&1023)<<10|r.charCodeAt(e)&1023,t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return Ee(new Uint8Array(Un(3,r.length)),new Uint8Array(t))}function Ll(r,t){if(r==14277111)return Ee(new Uint8Array([217,217,247]),t);if(r<24)return Ee(new Uint8Array([192+r]),t);{let e=r<=255?24:r<=65535?25:r<=4294967295?26:27,n=2**(e-24),i=r.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+e].concat(i.match(/../g).map(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}yt.tagged=Ll;function Gr(r){return new Uint8Array(r).buffer}yt.raw=Gr;function Ns(r){if(isNaN(r))throw new RangeError("Invalid number.");r=Math.min(Math.max(0,r),23);let t=[0+r];return new Uint8Array(t).buffer}yt.uSmall=Ns;function za(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),255),r=r.toString(16),oe(0,24,r)}yt.u8=za;function Ya(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),65535),r=r.toString(16),oe(0,25,r)}yt.u16=Ya;function Xa(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),4294967295),r=r.toString(16),oe(0,26,r)}yt.u32=Xa;function Rs(r,t){if(typeof r=="string"&&t==16){if(r.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return oe(0,27,r)}if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),Gl),r=r.toString(16),oe(0,27,r)}yt.u64=Rs;function Ja(r){if(isNaN(r))throw new RangeError("Invalid number.");if(r===0)return Ns(0);r=Math.min(Math.max(0,-r),24)-1;let t=[32+r];return new Uint8Array(t).buffer}yt.iSmall=Ja;function Za(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),255),r=r.toString(16),oe(1,24,r)}yt.i8=Za;function Qa(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),65535),r=r.toString(16),oe(1,25,r)}yt.i16=Qa;function tc(r,t){if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),4294967295),r=r.toString(16),oe(1,26,r)}yt.i32=tc;function ec(r,t){if(typeof r=="string"&&t==16){if(r.startsWith("-")?r=r.slice(1):r="0",r.match(/[^0-9a-fA-F]/)||r.length>16)throw new RangeError("Invalid number.");let e=!1,n=r.split("").reduceRight((i,s)=>{if(e)return s+i;let o=parseInt(s,16)-1;return o>=0?(e=!0,o.toString(16)+i):"f"+i},"");return e?oe(1,27,n):Rs(0)}if(r=parseInt(""+r,t),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),9007199254740992),r=r.toString(16),oe(1,27,r)}yt.i64=ec;function Wl(r){return r>=0?r<24?Ns(r):r<=255?za(r):r<=65535?Ya(r):r<=4294967295?Xa(r):Rs(r):r>=-24?Ja(r):r>=-255?Za(r):r>=-65535?Qa(r):r>=-4294967295?tc(r):ec(r)}yt.number=Wl;function Dl(r){return Ee(Un(2,r.byteLength),r)}yt.bytes=Dl;function zl(r){return Da(r)}yt.string=zl;function Yl(r){return Ee(Un(4,r.length),...r)}yt.array=Yl;function Xl(r,t=!1){r instanceof Map||(r=new Map(Object.entries(r)));let e=Array.from(r.entries());return t&&(e=e.sort(([n],[i])=>n.localeCompare(i))),Ee(Un(5,r.size),...e.map(([n,i])=>Ee(Da(n),i)))}yt.map=Xl;function Jl(r){let t=new Float32Array([r]);return Ee(new Uint8Array([250]),new Uint8Array(t.buffer))}yt.singleFloat=Jl;function Zl(r){let t=new Float64Array([r]);return Ee(new Uint8Array([251]),new Uint8Array(t.buffer))}yt.doubleFloat=Zl;function Ql(r){return r?rc():nc()}yt.bool=Ql;function rc(){return Gr(new Uint8Array([245]))}yt.true_=rc;function nc(){return Gr(new Uint8Array([244]))}yt.false_=nc;function th(){return Gr(new Uint8Array([246]))}yt.null_=th;function eh(){return Gr(new Uint8Array([247]))}yt.undefined_=eh});var ic=Bt(Fe=>{"use strict";var rh=Fe&&Fe.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t};Object.defineProperty(Fe,"__esModule",{value:!0});var ae=rh(Us()),nh=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],Fn=class{constructor(t,e=!1){this._serializer=t,this._stable=e,this.name="jsonDefault",this.priority=-100}match(t){return["undefined","boolean","number","string","object"].indexOf(typeof t)!=-1}encode(t){switch(typeof t){case"undefined":return ae.undefined_();case"boolean":return ae.bool(t);case"number":return Math.floor(t)===t?ae.number(t):ae.doubleFloat(t);case"string":return ae.string(t);case"object":if(t===null)return ae.null_();if(Array.isArray(t))return ae.array(t.map(e=>this._serializer.serializeValue(e)));if(nh.find(e=>t instanceof e))return ae.bytes(t.buffer);if(Object.getOwnPropertyNames(t).indexOf("toJSON")!==-1)return this.encode(t.toJSON());if(t instanceof Map){let e=new Map;for(let[n,i]of t.entries())e.set(n,this._serializer.serializeValue(i));return ae.map(e,this._stable)}else{let e=new Map;for(let[n,i]of Object.entries(t))e.set(n,this._serializer.serializeValue(i));return ae.map(e,this._stable)}default:throw new Error("Invalid value.")}}};Fe.JsonDefaultCborEncoder=Fn;var On=class{constructor(){this.name="cborEncoder",this.priority=-90}match(t){return typeof t=="object"&&typeof t.toCBOR=="function"}encode(t){return t.toCBOR()}};Fe.ToCborEncoder=On;var kn=class{constructor(){this._encoders=new Set}static withDefaultEncoders(t=!1){let e=new this;return e.addEncoder(new Fn(e,t)),e.addEncoder(new On),e}removeEncoder(t){for(let e of this._encoders.values())e.name==t&&this._encoders.delete(e)}addEncoder(t){this._encoders.add(t)}getEncoderFor(t){let e=null;for(let n of this._encoders)(!e||n.priority>e.priority)&&n.match(t)&&(e=n);if(e===null)throw new Error("Could not find an encoder for value.");return e}serializeValue(t){return this.getEncoderFor(t).encode(t)}serialize(t){return this.serializeValue(t)}};Fe.CborSerializer=kn;var Fs=class extends kn{serialize(t){return ae.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(t))]))}};Fe.SelfDescribeCborSerializer=Fs});var Lr=Bt(We=>{"use strict";function ih(r){for(var t in r)We.hasOwnProperty(t)||(We[t]=r[t])}var sh=We&&We.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t};Object.defineProperty(We,"__esModule",{value:!0});ih(ic());var oh=sh(Us());We.value=oh});function sc(r){let t=r.byteLength,e=BigInt(0);for(let n=0;n<t;n++)e=e*BigInt(256)+BigInt(r[n]);return e}function Pn(r){let t=new Uint8Array(r),e=new Cs({size:t.byteLength,tags:{2:n=>sc(n),3:n=>-sc(n),[Ms.Semantic]:n=>n}});try{return e.decodeFirst(t)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${bt(t)}`)}}var oc,De,ac,Os,ks,Ps,$s,Ms,Cs,Wr=L(()=>{oc=Te(Nn()),De=Te(Lr()),ac=Te(Lr());Gt();Os=class{get name(){return"Principal"}get priority(){return 0}match(t){return t&&t._isPrincipal===!0}encode(t){return De.value.bytes(t.toUint8Array())}},ks=class{get name(){return"Buffer"}get priority(){return 1}match(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)}encode(t){return De.value.bytes(new Uint8Array(t))}},Ps=class{get name(){return"BigInt"}get priority(){return 1}match(t){return typeof t=="bigint"}encode(t){return t>BigInt(0)?De.value.tagged(2,De.value.bytes(Kt(t.toString(16)))):De.value.tagged(3,De.value.bytes(Kt((BigInt("-1")*t).toString(16))))}},$s=ac.SelfDescribeCborSerializer.withDefaultEncoders(!0);$s.addEncoder(new Os);$s.addEncoder(new ks);$s.addEncoder(new Ps);(function(r){r[r.Uint64LittleEndian=71]="Uint64LittleEndian",r[r.Semantic=55799]="Semantic"})(Ms||(Ms={}));Cs=class extends oc.default.Decoder{createByteString(t){return he(...t)}createByteStringFromHeap(t,e){return t===e?new ArrayBuffer(0):new Uint8Array(this._heap.slice(t,e))}}});var Vs=L(()=>{});var qs,Dr=L(()=>{Vs();(function(r){r.Call="call"})(qs||(qs={}))});function zr(r){let t=[];return r.forEach((e,n)=>{t.push([n,e])}),t}var ah,Ey,vy,Cn=L(()=>{hr();ah=Te(Lr());Dr();Ey=BigInt(1e6),vy=60*1e3});var xr,$n=L(()=>{ar();xr=class extends zt{constructor(t,e){super(t),this.response=e,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}}});function js(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Ks(r){if(!js(r))throw new Error("Uint8Array expected")}function Vn(r,t){if(typeof t!="boolean")throw new Error(`${r} must be valid boolean, got "${t}".`)}function qn(r){Ks(r);let t="";for(let e=0;e<r.length;e++)t+=uh[r[e]];return t}function hc(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}function uc(r){if(r>=ve._0&&r<=ve._9)return r-ve._0;if(r>=ve._A&&r<=ve._F)return r-(ve._A-10);if(r>=ve._a&&r<=ve._f)return r-(ve._a-10)}function dc(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let i=0,s=0;i<e;i++,s+=2){let o=uc(r.charCodeAt(s)),c=uc(r.charCodeAt(s+1));if(o===void 0||c===void 0){let u=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+s)}n[i]=o*16+c}return n}function pc(r){return hc(qn(r))}function _r(r){return Ks(r),hc(qn(Uint8Array.from(r).reverse()))}function Gs(r,t){return dc(r.toString(16).padStart(t*2,"0"))}function Yr(r,t){return Gs(r,t).reverse()}function ye(r,t,e){let n;if(typeof t=="string")try{n=dc(t)}catch(s){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${s}`)}else if(js(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let i=n.length;if(typeof e=="number"&&i!==e)throw new Error(`${r} expected ${e} bytes, got ${i}`);return n}function Ls(...r){let t=0;for(let n=0;n<r.length;n++){let i=r[n];Ks(i),t+=i.length}let e=new Uint8Array(t);for(let n=0,i=0;n<r.length;n++){let s=r[n];e.set(s,i),i+=s.length}return e}function fh(r,t,e){return Hs(r)&&Hs(t)&&Hs(e)&&t<=r&&r<e}function br(r,t,e,n){if(!fh(t,e,n))throw new Error(`expected valid ${r}: ${e} <= n < ${n}, got ${typeof t} ${t}`)}function yc(r){let t;for(t=0;r>fc;r>>=lc,t+=1);return t}function Er(r,t,e={}){let n=(i,s,o)=>{let c=lh[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);let u=r[i];if(!(o&&u===void 0)&&!c(u,r))throw new Error(`Invalid param ${String(i)}=${u} (${typeof u}), expected ${s}`)};for(let[i,s]of Object.entries(t))n(i,s,!1);for(let[i,s]of Object.entries(e))n(i,s,!0);return r}function Ws(r){let t=new WeakMap;return(e,...n)=>{let i=t.get(e);if(i!==void 0)return i;let s=r(e,...n);return t.set(e,s),s}}var fc,lc,ch,uh,ve,Hs,wc,lh,Xr=L(()=>{fc=BigInt(0),lc=BigInt(1),ch=BigInt(2);uh=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));ve={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};Hs=r=>typeof r=="bigint"&&fc<=r;wc=r=>(ch<<BigInt(r-1))-lc,lh={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"||js(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)}});function At(r,t){let e=r%t;return e>=Ut?e:t+e}function wh(r,t,e){if(e<=Ut||t<Ut)throw new Error("Expected power/modulo > 0");if(e===Et)return Ut;let n=Et;for(;t>Ut;)t&Et&&(n=n*r%e),r=r*r%e,t>>=Et;return n}function ce(r,t,e){let n=r;for(;t-- >Ut;)n*=n,n%=e;return n}function xc(r,t){if(r===Ut||t<=Ut)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=At(r,t),n=t,i=Ut,s=Et,o=Et,c=Ut;for(;e!==Ut;){let w=n/e,y=n%e,m=i-o*w,N=s-c*w;n=e,e=y,i=o,s=c,o=m,c=N}if(n!==Et)throw new Error("invert: does not exist");return At(i,t)}function gh(r){let t=(r-Et)/ze,e,n,i;for(e=r-Et,n=0;e%ze===Ut;e/=ze,n++);for(i=ze;i<r&&wh(i,t,r)!==r-Et;i++);if(n===1){let o=(r+Et)/Ds;return function(u,w){let y=u.pow(w,o);if(!u.eql(u.sqr(y),w))throw new Error("Cannot find square root");return y}}let s=(e+Et)/ze;return function(c,u){if(c.pow(u,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let w=n,y=c.pow(c.mul(c.ONE,i),e),m=c.pow(u,s),N=c.pow(u,e);for(;!c.eql(N,c.ONE);){if(c.eql(N,c.ZERO))return c.ZERO;let P=1;for(let K=c.sqr(N);P<w&&!c.eql(K,c.ONE);P++)K=c.sqr(K);let O=c.pow(y,Et<<BigInt(w-P-1));y=c.sqr(O),m=c.mul(m,O),N=c.mul(N,y),w=P}return m}}function mh(r){if(r%Ds===dh){let t=(r+Et)/Ds;return function(n,i){let s=n.pow(i,t);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(r%mc===gc){let t=(r-gc)/mc;return function(n,i){let s=n.mul(i,ze),o=n.pow(s,t),c=n.mul(i,o),u=n.mul(n.mul(c,ze),o),w=n.mul(c,n.sub(u,n.ONE));if(!n.eql(n.sqr(w),i))throw new Error("Cannot find square root");return w}}return r%yh,gh(r)}function bc(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=xh.reduce((n,i)=>(n[i]="function",n),t);return Er(r,e)}function _h(r,t,e){if(e<Ut)throw new Error("Expected power > 0");if(e===Ut)return r.ONE;if(e===Et)return t;let n=r.ONE,i=t;for(;e>Ut;)e&Et&&(n=r.mul(n,i)),i=r.sqr(i),e>>=Et;return n}function bh(r,t){let e=new Array(t.length),n=t.reduce((s,o,c)=>r.is0(o)?s:(e[c]=s,r.mul(s,o)),r.ONE),i=r.inv(n);return t.reduceRight((s,o,c)=>r.is0(o)?s:(e[c]=r.mul(s,e[c]),r.mul(s,o)),i),e}function zs(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Hn(r,t,e=!1,n={}){if(r<=Ut)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:i,nByteLength:s}=zs(r,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=mh(r),c=Object.freeze({ORDER:r,BITS:i,BYTES:s,MASK:wc(i),ZERO:Ut,ONE:Et,create:u=>At(u,r),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return Ut<=u&&u<r},is0:u=>u===Ut,isOdd:u=>(u&Et)===Et,neg:u=>At(-u,r),eql:(u,w)=>u===w,sqr:u=>At(u*u,r),add:(u,w)=>At(u+w,r),sub:(u,w)=>At(u-w,r),mul:(u,w)=>At(u*w,r),pow:(u,w)=>_h(c,u,w),div:(u,w)=>At(u*xc(w,r),r),sqrN:u=>u*u,addN:(u,w)=>u+w,subN:(u,w)=>u-w,mulN:(u,w)=>u*w,inv:u=>xc(u,r),sqrt:n.sqrt||(u=>o(c,u)),invertBatch:u=>bh(c,u),cmov:(u,w,y)=>y?w:u,toBytes:u=>e?Yr(u,s):Gs(u,s),fromBytes:u=>{if(u.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${u.length}`);return e?_r(u):pc(u)}});return Object.freeze(c)}var Ut,Et,ze,dh,Ds,gc,mc,ph,yh,_c,xh,jn=L(()=>{Xr();Ut=BigInt(0),Et=BigInt(1),ze=BigInt(2),dh=BigInt(3),Ds=BigInt(4),gc=BigInt(5),mc=BigInt(8),ph=BigInt(9),yh=BigInt(16);_c=(r,t)=>(At(r,t)&Et)===Et,xh=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"]});function vc(r,t){let e=(s,o)=>{let c=o.negate();return s?c:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error(`Wrong window size=${s}, should be [1..${t}]`)},i=s=>{n(s);let o=Math.ceil(t/s)+1,c=2**(s-1);return{windows:o,windowSize:c}};return{constTimeNegate:e,unsafeLadder(s,o){let c=r.ZERO,u=s;for(;o>Eh;)o&Ys&&(c=c.add(u)),u=u.double(),o>>=Ys;return c},precomputeWindow(s,o){let{windows:c,windowSize:u}=i(o),w=[],y=s,m=y;for(let N=0;N<c;N++){m=y,w.push(m);for(let P=1;P<u;P++)m=m.add(y),w.push(m);y=m.double()}return w},wNAF(s,o,c){let{windows:u,windowSize:w}=i(s),y=r.ZERO,m=r.BASE,N=BigInt(2**s-1),P=2**s,O=BigInt(s);for(let K=0;K<u;K++){let ft=K*w,D=Number(c&N);c>>=O,D>w&&(D-=P,c+=Ys);let Mt=ft,C=ft+Math.abs(D)-1,lt=K%2!==0,V=D<0;D===0?m=m.add(e(lt,o[Mt])):y=y.add(e(V,o[C]))}return{p:y,f:m}},wNAFCached(s,o,c){let u=Ec.get(s)||1,w=Xs.get(s);return w||(w=this.precomputeWindow(s,u),u!==1&&Xs.set(s,c(w))),this.wNAF(u,w,o)},setWindowSize(s,o){n(o),Ec.set(s,o),Xs.delete(s)}}}function Ac(r,t,e,n){if(!Array.isArray(e)||!Array.isArray(n)||n.length!==e.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((y,m)=>{if(!t.isValid(y))throw new Error(`wrong scalar at index ${m}`)}),e.forEach((y,m)=>{if(!(y instanceof r))throw new Error(`wrong point at index ${m}`)});let i=yc(BigInt(e.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<<s)-1,c=new Array(o+1).fill(r.ZERO),u=Math.floor((t.BITS-1)/s)*s,w=r.ZERO;for(let y=u;y>=0;y-=s){c.fill(r.ZERO);for(let N=0;N<n.length;N++){let P=n[N],O=Number(P>>BigInt(y)&BigInt(o));c[O]=c[O].add(e[N])}let m=r.ZERO;for(let N=c.length-1,P=r.ZERO;N>0;N--)P=P.add(c[N]),m=m.add(P);if(w=w.add(m),y!==0)for(let N=0;N<s;N++)w=w.double()}return w}function Tc(r){return bc(r.Fp),Er(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...zs(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Eh,Ys,Xs,Ec,Sc=L(()=>{jn();Xr();Eh=BigInt(0),Ys=BigInt(1),Xs=new WeakMap,Ec=new WeakMap});var Js=L(()=>{Gt()});var Kn=L(()=>{hr()});var Ah,Bc,jy,Gn,Ic,vr=L(()=>{Wr();ar();Kr();Gt();Dt();Js();Kn();Jr();(function(r){r[r.Empty=0]="Empty",r[r.Fork=1]="Fork",r[r.Labeled=2]="Labeled",r[r.Leaf=3]="Leaf",r[r.Pruned=4]="Pruned"})(Bc||(Bc={}));Ah=new WeakMap;jy=Kt("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100");(function(r){r.Unknown="unknown",r.Absent="absent",r.Found="found"})(Gn||(Gn={}));(function(r){r.Less="less",r.Greater="greater"})(Ic||(Ic={}))});var Ln=L(()=>{Dt();ar();vr();Gt();Wr();Kn()});function Oc(r,t=!1){return t?{h:Number(r&Wn),l:Number(r>>Zs&Wn)}:{h:Number(r>>Zs&Wn)|0,l:Number(r&Wn)|0}}function Sh(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){let{h:s,l:o}=Oc(r[i],t);[e[i],n[i]]=[s,o]}return[e,n]}function qh(r,t,e,n){let i=(t>>>0)+(n>>>0);return{h:r+e+(i/2**32|0)|0,l:i|0}}var Wn,Zs,Bh,Ih,Nh,Rh,Uh,Fh,Oh,kh,Ph,Mh,Ch,$h,Vh,Hh,jh,Kh,Gh,Lh,Wh,Dh,W,kc=L(()=>{Wn=BigInt(4294967295),Zs=BigInt(32);Bh=(r,t)=>BigInt(r>>>0)<<Zs|BigInt(t>>>0),Ih=(r,t,e)=>r>>>e,Nh=(r,t,e)=>r<<32-e|t>>>e,Rh=(r,t,e)=>r>>>e|t<<32-e,Uh=(r,t,e)=>r<<32-e|t>>>e,Fh=(r,t,e)=>r<<64-e|t>>>e-32,Oh=(r,t,e)=>r>>>e-32|t<<64-e,kh=(r,t)=>t,Ph=(r,t)=>r,Mh=(r,t,e)=>r<<e|t>>>32-e,Ch=(r,t,e)=>t<<e|r>>>32-e,$h=(r,t,e)=>t<<e-32|r>>>64-e,Vh=(r,t,e)=>r<<e-32|t>>>64-e;Hh=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),jh=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Kh=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Gh=(r,t,e,n,i)=>t+e+n+i+(r/2**32|0)|0,Lh=(r,t,e,n,i)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(i>>>0),Wh=(r,t,e,n,i,s)=>t+e+n+i+s+(r/2**32|0)|0,Dh={fromBig:Oc,split:Sh,toBig:Bh,shrSH:Ih,shrSL:Nh,rotrSH:Rh,rotrSL:Uh,rotrBH:Fh,rotrBL:Oh,rotr32H:kh,rotr32L:Ph,rotlSH:Mh,rotlSL:Ch,rotlBH:$h,rotlBL:Vh,add:qh,add3L:Hh,add3H:jh,add4L:Kh,add4H:Gh,add5H:Wh,add5L:Lh},W=Dh});var zh,Yh,Oe,ke,Qs,Pc,Mc=L(()=>{ki();kc();kr();[zh,Yh]=W.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Oe=new Uint32Array(80),ke=new Uint32Array(80),Qs=class extends sr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:i,Ch:s,Cl:o,Dh:c,Dl:u,Eh:w,El:y,Fh:m,Fl:N,Gh:P,Gl:O,Hh:K,Hl:ft}=this;return[t,e,n,i,s,o,c,u,w,y,m,N,P,O,K,ft]}set(t,e,n,i,s,o,c,u,w,y,m,N,P,O,K,ft){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=c|0,this.Dl=u|0,this.Eh=w|0,this.El=y|0,this.Fh=m|0,this.Fl=N|0,this.Gh=P|0,this.Gl=O|0,this.Hh=K|0,this.Hl=ft|0}process(t,e){for(let C=0;C<16;C++,e+=4)Oe[C]=t.getUint32(e),ke[C]=t.getUint32(e+=4);for(let C=16;C<80;C++){let lt=Oe[C-15]|0,V=ke[C-15]|0,q=W.rotrSH(lt,V,1)^W.rotrSH(lt,V,8)^W.shrSH(lt,V,7),nt=W.rotrSL(lt,V,1)^W.rotrSL(lt,V,8)^W.shrSL(lt,V,7),Z=Oe[C-2]|0,R=ke[C-2]|0,ot=W.rotrSH(Z,R,19)^W.rotrBH(Z,R,61)^W.shrSH(Z,R,6),et=W.rotrSL(Z,R,19)^W.rotrBL(Z,R,61)^W.shrSL(Z,R,6),st=W.add4L(nt,et,ke[C-7],ke[C-16]),wt=W.add4H(st,q,ot,Oe[C-7],Oe[C-16]);Oe[C]=wt|0,ke[C]=st|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:c,Cl:u,Dh:w,Dl:y,Eh:m,El:N,Fh:P,Fl:O,Gh:K,Gl:ft,Hh:D,Hl:Mt}=this;for(let C=0;C<80;C++){let lt=W.rotrSH(m,N,14)^W.rotrSH(m,N,18)^W.rotrBH(m,N,41),V=W.rotrSL(m,N,14)^W.rotrSL(m,N,18)^W.rotrBL(m,N,41),q=m&P^~m&K,nt=N&O^~N&ft,Z=W.add5L(Mt,V,nt,Yh[C],ke[C]),R=W.add5H(Z,D,lt,q,zh[C],Oe[C]),ot=Z|0,et=W.rotrSH(n,i,28)^W.rotrBH(n,i,34)^W.rotrBH(n,i,39),st=W.rotrSL(n,i,28)^W.rotrBL(n,i,34)^W.rotrBL(n,i,39),wt=n&s^n&c^s&c,It=i&o^i&u^o&u;D=K|0,Mt=ft|0,K=P|0,ft=O|0,P=m|0,O=N|0,{h:m,l:N}=W.add(w|0,y|0,R|0,ot|0),w=c|0,y=u|0,c=s|0,u=o|0,s=n|0,o=i|0;let Ct=W.add3L(ot,st,It);n=W.add3H(Ct,R,et,wt),i=Ct|0}({h:n,l:i}=W.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=W.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:c,l:u}=W.add(this.Ch|0,this.Cl|0,c|0,u|0),{h:w,l:y}=W.add(this.Dh|0,this.Dl|0,w|0,y|0),{h:m,l:N}=W.add(this.Eh|0,this.El|0,m|0,N|0),{h:P,l:O}=W.add(this.Fh|0,this.Fl|0,P|0,O|0),{h:K,l:ft}=W.add(this.Gh|0,this.Gl|0,K|0,ft|0),{h:D,l:Mt}=W.add(this.Hh|0,this.Hl|0,D|0,Mt|0),this.set(n,i,s,o,c,u,w,y,m,N,P,O,K,ft,D,Mt)}roundClean(){Oe.fill(0),ke.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Pc=Or(()=>new Qs)});function Zh(r){let t=Tc(r);return Er(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Cc(r){let t=Zh(r),{Fp:e,n,prehash:i,hash:s,randomBytes:o,nByteLength:c,h:u}=t,w=Dn<<BigInt(c*8)-Wt,y=e.create,m=Hn(t.n,t.nBitLength),N=t.uvRatio||((j,U)=>{try{return{isValid:!0,value:e.sqrt(j*e.inv(U))}}catch{return{isValid:!1,value:ue}}}),P=t.adjustScalarBytes||(j=>j),O=t.domain||((j,U,k)=>{if(Vn("phflag",k),U.length||k)throw new Error("Contexts/pre-hash are not supported");return j});function K(j,U){br("coordinate "+j,U,ue,w)}function ft(j){if(!(j instanceof C))throw new Error("ExtendedPoint expected")}let D=Ws((j,U)=>{let{ex:k,ey:G,ez:Y}=j,z=j.is0();U==null&&(U=z?Xh:e.inv(Y));let it=y(k*U),B=y(G*U),h=y(Y*U);if(z)return{x:ue,y:Wt};if(h!==Wt)throw new Error("invZ was invalid");return{x:it,y:B}}),Mt=Ws(j=>{let{a:U,d:k}=t;if(j.is0())throw new Error("bad point: ZERO");let{ex:G,ey:Y,ez:z,et:it}=j,B=y(G*G),h=y(Y*Y),ct=y(z*z),gt=y(ct*ct),ut=y(B*U),M=y(ct*y(ut+h)),a=y(gt+y(k*y(B*h)));if(M!==a)throw new Error("bad point: equation left != right (1)");let f=y(G*Y),l=y(z*it);if(f!==l)throw new Error("bad point: equation left != right (2)");return!0});class C{constructor(U,k,G,Y){this.ex=U,this.ey=k,this.ez=G,this.et=Y,K("x",U),K("y",k),K("z",G),K("t",Y),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(U){if(U instanceof C)throw new Error("extended point not allowed");let{x:k,y:G}=U||{};return K("x",k),K("y",G),new C(k,G,Wt,y(k*G))}static normalizeZ(U){let k=e.invertBatch(U.map(G=>G.ez));return U.map((G,Y)=>G.toAffine(k[Y])).map(C.fromAffine)}static msm(U,k){return Ac(C,m,U,k)}_setWindowSize(U){q.setWindowSize(this,U)}assertValidity(){Mt(this)}equals(U){ft(U);let{ex:k,ey:G,ez:Y}=this,{ex:z,ey:it,ez:B}=U,h=y(k*B),ct=y(z*Y),gt=y(G*B),ut=y(it*Y);return h===ct&>===ut}is0(){return this.equals(C.ZERO)}negate(){return new C(y(-this.ex),this.ey,this.ez,y(-this.et))}double(){let{a:U}=t,{ex:k,ey:G,ez:Y}=this,z=y(k*k),it=y(G*G),B=y(Dn*y(Y*Y)),h=y(U*z),ct=k+G,gt=y(y(ct*ct)-z-it),ut=h+it,M=ut-B,a=h-it,f=y(gt*M),l=y(ut*a),b=y(gt*a),g=y(M*ut);return new C(f,l,g,b)}add(U){ft(U);let{a:k,d:G}=t,{ex:Y,ey:z,ez:it,et:B}=this,{ex:h,ey:ct,ez:gt,et:ut}=U;if(k===BigInt(-1)){let I=y((z-Y)*(ct+h)),F=y((z+Y)*(ct-h)),$=y(F-I);if($===ue)return this.double();let J=y(it*Dn*ut),dt=y(B*Dn*gt),mt=dt+J,X=F+I,H=dt-J,Tt=y(mt*$),Ae=y(X*H),Ve=y(mt*H),qe=y($*X);return new C(Tt,Ae,qe,Ve)}let M=y(Y*h),a=y(z*ct),f=y(B*G*ut),l=y(it*gt),b=y((Y+z)*(h+ct)-M-a),g=l-f,_=l+f,A=y(a-k*M),d=y(b*g),x=y(_*A),v=y(b*A),E=y(g*_);return new C(d,x,E,v)}subtract(U){return this.add(U.negate())}wNAF(U){return q.wNAFCached(this,U,C.normalizeZ)}multiply(U){let k=U;br("scalar",k,Wt,n);let{p:G,f:Y}=this.wNAF(k);return C.normalizeZ([G,Y])[0]}multiplyUnsafe(U){let k=U;return br("scalar",k,ue,n),k===ue?V:this.equals(V)||k===Wt?this:this.equals(lt)?this.wNAF(k).p:q.unsafeLadder(this,k)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return q.unsafeLadder(this,n).is0()}toAffine(U){return D(this,U)}clearCofactor(){let{h:U}=t;return U===Wt?this:this.multiplyUnsafe(U)}static fromHex(U,k=!1){let{d:G,a:Y}=t,z=e.BYTES;U=ye("pointHex",U,z),Vn("zip215",k);let it=U.slice(),B=U[z-1];it[z-1]=B&-129;let h=_r(it),ct=k?w:e.ORDER;br("pointHex.y",h,ue,ct);let gt=y(h*h),ut=y(gt-Wt),M=y(G*gt-Y),{isValid:a,value:f}=N(ut,M);if(!a)throw new Error("Point.fromHex: invalid y coordinate");let l=(f&Wt)===Wt,b=(B&128)!==0;if(!k&&f===ue&&b)throw new Error("Point.fromHex: x=0 and x_0=1");return b!==l&&(f=y(-f)),C.fromAffine({x:f,y:h})}static fromPrivateKey(U){return R(U).point}toRawBytes(){let{x:U,y:k}=this.toAffine(),G=Yr(k,e.BYTES);return G[G.length-1]|=U&Wt?128:0,G}toHex(){return qn(this.toRawBytes())}}C.BASE=new C(t.Gx,t.Gy,Wt,y(t.Gx*t.Gy)),C.ZERO=new C(ue,Wt,Wt,ue);let{BASE:lt,ZERO:V}=C,q=vc(C,c*8);function nt(j){return At(j,n)}function Z(j){return nt(_r(j))}function R(j){let U=c;j=ye("private key",j,U);let k=ye("hashed private key",s(j),2*U),G=P(k.slice(0,U)),Y=k.slice(U,2*U),z=Z(G),it=lt.multiply(z),B=it.toRawBytes();return{head:G,prefix:Y,scalar:z,point:it,pointBytes:B}}function ot(j){return R(j).pointBytes}function et(j=new Uint8Array,...U){let k=Ls(...U);return Z(s(O(k,ye("context",j),!!i)))}function st(j,U,k={}){j=ye("message",j),i&&(j=i(j));let{prefix:G,scalar:Y,pointBytes:z}=R(U),it=et(k.context,G,j),B=lt.multiply(it).toRawBytes(),h=et(k.context,B,z,j),ct=nt(it+h*Y);br("signature.s",ct,ue,n);let gt=Ls(B,Yr(ct,e.BYTES));return ye("result",gt,c*2)}let wt=Jh;function It(j,U,k,G=wt){let{context:Y,zip215:z}=G,it=e.BYTES;j=ye("signature",j,2*it),U=ye("message",U),z!==void 0&&Vn("zip215",z),i&&(U=i(U));let B=_r(j.slice(it,2*it)),h,ct,gt;try{h=C.fromHex(k,z),ct=C.fromHex(j.slice(0,it),z),gt=lt.multiplyUnsafe(B)}catch{return!1}if(!z&&h.isSmallOrder())return!1;let ut=et(Y,ct.toRawBytes(),h.toRawBytes(),U);return ct.add(h.multiplyUnsafe(ut)).subtract(gt).clearCofactor().equals(C.ZERO)}return lt._setWindowSize(8),{CURVE:t,getPublicKey:ot,sign:st,verify:It,ExtendedPoint:C,utils:{getExtendedPublicKey:R,randomPrivateKey:()=>o(e.BYTES),precompute(j=8,U=C.BASE){return U._setWindowSize(j),U.multiply(BigInt(3)),U}}}}var ue,Wt,Dn,Xh,Jh,$c=L(()=>{Sc();jn();Xr();Xr();ue=BigInt(0),Wt=BigInt(1),Dn=BigInt(2),Xh=BigInt(8),Jh={zip215:!0}});function r0(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),i=BigInt(80),s=to,c=r*r%s*r%s,u=ce(c,qc,s)*c%s,w=ce(u,Qh,s)*r%s,y=ce(w,t0,s)*w%s,m=ce(y,t,s)*y%s,N=ce(m,e,s)*m%s,P=ce(N,n,s)*N%s,O=ce(P,i,s)*P%s,K=ce(O,i,s)*P%s,ft=ce(K,t,s)*y%s;return{pow_p_5_8:ce(ft,qc,s)*r%s,b2:c}}function n0(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function i0(r,t){let e=to,n=At(t*t*t,e),i=At(n*n*t,e),s=r0(r*i).pow_p_5_8,o=At(r*n*s,e),c=At(t*o*o,e),u=o,w=At(o*Vc,e),y=c===r,m=c===At(-r,e),N=c===At(-r*Vc,e);return y&&(o=u),(m||N)&&(o=w),_c(o,e)&&(o=At(-o,e)),{isValid:y||m,value:o}}var to,Vc,pw,Qh,qc,yw,t0,e0,s0,o0,Ar,Hc=L(()=>{Mc();kr();$c();jn();to=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Vc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),pw=BigInt(0),Qh=BigInt(1),qc=BigInt(2),yw=BigInt(3),t0=BigInt(5),e0=BigInt(8);s0=Hn(to,void 0,!0),o0={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:s0,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:e0,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Pc,randomBytes:Do,adjustScalarBytes:n0,uvRatio:i0},Ar=Cc(o0)});var a0,c0,u0,f0,jc=L(()=>{a0=new WeakMap,c0=new WeakMap,u0=Symbol.iterator,f0=Symbol.toStringTag});function Tr(r,t){let e=2+Kc(r.byteLength+1),n=t.byteLength+e+r.byteLength,i=0,s=new Uint8Array(1+Kc(n)+n);return s[i++]=48,i+=Gc(s,i,n),s.set(t,i),i+=t.byteLength,s[i++]=3,i+=Gc(s,i,r.byteLength+1),s[i++]=0,s.set(new Uint8Array(r),i),s}var Kc,Gc,eo,l0,Lc,Ye,xw,Zr,ro=L(()=>{Gt();Kc=r=>{if(r<=127)return 1;if(r<=255)return 2;if(r<=65535)return 3;if(r<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},Gc=(r,t,e)=>{if(e<=127)return r[t]=e,1;if(e<=255)return r[t]=129,r[t+1]=e,2;if(e<=65535)return r[t]=130,r[t+1]=e>>8,r[t+2]=e,3;if(e<=16777215)return r[t]=131,r[t+1]=e>>16,r[t+2]=e>>8,r[t+3]=e,4;throw new Error("Length too long (> 4 bytes)")},eo=(r,t)=>{if(r[t]<128)return 1;if(r[t]===128)throw new Error("Invalid length 0");if(r[t]===129)return 2;if(r[t]===130)return 3;if(r[t]===131)return 4;throw new Error("Length too long (> 4 bytes)")},l0=(r,t)=>{let e=eo(r,t);if(e===1)return r[t];if(e===2)return r[t+1];if(e===3)return(r[t+1]<<8)+r[t+2];if(e===4)return(r[t+1]<<16)+(r[t+2]<<8)+r[t+3];throw new Error("Length too long (> 4 bytes)")},Lc=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),Ye=Uint8Array.from([48,5,6,3,43,101,112]),xw=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);Zr=(r,t)=>{let e=0,n=(c,u)=>{if(i[e++]!==c)throw new Error("Expected: "+u)},i=new Uint8Array(r);if(n(48,"sequence"),e+=eo(i,e),!or(i.slice(e,e+t.byteLength),t))throw new Error("Not the expected OID.");e+=t.byteLength,n(3,"bit string");let s=l0(i,e)-1;e+=eo(i,e),n(0,"0 padding");let o=i.slice(e);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o}});var Wc,Dc,zn,Yn,Xn,no=L(()=>{ro();Wc=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},Dc=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Xn=class r{constructor(t){if(zn.set(this,void 0),Yn.set(this,void 0),t.byteLength!==r.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Wc(this,zn,t,"f"),Wc(this,Yn,r.derEncode(t),"f")}static from(t){return this.fromDer(t.toDer())}static fromRaw(t){return new r(t)}static fromDer(t){return new r(this.derDecode(t))}static derEncode(t){return Tr(t,Ye).buffer}static derDecode(t){let e=Zr(t,Ye);if(e.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return e}get rawKey(){return Dc(this,zn,"f")}get derKey(){return Dc(this,Yn,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};zn=new WeakMap,Yn=new WeakMap;Xn.RAW_KEY_LENGTH=32});var io=L(()=>{});var we,$t,ge,Jn,Zn,Qn,ti,ei,ri,ni,Sr,ii,zc=L(()=>{we=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},$t=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},ii=class r{constructor(t=r.default){ge.set(this,void 0),Jn.set(this,void 0),Zn.set(this,void 0),Qn.set(this,void 0),ti.set(this,void 0),ei.set(this,void 0),ri.set(this,void 0),ni.set(this,void 0),Sr.set(this,0);let{initialInterval:e=500,randomizationFactor:n=.5,multiplier:i=1.5,maxInterval:s=6e4,maxElapsedTime:o=9e5,maxIterations:c=10,date:u=Date}=t;we(this,ge,e,"f"),we(this,Jn,n,"f"),we(this,Zn,i,"f"),we(this,Qn,s,"f"),we(this,ni,u,"f"),we(this,ti,u.now(),"f"),we(this,ei,o,"f"),we(this,ri,c,"f")}get ellapsedTimeInMsec(){return $t(this,ni,"f").now()-$t(this,ti,"f")}get currentInterval(){return $t(this,ge,"f")}get count(){return $t(this,Sr,"f")}get randomValueFromInterval(){let t=$t(this,Jn,"f")*$t(this,ge,"f"),e=$t(this,ge,"f")-t,n=$t(this,ge,"f")+t;return Math.random()*(n-e)+e}incrementCurrentInterval(){var t;return we(this,ge,Math.min($t(this,ge,"f")*$t(this,Zn,"f"),$t(this,Qn,"f")),"f"),we(this,Sr,(t=$t(this,Sr,"f"),t++,t),"f"),$t(this,ge,"f")}next(){return this.ellapsedTimeInMsec>=$t(this,ei,"f")||$t(this,Sr,"f")>=$t(this,ri,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};ge=new WeakMap,Jn=new WeakMap,Zn=new WeakMap,Qn=new WeakMap,ti=new WeakMap,ei=new WeakMap,ri=new WeakMap,ni=new WeakMap,Sr=new WeakMap;ii.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date}});var Vt,Qr,d0,so,p0,Yc,Xc,y0,w0,g0,Pe,m0,x0,_0,b0,E0,v0,Jc,A0,T0,S0,B0,oo,Yw,ao=L(()=>{Dt();ar();Is();Wr();Kr();Gt();Cn();Dr();$n();Ln();vr();jc();no();Kn();io();zc();Cn();$n();Dr();Vt=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)};(function(r){r.Received="received",r.Processing="processing",r.Replied="replied",r.Rejected="rejected",r.Unknown="unknown",r.Done="done"})(oo||(oo={}));Yw=60*1e3;d0=new WeakMap,so=new WeakMap,p0=new WeakMap,Yc=new WeakMap,Xc=new WeakMap,y0=new WeakMap,w0=new WeakMap,g0=new WeakMap,Pe=new WeakMap,m0=new WeakMap,x0=new WeakMap,_0=new WeakMap,b0=new WeakMap,E0=new WeakMap,v0=new WeakMap,Jc=new WeakMap,S0=new WeakMap,Qr=new WeakSet,A0=async function r(t){var e,n;let{ecid:i,transformedRequest:s,body:o,requestId:c,backoff:u,tries:w}=t,y=w===0?0:u.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:w,backoff:u,delay:y}),y===null)throw new zt(`Timestamp failed to pass the watermark after retrying the configured ${Vt(this,Pe,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);y>0&&await new Promise(O=>setTimeout(O,y));let m;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let O=await Vt(this,Yc,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},Vt(this,Xc,"f")),s.request),{body:o}));if(O.status===200){let K=Pn(await O.arrayBuffer());m=Object.assign(Object.assign({},K),{httpDetails:{ok:O.ok,status:O.status,statusText:O.statusText,headers:zr(O.headers)},requestId:c})}else throw new xr(`Gateway returned an error:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
${
|
|
7
|
-
|
|
8
|
-
${
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Body: ${c}
|
|
12
|
-
`;if(o.status===404&&o.url.includes("api/v3"))throw new xr("v3 api not supported. Fall back to v2",{ok:o.ok,status:o.status,statusText:o.statusText,headers:zr(o.headers)});if(i<Vt(this,Pe,"f"))return await Vt(this,Qr,"m",r).call(this,{request:e,backoff:n,tries:i+1});throw new xr(u,{ok:o.ok,status:o.status,statusText:o.statusText,headers:zr(o.headers)})},B0=async function(){if(!this.rootKey)if(this.rootKey===null&&Vt(this,so,"f"))await this.fetchRootKey();else throw new zt(`Invalid root key detected. The root key for this agent is ${this.rootKey} and the shouldFetchRootKey value is set to ${Vt(this,so,"f")}. The root key should only be unknown if you are in local development. Otherwise you should avoid fetching and use the default IC Root Key or the known root key of your environment.`)}});var Zc,Qc=L(()=>{Dt();(function(r){r.Error="err",r.GetPrincipal="gp",r.GetPrincipalResponse="gpr",r.Query="q",r.QueryResponse="qr",r.Call="c",r.CallResponse="cr",r.ReadState="rs",r.ReadStateResponse="rsr",r.Status="s",r.StatusResponse="sr"})(Zc||(Zc={}))});var Jr=L(()=>{Ni();ao();$n();Qc()});var F0=Te($o());Jr();ar();hr();Jr();vr();Gt();var si={};Xu(si,{backoff:()=>nu,chain:()=>iu,conditionalDelay:()=>eu,defaultStrategy:()=>co,maxAttempts:()=>N0,once:()=>tu,throttle:()=>R0,timeout:()=>ru});Gt();var I0=300*1e3;function co(){return iu(eu(tu(),1e3),nu(1e3,1.2),ru(I0))}function tu(){let r=!0;return async()=>r?(r=!1,!0):!1}function eu(r,t){return async(e,n,i)=>{if(await r(e,n,i))return new Promise(s=>setTimeout(s,t))}}function N0(r){let t=r;return async(e,n,i)=>{if(--t<=0)throw new Error(`Failed to retrieve a reply for request after ${r} attempts:
|
|
13
|
-
Request ID: ${bt(n)}
|
|
14
|
-
Request status: ${i}
|
|
15
|
-
`)}}function R0(r){return()=>new Promise(t=>setTimeout(t,r))}function ru(r){let t=Date.now()+r;return async(e,n,i)=>{if(Date.now()>t)throw new Error(`Request timed out after ${r} msec:
|
|
16
|
-
Request ID: ${bt(n)}
|
|
17
|
-
Request status: ${i}
|
|
18
|
-
`)}}function nu(r,t){let e=r;return()=>new Promise(n=>setTimeout(()=>{e*=t,n()},e))}function iu(...r){return async(t,e,n)=>{for(let i of r)await i(t,e,n)}}Dt();Gt();vr();var Tg=Symbol.for("ic-agent-metadata");var Sg={pollingStrategyFactory:si.defaultStrategy};Jr();Cn();Dr();Is();vr();ro();Dt();Ln();ao();io();no();Kr();Js();Gt();Vs();Ln();Wr();Hc();var ci=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},Me=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},oi,ai,Br,Ir;function su(r){return r!==null&&typeof r=="object"}var Xe=class r{constructor(t){if(oi.set(this,void 0),ai.set(this,void 0),t.byteLength!==r.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");ci(this,oi,t,"f"),ci(this,ai,r.derEncode(t),"f")}static from(t){if(typeof t=="string"){let e=Kt(t);return this.fromRaw(e)}else if(su(t)){let e=t;if(su(e)&&Object.hasOwnProperty.call(e,"__derEncodedPublicKey__"))return this.fromDer(e);if(ArrayBuffer.isView(e)){let n=e;return this.fromRaw(xn(n.buffer))}else{if(e instanceof ArrayBuffer)return this.fromRaw(e);if("rawKey"in e)return this.fromRaw(e.rawKey);if("derKey"in e)return this.fromDer(e.derKey);if("toDer"in e)return this.fromDer(e.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(t){return new r(t)}static fromDer(t){return new r(this.derDecode(t))}static derEncode(t){let e=Tr(t,Ye).buffer;return e.__derEncodedPublicKey__=void 0,e}static derDecode(t){let e=Zr(t,Ye);if(e.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return e}get rawKey(){return Me(this,oi,"f")}get derKey(){return Me(this,ai,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};oi=new WeakMap,ai=new WeakMap;Xe.RAW_KEY_LENGTH=32;var Je=class r extends be{constructor(t,e){super(),Br.set(this,void 0),Ir.set(this,void 0),ci(this,Br,Xe.from(t),"f"),ci(this,Ir,new Uint8Array(e),"f")}static generate(t){if(t&&t.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");t||(t=Ar.utils.randomPrivateKey()),or(t,new Uint8Array(new Array(32).fill(0)))&&console.warn("Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.");let e=new Uint8Array(32);for(let i=0;i<32;i++)e[i]=new Uint8Array(t)[i];let n=Ar.getPublicKey(e);return r.fromKeyPair(n,e)}static fromParsedJson(t){let[e,n]=t;return new r(Xe.fromDer(Kt(e)),Kt(n))}static fromJSON(t){let e=JSON.parse(t);if(Array.isArray(e)){if(typeof e[0]=="string"&&typeof e[1]=="string")return this.fromParsedJson([e[0],e[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(t)}`)}static fromKeyPair(t,e){return new r(Xe.fromRaw(t),e)}static fromSecretKey(t){let e=Ar.getPublicKey(new Uint8Array(t));return r.fromKeyPair(e,t)}toJSON(){return[bt(Me(this,Br,"f").toDer()),bt(Me(this,Ir,"f"))]}getKeyPair(){return{secretKey:Me(this,Ir,"f"),publicKey:Me(this,Br,"f")}}getPublicKey(){return Me(this,Br,"f")}async sign(t){let e=new Uint8Array(t),n=Ge(Ar.sign(e,Me(this,Ir,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(t,e,n){let[i,s,o]=[t,e,n].map(c=>(typeof c=="string"&&(c=Kt(c)),c instanceof Uint8Array&&(c=c.buffer),new Uint8Array(c)));return Ar.verify(s,i,o)}};Br=new WeakMap,Ir=new WeakMap;var uo=class r extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,r.prototype)}};function ou(r){if(typeof global<"u"&&global.crypto&&global.crypto.subtle)return global.crypto.subtle;if(r)return r;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new uo("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var tn=class r extends be{constructor(t,e,n){super(),this._keyPair=t,this._derKey=e,this._subtleCrypto=n}static async generate(t){let{extractable:e=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=t??{},s=ou(i),o=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},e,n),c=await s.exportKey("spki",o.publicKey);return new this(o,c,s)}static async fromKeyPair(t,e){let n=ou(e),i=await n.exportKey("spki",t.publicKey);return new r(t,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let t=this._derKey,e=Object.create(this._keyPair.publicKey);return e.toDer=function(){return t},e}async sign(t){let e={name:"ECDSA",hash:{name:"SHA-256"}};return await this._subtleCrypto.sign(e,this._keyPair.privateKey,t)}};Dt();var Nr=Te(Lr());Dt();var k0=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},en=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Ce,ui=class{constructor(t){Ce.set(this,void 0),k0(this,Ce,t,"f")}get rawKey(){return en(this,Ce,"f").rawKey}get derKey(){return en(this,Ce,"f").derKey}toDer(){return en(this,Ce,"f").toDer()}getPublicKey(){return en(this,Ce,"f")}getPrincipal(){return vt.from(en(this,Ce,"f").rawKey)}transformRequest(){return Promise.reject("Not implemented. You are attempting to use a partial identity to sign calls, but this identity only has access to the public key.To sign calls, use a DelegationIdentity instead.")}};Ce=new WeakMap;var P0=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},M0=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},C0=function(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(e[n[i]]=r[n[i]]);return e},fi,$0=new TextEncoder().encode("ic-request-auth-delegation"),V0=new TextEncoder().encode(`
|
|
19
|
-
ic-request`);function fo(r){if(typeof r!="string"||r.length<64)throw new Error("Invalid public key.");return Kt(r)}var Rr=class{constructor(t,e,n){this.pubkey=t,this.expiration=e,this.targets=n}toCBOR(){return Nr.value.map(Object.assign({pubkey:Nr.value.bytes(this.pubkey),expiration:Nr.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Nr.value.array(this.targets.map(t=>Nr.value.bytes(t.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:bt(this.pubkey)},this.targets&&{targets:this.targets.map(t=>t.toHex())})}};async function q0(r,t,e,n){let i=new Rr(t.toDer(),BigInt(+e)*BigInt(1e6),n),s=new Uint8Array([...$0,...new Uint8Array(gr(Object.assign({},i)))]),o=await r.sign(s);return{delegation:i,signature:o}}var Ze=class r{constructor(t,e){this.delegations=t,this.publicKey=e}static async create(t,e,n=new Date(Date.now()+900*1e3),i={}){var s,o;let c=await q0(t,e,n,i.targets);return new r([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],c],((o=i.previous)===null||o===void 0?void 0:o.publicKey)||t.getPublicKey().toDer())}static fromJSON(t){let{publicKey:e,delegations:n}=typeof t=="string"?JSON.parse(t):t;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:o,signature:c}=s,{pubkey:u,expiration:w,targets:y}=o;if(y!==void 0&&!Array.isArray(y))throw new Error("Invalid targets.");return{delegation:new Rr(fo(u),BigInt("0x"+w),y&&y.map(m=>{if(typeof m!="string")throw new Error("Invalid target.");return vt.fromHex(m)})),signature:fo(c)}});return new this(i,fo(e))}static fromDelegations(t,e){return new this(t,e)}toJSON(){return{delegations:this.delegations.map(t=>{let{delegation:e,signature:n}=t,{targets:i}=e;return{delegation:Object.assign({expiration:e.expiration.toString(16),pubkey:bt(e.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:bt(n)}}),publicKey:bt(this.publicKey)}}},rn=class extends be{constructor(t,e){super(),this._inner=t,this._delegation=e}static fromDelegation(t,e){return new this(t,e)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(t){return this._inner.sign(t)}async transformRequest(t){let{body:e}=t,n=C0(t,["body"]),i=await gr(e);return Object.assign(Object.assign({},n),{body:{content:e,sender_sig:await this.sign(new Uint8Array([...V0,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},nn=class r extends ui{constructor(t,e){super(t),fi.set(this,void 0),P0(this,fi,e,"f")}get delegation(){return M0(this,fi,"f")}static fromDelegation(t,e){return new r(t,e)}};fi=new WeakMap;function li(r,t){for(let{delegation:i}of r.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let e=[],n=t?.scope;n&&(Array.isArray(n)?e.push(...n.map(i=>typeof i=="string"?vt.fromText(i):i)):e.push(typeof n=="string"?vt.fromText(n):n));for(let i of e){let s=i.toText();for(let{delegation:o}of r.delegations){if(o.targets===void 0)continue;let c=!0;for(let u of o.targets)if(u.toText()===s){c=!1;break}if(c)return!1}}return!0}var H0=Te(Nn());hr();var au;(function(r){r[r.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(au||(au={}));var cu=["mousedown","mousemove","keydown","touchstart","wheel"],sn=class{constructor(t={}){var e;this.callbacks=[],this.idleTimeout=600*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=600*1e3}=t||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let s=this._resetTimer.bind(this);window.addEventListener("load",s,!0),cu.forEach(function(c){document.addEventListener(c,s,!0)});let o=(c,u)=>{let w;return(...y)=>{let m=this,N=function(){w=void 0,c.apply(m,y)};clearTimeout(w),w=window.setTimeout(N,u)}};if(t?.captureScroll){let c=o(s,(e=t?.scrollDebounce)!==null&&e!==void 0?e:100);window.addEventListener("scroll",c,!0)}s()}static create(t={}){return new this(t)}registerCallback(t){this.callbacks.push(t)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let t=this._resetTimer.bind(this);cu.forEach(function(e){document.removeEventListener(e,t,!0)}),this.callbacks.forEach(e=>e())}_resetTimer(){let t=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(t,this.idleTimeout)}};var j0=(r,t)=>t.some(e=>r instanceof e),uu,fu;function K0(){return uu||(uu=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function G0(){return fu||(fu=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var lu=new WeakMap,ho=new WeakMap,hu=new WeakMap,lo=new WeakMap,yo=new WeakMap;function L0(r){let t=new Promise((e,n)=>{let i=()=>{r.removeEventListener("success",s),r.removeEventListener("error",o)},s=()=>{e(me(r.result)),i()},o=()=>{n(r.error),i()};r.addEventListener("success",s),r.addEventListener("error",o)});return t.then(e=>{e instanceof IDBCursor&&lu.set(e,r)}).catch(()=>{}),yo.set(t,r),t}function W0(r){if(ho.has(r))return;let t=new Promise((e,n)=>{let i=()=>{r.removeEventListener("complete",s),r.removeEventListener("error",o),r.removeEventListener("abort",o)},s=()=>{e(),i()},o=()=>{n(r.error||new DOMException("AbortError","AbortError")),i()};r.addEventListener("complete",s),r.addEventListener("error",o),r.addEventListener("abort",o)});ho.set(r,t)}var po={get(r,t,e){if(r instanceof IDBTransaction){if(t==="done")return ho.get(r);if(t==="objectStoreNames")return r.objectStoreNames||hu.get(r);if(t==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return me(r[t])},set(r,t,e){return r[t]=e,!0},has(r,t){return r instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in r}};function du(r){po=r(po)}function D0(r){return r===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...e){let n=r.call(hi(this),t,...e);return hu.set(n,t.sort?t.sort():[t]),me(n)}:G0().includes(r)?function(...t){return r.apply(hi(this),t),me(lu.get(this))}:function(...t){return me(r.apply(hi(this),t))}}function z0(r){return typeof r=="function"?D0(r):(r instanceof IDBTransaction&&W0(r),j0(r,K0())?new Proxy(r,po):r)}function me(r){if(r instanceof IDBRequest)return L0(r);if(lo.has(r))return lo.get(r);let t=z0(r);return t!==r&&(lo.set(r,t),yo.set(t,r)),t}var hi=r=>yo.get(r);function yu(r,t,{blocked:e,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(r,t),c=me(o);return n&&o.addEventListener("upgradeneeded",u=>{n(me(o.result),u.oldVersion,u.newVersion,me(o.transaction),u)}),e&&o.addEventListener("blocked",u=>e(u.oldVersion,u.newVersion,u)),c.then(u=>{s&&u.addEventListener("close",()=>s()),i&&u.addEventListener("versionchange",w=>i(w.oldVersion,w.newVersion,w))}).catch(()=>{}),c}var Y0=["get","getKey","getAll","getAllKeys","count"],X0=["put","add","delete","clear"],wo=new Map;function pu(r,t){if(!(r instanceof IDBDatabase&&!(t in r)&&typeof t=="string"))return;if(wo.get(t))return wo.get(t);let e=t.replace(/FromIndex$/,""),n=t!==e,i=X0.includes(e);if(!(e in(n?IDBIndex:IDBObjectStore).prototype)||!(i||Y0.includes(e)))return;let s=async function(o,...c){let u=this.transaction(o,i?"readwrite":"readonly"),w=u.store;return n&&(w=w.index(c.shift())),(await Promise.all([w[e](...c),i&&u.done]))[0]};return wo.set(t,s),s}du(r=>({...r,get:(t,e,n)=>pu(t,e)||r.get(t,e,n),has:(t,e)=>!!pu(t,e)||r.has(t,e)}));var wu="auth-client-db",gu="ic-keyval",J0=async(r=wu,t=gu,e)=>(di&&(localStorage!=null&&localStorage.getItem(Qt))&&(localStorage.removeItem(Qt),localStorage.removeItem(ne)),await yu(r,e,{upgrade:n=>{n.objectStoreNames.contains(t)&&n.clear(t),n.createObjectStore(t)}}));async function Z0(r,t,e){return await r.get(t,e)}async function Q0(r,t,e,n){return await r.put(t,n,e)}async function td(r,t,e){return await r.delete(t,e)}var on=class r{constructor(t,e){this._db=t,this._storeName=e}static async create(t){let{dbName:e=wu,storeName:n=gu,version:i=mu}=t??{},s=await J0(e,n,i);return new r(s,n)}async set(t,e){return await Q0(this._db,this._storeName,t,e)}async get(t){var e;return(e=await Z0(this._db,this._storeName,t))!==null&&e!==void 0?e:null}async remove(t){return await td(this._db,this._storeName,t)}};var ed=function(r,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,e):i?i.value=e:t.set(r,e),e},rd=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},pi,ne="identity",Qt="delegation",xu="iv",mu=1,di=typeof window<"u",an=class{constructor(t="ic-",e){this.prefix=t,this._localStorage=e}get(t){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+t))}set(t,e){return this._getLocalStorage().setItem(this.prefix+t,e),Promise.resolve()}remove(t){return this._getLocalStorage().removeItem(this.prefix+t),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let t=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!t)throw new Error("Could not find local storage.");return t}},$e=class{constructor(t){pi.set(this,void 0),ed(this,pi,t??{},"f")}get _db(){return new Promise(t=>{if(this.initializedDb){t(this.initializedDb);return}on.create(rd(this,pi,"f")).then(e=>{this.initializedDb=e,t(e)})})}async get(t){return await(await this._db).get(t)}async set(t,e){await(await this._db).set(t,e)}async remove(t){await(await this._db).remove(t)}};pi=new WeakMap;var nd="https://identity.ic0.app",id="#authorize",go="ECDSA",mo="Ed25519",sd=500,od="UserInterrupt",yi=class{constructor(t,e,n,i,s,o,c,u){this._identity=t,this._key=e,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=o,this._idpWindow=c,this._eventHandler=u,this._registerDefaultIdleCallback()}static async create(t={}){var e,n,i;let s=(e=t.storage)!==null&&e!==void 0?e:new $e,o=(n=t.keyType)!==null&&n!==void 0?n:go,c=null;if(t.identity)c=t.identity;else{let m=await s.get(ne);if(!m&&di)try{let N=new an,P=await N.get(Qt),O=await N.get(ne);P&&O&&o===go&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(Qt,P),await s.set(ne,O),m=P,await N.remove(Qt),await N.remove(ne))}catch(N){console.error("error while attempting to recover localstorage: "+N)}if(m)try{typeof m=="object"?o===mo&&typeof m=="string"?c=await Je.fromJSON(m):c=await tn.fromKeyPair(m):typeof m=="string"&&(c=Je.fromJSON(m))}catch{}}let u=new mr,w=null;if(c)try{let m=await s.get(Qt);if(typeof m=="object"&&m!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");t.identity?u=t.identity:m&&(w=Ze.fromJSON(m),li(w)?"toDer"in c?u=nn.fromDelegation(c,w):u=rn.fromDelegation(c,w):(await xo(s),c=null))}catch(m){console.error(m),await xo(s),c=null}let y;return!((i=t.idleOptions)===null||i===void 0)&&i.disableIdle?y=void 0:(w||t.identity)&&(y=sn.create(t.idleOptions)),c||(o===mo?(c=await Je.generate(),await s.set(ne,JSON.stringify(c.toJSON()))):(t.storage&&o===go&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${mo}' as the key type, as it can serialize to a string`),c=await tn.generate(),await s.set(ne,c.getKeyPair()))),new this(u,c,w,s,y,t)}_registerDefaultIdleCallback(){var t,e;let n=(t=this._createOptions)===null||t===void 0?void 0:t.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((e=this.idleManager)===null||e===void 0||e.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(t,e){var n,i;let s=t.delegations.map(w=>({delegation:new Rr(w.delegation.pubkey,w.delegation.expiration,w.delegation.targets),signature:w.signature.buffer})),o=Ze.fromDelegations(s,t.userPublicKey.buffer),c=this._key;if(!c)return;this._chain=o,"toDer"in c?this._identity=nn.fromDelegation(c,this._chain):this._identity=rn.fromDelegation(c,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let u=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!u?.disableIdle&&(this.idleManager=sn.create(u),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(Qt,JSON.stringify(this._chain.toJSON())),e?.(t)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(t){var e,n,i,s;let o=BigInt(8)*BigInt(36e11),c=new URL(((e=t?.identityProvider)===null||e===void 0?void 0:e.toString())||nd);c.hash=id,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(c,Object.assign({maxTimeToLive:(i=t?.maxTimeToLive)!==null&&i!==void 0?i:o},t)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(c.toString(),"idpWindow",t?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let u=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(od,t?.onError):setTimeout(u,sd))};u()}_getEventHandler(t,e){return async n=>{var i,s,o;if(n.origin!==t.origin)return;let c=n.data;switch(c.kind){case"authorize-ready":{let u=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:e?.maxTimeToLive,allowPinAuthentication:e?.allowPinAuthentication,derivationOrigin:(s=e?.derivationOrigin)===null||s===void 0?void 0:s.toString()},e?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(u,t.origin);break}case"authorize-client-success":try{await this._handleSuccess(c,e?.onSuccess)}catch(u){this._handleFailure(u.message,e?.onError)}break;case"authorize-client-failure":this._handleFailure(c.text,e?.onError);break;default:break}}}_handleFailure(t,e){var n;(n=this._idpWindow)===null||n===void 0||n.close(),e?.(t),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(t={}){if(await xo(this._storage),this._identity=new mr,this._chain=null,t.returnTo)try{window.history.pushState({},"",t.returnTo)}catch{window.location.href=t.returnTo}}};async function xo(r){await r.remove(ne),await r.remove(Qt),await r.remove(xu)}var jm=BigInt(144e11);var _u=1e3;var bu=()=>yi.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Eu=({data:r})=>{let{msg:t}=r;switch(t){case"junoStartAuthTimer":ad();return;case"junoStopAuthTimer":vu();return}},wi,ad=()=>wi=setInterval(async()=>await cd(),_u),vu=()=>{wi&&(clearInterval(wi),wi=void 0)},cd=async()=>{let[r,t]=await Promise.all([ud(),fd()]);if(r&&t.valid&&t.delegation!==null){hd(t.delegation);return}ld()},ud=async()=>(await bu()).isAuthenticated(),fd=async()=>{let t=await new $e().get(Qt),e=t!==null?Ze.fromJSON(t):null;return{valid:e!==null&&li(e),delegation:e}},ld=()=>{vu(),postMessage({msg:"junoSignOutAuthTimer"})},hd=r=>{let t=r.delegations[0]?.delegation.expiration;if(t===void 0)return;let e=new Date(Number(t/BigInt(1e6))).getTime()-Date.now();postMessage({msg:"junoDelegationRemainingTime",data:{authRemainingTime:e}})};onmessage=r=>{Eu(r)};})();
|
|
1
|
+
"use strict";(()=>{var Qt="abcdefghijklmnopqrstuvwxyz234567",St=Object.create(null);for(let e=0;e<Qt.length;e++)St[Qt[e]]=e;St[0]=St.o;St[1]=St.i;function pr(e){let t=0,r=0,n="";function o(s){return t<0?r|=s>>-t:r=s<<t&248,t>3?(t-=8,1):(t<4&&(n+=Qt[r>>3],t+=5),0)}for(let s=0;s<e.length;)s+=o(e[s]);return n+(t<0?Qt[r>>3]:"")}function yr(e){let t=0,r=0,n=new Uint8Array(e.length*4/3|0),o=0;function s(i){let a=St[i.toLowerCase()];if(a===void 0)throw new Error(`Invalid character: ${JSON.stringify(i)}`);a<<=3,r|=a>>>t,t+=5,t>=8&&(n[o++]=r,t-=8,t>0?r=a<<5-t&255:r=0)}for(let i of e)s(i);return n.slice(0,o)}var Un=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 gr(e){let t=-1;for(let r=0;r<e.length;r++){let o=(e[r]^t)&255;t=Un[o]^t>>>8}return(t^-1)>>>0}var mt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function wt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ee(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function V(e,...t){if(!wt(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function _e(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function mr(e,t){V(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Et(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ee(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function F(e,t){return e<<32-t|e>>>t}var wr=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Mn=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function v(e){if(V(e),wr)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Mn[e[r]];return t}var tt={_0:48,_9:57,A:65,F:70,a:97,f:102};function br(e){if(e>=tt._0&&e<=tt._9)return e-tt._0;if(e>=tt.A&&e<=tt.F)return e-(tt.A-10);if(e>=tt.a&&e<=tt.f)return e-(tt.a-10)}function q(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(wr)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=br(e.charCodeAt(s)),a=br(e.charCodeAt(s+1));if(i===void 0||a===void 0){let c=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function Ie(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Be(e){return typeof e=="string"&&(e=Ie(e)),V(e),e}function G(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];V(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}var te=class{};function re(e){let t=n=>e().update(Be(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Ae(e=32){if(mt&&typeof mt.getRandomValues=="function")return mt.getRandomValues(new Uint8Array(e));if(mt&&typeof mt.randomBytes=="function")return Uint8Array.from(mt.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function jn(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(r>>o&s),a=Number(r&s),c=n?4:0,u=n?0:4;e.setUint32(t+c,i,n),e.setUint32(t+u,a,n)}function Er(e,t,r){return e&t^~e&r}function _r(e,t,r){return e&t^e&r^t&r}var Rt=class extends te{constructor(t,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=ee(this.buffer)}update(t){_e(this),t=Be(t),V(t);let{view:r,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=ee(t);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){_e(this),mr(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,Et(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let d=i;d<o;d++)r[d]=0;jn(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=ee(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<u;d++)a.setUint32(4*d,l[d],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},et=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),rt=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]);var P=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var ne=BigInt(4294967295),Ir=BigInt(32);function qn(e,t=!1){return t?{h:Number(e&ne),l:Number(e>>Ir&ne)}:{h:Number(e>>Ir&ne)|0,l:Number(e&ne)|0}}function Br(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=qn(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var Oe=(e,t,r)=>e>>>r,Se=(e,t,r)=>e<<32-r|t>>>r,_t=(e,t,r)=>e>>>r|t<<32-r,It=(e,t,r)=>e<<32-r|t>>>r,Nt=(e,t,r)=>e<<64-r|t>>>r-32,Pt=(e,t,r)=>e>>>r-32|t<<64-r;function X(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Ar=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Or=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Sr=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Tr=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,vr=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Dr=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;var Kn=Uint32Array.from([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]),at=new Uint32Array(64),oe=class extends Rt{constructor(t=32){super(64,t,8,!1),this.A=et[0]|0,this.B=et[1]|0,this.C=et[2]|0,this.D=et[3]|0,this.E=et[4]|0,this.F=et[5]|0,this.G=et[6]|0,this.H=et[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,r,n,o,s,i,a,c]}set(t,r,n,o,s,i,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,r){for(let d=0;d<16;d++,r+=4)at[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){let f=at[d-15],p=at[d-2],x=F(f,7)^F(f,18)^f>>>3,b=F(p,17)^F(p,19)^p>>>10;at[d]=b+at[d-7]+x+at[d-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:u,H:l}=this;for(let d=0;d<64;d++){let f=F(a,6)^F(a,11)^F(a,25),p=l+f+Er(a,c,u)+Kn[d]+at[d]|0,b=(F(n,2)^F(n,13)^F(n,22))+_r(n,o,s)|0;l=u,u=c,c=a,a=i+p|0,i=s,s=o,o=n,n=p+b|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(n,o,s,i,a,c,u,l)}roundClean(){Et(at)}destroy(){this.set(0,0,0,0,0,0,0,0),Et(this.buffer)}},Te=class extends oe{constructor(){super(28),this.A=rt[0]|0,this.B=rt[1]|0,this.C=rt[2]|0,this.D=rt[3]|0,this.E=rt[4]|0,this.F=rt[5]|0,this.G=rt[6]|0,this.H=rt[7]|0}},Lr=Br(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),kn=Lr[0],$n=Lr[1],ft=new Uint32Array(80),ut=new Uint32Array(80),ve=class extends Rt{constructor(t=64){super(128,t,16,!1),this.Ah=P[0]|0,this.Al=P[1]|0,this.Bh=P[2]|0,this.Bl=P[3]|0,this.Ch=P[4]|0,this.Cl=P[5]|0,this.Dh=P[6]|0,this.Dl=P[7]|0,this.Eh=P[8]|0,this.El=P[9]|0,this.Fh=P[10]|0,this.Fl=P[11]|0,this.Gh=P[12]|0,this.Gl=P[13]|0,this.Hh=P[14]|0,this.Hl=P[15]|0}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:u,El:l,Fh:d,Fl:f,Gh:p,Gl:x,Hh:b,Hl:E}=this;return[t,r,n,o,s,i,a,c,u,l,d,f,p,x,b,E]}set(t,r,n,o,s,i,a,c,u,l,d,f,p,x,b,E){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=l|0,this.Fh=d|0,this.Fl=f|0,this.Gh=p|0,this.Gl=x|0,this.Hh=b|0,this.Hl=E|0}process(t,r){for(let y=0;y<16;y++,r+=4)ft[y]=t.getUint32(r),ut[y]=t.getUint32(r+=4);for(let y=16;y<80;y++){let I=ft[y-15]|0,A=ut[y-15]|0,D=_t(I,A,1)^_t(I,A,8)^Oe(I,A,7),L=It(I,A,1)^It(I,A,8)^Se(I,A,7),B=ft[y-2]|0,g=ut[y-2]|0,m=_t(B,g,19)^Nt(B,g,61)^Oe(B,g,6),_=It(B,g,19)^Pt(B,g,61)^Se(B,g,6),O=Sr(L,_,ut[y-7],ut[y-16]),T=Tr(O,D,m,ft[y-7],ft[y-16]);ft[y]=T|0,ut[y]=O|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:u,Dl:l,Eh:d,El:f,Fh:p,Fl:x,Gh:b,Gl:E,Hh:h,Hl:w}=this;for(let y=0;y<80;y++){let I=_t(d,f,14)^_t(d,f,18)^Nt(d,f,41),A=It(d,f,14)^It(d,f,18)^Pt(d,f,41),D=d&p^~d&b,L=f&x^~f&E,B=vr(w,A,L,$n[y],ut[y]),g=Dr(B,h,I,D,kn[y],ft[y]),m=B|0,_=_t(n,o,28)^Nt(n,o,34)^Nt(n,o,39),O=It(n,o,28)^Pt(n,o,34)^Pt(n,o,39),T=n&s^n&a^s&a,S=o&i^o&c^i&c;h=b|0,w=E|0,b=p|0,E=x|0,p=d|0,x=f|0,{h:d,l:f}=X(u|0,l|0,g|0,m|0),u=a|0,l=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let R=Ar(m,O,S);n=Or(R,g,_,T),o=R|0}({h:n,l:o}=X(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=X(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=X(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l}=X(this.Dh|0,this.Dl|0,u|0,l|0),{h:d,l:f}=X(this.Eh|0,this.El|0,d|0,f|0),{h:p,l:x}=X(this.Fh|0,this.Fl|0,p|0,x|0),{h:b,l:E}=X(this.Gh|0,this.Gl|0,b|0,E|0),{h,l:w}=X(this.Hh|0,this.Hl|0,h|0,w|0),this.set(n,o,s,i,a,c,u,l,d,f,p,x,b,E,h,w)}roundClean(){Et(ft,ut)}destroy(){Et(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var dt=re(()=>new oe),Cr=re(()=>new Te),Rr=re(()=>new ve);var se="__principal__",Vn=2,Nr=4,Gn="aaaaa-aa",Z=class e{static anonymous(){return new this(new Uint8Array([Nr]))}static managementCanister(){return this.fromText(Gn)}static selfAuthenticating(t){let r=Cr(t);return new this(new Uint8Array([...r,Vn]))}static from(t){if(typeof t=="string")return e.fromText(t);if(Object.getPrototypeOf(t)===Uint8Array.prototype)return new e(t);if(e.isPrincipal(t))return new e(t._arr);throw new Error(`Impossible to convert ${JSON.stringify(t)} to Principal.`)}static fromHex(t){return new this(q(t))}static fromText(t){let r=t;if(t.includes(se)){let i=JSON.parse(t);se in i&&(r=i[se])}let n=r.toLowerCase().replace(/-/g,""),o=yr(n);o=o.slice(4,o.length);let s=new this(o);if(s.toText()!==r)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${r}" may not be a valid Principal ID).`);return s}static fromUint8Array(t){return new this(t)}static isPrincipal(t){return t instanceof e||typeof t=="object"&&t!==null&&"_isPrincipal"in t&&t._isPrincipal===!0&&"_arr"in t&&t._arr instanceof Uint8Array}constructor(t){this._arr=t,this._isPrincipal=!0}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===Nr}toUint8Array(){return this._arr}toHex(){return v(this._arr).toUpperCase()}toText(){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,gr(this._arr));let n=new Uint8Array(t),o=new Uint8Array([...n,...this._arr]),i=pr(o).match(/.{1,5}/g);if(!i)throw new Error;return i.join("-")}toString(){return this.toText()}toJSON(){return{[se]:this.toText()}}compareTo(t){for(let r=0;r<Math.min(this._arr.length,t._arr.length);r++){if(this._arr[r]<t._arr[r])return"lt";if(this._arr[r]>t._arr[r])return"gt"}return this._arr.length<t._arr.length?"lt":this._arr.length>t._arr.length?"gt":"eq"}ltEq(t){let r=this.compareTo(t);return r=="lt"||r=="eq"}gtEq(t){let r=this.compareTo(t);return r=="gt"||r=="eq"}};var De;(function(e){e.Trust="Trust",e.Protocol="Protocol",e.Reject="Reject",e.Transport="Transport",e.External="External",e.Limit="Limit",e.Input="Input",e.Unknown="Unknown"})(De||(De={}));var Tt=class{constructor(t=!1){this.isCertified=t}toString(){let t=this.toErrorMessage();return this.requestContext&&(t+=`
|
|
2
|
+
Request context:
|
|
3
|
+
Request ID (hex): ${this.requestContext.requestId?v(this.requestContext.requestId):"undefined"}
|
|
4
|
+
Sender pubkey (hex): ${v(this.requestContext.senderPubKey)}
|
|
5
|
+
Sender signature (hex): ${v(this.requestContext.senderSignature)}
|
|
6
|
+
Ingress expiry: ${this.requestContext.ingressExpiry.toString()}`),this.callContext&&(t+=`
|
|
7
|
+
Call context:
|
|
8
|
+
Canister ID: ${this.callContext.canisterId.toText()}
|
|
9
|
+
Method name: ${this.callContext.methodName}
|
|
10
|
+
HTTP details: ${JSON.stringify(this.callContext.httpDetails,null,2)}`),t}},Le=class e extends Error{get code(){return this.cause.code}set code(t){this.cause.code=t}get kind(){return this.cause.kind}set kind(t){this.cause.kind=t}get isCertified(){return this.code.isCertified}constructor(t,r){super(t.toString()),this.name="AgentError",this.cause={code:t,kind:r},Object.setPrototypeOf(this,e.prototype)}hasCode(t){return this.code instanceof t}toString(){return`${this.name} (${this.kind}): ${this.message}`}},Ce=class extends Le{static fromCode(t){return new this(t)}};var H=class e extends Ce{constructor(t){super(t,De.Input),this.name="InputError",Object.setPrototypeOf(this,e.prototype)}};var ie=class e extends Tt{constructor(t,r){super(),this.expectedLength=t,this.actualLength=r,this.name="DerDecodeLengthMismatchErrorCode",Object.setPrototypeOf(this,e.prototype)}toErrorMessage(){return`DER payload mismatch: Expected length ${this.expectedLength}, actual length: ${this.actualLength}`}},lt=class e extends Tt{constructor(t){super(),this.error=t,this.name="DerDecodeErrorCode",Object.setPrototypeOf(this,e.prototype)}toErrorMessage(){return`Failed to decode DER: ${this.error}`}},Ut=class e extends Tt{constructor(t){super(),this.error=t,this.name="DerEncodeErrorCode",Object.setPrototypeOf(this,e.prototype)}toErrorMessage(){return`Failed to encode DER: ${this.error}`}};var ce=class e extends Tt{constructor(t){super(),this.value=t,this.name="HashValueErrorCode",Object.setPrototypeOf(this,e.prototype)}toErrorMessage(){return`Attempt to hash a value of unsupported type: ${this.value}`}};var gs=new Error("unreachable");var ae=class{save(){return this._view}restore(t){if(!(t instanceof Uint8Array))throw new Error("Checkpoint must be a Uint8Array");this._view=t}constructor(t,r=t?.byteLength||0){if(t&&!(t instanceof Uint8Array))try{t=z(t)}catch{throw new Error("Buffer must be a Uint8Array")}if(r<0||!Number.isInteger(r))throw new Error("Length must be a non-negative integer");if(t&&r>t.byteLength)throw new Error("Length cannot exceed buffer length");this._buffer=t||new Uint8Array(0),this._view=new Uint8Array(this._buffer.buffer,0,r)}get buffer(){return this._view.slice()}get byteLength(){return this._view.byteLength}read(t){let r=this._view.subarray(0,t);return this._view=this._view.subarray(t),r.slice()}readUint8(){if(this._view.byteLength===0)return;let t=this._view[0];return this._view=this._view.subarray(1),t}write(t){if(!(t instanceof Uint8Array))throw new Error("Buffer must be a Uint8Array");let r=this._view.byteLength;this._view.byteOffset+this._view.byteLength+t.byteLength>=this._buffer.byteLength?this.alloc(t.byteLength):this._view=new Uint8Array(this._buffer.buffer,this._view.byteOffset,this._view.byteLength+t.byteLength),this._view.set(t,r)}get end(){return this._view.byteLength===0}alloc(t){if(t<=0||!Number.isInteger(t))throw new Error("Amount must be a positive integer");let r=new Uint8Array((this._buffer.byteLength+t)*1.2|0),n=new Uint8Array(r.buffer,0,this._view.byteLength+t);n.set(this._view),this._buffer=r,this._view=n}};function z(e){if(!e)throw new Error("Input cannot be null or undefined");return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):Array.isArray(e)?new Uint8Array(e):"buffer"in e?z(e.buffer):new Uint8Array(e)}function Re(e,t){if(e.byteLength!==t.byteLength)return e.byteLength-t.byteLength;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]-t[r];return 0}function Pr(e,t){return Re(e,t)===0}function Ur(e){let t=BigInt(e);if(e<=0)throw new RangeError("Input must be positive");return t.toString(2).length-1}function Ne(e){if(typeof e=="number"&&(e=BigInt(e)),e<BigInt(0))throw new Error("Cannot leb encode negative values.");let t=(e===BigInt(0)?0:Ur(e))+1,r=new ae(new Uint8Array(t),0);for(;;){let n=Number(e&BigInt(127));if(e/=BigInt(128),e===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}function Pe(e){if(!e)throw new Error("Input cannot be null or undefined");return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):Array.isArray(e)?new Uint8Array(e):"buffer"in e?Pe(e.buffer):new Uint8Array(e)}function Mr(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function Ue(e){if(typeof e=="string")return jr(e);if(typeof e=="number")return dt(Ne(e));if(e instanceof Uint8Array||ArrayBuffer.isView(e))return dt(Pe(e));if(Array.isArray(e)){let t=e.map(Ue);return dt(G(...t))}else{if(e&&typeof e=="object"&&e._isPrincipal)return dt(e.toUint8Array());if(typeof e=="object"&&e!==null&&typeof e.toHash=="function")return Ue(e.toHash());if(typeof e=="object")return qr(e);if(typeof e=="bigint")return dt(Ne(e))}throw H.fromCode(new ce(e))}var jr=e=>{let t=new TextEncoder().encode(e);return dt(t)};function Mt(e){return qr(e)}function qr(e){let n=Object.entries(e).filter(([,i])=>i!==void 0).map(([i,a])=>{let c=jr(i),u=Ue(a);return[c,u]}).sort(([i],[a])=>Re(i,a)),o=G(...n.map(i=>G(...i)));return dt(o)}var jt=new TextEncoder().encode(`
|
|
11
|
+
ic-request`),Yn=new TextEncoder().encode("\vic-response"),Me=new TextEncoder().encode("ic-request-auth-delegation");var ht=class{getPrincipal(){return this._principal||(this._principal=Z.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(t){let{body:r,...n}=t,o=Mt(r);return{...n,body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(G(jt,o))}}}},qt=class{getPrincipal(){return Z.anonymous()}async transformRequest(t){return{...t,body:{content:t.body}}}};var He=BigInt(0),qe=BigInt(1);function fe(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}"`;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function Ht(e,t,r=""){let n=wt(e),o=e?.length,s=t!==void 0;if(!n||s&&o!==t){let i=r&&`"${r}" `,a=s?` of length ${t}`:"",c=n?`length=${o}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+a+", got "+c)}return e}function Hr(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?He:BigInt("0x"+e)}function Kr(e){return Hr(v(e))}function xt(e){return V(e),Hr(v(Uint8Array.from(e).reverse()))}function Ke(e,t){return q(e.toString(16).padStart(t*2,"0"))}function kr(e,t){return Ke(e,t).reverse()}function K(e,t,r){let n;if(typeof t=="string")try{n=q(t)}catch(s){throw new Error(e+" must be hex string or Uint8Array, cause: "+s)}else if(wt(t))n=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(e+" of length "+r+" expected, got "+o);return n}function $r(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function ke(e){return Uint8Array.from(e)}var je=e=>typeof e=="bigint"&&He<=e;function Fn(e,t,r){return je(e)&&je(t)&&je(r)&&t<=e&&e<r}function $e(e,t,r,n){if(!Fn(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Vr(e){let t;for(t=0;e>He;e>>=qe,t+=1);return t}var Kt=e=>(qe<<BigInt(e))-qe;function kt(e,t,r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(o,s,i){let a=e[o];if(i&&a===void 0)return;let c=typeof a;if(c!==s||a===null)throw new Error(`param "${o}" is invalid: expected ${s}, got ${c}`)}Object.entries(t).forEach(([o,s])=>n(o,s,!1)),Object.entries(r).forEach(([o,s])=>n(o,s,!0))}var Ve=()=>{throw new Error("not implemented")};function Ge(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let s=e(r,...n);return t.set(r,s),s}}var M=BigInt(0),U=BigInt(1),Bt=BigInt(2),Fr=BigInt(3),Zr=BigInt(4),Wr=BigInt(5),Zn=BigInt(7),Xr=BigInt(8),Wn=BigInt(9),zr=BigInt(16);function C(e,t){let r=e%t;return r>=M?r:t+r}function W(e,t,r){let n=e;for(;t-- >M;)n*=n,n%=r;return n}function Gr(e,t){if(e===M)throw new Error("invert: expected non-zero number");if(t<=M)throw new Error("invert: expected positive modulus, got "+t);let r=C(e,t),n=t,o=M,s=U,i=U,a=M;for(;r!==M;){let u=n/r,l=n%r,d=o-i*u,f=s-a*u;n=r,r=l,o=i,s=a,i=d,a=f}if(n!==U)throw new Error("invert: does not exist");return C(o,t)}function Ye(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function Jr(e,t){let r=(e.ORDER+U)/Zr,n=e.pow(t,r);return Ye(e,n,t),n}function Xn(e,t){let r=(e.ORDER-Wr)/Xr,n=e.mul(t,Bt),o=e.pow(n,r),s=e.mul(t,o),i=e.mul(e.mul(s,Bt),o),a=e.mul(s,e.sub(i,e.ONE));return Ye(e,a,t),a}function zn(e){let t=ot(e),r=Qr(e),n=r(t,t.neg(t.ONE)),o=r(t,n),s=r(t,t.neg(n)),i=(e+Zn)/zr;return(a,c)=>{let u=a.pow(c,i),l=a.mul(u,n),d=a.mul(u,o),f=a.mul(u,s),p=a.eql(a.sqr(l),c),x=a.eql(a.sqr(d),c);u=a.cmov(u,l,p),l=a.cmov(f,d,x);let b=a.eql(a.sqr(l),c),E=a.cmov(u,l,b);return Ye(a,E,c),E}}function Qr(e){if(e<Fr)throw new Error("sqrt is not defined for small field");let t=e-U,r=0;for(;t%Bt===M;)t/=Bt,r++;let n=Bt,o=ot(e);for(;Yr(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Jr;let s=o.pow(n,t),i=(t+U)/Bt;return function(c,u){if(c.is0(u))return u;if(Yr(c,u)!==1)throw new Error("Cannot find square root");let l=r,d=c.mul(c.ONE,s),f=c.pow(u,t),p=c.pow(u,i);for(;!c.eql(f,c.ONE);){if(c.is0(f))return c.ZERO;let x=1,b=c.sqr(f);for(;!c.eql(b,c.ONE);)if(x++,b=c.sqr(b),x===l)throw new Error("Cannot find square root");let E=U<<BigInt(l-x-1),h=c.pow(d,E);l=x,d=c.sqr(h),f=c.mul(f,d),p=c.mul(p,h)}return p}}function Jn(e){return e%Zr===Fr?Jr:e%Xr===Wr?Xn:e%zr===Wn?zn(e):Qr(e)}var nt=(e,t)=>(C(e,t)&U)===U,Qn=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function tn(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},r=Qn.reduce((n,o)=>(n[o]="function",n),t);return kt(e,r),e}function to(e,t,r){if(r<M)throw new Error("invalid exponent, negatives unsupported");if(r===M)return e.ONE;if(r===U)return t;let n=e.ONE,o=t;for(;r>M;)r&U&&(n=e.mul(n,o)),o=e.sqr(o),r>>=U;return n}function ue(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((i,a,c)=>e.is0(a)?i:(n[c]=i,e.mul(i,a)),e.ONE),s=e.inv(o);return t.reduceRight((i,a,c)=>e.is0(a)?i:(n[c]=e.mul(i,n[c]),e.mul(i,a)),s),n}function Yr(e,t){let r=(e.ORDER-U)/Bt,n=e.pow(t,r),o=e.eql(n,e.ONE),s=e.eql(n,e.ZERO),i=e.eql(n,e.neg(e.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function en(e,t){t!==void 0&&Ee(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function ot(e,t,r=!1,n={}){if(e<=M)throw new Error("invalid field: expected ORDER > 0, got "+e);let o,s,i=!1,a;if(typeof t=="object"&&t!=null){if(n.sqrt||r)throw new Error("cannot specify opts in two arguments");let f=t;f.BITS&&(o=f.BITS),f.sqrt&&(s=f.sqrt),typeof f.isLE=="boolean"&&(r=f.isLE),typeof f.modFromBytes=="boolean"&&(i=f.modFromBytes),a=f.allowedLengths}else typeof t=="number"&&(o=t),n.sqrt&&(s=n.sqrt);let{nBitLength:c,nByteLength:u}=en(e,o);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let l,d=Object.freeze({ORDER:e,isLE:r,BITS:c,BYTES:u,MASK:Kt(c),ZERO:M,ONE:U,allowedLengths:a,create:f=>C(f,e),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return M<=f&&f<e},is0:f=>f===M,isValidNot0:f=>!d.is0(f)&&d.isValid(f),isOdd:f=>(f&U)===U,neg:f=>C(-f,e),eql:(f,p)=>f===p,sqr:f=>C(f*f,e),add:(f,p)=>C(f+p,e),sub:(f,p)=>C(f-p,e),mul:(f,p)=>C(f*p,e),pow:(f,p)=>to(d,f,p),div:(f,p)=>C(f*Gr(p,e),e),sqrN:f=>f*f,addN:(f,p)=>f+p,subN:(f,p)=>f-p,mulN:(f,p)=>f*p,inv:f=>Gr(f,e),sqrt:s||(f=>(l||(l=Jn(e)),l(d,f))),toBytes:f=>r?kr(f,u):Ke(f,u),fromBytes:(f,p=!0)=>{if(a){if(!a.includes(f.length)||f.length>u)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+f.length);let b=new Uint8Array(u);b.set(f,r?0:b.length-f.length),f=b}if(f.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+f.length);let x=r?xt(f):Kr(f);if(i&&(x=C(x,e)),!p&&!d.isValid(x))throw new Error("invalid field element: outside of range 0..ORDER");return x},invertBatch:f=>ue(d,f),cmov:(f,p,x)=>x?p:f});return Object.freeze(d)}var de=BigInt(0),Xe=BigInt(1);function rn(e,t){let r=t.negate();return e?r:t}function $t(e,t){let r=ue(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function cn(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Fe(e,t){cn(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,s=Kt(e),i=BigInt(e);return{windows:r,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function nn(e,t,r){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=r,a=Number(e&o),c=e>>i;a>n&&(a-=s,c+=Xe);let u=t*n,l=u+Math.abs(a)-1,d=a===0,f=a<0,p=t%2!==0;return{nextN:c,offset:l,isZero:d,isNeg:f,isNegF:p,offsetF:u}}function eo(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function ro(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((r,n)=>{if(!t.isValid(r))throw new Error("invalid scalar at index "+n)})}var Ze=new WeakMap,an=new WeakMap;function We(e){return an.get(e)||1}function on(e){if(e!==de)throw new Error("invalid wNAF")}var le=class{constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let o=t;for(;r>de;)r&Xe&&(n=n.add(o)),o=o.double(),r>>=Xe;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=Fe(r,this.bits),s=[],i=t,a=i;for(let c=0;c<n;c++){a=i,s.push(a);for(let u=1;u<o;u++)a=a.add(i),s.push(a);i=a.double()}return s}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE,i=Fe(t,this.bits);for(let a=0;a<i.windows;a++){let{nextN:c,offset:u,isZero:l,isNeg:d,isNegF:f,offsetF:p}=nn(n,a,i);n=c,l?s=s.add(rn(f,r[p])):o=o.add(rn(d,r[u]))}return on(n),{p:o,f:s}}wNAFUnsafe(t,r,n,o=this.ZERO){let s=Fe(t,this.bits);for(let i=0;i<s.windows&&n!==de;i++){let{nextN:a,offset:c,isZero:u,isNeg:l}=nn(n,i,s);if(n=a,!u){let d=r[c];o=o.add(l?d.negate():d)}}return on(n),o}getPrecomputes(t,r,n){let o=Ze.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),Ze.set(r,o))),o}cached(t,r,n){let o=We(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let s=We(t);return s===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,n),r,o)}createCache(t,r){cn(r,this.bits),an.set(t,r),Ze.delete(t)}hasCache(t){return We(t)!==1}};function he(e,t,r,n){eo(r,e),ro(n,t);let o=r.length,s=n.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");let i=e.ZERO,a=Vr(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let u=Kt(c),l=new Array(Number(u)+1).fill(i),d=Math.floor((t.BITS-1)/c)*c,f=i;for(let p=d;p>=0;p-=c){l.fill(i);for(let b=0;b<s;b++){let E=n[b],h=Number(E>>BigInt(p)&u);l[h]=l[h].add(r[b])}let x=i;for(let b=l.length-1,E=i;b>0;b--)E=E.add(l[b]),x=x.add(E);if(f=f.add(x),p!==0)for(let b=0;b<c;b++)f=f.double()}return f}function sn(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return tn(t),t}else return ot(e,{isLE:r})}function fn(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let u=t[c];if(!(typeof u=="bigint"&&u>de))throw new Error(`CURVE.${c} must be positive bigint`)}let o=sn(t.p,r.Fp,n),s=sn(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}var pt=BigInt(0),N=BigInt(1),ze=BigInt(2),no=BigInt(8);function oo(e,t,r,n){let o=e.sqr(r),s=e.sqr(n),i=e.add(e.mul(t.a,o),s),a=e.add(e.ONE,e.mul(t.d,e.mul(o,s)));return e.eql(i,a)}function so(e,t={}){let r=fn("edwards",e,t,t.FpFnLE),{Fp:n,Fn:o}=r,s=r.CURVE,{h:i}=s;kt(t,{},{uvRatio:"function"});let a=ze<<BigInt(o.BYTES*8)-N,c=E=>n.create(E),u=t.uvRatio||((E,h)=>{try{return{isValid:!0,value:n.sqrt(n.div(E,h))}}catch{return{isValid:!1,value:pt}}});if(!oo(n,s,s.Gx,s.Gy))throw new Error("bad curve params: generator point");function l(E,h,w=!1){let y=w?N:pt;return $e("coordinate "+E,h,y,a),h}function d(E){if(!(E instanceof x))throw new Error("ExtendedPoint expected")}let f=Ge((E,h)=>{let{X:w,Y:y,Z:I}=E,A=E.is0();h==null&&(h=A?no:n.inv(I));let D=c(w*h),L=c(y*h),B=n.mul(I,h);if(A)return{x:pt,y:N};if(B!==N)throw new Error("invZ was invalid");return{x:D,y:L}}),p=Ge(E=>{let{a:h,d:w}=s;if(E.is0())throw new Error("bad point: ZERO");let{X:y,Y:I,Z:A,T:D}=E,L=c(y*y),B=c(I*I),g=c(A*A),m=c(g*g),_=c(L*h),O=c(g*c(_+B)),T=c(m+c(w*c(L*B)));if(O!==T)throw new Error("bad point: equation left != right (1)");let S=c(y*I),R=c(A*D);if(S!==R)throw new Error("bad point: equation left != right (2)");return!0});class x{constructor(h,w,y,I){this.X=l("x",h),this.Y=l("y",w),this.Z=l("z",y,!0),this.T=l("t",I),Object.freeze(this)}static CURVE(){return s}static fromAffine(h){if(h instanceof x)throw new Error("extended point not allowed");let{x:w,y}=h||{};return l("x",w),l("y",y),new x(w,y,N,c(w*y))}static fromBytes(h,w=!1){let y=n.BYTES,{a:I,d:A}=s;h=ke(Ht(h,y,"point")),fe(w,"zip215");let D=ke(h),L=h[y-1];D[y-1]=L&-129;let B=xt(D),g=w?a:n.ORDER;$e("point.y",B,pt,g);let m=c(B*B),_=c(m-N),O=c(A*m-I),{isValid:T,value:S}=u(_,O);if(!T)throw new Error("bad point: invalid y coordinate");let R=(S&N)===N,j=(L&128)!==0;if(!w&&S===pt&&j)throw new Error("bad point: x=0 and x_0=1");return j!==R&&(S=c(-S)),x.fromAffine({x:S,y:B})}static fromHex(h,w=!1){return x.fromBytes(K("point",h),w)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(h=8,w=!0){return b.createCache(this,h),w||this.multiply(ze),this}assertValidity(){p(this)}equals(h){d(h);let{X:w,Y:y,Z:I}=this,{X:A,Y:D,Z:L}=h,B=c(w*L),g=c(A*I),m=c(y*L),_=c(D*I);return B===g&&m===_}is0(){return this.equals(x.ZERO)}negate(){return new x(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:h}=s,{X:w,Y:y,Z:I}=this,A=c(w*w),D=c(y*y),L=c(ze*c(I*I)),B=c(h*A),g=w+y,m=c(c(g*g)-A-D),_=B+D,O=_-L,T=B-D,S=c(m*O),R=c(_*T),j=c(m*T),ct=c(O*_);return new x(S,R,ct,j)}add(h){d(h);let{a:w,d:y}=s,{X:I,Y:A,Z:D,T:L}=this,{X:B,Y:g,Z:m,T:_}=h,O=c(I*B),T=c(A*g),S=c(L*y*_),R=c(D*m),j=c((I+A)*(B+g)-O-T),ct=R-S,bt=R+S,Q=c(T-w*O),Ct=c(j*ct),Jt=c(bt*Q),we=c(j*Q),xr=c(ct*bt);return new x(Ct,Jt,xr,we)}subtract(h){return this.add(h.negate())}multiply(h){if(!o.isValidNot0(h))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:w,f:y}=b.cached(this,h,I=>$t(x,I));return $t(x,[w,y])[0]}multiplyUnsafe(h,w=x.ZERO){if(!o.isValid(h))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return h===pt?x.ZERO:this.is0()||h===N?this:b.unsafe(this,h,y=>$t(x,y),w)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return b.unsafe(this,s.n).is0()}toAffine(h){return f(this,h)}clearCofactor(){return i===N?this:this.multiplyUnsafe(i)}toBytes(){let{x:h,y:w}=this.toAffine(),y=n.toBytes(w);return y[y.length-1]|=h&N?128:0,y}toHex(){return v(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(h){return $t(x,h)}static msm(h,w){return he(x,o,h,w)}_setWindowSize(h){this.precompute(h)}toRawBytes(){return this.toBytes()}}x.BASE=new x(s.Gx,s.Gy,N,c(s.Gx*s.Gy)),x.ZERO=new x(pt,N,N,pt),x.Fp=n,x.Fn=o;let b=new le(x,o.BITS);return x.BASE.precompute(8),x}var xe=class{constructor(t){this.ep=t}static fromBytes(t){Ve()}static fromHex(t){Ve()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return v(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,r){return this.init(this.ep.precompute(t,r))}toRawBytes(){return this.toBytes()}};function io(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');kt(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=r,{BASE:o,Fp:s,Fn:i}=e,a=r.randomBytes||Ae,c=r.adjustScalarBytes||(g=>g),u=r.domain||((g,m,_)=>{if(fe(_,"phflag"),m.length||_)throw new Error("Contexts/pre-hash are not supported");return g});function l(g){return i.create(xt(g))}function d(g){let m=y.secretKey;g=K("private key",g,m);let _=K("hashed private key",t(g),2*m),O=c(_.slice(0,m)),T=_.slice(m,2*m),S=l(O);return{head:O,prefix:T,scalar:S}}function f(g){let{head:m,prefix:_,scalar:O}=d(g),T=o.multiply(O),S=T.toBytes();return{head:m,prefix:_,scalar:O,point:T,pointBytes:S}}function p(g){return f(g).pointBytes}function x(g=Uint8Array.of(),...m){let _=G(...m);return l(t(u(_,K("context",g),!!n)))}function b(g,m,_={}){g=K("message",g),n&&(g=n(g));let{prefix:O,scalar:T,pointBytes:S}=f(m),R=x(_.context,O,g),j=o.multiply(R).toBytes(),ct=x(_.context,j,S,g),bt=i.create(R+ct*T);if(!i.isValid(bt))throw new Error("sign failed: invalid s");let Q=G(j,i.toBytes(bt));return Ht(Q,y.signature,"result")}let E={zip215:!0};function h(g,m,_,O=E){let{context:T,zip215:S}=O,R=y.signature;g=K("signature",g,R),m=K("message",m),_=K("publicKey",_,y.publicKey),S!==void 0&&fe(S,"zip215"),n&&(m=n(m));let j=R/2,ct=g.subarray(0,j),bt=xt(g.subarray(j,R)),Q,Ct,Jt;try{Q=e.fromBytes(_,S),Ct=e.fromBytes(ct,S),Jt=o.multiplyUnsafe(bt)}catch{return!1}if(!S&&Q.isSmallOrder())return!1;let we=x(T,Ct.toBytes(),Q.toBytes(),m);return Ct.add(Q.multiplyUnsafe(we)).subtract(Jt).clearCofactor().is0()}let w=s.BYTES,y={secretKey:w,publicKey:w,signature:2*w,seed:w};function I(g=a(y.seed)){return Ht(g,y.seed,"seed")}function A(g){let m=B.randomSecretKey(g);return{secretKey:m,publicKey:p(m)}}function D(g){return wt(g)&&g.length===i.BYTES}function L(g,m){try{return!!e.fromBytes(g,m)}catch{return!1}}let B={getExtendedPublicKey:f,randomSecretKey:I,isValidSecretKey:D,isValidPublicKey:L,toMontgomery(g){let{y:m}=e.fromBytes(g),_=y.publicKey,O=_===32;if(!O&&_!==57)throw new Error("only defined for 25519 and 448");let T=O?s.div(N+m,N-m):s.div(m-N,m+N);return s.toBytes(T)},toMontgomerySecret(g){let m=y.secretKey;Ht(g,m);let _=t(g.subarray(0,m));return c(_).subarray(0,m)},randomPrivateKey:I,precompute(g=8,m=e.BASE){return m.precompute(g,!1)}};return Object.freeze({keygen:A,getPublicKey:p,sign:b,verify:h,utils:B,Point:e,lengths:y})}function co(e){let t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},r=e.Fp,n=ot(t.n,e.nBitLength,!0),o={Fp:r,Fn:n,uvRatio:e.uvRatio},s={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:o,hash:e.hash,eddsaOpts:s}}function ao(e,t){let r=t.Point;return Object.assign({},t,{ExtendedPoint:r,CURVE:e,nBitLength:r.Fn.BITS,nByteLength:r.Fn.BYTES})}function un(e){let{CURVE:t,curveOpts:r,hash:n,eddsaOpts:o}=co(e),s=so(t,r),i=io(s,n,o);return ao(e,i)}var fo=BigInt(0),st=BigInt(1),dn=BigInt(2),oi=BigInt(3),uo=BigInt(5),lo=BigInt(8),vt=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Vt={p:vt,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:lo,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function ho(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=vt,a=e*e%s*e%s,c=W(a,dn,s)*a%s,u=W(c,st,s)*e%s,l=W(u,uo,s)*u%s,d=W(l,t,s)*l%s,f=W(d,r,s)*d%s,p=W(f,n,s)*f%s,x=W(p,o,s)*p%s,b=W(x,o,s)*p%s,E=W(b,t,s)*l%s;return{pow_p_5_8:W(E,dn,s)*e%s,b2:a}}function xo(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Je=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function er(e,t){let r=vt,n=C(t*t*t,r),o=C(n*n*t,r),s=ho(e*o).pow_p_5_8,i=C(e*n*s,r),a=C(t*i*i,r),c=i,u=C(i*Je,r),l=a===e,d=a===C(-e,r),f=a===C(-e*Je,r);return l&&(i=c),(d||f)&&(i=u),nt(i,r)&&(i=C(-i,r)),{isValid:l||d,value:i}}var yt=ot(Vt.p,{isLE:!0}),po=ot(Vt.n,{isLE:!0}),yo={...Vt,Fp:yt,hash:Rr,adjustScalarBytes:xo,uvRatio:er},k=un(yo);var Qe=Je,go=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),bo=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),mo=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),wo=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),ln=e=>er(st,e),Eo=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),tr=e=>k.Point.Fp.create(xt(e)&Eo);function hn(e){let{d:t}=Vt,r=vt,n=h=>yt.create(h),o=n(Qe*e*e),s=n((o+st)*mo),i=BigInt(-1),a=n((i-t*o)*n(o+t)),{isValid:c,value:u}=er(s,a),l=n(u*e);nt(l,r)||(l=n(-l)),c||(u=l),c||(i=o);let d=n(i*(o-st)*wo-a),f=u*u,p=n((u+u)*a),x=n(d*go),b=n(st-f),E=n(st+f);return new k.Point(n(p*E),n(b*x),n(x*E),n(p*b))}function _o(e){V(e,64);let t=tr(e.subarray(0,32)),r=hn(t),n=tr(e.subarray(32,64)),o=hn(n);return new it(r.add(o))}var it=class e extends xe{constructor(t){super(t)}static fromAffine(t){return new e(k.Point.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw new Error("RistrettoPoint expected")}init(t){return new e(t)}static hashToCurve(t){return _o(K("ristrettoHash",t,64))}static fromBytes(t){V(t,32);let{a:r,d:n}=Vt,o=vt,s=I=>yt.create(I),i=tr(t);if(!$r(yt.toBytes(i),t)||nt(i,o))throw new Error("invalid ristretto255 encoding 1");let a=s(i*i),c=s(st+r*a),u=s(st-r*a),l=s(c*c),d=s(u*u),f=s(r*n*l-d),{isValid:p,value:x}=ln(s(f*d)),b=s(x*u),E=s(x*b*f),h=s((i+i)*b);nt(h,o)&&(h=s(-h));let w=s(c*E),y=s(h*w);if(!p||nt(y,o)||w===fo)throw new Error("invalid ristretto255 encoding 2");return new e(new k.Point(h,w,st,y))}static fromHex(t){return e.fromBytes(K("ristrettoHex",t,32))}static msm(t,r){return he(e,k.Point.Fn,t,r)}toBytes(){let{X:t,Y:r,Z:n,T:o}=this.ep,s=vt,i=E=>yt.create(E),a=i(i(n+r)*i(n-r)),c=i(t*r),u=i(c*c),{value:l}=ln(i(a*u)),d=i(l*a),f=i(l*c),p=i(d*f*o),x;if(nt(o*p,s)){let E=i(r*Qe),h=i(t*Qe);t=E,r=h,x=i(d*bo)}else x=f;nt(t*p,s)&&(r=i(-r));let b=i((n-r)*x);return nt(b,s)&&(b=i(-b)),yt.toBytes(b)}equals(t){this.assertSame(t);let{X:r,Y:n}=this.ep,{X:o,Y:s}=t.ep,i=u=>yt.create(u),a=i(r*s)===i(n*o),c=i(n*s)===i(r*o);return a||c}is0(){return this.equals(e.ZERO)}};it.BASE=new it(k.Point.BASE);it.ZERO=new it(k.Point.ZERO);it.Fp=yt;it.Fn=po;var xn=e=>{if(e<=127)return 1;if(e<=255)return 2;if(e<=65535)return 3;if(e<=16777215)return 4;throw H.fromCode(new Ut("Length too long (> 4 bytes)"))},pn=(e,t,r)=>{if(r<=127)return e[t]=r,1;if(r<=255)return e[t]=129,e[t+1]=r,2;if(r<=65535)return e[t]=130,e[t+1]=r>>8,e[t+2]=r,3;if(r<=16777215)return e[t]=131,e[t+1]=r>>16,e[t+2]=r>>8,e[t+3]=r,4;throw H.fromCode(new Ut("Length too long (> 4 bytes)"))},rr=(e,t)=>{if(e[t]<128)return 1;if(e[t]===128)throw H.fromCode(new lt("Invalid length 0"));if(e[t]===129)return 2;if(e[t]===130)return 3;if(e[t]===131)return 4;throw H.fromCode(new lt("Length too long (> 4 bytes)"))},Io=(e,t)=>{let r=rr(e,t);if(r===1)return e[t];if(r===2)return e[t+1];if(r===3)return(e[t+1]<<8)+e[t+2];if(r===4)return(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];throw H.fromCode(new lt("Length too long (> 4 bytes)"))},ai=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),nr=Uint8Array.from([48,5,6,3,43,101,112]),fi=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]),ui=Uint8Array.from([48,29,6,13,43,6,1,4,1,130,220,124,5,3,1,2,1,6,12,43,6,1,4,1,130,220,124,5,3,2,1]);function yn(e,t){let r=2+xn(e.byteLength+1),n=t.byteLength+r+e.byteLength,o=0,s=new Uint8Array(1+xn(n)+n);return s[o++]=48,o+=pn(s,o,n),s.set(t,o),o+=t.byteLength,s[o++]=3,o+=pn(s,o,e.byteLength+1),s[o++]=0,s.set(new Uint8Array(e),o),s}var gn=(e,t)=>{let r=0,n=(a,c)=>{if(o[r++]!==a)throw H.fromCode(new lt(`Expected ${c} at offset ${r}`))},o=new Uint8Array(e);if(n(48,"sequence"),r+=rr(o,r),!Mr(o.slice(r,r+t.byteLength),t))throw H.fromCode(new lt("Not the expected OID."));r+=t.byteLength,n(3,"bit string");let s=Io(o,r)-1;r+=rr(o,r),n(0,"0 padding");let i=o.slice(r);if(s!==i.length)throw H.fromCode(new ie(s,i.length));return i};function bn(e){return e!==null&&typeof e=="object"}var Dt=class e{static from(t){if(typeof t=="string"){let r=q(t);return this.fromRaw(r)}else if(bn(t)){let r=t;if(bn(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw(z(n.buffer))}else{if(r instanceof ArrayBuffer)return this.fromRaw(z(r));if("rawKey"in r&&r.rawKey instanceof Uint8Array)return this.fromRaw(r.rawKey);if("derKey"in r)return this.fromDer(r.derKey);if("toDer"in r)return this.fromDer(r.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(t){return new e(t)}static fromDer(t){return new e(this.derDecode(t))}static{this.RAW_KEY_LENGTH=32}static derEncode(t){let r=yn(t,nr);return r.__derEncodedPublicKey__=void 0,r}static derDecode(t){let r=gn(t,nr);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}#t;get rawKey(){return this.#t}#e;get derKey(){return this.#e}constructor(t){if(t.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");this.#t=t,this.#e=e.derEncode(t)}toDer(){return this.derKey}toRaw(){return this.rawKey}},At=class e extends ht{static generate(t){if(t&&t.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");t||(t=k.utils.randomPrivateKey()),Pr(t,new Uint8Array(new Array(32).fill(0)))&&console.warn("Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.");let r=new Uint8Array(32);for(let o=0;o<32;o++)r[o]=t[o];let n=k.getPublicKey(r);return e.fromKeyPair(n,r)}static fromParsedJson(t){let[r,n]=t;return new e(Dt.fromDer(q(r)),q(n))}static fromJSON(t){let r=JSON.parse(t);if(Array.isArray(r)){if(typeof r[0]=="string"&&typeof r[1]=="string")return this.fromParsedJson([r[0],r[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(t)}`)}static fromKeyPair(t,r){return new e(Dt.fromRaw(t),r)}static fromSecretKey(t){let r=k.getPublicKey(t);return e.fromKeyPair(r,t)}#t;#e;constructor(t,r){super(),this.#t=Dt.from(t),this.#e=r}toJSON(){return[v(this.#t.toDer()),v(this.#e)]}getKeyPair(){return{secretKey:this.#e,publicKey:this.#t}}getPublicKey(){return this.#t}async sign(t){let r=k.sign(t,this.#e.slice(0,32));return Object.defineProperty(r,"__signature__",{enumerable:!1,value:void 0}),r}static verify(t,r,n){let[o,s,i]=[t,r,n].map(a=>(typeof a=="string"&&(a=q(a)),z(a)));return k.verify(o,s,i)}};var or=class e extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,e.prototype)}};function mn(e){if(typeof global<"u"&&global.crypto&&global.crypto.subtle)return global.crypto.subtle;if(e)return e;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new or("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var Gt=class e extends ht{static async generate(t){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:o}=t??{},s=mn(o),i=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=z(await s.exportKey("spki",i.publicKey));return Object.assign(a,{__derEncodedPublicKey__:void 0}),new this(i,a,s)}static async fromKeyPair(t,r){let n=mn(r),o=z(await n.exportKey("spki",t.publicKey));return Object.assign(o,{__derEncodedPublicKey__:void 0}),new e(t,o,n)}constructor(t,r,n){super(),this._keyPair=t,this._derKey=r,this._subtleCrypto=n}getKeyPair(){return this._keyPair}getPublicKey(){let t=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return t},r}async sign(t){let r={name:"ECDSA",hash:{name:"SHA-256"}},n=z(await this._subtleCrypto.sign(r,this._keyPair.privateKey,t));return Object.assign(n,{__signature__:void 0}),n}};var pe=class{#t;get rawKey(){return this.#t.rawKey}get derKey(){return this.#t.derKey}toDer(){return this.#t.toDer()}getPublicKey(){return this.#t}getPrincipal(){if(!this.#t.rawKey)throw new Error("Cannot get principal from a public key without a raw key.");return Z.fromUint8Array(new Uint8Array(this.#t.rawKey))}transformRequest(){return Promise.reject("Not implemented. You are attempting to use a partial identity to sign calls, but this identity only has access to the public key.To sign calls, use a DelegationIdentity instead.")}constructor(t){this.#t=t}};function sr(e){if(typeof e!="string"||e.length<64)throw new Error("Invalid public key.");return q(e)}var Lt=class{constructor(t,r,n){this.pubkey=t,this.expiration=r,this.targets=n}toCborValue(){return{pubkey:this.pubkey,expiration:this.expiration,...this.targets&&{targets:this.targets}}}toJSON(){return{expiration:this.expiration.toString(16),pubkey:v(this.pubkey),...this.targets&&{targets:this.targets.map(t=>t.toHex())}}}};async function Bo(e,t,r,n){let o=new Lt(t.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...Me,...new Uint8Array(Mt({...o}))]),i=await e.sign(s);return{delegation:o,signature:i}}var Ot=class e{static async create(t,r,n=new Date(Date.now()+900*1e3),o={}){let s=await Bo(t,r,n,o.targets);return new e([...o.previous?.delegations||[],s],o.previous?.publicKey||t.getPublicKey().toDer())}static fromJSON(t){let{publicKey:r,delegations:n}=typeof t=="string"?JSON.parse(t):t;if(!Array.isArray(n))throw new Error("Invalid delegations.");let o=n.map(s=>{let{delegation:i,signature:a}=s,{pubkey:c,expiration:u,targets:l}=i;if(l!==void 0&&!Array.isArray(l))throw new Error("Invalid targets.");return{delegation:new Lt(sr(c),BigInt("0x"+u),l&&l.map(d=>{if(typeof d!="string")throw new Error("Invalid target.");return Z.fromHex(d)})),signature:sr(a)}});return new this(o,sr(r))}static fromDelegations(t,r){return new this(t,r)}constructor(t,r){this.delegations=t,this.publicKey=r}toJSON(){return{delegations:this.delegations.map(t=>{let{delegation:r,signature:n}=t,{targets:o}=r;return{delegation:{expiration:r.expiration.toString(16),pubkey:v(r.pubkey),...o&&{targets:o.map(s=>s.toHex())}},signature:v(n)}}),publicKey:v(this.publicKey)}}},Yt=class extends ht{static fromDelegation(t,r){return new this(t,r)}constructor(t,r){super(),this._inner=t,this._delegation=r}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(t){return this._inner.sign(t)}async transformRequest(t){let{body:r,...n}=t,o=await Mt(r);return{...n,body:{content:r,sender_sig:await this.sign(new Uint8Array([...jt,...new Uint8Array(o)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}}}},Ft=class e extends pe{#t;get delegation(){return this.#t}constructor(t,r){super(t),this.#t=r}static fromDelegation(t,r){return new e(t,r)}};function Zt(e,t){for(let{delegation:o}of e.delegations)if(+new Date(Number(o.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=t?.scope;n&&(Array.isArray(n)?r.push(...n.map(o=>typeof o=="string"?Z.fromText(o):o)):r.push(typeof n=="string"?Z.fromText(n):n));for(let o of r){let s=o.toText();for(let{delegation:i}of e.delegations){if(i.targets===void 0)continue;let a=!0;for(let c of i.targets)if(c.toText()===s){a=!1;break}if(a)return!1}}return!0}var wn=["mousedown","mousemove","keydown","touchstart","wheel"],Wt=class{callbacks=[];idleTimeout=600*1e3;timeoutID=void 0;static create(t={}){return new this(t)}constructor(t={}){let{onIdle:r,idleTimeout:n=600*1e3}=t||{};this.callbacks=r?[r]:[],this.idleTimeout=n;let o=this._resetTimer.bind(this);window.addEventListener("load",o,!0),wn.forEach(function(i){document.addEventListener(i,o,!0)});let s=(i,a)=>{let c;return(...u)=>{let l=this,d=function(){c=void 0,i.apply(l,u)};clearTimeout(c),c=window.setTimeout(d,a)}};if(t?.captureScroll){let i=s(o,t?.scrollDebounce??100);window.addEventListener("scroll",i,!0)}o()}registerCallback(t){this.callbacks.push(t)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let t=this._resetTimer.bind(this);wn.forEach(function(r){document.removeEventListener(r,t,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let t=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(t,this.idleTimeout)}};var Ao=(e,t)=>t.some(r=>e instanceof r),En,_n;function Oo(){return En||(En=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function So(){return _n||(_n=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var In=new WeakMap,cr=new WeakMap,Bn=new WeakMap,ir=new WeakMap,fr=new WeakMap;function To(e){let t=new Promise((r,n)=>{let o=()=>{e.removeEventListener("success",s),e.removeEventListener("error",i)},s=()=>{r(J(e.result)),o()},i=()=>{n(e.error),o()};e.addEventListener("success",s),e.addEventListener("error",i)});return t.then(r=>{r instanceof IDBCursor&&In.set(r,e)}).catch(()=>{}),fr.set(t,e),t}function vo(e){if(cr.has(e))return;let t=new Promise((r,n)=>{let o=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",i),e.removeEventListener("abort",i)},s=()=>{r(),o()},i=()=>{n(e.error||new DOMException("AbortError","AbortError")),o()};e.addEventListener("complete",s),e.addEventListener("error",i),e.addEventListener("abort",i)});cr.set(e,t)}var ar={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return cr.get(e);if(t==="objectStoreNames")return e.objectStoreNames||Bn.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return J(e[t])},set(e,t,r){return e[t]=r,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};function An(e){ar=e(ar)}function Do(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...r){let n=e.call(ye(this),t,...r);return Bn.set(n,t.sort?t.sort():[t]),J(n)}:So().includes(e)?function(...t){return e.apply(ye(this),t),J(In.get(this))}:function(...t){return J(e.apply(ye(this),t))}}function Lo(e){return typeof e=="function"?Do(e):(e instanceof IDBTransaction&&vo(e),Ao(e,Oo())?new Proxy(e,ar):e)}function J(e){if(e instanceof IDBRequest)return To(e);if(ir.has(e))return ir.get(e);let t=Lo(e);return t!==e&&(ir.set(e,t),fr.set(t,e)),t}var ye=e=>fr.get(e);function Sn(e,t,{blocked:r,upgrade:n,blocking:o,terminated:s}={}){let i=indexedDB.open(e,t),a=J(i);return n&&i.addEventListener("upgradeneeded",c=>{n(J(i.result),c.oldVersion,c.newVersion,J(i.transaction),c)}),r&&i.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),o&&c.addEventListener("versionchange",u=>o(u.oldVersion,u.newVersion,u))}).catch(()=>{}),a}var Co=["get","getKey","getAll","getAllKeys","count"],Ro=["put","add","delete","clear"],ur=new Map;function On(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(ur.get(t))return ur.get(t);let r=t.replace(/FromIndex$/,""),n=t!==r,o=Ro.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(o||Co.includes(r)))return;let s=async function(i,...a){let c=this.transaction(i,o?"readwrite":"readonly"),u=c.store;return n&&(u=u.index(a.shift())),(await Promise.all([u[r](...a),o&&c.done]))[0]};return ur.set(t,s),s}An(e=>({...e,get:(t,r,n)=>On(t,r)||e.get(t,r,n),has:(t,r)=>!!On(t,r)||e.has(t,r)}));var Tn="auth-client-db",vn="ic-keyval",No=async(e=Tn,t=vn,r)=>(ge&&localStorage?.getItem($)&&(localStorage.removeItem($),localStorage.removeItem(Y)),await Sn(e,r,{upgrade:n=>{n.objectStoreNames.contains(t)&&n.clear(t),n.createObjectStore(t)}}));async function Po(e,t,r){return await e.get(t,r)}async function Uo(e,t,r,n){return await e.put(t,n,r)}async function Mo(e,t,r){return await e.delete(t,r)}var Xt=class e{_db;_storeName;static async create(t){let{dbName:r=Tn,storeName:n=vn,version:o=Dn}=t??{},s=await No(r,n,o);return new e(s,n)}constructor(t,r){this._db=t,this._storeName=r}async set(t,r){return await Uo(this._db,this._storeName,t,r)}async get(t){return await Po(this._db,this._storeName,t)??null}async remove(t){return await Mo(this._db,this._storeName,t)}};var Y="identity",$="delegation",Ln="iv",Dn=1,ge=typeof window<"u",zt=class{prefix;_localStorage;constructor(t="ic-",r){this.prefix=t,this._localStorage=r}get(t){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+t))}set(t,r){return this._getLocalStorage().setItem(this.prefix+t,r),Promise.resolve()}remove(t){return this._getLocalStorage().removeItem(this.prefix+t),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let t=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!t)throw new Error("Could not find local storage.");return t}},gt=class{#t;constructor(t){this.#t=t??{}}initializedDb;get _db(){return new Promise(t=>{if(this.initializedDb){t(this.initializedDb);return}Xt.create(this.#t).then(r=>{this.initializedDb=r,t(r)})})}async get(t){return await(await this._db).get(t)}async set(t,r){await(await this._db).set(t,r)}async remove(t){await(await this._db).remove(t)}};var jo=BigInt(1e9),qo=BigInt(3600),Ho=jo*qo,Ko="https://identity.internetcomputer.org",ko="#authorize",$o=BigInt(8)*Ho,dr="ECDSA",lr="Ed25519",Vo=500,Go="UserInterrupt",be=class{_identity;_key;_chain;_storage;idleManager;_createOptions;_idpWindow;_eventHandler;static async create(t={}){let r=t.storage??new gt,n=t.keyType??dr,o=null;if(t.identity)o=t.identity;else{let c=await r.get(Y);if(!c&&ge)try{let u=new zt,l=await u.get($),d=await u.get(Y);l&&d&&n===dr&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await r.set($,l),await r.set(Y,d),c=l,await u.remove($),await u.remove(Y))}catch(u){console.error("error while attempting to recover localstorage: "+u)}if(c)try{typeof c=="object"?n===lr&&typeof c=="string"?o=At.fromJSON(c):o=await Gt.fromKeyPair(c):typeof c=="string"&&(o=At.fromJSON(c))}catch{}}let s=new qt,i=null;if(o)try{let c=await r.get($);if(typeof c=="object"&&c!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");t.identity?s=t.identity:c&&(i=Ot.fromJSON(c),Zt(i)?"toDer"in o?s=Ft.fromDelegation(o,i):s=Yt.fromDelegation(o,i):(await hr(r),o=null))}catch(c){console.error(c),await hr(r),o=null}let a;return t.idleOptions?.disableIdle?a=void 0:(i||t.identity)&&(a=Wt.create(t.idleOptions)),o||(n===lr?(o=At.generate(),await r.set(Y,JSON.stringify(o.toJSON()))):(t.storage&&n===dr&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${lr}' as the key type, as it can serialize to a string`),o=await Gt.generate(),await r.set(Y,o.getKeyPair()))),new this(s,o,i,r,a,t)}constructor(t,r,n,o,s,i,a,c){this._identity=t,this._key=r,this._chain=n,this._storage=o,this.idleManager=s,this._createOptions=i,this._idpWindow=a,this._eventHandler=c,this._registerDefaultIdleCallback()}_registerDefaultIdleCallback(){let t=this._createOptions?.idleOptions;!t?.onIdle&&!t?.disableDefaultIdleCallback&&this.idleManager?.registerCallback(()=>{this.logout(),location.reload()})}async _handleSuccess(t,r){let n=t.delegations.map(a=>({delegation:new Lt(a.delegation.pubkey,a.delegation.expiration,a.delegation.targets),signature:a.signature})),o=Ot.fromDelegations(n,t.userPublicKey),s=this._key;if(!s)return;this._chain=o,"toDer"in s?this._identity=Ft.fromDelegation(s,this._chain):this._identity=Yt.fromDelegation(s,this._chain),this._idpWindow?.close();let i=this._createOptions?.idleOptions;!this.idleManager&&!i?.disableIdle&&(this.idleManager=Wt.create(i),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set($,JSON.stringify(this._chain.toJSON())),r?.(t)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null&&Zt(this._chain)}async login(t){let r=Yo(this._createOptions?.loginOptions,t),n=r?.maxTimeToLive??$o,o=new URL(r?.identityProvider?.toString()||Ko);o.hash=ko,this._idpWindow?.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(o,{maxTimeToLive:n,...r}),window.addEventListener("message",this._eventHandler),this._idpWindow=window.open(o.toString(),"idpWindow",r?.windowOpenerFeatures)??void 0;let s=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Go,r?.onError):setTimeout(s,Vo))};s()}_getEventHandler(t,r){return async n=>{if(n.origin!==t.origin)return;let o=n.data;switch(o.kind){case"authorize-ready":{let s={kind:"authorize-client",sessionPublicKey:new Uint8Array(this._key?.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:r?.derivationOrigin?.toString(),...r?.customValues};this._idpWindow?.postMessage(s,t.origin);break}case"authorize-client-success":try{await this._handleSuccess(o,r?.onSuccess)}catch(s){this._handleFailure(s.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(o.text,r?.onError);break;default:break}}}_handleFailure(t,r){this._idpWindow?.close(),r?.(t),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(t={}){if(await hr(this._storage),this._identity=new qt,this._chain=null,t.returnTo)try{window.history.pushState({},"",t.returnTo)}catch{window.location.href=t.returnTo}}};async function hr(e){await e.remove(Y),await e.remove($),await e.remove(Ln)}function Yo(e,t){if(!e&&!t)return;let r=e?.customValues||t?.customValues?{...e?.customValues,...t?.customValues}:void 0;return{...e,...t,customValues:r}}var gc=BigInt(144e11);var Cn=1e3;var Rn=()=>be.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Nn=({data:e})=>{let{msg:t}=e;switch(t){case"junoStartAuthTimer":Fo();return;case"junoStopAuthTimer":Pn();return}},me,Fo=()=>me=setInterval(async()=>await Zo(),Cn),Pn=()=>{me&&(clearInterval(me),me=void 0)},Zo=async()=>{let[e,t]=await Promise.all([Wo(),Xo()]);if(e&&t.valid&&t.delegation!==null){Jo(t.delegation);return}zo()},Wo=async()=>(await Rn()).isAuthenticated(),Xo=async()=>{let t=await new gt().get($),r=t!==null?Ot.fromJSON(t):null;return{valid:r!==null&&Zt(r),delegation:r}},zo=()=>{Pn(),postMessage({msg:"junoSignOutAuthTimer"})},Jo=e=>{let t=e.delegations[0]?.delegation.expiration;if(t===void 0)return;let r=new Date(Number(t/BigInt(1e6))).getTime()-Date.now();postMessage({msg:"junoDelegationRemainingTime",data:{authRemainingTime:r}})};onmessage=e=>{Nn(e)};})();
|
|
20
12
|
/*! Bundled license information:
|
|
21
13
|
|
|
22
|
-
ieee754/index.js:
|
|
23
|
-
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
24
|
-
|
|
25
|
-
buffer/index.js:
|
|
26
|
-
buffer/index.js:
|
|
27
|
-
(*!
|
|
28
|
-
* The buffer module from node.js, for the browser.
|
|
29
|
-
*
|
|
30
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
31
|
-
* @license MIT
|
|
32
|
-
*)
|
|
33
|
-
|
|
34
14
|
@noble/hashes/esm/utils.js:
|
|
35
15
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
36
16
|
|
|
37
|
-
@noble/curves/esm/
|
|
17
|
+
@noble/curves/esm/utils.js:
|
|
38
18
|
@noble/curves/esm/abstract/modular.js:
|
|
39
19
|
@noble/curves/esm/abstract/curve.js:
|
|
40
20
|
@noble/curves/esm/abstract/edwards.js:
|