@junobuild/core-peer 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/declarations/satellite/satellite.did.d.ts +34 -3
- package/dist/declarations/satellite/satellite.factory.certified.did.js +35 -4
- package/dist/declarations/satellite/satellite.factory.did.js +35 -4
- package/dist/declarations/satellite/satellite.factory.did.mjs +35 -4
- package/dist/declarations/sputnik/sputnik.did.d.ts +34 -3
- package/dist/declarations/sputnik/sputnik.factory.certified.did.js +35 -4
- package/dist/declarations/sputnik/sputnik.factory.did.js +35 -4
- package/dist/node/index.mjs +1 -1
- package/dist/node/index.mjs.map +3 -3
- package/package.json +1 -1
|
@@ -87,14 +87,24 @@ export const idlFactory = ({IDL}) => {
|
|
|
87
87
|
derivation_origin: IDL.Opt(IDL.Text),
|
|
88
88
|
external_alternative_origins: IDL.Opt(IDL.Vec(IDL.Text))
|
|
89
89
|
});
|
|
90
|
+
const AuthenticationRules = IDL.Record({
|
|
91
|
+
allowed_callers: IDL.Vec(IDL.Principal)
|
|
92
|
+
});
|
|
90
93
|
const AuthenticationConfig = IDL.Record({
|
|
91
|
-
|
|
94
|
+
updated_at: IDL.Opt(IDL.Nat64),
|
|
95
|
+
created_at: IDL.Opt(IDL.Nat64),
|
|
96
|
+
version: IDL.Opt(IDL.Nat64),
|
|
97
|
+
internet_identity: IDL.Opt(AuthenticationConfigInternetIdentity),
|
|
98
|
+
rules: IDL.Opt(AuthenticationRules)
|
|
92
99
|
});
|
|
93
100
|
const ConfigMaxMemorySize = IDL.Record({
|
|
94
101
|
stable: IDL.Opt(IDL.Nat64),
|
|
95
102
|
heap: IDL.Opt(IDL.Nat64)
|
|
96
103
|
});
|
|
97
104
|
const DbConfig = IDL.Record({
|
|
105
|
+
updated_at: IDL.Opt(IDL.Nat64),
|
|
106
|
+
created_at: IDL.Opt(IDL.Nat64),
|
|
107
|
+
version: IDL.Opt(IDL.Nat64),
|
|
98
108
|
max_memory_size: IDL.Opt(ConfigMaxMemorySize)
|
|
99
109
|
});
|
|
100
110
|
const StorageConfigIFrame = IDL.Variant({
|
|
@@ -112,8 +122,11 @@ export const idlFactory = ({IDL}) => {
|
|
|
112
122
|
});
|
|
113
123
|
const StorageConfig = IDL.Record({
|
|
114
124
|
iframe: IDL.Opt(StorageConfigIFrame),
|
|
125
|
+
updated_at: IDL.Opt(IDL.Nat64),
|
|
115
126
|
rewrites: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
116
127
|
headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)))),
|
|
128
|
+
created_at: IDL.Opt(IDL.Nat64),
|
|
129
|
+
version: IDL.Opt(IDL.Nat64),
|
|
117
130
|
max_memory_size: IDL.Opt(ConfigMaxMemorySize),
|
|
118
131
|
raw_access: IDL.Opt(StorageConfigRawAccess),
|
|
119
132
|
redirects: IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, StorageConfigRedirect)))
|
|
@@ -269,6 +282,11 @@ export const idlFactory = ({IDL}) => {
|
|
|
269
282
|
items_length: IDL.Nat64
|
|
270
283
|
});
|
|
271
284
|
const MemorySize = IDL.Record({stable: IDL.Nat64, heap: IDL.Nat64});
|
|
285
|
+
const SetAuthenticationConfig = IDL.Record({
|
|
286
|
+
version: IDL.Opt(IDL.Nat64),
|
|
287
|
+
internet_identity: IDL.Opt(AuthenticationConfigInternetIdentity),
|
|
288
|
+
rules: IDL.Opt(AuthenticationRules)
|
|
289
|
+
});
|
|
272
290
|
const SetController = IDL.Record({
|
|
273
291
|
metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
274
292
|
scope: ControllerScope,
|
|
@@ -278,6 +296,10 @@ export const idlFactory = ({IDL}) => {
|
|
|
278
296
|
controller: SetController,
|
|
279
297
|
controllers: IDL.Vec(IDL.Principal)
|
|
280
298
|
});
|
|
299
|
+
const SetDbConfig = IDL.Record({
|
|
300
|
+
version: IDL.Opt(IDL.Nat64),
|
|
301
|
+
max_memory_size: IDL.Opt(ConfigMaxMemorySize)
|
|
302
|
+
});
|
|
281
303
|
const SetDoc = IDL.Record({
|
|
282
304
|
data: IDL.Vec(IDL.Nat8),
|
|
283
305
|
description: IDL.Opt(IDL.Text),
|
|
@@ -294,6 +316,15 @@ export const idlFactory = ({IDL}) => {
|
|
|
294
316
|
write: Permission,
|
|
295
317
|
max_changes_per_user: IDL.Opt(IDL.Nat32)
|
|
296
318
|
});
|
|
319
|
+
const SetStorageConfig = IDL.Record({
|
|
320
|
+
iframe: IDL.Opt(StorageConfigIFrame),
|
|
321
|
+
rewrites: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
322
|
+
headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)))),
|
|
323
|
+
version: IDL.Opt(IDL.Nat64),
|
|
324
|
+
max_memory_size: IDL.Opt(ConfigMaxMemorySize),
|
|
325
|
+
raw_access: IDL.Opt(StorageConfigRawAccess),
|
|
326
|
+
redirects: IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, StorageConfigRedirect)))
|
|
327
|
+
});
|
|
297
328
|
const UploadChunk = IDL.Record({
|
|
298
329
|
content: IDL.Vec(IDL.Nat8),
|
|
299
330
|
batch_id: IDL.Nat,
|
|
@@ -361,14 +392,14 @@ export const idlFactory = ({IDL}) => {
|
|
|
361
392
|
list_rules: IDL.Func([CollectionType, ListRulesParams], [ListRulesResults], ['query']),
|
|
362
393
|
memory_size: IDL.Func([], [MemorySize], ['query']),
|
|
363
394
|
reject_proposal: IDL.Func([CommitProposal], [IDL.Null], []),
|
|
364
|
-
set_auth_config: IDL.Func([
|
|
395
|
+
set_auth_config: IDL.Func([SetAuthenticationConfig], [AuthenticationConfig], []),
|
|
365
396
|
set_controllers: IDL.Func(
|
|
366
397
|
[SetControllersArgs],
|
|
367
398
|
[IDL.Vec(IDL.Tuple(IDL.Principal, Controller))],
|
|
368
399
|
[]
|
|
369
400
|
),
|
|
370
401
|
set_custom_domain: IDL.Func([IDL.Text, IDL.Opt(IDL.Text)], [], []),
|
|
371
|
-
set_db_config: IDL.Func([
|
|
402
|
+
set_db_config: IDL.Func([SetDbConfig], [DbConfig], []),
|
|
372
403
|
set_doc: IDL.Func([IDL.Text, IDL.Text, SetDoc], [Doc], []),
|
|
373
404
|
set_many_docs: IDL.Func(
|
|
374
405
|
[IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text, SetDoc))],
|
|
@@ -376,7 +407,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
376
407
|
[]
|
|
377
408
|
),
|
|
378
409
|
set_rule: IDL.Func([CollectionType, IDL.Text, SetRule], [Rule], []),
|
|
379
|
-
set_storage_config: IDL.Func([
|
|
410
|
+
set_storage_config: IDL.Func([SetStorageConfig], [StorageConfig], []),
|
|
380
411
|
submit_proposal: IDL.Func([IDL.Nat], [IDL.Nat, Proposal], []),
|
|
381
412
|
upload_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], []),
|
|
382
413
|
upload_proposal_asset_chunk: IDL.Func([UploadChunk], [UploadChunkResult], [])
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as topLevelCreateRequire } from 'module';
|
|
2
2
|
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
-
import{assertNonNullish as go}from"@dfinity/utils";import{isNullish as _o}from"@dfinity/utils";var j=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:o})=>o(e))}subscribe(e){let o=Symbol();return this.callbacks.push({id:o,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:s})=>s!==o)}};var y=class t extends j{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let o=super.subscribe(e);return e(this.authUser),o}reset(){this.authUser=null,this.populate(this.authUser)}};var jt=({message:t,detail:e})=>{let o=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(o)};import{ERROR_USER_INTERRUPT as io}from"@dfinity/auth-client";import{isNullish as Ue}from"@dfinity/utils";var It=BigInt(144e11),Lt=!1,te={width:576,height:576},ee={width:505,height:705},oe="internetcomputer.org";import{isNullish as Ze,nonNullish as ae}from"@dfinity/utils";var J="http://127.0.0.1:5987",se="rdmx6-jaaaa-aaaaa-aaadq-cai";var g=class t extends j{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}reset(){this.env=null}subscribe(e){let o=super.subscribe(e);return e(this.env),o}};import{isNullish as re}from"@dfinity/utils";import{jsonReplacer as Ye,jsonReviver as Xe}from"@dfinity/utils";var ne=async t=>{let e=new Blob([JSON.stringify(t,Ye)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},L=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),Xe)},tt=()=>typeof window<"u";var Jt=({width:t,height:e})=>{if(!tt()||re(window)||re(window.top))return;let{top:{innerWidth:o,innerHeight:s}}=window,n=s/2+screenY-e/2,r=o/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${n}, left=${r}`};var et=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let o=()=>{let s=g.getInstance().get()?.container;if(Ze(s)||s===!1)return`https://identity.${this.#t??oe}`;let n=g.getInstance().get(),r=ae(n)&&ae(n?.internetIdentityId)?n.internetIdentityId:se,{host:a,protocol:i}=new URL(s===!0?J:s);return/apple/i.test(navigator?.vendor)?`${i}//${a}?canisterId=${r}`:`${i}//${r}.${a.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:Jt(te)},identityProvider:o()}}},ie=class{#t;#e;constructor({appName:e,logoUrl:o}){this.#t=e,this.#e=o}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:Jt(ee)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};import{Actor as De}from"@dfinity/agent";import{isNullish as Kt}from"@dfinity/utils";import{isNullish as qt}from"@dfinity/utils";import{HttpAgent as Qe}from"@dfinity/agent";import{nonNullish as ce}from"@dfinity/utils";var le=async({identity:t,container:e})=>{let s=ce(e)&&e!==!1?e===!0?J:e:"https://icp-api.io",n=ce(e);return await Qe.create({identity:t,shouldFetchRootKey:n,host:s})};var q=class t{static instance;#t=void 0;constructor(){}static getInstance(){return qt(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...o}){let s=e.getPrincipal().toText();if(qt(this.#t)||qt(this.#t[s])){let n=await le({identity:e,...o});return this.#t={...this.#t??{},[s]:n},n}return this.#t[s]}reset(){this.#t=null}};var K=class t{static instance;#t=void 0;constructor(){}static getInstance(){return Kt(t.instance)&&(t.instance=new t),t.instance}async getActor({satelliteId:e,identity:o,actorKey:s,...n}){let r=`${s}#${o.getPrincipal().toText()}#${e};`;if(Kt(this.#t)||Kt(this.#t[r])){let a=await this.createActor({satelliteId:e,identity:o,...n});return this.#t={...this.#t??{},[r]:a},a}return this.#t[r]}reset(){this.#t=null}async createActor({idlFactory:e,satelliteId:o,...s}){let n=await q.getInstance().getAgent(s);return De.createActor(e,{agent:n,canisterId:o})}};var ot=class extends Error{},st=class extends Error{},nt=class extends Error{},rt=class extends Error{},at=class extends Error{};import{AuthClient as Ie}from"@dfinity/auth-client";var it=()=>Ie.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});import{isNullish as ro,nonNullish as Ce}from"@dfinity/utils";var Bt=({error:t,type:e})=>typeof t=="string"?t.includes(e):t instanceof Error?t.message.includes(e):!1;var pe="juno.datastore.error.user.cannot_update";import{fromNullable as H,isNullish as eo,nonNullish as oo}from"@dfinity/utils";var de=async({data:t})=>{try{return await L(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};import{fromNullable as ue,toNullable as Ht}from"@dfinity/utils";var Gt=async t=>{let{data:e,version:o,description:s}=t;return{description:Ht(s),data:await ne(e),version:Ht(o)}},zt=t=>{let{version:e}=t;return{version:Ht(e)}},I=async({doc:t,key:e})=>{let{owner:o,version:s,description:n,data:r,...a}=t;return{key:e,description:ue(n),owner:o.toText(),data:await L(r),version:ue(s),...a}};import{Principal as Le}from"@dfinity/principal";import{isNullish as B,toNullable as O}from"@dfinity/utils";var _e=t=>{if(B(t))return O();switch(t.matcher){case"equal":return O({Equal:t.timestamp});case"greaterThan":return O({GreaterThan:t.timestamp});case"lessThan":return O({LessThan:t.timestamp});case"between":return O({Between:[t.timestamps.start,t.timestamps.end]});default:throw new at("Invalid list matcher for timestamp",t)}},S=({matcher:t,paginate:e,order:o,owner:s})=>({matcher:B(t)?[]:[{key:O(t.key),description:O(t.description),created_at:_e(t.createdAt),updated_at:_e(t.updatedAt)}],paginate:O(B(e)?void 0:{start_after:O(e.startAfter),limit:O(B(e.limit)?void 0:BigInt(e.limit))}),order:O(B(o)?void 0:{desc:o.desc,field:o.field==="created_at"?{CreatedAt:null}:o.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:O(B(s)?void 0:typeof s=="string"?Le.fromText(s):s)});import{assertNonNullish as to}from"@dfinity/utils";import{nonNullish as $t}from"@dfinity/utils";var me=({satelliteId:t,container:e})=>{let{satelliteId:o}=Wt({satelliteId:t}),{container:s}=Yt({container:e});if($t(s)&&s!==!1){let{host:n,protocol:r}=new URL(s===!0?J:s);return`${r}//${o??"unknown"}.${n.replace("127.0.0.1","localhost")}`}return`https://${o??"unknown"}.icp0.io`},Wt=({satelliteId:t})=>$t(t)?{satelliteId:t}:g.getInstance().get()??{satelliteId:void 0},Yt=({container:t})=>$t(t)?{container:t}:g.getInstance().get()??{container:void 0};var Xt=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),o=t.Record({sha256:t.Vec(t.Nat8),proposal_id:t.Nat}),s=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),n=t.Record({field:s,desc:t.Bool}),r=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),a=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(r),description:t.Opt(t.Text),created_at:t.Opt(r)}),i=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),c=t.Record({order:t.Opt(n),owner:t.Opt(t.Principal),matcher:t.Opt(a),paginate:t.Opt(i)}),R=t.Record({controllers:t.Vec(t.Principal)}),d=t.Variant({Write:t.Null,Admin:t.Null,Submit:t.Null}),u=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:d,expires_at:t.Opt(t.Nat64)}),m=t.Record({version:t.Opt(t.Nat64)}),_=t.Variant({Db:t.Null,Storage:t.Null}),P=t.Record({version:t.Opt(t.Nat64)}),C=t.Record({proposal_ids:t.Vec(t.Nat)}),F=t.Record({cycles:t.Nat,destination_id:t.Principal}),M=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),G=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),x=t.Record({key:M,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,G)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),z=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),f=t.Record({internet_identity:t.Opt(z)}),U=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),w=t.Record({max_memory_size:t.Opt(U)}),dt=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),ut=t.Variant({Deny:t.Null,Allow:t.Null}),_t=t.Record({status_code:t.Nat16,location:t.Text}),v=t.Record({iframe:t.Opt(dt),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(U),raw_access:t.Opt(ut),redirects:t.Opt(t.Vec(t.Tuple(t.Text,_t)))}),mt=t.Record({db:t.Opt(w),authentication:t.Opt(f),storage:v}),T=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),Ot=t.Variant({Initialized:t.Null,Failed:t.Null,Open:t.Null,Rejected:t.Null,Executed:t.Null,Accepted:t.Null}),Nt=t.Record({clear_existing_assets:t.Opt(t.Bool)}),Rt=t.Record({orbiter:t.Opt(t.Text),mission_control_version:t.Opt(t.Text),satellite_version:t.Opt(t.Text)}),$=t.Variant({AssetsUpgrade:Nt,SegmentsDeployment:Rt}),E=t.Record({status:Ot,updated_at:t.Nat64,sha256:t.Opt(t.Vec(t.Nat8)),executed_at:t.Opt(t.Nat64),owner:t.Principal,created_at:t.Nat64,version:t.Opt(t.Nat64),proposal_type:$}),b=t.Variant({Heap:t.Null,Stable:t.Null}),h=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),W=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),V=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(b),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:h,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(W),write:h,max_changes_per_user:t.Opt(t.Nat32)}),Tt=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),k=t.Record({memory:b,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),yt=t.Variant({Callback:t.Record({token:k,callback:t.Func([],[],["query"])})}),gt=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(yt),status_code:t.Nat16}),At=t.Record({token:t.Opt(k),body:t.Vec(t.Nat8)}),Y=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),X=t.Record({batch_id:t.Nat}),xt=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,x)),items_length:t.Nat64}),ft=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Et=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,T)),items_length:t.Nat64}),ht=t.Record({desc:t.Bool}),St=t.Record({start_after:t.Opt(t.Nat),limit:t.Opt(t.Nat)}),Pt=t.Record({order:t.Opt(ht),paginate:t.Opt(St)}),Ct=t.Record({proposal_id:t.Nat}),Ft=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(Ct,E)),items_length:t.Nat64}),Ut=t.Record({include_system:t.Bool}),wt=t.Record({matcher:t.Opt(Ut)}),vt=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(t.Text,V)),items_length:t.Nat64}),bt=t.Record({stable:t.Nat64,heap:t.Nat64}),Vt=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:d,expires_at:t.Opt(t.Nat64)}),kt=t.Record({controller:Vt,controllers:t.Vec(t.Principal)}),Z=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),Mt=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(b),max_size:t.Opt(t.Nat),read:h,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(W),write:h,max_changes_per_user:t.Opt(t.Nat32)}),Q=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),D=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),commit_proposal:t.Func([o],[t.Null],[]),commit_proposal_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,c],[t.Nat64],["query"]),count_collection_assets:t.Func([t.Text],[t.Nat64],["query"]),count_collection_docs:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text,c],[t.Nat64],["query"]),count_proposals:t.Func([],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([R],[t.Vec(t.Tuple(t.Principal,u))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,m],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,c],[],[]),del_filtered_docs:t.Func([t.Text,c],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,m))],[],[]),del_rule:t.Func([_,t.Text,P],[],[]),delete_proposal_assets:t.Func([C],[],[]),deposit_cycles:t.Func([F],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(x)],["query"]),get_auth_config:t.Func([],[t.Opt(f)],["query"]),get_config:t.Func([],[mt],[]),get_db_config:t.Func([],[t.Opt(w)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(T)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(x)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(T)))],["query"]),get_proposal:t.Func([t.Nat],[t.Opt(E)],["query"]),get_rule:t.Func([_,t.Text],[t.Opt(V)],["query"]),get_storage_config:t.Func([],[v],["query"]),http_request:t.Func([Tt],[gt],["query"]),http_request_streaming_callback:t.Func([k],[At],["query"]),init_asset_upload:t.Func([Y],[X],[]),init_proposal:t.Func([$],[t.Nat,E],[]),init_proposal_asset_upload:t.Func([Y,t.Nat],[X],[]),list_assets:t.Func([t.Text,c],[xt],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,u))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,ft))],["query"]),list_docs:t.Func([t.Text,c],[Et],["query"]),list_proposals:t.Func([Pt],[Ft],["query"]),list_rules:t.Func([_,wt],[vt],["query"]),memory_size:t.Func([],[bt],["query"]),reject_proposal:t.Func([o],[t.Null],[]),set_auth_config:t.Func([f],[],[]),set_controllers:t.Func([kt],[t.Vec(t.Tuple(t.Principal,u))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([w],[],[]),set_doc:t.Func([t.Text,t.Text,Z],[T],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,Z))],[t.Vec(t.Tuple(t.Text,T))],[]),set_rule:t.Func([_,t.Text,Mt],[V],[]),set_storage_config:t.Func([v],[],[]),submit_proposal:t.Func([t.Nat],[t.Nat,E],[]),upload_asset_chunk:t.Func([Q],[D],[]),upload_proposal_asset_chunk:t.Func([Q],[D],[])})};var Zt=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),o=t.Record({sha256:t.Vec(t.Nat8),proposal_id:t.Nat}),s=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),n=t.Record({field:s,desc:t.Bool}),r=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),a=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(r),description:t.Opt(t.Text),created_at:t.Opt(r)}),i=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),c=t.Record({order:t.Opt(n),owner:t.Opt(t.Principal),matcher:t.Opt(a),paginate:t.Opt(i)}),R=t.Record({controllers:t.Vec(t.Principal)}),d=t.Variant({Write:t.Null,Admin:t.Null,Submit:t.Null}),u=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:d,expires_at:t.Opt(t.Nat64)}),m=t.Record({version:t.Opt(t.Nat64)}),_=t.Variant({Db:t.Null,Storage:t.Null}),P=t.Record({version:t.Opt(t.Nat64)}),C=t.Record({proposal_ids:t.Vec(t.Nat)}),F=t.Record({cycles:t.Nat,destination_id:t.Principal}),M=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),G=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),x=t.Record({key:M,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,G)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),z=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),f=t.Record({internet_identity:t.Opt(z)}),U=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),w=t.Record({max_memory_size:t.Opt(U)}),dt=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),ut=t.Variant({Deny:t.Null,Allow:t.Null}),_t=t.Record({status_code:t.Nat16,location:t.Text}),v=t.Record({iframe:t.Opt(dt),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(U),raw_access:t.Opt(ut),redirects:t.Opt(t.Vec(t.Tuple(t.Text,_t)))}),mt=t.Record({db:t.Opt(w),authentication:t.Opt(f),storage:v}),T=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),Ot=t.Variant({Initialized:t.Null,Failed:t.Null,Open:t.Null,Rejected:t.Null,Executed:t.Null,Accepted:t.Null}),Nt=t.Record({clear_existing_assets:t.Opt(t.Bool)}),Rt=t.Record({orbiter:t.Opt(t.Text),mission_control_version:t.Opt(t.Text),satellite_version:t.Opt(t.Text)}),$=t.Variant({AssetsUpgrade:Nt,SegmentsDeployment:Rt}),E=t.Record({status:Ot,updated_at:t.Nat64,sha256:t.Opt(t.Vec(t.Nat8)),executed_at:t.Opt(t.Nat64),owner:t.Principal,created_at:t.Nat64,version:t.Opt(t.Nat64),proposal_type:$}),b=t.Variant({Heap:t.Null,Stable:t.Null}),h=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),W=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),V=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(b),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:h,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(W),write:h,max_changes_per_user:t.Opt(t.Nat32)}),Tt=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),k=t.Record({memory:b,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),yt=t.Variant({Callback:t.Record({token:k,callback:t.Func([],[],[])})}),gt=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(yt),status_code:t.Nat16}),At=t.Record({token:t.Opt(k),body:t.Vec(t.Nat8)}),Y=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),X=t.Record({batch_id:t.Nat}),xt=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,x)),items_length:t.Nat64}),ft=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Et=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,T)),items_length:t.Nat64}),ht=t.Record({desc:t.Bool}),St=t.Record({start_after:t.Opt(t.Nat),limit:t.Opt(t.Nat)}),Pt=t.Record({order:t.Opt(ht),paginate:t.Opt(St)}),Ct=t.Record({proposal_id:t.Nat}),Ft=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(Ct,E)),items_length:t.Nat64}),Ut=t.Record({include_system:t.Bool}),wt=t.Record({matcher:t.Opt(Ut)}),vt=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(t.Text,V)),items_length:t.Nat64}),bt=t.Record({stable:t.Nat64,heap:t.Nat64}),Vt=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:d,expires_at:t.Opt(t.Nat64)}),kt=t.Record({controller:Vt,controllers:t.Vec(t.Principal)}),Z=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),Mt=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(b),max_size:t.Opt(t.Nat),read:h,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(W),write:h,max_changes_per_user:t.Opt(t.Nat32)}),Q=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),D=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),commit_proposal:t.Func([o],[t.Null],[]),commit_proposal_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,c],[t.Nat64],[]),count_collection_assets:t.Func([t.Text],[t.Nat64],[]),count_collection_docs:t.Func([t.Text],[t.Nat64],[]),count_docs:t.Func([t.Text,c],[t.Nat64],[]),count_proposals:t.Func([],[t.Nat64],[]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([R],[t.Vec(t.Tuple(t.Principal,u))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,m],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,c],[],[]),del_filtered_docs:t.Func([t.Text,c],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,m))],[],[]),del_rule:t.Func([_,t.Text,P],[],[]),delete_proposal_assets:t.Func([C],[],[]),deposit_cycles:t.Func([F],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(x)],[]),get_auth_config:t.Func([],[t.Opt(f)],[]),get_config:t.Func([],[mt],[]),get_db_config:t.Func([],[t.Opt(w)],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(T)],[]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(x)))],[]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(T)))],[]),get_proposal:t.Func([t.Nat],[t.Opt(E)],[]),get_rule:t.Func([_,t.Text],[t.Opt(V)],[]),get_storage_config:t.Func([],[v],[]),http_request:t.Func([Tt],[gt],[]),http_request_streaming_callback:t.Func([k],[At],[]),init_asset_upload:t.Func([Y],[X],[]),init_proposal:t.Func([$],[t.Nat,E],[]),init_proposal_asset_upload:t.Func([Y,t.Nat],[X],[]),list_assets:t.Func([t.Text,c],[xt],[]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,u))],[]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,ft))],[]),list_docs:t.Func([t.Text,c],[Et],[]),list_proposals:t.Func([Pt],[Ft],[]),list_rules:t.Func([_,wt],[vt],[]),memory_size:t.Func([],[bt],[]),reject_proposal:t.Func([o],[t.Null],[]),set_auth_config:t.Func([f],[],[]),set_controllers:t.Func([kt],[t.Vec(t.Tuple(t.Principal,u))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([w],[],[]),set_doc:t.Func([t.Text,t.Text,Z],[T],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,Z))],[t.Vec(t.Tuple(t.Text,T))],[]),set_rule:t.Func([_,t.Text,Mt],[V],[]),set_storage_config:t.Func([v],[],[]),submit_proposal:t.Func([t.Nat],[t.Nat,E],[]),upload_asset_chunk:t.Func([Q],[D],[]),upload_proposal_asset_chunk:t.Func([Q],[D],[])})};var p=({satellite:t,options:{certified:e}})=>Ne({idlFactory:e?Zt:Xt,actorKey:`stock#${e?"update":"query"}`,...t}),Oe=({idlFactory:t,...e})=>Ne({idlFactory:t,actorKey:"extended#query",...e}),Ne=async({satelliteId:t,container:e,...o})=>{let{satelliteId:s}=Wt({satelliteId:t});to(s,"No satellite ID defined. Did you initialize Juno?");let{container:n}=Yt({container:e});return await K.getInstance().getActor({satelliteId:s,container:n,...o})};var Re=async({collection:t,key:e,...o})=>{let{get_doc:s}=await p(o),n=H(await s(t,e));if(!eo(n))return I({doc:n,key:e})},Te=async({docs:t,...e})=>{let{get_many_docs:o}=await p(e),s=t.map(({collection:a,key:i})=>[a,i]),n=await o(s),r=[];for(let[a,i]of n){let c=H(i);r.push(oo(c)?await I({key:a,doc:c}):void 0)}return r},ye=async({collection:t,doc:e,...o})=>{let{set_doc:s}=await p(o),{key:n}=e,r=await Gt(e),a=await s(t,n,r);return await I({key:n,doc:a})},ge=async({docs:t,...e})=>{let{set_many_docs:o}=await p(e),s=[];for(let{collection:a,doc:i}of t){let{key:c}=i;s.push([a,c,await Gt(i)])}let n=await o(s),r=[];for(let[a,i]of n)r.push(await I({key:a,doc:i}));return r},Ae=async({collection:t,doc:e,...o})=>{let{del_doc:s}=await p(o),{key:n}=e;return s(t,n,zt(e))},xe=async({docs:t,...e})=>{let{del_many_docs:o}=await p(e),s=t.map(({collection:n,doc:r})=>[n,r.key,zt(r)]);await o(s)},fe=async({collection:t,filter:e,...o})=>{let{del_filtered_docs:s}=await p(o);return s(t,S(e))},Ee=async({collection:t,filter:e,...o})=>{let{list_docs:s}=await p(o),{items:n,items_page:r,items_length:a,matches_length:i,matches_pages:c}=await s(t,S(e)),R=[];for(let[d,u]of n){let{data:m,owner:_,description:P,version:C,...F}=u;R.push({key:d,description:H(P),owner:_.toText(),data:await de({data:m}),version:H(C),...F})}return{items:R,items_length:a,items_page:H(r),matches_length:i,matches_pages:H(c)}},he=async({collection:t,filter:e,...o})=>{let{count_docs:s}=await p(o);return s(t,S(e))};var A={certified:!1};import{AnonymousIdentity as so}from"@dfinity/agent";import{nonNullish as no}from"@dfinity/utils";var l=t=>no(t)?t:ct()??new so;var Se=async({satellite:t,options:e,...o})=>{let s=l(t?.identity);return await Re({...o,satellite:{...t,identity:s},options:e??A})},$s=async({satellite:t,options:e,...o})=>{let s=l(t?.identity);return await Te({...o,satellite:{...t,identity:s},options:e??A})},Pe=async({satellite:t,...e})=>{let o=l(t?.identity);return await ye({...e,satellite:{...t,identity:o},options:{certified:!0}})},Ws=async({satellite:t,...e})=>{let o=l(t?.identity);return await ge({...e,satellite:{...t,identity:o},options:{certified:!0}})},Ys=async({satellite:t,...e})=>{let o=l(t?.identity);return await Ae({...e,satellite:{...t,identity:o},options:{certified:!0}})},Xs=async({satellite:t,...e})=>{let o=l(t?.identity);return await xe({...e,satellite:{...t,identity:o},options:{certified:!0}})},Zs=async({satellite:t,filter:e,...o})=>{let s=l(t?.identity);return await fe({...o,filter:e??{},satellite:{...t,identity:s},options:{certified:!0}})},Qs=async({satellite:t,options:e,filter:o,...s})=>{let n=l(t?.identity);return await Ee({...s,filter:o??{},satellite:{...t,identity:n},options:e??A})},Ds=async({satellite:t,options:e,filter:o,...s})=>{let n=l(t?.identity);return await he({...s,filter:o??{},satellite:{...t,identity:n},options:e??A})};var Fe=async t=>{let e=ct();if(ro(e))throw new rt("No identity to initialize the user. Have you initialized Juno?");let o=e.getPrincipal().toText(),s=()=>Se({collection:"#user",key:o}),n=await s();if(Ce(n))return n;try{return await ao({userId:o,provider:t})}catch(r){if(Bt({error:r,type:pe})){let a=await s();if(Ce(a))return a}throw r}},ao=({userId:t,...e})=>Pe({collection:"#user",doc:{key:t,data:e}});var N,Qt=async t=>{if(N=N??await it(),!(await N?.isAuthenticated()??!1))return;let o=await Fe(t);y.getInstance().set(o)},co=t=>new Promise(async(e,o)=>{if(Ue(N)){o(new st("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let s=t?.provider??new et({});await N.login({onSuccess:async()=>{await Qt(s.id),e()},onError:n=>{if(n===io){o(new nt(n));return}o(new ot(n))},maxTimeToLive:t?.maxTimeToLive??It,allowPinAuthentication:t?.allowPin??Lt,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...s.signInOptions({windowed:t?.windowed})})}),Dt=async()=>{await lo(),N=await it()},lo=async()=>{await N?.logout(),N=null,y.getInstance().reset(),K.getInstance().reset(),q.getInstance().reset()},ct=()=>N?.getIdentity(),po=async()=>(N??await it()).getIdentity(),uo=async()=>{let t=y.getInstance().get();return Ue(t)||!(await N?.isAuthenticated()??!1)?null:N?.getIdentity()??null};var we=t=>{let e=t===!0?"./workers/auth.worker.js":t,o=new Worker(e),s=async()=>{jt({message:"junoSignOutAuthTimer"}),await Dt()};return o.onmessage=async({data:n})=>{let{msg:r,data:a}=n;switch(r){case"junoSignOutAuthTimer":await s();return;case"junoDelegationRemainingTime":jt({message:"junoDelegationRemainingTime",detail:a?.authRemainingTime});return}},y.getInstance().subscribe(n=>{if(_o(n)){o.postMessage({msg:"junoStopAuthTimer"});return}o.postMessage({msg:"junoStartAuthTimer"})})};var ve=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},be=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};var hn=async({idlFactory:t,satellite:e})=>{let o=l(e?.identity);return await Oe({idlFactory:t,...e,identity:o})};import{fromNullable as ze,nonNullish as yo}from"@dfinity/utils";import{fromNullable as pt}from"@dfinity/utils";import{toNullable as lt}from"@dfinity/utils";var Ve=async({asset:{data:t,headers:e,...o},actor:s})=>{let{init_asset_upload:n,upload_asset_chunk:r,commit_asset_upload:a}=s,{batch_id:i}=await n(mo(o)),{chunkIds:c}=await No({data:t,uploadFn:r,batchId:i});await Oo({commitFn:a,batchId:i,data:t,headers:e,chunkIds:c})};var mo=({filename:t,collection:e,token:o,fullPath:s,encoding:n,description:r})=>({collection:e,full_path:s,name:t,token:lt(o),encoding_type:lt(n),description:lt(r)}),Oo=async({commitFn:t,batchId:e,chunkIds:o,headers:s,data:n})=>{let r=s.find(([a,i])=>a.toLowerCase()==="content-type")===void 0&&n.type!==void 0&&n.type!==""?[["Content-Type",n.type]]:void 0;await t({batch_id:e,chunk_ids:o.map(({chunk_id:a})=>a),headers:[...s,...r??[]]})},No=async({data:t,uploadFn:e,batchId:o})=>{let s=[],n=tt()?new Blob([await t.arrayBuffer()]):t,r=0n;for(let i=0;i<n.size;i+=19e5){let c=n.slice(i,i+19e5);s.push({batchId:o,chunk:c,uploadFn:e,orderId:r}),r++}let a=[];for await(let i of Ro({uploadChunks:s}))a=[...a,...i];return{chunkIds:a}};async function*Ro({uploadChunks:t,limit:e=12}){for(let o=0;o<t.length;o=o+e){let s=t.slice(o,o+e);yield await Promise.all(s.map(n=>To(n)))}}var To=async({batchId:t,chunk:e,uploadFn:o,orderId:s})=>o({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:lt(s)});var ke=async({asset:t,...e})=>{let o=await p(e);await Ve({actor:o,asset:t})},Me=async({collection:t,filter:e,...o})=>{let{list_assets:s}=await p(o),{items:n,items_length:r,items_page:a,matches_length:i,matches_pages:c}=await s(t,S(e));return{items:n.map(([R,d])=>d),items_length:r,items_page:pt(a),matches_length:i,matches_pages:pt(c)}},je=async({collection:t,filter:e,...o})=>{let{count_assets:s}=await p(o);return s(t,S(e))},Je=async({collection:t,fullPath:e,...o})=>(await p(o)).del_asset(t,e),qe=async({assets:t,satellite:e})=>{let{del_many_assets:o}=await p({satellite:e,options:{certified:!0}}),s=t.map(({collection:n,fullPath:r})=>[n,r]);await o(s)},Ke=async({collection:t,filter:e,...o})=>{let{del_filtered_assets:s}=await p(o);return s(t,S(e))},Be=async({collection:t,fullPath:e,...o})=>{let{get_asset:s}=await p(o);return pt(await s(t,e))},He=async({assets:t,...e})=>{let{get_many_assets:o}=await p(e),s=t.map(({collection:r,fullPath:a})=>[r,a]);return(await o(s)).map(([r,a])=>pt(a))};var Ge=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var Hn=t=>$e(t),Gn=t=>$e({filename:t.data.name,...t}),$e=async({filename:t,data:e,collection:o,headers:s=[],fullPath:n,token:r,satellite:a,encoding:i,description:c})=>{let R=l(a?.identity),d=decodeURI(t),u=n??`/${o}/${d}`,m={...a,identity:R};return await ke({asset:{data:e,filename:d,collection:o,token:r,headers:s,fullPath:u,encoding:i,description:c},satellite:m,options:{certified:!0}}),{downloadUrl:We({satellite:m,assetKey:{fullPath:u,token:r}}),fullPath:u,name:d}},zn=async({collection:t,filter:e,satellite:o,options:s})=>{let n={...o,identity:l(o?.identity)},{items:r,...a}=await Me({collection:t,filter:e??{},satellite:n,options:s??A}),i=r.map(({key:{full_path:c,token:R,name:d,owner:u,description:m},headers:_,encodings:P,created_at:C,updated_at:F})=>{let M=ze(R);return{fullPath:c,description:ze(m),name:d,downloadUrl:We({satellite:n,assetKey:{fullPath:c,token:M}}),token:M,headers:_,encodings:P.reduce((G,[x,{modified:z,sha256:f,total_length:U}])=>({...G,[x]:{modified:z,sha256:Ge(f),total_length:U}}),{}),owner:u.toText(),created_at:C,updated_at:F}});return{items:i,assets:i,...a}},$n=async({collection:t,filter:e,satellite:o,options:s})=>{let n={...o,identity:l(o?.identity)};return await je({collection:t,satellite:n,filter:e??{},options:s??A})},Wn=({collection:t,fullPath:e,satellite:o})=>Je({collection:t,fullPath:e,satellite:{...o,identity:l(o?.identity)},options:{certified:!0}}),Yn=({assets:t,satellite:e})=>qe({assets:t,satellite:{...e,identity:l(e?.identity)},options:{certified:!0}}),Xn=async({collection:t,satellite:e,filter:o})=>{let s={...e,identity:l(e?.identity)};return await Ke({collection:t,satellite:s,filter:o??{},options:{certified:!0}})},Zn=async({satellite:t,options:e,...o})=>{let s=l(t?.identity);return await Be({...o,satellite:{...t,identity:s},options:e??A})},Qn=async({satellite:t,options:e,...o})=>{let s=l(t?.identity);return await He({...o,satellite:{...t,identity:s},options:e??A})},We=({assetKey:{fullPath:t,token:e},satellite:o})=>{let s={...o,identity:l(o?.identity)};return`${me(s)}${t}${yo(e)?`?token=${e}`:""}`};var Ao=t=>{let e=t?.satelliteId??ve();go(e,"Satellite ID is not configured. Juno cannot be initialized.");let o=t?.container??be();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:o}},nr=t=>xo(t),xo=async t=>{let e=Ao(t);g.getInstance().set(e),await Qt();let o=e.workers?.auth!==void 0?we(e.workers.auth):void 0;return[...o?[o]:[]]},rr=t=>y.getInstance().subscribe(t);export{rt as InitError,et as InternetIdentityProvider,at as ListError,ie as NFIDProvider,ot as SignInError,st as SignInInitError,nt as SignInUserInterruptError,rr as authSubscribe,$n as countAssets,Ds as countDocs,Wn as deleteAsset,Ys as deleteDoc,Xn as deleteFilteredAssets,Zs as deleteFilteredDocs,Yn as deleteManyAssets,Xs as deleteManyDocs,We as downloadUrl,Zn as getAsset,Se as getDoc,uo as getIdentityOnce,Qn as getManyAssets,$s as getManyDocs,hn as getSatelliteExtendedActor,nr as initJuno,xo as initSatellite,zn as listAssets,Qs as listDocs,Pe as setDoc,Ws as setManyDocs,co as signIn,Dt as signOut,po as unsafeIdentity,Hn as uploadBlob,Gn as uploadFile};
|
|
3
|
+
import{assertNonNullish as Eo}from"@dfinity/utils";import{isNullish as To}from"@dfinity/utils";var q=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:o})=>o(e))}subscribe(e){let o=Symbol();return this.callbacks.push({id:o,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:s})=>s!==o)}};var y=class t extends q{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let o=super.subscribe(e);return e(this.authUser),o}reset(){this.authUser=null,this.populate(this.authUser)}};var Bt=({message:t,detail:e})=>{let o=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(o)};import{ERROR_USER_INTERRUPT as uo}from"@dfinity/auth-client";import{isNullish as Ve}from"@dfinity/utils";var oe=BigInt(144e11),se=!1,re={width:576,height:576},ne={width:505,height:705},ae="internetcomputer.org";import{isNullish as Le,nonNullish as pe}from"@dfinity/utils";var K="http://127.0.0.1:5987",ie="rdmx6-jaaaa-aaaaa-aaadq-cai";var g=class t extends q{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}reset(){this.env=null}subscribe(e){let o=super.subscribe(e);return e(this.env),o}};import{isNullish as le}from"@dfinity/utils";import{jsonReplacer as De,jsonReviver as Ie}from"@dfinity/utils";var ce=async t=>{let e=new Blob([JSON.stringify(t,De)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},st=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),Ie)},rt=()=>typeof window<"u";var Ht=({width:t,height:e})=>{if(!rt()||le(window)||le(window.top))return;let{top:{innerWidth:o,innerHeight:s}}=window,r=s/2+screenY-e/2,n=o/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${r}, left=${n}`};var nt=class{#t;constructor({domain:e}){this.#t=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let o=()=>{let s=g.getInstance().get()?.container;if(Le(s)||s===!1)return`https://identity.${this.#t??ae}`;let r=g.getInstance().get(),n=pe(r)&&pe(r?.internetIdentityId)?r.internetIdentityId:ie,{host:a,protocol:i}=new URL(s===!0?K:s);return/apple/i.test(navigator?.vendor)?`${i}//${a}?canisterId=${n}`:`${i}//${n}.${a.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:Ht(re)},identityProvider:o()}}},de=class{#t;#e;constructor({appName:e,logoUrl:o}){this.#t=e,this.#e=o}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:Ht(ne)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#t)}&applicationLogo=${encodeURI(this.#e)}`}}};import{Actor as eo}from"@dfinity/agent";import{isNullish as zt}from"@dfinity/utils";import{isNullish as Gt}from"@dfinity/utils";import{HttpAgent as to}from"@dfinity/agent";import{nonNullish as ue}from"@dfinity/utils";var _e=async({identity:t,container:e})=>{let s=ue(e)&&e!==!1?e===!0?K:e:"https://icp-api.io",r=ue(e);return await to.create({identity:t,shouldFetchRootKey:r,host:s})};var B=class t{static instance;#t=void 0;constructor(){}static getInstance(){return Gt(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...o}){let s=e.getPrincipal().toText();if(Gt(this.#t)||Gt(this.#t[s])){let r=await _e({identity:e,...o});return this.#t={...this.#t??{},[s]:r},r}return this.#t[s]}reset(){this.#t=null}};var H=class t{static instance;#t=void 0;constructor(){}static getInstance(){return zt(t.instance)&&(t.instance=new t),t.instance}async getActor({satelliteId:e,identity:o,actorKey:s,...r}){let n=`${s}#${o.getPrincipal().toText()}#${e};`;if(zt(this.#t)||zt(this.#t[n])){let a=await this.createActor({satelliteId:e,identity:o,...r});return this.#t={...this.#t??{},[n]:a},a}return this.#t[n]}reset(){this.#t=null}async createActor({idlFactory:e,satelliteId:o,...s}){let r=await B.getInstance().getAgent(s);return eo.createActor(e,{agent:r,canisterId:o})}};var at=class extends Error{},it=class extends Error{},ct=class extends Error{},lt=class extends Error{},pt=class extends Error{};import{AuthClient as oo}from"@dfinity/auth-client";var dt=()=>oo.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});import{isNullish as lo,nonNullish as we}from"@dfinity/utils";var $t=({error:t,type:e})=>typeof t=="string"?t.includes(e):t instanceof Error?t.message.includes(e):!1;var me="juno.datastore.error.user.cannot_update";import{fromNullable as z,isNullish as no,nonNullish as ao}from"@dfinity/utils";var Oe=async({data:t})=>{try{return await st(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};import{fromNullable as Ne,toNullable as Wt}from"@dfinity/utils";var Yt=async t=>{let{data:e,version:o,description:s}=t;return{description:Wt(s),data:await ce(e),version:Wt(o)}},Xt=t=>{let{version:e}=t;return{version:Wt(e)}},ot=async({doc:t,key:e})=>{let{owner:o,version:s,description:r,data:n,...a}=t;return{key:e,description:Ne(r),owner:o.toText(),data:await st(n),version:Ne(s),...a}};import{Principal as so}from"@dfinity/principal";import{isNullish as G,toNullable as O}from"@dfinity/utils";var Te=t=>{if(G(t))return O();switch(t.matcher){case"equal":return O({Equal:t.timestamp});case"greaterThan":return O({GreaterThan:t.timestamp});case"lessThan":return O({LessThan:t.timestamp});case"between":return O({Between:[t.timestamps.start,t.timestamps.end]});default:throw new pt("Invalid list matcher for timestamp",t)}},P=({matcher:t,paginate:e,order:o,owner:s})=>({matcher:G(t)?[]:[{key:O(t.key),description:O(t.description),created_at:Te(t.createdAt),updated_at:Te(t.updatedAt)}],paginate:O(G(e)?void 0:{start_after:O(e.startAfter),limit:O(G(e.limit)?void 0:BigInt(e.limit))}),order:O(G(o)?void 0:{desc:o.desc,field:o.field==="created_at"?{CreatedAt:null}:o.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:O(G(s)?void 0:typeof s=="string"?so.fromText(s):s)});import{assertNonNullish as ro}from"@dfinity/utils";import{nonNullish as Zt}from"@dfinity/utils";var Re=({satelliteId:t,container:e})=>{let{satelliteId:o}=Qt({satelliteId:t}),{container:s}=Dt({container:e});if(Zt(s)&&s!==!1){let{host:r,protocol:n}=new URL(s===!0?K:s);return`${n}//${o??"unknown"}.${r.replace("127.0.0.1","localhost")}`}return`https://${o??"unknown"}.icp0.io`},Qt=({satelliteId:t})=>Zt(t)?{satelliteId:t}:g.getInstance().get()??{satelliteId:void 0},Dt=({container:t})=>Zt(t)?{container:t}:g.getInstance().get()??{container:void 0};var It=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),o=t.Record({sha256:t.Vec(t.Nat8),proposal_id:t.Nat}),s=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),r=t.Record({field:s,desc:t.Bool}),n=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),a=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(n),description:t.Opt(t.Text),created_at:t.Opt(n)}),i=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),c=t.Record({order:t.Opt(r),owner:t.Opt(t.Principal),matcher:t.Opt(a),paginate:t.Opt(i)}),T=t.Record({controllers:t.Vec(t.Principal)}),d=t.Variant({Write:t.Null,Admin:t.Null,Submit:t.Null}),u=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:d,expires_at:t.Opt(t.Nat64)}),m=t.Record({version:t.Opt(t.Nat64)}),_=t.Variant({Db:t.Null,Storage:t.Null}),C=t.Record({version:t.Opt(t.Nat64)}),F=t.Record({proposal_ids:t.Vec(t.Nat)}),U=t.Record({cycles:t.Nat,destination_id:t.Principal}),J=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),$=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),A=t.Record({key:J,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,$)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),v=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),w=t.Record({allowed_callers:t.Vec(t.Principal)}),f=t.Record({updated_at:t.Opt(t.Nat64),created_at:t.Opt(t.Nat64),version:t.Opt(t.Nat64),internet_identity:t.Opt(v),rules:t.Opt(w)}),E=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),b=t.Record({updated_at:t.Opt(t.Nat64),created_at:t.Opt(t.Nat64),version:t.Opt(t.Nat64),max_memory_size:t.Opt(E)}),W=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),Y=t.Variant({Deny:t.Null,Allow:t.Null}),X=t.Record({status_code:t.Nat16,location:t.Text}),V=t.Record({iframe:t.Opt(W),updated_at:t.Opt(t.Nat64),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),created_at:t.Opt(t.Nat64),version:t.Opt(t.Nat64),max_memory_size:t.Opt(E),raw_access:t.Opt(Y),redirects:t.Opt(t.Vec(t.Tuple(t.Text,X)))}),Ot=t.Record({db:t.Opt(b),authentication:t.Opt(f),storage:V}),R=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),Nt=t.Variant({Initialized:t.Null,Failed:t.Null,Open:t.Null,Rejected:t.Null,Executed:t.Null,Accepted:t.Null}),Tt=t.Record({clear_existing_assets:t.Opt(t.Bool)}),Rt=t.Record({orbiter:t.Opt(t.Text),mission_control_version:t.Opt(t.Text),satellite_version:t.Opt(t.Text)}),Z=t.Variant({AssetsUpgrade:Tt,SegmentsDeployment:Rt}),h=t.Record({status:Nt,updated_at:t.Nat64,sha256:t.Opt(t.Vec(t.Nat8)),executed_at:t.Opt(t.Nat64),owner:t.Principal,created_at:t.Nat64,version:t.Opt(t.Nat64),proposal_type:Z}),k=t.Variant({Heap:t.Null,Stable:t.Null}),S=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),Q=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),M=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(k),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:S,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(Q),write:S,max_changes_per_user:t.Opt(t.Nat32)}),yt=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),j=t.Record({memory:k,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),gt=t.Variant({Callback:t.Record({token:j,callback:t.Func([],[],["query"])})}),xt=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(gt),status_code:t.Nat16}),At=t.Record({token:t.Opt(j),body:t.Vec(t.Nat8)}),D=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),I=t.Record({batch_id:t.Nat}),ft=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,A)),items_length:t.Nat64}),Et=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),ht=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,R)),items_length:t.Nat64}),St=t.Record({desc:t.Bool}),Pt=t.Record({start_after:t.Opt(t.Nat),limit:t.Opt(t.Nat)}),Ct=t.Record({order:t.Opt(St),paginate:t.Opt(Pt)}),Ft=t.Record({proposal_id:t.Nat}),Ut=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(Ft,h)),items_length:t.Nat64}),vt=t.Record({include_system:t.Bool}),wt=t.Record({matcher:t.Opt(vt)}),bt=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(t.Text,M)),items_length:t.Nat64}),Vt=t.Record({stable:t.Nat64,heap:t.Nat64}),kt=t.Record({version:t.Opt(t.Nat64),internet_identity:t.Opt(v),rules:t.Opt(w)}),Mt=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:d,expires_at:t.Opt(t.Nat64)}),jt=t.Record({controller:Mt,controllers:t.Vec(t.Principal)}),Jt=t.Record({version:t.Opt(t.Nat64),max_memory_size:t.Opt(E)}),L=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),qt=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(k),max_size:t.Opt(t.Nat),read:S,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(Q),write:S,max_changes_per_user:t.Opt(t.Nat32)}),Kt=t.Record({iframe:t.Opt(W),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),version:t.Opt(t.Nat64),max_memory_size:t.Opt(E),raw_access:t.Opt(Y),redirects:t.Opt(t.Vec(t.Tuple(t.Text,X)))}),tt=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),et=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),commit_proposal:t.Func([o],[t.Null],[]),commit_proposal_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,c],[t.Nat64],["query"]),count_collection_assets:t.Func([t.Text],[t.Nat64],["query"]),count_collection_docs:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text,c],[t.Nat64],["query"]),count_proposals:t.Func([],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([T],[t.Vec(t.Tuple(t.Principal,u))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,m],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,c],[],[]),del_filtered_docs:t.Func([t.Text,c],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,m))],[],[]),del_rule:t.Func([_,t.Text,C],[],[]),delete_proposal_assets:t.Func([F],[],[]),deposit_cycles:t.Func([U],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(A)],["query"]),get_auth_config:t.Func([],[t.Opt(f)],["query"]),get_config:t.Func([],[Ot],[]),get_db_config:t.Func([],[t.Opt(b)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(R)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(A)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(R)))],["query"]),get_proposal:t.Func([t.Nat],[t.Opt(h)],["query"]),get_rule:t.Func([_,t.Text],[t.Opt(M)],["query"]),get_storage_config:t.Func([],[V],["query"]),http_request:t.Func([yt],[xt],["query"]),http_request_streaming_callback:t.Func([j],[At],["query"]),init_asset_upload:t.Func([D],[I],[]),init_proposal:t.Func([Z],[t.Nat,h],[]),init_proposal_asset_upload:t.Func([D,t.Nat],[I],[]),list_assets:t.Func([t.Text,c],[ft],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,u))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,Et))],["query"]),list_docs:t.Func([t.Text,c],[ht],["query"]),list_proposals:t.Func([Ct],[Ut],["query"]),list_rules:t.Func([_,wt],[bt],["query"]),memory_size:t.Func([],[Vt],["query"]),reject_proposal:t.Func([o],[t.Null],[]),set_auth_config:t.Func([kt],[f],[]),set_controllers:t.Func([jt],[t.Vec(t.Tuple(t.Principal,u))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([Jt],[b],[]),set_doc:t.Func([t.Text,t.Text,L],[R],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,L))],[t.Vec(t.Tuple(t.Text,R))],[]),set_rule:t.Func([_,t.Text,qt],[M],[]),set_storage_config:t.Func([Kt],[V],[]),submit_proposal:t.Func([t.Nat],[t.Nat,h],[]),upload_asset_chunk:t.Func([tt],[et],[]),upload_proposal_asset_chunk:t.Func([tt],[et],[])})};var Lt=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),o=t.Record({sha256:t.Vec(t.Nat8),proposal_id:t.Nat}),s=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),r=t.Record({field:s,desc:t.Bool}),n=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),a=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(n),description:t.Opt(t.Text),created_at:t.Opt(n)}),i=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),c=t.Record({order:t.Opt(r),owner:t.Opt(t.Principal),matcher:t.Opt(a),paginate:t.Opt(i)}),T=t.Record({controllers:t.Vec(t.Principal)}),d=t.Variant({Write:t.Null,Admin:t.Null,Submit:t.Null}),u=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:d,expires_at:t.Opt(t.Nat64)}),m=t.Record({version:t.Opt(t.Nat64)}),_=t.Variant({Db:t.Null,Storage:t.Null}),C=t.Record({version:t.Opt(t.Nat64)}),F=t.Record({proposal_ids:t.Vec(t.Nat)}),U=t.Record({cycles:t.Nat,destination_id:t.Principal}),J=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),$=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),A=t.Record({key:J,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,$)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),v=t.Record({derivation_origin:t.Opt(t.Text),external_alternative_origins:t.Opt(t.Vec(t.Text))}),w=t.Record({allowed_callers:t.Vec(t.Principal)}),f=t.Record({updated_at:t.Opt(t.Nat64),created_at:t.Opt(t.Nat64),version:t.Opt(t.Nat64),internet_identity:t.Opt(v),rules:t.Opt(w)}),E=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),b=t.Record({updated_at:t.Opt(t.Nat64),created_at:t.Opt(t.Nat64),version:t.Opt(t.Nat64),max_memory_size:t.Opt(E)}),W=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),Y=t.Variant({Deny:t.Null,Allow:t.Null}),X=t.Record({status_code:t.Nat16,location:t.Text}),V=t.Record({iframe:t.Opt(W),updated_at:t.Opt(t.Nat64),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),created_at:t.Opt(t.Nat64),version:t.Opt(t.Nat64),max_memory_size:t.Opt(E),raw_access:t.Opt(Y),redirects:t.Opt(t.Vec(t.Tuple(t.Text,X)))}),Ot=t.Record({db:t.Opt(b),authentication:t.Opt(f),storage:V}),R=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),Nt=t.Variant({Initialized:t.Null,Failed:t.Null,Open:t.Null,Rejected:t.Null,Executed:t.Null,Accepted:t.Null}),Tt=t.Record({clear_existing_assets:t.Opt(t.Bool)}),Rt=t.Record({orbiter:t.Opt(t.Text),mission_control_version:t.Opt(t.Text),satellite_version:t.Opt(t.Text)}),Z=t.Variant({AssetsUpgrade:Tt,SegmentsDeployment:Rt}),h=t.Record({status:Nt,updated_at:t.Nat64,sha256:t.Opt(t.Vec(t.Nat8)),executed_at:t.Opt(t.Nat64),owner:t.Principal,created_at:t.Nat64,version:t.Opt(t.Nat64),proposal_type:Z}),k=t.Variant({Heap:t.Null,Stable:t.Null}),S=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),Q=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),M=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(k),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:S,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(Q),write:S,max_changes_per_user:t.Opt(t.Nat32)}),yt=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),j=t.Record({memory:k,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),gt=t.Variant({Callback:t.Record({token:j,callback:t.Func([],[],[])})}),xt=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(gt),status_code:t.Nat16}),At=t.Record({token:t.Opt(j),body:t.Vec(t.Nat8)}),D=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),I=t.Record({batch_id:t.Nat}),ft=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,A)),items_length:t.Nat64}),Et=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),ht=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,R)),items_length:t.Nat64}),St=t.Record({desc:t.Bool}),Pt=t.Record({start_after:t.Opt(t.Nat),limit:t.Opt(t.Nat)}),Ct=t.Record({order:t.Opt(St),paginate:t.Opt(Pt)}),Ft=t.Record({proposal_id:t.Nat}),Ut=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(Ft,h)),items_length:t.Nat64}),vt=t.Record({include_system:t.Bool}),wt=t.Record({matcher:t.Opt(vt)}),bt=t.Record({matches_length:t.Nat64,items:t.Vec(t.Tuple(t.Text,M)),items_length:t.Nat64}),Vt=t.Record({stable:t.Nat64,heap:t.Nat64}),kt=t.Record({version:t.Opt(t.Nat64),internet_identity:t.Opt(v),rules:t.Opt(w)}),Mt=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:d,expires_at:t.Opt(t.Nat64)}),jt=t.Record({controller:Mt,controllers:t.Vec(t.Principal)}),Jt=t.Record({version:t.Opt(t.Nat64),max_memory_size:t.Opt(E)}),L=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),qt=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(k),max_size:t.Opt(t.Nat),read:S,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(Q),write:S,max_changes_per_user:t.Opt(t.Nat32)}),Kt=t.Record({iframe:t.Opt(W),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),version:t.Opt(t.Nat64),max_memory_size:t.Opt(E),raw_access:t.Opt(Y),redirects:t.Opt(t.Vec(t.Tuple(t.Text,X)))}),tt=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),et=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),commit_proposal:t.Func([o],[t.Null],[]),commit_proposal_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,c],[t.Nat64],[]),count_collection_assets:t.Func([t.Text],[t.Nat64],[]),count_collection_docs:t.Func([t.Text],[t.Nat64],[]),count_docs:t.Func([t.Text,c],[t.Nat64],[]),count_proposals:t.Func([],[t.Nat64],[]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([T],[t.Vec(t.Tuple(t.Principal,u))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,m],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,c],[],[]),del_filtered_docs:t.Func([t.Text,c],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,m))],[],[]),del_rule:t.Func([_,t.Text,C],[],[]),delete_proposal_assets:t.Func([F],[],[]),deposit_cycles:t.Func([U],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(A)],[]),get_auth_config:t.Func([],[t.Opt(f)],[]),get_config:t.Func([],[Ot],[]),get_db_config:t.Func([],[t.Opt(b)],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(R)],[]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(A)))],[]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(R)))],[]),get_proposal:t.Func([t.Nat],[t.Opt(h)],[]),get_rule:t.Func([_,t.Text],[t.Opt(M)],[]),get_storage_config:t.Func([],[V],[]),http_request:t.Func([yt],[xt],[]),http_request_streaming_callback:t.Func([j],[At],[]),init_asset_upload:t.Func([D],[I],[]),init_proposal:t.Func([Z],[t.Nat,h],[]),init_proposal_asset_upload:t.Func([D,t.Nat],[I],[]),list_assets:t.Func([t.Text,c],[ft],[]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,u))],[]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,Et))],[]),list_docs:t.Func([t.Text,c],[ht],[]),list_proposals:t.Func([Ct],[Ut],[]),list_rules:t.Func([_,wt],[bt],[]),memory_size:t.Func([],[Vt],[]),reject_proposal:t.Func([o],[t.Null],[]),set_auth_config:t.Func([kt],[f],[]),set_controllers:t.Func([jt],[t.Vec(t.Tuple(t.Principal,u))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([Jt],[b],[]),set_doc:t.Func([t.Text,t.Text,L],[R],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,L))],[t.Vec(t.Tuple(t.Text,R))],[]),set_rule:t.Func([_,t.Text,qt],[M],[]),set_storage_config:t.Func([Kt],[V],[]),submit_proposal:t.Func([t.Nat],[t.Nat,h],[]),upload_asset_chunk:t.Func([tt],[et],[]),upload_proposal_asset_chunk:t.Func([tt],[et],[])})};var p=({satellite:t,options:{certified:e}})=>ge({idlFactory:e?Lt:It,actorKey:`stock#${e?"update":"query"}`,...t}),ye=({idlFactory:t,...e})=>ge({idlFactory:t,actorKey:"extended#query",...e}),ge=async({satelliteId:t,container:e,...o})=>{let{satelliteId:s}=Qt({satelliteId:t});ro(s,"No satellite ID defined. Did you initialize Juno?");let{container:r}=Dt({container:e});return await H.getInstance().getActor({satelliteId:s,container:r,...o})};var xe=async({collection:t,key:e,...o})=>{let{get_doc:s}=await p(o),r=z(await s(t,e));if(!no(r))return ot({doc:r,key:e})},Ae=async({docs:t,...e})=>{let{get_many_docs:o}=await p(e),s=t.map(({collection:a,key:i})=>[a,i]),r=await o(s),n=[];for(let[a,i]of r){let c=z(i);n.push(ao(c)?await ot({key:a,doc:c}):void 0)}return n},fe=async({collection:t,doc:e,...o})=>{let{set_doc:s}=await p(o),{key:r}=e,n=await Yt(e),a=await s(t,r,n);return await ot({key:r,doc:a})},Ee=async({docs:t,...e})=>{let{set_many_docs:o}=await p(e),s=[];for(let{collection:a,doc:i}of t){let{key:c}=i;s.push([a,c,await Yt(i)])}let r=await o(s),n=[];for(let[a,i]of r)n.push(await ot({key:a,doc:i}));return n},he=async({collection:t,doc:e,...o})=>{let{del_doc:s}=await p(o),{key:r}=e;return s(t,r,Xt(e))},Se=async({docs:t,...e})=>{let{del_many_docs:o}=await p(e),s=t.map(({collection:r,doc:n})=>[r,n.key,Xt(n)]);await o(s)},Pe=async({collection:t,filter:e,...o})=>{let{del_filtered_docs:s}=await p(o);return s(t,P(e))},Ce=async({collection:t,filter:e,...o})=>{let{list_docs:s}=await p(o),{items:r,items_page:n,items_length:a,matches_length:i,matches_pages:c}=await s(t,P(e)),T=[];for(let[d,u]of r){let{data:m,owner:_,description:C,version:F,...U}=u;T.push({key:d,description:z(C),owner:_.toText(),data:await Oe({data:m}),version:z(F),...U})}return{items:T,items_length:a,items_page:z(n),matches_length:i,matches_pages:z(c)}},Fe=async({collection:t,filter:e,...o})=>{let{count_docs:s}=await p(o);return s(t,P(e))};var x={certified:!1};import{AnonymousIdentity as io}from"@dfinity/agent";import{nonNullish as co}from"@dfinity/utils";var l=t=>co(t)?t:ut()??new io;var Ue=async({satellite:t,options:e,...o})=>{let s=l(t?.identity);return await xe({...o,satellite:{...t,identity:s},options:e??x})},Zs=async({satellite:t,options:e,...o})=>{let s=l(t?.identity);return await Ae({...o,satellite:{...t,identity:s},options:e??x})},ve=async({satellite:t,...e})=>{let o=l(t?.identity);return await fe({...e,satellite:{...t,identity:o},options:{certified:!0}})},Qs=async({satellite:t,...e})=>{let o=l(t?.identity);return await Ee({...e,satellite:{...t,identity:o},options:{certified:!0}})},Ds=async({satellite:t,...e})=>{let o=l(t?.identity);return await he({...e,satellite:{...t,identity:o},options:{certified:!0}})},Is=async({satellite:t,...e})=>{let o=l(t?.identity);return await Se({...e,satellite:{...t,identity:o},options:{certified:!0}})},Ls=async({satellite:t,filter:e,...o})=>{let s=l(t?.identity);return await Pe({...o,filter:e??{},satellite:{...t,identity:s},options:{certified:!0}})},tr=async({satellite:t,options:e,filter:o,...s})=>{let r=l(t?.identity);return await Ce({...s,filter:o??{},satellite:{...t,identity:r},options:e??x})},er=async({satellite:t,options:e,filter:o,...s})=>{let r=l(t?.identity);return await Fe({...s,filter:o??{},satellite:{...t,identity:r},options:e??x})};var be=async t=>{let e=ut();if(lo(e))throw new lt("No identity to initialize the user. Have you initialized Juno?");let o=e.getPrincipal().toText(),s=()=>Ue({collection:"#user",key:o}),r=await s();if(we(r))return r;try{return await po({userId:o,provider:t})}catch(n){if($t({error:n,type:me})){let a=await s();if(we(a))return a}throw n}},po=({userId:t,...e})=>ve({collection:"#user",doc:{key:t,data:e}});var N,te=async t=>{if(N=N??await dt(),!(await N?.isAuthenticated()??!1))return;let o=await be(t);y.getInstance().set(o)},_o=t=>new Promise(async(e,o)=>{if(Ve(N)){o(new it("No client is ready to perform a sign-in. Have you initialized the Satellite?"));return}let s=t?.provider??new nt({});await N.login({onSuccess:async()=>{await te(s.id),e()},onError:r=>{if(r===uo){o(new ct(r));return}o(new at(r))},maxTimeToLive:t?.maxTimeToLive??oe,allowPinAuthentication:t?.allowPin??se,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...s.signInOptions({windowed:t?.windowed})})}),ee=async()=>{await mo(),N=await dt()},mo=async()=>{await N?.logout(),N=null,y.getInstance().reset(),H.getInstance().reset(),B.getInstance().reset()},ut=()=>N?.getIdentity(),Oo=async()=>(N??await dt()).getIdentity(),No=async()=>{let t=y.getInstance().get();return Ve(t)||!(await N?.isAuthenticated()??!1)?null:N?.getIdentity()??null};var ke=t=>{let e=t===!0?"./workers/auth.worker.js":t,o=new Worker(e),s=async()=>{Bt({message:"junoSignOutAuthTimer"}),await ee()};return o.onmessage=async({data:r})=>{let{msg:n,data:a}=r;switch(n){case"junoSignOutAuthTimer":await s();return;case"junoDelegationRemainingTime":Bt({message:"junoDelegationRemainingTime",detail:a?.authRemainingTime});return}},y.getInstance().subscribe(r=>{if(To(r)){o.postMessage({msg:"junoStopAuthTimer"});return}o.postMessage({msg:"junoStartAuthTimer"})})};var Me=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},je=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};var Cr=async({idlFactory:t,satellite:e})=>{let o=l(e?.identity);return await ye({idlFactory:t,...e,identity:o})};import{fromNullable as Xe,nonNullish as fo}from"@dfinity/utils";import{fromNullable as mt}from"@dfinity/utils";import{toNullable as _t}from"@dfinity/utils";var Je=async({asset:{data:t,headers:e,...o},actor:s})=>{let{init_asset_upload:r,upload_asset_chunk:n,commit_asset_upload:a}=s,{batch_id:i}=await r(Ro(o)),{chunkIds:c}=await go({data:t,uploadFn:n,batchId:i});await yo({commitFn:a,batchId:i,data:t,headers:e,chunkIds:c})};var Ro=({filename:t,collection:e,token:o,fullPath:s,encoding:r,description:n})=>({collection:e,full_path:s,name:t,token:_t(o),encoding_type:_t(r),description:_t(n)}),yo=async({commitFn:t,batchId:e,chunkIds:o,headers:s,data:r})=>{let n=s.find(([a,i])=>a.toLowerCase()==="content-type")===void 0&&r.type!==void 0&&r.type!==""?[["Content-Type",r.type]]:void 0;await t({batch_id:e,chunk_ids:o.map(({chunk_id:a})=>a),headers:[...s,...n??[]]})},go=async({data:t,uploadFn:e,batchId:o})=>{let s=[],r=rt()?new Blob([await t.arrayBuffer()]):t,n=0n;for(let i=0;i<r.size;i+=19e5){let c=r.slice(i,i+19e5);s.push({batchId:o,chunk:c,uploadFn:e,orderId:n}),n++}let a=[];for await(let i of xo({uploadChunks:s}))a=[...a,...i];return{chunkIds:a}};async function*xo({uploadChunks:t,limit:e=12}){for(let o=0;o<t.length;o=o+e){let s=t.slice(o,o+e);yield await Promise.all(s.map(r=>Ao(r)))}}var Ao=async({batchId:t,chunk:e,uploadFn:o,orderId:s})=>o({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:_t(s)});var qe=async({asset:t,...e})=>{let o=await p(e);await Je({actor:o,asset:t})},Ke=async({collection:t,filter:e,...o})=>{let{list_assets:s}=await p(o),{items:r,items_length:n,items_page:a,matches_length:i,matches_pages:c}=await s(t,P(e));return{items:r.map(([T,d])=>d),items_length:n,items_page:mt(a),matches_length:i,matches_pages:mt(c)}},Be=async({collection:t,filter:e,...o})=>{let{count_assets:s}=await p(o);return s(t,P(e))},He=async({collection:t,fullPath:e,...o})=>(await p(o)).del_asset(t,e),Ge=async({assets:t,satellite:e})=>{let{del_many_assets:o}=await p({satellite:e,options:{certified:!0}}),s=t.map(({collection:r,fullPath:n})=>[r,n]);await o(s)},ze=async({collection:t,filter:e,...o})=>{let{del_filtered_assets:s}=await p(o);return s(t,P(e))},$e=async({collection:t,fullPath:e,...o})=>{let{get_asset:s}=await p(o);return mt(await s(t,e))},We=async({assets:t,...e})=>{let{get_many_assets:o}=await p(e),s=t.map(({collection:n,fullPath:a})=>[n,a]);return(await o(s)).map(([n,a])=>mt(a))};var Ye=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var $r=t=>Ze(t),Wr=t=>Ze({filename:t.data.name,...t}),Ze=async({filename:t,data:e,collection:o,headers:s=[],fullPath:r,token:n,satellite:a,encoding:i,description:c})=>{let T=l(a?.identity),d=decodeURI(t),u=r??`/${o}/${d}`,m={...a,identity:T};return await qe({asset:{data:e,filename:d,collection:o,token:n,headers:s,fullPath:u,encoding:i,description:c},satellite:m,options:{certified:!0}}),{downloadUrl:Qe({satellite:m,assetKey:{fullPath:u,token:n}}),fullPath:u,name:d}},Yr=async({collection:t,filter:e,satellite:o,options:s})=>{let r={...o,identity:l(o?.identity)},{items:n,...a}=await Ke({collection:t,filter:e??{},satellite:r,options:s??x}),i=n.map(({key:{full_path:c,token:T,name:d,owner:u,description:m},headers:_,encodings:C,created_at:F,updated_at:U})=>{let J=Xe(T);return{fullPath:c,description:Xe(m),name:d,downloadUrl:Qe({satellite:r,assetKey:{fullPath:c,token:J}}),token:J,headers:_,encodings:C.reduce(($,[A,{modified:v,sha256:w,total_length:f}])=>({...$,[A]:{modified:v,sha256:Ye(w),total_length:f}}),{}),owner:u.toText(),created_at:F,updated_at:U}});return{items:i,assets:i,...a}},Xr=async({collection:t,filter:e,satellite:o,options:s})=>{let r={...o,identity:l(o?.identity)};return await Be({collection:t,satellite:r,filter:e??{},options:s??x})},Zr=({collection:t,fullPath:e,satellite:o})=>He({collection:t,fullPath:e,satellite:{...o,identity:l(o?.identity)},options:{certified:!0}}),Qr=({assets:t,satellite:e})=>Ge({assets:t,satellite:{...e,identity:l(e?.identity)},options:{certified:!0}}),Dr=async({collection:t,satellite:e,filter:o})=>{let s={...e,identity:l(e?.identity)};return await ze({collection:t,satellite:s,filter:o??{},options:{certified:!0}})},Ir=async({satellite:t,options:e,...o})=>{let s=l(t?.identity);return await $e({...o,satellite:{...t,identity:s},options:e??x})},Lr=async({satellite:t,options:e,...o})=>{let s=l(t?.identity);return await We({...o,satellite:{...t,identity:s},options:e??x})},Qe=({assetKey:{fullPath:t,token:e},satellite:o})=>{let s={...o,identity:l(o?.identity)};return`${Re(s)}${t}${fo(e)?`?token=${e}`:""}`};var ho=t=>{let e=t?.satelliteId??Me();Eo(e,"Satellite ID is not configured. Juno cannot be initialized.");let o=t?.container??je();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:o}},cn=t=>So(t),So=async t=>{let e=ho(t);g.getInstance().set(e),await te();let o=e.workers?.auth!==void 0?ke(e.workers.auth):void 0;return[...o?[o]:[]]},ln=t=>y.getInstance().subscribe(t);export{lt as InitError,nt as InternetIdentityProvider,pt as ListError,de as NFIDProvider,at as SignInError,it as SignInInitError,ct as SignInUserInterruptError,ln as authSubscribe,Xr as countAssets,er as countDocs,Zr as deleteAsset,Ds as deleteDoc,Dr as deleteFilteredAssets,Ls as deleteFilteredDocs,Qr as deleteManyAssets,Is as deleteManyDocs,Qe as downloadUrl,Ir as getAsset,Ue as getDoc,No as getIdentityOnce,Lr as getManyAssets,Zs as getManyDocs,Cr as getSatelliteExtendedActor,cn as initJuno,So as initSatellite,Yr as listAssets,tr as listDocs,ve as setDoc,Qs as setManyDocs,_o as signIn,ee as signOut,Oo as unsafeIdentity,$r as uploadBlob,Wr as uploadFile};
|
|
4
4
|
//# sourceMappingURL=index.mjs.map
|