@junobuild/core 0.0.57 → 0.0.58-next-2024-08-09

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,32 +1,32 @@
1
- import{A as Nt,B as Xr,C as Qn,D as ut,E as dt,F as In,G as Dn,H as Ln,I as ti,J as ei,K as xe,L as ri,M as be,N as ni,O as ii,Q as Zr,a as $n,b as es,c as Xe,d as Wn,e as Gn,f as zn,g as v,h as rs,i as rt,j as Yn,k as _e,l as ns,m as Ze,n as $,o as gt,p as Qe,q as Jn,r as Ie,s as Ft,t as Yr,u as Xn,v as De,w as ee,x as Zn,y as Le,z as Jr}from"./chunk-FOA6PEDK.js";var yi=$n(nr=>{"use strict";nr.byteLength=cs;nr.toByteArray=us;nr.fromByteArray=ps;var xt=[],st=[],as=typeof Uint8Array<"u"?Uint8Array:Array,en="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for($t=0,hi=en.length;$t<hi;++$t)xt[$t]=en[$t],st[en.charCodeAt($t)]=$t;var $t,hi;st[45]=62;st[95]=63;function mi(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 cs(t){var e=mi(t),r=e[0],n=e[1];return(r+n)*3/4-n}function ls(t,e,r){return(e+r)*3/4-r}function us(t){var e,r=mi(t),n=r[0],i=r[1],o=new as(ls(t,n,i)),s=0,a=i>0?n-4:n,l;for(l=0;l<a;l+=4)e=st[t.charCodeAt(l)]<<18|st[t.charCodeAt(l+1)]<<12|st[t.charCodeAt(l+2)]<<6|st[t.charCodeAt(l+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=st[t.charCodeAt(l)]<<2|st[t.charCodeAt(l+1)]>>4,o[s++]=e&255),i===1&&(e=st[t.charCodeAt(l)]<<10|st[t.charCodeAt(l+1)]<<4|st[t.charCodeAt(l+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function ds(t){return xt[t>>18&63]+xt[t>>12&63]+xt[t>>6&63]+xt[t&63]}function fs(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(ds(n));return i.join("")}function ps(t){for(var e,r=t.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(fs(t,s,s+o>a?a:s+o));return n===1?(e=t[r-1],i.push(xt[e>>2]+xt[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(xt[e>>10]+xt[e>>4&63]+xt[e<<2&63]+"=")),i.join("")}});var ki=$n(ae=>{"use strict";var rn=yi(),oe=rs(),wi=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ae.Buffer=u;ae.SlowBuffer=_s;ae.INSPECT_MAX_BYTES=50;var ir=2147483647;ae.kMaxLength=ir;u.TYPED_ARRAY_SUPPORT=hs();!u.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 hs(){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(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}});Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function Pt(t){if(t>ir)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(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 an(t)}return bi(t,e,r)}u.poolSize=8192;function bi(t,e,r){if(typeof t=="string")return ys(t,e);if(ArrayBuffer.isView(t))return ws(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(bt(t,ArrayBuffer)||t&&bt(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(bt(t,SharedArrayBuffer)||t&&bt(t.buffer,SharedArrayBuffer)))return on(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 u.from(n,e,r);let i=gs(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return u.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)}u.from=function(t,e,r){return bi(t,e,r)};Object.setPrototypeOf(u.prototype,Uint8Array.prototype);Object.setPrototypeOf(u,Uint8Array);function Ei(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 ms(t,e,r){return Ei(t),t<=0?Pt(t):e!==void 0?typeof r=="string"?Pt(t).fill(e,r):Pt(t).fill(e):Pt(t)}u.alloc=function(t,e,r){return ms(t,e,r)};function an(t){return Ei(t),Pt(t<0?0:cn(t)|0)}u.allocUnsafe=function(t){return an(t)};u.allocUnsafeSlow=function(t){return an(t)};function ys(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=Ti(t,e)|0,n=Pt(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function nn(t){let e=t.length<0?0:cn(t.length)|0,r=Pt(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function ws(t){if(bt(t,Uint8Array)){let e=new Uint8Array(t);return on(e.buffer,e.byteOffset,e.byteLength)}return nn(t)}function on(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,u.prototype),n}function gs(t){if(u.isBuffer(t)){let e=cn(t.length)|0,r=Pt(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||un(t.length)?Pt(0):nn(t);if(t.type==="Buffer"&&Array.isArray(t.data))return nn(t.data)}function cn(t){if(t>=ir)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ir.toString(16)+" bytes");return t|0}function _s(t){return+t!=t&&(t=0),u.alloc(+t)}u.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==u.prototype};u.compare=function(e,r){if(bt(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),bt(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),!u.isBuffer(e)||!u.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};u.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}};u.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return u.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=u.allocUnsafe(r),o=0;for(n=0;n<e.length;++n){let s=e[n];if(bt(s,Uint8Array))o+s.length>i.length?(u.isBuffer(s)||(s=u.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(u.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function Ti(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||bt(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 sn(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ci(t).length;default:if(i)return n?-1:sn(t).length;e=(""+e).toLowerCase(),i=!0}}u.byteLength=Ti;function xs(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 Os(this,e,r);case"utf8":case"utf-8":return vi(this,e,r);case"ascii":return Bs(this,e,r);case"latin1":case"binary":return Ns(this,e,r);case"base64":return Ss(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ps(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}u.prototype._isBuffer=!0;function Wt(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}u.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)Wt(this,r,r+1);return this};u.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)Wt(this,r,r+3),Wt(this,r+1,r+2);return this};u.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)Wt(this,r,r+7),Wt(this,r+1,r+6),Wt(this,r+2,r+5),Wt(this,r+3,r+4);return this};u.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?vi(this,0,e):xs.apply(this,arguments)};u.prototype.toLocaleString=u.prototype.toString;u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:u.compare(this,e)===0};u.prototype.inspect=function(){let e="",r=ae.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};wi&&(u.prototype[wi]=u.prototype.inspect);u.prototype.compare=function(e,r,n,i,o){if(bt(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.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,l=Math.min(s,a),d=this.slice(i,o),c=e.slice(r,n);for(let f=0;f<l;++f)if(d[f]!==c[f]){s=d[f],a=c[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,un(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=u.from(e,n)),u.isBuffer(e))return e.length===0?-1:gi(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):gi(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function gi(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 l(c,f){return o===1?c[f]:c.readUInt16BE(f*o)}let d;if(i){let c=-1;for(d=r;d<s;d++)if(l(t,d)===l(e,c===-1?0:d-c)){if(c===-1&&(c=d),d-c+1===a)return c*o}else c!==-1&&(d-=d-c),c=-1}else for(r+a>s&&(r=s-a),d=r;d>=0;d--){let c=!0;for(let f=0;f<a;f++)if(l(t,d+f)!==l(e,f)){c=!1;break}if(c)return d}return-1}u.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};u.prototype.indexOf=function(e,r,n){return Ai(this,e,r,n,!0)};u.prototype.lastIndexOf=function(e,r,n){return Ai(this,e,r,n,!1)};function bs(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(un(a))return s;t[r+s]=a}return s}function Es(t,e,r,n){return or(sn(e,t.length-r),t,r,n)}function Ts(t,e,r,n){return or(Us(e),t,r,n)}function As(t,e,r,n){return or(Ci(e),t,r,n)}function vs(t,e,r,n){return or(Ms(e,t.length-r),t,r,n)}u.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 bs(this,e,r,n);case"utf8":case"utf-8":return Es(this,e,r,n);case"ascii":case"latin1":case"binary":return Ts(this,e,r,n);case"base64":return As(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return vs(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ss(t,e,r){return e===0&&r===t.length?rn.fromByteArray(t):rn.fromByteArray(t.slice(e,r))}function vi(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 l,d,c,f;switch(a){case 1:o<128&&(s=o);break;case 2:l=t[i+1],(l&192)===128&&(f=(o&31)<<6|l&63,f>127&&(s=f));break;case 3:l=t[i+1],d=t[i+2],(l&192)===128&&(d&192)===128&&(f=(o&15)<<12|(l&63)<<6|d&63,f>2047&&(f<55296||f>57343)&&(s=f));break;case 4:l=t[i+1],d=t[i+2],c=t[i+3],(l&192)===128&&(d&192)===128&&(c&192)===128&&(f=(o&15)<<18|(l&63)<<12|(d&63)<<6|c&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 Rs(n)}var _i=4096;function Rs(t){let e=t.length;if(e<=_i)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=_i));return r}function Bs(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 Ns(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 Os(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+=Ks[t[o]];return i}function Ps(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}u.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,u.prototype),i};function G(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")}u.prototype.readUintLE=u.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||G(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return i};u.prototype.readUintBE=u.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||G(e,r,this.length);let i=this[e+--r],o=1;for(;r>0&&(o*=256);)i+=this[e+--r]*o;return i};u.prototype.readUint8=u.prototype.readUInt8=function(e,r){return e=e>>>0,r||G(e,1,this.length),this[e]};u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||G(e,2,this.length),this[e]|this[e+1]<<8};u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||G(e,2,this.length),this[e]<<8|this[e+1]};u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||G(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||G(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};u.prototype.readBigUInt64LE=Ut(function(e){e=e>>>0,se(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ee(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))});u.prototype.readBigUInt64BE=Ut(function(e){e=e>>>0,se(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ee(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)});u.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||G(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};u.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||G(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};u.prototype.readInt8=function(e,r){return e=e>>>0,r||G(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};u.prototype.readInt16LE=function(e,r){e=e>>>0,r||G(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};u.prototype.readInt16BE=function(e,r){e=e>>>0,r||G(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};u.prototype.readInt32LE=function(e,r){return e=e>>>0,r||G(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};u.prototype.readInt32BE=function(e,r){return e=e>>>0,r||G(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};u.prototype.readBigInt64LE=Ut(function(e){e=e>>>0,se(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ee(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)});u.prototype.readBigInt64BE=Ut(function(e){e=e>>>0,se(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ee(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)});u.prototype.readFloatLE=function(e,r){return e=e>>>0,r||G(e,4,this.length),oe.read(this,e,!0,23,4)};u.prototype.readFloatBE=function(e,r){return e=e>>>0,r||G(e,4,this.length),oe.read(this,e,!1,23,4)};u.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||G(e,8,this.length),oe.read(this,e,!0,52,8)};u.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||G(e,8,this.length),oe.read(this,e,!1,52,8)};function tt(t,e,r,n,i,o){if(!u.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")}u.prototype.writeUintLE=u.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;tt(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};u.prototype.writeUintBE=u.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;tt(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};u.prototype.writeUint8=u.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||tt(this,e,r,1,255,0),this[r]=e&255,r+1};u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||tt(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||tt(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||tt(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};u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||tt(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 Si(t,e,r,n,i){Pi(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 Ri(t,e,r,n,i){Pi(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}u.prototype.writeBigUInt64LE=Ut(function(e,r=0){return Si(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});u.prototype.writeBigUInt64BE=Ut(function(e,r=0){return Ri(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});u.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let l=Math.pow(2,8*n-1);tt(this,e,r,n,l-1,-l)}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};u.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let l=Math.pow(2,8*n-1);tt(this,e,r,n,l-1,-l)}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};u.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||tt(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};u.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||tt(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};u.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||tt(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};u.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||tt(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};u.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||tt(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};u.prototype.writeBigInt64LE=Ut(function(e,r=0){return Si(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});u.prototype.writeBigInt64BE=Ut(function(e,r=0){return Ri(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Bi(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 Ni(t,e,r,n,i){return e=+e,r=r>>>0,i||Bi(t,e,r,4,34028234663852886e22,-34028234663852886e22),oe.write(t,e,r,n,23,4),r+4}u.prototype.writeFloatLE=function(e,r,n){return Ni(this,e,r,!0,n)};u.prototype.writeFloatBE=function(e,r,n){return Ni(this,e,r,!1,n)};function Oi(t,e,r,n,i){return e=+e,r=r>>>0,i||Bi(t,e,r,8,17976931348623157e292,-17976931348623157e292),oe.write(t,e,r,n,52,8),r+8}u.prototype.writeDoubleLE=function(e,r,n){return Oi(this,e,r,!0,n)};u.prototype.writeDoubleBE=function(e,r,n){return Oi(this,e,r,!1,n)};u.prototype.copy=function(e,r,n,i){if(!u.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};u.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"&&!u.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=u.isBuffer(e)?e:u.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 ie={};function ln(t,e,r){ie[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}`}}}ln("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ln("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);ln("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=xi(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=xi(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function xi(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 Cs(t,e,r){se(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Ee(e,t.length-(r+1))}function Pi(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 ie.ERR_OUT_OF_RANGE("value",a,t)}Cs(n,i,o)}function se(t,e){if(typeof t!="number")throw new ie.ERR_INVALID_ARG_TYPE(e,"number",t)}function Ee(t,e,r){throw Math.floor(t)!==t?(se(t,r),new ie.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new ie.ERR_BUFFER_OUT_OF_BOUNDS:new ie.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var ks=/[^+/0-9A-Za-z-_]/g;function Fs(t){if(t=t.split("=")[0],t=t.trim().replace(ks,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function sn(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 Us(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Ms(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 Ci(t){return rn.toByteArray(Fs(t))}function or(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 bt(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function un(t){return t!==t}var Ks=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"?Vs:t}function Vs(){throw new Error("BigInt not supported")}});var K=t=>t==null,V=t=>!K(t),is=class extends Error{},tr=(t,e)=>{if(K(t))throw new is(e)},Qr="__bigint__",Ir="__principal__",Dr="__uint8array__",os=(t,e)=>typeof e=="bigint"?{[Qr]:`${e}`}:V(e)&&e instanceof v?{[Ir]:e.toText()}:V(e)&&e instanceof Uint8Array?{[Dr]:Array.from(e)}:e,ss=(t,e)=>{let r=n=>e[n];return V(e)&&typeof e=="object"&&Qr in e?BigInt(r(Qr)):V(e)&&typeof e=="object"&&Ir in e?v.fromText(r(Ir)):V(e)&&typeof e=="object"&&Dr in e?Uint8Array.from(r(Dr)):e},z=t=>V(t)?[t]:[],W=t=>t?.[0],oi=async t=>{let e=new Blob([JSON.stringify(t,os)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},er=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(),ss)},si=()=>typeof window<"u";var re=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 Ot=class t extends re{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 Lr=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var ai=BigInt(144e11),ci=!1,li={width:576,height:576},ui={width:505,height:705},di="internetcomputer.org";var ne="http://127.0.0.1:5987",fi="rdmx6-jaaaa-aaaaa-aaadq-cai";var _t=class t extends re{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 tn=({width:t,height:e})=>{if(!si()||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 rr=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=_t.getInstance().get()?.container;if(K(n)||n===!1)return`https://identity.${this.#t??di}`;let i=_t.getInstance().get(),o=V(i)&&V(i?.internetIdentityId)?i.internetIdentityId:fi,{host:s,protocol:a}=new URL(n===!0?ne:n);return/apple/i.test(navigator?.vendor)?`${a}//${s}?canisterId=${o}`:`${a}//${o}.${s.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:tn(li)},identityProvider:r()}}},pi=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:tn(ui)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};var io=Xe(ki());var sr;(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"})(sr||(sr={}));var js=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},qs=new TextEncoder().encode(`
2
- ic-request`),Ct=class{getPrincipal(){return this._principal||(this._principal=v.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=js(e,["body"]),i=await Ft(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(Ze(qs,i))}})}},kt=class{getPrincipal(){return v.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};var Fi=Xe(Xn());var Te=()=>{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 ar;(function(t){t.Call="call"})(ar||(ar={}));function ce(){let t=new ArrayBuffer(16),e=new DataView(t),r=Te(),n=Te(),i=Te(),o=Te();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,o),t}var Hs=BigInt(1e6),$s=60*1e3,Gt=class{constructor(e){let o=BigInt(Math.floor(Date.now()+e-$s))*Hs/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=o}toCBOR(){return Fi.value.u64(this._value.toString(16),16)}toHash(){return Yn(this._value)}};function dn(t=ce){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}function Ae(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}var ve=class extends rt{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};var cr=BigInt(4294967295),fn=BigInt(32);function Ui(t,e=!1){return e?{h:Number(t&cr),l:Number(t>>fn&cr)}:{h:Number(t>>fn&cr)|0,l:Number(t&cr)|0}}function Ws(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}=Ui(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]}var Gs=(t,e)=>BigInt(t>>>0)<<fn|BigInt(e>>>0),zs=(t,e,r)=>t>>>r,Ys=(t,e,r)=>t<<32-r|e>>>r,Js=(t,e,r)=>t>>>r|e<<32-r,Xs=(t,e,r)=>t<<32-r|e>>>r,Zs=(t,e,r)=>t<<64-r|e>>>r-32,Qs=(t,e,r)=>t>>>r-32|e<<64-r,Is=(t,e)=>e,Ds=(t,e)=>t,Ls=(t,e,r)=>t<<r|e>>>32-r,ta=(t,e,r)=>e<<r|t>>>32-r,ea=(t,e,r)=>e<<r-32|t>>>64-r,ra=(t,e,r)=>t<<r-32|e>>>64-r;function na(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var ia=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),oa=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,sa=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),aa=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,ca=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),la=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;var ua={fromBig:Ui,split:Ws,toBig:Gs,shrSH:zs,shrSL:Ys,rotrSH:Js,rotrSL:Xs,rotrBH:Zs,rotrBL:Qs,rotr32H:Is,rotr32L:Ds,rotlSH:Ls,rotlSL:ta,rotlBH:ea,rotlBL:ra,add:na,add3L:ia,add3H:oa,add4L:sa,add4H:aa,add5H:la,add5L:ca},T=ua;var[da,fa]=T.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))),Mt=new Uint32Array(80),Kt=new Uint32Array(80),pn=class extends zn{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:l,Eh:d,El:c,Fh:f,Fl:m,Gh:g,Gl:h,Hh:y,Hl:A}=this;return[e,r,n,i,o,s,a,l,d,c,f,m,g,h,y,A]}set(e,r,n,i,o,s,a,l,d,c,f,m,g,h,y,A){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=l|0,this.Eh=d|0,this.El=c|0,this.Fh=f|0,this.Fl=m|0,this.Gh=g|0,this.Gl=h|0,this.Hh=y|0,this.Hl=A|0}process(e,r){for(let E=0;E<16;E++,r+=4)Mt[E]=e.getUint32(r),Kt[E]=e.getUint32(r+=4);for(let E=16;E<80;E++){let U=Mt[E-15]|0,x=Kt[E-15]|0,D=T.rotrSH(U,x,1)^T.rotrSH(U,x,8)^T.shrSH(U,x,7),it=T.rotrSL(U,x,1)^T.rotrSL(U,x,8)^T.shrSL(U,x,7),j=Mt[E-2]|0,Y=Kt[E-2]|0,et=T.rotrSH(j,Y,19)^T.rotrBH(j,Y,61)^T.shrSH(j,Y,6),ot=T.rotrSL(j,Y,19)^T.rotrBL(j,Y,61)^T.shrSL(j,Y,6),yt=T.add4L(it,ot,Kt[E-7],Kt[E-16]),ct=T.add4H(yt,D,et,Mt[E-7],Mt[E-16]);Mt[E]=ct|0,Kt[E]=yt|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:l,Dh:d,Dl:c,Eh:f,El:m,Fh:g,Fl:h,Gh:y,Gl:A,Hh:R,Hl:F}=this;for(let E=0;E<80;E++){let U=T.rotrSH(f,m,14)^T.rotrSH(f,m,18)^T.rotrBH(f,m,41),x=T.rotrSL(f,m,14)^T.rotrSL(f,m,18)^T.rotrBL(f,m,41),D=f&g^~f&y,it=m&h^~m&A,j=T.add5L(F,x,it,fa[E],Kt[E]),Y=T.add5H(j,R,U,D,da[E],Mt[E]),et=j|0,ot=T.rotrSH(n,i,28)^T.rotrBH(n,i,34)^T.rotrBH(n,i,39),yt=T.rotrSL(n,i,28)^T.rotrBL(n,i,34)^T.rotrBL(n,i,39),ct=n&o^n&a^o&a,Ht=i&s^i&l^s&l;R=y|0,F=A|0,y=g|0,A=h|0,g=f|0,h=m|0,{h:f,l:m}=T.add(d|0,c|0,Y|0,et|0),d=a|0,c=l|0,a=o|0,l=s|0,o=n|0,s=i|0;let Bt=T.add3L(et,yt,Ht);n=T.add3H(Bt,Y,ot,ct),i=Bt|0}({h:n,l:i}=T.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=T.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l}=T.add(this.Ch|0,this.Cl|0,a|0,l|0),{h:d,l:c}=T.add(this.Dh|0,this.Dl|0,d|0,c|0),{h:f,l:m}=T.add(this.Eh|0,this.El|0,f|0,m|0),{h:g,l:h}=T.add(this.Fh|0,this.Fl|0,g|0,h|0),{h:y,l:A}=T.add(this.Gh|0,this.Gl|0,y|0,A|0),{h:R,l:F}=T.add(this.Hh|0,this.Hl|0,R|0,F|0),this.set(n,i,o,s,a,l,d,c,f,m,g,h,y,A,R,F)}roundClean(){Mt.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 Mi=Wn(()=>new pn);var ft=BigInt(0),nt=BigInt(1),lr=BigInt(2),pa=BigInt(8),ha={zip215:!0};function ma(t){let e=ti(t);return Qn(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Ki(t){let e=ma(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:l}=e,d=lr<<BigInt(a*8)-nt,c=r.create,f=e.uvRatio||((w,p)=>{try{return{isValid:!0,value:r.sqrt(w*r.inv(p))}}catch{return{isValid:!1,value:ft}}}),m=e.adjustScalarBytes||(w=>w),g=e.domain||((w,p,_)=>{if(p.length||_)throw new Error("Contexts/pre-hash are not supported");return w}),h=w=>typeof w=="bigint"&&ft<w,y=(w,p)=>h(w)&&h(p)&&w<p,A=w=>w===ft||y(w,d);function R(w,p){if(y(w,p))return w;throw new Error(`Expected valid scalar < ${p}, got ${typeof w} ${w}`)}function F(w){return w===ft?w:R(w,n)}let E=new Map;function U(w){if(!(w instanceof x))throw new Error("ExtendedPoint expected")}class x{constructor(p,_,b,B){if(this.ex=p,this.ey=_,this.ez=b,this.et=B,!A(p))throw new Error("x required");if(!A(_))throw new Error("y required");if(!A(b))throw new Error("z required");if(!A(B))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(!A(_)||!A(b))throw new Error("invalid affine point");return new x(_,b,nt,c(_*b))}static normalizeZ(p){let _=r.invertBatch(p.map(b=>b.ez));return p.map((b,B)=>b.toAffine(_[B])).map(x.fromAffine)}_setWindowSize(p){this._WINDOW_SIZE=p,E.delete(this)}assertValidity(){let{a:p,d:_}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:b,ey:B,ez:N,et:P}=this,C=c(b*b),O=c(B*B),k=c(N*N),M=c(k*k),q=c(C*p),L=c(k*c(q+O)),H=c(M+c(_*c(C*O)));if(L!==H)throw new Error("bad point: equation left != right (1)");let wt=c(b*B),lt=c(N*P);if(wt!==lt)throw new Error("bad point: equation left != right (2)")}equals(p){U(p);let{ex:_,ey:b,ez:B}=this,{ex:N,ey:P,ez:C}=p,O=c(_*C),k=c(N*B),M=c(b*C),q=c(P*B);return O===k&&M===q}is0(){return this.equals(x.ZERO)}negate(){return new x(c(-this.ex),this.ey,this.ez,c(-this.et))}double(){let{a:p}=e,{ex:_,ey:b,ez:B}=this,N=c(_*_),P=c(b*b),C=c(lr*c(B*B)),O=c(p*N),k=_+b,M=c(c(k*k)-N-P),q=O+P,L=q-C,H=O-P,wt=c(M*L),lt=c(q*H),Lt=c(M*H),te=c(L*q);return new x(wt,lt,te,Lt)}add(p){U(p);let{a:_,d:b}=e,{ex:B,ey:N,ez:P,et:C}=this,{ex:O,ey:k,ez:M,et:q}=p;if(_===BigInt(-1)){let ze=c((N-B)*(k+O)),Ye=c((N+B)*(k-O)),ge=c(Ye-ze);if(ge===ft)return this.double();let Je=c(P*lr*q),Vn=c(C*lr*M),jn=Vn+Je,qn=Ye+ze,Hn=Vn-Je,Io=c(jn*ge),Do=c(qn*Hn),Lo=c(jn*Hn),ts=c(ge*qn);return new x(Io,Do,ts,Lo)}let L=c(B*O),H=c(N*k),wt=c(C*b*q),lt=c(P*M),Lt=c((B+N)*(O+k)-L-H),te=lt-wt,We=lt+wt,Ge=c(H-_*L),$r=c(Lt*te),Wr=c(We*Ge),Gr=c(Lt*Ge),zr=c(te*We);return new x($r,Wr,zr,Gr)}subtract(p){return this.add(p.negate())}wNAF(p){return j.wNAFCached(this,E,p,x.normalizeZ)}multiply(p){let{p:_,f:b}=this.wNAF(R(p,n));return x.normalizeZ([_,b])[0]}multiplyUnsafe(p){let _=F(p);return _===ft?it:this.equals(it)||_===nt?this:this.equals(D)?this.wNAF(_).p:j.unsafeLadder(this,_)}isSmallOrder(){return this.multiplyUnsafe(l).is0()}isTorsionFree(){return j.unsafeLadder(this,n).is0()}toAffine(p){let{ex:_,ey:b,ez:B}=this,N=this.is0();p==null&&(p=N?pa:r.inv(B));let P=c(_*p),C=c(b*p),O=c(B*p);if(N)return{x:ft,y:nt};if(O!==nt)throw new Error("invZ was invalid");return{x:P,y:C}}clearCofactor(){let{h:p}=e;return p===nt?this:this.multiplyUnsafe(p)}static fromHex(p,_=!1){let{d:b,a:B}=e,N=r.BYTES;p=Nt("pointHex",p,N);let P=p.slice(),C=p[N-1];P[N-1]=C&-129;let O=Le(P);O===ft||(_?R(O,d):R(O,r.ORDER));let k=c(O*O),M=c(k-nt),q=c(b*k-B),{isValid:L,value:H}=f(M,q);if(!L)throw new Error("Point.fromHex: invalid y coordinate");let wt=(H&nt)===nt,lt=(C&128)!==0;if(!_&&H===ft&&lt)throw new Error("Point.fromHex: x=0 and x_0=1");return lt!==wt&&(H=c(-H)),x.fromAffine({x:H,y:O})}static fromPrivateKey(p){return ot(p).point}toRawBytes(){let{x:p,y:_}=this.toAffine(),b=Jr(_,r.BYTES);return b[b.length-1]|=p&nt?128:0,b}toHex(){return Zn(this.toRawBytes())}}x.BASE=new x(e.Gx,e.Gy,nt,c(e.Gx*e.Gy)),x.ZERO=new x(ft,nt,nt,ft);let{BASE:D,ZERO:it}=x,j=Ln(x,a*8);function Y(w){return ut(w,n)}function et(w){return Y(Le(w))}function ot(w){let p=a;w=Nt("private key",w,p);let _=Nt("hashed private key",o(w),2*p),b=m(_.slice(0,p)),B=_.slice(p,2*p),N=et(b),P=D.multiply(N),C=P.toRawBytes();return{head:b,prefix:B,scalar:N,point:P,pointBytes:C}}function yt(w){return ot(w).pointBytes}function ct(w=new Uint8Array,...p){let _=Xr(...p);return et(o(g(_,Nt("context",w),!!i)))}function Ht(w,p,_={}){w=Nt("message",w),i&&(w=i(w));let{prefix:b,scalar:B,pointBytes:N}=ot(p),P=ct(_.context,b,w),C=D.multiply(P).toRawBytes(),O=ct(_.context,C,N,w),k=Y(P+O*B);F(k);let M=Xr(C,Jr(k,r.BYTES));return Nt("result",M,a*2)}let Bt=ha;function Dt(w,p,_,b=Bt){let{context:B,zip215:N}=b,P=r.BYTES;w=Nt("signature",w,2*P),p=Nt("message",p),i&&(p=i(p));let C=Le(w.slice(P,2*P)),O,k,M;try{O=x.fromHex(_,N),k=x.fromHex(w.slice(0,P),N),M=D.multiplyUnsafe(C)}catch{return!1}if(!N&&O.isSmallOrder())return!1;let q=ct(B,k.toRawBytes(),O.toRawBytes(),p);return k.add(O.multiplyUnsafe(q)).subtract(M).clearCofactor().equals(x.ZERO)}return D._setWindowSize(8),{CURVE:e,getPublicKey:yt,sign:Ht,verify:Dt,ExtendedPoint:x,utils:{getExtendedPublicKey:ot,randomPrivateKey:()=>s(r.BYTES),precompute(w=8,p=x.BASE){return p._setWindowSize(w),p.multiply(BigInt(3)),p}}}}var hn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Vi=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),bl=BigInt(0),ya=BigInt(1),ji=BigInt(2),El=BigInt(3),wa=BigInt(5),ga=BigInt(8);function _a(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),o=hn,a=t*t%o*t%o,l=dt(a,ji,o)*a%o,d=dt(l,ya,o)*t%o,c=dt(d,wa,o)*d%o,f=dt(c,e,o)*c%o,m=dt(f,r,o)*f%o,g=dt(m,n,o)*m%o,h=dt(g,i,o)*g%o,y=dt(h,i,o)*g%o,A=dt(y,e,o)*c%o;return{pow_p_5_8:dt(A,ji,o)*t%o,b2:a}}function xa(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function ba(t,e){let r=hn,n=ut(e*e*e,r),i=ut(n*n*e,r),o=_a(t*i).pow_p_5_8,s=ut(t*n*o,r),a=ut(e*s*s,r),l=s,d=ut(s*Vi,r),c=a===t,f=a===ut(-t,r),m=a===ut(-t*Vi,r);return c&&(s=l),(f||m)&&(s=d),In(s,r)&&(s=ut(-s,r)),{isValid:c||f,value:s}}var Ea=Dn(hn,void 0,!0),Ta={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ea,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:ga,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Mi,randomBytes:Gn,adjustScalarBytes:xa,uvRatio:ba},Vt=Ki(Ta);var qi=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},Q=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)},J,Se,Hi,$i,ur=class{constructor(e={}){J.set(this,void 0),Se.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();qi(this,J,new Map([...r].map(([o,s])=>[o,{value:s,timestamp:i}])),"f"),qi(this,Se,n,"f")}prune(){let e=Date.now();for(let[r,n]of Q(this,J,"f").entries())e-n.timestamp>Q(this,Se,"f")&&Q(this,J,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return Q(this,J,"f").set(e,n),this}get(e){let r=Q(this,J,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>Q(this,Se,"f")){Q(this,J,"f").delete(e);return}return r.value}}clear(){Q(this,J,"f").clear()}entries(){let e=Q(this,J,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=Q(this,J,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return Q(this,J,"f").keys()}forEach(e,r){for(let[n,i]of Q(this,J,"f").entries())e.call(r,i.value,n,this)}has(e){return Q(this,J,"f").has(e)}delete(e){return Q(this,J,"f").delete(e)}get size(){return Q(this,J,"f").size}};J=new WeakMap,Se=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)")},mn=(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)")},Aa=(t,e)=>{let r=mn(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)")},zi=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),zt=Uint8Array.from([48,5,6,3,43,101,112]),Sl=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function le(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 Re=(t,e)=>{let r=0,n=(a,l)=>{if(i[r++]!==a)throw new Error("Expected: "+l)},i=new Uint8Array(t);if(n(48,"sequence"),r+=mn(i,r),!Qe(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let o=Aa(i,r)-1;r+=mn(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 Yi=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},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)},dr,fr,Be=class t{constructor(e){if(dr.set(this,void 0),fr.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Yi(this,dr,e,"f"),Yi(this,fr,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 le(e,zt).buffer}static derDecode(e){let r=Re(e,zt);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Ji(this,dr,"f")}get derKey(){return Ji(this,fr,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};dr=new WeakMap,fr=new WeakMap;Be.RAW_KEY_LENGTH=32;var yn=class{constructor(){this.observers=[]}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e,...r){this.observers.forEach(n=>n(e,...r))}},pr=class extends yn{constructor(){super()}print(e,...r){this.notify({message:e,level:"info"},...r)}warn(e,...r){this.notify({message:e,level:"warn"},...r)}error(e,r,...n){this.notify({message:e,level:"error",error:r},...n)}};var Et=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)},Tt,hr,mr,yr,wr,gr,_r,xr,ue;var Ne=class t{constructor(e=t.default){Tt.set(this,void 0),hr.set(this,void 0),mr.set(this,void 0),yr.set(this,void 0),wr.set(this,void 0),gr.set(this,void 0),_r.set(this,void 0),xr.set(this,void 0),ue.set(this,0);let{initialInterval:r=500,randomizationFactor:n=.5,multiplier:i=1.5,maxInterval:o=6e4,maxElapsedTime:s=9e5,maxIterations:a=10,date:l=Date}=e;Et(this,Tt,r,"f"),Et(this,hr,n,"f"),Et(this,mr,i,"f"),Et(this,yr,o,"f"),Et(this,xr,l,"f"),Et(this,wr,l.now(),"f"),Et(this,gr,s,"f"),Et(this,_r,a,"f")}get ellapsedTimeInMsec(){return X(this,xr,"f").now()-X(this,wr,"f")}get currentInterval(){return X(this,Tt,"f")}get count(){return X(this,ue,"f")}get randomValueFromInterval(){let e=X(this,hr,"f")*X(this,Tt,"f"),r=X(this,Tt,"f")-e,n=X(this,Tt,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return Et(this,Tt,Math.min(X(this,Tt,"f")*X(this,mr,"f"),X(this,yr,"f")),"f"),Et(this,ue,(e=X(this,ue,"f"),e++,e),"f"),X(this,Tt,"f")}next(){return this.ellapsedTimeInMsec>=X(this,gr,"f")||X(this,ue,"f")>=X(this,_r,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Tt=new WeakMap,hr=new WeakMap,mr=new WeakMap,yr=new WeakMap,wr=new WeakMap,gr=new WeakMap,_r=new WeakMap,xr=new WeakMap,ue=new WeakMap;Ne.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date};var br=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},S=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)},At,pt,Yt,Tr,de,fe,Jt,Xt,Xi,Ar,vr,vt;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(vt||(vt={}));var Er=5*60*1e3,Sa="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";var Ra="ic0.app",Ba=".ic0.app",Na="icp0.io",Oa=".icp0.io",Pa="icp-api.io",Ca=".icp-api.io",Oe=class extends rt{constructor(e){super(e),this.message=e}},pe=class extends rt{constructor(e){super(e),this.message=e}};function ka(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new Oe("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 Oe("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 Oe("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var Pe=class t{constructor(e={}){var r;if(At.add(this),this.rootKey=gt(Sa),this._timeDiffMsecs=0,this._rootKeyFetched=!1,pt.set(this,void 0),Yt.set(this,void 0),this._isAgent=!0,Tr.set(this,0),this.log=new pr,de.set(this,[]),fe.set(this,[]),Jt.set(this,new ur({expirationTime:5*60*1e3})),Xt.set(this,!0),vr.set(this,(i,o)=>{if(S(this,Xt,"f")===!1)return i;if(!o)throw new xe("Invalid signature from replica signed query: no matching node key found.");let{status:s,signatures:a=[],requestId:l}=i,d=new TextEncoder().encode("\vic-response");for(let c of a){let{timestamp:f,identity:m}=c,g=v.fromUint8Array(m).toText(),h;if(s==="replied"){let{reply:E}=i;h=Yr({status:s,reply:E,timestamp:BigInt(f),request_id:l})}else if(s==="rejected"){let{reject_code:E,reject_message:U,error_code:x}=i;h=Yr({status:s,reject_code:E,reject_message:U,error_code:x,timestamp:BigInt(f),request_id:l})}else throw new Error(`Unknown status: ${s}`);let y=Ze(d,new Uint8Array(h)),A=o?.nodeKeys.get(g);if(!A)throw new xe("Invalid signature from replica signed query: no matching node key found.");let R=Be.fromDer(A).rawKey;if(Vt.verify(c.signature,new Uint8Array(y),new Uint8Array(R)))return i;throw new xe(`Invalid signature from replica ${g} signed query.`)}return i}),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||ka()||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 i=typeof window<"u"?window.location:void 0;i||(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 o=["ic0.app","icp0.io","127.0.0.1","localhost"],s=[".github.dev",".gitpod.io"],a=i?.hostname,l;a&&typeof a=="string"&&(s.some(d=>a.endsWith(d))?l=a:l=o.find(d=>a.endsWith(d))),i&&l?this._host=new URL(`${i.protocol}//${l}${i.port?":"+i.port:""}`):(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."))}e.verifyQuerySignatures!==void 0&&br(this,Xt,e.verifyQuerySignatures,"f"),br(this,pt,(r=e.retryTimes)!==null&&r!==void 0?r:3,"f");let n=()=>new Ne({maxIterations:S(this,pt,"f")});if(br(this,Yt,e.backoffStrategy||n,"f"),this._host.hostname.endsWith(Ba)?this._host.hostname=Ra:this._host.hostname.endsWith(Oa)?this._host.hostname=Na:this._host.hostname.endsWith(Ca)&&(this._host.hostname=Pa),e.credentials){let{name:i,password:o}=e.credentials;this._credentials=`${i}${o?":"+o:""}`}this._identity=Promise.resolve(e.identity||new kt),this.addTransform("update",dn(ce)),e.useQueryNonces&&this.addTransform("query",dn(ce)),e.logToConsole&&this.log.subscribe(i=>{i.level==="error"?console.error(i.message):i.level==="warn"?console.warn(i.message):console.log(i.message)})}get waterMark(){return S(this,Tr,"f")}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=S(this,fe,"f").findIndex(o=>(o.priority||0)<n);S(this,fe,"f").splice(i>=0?i:S(this,fe,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=S(this,de,"f").findIndex(o=>(o.priority||0)<n);S(this,de,"f").splice(i>=0?i:S(this,de,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!this._identity)throw new pe("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 pe("This identity has expired due this application's security policy. Please refresh your authentication.");let o=v.from(e),s=r.effectiveCanisterId?v.from(r.effectiveCanisterId):o,a=i.getPrincipal()||v.anonymous(),l=new Gt(Er);Math.abs(this._timeDiffMsecs)>1e3*30&&(l=new Gt(Er+this._timeDiffMsecs));let d={request_type:ar.Call,canister_id:o,method_name:r.methodName,arg:r.arg,sender:a,ingress_expiry:l},c=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:d});c=await i.transformRequest(c);let f=De(c.body);this.log.print(`fetching "/api/v2/canister/${s.toText()}/call" with request:`,c);let m=S(this,Yt,"f").call(this),g=S(this,At,"m",Ar).call(this,{request:()=>this._fetch(""+new URL(`/api/v2/canister/${s.toText()}/call`,this._host),Object.assign(Object.assign(Object.assign({},this._callOptions),c.request),{body:f})),backoff:m,tries:0}),[h,y]=await Promise.all([g,Ft(d)]),A=await h.arrayBuffer(),R=h.status===200&&A.byteLength>0?ee(A):null;return{requestId:y,response:{ok:h.ok,status:h.status,statusText:h.statusText,body:R,headers:Ae(h.headers)}}}async query(e,r,n){let i=S(this,Yt,"f").call(this),o=r.effectiveCanisterId?v.from(r.effectiveCanisterId):v.from(e);this.log.print(`ecid ${o.toString()}`),this.log.print(`canisterId ${e.toString()}`);let s=async()=>{let c=await(n!==void 0?await n:await this._identity);if(!c)throw new pe("This identity has expired due this application's security policy. Please refresh your authentication.");let f=v.from(e),m=c?.getPrincipal()||v.anonymous(),g={request_type:"query",canister_id:f,method_name:r.methodName,arg:r.arg,sender:m,ingress_expiry:new Gt(Er)},h=await Ft(g),y=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read",body:g});y=await c?.transformRequest(y);let A=De(y.body),R={canister:f.toText(),ecid:o,transformedRequest:y,body:A,requestId:h,backoff:i,tries:0};return await S(this,At,"m",Xi).call(this,R)},a=async()=>{if(!S(this,Xt,"f"))return;let c=S(this,Jt,"f").get(o.toString());return c||(await this.fetchSubnetKeys(o.toString()),S(this,Jt,"f").get(o.toString()))},[l,d]=await Promise.all([s(),a()]);if(this.log.print("Query response:",l),!S(this,Xt,"f"))return l;try{return S(this,vr,"f").call(this,l,d)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),S(this,Jt,"f").delete(e.toString()),await this.fetchSubnetKeys(o.toString());let f=S(this,Jt,"f").get(e.toString());if(!f)throw new xe("Invalid signature from replica signed query: no matching node key found.");return S(this,vr,"f").call(this,l,f)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await this._identity);if(!n)throw new pe("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||v.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 Gt(Er)}});return n?.transformRequest(o)}async readState(e,r,n,i){let o=typeof e=="string"?v.fromText(e):e,s=i??await this.createReadStateRequest(r,n),a=De(s.body);this.log.print(`fetching "/api/v2/canister/${o}/read_state" with request:`,s);let l=S(this,Yt,"f").call(this),d=await S(this,At,"m",Ar).call(this,{request:()=>this._fetch(""+new URL(`/api/v2/canister/${o.toString()}/read_state`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),s.request),{body:a})),backoff:l,tries:0});if(!d.ok)throw new Error(`Server returned an error:
1
+ import{A as Ct,B as en,C as ni,D as dt,E as ft,F as ii,G as oi,H as si,I as ai,J as ci,K as Se,L as li,M as Re,N as ui,O as di,Q as rn,a as Zn,b as ls,c as er,d as Qn,e as In,f as Dn,g as S,h as us,i as et,j as Ln,k as ve,l as ds,m as rr,n as G,o as xt,p as nr,q as ti,r as ir,s as Kt,t as Lr,u as ei,v as or,w as oe,x as ri,y as sr,z as tn}from"./chunk-FOA6PEDK.js";var Ti=Zn(ur=>{"use strict";ur.byteLength=ys;ur.toByteArray=gs;ur.fromByteArray=bs;var Et=[],at=[],ms=typeof Uint8Array<"u"?Uint8Array:Array,ln="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(zt=0,bi=ln.length;zt<bi;++zt)Et[zt]=ln[zt],at[ln.charCodeAt(zt)]=zt;var zt,bi;at[45]=62;at[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 ys(t){var e=Ei(t),r=e[0],n=e[1];return(r+n)*3/4-n}function ws(t,e,r){return(e+r)*3/4-r}function gs(t){var e,r=Ei(t),n=r[0],i=r[1],o=new ms(ws(t,n,i)),s=0,a=i>0?n-4:n,l;for(l=0;l<a;l+=4)e=at[t.charCodeAt(l)]<<18|at[t.charCodeAt(l+1)]<<12|at[t.charCodeAt(l+2)]<<6|at[t.charCodeAt(l+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=at[t.charCodeAt(l)]<<2|at[t.charCodeAt(l+1)]>>4,o[s++]=e&255),i===1&&(e=at[t.charCodeAt(l)]<<10|at[t.charCodeAt(l+1)]<<4|at[t.charCodeAt(l+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function _s(t){return Et[t>>18&63]+Et[t>>12&63]+Et[t>>6&63]+Et[t&63]}function xs(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(_s(n));return i.join("")}function bs(t){for(var e,r=t.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(xs(t,s,s+o>a?a:s+o));return n===1?(e=t[r-1],i.push(Et[e>>2]+Et[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(Et[e>>10]+Et[e>>4&63]+Et[e<<2&63]+"=")),i.join("")}});var qi=Zn(de=>{"use strict";var un=Ti(),le=us(),Ai=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;de.Buffer=u;de.SlowBuffer=Rs;de.INSPECT_MAX_BYTES=50;var dr=2147483647;de.kMaxLength=dr;u.TYPED_ARRAY_SUPPORT=Es();!u.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 Es(){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(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}});Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function Ft(t){if(t>dr)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(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 hn(t)}return Oi(t,e,r)}u.poolSize=8192;function Oi(t,e,r){if(typeof t=="string")return As(t,e);if(ArrayBuffer.isView(t))return vs(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(Tt(t,ArrayBuffer)||t&&Tt(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Tt(t,SharedArrayBuffer)||t&&Tt(t.buffer,SharedArrayBuffer)))return fn(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 u.from(n,e,r);let i=Ss(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return u.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)}u.from=function(t,e,r){return Oi(t,e,r)};Object.setPrototypeOf(u.prototype,Uint8Array.prototype);Object.setPrototypeOf(u,Uint8Array);function Ni(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 Ts(t,e,r){return Ni(t),t<=0?Ft(t):e!==void 0?typeof r=="string"?Ft(t).fill(e,r):Ft(t).fill(e):Ft(t)}u.alloc=function(t,e,r){return Ts(t,e,r)};function hn(t){return Ni(t),Ft(t<0?0:mn(t)|0)}u.allocUnsafe=function(t){return hn(t)};u.allocUnsafeSlow=function(t){return hn(t)};function As(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=Bi(t,e)|0,n=Ft(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function dn(t){let e=t.length<0?0:mn(t.length)|0,r=Ft(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function vs(t){if(Tt(t,Uint8Array)){let e=new Uint8Array(t);return fn(e.buffer,e.byteOffset,e.byteLength)}return dn(t)}function fn(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,u.prototype),n}function Ss(t){if(u.isBuffer(t)){let e=mn(t.length)|0,r=Ft(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||wn(t.length)?Ft(0):dn(t);if(t.type==="Buffer"&&Array.isArray(t.data))return dn(t.data)}function mn(t){if(t>=dr)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+dr.toString(16)+" bytes");return t|0}function Rs(t){return+t!=t&&(t=0),u.alloc(+t)}u.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==u.prototype};u.compare=function(e,r){if(Tt(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),Tt(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),!u.isBuffer(e)||!u.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};u.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}};u.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return u.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=u.allocUnsafe(r),o=0;for(n=0;n<e.length;++n){let s=e[n];if(Tt(s,Uint8Array))o+s.length>i.length?(u.isBuffer(s)||(s=u.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(u.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function Bi(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Tt(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 pn(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return ji(t).length;default:if(i)return n?-1:pn(t).length;e=(""+e).toLowerCase(),i=!0}}u.byteLength=Bi;function Os(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 Ms(this,e,r);case"latin1":case"binary":return Ks(this,e,r);case"base64":return Fs(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return js(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}u.prototype._isBuffer=!0;function Yt(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}u.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)Yt(this,r,r+1);return this};u.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)Yt(this,r,r+3),Yt(this,r+1,r+2);return this};u.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)Yt(this,r,r+7),Yt(this,r+1,r+6),Yt(this,r+2,r+5),Yt(this,r+3,r+4);return this};u.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Ci(this,0,e):Os.apply(this,arguments)};u.prototype.toLocaleString=u.prototype.toString;u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:u.compare(this,e)===0};u.prototype.inspect=function(){let e="",r=de.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};Ai&&(u.prototype[Ai]=u.prototype.inspect);u.prototype.compare=function(e,r,n,i,o){if(Tt(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.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,l=Math.min(s,a),d=this.slice(i,o),c=e.slice(r,n);for(let f=0;f<l;++f)if(d[f]!==c[f]){s=d[f],a=c[f];break}return s<a?-1:a<s?1:0};function Pi(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,wn(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=u.from(e,n)),u.isBuffer(e))return e.length===0?-1:vi(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):vi(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function vi(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 l(c,f){return o===1?c[f]:c.readUInt16BE(f*o)}let d;if(i){let c=-1;for(d=r;d<s;d++)if(l(t,d)===l(e,c===-1?0:d-c)){if(c===-1&&(c=d),d-c+1===a)return c*o}else c!==-1&&(d-=d-c),c=-1}else for(r+a>s&&(r=s-a),d=r;d>=0;d--){let c=!0;for(let f=0;f<a;f++)if(l(t,d+f)!==l(e,f)){c=!1;break}if(c)return d}return-1}u.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};u.prototype.indexOf=function(e,r,n){return Pi(this,e,r,n,!0)};u.prototype.lastIndexOf=function(e,r,n){return Pi(this,e,r,n,!1)};function Ns(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(wn(a))return s;t[r+s]=a}return s}function Bs(t,e,r,n){return fr(pn(e,t.length-r),t,r,n)}function Ps(t,e,r,n){return fr($s(e),t,r,n)}function Cs(t,e,r,n){return fr(ji(e),t,r,n)}function ks(t,e,r,n){return fr(Gs(e,t.length-r),t,r,n)}u.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 Ns(this,e,r,n);case"utf8":case"utf-8":return Bs(this,e,r,n);case"ascii":case"latin1":case"binary":return Ps(this,e,r,n);case"base64":return Cs(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ks(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Fs(t,e,r){return e===0&&r===t.length?un.fromByteArray(t):un.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 l,d,c,f;switch(a){case 1:o<128&&(s=o);break;case 2:l=t[i+1],(l&192)===128&&(f=(o&31)<<6|l&63,f>127&&(s=f));break;case 3:l=t[i+1],d=t[i+2],(l&192)===128&&(d&192)===128&&(f=(o&15)<<12|(l&63)<<6|d&63,f>2047&&(f<55296||f>57343)&&(s=f));break;case 4:l=t[i+1],d=t[i+2],c=t[i+3],(l&192)===128&&(d&192)===128&&(c&192)===128&&(f=(o&15)<<18|(l&63)<<12|(d&63)<<6|c&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 Us(n)}var Si=4096;function Us(t){let e=t.length;if(e<=Si)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Si));return r}function Ms(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 Ks(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+=zs[t[o]];return i}function js(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}u.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,u.prototype),i};function Y(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")}u.prototype.readUintLE=u.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Y(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return i};u.prototype.readUintBE=u.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||Y(e,r,this.length);let i=this[e+--r],o=1;for(;r>0&&(o*=256);)i+=this[e+--r]*o;return i};u.prototype.readUint8=u.prototype.readUInt8=function(e,r){return e=e>>>0,r||Y(e,1,this.length),this[e]};u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||Y(e,2,this.length),this[e]|this[e+1]<<8};u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||Y(e,2,this.length),this[e]<<8|this[e+1]};u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||Y(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||Y(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};u.prototype.readBigUInt64LE=Vt(function(e){e=e>>>0,ue(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Oe(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))});u.prototype.readBigUInt64BE=Vt(function(e){e=e>>>0,ue(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Oe(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)});u.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Y(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};u.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||Y(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};u.prototype.readInt8=function(e,r){return e=e>>>0,r||Y(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};u.prototype.readInt16LE=function(e,r){e=e>>>0,r||Y(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};u.prototype.readInt16BE=function(e,r){e=e>>>0,r||Y(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};u.prototype.readInt32LE=function(e,r){return e=e>>>0,r||Y(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};u.prototype.readInt32BE=function(e,r){return e=e>>>0,r||Y(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};u.prototype.readBigInt64LE=Vt(function(e){e=e>>>0,ue(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Oe(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)});u.prototype.readBigInt64BE=Vt(function(e){e=e>>>0,ue(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Oe(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)});u.prototype.readFloatLE=function(e,r){return e=e>>>0,r||Y(e,4,this.length),le.read(this,e,!0,23,4)};u.prototype.readFloatBE=function(e,r){return e=e>>>0,r||Y(e,4,this.length),le.read(this,e,!1,23,4)};u.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||Y(e,8,this.length),le.read(this,e,!0,52,8)};u.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||Y(e,8,this.length),le.read(this,e,!1,52,8)};function rt(t,e,r,n,i,o){if(!u.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")}u.prototype.writeUintLE=u.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;rt(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};u.prototype.writeUintBE=u.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;rt(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};u.prototype.writeUint8=u.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||rt(this,e,r,1,255,0),this[r]=e&255,r+1};u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||rt(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||rt(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||rt(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};u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||rt(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 ki(t,e,r,n,i){Vi(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 Fi(t,e,r,n,i){Vi(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}u.prototype.writeBigUInt64LE=Vt(function(e,r=0){return ki(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});u.prototype.writeBigUInt64BE=Vt(function(e,r=0){return Fi(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});u.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let l=Math.pow(2,8*n-1);rt(this,e,r,n,l-1,-l)}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};u.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let l=Math.pow(2,8*n-1);rt(this,e,r,n,l-1,-l)}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};u.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||rt(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};u.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||rt(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};u.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||rt(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};u.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||rt(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};u.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||rt(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};u.prototype.writeBigInt64LE=Vt(function(e,r=0){return ki(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});u.prototype.writeBigInt64BE=Vt(function(e,r=0){return Fi(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Ui(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 Mi(t,e,r,n,i){return e=+e,r=r>>>0,i||Ui(t,e,r,4,34028234663852886e22,-34028234663852886e22),le.write(t,e,r,n,23,4),r+4}u.prototype.writeFloatLE=function(e,r,n){return Mi(this,e,r,!0,n)};u.prototype.writeFloatBE=function(e,r,n){return Mi(this,e,r,!1,n)};function Ki(t,e,r,n,i){return e=+e,r=r>>>0,i||Ui(t,e,r,8,17976931348623157e292,-17976931348623157e292),le.write(t,e,r,n,52,8),r+8}u.prototype.writeDoubleLE=function(e,r,n){return Ki(this,e,r,!0,n)};u.prototype.writeDoubleBE=function(e,r,n){return Ki(this,e,r,!1,n)};u.prototype.copy=function(e,r,n,i){if(!u.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};u.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"&&!u.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=u.isBuffer(e)?e:u.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 ce={};function yn(t,e,r){ce[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}`}}}yn("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);yn("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);yn("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=Ri(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Ri(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Ri(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 qs(t,e,r){ue(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Oe(e,t.length-(r+1))}function Vi(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 ce.ERR_OUT_OF_RANGE("value",a,t)}qs(n,i,o)}function ue(t,e){if(typeof t!="number")throw new ce.ERR_INVALID_ARG_TYPE(e,"number",t)}function Oe(t,e,r){throw Math.floor(t)!==t?(ue(t,r),new ce.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new ce.ERR_BUFFER_OUT_OF_BOUNDS:new ce.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Hs=/[^+/0-9A-Za-z-_]/g;function Ws(t){if(t=t.split("=")[0],t=t.trim().replace(Hs,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function pn(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 $s(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Gs(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 ji(t){return un.toByteArray(Ws(t))}function fr(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 Tt(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function wn(t){return t!==t}var zs=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 Vt(t){return typeof BigInt>"u"?Ys:t}function Ys(){throw new Error("BigInt not supported")}});var j=t=>t==null,q=t=>!j(t),fs=class extends Error{},ar=(t,e)=>{if(j(t))throw new fs(e)},nn="__bigint__",on="__principal__",sn="__uint8array__",ps=(t,e)=>typeof e=="bigint"?{[nn]:`${e}`}:q(e)&&e instanceof S?{[on]:e.toText()}:q(e)&&e instanceof Uint8Array?{[sn]:Array.from(e)}:e,hs=(t,e)=>{let r=n=>e[n];return q(e)&&typeof e=="object"&&nn in e?BigInt(r(nn)):q(e)&&typeof e=="object"&&on in e?S.fromText(r(on)):q(e)&&typeof e=="object"&&sn in e?Uint8Array.from(r(sn)):e},J=t=>q(t)?[t]:[],z=t=>t?.[0],fi=async t=>{let e=new Blob([JSON.stringify(t,ps)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},cr=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(),hs)},pi=()=>typeof window<"u";var se=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 kt=class t extends se{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 an=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var hi=BigInt(144e11),mi=!1,yi={width:576,height:576},wi={width:505,height:705},gi="internetcomputer.org";var ae="http://127.0.0.1:5987",_i="rdmx6-jaaaa-aaaaa-aaadq-cai";var bt=class t extends se{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 cn=({width:t,height:e})=>{if(!pi()||j(window)||j(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 lr=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=bt.getInstance().get()?.container;if(j(n)||n===!1)return`https://identity.${this.#t??gi}`;let i=bt.getInstance().get(),o=q(i)&&q(i?.internetIdentityId)?i.internetIdentityId:_i,{host:s,protocol:a}=new URL(n===!0?ae:n);return/apple/i.test(navigator?.vendor)?`${a}//${s}?canisterId=${o}`:`${a}//${o}.${s.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:cn(yi)},identityProvider:r()}}},xi=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:cn(wi)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};var fo=er(qi());var pr;(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"})(pr||(pr={}));var Js=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},Xs=new TextEncoder().encode(`
2
+ ic-request`),Ut=class{getPrincipal(){return this._principal||(this._principal=S.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=Js(e,["body"]),i=await Kt(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(rr(Xs,i))}})}},Mt=class{getPrincipal(){return S.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};var Hi=er(ei());var Ne=()=>{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 hr;(function(t){t.Call="call"})(hr||(hr={}));function fe(){let t=new ArrayBuffer(16),e=new DataView(t),r=Ne(),n=Ne(),i=Ne(),o=Ne();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,o),t}var Zs=BigInt(1e6),Qs=60*1e3,Jt=class{constructor(e){let o=BigInt(Math.floor(Date.now()+e-Qs))*Zs/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=o}toCBOR(){return Hi.value.u64(this._value.toString(16),16)}toHash(){return Ln(this._value)}};function gn(t=fe){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}function Be(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}var Pe=class extends et{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};var mr=BigInt(4294967295),_n=BigInt(32);function Wi(t,e=!1){return e?{h:Number(t&mr),l:Number(t>>_n&mr)}:{h:Number(t>>_n&mr)|0,l:Number(t&mr)|0}}function Is(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}=Wi(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]}var Ds=(t,e)=>BigInt(t>>>0)<<_n|BigInt(e>>>0),Ls=(t,e,r)=>t>>>r,ta=(t,e,r)=>t<<32-r|e>>>r,ea=(t,e,r)=>t>>>r|e<<32-r,ra=(t,e,r)=>t<<32-r|e>>>r,na=(t,e,r)=>t<<64-r|e>>>r-32,ia=(t,e,r)=>t>>>r-32|e<<64-r,oa=(t,e)=>e,sa=(t,e)=>t,aa=(t,e,r)=>t<<r|e>>>32-r,ca=(t,e,r)=>e<<r|t>>>32-r,la=(t,e,r)=>e<<r-32|t>>>64-r,ua=(t,e,r)=>t<<r-32|e>>>64-r;function da(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var fa=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),pa=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,ha=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),ma=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,ya=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),wa=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;var ga={fromBig:Wi,split:Is,toBig:Ds,shrSH:Ls,shrSL:ta,rotrSH:ea,rotrSL:ra,rotrBH:na,rotrBL:ia,rotr32H:oa,rotr32L:sa,rotlSH:aa,rotlSL:ca,rotlBH:la,rotlBL:ua,add:da,add3L:fa,add3H:pa,add4L:ha,add4H:ma,add5H:wa,add5L:ya},v=ga;var[_a,xa]=v.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))),jt=new Uint32Array(80),qt=new Uint32Array(80),xn=class extends Dn{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:l,Eh:d,El:c,Fh:f,Fl:h,Gh:w,Gl:m,Hh:g,Hl:E}=this;return[e,r,n,i,o,s,a,l,d,c,f,h,w,m,g,E]}set(e,r,n,i,o,s,a,l,d,c,f,h,w,m,g,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=l|0,this.Eh=d|0,this.El=c|0,this.Fh=f|0,this.Fl=h|0,this.Gh=w|0,this.Gl=m|0,this.Hh=g|0,this.Hl=E|0}process(e,r){for(let A=0;A<16;A++,r+=4)jt[A]=e.getUint32(r),qt[A]=e.getUint32(r+=4);for(let A=16;A<80;A++){let F=jt[A-15]|0,b=qt[A-15]|0,M=v.rotrSH(F,b,1)^v.rotrSH(F,b,8)^v.shrSH(F,b,7),X=v.rotrSL(F,b,1)^v.rotrSL(F,b,8)^v.shrSL(F,b,7),K=jt[A-2]|0,H=qt[A-2]|0,nt=v.rotrSH(K,H,19)^v.rotrBH(K,H,61)^v.shrSH(K,H,6),st=v.rotrSL(K,H,19)^v.rotrBL(K,H,61)^v.shrSL(K,H,6),gt=v.add4L(X,st,qt[A-7],qt[A-16]),lt=v.add4H(gt,M,nt,jt[A-7],jt[A-16]);jt[A]=lt|0,qt[A]=gt|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:l,Dh:d,Dl:c,Eh:f,El:h,Fh:w,Fl:m,Gh:g,Gl:E,Hh:R,Hl:B}=this;for(let A=0;A<80;A++){let F=v.rotrSH(f,h,14)^v.rotrSH(f,h,18)^v.rotrBH(f,h,41),b=v.rotrSL(f,h,14)^v.rotrSL(f,h,18)^v.rotrBL(f,h,41),M=f&w^~f&g,X=h&m^~h&E,K=v.add5L(B,b,X,xa[A],qt[A]),H=v.add5H(K,R,F,M,_a[A],jt[A]),nt=K|0,st=v.rotrSH(n,i,28)^v.rotrBH(n,i,34)^v.rotrBH(n,i,39),gt=v.rotrSL(n,i,28)^v.rotrBL(n,i,34)^v.rotrBL(n,i,39),lt=n&o^n&a^o&a,Gt=i&s^i&l^s&l;R=g|0,B=E|0,g=w|0,E=m|0,w=f|0,m=h|0,{h:f,l:h}=v.add(d|0,c|0,H|0,nt|0),d=a|0,c=l|0,a=o|0,l=s|0,o=n|0,s=i|0;let Pt=v.add3L(nt,gt,Gt);n=v.add3H(Pt,H,st,lt),i=Pt|0}({h:n,l:i}=v.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=v.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l}=v.add(this.Ch|0,this.Cl|0,a|0,l|0),{h:d,l:c}=v.add(this.Dh|0,this.Dl|0,d|0,c|0),{h:f,l:h}=v.add(this.Eh|0,this.El|0,f|0,h|0),{h:w,l:m}=v.add(this.Fh|0,this.Fl|0,w|0,m|0),{h:g,l:E}=v.add(this.Gh|0,this.Gl|0,g|0,E|0),{h:R,l:B}=v.add(this.Hh|0,this.Hl|0,R|0,B|0),this.set(n,i,o,s,a,l,d,c,f,h,w,m,g,E,R,B)}roundClean(){jt.fill(0),qt.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 $i=Qn(()=>new xn);var pt=BigInt(0),it=BigInt(1),yr=BigInt(2),ba=BigInt(8),Ea={zip215:!0};function Ta(t){let e=ai(t);return ni(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Gi(t){let e=Ta(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:l}=e,d=yr<<BigInt(a*8)-it,c=r.create,f=e.uvRatio||((_,p)=>{try{return{isValid:!0,value:r.sqrt(_*r.inv(p))}}catch{return{isValid:!1,value:pt}}}),h=e.adjustScalarBytes||(_=>_),w=e.domain||((_,p,x)=>{if(p.length||x)throw new Error("Contexts/pre-hash are not supported");return _}),m=_=>typeof _=="bigint"&&pt<_,g=(_,p)=>m(_)&&m(p)&&_<p,E=_=>_===pt||g(_,d);function R(_,p){if(g(_,p))return _;throw new Error(`Expected valid scalar < ${p}, got ${typeof _} ${_}`)}function B(_){return _===pt?_:R(_,n)}let A=new Map;function F(_){if(!(_ instanceof b))throw new Error("ExtendedPoint expected")}class b{constructor(p,x,T,O){if(this.ex=p,this.ey=x,this.ez=T,this.et=O,!E(p))throw new Error("x required");if(!E(x))throw new Error("y required");if(!E(T))throw new Error("z required");if(!E(O))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof b)throw new Error("extended point not allowed");let{x,y:T}=p||{};if(!E(x)||!E(T))throw new Error("invalid affine point");return new b(x,T,it,c(x*T))}static normalizeZ(p){let x=r.invertBatch(p.map(T=>T.ez));return p.map((T,O)=>T.toAffine(x[O])).map(b.fromAffine)}_setWindowSize(p){this._WINDOW_SIZE=p,A.delete(this)}assertValidity(){let{a:p,d:x}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:T,ey:O,ez:N,et:C}=this,k=c(T*T),P=c(O*O),U=c(N*N),V=c(U*U),W=c(k*p),tt=c(U*c(W+P)),$=c(V+c(x*c(k*P)));if(tt!==$)throw new Error("bad point: equation left != right (1)");let _t=c(T*O),ut=c(N*C);if(_t!==ut)throw new Error("bad point: equation left != right (2)")}equals(p){F(p);let{ex:x,ey:T,ez:O}=this,{ex:N,ey:C,ez:k}=p,P=c(x*k),U=c(N*O),V=c(T*k),W=c(C*O);return P===U&&V===W}is0(){return this.equals(b.ZERO)}negate(){return new b(c(-this.ex),this.ey,this.ez,c(-this.et))}double(){let{a:p}=e,{ex:x,ey:T,ez:O}=this,N=c(x*x),C=c(T*T),k=c(yr*c(O*O)),P=c(p*N),U=x+T,V=c(c(U*U)-N-C),W=P+C,tt=W-k,$=P-C,_t=c(V*tt),ut=c(W*$),ne=c(V*$),ie=c(tt*W);return new b(_t,ut,ie,ne)}add(p){F(p);let{a:x,d:T}=e,{ex:O,ey:N,ez:C,et:k}=this,{ex:P,ey:U,ez:V,et:W}=p;if(x===BigInt(-1)){let De=c((N-O)*(U+P)),Le=c((N+O)*(U-P)),Ae=c(Le-De);if(Ae===pt)return this.double();let tr=c(C*yr*W),zn=c(k*yr*V),Yn=zn+tr,Jn=Le+De,Xn=zn-tr,os=c(Yn*Ae),ss=c(Jn*Xn),as=c(Yn*Xn),cs=c(Ae*Jn);return new b(os,ss,cs,as)}let tt=c(O*P),$=c(N*U),_t=c(k*T*W),ut=c(C*V),ne=c((O+N)*(P+U)-tt-$),ie=ut-_t,Qe=ut+_t,Ie=c($-x*tt),Zr=c(ne*ie),Qr=c(Qe*Ie),Ir=c(ne*Ie),Dr=c(ie*Qe);return new b(Zr,Qr,Dr,Ir)}subtract(p){return this.add(p.negate())}wNAF(p){return K.wNAFCached(this,A,p,b.normalizeZ)}multiply(p){let{p:x,f:T}=this.wNAF(R(p,n));return b.normalizeZ([x,T])[0]}multiplyUnsafe(p){let x=B(p);return x===pt?X:this.equals(X)||x===it?this:this.equals(M)?this.wNAF(x).p:K.unsafeLadder(this,x)}isSmallOrder(){return this.multiplyUnsafe(l).is0()}isTorsionFree(){return K.unsafeLadder(this,n).is0()}toAffine(p){let{ex:x,ey:T,ez:O}=this,N=this.is0();p==null&&(p=N?ba:r.inv(O));let C=c(x*p),k=c(T*p),P=c(O*p);if(N)return{x:pt,y:it};if(P!==it)throw new Error("invZ was invalid");return{x:C,y:k}}clearCofactor(){let{h:p}=e;return p===it?this:this.multiplyUnsafe(p)}static fromHex(p,x=!1){let{d:T,a:O}=e,N=r.BYTES;p=Ct("pointHex",p,N);let C=p.slice(),k=p[N-1];C[N-1]=k&-129;let P=sr(C);P===pt||(x?R(P,d):R(P,r.ORDER));let U=c(P*P),V=c(U-it),W=c(T*U-O),{isValid:tt,value:$}=f(V,W);if(!tt)throw new Error("Point.fromHex: invalid y coordinate");let _t=($&it)===it,ut=(k&128)!==0;if(!x&&$===pt&&ut)throw new Error("Point.fromHex: x=0 and x_0=1");return ut!==_t&&($=c(-$)),b.fromAffine({x:$,y:P})}static fromPrivateKey(p){return st(p).point}toRawBytes(){let{x:p,y:x}=this.toAffine(),T=tn(x,r.BYTES);return T[T.length-1]|=p&it?128:0,T}toHex(){return ri(this.toRawBytes())}}b.BASE=new b(e.Gx,e.Gy,it,c(e.Gx*e.Gy)),b.ZERO=new b(pt,it,it,pt);let{BASE:M,ZERO:X}=b,K=si(b,a*8);function H(_){return dt(_,n)}function nt(_){return H(sr(_))}function st(_){let p=a;_=Ct("private key",_,p);let x=Ct("hashed private key",o(_),2*p),T=h(x.slice(0,p)),O=x.slice(p,2*p),N=nt(T),C=M.multiply(N),k=C.toRawBytes();return{head:T,prefix:O,scalar:N,point:C,pointBytes:k}}function gt(_){return st(_).pointBytes}function lt(_=new Uint8Array,...p){let x=en(...p);return nt(o(w(x,Ct("context",_),!!i)))}function Gt(_,p,x={}){_=Ct("message",_),i&&(_=i(_));let{prefix:T,scalar:O,pointBytes:N}=st(p),C=lt(x.context,T,_),k=M.multiply(C).toRawBytes(),P=lt(x.context,k,N,_),U=H(C+P*O);B(U);let V=en(k,tn(U,r.BYTES));return Ct("result",V,a*2)}let Pt=Ea;function re(_,p,x,T=Pt){let{context:O,zip215:N}=T,C=r.BYTES;_=Ct("signature",_,2*C),p=Ct("message",p),i&&(p=i(p));let k=sr(_.slice(C,2*C)),P,U,V;try{P=b.fromHex(x,N),U=b.fromHex(_.slice(0,C),N),V=M.multiplyUnsafe(k)}catch{return!1}if(!N&&P.isSmallOrder())return!1;let W=lt(O,U.toRawBytes(),P.toRawBytes(),p);return U.add(P.multiplyUnsafe(W)).subtract(V).clearCofactor().equals(b.ZERO)}return M._setWindowSize(8),{CURVE:e,getPublicKey:gt,sign:Gt,verify:re,ExtendedPoint:b,utils:{getExtendedPublicKey:st,randomPrivateKey:()=>s(r.BYTES),precompute(_=8,p=b.BASE){return p._setWindowSize(_),p.multiply(BigInt(3)),p}}}}var bn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),zi=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Bl=BigInt(0),Aa=BigInt(1),Yi=BigInt(2),Pl=BigInt(3),va=BigInt(5),Sa=BigInt(8);function Ra(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),o=bn,a=t*t%o*t%o,l=ft(a,Yi,o)*a%o,d=ft(l,Aa,o)*t%o,c=ft(d,va,o)*d%o,f=ft(c,e,o)*c%o,h=ft(f,r,o)*f%o,w=ft(h,n,o)*h%o,m=ft(w,i,o)*w%o,g=ft(m,i,o)*w%o,E=ft(g,e,o)*c%o;return{pow_p_5_8:ft(E,Yi,o)*t%o,b2:a}}function Oa(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Na(t,e){let r=bn,n=dt(e*e*e,r),i=dt(n*n*e,r),o=Ra(t*i).pow_p_5_8,s=dt(t*n*o,r),a=dt(e*s*s,r),l=s,d=dt(s*zi,r),c=a===t,f=a===dt(-t,r),h=a===dt(-t*zi,r);return c&&(s=l),(f||h)&&(s=d),ii(s,r)&&(s=dt(-s,r)),{isValid:c||f,value:s}}var Ba=oi(bn,void 0,!0),Pa={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ba,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Sa,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:$i,randomBytes:In,adjustScalarBytes:Oa,uvRatio:Na},Ht=Gi(Pa);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},D=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,Ce,Xi,Zi,wr=class{constructor(e={}){Z.set(this,void 0),Ce.set(this,void 0),this[Xi]=this.entries.bind(this),this[Zi]="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,Ce,n,"f")}prune(){let e=Date.now();for(let[r,n]of D(this,Z,"f").entries())e-n.timestamp>D(this,Ce,"f")&&D(this,Z,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return D(this,Z,"f").set(e,n),this}get(e){let r=D(this,Z,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>D(this,Ce,"f")){D(this,Z,"f").delete(e);return}return r.value}}clear(){D(this,Z,"f").clear()}entries(){let e=D(this,Z,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=D(this,Z,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return D(this,Z,"f").keys()}forEach(e,r){for(let[n,i]of D(this,Z,"f").entries())e.call(r,i.value,n,this)}has(e){return D(this,Z,"f").has(e)}delete(e){return D(this,Z,"f").delete(e)}get size(){return D(this,Z,"f").size}};Z=new WeakMap,Ce=new WeakMap,Xi=Symbol.iterator,Zi=Symbol.toStringTag;var Qi=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)")},Ii=(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)")},En=(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)")},Ca=(t,e)=>{let r=En(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)")},Di=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),Xt=Uint8Array.from([48,5,6,3,43,101,112]),Ul=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function pe(t,e){let r=2+Qi(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,o=new Uint8Array(1+Qi(n)+n);return o[i++]=48,i+=Ii(o,i,n),o.set(e,i),i+=e.byteLength,o[i++]=3,i+=Ii(o,i,t.byteLength+1),o[i++]=0,o.set(new Uint8Array(t),i),o}var ke=(t,e)=>{let r=0,n=(a,l)=>{if(i[r++]!==a)throw new Error("Expected: "+l)},i=new Uint8Array(t);if(n(48,"sequence"),r+=En(i,r),!nr(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let o=Ca(i,r)-1;r+=En(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 Li=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},to=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)},gr,_r,Fe=class t{constructor(e){if(gr.set(this,void 0),_r.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Li(this,gr,e,"f"),Li(this,_r,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 pe(e,Xt).buffer}static derDecode(e){let r=ke(e,Xt);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return to(this,gr,"f")}get derKey(){return to(this,_r,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};gr=new WeakMap,_r=new WeakMap;Fe.RAW_KEY_LENGTH=32;var Tn=class{constructor(){this.observers=[]}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e,...r){this.observers.forEach(n=>n(e,...r))}},xr=class extends Tn{constructor(){super()}print(e,...r){this.notify({message:e,level:"info"},...r)}warn(e,...r){this.notify({message:e,level:"warn"},...r)}error(e,r,...n){this.notify({message:e,level:"error",error:r},...n)}};var At=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},Q=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,br,Er,Tr,Ar,vr,Sr,Rr,he;var Ue=class t{constructor(e=t.default){vt.set(this,void 0),br.set(this,void 0),Er.set(this,void 0),Tr.set(this,void 0),Ar.set(this,void 0),vr.set(this,void 0),Sr.set(this,void 0),Rr.set(this,void 0),he.set(this,0);let{initialInterval:r=500,randomizationFactor:n=.5,multiplier:i=1.5,maxInterval:o=6e4,maxElapsedTime:s=9e5,maxIterations:a=10,date:l=Date}=e;At(this,vt,r,"f"),At(this,br,n,"f"),At(this,Er,i,"f"),At(this,Tr,o,"f"),At(this,Rr,l,"f"),At(this,Ar,l.now(),"f"),At(this,vr,s,"f"),At(this,Sr,a,"f")}get ellapsedTimeInMsec(){return Q(this,Rr,"f").now()-Q(this,Ar,"f")}get currentInterval(){return Q(this,vt,"f")}get count(){return Q(this,he,"f")}get randomValueFromInterval(){let e=Q(this,br,"f")*Q(this,vt,"f"),r=Q(this,vt,"f")-e,n=Q(this,vt,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return At(this,vt,Math.min(Q(this,vt,"f")*Q(this,Er,"f"),Q(this,Tr,"f")),"f"),At(this,he,(e=Q(this,he,"f"),e++,e),"f"),Q(this,vt,"f")}next(){return this.ellapsedTimeInMsec>=Q(this,vr,"f")||Q(this,he,"f")>=Q(this,Sr,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};vt=new WeakMap,br=new WeakMap,Er=new WeakMap,Tr=new WeakMap,Ar=new WeakMap,vr=new WeakMap,Sr=new WeakMap,Rr=new WeakMap,he=new WeakMap;Ue.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date};var ot=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},y=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)},Rt,St,It,we,Nr,Me,ht,Br,mt,Zt,Pr,me,ye,Qt,Dt,eo,Cr,kr,Ot;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(Ot||(Ot={}));var Or=5*60*1e3,Fa="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";var Ua="ic0.app",Ma=".ic0.app",Ka="icp0.io",Va=".icp0.io",ja="icp-api.io",qa=".icp-api.io",Ke=class extends et{constructor(e){super(e),this.message=e}},ge=class extends et{constructor(e){super(e),this.message=e}};function Ha(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new Ke("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 Ke("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 Ke("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function Wa(t){let e;if(t!==void 0)!t.match(/^[a-z]+:/)&&typeof window<"u"?e=new URL(window.location.protocol+"//"+t):e=new URL(t);else{let r=["ic0.app","icp0.io","127.0.0.1","localhost"],n=[".github.dev",".gitpod.io"],i=typeof window<"u"?window.location:void 0,o=i?.hostname,s;o&&typeof o=="string"&&(n.some(a=>o.endsWith(a))?s=o:s=r.find(a=>o.endsWith(a))),i&&s?e=new URL(`${i.protocol}//${s}${i.port?":"+i.port:""}`):e=new URL("https://icp-api.io")}return e.toString()}var Ve=class t{constructor(e={}){var r;Rt.add(this),this.rootKey=xt(Fa),St.set(this,void 0),It.set(this,void 0),we.set(this,void 0),Nr.set(this,void 0),Me.set(this,0),ht.set(this,void 0),Br.set(this,!1),mt.set(this,void 0),Zt.set(this,void 0),this._isAgent=!0,this.config={},Pr.set(this,0),this.log=new xr,me.set(this,[]),ye.set(this,[]),Qt.set(this,new wr({expirationTime:5*60*1e3})),Dt.set(this,!0),kr.set(this,(o,s)=>{if(y(this,Dt,"f")===!1)return o;if(!s)throw new Se("Invalid signature from replica signed query: no matching node key found.");let{status:a,signatures:l=[],requestId:d}=o,c=new TextEncoder().encode("\vic-response");for(let f of l){let{timestamp:h,identity:w}=f,m=S.fromUint8Array(w).toText(),g;if(a==="replied"){let{reply:F}=o;g=Lr({status:a,reply:F,timestamp:BigInt(h),request_id:d})}else if(a==="rejected"){let{reject_code:F,reject_message:b,error_code:M}=o;g=Lr({status:a,reject_code:F,reject_message:b,error_code:M,timestamp:BigInt(h),request_id:d})}else throw new Error(`Unknown status: ${a}`);let E=rr(c,new Uint8Array(g)),R=s?.nodeKeys.get(m);if(!R)throw new Se("Invalid signature from replica signed query: no matching node key found.");let B=Fe.fromDer(R).rawKey;if(Ht.verify(f.signature,new Uint8Array(E),new Uint8Array(B)))return o;throw new Se(`Invalid signature from replica ${m} signed query.`)}return o}),this.config=e,ot(this,It,e.fetch||Ha()||fetch.bind(globalThis),"f"),ot(this,we,e.fetchOptions,"f"),ot(this,Nr,e.callOptions,"f");let n=Wa(e.host);this.host=new URL(n),e.verifyQuerySignatures!==void 0&&ot(this,Dt,e.verifyQuerySignatures,"f"),ot(this,mt,(r=e.retryTimes)!==null&&r!==void 0?r:3,"f");let i=()=>new Ue({maxIterations:y(this,mt,"f")});if(ot(this,Zt,e.backoffStrategy||i,"f"),this.host.hostname.endsWith(Ma)?this.host.hostname=Ua:this.host.hostname.endsWith(Va)?this.host.hostname=Ka:this.host.hostname.endsWith(qa)&&(this.host.hostname=ja),e.credentials){let{name:o,password:s}=e.credentials;ot(this,ht,`${o}${s?":"+s:""}`,"f")}ot(this,St,Promise.resolve(e.identity||new Mt),"f"),this.addTransform("update",gn(fe)),e.useQueryNonces&&this.addTransform("query",gn(fe)),e.logToConsole&&this.log.subscribe(o=>{o.level==="error"?console.error(o.message):o.level==="warn"?console.warn(o.message):console.log(o.message)})}get waterMark(){return y(this,Pr,"f")}static createSync(e={}){return new this(Object.assign({},e))}static async create(e={shouldFetchRootKey:!1}){let r=t.createSync(e),n=[r.syncTime()];return r.host.toString()!=="https://icp-api.io"&&e.shouldFetchRootKey&&n.push(r.fetchRootKey()),await Promise.all(n),r}static async from(e){var r;try{return"config"in e?await t.create(e.config):await t.create({fetch:e._fetch,fetchOptions:e._fetchOptions,callOptions:e._callOptions,host:e._host.toString(),identity:(r=e._identity)!==null&&r!==void 0?r:void 0})}catch{throw new et("Failed to create agent from provided agent")}}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=y(this,ye,"f").findIndex(o=>(o.priority||0)<n);y(this,ye,"f").splice(i>=0?i:y(this,ye,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=y(this,me,"f").findIndex(o=>(o.priority||0)<n);y(this,me,"f").splice(i>=0?i:y(this,me,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!y(this,St,"f"))throw new ge("This identity has expired due this application's security policy. Please refresh your authentication.");return(await y(this,St,"f")).getPrincipal()}async call(e,r,n){let i=await(n!==void 0?await n:await y(this,St,"f"));if(!i)throw new ge("This identity has expired due this application's security policy. Please refresh your authentication.");let o=S.from(e),s=r.effectiveCanisterId?S.from(r.effectiveCanisterId):o,a=i.getPrincipal()||S.anonymous(),l=new Jt(Or);Math.abs(y(this,Me,"f"))>1e3*30&&(l=new Jt(Or+y(this,Me,"f")));let d={request_type:hr.Call,canister_id:o,method_name:r.methodName,arg:r.arg,sender:a,ingress_expiry:l},c=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},y(this,ht,"f")?{Authorization:"Basic "+btoa(y(this,ht,"f"))}:{})},endpoint:"call",body:d}),f=c.body.nonce?h(c.body.nonce):void 0;d.nonce=f;function h(F){return new Uint8Array(F)}c=await i.transformRequest(c);let w=or(c.body);this.log.print(`fetching "/api/v2/canister/${s.toText()}/call" with request:`,c);let m=y(this,Zt,"f").call(this),g=y(this,Rt,"m",Cr).call(this,{request:()=>y(this,It,"f").call(this,""+new URL(`/api/v2/canister/${s.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},y(this,Nr,"f")),c.request),{body:w})),backoff:m,tries:0}),[E,R]=await Promise.all([g,Kt(d)]),B=await E.arrayBuffer(),A=E.status===200&&B.byteLength>0?oe(B):null;return{requestId:R,response:{ok:E.ok,status:E.status,statusText:E.statusText,body:A,headers:Be(E.headers)},requestDetails:d}}async query(e,r,n){let i=y(this,Zt,"f").call(this),o=r.effectiveCanisterId?S.from(r.effectiveCanisterId):S.from(e);this.log.print(`ecid ${o.toString()}`),this.log.print(`canisterId ${e.toString()}`);let s=async()=>{let w=await(n!==void 0?await n:await y(this,St,"f"));if(!w)throw new ge("This identity has expired due this application's security policy. Please refresh your authentication.");let m=S.from(e),g=w?.getPrincipal()||S.anonymous(),E={request_type:"query",canister_id:m,method_name:r.methodName,arg:r.arg,sender:g,ingress_expiry:new Jt(Or)},R=await Kt(E),B=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},y(this,ht,"f")?{Authorization:"Basic "+btoa(y(this,ht,"f"))}:{})},endpoint:"read",body:E});B=await w?.transformRequest(B);let A=or(B.body),F={canister:m.toText(),ecid:o,transformedRequest:B,body:A,requestId:R,backoff:i,tries:0};return{requestDetails:E,query:await y(this,Rt,"m",eo).call(this,F)}},a=async()=>{if(!y(this,Dt,"f"))return;let w=y(this,Qt,"f").get(o.toString());return w||(await this.fetchSubnetKeys(o.toString()),y(this,Qt,"f").get(o.toString()))},[l,d]=await Promise.all([s(),a()]),{requestDetails:c,query:f}=l,h=Object.assign(Object.assign({},f),{requestDetails:c});if(this.log.print("Query response:",h),!y(this,Dt,"f"))return h;try{return y(this,kr,"f").call(this,h,d)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),y(this,Qt,"f").delete(e.toString()),await this.fetchSubnetKeys(o.toString());let m=y(this,Qt,"f").get(e.toString());if(!m)throw new Se("Invalid signature from replica signed query: no matching node key found.");return y(this,kr,"f").call(this,h,m)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await y(this,St,"f"));if(!n)throw new ge("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||S.anonymous(),o=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},y(this,ht,"f")?{Authorization:"Basic "+btoa(y(this,ht,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Jt(Or)}});return n?.transformRequest(o)}async readState(e,r,n,i){let o=typeof e=="string"?S.fromText(e):e,s=i??await this.createReadStateRequest(r,n),a=or(s.body);this.log.print(`fetching "/api/v2/canister/${o}/read_state" with request:`,s);let l=y(this,Zt,"f").call(this),d=await y(this,Rt,"m",Cr).call(this,{request:()=>y(this,It,"f").call(this,""+new URL(`/api/v2/canister/${o.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},y(this,we,"f")),s.request),{body:a})),backoff:l,tries:0});if(!d.ok)throw new Error(`Server returned an error:
3
3
  Code: ${d.status} (${d.statusText})
4
4
  Body: ${await d.text()}
5
- `);let c=ee(await d.arrayBuffer());this.log.print("Read state response:",c);let f=await this.parseTimeFromResponse(c);return f>0&&(this.log.print("Read state response time:",f),br(this,Tr,f,"f")),c}async parseTimeFromResponse(e){let r;if(e.certificate){let n=ee(e.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=ii(["time"],r);if(i.status!==ni.Found)throw new Error("Time was not found in the response or was not in its expected format.");if(!(i.value instanceof ArrayBuffer)&&!ArrayBuffer.isView(i))throw new Error("Time was not found in the response or was not in its expected format.");let o=ei(Ie(i.value));return this.log.print("Time from response:",o),this.log.print("Time from response in milliseconds:",Number(o)),Number(o)}else this.log.warn("No certificate found in response");return 0}async syncTime(e){let r=await import("./canisterStatus-7ZJKVFTO.js"),n=Date.now();try{e||this.log.print("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let o=(await r.request({canisterId:e??v.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)}:{};this.log.print('fetching "/api/v2/status"');let r=S(this,Yt,"f").call(this),n=await S(this,At,"m",Ar).call(this,{backoff:r,request:()=>this._fetch(""+new URL("/api/v2/status",this._host),Object.assign({headers:e},this._fetchOptions)),tries:0});return ee(await n.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=v.from(e),i=(await Zr({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return S(this,Jt,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of S(this,fe,"f"))r=r.then(i=>n(i).then(o=>o||i));else for(let n of S(this,de,"f"))r=r.then(i=>n(i).then(o=>o||i));return r}};pt=new WeakMap,Yt=new WeakMap,Tr=new WeakMap,de=new WeakMap,fe=new WeakMap,Jt=new WeakMap,Xt=new WeakMap,vr=new WeakMap,At=new WeakSet,Xi=async function t(e){var r,n;let{ecid:i,transformedRequest:o,body:s,requestId:a,backoff:l,tries:d}=e,c=d===0?0:l.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:d,backoff:l,delay:c}),c===null)throw new rt(`Timestamp failed to pass the watermark after retrying the configured ${S(this,pt,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);c>0&&await new Promise(h=>setTimeout(h,c));let f;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,o);let h=await this._fetch(""+new URL(`/api/v2/canister/${i.toString()}/query`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),o.request),{body:s}));if(h.status===200){let y=ee(await h.arrayBuffer());f=Object.assign(Object.assign({},y),{httpDetails:{ok:h.ok,status:h.status,statusText:h.statusText,headers:Ae(h.headers)},requestId:a})}else throw new ve(`Gateway returned an error:
6
- Code: ${h.status} (${h.statusText})
7
- Body: ${await h.text()}
8
- `,{ok:h.ok,status:h.status,statusText:h.statusText,headers:Ae(h.headers)})}catch(h){if(d<S(this,pt,"f"))return this.log.warn(`Caught exception while attempting to make query:
9
- ${h}
10
- Retrying query.`),await S(this,At,"m",t).call(this,Object.assign(Object.assign({},e),{tries:d+1}));throw h}let m=(n=(r=f.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!S(this,Xt,"f"))return f;if(!m)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let g=Number(BigInt(m)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:g}),Number(this.waterMark)>g){let h=new rt("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",h,{timestamp:m,waterMark:this.waterMark}),d<S(this,pt,"f"))return await S(this,At,"m",t).call(this,Object.assign(Object.assign({},e),{tries:d+1}));throw new rt(`Timestamp failed to pass the watermark after retrying the configured ${S(this,pt,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return f},Ar=async function t(e){let{request:r,backoff:n,tries:i}=e,o=i===0?0:n.next();if(o===null)throw new rt(`Timestamp failed to pass the watermark after retrying the configured ${S(this,pt,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);o>0&&await new Promise(d=>setTimeout(d,o));let s;try{s=await r()}catch(d){if(S(this,pt,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
5
+ `);let c=oe(await d.arrayBuffer());this.log.print("Read state response:",c);let f=await this.parseTimeFromResponse(c);return f>0&&(this.log.print("Read state response time:",f),ot(this,Pr,f,"f")),c}async parseTimeFromResponse(e){let r;if(e.certificate){let n=oe(e.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=di(["time"],r);if(i.status!==ui.Found)throw new Error("Time was not found in the response or was not in its expected format.");if(!(i.value instanceof ArrayBuffer)&&!ArrayBuffer.isView(i))throw new Error("Time was not found in the response or was not in its expected format.");let o=ci(ir(i.value));return this.log.print("Time from response:",o),this.log.print("Time from response in milliseconds:",Number(o)),Number(o)}else this.log.warn("No certificate found in response");return 0}async syncTime(e){let r=await import("./canisterStatus-7ZJKVFTO.js"),n=Date.now();try{e||this.log.print("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let o=(await r.request({canisterId:e??S.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");o&&ot(this,Me,Number(o)-Number(n),"f")}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=y(this,ht,"f")?{Authorization:"Basic "+btoa(y(this,ht,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=y(this,Zt,"f").call(this),n=await y(this,Rt,"m",Cr).call(this,{backoff:r,request:()=>y(this,It,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:e},y(this,we,"f"))),tries:0});return oe(await n.arrayBuffer())}async fetchRootKey(){return y(this,Br,"f")||(this.rootKey=(await this.status()).root_key,ot(this,Br,!0,"f")),this.rootKey}invalidateIdentity(){ot(this,St,null,"f")}replaceIdentity(e){ot(this,St,Promise.resolve(e),"f")}async fetchSubnetKeys(e){let r=S.from(e),i=(await rn({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return y(this,Qt,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of y(this,ye,"f"))r=r.then(i=>n(i).then(o=>o||i));else for(let n of y(this,me,"f"))r=r.then(i=>n(i).then(o=>o||i));return r}};St=new WeakMap,It=new WeakMap,we=new WeakMap,Nr=new WeakMap,Me=new WeakMap,ht=new WeakMap,Br=new WeakMap,mt=new WeakMap,Zt=new WeakMap,Pr=new WeakMap,me=new WeakMap,ye=new WeakMap,Qt=new WeakMap,Dt=new WeakMap,kr=new WeakMap,Rt=new WeakSet,eo=async function t(e){var r,n;let{ecid:i,transformedRequest:o,body:s,requestId:a,backoff:l,tries:d}=e,c=d===0?0:l.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:d,backoff:l,delay:c}),c===null)throw new et(`Timestamp failed to pass the watermark after retrying the configured ${y(this,mt,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);c>0&&await new Promise(m=>setTimeout(m,c));let f;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,o);let m=await y(this,It,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},y(this,we,"f")),o.request),{body:s}));if(m.status===200){let g=oe(await m.arrayBuffer());f=Object.assign(Object.assign({},g),{httpDetails:{ok:m.ok,status:m.status,statusText:m.statusText,headers:Be(m.headers)},requestId:a})}else throw new Pe(`Gateway returned an error:
6
+ Code: ${m.status} (${m.statusText})
7
+ Body: ${await m.text()}
8
+ `,{ok:m.ok,status:m.status,statusText:m.statusText,headers:Be(m.headers)})}catch(m){if(d<y(this,mt,"f"))return this.log.warn(`Caught exception while attempting to make query:
9
+ ${m}
10
+ Retrying query.`),await y(this,Rt,"m",t).call(this,Object.assign(Object.assign({},e),{tries:d+1}));throw m}let h=(n=(r=f.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!y(this,Dt,"f"))return f;if(!h)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let w=Number(BigInt(h)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:w}),Number(this.waterMark)>w){let m=new et("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",m,{timestamp:h,waterMark:this.waterMark}),d<y(this,mt,"f"))return await y(this,Rt,"m",t).call(this,Object.assign(Object.assign({},e),{tries:d+1}));throw new et(`Timestamp failed to pass the watermark after retrying the configured ${y(this,mt,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return f},Cr=async function t(e){let{request:r,backoff:n,tries:i}=e,o=i===0?0:n.next();if(o===null)throw new et(`Timestamp failed to pass the watermark after retrying the configured ${y(this,mt,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);o>0&&await new Promise(d=>setTimeout(d,o));let s;try{s=await r()}catch(d){if(y(this,mt,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
11
11
  ${d}
12
- Retrying request.`),await S(this,At,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw d}if(s.ok)return s;let a=await s.clone().text(),l=`Server returned an error:
12
+ Retrying request.`),await y(this,Rt,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw d}if(s.ok)return s;let a=await s.clone().text(),l=`Server returned an error:
13
13
  Code: ${s.status} (${s.statusText})
14
14
  Body: ${a}
15
- `;if(i<S(this,pt,"f"))return await S(this,At,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw new ve(l,{ok:s.ok,status:s.status,statusText:s.statusText,headers:Ae(s.headers)})};var Zi;(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"})(Zi||(Zi={}));function wn(){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 Sr={};es(Sr,{backoff:()=>to,chain:()=>eo,conditionalDelay:()=>Di,defaultStrategy:()=>Qi,maxAttempts:()=>Ua,once:()=>Ii,throttle:()=>Ma,timeout:()=>Li});var Fa=5*60*1e3;function Qi(){return eo(Di(Ii(),1e3),to(1e3,1.2),Li(Fa))}function Ii(){let t=!0;return async()=>t?(t=!1,!0):!1}function Di(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(o=>setTimeout(o,e))}}function Ua(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:
16
- Request ID: ${$(n)}
15
+ `;if(i<y(this,mt,"f"))return await y(this,Rt,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw new Pe(l,{ok:s.ok,status:s.status,statusText:s.statusText,headers:Be(s.headers)})};var ro;(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"})(ro||(ro={}));function An(){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 Fr={};ls(Fr,{backoff:()=>ao,chain:()=>co,conditionalDelay:()=>oo,defaultStrategy:()=>no,maxAttempts:()=>Ga,once:()=>io,throttle:()=>za,timeout:()=>so});var $a=5*60*1e3;function no(){return co(oo(io(),1e3),ao(1e3,1.2),so($a))}function io(){let t=!0;return async()=>t?(t=!1,!0):!1}function oo(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(o=>setTimeout(o,e))}}function Ga(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:
16
+ Request ID: ${G(n)}
17
17
  Request status: ${i}
18
- `)}}function Ma(t){return()=>new Promise(e=>setTimeout(e,t))}function Li(t){let e=Date.now()+t;return async(r,n,i)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
19
- Request ID: ${$(n)}
18
+ `)}}function za(t){return()=>new Promise(e=>setTimeout(e,t))}function so(t){let e=Date.now()+t;return async(r,n,i)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
19
+ Request ID: ${G(n)}
20
20
  Request status: ${i}
21
- `)}}function to(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}function eo(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}async function gn(t,e,r,n,i,o){var s;let a=[new TextEncoder().encode("request_status"),r],l=i??await((s=t.createReadStateRequest)===null||s===void 0?void 0:s.call(t,{paths:[a]})),d=await t.readState(e,{paths:[a]},void 0,l);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let c=await ri.create({certificate:d.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:o}),f=be(c.lookup([...a,new TextEncoder().encode("status")])),m;switch(typeof f>"u"?m=vt.Unknown:m=new TextDecoder().decode(f),m){case vt.Replied:return be(c.lookup([...a,"reply"]));case vt.Received:case vt.Unknown:case vt.Processing:return await n(e,r,m),gn(t,e,r,n,l);case vt.Rejected:{let g=new Uint8Array(be(c.lookup([...a,"reject_code"])))[0],h=new TextDecoder().decode(be(c.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
22
- Request ID: ${$(r)}
23
- Reject code: ${g}
24
- Reject text: ${h}
25
- `)}case vt.Done:throw new Error(`Call was marked as done but we never saw the reply:
26
- Request ID: ${$(r)}
27
- `)}throw new Error("unreachable")}var ro=({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=i,s=t.Record({network:e}),a=t.Nat64,l=t.Vec(a),d=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),f=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),m=t.Record({height:t.Nat32,value:i,outpoint:f}),g=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:c,utxos:t.Vec(m)}),h=t.Record({transaction:t.Vec(t.Nat8),network:e}),y=t.Principal,A=t.Record({canister_id:y,num_requested_changes:t.Opt(t.Nat64)}),R=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),F=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:R,details:F}),U=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}),x=t.Record({canister_id:y}),D=t.Variant({controllers:t.Null,public:t.Null}),it=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:D,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),j=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:it,query_stats:t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),Y=t.Record({canister_id:y}),et=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(D),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),ot=t.Record({settings:t.Opt(et),sender_canister_version:t.Opt(t.Nat64)}),yt=t.Record({canister_id:y}),ct=t.Record({canister_id:y}),Ht=t.Record({canister_id:y}),Bt=t.Variant({secp256k1:t.Null}),Dt=t.Record({key_id:t.Record({name:t.Text,curve:Bt}),canister_id:t.Opt(y),derivation_path:t.Vec(t.Vec(t.Nat8))}),$e=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),w=t.Record({canister_id:y}),p=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),_=t.Record({canister_log_records:t.Vec(p)}),b=t.Record({value:t.Text,name:t.Text}),B=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(b)}),N=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:B})],[B],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(b)}),P=t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({wasm_memory_persistence:t.Opt(t.Variant({keep:t.Null,replace:t.Null})),skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),C=t.Record({hash:t.Vec(t.Nat8)}),O=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:P,chunk_hashes_list:t.Vec(C),target_canister:y,store_canister:t.Opt(y),sender_canister_version:t.Opt(t.Nat64)}),k=t.Vec(t.Nat8),M=t.Record({arg:t.Vec(t.Nat8),wasm_module:k,mode:P,canister_id:y,sender_canister_version:t.Opt(t.Nat64)}),q=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),L=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_proposed_total:t.Nat64}),H=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(L)})),wt=t.Record({settings:t.Opt(et),specified_id:t.Opt(y),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),lt=t.Record({canister_id:y}),Lt=t.Record({canister_id:y,amount:t.Nat}),te=t.Vec(t.Nat8),We=t.Record({key_id:t.Record({name:t.Text,curve:Bt}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),Ge=t.Record({signature:t.Vec(t.Nat8)}),$r=t.Record({canister_id:y}),Wr=t.Record({canister_id:y}),Gr=t.Record({canister_id:y}),zr=t.Vec(C),ze=t.Record({canister_id:y,sender_canister_version:t.Opt(t.Nat64)}),Ye=t.Record({canister_id:t.Principal,settings:et,sender_canister_version:t.Opt(t.Nat64)}),ge=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),Je=C;return t.Service({bitcoin_get_balance:t.Func([n],[o],[]),bitcoin_get_current_fee_percentiles:t.Func([s],[l],[]),bitcoin_get_utxos:t.Func([d],[g],[]),bitcoin_send_transaction:t.Func([h],[],[]),canister_info:t.Func([A],[U],[]),canister_status:t.Func([x],[j],[]),clear_chunk_store:t.Func([Y],[],[]),create_canister:t.Func([ot],[yt],[]),delete_canister:t.Func([ct],[],[]),deposit_cycles:t.Func([Ht],[],[]),ecdsa_public_key:t.Func([Dt],[$e],[]),fetch_canister_logs:t.Func([w],[_],["query"]),http_request:t.Func([N],[B],[]),install_chunked_code:t.Func([O],[],[]),install_code:t.Func([M],[],[]),node_metrics_history:t.Func([q],[H],[]),provisional_create_canister_with_cycles:t.Func([wt],[lt],[]),provisional_top_up_canister:t.Func([Lt],[],[]),raw_rand:t.Func([],[te],[]),sign_with_ecdsa:t.Func([We],[Ge],[]),start_canister:t.Func([$r],[],[]),stop_canister:t.Func([Wr],[],[]),stored_chunks:t.Func([Gr],[zr],[]),uninstall_code:t.Func([ze],[],[]),update_settings:t.Func([Ye],[],[]),upload_chunk:t.Func([ge],[Je],[])})};var Br=class extends rt{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(`
28
- `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}},_n=class extends Br{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=sr[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},xn=class extends Br{constructor(e,r,n,i){super(e,r,"update",Object.assign({"Request ID":$(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}},at=Symbol.for("ic-agent-metadata"),Zt=class t{constructor(e){this[at]=Object.freeze(e)}static agentOf(e){return e[at].config.agent}static interfaceOf(e){return e[at].service}static canisterIdOf(e){return v.from(e[at].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"?v.fromText(r.canisterId):r.canisterId;await no(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]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await no(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:_e});class i extends t{constructor(s){if(!s.canisterId)throw new rt(`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"?v.fromText(s.canisterId):s.canisterId;super({config:Object.assign(Object.assign(Object.assign({},oo),s),{canisterId:a}),service:n});for(let[l,d]of n._fields)r?.httpDetails&&d.annotations.push(bn),this[l]=Va(this,l,d,s.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new rt(`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 Rr(t,e){let r=_e.decode(t,io.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var oo={pollingStrategyFactory:Sr.defaultStrategy},bn="http-details";function Va(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(s,...a)=>{var l,d;s=Object.assign(Object.assign({},s),(d=(l=t[at].config).queryTransform)===null||d===void 0?void 0:d.call(l,e,a,Object.assign(Object.assign({},t[at].config),s)));let c=s.agent||t[at].config.agent||wn(),f=v.from(s.canisterId||t[at].config.canisterId),m=_e.encode(r.argTypes,a),g=await c.query(f,{methodName:e,arg:m,effectiveCanisterId:s.effectiveCanisterId});switch(g.status){case"rejected":throw new _n(f,e,g);case"replied":return r.annotations.includes(bn)?{httpDetails:g.httpDetails,result:Rr(r.retTypes,g.reply.arg)}:Rr(r.retTypes,g.reply.arg)}}:i=async(s,...a)=>{var l,d;s=Object.assign(Object.assign({},s),(d=(l=t[at].config).callTransform)===null||d===void 0?void 0:d.call(l,e,a,Object.assign(Object.assign({},t[at].config),s)));let c=s.agent||t[at].config.agent||wn(),{canisterId:f,effectiveCanisterId:m,pollingStrategyFactory:g}=Object.assign(Object.assign(Object.assign({},oo),t[at].config),s),h=v.from(f),y=m!==void 0?v.from(m):h,A=_e.encode(r.argTypes,a),{requestId:R,response:F}=await c.call(h,{methodName:e,arg:A,effectiveCanisterId:y});if(!F.ok||F.body)throw new xn(h,e,R,F);let E=g(),U=await gn(c,y,R,E,n),x=r.annotations.includes(bn);if(U!==void 0)return x?{httpDetails:F,result:Rr(r.retTypes,U)}:Rr(r.retTypes,U);if(r.retTypes.length===0)return x?{httpDetails:F,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 no(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:v.from(t.effectiveCanisterId)};let i=n[0],o=v.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(o=v.from(i.canister_id)),{effectiveCanisterId:o}}return Zt.createActor(ro,Object.assign(Object.assign(Object.assign({},t),{canisterId:v.fromHex("")}),{callTransform:e,queryTransform:e}))}var Pr=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},jt=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)},Nr,Or,he,me;function so(t){return t!==null&&typeof t=="object"}var Qt=class t{constructor(e){if(Nr.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");Pr(this,Nr,e,"f"),Pr(this,Or,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=gt(e);return this.fromRaw(r)}else if(so(e)){let r=e;if(so(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw(Ie(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=le(e,zt).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=Re(e,zt);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return jt(this,Nr,"f")}get derKey(){return jt(this,Or,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Nr=new WeakMap,Or=new WeakMap;Qt.RAW_KEY_LENGTH=32;var It=class t extends Ct{constructor(e,r){super(),he.set(this,void 0),me.set(this,void 0),Pr(this,he,Qt.from(e),"f"),Pr(this,me,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=Vt.utils.randomPrivateKey()),Qe(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=Vt.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(Qt.fromDer(gt(r)),gt(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(Qt.fromRaw(e),r)}static fromSecretKey(e){let r=Vt.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[$(jt(this,he,"f").toDer()),$(jt(this,me,"f"))]}getKeyPair(){return{secretKey:jt(this,me,"f"),publicKey:jt(this,he,"f")}}getPublicKey(){return jt(this,he,"f")}async sign(e){let r=new Uint8Array(e),n=Jn(Vt.sign(r,jt(this,me,"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=gt(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return Vt.verify(o,i,s)}};he=new WeakMap,me=new WeakMap;var En=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};function ao(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 En("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 Ce=class t extends Ct{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=ao(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=ao(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 ye=Xe(Xn());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},ke=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)},qt,Cr=class{constructor(e){qt.set(this,void 0),qa(this,qt,e,"f")}get rawKey(){return ke(this,qt,"f").rawKey}get derKey(){return ke(this,qt,"f").derKey}toDer(){return ke(this,qt,"f").toDer()}getPublicKey(){return ke(this,qt,"f")}getPrincipal(){return v.from(ke(this,qt,"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.")}};qt=new WeakMap;var Ha=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},$a=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)},Wa=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},kr,Ga=new TextEncoder().encode("ic-request-auth-delegation"),za=new TextEncoder().encode(`
29
- ic-request`);function Tn(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return gt(t)}var we=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return ye.value.map(Object.assign({pubkey:ye.value.bytes(this.pubkey),expiration:ye.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:ye.value.array(this.targets.map(e=>ye.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:$(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};async function Ya(t,e,r,n){let i=new we(e.toDer(),BigInt(+r)*BigInt(1e6),n),o=new Uint8Array([...Ga,...new Uint8Array(Ft(i))]),s=await t.sign(o);return{delegation:i,signature:s}}var Fe=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 Ya(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:l,expiration:d,targets:c}=s;if(c!==void 0&&!Array.isArray(c))throw new Error("Invalid targets.");return{delegation:new we(Tn(l),BigInt("0x"+d),c&&c.map(f=>{if(typeof f!="string")throw new Error("Invalid target.");return v.fromHex(f)})),signature:Tn(a)}});return new this(i,Tn(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:$(r.pubkey)},i&&{targets:i.map(o=>o.toHex())}),signature:$(n)}}),publicKey:$(this.publicKey)}}},Ue=class extends Ct{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=Wa(e,["body"]),i=await Ft(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...za,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},Me=class t extends Cr{constructor(e,r){super(e),kr.set(this,void 0),Ha(this,kr,r,"f")}get delegation(){return $a(this,kr,"f")}static fromDelegation(e,r){return new t(e,r)}};kr=new WeakMap;function co(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"?v.fromText(i):i)):r.push(typeof n=="string"?v.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 l of s.targets)if(l.toText()===o){a=!1;break}if(a)return!1}}return!0}var Ja=Xe(ns());var lo;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(lo||(lo={}));var uo=["mousedown","mousemove","keydown","touchstart","wheel"],Ke=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),uo.forEach(function(a){document.addEventListener(a,o,!0)});let s=(a,l)=>{let d;return(...c)=>{let f=this,m=function(){d=void 0,a.apply(f,c)};clearTimeout(d),d=window.setTimeout(m,l)}};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);uo.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 Xa=(t,e)=>e.some(r=>t instanceof r),fo,po;function Za(){return fo||(fo=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Qa(){return po||(po=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var ho=new WeakMap,vn=new WeakMap,mo=new WeakMap,An=new WeakMap,Rn=new WeakMap;function Ia(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",o),t.removeEventListener("error",s)},o=()=>{r(St(t.result)),i()},s=()=>{n(t.error),i()};t.addEventListener("success",o),t.addEventListener("error",s)});return e.then(r=>{r instanceof IDBCursor&&ho.set(r,t)}).catch(()=>{}),Rn.set(e,t),e}function Da(t){if(vn.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)});vn.set(t,e)}var Sn={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return vn.get(t);if(e==="objectStoreNames")return t.objectStoreNames||mo.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return St(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){Sn=t(Sn)}function La(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Fr(this),e,...r);return mo.set(n,e.sort?e.sort():[e]),St(n)}:Qa().includes(t)?function(...e){return t.apply(Fr(this),e),St(ho.get(this))}:function(...e){return St(t.apply(Fr(this),e))}}function tc(t){return typeof t=="function"?La(t):(t instanceof IDBTransaction&&Da(t),Xa(t,Za())?new Proxy(t,Sn):t)}function St(t){if(t instanceof IDBRequest)return Ia(t);if(An.has(t))return An.get(t);let e=tc(t);return e!==t&&(An.set(t,e),Rn.set(e,t)),e}var Fr=t=>Rn.get(t);function go(t,e,{blocked:r,upgrade:n,blocking:i,terminated:o}={}){let s=indexedDB.open(t,e),a=St(s);return n&&s.addEventListener("upgradeneeded",l=>{n(St(s.result),l.oldVersion,l.newVersion,St(s.transaction),l)}),r&&s.addEventListener("blocked",l=>r(l.oldVersion,l.newVersion,l)),a.then(l=>{o&&l.addEventListener("close",()=>o()),i&&l.addEventListener("versionchange",d=>i(d.oldVersion,d.newVersion,d))}).catch(()=>{}),a}var ec=["get","getKey","getAll","getAllKeys","count"],rc=["put","add","delete","clear"],Bn=new Map;function wo(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Bn.get(e))return Bn.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=rc.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||ec.includes(r)))return;let o=async function(s,...a){let l=this.transaction(s,i?"readwrite":"readonly"),d=l.store;return n&&(d=d.index(a.shift())),(await Promise.all([d[r](...a),i&&l.done]))[0]};return Bn.set(e,o),o}yo(t=>({...t,get:(e,r,n)=>wo(e,r)||t.get(e,r,n),has:(e,r)=>!!wo(e,r)||t.has(e,r)}));var _o="auth-client-db",xo="ic-keyval",nc=async(t=_o,e=xo,r)=>(Ur&&(localStorage!=null&&localStorage.getItem(ht))&&(localStorage.removeItem(ht),localStorage.removeItem(mt)),await go(t,r,{upgrade:n=>{n.objectStoreNames,n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function ic(t,e,r){return await t.get(e,r)}async function oc(t,e,r,n){return await t.put(e,n,r)}async function sc(t,e,r){return await t.delete(e,r)}var Ve=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=_o,storeName:n=xo,version:i=bo}=e??{},o=await nc(r,n,i);return new t(o,n)}async set(e,r){return await oc(this._db,this._storeName,e,r)}async get(e){var r;return(r=await ic(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await sc(this._db,this._storeName,e)}};var ac=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},cc=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)},Mr,mt="identity",ht="delegation",Eo="iv",bo=1,Ur=typeof window<"u",je=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}},qe=class{constructor(e){Mr.set(this,void 0),ac(this,Mr,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}Ve.create(cc(this,Mr,"f")).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)}};Mr=new WeakMap;var lc="https://identity.ic0.app",uc="#authorize",Nn="ECDSA",On="Ed25519",dc=500,fc="UserInterrupt",Kr=class{constructor(e,r,n,i,o,s,a,l){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=o,this._createOptions=s,this._idpWindow=a,this._eventHandler=l,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let o=(r=e.storage)!==null&&r!==void 0?r:new qe,s=(n=e.keyType)!==null&&n!==void 0?n:Nn,a=null;if(e.identity)a=e.identity;else{let f=await o.get(mt);if(!f&&Ur)try{let m=new je,g=await m.get(ht),h=await m.get(mt);g&&h&&s===Nn&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await o.set(ht,g),await o.set(mt,h),f=g,await m.remove(ht),await m.remove(mt))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(f)try{typeof f=="object"?s===On&&typeof f=="string"?a=await It.fromJSON(f):a=await Ce.fromKeyPair(f):typeof f=="string"&&(a=It.fromJSON(f))}catch{}}let l=new kt,d=null;if(a)try{let f=await o.get(ht);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?l=e.identity:f&&(d=Fe.fromJSON(f),co(d)?"toDer"in a?l=Me.fromDelegation(a,d):l=Ue.fromDelegation(a,d):(await Pn(o),a=null))}catch(f){console.error(f),await Pn(o),a=null}let c;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?c=void 0:(d||e.identity)&&(c=Ke.create(e.idleOptions)),a||(s===On?(a=await It.generate(),await o.set(mt,JSON.stringify(a.toJSON()))):(e.storage&&s===Nn&&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 '${On}' as the key type, as it can serialize to a string`),a=await Ce.generate(),await o.set(mt,a.getKeyPair()))),new this(l,a,d,o,c,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(d=>({delegation:new we(d.delegation.pubkey,d.delegation.expiration,d.delegation.targets),signature:d.signature.buffer})),s=Fe.fromDelegations(o,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=s,"toDer"in a?this._identity=Me.fromDelegation(a,this._chain):this._identity=Ue.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let l=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!l?.disableIdle&&(this.idleManager=Ke.create(l),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(ht,JSON.stringify(this._chain.toJSON())),r?.(e)}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())||lc);a.hash=uc,(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 l=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(fc,e?.onError):setTimeout(l,dc))};l()}_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 l=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(o=r?.derivationOrigin)===null||o===void 0?void 0:o.toString()},r?.customValues);(s=this._idpWindow)===null||s===void 0||s.postMessage(l,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(l){this._handleFailure(l.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 Pn(this._storage),this._identity=new kt,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};async function Pn(t){await t.remove(mt),await t.remove(ht),await t.remove(Eo)}var Vr=()=>Kr.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var To=async({data:t})=>{try{return await er(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var Cn=async t=>{let{data:e,version:r,description:n}=t;return{description:z(n),data:await oi(e),version:z(r)}},kn=t=>{let{version:e}=t;return{version:z(e)}},He=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:o,...s}=t;return{key:e,description:W(i),owner:r.toText(),data:await er(o),version:W(n),...s}};var Ao=t=>{if(K(t))return z();switch(t.matcher){case"equal":return z({Equal:t.timestamp});case"greaterThan":return z({GreaterThan:t.timestamp});case"lessThan":return z({LessThan:t.timestamp});case"between":return z({Between:[t.timestamps.start,t.timestamps.end]});default:throw new Error("Invalid list matcher for timestamp",t)}},jr=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:K(t)?[]:[{key:z(t.key),description:z(t.description),created_at:Ao(t.createdAt),updated_at:Ao(t.updatedAt)}],paginate:z(K(e)?void 0:{start_after:z(e.startAfter),limit:z(K(e.limit)?void 0:BigInt(e.limit))}),order:z(K(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:z(K(n)?void 0:typeof n=="string"?v.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({version:t.Opt(t.Nat64)}),s=t.Variant({Db:t.Null,Storage:t.Null}),a=t.Record({version:t.Opt(t.Nat64)}),l=t.Record({cycles:t.Nat,destination_id:t.Principal}),d=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}),c=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),f=t.Record({key:d,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,c)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),m=t.Record({derivation_origin:t.Opt(t.Text)}),g=t.Record({internet_identity:t.Opt(m)}),h=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),y=t.Record({max_memory_size:t.Opt(h)}),A=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),R=t.Variant({Deny:t.Null,Allow:t.Null}),F=t.Record({status_code:t.Nat16,location:t.Text}),E=t.Record({iframe:t.Opt(A),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(h),raw_access:t.Opt(R),redirects:t.Opt(t.Vec(t.Tuple(t.Text,F)))}),U=t.Record({db:t.Opt(y),authentication:t.Opt(g),storage:E}),x=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),D=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)}),it=t.Variant({Heap:t.Null,Stable:t.Null}),j=t.Record({memory:it,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}),Y=t.Variant({Callback:t.Record({token:j,callback:t.Func([],[],["query"])})}),et=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(Y),status_code:t.Nat16}),ot=t.Record({token:t.Opt(j),body:t.Vec(t.Nat8)}),yt=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}),ct=t.Record({batch_id:t.Nat}),Ht=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),Bt=t.Record({field:Ht,desc:t.Bool}),Dt=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),$e=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(Dt),description:t.Opt(t.Text),created_at:t.Opt(Dt)}),w=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),p=t.Record({order:t.Opt(Bt),owner:t.Opt(t.Principal),matcher:t.Opt($e),paginate:t.Opt(w)}),_=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,f)),items_length:t.Nat64}),b=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),B=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,x)),items_length:t.Nat64}),N=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),P=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(it),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:N,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:N}),C=t.Record({stable:t.Nat64,heap:t.Nat64}),O=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:n,expires_at:t.Opt(t.Nat64)}),k=t.Record({controller:O,controllers:t.Vec(t.Principal)}),M=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),q=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(it),max_size:t.Opt(t.Nat),read:N,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:N}),L=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),H=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,a],[],[]),deposit_cycles:t.Func([l],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(f)],["query"]),get_auth_config:t.Func([],[t.Opt(g)],["query"]),get_config:t.Func([],[U],[]),get_db_config:t.Func([],[t.Opt(y)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(x)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(f)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(x)))],["query"]),get_storage_config:t.Func([],[E],["query"]),http_request:t.Func([D],[et],["query"]),http_request_streaming_callback:t.Func([j],[ot],["query"]),init_asset_upload:t.Func([yt],[ct],[]),list_assets:t.Func([t.Text,p],[_],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,i))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,b))],["query"]),list_docs:t.Func([t.Text,p],[B],["query"]),list_rules:t.Func([s],[t.Vec(t.Tuple(t.Text,P))],["query"]),memory_size:t.Func([],[C],["query"]),set_auth_config:t.Func([g],[],[]),set_controllers:t.Func([k],[t.Vec(t.Tuple(t.Principal,i))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([y],[],[]),set_doc:t.Func([t.Text,t.Text,M],[x],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,M))],[t.Vec(t.Tuple(t.Text,x))],[]),set_rule:t.Func([s,t.Text,q],[],[]),set_storage_config:t.Func([E],[],[]),upload_asset_chunk:t.Func([L],[H],[]),version:t.Func([],[t.Text],["query"])})};var So=async({satelliteId:t,idlFactory:e,identity:r,fetch:n,container:i})=>{let s=V(i)&&i!==!1?i===!0?ne:i:"https://icp-api.io",a=new Pe({identity:r,host:s,...n&&{fetch:n}});return V(i)&&await a.fetchRootKey(),Zt.createActor(e,{agent:a,canisterId:t})};var Ro=({satelliteId:t,container:e})=>{let{satelliteId:r}=Fn({satelliteId:t}),{container:n}=Un({container:e});if(V(n)&&n!==!1){let{host:i,protocol:o}=new URL(n===!0?ne:n);return`${o}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},Fn=({satelliteId:t})=>V(t)?{satelliteId:t}:_t.getInstance().get()??{satelliteId:void 0},Un=({container:t})=>V(t)?{container:t}:_t.getInstance().get()??{container:void 0};var I=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=Fn({satelliteId:t});tr(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=Un({container:e});return So({satelliteId:n,container:i,idlFactory:vo,...r})};var Bo=async({collection:t,key:e,satellite:r})=>{let n=await I(r),i=W(await n.get_doc(t,e));if(!K(i))return He({doc:i,key:e})},No=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await I(e),n=t.map(({collection:s,key:a})=>[s,a]),i=await r(n),o=[];for(let[s,a]of i){let l=W(a);o.push(V(l)?await He({key:s,doc:l}):void 0)}return o},Oo=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await I(r),{key:i}=e,o=await Cn(e),s=await n(t,i,o);return await He({key:i,doc:s})},Po=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await I(e),n=[];for(let{collection:s,doc:a}of t){let{key:l}=a;n.push([s,l,await Cn(a)])}let i=await r(n),o=[];for(let[s,a]of i)o.push(await He({key:s,doc:a}));return o},Co=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await I(r),{key:i}=e;return n(t,i,kn(e))},ko=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await I(e),n=t.map(({collection:i,doc:o})=>[i,o.key,kn(o)]);await r(n)},Fo=async({collection:t,filter:e,satellite:r})=>{let n=await I(r),{items:i,items_page:o,items_length:s,matches_length:a,matches_pages:l}=await n.list_docs(t,jr(e)),d=[];for(let[c,f]of i){let{data:m,owner:g,description:h,version:y,...A}=f;d.push({key:c,description:W(h),owner:g.toText(),data:await To({data:m}),version:W(y),...A})}return{items:d,items_length:s,items_page:W(o),matches_length:a,matches_pages:W(l)}};var Z=t=>t!==void 0?t:qr()??new kt;var Uo=async({satellite:t,...e})=>{let r=Z(t?.identity);return Bo({...e,satellite:{...t,identity:r}})},df=async({satellite:t,...e})=>{let r=Z(t?.identity);return No({...e,satellite:{...t,identity:r}})},Mo=async({satellite:t,...e})=>{let r=Z(t?.identity);return Oo({...e,satellite:{...t,identity:r}})},ff=async({satellite:t,...e})=>{let r=Z(t?.identity);return Po({...e,satellite:{...t,identity:r}})},pf=async({satellite:t,...e})=>{let r=Z(t?.identity);return Co({...e,satellite:{...t,identity:r}})},hf=async({satellite:t,...e})=>{let r=Z(t?.identity);return ko({...e,satellite:{...t,identity:r}})},mf=async({satellite:t,filter:e,...r})=>{let n=Z(t?.identity);return Fo({...r,filter:e??{},satellite:{...t,identity:n}})};var Ko=async t=>{let e=qr();if(K(e))throw new Error("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=await Uo({collection:"#user",key:r});return K(n)?await pc({userId:r,provider:t}):n},pc=async({userId:t,...e})=>Mo({collection:"#user",doc:{key:t,data:e}});var Rt,Mn=async t=>{if(Rt=Rt??await Vr(),!(await Rt?.isAuthenticated()??!1))return;let r=await Ko(t);Ot.getInstance().set(r)},hc=async t=>new Promise(async(e,r)=>{Rt=Rt??await Vr();let n=t?.provider??new rr({});await Rt.login({onSuccess:async()=>{await Mn(n.id),e()},onError:i=>r(i),maxTimeToLive:t?.maxTimeToLive??ai,allowPinAuthentication:t?.allowPin??ci,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),Kn=async()=>{await Rt?.logout(),Rt=void 0,Ot.getInstance().reset()},qr=()=>Rt?.getIdentity(),mc=async()=>(Rt??await Vr()).getIdentity();var Vo=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{Lr({message:"junoSignOutAuthTimer"}),await Kn()};return r.onmessage=async({data:i})=>{let{msg:o,data:s}=i;switch(o){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":Lr({message:"junoDelegationRemainingTime",detail:s?.authRemainingTime});return}},Ot.getInstance().subscribe(i=>{if(K(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var jo=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},qo=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};var yc=t=>t==null,wc=t=>!yc(t),Hr=t=>wc(t)?[t]:[],gc=()=>typeof window<"u",Ho=async({asset:{data:t,filename:e,collection:r,headers:n,token:i,fullPath:o,encoding:s,description:a},actor:l,init_asset_upload:d})=>{let{batch_id:c}=await d({collection:r,full_path:o,name:e,token:Hr(i),encoding_type:Hr(s),description:Hr(a)}),f=19e5,m=[],g=gc()?new Blob([await t.arrayBuffer()]):t,h=0n;for(let R=0;R<g.size;R+=f){let F=g.slice(R,R+f);m.push({batchId:c,chunk:F,actor:l,orderId:h}),h++}let y=[];for await(let R of _c({uploadChunks:m}))y=[...y,...R];let A=n.find(([R,F])=>R.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await l.commit_asset_upload({batch_id:c,chunk_ids:y.map(({chunk_id:R})=>R),headers:[...n,...A||[]]})};async function*_c({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(i=>xc(i)))}}var xc=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:Hr(n)});var $o=async({satellite:t,...e})=>{let r=await I(t);await Ho({actor:r,asset:e,init_asset_upload:async i=>await r.init_asset_upload(i)})},Wo=async({collection:t,satellite:e,filter:r})=>{let n=await I(e),{items:i,items_length:o,items_page:s,matches_length:a,matches_pages:l}=await n.list_assets(t,jr(r));return{items:i.map(([d,c])=>c),items_length:o,items_page:W(s),matches_length:a,matches_pages:W(l)}},Go=async({collection:t,fullPath:e,satellite:r})=>(await I(r)).del_asset(t,e),zo=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await I(e),n=t.map(({collection:i,fullPath:o})=>[i,o]);await r(n)},Yo=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await I(r);return W(await n(t,e))},Jo=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await I(e),n=t.map(({collection:o,fullPath:s})=>[o,s]);return(await r(n)).map(([o,s])=>W(s))};var Xo=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var Jf=async t=>Zo(t),Xf=async t=>Zo({filename:t.data.name,...t}),Zo=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:o,satellite:s,encoding:a,description:l})=>{let d=Z(s?.identity),c=decodeURI(t),f=i??`/${r}/${c}`,m={...s,identity:d};return await $o({data:e,filename:c,collection:r,token:o,headers:n,fullPath:f,encoding:a,satellite:m,description:l}),{downloadUrl:Qo({satellite:m,assetKey:{fullPath:f,token:o}}),fullPath:f,name:c}},Zf=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:Z(e?.identity)},{items:i,...o}=await Wo({collection:t,satellite:n,filter:r??{}}),s=i.map(({key:{full_path:a,token:l,name:d,owner:c,description:f},headers:m,encodings:g,created_at:h,updated_at:y})=>{let A=W(l);return{fullPath:a,description:W(f),name:d,downloadUrl:Qo({satellite:n,assetKey:{fullPath:a,token:A}}),token:A,headers:m,encodings:g.reduce((R,[F,{modified:E,sha256:U,total_length:x}])=>({...R,[F]:{modified:E,sha256:Xo(U),total_length:x}}),{}),owner:c.toText(),created_at:h,updated_at:y}});return{items:s,assets:s,...o}},Qf=async({collection:t,fullPath:e,satellite:r})=>Go({collection:t,fullPath:e,satellite:{...r,identity:Z(r?.identity)}}),If=async({assets:t,satellite:e})=>zo({assets:t,satellite:{...e,identity:Z(e?.identity)}}),Df=async({satellite:t,...e})=>{let r=Z(t?.identity);return Yo({...e,satellite:{...t,identity:r}})},Lf=async({satellite:t,...e})=>{let r=Z(t?.identity);return Jo({...e,satellite:{...t,identity:r}})},Qo=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:Z(r?.identity)};return`${Ro(n)}${t}${V(e)?`?token=${e}`:""}`};var bc=t=>{let e=t?.satelliteId??jo();tr(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??qo();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},ap=async t=>Ec(t),Ec=async t=>{let e=bc(t);_t.getInstance().set(e),await Mn();let r=e.workers?.auth!==void 0?Vo(e.workers.auth):void 0;return[...r?[r]:[]]},cp=t=>Ot.getInstance().subscribe(t);export{rr as InternetIdentityProvider,pi as NFIDProvider,cp as authSubscribe,Qf as deleteAsset,pf as deleteDoc,If as deleteManyAssets,hf as deleteManyDocs,Qo as downloadUrl,Df as getAsset,Uo as getDoc,Lf as getManyAssets,df as getManyDocs,ap as initJuno,Ec as initSatellite,Zf as listAssets,mf as listDocs,Mo as setDoc,ff as setManyDocs,hc as signIn,Kn as signOut,mc as unsafeIdentity,Jf as uploadBlob,Xf as uploadFile};
21
+ `)}}function ao(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}function co(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}async function vn(t,e,r,n,i,o){var s;let a=[new TextEncoder().encode("request_status"),r],l=i??await((s=t.createReadStateRequest)===null||s===void 0?void 0:s.call(t,{paths:[a]})),d=await t.readState(e,{paths:[a]},void 0,l);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let c=await li.create({certificate:d.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:o}),f=Re(c.lookup([...a,new TextEncoder().encode("status")])),h;switch(typeof f>"u"?h=Ot.Unknown:h=new TextDecoder().decode(f),h){case Ot.Replied:return{reply:Re(c.lookup([...a,"reply"])),certificate:c};case Ot.Received:case Ot.Unknown:case Ot.Processing:return await n(e,r,h),vn(t,e,r,n,l);case Ot.Rejected:{let w=new Uint8Array(Re(c.lookup([...a,"reject_code"])))[0],m=new TextDecoder().decode(Re(c.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
22
+ Request ID: ${G(r)}
23
+ Reject code: ${w}
24
+ Reject text: ${m}
25
+ `)}case Ot.Done:throw new Error(`Call was marked as done but we never saw the reply:
26
+ Request ID: ${G(r)}
27
+ `)}throw new Error("unreachable")}var lo=({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=i,s=t.Record({network:e}),a=t.Nat64,l=t.Vec(a),d=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),f=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),h=t.Record({height:t.Nat32,value:i,outpoint:f}),w=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:c,utxos:t.Vec(h)}),m=t.Record({transaction:t.Vec(t.Nat8),network:e}),g=t.Principal,E=t.Record({canister_id:g,num_requested_changes:t.Opt(t.Nat64)}),R=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),B=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}),A=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:R,details:B}),F=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(A),total_num_changes:t.Nat64}),b=t.Record({canister_id:g}),M=t.Variant({controllers:t.Null,public:t.Null}),X=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:M,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),K=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:X,query_stats:t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),H=t.Record({canister_id:g}),nt=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(M),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),st=t.Record({settings:t.Opt(nt),sender_canister_version:t.Opt(t.Nat64)}),gt=t.Record({canister_id:g}),lt=t.Record({canister_id:g}),Gt=t.Record({canister_id:g}),Pt=t.Variant({secp256k1:t.Null}),re=t.Record({key_id:t.Record({name:t.Text,curve:Pt}),canister_id:t.Opt(g),derivation_path:t.Vec(t.Vec(t.Nat8))}),Ze=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),_=t.Record({canister_id:g}),p=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),x=t.Record({canister_log_records:t.Vec(p)}),T=t.Record({value:t.Text,name:t.Text}),O=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(T)}),N=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:O})],[O],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(T)}),C=t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({wasm_memory_persistence:t.Opt(t.Variant({keep:t.Null,replace:t.Null})),skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),k=t.Record({hash:t.Vec(t.Nat8)}),P=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:C,chunk_hashes_list:t.Vec(k),target_canister:g,store_canister:t.Opt(g),sender_canister_version:t.Opt(t.Nat64)}),U=t.Vec(t.Nat8),V=t.Record({arg:t.Vec(t.Nat8),wasm_module:U,mode:C,canister_id:g,sender_canister_version:t.Opt(t.Nat64)}),W=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),tt=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_proposed_total:t.Nat64}),$=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(tt)})),_t=t.Record({settings:t.Opt(nt),specified_id:t.Opt(g),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),ut=t.Record({canister_id:g}),ne=t.Record({canister_id:g,amount:t.Nat}),ie=t.Vec(t.Nat8),Qe=t.Record({key_id:t.Record({name:t.Text,curve:Pt}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),Ie=t.Record({signature:t.Vec(t.Nat8)}),Zr=t.Record({canister_id:g}),Qr=t.Record({canister_id:g}),Ir=t.Record({canister_id:g}),Dr=t.Vec(k),De=t.Record({canister_id:g,sender_canister_version:t.Opt(t.Nat64)}),Le=t.Record({canister_id:t.Principal,settings:nt,sender_canister_version:t.Opt(t.Nat64)}),Ae=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),tr=k;return t.Service({bitcoin_get_balance:t.Func([n],[o],[]),bitcoin_get_current_fee_percentiles:t.Func([s],[l],[]),bitcoin_get_utxos:t.Func([d],[w],[]),bitcoin_send_transaction:t.Func([m],[],[]),canister_info:t.Func([E],[F],[]),canister_status:t.Func([b],[K],[]),clear_chunk_store:t.Func([H],[],[]),create_canister:t.Func([st],[gt],[]),delete_canister:t.Func([lt],[],[]),deposit_cycles:t.Func([Gt],[],[]),ecdsa_public_key:t.Func([re],[Ze],[]),fetch_canister_logs:t.Func([_],[x],["query"]),http_request:t.Func([N],[O],[]),install_chunked_code:t.Func([P],[],[]),install_code:t.Func([V],[],[]),node_metrics_history:t.Func([W],[$],[]),provisional_create_canister_with_cycles:t.Func([_t],[ut],[]),provisional_top_up_canister:t.Func([ne],[],[]),raw_rand:t.Func([],[ie],[]),sign_with_ecdsa:t.Func([Qe],[Ie],[]),start_canister:t.Func([Zr],[],[]),stop_canister:t.Func([Qr],[],[]),stored_chunks:t.Func([Ir],[Dr],[]),uninstall_code:t.Func([De],[],[]),update_settings:t.Func([Le],[],[]),upload_chunk:t.Func([Ae],[tr],[])})};var Ur=class extends et{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(`
28
+ `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}},Sn=class extends Ur{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=pr[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},Rn=class extends Ur{constructor(e,r,n,i){super(e,r,"update",Object.assign({"Request ID":G(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}},ct=Symbol.for("ic-agent-metadata"),Lt=class t{constructor(e){this[ct]=Object.freeze(e)}static agentOf(e){return e[ct].config.agent}static interfaceOf(e){return e[ct].service}static canisterIdOf(e){return S.from(e[ct].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"?S.fromText(r.canisterId):r.canisterId;await uo(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]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await uo(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:ve});class i extends t{constructor(s){if(!s.canisterId)throw new et(`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"?S.fromText(s.canisterId):s.canisterId;super({config:Object.assign(Object.assign(Object.assign({},po),s),{canisterId:a}),service:n});for(let[l,d]of n._fields)r?.httpDetails&&d.annotations.push(On),r?.certificate&&d.annotations.push(ho),this[l]=Ja(this,l,d,s.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new et(`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)}static createActorWithExtendedDetails(e,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(e,n))(r)}};function _e(t,e){let r=ve.decode(t,fo.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var po={pollingStrategyFactory:Fr.defaultStrategy},On="http-details",ho="certificate";function Ja(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(s,...a)=>{var l,d;s=Object.assign(Object.assign({},s),(d=(l=t[ct].config).queryTransform)===null||d===void 0?void 0:d.call(l,e,a,Object.assign(Object.assign({},t[ct].config),s)));let c=s.agent||t[ct].config.agent||An(),f=S.from(s.canisterId||t[ct].config.canisterId),h=ve.encode(r.argTypes,a),w=await c.query(f,{methodName:e,arg:h,effectiveCanisterId:s.effectiveCanisterId}),m=Object.assign(Object.assign({},w.httpDetails),{requestDetails:w.requestDetails});switch(w.status){case"rejected":throw new Sn(f,e,w);case"replied":return r.annotations.includes(On)?{httpDetails:m,result:_e(r.retTypes,w.reply.arg)}:_e(r.retTypes,w.reply.arg)}}:i=async(s,...a)=>{var l,d;s=Object.assign(Object.assign({},s),(d=(l=t[ct].config).callTransform)===null||d===void 0?void 0:d.call(l,e,a,Object.assign(Object.assign({},t[ct].config),s)));let c=s.agent||t[ct].config.agent||An(),{canisterId:f,effectiveCanisterId:h,pollingStrategyFactory:w}=Object.assign(Object.assign(Object.assign({},po),t[ct].config),s),m=S.from(f),g=h!==void 0?S.from(h):m,E=ve.encode(r.argTypes,a),{requestId:R,response:B,requestDetails:A}=await c.call(m,{methodName:e,arg:E,effectiveCanisterId:g});if(!B.ok||B.body)throw new Rn(m,e,R,B);let F=w(),{certificate:b,reply:M}=await vn(c,g,R,F,n),X=r.annotations.includes(On),K=r.annotations.includes(ho),H=Object.assign(Object.assign({},B),{requestDetails:A});if(M!==void 0)return X&&K?{httpDetails:H,certificate:b,result:_e(r.retTypes,M)}:K?{certificate:b,result:_e(r.retTypes,M)}:X?{httpDetails:H,result:_e(r.retTypes,M)}:_e(r.retTypes,M);if(r.retTypes.length===0)return X?{httpDetails:B,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 uo(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:S.from(t.effectiveCanisterId)};let i=n[0],o=S.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(o=S.from(i.canister_id)),{effectiveCanisterId:o}}return Lt.createActor(lo,Object.assign(Object.assign(Object.assign({},t),{canisterId:S.fromHex("")}),{callTransform:e,queryTransform:e}))}var Vr=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},Wt=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)},Mr,Kr,xe,be;function mo(t){return t!==null&&typeof t=="object"}var te=class t{constructor(e){if(Mr.set(this,void 0),Kr.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Vr(this,Mr,e,"f"),Vr(this,Kr,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=xt(e);return this.fromRaw(r)}else if(mo(e)){let r=e;if(mo(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw(ir(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=pe(e,Xt).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=ke(e,Xt);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Wt(this,Mr,"f")}get derKey(){return Wt(this,Kr,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Mr=new WeakMap,Kr=new WeakMap;te.RAW_KEY_LENGTH=32;var ee=class t extends Ut{constructor(e,r){super(),xe.set(this,void 0),be.set(this,void 0),Vr(this,xe,te.from(e),"f"),Vr(this,be,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=Ht.utils.randomPrivateKey()),nr(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=Ht.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(te.fromDer(xt(r)),xt(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(te.fromRaw(e),r)}static fromSecretKey(e){let r=Ht.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[G(Wt(this,xe,"f").toDer()),G(Wt(this,be,"f"))]}getKeyPair(){return{secretKey:Wt(this,be,"f"),publicKey:Wt(this,xe,"f")}}getPublicKey(){return Wt(this,xe,"f")}async sign(e){let r=new Uint8Array(e),n=ti(Ht.sign(r,Wt(this,be,"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=xt(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return Ht.verify(o,i,s)}};xe=new WeakMap,be=new WeakMap;var Nn=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};function yo(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 Nn("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 je=class t extends Ut{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=yo(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=yo(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 Ee=er(ei());var Za=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},qe=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)},$t,jr=class{constructor(e){$t.set(this,void 0),Za(this,$t,e,"f")}get rawKey(){return qe(this,$t,"f").rawKey}get derKey(){return qe(this,$t,"f").derKey}toDer(){return qe(this,$t,"f").toDer()}getPublicKey(){return qe(this,$t,"f")}getPrincipal(){return S.from(qe(this,$t,"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.")}};$t=new WeakMap;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},Ia=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)},Da=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},qr,La=new TextEncoder().encode("ic-request-auth-delegation"),tc=new TextEncoder().encode(`
29
+ ic-request`);function Bn(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return xt(t)}var Te=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return Ee.value.map(Object.assign({pubkey:Ee.value.bytes(this.pubkey),expiration:Ee.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Ee.value.array(this.targets.map(e=>Ee.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:G(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};async function ec(t,e,r,n){let i=new Te(e.toDer(),BigInt(+r)*BigInt(1e6),n),o=new Uint8Array([...La,...new Uint8Array(Kt(i))]),s=await t.sign(o);return{delegation:i,signature:s}}var He=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 ec(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:l,expiration:d,targets:c}=s;if(c!==void 0&&!Array.isArray(c))throw new Error("Invalid targets.");return{delegation:new Te(Bn(l),BigInt("0x"+d),c&&c.map(f=>{if(typeof f!="string")throw new Error("Invalid target.");return S.fromHex(f)})),signature:Bn(a)}});return new this(i,Bn(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:G(r.pubkey)},i&&{targets:i.map(o=>o.toHex())}),signature:G(n)}}),publicKey:G(this.publicKey)}}},We=class extends Ut{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=Da(e,["body"]),i=await Kt(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...tc,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},$e=class t extends jr{constructor(e,r){super(e),qr.set(this,void 0),Qa(this,qr,r,"f")}get delegation(){return Ia(this,qr,"f")}static fromDelegation(e,r){return new t(e,r)}};qr=new WeakMap;function wo(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"?S.fromText(i):i)):r.push(typeof n=="string"?S.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 l of s.targets)if(l.toText()===o){a=!1;break}if(a)return!1}}return!0}var rc=er(ds());var go;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(go||(go={}));var _o=["mousedown","mousemove","keydown","touchstart","wheel"],Ge=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),_o.forEach(function(a){document.addEventListener(a,o,!0)});let s=(a,l)=>{let d;return(...c)=>{let f=this,h=function(){d=void 0,a.apply(f,c)};clearTimeout(d),d=window.setTimeout(h,l)}};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);_o.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 nc=(t,e)=>e.some(r=>t instanceof r),xo,bo;function ic(){return xo||(xo=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function oc(){return bo||(bo=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Eo=new WeakMap,Cn=new WeakMap,To=new WeakMap,Pn=new WeakMap,Fn=new WeakMap;function sc(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",o),t.removeEventListener("error",s)},o=()=>{r(Nt(t.result)),i()},s=()=>{n(t.error),i()};t.addEventListener("success",o),t.addEventListener("error",s)});return e.then(r=>{r instanceof IDBCursor&&Eo.set(r,t)}).catch(()=>{}),Fn.set(e,t),e}function ac(t){if(Cn.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)});Cn.set(t,e)}var kn={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return Cn.get(t);if(e==="objectStoreNames")return t.objectStoreNames||To.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return Nt(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 Ao(t){kn=t(kn)}function cc(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Hr(this),e,...r);return To.set(n,e.sort?e.sort():[e]),Nt(n)}:oc().includes(t)?function(...e){return t.apply(Hr(this),e),Nt(Eo.get(this))}:function(...e){return Nt(t.apply(Hr(this),e))}}function lc(t){return typeof t=="function"?cc(t):(t instanceof IDBTransaction&&ac(t),nc(t,ic())?new Proxy(t,kn):t)}function Nt(t){if(t instanceof IDBRequest)return sc(t);if(Pn.has(t))return Pn.get(t);let e=lc(t);return e!==t&&(Pn.set(t,e),Fn.set(e,t)),e}var Hr=t=>Fn.get(t);function So(t,e,{blocked:r,upgrade:n,blocking:i,terminated:o}={}){let s=indexedDB.open(t,e),a=Nt(s);return n&&s.addEventListener("upgradeneeded",l=>{n(Nt(s.result),l.oldVersion,l.newVersion,Nt(s.transaction),l)}),r&&s.addEventListener("blocked",l=>r(l.oldVersion,l.newVersion,l)),a.then(l=>{o&&l.addEventListener("close",()=>o()),i&&l.addEventListener("versionchange",d=>i(d.oldVersion,d.newVersion,d))}).catch(()=>{}),a}var uc=["get","getKey","getAll","getAllKeys","count"],dc=["put","add","delete","clear"],Un=new Map;function vo(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Un.get(e))return Un.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=dc.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||uc.includes(r)))return;let o=async function(s,...a){let l=this.transaction(s,i?"readwrite":"readonly"),d=l.store;return n&&(d=d.index(a.shift())),(await Promise.all([d[r](...a),i&&l.done]))[0]};return Un.set(e,o),o}Ao(t=>({...t,get:(e,r,n)=>vo(e,r)||t.get(e,r,n),has:(e,r)=>!!vo(e,r)||t.has(e,r)}));var Ro="auth-client-db",Oo="ic-keyval",fc=async(t=Ro,e=Oo,r)=>(Wr&&(localStorage!=null&&localStorage.getItem(yt))&&(localStorage.removeItem(yt),localStorage.removeItem(wt)),await So(t,r,{upgrade:n=>{n.objectStoreNames,n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function pc(t,e,r){return await t.get(e,r)}async function hc(t,e,r,n){return await t.put(e,n,r)}async function mc(t,e,r){return await t.delete(e,r)}var ze=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=Ro,storeName:n=Oo,version:i=No}=e??{},o=await fc(r,n,i);return new t(o,n)}async set(e,r){return await hc(this._db,this._storeName,e,r)}async get(e){var r;return(r=await pc(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await mc(this._db,this._storeName,e)}};var yc=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},wc=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)},$r,wt="identity",yt="delegation",Bo="iv",No=1,Wr=typeof window<"u",Ye=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}},Je=class{constructor(e){$r.set(this,void 0),yc(this,$r,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}ze.create(wc(this,$r,"f")).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)}};$r=new WeakMap;var gc="https://identity.ic0.app",_c="#authorize",Mn="ECDSA",Kn="Ed25519",xc=500,bc="UserInterrupt",Gr=class{constructor(e,r,n,i,o,s,a,l){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=o,this._createOptions=s,this._idpWindow=a,this._eventHandler=l,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let o=(r=e.storage)!==null&&r!==void 0?r:new Je,s=(n=e.keyType)!==null&&n!==void 0?n:Mn,a=null;if(e.identity)a=e.identity;else{let f=await o.get(wt);if(!f&&Wr)try{let h=new Ye,w=await h.get(yt),m=await h.get(wt);w&&m&&s===Mn&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await o.set(yt,w),await o.set(wt,m),f=w,await h.remove(yt),await h.remove(wt))}catch(h){console.error("error while attempting to recover localstorage: "+h)}if(f)try{typeof f=="object"?s===Kn&&typeof f=="string"?a=await ee.fromJSON(f):a=await je.fromKeyPair(f):typeof f=="string"&&(a=ee.fromJSON(f))}catch{}}let l=new Mt,d=null;if(a)try{let f=await o.get(yt);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?l=e.identity:f&&(d=He.fromJSON(f),wo(d)?"toDer"in a?l=$e.fromDelegation(a,d):l=We.fromDelegation(a,d):(await Vn(o),a=null))}catch(f){console.error(f),await Vn(o),a=null}let c;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?c=void 0:(d||e.identity)&&(c=Ge.create(e.idleOptions)),a||(s===Kn?(a=await ee.generate(),await o.set(wt,JSON.stringify(a.toJSON()))):(e.storage&&s===Mn&&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 '${Kn}' as the key type, as it can serialize to a string`),a=await je.generate(),await o.set(wt,a.getKeyPair()))),new this(l,a,d,o,c,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(d=>({delegation:new Te(d.delegation.pubkey,d.delegation.expiration,d.delegation.targets),signature:d.signature.buffer})),s=He.fromDelegations(o,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=s,"toDer"in a?this._identity=$e.fromDelegation(a,this._chain):this._identity=We.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let l=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!l?.disableIdle&&(this.idleManager=Ge.create(l),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(yt,JSON.stringify(this._chain.toJSON())),r?.(e)}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())||gc);a.hash=_c,(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 l=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(bc,e?.onError):setTimeout(l,xc))};l()}_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 l=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(o=r?.derivationOrigin)===null||o===void 0?void 0:o.toString()},r?.customValues);(s=this._idpWindow)===null||s===void 0||s.postMessage(l,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(l){this._handleFailure(l.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 Vn(this._storage),this._identity=new Mt,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};async function Vn(t){await t.remove(wt),await t.remove(yt),await t.remove(Bo)}var zr=()=>Gr.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Po=async({data:t})=>{try{return await cr(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var jn=async t=>{let{data:e,version:r,description:n}=t;return{description:J(n),data:await fi(e),version:J(r)}},qn=t=>{let{version:e}=t;return{version:J(e)}},Xe=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:o,...s}=t;return{key:e,description:z(i),owner:r.toText(),data:await cr(o),version:z(n),...s}};var Co=t=>{if(j(t))return J();switch(t.matcher){case"equal":return J({Equal:t.timestamp});case"greaterThan":return J({GreaterThan:t.timestamp});case"lessThan":return J({LessThan:t.timestamp});case"between":return J({Between:[t.timestamps.start,t.timestamps.end]});default:throw new Error("Invalid list matcher for timestamp",t)}},Yr=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:j(t)?[]:[{key:J(t.key),description:J(t.description),created_at:Co(t.createdAt),updated_at:Co(t.updatedAt)}],paginate:J(j(e)?void 0:{start_after:J(e.startAfter),limit:J(j(e.limit)?void 0:BigInt(e.limit))}),order:J(j(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:J(j(n)?void 0:typeof n=="string"?S.fromText(n):n)});var ko=({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({version:t.Opt(t.Nat64)}),s=t.Variant({Db:t.Null,Storage:t.Null}),a=t.Record({version:t.Opt(t.Nat64)}),l=t.Record({cycles:t.Nat,destination_id:t.Principal}),d=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}),c=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),f=t.Record({key:d,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,c)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),h=t.Record({derivation_origin:t.Opt(t.Text)}),w=t.Record({internet_identity:t.Opt(h)}),m=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),g=t.Record({max_memory_size:t.Opt(m)}),E=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),R=t.Variant({Deny:t.Null,Allow:t.Null}),B=t.Record({status_code:t.Nat16,location:t.Text}),A=t.Record({iframe:t.Opt(E),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(m),raw_access:t.Opt(R),redirects:t.Opt(t.Vec(t.Tuple(t.Text,B)))}),F=t.Record({db:t.Opt(g),authentication:t.Opt(w),storage:A}),b=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),M=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)}),X=t.Variant({Heap:t.Null,Stable:t.Null}),K=t.Record({memory:X,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}),H=t.Variant({Callback:t.Record({token:K,callback:t.Func([],[],["query"])})}),nt=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(H),status_code:t.Nat16}),st=t.Record({token:t.Opt(K),body:t.Vec(t.Nat8)}),gt=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}),Gt=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),Pt=t.Record({field:Gt,desc:t.Bool}),re=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),Ze=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(re),description:t.Opt(t.Text),created_at:t.Opt(re)}),_=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),p=t.Record({order:t.Opt(Pt),owner:t.Opt(t.Principal),matcher:t.Opt(Ze),paginate:t.Opt(_)}),x=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,f)),items_length:t.Nat64}),T=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),O=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,b)),items_length:t.Nat64}),N=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),C=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(X),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:N,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:N}),k=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)}),U=t.Record({controller:P,controllers:t.Vec(t.Principal)}),V=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),W=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(X),max_size:t.Opt(t.Nat),read:N,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:N}),tt=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),$=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,a],[],[]),deposit_cycles:t.Func([l],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(f)],["query"]),get_auth_config:t.Func([],[t.Opt(w)],["query"]),get_config:t.Func([],[F],[]),get_db_config:t.Func([],[t.Opt(g)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(b)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(f)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(b)))],["query"]),get_storage_config:t.Func([],[A],["query"]),http_request:t.Func([M],[nt],["query"]),http_request_streaming_callback:t.Func([K],[st],["query"]),init_asset_upload:t.Func([gt],[lt],[]),list_assets:t.Func([t.Text,p],[x],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,i))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,T))],["query"]),list_docs:t.Func([t.Text,p],[O],["query"]),list_rules:t.Func([s],[t.Vec(t.Tuple(t.Text,C))],["query"]),memory_size:t.Func([],[k],["query"]),set_auth_config:t.Func([w],[],[]),set_controllers:t.Func([U],[t.Vec(t.Tuple(t.Principal,i))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([g],[],[]),set_doc:t.Func([t.Text,t.Text,V],[b],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,V))],[t.Vec(t.Tuple(t.Text,b))],[]),set_rule:t.Func([s,t.Text,W],[],[]),set_storage_config:t.Func([A],[],[]),upload_asset_chunk:t.Func([tt],[$],[]),version:t.Func([],[t.Text],["query"])})};var Fo=async({satelliteId:t,idlFactory:e,identity:r,fetch:n,container:i})=>{let s=q(i)&&i!==!1?i===!0?ae:i:"https://icp-api.io",a=q(i),l=await Ve.create({identity:r,shouldFetchRootKey:a,host:s,...n&&{fetch:n}});return Lt.createActor(e,{agent:l,canisterId:t})};var Uo=({satelliteId:t,container:e})=>{let{satelliteId:r}=Hn({satelliteId:t}),{container:n}=Wn({container:e});if(q(n)&&n!==!1){let{host:i,protocol:o}=new URL(n===!0?ae:n);return`${o}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},Hn=({satelliteId:t})=>q(t)?{satelliteId:t}:bt.getInstance().get()??{satelliteId:void 0},Wn=({container:t})=>q(t)?{container:t}:bt.getInstance().get()??{container:void 0};var L=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=Hn({satelliteId:t});ar(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=Wn({container:e});return Fo({satelliteId:n,container:i,idlFactory:ko,...r})};var Mo=async({collection:t,key:e,satellite:r})=>{let n=await L(r),i=z(await n.get_doc(t,e));if(!j(i))return Xe({doc:i,key:e})},Ko=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await L(e),n=t.map(({collection:s,key:a})=>[s,a]),i=await r(n),o=[];for(let[s,a]of i){let l=z(a);o.push(q(l)?await Xe({key:s,doc:l}):void 0)}return o},Vo=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await L(r),{key:i}=e,o=await jn(e),s=await n(t,i,o);return await Xe({key:i,doc:s})},jo=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await L(e),n=[];for(let{collection:s,doc:a}of t){let{key:l}=a;n.push([s,l,await jn(a)])}let i=await r(n),o=[];for(let[s,a]of i)o.push(await Xe({key:s,doc:a}));return o},qo=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await L(r),{key:i}=e;return n(t,i,qn(e))},Ho=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await L(e),n=t.map(({collection:i,doc:o})=>[i,o.key,qn(o)]);await r(n)},Wo=async({collection:t,filter:e,satellite:r})=>{let n=await L(r),{items:i,items_page:o,items_length:s,matches_length:a,matches_pages:l}=await n.list_docs(t,Yr(e)),d=[];for(let[c,f]of i){let{data:h,owner:w,description:m,version:g,...E}=f;d.push({key:c,description:z(m),owner:w.toText(),data:await Po({data:h}),version:z(g),...E})}return{items:d,items_length:s,items_page:z(o),matches_length:a,matches_pages:z(l)}};var I=t=>t!==void 0?t:Jr()??new Mt;var $o=async({satellite:t,...e})=>{let r=I(t?.identity);return Mo({...e,satellite:{...t,identity:r}})},xf=async({satellite:t,...e})=>{let r=I(t?.identity);return Ko({...e,satellite:{...t,identity:r}})},Go=async({satellite:t,...e})=>{let r=I(t?.identity);return Vo({...e,satellite:{...t,identity:r}})},bf=async({satellite:t,...e})=>{let r=I(t?.identity);return jo({...e,satellite:{...t,identity:r}})},Ef=async({satellite:t,...e})=>{let r=I(t?.identity);return qo({...e,satellite:{...t,identity:r}})},Tf=async({satellite:t,...e})=>{let r=I(t?.identity);return Ho({...e,satellite:{...t,identity:r}})},Af=async({satellite:t,filter:e,...r})=>{let n=I(t?.identity);return Wo({...r,filter:e??{},satellite:{...t,identity:n}})};var zo=async t=>{let e=Jr();if(j(e))throw new Error("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=await $o({collection:"#user",key:r});return j(n)?await Ec({userId:r,provider:t}):n},Ec=async({userId:t,...e})=>Go({collection:"#user",doc:{key:t,data:e}});var Bt,$n=async t=>{if(Bt=Bt??await zr(),!(await Bt?.isAuthenticated()??!1))return;let r=await zo(t);kt.getInstance().set(r)},Tc=async t=>new Promise(async(e,r)=>{Bt=Bt??await zr();let n=t?.provider??new lr({});await Bt.login({onSuccess:async()=>{await $n(n.id),e()},onError:i=>r(i),maxTimeToLive:t?.maxTimeToLive??hi,allowPinAuthentication:t?.allowPin??mi,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),Gn=async()=>{await Bt?.logout(),Bt=void 0,kt.getInstance().reset()},Jr=()=>Bt?.getIdentity(),Ac=async()=>(Bt??await zr()).getIdentity();var Yo=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{an({message:"junoSignOutAuthTimer"}),await Gn()};return r.onmessage=async({data:i})=>{let{msg:o,data:s}=i;switch(o){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":an({message:"junoDelegationRemainingTime",detail:s?.authRemainingTime});return}},kt.getInstance().subscribe(i=>{if(j(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var Jo=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},Xo=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};var vc=t=>t==null,Sc=t=>!vc(t),Xr=t=>Sc(t)?[t]:[],Rc=()=>typeof window<"u",Zo=async({asset:{data:t,filename:e,collection:r,headers:n,token:i,fullPath:o,encoding:s,description:a},actor:l,init_asset_upload:d})=>{let{batch_id:c}=await d({collection:r,full_path:o,name:e,token:Xr(i),encoding_type:Xr(s),description:Xr(a)}),f=19e5,h=[],w=Rc()?new Blob([await t.arrayBuffer()]):t,m=0n;for(let R=0;R<w.size;R+=f){let B=w.slice(R,R+f);h.push({batchId:c,chunk:B,actor:l,orderId:m}),m++}let g=[];for await(let R of Oc({uploadChunks:h}))g=[...g,...R];let E=n.find(([R,B])=>R.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await l.commit_asset_upload({batch_id:c,chunk_ids:g.map(({chunk_id:R})=>R),headers:[...n,...E||[]]})};async function*Oc({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(i=>Nc(i)))}}var Nc=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:Xr(n)});var Qo=async({satellite:t,...e})=>{let r=await L(t);await Zo({actor:r,asset:e,init_asset_upload:async i=>await r.init_asset_upload(i)})},Io=async({collection:t,satellite:e,filter:r})=>{let n=await L(e),{items:i,items_length:o,items_page:s,matches_length:a,matches_pages:l}=await n.list_assets(t,Yr(r));return{items:i.map(([d,c])=>c),items_length:o,items_page:z(s),matches_length:a,matches_pages:z(l)}},Do=async({collection:t,fullPath:e,satellite:r})=>(await L(r)).del_asset(t,e),Lo=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await L(e),n=t.map(({collection:i,fullPath:o})=>[i,o]);await r(n)},ts=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await L(r);return z(await n(t,e))},es=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await L(e),n=t.map(({collection:o,fullPath:s})=>[o,s]);return(await r(n)).map(([o,s])=>z(s))};var rs=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var rp=async t=>ns(t),np=async t=>ns({filename:t.data.name,...t}),ns=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:o,satellite:s,encoding:a,description:l})=>{let d=I(s?.identity),c=decodeURI(t),f=i??`/${r}/${c}`,h={...s,identity:d};return await Qo({data:e,filename:c,collection:r,token:o,headers:n,fullPath:f,encoding:a,satellite:h,description:l}),{downloadUrl:is({satellite:h,assetKey:{fullPath:f,token:o}}),fullPath:f,name:c}},ip=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:I(e?.identity)},{items:i,...o}=await Io({collection:t,satellite:n,filter:r??{}}),s=i.map(({key:{full_path:a,token:l,name:d,owner:c,description:f},headers:h,encodings:w,created_at:m,updated_at:g})=>{let E=z(l);return{fullPath:a,description:z(f),name:d,downloadUrl:is({satellite:n,assetKey:{fullPath:a,token:E}}),token:E,headers:h,encodings:w.reduce((R,[B,{modified:A,sha256:F,total_length:b}])=>({...R,[B]:{modified:A,sha256:rs(F),total_length:b}}),{}),owner:c.toText(),created_at:m,updated_at:g}});return{items:s,assets:s,...o}},op=async({collection:t,fullPath:e,satellite:r})=>Do({collection:t,fullPath:e,satellite:{...r,identity:I(r?.identity)}}),sp=async({assets:t,satellite:e})=>Lo({assets:t,satellite:{...e,identity:I(e?.identity)}}),ap=async({satellite:t,...e})=>{let r=I(t?.identity);return ts({...e,satellite:{...t,identity:r}})},cp=async({satellite:t,...e})=>{let r=I(t?.identity);return es({...e,satellite:{...t,identity:r}})},is=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:I(r?.identity)};return`${Uo(n)}${t}${q(e)?`?token=${e}`:""}`};var Bc=t=>{let e=t?.satelliteId??Jo();ar(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??Xo();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},yp=async t=>Pc(t),Pc=async t=>{let e=Bc(t);bt.getInstance().set(e),await $n();let r=e.workers?.auth!==void 0?Yo(e.workers.auth):void 0;return[...r?[r]:[]]},wp=t=>kt.getInstance().subscribe(t);export{lr as InternetIdentityProvider,xi as NFIDProvider,wp as authSubscribe,op as deleteAsset,Ef as deleteDoc,sp as deleteManyAssets,Tf as deleteManyDocs,is as downloadUrl,ap as getAsset,$o as getDoc,cp as getManyAssets,xf as getManyDocs,yp as initJuno,Pc as initSatellite,ip as listAssets,Af as listDocs,Go as setDoc,bf as setManyDocs,Tc as signIn,Gn as signOut,Ac as unsafeIdentity,rp as uploadBlob,np as uploadFile};
30
30
  /*! Bundled license information:
31
31
 
32
32
  buffer/index.js: