@junobuild/core-standalone 1.1.0 → 1.1.1

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,18 +1,18 @@
1
- import{A as Ar,B as Vr,C as ot,D as le,E as pr,F as st,a as Jt,b as Ya,c as nt,d as Xa,e as Ht,f as h,g as P,h as ce,i as $t,j as zt,k as Wt,l as Er,m as at,n as dr,o as Qa,p as it,q as Re,r as ve,s as Za,t as br,u as z,z as Se}from"./chunk-EMF4NSTU.js";var Xt=Jt(Pr=>{"use strict";Pr.byteLength=ei;Pr.toByteArray=ti;Pr.fromByteArray=ii;var Y=[],D=[],La=typeof Uint8Array<"u"?Uint8Array:Array,ct="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(we=0,Gt=ct.length;we<Gt;++we)Y[we]=ct[we],D[ct.charCodeAt(we)]=we;var we,Gt;D[45]=62;D[95]=63;function Yt(e){var r=e.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=r);var n=t===r?0:4-t%4;return[t,n]}function ei(e){var r=Yt(e),t=r[0],n=r[1];return(t+n)*3/4-n}function ri(e,r,t){return(r+t)*3/4-t}function ti(e){var r,t=Yt(e),n=t[0],a=t[1],i=new La(ri(e,n,a)),o=0,s=a>0?n-4:n,l;for(l=0;l<s;l+=4)r=D[e.charCodeAt(l)]<<18|D[e.charCodeAt(l+1)]<<12|D[e.charCodeAt(l+2)]<<6|D[e.charCodeAt(l+3)],i[o++]=r>>16&255,i[o++]=r>>8&255,i[o++]=r&255;return a===2&&(r=D[e.charCodeAt(l)]<<2|D[e.charCodeAt(l+1)]>>4,i[o++]=r&255),a===1&&(r=D[e.charCodeAt(l)]<<10|D[e.charCodeAt(l+1)]<<4|D[e.charCodeAt(l+2)]>>2,i[o++]=r>>8&255,i[o++]=r&255),i}function ni(e){return Y[e>>18&63]+Y[e>>12&63]+Y[e>>6&63]+Y[e&63]}function ai(e,r,t){for(var n,a=[],i=r;i<t;i+=3)n=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(e[i+2]&255),a.push(ni(n));return a.join("")}function ii(e){for(var r,t=e.length,n=t%3,a=[],i=16383,o=0,s=t-n;o<s;o+=i)a.push(ai(e,o,o+i>s?s:o+i));return n===1?(r=e[t-1],a.push(Y[r>>2]+Y[r<<4&63]+"==")):n===2&&(r=(e[t-2]<<8)+e[t-1],a.push(Y[r>>10]+Y[r>>4&63]+Y[r<<2&63]+"=")),a.join("")}});var mn=Jt(Be=>{"use strict";var lt=Xt(),Ce=Xa(),Qt=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Be.Buffer=c;Be.SlowBuffer=di;Be.INSPECT_MAX_BYTES=50;var vr=2147483647;Be.kMaxLength=vr;c.TYPED_ARRAY_SUPPORT=oi();!c.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 oi(){try{let e=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(e,r),e.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}});Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function ie(e){if(e>vr)throw new RangeError('The value "'+e+'" is invalid for option "size"');let r=new Uint8Array(e);return Object.setPrototypeOf(r,c.prototype),r}function c(e,r,t){if(typeof e=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return _t(e)}return rn(e,r,t)}c.poolSize=8192;function rn(e,r,t){if(typeof e=="string")return ci(e,r);if(ArrayBuffer.isView(e))return li(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(X(e,ArrayBuffer)||e&&X(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(X(e,SharedArrayBuffer)||e&&X(e.buffer,SharedArrayBuffer)))return dt(e,r,t);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return c.from(n,r,t);let a=ui(e);if(a)return a;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return c.from(e[Symbol.toPrimitive]("string"),r,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}c.from=function(e,r,t){return rn(e,r,t)};Object.setPrototypeOf(c.prototype,Uint8Array.prototype);Object.setPrototypeOf(c,Uint8Array);function tn(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function si(e,r,t){return tn(e),e<=0?ie(e):r!==void 0?typeof t=="string"?ie(e).fill(r,t):ie(e).fill(r):ie(e)}c.alloc=function(e,r,t){return si(e,r,t)};function _t(e){return tn(e),ie(e<0?0:mt(e)|0)}c.allocUnsafe=function(e){return _t(e)};c.allocUnsafeSlow=function(e){return _t(e)};function ci(e,r){if((typeof r!="string"||r==="")&&(r="utf8"),!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let t=nn(e,r)|0,n=ie(t),a=n.write(e,r);return a!==t&&(n=n.slice(0,a)),n}function ut(e){let r=e.length<0?0:mt(e.length)|0,t=ie(r);for(let n=0;n<r;n+=1)t[n]=e[n]&255;return t}function li(e){if(X(e,Uint8Array)){let r=new Uint8Array(e);return dt(r.buffer,r.byteOffset,r.byteLength)}return ut(e)}function dt(e,r,t){if(r<0||e.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<r+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return r===void 0&&t===void 0?n=new Uint8Array(e):t===void 0?n=new Uint8Array(e,r):n=new Uint8Array(e,r,t),Object.setPrototypeOf(n,c.prototype),n}function ui(e){if(c.isBuffer(e)){let r=mt(e.length)|0,t=ie(r);return t.length===0||e.copy(t,0,0,r),t}if(e.length!==void 0)return typeof e.length!="number"||yt(e.length)?ie(0):ut(e);if(e.type==="Buffer"&&Array.isArray(e.data))return ut(e.data)}function mt(e){if(e>=vr)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+vr.toString(16)+" bytes");return e|0}function di(e){return+e!=e&&(e=0),c.alloc(+e)}c.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==c.prototype};c.compare=function(r,t){if(X(r,Uint8Array)&&(r=c.from(r,r.offset,r.byteLength)),X(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(r)||!c.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===t)return 0;let n=r.length,a=t.length;for(let i=0,o=Math.min(n,a);i<o;++i)if(r[i]!==t[i]){n=r[i],a=t[i];break}return n<a?-1:a<n?1:0};c.isEncoding=function(r){switch(String(r).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}};c.concat=function(r,t){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return c.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<r.length;++n)t+=r[n].length;let a=c.allocUnsafe(t),i=0;for(n=0;n<r.length;++n){let o=r[n];if(X(o,Uint8Array))i+o.length>a.length?(c.isBuffer(o)||(o=c.from(o)),o.copy(a,i)):Uint8Array.prototype.set.call(a,o,i);else if(c.isBuffer(o))o.copy(a,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=o.length}return a};function nn(e,r){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||X(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let t=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let a=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return pt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return _n(e).length;default:if(a)return n?-1:pt(e).length;r=(""+r).toLowerCase(),a=!0}}c.byteLength=nn;function pi(e,r,t){let n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,r>>>=0,t<=r))return"";for(e||(e="utf8");;)switch(e){case"hex":return Oi(this,r,t);case"utf8":case"utf-8":return on(this,r,t);case"ascii":return gi(this,r,t);case"latin1":case"binary":return xi(this,r,t);case"base64":return Ti(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ri(this,r,t);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}c.prototype._isBuffer=!0;function Fe(e,r,t){let n=e[r];e[r]=e[t],e[t]=n}c.prototype.swap16=function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<r;t+=2)Fe(this,t,t+1);return this};c.prototype.swap32=function(){let r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<r;t+=4)Fe(this,t,t+3),Fe(this,t+1,t+2);return this};c.prototype.swap64=function(){let r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<r;t+=8)Fe(this,t,t+7),Fe(this,t+1,t+6),Fe(this,t+2,t+5),Fe(this,t+3,t+4);return this};c.prototype.toString=function(){let r=this.length;return r===0?"":arguments.length===0?on(this,0,r):pi.apply(this,arguments)};c.prototype.toLocaleString=c.prototype.toString;c.prototype.equals=function(r){if(!c.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:c.compare(this,r)===0};c.prototype.inspect=function(){let r="",t=Be.INSPECT_MAX_BYTES;return r=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(r+=" ... "),"<Buffer "+r+">"};Qt&&(c.prototype[Qt]=c.prototype.inspect);c.prototype.compare=function(r,t,n,a,i){if(X(r,Uint8Array)&&(r=c.from(r,r.offset,r.byteLength)),!c.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(t===void 0&&(t=0),n===void 0&&(n=r?r.length:0),a===void 0&&(a=0),i===void 0&&(i=this.length),t<0||n>r.length||a<0||i>this.length)throw new RangeError("out of range index");if(a>=i&&t>=n)return 0;if(a>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,a>>>=0,i>>>=0,this===r)return 0;let o=i-a,s=n-t,l=Math.min(o,s),u=this.slice(a,i),p=r.slice(t,n);for(let d=0;d<l;++d)if(u[d]!==p[d]){o=u[d],s=p[d];break}return o<s?-1:s<o?1:0};function an(e,r,t,n,a){if(e.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,yt(t)&&(t=a?0:e.length-1),t<0&&(t=e.length+t),t>=e.length){if(a)return-1;t=e.length-1}else if(t<0)if(a)t=0;else return-1;if(typeof r=="string"&&(r=c.from(r,n)),c.isBuffer(r))return r.length===0?-1:Zt(e,r,t,n,a);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?a?Uint8Array.prototype.indexOf.call(e,r,t):Uint8Array.prototype.lastIndexOf.call(e,r,t):Zt(e,[r],t,n,a);throw new TypeError("val must be string, number or Buffer")}function Zt(e,r,t,n,a){let i=1,o=e.length,s=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||r.length<2)return-1;i=2,o/=2,s/=2,t/=2}function l(p,d){return i===1?p[d]:p.readUInt16BE(d*i)}let u;if(a){let p=-1;for(u=t;u<o;u++)if(l(e,u)===l(r,p===-1?0:u-p)){if(p===-1&&(p=u),u-p+1===s)return p*i}else p!==-1&&(u-=u-p),p=-1}else for(t+s>o&&(t=o-s),u=t;u>=0;u--){let p=!0;for(let d=0;d<s;d++)if(l(e,u+d)!==l(r,d)){p=!1;break}if(p)return u}return-1}c.prototype.includes=function(r,t,n){return this.indexOf(r,t,n)!==-1};c.prototype.indexOf=function(r,t,n){return an(this,r,t,n,!0)};c.prototype.lastIndexOf=function(r,t,n){return an(this,r,t,n,!1)};function _i(e,r,t,n){t=Number(t)||0;let a=e.length-t;n?(n=Number(n),n>a&&(n=a)):n=a;let i=r.length;n>i/2&&(n=i/2);let o;for(o=0;o<n;++o){let s=parseInt(r.substr(o*2,2),16);if(yt(s))return o;e[t+o]=s}return o}function mi(e,r,t,n){return Sr(pt(r,e.length-t),e,t,n)}function fi(e,r,t,n){return Sr(bi(r),e,t,n)}function yi(e,r,t,n){return Sr(_n(r),e,t,n)}function hi(e,r,t,n){return Sr(Ai(r,e.length-t),e,t,n)}c.prototype.write=function(r,t,n,a){if(t===void 0)a="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")a=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,a===void 0&&(a="utf8")):(a=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let i=this.length-t;if((n===void 0||n>i)&&(n=i),r.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");a||(a="utf8");let o=!1;for(;;)switch(a){case"hex":return _i(this,r,t,n);case"utf8":case"utf-8":return mi(this,r,t,n);case"ascii":case"latin1":case"binary":return fi(this,r,t,n);case"base64":return yi(this,r,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return hi(this,r,t,n);default:if(o)throw new TypeError("Unknown encoding: "+a);a=(""+a).toLowerCase(),o=!0}};c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ti(e,r,t){return r===0&&t===e.length?lt.fromByteArray(e):lt.fromByteArray(e.slice(r,t))}function on(e,r,t){t=Math.min(e.length,t);let n=[],a=r;for(;a<t;){let i=e[a],o=null,s=i>239?4:i>223?3:i>191?2:1;if(a+s<=t){let l,u,p,d;switch(s){case 1:i<128&&(o=i);break;case 2:l=e[a+1],(l&192)===128&&(d=(i&31)<<6|l&63,d>127&&(o=d));break;case 3:l=e[a+1],u=e[a+2],(l&192)===128&&(u&192)===128&&(d=(i&15)<<12|(l&63)<<6|u&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:l=e[a+1],u=e[a+2],p=e[a+3],(l&192)===128&&(u&192)===128&&(p&192)===128&&(d=(i&15)<<18|(l&63)<<12|(u&63)<<6|p&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),a+=s}return Ni(n)}var Lt=4096;function Ni(e){let r=e.length;if(r<=Lt)return String.fromCharCode.apply(String,e);let t="",n=0;for(;n<r;)t+=String.fromCharCode.apply(String,e.slice(n,n+=Lt));return t}function gi(e,r,t){let n="";t=Math.min(e.length,t);for(let a=r;a<t;++a)n+=String.fromCharCode(e[a]&127);return n}function xi(e,r,t){let n="";t=Math.min(e.length,t);for(let a=r;a<t;++a)n+=String.fromCharCode(e[a]);return n}function Oi(e,r,t){let n=e.length;(!r||r<0)&&(r=0),(!t||t<0||t>n)&&(t=n);let a="";for(let i=r;i<t;++i)a+=Vi[e[i]];return a}function Ri(e,r,t){let n=e.slice(r,t),a="";for(let i=0;i<n.length-1;i+=2)a+=String.fromCharCode(n[i]+n[i+1]*256);return a}c.prototype.slice=function(r,t){let n=this.length;r=~~r,t=t===void 0?n:~~t,r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<r&&(t=r);let a=this.subarray(r,t);return Object.setPrototypeOf(a,c.prototype),a};function b(e,r,t){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+r>t)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(r,t,n){r=r>>>0,t=t>>>0,n||b(r,t,this.length);let a=this[r],i=1,o=0;for(;++o<t&&(i*=256);)a+=this[r+o]*i;return a};c.prototype.readUintBE=c.prototype.readUIntBE=function(r,t,n){r=r>>>0,t=t>>>0,n||b(r,t,this.length);let a=this[r+--t],i=1;for(;t>0&&(i*=256);)a+=this[r+--t]*i;return a};c.prototype.readUint8=c.prototype.readUInt8=function(r,t){return r=r>>>0,t||b(r,1,this.length),this[r]};c.prototype.readUint16LE=c.prototype.readUInt16LE=function(r,t){return r=r>>>0,t||b(r,2,this.length),this[r]|this[r+1]<<8};c.prototype.readUint16BE=c.prototype.readUInt16BE=function(r,t){return r=r>>>0,t||b(r,2,this.length),this[r]<<8|this[r+1]};c.prototype.readUint32LE=c.prototype.readUInt32LE=function(r,t){return r=r>>>0,t||b(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};c.prototype.readUint32BE=c.prototype.readUInt32BE=function(r,t){return r=r>>>0,t||b(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};c.prototype.readBigUInt64LE=ue(function(r){r=r>>>0,Ue(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&_r(r,this.length-8);let a=t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,i=this[++r]+this[++r]*2**8+this[++r]*2**16+n*2**24;return BigInt(a)+(BigInt(i)<<BigInt(32))});c.prototype.readBigUInt64BE=ue(function(r){r=r>>>0,Ue(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&_r(r,this.length-8);let a=t*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],i=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+n;return(BigInt(a)<<BigInt(32))+BigInt(i)});c.prototype.readIntLE=function(r,t,n){r=r>>>0,t=t>>>0,n||b(r,t,this.length);let a=this[r],i=1,o=0;for(;++o<t&&(i*=256);)a+=this[r+o]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*t)),a};c.prototype.readIntBE=function(r,t,n){r=r>>>0,t=t>>>0,n||b(r,t,this.length);let a=t,i=1,o=this[r+--a];for(;a>0&&(i*=256);)o+=this[r+--a]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o};c.prototype.readInt8=function(r,t){return r=r>>>0,t||b(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};c.prototype.readInt16LE=function(r,t){r=r>>>0,t||b(r,2,this.length);let n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n};c.prototype.readInt16BE=function(r,t){r=r>>>0,t||b(r,2,this.length);let n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n};c.prototype.readInt32LE=function(r,t){return r=r>>>0,t||b(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};c.prototype.readInt32BE=function(r,t){return r=r>>>0,t||b(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};c.prototype.readBigInt64LE=ue(function(r){r=r>>>0,Ue(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&_r(r,this.length-8);let a=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(n<<24);return(BigInt(a)<<BigInt(32))+BigInt(t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)});c.prototype.readBigInt64BE=ue(function(r){r=r>>>0,Ue(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&_r(r,this.length-8);let a=(t<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(a)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+n)});c.prototype.readFloatLE=function(r,t){return r=r>>>0,t||b(r,4,this.length),Ce.read(this,r,!0,23,4)};c.prototype.readFloatBE=function(r,t){return r=r>>>0,t||b(r,4,this.length),Ce.read(this,r,!1,23,4)};c.prototype.readDoubleLE=function(r,t){return r=r>>>0,t||b(r,8,this.length),Ce.read(this,r,!0,52,8)};c.prototype.readDoubleBE=function(r,t){return r=r>>>0,t||b(r,8,this.length),Ce.read(this,r,!1,52,8)};function k(e,r,t,n,a,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>a||r<i)throw new RangeError('"value" argument is out of bounds');if(t+n>e.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(r,t,n,a){if(r=+r,t=t>>>0,n=n>>>0,!a){let s=Math.pow(2,8*n)-1;k(this,r,t,n,s,0)}let i=1,o=0;for(this[t]=r&255;++o<n&&(i*=256);)this[t+o]=r/i&255;return t+n};c.prototype.writeUintBE=c.prototype.writeUIntBE=function(r,t,n,a){if(r=+r,t=t>>>0,n=n>>>0,!a){let s=Math.pow(2,8*n)-1;k(this,r,t,n,s,0)}let i=n-1,o=1;for(this[t+i]=r&255;--i>=0&&(o*=256);)this[t+i]=r/o&255;return t+n};c.prototype.writeUint8=c.prototype.writeUInt8=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,1,255,0),this[t]=r&255,t+1};c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,2,65535,0),this[t]=r&255,this[t+1]=r>>>8,t+2};c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,2,65535,0),this[t]=r>>>8,this[t+1]=r&255,t+2};c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,4,4294967295,0),this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=r&255,t+4};c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,4,4294967295,0),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};function sn(e,r,t,n,a){pn(r,n,a,e,t,7);let i=Number(r&BigInt(4294967295));e[t++]=i,i=i>>8,e[t++]=i,i=i>>8,e[t++]=i,i=i>>8,e[t++]=i;let o=Number(r>>BigInt(32)&BigInt(4294967295));return e[t++]=o,o=o>>8,e[t++]=o,o=o>>8,e[t++]=o,o=o>>8,e[t++]=o,t}function cn(e,r,t,n,a){pn(r,n,a,e,t,7);let i=Number(r&BigInt(4294967295));e[t+7]=i,i=i>>8,e[t+6]=i,i=i>>8,e[t+5]=i,i=i>>8,e[t+4]=i;let o=Number(r>>BigInt(32)&BigInt(4294967295));return e[t+3]=o,o=o>>8,e[t+2]=o,o=o>>8,e[t+1]=o,o=o>>8,e[t]=o,t+8}c.prototype.writeBigUInt64LE=ue(function(r,t=0){return sn(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeBigUInt64BE=ue(function(r,t=0){return cn(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeIntLE=function(r,t,n,a){if(r=+r,t=t>>>0,!a){let l=Math.pow(2,8*n-1);k(this,r,t,n,l-1,-l)}let i=0,o=1,s=0;for(this[t]=r&255;++i<n&&(o*=256);)r<0&&s===0&&this[t+i-1]!==0&&(s=1),this[t+i]=(r/o>>0)-s&255;return t+n};c.prototype.writeIntBE=function(r,t,n,a){if(r=+r,t=t>>>0,!a){let l=Math.pow(2,8*n-1);k(this,r,t,n,l-1,-l)}let i=n-1,o=1,s=0;for(this[t+i]=r&255;--i>=0&&(o*=256);)r<0&&s===0&&this[t+i+1]!==0&&(s=1),this[t+i]=(r/o>>0)-s&255;return t+n};c.prototype.writeInt8=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,1,127,-128),r<0&&(r=255+r+1),this[t]=r&255,t+1};c.prototype.writeInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,2,32767,-32768),this[t]=r&255,this[t+1]=r>>>8,t+2};c.prototype.writeInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,2,32767,-32768),this[t]=r>>>8,this[t+1]=r&255,t+2};c.prototype.writeInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,4,2147483647,-2147483648),this[t]=r&255,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24,t+4};c.prototype.writeInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};c.prototype.writeBigInt64LE=ue(function(r,t=0){return sn(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});c.prototype.writeBigInt64BE=ue(function(r,t=0){return cn(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ln(e,r,t,n,a,i){if(t+n>e.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function un(e,r,t,n,a){return r=+r,t=t>>>0,a||ln(e,r,t,4,34028234663852886e22,-34028234663852886e22),Ce.write(e,r,t,n,23,4),t+4}c.prototype.writeFloatLE=function(r,t,n){return un(this,r,t,!0,n)};c.prototype.writeFloatBE=function(r,t,n){return un(this,r,t,!1,n)};function dn(e,r,t,n,a){return r=+r,t=t>>>0,a||ln(e,r,t,8,17976931348623157e292,-17976931348623157e292),Ce.write(e,r,t,n,52,8),t+8}c.prototype.writeDoubleLE=function(r,t,n){return dn(this,r,t,!0,n)};c.prototype.writeDoubleBE=function(r,t,n){return dn(this,r,t,!1,n)};c.prototype.copy=function(r,t,n,a){if(!c.isBuffer(r))throw new TypeError("argument should be a Buffer");if(n||(n=0),!a&&a!==0&&(a=this.length),t>=r.length&&(t=r.length),t||(t=0),a>0&&a<n&&(a=n),a===n||r.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length),r.length-t<a-n&&(a=r.length-t+n);let i=a-n;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,a):Uint8Array.prototype.set.call(r,this.subarray(n,a),t),i};c.prototype.fill=function(r,t,n,a){if(typeof r=="string"){if(typeof t=="string"?(a=t,t=0,n=this.length):typeof n=="string"&&(a=n,n=this.length),a!==void 0&&typeof a!="string")throw new TypeError("encoding must be a string");if(typeof a=="string"&&!c.isEncoding(a))throw new TypeError("Unknown encoding: "+a);if(r.length===1){let o=r.charCodeAt(0);(a==="utf8"&&o<128||a==="latin1")&&(r=o)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,r||(r=0);let i;if(typeof r=="number")for(i=t;i<n;++i)this[i]=r;else{let o=c.isBuffer(r)?r:c.from(r,a),s=o.length;if(s===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(i=0;i<n-t;++i)this[i+t]=o[i%s]}return this};var ke={};function ft(e,r,t){ke[e]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(a){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:a,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}ft("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ft("ERR_INVALID_ARG_TYPE",function(e,r){return`The "${e}" argument must be of type number. Received type ${typeof r}`},TypeError);ft("ERR_OUT_OF_RANGE",function(e,r,t){let n=`The value of "${e}" is out of range.`,a=t;return Number.isInteger(t)&&Math.abs(t)>2**32?a=en(String(t)):typeof t=="bigint"&&(a=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(a=en(a)),a+="n"),n+=` It must be ${r}. Received ${a}`,n},RangeError);function en(e){let r="",t=e.length,n=e[0]==="-"?1:0;for(;t>=n+4;t-=3)r=`_${e.slice(t-3,t)}${r}`;return`${e.slice(0,t)}${r}`}function wi(e,r,t){Ue(r,"offset"),(e[r]===void 0||e[r+t]===void 0)&&_r(r,e.length-(t+1))}function pn(e,r,t,n,a,i){if(e>t||e<r){let o=typeof r=="bigint"?"n":"",s;throw i>3?r===0||r===BigInt(0)?s=`>= 0${o} and < 2${o} ** ${(i+1)*8}${o}`:s=`>= -(2${o} ** ${(i+1)*8-1}${o}) and < 2 ** ${(i+1)*8-1}${o}`:s=`>= ${r}${o} and <= ${t}${o}`,new ke.ERR_OUT_OF_RANGE("value",s,e)}wi(n,a,i)}function Ue(e,r){if(typeof e!="number")throw new ke.ERR_INVALID_ARG_TYPE(r,"number",e)}function _r(e,r,t){throw Math.floor(e)!==e?(Ue(e,t),new ke.ERR_OUT_OF_RANGE(t||"offset","an integer",e)):r<0?new ke.ERR_BUFFER_OUT_OF_BOUNDS:new ke.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${r}`,e)}var Fi=/[^+/0-9A-Za-z-_]/g;function Ei(e){if(e=e.split("=")[0],e=e.trim().replace(Fi,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function pt(e,r){r=r||1/0;let t,n=e.length,a=null,i=[];for(let o=0;o<n;++o){if(t=e.charCodeAt(o),t>55295&&t<57344){if(!a){if(t>56319){(r-=3)>-1&&i.push(239,191,189);continue}else if(o+1===n){(r-=3)>-1&&i.push(239,191,189);continue}a=t;continue}if(t<56320){(r-=3)>-1&&i.push(239,191,189),a=t;continue}t=(a-55296<<10|t-56320)+65536}else a&&(r-=3)>-1&&i.push(239,191,189);if(a=null,t<128){if((r-=1)<0)break;i.push(t)}else if(t<2048){if((r-=2)<0)break;i.push(t>>6|192,t&63|128)}else if(t<65536){if((r-=3)<0)break;i.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((r-=4)<0)break;i.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return i}function bi(e){let r=[];for(let t=0;t<e.length;++t)r.push(e.charCodeAt(t)&255);return r}function Ai(e,r){let t,n,a,i=[];for(let o=0;o<e.length&&!((r-=2)<0);++o)t=e.charCodeAt(o),n=t>>8,a=t%256,i.push(a),i.push(n);return i}function _n(e){return lt.toByteArray(Ei(e))}function Sr(e,r,t,n){let a;for(a=0;a<n&&!(a+t>=r.length||a>=e.length);++a)r[a+t]=e[a];return a}function X(e,r){return e instanceof r||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===r.name}function yt(e){return e!==e}var Vi=function(){let e="0123456789abcdef",r=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let a=0;a<16;++a)r[n+a]=e[t]+e[a]}return r}();function ue(e){return typeof BigInt>"u"?Pi:e}function Pi(){throw new Error("BigInt not supported")}});var On=nt(mn());var Cr={};Ya(Cr,{backoff:()=>Tn,chain:()=>Nn,conditionalDelay:()=>yn,defaultStrategy:()=>kr,maxAttempts:()=>Si,once:()=>fn,throttle:()=>ki,timeout:()=>hn});var vi=300*1e3;function kr(){return Nn(yn(fn(),1e3),Tn(1e3,1.2),hn(vi))}function fn(){let e=!0;return async()=>e?(e=!1,!0):!1}function yn(e,r){return async(t,n,a)=>{if(await e(t,n,a))return new Promise(i=>setTimeout(i,r))}}function Si(e){let r=e;return async(t,n,a)=>{if(--r<=0)throw new Error(`Failed to retrieve a reply for request after ${e} attempts:
1
+ import{A as Vr,B as Pr,C as ot,D as ue,E as pr,F as st,a as Jt,b as Ya,c as nt,d as Xa,e as Ht,f as y,g as P,h as le,i as $t,j as zt,k as Wt,l as br,m as at,n as dr,o as Qa,p as it,q as Re,r as ve,s as Za,t as Ar,u as z,z as Se}from"./chunk-EMF4NSTU.js";var Xt=Jt(vr=>{"use strict";vr.byteLength=ei;vr.toByteArray=ti;vr.fromByteArray=ii;var X=[],D=[],La=typeof Uint8Array<"u"?Uint8Array:Array,ct="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(we=0,Gt=ct.length;we<Gt;++we)X[we]=ct[we],D[ct.charCodeAt(we)]=we;var we,Gt;D[45]=62;D[95]=63;function Yt(e){var r=e.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=r);var n=t===r?0:4-t%4;return[t,n]}function ei(e){var r=Yt(e),t=r[0],n=r[1];return(t+n)*3/4-n}function ri(e,r,t){return(r+t)*3/4-t}function ti(e){var r,t=Yt(e),n=t[0],a=t[1],i=new La(ri(e,n,a)),o=0,s=a>0?n-4:n,l;for(l=0;l<s;l+=4)r=D[e.charCodeAt(l)]<<18|D[e.charCodeAt(l+1)]<<12|D[e.charCodeAt(l+2)]<<6|D[e.charCodeAt(l+3)],i[o++]=r>>16&255,i[o++]=r>>8&255,i[o++]=r&255;return a===2&&(r=D[e.charCodeAt(l)]<<2|D[e.charCodeAt(l+1)]>>4,i[o++]=r&255),a===1&&(r=D[e.charCodeAt(l)]<<10|D[e.charCodeAt(l+1)]<<4|D[e.charCodeAt(l+2)]>>2,i[o++]=r>>8&255,i[o++]=r&255),i}function ni(e){return X[e>>18&63]+X[e>>12&63]+X[e>>6&63]+X[e&63]}function ai(e,r,t){for(var n,a=[],i=r;i<t;i+=3)n=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(e[i+2]&255),a.push(ni(n));return a.join("")}function ii(e){for(var r,t=e.length,n=t%3,a=[],i=16383,o=0,s=t-n;o<s;o+=i)a.push(ai(e,o,o+i>s?s:o+i));return n===1?(r=e[t-1],a.push(X[r>>2]+X[r<<4&63]+"==")):n===2&&(r=(e[t-2]<<8)+e[t-1],a.push(X[r>>10]+X[r>>4&63]+X[r<<2&63]+"=")),a.join("")}});var mn=Jt(Be=>{"use strict";var lt=Xt(),Ce=Xa(),Qt=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Be.Buffer=c;Be.SlowBuffer=di;Be.INSPECT_MAX_BYTES=50;var Sr=2147483647;Be.kMaxLength=Sr;c.TYPED_ARRAY_SUPPORT=oi();!c.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 oi(){try{let e=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(e,r),e.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}});Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function se(e){if(e>Sr)throw new RangeError('The value "'+e+'" is invalid for option "size"');let r=new Uint8Array(e);return Object.setPrototypeOf(r,c.prototype),r}function c(e,r,t){if(typeof e=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return _t(e)}return rn(e,r,t)}c.poolSize=8192;function rn(e,r,t){if(typeof e=="string")return ci(e,r);if(ArrayBuffer.isView(e))return li(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Q(e,ArrayBuffer)||e&&Q(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Q(e,SharedArrayBuffer)||e&&Q(e.buffer,SharedArrayBuffer)))return dt(e,r,t);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return c.from(n,r,t);let a=ui(e);if(a)return a;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return c.from(e[Symbol.toPrimitive]("string"),r,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}c.from=function(e,r,t){return rn(e,r,t)};Object.setPrototypeOf(c.prototype,Uint8Array.prototype);Object.setPrototypeOf(c,Uint8Array);function tn(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function si(e,r,t){return tn(e),e<=0?se(e):r!==void 0?typeof t=="string"?se(e).fill(r,t):se(e).fill(r):se(e)}c.alloc=function(e,r,t){return si(e,r,t)};function _t(e){return tn(e),se(e<0?0:mt(e)|0)}c.allocUnsafe=function(e){return _t(e)};c.allocUnsafeSlow=function(e){return _t(e)};function ci(e,r){if((typeof r!="string"||r==="")&&(r="utf8"),!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let t=nn(e,r)|0,n=se(t),a=n.write(e,r);return a!==t&&(n=n.slice(0,a)),n}function ut(e){let r=e.length<0?0:mt(e.length)|0,t=se(r);for(let n=0;n<r;n+=1)t[n]=e[n]&255;return t}function li(e){if(Q(e,Uint8Array)){let r=new Uint8Array(e);return dt(r.buffer,r.byteOffset,r.byteLength)}return ut(e)}function dt(e,r,t){if(r<0||e.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<r+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return r===void 0&&t===void 0?n=new Uint8Array(e):t===void 0?n=new Uint8Array(e,r):n=new Uint8Array(e,r,t),Object.setPrototypeOf(n,c.prototype),n}function ui(e){if(c.isBuffer(e)){let r=mt(e.length)|0,t=se(r);return t.length===0||e.copy(t,0,0,r),t}if(e.length!==void 0)return typeof e.length!="number"||ht(e.length)?se(0):ut(e);if(e.type==="Buffer"&&Array.isArray(e.data))return ut(e.data)}function mt(e){if(e>=Sr)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Sr.toString(16)+" bytes");return e|0}function di(e){return+e!=e&&(e=0),c.alloc(+e)}c.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==c.prototype};c.compare=function(r,t){if(Q(r,Uint8Array)&&(r=c.from(r,r.offset,r.byteLength)),Q(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(r)||!c.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===t)return 0;let n=r.length,a=t.length;for(let i=0,o=Math.min(n,a);i<o;++i)if(r[i]!==t[i]){n=r[i],a=t[i];break}return n<a?-1:a<n?1:0};c.isEncoding=function(r){switch(String(r).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}};c.concat=function(r,t){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return c.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<r.length;++n)t+=r[n].length;let a=c.allocUnsafe(t),i=0;for(n=0;n<r.length;++n){let o=r[n];if(Q(o,Uint8Array))i+o.length>a.length?(c.isBuffer(o)||(o=c.from(o)),o.copy(a,i)):Uint8Array.prototype.set.call(a,o,i);else if(c.isBuffer(o))o.copy(a,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=o.length}return a};function nn(e,r){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Q(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let t=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let a=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return pt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return _n(e).length;default:if(a)return n?-1:pt(e).length;r=(""+r).toLowerCase(),a=!0}}c.byteLength=nn;function pi(e,r,t){let n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,r>>>=0,t<=r))return"";for(e||(e="utf8");;)switch(e){case"hex":return Oi(this,r,t);case"utf8":case"utf-8":return on(this,r,t);case"ascii":return gi(this,r,t);case"latin1":case"binary":return xi(this,r,t);case"base64":return Ti(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ri(this,r,t);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}c.prototype._isBuffer=!0;function Fe(e,r,t){let n=e[r];e[r]=e[t],e[t]=n}c.prototype.swap16=function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<r;t+=2)Fe(this,t,t+1);return this};c.prototype.swap32=function(){let r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<r;t+=4)Fe(this,t,t+3),Fe(this,t+1,t+2);return this};c.prototype.swap64=function(){let r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<r;t+=8)Fe(this,t,t+7),Fe(this,t+1,t+6),Fe(this,t+2,t+5),Fe(this,t+3,t+4);return this};c.prototype.toString=function(){let r=this.length;return r===0?"":arguments.length===0?on(this,0,r):pi.apply(this,arguments)};c.prototype.toLocaleString=c.prototype.toString;c.prototype.equals=function(r){if(!c.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:c.compare(this,r)===0};c.prototype.inspect=function(){let r="",t=Be.INSPECT_MAX_BYTES;return r=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(r+=" ... "),"<Buffer "+r+">"};Qt&&(c.prototype[Qt]=c.prototype.inspect);c.prototype.compare=function(r,t,n,a,i){if(Q(r,Uint8Array)&&(r=c.from(r,r.offset,r.byteLength)),!c.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(t===void 0&&(t=0),n===void 0&&(n=r?r.length:0),a===void 0&&(a=0),i===void 0&&(i=this.length),t<0||n>r.length||a<0||i>this.length)throw new RangeError("out of range index");if(a>=i&&t>=n)return 0;if(a>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,a>>>=0,i>>>=0,this===r)return 0;let o=i-a,s=n-t,l=Math.min(o,s),u=this.slice(a,i),p=r.slice(t,n);for(let d=0;d<l;++d)if(u[d]!==p[d]){o=u[d],s=p[d];break}return o<s?-1:s<o?1:0};function an(e,r,t,n,a){if(e.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,ht(t)&&(t=a?0:e.length-1),t<0&&(t=e.length+t),t>=e.length){if(a)return-1;t=e.length-1}else if(t<0)if(a)t=0;else return-1;if(typeof r=="string"&&(r=c.from(r,n)),c.isBuffer(r))return r.length===0?-1:Zt(e,r,t,n,a);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?a?Uint8Array.prototype.indexOf.call(e,r,t):Uint8Array.prototype.lastIndexOf.call(e,r,t):Zt(e,[r],t,n,a);throw new TypeError("val must be string, number or Buffer")}function Zt(e,r,t,n,a){let i=1,o=e.length,s=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||r.length<2)return-1;i=2,o/=2,s/=2,t/=2}function l(p,d){return i===1?p[d]:p.readUInt16BE(d*i)}let u;if(a){let p=-1;for(u=t;u<o;u++)if(l(e,u)===l(r,p===-1?0:u-p)){if(p===-1&&(p=u),u-p+1===s)return p*i}else p!==-1&&(u-=u-p),p=-1}else for(t+s>o&&(t=o-s),u=t;u>=0;u--){let p=!0;for(let d=0;d<s;d++)if(l(e,u+d)!==l(r,d)){p=!1;break}if(p)return u}return-1}c.prototype.includes=function(r,t,n){return this.indexOf(r,t,n)!==-1};c.prototype.indexOf=function(r,t,n){return an(this,r,t,n,!0)};c.prototype.lastIndexOf=function(r,t,n){return an(this,r,t,n,!1)};function _i(e,r,t,n){t=Number(t)||0;let a=e.length-t;n?(n=Number(n),n>a&&(n=a)):n=a;let i=r.length;n>i/2&&(n=i/2);let o;for(o=0;o<n;++o){let s=parseInt(r.substr(o*2,2),16);if(ht(s))return o;e[t+o]=s}return o}function mi(e,r,t,n){return kr(pt(r,e.length-t),e,t,n)}function fi(e,r,t,n){return kr(bi(r),e,t,n)}function hi(e,r,t,n){return kr(_n(r),e,t,n)}function yi(e,r,t,n){return kr(Ai(r,e.length-t),e,t,n)}c.prototype.write=function(r,t,n,a){if(t===void 0)a="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")a=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,a===void 0&&(a="utf8")):(a=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let i=this.length-t;if((n===void 0||n>i)&&(n=i),r.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");a||(a="utf8");let o=!1;for(;;)switch(a){case"hex":return _i(this,r,t,n);case"utf8":case"utf-8":return mi(this,r,t,n);case"ascii":case"latin1":case"binary":return fi(this,r,t,n);case"base64":return hi(this,r,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return yi(this,r,t,n);default:if(o)throw new TypeError("Unknown encoding: "+a);a=(""+a).toLowerCase(),o=!0}};c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ti(e,r,t){return r===0&&t===e.length?lt.fromByteArray(e):lt.fromByteArray(e.slice(r,t))}function on(e,r,t){t=Math.min(e.length,t);let n=[],a=r;for(;a<t;){let i=e[a],o=null,s=i>239?4:i>223?3:i>191?2:1;if(a+s<=t){let l,u,p,d;switch(s){case 1:i<128&&(o=i);break;case 2:l=e[a+1],(l&192)===128&&(d=(i&31)<<6|l&63,d>127&&(o=d));break;case 3:l=e[a+1],u=e[a+2],(l&192)===128&&(u&192)===128&&(d=(i&15)<<12|(l&63)<<6|u&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:l=e[a+1],u=e[a+2],p=e[a+3],(l&192)===128&&(u&192)===128&&(p&192)===128&&(d=(i&15)<<18|(l&63)<<12|(u&63)<<6|p&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),a+=s}return Ni(n)}var Lt=4096;function Ni(e){let r=e.length;if(r<=Lt)return String.fromCharCode.apply(String,e);let t="",n=0;for(;n<r;)t+=String.fromCharCode.apply(String,e.slice(n,n+=Lt));return t}function gi(e,r,t){let n="";t=Math.min(e.length,t);for(let a=r;a<t;++a)n+=String.fromCharCode(e[a]&127);return n}function xi(e,r,t){let n="";t=Math.min(e.length,t);for(let a=r;a<t;++a)n+=String.fromCharCode(e[a]);return n}function Oi(e,r,t){let n=e.length;(!r||r<0)&&(r=0),(!t||t<0||t>n)&&(t=n);let a="";for(let i=r;i<t;++i)a+=Vi[e[i]];return a}function Ri(e,r,t){let n=e.slice(r,t),a="";for(let i=0;i<n.length-1;i+=2)a+=String.fromCharCode(n[i]+n[i+1]*256);return a}c.prototype.slice=function(r,t){let n=this.length;r=~~r,t=t===void 0?n:~~t,r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<r&&(t=r);let a=this.subarray(r,t);return Object.setPrototypeOf(a,c.prototype),a};function b(e,r,t){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+r>t)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(r,t,n){r=r>>>0,t=t>>>0,n||b(r,t,this.length);let a=this[r],i=1,o=0;for(;++o<t&&(i*=256);)a+=this[r+o]*i;return a};c.prototype.readUintBE=c.prototype.readUIntBE=function(r,t,n){r=r>>>0,t=t>>>0,n||b(r,t,this.length);let a=this[r+--t],i=1;for(;t>0&&(i*=256);)a+=this[r+--t]*i;return a};c.prototype.readUint8=c.prototype.readUInt8=function(r,t){return r=r>>>0,t||b(r,1,this.length),this[r]};c.prototype.readUint16LE=c.prototype.readUInt16LE=function(r,t){return r=r>>>0,t||b(r,2,this.length),this[r]|this[r+1]<<8};c.prototype.readUint16BE=c.prototype.readUInt16BE=function(r,t){return r=r>>>0,t||b(r,2,this.length),this[r]<<8|this[r+1]};c.prototype.readUint32LE=c.prototype.readUInt32LE=function(r,t){return r=r>>>0,t||b(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};c.prototype.readUint32BE=c.prototype.readUInt32BE=function(r,t){return r=r>>>0,t||b(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};c.prototype.readBigUInt64LE=de(function(r){r=r>>>0,Ue(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&_r(r,this.length-8);let a=t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,i=this[++r]+this[++r]*2**8+this[++r]*2**16+n*2**24;return BigInt(a)+(BigInt(i)<<BigInt(32))});c.prototype.readBigUInt64BE=de(function(r){r=r>>>0,Ue(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&_r(r,this.length-8);let a=t*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],i=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+n;return(BigInt(a)<<BigInt(32))+BigInt(i)});c.prototype.readIntLE=function(r,t,n){r=r>>>0,t=t>>>0,n||b(r,t,this.length);let a=this[r],i=1,o=0;for(;++o<t&&(i*=256);)a+=this[r+o]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*t)),a};c.prototype.readIntBE=function(r,t,n){r=r>>>0,t=t>>>0,n||b(r,t,this.length);let a=t,i=1,o=this[r+--a];for(;a>0&&(i*=256);)o+=this[r+--a]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o};c.prototype.readInt8=function(r,t){return r=r>>>0,t||b(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};c.prototype.readInt16LE=function(r,t){r=r>>>0,t||b(r,2,this.length);let n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n};c.prototype.readInt16BE=function(r,t){r=r>>>0,t||b(r,2,this.length);let n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n};c.prototype.readInt32LE=function(r,t){return r=r>>>0,t||b(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};c.prototype.readInt32BE=function(r,t){return r=r>>>0,t||b(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};c.prototype.readBigInt64LE=de(function(r){r=r>>>0,Ue(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&_r(r,this.length-8);let a=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(n<<24);return(BigInt(a)<<BigInt(32))+BigInt(t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)});c.prototype.readBigInt64BE=de(function(r){r=r>>>0,Ue(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&_r(r,this.length-8);let a=(t<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(a)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+n)});c.prototype.readFloatLE=function(r,t){return r=r>>>0,t||b(r,4,this.length),Ce.read(this,r,!0,23,4)};c.prototype.readFloatBE=function(r,t){return r=r>>>0,t||b(r,4,this.length),Ce.read(this,r,!1,23,4)};c.prototype.readDoubleLE=function(r,t){return r=r>>>0,t||b(r,8,this.length),Ce.read(this,r,!0,52,8)};c.prototype.readDoubleBE=function(r,t){return r=r>>>0,t||b(r,8,this.length),Ce.read(this,r,!1,52,8)};function k(e,r,t,n,a,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>a||r<i)throw new RangeError('"value" argument is out of bounds');if(t+n>e.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(r,t,n,a){if(r=+r,t=t>>>0,n=n>>>0,!a){let s=Math.pow(2,8*n)-1;k(this,r,t,n,s,0)}let i=1,o=0;for(this[t]=r&255;++o<n&&(i*=256);)this[t+o]=r/i&255;return t+n};c.prototype.writeUintBE=c.prototype.writeUIntBE=function(r,t,n,a){if(r=+r,t=t>>>0,n=n>>>0,!a){let s=Math.pow(2,8*n)-1;k(this,r,t,n,s,0)}let i=n-1,o=1;for(this[t+i]=r&255;--i>=0&&(o*=256);)this[t+i]=r/o&255;return t+n};c.prototype.writeUint8=c.prototype.writeUInt8=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,1,255,0),this[t]=r&255,t+1};c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,2,65535,0),this[t]=r&255,this[t+1]=r>>>8,t+2};c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,2,65535,0),this[t]=r>>>8,this[t+1]=r&255,t+2};c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,4,4294967295,0),this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=r&255,t+4};c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,4,4294967295,0),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};function sn(e,r,t,n,a){pn(r,n,a,e,t,7);let i=Number(r&BigInt(4294967295));e[t++]=i,i=i>>8,e[t++]=i,i=i>>8,e[t++]=i,i=i>>8,e[t++]=i;let o=Number(r>>BigInt(32)&BigInt(4294967295));return e[t++]=o,o=o>>8,e[t++]=o,o=o>>8,e[t++]=o,o=o>>8,e[t++]=o,t}function cn(e,r,t,n,a){pn(r,n,a,e,t,7);let i=Number(r&BigInt(4294967295));e[t+7]=i,i=i>>8,e[t+6]=i,i=i>>8,e[t+5]=i,i=i>>8,e[t+4]=i;let o=Number(r>>BigInt(32)&BigInt(4294967295));return e[t+3]=o,o=o>>8,e[t+2]=o,o=o>>8,e[t+1]=o,o=o>>8,e[t]=o,t+8}c.prototype.writeBigUInt64LE=de(function(r,t=0){return sn(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeBigUInt64BE=de(function(r,t=0){return cn(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeIntLE=function(r,t,n,a){if(r=+r,t=t>>>0,!a){let l=Math.pow(2,8*n-1);k(this,r,t,n,l-1,-l)}let i=0,o=1,s=0;for(this[t]=r&255;++i<n&&(o*=256);)r<0&&s===0&&this[t+i-1]!==0&&(s=1),this[t+i]=(r/o>>0)-s&255;return t+n};c.prototype.writeIntBE=function(r,t,n,a){if(r=+r,t=t>>>0,!a){let l=Math.pow(2,8*n-1);k(this,r,t,n,l-1,-l)}let i=n-1,o=1,s=0;for(this[t+i]=r&255;--i>=0&&(o*=256);)r<0&&s===0&&this[t+i+1]!==0&&(s=1),this[t+i]=(r/o>>0)-s&255;return t+n};c.prototype.writeInt8=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,1,127,-128),r<0&&(r=255+r+1),this[t]=r&255,t+1};c.prototype.writeInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,2,32767,-32768),this[t]=r&255,this[t+1]=r>>>8,t+2};c.prototype.writeInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,2,32767,-32768),this[t]=r>>>8,this[t+1]=r&255,t+2};c.prototype.writeInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,4,2147483647,-2147483648),this[t]=r&255,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24,t+4};c.prototype.writeInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};c.prototype.writeBigInt64LE=de(function(r,t=0){return sn(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});c.prototype.writeBigInt64BE=de(function(r,t=0){return cn(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ln(e,r,t,n,a,i){if(t+n>e.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function un(e,r,t,n,a){return r=+r,t=t>>>0,a||ln(e,r,t,4,34028234663852886e22,-34028234663852886e22),Ce.write(e,r,t,n,23,4),t+4}c.prototype.writeFloatLE=function(r,t,n){return un(this,r,t,!0,n)};c.prototype.writeFloatBE=function(r,t,n){return un(this,r,t,!1,n)};function dn(e,r,t,n,a){return r=+r,t=t>>>0,a||ln(e,r,t,8,17976931348623157e292,-17976931348623157e292),Ce.write(e,r,t,n,52,8),t+8}c.prototype.writeDoubleLE=function(r,t,n){return dn(this,r,t,!0,n)};c.prototype.writeDoubleBE=function(r,t,n){return dn(this,r,t,!1,n)};c.prototype.copy=function(r,t,n,a){if(!c.isBuffer(r))throw new TypeError("argument should be a Buffer");if(n||(n=0),!a&&a!==0&&(a=this.length),t>=r.length&&(t=r.length),t||(t=0),a>0&&a<n&&(a=n),a===n||r.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length),r.length-t<a-n&&(a=r.length-t+n);let i=a-n;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,a):Uint8Array.prototype.set.call(r,this.subarray(n,a),t),i};c.prototype.fill=function(r,t,n,a){if(typeof r=="string"){if(typeof t=="string"?(a=t,t=0,n=this.length):typeof n=="string"&&(a=n,n=this.length),a!==void 0&&typeof a!="string")throw new TypeError("encoding must be a string");if(typeof a=="string"&&!c.isEncoding(a))throw new TypeError("Unknown encoding: "+a);if(r.length===1){let o=r.charCodeAt(0);(a==="utf8"&&o<128||a==="latin1")&&(r=o)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,r||(r=0);let i;if(typeof r=="number")for(i=t;i<n;++i)this[i]=r;else{let o=c.isBuffer(r)?r:c.from(r,a),s=o.length;if(s===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(i=0;i<n-t;++i)this[i+t]=o[i%s]}return this};var ke={};function ft(e,r,t){ke[e]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(a){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:a,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}ft("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ft("ERR_INVALID_ARG_TYPE",function(e,r){return`The "${e}" argument must be of type number. Received type ${typeof r}`},TypeError);ft("ERR_OUT_OF_RANGE",function(e,r,t){let n=`The value of "${e}" is out of range.`,a=t;return Number.isInteger(t)&&Math.abs(t)>2**32?a=en(String(t)):typeof t=="bigint"&&(a=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(a=en(a)),a+="n"),n+=` It must be ${r}. Received ${a}`,n},RangeError);function en(e){let r="",t=e.length,n=e[0]==="-"?1:0;for(;t>=n+4;t-=3)r=`_${e.slice(t-3,t)}${r}`;return`${e.slice(0,t)}${r}`}function wi(e,r,t){Ue(r,"offset"),(e[r]===void 0||e[r+t]===void 0)&&_r(r,e.length-(t+1))}function pn(e,r,t,n,a,i){if(e>t||e<r){let o=typeof r=="bigint"?"n":"",s;throw i>3?r===0||r===BigInt(0)?s=`>= 0${o} and < 2${o} ** ${(i+1)*8}${o}`:s=`>= -(2${o} ** ${(i+1)*8-1}${o}) and < 2 ** ${(i+1)*8-1}${o}`:s=`>= ${r}${o} and <= ${t}${o}`,new ke.ERR_OUT_OF_RANGE("value",s,e)}wi(n,a,i)}function Ue(e,r){if(typeof e!="number")throw new ke.ERR_INVALID_ARG_TYPE(r,"number",e)}function _r(e,r,t){throw Math.floor(e)!==e?(Ue(e,t),new ke.ERR_OUT_OF_RANGE(t||"offset","an integer",e)):r<0?new ke.ERR_BUFFER_OUT_OF_BOUNDS:new ke.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${r}`,e)}var Fi=/[^+/0-9A-Za-z-_]/g;function Ei(e){if(e=e.split("=")[0],e=e.trim().replace(Fi,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function pt(e,r){r=r||1/0;let t,n=e.length,a=null,i=[];for(let o=0;o<n;++o){if(t=e.charCodeAt(o),t>55295&&t<57344){if(!a){if(t>56319){(r-=3)>-1&&i.push(239,191,189);continue}else if(o+1===n){(r-=3)>-1&&i.push(239,191,189);continue}a=t;continue}if(t<56320){(r-=3)>-1&&i.push(239,191,189),a=t;continue}t=(a-55296<<10|t-56320)+65536}else a&&(r-=3)>-1&&i.push(239,191,189);if(a=null,t<128){if((r-=1)<0)break;i.push(t)}else if(t<2048){if((r-=2)<0)break;i.push(t>>6|192,t&63|128)}else if(t<65536){if((r-=3)<0)break;i.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((r-=4)<0)break;i.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return i}function bi(e){let r=[];for(let t=0;t<e.length;++t)r.push(e.charCodeAt(t)&255);return r}function Ai(e,r){let t,n,a,i=[];for(let o=0;o<e.length&&!((r-=2)<0);++o)t=e.charCodeAt(o),n=t>>8,a=t%256,i.push(a),i.push(n);return i}function _n(e){return lt.toByteArray(Ei(e))}function kr(e,r,t,n){let a;for(a=0;a<n&&!(a+t>=r.length||a>=e.length);++a)r[a+t]=e[a];return a}function Q(e,r){return e instanceof r||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===r.name}function ht(e){return e!==e}var Vi=function(){let e="0123456789abcdef",r=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let a=0;a<16;++a)r[n+a]=e[t]+e[a]}return r}();function de(e){return typeof BigInt>"u"?Pi:e}function Pi(){throw new Error("BigInt not supported")}});var On=nt(mn());var Ur={};Ya(Ur,{backoff:()=>Tn,chain:()=>Nn,conditionalDelay:()=>hn,defaultStrategy:()=>Cr,maxAttempts:()=>Si,once:()=>fn,throttle:()=>ki,timeout:()=>yn});var vi=300*1e3;function Cr(){return Nn(hn(fn(),1e3),Tn(1e3,1.2),yn(vi))}function fn(){let e=!0;return async()=>e?(e=!1,!0):!1}function hn(e,r){return async(t,n,a)=>{if(await e(t,n,a))return new Promise(i=>setTimeout(i,r))}}function Si(e){let r=e;return async(t,n,a)=>{if(--r<=0)throw new Error(`Failed to retrieve a reply for request after ${e} attempts:
2
2
  Request ID: ${P(n)}
3
3
  Request status: ${a}
4
- `)}}function ki(e){return()=>new Promise(r=>setTimeout(r,e))}function hn(e){let r=Date.now()+e;return async(t,n,a)=>{if(Date.now()>r)throw new Error(`Request timed out after ${e} msec:
4
+ `)}}function ki(e){return()=>new Promise(r=>setTimeout(r,e))}function yn(e){let r=Date.now()+e;return async(t,n,a)=>{if(Date.now()>r)throw new Error(`Request timed out after ${e} msec:
5
5
  Request ID: ${P(n)}
6
6
  Request status: ${a}
7
- `)}}function Tn(e,r){let t=e;return()=>new Promise(n=>setTimeout(()=>{t*=r,n()},t))}function Nn(...e){return async(r,t,n)=>{for(let a of e)await a(r,t,n)}}async function ht(e,r,t,n=kr(),a,i){var o;let s=[new TextEncoder().encode("request_status"),t],l=a??await((o=e.createReadStateRequest)===null||o===void 0?void 0:o.call(e,{paths:[s]})),u=await e.readState(r,{paths:[s]},void 0,l);if(e.rootKey==null)throw new Error("Agent root key not initialized before polling");let p=await br.create({certificate:u.certificate,rootKey:e.rootKey,canisterId:r,blsVerify:i}),d=z(p.lookup([...s,new TextEncoder().encode("status")])),m;switch(typeof d>"u"?m=le.Unknown:m=new TextDecoder().decode(d),m){case le.Replied:return{reply:z(p.lookup([...s,"reply"])),certificate:p};case le.Received:case le.Unknown:case le.Processing:return await n(r,t,m),ht(e,r,t,n,l,i);case le.Rejected:{let f=new Uint8Array(z(p.lookup([...s,"reject_code"])))[0],x=new TextDecoder().decode(z(p.lookup([...s,"reject_message"])));throw new Error(`Call was rejected:
7
+ `)}}function Tn(e,r){let t=e;return()=>new Promise(n=>setTimeout(()=>{t*=r,n()},t))}function Nn(...e){return async(r,t,n)=>{for(let a of e)await a(r,t,n)}}async function yt(e,r,t,n=Cr(),a,i){var o;let s=[new TextEncoder().encode("request_status"),t],l=a??await((o=e.createReadStateRequest)===null||o===void 0?void 0:o.call(e,{paths:[s]})),u=await e.readState(r,{paths:[s]},void 0,l);if(e.rootKey==null)throw new Error("Agent root key not initialized before polling");let p=await Ar.create({certificate:u.certificate,rootKey:e.rootKey,canisterId:r,blsVerify:i}),d=z(p.lookup([...s,new TextEncoder().encode("status")])),m;switch(typeof d>"u"?m=ue.Unknown:m=new TextDecoder().decode(d),m){case ue.Replied:return{reply:z(p.lookup([...s,"reply"])),certificate:p};case ue.Received:case ue.Unknown:case ue.Processing:return await n(r,t,m),yt(e,r,t,n,l,i);case ue.Rejected:{let f=new Uint8Array(z(p.lookup([...s,"reject_code"])))[0],x=new TextDecoder().decode(z(p.lookup([...s,"reject_message"])));throw new Error(`Call was rejected:
8
8
  Request ID: ${P(t)}
9
9
  Reject code: ${f}
10
10
  Reject text: ${x}
11
- `)}case le.Done:throw new Error(`Call was marked as done but we never saw the reply:
11
+ `)}case ue.Done:throw new Error(`Call was marked as done but we never saw the reply:
12
12
  Request ID: ${P(t)}
13
- `)}throw new Error("unreachable")}var gn=({IDL:e})=>{let r=e.Variant({mainnet:e.Null,testnet:e.Null}),t=e.Text,n=e.Record({network:r,address:t,min_confirmations:e.Opt(e.Nat32)}),a=e.Nat64,i=a,o=e.Nat32,s=e.Record({start_height:o,end_height:e.Opt(o),network:r}),l=e.Vec(e.Nat8),u=e.Record({tip_height:o,block_headers:e.Vec(l)}),p=e.Record({network:r}),d=e.Nat64,m=e.Vec(d),f=e.Record({network:r,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:t}),x=e.Vec(e.Nat8),B=e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32}),K=e.Record({height:e.Nat32,value:a,outpoint:B}),C=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:o,tip_block_hash:x,utxos:e.Vec(K)}),O=e.Record({transaction:e.Vec(e.Nat8),network:r}),_=e.Principal,V=e.Record({canister_id:_,num_requested_changes:e.Opt(e.Nat64)}),R=e.Variant({from_user:e.Record({user_id:e.Principal}),from_canister:e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal})}),w=e.Vec(e.Nat8),S=e.Variant({creation:e.Record({controllers:e.Vec(e.Principal)}),code_deployment:e.Record({mode:e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),module_hash:e.Vec(e.Nat8)}),load_snapshot:e.Record({canister_version:e.Nat64,taken_at_timestamp:e.Nat64,snapshot_id:w}),controllers_change:e.Record({controllers:e.Vec(e.Principal)}),code_uninstall:e.Null}),I=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:R,details:S}),U=e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec(I),total_num_changes:e.Nat64}),E=e.Record({canister_id:_}),J=e.Variant({controllers:e.Null,public:e.Null,allowed_viewers:e.Vec(e.Principal)}),H=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),reserved_cycles_limit:e.Nat,log_visibility:J,wasm_memory_limit:e.Nat,memory_allocation:e.Nat,compute_allocation:e.Nat}),me=e.Record({status:e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),memory_size:e.Nat,cycles:e.Nat,settings:H,query_stats:e.Record({response_payload_bytes_total:e.Nat,num_instructions_total:e.Nat,num_calls_total:e.Nat,request_payload_bytes_total:e.Nat}),idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8)),reserved_cycles:e.Nat}),v=e.Record({canister_id:_}),re=e.Record({freezing_threshold:e.Opt(e.Nat),controllers:e.Opt(e.Vec(e.Principal)),reserved_cycles_limit:e.Opt(e.Nat),log_visibility:e.Opt(J),wasm_memory_limit:e.Opt(e.Nat),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),ze=e.Record({settings:e.Opt(re),sender_canister_version:e.Opt(e.Nat64)}),We=e.Record({canister_id:_}),fe=e.Record({canister_id:_}),$=e.Record({canister_id:_,snapshot_id:w}),te=e.Record({canister_id:_}),q=e.Variant({secp256k1:e.Null}),ye=e.Record({key_id:e.Record({name:e.Text,curve:q}),canister_id:e.Opt(_),derivation_path:e.Vec(e.Vec(e.Nat8))}),ne=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),Ge=e.Record({canister_id:_}),ae=e.Record({idx:e.Nat64,timestamp_nanos:e.Nat64,content:e.Vec(e.Nat8)}),Ye=e.Record({canister_log_records:e.Vec(ae)}),Ae=e.Record({value:e.Text,name:e.Text}),he=e.Record({status:e.Nat,body:e.Vec(e.Nat8),headers:e.Vec(Ae)}),Te=e.Record({url:e.Text,method:e.Variant({get:e.Null,head:e.Null,post:e.Null}),max_response_bytes:e.Opt(e.Nat64),body:e.Opt(e.Vec(e.Nat8)),transform:e.Opt(e.Record({function:e.Func([e.Record({context:e.Vec(e.Nat8),response:he})],[he],["query"]),context:e.Vec(e.Nat8)})),headers:e.Vec(Ae)}),se=e.Variant({reinstall:e.Null,upgrade:e.Opt(e.Record({wasm_memory_persistence:e.Opt(e.Variant({keep:e.Null,replace:e.Null})),skip_pre_upgrade:e.Opt(e.Bool)})),install:e.Null}),Ne=e.Record({hash:e.Vec(e.Nat8)}),Xe=e.Record({arg:e.Vec(e.Nat8),wasm_module_hash:e.Vec(e.Nat8),mode:se,chunk_hashes_list:e.Vec(Ne),target_canister:_,store_canister:e.Opt(_),sender_canister_version:e.Opt(e.Nat64)}),Qe=e.Vec(e.Nat8),Ze=e.Record({arg:e.Vec(e.Nat8),wasm_module:Qe,mode:se,canister_id:_,sender_canister_version:e.Opt(e.Nat64)}),Le=e.Record({canister_id:_}),Ve=e.Record({id:w,total_size:e.Nat64,taken_at_timestamp:e.Nat64}),er=e.Vec(Ve),rr=e.Record({canister_id:_,sender_canister_version:e.Opt(e.Nat64),snapshot_id:w}),tr=e.Record({start_at_timestamp_nanos:e.Nat64,subnet_id:e.Principal}),nr=e.Record({num_block_failures_total:e.Nat64,node_id:e.Principal,num_blocks_proposed_total:e.Nat64}),ar=e.Vec(e.Record({timestamp_nanos:e.Nat64,node_metrics:e.Vec(nr)})),ir=e.Record({settings:e.Opt(re),specified_id:e.Opt(_),amount:e.Opt(e.Nat),sender_canister_version:e.Opt(e.Nat64)}),or=e.Record({canister_id:_}),sr=e.Record({canister_id:_,amount:e.Nat}),cr=e.Vec(e.Nat8),Pe=e.Variant({ed25519:e.Null,bip340secp256k1:e.Null}),ge=e.Record({key_id:e.Record({algorithm:Pe,name:e.Text}),canister_id:e.Opt(_),derivation_path:e.Vec(e.Vec(e.Nat8))}),lr=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),ur=e.Record({key_id:e.Record({name:e.Text,curve:q}),derivation_path:e.Vec(e.Vec(e.Nat8)),message_hash:e.Vec(e.Nat8)}),xe=e.Record({signature:e.Vec(e.Nat8)}),Oe=e.Variant({bip341:e.Record({merkle_root_hash:e.Vec(e.Nat8)})}),Ua=e.Record({aux:e.Opt(Oe),key_id:e.Record({algorithm:Pe,name:e.Text}),derivation_path:e.Vec(e.Vec(e.Nat8)),message:e.Vec(e.Nat8)}),Ba=e.Record({signature:e.Vec(e.Nat8)}),Ia=e.Record({canister_id:_}),qa=e.Record({canister_id:_}),Da=e.Record({canister_id:_}),ja=e.Vec(Ne),Ma=e.Record({subnet_id:e.Principal}),Ka=e.Record({replica_version:e.Text}),Ja=e.Record({replace_snapshot:e.Opt(w),canister_id:_}),Ha=Ve,$a=e.Record({canister_id:_,sender_canister_version:e.Opt(e.Nat64)}),za=e.Record({canister_id:e.Principal,settings:re,sender_canister_version:e.Opt(e.Nat64)}),Wa=e.Record({chunk:e.Vec(e.Nat8),canister_id:e.Principal}),Ga=Ne;return e.Service({bitcoin_get_balance:e.Func([n],[i],[]),bitcoin_get_block_headers:e.Func([s],[u],[]),bitcoin_get_current_fee_percentiles:e.Func([p],[m],[]),bitcoin_get_utxos:e.Func([f],[C],[]),bitcoin_send_transaction:e.Func([O],[],[]),canister_info:e.Func([V],[U],[]),canister_status:e.Func([E],[me],[]),clear_chunk_store:e.Func([v],[],[]),create_canister:e.Func([ze],[We],[]),delete_canister:e.Func([fe],[],[]),delete_canister_snapshot:e.Func([$],[],[]),deposit_cycles:e.Func([te],[],[]),ecdsa_public_key:e.Func([ye],[ne],[]),fetch_canister_logs:e.Func([Ge],[Ye],["query"]),http_request:e.Func([Te],[he],[]),install_chunked_code:e.Func([Xe],[],[]),install_code:e.Func([Ze],[],[]),list_canister_snapshots:e.Func([Le],[er],[]),load_canister_snapshot:e.Func([rr],[],[]),node_metrics_history:e.Func([tr],[ar],[]),provisional_create_canister_with_cycles:e.Func([ir],[or],[]),provisional_top_up_canister:e.Func([sr],[],[]),raw_rand:e.Func([],[cr],[]),schnorr_public_key:e.Func([ge],[lr],[]),sign_with_ecdsa:e.Func([ur],[xe],[]),sign_with_schnorr:e.Func([Ua],[Ba],[]),start_canister:e.Func([Ia],[],[]),stop_canister:e.Func([qa],[],[]),stored_chunks:e.Func([Da],[ja],[]),subnet_info:e.Func([Ma],[Ka],[]),take_canister_snapshot:e.Func([Ja],[Ha],[]),uninstall_code:e.Func([$a],[],[]),update_settings:e.Func([za],[],[]),upload_chunk:e.Func([Wa],[Ga],[])})};var Ur=class extends Er{constructor(r,t,n,a){super(["Call failed:",` Canister: ${r.toText()}`,` Method: ${t} (${n})`,...Object.getOwnPropertyNames(a).map(i=>` "${i}": ${JSON.stringify(a[i])}`)].join(`
14
- `)),this.canisterId=r,this.methodName=t,this.type=n,this.props=a}},Tt=class extends Ur{constructor(r,t,n){var a;super(r,t,"query",{Status:n.status,Code:(a=Ht[n.reject_code])!==null&&a!==void 0?a:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},Br=class extends Ur{constructor(r,t,n,a,i,o,s){super(r,t,"update",Object.assign({"Request ID":P(n)},a.body?Object.assign(Object.assign({},s?{"Error code":s}:{}),{"Reject code":String(i),"Reject message":o}):{"HTTP status code":a.status.toString(),"HTTP status text":a.statusText})),this.requestId=n,this.response=a,this.reject_code=i,this.reject_message=o,this.error_code=s}},j=Symbol.for("ic-agent-metadata"),oe=class e{constructor(r){this[j]=Object.freeze(r)}static agentOf(r){return r[j].config.agent}static interfaceOf(r){return r[j].service}static canisterIdOf(r){return h.from(r[j].config.canisterId)}static async install(r,t){let n=r.mode===void 0?{install:null}:r.mode,a=r.arg?[...new Uint8Array(r.arg)]:[],i=[...new Uint8Array(r.module)],o=typeof t.canisterId=="string"?h.fromText(t.canisterId):t.canisterId;await xn(t).install_code({mode:n,arg:a,wasm_module:i,canister_id:o,sender_canister_version:[]})}static async createCanister(r,t){function n(i){return[{controllers:i.controllers?[i.controllers]:[],compute_allocation:i.compute_allocation?[i.compute_allocation]:[],freezing_threshold:i.freezing_threshold?[i.freezing_threshold]:[],memory_allocation:i.memory_allocation?[i.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:a}=await xn(r||{}).provisional_create_canister_with_cycles({amount:[],settings:n(t||{}),specified_id:[],sender_canister_version:[]});return a}static async createAndInstallCanister(r,t,n){let a=await this.createCanister(n);return await this.install(Object.assign({},t),Object.assign(Object.assign({},n),{canisterId:a})),this.createActor(r,Object.assign(Object.assign({},n),{canisterId:a}))}static createActorClass(r,t){let n=r({IDL:dr});class a extends e{constructor(o){if(!o.canisterId)throw new Er(`Canister ID is required, but received ${typeof o.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 s=typeof o.canisterId=="string"?h.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Rn),o),{canisterId:s}),service:n});for(let[l,u]of n._fields)t?.httpDetails&&u.annotations.push(Nt),t?.certificate&&u.annotations.push(wn),this[l]=Ui(this,l,u,o.blsVerify)}}return a}static createActor(r,t){if(!t.canisterId)throw new Er(`Canister ID is required, but received ${typeof t.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(r))(t)}static createActorWithHttpDetails(r,t){return new(this.createActorClass(r,{httpDetails:!0}))(t)}static createActorWithExtendedDetails(r,t,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(r,n))(t)}};function Ie(e,r){let t=dr.decode(e,On.Buffer.from(r));switch(t.length){case 0:return;case 1:return t[0];default:return t}}var Rn={pollingStrategyFactory:Cr.defaultStrategy},Nt="http-details",wn="certificate";function Ui(e,r,t,n){let a;t.annotations.includes("query")||t.annotations.includes("composite_query")?a=async(o,...s)=>{var l,u;o=Object.assign(Object.assign({},o),(u=(l=e[j].config).queryTransform)===null||u===void 0?void 0:u.call(l,r,s,Object.assign(Object.assign({},e[j].config),o)));let p=o.agent||e[j].config.agent||st(),d=h.from(o.canisterId||e[j].config.canisterId),m=dr.encode(t.argTypes,s),f=await p.query(d,{methodName:r,arg:m,effectiveCanisterId:o.effectiveCanisterId}),x=Object.assign(Object.assign({},f.httpDetails),{requestDetails:f.requestDetails});switch(f.status){case"rejected":throw new Tt(d,r,f);case"replied":return t.annotations.includes(Nt)?{httpDetails:x,result:Ie(t.retTypes,f.reply.arg)}:Ie(t.retTypes,f.reply.arg)}}:a=async(o,...s)=>{var l,u;o=Object.assign(Object.assign({},o),(u=(l=e[j].config).callTransform)===null||u===void 0?void 0:u.call(l,r,s,Object.assign(Object.assign({},e[j].config),o)));let p=o.agent||e[j].config.agent||st(),{canisterId:d,effectiveCanisterId:m,pollingStrategyFactory:f}=Object.assign(Object.assign(Object.assign({},Rn),e[j].config),o),x=h.from(d),B=m!==void 0?h.from(m):x,K=dr.encode(t.argTypes,s),{requestId:C,response:O,requestDetails:_}=await p.call(x,{methodName:r,arg:K,effectiveCanisterId:B}),V,R;if(O.body&&O.body.certificate){if(p.rootKey==null)throw new Error("Agent is missing root key");let U=O.body.certificate;R=await br.create({certificate:at(U),rootKey:p.rootKey,canisterId:h.from(d),blsVerify:n});let E=[new TextEncoder().encode("request_status"),C];switch(new TextDecoder().decode(z(R.lookup([...E,"status"])))){case"replied":V=z(R.lookup([...E,"reply"]));break;case"rejected":{let H=new Uint8Array(z(R.lookup([...E,"reject_code"])))[0],me=new TextDecoder().decode(z(R.lookup([...E,"reject_message"]))),v=z(R.lookup([...E,"error_code"])),re=v?new TextDecoder().decode(v):void 0;throw new Br(x,r,C,O,H,me,re)}}}else if(O.body&&"reject_message"in O.body){let{reject_code:U,reject_message:E,error_code:J}=O.body;throw new Br(x,r,C,O,U,E,J)}if(O.status===202){let U=f(),E=await ht(p,B,C,U,n);R=E.certificate,V=E.reply}let w=t.annotations.includes(Nt),S=t.annotations.includes(wn),I=Object.assign(Object.assign({},O),{requestDetails:_});if(V!==void 0)return w&&S?{httpDetails:I,certificate:R,result:Ie(t.retTypes,V)}:S?{certificate:R,result:Ie(t.retTypes,V)}:w?{httpDetails:I,result:Ie(t.retTypes,V)}:Ie(t.retTypes,V);if(t.retTypes.length===0)return w?{httpDetails:O,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${t.retTypes.join(",")}].`)};let i=(...o)=>a({},...o);return i.withOptions=o=>(...s)=>a(o,...s),i}function xn(e){function r(t,n){if(e.effectiveCanisterId)return{effectiveCanisterId:h.from(e.effectiveCanisterId)};let a=n[0],i=h.fromHex("");return a&&typeof a=="object"&&a.target_canister&&t==="install_chunked_code"&&(i=h.from(a.target_canister)),a&&typeof a=="object"&&a.canister_id&&(i=h.from(a.canister_id)),{effectiveCanisterId:i}}return oe.createActor(gn,Object.assign(Object.assign(Object.assign({},e),{canisterId:h.fromHex("")}),{callTransform:r,queryTransform:r}))}var Ii=(e=>(e[e.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",e[e.InvalidFormat=1]="InvalidFormat",e[e.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",e))(Ii||{}),Ns=BigInt(1e8);var y=e=>e==null,T=e=>!y(e);var qi=class extends Error{},Ir=(e,r)=>{if(e==null)throw new qi(r)};var Fn="abcdefghijklmnopqrstuvwxyz234567",mr=Object.create(null);for(let e=0;e<Fn.length;e++)mr[Fn[e]]=e;mr[0]=mr.o;mr[1]=mr.i;var Os=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);var gt="__bigint__",xt="__principal__",Ot="__uint8array__",En=(e,r)=>typeof r=="bigint"?{[gt]:`${r}`}:T(r)&&r instanceof h?{[xt]:r.toText()}:T(r)&&r instanceof Uint8Array?{[Ot]:Array.from(r)}:r,bn=(e,r)=>{let t=n=>r[n];return T(r)&&typeof r=="object"&&gt in r?BigInt(t(gt)):T(r)&&typeof r=="object"&&xt in r?h.fromText(t(xt)):T(r)&&typeof r=="object"&&Ot in r?Uint8Array.from(t(Ot)):r};var N=e=>T(e)?[e]:[],A=e=>e?.[0];var qe=class{callbacks=[];populate(r){this.callbacks.forEach(({callback:t})=>t(r))}subscribe(r){let t=Symbol();return this.callbacks.push({id:t,callback:r}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==t)}};var Q=class e extends qe{static instance;authUser=null;constructor(){super()}static getInstance(){return e.instance||(e.instance=new e),e.instance}set(r){this.authUser=r,this.populate(r)}get(){return this.authUser}subscribe(r){let t=super.subscribe(r);return r(this.authUser),t}reset(){this.authUser=null,this.populate(this.authUser)}};var Rt=({message:e,detail:r})=>{let t=new CustomEvent(e,{detail:r,bubbles:!0});document.dispatchEvent(t)};var jr=function(e,r,t,n,a){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?e!==r||!a:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?a.call(e,t):a?a.value=t:r.set(e,t),t},de=function(e,r,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?e!==r||!n:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(e):n?n.value:r.get(e)},qr,Dr,De,je;function An(e){return e!==null&&typeof e=="object"}var Ee=class e{constructor(r){if(qr.set(this,void 0),Dr.set(this,void 0),r.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");jr(this,qr,r,"f"),jr(this,Dr,e.derEncode(r),"f")}static from(r){if(typeof r=="string"){let t=ce(r);return this.fromRaw(t)}else if(An(r)){let t=r;if(An(t)&&Object.hasOwnProperty.call(t,"__derEncodedPublicKey__"))return this.fromDer(t);if(ArrayBuffer.isView(t)){let n=t;return this.fromRaw(Wt(n.buffer))}else{if(t instanceof ArrayBuffer)return this.fromRaw(t);if("rawKey"in t)return this.fromRaw(t.rawKey);if("derKey"in t)return this.fromDer(t.derKey);if("toDer"in t)return this.fromDer(t.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(r){return new e(r)}static fromDer(r){return new e(this.derDecode(r))}static derEncode(r){let t=Vr(r,Ar).buffer;return t.__derEncodedPublicKey__=void 0,t}static derDecode(r){let t=ot(r,Ar);if(t.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return t}get rawKey(){return de(this,qr,"f")}get derKey(){return de(this,Dr,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};qr=new WeakMap,Dr=new WeakMap;Ee.RAW_KEY_LENGTH=32;var be=class e extends Re{constructor(r,t){super(),De.set(this,void 0),je.set(this,void 0),jr(this,De,Ee.from(r),"f"),jr(this,je,new Uint8Array(t),"f")}static generate(r){if(r&&r.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");r||(r=Se.utils.randomPrivateKey()),$t(r,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 t=new Uint8Array(32);for(let a=0;a<32;a++)t[a]=new Uint8Array(r)[a];let n=Se.getPublicKey(t);return e.fromKeyPair(n,t)}static fromParsedJson(r){let[t,n]=r;return new e(Ee.fromDer(ce(t)),ce(n))}static fromJSON(r){let t=JSON.parse(r);if(Array.isArray(t)){if(typeof t[0]=="string"&&typeof t[1]=="string")return this.fromParsedJson([t[0],t[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(r)}`)}static fromKeyPair(r,t){return new e(Ee.fromRaw(r),t)}static fromSecretKey(r){let t=Se.getPublicKey(new Uint8Array(r));return e.fromKeyPair(t,r)}toJSON(){return[P(de(this,De,"f").toDer()),P(de(this,je,"f"))]}getKeyPair(){return{secretKey:de(this,je,"f"),publicKey:de(this,De,"f")}}getPublicKey(){return de(this,De,"f")}async sign(r){let t=new Uint8Array(r),n=zt(Se.sign(t,de(this,je,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(r,t,n){let[a,i,o]=[r,t,n].map(s=>(typeof s=="string"&&(s=ce(s)),s instanceof Uint8Array&&(s=s.buffer),new Uint8Array(s)));return Se.verify(i,a,o)}};De=new WeakMap,je=new WeakMap;var wt=class e extends Error{constructor(r){super(r),this.message=r,Object.setPrototypeOf(this,e.prototype)}};function Vn(e){if(typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.subtle)return globalThis.crypto.subtle;if(e)return e;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new wt("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 fr=class e extends Re{constructor(r,t,n){super(),this._keyPair=r,this._derKey=t,this._subtleCrypto=n}static async generate(r){let{extractable:t=!1,keyUsages:n=["sign","verify"],subtleCrypto:a}=r??{},i=Vn(a),o=await i.generateKey({name:"ECDSA",namedCurve:"P-256"},t,n),s=await i.exportKey("spki",o.publicKey);return new this(o,s,i)}static async fromKeyPair(r,t){let n=Vn(t),a=await n.exportKey("spki",r.publicKey);return new e(r,a,n)}getKeyPair(){return this._keyPair}getPublicKey(){let r=this._derKey,t=Object.create(this._keyPair.publicKey);return t.toDer=function(){return r},t}async sign(r){let t={name:"ECDSA",hash:{name:"SHA-256"}};return await this._subtleCrypto.sign(t,this._keyPair.privateKey,r)}};var Me=nt(Za());var Di=function(e,r,t,n,a){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?e!==r||!a:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?a.call(e,t):a?a.value=t:r.set(e,t),t},yr=function(e,r,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?e!==r||!n:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(e):n?n.value:r.get(e)},pe,Mr=class{constructor(r){pe.set(this,void 0),Di(this,pe,r,"f")}get rawKey(){return yr(this,pe,"f").rawKey}get derKey(){return yr(this,pe,"f").derKey}toDer(){return yr(this,pe,"f").toDer()}getPublicKey(){return yr(this,pe,"f")}getPrincipal(){return h.from(yr(this,pe,"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.")}};pe=new WeakMap;var ji=function(e,r,t,n,a){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?e!==r||!a:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?a.call(e,t):a?a.value=t:r.set(e,t),t},Mi=function(e,r,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?e!==r||!n:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(e):n?n.value:r.get(e)},Ki=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)r.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(t[n[a]]=e[n[a]]);return t},Kr,Ji=new TextEncoder().encode("ic-request-auth-delegation"),Hi=new TextEncoder().encode(`
15
- ic-request`);function Ft(e){if(typeof e!="string"||e.length<64)throw new Error("Invalid public key.");return ce(e)}var Ke=class{constructor(r,t,n){this.pubkey=r,this.expiration=t,this.targets=n}toCBOR(){return Me.value.map(Object.assign({pubkey:Me.value.bytes(this.pubkey),expiration:Me.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Me.value.array(this.targets.map(r=>Me.value.bytes(r.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:P(this.pubkey)},this.targets&&{targets:this.targets.map(r=>r.toHex())})}};async function $i(e,r,t,n){let a=new Ke(r.toDer(),BigInt(+t)*BigInt(1e6),n),i=new Uint8Array([...Ji,...new Uint8Array(it(Object.assign({},a)))]),o=await e.sign(i);return{delegation:a,signature:o}}var hr=class e{constructor(r,t){this.delegations=r,this.publicKey=t}static async create(r,t,n=new Date(Date.now()+900*1e3),a={}){var i,o;let s=await $i(r,t,n,a.targets);return new e([...((i=a.previous)===null||i===void 0?void 0:i.delegations)||[],s],((o=a.previous)===null||o===void 0?void 0:o.publicKey)||r.getPublicKey().toDer())}static fromJSON(r){let{publicKey:t,delegations:n}=typeof r=="string"?JSON.parse(r):r;if(!Array.isArray(n))throw new Error("Invalid delegations.");let a=n.map(i=>{let{delegation:o,signature:s}=i,{pubkey:l,expiration:u,targets:p}=o;if(p!==void 0&&!Array.isArray(p))throw new Error("Invalid targets.");return{delegation:new Ke(Ft(l),BigInt("0x"+u),p&&p.map(d=>{if(typeof d!="string")throw new Error("Invalid target.");return h.fromHex(d)})),signature:Ft(s)}});return new this(a,Ft(t))}static fromDelegations(r,t){return new this(r,t)}toJSON(){return{delegations:this.delegations.map(r=>{let{delegation:t,signature:n}=r,{targets:a}=t;return{delegation:Object.assign({expiration:t.expiration.toString(16),pubkey:P(t.pubkey)},a&&{targets:a.map(i=>i.toHex())}),signature:P(n)}}),publicKey:P(this.publicKey)}}},Tr=class extends Re{constructor(r,t){super(),this._inner=r,this._delegation=t}static fromDelegation(r,t){return new this(r,t)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(r){return this._inner.sign(r)}async transformRequest(r){let{body:t}=r,n=Ki(r,["body"]),a=await it(t);return Object.assign(Object.assign({},n),{body:{content:t,sender_sig:await this.sign(new Uint8Array([...Hi,...new Uint8Array(a)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},Nr=class e extends Mr{constructor(r,t){super(r),Kr.set(this,void 0),ji(this,Kr,t,"f")}get delegation(){return Mi(this,Kr,"f")}static fromDelegation(r,t){return new e(r,t)}};Kr=new WeakMap;function Pn(e,r){for(let{delegation:a}of e.delegations)if(+new Date(Number(a.expiration/BigInt(1e6)))<=+Date.now())return!1;let t=[],n=r?.scope;n&&(Array.isArray(n)?t.push(...n.map(a=>typeof a=="string"?h.fromText(a):a)):t.push(typeof n=="string"?h.fromText(n):n));for(let a of t){let i=a.toText();for(let{delegation:o}of e.delegations){if(o.targets===void 0)continue;let s=!0;for(let l of o.targets)if(l.toText()===i){s=!1;break}if(s)return!1}}return!0}var Wi=nt(Qa());var vn;(function(e){e[e.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(vn||(vn={}));var Sn=["mousedown","mousemove","keydown","touchstart","wheel"],gr=class{constructor(r={}){var t;this.callbacks=[],this.idleTimeout=600*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:a=600*1e3}=r||{};this.callbacks=n?[n]:[],this.idleTimeout=a;let i=this._resetTimer.bind(this);window.addEventListener("load",i,!0),Sn.forEach(function(s){document.addEventListener(s,i,!0)});let o=(s,l)=>{let u;return(...p)=>{let d=this,m=function(){u=void 0,s.apply(d,p)};clearTimeout(u),u=window.setTimeout(m,l)}};if(r?.captureScroll){let s=o(i,(t=r?.scrollDebounce)!==null&&t!==void 0?t:100);window.addEventListener("scroll",s,!0)}i()}static create(r={}){return new this(r)}registerCallback(r){this.callbacks.push(r)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let r=this._resetTimer.bind(this);Sn.forEach(function(t){document.removeEventListener(t,r,!0)}),this.callbacks.forEach(t=>t())}_resetTimer(){let r=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(r,this.idleTimeout)}};var Gi=(e,r)=>r.some(t=>e instanceof t),kn,Cn;function Yi(){return kn||(kn=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Xi(){return Cn||(Cn=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Un=new WeakMap,bt=new WeakMap,Bn=new WeakMap,Et=new WeakMap,Vt=new WeakMap;function Qi(e){let r=new Promise((t,n)=>{let a=()=>{e.removeEventListener("success",i),e.removeEventListener("error",o)},i=()=>{t(Z(e.result)),a()},o=()=>{n(e.error),a()};e.addEventListener("success",i),e.addEventListener("error",o)});return r.then(t=>{t instanceof IDBCursor&&Un.set(t,e)}).catch(()=>{}),Vt.set(r,e),r}function Zi(e){if(bt.has(e))return;let r=new Promise((t,n)=>{let a=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",o),e.removeEventListener("abort",o)},i=()=>{t(),a()},o=()=>{n(e.error||new DOMException("AbortError","AbortError")),a()};e.addEventListener("complete",i),e.addEventListener("error",o),e.addEventListener("abort",o)});bt.set(e,r)}var At={get(e,r,t){if(e instanceof IDBTransaction){if(r==="done")return bt.get(e);if(r==="objectStoreNames")return e.objectStoreNames||Bn.get(e);if(r==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return Z(e[r])},set(e,r,t){return e[r]=t,!0},has(e,r){return e instanceof IDBTransaction&&(r==="done"||r==="store")?!0:r in e}};function In(e){At=e(At)}function Li(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(r,...t){let n=e.call(Jr(this),r,...t);return Bn.set(n,r.sort?r.sort():[r]),Z(n)}:Xi().includes(e)?function(...r){return e.apply(Jr(this),r),Z(Un.get(this))}:function(...r){return Z(e.apply(Jr(this),r))}}function eo(e){return typeof e=="function"?Li(e):(e instanceof IDBTransaction&&Zi(e),Gi(e,Yi())?new Proxy(e,At):e)}function Z(e){if(e instanceof IDBRequest)return Qi(e);if(Et.has(e))return Et.get(e);let r=eo(e);return r!==e&&(Et.set(e,r),Vt.set(r,e)),r}var Jr=e=>Vt.get(e);function Dn(e,r,{blocked:t,upgrade:n,blocking:a,terminated:i}={}){let o=indexedDB.open(e,r),s=Z(o);return n&&o.addEventListener("upgradeneeded",l=>{n(Z(o.result),l.oldVersion,l.newVersion,Z(o.transaction),l)}),t&&o.addEventListener("blocked",l=>t(l.oldVersion,l.newVersion,l)),s.then(l=>{i&&l.addEventListener("close",()=>i()),a&&l.addEventListener("versionchange",u=>a(u.oldVersion,u.newVersion,u))}).catch(()=>{}),s}var ro=["get","getKey","getAll","getAllKeys","count"],to=["put","add","delete","clear"],Pt=new Map;function qn(e,r){if(!(e instanceof IDBDatabase&&!(r in e)&&typeof r=="string"))return;if(Pt.get(r))return Pt.get(r);let t=r.replace(/FromIndex$/,""),n=r!==t,a=to.includes(t);if(!(t in(n?IDBIndex:IDBObjectStore).prototype)||!(a||ro.includes(t)))return;let i=async function(o,...s){let l=this.transaction(o,a?"readwrite":"readonly"),u=l.store;return n&&(u=u.index(s.shift())),(await Promise.all([u[t](...s),a&&l.done]))[0]};return Pt.set(r,i),i}In(e=>({...e,get:(r,t,n)=>qn(r,t)||e.get(r,t,n),has:(r,t)=>!!qn(r,t)||e.has(r,t)}));var jn="auth-client-db",Mn="ic-keyval",no=async(e=jn,r=Mn,t)=>(Hr&&(localStorage!=null&&localStorage.getItem(W))&&(localStorage.removeItem(W),localStorage.removeItem(G)),await Dn(e,t,{upgrade:n=>{n.objectStoreNames.contains(r)&&n.clear(r),n.createObjectStore(r)}}));async function ao(e,r,t){return await e.get(r,t)}async function io(e,r,t,n){return await e.put(r,n,t)}async function oo(e,r,t){return await e.delete(r,t)}var xr=class e{constructor(r,t){this._db=r,this._storeName=t}static async create(r){let{dbName:t=jn,storeName:n=Mn,version:a=Kn}=r??{},i=await no(t,n,a);return new e(i,n)}async set(r,t){return await io(this._db,this._storeName,r,t)}async get(r){var t;return(t=await ao(this._db,this._storeName,r))!==null&&t!==void 0?t:null}async remove(r){return await oo(this._db,this._storeName,r)}};var so=function(e,r,t,n,a){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?e!==r||!a:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?a.call(e,t):a?a.value=t:r.set(e,t),t},co=function(e,r,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?e!==r||!n:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(e):n?n.value:r.get(e)},$r,G="identity",W="delegation",Jn="iv",Kn=1,Hr=typeof window<"u",Or=class{constructor(r="ic-",t){this.prefix=r,this._localStorage=t}get(r){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+r))}set(r,t){return this._getLocalStorage().setItem(this.prefix+r,t),Promise.resolve()}remove(r){return this._getLocalStorage().removeItem(this.prefix+r),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let r=typeof window>"u"?typeof globalThis>"u"?typeof self>"u"?void 0:self.localStorage:globalThis.localStorage:window.localStorage;if(!r)throw new Error("Could not find local storage.");return r}},Rr=class{constructor(r){$r.set(this,void 0),so(this,$r,r??{},"f")}get _db(){return new Promise(r=>{if(this.initializedDb){r(this.initializedDb);return}xr.create(co(this,$r,"f")).then(t=>{this.initializedDb=t,r(t)})})}async get(r){return await(await this._db).get(r)}async set(r,t){await(await this._db).set(r,t)}async remove(r){await(await this._db).remove(r)}};$r=new WeakMap;var lo="https://identity.ic0.app",uo="#authorize",vt="ECDSA",St="Ed25519",po=500,Ct="UserInterrupt",zr=class{constructor(r,t,n,a,i,o,s,l){this._identity=r,this._key=t,this._chain=n,this._storage=a,this.idleManager=i,this._createOptions=o,this._idpWindow=s,this._eventHandler=l,this._registerDefaultIdleCallback()}static async create(r={}){var t,n,a;let i=(t=r.storage)!==null&&t!==void 0?t:new Rr,o=(n=r.keyType)!==null&&n!==void 0?n:vt,s=null;if(r.identity)s=r.identity;else{let d=await i.get(G);if(!d&&Hr)try{let m=new Or,f=await m.get(W),x=await m.get(G);f&&x&&o===vt&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await i.set(W,f),await i.set(G,x),d=f,await m.remove(W),await m.remove(G))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(d)try{typeof d=="object"?o===St&&typeof d=="string"?s=await be.fromJSON(d):s=await fr.fromKeyPair(d):typeof d=="string"&&(s=be.fromJSON(d))}catch{}}let l=new ve,u=null;if(s)try{let d=await i.get(W);if(typeof d=="object"&&d!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");r.identity?l=r.identity:d&&(u=hr.fromJSON(d),Pn(u)?"toDer"in s?l=Nr.fromDelegation(s,u):l=Tr.fromDelegation(s,u):(await kt(i),s=null))}catch(d){console.error(d),await kt(i),s=null}let p;return!((a=r.idleOptions)===null||a===void 0)&&a.disableIdle?p=void 0:(u||r.identity)&&(p=gr.create(r.idleOptions)),s||(o===St?(s=await be.generate(),await i.set(G,JSON.stringify(s.toJSON()))):(r.storage&&o===vt&&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 '${St}' as the key type, as it can serialize to a string`),s=await fr.generate(),await i.set(G,s.getKeyPair()))),new this(l,s,u,i,p,r)}_registerDefaultIdleCallback(){var r,t;let n=(r=this._createOptions)===null||r===void 0?void 0:r.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((t=this.idleManager)===null||t===void 0||t.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(r,t){var n,a;let i=r.delegations.map(u=>({delegation:new Ke(u.delegation.pubkey,u.delegation.expiration,u.delegation.targets),signature:u.signature.buffer})),o=hr.fromDelegations(i,r.userPublicKey.buffer),s=this._key;if(!s)return;this._chain=o,"toDer"in s?this._identity=Nr.fromDelegation(s,this._chain):this._identity=Tr.fromDelegation(s,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let l=(a=this._createOptions)===null||a===void 0?void 0:a.idleOptions;!this.idleManager&&!l?.disableIdle&&(this.idleManager=gr.create(l),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(W,JSON.stringify(this._chain.toJSON())),t?.(r)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(r){var t,n,a,i;let o=BigInt(8)*BigInt(36e11),s=new URL(((t=r?.identityProvider)===null||t===void 0?void 0:t.toString())||lo);s.hash=uo,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(s,Object.assign({maxTimeToLive:(a=r?.maxTimeToLive)!==null&&a!==void 0?a:o},r)),window.addEventListener("message",this._eventHandler),this._idpWindow=(i=window.open(s.toString(),"idpWindow",r?.windowOpenerFeatures))!==null&&i!==void 0?i:void 0;let l=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Ct,r?.onError):setTimeout(l,po))};l()}_getEventHandler(r,t){return async n=>{var a,i,o;if(n.origin!==r.origin)return;let s=n.data;switch(s.kind){case"authorize-ready":{let l=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((a=this._key)===null||a===void 0?void 0:a.getPublicKey().toDer()),maxTimeToLive:t?.maxTimeToLive,allowPinAuthentication:t?.allowPinAuthentication,derivationOrigin:(i=t?.derivationOrigin)===null||i===void 0?void 0:i.toString()},t?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(l,r.origin);break}case"authorize-client-success":try{await this._handleSuccess(s,t?.onSuccess)}catch(l){this._handleFailure(l.message,t?.onError)}break;case"authorize-client-failure":this._handleFailure(s.text,t?.onError);break;default:break}}}_handleFailure(r,t){var n;(n=this._idpWindow)===null||n===void 0||n.close(),t?.(r),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(r={}){if(await kt(this._storage),this._identity=new ve,this._chain=null,r.returnTo)try{window.history.pushState({},"",r.returnTo)}catch{window.location.href=r.returnTo}}};async function kt(e){await e.remove(G),await e.remove(W),await e.remove(Jn)}var Hn=BigInt(144e11),$n=!1,zn={width:576,height:576},Wn={width:505,height:705},Gn="internetcomputer.org";var Je="http://127.0.0.1:5987",Yn="rdmx6-jaaaa-aaaaa-aaadq-cai";var L=class e extends qe{static instance;env;constructor(){super()}static getInstance(){return e.instance||(e.instance=new e),e.instance}set(r){this.env=r,this.populate(r)}get(){return this.env}reset(){this.env=null}subscribe(r){let t=super.subscribe(r);return r(this.env),t}};var Xn=async e=>{let r=new Blob([JSON.stringify(e,En)],{type:"application/json; charset=utf-8"});return new Uint8Array(await r.arrayBuffer())},Wr=async e=>{let r=new Blob([e instanceof Uint8Array?e:new Uint8Array(e)],{type:"application/json; charset=utf-8"});return JSON.parse(await r.text(),bn)},Gr=()=>typeof window<"u";var Ut=({width:e,height:r})=>{if(!Gr()||y(window)||y(window.top))return;let{top:{innerWidth:t,innerHeight:n}}=window,a=n/2+screenY-r/2,i=t/2+screenX-e/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${e}, height=${r}, top=${a}, left=${i}`};var Yr=class{#e;constructor({domain:r}){this.#e=r}get id(){return"internet_identity"}signInOptions({windowed:r}){let t=()=>{let n=L.getInstance().get()?.container;if(y(n)||n===!1)return`https://identity.${this.#e??Gn}`;let a=L.getInstance().get(),i=T(a)&&T(a?.internetIdentityId)?a.internetIdentityId:Yn,{host:o,protocol:s}=new URL(n===!0?Je:n);return/apple/i.test(navigator?.vendor)?`${s}//${o}?canisterId=${i}`:`${s}//${i}.${o.replace("127.0.0.1","localhost")}`};return{...r!==!1&&{windowOpenerFeatures:Ut(zn)},identityProvider:t()}}},Qn=class{#e;#r;constructor({appName:r,logoUrl:t}){this.#e=r,this.#r=t}get id(){return"nfid"}signInOptions({windowed:r}){return{...r!==!1&&{windowOpenerFeatures:Ut(Wn)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#r)}`}}};var Zn=async({identity:e,container:r})=>{let n=T(r)&&r!==!1?r===!0?Je:r:"https://icp-api.io",a=T(r);return await pr.create({identity:e,shouldFetchRootKey:a,host:n})};var He=class e{static instance;#e=void 0;constructor(){}static getInstance(){return y(e.instance)&&(e.instance=new e),e.instance}async getAgent({identity:r,...t}){let n=r.getPrincipal().toText();if(y(this.#e)||y(this.#e[n])){let a=await Zn({identity:r,...t});return this.#e={...this.#e??{},[n]:a},a}return this.#e[n]}reset(){this.#e=null}};var $e=class e{static instance;#e=void 0;constructor(){}static getInstance(){return y(e.instance)&&(e.instance=new e),e.instance}async getActor({satelliteId:r,identity:t,actorKey:n,...a}){let i=`${n}#${t.getPrincipal().toText()}#${r};`;if(y(this.#e)||y(this.#e[i])){let o=await this.createActor({satelliteId:r,identity:t,...a});return this.#e={...this.#e??{},[i]:o},o}return this.#e[i]}reset(){this.#e=null}async createActor({idlFactory:r,satelliteId:t,...n}){let a=await He.getInstance().getAgent(n);return oe.createActor(r,{agent:a,canisterId:t})}};var Xr=class extends Error{},Qr=class extends Error{},Zr=class extends Error{},Lr=class extends Error{},et=class extends Error{};var rt=()=>zr.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Bt=({error:e,type:r})=>typeof e=="string"?e.includes(r):e instanceof Error?e.message.includes(r):!1;var Ln="juno.datastore.error.user.cannot_update";var ea=async({data:e})=>{try{return await Wr(e)}catch(r){console.error("The data parsing has failed, mapping to undefined as a fallback.",r);return}};var It=async e=>{let{data:r,version:t,description:n}=e;return{description:N(n),data:await Xn(r),version:N(t)}},qt=e=>{let{version:r}=e;return{version:N(r)}},wr=async({doc:e,key:r})=>{let{owner:t,version:n,description:a,data:i,...o}=e;return{key:r,description:A(a),owner:t.toText(),data:await Wr(i),version:A(n),...o}};var ra=e=>{if(y(e))return N();switch(e.matcher){case"equal":return N({Equal:e.timestamp});case"greaterThan":return N({GreaterThan:e.timestamp});case"lessThan":return N({LessThan:e.timestamp});case"between":return N({Between:[e.timestamps.start,e.timestamps.end]});default:throw new et("Invalid list matcher for timestamp",e)}},_e=({matcher:e,paginate:r,order:t,owner:n})=>({matcher:y(e)?[]:[{key:N(e.key),description:N(e.description),created_at:ra(e.createdAt),updated_at:ra(e.updatedAt)}],paginate:N(y(r)?void 0:{start_after:N(r.startAfter),limit:N(y(r.limit)?void 0:BigInt(r.limit))}),order:N(y(t)?void 0:{desc:t.desc,field:t.field==="created_at"?{CreatedAt:null}:t.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:N(y(n)?void 0:typeof n=="string"?h.fromText(n):n)});var _o=(e=>(e[e.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",e[e.InvalidFormat=1]="InvalidFormat",e[e.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",e))(_o||{}),pl=BigInt(1e8);var ta="abcdefghijklmnopqrstuvwxyz234567",Fr=Object.create(null);for(let e=0;e<ta.length;e++)Fr[ta[e]]=e;Fr[0]=Fr.o;Fr[1]=Fr.i;var _l=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);var na=({IDL:e})=>{let r=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),t=e.Record({sha256:e.Vec(e.Nat8),proposal_id:e.Nat}),n=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),a=e.Record({field:n,desc:e.Bool}),i=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),o=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(i),description:e.Opt(e.Text),created_at:e.Opt(i)}),s=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),l=e.Record({order:e.Opt(a),owner:e.Opt(e.Principal),matcher:e.Opt(o),paginate:e.Opt(s)}),u=e.Record({controllers:e.Vec(e.Principal)}),p=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),d=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:p,expires_at:e.Opt(e.Nat64)}),m=e.Record({version:e.Opt(e.Nat64)}),f=e.Variant({Db:e.Null,Storage:e.Null}),x=e.Record({version:e.Opt(e.Nat64)}),B=e.Record({proposal_ids:e.Vec(e.Nat)}),K=e.Record({cycles:e.Nat,destination_id:e.Principal}),C=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),O=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),_=e.Record({key:C,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,O)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),V=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),R=e.Record({allowed_callers:e.Vec(e.Principal)}),w=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(V),rules:e.Opt(R)}),S=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),I=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(S)}),U=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),E=e.Variant({Deny:e.Null,Allow:e.Null}),J=e.Record({status_code:e.Nat16,location:e.Text}),H=e.Record({iframe:e.Opt(U),updated_at:e.Opt(e.Nat64),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(S),raw_access:e.Opt(E),redirects:e.Opt(e.Vec(e.Tuple(e.Text,J)))}),me=e.Record({db:e.Opt(I),authentication:e.Opt(w),storage:H}),v=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),re=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),ze=e.Record({clear_existing_assets:e.Opt(e.Bool)}),We=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),fe=e.Variant({AssetsUpgrade:ze,SegmentsDeployment:We}),$=e.Record({status:re,updated_at:e.Nat64,sha256:e.Opt(e.Vec(e.Nat8)),executed_at:e.Opt(e.Nat64),owner:e.Principal,created_at:e.Nat64,version:e.Opt(e.Nat64),proposal_type:fe}),te=e.Variant({Heap:e.Null,Stable:e.Null}),q=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),ye=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),ne=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(te),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:q,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(ye),write:q,max_changes_per_user:e.Opt(e.Nat32)}),Ge=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),certificate_version:e.Opt(e.Nat16)}),ae=e.Record({memory:te,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),Ye=e.Variant({Callback:e.Record({token:ae,callback:e.Func([],[],["query"])})}),Ae=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(Ye),status_code:e.Nat16}),he=e.Record({token:e.Opt(ae),body:e.Vec(e.Nat8)}),Te=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),se=e.Record({batch_id:e.Nat}),Ne=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,_)),items_length:e.Nat64}),Xe=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),Qe=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,v)),items_length:e.Nat64}),Ze=e.Record({desc:e.Bool}),Le=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),Ve=e.Record({order:e.Opt(Ze),paginate:e.Opt(Le)}),er=e.Record({proposal_id:e.Nat}),rr=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(er,$)),items_length:e.Nat64}),tr=e.Record({include_system:e.Bool}),nr=e.Record({matcher:e.Opt(tr)}),ar=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,ne)),items_length:e.Nat64}),ir=e.Record({stable:e.Nat64,heap:e.Nat64}),or=e.Record({version:e.Opt(e.Nat64),internet_identity:e.Opt(V),rules:e.Opt(R)}),sr=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:p,expires_at:e.Opt(e.Nat64)}),cr=e.Record({controller:sr,controllers:e.Vec(e.Principal)}),Pe=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(S)}),ge=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),lr=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(te),max_size:e.Opt(e.Nat),read:q,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(ye),write:q,max_changes_per_user:e.Opt(e.Nat32)}),ur=e.Record({iframe:e.Opt(U),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),version:e.Opt(e.Nat64),max_memory_size:e.Opt(S),raw_access:e.Opt(E),redirects:e.Opt(e.Vec(e.Tuple(e.Text,J)))}),xe=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Oe=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([r],[],[]),commit_proposal:e.Func([t],[e.Null],[]),commit_proposal_asset_upload:e.Func([r],[],[]),count_assets:e.Func([e.Text,l],[e.Nat64],["query"]),count_collection_assets:e.Func([e.Text],[e.Nat64],["query"]),count_collection_docs:e.Func([e.Text],[e.Nat64],["query"]),count_docs:e.Func([e.Text,l],[e.Nat64],["query"]),count_proposals:e.Func([],[e.Nat64],["query"]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([u],[e.Vec(e.Tuple(e.Principal,d))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,m],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,l],[],[]),del_filtered_docs:e.Func([e.Text,l],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,m))],[],[]),del_rule:e.Func([f,e.Text,x],[],[]),delete_proposal_assets:e.Func([B],[],[]),deposit_cycles:e.Func([K],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(_)],["query"]),get_auth_config:e.Func([],[e.Opt(w)],["query"]),get_config:e.Func([],[me],[]),get_db_config:e.Func([],[e.Opt(I)],["query"]),get_doc:e.Func([e.Text,e.Text],[e.Opt(v)],["query"]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(_)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(v)))],["query"]),get_proposal:e.Func([e.Nat],[e.Opt($)],["query"]),get_rule:e.Func([f,e.Text],[e.Opt(ne)],["query"]),get_storage_config:e.Func([],[H],["query"]),http_request:e.Func([Ge],[Ae],["query"]),http_request_streaming_callback:e.Func([ae],[he],["query"]),init_asset_upload:e.Func([Te],[se],[]),init_proposal:e.Func([fe],[e.Nat,$],[]),init_proposal_asset_upload:e.Func([Te,e.Nat],[se],[]),list_assets:e.Func([e.Text,l],[Ne],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,d))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Xe))],["query"]),list_docs:e.Func([e.Text,l],[Qe],["query"]),list_proposals:e.Func([Ve],[rr],["query"]),list_rules:e.Func([f,nr],[ar],["query"]),memory_size:e.Func([],[ir],["query"]),reject_proposal:e.Func([t],[e.Null],[]),set_auth_config:e.Func([or],[w],[]),set_controllers:e.Func([cr],[e.Vec(e.Tuple(e.Principal,d))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([Pe],[I],[]),set_doc:e.Func([e.Text,e.Text,ge],[v],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,ge))],[e.Vec(e.Tuple(e.Text,v))],[]),set_rule:e.Func([f,e.Text,lr],[ne],[]),set_storage_config:e.Func([ur],[H],[]),submit_proposal:e.Func([e.Nat],[e.Nat,$],[]),upload_asset_chunk:e.Func([xe],[Oe],[]),upload_proposal_asset_chunk:e.Func([xe],[Oe],[])})},aa=({IDL:e})=>{let r=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),t=e.Record({sha256:e.Vec(e.Nat8),proposal_id:e.Nat}),n=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),a=e.Record({field:n,desc:e.Bool}),i=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),o=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(i),description:e.Opt(e.Text),created_at:e.Opt(i)}),s=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),l=e.Record({order:e.Opt(a),owner:e.Opt(e.Principal),matcher:e.Opt(o),paginate:e.Opt(s)}),u=e.Record({controllers:e.Vec(e.Principal)}),p=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),d=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:p,expires_at:e.Opt(e.Nat64)}),m=e.Record({version:e.Opt(e.Nat64)}),f=e.Variant({Db:e.Null,Storage:e.Null}),x=e.Record({version:e.Opt(e.Nat64)}),B=e.Record({proposal_ids:e.Vec(e.Nat)}),K=e.Record({cycles:e.Nat,destination_id:e.Principal}),C=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),O=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),_=e.Record({key:C,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,O)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),V=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),R=e.Record({allowed_callers:e.Vec(e.Principal)}),w=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(V),rules:e.Opt(R)}),S=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),I=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(S)}),U=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),E=e.Variant({Deny:e.Null,Allow:e.Null}),J=e.Record({status_code:e.Nat16,location:e.Text}),H=e.Record({iframe:e.Opt(U),updated_at:e.Opt(e.Nat64),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(S),raw_access:e.Opt(E),redirects:e.Opt(e.Vec(e.Tuple(e.Text,J)))}),me=e.Record({db:e.Opt(I),authentication:e.Opt(w),storage:H}),v=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),re=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),ze=e.Record({clear_existing_assets:e.Opt(e.Bool)}),We=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),fe=e.Variant({AssetsUpgrade:ze,SegmentsDeployment:We}),$=e.Record({status:re,updated_at:e.Nat64,sha256:e.Opt(e.Vec(e.Nat8)),executed_at:e.Opt(e.Nat64),owner:e.Principal,created_at:e.Nat64,version:e.Opt(e.Nat64),proposal_type:fe}),te=e.Variant({Heap:e.Null,Stable:e.Null}),q=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),ye=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),ne=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(te),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:q,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(ye),write:q,max_changes_per_user:e.Opt(e.Nat32)}),Ge=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),certificate_version:e.Opt(e.Nat16)}),ae=e.Record({memory:te,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),Ye=e.Variant({Callback:e.Record({token:ae,callback:e.Func([],[],[])})}),Ae=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(Ye),status_code:e.Nat16}),he=e.Record({token:e.Opt(ae),body:e.Vec(e.Nat8)}),Te=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),se=e.Record({batch_id:e.Nat}),Ne=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,_)),items_length:e.Nat64}),Xe=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),Qe=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,v)),items_length:e.Nat64}),Ze=e.Record({desc:e.Bool}),Le=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),Ve=e.Record({order:e.Opt(Ze),paginate:e.Opt(Le)}),er=e.Record({proposal_id:e.Nat}),rr=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(er,$)),items_length:e.Nat64}),tr=e.Record({include_system:e.Bool}),nr=e.Record({matcher:e.Opt(tr)}),ar=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,ne)),items_length:e.Nat64}),ir=e.Record({stable:e.Nat64,heap:e.Nat64}),or=e.Record({version:e.Opt(e.Nat64),internet_identity:e.Opt(V),rules:e.Opt(R)}),sr=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:p,expires_at:e.Opt(e.Nat64)}),cr=e.Record({controller:sr,controllers:e.Vec(e.Principal)}),Pe=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(S)}),ge=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),lr=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(te),max_size:e.Opt(e.Nat),read:q,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(ye),write:q,max_changes_per_user:e.Opt(e.Nat32)}),ur=e.Record({iframe:e.Opt(U),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),version:e.Opt(e.Nat64),max_memory_size:e.Opt(S),raw_access:e.Opt(E),redirects:e.Opt(e.Vec(e.Tuple(e.Text,J)))}),xe=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Oe=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([r],[],[]),commit_proposal:e.Func([t],[e.Null],[]),commit_proposal_asset_upload:e.Func([r],[],[]),count_assets:e.Func([e.Text,l],[e.Nat64],[]),count_collection_assets:e.Func([e.Text],[e.Nat64],[]),count_collection_docs:e.Func([e.Text],[e.Nat64],[]),count_docs:e.Func([e.Text,l],[e.Nat64],[]),count_proposals:e.Func([],[e.Nat64],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([u],[e.Vec(e.Tuple(e.Principal,d))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,m],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,l],[],[]),del_filtered_docs:e.Func([e.Text,l],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,m))],[],[]),del_rule:e.Func([f,e.Text,x],[],[]),delete_proposal_assets:e.Func([B],[],[]),deposit_cycles:e.Func([K],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(_)],[]),get_auth_config:e.Func([],[e.Opt(w)],[]),get_config:e.Func([],[me],[]),get_db_config:e.Func([],[e.Opt(I)],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(v)],[]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(_)))],[]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(v)))],[]),get_proposal:e.Func([e.Nat],[e.Opt($)],[]),get_rule:e.Func([f,e.Text],[e.Opt(ne)],[]),get_storage_config:e.Func([],[H],[]),http_request:e.Func([Ge],[Ae],[]),http_request_streaming_callback:e.Func([ae],[he],[]),init_asset_upload:e.Func([Te],[se],[]),init_proposal:e.Func([fe],[e.Nat,$],[]),init_proposal_asset_upload:e.Func([Te,e.Nat],[se],[]),list_assets:e.Func([e.Text,l],[Ne],[]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,d))],[]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Xe))],[]),list_docs:e.Func([e.Text,l],[Qe],[]),list_proposals:e.Func([Ve],[rr],[]),list_rules:e.Func([f,nr],[ar],[]),memory_size:e.Func([],[ir],[]),reject_proposal:e.Func([t],[e.Null],[]),set_auth_config:e.Func([or],[w],[]),set_controllers:e.Func([cr],[e.Vec(e.Tuple(e.Principal,d))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([Pe],[I],[]),set_doc:e.Func([e.Text,e.Text,ge],[v],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,ge))],[e.Vec(e.Tuple(e.Text,v))],[]),set_rule:e.Func([f,e.Text,lr],[ne],[]),set_storage_config:e.Func([ur],[H],[]),submit_proposal:e.Func([e.Nat],[e.Nat,$],[]),upload_asset_chunk:e.Func([xe],[Oe],[]),upload_proposal_asset_chunk:e.Func([xe],[Oe],[])})};var ia=({satelliteId:e,container:r})=>{let{satelliteId:t}=Dt({satelliteId:e}),{container:n}=jt({container:r});if(T(n)&&n!==!1){let{host:a,protocol:i}=new URL(n===!0?Je:n);return`${i}//${t??"unknown"}.${a.replace("127.0.0.1","localhost")}`}return`https://${t??"unknown"}.icp0.io`},Dt=({satelliteId:e})=>T(e)?{satelliteId:e}:L.getInstance().get()??{satelliteId:void 0},jt=({container:e})=>T(e)?{container:e}:L.getInstance().get()??{container:void 0};var F=({satellite:e,options:{certified:r}})=>sa({idlFactory:r?aa:na,actorKey:`stock#${r?"update":"query"}`,...e}),oa=({idlFactory:e,...r})=>sa({idlFactory:e,actorKey:"extended#query",...r}),sa=async({satelliteId:e,container:r,...t})=>{let{satelliteId:n}=Dt({satelliteId:e});Ir(n,"No satellite ID defined. Did you initialize Juno?");let{container:a}=jt({container:r});return await $e.getInstance().getActor({satelliteId:n,container:a,...t})};var ca=async({collection:e,key:r,...t})=>{let{get_doc:n}=await F(t),a=A(await n(e,r));if(!y(a))return wr({doc:a,key:r})},la=async({docs:e,...r})=>{let{get_many_docs:t}=await F(r),n=e.map(({collection:o,key:s})=>[o,s]),a=await t(n),i=[];for(let[o,s]of a){let l=A(s);i.push(T(l)?await wr({key:o,doc:l}):void 0)}return i},ua=async({collection:e,doc:r,...t})=>{let{set_doc:n}=await F(t),{key:a}=r,i=await It(r),o=await n(e,a,i);return await wr({key:a,doc:o})},da=async({docs:e,...r})=>{let{set_many_docs:t}=await F(r),n=[];for(let{collection:o,doc:s}of e){let{key:l}=s;n.push([o,l,await It(s)])}let a=await t(n),i=[];for(let[o,s]of a)i.push(await wr({key:o,doc:s}));return i},pa=async({collection:e,doc:r,...t})=>{let{del_doc:n}=await F(t),{key:a}=r;return n(e,a,qt(r))},_a=async({docs:e,...r})=>{let{del_many_docs:t}=await F(r),n=e.map(({collection:a,doc:i})=>[a,i.key,qt(i)]);await t(n)},ma=async({collection:e,filter:r,...t})=>{let{del_filtered_docs:n}=await F(t);return n(e,_e(r))},fa=async({collection:e,filter:r,...t})=>{let{list_docs:n}=await F(t),{items:a,items_page:i,items_length:o,matches_length:s,matches_pages:l}=await n(e,_e(r)),u=[];for(let[p,d]of a){let{data:m,owner:f,description:x,version:B,...K}=d;u.push({key:p,description:A(x),owner:f.toText(),data:await ea({data:m}),version:A(B),...K})}return{items:u,items_length:o,items_page:A(i),matches_length:s,matches_pages:A(l)}},ya=async({collection:e,filter:r,...t})=>{let{count_docs:n}=await F(t);return n(e,_e(r))};var ee={certified:!1};var g=e=>T(e)?e:tt()??new ve;var ha=async({satellite:e,options:r,...t})=>{let n=g(e?.identity);return await ca({...t,satellite:{...e,identity:n},options:r??ee})},jl=async({satellite:e,options:r,...t})=>{let n=g(e?.identity);return await la({...t,satellite:{...e,identity:n},options:r??ee})},Ta=async({satellite:e,...r})=>{let t=g(e?.identity);return await ua({...r,satellite:{...e,identity:t},options:{certified:!0}})},Ml=async({satellite:e,...r})=>{let t=g(e?.identity);return await da({...r,satellite:{...e,identity:t},options:{certified:!0}})},Kl=async({satellite:e,...r})=>{let t=g(e?.identity);return await pa({...r,satellite:{...e,identity:t},options:{certified:!0}})},Jl=async({satellite:e,...r})=>{let t=g(e?.identity);return await _a({...r,satellite:{...e,identity:t},options:{certified:!0}})},Hl=async({satellite:e,filter:r,...t})=>{let n=g(e?.identity);return await ma({...t,filter:r??{},satellite:{...e,identity:n},options:{certified:!0}})},$l=async({satellite:e,options:r,filter:t,...n})=>{let a=g(e?.identity);return await fa({...n,filter:t??{},satellite:{...e,identity:a},options:r??ee})},zl=async({satellite:e,options:r,filter:t,...n})=>{let a=g(e?.identity);return await ya({...n,filter:t??{},satellite:{...e,identity:a},options:r??ee})};var Na=async e=>{let r=tt();if(y(r))throw new Lr("No identity to initialize the user. Have you initialized Juno?");let t=r.getPrincipal().toText(),n=()=>ha({collection:"#user",key:t}),a=await n();if(T(a))return a;try{return await mo({userId:t,provider:e})}catch(i){if(Bt({error:i,type:Ln})){let o=await n();if(T(o))return o}throw i}},mo=({userId:e,...r})=>Ta({collection:"#user",doc:{key:e,data:r}});var M,Mt=async e=>{if(M=M??await rt(),!(await M?.isAuthenticated()??!1))return;let t=await Na(e);Q.getInstance().set(t)},fo=e=>new Promise(async(r,t)=>{if(y(M)){t(new Qr("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let n=e?.provider??new Yr({});await M.login({onSuccess:async()=>{await Mt(n.id),r()},onError:a=>{if(a===Ct){t(new Zr(a));return}t(new Xr(a))},maxTimeToLive:e?.maxTimeToLive??Hn,allowPinAuthentication:e?.allowPin??$n,...e?.derivationOrigin!==void 0&&{derivationOrigin:e.derivationOrigin},...n.signInOptions({windowed:e?.windowed})})}),Kt=async()=>{await yo(),M=await rt()},yo=async()=>{await M?.logout(),M=null,Q.getInstance().reset(),$e.getInstance().reset(),He.getInstance().reset()},tt=()=>M?.getIdentity(),ho=async()=>(M??await rt()).getIdentity(),To=async()=>{let e=Q.getInstance().get();return y(e)||!(await M?.isAuthenticated()??!1)?null:M?.getIdentity()??null};var ga=e=>{let r=e===!0?"./workers/auth.worker.js":e,t=new Worker(r),n=async()=>{Rt({message:"junoSignOutAuthTimer"}),await Kt()};return t.onmessage=async({data:a})=>{let{msg:i,data:o}=a;switch(i){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":Rt({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},Q.getInstance().subscribe(a=>{if(y(a)){t.postMessage({msg:"junoStopAuthTimer"});return}t.postMessage({msg:"junoStartAuthTimer"})})};var xa=()=>{let e=()=>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??e():e()},Oa=()=>{let e=()=>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??e():e()};var Nu=async({idlFactory:e,satellite:r})=>{let t=g(r?.identity);return await oa({idlFactory:e,...r,identity:t})};var Ra=async({asset:{data:e,headers:r,...t},actor:n})=>{let{init_asset_upload:a,upload_asset_chunk:i,commit_asset_upload:o}=n,{batch_id:s}=await a(No(t)),{chunkIds:l}=await xo({data:e,uploadFn:i,batchId:s});await go({commitFn:o,batchId:s,data:e,headers:r,chunkIds:l})};var No=({filename:e,collection:r,token:t,fullPath:n,encoding:a,description:i})=>({collection:r,full_path:n,name:e,token:N(t),encoding_type:N(a),description:N(i)}),go=async({commitFn:e,batchId:r,chunkIds:t,headers:n,data:a})=>{let i=n.find(([o,s])=>o.toLowerCase()==="content-type")===void 0&&a.type!==void 0&&a.type!==""?[["Content-Type",a.type]]:void 0;await e({batch_id:r,chunk_ids:t.map(({chunk_id:o})=>o),headers:[...n,...i??[]]})},xo=async({data:e,uploadFn:r,batchId:t})=>{let n=[],a=Gr()?new Blob([await e.arrayBuffer()]):e,i=0n;for(let s=0;s<a.size;s+=19e5){let l=a.slice(s,s+19e5);n.push({batchId:t,chunk:l,uploadFn:r,orderId:i}),i++}let o=[];for await(let s of Oo({uploadChunks:n}))o=[...o,...s];return{chunkIds:o}};async function*Oo({uploadChunks:e,limit:r=12}){for(let t=0;t<e.length;t=t+r){let n=e.slice(t,t+r);yield await Promise.all(n.map(a=>Ro(a)))}}var Ro=async({batchId:e,chunk:r,uploadFn:t,orderId:n})=>t({batch_id:e,content:new Uint8Array(await r.arrayBuffer()),order_id:N(n)});var wa=async({asset:e,...r})=>{let t=await F(r);await Ra({actor:t,asset:e})},Fa=async({collection:e,filter:r,...t})=>{let{list_assets:n}=await F(t),{items:a,items_length:i,items_page:o,matches_length:s,matches_pages:l}=await n(e,_e(r));return{items:a.map(([u,p])=>p),items_length:i,items_page:A(o),matches_length:s,matches_pages:A(l)}},Ea=async({collection:e,filter:r,...t})=>{let{count_assets:n}=await F(t);return n(e,_e(r))},ba=async({collection:e,fullPath:r,...t})=>(await F(t)).del_asset(e,r),Aa=async({assets:e,satellite:r})=>{let{del_many_assets:t}=await F({satellite:r,options:{certified:!0}}),n=e.map(({collection:a,fullPath:i})=>[a,i]);await t(n)},Va=async({collection:e,filter:r,...t})=>{let{del_filtered_assets:n}=await F(t);return n(e,_e(r))},Pa=async({collection:e,fullPath:r,...t})=>{let{get_asset:n}=await F(t);return A(await n(e,r))},va=async({assets:e,...r})=>{let{get_many_assets:t}=await F(r),n=e.map(({collection:i,fullPath:o})=>[i,o]);return(await t(n)).map(([i,o])=>A(o))};var Sa=e=>btoa([...e].map(r=>String.fromCharCode(r)).join(""));var Bu=e=>ka(e),Iu=e=>ka({filename:e.data.name,...e}),ka=async({filename:e,data:r,collection:t,headers:n=[],fullPath:a,token:i,satellite:o,encoding:s,description:l})=>{let u=g(o?.identity),p=decodeURI(e),d=a??`/${t}/${p}`,m={...o,identity:u};return await wa({asset:{data:r,filename:p,collection:t,token:i,headers:n,fullPath:d,encoding:s,description:l},satellite:m,options:{certified:!0}}),{downloadUrl:Ca({satellite:m,assetKey:{fullPath:d,token:i}}),fullPath:d,name:p}},qu=async({collection:e,filter:r,satellite:t,options:n})=>{let a={...t,identity:g(t?.identity)},{items:i,...o}=await Fa({collection:e,filter:r??{},satellite:a,options:n??ee}),s=i.map(({key:{full_path:l,token:u,name:p,owner:d,description:m},headers:f,encodings:x,created_at:B,updated_at:K})=>{let C=A(u);return{fullPath:l,description:A(m),name:p,downloadUrl:Ca({satellite:a,assetKey:{fullPath:l,token:C}}),token:C,headers:f,encodings:x.reduce((O,[_,{modified:V,sha256:R,total_length:w}])=>({...O,[_]:{modified:V,sha256:Sa(R),total_length:w}}),{}),owner:d.toText(),created_at:B,updated_at:K}});return{items:s,assets:s,...o}},Du=async({collection:e,filter:r,satellite:t,options:n})=>{let a={...t,identity:g(t?.identity)};return await Ea({collection:e,satellite:a,filter:r??{},options:n??ee})},ju=({collection:e,fullPath:r,satellite:t})=>ba({collection:e,fullPath:r,satellite:{...t,identity:g(t?.identity)},options:{certified:!0}}),Mu=({assets:e,satellite:r})=>Aa({assets:e,satellite:{...r,identity:g(r?.identity)},options:{certified:!0}}),Ku=async({collection:e,satellite:r,filter:t})=>{let n={...r,identity:g(r?.identity)};return await Va({collection:e,satellite:n,filter:t??{},options:{certified:!0}})},Ju=async({satellite:e,options:r,...t})=>{let n=g(e?.identity);return await Pa({...t,satellite:{...e,identity:n},options:r??ee})},Hu=async({satellite:e,options:r,...t})=>{let n=g(e?.identity);return await va({...t,satellite:{...e,identity:n},options:r??ee})},Ca=({assetKey:{fullPath:e,token:r},satellite:t})=>{let n={...t,identity:g(t?.identity)};return`${ia(n)}${e}${T(r)?`?token=${r}`:""}`};var wo=e=>{let r=e?.satelliteId??xa();Ir(r,"Satellite ID is not configured. Juno cannot be initialized.");let t=e?.container??Oa();return{satelliteId:r,internetIdentityId:e?.internetIdentityId,workers:e?.workers,container:t}},Zu=e=>Fo(e),Fo=async e=>{let r=wo(e);L.getInstance().set(r),await Mt();let t=r.workers?.auth!==void 0?ga(r.workers.auth):void 0;return[...t?[t]:[]]},Lu=e=>Q.getInstance().subscribe(e);export{Lr as InitError,Yr as InternetIdentityProvider,et as ListError,Qn as NFIDProvider,Xr as SignInError,Qr as SignInInitError,Zr as SignInUserInterruptError,Lu as authSubscribe,Du as countAssets,zl as countDocs,ju as deleteAsset,Kl as deleteDoc,Ku as deleteFilteredAssets,Hl as deleteFilteredDocs,Mu as deleteManyAssets,Jl as deleteManyDocs,Ca as downloadUrl,Ju as getAsset,ha as getDoc,To as getIdentityOnce,Hu as getManyAssets,jl as getManyDocs,Nu as getSatelliteExtendedActor,Zu as initJuno,Fo as initSatellite,qu as listAssets,$l as listDocs,Ta as setDoc,Ml as setManyDocs,fo as signIn,Kt as signOut,ho as unsafeIdentity,Bu as uploadBlob,Iu as uploadFile};
13
+ `)}throw new Error("unreachable")}var gn=({IDL:e})=>{let r=e.Variant({mainnet:e.Null,testnet:e.Null}),t=e.Text,n=e.Record({network:r,address:t,min_confirmations:e.Opt(e.Nat32)}),a=e.Nat64,i=a,o=e.Nat32,s=e.Record({start_height:o,end_height:e.Opt(o),network:r}),l=e.Vec(e.Nat8),u=e.Record({tip_height:o,block_headers:e.Vec(l)}),p=e.Record({network:r}),d=e.Nat64,m=e.Vec(d),f=e.Record({network:r,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:t}),x=e.Vec(e.Nat8),B=e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32}),K=e.Record({height:e.Nat32,value:a,outpoint:B}),C=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:o,tip_block_hash:x,utxos:e.Vec(K)}),O=e.Record({transaction:e.Vec(e.Nat8),network:r}),_=e.Principal,V=e.Record({canister_id:_,num_requested_changes:e.Opt(e.Nat64)}),R=e.Variant({from_user:e.Record({user_id:e.Principal}),from_canister:e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal})}),w=e.Vec(e.Nat8),S=e.Variant({creation:e.Record({controllers:e.Vec(e.Principal)}),code_deployment:e.Record({mode:e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),module_hash:e.Vec(e.Nat8)}),load_snapshot:e.Record({canister_version:e.Nat64,taken_at_timestamp:e.Nat64,snapshot_id:w}),controllers_change:e.Record({controllers:e.Vec(e.Principal)}),code_uninstall:e.Null}),I=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:R,details:S}),U=e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec(I),total_num_changes:e.Nat64}),E=e.Record({canister_id:_}),J=e.Variant({controllers:e.Null,public:e.Null,allowed_viewers:e.Vec(e.Principal)}),H=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),reserved_cycles_limit:e.Nat,log_visibility:J,wasm_memory_limit:e.Nat,memory_allocation:e.Nat,compute_allocation:e.Nat}),fe=e.Record({status:e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),memory_size:e.Nat,cycles:e.Nat,settings:H,query_stats:e.Record({response_payload_bytes_total:e.Nat,num_instructions_total:e.Nat,num_calls_total:e.Nat,request_payload_bytes_total:e.Nat}),idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8)),reserved_cycles:e.Nat}),v=e.Record({canister_id:_}),te=e.Record({freezing_threshold:e.Opt(e.Nat),controllers:e.Opt(e.Vec(e.Principal)),reserved_cycles_limit:e.Opt(e.Nat),log_visibility:e.Opt(J),wasm_memory_limit:e.Opt(e.Nat),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),ze=e.Record({settings:e.Opt(te),sender_canister_version:e.Opt(e.Nat64)}),We=e.Record({canister_id:_}),he=e.Record({canister_id:_}),$=e.Record({canister_id:_,snapshot_id:w}),ne=e.Record({canister_id:_}),q=e.Variant({secp256k1:e.Null}),ye=e.Record({key_id:e.Record({name:e.Text,curve:q}),canister_id:e.Opt(_),derivation_path:e.Vec(e.Vec(e.Nat8))}),ae=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),Ge=e.Record({canister_id:_}),ie=e.Record({idx:e.Nat64,timestamp_nanos:e.Nat64,content:e.Vec(e.Nat8)}),Ye=e.Record({canister_log_records:e.Vec(ie)}),Ae=e.Record({value:e.Text,name:e.Text}),Te=e.Record({status:e.Nat,body:e.Vec(e.Nat8),headers:e.Vec(Ae)}),oe=e.Record({url:e.Text,method:e.Variant({get:e.Null,head:e.Null,post:e.Null}),max_response_bytes:e.Opt(e.Nat64),body:e.Opt(e.Vec(e.Nat8)),transform:e.Opt(e.Record({function:e.Func([e.Record({context:e.Vec(e.Nat8),response:Te})],[Te],["query"]),context:e.Vec(e.Nat8)})),headers:e.Vec(Ae)}),Y=e.Variant({reinstall:e.Null,upgrade:e.Opt(e.Record({wasm_memory_persistence:e.Opt(e.Variant({keep:e.Null,replace:e.Null})),skip_pre_upgrade:e.Opt(e.Bool)})),install:e.Null}),Ne=e.Record({hash:e.Vec(e.Nat8)}),Xe=e.Record({arg:e.Vec(e.Nat8),wasm_module_hash:e.Vec(e.Nat8),mode:Y,chunk_hashes_list:e.Vec(Ne),target_canister:_,store_canister:e.Opt(_),sender_canister_version:e.Opt(e.Nat64)}),Qe=e.Vec(e.Nat8),Ze=e.Record({arg:e.Vec(e.Nat8),wasm_module:Qe,mode:Y,canister_id:_,sender_canister_version:e.Opt(e.Nat64)}),Le=e.Record({canister_id:_}),Ve=e.Record({id:w,total_size:e.Nat64,taken_at_timestamp:e.Nat64}),er=e.Vec(Ve),rr=e.Record({canister_id:_,sender_canister_version:e.Opt(e.Nat64),snapshot_id:w}),tr=e.Record({start_at_timestamp_nanos:e.Nat64,subnet_id:e.Principal}),nr=e.Record({num_block_failures_total:e.Nat64,node_id:e.Principal,num_blocks_proposed_total:e.Nat64}),ar=e.Vec(e.Record({timestamp_nanos:e.Nat64,node_metrics:e.Vec(nr)})),ir=e.Record({settings:e.Opt(te),specified_id:e.Opt(_),amount:e.Opt(e.Nat),sender_canister_version:e.Opt(e.Nat64)}),or=e.Record({canister_id:_}),sr=e.Record({canister_id:_,amount:e.Nat}),cr=e.Vec(e.Nat8),Pe=e.Variant({ed25519:e.Null,bip340secp256k1:e.Null}),ge=e.Record({key_id:e.Record({algorithm:Pe,name:e.Text}),canister_id:e.Opt(_),derivation_path:e.Vec(e.Vec(e.Nat8))}),lr=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),ur=e.Record({key_id:e.Record({name:e.Text,curve:q}),derivation_path:e.Vec(e.Vec(e.Nat8)),message_hash:e.Vec(e.Nat8)}),xe=e.Record({signature:e.Vec(e.Nat8)}),Oe=e.Variant({bip341:e.Record({merkle_root_hash:e.Vec(e.Nat8)})}),Ua=e.Record({aux:e.Opt(Oe),key_id:e.Record({algorithm:Pe,name:e.Text}),derivation_path:e.Vec(e.Vec(e.Nat8)),message:e.Vec(e.Nat8)}),Ba=e.Record({signature:e.Vec(e.Nat8)}),Ia=e.Record({canister_id:_}),qa=e.Record({canister_id:_}),Da=e.Record({canister_id:_}),ja=e.Vec(Ne),Ma=e.Record({subnet_id:e.Principal}),Ka=e.Record({replica_version:e.Text}),Ja=e.Record({replace_snapshot:e.Opt(w),canister_id:_}),Ha=Ve,$a=e.Record({canister_id:_,sender_canister_version:e.Opt(e.Nat64)}),za=e.Record({canister_id:e.Principal,settings:te,sender_canister_version:e.Opt(e.Nat64)}),Wa=e.Record({chunk:e.Vec(e.Nat8),canister_id:e.Principal}),Ga=Ne;return e.Service({bitcoin_get_balance:e.Func([n],[i],[]),bitcoin_get_block_headers:e.Func([s],[u],[]),bitcoin_get_current_fee_percentiles:e.Func([p],[m],[]),bitcoin_get_utxos:e.Func([f],[C],[]),bitcoin_send_transaction:e.Func([O],[],[]),canister_info:e.Func([V],[U],[]),canister_status:e.Func([E],[fe],[]),clear_chunk_store:e.Func([v],[],[]),create_canister:e.Func([ze],[We],[]),delete_canister:e.Func([he],[],[]),delete_canister_snapshot:e.Func([$],[],[]),deposit_cycles:e.Func([ne],[],[]),ecdsa_public_key:e.Func([ye],[ae],[]),fetch_canister_logs:e.Func([Ge],[Ye],["query"]),http_request:e.Func([oe],[Te],[]),install_chunked_code:e.Func([Xe],[],[]),install_code:e.Func([Ze],[],[]),list_canister_snapshots:e.Func([Le],[er],[]),load_canister_snapshot:e.Func([rr],[],[]),node_metrics_history:e.Func([tr],[ar],[]),provisional_create_canister_with_cycles:e.Func([ir],[or],[]),provisional_top_up_canister:e.Func([sr],[],[]),raw_rand:e.Func([],[cr],[]),schnorr_public_key:e.Func([ge],[lr],[]),sign_with_ecdsa:e.Func([ur],[xe],[]),sign_with_schnorr:e.Func([Ua],[Ba],[]),start_canister:e.Func([Ia],[],[]),stop_canister:e.Func([qa],[],[]),stored_chunks:e.Func([Da],[ja],[]),subnet_info:e.Func([Ma],[Ka],[]),take_canister_snapshot:e.Func([Ja],[Ha],[]),uninstall_code:e.Func([$a],[],[]),update_settings:e.Func([za],[],[]),upload_chunk:e.Func([Wa],[Ga],[])})};var Br=class extends br{constructor(r,t,n,a){super(["Call failed:",` Canister: ${r.toText()}`,` Method: ${t} (${n})`,...Object.getOwnPropertyNames(a).map(i=>` "${i}": ${JSON.stringify(a[i])}`)].join(`
14
+ `)),this.canisterId=r,this.methodName=t,this.type=n,this.props=a}},Tt=class extends Br{constructor(r,t,n){var a;super(r,t,"query",{Status:n.status,Code:(a=Ht[n.reject_code])!==null&&a!==void 0?a:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},Ir=class extends Br{constructor(r,t,n,a,i,o,s){super(r,t,"update",Object.assign({"Request ID":P(n)},a.body?Object.assign(Object.assign({},s?{"Error code":s}:{}),{"Reject code":String(i),"Reject message":o}):{"HTTP status code":a.status.toString(),"HTTP status text":a.statusText})),this.requestId=n,this.response=a,this.reject_code=i,this.reject_message=o,this.error_code=s}},j=Symbol.for("ic-agent-metadata"),ce=class e{constructor(r){this[j]=Object.freeze(r)}static agentOf(r){return r[j].config.agent}static interfaceOf(r){return r[j].service}static canisterIdOf(r){return y.from(r[j].config.canisterId)}static async install(r,t){let n=r.mode===void 0?{install:null}:r.mode,a=r.arg?[...new Uint8Array(r.arg)]:[],i=[...new Uint8Array(r.module)],o=typeof t.canisterId=="string"?y.fromText(t.canisterId):t.canisterId;await xn(t).install_code({mode:n,arg:a,wasm_module:i,canister_id:o,sender_canister_version:[]})}static async createCanister(r,t){function n(i){return[{controllers:i.controllers?[i.controllers]:[],compute_allocation:i.compute_allocation?[i.compute_allocation]:[],freezing_threshold:i.freezing_threshold?[i.freezing_threshold]:[],memory_allocation:i.memory_allocation?[i.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:a}=await xn(r||{}).provisional_create_canister_with_cycles({amount:[],settings:n(t||{}),specified_id:[],sender_canister_version:[]});return a}static async createAndInstallCanister(r,t,n){let a=await this.createCanister(n);return await this.install(Object.assign({},t),Object.assign(Object.assign({},n),{canisterId:a})),this.createActor(r,Object.assign(Object.assign({},n),{canisterId:a}))}static createActorClass(r,t){let n=r({IDL:dr});class a extends e{constructor(o){if(!o.canisterId)throw new br(`Canister ID is required, but received ${typeof o.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 s=typeof o.canisterId=="string"?y.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Rn),o),{canisterId:s}),service:n});for(let[l,u]of n._fields)t?.httpDetails&&u.annotations.push(Nt),t?.certificate&&u.annotations.push(wn),this[l]=Ui(this,l,u,o.blsVerify)}}return a}static createActor(r,t){if(!t.canisterId)throw new br(`Canister ID is required, but received ${typeof t.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(r))(t)}static createActorWithHttpDetails(r,t){return new(this.createActorClass(r,{httpDetails:!0}))(t)}static createActorWithExtendedDetails(r,t,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(r,n))(t)}};function Ie(e,r){let t=dr.decode(e,On.Buffer.from(r));switch(t.length){case 0:return;case 1:return t[0];default:return t}}var Rn={pollingStrategyFactory:Ur.defaultStrategy},Nt="http-details",wn="certificate";function Ui(e,r,t,n){let a;t.annotations.includes("query")||t.annotations.includes("composite_query")?a=async(o,...s)=>{var l,u;o=Object.assign(Object.assign({},o),(u=(l=e[j].config).queryTransform)===null||u===void 0?void 0:u.call(l,r,s,Object.assign(Object.assign({},e[j].config),o)));let p=o.agent||e[j].config.agent||st(),d=y.from(o.canisterId||e[j].config.canisterId),m=dr.encode(t.argTypes,s),f=await p.query(d,{methodName:r,arg:m,effectiveCanisterId:o.effectiveCanisterId}),x=Object.assign(Object.assign({},f.httpDetails),{requestDetails:f.requestDetails});switch(f.status){case"rejected":throw new Tt(d,r,f);case"replied":return t.annotations.includes(Nt)?{httpDetails:x,result:Ie(t.retTypes,f.reply.arg)}:Ie(t.retTypes,f.reply.arg)}}:a=async(o,...s)=>{var l,u;o=Object.assign(Object.assign({},o),(u=(l=e[j].config).callTransform)===null||u===void 0?void 0:u.call(l,r,s,Object.assign(Object.assign({},e[j].config),o)));let p=o.agent||e[j].config.agent||st(),{canisterId:d,effectiveCanisterId:m,pollingStrategyFactory:f}=Object.assign(Object.assign(Object.assign({},Rn),e[j].config),o),x=y.from(d),B=m!==void 0?y.from(m):x,K=dr.encode(t.argTypes,s),{requestId:C,response:O,requestDetails:_}=await p.call(x,{methodName:r,arg:K,effectiveCanisterId:B}),V,R;if(O.body&&O.body.certificate){if(p.rootKey==null)throw new Error("Agent is missing root key");let U=O.body.certificate;R=await Ar.create({certificate:at(U),rootKey:p.rootKey,canisterId:y.from(d),blsVerify:n});let E=[new TextEncoder().encode("request_status"),C];switch(new TextDecoder().decode(z(R.lookup([...E,"status"])))){case"replied":V=z(R.lookup([...E,"reply"]));break;case"rejected":{let H=new Uint8Array(z(R.lookup([...E,"reject_code"])))[0],fe=new TextDecoder().decode(z(R.lookup([...E,"reject_message"]))),v=z(R.lookup([...E,"error_code"])),te=v?new TextDecoder().decode(v):void 0;throw new Ir(x,r,C,O,H,fe,te)}}}else if(O.body&&"reject_message"in O.body){let{reject_code:U,reject_message:E,error_code:J}=O.body;throw new Ir(x,r,C,O,U,E,J)}if(O.status===202){let U=f(),E=await yt(p,B,C,U,n);R=E.certificate,V=E.reply}let w=t.annotations.includes(Nt),S=t.annotations.includes(wn),I=Object.assign(Object.assign({},O),{requestDetails:_});if(V!==void 0)return w&&S?{httpDetails:I,certificate:R,result:Ie(t.retTypes,V)}:S?{certificate:R,result:Ie(t.retTypes,V)}:w?{httpDetails:I,result:Ie(t.retTypes,V)}:Ie(t.retTypes,V);if(t.retTypes.length===0)return w?{httpDetails:O,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${t.retTypes.join(",")}].`)};let i=(...o)=>a({},...o);return i.withOptions=o=>(...s)=>a(o,...s),i}function xn(e){function r(t,n){if(e.effectiveCanisterId)return{effectiveCanisterId:y.from(e.effectiveCanisterId)};let a=n[0],i=y.fromHex("");return a&&typeof a=="object"&&a.target_canister&&t==="install_chunked_code"&&(i=y.from(a.target_canister)),a&&typeof a=="object"&&a.canister_id&&(i=y.from(a.canister_id)),{effectiveCanisterId:i}}return ce.createActor(gn,Object.assign(Object.assign(Object.assign({},e),{canisterId:y.fromHex("")}),{callTransform:r,queryTransform:r}))}var Ii=(e=>(e[e.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",e[e.InvalidFormat=1]="InvalidFormat",e[e.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",e))(Ii||{}),gs=BigInt(1e8);var h=e=>e==null,T=e=>!h(e);var qi=class extends Error{},fr=(e,r)=>{if(e==null)throw new qi(r)};var Fn="abcdefghijklmnopqrstuvwxyz234567",mr=Object.create(null);for(let e=0;e<Fn.length;e++)mr[Fn[e]]=e;mr[0]=mr.o;mr[1]=mr.i;var Rs=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);var gt="__bigint__",xt="__principal__",Ot="__uint8array__",En=(e,r)=>typeof r=="bigint"?{[gt]:`${r}`}:T(r)&&r instanceof y?{[xt]:r.toText()}:T(r)&&r instanceof Uint8Array?{[Ot]:Array.from(r)}:r,bn=(e,r)=>{let t=n=>r[n];return T(r)&&typeof r=="object"&&gt in r?BigInt(t(gt)):T(r)&&typeof r=="object"&&xt in r?y.fromText(t(xt)):T(r)&&typeof r=="object"&&Ot in r?Uint8Array.from(t(Ot)):r};var N=e=>T(e)?[e]:[],A=e=>e?.[0];var qe=class{callbacks=[];populate(r){this.callbacks.forEach(({callback:t})=>t(r))}subscribe(r){let t=Symbol();return this.callbacks.push({id:t,callback:r}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==t)}};var Z=class e extends qe{static instance;authUser=null;constructor(){super()}static getInstance(){return e.instance||(e.instance=new e),e.instance}set(r){this.authUser=r,this.populate(r)}get(){return this.authUser}subscribe(r){let t=super.subscribe(r);return r(this.authUser),t}reset(){this.authUser=null,this.populate(this.authUser)}};var Rt=({message:e,detail:r})=>{let t=new CustomEvent(e,{detail:r,bubbles:!0});document.dispatchEvent(t)};var jr=function(e,r,t,n,a){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?e!==r||!a:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?a.call(e,t):a?a.value=t:r.set(e,t),t},pe=function(e,r,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?e!==r||!n:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(e):n?n.value:r.get(e)},qr,Dr,De,je;function An(e){return e!==null&&typeof e=="object"}var Ee=class e{constructor(r){if(qr.set(this,void 0),Dr.set(this,void 0),r.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");jr(this,qr,r,"f"),jr(this,Dr,e.derEncode(r),"f")}static from(r){if(typeof r=="string"){let t=le(r);return this.fromRaw(t)}else if(An(r)){let t=r;if(An(t)&&Object.hasOwnProperty.call(t,"__derEncodedPublicKey__"))return this.fromDer(t);if(ArrayBuffer.isView(t)){let n=t;return this.fromRaw(Wt(n.buffer))}else{if(t instanceof ArrayBuffer)return this.fromRaw(t);if("rawKey"in t)return this.fromRaw(t.rawKey);if("derKey"in t)return this.fromDer(t.derKey);if("toDer"in t)return this.fromDer(t.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(r){return new e(r)}static fromDer(r){return new e(this.derDecode(r))}static derEncode(r){let t=Pr(r,Vr).buffer;return t.__derEncodedPublicKey__=void 0,t}static derDecode(r){let t=ot(r,Vr);if(t.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return t}get rawKey(){return pe(this,qr,"f")}get derKey(){return pe(this,Dr,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};qr=new WeakMap,Dr=new WeakMap;Ee.RAW_KEY_LENGTH=32;var be=class e extends Re{constructor(r,t){super(),De.set(this,void 0),je.set(this,void 0),jr(this,De,Ee.from(r),"f"),jr(this,je,new Uint8Array(t),"f")}static generate(r){if(r&&r.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");r||(r=Se.utils.randomPrivateKey()),$t(r,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 t=new Uint8Array(32);for(let a=0;a<32;a++)t[a]=new Uint8Array(r)[a];let n=Se.getPublicKey(t);return e.fromKeyPair(n,t)}static fromParsedJson(r){let[t,n]=r;return new e(Ee.fromDer(le(t)),le(n))}static fromJSON(r){let t=JSON.parse(r);if(Array.isArray(t)){if(typeof t[0]=="string"&&typeof t[1]=="string")return this.fromParsedJson([t[0],t[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(r)}`)}static fromKeyPair(r,t){return new e(Ee.fromRaw(r),t)}static fromSecretKey(r){let t=Se.getPublicKey(new Uint8Array(r));return e.fromKeyPair(t,r)}toJSON(){return[P(pe(this,De,"f").toDer()),P(pe(this,je,"f"))]}getKeyPair(){return{secretKey:pe(this,je,"f"),publicKey:pe(this,De,"f")}}getPublicKey(){return pe(this,De,"f")}async sign(r){let t=new Uint8Array(r),n=zt(Se.sign(t,pe(this,je,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(r,t,n){let[a,i,o]=[r,t,n].map(s=>(typeof s=="string"&&(s=le(s)),s instanceof Uint8Array&&(s=s.buffer),new Uint8Array(s)));return Se.verify(i,a,o)}};De=new WeakMap,je=new WeakMap;var wt=class e extends Error{constructor(r){super(r),this.message=r,Object.setPrototypeOf(this,e.prototype)}};function Vn(e){if(typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.subtle)return globalThis.crypto.subtle;if(e)return e;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new wt("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 hr=class e extends Re{constructor(r,t,n){super(),this._keyPair=r,this._derKey=t,this._subtleCrypto=n}static async generate(r){let{extractable:t=!1,keyUsages:n=["sign","verify"],subtleCrypto:a}=r??{},i=Vn(a),o=await i.generateKey({name:"ECDSA",namedCurve:"P-256"},t,n),s=await i.exportKey("spki",o.publicKey);return new this(o,s,i)}static async fromKeyPair(r,t){let n=Vn(t),a=await n.exportKey("spki",r.publicKey);return new e(r,a,n)}getKeyPair(){return this._keyPair}getPublicKey(){let r=this._derKey,t=Object.create(this._keyPair.publicKey);return t.toDer=function(){return r},t}async sign(r){let t={name:"ECDSA",hash:{name:"SHA-256"}};return await this._subtleCrypto.sign(t,this._keyPair.privateKey,r)}};var Me=nt(Za());var Di=function(e,r,t,n,a){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?e!==r||!a:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?a.call(e,t):a?a.value=t:r.set(e,t),t},yr=function(e,r,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?e!==r||!n:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(e):n?n.value:r.get(e)},_e,Mr=class{constructor(r){_e.set(this,void 0),Di(this,_e,r,"f")}get rawKey(){return yr(this,_e,"f").rawKey}get derKey(){return yr(this,_e,"f").derKey}toDer(){return yr(this,_e,"f").toDer()}getPublicKey(){return yr(this,_e,"f")}getPrincipal(){return y.from(yr(this,_e,"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.")}};_e=new WeakMap;var ji=function(e,r,t,n,a){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?e!==r||!a:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?a.call(e,t):a?a.value=t:r.set(e,t),t},Mi=function(e,r,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?e!==r||!n:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(e):n?n.value:r.get(e)},Ki=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)r.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(t[n[a]]=e[n[a]]);return t},Kr,Ji=new TextEncoder().encode("ic-request-auth-delegation"),Hi=new TextEncoder().encode(`
15
+ ic-request`);function Ft(e){if(typeof e!="string"||e.length<64)throw new Error("Invalid public key.");return le(e)}var Ke=class{constructor(r,t,n){this.pubkey=r,this.expiration=t,this.targets=n}toCBOR(){return Me.value.map(Object.assign({pubkey:Me.value.bytes(this.pubkey),expiration:Me.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Me.value.array(this.targets.map(r=>Me.value.bytes(r.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:P(this.pubkey)},this.targets&&{targets:this.targets.map(r=>r.toHex())})}};async function $i(e,r,t,n){let a=new Ke(r.toDer(),BigInt(+t)*BigInt(1e6),n),i=new Uint8Array([...Ji,...new Uint8Array(it(Object.assign({},a)))]),o=await e.sign(i);return{delegation:a,signature:o}}var Tr=class e{constructor(r,t){this.delegations=r,this.publicKey=t}static async create(r,t,n=new Date(Date.now()+900*1e3),a={}){var i,o;let s=await $i(r,t,n,a.targets);return new e([...((i=a.previous)===null||i===void 0?void 0:i.delegations)||[],s],((o=a.previous)===null||o===void 0?void 0:o.publicKey)||r.getPublicKey().toDer())}static fromJSON(r){let{publicKey:t,delegations:n}=typeof r=="string"?JSON.parse(r):r;if(!Array.isArray(n))throw new Error("Invalid delegations.");let a=n.map(i=>{let{delegation:o,signature:s}=i,{pubkey:l,expiration:u,targets:p}=o;if(p!==void 0&&!Array.isArray(p))throw new Error("Invalid targets.");return{delegation:new Ke(Ft(l),BigInt("0x"+u),p&&p.map(d=>{if(typeof d!="string")throw new Error("Invalid target.");return y.fromHex(d)})),signature:Ft(s)}});return new this(a,Ft(t))}static fromDelegations(r,t){return new this(r,t)}toJSON(){return{delegations:this.delegations.map(r=>{let{delegation:t,signature:n}=r,{targets:a}=t;return{delegation:Object.assign({expiration:t.expiration.toString(16),pubkey:P(t.pubkey)},a&&{targets:a.map(i=>i.toHex())}),signature:P(n)}}),publicKey:P(this.publicKey)}}},Nr=class extends Re{constructor(r,t){super(),this._inner=r,this._delegation=t}static fromDelegation(r,t){return new this(r,t)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(r){return this._inner.sign(r)}async transformRequest(r){let{body:t}=r,n=Ki(r,["body"]),a=await it(t);return Object.assign(Object.assign({},n),{body:{content:t,sender_sig:await this.sign(new Uint8Array([...Hi,...new Uint8Array(a)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},gr=class e extends Mr{constructor(r,t){super(r),Kr.set(this,void 0),ji(this,Kr,t,"f")}get delegation(){return Mi(this,Kr,"f")}static fromDelegation(r,t){return new e(r,t)}};Kr=new WeakMap;function Pn(e,r){for(let{delegation:a}of e.delegations)if(+new Date(Number(a.expiration/BigInt(1e6)))<=+Date.now())return!1;let t=[],n=r?.scope;n&&(Array.isArray(n)?t.push(...n.map(a=>typeof a=="string"?y.fromText(a):a)):t.push(typeof n=="string"?y.fromText(n):n));for(let a of t){let i=a.toText();for(let{delegation:o}of e.delegations){if(o.targets===void 0)continue;let s=!0;for(let l of o.targets)if(l.toText()===i){s=!1;break}if(s)return!1}}return!0}var Wi=nt(Qa());var vn;(function(e){e[e.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(vn||(vn={}));var Sn=["mousedown","mousemove","keydown","touchstart","wheel"],xr=class{constructor(r={}){var t;this.callbacks=[],this.idleTimeout=600*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:a=600*1e3}=r||{};this.callbacks=n?[n]:[],this.idleTimeout=a;let i=this._resetTimer.bind(this);window.addEventListener("load",i,!0),Sn.forEach(function(s){document.addEventListener(s,i,!0)});let o=(s,l)=>{let u;return(...p)=>{let d=this,m=function(){u=void 0,s.apply(d,p)};clearTimeout(u),u=window.setTimeout(m,l)}};if(r?.captureScroll){let s=o(i,(t=r?.scrollDebounce)!==null&&t!==void 0?t:100);window.addEventListener("scroll",s,!0)}i()}static create(r={}){return new this(r)}registerCallback(r){this.callbacks.push(r)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let r=this._resetTimer.bind(this);Sn.forEach(function(t){document.removeEventListener(t,r,!0)}),this.callbacks.forEach(t=>t())}_resetTimer(){let r=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(r,this.idleTimeout)}};var Gi=(e,r)=>r.some(t=>e instanceof t),kn,Cn;function Yi(){return kn||(kn=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Xi(){return Cn||(Cn=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Un=new WeakMap,bt=new WeakMap,Bn=new WeakMap,Et=new WeakMap,Vt=new WeakMap;function Qi(e){let r=new Promise((t,n)=>{let a=()=>{e.removeEventListener("success",i),e.removeEventListener("error",o)},i=()=>{t(L(e.result)),a()},o=()=>{n(e.error),a()};e.addEventListener("success",i),e.addEventListener("error",o)});return r.then(t=>{t instanceof IDBCursor&&Un.set(t,e)}).catch(()=>{}),Vt.set(r,e),r}function Zi(e){if(bt.has(e))return;let r=new Promise((t,n)=>{let a=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",o),e.removeEventListener("abort",o)},i=()=>{t(),a()},o=()=>{n(e.error||new DOMException("AbortError","AbortError")),a()};e.addEventListener("complete",i),e.addEventListener("error",o),e.addEventListener("abort",o)});bt.set(e,r)}var At={get(e,r,t){if(e instanceof IDBTransaction){if(r==="done")return bt.get(e);if(r==="objectStoreNames")return e.objectStoreNames||Bn.get(e);if(r==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return L(e[r])},set(e,r,t){return e[r]=t,!0},has(e,r){return e instanceof IDBTransaction&&(r==="done"||r==="store")?!0:r in e}};function In(e){At=e(At)}function Li(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(r,...t){let n=e.call(Jr(this),r,...t);return Bn.set(n,r.sort?r.sort():[r]),L(n)}:Xi().includes(e)?function(...r){return e.apply(Jr(this),r),L(Un.get(this))}:function(...r){return L(e.apply(Jr(this),r))}}function eo(e){return typeof e=="function"?Li(e):(e instanceof IDBTransaction&&Zi(e),Gi(e,Yi())?new Proxy(e,At):e)}function L(e){if(e instanceof IDBRequest)return Qi(e);if(Et.has(e))return Et.get(e);let r=eo(e);return r!==e&&(Et.set(e,r),Vt.set(r,e)),r}var Jr=e=>Vt.get(e);function Dn(e,r,{blocked:t,upgrade:n,blocking:a,terminated:i}={}){let o=indexedDB.open(e,r),s=L(o);return n&&o.addEventListener("upgradeneeded",l=>{n(L(o.result),l.oldVersion,l.newVersion,L(o.transaction),l)}),t&&o.addEventListener("blocked",l=>t(l.oldVersion,l.newVersion,l)),s.then(l=>{i&&l.addEventListener("close",()=>i()),a&&l.addEventListener("versionchange",u=>a(u.oldVersion,u.newVersion,u))}).catch(()=>{}),s}var ro=["get","getKey","getAll","getAllKeys","count"],to=["put","add","delete","clear"],Pt=new Map;function qn(e,r){if(!(e instanceof IDBDatabase&&!(r in e)&&typeof r=="string"))return;if(Pt.get(r))return Pt.get(r);let t=r.replace(/FromIndex$/,""),n=r!==t,a=to.includes(t);if(!(t in(n?IDBIndex:IDBObjectStore).prototype)||!(a||ro.includes(t)))return;let i=async function(o,...s){let l=this.transaction(o,a?"readwrite":"readonly"),u=l.store;return n&&(u=u.index(s.shift())),(await Promise.all([u[t](...s),a&&l.done]))[0]};return Pt.set(r,i),i}In(e=>({...e,get:(r,t,n)=>qn(r,t)||e.get(r,t,n),has:(r,t)=>!!qn(r,t)||e.has(r,t)}));var jn="auth-client-db",Mn="ic-keyval",no=async(e=jn,r=Mn,t)=>(Hr&&(localStorage!=null&&localStorage.getItem(W))&&(localStorage.removeItem(W),localStorage.removeItem(G)),await Dn(e,t,{upgrade:n=>{n.objectStoreNames.contains(r)&&n.clear(r),n.createObjectStore(r)}}));async function ao(e,r,t){return await e.get(r,t)}async function io(e,r,t,n){return await e.put(r,n,t)}async function oo(e,r,t){return await e.delete(r,t)}var Or=class e{constructor(r,t){this._db=r,this._storeName=t}static async create(r){let{dbName:t=jn,storeName:n=Mn,version:a=Kn}=r??{},i=await no(t,n,a);return new e(i,n)}async set(r,t){return await io(this._db,this._storeName,r,t)}async get(r){var t;return(t=await ao(this._db,this._storeName,r))!==null&&t!==void 0?t:null}async remove(r){return await oo(this._db,this._storeName,r)}};var so=function(e,r,t,n,a){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?e!==r||!a:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?a.call(e,t):a?a.value=t:r.set(e,t),t},co=function(e,r,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?e!==r||!n:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(e):n?n.value:r.get(e)},$r,G="identity",W="delegation",Jn="iv",Kn=1,Hr=typeof window<"u",Rr=class{constructor(r="ic-",t){this.prefix=r,this._localStorage=t}get(r){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+r))}set(r,t){return this._getLocalStorage().setItem(this.prefix+r,t),Promise.resolve()}remove(r){return this._getLocalStorage().removeItem(this.prefix+r),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let r=typeof window>"u"?typeof globalThis>"u"?typeof self>"u"?void 0:self.localStorage:globalThis.localStorage:window.localStorage;if(!r)throw new Error("Could not find local storage.");return r}},wr=class{constructor(r){$r.set(this,void 0),so(this,$r,r??{},"f")}get _db(){return new Promise(r=>{if(this.initializedDb){r(this.initializedDb);return}Or.create(co(this,$r,"f")).then(t=>{this.initializedDb=t,r(t)})})}async get(r){return await(await this._db).get(r)}async set(r,t){await(await this._db).set(r,t)}async remove(r){await(await this._db).remove(r)}};$r=new WeakMap;var lo="https://identity.ic0.app",uo="#authorize",vt="ECDSA",St="Ed25519",po=500,Ct="UserInterrupt",zr=class{constructor(r,t,n,a,i,o,s,l){this._identity=r,this._key=t,this._chain=n,this._storage=a,this.idleManager=i,this._createOptions=o,this._idpWindow=s,this._eventHandler=l,this._registerDefaultIdleCallback()}static async create(r={}){var t,n,a;let i=(t=r.storage)!==null&&t!==void 0?t:new wr,o=(n=r.keyType)!==null&&n!==void 0?n:vt,s=null;if(r.identity)s=r.identity;else{let d=await i.get(G);if(!d&&Hr)try{let m=new Rr,f=await m.get(W),x=await m.get(G);f&&x&&o===vt&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await i.set(W,f),await i.set(G,x),d=f,await m.remove(W),await m.remove(G))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(d)try{typeof d=="object"?o===St&&typeof d=="string"?s=await be.fromJSON(d):s=await hr.fromKeyPair(d):typeof d=="string"&&(s=be.fromJSON(d))}catch{}}let l=new ve,u=null;if(s)try{let d=await i.get(W);if(typeof d=="object"&&d!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");r.identity?l=r.identity:d&&(u=Tr.fromJSON(d),Pn(u)?"toDer"in s?l=gr.fromDelegation(s,u):l=Nr.fromDelegation(s,u):(await kt(i),s=null))}catch(d){console.error(d),await kt(i),s=null}let p;return!((a=r.idleOptions)===null||a===void 0)&&a.disableIdle?p=void 0:(u||r.identity)&&(p=xr.create(r.idleOptions)),s||(o===St?(s=await be.generate(),await i.set(G,JSON.stringify(s.toJSON()))):(r.storage&&o===vt&&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 '${St}' as the key type, as it can serialize to a string`),s=await hr.generate(),await i.set(G,s.getKeyPair()))),new this(l,s,u,i,p,r)}_registerDefaultIdleCallback(){var r,t;let n=(r=this._createOptions)===null||r===void 0?void 0:r.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((t=this.idleManager)===null||t===void 0||t.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(r,t){var n,a;let i=r.delegations.map(u=>({delegation:new Ke(u.delegation.pubkey,u.delegation.expiration,u.delegation.targets),signature:u.signature.buffer})),o=Tr.fromDelegations(i,r.userPublicKey.buffer),s=this._key;if(!s)return;this._chain=o,"toDer"in s?this._identity=gr.fromDelegation(s,this._chain):this._identity=Nr.fromDelegation(s,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let l=(a=this._createOptions)===null||a===void 0?void 0:a.idleOptions;!this.idleManager&&!l?.disableIdle&&(this.idleManager=xr.create(l),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(W,JSON.stringify(this._chain.toJSON())),t?.(r)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(r){var t,n,a,i;let o=BigInt(8)*BigInt(36e11),s=new URL(((t=r?.identityProvider)===null||t===void 0?void 0:t.toString())||lo);s.hash=uo,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(s,Object.assign({maxTimeToLive:(a=r?.maxTimeToLive)!==null&&a!==void 0?a:o},r)),window.addEventListener("message",this._eventHandler),this._idpWindow=(i=window.open(s.toString(),"idpWindow",r?.windowOpenerFeatures))!==null&&i!==void 0?i:void 0;let l=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Ct,r?.onError):setTimeout(l,po))};l()}_getEventHandler(r,t){return async n=>{var a,i,o;if(n.origin!==r.origin)return;let s=n.data;switch(s.kind){case"authorize-ready":{let l=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((a=this._key)===null||a===void 0?void 0:a.getPublicKey().toDer()),maxTimeToLive:t?.maxTimeToLive,allowPinAuthentication:t?.allowPinAuthentication,derivationOrigin:(i=t?.derivationOrigin)===null||i===void 0?void 0:i.toString()},t?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(l,r.origin);break}case"authorize-client-success":try{await this._handleSuccess(s,t?.onSuccess)}catch(l){this._handleFailure(l.message,t?.onError)}break;case"authorize-client-failure":this._handleFailure(s.text,t?.onError);break;default:break}}}_handleFailure(r,t){var n;(n=this._idpWindow)===null||n===void 0||n.close(),t?.(r),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(r={}){if(await kt(this._storage),this._identity=new ve,this._chain=null,r.returnTo)try{window.history.pushState({},"",r.returnTo)}catch{window.location.href=r.returnTo}}};async function kt(e){await e.remove(G),await e.remove(W),await e.remove(Jn)}var Hn=BigInt(144e11),$n=!1,zn={width:576,height:576},Wn={width:505,height:705},Gn="internetcomputer.org";var Je="http://127.0.0.1:5987",Yn="rdmx6-jaaaa-aaaaa-aaadq-cai";var ee=class e extends qe{static instance;env;constructor(){super()}static getInstance(){return e.instance||(e.instance=new e),e.instance}set(r){this.env=r,this.populate(r)}get(){return this.env}reset(){this.env=null}subscribe(r){let t=super.subscribe(r);return r(this.env),t}};var Xn=async e=>{let r=new Blob([JSON.stringify(e,En)],{type:"application/json; charset=utf-8"});return new Uint8Array(await r.arrayBuffer())},Wr=async e=>{let r=new Blob([e instanceof Uint8Array?e:new Uint8Array(e)],{type:"application/json; charset=utf-8"});return JSON.parse(await r.text(),bn)},Gr=()=>typeof window<"u";var Ut=({width:e,height:r})=>{if(!Gr()||h(window)||h(window.top))return;let{top:{innerWidth:t,innerHeight:n}}=window,a=n/2+screenY-r/2,i=t/2+screenX-e/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${e}, height=${r}, top=${a}, left=${i}`};var Yr=class{#e;constructor({domain:r}){this.#e=r}get id(){return"internet_identity"}signInOptions({windowed:r}){let t=()=>{let n=ee.getInstance().get()?.container;if(h(n)||n===!1)return`https://identity.${this.#e??Gn}`;let a=ee.getInstance().get(),i=T(a)&&T(a?.internetIdentityId)?a.internetIdentityId:Yn,{host:o,protocol:s}=new URL(n===!0?Je:n);return/apple/i.test(navigator?.vendor)?`${s}//${o}?canisterId=${i}`:`${s}//${i}.${o.replace("127.0.0.1","localhost")}`};return{...r!==!1&&{windowOpenerFeatures:Ut(zn)},identityProvider:t()}}},Qn=class{#e;#r;constructor({appName:r,logoUrl:t}){this.#e=r,this.#r=t}get id(){return"nfid"}signInOptions({windowed:r}){return{...r!==!1&&{windowOpenerFeatures:Ut(Wn)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#r)}`}}};var Zn=async({identity:e,container:r})=>{let n=T(r)&&r!==!1?r===!0?Je:r:"https://icp-api.io",a=T(r);return await pr.create({identity:e,shouldFetchRootKey:a,host:n})};var He=class e{static instance;#e=void 0;constructor(){}static getInstance(){return h(e.instance)&&(e.instance=new e),e.instance}async getAgent({identity:r,...t}){let n=r.getPrincipal().toText();if(h(this.#e)||h(this.#e[n])){let a=await Zn({identity:r,...t});return this.#e={...this.#e??{},[n]:a},a}return this.#e[n]}reset(){this.#e=null}};var $e=class e{static instance;#e=void 0;constructor(){}static getInstance(){return h(e.instance)&&(e.instance=new e),e.instance}async getActor({satelliteId:r,identity:t,actorKey:n,...a}){let i=`${n}#${t.getPrincipal().toText()}#${r};`;if(h(this.#e)||h(this.#e[i])){let o=await this.createActor({satelliteId:r,identity:t,...a});return this.#e={...this.#e??{},[i]:o},o}return this.#e[i]}reset(){this.#e=null}async createActor({idlFactory:r,satelliteId:t,...n}){let a=await He.getInstance().getAgent(n);return ce.createActor(r,{agent:a,canisterId:t})}};var Xr=class extends Error{},Qr=class extends Error{},Zr=class extends Error{},Lr=class extends Error{},et=class extends Error{};var rt=()=>zr.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Bt=({error:e,type:r})=>typeof e=="string"?e.includes(r):e instanceof Error?e.message.includes(r):!1;var Ln="juno.datastore.error.user.cannot_update";var ea=async({data:e})=>{try{return await Wr(e)}catch(r){console.error("The data parsing has failed, mapping to undefined as a fallback.",r);return}};var It=async e=>{let{data:r,version:t,description:n}=e;return{description:N(n),data:await Xn(r),version:N(t)}},qt=e=>{let{version:r}=e;return{version:N(r)}},Fr=async({doc:e,key:r})=>{let{owner:t,version:n,description:a,data:i,...o}=e;return{key:r,description:A(a),owner:t.toText(),data:await Wr(i),version:A(n),...o}};var ra=e=>{if(h(e))return N();switch(e.matcher){case"equal":return N({Equal:e.timestamp});case"greaterThan":return N({GreaterThan:e.timestamp});case"lessThan":return N({LessThan:e.timestamp});case"between":return N({Between:[e.timestamps.start,e.timestamps.end]});default:throw new et("Invalid list matcher for timestamp",e)}},me=({matcher:e,paginate:r,order:t,owner:n})=>({matcher:h(e)?[]:[{key:N(e.key),description:N(e.description),created_at:ra(e.createdAt),updated_at:ra(e.updatedAt)}],paginate:N(h(r)?void 0:{start_after:N(r.startAfter),limit:N(h(r.limit)?void 0:BigInt(r.limit))}),order:N(h(t)?void 0:{desc:t.desc,field:t.field==="created_at"?{CreatedAt:null}:t.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:N(h(n)?void 0:typeof n=="string"?y.fromText(n):n)});var _o=(e=>(e[e.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",e[e.InvalidFormat=1]="InvalidFormat",e[e.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",e))(_o||{}),_l=BigInt(1e8);var ta="abcdefghijklmnopqrstuvwxyz234567",Er=Object.create(null);for(let e=0;e<ta.length;e++)Er[ta[e]]=e;Er[0]=Er.o;Er[1]=Er.i;var ml=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);var na=({IDL:e})=>{let r=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),t=e.Record({sha256:e.Vec(e.Nat8),proposal_id:e.Nat}),n=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),a=e.Record({field:n,desc:e.Bool}),i=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),o=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(i),description:e.Opt(e.Text),created_at:e.Opt(i)}),s=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),l=e.Record({order:e.Opt(a),owner:e.Opt(e.Principal),matcher:e.Opt(o),paginate:e.Opt(s)}),u=e.Record({controllers:e.Vec(e.Principal)}),p=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),d=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:p,expires_at:e.Opt(e.Nat64)}),m=e.Record({version:e.Opt(e.Nat64)}),f=e.Variant({Db:e.Null,Storage:e.Null}),x=e.Record({version:e.Opt(e.Nat64)}),B=e.Record({proposal_ids:e.Vec(e.Nat)}),K=e.Record({cycles:e.Nat,destination_id:e.Principal}),C=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),O=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),_=e.Record({key:C,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,O)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),V=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),R=e.Record({allowed_callers:e.Vec(e.Principal)}),w=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(V),rules:e.Opt(R)}),S=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),I=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(S)}),U=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),E=e.Variant({Deny:e.Null,Allow:e.Null}),J=e.Record({status_code:e.Nat16,location:e.Text}),H=e.Record({iframe:e.Opt(U),updated_at:e.Opt(e.Nat64),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(S),raw_access:e.Opt(E),redirects:e.Opt(e.Vec(e.Tuple(e.Text,J)))}),fe=e.Record({db:e.Opt(I),authentication:e.Opt(w),storage:H}),v=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),te=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),ze=e.Record({clear_existing_assets:e.Opt(e.Bool)}),We=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),he=e.Variant({AssetsUpgrade:ze,SegmentsDeployment:We}),$=e.Record({status:te,updated_at:e.Nat64,sha256:e.Opt(e.Vec(e.Nat8)),executed_at:e.Opt(e.Nat64),owner:e.Principal,created_at:e.Nat64,version:e.Opt(e.Nat64),proposal_type:he}),ne=e.Variant({Heap:e.Null,Stable:e.Null}),q=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),ye=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),ae=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(ne),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:q,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(ye),write:q,max_changes_per_user:e.Opt(e.Nat32)}),Ge=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),certificate_version:e.Opt(e.Nat16)}),ie=e.Record({memory:ne,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),Ye=e.Variant({Callback:e.Record({token:ie,callback:e.Func([],[],["query"])})}),Ae=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(Ye),status_code:e.Nat16}),Te=e.Record({token:e.Opt(ie),body:e.Vec(e.Nat8)}),oe=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),Y=e.Record({batch_id:e.Nat}),Ne=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,_)),items_length:e.Nat64}),Xe=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),Qe=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,v)),items_length:e.Nat64}),Ze=e.Record({desc:e.Bool}),Le=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),Ve=e.Record({order:e.Opt(Ze),paginate:e.Opt(Le)}),er=e.Record({proposal_id:e.Nat}),rr=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(er,$)),items_length:e.Nat64}),tr=e.Record({include_system:e.Bool}),nr=e.Record({matcher:e.Opt(tr)}),ar=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,ae)),items_length:e.Nat64}),ir=e.Record({stable:e.Nat64,heap:e.Nat64}),or=e.Record({version:e.Opt(e.Nat64),internet_identity:e.Opt(V),rules:e.Opt(R)}),sr=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:p,expires_at:e.Opt(e.Nat64)}),cr=e.Record({controller:sr,controllers:e.Vec(e.Principal)}),Pe=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(S)}),ge=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),lr=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(ne),max_size:e.Opt(e.Nat),read:q,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(ye),write:q,max_changes_per_user:e.Opt(e.Nat32)}),ur=e.Record({iframe:e.Opt(U),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),version:e.Opt(e.Nat64),max_memory_size:e.Opt(S),raw_access:e.Opt(E),redirects:e.Opt(e.Vec(e.Tuple(e.Text,J)))}),xe=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Oe=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([r],[],[]),commit_proposal:e.Func([t],[e.Null],[]),commit_proposal_asset_upload:e.Func([r],[],[]),commit_proposal_many_assets_upload:e.Func([e.Vec(r)],[],[]),count_assets:e.Func([e.Text,l],[e.Nat64],["query"]),count_collection_assets:e.Func([e.Text],[e.Nat64],["query"]),count_collection_docs:e.Func([e.Text],[e.Nat64],["query"]),count_docs:e.Func([e.Text,l],[e.Nat64],["query"]),count_proposals:e.Func([],[e.Nat64],["query"]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([u],[e.Vec(e.Tuple(e.Principal,d))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,m],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,l],[],[]),del_filtered_docs:e.Func([e.Text,l],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,m))],[],[]),del_rule:e.Func([f,e.Text,x],[],[]),delete_proposal_assets:e.Func([B],[],[]),deposit_cycles:e.Func([K],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(_)],["query"]),get_auth_config:e.Func([],[e.Opt(w)],["query"]),get_config:e.Func([],[fe],[]),get_db_config:e.Func([],[e.Opt(I)],["query"]),get_doc:e.Func([e.Text,e.Text],[e.Opt(v)],["query"]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(_)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(v)))],["query"]),get_proposal:e.Func([e.Nat],[e.Opt($)],["query"]),get_rule:e.Func([f,e.Text],[e.Opt(ae)],["query"]),get_storage_config:e.Func([],[H],["query"]),http_request:e.Func([Ge],[Ae],["query"]),http_request_streaming_callback:e.Func([ie],[Te],["query"]),init_asset_upload:e.Func([oe],[Y],[]),init_proposal:e.Func([he],[e.Nat,$],[]),init_proposal_asset_upload:e.Func([oe,e.Nat],[Y],[]),init_proposal_many_assets_upload:e.Func([e.Vec(oe),e.Nat],[e.Vec(e.Tuple(e.Text,Y))],[]),list_assets:e.Func([e.Text,l],[Ne],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,d))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Xe))],["query"]),list_docs:e.Func([e.Text,l],[Qe],["query"]),list_proposals:e.Func([Ve],[rr],["query"]),list_rules:e.Func([f,nr],[ar],["query"]),memory_size:e.Func([],[ir],["query"]),reject_proposal:e.Func([t],[e.Null],[]),set_auth_config:e.Func([or],[w],[]),set_controllers:e.Func([cr],[e.Vec(e.Tuple(e.Principal,d))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([Pe],[I],[]),set_doc:e.Func([e.Text,e.Text,ge],[v],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,ge))],[e.Vec(e.Tuple(e.Text,v))],[]),set_rule:e.Func([f,e.Text,lr],[ae],[]),set_storage_config:e.Func([ur],[H],[]),submit_proposal:e.Func([e.Nat],[e.Nat,$],[]),upload_asset_chunk:e.Func([xe],[Oe],[]),upload_proposal_asset_chunk:e.Func([xe],[Oe],[])})},aa=({IDL:e})=>{let r=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),t=e.Record({sha256:e.Vec(e.Nat8),proposal_id:e.Nat}),n=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),a=e.Record({field:n,desc:e.Bool}),i=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),o=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(i),description:e.Opt(e.Text),created_at:e.Opt(i)}),s=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),l=e.Record({order:e.Opt(a),owner:e.Opt(e.Principal),matcher:e.Opt(o),paginate:e.Opt(s)}),u=e.Record({controllers:e.Vec(e.Principal)}),p=e.Variant({Write:e.Null,Admin:e.Null,Submit:e.Null}),d=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:p,expires_at:e.Opt(e.Nat64)}),m=e.Record({version:e.Opt(e.Nat64)}),f=e.Variant({Db:e.Null,Storage:e.Null}),x=e.Record({version:e.Opt(e.Nat64)}),B=e.Record({proposal_ids:e.Vec(e.Nat)}),K=e.Record({cycles:e.Nat,destination_id:e.Principal}),C=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),O=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),_=e.Record({key:C,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,O)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),V=e.Record({derivation_origin:e.Opt(e.Text),external_alternative_origins:e.Opt(e.Vec(e.Text))}),R=e.Record({allowed_callers:e.Vec(e.Principal)}),w=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),internet_identity:e.Opt(V),rules:e.Opt(R)}),S=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),I=e.Record({updated_at:e.Opt(e.Nat64),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(S)}),U=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),E=e.Variant({Deny:e.Null,Allow:e.Null}),J=e.Record({status_code:e.Nat16,location:e.Text}),H=e.Record({iframe:e.Opt(U),updated_at:e.Opt(e.Nat64),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),created_at:e.Opt(e.Nat64),version:e.Opt(e.Nat64),max_memory_size:e.Opt(S),raw_access:e.Opt(E),redirects:e.Opt(e.Vec(e.Tuple(e.Text,J)))}),fe=e.Record({db:e.Opt(I),authentication:e.Opt(w),storage:H}),v=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),te=e.Variant({Initialized:e.Null,Failed:e.Null,Open:e.Null,Rejected:e.Null,Executed:e.Null,Accepted:e.Null}),ze=e.Record({clear_existing_assets:e.Opt(e.Bool)}),We=e.Record({orbiter:e.Opt(e.Text),mission_control_version:e.Opt(e.Text),satellite_version:e.Opt(e.Text)}),he=e.Variant({AssetsUpgrade:ze,SegmentsDeployment:We}),$=e.Record({status:te,updated_at:e.Nat64,sha256:e.Opt(e.Vec(e.Nat8)),executed_at:e.Opt(e.Nat64),owner:e.Principal,created_at:e.Nat64,version:e.Opt(e.Nat64),proposal_type:he}),ne=e.Variant({Heap:e.Null,Stable:e.Null}),q=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),ye=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),ae=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(ne),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:q,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(ye),write:q,max_changes_per_user:e.Opt(e.Nat32)}),Ge=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),certificate_version:e.Opt(e.Nat16)}),ie=e.Record({memory:ne,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),Ye=e.Variant({Callback:e.Record({token:ie,callback:e.Func([],[],[])})}),Ae=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(Ye),status_code:e.Nat16}),Te=e.Record({token:e.Opt(ie),body:e.Vec(e.Nat8)}),oe=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),Y=e.Record({batch_id:e.Nat}),Ne=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,_)),items_length:e.Nat64}),Xe=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),Qe=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,v)),items_length:e.Nat64}),Ze=e.Record({desc:e.Bool}),Le=e.Record({start_after:e.Opt(e.Nat),limit:e.Opt(e.Nat)}),Ve=e.Record({order:e.Opt(Ze),paginate:e.Opt(Le)}),er=e.Record({proposal_id:e.Nat}),rr=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(er,$)),items_length:e.Nat64}),tr=e.Record({include_system:e.Bool}),nr=e.Record({matcher:e.Opt(tr)}),ar=e.Record({matches_length:e.Nat64,items:e.Vec(e.Tuple(e.Text,ae)),items_length:e.Nat64}),ir=e.Record({stable:e.Nat64,heap:e.Nat64}),or=e.Record({version:e.Opt(e.Nat64),internet_identity:e.Opt(V),rules:e.Opt(R)}),sr=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:p,expires_at:e.Opt(e.Nat64)}),cr=e.Record({controller:sr,controllers:e.Vec(e.Principal)}),Pe=e.Record({version:e.Opt(e.Nat64),max_memory_size:e.Opt(S)}),ge=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),lr=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(ne),max_size:e.Opt(e.Nat),read:q,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(ye),write:q,max_changes_per_user:e.Opt(e.Nat32)}),ur=e.Record({iframe:e.Opt(U),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),version:e.Opt(e.Nat64),max_memory_size:e.Opt(S),raw_access:e.Opt(E),redirects:e.Opt(e.Vec(e.Tuple(e.Text,J)))}),xe=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Oe=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([r],[],[]),commit_proposal:e.Func([t],[e.Null],[]),commit_proposal_asset_upload:e.Func([r],[],[]),commit_proposal_many_assets_upload:e.Func([e.Vec(r)],[],[]),count_assets:e.Func([e.Text,l],[e.Nat64],[]),count_collection_assets:e.Func([e.Text],[e.Nat64],[]),count_collection_docs:e.Func([e.Text],[e.Nat64],[]),count_docs:e.Func([e.Text,l],[e.Nat64],[]),count_proposals:e.Func([],[e.Nat64],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([u],[e.Vec(e.Tuple(e.Principal,d))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,m],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,l],[],[]),del_filtered_docs:e.Func([e.Text,l],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,m))],[],[]),del_rule:e.Func([f,e.Text,x],[],[]),delete_proposal_assets:e.Func([B],[],[]),deposit_cycles:e.Func([K],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(_)],[]),get_auth_config:e.Func([],[e.Opt(w)],[]),get_config:e.Func([],[fe],[]),get_db_config:e.Func([],[e.Opt(I)],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(v)],[]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(_)))],[]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(v)))],[]),get_proposal:e.Func([e.Nat],[e.Opt($)],[]),get_rule:e.Func([f,e.Text],[e.Opt(ae)],[]),get_storage_config:e.Func([],[H],[]),http_request:e.Func([Ge],[Ae],[]),http_request_streaming_callback:e.Func([ie],[Te],[]),init_asset_upload:e.Func([oe],[Y],[]),init_proposal:e.Func([he],[e.Nat,$],[]),init_proposal_asset_upload:e.Func([oe,e.Nat],[Y],[]),init_proposal_many_assets_upload:e.Func([e.Vec(oe),e.Nat],[e.Vec(e.Tuple(e.Text,Y))],[]),list_assets:e.Func([e.Text,l],[Ne],[]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,d))],[]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Xe))],[]),list_docs:e.Func([e.Text,l],[Qe],[]),list_proposals:e.Func([Ve],[rr],[]),list_rules:e.Func([f,nr],[ar],[]),memory_size:e.Func([],[ir],[]),reject_proposal:e.Func([t],[e.Null],[]),set_auth_config:e.Func([or],[w],[]),set_controllers:e.Func([cr],[e.Vec(e.Tuple(e.Principal,d))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([Pe],[I],[]),set_doc:e.Func([e.Text,e.Text,ge],[v],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,ge))],[e.Vec(e.Tuple(e.Text,v))],[]),set_rule:e.Func([f,e.Text,lr],[ae],[]),set_storage_config:e.Func([ur],[H],[]),submit_proposal:e.Func([e.Nat],[e.Nat,$],[]),upload_asset_chunk:e.Func([xe],[Oe],[]),upload_proposal_asset_chunk:e.Func([xe],[Oe],[])})};var ia=({satelliteId:e,container:r})=>{let{satelliteId:t}=Dt({satelliteId:e}),{container:n}=jt({container:r});if(T(n)&&n!==!1){let{host:a,protocol:i}=new URL(n===!0?Je:n);return`${i}//${t??"unknown"}.${a.replace("127.0.0.1","localhost")}`}return`https://${t??"unknown"}.icp0.io`},Dt=({satelliteId:e})=>T(e)?{satelliteId:e}:ee.getInstance().get()??{satelliteId:void 0},jt=({container:e})=>T(e)?{container:e}:ee.getInstance().get()??{container:void 0};var F=({satellite:e,options:{certified:r}})=>sa({idlFactory:r?aa:na,actorKey:`stock#${r?"update":"query"}`,...e}),oa=({idlFactory:e,...r})=>sa({idlFactory:e,actorKey:"extended#query",...r}),sa=async({satelliteId:e,container:r,...t})=>{let{satelliteId:n}=Dt({satelliteId:e});fr(n,"No satellite ID defined. Did you initialize Juno?");let{container:a}=jt({container:r});return await $e.getInstance().getActor({satelliteId:n,container:a,...t})};var ca=async({collection:e,key:r,...t})=>{let{get_doc:n}=await F(t),a=A(await n(e,r));if(!h(a))return Fr({doc:a,key:r})},la=async({docs:e,...r})=>{let{get_many_docs:t}=await F(r),n=e.map(({collection:o,key:s})=>[o,s]),a=await t(n),i=[];for(let[o,s]of a){let l=A(s);i.push(T(l)?await Fr({key:o,doc:l}):void 0)}return i},ua=async({collection:e,doc:r,...t})=>{let{set_doc:n}=await F(t),{key:a}=r,i=await It(r),o=await n(e,a,i);return await Fr({key:a,doc:o})},da=async({docs:e,...r})=>{let{set_many_docs:t}=await F(r),n=[];for(let{collection:o,doc:s}of e){let{key:l}=s;n.push([o,l,await It(s)])}let a=await t(n),i=[];for(let[o,s]of a)i.push(await Fr({key:o,doc:s}));return i},pa=async({collection:e,doc:r,...t})=>{let{del_doc:n}=await F(t),{key:a}=r;return n(e,a,qt(r))},_a=async({docs:e,...r})=>{let{del_many_docs:t}=await F(r),n=e.map(({collection:a,doc:i})=>[a,i.key,qt(i)]);await t(n)},ma=async({collection:e,filter:r,...t})=>{let{del_filtered_docs:n}=await F(t);return n(e,me(r))},fa=async({collection:e,filter:r,...t})=>{let{list_docs:n}=await F(t),{items:a,items_page:i,items_length:o,matches_length:s,matches_pages:l}=await n(e,me(r)),u=[];for(let[p,d]of a){let{data:m,owner:f,description:x,version:B,...K}=d;u.push({key:p,description:A(x),owner:f.toText(),data:await ea({data:m}),version:A(B),...K})}return{items:u,items_length:o,items_page:A(i),matches_length:s,matches_pages:A(l)}},ha=async({collection:e,filter:r,...t})=>{let{count_docs:n}=await F(t);return n(e,me(r))};var re={certified:!1};var g=e=>T(e)?e:tt()??new ve;var ya=async({satellite:e,options:r,...t})=>{let n=g(e?.identity);return await ca({...t,satellite:{...e,identity:n},options:r??re})},Ml=async({satellite:e,options:r,...t})=>{let n=g(e?.identity);return await la({...t,satellite:{...e,identity:n},options:r??re})},Ta=async({satellite:e,...r})=>{let t=g(e?.identity);return await ua({...r,satellite:{...e,identity:t},options:{certified:!0}})},Kl=async({satellite:e,...r})=>{let t=g(e?.identity);return await da({...r,satellite:{...e,identity:t},options:{certified:!0}})},Jl=async({satellite:e,...r})=>{let t=g(e?.identity);return await pa({...r,satellite:{...e,identity:t},options:{certified:!0}})},Hl=async({satellite:e,...r})=>{let t=g(e?.identity);return await _a({...r,satellite:{...e,identity:t},options:{certified:!0}})},$l=async({satellite:e,filter:r,...t})=>{let n=g(e?.identity);return await ma({...t,filter:r??{},satellite:{...e,identity:n},options:{certified:!0}})},zl=async({satellite:e,options:r,filter:t,...n})=>{let a=g(e?.identity);return await fa({...n,filter:t??{},satellite:{...e,identity:a},options:r??re})},Wl=async({satellite:e,options:r,filter:t,...n})=>{let a=g(e?.identity);return await ha({...n,filter:t??{},satellite:{...e,identity:a},options:r??re})};var Na=async e=>{let r=tt();if(h(r))throw new Lr("No identity to initialize the user. Have you initialized Juno?");let t=r.getPrincipal().toText(),n=()=>ya({collection:"#user",key:t}),a=await n();if(T(a))return a;try{return await mo({userId:t,provider:e})}catch(i){if(Bt({error:i,type:Ln})){let o=await n();if(T(o))return o}throw i}},mo=({userId:e,...r})=>Ta({collection:"#user",doc:{key:e,data:r}});var M,Mt=async e=>{if(M=M??await rt(),!(await M?.isAuthenticated()??!1))return;let t=await Na(e);Z.getInstance().set(t)},fo=e=>new Promise(async(r,t)=>{if(h(M)){t(new Qr("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let n=e?.provider??new Yr({});await M.login({onSuccess:async()=>{await Mt(n.id),r()},onError:a=>{if(a===Ct){t(new Zr(a));return}t(new Xr(a))},maxTimeToLive:e?.maxTimeToLive??Hn,allowPinAuthentication:e?.allowPin??$n,...e?.derivationOrigin!==void 0&&{derivationOrigin:e.derivationOrigin},...n.signInOptions({windowed:e?.windowed})})}),Kt=async()=>{await ho(),M=await rt()},ho=async()=>{await M?.logout(),M=null,Z.getInstance().reset(),$e.getInstance().reset(),He.getInstance().reset()},tt=()=>M?.getIdentity(),yo=async()=>(M??await rt()).getIdentity(),To=async()=>{let e=Z.getInstance().get();return h(e)||!(await M?.isAuthenticated()??!1)?null:M?.getIdentity()??null};var ga=e=>{let r=e===!0?"./workers/auth.worker.js":e,t=new Worker(r),n=async()=>{Rt({message:"junoSignOutAuthTimer"}),await Kt()};return t.onmessage=async({data:a})=>{let{msg:i,data:o}=a;switch(i){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":Rt({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},Z.getInstance().subscribe(a=>{if(h(a)){t.postMessage({msg:"junoStopAuthTimer"});return}t.postMessage({msg:"junoStartAuthTimer"})})};var xa=()=>{let e=()=>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??e():e()},Oa=()=>{let e=()=>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??e():e()};var gu=async({idlFactory:e,satellite:r})=>{let t=g(r?.identity);return await oa({idlFactory:e,...r,identity:t})};var Ra=async({asset:{data:e,headers:r,...t},actor:n,progress:a})=>{let{init_asset_upload:i,upload_asset_chunk:o,commit_asset_upload:s}=n,{batch_id:l}=await i(No(t));a?.onInitiatedBatch();let{chunkIds:u}=await Oo({data:e,uploadFn:o,batchId:l});a?.onUploadedFileChunks(t.fullPath),await xo({commitFn:s,batchId:l,data:e,headers:r,chunkIds:u}),a?.onCommittedBatch()};var No=({filename:e,collection:r,token:t,fullPath:n,encoding:a,description:i})=>({collection:r,full_path:n,name:e,token:N(t),encoding_type:N(a),description:N(i)}),go=({batchId:e,chunkIds:r,headers:t,data:n})=>{let a=t.find(([i,o])=>i.toLowerCase()==="content-type")===void 0&&n.type!==void 0&&n.type!==""?[["Content-Type",n.type]]:void 0;return{batch_id:e,chunk_ids:r.map(({chunk_id:i})=>i),headers:[...t,...a??[]]}},xo=async({commitFn:e,...r})=>{let t=go(r);await e(t)},Oo=async({data:e,uploadFn:r,batchId:t})=>{let n=[],a=Gr()?new Blob([await e.arrayBuffer()]):e,i=0n;for(let s=0;s<a.size;s+=19e5){let l=a.slice(s,s+19e5);n.push({batchId:t,chunk:l,uploadFn:r,orderId:i}),i++}let o=[];for await(let s of Ro({uploadChunks:n}))o=[...o,...s];return{chunkIds:o}};async function*Ro({uploadChunks:e,limit:r=12}){for(let t=0;t<e.length;t=t+r){let n=e.slice(t,t+r);yield await Promise.all(n.map(a=>wo(a)))}}var wo=async({batchId:e,chunk:r,uploadFn:t,orderId:n})=>t({batch_id:e,content:new Uint8Array(await r.arrayBuffer()),order_id:N(n)});var wa=async({asset:e,...r})=>{let t=await F(r);await Ra({actor:t,asset:e})},Fa=async({collection:e,filter:r,...t})=>{let{list_assets:n}=await F(t),{items:a,items_length:i,items_page:o,matches_length:s,matches_pages:l}=await n(e,me(r));return{items:a.map(([u,p])=>p),items_length:i,items_page:A(o),matches_length:s,matches_pages:A(l)}},Ea=async({collection:e,filter:r,...t})=>{let{count_assets:n}=await F(t);return n(e,me(r))},ba=async({collection:e,fullPath:r,...t})=>(await F(t)).del_asset(e,r),Aa=async({assets:e,satellite:r})=>{let{del_many_assets:t}=await F({satellite:r,options:{certified:!0}}),n=e.map(({collection:a,fullPath:i})=>[a,i]);await t(n)},Va=async({collection:e,filter:r,...t})=>{let{del_filtered_assets:n}=await F(t);return n(e,me(r))},Pa=async({collection:e,fullPath:r,...t})=>{let{get_asset:n}=await F(t);return A(await n(e,r))},va=async({assets:e,...r})=>{let{get_many_assets:t}=await F(r),n=e.map(({collection:i,fullPath:o})=>[i,o]);return(await t(n)).map(([i,o])=>A(o))};var Sa=e=>btoa([...e].map(r=>String.fromCharCode(r)).join(""));var Iu=e=>ka(e),qu=e=>ka({filename:e.data.name,...e}),ka=async({filename:e,data:r,collection:t,headers:n=[],fullPath:a,token:i,satellite:o,encoding:s,description:l})=>{let u=g(o?.identity),p=decodeURI(e),d=a??`/${t}/${p}`,m={...o,identity:u};return await wa({asset:{data:r,filename:p,collection:t,token:i,headers:n,fullPath:d,encoding:s,description:l},satellite:m,options:{certified:!0}}),{downloadUrl:Ca({satellite:m,assetKey:{fullPath:d,token:i}}),fullPath:d,name:p}},Du=async({collection:e,filter:r,satellite:t,options:n})=>{let a={...t,identity:g(t?.identity)},{items:i,...o}=await Fa({collection:e,filter:r??{},satellite:a,options:n??re}),s=i.map(({key:{full_path:l,token:u,name:p,owner:d,description:m},headers:f,encodings:x,created_at:B,updated_at:K})=>{let C=A(u);return{fullPath:l,description:A(m),name:p,downloadUrl:Ca({satellite:a,assetKey:{fullPath:l,token:C}}),token:C,headers:f,encodings:x.reduce((O,[_,{modified:V,sha256:R,total_length:w}])=>({...O,[_]:{modified:V,sha256:Sa(R),total_length:w}}),{}),owner:d.toText(),created_at:B,updated_at:K}});return{items:s,assets:s,...o}},ju=async({collection:e,filter:r,satellite:t,options:n})=>{let a={...t,identity:g(t?.identity)};return await Ea({collection:e,satellite:a,filter:r??{},options:n??re})},Mu=({collection:e,fullPath:r,satellite:t})=>ba({collection:e,fullPath:r,satellite:{...t,identity:g(t?.identity)},options:{certified:!0}}),Ku=({assets:e,satellite:r})=>Aa({assets:e,satellite:{...r,identity:g(r?.identity)},options:{certified:!0}}),Ju=async({collection:e,satellite:r,filter:t})=>{let n={...r,identity:g(r?.identity)};return await Va({collection:e,satellite:n,filter:t??{},options:{certified:!0}})},Hu=async({satellite:e,options:r,...t})=>{let n=g(e?.identity);return await Pa({...t,satellite:{...e,identity:n},options:r??re})},$u=async({satellite:e,options:r,...t})=>{let n=g(e?.identity);return await va({...t,satellite:{...e,identity:n},options:r??re})},Ca=({assetKey:{fullPath:e,token:r},satellite:t})=>{let n={...t,identity:g(t?.identity)};return`${ia(n)}${e}${T(r)?`?token=${r}`:""}`};var Fo=e=>{let r=e?.satelliteId??xa();fr(r,"Satellite ID is not configured. Juno cannot be initialized.");let t=e?.container??Oa();return{satelliteId:r,internetIdentityId:e?.internetIdentityId,workers:e?.workers,container:t}},Lu=e=>Eo(e),Eo=async e=>{let r=Fo(e);ee.getInstance().set(r),await Mt();let t=r.workers?.auth!==void 0?ga(r.workers.auth):void 0;return[...t?[t]:[]]},ed=e=>Z.getInstance().subscribe(e);export{Lr as InitError,Yr as InternetIdentityProvider,et as ListError,Qn as NFIDProvider,Xr as SignInError,Qr as SignInInitError,Zr as SignInUserInterruptError,ed as authSubscribe,ju as countAssets,Wl as countDocs,Mu as deleteAsset,Jl as deleteDoc,Ju as deleteFilteredAssets,$l as deleteFilteredDocs,Ku as deleteManyAssets,Hl as deleteManyDocs,Ca as downloadUrl,Hu as getAsset,ya as getDoc,To as getIdentityOnce,$u as getManyAssets,Ml as getManyDocs,gu as getSatelliteExtendedActor,Lu as initJuno,Eo as initSatellite,Du as listAssets,zl as listDocs,Ta as setDoc,Kl as setManyDocs,fo as signIn,Kt as signOut,yo as unsafeIdentity,Iu as uploadBlob,qu as uploadFile};
16
16
  /*! Bundled license information:
17
17
 
18
18
  buffer/index.js: