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