@junobuild/admin 0.0.52 → 0.0.53-next-2024-08-04.1

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.
@@ -35,8 +35,14 @@ export interface CommitBatch {
35
35
  chunk_ids: Array<bigint>;
36
36
  }
37
37
  export interface Config {
38
+ db: [] | [DbConfig];
39
+ authentication: [] | [AuthenticationConfig];
38
40
  storage: StorageConfig;
39
41
  }
42
+ export interface ConfigMaxMemorySize {
43
+ stable: [] | [bigint];
44
+ heap: [] | [bigint];
45
+ }
40
46
  export interface Controller {
41
47
  updated_at: bigint;
42
48
  metadata: Array<[string, string]>;
@@ -51,9 +57,15 @@ export interface CustomDomain {
51
57
  version: [] | [bigint];
52
58
  bn_id: [] | [string];
53
59
  }
60
+ export interface DbConfig {
61
+ max_memory_size: [] | [ConfigMaxMemorySize];
62
+ }
54
63
  export interface DelDoc {
55
64
  version: [] | [bigint];
56
65
  }
66
+ export interface DelRule {
67
+ version: [] | [bigint];
68
+ }
57
69
  export interface DeleteControllersArgs {
58
70
  controllers: Array<Principal>;
59
71
  }
@@ -95,7 +107,9 @@ export interface InitUploadResult {
95
107
  }
96
108
  export interface ListMatcher {
97
109
  key: [] | [string];
110
+ updated_at: [] | [TimestampMatcher];
98
111
  description: [] | [string];
112
+ created_at: [] | [TimestampMatcher];
99
113
  }
100
114
  export interface ListOrder {
101
115
  field: ListOrderField;
@@ -171,6 +185,7 @@ export interface StorageConfig {
171
185
  iframe: [] | [StorageConfigIFrame];
172
186
  rewrites: Array<[string, string]>;
173
187
  headers: Array<[string, Array<[string, string]>]>;
188
+ max_memory_size: [] | [ConfigMaxMemorySize];
174
189
  raw_access: [] | [StorageConfigRawAccess];
175
190
  redirects: [] | [Array<[string, StorageConfigRedirect]>];
176
191
  }
@@ -199,6 +214,11 @@ export type StreamingStrategy = {
199
214
  callback: [Principal, string];
200
215
  };
201
216
  };
217
+ export type TimestampMatcher =
218
+ | {Equal: bigint}
219
+ | {Between: [bigint, bigint]}
220
+ | {GreaterThan: bigint}
221
+ | {LessThan: bigint};
202
222
  export interface UploadChunk {
203
223
  content: Uint8Array | number[];
204
224
  batch_id: bigint;
@@ -220,14 +240,16 @@ export interface _SERVICE {
220
240
  del_docs: ActorMethod<[string], undefined>;
221
241
  del_many_assets: ActorMethod<[Array<[string, string]>], undefined>;
222
242
  del_many_docs: ActorMethod<[Array<[string, string, DelDoc]>], undefined>;
223
- del_rule: ActorMethod<[RulesType, string, DelDoc], undefined>;
243
+ del_rule: ActorMethod<[RulesType, string, DelRule], undefined>;
224
244
  deposit_cycles: ActorMethod<[DepositCyclesArgs], undefined>;
225
245
  get_asset: ActorMethod<[string, string], [] | [AssetNoContent]>;
226
246
  get_auth_config: ActorMethod<[], [] | [AuthenticationConfig]>;
227
247
  get_config: ActorMethod<[], Config>;
248
+ get_db_config: ActorMethod<[], [] | [DbConfig]>;
228
249
  get_doc: ActorMethod<[string, string], [] | [Doc]>;
229
250
  get_many_assets: ActorMethod<[Array<[string, string]>], Array<[string, [] | [AssetNoContent]]>>;
230
251
  get_many_docs: ActorMethod<[Array<[string, string]>], Array<[string, [] | [Doc]]>>;
252
+ get_storage_config: ActorMethod<[], StorageConfig>;
231
253
  http_request: ActorMethod<[HttpRequest], HttpResponse>;
232
254
  http_request_streaming_callback: ActorMethod<
233
255
  [StreamingCallbackToken],
@@ -241,12 +263,13 @@ export interface _SERVICE {
241
263
  list_rules: ActorMethod<[RulesType], Array<[string, Rule]>>;
242
264
  memory_size: ActorMethod<[], MemorySize>;
243
265
  set_auth_config: ActorMethod<[AuthenticationConfig], undefined>;
244
- set_config: ActorMethod<[Config], undefined>;
245
266
  set_controllers: ActorMethod<[SetControllersArgs], Array<[Principal, Controller]>>;
246
267
  set_custom_domain: ActorMethod<[string, [] | [string]], undefined>;
268
+ set_db_config: ActorMethod<[DbConfig], undefined>;
247
269
  set_doc: ActorMethod<[string, string, SetDoc], Doc>;
248
270
  set_many_docs: ActorMethod<[Array<[string, string, SetDoc]>], Array<[string, Doc]>>;
249
271
  set_rule: ActorMethod<[RulesType, string, SetRule], undefined>;
272
+ set_storage_config: ActorMethod<[StorageConfig], undefined>;
250
273
  upload_asset_chunk: ActorMethod<[UploadChunk], UploadChunkResult>;
251
274
  version: ActorMethod<[], string>;
252
275
  }
@@ -21,6 +21,7 @@ export const idlFactory = ({IDL}) => {
21
21
  });
22
22
  const DelDoc = IDL.Record({version: IDL.Opt(IDL.Nat64)});
23
23
  const RulesType = IDL.Variant({Db: IDL.Null, Storage: IDL.Null});
24
+ const DelRule = IDL.Record({version: IDL.Opt(IDL.Nat64)});
24
25
  const DepositCyclesArgs = IDL.Record({
25
26
  cycles: IDL.Nat,
26
27
  destination_id: IDL.Principal
@@ -52,6 +53,13 @@ export const idlFactory = ({IDL}) => {
52
53
  const AuthenticationConfig = IDL.Record({
53
54
  internet_identity: IDL.Opt(AuthenticationConfigInternetIdentity)
54
55
  });
56
+ const ConfigMaxMemorySize = IDL.Record({
57
+ stable: IDL.Opt(IDL.Nat64),
58
+ heap: IDL.Opt(IDL.Nat64)
59
+ });
60
+ const DbConfig = IDL.Record({
61
+ max_memory_size: IDL.Opt(ConfigMaxMemorySize)
62
+ });
55
63
  const StorageConfigIFrame = IDL.Variant({
56
64
  Deny: IDL.Null,
57
65
  AllowAny: IDL.Null,
@@ -69,10 +77,15 @@ export const idlFactory = ({IDL}) => {
69
77
  iframe: IDL.Opt(StorageConfigIFrame),
70
78
  rewrites: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
71
79
  headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)))),
80
+ max_memory_size: IDL.Opt(ConfigMaxMemorySize),
72
81
  raw_access: IDL.Opt(StorageConfigRawAccess),
73
82
  redirects: IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, StorageConfigRedirect)))
74
83
  });
75
- const Config = IDL.Record({storage: StorageConfig});
84
+ const Config = IDL.Record({
85
+ db: IDL.Opt(DbConfig),
86
+ authentication: IDL.Opt(AuthenticationConfig),
87
+ storage: StorageConfig
88
+ });
76
89
  const Doc = IDL.Record({
77
90
  updated_at: IDL.Nat64,
78
91
  owner: IDL.Principal,
@@ -129,9 +142,17 @@ export const idlFactory = ({IDL}) => {
129
142
  CreatedAt: IDL.Null
130
143
  });
131
144
  const ListOrder = IDL.Record({field: ListOrderField, desc: IDL.Bool});
145
+ const TimestampMatcher = IDL.Variant({
146
+ Equal: IDL.Nat64,
147
+ Between: IDL.Tuple(IDL.Nat64, IDL.Nat64),
148
+ GreaterThan: IDL.Nat64,
149
+ LessThan: IDL.Nat64
150
+ });
132
151
  const ListMatcher = IDL.Record({
133
152
  key: IDL.Opt(IDL.Text),
134
- description: IDL.Opt(IDL.Text)
153
+ updated_at: IDL.Opt(TimestampMatcher),
154
+ description: IDL.Opt(IDL.Text),
155
+ created_at: IDL.Opt(TimestampMatcher)
135
156
  });
136
157
  const ListPaginate = IDL.Record({
137
158
  start_after: IDL.Opt(IDL.Text),
@@ -227,11 +248,12 @@ export const idlFactory = ({IDL}) => {
227
248
  del_docs: IDL.Func([IDL.Text], [], []),
228
249
  del_many_assets: IDL.Func([IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))], [], []),
229
250
  del_many_docs: IDL.Func([IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text, DelDoc))], [], []),
230
- del_rule: IDL.Func([RulesType, IDL.Text, DelDoc], [], []),
251
+ del_rule: IDL.Func([RulesType, IDL.Text, DelRule], [], []),
231
252
  deposit_cycles: IDL.Func([DepositCyclesArgs], [], []),
232
253
  get_asset: IDL.Func([IDL.Text, IDL.Text], [IDL.Opt(AssetNoContent)], ['query']),
233
254
  get_auth_config: IDL.Func([], [IDL.Opt(AuthenticationConfig)], ['query']),
234
255
  get_config: IDL.Func([], [Config], []),
256
+ get_db_config: IDL.Func([], [IDL.Opt(DbConfig)], ['query']),
235
257
  get_doc: IDL.Func([IDL.Text, IDL.Text], [IDL.Opt(Doc)], ['query']),
236
258
  get_many_assets: IDL.Func(
237
259
  [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))],
@@ -243,6 +265,7 @@ export const idlFactory = ({IDL}) => {
243
265
  [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Opt(Doc)))],
244
266
  ['query']
245
267
  ),
268
+ get_storage_config: IDL.Func([], [StorageConfig], ['query']),
246
269
  http_request: IDL.Func([HttpRequest], [HttpResponse], ['query']),
247
270
  http_request_streaming_callback: IDL.Func(
248
271
  [StreamingCallbackToken],
@@ -257,13 +280,13 @@ export const idlFactory = ({IDL}) => {
257
280
  list_rules: IDL.Func([RulesType], [IDL.Vec(IDL.Tuple(IDL.Text, Rule))], ['query']),
258
281
  memory_size: IDL.Func([], [MemorySize], ['query']),
259
282
  set_auth_config: IDL.Func([AuthenticationConfig], [], []),
260
- set_config: IDL.Func([Config], [], []),
261
283
  set_controllers: IDL.Func(
262
284
  [SetControllersArgs],
263
285
  [IDL.Vec(IDL.Tuple(IDL.Principal, Controller))],
264
286
  []
265
287
  ),
266
288
  set_custom_domain: IDL.Func([IDL.Text, IDL.Opt(IDL.Text)], [], []),
289
+ set_db_config: IDL.Func([DbConfig], [], []),
267
290
  set_doc: IDL.Func([IDL.Text, IDL.Text, SetDoc], [Doc], []),
268
291
  set_many_docs: IDL.Func(
269
292
  [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text, SetDoc))],
@@ -271,6 +294,7 @@ export const idlFactory = ({IDL}) => {
271
294
  []
272
295
  ),
273
296
  set_rule: IDL.Func([RulesType, IDL.Text, SetRule], [], []),
297
+ set_storage_config: IDL.Func([StorageConfig], [], []),
274
298
  upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], []),
275
299
  version: IDL.Func([], [IDL.Text], ['query'])
276
300
  });
@@ -21,6 +21,7 @@ export const idlFactory = ({IDL}) => {
21
21
  });
22
22
  const DelDoc = IDL.Record({version: IDL.Opt(IDL.Nat64)});
23
23
  const RulesType = IDL.Variant({Db: IDL.Null, Storage: IDL.Null});
24
+ const DelRule = IDL.Record({version: IDL.Opt(IDL.Nat64)});
24
25
  const DepositCyclesArgs = IDL.Record({
25
26
  cycles: IDL.Nat,
26
27
  destination_id: IDL.Principal
@@ -52,6 +53,13 @@ export const idlFactory = ({IDL}) => {
52
53
  const AuthenticationConfig = IDL.Record({
53
54
  internet_identity: IDL.Opt(AuthenticationConfigInternetIdentity)
54
55
  });
56
+ const ConfigMaxMemorySize = IDL.Record({
57
+ stable: IDL.Opt(IDL.Nat64),
58
+ heap: IDL.Opt(IDL.Nat64)
59
+ });
60
+ const DbConfig = IDL.Record({
61
+ max_memory_size: IDL.Opt(ConfigMaxMemorySize)
62
+ });
55
63
  const StorageConfigIFrame = IDL.Variant({
56
64
  Deny: IDL.Null,
57
65
  AllowAny: IDL.Null,
@@ -69,10 +77,15 @@ export const idlFactory = ({IDL}) => {
69
77
  iframe: IDL.Opt(StorageConfigIFrame),
70
78
  rewrites: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
71
79
  headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)))),
80
+ max_memory_size: IDL.Opt(ConfigMaxMemorySize),
72
81
  raw_access: IDL.Opt(StorageConfigRawAccess),
73
82
  redirects: IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, StorageConfigRedirect)))
74
83
  });
75
- const Config = IDL.Record({storage: StorageConfig});
84
+ const Config = IDL.Record({
85
+ db: IDL.Opt(DbConfig),
86
+ authentication: IDL.Opt(AuthenticationConfig),
87
+ storage: StorageConfig
88
+ });
76
89
  const Doc = IDL.Record({
77
90
  updated_at: IDL.Nat64,
78
91
  owner: IDL.Principal,
@@ -129,9 +142,17 @@ export const idlFactory = ({IDL}) => {
129
142
  CreatedAt: IDL.Null
130
143
  });
131
144
  const ListOrder = IDL.Record({field: ListOrderField, desc: IDL.Bool});
145
+ const TimestampMatcher = IDL.Variant({
146
+ Equal: IDL.Nat64,
147
+ Between: IDL.Tuple(IDL.Nat64, IDL.Nat64),
148
+ GreaterThan: IDL.Nat64,
149
+ LessThan: IDL.Nat64
150
+ });
132
151
  const ListMatcher = IDL.Record({
133
152
  key: IDL.Opt(IDL.Text),
134
- description: IDL.Opt(IDL.Text)
153
+ updated_at: IDL.Opt(TimestampMatcher),
154
+ description: IDL.Opt(IDL.Text),
155
+ created_at: IDL.Opt(TimestampMatcher)
135
156
  });
136
157
  const ListPaginate = IDL.Record({
137
158
  start_after: IDL.Opt(IDL.Text),
@@ -227,11 +248,12 @@ export const idlFactory = ({IDL}) => {
227
248
  del_docs: IDL.Func([IDL.Text], [], []),
228
249
  del_many_assets: IDL.Func([IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))], [], []),
229
250
  del_many_docs: IDL.Func([IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text, DelDoc))], [], []),
