@junobuild/admin 0.0.15 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,24 +1,24 @@
1
- import{a as Mt,b as Ze,c as jt,d as f,e as Ht,f as y,g as Ie,h as W,i as N,j as $t,k as wt,l as De,m as D,n as L,o as zt}from"./chunk-CAKYEEJ6.js";var Xt=Mt(tt=>{"use strict";tt.byteLength=tr;tt.toByteArray=rr;tt.fromByteArray=ir;var R=[],g=[],Le=typeof Uint8Array<"u"?Uint8Array:Array,gt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(S=0,Jt=gt.length;S<Jt;++S)R[S]=gt[S],g[gt.charCodeAt(S)]=S;var S,Jt;g["-".charCodeAt(0)]=62;g["_".charCodeAt(0)]=63;function Qt(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 tr(t){var e=Qt(t),r=e[0],n=e[1];return(r+n)*3/4-n}function er(t,e,r){return(e+r)*3/4-r}function rr(t){var e,r=Qt(t),n=r[0],o=r[1],i=new Le(er(t,n,o)),a=0,c=o>0?n-4:n,l;for(l=0;l<c;l+=4)e=g[t.charCodeAt(l)]<<18|g[t.charCodeAt(l+1)]<<12|g[t.charCodeAt(l+2)]<<6|g[t.charCodeAt(l+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=e&255;return o===2&&(e=g[t.charCodeAt(l)]<<2|g[t.charCodeAt(l+1)]>>4,i[a++]=e&255),o===1&&(e=g[t.charCodeAt(l)]<<10|g[t.charCodeAt(l+1)]<<4|g[t.charCodeAt(l+2)]>>2,i[a++]=e>>8&255,i[a++]=e&255),i}function nr(t){return R[t>>18&63]+R[t>>12&63]+R[t>>6&63]+R[t&63]}function or(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(nr(n));return o.join("")}function ir(t){for(var e,r=t.length,n=r%3,o=[],i=16383,a=0,c=r-n;a<c;a+=i)o.push(or(t,a,a+i>c?c:a+i));return n===1?(e=t[r-1],o.push(R[e>>2]+R[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],o.push(R[e>>10]+R[e>>4&63]+R[e<<2&63]+"=")),o.join("")}});var ce=Mt(j=>{"use strict";var Tt=Xt(),M=Ie(),Zt=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;j.Buffer=s;j.SlowBuffer=pr;j.INSPECT_MAX_BYTES=50;var et=2147483647;j.kMaxLength=et;s.TYPED_ARRAY_SUPPORT=ar();!s.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 ar(){try{var 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(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}});Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function A(t){if(t>et)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,s.prototype),e}function s(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 Nt(t)}return Lt(t,e,r)}s.poolSize=8192;function Lt(t,e,r){if(typeof t=="string")return cr(t,e);if(ArrayBuffer.isView(t))return lr(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(C(t,ArrayBuffer)||t&&C(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(C(t,SharedArrayBuffer)||t&&C(t.buffer,SharedArrayBuffer)))return Ct(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return s.from(n,e,r);var o=ur(t);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return s.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)}s.from=function(t,e,r){return Lt(t,e,r)};Object.setPrototypeOf(s.prototype,Uint8Array.prototype);Object.setPrototypeOf(s,Uint8Array);function te(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 sr(t,e,r){return te(t),t<=0?A(t):e!==void 0?typeof r=="string"?A(t).fill(e,r):A(t).fill(e):A(t)}s.alloc=function(t,e,r){return sr(t,e,r)};function Nt(t){return te(t),A(t<0?0:At(t)|0)}s.allocUnsafe=function(t){return Nt(t)};s.allocUnsafeSlow=function(t){return Nt(t)};function cr(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=ee(t,e)|0,n=A(r),o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}function Rt(t){for(var e=t.length<0?0:At(t.length)|0,r=A(e),n=0;n<e;n+=1)r[n]=t[n]&255;return r}function lr(t){if(C(t,Uint8Array)){var e=new Uint8Array(t);return Ct(e.buffer,e.byteOffset,e.byteLength)}return Rt(t)}function Ct(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');var 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,s.prototype),n}function ur(t){if(s.isBuffer(t)){var e=At(t.length)|0,r=A(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||bt(t.length)?A(0):Rt(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Rt(t.data)}function At(t){if(t>=et)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+et.toString(16)+" bytes");return t|0}function pr(t){return+t!=t&&(t=0),s.alloc(+t)}s.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==s.prototype};s.compare=function(e,r){if(C(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),C(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),!s.isBuffer(e)||!s.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;for(var n=e.length,o=r.length,i=0,a=Math.min(n,o);i<a;++i)if(e[i]!==r[i]){n=e[i],o=r[i];break}return n<o?-1:o<n?1:0};s.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}};s.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return s.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;var o=s.allocUnsafe(r),i=0;for(n=0;n<e.length;++n){var a=e[n];if(C(a,Uint8Array))i+a.length>o.length?s.from(a).copy(o,i):Uint8Array.prototype.set.call(o,a,i);else if(s.isBuffer(a))a.copy(o,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=a.length}return o};function ee(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||C(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);var r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Ft(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return se(t).length;default:if(o)return n?-1:Ft(t).length;e=(""+e).toLowerCase(),o=!0}}s.byteLength=ee;function dr(t,e,r){var 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 Rr(this,e,r);case"utf8":case"utf-8":return ne(this,e,r);case"ascii":return gr(this,e,r);case"latin1":case"binary":return Tr(this,e,r);case"base64":return xr(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Cr(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}s.prototype._isBuffer=!0;function E(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}s.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<e;r+=2)E(this,r,r+1);return this};s.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<e;r+=4)E(this,r,r+3),E(this,r+1,r+2);return this};s.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<e;r+=8)E(this,r,r+7),E(this,r+1,r+6),E(this,r+2,r+5),E(this,r+3,r+4);return this};s.prototype.toString=function(){var e=this.length;return e===0?"":arguments.length===0?ne(this,0,e):dr.apply(this,arguments)};s.prototype.toLocaleString=s.prototype.toString;s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:s.compare(this,e)===0};s.prototype.inspect=function(){var e="",r=j.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};Zt&&(s.prototype[Zt]=s.prototype.inspect);s.prototype.compare=function(e,r,n,o,i){if(C(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.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;for(var a=i-o,c=n-r,l=Math.min(a,c),u=this.slice(o,i),d=e.slice(r,n),p=0;p<l;++p)if(u[p]!==d[p]){a=u[p],c=d[p];break}return a<c?-1:c<a?1:0};function re(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,bt(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=s.from(e,n)),s.isBuffer(e))return e.length===0?-1:It(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):It(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function It(t,e,r,n,o){var i=1,a=t.length,c=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,a/=2,c/=2,r/=2}function l(m,x){return i===1?m[x]:m.readUInt16BE(x*i)}var u;if(o){var d=-1;for(u=r;u<a;u++)if(l(t,u)===l(e,d===-1?0:u-d)){if(d===-1&&(d=u),u-d+1===c)return d*i}else d!==-1&&(u-=u-d),d=-1}else for(r+c>a&&(r=a-c),u=r;u>=0;u--){for(var p=!0,h=0;h<c;h++)if(l(t,u+h)!==l(e,h)){p=!1;break}if(p)return u}return-1}s.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};s.prototype.indexOf=function(e,r,n){return re(this,e,r,n,!0)};s.prototype.lastIndexOf=function(e,r,n){return re(this,e,r,n,!1)};function fr(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n),n>o&&(n=o)):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a<n;++a){var c=parseInt(e.substr(a*2,2),16);if(bt(c))return a;t[r+a]=c}return a}function hr(t,e,r,n){return rt(Ft(e,t.length-r),t,r,n)}function mr(t,e,r,n){return rt(Ar(e),t,r,n)}function yr(t,e,r,n){return rt(se(e),t,r,n)}function _r(t,e,r,n){return rt(br(e,t.length-r),t,r,n)}s.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");var 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");for(var a=!1;;)switch(o){case"hex":return fr(this,e,r,n);case"utf8":case"utf-8":return hr(this,e,r,n);case"ascii":case"latin1":case"binary":return mr(this,e,r,n);case"base64":return yr(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _r(this,e,r,n);default:if(a)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),a=!0}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function xr(t,e,r){return e===0&&r===t.length?Tt.fromByteArray(t):Tt.fromByteArray(t.slice(e,r))}function ne(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i=t[o],a=null,c=i>239?4:i>223?3:i>191?2:1;if(o+c<=r){var l,u,d,p;switch(c){case 1:i<128&&(a=i);break;case 2:l=t[o+1],(l&192)===128&&(p=(i&31)<<6|l&63,p>127&&(a=p));break;case 3:l=t[o+1],u=t[o+2],(l&192)===128&&(u&192)===128&&(p=(i&15)<<12|(l&63)<<6|u&63,p>2047&&(p<55296||p>57343)&&(a=p));break;case 4:l=t[o+1],u=t[o+2],d=t[o+3],(l&192)===128&&(u&192)===128&&(d&192)===128&&(p=(i&15)<<18|(l&63)<<12|(u&63)<<6|d&63,p>65535&&p<1114112&&(a=p))}}a===null?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),o+=c}return wr(n)}var Dt=4096;function wr(t){var e=t.length;if(e<=Dt)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Dt));return r}function gr(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]&127);return n}function Tr(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function Rr(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=Pr[t[i]];return o}function Cr(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length-1;i+=2)o+=String.fromCharCode(n[i]+n[i+1]*256);return o}s.prototype.slice=function(e,r){var 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);var o=this.subarray(e,r);return Object.setPrototypeOf(o,s.prototype),o};function _(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")}s.prototype.readUintLE=s.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||_(e,r,this.length);for(var o=this[e],i=1,a=0;++a<r&&(i*=256);)o+=this[e+a]*i;return o};s.prototype.readUintBE=s.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||_(e,r,this.length);for(var o=this[e+--r],i=1;r>0&&(i*=256);)o+=this[e+--r]*i;return o};s.prototype.readUint8=s.prototype.readUInt8=function(e,r){return e=e>>>0,r||_(e,1,this.length),this[e]};s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||_(e,2,this.length),this[e]|this[e+1]<<8};s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||_(e,2,this.length),this[e]<<8|this[e+1]};s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||_(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||_(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};s.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||_(e,r,this.length);for(var o=this[e],i=1,a=0;++a<r&&(i*=256);)o+=this[e+a]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*r)),o};s.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||_(e,r,this.length);for(var o=r,i=1,a=this[e+--o];o>0&&(i*=256);)a+=this[e+--o]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*r)),a};s.prototype.readInt8=function(e,r){return e=e>>>0,r||_(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};s.prototype.readInt16LE=function(e,r){e=e>>>0,r||_(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};s.prototype.readInt16BE=function(e,r){e=e>>>0,r||_(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};s.prototype.readInt32LE=function(e,r){return e=e>>>0,r||_(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};s.prototype.readInt32BE=function(e,r){return e=e>>>0,r||_(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};s.prototype.readFloatLE=function(e,r){return e=e>>>0,r||_(e,4,this.length),M.read(this,e,!0,23,4)};s.prototype.readFloatBE=function(e,r){return e=e>>>0,r||_(e,4,this.length),M.read(this,e,!1,23,4)};s.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||_(e,8,this.length),M.read(this,e,!0,52,8)};s.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||_(e,8,this.length),M.read(this,e,!1,52,8)};function w(t,e,r,n,o,i){if(!s.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")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,r,n,o){if(e=+e,r=r>>>0,n=n>>>0,!o){var i=Math.pow(2,8*n)-1;w(this,e,r,n,i,0)}var a=1,c=0;for(this[r]=e&255;++c<n&&(a*=256);)this[r+c]=e/a&255;return r+n};s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,r,n,o){if(e=+e,r=r>>>0,n=n>>>0,!o){var i=Math.pow(2,8*n)-1;w(this,e,r,n,i,0)}var a=n-1,c=1;for(this[r+a]=e&255;--a>=0&&(c*=256);)this[r+a]=e/c&255;return r+n};s.prototype.writeUint8=s.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||w(this,e,r,1,255,0),this[r]=e&255,r+1};s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||w(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||w(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||w(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};s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||w(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};s.prototype.writeIntLE=function(e,r,n,o){if(e=+e,r=r>>>0,!o){var i=Math.pow(2,8*n-1);w(this,e,r,n,i-1,-i)}var a=0,c=1,l=0;for(this[r]=e&255;++a<n&&(c*=256);)e<0&&l===0&&this[r+a-1]!==0&&(l=1),this[r+a]=(e/c>>0)-l&255;return r+n};s.prototype.writeIntBE=function(e,r,n,o){if(e=+e,r=r>>>0,!o){var i=Math.pow(2,8*n-1);w(this,e,r,n,i-1,-i)}var a=n-1,c=1,l=0;for(this[r+a]=e&255;--a>=0&&(c*=256);)e<0&&l===0&&this[r+a+1]!==0&&(l=1),this[r+a]=(e/c>>0)-l&255;return r+n};s.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||w(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};s.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||w(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};s.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||w(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};s.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||w(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};s.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||w(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};function oe(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 ie(t,e,r,n,o){return e=+e,r=r>>>0,o||oe(t,e,r,4,34028234663852886e22,-34028234663852886e22),M.write(t,e,r,n,23,4),r+4}s.prototype.writeFloatLE=function(e,r,n){return ie(this,e,r,!0,n)};s.prototype.writeFloatBE=function(e,r,n){return ie(this,e,r,!1,n)};function ae(t,e,r,n,o){return e=+e,r=r>>>0,o||oe(t,e,r,8,17976931348623157e292,-17976931348623157e292),M.write(t,e,r,n,52,8),r+8}s.prototype.writeDoubleLE=function(e,r,n){return ae(this,e,r,!0,n)};s.prototype.writeDoubleBE=function(e,r,n){return ae(this,e,r,!1,n)};s.prototype.copy=function(e,r,n,o){if(!s.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);var 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};s.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"&&!s.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){var i=e.charCodeAt(0);(o==="utf8"&&i<128||o==="latin1")&&(e=i)}}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);var a;if(typeof e=="number")for(a=r;a<n;++a)this[a]=e;else{var c=s.isBuffer(e)?e:s.from(e,o),l=c.length;if(l===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(a=0;a<n-r;++a)this[a+r]=c[a%l]}return this};var Fr=/[^+/0-9A-Za-z-_]/g;function Nr(t){if(t=t.split("=")[0],t=t.trim().replace(Fr,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Ft(t,e){e=e||1/0;for(var r,n=t.length,o=null,i=[],a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(a+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 Ar(t){for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function br(t,e){for(var r,n,o,i=[],a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,o=r%256,i.push(o),i.push(n);return i}function se(t){return Tt.toByteArray(Nr(t))}function rt(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function C(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function bt(t){return t!==t}var Pr=function(){for(var t="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var n=r*16,o=0;o<16;++o)e[n+o]=t[r]+t[o];return e}()});var Kt=({IDL:t})=>{let e=t.Principal,r=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),n=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),o=t.Record({value:t.Text,name:t.Text}),i=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(o)}),a=t.Variant({dns_error:t.Null,no_consensus:t.Null,transform_error:t.Null,unreachable:t.Null,bad_tls:t.Null,conn_timeout:t.Null,invalid_url:t.Null,timeout:t.Null}),c=t.Vec(t.Nat8);return t.Service({canister_status:t.Func([t.Record({canister_id:e})],[t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:r,module_hash:t.Opt(t.Vec(t.Nat8))})],[]),create_canister:t.Func([t.Record({settings:t.Opt(n)})],[t.Record({canister_id:e})],[]),delete_canister:t.Func([t.Record({canister_id:e})],[],[]),deposit_cycles:t.Func([t.Record({canister_id:e})],[],[]),http_request:t.Func([t.Record({url:t.Text,method:t.Variant({get:t.Null}),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Variant({function:t.Func([i],[i],["query"])})),headers:t.Vec(o)})],[t.Variant({Ok:i,Err:t.Opt(a)})],[]),install_code:t.Func([t.Record({arg:t.Vec(t.Nat8),wasm_module:c,mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),canister_id:e})],[],[]),provisional_create_canister_with_cycles:t.Func([t.Record({settings:t.Opt(n),amount:t.Opt(t.Nat)})],[t.Record({canister_id:e})],[]),provisional_top_up_canister:t.Func([t.Record({canister_id:e,amount:t.Nat})],[],[]),raw_rand:t.Func([],[t.Vec(t.Nat8)],[]),start_canister:t.Func([t.Record({canister_id:e})],[],[]),stop_canister:t.Func([t.Record({canister_id:e})],[],[]),uninstall_code:t.Func([t.Record({canister_id:e})],[],[]),update_settings:t.Func([t.Record({canister_id:t.Principal,settings:n})],[],[])})};var Wt=({IDL:t})=>{let e=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,satellite_id:t.Principal}),r=t.Variant({Write:t.Null,Admin:t.Null}),n=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:r,expires_at:t.Opt(t.Nat64)}),o=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),i=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),a=t.Record({status:o,memory_size:t.Nat,cycles:t.Nat,settings:i,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))}),c=t.Record({id:t.Principal,status:a,metadata:t.Opt(t.Vec(t.Tuple(t.Text,t.Text))),status_at:t.Nat64}),l=t.Variant({Ok:c,Err:t.Text}),u=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:r,expires_at:t.Opt(t.Nat64)}),d=t.Record({enabled:t.Bool,cycles_threshold:t.Opt(t.Nat64)}),p=t.Record({mission_control_cycles_threshold:t.Opt(t.Nat64),satellites:t.Vec(t.Tuple(t.Principal,d)),cycles_threshold:t.Opt(t.Nat64)}),h=t.Record({satellites:t.Opt(t.Vec(l)),mission_control:l}),m=t.Record({e8s:t.Nat64});return t.Service({add_mission_control_controllers:t.Func([t.Vec(t.Principal)],[],[]),add_satellites_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal)],[],[]),create_satellite:t.Func([t.Text],[e],[]),del_mission_control_controllers:t.Func([t.Vec(t.Principal)],[],[]),del_satellites_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal)],[],[]),get_user:t.Func([],[t.Principal],["query"]),list_mission_control_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,n))],["query"]),list_mission_control_statuses:t.Func([],[t.Vec(t.Tuple(t.Nat64,l))],["query"]),list_satellite_statuses:t.Func([t.Principal],[t.Opt(t.Vec(t.Tuple(t.Nat64,l)))],["query"]),list_satellites:t.Func([],[t.Vec(t.Tuple(t.Principal,e))],["query"]),remove_mission_control_controllers:t.Func([t.Vec(t.Principal)],[],[]),remove_satellites_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal)],[],[]),set_metadata:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),set_mission_control_controllers:t.Func([t.Vec(t.Principal),u],[],[]),set_satellites_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal),u],[],[]),status:t.Func([p],[h],[]),top_up:t.Func([t.Principal,m],[],[]),version:t.Func([],[t.Text],["query"])})};var Gt=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({controllers:t.Vec(t.Principal)}),n=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,expires_at:t.Opt(t.Nat64)}),o=t.Record({updated_at:t.Opt(t.Nat64)}),i=t.Record({headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text))))}),a=t.Record({storage:i}),c=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),created_at:t.Nat64}),l=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text))}),u=t.Record({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}),d=t.Variant({Callback:t.Record({token:u,callback:t.Func([],[],[])})}),p=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(d),status_code:t.Nat16}),h=t.Record({token:t.Opt(u),body:t.Vec(t.Nat8)}),m=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,encoding_type:t.Opt(t.Text),full_path:t.Text}),x=t.Record({batch_id:t.Nat}),V=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),z=t.Record({field:V,desc:t.Bool}),B=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),P=t.Record({order:t.Opt(z),matcher:t.Opt(t.Text),paginate:t.Opt(B)}),K=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,full_path:t.Text}),U=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),Z=t.Record({key:K,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,U)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64}),ut=t.Record({matches_length:t.Nat64,length:t.Nat64,items:t.Vec(t.Tuple(t.Text,Z))}),pt=t.Record({updated_at:t.Nat64,created_at:t.Nat64,bn_id:t.Opt(t.Text)}),dt=t.Record({matches_length:t.Nat64,length:t.Nat64,items:t.Vec(t.Tuple(t.Text,c))}),I=t.Variant({Db:t.Null,Storage:t.Null}),k=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),ft=t.Record({updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:k,created_at:t.Nat64,write:k}),q=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),expires_at:t.Opt(t.Nat64)}),ht=t.Record({controller:q,controllers:t.Vec(t.Principal)}),mt=t.Record({updated_at:t.Opt(t.Nat64),data:t.Vec(t.Nat8)}),yt=t.Record({updated_at:t.Opt(t.Nat64),max_size:t.Opt(t.Nat),read:k,write:k}),_t=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat}),xt=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Opt(t.Text)],[],[]),del_controllers:t.Func([r],[t.Vec(t.Tuple(t.Principal,n))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,o],[],[]),get_config:t.Func([],[a],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(c)],["query"]),http_request:t.Func([l],[p],["query"]),http_request_streaming_callback:t.Func([u],[h],["query"]),init_asset_upload:t.Func([m],[x],[]),list_assets:t.Func([t.Opt(t.Text),P],[ut],["query"]),list_controllers:t.Func([],[t.Vec(t.Principal)],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,pt))],["query"]),list_docs:t.Func([t.Text,P],[dt],["query"]),list_rules:t.Func([I],[t.Vec(t.Tuple(t.Text,ft))],["query"]),set_config:t.Func([a],[],[]),set_controllers:t.Func([ht],[t.Vec(t.Tuple(t.Principal,n))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,mt],[c],[]),set_rule:t.Func([I,t.Text,yt],[],[]),upload_asset_chunk:t.Func([_t],[xt],[]),version:t.Func([],[t.Text],["query"])})};var Yt=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({controllers:t.Vec(t.Principal)}),n=t.Variant({Write:t.Null,Admin:t.Null}),o=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:n,expires_at:t.Opt(t.Nat64)}),i=t.Record({updated_at:t.Opt(t.Nat64)}),a=t.Variant({Db:t.Null,Storage:t.Null}),c=t.Record({headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text))))}),l=t.Record({storage:c}),u=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64}),d=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text))}),p=t.Record({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}),h=t.Variant({Callback:t.Record({token:p,callback:t.Func([],[],[])})}),m=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(h),status_code:t.Nat16}),x=t.Record({token:t.Opt(p),body:t.Vec(t.Nat8)}),V=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}),z=t.Record({batch_id:t.Nat}),B=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),P=t.Record({field:B,desc:t.Bool}),K=t.Record({key:t.Opt(t.Text),description:t.Opt(t.Text)}),U=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),Z=t.Record({order:t.Opt(P),owner:t.Opt(t.Principal),matcher:t.Opt(K),paginate:t.Opt(U)}),ut=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}),pt=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),dt=t.Record({key:ut,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,pt)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64}),I=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,dt)),items_length:t.Nat64}),k=t.Record({updated_at:t.Nat64,created_at:t.Nat64,bn_id:t.Opt(t.Text)}),ft=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,u)),items_length:t.Nat64}),q=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),ht=t.Record({updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:q,created_at:t.Nat64,write:q}),mt=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:n,expires_at:t.Opt(t.Nat64)}),yt=t.Record({controller:mt,controllers:t.Vec(t.Principal)}),_t=t.Record({updated_at:t.Opt(t.Nat64),data:t.Vec(t.Nat8),description:t.Opt(t.Text)}),xt=t.Record({updated_at:t.Opt(t.Nat64),max_size:t.Opt(t.Nat),read:q,write:q}),Qe=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat}),Xe=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Opt(t.Text)],[],[]),del_controllers:t.Func([r],[t.Vec(t.Tuple(t.Principal,o))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,i],[],[]),del_rule:t.Func([a,t.Text,i],[],[]),get_config:t.Func([],[l],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(u)],["query"]),http_request:t.Func([d],[m],["query"]),http_request_streaming_callback:t.Func([p],[x],["query"]),init_asset_upload:t.Func([V],[z],[]),list_assets:t.Func([t.Opt(t.Text),Z],[I],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,o))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,k))],["query"]),list_docs:t.Func([t.Text,Z],[ft],["query"]),list_rules:t.Func([a],[t.Vec(t.Tuple(t.Text,ht))],["query"]),set_config:t.Func([l],[],[]),set_controllers:t.Func([yt],[t.Vec(t.Tuple(t.Principal,o))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,_t],[u],[]),set_rule:t.Func([a,t.Text,xt],[],[]),upload_asset_chunk:t.Func([Qe],[Xe],[]),version:t.Func([],[t.Text],["query"])})};var Te=jt(ce());var nt;(function(t){t[t.SysFatal=1]="SysFatal",t[t.SysTransient=2]="SysTransient",t[t.DestinationInvalid=3]="DestinationInvalid",t[t.CanisterReject=4]="CanisterReject",t[t.CanisterError=5]="CanisterError"})(nt||(nt={}));var an=new TextEncoder().encode(`
2
- ic-request`);var ot=class{getPrincipal(){return f.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};var le=jt(De());var it;(function(t){t.Call="call"})(it||(it={}));function G(){let t=new ArrayBuffer(16),e=new DataView(t),r=BigInt(+Date.now()),n=Math.floor(Math.random()*4294967295),o=Math.floor(Math.random()*4294967295);if(typeof e.setBigUint64=="function")e.setBigUint64(0,r);else{let i=BigInt(1)<<BigInt(32);e.setUint32(0,Number(r>>BigInt(32))),e.setUint32(4,Number(r%i))}return e.setUint32(8,n),e.setUint32(12,o),t}var Sr=BigInt(1e6),Er=BigInt(60*1e3),O=class{constructor(e){this._value=(BigInt(Date.now())+BigInt(e)-Er)*Sr}toCBOR(){return le.value.u64(this._value.toString(16),16)}toHash(){return Ht(this._value)}};function ue(t=G){return async e=>{let r=t(),n=e.request.headers?new Headers(e.request.headers):new Headers;e.request.headers=n,e.endpoint==="call"&&(e.body.nonce=t())}}var F;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(F||(F={}));var at=5*60*1e3,vr="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae",Vr="ic0.app",Br=".ic0.app",Ur="icp0.io",kr=".icp0.io",qr="icp-api.io",Mr=".icp-api.io",Y=class extends W{constructor(e){super(e),this.message=e}},H=class extends W{constructor(e){super(e),this.message=e}};function jr(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new Y("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new Y("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(t=self.fetch.bind(self));if(t)return t;throw new Y("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var v=class{constructor(e={}){if(this.rootKey=$t(vr),this._pipeline=[],this._timeDiffMsecs=0,this._rootKeyFetched=!1,this._retryTimes=3,this._isAgent=!0,e.source){if(!(e.source instanceof v))throw new Error("An Agent's source can only be another HttpAgent");this._pipeline=[...e.source._pipeline],this._identity=e.source._identity,this._fetch=e.source._fetch,this._host=e.source._host,this._credentials=e.source._credentials}else this._fetch=e.fetch||jr()||fetch.bind(window),this._fetchOptions=e.fetchOptions,this._callOptions=e.callOptions;if(e.host!==void 0)!e.host.match(/^[a-z]+:/)&&typeof window<"u"?this._host=new URL(window.location.protocol+"//"+e.host):this._host=new URL(e.host);else if(e.source!==void 0)this._host=e.source._host;else{let r=typeof window<"u"?window.location:void 0;if(!r)throw new Error("Must specify a host to connect to.");this._host=new URL(r+"")}if(e.retryTimes!==void 0&&(this._retryTimes=e.retryTimes),this._host.hostname.endsWith(Br)?this._host.hostname=Vr:this._host.hostname.endsWith(kr)?this._host.hostname=Ur:this._host.hostname.endsWith(Mr)&&(this._host.hostname=qr),e.credentials){let{name:r,password:n}=e.credentials;this._credentials=`${r}${n?":"+n:""}`}this._identity=Promise.resolve(e.identity||new ot),e.disableNonce||this.addTransform(ue(G))}isLocal(){let e=this._host.hostname;return e==="127.0.0.1"||e.endsWith("localhost")}addTransform(e,r=e.priority||0){let n=this._pipeline.findIndex(o=>(o.priority||0)<r);this._pipeline.splice(n>=0?n:this._pipeline.length,0,Object.assign(e,{priority:r}))}async getPrincipal(){if(!this._identity)throw new H("This identity has expired due this application's security policy. Please refresh your authentication.");return(await this._identity).getPrincipal()}async call(e,r,n){let o=await(n!==void 0?await n:await this._identity);if(!o)throw new H("This identity has expired due this application's security policy. Please refresh your authentication.");let i=f.from(e),a=r.effectiveCanisterId?f.from(r.effectiveCanisterId):i,c=o.getPrincipal()||f.anonymous(),l=new O(at);Math.abs(this._timeDiffMsecs)>1e3*30&&(l=new O(at+this._timeDiffMsecs));let u={request_type:it.Call,canister_id:i,method_name:r.methodName,arg:r.arg,sender:c,ingress_expiry:l},d=await this._transform({request:{body:null,method:"POST",headers:new Headers(Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{}))},endpoint:"call",body:u});d=await o.transformRequest(d);let p=D(d.body),h=this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${a.toText()}/call`,this._host),Object.assign(Object.assign(Object.assign({},this._callOptions),d.request),{body:p}))),[m,x]=await Promise.all([h,wt(u)]);return{requestId:x,response:{ok:m.ok,status:m.status,statusText:m.statusText}}}async _requestAndRetry(e,r=0){if(r>this._retryTimes&&this._retryTimes!==0)throw new Error(`AgentError: Exceeded configured limit of ${this._retryTimes} retry attempts. Please check your network connection or try again in a few moments`);let n=await e();if(!n.ok){let o=await n.clone().text(),i=`Server returned an error:
1
+ import{a as jt,b as tr,c as Ht,d as f,e as $t,f as y,g as er,h as et,i as b,j as zt,k as Tt,l as rr,m as st,n as ct,o as Kt}from"./chunk-UAGXZWTT.js";var It=jt(lt=>{"use strict";lt.byteLength=or;lt.toByteArray=ar;lt.fromByteArray=lr;var C=[],w=[],nr=typeof Uint8Array<"u"?Uint8Array:Array,Rt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(q=0,Xt=Rt.length;q<Xt;++q)C[q]=Rt[q],w[Rt.charCodeAt(q)]=q;var q,Xt;w["-".charCodeAt(0)]=62;w["_".charCodeAt(0)]=63;function Zt(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 or(t){var e=Zt(t),r=e[0],n=e[1];return(r+n)*3/4-n}function ir(t,e,r){return(e+r)*3/4-r}function ar(t){var e,r=Zt(t),n=r[0],o=r[1],i=new nr(ir(t,n,o)),a=0,c=o>0?n-4:n,l;for(l=0;l<c;l+=4)e=w[t.charCodeAt(l)]<<18|w[t.charCodeAt(l+1)]<<12|w[t.charCodeAt(l+2)]<<6|w[t.charCodeAt(l+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=e&255;return o===2&&(e=w[t.charCodeAt(l)]<<2|w[t.charCodeAt(l+1)]>>4,i[a++]=e&255),o===1&&(e=w[t.charCodeAt(l)]<<10|w[t.charCodeAt(l+1)]<<4|w[t.charCodeAt(l+2)]>>2,i[a++]=e>>8&255,i[a++]=e&255),i}function sr(t){return C[t>>18&63]+C[t>>12&63]+C[t>>6&63]+C[t&63]}function cr(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(sr(n));return o.join("")}function lr(t){for(var e,r=t.length,n=r%3,o=[],i=16383,a=0,c=r-n;a<c;a+=i)o.push(cr(t,a,a+i>c?c:a+i));return n===1?(e=t[r-1],o.push(C[e>>2]+C[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],o.push(C[e>>10]+C[e>>4&63]+C[e<<2&63]+"=")),o.join("")}});var ue=jt(W=>{"use strict";var Nt=It(),K=er(),Dt=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;W.Buffer=s;W.SlowBuffer=hr;W.INSPECT_MAX_BYTES=50;var ut=2147483647;W.kMaxLength=ut;s.TYPED_ARRAY_SUPPORT=ur();!s.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 ur(){try{var 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(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}});Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function S(t){if(t>ut)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,s.prototype),e}function s(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 bt(t)}return ee(t,e,r)}s.poolSize=8192;function ee(t,e,r){if(typeof t=="string")return dr(t,e);if(ArrayBuffer.isView(t))return fr(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(F(t,ArrayBuffer)||t&&F(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(F(t,SharedArrayBuffer)||t&&F(t.buffer,SharedArrayBuffer)))return Ft(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return s.from(n,e,r);var o=mr(t);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return s.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)}s.from=function(t,e,r){return ee(t,e,r)};Object.setPrototypeOf(s.prototype,Uint8Array.prototype);Object.setPrototypeOf(s,Uint8Array);function re(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 pr(t,e,r){return re(t),t<=0?S(t):e!==void 0?typeof r=="string"?S(t).fill(e,r):S(t).fill(e):S(t)}s.alloc=function(t,e,r){return pr(t,e,r)};function bt(t){return re(t),S(t<0?0:St(t)|0)}s.allocUnsafe=function(t){return bt(t)};s.allocUnsafeSlow=function(t){return bt(t)};function dr(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=ne(t,e)|0,n=S(r),o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}function Ct(t){for(var e=t.length<0?0:St(t.length)|0,r=S(e),n=0;n<e;n+=1)r[n]=t[n]&255;return r}function fr(t){if(F(t,Uint8Array)){var e=new Uint8Array(t);return Ft(e.buffer,e.byteOffset,e.byteLength)}return Ct(t)}function Ft(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');var 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,s.prototype),n}function mr(t){if(s.isBuffer(t)){var e=St(t.length)|0,r=S(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Pt(t.length)?S(0):Ct(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Ct(t.data)}function St(t){if(t>=ut)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ut.toString(16)+" bytes");return t|0}function hr(t){return+t!=t&&(t=0),s.alloc(+t)}s.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==s.prototype};s.compare=function(e,r){if(F(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),F(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),!s.isBuffer(e)||!s.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;for(var n=e.length,o=r.length,i=0,a=Math.min(n,o);i<a;++i)if(e[i]!==r[i]){n=e[i],o=r[i];break}return n<o?-1:o<n?1:0};s.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}};s.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return s.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;var o=s.allocUnsafe(r),i=0;for(n=0;n<e.length;++n){var a=e[n];if(F(a,Uint8Array))i+a.length>o.length?s.from(a).copy(o,i):Uint8Array.prototype.set.call(o,a,i);else if(s.isBuffer(a))a.copy(o,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=a.length}return o};function ne(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||F(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);var r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return At(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return le(t).length;default:if(o)return n?-1:At(t).length;e=(""+e).toLowerCase(),o=!0}}s.byteLength=ne;function yr(t,e,r){var 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 Ar(this,e,r);case"utf8":case"utf-8":return ie(this,e,r);case"ascii":return Cr(this,e,r);case"latin1":case"binary":return Fr(this,e,r);case"base64":return Rr(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return br(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}s.prototype._isBuffer=!0;function M(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}s.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<e;r+=2)M(this,r,r+1);return this};s.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<e;r+=4)M(this,r,r+3),M(this,r+1,r+2);return this};s.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<e;r+=8)M(this,r,r+7),M(this,r+1,r+6),M(this,r+2,r+5),M(this,r+3,r+4);return this};s.prototype.toString=function(){var e=this.length;return e===0?"":arguments.length===0?ie(this,0,e):yr.apply(this,arguments)};s.prototype.toLocaleString=s.prototype.toString;s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:s.compare(this,e)===0};s.prototype.inspect=function(){var e="",r=W.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};Dt&&(s.prototype[Dt]=s.prototype.inspect);s.prototype.compare=function(e,r,n,o,i){if(F(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.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;for(var a=i-o,c=n-r,l=Math.min(a,c),u=this.slice(o,i),p=e.slice(r,n),d=0;d<l;++d)if(u[d]!==p[d]){a=u[d],c=p[d];break}return a<c?-1:c<a?1:0};function oe(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,Pt(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=s.from(e,n)),s.isBuffer(e))return e.length===0?-1:Lt(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):Lt(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function Lt(t,e,r,n,o){var i=1,a=t.length,c=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,a/=2,c/=2,r/=2}function l(h,x){return i===1?h[x]:h.readUInt16BE(x*i)}var u;if(o){var p=-1;for(u=r;u<a;u++)if(l(t,u)===l(e,p===-1?0:u-p)){if(p===-1&&(p=u),u-p+1===c)return p*i}else p!==-1&&(u-=u-p),p=-1}else for(r+c>a&&(r=a-c),u=r;u>=0;u--){for(var d=!0,m=0;m<c;m++)if(l(t,u+m)!==l(e,m)){d=!1;break}if(d)return u}return-1}s.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};s.prototype.indexOf=function(e,r,n){return oe(this,e,r,n,!0)};s.prototype.lastIndexOf=function(e,r,n){return oe(this,e,r,n,!1)};function _r(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n),n>o&&(n=o)):n=o;var i=e.length;n>i/2&&(n=i/2);for(var a=0;a<n;++a){var c=parseInt(e.substr(a*2,2),16);if(Pt(c))return a;t[r+a]=c}return a}function xr(t,e,r,n){return pt(At(e,t.length-r),t,r,n)}function gr(t,e,r,n){return pt(Or(e),t,r,n)}function wr(t,e,r,n){return pt(le(e),t,r,n)}function Tr(t,e,r,n){return pt(Er(e,t.length-r),t,r,n)}s.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");var 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");for(var a=!1;;)switch(o){case"hex":return _r(this,e,r,n);case"utf8":case"utf-8":return xr(this,e,r,n);case"ascii":case"latin1":case"binary":return gr(this,e,r,n);case"base64":return wr(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Tr(this,e,r,n);default:if(a)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),a=!0}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Rr(t,e,r){return e===0&&r===t.length?Nt.fromByteArray(t):Nt.fromByteArray(t.slice(e,r))}function ie(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i=t[o],a=null,c=i>239?4:i>223?3:i>191?2:1;if(o+c<=r){var l,u,p,d;switch(c){case 1:i<128&&(a=i);break;case 2:l=t[o+1],(l&192)===128&&(d=(i&31)<<6|l&63,d>127&&(a=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)&&(a=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&&(a=d))}}a===null?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),o+=c}return Nr(n)}var te=4096;function Nr(t){var e=t.length;if(e<=te)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=te));return r}function Cr(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]&127);return n}function Fr(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function Ar(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=vr[t[i]];return o}function br(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length-1;i+=2)o+=String.fromCharCode(n[i]+n[i+1]*256);return o}s.prototype.slice=function(e,r){var 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);var o=this.subarray(e,r);return Object.setPrototypeOf(o,s.prototype),o};function _(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")}s.prototype.readUintLE=s.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||_(e,r,this.length);for(var o=this[e],i=1,a=0;++a<r&&(i*=256);)o+=this[e+a]*i;return o};s.prototype.readUintBE=s.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||_(e,r,this.length);for(var o=this[e+--r],i=1;r>0&&(i*=256);)o+=this[e+--r]*i;return o};s.prototype.readUint8=s.prototype.readUInt8=function(e,r){return e=e>>>0,r||_(e,1,this.length),this[e]};s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||_(e,2,this.length),this[e]|this[e+1]<<8};s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||_(e,2,this.length),this[e]<<8|this[e+1]};s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||_(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||_(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};s.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||_(e,r,this.length);for(var o=this[e],i=1,a=0;++a<r&&(i*=256);)o+=this[e+a]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*r)),o};s.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||_(e,r,this.length);for(var o=r,i=1,a=this[e+--o];o>0&&(i*=256);)a+=this[e+--o]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*r)),a};s.prototype.readInt8=function(e,r){return e=e>>>0,r||_(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};s.prototype.readInt16LE=function(e,r){e=e>>>0,r||_(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};s.prototype.readInt16BE=function(e,r){e=e>>>0,r||_(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};s.prototype.readInt32LE=function(e,r){return e=e>>>0,r||_(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};s.prototype.readInt32BE=function(e,r){return e=e>>>0,r||_(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};s.prototype.readFloatLE=function(e,r){return e=e>>>0,r||_(e,4,this.length),K.read(this,e,!0,23,4)};s.prototype.readFloatBE=function(e,r){return e=e>>>0,r||_(e,4,this.length),K.read(this,e,!1,23,4)};s.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||_(e,8,this.length),K.read(this,e,!0,52,8)};s.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||_(e,8,this.length),K.read(this,e,!1,52,8)};function g(t,e,r,n,o,i){if(!s.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")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,r,n,o){if(e=+e,r=r>>>0,n=n>>>0,!o){var i=Math.pow(2,8*n)-1;g(this,e,r,n,i,0)}var a=1,c=0;for(this[r]=e&255;++c<n&&(a*=256);)this[r+c]=e/a&255;return r+n};s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,r,n,o){if(e=+e,r=r>>>0,n=n>>>0,!o){var i=Math.pow(2,8*n)-1;g(this,e,r,n,i,0)}var a=n-1,c=1;for(this[r+a]=e&255;--a>=0&&(c*=256);)this[r+a]=e/c&255;return r+n};s.prototype.writeUint8=s.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||g(this,e,r,1,255,0),this[r]=e&255,r+1};s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||g(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||g(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||g(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};s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||g(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};s.prototype.writeIntLE=function(e,r,n,o){if(e=+e,r=r>>>0,!o){var i=Math.pow(2,8*n-1);g(this,e,r,n,i-1,-i)}var a=0,c=1,l=0;for(this[r]=e&255;++a<n&&(c*=256);)e<0&&l===0&&this[r+a-1]!==0&&(l=1),this[r+a]=(e/c>>0)-l&255;return r+n};s.prototype.writeIntBE=function(e,r,n,o){if(e=+e,r=r>>>0,!o){var i=Math.pow(2,8*n-1);g(this,e,r,n,i-1,-i)}var a=n-1,c=1,l=0;for(this[r+a]=e&255;--a>=0&&(c*=256);)e<0&&l===0&&this[r+a+1]!==0&&(l=1),this[r+a]=(e/c>>0)-l&255;return r+n};s.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||g(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};s.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||g(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};s.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||g(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};s.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||g(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};s.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||g(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};function ae(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 se(t,e,r,n,o){return e=+e,r=r>>>0,o||ae(t,e,r,4,34028234663852886e22,-34028234663852886e22),K.write(t,e,r,n,23,4),r+4}s.prototype.writeFloatLE=function(e,r,n){return se(this,e,r,!0,n)};s.prototype.writeFloatBE=function(e,r,n){return se(this,e,r,!1,n)};function ce(t,e,r,n,o){return e=+e,r=r>>>0,o||ae(t,e,r,8,17976931348623157e292,-17976931348623157e292),K.write(t,e,r,n,52,8),r+8}s.prototype.writeDoubleLE=function(e,r,n){return ce(this,e,r,!0,n)};s.prototype.writeDoubleBE=function(e,r,n){return ce(this,e,r,!1,n)};s.prototype.copy=function(e,r,n,o){if(!s.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);var 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};s.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"&&!s.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){var i=e.charCodeAt(0);(o==="utf8"&&i<128||o==="latin1")&&(e=i)}}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);var a;if(typeof e=="number")for(a=r;a<n;++a)this[a]=e;else{var c=s.isBuffer(e)?e:s.from(e,o),l=c.length;if(l===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(a=0;a<n-r;++a)this[a+r]=c[a%l]}return this};var Sr=/[^+/0-9A-Za-z-_]/g;function Pr(t){if(t=t.split("=")[0],t=t.trim().replace(Sr,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function At(t,e){e=e||1/0;for(var r,n=t.length,o=null,i=[],a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(a+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 Or(t){for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Er(t,e){for(var r,n,o,i=[],a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,o=r%256,i.push(o),i.push(n);return i}function le(t){return Nt.toByteArray(Pr(t))}function pt(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function F(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Pt(t){return t!==t}var vr=function(){for(var t="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var n=r*16,o=0;o<16;++o)e[n+o]=t[r]+t[o];return e}()});var Wt=({IDL:t})=>{let e=t.Principal,r=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),n=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),o=t.Record({value:t.Text,name:t.Text}),i=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(o)}),a=t.Variant({dns_error:t.Null,no_consensus:t.Null,transform_error:t.Null,unreachable:t.Null,bad_tls:t.Null,conn_timeout:t.Null,invalid_url:t.Null,timeout:t.Null}),c=t.Vec(t.Nat8);return t.Service({canister_status:t.Func([t.Record({canister_id:e})],[t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:r,module_hash:t.Opt(t.Vec(t.Nat8))})],[]),create_canister:t.Func([t.Record({settings:t.Opt(n)})],[t.Record({canister_id:e})],[]),delete_canister:t.Func([t.Record({canister_id:e})],[],[]),deposit_cycles:t.Func([t.Record({canister_id:e})],[],[]),http_request:t.Func([t.Record({url:t.Text,method:t.Variant({get:t.Null}),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Variant({function:t.Func([i],[i],["query"])})),headers:t.Vec(o)})],[t.Variant({Ok:i,Err:t.Opt(a)})],[]),install_code:t.Func([t.Record({arg:t.Vec(t.Nat8),wasm_module:c,mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),canister_id:e})],[],[]),provisional_create_canister_with_cycles:t.Func([t.Record({settings:t.Opt(n),amount:t.Opt(t.Nat)})],[t.Record({canister_id:e})],[]),provisional_top_up_canister:t.Func([t.Record({canister_id:e,amount:t.Nat})],[],[]),raw_rand:t.Func([],[t.Vec(t.Nat8)],[]),start_canister:t.Func([t.Record({canister_id:e})],[],[]),stop_canister:t.Func([t.Record({canister_id:e})],[],[]),uninstall_code:t.Func([t.Record({canister_id:e})],[],[]),update_settings:t.Func([t.Record({canister_id:t.Principal,settings:n})],[],[])})};var Gt=({IDL:t})=>{let e=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,satellite_id:t.Principal}),r=t.Variant({Write:t.Null,Admin:t.Null}),n=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:r,expires_at:t.Opt(t.Nat64)}),o=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),i=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),a=t.Record({status:o,memory_size:t.Nat,cycles:t.Nat,settings:i,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))}),c=t.Record({id:t.Principal,status:a,metadata:t.Opt(t.Vec(t.Tuple(t.Text,t.Text))),status_at:t.Nat64}),l=t.Variant({Ok:c,Err:t.Text}),u=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:r,expires_at:t.Opt(t.Nat64)}),p=t.Record({enabled:t.Bool,cycles_threshold:t.Opt(t.Nat64)}),d=t.Record({mission_control_cycles_threshold:t.Opt(t.Nat64),satellites:t.Vec(t.Tuple(t.Principal,p)),cycles_threshold:t.Opt(t.Nat64)}),m=t.Record({satellites:t.Opt(t.Vec(l)),mission_control:l}),h=t.Record({e8s:t.Nat64});return t.Service({add_mission_control_controllers:t.Func([t.Vec(t.Principal)],[],[]),add_satellites_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal)],[],[]),create_satellite:t.Func([t.Text],[e],[]),del_mission_control_controllers:t.Func([t.Vec(t.Principal)],[],[]),del_satellites_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal)],[],[]),get_user:t.Func([],[t.Principal],["query"]),list_mission_control_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,n))],["query"]),list_mission_control_statuses:t.Func([],[t.Vec(t.Tuple(t.Nat64,l))],["query"]),list_satellite_statuses:t.Func([t.Principal],[t.Opt(t.Vec(t.Tuple(t.Nat64,l)))],["query"]),list_satellites:t.Func([],[t.Vec(t.Tuple(t.Principal,e))],["query"]),remove_mission_control_controllers:t.Func([t.Vec(t.Principal)],[],[]),remove_satellites_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal)],[],[]),set_metadata:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),set_mission_control_controllers:t.Func([t.Vec(t.Principal),u],[],[]),set_satellites_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal),u],[],[]),status:t.Func([d],[m],[]),top_up:t.Func([t.Principal,h],[],[]),version:t.Func([],[t.Text],["query"])})};var Yt=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({controllers:t.Vec(t.Principal)}),n=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,expires_at:t.Opt(t.Nat64)}),o=t.Record({updated_at:t.Opt(t.Nat64)}),i=t.Record({headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text))))}),a=t.Record({storage:i}),c=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),created_at:t.Nat64}),l=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text))}),u=t.Record({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}),p=t.Variant({Callback:t.Record({token:u,callback:t.Func([],[],[])})}),d=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(p),status_code:t.Nat16}),m=t.Record({token:t.Opt(u),body:t.Vec(t.Nat8)}),h=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,encoding_type:t.Opt(t.Text),full_path:t.Text}),x=t.Record({batch_id:t.Nat}),O=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),B=t.Record({field:O,desc:t.Bool}),E=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),N=t.Record({order:t.Opt(B),owner:t.Opt(t.Principal),matcher:t.Opt(t.Text),paginate:t.Opt(E)}),k=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,full_path:t.Text}),v=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),z=t.Record({key:k,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,v)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64}),Y=t.Record({matches_length:t.Nat64,length:t.Nat64,items:t.Vec(t.Tuple(t.Text,z))}),J=t.Record({updated_at:t.Nat64,created_at:t.Nat64,bn_id:t.Opt(t.Text)}),Q=t.Record({matches_length:t.Nat64,length:t.Nat64,items:t.Vec(t.Tuple(t.Text,c))}),U=t.Variant({Db:t.Null,Storage:t.Null}),R=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),X=t.Record({updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:R,created_at:t.Nat64,write:R}),V=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),expires_at:t.Opt(t.Nat64)}),Z=t.Record({controller:V,controllers:t.Vec(t.Principal)}),I=t.Record({updated_at:t.Opt(t.Nat64),data:t.Vec(t.Nat8)}),D=t.Record({updated_at:t.Opt(t.Nat64),max_size:t.Opt(t.Nat),read:R,write:R}),L=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat}),tt=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Opt(t.Text)],[],[]),del_controllers:t.Func([r],[t.Vec(t.Tuple(t.Principal,n))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,o],[],[]),get_config:t.Func([],[a],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(c)],["query"]),http_request:t.Func([l],[d],["query"]),http_request_streaming_callback:t.Func([u],[m],["query"]),init_asset_upload:t.Func([h],[x],[]),list_assets:t.Func([t.Opt(t.Text),N],[Y],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,n))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,J))],["query"]),list_docs:t.Func([t.Text,N],[Q],["query"]),list_rules:t.Func([U],[t.Vec(t.Tuple(t.Text,X))],["query"]),set_config:t.Func([a],[],[]),set_controllers:t.Func([Z],[t.Vec(t.Tuple(t.Principal,n))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,I],[c],[]),set_rule:t.Func([U,t.Text,D],[],[]),upload_asset_chunk:t.Func([L],[tt],[]),version:t.Func([],[t.Text],["query"])})};var Jt=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({controllers:t.Vec(t.Principal)}),n=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,expires_at:t.Opt(t.Nat64)}),o=t.Record({updated_at:t.Opt(t.Nat64)}),i=t.Record({headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text))))}),a=t.Record({storage:i}),c=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),created_at:t.Nat64}),l=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text))}),u=t.Record({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}),p=t.Variant({Callback:t.Record({token:u,callback:t.Func([],[],[])})}),d=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(p),status_code:t.Nat16}),m=t.Record({token:t.Opt(u),body:t.Vec(t.Nat8)}),h=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,encoding_type:t.Opt(t.Text),full_path:t.Text}),x=t.Record({batch_id:t.Nat}),O=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),B=t.Record({field:O,desc:t.Bool}),E=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),N=t.Record({order:t.Opt(B),matcher:t.Opt(t.Text),paginate:t.Opt(E)}),k=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,full_path:t.Text}),v=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),z=t.Record({key:k,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,v)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64}),Y=t.Record({matches_length:t.Nat64,length:t.Nat64,items:t.Vec(t.Tuple(t.Text,z))}),J=t.Record({updated_at:t.Nat64,created_at:t.Nat64,bn_id:t.Opt(t.Text)}),Q=t.Record({matches_length:t.Nat64,length:t.Nat64,items:t.Vec(t.Tuple(t.Text,c))}),U=t.Variant({Db:t.Null,Storage:t.Null}),R=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),X=t.Record({updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:R,created_at:t.Nat64,write:R}),V=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),expires_at:t.Opt(t.Nat64)}),Z=t.Record({controller:V,controllers:t.Vec(t.Principal)}),I=t.Record({updated_at:t.Opt(t.Nat64),data:t.Vec(t.Nat8)}),D=t.Record({updated_at:t.Opt(t.Nat64),max_size:t.Opt(t.Nat),read:R,write:R}),L=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat}),tt=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Opt(t.Text)],[],[]),del_controllers:t.Func([r],[t.Vec(t.Tuple(t.Principal,n))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,o],[],[]),get_config:t.Func([],[a],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(c)],["query"]),http_request:t.Func([l],[d],["query"]),http_request_streaming_callback:t.Func([u],[m],["query"]),init_asset_upload:t.Func([h],[x],[]),list_assets:t.Func([t.Opt(t.Text),N],[Y],["query"]),list_controllers:t.Func([],[t.Vec(t.Principal)],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,J))],["query"]),list_docs:t.Func([t.Text,N],[Q],["query"]),list_rules:t.Func([U],[t.Vec(t.Tuple(t.Text,X))],["query"]),set_config:t.Func([a],[],[]),set_controllers:t.Func([Z],[t.Vec(t.Tuple(t.Principal,n))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,I],[c],[]),set_rule:t.Func([U,t.Text,D],[],[]),upload_asset_chunk:t.Func([L],[tt],[]),version:t.Func([],[t.Text],["query"])})};var Qt=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({controllers:t.Vec(t.Principal)}),n=t.Variant({Write:t.Null,Admin:t.Null}),o=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:n,expires_at:t.Opt(t.Nat64)}),i=t.Record({updated_at:t.Opt(t.Nat64)}),a=t.Variant({Db:t.Null,Storage:t.Null}),c=t.Record({headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text))))}),l=t.Record({storage:c}),u=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64}),p=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text))}),d=t.Record({token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),m=t.Variant({Callback:t.Record({token:d,callback:t.Func([],[],[])})}),h=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(m),status_code:t.Nat16}),x=t.Record({token:t.Opt(d),body:t.Vec(t.Nat8)}),O=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}),B=t.Record({batch_id:t.Nat}),E=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),N=t.Record({field:E,desc:t.Bool}),k=t.Record({key:t.Opt(t.Text),description:t.Opt(t.Text)}),v=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),z=t.Record({order:t.Opt(N),owner:t.Opt(t.Principal),matcher:t.Opt(k),paginate:t.Opt(v)}),Y=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}),J=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),Q=t.Record({key:Y,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,J)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64}),U=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,Q)),items_length:t.Nat64}),R=t.Record({updated_at:t.Nat64,created_at:t.Nat64,bn_id:t.Opt(t.Text)}),X=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,u)),items_length:t.Nat64}),V=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),Z=t.Record({updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:V,created_at:t.Nat64,write:V}),I=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:n,expires_at:t.Opt(t.Nat64)}),D=t.Record({controller:I,controllers:t.Vec(t.Principal)}),L=t.Record({updated_at:t.Opt(t.Nat64),data:t.Vec(t.Nat8),description:t.Opt(t.Text)}),tt=t.Record({updated_at:t.Opt(t.Nat64),max_size:t.Opt(t.Nat),read:V,write:V}),De=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat}),Le=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Opt(t.Text)],[],[]),del_controllers:t.Func([r],[t.Vec(t.Tuple(t.Principal,o))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,i],[],[]),del_rule:t.Func([a,t.Text,i],[],[]),get_config:t.Func([],[l],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(u)],["query"]),http_request:t.Func([p],[h],["query"]),http_request_streaming_callback:t.Func([d],[x],["query"]),init_asset_upload:t.Func([O],[B],[]),list_assets:t.Func([t.Opt(t.Text),z],[U],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,o))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,R))],["query"]),list_docs:t.Func([t.Text,z],[X],["query"]),list_rules:t.Func([a],[t.Vec(t.Tuple(t.Text,Z))],["query"]),set_config:t.Func([l],[],[]),set_controllers:t.Func([D],[t.Vec(t.Tuple(t.Principal,o))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,L],[u],[]),set_rule:t.Func([a,t.Text,tt],[],[]),upload_asset_chunk:t.Func([De],[Le],[]),version:t.Func([],[t.Text],["query"])})};var Ne=Ht(ue());var dt;(function(t){t[t.SysFatal=1]="SysFatal",t[t.SysTransient=2]="SysTransient",t[t.DestinationInvalid=3]="DestinationInvalid",t[t.CanisterReject=4]="CanisterReject",t[t.CanisterError=5]="CanisterError"})(dt||(dt={}));var pn=new TextEncoder().encode(`
2
+ ic-request`);var ft=class{getPrincipal(){return f.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};var pe=Ht(rr());var mt;(function(t){t.Call="call"})(mt||(mt={}));function rt(){let t=new ArrayBuffer(16),e=new DataView(t),r=BigInt(+Date.now()),n=Math.floor(Math.random()*4294967295),o=Math.floor(Math.random()*4294967295);if(typeof e.setBigUint64=="function")e.setBigUint64(0,r);else{let i=BigInt(1)<<BigInt(32);e.setUint32(0,Number(r>>BigInt(32))),e.setUint32(4,Number(r%i))}return e.setUint32(8,n),e.setUint32(12,o),t}var Vr=BigInt(1e6),Br=BigInt(60*1e3),j=class{constructor(e){this._value=(BigInt(Date.now())+BigInt(e)-Br)*Vr}toCBOR(){return pe.value.u64(this._value.toString(16),16)}toHash(){return $t(this._value)}};function de(t=rt){return async e=>{let r=t(),n=e.request.headers?new Headers(e.request.headers):new Headers;e.request.headers=n,e.endpoint==="call"&&(e.body.nonce=t())}}var A;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(A||(A={}));var ht=5*60*1e3,Ur="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae",qr="ic0.app",Mr=".ic0.app",jr="icp0.io",Hr=".icp0.io",$r="icp-api.io",zr=".icp-api.io",nt=class extends et{constructor(e){super(e),this.message=e}},G=class extends et{constructor(e){super(e),this.message=e}};function Kr(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new nt("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new nt("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(t=self.fetch.bind(self));if(t)return t;throw new nt("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var H=class{constructor(e={}){if(this.rootKey=zt(Ur),this._pipeline=[],this._timeDiffMsecs=0,this._rootKeyFetched=!1,this._retryTimes=3,this._isAgent=!0,e.source){if(!(e.source instanceof H))throw new Error("An Agent's source can only be another HttpAgent");this._pipeline=[...e.source._pipeline],this._identity=e.source._identity,this._fetch=e.source._fetch,this._host=e.source._host,this._credentials=e.source._credentials}else this._fetch=e.fetch||Kr()||fetch.bind(window),this._fetchOptions=e.fetchOptions,this._callOptions=e.callOptions;if(e.host!==void 0)!e.host.match(/^[a-z]+:/)&&typeof window<"u"?this._host=new URL(window.location.protocol+"//"+e.host):this._host=new URL(e.host);else if(e.source!==void 0)this._host=e.source._host;else{let r=typeof window<"u"?window.location:void 0;if(!r)throw new Error("Must specify a host to connect to.");this._host=new URL(r+"")}if(e.retryTimes!==void 0&&(this._retryTimes=e.retryTimes),this._host.hostname.endsWith(Mr)?this._host.hostname=qr:this._host.hostname.endsWith(Hr)?this._host.hostname=jr:this._host.hostname.endsWith(zr)&&(this._host.hostname=$r),e.credentials){let{name:r,password:n}=e.credentials;this._credentials=`${r}${n?":"+n:""}`}this._identity=Promise.resolve(e.identity||new ft),e.disableNonce||this.addTransform(de(rt))}isLocal(){let e=this._host.hostname;return e==="127.0.0.1"||e.endsWith("localhost")}addTransform(e,r=e.priority||0){let n=this._pipeline.findIndex(o=>(o.priority||0)<r);this._pipeline.splice(n>=0?n:this._pipeline.length,0,Object.assign(e,{priority:r}))}async getPrincipal(){if(!this._identity)throw new G("This identity has expired due this application's security policy. Please refresh your authentication.");return(await this._identity).getPrincipal()}async call(e,r,n){let o=await(n!==void 0?await n:await this._identity);if(!o)throw new G("This identity has expired due this application's security policy. Please refresh your authentication.");let i=f.from(e),a=r.effectiveCanisterId?f.from(r.effectiveCanisterId):i,c=o.getPrincipal()||f.anonymous(),l=new j(ht);Math.abs(this._timeDiffMsecs)>1e3*30&&(l=new j(ht+this._timeDiffMsecs));let u={request_type:mt.Call,canister_id:i,method_name:r.methodName,arg:r.arg,sender:c,ingress_expiry:l},p=await this._transform({request:{body:null,method:"POST",headers:new Headers(Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{}))},endpoint:"call",body:u});p=await o.transformRequest(p);let d=st(p.body),m=this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${a.toText()}/call`,this._host),Object.assign(Object.assign(Object.assign({},this._callOptions),p.request),{body:d}))),[h,x]=await Promise.all([m,Tt(u)]);return{requestId:x,response:{ok:h.ok,status:h.status,statusText:h.statusText}}}async _requestAndRetry(e,r=0){if(r>this._retryTimes&&this._retryTimes!==0)throw new Error(`AgentError: Exceeded configured limit of ${this._retryTimes} retry attempts. Please check your network connection or try again in a few moments`);let n=await e();if(!n.ok){let o=await n.clone().text(),i=`Server returned an error:
3
3
  Code: ${n.status} (${n.statusText})
4
4
  Body: ${o}
5
- `;if(this._retryTimes>r)return console.warn(i+" Retrying request."),await this._requestAndRetry(e,r+1);throw new Error(i)}return n}async query(e,r,n){let o=await(n!==void 0?await n:await this._identity);if(!o)throw new H("This identity has expired due this application's security policy. Please refresh your authentication.");let i=typeof e=="string"?f.fromText(e):e,a=o?.getPrincipal()||f.anonymous(),c={request_type:"query",canister_id:i,method_name:r.methodName,arg:r.arg,sender:a,ingress_expiry:new O(at)},l=await this._transform({request:{method:"POST",headers:new Headers(Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{}))},endpoint:"read",body:c});l=await o?.transformRequest(l);let u=D(l.body),d=await this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${i.toText()}/query`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),l.request),{body:u})));return L(await d.arrayBuffer())}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await this._identity);if(!n)throw new H("This identity has expired due this application's security policy. Please refresh your authentication.");let o=n?.getPrincipal()||f.anonymous(),i=await this._transform({request:{method:"POST",headers:new Headers(Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{}))},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:o,ingress_expiry:new O(at)}});return n?.transformRequest(i)}async readState(e,r,n,o){let i=typeof e=="string"?f.fromText(e):e,a=o??await this.createReadStateRequest(r,n),c=D(a.body),l=await this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${i}/read_state`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),a.request),{body:c})));if(!l.ok)throw new Error(`Server returned an error:
5
+ `;if(this._retryTimes>r)return console.warn(i+" Retrying request."),await this._requestAndRetry(e,r+1);throw new Error(i)}return n}async query(e,r,n){let o=await(n!==void 0?await n:await this._identity);if(!o)throw new G("This identity has expired due this application's security policy. Please refresh your authentication.");let i=typeof e=="string"?f.fromText(e):e,a=o?.getPrincipal()||f.anonymous(),c={request_type:"query",canister_id:i,method_name:r.methodName,arg:r.arg,sender:a,ingress_expiry:new j(ht)},l=await this._transform({request:{method:"POST",headers:new Headers(Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{}))},endpoint:"read",body:c});l=await o?.transformRequest(l);let u=st(l.body),p=await this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${i.toText()}/query`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),l.request),{body:u})));return ct(await p.arrayBuffer())}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await this._identity);if(!n)throw new G("This identity has expired due this application's security policy. Please refresh your authentication.");let o=n?.getPrincipal()||f.anonymous(),i=await this._transform({request:{method:"POST",headers:new Headers(Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{}))},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:o,ingress_expiry:new j(ht)}});return n?.transformRequest(i)}async readState(e,r,n,o){let i=typeof e=="string"?f.fromText(e):e,a=o??await this.createReadStateRequest(r,n),c=st(a.body),l=await this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${i}/read_state`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),a.request),{body:c})));if(!l.ok)throw new Error(`Server returned an error:
6
6
  Code: ${l.status} (${l.statusText})
7
7
  Body: ${await l.text()}
8
- `);return L(await l.arrayBuffer())}async syncTime(e){let r=await import("./canisterStatus-D52DQGXX.js"),n=Date.now();try{e||console.log("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let i=(await r.request({canisterId:e??f.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");i&&(this._timeDiffMsecs=Number(i)-Number(n))}catch(o){console.error("Caught exception while attempting to sync time:",o)}}async status(){let e=this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{},r=await this._requestAndRetry(()=>this._fetch(""+new URL("/api/v2/status",this._host),Object.assign({headers:e},this._fetchOptions)));return L(await r.arrayBuffer())}async fetchRootKey(){return this._rootKeyFetched||(this.rootKey=(await this.status()).root_key,this._rootKeyFetched=!0),this.rootKey}invalidateIdentity(){this._identity=null}replaceIdentity(e){this._identity=Promise.resolve(e)}_transform(e){let r=Promise.resolve(e);for(let n of this._pipeline)r=r.then(o=>n(o).then(i=>i||o));return r}};var pe;(function(t){t.Error="err",t.GetPrincipal="gp",t.GetPrincipalResponse="gpr",t.Query="q",t.QueryResponse="qr",t.Call="c",t.CallResponse="cr",t.ReadState="rs",t.ReadStateResponse="rsr",t.Status="s",t.StatusResponse="sr"})(pe||(pe={}));function Pt(){let t=typeof window>"u"&&typeof window>"u"?typeof self>"u"?void 0:self.ic.agent:window.ic.agent;if(!t)throw new Error("No Agent could be found.");return t}var st={};Ze(st,{backoff:()=>ye,chain:()=>_e,conditionalDelay:()=>he,defaultStrategy:()=>de,maxAttempts:()=>$r,once:()=>fe,throttle:()=>zr,timeout:()=>me});var Hr=5*60*1e3;function de(){return _e(he(fe(),1e3),ye(1e3,1.2),me(Hr))}function fe(){let t=!0;return async()=>t?(t=!1,!0):!1}function he(t,e){return async(r,n,o)=>{if(await t(r,n,o))return new Promise(i=>setTimeout(i,e))}}function $r(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:
9
- Request ID: ${N(n)}
8
+ `);return ct(await l.arrayBuffer())}async syncTime(e){let r=await import("./canisterStatus-53J5CMIV.js"),n=Date.now();try{e||console.log("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let i=(await r.request({canisterId:e??f.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");i&&(this._timeDiffMsecs=Number(i)-Number(n))}catch(o){console.error("Caught exception while attempting to sync time:",o)}}async status(){let e=this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{},r=await this._requestAndRetry(()=>this._fetch(""+new URL("/api/v2/status",this._host),Object.assign({headers:e},this._fetchOptions)));return ct(await r.arrayBuffer())}async fetchRootKey(){return this._rootKeyFetched||(this.rootKey=(await this.status()).root_key,this._rootKeyFetched=!0),this.rootKey}invalidateIdentity(){this._identity=null}replaceIdentity(e){this._identity=Promise.resolve(e)}_transform(e){let r=Promise.resolve(e);for(let n of this._pipeline)r=r.then(o=>n(o).then(i=>i||o));return r}};var fe;(function(t){t.Error="err",t.GetPrincipal="gp",t.GetPrincipalResponse="gpr",t.Query="q",t.QueryResponse="qr",t.Call="c",t.CallResponse="cr",t.ReadState="rs",t.ReadStateResponse="rsr",t.Status="s",t.StatusResponse="sr"})(fe||(fe={}));function Ot(){let t=typeof window>"u"&&typeof window>"u"?typeof self>"u"?void 0:self.ic.agent:window.ic.agent;if(!t)throw new Error("No Agent could be found.");return t}var yt={};tr(yt,{backoff:()=>xe,chain:()=>ge,conditionalDelay:()=>ye,defaultStrategy:()=>me,maxAttempts:()=>Gr,once:()=>he,throttle:()=>Yr,timeout:()=>_e});var Wr=5*60*1e3;function me(){return ge(ye(he(),1e3),xe(1e3,1.2),_e(Wr))}function he(){let t=!0;return async()=>t?(t=!1,!0):!1}function ye(t,e){return async(r,n,o)=>{if(await t(r,n,o))return new Promise(i=>setTimeout(i,e))}}function Gr(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:
9
+ Request ID: ${b(n)}
10
10
  Request status: ${o}
11
- `)}}function zr(t){return()=>new Promise(e=>setTimeout(e,t))}function me(t){let e=Date.now()+t;return async(r,n,o)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
12
- Request ID: ${N(n)}
11
+ `)}}function Yr(t){return()=>new Promise(e=>setTimeout(e,t))}function _e(t){let e=Date.now()+t;return async(r,n,o)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
12
+ Request ID: ${b(n)}
13
13
  Request status: ${o}
14
- `)}}function ye(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}function _e(...t){return async(e,r,n)=>{for(let o of t)await o(e,r,n)}}async function St(t,e,r,n,o,i){var a;let c=[new TextEncoder().encode("request_status"),r],l=o??await((a=t.createReadStateRequest)===null||a===void 0?void 0:a.call(t,{paths:[c]})),u=await t.readState(e,{paths:[c]},void 0,l);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let d=await zt.create({certificate:u.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:i}),p=d.lookup([...c,new TextEncoder().encode("status")]),h;switch(typeof p>"u"?h=F.Unknown:h=new TextDecoder().decode(p),h){case F.Replied:return d.lookup([...c,"reply"]);case F.Received:case F.Unknown:case F.Processing:return await n(e,r,h),St(t,e,r,n,l);case F.Rejected:{let m=new Uint8Array(d.lookup([...c,"reject_code"]))[0],x=new TextDecoder().decode(d.lookup([...c,"reject_message"]));throw new Error(`Call was rejected:
15
- Request ID: ${N(r)}
16
- Reject code: ${m}
14
+ `)}}function xe(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}function ge(...t){return async(e,r,n)=>{for(let o of t)await o(e,r,n)}}async function Et(t,e,r,n,o,i){var a;let c=[new TextEncoder().encode("request_status"),r],l=o??await((a=t.createReadStateRequest)===null||a===void 0?void 0:a.call(t,{paths:[c]})),u=await t.readState(e,{paths:[c]},void 0,l);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let p=await Kt.create({certificate:u.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:i}),d=p.lookup([...c,new TextEncoder().encode("status")]),m;switch(typeof d>"u"?m=A.Unknown:m=new TextDecoder().decode(d),m){case A.Replied:return p.lookup([...c,"reply"]);case A.Received:case A.Unknown:case A.Processing:return await n(e,r,m),Et(t,e,r,n,l);case A.Rejected:{let h=new Uint8Array(p.lookup([...c,"reject_code"]))[0],x=new TextDecoder().decode(p.lookup([...c,"reject_message"]));throw new Error(`Call was rejected:
15
+ Request ID: ${b(r)}
16
+ Reject code: ${h}
17
17
  Reject text: ${x}
18
- `)}case F.Done:throw new Error(`Call was marked as done but we never saw the reply:
19
- Request ID: ${N(r)}
20
- `)}throw new Error("unreachable")}var xe=({IDL:t})=>{let e=t.Principal,r=t.Record({controllers:t.Vec(t.Principal),freezing_threshold:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),n=t.Record({controllers:t.Opt(t.Vec(t.Principal)),freezing_threshold:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),o=t.Vec(t.Nat8);return t.Service({canister_status:t.Func([t.Record({canister_id:e})],[t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:r,module_hash:t.Opt(t.Vec(t.Nat8))})],[]),create_canister:t.Func([t.Record({settings:t.Opt(n)})],[t.Record({canister_id:e})],[]),delete_canister:t.Func([t.Record({canister_id:e})],[],[]),deposit_cycles:t.Func([t.Record({canister_id:e})],[],[]),install_code:t.Func([t.Record({arg:t.Vec(t.Nat8),wasm_module:o,mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),canister_id:e})],[],[]),provisional_create_canister_with_cycles:t.Func([t.Record({settings:t.Opt(n),amount:t.Opt(t.Nat)})],[t.Record({canister_id:e})],[]),provisional_top_up_canister:t.Func([t.Record({canister_id:e,amount:t.Nat})],[],[]),raw_rand:t.Func([],[t.Vec(t.Nat8)],[]),start_canister:t.Func([t.Record({canister_id:e})],[],[]),stop_canister:t.Func([t.Record({canister_id:e})],[],[]),uninstall_code:t.Func([t.Record({canister_id:e})],[],[]),update_settings:t.Func([t.Record({canister_id:t.Principal,settings:n})],[],[])})};var ct=class extends W{constructor(e,r,n,o){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(o).map(i=>` "${i}": ${JSON.stringify(o[i])}`)].join(`
21
- `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=o}},Et=class extends ct{constructor(e,r,n){var o;super(e,r,"query",{Status:n.status,Code:(o=nt[n.reject_code])!==null&&o!==void 0?o:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},Ot=class extends ct{constructor(e,r,n,o){super(e,r,"update",{"Request ID":N(n),"HTTP status code":o.status.toString(),"HTTP status text":o.statusText}),this.requestId=n,this.response=o}},vt;(function(t){t.Install="install",t.Reinstall="reinstall",t.Upgrade="upgrade"})(vt||(vt={}));var T=Symbol.for("ic-agent-metadata"),b=class{constructor(e){this[T]=Object.freeze(e)}static agentOf(e){return e[T].config.agent}static interfaceOf(e){return e[T].service}static canisterIdOf(e){return f.from(e[T].config.canisterId)}static async install(e,r){let n=e.mode===void 0?vt.Install:e.mode,o=e.arg?[...new Uint8Array(e.arg)]:[],i=[...new Uint8Array(e.module)],a=typeof r.canisterId=="string"?f.fromText(r.canisterId):r.canisterId;await ge(r).install_code({mode:{[n]:null},arg:o,wasm_module:i,canister_id:a})}static async createCanister(e){let{canister_id:r}=await ge(e||{}).provisional_create_canister_with_cycles({amount:[],settings:[]});return r}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){let r=e({IDL:y});class n extends b{constructor(i){let a=typeof i.canisterId=="string"?f.fromText(i.canisterId):i.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Re),i),{canisterId:a}),service:r});for(let[c,l]of r._fields)this[c]=Wr(this,c,l,i.blsVerify)}}return n}static createActor(e,r){return new(this.createActorClass(e))(r)}};function we(t,e){let r=y.decode(t,Te.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var Re={pollingStrategyFactory:st.defaultStrategy};function Wr(t,e,r,n){let o;r.annotations.includes("query")?o=async(a,...c)=>{var l,u;a=Object.assign(Object.assign({},a),(u=(l=t[T].config).queryTransform)===null||u===void 0?void 0:u.call(l,e,c,Object.assign(Object.assign({},t[T].config),a)));let d=a.agent||t[T].config.agent||Pt(),p=f.from(a.canisterId||t[T].config.canisterId),h=y.encode(r.argTypes,c),m=await d.query(p,{methodName:e,arg:h});switch(m.status){case"rejected":throw new Et(p,e,m);case"replied":return we(r.retTypes,m.reply.arg)}}:o=async(a,...c)=>{var l,u;a=Object.assign(Object.assign({},a),(u=(l=t[T].config).callTransform)===null||u===void 0?void 0:u.call(l,e,c,Object.assign(Object.assign({},t[T].config),a)));let d=a.agent||t[T].config.agent||Pt(),{canisterId:p,effectiveCanisterId:h,pollingStrategyFactory:m}=Object.assign(Object.assign(Object.assign({},Re),t[T].config),a),x=f.from(p),V=h!==void 0?f.from(h):x,z=y.encode(r.argTypes,c),{requestId:B,response:P}=await d.call(x,{methodName:e,arg:z,effectiveCanisterId:V});if(!P.ok)throw new Ot(x,e,B,P);let K=m(),U=await St(d,V,B,K,n);if(U!==void 0)return we(r.retTypes,U);if(r.retTypes.length===0)return;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let i=(...a)=>o({},...a);return i.withOptions=a=>(...c)=>o(a,...c),i}function ge(t){function e(r,n,o){let i=n[0],a=f.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(a=f.from(i.canister_id)),{effectiveCanisterId:a}}return b.createActor(xe,Object.assign(Object.assign(Object.assign({},t),{canisterId:f.fromHex("")}),{callTransform:e,queryTransform:e}))}var Vt=async({canisterId:t,idlFactory:e,identity:r,fetch:n,env:o="prod",config:i})=>{let a=o==="dev"?"http://127.0.0.1:8000/":"https://icp0.io",c=new v({identity:r,...a&&{host:a},...n&&{fetch:n}});return o==="dev"&&await c.fetchRootKey(),b.createActor(e,{agent:c,canisterId:t,...i!==void 0?i:{}})};var Fe=async({satelliteId:t,...e})=>Bt({canisterId:t,...e,idlFactory:Gt}),$=async({satelliteId:t,...e})=>Bt({canisterId:t,...e,idlFactory:Yt}),J=async({missionControlId:t,...e})=>Bt({canisterId:t,...e,idlFactory:Wt});var Bt=async({canisterId:t,idlFactory:e,...r})=>{if(!t)throw new Error("No canister ID provided.");return Vt({canisterId:t,idlFactory:e,...r})},Ne=f.fromText("aaaaa-aa"),Ce=(t,e,r)=>{let n=e[0],o=Ne;return n&&typeof n=="object"&&n.canister_id&&(o=f.from(n.canister_id)),{effectiveCanisterId:o}},Ae=t=>Vt({canisterId:Ne.toText(),config:{callTransform:Ce,queryTransform:Ce},idlFactory:Kt,...t});var Q=async({actor:t,code:e})=>{let{install_code:r}=await Ae(t);return r({...e,mode:{upgrade:null}})};var be=async({missionControl:t})=>(await J(t)).version(),Pe=async({missionControl:t})=>(await J(t)).get_user();var Se=async({missionControl:t,satelliteIds:e,controllerIds:r,controller:n})=>(await J(t)).set_satellites_controllers(e,r,n),Ee=async({missionControl:t,controllerIds:e,controller:r})=>(await J(t)).set_mission_control_controllers(e,r);var lt=t=>t?[t]:[],Oe=t=>t?.[0];var Ut=t=>t==null,X=t=>!Ut(t);var kt=({controllerId:t,profile:e})=>({controllerIds:[f.fromText(t)],controller:Yr(e)}),Yr=t=>({metadata:X(t)&&t!==""?[["profile",t]]:[],expires_at:lt(void 0),scope:{Admin:null}});var qo=async t=>be(t),Mo=async({missionControl:t,wasm_module:e})=>{let r=await Pe({missionControl:t}),{missionControlId:n,...o}=t;if(!n)throw new Error("No mission control principal defined.");let i=y.encode([y.Record({user:y.Principal})],[{user:r}]);await Q({actor:o,code:{canister_id:f.fromText(n),arg:[...new Uint8Array(i)],wasm_module:e}})},jo=async({controllerId:t,profile:e,...r})=>Se({...r,...kt({controllerId:t,profile:e})}),Ho=async({controllerId:t,profile:e,...r})=>Ee({...r,...kt({controllerId:t,profile:e})});var ve=async({config:t,satellite:e})=>(await $(e)).set_config(t),Ve=async({satellite:t,type:e})=>(await $(t)).list_rules(e),Be=async({type:t,collection:e,rule:r,satellite:n})=>(await $(n)).set_rule(t,e,r),Ue=async({satellite:t})=>(await $(t)).version(),ke=async({satellite:t})=>(await Fe(t)).list_controllers(),qe=async({satellite:t})=>(await $(t)).list_controllers();var Me={Db:null},je={Storage:null},He={Public:null},$e={Private:null},ze={Managed:null},Ke={Controllers:null};var qt=t=>t==="storage"?je:Me,Ye=({read:t,write:e,max_size:r,updated_at:n})=>({read:Ge(t),write:Ge(e),updated_at:Ut(n)?[]:[n],max_size:lt(X(r)&&r>0?BigInt(r):void 0)}),Je=([t,e])=>{let{read:r,write:n,updated_at:o,created_at:i,max_size:a}=e,c=a?.[0]??0n>0n?Number(Oe(a)):void 0;return{collection:t,read:We(r),write:We(n),updated_at:o,created_at:i,...X(c)&&{max_size:c}}},We=t=>"Public"in t?"public":"Private"in t?"private":"Managed"in t?"managed":"controllers",Ge=t=>{switch(t){case"public":return He;case"private":return $e;case"managed":return ze;default:return Ke}};var ti=async({config:{storage:{headers:t}},satellite:e})=>{let r=t.map(({source:n,headers:o})=>[n,o]);return ve({satellite:e,config:{storage:{headers:r}}})},ei=async({type:t,satellite:e})=>(await Ve({satellite:e,type:qt(t)})).map(n=>Je(n)),ri=async({rule:{collection:t,...e},type:r,satellite:n})=>Be({type:qt(r),rule:Ye(e),satellite:n,collection:t}),ni=async t=>Ue(t),oi=async({satellite:t,wasm_module:e,deprecated:r})=>{let{satelliteId:n,...o}=t;if(!n)throw new Error("No satellite principal defined.");if(r){let c=await ke({satellite:t}),l=y.encode([y.Record({controllers:y.Vec(y.Principal)})],[{controllers:c}]);await Q({actor:o,code:{canister_id:f.fromText(n),arg:[...new Uint8Array(l)],wasm_module:e}});return}let i=await qe({satellite:t}),a=y.encode([y.Record({controllers:y.Vec(y.Principal)})],[{controllers:i.map(([c,l])=>c)}]);await Q({actor:o,code:{canister_id:f.fromText(n),arg:[...new Uint8Array(a)],wasm_module:e}})};export{ei as listRules,qo as missionControlVersion,ni as satelliteVersion,ti as setConfig,Ho as setMissionControlController,ri as setRule,jo as setSatellitesController,Mo as upgradeMissionControl,oi as upgradeSatellite};
18
+ `)}case A.Done:throw new Error(`Call was marked as done but we never saw the reply:
19
+ Request ID: ${b(r)}
20
+ `)}throw new Error("unreachable")}var we=({IDL:t})=>{let e=t.Principal,r=t.Record({controllers:t.Vec(t.Principal),freezing_threshold:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),n=t.Record({controllers:t.Opt(t.Vec(t.Principal)),freezing_threshold:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),o=t.Vec(t.Nat8);return t.Service({canister_status:t.Func([t.Record({canister_id:e})],[t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:r,module_hash:t.Opt(t.Vec(t.Nat8))})],[]),create_canister:t.Func([t.Record({settings:t.Opt(n)})],[t.Record({canister_id:e})],[]),delete_canister:t.Func([t.Record({canister_id:e})],[],[]),deposit_cycles:t.Func([t.Record({canister_id:e})],[],[]),install_code:t.Func([t.Record({arg:t.Vec(t.Nat8),wasm_module:o,mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),canister_id:e})],[],[]),provisional_create_canister_with_cycles:t.Func([t.Record({settings:t.Opt(n),amount:t.Opt(t.Nat)})],[t.Record({canister_id:e})],[]),provisional_top_up_canister:t.Func([t.Record({canister_id:e,amount:t.Nat})],[],[]),raw_rand:t.Func([],[t.Vec(t.Nat8)],[]),start_canister:t.Func([t.Record({canister_id:e})],[],[]),stop_canister:t.Func([t.Record({canister_id:e})],[],[]),uninstall_code:t.Func([t.Record({canister_id:e})],[],[]),update_settings:t.Func([t.Record({canister_id:t.Principal,settings:n})],[],[])})};var _t=class extends et{constructor(e,r,n,o){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(o).map(i=>` "${i}": ${JSON.stringify(o[i])}`)].join(`
21
+ `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=o}},vt=class extends _t{constructor(e,r,n){var o;super(e,r,"query",{Status:n.status,Code:(o=dt[n.reject_code])!==null&&o!==void 0?o:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},Vt=class extends _t{constructor(e,r,n,o){super(e,r,"update",{"Request ID":b(n),"HTTP status code":o.status.toString(),"HTTP status text":o.statusText}),this.requestId=n,this.response=o}},Bt;(function(t){t.Install="install",t.Reinstall="reinstall",t.Upgrade="upgrade"})(Bt||(Bt={}));var T=Symbol.for("ic-agent-metadata"),P=class{constructor(e){this[T]=Object.freeze(e)}static agentOf(e){return e[T].config.agent}static interfaceOf(e){return e[T].service}static canisterIdOf(e){return f.from(e[T].config.canisterId)}static async install(e,r){let n=e.mode===void 0?Bt.Install:e.mode,o=e.arg?[...new Uint8Array(e.arg)]:[],i=[...new Uint8Array(e.module)],a=typeof r.canisterId=="string"?f.fromText(r.canisterId):r.canisterId;await Re(r).install_code({mode:{[n]:null},arg:o,wasm_module:i,canister_id:a})}static async createCanister(e){let{canister_id:r}=await Re(e||{}).provisional_create_canister_with_cycles({amount:[],settings:[]});return r}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){let r=e({IDL:y});class n extends P{constructor(i){let a=typeof i.canisterId=="string"?f.fromText(i.canisterId):i.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Ce),i),{canisterId:a}),service:r});for(let[c,l]of r._fields)this[c]=Qr(this,c,l,i.blsVerify)}}return n}static createActor(e,r){return new(this.createActorClass(e))(r)}};function Te(t,e){let r=y.decode(t,Ne.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var Ce={pollingStrategyFactory:yt.defaultStrategy};function Qr(t,e,r,n){let o;r.annotations.includes("query")?o=async(a,...c)=>{var l,u;a=Object.assign(Object.assign({},a),(u=(l=t[T].config).queryTransform)===null||u===void 0?void 0:u.call(l,e,c,Object.assign(Object.assign({},t[T].config),a)));let p=a.agent||t[T].config.agent||Ot(),d=f.from(a.canisterId||t[T].config.canisterId),m=y.encode(r.argTypes,c),h=await p.query(d,{methodName:e,arg:m});switch(h.status){case"rejected":throw new vt(d,e,h);case"replied":return Te(r.retTypes,h.reply.arg)}}:o=async(a,...c)=>{var l,u;a=Object.assign(Object.assign({},a),(u=(l=t[T].config).callTransform)===null||u===void 0?void 0:u.call(l,e,c,Object.assign(Object.assign({},t[T].config),a)));let p=a.agent||t[T].config.agent||Ot(),{canisterId:d,effectiveCanisterId:m,pollingStrategyFactory:h}=Object.assign(Object.assign(Object.assign({},Ce),t[T].config),a),x=f.from(d),O=m!==void 0?f.from(m):x,B=y.encode(r.argTypes,c),{requestId:E,response:N}=await p.call(x,{methodName:e,arg:B,effectiveCanisterId:O});if(!N.ok)throw new Vt(x,e,E,N);let k=h(),v=await Et(p,O,E,k,n);if(v!==void 0)return Te(r.retTypes,v);if(r.retTypes.length===0)return;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let i=(...a)=>o({},...a);return i.withOptions=a=>(...c)=>o(a,...c),i}function Re(t){function e(r,n,o){let i=n[0],a=f.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(a=f.from(i.canister_id)),{effectiveCanisterId:a}}return P.createActor(we,Object.assign(Object.assign(Object.assign({},t),{canisterId:f.fromHex("")}),{callTransform:e,queryTransform:e}))}var kt=async({canisterId:t,idlFactory:e,identity:r,fetch:n,env:o="prod",config:i})=>{let a=o==="dev"?"http://127.0.0.1:8000/":"https://icp0.io",c=new H({identity:r,...a&&{host:a},...n&&{fetch:n}});return o==="dev"&&await c.fetchRootKey(),P.createActor(e,{agent:c,canisterId:t,...i!==void 0?i:{}})};var Ae=async({satelliteId:t,...e})=>xt({canisterId:t,...e,idlFactory:Jt}),$=async({satelliteId:t,...e})=>xt({canisterId:t,...e,idlFactory:Qt}),be=async({satelliteId:t,...e})=>xt({canisterId:t,...e,idlFactory:Yt}),ot=async({missionControlId:t,...e})=>xt({canisterId:t,...e,idlFactory:Gt});var xt=async({canisterId:t,idlFactory:e,...r})=>{if(!t)throw new Error("No canister ID provided.");return kt({canisterId:t,idlFactory:e,...r})},Se=f.fromText("aaaaa-aa"),Fe=(t,e,r)=>{let n=e[0],o=Se;return n&&typeof n=="object"&&n.canister_id&&(o=f.from(n.canister_id)),{effectiveCanisterId:o}},Pe=t=>kt({canisterId:Se.toText(),config:{callTransform:Fe,queryTransform:Fe},idlFactory:Wt,...t});var it=async({actor:t,code:e})=>{let{install_code:r}=await Pe(t);return r({...e,mode:{upgrade:null}})};var Oe=async({missionControl:t})=>(await ot(t)).version(),Ee=async({missionControl:t})=>(await ot(t)).get_user();var ve=async({missionControl:t,satelliteIds:e,controllerIds:r,controller:n})=>(await ot(t)).set_satellites_controllers(e,r,n),Ve=async({missionControl:t,controllerIds:e,controller:r})=>(await ot(t)).set_mission_control_controllers(e,r);var gt=t=>t?[t]:[],wt=t=>t?.[0];var Ut=t=>t==null,at=t=>!Ut(t);var qt=({controllerId:t,profile:e})=>({controllerIds:[f.fromText(t)],controller:Zr(e)}),Zr=t=>({metadata:at(t)&&t!==""?[["profile",t]]:[],expires_at:gt(void 0),scope:{Admin:null}});var Ko=async t=>Oe(t),Wo=async({missionControl:t,wasm_module:e})=>{let r=await Ee({missionControl:t}),{missionControlId:n,...o}=t;if(!n)throw new Error("No mission control principal defined.");let i=y.encode([y.Record({user:y.Principal})],[{user:r}]);await it({actor:o,code:{canister_id:f.fromText(n),arg:[...new Uint8Array(i)],wasm_module:e}})},Go=async({controllerId:t,profile:e,...r})=>ve({...r,...qt({controllerId:t,profile:e})}),Yo=async({controllerId:t,profile:e,...r})=>Ve({...r,...qt({controllerId:t,profile:e})});var Be=async({config:t,satellite:e})=>(await $(e)).set_config(t),ke=async({satellite:t,type:e})=>(await $(t)).list_rules(e),Ue=async({type:t,collection:e,rule:r,satellite:n})=>(await $(n)).set_rule(t,e,r),qe=async({satellite:t})=>(await $(t)).version(),Me=async({satellite:t})=>(await Ae(t)).list_controllers(),je=async({satellite:t})=>(await be(t)).list_controllers(),He=async({satellite:t})=>(await $(t)).list_controllers(),$e=async({satellite:t})=>(await $(t)).list_custom_domains();var ze={Db:null},Ke={Storage:null},We={Public:null},Ge={Private:null},Ye={Managed:null},Je={Controllers:null};var Mt=t=>t==="storage"?Ke:ze,Ze=({read:t,write:e,max_size:r,updated_at:n})=>({read:Xe(t),write:Xe(e),updated_at:Ut(n)?[]:[n],max_size:gt(at(r)&&r>0?BigInt(r):void 0)}),Ie=([t,e])=>{let{read:r,write:n,updated_at:o,created_at:i,max_size:a}=e,c=a?.[0]??0n>0n?Number(wt(a)):void 0;return{collection:t,read:Qe(r),write:Qe(n),updated_at:o,created_at:i,...at(c)&&{max_size:c}}},Qe=t=>"Public"in t?"public":"Private"in t?"private":"Managed"in t?"managed":"controllers",Xe=t=>{switch(t){case"public":return We;case"private":return Ge;case"managed":return Ye;default:return Je}};var si=async({config:{storage:{headers:t}},satellite:e})=>{let r=t.map(({source:n,headers:o})=>[n,o]);return Be({satellite:e,config:{storage:{headers:r}}})},ci=async({type:t,satellite:e})=>(await ke({satellite:e,type:Mt(t)})).map(n=>Ie(n)),li=async({rule:{collection:t,...e},type:r,satellite:n})=>Ue({type:Mt(r),rule:Ze(e),satellite:n,collection:t}),ui=async t=>qe(t),pi=async({satellite:t,wasm_module:e,deprecated:r,deprecatedNoScope:n})=>{let{satelliteId:o,...i}=t;if(!o)throw new Error("No satellite principal defined.");if(r){let u=await Me({satellite:t}),p=y.encode([y.Record({controllers:y.Vec(y.Principal)})],[{controllers:u}]);await it({actor:i,code:{canister_id:f.fromText(o),arg:[...new Uint8Array(p)],wasm_module:e}});return}let c=await(n?je:He)({satellite:t}),l=y.encode([y.Record({controllers:y.Vec(y.Principal)})],[{controllers:c.map(([u,p])=>u)}]);await it({actor:i,code:{canister_id:f.fromText(o),arg:[...new Uint8Array(l)],wasm_module:e}})},di=async({satellite:t})=>(await $e({satellite:t})).map(([r,n])=>({domain:r,bn_id:wt(n.bn_id),created_at:n.created_at,updated_at:n.updated_at}));export{di as listCustomDomains,ci as listRules,Ko as missionControlVersion,ui as satelliteVersion,si as setConfig,Yo as setMissionControlController,li as setRule,Go as setSatellitesController,Wo as upgradeMissionControl,pi as upgradeSatellite};
22
22
  /*! Bundled license information:
23
23
 
24
24
  buffer/index.js: