@junobuild/admin 0.0.33 → 0.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/declarations/satellite/satellite.did.d.ts +6 -0
- package/declarations/satellite/satellite.factory.did.js +6 -0
- package/declarations/satellite/satellite.factory.did.mjs +6 -0
- package/dist/browser/index.js +7 -7
- package/dist/browser/index.js.map +3 -3
- package/dist/declarations/satellite/satellite.did.d.ts +6 -0
- package/dist/declarations/satellite/satellite.factory.did.js +6 -0
- package/dist/declarations/satellite/satellite.factory.did.mjs +6 -0
- package/dist/node/index.mjs +7 -7
- package/dist/node/index.mjs.map +3 -3
- package/dist/types/api/actor.api.d.ts +1 -3
- package/dist/types/constants/rules.constants.d.ts +3 -1
- package/dist/types/types/rules.types.d.ts +3 -0
- package/dist/types/utils/rule.utils.d.ts +5 -3
- package/package.json +6 -6
- package/declarations/cmc/cmc.did +0 -122
- package/declarations/cmc/cmc.did.d.ts +0 -48
- package/declarations/cmc/cmc.factory.did.js +0 -67
- package/declarations/cmc/index.d.ts +0 -45
- package/declarations/cmc/index.js +0 -37
- package/declarations/console/console.did.d.ts +0 -71
- package/declarations/console/console.factory.did.js +0 -79
- package/declarations/console/console.factory.did.mjs +0 -79
- package/declarations/console/index.d.ts +0 -45
- package/declarations/console/index.js +0 -37
- package/declarations/index/index.d.ts +0 -45
- package/declarations/index/index.did +0 -68
- package/declarations/index/index.did.d.ts +0 -97
- package/declarations/index/index.factory.did.js +0 -94
- package/declarations/index/index.js +0 -37
- package/declarations/observatory/index.d.ts +0 -45
- package/declarations/observatory/index.js +0 -38
- package/declarations/observatory/observatory.did.d.ts +0 -86
- package/declarations/observatory/observatory.factory.did.js +0 -95
- package/declarations/observatory/observatory.factory.did.mjs +0 -95
- package/dist/declarations/cmc/cmc.did +0 -122
- package/dist/declarations/cmc/cmc.did.d.ts +0 -48
- package/dist/declarations/cmc/cmc.factory.did.js +0 -67
- package/dist/declarations/cmc/index.d.ts +0 -45
- package/dist/declarations/cmc/index.js +0 -37
- package/dist/declarations/console/console.did.d.ts +0 -71
- package/dist/declarations/console/console.factory.did.js +0 -79
- package/dist/declarations/console/console.factory.did.mjs +0 -79
- package/dist/declarations/console/index.d.ts +0 -45
- package/dist/declarations/console/index.js +0 -37
- package/dist/declarations/index/index.d.ts +0 -45
- package/dist/declarations/index/index.did +0 -68
- package/dist/declarations/index/index.did.d.ts +0 -97
- package/dist/declarations/index/index.factory.did.js +0 -94
- package/dist/declarations/index/index.js +0 -37
- package/dist/declarations/observatory/index.d.ts +0 -45
- package/dist/declarations/observatory/index.js +0 -38
- package/dist/declarations/observatory/observatory.did.d.ts +0 -86
- package/dist/declarations/observatory/observatory.factory.did.js +0 -95
- package/dist/declarations/observatory/observatory.factory.did.mjs +0 -95
|
@@ -111,12 +111,15 @@ export interface ListResults_1 {
|
|
|
111
111
|
items: Array<[string, Doc]>;
|
|
112
112
|
items_length: bigint;
|
|
113
113
|
}
|
|
114
|
+
export type Memory = {Heap: null} | {Stable: null};
|
|
114
115
|
export type Permission = {Controllers: null} | {Private: null} | {Public: null} | {Managed: null};
|
|
115
116
|
export interface Rule {
|
|
117
|
+
memory: [] | [Memory];
|
|
116
118
|
updated_at: bigint;
|
|
117
119
|
max_size: [] | [bigint];
|
|
118
120
|
read: Permission;
|
|
119
121
|
created_at: bigint;
|
|
122
|
+
mutable_permissions: [] | [boolean];
|
|
120
123
|
write: Permission;
|
|
121
124
|
}
|
|
122
125
|
export type RulesType = {Db: null} | {Storage: null};
|
|
@@ -135,9 +138,11 @@ export interface SetDoc {
|
|
|
135
138
|
description: [] | [string];
|
|
136
139
|
}
|
|
137
140
|
export interface SetRule {
|
|
141
|
+
memory: [] | [Memory];
|
|
138
142
|
updated_at: [] | [bigint];
|
|
139
143
|
max_size: [] | [bigint];
|
|
140
144
|
read: Permission;
|
|
145
|
+
mutable_permissions: [] | [boolean];
|
|
141
146
|
write: Permission;
|
|
142
147
|
}
|
|
143
148
|
export interface StorageConfig {
|
|
@@ -149,6 +154,7 @@ export interface StreamingCallbackHttpResponse {
|
|
|
149
154
|
body: Uint8Array | number[];
|
|
150
155
|
}
|
|
151
156
|
export interface StreamingCallbackToken {
|
|
157
|
+
memory: Memory;
|
|
152
158
|
token: [] | [string];
|
|
153
159
|
sha256: [] | [Uint8Array | number[]];
|
|
154
160
|
headers: Array<[string, string]>;
|
|
@@ -39,7 +39,9 @@ export const idlFactory = ({IDL}) => {
|
|
|
39
39
|
body: IDL.Vec(IDL.Nat8),
|
|
40
40
|
headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))
|
|
41
41
|
});
|
|
42
|
+
const Memory = IDL.Variant({Heap: IDL.Null, Stable: IDL.Null});
|
|
42
43
|
const StreamingCallbackToken = IDL.Record({
|
|
44
|
+
memory: Memory,
|
|
43
45
|
token: IDL.Opt(IDL.Text),
|
|
44
46
|
sha256: IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
45
47
|
headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
@@ -138,10 +140,12 @@ export const idlFactory = ({IDL}) => {
|
|
|
138
140
|
Managed: IDL.Null
|
|
139
141
|
});
|
|
140
142
|
const Rule = IDL.Record({
|
|
143
|
+
memory: IDL.Opt(Memory),
|
|
141
144
|
updated_at: IDL.Nat64,
|
|
142
145
|
max_size: IDL.Opt(IDL.Nat),
|
|
143
146
|
read: Permission,
|
|
144
147
|
created_at: IDL.Nat64,
|
|
148
|
+
mutable_permissions: IDL.Opt(IDL.Bool),
|
|
145
149
|
write: Permission
|
|
146
150
|
});
|
|
147
151
|
const SetController = IDL.Record({
|
|
@@ -159,9 +163,11 @@ export const idlFactory = ({IDL}) => {
|
|
|
159
163
|
description: IDL.Opt(IDL.Text)
|
|
160
164
|
});
|
|
161
165
|
const SetRule = IDL.Record({
|
|
166
|
+
memory: IDL.Opt(Memory),
|
|
162
167
|
updated_at: IDL.Opt(IDL.Nat64),
|
|
163
168
|
max_size: IDL.Opt(IDL.Nat),
|
|
164
169
|
read: Permission,
|
|
170
|
+
mutable_permissions: IDL.Opt(IDL.Bool),
|
|
165
171
|
write: Permission
|
|
166
172
|
});
|
|
167
173
|
const UploadChunk = IDL.Record({
|
|
@@ -39,7 +39,9 @@ export const idlFactory = ({IDL}) => {
|
|
|
39
39
|
body: IDL.Vec(IDL.Nat8),
|
|
40
40
|
headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))
|
|
41
41
|
});
|
|
42
|
+
const Memory = IDL.Variant({Heap: IDL.Null, Stable: IDL.Null});
|
|
42
43
|
const StreamingCallbackToken = IDL.Record({
|
|
44
|
+
memory: Memory,
|
|
43
45
|
token: IDL.Opt(IDL.Text),
|
|
44
46
|
sha256: IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
45
47
|
headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
@@ -138,10 +140,12 @@ export const idlFactory = ({IDL}) => {
|
|
|
138
140
|
Managed: IDL.Null
|
|
139
141
|
});
|
|
140
142
|
const Rule = IDL.Record({
|
|
143
|
+
memory: IDL.Opt(Memory),
|
|
141
144
|
updated_at: IDL.Nat64,
|
|
142
145
|
max_size: IDL.Opt(IDL.Nat),
|
|
143
146
|
read: Permission,
|
|
144
147
|
created_at: IDL.Nat64,
|
|
148
|
+
mutable_permissions: IDL.Opt(IDL.Bool),
|
|
145
149
|
write: Permission
|
|
146
150
|
});
|
|
147
151
|
const SetController = IDL.Record({
|
|
@@ -159,9 +163,11 @@ export const idlFactory = ({IDL}) => {
|
|
|
159
163
|
description: IDL.Opt(IDL.Text)
|
|
160
164
|
});
|
|
161
165
|
const SetRule = IDL.Record({
|
|
166
|
+
memory: IDL.Opt(Memory),
|
|
162
167
|
updated_at: IDL.Opt(IDL.Nat64),
|
|
163
168
|
max_size: IDL.Opt(IDL.Nat),
|
|
164
169
|
read: Permission,
|
|
170
|
+
mutable_permissions: IDL.Opt(IDL.Bool),
|
|
165
171
|
write: Permission
|
|
166
172
|
});
|
|
167
173
|
const UploadChunk = IDL.Record({
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { createRequire as topLevelCreateRequire } from 'module';
|
|
2
2
|
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
-
var br=Object.create;var st=Object.defineProperty;var wr=Object.getOwnPropertyDescriptor;var xr=Object.getOwnPropertyNames;var vr=Object.getPrototypeOf,Nr=Object.prototype.hasOwnProperty;var at=(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 new Error('Dynamic require of "'+e+'" is not supported')});var z=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Rr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of xr(t))!Nr.call(e,o)&&o!==r&&st(e,o,{get:()=>t[o],enumerable:!(n=wr(t,o))||n.enumerable});return e};var ct=(e,t,r)=>(r=e!=null?br(vr(e)):{},Rr(t||!e||!e.__esModule?st(r,"default",{value:e,enumerable:!0}):r,e));var ge=z($=>{"use strict";Object.defineProperty($,"__esModule",{value:!0});$.PipeArrayBuffer=$.fromHexString=$.toHexString=$.concat=void 0;function Sr(...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}$.concat=Sr;function Ar(e){return new Uint8Array(e).reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")}$.toHexString=Ar;function Br(e){var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))}$.fromHexString=Br;var Ue=class{constructor(t,r=t?.byteLength||0){this._buffer=t||new ArrayBuffer(0),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return 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}};$.PipeArrayBuffer=Ue});var Me=z(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.idlLabelToId=void 0;function kr(e){let r=new TextEncoder().encode(e),n=0;for(let o of r)n=(n*223+o)%2**32;return n}function $r(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 kr(e)}Te.idlLabelToId=$r});var je=z(w=>{"use strict";Object.defineProperty(w,"__esModule",{value:!0});w.readIntLE=w.readUIntLE=w.writeIntLE=w.writeUIntLE=w.slebDecode=w.slebEncode=w.lebDecode=w.lebEncode=w.safeReadUint8=w.safeRead=void 0;var qe=ge();function Rt(){throw new Error("unexpected end of buffer")}function Vt(e,t){return e.byteLength<t&&Rt(),e.read(t)}w.safeRead=Vt;function be(e){let t=e.readUint8();return t===void 0&&Rt(),t}w.safeReadUint8=be;function Ur(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 qe.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}w.lebEncode=Ur;function Pt(e){let t=BigInt(1),r=BigInt(0),n;do n=be(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}w.lebDecode=Pt;function Mr(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 qe.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}w.slebEncode=Mr;function qr(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if(!(t[r]&64))return Pt(e);break}let n=new Uint8Array(Vt(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)}w.slebDecode=qr;function jr(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return Ct(e,t)}w.writeUIntLE=jr;function Ct(e,t){e=BigInt(e);let r=new qe.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}w.writeIntLE=Ct;function Ft(e,t){let r=BigInt(be(e)),n=BigInt(1),o=0;for(;++o<t;){n*=BigInt(256);let i=BigInt(be(e));r=r+n*i}return r}w.readUIntLE=Ft;function zr(e,t){let r=Ft(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}w.readIntLE=zr});var Et=z(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0});I.iexp2=I.ilog2=void 0;function Hr(e){let t=BigInt(e);if(e<=0)throw new RangeError("Input must be positive");return t.toString(2).length-1}I.ilog2=Hr;function Kr(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}I.iexp2=Kr});var Ge=z(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 Wr=at("@dfinity/principal"),f=ge(),k=Me(),c=je(),ze=Et(),we="DIDL",Ot=400;function me(e,t,r){return e.map((n,o)=>r(n,t[o]))}var He=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,f.concat)(...this._typs);return(0,f.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)}},Ke=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=Ke;var L=class{display(){return this.name}valueToString(t){return v(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}};s.Type=L;var A=class extends L{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=A;var M=class extends L{checkType(t){if(t instanceof q){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=M;var xe=class extends A{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=xe;var ve=class extends L{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 q?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=ve;var Ne=class extends A{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=Ne;var Re=class extends A{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=Re;var D=class extends A{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=D;var Ve=class extends A{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,f.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=Ve;var Pe=class extends A{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=Pe;var Ce=class extends A{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=Ce;var he=class extends A{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=he;var H=class extends A{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedInt(this,r)}covariant(t){let r=(0,ze.iexp2)(this._bits-1)*BigInt(-1),n=(0,ze.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=H;var U=class extends A{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedNat(this,r)}covariant(t){let r=(0,ze.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=U;var ee=class extends M{constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof U&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof U?this._type._bits:this._type instanceof H?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 Rr=Object.create;var lt=Object.defineProperty;var Vr=Object.getOwnPropertyDescriptor;var Pr=Object.getOwnPropertyNames;var Cr=Object.getPrototypeOf,Er=Object.prototype.hasOwnProperty;var ut=(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 j=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Fr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Pr(t))!Er.call(e,o)&&o!==r&<(e,o,{get:()=>t[o],enumerable:!(n=Vr(t,o))||n.enumerable});return e};var dt=(e,t,r)=>(r=e!=null?Rr(Cr(e)):{},Fr(t||!e||!e.__esModule?lt(r,"default",{value:e,enumerable:!0}):r,e));var fe=j(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.PipeArrayBuffer=M.fromHexString=M.toHexString=M.concat=void 0;function $r(...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=$r;function Ur(e){return new Uint8Array(e).reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")}M.toHexString=Ur;function qr(e){var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))}M.fromHexString=qr;var $e=class{constructor(t,r=t?.byteLength||0){this._buffer=t||new ArrayBuffer(0),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return 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=$e});var Ue=j(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.idlLabelToId=void 0;function jr(e){let r=new TextEncoder().encode(e),n=0;for(let o of r)n=(n*223+o)%2**32;return n}function zr(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 jr(e)}_e.idlLabelToId=zr});var je=j(w=>{"use strict";Object.defineProperty(w,"__esModule",{value:!0});w.readIntLE=w.readUIntLE=w.writeIntLE=w.writeUIntLE=w.slebDecode=w.slebEncode=w.lebDecode=w.lebEncode=w.safeReadUint8=w.safeRead=void 0;var qe=fe();function Ct(){throw new Error("unexpected end of buffer")}function Et(e,t){return e.byteLength<t&&Ct(),e.read(t)}w.safeRead=Et;function ye(e){let t=e.readUint8();return t===void 0&&Ct(),t}w.safeReadUint8=ye;function Hr(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 qe.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}w.lebEncode=Hr;function Ft(e){let t=BigInt(1),r=BigInt(0),n;do n=ye(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}w.lebDecode=Ft;function Kr(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 qe.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}w.slebEncode=Kr;function Wr(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if(!(t[r]&64))return Ft(e);break}let n=new Uint8Array(Et(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)}w.slebDecode=Wr;function Gr(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return Ot(e,t)}w.writeUIntLE=Gr;function Ot(e,t){e=BigInt(e);let r=new qe.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}w.writeIntLE=Ot;function St(e,t){let r=BigInt(ye(e)),n=BigInt(1),o=0;for(;++o<t;){n*=BigInt(256);let i=BigInt(ye(e));r=r+n*i}return r}w.readUIntLE=St;function Jr(e,t){let r=St(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}w.readIntLE=Jr});var At=j(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.iexp2=X.ilog2=void 0;function Yr(e){let t=BigInt(e);if(e<=0)throw new RangeError("Input must be positive");return t.toString(2).length-1}X.ilog2=Yr;function Qr(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}X.iexp2=Qr});var Ge=j(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 Xr=ut("@dfinity/principal"),f=fe(),k=Ue(),c=je(),ze=At(),ge="DIDL",Bt=400;function le(e,t,r){return e.map((n,o)=>r(n,t[o]))}var He=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,f.concat)(...this._typs);return(0,f.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)}},Ke=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=Ke;var Z=class{display(){return this.name}valueToString(t){return v(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}};s.Type=Z;var A=class extends Z{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=A;var U=class extends Z{checkType(t){if(t instanceof K){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=U;var Te=class extends A{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=Te;var be=class extends Z{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 K?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 we=class extends A{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=we;var xe=class extends A{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=xe;var I=class extends A{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=I;var ve=class extends A{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,f.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=ve;var Ne=class extends A{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=Ne;var Re=class extends A{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=Re;var ue=class extends A{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=ue;var z=class extends A{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedInt(this,r)}covariant(t){let r=(0,ze.iexp2)(this._bits-1)*BigInt(-1),n=(0,ze.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=z;var $=class extends A{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedNat(this,r)}covariant(t){let r=(0,ze.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=$;var Ve=class e extends U{constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof $&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof $?this._type._bits:this._type instanceof z?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: ${v(t)}`)}encodeValue(t){let r=(0,c.lebEncode)(t.length);if(this._blobOptimization)return(0,f.concat)(r,new Uint8Array(t));if(ArrayBuffer.isView(t))return(0,f.concat)(r,new Uint8Array(t.buffer));let n=new f.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,f.concat)(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof
|
|
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,f.concat)(r,new Uint8Array(t));if(ArrayBuffer.isView(t))return(0,f.concat)(r,new Uint8Array(t.buffer));let n=new f.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,f.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 $){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 z){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=Ve;var L=class e extends U{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: ${v(t)}`)}encodeValue(t){return t.length===0?new Uint8Array([0]):(0,f.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,f.concat)(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof
|
|
7
|
+
-> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${v(t)}`)}encodeValue(t){return t.length===0?new Uint8Array([0]):(0,f.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,f.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=L;var de=class e extends U{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: ${v(t)}`)}encodeValue(t){let r=this._fields.map(([o])=>t[o]),n=
|
|
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=le(this._fields,r,([,o],i)=>o.encodeValue(i));return(0,f.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,f.concat)((0,c.lebEncode)((0,k.idlLabelToId)(i)),a.encodeType(t)));t.add(this,(0,f.concat)(r,n,(0,f.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[d,p]=n._fields[a];if(i>=this._fields.length){p.decodeValue(t,p),a++;continue}let[u,y]=this._fields[i],g=(0,k.idlLabelToId)(this._fields[i][0]),N=(0,k.idlLabelToId)(d);if(g===N)o[u]=y.decodeValue(t,p),i++,a++;else if(N>g)if(y instanceof L||y instanceof I)o[u]=[],i++;else throw new Error("Cannot find required field "+u);else p.decodeValue(t,p),a++}for(let[d,p]of this._fields.slice(i))if(p instanceof L||p instanceof I)o[d]=[];else throw new Error("Cannot find required field "+d);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 {${le(this._fields,r,([o,i],a)=>o+"="+i.valueToString(a)).join("; ")}}`}};s.RecordClass=de;var Pe=class e extends de{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: ${v(t)}`)}encodeValue(t){let r=
|
|
11
|
+
index ${n} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${v(t)}`)}encodeValue(t){let r=le(this._components,t,(n,o)=>n.encodeValue(o));return(0,f.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 {${le(this._components,t,(n,o)=>n.valueToString(o)).join("; ")}}`}};s.TupleClass=Pe;var Ce=class e extends U{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: ${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,f.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,f.concat)((0,c.lebEncode)((0,k.idlLabelToId)(i)),a.encodeType(t)));t.add(this,(0,f.concat)(r,n,...o))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof
|
|
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,f.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,f.concat)((0,c.lebEncode)((0,k.idlLabelToId)(i)),a.encodeType(t)));t.add(this,(0,f.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[d,p]of this._fields)if((0,k.idlLabelToId)(i)===(0,k.idlLabelToId)(d)){let u=p.decodeValue(t,a);return{[d]:u}}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=Ce;var K=class e extends U{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=K;K._counter=0;function We(e){if((0,c.safeReadUint8)(e)!==1)throw new Error("Cannot decode principal");let r=Number((0,c.lebDecode)(e));return Xr.Principal.fromUint8Array(new Uint8Array((0,c.safeRead)(e,r)))}var Ee=class extends A{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,f.concat)(new Uint8Array([1]),n,r)}encodeType(){return(0,c.slebEncode)(-24)}decodeValue(t,r){return this.checkType(r),We(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}};s.PrincipalClass=Ee;var pe=class extends U{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,f.concat)(new Uint8Array([1]),o,n),a=new TextEncoder().encode(r),d=(0,c.lebEncode)(a.byteLength);return(0,f.concat)(new Uint8Array([1]),i,d,a)}_buildTypeTableImpl(t){this.argTypes.forEach(u=>u.buildTypeTable(t)),this.retTypes.forEach(u=>u.buildTypeTable(t));let r=(0,c.slebEncode)(-22),n=(0,c.lebEncode)(this.argTypes.length),o=(0,f.concat)(...this.argTypes.map(u=>u.encodeType(t))),i=(0,c.lebEncode)(this.retTypes.length),a=(0,f.concat)(...this.retTypes.map(u=>u.encodeType(t))),d=(0,c.lebEncode)(this.annotations.length),p=(0,f.concat)(...this.annotations.map(u=>this.encodeAnnotation(u)));t.add(this,(0,f.concat)(r,n,o,i,a,d,p))}decodeValue(t){if((0,c.safeReadUint8)(t)!==1)throw new Error("Cannot decode function reference");let n=We(t),o=Number((0,c.lebDecode)(t)),i=(0,c.safeRead)(t,o),d=new TextDecoder("utf8",{fatal:!0}).decode(i);return[n,d]}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=pe;var Fe=class extends U{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.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,f.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 d=new TextEncoder().encode(i),p=(0,c.lebEncode)(d.length);return(0,f.concat)(p,d,a.encodeType(t))});t.add(this,(0,f.concat)(r,n,...o))}decodeValue(t){return We(t)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(t){return`service "${t.toText()}"`}};s.ServiceClass=Fe;function v(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>Bt?t.substring(0,Bt-3)+"...":t}function Zr(e,t){if(t.length<e.length)throw Error("Wrong number of message arguments");let r=new He;e.forEach(p=>p.buildTypeTable(r));let n=new TextEncoder().encode(ge),o=r.encode(),i=(0,c.lebEncode)(t.length),a=(0,f.concat)(...e.map(p=>p.encodeType(r))),d=(0,f.concat)(...le(e,t,(p,u)=>{try{p.covariant(u)}catch(y){throw new Error(y.message+`
|
|
14
14
|
|
|
15
|
-
`)}return p.encodeValue(u)}));return(0,f.concat)(n,o,i,a,d)}s.encode=Gr;function Jr(e,t){let r=new f.PipeArrayBuffer(t);if(t.byteLength<we.length)throw new Error("Message length smaller than magic number");let n=(0,c.safeRead)(r,we.length),o=new TextDecoder().decode(n);if(o!==we)throw new Error("Wrong magic number: "+JSON.stringify(o));function i(l){let m=[],T=Number((0,c.lebDecode)(l));for(let _=0;_<T;_++){let V=Number((0,c.slebDecode)(l));switch(V){case-18:case-19:{let N=Number((0,c.slebDecode)(l));m.push([V,N]);break}case-20:case-21:{let N=[],P=Number((0,c.lebDecode)(l)),F;for(;P--;){let O=Number((0,c.lebDecode)(l));if(O>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof F=="number"&&F>=O)throw new Error("field id collision or not sorted");F=O;let S=Number((0,c.slebDecode)(l));N.push([O,S])}m.push([V,N]);break}case-22:{let N=[],P=Number((0,c.lebDecode)(l));for(;P--;)N.push(Number((0,c.slebDecode)(l)));let F=[],O=Number((0,c.lebDecode)(l));for(;O--;)F.push(Number((0,c.slebDecode)(l)));let S=[],j=Number((0,c.lebDecode)(l));for(;j--;)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([V,[N,F,S]]);break}case-23:{let N=Number((0,c.lebDecode)(l)),P=[];for(;N--;){let F=Number((0,c.lebDecode)(l)),O=new TextDecoder().decode((0,c.safeRead)(l,F)),S=(0,c.slebDecode)(l);P.push([O,S])}m.push([V,P]);break}default:throw new Error("Illegal op_code: "+V)}}let x=[],b=Number((0,c.lebDecode)(l));for(let _=0;_<b;_++)x.push(Number((0,c.slebDecode)(l)));return[m,x]}let[a,d]=i(r);if(d.length<e.length)throw new Error("Wrong number of return values");let p=a.map(l=>Ut());function u(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=u(l[1]);return At(m)}case-18:{let m=u(l[1]);return Bt(m)}case-20:{let m={};for(let[b,_]of l[1]){let V=`_${b}_`;m[V]=u(_)}let T=kt(m),x=T.tryAsTuple();return Array.isArray(x)?St(...x):T}case-21:{let m={};for(let[T,x]of l[1]){let b=`_${T}_`;m[b]=u(x)}return $t(m)}case-22:{let[m,T,x]=l[1];return Mt(m.map(b=>u(b)),T.map(b=>u(b)),x)}case-23:{let m={},T=l[1];for(let[x,b]of T){let _=u(b);if(_ instanceof q&&(_=_.getType()),!(_ instanceof fe))throw new Error("Illegal service definition: services can only contain functions");m[x]=_}return qt(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=d.map(l=>u(l)),C=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 C}s.decode=Jr;s.Empty=new xe;s.Reserved=new D;s.Unknown=new ve;s.Bool=new Ne;s.Null=new Re;s.Text=new Ve;s.Int=new Pe;s.Nat=new Ce;s.Float32=new he(32);s.Float64=new he(64);s.Int8=new H(8);s.Int16=new H(16);s.Int32=new H(32);s.Int64=new H(64);s.Nat8=new U(8);s.Nat16=new U(16);s.Nat32=new U(32);s.Nat64=new U(64);s.Principal=new Fe;function St(...e){return new te(e)}s.Tuple=St;function At(e){return new ee(e)}s.Vec=At;function Bt(e){return new W(e)}s.Opt=Bt;function kt(e){return new X(e)}s.Record=kt;function $t(e){return new re(e)}s.Variant=$t;function Ut(){return new q}s.Rec=Ut;function Mt(e,t,r=[]){return new fe(e,t,r)}s.Func=Mt;function qt(e){return new Ee(e)}s.Service=qt});var Le=z(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.VecForm=E.OptionForm=E.VariantForm=E.TupleForm=E.RecordForm=E.InputForm=E.InputBox=void 0;var Je=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)}};E.InputBox=Je;var G=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)}};E.InputForm=G;var Ye=class extends G{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}};E.RecordForm=Ye;var Qe=class extends G{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}};E.TupleForm=Qe;var Xe=class extends G{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}};E.VariantForm=Xe;var Ze=class extends G{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]}}};E.OptionForm=Ze;var Ie=class extends G{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}};E.VecForm=Ie});var zt=z(h=>{"use strict";var Yr=h&&h.__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]}),Qr=h&&h.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),jt=h&&h.__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)&&Yr(t,e,r);return Qr(t,e),t};Object.defineProperty(h,"__esModule",{value:!0});h.renderValue=h.renderInput=h.Render=h.vecForm=h.optForm=h.variantForm=h.tupleForm=h.recordForm=h.inputBox=void 0;var Se=jt(Ge()),De=at("@dfinity/principal"),ne=jt(Le()),Xr={parse:rn},_e={render:nt},Zr=(e,t)=>new ne.InputBox(e,Object.assign(Object.assign({},Xr),t));h.inputBox=Zr;var Ir=(e,t)=>new ne.RecordForm(e,Object.assign(Object.assign({},_e),t));h.recordForm=Ir;var Lr=(e,t)=>new ne.TupleForm(e,Object.assign(Object.assign({},_e),t));h.tupleForm=Lr;var Dr=(e,t)=>new ne.VariantForm(e,Object.assign(Object.assign({},_e),t));h.variantForm=Dr;var en=(e,t)=>new ne.OptionForm(e,Object.assign(Object.assign({},_e),t));h.optForm=en;var tn=(e,t)=>new ne.VecForm(e,Object.assign(Object.assign({},_e),t));h.vecForm=tn;var Oe=class extends Se.Visitor{visitType(t,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=t.display(),(0,h.inputBox)(t,{input:n})}visitNull(t,r){return(0,h.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,h.recordForm)(r,o);return(0,h.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,h.tupleForm)(r,o);return(0,h.inputBox)(t,{form:i})}visitVariant(t,r,n){let o=document.createElement("select");for(let[d,p]of r){let u=new Option(d);o.add(u)}o.selectedIndex=-1,o.classList.add("open");let i={open:o,event:"change"},a=(0,h.variantForm)(r,i);return(0,h.inputBox)(t,{form:a})}visitOpt(t,r,n){let o=document.createElement("input");o.type="checkbox",o.classList.add("open");let i=(0,h.optForm)(r,{open:o,event:"change"});return(0,h.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,h.vecForm)(r,{open:o,event:"change",container:i});return(0,h.inputBox)(t,{form:a})}visitRec(t,r,n){return nt(r)}};h.Render=Oe;var et=class extends Se.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 De.Principal.fromText(r)}visitService(t,r){return De.Principal.fromText(r)}visitFunc(t,r){let n=r.split(".",2);return[De.Principal.fromText(n[0]),n[1]]}},tt=class extends Se.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 rn(e,t,r){return t.random&&r===""?e.accept(new tt,r):e.accept(new et,r)}function nt(e){return e.accept(new Oe,null)}h.renderInput=nt;function Z(e,t,r){return e.accept(new rt,{input:t,value:r})}h.renderValue=Z;var rt=class extends Se.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){Z(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)),Z(r,o.form[0],n.value[0])}}visitRecord(t,r,n){let o=n.input.ui.form;r.forEach(([i,a],d)=>{Z(a,o.form[d],n.value[i])})}visitTuple(t,r,n){let o=n.input.ui.form;r.forEach((i,a)=>{Z(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,d],p)=>{if(a===i[0]){let u=o.ui.open;u.selectedIndex=p,u.dispatchEvent(new Event(o.ui.event)),Z(d,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((d,p)=>{Z(r,o.form[p],d)})}}});var Kt=z(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0})});var ot=z(R=>{"use strict";var Wt=R&&R.__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]}),nn=R&&R.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),oe=R&&R.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Wt(t,e,r)},on=R&&R.__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)&&Wt(t,e,r);return nn(t,e),t};Object.defineProperty(R,"__esModule",{value:!0});R.IDL=void 0;oe(zt(),R);oe(Le(),R);R.IDL=on(Ge());oe(Me(),R);oe(je(),R);oe(ge(),R);oe(Kt(),R)});import{Principal as sn}from"@dfinity/principal";import{Principal as _t}from"@dfinity/principal";var lt=({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=e.Record({network:t}),a=e.Nat64,d=e.Record({network:t,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:r}),p=e.Vec(e.Nat8),u=e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32}),y=e.Record({height:e.Nat32,value:o,outpoint:u}),g=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:e.Nat32,tip_block_hash:p,utxos:e.Vec(y)}),C=e.Record({transaction:e.Vec(e.Nat8),network:t}),l=e.Principal,m=e.Variant({from_user:e.Record({user_id:e.Principal}),from_canister:e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal})}),T=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}),x=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:m,details:T}),b=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),_=e.Record({freezing_threshold:e.Opt(e.Nat),controllers:e.Opt(e.Vec(e.Principal)),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),V=e.Variant({secp256k1:e.Null}),N=e.Record({value:e.Text,name:e.Text}),P=e.Record({status:e.Nat,body:e.Vec(e.Nat8),headers:e.Vec(N)}),F=e.Vec(e.Nat8);return e.Service({bitcoin_get_balance:e.Func([n],[o],[]),bitcoin_get_current_fee_percentiles:e.Func([i],[e.Vec(a)],[]),bitcoin_get_utxos:e.Func([d],[g],[]),bitcoin_send_transaction:e.Func([C],[],[]),canister_info:e.Func([e.Record({canister_id:l,num_requested_changes:e.Opt(e.Nat64)})],[e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec(x),total_num_changes:e.Nat64})],[]),canister_status:e.Func([e.Record({canister_id:l})],[e.Record({status:e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),memory_size:e.Nat,cycles:e.Nat,settings:b,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))})],[]),create_canister:e.Func([e.Record({settings:e.Opt(_),sender_canister_version:e.Opt(e.Nat64)})],[e.Record({canister_id:l})],[]),delete_canister:e.Func([e.Record({canister_id:l})],[],[]),deposit_cycles:e.Func([e.Record({canister_id:l})],[],[]),ecdsa_public_key:e.Func([e.Record({key_id:e.Record({name:e.Text,curve:V}),canister_id:e.Opt(l),derivation_path:e.Vec(e.Vec(e.Nat8))})],[e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)})],[]),http_request:e.Func([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:P})],[P],["query"]),context:e.Vec(e.Nat8)})),headers:e.Vec(N)})],[P],[]),install_code:e.Func([e.Record({arg:e.Vec(e.Nat8),wasm_module:F,mode:e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),canister_id:l,sender_canister_version:e.Opt(e.Nat64)})],[],[]),provisional_create_canister_with_cycles:e.Func([e.Record({settings:e.Opt(_),specified_id:e.Opt(l),amount:e.Opt(e.Nat)})],[e.Record({canister_id:l})],[]),provisional_top_up_canister:e.Func([e.Record({canister_id:l,amount:e.Nat})],[],[]),raw_rand:e.Func([],[e.Vec(e.Nat8)],[]),sign_with_ecdsa:e.Func([e.Record({key_id:e.Record({name:e.Text,curve:V}),derivation_path:e.Vec(e.Vec(e.Nat8)),message_hash:e.Vec(e.Nat8)})],[e.Record({signature:e.Vec(e.Nat8)})],[]),start_canister:e.Func([e.Record({canister_id:l})],[],[]),stop_canister:e.Func([e.Record({canister_id:l})],[],[]),uninstall_code:e.Func([e.Record({canister_id:l,sender_canister_version:e.Opt(e.Nat64)})],[],[]),update_settings:e.Func([e.Record({canister_id:e.Principal,settings:_,sender_canister_version:e.Opt(e.Nat64)})],[],[])})};var ut=({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.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.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),a=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),d=e.Record({status:i,memory_size:e.Nat,cycles:e.Nat,settings:a,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),p=e.Record({id:e.Principal,status:d,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),status_at:e.Nat64}),u=e.Variant({Ok:p,Err:e.Text}),y=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:n,expires_at:e.Opt(e.Nat64)}),g=e.Record({enabled:e.Bool,cycles_threshold:e.Opt(e.Nat64)}),C=e.Record({mission_control_cycles_threshold:e.Opt(e.Nat64),orbiters:e.Vec(e.Tuple(e.Principal,g)),satellites:e.Vec(e.Tuple(e.Principal,g)),cycles_threshold:e.Opt(e.Nat64)}),l=e.Record({orbiters:e.Opt(e.Vec(u)),satellites:e.Opt(e.Vec(u)),mission_control:u}),m=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_orbiters_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),del_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),get_user:e.Func([],[e.Principal],["query"]),list_mission_control_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,o))],["query"]),list_mission_control_statuses:e.Func([],[e.Vec(e.Tuple(e.Nat64,u))],["query"]),list_orbiter_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,u)))],["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,u)))],["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),y],[],[]),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),y],[],[]),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),y],[],[]),status:e.Func([C],[l],[]),top_up:e.Func([e.Principal,m],[],[]),version:e.Func([],[e.Text],["query"])})};var dt=({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({updated_at:e.Opt(e.Nat64)}),i=e.Record({to:e.Opt(e.Nat64),from:e.Opt(e.Nat64),satellite_id:e.Opt(e.Principal)}),a=e.Record({key:e.Text,collected_at:e.Nat64}),d=e.Record({inner_height:e.Nat16,inner_width:e.Nat16}),p=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:d,user_agent:e.Opt(e.Text)}),u=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}),y=e.Record({updated_at:e.Nat64,created_at:e.Nat64,enabled:e.Bool}),g=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:r,expires_at:e.Opt(e.Nat64)}),C=e.Record({controller:g,controllers:e.Vec(e.Principal)}),l=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:d,user_agent:e.Opt(e.Text)}),m=e.Variant({Ok:p,Err:e.Text}),T=e.Variant({Ok:e.Null,Err:e.Vec(e.Tuple(a,e.Text))}),x=e.Record({updated_at:e.Opt(e.Nat64),enabled:e.Bool}),b=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,user_agent:e.Opt(e.Text)}),_=e.Variant({Ok:u,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],[],[]),get_page_views:e.Func([i],[e.Vec(e.Tuple(a,p))],["query"]),get_track_events:e.Func([i],[e.Vec(e.Tuple(a,u))],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_satellite_configs:e.Func([],[e.Vec(e.Tuple(e.Principal,y))],["query"]),set_controllers:e.Func([C],[e.Vec(e.Tuple(e.Principal,n))],[]),set_page_view:e.Func([a,l],[m],[]),set_page_views:e.Func([e.Vec(e.Tuple(a,l))],[T],[]),set_satellite_configs:e.Func([e.Vec(e.Tuple(e.Principal,x))],[e.Vec(e.Tuple(e.Principal,y))],[]),set_track_event:e.Func([a,b],[_],[]),set_track_events:e.Func([e.Vec(e.Tuple(a,b))],[T],[]),version:e.Func([],[e.Text],["query"])})};var pt=({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}),d=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))}),u=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:u,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}),C=e.Record({token:e.Opt(u),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}),x=e.Record({field:T,desc:e.Bool}),b=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),_=e.Record({order:e.Opt(x),owner:e.Opt(e.Principal),matcher:e.Opt(e.Text),paginate:e.Opt(b)}),V=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),N=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),P=e.Record({key:V,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}),F=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,P))}),O=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,d))}),j=e.Variant({Db:e.Null,Storage:e.Null}),B=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),ie=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:B,created_at:e.Nat64,write:B}),K=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),se=e.Record({controller:K,controllers:e.Vec(e.Principal)}),ae=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),ce=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:B,write:B}),le=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),ue=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(d)],["query"]),http_request:e.Func([p],[g],["query"]),http_request_streaming_callback:e.Func([u],[C],["query"]),init_asset_upload:e.Func([l],[m],[]),list_assets:e.Func([e.Opt(e.Text),_],[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,O))],["query"]),list_docs:e.Func([e.Text,_],[S],["query"]),list_rules:e.Func([j],[e.Vec(e.Tuple(e.Text,ie))],["query"]),set_config:e.Func([a],[],[]),set_controllers:e.Func([se],[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,ae],[d],[]),set_rule:e.Func([j,e.Text,ce],[],[]),upload_asset_chunk:e.Func([le],[ue],[]),version:e.Func([],[e.Text],["query"])})};var mt=({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}),d=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))}),u=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:u,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}),C=e.Record({token:e.Opt(u),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}),x=e.Record({field:T,desc:e.Bool}),b=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),_=e.Record({order:e.Opt(x),matcher:e.Opt(e.Text),paginate:e.Opt(b)}),V=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),N=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),P=e.Record({key:V,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}),F=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,P))}),O=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,d))}),j=e.Variant({Db:e.Null,Storage:e.Null}),B=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),ie=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:B,created_at:e.Nat64,write:B}),K=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),se=e.Record({controller:K,controllers:e.Vec(e.Principal)}),ae=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),ce=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:B,write:B}),le=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),ue=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(d)],["query"]),http_request:e.Func([p],[g],["query"]),http_request_streaming_callback:e.Func([u],[C],["query"]),init_asset_upload:e.Func([l],[m],[]),list_assets:e.Func([e.Opt(e.Text),_],[F],["query"]),list_controllers:e.Func([],[e.Vec(e.Principal)],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,O))],["query"]),list_docs:e.Func([e.Text,_],[S],["query"]),list_rules:e.Func([j],[e.Vec(e.Tuple(e.Text,ie))],["query"]),set_config:e.Func([a],[],[]),set_controllers:e.Func([se],[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,ae],[d],[]),set_rule:e.Func([j,e.Text,ce],[],[]),upload_asset_chunk:e.Func([le],[ue],[]),version:e.Func([],[e.Text],["query"])})};var ht=({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({updated_at:e.Opt(e.Nat64)}),a=e.Variant({Db:e.Null,Storage:e.Null}),d=e.Record({rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),p=e.Record({storage:d}),u=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64}),y=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),g=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}),C=e.Variant({Callback:e.Record({token:g,callback:e.Func([],[],["query"])})}),l=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(C),status_code:e.Nat16}),m=e.Record({token:e.Opt(g),body:e.Vec(e.Nat8)}),T=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}),x=e.Record({batch_id:e.Nat}),b=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),_=e.Record({field:b,desc:e.Bool}),V=e.Record({key:e.Opt(e.Text),description:e.Opt(e.Text)}),N=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),P=e.Record({order:e.Opt(_),owner:e.Opt(e.Principal),matcher:e.Opt(V),paginate:e.Opt(N)}),F=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),O=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),S=e.Record({key:F,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,O)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),j=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,S)),items_length:e.Nat64}),B=e.Record({updated_at:e.Nat64,created_at: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}),K=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),se=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:K,created_at:e.Nat64,write:K}),ae=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:n,expires_at:e.Opt(e.Nat64)}),ce=e.Record({controller:ae,controllers:e.Vec(e.Principal)}),le=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8),description:e.Opt(e.Text)}),ue=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:K,write:K}),gr=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Tr=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.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_rule:e.Func([a,e.Text,i],[],[]),get_config:e.Func([],[p],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(u)],["query"]),http_request:e.Func([y],[l],["query"]),http_request_streaming_callback:e.Func([g],[m],["query"]),init_asset_upload:e.Func([T],[x],[]),list_assets:e.Func([e.Text,P],[j],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,o))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,B))],["query"]),list_docs:e.Func([e.Text,P],[ie],["query"]),list_rules:e.Func([a],[e.Vec(e.Tuple(e.Text,se))],["query"]),set_config:e.Func([p],[],[]),set_controllers:e.Func([ce],[e.Vec(e.Tuple(e.Principal,o))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,le],[u],[]),set_rule:e.Func([a,e.Text,ue],[],[]),upload_asset_chunk:e.Func([gr],[Tr],[]),version:e.Func([],[e.Text],["query"])})};import{Actor as Vr,HttpAgent as Pr}from"@dfinity/agent";var Be=async({canisterId:e,idlFactory:t,identity:r,fetch:n,env:o="prod",config:i})=>{let a=o==="dev"?"http://127.0.0.1:8000/":"https://icp-api.io",d=new Pr({identity:r,...a&&{host:a},...n&&{fetch:n}});return o==="dev"&&await d.fetchRootKey(),Vr.createActor(t,{agent:d,canisterId:e,...i!==void 0?i:{}})};var yt=async({satelliteId:e,...t})=>pe({canisterId:e,...t,idlFactory:mt}),Y=async({satelliteId:e,...t})=>pe({canisterId:e,...t,idlFactory:ht}),gt=async({satelliteId:e,...t})=>pe({canisterId:e,...t,idlFactory:pt}),de=async({missionControlId:e,...t})=>pe({canisterId:e,...t,idlFactory:ut}),ke=async({orbiterId:e,...t})=>pe({canisterId:e,...t,idlFactory:dt});var pe=async({canisterId:e,idlFactory:t,...r})=>{if(!e)throw new Error("No canister ID provided.");return Be({canisterId:e,idlFactory:t,...r})},Tt=_t.fromText("aaaaa-aa"),ft=(e,t,r)=>{let n=t[0],o=Tt;return n&&typeof n=="object"&&n.canister_id&&(o=_t.from(n.canister_id)),{effectiveCanisterId:o}},bt=e=>Be({canisterId:Tt.toText(),config:{callTransform:ft,queryTransform:ft},idlFactory:lt,...e});var Q=async({actor:e,code:t})=>{let{install_code:r}=await bt(e);return r({...t,sender_canister_version:[]})};var wt=async({missionControl:e})=>(await de(e)).version(),xt=async({missionControl:e})=>(await de(e)).get_user();var vt=async({missionControl:e,satelliteIds:t,controllerIds:r,controller:n})=>(await de(e)).set_satellites_controllers(t,r,n),Nt=async({missionControl:e,controllerIds:t,controller:r})=>(await de(e)).set_mission_control_controllers(t,r);import{Principal as Cr}from"@dfinity/principal";import{nonNullish as Fr,toNullable as Er}from"@junobuild/utils";var $e=({controllerId:e,profile:t})=>({controllerIds:[Cr.fromText(e)],controller:Or(t)}),Or=e=>({metadata:Fr(e)&&e!==""?[["profile",e]]:[],expires_at:Er(void 0),scope:{Admin:null}});var J=ct(ot(),1),Gt=e=>J.IDL.encode([J.IDL.Record({user:J.IDL.Principal})],[{user:e}]),Ae=e=>J.IDL.encode([J.IDL.Record({controllers:J.IDL.Vec(J.IDL.Principal)})],[{controllers:e.map(([t,r])=>t)}]);var to=async e=>wt(e),ro=async({missionControl:e,wasm_module:t})=>{let r=await xt({missionControl:e}),{missionControlId:n,...o}=e;if(!n)throw new Error("No mission control principal defined.");let i=Gt(r);await Q({actor:o,code:{canister_id:sn.fromText(n),arg:new Uint8Array(i),wasm_module:t,mode:{upgrade:null}}})},no=async({controllerId:e,profile:t,...r})=>vt({...r,...$e({controllerId:e,profile:t})}),oo=async({controllerId:e,profile:t,...r})=>Nt({...r,...$e({controllerId:e,profile:t})});import{Principal as an}from"@dfinity/principal";var Jt=async({orbiter:e})=>(await ke(e)).version(),Yt=async({orbiter:e})=>(await ke(e)).list_controllers();var mo=async e=>Jt(e),ho=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 Yt({orbiter:e}),a=Ae(i);await Q({actor:o,code:{canister_id:an.fromText(n),arg:new Uint8Array(a),wasm_module:t,mode:r?{reinstall:null}:{upgrade:null}}})};import{major as Qt,minor as Xt,patch as Zt}from"semver";var yo=({currentVersion:e,selectedVersion:t})=>{let r=Qt(e),n=Qt(t),o=Xt(e),i=Xt(t),a=Zt(e),d=Zt(t);return r<n-1||o<i-1||a<d-1?{canUpgrade:!1}:{canUpgrade:!0}};var ye=ct(ot(),1);import{Principal as yr}from"@dfinity/principal";import{fromNullable as dn}from"@junobuild/utils";var It=async({config:e,satellite:t})=>(await Y(t)).set_config(e),Lt=async({satellite:e,type:t})=>(await Y(e)).list_rules(t),Dt=async({type:e,collection:t,rule:r,satellite:n})=>(await Y(n)).set_rule(e,t,r),er=async({satellite:e})=>(await Y(e)).version(),tr=async({satellite:e})=>(await yt(e)).list_controllers(),rr=async({satellite:e})=>(await gt(e)).list_controllers(),nr=async({satellite:e})=>(await Y(e)).list_controllers(),or=async({satellite:e})=>(await Y(e)).list_custom_domains();var ir=[{source:"**",destination:"/index.html"}];import{fromNullable as cn,isNullish as ln,nonNullish as hr,toNullable as un}from"@junobuild/utils";var sr={Db:null},ar={Storage:null},cr={Public:null},lr={Private:null},ur={Managed:null},dr={Controllers:null};var it=e=>e==="storage"?ar:sr,fr=({read:e,write:t,max_size:r,updated_at:n})=>({read:mr(e),write:mr(t),updated_at:ln(n)?[]:[n],max_size:un(hr(r)&&r>0?BigInt(r):void 0)}),_r=([e,t])=>{let{read:r,write:n,updated_at:o,created_at:i,max_size:a}=t,d=a?.[0]??0n>0n?Number(cn(a)):void 0;return{collection:e,read:pr(r),write:pr(n),updated_at:o,created_at:i,...hr(d)&&{max_size:d}}},pr=e=>"Public"in e?"public":"Private"in e?"private":"Managed"in e?"managed":"controllers",mr=e=>{switch(e){case"public":return cr;case"private":return lr;case"managed":return ur;default:return dr}};var Ao=async({config:{storage:{headers:e,rewrites:t}},satellite:r})=>{let n=(e??[]).map(({source:i,headers:a})=>[i,a]),o=(t??ir).map(({source:i,destination:a})=>[i,a]);return It({satellite:r,config:{storage:{headers:n,rewrites:o}}})},Bo=async({type:e,satellite:t})=>(await Lt({satellite:t,type:it(e)})).map(n=>_r(n)),ko=async({rule:{collection:e,...t},type:r,satellite:n})=>Dt({type:it(r),rule:fr(t),satellite:n,collection:e}),$o=async e=>er(e),Uo=async({satellite:e,wasm_module:t,deprecated:r,deprecatedNoScope:n,reset:o=!1})=>{let{satelliteId:i,...a}=e;if(!i)throw new Error("No satellite principal defined.");if(r){let y=await tr({satellite:e}),g=ye.IDL.encode([ye.IDL.Record({controllers:ye.IDL.Vec(ye.IDL.Principal)})],[{controllers:y}]);await Q({actor:a,code:{canister_id:yr.fromText(i),arg:new Uint8Array(g),wasm_module:t,mode:o?{reinstall:null}:{upgrade:null}}});return}let p=await(n?rr:nr)({satellite:e}),u=Ae(p);await Q({actor:a,code:{canister_id:yr.fromText(i),arg:new Uint8Array(u),wasm_module:t,mode:o?{reinstall:null}:{upgrade:null}}})},Mo=async({satellite:e})=>(await or({satellite:e})).map(([r,n])=>({domain:r,bn_id:dn(n.bn_id),created_at:n.created_at,updated_at:n.updated_at}));export{yo as checkUpgradeVersion,Mo as listCustomDomains,Bo as listRules,to as missionControlVersion,mo as orbiterVersion,$o as satelliteVersion,Ao as setConfig,oo as setMissionControlController,ko as setRule,no as setSatellitesController,ro as upgradeMissionControl,ho as upgradeOrbiter,Uo as upgradeSatellite};
|
|
15
|
+
`)}return p.encodeValue(u)}));return(0,f.concat)(n,o,i,a,d)}s.encode=Zr;function Ir(e,t){let r=new f.PipeArrayBuffer(t);if(t.byteLength<ge.length)throw new Error("Message length smaller than magic number");let n=(0,c.safeRead)(r,ge.length),o=new TextDecoder().decode(n);if(o!==ge)throw new Error("Wrong magic number: "+JSON.stringify(o));function i(l){let m=[],T=Number((0,c.lebDecode)(l));for(let _=0;_<T;_++){let P=Number((0,c.slebDecode)(l));switch(P){case-18:case-19:{let R=Number((0,c.slebDecode)(l));m.push([P,R]);break}case-20:case-21:{let R=[],E=Number((0,c.lebDecode)(l)),C;for(;E--;){let O=Number((0,c.lebDecode)(l));if(O>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof C=="number"&&C>=O)throw new Error("field id collision or not sorted");C=O;let S=Number((0,c.slebDecode)(l));R.push([O,S])}m.push([P,R]);break}case-22:{let R=[],E=Number((0,c.lebDecode)(l));for(;E--;)R.push(Number((0,c.slebDecode)(l)));let C=[],O=Number((0,c.lebDecode)(l));for(;O--;)C.push(Number((0,c.slebDecode)(l)));let S=[],q=Number((0,c.lebDecode)(l));for(;q--;)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,[R,C,S]]);break}case-23:{let R=Number((0,c.lebDecode)(l)),E=[];for(;R--;){let C=Number((0,c.lebDecode)(l)),O=new TextDecoder().decode((0,c.safeRead)(l,C)),S=(0,c.slebDecode)(l);E.push([O,S])}m.push([P,E]);break}default:throw new Error("Illegal op_code: "+P)}}let x=[],b=Number((0,c.lebDecode)(l));for(let _=0;_<b;_++)x.push(Number((0,c.slebDecode)(l)));return[m,x]}let[a,d]=i(r);if(d.length<e.length)throw new Error("Wrong number of return values");let p=a.map(l=>jt());function u(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=u(l[1]);return Mt(m)}case-18:{let m=u(l[1]);return $t(m)}case-20:{let m={};for(let[b,_]of l[1]){let P=`_${b}_`;m[P]=u(_)}let T=Ut(m),x=T.tryAsTuple();return Array.isArray(x)?kt(...x):T}case-21:{let m={};for(let[T,x]of l[1]){let b=`_${T}_`;m[b]=u(x)}return qt(m)}case-22:{let[m,T,x]=l[1];return zt(m.map(b=>u(b)),T.map(b=>u(b)),x)}case-23:{let m={},T=l[1];for(let[x,b]of T){let _=u(b);if(_ instanceof K&&(_=_.getType()),!(_ instanceof pe))throw new Error("Illegal service definition: services can only contain functions");m[x]=_}return Ht(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=d.map(l=>u(l)),N=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 N}s.decode=Ir;s.Empty=new Te;s.Reserved=new I;s.Unknown=new be;s.Bool=new we;s.Null=new xe;s.Text=new ve;s.Int=new Ne;s.Nat=new Re;s.Float32=new ue(32);s.Float64=new ue(64);s.Int8=new z(8);s.Int16=new z(16);s.Int32=new z(32);s.Int64=new z(64);s.Nat8=new $(8);s.Nat16=new $(16);s.Nat32=new $(32);s.Nat64=new $(64);s.Principal=new Ee;function kt(...e){return new Pe(e)}s.Tuple=kt;function Mt(e){return new Ve(e)}s.Vec=Mt;function $t(e){return new L(e)}s.Opt=$t;function Ut(e){return new de(e)}s.Record=Ut;function qt(e){return new Ce(e)}s.Variant=qt;function jt(){return new K}s.Rec=jt;function zt(e,t,r=[]){return new pe(e,t,r)}s.Func=zt;function Ht(e){return new Fe(e)}s.Service=Ht});var Le=j(F=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.VecForm=F.OptionForm=F.VariantForm=F.TupleForm=F.RecordForm=F.InputForm=F.InputBox=void 0;var Je=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)}};F.InputBox=Je;var W=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)}};F.InputForm=W;var Ye=class extends W{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}};F.RecordForm=Ye;var Qe=class extends W{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}};F.TupleForm=Qe;var Xe=class extends W{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}};F.VariantForm=Xe;var Ze=class extends W{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]}}};F.OptionForm=Ze;var Ie=class extends W{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}};F.VecForm=Ie});var Wt=j(h=>{"use strict";var Lr=h&&h.__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]}),Dr=h&&h.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Kt=h&&h.__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)&&Lr(t,e,r);return Dr(t,e),t};Object.defineProperty(h,"__esModule",{value:!0});h.renderValue=h.renderInput=h.Render=h.vecForm=h.optForm=h.variantForm=h.tupleForm=h.recordForm=h.inputBox=void 0;var Se=Kt(Ge()),De=ut("@dfinity/principal"),D=Kt(Le()),en={parse:cn},me={render:nt},tn=(e,t)=>new D.InputBox(e,Object.assign(Object.assign({},en),t));h.inputBox=tn;var rn=(e,t)=>new D.RecordForm(e,Object.assign(Object.assign({},me),t));h.recordForm=rn;var nn=(e,t)=>new D.TupleForm(e,Object.assign(Object.assign({},me),t));h.tupleForm=nn;var on=(e,t)=>new D.VariantForm(e,Object.assign(Object.assign({},me),t));h.variantForm=on;var sn=(e,t)=>new D.OptionForm(e,Object.assign(Object.assign({},me),t));h.optForm=sn;var an=(e,t)=>new D.VecForm(e,Object.assign(Object.assign({},me),t));h.vecForm=an;var Oe=class extends Se.Visitor{visitType(t,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=t.display(),(0,h.inputBox)(t,{input:n})}visitNull(t,r){return(0,h.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,h.recordForm)(r,o);return(0,h.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,h.tupleForm)(r,o);return(0,h.inputBox)(t,{form:i})}visitVariant(t,r,n){let o=document.createElement("select");for(let[d,p]of r){let u=new Option(d);o.add(u)}o.selectedIndex=-1,o.classList.add("open");let i={open:o,event:"change"},a=(0,h.variantForm)(r,i);return(0,h.inputBox)(t,{form:a})}visitOpt(t,r,n){let o=document.createElement("input");o.type="checkbox",o.classList.add("open");let i=(0,h.optForm)(r,{open:o,event:"change"});return(0,h.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,h.vecForm)(r,{open:o,event:"change",container:i});return(0,h.inputBox)(t,{form:a})}visitRec(t,r,n){return nt(r)}};h.Render=Oe;var et=class extends Se.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 De.Principal.fromText(r)}visitService(t,r){return De.Principal.fromText(r)}visitFunc(t,r){let n=r.split(".",2);return[De.Principal.fromText(n[0]),n[1]]}},tt=class extends Se.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 cn(e,t,r){return t.random&&r===""?e.accept(new tt,r):e.accept(new et,r)}function nt(e){return e.accept(new Oe,null)}h.renderInput=nt;function Q(e,t,r){return e.accept(new rt,{input:t,value:r})}h.renderValue=Q;var rt=class extends Se.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){Q(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)),Q(r,o.form[0],n.value[0])}}visitRecord(t,r,n){let o=n.input.ui.form;r.forEach(([i,a],d)=>{Q(a,o.form[d],n.value[i])})}visitTuple(t,r,n){let o=n.input.ui.form;r.forEach((i,a)=>{Q(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,d],p)=>{if(a===i[0]){let u=o.ui.open;u.selectedIndex=p,u.dispatchEvent(new Event(o.ui.event)),Q(d,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((d,p)=>{Q(r,o.form[p],d)})}}});var Jt=j(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0})});var ot=j(V=>{"use strict";var Yt=V&&V.__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]}),ln=V&&V.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),ee=V&&V.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Yt(t,e,r)},un=V&&V.__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)&&Yt(t,e,r);return ln(t,e),t};Object.defineProperty(V,"__esModule",{value:!0});V.IDL=void 0;ee(Wt(),V);ee(Le(),V);V.IDL=un(Ge());ee(Ue(),V);ee(je(),V);ee(fe(),V);ee(Jt(),V)});import{Principal as dn}from"@dfinity/principal";import{Principal as Tt}from"@dfinity/principal";var pt=({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=e.Record({network:t}),a=e.Nat64,d=e.Record({network:t,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:r}),p=e.Vec(e.Nat8),u=e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32}),y=e.Record({height:e.Nat32,value:o,outpoint:u}),g=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:e.Nat32,tip_block_hash:p,utxos:e.Vec(y)}),N=e.Record({transaction:e.Vec(e.Nat8),network:t}),l=e.Principal,m=e.Variant({from_user:e.Record({user_id:e.Principal}),from_canister:e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal})}),T=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}),x=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:m,details:T}),b=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),_=e.Record({freezing_threshold:e.Opt(e.Nat),controllers:e.Opt(e.Vec(e.Principal)),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),P=e.Variant({secp256k1:e.Null}),R=e.Record({value:e.Text,name:e.Text}),E=e.Record({status:e.Nat,body:e.Vec(e.Nat8),headers:e.Vec(R)}),C=e.Vec(e.Nat8);return e.Service({bitcoin_get_balance:e.Func([n],[o],[]),bitcoin_get_current_fee_percentiles:e.Func([i],[e.Vec(a)],[]),bitcoin_get_utxos:e.Func([d],[g],[]),bitcoin_send_transaction:e.Func([N],[],[]),canister_info:e.Func([e.Record({canister_id:l,num_requested_changes:e.Opt(e.Nat64)})],[e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec(x),total_num_changes:e.Nat64})],[]),canister_status:e.Func([e.Record({canister_id:l})],[e.Record({status:e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),memory_size:e.Nat,cycles:e.Nat,settings:b,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))})],[]),create_canister:e.Func([e.Record({settings:e.Opt(_),sender_canister_version:e.Opt(e.Nat64)})],[e.Record({canister_id:l})],[]),delete_canister:e.Func([e.Record({canister_id:l})],[],[]),deposit_cycles:e.Func([e.Record({canister_id:l})],[],[]),ecdsa_public_key:e.Func([e.Record({key_id:e.Record({name:e.Text,curve:P}),canister_id:e.Opt(l),derivation_path:e.Vec(e.Vec(e.Nat8))})],[e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)})],[]),http_request:e.Func([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(R)})],[E],[]),install_code:e.Func([e.Record({arg:e.Vec(e.Nat8),wasm_module:C,mode:e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),canister_id:l,sender_canister_version:e.Opt(e.Nat64)})],[],[]),provisional_create_canister_with_cycles:e.Func([e.Record({settings:e.Opt(_),specified_id:e.Opt(l),amount:e.Opt(e.Nat)})],[e.Record({canister_id:l})],[]),provisional_top_up_canister:e.Func([e.Record({canister_id:l,amount:e.Nat})],[],[]),raw_rand:e.Func([],[e.Vec(e.Nat8)],[]),sign_with_ecdsa:e.Func([e.Record({key_id:e.Record({name:e.Text,curve:P}),derivation_path:e.Vec(e.Vec(e.Nat8)),message_hash:e.Vec(e.Nat8)})],[e.Record({signature:e.Vec(e.Nat8)})],[]),start_canister:e.Func([e.Record({canister_id:l})],[],[]),stop_canister:e.Func([e.Record({canister_id:l})],[],[]),uninstall_code:e.Func([e.Record({canister_id:l,sender_canister_version:e.Opt(e.Nat64)})],[],[]),update_settings:e.Func([e.Record({canister_id:e.Principal,settings:_,sender_canister_version:e.Opt(e.Nat64)})],[],[])})};var mt=({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.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.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),a=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),d=e.Record({status:i,memory_size:e.Nat,cycles:e.Nat,settings:a,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),p=e.Record({id:e.Principal,status:d,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),status_at:e.Nat64}),u=e.Variant({Ok:p,Err:e.Text}),y=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:n,expires_at:e.Opt(e.Nat64)}),g=e.Record({enabled:e.Bool,cycles_threshold:e.Opt(e.Nat64)}),N=e.Record({mission_control_cycles_threshold:e.Opt(e.Nat64),orbiters:e.Vec(e.Tuple(e.Principal,g)),satellites:e.Vec(e.Tuple(e.Principal,g)),cycles_threshold:e.Opt(e.Nat64)}),l=e.Record({orbiters:e.Opt(e.Vec(u)),satellites:e.Opt(e.Vec(u)),mission_control:u}),m=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_orbiters_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),del_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),get_user:e.Func([],[e.Principal],["query"]),list_mission_control_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,o))],["query"]),list_mission_control_statuses:e.Func([],[e.Vec(e.Tuple(e.Nat64,u))],["query"]),list_orbiter_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,u)))],["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,u)))],["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),y],[],[]),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),y],[],[]),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),y],[],[]),status:e.Func([N],[l],[]),top_up:e.Func([e.Principal,m],[],[]),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({updated_at:e.Opt(e.Nat64)}),i=e.Record({to:e.Opt(e.Nat64),from:e.Opt(e.Nat64),satellite_id:e.Opt(e.Principal)}),a=e.Record({key:e.Text,collected_at:e.Nat64}),d=e.Record({inner_height:e.Nat16,inner_width:e.Nat16}),p=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:d,user_agent:e.Opt(e.Text)}),u=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}),y=e.Record({updated_at:e.Nat64,created_at:e.Nat64,enabled:e.Bool}),g=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:r,expires_at:e.Opt(e.Nat64)}),N=e.Record({controller:g,controllers:e.Vec(e.Principal)}),l=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:d,user_agent:e.Opt(e.Text)}),m=e.Variant({Ok:p,Err:e.Text}),T=e.Variant({Ok:e.Null,Err:e.Vec(e.Tuple(a,e.Text))}),x=e.Record({updated_at:e.Opt(e.Nat64),enabled:e.Bool}),b=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,user_agent:e.Opt(e.Text)}),_=e.Variant({Ok:u,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],[],[]),get_page_views:e.Func([i],[e.Vec(e.Tuple(a,p))],["query"]),get_track_events:e.Func([i],[e.Vec(e.Tuple(a,u))],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_satellite_configs:e.Func([],[e.Vec(e.Tuple(e.Principal,y))],["query"]),set_controllers:e.Func([N],[e.Vec(e.Tuple(e.Principal,n))],[]),set_page_view:e.Func([a,l],[m],[]),set_page_views:e.Func([e.Vec(e.Tuple(a,l))],[T],[]),set_satellite_configs:e.Func([e.Vec(e.Tuple(e.Principal,x))],[e.Vec(e.Tuple(e.Principal,y))],[]),set_track_event:e.Func([a,b],[_],[]),set_track_events:e.Func([e.Vec(e.Tuple(a,b))],[T],[]),version:e.Func([],[e.Text],["query"])})};var ft=({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}),d=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))}),u=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:u,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}),N=e.Record({token:e.Opt(u),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}),x=e.Record({field:T,desc:e.Bool}),b=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),_=e.Record({order:e.Opt(x),owner:e.Opt(e.Principal),matcher:e.Opt(e.Text),paginate:e.Opt(b)}),P=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),R=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),E=e.Record({key:P,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,R)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),C=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,E))}),O=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,d))}),q=e.Variant({Db:e.Null,Storage:e.Null}),B=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),te=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:B,created_at:e.Nat64,write:B}),re=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),H=e.Record({controller:re,controllers:e.Vec(e.Principal)}),ne=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),oe=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:B,write:B}),ie=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),se=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(d)],["query"]),http_request:e.Func([p],[g],["query"]),http_request_streaming_callback:e.Func([u],[N],["query"]),init_asset_upload:e.Func([l],[m],[]),list_assets:e.Func([e.Opt(e.Text),_],[C],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,O))],["query"]),list_docs:e.Func([e.Text,_],[S],["query"]),list_rules:e.Func([q],[e.Vec(e.Tuple(e.Text,te))],["query"]),set_config:e.Func([a],[],[]),set_controllers:e.Func([H],[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,ne],[d],[]),set_rule:e.Func([q,e.Text,oe],[],[]),upload_asset_chunk:e.Func([ie],[se],[]),version:e.Func([],[e.Text],["query"])})};var _t=({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}),d=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))}),u=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:u,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}),N=e.Record({token:e.Opt(u),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}),x=e.Record({field:T,desc:e.Bool}),b=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),_=e.Record({order:e.Opt(x),matcher:e.Opt(e.Text),paginate:e.Opt(b)}),P=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),R=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),E=e.Record({key:P,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,R)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),C=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,E))}),O=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,d))}),q=e.Variant({Db:e.Null,Storage:e.Null}),B=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),te=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:B,created_at:e.Nat64,write:B}),re=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),H=e.Record({controller:re,controllers:e.Vec(e.Principal)}),ne=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),oe=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:B,write:B}),ie=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),se=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(d)],["query"]),http_request:e.Func([p],[g],["query"]),http_request_streaming_callback:e.Func([u],[N],["query"]),init_asset_upload:e.Func([l],[m],[]),list_assets:e.Func([e.Opt(e.Text),_],[C],["query"]),list_controllers:e.Func([],[e.Vec(e.Principal)],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,O))],["query"]),list_docs:e.Func([e.Text,_],[S],["query"]),list_rules:e.Func([q],[e.Vec(e.Tuple(e.Text,te))],["query"]),set_config:e.Func([a],[],[]),set_controllers:e.Func([H],[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,ne],[d],[]),set_rule:e.Func([q,e.Text,oe],[],[]),upload_asset_chunk:e.Func([ie],[se],[]),version:e.Func([],[e.Text],["query"])})};var yt=({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({updated_at:e.Opt(e.Nat64)}),a=e.Variant({Db:e.Null,Storage:e.Null}),d=e.Record({rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),p=e.Record({storage:d}),u=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64}),y=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),g=e.Variant({Heap:e.Null,Stable:e.Null}),N=e.Record({memory:g,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}),l=e.Variant({Callback:e.Record({token:N,callback:e.Func([],[],["query"])})}),m=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(l),status_code:e.Nat16}),T=e.Record({token:e.Opt(N),body:e.Vec(e.Nat8)}),x=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}),b=e.Record({batch_id:e.Nat}),_=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),P=e.Record({field:_,desc:e.Bool}),R=e.Record({key:e.Opt(e.Text),description:e.Opt(e.Text)}),E=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),C=e.Record({order:e.Opt(P),owner:e.Opt(e.Principal),matcher:e.Opt(R),paginate:e.Opt(E)}),O=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}),S=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),q=e.Record({key:O,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,S)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),B=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,q)),items_length:e.Nat64}),te=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),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,u)),items_length:e.Nat64}),H=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),ne=e.Record({memory:e.Opt(g),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:H,created_at:e.Nat64,mutable_permissions:e.Opt(e.Bool),write:H}),oe=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:n,expires_at:e.Opt(e.Nat64)}),ie=e.Record({controller:oe,controllers:e.Vec(e.Principal)}),se=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8),description:e.Opt(e.Text)}),xr=e.Record({memory:e.Opt(g),updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:H,mutable_permissions:e.Opt(e.Bool),write:H}),vr=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Nr=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.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_rule:e.Func([a,e.Text,i],[],[]),get_config:e.Func([],[p],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(u)],["query"]),http_request:e.Func([y],[m],["query"]),http_request_streaming_callback:e.Func([N],[T],["query"]),init_asset_upload:e.Func([x],[b],[]),list_assets:e.Func([e.Text,C],[B],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,o))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,te))],["query"]),list_docs:e.Func([e.Text,C],[re],["query"]),list_rules:e.Func([a],[e.Vec(e.Tuple(e.Text,ne))],["query"]),set_config:e.Func([p],[],[]),set_controllers:e.Func([ie],[e.Vec(e.Tuple(e.Principal,o))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,se],[u],[]),set_rule:e.Func([a,e.Text,xr],[],[]),upload_asset_chunk:e.Func([vr],[Nr],[]),version:e.Func([],[e.Text],["query"])})};import{Actor as Or,HttpAgent as Sr}from"@dfinity/agent";var Be=async({canisterId:e,idlFactory:t,identity:r,fetch:n,env:o="prod",config:i})=>{let a=o==="dev"?"http://127.0.0.1:8000/":"https://icp-api.io",d=new Sr({identity:r,...a&&{host:a},...n&&{fetch:n}});return o==="dev"&&await d.fetchRootKey(),Or.createActor(t,{agent:d,canisterId:e,...i!==void 0?i:{}})};var bt=async({satelliteId:e,...t})=>ce({canisterId:e,...t,idlFactory:_t}),J=async({satelliteId:e,...t})=>ce({canisterId:e,...t,idlFactory:yt}),wt=async({satelliteId:e,...t})=>ce({canisterId:e,...t,idlFactory:ft}),ae=async({missionControlId:e,...t})=>ce({canisterId:e,...t,idlFactory:mt}),ke=async({orbiterId:e,...t})=>ce({canisterId:e,...t,idlFactory:ht}),ce=async({canisterId:e,idlFactory:t,...r})=>{if(!e)throw new Error("No canister ID provided.");return Be({canisterId:e,idlFactory:t,...r})},xt=Tt.fromText("aaaaa-aa"),gt=(e,t,r)=>{let n=t[0],o=xt;return n&&typeof n=="object"&&n.canister_id&&(o=Tt.from(n.canister_id)),{effectiveCanisterId:o}},vt=e=>Be({canisterId:xt.toText(),config:{callTransform:gt,queryTransform:gt},idlFactory:pt,...e});var Y=async({actor:e,code:t})=>{let{install_code:r}=await vt(e);return r({...t,sender_canister_version:[]})};var Nt=async({missionControl:e})=>(await ae(e)).version(),Rt=async({missionControl:e})=>(await ae(e)).get_user();var Vt=async({missionControl:e,satelliteIds:t,controllerIds:r,controller:n})=>(await ae(e)).set_satellites_controllers(t,r,n),Pt=async({missionControl:e,controllerIds:t,controller:r})=>(await ae(e)).set_mission_control_controllers(t,r);import{Principal as Ar}from"@dfinity/principal";import{nonNullish as Br,toNullable as kr}from"@junobuild/utils";var Me=({controllerId:e,profile:t})=>({controllerIds:[Ar.fromText(e)],controller:Mr(t)}),Mr=e=>({metadata:Br(e)&&e!==""?[["profile",e]]:[],expires_at:kr(void 0),scope:{Admin:null}});var G=dt(ot(),1),Qt=e=>G.IDL.encode([G.IDL.Record({user:G.IDL.Principal})],[{user:e}]),Ae=e=>G.IDL.encode([G.IDL.Record({controllers:G.IDL.Vec(G.IDL.Principal)})],[{controllers:e.map(([t,r])=>t)}]);var no=async e=>Nt(e),oo=async({missionControl:e,wasm_module:t})=>{let r=await Rt({missionControl:e}),{missionControlId:n,...o}=e;if(!n)throw new Error("No mission control principal defined.");let i=Qt(r);await Y({actor:o,code:{canister_id:dn.fromText(n),arg:new Uint8Array(i),wasm_module:t,mode:{upgrade:null}}})},io=async({controllerId:e,profile:t,...r})=>Vt({...r,...Me({controllerId:e,profile:t})}),so=async({controllerId:e,profile:t,...r})=>Pt({...r,...Me({controllerId:e,profile:t})});import{Principal as pn}from"@dfinity/principal";var Xt=async({orbiter:e})=>(await ke(e)).version(),Zt=async({orbiter:e})=>(await ke(e)).list_controllers();var fo=async e=>Xt(e),_o=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 Zt({orbiter:e}),a=Ae(i);await Y({actor:o,code:{canister_id:pn.fromText(n),arg:new Uint8Array(a),wasm_module:t,mode:r?{reinstall:null}:{upgrade:null}}})};import{major as It,minor as Lt,patch as Dt}from"semver";var To=({currentVersion:e,selectedVersion:t})=>{let r=It(e),n=It(t),o=Lt(e),i=Lt(t),a=Dt(e),d=Dt(t);return r<n-1||o<i-1||a<d-1?{canUpgrade:!1}:{canUpgrade:!0}};var he=dt(ot(),1);import{Principal as wr}from"@dfinity/principal";import{fromNullable as _n}from"@junobuild/utils";var er=async({config:e,satellite:t})=>(await J(t)).set_config(e),tr=async({satellite:e,type:t})=>(await J(e)).list_rules(t),rr=async({type:e,collection:t,rule:r,satellite:n})=>(await J(n)).set_rule(e,t,r),nr=async({satellite:e})=>(await J(e)).version(),or=async({satellite:e})=>(await bt(e)).list_controllers(),ir=async({satellite:e})=>(await wt(e)).list_controllers(),sr=async({satellite:e})=>(await J(e)).list_controllers(),ar=async({satellite:e})=>(await J(e)).list_custom_domains();var cr=[{source:"**",destination:"/index.html"}];import{fromNullable as st,isNullish as mn,nonNullish as at,toNullable as _r}from"@junobuild/utils";var lr={Db:null},ur={Storage:null},dr={Public:null},pr={Private:null},mr={Managed:null},hr={Controllers:null},it={Heap:null},fr={Stable:null};var ct=e=>e==="storage"?ur:lr,Tr=({read:e,write:t,memory:r,max_size:n,updated_at:o,mutablePermissions:i})=>({read:gr(e),write:gr(t),memory:at(r)?[hn(r)]:[],updated_at:mn(o)?[]:[o],max_size:_r(at(n)&&n>0?BigInt(n):void 0),mutable_permissions:_r(i)}),br=([e,t])=>{let{read:r,write:n,updated_at:o,created_at:i,max_size:a,memory:d,mutable_permissions:p}=t,u=a?.[0]??0n>0n?Number(st(a)):void 0;return{collection:e,read:yr(r),write:yr(n),memory:fn(st(d)??it),updated_at:o,created_at:i,...at(u)&&{max_size:u},mutablePermissions:st(p)??!0}},yr=e=>"Public"in e?"public":"Private"in e?"private":"Managed"in e?"managed":"controllers",gr=e=>{switch(e){case"public":return dr;case"private":return pr;case"managed":return mr;default:return hr}},hn=e=>{switch(e){case"Stable":return fr;default:return it}},fn=e=>"Stable"in e?"Stable":"Heap";var ko=async({config:{storage:{headers:e,rewrites:t}},satellite:r})=>{let n=(e??[]).map(({source:i,headers:a})=>[i,a]),o=(t??cr).map(({source:i,destination:a})=>[i,a]);return er({satellite:r,config:{storage:{headers:n,rewrites:o}}})},Mo=async({type:e,satellite:t})=>(await tr({satellite:t,type:ct(e)})).map(n=>br(n)),$o=async({rule:{collection:e,...t},type:r,satellite:n})=>rr({type:ct(r),rule:Tr(t),satellite:n,collection:e}),Uo=async e=>nr(e),qo=async({satellite:e,wasm_module:t,deprecated:r,deprecatedNoScope:n,reset:o=!1})=>{let{satelliteId:i,...a}=e;if(!i)throw new Error("No satellite principal defined.");if(r){let y=await or({satellite:e}),g=he.IDL.encode([he.IDL.Record({controllers:he.IDL.Vec(he.IDL.Principal)})],[{controllers:y}]);await Y({actor:a,code:{canister_id:wr.fromText(i),arg:new Uint8Array(g),wasm_module:t,mode:o?{reinstall:null}:{upgrade:null}}});return}let p=await(n?ir:sr)({satellite:e}),u=Ae(p);await Y({actor:a,code:{canister_id:wr.fromText(i),arg:new Uint8Array(u),wasm_module:t,mode:o?{reinstall:null}:{upgrade:null}}})},jo=async({satellite:e})=>(await ar({satellite:e})).map(([r,n])=>({domain:r,bn_id:_n(n.bn_id),created_at:n.created_at,updated_at:n.updated_at}));export{To as checkUpgradeVersion,jo as listCustomDomains,Mo as listRules,no as missionControlVersion,fo as orbiterVersion,Uo as satelliteVersion,ko as setConfig,so as setMissionControlController,$o as setRule,io as setSatellitesController,oo as upgradeMissionControl,_o as upgradeOrbiter,qo as upgradeSatellite};
|
|
16
16
|
//# sourceMappingURL=index.mjs.map
|