230
- del_rule: IDL.Func([RulesType, IDL.Text, DelDoc], [], []),
251
+ del_rule: IDL.Func([RulesType, IDL.Text, DelRule], [], []),
231
252
  deposit_cycles: IDL.Func([DepositCyclesArgs], [], []),
232
253
  get_asset: IDL.Func([IDL.Text, IDL.Text], [IDL.Opt(AssetNoContent)], ['query']),
233
254
  get_auth_config: IDL.Func([], [IDL.Opt(AuthenticationConfig)], ['query']),
234
255
  get_config: IDL.Func([], [Config], []),
256
+ get_db_config: IDL.Func([], [IDL.Opt(DbConfig)], ['query']),
235
257
  get_doc: IDL.Func([IDL.Text, IDL.Text], [IDL.Opt(Doc)], ['query']),
236
258
  get_many_assets: IDL.Func(
237
259
  [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))],
@@ -243,6 +265,7 @@ export const idlFactory = ({IDL}) => {
243
265
  [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Opt(Doc)))],
244
266
  ['query']
245
267
  ),
268
+ get_storage_config: IDL.Func([], [StorageConfig], ['query']),
246
269
  http_request: IDL.Func([HttpRequest], [HttpResponse], ['query']),
247
270
  http_request_streaming_callback: IDL.Func(
248
271
  [StreamingCallbackToken],
@@ -257,13 +280,13 @@ export const idlFactory = ({IDL}) => {
257
280
  list_rules: IDL.Func([RulesType], [IDL.Vec(IDL.Tuple(IDL.Text, Rule))], ['query']),
258
281
  memory_size: IDL.Func([], [MemorySize], ['query']),
259
282
  set_auth_config: IDL.Func([AuthenticationConfig], [], []),
260
- set_config: IDL.Func([Config], [], []),
261
283
  set_controllers: IDL.Func(
262
284
  [SetControllersArgs],
263
285
  [IDL.Vec(IDL.Tuple(IDL.Principal, Controller))],
264
286
  []
265
287
  ),
266
288
  set_custom_domain: IDL.Func([IDL.Text, IDL.Opt(IDL.Text)], [], []),
289
+ set_db_config: IDL.Func([DbConfig], [], []),
267
290
  set_doc: IDL.Func([IDL.Text, IDL.Text, SetDoc], [Doc], []),
268
291
  set_many_docs: IDL.Func(
269
292
  [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text, SetDoc))],
@@ -271,6 +294,7 @@ export const idlFactory = ({IDL}) => {
271
294
  []
272
295
  ),
273
296
  set_rule: IDL.Func([RulesType, IDL.Text, SetRule], [], []),
297
+ set_storage_config: IDL.Func([StorageConfig], [], []),
274
298
  upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], []),
275
299
  version: IDL.Func([], [IDL.Text], ['query'])
276
300
  });
