@junobuild/core 0.0.48 → 0.0.49
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/declarations/satellite/satellite.did.d.ts +17 -3
- package/declarations/satellite/satellite.factory.did.js +23 -6
- package/declarations/satellite/satellite.factory.did.mjs +23 -6
- package/dist/browser/canisterStatus-TBLYKI2M.js +2 -0
- package/dist/browser/{chunk-DAMIJKS3.js → chunk-JAXPYESO.js} +8 -8
- package/dist/browser/{chunk-DAMIJKS3.js.map → chunk-JAXPYESO.js.map} +3 -3
- package/dist/browser/index.js +27 -27
- package/dist/browser/index.js.map +4 -4
- package/dist/declarations/satellite/satellite.did.d.ts +17 -3
- package/dist/declarations/satellite/satellite.factory.did.js +23 -6
- package/dist/declarations/satellite/satellite.factory.did.mjs +23 -6
- package/dist/node/index.mjs +36 -36
- package/dist/node/index.mjs.map +4 -4
- package/dist/types/api/doc.api.d.ts +1 -1
- package/dist/types/api/storage.api.d.ts +3 -3
- package/dist/types/services/doc.services.d.ts +9 -9
- package/dist/types/services/storage.services.d.ts +9 -9
- package/dist/types/types/doc.types.d.ts +1 -0
- package/dist/types/utils/actor.utils.d.ts +1 -1
- package/dist/workers/auth.worker.js +17 -12
- package/dist/workers/auth.worker.js.map +4 -4
- package/package.json +5 -5
- package/declarations/satellite/index.d.ts +0 -45
- package/declarations/satellite/index.js +0 -37
- package/dist/browser/canisterStatus-XBZ7P3SA.js +0 -2
- package/dist/declarations/satellite/index.d.ts +0 -45
- package/dist/declarations/satellite/index.js +0 -37
- /package/dist/browser/{canisterStatus-XBZ7P3SA.js.map → canisterStatus-TBLYKI2M.js.map} +0 -0
package/dist/browser/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import{A as Xe,B as kr,C as At,D as Ur,E as $n,F as lt,G as ut,H as Wn,I as Gn,J as Yn,K as zn,L as Jn,M as Zn,N as pe,O as Xn,P as Qn,R as Kr,a as Cn,b as Yo,c as Ge,d as Fn,e as kn,f as Un,g as Kn,h as Vn,i as A,j as zo,k as ct,l as Mn,m as he,n as Jo,o as Ye,p as M,q as mt,r as ze,s as qn,t as Je,u as Ct,v as Fr,w as jn,x as Ze,y as Qt,z as Hn}from"./chunk-DAMIJKS3.js";var ci=Cn(Le=>{"use strict";Le.byteLength=Do;Le.toByteArray=ts;Le.fromByteArray=ns;var gt=[],nt=[],Io=typeof Uint8Array<"u"?Uint8Array:Array,$r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(qt=0,si=$r.length;qt<si;++qt)gt[qt]=$r[qt],nt[$r.charCodeAt(qt)]=qt;var qt,si;nt[45]=62;nt[95]=63;function ai(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 Do(t){var e=ai(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Lo(t,e,r){return(e+r)*3/4-r}function ts(t){var e,r=ai(t),n=r[0],i=r[1],o=new Io(Lo(t,n,i)),s=0,a=i>0?n-4:n,l;for(l=0;l<a;l+=4)e=nt[t.charCodeAt(l)]<<18|nt[t.charCodeAt(l+1)]<<12|nt[t.charCodeAt(l+2)]<<6|nt[t.charCodeAt(l+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=nt[t.charCodeAt(l)]<<2|nt[t.charCodeAt(l+1)]>>4,o[s++]=e&255),i===1&&(e=nt[t.charCodeAt(l)]<<10|nt[t.charCodeAt(l+1)]<<4|nt[t.charCodeAt(l+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function es(t){return gt[t>>18&63]+gt[t>>12&63]+gt[t>>6&63]+gt[t&63]}function rs(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),i.push(es(n));return i.join("")}function ns(t){for(var e,r=t.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(rs(t,s,s+o>a?a:s+o));return n===1?(e=t[r-1],i.push(gt[e>>2]+gt[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(gt[e>>10]+gt[e>>4&63]+gt[e<<2&63]+"=")),i.join("")}});var vi=Cn(re=>{"use strict";var Wr=ci(),te=zo(),li=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;re.Buffer=u;re.SlowBuffer=ls;re.INSPECT_MAX_BYTES=50;var tr=2147483647;re.kMaxLength=tr;u.TYPED_ARRAY_SUPPORT=is();!u.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function is(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}});Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function St(t){if(t>tr)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Jr(t)}return hi(t,e,r)}u.poolSize=8192;function hi(t,e,r){if(typeof t=="string")return ss(t,e);if(ArrayBuffer.isView(t))return as(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(_t(t,ArrayBuffer)||t&&_t(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(_t(t,SharedArrayBuffer)||t&&_t(t.buffer,SharedArrayBuffer)))return Yr(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return u.from(n,e,r);let i=cs(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}u.from=function(t,e,r){return hi(t,e,r)};Object.setPrototypeOf(u.prototype,Uint8Array.prototype);Object.setPrototypeOf(u,Uint8Array);function pi(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 os(t,e,r){return pi(t),t<=0?St(t):e!==void 0?typeof r=="string"?St(t).fill(e,r):St(t).fill(e):St(t)}u.alloc=function(t,e,r){return os(t,e,r)};function Jr(t){return pi(t),St(t<0?0:Zr(t)|0)}u.allocUnsafe=function(t){return Jr(t)};u.allocUnsafeSlow=function(t){return Jr(t)};function ss(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=yi(t,e)|0,n=St(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Gr(t){let e=t.length<0?0:Zr(t.length)|0,r=St(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function as(t){if(_t(t,Uint8Array)){let e=new Uint8Array(t);return Yr(e.buffer,e.byteOffset,e.byteLength)}return Gr(t)}function Yr(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,u.prototype),n}function cs(t){if(u.isBuffer(t)){let e=Zr(t.length)|0,r=St(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Qr(t.length)?St(0):Gr(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Gr(t.data)}function Zr(t){if(t>=tr)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+tr.toString(16)+" bytes");return t|0}function ls(t){return+t!=t&&(t=0),u.alloc(+t)}u.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==u.prototype};u.compare=function(e,r){if(_t(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),_t(r,Uint8Array)&&(r=u.from(r,r.offset,r.byteLength)),!u.isBuffer(e)||!u.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(e[o]!==r[o]){n=e[o],i=r[o];break}return n<i?-1:i<n?1:0};u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};u.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return u.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=u.allocUnsafe(r),o=0;for(n=0;n<e.length;++n){let s=e[n];if(_t(s,Uint8Array))o+s.length>i.length?(u.isBuffer(s)||(s=u.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(u.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function yi(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||_t(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return zr(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ai(t).length;default:if(i)return n?-1:zr(t).length;e=(""+e).toLowerCase(),i=!0}}u.byteLength=yi;function us(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 xs(this,e,r);case"utf8":case"utf-8":return wi(this,e,r);case"ascii":return gs(this,e,r);case"latin1":case"binary":return _s(this,e,r);case"base64":return ms(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return bs(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}u.prototype._isBuffer=!0;function jt(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}u.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)jt(this,r,r+1);return this};u.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)jt(this,r,r+3),jt(this,r+1,r+2);return this};u.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)jt(this,r,r+7),jt(this,r+1,r+6),jt(this,r+2,r+5),jt(this,r+3,r+4);return this};u.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?wi(this,0,e):us.apply(this,arguments)};u.prototype.toLocaleString=u.prototype.toString;u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:u.compare(this,e)===0};u.prototype.inspect=function(){let e="",r=re.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};li&&(u.prototype[li]=u.prototype.inspect);u.prototype.compare=function(e,r,n,i,o){if(_t(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let s=o-i,a=n-r,l=Math.min(s,a),d=this.slice(i,o),c=e.slice(r,n);for(let f=0;f<l;++f)if(d[f]!==c[f]){s=d[f],a=c[f];break}return s<a?-1:a<s?1:0};function mi(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Qr(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=u.from(e,n)),u.isBuffer(e))return e.length===0?-1:ui(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):ui(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ui(t,e,r,n,i){let o=1,s=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;o=2,s/=2,a/=2,r/=2}function l(c,f){return o===1?c[f]:c.readUInt16BE(f*o)}let d;if(i){let c=-1;for(d=r;d<s;d++)if(l(t,d)===l(e,c===-1?0:d-c)){if(c===-1&&(c=d),d-c+1===a)return c*o}else c!==-1&&(d-=d-c),c=-1}else for(r+a>s&&(r=s-a),d=r;d>=0;d--){let c=!0;for(let f=0;f<a;f++)if(l(t,d+f)!==l(e,f)){c=!1;break}if(c)return d}return-1}u.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};u.prototype.indexOf=function(e,r,n){return mi(this,e,r,n,!0)};u.prototype.lastIndexOf=function(e,r,n){return mi(this,e,r,n,!1)};function ds(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(e.substr(s*2,2),16);if(Qr(a))return s;t[r+s]=a}return s}function fs(t,e,r,n){return er(zr(e,t.length-r),t,r,n)}function hs(t,e,r,n){return er(vs(e),t,r,n)}function ps(t,e,r,n){return er(Ai(e),t,r,n)}function ys(t,e,r,n){return er(Ss(e,t.length-r),t,r,n)}u.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return ds(this,e,r,n);case"utf8":case"utf-8":return fs(this,e,r,n);case"ascii":case"latin1":case"binary":return hs(this,e,r,n);case"base64":return ps(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ys(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ms(t,e,r){return e===0&&r===t.length?Wr.fromByteArray(t):Wr.fromByteArray(t.slice(e,r))}function wi(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let o=t[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let l,d,c,f;switch(a){case 1:o<128&&(s=o);break;case 2:l=t[i+1],(l&192)===128&&(f=(o&31)<<6|l&63,f>127&&(s=f));break;case 3:l=t[i+1],d=t[i+2],(l&192)===128&&(d&192)===128&&(f=(o&15)<<12|(l&63)<<6|d&63,f>2047&&(f<55296||f>57343)&&(s=f));break;case 4:l=t[i+1],d=t[i+2],c=t[i+3],(l&192)===128&&(d&192)===128&&(c&192)===128&&(f=(o&15)<<18|(l&63)<<12|(d&63)<<6|c&63,f>65535&&f<1114112&&(s=f))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return ws(n)}var di=4096;function ws(t){let e=t.length;if(e<=di)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=di));return r}function gs(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function _s(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function xs(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=e;o<r;++o)i+=Rs[t[o]];return i}function bs(t,e,r){let n=t.slice(e,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}u.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,u.prototype),i};function j(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||j(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return i};u.prototype.readUintBE=u.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||j(e,r,this.length);let i=this[e+--r],o=1;for(;r>0&&(o*=256);)i+=this[e+--r]*o;return i};u.prototype.readUint8=u.prototype.readUInt8=function(e,r){return e=e>>>0,r||j(e,1,this.length),this[e]};u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||j(e,2,this.length),this[e]|this[e+1]<<8};u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||j(e,2,this.length),this[e]<<8|this[e+1]};u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||j(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||j(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};u.prototype.readBigUInt64LE=Ft(function(e){e=e>>>0,ee(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ye(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});u.prototype.readBigUInt64BE=Ft(function(e){e=e>>>0,ee(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ye(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});u.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||j(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};u.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||j(e,r,this.length);let i=r,o=1,s=this[e+--i];for(;i>0&&(o*=256);)s+=this[e+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};u.prototype.readInt8=function(e,r){return e=e>>>0,r||j(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};u.prototype.readInt16LE=function(e,r){e=e>>>0,r||j(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};u.prototype.readInt16BE=function(e,r){e=e>>>0,r||j(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};u.prototype.readInt32LE=function(e,r){return e=e>>>0,r||j(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};u.prototype.readInt32BE=function(e,r){return e=e>>>0,r||j(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};u.prototype.readBigInt64LE=Ft(function(e){e=e>>>0,ee(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ye(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});u.prototype.readBigInt64BE=Ft(function(e){e=e>>>0,ee(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ye(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});u.prototype.readFloatLE=function(e,r){return e=e>>>0,r||j(e,4,this.length),te.read(this,e,!0,23,4)};u.prototype.readFloatBE=function(e,r){return e=e>>>0,r||j(e,4,this.length),te.read(this,e,!1,23,4)};u.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||j(e,8,this.length),te.read(this,e,!0,52,8)};u.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||j(e,8,this.length),te.read(this,e,!1,52,8)};function I(t,e,r,n,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;I(this,e,r,n,a,0)}let o=1,s=0;for(this[r]=e&255;++s<n&&(o*=256);)this[r+s]=e/o&255;return r+n};u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;I(this,e,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=e&255;--o>=0&&(s*=256);)this[r+o]=e/s&255;return r+n};u.prototype.writeUint8=u.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||I(this,e,r,1,255,0),this[r]=e&255,r+1};u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||I(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||I(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||I(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||I(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 gi(t,e,r,n,i){Ti(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,r}function _i(t,e,r,n,i){Ti(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o=o>>8,t[r+6]=o,o=o>>8,t[r+5]=o,o=o>>8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s=s>>8,t[r+2]=s,s=s>>8,t[r+1]=s,s=s>>8,t[r]=s,r+8}u.prototype.writeBigUInt64LE=Ft(function(e,r=0){return gi(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});u.prototype.writeBigUInt64BE=Ft(function(e,r=0){return _i(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});u.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let l=Math.pow(2,8*n-1);I(this,e,r,n,l-1,-l)}let o=0,s=1,a=0;for(this[r]=e&255;++o<n&&(s*=256);)e<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};u.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let l=Math.pow(2,8*n-1);I(this,e,r,n,l-1,-l)}let o=n-1,s=1,a=0;for(this[r+o]=e&255;--o>=0&&(s*=256);)e<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};u.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||I(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};u.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||I(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};u.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||I(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};u.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||I(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};u.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||I(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};u.prototype.writeBigInt64LE=Ft(function(e,r=0){return gi(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});u.prototype.writeBigInt64BE=Ft(function(e,r=0){return _i(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function xi(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function bi(t,e,r,n,i){return e=+e,r=r>>>0,i||xi(t,e,r,4,34028234663852886e22,-34028234663852886e22),te.write(t,e,r,n,23,4),r+4}u.prototype.writeFloatLE=function(e,r,n){return bi(this,e,r,!0,n)};u.prototype.writeFloatBE=function(e,r,n){return bi(this,e,r,!1,n)};function Ei(t,e,r,n,i){return e=+e,r=r>>>0,i||xi(t,e,r,8,17976931348623157e292,-17976931348623157e292),te.write(t,e,r,n,52,8),r+8}u.prototype.writeDoubleLE=function(e,r,n){return Ei(this,e,r,!0,n)};u.prototype.writeDoubleBE=function(e,r,n){return Ei(this,e,r,!1,n)};u.prototype.copy=function(e,r,n,i){if(!u.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),o};u.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!u.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let s=e.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=r;o<n;++o)this[o]=e;else{let s=u.isBuffer(e)?e:u.from(e,i),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var Lt={};function Xr(t,e,r){Lt[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Xr("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Xr("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Xr("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=fi(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=fi(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function fi(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 Es(t,e,r){ee(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&ye(e,t.length-(r+1))}function Ti(t,e,r,n,i,o){if(t>r||t<e){let s=typeof e=="bigint"?"n":"",a;throw o>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${r}${s}`,new Lt.ERR_OUT_OF_RANGE("value",a,t)}Es(n,i,o)}function ee(t,e){if(typeof t!="number")throw new Lt.ERR_INVALID_ARG_TYPE(e,"number",t)}function ye(t,e,r){throw Math.floor(t)!==t?(ee(t,r),new Lt.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new Lt.ERR_BUFFER_OUT_OF_BOUNDS:new Lt.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Ts=/[^+/0-9A-Za-z-_]/g;function As(t){if(t=t.split("=")[0],t=t.trim().replace(Ts,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function zr(t,e){e=e||1/0;let r,n=t.length,i=null,o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function vs(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Ss(t,e){let r,n,i,o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function Ai(t){return Wr.toByteArray(As(t))}function er(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function _t(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Qr(t){return t!==t}var Rs=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Ft(t){return typeof BigInt>"u"?Bs:t}function Bs(){throw new Error("BigInt not supported")}});var V=t=>t==null,q=t=>!V(t),Zo=class extends Error{},In=(t,e)=>{if(V(t))throw new Zo(e)},Vr="__bigint__",Mr="__principal__",qr="__uint8array__",Xo=(t,e)=>typeof e=="bigint"?{[Vr]:`${e}`}:q(e)&&e instanceof A?{[Mr]:e.toText()}:q(e)&&e instanceof Uint8Array?{[qr]:Array.from(e)}:e,Qo=(t,e)=>{let r=n=>e[n];return q(e)&&typeof e=="object"&&Vr in e?BigInt(r(Vr)):q(e)&&typeof e=="object"&&Mr in e?A.fromText(r(Mr)):q(e)&&typeof e=="object"&&qr in e?Uint8Array.from(r(qr)):e},$=t=>q(t)?[t]:[],z=t=>t?.[0],Dn=async t=>{let e=new Blob([JSON.stringify(t,Xo)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},Qe=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(),Qo)},Ie=()=>typeof window<"u";var It=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:r})=>r(e))}subscribe(e){let r=Symbol();return this.callbacks.push({id:r,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var vt=class t extends It{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 jr=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var Ln=BigInt(144e11),ti=!1,ei={width:576,height:576},ri={width:505,height:705},ni="internetcomputer.org";var Dt="http://127.0.0.1:5987",ii="rdmx6-jaaaa-aaaaa-aaadq-cai";var wt=class t extends It{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var Hr=({width:t,height:e})=>{if(!Ie()||V(window)||V(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-e/2,o=r/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${o}`};var De=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=wt.getInstance().get()?.container;if(V(n)||n===!1)return`https://identity.${this.#t??ni}`;let i=wt.getInstance().get(),o=q(i)&&q(i?.internetIdentityId)?i.internetIdentityId:ii,{host:s,protocol:a}=new URL(n===!0?Dt:n);return/apple/i.test(navigator?.vendor)?`${a}//${s}?canisterId=${o}`:`${a}//${o}.${s.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:Hr(ei)},identityProvider:r()}}},oi=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:Hr(ri)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};var to=Ge(vi());var rr;(function(t){t[t.SysFatal=1]="SysFatal",t[t.SysTransient=2]="SysTransient",t[t.DestinationInvalid=3]="DestinationInvalid",t[t.CanisterReject=4]="CanisterReject",t[t.CanisterError=5]="CanisterError"})(rr||(rr={}));var Os=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},Ps=new TextEncoder().encode(`
|
|
2
|
-
ic-request`),Rt=class{getPrincipal(){return this._principal||(this._principal=A.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=Os(e,["body"]),i=await Ct(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(Ye(Ps,i))}})}},Bt=class{getPrincipal(){return A.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};var Si=Ge(jn());var me=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let t=new Uint32Array(1);return window.crypto.getRandomValues(t),t[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let t=new Uint32Array(1);return crypto.getRandomValues(t),t[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};var nr;(function(t){t.Call="call"})(nr||(nr={}));function ne(){let t=new ArrayBuffer(16),e=new DataView(t),r=me(),n=me(),i=me(),o=me();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,o),t}var Ns=BigInt(1e6),Cs=60*1e3,Ht=class{constructor(e){let o=BigInt(Math.floor(Date.now()+e-Cs))*Ns/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=o}toCBOR(){return Si.value.u64(this._value.toString(16),16)}toHash(){return Mn(this._value)}};function Ir(t=ne){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}function we(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}var ge=class extends ct{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};var ir=BigInt(4294967295),Dr=BigInt(32);function Ri(t,e=!1){return e?{h:Number(t&ir),l:Number(t>>Dr&ir)}:{h:Number(t>>Dr&ir)|0,l:Number(t&ir)|0}}function Fs(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:o,l:s}=Ri(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]}var ks=(t,e)=>BigInt(t>>>0)<<Dr|BigInt(e>>>0),Us=(t,e,r)=>t>>>r,Ks=(t,e,r)=>t<<32-r|e>>>r,Vs=(t,e,r)=>t>>>r|e<<32-r,Ms=(t,e,r)=>t<<32-r|e>>>r,qs=(t,e,r)=>t<<64-r|e>>>r-32,js=(t,e,r)=>t>>>r-32|e<<64-r,Hs=(t,e)=>e,$s=(t,e)=>t,Ws=(t,e,r)=>t<<r|e>>>32-r,Gs=(t,e,r)=>e<<r|t>>>32-r,Ys=(t,e,r)=>e<<r-32|t>>>64-r,zs=(t,e,r)=>t<<r-32|e>>>64-r;function Js(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var Zs=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Xs=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Qs=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),Is=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,Ds=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),Ls=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;var ta={fromBig:Ri,split:Fs,toBig:ks,shrSH:Us,shrSL:Ks,rotrSH:Vs,rotrSL:Ms,rotrBH:qs,rotrBL:js,rotr32H:Hs,rotr32L:$s,rotlSH:Ws,rotlSL:Gs,rotlBH:Ys,rotlBL:zs,add:Js,add3L:Zs,add3H:Xs,add4L:Qs,add4H:Is,add5H:Ls,add5L:Ds},E=ta;var[ea,ra]=E.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),kt=new Uint32Array(80),Ut=new Uint32Array(80),Lr=class extends Vn{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:l,Eh:d,El:c,Fh:f,Fl:h,Gh:w,Gl:_,Hh:T,Hl:v}=this;return[e,r,n,i,o,s,a,l,d,c,f,h,w,_,T,v]}set(e,r,n,i,o,s,a,l,d,c,f,h,w,_,T,v){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=l|0,this.Eh=d|0,this.El=c|0,this.Fh=f|0,this.Fl=h|0,this.Gh=w|0,this.Gl=_|0,this.Hh=T|0,this.Hl=v|0}process(e,r){for(let m=0;m<16;m++,r+=4)kt[m]=e.getUint32(r),Ut[m]=e.getUint32(r+=4);for(let m=16;m<80;m++){let k=kt[m-15]|0,b=Ut[m-15]|0,D=E.rotrSH(k,b,1)^E.rotrSH(k,b,8)^E.shrSH(k,b,7),pt=E.rotrSL(k,b,1)^E.rotrSL(k,b,8)^E.shrSL(k,b,7),H=kt[m-2]|0,W=Ut[m-2]|0,tt=E.rotrSH(H,W,19)^E.rotrBH(H,W,61)^E.shrSH(H,W,6),et=E.rotrSL(H,W,19)^E.rotrBL(H,W,61)^E.shrSL(H,W,6),ot=E.add4L(pt,et,Ut[m-7],Ut[m-16]),st=E.add4H(ot,D,tt,kt[m-7],kt[m-16]);kt[m]=st|0,Ut[m]=ot|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:l,Dh:d,Dl:c,Eh:f,El:h,Fh:w,Fl:_,Gh:T,Gl:v,Hh:R,Hl:N}=this;for(let m=0;m<80;m++){let k=E.rotrSH(f,h,14)^E.rotrSH(f,h,18)^E.rotrBH(f,h,41),b=E.rotrSL(f,h,14)^E.rotrSL(f,h,18)^E.rotrBL(f,h,41),D=f&w^~f&T,pt=h&_^~h&v,H=E.add5L(N,b,pt,ra[m],Ut[m]),W=E.add5H(H,R,k,D,ea[m],kt[m]),tt=H|0,et=E.rotrSH(n,i,28)^E.rotrBH(n,i,34)^E.rotrBH(n,i,39),ot=E.rotrSL(n,i,28)^E.rotrBL(n,i,34)^E.rotrBL(n,i,39),st=n&o^n&a^o&a,Tt=i&s^i&l^s&l;R=T|0,N=v|0,T=w|0,v=_|0,w=f|0,_=h|0,{h:f,l:h}=E.add(d|0,c|0,W|0,tt|0),d=a|0,c=l|0,a=o|0,l=s|0,o=n|0,s=i|0;let Pt=E.add3L(tt,ot,Tt);n=E.add3H(Pt,W,et,st),i=Pt|0}({h:n,l:i}=E.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=E.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l}=E.add(this.Ch|0,this.Cl|0,a|0,l|0),{h:d,l:c}=E.add(this.Dh|0,this.Dl|0,d|0,c|0),{h:f,l:h}=E.add(this.Eh|0,this.El|0,f|0,h|0),{h:w,l:_}=E.add(this.Fh|0,this.Fl|0,w|0,_|0),{h:T,l:v}=E.add(this.Gh|0,this.Gl|0,T|0,v|0),{h:R,l:N}=E.add(this.Hh|0,this.Hl|0,R|0,N|0),this.set(n,i,o,s,a,l,d,c,f,h,w,_,T,v,R,N)}roundClean(){kt.fill(0),Ut.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var tn=Un(()=>new Lr);var dt=BigInt(0),L=BigInt(1),or=BigInt(2),na=BigInt(8),ia={zip215:!0};function oa(t){let e=Jn(t);return $n(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function sr(t){let e=oa(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:l}=e,d=or<<BigInt(a*8)-L,c=r.create,f=e.uvRatio||((y,p)=>{try{return{isValid:!0,value:r.sqrt(y*r.inv(p))}}catch{return{isValid:!1,value:dt}}}),h=e.adjustScalarBytes||(y=>y),w=e.domain||((y,p,g)=>{if(p.length||g)throw new Error("Contexts/pre-hash are not supported");return y}),_=y=>typeof y=="bigint"&&dt<y,T=(y,p)=>_(y)&&_(p)&&y<p,v=y=>y===dt||T(y,d);function R(y,p){if(T(y,p))return y;throw new Error(`Expected valid scalar < ${p}, got ${typeof y} ${y}`)}function N(y){return y===dt?y:R(y,n)}let m=new Map;function k(y){if(!(y instanceof b))throw new Error("ExtendedPoint expected")}class b{constructor(p,g,x,S){if(this.ex=p,this.ey=g,this.ez=x,this.et=S,!v(p))throw new Error("x required");if(!v(g))throw new Error("y required");if(!v(x))throw new Error("z required");if(!v(S))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof b)throw new Error("extended point not allowed");let{x:g,y:x}=p||{};if(!v(g)||!v(x))throw new Error("invalid affine point");return new b(g,x,L,c(g*x))}static normalizeZ(p){let g=r.invertBatch(p.map(x=>x.ez));return p.map((x,S)=>x.toAffine(g[S])).map(b.fromAffine)}_setWindowSize(p){this._WINDOW_SIZE=p,m.delete(this)}assertValidity(){let{a:p,d:g}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:x,ey:S,ez:B,et:P}=this,C=c(x*x),O=c(S*S),F=c(B*B),K=c(F*F),G=c(C*p),rt=c(F*c(G+O)),Y=c(K+c(g*c(C*O)));if(rt!==Y)throw new Error("bad point: equation left != right (1)");let yt=c(x*S),at=c(B*P);if(yt!==at)throw new Error("bad point: equation left != right (2)")}equals(p){k(p);let{ex:g,ey:x,ez:S}=this,{ex:B,ey:P,ez:C}=p,O=c(g*C),F=c(B*S),K=c(x*C),G=c(P*S);return O===F&&K===G}is0(){return this.equals(b.ZERO)}negate(){return new b(c(-this.ex),this.ey,this.ez,c(-this.et))}double(){let{a:p}=e,{ex:g,ey:x,ez:S}=this,B=c(g*g),P=c(x*x),C=c(or*c(S*S)),O=c(p*B),F=g+x,K=c(c(F*F)-B-P),G=O+P,rt=G-C,Y=O-P,yt=c(K*rt),at=c(G*Y),Zt=c(K*Y),Xt=c(rt*G);return new b(yt,at,Xt,Zt)}add(p){k(p);let{a:g,d:x}=e,{ex:S,ey:B,ez:P,et:C}=this,{ex:O,ey:F,ez:K,et:G}=p;if(g===BigInt(-1)){let Me=c((B-S)*(F+O)),qe=c((B+S)*(F-O)),fe=c(qe-Me);if(fe===dt)return this.double();let je=c(P*or*G),He=c(C*or*K),$e=He+je,We=qe+Me,Nn=He-je,Ho=c($e*fe),$o=c(We*Nn),Wo=c($e*Nn),Go=c(fe*We);return new b(Ho,$o,Go,Wo)}let rt=c(S*O),Y=c(B*F),yt=c(C*x*G),at=c(P*K),Zt=c((S+B)*(O+F)-rt-Y),Xt=at-yt,Ke=at+yt,Ve=c(Y-g*rt),Or=c(Zt*Xt),Pr=c(Ke*Ve),Nr=c(Zt*Ve),Cr=c(Xt*Ke);return new b(Or,Pr,Cr,Nr)}subtract(p){return this.add(p.negate())}wNAF(p){return H.wNAFCached(this,m,p,b.normalizeZ)}multiply(p){let{p:g,f:x}=this.wNAF(R(p,n));return b.normalizeZ([g,x])[0]}multiplyUnsafe(p){let g=N(p);return g===dt?pt:this.equals(pt)||g===L?this:this.equals(D)?this.wNAF(g).p:H.unsafeLadder(this,g)}isSmallOrder(){return this.multiplyUnsafe(l).is0()}isTorsionFree(){return H.unsafeLadder(this,n).is0()}toAffine(p){let{ex:g,ey:x,ez:S}=this,B=this.is0();p==null&&(p=B?na:r.inv(S));let P=c(g*p),C=c(x*p),O=c(S*p);if(B)return{x:dt,y:L};if(O!==L)throw new Error("invZ was invalid");return{x:P,y:C}}clearCofactor(){let{h:p}=e;return p===L?this:this.multiplyUnsafe(p)}static fromHex(p,g=!1){let{d:x,a:S}=e,B=r.BYTES;p=At("pointHex",p,B);let P=p.slice(),C=p[B-1];P[B-1]=C&-129;let O=Xe(P);O===dt||(g?R(O,d):R(O,r.ORDER));let F=c(O*O),K=c(F-L),G=c(x*F-S),{isValid:rt,value:Y}=f(K,G);if(!rt)throw new Error("Point.fromHex: invalid y coordinate");let yt=(Y&L)===L,at=(C&128)!==0;if(!g&&Y===dt&&at)throw new Error("Point.fromHex: x=0 and x_0=1");return at!==yt&&(Y=c(-Y)),b.fromAffine({x:Y,y:O})}static fromPrivateKey(p){return et(p).point}toRawBytes(){let{x:p,y:g}=this.toAffine(),x=kr(g,r.BYTES);return x[x.length-1]|=p&L?128:0,x}toHex(){return Hn(this.toRawBytes())}}b.BASE=new b(e.Gx,e.Gy,L,c(e.Gx*e.Gy)),b.ZERO=new b(dt,L,L,dt);let{BASE:D,ZERO:pt}=b,H=zn(b,a*8);function W(y){return lt(y,n)}function tt(y){return W(Xe(y))}function et(y){let p=a;y=At("private key",y,p);let g=At("hashed private key",o(y),2*p),x=h(g.slice(0,p)),S=g.slice(p,2*p),B=tt(x),P=D.multiply(B),C=P.toRawBytes();return{head:x,prefix:S,scalar:B,point:P,pointBytes:C}}function ot(y){return et(y).pointBytes}function st(y=new Uint8Array,...p){let g=Ur(...p);return tt(o(w(g,At("context",y),!!i)))}function Tt(y,p,g={}){y=At("message",y),i&&(y=i(y));let{prefix:x,scalar:S,pointBytes:B}=et(p),P=st(g.context,x,y),C=D.multiply(P).toRawBytes(),O=st(g.context,C,B,y),F=W(P+O*S);N(F);let K=Ur(C,kr(F,r.BYTES));return At("result",K,a*2)}let Pt=ia;function Nt(y,p,g,x=Pt){let{context:S,zip215:B}=x,P=r.BYTES;y=At("signature",y,2*P),p=At("message",p),i&&(p=i(p));let C=Xe(y.slice(P,2*P)),O,F,K;try{O=b.fromHex(g,B),F=b.fromHex(y.slice(0,P),B),K=D.multiplyUnsafe(C)}catch{return!1}if(!B&&O.isSmallOrder())return!1;let G=st(S,F.toRawBytes(),O.toRawBytes(),p);return F.add(O.multiplyUnsafe(G)).subtract(K).clearCofactor().equals(b.ZERO)}return D._setWindowSize(8),{CURVE:e,getPublicKey:ot,sign:Tt,verify:Nt,ExtendedPoint:b,utils:{getExtendedPublicKey:et,randomPrivateKey:()=>s(r.BYTES),precompute(y=8,p=b.BASE){return p._setWindowSize(y),p.multiply(BigInt(3)),p}}}}var rn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Bi=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),nl=BigInt(0),sa=BigInt(1),en=BigInt(2),aa=BigInt(5),Oi=BigInt(10),ca=BigInt(20),la=BigInt(40),Pi=BigInt(80);function ua(t){let e=rn,n=t*t%e*t%e,i=ut(n,en,e)*n%e,o=ut(i,sa,e)*t%e,s=ut(o,aa,e)*o%e,a=ut(s,Oi,e)*s%e,l=ut(a,ca,e)*a%e,d=ut(l,la,e)*l%e,c=ut(d,Pi,e)*d%e,f=ut(c,Pi,e)*d%e,h=ut(f,Oi,e)*s%e;return{pow_p_5_8:ut(h,en,e)*t%e,b2:n}}function da(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function fa(t,e){let r=rn,n=lt(e*e*e,r),i=lt(n*n*e,r),o=ua(t*i).pow_p_5_8,s=lt(t*n*o,r),a=lt(e*s*s,r),l=s,d=lt(s*Bi,r),c=a===t,f=a===lt(-t,r),h=a===lt(-t*Bi,r);return c&&(s=l),(f||h)&&(s=d),Wn(s,r)&&(s=lt(-s,r)),{isValid:c||f,value:s}}var Ot=Gn(rn,void 0,!0),nn={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ot,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:tn,randomBytes:Kn,adjustScalarBytes:da,uvRatio:fa},Kt=sr(nn);function Ni(t,e,r){if(e.length>255)throw new Error("Context is too big");return kn(Fn("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var il=sr({...nn,domain:Ni}),ol=sr({...nn,domain:Ni,prehash:tn});var ha=(Ot.ORDER+BigInt(3))/BigInt(8),sl=Ot.pow(en,ha),al=Ot.sqrt(Ot.neg(Ot.ONE)),cl=(Ot.ORDER-BigInt(5))/BigInt(8),ll=BigInt(486662);var ul=Yn(Ot,Ot.neg(BigInt(486664)));var dl=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),fl=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),hl=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),pl=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var yl=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Ci=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Z=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},J,_e,Fi,ki,ar=class{constructor(e={}){J.set(this,void 0),_e.set(this,void 0),this[Fi]=this.entries.bind(this),this[ki]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();Ci(this,J,new Map([...r].map(([o,s])=>[o,{value:s,timestamp:i}])),"f"),Ci(this,_e,n,"f")}prune(){let e=Date.now();for(let[r,n]of Z(this,J,"f").entries())e-n.timestamp>Z(this,_e,"f")&&Z(this,J,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return Z(this,J,"f").set(e,n),this}get(e){let r=Z(this,J,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>Z(this,_e,"f")){Z(this,J,"f").delete(e);return}return r.value}}clear(){Z(this,J,"f").clear()}entries(){let e=Z(this,J,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=Z(this,J,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return Z(this,J,"f").keys()}forEach(e,r){for(let[n,i]of Z(this,J,"f").entries())e.call(r,i.value,n,this)}has(e){return Z(this,J,"f").has(e)}delete(e){return Z(this,J,"f").delete(e)}get size(){return Z(this,J,"f").size}};J=new WeakMap,_e=new WeakMap,Fi=Symbol.iterator,ki=Symbol.toStringTag;var Ui=t=>{if(t<=127)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},Ki=(t,e,r)=>{if(r<=127)return t[e]=r,1;if(r<=255)return t[e]=129,t[e+1]=r,2;if(r<=65535)return t[e]=130,t[e+1]=r>>8,t[e+2]=r,3;if(r<=16777215)return t[e]=131,t[e+1]=r>>16,t[e+2]=r>>8,t[e+3]=r,4;throw new Error("Length too long (> 4 bytes)")},on=(t,e)=>{if(t[e]<128)return 1;if(t[e]===128)throw new Error("Invalid length 0");if(t[e]===129)return 2;if(t[e]===130)return 3;if(t[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")},pa=(t,e)=>{let r=on(t,e);if(r===1)return t[e];if(r===2)return t[e+1];if(r===3)return(t[e+1]<<8)+t[e+2];if(r===4)return(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];throw new Error("Length too long (> 4 bytes)")},Vi=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),$t=Uint8Array.from([48,5,6,3,43,101,112]),_l=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function ie(t,e){let r=2+Ui(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,o=new Uint8Array(1+Ui(n)+n);return o[i++]=48,i+=Ki(o,i,n),o.set(e,i),i+=e.byteLength,o[i++]=3,i+=Ki(o,i,t.byteLength+1),o[i++]=0,o.set(new Uint8Array(t),i),o}var xe=(t,e)=>{let r=0,n=(a,l)=>{if(i[r++]!==a)throw new Error("Expected: "+l)},i=new Uint8Array(t);if(n(48,"sequence"),r+=on(i,r),!ze(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let o=pa(i,r)-1;r+=on(i,r),n(0,"0 padding");let s=i.slice(r);if(o!==s.length)throw new Error(`DER payload mismatch: Expected length ${o} actual length ${s.length}`);return s};var Mi=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},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)},cr,lr,be=class t{constructor(e){if(cr.set(this,void 0),lr.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Mi(this,cr,e,"f"),Mi(this,lr,t.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){return ie(e,$t).buffer}static derDecode(e){let r=xe(e,$t);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return qi(this,cr,"f")}get derKey(){return qi(this,lr,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};cr=new WeakMap,lr=new WeakMap;be.RAW_KEY_LENGTH=32;var ji=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},sn,Hi,an,$i,cn=class extends Function{constructor(){return super(),sn.add(this),this.observers=[],new Proxy(this,{apply:(e,r,n)=>ji(e,sn,"m",Hi).call(e,n[0],...n.slice(1))})}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e,...r){this.observers.forEach(n=>n(e,...r))}};sn=new WeakSet,Hi=function(e,...r){this.notify(e,...r)};var ur=class extends cn{constructor(){return super(),an.add(this),new Proxy(this,{apply:(e,r,n)=>ji(e,an,"m",$i).call(e,n[0],...n.slice(1))})}log(e,...r){this.notify({message:e,level:"info"},...r)}warn(e,...r){this.notify({message:e,level:"warn"},...r)}error(e,r,...n){this.notify({message:e,level:"error",error:r},...n)}};an=new WeakSet,$i=function(e,...r){this.log(e,...r)};var Wi=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},U=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)},Ee,fr,oe,se,Wt,Gt,Gi,hr,xt;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(xt||(xt={}));var dr=5*60*1e3,ma="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";var wa="ic0.app",ga=".ic0.app",_a="icp0.io",xa=".icp0.io",ba="icp-api.io",Ea=".icp-api.io",Te=class extends ct{constructor(e){super(e),this.message=e}},ae=class extends ct{constructor(e){super(e),this.message=e}};function Ta(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new Te("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof globalThis<"u")if(globalThis.fetch)t=globalThis.fetch.bind(globalThis);else throw new Te("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(t=self.fetch.bind(self));if(t)return t;throw new Te("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var Ae=class t{constructor(e={}){var r;if(Ee.add(this),this.rootKey=mt(ma),this._timeDiffMsecs=0,this._rootKeyFetched=!1,this._isAgent=!0,fr.set(this,0),this.log=new ur,oe.set(this,[]),se.set(this,[]),Wt.set(this,new ar({expirationTime:5*60*1e3})),Gt.set(this,!0),hr.set(this,(n,i)=>{if(U(this,Gt,"f")===!1)return n;if(!i)throw new pe("Invalid signature from replica signed query: no matching node key found.");let{status:o,signatures:s=[],requestId:a}=n,l=new TextEncoder().encode("\vic-response");for(let d of s){let{timestamp:c,identity:f}=d,h=A.fromUint8Array(f).toText(),w;if(o==="replied"){let{reply:N}=n;w=Fr({status:o,reply:N,timestamp:BigInt(c),request_id:a})}else if(o==="rejected"){let{reject_code:N,reject_message:m,error_code:k}=n;w=Fr({status:o,reject_code:N,reject_message:m,error_code:k,timestamp:BigInt(c),request_id:a})}else throw new Error(`Unknown status: ${o}`);let _=Ye(l,new Uint8Array(w)),T=i?.nodeKeys.get(h);if(!T)throw new pe("Invalid signature from replica signed query: no matching node key found.");let v=be.fromDer(T).rawKey;if(Kt.verify(d.signature,new Uint8Array(_),new Uint8Array(v)))return n;throw new pe(`Invalid signature from replica ${h} signed query.`)}return n}),e.source){if(!(e.source instanceof t))throw new Error("An Agent's source can only be another HttpAgent");this._identity=e.source._identity,this._fetch=e.source._fetch,this._host=e.source._host,this._credentials=e.source._credentials}else this._fetch=e.fetch||Ta()||fetch.bind(globalThis),this._fetchOptions=e.fetchOptions,this._callOptions=e.callOptions;if(e.host!==void 0)!e.host.match(/^[a-z]+:/)&&typeof window<"u"?this._host=new URL(window.location.protocol+"//"+e.host):this._host=new URL(e.host);else if(e.source!==void 0)this._host=e.source._host;else{let n=typeof window<"u"?window.location:void 0;n||(this._host=new URL("https://icp-api.io"),this.log.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."));let i=["ic0.app","icp0.io","127.0.0.1","localhost"],o=[".github.dev",".gitpod.io"],s=n?.hostname,a;s&&typeof s=="string"&&(o.some(l=>s.endsWith(l))?a=s:a=i.find(l=>s.endsWith(l))),n&&a?this._host=new URL(`${n.protocol}//${a}${n.port?":"+n.port:""}`):(this._host=new URL("https://icp-api.io"),this.log.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."))}if(e.verifyQuerySignatures!==void 0&&Wi(this,Gt,e.verifyQuerySignatures,"f"),this._retryTimes=(r=e.retryTimes)!==null&&r!==void 0?r:3,this._host.hostname.endsWith(ga)?this._host.hostname=wa:this._host.hostname.endsWith(xa)?this._host.hostname=_a:this._host.hostname.endsWith(Ea)&&(this._host.hostname=ba),e.credentials){let{name:n,password:i}=e.credentials;this._credentials=`${n}${i?":"+i:""}`}this._identity=Promise.resolve(e.identity||new Bt),this.addTransform("update",Ir(ne)),e.useQueryNonces&&this.addTransform("query",Ir(ne)),e.logToConsole&&this.log.subscribe(n=>{n.level==="error"?console.error(n.message):n.level==="warn"?console.warn(n.message):console.log(n.message)})}get waterMark(){return U(this,fr,"f")}isLocal(){let e=this._host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,r,n=r.priority||0){if(e==="update"){let i=U(this,se,"f").findIndex(o=>(o.priority||0)<n);U(this,se,"f").splice(i>=0?i:U(this,se,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=U(this,oe,"f").findIndex(o=>(o.priority||0)<n);U(this,oe,"f").splice(i>=0?i:U(this,oe,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!this._identity)throw new ae("This identity has expired due this application's security policy. Please refresh your authentication.");return(await this._identity).getPrincipal()}async call(e,r,n){let i=await(n!==void 0?await n:await this._identity);if(!i)throw new ae("This identity has expired due this application's security policy. Please refresh your authentication.");let o=A.from(e),s=r.effectiveCanisterId?A.from(r.effectiveCanisterId):o,a=i.getPrincipal()||A.anonymous(),l=new Ht(dr);Math.abs(this._timeDiffMsecs)>1e3*30&&(l=new Ht(dr+this._timeDiffMsecs));let d={request_type:nr.Call,canister_id:o,method_name:r.methodName,arg:r.arg,sender:a,ingress_expiry:l},c=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"call",body:d});c=await i.transformRequest(c);let f=Ze(c.body);this.log(`fetching "/api/v2/canister/${s.toText()}/call" with request:`,c);let h=this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${s.toText()}/call`,this._host),Object.assign(Object.assign(Object.assign({},this._callOptions),c.request),{body:f}))),[w,_]=await Promise.all([h,Ct(d)]),T=await w.arrayBuffer(),v=w.status===200&&T.byteLength>0?Qt(T):null;return{requestId:_,response:{ok:w.ok,status:w.status,statusText:w.statusText,body:v,headers:we(w.headers)}}}async _requestAndRetry(e,r=0){let n;try{n=await e()}catch(s){if(this._retryTimes>r)return this.log.warn(`Caught exception while attempting to make request:
|
|
3
|
-
${
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
${
|
|
15
|
-
|
|
16
|
-
Request ID: ${
|
|
1
|
+
import{A as rr,B as Qr,C as Nt,D as Ir,E as ii,F as lt,G as ut,H as oi,I as si,J as ai,K as ci,L as li,M as ui,N as be,O as di,P as fi,R as Dr,a as Xn,b as ss,c as Ie,d as Zn,e as Qn,f as In,g as Dn,h as Ln,i as A,j as as,k as tt,l as ti,m as xe,n as cs,o as De,p as K,q as gt,r as Le,s as ei,t as tr,u as Mt,v as Zr,w as ri,x as er,y as ee,z as ni}from"./chunk-JAXPYESO.js";var Ai=Xn(sr=>{"use strict";sr.byteLength=hs;sr.toByteArray=ms;sr.fromByteArray=gs;var xt=[],ot=[],fs=typeof Uint8Array<"u"?Uint8Array:Array,on="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Wt=0,Ei=on.length;Wt<Ei;++Wt)xt[Wt]=on[Wt],ot[on.charCodeAt(Wt)]=Wt;var Wt,Ei;ot[45]=62;ot[95]=63;function Ti(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 hs(t){var e=Ti(t),r=e[0],n=e[1];return(r+n)*3/4-n}function ps(t,e,r){return(e+r)*3/4-r}function ms(t){var e,r=Ti(t),n=r[0],i=r[1],o=new fs(ps(t,n,i)),s=0,a=i>0?n-4:n,l;for(l=0;l<a;l+=4)e=ot[t.charCodeAt(l)]<<18|ot[t.charCodeAt(l+1)]<<12|ot[t.charCodeAt(l+2)]<<6|ot[t.charCodeAt(l+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=ot[t.charCodeAt(l)]<<2|ot[t.charCodeAt(l+1)]>>4,o[s++]=e&255),i===1&&(e=ot[t.charCodeAt(l)]<<10|ot[t.charCodeAt(l+1)]<<4|ot[t.charCodeAt(l+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function ys(t){return xt[t>>18&63]+xt[t>>12&63]+xt[t>>6&63]+xt[t&63]}function ws(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),i.push(ys(n));return i.join("")}function gs(t){for(var e,r=t.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(ws(t,s,s+o>a?a:s+o));return n===1?(e=t[r-1],i.push(xt[e>>2]+xt[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(xt[e>>10]+xt[e>>4&63]+xt[e<<2&63]+"=")),i.join("")}});var Hi=Xn(ae=>{"use strict";var sn=Ai(),oe=as(),vi=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ae.Buffer=d;ae.SlowBuffer=As;ae.INSPECT_MAX_BYTES=50;var ar=2147483647;ae.kMaxLength=ar;d.TYPED_ARRAY_SUPPORT=_s();!d.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function _s(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}});Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function Ct(t){if(t>ar)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,d.prototype),e}function d(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return un(t)}return Oi(t,e,r)}d.poolSize=8192;function Oi(t,e,r){if(typeof t=="string")return bs(t,e);if(ArrayBuffer.isView(t))return Es(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(bt(t,ArrayBuffer)||t&&bt(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(bt(t,SharedArrayBuffer)||t&&bt(t.buffer,SharedArrayBuffer)))return cn(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return d.from(n,e,r);let i=Ts(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return d.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}d.from=function(t,e,r){return Oi(t,e,r)};Object.setPrototypeOf(d.prototype,Uint8Array.prototype);Object.setPrototypeOf(d,Uint8Array);function Ni(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function xs(t,e,r){return Ni(t),t<=0?Ct(t):e!==void 0?typeof r=="string"?Ct(t).fill(e,r):Ct(t).fill(e):Ct(t)}d.alloc=function(t,e,r){return xs(t,e,r)};function un(t){return Ni(t),Ct(t<0?0:dn(t)|0)}d.allocUnsafe=function(t){return un(t)};d.allocUnsafeSlow=function(t){return un(t)};function bs(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!d.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=Pi(t,e)|0,n=Ct(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function an(t){let e=t.length<0?0:dn(t.length)|0,r=Ct(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Es(t){if(bt(t,Uint8Array)){let e=new Uint8Array(t);return cn(e.buffer,e.byteOffset,e.byteLength)}return an(t)}function cn(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,d.prototype),n}function Ts(t){if(d.isBuffer(t)){let e=dn(t.length)|0,r=Ct(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||hn(t.length)?Ct(0):an(t);if(t.type==="Buffer"&&Array.isArray(t.data))return an(t.data)}function dn(t){if(t>=ar)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ar.toString(16)+" bytes");return t|0}function As(t){return+t!=t&&(t=0),d.alloc(+t)}d.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==d.prototype};d.compare=function(e,r){if(bt(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),bt(r,Uint8Array)&&(r=d.from(r,r.offset,r.byteLength)),!d.isBuffer(e)||!d.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(e[o]!==r[o]){n=e[o],i=r[o];break}return n<i?-1:i<n?1:0};d.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};d.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return d.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=d.allocUnsafe(r),o=0;for(n=0;n<e.length;++n){let s=e[n];if(bt(s,Uint8Array))o+s.length>i.length?(d.isBuffer(s)||(s=d.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(d.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function Pi(t,e){if(d.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||bt(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return ln(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return ji(t).length;default:if(i)return n?-1:ln(t).length;e=(""+e).toLowerCase(),i=!0}}d.byteLength=Pi;function vs(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 Us(this,e,r);case"utf8":case"utf-8":return ki(this,e,r);case"ascii":return ks(this,e,r);case"latin1":case"binary":return Fs(this,e,r);case"base64":return Ps(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ms(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}d.prototype._isBuffer=!0;function Gt(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}d.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)Gt(this,r,r+1);return this};d.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)Gt(this,r,r+3),Gt(this,r+1,r+2);return this};d.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)Gt(this,r,r+7),Gt(this,r+1,r+6),Gt(this,r+2,r+5),Gt(this,r+3,r+4);return this};d.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?ki(this,0,e):vs.apply(this,arguments)};d.prototype.toLocaleString=d.prototype.toString;d.prototype.equals=function(e){if(!d.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:d.compare(this,e)===0};d.prototype.inspect=function(){let e="",r=ae.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};vi&&(d.prototype[vi]=d.prototype.inspect);d.prototype.compare=function(e,r,n,i,o){if(bt(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),!d.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let s=o-i,a=n-r,l=Math.min(s,a),u=this.slice(i,o),c=e.slice(r,n);for(let f=0;f<l;++f)if(u[f]!==c[f]){s=u[f],a=c[f];break}return s<a?-1:a<s?1:0};function Ci(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,hn(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=d.from(e,n)),d.isBuffer(e))return e.length===0?-1:Si(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):Si(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Si(t,e,r,n,i){let o=1,s=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;o=2,s/=2,a/=2,r/=2}function l(c,f){return o===1?c[f]:c.readUInt16BE(f*o)}let u;if(i){let c=-1;for(u=r;u<s;u++)if(l(t,u)===l(e,c===-1?0:u-c)){if(c===-1&&(c=u),u-c+1===a)return c*o}else c!==-1&&(u-=u-c),c=-1}else for(r+a>s&&(r=s-a),u=r;u>=0;u--){let c=!0;for(let f=0;f<a;f++)if(l(t,u+f)!==l(e,f)){c=!1;break}if(c)return u}return-1}d.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};d.prototype.indexOf=function(e,r,n){return Ci(this,e,r,n,!0)};d.prototype.lastIndexOf=function(e,r,n){return Ci(this,e,r,n,!1)};function Ss(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(e.substr(s*2,2),16);if(hn(a))return s;t[r+s]=a}return s}function Rs(t,e,r,n){return cr(ln(e,t.length-r),t,r,n)}function Bs(t,e,r,n){return cr(js(e),t,r,n)}function Os(t,e,r,n){return cr(ji(e),t,r,n)}function Ns(t,e,r,n){return cr(Hs(e,t.length-r),t,r,n)}d.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return Ss(this,e,r,n);case"utf8":case"utf-8":return Rs(this,e,r,n);case"ascii":case"latin1":case"binary":return Bs(this,e,r,n);case"base64":return Os(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ns(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ps(t,e,r){return e===0&&r===t.length?sn.fromByteArray(t):sn.fromByteArray(t.slice(e,r))}function ki(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let o=t[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let l,u,c,f;switch(a){case 1:o<128&&(s=o);break;case 2:l=t[i+1],(l&192)===128&&(f=(o&31)<<6|l&63,f>127&&(s=f));break;case 3:l=t[i+1],u=t[i+2],(l&192)===128&&(u&192)===128&&(f=(o&15)<<12|(l&63)<<6|u&63,f>2047&&(f<55296||f>57343)&&(s=f));break;case 4:l=t[i+1],u=t[i+2],c=t[i+3],(l&192)===128&&(u&192)===128&&(c&192)===128&&(f=(o&15)<<18|(l&63)<<12|(u&63)<<6|c&63,f>65535&&f<1114112&&(s=f))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return Cs(n)}var Ri=4096;function Cs(t){let e=t.length;if(e<=Ri)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Ri));return r}function ks(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Fs(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Us(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=e;o<r;++o)i+=$s[t[o]];return i}function Ms(t,e,r){let n=t.slice(e,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}d.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,d.prototype),i};function H(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return i};d.prototype.readUintBE=d.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=this[e+--r],o=1;for(;r>0&&(o*=256);)i+=this[e+--r]*o;return i};d.prototype.readUint8=d.prototype.readUInt8=function(e,r){return e=e>>>0,r||H(e,1,this.length),this[e]};d.prototype.readUint16LE=d.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||H(e,2,this.length),this[e]|this[e+1]<<8};d.prototype.readUint16BE=d.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||H(e,2,this.length),this[e]<<8|this[e+1]};d.prototype.readUint32LE=d.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||H(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};d.prototype.readUint32BE=d.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||H(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};d.prototype.readBigUInt64LE=Vt(function(e){e=e>>>0,se(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ee(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});d.prototype.readBigUInt64BE=Vt(function(e){e=e>>>0,se(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ee(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});d.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};d.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=r,o=1,s=this[e+--i];for(;i>0&&(o*=256);)s+=this[e+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};d.prototype.readInt8=function(e,r){return e=e>>>0,r||H(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};d.prototype.readInt16LE=function(e,r){e=e>>>0,r||H(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};d.prototype.readInt16BE=function(e,r){e=e>>>0,r||H(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};d.prototype.readInt32LE=function(e,r){return e=e>>>0,r||H(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};d.prototype.readInt32BE=function(e,r){return e=e>>>0,r||H(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};d.prototype.readBigInt64LE=Vt(function(e){e=e>>>0,se(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ee(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});d.prototype.readBigInt64BE=Vt(function(e){e=e>>>0,se(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ee(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});d.prototype.readFloatLE=function(e,r){return e=e>>>0,r||H(e,4,this.length),oe.read(this,e,!0,23,4)};d.prototype.readFloatBE=function(e,r){return e=e>>>0,r||H(e,4,this.length),oe.read(this,e,!1,23,4)};d.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||H(e,8,this.length),oe.read(this,e,!0,52,8)};d.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||H(e,8,this.length),oe.read(this,e,!1,52,8)};function D(t,e,r,n,i,o){if(!d.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;D(this,e,r,n,a,0)}let o=1,s=0;for(this[r]=e&255;++s<n&&(o*=256);)this[r+s]=e/o&255;return r+n};d.prototype.writeUintBE=d.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;D(this,e,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=e&255;--o>=0&&(s*=256);)this[r+o]=e/s&255;return r+n};d.prototype.writeUint8=d.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||D(this,e,r,1,255,0),this[r]=e&255,r+1};d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||D(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||D(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||D(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||D(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function Fi(t,e,r,n,i){qi(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,r}function Ui(t,e,r,n,i){qi(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o=o>>8,t[r+6]=o,o=o>>8,t[r+5]=o,o=o>>8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s=s>>8,t[r+2]=s,s=s>>8,t[r+1]=s,s=s>>8,t[r]=s,r+8}d.prototype.writeBigUInt64LE=Vt(function(e,r=0){return Fi(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});d.prototype.writeBigUInt64BE=Vt(function(e,r=0){return Ui(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});d.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let l=Math.pow(2,8*n-1);D(this,e,r,n,l-1,-l)}let o=0,s=1,a=0;for(this[r]=e&255;++o<n&&(s*=256);)e<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};d.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let l=Math.pow(2,8*n-1);D(this,e,r,n,l-1,-l)}let o=n-1,s=1,a=0;for(this[r+o]=e&255;--o>=0&&(s*=256);)e<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};d.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||D(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};d.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||D(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};d.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||D(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};d.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||D(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};d.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||D(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};d.prototype.writeBigInt64LE=Vt(function(e,r=0){return Fi(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});d.prototype.writeBigInt64BE=Vt(function(e,r=0){return Ui(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Mi(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Vi(t,e,r,n,i){return e=+e,r=r>>>0,i||Mi(t,e,r,4,34028234663852886e22,-34028234663852886e22),oe.write(t,e,r,n,23,4),r+4}d.prototype.writeFloatLE=function(e,r,n){return Vi(this,e,r,!0,n)};d.prototype.writeFloatBE=function(e,r,n){return Vi(this,e,r,!1,n)};function Ki(t,e,r,n,i){return e=+e,r=r>>>0,i||Mi(t,e,r,8,17976931348623157e292,-17976931348623157e292),oe.write(t,e,r,n,52,8),r+8}d.prototype.writeDoubleLE=function(e,r,n){return Ki(this,e,r,!0,n)};d.prototype.writeDoubleBE=function(e,r,n){return Ki(this,e,r,!1,n)};d.prototype.copy=function(e,r,n,i){if(!d.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),o};d.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!d.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let s=e.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=r;o<n;++o)this[o]=e;else{let s=d.isBuffer(e)?e:d.from(e,i),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var ie={};function fn(t,e,r){ie[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}fn("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);fn("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);fn("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=Bi(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Bi(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Bi(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 Vs(t,e,r){se(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Ee(e,t.length-(r+1))}function qi(t,e,r,n,i,o){if(t>r||t<e){let s=typeof e=="bigint"?"n":"",a;throw o>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${r}${s}`,new ie.ERR_OUT_OF_RANGE("value",a,t)}Vs(n,i,o)}function se(t,e){if(typeof t!="number")throw new ie.ERR_INVALID_ARG_TYPE(e,"number",t)}function Ee(t,e,r){throw Math.floor(t)!==t?(se(t,r),new ie.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new ie.ERR_BUFFER_OUT_OF_BOUNDS:new ie.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Ks=/[^+/0-9A-Za-z-_]/g;function qs(t){if(t=t.split("=")[0],t=t.trim().replace(Ks,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function ln(t,e){e=e||1/0;let r,n=t.length,i=null,o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function js(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Hs(t,e){let r,n,i,o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function ji(t){return sn.toByteArray(qs(t))}function cr(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function bt(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function hn(t){return t!==t}var $s=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Vt(t){return typeof BigInt>"u"?Ws:t}function Ws(){throw new Error("BigInt not supported")}});var V=t=>t==null,q=t=>!V(t),ls=class extends Error{},hi=(t,e)=>{if(V(t))throw new ls(e)},Lr="__bigint__",tn="__principal__",en="__uint8array__",us=(t,e)=>typeof e=="bigint"?{[Lr]:`${e}`}:q(e)&&e instanceof A?{[tn]:e.toText()}:q(e)&&e instanceof Uint8Array?{[en]:Array.from(e)}:e,ds=(t,e)=>{let r=n=>e[n];return q(e)&&typeof e=="object"&&Lr in e?BigInt(r(Lr)):q(e)&&typeof e=="object"&&tn in e?A.fromText(r(tn)):q(e)&&typeof e=="object"&&en in e?Uint8Array.from(r(en)):e},W=t=>q(t)?[t]:[],j=t=>t?.[0],pi=async t=>{let e=new Blob([JSON.stringify(t,us)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},nr=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(),ds)},ir=()=>typeof window<"u";var re=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:r})=>r(e))}subscribe(e){let r=Symbol();return this.callbacks.push({id:r,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var Pt=class t extends re{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let r=super.subscribe(e);return e(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var rn=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var mi=BigInt(144e11),yi=!1,wi={width:576,height:576},gi={width:505,height:705},_i="internetcomputer.org";var ne="http://127.0.0.1:5987",xi="rdmx6-jaaaa-aaaaa-aaadq-cai";var _t=class t extends re{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var nn=({width:t,height:e})=>{if(!ir()||V(window)||V(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-e/2,o=r/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${o}`};var or=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=_t.getInstance().get()?.container;if(V(n)||n===!1)return`https://identity.${this.#t??_i}`;let i=_t.getInstance().get(),o=q(i)&&q(i?.internetIdentityId)?i.internetIdentityId:xi,{host:s,protocol:a}=new URL(n===!0?ne:n);return/apple/i.test(navigator?.vendor)?`${a}//${s}?canisterId=${o}`:`${a}//${o}.${s.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:nn(wi)},identityProvider:r()}}},bi=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:nn(gi)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};var yo=Ie(Hi());var lr;(function(t){t[t.SysFatal=1]="SysFatal",t[t.SysTransient=2]="SysTransient",t[t.DestinationInvalid=3]="DestinationInvalid",t[t.CanisterReject=4]="CanisterReject",t[t.CanisterError=5]="CanisterError"})(lr||(lr={}));var Gs=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},Ys=new TextEncoder().encode(`
|
|
2
|
+
ic-request`),kt=class{getPrincipal(){return this._principal||(this._principal=A.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=Gs(e,["body"]),i=await Mt(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(De(Ys,i))}})}},Ft=class{getPrincipal(){return A.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};var $i=Ie(ri());var Te=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let t=new Uint32Array(1);return window.crypto.getRandomValues(t),t[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let t=new Uint32Array(1);return crypto.getRandomValues(t),t[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};var ur;(function(t){t.Call="call"})(ur||(ur={}));function ce(){let t=new ArrayBuffer(16),e=new DataView(t),r=Te(),n=Te(),i=Te(),o=Te();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,o),t}var zs=BigInt(1e6),Js=60*1e3,Yt=class{constructor(e){let o=BigInt(Math.floor(Date.now()+e-Js))*zs/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=o}toCBOR(){return $i.value.u64(this._value.toString(16),16)}toHash(){return ti(this._value)}};function pn(t=ce){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}function Ae(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}var ve=class extends tt{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};var dr=BigInt(4294967295),mn=BigInt(32);function Wi(t,e=!1){return e?{h:Number(t&dr),l:Number(t>>mn&dr)}:{h:Number(t>>mn&dr)|0,l:Number(t&dr)|0}}function Xs(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:o,l:s}=Wi(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]}var Zs=(t,e)=>BigInt(t>>>0)<<mn|BigInt(e>>>0),Qs=(t,e,r)=>t>>>r,Is=(t,e,r)=>t<<32-r|e>>>r,Ds=(t,e,r)=>t>>>r|e<<32-r,Ls=(t,e,r)=>t<<32-r|e>>>r,ta=(t,e,r)=>t<<64-r|e>>>r-32,ea=(t,e,r)=>t>>>r-32|e<<64-r,ra=(t,e)=>e,na=(t,e)=>t,ia=(t,e,r)=>t<<r|e>>>32-r,oa=(t,e,r)=>e<<r|t>>>32-r,sa=(t,e,r)=>e<<r-32|t>>>64-r,aa=(t,e,r)=>t<<r-32|e>>>64-r;function ca(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var la=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),ua=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,da=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),fa=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,ha=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),pa=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;var ma={fromBig:Wi,split:Xs,toBig:Zs,shrSH:Qs,shrSL:Is,rotrSH:Ds,rotrSL:Ls,rotrBH:ta,rotrBL:ea,rotr32H:ra,rotr32L:na,rotlSH:ia,rotlSL:oa,rotlBH:sa,rotlBL:aa,add:ca,add3L:la,add3H:ua,add4L:da,add4H:fa,add5H:pa,add5L:ha},E=ma;var[ya,wa]=E.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Kt=new Uint32Array(80),qt=new Uint32Array(80),yn=class extends Ln{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:l,Eh:u,El:c,Fh:f,Fl:p,Gh:_,Gl:m,Hh:S,Hl:T}=this;return[e,r,n,i,o,s,a,l,u,c,f,p,_,m,S,T]}set(e,r,n,i,o,s,a,l,u,c,f,p,_,m,S,T){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=l|0,this.Eh=u|0,this.El=c|0,this.Fh=f|0,this.Fl=p|0,this.Gh=_|0,this.Gl=m|0,this.Hh=S|0,this.Hl=T|0}process(e,r){for(let y=0;y<16;y++,r+=4)Kt[y]=e.getUint32(r),qt[y]=e.getUint32(r+=4);for(let y=16;y<80;y++){let U=Kt[y-15]|0,x=qt[y-15]|0,L=E.rotrSH(U,x,1)^E.rotrSH(U,x,8)^E.shrSH(U,x,7),mt=E.rotrSL(U,x,1)^E.rotrSL(U,x,8)^E.shrSL(U,x,7),$=Kt[y-2]|0,G=qt[y-2]|0,rt=E.rotrSH($,G,19)^E.rotrBH($,G,61)^E.shrSH($,G,6),nt=E.rotrSL($,G,19)^E.rotrBL($,G,61)^E.shrSL($,G,6),yt=E.add4L(mt,nt,qt[y-7],qt[y-16]),at=E.add4H(yt,L,rt,Kt[y-7],Kt[y-16]);Kt[y]=at|0,qt[y]=yt|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:l,Dh:u,Dl:c,Eh:f,El:p,Fh:_,Fl:m,Gh:S,Gl:T,Hh:R,Hl:C}=this;for(let y=0;y<80;y++){let U=E.rotrSH(f,p,14)^E.rotrSH(f,p,18)^E.rotrBH(f,p,41),x=E.rotrSL(f,p,14)^E.rotrSL(f,p,18)^E.rotrBL(f,p,41),L=f&_^~f&S,mt=p&m^~p&T,$=E.add5L(C,x,mt,wa[y],qt[y]),G=E.add5H($,R,U,L,ya[y],Kt[y]),rt=$|0,nt=E.rotrSH(n,i,28)^E.rotrBH(n,i,34)^E.rotrBH(n,i,39),yt=E.rotrSL(n,i,28)^E.rotrBL(n,i,34)^E.rotrBL(n,i,39),at=n&o^n&a^o&a,Bt=i&s^i&l^s&l;R=S|0,C=T|0,S=_|0,T=m|0,_=f|0,m=p|0,{h:f,l:p}=E.add(u|0,c|0,G|0,rt|0),u=a|0,c=l|0,a=o|0,l=s|0,o=n|0,s=i|0;let Ot=E.add3L(rt,yt,Bt);n=E.add3H(Ot,G,nt,at),i=Ot|0}({h:n,l:i}=E.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=E.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l}=E.add(this.Ch|0,this.Cl|0,a|0,l|0),{h:u,l:c}=E.add(this.Dh|0,this.Dl|0,u|0,c|0),{h:f,l:p}=E.add(this.Eh|0,this.El|0,f|0,p|0),{h:_,l:m}=E.add(this.Fh|0,this.Fl|0,_|0,m|0),{h:S,l:T}=E.add(this.Gh|0,this.Gl|0,S|0,T|0),{h:R,l:C}=E.add(this.Hh|0,this.Hl|0,R|0,C|0),this.set(n,i,o,s,a,l,u,c,f,p,_,m,S,T,R,C)}roundClean(){Kt.fill(0),qt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var wn=In(()=>new yn);var dt=BigInt(0),et=BigInt(1),fr=BigInt(2),ga=BigInt(8),_a={zip215:!0};function xa(t){let e=li(t);return ii(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function hr(t){let e=xa(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:l}=e,u=fr<<BigInt(a*8)-et,c=r.create,f=e.uvRatio||((w,h)=>{try{return{isValid:!0,value:r.sqrt(w*r.inv(h))}}catch{return{isValid:!1,value:dt}}}),p=e.adjustScalarBytes||(w=>w),_=e.domain||((w,h,g)=>{if(h.length||g)throw new Error("Contexts/pre-hash are not supported");return w}),m=w=>typeof w=="bigint"&&dt<w,S=(w,h)=>m(w)&&m(h)&&w<h,T=w=>w===dt||S(w,u);function R(w,h){if(S(w,h))return w;throw new Error(`Expected valid scalar < ${h}, got ${typeof w} ${w}`)}function C(w){return w===dt?w:R(w,n)}let y=new Map;function U(w){if(!(w instanceof x))throw new Error("ExtendedPoint expected")}class x{constructor(h,g,b,B){if(this.ex=h,this.ey=g,this.ez=b,this.et=B,!T(h))throw new Error("x required");if(!T(g))throw new Error("y required");if(!T(b))throw new Error("z required");if(!T(B))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(h){if(h instanceof x)throw new Error("extended point not allowed");let{x:g,y:b}=h||{};if(!T(g)||!T(b))throw new Error("invalid affine point");return new x(g,b,et,c(g*b))}static normalizeZ(h){let g=r.invertBatch(h.map(b=>b.ez));return h.map((b,B)=>b.toAffine(g[B])).map(x.fromAffine)}_setWindowSize(h){this._WINDOW_SIZE=h,y.delete(this)}assertValidity(){let{a:h,d:g}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:b,ey:B,ez:N,et:P}=this,k=c(b*b),O=c(B*B),F=c(N*N),M=c(F*F),Y=c(k*h),it=c(F*c(Y+O)),z=c(M+c(g*c(k*O)));if(it!==z)throw new Error("bad point: equation left != right (1)");let wt=c(b*B),ct=c(N*P);if(wt!==ct)throw new Error("bad point: equation left != right (2)")}equals(h){U(h);let{ex:g,ey:b,ez:B}=this,{ex:N,ey:P,ez:k}=h,O=c(g*k),F=c(N*B),M=c(b*k),Y=c(P*B);return O===F&&M===Y}is0(){return this.equals(x.ZERO)}negate(){return new x(c(-this.ex),this.ey,this.ez,c(-this.et))}double(){let{a:h}=e,{ex:g,ey:b,ez:B}=this,N=c(g*g),P=c(b*b),k=c(fr*c(B*B)),O=c(h*N),F=g+b,M=c(c(F*F)-N-P),Y=O+P,it=Y-k,z=O-P,wt=c(M*it),ct=c(Y*z),Lt=c(M*z),te=c(it*Y);return new x(wt,ct,te,Lt)}add(h){U(h);let{a:g,d:b}=e,{ex:B,ey:N,ez:P,et:k}=this,{ex:O,ey:F,ez:M,et:Y}=h;if(g===BigInt(-1)){let Ye=c((N-B)*(F+O)),ze=c((N+B)*(F-O)),_e=c(ze-Ye);if(_e===dt)return this.double();let Je=c(P*fr*Y),Xe=c(k*fr*M),Ze=Xe+Je,Qe=ze+Ye,Jn=Xe-Je,rs=c(Ze*_e),ns=c(Qe*Jn),is=c(Ze*Jn),os=c(_e*Qe);return new x(rs,ns,os,is)}let it=c(B*O),z=c(N*F),wt=c(k*b*Y),ct=c(P*M),Lt=c((B+N)*(O+F)-it-z),te=ct-wt,We=ct+wt,Ge=c(z-g*it),Yr=c(Lt*te),zr=c(We*Ge),Jr=c(Lt*Ge),Xr=c(te*We);return new x(Yr,zr,Xr,Jr)}subtract(h){return this.add(h.negate())}wNAF(h){return $.wNAFCached(this,y,h,x.normalizeZ)}multiply(h){let{p:g,f:b}=this.wNAF(R(h,n));return x.normalizeZ([g,b])[0]}multiplyUnsafe(h){let g=C(h);return g===dt?mt:this.equals(mt)||g===et?this:this.equals(L)?this.wNAF(g).p:$.unsafeLadder(this,g)}isSmallOrder(){return this.multiplyUnsafe(l).is0()}isTorsionFree(){return $.unsafeLadder(this,n).is0()}toAffine(h){let{ex:g,ey:b,ez:B}=this,N=this.is0();h==null&&(h=N?ga:r.inv(B));let P=c(g*h),k=c(b*h),O=c(B*h);if(N)return{x:dt,y:et};if(O!==et)throw new Error("invZ was invalid");return{x:P,y:k}}clearCofactor(){let{h}=e;return h===et?this:this.multiplyUnsafe(h)}static fromHex(h,g=!1){let{d:b,a:B}=e,N=r.BYTES;h=Nt("pointHex",h,N);let P=h.slice(),k=h[N-1];P[N-1]=k&-129;let O=rr(P);O===dt||(g?R(O,u):R(O,r.ORDER));let F=c(O*O),M=c(F-et),Y=c(b*F-B),{isValid:it,value:z}=f(M,Y);if(!it)throw new Error("Point.fromHex: invalid y coordinate");let wt=(z&et)===et,ct=(k&128)!==0;if(!g&&z===dt&&ct)throw new Error("Point.fromHex: x=0 and x_0=1");return ct!==wt&&(z=c(-z)),x.fromAffine({x:z,y:O})}static fromPrivateKey(h){return nt(h).point}toRawBytes(){let{x:h,y:g}=this.toAffine(),b=Qr(g,r.BYTES);return b[b.length-1]|=h&et?128:0,b}toHex(){return ni(this.toRawBytes())}}x.BASE=new x(e.Gx,e.Gy,et,c(e.Gx*e.Gy)),x.ZERO=new x(dt,et,et,dt);let{BASE:L,ZERO:mt}=x,$=ci(x,a*8);function G(w){return lt(w,n)}function rt(w){return G(rr(w))}function nt(w){let h=a;w=Nt("private key",w,h);let g=Nt("hashed private key",o(w),2*h),b=p(g.slice(0,h)),B=g.slice(h,2*h),N=rt(b),P=L.multiply(N),k=P.toRawBytes();return{head:b,prefix:B,scalar:N,point:P,pointBytes:k}}function yt(w){return nt(w).pointBytes}function at(w=new Uint8Array,...h){let g=Ir(...h);return rt(o(_(g,Nt("context",w),!!i)))}function Bt(w,h,g={}){w=Nt("message",w),i&&(w=i(w));let{prefix:b,scalar:B,pointBytes:N}=nt(h),P=at(g.context,b,w),k=L.multiply(P).toRawBytes(),O=at(g.context,k,N,w),F=G(P+O*B);C(F);let M=Ir(k,Qr(F,r.BYTES));return Nt("result",M,a*2)}let Ot=_a;function ge(w,h,g,b=Ot){let{context:B,zip215:N}=b,P=r.BYTES;w=Nt("signature",w,2*P),h=Nt("message",h),i&&(h=i(h));let k=rr(w.slice(P,2*P)),O,F,M;try{O=x.fromHex(g,N),F=x.fromHex(w.slice(0,P),N),M=L.multiplyUnsafe(k)}catch{return!1}if(!N&&O.isSmallOrder())return!1;let Y=at(B,F.toRawBytes(),O.toRawBytes(),h);return F.add(O.multiplyUnsafe(Y)).subtract(M).clearCofactor().equals(x.ZERO)}return L._setWindowSize(8),{CURVE:e,getPublicKey:yt,sign:Bt,verify:ge,ExtendedPoint:x,utils:{getExtendedPublicKey:nt,randomPrivateKey:()=>s(r.BYTES),precompute(w=8,h=x.BASE){return h._setWindowSize(w),h.multiply(BigInt(3)),h}}}}var _n=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Gi=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),gl=BigInt(0),ba=BigInt(1),gn=BigInt(2),Ea=BigInt(5),Yi=BigInt(10),Ta=BigInt(20),Aa=BigInt(40),zi=BigInt(80);function va(t){let e=_n,n=t*t%e*t%e,i=ut(n,gn,e)*n%e,o=ut(i,ba,e)*t%e,s=ut(o,Ea,e)*o%e,a=ut(s,Yi,e)*s%e,l=ut(a,Ta,e)*a%e,u=ut(l,Aa,e)*l%e,c=ut(u,zi,e)*u%e,f=ut(c,zi,e)*u%e,p=ut(f,Yi,e)*s%e;return{pow_p_5_8:ut(p,gn,e)*t%e,b2:n}}function Sa(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Ra(t,e){let r=_n,n=lt(e*e*e,r),i=lt(n*n*e,r),o=va(t*i).pow_p_5_8,s=lt(t*n*o,r),a=lt(e*s*s,r),l=s,u=lt(s*Gi,r),c=a===t,f=a===lt(-t,r),p=a===lt(-t*Gi,r);return c&&(s=l),(f||p)&&(s=u),oi(s,r)&&(s=lt(-s,r)),{isValid:c||f,value:s}}var Ut=si(_n,void 0,!0),xn={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ut,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:wn,randomBytes:Dn,adjustScalarBytes:Sa,uvRatio:Ra},jt=hr(xn);function Ji(t,e,r){if(e.length>255)throw new Error("Context is too big");return Qn(Zn("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var _l=hr({...xn,domain:Ji}),xl=hr({...xn,domain:Ji,prehash:wn});var Ba=(Ut.ORDER+BigInt(3))/BigInt(8),bl=Ut.pow(gn,Ba),El=Ut.sqrt(Ut.neg(Ut.ONE)),Tl=(Ut.ORDER-BigInt(5))/BigInt(8),Al=BigInt(486662);var vl=ai(Ut,Ut.neg(BigInt(486664)));var Sl=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Rl=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Bl=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Ol=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var Nl=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Xi=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Z=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},J,Se,Zi,Qi,pr=class{constructor(e={}){J.set(this,void 0),Se.set(this,void 0),this[Zi]=this.entries.bind(this),this[Qi]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();Xi(this,J,new Map([...r].map(([o,s])=>[o,{value:s,timestamp:i}])),"f"),Xi(this,Se,n,"f")}prune(){let e=Date.now();for(let[r,n]of Z(this,J,"f").entries())e-n.timestamp>Z(this,Se,"f")&&Z(this,J,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return Z(this,J,"f").set(e,n),this}get(e){let r=Z(this,J,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>Z(this,Se,"f")){Z(this,J,"f").delete(e);return}return r.value}}clear(){Z(this,J,"f").clear()}entries(){let e=Z(this,J,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=Z(this,J,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return Z(this,J,"f").keys()}forEach(e,r){for(let[n,i]of Z(this,J,"f").entries())e.call(r,i.value,n,this)}has(e){return Z(this,J,"f").has(e)}delete(e){return Z(this,J,"f").delete(e)}get size(){return Z(this,J,"f").size}};J=new WeakMap,Se=new WeakMap,Zi=Symbol.iterator,Qi=Symbol.toStringTag;var Ii=t=>{if(t<=127)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},Di=(t,e,r)=>{if(r<=127)return t[e]=r,1;if(r<=255)return t[e]=129,t[e+1]=r,2;if(r<=65535)return t[e]=130,t[e+1]=r>>8,t[e+2]=r,3;if(r<=16777215)return t[e]=131,t[e+1]=r>>16,t[e+2]=r>>8,t[e+3]=r,4;throw new Error("Length too long (> 4 bytes)")},bn=(t,e)=>{if(t[e]<128)return 1;if(t[e]===128)throw new Error("Invalid length 0");if(t[e]===129)return 2;if(t[e]===130)return 3;if(t[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")},Oa=(t,e)=>{let r=bn(t,e);if(r===1)return t[e];if(r===2)return t[e+1];if(r===3)return(t[e+1]<<8)+t[e+2];if(r===4)return(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];throw new Error("Length too long (> 4 bytes)")},Li=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),zt=Uint8Array.from([48,5,6,3,43,101,112]),Fl=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function le(t,e){let r=2+Ii(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,o=new Uint8Array(1+Ii(n)+n);return o[i++]=48,i+=Di(o,i,n),o.set(e,i),i+=e.byteLength,o[i++]=3,i+=Di(o,i,t.byteLength+1),o[i++]=0,o.set(new Uint8Array(t),i),o}var Re=(t,e)=>{let r=0,n=(a,l)=>{if(i[r++]!==a)throw new Error("Expected: "+l)},i=new Uint8Array(t);if(n(48,"sequence"),r+=bn(i,r),!Le(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let o=Oa(i,r)-1;r+=bn(i,r),n(0,"0 padding");let s=i.slice(r);if(o!==s.length)throw new Error(`DER payload mismatch: Expected length ${o} actual length ${s.length}`);return s};var to=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},eo=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},mr,yr,Be=class t{constructor(e){if(mr.set(this,void 0),yr.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");to(this,mr,e,"f"),to(this,yr,t.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){return le(e,zt).buffer}static derDecode(e){let r=Re(e,zt);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return eo(this,mr,"f")}get derKey(){return eo(this,yr,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};mr=new WeakMap,yr=new WeakMap;Be.RAW_KEY_LENGTH=32;var ro=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)},En,no,Tn,io,An=class extends Function{constructor(){return super(),En.add(this),this.observers=[],new Proxy(this,{apply:(e,r,n)=>ro(e,En,"m",no).call(e,n[0],...n.slice(1))})}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e,...r){this.observers.forEach(n=>n(e,...r))}};En=new WeakSet,no=function(e,...r){this.notify(e,...r)};var wr=class extends An{constructor(){return super(),Tn.add(this),new Proxy(this,{apply:(e,r,n)=>ro(e,Tn,"m",io).call(e,n[0],...n.slice(1))})}log(e,...r){this.notify({message:e,level:"info"},...r)}warn(e,...r){this.notify({message:e,level:"warn"},...r)}error(e,r,...n){this.notify({message:e,level:"error",error:r},...n)}};Tn=new WeakSet,io=function(e,...r){this.log(e,...r)};var Et=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},X=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Tt,gr,_r,xr,br,Er,Tr,Ar,ue;var Oe=class t{constructor(e=t.default){Tt.set(this,void 0),gr.set(this,void 0),_r.set(this,void 0),xr.set(this,void 0),br.set(this,void 0),Er.set(this,void 0),Tr.set(this,void 0),Ar.set(this,void 0),ue.set(this,0);let{initialInterval:r=500,randomizationFactor:n=.5,multiplier:i=1.5,maxInterval:o=6e4,maxElapsedTime:s=9e5,maxIterations:a=10,date:l=Date}=e;Et(this,Tt,r,"f"),Et(this,gr,n,"f"),Et(this,_r,i,"f"),Et(this,xr,o,"f"),Et(this,Ar,l,"f"),Et(this,br,l.now(),"f"),Et(this,Er,s,"f"),Et(this,Tr,a,"f")}get ellapsedTimeInMsec(){return X(this,Ar,"f").now()-X(this,br,"f")}get currentInterval(){return X(this,Tt,"f")}get count(){return X(this,ue,"f")}get randomValueFromInterval(){let e=X(this,gr,"f")*X(this,Tt,"f"),r=X(this,Tt,"f")-e,n=X(this,Tt,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return Et(this,Tt,Math.min(X(this,Tt,"f")*X(this,_r,"f"),X(this,xr,"f")),"f"),Et(this,ue,(e=X(this,ue,"f"),e++,e),"f"),X(this,Tt,"f")}next(){return this.ellapsedTimeInMsec>=X(this,Er,"f")||X(this,ue,"f")>=X(this,Tr,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Tt=new WeakMap,gr=new WeakMap,_r=new WeakMap,xr=new WeakMap,br=new WeakMap,Er=new WeakMap,Tr=new WeakMap,Ar=new WeakMap,ue=new WeakMap;Oe.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date};var vr=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},v=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},At,ft,Jt,Rr,de,fe,Xt,Zt,oo,Br,Or,vt;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(vt||(vt={}));var Sr=5*60*1e3,Pa="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";var Ca="ic0.app",ka=".ic0.app",Fa="icp0.io",Ua=".icp0.io",Ma="icp-api.io",Va=".icp-api.io",Ne=class extends tt{constructor(e){super(e),this.message=e}},he=class extends tt{constructor(e){super(e),this.message=e}};function Ka(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new Ne("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof globalThis<"u")if(globalThis.fetch)t=globalThis.fetch.bind(globalThis);else throw new Ne("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(t=self.fetch.bind(self));if(t)return t;throw new Ne("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var Pe=class t{constructor(e={}){var r;if(At.add(this),this.rootKey=gt(Pa),this._timeDiffMsecs=0,this._rootKeyFetched=!1,ft.set(this,void 0),Jt.set(this,void 0),this._isAgent=!0,Rr.set(this,0),this.log=new wr,de.set(this,[]),fe.set(this,[]),Xt.set(this,new pr({expirationTime:5*60*1e3})),Zt.set(this,!0),Or.set(this,(i,o)=>{if(v(this,Zt,"f")===!1)return i;if(!o)throw new be("Invalid signature from replica signed query: no matching node key found.");let{status:s,signatures:a=[],requestId:l}=i,u=new TextEncoder().encode("\vic-response");for(let c of a){let{timestamp:f,identity:p}=c,_=A.fromUint8Array(p).toText(),m;if(s==="replied"){let{reply:y}=i;m=Zr({status:s,reply:y,timestamp:BigInt(f),request_id:l})}else if(s==="rejected"){let{reject_code:y,reject_message:U,error_code:x}=i;m=Zr({status:s,reject_code:y,reject_message:U,error_code:x,timestamp:BigInt(f),request_id:l})}else throw new Error(`Unknown status: ${s}`);let S=De(u,new Uint8Array(m)),T=o?.nodeKeys.get(_);if(!T)throw new be("Invalid signature from replica signed query: no matching node key found.");let R=Be.fromDer(T).rawKey;if(jt.verify(c.signature,new Uint8Array(S),new Uint8Array(R)))return i;throw new be(`Invalid signature from replica ${_} signed query.`)}return i}),e.source){if(!(e.source instanceof t))throw new Error("An Agent's source can only be another HttpAgent");this._identity=e.source._identity,this._fetch=e.source._fetch,this._host=e.source._host,this._credentials=e.source._credentials}else this._fetch=e.fetch||Ka()||fetch.bind(globalThis),this._fetchOptions=e.fetchOptions,this._callOptions=e.callOptions;if(e.host!==void 0)!e.host.match(/^[a-z]+:/)&&typeof window<"u"?this._host=new URL(window.location.protocol+"//"+e.host):this._host=new URL(e.host);else if(e.source!==void 0)this._host=e.source._host;else{let i=typeof window<"u"?window.location:void 0;i||(this._host=new URL("https://icp-api.io"),this.log.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."));let o=["ic0.app","icp0.io","127.0.0.1","localhost"],s=[".github.dev",".gitpod.io"],a=i?.hostname,l;a&&typeof a=="string"&&(s.some(u=>a.endsWith(u))?l=a:l=o.find(u=>a.endsWith(u))),i&&l?this._host=new URL(`${i.protocol}//${l}${i.port?":"+i.port:""}`):(this._host=new URL("https://icp-api.io"),this.log.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."))}e.verifyQuerySignatures!==void 0&&vr(this,Zt,e.verifyQuerySignatures,"f"),vr(this,ft,(r=e.retryTimes)!==null&&r!==void 0?r:3,"f");let n=()=>new Oe({maxIterations:v(this,ft,"f")});if(vr(this,Jt,e.backoffStrategy||n,"f"),this._host.hostname.endsWith(ka)?this._host.hostname=Ca:this._host.hostname.endsWith(Ua)?this._host.hostname=Fa:this._host.hostname.endsWith(Va)&&(this._host.hostname=Ma),e.credentials){let{name:i,password:o}=e.credentials;this._credentials=`${i}${o?":"+o:""}`}this._identity=Promise.resolve(e.identity||new Ft),this.addTransform("update",pn(ce)),e.useQueryNonces&&this.addTransform("query",pn(ce)),e.logToConsole&&this.log.subscribe(i=>{i.level==="error"?console.error(i.message):i.level==="warn"?console.warn(i.message):console.log(i.message)})}get waterMark(){return v(this,Rr,"f")}isLocal(){let e=this._host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,r,n=r.priority||0){if(e==="update"){let i=v(this,fe,"f").findIndex(o=>(o.priority||0)<n);v(this,fe,"f").splice(i>=0?i:v(this,fe,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=v(this,de,"f").findIndex(o=>(o.priority||0)<n);v(this,de,"f").splice(i>=0?i:v(this,de,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!this._identity)throw new he("This identity has expired due this application's security policy. Please refresh your authentication.");return(await this._identity).getPrincipal()}async call(e,r,n){let i=await(n!==void 0?await n:await this._identity);if(!i)throw new he("This identity has expired due this application's security policy. Please refresh your authentication.");let o=A.from(e),s=r.effectiveCanisterId?A.from(r.effectiveCanisterId):o,a=i.getPrincipal()||A.anonymous(),l=new Yt(Sr);Math.abs(this._timeDiffMsecs)>1e3*30&&(l=new Yt(Sr+this._timeDiffMsecs));let u={request_type:ur.Call,canister_id:o,method_name:r.methodName,arg:r.arg,sender:a,ingress_expiry:l},c=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"call",body:u});c=await i.transformRequest(c);let f=er(c.body);this.log(`fetching "/api/v2/canister/${s.toText()}/call" with request:`,c);let p=v(this,Jt,"f").call(this),_=v(this,At,"m",Br).call(this,{request:()=>this._fetch(""+new URL(`/api/v2/canister/${s.toText()}/call`,this._host),Object.assign(Object.assign(Object.assign({},this._callOptions),c.request),{body:f})),backoff:p,tries:0}),[m,S]=await Promise.all([_,Mt(u)]),T=await m.arrayBuffer(),R=m.status===200&&T.byteLength>0?ee(T):null;return{requestId:S,response:{ok:m.ok,status:m.status,statusText:m.statusText,body:R,headers:Ae(m.headers)}}}async query(e,r,n){let i=v(this,Jt,"f").call(this),o=r.effectiveCanisterId?A.from(r.effectiveCanisterId):A.from(e);this.log(`ecid ${o.toString()}`),this.log(`canisterId ${e.toString()}`);let s=async()=>{let c=await(n!==void 0?await n:await this._identity);if(!c)throw new he("This identity has expired due this application's security policy. Please refresh your authentication.");let f=A.from(e),p=c?.getPrincipal()||A.anonymous(),_={request_type:"query",canister_id:f,method_name:r.methodName,arg:r.arg,sender:p,ingress_expiry:new Yt(Sr)},m=await Mt(_),S=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read",body:_});S=await c?.transformRequest(S);let T=er(S.body),R={canister:f.toText(),ecid:o,transformedRequest:S,body:T,requestId:m,backoff:i,tries:0};return await v(this,At,"m",oo).call(this,R)},a=async()=>{if(!v(this,Zt,"f"))return;let c=v(this,Xt,"f").get(o.toString());return c||(await this.fetchSubnetKeys(o.toString()),v(this,Xt,"f").get(o.toString()))},[l,u]=await Promise.all([s(),a()]);if(this.log("Query response:",l),!v(this,Zt,"f"))return l;try{return v(this,Or,"f").call(this,l,u)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),v(this,Xt,"f").delete(e.toString()),await this.fetchSubnetKeys(o.toString());let f=v(this,Xt,"f").get(e.toString());if(!f)throw new be("Invalid signature from replica signed query: no matching node key found.");return v(this,Or,"f").call(this,l,f)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await this._identity);if(!n)throw new he("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||A.anonymous(),o=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Yt(Sr)}});return n?.transformRequest(o)}async readState(e,r,n,i){let o=typeof e=="string"?A.fromText(e):e,s=i??await this.createReadStateRequest(r,n),a=er(s.body);this.log(`fetching "/api/v2/canister/${o}/read_state" with request:`,s);let l=v(this,Jt,"f").call(this),u=await v(this,At,"m",Br).call(this,{request:()=>this._fetch(""+new URL(`/api/v2/canister/${o.toString()}/read_state`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),s.request),{body:a})),backoff:l,tries:0});if(!u.ok)throw new Error(`Server returned an error:
|
|
3
|
+
Code: ${u.status} (${u.statusText})
|
|
4
|
+
Body: ${await u.text()}
|
|
5
|
+
`);let c=ee(await u.arrayBuffer());this.log("Read state response:",c);let f=await this.parseTimeFromResponse(c);return f>0&&(this.log("Read state response time:",f),vr(this,Rr,f,"f")),c}async parseTimeFromResponse(e){let r;if(e.certificate){let n=ee(e.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=fi(["time"],r);if(!i)throw new Error("Time was not found in the response or was not in its expected format.");if(!(i instanceof ArrayBuffer)&&!ArrayBuffer.isView(i))throw new Error("Time was not found in the response or was not in its expected format.");let o=ui(tr(i));return this.log("Time from response:",o),this.log("Time from response in milliseconds:",Number(o)),Number(o)}else this.log.warn("No certificate found in response");return 0}async syncTime(e){let r=await import("./canisterStatus-TBLYKI2M.js"),n=Date.now();try{e||this.log("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let o=(await r.request({canisterId:e??A.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");o&&(this._timeDiffMsecs=Number(o)-Number(n))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{};this.log('fetching "/api/v2/status"');let r=v(this,Jt,"f").call(this),n=await v(this,At,"m",Br).call(this,{backoff:r,request:()=>this._fetch(""+new URL("/api/v2/status",this._host),Object.assign({headers:e},this._fetchOptions)),tries:0});return ee(await n.arrayBuffer())}async fetchRootKey(){return this._rootKeyFetched||(this.rootKey=(await this.status()).root_key,this._rootKeyFetched=!0),this.rootKey}invalidateIdentity(){this._identity=null}replaceIdentity(e){this._identity=Promise.resolve(e)}async fetchSubnetKeys(e){let r=A.from(e),i=(await Dr({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return v(this,Xt,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of v(this,fe,"f"))r=r.then(i=>n(i).then(o=>o||i));else for(let n of v(this,de,"f"))r=r.then(i=>n(i).then(o=>o||i));return r}};ft=new WeakMap,Jt=new WeakMap,Rr=new WeakMap,de=new WeakMap,fe=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,Or=new WeakMap,At=new WeakSet,oo=async function t(e){var r,n;let{ecid:i,transformedRequest:o,body:s,requestId:a,backoff:l,tries:u}=e,c=u===0?0:l.next();if(this.log(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:u,backoff:l,delay:c}),c===null)throw new tt(`Timestamp failed to pass the watermark after retrying the configured ${v(this,ft,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);c>0&&await new Promise(m=>setTimeout(m,c));let f;try{this.log(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,o);let m=await this._fetch(""+new URL(`/api/v2/canister/${i.toString()}/query`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),o.request),{body:s}));if(m.status===200){let S=ee(await m.arrayBuffer());f=Object.assign(Object.assign({},S),{httpDetails:{ok:m.ok,status:m.status,statusText:m.statusText,headers:Ae(m.headers)},requestId:a})}else throw new ve(`Server returned an error:
|
|
6
|
+
Code: ${m.status} (${m.statusText})
|
|
7
|
+
Body: ${await m.text()}
|
|
8
|
+
`,{ok:m.ok,status:m.status,statusText:m.statusText,headers:Ae(m.headers)})}catch(m){if(u<v(this,ft,"f"))return this.log.warn(`Caught exception while attempting to make query:
|
|
9
|
+
${m}
|
|
10
|
+
Retrying query.`),await v(this,At,"m",t).call(this,Object.assign(Object.assign({},e),{tries:u+1}));throw m}let p=(n=(r=f.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!v(this,Zt,"f"))return f;if(!p)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let _=Number(BigInt(p)/BigInt(1e6));if(this.log("watermark and timestamp",{waterMark:this.waterMark,timestamp:_}),Number(this.waterMark)>_){let m=new tt("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",m,{timestamp:p,waterMark:this.waterMark}),u<v(this,ft,"f"))return await v(this,At,"m",t).call(this,Object.assign(Object.assign({},e),{tries:u+1}));throw new tt(`Timestamp failed to pass the watermark after retrying the configured ${v(this,ft,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return f},Br=async function t(e){let{request:r,backoff:n,tries:i}=e,o=i===0?0:n.next();if(o===null)throw new tt(`Timestamp failed to pass the watermark after retrying the configured ${v(this,ft,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);o>0&&await new Promise(u=>setTimeout(u,o));let s;try{s=await r()}catch(u){if(v(this,ft,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
|
|
11
|
+
${u}
|
|
12
|
+
Retrying request.`),await v(this,At,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw u}if(s.ok)return s;let a=await s.clone().text(),l=`Server returned an error:
|
|
13
|
+
Code: ${s.status} (${s.statusText})
|
|
14
|
+
Body: ${a}
|
|
15
|
+
`;if(i<v(this,ft,"f"))return await v(this,At,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw new ve(l,{ok:s.ok,status:s.status,statusText:s.statusText,headers:Ae(s.headers)})};var so;(function(t){t.Error="err",t.GetPrincipal="gp",t.GetPrincipalResponse="gpr",t.Query="q",t.QueryResponse="qr",t.Call="c",t.CallResponse="cr",t.ReadState="rs",t.ReadStateResponse="rsr",t.Status="s",t.StatusResponse="sr"})(so||(so={}));function vn(){let t=typeof window>"u"?typeof globalThis>"u"?typeof self>"u"?void 0:self.ic.agent:globalThis.ic.agent:window.ic.agent;if(!t)throw new Error("No Agent could be found.");return t}var Nr={};ss(Nr,{backoff:()=>fo,chain:()=>ho,conditionalDelay:()=>lo,defaultStrategy:()=>ao,maxAttempts:()=>ja,once:()=>co,throttle:()=>Ha,timeout:()=>uo});var qa=5*60*1e3;function ao(){return ho(lo(co(),1e3),fo(1e3,1.2),uo(qa))}function co(){let t=!0;return async()=>t?(t=!1,!0):!1}function lo(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(o=>setTimeout(o,e))}}function ja(t){let e=t;return async(r,n,i)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${t} attempts:
|
|
16
|
+
Request ID: ${K(n)}
|
|
17
17
|
Request status: ${i}
|
|
18
|
-
`)}}function
|
|
19
|
-
Request ID: ${
|
|
18
|
+
`)}}function Ha(t){return()=>new Promise(e=>setTimeout(e,t))}function uo(t){let e=Date.now()+t;return async(r,n,i)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
|
|
19
|
+
Request ID: ${K(n)}
|
|
20
20
|
Request status: ${i}
|
|
21
|
-
`)}}function
|
|
22
|
-
Request ID: ${
|
|
23
|
-
Reject code: ${
|
|
24
|
-
Reject text: ${
|
|
25
|
-
`)}case
|
|
26
|
-
Request ID: ${
|
|
27
|
-
`)}throw new Error("unreachable")}var
|
|
28
|
-
`)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}},dn=class extends mr{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=rr[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},fn=class extends mr{constructor(e,r,n,i){super(e,r,"update",Object.assign({"Request ID":M(n)},i.body?Object.assign(Object.assign({},i.body.error_code?{"Error code":i.body.error_code}:{}),{"Reject code":String(i.body.reject_code),"Reject message":i.body.reject_message}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i}},it=Symbol.for("ic-agent-metadata"),Yt=class t{constructor(e){this[it]=Object.freeze(e)}static agentOf(e){return e[it].config.agent}static interfaceOf(e){return e[it].service}static canisterIdOf(e){return A.from(e[it].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],o=[...new Uint8Array(e.module)],s=typeof r.canisterId=="string"?A.fromText(r.canisterId):r.canisterId;await Li(r).install_code({mode:n,arg:i,wasm_module:o,canister_id:s,sender_canister_version:[]})}static async createCanister(e,r){function n(o){return[{controllers:o.controllers?[o.controllers]:[],compute_allocation:o.compute_allocation?[o.compute_allocation]:[],freezing_threshold:o.freezing_threshold?[o.freezing_threshold]:[],memory_allocation:o.memory_allocation?[o.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[]}]}let{canister_id:i}=await Li(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:he});class i extends t{constructor(s){if(!s.canisterId)throw new ct(`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"?A.fromText(s.canisterId):s.canisterId;super({config:Object.assign(Object.assign(Object.assign({},eo),s),{canisterId:a}),service:n});for(let[l,d]of n._fields)r?.httpDetails&&d.annotations.push(hn),this[l]=Ba(this,l,d,s.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new ct(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}};function yr(t,e){let r=he.decode(t,to.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var eo={pollingStrategyFactory:pr.defaultStrategy},hn="http-details";function Ba(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(s,...a)=>{var l,d;s=Object.assign(Object.assign({},s),(d=(l=t[it].config).queryTransform)===null||d===void 0?void 0:d.call(l,e,a,Object.assign(Object.assign({},t[it].config),s)));let c=s.agent||t[it].config.agent||ln(),f=A.from(s.canisterId||t[it].config.canisterId),h=he.encode(r.argTypes,a),w=await c.query(f,{methodName:e,arg:h,effectiveCanisterId:s.effectiveCanisterId});switch(w.status){case"rejected":throw new dn(f,e,w);case"replied":return r.annotations.includes(hn)?{httpDetails:w.httpDetails,result:yr(r.retTypes,w.reply.arg)}:yr(r.retTypes,w.reply.arg)}}:i=async(s,...a)=>{var l,d;s=Object.assign(Object.assign({},s),(d=(l=t[it].config).callTransform)===null||d===void 0?void 0:d.call(l,e,a,Object.assign(Object.assign({},t[it].config),s)));let c=s.agent||t[it].config.agent||ln(),{canisterId:f,effectiveCanisterId:h,pollingStrategyFactory:w}=Object.assign(Object.assign(Object.assign({},eo),t[it].config),s),_=A.from(f),T=h!==void 0?A.from(h):_,v=he.encode(r.argTypes,a),{requestId:R,response:N}=await c.call(_,{methodName:e,arg:v,effectiveCanisterId:T});if(!N.ok||N.body)throw new fn(_,e,R,N);let m=w(),k=await un(c,T,R,m,n),b=r.annotations.includes(hn);if(k!==void 0)return b?{httpDetails:N,result:yr(r.retTypes,k)}:yr(r.retTypes,k);if(r.retTypes.length===0)return b?{httpDetails:N,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let o=(...s)=>i({},...s);return o.withOptions=s=>(...a)=>i(s,...a),o}function Li(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:A.from(t.effectiveCanisterId)};let i=n[0],o=A.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(o=A.from(i.canister_id)),{effectiveCanisterId:o}}return Yt.createActor(Di,Object.assign(Object.assign(Object.assign({},t),{canisterId:A.fromHex("")}),{callTransform:e,queryTransform:e}))}var _r=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Vt=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)},wr,gr,ce,le;function ro(t){return t!==null&&typeof t=="object"}var zt=class t{constructor(e){if(wr.set(this,void 0),gr.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");_r(this,wr,e,"f"),_r(this,gr,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=mt(e);return this.fromRaw(r)}else if(ro(e)){let r=e;if(ro(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw(Je(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=ie(e,$t).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=xe(e,$t);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Vt(this,wr,"f")}get derKey(){return Vt(this,gr,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};wr=new WeakMap,gr=new WeakMap;zt.RAW_KEY_LENGTH=32;var Jt=class t extends Rt{constructor(e,r){super(),ce.set(this,void 0),le.set(this,void 0),_r(this,ce,zt.from(e),"f"),_r(this,le,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=Kt.utils.randomPrivateKey()),ze(e,new Uint8Array(new Array(32).fill(0)))&&console.warn("Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.");let r=new Uint8Array(32);for(let i=0;i<32;i++)r[i]=new Uint8Array(e)[i];let n=Kt.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(zt.fromDer(mt(r)),mt(n))}static fromJSON(e){let r=JSON.parse(e);if(Array.isArray(r)){if(typeof r[0]=="string"&&typeof r[1]=="string")return this.fromParsedJson([r[0],r[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(e)}`)}static fromKeyPair(e,r){return new t(zt.fromRaw(e),r)}static fromSecretKey(e){let r=Kt.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[M(Vt(this,ce,"f").toDer()),M(Vt(this,le,"f"))]}getKeyPair(){return{secretKey:Vt(this,le,"f"),publicKey:Vt(this,ce,"f")}}getPublicKey(){return Vt(this,ce,"f")}async sign(e){let r=new Uint8Array(e),n=qn(Kt.sign(r,Vt(this,le,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(e,r,n){let[i,o,s]=[e,r,n].map(a=>(typeof a=="string"&&(a=mt(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return Kt.verify(o,i,s)}};ce=new WeakMap,le=new WeakMap;var pn=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};function no(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 pn("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 ve=class t extends Rt{constructor(e,r,n){super(),this._keyPair=e,this._derKey=r,this._subtleCrypto=n}static async generate(e){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=e??{},o=no(i),s=await o.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await o.exportKey("spki",s.publicKey);return new this(s,a,o)}static async fromKeyPair(e,r){let n=no(r),i=await n.exportKey("spki",e.publicKey);return new t(e,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let e=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return e},r}async sign(e){let r={name:"ECDSA",hash:{name:"SHA-256"}};return this._keyPair.privateKey,await this._subtleCrypto.sign(r,this._keyPair.privateKey,e)}};var ue=Ge(jn());var Pa=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Se=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)},Mt,xr=class{constructor(e){Mt.set(this,void 0),Pa(this,Mt,e,"f")}get rawKey(){return Se(this,Mt,"f").rawKey}get derKey(){return Se(this,Mt,"f").derKey}toDer(){return Se(this,Mt,"f").toDer()}getPublicKey(){return Se(this,Mt,"f")}getPrincipal(){return A.from(Se(this,Mt,"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.")}};Mt=new WeakMap;var Na=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ca=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)},Fa=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},br,ka=new TextEncoder().encode("ic-request-auth-delegation"),Ua=new TextEncoder().encode(`
|
|
29
|
-
ic-request`);function yn(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return mt(t)}var de=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return ue.value.map(Object.assign({pubkey:ue.value.bytes(this.pubkey),expiration:ue.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:ue.value.array(this.targets.map(e=>ue.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:M(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};async function Ka(t,e,r,n){let i=new de(e.toDer(),BigInt(+r)*BigInt(1e6),n),o=new Uint8Array([...ka,...new Uint8Array(Ct(i))]),s=await t.sign(o);return{delegation:i,signature:s}}var Re=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+15*60*1e3),i={}){var o,s;let a=await Ka(e,r,n,i.targets);return new t([...((o=i.previous)===null||o===void 0?void 0:o.delegations)||[],a],((s=i.previous)===null||s===void 0?void 0:s.publicKey)||e.getPublicKey().toDer())}static fromJSON(e){let{publicKey:r,delegations:n}=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(o=>{let{delegation:s,signature:a}=o,{pubkey:l,expiration:d,targets:c}=s;if(c!==void 0&&!Array.isArray(c))throw new Error("Invalid targets.");return{delegation:new de(yn(l),BigInt("0x"+d),c&&c.map(f=>{if(typeof f!="string")throw new Error("Invalid target.");return A.fromHex(f)})),signature:yn(a)}});return new this(i,yn(r))}static fromDelegations(e,r){return new this(e,r)}toJSON(){return{delegations:this.delegations.map(e=>{let{delegation:r,signature:n}=e,{targets:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:M(r.pubkey)},i&&{targets:i.map(o=>o.toHex())}),signature:M(n)}}),publicKey:M(this.publicKey)}}},Be=class extends Rt{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=Fa(e,["body"]),i=await Ct(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...Ua,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},Oe=class t extends xr{constructor(e,r){super(e),br.set(this,void 0),Na(this,br,r,"f")}get delegation(){return Ca(this,br,"f")}static fromDelegation(e,r){return new t(e,r)}};br=new WeakMap;function io(t,e){for(let{delegation:i}of t.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?A.fromText(i):i)):r.push(typeof n=="string"?A.fromText(n):n));for(let i of r){let o=i.toText();for(let{delegation:s}of t.delegations){if(s.targets===void 0)continue;let a=!0;for(let l of s.targets)if(l.toText()===o){a=!1;break}if(a)return!1}}return!0}var Va=Ge(Jo());var oo;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(oo||(oo={}));var so=["mousedown","mousemove","keydown","touchstart","wheel"],Pe=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let o=this._resetTimer.bind(this);window.addEventListener("load",o,!0),so.forEach(function(a){document.addEventListener(a,o,!0)});let s=(a,l)=>{let d;return(...c)=>{let f=this,h=function(){d=void 0,a.apply(f,c)};clearTimeout(d),d=window.setTimeout(h,l)}};if(e?.captureScroll){let a=s(o,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}o()}static create(e={}){return new this(e)}registerCallback(e){this.callbacks.push(e)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let e=this._resetTimer.bind(this);so.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 Ma=(t,e)=>e.some(r=>t instanceof r),ao,co;function qa(){return ao||(ao=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ja(){return co||(co=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var lo=new WeakMap,wn=new WeakMap,uo=new WeakMap,mn=new WeakMap,_n=new WeakMap;function Ha(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",o),t.removeEventListener("error",s)},o=()=>{r(bt(t.result)),i()},s=()=>{n(t.error),i()};t.addEventListener("success",o),t.addEventListener("error",s)});return e.then(r=>{r instanceof IDBCursor&&lo.set(r,t)}).catch(()=>{}),_n.set(e,t),e}function $a(t){if(wn.has(t))return;let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("complete",o),t.removeEventListener("error",s),t.removeEventListener("abort",s)},o=()=>{r(),i()},s=()=>{n(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",o),t.addEventListener("error",s),t.addEventListener("abort",s)});wn.set(t,e)}var gn={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return wn.get(t);if(e==="objectStoreNames")return t.objectStoreNames||uo.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return bt(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 fo(t){gn=t(gn)}function Wa(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Er(this),e,...r);return uo.set(n,e.sort?e.sort():[e]),bt(n)}:ja().includes(t)?function(...e){return t.apply(Er(this),e),bt(lo.get(this))}:function(...e){return bt(t.apply(Er(this),e))}}function Ga(t){return typeof t=="function"?Wa(t):(t instanceof IDBTransaction&&$a(t),Ma(t,qa())?new Proxy(t,gn):t)}function bt(t){if(t instanceof IDBRequest)return Ha(t);if(mn.has(t))return mn.get(t);let e=Ga(t);return e!==t&&(mn.set(t,e),_n.set(e,t)),e}var Er=t=>_n.get(t);function po(t,e,{blocked:r,upgrade:n,blocking:i,terminated:o}={}){let s=indexedDB.open(t,e),a=bt(s);return n&&s.addEventListener("upgradeneeded",l=>{n(bt(s.result),l.oldVersion,l.newVersion,bt(s.transaction),l)}),r&&s.addEventListener("blocked",l=>r(l.oldVersion,l.newVersion,l)),a.then(l=>{o&&l.addEventListener("close",()=>o()),i&&l.addEventListener("versionchange",d=>i(d.oldVersion,d.newVersion,d))}).catch(()=>{}),a}var Ya=["get","getKey","getAll","getAllKeys","count"],za=["put","add","delete","clear"],xn=new Map;function ho(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(xn.get(e))return xn.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=za.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||Ya.includes(r)))return;let o=async function(s,...a){let l=this.transaction(s,i?"readwrite":"readonly"),d=l.store;return n&&(d=d.index(a.shift())),(await Promise.all([d[r](...a),i&&l.done]))[0]};return xn.set(e,o),o}fo(t=>({...t,get:(e,r,n)=>ho(e,r)||t.get(e,r,n),has:(e,r)=>!!ho(e,r)||t.has(e,r)}));var yo="auth-client-db",mo="ic-keyval",Ja=async(t=yo,e=mo,r)=>(Tr&&(localStorage!=null&&localStorage.getItem(ft))&&(localStorage.removeItem(ft),localStorage.removeItem(ht)),await po(t,r,{upgrade:n=>{n.objectStoreNames,n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function Za(t,e,r){return await t.get(e,r)}async function Xa(t,e,r,n){return await t.put(e,n,r)}async function Qa(t,e,r){return await t.delete(e,r)}var Ne=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=yo,storeName:n=mo,version:i=wo}=e??{},o=await Ja(r,n,i);return new t(o,n)}async set(e,r){return await Xa(this._db,this._storeName,e,r)}async get(e){var r;return(r=await Za(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await Qa(this._db,this._storeName,e)}};var Ia=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Da=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)},Ar,ht="identity",ft="delegation",go="iv",wo=1,Tr=typeof window<"u",Ce=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}},Fe=class{constructor(e){Ar.set(this,void 0),Ia(this,Ar,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}Ne.create(Da(this,Ar,"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)}};Ar=new WeakMap;var La="https://identity.ic0.app",tc="#authorize",bn="ECDSA",En="Ed25519",ec=500,rc="UserInterrupt",vr=class{constructor(e,r,n,i,o,s,a,l){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=o,this._createOptions=s,this._idpWindow=a,this._eventHandler=l,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let o=(r=e.storage)!==null&&r!==void 0?r:new Fe,s=(n=e.keyType)!==null&&n!==void 0?n:bn,a=null;if(e.identity)a=e.identity;else{let f=await o.get(ht);if(!f&&Tr)try{let h=new Ce,w=await h.get(ft),_=await h.get(ht);w&&_&&s===bn&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await o.set(ft,w),await o.set(ht,_),f=w,await h.remove(ft),await h.remove(ht))}catch(h){console.error("error while attempting to recover localstorage: "+h)}if(f)try{typeof f=="object"?s===En&&typeof f=="string"?a=await Jt.fromJSON(f):a=await ve.fromKeyPair(f):typeof f=="string"&&(a=Jt.fromJSON(f))}catch{}}let l=new Bt,d=null;if(a)try{let f=await o.get(ft);if(typeof f=="object"&&f!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?l=e.identity:f&&(d=Re.fromJSON(f),io(d)?"toDer"in a?l=Oe.fromDelegation(a,d):l=Be.fromDelegation(a,d):(await Tn(o),a=null))}catch(f){console.error(f),await Tn(o),a=null}let c;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?c=void 0:(d||e.identity)&&(c=Pe.create(e.idleOptions)),a||(s===En?(a=await Jt.generate(),await o.set(ht,JSON.stringify(a.toJSON()))):(e.storage&&s===bn&&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 '${En}' as the key type, as it can serialize to a string`),a=await ve.generate(),await o.set(ht,a.getKeyPair()))),new this(l,a,d,o,c,e)}_registerDefaultIdleCallback(){var e,r;let n=(e=this._createOptions)===null||e===void 0?void 0:e.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(e,r){var n,i;let o=e.delegations.map(d=>({delegation:new de(d.delegation.pubkey,d.delegation.expiration,d.delegation.targets),signature:d.signature.buffer})),s=Re.fromDelegations(o,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=s,"toDer"in a?this._identity=Oe.fromDelegation(a,this._chain):this._identity=Be.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let l=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!l?.disableIdle&&(this.idleManager=Pe.create(l),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(ft,JSON.stringify(this._chain.toJSON())),r?.(e)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(e){var r,n,i,o;let s=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||La);a.hash=tc,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=e?.maxTimeToLive)!==null&&i!==void 0?i:s},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(o=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&o!==void 0?o:void 0;let l=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(rc,e?.onError):setTimeout(l,ec))};l()}_getEventHandler(e,r){return async n=>{var i,o,s;if(n.origin!==e.origin){console.warn(`WARNING: expected origin '${e.origin}', got '${n.origin}' (ignoring)`);return}let a=n.data;switch(a.kind){case"authorize-ready":{let l=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(o=r?.derivationOrigin)===null||o===void 0?void 0:o.toString()},r?.customValues);(s=this._idpWindow)===null||s===void 0||s.postMessage(l,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(l){this._handleFailure(l.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.text,r?.onError);break;default:break}}}_handleFailure(e,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(e),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(e={}){if(await Tn(this._storage),this._identity=new Bt,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};async function Tn(t){await t.remove(ht),await t.remove(ft),await t.remove(go)}var Sr=()=>vr.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var _o=async({data:t})=>{try{return await Qe(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var An=async t=>{let{data:e,updated_at:r,description:n}=t;return{description:$(n),data:await Dn(e),updated_at:$(r)}},vn=t=>{let{updated_at:e}=t;return{updated_at:$(e)}},ke=async({doc:t,key:e})=>{let{owner:r,description:n,data:i,...o}=t;return{key:e,description:z(n),owner:r.toText(),data:await Qe(i),...o}};var Rr=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:V(t)?[]:[{key:$(t.key),description:$(t.description)}],paginate:$(V(e)?void 0:{start_after:$(e.startAfter),limit:$(V(e.limit)?void 0:BigInt(e.limit))}),order:$(V(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:$(V(n)?void 0:typeof n=="string"?A.fromText(n):n)});var xo=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({controllers:t.Vec(t.Principal)}),n=t.Variant({Write:t.Null,Admin:t.Null}),i=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:n,expires_at:t.Opt(t.Nat64)}),o=t.Record({updated_at:t.Opt(t.Nat64)}),s=t.Variant({Db:t.Null,Storage:t.Null}),a=t.Record({cycles:t.Nat,destination_id:t.Principal}),l=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}),d=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),c=t.Record({key:l,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,d)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64}),f=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),h=t.Record({status_code:t.Nat16,location:t.Text}),w=t.Record({iframe:t.Opt(f),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),redirects:t.Opt(t.Vec(t.Tuple(t.Text,h)))}),_=t.Record({storage:w}),T=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64}),v=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)}),R=t.Variant({Heap:t.Null,Stable:t.Null}),N=t.Record({memory:R,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}),m=t.Variant({Callback:t.Record({token:N,callback:t.Func([],[],["query"])})}),k=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(m),status_code:t.Nat16}),b=t.Record({token:t.Opt(N),body:t.Vec(t.Nat8)}),D=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}),pt=t.Record({batch_id:t.Nat}),H=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),W=t.Record({field:H,desc:t.Bool}),tt=t.Record({key:t.Opt(t.Text),description:t.Opt(t.Text)}),et=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),ot=t.Record({order:t.Opt(W),owner:t.Opt(t.Principal),matcher:t.Opt(tt),paginate:t.Opt(et)}),st=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,c)),items_length:t.Nat64}),Tt=t.Record({updated_at:t.Nat64,created_at:t.Nat64,bn_id:t.Opt(t.Text)}),Pt=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,T)),items_length:t.Nat64}),Nt=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),Ue=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(R),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:Nt,created_at:t.Nat64,mutable_permissions:t.Opt(t.Bool),write:Nt}),y=t.Record({stable:t.Nat64,heap:t.Nat64}),p=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:n,expires_at:t.Opt(t.Nat64)}),g=t.Record({controller:p,controllers:t.Vec(t.Principal)}),x=t.Record({updated_at:t.Opt(t.Nat64),data:t.Vec(t.Nat8),description:t.Opt(t.Text)}),S=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(R),updated_at:t.Opt(t.Nat64),max_size:t.Opt(t.Nat),read:Nt,mutable_permissions:t.Opt(t.Bool),write:Nt}),B=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),P=t.Record({chunk_id:t.Nat});return t.Service({build_version:t.Func([],[t.Text],["query"]),commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([r],[t.Vec(t.Tuple(t.Principal,i))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,o],[],[]),del_docs:t.Func([t.Text],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,o))],[],[]),del_rule:t.Func([s,t.Text,o],[],[]),deposit_cycles:t.Func([a],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(c)],["query"]),get_config:t.Func([],[_],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(T)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(c)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(T)))],["query"]),http_request:t.Func([v],[k],["query"]),http_request_streaming_callback:t.Func([N],[b],["query"]),init_asset_upload:t.Func([D],[pt],[]),list_assets:t.Func([t.Text,ot],[st],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,i))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,Tt))],["query"]),list_docs:t.Func([t.Text,ot],[Pt],["query"]),list_rules:t.Func([s],[t.Vec(t.Tuple(t.Text,Ue))],["query"]),memory_size:t.Func([],[y],["query"]),set_config:t.Func([_],[],[]),set_controllers:t.Func([g],[t.Vec(t.Tuple(t.Principal,i))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,x],[T],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,x))],[t.Vec(t.Tuple(t.Text,T))],[]),set_rule:t.Func([s,t.Text,S],[],[]),upload_asset_chunk:t.Func([B],[P],[]),version:t.Func([],[t.Text],["query"])})};var bo=async({satelliteId:t,idlFactory:e,identity:r,fetch:n,container:i})=>{let s=q(i)&&i!==!1?i===!0?Dt:i:"https://icp-api.io",a=new Ae({identity:r,host:s,...n&&{fetch:n}});return q(i)&&await a.fetchRootKey(),Yt.createActor(e,{agent:a,canisterId:t})};var Sn=({satelliteId:t,container:e})=>{let{satelliteId:r}=Rn({satelliteId:t}),{container:n}=Bn({container:e});if(q(n)&&n!==!1){let{host:i,protocol:o}=new URL(n===!0?Dt:n);return`${o}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},Rn=({satelliteId:t})=>q(t)?{satelliteId:t}:wt.getInstance().get()??{satelliteId:void 0},Bn=({container:t})=>q(t)?{container:t}:wt.getInstance().get()??{container:void 0};var X=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=Rn({satelliteId:t});In(n,"No satellite principal defined.");let{container:i}=Bn({container:e});return bo({satelliteId:n,container:i,idlFactory:xo,...r})};var Eo=async({collection:t,key:e,satellite:r})=>{let n=await X(r),i=z(await n.get_doc(t,e));if(!V(i))return ke({doc:i,key:e})},To=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await X(e),n=t.map(({collection:s,key:a})=>[s,a]),i=await r(n),o=[];for(let[s,a]of i){let l=z(a);o.push(q(l)?await ke({key:s,doc:l}):void 0)}return o},Ao=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await X(r),{key:i}=e,o=await An(e),s=await n(t,i,o);return await ke({key:i,doc:s})},vo=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await X(e),n=[];for(let{collection:s,doc:a}of t){let{key:l}=a;n.push([s,l,await An(a)])}let i=await r(n),o=[];for(let[s,a]of i)o.push(await ke({key:s,doc:a}));return o},So=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await X(r),{key:i}=e;return n(t,i,vn(e))},Ro=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await X(e),n=t.map(({collection:i,doc:o})=>[i,o.key,vn(o)]);await r(n)},Bo=async({collection:t,filter:e,satellite:r})=>{let n=await X(r),{items:i,items_page:o,items_length:s,matches_length:a,matches_pages:l}=await n.list_docs(t,Rr(e)),d=[];for(let[c,f]of i){let{data:h,owner:w,description:_,...T}=f;d.push({key:c,description:z(_),owner:w.toText(),data:await _o({data:h}),...T})}return{items:d,items_length:s,items_page:z(o),matches_length:a,matches_pages:z(l)}};var Q=t=>t!==void 0?t:Br()??new Bt;var Oo=async({satellite:t,...e})=>{let r=Q(t?.identity);return Eo({...e,satellite:{...t,identity:r}})},ef=async({satellite:t,...e})=>{let r=Q(t?.identity);return To({...e,satellite:{...t,identity:r}})},Po=async({satellite:t,...e})=>{let r=Q(t?.identity);return Ao({...e,satellite:{...t,identity:r}})},rf=async({satellite:t,...e})=>{let r=Q(t?.identity);return vo({...e,satellite:{...t,identity:r}})},nf=async({satellite:t,...e})=>{let r=Q(t?.identity);return So({...e,satellite:{...t,identity:r}})},of=async({satellite:t,...e})=>{let r=Q(t?.identity);return Ro({...e,satellite:{...t,identity:r}})},sf=async({satellite:t,filter:e,...r})=>{let n=Q(t?.identity);return Bo({...r,filter:e??{},satellite:{...t,identity:n}})};var No=async t=>{let e=Br();if(V(e))throw new Error("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=await Oo({collection:"#user",key:r});return V(n)?await nc({userId:r,provider:t}):n},nc=async({userId:t,...e})=>Po({collection:"#user",doc:{key:t,data:e}});var Et,On=async t=>{if(Et=Et??await Sr(),!(await Et?.isAuthenticated()??!1))return;let r=await No(t);vt.getInstance().set(r)},ic=async t=>new Promise(async(e,r)=>{Et=Et??await Sr();let n=t?.provider??new De({});await Et.login({onSuccess:async()=>{await On(n.id),e()},onError:i=>r(i),maxTimeToLive:t?.maxTimeToLive??Ln,allowPinAuthentication:t?.allowPin??ti,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),Pn=async()=>{await Et?.logout(),Et=void 0,vt.getInstance().reset()},Br=()=>Et?.getIdentity(),oc=async()=>(Et??await Sr()).getIdentity();var Co=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{jr({message:"junoSignOutAuthTimer"}),await Pn()};return r.onmessage=async({data:i})=>{let{msg:o,data:s}=i;switch(o){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":jr({message:"junoDelegationRemainingTime",detail:s?.authRemainingTime});return}},vt.getInstance().subscribe(i=>{if(V(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var Fo=async({data:t,filename:e,collection:r,headers:n,token:i,fullPath:o,encoding:s,description:a,satellite:l})=>{let d=await X(l),{batch_id:c}=await d.init_asset_upload({collection:r,full_path:o,name:e,token:$(i),encoding_type:$(s),description:$(a)}),f=19e5,h=[],w=Ie()?new Blob([await t.arrayBuffer()]):t,_=0n;for(let R=0;R<w.size;R+=f){let N=w.slice(R,R+f);h.push({batchId:c,chunk:N,actor:d,orderId:_}),_++}let T=[];for await(let R of sc({uploadChunks:h}))T=[...T,...R];let v=n.find(([R,N])=>R.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await d.commit_asset_upload({batch_id:c,chunk_ids:T.map(({chunk_id:R})=>R),headers:[...n,...v||[]]})};async function*sc({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=>ac(o)))}}var ac=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:$(n)}),ko=async({collection:t,satellite:e,filter:r})=>{let n=await X(e),{items:i,items_length:o,items_page:s,matches_length:a,matches_pages:l}=await n.list_assets(t,Rr(r));return{items:i.map(([d,c])=>c),items_length:o,items_page:z(s),matches_length:a,matches_pages:z(l)}},Uo=async({collection:t,fullPath:e,satellite:r})=>(await X(r)).del_asset(t,e),Ko=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await X(e),n=t.map(({collection:i,fullPath:o})=>[i,o]);await r(n)},Vo=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await X(r);return z(await n(t,e))},Mo=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await X(e),n=t.map(({collection:o,fullPath:s})=>[o,s]);return(await r(n)).map(([o,s])=>z(s))};var qo=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var Ff=async t=>jo(t),kf=async t=>jo({filename:t.data.name,...t}),jo=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:o,satellite:s,encoding:a,description:l})=>{let d=Q(s?.identity),c=decodeURI(t),f=i??`/${r}/${c}`,h={...s,identity:d};return await Fo({data:e,filename:c,collection:r,token:o,headers:n,fullPath:f,encoding:a,satellite:h,description:l}),{downloadUrl:`${Sn(h)}${f}${o!==void 0?`?token=${o}`:""}`,fullPath:f,name:c}},Uf=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:Q(e?.identity)},{items:i,...o}=await ko({collection:t,satellite:n,filter:r??{}}),s=Sn(n);return{assets:i.map(({key:{full_path:a,token:l,name:d,owner:c,description:f},headers:h,encodings:w,created_at:_,updated_at:T})=>{let v=z(l);return{fullPath:a,description:z(f),name:d,downloadUrl:`${s}${a}${v!==void 0?`?token=${v}`:""}`,token:v,headers:h,encodings:w.reduce((R,[N,{modified:m,sha256:k,total_length:b}])=>({...R,[N]:{modified:m,sha256:qo(k),total_length:b}}),{}),owner:c.toText(),created_at:_,updated_at:T}}),...o}},Kf=async({collection:t,fullPath:e,satellite:r})=>Uo({collection:t,fullPath:e,satellite:{...r,identity:Q(r?.identity)}}),Vf=async({assets:t,satellite:e})=>Ko({assets:t,satellite:{...e,identity:Q(e?.identity)}}),Mf=async({satellite:t,...e})=>{let r=Q(t?.identity);return Vo({...e,satellite:{...t,identity:r}})},qf=async({satellite:t,...e})=>{let r=Q(t?.identity);return Mo({...e,satellite:{...t,identity:r}})};var Yf=async t=>{wt.getInstance().set(t),await On();let e=t.workers?.auth!==void 0?Co(t.workers.auth):void 0;return[...e?[e]:[]]},zf=t=>vt.getInstance().subscribe(t);export{De as InternetIdentityProvider,oi as NFIDProvider,zf as authSubscribe,Kf as deleteAsset,nf as deleteDoc,Vf as deleteManyAssets,of as deleteManyDocs,Mf as getAsset,Oo as getDoc,qf as getManyAssets,ef as getManyDocs,Yf as initJuno,Uf as listAssets,sf as listDocs,Po as setDoc,rf as setManyDocs,ic as signIn,Pn as signOut,oc as unsafeIdentity,Ff as uploadBlob,kf as uploadFile};
|
|
21
|
+
`)}}function fo(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}function ho(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}async function Sn(t,e,r,n,i,o){var s;let a=[new TextEncoder().encode("request_status"),r],l=i??await((s=t.createReadStateRequest)===null||s===void 0?void 0:s.call(t,{paths:[a]})),u=await t.readState(e,{paths:[a]},void 0,l);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let c=await di.create({certificate:u.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:o}),f=c.lookup([...a,new TextEncoder().encode("status")]),p;switch(typeof f>"u"?p=vt.Unknown:p=new TextDecoder().decode(f),p){case vt.Replied:return c.lookup([...a,"reply"]);case vt.Received:case vt.Unknown:case vt.Processing:return await n(e,r,p),Sn(t,e,r,n,l);case vt.Rejected:{let _=new Uint8Array(c.lookup([...a,"reject_code"]))[0],m=new TextDecoder().decode(c.lookup([...a,"reject_message"]));throw new Error(`Call was rejected:
|
|
22
|
+
Request ID: ${K(r)}
|
|
23
|
+
Reject code: ${_}
|
|
24
|
+
Reject text: ${m}
|
|
25
|
+
`)}case vt.Done:throw new Error(`Call was marked as done but we never saw the reply:
|
|
26
|
+
Request ID: ${K(r)}
|
|
27
|
+
`)}throw new Error("unreachable")}var po=({IDL:t})=>{let e=t.Variant({mainnet:t.Null,testnet:t.Null}),r=t.Text,n=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,o=i,s=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),a=i,l=t.Record({network:e}),u=t.Nat64,c=t.Vec(u),f=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),p=t.Vec(t.Nat8),_=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),m=t.Record({height:t.Nat32,value:i,outpoint:_}),S=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:p,utxos:t.Vec(m)}),T=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),R=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:p,utxos:t.Vec(m)}),C=t.Record({transaction:t.Vec(t.Nat8),network:e}),y=t.Principal,U=t.Record({canister_id:y,num_requested_changes:t.Opt(t.Nat64)}),x=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),L=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),mt=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:x,details:L}),$=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(mt),total_num_changes:t.Nat64}),G=t.Record({canister_id:y}),rt=t.Variant({controllers:t.Null,public:t.Null}),nt=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:rt,memory_allocation:t.Nat,compute_allocation:t.Nat}),yt=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:nt,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),at=t.Record({canister_id:y}),Bt=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(rt),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),Ot=t.Record({settings:t.Opt(Bt),sender_canister_version:t.Opt(t.Nat64)}),ge=t.Record({canister_id:y}),$e=t.Record({canister_id:y}),w=t.Record({canister_id:y}),h=t.Variant({secp256k1:t.Null}),g=t.Record({key_id:t.Record({name:t.Text,curve:h}),canister_id:t.Opt(y),derivation_path:t.Vec(t.Vec(t.Nat8))}),b=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),B=t.Record({canister_id:y}),N=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),P=t.Record({canister_log_records:t.Vec(N)}),k=t.Record({value:t.Text,name:t.Text}),O=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(k)}),F=t.Record({url:t.Text,method:t.Variant({get:t.Null,head:t.Null,post:t.Null}),max_response_bytes:t.Opt(t.Nat64),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Record({function:t.Func([t.Record({context:t.Vec(t.Nat8),response:O})],[O],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(k)}),M=t.Vec(t.Nat8),Y=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),chunk_hashes_list:t.Vec(M),target_canister:y,sender_canister_version:t.Opt(t.Nat64),storage_canister:t.Opt(y)}),it=t.Vec(t.Nat8),z=t.Record({arg:t.Vec(t.Nat8),wasm_module:it,mode:t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),canister_id:y,sender_canister_version:t.Opt(t.Nat64)}),wt=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),ct=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_total:t.Nat64}),Lt=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(ct)})),te=t.Record({settings:t.Opt(Bt),specified_id:t.Opt(y),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),We=t.Record({canister_id:y}),Ge=t.Record({canister_id:y,amount:t.Nat}),Yr=t.Vec(t.Nat8),zr=t.Record({key_id:t.Record({name:t.Text,curve:h}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),Jr=t.Record({signature:t.Vec(t.Nat8)}),Xr=t.Record({canister_id:y}),Ye=t.Record({canister_id:y}),ze=t.Record({canister_id:y}),_e=t.Vec(M),Je=t.Record({canister_id:y,sender_canister_version:t.Opt(t.Nat64)}),Xe=t.Record({canister_id:t.Principal,settings:Bt,sender_canister_version:t.Opt(t.Nat64)}),Ze=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),Qe=M;return t.Service({bitcoin_get_balance:t.Func([n],[o],[]),bitcoin_get_balance_query:t.Func([s],[a],["query"]),bitcoin_get_current_fee_percentiles:t.Func([l],[c],[]),bitcoin_get_utxos:t.Func([f],[S],[]),bitcoin_get_utxos_query:t.Func([T],[R],["query"]),bitcoin_send_transaction:t.Func([C],[],[]),canister_info:t.Func([U],[$],[]),canister_status:t.Func([G],[yt],[]),clear_chunk_store:t.Func([at],[],[]),create_canister:t.Func([Ot],[ge],[]),delete_canister:t.Func([$e],[],[]),deposit_cycles:t.Func([w],[],[]),ecdsa_public_key:t.Func([g],[b],[]),fetch_canister_logs:t.Func([B],[P],["query"]),http_request:t.Func([F],[O],[]),install_chunked_code:t.Func([Y],[],[]),install_code:t.Func([z],[],[]),node_metrics_history:t.Func([wt],[Lt],[]),provisional_create_canister_with_cycles:t.Func([te],[We],[]),provisional_top_up_canister:t.Func([Ge],[],[]),raw_rand:t.Func([],[Yr],[]),sign_with_ecdsa:t.Func([zr],[Jr],[]),start_canister:t.Func([Xr],[],[]),stop_canister:t.Func([Ye],[],[]),stored_chunks:t.Func([ze],[_e],[]),uninstall_code:t.Func([Je],[],[]),update_settings:t.Func([Xe],[],[]),upload_chunk:t.Func([Ze],[Qe],[])})};var Cr=class extends tt{constructor(e,r,n,i){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(o=>` "${o}": ${JSON.stringify(i[o])}`)].join(`
|
|
28
|
+
`)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}},Rn=class extends Cr{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=lr[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},Bn=class extends Cr{constructor(e,r,n,i){super(e,r,"update",Object.assign({"Request ID":K(n)},i.body?Object.assign(Object.assign({},i.body.error_code?{"Error code":i.body.error_code}:{}),{"Reject code":String(i.body.reject_code),"Reject message":i.body.reject_message}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i}},st=Symbol.for("ic-agent-metadata"),Qt=class t{constructor(e){this[st]=Object.freeze(e)}static agentOf(e){return e[st].config.agent}static interfaceOf(e){return e[st].service}static canisterIdOf(e){return A.from(e[st].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],o=[...new Uint8Array(e.module)],s=typeof r.canisterId=="string"?A.fromText(r.canisterId):r.canisterId;await mo(r).install_code({mode:n,arg:i,wasm_module:o,canister_id:s,sender_canister_version:[]})}static async createCanister(e,r){function n(o){return[{controllers:o.controllers?[o.controllers]:[],compute_allocation:o.compute_allocation?[o.compute_allocation]:[],freezing_threshold:o.freezing_threshold?[o.freezing_threshold]:[],memory_allocation:o.memory_allocation?[o.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[]}]}let{canister_id:i}=await mo(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:xe});class i extends t{constructor(s){if(!s.canisterId)throw new tt(`Canister ID is required, but received ${typeof s.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof s.canisterId=="string"?A.fromText(s.canisterId):s.canisterId;super({config:Object.assign(Object.assign(Object.assign({},wo),s),{canisterId:a}),service:n});for(let[l,u]of n._fields)r?.httpDetails&&u.annotations.push(On),this[l]=Wa(this,l,u,s.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new tt(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}};function Pr(t,e){let r=xe.decode(t,yo.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var wo={pollingStrategyFactory:Nr.defaultStrategy},On="http-details";function Wa(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(s,...a)=>{var l,u;s=Object.assign(Object.assign({},s),(u=(l=t[st].config).queryTransform)===null||u===void 0?void 0:u.call(l,e,a,Object.assign(Object.assign({},t[st].config),s)));let c=s.agent||t[st].config.agent||vn(),f=A.from(s.canisterId||t[st].config.canisterId),p=xe.encode(r.argTypes,a),_=await c.query(f,{methodName:e,arg:p,effectiveCanisterId:s.effectiveCanisterId});switch(_.status){case"rejected":throw new Rn(f,e,_);case"replied":return r.annotations.includes(On)?{httpDetails:_.httpDetails,result:Pr(r.retTypes,_.reply.arg)}:Pr(r.retTypes,_.reply.arg)}}:i=async(s,...a)=>{var l,u;s=Object.assign(Object.assign({},s),(u=(l=t[st].config).callTransform)===null||u===void 0?void 0:u.call(l,e,a,Object.assign(Object.assign({},t[st].config),s)));let c=s.agent||t[st].config.agent||vn(),{canisterId:f,effectiveCanisterId:p,pollingStrategyFactory:_}=Object.assign(Object.assign(Object.assign({},wo),t[st].config),s),m=A.from(f),S=p!==void 0?A.from(p):m,T=xe.encode(r.argTypes,a),{requestId:R,response:C}=await c.call(m,{methodName:e,arg:T,effectiveCanisterId:S});if(!C.ok||C.body)throw new Bn(m,e,R,C);let y=_(),U=await Sn(c,S,R,y,n),x=r.annotations.includes(On);if(U!==void 0)return x?{httpDetails:C,result:Pr(r.retTypes,U)}:Pr(r.retTypes,U);if(r.retTypes.length===0)return x?{httpDetails:C,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let o=(...s)=>i({},...s);return o.withOptions=s=>(...a)=>i(s,...a),o}function mo(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:A.from(t.effectiveCanisterId)};let i=n[0],o=A.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(o=A.from(i.canister_id)),{effectiveCanisterId:o}}return Qt.createActor(po,Object.assign(Object.assign(Object.assign({},t),{canisterId:A.fromHex("")}),{callTransform:e,queryTransform:e}))}var Ur=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ht=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)},kr,Fr,pe,me;function go(t){return t!==null&&typeof t=="object"}var It=class t{constructor(e){if(kr.set(this,void 0),Fr.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Ur(this,kr,e,"f"),Ur(this,Fr,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=gt(e);return this.fromRaw(r)}else if(go(e)){let r=e;if(go(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw(tr(n.buffer))}else{if(r instanceof ArrayBuffer)return this.fromRaw(r);if("rawKey"in r)return this.fromRaw(r.rawKey);if("derKey"in r)return this.fromDer(r.derKey);if("toDer"in r)return this.fromDer(r.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){let r=le(e,zt).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=Re(e,zt);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Ht(this,kr,"f")}get derKey(){return Ht(this,Fr,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};kr=new WeakMap,Fr=new WeakMap;It.RAW_KEY_LENGTH=32;var Dt=class t extends kt{constructor(e,r){super(),pe.set(this,void 0),me.set(this,void 0),Ur(this,pe,It.from(e),"f"),Ur(this,me,new Uint8Array(r),"f")}static generate(e){if(e&&e.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");e||(e=jt.utils.randomPrivateKey()),Le(e,new Uint8Array(new Array(32).fill(0)))&&console.warn("Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.");let r=new Uint8Array(32);for(let i=0;i<32;i++)r[i]=new Uint8Array(e)[i];let n=jt.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(It.fromDer(gt(r)),gt(n))}static fromJSON(e){let r=JSON.parse(e);if(Array.isArray(r)){if(typeof r[0]=="string"&&typeof r[1]=="string")return this.fromParsedJson([r[0],r[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(e)}`)}static fromKeyPair(e,r){return new t(It.fromRaw(e),r)}static fromSecretKey(e){let r=jt.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[K(Ht(this,pe,"f").toDer()),K(Ht(this,me,"f"))]}getKeyPair(){return{secretKey:Ht(this,me,"f"),publicKey:Ht(this,pe,"f")}}getPublicKey(){return Ht(this,pe,"f")}async sign(e){let r=new Uint8Array(e),n=ei(jt.sign(r,Ht(this,me,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(e,r,n){let[i,o,s]=[e,r,n].map(a=>(typeof a=="string"&&(a=gt(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return jt.verify(o,i,s)}};pe=new WeakMap,me=new WeakMap;var Nn=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};function _o(t){if(typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.subtle)return globalThis.crypto.subtle;if(t)return t;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new Nn("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var Ce=class t extends kt{constructor(e,r,n){super(),this._keyPair=e,this._derKey=r,this._subtleCrypto=n}static async generate(e){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=e??{},o=_o(i),s=await o.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await o.exportKey("spki",s.publicKey);return new this(s,a,o)}static async fromKeyPair(e,r){let n=_o(r),i=await n.exportKey("spki",e.publicKey);return new t(e,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let e=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return e},r}async sign(e){let r={name:"ECDSA",hash:{name:"SHA-256"}};return this._keyPair.privateKey,await this._subtleCrypto.sign(r,this._keyPair.privateKey,e)}};var ye=Ie(ri());var Ya=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ke=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},$t,Mr=class{constructor(e){$t.set(this,void 0),Ya(this,$t,e,"f")}get rawKey(){return ke(this,$t,"f").rawKey}get derKey(){return ke(this,$t,"f").derKey}toDer(){return ke(this,$t,"f").toDer()}getPublicKey(){return ke(this,$t,"f")}getPrincipal(){return A.from(ke(this,$t,"f").rawKey)}transformRequest(){return Promise.reject("Not implemented. You are attempting to use a partial identity to sign calls, but this identity only has access to the public key.To sign calls, use a DelegationIdentity instead.")}};$t=new WeakMap;var za=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ja=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)},Xa=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},Vr,Za=new TextEncoder().encode("ic-request-auth-delegation"),Qa=new TextEncoder().encode(`
|
|
29
|
+
ic-request`);function Pn(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return gt(t)}var we=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return ye.value.map(Object.assign({pubkey:ye.value.bytes(this.pubkey),expiration:ye.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:ye.value.array(this.targets.map(e=>ye.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:K(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};async function Ia(t,e,r,n){let i=new we(e.toDer(),BigInt(+r)*BigInt(1e6),n),o=new Uint8Array([...Za,...new Uint8Array(Mt(i))]),s=await t.sign(o);return{delegation:i,signature:s}}var Fe=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+15*60*1e3),i={}){var o,s;let a=await Ia(e,r,n,i.targets);return new t([...((o=i.previous)===null||o===void 0?void 0:o.delegations)||[],a],((s=i.previous)===null||s===void 0?void 0:s.publicKey)||e.getPublicKey().toDer())}static fromJSON(e){let{publicKey:r,delegations:n}=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(o=>{let{delegation:s,signature:a}=o,{pubkey:l,expiration:u,targets:c}=s;if(c!==void 0&&!Array.isArray(c))throw new Error("Invalid targets.");return{delegation:new we(Pn(l),BigInt("0x"+u),c&&c.map(f=>{if(typeof f!="string")throw new Error("Invalid target.");return A.fromHex(f)})),signature:Pn(a)}});return new this(i,Pn(r))}static fromDelegations(e,r){return new this(e,r)}toJSON(){return{delegations:this.delegations.map(e=>{let{delegation:r,signature:n}=e,{targets:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:K(r.pubkey)},i&&{targets:i.map(o=>o.toHex())}),signature:K(n)}}),publicKey:K(this.publicKey)}}},Ue=class extends kt{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=Xa(e,["body"]),i=await Mt(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...Qa,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}},Me=class t extends Mr{constructor(e,r){super(e),Vr.set(this,void 0),za(this,Vr,r,"f")}get delegation(){return Ja(this,Vr,"f")}static fromDelegation(e,r){return new t(e,r)}};Vr=new WeakMap;function xo(t,e){for(let{delegation:i}of t.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?A.fromText(i):i)):r.push(typeof n=="string"?A.fromText(n):n));for(let i of r){let o=i.toText();for(let{delegation:s}of t.delegations){if(s.targets===void 0)continue;let a=!0;for(let l of s.targets)if(l.toText()===o){a=!1;break}if(a)return!1}}return!0}var Da=Ie(cs());var bo;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(bo||(bo={}));var Eo=["mousedown","mousemove","keydown","touchstart","wheel"],Ve=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let o=this._resetTimer.bind(this);window.addEventListener("load",o,!0),Eo.forEach(function(a){document.addEventListener(a,o,!0)});let s=(a,l)=>{let u;return(...c)=>{let f=this,p=function(){u=void 0,a.apply(f,c)};clearTimeout(u),u=window.setTimeout(p,l)}};if(e?.captureScroll){let a=s(o,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}o()}static create(e={}){return new this(e)}registerCallback(e){this.callbacks.push(e)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let e=this._resetTimer.bind(this);Eo.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 La=(t,e)=>e.some(r=>t instanceof r),To,Ao;function tc(){return To||(To=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ec(){return Ao||(Ao=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var vo=new WeakMap,kn=new WeakMap,So=new WeakMap,Cn=new WeakMap,Un=new WeakMap;function rc(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",o),t.removeEventListener("error",s)},o=()=>{r(St(t.result)),i()},s=()=>{n(t.error),i()};t.addEventListener("success",o),t.addEventListener("error",s)});return e.then(r=>{r instanceof IDBCursor&&vo.set(r,t)}).catch(()=>{}),Un.set(e,t),e}function nc(t){if(kn.has(t))return;let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("complete",o),t.removeEventListener("error",s),t.removeEventListener("abort",s)},o=()=>{r(),i()},s=()=>{n(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",o),t.addEventListener("error",s),t.addEventListener("abort",s)});kn.set(t,e)}var Fn={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return kn.get(t);if(e==="objectStoreNames")return t.objectStoreNames||So.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return St(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function Ro(t){Fn=t(Fn)}function ic(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Kr(this),e,...r);return So.set(n,e.sort?e.sort():[e]),St(n)}:ec().includes(t)?function(...e){return t.apply(Kr(this),e),St(vo.get(this))}:function(...e){return St(t.apply(Kr(this),e))}}function oc(t){return typeof t=="function"?ic(t):(t instanceof IDBTransaction&&nc(t),La(t,tc())?new Proxy(t,Fn):t)}function St(t){if(t instanceof IDBRequest)return rc(t);if(Cn.has(t))return Cn.get(t);let e=oc(t);return e!==t&&(Cn.set(t,e),Un.set(e,t)),e}var Kr=t=>Un.get(t);function Oo(t,e,{blocked:r,upgrade:n,blocking:i,terminated:o}={}){let s=indexedDB.open(t,e),a=St(s);return n&&s.addEventListener("upgradeneeded",l=>{n(St(s.result),l.oldVersion,l.newVersion,St(s.transaction),l)}),r&&s.addEventListener("blocked",l=>r(l.oldVersion,l.newVersion,l)),a.then(l=>{o&&l.addEventListener("close",()=>o()),i&&l.addEventListener("versionchange",u=>i(u.oldVersion,u.newVersion,u))}).catch(()=>{}),a}var sc=["get","getKey","getAll","getAllKeys","count"],ac=["put","add","delete","clear"],Mn=new Map;function Bo(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Mn.get(e))return Mn.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=ac.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||sc.includes(r)))return;let o=async function(s,...a){let l=this.transaction(s,i?"readwrite":"readonly"),u=l.store;return n&&(u=u.index(a.shift())),(await Promise.all([u[r](...a),i&&l.done]))[0]};return Mn.set(e,o),o}Ro(t=>({...t,get:(e,r,n)=>Bo(e,r)||t.get(e,r,n),has:(e,r)=>!!Bo(e,r)||t.has(e,r)}));var No="auth-client-db",Po="ic-keyval",cc=async(t=No,e=Po,r)=>(qr&&(localStorage!=null&&localStorage.getItem(ht))&&(localStorage.removeItem(ht),localStorage.removeItem(pt)),await Oo(t,r,{upgrade:n=>{n.objectStoreNames,n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function lc(t,e,r){return await t.get(e,r)}async function uc(t,e,r,n){return await t.put(e,n,r)}async function dc(t,e,r){return await t.delete(e,r)}var Ke=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=No,storeName:n=Po,version:i=Co}=e??{},o=await cc(r,n,i);return new t(o,n)}async set(e,r){return await uc(this._db,this._storeName,e,r)}async get(e){var r;return(r=await lc(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await dc(this._db,this._storeName,e)}};var fc=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},hc=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)},jr,pt="identity",ht="delegation",ko="iv",Co=1,qr=typeof window<"u",qe=class{constructor(e="ic-",r){this.prefix=e,this._localStorage=r}get(e){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+e))}set(e,r){return this._getLocalStorage().setItem(this.prefix+e,r),Promise.resolve()}remove(e){return this._getLocalStorage().removeItem(this.prefix+e),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let e=typeof window>"u"?typeof globalThis>"u"?typeof self>"u"?void 0:self.localStorage:globalThis.localStorage:window.localStorage;if(!e)throw new Error("Could not find local storage.");return e}},je=class{constructor(e){jr.set(this,void 0),fc(this,jr,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}Ke.create(hc(this,jr,"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)}};jr=new WeakMap;var pc="https://identity.ic0.app",mc="#authorize",Vn="ECDSA",Kn="Ed25519",yc=500,wc="UserInterrupt",Hr=class{constructor(e,r,n,i,o,s,a,l){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=o,this._createOptions=s,this._idpWindow=a,this._eventHandler=l,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let o=(r=e.storage)!==null&&r!==void 0?r:new je,s=(n=e.keyType)!==null&&n!==void 0?n:Vn,a=null;if(e.identity)a=e.identity;else{let f=await o.get(pt);if(!f&&qr)try{let p=new qe,_=await p.get(ht),m=await p.get(pt);_&&m&&s===Vn&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await o.set(ht,_),await o.set(pt,m),f=_,await p.remove(ht),await p.remove(pt))}catch(p){console.error("error while attempting to recover localstorage: "+p)}if(f)try{typeof f=="object"?s===Kn&&typeof f=="string"?a=await Dt.fromJSON(f):a=await Ce.fromKeyPair(f):typeof f=="string"&&(a=Dt.fromJSON(f))}catch{}}let l=new Ft,u=null;if(a)try{let f=await o.get(ht);if(typeof f=="object"&&f!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?l=e.identity:f&&(u=Fe.fromJSON(f),xo(u)?"toDer"in a?l=Me.fromDelegation(a,u):l=Ue.fromDelegation(a,u):(await qn(o),a=null))}catch(f){console.error(f),await qn(o),a=null}let c;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?c=void 0:(u||e.identity)&&(c=Ve.create(e.idleOptions)),a||(s===Kn?(a=await Dt.generate(),await o.set(pt,JSON.stringify(a.toJSON()))):(e.storage&&s===Vn&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${Kn}' as the key type, as it can serialize to a string`),a=await Ce.generate(),await o.set(pt,a.getKeyPair()))),new this(l,a,u,o,c,e)}_registerDefaultIdleCallback(){var e,r;let n=(e=this._createOptions)===null||e===void 0?void 0:e.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(e,r){var n,i;let o=e.delegations.map(u=>({delegation:new we(u.delegation.pubkey,u.delegation.expiration,u.delegation.targets),signature:u.signature.buffer})),s=Fe.fromDelegations(o,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=s,"toDer"in a?this._identity=Me.fromDelegation(a,this._chain):this._identity=Ue.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let l=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!l?.disableIdle&&(this.idleManager=Ve.create(l),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(ht,JSON.stringify(this._chain.toJSON())),r?.(e)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(e){var r,n,i,o;let s=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||pc);a.hash=mc,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=e?.maxTimeToLive)!==null&&i!==void 0?i:s},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(o=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&o!==void 0?o:void 0;let l=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(wc,e?.onError):setTimeout(l,yc))};l()}_getEventHandler(e,r){return async n=>{var i,o,s;if(n.origin!==e.origin){console.warn(`WARNING: expected origin '${e.origin}', got '${n.origin}' (ignoring)`);return}let a=n.data;switch(a.kind){case"authorize-ready":{let l=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(o=r?.derivationOrigin)===null||o===void 0?void 0:o.toString()},r?.customValues);(s=this._idpWindow)===null||s===void 0||s.postMessage(l,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(l){this._handleFailure(l.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.text,r?.onError);break;default:break}}}_handleFailure(e,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(e),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(e={}){if(await qn(this._storage),this._identity=new Ft,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};async function qn(t){await t.remove(pt),await t.remove(ht),await t.remove(ko)}var $r=()=>Hr.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Fo=async({data:t})=>{try{return await nr(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var jn=async t=>{let{data:e,version:r,description:n}=t;return{description:W(n),data:await pi(e),version:W(r)}},Hn=t=>{let{version:e}=t;return{version:W(e)}},He=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:o,...s}=t;return{key:e,description:j(i),owner:r.toText(),data:await nr(o),version:j(n),...s}};var Wr=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:V(t)?[]:[{key:W(t.key),description:W(t.description)}],paginate:W(V(e)?void 0:{start_after:W(e.startAfter),limit:W(V(e.limit)?void 0:BigInt(e.limit))}),order:W(V(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:W(V(n)?void 0:typeof n=="string"?A.fromText(n):n)});var Uo=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({controllers:t.Vec(t.Principal)}),n=t.Variant({Write:t.Null,Admin:t.Null}),i=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:n,expires_at:t.Opt(t.Nat64)}),o=t.Record({version:t.Opt(t.Nat64)}),s=t.Variant({Db:t.Null,Storage:t.Null}),a=t.Record({cycles:t.Nat,destination_id:t.Principal}),l=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),u=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),c=t.Record({key:l,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,u)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),f=t.Record({derivation_origin:t.Opt(t.Text)}),p=t.Record({internet_identity:t.Opt(f)}),_=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),m=t.Variant({Deny:t.Null,Allow:t.Null}),S=t.Record({status_code:t.Nat16,location:t.Text}),T=t.Record({iframe:t.Opt(_),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),raw_access:t.Opt(m),redirects:t.Opt(t.Vec(t.Tuple(t.Text,S)))}),R=t.Record({storage:T}),C=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)}),y=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)}),U=t.Variant({Heap:t.Null,Stable:t.Null}),x=t.Record({memory:U,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}),L=t.Variant({Callback:t.Record({token:x,callback:t.Func([],[],["query"])})}),mt=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(L),status_code:t.Nat16}),$=t.Record({token:t.Opt(x),body:t.Vec(t.Nat8)}),G=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}),rt=t.Record({batch_id:t.Nat}),nt=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),yt=t.Record({field:nt,desc:t.Bool}),at=t.Record({key:t.Opt(t.Text),description:t.Opt(t.Text)}),Bt=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),Ot=t.Record({order:t.Opt(yt),owner:t.Opt(t.Principal),matcher:t.Opt(at),paginate:t.Opt(Bt)}),ge=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,c)),items_length:t.Nat64}),$e=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),w=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,C)),items_length:t.Nat64}),h=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),g=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(U),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:h,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:h}),b=t.Record({stable:t.Nat64,heap:t.Nat64}),B=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:n,expires_at:t.Opt(t.Nat64)}),N=t.Record({controller:B,controllers:t.Vec(t.Principal)}),P=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),k=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(U),max_size:t.Opt(t.Nat),read:h,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:h}),O=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),F=t.Record({chunk_id:t.Nat});return t.Service({build_version:t.Func([],[t.Text],["query"]),commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([r],[t.Vec(t.Tuple(t.Principal,i))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,o],[],[]),del_docs:t.Func([t.Text],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,o))],[],[]),del_rule:t.Func([s,t.Text,o],[],[]),deposit_cycles:t.Func([a],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(c)],["query"]),get_auth_config:t.Func([],[t.Opt(p)],["query"]),get_config:t.Func([],[R],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(C)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(c)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(C)))],["query"]),http_request:t.Func([y],[mt],["query"]),http_request_streaming_callback:t.Func([x],[$],["query"]),init_asset_upload:t.Func([G],[rt],[]),list_assets:t.Func([t.Text,Ot],[ge],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,i))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,$e))],["query"]),list_docs:t.Func([t.Text,Ot],[w],["query"]),list_rules:t.Func([s],[t.Vec(t.Tuple(t.Text,g))],["query"]),memory_size:t.Func([],[b],["query"]),set_auth_config:t.Func([p],[],[]),set_config:t.Func([R],[],[]),set_controllers:t.Func([N],[t.Vec(t.Tuple(t.Principal,i))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,P],[C],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,P))],[t.Vec(t.Tuple(t.Text,C))],[]),set_rule:t.Func([s,t.Text,k],[],[]),upload_asset_chunk:t.Func([O],[F],[]),version:t.Func([],[t.Text],["query"])})};var Mo=async({satelliteId:t,idlFactory:e,identity:r,fetch:n,container:i})=>{let s=q(i)&&i!==!1?i===!0?ne:i:"https://icp-api.io",a=new Pe({identity:r,host:s,...n&&{fetch:n}});return q(i)&&await a.fetchRootKey(),Qt.createActor(e,{agent:a,canisterId:t})};var $n=({satelliteId:t,container:e})=>{let{satelliteId:r}=Wn({satelliteId:t}),{container:n}=Gn({container:e});if(q(n)&&n!==!1){let{host:i,protocol:o}=new URL(n===!0?ne:n);return`${o}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},Wn=({satelliteId:t})=>q(t)?{satelliteId:t}:_t.getInstance().get()??{satelliteId:void 0},Gn=({container:t})=>q(t)?{container:t}:_t.getInstance().get()??{container:void 0};var Q=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=Wn({satelliteId:t});hi(n,"No satellite principal defined.");let{container:i}=Gn({container:e});return Mo({satelliteId:n,container:i,idlFactory:Uo,...r})};var Vo=async({collection:t,key:e,satellite:r})=>{let n=await Q(r),i=j(await n.get_doc(t,e));if(!V(i))return He({doc:i,key:e})},Ko=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await Q(e),n=t.map(({collection:s,key:a})=>[s,a]),i=await r(n),o=[];for(let[s,a]of i){let l=j(a);o.push(q(l)?await He({key:s,doc:l}):void 0)}return o},qo=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await Q(r),{key:i}=e,o=await jn(e),s=await n(t,i,o);return await He({key:i,doc:s})},jo=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await Q(e),n=[];for(let{collection:s,doc:a}of t){let{key:l}=a;n.push([s,l,await jn(a)])}let i=await r(n),o=[];for(let[s,a]of i)o.push(await He({key:s,doc:a}));return o},Ho=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await Q(r),{key:i}=e;return n(t,i,Hn(e))},$o=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await Q(e),n=t.map(({collection:i,doc:o})=>[i,o.key,Hn(o)]);await r(n)},Wo=async({collection:t,filter:e,satellite:r})=>{let n=await Q(r),{items:i,items_page:o,items_length:s,matches_length:a,matches_pages:l}=await n.list_docs(t,Wr(e)),u=[];for(let[c,f]of i){let{data:p,owner:_,description:m,version:S,...T}=f;u.push({key:c,description:j(m),owner:_.toText(),data:await Fo({data:p}),version:j(S),...T})}return{items:u,items_length:s,items_page:j(o),matches_length:a,matches_pages:j(l)}};var I=t=>t!==void 0?t:Gr()??new Ft;var Go=async({satellite:t,...e})=>{let r=I(t?.identity);return Vo({...e,satellite:{...t,identity:r}})},_f=async({satellite:t,...e})=>{let r=I(t?.identity);return Ko({...e,satellite:{...t,identity:r}})},Yo=async({satellite:t,...e})=>{let r=I(t?.identity);return qo({...e,satellite:{...t,identity:r}})},xf=async({satellite:t,...e})=>{let r=I(t?.identity);return jo({...e,satellite:{...t,identity:r}})},bf=async({satellite:t,...e})=>{let r=I(t?.identity);return Ho({...e,satellite:{...t,identity:r}})},Ef=async({satellite:t,...e})=>{let r=I(t?.identity);return $o({...e,satellite:{...t,identity:r}})},Tf=async({satellite:t,filter:e,...r})=>{let n=I(t?.identity);return Wo({...r,filter:e??{},satellite:{...t,identity:n}})};var zo=async t=>{let e=Gr();if(V(e))throw new Error("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=await Go({collection:"#user",key:r});return V(n)?await gc({userId:r,provider:t}):n},gc=async({userId:t,...e})=>Yo({collection:"#user",doc:{key:t,data:e}});var Rt,Yn=async t=>{if(Rt=Rt??await $r(),!(await Rt?.isAuthenticated()??!1))return;let r=await zo(t);Pt.getInstance().set(r)},_c=async t=>new Promise(async(e,r)=>{Rt=Rt??await $r();let n=t?.provider??new or({});await Rt.login({onSuccess:async()=>{await Yn(n.id),e()},onError:i=>r(i),maxTimeToLive:t?.maxTimeToLive??mi,allowPinAuthentication:t?.allowPin??yi,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),zn=async()=>{await Rt?.logout(),Rt=void 0,Pt.getInstance().reset()},Gr=()=>Rt?.getIdentity(),xc=async()=>(Rt??await $r()).getIdentity();var Jo=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{rn({message:"junoSignOutAuthTimer"}),await zn()};return r.onmessage=async({data:i})=>{let{msg:o,data:s}=i;switch(o){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":rn({message:"junoDelegationRemainingTime",detail:s?.authRemainingTime});return}},Pt.getInstance().subscribe(i=>{if(V(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var Xo=async({data:t,filename:e,collection:r,headers:n,token:i,fullPath:o,encoding:s,description:a,satellite:l})=>{let u=await Q(l),{batch_id:c}=await u.init_asset_upload({collection:r,full_path:o,name:e,token:W(i),encoding_type:W(s),description:W(a)}),f=19e5,p=[],_=ir()?new Blob([await t.arrayBuffer()]):t,m=0n;for(let R=0;R<_.size;R+=f){let C=_.slice(R,R+f);p.push({batchId:c,chunk:C,actor:u,orderId:m}),m++}let S=[];for await(let R of bc({uploadChunks:p}))S=[...S,...R];let T=n.find(([R,C])=>R.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await u.commit_asset_upload({batch_id:c,chunk_ids:S.map(({chunk_id:R})=>R),headers:[...n,...T||[]]})};async function*bc({uploadChunks:t,limit:e=12}){for(let r=0;r<t.length;r=r+e){let n=t.slice(r,r+e);yield await Promise.all(n.map(o=>Ec(o)))}}var Ec=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:W(n)}),Zo=async({collection:t,satellite:e,filter:r})=>{let n=await Q(e),{items:i,items_length:o,items_page:s,matches_length:a,matches_pages:l}=await n.list_assets(t,Wr(r));return{items:i.map(([u,c])=>c),items_length:o,items_page:j(s),matches_length:a,matches_pages:j(l)}},Qo=async({collection:t,fullPath:e,satellite:r})=>(await Q(r)).del_asset(t,e),Io=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await Q(e),n=t.map(({collection:i,fullPath:o})=>[i,o]);await r(n)},Do=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await Q(r);return j(await n(t,e))},Lo=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await Q(e),n=t.map(({collection:o,fullPath:s})=>[o,s]);return(await r(n)).map(([o,s])=>j(s))};var ts=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var Qf=async t=>es(t),If=async t=>es({filename:t.data.name,...t}),es=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:o,satellite:s,encoding:a,description:l})=>{let u=I(s?.identity),c=decodeURI(t),f=i??`/${r}/${c}`,p={...s,identity:u};return await Xo({data:e,filename:c,collection:r,token:o,headers:n,fullPath:f,encoding:a,satellite:p,description:l}),{downloadUrl:`${$n(p)}${f}${o!==void 0?`?token=${o}`:""}`,fullPath:f,name:c}},Df=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:I(e?.identity)},{items:i,...o}=await Zo({collection:t,satellite:n,filter:r??{}}),s=$n(n);return{assets:i.map(({key:{full_path:a,token:l,name:u,owner:c,description:f},headers:p,encodings:_,created_at:m,updated_at:S})=>{let T=j(l);return{fullPath:a,description:j(f),name:u,downloadUrl:`${s}${a}${T!==void 0?`?token=${T}`:""}`,token:T,headers:p,encodings:_.reduce((R,[C,{modified:y,sha256:U,total_length:x}])=>({...R,[C]:{modified:y,sha256:ts(U),total_length:x}}),{}),owner:c.toText(),created_at:m,updated_at:S}}),...o}},Lf=async({collection:t,fullPath:e,satellite:r})=>Qo({collection:t,fullPath:e,satellite:{...r,identity:I(r?.identity)}}),th=async({assets:t,satellite:e})=>Io({assets:t,satellite:{...e,identity:I(e?.identity)}}),eh=async({satellite:t,...e})=>{let r=I(t?.identity);return Do({...e,satellite:{...t,identity:r}})},rh=async({satellite:t,...e})=>{let r=I(t?.identity);return Lo({...e,satellite:{...t,identity:r}})};var ch=async t=>{_t.getInstance().set(t),await Yn();let e=t.workers?.auth!==void 0?Jo(t.workers.auth):void 0;return[...e?[e]:[]]},lh=t=>Pt.getInstance().subscribe(t);export{or as InternetIdentityProvider,bi as NFIDProvider,lh as authSubscribe,Lf as deleteAsset,bf as deleteDoc,th as deleteManyAssets,Ef as deleteManyDocs,eh as getAsset,Go as getDoc,rh as getManyAssets,_f as getManyDocs,ch as initJuno,Df as listAssets,Tf as listDocs,Yo as setDoc,xf as setManyDocs,_c as signIn,zn as signOut,xc as unsafeIdentity,Qf as uploadBlob,If as uploadFile};
|
|
30
30
|
/*! Bundled license information:
|
|
31
31
|
|
|
32
32
|
buffer/index.js:
|