@junobuild/core 0.0.46 → 0.0.47

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.
@@ -1,27 +1,27 @@
1
- import{A as Wn,C as vr,a as Un,b as Io,c as Me,d as Fn,e as kn,f as qn,g as Kn,h as Vn,i as B,j as Do,k as Tt,l as Mn,m as ye,n as Lo,o as je,p as j,q as pt,r as He,s as jn,t as Hn,u as Ct,v as Tr,w as $n,x as $e,y as me,z as we}from"./chunk-572NAHJJ.js";var Ln=Un(ze=>{"use strict";ze.byteLength=ns;ze.toByteArray=os;ze.fromByteArray=cs;var ht=[],it=[],rs=typeof Uint8Array<"u"?Uint8Array:Array,Pr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Mt=0,In=Pr.length;Mt<In;++Mt)ht[Mt]=Pr[Mt],it[Pr.charCodeAt(Mt)]=Mt;var Mt,In;it[45]=62;it[95]=63;function Dn(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function ns(t){var e=Dn(t),r=e[0],n=e[1];return(r+n)*3/4-n}function is(t,e,r){return(e+r)*3/4-r}function os(t){var e,r=Dn(t),n=r[0],i=r[1],o=new rs(is(t,n,i)),s=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=it[t.charCodeAt(c)]<<18|it[t.charCodeAt(c+1)]<<12|it[t.charCodeAt(c+2)]<<6|it[t.charCodeAt(c+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=it[t.charCodeAt(c)]<<2|it[t.charCodeAt(c+1)]>>4,o[s++]=e&255),i===1&&(e=it[t.charCodeAt(c)]<<10|it[t.charCodeAt(c+1)]<<4|it[t.charCodeAt(c+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function ss(t){return ht[t>>18&63]+ht[t>>12&63]+ht[t>>6&63]+ht[t&63]}function as(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),i.push(ss(n));return i.join("")}function cs(t){for(var e,r=t.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(as(t,s,s+o>a?a:s+o));return n===1?(e=t[r-1],i.push(ht[e>>2]+ht[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(ht[e>>10]+ht[e>>4&63]+ht[e<<2&63]+"=")),i.join("")}});var mi=Un(ee=>{"use strict";var Cr=Ln(),Lt=Do(),ti=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ee.Buffer=d;ee.SlowBuffer=hs;ee.INSPECT_MAX_BYTES=50;var Ze=2147483647;ee.kMaxLength=Ze;d.TYPED_ARRAY_SUPPORT=ls();!d.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 ls(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}});Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function Bt(t){if(t>Ze)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,d.prototype),e}function d(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return qr(t)}return ii(t,e,r)}d.poolSize=8192;function ii(t,e,r){if(typeof t=="string")return ds(t,e);if(ArrayBuffer.isView(t))return fs(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(yt(t,ArrayBuffer)||t&&yt(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(yt(t,SharedArrayBuffer)||t&&yt(t.buffer,SharedArrayBuffer)))return Fr(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return d.from(n,e,r);let i=ps(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return d.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}d.from=function(t,e,r){return ii(t,e,r)};Object.setPrototypeOf(d.prototype,Uint8Array.prototype);Object.setPrototypeOf(d,Uint8Array);function oi(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function us(t,e,r){return oi(t),t<=0?Bt(t):e!==void 0?typeof r=="string"?Bt(t).fill(e,r):Bt(t).fill(e):Bt(t)}d.alloc=function(t,e,r){return us(t,e,r)};function qr(t){return oi(t),Bt(t<0?0:Kr(t)|0)}d.allocUnsafe=function(t){return qr(t)};d.allocUnsafeSlow=function(t){return qr(t)};function ds(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!d.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=si(t,e)|0,n=Bt(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Ur(t){let e=t.length<0?0:Kr(t.length)|0,r=Bt(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function fs(t){if(yt(t,Uint8Array)){let e=new Uint8Array(t);return Fr(e.buffer,e.byteOffset,e.byteLength)}return Ur(t)}function Fr(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,d.prototype),n}function ps(t){if(d.isBuffer(t)){let e=Kr(t.length)|0,r=Bt(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Mr(t.length)?Bt(0):Ur(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Ur(t.data)}function Kr(t){if(t>=Ze)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ze.toString(16)+" bytes");return t|0}function hs(t){return+t!=t&&(t=0),d.alloc(+t)}d.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==d.prototype};d.compare=function(e,r){if(yt(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),yt(r,Uint8Array)&&(r=d.from(r,r.offset,r.byteLength)),!d.isBuffer(e)||!d.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(e[o]!==r[o]){n=e[o],i=r[o];break}return n<i?-1:i<n?1:0};d.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};d.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return d.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=d.allocUnsafe(r),o=0;for(n=0;n<e.length;++n){let s=e[n];if(yt(s,Uint8Array))o+s.length>i.length?(d.isBuffer(s)||(s=d.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(d.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function si(t,e){if(d.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||yt(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return kr(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return yi(t).length;default:if(i)return n?-1:kr(t).length;e=(""+e).toLowerCase(),i=!0}}d.byteLength=si;function ys(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return vs(this,e,r);case"utf8":case"utf-8":return ci(this,e,r);case"ascii":return As(this,e,r);case"latin1":case"binary":return Ts(this,e,r);case"base64":return bs(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Bs(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}d.prototype._isBuffer=!0;function jt(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}d.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)jt(this,r,r+1);return this};d.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)jt(this,r,r+3),jt(this,r+1,r+2);return this};d.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)jt(this,r,r+7),jt(this,r+1,r+6),jt(this,r+2,r+5),jt(this,r+3,r+4);return this};d.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?ci(this,0,e):ys.apply(this,arguments)};d.prototype.toLocaleString=d.prototype.toString;d.prototype.equals=function(e){if(!d.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:d.compare(this,e)===0};d.prototype.inspect=function(){let e="",r=ee.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};ti&&(d.prototype[ti]=d.prototype.inspect);d.prototype.compare=function(e,r,n,i,o){if(yt(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),!d.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let s=o-i,a=n-r,c=Math.min(s,a),u=this.slice(i,o),l=e.slice(r,n);for(let f=0;f<c;++f)if(u[f]!==l[f]){s=u[f],a=l[f];break}return s<a?-1:a<s?1:0};function ai(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Mr(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=d.from(e,n)),d.isBuffer(e))return e.length===0?-1:ei(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):ei(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ei(t,e,r,n,i){let o=1,s=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;o=2,s/=2,a/=2,r/=2}function c(l,f){return o===1?l[f]:l.readUInt16BE(f*o)}let u;if(i){let l=-1;for(u=r;u<s;u++)if(c(t,u)===c(e,l===-1?0:u-l)){if(l===-1&&(l=u),u-l+1===a)return l*o}else l!==-1&&(u-=u-l),l=-1}else for(r+a>s&&(r=s-a),u=r;u>=0;u--){let l=!0;for(let f=0;f<a;f++)if(c(t,u+f)!==c(e,f)){l=!1;break}if(l)return u}return-1}d.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};d.prototype.indexOf=function(e,r,n){return ai(this,e,r,n,!0)};d.prototype.lastIndexOf=function(e,r,n){return ai(this,e,r,n,!1)};function ms(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(e.substr(s*2,2),16);if(Mr(a))return s;t[r+s]=a}return s}function ws(t,e,r,n){return Je(kr(e,t.length-r),t,r,n)}function gs(t,e,r,n){return Je(Ns(e),t,r,n)}function _s(t,e,r,n){return Je(yi(e),t,r,n)}function xs(t,e,r,n){return Je(Ps(e,t.length-r),t,r,n)}d.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>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 o=this.length-r;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return ms(this,e,r,n);case"utf8":case"utf-8":return ws(this,e,r,n);case"ascii":case"latin1":case"binary":return gs(this,e,r,n);case"base64":return _s(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xs(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function bs(t,e,r){return e===0&&r===t.length?Cr.fromByteArray(t):Cr.fromByteArray(t.slice(e,r))}function ci(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let o=t[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let c,u,l,f;switch(a){case 1:o<128&&(s=o);break;case 2:c=t[i+1],(c&192)===128&&(f=(o&31)<<6|c&63,f>127&&(s=f));break;case 3:c=t[i+1],u=t[i+2],(c&192)===128&&(u&192)===128&&(f=(o&15)<<12|(c&63)<<6|u&63,f>2047&&(f<55296||f>57343)&&(s=f));break;case 4:c=t[i+1],u=t[i+2],l=t[i+3],(c&192)===128&&(u&192)===128&&(l&192)===128&&(f=(o&15)<<18|(c&63)<<12|(u&63)<<6|l&63,f>65535&&f<1114112&&(s=f))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return Es(n)}var ri=4096;function Es(t){let e=t.length;if(e<=ri)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=ri));return r}function As(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Ts(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function vs(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=e;o<r;++o)i+=Cs[t[o]];return i}function Bs(t,e,r){let n=t.slice(e,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}d.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,d.prototype),i};function H(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return i};d.prototype.readUintBE=d.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=this[e+--r],o=1;for(;r>0&&(o*=256);)i+=this[e+--r]*o;return i};d.prototype.readUint8=d.prototype.readUInt8=function(e,r){return e=e>>>0,r||H(e,1,this.length),this[e]};d.prototype.readUint16LE=d.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||H(e,2,this.length),this[e]|this[e+1]<<8};d.prototype.readUint16BE=d.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||H(e,2,this.length),this[e]<<8|this[e+1]};d.prototype.readUint32LE=d.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||H(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};d.prototype.readUint32BE=d.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||H(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};d.prototype.readBigUInt64LE=Ut(function(e){e=e>>>0,te(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ge(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});d.prototype.readBigUInt64BE=Ut(function(e){e=e>>>0,te(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ge(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});d.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};d.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=r,o=1,s=this[e+--i];for(;i>0&&(o*=256);)s+=this[e+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};d.prototype.readInt8=function(e,r){return e=e>>>0,r||H(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};d.prototype.readInt16LE=function(e,r){e=e>>>0,r||H(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};d.prototype.readInt16BE=function(e,r){e=e>>>0,r||H(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};d.prototype.readInt32LE=function(e,r){return e=e>>>0,r||H(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};d.prototype.readInt32BE=function(e,r){return e=e>>>0,r||H(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};d.prototype.readBigInt64LE=Ut(function(e){e=e>>>0,te(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ge(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});d.prototype.readBigInt64BE=Ut(function(e){e=e>>>0,te(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ge(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});d.prototype.readFloatLE=function(e,r){return e=e>>>0,r||H(e,4,this.length),Lt.read(this,e,!0,23,4)};d.prototype.readFloatBE=function(e,r){return e=e>>>0,r||H(e,4,this.length),Lt.read(this,e,!1,23,4)};d.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||H(e,8,this.length),Lt.read(this,e,!0,52,8)};d.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||H(e,8,this.length),Lt.read(this,e,!1,52,8)};function et(t,e,r,n,i,o){if(!d.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;et(this,e,r,n,a,0)}let o=1,s=0;for(this[r]=e&255;++s<n&&(o*=256);)this[r+s]=e/o&255;return r+n};d.prototype.writeUintBE=d.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;et(this,e,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=e&255;--o>=0&&(s*=256);)this[r+o]=e/s&255;return r+n};d.prototype.writeUint8=d.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,1,255,0),this[r]=e&255,r+1};d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function li(t,e,r,n,i){hi(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,r}function ui(t,e,r,n,i){hi(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o=o>>8,t[r+6]=o,o=o>>8,t[r+5]=o,o=o>>8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s=s>>8,t[r+2]=s,s=s>>8,t[r+1]=s,s=s>>8,t[r]=s,r+8}d.prototype.writeBigUInt64LE=Ut(function(e,r=0){return li(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});d.prototype.writeBigUInt64BE=Ut(function(e,r=0){return ui(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});d.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);et(this,e,r,n,c-1,-c)}let o=0,s=1,a=0;for(this[r]=e&255;++o<n&&(s*=256);)e<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};d.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);et(this,e,r,n,c-1,-c)}let o=n-1,s=1,a=0;for(this[r+o]=e&255;--o>=0&&(s*=256);)e<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};d.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};d.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};d.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};d.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};d.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};d.prototype.writeBigInt64LE=Ut(function(e,r=0){return li(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});d.prototype.writeBigInt64BE=Ut(function(e,r=0){return ui(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function di(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function fi(t,e,r,n,i){return e=+e,r=r>>>0,i||di(t,e,r,4,34028234663852886e22,-34028234663852886e22),Lt.write(t,e,r,n,23,4),r+4}d.prototype.writeFloatLE=function(e,r,n){return fi(this,e,r,!0,n)};d.prototype.writeFloatBE=function(e,r,n){return fi(this,e,r,!1,n)};function pi(t,e,r,n,i){return e=+e,r=r>>>0,i||di(t,e,r,8,17976931348623157e292,-17976931348623157e292),Lt.write(t,e,r,n,52,8),r+8}d.prototype.writeDoubleLE=function(e,r,n){return pi(this,e,r,!0,n)};d.prototype.writeDoubleBE=function(e,r,n){return pi(this,e,r,!1,n)};d.prototype.copy=function(e,r,n,i){if(!d.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<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),e.length-r<i-n&&(i=e.length-r+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),o};d.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=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"&&!d.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let s=e.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=r;o<n;++o)this[o]=e;else{let s=d.isBuffer(e)?e:d.from(e,i),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var Dt={};function Vr(t,e,r){Dt[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Vr("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Vr("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Vr("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=ni(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=ni(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function ni(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function Ss(t,e,r){te(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&ge(e,t.length-(r+1))}function hi(t,e,r,n,i,o){if(t>r||t<e){let s=typeof e=="bigint"?"n":"",a;throw o>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${r}${s}`,new Dt.ERR_OUT_OF_RANGE("value",a,t)}Ss(n,i,o)}function te(t,e){if(typeof t!="number")throw new Dt.ERR_INVALID_ARG_TYPE(e,"number",t)}function ge(t,e,r){throw Math.floor(t)!==t?(te(t,r),new Dt.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new Dt.ERR_BUFFER_OUT_OF_BOUNDS:new Dt.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Os=/[^+/0-9A-Za-z-_]/g;function Rs(t){if(t=t.split("=")[0],t=t.trim().replace(Os,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function kr(t,e){e=e||1/0;let r,n=t.length,i=null,o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function Ns(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Ps(t,e){let r,n,i,o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function yi(t){return Cr.toByteArray(Rs(t))}function Je(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function yt(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Mr(t){return t!==t}var Cs=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Ut(t){return typeof BigInt>"u"?Us:t}function Us(){throw new Error("BigInt not supported")}});var V=t=>t==null,K=t=>!V(t);var Br="__bigint__",Sr="__principal__",Or="__uint8array__",ts=(t,e)=>typeof e=="bigint"?{[Br]:`${e}`}:K(e)&&e instanceof B?{[Sr]:e.toText()}:K(e)&&e instanceof Uint8Array?{[Or]:Array.from(e)}:e,es=(t,e)=>{let r=n=>e[n];return K(e)&&typeof e=="object"&&Br in e?BigInt(r(Br)):K(e)&&typeof e=="object"&&Sr in e?B.fromText(r(Sr)):K(e)&&typeof e=="object"&&Or in e?Uint8Array.from(r(Or)):e},G=t=>K(t)?[t]:[],z=t=>t?.[0],Gn=async t=>{let e=new Blob([JSON.stringify(t,ts)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},We=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),es)},Ge=()=>typeof window<"u";var Qt=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:r})=>r(e))}subscribe(e){let r=Symbol();return this.callbacks.push({id:r,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var vt=class t extends Qt{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let r=super.subscribe(e);return e(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var Rr=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var Yn=BigInt(144e11),zn={width:576,height:576},Zn={width:505,height:705},Jn="internetcomputer.org";var It="http://127.0.0.1:5987",Xn="rdmx6-jaaaa-aaaaa-aaadq-cai";var rt=class t extends Qt{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var Nr=({width:t,height:e})=>{if(!Ge()||V(window)||V(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-e/2,o=r/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${o}`};var Ye=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=rt.getInstance().get()?.container;if(V(n)||n===!1)return`https://identity.${this.#t??Jn}`;let i=rt.getInstance().get(),o=K(i)&&K(i?.internetIdentityId)?i.internetIdentityId:Xn,{host:s,protocol:a}=new URL(n===!0?It:n);return/apple/i.test(navigator?.vendor)?`${a}//${s}?canisterId=${o}`:`${a}//${o}.${s.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:Nr(zn)},identityProvider:r()}}},Qn=class{#t;#e;constructor({appName:e,logoUrl:r}){this.#t=e,this.#e=r}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:Nr(Zn)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};var no=Me(mi());var Xe;(function(t){t[t.SysFatal=1]="SysFatal",t[t.SysTransient=2]="SysTransient",t[t.DestinationInvalid=3]="DestinationInvalid",t[t.CanisterReject=4]="CanisterReject",t[t.CanisterError=5]="CanisterError"})(Xe||(Xe={}));var Fs=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},ks=new TextEncoder().encode(`
2
- ic-request`),St=class{getPrincipal(){return this._principal||(this._principal=B.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=Fs(e,["body"]),i=await Ct(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(je(ks,i))}})}},Ot=class{getPrincipal(){return B.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};var wi=Me($n());var _e=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let t=new Uint32Array(1);return window.crypto.getRandomValues(t),t[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let t=new Uint32Array(1);return crypto.getRandomValues(t),t[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};var Qe;(function(t){t.Call="call"})(Qe||(Qe={}));function re(){let t=new ArrayBuffer(16),e=new DataView(t),r=_e(),n=_e(),i=_e(),o=_e();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,o),t}var qs=BigInt(1e6),Ks=60*1e3,Ht=class{constructor(e){let o=BigInt(Math.floor(Date.now()+e-Ks))*qs/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=o}toCBOR(){return wi.value.u64(this._value.toString(16),16)}toHash(){return Mn(this._value)}};function jr(t=re){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}function Ie(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}var De=class extends Tt{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};var Le=BigInt(4294967295),Hr=BigInt(32);function gi(t,e=!1){return e?{h:Number(t&Le),l:Number(t>>Hr&Le)}:{h:Number(t>>Hr&Le)|0,l:Number(t&Le)|0}}function Vs(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:o,l:s}=gi(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]}var Ms=(t,e)=>BigInt(t>>>0)<<Hr|BigInt(e>>>0),js=(t,e,r)=>t>>>r,Hs=(t,e,r)=>t<<32-r|e>>>r,$s=(t,e,r)=>t>>>r|e<<32-r,Ws=(t,e,r)=>t<<32-r|e>>>r,Gs=(t,e,r)=>t<<64-r|e>>>r-32,Ys=(t,e,r)=>t>>>r-32|e<<64-r,zs=(t,e)=>e,Zs=(t,e)=>t,Js=(t,e,r)=>t<<r|e>>>32-r,Xs=(t,e,r)=>e<<r|t>>>32-r,Qs=(t,e,r)=>e<<r-32|t>>>64-r,Is=(t,e,r)=>t<<r-32|e>>>64-r;function Ds(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var Ls=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),ta=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,ea=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),ra=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,na=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),ia=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;var oa={fromBig:gi,split:Vs,toBig:Ms,shrSH:js,shrSL:Hs,rotrSH:$s,rotrSL:Ws,rotrBH:Gs,rotrBL:Ys,rotr32H:zs,rotr32L:Zs,rotlSH:Js,rotlSL:Xs,rotlBH:Qs,rotlBL:Is,add:Ds,add3L:Ls,add3H:ta,add4L:ea,add4H:ra,add5H:ia,add5L:na},E=oa;var[sa,aa]=E.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(t=>BigInt(t))),Ft=new Uint32Array(80),kt=new Uint32Array(80),$r=class extends Vn{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:e,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:c,Eh:u,El:l,Fh:f,Fl:h,Gh:y,Gl:g,Hh:w,Hl:T}=this;return[e,r,n,i,o,s,a,c,u,l,f,h,y,g,w,T]}set(e,r,n,i,o,s,a,c,u,l,f,h,y,g,w,T){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=l|0,this.Fh=f|0,this.Fl=h|0,this.Gh=y|0,this.Gl=g|0,this.Hh=w|0,this.Hl=T|0}process(e,r){for(let A=0;A<16;A++,r+=4)Ft[A]=e.getUint32(r),kt[A]=e.getUint32(r+=4);for(let A=16;A<80;A++){let C=Ft[A-15]|0,x=kt[A-15]|0,J=E.rotrSH(C,x,1)^E.rotrSH(C,x,8)^E.shrSH(C,x,7),ut=E.rotrSL(C,x,1)^E.rotrSL(C,x,8)^E.shrSL(C,x,7),W=Ft[A-2]|0,D=kt[A-2]|0,xt=E.rotrSH(W,D,19)^E.rotrBH(W,D,61)^E.shrSH(W,D,6),dt=E.rotrSL(W,D,19)^E.rotrBL(W,D,61)^E.shrSL(W,D,6),bt=E.add4L(ut,dt,kt[A-7],kt[A-16]),Et=E.add4H(bt,J,xt,Ft[A-7],Ft[A-16]);Ft[A]=Et|0,kt[A]=bt|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:c,Dh:u,Dl:l,Eh:f,El:h,Fh:y,Fl:g,Gh:w,Gl:T,Hh:v,Hl:O}=this;for(let A=0;A<80;A++){let C=E.rotrSH(f,h,14)^E.rotrSH(f,h,18)^E.rotrBH(f,h,41),x=E.rotrSL(f,h,14)^E.rotrSL(f,h,18)^E.rotrBL(f,h,41),J=f&y^~f&w,ut=h&g^~h&T,W=E.add5L(O,x,ut,aa[A],kt[A]),D=E.add5H(W,v,C,J,sa[A],Ft[A]),xt=W|0,dt=E.rotrSH(n,i,28)^E.rotrBH(n,i,34)^E.rotrBH(n,i,39),bt=E.rotrSL(n,i,28)^E.rotrBL(n,i,34)^E.rotrBL(n,i,39),Et=n&o^n&a^o&a,he=i&s^i&c^s&c;v=w|0,O=T|0,w=y|0,T=g|0,y=f|0,g=h|0,{h:f,l:h}=E.add(u|0,l|0,D|0,xt|0),u=a|0,l=c|0,a=o|0,c=s|0,o=n|0,s=i|0;let Jt=E.add3L(xt,bt,he);n=E.add3H(Jt,D,dt,Et),i=Jt|0}({h:n,l:i}=E.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=E.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:c}=E.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l}=E.add(this.Dh|0,this.Dl|0,u|0,l|0),{h:f,l:h}=E.add(this.Eh|0,this.El|0,f|0,h|0),{h:y,l:g}=E.add(this.Fh|0,this.Fl|0,y|0,g|0),{h:w,l:T}=E.add(this.Gh|0,this.Gl|0,w|0,T|0),{h:v,l:O}=E.add(this.Hh|0,this.Hl|0,v|0,O|0),this.set(n,i,o,s,a,c,u,l,f,h,y,g,w,T,v,O)}roundClean(){Ft.fill(0),kt.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)}};var Wr=qn(()=>new $r);var pl=BigInt(0),ca=BigInt(1),la=BigInt(2);function xe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var ua=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function tr(t){if(!xe(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=ua[t[r]];return e}function xi(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var Rt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function _i(t){if(t>=Rt._0&&t<=Rt._9)return t-Rt._0;if(t>=Rt._A&&t<=Rt._F)return t-(Rt._A-10);if(t>=Rt._a&&t<=Rt._f)return t-(Rt._a-10)}function bi(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;i<r;i++,o+=2){let s=_i(t.charCodeAt(o)),a=_i(t.charCodeAt(o+1));if(s===void 0||a===void 0){let c=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+o)}n[i]=s*16+a}return n}function Ei(t){return xi(tr(t))}function ne(t){if(!xe(t))throw new Error("Uint8Array expected");return xi(tr(Uint8Array.from(t).reverse()))}function Gr(t,e){return bi(t.toString(16).padStart(e*2,"0"))}function be(t,e){return Gr(t,e).reverse()}function mt(t,e,r){let n;if(typeof e=="string")try{n=bi(e)}catch(o){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${o}`)}else if(xe(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function Yr(...t){let e=0;for(let i=0;i<t.length;i++){let o=t[i];if(!xe(o))throw new Error("Uint8Array expected");e+=o.length}let r=new Uint8Array(e),n=0;for(let i=0;i<t.length;i++){let o=t[i];r.set(o,n),n+=o.length}return r}var Ai=t=>(la<<BigInt(t-1))-ca;var da={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||xe(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function ie(t,e,r={}){let n=(i,o,s)=>{let a=da[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let c=t[i];if(!(s&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${o}`)};for(let[i,o]of Object.entries(e))n(i,o,!1);for(let[i,o]of Object.entries(r))n(i,o,!0);return t}var M=BigInt(0),k=BigInt(1),$t=BigInt(2),pa=BigInt(3),zr=BigInt(4),Ti=BigInt(5),vi=BigInt(8),ha=BigInt(9),ya=BigInt(16);function q(t,e){let r=t%e;return r>=M?r:e+r}function ma(t,e,r){if(r<=M||e<M)throw new Error("Expected power/modulo > 0");if(r===k)return M;let n=k;for(;e>M;)e&k&&(n=n*t%r),t=t*t%r,e>>=k;return n}function st(t,e,r){let n=t;for(;e-- >M;)n*=n,n%=r;return n}function Bi(t,e){if(t===M||e<=M)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=q(t,e),n=e,i=M,o=k,s=k,a=M;for(;r!==M;){let u=n/r,l=n%r,f=i-s*u,h=o-a*u;n=r,r=l,i=s,o=a,s=f,a=h}if(n!==k)throw new Error("invert: does not exist");return q(i,e)}function wa(t){let e=(t-k)/$t,r,n,i;for(r=t-k,n=0;r%$t===M;r/=$t,n++);for(i=$t;i<t&&ma(i,e,t)!==t-k;i++);if(n===1){let s=(t+k)/zr;return function(c,u){let l=c.pow(u,s);if(!c.eql(c.sqr(l),u))throw new Error("Cannot find square root");return l}}let o=(r+k)/$t;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let u=n,l=a.pow(a.mul(a.ONE,i),r),f=a.pow(c,o),h=a.pow(c,r);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let y=1;for(let w=a.sqr(h);y<u&&!a.eql(w,a.ONE);y++)w=a.sqr(w);let g=a.pow(l,k<<BigInt(u-y-1));l=a.sqr(g),f=a.mul(f,g),h=a.mul(h,l),u=y}return f}}function ga(t){if(t%zr===pa){let e=(t+k)/zr;return function(n,i){let o=n.pow(i,e);if(!n.eql(n.sqr(o),i))throw new Error("Cannot find square root");return o}}if(t%vi===Ti){let e=(t-Ti)/vi;return function(n,i){let o=n.mul(i,$t),s=n.pow(o,e),a=n.mul(i,s),c=n.mul(n.mul(a,$t),s),u=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(u),i))throw new Error("Cannot find square root");return u}}return t%ya,wa(t)}var Si=(t,e)=>(q(t,e)&k)===k,_a=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Oi(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=_a.reduce((n,i)=>(n[i]="function",n),e);return ie(t,r)}function xa(t,e,r){if(r<M)throw new Error("Expected power > 0");if(r===M)return t.ONE;if(r===k)return e;let n=t.ONE,i=e;for(;r>M;)r&k&&(n=t.mul(n,i)),i=t.sqr(i),r>>=k;return n}function ba(t,e){let r=new Array(e.length),n=e.reduce((o,s,a)=>t.is0(s)?o:(r[a]=o,t.mul(o,s)),t.ONE),i=t.inv(n);return e.reduceRight((o,s,a)=>t.is0(s)?o:(r[a]=t.mul(o,r[a]),t.mul(o,s)),i),r}function Zr(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Ri(t,e,r=!1,n={}){if(t<=M)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:o}=Zr(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=ga(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:Ai(i),ZERO:M,ONE:k,create:c=>q(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return M<=c&&c<t},is0:c=>c===M,isOdd:c=>(c&k)===k,neg:c=>q(-c,t),eql:(c,u)=>c===u,sqr:c=>q(c*c,t),add:(c,u)=>q(c+u,t),sub:(c,u)=>q(c-u,t),mul:(c,u)=>q(c*u,t),pow:(c,u)=>xa(a,c,u),div:(c,u)=>q(c*Bi(u,t),t),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>Bi(c,t),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>ba(a,c),cmov:(c,u,l)=>l?u:c,toBytes:c=>r?be(c,o):Gr(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return r?ne(c):Ei(c)}});return Object.freeze(a)}function Ni(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}var Ea=BigInt(0),Jr=BigInt(1);function Pi(t,e){let r=(i,o)=>{let s=o.negate();return i?s:o},n=i=>{let o=Math.ceil(e/i)+1,s=2**(i-1);return{windows:o,windowSize:s}};return{constTimeNegate:r,unsafeLadder(i,o){let s=t.ZERO,a=i;for(;o>Ea;)o&Jr&&(s=s.add(a)),a=a.double(),o>>=Jr;return s},precomputeWindow(i,o){let{windows:s,windowSize:a}=n(o),c=[],u=i,l=u;for(let f=0;f<s;f++){l=u,c.push(l);for(let h=1;h<a;h++)l=l.add(u),c.push(l);u=l.double()}return c},wNAF(i,o,s){let{windows:a,windowSize:c}=n(i),u=t.ZERO,l=t.BASE,f=BigInt(2**i-1),h=2**i,y=BigInt(i);for(let g=0;g<a;g++){let w=g*c,T=Number(s&f);s>>=y,T>c&&(T-=h,s+=Jr);let v=w,O=w+Math.abs(T)-1,A=g%2!==0,C=T<0;T===0?l=l.add(r(A,o[v])):u=u.add(r(C,o[O]))}return{p:u,f:l}},wNAFCached(i,o,s,a){let c=i._WINDOW_SIZE||1,u=o.get(i);return u||(u=this.precomputeWindow(i,c),c!==1&&o.set(i,a(u))),this.wNAF(c,u,s)}}}function Ci(t){return Oi(t.Fp),ie(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Zr(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}var at=BigInt(0),nt=BigInt(1),er=BigInt(2),Aa=BigInt(8),Ta={zip215:!0};function va(t){let e=Ci(t);return ie(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function rr(t){let e=va(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:c}=e,u=er<<BigInt(a*8)-nt,l=r.create,f=e.uvRatio||((m,p)=>{try{return{isValid:!0,value:r.sqrt(m*r.inv(p))}}catch{return{isValid:!1,value:at}}}),h=e.adjustScalarBytes||(m=>m),y=e.domain||((m,p,_)=>{if(p.length||_)throw new Error("Contexts/pre-hash are not supported");return m}),g=m=>typeof m=="bigint"&&at<m,w=(m,p)=>g(m)&&g(p)&&m<p,T=m=>m===at||w(m,u);function v(m,p){if(w(m,p))return m;throw new Error(`Expected valid scalar < ${p}, got ${typeof m} ${m}`)}function O(m){return m===at?m:v(m,n)}let A=new Map;function C(m){if(!(m instanceof x))throw new Error("ExtendedPoint expected")}class x{constructor(p,_,b,S){if(this.ex=p,this.ey=_,this.ez=b,this.et=S,!T(p))throw new Error("x required");if(!T(_))throw new Error("y required");if(!T(b))throw new Error("z required");if(!T(S))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof x)throw new Error("extended point not allowed");let{x:_,y:b}=p||{};if(!T(_)||!T(b))throw new Error("invalid affine point");return new x(_,b,nt,l(_*b))}static normalizeZ(p){let _=r.invertBatch(p.map(b=>b.ez));return p.map((b,S)=>b.toAffine(_[S])).map(x.fromAffine)}_setWindowSize(p){this._WINDOW_SIZE=p,A.delete(this)}assertValidity(){let{a:p,d:_}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:b,ey:S,ez:R,et:N}=this,F=l(b*b),P=l(S*S),U=l(R*R),Y=l(U*U),L=l(F*p),ft=l(U*l(L+P)),tt=l(Y+l(_*l(F*P)));if(ft!==tt)throw new Error("bad point: equation left != right (1)");let Pt=l(b*S),At=l(R*N);if(Pt!==At)throw new Error("bad point: equation left != right (2)")}equals(p){C(p);let{ex:_,ey:b,ez:S}=this,{ex:R,ey:N,ez:F}=p,P=l(_*F),U=l(R*S),Y=l(b*F),L=l(N*S);return P===U&&Y===L}is0(){return this.equals(x.ZERO)}negate(){return new x(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){let{a:p}=e,{ex:_,ey:b,ez:S}=this,R=l(_*_),N=l(b*b),F=l(er*l(S*S)),P=l(p*R),U=_+b,Y=l(l(U*U)-R-N),L=P+N,ft=L-F,tt=P-N,Pt=l(Y*ft),At=l(L*tt),Ke=l(Y*tt),Ve=l(ft*L);return new x(Pt,At,Ve,Ke)}add(p){C(p);let{a:_,d:b}=e,{ex:S,ey:R,ez:N,et:F}=this,{ex:P,ey:U,ez:Y,et:L}=p;if(_===BigInt(-1)){let Bn=l((R-S)*(U+P)),Sn=l((R+S)*(U-P)),Ar=l(Sn-Bn);if(Ar===at)return this.double();let On=l(N*er*L),Rn=l(F*er*Y),Nn=Rn+On,Pn=Sn+Bn,Cn=Rn-On,Zo=l(Nn*Ar),Jo=l(Pn*Cn),Xo=l(Nn*Cn),Qo=l(Ar*Pn);return new x(Zo,Jo,Qo,Xo)}let ft=l(S*P),tt=l(R*U),Pt=l(F*b*L),At=l(N*Y),Ke=l((S+R)*(P+U)-ft-tt),Ve=At-Pt,Tn=At+Pt,vn=l(tt-_*ft),Wo=l(Ke*Ve),Go=l(Tn*vn),Yo=l(Ke*vn),zo=l(Ve*Tn);return new x(Wo,Go,zo,Yo)}subtract(p){return this.add(p.negate())}wNAF(p){return W.wNAFCached(this,A,p,x.normalizeZ)}multiply(p){let{p:_,f:b}=this.wNAF(v(p,n));return x.normalizeZ([_,b])[0]}multiplyUnsafe(p){let _=O(p);return _===at?ut:this.equals(ut)||_===nt?this:this.equals(J)?this.wNAF(_).p:W.unsafeLadder(this,_)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return W.unsafeLadder(this,n).is0()}toAffine(p){let{ex:_,ey:b,ez:S}=this,R=this.is0();p==null&&(p=R?Aa:r.inv(S));let N=l(_*p),F=l(b*p),P=l(S*p);if(R)return{x:at,y:nt};if(P!==nt)throw new Error("invZ was invalid");return{x:N,y:F}}clearCofactor(){let{h:p}=e;return p===nt?this:this.multiplyUnsafe(p)}static fromHex(p,_=!1){let{d:b,a:S}=e,R=r.BYTES;p=mt("pointHex",p,R);let N=p.slice(),F=p[R-1];N[R-1]=F&-129;let P=ne(N);P===at||(_?v(P,u):v(P,r.ORDER));let U=l(P*P),Y=l(U-nt),L=l(b*U-S),{isValid:ft,value:tt}=f(Y,L);if(!ft)throw new Error("Point.fromHex: invalid y coordinate");let Pt=(tt&nt)===nt,At=(F&128)!==0;if(!_&&tt===at&&At)throw new Error("Point.fromHex: x=0 and x_0=1");return At!==Pt&&(tt=l(-tt)),x.fromAffine({x:tt,y:P})}static fromPrivateKey(p){return dt(p).point}toRawBytes(){let{x:p,y:_}=this.toAffine(),b=be(_,r.BYTES);return b[b.length-1]|=p&nt?128:0,b}toHex(){return tr(this.toRawBytes())}}x.BASE=new x(e.Gx,e.Gy,nt,l(e.Gx*e.Gy)),x.ZERO=new x(at,nt,nt,at);let{BASE:J,ZERO:ut}=x,W=Pi(x,a*8);function D(m){return q(m,n)}function xt(m){return D(ne(m))}function dt(m){let p=a;m=mt("private key",m,p);let _=mt("hashed private key",o(m),2*p),b=h(_.slice(0,p)),S=_.slice(p,2*p),R=xt(b),N=J.multiply(R),F=N.toRawBytes();return{head:b,prefix:S,scalar:R,point:N,pointBytes:F}}function bt(m){return dt(m).pointBytes}function Et(m=new Uint8Array,...p){let _=Yr(...p);return xt(o(y(_,mt("context",m),!!i)))}function he(m,p,_={}){m=mt("message",m),i&&(m=i(m));let{prefix:b,scalar:S,pointBytes:R}=dt(p),N=Et(_.context,b,m),F=J.multiply(N).toRawBytes(),P=Et(_.context,F,R,m),U=D(N+P*S);O(U);let Y=Yr(F,be(U,r.BYTES));return mt("result",Y,a*2)}let Jt=Ta;function Xt(m,p,_,b=Jt){let{context:S,zip215:R}=b,N=r.BYTES;m=mt("signature",m,2*N),p=mt("message",p),i&&(p=i(p));let F=ne(m.slice(N,2*N)),P,U,Y;try{P=x.fromHex(_,R),U=x.fromHex(m.slice(0,N),R),Y=J.multiplyUnsafe(F)}catch{return!1}if(!R&&P.isSmallOrder())return!1;let L=Et(S,U.toRawBytes(),P.toRawBytes(),p);return U.add(P.multiplyUnsafe(L)).subtract(Y).clearCofactor().equals(x.ZERO)}return J._setWindowSize(8),{CURVE:e,getPublicKey:bt,sign:he,verify:Xt,ExtendedPoint:x,utils:{getExtendedPublicKey:dt,randomPrivateKey:()=>s(r.BYTES),precompute(m=8,p=x.BASE){return p._setWindowSize(m),p.multiply(BigInt(3)),p}}}}var Qr=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ui=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Sl=BigInt(0),Ba=BigInt(1),Xr=BigInt(2),Sa=BigInt(5),Fi=BigInt(10),Oa=BigInt(20),Ra=BigInt(40),ki=BigInt(80);function Na(t){let e=Qr,n=t*t%e*t%e,i=st(n,Xr,e)*n%e,o=st(i,Ba,e)*t%e,s=st(o,Sa,e)*o%e,a=st(s,Fi,e)*s%e,c=st(a,Oa,e)*a%e,u=st(c,Ra,e)*c%e,l=st(u,ki,e)*u%e,f=st(l,ki,e)*u%e,h=st(f,Fi,e)*s%e;return{pow_p_5_8:st(h,Xr,e)*t%e,b2:n}}function Pa(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Ca(t,e){let r=Qr,n=q(e*e*e,r),i=q(n*n*e,r),o=Na(t*i).pow_p_5_8,s=q(t*n*o,r),a=q(e*s*s,r),c=s,u=q(s*Ui,r),l=a===t,f=a===q(-t,r),h=a===q(-t*Ui,r);return l&&(s=c),(f||h)&&(s=u),Si(s,r)&&(s=q(-s,r)),{isValid:l||f,value:s}}var Nt=Ri(Qr,void 0,!0),Ir={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Nt,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Wr,randomBytes:Kn,adjustScalarBytes:Pa,uvRatio:Ca},qt=rr(Ir);function qi(t,e,r){if(e.length>255)throw new Error("Context is too big");return kn(Fn("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var Ol=rr({...Ir,domain:qi}),Rl=rr({...Ir,domain:qi,prehash:Wr});var Ua=(Nt.ORDER+BigInt(3))/BigInt(8),Nl=Nt.pow(Xr,Ua),Pl=Nt.sqrt(Nt.neg(Nt.ONE)),Cl=(Nt.ORDER-BigInt(5))/BigInt(8),Ul=BigInt(486662);var Fl=Ni(Nt,Nt.neg(BigInt(486664)));var kl=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),ql=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Kl=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Vl=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var Ml=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Ki=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},X=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Z,Ee,Vi,Mi,nr=class{constructor(e={}){Z.set(this,void 0),Ee.set(this,void 0),this[Vi]=this.entries.bind(this),this[Mi]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();Ki(this,Z,new Map([...r].map(([o,s])=>[o,{value:s,timestamp:i}])),"f"),Ki(this,Ee,n,"f")}prune(){let e=Date.now();for(let[r,n]of X(this,Z,"f").entries())e-n.timestamp>X(this,Ee,"f")&&X(this,Z,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return X(this,Z,"f").set(e,n),this}get(e){let r=X(this,Z,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>X(this,Ee,"f")){X(this,Z,"f").delete(e);return}return r.value}}clear(){X(this,Z,"f").clear()}entries(){let e=X(this,Z,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=X(this,Z,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return X(this,Z,"f").keys()}forEach(e,r){for(let[n,i]of X(this,Z,"f").entries())e.call(r,i.value,n,this)}has(e){return X(this,Z,"f").has(e)}delete(e){return X(this,Z,"f").delete(e)}get size(){return X(this,Z,"f").size}};Z=new WeakMap,Ee=new WeakMap,Vi=Symbol.iterator,Mi=Symbol.toStringTag;var ji=t=>{if(t<=127)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},Hi=(t,e,r)=>{if(r<=127)return t[e]=r,1;if(r<=255)return t[e]=129,t[e+1]=r,2;if(r<=65535)return t[e]=130,t[e+1]=r>>8,t[e+2]=r,3;if(r<=16777215)return t[e]=131,t[e+1]=r>>16,t[e+2]=r>>8,t[e+3]=r,4;throw new Error("Length too long (> 4 bytes)")},Dr=(t,e)=>{if(t[e]<128)return 1;if(t[e]===128)throw new Error("Invalid length 0");if(t[e]===129)return 2;if(t[e]===130)return 3;if(t[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")},Fa=(t,e)=>{let r=Dr(t,e);if(r===1)return t[e];if(r===2)return t[e+1];if(r===3)return(t[e+1]<<8)+t[e+2];if(r===4)return(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];throw new Error("Length too long (> 4 bytes)")},$i=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),Wt=Uint8Array.from([48,5,6,3,43,101,112]),Wl=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function oe(t,e){let r=2+ji(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,o=new Uint8Array(1+ji(n)+n);return o[i++]=48,i+=Hi(o,i,n),o.set(e,i),i+=e.byteLength,o[i++]=3,i+=Hi(o,i,t.byteLength+1),o[i++]=0,o.set(new Uint8Array(t),i),o}var Ae=(t,e)=>{let r=0,n=(a,c)=>{if(i[r++]!==a)throw new Error("Expected: "+c)},i=new Uint8Array(t);if(n(48,"sequence"),r+=Dr(i,r),!He(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let o=Fa(i,r)-1;r+=Dr(i,r),n(0,"0 padding");let s=i.slice(r);if(o!==s.length)throw new Error(`DER payload mismatch: Expected length ${o} actual length ${s.length}`);return s};var Wi=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Gi=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ir,or,Te=class t{constructor(e){if(ir.set(this,void 0),or.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Wi(this,ir,e,"f"),Wi(this,or,t.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){return oe(e,Wt).buffer}static derDecode(e){let r=Ae(e,Wt);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Gi(this,ir,"f")}get derKey(){return Gi(this,or,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};ir=new WeakMap,or=new WeakMap;Te.RAW_KEY_LENGTH=32;var Yi=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Lr,zi,tn,Zi,en=class extends Function{constructor(){return super(),Lr.add(this),this.observers=[],new Proxy(this,{apply:(e,r,n)=>Yi(e,Lr,"m",zi).call(e,n[0])})}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e){this.observers.forEach(r=>r(e))}};Lr=new WeakSet,zi=function(e){this.notify(e)};var sr=class extends en{constructor(){return super(),tn.add(this),new Proxy(this,{apply:(e,r,n)=>Yi(e,tn,"m",Zi).call(e,n[0])})}log(e){this.notify({message:e,level:"info"})}warn(e){this.notify({message:e,level:"warn"})}error(e,r){this.notify({message:e,level:"error",error:r})}};tn=new WeakSet,Zi=function(e){this.log(e)};var qa=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},$=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},se,ae,Gt,ce,cr,wt;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(wt||(wt={}));var ar=5*60*1e3,Ka="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae",Va="ic0.app",Ma=".ic0.app",ja="icp0.io",Ha=".icp0.io",$a="icp-api.io",Wa=".icp-api.io",ve=class extends Tt{constructor(e){super(e),this.message=e}},le=class extends Tt{constructor(e){super(e),this.message=e}};function Ga(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new ve("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof globalThis<"u")if(globalThis.fetch)t=globalThis.fetch.bind(globalThis);else throw new ve("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(t=self.fetch.bind(self));if(t)return t;throw new ve("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var Be=class t{constructor(e={}){if(this.rootKey=pt(Ka),this._timeDiffMsecs=0,this._rootKeyFetched=!1,this._isAgent=!0,this.log=new sr,se.set(this,[]),ae.set(this,[]),Gt.set(this,new nr({expirationTime:5*60*1e3})),ce.set(this,!0),cr.set(this,(r,n)=>{if($(this,ce,"f")===!1)return r;if(!n)throw new we("Invalid signature from replica signed query: no matching node key found.");let{status:i,signatures:o=[],requestId:s}=r,a=new TextEncoder().encode("\vic-response");for(let c of o){let{timestamp:u,identity:l}=c,f=B.fromUint8Array(l).toText(),h;if(i==="replied"){let{reply:v}=r;h=Tr({status:i,reply:v,timestamp:BigInt(u),request_id:s})}else if(i==="rejected"){let{reject_code:v,reject_message:O,error_code:A}=r;h=Tr({status:i,reject_code:v,reject_message:O,error_code:A,timestamp:BigInt(u),request_id:s})}else throw new Error(`Unknown status: ${i}`);let y=je(a,new Uint8Array(h)),g=n?.nodeKeys.get(f);if(!g)throw new we("Invalid signature from replica signed query: no matching node key found.");let w=Te.fromDer(g).rawKey;if(qt.verify(c.signature,new Uint8Array(y),new Uint8Array(w)))return r;throw new we(`Invalid signature from replica ${f} signed query.`)}return r}),e.source){if(!(e.source instanceof t))throw new Error("An Agent's source can only be another HttpAgent");this._identity=e.source._identity,this._fetch=e.source._fetch,this._host=e.source._host,this._credentials=e.source._credentials}else this._fetch=e.fetch||Ga()||fetch.bind(globalThis),this._fetchOptions=e.fetchOptions,this._callOptions=e.callOptions;if(e.host!==void 0)!e.host.match(/^[a-z]+:/)&&typeof window<"u"?this._host=new URL(window.location.protocol+"//"+e.host):this._host=new URL(e.host);else if(e.source!==void 0)this._host=e.source._host;else{let r=typeof window<"u"?window.location:void 0;r||(this._host=new URL("https://icp-api.io"),this.log.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."));let n=["ic0.app","icp0.io","127.0.0.1","localhost"],i=[".github.dev",".gitpod.io"],o=r?.hostname,s;o&&typeof o=="string"&&(i.some(a=>o.endsWith(a))?s=o:s=n.find(a=>o.endsWith(a))),r&&s?this._host=new URL(`${r.protocol}//${s}${r.port?":"+r.port:""}`):(this._host=new URL("https://icp-api.io"),console.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."))}if(e.verifyQuerySignatures!==void 0&&qa(this,ce,e.verifyQuerySignatures,"f"),this._retryTimes=e.retryTimes!==void 0&&e.retryTimes>=0?e.retryTimes:3,this._host.hostname.endsWith(Ma)?this._host.hostname=Va:this._host.hostname.endsWith(Ha)?this._host.hostname=ja:this._host.hostname.endsWith(Wa)&&(this._host.hostname=$a),e.credentials){let{name:r,password:n}=e.credentials;this._credentials=`${r}${n?":"+n:""}`}this._identity=Promise.resolve(e.identity||new Ot),this.addTransform("update",jr(re)),e.useQueryNonces&&this.addTransform("query",jr(re)),e.logToConsole&&this.log.subscribe(r=>{r.level==="error"?console.error(r.message):r.level==="warn"?console.warn(r.message):console.log(r.message)})}isLocal(){let e=this._host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,r,n=r.priority||0){if(e==="update"){let i=$(this,ae,"f").findIndex(o=>(o.priority||0)<n);$(this,ae,"f").splice(i>=0?i:$(this,ae,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=$(this,se,"f").findIndex(o=>(o.priority||0)<n);$(this,se,"f").splice(i>=0?i:$(this,se,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!this._identity)throw new le("This identity has expired due this application's security policy. Please refresh your authentication.");return(await this._identity).getPrincipal()}async call(e,r,n){let i=await(n!==void 0?await n:await this._identity);if(!i)throw new le("This identity has expired due this application's security policy. Please refresh your authentication.");let o=B.from(e),s=r.effectiveCanisterId?B.from(r.effectiveCanisterId):o,a=i.getPrincipal()||B.anonymous(),c=new Ht(ar);Math.abs(this._timeDiffMsecs)>1e3*30&&(c=new Ht(ar+this._timeDiffMsecs));let u={request_type:Qe.Call,canister_id:o,method_name:r.methodName,arg:r.arg,sender:a,ingress_expiry:c},l=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"call",body:u});l=await i.transformRequest(l);let f=$e(l.body),h=this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${s.toText()}/call`,this._host),Object.assign(Object.assign(Object.assign({},this._callOptions),l.request),{body:f}))),[y,g]=await Promise.all([h,Ct(u)]),w=await y.arrayBuffer(),T=y.status===200&&w.byteLength>0?me(w):null;return{requestId:g,response:{ok:y.ok,status:y.status,statusText:y.statusText,body:T,headers:Ie(y.headers)}}}async _requestAndRetry(e,r=0){let n;try{n=await e()}catch(s){if(this._retryTimes>r)return console.warn(`Caught exception while attempting to make request:
1
+ import{A as Yn,C as vr,a as kn,b as ts,c as Me,d as qn,e as Kn,f as Vn,g as Mn,h as jn,i as B,j as es,k as Tt,l as Hn,m as ye,n as rs,o as je,p as M,q as ft,r as He,s as $n,t as Wn,u as Ct,v as Tr,w as Gn,x as $e,y as me,z as we}from"./chunk-572NAHJJ.js";var ri=kn(ze=>{"use strict";ze.byteLength=as;ze.toByteArray=ls;ze.fromByteArray=fs;var ht=[],nt=[],ss=typeof Uint8Array<"u"?Uint8Array:Array,Pr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Mt=0,ti=Pr.length;Mt<ti;++Mt)ht[Mt]=Pr[Mt],nt[Pr.charCodeAt(Mt)]=Mt;var Mt,ti;nt[45]=62;nt[95]=63;function ei(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function as(t){var e=ei(t),r=e[0],n=e[1];return(r+n)*3/4-n}function cs(t,e,r){return(e+r)*3/4-r}function ls(t){var e,r=ei(t),n=r[0],i=r[1],o=new ss(cs(t,n,i)),s=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=nt[t.charCodeAt(c)]<<18|nt[t.charCodeAt(c+1)]<<12|nt[t.charCodeAt(c+2)]<<6|nt[t.charCodeAt(c+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=nt[t.charCodeAt(c)]<<2|nt[t.charCodeAt(c+1)]>>4,o[s++]=e&255),i===1&&(e=nt[t.charCodeAt(c)]<<10|nt[t.charCodeAt(c+1)]<<4|nt[t.charCodeAt(c+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function us(t){return ht[t>>18&63]+ht[t>>12&63]+ht[t>>6&63]+ht[t&63]}function ds(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),i.push(us(n));return i.join("")}function fs(t){for(var e,r=t.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(ds(t,s,s+o>a?a:s+o));return n===1?(e=t[r-1],i.push(ht[e>>2]+ht[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(ht[e>>10]+ht[e>>4&63]+ht[e<<2&63]+"=")),i.join("")}});var _i=kn(ee=>{"use strict";var Cr=ri(),Lt=es(),ni=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ee.Buffer=d;ee.SlowBuffer=gs;ee.INSPECT_MAX_BYTES=50;var Ze=2147483647;ee.kMaxLength=Ze;d.TYPED_ARRAY_SUPPORT=ps();!d.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 ps(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}});Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function Bt(t){if(t>Ze)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,d.prototype),e}function d(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return qr(t)}return ai(t,e,r)}d.poolSize=8192;function ai(t,e,r){if(typeof t=="string")return ys(t,e);if(ArrayBuffer.isView(t))return ms(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(yt(t,ArrayBuffer)||t&&yt(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(yt(t,SharedArrayBuffer)||t&&yt(t.buffer,SharedArrayBuffer)))return Fr(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return d.from(n,e,r);let i=ws(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return d.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}d.from=function(t,e,r){return ai(t,e,r)};Object.setPrototypeOf(d.prototype,Uint8Array.prototype);Object.setPrototypeOf(d,Uint8Array);function ci(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function hs(t,e,r){return ci(t),t<=0?Bt(t):e!==void 0?typeof r=="string"?Bt(t).fill(e,r):Bt(t).fill(e):Bt(t)}d.alloc=function(t,e,r){return hs(t,e,r)};function qr(t){return ci(t),Bt(t<0?0:Kr(t)|0)}d.allocUnsafe=function(t){return qr(t)};d.allocUnsafeSlow=function(t){return qr(t)};function ys(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!d.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=li(t,e)|0,n=Bt(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Ur(t){let e=t.length<0?0:Kr(t.length)|0,r=Bt(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function ms(t){if(yt(t,Uint8Array)){let e=new Uint8Array(t);return Fr(e.buffer,e.byteOffset,e.byteLength)}return Ur(t)}function Fr(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,d.prototype),n}function ws(t){if(d.isBuffer(t)){let e=Kr(t.length)|0,r=Bt(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Mr(t.length)?Bt(0):Ur(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Ur(t.data)}function Kr(t){if(t>=Ze)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ze.toString(16)+" bytes");return t|0}function gs(t){return+t!=t&&(t=0),d.alloc(+t)}d.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==d.prototype};d.compare=function(e,r){if(yt(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),yt(r,Uint8Array)&&(r=d.from(r,r.offset,r.byteLength)),!d.isBuffer(e)||!d.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(e[o]!==r[o]){n=e[o],i=r[o];break}return n<i?-1:i<n?1:0};d.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};d.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return d.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=d.allocUnsafe(r),o=0;for(n=0;n<e.length;++n){let s=e[n];if(yt(s,Uint8Array))o+s.length>i.length?(d.isBuffer(s)||(s=d.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(d.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function li(t,e){if(d.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||yt(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return kr(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return gi(t).length;default:if(i)return n?-1:kr(t).length;e=(""+e).toLowerCase(),i=!0}}d.byteLength=li;function _s(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Rs(this,e,r);case"utf8":case"utf-8":return di(this,e,r);case"ascii":return Ss(this,e,r);case"latin1":case"binary":return Os(this,e,r);case"base64":return vs(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ns(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}d.prototype._isBuffer=!0;function jt(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}d.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)jt(this,r,r+1);return this};d.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)jt(this,r,r+3),jt(this,r+1,r+2);return this};d.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)jt(this,r,r+7),jt(this,r+1,r+6),jt(this,r+2,r+5),jt(this,r+3,r+4);return this};d.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?di(this,0,e):_s.apply(this,arguments)};d.prototype.toLocaleString=d.prototype.toString;d.prototype.equals=function(e){if(!d.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:d.compare(this,e)===0};d.prototype.inspect=function(){let e="",r=ee.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};ni&&(d.prototype[ni]=d.prototype.inspect);d.prototype.compare=function(e,r,n,i,o){if(yt(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),!d.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let s=o-i,a=n-r,c=Math.min(s,a),u=this.slice(i,o),l=e.slice(r,n);for(let f=0;f<c;++f)if(u[f]!==l[f]){s=u[f],a=l[f];break}return s<a?-1:a<s?1:0};function ui(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Mr(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=d.from(e,n)),d.isBuffer(e))return e.length===0?-1:ii(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):ii(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ii(t,e,r,n,i){let o=1,s=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;o=2,s/=2,a/=2,r/=2}function c(l,f){return o===1?l[f]:l.readUInt16BE(f*o)}let u;if(i){let l=-1;for(u=r;u<s;u++)if(c(t,u)===c(e,l===-1?0:u-l)){if(l===-1&&(l=u),u-l+1===a)return l*o}else l!==-1&&(u-=u-l),l=-1}else for(r+a>s&&(r=s-a),u=r;u>=0;u--){let l=!0;for(let f=0;f<a;f++)if(c(t,u+f)!==c(e,f)){l=!1;break}if(l)return u}return-1}d.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};d.prototype.indexOf=function(e,r,n){return ui(this,e,r,n,!0)};d.prototype.lastIndexOf=function(e,r,n){return ui(this,e,r,n,!1)};function xs(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(e.substr(s*2,2),16);if(Mr(a))return s;t[r+s]=a}return s}function bs(t,e,r,n){return Je(kr(e,t.length-r),t,r,n)}function Es(t,e,r,n){return Je(Fs(e),t,r,n)}function As(t,e,r,n){return Je(gi(e),t,r,n)}function Ts(t,e,r,n){return Je(ks(e,t.length-r),t,r,n)}d.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>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 o=this.length-r;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return xs(this,e,r,n);case"utf8":case"utf-8":return bs(this,e,r,n);case"ascii":case"latin1":case"binary":return Es(this,e,r,n);case"base64":return As(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ts(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function vs(t,e,r){return e===0&&r===t.length?Cr.fromByteArray(t):Cr.fromByteArray(t.slice(e,r))}function di(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let o=t[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let c,u,l,f;switch(a){case 1:o<128&&(s=o);break;case 2:c=t[i+1],(c&192)===128&&(f=(o&31)<<6|c&63,f>127&&(s=f));break;case 3:c=t[i+1],u=t[i+2],(c&192)===128&&(u&192)===128&&(f=(o&15)<<12|(c&63)<<6|u&63,f>2047&&(f<55296||f>57343)&&(s=f));break;case 4:c=t[i+1],u=t[i+2],l=t[i+3],(c&192)===128&&(u&192)===128&&(l&192)===128&&(f=(o&15)<<18|(c&63)<<12|(u&63)<<6|l&63,f>65535&&f<1114112&&(s=f))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return Bs(n)}var oi=4096;function Bs(t){let e=t.length;if(e<=oi)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=oi));return r}function Ss(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Os(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Rs(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=e;o<r;++o)i+=qs[t[o]];return i}function Ns(t,e,r){let n=t.slice(e,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}d.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,d.prototype),i};function H(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return i};d.prototype.readUintBE=d.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=this[e+--r],o=1;for(;r>0&&(o*=256);)i+=this[e+--r]*o;return i};d.prototype.readUint8=d.prototype.readUInt8=function(e,r){return e=e>>>0,r||H(e,1,this.length),this[e]};d.prototype.readUint16LE=d.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||H(e,2,this.length),this[e]|this[e+1]<<8};d.prototype.readUint16BE=d.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||H(e,2,this.length),this[e]<<8|this[e+1]};d.prototype.readUint32LE=d.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||H(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};d.prototype.readUint32BE=d.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||H(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};d.prototype.readBigUInt64LE=Ut(function(e){e=e>>>0,te(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ge(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});d.prototype.readBigUInt64BE=Ut(function(e){e=e>>>0,te(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ge(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});d.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};d.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=r,o=1,s=this[e+--i];for(;i>0&&(o*=256);)s+=this[e+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};d.prototype.readInt8=function(e,r){return e=e>>>0,r||H(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};d.prototype.readInt16LE=function(e,r){e=e>>>0,r||H(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};d.prototype.readInt16BE=function(e,r){e=e>>>0,r||H(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};d.prototype.readInt32LE=function(e,r){return e=e>>>0,r||H(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};d.prototype.readInt32BE=function(e,r){return e=e>>>0,r||H(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};d.prototype.readBigInt64LE=Ut(function(e){e=e>>>0,te(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ge(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});d.prototype.readBigInt64BE=Ut(function(e){e=e>>>0,te(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ge(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});d.prototype.readFloatLE=function(e,r){return e=e>>>0,r||H(e,4,this.length),Lt.read(this,e,!0,23,4)};d.prototype.readFloatBE=function(e,r){return e=e>>>0,r||H(e,4,this.length),Lt.read(this,e,!1,23,4)};d.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||H(e,8,this.length),Lt.read(this,e,!0,52,8)};d.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||H(e,8,this.length),Lt.read(this,e,!1,52,8)};function et(t,e,r,n,i,o){if(!d.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;et(this,e,r,n,a,0)}let o=1,s=0;for(this[r]=e&255;++s<n&&(o*=256);)this[r+s]=e/o&255;return r+n};d.prototype.writeUintBE=d.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;et(this,e,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=e&255;--o>=0&&(s*=256);)this[r+o]=e/s&255;return r+n};d.prototype.writeUint8=d.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,1,255,0),this[r]=e&255,r+1};d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function fi(t,e,r,n,i){wi(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,r}function pi(t,e,r,n,i){wi(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o=o>>8,t[r+6]=o,o=o>>8,t[r+5]=o,o=o>>8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s=s>>8,t[r+2]=s,s=s>>8,t[r+1]=s,s=s>>8,t[r]=s,r+8}d.prototype.writeBigUInt64LE=Ut(function(e,r=0){return fi(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});d.prototype.writeBigUInt64BE=Ut(function(e,r=0){return pi(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});d.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);et(this,e,r,n,c-1,-c)}let o=0,s=1,a=0;for(this[r]=e&255;++o<n&&(s*=256);)e<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};d.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);et(this,e,r,n,c-1,-c)}let o=n-1,s=1,a=0;for(this[r+o]=e&255;--o>=0&&(s*=256);)e<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};d.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};d.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};d.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};d.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};d.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||et(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};d.prototype.writeBigInt64LE=Ut(function(e,r=0){return fi(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});d.prototype.writeBigInt64BE=Ut(function(e,r=0){return pi(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function hi(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function yi(t,e,r,n,i){return e=+e,r=r>>>0,i||hi(t,e,r,4,34028234663852886e22,-34028234663852886e22),Lt.write(t,e,r,n,23,4),r+4}d.prototype.writeFloatLE=function(e,r,n){return yi(this,e,r,!0,n)};d.prototype.writeFloatBE=function(e,r,n){return yi(this,e,r,!1,n)};function mi(t,e,r,n,i){return e=+e,r=r>>>0,i||hi(t,e,r,8,17976931348623157e292,-17976931348623157e292),Lt.write(t,e,r,n,52,8),r+8}d.prototype.writeDoubleLE=function(e,r,n){return mi(this,e,r,!0,n)};d.prototype.writeDoubleBE=function(e,r,n){return mi(this,e,r,!1,n)};d.prototype.copy=function(e,r,n,i){if(!d.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<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),e.length-r<i-n&&(i=e.length-r+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),o};d.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=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"&&!d.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let s=e.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=r;o<n;++o)this[o]=e;else{let s=d.isBuffer(e)?e:d.from(e,i),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var Dt={};function Vr(t,e,r){Dt[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Vr("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Vr("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Vr("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=si(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=si(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function si(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function Ps(t,e,r){te(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&ge(e,t.length-(r+1))}function wi(t,e,r,n,i,o){if(t>r||t<e){let s=typeof e=="bigint"?"n":"",a;throw o>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${r}${s}`,new Dt.ERR_OUT_OF_RANGE("value",a,t)}Ps(n,i,o)}function te(t,e){if(typeof t!="number")throw new Dt.ERR_INVALID_ARG_TYPE(e,"number",t)}function ge(t,e,r){throw Math.floor(t)!==t?(te(t,r),new Dt.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new Dt.ERR_BUFFER_OUT_OF_BOUNDS:new Dt.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Cs=/[^+/0-9A-Za-z-_]/g;function Us(t){if(t=t.split("=")[0],t=t.trim().replace(Cs,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function kr(t,e){e=e||1/0;let r,n=t.length,i=null,o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function Fs(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function ks(t,e){let r,n,i,o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function gi(t){return Cr.toByteArray(Us(t))}function Je(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function yt(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Mr(t){return t!==t}var qs=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Ut(t){return typeof BigInt>"u"?Ks:t}function Ks(){throw new Error("BigInt not supported")}});var K=t=>t==null,j=t=>!K(t),ns=class extends Error{},zn=(t,e)=>{if(K(t))throw new ns(e)},Br="__bigint__",Sr="__principal__",Or="__uint8array__",is=(t,e)=>typeof e=="bigint"?{[Br]:`${e}`}:j(e)&&e instanceof B?{[Sr]:e.toText()}:j(e)&&e instanceof Uint8Array?{[Or]:Array.from(e)}:e,os=(t,e)=>{let r=n=>e[n];return j(e)&&typeof e=="object"&&Br in e?BigInt(r(Br)):j(e)&&typeof e=="object"&&Sr in e?B.fromText(r(Sr)):j(e)&&typeof e=="object"&&Or in e?Uint8Array.from(r(Or)):e},G=t=>j(t)?[t]:[],z=t=>t?.[0],Zn=async t=>{let e=new Blob([JSON.stringify(t,is)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},We=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),os)},Ge=()=>typeof window<"u";var Qt=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:r})=>r(e))}subscribe(e){let r=Symbol();return this.callbacks.push({id:r,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var vt=class t extends Qt{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let r=super.subscribe(e);return e(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var Rr=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var Jn=BigInt(144e11),Xn={width:576,height:576},Qn={width:505,height:705},In="internetcomputer.org";var It="http://127.0.0.1:5987",Dn="rdmx6-jaaaa-aaaaa-aaadq-cai";var pt=class t extends Qt{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var Nr=({width:t,height:e})=>{if(!Ge()||K(window)||K(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-e/2,o=r/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${o}`};var Ye=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=pt.getInstance().get()?.container;if(K(n)||n===!1)return`https://identity.${this.#t??In}`;let i=pt.getInstance().get(),o=j(i)&&j(i?.internetIdentityId)?i.internetIdentityId:Dn,{host:s,protocol:a}=new URL(n===!0?It:n);return/apple/i.test(navigator?.vendor)?`${a}//${s}?canisterId=${o}`:`${a}//${o}.${s.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:Nr(Xn)},identityProvider:r()}}},Ln=class{#t;#e;constructor({appName:e,logoUrl:r}){this.#t=e,this.#e=r}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:Nr(Qn)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};var so=Me(_i());var Xe;(function(t){t[t.SysFatal=1]="SysFatal",t[t.SysTransient=2]="SysTransient",t[t.DestinationInvalid=3]="DestinationInvalid",t[t.CanisterReject=4]="CanisterReject",t[t.CanisterError=5]="CanisterError"})(Xe||(Xe={}));var Vs=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},Ms=new TextEncoder().encode(`
2
+ ic-request`),St=class{getPrincipal(){return this._principal||(this._principal=B.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=Vs(e,["body"]),i=await Ct(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(je(Ms,i))}})}},Ot=class{getPrincipal(){return B.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};var xi=Me(Gn());var _e=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let t=new Uint32Array(1);return window.crypto.getRandomValues(t),t[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let t=new Uint32Array(1);return crypto.getRandomValues(t),t[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};var Qe;(function(t){t.Call="call"})(Qe||(Qe={}));function re(){let t=new ArrayBuffer(16),e=new DataView(t),r=_e(),n=_e(),i=_e(),o=_e();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,o),t}var js=BigInt(1e6),Hs=60*1e3,Ht=class{constructor(e){let o=BigInt(Math.floor(Date.now()+e-Hs))*js/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=o}toCBOR(){return xi.value.u64(this._value.toString(16),16)}toHash(){return Hn(this._value)}};function jr(t=re){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}function Ie(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}var De=class extends Tt{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};var Le=BigInt(4294967295),Hr=BigInt(32);function bi(t,e=!1){return e?{h:Number(t&Le),l:Number(t>>Hr&Le)}:{h:Number(t>>Hr&Le)|0,l:Number(t&Le)|0}}function $s(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:o,l:s}=bi(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]}var Ws=(t,e)=>BigInt(t>>>0)<<Hr|BigInt(e>>>0),Gs=(t,e,r)=>t>>>r,Ys=(t,e,r)=>t<<32-r|e>>>r,zs=(t,e,r)=>t>>>r|e<<32-r,Zs=(t,e,r)=>t<<32-r|e>>>r,Js=(t,e,r)=>t<<64-r|e>>>r-32,Xs=(t,e,r)=>t>>>r-32|e<<64-r,Qs=(t,e)=>e,Is=(t,e)=>t,Ds=(t,e,r)=>t<<r|e>>>32-r,Ls=(t,e,r)=>e<<r|t>>>32-r,ta=(t,e,r)=>e<<r-32|t>>>64-r,ea=(t,e,r)=>t<<r-32|e>>>64-r;function ra(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var na=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),ia=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,oa=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),sa=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,aa=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),ca=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;var la={fromBig:bi,split:$s,toBig:Ws,shrSH:Gs,shrSL:Ys,rotrSH:zs,rotrSL:Zs,rotrBH:Js,rotrBL:Xs,rotr32H:Qs,rotr32L:Is,rotlSH:Ds,rotlSL:Ls,rotlBH:ta,rotlBL:ea,add:ra,add3L:na,add3H:ia,add4L:oa,add4H:sa,add5H:ca,add5L:aa},A=la;var[ua,da]=A.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(t=>BigInt(t))),Ft=new Uint32Array(80),kt=new Uint32Array(80),$r=class extends jn{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:e,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:c,Eh:u,El:l,Fh:f,Fl:p,Gh:y,Gl:g,Hh:w,Hl:E}=this;return[e,r,n,i,o,s,a,c,u,l,f,p,y,g,w,E]}set(e,r,n,i,o,s,a,c,u,l,f,p,y,g,w,E){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=l|0,this.Fh=f|0,this.Fl=p|0,this.Gh=y|0,this.Gl=g|0,this.Hh=w|0,this.Hl=E|0}process(e,r){for(let T=0;T<16;T++,r+=4)Ft[T]=e.getUint32(r),kt[T]=e.getUint32(r+=4);for(let T=16;T<80;T++){let C=Ft[T-15]|0,x=kt[T-15]|0,J=A.rotrSH(C,x,1)^A.rotrSH(C,x,8)^A.shrSH(C,x,7),lt=A.rotrSL(C,x,1)^A.rotrSL(C,x,8)^A.shrSL(C,x,7),W=Ft[T-2]|0,D=kt[T-2]|0,xt=A.rotrSH(W,D,19)^A.rotrBH(W,D,61)^A.shrSH(W,D,6),ut=A.rotrSL(W,D,19)^A.rotrBL(W,D,61)^A.shrSL(W,D,6),bt=A.add4L(lt,ut,kt[T-7],kt[T-16]),Et=A.add4H(bt,J,xt,Ft[T-7],Ft[T-16]);Ft[T]=Et|0,kt[T]=bt|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:c,Dh:u,Dl:l,Eh:f,El:p,Fh:y,Fl:g,Gh:w,Gl:E,Hh:v,Hl:O}=this;for(let T=0;T<80;T++){let C=A.rotrSH(f,p,14)^A.rotrSH(f,p,18)^A.rotrBH(f,p,41),x=A.rotrSL(f,p,14)^A.rotrSL(f,p,18)^A.rotrBL(f,p,41),J=f&y^~f&w,lt=p&g^~p&E,W=A.add5L(O,x,lt,da[T],kt[T]),D=A.add5H(W,v,C,J,ua[T],Ft[T]),xt=W|0,ut=A.rotrSH(n,i,28)^A.rotrBH(n,i,34)^A.rotrBH(n,i,39),bt=A.rotrSL(n,i,28)^A.rotrBL(n,i,34)^A.rotrBL(n,i,39),Et=n&o^n&a^o&a,he=i&s^i&c^s&c;v=w|0,O=E|0,w=y|0,E=g|0,y=f|0,g=p|0,{h:f,l:p}=A.add(u|0,l|0,D|0,xt|0),u=a|0,l=c|0,a=o|0,c=s|0,o=n|0,s=i|0;let Jt=A.add3L(xt,bt,he);n=A.add3H(Jt,D,ut,Et),i=Jt|0}({h:n,l:i}=A.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=A.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:c}=A.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l}=A.add(this.Dh|0,this.Dl|0,u|0,l|0),{h:f,l:p}=A.add(this.Eh|0,this.El|0,f|0,p|0),{h:y,l:g}=A.add(this.Fh|0,this.Fl|0,y|0,g|0),{h:w,l:E}=A.add(this.Gh|0,this.Gl|0,w|0,E|0),{h:v,l:O}=A.add(this.Hh|0,this.Hl|0,v|0,O|0),this.set(n,i,o,s,a,c,u,l,f,p,y,g,w,E,v,O)}roundClean(){Ft.fill(0),kt.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)}};var Wr=Vn(()=>new $r);var gl=BigInt(0),fa=BigInt(1),pa=BigInt(2);function xe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var ha=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function tr(t){if(!xe(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=ha[t[r]];return e}function Ai(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var Rt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Ei(t){if(t>=Rt._0&&t<=Rt._9)return t-Rt._0;if(t>=Rt._A&&t<=Rt._F)return t-(Rt._A-10);if(t>=Rt._a&&t<=Rt._f)return t-(Rt._a-10)}function Ti(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;i<r;i++,o+=2){let s=Ei(t.charCodeAt(o)),a=Ei(t.charCodeAt(o+1));if(s===void 0||a===void 0){let c=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+o)}n[i]=s*16+a}return n}function vi(t){return Ai(tr(t))}function ne(t){if(!xe(t))throw new Error("Uint8Array expected");return Ai(tr(Uint8Array.from(t).reverse()))}function Gr(t,e){return Ti(t.toString(16).padStart(e*2,"0"))}function be(t,e){return Gr(t,e).reverse()}function mt(t,e,r){let n;if(typeof e=="string")try{n=Ti(e)}catch(o){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${o}`)}else if(xe(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function Yr(...t){let e=0;for(let i=0;i<t.length;i++){let o=t[i];if(!xe(o))throw new Error("Uint8Array expected");e+=o.length}let r=new Uint8Array(e),n=0;for(let i=0;i<t.length;i++){let o=t[i];r.set(o,n),n+=o.length}return r}var Bi=t=>(pa<<BigInt(t-1))-fa;var ya={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||xe(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function ie(t,e,r={}){let n=(i,o,s)=>{let a=ya[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let c=t[i];if(!(s&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${o}`)};for(let[i,o]of Object.entries(e))n(i,o,!1);for(let[i,o]of Object.entries(r))n(i,o,!0);return t}var V=BigInt(0),k=BigInt(1),$t=BigInt(2),wa=BigInt(3),zr=BigInt(4),Si=BigInt(5),Oi=BigInt(8),ga=BigInt(9),_a=BigInt(16);function q(t,e){let r=t%e;return r>=V?r:e+r}function xa(t,e,r){if(r<=V||e<V)throw new Error("Expected power/modulo > 0");if(r===k)return V;let n=k;for(;e>V;)e&k&&(n=n*t%r),t=t*t%r,e>>=k;return n}function ot(t,e,r){let n=t;for(;e-- >V;)n*=n,n%=r;return n}function Ri(t,e){if(t===V||e<=V)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=q(t,e),n=e,i=V,o=k,s=k,a=V;for(;r!==V;){let u=n/r,l=n%r,f=i-s*u,p=o-a*u;n=r,r=l,i=s,o=a,s=f,a=p}if(n!==k)throw new Error("invert: does not exist");return q(i,e)}function ba(t){let e=(t-k)/$t,r,n,i;for(r=t-k,n=0;r%$t===V;r/=$t,n++);for(i=$t;i<t&&xa(i,e,t)!==t-k;i++);if(n===1){let s=(t+k)/zr;return function(c,u){let l=c.pow(u,s);if(!c.eql(c.sqr(l),u))throw new Error("Cannot find square root");return l}}let o=(r+k)/$t;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let u=n,l=a.pow(a.mul(a.ONE,i),r),f=a.pow(c,o),p=a.pow(c,r);for(;!a.eql(p,a.ONE);){if(a.eql(p,a.ZERO))return a.ZERO;let y=1;for(let w=a.sqr(p);y<u&&!a.eql(w,a.ONE);y++)w=a.sqr(w);let g=a.pow(l,k<<BigInt(u-y-1));l=a.sqr(g),f=a.mul(f,g),p=a.mul(p,l),u=y}return f}}function Ea(t){if(t%zr===wa){let e=(t+k)/zr;return function(n,i){let o=n.pow(i,e);if(!n.eql(n.sqr(o),i))throw new Error("Cannot find square root");return o}}if(t%Oi===Si){let e=(t-Si)/Oi;return function(n,i){let o=n.mul(i,$t),s=n.pow(o,e),a=n.mul(i,s),c=n.mul(n.mul(a,$t),s),u=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(u),i))throw new Error("Cannot find square root");return u}}return t%_a,ba(t)}var Ni=(t,e)=>(q(t,e)&k)===k,Aa=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Pi(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Aa.reduce((n,i)=>(n[i]="function",n),e);return ie(t,r)}function Ta(t,e,r){if(r<V)throw new Error("Expected power > 0");if(r===V)return t.ONE;if(r===k)return e;let n=t.ONE,i=e;for(;r>V;)r&k&&(n=t.mul(n,i)),i=t.sqr(i),r>>=k;return n}function va(t,e){let r=new Array(e.length),n=e.reduce((o,s,a)=>t.is0(s)?o:(r[a]=o,t.mul(o,s)),t.ONE),i=t.inv(n);return e.reduceRight((o,s,a)=>t.is0(s)?o:(r[a]=t.mul(o,r[a]),t.mul(o,s)),i),r}function Zr(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Ci(t,e,r=!1,n={}){if(t<=V)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:o}=Zr(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=Ea(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:Bi(i),ZERO:V,ONE:k,create:c=>q(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return V<=c&&c<t},is0:c=>c===V,isOdd:c=>(c&k)===k,neg:c=>q(-c,t),eql:(c,u)=>c===u,sqr:c=>q(c*c,t),add:(c,u)=>q(c+u,t),sub:(c,u)=>q(c-u,t),mul:(c,u)=>q(c*u,t),pow:(c,u)=>Ta(a,c,u),div:(c,u)=>q(c*Ri(u,t),t),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>Ri(c,t),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>va(a,c),cmov:(c,u,l)=>l?u:c,toBytes:c=>r?be(c,o):Gr(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return r?ne(c):vi(c)}});return Object.freeze(a)}function Ui(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}var Ba=BigInt(0),Jr=BigInt(1);function Fi(t,e){let r=(i,o)=>{let s=o.negate();return i?s:o},n=i=>{let o=Math.ceil(e/i)+1,s=2**(i-1);return{windows:o,windowSize:s}};return{constTimeNegate:r,unsafeLadder(i,o){let s=t.ZERO,a=i;for(;o>Ba;)o&Jr&&(s=s.add(a)),a=a.double(),o>>=Jr;return s},precomputeWindow(i,o){let{windows:s,windowSize:a}=n(o),c=[],u=i,l=u;for(let f=0;f<s;f++){l=u,c.push(l);for(let p=1;p<a;p++)l=l.add(u),c.push(l);u=l.double()}return c},wNAF(i,o,s){let{windows:a,windowSize:c}=n(i),u=t.ZERO,l=t.BASE,f=BigInt(2**i-1),p=2**i,y=BigInt(i);for(let g=0;g<a;g++){let w=g*c,E=Number(s&f);s>>=y,E>c&&(E-=p,s+=Jr);let v=w,O=w+Math.abs(E)-1,T=g%2!==0,C=E<0;E===0?l=l.add(r(T,o[v])):u=u.add(r(C,o[O]))}return{p:u,f:l}},wNAFCached(i,o,s,a){let c=i._WINDOW_SIZE||1,u=o.get(i);return u||(u=this.precomputeWindow(i,c),c!==1&&o.set(i,a(u))),this.wNAF(c,u,s)}}}function ki(t){return Pi(t.Fp),ie(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Zr(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}var st=BigInt(0),rt=BigInt(1),er=BigInt(2),Sa=BigInt(8),Oa={zip215:!0};function Ra(t){let e=ki(t);return ie(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function rr(t){let e=Ra(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:c}=e,u=er<<BigInt(a*8)-rt,l=r.create,f=e.uvRatio||((m,h)=>{try{return{isValid:!0,value:r.sqrt(m*r.inv(h))}}catch{return{isValid:!1,value:st}}}),p=e.adjustScalarBytes||(m=>m),y=e.domain||((m,h,_)=>{if(h.length||_)throw new Error("Contexts/pre-hash are not supported");return m}),g=m=>typeof m=="bigint"&&st<m,w=(m,h)=>g(m)&&g(h)&&m<h,E=m=>m===st||w(m,u);function v(m,h){if(w(m,h))return m;throw new Error(`Expected valid scalar < ${h}, got ${typeof m} ${m}`)}function O(m){return m===st?m:v(m,n)}let T=new Map;function C(m){if(!(m instanceof x))throw new Error("ExtendedPoint expected")}class x{constructor(h,_,b,S){if(this.ex=h,this.ey=_,this.ez=b,this.et=S,!E(h))throw new Error("x required");if(!E(_))throw new Error("y required");if(!E(b))throw new Error("z required");if(!E(S))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(h){if(h instanceof x)throw new Error("extended point not allowed");let{x:_,y:b}=h||{};if(!E(_)||!E(b))throw new Error("invalid affine point");return new x(_,b,rt,l(_*b))}static normalizeZ(h){let _=r.invertBatch(h.map(b=>b.ez));return h.map((b,S)=>b.toAffine(_[S])).map(x.fromAffine)}_setWindowSize(h){this._WINDOW_SIZE=h,T.delete(this)}assertValidity(){let{a:h,d:_}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:b,ey:S,ez:R,et:N}=this,F=l(b*b),P=l(S*S),U=l(R*R),Y=l(U*U),L=l(F*h),dt=l(U*l(L+P)),tt=l(Y+l(_*l(F*P)));if(dt!==tt)throw new Error("bad point: equation left != right (1)");let Pt=l(b*S),At=l(R*N);if(Pt!==At)throw new Error("bad point: equation left != right (2)")}equals(h){C(h);let{ex:_,ey:b,ez:S}=this,{ex:R,ey:N,ez:F}=h,P=l(_*F),U=l(R*S),Y=l(b*F),L=l(N*S);return P===U&&Y===L}is0(){return this.equals(x.ZERO)}negate(){return new x(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){let{a:h}=e,{ex:_,ey:b,ez:S}=this,R=l(_*_),N=l(b*b),F=l(er*l(S*S)),P=l(h*R),U=_+b,Y=l(l(U*U)-R-N),L=P+N,dt=L-F,tt=P-N,Pt=l(Y*dt),At=l(L*tt),Ke=l(Y*tt),Ve=l(dt*L);return new x(Pt,At,Ve,Ke)}add(h){C(h);let{a:_,d:b}=e,{ex:S,ey:R,ez:N,et:F}=this,{ex:P,ey:U,ez:Y,et:L}=h;if(_===BigInt(-1)){let On=l((R-S)*(U+P)),Rn=l((R+S)*(U-P)),Ar=l(Rn-On);if(Ar===st)return this.double();let Nn=l(N*er*L),Pn=l(F*er*Y),Cn=Pn+Nn,Un=Rn+On,Fn=Pn-Nn,Qo=l(Cn*Ar),Io=l(Un*Fn),Do=l(Cn*Fn),Lo=l(Ar*Un);return new x(Qo,Io,Lo,Do)}let dt=l(S*P),tt=l(R*U),Pt=l(F*b*L),At=l(N*Y),Ke=l((S+R)*(P+U)-dt-tt),Ve=At-Pt,Bn=At+Pt,Sn=l(tt-_*dt),zo=l(Ke*Ve),Zo=l(Bn*Sn),Jo=l(Ke*Sn),Xo=l(Ve*Bn);return new x(zo,Zo,Xo,Jo)}subtract(h){return this.add(h.negate())}wNAF(h){return W.wNAFCached(this,T,h,x.normalizeZ)}multiply(h){let{p:_,f:b}=this.wNAF(v(h,n));return x.normalizeZ([_,b])[0]}multiplyUnsafe(h){let _=O(h);return _===st?lt:this.equals(lt)||_===rt?this:this.equals(J)?this.wNAF(_).p:W.unsafeLadder(this,_)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return W.unsafeLadder(this,n).is0()}toAffine(h){let{ex:_,ey:b,ez:S}=this,R=this.is0();h==null&&(h=R?Sa:r.inv(S));let N=l(_*h),F=l(b*h),P=l(S*h);if(R)return{x:st,y:rt};if(P!==rt)throw new Error("invZ was invalid");return{x:N,y:F}}clearCofactor(){let{h}=e;return h===rt?this:this.multiplyUnsafe(h)}static fromHex(h,_=!1){let{d:b,a:S}=e,R=r.BYTES;h=mt("pointHex",h,R);let N=h.slice(),F=h[R-1];N[R-1]=F&-129;let P=ne(N);P===st||(_?v(P,u):v(P,r.ORDER));let U=l(P*P),Y=l(U-rt),L=l(b*U-S),{isValid:dt,value:tt}=f(Y,L);if(!dt)throw new Error("Point.fromHex: invalid y coordinate");let Pt=(tt&rt)===rt,At=(F&128)!==0;if(!_&&tt===st&&At)throw new Error("Point.fromHex: x=0 and x_0=1");return At!==Pt&&(tt=l(-tt)),x.fromAffine({x:tt,y:P})}static fromPrivateKey(h){return ut(h).point}toRawBytes(){let{x:h,y:_}=this.toAffine(),b=be(_,r.BYTES);return b[b.length-1]|=h&rt?128:0,b}toHex(){return tr(this.toRawBytes())}}x.BASE=new x(e.Gx,e.Gy,rt,l(e.Gx*e.Gy)),x.ZERO=new x(st,rt,rt,st);let{BASE:J,ZERO:lt}=x,W=Fi(x,a*8);function D(m){return q(m,n)}function xt(m){return D(ne(m))}function ut(m){let h=a;m=mt("private key",m,h);let _=mt("hashed private key",o(m),2*h),b=p(_.slice(0,h)),S=_.slice(h,2*h),R=xt(b),N=J.multiply(R),F=N.toRawBytes();return{head:b,prefix:S,scalar:R,point:N,pointBytes:F}}function bt(m){return ut(m).pointBytes}function Et(m=new Uint8Array,...h){let _=Yr(...h);return xt(o(y(_,mt("context",m),!!i)))}function he(m,h,_={}){m=mt("message",m),i&&(m=i(m));let{prefix:b,scalar:S,pointBytes:R}=ut(h),N=Et(_.context,b,m),F=J.multiply(N).toRawBytes(),P=Et(_.context,F,R,m),U=D(N+P*S);O(U);let Y=Yr(F,be(U,r.BYTES));return mt("result",Y,a*2)}let Jt=Oa;function Xt(m,h,_,b=Jt){let{context:S,zip215:R}=b,N=r.BYTES;m=mt("signature",m,2*N),h=mt("message",h),i&&(h=i(h));let F=ne(m.slice(N,2*N)),P,U,Y;try{P=x.fromHex(_,R),U=x.fromHex(m.slice(0,N),R),Y=J.multiplyUnsafe(F)}catch{return!1}if(!R&&P.isSmallOrder())return!1;let L=Et(S,U.toRawBytes(),P.toRawBytes(),h);return U.add(P.multiplyUnsafe(L)).subtract(Y).clearCofactor().equals(x.ZERO)}return J._setWindowSize(8),{CURVE:e,getPublicKey:bt,sign:he,verify:Xt,ExtendedPoint:x,utils:{getExtendedPublicKey:ut,randomPrivateKey:()=>s(r.BYTES),precompute(m=8,h=x.BASE){return h._setWindowSize(m),h.multiply(BigInt(3)),h}}}}var Qr=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),qi=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Cl=BigInt(0),Na=BigInt(1),Xr=BigInt(2),Pa=BigInt(5),Ki=BigInt(10),Ca=BigInt(20),Ua=BigInt(40),Vi=BigInt(80);function Fa(t){let e=Qr,n=t*t%e*t%e,i=ot(n,Xr,e)*n%e,o=ot(i,Na,e)*t%e,s=ot(o,Pa,e)*o%e,a=ot(s,Ki,e)*s%e,c=ot(a,Ca,e)*a%e,u=ot(c,Ua,e)*c%e,l=ot(u,Vi,e)*u%e,f=ot(l,Vi,e)*u%e,p=ot(f,Ki,e)*s%e;return{pow_p_5_8:ot(p,Xr,e)*t%e,b2:n}}function ka(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function qa(t,e){let r=Qr,n=q(e*e*e,r),i=q(n*n*e,r),o=Fa(t*i).pow_p_5_8,s=q(t*n*o,r),a=q(e*s*s,r),c=s,u=q(s*qi,r),l=a===t,f=a===q(-t,r),p=a===q(-t*qi,r);return l&&(s=c),(f||p)&&(s=u),Ni(s,r)&&(s=q(-s,r)),{isValid:l||f,value:s}}var Nt=Ci(Qr,void 0,!0),Ir={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Nt,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Wr,randomBytes:Mn,adjustScalarBytes:ka,uvRatio:qa},qt=rr(Ir);function Mi(t,e,r){if(e.length>255)throw new Error("Context is too big");return Kn(qn("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var Ul=rr({...Ir,domain:Mi}),Fl=rr({...Ir,domain:Mi,prehash:Wr});var Ka=(Nt.ORDER+BigInt(3))/BigInt(8),kl=Nt.pow(Xr,Ka),ql=Nt.sqrt(Nt.neg(Nt.ONE)),Kl=(Nt.ORDER-BigInt(5))/BigInt(8),Vl=BigInt(486662);var Ml=Ui(Nt,Nt.neg(BigInt(486664)));var jl=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Hl=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),$l=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Wl=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var Gl=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var ji=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},X=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Z,Ee,Hi,$i,nr=class{constructor(e={}){Z.set(this,void 0),Ee.set(this,void 0),this[Hi]=this.entries.bind(this),this[$i]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();ji(this,Z,new Map([...r].map(([o,s])=>[o,{value:s,timestamp:i}])),"f"),ji(this,Ee,n,"f")}prune(){let e=Date.now();for(let[r,n]of X(this,Z,"f").entries())e-n.timestamp>X(this,Ee,"f")&&X(this,Z,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return X(this,Z,"f").set(e,n),this}get(e){let r=X(this,Z,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>X(this,Ee,"f")){X(this,Z,"f").delete(e);return}return r.value}}clear(){X(this,Z,"f").clear()}entries(){let e=X(this,Z,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=X(this,Z,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return X(this,Z,"f").keys()}forEach(e,r){for(let[n,i]of X(this,Z,"f").entries())e.call(r,i.value,n,this)}has(e){return X(this,Z,"f").has(e)}delete(e){return X(this,Z,"f").delete(e)}get size(){return X(this,Z,"f").size}};Z=new WeakMap,Ee=new WeakMap,Hi=Symbol.iterator,$i=Symbol.toStringTag;var Wi=t=>{if(t<=127)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},Gi=(t,e,r)=>{if(r<=127)return t[e]=r,1;if(r<=255)return t[e]=129,t[e+1]=r,2;if(r<=65535)return t[e]=130,t[e+1]=r>>8,t[e+2]=r,3;if(r<=16777215)return t[e]=131,t[e+1]=r>>16,t[e+2]=r>>8,t[e+3]=r,4;throw new Error("Length too long (> 4 bytes)")},Dr=(t,e)=>{if(t[e]<128)return 1;if(t[e]===128)throw new Error("Invalid length 0");if(t[e]===129)return 2;if(t[e]===130)return 3;if(t[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")},Va=(t,e)=>{let r=Dr(t,e);if(r===1)return t[e];if(r===2)return t[e+1];if(r===3)return(t[e+1]<<8)+t[e+2];if(r===4)return(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];throw new Error("Length too long (> 4 bytes)")},Yi=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),Wt=Uint8Array.from([48,5,6,3,43,101,112]),Jl=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function oe(t,e){let r=2+Wi(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,o=new Uint8Array(1+Wi(n)+n);return o[i++]=48,i+=Gi(o,i,n),o.set(e,i),i+=e.byteLength,o[i++]=3,i+=Gi(o,i,t.byteLength+1),o[i++]=0,o.set(new Uint8Array(t),i),o}var Ae=(t,e)=>{let r=0,n=(a,c)=>{if(i[r++]!==a)throw new Error("Expected: "+c)},i=new Uint8Array(t);if(n(48,"sequence"),r+=Dr(i,r),!He(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let o=Va(i,r)-1;r+=Dr(i,r),n(0,"0 padding");let s=i.slice(r);if(o!==s.length)throw new Error(`DER payload mismatch: Expected length ${o} actual length ${s.length}`);return s};var zi=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Zi=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ir,or,Te=class t{constructor(e){if(ir.set(this,void 0),or.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");zi(this,ir,e,"f"),zi(this,or,t.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){return oe(e,Wt).buffer}static derDecode(e){let r=Ae(e,Wt);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Zi(this,ir,"f")}get derKey(){return Zi(this,or,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};ir=new WeakMap,or=new WeakMap;Te.RAW_KEY_LENGTH=32;var Ji=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Lr,Xi,tn,Qi,en=class extends Function{constructor(){return super(),Lr.add(this),this.observers=[],new Proxy(this,{apply:(e,r,n)=>Ji(e,Lr,"m",Xi).call(e,n[0])})}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e){this.observers.forEach(r=>r(e))}};Lr=new WeakSet,Xi=function(e){this.notify(e)};var sr=class extends en{constructor(){return super(),tn.add(this),new Proxy(this,{apply:(e,r,n)=>Ji(e,tn,"m",Qi).call(e,n[0])})}log(e){this.notify({message:e,level:"info"})}warn(e){this.notify({message:e,level:"warn"})}error(e,r){this.notify({message:e,level:"error",error:r})}};tn=new WeakSet,Qi=function(e){this.log(e)};var ja=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},$=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},se,ae,Gt,ce,cr,wt;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(wt||(wt={}));var ar=5*60*1e3,Ha="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae",$a="ic0.app",Wa=".ic0.app",Ga="icp0.io",Ya=".icp0.io",za="icp-api.io",Za=".icp-api.io",ve=class extends Tt{constructor(e){super(e),this.message=e}},le=class extends Tt{constructor(e){super(e),this.message=e}};function Ja(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new ve("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof globalThis<"u")if(globalThis.fetch)t=globalThis.fetch.bind(globalThis);else throw new ve("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(t=self.fetch.bind(self));if(t)return t;throw new ve("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var Be=class t{constructor(e={}){if(this.rootKey=ft(Ha),this._timeDiffMsecs=0,this._rootKeyFetched=!1,this._isAgent=!0,this.log=new sr,se.set(this,[]),ae.set(this,[]),Gt.set(this,new nr({expirationTime:5*60*1e3})),ce.set(this,!0),cr.set(this,(r,n)=>{if($(this,ce,"f")===!1)return r;if(!n)throw new we("Invalid signature from replica signed query: no matching node key found.");let{status:i,signatures:o=[],requestId:s}=r,a=new TextEncoder().encode("\vic-response");for(let c of o){let{timestamp:u,identity:l}=c,f=B.fromUint8Array(l).toText(),p;if(i==="replied"){let{reply:v}=r;p=Tr({status:i,reply:v,timestamp:BigInt(u),request_id:s})}else if(i==="rejected"){let{reject_code:v,reject_message:O,error_code:T}=r;p=Tr({status:i,reject_code:v,reject_message:O,error_code:T,timestamp:BigInt(u),request_id:s})}else throw new Error(`Unknown status: ${i}`);let y=je(a,new Uint8Array(p)),g=n?.nodeKeys.get(f);if(!g)throw new we("Invalid signature from replica signed query: no matching node key found.");let w=Te.fromDer(g).rawKey;if(qt.verify(c.signature,new Uint8Array(y),new Uint8Array(w)))return r;throw new we(`Invalid signature from replica ${f} signed query.`)}return r}),e.source){if(!(e.source instanceof t))throw new Error("An Agent's source can only be another HttpAgent");this._identity=e.source._identity,this._fetch=e.source._fetch,this._host=e.source._host,this._credentials=e.source._credentials}else this._fetch=e.fetch||Ja()||fetch.bind(globalThis),this._fetchOptions=e.fetchOptions,this._callOptions=e.callOptions;if(e.host!==void 0)!e.host.match(/^[a-z]+:/)&&typeof window<"u"?this._host=new URL(window.location.protocol+"//"+e.host):this._host=new URL(e.host);else if(e.source!==void 0)this._host=e.source._host;else{let r=typeof window<"u"?window.location:void 0;r||(this._host=new URL("https://icp-api.io"),this.log.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."));let n=["ic0.app","icp0.io","127.0.0.1","localhost"],i=[".github.dev",".gitpod.io"],o=r?.hostname,s;o&&typeof o=="string"&&(i.some(a=>o.endsWith(a))?s=o:s=n.find(a=>o.endsWith(a))),r&&s?this._host=new URL(`${r.protocol}//${s}${r.port?":"+r.port:""}`):(this._host=new URL("https://icp-api.io"),console.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."))}if(e.verifyQuerySignatures!==void 0&&ja(this,ce,e.verifyQuerySignatures,"f"),this._retryTimes=e.retryTimes!==void 0&&e.retryTimes>=0?e.retryTimes:3,this._host.hostname.endsWith(Wa)?this._host.hostname=$a:this._host.hostname.endsWith(Ya)?this._host.hostname=Ga:this._host.hostname.endsWith(Za)&&(this._host.hostname=za),e.credentials){let{name:r,password:n}=e.credentials;this._credentials=`${r}${n?":"+n:""}`}this._identity=Promise.resolve(e.identity||new Ot),this.addTransform("update",jr(re)),e.useQueryNonces&&this.addTransform("query",jr(re)),e.logToConsole&&this.log.subscribe(r=>{r.level==="error"?console.error(r.message):r.level==="warn"?console.warn(r.message):console.log(r.message)})}isLocal(){let e=this._host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,r,n=r.priority||0){if(e==="update"){let i=$(this,ae,"f").findIndex(o=>(o.priority||0)<n);$(this,ae,"f").splice(i>=0?i:$(this,ae,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=$(this,se,"f").findIndex(o=>(o.priority||0)<n);$(this,se,"f").splice(i>=0?i:$(this,se,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!this._identity)throw new le("This identity has expired due this application's security policy. Please refresh your authentication.");return(await this._identity).getPrincipal()}async call(e,r,n){let i=await(n!==void 0?await n:await this._identity);if(!i)throw new le("This identity has expired due this application's security policy. Please refresh your authentication.");let o=B.from(e),s=r.effectiveCanisterId?B.from(r.effectiveCanisterId):o,a=i.getPrincipal()||B.anonymous(),c=new Ht(ar);Math.abs(this._timeDiffMsecs)>1e3*30&&(c=new Ht(ar+this._timeDiffMsecs));let u={request_type:Qe.Call,canister_id:o,method_name:r.methodName,arg:r.arg,sender:a,ingress_expiry:c},l=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"call",body:u});l=await i.transformRequest(l);let f=$e(l.body),p=this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${s.toText()}/call`,this._host),Object.assign(Object.assign(Object.assign({},this._callOptions),l.request),{body:f}))),[y,g]=await Promise.all([p,Ct(u)]),w=await y.arrayBuffer(),E=y.status===200&&w.byteLength>0?me(w):null;return{requestId:g,response:{ok:y.ok,status:y.status,statusText:y.statusText,body:E,headers:Ie(y.headers)}}}async _requestAndRetry(e,r=0){let n;try{n=await e()}catch(s){if(this._retryTimes>r)return console.warn(`Caught exception while attempting to make request:
3
3
  ${s}
4
4
  Retrying request.`),await this._requestAndRetry(e,r+1);throw s}if(n.ok)return n;let i=await n.clone().text(),o=`Server returned an error:
5
5
  Code: ${n.status} (${n.statusText})
6
6
  Body: ${i}
7
- `;if(this._retryTimes>r)return console.warn(o+" Retrying request."),await this._requestAndRetry(e,r+1);throw new De(o,{ok:n.ok,status:n.status,statusText:n.statusText,headers:Ie(n.headers)})}async query(e,r,n){let i=async()=>{let c=await(n!==void 0?await n:await this._identity);if(!c)throw new le("This identity has expired due this application's security policy. Please refresh your authentication.");let u=B.from(e),l=c?.getPrincipal()||B.anonymous(),f={request_type:"query",canister_id:u,method_name:r.methodName,arg:r.arg,sender:l,ingress_expiry:new Ht(ar)},h=await Ct(f),y=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read",body:f});y=await c?.transformRequest(y);let g=$e(y.body),w=await this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${u.toText()}/query`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),y.request),{body:g}))),T=me(await w.arrayBuffer());return Object.assign(Object.assign({},T),{httpDetails:{ok:w.ok,status:w.status,statusText:w.statusText,headers:Ie(w.headers)},requestId:h})},o=async()=>{if(!$(this,ce,"f"))return;let c=$(this,Gt,"f").get(e.toString());return c||(await this.fetchSubnetKeys(e.toString()),$(this,Gt,"f").get(e.toString()))},[s,a]=await Promise.all([i(),o()]);if(!$(this,ce,"f"))return s;try{return $(this,cr,"f").call(this,s,a)}catch{console.warn("Query response verification failed. Retrying with fresh subnet keys."),$(this,Gt,"f").delete(e.toString()),await this.fetchSubnetKeys(e.toString());let u=$(this,Gt,"f").get(e.toString());if(!u)throw new we("Invalid signature from replica signed query: no matching node key found.");return $(this,cr,"f").call(this,s,u)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await this._identity);if(!n)throw new le("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||B.anonymous(),o=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Ht(ar)}});return n?.transformRequest(o)}async readState(e,r,n,i){let o=typeof e=="string"?B.fromText(e):e,s=i??await this.createReadStateRequest(r,n),a=$e(s.body),c=await this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${o}/read_state`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),s.request),{body:a})));if(!c.ok)throw new Error(`Server returned an error:
7
+ `;if(this._retryTimes>r)return console.warn(o+" Retrying request."),await this._requestAndRetry(e,r+1);throw new De(o,{ok:n.ok,status:n.status,statusText:n.statusText,headers:Ie(n.headers)})}async query(e,r,n){let i=async()=>{let c=await(n!==void 0?await n:await this._identity);if(!c)throw new le("This identity has expired due this application's security policy. Please refresh your authentication.");let u=B.from(e),l=c?.getPrincipal()||B.anonymous(),f={request_type:"query",canister_id:u,method_name:r.methodName,arg:r.arg,sender:l,ingress_expiry:new Ht(ar)},p=await Ct(f),y=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read",body:f});y=await c?.transformRequest(y);let g=$e(y.body),w=await this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${u.toText()}/query`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),y.request),{body:g}))),E=me(await w.arrayBuffer());return Object.assign(Object.assign({},E),{httpDetails:{ok:w.ok,status:w.status,statusText:w.statusText,headers:Ie(w.headers)},requestId:p})},o=async()=>{if(!$(this,ce,"f"))return;let c=$(this,Gt,"f").get(e.toString());return c||(await this.fetchSubnetKeys(e.toString()),$(this,Gt,"f").get(e.toString()))},[s,a]=await Promise.all([i(),o()]);if(!$(this,ce,"f"))return s;try{return $(this,cr,"f").call(this,s,a)}catch{console.warn("Query response verification failed. Retrying with fresh subnet keys."),$(this,Gt,"f").delete(e.toString()),await this.fetchSubnetKeys(e.toString());let u=$(this,Gt,"f").get(e.toString());if(!u)throw new we("Invalid signature from replica signed query: no matching node key found.");return $(this,cr,"f").call(this,s,u)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await this._identity);if(!n)throw new le("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||B.anonymous(),o=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Ht(ar)}});return n?.transformRequest(o)}async readState(e,r,n,i){let o=typeof e=="string"?B.fromText(e):e,s=i??await this.createReadStateRequest(r,n),a=$e(s.body),c=await this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${o}/read_state`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),s.request),{body:a})));if(!c.ok)throw new Error(`Server returned an error:
8
8
  Code: ${c.status} (${c.statusText})
9
9
  Body: ${await c.text()}
10
- `);return me(await c.arrayBuffer())}async syncTime(e){let r=await import("./canisterStatus-NVVVKUKM.js"),n=Date.now();try{e||this.log("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let o=(await r.request({canisterId:e??B.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");o&&(this._timeDiffMsecs=Number(o)-Number(n))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{},r=await this._requestAndRetry(()=>this._fetch(""+new URL("/api/v2/status",this._host),Object.assign({headers:e},this._fetchOptions)));return me(await r.arrayBuffer())}async fetchRootKey(){return this._rootKeyFetched||(this.rootKey=(await this.status()).root_key,this._rootKeyFetched=!0),this.rootKey}invalidateIdentity(){this._identity=null}replaceIdentity(e){this._identity=Promise.resolve(e)}async fetchSubnetKeys(e){let r=B.from(e),i=(await vr({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return $(this,Gt,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of $(this,ae,"f"))r=r.then(i=>n(i).then(o=>o||i));else for(let n of $(this,se,"f"))r=r.then(i=>n(i).then(o=>o||i));return r}};se=new WeakMap,ae=new WeakMap,Gt=new WeakMap,ce=new WeakMap,cr=new WeakMap;var Ji;(function(t){t.Error="err",t.GetPrincipal="gp",t.GetPrincipalResponse="gpr",t.Query="q",t.QueryResponse="qr",t.Call="c",t.CallResponse="cr",t.ReadState="rs",t.ReadStateResponse="rsr",t.Status="s",t.StatusResponse="sr"})(Ji||(Ji={}));function rn(){let t=typeof window>"u"?typeof globalThis>"u"?typeof self>"u"?void 0:self.ic.agent:globalThis.ic.agent:window.ic.agent;if(!t)throw new Error("No Agent could be found.");return t}var lr={};Io(lr,{backoff:()=>Li,chain:()=>to,conditionalDelay:()=>Ii,defaultStrategy:()=>Xi,maxAttempts:()=>za,once:()=>Qi,throttle:()=>Za,timeout:()=>Di});var Ya=5*60*1e3;function Xi(){return to(Ii(Qi(),1e3),Li(1e3,1.2),Di(Ya))}function Qi(){let t=!0;return async()=>t?(t=!1,!0):!1}function Ii(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(o=>setTimeout(o,e))}}function za(t){let e=t;return async(r,n,i)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${t} attempts:
11
- Request ID: ${j(n)}
10
+ `);return me(await c.arrayBuffer())}async syncTime(e){let r=await import("./canisterStatus-NVVVKUKM.js"),n=Date.now();try{e||this.log("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let o=(await r.request({canisterId:e??B.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");o&&(this._timeDiffMsecs=Number(o)-Number(n))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{},r=await this._requestAndRetry(()=>this._fetch(""+new URL("/api/v2/status",this._host),Object.assign({headers:e},this._fetchOptions)));return me(await r.arrayBuffer())}async fetchRootKey(){return this._rootKeyFetched||(this.rootKey=(await this.status()).root_key,this._rootKeyFetched=!0),this.rootKey}invalidateIdentity(){this._identity=null}replaceIdentity(e){this._identity=Promise.resolve(e)}async fetchSubnetKeys(e){let r=B.from(e),i=(await vr({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return $(this,Gt,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of $(this,ae,"f"))r=r.then(i=>n(i).then(o=>o||i));else for(let n of $(this,se,"f"))r=r.then(i=>n(i).then(o=>o||i));return r}};se=new WeakMap,ae=new WeakMap,Gt=new WeakMap,ce=new WeakMap,cr=new WeakMap;var Ii;(function(t){t.Error="err",t.GetPrincipal="gp",t.GetPrincipalResponse="gpr",t.Query="q",t.QueryResponse="qr",t.Call="c",t.CallResponse="cr",t.ReadState="rs",t.ReadStateResponse="rsr",t.Status="s",t.StatusResponse="sr"})(Ii||(Ii={}));function rn(){let t=typeof window>"u"?typeof globalThis>"u"?typeof self>"u"?void 0:self.ic.agent:globalThis.ic.agent:window.ic.agent;if(!t)throw new Error("No Agent could be found.");return t}var lr={};ts(lr,{backoff:()=>ro,chain:()=>no,conditionalDelay:()=>to,defaultStrategy:()=>Di,maxAttempts:()=>Qa,once:()=>Li,throttle:()=>Ia,timeout:()=>eo});var Xa=5*60*1e3;function Di(){return no(to(Li(),1e3),ro(1e3,1.2),eo(Xa))}function Li(){let t=!0;return async()=>t?(t=!1,!0):!1}function to(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(o=>setTimeout(o,e))}}function Qa(t){let e=t;return async(r,n,i)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${t} attempts:
11
+ Request ID: ${M(n)}
12
12
  Request status: ${i}
13
- `)}}function Za(t){return()=>new Promise(e=>setTimeout(e,t))}function Di(t){let e=Date.now()+t;return async(r,n,i)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
14
- Request ID: ${j(n)}
13
+ `)}}function Ia(t){return()=>new Promise(e=>setTimeout(e,t))}function eo(t){let e=Date.now()+t;return async(r,n,i)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
14
+ Request ID: ${M(n)}
15
15
  Request status: ${i}
16
- `)}}function Li(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}function to(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}async function nn(t,e,r,n,i,o){var s;let a=[new TextEncoder().encode("request_status"),r],c=i??await((s=t.createReadStateRequest)===null||s===void 0?void 0:s.call(t,{paths:[a]})),u=await t.readState(e,{paths:[a]},void 0,c);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let l=await Wn.create({certificate:u.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:o}),f=l.lookup([...a,new TextEncoder().encode("status")]),h;switch(typeof f>"u"?h=wt.Unknown:h=new TextDecoder().decode(f),h){case wt.Replied:return l.lookup([...a,"reply"]);case wt.Received:case wt.Unknown:case wt.Processing:return await n(e,r,h),nn(t,e,r,n,c);case wt.Rejected:{let y=new Uint8Array(l.lookup([...a,"reject_code"]))[0],g=new TextDecoder().decode(l.lookup([...a,"reject_message"]));throw new Error(`Call was rejected:
17
- Request ID: ${j(r)}
16
+ `)}}function ro(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}function no(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}async function nn(t,e,r,n,i,o){var s;let a=[new TextEncoder().encode("request_status"),r],c=i??await((s=t.createReadStateRequest)===null||s===void 0?void 0:s.call(t,{paths:[a]})),u=await t.readState(e,{paths:[a]},void 0,c);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let l=await Yn.create({certificate:u.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:o}),f=l.lookup([...a,new TextEncoder().encode("status")]),p;switch(typeof f>"u"?p=wt.Unknown:p=new TextDecoder().decode(f),p){case wt.Replied:return l.lookup([...a,"reply"]);case wt.Received:case wt.Unknown:case wt.Processing:return await n(e,r,p),nn(t,e,r,n,c);case wt.Rejected:{let y=new Uint8Array(l.lookup([...a,"reject_code"]))[0],g=new TextDecoder().decode(l.lookup([...a,"reject_message"]));throw new Error(`Call was rejected:
17
+ Request ID: ${M(r)}
18
18
  Reject code: ${y}
19
19
  Reject text: ${g}
20
20
  `)}case wt.Done:throw new Error(`Call was marked as done but we never saw the reply:
21
- Request ID: ${j(r)}
22
- `)}throw new Error("unreachable")}var eo=({IDL:t})=>{let e=t.Variant({mainnet:t.Null,testnet:t.Null}),r=t.Text,n=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,o=t.Record({network:e}),s=t.Nat64,a=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),c=t.Vec(t.Nat8),u=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),l=t.Record({height:t.Nat32,value:i,outpoint:u}),f=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:c,utxos:t.Vec(l)}),h=t.Record({transaction:t.Vec(t.Nat8),network:e}),y=t.Principal,g=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),w=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),T=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:g,details:w}),v=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),O=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),A=t.Variant({secp256k1:t.Null}),C=t.Record({value:t.Text,name:t.Text}),x=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(C)}),J=t.Vec(t.Nat8),ut=t.Vec(t.Nat8),W=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_total:t.Nat64});return t.Service({bitcoin_get_balance:t.Func([n],[i],[]),bitcoin_get_balance_query:t.Func([n],[i],["query"]),bitcoin_get_current_fee_percentiles:t.Func([o],[t.Vec(s)],[]),bitcoin_get_utxos:t.Func([a],[f],[]),bitcoin_get_utxos_query:t.Func([a],[f],["query"]),bitcoin_send_transaction:t.Func([h],[],[]),canister_info:t.Func([t.Record({canister_id:y,num_requested_changes:t.Opt(t.Nat64)})],[t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(T),total_num_changes:t.Nat64})],[]),canister_status:t.Func([t.Record({canister_id:y})],[t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:v,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))})],[]),clear_chunk_store:t.Func([t.Record({canister_id:y})],[],[]),create_canister:t.Func([t.Record({settings:t.Opt(O),sender_canister_version:t.Opt(t.Nat64)})],[t.Record({canister_id:y})],[]),delete_canister:t.Func([t.Record({canister_id:y})],[],[]),deposit_cycles:t.Func([t.Record({canister_id:y})],[],[]),ecdsa_public_key:t.Func([t.Record({key_id:t.Record({name:t.Text,curve:A}),canister_id:t.Opt(y),derivation_path:t.Vec(t.Vec(t.Nat8))})],[t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)})],[]),http_request:t.Func([t.Record({url:t.Text,method:t.Variant({get:t.Null,head:t.Null,post:t.Null}),max_response_bytes:t.Opt(t.Nat64),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Record({function:t.Func([t.Record({context:t.Vec(t.Nat8),response:x})],[x],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(C)})],[x],[]),install_chunked_code:t.Func([t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),chunk_hashes_list:t.Vec(J),target_canister:y,sender_canister_version:t.Opt(t.Nat64),storage_canister:t.Opt(y)})],[],[]),install_code:t.Func([t.Record({arg:t.Vec(t.Nat8),wasm_module:ut,mode:t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),canister_id:y,sender_canister_version:t.Opt(t.Nat64)})],[],[]),node_metrics_history:t.Func([t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal})],[t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(W)}))],[]),provisional_create_canister_with_cycles:t.Func([t.Record({settings:t.Opt(O),specified_id:t.Opt(y),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)})],[t.Record({canister_id:y})],[]),provisional_top_up_canister:t.Func([t.Record({canister_id:y,amount:t.Nat})],[],[]),raw_rand:t.Func([],[t.Vec(t.Nat8)],[]),sign_with_ecdsa:t.Func([t.Record({key_id:t.Record({name:t.Text,curve:A}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)})],[t.Record({signature:t.Vec(t.Nat8)})],[]),start_canister:t.Func([t.Record({canister_id:y})],[],[]),stop_canister:t.Func([t.Record({canister_id:y})],[],[]),stored_chunks:t.Func([t.Record({canister_id:y})],[t.Vec(J)],[]),uninstall_code:t.Func([t.Record({canister_id:y,sender_canister_version:t.Opt(t.Nat64)})],[],[]),update_settings:t.Func([t.Record({canister_id:t.Principal,settings:O,sender_canister_version:t.Opt(t.Nat64)})],[],[]),upload_chunk:t.Func([t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal})],[J],[])})};var dr=class extends Tt{constructor(e,r,n,i){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(o=>` "${o}": ${JSON.stringify(i[o])}`)].join(`
23
- `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}},on=class extends dr{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=Xe[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},sn=class extends dr{constructor(e,r,n,i){super(e,r,"update",Object.assign({"Request ID":j(n)},i.body?Object.assign(Object.assign({},i.body.error_code?{"Error code":i.body.error_code}:{}),{"Reject code":String(i.body.reject_code),"Reject message":i.body.reject_message}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i}},ot=Symbol.for("ic-agent-metadata"),Yt=class t{constructor(e){this[ot]=Object.freeze(e)}static agentOf(e){return e[ot].config.agent}static interfaceOf(e){return e[ot].service}static canisterIdOf(e){return B.from(e[ot].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],o=[...new Uint8Array(e.module)],s=typeof r.canisterId=="string"?B.fromText(r.canisterId):r.canisterId;await ro(r).install_code({mode:n,arg:i,wasm_module:o,canister_id:s,sender_canister_version:[]})}static async createCanister(e,r){function n(o){return[{controllers:o.controllers?[o.controllers]:[],compute_allocation:o.compute_allocation?[o.compute_allocation]:[],freezing_threshold:o.freezing_threshold?[o.freezing_threshold]:[],memory_allocation:o.memory_allocation?[o.memory_allocation]:[]}]}let{canister_id:i}=await ro(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:ye});class i extends t{constructor(s){if(!s.canisterId)throw new Tt(`Canister ID is required, but received ${typeof s.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof s.canisterId=="string"?B.fromText(s.canisterId):s.canisterId;super({config:Object.assign(Object.assign(Object.assign({},io),s),{canisterId:a}),service:n});for(let[c,u]of n._fields)r?.httpDetails&&u.annotations.push(an),this[c]=Xa(this,c,u,s.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Tt(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}};function ur(t,e){let r=ye.decode(t,no.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var io={pollingStrategyFactory:lr.defaultStrategy},an="http-details";function Xa(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(s,...a)=>{var c,u;s=Object.assign(Object.assign({},s),(u=(c=t[ot].config).queryTransform)===null||u===void 0?void 0:u.call(c,e,a,Object.assign(Object.assign({},t[ot].config),s)));let l=s.agent||t[ot].config.agent||rn(),f=B.from(s.canisterId||t[ot].config.canisterId),h=ye.encode(r.argTypes,a),y=await l.query(f,{methodName:e,arg:h});switch(y.status){case"rejected":throw new on(f,e,y);case"replied":return r.annotations.includes(an)?{httpDetails:y.httpDetails,result:ur(r.retTypes,y.reply.arg)}:ur(r.retTypes,y.reply.arg)}}:i=async(s,...a)=>{var c,u;s=Object.assign(Object.assign({},s),(u=(c=t[ot].config).callTransform)===null||u===void 0?void 0:u.call(c,e,a,Object.assign(Object.assign({},t[ot].config),s)));let l=s.agent||t[ot].config.agent||rn(),{canisterId:f,effectiveCanisterId:h,pollingStrategyFactory:y}=Object.assign(Object.assign(Object.assign({},io),t[ot].config),s),g=B.from(f),w=h!==void 0?B.from(h):g,T=ye.encode(r.argTypes,a),{requestId:v,response:O}=await l.call(g,{methodName:e,arg:T,effectiveCanisterId:w});if(!O.ok||O.body)throw new sn(g,e,v,O);let A=y(),C=await nn(l,w,v,A,n),x=r.annotations.includes(an);if(C!==void 0)return x?{httpDetails:O,result:ur(r.retTypes,C)}:ur(r.retTypes,C);if(r.retTypes.length===0)return x?{httpDetails:O,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let o=(...s)=>i({},...s);return o.withOptions=s=>(...a)=>i(s,...a),o}function ro(t){function e(r,n){let i=n[0],o=B.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(o=B.from(i.canister_id)),{effectiveCanisterId:o}}return Yt.createActor(eo,Object.assign(Object.assign(Object.assign({},t),{canisterId:B.fromHex("")}),{callTransform:e,queryTransform:e}))}var hr=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Kt=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},fr,pr,ue,de;function oo(t){return t!==null&&typeof t=="object"}var zt=class t{constructor(e){if(fr.set(this,void 0),pr.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");hr(this,fr,e,"f"),hr(this,pr,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=pt(e);return this.fromRaw(r)}else if(oo(e)){let r=e;if(oo(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw(Hn(n.buffer))}else{if(r instanceof ArrayBuffer)return this.fromRaw(r);if("rawKey"in r)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(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){let r=oe(e,Wt).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=Ae(e,Wt);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Kt(this,fr,"f")}get derKey(){return Kt(this,pr,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};fr=new WeakMap,pr=new WeakMap;zt.RAW_KEY_LENGTH=32;var Zt=class t extends St{constructor(e,r){super(),ue.set(this,void 0),de.set(this,void 0),hr(this,ue,zt.from(e),"f"),hr(this,de,new Uint8Array(r),"f")}static generate(e){if(e&&e.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");e||(e=qt.utils.randomPrivateKey()),He(e,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 i=0;i<32;i++)r[i]=new Uint8Array(e)[i];let n=qt.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(zt.fromDer(pt(r)),pt(n))}static fromJSON(e){let r=JSON.parse(e);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(e)}`)}static fromKeyPair(e,r){return new t(zt.fromRaw(e),r)}static fromSecretKey(e){let r=qt.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[j(Kt(this,ue,"f").toDer()),j(Kt(this,de,"f"))]}getKeyPair(){return{secretKey:Kt(this,de,"f"),publicKey:Kt(this,ue,"f")}}getPublicKey(){return Kt(this,ue,"f")}async sign(e){let r=new Uint8Array(e),n=jn(qt.sign(r,Kt(this,de,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(e,r,n){let[i,o,s]=[e,r,n].map(a=>(typeof a=="string"&&(a=pt(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return qt.verify(o,i,s)}};ue=new WeakMap,de=new WeakMap;var cn=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};function so(t){if(typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.subtle)return globalThis.crypto.subtle;if(t)return t;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new cn("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 Se=class t extends St{constructor(e,r,n){super(),this._keyPair=e,this._derKey=r,this._subtleCrypto=n}static async generate(e){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=e??{},o=so(i),s=await o.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await o.exportKey("spki",s.publicKey);return new this(s,a,o)}static async fromKeyPair(e,r){let n=so(r),i=await n.exportKey("spki",e.publicKey);return new t(e,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let e=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return e},r}async sign(e){let r={name:"ECDSA",hash:{name:"SHA-256"}};return this._keyPair.privateKey,await this._subtleCrypto.sign(r,this._keyPair.privateKey,e)}};var fe=Me($n());var Ia=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Oe=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Vt,yr=class{constructor(e){Vt.set(this,void 0),Ia(this,Vt,e,"f")}get rawKey(){return Oe(this,Vt,"f").rawKey}get derKey(){return Oe(this,Vt,"f").derKey}toDer(){return Oe(this,Vt,"f").toDer()}getPublicKey(){return Oe(this,Vt,"f")}getPrincipal(){return B.from(Oe(this,Vt,"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.")}};Vt=new WeakMap;var Da=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},La=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},tc=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},mr,ec=new TextEncoder().encode("ic-request-auth-delegation"),rc=new TextEncoder().encode(`
24
- ic-request`);function ln(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return pt(t)}var pe=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return fe.value.map(Object.assign({pubkey:fe.value.bytes(this.pubkey),expiration:fe.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:fe.value.array(this.targets.map(e=>fe.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:j(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};async function nc(t,e,r,n){let i=new pe(e.toDer(),BigInt(+r)*BigInt(1e6),n),o=new Uint8Array([...ec,...new Uint8Array(Ct(i))]),s=await t.sign(o);return{delegation:i,signature:s}}var Re=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+15*60*1e3),i={}){var o,s;let a=await nc(e,r,n,i.targets);return new t([...((o=i.previous)===null||o===void 0?void 0:o.delegations)||[],a],((s=i.previous)===null||s===void 0?void 0:s.publicKey)||e.getPublicKey().toDer())}static fromJSON(e){let{publicKey:r,delegations:n}=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(o=>{let{delegation:s,signature:a}=o,{pubkey:c,expiration:u,targets:l}=s;if(l!==void 0&&!Array.isArray(l))throw new Error("Invalid targets.");return{delegation:new pe(ln(c),BigInt("0x"+u),l&&l.map(f=>{if(typeof f!="string")throw new Error("Invalid target.");return B.fromHex(f)})),signature:ln(a)}});return new this(i,ln(r))}static fromDelegations(e,r){return new this(e,r)}toJSON(){return{delegations:this.delegations.map(e=>{let{delegation:r,signature:n}=e,{targets:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:j(r.pubkey)},i&&{targets:i.map(o=>o.toHex())}),signature:j(n)}}),publicKey:j(this.publicKey)}}},Ne=class extends St{constructor(e,r){super(),this._inner=e,this._delegation=r}static fromDelegation(e,r){return new this(e,r)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(e){return this._inner.sign(e)}async transformRequest(e){let{body:r}=e,n=tc(e,["body"]),i=await Ct(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...rc,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},Pe=class t extends yr{constructor(e,r){super(e),mr.set(this,void 0),Da(this,mr,r,"f")}get delegation(){return La(this,mr,"f")}static fromDelegation(e,r){return new t(e,r)}};mr=new WeakMap;function ao(t,e){for(let{delegation:i}of t.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?B.fromText(i):i)):r.push(typeof n=="string"?B.fromText(n):n));for(let i of r){let o=i.toText();for(let{delegation:s}of t.delegations){if(s.targets===void 0)continue;let a=!0;for(let c of s.targets)if(c.toText()===o){a=!1;break}if(a)return!1}}return!0}var ic=Me(Lo());var co;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(co||(co={}));var lo=["mousedown","mousemove","keydown","touchstart","wheel"],Ce=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let o=this._resetTimer.bind(this);window.addEventListener("load",o,!0),lo.forEach(function(a){document.addEventListener(a,o,!0)});let s=(a,c)=>{let u;return(...l)=>{let f=this,h=function(){u=void 0,a.apply(f,l)};clearTimeout(u),u=window.setTimeout(h,c)}};if(e?.captureScroll){let a=s(o,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}o()}static create(e={}){return new this(e)}registerCallback(e){this.callbacks.push(e)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let e=this._resetTimer.bind(this);lo.forEach(function(r){document.removeEventListener(r,e,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let e=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(e,this.idleTimeout)}};var oc=(t,e)=>e.some(r=>t instanceof r),uo,fo;function sc(){return uo||(uo=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ac(){return fo||(fo=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var po=new WeakMap,dn=new WeakMap,ho=new WeakMap,un=new WeakMap,pn=new WeakMap;function cc(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",o),t.removeEventListener("error",s)},o=()=>{r(gt(t.result)),i()},s=()=>{n(t.error),i()};t.addEventListener("success",o),t.addEventListener("error",s)});return e.then(r=>{r instanceof IDBCursor&&po.set(r,t)}).catch(()=>{}),pn.set(e,t),e}function lc(t){if(dn.has(t))return;let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("complete",o),t.removeEventListener("error",s),t.removeEventListener("abort",s)},o=()=>{r(),i()},s=()=>{n(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",o),t.addEventListener("error",s),t.addEventListener("abort",s)});dn.set(t,e)}var fn={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return dn.get(t);if(e==="objectStoreNames")return t.objectStoreNames||ho.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return gt(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function yo(t){fn=t(fn)}function uc(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(wr(this),e,...r);return ho.set(n,e.sort?e.sort():[e]),gt(n)}:ac().includes(t)?function(...e){return t.apply(wr(this),e),gt(po.get(this))}:function(...e){return gt(t.apply(wr(this),e))}}function dc(t){return typeof t=="function"?uc(t):(t instanceof IDBTransaction&&lc(t),oc(t,sc())?new Proxy(t,fn):t)}function gt(t){if(t instanceof IDBRequest)return cc(t);if(un.has(t))return un.get(t);let e=dc(t);return e!==t&&(un.set(t,e),pn.set(e,t)),e}var wr=t=>pn.get(t);function wo(t,e,{blocked:r,upgrade:n,blocking:i,terminated:o}={}){let s=indexedDB.open(t,e),a=gt(s);return n&&s.addEventListener("upgradeneeded",c=>{n(gt(s.result),c.oldVersion,c.newVersion,gt(s.transaction),c)}),r&&s.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{o&&c.addEventListener("close",()=>o()),i&&c.addEventListener("versionchange",u=>i(u.oldVersion,u.newVersion,u))}).catch(()=>{}),a}var fc=["get","getKey","getAll","getAllKeys","count"],pc=["put","add","delete","clear"],hn=new Map;function mo(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(hn.get(e))return hn.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=pc.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||fc.includes(r)))return;let o=async function(s,...a){let c=this.transaction(s,i?"readwrite":"readonly"),u=c.store;return n&&(u=u.index(a.shift())),(await Promise.all([u[r](...a),i&&c.done]))[0]};return hn.set(e,o),o}yo(t=>({...t,get:(e,r,n)=>mo(e,r)||t.get(e,r,n),has:(e,r)=>!!mo(e,r)||t.has(e,r)}));var go="auth-client-db",_o="ic-keyval",hc=async(t=go,e=_o,r)=>(gr&&(localStorage!=null&&localStorage.getItem(ct))&&(localStorage.removeItem(ct),localStorage.removeItem(lt)),await wo(t,r,{upgrade:n=>{n.objectStoreNames,n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function yc(t,e,r){return await t.get(e,r)}async function mc(t,e,r,n){return await t.put(e,n,r)}async function wc(t,e,r){return await t.delete(e,r)}var Ue=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=go,storeName:n=_o,version:i=1}=e??{},o=await hc(r,n,i);return new t(o,n)}async set(e,r){return await mc(this._db,this._storeName,e,r)}async get(e){var r;return(r=await yc(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await wc(this._db,this._storeName,e)}};var lt="identity",ct="delegation",xo="iv",gc=1,gr=typeof window<"u",Fe=class{constructor(e="ic-",r){this.prefix=e,this._localStorage=r}get(e){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+e))}set(e,r){return this._getLocalStorage().setItem(this.prefix+e,r),Promise.resolve()}remove(e){return this._getLocalStorage().removeItem(this.prefix+e),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let e=typeof window>"u"?typeof globalThis>"u"?typeof self>"u"?void 0:self.localStorage:globalThis.localStorage:window.localStorage;if(!e)throw new Error("Could not find local storage.");return e}},ke=class{get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}Ue.create({version:gc}).then(r=>{this.initializedDb=r,e(r)})})}async get(e){return await(await this._db).get(e)}async set(e,r){await(await this._db).set(e,r)}async remove(e){await(await this._db).remove(e)}};var _c="https://identity.ic0.app",xc="#authorize",yn="ECDSA",mn="Ed25519",bc=500,Ec="UserInterrupt",_r=class{constructor(e,r,n,i,o,s,a,c){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=o,this._createOptions=s,this._idpWindow=a,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let o=(r=e.storage)!==null&&r!==void 0?r:new ke,s=(n=e.keyType)!==null&&n!==void 0?n:yn,a=null;if(e.identity)a=e.identity;else{let f=await o.get(lt);if(!f&&gr)try{let h=new Fe,y=await h.get(ct),g=await h.get(lt);y&&g&&s===yn&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await o.set(ct,y),await o.set(lt,g),f=y,await h.remove(ct),await h.remove(lt))}catch(h){console.error("error while attempting to recover localstorage: "+h)}if(f)try{typeof f=="object"?s===mn&&typeof f=="string"?a=await Zt.fromJSON(f):a=await Se.fromKeyPair(f):typeof f=="string"&&(a=Zt.fromJSON(f))}catch{}}let c=new Ot,u=null;if(a)try{let f=await o.get(ct);if(typeof f=="object"&&f!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?c=e.identity:f&&(u=Re.fromJSON(f),ao(u)?"toDer"in a?c=Pe.fromDelegation(a,u):c=Ne.fromDelegation(a,u):(await wn(o),a=null))}catch(f){console.error(f),await wn(o),a=null}let l;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?l=void 0:(u||e.identity)&&(l=Ce.create(e.idleOptions)),a||(s===mn?(a=await Zt.generate(),await o.set(lt,JSON.stringify(a.toJSON()))):(e.storage&&s===yn&&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 '${mn}' as the key type, as it can serialize to a string`),a=await Se.generate(),await o.set(lt,a.getKeyPair()))),new this(c,a,u,o,l,e)}_registerDefaultIdleCallback(){var e,r;let n=(e=this._createOptions)===null||e===void 0?void 0:e.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(e,r){var n,i;let o=e.delegations.map(u=>({delegation:new pe(u.delegation.pubkey,u.delegation.expiration,u.delegation.targets),signature:u.signature.buffer})),s=Re.fromDelegations(o,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=s,"toDer"in a?this._identity=Pe.fromDelegation(a,this._chain):this._identity=Ne.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=Ce.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(ct,JSON.stringify(this._chain.toJSON())),r?.()}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(e){var r,n,i,o;let s=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||_c);a.hash=xc,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=e?.maxTimeToLive)!==null&&i!==void 0?i:s},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(o=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&o!==void 0?o:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Ec,e?.onError):setTimeout(c,bc))};c()}_getEventHandler(e,r){return async n=>{var i,o,s;if(n.origin!==e.origin){console.warn(`WARNING: expected origin '${e.origin}', got '${n.origin}' (ignoring)`);return}let a=n.data;switch(a.kind){case"authorize-ready":{let c={kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,derivationOrigin:(o=r?.derivationOrigin)===null||o===void 0?void 0:o.toString()};(s=this._idpWindow)===null||s===void 0||s.postMessage(c,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.text,r?.onError);break;default:break}}}_handleFailure(e,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(e),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(e={}){if(await wn(this._storage),this._identity=new Ot,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};async function wn(t){await t.remove(lt),await t.remove(ct),await t.remove(xo)}var xr=()=>_r.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var bo=async({data:t})=>{try{return await We(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var gn=async t=>{let{data:e,updated_at:r,description:n}=t;return{description:G(n),data:await Gn(e),updated_at:G(r)}},_n=t=>{let{updated_at:e}=t;return{updated_at:G(e)}},qe=async({doc:t,key:e})=>{let{owner:r,description:n,data:i,...o}=t;return{key:e,description:z(n),owner:r.toText(),data:await We(i),...o}};var br=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:V(t)?[]:[{key:G(t.key),description:G(t.description)}],paginate:G(V(e)?void 0:{start_after:G(e.startAfter),limit:G(V(e.limit)?void 0:BigInt(e.limit))}),order:G(V(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:G(V(n)?void 0:typeof n=="string"?B.fromText(n):n)});var Eo=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({controllers:t.Vec(t.Principal)}),n=t.Variant({Write:t.Null,Admin:t.Null}),i=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:n,expires_at:t.Opt(t.Nat64)}),o=t.Record({updated_at:t.Opt(t.Nat64)}),s=t.Variant({Db:t.Null,Storage:t.Null}),a=t.Record({cycles:t.Nat,destination_id:t.Principal}),c=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),u=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),l=t.Record({key:c,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,u)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64}),f=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),h=t.Record({status_code:t.Nat16,location:t.Text}),y=t.Record({iframe:t.Opt(f),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),redirects:t.Opt(t.Vec(t.Tuple(t.Text,h)))}),g=t.Record({storage:y}),w=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64}),T=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),v=t.Variant({Heap:t.Null,Stable:t.Null}),O=t.Record({memory:v,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),A=t.Variant({Callback:t.Record({token:O,callback:t.Func([],[],["query"])})}),C=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(A),status_code:t.Nat16}),x=t.Record({token:t.Opt(O),body:t.Vec(t.Nat8)}),J=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),ut=t.Record({batch_id:t.Nat}),W=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),D=t.Record({field:W,desc:t.Bool}),xt=t.Record({key:t.Opt(t.Text),description:t.Opt(t.Text)}),dt=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),bt=t.Record({order:t.Opt(D),owner:t.Opt(t.Principal),matcher:t.Opt(xt),paginate:t.Opt(dt)}),Et=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,l)),items_length:t.Nat64}),he=t.Record({updated_at:t.Nat64,created_at:t.Nat64,bn_id:t.Opt(t.Text)}),Jt=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,w)),items_length:t.Nat64}),Xt=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),An=t.Record({memory:t.Opt(v),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:Xt,created_at:t.Nat64,mutable_permissions:t.Opt(t.Bool),write:Xt}),m=t.Record({stable:t.Nat64,heap:t.Nat64}),p=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:n,expires_at:t.Opt(t.Nat64)}),_=t.Record({controller:p,controllers:t.Vec(t.Principal)}),b=t.Record({updated_at:t.Opt(t.Nat64),data:t.Vec(t.Nat8),description:t.Opt(t.Text)}),S=t.Record({memory:t.Opt(v),updated_at:t.Opt(t.Nat64),max_size:t.Opt(t.Nat),read:Xt,mutable_permissions:t.Opt(t.Bool),write:Xt}),R=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),N=t.Record({chunk_id:t.Nat});return t.Service({build_version:t.Func([],[t.Text],["query"]),commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([r],[t.Vec(t.Tuple(t.Principal,i))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,o],[],[]),del_docs:t.Func([t.Text],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,o))],[],[]),del_rule:t.Func([s,t.Text,o],[],[]),deposit_cycles:t.Func([a],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(l)],["query"]),get_config:t.Func([],[g],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(w)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(l)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(w)))],["query"]),http_request:t.Func([T],[C],["query"]),http_request_streaming_callback:t.Func([O],[x],["query"]),init_asset_upload:t.Func([J],[ut],[]),list_assets:t.Func([t.Text,bt],[Et],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,i))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,he))],["query"]),list_docs:t.Func([t.Text,bt],[Jt],["query"]),list_rules:t.Func([s],[t.Vec(t.Tuple(t.Text,An))],["query"]),memory_size:t.Func([],[m],["query"]),set_config:t.Func([g],[],[]),set_controllers:t.Func([_],[t.Vec(t.Tuple(t.Principal,i))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,b],[w],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,b))],[t.Vec(t.Tuple(t.Text,w))],[]),set_rule:t.Func([s,t.Text,S],[],[]),upload_asset_chunk:t.Func([R],[N],[]),version:t.Func([],[t.Text],["query"])})};var Ao=async({satelliteId:t,idlFactory:e,identity:r,fetch:n,container:i})=>{let s=K(i)&&i!==!1?i===!0?It:i:"https://icp-api.io",a=new Be({identity:r,host:s,...n&&{fetch:n}});return K(i)&&await a.fetchRootKey(),Yt.createActor(e,{agent:a,canisterId:t})};var Q=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=K(t)?{satelliteId:t}:rt.getInstance().get()??{satelliteId:void 0},{container:i}=K(e)?{container:e}:rt.getInstance().get()??{container:void 0};if(!n)throw new Error("No satellite principal defined.");return Ao({satelliteId:n,container:i,idlFactory:Eo,...r})};var To=async({collection:t,key:e,satellite:r})=>{let n=await Q(r),i=z(await n.get_doc(t,e));if(!V(i))return qe({doc:i,key:e})},vo=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await Q(e),n=t.map(({collection:s,key:a})=>[s,a]),i=await r(n),o=[];for(let[s,a]of i){let c=z(a);o.push(K(c)?await qe({key:s,doc:c}):void 0)}return o},Bo=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await Q(r),{key:i}=e,o=await gn(e),s=await n(t,i,o);return await qe({key:i,doc:s})},So=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await Q(e),n=[];for(let{collection:s,doc:a}of t){let{key:c}=a;n.push([s,c,await gn(a)])}let i=await r(n),o=[];for(let[s,a]of i)o.push(await qe({key:s,doc:a}));return o},Oo=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await Q(r),{key:i}=e;return n(t,i,_n(e))},Ro=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await Q(e),n=t.map(({collection:i,doc:o})=>[i,o.key,_n(o)]);await r(n)},No=async({collection:t,filter:e,satellite:r})=>{let n=await Q(r),{items:i,items_page:o,items_length:s,matches_length:a,matches_pages:c}=await n.list_docs(t,br(e)),u=[];for(let[l,f]of i){let{data:h,owner:y,description:g,...w}=f;u.push({key:l,description:z(g),owner:y.toText(),data:await bo({data:h}),...w})}return{items:u,items_length:s,items_page:z(o),matches_length:a,matches_pages:z(c)}};var I=t=>t!==void 0?t:Er()??new Ot;var Po=async({satellite:t,...e})=>{let r=I(t?.identity);return To({...e,satellite:{...t,identity:r}})},_f=async({satellite:t,...e})=>{let r=I(t?.identity);return vo({...e,satellite:{...t,identity:r}})},Co=async({satellite:t,...e})=>{let r=I(t?.identity);return Bo({...e,satellite:{...t,identity:r}})},xf=async({satellite:t,...e})=>{let r=I(t?.identity);return So({...e,satellite:{...t,identity:r}})},bf=async({satellite:t,...e})=>{let r=I(t?.identity);return Oo({...e,satellite:{...t,identity:r}})},Ef=async({satellite:t,...e})=>{let r=I(t?.identity);return Ro({...e,satellite:{...t,identity:r}})},Af=async({satellite:t,filter:e,...r})=>{let n=I(t?.identity);return No({...r,filter:e??{},satellite:{...t,identity:n}})};var Uo=async t=>{let e=Er();if(V(e))throw new Error("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=await Po({collection:"#user",key:r});return V(n)?await Ac({userId:r,provider:t}):n},Ac=async({userId:t,...e})=>Co({collection:"#user",doc:{key:t,data:e}});var _t,xn=async t=>{if(_t=_t??await xr(),!(await _t?.isAuthenticated()??!1))return;let r=await Uo(t);vt.getInstance().set(r)},Tc=async t=>new Promise(async(e,r)=>{_t=_t??await xr();let n=t?.provider??new Ye({});await _t.login({onSuccess:async()=>{await xn(n.id),e()},onError:i=>r(i),maxTimeToLive:t?.maxTimeToLive??Yn,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),bn=async()=>{await _t?.logout(),_t=void 0,vt.getInstance().reset()},Er=()=>_t?.getIdentity(),vc=async()=>(_t??await xr()).getIdentity();var Fo=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{Rr({message:"junoSignOutAuthTimer"}),await bn()};return r.onmessage=async({data:i})=>{let{msg:o,data:s}=i;switch(o){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":Rr({message:"junoDelegationRemainingTime",detail:s?.authRemainingTime});return}},vt.getInstance().subscribe(i=>{if(V(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var ko=async({data:t,filename:e,collection:r,headers:n,token:i,fullPath:o,encoding:s,description:a,satellite:c})=>{let u=await Q(c),{batch_id:l}=await u.init_asset_upload({collection:r,full_path:o,name:e,token:G(i),encoding_type:G(s),description:G(a)}),f=19e5,h=[],y=Ge()?new Blob([await t.arrayBuffer()]):t,g=0n;for(let v=0;v<y.size;v+=f){let O=y.slice(v,v+f);h.push({batchId:l,chunk:O,actor:u,orderId:g}),g++}let w=[];for await(let v of Bc({uploadChunks:h}))w=[...w,...v];let T=n.find(([v,O])=>v.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await u.commit_asset_upload({batch_id:l,chunk_ids:w.map(({chunk_id:v})=>v),headers:[...n,...T||[]]})};async function*Bc({uploadChunks:t,limit:e=12}){for(let r=0;r<t.length;r=r+e){let n=t.slice(r,r+e);yield await Promise.all(n.map(o=>Sc(o)))}}var Sc=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:G(n)}),qo=async({collection:t,satellite:e,filter:r})=>{let n=await Q(e),{items:i,items_length:o,items_page:s,matches_length:a,matches_pages:c}=await n.list_assets(t,br(r));return{items:i.map(([u,l])=>l),items_length:o,items_page:z(s),matches_length:a,matches_pages:z(c)}},Ko=async({collection:t,fullPath:e,satellite:r})=>(await Q(r)).del_asset(t,e),Vo=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await Q(e),n=t.map(({collection:i,fullPath:o})=>[i,o]);await r(n)},Mo=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await Q(r);return z(await n(t,e))},jo=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await Q(e),n=t.map(({collection:o,fullPath:s})=>[o,s]);return(await r(n)).map(([o,s])=>z(s))};var Ho=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var En=()=>{let t=rt.getInstance().get()?.satelliteId??"unknown",e=rt.getInstance().get()?.container;if(K(e)&&e!==!1){let{host:r,protocol:n}=new URL(e===!0?It:e);return`${n}//${t}.${r.replace("127.0.0.1","localhost")}`}return`https://${t}.icp0.io`};var tp=async t=>$o(t),ep=async t=>$o({filename:t.data.name,...t}),$o=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:o,satellite:s,encoding:a,description:c})=>{let u=I(s?.identity),l=decodeURI(t),f=i??`/${r}/${l}`;return await ko({data:e,filename:l,collection:r,token:o,headers:n,fullPath:f,encoding:a,satellite:{...s,identity:u},description:c}),{downloadUrl:`${En()}${f}${o!==void 0?`?token=${o}`:""}`,fullPath:f,name:l}},rp=async({collection:t,satellite:e,filter:r})=>{let{items:n,...i}=await qo({collection:t,satellite:{...e,identity:I(e?.identity)},filter:r??{}}),o=En();return{assets:n.map(({key:{full_path:s,token:a,name:c,owner:u,description:l},headers:f,encodings:h,created_at:y,updated_at:g})=>{let w=z(a);return{fullPath:s,description:z(l),name:c,downloadUrl:`${o}${s}${w!==void 0?`?token=${w}`:""}`,token:w,headers:f,encodings:h.reduce((T,[v,{modified:O,sha256:A,total_length:C}])=>({...T,[v]:{modified:O,sha256:Ho(A),total_length:C}}),{}),owner:u.toText(),created_at:y,updated_at:g}}),...i}},np=async({collection:t,fullPath:e,satellite:r})=>Ko({collection:t,fullPath:e,satellite:{...r,identity:I(r?.identity)}}),ip=async({assets:t,satellite:e})=>Vo({assets:t,satellite:{...e,identity:I(e?.identity)}}),op=async({satellite:t,...e})=>{let r=I(t?.identity);return Mo({...e,satellite:{...t,identity:r}})},sp=async({satellite:t,...e})=>{let r=I(t?.identity);return jo({...e,satellite:{...t,identity:r}})};var fp=async t=>{rt.getInstance().set(t),await xn();let e=t.workers?.auth!==void 0?Fo(t.workers.auth):void 0;return[...e?[e]:[]]},pp=t=>vt.getInstance().subscribe(t);export{Ye as InternetIdentityProvider,Qn as NFIDProvider,pp as authSubscribe,np as deleteAsset,bf as deleteDoc,ip as deleteManyAssets,Ef as deleteManyDocs,op as getAsset,Po as getDoc,sp as getManyAssets,_f as getManyDocs,fp as initJuno,rp as listAssets,Af as listDocs,Co as setDoc,xf as setManyDocs,Tc as signIn,bn as signOut,vc as unsafeIdentity,tp as uploadBlob,ep as uploadFile};
21
+ Request ID: ${M(r)}
22
+ `)}throw new Error("unreachable")}var io=({IDL:t})=>{let e=t.Variant({mainnet:t.Null,testnet:t.Null}),r=t.Text,n=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,o=t.Record({network:e}),s=t.Nat64,a=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),c=t.Vec(t.Nat8),u=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),l=t.Record({height:t.Nat32,value:i,outpoint:u}),f=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:c,utxos:t.Vec(l)}),p=t.Record({transaction:t.Vec(t.Nat8),network:e}),y=t.Principal,g=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),w=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),E=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:g,details:w}),v=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),O=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),T=t.Variant({secp256k1:t.Null}),C=t.Record({value:t.Text,name:t.Text}),x=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(C)}),J=t.Vec(t.Nat8),lt=t.Vec(t.Nat8),W=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_total:t.Nat64});return t.Service({bitcoin_get_balance:t.Func([n],[i],[]),bitcoin_get_balance_query:t.Func([n],[i],["query"]),bitcoin_get_current_fee_percentiles:t.Func([o],[t.Vec(s)],[]),bitcoin_get_utxos:t.Func([a],[f],[]),bitcoin_get_utxos_query:t.Func([a],[f],["query"]),bitcoin_send_transaction:t.Func([p],[],[]),canister_info:t.Func([t.Record({canister_id:y,num_requested_changes:t.Opt(t.Nat64)})],[t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(E),total_num_changes:t.Nat64})],[]),canister_status:t.Func([t.Record({canister_id:y})],[t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:v,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))})],[]),clear_chunk_store:t.Func([t.Record({canister_id:y})],[],[]),create_canister:t.Func([t.Record({settings:t.Opt(O),sender_canister_version:t.Opt(t.Nat64)})],[t.Record({canister_id:y})],[]),delete_canister:t.Func([t.Record({canister_id:y})],[],[]),deposit_cycles:t.Func([t.Record({canister_id:y})],[],[]),ecdsa_public_key:t.Func([t.Record({key_id:t.Record({name:t.Text,curve:T}),canister_id:t.Opt(y),derivation_path:t.Vec(t.Vec(t.Nat8))})],[t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)})],[]),http_request:t.Func([t.Record({url:t.Text,method:t.Variant({get:t.Null,head:t.Null,post:t.Null}),max_response_bytes:t.Opt(t.Nat64),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Record({function:t.Func([t.Record({context:t.Vec(t.Nat8),response:x})],[x],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(C)})],[x],[]),install_chunked_code:t.Func([t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),chunk_hashes_list:t.Vec(J),target_canister:y,sender_canister_version:t.Opt(t.Nat64),storage_canister:t.Opt(y)})],[],[]),install_code:t.Func([t.Record({arg:t.Vec(t.Nat8),wasm_module:lt,mode:t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),canister_id:y,sender_canister_version:t.Opt(t.Nat64)})],[],[]),node_metrics_history:t.Func([t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal})],[t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(W)}))],[]),provisional_create_canister_with_cycles:t.Func([t.Record({settings:t.Opt(O),specified_id:t.Opt(y),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)})],[t.Record({canister_id:y})],[]),provisional_top_up_canister:t.Func([t.Record({canister_id:y,amount:t.Nat})],[],[]),raw_rand:t.Func([],[t.Vec(t.Nat8)],[]),sign_with_ecdsa:t.Func([t.Record({key_id:t.Record({name:t.Text,curve:T}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)})],[t.Record({signature:t.Vec(t.Nat8)})],[]),start_canister:t.Func([t.Record({canister_id:y})],[],[]),stop_canister:t.Func([t.Record({canister_id:y})],[],[]),stored_chunks:t.Func([t.Record({canister_id:y})],[t.Vec(J)],[]),uninstall_code:t.Func([t.Record({canister_id:y,sender_canister_version:t.Opt(t.Nat64)})],[],[]),update_settings:t.Func([t.Record({canister_id:t.Principal,settings:O,sender_canister_version:t.Opt(t.Nat64)})],[],[]),upload_chunk:t.Func([t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal})],[J],[])})};var dr=class extends Tt{constructor(e,r,n,i){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(o=>` "${o}": ${JSON.stringify(i[o])}`)].join(`
23
+ `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}},on=class extends dr{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=Xe[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},sn=class extends dr{constructor(e,r,n,i){super(e,r,"update",Object.assign({"Request ID":M(n)},i.body?Object.assign(Object.assign({},i.body.error_code?{"Error code":i.body.error_code}:{}),{"Reject code":String(i.body.reject_code),"Reject message":i.body.reject_message}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i}},it=Symbol.for("ic-agent-metadata"),Yt=class t{constructor(e){this[it]=Object.freeze(e)}static agentOf(e){return e[it].config.agent}static interfaceOf(e){return e[it].service}static canisterIdOf(e){return B.from(e[it].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],o=[...new Uint8Array(e.module)],s=typeof r.canisterId=="string"?B.fromText(r.canisterId):r.canisterId;await oo(r).install_code({mode:n,arg:i,wasm_module:o,canister_id:s,sender_canister_version:[]})}static async createCanister(e,r){function n(o){return[{controllers:o.controllers?[o.controllers]:[],compute_allocation:o.compute_allocation?[o.compute_allocation]:[],freezing_threshold:o.freezing_threshold?[o.freezing_threshold]:[],memory_allocation:o.memory_allocation?[o.memory_allocation]:[]}]}let{canister_id:i}=await oo(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:ye});class i extends t{constructor(s){if(!s.canisterId)throw new Tt(`Canister ID is required, but received ${typeof s.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof s.canisterId=="string"?B.fromText(s.canisterId):s.canisterId;super({config:Object.assign(Object.assign(Object.assign({},ao),s),{canisterId:a}),service:n});for(let[c,u]of n._fields)r?.httpDetails&&u.annotations.push(an),this[c]=La(this,c,u,s.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Tt(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}};function ur(t,e){let r=ye.decode(t,so.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var ao={pollingStrategyFactory:lr.defaultStrategy},an="http-details";function La(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(s,...a)=>{var c,u;s=Object.assign(Object.assign({},s),(u=(c=t[it].config).queryTransform)===null||u===void 0?void 0:u.call(c,e,a,Object.assign(Object.assign({},t[it].config),s)));let l=s.agent||t[it].config.agent||rn(),f=B.from(s.canisterId||t[it].config.canisterId),p=ye.encode(r.argTypes,a),y=await l.query(f,{methodName:e,arg:p});switch(y.status){case"rejected":throw new on(f,e,y);case"replied":return r.annotations.includes(an)?{httpDetails:y.httpDetails,result:ur(r.retTypes,y.reply.arg)}:ur(r.retTypes,y.reply.arg)}}:i=async(s,...a)=>{var c,u;s=Object.assign(Object.assign({},s),(u=(c=t[it].config).callTransform)===null||u===void 0?void 0:u.call(c,e,a,Object.assign(Object.assign({},t[it].config),s)));let l=s.agent||t[it].config.agent||rn(),{canisterId:f,effectiveCanisterId:p,pollingStrategyFactory:y}=Object.assign(Object.assign(Object.assign({},ao),t[it].config),s),g=B.from(f),w=p!==void 0?B.from(p):g,E=ye.encode(r.argTypes,a),{requestId:v,response:O}=await l.call(g,{methodName:e,arg:E,effectiveCanisterId:w});if(!O.ok||O.body)throw new sn(g,e,v,O);let T=y(),C=await nn(l,w,v,T,n),x=r.annotations.includes(an);if(C!==void 0)return x?{httpDetails:O,result:ur(r.retTypes,C)}:ur(r.retTypes,C);if(r.retTypes.length===0)return x?{httpDetails:O,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let o=(...s)=>i({},...s);return o.withOptions=s=>(...a)=>i(s,...a),o}function oo(t){function e(r,n){let i=n[0],o=B.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(o=B.from(i.canister_id)),{effectiveCanisterId:o}}return Yt.createActor(io,Object.assign(Object.assign(Object.assign({},t),{canisterId:B.fromHex("")}),{callTransform:e,queryTransform:e}))}var hr=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Kt=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},fr,pr,ue,de;function co(t){return t!==null&&typeof t=="object"}var zt=class t{constructor(e){if(fr.set(this,void 0),pr.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");hr(this,fr,e,"f"),hr(this,pr,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=ft(e);return this.fromRaw(r)}else if(co(e)){let r=e;if(co(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw(Wn(n.buffer))}else{if(r instanceof ArrayBuffer)return this.fromRaw(r);if("rawKey"in r)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(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){let r=oe(e,Wt).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=Ae(e,Wt);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Kt(this,fr,"f")}get derKey(){return Kt(this,pr,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};fr=new WeakMap,pr=new WeakMap;zt.RAW_KEY_LENGTH=32;var Zt=class t extends St{constructor(e,r){super(),ue.set(this,void 0),de.set(this,void 0),hr(this,ue,zt.from(e),"f"),hr(this,de,new Uint8Array(r),"f")}static generate(e){if(e&&e.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");e||(e=qt.utils.randomPrivateKey()),He(e,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 i=0;i<32;i++)r[i]=new Uint8Array(e)[i];let n=qt.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(zt.fromDer(ft(r)),ft(n))}static fromJSON(e){let r=JSON.parse(e);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(e)}`)}static fromKeyPair(e,r){return new t(zt.fromRaw(e),r)}static fromSecretKey(e){let r=qt.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[M(Kt(this,ue,"f").toDer()),M(Kt(this,de,"f"))]}getKeyPair(){return{secretKey:Kt(this,de,"f"),publicKey:Kt(this,ue,"f")}}getPublicKey(){return Kt(this,ue,"f")}async sign(e){let r=new Uint8Array(e),n=$n(qt.sign(r,Kt(this,de,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(e,r,n){let[i,o,s]=[e,r,n].map(a=>(typeof a=="string"&&(a=ft(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return qt.verify(o,i,s)}};ue=new WeakMap,de=new WeakMap;var cn=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};function lo(t){if(typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.subtle)return globalThis.crypto.subtle;if(t)return t;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new cn("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 Se=class t extends St{constructor(e,r,n){super(),this._keyPair=e,this._derKey=r,this._subtleCrypto=n}static async generate(e){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=e??{},o=lo(i),s=await o.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await o.exportKey("spki",s.publicKey);return new this(s,a,o)}static async fromKeyPair(e,r){let n=lo(r),i=await n.exportKey("spki",e.publicKey);return new t(e,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let e=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return e},r}async sign(e){let r={name:"ECDSA",hash:{name:"SHA-256"}};return this._keyPair.privateKey,await this._subtleCrypto.sign(r,this._keyPair.privateKey,e)}};var fe=Me(Gn());var ec=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Oe=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Vt,yr=class{constructor(e){Vt.set(this,void 0),ec(this,Vt,e,"f")}get rawKey(){return Oe(this,Vt,"f").rawKey}get derKey(){return Oe(this,Vt,"f").derKey}toDer(){return Oe(this,Vt,"f").toDer()}getPublicKey(){return Oe(this,Vt,"f")}getPrincipal(){return B.from(Oe(this,Vt,"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.")}};Vt=new WeakMap;var rc=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},nc=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ic=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},mr,oc=new TextEncoder().encode("ic-request-auth-delegation"),sc=new TextEncoder().encode(`
24
+ ic-request`);function ln(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return ft(t)}var pe=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return fe.value.map(Object.assign({pubkey:fe.value.bytes(this.pubkey),expiration:fe.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:fe.value.array(this.targets.map(e=>fe.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:M(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};async function ac(t,e,r,n){let i=new pe(e.toDer(),BigInt(+r)*BigInt(1e6),n),o=new Uint8Array([...oc,...new Uint8Array(Ct(i))]),s=await t.sign(o);return{delegation:i,signature:s}}var Re=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+15*60*1e3),i={}){var o,s;let a=await ac(e,r,n,i.targets);return new t([...((o=i.previous)===null||o===void 0?void 0:o.delegations)||[],a],((s=i.previous)===null||s===void 0?void 0:s.publicKey)||e.getPublicKey().toDer())}static fromJSON(e){let{publicKey:r,delegations:n}=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(o=>{let{delegation:s,signature:a}=o,{pubkey:c,expiration:u,targets:l}=s;if(l!==void 0&&!Array.isArray(l))throw new Error("Invalid targets.");return{delegation:new pe(ln(c),BigInt("0x"+u),l&&l.map(f=>{if(typeof f!="string")throw new Error("Invalid target.");return B.fromHex(f)})),signature:ln(a)}});return new this(i,ln(r))}static fromDelegations(e,r){return new this(e,r)}toJSON(){return{delegations:this.delegations.map(e=>{let{delegation:r,signature:n}=e,{targets:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:M(r.pubkey)},i&&{targets:i.map(o=>o.toHex())}),signature:M(n)}}),publicKey:M(this.publicKey)}}},Ne=class extends St{constructor(e,r){super(),this._inner=e,this._delegation=r}static fromDelegation(e,r){return new this(e,r)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(e){return this._inner.sign(e)}async transformRequest(e){let{body:r}=e,n=ic(e,["body"]),i=await Ct(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...sc,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},Pe=class t extends yr{constructor(e,r){super(e),mr.set(this,void 0),rc(this,mr,r,"f")}get delegation(){return nc(this,mr,"f")}static fromDelegation(e,r){return new t(e,r)}};mr=new WeakMap;function uo(t,e){for(let{delegation:i}of t.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?B.fromText(i):i)):r.push(typeof n=="string"?B.fromText(n):n));for(let i of r){let o=i.toText();for(let{delegation:s}of t.delegations){if(s.targets===void 0)continue;let a=!0;for(let c of s.targets)if(c.toText()===o){a=!1;break}if(a)return!1}}return!0}var cc=Me(rs());var fo;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(fo||(fo={}));var po=["mousedown","mousemove","keydown","touchstart","wheel"],Ce=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let o=this._resetTimer.bind(this);window.addEventListener("load",o,!0),po.forEach(function(a){document.addEventListener(a,o,!0)});let s=(a,c)=>{let u;return(...l)=>{let f=this,p=function(){u=void 0,a.apply(f,l)};clearTimeout(u),u=window.setTimeout(p,c)}};if(e?.captureScroll){let a=s(o,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}o()}static create(e={}){return new this(e)}registerCallback(e){this.callbacks.push(e)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let e=this._resetTimer.bind(this);po.forEach(function(r){document.removeEventListener(r,e,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let e=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(e,this.idleTimeout)}};var lc=(t,e)=>e.some(r=>t instanceof r),ho,yo;function uc(){return ho||(ho=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function dc(){return yo||(yo=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var mo=new WeakMap,dn=new WeakMap,wo=new WeakMap,un=new WeakMap,pn=new WeakMap;function fc(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",o),t.removeEventListener("error",s)},o=()=>{r(gt(t.result)),i()},s=()=>{n(t.error),i()};t.addEventListener("success",o),t.addEventListener("error",s)});return e.then(r=>{r instanceof IDBCursor&&mo.set(r,t)}).catch(()=>{}),pn.set(e,t),e}function pc(t){if(dn.has(t))return;let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("complete",o),t.removeEventListener("error",s),t.removeEventListener("abort",s)},o=()=>{r(),i()},s=()=>{n(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",o),t.addEventListener("error",s),t.addEventListener("abort",s)});dn.set(t,e)}var fn={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return dn.get(t);if(e==="objectStoreNames")return t.objectStoreNames||wo.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return gt(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function go(t){fn=t(fn)}function hc(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(wr(this),e,...r);return wo.set(n,e.sort?e.sort():[e]),gt(n)}:dc().includes(t)?function(...e){return t.apply(wr(this),e),gt(mo.get(this))}:function(...e){return gt(t.apply(wr(this),e))}}function yc(t){return typeof t=="function"?hc(t):(t instanceof IDBTransaction&&pc(t),lc(t,uc())?new Proxy(t,fn):t)}function gt(t){if(t instanceof IDBRequest)return fc(t);if(un.has(t))return un.get(t);let e=yc(t);return e!==t&&(un.set(t,e),pn.set(e,t)),e}var wr=t=>pn.get(t);function xo(t,e,{blocked:r,upgrade:n,blocking:i,terminated:o}={}){let s=indexedDB.open(t,e),a=gt(s);return n&&s.addEventListener("upgradeneeded",c=>{n(gt(s.result),c.oldVersion,c.newVersion,gt(s.transaction),c)}),r&&s.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{o&&c.addEventListener("close",()=>o()),i&&c.addEventListener("versionchange",u=>i(u.oldVersion,u.newVersion,u))}).catch(()=>{}),a}var mc=["get","getKey","getAll","getAllKeys","count"],wc=["put","add","delete","clear"],hn=new Map;function _o(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(hn.get(e))return hn.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=wc.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||mc.includes(r)))return;let o=async function(s,...a){let c=this.transaction(s,i?"readwrite":"readonly"),u=c.store;return n&&(u=u.index(a.shift())),(await Promise.all([u[r](...a),i&&c.done]))[0]};return hn.set(e,o),o}go(t=>({...t,get:(e,r,n)=>_o(e,r)||t.get(e,r,n),has:(e,r)=>!!_o(e,r)||t.has(e,r)}));var bo="auth-client-db",Eo="ic-keyval",gc=async(t=bo,e=Eo,r)=>(gr&&(localStorage!=null&&localStorage.getItem(at))&&(localStorage.removeItem(at),localStorage.removeItem(ct)),await xo(t,r,{upgrade:n=>{n.objectStoreNames,n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function _c(t,e,r){return await t.get(e,r)}async function xc(t,e,r,n){return await t.put(e,n,r)}async function bc(t,e,r){return await t.delete(e,r)}var Ue=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=bo,storeName:n=Eo,version:i=1}=e??{},o=await gc(r,n,i);return new t(o,n)}async set(e,r){return await xc(this._db,this._storeName,e,r)}async get(e){var r;return(r=await _c(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await bc(this._db,this._storeName,e)}};var ct="identity",at="delegation",Ao="iv",Ec=1,gr=typeof window<"u",Fe=class{constructor(e="ic-",r){this.prefix=e,this._localStorage=r}get(e){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+e))}set(e,r){return this._getLocalStorage().setItem(this.prefix+e,r),Promise.resolve()}remove(e){return this._getLocalStorage().removeItem(this.prefix+e),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let e=typeof window>"u"?typeof globalThis>"u"?typeof self>"u"?void 0:self.localStorage:globalThis.localStorage:window.localStorage;if(!e)throw new Error("Could not find local storage.");return e}},ke=class{get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}Ue.create({version:Ec}).then(r=>{this.initializedDb=r,e(r)})})}async get(e){return await(await this._db).get(e)}async set(e,r){await(await this._db).set(e,r)}async remove(e){await(await this._db).remove(e)}};var Ac="https://identity.ic0.app",Tc="#authorize",yn="ECDSA",mn="Ed25519",vc=500,Bc="UserInterrupt",_r=class{constructor(e,r,n,i,o,s,a,c){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=o,this._createOptions=s,this._idpWindow=a,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let o=(r=e.storage)!==null&&r!==void 0?r:new ke,s=(n=e.keyType)!==null&&n!==void 0?n:yn,a=null;if(e.identity)a=e.identity;else{let f=await o.get(ct);if(!f&&gr)try{let p=new Fe,y=await p.get(at),g=await p.get(ct);y&&g&&s===yn&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await o.set(at,y),await o.set(ct,g),f=y,await p.remove(at),await p.remove(ct))}catch(p){console.error("error while attempting to recover localstorage: "+p)}if(f)try{typeof f=="object"?s===mn&&typeof f=="string"?a=await Zt.fromJSON(f):a=await Se.fromKeyPair(f):typeof f=="string"&&(a=Zt.fromJSON(f))}catch{}}let c=new Ot,u=null;if(a)try{let f=await o.get(at);if(typeof f=="object"&&f!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?c=e.identity:f&&(u=Re.fromJSON(f),uo(u)?"toDer"in a?c=Pe.fromDelegation(a,u):c=Ne.fromDelegation(a,u):(await wn(o),a=null))}catch(f){console.error(f),await wn(o),a=null}let l;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?l=void 0:(u||e.identity)&&(l=Ce.create(e.idleOptions)),a||(s===mn?(a=await Zt.generate(),await o.set(ct,JSON.stringify(a.toJSON()))):(e.storage&&s===yn&&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 '${mn}' as the key type, as it can serialize to a string`),a=await Se.generate(),await o.set(ct,a.getKeyPair()))),new this(c,a,u,o,l,e)}_registerDefaultIdleCallback(){var e,r;let n=(e=this._createOptions)===null||e===void 0?void 0:e.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(e,r){var n,i;let o=e.delegations.map(u=>({delegation:new pe(u.delegation.pubkey,u.delegation.expiration,u.delegation.targets),signature:u.signature.buffer})),s=Re.fromDelegations(o,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=s,"toDer"in a?this._identity=Pe.fromDelegation(a,this._chain):this._identity=Ne.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=Ce.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(at,JSON.stringify(this._chain.toJSON())),r?.()}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(e){var r,n,i,o;let s=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||Ac);a.hash=Tc,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=e?.maxTimeToLive)!==null&&i!==void 0?i:s},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(o=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&o!==void 0?o:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Bc,e?.onError):setTimeout(c,vc))};c()}_getEventHandler(e,r){return async n=>{var i,o,s;if(n.origin!==e.origin){console.warn(`WARNING: expected origin '${e.origin}', got '${n.origin}' (ignoring)`);return}let a=n.data;switch(a.kind){case"authorize-ready":{let c={kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,derivationOrigin:(o=r?.derivationOrigin)===null||o===void 0?void 0:o.toString()};(s=this._idpWindow)===null||s===void 0||s.postMessage(c,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.text,r?.onError);break;default:break}}}_handleFailure(e,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(e),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(e={}){if(await wn(this._storage),this._identity=new Ot,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};async function wn(t){await t.remove(ct),await t.remove(at),await t.remove(Ao)}var xr=()=>_r.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var To=async({data:t})=>{try{return await We(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var gn=async t=>{let{data:e,updated_at:r,description:n}=t;return{description:G(n),data:await Zn(e),updated_at:G(r)}},_n=t=>{let{updated_at:e}=t;return{updated_at:G(e)}},qe=async({doc:t,key:e})=>{let{owner:r,description:n,data:i,...o}=t;return{key:e,description:z(n),owner:r.toText(),data:await We(i),...o}};var br=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:K(t)?[]:[{key:G(t.key),description:G(t.description)}],paginate:G(K(e)?void 0:{start_after:G(e.startAfter),limit:G(K(e.limit)?void 0:BigInt(e.limit))}),order:G(K(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:G(K(n)?void 0:typeof n=="string"?B.fromText(n):n)});var vo=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({controllers:t.Vec(t.Principal)}),n=t.Variant({Write:t.Null,Admin:t.Null}),i=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:n,expires_at:t.Opt(t.Nat64)}),o=t.Record({updated_at:t.Opt(t.Nat64)}),s=t.Variant({Db:t.Null,Storage:t.Null}),a=t.Record({cycles:t.Nat,destination_id:t.Principal}),c=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),u=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),l=t.Record({key:c,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,u)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64}),f=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),p=t.Record({status_code:t.Nat16,location:t.Text}),y=t.Record({iframe:t.Opt(f),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),redirects:t.Opt(t.Vec(t.Tuple(t.Text,p)))}),g=t.Record({storage:y}),w=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64}),E=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),v=t.Variant({Heap:t.Null,Stable:t.Null}),O=t.Record({memory:v,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),T=t.Variant({Callback:t.Record({token:O,callback:t.Func([],[],["query"])})}),C=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(T),status_code:t.Nat16}),x=t.Record({token:t.Opt(O),body:t.Vec(t.Nat8)}),J=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),lt=t.Record({batch_id:t.Nat}),W=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),D=t.Record({field:W,desc:t.Bool}),xt=t.Record({key:t.Opt(t.Text),description:t.Opt(t.Text)}),ut=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),bt=t.Record({order:t.Opt(D),owner:t.Opt(t.Principal),matcher:t.Opt(xt),paginate:t.Opt(ut)}),Et=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,l)),items_length:t.Nat64}),he=t.Record({updated_at:t.Nat64,created_at:t.Nat64,bn_id:t.Opt(t.Text)}),Jt=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,w)),items_length:t.Nat64}),Xt=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),vn=t.Record({memory:t.Opt(v),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:Xt,created_at:t.Nat64,mutable_permissions:t.Opt(t.Bool),write:Xt}),m=t.Record({stable:t.Nat64,heap:t.Nat64}),h=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:n,expires_at:t.Opt(t.Nat64)}),_=t.Record({controller:h,controllers:t.Vec(t.Principal)}),b=t.Record({updated_at:t.Opt(t.Nat64),data:t.Vec(t.Nat8),description:t.Opt(t.Text)}),S=t.Record({memory:t.Opt(v),updated_at:t.Opt(t.Nat64),max_size:t.Opt(t.Nat),read:Xt,mutable_permissions:t.Opt(t.Bool),write:Xt}),R=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),N=t.Record({chunk_id:t.Nat});return t.Service({build_version:t.Func([],[t.Text],["query"]),commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([r],[t.Vec(t.Tuple(t.Principal,i))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,o],[],[]),del_docs:t.Func([t.Text],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,o))],[],[]),del_rule:t.Func([s,t.Text,o],[],[]),deposit_cycles:t.Func([a],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(l)],["query"]),get_config:t.Func([],[g],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(w)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(l)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(w)))],["query"]),http_request:t.Func([E],[C],["query"]),http_request_streaming_callback:t.Func([O],[x],["query"]),init_asset_upload:t.Func([J],[lt],[]),list_assets:t.Func([t.Text,bt],[Et],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,i))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,he))],["query"]),list_docs:t.Func([t.Text,bt],[Jt],["query"]),list_rules:t.Func([s],[t.Vec(t.Tuple(t.Text,vn))],["query"]),memory_size:t.Func([],[m],["query"]),set_config:t.Func([g],[],[]),set_controllers:t.Func([_],[t.Vec(t.Tuple(t.Principal,i))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,b],[w],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,b))],[t.Vec(t.Tuple(t.Text,w))],[]),set_rule:t.Func([s,t.Text,S],[],[]),upload_asset_chunk:t.Func([R],[N],[]),version:t.Func([],[t.Text],["query"])})};var Bo=async({satelliteId:t,idlFactory:e,identity:r,fetch:n,container:i})=>{let s=j(i)&&i!==!1?i===!0?It:i:"https://icp-api.io",a=new Be({identity:r,host:s,...n&&{fetch:n}});return j(i)&&await a.fetchRootKey(),Yt.createActor(e,{agent:a,canisterId:t})};var xn=({satelliteId:t,container:e})=>{let{satelliteId:r}=bn({satelliteId:t}),{container:n}=En({container:e});if(j(n)&&n!==!1){let{host:i,protocol:o}=new URL(n===!0?It:n);return`${o}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},bn=({satelliteId:t})=>j(t)?{satelliteId:t}:pt.getInstance().get()??{satelliteId:void 0},En=({container:t})=>j(t)?{container:t}:pt.getInstance().get()??{container:void 0};var Q=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=bn({satelliteId:t});zn(n,"No satellite principal defined.");let{container:i}=En({container:e});return Bo({satelliteId:n,container:i,idlFactory:vo,...r})};var So=async({collection:t,key:e,satellite:r})=>{let n=await Q(r),i=z(await n.get_doc(t,e));if(!K(i))return qe({doc:i,key:e})},Oo=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await Q(e),n=t.map(({collection:s,key:a})=>[s,a]),i=await r(n),o=[];for(let[s,a]of i){let c=z(a);o.push(j(c)?await qe({key:s,doc:c}):void 0)}return o},Ro=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await Q(r),{key:i}=e,o=await gn(e),s=await n(t,i,o);return await qe({key:i,doc:s})},No=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await Q(e),n=[];for(let{collection:s,doc:a}of t){let{key:c}=a;n.push([s,c,await gn(a)])}let i=await r(n),o=[];for(let[s,a]of i)o.push(await qe({key:s,doc:a}));return o},Po=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await Q(r),{key:i}=e;return n(t,i,_n(e))},Co=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await Q(e),n=t.map(({collection:i,doc:o})=>[i,o.key,_n(o)]);await r(n)},Uo=async({collection:t,filter:e,satellite:r})=>{let n=await Q(r),{items:i,items_page:o,items_length:s,matches_length:a,matches_pages:c}=await n.list_docs(t,br(e)),u=[];for(let[l,f]of i){let{data:p,owner:y,description:g,...w}=f;u.push({key:l,description:z(g),owner:y.toText(),data:await To({data:p}),...w})}return{items:u,items_length:s,items_page:z(o),matches_length:a,matches_pages:z(c)}};var I=t=>t!==void 0?t:Er()??new Ot;var Fo=async({satellite:t,...e})=>{let r=I(t?.identity);return So({...e,satellite:{...t,identity:r}})},Of=async({satellite:t,...e})=>{let r=I(t?.identity);return Oo({...e,satellite:{...t,identity:r}})},ko=async({satellite:t,...e})=>{let r=I(t?.identity);return Ro({...e,satellite:{...t,identity:r}})},Rf=async({satellite:t,...e})=>{let r=I(t?.identity);return No({...e,satellite:{...t,identity:r}})},Nf=async({satellite:t,...e})=>{let r=I(t?.identity);return Po({...e,satellite:{...t,identity:r}})},Pf=async({satellite:t,...e})=>{let r=I(t?.identity);return Co({...e,satellite:{...t,identity:r}})},Cf=async({satellite:t,filter:e,...r})=>{let n=I(t?.identity);return Uo({...r,filter:e??{},satellite:{...t,identity:n}})};var qo=async t=>{let e=Er();if(K(e))throw new Error("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=await Fo({collection:"#user",key:r});return K(n)?await Sc({userId:r,provider:t}):n},Sc=async({userId:t,...e})=>ko({collection:"#user",doc:{key:t,data:e}});var _t,An=async t=>{if(_t=_t??await xr(),!(await _t?.isAuthenticated()??!1))return;let r=await qo(t);vt.getInstance().set(r)},Oc=async t=>new Promise(async(e,r)=>{_t=_t??await xr();let n=t?.provider??new Ye({});await _t.login({onSuccess:async()=>{await An(n.id),e()},onError:i=>r(i),maxTimeToLive:t?.maxTimeToLive??Jn,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),Tn=async()=>{await _t?.logout(),_t=void 0,vt.getInstance().reset()},Er=()=>_t?.getIdentity(),Rc=async()=>(_t??await xr()).getIdentity();var Ko=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{Rr({message:"junoSignOutAuthTimer"}),await Tn()};return r.onmessage=async({data:i})=>{let{msg:o,data:s}=i;switch(o){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":Rr({message:"junoDelegationRemainingTime",detail:s?.authRemainingTime});return}},vt.getInstance().subscribe(i=>{if(K(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var Vo=async({data:t,filename:e,collection:r,headers:n,token:i,fullPath:o,encoding:s,description:a,satellite:c})=>{let u=await Q(c),{batch_id:l}=await u.init_asset_upload({collection:r,full_path:o,name:e,token:G(i),encoding_type:G(s),description:G(a)}),f=19e5,p=[],y=Ge()?new Blob([await t.arrayBuffer()]):t,g=0n;for(let v=0;v<y.size;v+=f){let O=y.slice(v,v+f);p.push({batchId:l,chunk:O,actor:u,orderId:g}),g++}let w=[];for await(let v of Nc({uploadChunks:p}))w=[...w,...v];let E=n.find(([v,O])=>v.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await u.commit_asset_upload({batch_id:l,chunk_ids:w.map(({chunk_id:v})=>v),headers:[...n,...E||[]]})};async function*Nc({uploadChunks:t,limit:e=12}){for(let r=0;r<t.length;r=r+e){let n=t.slice(r,r+e);yield await Promise.all(n.map(o=>Pc(o)))}}var Pc=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:G(n)}),Mo=async({collection:t,satellite:e,filter:r})=>{let n=await Q(e),{items:i,items_length:o,items_page:s,matches_length:a,matches_pages:c}=await n.list_assets(t,br(r));return{items:i.map(([u,l])=>l),items_length:o,items_page:z(s),matches_length:a,matches_pages:z(c)}},jo=async({collection:t,fullPath:e,satellite:r})=>(await Q(r)).del_asset(t,e),Ho=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await Q(e),n=t.map(({collection:i,fullPath:o})=>[i,o]);await r(n)},$o=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await Q(r);return z(await n(t,e))},Wo=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await Q(e),n=t.map(({collection:o,fullPath:s})=>[o,s]);return(await r(n)).map(([o,s])=>z(s))};var Go=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var op=async t=>Yo(t),sp=async t=>Yo({filename:t.data.name,...t}),Yo=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:o,satellite:s,encoding:a,description:c})=>{let u=I(s?.identity),l=decodeURI(t),f=i??`/${r}/${l}`,p={...s,identity:u};return await Vo({data:e,filename:l,collection:r,token:o,headers:n,fullPath:f,encoding:a,satellite:p,description:c}),{downloadUrl:`${xn(p)}${f}${o!==void 0?`?token=${o}`:""}`,fullPath:f,name:l}},ap=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:I(e?.identity)},{items:i,...o}=await Mo({collection:t,satellite:n,filter:r??{}}),s=xn(n);return{assets:i.map(({key:{full_path:a,token:c,name:u,owner:l,description:f},headers:p,encodings:y,created_at:g,updated_at:w})=>{let E=z(c);return{fullPath:a,description:z(f),name:u,downloadUrl:`${s}${a}${E!==void 0?`?token=${E}`:""}`,token:E,headers:p,encodings:y.reduce((v,[O,{modified:T,sha256:C,total_length:x}])=>({...v,[O]:{modified:T,sha256:Go(C),total_length:x}}),{}),owner:l.toText(),created_at:g,updated_at:w}}),...o}},cp=async({collection:t,fullPath:e,satellite:r})=>jo({collection:t,fullPath:e,satellite:{...r,identity:I(r?.identity)}}),lp=async({assets:t,satellite:e})=>Ho({assets:t,satellite:{...e,identity:I(e?.identity)}}),up=async({satellite:t,...e})=>{let r=I(t?.identity);return $o({...e,satellite:{...t,identity:r}})},dp=async({satellite:t,...e})=>{let r=I(t?.identity);return Wo({...e,satellite:{...t,identity:r}})};var wp=async t=>{pt.getInstance().set(t),await An();let e=t.workers?.auth!==void 0?Ko(t.workers.auth):void 0;return[...e?[e]:[]]},gp=t=>vt.getInstance().subscribe(t);export{Ye as InternetIdentityProvider,Ln as NFIDProvider,gp as authSubscribe,cp as deleteAsset,Nf as deleteDoc,lp as deleteManyAssets,Pf as deleteManyDocs,up as getAsset,Fo as getDoc,dp as getManyAssets,Of as getManyDocs,wp as initJuno,ap as listAssets,Cf as listDocs,ko as setDoc,Rf as setManyDocs,Oc as signIn,Tn as signOut,Rc as unsafeIdentity,op as uploadBlob,sp as uploadFile};
25
25
  /*! Bundled license information:
26
26
 
27
27
  buffer/index.js: