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