@@ -1,14 +1,14 @@
1
- var Zr=Object.defineProperty;var Ir=(e,t)=>{for(var r in t)Zr(e,r,{get:t[r],enumerable:!0})};import{Principal as hn}from"@dfinity/principal";import{CanisterStatus as tn}from"@dfinity/agent";import{Principal as rn}from"@dfinity/principal";import{assertNonNullish as nn}from"@junobuild/utils";import{Actor as Dr,HttpAgent as Lr}from"@dfinity/agent";import{nonNullish as tt}from"@junobuild/utils";var je=async({canisterId:e,idlFactory:t,config:r,...n})=>{let o=await ze(n);return Dr.createActor(t,{agent:o,canisterId:e,...r!==void 0?r:{}})},ze=async({identity:e,fetch:t,container:r})=>{let n=tt(r)&&r!==!1,o=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io",i=new Lr({identity:e,host:o,retryTimes:10,...tt(t)&&{fetch:t}});return n&&await i.fetchRootKey(),i};import{Principal as lt}from"@dfinity/principal";import{isNullish as en}from"@junobuild/utils";var rt=({IDL:e})=>{let t=e.Variant({mainnet:e.Null,testnet:e.Null}),r=e.Text,n=e.Record({network:t,address:r,min_confirmations:e.Opt(e.Nat32)}),o=e.Nat64,i=o,s=e.Record({network:t,address:r,min_confirmations:e.Opt(e.Nat32)}),c=o,u=e.Record({network:t}),l=e.Nat64,_=e.Vec(l),m=e.Record({network:t,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:r}),y=e.Vec(e.Nat8),a=e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32}),p=e.Record({height:e.Nat32,value:o,outpoint:a}),g=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:e.Nat32,tip_block_hash:y,utxos:e.Vec(p)}),x=e.Record({network:t,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:r}),T=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:e.Nat32,tip_block_hash:y,utxos:e.Vec(p)}),h=e.Record({transaction:e.Vec(e.Nat8),network:t}),d=e.Principal,w=e.Record({canister_id:d,num_requested_changes:e.Opt(e.Nat64)}),R=e.Variant({from_user:e.Record({user_id:e.Principal}),from_canister:e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal})}),P=e.Variant({creation:e.Record({controllers:e.Vec(e.Principal)}),code_deployment:e.Record({mode:e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),module_hash:e.Vec(e.Nat8)}),controllers_change:e.Record({controllers:e.Vec(e.Principal)}),code_uninstall:e.Null}),C=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:R,details:P}),V=e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec(C),total_num_changes:e.Nat64}),k=e.Record({canister_id:d}),S=e.Variant({controllers:e.Null,public:e.Null}),q=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),reserved_cycles_limit:e.Nat,log_visibility:S,memory_allocation:e.Nat,compute_allocation:e.Nat}),Y=e.Record({status:e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),memory_size:e.Nat,cycles:e.Nat,settings:q,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8)),reserved_cycles:e.Nat}),Q=e.Record({canister_id:d}),U=e.Record({freezing_threshold:e.Opt(e.Nat),controllers:e.Opt(e.Vec(e.Principal)),reserved_cycles_limit:e.Opt(e.Nat),log_visibility:e.Opt(S),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),K=e.Record({settings:e.Opt(U),sender_canister_version:e.Opt(e.Nat64)}),X=e.Record({canister_id:d}),Z=e.Record({canister_id:d}),Ee=e.Record({canister_id:d}),I=e.Variant({secp256k1:e.Null}),ke=e.Record({key_id:e.Record({name:e.Text,curve:I}),canister_id:e.Opt(d),derivation_path:e.Vec(e.Vec(e.Nat8))}),Be=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),Me=e.Record({canister_id:d}),$e=e.Record({idx:e.Nat64,timestamp_nanos:e.Nat64,content:e.Vec(e.Nat8)}),de=e.Record({canister_log_records:e.Vec($e)}),me=e.Record({value:e.Text,name:e.Text}),ie=e.Record({status:e.Nat,body:e.Vec(e.Nat8),headers:e.Vec(me)}),qe=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:ie})],[ie],["query"]),context:e.Vec(e.Nat8)})),headers:e.Vec(me)}),Ue=e.Vec(e.Nat8),Ar=e.Record({arg:e.Vec(e.Nat8),wasm_module_hash:e.Vec(e.Nat8),mode:e.Variant({reinstall:e.Null,upgrade:e.Opt(e.Record({skip_pre_upgrade:e.Opt(e.Bool)})),install:e.Null}),chunk_hashes_list:e.Vec(Ue),target_canister:d,sender_canister_version:e.Opt(e.Nat64),storage_canister:e.Opt(d)}),Or=e.Vec(e.Nat8),Fr=e.Record({arg:e.Vec(e.Nat8),wasm_module:Or,mode:e.Variant({reinstall:e.Null,upgrade:e.Opt(e.Record({skip_pre_upgrade:e.Opt(e.Bool)})),install:e.Null}),canister_id:d,sender_canister_version:e.Opt(e.Nat64)}),Er=e.Record({start_at_timestamp_nanos:e.Nat64,subnet_id:e.Principal}),kr=e.Record({num_block_failures_total:e.Nat64,node_id:e.Principal,num_blocks_total:e.Nat64}),Br=e.Vec(e.Record({timestamp_nanos:e.Nat64,node_metrics:e.Vec(kr)})),Mr=e.Record({settings:e.Opt(U),specified_id:e.Opt(d),amount:e.Opt(e.Nat),sender_canister_version:e.Opt(e.Nat64)}),$r=e.Record({canister_id:d}),qr=e.Record({canister_id:d,amount:e.Nat}),Ur=e.Vec(e.Nat8),jr=e.Record({key_id:e.Record({name:e.Text,curve:I}),derivation_path:e.Vec(e.Vec(e.Nat8)),message_hash:e.Vec(e.Nat8)}),zr=e.Record({signature:e.Vec(e.Nat8)}),Hr=e.Record({canister_id:d}),Kr=e.Record({canister_id:d}),Wr=e.Record({canister_id:d}),Jr=e.Vec(Ue),Gr=e.Record({canister_id:d,sender_canister_version:e.Opt(e.Nat64)}),Yr=e.Record({canister_id:e.Principal,settings:U,sender_canister_version:e.Opt(e.Nat64)}),Qr=e.Record({chunk:e.Vec(e.Nat8),canister_id:e.Principal}),Xr=Ue;return e.Service({bitcoin_get_balance:e.Func([n],[i],[]),bitcoin_get_balance_query:e.Func([s],[c],["query"]),bitcoin_get_current_fee_percentiles:e.Func([u],[_],[]),bitcoin_get_utxos:e.Func([m],[g],[]),bitcoin_get_utxos_query:e.Func([x],[T],["query"]),bitcoin_send_transaction:e.Func([h],[],[]),canister_info:e.Func([w],[V],[]),canister_status:e.Func([k],[Y],[]),clear_chunk_store:e.Func([Q],[],[]),create_canister:e.Func([K],[X],[]),delete_canister:e.Func([Z],[],[]),deposit_cycles:e.Func([Ee],[],[]),ecdsa_public_key:e.Func([ke],[Be],[]),fetch_canister_logs:e.Func([Me],[de],["query"]),http_request:e.Func([qe],[ie],[]),install_chunked_code:e.Func([Ar],[],[]),install_code:e.Func([Fr],[],[]),node_metrics_history:e.Func([Er],[Br],[]),provisional_create_canister_with_cycles:e.Func([Mr],[$r],[]),provisional_top_up_canister:e.Func([qr],[],[]),raw_rand:e.Func([],[Ur],[]),sign_with_ecdsa:e.Func([jr],[zr],[]),start_canister:e.Func([Hr],[],[]),stop_canister:e.Func([Kr],[],[]),stored_chunks:e.Func([Wr],[Jr],[]),uninstall_code:e.Func([Gr],[],[]),update_settings:e.Func([Yr],[],[]),upload_chunk:e.Func([Qr],[Xr],[])})};var nt=({IDL:e})=>{let t=e.Record({updated_at:e.Nat64,orbiter_id:e.Principal,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),r=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,satellite_id:e.Principal}),n=e.Record({cycles:e.Nat,destination_id:e.Principal}),o=e.Variant({Write:e.Null,Admin:e.Null}),i=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:o,expires_at:e.Opt(e.Nat64)}),s=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),c=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),u=e.Record({status:s,memory_size:e.Nat,cycles:e.Nat,settings:c,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),l=e.Record({id:e.Principal,status:u,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),status_at:e.Nat64}),_=e.Variant({Ok:l,Err:e.Text}),m=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:o,expires_at:e.Opt(e.Nat64)}),y=e.Record({enabled:e.Bool,cycles_threshold:e.Opt(e.Nat64)}),a=e.Record({mission_control_cycles_threshold:e.Opt(e.Nat64),orbiters:e.Vec(e.Tuple(e.Principal,y)),satellites:e.Vec(e.Tuple(e.Principal,y)),cycles_threshold:e.Opt(e.Nat64)}),p=e.Record({orbiters:e.Opt(e.Vec(_)),satellites:e.Opt(e.Vec(_)),mission_control:_}),g=e.Record({e8s:e.Nat64});return e.Service({add_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),add_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),create_orbiter:e.Func([e.Opt(e.Text)],[t],[]),create_satellite:e.Func([e.Text],[r],[]),del_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),del_orbiter:e.Func([e.Principal,e.Nat],[],[]),del_orbiters_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),del_satellite:e.Func([e.Principal,e.Nat],[],[]),del_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),deposit_cycles:e.Func([n],[],[]),get_user:e.Func([],[e.Principal],["query"]),list_mission_control_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,i))],["query"]),list_mission_control_statuses:e.Func([],[e.Vec(e.Tuple(e.Nat64,_))],["query"]),list_orbiter_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,_)))],["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,_)))],["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),m],[],[]),set_orbiter:e.Func([e.Principal,e.Opt(e.Text)],[t],[]),set_orbiter_metadata:e.Func([e.Principal,e.Vec(e.Tuple(e.Text,e.Text))],[t],[]),set_orbiters_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal),m],[],[]),set_satellite:e.Func([e.Principal,e.Opt(e.Text)],[r],[]),set_satellite_metadata:e.Func([e.Principal,e.Vec(e.Tuple(e.Text,e.Text))],[r],[]),set_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal),m],[],[]),status:e.Func([a],[p],[]),top_up:e.Func([e.Principal,g],[],[]),unset_orbiter:e.Func([e.Principal],[],[]),unset_satellite:e.Func([e.Principal],[],[]),version:e.Func([],[e.Text],["query"])})};var ot=({IDL:e})=>{let t=e.Record({controllers:e.Vec(e.Principal)}),r=e.Variant({Write:e.Null,Admin:e.Null}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:r,expires_at:e.Opt(e.Nat64)}),o=e.Record({version:e.Opt(e.Nat64)}),i=e.Record({cycles:e.Nat,destination_id:e.Principal}),s=e.Record({to:e.Opt(e.Nat64),from:e.Opt(e.Nat64),satellite_id:e.Opt(e.Principal)}),c=e.Record({key:e.Text,collected_at:e.Nat64}),u=e.Record({inner_height:e.Nat16,inner_width:e.Nat16}),l=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:u,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),_=e.Record({safari:e.Float64,opera:e.Float64,others:e.Float64,firefox:e.Float64,chrome:e.Float64}),m=e.Record({desktop:e.Float64,others:e.Float64,mobile:e.Float64}),y=e.Record({browsers:_,devices:m}),a=e.Record({day:e.Nat8,month:e.Nat8,year:e.Int32}),p=e.Record({bounce_rate:e.Float64,average_page_views_per_session:e.Float64,daily_total_page_views:e.Vec(e.Tuple(a,e.Nat32)),total_page_views:e.Nat32,unique_page_views:e.Nat64,unique_sessions:e.Nat64}),g=e.Record({referrers:e.Vec(e.Tuple(e.Text,e.Nat32)),pages:e.Vec(e.Tuple(e.Text,e.Nat32))}),x=e.Record({updated_at:e.Nat64,session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),T=e.Record({total:e.Vec(e.Tuple(e.Text,e.Nat32))}),h=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),enabled:e.Bool}),d=e.Record({stable:e.Nat64,heap:e.Nat64}),w=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:r,expires_at:e.Opt(e.Nat64)}),R=e.Record({controller:w,controllers:e.Vec(e.Principal)}),P=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:u,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),C=e.Variant({Ok:l,Err:e.Text}),V=e.Variant({Ok:e.Null,Err:e.Vec(e.Tuple(c,e.Text))}),k=e.Record({version:e.Opt(e.Nat64),enabled:e.Bool}),S=e.Record({updated_at:e.Opt(e.Nat64),session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),q=e.Variant({Ok:x,Err:e.Text});return e.Service({del_controllers:e.Func([t],[e.Vec(e.Tuple(e.Principal,n))],[]),del_satellite_config:e.Func([e.Principal,o],[],[]),deposit_cycles:e.Func([i],[],[]),get_page_views:e.Func([s],[e.Vec(e.Tuple(c,l))],["query"]),get_page_views_analytics_clients:e.Func([s],[y],["query"]),get_page_views_analytics_metrics:e.Func([s],[p],["query"]),get_page_views_analytics_top_10:e.Func([s],[g],["query"]),get_track_events:e.Func([s],[e.Vec(e.Tuple(c,x))],["query"]),get_track_events_analytics:e.Func([s],[T],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_satellite_configs:e.Func([],[e.Vec(e.Tuple(e.Principal,h))],["query"]),memory_size:e.Func([],[d],["query"]),set_controllers:e.Func([R],[e.Vec(e.Tuple(e.Principal,n))],[]),set_page_view:e.Func([c,P],[C],[]),set_page_views:e.Func([e.Vec(e.Tuple(c,P))],[V],[]),set_satellite_configs:e.Func([e.Vec(e.Tuple(e.Principal,k))],[e.Vec(e.Tuple(e.Principal,h))],[]),set_track_event:e.Func([c,S],[q],[]),set_track_events:e.Func([e.Vec(e.Tuple(c,S))],[V],[]),version:e.Func([],[e.Text],["query"])})};var it=({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))))}),s=e.Record({storage:i}),c=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),u=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),l=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}),_=e.Variant({Callback:e.Record({token:l,callback:e.Func([],[],[])})}),m=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(_),status_code:e.Nat16}),y=e.Record({token:e.Opt(l),body:e.Vec(e.Nat8)}),a=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),p=e.Record({batch_id:e.Nat}),g=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),x=e.Record({field:g,desc:e.Bool}),T=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),h=e.Record({order:e.Opt(x),owner:e.Opt(e.Principal),matcher:e.Opt(e.Text),paginate:e.Opt(T)}),d=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),w=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),R=e.Record({key:d,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,w)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),P=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,R))}),C=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),V=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,c))}),k=e.Variant({Db:e.Null,Storage:e.Null}),S=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),q=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:S,created_at:e.Nat64,write:S}),Y=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),Q=e.Record({controller:Y,controllers:e.Vec(e.Principal)}),U=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),K=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:S,write:S}),X=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),Z=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([],[s],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(c)],["query"]),http_request:e.Func([u],[m],["query"]),http_request_streaming_callback:e.Func([l],[y],["query"]),init_asset_upload:e.Func([a],[p],[]),list_assets:e.Func([e.Opt(e.Text),h],[P],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,C))],["query"]),list_docs:e.Func([e.Text,h],[V],["query"]),list_rules:e.Func([k],[e.Vec(e.Tuple(e.Text,q))],["query"]),set_config:e.Func([s],[],[]),set_controllers:e.Func([Q],[e.Vec(e.Tuple(e.Principal,n))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,U],[c],[]),set_rule:e.Func([k,e.Text,K],[],[]),upload_asset_chunk:e.Func([X],[Z],[]),version:e.Func([],[e.Text],["query"])})};var st=({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))))}),s=e.Record({storage:i}),c=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),u=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),l=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}),_=e.Variant({Callback:e.Record({token:l,callback:e.Func([],[],[])})}),m=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(_),status_code:e.Nat16}),y=e.Record({token:e.Opt(l),body:e.Vec(e.Nat8)}),a=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),p=e.Record({batch_id:e.Nat}),g=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),x=e.Record({field:g,desc:e.Bool}),T=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),h=e.Record({order:e.Opt(x),matcher:e.Opt(e.Text),paginate:e.Opt(T)}),d=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),w=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),R=e.Record({key:d,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,w)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),P=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,R))}),C=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),V=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,c))}),k=e.Variant({Db:e.Null,Storage:e.Null}),S=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),q=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:S,created_at:e.Nat64,write:S}),Y=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),Q=e.Record({controller:Y,controllers:e.Vec(e.Principal)}),U=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),K=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:S,write:S}),X=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),Z=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([],[s],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(c)],["query"]),http_request:e.Func([u],[m],["query"]),http_request_streaming_callback:e.Func([l],[y],["query"]),init_asset_upload:e.Func([a],[p],[]),list_assets:e.Func([e.Opt(e.Text),h],[P],["query"]),list_controllers:e.Func([],[e.Vec(e.Principal)],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,C))],["query"]),list_docs:e.Func([e.Text,h],[V],["query"]),list_rules:e.Func([k],[e.Vec(e.Tuple(e.Text,q))],["query"]),set_config:e.Func([s],[],[]),set_controllers:e.Func([Q],[e.Vec(e.Tuple(e.Principal,n))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,U],[c],[]),set_rule:e.Func([k,e.Text,K],[],[]),upload_asset_chunk:e.Func([X],[Z],[]),version:e.Func([],[e.Text],["query"])})};var at=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({controllers:e.Vec(e.Principal)}),n=e.Variant({Write:e.Null,Admin:e.Null}),o=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:n,expires_at:e.Opt(e.Nat64)}),i=e.Record({version:e.Opt(e.Nat64)}),s=e.Variant({Db:e.Null,Storage:e.Null}),c=e.Record({cycles:e.Nat,destination_id:e.Principal}),u=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}),l=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),_=e.Record({key:u,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,l)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),m=e.Record({derivation_origin:e.Opt(e.Text)}),y=e.Record({internet_identity:e.Opt(m)}),a=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),p=e.Variant({Deny:e.Null,Allow:e.Null}),g=e.Record({status_code:e.Nat16,location:e.Text}),x=e.Record({iframe:e.Opt(a),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),raw_access:e.Opt(p),redirects:e.Opt(e.Vec(e.Tuple(e.Text,g)))}),T=e.Record({storage:x}),h=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),d=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),certificate_version:e.Opt(e.Nat16)}),w=e.Variant({Heap:e.Null,Stable:e.Null}),R=e.Record({memory:w,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}),P=e.Variant({Callback:e.Record({token:R,callback:e.Func([],[],["query"])})}),C=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(P),status_code:e.Nat16}),V=e.Record({token:e.Opt(R),body:e.Vec(e.Nat8)}),k=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}),S=e.Record({batch_id:e.Nat}),q=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),Y=e.Record({field:q,desc:e.Bool}),Q=e.Record({key:e.Opt(e.Text),description:e.Opt(e.Text)}),U=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),K=e.Record({order:e.Opt(Y),owner:e.Opt(e.Principal),matcher:e.Opt(Q),paginate:e.Opt(U)}),X=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,_)),items_length:e.Nat64}),Z=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),Ee=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,h)),items_length:e.Nat64}),I=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),ke=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(w),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:I,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),write:I}),Be=e.Record({stable:e.Nat64,heap:e.Nat64}),Me=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:n,expires_at:e.Opt(e.Nat64)}),$e=e.Record({controller:Me,controllers:e.Vec(e.Principal)}),de=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),me=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(w),max_size:e.Opt(e.Nat),read:I,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),write:I}),ie=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),qe=e.Record({chunk_id:e.Nat});return e.Service({build_version:e.Func([],[e.Text],["query"]),commit_asset_upload:e.Func([t],[],[]),count_assets:e.Func([e.Text],[e.Nat64],["query"]),count_docs:e.Func([e.Text],[e.Nat64],["query"]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([r],[e.Vec(e.Tuple(e.Principal,o))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,i],[],[]),del_docs:e.Func([e.Text],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,i))],[],[]),del_rule:e.Func([s,e.Text,i],[],[]),deposit_cycles:e.Func([c],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(_)],["query"]),get_auth_config:e.Func([],[e.Opt(y)],["query"]),get_config:e.Func([],[T],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(h)],["query"]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(_)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(h)))],["query"]),http_request:e.Func([d],[C],["query"]),http_request_streaming_callback:e.Func([R],[V],["query"]),init_asset_upload:e.Func([k],[S],[]),list_assets:e.Func([e.Text,K],[X],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,o))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Z))],["query"]),list_docs:e.Func([e.Text,K],[Ee],["query"]),list_rules:e.Func([s],[e.Vec(e.Tuple(e.Text,ke))],["query"]),memory_size:e.Func([],[Be],["query"]),set_auth_config:e.Func([y],[],[]),set_config:e.Func([T],[],[]),set_controllers:e.Func([$e],[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,de],[h],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,de))],[e.Vec(e.Tuple(e.Text,h))],[]),set_rule:e.Func([s,e.Text,me],[],[]),upload_asset_chunk:e.Func([ie],[qe],[]),version:e.Func([],[e.Text],["query"])})};var ut=async({satelliteId:e,...t})=>se({canisterId:e,...t,idlFactory:st}),O=async({satelliteId:e,...t})=>se({canisterId:e,...t,idlFactory:at}),pt=async({satelliteId:e,...t})=>se({canisterId:e,...t,idlFactory:it}),L=async({missionControlId:e,...t})=>se({canisterId:e,...t,idlFactory:nt}),_e=async({orbiterId:e,...t})=>se({canisterId:e,...t,idlFactory:ot}),se=async({canisterId:e,idlFactory:t,...r})=>{if(en(e))throw new Error("No canister ID provided.");return je({canisterId:e,idlFactory:t,...r})},dt=lt.fromText("aaaaa-aa"),ct=(e,t,r)=>{let n=t[0],o=dt;return n&&typeof n=="object"&&n.canister_id&&(o=lt.from(n.canister_id)),{effectiveCanisterId:o}},mt=e=>je({canisterId:dt.toText(),config:{callTransform:ct,queryTransform:ct},idlFactory:rt,...e});var D=async({actor:e,code:t})=>{let{install_code:r}=await mt(e);return r({...t,sender_canister_version:[]})},_t=async({canisterId:e,path:t,...r})=>{nn(e,"A canister ID must be provided to request its status.");let n=await ze(r);return(await tn.request({canisterId:rn.from(e),agent:n,paths:[{kind:"metadata",key:t,path:t,decodeStrategy:"utf-8"}]})).get(t)};var ht=async({missionControl:e})=>(await L(e)).version(),ft=async({missionControl:e})=>(await L(e)).get_user(),yt=async({missionControl:e})=>(await L(e)).list_mission_control_controllers(),gt=async({missionControl:e,satelliteIds:t,controllerIds:r,controller:n})=>(await L(e)).set_satellites_controllers(t,r,n),xt=async({missionControl:e,controllerIds:t,controller:r})=>(await L(e)).set_mission_control_controllers(t,r);import{Principal as on}from"@dfinity/principal";import{nonNullish as sn,toNullable as an}from"@junobuild/utils";var He=({controllerId:e,profile:t})=>({controllerIds:[on.fromText(e)],controller:cn(t)}),cn=e=>({metadata:sn(e)&&e!==""?[["profile",e]]:[],expires_at:an(void 0),scope:{Admin:null}});var F={};Ir(F,{Bool:()=>Vt,BoolClass:()=>Te,ConstructType:()=>$,Empty:()=>vt,EmptyClass:()=>ge,FixedIntClass:()=>H,FixedNatClass:()=>M,Float32:()=>Ot,Float64:()=>Ft,FloatClass:()=>ce,Func:()=>Qt,FuncClass:()=>ue,Int:()=>St,Int16:()=>kt,Int32:()=>Bt,Int64:()=>Mt,Int8:()=>Et,IntClass:()=>Ne,Nat:()=>At,Nat16:()=>qt,Nat32:()=>Ut,Nat64:()=>jt,Nat8:()=>$t,NatClass:()=>ve,Null:()=>Rt,NullClass:()=>we,Opt:()=>Wt,OptClass:()=>re,PrimitiveType:()=>E,Principal:()=>zt,PrincipalClass:()=>Ce,Rec:()=>Yt,RecClass:()=>G,Record:()=>Jt,RecordClass:()=>le,Reserved:()=>Pt,ReservedClass:()=>te,Service:()=>Xt,ServiceClass:()=>Se,Text:()=>Ct,TextClass:()=>be,Tuple:()=>Ht,TupleClass:()=>Ve,Type:()=>ee,Unknown:()=>mn,UnknownClass:()=>xe,Variant:()=>Gt,VariantClass:()=>Re,Vec:()=>Kt,VecClass:()=>Pe,Visitor:()=>ye,decode:()=>dn,encode:()=>pn});import{Principal as un}from"@dfinity/principal";function f(...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}var j=class{constructor(t,r=t?.byteLength||0){this._buffer=We(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return We(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}};function Ke(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}function We(e){return e instanceof Uint8Array?Ke(e):e instanceof ArrayBuffer?e:Array.isArray(e)?Ke(new Uint8Array(e)):"buffer"in e?We(e.buffer):Ke(new Uint8Array(e))}function ln(e){let r=new TextEncoder().encode(e),n=0;for(let o of r)n=(n*223+o)%2**32;return n}function B(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 ln(e)}function Tt(){throw new Error("unexpected end of buffer")}function J(e,t){return e.byteLength<t&&Tt(),e.read(t)}function W(e){let t=e.readUint8();return t===void 0&&Tt(),t}function N(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 j(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}function A(e){let t=BigInt(1),r=BigInt(0),n;do n=W(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}function v(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 j(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 s=i%BigInt(128);return Number(t?BigInt(128)-s-BigInt(1):s)}return n.buffer}function z(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if(!(t[r]&64))return A(e);break}let n=new Uint8Array(J(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)}function wt(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return Je(e,t)}function Je(e,t){e=BigInt(e);let r=new j(new ArrayBuffer(Math.min(1,t)),0),n=0,o=BigInt(256),i=BigInt(0),s=Number(e%o);for(r.write(new Uint8Array([s]));++n<t;)e<0&&i===BigInt(0)&&s!==0&&(i=BigInt(1)),s=Number((e/o-i)%BigInt(256)),r.write(new Uint8Array([s])),o*=BigInt(256);return r.buffer}function Ge(e,t){let r=BigInt(W(e)),n=BigInt(1),o=0;for(;++o<t;){n*=BigInt(256);let i=BigInt(W(e));r=r+n*i}return r}function bt(e,t){let r=Ge(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}function he(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}var fe="DIDL",Nt=400;function ae(e,t,r){return e.map((n,o)=>r(n,t[o]))}var Ye=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=N(this._typs.length),r=f(...this._typs);return f(t,r)}indexOf(t){if(!this._idx.has(t))throw new Error("Missing type index for "+t);return v(this._idx.get(t)||0)}},ye=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,s)=>[`_${s}_`,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)}},ee=class{display(){return this.name}valueToString(t){return b(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}},E=class extends ee{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){}},$=class extends ee{checkType(t){if(t instanceof G){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)}},ge=class extends E{accept(t,r){return t.visitEmpty(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return v(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},xe=class extends ee{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: ${b(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 G?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"}},Te=class extends E{accept(t,r){return t.visitBool(this,r)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return v(-2)}decodeValue(t,r){switch(this.checkType(r),W(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},we=class extends E{accept(t,r){return t.visitNull(this,r)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return v(-1)}decodeValue(t,r){return this.checkType(r),null}get name(){return"null"}},te=class extends E{accept(t,r){return t.visitReserved(this,r)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return v(-16)}decodeValue(t,r){return r.name!==this.name&&r.decodeValue(t,r),null}get name(){return"reserved"}},be=class extends E{accept(t,r){return t.visitText(this,r)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){let r=new TextEncoder().encode(t),n=N(r.byteLength);return f(n,r)}encodeType(){return v(-15)}decodeValue(t,r){this.checkType(r);let n=A(t),o=J(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(o)}get name(){return"text"}valueToString(t){return'"'+t+'"'}},Ne=class extends E{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: ${b(t)}`)}encodeValue(t){return v(t)}encodeType(){return v(-4)}decodeValue(t,r){return this.checkType(r),z(t)}get name(){return"int"}valueToString(t){return t.toString()}},ve=class extends E{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: ${b(t)}`)}encodeValue(t){return N(t)}encodeType(){return v(-3)}decodeValue(t,r){return this.checkType(r),A(t)}get name(){return"nat"}valueToString(t){return t.toString()}},ce=class extends E{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: ${b(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 v(t)}decodeValue(t,r){this.checkType(r);let n=J(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()}},H=class extends E{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedInt(this,r)}covariant(t){let r=he(this._bits-1)*BigInt(-1),n=he(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: ${b(t)}`)}encodeValue(t){return Je(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return v(-9-t)}decodeValue(t,r){this.checkType(r);let n=bt(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}},M=class extends E{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedNat(this,r)}covariant(t){let r=he(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: ${b(t)}`)}encodeValue(t){return wt(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return v(-5-t)}decodeValue(t,r){this.checkType(r);let n=Ge(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}},Pe=class e extends ${constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof M&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof M?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:
1
+ var Lr=Object.defineProperty;var en=(e,t)=>{for(var r in t)Lr(e,r,{get:t[r],enumerable:!0})};import{Principal as gn}from"@dfinity/principal";import{CanisterStatus as on}from"@dfinity/agent";import{Principal as sn}from"@dfinity/principal";import{assertNonNullish as an}from"@junobuild/utils";import{Actor as tn,HttpAgent as rn}from"@dfinity/agent";import{nonNullish as st}from"@junobuild/utils";var Ke=async({canisterId:e,idlFactory:t,config:r,...n})=>{let o=await We(n);return tn.createActor(t,{agent:o,canisterId:e,...r!==void 0?r:{}})},We=async({identity:e,fetch:t,container:r})=>{let n=st(r)&&r!==!1,o=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io",i=new rn({identity:e,host:o,retryTimes:10,...st(t)&&{fetch:t}});return n&&await i.fetchRootKey(),i};import{Principal as _t}from"@dfinity/principal";import{isNullish as nn}from"@junobuild/utils";var at=({IDL:e})=>{let t=e.Variant({mainnet:e.Null,testnet:e.Null}),r=e.Text,n=e.Record({network:t,address:r,min_confirmations:e.Opt(e.Nat32)}),o=e.Nat64,i=o,s=e.Record({network:t,address:r,min_confirmations:e.Opt(e.Nat32)}),c=o,u=e.Record({network:t}),l=e.Nat64,m=e.Vec(l),_=e.Record({network:t,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:r}),y=e.Vec(e.Nat8),a=e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32}),p=e.Record({height:e.Nat32,value:o,outpoint:a}),f=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:e.Nat32,tip_block_hash:y,utxos:e.Vec(p)}),x=e.Record({network:t,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:r}),T=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:e.Nat32,tip_block_hash:y,utxos:e.Vec(p)}),g=e.Record({transaction:e.Vec(e.Nat8),network:t}),d=e.Principal,R=e.Record({canister_id:d,num_requested_changes:e.Opt(e.Nat64)}),N=e.Variant({from_user:e.Record({user_id:e.Principal}),from_canister:e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal})}),C=e.Variant({creation:e.Record({controllers:e.Vec(e.Principal)}),code_deployment:e.Record({mode:e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),module_hash:e.Vec(e.Nat8)}),controllers_change:e.Record({controllers:e.Vec(e.Principal)}),code_uninstall:e.Null}),v=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:N,details:C}),w=e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec(v),total_num_changes:e.Nat64}),k=e.Record({canister_id:d}),S=e.Variant({controllers:e.Null,public:e.Null}),q=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),reserved_cycles_limit:e.Nat,log_visibility:S,memory_allocation:e.Nat,compute_allocation:e.Nat}),Y=e.Record({status:e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),memory_size:e.Nat,cycles:e.Nat,settings:q,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8)),reserved_cycles:e.Nat}),Q=e.Record({canister_id:d}),U=e.Record({freezing_threshold:e.Opt(e.Nat),controllers:e.Opt(e.Vec(e.Principal)),reserved_cycles_limit:e.Opt(e.Nat),log_visibility:e.Opt(S),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),X=e.Record({settings:e.Opt(U),sender_canister_version:e.Opt(e.Nat64)}),K=e.Record({canister_id:d}),Z=e.Record({canister_id:d}),ke=e.Record({canister_id:d}),se=e.Variant({secp256k1:e.Null}),Me=e.Record({key_id:e.Record({name:e.Text,curve:se}),canister_id:e.Opt(d),derivation_path:e.Vec(e.Vec(e.Nat8))}),Be=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),$e=e.Record({canister_id:d}),D=e.Record({idx:e.Nat64,timestamp_nanos:e.Nat64,content:e.Vec(e.Nat8)}),qe=e.Record({canister_log_records:e.Vec(D)}),_e=e.Record({value:e.Text,name:e.Text}),ae=e.Record({status:e.Nat,body:e.Vec(e.Nat8),headers:e.Vec(_e)}),Ue=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:ae})],[ae],["query"]),context:e.Vec(e.Nat8)})),headers:e.Vec(_e)}),L=e.Vec(e.Nat8),ze=e.Record({arg:e.Vec(e.Nat8),wasm_module_hash:e.Vec(e.Nat8),mode:e.Variant({reinstall:e.Null,upgrade:e.Opt(e.Record({skip_pre_upgrade:e.Opt(e.Bool)})),install:e.Null}),chunk_hashes_list:e.Vec(L),target_canister:d,sender_canister_version:e.Opt(e.Nat64),storage_canister:e.Opt(d)}),je=e.Vec(e.Nat8),He=e.Record({arg:e.Vec(e.Nat8),wasm_module:je,mode:e.Variant({reinstall:e.Null,upgrade:e.Opt(e.Record({skip_pre_upgrade:e.Opt(e.Bool)})),install:e.Null}),canister_id:d,sender_canister_version:e.Opt(e.Nat64)}),Br=e.Record({start_at_timestamp_nanos:e.Nat64,subnet_id:e.Principal}),$r=e.Record({num_block_failures_total:e.Nat64,node_id:e.Principal,num_blocks_total:e.Nat64}),qr=e.Vec(e.Record({timestamp_nanos:e.Nat64,node_metrics:e.Vec($r)})),Ur=e.Record({settings:e.Opt(U),specified_id:e.Opt(d),amount:e.Opt(e.Nat),sender_canister_version:e.Opt(e.Nat64)}),zr=e.Record({canister_id:d}),jr=e.Record({canister_id:d,amount:e.Nat}),Hr=e.Vec(e.Nat8),Kr=e.Record({key_id:e.Record({name:e.Text,curve:se}),derivation_path:e.Vec(e.Vec(e.Nat8)),message_hash:e.Vec(e.Nat8)}),Wr=e.Record({signature:e.Vec(e.Nat8)}),Gr=e.Record({canister_id:d}),Jr=e.Record({canister_id:d}),Yr=e.Record({canister_id:d}),Qr=e.Vec(L),Xr=e.Record({canister_id:d,sender_canister_version:e.Opt(e.Nat64)}),Zr=e.Record({canister_id:e.Principal,settings:U,sender_canister_version:e.Opt(e.Nat64)}),Ir=e.Record({chunk:e.Vec(e.Nat8),canister_id:e.Principal}),Dr=L;return e.Service({bitcoin_get_balance:e.Func([n],[i],[]),bitcoin_get_balance_query:e.Func([s],[c],["query"]),bitcoin_get_current_fee_percentiles:e.Func([u],[m],[]),bitcoin_get_utxos:e.Func([_],[f],[]),bitcoin_get_utxos_query:e.Func([x],[T],["query"]),bitcoin_send_transaction:e.Func([g],[],[]),canister_info:e.Func([R],[w],[]),canister_status:e.Func([k],[Y],[]),clear_chunk_store:e.Func([Q],[],[]),create_canister:e.Func([X],[K],[]),delete_canister:e.Func([Z],[],[]),deposit_cycles:e.Func([ke],[],[]),ecdsa_public_key:e.Func([Me],[Be],[]),fetch_canister_logs:e.Func([$e],[qe],["query"]),http_request:e.Func([Ue],[ae],[]),install_chunked_code:e.Func([ze],[],[]),install_code:e.Func([He],[],[]),node_metrics_history:e.Func([Br],[qr],[]),provisional_create_canister_with_cycles:e.Func([Ur],[zr],[]),provisional_top_up_canister:e.Func([jr],[],[]),raw_rand:e.Func([],[Hr],[]),sign_with_ecdsa:e.Func([Kr],[Wr],[]),start_canister:e.Func([Gr],[],[]),stop_canister:e.Func([Jr],[],[]),stored_chunks:e.Func([Yr],[Qr],[]),uninstall_code:e.Func([Xr],[],[]),update_settings:e.Func([Zr],[],[]),upload_chunk:e.Func([Ir],[Dr],[])})};var ct=({IDL:e})=>{let t=e.Record({updated_at:e.Nat64,orbiter_id:e.Principal,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),r=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,satellite_id:e.Principal}),n=e.Record({cycles:e.Nat,destination_id:e.Principal}),o=e.Variant({Write:e.Null,Admin:e.Null}),i=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:o,expires_at:e.Opt(e.Nat64)}),s=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),c=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),u=e.Record({status:s,memory_size:e.Nat,cycles:e.Nat,settings:c,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),l=e.Record({id:e.Principal,status:u,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),status_at:e.Nat64}),m=e.Variant({Ok:l,Err:e.Text}),_=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:o,expires_at:e.Opt(e.Nat64)}),y=e.Record({enabled:e.Bool,cycles_threshold:e.Opt(e.Nat64)}),a=e.Record({mission_control_cycles_threshold:e.Opt(e.Nat64),orbiters:e.Vec(e.Tuple(e.Principal,y)),satellites:e.Vec(e.Tuple(e.Principal,y)),cycles_threshold:e.Opt(e.Nat64)}),p=e.Record({orbiters:e.Opt(e.Vec(m)),satellites:e.Opt(e.Vec(m)),mission_control:m}),f=e.Record({e8s:e.Nat64});return e.Service({add_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),add_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),create_orbiter:e.Func([e.Opt(e.Text)],[t],[]),create_satellite:e.Func([e.Text],[r],[]),del_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),del_orbiter:e.Func([e.Principal,e.Nat],[],[]),del_orbiters_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),del_satellite:e.Func([e.Principal,e.Nat],[],[]),del_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),deposit_cycles:e.Func([n],[],[]),get_user:e.Func([],[e.Principal],["query"]),list_mission_control_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,i))],["query"]),list_mission_control_statuses:e.Func([],[e.Vec(e.Tuple(e.Nat64,m))],["query"]),list_orbiter_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,m)))],["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,m)))],["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),_],[],[]),set_orbiter:e.Func([e.Principal,e.Opt(e.Text)],[t],[]),set_orbiter_metadata:e.Func([e.Principal,e.Vec(e.Tuple(e.Text,e.Text))],[t],[]),set_orbiters_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal),_],[],[]),set_satellite:e.Func([e.Principal,e.Opt(e.Text)],[r],[]),set_satellite_metadata:e.Func([e.Principal,e.Vec(e.Tuple(e.Text,e.Text))],[r],[]),set_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal),_],[],[]),status:e.Func([a],[p],[]),top_up:e.Func([e.Principal,f],[],[]),unset_orbiter:e.Func([e.Principal],[],[]),unset_satellite:e.Func([e.Principal],[],[]),version:e.Func([],[e.Text],["query"])})};var lt=({IDL:e})=>{let t=e.Record({controllers:e.Vec(e.Principal)}),r=e.Variant({Write:e.Null,Admin:e.Null}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:r,expires_at:e.Opt(e.Nat64)}),o=e.Record({version:e.Opt(e.Nat64)}),i=e.Record({cycles:e.Nat,destination_id:e.Principal}),s=e.Record({to:e.Opt(e.Nat64),from:e.Opt(e.Nat64),satellite_id:e.Opt(e.Principal)}),c=e.Record({key:e.Text,collected_at:e.Nat64}),u=e.Record({inner_height:e.Nat16,inner_width:e.Nat16}),l=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:u,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),m=e.Record({safari:e.Float64,opera:e.Float64,others:e.Float64,firefox:e.Float64,chrome:e.Float64}),_=e.Record({desktop:e.Float64,others:e.Float64,mobile:e.Float64}),y=e.Record({browsers:m,devices:_}),a=e.Record({day:e.Nat8,month:e.Nat8,year:e.Int32}),p=e.Record({bounce_rate:e.Float64,average_page_views_per_session:e.Float64,daily_total_page_views:e.Vec(e.Tuple(a,e.Nat32)),total_page_views:e.Nat32,unique_page_views:e.Nat64,unique_sessions:e.Nat64}),f=e.Record({referrers:e.Vec(e.Tuple(e.Text,e.Nat32)),pages:e.Vec(e.Tuple(e.Text,e.Nat32))}),x=e.Record({updated_at:e.Nat64,session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),T=e.Record({total:e.Vec(e.Tuple(e.Text,e.Nat32))}),g=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),enabled:e.Bool}),d=e.Record({stable:e.Nat64,heap:e.Nat64}),R=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:r,expires_at:e.Opt(e.Nat64)}),N=e.Record({controller:R,controllers:e.Vec(e.Principal)}),C=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:u,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),v=e.Variant({Ok:l,Err:e.Text}),w=e.Variant({Ok:e.Null,Err:e.Vec(e.Tuple(c,e.Text))}),k=e.Record({version:e.Opt(e.Nat64),enabled:e.Bool}),S=e.Record({updated_at:e.Opt(e.Nat64),session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),q=e.Variant({Ok:x,Err:e.Text});return e.Service({del_controllers:e.Func([t],[e.Vec(e.Tuple(e.Principal,n))],[]),del_satellite_config:e.Func([e.Principal,o],[],[]),deposit_cycles:e.Func([i],[],[]),get_page_views:e.Func([s],[e.Vec(e.Tuple(c,l))],["query"]),get_page_views_analytics_clients:e.Func([s],[y],["query"]),get_page_views_analytics_metrics:e.Func([s],[p],["query"]),get_page_views_analytics_top_10:e.Func([s],[f],["query"]),get_track_events:e.Func([s],[e.Vec(e.Tuple(c,x))],["query"]),get_track_events_analytics:e.Func([s],[T],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_satellite_configs:e.Func([],[e.Vec(e.Tuple(e.Principal,g))],["query"]),memory_size:e.Func([],[d],["query"]),set_controllers:e.Func([N],[e.Vec(e.Tuple(e.Principal,n))],[]),set_page_view:e.Func([c,C],[v],[]),set_page_views:e.Func([e.Vec(e.Tuple(c,C))],[w],[]),set_satellite_configs:e.Func([e.Vec(e.Tuple(e.Principal,k))],[e.Vec(e.Tuple(e.Principal,g))],[]),set_track_event:e.Func([c,S],[q],[]),set_track_events:e.Func([e.Vec(e.Tuple(c,S))],[w],[]),version:e.Func([],[e.Text],["query"])})};var ut=({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))))}),s=e.Record({storage:i}),c=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),u=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),l=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}),m=e.Variant({Callback:e.Record({token:l,callback:e.Func([],[],[])})}),_=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(m),status_code:e.Nat16}),y=e.Record({token:e.Opt(l),body:e.Vec(e.Nat8)}),a=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),p=e.Record({batch_id:e.Nat}),f=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),x=e.Record({field:f,desc:e.Bool}),T=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),g=e.Record({order:e.Opt(x),owner:e.Opt(e.Principal),matcher:e.Opt(e.Text),paginate:e.Opt(T)}),d=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}),N=e.Record({key:d,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,N))}),v=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),w=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,c))}),k=e.Variant({Db:e.Null,Storage:e.Null}),S=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),q=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:S,created_at:e.Nat64,write:S}),Y=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),Q=e.Record({controller:Y,controllers:e.Vec(e.Principal)}),U=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),X=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:S,write:S}),K=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),Z=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([],[s],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(c)],["query"]),http_request:e.Func([u],[_],["query"]),http_request_streaming_callback:e.Func([l],[y],["query"]),init_asset_upload:e.Func([a],[p],[]),list_assets:e.Func([e.Opt(e.Text),g],[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,v))],["query"]),list_docs:e.Func([e.Text,g],[w],["query"]),list_rules:e.Func([k],[e.Vec(e.Tuple(e.Text,q))],["query"]),set_config:e.Func([s],[],[]),set_controllers:e.Func([Q],[e.Vec(e.Tuple(e.Principal,n))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,U],[c],[]),set_rule:e.Func([k,e.Text,X],[],[]),upload_asset_chunk:e.Func([K],[Z],[]),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))))}),s=e.Record({storage:i}),c=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),u=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),l=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}),m=e.Variant({Callback:e.Record({token:l,callback:e.Func([],[],[])})}),_=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(m),status_code:e.Nat16}),y=e.Record({token:e.Opt(l),body:e.Vec(e.Nat8)}),a=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),p=e.Record({batch_id:e.Nat}),f=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),x=e.Record({field:f,desc:e.Bool}),T=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),g=e.Record({order:e.Opt(x),matcher:e.Opt(e.Text),paginate:e.Opt(T)}),d=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}),N=e.Record({key:d,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,N))}),v=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),w=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,c))}),k=e.Variant({Db:e.Null,Storage:e.Null}),S=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),q=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:S,created_at:e.Nat64,write:S}),Y=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),Q=e.Record({controller:Y,controllers:e.Vec(e.Principal)}),U=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),X=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:S,write:S}),K=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),Z=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([],[s],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(c)],["query"]),http_request:e.Func([u],[_],["query"]),http_request_streaming_callback:e.Func([l],[y],["query"]),init_asset_upload:e.Func([a],[p],[]),list_assets:e.Func([e.Opt(e.Text),g],[C],["query"]),list_controllers:e.Func([],[e.Vec(e.Principal)],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,v))],["query"]),list_docs:e.Func([e.Text,g],[w],["query"]),list_rules:e.Func([k],[e.Vec(e.Tuple(e.Text,q))],["query"]),set_config:e.Func([s],[],[]),set_controllers:e.Func([Q],[e.Vec(e.Tuple(e.Principal,n))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,U],[c],[]),set_rule:e.Func([k,e.Text,X],[],[]),upload_asset_chunk:e.Func([K],[Z],[]),version:e.Func([],[e.Text],["query"])})};var dt=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({controllers:e.Vec(e.Principal)}),n=e.Variant({Write:e.Null,Admin:e.Null}),o=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:n,expires_at:e.Opt(e.Nat64)}),i=e.Record({version:e.Opt(e.Nat64)}),s=e.Variant({Db:e.Null,Storage:e.Null}),c=e.Record({version:e.Opt(e.Nat64)}),u=e.Record({cycles:e.Nat,destination_id:e.Principal}),l=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}),m=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),_=e.Record({key:l,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,m)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),y=e.Record({derivation_origin:e.Opt(e.Text)}),a=e.Record({internet_identity:e.Opt(y)}),p=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),f=e.Record({max_memory_size:e.Opt(p)}),x=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),T=e.Variant({Deny:e.Null,Allow:e.Null}),g=e.Record({status_code:e.Nat16,location:e.Text}),d=e.Record({iframe:e.Opt(x),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),max_memory_size:e.Opt(p),raw_access:e.Opt(T),redirects:e.Opt(e.Vec(e.Tuple(e.Text,g)))}),R=e.Record({db:e.Opt(f),authentication:e.Opt(a),storage:d}),N=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),C=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),certificate_version:e.Opt(e.Nat16)}),v=e.Variant({Heap:e.Null,Stable:e.Null}),w=e.Record({memory:v,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),k=e.Variant({Callback:e.Record({token:w,callback:e.Func([],[],["query"])})}),S=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(k),status_code:e.Nat16}),q=e.Record({token:e.Opt(w),body:e.Vec(e.Nat8)}),Y=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}),Q=e.Record({batch_id:e.Nat}),U=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),X=e.Record({field:U,desc:e.Bool}),K=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),Z=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(K),description:e.Opt(e.Text),created_at:e.Opt(K)}),ke=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),se=e.Record({order:e.Opt(X),owner:e.Opt(e.Principal),matcher:e.Opt(Z),paginate:e.Opt(ke)}),Me=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,_)),items_length:e.Nat64}),Be=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),$e=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,N)),items_length:e.Nat64}),D=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),qe=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(v),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:D,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),write:D}),_e=e.Record({stable:e.Nat64,heap:e.Nat64}),ae=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:n,expires_at:e.Opt(e.Nat64)}),Ue=e.Record({controller:ae,controllers:e.Vec(e.Principal)}),L=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),ze=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(v),max_size:e.Opt(e.Nat),read:D,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),write:D}),je=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),He=e.Record({chunk_id:e.Nat});return e.Service({build_version:e.Func([],[e.Text],["query"]),commit_asset_upload:e.Func([t],[],[]),count_assets:e.Func([e.Text],[e.Nat64],["query"]),count_docs:e.Func([e.Text],[e.Nat64],["query"]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([r],[e.Vec(e.Tuple(e.Principal,o))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,i],[],[]),del_docs:e.Func([e.Text],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,i))],[],[]),del_rule:e.Func([s,e.Text,c],[],[]),deposit_cycles:e.Func([u],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(_)],["query"]),get_auth_config:e.Func([],[e.Opt(a)],["query"]),get_config:e.Func([],[R],[]),get_db_config:e.Func([],[e.Opt(f)],["query"]),get_doc:e.Func([e.Text,e.Text],[e.Opt(N)],["query"]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(_)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(N)))],["query"]),get_storage_config:e.Func([],[d],["query"]),http_request:e.Func([C],[S],["query"]),http_request_streaming_callback:e.Func([w],[q],["query"]),init_asset_upload:e.Func([Y],[Q],[]),list_assets:e.Func([e.Text,se],[Me],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,o))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Be))],["query"]),list_docs:e.Func([e.Text,se],[$e],["query"]),list_rules:e.Func([s],[e.Vec(e.Tuple(e.Text,qe))],["query"]),memory_size:e.Func([],[_e],["query"]),set_auth_config:e.Func([a],[],[]),set_controllers:e.Func([Ue],[e.Vec(e.Tuple(e.Principal,o))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([f],[],[]),set_doc:e.Func([e.Text,e.Text,L],[N],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,L))],[e.Vec(e.Tuple(e.Text,N))],[]),set_rule:e.Func([s,e.Text,ze],[],[]),set_storage_config:e.Func([d],[],[]),upload_asset_chunk:e.Func([je],[He],[]),version:e.Func([],[e.Text],["query"])})};var ht=async({satelliteId:e,...t})=>ce({canisterId:e,...t,idlFactory:pt}),O=async({satelliteId:e,...t})=>ce({canisterId:e,...t,idlFactory:dt}),ft=async({satelliteId:e,...t})=>ce({canisterId:e,...t,idlFactory:ut}),ee=async({missionControlId:e,...t})=>ce({canisterId:e,...t,idlFactory:ct}),he=async({orbiterId:e,...t})=>ce({canisterId:e,...t,idlFactory:lt}),ce=async({canisterId:e,idlFactory:t,...r})=>{if(nn(e))throw new Error("No canister ID provided.");return Ke({canisterId:e,idlFactory:t,...r})},yt=_t.fromText("aaaaa-aa"),mt=(e,t,r)=>{let n=t[0],o=yt;return n&&typeof n=="object"&&n.canister_id&&(o=_t.from(n.canister_id)),{effectiveCanisterId:o}},gt=e=>Ke({canisterId:yt.toText(),config:{callTransform:mt,queryTransform:mt},idlFactory:at,...e});var I=async({actor:e,code:t})=>{let{install_code:r}=await gt(e);return r({...t,sender_canister_version:[]})},xt=async({canisterId:e,path:t,...r})=>{an(e,"A canister ID must be provided to request its status.");let n=await We(r);return(await on.request({canisterId:sn.from(e),agent:n,paths:[{kind:"metadata",key:t,path:t,decodeStrategy:"utf-8"}]})).get(t)};var Tt=async({missionControl:e})=>(await ee(e)).version(),wt=async({missionControl:e})=>(await ee(e)).get_user(),bt=async({missionControl:e})=>(await ee(e)).list_mission_control_controllers(),Nt=async({missionControl:e,satelliteIds:t,controllerIds:r,controller:n})=>(await ee(e)).set_satellites_controllers(t,r,n),vt=async({missionControl:e,controllerIds:t,controller:r})=>(await ee(e)).set_mission_control_controllers(t,r);import{Principal as cn}from"@dfinity/principal";import{nonNullish as ln,toNullable as un}from"@junobuild/utils";var Ge=({controllerId:e,profile:t})=>({controllerIds:[cn.fromText(e)],controller:pn(t)}),pn=e=>({metadata:ln(e)&&e!==""?[["profile",e]]:[],expires_at:un(void 0),scope:{Admin:null}});var F={};en(F,{Bool:()=>At,BoolClass:()=>we,ConstructType:()=>$,Empty:()=>St,EmptyClass:()=>xe,FixedIntClass:()=>H,FixedNatClass:()=>B,Float32:()=>Bt,Float64:()=>$t,FloatClass:()=>ue,Func:()=>Lt,FuncClass:()=>de,Int:()=>kt,Int16:()=>Ut,Int32:()=>zt,Int64:()=>jt,Int8:()=>qt,IntClass:()=>ve,Nat:()=>Mt,Nat16:()=>Kt,Nat32:()=>Wt,Nat64:()=>Gt,Nat8:()=>Ht,NatClass:()=>Pe,Null:()=>Ft,NullClass:()=>be,Opt:()=>Xt,OptClass:()=>ne,PrimitiveType:()=>E,Principal:()=>Jt,PrincipalClass:()=>Se,Rec:()=>Dt,RecClass:()=>J,Record:()=>Zt,RecordClass:()=>pe,Reserved:()=>Ot,ReservedClass:()=>re,Service:()=>er,ServiceClass:()=>Oe,Text:()=>Et,TextClass:()=>Ne,Tuple:()=>Yt,TupleClass:()=>Re,Type:()=>te,Unknown:()=>fn,UnknownClass:()=>Te,Variant:()=>It,VariantClass:()=>Ce,Vec:()=>Qt,VecClass:()=>Ve,Visitor:()=>ge,decode:()=>hn,encode:()=>_n});import{Principal as mn}from"@dfinity/principal";function h(...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}var z=class{constructor(t,r=t?.byteLength||0){this._buffer=Ye(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return Ye(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}};function Je(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}function Ye(e){return e instanceof Uint8Array?Je(e):e instanceof ArrayBuffer?e:Array.isArray(e)?Je(new Uint8Array(e)):"buffer"in e?Ye(e.buffer):Je(new Uint8Array(e))}function dn(e){let r=new TextEncoder().encode(e),n=0;for(let o of r)n=(n*223+o)%2**32;return n}function M(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 dn(e)}function Pt(){throw new Error("unexpected end of buffer")}function G(e,t){return e.byteLength<t&&Pt(),e.read(t)}function W(e){let t=e.readUint8();return t===void 0&&Pt(),t}function P(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 z(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}function A(e){let t=BigInt(1),r=BigInt(0),n;do n=W(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}function V(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 z(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 s=i%BigInt(128);return Number(t?BigInt(128)-s-BigInt(1):s)}return n.buffer}function j(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if(!(t[r]&64))return A(e);break}let n=new Uint8Array(G(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)}function Vt(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return Qe(e,t)}function Qe(e,t){e=BigInt(e);let r=new z(new ArrayBuffer(Math.min(1,t)),0),n=0,o=BigInt(256),i=BigInt(0),s=Number(e%o);for(r.write(new Uint8Array([s]));++n<t;)e<0&&i===BigInt(0)&&s!==0&&(i=BigInt(1)),s=Number((e/o-i)%BigInt(256)),r.write(new Uint8Array([s])),o*=BigInt(256);return r.buffer}function Xe(e,t){let r=BigInt(W(e)),n=BigInt(1),o=0;for(;++o<t;){n*=BigInt(256);let i=BigInt(W(e));r=r+n*i}return r}function Rt(e,t){let r=Xe(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}function fe(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}var ye="DIDL",Ct=400;function le(e,t,r){return e.map((n,o)=>r(n,t[o]))}var Ze=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=P(this._typs.length),r=h(...this._typs);return h(t,r)}indexOf(t){if(!this._idx.has(t))throw new Error("Missing type index for "+t);return V(this._idx.get(t)||0)}},ge=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,s)=>[`_${s}_`,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)}},te=class{display(){return this.name}valueToString(t){return b(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}},E=class extends te{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){}},$=class extends te{checkType(t){if(t instanceof J){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)}},xe=class extends E{accept(t,r){return t.visitEmpty(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return V(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},Te=class extends te{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: ${b(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 J?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"}},we=class extends E{accept(t,r){return t.visitBool(this,r)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return V(-2)}decodeValue(t,r){switch(this.checkType(r),W(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},be=class extends E{accept(t,r){return t.visitNull(this,r)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return V(-1)}decodeValue(t,r){return this.checkType(r),null}get name(){return"null"}},re=class extends E{accept(t,r){return t.visitReserved(this,r)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return V(-16)}decodeValue(t,r){return r.name!==this.name&&r.decodeValue(t,r),null}get name(){return"reserved"}},Ne=class extends E{accept(t,r){return t.visitText(this,r)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){let r=new TextEncoder().encode(t),n=P(r.byteLength);return h(n,r)}encodeType(){return V(-15)}decodeValue(t,r){this.checkType(r);let n=A(t),o=G(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(o)}get name(){return"text"}valueToString(t){return'"'+t+'"'}},ve=class extends E{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: ${b(t)}`)}encodeValue(t){return V(t)}encodeType(){return V(-4)}decodeValue(t,r){return this.checkType(r),j(t)}get name(){return"int"}valueToString(t){return t.toString()}},Pe=class extends E{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: ${b(t)}`)}encodeValue(t){return P(t)}encodeType(){return V(-3)}decodeValue(t,r){return this.checkType(r),A(t)}get name(){return"nat"}valueToString(t){return t.toString()}},ue=class extends E{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: ${b(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 V(t)}decodeValue(t,r){this.checkType(r);let n=G(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()}},H=class extends E{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedInt(this,r)}covariant(t){let r=fe(this._bits-1)*BigInt(-1),n=fe(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: ${b(t)}`)}encodeValue(t){return Qe(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return V(-9-t)}decodeValue(t,r){this.checkType(r);let n=Rt(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}},B=class extends E{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedNat(this,r)}covariant(t){let r=fe(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: ${b(t)}`)}encodeValue(t){return Vt(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return V(-5-t)}decodeValue(t,r){this.checkType(r);let n=Xe(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}},Ve=class e extends ${constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof B&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof B?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:
2
2
 
3
- index ${o} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){let r=N(t.length);if(this._blobOptimization)return f(r,new Uint8Array(t));if(ArrayBuffer.isView(t))return f(r,new Uint8Array(t.buffer));let n=new j(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=v(-19),n=this._type.encodeType(t);t.add(this,f(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a vector type");let o=Number(A(t));if(this._type instanceof M){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 H){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 s=0;s<o;s++)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("; ")+"}"}},re=class e extends ${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: ${b(t)}
3
+ index ${o} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){let r=P(t.length);if(this._blobOptimization)return h(r,new Uint8Array(t));if(ArrayBuffer.isView(t))return h(r,new Uint8Array(t.buffer));let n=new z(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=V(-19),n=this._type.encodeType(t);t.add(this,h(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a vector type");let o=Number(A(t));if(this._type instanceof B){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 H){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 s=0;s<o;s++)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("; ")+"}"}},ne=class e extends ${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: ${b(t)}
4
4
 
5
- -> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){return t.length===0?new Uint8Array([0]):f(new Uint8Array([1]),this._type.encodeValue(t[0]))}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=v(-18),n=this._type.encodeType(t);t.add(this,f(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not an option type");switch(W(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])}`}},le=class e extends ${constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>B(r[0])-B(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:
5
+ -> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){return t.length===0?new Uint8Array([0]):h(new Uint8Array([1]),this._type.encodeValue(t[0]))}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=V(-18),n=this._type.encodeType(t);t.add(this,h(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not an option type");switch(W(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])}`}},pe=class e extends ${constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>M(r[0])-M(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:
6
6
 
7
- field ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){let r=this._fields.map(([o])=>t[o]),n=ae(this._fields,r,([,o],i)=>o.encodeValue(i));return f(...n)}_buildTypeTableImpl(t){this._fields.forEach(([i,s])=>s.buildTypeTable(t));let r=v(-20),n=N(this._fields.length),o=this._fields.map(([i,s])=>f(N(B(i)),s.encodeType(t)));t.add(this,f(r,n,f(...o)))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a record type");let o={},i=0,s=0;for(;s<n._fields.length;){let[c,u]=n._fields[s];if(i>=this._fields.length){u.decodeValue(t,u),s++;continue}let[l,_]=this._fields[i],m=B(this._fields[i][0]),y=B(c);if(m===y)o[l]=_.decodeValue(t,u),i++,s++;else if(y>m)if(_ instanceof re||_ instanceof te)o[l]=[],i++;else throw new Error("Cannot find required field "+l);else u.decodeValue(t,u),s++}for(let[c,u]of this._fields.slice(i))if(u instanceof re||u instanceof te)o[c]=[];else throw new Error("Cannot find required field "+c);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 {${ae(this._fields,r,([o,i],s)=>o+"="+i.valueToString(s)).join("; ")}}`}},Ve=class e extends le{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:
7
+ field ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){let r=this._fields.map(([o])=>t[o]),n=le(this._fields,r,([,o],i)=>o.encodeValue(i));return h(...n)}_buildTypeTableImpl(t){this._fields.forEach(([i,s])=>s.buildTypeTable(t));let r=V(-20),n=P(this._fields.length),o=this._fields.map(([i,s])=>h(P(M(i)),s.encodeType(t)));t.add(this,h(r,n,h(...o)))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a record type");let o={},i=0,s=0;for(;s<n._fields.length;){let[c,u]=n._fields[s];if(i>=this._fields.length){u.decodeValue(t,u),s++;continue}let[l,m]=this._fields[i],_=M(this._fields[i][0]),y=M(c);if(_===y)o[l]=m.decodeValue(t,u),i++,s++;else if(y>_)if(m instanceof ne||m instanceof re)o[l]=[],i++;else throw new Error("Cannot find required field "+l);else u.decodeValue(t,u),s++}for(let[c,u]of this._fields.slice(i))if(u instanceof ne||u instanceof re)o[c]=[];else throw new Error("Cannot find required field "+c);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],s)=>o+"="+i.valueToString(s)).join("; ")}}`}},Re=class e extends pe{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:
8
8
 
9
- index ${n} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){let r=ae(this._components,t,(n,o)=>n.encodeValue(o));return f(...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,s]of n._components.entries())i>=this._components.length?s.decodeValue(t,s):o.push(this._components[i].decodeValue(t,s));return o}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(t){return`record {${ae(this._components,t,(n,o)=>n.valueToString(o)).join("; ")}}`}},Re=class e extends ${constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>B(r[0])-B(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:
9
+ index ${n} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){let r=le(this._components,t,(n,o)=>n.encodeValue(o));return h(...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,s]of n._components.entries())i>=this._components.length?s.decodeValue(t,s):o.push(this._components[i].decodeValue(t,s));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("; ")}}`}},Ce=class e extends ${constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>M(r[0])-M(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:
10
10
 
11
- variant ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){for(let r=0;r<this._fields.length;r++){let[n,o]=this._fields[r];if(t.hasOwnProperty(n)){let i=N(r),s=o.encodeValue(t[n]);return f(i,s)}}throw Error("Variant has no data: "+t)}_buildTypeTableImpl(t){this._fields.forEach(([,i])=>{i.buildTypeTable(t)});let r=v(-21),n=N(this._fields.length),o=this._fields.map(([i,s])=>f(N(B(i)),s.encodeType(t)));t.add(this,f(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(A(t));if(o>=n._fields.length)throw Error("Invalid variant index: "+o);let[i,s]=n._fields[o];for(let[c,u]of this._fields)if(B(i)===B(c)){let l=u.decodeValue(t,s);return{[c]:l}}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)}},G=class e extends ${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: ${b(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)}};G._counter=0;function Qe(e){if(W(e)!==1)throw new Error("Cannot decode principal");let r=Number(A(e));return un.fromUint8Array(new Uint8Array(J(e,r)))}var Ce=class extends E{accept(t,r){return t.visitPrincipal(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=N(r.byteLength);return f(new Uint8Array([1]),n,r)}encodeType(){return v(-24)}decodeValue(t,r){return this.checkType(r),Qe(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}},ue=class extends ${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: ${b(t)}`)}encodeValue([t,r]){let n=t.toUint8Array(),o=N(n.byteLength),i=f(new Uint8Array([1]),o,n),s=new TextEncoder().encode(r),c=N(s.byteLength);return f(new Uint8Array([1]),i,c,s)}_buildTypeTableImpl(t){this.argTypes.forEach(l=>l.buildTypeTable(t)),this.retTypes.forEach(l=>l.buildTypeTable(t));let r=v(-22),n=N(this.argTypes.length),o=f(...this.argTypes.map(l=>l.encodeType(t))),i=N(this.retTypes.length),s=f(...this.retTypes.map(l=>l.encodeType(t))),c=N(this.annotations.length),u=f(...this.annotations.map(l=>this.encodeAnnotation(l)));t.add(this,f(r,n,o,i,s,c,u))}decodeValue(t){if(W(t)!==1)throw new Error("Cannot decode function reference");let n=Qe(t),o=Number(A(t)),i=J(t,o),c=new TextDecoder("utf8",{fatal:!0}).decode(i);return[n,c]}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")}},Se=class extends ${constructor(t){super(),this._fields=Object.entries(t).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(t,r){return t.visitService(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=N(r.length);return f(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([i,s])=>s.buildTypeTable(t));let r=v(-23),n=N(this._fields.length),o=this._fields.map(([i,s])=>{let c=new TextEncoder().encode(i),u=N(c.length);return f(u,c,s.encodeType(t))});t.add(this,f(r,n,...o))}decodeValue(t){return Qe(t)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(t){return`service "${t.toText()}"`}};function b(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>Nt?t.substring(0,Nt-3)+"...":t}function pn(e,t){if(t.length<e.length)throw Error("Wrong number of message arguments");let r=new Ye;e.forEach(u=>u.buildTypeTable(r));let n=new TextEncoder().encode(fe),o=r.encode(),i=N(t.length),s=f(...e.map(u=>u.encodeType(r))),c=f(...ae(e,t,(u,l)=>{try{u.covariant(l)}catch(_){throw new Error(_.message+`
11
+ variant ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){for(let r=0;r<this._fields.length;r++){let[n,o]=this._fields[r];if(t.hasOwnProperty(n)){let i=P(r),s=o.encodeValue(t[n]);return h(i,s)}}throw Error("Variant has no data: "+t)}_buildTypeTableImpl(t){this._fields.forEach(([,i])=>{i.buildTypeTable(t)});let r=V(-21),n=P(this._fields.length),o=this._fields.map(([i,s])=>h(P(M(i)),s.encodeType(t)));t.add(this,h(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(A(t));if(o>=n._fields.length)throw Error("Invalid variant index: "+o);let[i,s]=n._fields[o];for(let[c,u]of this._fields)if(M(i)===M(c)){let l=u.decodeValue(t,s);return{[c]:l}}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)}},J=class e extends ${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: ${b(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)}};J._counter=0;function Ie(e){if(W(e)!==1)throw new Error("Cannot decode principal");let r=Number(A(e));return mn.fromUint8Array(new Uint8Array(G(e,r)))}var Se=class extends E{accept(t,r){return t.visitPrincipal(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=P(r.byteLength);return h(new Uint8Array([1]),n,r)}encodeType(){return V(-24)}decodeValue(t,r){return this.checkType(r),Ie(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}},de=class extends ${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: ${b(t)}`)}encodeValue([t,r]){let n=t.toUint8Array(),o=P(n.byteLength),i=h(new Uint8Array([1]),o,n),s=new TextEncoder().encode(r),c=P(s.byteLength);return h(new Uint8Array([1]),i,c,s)}_buildTypeTableImpl(t){this.argTypes.forEach(l=>l.buildTypeTable(t)),this.retTypes.forEach(l=>l.buildTypeTable(t));let r=V(-22),n=P(this.argTypes.length),o=h(...this.argTypes.map(l=>l.encodeType(t))),i=P(this.retTypes.length),s=h(...this.retTypes.map(l=>l.encodeType(t))),c=P(this.annotations.length),u=h(...this.annotations.map(l=>this.encodeAnnotation(l)));t.add(this,h(r,n,o,i,s,c,u))}decodeValue(t){if(W(t)!==1)throw new Error("Cannot decode function reference");let n=Ie(t),o=Number(A(t)),i=G(t,o),c=new TextDecoder("utf8",{fatal:!0}).decode(i);return[n,c]}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")}},Oe=class extends ${constructor(t){super(),this._fields=Object.entries(t).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(t,r){return t.visitService(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${b(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=P(r.length);return h(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([i,s])=>s.buildTypeTable(t));let r=V(-23),n=P(this._fields.length),o=this._fields.map(([i,s])=>{let c=new TextEncoder().encode(i),u=P(c.length);return h(u,c,s.encodeType(t))});t.add(this,h(r,n,...o))}decodeValue(t){return Ie(t)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(t){return`service "${t.toText()}"`}};function b(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>Ct?t.substring(0,Ct-3)+"...":t}function _n(e,t){if(t.length<e.length)throw Error("Wrong number of message arguments");let r=new Ze;e.forEach(u=>u.buildTypeTable(r));let n=new TextEncoder().encode(ye),o=r.encode(),i=P(t.length),s=h(...e.map(u=>u.encodeType(r))),c=h(...le(e,t,(u,l)=>{try{u.covariant(l)}catch(m){throw new Error(m.message+`
12
12
 
13
- `)}return u.encodeValue(l)}));return f(n,o,i,s,c)}function dn(e,t){let r=new j(t);if(t.byteLength<fe.length)throw new Error("Message length smaller than magic number");let n=J(r,fe.length),o=new TextDecoder().decode(n);if(o!==fe)throw new Error("Wrong magic number: "+JSON.stringify(o));function i(a){let p=[],g=Number(A(a));for(let h=0;h<g;h++){let d=Number(z(a));switch(d){case-18:case-19:{let w=Number(z(a));p.push([d,w]);break}case-20:case-21:{let w=[],R=Number(A(a)),P;for(;R--;){let C=Number(A(a));if(C>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof P=="number"&&P>=C)throw new Error("field id collision or not sorted");P=C;let V=Number(z(a));w.push([C,V])}p.push([d,w]);break}case-22:{let w=[],R=Number(A(a));for(;R--;)w.push(Number(z(a)));let P=[],C=Number(A(a));for(;C--;)P.push(Number(z(a)));let V=[],k=Number(A(a));for(;k--;)switch(Number(A(a))){case 1:{V.push("query");break}case 2:{V.push("oneway");break}case 3:{V.push("composite_query");break}default:throw new Error("unknown annotation")}p.push([d,[w,P,V]]);break}case-23:{let w=Number(A(a)),R=[];for(;w--;){let P=Number(A(a)),C=new TextDecoder().decode(J(a,P)),V=z(a);R.push([C,V])}p.push([d,R]);break}default:throw new Error("Illegal op_code: "+d)}}let x=[],T=Number(A(a));for(let h=0;h<T;h++)x.push(Number(z(a)));return[p,x]}let[s,c]=i(r);if(c.length<e.length)throw new Error("Wrong number of return values");let u=s.map(a=>Yt());function l(a){if(a<-24)throw new Error("future value not supported");if(a<0)switch(a){case-1:return Rt;case-2:return Vt;case-3:return At;case-4:return St;case-5:return $t;case-6:return qt;case-7:return Ut;case-8:return jt;case-9:return Et;case-10:return kt;case-11:return Bt;case-12:return Mt;case-13:return Ot;case-14:return Ft;case-15:return Ct;case-16:return Pt;case-17:return vt;case-24:return zt;default:throw new Error("Illegal op_code: "+a)}if(a>=s.length)throw new Error("type index out of range");return u[a]}function _(a){switch(a[0]){case-19:{let p=l(a[1]);return Kt(p)}case-18:{let p=l(a[1]);return Wt(p)}case-20:{let p={};for(let[T,h]of a[1]){let d=`_${T}_`;p[d]=l(h)}let g=Jt(p),x=g.tryAsTuple();return Array.isArray(x)?Ht(...x):g}case-21:{let p={};for(let[g,x]of a[1]){let T=`_${g}_`;p[T]=l(x)}return Gt(p)}case-22:{let[p,g,x]=a[1];return Qt(p.map(T=>l(T)),g.map(T=>l(T)),x)}case-23:{let p={},g=a[1];for(let[x,T]of g){let h=l(T);if(h instanceof G&&(h=h.getType()),!(h instanceof ue))throw new Error("Illegal service definition: services can only contain functions");p[x]=h}return Xt(p)}default:throw new Error("Illegal op_code: "+a[0])}}s.forEach((a,p)=>{if(a[0]===-22){let g=_(a);u[p].fill(g)}}),s.forEach((a,p)=>{if(a[0]!==-22){let g=_(a);u[p].fill(g)}});let m=c.map(a=>l(a)),y=e.map((a,p)=>a.decodeValue(r,m[p]));for(let a=e.length;a<m.length;a++)m[a].decodeValue(r,m[a]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return y}var vt=new ge,Pt=new te,mn=new xe,Vt=new Te,Rt=new we,Ct=new be,St=new Ne,At=new ve,Ot=new ce(32),Ft=new ce(64),Et=new H(8),kt=new H(16),Bt=new H(32),Mt=new H(64),$t=new M(8),qt=new M(16),Ut=new M(32),jt=new M(64),zt=new Ce;function Ht(...e){return new Ve(e)}function Kt(e){return new Pe(e)}function Wt(e){return new re(e)}function Jt(e){return new le(e)}function Gt(e){return new Re(e)}function Yt(){return new G}function Qt(e,t,r=[]){return new ue(e,t,r)}function Xt(e){return new Se(e)}import{Principal as ho}from"@dfinity/principal";var Zt=e=>F.encode([F.Record({user:F.Principal})],[{user:e}]),Ae=e=>F.encode([F.Record({controllers:F.Vec(F.Principal)})],[{controllers:e.map(([t,r])=>t)}]);var Oo=async e=>ht(e),Fo=async({missionControl:e,wasm_module:t})=>{let r=await ft({missionControl:e}),{missionControlId:n,...o}=e;if(!n)throw new Error("No mission control principal defined.");let i=Zt(r);await D({actor:o,code:{canister_id:hn.fromText(n),arg:new Uint8Array(i),wasm_module:t,mode:{upgrade:[{skip_pre_upgrade:[!1]}]}}})},Eo=async({controllerId:e,profile:t,...r})=>gt({...r,...He({controllerId:e,profile:t})}),ko=async({controllerId:e,profile:t,...r})=>xt({...r,...He({controllerId:e,profile:t})}),Bo=e=>yt(e);import{Principal as fn}from"@dfinity/principal";var It=async({orbiter:e})=>(await _e(e)).version(),Xe=async({orbiter:e})=>(await _e(e)).list_controllers(),Dt=async({orbiter:e})=>{let{memory_size:t}=await _e(e);return t()};var Ko=async e=>It(e),Wo=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 Xe({orbiter:e}),s=Ae(i);await D({actor:o,code:{canister_id:fn.fromText(n),arg:new Uint8Array(s),wasm_module:t,mode:r?{reinstall:null}:{upgrade:[{skip_pre_upgrade:[!1]}]}}})},Jo=e=>Dt(e),Go=e=>Xe(e);import{major as Lt,minor as er,patch as tr}from"semver";var Xo=({currentVersion:e,selectedVersion:t})=>{let r=Lt(e),n=Lt(t),o=er(e),i=er(t),s=tr(e),c=tr(t);return r<n-1||o<i-1||s<c-1?{canUpgrade:!1}:{canUpgrade:!0}};import{Principal as Sr}from"@dfinity/principal";import{fromNullable as oe,isNullish as et,nonNullish as Fe}from"@junobuild/utils";import{toNullable as yn}from"@junobuild/utils";var rr=async({config:e,satellite:t})=>{let{set_config:r}=await O(t);return r(e)},nr=async({config:e,satellite:t})=>{let{set_auth_config:r}=await O(t);return r(e)},or=async({satellite:e})=>{let{get_auth_config:t}=await O(e);return t()},ir=async({satellite:e,type:t})=>(await O(e)).list_rules(t),sr=async({type:e,collection:t,rule:r,satellite:n})=>(await O(n)).set_rule(e,t,r),ar=async({satellite:e})=>{let{version:t}=await O(e);return t()},cr=async({satellite:e})=>{let{build_version:t}=await O(e);return t()},lr=async({satellite:e})=>(await ut(e)).list_controllers(),Ze=async({satellite:e})=>(await pt(e)).list_controllers(),Ie=async({satellite:e})=>(await O(e)).list_controllers(),ur=async({satellite:e})=>{let{list_custom_domains:t}=await O(e);return t()},pr=async({satellite:e,domainName:t,boundaryNodesId:r})=>{let{set_custom_domain:n}=await O(e);await n(t,yn(r))},dr=async({satellite:e})=>{let{memory_size:t}=await O(e);return t()},mr=async({collection:e,satellite:t})=>{let{count_docs:r}=await O(t);return r(e)},_r=async({collection:e,satellite:t})=>{let{count_assets:r}=await O(t);return r(e)},hr=async({collection:e,satellite:t})=>{let{del_docs:r}=await O(t);return r(e)},fr=async({collection:e,satellite:t})=>{let{del_assets:r}=await O(t);return r(e)},yr=async({args:e,satellite:t})=>{let{set_controllers:r}=await O(t);return r(e)};import{fromNullable as pe,nonNullish as ne,toNullable as Oe}from"@junobuild/utils";var gr={Db:null},xr={Storage:null},Tr={Public:null},wr={Private:null},br={Managed:null},Nr={Controllers:null},De={Heap:null},vr={Stable:null};var Le=e=>e==="storage"?xr:gr,Rr=({read:e,write:t,memory:r,maxSize:n,maxCapacity:o,version:i,mutablePermissions:s})=>({read:Vr(e),write:Vr(t),memory:ne(r)?[gn(r)]:[],version:Oe(i),max_size:Oe(ne(n)&&n>0?BigInt(n):void 0),max_capacity:Oe(ne(o)&&o>0?o:void 0),mutable_permissions:Oe(s)}),Cr=([e,t])=>{let{read:r,write:n,updated_at:o,created_at:i,max_size:s,max_capacity:c,memory:u,mutable_permissions:l,version:_}=t,m=s?.[0]??0n>0n?Number(pe(s)):void 0,y=c?.[0]??!1?pe(c):void 0,a=pe(_);return{collection:e,read:Pr(r),write:Pr(n),memory:xn(pe(u)??De),updatedAt:o,createdAt:i,...ne(a)&&{version:a},...ne(m)&&{maxSize:m},...ne(y)&&{maxCapacity:y},mutablePermissions:pe(l)??!0}},Pr=e=>"Public"in e?"public":"Private"in e?"private":"Managed"in e?"managed":"controllers",Vr=e=>{switch(e){case"public":return Tr;case"private":return wr;case"managed":return br;default:return Nr}},gn=e=>{switch(e.toLowerCase()){case"heap":return De;default:return vr}},xn=e=>"Heap"in e?"heap":"stable";var pi=async({config:{storage:{headers:e,rewrites:t,redirects:r,iframe:n,rawAccess:o}},satellite:i})=>{let s=(e??[]).map(({source:m,headers:y})=>[m,y]),c=(t??[]).map(({source:m,destination:y})=>[m,y]),u=(r??[]).map(({source:m,location:y,code:a})=>[m,{status_code:a,location:y}]);return rr({satellite:i,config:{storage:{headers:s,rewrites:c,redirects:[u],iframe:[n==="same-origin"?{SameOrigin:null}:n==="allow-any"?{AllowAny:null}:{Deny:null}],raw_access:[o===!0?{Allow:null}:{Deny:null}]}}})},di=async({config:{authentication:{internetIdentity:e}},...t})=>{await nr({config:{internet_identity:et(e?.derivationOrigin)?[]:[{derivation_origin:[e.derivationOrigin]}]},...t})},mi=async({satellite:e})=>{let t=oe(await or({satellite:e}));if(et(t))return;let r=oe(t.internet_identity??[]);return{...Fe(r)&&{internetIdentity:{...Fe(oe(r.derivation_origin))&&{derivationOrigin:oe(r.derivation_origin)}}}}},_i=async({type:e,satellite:t})=>(await ir({satellite:t,type:Le(e)})).map(n=>Cr(n)),hi=async({rule:{collection:e,...t},type:r,satellite:n})=>sr({type:Le(r),rule:Rr(t),satellite:n,collection:e}),fi=e=>ar(e),yi=e=>cr(e),gi=async({satellite:{satelliteId:e,...t}})=>{let r=await _t({...t,canisterId:e,path:"juno:build"});return Fe(r)&&["stock","extended"].includes(r)?r:void 0},xi=async({satellite:e,wasm_module:t,deprecated:r,deprecatedNoScope:n,reset:o=!1})=>{let{satelliteId:i,...s}=e;if(et(i))throw new Error("No satellite principal defined.");if(r){let _=await lr({satellite:e}),m=F.encode([F.Record({controllers:F.Vec(F.Principal)})],[{controllers:_}]);await D({actor:s,code:{canister_id:Sr.fromText(i),arg:new Uint8Array(m),wasm_module:t,mode:o?{reinstall:null}:{upgrade:[{skip_pre_upgrade:[!1]}]}}});return}let u=await(n?Ze:Ie)({satellite:e}),l=Ae(u);await D({actor:s,code:{canister_id:Sr.fromText(i),arg:new Uint8Array(l),wasm_module:t,mode:o?{reinstall:null}:{upgrade:[{skip_pre_upgrade:[!1]}]}}})},Ti=async({satellite:e})=>(await ur({satellite:e})).map(([r,n])=>{let o=oe(n.version);return{domain:r,bn_id:oe(n.bn_id),created_at:n.created_at,updated_at:n.updated_at,...Fe(o)&&{version:o}}}),wi=async({satellite:e,domains:t})=>Promise.all(t.map(({domain:r,bn_id:n})=>pr({satellite:e,domainName:r,boundaryNodesId:n}))),bi=e=>dr(e),Ni=async e=>mr(e),vi=async e=>hr(e),Pi=async e=>_r(e),Vi=async e=>fr(e),Ri=({deprecatedNoScope:e,...t})=>(e===!0?Ze:Ie)(t),Ci=e=>yr(e);export{Xo as checkUpgradeVersion,Pi as countAssets,Ni as countDocs,Vi as deleteAssets,vi as deleteDocs,mi as getAuthConfig,Ti as listCustomDomains,Bo as listMissionControlControllers,Go as listOrbiterControllers,_i as listRules,Ri as listSatelliteControllers,Oo as missionControlVersion,Jo as orbiterMemorySize,Ko as orbiterVersion,gi as satelliteBuildType,yi as satelliteBuildVersion,bi as satelliteMemorySize,fi as satelliteVersion,di as setAuthConfig,pi as setConfig,wi as setCustomDomains,ko as setMissionControlController,hi as setRule,Ci as setSatelliteControllers,Eo as setSatellitesController,Fo as upgradeMissionControl,Wo as upgradeOrbiter,xi as upgradeSatellite};
13
+ `)}return u.encodeValue(l)}));return h(n,o,i,s,c)}function hn(e,t){let r=new z(t);if(t.byteLength<ye.length)throw new Error("Message length smaller than magic number");let n=G(r,ye.length),o=new TextDecoder().decode(n);if(o!==ye)throw new Error("Wrong magic number: "+JSON.stringify(o));function i(a){let p=[],f=Number(A(a));for(let g=0;g<f;g++){let d=Number(j(a));switch(d){case-18:case-19:{let R=Number(j(a));p.push([d,R]);break}case-20:case-21:{let R=[],N=Number(A(a)),C;for(;N--;){let v=Number(A(a));if(v>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof C=="number"&&C>=v)throw new Error("field id collision or not sorted");C=v;let w=Number(j(a));R.push([v,w])}p.push([d,R]);break}case-22:{let R=[],N=Number(A(a));for(;N--;)R.push(Number(j(a)));let C=[],v=Number(A(a));for(;v--;)C.push(Number(j(a)));let w=[],k=Number(A(a));for(;k--;)switch(Number(A(a))){case 1:{w.push("query");break}case 2:{w.push("oneway");break}case 3:{w.push("composite_query");break}default:throw new Error("unknown annotation")}p.push([d,[R,C,w]]);break}case-23:{let R=Number(A(a)),N=[];for(;R--;){let C=Number(A(a)),v=new TextDecoder().decode(G(a,C)),w=j(a);N.push([v,w])}p.push([d,N]);break}default:throw new Error("Illegal op_code: "+d)}}let x=[],T=Number(A(a));for(let g=0;g<T;g++)x.push(Number(j(a)));return[p,x]}let[s,c]=i(r);if(c.length<e.length)throw new Error("Wrong number of return values");let u=s.map(a=>Dt());function l(a){if(a<-24)throw new Error("future value not supported");if(a<0)switch(a){case-1:return Ft;case-2:return At;case-3:return Mt;case-4:return kt;case-5:return Ht;case-6:return Kt;case-7:return Wt;case-8:return Gt;case-9:return qt;case-10:return Ut;case-11:return zt;case-12:return jt;case-13:return Bt;case-14:return $t;case-15:return Et;case-16:return Ot;case-17:return St;case-24:return Jt;default:throw new Error("Illegal op_code: "+a)}if(a>=s.length)throw new Error("type index out of range");return u[a]}function m(a){switch(a[0]){case-19:{let p=l(a[1]);return Qt(p)}case-18:{let p=l(a[1]);return Xt(p)}case-20:{let p={};for(let[T,g]of a[1]){let d=`_${T}_`;p[d]=l(g)}let f=Zt(p),x=f.tryAsTuple();return Array.isArray(x)?Yt(...x):f}case-21:{let p={};for(let[f,x]of a[1]){let T=`_${f}_`;p[T]=l(x)}return It(p)}case-22:{let[p,f,x]=a[1];return Lt(p.map(T=>l(T)),f.map(T=>l(T)),x)}case-23:{let p={},f=a[1];for(let[x,T]of f){let g=l(T);if(g instanceof J&&(g=g.getType()),!(g instanceof de))throw new Error("Illegal service definition: services can only contain functions");p[x]=g}return er(p)}default:throw new Error("Illegal op_code: "+a[0])}}s.forEach((a,p)=>{if(a[0]===-22){let f=m(a);u[p].fill(f)}}),s.forEach((a,p)=>{if(a[0]!==-22){let f=m(a);u[p].fill(f)}});let _=c.map(a=>l(a)),y=e.map((a,p)=>a.decodeValue(r,_[p]));for(let a=e.length;a<_.length;a++)_[a].decodeValue(r,_[a]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return y}var St=new xe,Ot=new re,fn=new Te,At=new we,Ft=new be,Et=new Ne,kt=new ve,Mt=new Pe,Bt=new ue(32),$t=new ue(64),qt=new H(8),Ut=new H(16),zt=new H(32),jt=new H(64),Ht=new B(8),Kt=new B(16),Wt=new B(32),Gt=new B(64),Jt=new Se;function Yt(...e){return new Re(e)}function Qt(e){return new Ve(e)}function Xt(e){return new ne(e)}function Zt(e){return new pe(e)}function It(e){return new Ce(e)}function Dt(){return new J}function Lt(e,t,r=[]){return new de(e,t,r)}function er(e){return new Oe(e)}import{Principal as xo}from"@dfinity/principal";var tr=e=>F.encode([F.Record({user:F.Principal})],[{user:e}]),Ae=e=>F.encode([F.Record({controllers:F.Vec(F.Principal)})],[{controllers:e.map(([t,r])=>t)}]);var Mo=async e=>Tt(e),Bo=async({missionControl:e,wasm_module:t})=>{let r=await wt({missionControl:e}),{missionControlId:n,...o}=e;if(!n)throw new Error("No mission control principal defined.");let i=tr(r);await I({actor:o,code:{canister_id:gn.fromText(n),arg:new Uint8Array(i),wasm_module:t,mode:{upgrade:[{skip_pre_upgrade:[!1]}]}}})},$o=async({controllerId:e,profile:t,...r})=>Nt({...r,...Ge({controllerId:e,profile:t})}),qo=async({controllerId:e,profile:t,...r})=>vt({...r,...Ge({controllerId:e,profile:t})}),Uo=e=>bt(e);import{Principal as xn}from"@dfinity/principal";var rr=async({orbiter:e})=>(await he(e)).version(),De=async({orbiter:e})=>(await he(e)).list_controllers(),nr=async({orbiter:e})=>{let{memory_size:t}=await he(e);return t()};var Yo=async e=>rr(e),Qo=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 De({orbiter:e}),s=Ae(i);await I({actor:o,code:{canister_id:xn.fromText(n),arg:new Uint8Array(s),wasm_module:t,mode:r?{reinstall:null}:{upgrade:[{skip_pre_upgrade:[!1]}]}}})},Xo=e=>nr(e),Zo=e=>De(e);import{major as or,minor as ir,patch as sr}from"semver";var Lo=({currentVersion:e,selectedVersion:t})=>{let r=or(e),n=or(t),o=ir(e),i=ir(t),s=sr(e),c=sr(t);return r<n-1||o<i-1||s<c-1?{canUpgrade:!1}:{canUpgrade:!0}};import{Principal as Mr}from"@dfinity/principal";import{fromNullable as ie,isNullish as it,nonNullish as Ee}from"@junobuild/utils";import{toNullable as Tn}from"@junobuild/utils";var ar=async({config:e,satellite:t})=>{let{set_storage_config:r}=await O(t);return r(e)},cr=async({config:e,satellite:t})=>{let{set_db_config:r}=await O(t);return r(e)},lr=async({config:e,satellite:t})=>{let{set_auth_config:r}=await O(t);return r(e)};var ur=async({satellite:e})=>{let{get_auth_config:t}=await O(e);return t()},pr=async({satellite:e,type:t})=>(await O(e)).list_rules(t),dr=async({type:e,collection:t,rule:r,satellite:n})=>(await O(n)).set_rule(e,t,r),mr=async({satellite:e})=>{let{version:t}=await O(e);return t()},_r=async({satellite:e})=>{let{build_version:t}=await O(e);return t()},hr=async({satellite:e})=>(await ht(e)).list_controllers(),Le=async({satellite:e})=>(await ft(e)).list_controllers(),et=async({satellite:e})=>(await O(e)).list_controllers(),fr=async({satellite:e})=>{let{list_custom_domains:t}=await O(e);return t()},yr=async({satellite:e,domainName:t,boundaryNodesId:r})=>{let{set_custom_domain:n}=await O(e);await n(t,Tn(r))},gr=async({satellite:e})=>{let{memory_size:t}=await O(e);return t()},xr=async({collection:e,satellite:t})=>{let{count_docs:r}=await O(t);return r(e)},Tr=async({collection:e,satellite:t})=>{let{count_assets:r}=await O(t);return r(e)},wr=async({collection:e,satellite:t})=>{let{del_docs:r}=await O(t);return r(e)},br=async({collection:e,satellite:t})=>{let{del_assets:r}=await O(t);return r(e)},Nr=async({args:e,satellite:t})=>{let{set_controllers:r}=await O(t);return r(e)};import{nonNullish as wn,toNullable as tt}from"@junobuild/utils";var rt=e=>tt(wn(e)?{heap:tt(e.heap),stable:tt(e.stable)}:void 0);import{fromNullable as me,nonNullish as oe,toNullable as Fe}from"@junobuild/utils";var vr={Db:null},Pr={Storage:null},Vr={Public:null},Rr={Private:null},Cr={Managed:null},Sr={Controllers:null},nt={Heap:null},Or={Stable:null};var ot=e=>e==="storage"?Pr:vr,Er=({read:e,write:t,memory:r,maxSize:n,maxCapacity:o,version:i,mutablePermissions:s})=>({read:Fr(e),write:Fr(t),memory:oe(r)?[bn(r)]:[],version:Fe(i),max_size:Fe(oe(n)&&n>0?BigInt(n):void 0),max_capacity:Fe(oe(o)&&o>0?o:void 0),mutable_permissions:Fe(s)}),kr=([e,t])=>{let{read:r,write:n,updated_at:o,created_at:i,max_size:s,max_capacity:c,memory:u,mutable_permissions:l,version:m}=t,_=s?.[0]??0n>0n?Number(me(s)):void 0,y=c?.[0]??!1?me(c):void 0,a=me(m);return{collection:e,read:Ar(r),write:Ar(n),memory:Nn(me(u)??nt),updatedAt:o,createdAt:i,...oe(a)&&{version:a},...oe(_)&&{maxSize:_},...oe(y)&&{maxCapacity:y},mutablePermissions:me(l)??!0}},Ar=e=>"Public"in e?"public":"Private"in e?"private":"Managed"in e?"managed":"controllers",Fr=e=>{switch(e){case"public":return Vr;case"private":return Rr;case"managed":return Cr;default:return Sr}},bn=e=>{switch(e.toLowerCase()){case"heap":return nt;default:return Or}},Nn=e=>"Heap"in e?"heap":"stable";var gi=async({config:{headers:e,rewrites:t,redirects:r,iframe:n,rawAccess:o,maxMemorySize:i},satellite:s})=>{let c=(e??[]).map(({source:y,headers:a})=>[y,a]),u=(t??[]).map(({source:y,destination:a})=>[y,a]),l=(r??[]).map(({source:y,location:a,code:p})=>[y,{status_code:p,location:a}]);return ar({satellite:s,config:{headers:c,rewrites:u,redirects:[l],iframe:[n==="same-origin"?{SameOrigin:null}:n==="allow-any"?{AllowAny:null}:{Deny:null}],raw_access:[o===!0?{Allow:null}:{Deny:null}],max_memory_size:rt(i)}})},xi=async({config:{maxMemorySize:e},...t})=>{await cr({config:{max_memory_size:rt(e)},...t})},Ti=async({config:{internetIdentity:e},...t})=>{await lr({config:{internet_identity:it(e?.derivationOrigin)?[]:[{derivation_origin:[e.derivationOrigin]}]},...t})},wi=async({satellite:e})=>{let t=ie(await ur({satellite:e}));if(it(t))return;let r=ie(t.internet_identity??[]);return{...Ee(r)&&{internetIdentity:{...Ee(ie(r.derivation_origin))&&{derivationOrigin:ie(r.derivation_origin)}}}}},bi=async({type:e,satellite:t})=>(await pr({satellite:t,type:ot(e)})).map(n=>kr(n)),Ni=async({rule:{collection:e,...t},type:r,satellite:n})=>dr({type:ot(r),rule:Er(t),satellite:n,collection:e}),vi=e=>mr(e),Pi=e=>_r(e),Vi=async({satellite:{satelliteId:e,...t}})=>{let r=await xt({...t,canisterId:e,path:"juno:build"});return Ee(r)&&["stock","extended"].includes(r)?r:void 0},Ri=async({satellite:e,wasm_module:t,deprecated:r,deprecatedNoScope:n,reset:o=!1})=>{let{satelliteId:i,...s}=e;if(it(i))throw new Error("No satellite principal defined.");if(r){let m=await hr({satellite:e}),_=F.encode([F.Record({controllers:F.Vec(F.Principal)})],[{controllers:m}]);await I({actor:s,code:{canister_id:Mr.fromText(i),arg:new Uint8Array(_),wasm_module:t,mode:o?{reinstall:null}:{upgrade:[{skip_pre_upgrade:[!1]}]}}});return}let u=await(n?Le:et)({satellite:e}),l=Ae(u);await I({actor:s,code:{canister_id:Mr.fromText(i),arg:new Uint8Array(l),wasm_module:t,mode:o?{reinstall:null}:{upgrade:[{skip_pre_upgrade:[!1]}]}}})},Ci=async({satellite:e})=>(await fr({satellite:e})).map(([r,n])=>{let o=ie(n.version);return{domain:r,bn_id:ie(n.bn_id),created_at:n.created_at,updated_at:n.updated_at,...Ee(o)&&{version:o}}}),Si=async({satellite:e,domains:t})=>Promise.all(t.map(({domain:r,bn_id:n})=>yr({satellite:e,domainName:r,boundaryNodesId:n}))),Oi=e=>gr(e),Ai=async e=>xr(e),Fi=async e=>wr(e),Ei=async e=>Tr(e),ki=async e=>br(e),Mi=({deprecatedNoScope:e,...t})=>(e===!0?Le:et)(t),Bi=e=>Nr(e);export{Lo as checkUpgradeVersion,Ei as countAssets,Ai as countDocs,ki as deleteAssets,Fi as deleteDocs,wi as getAuthConfig,Ci as listCustomDomains,Uo as listMissionControlControllers,Zo as listOrbiterControllers,bi as listRules,Mi as listSatelliteControllers,Mo as missionControlVersion,Xo as orbiterMemorySize,Yo as orbiterVersion,Vi as satelliteBuildType,Pi as satelliteBuildVersion,Oi as satelliteMemorySize,vi as satelliteVersion,Ti as setAuthConfig,Si as setCustomDomains,xi as setDatastoreConfig,qo as setMissionControlController,Ni as setRule,Bi as setSatelliteControllers,$o as setSatellitesController,gi as setStorageConfig,Bo as upgradeMissionControl,Qo as upgradeOrbiter,Ri as upgradeSatellite};
14
14
  //# sourceMappingURL=index.js.map