@junobuild/admin 0.0.54-next-2024-08-24 → 0.0.55-next-2024-08-24

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,16 +1,16 @@
1
1
  import { createRequire as topLevelCreateRequire } from 'module';
2
2
  const require = topLevelCreateRequire(import.meta.url);
3
- var Cn=Object.create;var Mt=Object.defineProperty;var Fn=Object.getOwnPropertyDescriptor;var Sn=Object.getOwnPropertyNames;var On=Object.getPrototypeOf,An=Object.prototype.hasOwnProperty;var qt=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Q=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var En=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Sn(t))!An.call(e,o)&&o!==r&&Mt(e,o,{get:()=>t[o],enumerable:!(n=Fn(t,o))||n.enumerable});return e};var $t=(e,t,r)=>(r=e!=null?Cn(On(e)):{},En(t||!e||!e.__esModule?Mt(r,"default",{value:e,enumerable:!0}):r,e));var Fe=Q(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.bufFromBufLike=M.uint8ToBuf=M.PipeArrayBuffer=M.fromHexString=M.toHexString=M.concat=void 0;function Wn(...e){let t=new Uint8Array(e.reduce((n,o)=>n+o.byteLength,0)),r=0;for(let n of e)t.set(new Uint8Array(n),r),r+=n.byteLength;return t}M.concat=Wn;function Gn(e){return new Uint8Array(e).reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")}M.toHexString=Gn;function Jn(e){var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))}M.fromHexString=Jn;var it=class{constructor(t,r=t?.byteLength||0){this._buffer=Ce(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return Ce(this._view.slice())}get byteLength(){return this._view.byteLength}read(t){let r=this._view.subarray(0,t);return this._view=this._view.subarray(t),r.slice().buffer}readUint8(){let t=this._view[0];return this._view=this._view.subarray(1),t}write(t){let r=new Uint8Array(t),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+r.byteLength>=this._buffer.byteLength?this.alloc(r.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+r.byteLength),this._view.set(r,n)}get end(){return this._view.byteLength===0}alloc(t){let r=new ArrayBuffer((this._buffer.byteLength+t)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+t);n.set(this._view),this._buffer=r,this._view=n}};M.PipeArrayBuffer=it;function Re(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}M.uint8ToBuf=Re;function Ce(e){return e instanceof Uint8Array?Re(e):e instanceof ArrayBuffer?e:Array.isArray(e)?Re(new Uint8Array(e)):"buffer"in e?Ce(e.buffer):Re(new Uint8Array(e))}M.bufFromBufLike=Ce});var st=Q(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.idlLabelToId=void 0;function Yn(e){let r=new TextEncoder().encode(e),n=0;for(let o of r)n=(n*223+o)%2**32;return n}function Qn(e){if(/^_\d+_$/.test(e)||/^_0x[0-9a-fA-F]+_$/.test(e)){let t=+e.slice(1,-1);if(Number.isSafeInteger(t)&&t>=0&&t<2**32)return t}return Yn(e)}Se.idlLabelToId=Qn});var ct=Q(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.readIntLE=x.readUIntLE=x.writeIntLE=x.writeUIntLE=x.slebDecode=x.slebEncode=x.lebDecode=x.lebEncode=x.safeReadUint8=x.safeRead=void 0;var at=Fe();function or(){throw new Error("unexpected end of buffer")}function ir(e,t){return e.byteLength<t&&or(),e.read(t)}x.safeRead=ir;function Oe(e){let t=e.readUint8();return t===void 0&&or(),t}x.safeReadUint8=Oe;function Xn(e){if(typeof e=="number"&&(e=BigInt(e)),e<BigInt(0))throw new Error("Cannot leb encode negative values.");let t=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,r=new at.PipeArrayBuffer(new ArrayBuffer(t),0);for(;;){let n=Number(e&BigInt(127));if(e/=BigInt(128),e===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}x.lebEncode=Xn;function sr(e){let t=BigInt(1),r=BigInt(0),n;do n=Oe(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}x.lebDecode=sr;function Zn(e){typeof e=="number"&&(e=BigInt(e));let t=e<BigInt(0);t&&(e=-e-BigInt(1));let r=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,n=new at.PipeArrayBuffer(new ArrayBuffer(r),0);for(;;){let i=o(e);if(e/=BigInt(128),t&&e===BigInt(0)&&i&64||!t&&e===BigInt(0)&&!(i&64)){n.write(new Uint8Array([i]));break}else n.write(new Uint8Array([i|128]))}function o(i){let a=i%BigInt(128);return Number(t?BigInt(128)-a-BigInt(1):a)}return n.buffer}x.slebEncode=Zn;function In(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if(!(t[r]&64))return sr(e);break}let n=new Uint8Array(ir(e,r+1)),o=BigInt(0);for(let i=n.byteLength-1;i>=0;i--)o=o*BigInt(128)+BigInt(128-(n[i]&127)-1);return-o-BigInt(1)}x.slebDecode=In;function Dn(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return ar(e,t)}x.writeUIntLE=Dn;function ar(e,t){e=BigInt(e);let r=new at.PipeArrayBuffer(new ArrayBuffer(Math.min(1,t)),0),n=0,o=BigInt(256),i=BigInt(0),a=Number(e%o);for(r.write(new Uint8Array([a]));++n<t;)e<0&&i===BigInt(0)&&a!==0&&(i=BigInt(1)),a=Number((e/o-i)%BigInt(256)),r.write(new Uint8Array([a])),o*=BigInt(256);return r.buffer}x.writeIntLE=ar;function cr(e,t){let r=BigInt(Oe(e)),n=BigInt(1),o=0;for(;++o<t;){n*=BigInt(256);let i=BigInt(Oe(e));r=r+n*i}return r}x.readUIntLE=cr;function Ln(e,t){let r=cr(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}x.readIntLE=Ln});var lr=Q(oe=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});oe.iexp2=oe.ilog2=void 0;function eo(e){let t=BigInt(e);if(e<=0)throw new RangeError("Input must be positive");return t.toString(2).length-1}oe.ilog2=eo;function to(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}oe.iexp2=to});var mt=Q(s=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0});s.Variant=s.Record=s.Opt=s.Vec=s.Tuple=s.Principal=s.Nat64=s.Nat32=s.Nat16=s.Nat8=s.Int64=s.Int32=s.Int16=s.Int8=s.Float64=s.Float32=s.Nat=s.Int=s.Text=s.Null=s.Bool=s.Unknown=s.Reserved=s.Empty=s.decode=s.encode=s.ServiceClass=s.FuncClass=s.PrincipalClass=s.RecClass=s.VariantClass=s.TupleClass=s.RecordClass=s.OptClass=s.VecClass=s.FixedNatClass=s.FixedIntClass=s.FloatClass=s.NatClass=s.IntClass=s.TextClass=s.ReservedClass=s.NullClass=s.BoolClass=s.UnknownClass=s.EmptyClass=s.ConstructType=s.PrimitiveType=s.Type=s.Visitor=void 0;s.Service=s.Func=s.Rec=void 0;var ro=qt("@dfinity/principal"),h=Fe(),H=st(),c=ct(),lt=lr(),Ae="DIDL",ur=400;function ge(e,t,r){return e.map((n,o)=>r(n,t[o]))}var ut=class{constructor(){this._typs=[],this._idx=new Map}has(t){return this._idx.has(t.name)}add(t,r){let n=this._typs.length;this._idx.set(t.name,n),this._typs.push(r)}merge(t,r){let n=this._idx.get(t.name),o=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+t);if(o===void 0)throw new Error("Missing type index for "+r);this._typs[n]=this._typs[o],this._typs.splice(o,1),this._idx.delete(r)}encode(){let t=(0,c.lebEncode)(this._typs.length),r=(0,h.concat)(...this._typs);return(0,h.concat)(t,r)}indexOf(t){if(!this._idx.has(t))throw new Error("Missing type index for "+t);return(0,c.slebEncode)(this._idx.get(t)||0)}},dt=class{visitType(t,r){throw new Error("Not implemented")}visitPrimitive(t,r){return this.visitType(t,r)}visitEmpty(t,r){return this.visitPrimitive(t,r)}visitBool(t,r){return this.visitPrimitive(t,r)}visitNull(t,r){return this.visitPrimitive(t,r)}visitReserved(t,r){return this.visitPrimitive(t,r)}visitText(t,r){return this.visitPrimitive(t,r)}visitNumber(t,r){return this.visitPrimitive(t,r)}visitInt(t,r){return this.visitNumber(t,r)}visitNat(t,r){return this.visitNumber(t,r)}visitFloat(t,r){return this.visitPrimitive(t,r)}visitFixedInt(t,r){return this.visitNumber(t,r)}visitFixedNat(t,r){return this.visitNumber(t,r)}visitPrincipal(t,r){return this.visitPrimitive(t,r)}visitConstruct(t,r){return this.visitType(t,r)}visitVec(t,r,n){return this.visitConstruct(t,n)}visitOpt(t,r,n){return this.visitConstruct(t,n)}visitRecord(t,r,n){return this.visitConstruct(t,n)}visitTuple(t,r,n){let o=r.map((i,a)=>[`_${a}_`,i]);return this.visitRecord(t,o,n)}visitVariant(t,r,n){return this.visitConstruct(t,n)}visitRec(t,r,n){return this.visitConstruct(r,n)}visitFunc(t,r){return this.visitConstruct(t,r)}visitService(t,r){return this.visitConstruct(t,r)}};s.Visitor=dt;var ie=class{display(){return this.name}valueToString(t){return R(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}};s.Type=ie;var q=class extends ie{checkType(t){if(this.name!==t.name)throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`);return t}_buildTypeTableImpl(t){}};s.PrimitiveType=q;var W=class extends ie{checkType(t){if(t instanceof I){let r=t.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`)}encodeType(t){return t.indexOf(this.name)}};s.ConstructType=W;var Ee=class extends q{accept(t,r){return t.visitEmpty(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return(0,c.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};s.EmptyClass=Ee;var ke=class extends ie{checkType(t){throw new Error("Method not implemented for unknown.")}accept(t,r){throw t.visitType(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(t,r){let n=r.decodeValue(t,r);Object(n)!==n&&(n=Object(n));let o;return r instanceof I?o=()=>r.getType():o=()=>r,Object.defineProperty(n,"type",{value:o,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}};s.UnknownClass=ke;var Be=class extends q{accept(t,r){return t.visitBool(this,r)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return(0,c.slebEncode)(-2)}decodeValue(t,r){switch(this.checkType(r),(0,c.safeReadUint8)(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};s.BoolClass=Be;var Me=class extends q{accept(t,r){return t.visitNull(this,r)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,c.slebEncode)(-1)}decodeValue(t,r){return this.checkType(r),null}get name(){return"null"}};s.NullClass=Me;var se=class extends q{accept(t,r){return t.visitReserved(this,r)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,c.slebEncode)(-16)}decodeValue(t,r){return r.name!==this.name&&r.decodeValue(t,r),null}get name(){return"reserved"}};s.ReservedClass=se;var qe=class extends q{accept(t,r){return t.visitText(this,r)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(t){let r=new TextEncoder().encode(t),n=(0,c.lebEncode)(r.byteLength);return(0,h.concat)(n,r)}encodeType(){return(0,c.slebEncode)(-15)}decodeValue(t,r){this.checkType(r);let n=(0,c.lebDecode)(t),o=(0,c.safeRead)(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(o)}get name(){return"text"}valueToString(t){return'"'+t+'"'}};s.TextClass=qe;var $e=class extends q{accept(t,r){return t.visitInt(this,r)}covariant(t){if(typeof t=="bigint"||Number.isInteger(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(t){return(0,c.slebEncode)(t)}encodeType(){return(0,c.slebEncode)(-4)}decodeValue(t,r){return this.checkType(r),(0,c.slebDecode)(t)}get name(){return"int"}valueToString(t){return t.toString()}};s.IntClass=$e;var Ue=class extends q{accept(t,r){return t.visitNat(this,r)}covariant(t){if(typeof t=="bigint"&&t>=BigInt(0)||Number.isInteger(t)&&t>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(t){return(0,c.lebEncode)(t)}encodeType(){return(0,c.slebEncode)(-3)}decodeValue(t,r){return this.checkType(r),(0,c.lebDecode)(t)}get name(){return"nat"}valueToString(t){return t.toString()}};s.NatClass=Ue;var Te=class extends q{constructor(t){if(super(),this._bits=t,t!==32&&t!==64)throw new Error("not a valid float type")}accept(t,r){return t.visitFloat(this,r)}covariant(t){if(typeof t=="number"||t instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(t){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,t,!0):n.setFloat64(0,t,!0),r}encodeType(){let t=this._bits===32?-13:-14;return(0,c.slebEncode)(t)}decodeValue(t,r){this.checkType(r);let n=(0,c.safeRead)(t,this._bits/8),o=new DataView(n);return this._bits===32?o.getFloat32(0,!0):o.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(t){return t.toString()}};s.FloatClass=Te;var X=class extends q{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedInt(this,r)}covariant(t){let r=(0,lt.iexp2)(this._bits-1)*BigInt(-1),n=(0,lt.iexp2)(this._bits-1)-BigInt(1),o=!1;if(typeof t=="bigint")o=t>=r&&t<=n;else if(Number.isInteger(t)){let i=BigInt(t);o=i>=r&&i<=n}else o=!1;if(o)return!0;throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(t){return(0,c.writeIntLE)(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return(0,c.slebEncode)(-9-t)}decodeValue(t,r){this.checkType(r);let n=(0,c.readIntLE)(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}};s.FixedIntClass=X;var K=class extends q{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedNat(this,r)}covariant(t){let r=(0,lt.iexp2)(this._bits),n=!1;if(typeof t=="bigint"&&t>=BigInt(0)?n=t<r:Number.isInteger(t)&&t>=0?n=BigInt(t)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(t){return(0,c.writeUIntLE)(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return(0,c.slebEncode)(-5-t)}decodeValue(t,r){this.checkType(r);let n=(0,c.readUIntLE)(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}};s.FixedNatClass=K;var je=class e extends W{constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof K&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof K?this._type._bits:this._type instanceof X?this._type._bits:0;if(ArrayBuffer.isView(t)&&r==t.BYTES_PER_ELEMENT*8||Array.isArray(t)&&t.every((n,o)=>{try{return this._type.covariant(n)}catch(i){throw new Error(`Invalid ${this.display()} argument:
3
+ var Cn=Object.create;var Mt=Object.defineProperty;var Fn=Object.getOwnPropertyDescriptor;var Sn=Object.getOwnPropertyNames;var On=Object.getPrototypeOf,An=Object.prototype.hasOwnProperty;var qt=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Q=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var En=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Sn(t))!An.call(e,o)&&o!==r&&Mt(e,o,{get:()=>t[o],enumerable:!(n=Fn(t,o))||n.enumerable});return e};var $t=(e,t,r)=>(r=e!=null?Cn(On(e)):{},En(t||!e||!e.__esModule?Mt(r,"default",{value:e,enumerable:!0}):r,e));var Se=Q(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});q.bufFromBufLike=q.uint8ToBuf=q.PipeArrayBuffer=q.fromHexString=q.toHexString=q.concat=void 0;function Wn(...e){let t=new Uint8Array(e.reduce((n,o)=>n+o.byteLength,0)),r=0;for(let n of e)t.set(new Uint8Array(n),r),r+=n.byteLength;return t}q.concat=Wn;function Gn(e){return new Uint8Array(e).reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")}q.toHexString=Gn;function Jn(e){var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))}q.fromHexString=Jn;var it=class{constructor(t,r=t?.byteLength||0){this._buffer=Fe(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return Fe(this._view.slice())}get byteLength(){return this._view.byteLength}read(t){let r=this._view.subarray(0,t);return this._view=this._view.subarray(t),r.slice().buffer}readUint8(){let t=this._view[0];return this._view=this._view.subarray(1),t}write(t){let r=new Uint8Array(t),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+r.byteLength>=this._buffer.byteLength?this.alloc(r.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+r.byteLength),this._view.set(r,n)}get end(){return this._view.byteLength===0}alloc(t){let r=new ArrayBuffer((this._buffer.byteLength+t)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+t);n.set(this._view),this._buffer=r,this._view=n}};q.PipeArrayBuffer=it;function Ce(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}q.uint8ToBuf=Ce;function Fe(e){return e instanceof Uint8Array?Ce(e):e instanceof ArrayBuffer?e:Array.isArray(e)?Ce(new Uint8Array(e)):"buffer"in e?Fe(e.buffer):Ce(new Uint8Array(e))}q.bufFromBufLike=Fe});var st=Q(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});Oe.idlLabelToId=void 0;function Yn(e){let r=new TextEncoder().encode(e),n=0;for(let o of r)n=(n*223+o)%2**32;return n}function Qn(e){if(/^_\d+_$/.test(e)||/^_0x[0-9a-fA-F]+_$/.test(e)){let t=+e.slice(1,-1);if(Number.isSafeInteger(t)&&t>=0&&t<2**32)return t}return Yn(e)}Oe.idlLabelToId=Qn});var ct=Q(v=>{"use strict";Object.defineProperty(v,"__esModule",{value:!0});v.readIntLE=v.readUIntLE=v.writeIntLE=v.writeUIntLE=v.slebDecode=v.slebEncode=v.lebDecode=v.lebEncode=v.safeReadUint8=v.safeRead=void 0;var at=Se();function or(){throw new Error("unexpected end of buffer")}function ir(e,t){return e.byteLength<t&&or(),e.read(t)}v.safeRead=ir;function Ae(e){let t=e.readUint8();return t===void 0&&or(),t}v.safeReadUint8=Ae;function Xn(e){if(typeof e=="number"&&(e=BigInt(e)),e<BigInt(0))throw new Error("Cannot leb encode negative values.");let t=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,r=new at.PipeArrayBuffer(new ArrayBuffer(t),0);for(;;){let n=Number(e&BigInt(127));if(e/=BigInt(128),e===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}v.lebEncode=Xn;function sr(e){let t=BigInt(1),r=BigInt(0),n;do n=Ae(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}v.lebDecode=sr;function Zn(e){typeof e=="number"&&(e=BigInt(e));let t=e<BigInt(0);t&&(e=-e-BigInt(1));let r=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,n=new at.PipeArrayBuffer(new ArrayBuffer(r),0);for(;;){let i=o(e);if(e/=BigInt(128),t&&e===BigInt(0)&&i&64||!t&&e===BigInt(0)&&!(i&64)){n.write(new Uint8Array([i]));break}else n.write(new Uint8Array([i|128]))}function o(i){let a=i%BigInt(128);return Number(t?BigInt(128)-a-BigInt(1):a)}return n.buffer}v.slebEncode=Zn;function In(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if(!(t[r]&64))return sr(e);break}let n=new Uint8Array(ir(e,r+1)),o=BigInt(0);for(let i=n.byteLength-1;i>=0;i--)o=o*BigInt(128)+BigInt(128-(n[i]&127)-1);return-o-BigInt(1)}v.slebDecode=In;function Dn(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return ar(e,t)}v.writeUIntLE=Dn;function ar(e,t){e=BigInt(e);let r=new at.PipeArrayBuffer(new ArrayBuffer(Math.min(1,t)),0),n=0,o=BigInt(256),i=BigInt(0),a=Number(e%o);for(r.write(new Uint8Array([a]));++n<t;)e<0&&i===BigInt(0)&&a!==0&&(i=BigInt(1)),a=Number((e/o-i)%BigInt(256)),r.write(new Uint8Array([a])),o*=BigInt(256);return r.buffer}v.writeIntLE=ar;function cr(e,t){let r=BigInt(Ae(e)),n=BigInt(1),o=0;for(;++o<t;){n*=BigInt(256);let i=BigInt(Ae(e));r=r+n*i}return r}v.readUIntLE=cr;function Ln(e,t){let r=cr(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}v.readIntLE=Ln});var lr=Q(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.iexp2=ie.ilog2=void 0;function eo(e){let t=BigInt(e);if(e<=0)throw new RangeError("Input must be positive");return t.toString(2).length-1}ie.ilog2=eo;function to(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}ie.iexp2=to});var mt=Q(s=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0});s.Variant=s.Record=s.Opt=s.Vec=s.Tuple=s.Principal=s.Nat64=s.Nat32=s.Nat16=s.Nat8=s.Int64=s.Int32=s.Int16=s.Int8=s.Float64=s.Float32=s.Nat=s.Int=s.Text=s.Null=s.Bool=s.Unknown=s.Reserved=s.Empty=s.decode=s.encode=s.ServiceClass=s.FuncClass=s.PrincipalClass=s.RecClass=s.VariantClass=s.TupleClass=s.RecordClass=s.OptClass=s.VecClass=s.FixedNatClass=s.FixedIntClass=s.FloatClass=s.NatClass=s.IntClass=s.TextClass=s.ReservedClass=s.NullClass=s.BoolClass=s.UnknownClass=s.EmptyClass=s.ConstructType=s.PrimitiveType=s.Type=s.Visitor=void 0;s.Service=s.Func=s.Rec=void 0;var ro=qt("@dfinity/principal"),y=Se(),K=st(),c=ct(),lt=lr(),Ee="DIDL",ur=400;function Te(e,t,r){return e.map((n,o)=>r(n,t[o]))}var ut=class{constructor(){this._typs=[],this._idx=new Map}has(t){return this._idx.has(t.name)}add(t,r){let n=this._typs.length;this._idx.set(t.name,n),this._typs.push(r)}merge(t,r){let n=this._idx.get(t.name),o=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+t);if(o===void 0)throw new Error("Missing type index for "+r);this._typs[n]=this._typs[o],this._typs.splice(o,1),this._idx.delete(r)}encode(){let t=(0,c.lebEncode)(this._typs.length),r=(0,y.concat)(...this._typs);return(0,y.concat)(t,r)}indexOf(t){if(!this._idx.has(t))throw new Error("Missing type index for "+t);return(0,c.slebEncode)(this._idx.get(t)||0)}},dt=class{visitType(t,r){throw new Error("Not implemented")}visitPrimitive(t,r){return this.visitType(t,r)}visitEmpty(t,r){return this.visitPrimitive(t,r)}visitBool(t,r){return this.visitPrimitive(t,r)}visitNull(t,r){return this.visitPrimitive(t,r)}visitReserved(t,r){return this.visitPrimitive(t,r)}visitText(t,r){return this.visitPrimitive(t,r)}visitNumber(t,r){return this.visitPrimitive(t,r)}visitInt(t,r){return this.visitNumber(t,r)}visitNat(t,r){return this.visitNumber(t,r)}visitFloat(t,r){return this.visitPrimitive(t,r)}visitFixedInt(t,r){return this.visitNumber(t,r)}visitFixedNat(t,r){return this.visitNumber(t,r)}visitPrincipal(t,r){return this.visitPrimitive(t,r)}visitConstruct(t,r){return this.visitType(t,r)}visitVec(t,r,n){return this.visitConstruct(t,n)}visitOpt(t,r,n){return this.visitConstruct(t,n)}visitRecord(t,r,n){return this.visitConstruct(t,n)}visitTuple(t,r,n){let o=r.map((i,a)=>[`_${a}_`,i]);return this.visitRecord(t,o,n)}visitVariant(t,r,n){return this.visitConstruct(t,n)}visitRec(t,r,n){return this.visitConstruct(r,n)}visitFunc(t,r){return this.visitConstruct(t,r)}visitService(t,r){return this.visitConstruct(t,r)}};s.Visitor=dt;var se=class{display(){return this.name}valueToString(t){return V(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}};s.Type=se;var $=class extends se{checkType(t){if(this.name!==t.name)throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`);return t}_buildTypeTableImpl(t){}};s.PrimitiveType=$;var G=class extends se{checkType(t){if(t instanceof Z){let r=t.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`)}encodeType(t){return t.indexOf(this.name)}};s.ConstructType=G;var ke=class extends ${accept(t,r){return t.visitEmpty(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return(0,c.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};s.EmptyClass=ke;var Be=class extends se{checkType(t){throw new Error("Method not implemented for unknown.")}accept(t,r){throw t.visitType(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(t,r){let n=r.decodeValue(t,r);Object(n)!==n&&(n=Object(n));let o;return r instanceof Z?o=()=>r.getType():o=()=>r,Object.defineProperty(n,"type",{value:o,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}};s.UnknownClass=Be;var Me=class extends ${accept(t,r){return t.visitBool(this,r)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return(0,c.slebEncode)(-2)}decodeValue(t,r){switch(this.checkType(r),(0,c.safeReadUint8)(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};s.BoolClass=Me;var qe=class extends ${accept(t,r){return t.visitNull(this,r)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,c.slebEncode)(-1)}decodeValue(t,r){return this.checkType(r),null}get name(){return"null"}};s.NullClass=qe;var ae=class extends ${accept(t,r){return t.visitReserved(this,r)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,c.slebEncode)(-16)}decodeValue(t,r){return r.name!==this.name&&r.decodeValue(t,r),null}get name(){return"reserved"}};s.ReservedClass=ae;var $e=class extends ${accept(t,r){return t.visitText(this,r)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(t){let r=new TextEncoder().encode(t),n=(0,c.lebEncode)(r.byteLength);return(0,y.concat)(n,r)}encodeType(){return(0,c.slebEncode)(-15)}decodeValue(t,r){this.checkType(r);let n=(0,c.lebDecode)(t),o=(0,c.safeRead)(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(o)}get name(){return"text"}valueToString(t){return'"'+t+'"'}};s.TextClass=$e;var Ue=class extends ${accept(t,r){return t.visitInt(this,r)}covariant(t){if(typeof t=="bigint"||Number.isInteger(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(t){return(0,c.slebEncode)(t)}encodeType(){return(0,c.slebEncode)(-4)}decodeValue(t,r){return this.checkType(r),(0,c.slebDecode)(t)}get name(){return"int"}valueToString(t){return t.toString()}};s.IntClass=Ue;var je=class extends ${accept(t,r){return t.visitNat(this,r)}covariant(t){if(typeof t=="bigint"&&t>=BigInt(0)||Number.isInteger(t)&&t>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(t){return(0,c.lebEncode)(t)}encodeType(){return(0,c.slebEncode)(-3)}decodeValue(t,r){return this.checkType(r),(0,c.lebDecode)(t)}get name(){return"nat"}valueToString(t){return t.toString()}};s.NatClass=je;var be=class extends ${constructor(t){if(super(),this._bits=t,t!==32&&t!==64)throw new Error("not a valid float type")}accept(t,r){return t.visitFloat(this,r)}covariant(t){if(typeof t=="number"||t instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(t){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,t,!0):n.setFloat64(0,t,!0),r}encodeType(){let t=this._bits===32?-13:-14;return(0,c.slebEncode)(t)}decodeValue(t,r){this.checkType(r);let n=(0,c.safeRead)(t,this._bits/8),o=new DataView(n);return this._bits===32?o.getFloat32(0,!0):o.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(t){return t.toString()}};s.FloatClass=be;var X=class extends ${constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedInt(this,r)}covariant(t){let r=(0,lt.iexp2)(this._bits-1)*BigInt(-1),n=(0,lt.iexp2)(this._bits-1)-BigInt(1),o=!1;if(typeof t=="bigint")o=t>=r&&t<=n;else if(Number.isInteger(t)){let i=BigInt(t);o=i>=r&&i<=n}else o=!1;if(o)return!0;throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(t){return(0,c.writeIntLE)(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return(0,c.slebEncode)(-9-t)}decodeValue(t,r){this.checkType(r);let n=(0,c.readIntLE)(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}};s.FixedIntClass=X;var W=class extends ${constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedNat(this,r)}covariant(t){let r=(0,lt.iexp2)(this._bits),n=!1;if(typeof t=="bigint"&&t>=BigInt(0)?n=t<r:Number.isInteger(t)&&t>=0?n=BigInt(t)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(t){return(0,c.writeUIntLE)(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return(0,c.slebEncode)(-5-t)}decodeValue(t,r){this.checkType(r);let n=(0,c.readUIntLE)(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}};s.FixedNatClass=W;var ze=class e extends G{constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof W&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof W?this._type._bits:this._type instanceof X?this._type._bits:0;if(ArrayBuffer.isView(t)&&r==t.BYTES_PER_ELEMENT*8||Array.isArray(t)&&t.every((n,o)=>{try{return this._type.covariant(n)}catch(i){throw new Error(`Invalid ${this.display()} argument:
4
4
 
5
- index ${o} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(t){let r=(0,c.lebEncode)(t.length);if(this._blobOptimization)return(0,h.concat)(r,new Uint8Array(t));if(ArrayBuffer.isView(t))return(0,h.concat)(r,new Uint8Array(t.buffer));let n=new h.PipeArrayBuffer(new ArrayBuffer(r.byteLength+t.length),0);n.write(r);for(let o of t){let i=this._type.encodeValue(o);n.write(new Uint8Array(i))}return n.buffer}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=(0,c.slebEncode)(-19),n=this._type.encodeType(t);t.add(this,(0,h.concat)(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a vector type");let o=Number((0,c.lebDecode)(t));if(this._type instanceof K){if(this._type._bits==8)return new Uint8Array(t.read(o));if(this._type._bits==16)return new Uint16Array(t.read(o*2));if(this._type._bits==32)return new Uint32Array(t.read(o*4));if(this._type._bits==64)return new BigUint64Array(t.read(o*8))}if(this._type instanceof X){if(this._type._bits==8)return new Int8Array(t.read(o));if(this._type._bits==16)return new Int16Array(t.read(o*2));if(this._type._bits==32)return new Int32Array(t.read(o*4));if(this._type._bits==64)return new BigInt64Array(t.read(o*8))}let i=[];for(let a=0;a<o;a++)i.push(this._type.decodeValue(t,n._type));return i}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(t){return"vec {"+t.map(n=>this._type.valueToString(n)).join("; ")+"}"}};s.VecClass=je;var ae=class e extends W{constructor(t){super(),this._type=t}accept(t,r){return t.visitOpt(this,this._type,r)}covariant(t){try{if(Array.isArray(t)&&(t.length===0||t.length===1&&this._type.covariant(t[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${R(t)}
5
+ index ${o} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(t){let r=(0,c.lebEncode)(t.length);if(this._blobOptimization)return(0,y.concat)(r,new Uint8Array(t));if(ArrayBuffer.isView(t))return(0,y.concat)(r,new Uint8Array(t.buffer));let n=new y.PipeArrayBuffer(new ArrayBuffer(r.byteLength+t.length),0);n.write(r);for(let o of t){let i=this._type.encodeValue(o);n.write(new Uint8Array(i))}return n.buffer}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=(0,c.slebEncode)(-19),n=this._type.encodeType(t);t.add(this,(0,y.concat)(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a vector type");let o=Number((0,c.lebDecode)(t));if(this._type instanceof W){if(this._type._bits==8)return new Uint8Array(t.read(o));if(this._type._bits==16)return new Uint16Array(t.read(o*2));if(this._type._bits==32)return new Uint32Array(t.read(o*4));if(this._type._bits==64)return new BigUint64Array(t.read(o*8))}if(this._type instanceof X){if(this._type._bits==8)return new Int8Array(t.read(o));if(this._type._bits==16)return new Int16Array(t.read(o*2));if(this._type._bits==32)return new Int32Array(t.read(o*4));if(this._type._bits==64)return new BigInt64Array(t.read(o*8))}let i=[];for(let a=0;a<o;a++)i.push(this._type.decodeValue(t,n._type));return i}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(t){return"vec {"+t.map(n=>this._type.valueToString(n)).join("; ")+"}"}};s.VecClass=ze;var ce=class e extends G{constructor(t){super(),this._type=t}accept(t,r){return t.visitOpt(this,this._type,r)}covariant(t){try{if(Array.isArray(t)&&(t.length===0||t.length===1&&this._type.covariant(t[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${V(t)}
6
6
 
7
- -> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(t){return t.length===0?new Uint8Array([0]):(0,h.concat)(new Uint8Array([1]),this._type.encodeValue(t[0]))}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=(0,c.slebEncode)(-18),n=this._type.encodeType(t);t.add(this,(0,h.concat)(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not an option type");switch((0,c.safeReadUint8)(t)){case 0:return[];case 1:return[this._type.decodeValue(t,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(t){return t.length===0?"null":`opt ${this._type.valueToString(t[0])}`}};s.OptClass=ae;var be=class e extends W{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>(0,H.idlLabelToId)(r[0])-(0,H.idlLabelToId)(n[0]))}accept(t,r){return t.visitRecord(this,this._fields,r)}tryAsTuple(){let t=[];for(let r=0;r<this._fields.length;r++){let[n,o]=this._fields[r];if(n!==`_${r}_`)return null;t.push(o)}return t}covariant(t){if(typeof t=="object"&&this._fields.every(([r,n])=>{if(!t.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(t[r])}catch(o){throw new Error(`Invalid ${this.display()} argument:
7
+ -> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(t){return t.length===0?new Uint8Array([0]):(0,y.concat)(new Uint8Array([1]),this._type.encodeValue(t[0]))}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=(0,c.slebEncode)(-18),n=this._type.encodeType(t);t.add(this,(0,y.concat)(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not an option type");switch((0,c.safeReadUint8)(t)){case 0:return[];case 1:return[this._type.decodeValue(t,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(t){return t.length===0?"null":`opt ${this._type.valueToString(t[0])}`}};s.OptClass=ce;var we=class e extends G{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>(0,K.idlLabelToId)(r[0])-(0,K.idlLabelToId)(n[0]))}accept(t,r){return t.visitRecord(this,this._fields,r)}tryAsTuple(){let t=[];for(let r=0;r<this._fields.length;r++){let[n,o]=this._fields[r];if(n!==`_${r}_`)return null;t.push(o)}return t}covariant(t){if(typeof t=="object"&&this._fields.every(([r,n])=>{if(!t.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(t[r])}catch(o){throw new Error(`Invalid ${this.display()} argument:
8
8
 
9
- field ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(t){let r=this._fields.map(([o])=>t[o]),n=ge(this._fields,r,([,o],i)=>o.encodeValue(i));return(0,h.concat)(...n)}_buildTypeTableImpl(t){this._fields.forEach(([i,a])=>a.buildTypeTable(t));let r=(0,c.slebEncode)(-20),n=(0,c.lebEncode)(this._fields.length),o=this._fields.map(([i,a])=>(0,h.concat)((0,c.lebEncode)((0,H.idlLabelToId)(i)),a.encodeType(t)));t.add(this,(0,h.concat)(r,n,(0,h.concat)(...o)))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a record type");let o={},i=0,a=0;for(;a<n._fields.length;){let[u,p]=n._fields[a];if(i>=this._fields.length){p.decodeValue(t,p),a++;continue}let[d,y]=this._fields[i],g=(0,H.idlLabelToId)(this._fields[i][0]),b=(0,H.idlLabelToId)(u);if(g===b)o[d]=y.decodeValue(t,p),i++,a++;else if(b>g)if(y instanceof ae||y instanceof se)o[d]=[],i++;else throw new Error("Cannot find required field "+d);else p.decodeValue(t,p),a++}for(let[u,p]of this._fields.slice(i))if(p instanceof ae||p instanceof se)o[u]=[];else throw new Error("Cannot find required field "+u);return o}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(t){let r=this._fields.map(([o])=>t[o]);return`record {${ge(this._fields,r,([o,i],a)=>o+"="+i.valueToString(a)).join("; ")}}`}};s.RecordClass=be;var ze=class e extends be{constructor(t){let r={};t.forEach((n,o)=>r["_"+o+"_"]=n),super(r),this._components=t}accept(t,r){return t.visitTuple(this,this._components,r)}covariant(t){if(Array.isArray(t)&&t.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(t[n])}catch(o){throw new Error(`Invalid ${this.display()} argument:
9
+ field ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(t){let r=this._fields.map(([o])=>t[o]),n=Te(this._fields,r,([,o],i)=>o.encodeValue(i));return(0,y.concat)(...n)}_buildTypeTableImpl(t){this._fields.forEach(([i,a])=>a.buildTypeTable(t));let r=(0,c.slebEncode)(-20),n=(0,c.lebEncode)(this._fields.length),o=this._fields.map(([i,a])=>(0,y.concat)((0,c.lebEncode)((0,K.idlLabelToId)(i)),a.encodeType(t)));t.add(this,(0,y.concat)(r,n,(0,y.concat)(...o)))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a record type");let o={},i=0,a=0;for(;a<n._fields.length;){let[u,p]=n._fields[a];if(i>=this._fields.length){p.decodeValue(t,p),a++;continue}let[d,h]=this._fields[i],g=(0,K.idlLabelToId)(this._fields[i][0]),T=(0,K.idlLabelToId)(u);if(g===T)o[d]=h.decodeValue(t,p),i++,a++;else if(T>g)if(h instanceof ce||h instanceof ae)o[d]=[],i++;else throw new Error("Cannot find required field "+d);else p.decodeValue(t,p),a++}for(let[u,p]of this._fields.slice(i))if(p instanceof ce||p instanceof ae)o[u]=[];else throw new Error("Cannot find required field "+u);return o}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(t){let r=this._fields.map(([o])=>t[o]);return`record {${Te(this._fields,r,([o,i],a)=>o+"="+i.valueToString(a)).join("; ")}}`}};s.RecordClass=we;var He=class e extends we{constructor(t){let r={};t.forEach((n,o)=>r["_"+o+"_"]=n),super(r),this._components=t}accept(t,r){return t.visitTuple(this,this._components,r)}covariant(t){if(Array.isArray(t)&&t.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(t[n])}catch(o){throw new Error(`Invalid ${this.display()} argument:
10
10
 
11
- index ${n} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(t){let r=ge(this._components,t,(n,o)=>n.encodeValue(o));return(0,h.concat)(...r)}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let o=[];for(let[i,a]of n._components.entries())i>=this._components.length?a.decodeValue(t,a):o.push(this._components[i].decodeValue(t,a));return o}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(t){return`record {${ge(this._components,t,(n,o)=>n.valueToString(o)).join("; ")}}`}};s.TupleClass=ze;var He=class e extends W{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>(0,H.idlLabelToId)(r[0])-(0,H.idlLabelToId)(n[0]))}accept(t,r){return t.visitVariant(this,this._fields,r)}covariant(t){if(typeof t=="object"&&Object.entries(t).length===1&&this._fields.every(([r,n])=>{try{return!t.hasOwnProperty(r)||n.covariant(t[r])}catch(o){throw new Error(`Invalid ${this.display()} argument:
11
+ index ${n} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(t){let r=Te(this._components,t,(n,o)=>n.encodeValue(o));return(0,y.concat)(...r)}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let o=[];for(let[i,a]of n._components.entries())i>=this._components.length?a.decodeValue(t,a):o.push(this._components[i].decodeValue(t,a));return o}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(t){return`record {${Te(this._components,t,(n,o)=>n.valueToString(o)).join("; ")}}`}};s.TupleClass=He;var Ke=class e extends G{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>(0,K.idlLabelToId)(r[0])-(0,K.idlLabelToId)(n[0]))}accept(t,r){return t.visitVariant(this,this._fields,r)}covariant(t){if(typeof t=="object"&&Object.entries(t).length===1&&this._fields.every(([r,n])=>{try{return!t.hasOwnProperty(r)||n.covariant(t[r])}catch(o){throw new Error(`Invalid ${this.display()} argument:
12
12
 
13
- variant ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(t){for(let r=0;r<this._fields.length;r++){let[n,o]=this._fields[r];if(t.hasOwnProperty(n)){let i=(0,c.lebEncode)(r),a=o.encodeValue(t[n]);return(0,h.concat)(i,a)}}throw Error("Variant has no data: "+t)}_buildTypeTableImpl(t){this._fields.forEach(([,i])=>{i.buildTypeTable(t)});let r=(0,c.slebEncode)(-21),n=(0,c.lebEncode)(this._fields.length),o=this._fields.map(([i,a])=>(0,h.concat)((0,c.lebEncode)((0,H.idlLabelToId)(i)),a.encodeType(t)));t.add(this,(0,h.concat)(r,n,...o))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a variant type");let o=Number((0,c.lebDecode)(t));if(o>=n._fields.length)throw Error("Invalid variant index: "+o);let[i,a]=n._fields[o];for(let[u,p]of this._fields)if((0,H.idlLabelToId)(i)===(0,H.idlLabelToId)(u)){let d=p.decodeValue(t,a);return{[u]:d}}throw new Error("Cannot find field hash "+i)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(t){for(let[r,n]of this._fields)if(t.hasOwnProperty(r)){let o=n.valueToString(t[r]);return o==="null"?`variant {${r}}`:`variant {${r}=${o}}`}throw new Error("Variant has no data: "+t)}};s.VariantClass=He;var I=class e extends W{constructor(){super(...arguments),this._id=e._counter++,this._type=void 0}accept(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return t.visitRec(this,this._type,r)}fill(t){this._type=t}getType(){return this._type}covariant(t){if(this._type&&this._type.covariant(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(t)}_buildTypeTableImpl(t){if(!this._type)throw Error("Recursive type uninitialized.");t.add(this,new Uint8Array([])),this._type.buildTypeTable(t),t.merge(this,this._type.name)}decodeValue(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(t,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(t)}};s.RecClass=I;I._counter=0;function pt(e){if((0,c.safeReadUint8)(e)!==1)throw new Error("Cannot decode principal");let r=Number((0,c.lebDecode)(e));return ro.Principal.fromUint8Array(new Uint8Array((0,c.safeRead)(e,r)))}var Ke=class extends q{accept(t,r){return t.visitPrincipal(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=(0,c.lebEncode)(r.byteLength);return(0,h.concat)(new Uint8Array([1]),n,r)}encodeType(){return(0,c.slebEncode)(-24)}decodeValue(t,r){return this.checkType(r),pt(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}};s.PrincipalClass=Ke;var we=class extends W{constructor(t,r,n=[]){super(),this.argTypes=t,this.retTypes=r,this.annotations=n}static argsToString(t,r){if(t.length!==r.length)throw new Error("arity mismatch");return"("+t.map((n,o)=>n.valueToString(r[o])).join(", ")+")"}accept(t,r){return t.visitFunc(this,r)}covariant(t){if(Array.isArray(t)&&t.length===2&&t[0]&&t[0]._isPrincipal&&typeof t[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue([t,r]){let n=t.toUint8Array(),o=(0,c.lebEncode)(n.byteLength),i=(0,h.concat)(new Uint8Array([1]),o,n),a=new TextEncoder().encode(r),u=(0,c.lebEncode)(a.byteLength);return(0,h.concat)(new Uint8Array([1]),i,u,a)}_buildTypeTableImpl(t){this.argTypes.forEach(d=>d.buildTypeTable(t)),this.retTypes.forEach(d=>d.buildTypeTable(t));let r=(0,c.slebEncode)(-22),n=(0,c.lebEncode)(this.argTypes.length),o=(0,h.concat)(...this.argTypes.map(d=>d.encodeType(t))),i=(0,c.lebEncode)(this.retTypes.length),a=(0,h.concat)(...this.retTypes.map(d=>d.encodeType(t))),u=(0,c.lebEncode)(this.annotations.length),p=(0,h.concat)(...this.annotations.map(d=>this.encodeAnnotation(d)));t.add(this,(0,h.concat)(r,n,o,i,a,u,p))}decodeValue(t){if((0,c.safeReadUint8)(t)!==1)throw new Error("Cannot decode function reference");let n=pt(t),o=Number((0,c.lebDecode)(t)),i=(0,c.safeRead)(t,o),u=new TextDecoder("utf8",{fatal:!0}).decode(i);return[n,u]}get name(){let t=this.argTypes.map(o=>o.name).join(", "),r=this.retTypes.map(o=>o.name).join(", "),n=" "+this.annotations.join(" ");return`(${t}) -> (${r})${n}`}valueToString([t,r]){return`func "${t.toText()}".${r}`}display(){let t=this.argTypes.map(o=>o.display()).join(", "),r=this.retTypes.map(o=>o.display()).join(", "),n=" "+this.annotations.join(" ");return`(${t}) \u2192 (${r})${n}`}encodeAnnotation(t){if(t==="query")return new Uint8Array([1]);if(t==="oneway")return new Uint8Array([2]);if(t==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}};s.FuncClass=we;var We=class extends W{constructor(t){super(),this._fields=Object.entries(t).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(t,r){return t.visitService(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${R(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=(0,c.lebEncode)(r.length);return(0,h.concat)(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([i,a])=>a.buildTypeTable(t));let r=(0,c.slebEncode)(-23),n=(0,c.lebEncode)(this._fields.length),o=this._fields.map(([i,a])=>{let u=new TextEncoder().encode(i),p=(0,c.lebEncode)(u.length);return(0,h.concat)(p,u,a.encodeType(t))});t.add(this,(0,h.concat)(r,n,...o))}decodeValue(t){return pt(t)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(t){return`service "${t.toText()}"`}};s.ServiceClass=We;function R(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>ur?t.substring(0,ur-3)+"...":t}function no(e,t){if(t.length<e.length)throw Error("Wrong number of message arguments");let r=new ut;e.forEach(p=>p.buildTypeTable(r));let n=new TextEncoder().encode(Ae),o=r.encode(),i=(0,c.lebEncode)(t.length),a=(0,h.concat)(...e.map(p=>p.encodeType(r))),u=(0,h.concat)(...ge(e,t,(p,d)=>{try{p.covariant(d)}catch(y){throw new Error(y.message+`
13
+ variant ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(t){for(let r=0;r<this._fields.length;r++){let[n,o]=this._fields[r];if(t.hasOwnProperty(n)){let i=(0,c.lebEncode)(r),a=o.encodeValue(t[n]);return(0,y.concat)(i,a)}}throw Error("Variant has no data: "+t)}_buildTypeTableImpl(t){this._fields.forEach(([,i])=>{i.buildTypeTable(t)});let r=(0,c.slebEncode)(-21),n=(0,c.lebEncode)(this._fields.length),o=this._fields.map(([i,a])=>(0,y.concat)((0,c.lebEncode)((0,K.idlLabelToId)(i)),a.encodeType(t)));t.add(this,(0,y.concat)(r,n,...o))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a variant type");let o=Number((0,c.lebDecode)(t));if(o>=n._fields.length)throw Error("Invalid variant index: "+o);let[i,a]=n._fields[o];for(let[u,p]of this._fields)if((0,K.idlLabelToId)(i)===(0,K.idlLabelToId)(u)){let d=p.decodeValue(t,a);return{[u]:d}}throw new Error("Cannot find field hash "+i)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(t){for(let[r,n]of this._fields)if(t.hasOwnProperty(r)){let o=n.valueToString(t[r]);return o==="null"?`variant {${r}}`:`variant {${r}=${o}}`}throw new Error("Variant has no data: "+t)}};s.VariantClass=Ke;var Z=class e extends G{constructor(){super(...arguments),this._id=e._counter++,this._type=void 0}accept(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return t.visitRec(this,this._type,r)}fill(t){this._type=t}getType(){return this._type}covariant(t){if(this._type&&this._type.covariant(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(t)}_buildTypeTableImpl(t){if(!this._type)throw Error("Recursive type uninitialized.");t.add(this,new Uint8Array([])),this._type.buildTypeTable(t),t.merge(this,this._type.name)}decodeValue(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(t,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(t)}};s.RecClass=Z;Z._counter=0;function pt(e){if((0,c.safeReadUint8)(e)!==1)throw new Error("Cannot decode principal");let r=Number((0,c.lebDecode)(e));return ro.Principal.fromUint8Array(new Uint8Array((0,c.safeRead)(e,r)))}var We=class extends ${accept(t,r){return t.visitPrincipal(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=(0,c.lebEncode)(r.byteLength);return(0,y.concat)(new Uint8Array([1]),n,r)}encodeType(){return(0,c.slebEncode)(-24)}decodeValue(t,r){return this.checkType(r),pt(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}};s.PrincipalClass=We;var xe=class extends G{constructor(t,r,n=[]){super(),this.argTypes=t,this.retTypes=r,this.annotations=n}static argsToString(t,r){if(t.length!==r.length)throw new Error("arity mismatch");return"("+t.map((n,o)=>n.valueToString(r[o])).join(", ")+")"}accept(t,r){return t.visitFunc(this,r)}covariant(t){if(Array.isArray(t)&&t.length===2&&t[0]&&t[0]._isPrincipal&&typeof t[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue([t,r]){let n=t.toUint8Array(),o=(0,c.lebEncode)(n.byteLength),i=(0,y.concat)(new Uint8Array([1]),o,n),a=new TextEncoder().encode(r),u=(0,c.lebEncode)(a.byteLength);return(0,y.concat)(new Uint8Array([1]),i,u,a)}_buildTypeTableImpl(t){this.argTypes.forEach(d=>d.buildTypeTable(t)),this.retTypes.forEach(d=>d.buildTypeTable(t));let r=(0,c.slebEncode)(-22),n=(0,c.lebEncode)(this.argTypes.length),o=(0,y.concat)(...this.argTypes.map(d=>d.encodeType(t))),i=(0,c.lebEncode)(this.retTypes.length),a=(0,y.concat)(...this.retTypes.map(d=>d.encodeType(t))),u=(0,c.lebEncode)(this.annotations.length),p=(0,y.concat)(...this.annotations.map(d=>this.encodeAnnotation(d)));t.add(this,(0,y.concat)(r,n,o,i,a,u,p))}decodeValue(t){if((0,c.safeReadUint8)(t)!==1)throw new Error("Cannot decode function reference");let n=pt(t),o=Number((0,c.lebDecode)(t)),i=(0,c.safeRead)(t,o),u=new TextDecoder("utf8",{fatal:!0}).decode(i);return[n,u]}get name(){let t=this.argTypes.map(o=>o.name).join(", "),r=this.retTypes.map(o=>o.name).join(", "),n=" "+this.annotations.join(" ");return`(${t}) -> (${r})${n}`}valueToString([t,r]){return`func "${t.toText()}".${r}`}display(){let t=this.argTypes.map(o=>o.display()).join(", "),r=this.retTypes.map(o=>o.display()).join(", "),n=" "+this.annotations.join(" ");return`(${t}) \u2192 (${r})${n}`}encodeAnnotation(t){if(t==="query")return new Uint8Array([1]);if(t==="oneway")return new Uint8Array([2]);if(t==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}};s.FuncClass=xe;var Ge=class extends G{constructor(t){super(),this._fields=Object.entries(t).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(t,r){return t.visitService(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${V(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=(0,c.lebEncode)(r.length);return(0,y.concat)(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([i,a])=>a.buildTypeTable(t));let r=(0,c.slebEncode)(-23),n=(0,c.lebEncode)(this._fields.length),o=this._fields.map(([i,a])=>{let u=new TextEncoder().encode(i),p=(0,c.lebEncode)(u.length);return(0,y.concat)(p,u,a.encodeType(t))});t.add(this,(0,y.concat)(r,n,...o))}decodeValue(t){return pt(t)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(t){return`service "${t.toText()}"`}};s.ServiceClass=Ge;function V(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>ur?t.substring(0,ur-3)+"...":t}function no(e,t){if(t.length<e.length)throw Error("Wrong number of message arguments");let r=new ut;e.forEach(p=>p.buildTypeTable(r));let n=new TextEncoder().encode(Ee),o=r.encode(),i=(0,c.lebEncode)(t.length),a=(0,y.concat)(...e.map(p=>p.encodeType(r))),u=(0,y.concat)(...Te(e,t,(p,d)=>{try{p.covariant(d)}catch(h){throw new Error(h.message+`
14
14
 
15
- `)}return p.encodeValue(d)}));return(0,h.concat)(n,o,i,a,u)}s.encode=no;function oo(e,t){let r=new h.PipeArrayBuffer(t);if(t.byteLength<Ae.length)throw new Error("Message length smaller than magic number");let n=(0,c.safeRead)(r,Ae.length),o=new TextDecoder().decode(n);if(o!==Ae)throw new Error("Wrong magic number: "+JSON.stringify(o));function i(l){let m=[],T=Number((0,c.lebDecode)(l));for(let w=0;w<T;w++){let _=Number((0,c.slebDecode)(l));switch(_){case-18:case-19:{let C=Number((0,c.slebDecode)(l));m.push([_,C]);break}case-20:case-21:{let C=[],P=Number((0,c.lebDecode)(l)),S;for(;P--;){let V=Number((0,c.lebDecode)(l));if(V>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof S=="number"&&S>=V)throw new Error("field id collision or not sorted");S=V;let F=Number((0,c.slebDecode)(l));C.push([V,F])}m.push([_,C]);break}case-22:{let C=[],P=Number((0,c.lebDecode)(l));for(;P--;)C.push(Number((0,c.slebDecode)(l)));let S=[],V=Number((0,c.lebDecode)(l));for(;V--;)S.push(Number((0,c.slebDecode)(l)));let F=[],B=Number((0,c.lebDecode)(l));for(;B--;)switch(Number((0,c.lebDecode)(l))){case 1:{F.push("query");break}case 2:{F.push("oneway");break}case 3:{F.push("composite_query");break}default:throw new Error("unknown annotation")}m.push([_,[C,S,F]]);break}case-23:{let C=Number((0,c.lebDecode)(l)),P=[];for(;C--;){let S=Number((0,c.lebDecode)(l)),V=new TextDecoder().decode((0,c.safeRead)(l,S)),F=(0,c.slebDecode)(l);P.push([V,F])}m.push([_,P]);break}default:throw new Error("Illegal op_code: "+_)}}let v=[],N=Number((0,c.lebDecode)(l));for(let w=0;w<N;w++)v.push(Number((0,c.slebDecode)(l)));return[m,v]}let[a,u]=i(r);if(u.length<e.length)throw new Error("Wrong number of return values");let p=a.map(l=>hr());function d(l){if(l<-24)throw new Error("future value not supported");if(l<0)switch(l){case-1:return s.Null;case-2:return s.Bool;case-3:return s.Nat;case-4:return s.Int;case-5:return s.Nat8;case-6:return s.Nat16;case-7:return s.Nat32;case-8:return s.Nat64;case-9:return s.Int8;case-10:return s.Int16;case-11:return s.Int32;case-12:return s.Int64;case-13:return s.Float32;case-14:return s.Float64;case-15:return s.Text;case-16:return s.Reserved;case-17:return s.Empty;case-24:return s.Principal;default:throw new Error("Illegal op_code: "+l)}if(l>=a.length)throw new Error("type index out of range");return p[l]}function y(l){switch(l[0]){case-19:{let m=d(l[1]);return pr(m)}case-18:{let m=d(l[1]);return mr(m)}case-20:{let m={};for(let[N,w]of l[1]){let _=`_${N}_`;m[_]=d(w)}let T=_r(m),v=T.tryAsTuple();return Array.isArray(v)?dr(...v):T}case-21:{let m={};for(let[T,v]of l[1]){let N=`_${T}_`;m[N]=d(v)}return fr(m)}case-22:{let[m,T,v]=l[1];return yr(m.map(N=>d(N)),T.map(N=>d(N)),v)}case-23:{let m={},T=l[1];for(let[v,N]of T){let w=d(N);if(w instanceof I&&(w=w.getType()),!(w instanceof we))throw new Error("Illegal service definition: services can only contain functions");m[v]=w}return gr(m)}default:throw new Error("Illegal op_code: "+l[0])}}a.forEach((l,m)=>{if(l[0]===-22){let T=y(l);p[m].fill(T)}}),a.forEach((l,m)=>{if(l[0]!==-22){let T=y(l);p[m].fill(T)}});let g=u.map(l=>d(l)),b=e.map((l,m)=>l.decodeValue(r,g[m]));for(let l=e.length;l<g.length;l++)g[l].decodeValue(r,g[l]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return b}s.decode=oo;s.Empty=new Ee;s.Reserved=new se;s.Unknown=new ke;s.Bool=new Be;s.Null=new Me;s.Text=new qe;s.Int=new $e;s.Nat=new Ue;s.Float32=new Te(32);s.Float64=new Te(64);s.Int8=new X(8);s.Int16=new X(16);s.Int32=new X(32);s.Int64=new X(64);s.Nat8=new K(8);s.Nat16=new K(16);s.Nat32=new K(32);s.Nat64=new K(64);s.Principal=new Ke;function dr(...e){return new ze(e)}s.Tuple=dr;function pr(e){return new je(e)}s.Vec=pr;function mr(e){return new ae(e)}s.Opt=mr;function _r(e){return new be(e)}s.Record=_r;function fr(e){return new He(e)}s.Variant=fr;function hr(){return new I}s.Rec=hr;function yr(e,t,r=[]){return new we(e,t,r)}s.Func=yr;function gr(e){return new We(e)}s.Service=gr});var bt=Q(k=>{"use strict";Object.defineProperty(k,"__esModule",{value:!0});k.VecForm=k.OptionForm=k.VariantForm=k.TupleForm=k.RecordForm=k.InputForm=k.InputBox=void 0;var _t=class{constructor(t,r){this.idl=t,this.ui=r,this.label=null,this.value=void 0;let n=document.createElement("span");n.className="status",this.status=n,r.input&&(r.input.addEventListener("blur",()=>{r.input.value!==""&&this.parse()}),r.input.addEventListener("input",()=>{n.style.display="none",r.input.classList.remove("reject")}))}isRejected(){return this.value===void 0}parse(t={}){if(this.ui.form){let r=this.ui.form.parse(t);return this.value=r,r}if(this.ui.input){let r=this.ui.input;try{let n=this.ui.parse(this.idl,t,r.value);if(!this.idl.covariant(n))throw new Error(`${r.value} is not of type ${this.idl.display()}`);return this.status.style.display="none",this.value=n,n}catch(n){r.classList.add("reject"),this.status.style.display="block",this.status.innerHTML="InputError: "+n.message,this.value=void 0;return}}return null}render(t){let r=document.createElement("span");if(this.label){let n=document.createElement("label");n.innerText=this.label,r.appendChild(n)}this.ui.input&&(r.appendChild(this.ui.input),r.appendChild(this.status)),this.ui.form&&this.ui.form.render(r),t.appendChild(r)}};k.InputBox=_t;var D=class{constructor(t){this.ui=t,this.form=[]}renderForm(t){this.ui.container?(this.form.forEach(r=>r.render(this.ui.container)),t.appendChild(this.ui.container)):this.form.forEach(r=>r.render(t))}render(t){if(this.ui.open&&this.ui.event){t.appendChild(this.ui.open);let r=this;r.ui.open.addEventListener(r.ui.event,()=>{if(r.ui.container)r.ui.container.innerHTML="";else{let n=r.ui.open.nextElementSibling;n&&n.parentNode.removeChild(n)}r.generateForm(),r.renderForm(t)})}else this.generateForm(),this.renderForm(t)}};k.InputForm=D;var ft=class extends D{constructor(t,r){super(r),this.fields=t,this.ui=r}generateForm(){this.form=this.fields.map(([t,r])=>{let n=this.ui.render(r);return this.ui.labelMap&&this.ui.labelMap.hasOwnProperty(t)?n.label=this.ui.labelMap[t]+" ":n.label=t+" ",n})}parse(t){let r={};if(this.fields.forEach(([n,o],i)=>{let a=this.form[i].parse(t);r[n]=a}),!this.form.some(n=>n.isRejected()))return r}};k.RecordForm=ft;var ht=class extends D{constructor(t,r){super(r),this.components=t,this.ui=r}generateForm(){this.form=this.components.map(t=>this.ui.render(t))}parse(t){let r=[];if(this.components.forEach((n,o)=>{let i=this.form[o].parse(t);r.push(i)}),!this.form.some(n=>n.isRejected()))return r}};k.TupleForm=ht;var yt=class extends D{constructor(t,r){super(r),this.fields=t,this.ui=r}generateForm(){let t=this.ui.open.selectedIndex,[r,n]=this.fields[t],o=this.ui.render(n);this.form=[o]}parse(t){let r=this.ui.open,n=r.options[r.selectedIndex].value,o=this.form[0].parse(t);if(o===void 0)return;let i={};return i[n]=o,i}};k.VariantForm=yt;var gt=class extends D{constructor(t,r){super(r),this.ty=t,this.ui=r}generateForm(){if(this.ui.open.checked){let t=this.ui.render(this.ty);this.form=[t]}else this.form=[]}parse(t){if(this.form.length===0)return[];{let r=this.form[0].parse(t);return r===void 0?void 0:[r]}}};k.OptionForm=gt;var Tt=class extends D{constructor(t,r){super(r),this.ty=t,this.ui=r}generateForm(){let t=+this.ui.open.value;this.form=[];for(let r=0;r<t;r++){let n=this.ui.render(this.ty);this.form.push(n)}}parse(t){let r=this.form.map(n=>n.parse(t));if(!this.form.some(n=>n.isRejected()))return r}};k.VecForm=Tt});var br=Q(f=>{"use strict";var io=f&&f.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),so=f&&f.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Tr=f&&f.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&io(t,e,r);return so(t,e),t};Object.defineProperty(f,"__esModule",{value:!0});f.renderValue=f.renderInput=f.Render=f.vecForm=f.optForm=f.variantForm=f.tupleForm=f.recordForm=f.inputBox=void 0;var Je=Tr(mt()),wt=qt("@dfinity/principal"),ce=Tr(bt()),ao={parse:fo},xe={render:Pt},co=(e,t)=>new ce.InputBox(e,Object.assign(Object.assign({},ao),t));f.inputBox=co;var lo=(e,t)=>new ce.RecordForm(e,Object.assign(Object.assign({},xe),t));f.recordForm=lo;var uo=(e,t)=>new ce.TupleForm(e,Object.assign(Object.assign({},xe),t));f.tupleForm=uo;var po=(e,t)=>new ce.VariantForm(e,Object.assign(Object.assign({},xe),t));f.variantForm=po;var mo=(e,t)=>new ce.OptionForm(e,Object.assign(Object.assign({},xe),t));f.optForm=mo;var _o=(e,t)=>new ce.VecForm(e,Object.assign(Object.assign({},xe),t));f.vecForm=_o;var Ge=class extends Je.Visitor{visitType(t,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=t.display(),(0,f.inputBox)(t,{input:n})}visitNull(t,r){return(0,f.inputBox)(t,{})}visitRecord(t,r,n){let o={};if(r.length>1){let a=document.createElement("div");a.classList.add("popup-form"),o={container:a}}let i=(0,f.recordForm)(r,o);return(0,f.inputBox)(t,{form:i})}visitTuple(t,r,n){let o={};if(r.length>1){let a=document.createElement("div");a.classList.add("popup-form"),o={container:a}}let i=(0,f.tupleForm)(r,o);return(0,f.inputBox)(t,{form:i})}visitVariant(t,r,n){let o=document.createElement("select");for(let[u,p]of r){let d=new Option(u);o.add(d)}o.selectedIndex=-1,o.classList.add("open");let i={open:o,event:"change"},a=(0,f.variantForm)(r,i);return(0,f.inputBox)(t,{form:a})}visitOpt(t,r,n){let o=document.createElement("input");o.type="checkbox",o.classList.add("open");let i=(0,f.optForm)(r,{open:o,event:"change"});return(0,f.inputBox)(t,{form:i})}visitVec(t,r,n){let o=document.createElement("input");o.type="number",o.min="0",o.max="100",o.style.width="8rem",o.placeholder="len",o.classList.add("open");let i=document.createElement("div");i.classList.add("popup-form");let a=(0,f.vecForm)(r,{open:o,event:"change",container:i});return(0,f.inputBox)(t,{form:a})}visitRec(t,r,n){return Pt(r)}};f.Render=Ge;var xt=class extends Je.Visitor{visitNull(t,r){return null}visitBool(t,r){if(r==="true")return!0;if(r==="false")return!1;throw new Error(`Cannot parse ${r} as boolean`)}visitText(t,r){return r}visitFloat(t,r){return parseFloat(r)}visitFixedInt(t,r){return t._bits<=32?parseInt(r,10):BigInt(r)}visitFixedNat(t,r){return t._bits<=32?parseInt(r,10):BigInt(r)}visitNumber(t,r){return BigInt(r)}visitPrincipal(t,r){return wt.Principal.fromText(r)}visitService(t,r){return wt.Principal.fromText(r)}visitFunc(t,r){let n=r.split(".",2);return[wt.Principal.fromText(n[0]),n[1]]}},vt=class extends Je.Visitor{visitNull(t,r){return null}visitBool(t,r){return Math.random()<.5}visitText(t,r){return Math.random().toString(36).substring(6)}visitFloat(t,r){return Math.random()}visitInt(t,r){return BigInt(this.generateNumber(!0))}visitNat(t,r){return BigInt(this.generateNumber(!1))}visitFixedInt(t,r){let n=this.generateNumber(!0);return t._bits<=32?n:BigInt(r)}visitFixedNat(t,r){let n=this.generateNumber(!1);return t._bits<=32?n:BigInt(r)}generateNumber(t){let r=Math.floor(Math.random()*100);return t&&Math.random()<.5?-r:r}};function fo(e,t,r){return t.random&&r===""?e.accept(new vt,r):e.accept(new xt,r)}function Pt(e){return e.accept(new Ge,null)}f.renderInput=Pt;function te(e,t,r){return e.accept(new Nt,{input:t,value:r})}f.renderValue=te;var Nt=class extends Je.Visitor{visitType(t,r){r.input.ui.input.value=t.valueToString(r.value)}visitNull(t,r){}visitText(t,r){r.input.ui.input.value=r.value}visitRec(t,r,n){te(r,n.input,n.value)}visitOpt(t,r,n){if(n.value.length!==0){let o=n.input.ui.form,i=o.ui.open;i.checked=!0,i.dispatchEvent(new Event(o.ui.event)),te(r,o.form[0],n.value[0])}}visitRecord(t,r,n){let o=n.input.ui.form;r.forEach(([i,a],u)=>{te(a,o.form[u],n.value[i])})}visitTuple(t,r,n){let o=n.input.ui.form;r.forEach((i,a)=>{te(i,o.form[a],n.value[a])})}visitVariant(t,r,n){let o=n.input.ui.form,i=Object.entries(n.value)[0];r.forEach(([a,u],p)=>{if(a===i[0]){let d=o.ui.open;d.selectedIndex=p,d.dispatchEvent(new Event(o.ui.event)),te(u,o.form[0],i[1])}})}visitVec(t,r,n){let o=n.input.ui.form,i=n.value.length,a=o.ui.open;a.value=i,a.dispatchEvent(new Event(o.ui.event)),n.value.forEach((u,p)=>{te(r,o.form[p],u)})}}});var xr=Q(wr=>{"use strict";Object.defineProperty(wr,"__esModule",{value:!0})});var Vt=Q(A=>{"use strict";var vr=A&&A.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),ho=A&&A.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),le=A&&A.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&vr(t,e,r)},yo=A&&A.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&vr(t,e,r);return ho(t,e),t};Object.defineProperty(A,"__esModule",{value:!0});A.IDL=void 0;le(br(),A);le(bt(),A);A.IDL=yo(mt());le(st(),A);le(ct(),A);le(Fe(),A);le(xr(),A)});import{Principal as go}from"@dfinity/principal";import{CanisterStatus as qn}from"@dfinity/agent";import{Principal as $n}from"@dfinity/principal";import{assertNonNullish as Un}from"@junobuild/utils";import{Actor as kn,HttpAgent as Bn}from"@dfinity/agent";import{nonNullish as Ut}from"@junobuild/utils";var rt=async({canisterId:e,idlFactory:t,config:r,...n})=>{let o=await nt(n);return kn.createActor(t,{agent:o,canisterId:e,...r!==void 0?r:{}})},nt=async({identity:e,fetch:t,container:r})=>{let n=Ut(r)&&r!==!1,o=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io",i=new Bn({identity:e,host:o,retryTimes:10,...Ut(t)&&{fetch:t}});return n&&await i.fetchRootKey(),i};import{Principal as Yt}from"@dfinity/principal";import{isNullish as Mn}from"@junobuild/utils";var jt=({IDL:e})=>{let t=e.Variant({mainnet:e.Null,testnet:e.Null}),r=e.Text,n=e.Record({network:t,address:r,min_confirmations:e.Opt(e.Nat32)}),o=e.Nat64,i=o,a=e.Record({network:t,address:r,min_confirmations:e.Opt(e.Nat32)}),u=o,p=e.Record({network:t}),d=e.Nat64,y=e.Vec(d),g=e.Record({network:t,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:r}),b=e.Vec(e.Nat8),l=e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32}),m=e.Record({height:e.Nat32,value:o,outpoint:l}),T=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:e.Nat32,tip_block_hash:b,utxos:e.Vec(m)}),v=e.Record({network:t,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:r}),N=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:e.Nat32,tip_block_hash:b,utxos:e.Vec(m)}),w=e.Record({transaction:e.Vec(e.Nat8),network:t}),_=e.Principal,C=e.Record({canister_id:_,num_requested_changes:e.Opt(e.Nat64)}),P=e.Variant({from_user:e.Record({user_id:e.Principal}),from_canister:e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal})}),S=e.Variant({creation:e.Record({controllers:e.Vec(e.Principal)}),code_deployment:e.Record({mode:e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),module_hash:e.Vec(e.Nat8)}),controllers_change:e.Record({controllers:e.Vec(e.Principal)}),code_uninstall:e.Null}),V=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:P,details:S}),F=e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec(V),total_num_changes:e.Nat64}),B=e.Record({canister_id:_}),E=e.Variant({controllers:e.Null,public:e.Null}),G=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),reserved_cycles_limit:e.Nat,log_visibility:E,wasm_memory_limit:e.Nat,memory_allocation:e.Nat,compute_allocation:e.Nat}),J=e.Record({status:e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),memory_size:e.Nat,cycles:e.Nat,settings:G,query_stats:e.Record({response_payload_bytes_total:e.Nat,num_instructions_total:e.Nat,num_calls_total:e.Nat,request_payload_bytes_total:e.Nat}),idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8)),reserved_cycles:e.Nat}),z=e.Record({canister_id:_}),$=e.Record({freezing_threshold:e.Opt(e.Nat),controllers:e.Opt(e.Vec(e.Principal)),reserved_cycles_limit:e.Opt(e.Nat),log_visibility:e.Opt(E),wasm_memory_limit:e.Opt(e.Nat),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),U=e.Record({settings:e.Opt($),sender_canister_version:e.Opt(e.Nat64)}),j=e.Record({canister_id:_}),Y=e.Record({canister_id:_}),pe=e.Record({canister_id:_}),Z=e.Variant({secp256k1:e.Null}),me=e.Record({key_id:e.Record({name:e.Text,curve:Z}),canister_id:e.Opt(_),derivation_path:e.Vec(e.Vec(e.Nat8))}),Ze=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),Ie=e.Record({canister_id:_}),re=e.Record({idx:e.Nat64,timestamp_nanos:e.Nat64,content:e.Vec(e.Nat8)}),De=e.Record({canister_log_records:e.Vec(re)}),Pe=e.Record({value:e.Text,name:e.Text}),_e=e.Record({status:e.Nat,body:e.Vec(e.Nat8),headers:e.Vec(Pe)}),Le=e.Record({url:e.Text,method:e.Variant({get:e.Null,head:e.Null,post:e.Null}),max_response_bytes:e.Opt(e.Nat64),body:e.Opt(e.Vec(e.Nat8)),transform:e.Opt(e.Record({function:e.Func([e.Record({context:e.Vec(e.Nat8),response:_e})],[_e],["query"]),context:e.Vec(e.Nat8)})),headers:e.Vec(Pe)}),fe=e.Variant({reinstall:e.Null,upgrade:e.Opt(e.Record({wasm_memory_persistence:e.Opt(e.Variant({keep:e.Null,replace:e.Null})),skip_pre_upgrade:e.Opt(e.Bool)})),install:e.Null}),he=e.Record({hash:e.Vec(e.Nat8)}),et=e.Record({arg:e.Vec(e.Nat8),wasm_module_hash:e.Vec(e.Nat8),mode:fe,chunk_hashes_list:e.Vec(he),target_canister:_,store_canister:e.Opt(_),sender_canister_version:e.Opt(e.Nat64)}),tt=e.Vec(e.Nat8),sn=e.Record({arg:e.Vec(e.Nat8),wasm_module:tt,mode:fe,canister_id:_,sender_canister_version:e.Opt(e.Nat64)}),an=e.Record({start_at_timestamp_nanos:e.Nat64,subnet_id:e.Principal}),cn=e.Record({num_block_failures_total:e.Nat64,node_id:e.Principal,num_blocks_proposed_total:e.Nat64}),ln=e.Vec(e.Record({timestamp_nanos:e.Nat64,node_metrics:e.Vec(cn)})),un=e.Record({settings:e.Opt($),specified_id:e.Opt(_),amount:e.Opt(e.Nat),sender_canister_version:e.Opt(e.Nat64)}),dn=e.Record({canister_id:_}),pn=e.Record({canister_id:_,amount:e.Nat}),mn=e.Vec(e.Nat8),Bt=e.Variant({ed25519:e.Null,bip340secp256k1:e.Null}),_n=e.Record({key_id:e.Record({algorithm:Bt,name:e.Text}),canister_id:e.Opt(_),derivation_path:e.Vec(e.Vec(e.Nat8))}),fn=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),hn=e.Record({key_id:e.Record({name:e.Text,curve:Z}),derivation_path:e.Vec(e.Vec(e.Nat8)),message_hash:e.Vec(e.Nat8)}),yn=e.Record({signature:e.Vec(e.Nat8)}),gn=e.Record({key_id:e.Record({algorithm:Bt,name:e.Text}),derivation_path:e.Vec(e.Vec(e.Nat8)),message:e.Vec(e.Nat8)}),Tn=e.Record({signature:e.Vec(e.Nat8)}),bn=e.Record({canister_id:_}),wn=e.Record({canister_id:_}),xn=e.Record({canister_id:_}),vn=e.Vec(he),Nn=e.Record({canister_id:_,sender_canister_version:e.Opt(e.Nat64)}),Pn=e.Record({canister_id:e.Principal,settings:$,sender_canister_version:e.Opt(e.Nat64)}),Vn=e.Record({chunk:e.Vec(e.Nat8),canister_id:e.Principal}),Rn=he;return e.Service({bitcoin_get_balance:e.Func([n],[i],[]),bitcoin_get_balance_query:e.Func([a],[u],["query"]),bitcoin_get_current_fee_percentiles:e.Func([p],[y],[]),bitcoin_get_utxos:e.Func([g],[T],[]),bitcoin_get_utxos_query:e.Func([v],[N],["query"]),bitcoin_send_transaction:e.Func([w],[],[]),canister_info:e.Func([C],[F],[]),canister_status:e.Func([B],[J],[]),clear_chunk_store:e.Func([z],[],[]),create_canister:e.Func([U],[j],[]),delete_canister:e.Func([Y],[],[]),deposit_cycles:e.Func([pe],[],[]),ecdsa_public_key:e.Func([me],[Ze],[]),fetch_canister_logs:e.Func([Ie],[De],["query"]),http_request:e.Func([Le],[_e],[]),install_chunked_code:e.Func([et],[],[]),install_code:e.Func([sn],[],[]),node_metrics_history:e.Func([an],[ln],[]),provisional_create_canister_with_cycles:e.Func([un],[dn],[]),provisional_top_up_canister:e.Func([pn],[],[]),raw_rand:e.Func([],[mn],[]),schnorr_public_key:e.Func([_n],[fn],[]),sign_with_ecdsa:e.Func([hn],[yn],[]),sign_with_schnorr:e.Func([gn],[Tn],[]),start_canister:e.Func([bn],[],[]),stop_canister:e.Func([wn],[],[]),stored_chunks:e.Func([xn],[vn],[]),uninstall_code:e.Func([Nn],[],[]),update_settings:e.Func([Pn],[],[]),upload_chunk:e.Func([Vn],[Rn],[])})};var zt=({IDL:e})=>{let t=e.Record({updated_at:e.Nat64,orbiter_id:e.Principal,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),r=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,satellite_id:e.Principal}),n=e.Record({cycles:e.Nat,destination_id:e.Principal}),o=e.Variant({Write:e.Null,Admin:e.Null}),i=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:o,expires_at:e.Opt(e.Nat64)}),a=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),u=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),p=e.Record({status:a,memory_size:e.Nat,cycles:e.Nat,settings:u,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),d=e.Record({id:e.Principal,status:p,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),status_at:e.Nat64}),y=e.Variant({Ok:d,Err:e.Text}),g=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:o,expires_at:e.Opt(e.Nat64)}),b=e.Record({enabled:e.Bool,cycles_threshold:e.Opt(e.Nat64)}),l=e.Record({mission_control_cycles_threshold:e.Opt(e.Nat64),orbiters:e.Vec(e.Tuple(e.Principal,b)),satellites:e.Vec(e.Tuple(e.Principal,b)),cycles_threshold:e.Opt(e.Nat64)}),m=e.Record({orbiters:e.Opt(e.Vec(y)),satellites:e.Opt(e.Vec(y)),mission_control:y}),T=e.Record({e8s:e.Nat64});return e.Service({add_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),add_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),create_orbiter:e.Func([e.Opt(e.Text)],[t],[]),create_satellite:e.Func([e.Text],[r],[]),del_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),del_orbiter:e.Func([e.Principal,e.Nat],[],[]),del_orbiters_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),del_satellite:e.Func([e.Principal,e.Nat],[],[]),del_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),deposit_cycles:e.Func([n],[],[]),get_user:e.Func([],[e.Principal],["query"]),list_mission_control_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,i))],["query"]),list_mission_control_statuses:e.Func([],[e.Vec(e.Tuple(e.Nat64,y))],["query"]),list_orbiter_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,y)))],["query"]),list_orbiters:e.Func([],[e.Vec(e.Tuple(e.Principal,t))],["query"]),list_satellite_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,y)))],["query"]),list_satellites:e.Func([],[e.Vec(e.Tuple(e.Principal,r))],["query"]),remove_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),remove_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),set_metadata:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),set_mission_control_controllers:e.Func([e.Vec(e.Principal),g],[],[]),set_orbiter:e.Func([e.Principal,e.Opt(e.Text)],[t],[]),set_orbiter_metadata:e.Func([e.Principal,e.Vec(e.Tuple(e.Text,e.Text))],[t],[]),set_orbiters_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal),g],[],[]),set_satellite:e.Func([e.Principal,e.Opt(e.Text)],[r],[]),set_satellite_metadata:e.Func([e.Principal,e.Vec(e.Tuple(e.Text,e.Text))],[r],[]),set_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal),g],[],[]),status:e.Func([l],[m],[]),top_up:e.Func([e.Principal,T],[],[]),unset_orbiter:e.Func([e.Principal],[],[]),unset_satellite:e.Func([e.Principal],[],[]),version:e.Func([],[e.Text],["query"])})};var Ht=({IDL:e})=>{let t=e.Record({controllers:e.Vec(e.Principal)}),r=e.Variant({Write:e.Null,Admin:e.Null}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:r,expires_at:e.Opt(e.Nat64)}),o=e.Record({version:e.Opt(e.Nat64)}),i=e.Record({cycles:e.Nat,destination_id:e.Principal}),a=e.Record({to:e.Opt(e.Nat64),from:e.Opt(e.Nat64),satellite_id:e.Opt(e.Principal)}),u=e.Record({key:e.Text,collected_at:e.Nat64}),p=e.Record({inner_height:e.Nat16,inner_width:e.Nat16}),d=e.Record({title:e.Text,updated_at:e.Nat64,referrer:e.Opt(e.Text),time_zone:e.Text,session_id:e.Text,href:e.Text,created_at:e.Nat64,satellite_id:e.Principal,device:p,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),y=e.Record({safari:e.Float64,opera:e.Float64,others:e.Float64,firefox:e.Float64,chrome:e.Float64}),g=e.Record({desktop:e.Float64,others:e.Float64,mobile:e.Float64}),b=e.Record({browsers:y,devices:g}),l=e.Record({day:e.Nat8,month:e.Nat8,year:e.Int32}),m=e.Record({bounce_rate:e.Float64,average_page_views_per_session:e.Float64,daily_total_page_views:e.Vec(e.Tuple(l,e.Nat32)),total_page_views:e.Nat32,unique_page_views:e.Nat64,unique_sessions:e.Nat64}),T=e.Record({referrers:e.Vec(e.Tuple(e.Text,e.Nat32)),pages:e.Vec(e.Tuple(e.Text,e.Nat32))}),v=e.Variant({Navigate:e.Null,Restore:e.Null,Reload:e.Null,BackForward:e.Null,BackForwardCache:e.Null,Prerender:e.Null}),N=e.Record({id:e.Text,value:e.Float64,navigation_type:e.Opt(v),delta:e.Float64}),w=e.Variant({WebVitalsMetric:N}),_=e.Variant({CLS:e.Null,FCP:e.Null,INP:e.Null,LCP:e.Null,TTFB:e.Null}),C=e.Record({updated_at:e.Nat64,session_id:e.Text,data:w,href:e.Text,metric_name:_,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),P=e.Record({cls:e.Opt(e.Float64),fcp:e.Opt(e.Float64),inp:e.Opt(e.Float64),lcp:e.Opt(e.Float64),ttfb:e.Opt(e.Float64)}),S=e.Record({overall:P,pages:e.Vec(e.Tuple(e.Text,P))}),V=e.Record({updated_at:e.Nat64,session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),F=e.Record({total:e.Vec(e.Tuple(e.Text,e.Nat32))}),B=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),enabled:e.Bool}),E=e.Record({stable:e.Nat64,heap:e.Nat64}),G=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:r,expires_at:e.Opt(e.Nat64)}),J=e.Record({controller:G,controllers:e.Vec(e.Principal)}),z=e.Record({title:e.Text,updated_at:e.Opt(e.Nat64),referrer:e.Opt(e.Text),time_zone:e.Text,session_id:e.Text,href:e.Text,satellite_id:e.Principal,device:p,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),$=e.Variant({Ok:d,Err:e.Text}),U=e.Variant({Ok:e.Null,Err:e.Vec(e.Tuple(u,e.Text))}),j=e.Record({session_id:e.Text,data:w,href:e.Text,metric_name:_,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),Y=e.Variant({Ok:C,Err:e.Text}),pe=e.Record({version:e.Opt(e.Nat64),enabled:e.Bool}),Z=e.Record({updated_at:e.Opt(e.Nat64),session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),me=e.Variant({Ok:V,Err:e.Text});return e.Service({del_controllers:e.Func([t],[e.Vec(e.Tuple(e.Principal,n))],[]),del_satellite_config:e.Func([e.Principal,o],[],[]),deposit_cycles:e.Func([i],[],[]),get_page_views:e.Func([a],[e.Vec(e.Tuple(u,d))],["query"]),get_page_views_analytics_clients:e.Func([a],[b],["query"]),get_page_views_analytics_metrics:e.Func([a],[m],["query"]),get_page_views_analytics_top_10:e.Func([a],[T],["query"]),get_performance_metrics:e.Func([a],[e.Vec(e.Tuple(u,C))],["query"]),get_performance_metrics_analytics_web_vitals:e.Func([a],[S],["query"]),get_track_events:e.Func([a],[e.Vec(e.Tuple(u,V))],["query"]),get_track_events_analytics:e.Func([a],[F],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_satellite_configs:e.Func([],[e.Vec(e.Tuple(e.Principal,B))],["query"]),memory_size:e.Func([],[E],["query"]),set_controllers:e.Func([J],[e.Vec(e.Tuple(e.Principal,n))],[]),set_page_view:e.Func([u,z],[$],[]),set_page_views:e.Func([e.Vec(e.Tuple(u,z))],[U],[]),set_performance_metric:e.Func([u,j],[Y],[]),set_performance_metrics:e.Func([e.Vec(e.Tuple(u,j))],[U],[]),set_satellite_configs:e.Func([e.Vec(e.Tuple(e.Principal,pe))],[e.Vec(e.Tuple(e.Principal,B))],[]),set_track_event:e.Func([u,Z],[me],[]),set_track_events:e.Func([e.Vec(e.Tuple(u,Z))],[U],[]),version:e.Func([],[e.Text],["query"])})};var Kt=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({controllers:e.Vec(e.Principal)}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,expires_at:e.Opt(e.Nat64)}),o=e.Record({updated_at:e.Opt(e.Nat64)}),i=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),a=e.Record({storage:i}),u=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),p=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),d=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),y=e.Variant({Callback:e.Record({token:d,callback:e.Func([],[],[])})}),g=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(y),status_code:e.Nat16}),b=e.Record({token:e.Opt(d),body:e.Vec(e.Nat8)}),l=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),m=e.Record({batch_id:e.Nat}),T=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),v=e.Record({field:T,desc:e.Bool}),N=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),w=e.Record({order:e.Opt(v),owner:e.Opt(e.Principal),matcher:e.Opt(e.Text),paginate:e.Opt(N)}),_=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),C=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),P=e.Record({key:_,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,C)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),S=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,P))}),V=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),F=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,u))}),B=e.Variant({Db:e.Null,Storage:e.Null}),E=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),G=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:E,created_at:e.Nat64,write:E}),J=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),z=e.Record({controller:J,controllers:e.Vec(e.Principal)}),$=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),U=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:E,write:E}),j=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),Y=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_controllers:e.Func([r],[e.Vec(e.Tuple(e.Principal,n))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,o],[],[]),get_config:e.Func([],[a],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(u)],["query"]),http_request:e.Func([p],[g],["query"]),http_request_streaming_callback:e.Func([d],[b],["query"]),init_asset_upload:e.Func([l],[m],[]),list_assets:e.Func([e.Opt(e.Text),w],[S],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,V))],["query"]),list_docs:e.Func([e.Text,w],[F],["query"]),list_rules:e.Func([B],[e.Vec(e.Tuple(e.Text,G))],["query"]),set_config:e.Func([a],[],[]),set_controllers:e.Func([z],[e.Vec(e.Tuple(e.Principal,n))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,$],[u],[]),set_rule:e.Func([B,e.Text,U],[],[]),upload_asset_chunk:e.Func([j],[Y],[]),version:e.Func([],[e.Text],["query"])})};var Wt=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({controllers:e.Vec(e.Principal)}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,expires_at:e.Opt(e.Nat64)}),o=e.Record({updated_at:e.Opt(e.Nat64)}),i=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),a=e.Record({storage:i}),u=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),p=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),d=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),y=e.Variant({Callback:e.Record({token:d,callback:e.Func([],[],[])})}),g=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(y),status_code:e.Nat16}),b=e.Record({token:e.Opt(d),body:e.Vec(e.Nat8)}),l=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),m=e.Record({batch_id:e.Nat}),T=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),v=e.Record({field:T,desc:e.Bool}),N=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),w=e.Record({order:e.Opt(v),matcher:e.Opt(e.Text),paginate:e.Opt(N)}),_=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),C=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),P=e.Record({key:_,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,C)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),S=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,P))}),V=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),F=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,u))}),B=e.Variant({Db:e.Null,Storage:e.Null}),E=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),G=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:E,created_at:e.Nat64,write:E}),J=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),z=e.Record({controller:J,controllers:e.Vec(e.Principal)}),$=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),U=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:E,write:E}),j=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),Y=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_controllers:e.Func([r],[e.Vec(e.Tuple(e.Principal,n))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,o],[],[]),get_config:e.Func([],[a],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(u)],["query"]),http_request:e.Func([p],[g],["query"]),http_request_streaming_callback:e.Func([d],[b],["query"]),init_asset_upload:e.Func([l],[m],[]),list_assets:e.Func([e.Opt(e.Text),w],[S],["query"]),list_controllers:e.Func([],[e.Vec(e.Principal)],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,V))],["query"]),list_docs:e.Func([e.Text,w],[F],["query"]),list_rules:e.Func([B],[e.Vec(e.Tuple(e.Text,G))],["query"]),set_config:e.Func([a],[],[]),set_controllers:e.Func([z],[e.Vec(e.Tuple(e.Principal,n))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,$],[u],[]),set_rule:e.Func([B,e.Text,U],[],[]),upload_asset_chunk:e.Func([j],[Y],[]),version:e.Func([],[e.Text],["query"])})};var Gt=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({controllers:e.Vec(e.Principal)}),n=e.Variant({Write:e.Null,Admin:e.Null}),o=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:n,expires_at:e.Opt(e.Nat64)}),i=e.Record({version:e.Opt(e.Nat64)}),a=e.Variant({Db:e.Null,Storage:e.Null}),u=e.Record({version:e.Opt(e.Nat64)}),p=e.Record({cycles:e.Nat,destination_id:e.Principal}),d=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),y=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),g=e.Record({key:d,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,y)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),b=e.Record({derivation_origin:e.Opt(e.Text)}),l=e.Record({internet_identity:e.Opt(b)}),m=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),T=e.Record({max_memory_size:e.Opt(m)}),v=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),N=e.Variant({Deny:e.Null,Allow:e.Null}),w=e.Record({status_code:e.Nat16,location:e.Text}),_=e.Record({iframe:e.Opt(v),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),max_memory_size:e.Opt(m),raw_access:e.Opt(N),redirects:e.Opt(e.Vec(e.Tuple(e.Text,w)))}),C=e.Record({db:e.Opt(T),authentication:e.Opt(l),storage:_}),P=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),S=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),certificate_version:e.Opt(e.Nat16)}),V=e.Variant({Heap:e.Null,Stable:e.Null}),F=e.Record({memory:V,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),B=e.Variant({Callback:e.Record({token:F,callback:e.Func([],[],["query"])})}),E=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(B),status_code:e.Nat16}),G=e.Record({token:e.Opt(F),body:e.Vec(e.Nat8)}),J=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),z=e.Record({batch_id:e.Nat}),$=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),U=e.Record({field:$,desc:e.Bool}),j=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),Y=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(j),description:e.Opt(e.Text),created_at:e.Opt(j)}),pe=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),Z=e.Record({order:e.Opt(U),owner:e.Opt(e.Principal),matcher:e.Opt(Y),paginate:e.Opt(pe)}),me=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,g)),items_length:e.Nat64}),Ze=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),Ie=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,P)),items_length:e.Nat64}),re=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),De=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(V),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:re,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),write:re}),Pe=e.Record({stable:e.Nat64,heap:e.Nat64}),_e=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:n,expires_at:e.Opt(e.Nat64)}),Le=e.Record({controller:_e,controllers:e.Vec(e.Principal)}),fe=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),he=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(V),max_size:e.Opt(e.Nat),read:re,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),write:re}),et=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),tt=e.Record({chunk_id:e.Nat});return e.Service({build_version:e.Func([],[e.Text],["query"]),commit_asset_upload:e.Func([t],[],[]),count_assets:e.Func([e.Text],[e.Nat64],["query"]),count_docs:e.Func([e.Text],[e.Nat64],["query"]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([r],[e.Vec(e.Tuple(e.Principal,o))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,i],[],[]),del_docs:e.Func([e.Text],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,i))],[],[]),del_rule:e.Func([a,e.Text,u],[],[]),deposit_cycles:e.Func([p],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(g)],["query"]),get_auth_config:e.Func([],[e.Opt(l)],["query"]),get_config:e.Func([],[C],[]),get_db_config:e.Func([],[e.Opt(T)],["query"]),get_doc:e.Func([e.Text,e.Text],[e.Opt(P)],["query"]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(g)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(P)))],["query"]),get_storage_config:e.Func([],[_],["query"]),http_request:e.Func([S],[E],["query"]),http_request_streaming_callback:e.Func([F],[G],["query"]),init_asset_upload:e.Func([J],[z],[]),list_assets:e.Func([e.Text,Z],[me],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,o))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Ze))],["query"]),list_docs:e.Func([e.Text,Z],[Ie],["query"]),list_rules:e.Func([a],[e.Vec(e.Tuple(e.Text,De))],["query"]),memory_size:e.Func([],[Pe],["query"]),set_auth_config:e.Func([l],[],[]),set_controllers:e.Func([Le],[e.Vec(e.Tuple(e.Principal,o))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([T],[],[]),set_doc:e.Func([e.Text,e.Text,fe],[P],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,fe))],[e.Vec(e.Tuple(e.Text,P))],[]),set_rule:e.Func([a,e.Text,he],[],[]),set_storage_config:e.Func([_],[],[]),upload_asset_chunk:e.Func([et],[tt],[]),version:e.Func([],[e.Text],["query"])})};var Qt=async({satelliteId:e,...t})=>ye({canisterId:e,...t,idlFactory:Wt}),O=async({satelliteId:e,...t})=>ye({canisterId:e,...t,idlFactory:Gt}),Xt=async({satelliteId:e,...t})=>ye({canisterId:e,...t,idlFactory:Kt}),ne=async({missionControlId:e,...t})=>ye({canisterId:e,...t,idlFactory:zt}),Ve=async({orbiterId:e,...t})=>ye({canisterId:e,...t,idlFactory:Ht}),ye=async({canisterId:e,idlFactory:t,...r})=>{if(Mn(e))throw new Error("No canister ID provided.");return rt({canisterId:e,idlFactory:t,...r})},Zt=Yt.fromText("aaaaa-aa"),Jt=(e,t,r)=>{let n=t[0],o=Zt;return n&&typeof n=="object"&&n.canister_id&&(o=Yt.from(n.canister_id)),{effectiveCanisterId:o}},It=e=>rt({canisterId:Zt.toText(),config:{callTransform:Jt,queryTransform:Jt},idlFactory:jt,...e});var ee=async({actor:e,code:t})=>{let{install_code:r}=await It(e);return r({...t,sender_canister_version:[]})},Dt=async({canisterId:e,path:t,...r})=>{Un(e,"A canister ID must be provided to request its status.");let n=await nt(r);return(await qn.request({canisterId:$n.from(e),agent:n,paths:[{kind:"metadata",key:t,path:t,decodeStrategy:"utf-8"}]})).get(t)};var Lt=async({missionControl:e})=>(await ne(e)).version(),er=async({missionControl:e})=>(await ne(e)).get_user(),tr=async({missionControl:e})=>(await ne(e)).list_mission_control_controllers(),rr=async({missionControl:e,satelliteIds:t,controllerIds:r,controller:n})=>(await ne(e)).set_satellites_controllers(t,r,n),nr=async({missionControl:e,controllerIds:t,controller:r})=>(await ne(e)).set_mission_control_controllers(t,r);import{Principal as jn}from"@dfinity/principal";import{nonNullish as zn,toNullable as Hn}from"@junobuild/utils";var ot=({controllerId:e,profile:t})=>({controllerIds:[jn.fromText(e)],controller:Kn(t)}),Kn=e=>({metadata:zn(e)&&e!==""?[["profile",e]]:[],expires_at:Hn(void 0),scope:{Admin:null}});var L=$t(Vt(),1),Nr=e=>L.IDL.encode([L.IDL.Record({user:L.IDL.Principal})],[{user:e}]),Ye=e=>L.IDL.encode([L.IDL.Record({controllers:L.IDL.Vec(L.IDL.Principal)})],[{controllers:e.map(([t,r])=>t)}]);var hi=async e=>Lt(e),yi=async({missionControl:e,wasm_module:t})=>{let r=await er({missionControl:e}),{missionControlId:n,...o}=e;if(!n)throw new Error("No mission control principal defined.");let i=Nr(r);await ee({actor:o,code:{canister_id:go.fromText(n),arg:new Uint8Array(i),wasm_module:t,mode:{upgrade:[{skip_pre_upgrade:[!1],wasm_memory_persistence:[{replace:null}]}]}}})},gi=async({controllerId:e,profile:t,...r})=>rr({...r,...ot({controllerId:e,profile:t})}),Ti=async({controllerId:e,profile:t,...r})=>nr({...r,...ot({controllerId:e,profile:t})}),bi=e=>tr(e);import{Principal as To}from"@dfinity/principal";var Pr=async({orbiter:e})=>(await Ve(e)).version(),Rt=async({orbiter:e})=>(await Ve(e)).list_controllers(),Vr=async({orbiter:e})=>{let{memory_size:t}=await Ve(e);return t()};var Ci=async e=>Pr(e),Fi=async({orbiter:e,wasm_module:t,reset:r=!1})=>{let{orbiterId:n,...o}=e;if(!n)throw new Error("No orbiter principal defined.");let i=await Rt({orbiter:e}),a=Ye(i);await ee({actor:o,code:{canister_id:To.fromText(n),arg:new Uint8Array(a),wasm_module:t,mode:r?{reinstall:null}:{upgrade:[{skip_pre_upgrade:[!1],wasm_memory_persistence:[{replace:null}]}]}}})},Si=e=>Vr(e),Oi=e=>Rt(e);import{major as Rr,minor as Cr,patch as Fr}from"semver";var ki=({currentVersion:e,selectedVersion:t})=>{let r=Rr(e),n=Rr(t),o=Cr(e),i=Cr(t),a=Fr(e),u=Fr(t);return r<n-1||o<i-1||a<u-1?{canUpgrade:!1}:{canUpgrade:!0}};var Ne=$t(Vt(),1);import{Principal as on}from"@dfinity/principal";import{fromNullable as de,isNullish as kt,nonNullish as Xe}from"@junobuild/utils";import{toNullable as bo}from"@junobuild/utils";var Sr=async({config:e,satellite:t})=>{let{set_storage_config:r}=await O(t);return r(e)},Or=async({config:e,satellite:t})=>{let{set_db_config:r}=await O(t);return r(e)},Ar=async({config:e,satellite:t})=>{let{set_auth_config:r}=await O(t);return r(e)};var Er=async({satellite:e})=>{let{get_auth_config:t}=await O(e);return t()},kr=async({satellite:e,type:t})=>(await O(e)).list_rules(t),Br=async({type:e,collection:t,rule:r,satellite:n})=>(await O(n)).set_rule(e,t,r),Mr=async({satellite:e})=>{let{version:t}=await O(e);return t()},qr=async({satellite:e})=>{let{build_version:t}=await O(e);return t()},$r=async({satellite:e})=>(await Qt(e)).list_controllers(),Ct=async({satellite:e})=>(await Xt(e)).list_controllers(),Ft=async({satellite:e})=>(await O(e)).list_controllers(),Ur=async({satellite:e})=>{let{list_custom_domains:t}=await O(e);return t()},jr=async({satellite:e,domainName:t,boundaryNodesId:r})=>{let{set_custom_domain:n}=await O(e);await n(t,bo(r))},zr=async({satellite:e})=>{let{memory_size:t}=await O(e);return t()},Hr=async({collection:e,satellite:t})=>{let{count_docs:r}=await O(t);return r(e)},Kr=async({collection:e,satellite:t})=>{let{count_assets:r}=await O(t);return r(e)},Wr=async({collection:e,satellite:t})=>{let{del_docs:r}=await O(t);return r(e)},Gr=async({collection:e,satellite:t})=>{let{del_assets:r}=await O(t);return r(e)},Jr=async({args:e,satellite:t})=>{let{set_controllers:r}=await O(t);return r(e)};import{nonNullish as wo,toNullable as St}from"@junobuild/utils";var Ot=e=>St(wo(e)?{heap:St(e.heap),stable:St(e.stable)}:void 0);import{fromNullable as ve,nonNullish as ue,toNullable as Qe}from"@junobuild/utils";var Yr={Db:null},Qr={Storage:null},Xr={Public:null},Zr={Private:null},Ir={Managed:null},Dr={Controllers:null},At={Heap:null},Lr={Stable:null};var Et=e=>e==="storage"?Qr:Yr,rn=({read:e,write:t,memory:r,maxSize:n,maxCapacity:o,version:i,mutablePermissions:a})=>({read:tn(e),write:tn(t),memory:ue(r)?[xo(r)]:[],version:Qe(i),max_size:Qe(ue(n)&&n>0?BigInt(n):void 0),max_capacity:Qe(ue(o)&&o>0?o:void 0),mutable_permissions:Qe(a)}),nn=([e,t])=>{let{read:r,write:n,updated_at:o,created_at:i,max_size:a,max_capacity:u,memory:p,mutable_permissions:d,version:y}=t,g=a?.[0]??0n>0n?Number(ve(a)):void 0,b=u?.[0]??!1?ve(u):void 0,l=ve(y);return{collection:e,read:en(r),write:en(n),memory:vo(ve(p)??At),updatedAt:o,createdAt:i,...ue(l)&&{version:l},...ue(g)&&{maxSize:g},...ue(b)&&{maxCapacity:b},mutablePermissions:ve(d)??!0}},en=e=>"Public"in e?"public":"Private"in e?"private":"Managed"in e?"managed":"controllers",tn=e=>{switch(e){case"public":return Xr;case"private":return Zr;case"managed":return Ir;default:return Dr}},xo=e=>{switch(e.toLowerCase()){case"heap":return At;default:return Lr}},vo=e=>"Heap"in e?"heap":"stable";var Di=async({config:{headers:e,rewrites:t,redirects:r,iframe:n,rawAccess:o,maxMemorySize:i},satellite:a})=>{let u=(e??[]).map(({source:b,headers:l})=>[b,l]),p=(t??[]).map(({source:b,destination:l})=>[b,l]),d=(r??[]).map(({source:b,location:l,code:m})=>[b,{status_code:m,location:l}]);return Sr({satellite:a,config:{headers:u,rewrites:p,redirects:[d],iframe:[n==="same-origin"?{SameOrigin:null}:n==="allow-any"?{AllowAny:null}:{Deny:null}],raw_access:[o===!0?{Allow:null}:{Deny:null}],max_memory_size:Ot(i)}})},Li=async({config:{maxMemorySize:e},...t})=>{await Or({config:{max_memory_size:Ot(e)},...t})},es=async({config:{internetIdentity:e},...t})=>{await Ar({config:{internet_identity:kt(e?.derivationOrigin)?[]:[{derivation_origin:[e.derivationOrigin]}]},...t})},ts=async({satellite:e})=>{let t=de(await Er({satellite:e}));if(kt(t))return;let r=de(t.internet_identity??[]);return{...Xe(r)&&{internetIdentity:{...Xe(de(r.derivation_origin))&&{derivationOrigin:de(r.derivation_origin)}}}}},rs=async({type:e,satellite:t})=>(await kr({satellite:t,type:Et(e)})).map(n=>nn(n)),ns=async({rule:{collection:e,...t},type:r,satellite:n})=>Br({type:Et(r),rule:rn(t),satellite:n,collection:e}),os=e=>Mr(e),is=e=>qr(e),ss=async({satellite:{satelliteId:e,...t}})=>{let r=await Dt({...t,canisterId:e,path:"juno:build"});return Xe(r)&&["stock","extended"].includes(r)?r:void 0},as=async({satellite:e,wasm_module:t,deprecated:r,deprecatedNoScope:n,reset:o=!1})=>{let{satelliteId:i,...a}=e;if(kt(i))throw new Error("No satellite principal defined.");if(r){let y=await $r({satellite:e}),g=Ne.IDL.encode([Ne.IDL.Record({controllers:Ne.IDL.Vec(Ne.IDL.Principal)})],[{controllers:y}]);await ee({actor:a,code:{canister_id:on.fromText(i),arg:new Uint8Array(g),wasm_module:t,mode:o?{reinstall:null}:{upgrade:[{skip_pre_upgrade:[!1],wasm_memory_persistence:[{replace:null}]}]}}});return}let p=await(n?Ct:Ft)({satellite:e}),d=Ye(p);await ee({actor:a,code:{canister_id:on.fromText(i),arg:new Uint8Array(d),wasm_module:t,mode:o?{reinstall:null}:{upgrade:[{skip_pre_upgrade:[!1],wasm_memory_persistence:[{replace:null}]}]}}})},cs=async({satellite:e})=>(await Ur({satellite:e})).map(([r,n])=>{let o=de(n.version);return{domain:r,bn_id:de(n.bn_id),created_at:n.created_at,updated_at:n.updated_at,...Xe(o)&&{version:o}}}),ls=async({satellite:e,domains:t})=>Promise.all(t.map(({domain:r,bn_id:n})=>jr({satellite:e,domainName:r,boundaryNodesId:n}))),us=e=>zr(e),ds=async e=>Hr(e),ps=async e=>Wr(e),ms=async e=>Kr(e),_s=async e=>Gr(e),fs=({deprecatedNoScope:e,...t})=>(e===!0?Ct:Ft)(t),hs=e=>Jr(e);export{ki as checkUpgradeVersion,ms as countAssets,ds as countDocs,_s as deleteAssets,ps as deleteDocs,ts as getAuthConfig,cs as listCustomDomains,bi as listMissionControlControllers,Oi as listOrbiterControllers,rs as listRules,fs as listSatelliteControllers,hi as missionControlVersion,Si as orbiterMemorySize,Ci as orbiterVersion,ss as satelliteBuildType,is as satelliteBuildVersion,us as satelliteMemorySize,os as satelliteVersion,es as setAuthConfig,ls as setCustomDomains,Li as setDatastoreConfig,Ti as setMissionControlController,ns as setRule,hs as setSatelliteControllers,gi as setSatellitesController,Di as setStorageConfig,yi as upgradeMissionControl,Fi as upgradeOrbiter,as as upgradeSatellite};
15
+ `)}return p.encodeValue(d)}));return(0,y.concat)(n,o,i,a,u)}s.encode=no;function oo(e,t){let r=new y.PipeArrayBuffer(t);if(t.byteLength<Ee.length)throw new Error("Message length smaller than magic number");let n=(0,c.safeRead)(r,Ee.length),o=new TextDecoder().decode(n);if(o!==Ee)throw new Error("Wrong magic number: "+JSON.stringify(o));function i(l){let m=[],b=Number((0,c.lebDecode)(l));for(let w=0;w<b;w++){let _=Number((0,c.slebDecode)(l));switch(_){case-18:case-19:{let P=Number((0,c.slebDecode)(l));m.push([_,P]);break}case-20:case-21:{let P=[],R=Number((0,c.lebDecode)(l)),F;for(;R--;){let C=Number((0,c.lebDecode)(l));if(C>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof F=="number"&&F>=C)throw new Error("field id collision or not sorted");F=C;let S=Number((0,c.slebDecode)(l));P.push([C,S])}m.push([_,P]);break}case-22:{let P=[],R=Number((0,c.lebDecode)(l));for(;R--;)P.push(Number((0,c.slebDecode)(l)));let F=[],C=Number((0,c.lebDecode)(l));for(;C--;)F.push(Number((0,c.slebDecode)(l)));let S=[],k=Number((0,c.lebDecode)(l));for(;k--;)switch(Number((0,c.lebDecode)(l))){case 1:{S.push("query");break}case 2:{S.push("oneway");break}case 3:{S.push("composite_query");break}default:throw new Error("unknown annotation")}m.push([_,[P,F,S]]);break}case-23:{let P=Number((0,c.lebDecode)(l)),R=[];for(;P--;){let F=Number((0,c.lebDecode)(l)),C=new TextDecoder().decode((0,c.safeRead)(l,F)),S=(0,c.slebDecode)(l);R.push([C,S])}m.push([_,R]);break}default:throw new Error("Illegal op_code: "+_)}}let N=[],x=Number((0,c.lebDecode)(l));for(let w=0;w<x;w++)N.push(Number((0,c.slebDecode)(l)));return[m,N]}let[a,u]=i(r);if(u.length<e.length)throw new Error("Wrong number of return values");let p=a.map(l=>hr());function d(l){if(l<-24)throw new Error("future value not supported");if(l<0)switch(l){case-1:return s.Null;case-2:return s.Bool;case-3:return s.Nat;case-4:return s.Int;case-5:return s.Nat8;case-6:return s.Nat16;case-7:return s.Nat32;case-8:return s.Nat64;case-9:return s.Int8;case-10:return s.Int16;case-11:return s.Int32;case-12:return s.Int64;case-13:return s.Float32;case-14:return s.Float64;case-15:return s.Text;case-16:return s.Reserved;case-17:return s.Empty;case-24:return s.Principal;default:throw new Error("Illegal op_code: "+l)}if(l>=a.length)throw new Error("type index out of range");return p[l]}function h(l){switch(l[0]){case-19:{let m=d(l[1]);return pr(m)}case-18:{let m=d(l[1]);return mr(m)}case-20:{let m={};for(let[x,w]of l[1]){let _=`_${x}_`;m[_]=d(w)}let b=_r(m),N=b.tryAsTuple();return Array.isArray(N)?dr(...N):b}case-21:{let m={};for(let[b,N]of l[1]){let x=`_${b}_`;m[x]=d(N)}return fr(m)}case-22:{let[m,b,N]=l[1];return yr(m.map(x=>d(x)),b.map(x=>d(x)),N)}case-23:{let m={},b=l[1];for(let[N,x]of b){let w=d(x);if(w instanceof Z&&(w=w.getType()),!(w instanceof xe))throw new Error("Illegal service definition: services can only contain functions");m[N]=w}return gr(m)}default:throw new Error("Illegal op_code: "+l[0])}}a.forEach((l,m)=>{if(l[0]===-22){let b=h(l);p[m].fill(b)}}),a.forEach((l,m)=>{if(l[0]!==-22){let b=h(l);p[m].fill(b)}});let g=u.map(l=>d(l)),T=e.map((l,m)=>l.decodeValue(r,g[m]));for(let l=e.length;l<g.length;l++)g[l].decodeValue(r,g[l]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return T}s.decode=oo;s.Empty=new ke;s.Reserved=new ae;s.Unknown=new Be;s.Bool=new Me;s.Null=new qe;s.Text=new $e;s.Int=new Ue;s.Nat=new je;s.Float32=new be(32);s.Float64=new be(64);s.Int8=new X(8);s.Int16=new X(16);s.Int32=new X(32);s.Int64=new X(64);s.Nat8=new W(8);s.Nat16=new W(16);s.Nat32=new W(32);s.Nat64=new W(64);s.Principal=new We;function dr(...e){return new He(e)}s.Tuple=dr;function pr(e){return new ze(e)}s.Vec=pr;function mr(e){return new ce(e)}s.Opt=mr;function _r(e){return new we(e)}s.Record=_r;function fr(e){return new Ke(e)}s.Variant=fr;function hr(){return new Z}s.Rec=hr;function yr(e,t,r=[]){return new xe(e,t,r)}s.Func=yr;function gr(e){return new Ge(e)}s.Service=gr});var bt=Q(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.VecForm=B.OptionForm=B.VariantForm=B.TupleForm=B.RecordForm=B.InputForm=B.InputBox=void 0;var _t=class{constructor(t,r){this.idl=t,this.ui=r,this.label=null,this.value=void 0;let n=document.createElement("span");n.className="status",this.status=n,r.input&&(r.input.addEventListener("blur",()=>{r.input.value!==""&&this.parse()}),r.input.addEventListener("input",()=>{n.style.display="none",r.input.classList.remove("reject")}))}isRejected(){return this.value===void 0}parse(t={}){if(this.ui.form){let r=this.ui.form.parse(t);return this.value=r,r}if(this.ui.input){let r=this.ui.input;try{let n=this.ui.parse(this.idl,t,r.value);if(!this.idl.covariant(n))throw new Error(`${r.value} is not of type ${this.idl.display()}`);return this.status.style.display="none",this.value=n,n}catch(n){r.classList.add("reject"),this.status.style.display="block",this.status.innerHTML="InputError: "+n.message,this.value=void 0;return}}return null}render(t){let r=document.createElement("span");if(this.label){let n=document.createElement("label");n.innerText=this.label,r.appendChild(n)}this.ui.input&&(r.appendChild(this.ui.input),r.appendChild(this.status)),this.ui.form&&this.ui.form.render(r),t.appendChild(r)}};B.InputBox=_t;var I=class{constructor(t){this.ui=t,this.form=[]}renderForm(t){this.ui.container?(this.form.forEach(r=>r.render(this.ui.container)),t.appendChild(this.ui.container)):this.form.forEach(r=>r.render(t))}render(t){if(this.ui.open&&this.ui.event){t.appendChild(this.ui.open);let r=this;r.ui.open.addEventListener(r.ui.event,()=>{if(r.ui.container)r.ui.container.innerHTML="";else{let n=r.ui.open.nextElementSibling;n&&n.parentNode.removeChild(n)}r.generateForm(),r.renderForm(t)})}else this.generateForm(),this.renderForm(t)}};B.InputForm=I;var ft=class extends I{constructor(t,r){super(r),this.fields=t,this.ui=r}generateForm(){this.form=this.fields.map(([t,r])=>{let n=this.ui.render(r);return this.ui.labelMap&&this.ui.labelMap.hasOwnProperty(t)?n.label=this.ui.labelMap[t]+" ":n.label=t+" ",n})}parse(t){let r={};if(this.fields.forEach(([n,o],i)=>{let a=this.form[i].parse(t);r[n]=a}),!this.form.some(n=>n.isRejected()))return r}};B.RecordForm=ft;var ht=class extends I{constructor(t,r){super(r),this.components=t,this.ui=r}generateForm(){this.form=this.components.map(t=>this.ui.render(t))}parse(t){let r=[];if(this.components.forEach((n,o)=>{let i=this.form[o].parse(t);r.push(i)}),!this.form.some(n=>n.isRejected()))return r}};B.TupleForm=ht;var yt=class extends I{constructor(t,r){super(r),this.fields=t,this.ui=r}generateForm(){let t=this.ui.open.selectedIndex,[r,n]=this.fields[t],o=this.ui.render(n);this.form=[o]}parse(t){let r=this.ui.open,n=r.options[r.selectedIndex].value,o=this.form[0].parse(t);if(o===void 0)return;let i={};return i[n]=o,i}};B.VariantForm=yt;var gt=class extends I{constructor(t,r){super(r),this.ty=t,this.ui=r}generateForm(){if(this.ui.open.checked){let t=this.ui.render(this.ty);this.form=[t]}else this.form=[]}parse(t){if(this.form.length===0)return[];{let r=this.form[0].parse(t);return r===void 0?void 0:[r]}}};B.OptionForm=gt;var Tt=class extends I{constructor(t,r){super(r),this.ty=t,this.ui=r}generateForm(){let t=+this.ui.open.value;this.form=[];for(let r=0;r<t;r++){let n=this.ui.render(this.ty);this.form.push(n)}}parse(t){let r=this.form.map(n=>n.parse(t));if(!this.form.some(n=>n.isRejected()))return r}};B.VecForm=Tt});var br=Q(f=>{"use strict";var io=f&&f.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),so=f&&f.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Tr=f&&f.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&io(t,e,r);return so(t,e),t};Object.defineProperty(f,"__esModule",{value:!0});f.renderValue=f.renderInput=f.Render=f.vecForm=f.optForm=f.variantForm=f.tupleForm=f.recordForm=f.inputBox=void 0;var Ye=Tr(mt()),wt=qt("@dfinity/principal"),le=Tr(bt()),ao={parse:fo},ve={render:Pt},co=(e,t)=>new le.InputBox(e,Object.assign(Object.assign({},ao),t));f.inputBox=co;var lo=(e,t)=>new le.RecordForm(e,Object.assign(Object.assign({},ve),t));f.recordForm=lo;var uo=(e,t)=>new le.TupleForm(e,Object.assign(Object.assign({},ve),t));f.tupleForm=uo;var po=(e,t)=>new le.VariantForm(e,Object.assign(Object.assign({},ve),t));f.variantForm=po;var mo=(e,t)=>new le.OptionForm(e,Object.assign(Object.assign({},ve),t));f.optForm=mo;var _o=(e,t)=>new le.VecForm(e,Object.assign(Object.assign({},ve),t));f.vecForm=_o;var Je=class extends Ye.Visitor{visitType(t,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=t.display(),(0,f.inputBox)(t,{input:n})}visitNull(t,r){return(0,f.inputBox)(t,{})}visitRecord(t,r,n){let o={};if(r.length>1){let a=document.createElement("div");a.classList.add("popup-form"),o={container:a}}let i=(0,f.recordForm)(r,o);return(0,f.inputBox)(t,{form:i})}visitTuple(t,r,n){let o={};if(r.length>1){let a=document.createElement("div");a.classList.add("popup-form"),o={container:a}}let i=(0,f.tupleForm)(r,o);return(0,f.inputBox)(t,{form:i})}visitVariant(t,r,n){let o=document.createElement("select");for(let[u,p]of r){let d=new Option(u);o.add(d)}o.selectedIndex=-1,o.classList.add("open");let i={open:o,event:"change"},a=(0,f.variantForm)(r,i);return(0,f.inputBox)(t,{form:a})}visitOpt(t,r,n){let o=document.createElement("input");o.type="checkbox",o.classList.add("open");let i=(0,f.optForm)(r,{open:o,event:"change"});return(0,f.inputBox)(t,{form:i})}visitVec(t,r,n){let o=document.createElement("input");o.type="number",o.min="0",o.max="100",o.style.width="8rem",o.placeholder="len",o.classList.add("open");let i=document.createElement("div");i.classList.add("popup-form");let a=(0,f.vecForm)(r,{open:o,event:"change",container:i});return(0,f.inputBox)(t,{form:a})}visitRec(t,r,n){return Pt(r)}};f.Render=Je;var xt=class extends Ye.Visitor{visitNull(t,r){return null}visitBool(t,r){if(r==="true")return!0;if(r==="false")return!1;throw new Error(`Cannot parse ${r} as boolean`)}visitText(t,r){return r}visitFloat(t,r){return parseFloat(r)}visitFixedInt(t,r){return t._bits<=32?parseInt(r,10):BigInt(r)}visitFixedNat(t,r){return t._bits<=32?parseInt(r,10):BigInt(r)}visitNumber(t,r){return BigInt(r)}visitPrincipal(t,r){return wt.Principal.fromText(r)}visitService(t,r){return wt.Principal.fromText(r)}visitFunc(t,r){let n=r.split(".",2);return[wt.Principal.fromText(n[0]),n[1]]}},vt=class extends Ye.Visitor{visitNull(t,r){return null}visitBool(t,r){return Math.random()<.5}visitText(t,r){return Math.random().toString(36).substring(6)}visitFloat(t,r){return Math.random()}visitInt(t,r){return BigInt(this.generateNumber(!0))}visitNat(t,r){return BigInt(this.generateNumber(!1))}visitFixedInt(t,r){let n=this.generateNumber(!0);return t._bits<=32?n:BigInt(r)}visitFixedNat(t,r){let n=this.generateNumber(!1);return t._bits<=32?n:BigInt(r)}generateNumber(t){let r=Math.floor(Math.random()*100);return t&&Math.random()<.5?-r:r}};function fo(e,t,r){return t.random&&r===""?e.accept(new vt,r):e.accept(new xt,r)}function Pt(e){return e.accept(new Je,null)}f.renderInput=Pt;function ee(e,t,r){return e.accept(new Nt,{input:t,value:r})}f.renderValue=ee;var Nt=class extends Ye.Visitor{visitType(t,r){r.input.ui.input.value=t.valueToString(r.value)}visitNull(t,r){}visitText(t,r){r.input.ui.input.value=r.value}visitRec(t,r,n){ee(r,n.input,n.value)}visitOpt(t,r,n){if(n.value.length!==0){let o=n.input.ui.form,i=o.ui.open;i.checked=!0,i.dispatchEvent(new Event(o.ui.event)),ee(r,o.form[0],n.value[0])}}visitRecord(t,r,n){let o=n.input.ui.form;r.forEach(([i,a],u)=>{ee(a,o.form[u],n.value[i])})}visitTuple(t,r,n){let o=n.input.ui.form;r.forEach((i,a)=>{ee(i,o.form[a],n.value[a])})}visitVariant(t,r,n){let o=n.input.ui.form,i=Object.entries(n.value)[0];r.forEach(([a,u],p)=>{if(a===i[0]){let d=o.ui.open;d.selectedIndex=p,d.dispatchEvent(new Event(o.ui.event)),ee(u,o.form[0],i[1])}})}visitVec(t,r,n){let o=n.input.ui.form,i=n.value.length,a=o.ui.open;a.value=i,a.dispatchEvent(new Event(o.ui.event)),n.value.forEach((u,p)=>{ee(r,o.form[p],u)})}}});var xr=Q(wr=>{"use strict";Object.defineProperty(wr,"__esModule",{value:!0})});var Vt=Q(E=>{"use strict";var vr=E&&E.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),ho=E&&E.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),ue=E&&E.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&vr(t,e,r)},yo=E&&E.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&vr(t,e,r);return ho(t,e),t};Object.defineProperty(E,"__esModule",{value:!0});E.IDL=void 0;ue(br(),E);ue(bt(),E);E.IDL=yo(mt());ue(st(),E);ue(ct(),E);ue(Se(),E);ue(xr(),E)});import{Principal as go}from"@dfinity/principal";import{CanisterStatus as qn}from"@dfinity/agent";import{Principal as $n}from"@dfinity/principal";import{assertNonNullish as Un}from"@junobuild/utils";import{Actor as kn,HttpAgent as Bn}from"@dfinity/agent";import{nonNullish as Ut}from"@junobuild/utils";var rt=async({canisterId:e,idlFactory:t,config:r,...n})=>{let o=await nt(n);return kn.createActor(t,{agent:o,canisterId:e,...r!==void 0?r:{}})},nt=async({identity:e,fetch:t,container:r})=>{let n=Ut(r)&&r!==!1,o=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io";return await Bn.create({identity:e,host:o,retryTimes:10,...Ut(t)&&{fetch:t},shouldFetchRootKey:n})};import{Principal as Yt}from"@dfinity/principal";import{isNullish as Mn}from"@junobuild/utils";var jt=({IDL:e})=>{let t=e.Variant({mainnet:e.Null,testnet:e.Null}),r=e.Text,n=e.Record({network:t,address:r,min_confirmations:e.Opt(e.Nat32)}),o=e.Nat64,i=o,a=e.Record({network:t,address:r,min_confirmations:e.Opt(e.Nat32)}),u=o,p=e.Record({network:t}),d=e.Nat64,h=e.Vec(d),g=e.Record({network:t,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:r}),T=e.Vec(e.Nat8),l=e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32}),m=e.Record({height:e.Nat32,value:o,outpoint:l}),b=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:e.Nat32,tip_block_hash:T,utxos:e.Vec(m)}),N=e.Record({network:t,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:r}),x=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:e.Nat32,tip_block_hash:T,utxos:e.Vec(m)}),w=e.Record({transaction:e.Vec(e.Nat8),network:t}),_=e.Principal,P=e.Record({canister_id:_,num_requested_changes:e.Opt(e.Nat64)}),R=e.Variant({from_user:e.Record({user_id:e.Principal}),from_canister:e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal})}),F=e.Variant({creation:e.Record({controllers:e.Vec(e.Principal)}),code_deployment:e.Record({mode:e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),module_hash:e.Vec(e.Nat8)}),controllers_change:e.Record({controllers:e.Vec(e.Principal)}),code_uninstall:e.Null}),C=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:R,details:F}),S=e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec(C),total_num_changes:e.Nat64}),k=e.Record({canister_id:_}),O=e.Variant({controllers:e.Null,public:e.Null}),U=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),reserved_cycles_limit:e.Nat,log_visibility:O,wasm_memory_limit:e.Nat,memory_allocation:e.Nat,compute_allocation:e.Nat}),J=e.Record({status:e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),memory_size:e.Nat,cycles:e.Nat,settings:U,query_stats:e.Record({response_payload_bytes_total:e.Nat,num_instructions_total:e.Nat,num_calls_total:e.Nat,request_payload_bytes_total:e.Nat}),idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8)),reserved_cycles:e.Nat}),j=e.Record({canister_id:_}),M=e.Record({freezing_threshold:e.Opt(e.Nat),controllers:e.Opt(e.Vec(e.Principal)),reserved_cycles_limit:e.Opt(e.Nat),log_visibility:e.Opt(O),wasm_memory_limit:e.Opt(e.Nat),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),Y=e.Record({settings:e.Opt(M),sender_canister_version:e.Opt(e.Nat64)}),z=e.Record({canister_id:_}),H=e.Record({canister_id:_}),me=e.Record({canister_id:_}),te=e.Variant({secp256k1:e.Null}),re=e.Record({key_id:e.Record({name:e.Text,curve:te}),canister_id:e.Opt(_),derivation_path:e.Vec(e.Vec(e.Nat8))}),_e=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),Ie=e.Record({canister_id:_}),ne=e.Record({idx:e.Nat64,timestamp_nanos:e.Nat64,content:e.Vec(e.Nat8)}),De=e.Record({canister_log_records:e.Vec(ne)}),Ve=e.Record({value:e.Text,name:e.Text}),fe=e.Record({status:e.Nat,body:e.Vec(e.Nat8),headers:e.Vec(Ve)}),Le=e.Record({url:e.Text,method:e.Variant({get:e.Null,head:e.Null,post:e.Null}),max_response_bytes:e.Opt(e.Nat64),body:e.Opt(e.Vec(e.Nat8)),transform:e.Opt(e.Record({function:e.Func([e.Record({context:e.Vec(e.Nat8),response:fe})],[fe],["query"]),context:e.Vec(e.Nat8)})),headers:e.Vec(Ve)}),he=e.Variant({reinstall:e.Null,upgrade:e.Opt(e.Record({wasm_memory_persistence:e.Opt(e.Variant({keep:e.Null,replace:e.Null})),skip_pre_upgrade:e.Opt(e.Bool)})),install:e.Null}),ye=e.Record({hash:e.Vec(e.Nat8)}),et=e.Record({arg:e.Vec(e.Nat8),wasm_module_hash:e.Vec(e.Nat8),mode:he,chunk_hashes_list:e.Vec(ye),target_canister:_,store_canister:e.Opt(_),sender_canister_version:e.Opt(e.Nat64)}),tt=e.Vec(e.Nat8),sn=e.Record({arg:e.Vec(e.Nat8),wasm_module:tt,mode:he,canister_id:_,sender_canister_version:e.Opt(e.Nat64)}),an=e.Record({start_at_timestamp_nanos:e.Nat64,subnet_id:e.Principal}),cn=e.Record({num_block_failures_total:e.Nat64,node_id:e.Principal,num_blocks_proposed_total:e.Nat64}),ln=e.Vec(e.Record({timestamp_nanos:e.Nat64,node_metrics:e.Vec(cn)})),un=e.Record({settings:e.Opt(M),specified_id:e.Opt(_),amount:e.Opt(e.Nat),sender_canister_version:e.Opt(e.Nat64)}),dn=e.Record({canister_id:_}),pn=e.Record({canister_id:_,amount:e.Nat}),mn=e.Vec(e.Nat8),Bt=e.Variant({ed25519:e.Null,bip340secp256k1:e.Null}),_n=e.Record({key_id:e.Record({algorithm:Bt,name:e.Text}),canister_id:e.Opt(_),derivation_path:e.Vec(e.Vec(e.Nat8))}),fn=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),hn=e.Record({key_id:e.Record({name:e.Text,curve:te}),derivation_path:e.Vec(e.Vec(e.Nat8)),message_hash:e.Vec(e.Nat8)}),yn=e.Record({signature:e.Vec(e.Nat8)}),gn=e.Record({key_id:e.Record({algorithm:Bt,name:e.Text}),derivation_path:e.Vec(e.Vec(e.Nat8)),message:e.Vec(e.Nat8)}),Tn=e.Record({signature:e.Vec(e.Nat8)}),bn=e.Record({canister_id:_}),wn=e.Record({canister_id:_}),xn=e.Record({canister_id:_}),vn=e.Vec(ye),Nn=e.Record({canister_id:_,sender_canister_version:e.Opt(e.Nat64)}),Pn=e.Record({canister_id:e.Principal,settings:M,sender_canister_version:e.Opt(e.Nat64)}),Vn=e.Record({chunk:e.Vec(e.Nat8),canister_id:e.Principal}),Rn=ye;return e.Service({bitcoin_get_balance:e.Func([n],[i],[]),bitcoin_get_balance_query:e.Func([a],[u],["query"]),bitcoin_get_current_fee_percentiles:e.Func([p],[h],[]),bitcoin_get_utxos:e.Func([g],[b],[]),bitcoin_get_utxos_query:e.Func([N],[x],["query"]),bitcoin_send_transaction:e.Func([w],[],[]),canister_info:e.Func([P],[S],[]),canister_status:e.Func([k],[J],[]),clear_chunk_store:e.Func([j],[],[]),create_canister:e.Func([Y],[z],[]),delete_canister:e.Func([H],[],[]),deposit_cycles:e.Func([me],[],[]),ecdsa_public_key:e.Func([re],[_e],[]),fetch_canister_logs:e.Func([Ie],[De],["query"]),http_request:e.Func([Le],[fe],[]),install_chunked_code:e.Func([et],[],[]),install_code:e.Func([sn],[],[]),node_metrics_history:e.Func([an],[ln],[]),provisional_create_canister_with_cycles:e.Func([un],[dn],[]),provisional_top_up_canister:e.Func([pn],[],[]),raw_rand:e.Func([],[mn],[]),schnorr_public_key:e.Func([_n],[fn],[]),sign_with_ecdsa:e.Func([hn],[yn],[]),sign_with_schnorr:e.Func([gn],[Tn],[]),start_canister:e.Func([bn],[],[]),stop_canister:e.Func([wn],[],[]),stored_chunks:e.Func([xn],[vn],[]),uninstall_code:e.Func([Nn],[],[]),update_settings:e.Func([Pn],[],[]),upload_chunk:e.Func([Vn],[Rn],[])})};var zt=({IDL:e})=>{let t=e.Record({updated_at:e.Nat64,orbiter_id:e.Principal,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),r=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,satellite_id:e.Principal}),n=e.Record({cycles:e.Nat,destination_id:e.Principal}),o=e.Variant({Write:e.Null,Admin:e.Null}),i=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:o,expires_at:e.Opt(e.Nat64)}),a=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),u=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),p=e.Record({status:a,memory_size:e.Nat,cycles:e.Nat,settings:u,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),d=e.Record({id:e.Principal,status:p,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),status_at:e.Nat64}),h=e.Variant({Ok:d,Err:e.Text}),g=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:o,expires_at:e.Opt(e.Nat64)}),T=e.Record({enabled:e.Bool,cycles_threshold:e.Opt(e.Nat64)}),l=e.Record({mission_control_cycles_threshold:e.Opt(e.Nat64),orbiters:e.Vec(e.Tuple(e.Principal,T)),satellites:e.Vec(e.Tuple(e.Principal,T)),cycles_threshold:e.Opt(e.Nat64)}),m=e.Record({orbiters:e.Opt(e.Vec(h)),satellites:e.Opt(e.Vec(h)),mission_control:h}),b=e.Record({e8s:e.Nat64});return e.Service({add_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),add_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),create_orbiter:e.Func([e.Opt(e.Text)],[t],[]),create_satellite:e.Func([e.Text],[r],[]),del_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),del_orbiter:e.Func([e.Principal,e.Nat],[],[]),del_orbiters_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),del_satellite:e.Func([e.Principal,e.Nat],[],[]),del_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),deposit_cycles:e.Func([n],[],[]),get_user:e.Func([],[e.Principal],["query"]),list_mission_control_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,i))],["query"]),list_mission_control_statuses:e.Func([],[e.Vec(e.Tuple(e.Nat64,h))],["query"]),list_orbiter_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,h)))],["query"]),list_orbiters:e.Func([],[e.Vec(e.Tuple(e.Principal,t))],["query"]),list_satellite_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,h)))],["query"]),list_satellites:e.Func([],[e.Vec(e.Tuple(e.Principal,r))],["query"]),remove_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),remove_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),set_metadata:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),set_mission_control_controllers:e.Func([e.Vec(e.Principal),g],[],[]),set_orbiter:e.Func([e.Principal,e.Opt(e.Text)],[t],[]),set_orbiter_metadata:e.Func([e.Principal,e.Vec(e.Tuple(e.Text,e.Text))],[t],[]),set_orbiters_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal),g],[],[]),set_satellite:e.Func([e.Principal,e.Opt(e.Text)],[r],[]),set_satellite_metadata:e.Func([e.Principal,e.Vec(e.Tuple(e.Text,e.Text))],[r],[]),set_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal),g],[],[]),status:e.Func([l],[m],[]),top_up:e.Func([e.Principal,b],[],[]),unset_orbiter:e.Func([e.Principal],[],[]),unset_satellite:e.Func([e.Principal],[],[]),version:e.Func([],[e.Text],["query"])})};var Ht=({IDL:e})=>{let t=e.Record({controllers:e.Vec(e.Principal)}),r=e.Variant({Write:e.Null,Admin:e.Null}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:r,expires_at:e.Opt(e.Nat64)}),o=e.Record({version:e.Opt(e.Nat64)}),i=e.Record({cycles:e.Nat,destination_id:e.Principal}),a=e.Record({to:e.Opt(e.Nat64),from:e.Opt(e.Nat64),satellite_id:e.Opt(e.Principal)}),u=e.Record({key:e.Text,collected_at:e.Nat64}),p=e.Record({inner_height:e.Nat16,inner_width:e.Nat16}),d=e.Record({title:e.Text,updated_at:e.Nat64,referrer:e.Opt(e.Text),time_zone:e.Text,session_id:e.Text,href:e.Text,created_at:e.Nat64,satellite_id:e.Principal,device:p,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),h=e.Record({safari:e.Float64,opera:e.Float64,others:e.Float64,firefox:e.Float64,chrome:e.Float64}),g=e.Record({desktop:e.Float64,others:e.Float64,mobile:e.Float64}),T=e.Record({browsers:h,devices:g}),l=e.Record({day:e.Nat8,month:e.Nat8,year:e.Int32}),m=e.Record({bounce_rate:e.Float64,average_page_views_per_session:e.Float64,daily_total_page_views:e.Vec(e.Tuple(l,e.Nat32)),total_page_views:e.Nat32,unique_page_views:e.Nat64,unique_sessions:e.Nat64}),b=e.Record({referrers:e.Vec(e.Tuple(e.Text,e.Nat32)),pages:e.Vec(e.Tuple(e.Text,e.Nat32))}),N=e.Variant({Navigate:e.Null,Restore:e.Null,Reload:e.Null,BackForward:e.Null,BackForwardCache:e.Null,Prerender:e.Null}),x=e.Record({id:e.Text,value:e.Float64,navigation_type:e.Opt(N),delta:e.Float64}),w=e.Variant({WebVitalsMetric:x}),_=e.Variant({CLS:e.Null,FCP:e.Null,INP:e.Null,LCP:e.Null,TTFB:e.Null}),P=e.Record({updated_at:e.Nat64,session_id:e.Text,data:w,href:e.Text,metric_name:_,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),R=e.Record({cls:e.Opt(e.Float64),fcp:e.Opt(e.Float64),inp:e.Opt(e.Float64),lcp:e.Opt(e.Float64),ttfb:e.Opt(e.Float64)}),F=e.Record({overall:R,pages:e.Vec(e.Tuple(e.Text,R))}),C=e.Record({updated_at:e.Nat64,session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),S=e.Record({total:e.Vec(e.Tuple(e.Text,e.Nat32))}),k=e.Record({performance_metrics:e.Bool,track_events:e.Bool,page_views:e.Bool}),O=e.Record({updated_at:e.Nat64,features:e.Opt(k),created_at:e.Nat64,version:e.Opt(e.Nat64)}),U=e.Record({stable:e.Nat64,heap:e.Nat64}),J=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:r,expires_at:e.Opt(e.Nat64)}),j=e.Record({controller:J,controllers:e.Vec(e.Principal)}),M=e.Record({title:e.Text,updated_at:e.Opt(e.Nat64),referrer:e.Opt(e.Text),time_zone:e.Text,session_id:e.Text,href:e.Text,satellite_id:e.Principal,device:p,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),Y=e.Variant({Ok:d,Err:e.Text}),z=e.Variant({Ok:e.Null,Err:e.Vec(e.Tuple(u,e.Text))}),H=e.Record({session_id:e.Text,data:w,href:e.Text,metric_name:_,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),me=e.Variant({Ok:P,Err:e.Text}),te=e.Record({features:e.Opt(k),version:e.Opt(e.Nat64)}),re=e.Record({updated_at:e.Opt(e.Nat64),session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),_e=e.Variant({Ok:C,Err:e.Text});return e.Service({del_controllers:e.Func([t],[e.Vec(e.Tuple(e.Principal,n))],[]),del_satellite_config:e.Func([e.Principal,o],[],[]),deposit_cycles:e.Func([i],[],[]),get_page_views:e.Func([a],[e.Vec(e.Tuple(u,d))],["query"]),get_page_views_analytics_clients:e.Func([a],[T],["query"]),get_page_views_analytics_metrics:e.Func([a],[m],["query"]),get_page_views_analytics_top_10:e.Func([a],[b],["query"]),get_performance_metrics:e.Func([a],[e.Vec(e.Tuple(u,P))],["query"]),get_performance_metrics_analytics_web_vitals:e.Func([a],[F],["query"]),get_track_events:e.Func([a],[e.Vec(e.Tuple(u,C))],["query"]),get_track_events_analytics:e.Func([a],[S],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_satellite_configs:e.Func([],[e.Vec(e.Tuple(e.Principal,O))],["query"]),memory_size:e.Func([],[U],["query"]),set_controllers:e.Func([j],[e.Vec(e.Tuple(e.Principal,n))],[]),set_page_view:e.Func([u,M],[Y],[]),set_page_views:e.Func([e.Vec(e.Tuple(u,M))],[z],[]),set_performance_metric:e.Func([u,H],[me],[]),set_performance_metrics:e.Func([e.Vec(e.Tuple(u,H))],[z],[]),set_satellite_configs:e.Func([e.Vec(e.Tuple(e.Principal,te))],[e.Vec(e.Tuple(e.Principal,O))],[]),set_track_event:e.Func([u,re],[_e],[]),set_track_events:e.Func([e.Vec(e.Tuple(u,re))],[z],[]),version:e.Func([],[e.Text],["query"])})};var Kt=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({controllers:e.Vec(e.Principal)}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,expires_at:e.Opt(e.Nat64)}),o=e.Record({updated_at:e.Opt(e.Nat64)}),i=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),a=e.Record({storage:i}),u=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),p=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),d=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),h=e.Variant({Callback:e.Record({token:d,callback:e.Func([],[],[])})}),g=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(h),status_code:e.Nat16}),T=e.Record({token:e.Opt(d),body:e.Vec(e.Nat8)}),l=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),m=e.Record({batch_id:e.Nat}),b=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),N=e.Record({field:b,desc:e.Bool}),x=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),w=e.Record({order:e.Opt(N),owner:e.Opt(e.Principal),matcher:e.Opt(e.Text),paginate:e.Opt(x)}),_=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),P=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),R=e.Record({key:_,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,P)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),F=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,R))}),C=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),S=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,u))}),k=e.Variant({Db:e.Null,Storage:e.Null}),O=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),U=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:O,created_at:e.Nat64,write:O}),J=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),j=e.Record({controller:J,controllers:e.Vec(e.Principal)}),M=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),Y=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:O,write:O}),z=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),H=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_controllers:e.Func([r],[e.Vec(e.Tuple(e.Principal,n))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,o],[],[]),get_config:e.Func([],[a],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(u)],["query"]),http_request:e.Func([p],[g],["query"]),http_request_streaming_callback:e.Func([d],[T],["query"]),init_asset_upload:e.Func([l],[m],[]),list_assets:e.Func([e.Opt(e.Text),w],[F],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,C))],["query"]),list_docs:e.Func([e.Text,w],[S],["query"]),list_rules:e.Func([k],[e.Vec(e.Tuple(e.Text,U))],["query"]),set_config:e.Func([a],[],[]),set_controllers:e.Func([j],[e.Vec(e.Tuple(e.Principal,n))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,M],[u],[]),set_rule:e.Func([k,e.Text,Y],[],[]),upload_asset_chunk:e.Func([z],[H],[]),version:e.Func([],[e.Text],["query"])})};var Wt=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({controllers:e.Vec(e.Principal)}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,expires_at:e.Opt(e.Nat64)}),o=e.Record({updated_at:e.Opt(e.Nat64)}),i=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),a=e.Record({storage:i}),u=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),p=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),d=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),h=e.Variant({Callback:e.Record({token:d,callback:e.Func([],[],[])})}),g=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(h),status_code:e.Nat16}),T=e.Record({token:e.Opt(d),body:e.Vec(e.Nat8)}),l=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),m=e.Record({batch_id:e.Nat}),b=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),N=e.Record({field:b,desc:e.Bool}),x=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),w=e.Record({order:e.Opt(N),matcher:e.Opt(e.Text),paginate:e.Opt(x)}),_=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),P=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),R=e.Record({key:_,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,P)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),F=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,R))}),C=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),S=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,u))}),k=e.Variant({Db:e.Null,Storage:e.Null}),O=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),U=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:O,created_at:e.Nat64,write:O}),J=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),j=e.Record({controller:J,controllers:e.Vec(e.Principal)}),M=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),Y=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:O,write:O}),z=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),H=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_controllers:e.Func([r],[e.Vec(e.Tuple(e.Principal,n))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,o],[],[]),get_config:e.Func([],[a],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(u)],["query"]),http_request:e.Func([p],[g],["query"]),http_request_streaming_callback:e.Func([d],[T],["query"]),init_asset_upload:e.Func([l],[m],[]),list_assets:e.Func([e.Opt(e.Text),w],[F],["query"]),list_controllers:e.Func([],[e.Vec(e.Principal)],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,C))],["query"]),list_docs:e.Func([e.Text,w],[S],["query"]),list_rules:e.Func([k],[e.Vec(e.Tuple(e.Text,U))],["query"]),set_config:e.Func([a],[],[]),set_controllers:e.Func([j],[e.Vec(e.Tuple(e.Principal,n))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,M],[u],[]),set_rule:e.Func([k,e.Text,Y],[],[]),upload_asset_chunk:e.Func([z],[H],[]),version:e.Func([],[e.Text],["query"])})};var Gt=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),n=e.Record({field:r,desc:e.Bool}),o=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),i=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(o),description:e.Opt(e.Text),created_at:e.Opt(o)}),a=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),u=e.Record({order:e.Opt(n),owner:e.Opt(e.Principal),matcher:e.Opt(i),paginate:e.Opt(a)}),p=e.Record({controllers:e.Vec(e.Principal)}),d=e.Variant({Write:e.Null,Admin:e.Null}),h=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:d,expires_at:e.Opt(e.Nat64)}),g=e.Record({version:e.Opt(e.Nat64)}),T=e.Variant({Db:e.Null,Storage:e.Null}),l=e.Record({version:e.Opt(e.Nat64)}),m=e.Record({cycles:e.Nat,destination_id:e.Principal}),b=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),N=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),x=e.Record({key:b,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,N)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),w=e.Record({derivation_origin:e.Opt(e.Text)}),_=e.Record({internet_identity:e.Opt(w)}),P=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),R=e.Record({max_memory_size:e.Opt(P)}),F=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),C=e.Variant({Deny:e.Null,Allow:e.Null}),S=e.Record({status_code:e.Nat16,location:e.Text}),k=e.Record({iframe:e.Opt(F),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),max_memory_size:e.Opt(P),raw_access:e.Opt(C),redirects:e.Opt(e.Vec(e.Tuple(e.Text,S)))}),O=e.Record({db:e.Opt(R),authentication:e.Opt(_),storage:k}),U=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),J=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),certificate_version:e.Opt(e.Nat16)}),j=e.Variant({Heap:e.Null,Stable:e.Null}),M=e.Record({memory:j,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),Y=e.Variant({Callback:e.Record({token:M,callback:e.Func([],[],["query"])})}),z=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(Y),status_code:e.Nat16}),H=e.Record({token:e.Opt(M),body:e.Vec(e.Nat8)}),me=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,description:e.Opt(e.Text),encoding_type:e.Opt(e.Text),full_path:e.Text}),te=e.Record({batch_id:e.Nat}),re=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,x)),items_length:e.Nat64}),_e=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),Ie=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,U)),items_length:e.Nat64}),ne=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),De=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(j),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:ne,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),write:ne}),Ve=e.Record({stable:e.Nat64,heap:e.Nat64}),fe=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:d,expires_at:e.Opt(e.Nat64)}),Le=e.Record({controller:fe,controllers:e.Vec(e.Principal)}),he=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),ye=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(j),max_size:e.Opt(e.Nat),read:ne,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),write:ne}),et=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),tt=e.Record({chunk_id:e.Nat});return e.Service({build_version:e.Func([],[e.Text],["query"]),commit_asset_upload:e.Func([t],[],[]),count_assets:e.Func([e.Text,u],[e.Nat64],["query"]),count_collection_assets:e.Func([e.Text],[e.Nat64],["query"]),count_collection_docs:e.Func([e.Text],[e.Nat64],["query"]),count_docs:e.Func([e.Text,u],[e.Nat64],["query"]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([p],[e.Vec(e.Tuple(e.Principal,h))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,g],[],[]),del_docs:e.Func([e.Text],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,g))],[],[]),del_rule:e.Func([T,e.Text,l],[],[]),deposit_cycles:e.Func([m],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(x)],["query"]),get_auth_config:e.Func([],[e.Opt(_)],["query"]),get_config:e.Func([],[O],[]),get_db_config:e.Func([],[e.Opt(R)],["query"]),get_doc:e.Func([e.Text,e.Text],[e.Opt(U)],["query"]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(x)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(U)))],["query"]),get_storage_config:e.Func([],[k],["query"]),http_request:e.Func([J],[z],["query"]),http_request_streaming_callback:e.Func([M],[H],["query"]),init_asset_upload:e.Func([me],[te],[]),list_assets:e.Func([e.Text,u],[re],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,h))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,_e))],["query"]),list_docs:e.Func([e.Text,u],[Ie],["query"]),list_rules:e.Func([T],[e.Vec(e.Tuple(e.Text,De))],["query"]),memory_size:e.Func([],[Ve],["query"]),set_auth_config:e.Func([_],[],[]),set_controllers:e.Func([Le],[e.Vec(e.Tuple(e.Principal,h))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([R],[],[]),set_doc:e.Func([e.Text,e.Text,he],[U],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,he))],[e.Vec(e.Tuple(e.Text,U))],[]),set_rule:e.Func([T,e.Text,ye],[],[]),set_storage_config:e.Func([k],[],[]),upload_asset_chunk:e.Func([et],[tt],[]),version:e.Func([],[e.Text],["query"])})};var Qt=async({satelliteId:e,...t})=>ge({canisterId:e,...t,idlFactory:Wt}),A=async({satelliteId:e,...t})=>ge({canisterId:e,...t,idlFactory:Gt}),Xt=async({satelliteId:e,...t})=>ge({canisterId:e,...t,idlFactory:Kt}),oe=async({missionControlId:e,...t})=>ge({canisterId:e,...t,idlFactory:zt}),Re=async({orbiterId:e,...t})=>ge({canisterId:e,...t,idlFactory:Ht}),ge=async({canisterId:e,idlFactory:t,...r})=>{if(Mn(e))throw new Error("No canister ID provided.");return rt({canisterId:e,idlFactory:t,...r})},Zt=Yt.fromText("aaaaa-aa"),Jt=(e,t,r)=>{let n=t[0],o=Zt;return n&&typeof n=="object"&&n.canister_id&&(o=Yt.from(n.canister_id)),{effectiveCanisterId:o}},It=e=>rt({canisterId:Zt.toText(),config:{callTransform:Jt,queryTransform:Jt},idlFactory:jt,...e});var L=async({actor:e,code:t})=>{let{install_code:r}=await It(e);return r({...t,sender_canister_version:[]})},Dt=async({canisterId:e,path:t,...r})=>{Un(e,"A canister ID must be provided to request its status.");let n=await nt(r);return(await qn.request({canisterId:$n.from(e),agent:n,paths:[{kind:"metadata",key:t,path:t,decodeStrategy:"utf-8"}]})).get(t)};var Lt=async({missionControl:e})=>(await oe(e)).version(),er=async({missionControl:e})=>(await oe(e)).get_user(),tr=async({missionControl:e})=>(await oe(e)).list_mission_control_controllers(),rr=async({missionControl:e,satelliteIds:t,controllerIds:r,controller:n})=>(await oe(e)).set_satellites_controllers(t,r,n),nr=async({missionControl:e,controllerIds:t,controller:r})=>(await oe(e)).set_mission_control_controllers(t,r);import{Principal as jn}from"@dfinity/principal";import{nonNullish as zn,toNullable as Hn}from"@junobuild/utils";var ot=({controllerId:e,profile:t})=>({controllerIds:[jn.fromText(e)],controller:Kn(t)}),Kn=e=>({metadata:zn(e)&&e!==""?[["profile",e]]:[],expires_at:Hn(void 0),scope:{Admin:null}});var D=$t(Vt(),1),Nr=e=>D.IDL.encode([D.IDL.Record({user:D.IDL.Principal})],[{user:e}]),Qe=e=>D.IDL.encode([D.IDL.Record({controllers:D.IDL.Vec(D.IDL.Principal)})],[{controllers:e.map(([t,r])=>t)}]);var hi=async e=>Lt(e),yi=async({missionControl:e,wasm_module:t})=>{let r=await er({missionControl:e}),{missionControlId:n,...o}=e;if(!n)throw new Error("No mission control principal defined.");let i=Nr(r);await L({actor:o,code:{canister_id:go.fromText(n),arg:new Uint8Array(i),wasm_module:t,mode:{upgrade:[{skip_pre_upgrade:[!1],wasm_memory_persistence:[{replace:null}]}]}}})},gi=async({controllerId:e,profile:t,...r})=>rr({...r,...ot({controllerId:e,profile:t})}),Ti=async({controllerId:e,profile:t,...r})=>nr({...r,...ot({controllerId:e,profile:t})}),bi=e=>tr(e);import{Principal as To}from"@dfinity/principal";var Pr=async({orbiter:e})=>(await Re(e)).version(),Rt=async({orbiter:e})=>(await Re(e)).list_controllers(),Vr=async({orbiter:e})=>{let{memory_size:t}=await Re(e);return t()};var Ci=async e=>Pr(e),Fi=async({orbiter:e,wasm_module:t,reset:r=!1})=>{let{orbiterId:n,...o}=e;if(!n)throw new Error("No orbiter principal defined.");let i=await Rt({orbiter:e}),a=Qe(i);await L({actor:o,code:{canister_id:To.fromText(n),arg:new Uint8Array(a),wasm_module:t,mode:r?{reinstall:null}:{upgrade:[{skip_pre_upgrade:[!1],wasm_memory_persistence:[{replace:null}]}]}}})},Si=e=>Vr(e),Oi=e=>Rt(e);import{major as Rr,minor as Cr,patch as Fr}from"semver";var ki=({currentVersion:e,selectedVersion:t})=>{let r=Rr(e),n=Rr(t),o=Cr(e),i=Cr(t),a=Fr(e),u=Fr(t);return r<n-1||o<i-1||a<u-1?{canUpgrade:!1}:{canUpgrade:!0}};var Pe=$t(Vt(),1);import{Principal as on}from"@dfinity/principal";import{fromNullable as pe,isNullish as kt,nonNullish as Ze}from"@junobuild/utils";import{toNullable as bo}from"@junobuild/utils";var Sr=async({config:e,satellite:t})=>{let{set_storage_config:r}=await A(t);return r(e)},Or=async({config:e,satellite:t})=>{let{set_db_config:r}=await A(t);return r(e)},Ar=async({config:e,satellite:t})=>{let{set_auth_config:r}=await A(t);return r(e)};var Er=async({satellite:e})=>{let{get_auth_config:t}=await A(e);return t()},kr=async({satellite:e,type:t})=>(await A(e)).list_rules(t),Br=async({type:e,collection:t,rule:r,satellite:n})=>(await A(n)).set_rule(e,t,r),Mr=async({satellite:e})=>{let{version:t}=await A(e);return t()},qr=async({satellite:e})=>{let{build_version:t}=await A(e);return t()},$r=async({satellite:e})=>(await Qt(e)).list_controllers(),Ct=async({satellite:e})=>(await Xt(e)).list_controllers(),Ft=async({satellite:e})=>(await A(e)).list_controllers(),Ur=async({satellite:e})=>{let{list_custom_domains:t}=await A(e);return t()},jr=async({satellite:e,domainName:t,boundaryNodesId:r})=>{let{set_custom_domain:n}=await A(e);await n(t,bo(r))},zr=async({satellite:e})=>{let{memory_size:t}=await A(e);return t()},Hr=async({collection:e,satellite:t})=>{let{count_collection_docs:r}=await A(t);return r(e)},Kr=async({collection:e,satellite:t})=>{let{count_collection_assets:r}=await A(t);return r(e)},Wr=async({collection:e,satellite:t})=>{let{del_docs:r}=await A(t);return r(e)},Gr=async({collection:e,satellite:t})=>{let{del_assets:r}=await A(t);return r(e)},Jr=async({args:e,satellite:t})=>{let{set_controllers:r}=await A(t);return r(e)};import{nonNullish as wo,toNullable as St}from"@junobuild/utils";var Ot=e=>St(wo(e)?{heap:St(e.heap),stable:St(e.stable)}:void 0);import{fromNullable as Ne,nonNullish as de,toNullable as Xe}from"@junobuild/utils";var Yr={Db:null},Qr={Storage:null},Xr={Public:null},Zr={Private:null},Ir={Managed:null},Dr={Controllers:null},At={Heap:null},Lr={Stable:null};var Et=e=>e==="storage"?Qr:Yr,rn=({read:e,write:t,memory:r,maxSize:n,maxCapacity:o,version:i,mutablePermissions:a})=>({read:tn(e),write:tn(t),memory:de(r)?[xo(r)]:[],version:Xe(i),max_size:Xe(de(n)&&n>0?BigInt(n):void 0),max_capacity:Xe(de(o)&&o>0?o:void 0),mutable_permissions:Xe(a)}),nn=([e,t])=>{let{read:r,write:n,updated_at:o,created_at:i,max_size:a,max_capacity:u,memory:p,mutable_permissions:d,version:h}=t,g=a?.[0]??0n>0n?Number(Ne(a)):void 0,T=u?.[0]??!1?Ne(u):void 0,l=Ne(h);return{collection:e,read:en(r),write:en(n),memory:vo(Ne(p)??At),updatedAt:o,createdAt:i,...de(l)&&{version:l},...de(g)&&{maxSize:g},...de(T)&&{maxCapacity:T},mutablePermissions:Ne(d)??!0}},en=e=>"Public"in e?"public":"Private"in e?"private":"Managed"in e?"managed":"controllers",tn=e=>{switch(e){case"public":return Xr;case"private":return Zr;case"managed":return Ir;default:return Dr}},xo=e=>{switch(e.toLowerCase()){case"heap":return At;default:return Lr}},vo=e=>"Heap"in e?"heap":"stable";var Di=async({config:{headers:e,rewrites:t,redirects:r,iframe:n,rawAccess:o,maxMemorySize:i},satellite:a})=>{let u=(e??[]).map(({source:T,headers:l})=>[T,l]),p=(t??[]).map(({source:T,destination:l})=>[T,l]),d=(r??[]).map(({source:T,location:l,code:m})=>[T,{status_code:m,location:l}]);return Sr({satellite:a,config:{headers:u,rewrites:p,redirects:[d],iframe:[n==="same-origin"?{SameOrigin:null}:n==="allow-any"?{AllowAny:null}:{Deny:null}],raw_access:[o===!0?{Allow:null}:{Deny:null}],max_memory_size:Ot(i)}})},Li=async({config:{maxMemorySize:e},...t})=>{await Or({config:{max_memory_size:Ot(e)},...t})},es=async({config:{internetIdentity:e},...t})=>{await Ar({config:{internet_identity:kt(e?.derivationOrigin)?[]:[{derivation_origin:[e.derivationOrigin]}]},...t})},ts=async({satellite:e})=>{let t=pe(await Er({satellite:e}));if(kt(t))return;let r=pe(t.internet_identity??[]);return{...Ze(r)&&{internetIdentity:{...Ze(pe(r.derivation_origin))&&{derivationOrigin:pe(r.derivation_origin)}}}}},rs=async({type:e,satellite:t})=>(await kr({satellite:t,type:Et(e)})).map(n=>nn(n)),ns=async({rule:{collection:e,...t},type:r,satellite:n})=>Br({type:Et(r),rule:rn(t),satellite:n,collection:e}),os=e=>Mr(e),is=e=>qr(e),ss=async({satellite:{satelliteId:e,...t}})=>{let r=await Dt({...t,canisterId:e,path:"juno:build"});return Ze(r)&&["stock","extended"].includes(r)?r:void 0},as=async({satellite:e,wasm_module:t,deprecated:r,deprecatedNoScope:n,reset:o=!1})=>{let{satelliteId:i,...a}=e;if(kt(i))throw new Error("No satellite principal defined.");if(r){let h=await $r({satellite:e}),g=Pe.IDL.encode([Pe.IDL.Record({controllers:Pe.IDL.Vec(Pe.IDL.Principal)})],[{controllers:h}]);await L({actor:a,code:{canister_id:on.fromText(i),arg:new Uint8Array(g),wasm_module:t,mode:o?{reinstall:null}:{upgrade:[{skip_pre_upgrade:[!1],wasm_memory_persistence:[{replace:null}]}]}}});return}let p=await(n?Ct:Ft)({satellite:e}),d=Qe(p);await L({actor:a,code:{canister_id:on.fromText(i),arg:new Uint8Array(d),wasm_module:t,mode:o?{reinstall:null}:{upgrade:[{skip_pre_upgrade:[!1],wasm_memory_persistence:[{replace:null}]}]}}})},cs=async({satellite:e})=>(await Ur({satellite:e})).map(([r,n])=>{let o=pe(n.version);return{domain:r,bn_id:pe(n.bn_id),created_at:n.created_at,updated_at:n.updated_at,...Ze(o)&&{version:o}}}),ls=async({satellite:e,domains:t})=>Promise.all(t.map(({domain:r,bn_id:n})=>jr({satellite:e,domainName:r,boundaryNodesId:n}))),us=e=>zr(e),ds=async e=>Hr(e),ps=async e=>Wr(e),ms=async e=>Kr(e),_s=async e=>Gr(e),fs=({deprecatedNoScope:e,...t})=>(e===!0?Ct:Ft)(t),hs=e=>Jr(e);export{ki as checkUpgradeVersion,ms as countAssets,ds as countDocs,_s as deleteAssets,ps as deleteDocs,ts as getAuthConfig,cs as listCustomDomains,bi as listMissionControlControllers,Oi as listOrbiterControllers,rs as listRules,fs as listSatelliteControllers,hi as missionControlVersion,Si as orbiterMemorySize,Ci as orbiterVersion,ss as satelliteBuildType,is as satelliteBuildVersion,us as satelliteMemorySize,os as satelliteVersion,es as setAuthConfig,ls as setCustomDomains,Li as setDatastoreConfig,Ti as setMissionControlController,ns as setRule,hs as setSatelliteControllers,gi as setSatellitesController,Di as setStorageConfig,yi as upgradeMissionControl,Fi as upgradeOrbiter,as as upgradeSatellite};
16
16
  //# sourceMappingURL=index.mjs.map