@junobuild/core-standalone 1.2.0 → 1.2.1-next-2025-08-27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +6 -6
- package/dist/browser/index.js.map +4 -4
- package/dist/node/index.mjs +25 -25
- package/dist/node/index.mjs.map +4 -4
- package/package.json +3 -3
package/dist/browser/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
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 Yn,c as at,d as Xn,e as Ht,f as h,g as P,h as le,i as zt,j as $t,k as Wt,l as br,m as nt,n as dr,o as Qn,p as it,q as Re,r as ve,s as Zn,t as Ar,u as $,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=[],Ln=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 a=t===r?0:4-t%4;return[t,a]}function ei(e){var r=Yt(e),t=r[0],a=r[1];return(t+a)*3/4-a}function ri(e,r,t){return(r+t)*3/4-t}function ti(e){var r,t=Yt(e),a=t[0],n=t[1],i=new Ln(ri(e,a,n)),o=0,s=n>0?a-4:a,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 n===2&&(r=D[e.charCodeAt(l)]<<2|D[e.charCodeAt(l+1)]>>4,i[o++]=r&255),n===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 ai(e){return X[e>>18&63]+X[e>>12&63]+X[e>>6&63]+X[e&63]}function ni(e,r,t){for(var a,n=[],i=r;i<t;i+=3)a=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(e[i+2]&255),n.push(ai(a));return n.join("")}function ii(e){for(var r,t=e.length,a=t%3,n=[],i=16383,o=0,s=t-a;o<s;o+=i)n.push(ni(e,o,o+i>s?s:o+i));return a===1?(r=e[t-1],n.push(X[r>>2]+X[r<<4&63]+"==")):a===2&&(r=(e[t-2]<<8)+e[t-1],n.push(X[r>>10]+X[r>>4&63]+X[r<<2&63]+"=")),n.join("")}});var _a=Jt(Be=>{"use strict";var lt=Xt(),Ce=Xn(),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 ra(e,r,t)}c.poolSize=8192;function ra(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 a=e.valueOf&&e.valueOf();if(a!=null&&a!==e)return c.from(a,r,t);let n=ui(e);if(n)return n;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 ra(e,r,t)};Object.setPrototypeOf(c.prototype,Uint8Array.prototype);Object.setPrototypeOf(c,Uint8Array);function ta(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 ta(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 ta(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=aa(e,r)|0,a=se(t),n=a.write(e,r);return n!==t&&(a=a.slice(0,n)),a}function ut(e){let r=e.length<0?0:mt(e.length)|0,t=se(r);for(let a=0;a<r;a+=1)t[a]=e[a]&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 a;return r===void 0&&t===void 0?a=new Uint8Array(e):t===void 0?a=new Uint8Array(e,r):a=new Uint8Array(e,r,t),Object.setPrototypeOf(a,c.prototype),a}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"||yt(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 a=r.length,n=t.length;for(let i=0,o=Math.min(a,n);i<o;++i)if(r[i]!==t[i]){a=r[i],n=t[i];break}return a<n?-1:n<a?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 a;if(t===void 0)for(t=0,a=0;a<r.length;++a)t+=r[a].length;let n=c.allocUnsafe(t),i=0;for(a=0;a<r.length;++a){let o=r[a];if(Q(o,Uint8Array))i+o.length>n.length?(c.isBuffer(o)||(o=c.from(o)),o.copy(n,i)):Uint8Array.prototype.set.call(n,o,i);else if(c.isBuffer(o))o.copy(n,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=o.length}return n};function aa(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,a=arguments.length>2&&arguments[2]===!0;if(!a&&t===0)return 0;let n=!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 pa(e).length;default:if(n)return a?-1:pt(e).length;r=(""+r).toLowerCase(),n=!0}}c.byteLength=aa;function pi(e,r,t){let a=!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 ia(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(a)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),a=!0}}c.prototype._isBuffer=!0;function Fe(e,r,t){let a=e[r];e[r]=e[t],e[t]=a}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?ia(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,a,n,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),a===void 0&&(a=r?r.length:0),n===void 0&&(n=0),i===void 0&&(i=this.length),t<0||a>r.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=a)return 0;if(n>=i)return-1;if(t>=a)return 1;if(t>>>=0,a>>>=0,n>>>=0,i>>>=0,this===r)return 0;let o=i-n,s=a-t,l=Math.min(o,s),u=this.slice(n,i),p=r.slice(t,a);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 na(e,r,t,a,n){if(e.length===0)return-1;if(typeof t=="string"?(a=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,yt(t)&&(t=n?0:e.length-1),t<0&&(t=e.length+t),t>=e.length){if(n)return-1;t=e.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof r=="string"&&(r=c.from(r,a)),c.isBuffer(r))return r.length===0?-1:Zt(e,r,t,a,n);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(e,r,t):Uint8Array.prototype.lastIndexOf.call(e,r,t):Zt(e,[r],t,a,n);throw new TypeError("val must be string, number or Buffer")}function Zt(e,r,t,a,n){let i=1,o=e.length,s=r.length;if(a!==void 0&&(a=String(a).toLowerCase(),a==="ucs2"||a==="ucs-2"||a==="utf16le"||a==="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(n){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,a){return this.indexOf(r,t,a)!==-1};c.prototype.indexOf=function(r,t,a){return na(this,r,t,a,!0)};c.prototype.lastIndexOf=function(r,t,a){return na(this,r,t,a,!1)};function _i(e,r,t,a){t=Number(t)||0;let n=e.length-t;a?(a=Number(a),a>n&&(a=n)):a=n;let i=r.length;a>i/2&&(a=i/2);let o;for(o=0;o<a;++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,a){return kr(pt(r,e.length-t),e,t,a)}function fi(e,r,t,a){return kr(bi(r),e,t,a)}function yi(e,r,t,a){return kr(pa(r),e,t,a)}function hi(e,r,t,a){return kr(Ai(r,e.length-t),e,t,a)}c.prototype.write=function(r,t,a,n){if(t===void 0)n="utf8",a=this.length,t=0;else if(a===void 0&&typeof t=="string")n=t,a=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(a)?(a=a>>>0,n===void 0&&(n="utf8")):(n=a,a=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let i=this.length-t;if((a===void 0||a>i)&&(a=i),r.length>0&&(a<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return _i(this,r,t,a);case"utf8":case"utf-8":return mi(this,r,t,a);case"ascii":case"latin1":case"binary":return fi(this,r,t,a);case"base64":return yi(this,r,t,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return hi(this,r,t,a);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).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 ia(e,r,t){t=Math.min(e.length,t);let a=[],n=r;for(;n<t;){let i=e[n],o=null,s=i>239?4:i>223?3:i>191?2:1;if(n+s<=t){let l,u,p,d;switch(s){case 1:i<128&&(o=i);break;case 2:l=e[n+1],(l&192)===128&&(d=(i&31)<<6|l&63,d>127&&(o=d));break;case 3:l=e[n+1],u=e[n+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[n+1],u=e[n+2],p=e[n+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,a.push(o>>>10&1023|55296),o=56320|o&1023),a.push(o),n+=s}return Ni(a)}var Lt=4096;function Ni(e){let r=e.length;if(r<=Lt)return String.fromCharCode.apply(String,e);let t="",a=0;for(;a<r;)t+=String.fromCharCode.apply(String,e.slice(a,a+=Lt));return t}function gi(e,r,t){let a="";t=Math.min(e.length,t);for(let n=r;n<t;++n)a+=String.fromCharCode(e[n]&127);return a}function xi(e,r,t){let a="";t=Math.min(e.length,t);for(let n=r;n<t;++n)a+=String.fromCharCode(e[n]);return a}function Oi(e,r,t){let a=e.length;(!r||r<0)&&(r=0),(!t||t<0||t>a)&&(t=a);let n="";for(let i=r;i<t;++i)n+=Vi[e[i]];return n}function Ri(e,r,t){let a=e.slice(r,t),n="";for(let i=0;i<a.length-1;i+=2)n+=String.fromCharCode(a[i]+a[i+1]*256);return n}c.prototype.slice=function(r,t){let a=this.length;r=~~r,t=t===void 0?a:~~t,r<0?(r+=a,r<0&&(r=0)):r>a&&(r=a),t<0?(t+=a,t<0&&(t=0)):t>a&&(t=a),t<r&&(t=r);let n=this.subarray(r,t);return Object.setPrototypeOf(n,c.prototype),n};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,a){r=r>>>0,t=t>>>0,a||b(r,t,this.length);let n=this[r],i=1,o=0;for(;++o<t&&(i*=256);)n+=this[r+o]*i;return n};c.prototype.readUintBE=c.prototype.readUIntBE=function(r,t,a){r=r>>>0,t=t>>>0,a||b(r,t,this.length);let n=this[r+--t],i=1;for(;t>0&&(i*=256);)n+=this[r+--t]*i;return n};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],a=this[r+7];(t===void 0||a===void 0)&&_r(r,this.length-8);let n=t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,i=this[++r]+this[++r]*2**8+this[++r]*2**16+a*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))});c.prototype.readBigUInt64BE=de(function(r){r=r>>>0,Ue(r,"offset");let t=this[r],a=this[r+7];(t===void 0||a===void 0)&&_r(r,this.length-8);let n=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+a;return(BigInt(n)<<BigInt(32))+BigInt(i)});c.prototype.readIntLE=function(r,t,a){r=r>>>0,t=t>>>0,a||b(r,t,this.length);let n=this[r],i=1,o=0;for(;++o<t&&(i*=256);)n+=this[r+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*t)),n};c.prototype.readIntBE=function(r,t,a){r=r>>>0,t=t>>>0,a||b(r,t,this.length);let n=t,i=1,o=this[r+--n];for(;n>0&&(i*=256);)o+=this[r+--n]*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 a=this[r]|this[r+1]<<8;return a&32768?a|4294901760:a};c.prototype.readInt16BE=function(r,t){r=r>>>0,t||b(r,2,this.length);let a=this[r+1]|this[r]<<8;return a&32768?a|4294901760:a};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],a=this[r+7];(t===void 0||a===void 0)&&_r(r,this.length-8);let n=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(a<<24);return(BigInt(n)<<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],a=this[r+7];(t===void 0||a===void 0)&&_r(r,this.length-8);let n=(t<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(n)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+a)});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,a,n,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>n||r<i)throw new RangeError('"value" argument is out of bounds');if(t+a>e.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(r,t,a,n){if(r=+r,t=t>>>0,a=a>>>0,!n){let s=Math.pow(2,8*a)-1;k(this,r,t,a,s,0)}let i=1,o=0;for(this[t]=r&255;++o<a&&(i*=256);)this[t+o]=r/i&255;return t+a};c.prototype.writeUintBE=c.prototype.writeUIntBE=function(r,t,a,n){if(r=+r,t=t>>>0,a=a>>>0,!n){let s=Math.pow(2,8*a)-1;k(this,r,t,a,s,0)}let i=a-1,o=1;for(this[t+i]=r&255;--i>=0&&(o*=256);)this[t+i]=r/o&255;return t+a};c.prototype.writeUint8=c.prototype.writeUInt8=function(r,t,a){return r=+r,t=t>>>0,a||k(this,r,t,1,255,0),this[t]=r&255,t+1};c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(r,t,a){return r=+r,t=t>>>0,a||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,a){return r=+r,t=t>>>0,a||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,a){return r=+r,t=t>>>0,a||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,a){return r=+r,t=t>>>0,a||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 oa(e,r,t,a,n){da(r,a,n,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 sa(e,r,t,a,n){da(r,a,n,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 oa(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeBigUInt64BE=de(function(r,t=0){return sa(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeIntLE=function(r,t,a,n){if(r=+r,t=t>>>0,!n){let l=Math.pow(2,8*a-1);k(this,r,t,a,l-1,-l)}let i=0,o=1,s=0;for(this[t]=r&255;++i<a&&(o*=256);)r<0&&s===0&&this[t+i-1]!==0&&(s=1),this[t+i]=(r/o>>0)-s&255;return t+a};c.prototype.writeIntBE=function(r,t,a,n){if(r=+r,t=t>>>0,!n){let l=Math.pow(2,8*a-1);k(this,r,t,a,l-1,-l)}let i=a-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+a};c.prototype.writeInt8=function(r,t,a){return r=+r,t=t>>>0,a||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,a){return r=+r,t=t>>>0,a||k(this,r,t,2,32767,-32768),this[t]=r&255,this[t+1]=r>>>8,t+2};c.prototype.writeInt16BE=function(r,t,a){return r=+r,t=t>>>0,a||k(this,r,t,2,32767,-32768),this[t]=r>>>8,this[t+1]=r&255,t+2};c.prototype.writeInt32LE=function(r,t,a){return r=+r,t=t>>>0,a||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,a){return r=+r,t=t>>>0,a||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 oa(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});c.prototype.writeBigInt64BE=de(function(r,t=0){return sa(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ca(e,r,t,a,n,i){if(t+a>e.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function la(e,r,t,a,n){return r=+r,t=t>>>0,n||ca(e,r,t,4,34028234663852886e22,-34028234663852886e22),Ce.write(e,r,t,a,23,4),t+4}c.prototype.writeFloatLE=function(r,t,a){return la(this,r,t,!0,a)};c.prototype.writeFloatBE=function(r,t,a){return la(this,r,t,!1,a)};function ua(e,r,t,a,n){return r=+r,t=t>>>0,n||ca(e,r,t,8,17976931348623157e292,-17976931348623157e292),Ce.write(e,r,t,a,52,8),t+8}c.prototype.writeDoubleLE=function(r,t,a){return ua(this,r,t,!0,a)};c.prototype.writeDoubleBE=function(r,t,a){return ua(this,r,t,!1,a)};c.prototype.copy=function(r,t,a,n){if(!c.isBuffer(r))throw new TypeError("argument should be a Buffer");if(a||(a=0),!n&&n!==0&&(n=this.length),t>=r.length&&(t=r.length),t||(t=0),n>0&&n<a&&(n=a),n===a||r.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(a<0||a>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),r.length-t<n-a&&(n=r.length-t+a);let i=n-a;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,a,n):Uint8Array.prototype.set.call(r,this.subarray(a,n),t),i};c.prototype.fill=function(r,t,a,n){if(typeof r=="string"){if(typeof t=="string"?(n=t,t=0,a=this.length):typeof a=="string"&&(n=a,a=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(r.length===1){let o=r.charCodeAt(0);(n==="utf8"&&o<128||n==="latin1")&&(r=o)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(t<0||this.length<t||this.length<a)throw new RangeError("Out of range index");if(a<=t)return this;t=t>>>0,a=a===void 0?this.length:a>>>0,r||(r=0);let i;if(typeof r=="number")for(i=t;i<a;++i)this[i]=r;else{let o=c.isBuffer(r)?r:c.from(r,n),s=o.length;if(s===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(i=0;i<a-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(n){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:n,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 a=`The value of "${e}" is out of range.`,n=t;return Number.isInteger(t)&&Math.abs(t)>2**32?n=ea(String(t)):typeof t=="bigint"&&(n=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(n=ea(n)),n+="n"),a+=` It must be ${r}. Received ${n}`,a},RangeError);function ea(e){let r="",t=e.length,a=e[0]==="-"?1:0;for(;t>=a+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 da(e,r,t,a,n,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(a,n,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,a=e.length,n=null,i=[];for(let o=0;o<a;++o){if(t=e.charCodeAt(o),t>55295&&t<57344){if(!n){if(t>56319){(r-=3)>-1&&i.push(239,191,189);continue}else if(o+1===a){(r-=3)>-1&&i.push(239,191,189);continue}n=t;continue}if(t<56320){(r-=3)>-1&&i.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(r-=3)>-1&&i.push(239,191,189);if(n=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,a,n,i=[];for(let o=0;o<e.length&&!((r-=2)<0);++o)t=e.charCodeAt(o),a=t>>8,n=t%256,i.push(n),i.push(a);return i}function pa(e){return lt.toByteArray(Ei(e))}function kr(e,r,t,a){let n;for(n=0;n<a&&!(n+t>=r.length||n>=e.length);++n)r[n+t]=e[n];return n}function Q(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 a=t*16;for(let n=0;n<16;++n)r[a+n]=e[t]+e[n]}return r}();function de(e){return typeof BigInt>"u"?Pi:e}function Pi(){throw new Error("BigInt not supported")}});var xa=at(_a());var Ur={};Yn(Ur,{backoff:()=>ha,chain:()=>Ta,conditionalDelay:()=>fa,defaultStrategy:()=>Cr,maxAttempts:()=>Si,once:()=>ma,throttle:()=>ki,timeout:()=>ya});var vi=300*1e3;function Cr(){return Ta(fa(ma(),1e3),ha(1e3,1.2),ya(vi))}function ma(){let e=!0;return async()=>e?(e=!1,!0):!1}function fa(e,r){return async(t,a,n)=>{if(await e(t,a,n))return new Promise(i=>setTimeout(i,r))}}function Si(e){let r=e;return async(t,a,n)=>{if(--r<=0)throw new Error(`Failed to retrieve a reply for request after ${e} attempts:
|
|
1
|
+
import{A as Ar,B as Vr,C as it,D as ue,E as pr,F as ot,a as Mt,b as Wn,c as tt,d as Gn,e as Jt,f as T,g as P,h as le,i as Ht,j as $t,k as zt,l as Er,m as at,n as dr,o as Yn,p as nt,q as Re,r as ve,s as Xn,t as br,u as z,z as Se}from"./chunk-EMF4NSTU.js";var Yt=Mt(Pr=>{"use strict";Pr.byteLength=Qn;Pr.toByteArray=ei;Pr.fromByteArray=ai;var X=[],D=[],Zn=typeof Uint8Array<"u"?Uint8Array:Array,st="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(we=0,Wt=st.length;we<Wt;++we)X[we]=st[we],D[st.charCodeAt(we)]=we;var we,Wt;D[45]=62;D[95]=63;function Gt(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 a=t===r?0:4-t%4;return[t,a]}function Qn(e){var r=Gt(e),t=r[0],a=r[1];return(t+a)*3/4-a}function Ln(e,r,t){return(r+t)*3/4-t}function ei(e){var r,t=Gt(e),a=t[0],n=t[1],i=new Zn(Ln(e,a,n)),o=0,s=n>0?a-4:a,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 n===2&&(r=D[e.charCodeAt(l)]<<2|D[e.charCodeAt(l+1)]>>4,i[o++]=r&255),n===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 ri(e){return X[e>>18&63]+X[e>>12&63]+X[e>>6&63]+X[e&63]}function ti(e,r,t){for(var a,n=[],i=r;i<t;i+=3)a=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(e[i+2]&255),n.push(ri(a));return n.join("")}function ai(e){for(var r,t=e.length,a=t%3,n=[],i=16383,o=0,s=t-a;o<s;o+=i)n.push(ti(e,o,o+i>s?s:o+i));return a===1?(r=e[t-1],n.push(X[r>>2]+X[r<<4&63]+"==")):a===2&&(r=(e[t-2]<<8)+e[t-1],n.push(X[r>>10]+X[r>>4&63]+X[r<<2&63]+"=")),n.join("")}});var pa=Mt(Be=>{"use strict";var ct=Yt(),Ce=Gn(),Xt=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Be.Buffer=c;Be.SlowBuffer=li;Be.INSPECT_MAX_BYTES=50;var vr=2147483647;Be.kMaxLength=vr;c.TYPED_ARRAY_SUPPORT=ni();!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 ni(){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>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 pt(e)}return ea(e,r,t)}c.poolSize=8192;function ea(e,r,t){if(typeof e=="string")return oi(e,r);if(ArrayBuffer.isView(e))return si(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(Z(e,ArrayBuffer)||e&&Z(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Z(e,SharedArrayBuffer)||e&&Z(e.buffer,SharedArrayBuffer)))return ut(e,r,t);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let a=e.valueOf&&e.valueOf();if(a!=null&&a!==e)return c.from(a,r,t);let n=ci(e);if(n)return n;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 ea(e,r,t)};Object.setPrototypeOf(c.prototype,Uint8Array.prototype);Object.setPrototypeOf(c,Uint8Array);function ra(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 ii(e,r,t){return ra(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 ii(e,r,t)};function pt(e){return ra(e),se(e<0?0:_t(e)|0)}c.allocUnsafe=function(e){return pt(e)};c.allocUnsafeSlow=function(e){return pt(e)};function oi(e,r){if((typeof r!="string"||r==="")&&(r="utf8"),!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let t=ta(e,r)|0,a=se(t),n=a.write(e,r);return n!==t&&(a=a.slice(0,n)),a}function lt(e){let r=e.length<0?0:_t(e.length)|0,t=se(r);for(let a=0;a<r;a+=1)t[a]=e[a]&255;return t}function si(e){if(Z(e,Uint8Array)){let r=new Uint8Array(e);return ut(r.buffer,r.byteOffset,r.byteLength)}return lt(e)}function ut(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 a;return r===void 0&&t===void 0?a=new Uint8Array(e):t===void 0?a=new Uint8Array(e,r):a=new Uint8Array(e,r,t),Object.setPrototypeOf(a,c.prototype),a}function ci(e){if(c.isBuffer(e)){let r=_t(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"||yt(e.length)?se(0):lt(e);if(e.type==="Buffer"&&Array.isArray(e.data))return lt(e.data)}function _t(e){if(e>=vr)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+vr.toString(16)+" bytes");return e|0}function li(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(Z(r,Uint8Array)&&(r=c.from(r,r.offset,r.byteLength)),Z(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 a=r.length,n=t.length;for(let i=0,o=Math.min(a,n);i<o;++i)if(r[i]!==t[i]){a=r[i],n=t[i];break}return a<n?-1:n<a?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 a;if(t===void 0)for(t=0,a=0;a<r.length;++a)t+=r[a].length;let n=c.allocUnsafe(t),i=0;for(a=0;a<r.length;++a){let o=r[a];if(Z(o,Uint8Array))i+o.length>n.length?(c.isBuffer(o)||(o=c.from(o)),o.copy(n,i)):Uint8Array.prototype.set.call(n,o,i);else if(c.isBuffer(o))o.copy(n,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=o.length}return n};function ta(e,r){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Z(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,a=arguments.length>2&&arguments[2]===!0;if(!a&&t===0)return 0;let n=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return dt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return da(e).length;default:if(n)return a?-1:dt(e).length;r=(""+r).toLowerCase(),n=!0}}c.byteLength=ta;function ui(e,r,t){let a=!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 gi(this,r,t);case"utf8":case"utf-8":return na(this,r,t);case"ascii":return Ti(this,r,t);case"latin1":case"binary":return Ni(this,r,t);case"base64":return fi(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xi(this,r,t);default:if(a)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),a=!0}}c.prototype._isBuffer=!0;function Fe(e,r,t){let a=e[r];e[r]=e[t],e[t]=a}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?na(this,0,r):ui.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+">"};Xt&&(c.prototype[Xt]=c.prototype.inspect);c.prototype.compare=function(r,t,a,n,i){if(Z(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),a===void 0&&(a=r?r.length:0),n===void 0&&(n=0),i===void 0&&(i=this.length),t<0||a>r.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=a)return 0;if(n>=i)return-1;if(t>=a)return 1;if(t>>>=0,a>>>=0,n>>>=0,i>>>=0,this===r)return 0;let o=i-n,s=a-t,l=Math.min(o,s),u=this.slice(n,i),p=r.slice(t,a);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 aa(e,r,t,a,n){if(e.length===0)return-1;if(typeof t=="string"?(a=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,yt(t)&&(t=n?0:e.length-1),t<0&&(t=e.length+t),t>=e.length){if(n)return-1;t=e.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof r=="string"&&(r=c.from(r,a)),c.isBuffer(r))return r.length===0?-1:Zt(e,r,t,a,n);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(e,r,t):Uint8Array.prototype.lastIndexOf.call(e,r,t):Zt(e,[r],t,a,n);throw new TypeError("val must be string, number or Buffer")}function Zt(e,r,t,a,n){let i=1,o=e.length,s=r.length;if(a!==void 0&&(a=String(a).toLowerCase(),a==="ucs2"||a==="ucs-2"||a==="utf16le"||a==="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(n){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,a){return this.indexOf(r,t,a)!==-1};c.prototype.indexOf=function(r,t,a){return aa(this,r,t,a,!0)};c.prototype.lastIndexOf=function(r,t,a){return aa(this,r,t,a,!1)};function di(e,r,t,a){t=Number(t)||0;let n=e.length-t;a?(a=Number(a),a>n&&(a=n)):a=n;let i=r.length;a>i/2&&(a=i/2);let o;for(o=0;o<a;++o){let s=parseInt(r.substr(o*2,2),16);if(yt(s))return o;e[t+o]=s}return o}function pi(e,r,t,a){return Sr(dt(r,e.length-t),e,t,a)}function _i(e,r,t,a){return Sr(Fi(r),e,t,a)}function mi(e,r,t,a){return Sr(da(r),e,t,a)}function yi(e,r,t,a){return Sr(Ei(r,e.length-t),e,t,a)}c.prototype.write=function(r,t,a,n){if(t===void 0)n="utf8",a=this.length,t=0;else if(a===void 0&&typeof t=="string")n=t,a=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(a)?(a=a>>>0,n===void 0&&(n="utf8")):(n=a,a=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let i=this.length-t;if((a===void 0||a>i)&&(a=i),r.length>0&&(a<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return di(this,r,t,a);case"utf8":case"utf-8":return pi(this,r,t,a);case"ascii":case"latin1":case"binary":return _i(this,r,t,a);case"base64":return mi(this,r,t,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return yi(this,r,t,a);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}};c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function fi(e,r,t){return r===0&&t===e.length?ct.fromByteArray(e):ct.fromByteArray(e.slice(r,t))}function na(e,r,t){t=Math.min(e.length,t);let a=[],n=r;for(;n<t;){let i=e[n],o=null,s=i>239?4:i>223?3:i>191?2:1;if(n+s<=t){let l,u,p,d;switch(s){case 1:i<128&&(o=i);break;case 2:l=e[n+1],(l&192)===128&&(d=(i&31)<<6|l&63,d>127&&(o=d));break;case 3:l=e[n+1],u=e[n+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[n+1],u=e[n+2],p=e[n+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,a.push(o>>>10&1023|55296),o=56320|o&1023),a.push(o),n+=s}return hi(a)}var Qt=4096;function hi(e){let r=e.length;if(r<=Qt)return String.fromCharCode.apply(String,e);let t="",a=0;for(;a<r;)t+=String.fromCharCode.apply(String,e.slice(a,a+=Qt));return t}function Ti(e,r,t){let a="";t=Math.min(e.length,t);for(let n=r;n<t;++n)a+=String.fromCharCode(e[n]&127);return a}function Ni(e,r,t){let a="";t=Math.min(e.length,t);for(let n=r;n<t;++n)a+=String.fromCharCode(e[n]);return a}function gi(e,r,t){let a=e.length;(!r||r<0)&&(r=0),(!t||t<0||t>a)&&(t=a);let n="";for(let i=r;i<t;++i)n+=bi[e[i]];return n}function xi(e,r,t){let a=e.slice(r,t),n="";for(let i=0;i<a.length-1;i+=2)n+=String.fromCharCode(a[i]+a[i+1]*256);return n}c.prototype.slice=function(r,t){let a=this.length;r=~~r,t=t===void 0?a:~~t,r<0?(r+=a,r<0&&(r=0)):r>a&&(r=a),t<0?(t+=a,t<0&&(t=0)):t>a&&(t=a),t<r&&(t=r);let n=this.subarray(r,t);return Object.setPrototypeOf(n,c.prototype),n};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,a){r=r>>>0,t=t>>>0,a||b(r,t,this.length);let n=this[r],i=1,o=0;for(;++o<t&&(i*=256);)n+=this[r+o]*i;return n};c.prototype.readUintBE=c.prototype.readUIntBE=function(r,t,a){r=r>>>0,t=t>>>0,a||b(r,t,this.length);let n=this[r+--t],i=1;for(;t>0&&(i*=256);)n+=this[r+--t]*i;return n};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],a=this[r+7];(t===void 0||a===void 0)&&_r(r,this.length-8);let n=t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,i=this[++r]+this[++r]*2**8+this[++r]*2**16+a*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))});c.prototype.readBigUInt64BE=de(function(r){r=r>>>0,Ue(r,"offset");let t=this[r],a=this[r+7];(t===void 0||a===void 0)&&_r(r,this.length-8);let n=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+a;return(BigInt(n)<<BigInt(32))+BigInt(i)});c.prototype.readIntLE=function(r,t,a){r=r>>>0,t=t>>>0,a||b(r,t,this.length);let n=this[r],i=1,o=0;for(;++o<t&&(i*=256);)n+=this[r+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*t)),n};c.prototype.readIntBE=function(r,t,a){r=r>>>0,t=t>>>0,a||b(r,t,this.length);let n=t,i=1,o=this[r+--n];for(;n>0&&(i*=256);)o+=this[r+--n]*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 a=this[r]|this[r+1]<<8;return a&32768?a|4294901760:a};c.prototype.readInt16BE=function(r,t){r=r>>>0,t||b(r,2,this.length);let a=this[r+1]|this[r]<<8;return a&32768?a|4294901760:a};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],a=this[r+7];(t===void 0||a===void 0)&&_r(r,this.length-8);let n=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(a<<24);return(BigInt(n)<<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],a=this[r+7];(t===void 0||a===void 0)&&_r(r,this.length-8);let n=(t<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(n)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+a)});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,a,n,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>n||r<i)throw new RangeError('"value" argument is out of bounds');if(t+a>e.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(r,t,a,n){if(r=+r,t=t>>>0,a=a>>>0,!n){let s=Math.pow(2,8*a)-1;k(this,r,t,a,s,0)}let i=1,o=0;for(this[t]=r&255;++o<a&&(i*=256);)this[t+o]=r/i&255;return t+a};c.prototype.writeUintBE=c.prototype.writeUIntBE=function(r,t,a,n){if(r=+r,t=t>>>0,a=a>>>0,!n){let s=Math.pow(2,8*a)-1;k(this,r,t,a,s,0)}let i=a-1,o=1;for(this[t+i]=r&255;--i>=0&&(o*=256);)this[t+i]=r/o&255;return t+a};c.prototype.writeUint8=c.prototype.writeUInt8=function(r,t,a){return r=+r,t=t>>>0,a||k(this,r,t,1,255,0),this[t]=r&255,t+1};c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(r,t,a){return r=+r,t=t>>>0,a||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,a){return r=+r,t=t>>>0,a||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,a){return r=+r,t=t>>>0,a||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,a){return r=+r,t=t>>>0,a||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 ia(e,r,t,a,n){ua(r,a,n,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 oa(e,r,t,a,n){ua(r,a,n,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 ia(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeBigUInt64BE=de(function(r,t=0){return oa(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeIntLE=function(r,t,a,n){if(r=+r,t=t>>>0,!n){let l=Math.pow(2,8*a-1);k(this,r,t,a,l-1,-l)}let i=0,o=1,s=0;for(this[t]=r&255;++i<a&&(o*=256);)r<0&&s===0&&this[t+i-1]!==0&&(s=1),this[t+i]=(r/o>>0)-s&255;return t+a};c.prototype.writeIntBE=function(r,t,a,n){if(r=+r,t=t>>>0,!n){let l=Math.pow(2,8*a-1);k(this,r,t,a,l-1,-l)}let i=a-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+a};c.prototype.writeInt8=function(r,t,a){return r=+r,t=t>>>0,a||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,a){return r=+r,t=t>>>0,a||k(this,r,t,2,32767,-32768),this[t]=r&255,this[t+1]=r>>>8,t+2};c.prototype.writeInt16BE=function(r,t,a){return r=+r,t=t>>>0,a||k(this,r,t,2,32767,-32768),this[t]=r>>>8,this[t+1]=r&255,t+2};c.prototype.writeInt32LE=function(r,t,a){return r=+r,t=t>>>0,a||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,a){return r=+r,t=t>>>0,a||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 ia(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});c.prototype.writeBigInt64BE=de(function(r,t=0){return oa(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function sa(e,r,t,a,n,i){if(t+a>e.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function ca(e,r,t,a,n){return r=+r,t=t>>>0,n||sa(e,r,t,4,34028234663852886e22,-34028234663852886e22),Ce.write(e,r,t,a,23,4),t+4}c.prototype.writeFloatLE=function(r,t,a){return ca(this,r,t,!0,a)};c.prototype.writeFloatBE=function(r,t,a){return ca(this,r,t,!1,a)};function la(e,r,t,a,n){return r=+r,t=t>>>0,n||sa(e,r,t,8,17976931348623157e292,-17976931348623157e292),Ce.write(e,r,t,a,52,8),t+8}c.prototype.writeDoubleLE=function(r,t,a){return la(this,r,t,!0,a)};c.prototype.writeDoubleBE=function(r,t,a){return la(this,r,t,!1,a)};c.prototype.copy=function(r,t,a,n){if(!c.isBuffer(r))throw new TypeError("argument should be a Buffer");if(a||(a=0),!n&&n!==0&&(n=this.length),t>=r.length&&(t=r.length),t||(t=0),n>0&&n<a&&(n=a),n===a||r.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(a<0||a>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),r.length-t<n-a&&(n=r.length-t+a);let i=n-a;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,a,n):Uint8Array.prototype.set.call(r,this.subarray(a,n),t),i};c.prototype.fill=function(r,t,a,n){if(typeof r=="string"){if(typeof t=="string"?(n=t,t=0,a=this.length):typeof a=="string"&&(n=a,a=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(r.length===1){let o=r.charCodeAt(0);(n==="utf8"&&o<128||n==="latin1")&&(r=o)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(t<0||this.length<t||this.length<a)throw new RangeError("Out of range index");if(a<=t)return this;t=t>>>0,a=a===void 0?this.length:a>>>0,r||(r=0);let i;if(typeof r=="number")for(i=t;i<a;++i)this[i]=r;else{let o=c.isBuffer(r)?r:c.from(r,n),s=o.length;if(s===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(i=0;i<a-t;++i)this[i+t]=o[i%s]}return this};var ke={};function mt(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(n){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:n,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}mt("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);mt("ERR_INVALID_ARG_TYPE",function(e,r){return`The "${e}" argument must be of type number. Received type ${typeof r}`},TypeError);mt("ERR_OUT_OF_RANGE",function(e,r,t){let a=`The value of "${e}" is out of range.`,n=t;return Number.isInteger(t)&&Math.abs(t)>2**32?n=Lt(String(t)):typeof t=="bigint"&&(n=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(n=Lt(n)),n+="n"),a+=` It must be ${r}. Received ${n}`,a},RangeError);function Lt(e){let r="",t=e.length,a=e[0]==="-"?1:0;for(;t>=a+4;t-=3)r=`_${e.slice(t-3,t)}${r}`;return`${e.slice(0,t)}${r}`}function Oi(e,r,t){Ue(r,"offset"),(e[r]===void 0||e[r+t]===void 0)&&_r(r,e.length-(t+1))}function ua(e,r,t,a,n,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)}Oi(a,n,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 Ri=/[^+/0-9A-Za-z-_]/g;function wi(e){if(e=e.split("=")[0],e=e.trim().replace(Ri,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function dt(e,r){r=r||1/0;let t,a=e.length,n=null,i=[];for(let o=0;o<a;++o){if(t=e.charCodeAt(o),t>55295&&t<57344){if(!n){if(t>56319){(r-=3)>-1&&i.push(239,191,189);continue}else if(o+1===a){(r-=3)>-1&&i.push(239,191,189);continue}n=t;continue}if(t<56320){(r-=3)>-1&&i.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(r-=3)>-1&&i.push(239,191,189);if(n=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 Fi(e){let r=[];for(let t=0;t<e.length;++t)r.push(e.charCodeAt(t)&255);return r}function Ei(e,r){let t,a,n,i=[];for(let o=0;o<e.length&&!((r-=2)<0);++o)t=e.charCodeAt(o),a=t>>8,n=t%256,i.push(n),i.push(a);return i}function da(e){return ct.toByteArray(wi(e))}function Sr(e,r,t,a){let n;for(n=0;n<a&&!(n+t>=r.length||n>=e.length);++n)r[n+t]=e[n];return n}function Z(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 bi=function(){let e="0123456789abcdef",r=new Array(256);for(let t=0;t<16;++t){let a=t*16;for(let n=0;n<16;++n)r[a+n]=e[t]+e[n]}return r}();function de(e){return typeof BigInt>"u"?Ai:e}function Ai(){throw new Error("BigInt not supported")}});var ga=tt(pa());var Cr={};Wn(Cr,{backoff:()=>fa,chain:()=>ha,conditionalDelay:()=>ma,defaultStrategy:()=>kr,maxAttempts:()=>Pi,once:()=>_a,throttle:()=>vi,timeout:()=>ya});var Vi=300*1e3;function kr(){return ha(ma(_a(),1e3),fa(1e3,1.2),ya(Vi))}function _a(){let e=!0;return async()=>e?(e=!1,!0):!1}function ma(e,r){return async(t,a,n)=>{if(await e(t,a,n))return new Promise(i=>setTimeout(i,r))}}function Pi(e){let r=e;return async(t,a,n)=>{if(--r<=0)throw new Error(`Failed to retrieve a reply for request after ${e} attempts:
|
|
2
2
|
Request ID: ${P(a)}
|
|
3
3
|
Request status: ${n}
|
|
4
|
-
`)}}function
|
|
4
|
+
`)}}function vi(e){return()=>new Promise(r=>setTimeout(r,e))}function ya(e){let r=Date.now()+e;return async(t,a,n)=>{if(Date.now()>r)throw new Error(`Request timed out after ${e} msec:
|
|
5
5
|
Request ID: ${P(a)}
|
|
6
6
|
Request status: ${n}
|
|
7
|
-
`)}}function
|
|
7
|
+
`)}}function fa(e,r){let t=e;return()=>new Promise(a=>setTimeout(()=>{t*=r,a()},t))}function ha(...e){return async(r,t,a)=>{for(let n of e)await n(r,t,a)}}async function ft(e,r,t,a=kr(),n,i){var o;let s=[new TextEncoder().encode("request_status"),t],l=n??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=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 a(r,t,m),ft(e,r,t,a,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
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
|
|
14
|
-
`)),this.canisterId=r,this.methodName=t,this.type=a,this.props=n}},Tt=class extends Br{constructor(r,t,a){var n;super(r,t,"query",{Status:a.status,Code:(n=Ht[a.reject_code])!==null&&n!==void 0?n:`Unknown Code "${a.reject_code}"`,Message:a.reject_message}),this.result=a}},Ir=class extends Br{constructor(r,t,a,n,i,o,s){super(r,t,"update",Object.assign({"Request ID":P(a)},n.body?Object.assign(Object.assign({},s?{"Error code":s}:{}),{"Reject code":String(i),"Reject message":o}):{"HTTP status code":n.status.toString(),"HTTP status text":n.statusText})),this.requestId=a,this.response=n,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 h.from(r[j].config.canisterId)}static async install(r,t){let a=r.mode===void 0?{install:null}:r.mode,n=r.arg?[...new Uint8Array(r.arg)]:[],i=[...new Uint8Array(r.module)],o=typeof t.canisterId=="string"?h.fromText(t.canisterId):t.canisterId;await ga(t).install_code({mode:a,arg:n,wasm_module:i,canister_id:o,sender_canister_version:[]})}static async createCanister(r,t){function a(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:n}=await ga(r||{}).provisional_create_canister_with_cycles({amount:[],settings:a(t||{}),specified_id:[],sender_canister_version:[]});return n}static async createAndInstallCanister(r,t,a){let n=await this.createCanister(a);return await this.install(Object.assign({},t),Object.assign(Object.assign({},a),{canisterId:n})),this.createActor(r,Object.assign(Object.assign({},a),{canisterId:n}))}static createActorClass(r,t){let a=r({IDL:dr});class n 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"?h.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Oa),o),{canisterId:s}),service:a});for(let[l,u]of a._fields)t?.httpDetails&&u.annotations.push(Nt),t?.certificate&&u.annotations.push(Ra),this[l]=Ui(this,l,u,o.blsVerify)}}return n}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,a={httpDetails:!0,certificate:!0}){return new(this.createActorClass(r,a))(t)}};function Ie(e,r){let t=dr.decode(e,xa.Buffer.from(r));switch(t.length){case 0:return;case 1:return t[0];default:return t}}var Oa={pollingStrategyFactory:Ur.defaultStrategy},Nt="http-details",Ra="certificate";function Ui(e,r,t,a){let n;t.annotations.includes("query")||t.annotations.includes("composite_query")?n=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)}}:n=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({},Oa),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 Ar.create({certificate:nt(U),rootKey:p.rootKey,canisterId:h.from(d),blsVerify:a});let E=[new TextEncoder().encode("request_status"),C];switch(new TextDecoder().decode($(R.lookup([...E,"status"])))){case"replied":V=$(R.lookup([...E,"reply"]));break;case"rejected":{let H=new Uint8Array($(R.lookup([...E,"reject_code"])))[0],fe=new TextDecoder().decode($(R.lookup([...E,"reject_message"]))),v=$(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 ht(p,B,C,U,a);R=E.certificate,V=E.reply}let w=t.annotations.includes(Nt),S=t.annotations.includes(Ra),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)=>n({},...o);return i.withOptions=o=>(...s)=>n(o,...s),i}function ga(e){function r(t,a){if(e.effectiveCanisterId)return{effectiveCanisterId:h.from(e.effectiveCanisterId)};let n=a[0],i=h.fromHex("");return n&&typeof n=="object"&&n.target_canister&&t==="install_chunked_code"&&(i=h.from(n.target_canister)),n&&typeof n=="object"&&n.canister_id&&(i=h.from(n.canister_id)),{effectiveCanisterId:i}}return ce.createActor(Na,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||{}),gs=BigInt(1e8);var y=e=>e==null,T=e=>!y(e);var qi=class extends Error{},fr=(e,r)=>{if(e==null)throw new qi(r)};var wa="abcdefghijklmnopqrstuvwxyz234567",mr=Object.create(null);for(let e=0;e<wa.length;e++)mr[wa[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__",Fa=(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,Ea=(e,r)=>{let t=a=>r[a];return T(r)&&typeof r=="object"&> 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:a})=>a!==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,a,n){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?e!==r||!n:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?n.call(e,t):n?n.value=t:r.set(e,t),t},pe=function(e,r,t,a){if(t==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?e!==r||!a:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?a:t==="a"?a.call(e):a?a.value:r.get(e)},qr,Dr,De,je;function ba(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(ba(r)){let t=r;if(ba(t)&&Object.hasOwnProperty.call(t,"__derEncodedPublicKey__"))return this.fromDer(t);if(ArrayBuffer.isView(t)){let a=t;return this.fromRaw(Wt(a.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()),zt(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 n=0;n<32;n++)t[n]=new Uint8Array(r)[n];let a=Se.getPublicKey(t);return e.fromKeyPair(a,t)}static fromParsedJson(r){let[t,a]=r;return new e(Ee.fromDer(le(t)),le(a))}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),a=$t(Se.sign(t,pe(this,je,"f").slice(0,32)));return Object.defineProperty(a,"__signature__",{enumerable:!1,value:void 0}),a}static verify(r,t,a){let[n,i,o]=[r,t,a].map(s=>(typeof s=="string"&&(s=le(s)),s instanceof Uint8Array&&(s=s.buffer),new Uint8Array(s)));return Se.verify(i,n,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 Aa(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 yr=class e extends Re{constructor(r,t,a){super(),this._keyPair=r,this._derKey=t,this._subtleCrypto=a}static async generate(r){let{extractable:t=!1,keyUsages:a=["sign","verify"],subtleCrypto:n}=r??{},i=Aa(n),o=await i.generateKey({name:"ECDSA",namedCurve:"P-256"},t,a),s=await i.exportKey("spki",o.publicKey);return new this(o,s,i)}static async fromKeyPair(r,t){let a=Aa(t),n=await a.exportKey("spki",r.publicKey);return new e(r,n,a)}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=at(Zn());var Di=function(e,r,t,a,n){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?e!==r||!n:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?n.call(e,t):n?n.value=t:r.set(e,t),t},hr=function(e,r,t,a){if(t==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?e!==r||!a:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?a:t==="a"?a.call(e):a?a.value:r.get(e)},_e,Mr=class{constructor(r){_e.set(this,void 0),Di(this,_e,r,"f")}get rawKey(){return hr(this,_e,"f").rawKey}get derKey(){return hr(this,_e,"f").derKey}toDer(){return hr(this,_e,"f").toDer()}getPublicKey(){return hr(this,_e,"f")}getPrincipal(){return h.from(hr(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,a,n){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?e!==r||!n:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?n.call(e,t):n?n.value=t:r.set(e,t),t},Mi=function(e,r,t,a){if(t==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?e!==r||!a:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?a:t==="a"?a.call(e):a?a.value:r.get(e)},Ki=function(e,r){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&r.indexOf(a)<0&&(t[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,a=Object.getOwnPropertySymbols(e);n<a.length;n++)r.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(t[a[n]]=e[a[n]]);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,a){this.pubkey=r,this.expiration=t,this.targets=a}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 zi(e,r,t,a){let n=new Ke(r.toDer(),BigInt(+t)*BigInt(1e6),a),i=new Uint8Array([...Ji,...new Uint8Array(it(Object.assign({},n)))]),o=await e.sign(i);return{delegation:n,signature:o}}var Tr=class e{constructor(r,t){this.delegations=r,this.publicKey=t}static async create(r,t,a=new Date(Date.now()+900*1e3),n={}){var i,o;let s=await zi(r,t,a,n.targets);return new e([...((i=n.previous)===null||i===void 0?void 0:i.delegations)||[],s],((o=n.previous)===null||o===void 0?void 0:o.publicKey)||r.getPublicKey().toDer())}static fromJSON(r){let{publicKey:t,delegations:a}=typeof r=="string"?JSON.parse(r):r;if(!Array.isArray(a))throw new Error("Invalid delegations.");let n=a.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(n,Ft(t))}static fromDelegations(r,t){return new this(r,t)}toJSON(){return{delegations:this.delegations.map(r=>{let{delegation:t,signature:a}=r,{targets:n}=t;return{delegation:Object.assign({expiration:t.expiration.toString(16),pubkey:P(t.pubkey)},n&&{targets:n.map(i=>i.toHex())}),signature:P(a)}}),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,a=Ki(r,["body"]),n=await it(t);return Object.assign(Object.assign({},a),{body:{content:t,sender_sig:await this.sign(new Uint8Array([...Hi,...new Uint8Array(n)])),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 Va(e,r){for(let{delegation:n}of e.delegations)if(+new Date(Number(n.expiration/BigInt(1e6)))<=+Date.now())return!1;let t=[],a=r?.scope;a&&(Array.isArray(a)?t.push(...a.map(n=>typeof n=="string"?h.fromText(n):n)):t.push(typeof a=="string"?h.fromText(a):a));for(let n of t){let i=n.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=at(Qn());var Pa;(function(e){e[e.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(Pa||(Pa={}));var va=["mousedown","mousemove","keydown","touchstart","wheel"],xr=class{constructor(r={}){var t;this.callbacks=[],this.idleTimeout=600*1e3,this.timeoutID=void 0;let{onIdle:a,idleTimeout:n=600*1e3}=r||{};this.callbacks=a?[a]:[],this.idleTimeout=n;let i=this._resetTimer.bind(this);window.addEventListener("load",i,!0),va.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);va.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),Sa,ka;function Yi(){return Sa||(Sa=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Xi(){return ka||(ka=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Ca=new WeakMap,bt=new WeakMap,Ua=new WeakMap,Et=new WeakMap,Vt=new WeakMap;function Qi(e){let r=new Promise((t,a)=>{let n=()=>{e.removeEventListener("success",i),e.removeEventListener("error",o)},i=()=>{t(L(e.result)),n()},o=()=>{a(e.error),n()};e.addEventListener("success",i),e.addEventListener("error",o)});return r.then(t=>{t instanceof IDBCursor&&Ca.set(t,e)}).catch(()=>{}),Vt.set(r,e),r}function Zi(e){if(bt.has(e))return;let r=new Promise((t,a)=>{let n=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",o),e.removeEventListener("abort",o)},i=()=>{t(),n()},o=()=>{a(e.error||new DOMException("AbortError","AbortError")),n()};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||Ua.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 Ba(e){At=e(At)}function Li(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(r,...t){let a=e.call(Jr(this),r,...t);return Ua.set(a,r.sort?r.sort():[r]),L(a)}:Xi().includes(e)?function(...r){return e.apply(Jr(this),r),L(Ca.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 qa(e,r,{blocked:t,upgrade:a,blocking:n,terminated:i}={}){let o=indexedDB.open(e,r),s=L(o);return a&&o.addEventListener("upgradeneeded",l=>{a(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()),n&&l.addEventListener("versionchange",u=>n(u.oldVersion,u.newVersion,u))}).catch(()=>{}),s}var ro=["get","getKey","getAll","getAllKeys","count"],to=["put","add","delete","clear"],Pt=new Map;function Ia(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$/,""),a=r!==t,n=to.includes(t);if(!(t in(a?IDBIndex:IDBObjectStore).prototype)||!(n||ro.includes(t)))return;let i=async function(o,...s){let l=this.transaction(o,n?"readwrite":"readonly"),u=l.store;return a&&(u=u.index(s.shift())),(await Promise.all([u[t](...s),n&&l.done]))[0]};return Pt.set(r,i),i}Ba(e=>({...e,get:(r,t,a)=>Ia(r,t)||e.get(r,t,a),has:(r,t)=>!!Ia(r,t)||e.has(r,t)}));var Da="auth-client-db",ja="ic-keyval",ao=async(e=Da,r=ja,t)=>(Hr&&(localStorage!=null&&localStorage.getItem(W))&&(localStorage.removeItem(W),localStorage.removeItem(G)),await qa(e,t,{upgrade:a=>{a.objectStoreNames.contains(r)&&a.clear(r),a.createObjectStore(r)}}));async function no(e,r,t){return await e.get(r,t)}async function io(e,r,t,a){return await e.put(r,a,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=Da,storeName:a=ja,version:n=Ma}=r??{},i=await ao(t,a,n);return new e(i,a)}async set(r,t){return await io(this._db,this._storeName,r,t)}async get(r){var t;return(t=await no(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,a,n){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?e!==r||!n:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?n.call(e,t):n?n.value=t:r.set(e,t),t},co=function(e,r,t,a){if(t==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?e!==r||!a:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?a:t==="a"?a.call(e):a?a.value:r.get(e)},zr,G="identity",W="delegation",Ka="iv",Ma=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){zr.set(this,void 0),so(this,zr,r??{},"f")}get _db(){return new Promise(r=>{if(this.initializedDb){r(this.initializedDb);return}Or.create(co(this,zr,"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)}};zr=new WeakMap;var lo="https://identity.ic0.app",uo="#authorize",vt="ECDSA",St="Ed25519",po=500,Ct="UserInterrupt",$r=class{constructor(r,t,a,n,i,o,s,l){this._identity=r,this._key=t,this._chain=a,this._storage=n,this.idleManager=i,this._createOptions=o,this._idpWindow=s,this._eventHandler=l,this._registerDefaultIdleCallback()}static async create(r={}){var t,a,n;let i=(t=r.storage)!==null&&t!==void 0?t:new wr,o=(a=r.keyType)!==null&&a!==void 0?a: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 yr.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),Va(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!((n=r.idleOptions)===null||n===void 0)&&n.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 yr.generate(),await i.set(G,s.getKeyPair()))),new this(l,s,u,i,p,r)}_registerDefaultIdleCallback(){var r,t;let a=(r=this._createOptions)===null||r===void 0?void 0:r.idleOptions;!a?.onIdle&&!a?.disableDefaultIdleCallback&&((t=this.idleManager)===null||t===void 0||t.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(r,t){var a,n;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),(a=this._idpWindow)===null||a===void 0||a.close();let l=(n=this._createOptions)===null||n===void 0?void 0:n.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,a,n,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,(a=this._idpWindow)===null||a===void 0||a.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(s,Object.assign({maxTimeToLive:(n=r?.maxTimeToLive)!==null&&n!==void 0?n: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 a=>{var n,i,o;if(a.origin!==r.origin)return;let s=a.data;switch(s.kind){case"authorize-ready":{let l=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((n=this._key)===null||n===void 0?void 0:n.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 a;(a=this._idpWindow)===null||a===void 0||a.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(Ka)}var Ja=BigInt(144e11),Ha=!1,za={width:576,height:576},$a={width:505,height:705},Wa="internetcomputer.org";var Je="http://127.0.0.1:5987",Ga="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 Ya=async e=>{let r=new Blob([JSON.stringify(e,Fa)],{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(),Ea)},Gr=()=>typeof window<"u";var Ut=({width:e,height:r})=>{if(!Gr()||y(window)||y(window.top))return;let{top:{innerWidth:t,innerHeight:a}}=window,n=a/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=${n}, left=${i}`};var Yr=class{#e;constructor({domain:r}){this.#e=r}get id(){return"internet_identity"}signInOptions({windowed:r}){let t=()=>{let a=ee.getInstance().get()?.container;if(y(a)||a===!1)return`https://identity.${this.#e??Wa}`;let n=ee.getInstance().get(),i=T(n)&&T(n?.internetIdentityId)?n.internetIdentityId:Ga,{host:o,protocol:s}=new URL(a===!0?Je:a);return/apple/i.test(navigator?.vendor)?`${s}//${o}?canisterId=${i}`:`${s}//${i}.${o.replace("127.0.0.1","localhost")}`};return{...r!==!1&&{windowOpenerFeatures:Ut(za)},identityProvider:t()}}},Xa=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($a)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#r)}`}}};var Qa=async({identity:e,container:r})=>{let a=T(r)&&r!==!1?r===!0?Je:r:"https://icp-api.io",n=T(r);return await pr.create({identity:e,shouldFetchRootKey:n,host:a})};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 a=r.getPrincipal().toText();if(y(this.#e)||y(this.#e[a])){let n=await Qa({identity:r,...t});return this.#e={...this.#e??{},[a]:n},n}return this.#e[a]}reset(){this.#e=null}};var ze=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:a,...n}){let i=`${a}#${t.getPrincipal().toText()}#${r};`;if(y(this.#e)||y(this.#e[i])){let o=await this.createActor({satelliteId:r,identity:t,...n});return this.#e={...this.#e??{},[i]:o},o}return this.#e[i]}reset(){this.#e=null}async createActor({idlFactory:r,satelliteId:t,...a}){let n=await He.getInstance().getAgent(a);return ce.createActor(r,{agent:n,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=()=>$r.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 Za="juno.datastore.error.user.cannot_update";var La=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:a}=e;return{description:N(a),data:await Ya(r),version:N(t)}},qt=e=>{let{version:r}=e;return{version:N(r)}},Fr=async({doc:e,key:r})=>{let{owner:t,version:a,description:n,data:i,...o}=e;return{key:r,description:A(n),owner:t.toText(),data:await Wr(i),version:A(a),...o}};var en=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)}},me=({matcher:e,paginate:r,order:t,owner:a})=>({matcher:y(e)?[]:[{key:N(e.key),description:N(e.description),created_at:en(e.createdAt),updated_at:en(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(a)?void 0:typeof a=="string"?h.fromText(a):a)});var _o=(e=>(e[e.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",e[e.InvalidFormat=1]="InvalidFormat",e[e.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",e))(_o||{}),_l=BigInt(1e8);var rn="abcdefghijklmnopqrstuvwxyz234567",Er=Object.create(null);for(let e=0;e<rn.length;e++)Er[rn[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 tn=({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}),a=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),n=e.Record({field:a,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(n),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}),$e=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)}),ye=e.Variant({AssetsUpgrade:$e,SegmentsDeployment:We}),z=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:ye}),ae=e.Variant({Heap:e.Null,Stable:e.Null}),q=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),he=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),ne=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(ae),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(he),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:ae,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,z)),items_length:e.Nat64}),tr=e.Record({include_system:e.Bool}),ar=e.Record({matcher:e.Opt(tr)}),nr=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(ae),max_size:e.Opt(e.Nat),read:q,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(he),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(z)],["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([ie],[Te],["query"]),init_asset_upload:e.Func([oe],[Y],[]),init_proposal:e.Func([ye],[e.Nat,z],[]),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,ar],[nr],["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,z],[]),upload_asset_chunk:e.Func([xe],[Oe],[]),upload_proposal_asset_chunk:e.Func([xe],[Oe],[])})},an=({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}),a=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),n=e.Record({field:a,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(n),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}),$e=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)}),ye=e.Variant({AssetsUpgrade:$e,SegmentsDeployment:We}),z=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:ye}),ae=e.Variant({Heap:e.Null,Stable:e.Null}),q=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),he=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),ne=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(ae),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(he),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:ae,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,z)),items_length:e.Nat64}),tr=e.Record({include_system:e.Bool}),ar=e.Record({matcher:e.Opt(tr)}),nr=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(ae),max_size:e.Opt(e.Nat),read:q,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(he),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(z)],[]),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([ie],[Te],[]),init_asset_upload:e.Func([oe],[Y],[]),init_proposal:e.Func([ye],[e.Nat,z],[]),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,ar],[nr],[]),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,z],[]),upload_asset_chunk:e.Func([xe],[Oe],[]),upload_proposal_asset_chunk:e.Func([xe],[Oe],[])})};var nn=({satelliteId:e,container:r})=>{let{satelliteId:t}=Dt({satelliteId:e}),{container:a}=jt({container:r});if(T(a)&&a!==!1){let{host:n,protocol:i}=new URL(a===!0?Je:a);return`${i}//${t??"unknown"}.${n.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}})=>sn({idlFactory:r?an:tn,actorKey:`stock#${r?"update":"query"}`,...e}),on=({idlFactory:e,...r})=>sn({idlFactory:e,actorKey:"extended#query",...r}),sn=async({satelliteId:e,container:r,...t})=>{let{satelliteId:a}=Dt({satelliteId:e});fr(a,"No satellite ID defined. Did you initialize Juno?");let{container:n}=jt({container:r});return await ze.getInstance().getActor({satelliteId:a,container:n,...t})};var cn=async({collection:e,key:r,...t})=>{let{get_doc:a}=await F(t),n=A(await a(e,r));if(!y(n))return Fr({doc:n,key:r})},ln=async({docs:e,...r})=>{let{get_many_docs:t}=await F(r),a=e.map(({collection:o,key:s})=>[o,s]),n=await t(a),i=[];for(let[o,s]of n){let l=A(s);i.push(T(l)?await Fr({key:o,doc:l}):void 0)}return i},un=async({collection:e,doc:r,...t})=>{let{set_doc:a}=await F(t),{key:n}=r,i=await It(r),o=await a(e,n,i);return await Fr({key:n,doc:o})},dn=async({docs:e,...r})=>{let{set_many_docs:t}=await F(r),a=[];for(let{collection:o,doc:s}of e){let{key:l}=s;a.push([o,l,await It(s)])}let n=await t(a),i=[];for(let[o,s]of n)i.push(await Fr({key:o,doc:s}));return i},pn=async({collection:e,doc:r,...t})=>{let{del_doc:a}=await F(t),{key:n}=r;return a(e,n,qt(r))},_n=async({docs:e,...r})=>{let{del_many_docs:t}=await F(r),a=e.map(({collection:n,doc:i})=>[n,i.key,qt(i)]);await t(a)},mn=async({collection:e,filter:r,...t})=>{let{del_filtered_docs:a}=await F(t);return a(e,me(r))},fn=async({collection:e,filter:r,...t})=>{let{list_docs:a}=await F(t),{items:n,items_page:i,items_length:o,matches_length:s,matches_pages:l}=await a(e,me(r)),u=[];for(let[p,d]of n){let{data:m,owner:f,description:x,version:B,...K}=d;u.push({key:p,description:A(x),owner:f.toText(),data:await La({data:m}),version:A(B),...K})}return{items:u,items_length:o,items_page:A(i),matches_length:s,matches_pages:A(l)}},yn=async({collection:e,filter:r,...t})=>{let{count_docs:a}=await F(t);return a(e,me(r))};var re={certified:!1};var g=e=>T(e)?e:tt()??new ve;var hn=async({satellite:e,options:r,...t})=>{let a=g(e?.identity);return await cn({...t,satellite:{...e,identity:a},options:r??re})},jl=async({satellite:e,options:r,...t})=>{let a=g(e?.identity);return await ln({...t,satellite:{...e,identity:a},options:r??re})},Tn=async({satellite:e,...r})=>{let t=g(e?.identity);return await un({...r,satellite:{...e,identity:t},options:{certified:!0}})},Ml=async({satellite:e,...r})=>{let t=g(e?.identity);return await dn({...r,satellite:{...e,identity:t},options:{certified:!0}})},Kl=async({satellite:e,...r})=>{let t=g(e?.identity);return await pn({...r,satellite:{...e,identity:t},options:{certified:!0}})},Jl=async({satellite:e,...r})=>{let t=g(e?.identity);return await _n({...r,satellite:{...e,identity:t},options:{certified:!0}})},Hl=async({satellite:e,filter:r,...t})=>{let a=g(e?.identity);return await mn({...t,filter:r??{},satellite:{...e,identity:a},options:{certified:!0}})},zl=async({satellite:e,options:r,filter:t,...a})=>{let n=g(e?.identity);return await fn({...a,filter:t??{},satellite:{...e,identity:n},options:r??re})},$l=async({satellite:e,options:r,filter:t,...a})=>{let n=g(e?.identity);return await yn({...a,filter:t??{},satellite:{...e,identity:n},options:r??re})};var Nn=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(),a=()=>hn({collection:"#user",key:t}),n=await a();if(T(n))return n;try{return await mo({userId:t,provider:e})}catch(i){if(Bt({error:i,type:Za})){let o=await a();if(T(o))return o}throw i}},mo=({userId:e,...r})=>Tn({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 Nn(e);Z.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 a=e?.provider??new Yr({});await M.login({onSuccess:async()=>{await Mt(a.id),r()},onError:n=>{if(n===Ct){t(new Zr(n));return}t(new Xr(n))},maxTimeToLive:e?.maxTimeToLive??Ja,allowPinAuthentication:e?.allowPin??Ha,...e?.derivationOrigin!==void 0&&{derivationOrigin:e.derivationOrigin},...a.signInOptions({windowed:e?.windowed})})}),Kt=async()=>{await yo(),M=await rt()},yo=async()=>{await M?.logout(),M=null,Z.getInstance().reset(),ze.getInstance().reset(),He.getInstance().reset()},tt=()=>M?.getIdentity(),ho=async()=>(M??await rt()).getIdentity(),To=async()=>{let e=Z.getInstance().get();return y(e)||!(await M?.isAuthenticated()??!1)?null:M?.getIdentity()??null};var gn=e=>{let r=e===!0?"./workers/auth.worker.js":e,t=new Worker(r),a=async()=>{Rt({message:"junoSignOutAuthTimer"}),await Kt()};return t.onmessage=async({data:n})=>{let{msg:i,data:o}=n;switch(i){case"junoSignOutAuthTimer":await a();return;case"junoDelegationRemainingTime":Rt({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},Z.getInstance().subscribe(n=>{if(y(n)){t.postMessage({msg:"junoStopAuthTimer"});return}t.postMessage({msg:"junoStartAuthTimer"})})};var xn=()=>{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()},On=()=>{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 on({idlFactory:e,...r,identity:t})};var Rn=async({asset:{data:e,headers:r,...t},actor:a,progress:n})=>{let{init_asset_upload:i,upload_asset_chunk:o,commit_asset_upload:s}=a,{batch_id:l}=await i(No(t));n?.onInitiatedBatch();let{chunkIds:u}=await Oo({data:e,uploadFn:o,batchId:l});n?.onUploadedFileChunks(t.fullPath),await xo({commitFn:s,batchId:l,data:e,headers:r,chunkIds:u}),n?.onCommittedBatch()};var No=({filename:e,collection:r,token:t,fullPath:a,encoding:n,description:i})=>({collection:r,full_path:a,name:e,token:N(t),encoding_type:N(n),description:N(i)}),go=({batchId:e,chunkIds:r,headers:t,data:a})=>{let n=t.find(([i,o])=>i.toLowerCase()==="content-type")===void 0&&a.type!==void 0&&a.type!==""?[["Content-Type",a.type]]:void 0;return{batch_id:e,chunk_ids:r.map(({chunk_id:i})=>i),headers:[...t,...n??[]]}},xo=async({commitFn:e,...r})=>{let t=go(r);await e(t)},Oo=async({data:e,uploadFn:r,batchId:t})=>{let a=[],n=Gr()?new Blob([await e.arrayBuffer()]):e,i=0n;for(let s=0;s<n.size;s+=19e5){let l=n.slice(s,s+19e5);a.push({batchId:t,chunk:l,uploadFn:r,orderId:i}),i++}let o=[];for await(let s of Ro({uploadChunks:a}))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 a=e.slice(t,t+r);yield await Promise.all(a.map(n=>wo(n)))}}var wo=async({batchId:e,chunk:r,uploadFn:t,orderId:a})=>t({batch_id:e,content:new Uint8Array(await r.arrayBuffer()),order_id:N(a)});var wn=async({asset:e,...r})=>{let t=await F(r);await Rn({actor:t,asset:e})},Fn=async({collection:e,filter:r,...t})=>{let{list_assets:a}=await F(t),{items:n,items_length:i,items_page:o,matches_length:s,matches_pages:l}=await a(e,me(r));return{items:n.map(([u,p])=>p),items_length:i,items_page:A(o),matches_length:s,matches_pages:A(l)}},En=async({collection:e,filter:r,...t})=>{let{count_assets:a}=await F(t);return a(e,me(r))},bn=async({collection:e,fullPath:r,...t})=>(await F(t)).del_asset(e,r),An=async({assets:e,satellite:r})=>{let{del_many_assets:t}=await F({satellite:r,options:{certified:!0}}),a=e.map(({collection:n,fullPath:i})=>[n,i]);await t(a)},Vn=async({collection:e,filter:r,...t})=>{let{del_filtered_assets:a}=await F(t);return a(e,me(r))},Pn=async({collection:e,fullPath:r,...t})=>{let{get_asset:a}=await F(t);return A(await a(e,r))},vn=async({assets:e,...r})=>{let{get_many_assets:t}=await F(r),a=e.map(({collection:i,fullPath:o})=>[i,o]);return(await t(a)).map(([i,o])=>A(o))};var Sn=e=>btoa([...e].map(r=>String.fromCharCode(r)).join(""));var Bu=e=>kn(e),Iu=e=>kn({filename:e.data.name,...e}),kn=async({filename:e,data:r,collection:t,headers:a=[],fullPath:n,token:i,satellite:o,encoding:s,description:l})=>{let u=g(o?.identity),p=decodeURI(e),d=n??`/${t}/${p}`,m={...o,identity:u};return await wn({asset:{data:r,filename:p,collection:t,token:i,headers:a,fullPath:d,encoding:s,description:l},satellite:m,options:{certified:!0}}),{downloadUrl:Cn({satellite:m,assetKey:{fullPath:d,token:i}}),fullPath:d,name:p}},qu=async({collection:e,filter:r,satellite:t,options:a})=>{let n={...t,identity:g(t?.identity)},{items:i,...o}=await Fn({collection:e,filter:r??{},satellite:n,options:a??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:Cn({satellite:n,assetKey:{fullPath:l,token:C}}),token:C,headers:f,encodings:x.reduce((O,[_,{modified:V,sha256:R,total_length:w}])=>({...O,[_]:{modified:V,sha256:Sn(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:a})=>{let n={...t,identity:g(t?.identity)};return await En({collection:e,satellite:n,filter:r??{},options:a??re})},ju=({collection:e,fullPath:r,satellite:t})=>bn({collection:e,fullPath:r,satellite:{...t,identity:g(t?.identity)},options:{certified:!0}}),Mu=({assets:e,satellite:r})=>An({assets:e,satellite:{...r,identity:g(r?.identity)},options:{certified:!0}}),Ku=async({collection:e,satellite:r,filter:t})=>{let a={...r,identity:g(r?.identity)};return await Vn({collection:e,satellite:a,filter:t??{},options:{certified:!0}})},Ju=async({satellite:e,options:r,...t})=>{let a=g(e?.identity);return await Pn({...t,satellite:{...e,identity:a},options:r??re})},Hu=async({satellite:e,options:r,...t})=>{let a=g(e?.identity);return await vn({...t,satellite:{...e,identity:a},options:r??re})},Cn=({assetKey:{fullPath:e,token:r},satellite:t})=>{let a={...t,identity:g(t?.identity)};return`${nn(a)}${e}${T(r)?`?token=${r}`:""}`};var Fo=e=>{let r=e?.satelliteId??xn();fr(r,"Satellite ID is not configured. Juno cannot be initialized.");let t=e?.container??On();return{satelliteId:r,internetIdentityId:e?.internetIdentityId,workers:e?.workers,container:t}},Zu=e=>Eo(e),Eo=async e=>{let r=Fo(e);ee.getInstance().set(r),await Mt();let t=r.workers?.auth!==void 0?gn(r.workers.auth):void 0;return[...t?[t]:[]]},Lu=e=>Z.getInstance().subscribe(e);export{Lr as InitError,Yr as InternetIdentityProvider,et as ListError,Xa as NFIDProvider,Xr as SignInError,Qr as SignInInitError,Zr as SignInUserInterruptError,Lu as authSubscribe,Du as countAssets,$l as countDocs,ju as deleteAsset,Kl as deleteDoc,Ku as deleteFilteredAssets,Hl as deleteFilteredDocs,Mu as deleteManyAssets,Jl as deleteManyDocs,Cn as downloadUrl,Ju as getAsset,hn as getDoc,To as getIdentityOnce,Hu as getManyAssets,jl as getManyDocs,Nu as getSatelliteExtendedActor,Zu as initJuno,Eo as initSatellite,qu as listAssets,zl as listDocs,Tn 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 Ta=({IDL:e})=>{let r=e.Variant({mainnet:e.Null,testnet:e.Null}),t=e.Text,a=e.Record({network:r,address:t,min_confirmations:e.Opt(e.Nat32)}),n=e.Nat64,i=n,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}),M=e.Record({height:e.Nat32,value:n,outpoint:B}),C=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:o,tip_block_hash:x,utxos:e.Vec(M)}),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}),ye=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:_}),fe=e.Record({canister_id:_}),$=e.Record({canister_id:_,snapshot_id:w}),ae=e.Record({canister_id:_}),q=e.Variant({secp256k1:e.Null}),he=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:_}),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)}),Ze=e.Vec(e.Nat8),Qe=e.Record({arg:e.Vec(e.Nat8),wasm_module:Ze,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}),ar=e.Record({num_block_failures_total:e.Nat64,node_id:e.Principal,num_blocks_proposed_total:e.Nat64}),nr=e.Vec(e.Record({timestamp_nanos:e.Nat64,node_metrics:e.Vec(ar)})),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)})}),kn=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)}),Cn=e.Record({signature:e.Vec(e.Nat8)}),Un=e.Record({canister_id:_}),Bn=e.Record({canister_id:_}),In=e.Record({canister_id:_}),qn=e.Vec(Ne),Dn=e.Record({subnet_id:e.Principal}),jn=e.Record({replica_version:e.Text}),Kn=e.Record({replace_snapshot:e.Opt(w),canister_id:_}),Mn=Ve,Jn=e.Record({canister_id:_,sender_canister_version:e.Opt(e.Nat64)}),Hn=e.Record({canister_id:e.Principal,settings:te,sender_canister_version:e.Opt(e.Nat64)}),$n=e.Record({chunk:e.Vec(e.Nat8),canister_id:e.Principal}),zn=Ne;return e.Service({bitcoin_get_balance:e.Func([a],[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],[ye],[]),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([ae],[],[]),ecdsa_public_key:e.Func([he],[ne],[]),fetch_canister_logs:e.Func([Ge],[Ye],["query"]),http_request:e.Func([oe],[Te],[]),install_chunked_code:e.Func([Xe],[],[]),install_code:e.Func([Qe],[],[]),list_canister_snapshots:e.Func([Le],[er],[]),load_canister_snapshot:e.Func([rr],[],[]),node_metrics_history:e.Func([tr],[nr],[]),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([kn],[Cn],[]),start_canister:e.Func([Un],[],[]),stop_canister:e.Func([Bn],[],[]),stored_chunks:e.Func([In],[qn],[]),subnet_info:e.Func([Dn],[jn],[]),take_canister_snapshot:e.Func([Kn],[Mn],[]),uninstall_code:e.Func([Jn],[],[]),update_settings:e.Func([Hn],[],[]),upload_chunk:e.Func([$n],[zn],[])})};var Ur=class extends Er{constructor(r,t,a,n){super(["Call failed:",` Canister: ${r.toText()}`,` Method: ${t} (${a})`,...Object.getOwnPropertyNames(n).map(i=>` "${i}": ${JSON.stringify(n[i])}`)].join(`
|
|
14
|
+
`)),this.canisterId=r,this.methodName=t,this.type=a,this.props=n}},ht=class extends Ur{constructor(r,t,a){var n;super(r,t,"query",{Status:a.status,Code:(n=Jt[a.reject_code])!==null&&n!==void 0?n:`Unknown Code "${a.reject_code}"`,Message:a.reject_message}),this.result=a}},Br=class extends Ur{constructor(r,t,a,n,i,o,s){super(r,t,"update",Object.assign({"Request ID":P(a)},n.body?Object.assign(Object.assign({},s?{"Error code":s}:{}),{"Reject code":String(i),"Reject message":o}):{"HTTP status code":n.status.toString(),"HTTP status text":n.statusText})),this.requestId=a,this.response=n,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 T.from(r[j].config.canisterId)}static async install(r,t){let a=r.mode===void 0?{install:null}:r.mode,n=r.arg?[...new Uint8Array(r.arg)]:[],i=[...new Uint8Array(r.module)],o=typeof t.canisterId=="string"?T.fromText(t.canisterId):t.canisterId;await Na(t).install_code({mode:a,arg:n,wasm_module:i,canister_id:o,sender_canister_version:[]})}static async createCanister(r,t){function a(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:n}=await Na(r||{}).provisional_create_canister_with_cycles({amount:[],settings:a(t||{}),specified_id:[],sender_canister_version:[]});return n}static async createAndInstallCanister(r,t,a){let n=await this.createCanister(a);return await this.install(Object.assign({},t),Object.assign(Object.assign({},a),{canisterId:n})),this.createActor(r,Object.assign(Object.assign({},a),{canisterId:n}))}static createActorClass(r,t){let a=r({IDL:dr});class n 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"?T.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},xa),o),{canisterId:s}),service:a});for(let[l,u]of a._fields)t?.httpDetails&&u.annotations.push(Tt),t?.certificate&&u.annotations.push(Oa),this[l]=ki(this,l,u,o.blsVerify)}}return n}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,a={httpDetails:!0,certificate:!0}){return new(this.createActorClass(r,a))(t)}};function Ie(e,r){let t=dr.decode(e,ga.Buffer.from(r));switch(t.length){case 0:return;case 1:return t[0];default:return t}}var xa={pollingStrategyFactory:Cr.defaultStrategy},Tt="http-details",Oa="certificate";function ki(e,r,t,a){let n;t.annotations.includes("query")||t.annotations.includes("composite_query")?n=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||ot(),d=T.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 ht(d,r,f);case"replied":return t.annotations.includes(Tt)?{httpDetails:x,result:Ie(t.retTypes,f.reply.arg)}:Ie(t.retTypes,f.reply.arg)}}:n=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||ot(),{canisterId:d,effectiveCanisterId:m,pollingStrategyFactory:f}=Object.assign(Object.assign(Object.assign({},xa),e[j].config),o),x=T.from(d),B=m!==void 0?T.from(m):x,M=dr.encode(t.argTypes,s),{requestId:C,response:O,requestDetails:_}=await p.call(x,{methodName:r,arg:M,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:T.from(d),blsVerify:a});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],ye=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 Br(x,r,C,O,H,ye,te)}}}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 ft(p,B,C,U,a);R=E.certificate,V=E.reply}let w=t.annotations.includes(Tt),S=t.annotations.includes(Oa),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)=>n({},...o);return i.withOptions=o=>(...s)=>n(o,...s),i}function Na(e){function r(t,a){if(e.effectiveCanisterId)return{effectiveCanisterId:T.from(e.effectiveCanisterId)};let n=a[0],i=T.fromHex("");return n&&typeof n=="object"&&n.target_canister&&t==="install_chunked_code"&&(i=T.from(n.target_canister)),n&&typeof n=="object"&&n.canister_id&&(i=T.from(n.canister_id)),{effectiveCanisterId:i}}return ce.createActor(Ta,Object.assign(Object.assign(Object.assign({},e),{canisterId:T.fromHex("")}),{callTransform:r,queryTransform:r}))}var Ui=(e=>(e[e.FractionalMoreThan8Decimals=0]="FractionalMoreThan8Decimals",e[e.InvalidFormat=1]="InvalidFormat",e[e.FractionalTooManyDecimals=2]="FractionalTooManyDecimals",e))(Ui||{}),hs=BigInt(1e8);var y=e=>e==null,h=e=>!y(e);var Bi=class extends Error{},yr=(e,r)=>{if(e==null)throw new Bi(r)};var Ra="abcdefghijklmnopqrstuvwxyz234567",mr=Object.create(null);for(let e=0;e<Ra.length;e++)mr[Ra[e]]=e;mr[0]=mr.o;mr[1]=mr.i;var gs=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 Nt="__bigint__",gt="__principal__",xt="__uint8array__",wa=(e,r)=>typeof r=="bigint"?{[Nt]:`${r}`}:h(r)&&r instanceof T?{[gt]:r.toText()}:h(r)&&r instanceof Uint8Array?{[xt]:Array.from(r)}:r,Fa=(e,r)=>{let t=a=>r[a];return h(r)&&typeof r=="object"&&Nt in r?BigInt(t(Nt)):h(r)&&typeof r=="object"&> in r?T.fromText(t(gt)):h(r)&&typeof r=="object"&&xt in r?Uint8Array.from(t(xt)):r};var N=e=>h(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:a})=>a!==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 Ot=({message:e,detail:r})=>{let t=new CustomEvent(e,{detail:r,bubbles:!0});document.dispatchEvent(t)};var Dr=function(e,r,t,a,n){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?e!==r||!n:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?n.call(e,t):n?n.value=t:r.set(e,t),t},pe=function(e,r,t,a){if(t==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?e!==r||!a:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?a:t==="a"?a.call(e):a?a.value:r.get(e)},Ir,qr,De,je;function Ea(e){return e!==null&&typeof e=="object"}var Ee=class e{constructor(r){if(Ir.set(this,void 0),qr.set(this,void 0),r.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Dr(this,Ir,r,"f"),Dr(this,qr,e.derEncode(r),"f")}static from(r){if(typeof r=="string"){let t=le(r);return this.fromRaw(t)}else if(Ea(r)){let t=r;if(Ea(t)&&Object.hasOwnProperty.call(t,"__derEncodedPublicKey__"))return this.fromDer(t);if(ArrayBuffer.isView(t)){let a=t;return this.fromRaw(zt(a.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=it(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 pe(this,Ir,"f")}get derKey(){return pe(this,qr,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Ir=new WeakMap,qr=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),Dr(this,De,Ee.from(r),"f"),Dr(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()),Ht(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 n=0;n<32;n++)t[n]=new Uint8Array(r)[n];let a=Se.getPublicKey(t);return e.fromKeyPair(a,t)}static fromParsedJson(r){let[t,a]=r;return new e(Ee.fromDer(le(t)),le(a))}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),a=$t(Se.sign(t,pe(this,je,"f").slice(0,32)));return Object.defineProperty(a,"__signature__",{enumerable:!1,value:void 0}),a}static verify(r,t,a){let[n,i,o]=[r,t,a].map(s=>(typeof s=="string"&&(s=le(s)),s instanceof Uint8Array&&(s=s.buffer),new Uint8Array(s)));return Se.verify(i,n,o)}};De=new WeakMap,je=new WeakMap;var Rt=class e extends Error{constructor(r){super(r),this.message=r,Object.setPrototypeOf(this,e.prototype)}};function ba(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 Rt("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,a){super(),this._keyPair=r,this._derKey=t,this._subtleCrypto=a}static async generate(r){let{extractable:t=!1,keyUsages:a=["sign","verify"],subtleCrypto:n}=r??{},i=ba(n),o=await i.generateKey({name:"ECDSA",namedCurve:"P-256"},t,a),s=await i.exportKey("spki",o.publicKey);return new this(o,s,i)}static async fromKeyPair(r,t){let a=ba(t),n=await a.exportKey("spki",r.publicKey);return new e(r,n,a)}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 Ke=tt(Xn());var Ii=function(e,r,t,a,n){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?e!==r||!n:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?n.call(e,t):n?n.value=t:r.set(e,t),t},hr=function(e,r,t,a){if(t==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?e!==r||!a:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?a:t==="a"?a.call(e):a?a.value:r.get(e)},_e,jr=class{constructor(r){_e.set(this,void 0),Ii(this,_e,r,"f")}get rawKey(){return hr(this,_e,"f").rawKey}get derKey(){return hr(this,_e,"f").derKey}toDer(){return hr(this,_e,"f").toDer()}getPublicKey(){return hr(this,_e,"f")}getPrincipal(){return T.from(hr(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 qi=function(e,r,t,a,n){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?e!==r||!n:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?n.call(e,t):n?n.value=t:r.set(e,t),t},Di=function(e,r,t,a){if(t==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?e!==r||!a:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?a:t==="a"?a.call(e):a?a.value:r.get(e)},ji=function(e,r){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&r.indexOf(a)<0&&(t[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,a=Object.getOwnPropertySymbols(e);n<a.length;n++)r.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(t[a[n]]=e[a[n]]);return t},Kr,Ki=new TextEncoder().encode("ic-request-auth-delegation"),Mi=new TextEncoder().encode(`
|
|
15
|
+
ic-request`);function wt(e){if(typeof e!="string"||e.length<64)throw new Error("Invalid public key.");return le(e)}var Me=class{constructor(r,t,a){this.pubkey=r,this.expiration=t,this.targets=a}toCBOR(){return Ke.value.map(Object.assign({pubkey:Ke.value.bytes(this.pubkey),expiration:Ke.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Ke.value.array(this.targets.map(r=>Ke.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 Ji(e,r,t,a){let n=new Me(r.toDer(),BigInt(+t)*BigInt(1e6),a),i=new Uint8Array([...Ki,...new Uint8Array(nt(Object.assign({},n)))]),o=await e.sign(i);return{delegation:n,signature:o}}var Tr=class e{constructor(r,t){this.delegations=r,this.publicKey=t}static async create(r,t,a=new Date(Date.now()+900*1e3),n={}){var i,o;let s=await Ji(r,t,a,n.targets);return new e([...((i=n.previous)===null||i===void 0?void 0:i.delegations)||[],s],((o=n.previous)===null||o===void 0?void 0:o.publicKey)||r.getPublicKey().toDer())}static fromJSON(r){let{publicKey:t,delegations:a}=typeof r=="string"?JSON.parse(r):r;if(!Array.isArray(a))throw new Error("Invalid delegations.");let n=a.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 Me(wt(l),BigInt("0x"+u),p&&p.map(d=>{if(typeof d!="string")throw new Error("Invalid target.");return T.fromHex(d)})),signature:wt(s)}});return new this(n,wt(t))}static fromDelegations(r,t){return new this(r,t)}toJSON(){return{delegations:this.delegations.map(r=>{let{delegation:t,signature:a}=r,{targets:n}=t;return{delegation:Object.assign({expiration:t.expiration.toString(16),pubkey:P(t.pubkey)},n&&{targets:n.map(i=>i.toHex())}),signature:P(a)}}),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,a=ji(r,["body"]),n=await nt(t);return Object.assign(Object.assign({},a),{body:{content:t,sender_sig:await this.sign(new Uint8Array([...Mi,...new Uint8Array(n)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},gr=class e extends jr{constructor(r,t){super(r),Kr.set(this,void 0),qi(this,Kr,t,"f")}get delegation(){return Di(this,Kr,"f")}static fromDelegation(r,t){return new e(r,t)}};Kr=new WeakMap;function Aa(e,r){for(let{delegation:n}of e.delegations)if(+new Date(Number(n.expiration/BigInt(1e6)))<=+Date.now())return!1;let t=[],a=r?.scope;a&&(Array.isArray(a)?t.push(...a.map(n=>typeof n=="string"?T.fromText(n):n)):t.push(typeof a=="string"?T.fromText(a):a));for(let n of t){let i=n.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 $i=tt(Yn());var Va;(function(e){e[e.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(Va||(Va={}));var Pa=["mousedown","mousemove","keydown","touchstart","wheel"],xr=class{constructor(r={}){var t;this.callbacks=[],this.idleTimeout=600*1e3,this.timeoutID=void 0;let{onIdle:a,idleTimeout:n=600*1e3}=r||{};this.callbacks=a?[a]:[],this.idleTimeout=n;let i=this._resetTimer.bind(this);window.addEventListener("load",i,!0),Pa.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);Pa.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 zi=(e,r)=>r.some(t=>e instanceof t),va,Sa;function Wi(){return va||(va=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Gi(){return Sa||(Sa=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var ka=new WeakMap,Et=new WeakMap,Ca=new WeakMap,Ft=new WeakMap,At=new WeakMap;function Yi(e){let r=new Promise((t,a)=>{let n=()=>{e.removeEventListener("success",i),e.removeEventListener("error",o)},i=()=>{t(L(e.result)),n()},o=()=>{a(e.error),n()};e.addEventListener("success",i),e.addEventListener("error",o)});return r.then(t=>{t instanceof IDBCursor&&ka.set(t,e)}).catch(()=>{}),At.set(r,e),r}function Xi(e){if(Et.has(e))return;let r=new Promise((t,a)=>{let n=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",o),e.removeEventListener("abort",o)},i=()=>{t(),n()},o=()=>{a(e.error||new DOMException("AbortError","AbortError")),n()};e.addEventListener("complete",i),e.addEventListener("error",o),e.addEventListener("abort",o)});Et.set(e,r)}var bt={get(e,r,t){if(e instanceof IDBTransaction){if(r==="done")return Et.get(e);if(r==="objectStoreNames")return e.objectStoreNames||Ca.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 Ua(e){bt=e(bt)}function Zi(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(r,...t){let a=e.call(Mr(this),r,...t);return Ca.set(a,r.sort?r.sort():[r]),L(a)}:Gi().includes(e)?function(...r){return e.apply(Mr(this),r),L(ka.get(this))}:function(...r){return L(e.apply(Mr(this),r))}}function Qi(e){return typeof e=="function"?Zi(e):(e instanceof IDBTransaction&&Xi(e),zi(e,Wi())?new Proxy(e,bt):e)}function L(e){if(e instanceof IDBRequest)return Yi(e);if(Ft.has(e))return Ft.get(e);let r=Qi(e);return r!==e&&(Ft.set(e,r),At.set(r,e)),r}var Mr=e=>At.get(e);function Ia(e,r,{blocked:t,upgrade:a,blocking:n,terminated:i}={}){let o=indexedDB.open(e,r),s=L(o);return a&&o.addEventListener("upgradeneeded",l=>{a(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()),n&&l.addEventListener("versionchange",u=>n(u.oldVersion,u.newVersion,u))}).catch(()=>{}),s}var Li=["get","getKey","getAll","getAllKeys","count"],eo=["put","add","delete","clear"],Vt=new Map;function Ba(e,r){if(!(e instanceof IDBDatabase&&!(r in e)&&typeof r=="string"))return;if(Vt.get(r))return Vt.get(r);let t=r.replace(/FromIndex$/,""),a=r!==t,n=eo.includes(t);if(!(t in(a?IDBIndex:IDBObjectStore).prototype)||!(n||Li.includes(t)))return;let i=async function(o,...s){let l=this.transaction(o,n?"readwrite":"readonly"),u=l.store;return a&&(u=u.index(s.shift())),(await Promise.all([u[t](...s),n&&l.done]))[0]};return Vt.set(r,i),i}Ua(e=>({...e,get:(r,t,a)=>Ba(r,t)||e.get(r,t,a),has:(r,t)=>!!Ba(r,t)||e.has(r,t)}));var qa="auth-client-db",Da="ic-keyval",ro=async(e=qa,r=Da,t)=>(Jr&&(localStorage!=null&&localStorage.getItem(W))&&(localStorage.removeItem(W),localStorage.removeItem(G)),await Ia(e,t,{upgrade:a=>{a.objectStoreNames.contains(r)&&a.clear(r),a.createObjectStore(r)}}));async function to(e,r,t){return await e.get(r,t)}async function ao(e,r,t,a){return await e.put(r,a,t)}async function no(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=qa,storeName:a=Da,version:n=ja}=r??{},i=await ro(t,a,n);return new e(i,a)}async set(r,t){return await ao(this._db,this._storeName,r,t)}async get(r){var t;return(t=await to(this._db,this._storeName,r))!==null&&t!==void 0?t:null}async remove(r){return await no(this._db,this._storeName,r)}};var io=function(e,r,t,a,n){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?e!==r||!n:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?n.call(e,t):n?n.value=t:r.set(e,t),t},oo=function(e,r,t,a){if(t==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?e!==r||!a:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?a:t==="a"?a.call(e):a?a.value:r.get(e)},Hr,G="identity",W="delegation",Ka="iv",ja=1,Jr=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){Hr.set(this,void 0),io(this,Hr,r??{},"f")}get _db(){return new Promise(r=>{if(this.initializedDb){r(this.initializedDb);return}Or.create(oo(this,Hr,"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)}};Hr=new WeakMap;var so="https://identity.ic0.app",co="#authorize",Pt="ECDSA",vt="Ed25519",lo=500,kt="UserInterrupt",$r=class{constructor(r,t,a,n,i,o,s,l){this._identity=r,this._key=t,this._chain=a,this._storage=n,this.idleManager=i,this._createOptions=o,this._idpWindow=s,this._eventHandler=l,this._registerDefaultIdleCallback()}static async create(r={}){var t,a,n;let i=(t=r.storage)!==null&&t!==void 0?t:new wr,o=(a=r.keyType)!==null&&a!==void 0?a:Pt,s=null;if(r.identity)s=r.identity;else{let d=await i.get(G);if(!d&&Jr)try{let m=new Rr,f=await m.get(W),x=await m.get(G);f&&x&&o===Pt&&(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===vt&&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=Tr.fromJSON(d),Aa(u)?"toDer"in s?l=gr.fromDelegation(s,u):l=Nr.fromDelegation(s,u):(await St(i),s=null))}catch(d){console.error(d),await St(i),s=null}let p;return!((n=r.idleOptions)===null||n===void 0)&&n.disableIdle?p=void 0:(u||r.identity)&&(p=xr.create(r.idleOptions)),s||(o===vt?(s=await be.generate(),await i.set(G,JSON.stringify(s.toJSON()))):(r.storage&&o===Pt&&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 '${vt}' 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 a=(r=this._createOptions)===null||r===void 0?void 0:r.idleOptions;!a?.onIdle&&!a?.disableDefaultIdleCallback&&((t=this.idleManager)===null||t===void 0||t.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(r,t){var a,n;let i=r.delegations.map(u=>({delegation:new Me(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),(a=this._idpWindow)===null||a===void 0||a.close();let l=(n=this._createOptions)===null||n===void 0?void 0:n.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,a,n,i;let o=BigInt(8)*BigInt(36e11),s=new URL(((t=r?.identityProvider)===null||t===void 0?void 0:t.toString())||so);s.hash=co,(a=this._idpWindow)===null||a===void 0||a.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(s,Object.assign({maxTimeToLive:(n=r?.maxTimeToLive)!==null&&n!==void 0?n: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(kt,r?.onError):setTimeout(l,lo))};l()}_getEventHandler(r,t){return async a=>{var n,i,o;if(a.origin!==r.origin)return;let s=a.data;switch(s.kind){case"authorize-ready":{let l=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((n=this._key)===null||n===void 0?void 0:n.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 a;(a=this._idpWindow)===null||a===void 0||a.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 St(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 St(e){await e.remove(G),await e.remove(W),await e.remove(Ka)}var Ma=BigInt(144e11),Ja=!1,Ha={width:576,height:576},$a={width:505,height:705},za="internetcomputer.org";var Je="http://127.0.0.1:5987",Wa="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 Ga=async e=>{let r=new Blob([JSON.stringify(e,wa)],{type:"application/json; charset=utf-8"});return new Uint8Array(await r.arrayBuffer())},zr=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(),Fa)},Wr=()=>typeof window<"u";var Ct=({width:e,height:r})=>{if(!Wr()||y(window)||y(window.top))return;let{top:{innerWidth:t,innerHeight:a}}=window,n=a/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=${n}, left=${i}`};var Gr=class{#e;constructor({domain:r}){this.#e=r}get id(){return"internet_identity"}signInOptions({windowed:r}){let t=()=>{let a=ee.getInstance().get()?.container;if(y(a)||a===!1)return`https://identity.${this.#e??za}`;let n=ee.getInstance().get(),i=h(n)&&h(n?.internetIdentityId)?n.internetIdentityId:Wa,{host:o,protocol:s}=new URL(a===!0?Je:a);return/apple/i.test(navigator?.vendor)?`${s}//${o}?canisterId=${i}`:`${s}//${i}.${o.replace("127.0.0.1","localhost")}`};return{...r!==!1&&{windowOpenerFeatures:Ct(Ha)},identityProvider:t()}}},Ya=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:Ct($a)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#r)}`}}};var Xa=async({identity:e,container:r})=>{let a=h(r)&&r!==!1?r===!0?Je:r:"https://icp-api.io",n=h(r);return await pr.create({identity:e,shouldFetchRootKey:n,host:a})};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 a=r.getPrincipal().toText();if(y(this.#e)||y(this.#e[a])){let n=await Xa({identity:r,...t});return this.#e={...this.#e??{},[a]:n},n}return this.#e[a]}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:a,...n}){let i=`${a}#${t.getPrincipal().toText()}#${r};`;if(y(this.#e)||y(this.#e[i])){let o=await this.createActor({satelliteId:r,identity:t,...n});return this.#e={...this.#e??{},[i]:o},o}return this.#e[i]}reset(){this.#e=null}async createActor({idlFactory:r,satelliteId:t,...a}){let n=await He.getInstance().getAgent(a);return ce.createActor(r,{agent:n,canisterId:t})}};var Yr=class extends Error{},Xr=class extends Error{},Zr=class extends Error{},Qr=class extends Error{},Lr=class extends Error{};var et=()=>$r.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Ut=({error:e,type:r})=>typeof e=="string"?e.includes(r):e instanceof Error?e.message.includes(r):!1;var Za="juno.datastore.error.user.cannot_update";var Qa=async({data:e})=>{try{return await zr(e)}catch(r){console.error("The data parsing has failed, mapping to undefined as a fallback.",r);return}};var Bt=async e=>{let{data:r,version:t,description:a}=e;return{description:N(a),data:await Ga(r),version:N(t)}},It=e=>{let{version:r}=e;return{version:N(r)}},Fr=async({doc:e,key:r})=>{let{owner:t,version:a,description:n,data:i,...o}=e;return{key:r,description:A(n),owner:t.toText(),data:await zr(i),version:A(a),...o}};var La=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 Lr("Invalid list matcher for timestamp",e)}},me=({matcher:e,paginate:r,order:t,owner:a})=>({matcher:y(e)?[]:[{key:N(e.key),description:N(e.description),created_at:La(e.createdAt),updated_at:La(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(a)?void 0:typeof a=="string"?T.fromText(a):a)});var en=({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}),a=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),n=e.Record({field:a,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(n),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)}),M=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)))}),ye=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)}),fe=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:fe}),ae=e.Variant({Heap:e.Null,Stable:e.Null}),q=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),he=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),ne=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(ae),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(he),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:ae,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)}),Ze=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}),Qe=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(Qe),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}),ar=e.Record({matcher:e.Opt(tr)}),nr=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(ae),max_size:e.Opt(e.Nat),read:q,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(he),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([M],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(_)],["query"]),get_auth_config:e.Func([],[e.Opt(w)],["query"]),get_config:e.Func([],[ye],[]),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([ie],[Te],["query"]),init_asset_upload:e.Func([oe],[Y],[]),init_proposal:e.Func([fe],[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],[Ze],["query"]),list_proposals:e.Func([Ve],[rr],["query"]),list_rules:e.Func([f,ar],[nr],["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],[])})},rn=({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}),a=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),n=e.Record({field:a,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(n),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)}),M=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)))}),ye=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)}),fe=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:fe}),ae=e.Variant({Heap:e.Null,Stable:e.Null}),q=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),he=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),ne=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(ae),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(he),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:ae,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)}),Ze=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}),Qe=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(Qe),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}),ar=e.Record({matcher:e.Opt(tr)}),nr=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(ae),max_size:e.Opt(e.Nat),read:q,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(he),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([M],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(_)],[]),get_auth_config:e.Func([],[e.Opt(w)],[]),get_config:e.Func([],[ye],[]),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([ie],[Te],[]),init_asset_upload:e.Func([oe],[Y],[]),init_proposal:e.Func([fe],[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],[Ze],[]),list_proposals:e.Func([Ve],[rr],[]),list_rules:e.Func([f,ar],[nr],[]),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 tn=({satelliteId:e,container:r})=>{let{satelliteId:t}=qt({satelliteId:e}),{container:a}=Dt({container:r});if(h(a)&&a!==!1){let{host:n,protocol:i}=new URL(a===!0?Je:a);return`${i}//${t??"unknown"}.${n.replace("127.0.0.1","localhost")}`}return`https://${t??"unknown"}.icp0.io`},qt=({satelliteId:e})=>h(e)?{satelliteId:e}:ee.getInstance().get()??{satelliteId:void 0},Dt=({container:e})=>h(e)?{container:e}:ee.getInstance().get()??{container:void 0};var F=({satellite:e,options:{certified:r}})=>nn({idlFactory:r?rn:en,actorKey:`stock#${r?"update":"query"}`,...e}),an=({idlFactory:e,...r})=>nn({idlFactory:e,actorKey:"extended#query",...r}),nn=async({satelliteId:e,container:r,...t})=>{let{satelliteId:a}=qt({satelliteId:e});yr(a,"No satellite ID defined. Did you initialize Juno?");let{container:n}=Dt({container:r});return await $e.getInstance().getActor({satelliteId:a,container:n,...t})};var on=async({collection:e,key:r,...t})=>{let{get_doc:a}=await F(t),n=A(await a(e,r));if(!y(n))return Fr({doc:n,key:r})},sn=async({docs:e,...r})=>{let{get_many_docs:t}=await F(r),a=e.map(({collection:o,key:s})=>[o,s]),n=await t(a),i=[];for(let[o,s]of n){let l=A(s);i.push(h(l)?await Fr({key:o,doc:l}):void 0)}return i},cn=async({collection:e,doc:r,...t})=>{let{set_doc:a}=await F(t),{key:n}=r,i=await Bt(r),o=await a(e,n,i);return await Fr({key:n,doc:o})},ln=async({docs:e,...r})=>{let{set_many_docs:t}=await F(r),a=[];for(let{collection:o,doc:s}of e){let{key:l}=s;a.push([o,l,await Bt(s)])}let n=await t(a),i=[];for(let[o,s]of n)i.push(await Fr({key:o,doc:s}));return i},un=async({collection:e,doc:r,...t})=>{let{del_doc:a}=await F(t),{key:n}=r;return a(e,n,It(r))},dn=async({docs:e,...r})=>{let{del_many_docs:t}=await F(r),a=e.map(({collection:n,doc:i})=>[n,i.key,It(i)]);await t(a)},pn=async({collection:e,filter:r,...t})=>{let{del_filtered_docs:a}=await F(t);return a(e,me(r))},_n=async({collection:e,filter:r,...t})=>{let{list_docs:a}=await F(t),{items:n,items_page:i,items_length:o,matches_length:s,matches_pages:l}=await a(e,me(r)),u=[];for(let[p,d]of n){let{data:m,owner:f,description:x,version:B,...M}=d;u.push({key:p,description:A(x),owner:f.toText(),data:await Qa({data:m}),version:A(B),...M})}return{items:u,items_length:o,items_page:A(i),matches_length:s,matches_pages:A(l)}},mn=async({collection:e,filter:r,...t})=>{let{count_docs:a}=await F(t);return a(e,me(r))};var re={certified:!1};var g=e=>h(e)?e:rt()??new ve;var yn=async({satellite:e,options:r,...t})=>{let a=g(e?.identity);return await on({...t,satellite:{...e,identity:a},options:r??re})},Pl=async({satellite:e,options:r,...t})=>{let a=g(e?.identity);return await sn({...t,satellite:{...e,identity:a},options:r??re})},fn=async({satellite:e,...r})=>{let t=g(e?.identity);return await cn({...r,satellite:{...e,identity:t},options:{certified:!0}})},vl=async({satellite:e,...r})=>{let t=g(e?.identity);return await ln({...r,satellite:{...e,identity:t},options:{certified:!0}})},Sl=async({satellite:e,...r})=>{let t=g(e?.identity);return await un({...r,satellite:{...e,identity:t},options:{certified:!0}})},kl=async({satellite:e,...r})=>{let t=g(e?.identity);return await dn({...r,satellite:{...e,identity:t},options:{certified:!0}})},Cl=async({satellite:e,filter:r,...t})=>{let a=g(e?.identity);return await pn({...t,filter:r??{},satellite:{...e,identity:a},options:{certified:!0}})},Ul=async({satellite:e,options:r,filter:t,...a})=>{let n=g(e?.identity);return await _n({...a,filter:t??{},satellite:{...e,identity:n},options:r??re})},Bl=async({satellite:e,options:r,filter:t,...a})=>{let n=g(e?.identity);return await mn({...a,filter:t??{},satellite:{...e,identity:n},options:r??re})};var hn=async e=>{let r=rt();if(y(r))throw new Qr("No identity to initialize the user. Have you initialized Juno?");let t=r.getPrincipal().toText(),a=()=>yn({collection:"#user",key:t}),n=await a();if(h(n))return n;try{return await uo({userId:t,provider:e})}catch(i){if(Ut({error:i,type:Za})){let o=await a();if(h(o))return o}throw i}},uo=({userId:e,...r})=>fn({collection:"#user",doc:{key:e,data:r}});var K,jt=async e=>{if(K=K??await et(),!(await K?.isAuthenticated()??!1))return;let t=await hn(e);Q.getInstance().set(t)},po=e=>new Promise(async(r,t)=>{if(y(K)){t(new Xr("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let a=e?.provider??new Gr({});await K.login({onSuccess:async()=>{await jt(a.id),r()},onError:n=>{if(n===kt){t(new Zr(n));return}t(new Yr(n))},maxTimeToLive:e?.maxTimeToLive??Ma,allowPinAuthentication:e?.allowPin??Ja,...e?.derivationOrigin!==void 0&&{derivationOrigin:e.derivationOrigin},...a.signInOptions({windowed:e?.windowed})})}),Kt=async()=>{await _o(),K=await et()},_o=async()=>{await K?.logout(),K=null,Q.getInstance().reset(),$e.getInstance().reset(),He.getInstance().reset()},rt=()=>K?.getIdentity(),mo=async()=>(K??await et()).getIdentity(),yo=async()=>{let e=Q.getInstance().get();return y(e)||!(await K?.isAuthenticated()??!1)?null:K?.getIdentity()??null};var Tn=e=>{let r=e===!0?"./workers/auth.worker.js":e,t=new Worker(r),a=async()=>{Ot({message:"junoSignOutAuthTimer"}),await Kt()};return t.onmessage=async({data:n})=>{let{msg:i,data:o}=n;switch(i){case"junoSignOutAuthTimer":await a();return;case"junoDelegationRemainingTime":Ot({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},Q.getInstance().subscribe(n=>{if(y(n)){t.postMessage({msg:"junoStopAuthTimer"});return}t.postMessage({msg:"junoStartAuthTimer"})})};var Nn=()=>{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()},gn=()=>{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 lu=async({idlFactory:e,satellite:r})=>{let t=g(r?.identity);return await an({idlFactory:e,...r,identity:t})};var xn=async({asset:{data:e,headers:r,...t},actor:a,progress:n})=>{let{init_asset_upload:i,upload_asset_chunk:o,commit_asset_upload:s}=a,{batch_id:l}=await i(fo(t));n?.onInitiatedBatch();let{chunkIds:u}=await No({data:e,uploadFn:o,batchId:l});n?.onUploadedFileChunks(t.fullPath),await To({commitFn:s,batchId:l,data:e,headers:r,chunkIds:u}),n?.onCommittedBatch()};var fo=({filename:e,collection:r,token:t,fullPath:a,encoding:n,description:i})=>({collection:r,full_path:a,name:e,token:N(t),encoding_type:N(n),description:N(i)}),ho=({batchId:e,chunkIds:r,headers:t,data:a})=>{let n=t.find(([i,o])=>i.toLowerCase()==="content-type")===void 0&&a.type!==void 0&&a.type!==""?[["Content-Type",a.type]]:void 0;return{batch_id:e,chunk_ids:r.map(({chunk_id:i})=>i),headers:[...t,...n??[]]}},To=async({commitFn:e,...r})=>{let t=ho(r);await e(t)},No=async({data:e,uploadFn:r,batchId:t})=>{let a=[],n=Wr()?new Blob([await e.arrayBuffer()]):e,i=0n;for(let s=0;s<n.size;s+=19e5){let l=n.slice(s,s+19e5);a.push({batchId:t,chunk:l,uploadFn:r,orderId:i}),i++}let o=[];for await(let s of go({uploadChunks:a}))o=[...o,...s];return{chunkIds:o}};async function*go({uploadChunks:e,limit:r=12}){for(let t=0;t<e.length;t=t+r){let a=e.slice(t,t+r);yield await Promise.all(a.map(n=>xo(n)))}}var xo=async({batchId:e,chunk:r,uploadFn:t,orderId:a})=>t({batch_id:e,content:new Uint8Array(await r.arrayBuffer()),order_id:N(a)});var On=async({asset:e,...r})=>{let t=await F(r);await xn({actor:t,asset:e})},Rn=async({collection:e,filter:r,...t})=>{let{list_assets:a}=await F(t),{items:n,items_length:i,items_page:o,matches_length:s,matches_pages:l}=await a(e,me(r));return{items:n.map(([u,p])=>p),items_length:i,items_page:A(o),matches_length:s,matches_pages:A(l)}},wn=async({collection:e,filter:r,...t})=>{let{count_assets:a}=await F(t);return a(e,me(r))},Fn=async({collection:e,fullPath:r,...t})=>(await F(t)).del_asset(e,r),En=async({assets:e,satellite:r})=>{let{del_many_assets:t}=await F({satellite:r,options:{certified:!0}}),a=e.map(({collection:n,fullPath:i})=>[n,i]);await t(a)},bn=async({collection:e,filter:r,...t})=>{let{del_filtered_assets:a}=await F(t);return a(e,me(r))},An=async({collection:e,fullPath:r,...t})=>{let{get_asset:a}=await F(t);return A(await a(e,r))},Vn=async({assets:e,...r})=>{let{get_many_assets:t}=await F(r),a=e.map(({collection:i,fullPath:o})=>[i,o]);return(await t(a)).map(([i,o])=>A(o))};var Pn=e=>btoa([...e].map(r=>String.fromCharCode(r)).join(""));var Eu=e=>vn(e),bu=e=>vn({filename:e.data.name,...e}),vn=async({filename:e,data:r,collection:t,headers:a=[],fullPath:n,token:i,satellite:o,encoding:s,description:l})=>{let u=g(o?.identity),p=decodeURI(e),d=n??`/${t}/${p}`,m={...o,identity:u};return await On({asset:{data:r,filename:p,collection:t,token:i,headers:a,fullPath:d,encoding:s,description:l},satellite:m,options:{certified:!0}}),{downloadUrl:Sn({satellite:m,assetKey:{fullPath:d,token:i}}),fullPath:d,name:p}},Au=async({collection:e,filter:r,satellite:t,options:a})=>{let n={...t,identity:g(t?.identity)},{items:i,...o}=await Rn({collection:e,filter:r??{},satellite:n,options:a??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:M})=>{let C=A(u);return{fullPath:l,description:A(m),name:p,downloadUrl:Sn({satellite:n,assetKey:{fullPath:l,token:C}}),token:C,headers:f,encodings:x.reduce((O,[_,{modified:V,sha256:R,total_length:w}])=>({...O,[_]:{modified:V,sha256:Pn(R),total_length:w}}),{}),owner:d.toText(),created_at:B,updated_at:M}});return{items:s,assets:s,...o}},Vu=async({collection:e,filter:r,satellite:t,options:a})=>{let n={...t,identity:g(t?.identity)};return await wn({collection:e,satellite:n,filter:r??{},options:a??re})},Pu=({collection:e,fullPath:r,satellite:t})=>Fn({collection:e,fullPath:r,satellite:{...t,identity:g(t?.identity)},options:{certified:!0}}),vu=({assets:e,satellite:r})=>En({assets:e,satellite:{...r,identity:g(r?.identity)},options:{certified:!0}}),Su=async({collection:e,satellite:r,filter:t})=>{let a={...r,identity:g(r?.identity)};return await bn({collection:e,satellite:a,filter:t??{},options:{certified:!0}})},ku=async({satellite:e,options:r,...t})=>{let a=g(e?.identity);return await An({...t,satellite:{...e,identity:a},options:r??re})},Cu=async({satellite:e,options:r,...t})=>{let a=g(e?.identity);return await Vn({...t,satellite:{...e,identity:a},options:r??re})},Sn=({assetKey:{fullPath:e,token:r},satellite:t})=>{let a={...t,identity:g(t?.identity)};return`${tn(a)}${e}${h(r)?`?token=${r}`:""}`};var Oo=e=>{let r=e?.satelliteId??Nn();yr(r,"Satellite ID is not configured. Juno cannot be initialized.");let t=e?.container??gn();return{satelliteId:r,internetIdentityId:e?.internetIdentityId,workers:e?.workers,container:t}},Mu=e=>Ro(e),Ro=async e=>{let r=Oo(e);ee.getInstance().set(r),await jt();let t=r.workers?.auth!==void 0?Tn(r.workers.auth):void 0;return[...t?[t]:[]]},Ju=e=>Q.getInstance().subscribe(e);export{Qr as InitError,Gr as InternetIdentityProvider,Lr as ListError,Ya as NFIDProvider,Yr as SignInError,Xr as SignInInitError,Zr as SignInUserInterruptError,Ju as authSubscribe,Vu as countAssets,Bl as countDocs,Pu as deleteAsset,Sl as deleteDoc,Su as deleteFilteredAssets,Cl as deleteFilteredDocs,vu as deleteManyAssets,kl as deleteManyDocs,Sn as downloadUrl,ku as getAsset,yn as getDoc,yo as getIdentityOnce,Cu as getManyAssets,Pl as getManyDocs,lu as getSatelliteExtendedActor,Mu as initJuno,Ro as initSatellite,Au as listAssets,Ul as listDocs,fn as setDoc,vl as setManyDocs,po as signIn,Kt as signOut,mo as unsafeIdentity,Eu as uploadBlob,bu as uploadFile};
|
|
16
16
|
/*! Bundled license information:
|
|
17
17
|
|
|
18
18
|
buffer/index.js:
|