@junobuild/admin 0.0.58-next-2024-11-24 → 0.0.58-next-2024-11-25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var Wr=Object.defineProperty;var Gr=(e,t)=>{for(var r in t)Wr(e,r,{get:t[r],enumerable:!0})};var me=class extends Error{constructor(){super("The Wasm code for the upgrade is identical to the code currently installed. No upgrade is necessary.")}};import{isNullish as Zr}from"@junobuild/utils";var Ie=({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({subnet_id:e.Opt(e.Principal),name:e.Opt(e.Text)}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,satellite_id:e.Principal}),o=e.Record({cycles:e.Nat,destination_id:e.Principal}),i=e.Record({e8s:e.Nat64}),s=e.Record({timestamp_nanos:e.Nat64}),c=e.Record({to:e.Vec(e.Nat8),fee:i,memo:e.Nat64,from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:i}),u=e.Variant({TxTooOld:e.Record({allowed_window_nanos:e.Nat64}),BadFee:e.Record({expected_fee:i}),TxDuplicate:e.Record({duplicate_of:e.Nat64}),TxCreatedInFuture:e.Null,InsufficientFunds:e.Record({balance:i})}),l=e.Variant({Ok:e.Nat64,Err:u}),_=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),g=e.Record({to:_,fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),m=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:e.Nat}),Duplicate:e.Record({duplicate_of:e.Nat}),BadFee:e.Record({expected_fee:e.Nat}),CreatedInFuture:e.Record({ledger_time:e.Nat64}),TooOld:e.Null,InsufficientFunds:e.Record({balance:e.Nat})}),a=e.Variant({Ok:e.Nat,Err:m}),p=e.Variant({Write:e.Null,Admin:e.Null}),f=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:p,expires_at:e.Opt(e.Nat64)}),T=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),x=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),h=e.Record({status:T,memory_size:e.Nat,cycles:e.Nat,settings:x,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),w=e.Record({id:e.Principal,status:h,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),status_at:e.Nat64}),y=e.Variant({Ok:w,Err:e.Text}),b=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:p,expires_at:e.Opt(e.Nat64)}),S=e.Record({enabled:e.Bool,cycles_threshold:e.Opt(e.Nat64)}),C=e.Record({mission_control_cycles_threshold:e.Opt(e.Nat64),orbiters:e.Vec(e.Tuple(e.Principal,S)),satellites:e.Vec(e.Tuple(e.Principal,S)),cycles_threshold:e.Opt(e.Nat64)}),R=e.Record({orbiters:e.Opt(e.Vec(y)),satellites:e.Opt(e.Vec(y)),mission_control:y});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_orbiter_with_config:e.Func([r],[t],[]),create_satellite:e.Func([e.Text],[n],[]),create_satellite_with_config:e.Func([r],[n],[]),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([o],[],[]),get_user:e.Func([],[e.Principal],["query"]),icp_transfer:e.Func([c],[l],[]),icrc_transfer:e.Func([e.Principal,g],[a],[]),list_mission_control_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,f))],["query"]),list_mission_control_statuses:e.Func([],[e.Vec(e.Tuple(e.Nat64,y))],["query"]),list_orbiter_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,y)))],["query"]),list_orbiters:e.Func([],[e.Vec(e.Tuple(e.Principal,t))],["query"]),list_satellite_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,y)))],["query"]),list_satellites:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["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),b],[],[]),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),b],[],[]),set_satellite:e.Func([e.Principal,e.Opt(e.Text)],[n],[]),set_satellite_metadata:e.Func([e.Principal,e.Vec(e.Tuple(e.Text,e.Text))],[n],[]),set_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal),b],[],[]),status:e.Func([C],[R],[]),top_up:e.Func([e.Principal,i],[],[]),unset_orbiter:e.Func([e.Principal],[],[]),unset_satellite:e.Func([e.Principal],[],[]),version:e.Func([],[e.Text],["query"])})};var De=({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}),g=e.Record({desktop:e.Float64,others:e.Float64,mobile:e.Float64}),m=e.Record({browsers:_,devices:g}),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))}),T=e.Variant({Navigate:e.Null,Restore:e.Null,Reload:e.Null,BackForward:e.Null,BackForwardCache:e.Null,Prerender:e.Null}),x=e.Record({id:e.Text,value:e.Float64,navigation_type:e.Opt(T),delta:e.Float64}),h=e.Variant({WebVitalsMetric:x}),w=e.Variant({CLS:e.Null,FCP:e.Null,INP:e.Null,LCP:e.Null,TTFB:e.Null}),y=e.Record({updated_at:e.Nat64,session_id:e.Text,data:h,href:e.Text,metric_name:w,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),b=e.Record({cls:e.Opt(e.Float64),fcp:e.Opt(e.Float64),inp:e.Opt(e.Float64),lcp:e.Opt(e.Float64),ttfb:e.Opt(e.Float64)}),S=e.Record({overall:b,pages:e.Vec(e.Tuple(e.Text,b))}),C=e.Record({updated_at:e.Nat64,session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),R=e.Record({total:e.Vec(e.Tuple(e.Text,e.Nat32))}),E=e.Record({performance_metrics:e.Bool,track_events:e.Bool,page_views:e.Bool}),F=e.Record({updated_at:e.Nat64,features:e.Opt(E),created_at:e.Nat64,version:e.Opt(e.Nat64)}),k=e.Record({stable:e.Nat64,heap:e.Nat64}),j=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:r,expires_at:e.Opt(e.Nat64)}),U=e.Record({controller:j,controllers:e.Vec(e.Principal)}),H=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)}),K=e.Variant({Ok:l,Err:e.Text}),W=e.Variant({Ok:e.Null,Err:e.Vec(e.Tuple(c,e.Text))}),$=e.Record({session_id:e.Text,data:h,href:e.Text,metric_name:w,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),Be=e.Variant({Ok:y,Err:e.Text}),Ue=e.Record({features:e.Opt(E),version:e.Opt(e.Nat64)}),de=e.Record({updated_at:e.Opt(e.Nat64),session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),$e=e.Variant({Ok:C,Err:e.Text});return e.Service({del_controllers:e.Func([t],[e.Vec(e.Tuple(e.Principal,n))],[]),del_satellite_config:e.Func([e.Principal,o],[],[]),deposit_cycles:e.Func([i],[],[]),get_page_views:e.Func([s],[e.Vec(e.Tuple(c,l))],["query"]),get_page_views_analytics_clients:e.Func([s],[m],["query"]),get_page_views_analytics_metrics:e.Func([s],[p],["query"]),get_page_views_analytics_top_10:e.Func([s],[f],["query"]),get_performance_metrics:e.Func([s],[e.Vec(e.Tuple(c,y))],["query"]),get_performance_metrics_analytics_web_vitals:e.Func([s],[S],["query"]),get_track_events:e.Func([s],[e.Vec(e.Tuple(c,C))],["query"]),get_track_events_analytics:e.Func([s],[R],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_satellite_configs:e.Func([],[e.Vec(e.Tuple(e.Principal,F))],["query"]),memory_size:e.Func([],[k],["query"]),set_controllers:e.Func([U],[e.Vec(e.Tuple(e.Principal,n))],[]),set_page_view:e.Func([c,H],[K],[]),set_page_views:e.Func([e.Vec(e.Tuple(c,H))],[W],[]),set_performance_metric:e.Func([c,$],[Be],[]),set_performance_metrics:e.Func([e.Vec(e.Tuple(c,$))],[W],[]),set_satellite_configs:e.Func([e.Vec(e.Tuple(e.Principal,Ue))],[e.Vec(e.Tuple(e.Principal,F))],[]),set_track_event:e.Func([c,de],[$e],[]),set_track_events:e.Func([e.Vec(e.Tuple(c,de))],[W],[]),version:e.Func([],[e.Text],["query"])})};var Le=({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([],[],[])})}),g=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(_),status_code:e.Nat16}),m=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}),T=e.Record({field:f,desc:e.Bool}),x=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),h=e.Record({order:e.Opt(T),owner:e.Opt(e.Principal),matcher:e.Opt(e.Text),paginate:e.Opt(x)}),w=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),y=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),b=e.Record({key:w,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,y)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),S=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,b))}),C=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),R=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,c))}),E=e.Variant({Db:e.Null,Storage:e.Null}),F=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),k=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:F,created_at:e.Nat64,write:F}),j=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),U=e.Record({controller:j,controllers:e.Vec(e.Principal)}),H=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:F,write:F}),W=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),$=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],[g],["query"]),http_request_streaming_callback:e.Func([l],[m],["query"]),init_asset_upload:e.Func([a],[p],[]),list_assets:e.Func([e.Opt(e.Text),h],[S],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,C))],["query"]),list_docs:e.Func([e.Text,h],[R],["query"]),list_rules:e.Func([E],[e.Vec(e.Tuple(e.Text,k))],["query"]),set_config:e.Func([s],[],[]),set_controllers:e.Func([U],[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,H],[c],[]),set_rule:e.Func([E,e.Text,K],[],[]),upload_asset_chunk:e.Func([W],[$],[]),version:e.Func([],[e.Text],["query"])})};var et=({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([],[],[])})}),g=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(_),status_code:e.Nat16}),m=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}),T=e.Record({field:f,desc:e.Bool}),x=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),h=e.Record({order:e.Opt(T),matcher:e.Opt(e.Text),paginate:e.Opt(x)}),w=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),y=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),b=e.Record({key:w,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,y)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),S=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,b))}),C=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),R=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,c))}),E=e.Variant({Db:e.Null,Storage:e.Null}),F=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),k=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:F,created_at:e.Nat64,write:F}),j=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),U=e.Record({controller:j,controllers:e.Vec(e.Principal)}),H=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:F,write:F}),W=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),$=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],[g],["query"]),http_request_streaming_callback:e.Func([l],[m],["query"]),init_asset_upload:e.Func([a],[p],[]),list_assets:e.Func([e.Opt(e.Text),h],[S],["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],[R],["query"]),list_rules:e.Func([E],[e.Vec(e.Tuple(e.Text,k))],["query"]),set_config:e.Func([s],[],[]),set_controllers:e.Func([U],[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,H],[c],[]),set_rule:e.Func([E,e.Text,K],[],[]),upload_asset_chunk:e.Func([W],[$],[]),version:e.Func([],[e.Text],["query"])})};var tt=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),n=e.Record({field:r,desc:e.Bool}),o=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),i=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(o),description:e.Opt(e.Text),created_at:e.Opt(o)}),s=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),c=e.Record({order:e.Opt(n),owner:e.Opt(e.Principal),matcher:e.Opt(i),paginate:e.Opt(s)}),u=e.Record({controllers:e.Vec(e.Principal)}),l=e.Variant({Write:e.Null,Admin:e.Null}),_=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:l,expires_at:e.Opt(e.Nat64)}),g=e.Record({version:e.Opt(e.Nat64)}),m=e.Variant({Db:e.Null,Storage:e.Null}),a=e.Record({version:e.Opt(e.Nat64)}),p=e.Record({cycles:e.Nat,destination_id:e.Principal}),f=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),T=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),x=e.Record({key:f,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,T)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),h=e.Record({derivation_origin:e.Opt(e.Text)}),w=e.Record({internet_identity:e.Opt(h)}),y=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),b=e.Record({max_memory_size:e.Opt(y)}),S=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),C=e.Variant({Deny:e.Null,Allow:e.Null}),R=e.Record({status_code:e.Nat16,location:e.Text}),E=e.Record({iframe:e.Opt(S),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(y),raw_access:e.Opt(C),redirects:e.Opt(e.Vec(e.Tuple(e.Text,R)))}),F=e.Record({db:e.Opt(b),authentication:e.Opt(w),storage:E}),k=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),j=e.Variant({Heap:e.Null,Stable:e.Null}),U=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),H=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),K=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(j),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:U,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(H),write:U}),W=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)}),$=e.Record({memory:j,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),Be=e.Variant({Callback:e.Record({token:$,callback:e.Func([],[],["query"])})}),Ue=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(Be),status_code:e.Nat16}),de=e.Record({token:e.Opt($),body:e.Vec(e.Nat8)}),$e=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}),Mr=e.Record({batch_id:e.Nat}),kr=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,x)),items_length:e.Nat64}),Br=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),Ur=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,k)),items_length:e.Nat64}),$r=e.Record({stable:e.Nat64,heap:e.Nat64}),qr=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:l,expires_at:e.Opt(e.Nat64)}),zr=e.Record({controller:qr,controllers:e.Vec(e.Principal)}),Qe=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),jr=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(j),max_size:e.Opt(e.Nat),read:U,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(H),write:U}),Hr=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Kr=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,c],[e.Nat64],["query"]),count_collection_assets:e.Func([e.Text],[e.Nat64],["query"]),count_collection_docs:e.Func([e.Text],[e.Nat64],["query"]),count_docs:e.Func([e.Text,c],[e.Nat64],["query"]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([u],[e.Vec(e.Tuple(e.Principal,_))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,g],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,c],[],[]),del_filtered_docs:e.Func([e.Text,c],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,g))],[],[]),del_rule:e.Func([m,e.Text,a],[],[]),deposit_cycles:e.Func([p],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(x)],["query"]),get_auth_config:e.Func([],[e.Opt(w)],["query"]),get_config:e.Func([],[F],[]),get_db_config:e.Func([],[e.Opt(b)],["query"]),get_doc:e.Func([e.Text,e.Text],[e.Opt(k)],["query"]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(x)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(k)))],["query"]),get_rule:e.Func([m,e.Text],[e.Opt(K)],["query"]),get_storage_config:e.Func([],[E],["query"]),http_request:e.Func([W],[Ue],["query"]),http_request_streaming_callback:e.Func([$],[de],["query"]),init_asset_upload:e.Func([$e],[Mr],[]),list_assets:e.Func([e.Text,c],[kr],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,_))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Br))],["query"]),list_docs:e.Func([e.Text,c],[Ur],["query"]),list_rules:e.Func([m],[e.Vec(e.Tuple(e.Text,K))],["query"]),memory_size:e.Func([],[$r],["query"]),set_auth_config:e.Func([w],[],[]),set_controllers:e.Func([zr],[e.Vec(e.Tuple(e.Principal,_))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([b],[],[]),set_doc:e.Func([e.Text,e.Text,Qe],[k],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,Qe))],[e.Vec(e.Tuple(e.Text,k))],[]),set_rule:e.Func([m,e.Text,jr],[K],[]),set_storage_config:e.Func([E],[],[]),upload_asset_chunk:e.Func([Hr],[Kr],[]),version:e.Func([],[e.Text],["query"])})};import{Actor as Jr,HttpAgent as Xr}from"@dfinity/agent";import{nonNullish as rt}from"@junobuild/utils";var nt=async({canisterId:e,idlFactory:t,config:r,...n})=>{let o=await ie(n);return Jr.createActor(t,{agent:o,canisterId:e,...r??{}})},ie=async({identity:e,fetch:t,container:r})=>{let n=rt(r)&&r!==!1,o=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io";return await Xr.create({identity:e,host:o,retryTimes:10,...rt(t)&&{fetch:t},shouldFetchRootKey:n})};var ot=({satelliteId:e,...t})=>se({canisterId:e,...t,idlFactory:et}),V=({satelliteId:e,...t})=>se({canisterId:e,...t,idlFactory:tt}),it=({satelliteId:e,...t})=>se({canisterId:e,...t,idlFactory:Le}),ee=({missionControlId:e,...t})=>se({canisterId:e,...t,idlFactory:Ie}),fe=({orbiterId:e,...t})=>se({canisterId:e,...t,idlFactory:De}),se=({canisterId:e,idlFactory:t,...r})=>{if(Zr(e))throw new Error("No canister ID provided.");return nt({canisterId:e,idlFactory:t,...r})};var st=async({missionControl:e})=>(await ee(e)).version(),at=async({missionControl:e})=>(await ee(e)).get_user(),ct=async({missionControl:e})=>(await ee(e)).list_mission_control_controllers(),lt=async({missionControl:e,satelliteIds:t,controllerIds:r,controller:n})=>(await ee(e)).set_satellites_controllers(t,r,n),ut=async({missionControl:e,controllerIds:t,controller:r})=>(await ee(e)).set_mission_control_controllers(t,r);import{Principal as Yr}from"@dfinity/principal";import{nonNullish as Qr,toNullable as Ir}from"@junobuild/utils";var qe=({controllerId:e,profile:t})=>({controllerIds:[Yr.fromText(e)],controller:Dr(t)}),Dr=e=>({metadata:Qr(e)&&e!==""?[["profile",e]]:[],expires_at:Ir(void 0),scope:{Admin:null}});var Zn=({controllerId:e,profile:t,...r})=>lt({...r,...qe({controllerId:e,profile:t})}),Yn=({controllerId:e,profile:t,...r})=>ut({...r,...qe({controllerId:e,profile:t})}),Qn=e=>ct(e);import{Principal as fn}from"@dfinity/principal";var ae={reinstall:null},D={upgrade:[{skip_pre_upgrade:[!1],wasm_memory_persistence:[{replace:null}]}]};import{fromNullable as nn,isNullish as on}from"@junobuild/utils";import{CanisterStatus as Lr}from"@dfinity/agent";import{ICManagementCanister as pt}from"@dfinity/ic-management";import{Principal as en}from"@dfinity/principal";import{assertNonNullish as tn}from"@junobuild/utils";var dt=async({actor:e,code:t})=>{let r=await ie(e),{installCode:n}=pt.create({agent:r});return n(t)};var mt=async({actor:e,canisterId:t})=>{let r=await ie(e),{canisterStatus:n}=pt.create({agent:r});return n(t)},ft=async({canisterId:e,path:t,...r})=>{tn(e,"A canister ID must be provided to request its status.");let n=await ie(r);return(await Lr.request({canisterId:en.from(e),agent:n,paths:[{kind:"metadata",key:t,path:t,decodeStrategy:"utf-8"}]})).get(t)};var ht=e=>(e instanceof Uint8Array||(e=Uint8Array.from(e)),e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),""));var yt=e=>crypto.subtle.digest("SHA-256",e),_t=e=>Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join(""),ao=async e=>{let t=await yt(await e.arrayBuffer());return _t(t)},gt=async e=>{let t=await yt(e);return _t(t)};var L=async({wasmModule:e,...t})=>{await sn({wasmModule:e,...t});let r=()=>new Blob([e]).size>2e6?"chunked":"simple";await an({wasmModule:e,...t})},sn=async({actor:e,canisterId:t,wasmModule:r})=>{let{module_hash:n}=await mt({actor:e,canisterId:t}),o=nn(n);if(on(o))return;let i=await gt(r),s=ht(o);if(i===s)throw new me},an=async({actor:e,...t})=>{await dt({actor:e,code:t})};var O={};Gr(O,{Bool:()=>Pt,BoolClass:()=>Te,ConstructType:()=>z,Empty:()=>Nt,EmptyClass:()=>ge,FixedIntClass:()=>X,FixedNatClass:()=>q,Float32:()=>At,Float64:()=>Ot,FloatClass:()=>le,Func:()=>Xt,FuncClass:()=>pe,Int:()=>Rt,Int16:()=>Et,Int32:()=>Mt,Int64:()=>kt,Int8:()=>Ft,IntClass:()=>Ne,Nat:()=>Vt,Nat16:()=>Ut,Nat32:()=>$t,Nat64:()=>qt,Nat8:()=>Bt,NatClass:()=>ve,Null:()=>St,NullClass:()=>we,Opt:()=>Kt,OptClass:()=>ne,PrimitiveType:()=>M,Principal:()=>zt,PrincipalClass:()=>Re,Rec:()=>Jt,RecClass:()=>Q,Record:()=>Wt,RecordClass:()=>ue,Reserved:()=>vt,ReservedClass:()=>re,Service:()=>Zt,ServiceClass:()=>Ve,Text:()=>Ct,TextClass:()=>be,Tuple:()=>jt,TupleClass:()=>Se,Type:()=>te,Unknown:()=>dn,UnknownClass:()=>xe,Variant:()=>Gt,VariantClass:()=>Ce,Vec:()=>Ht,VecClass:()=>Pe,Visitor:()=>_e,decode:()=>pn,encode:()=>un});import{Principal as ln}from"@dfinity/principal";function d(...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 G=class{constructor(t,r=t?.byteLength||0){this._buffer=je(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return je(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 ze(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}function je(e){return e instanceof Uint8Array?ze(e):e instanceof ArrayBuffer?e:Array.isArray(e)?ze(new Uint8Array(e)):"buffer"in e?je(e.buffer):ze(new Uint8Array(e))}function cn(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 cn(e)}function xt(){throw new Error("unexpected end of buffer")}function Y(e,t){return e.byteLength<t&&xt(),e.read(t)}function Z(e){let t=e.readUint8();return t===void 0&&xt(),t}function v(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 G(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=Z(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}function P(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 G(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(Y(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 Tt(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return He(e,t)}function He(e,t){e=BigInt(e);let r=new G(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 Ke(e,t){let r=BigInt(Z(e)),n=BigInt(1),o=0;for(;++o<t;){n*=BigInt(256);let i=BigInt(Z(e));r=r+n*i}return r}function wt(e,t){let r=Ke(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 ye="DIDL",bt=400;function ce(e,t,r){return e.map((n,o)=>r(n,t[o]))}var We=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=v(this._typs.length),r=d(...this._typs);return d(t,r)}indexOf(t){if(!this._idx.has(t))throw new Error("Missing type index for "+t);return P(this._idx.get(t)||0)}},_e=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 N(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}},M=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){}},z=class extends te{checkType(t){if(t instanceof Q){let r=t.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`)}encodeType(t){return t.indexOf(this.name)}},ge=class extends M{accept(t,r){return t.visitEmpty(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${N(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return P(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},xe=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: ${N(t)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(t,r){let n=r.decodeValue(t,r);Object(n)!==n&&(n=Object(n));let o;return r instanceof Q?o=()=>r.getType():o=()=>r,Object.defineProperty(n,"type",{value:o,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}},Te=class extends M{accept(t,r){return t.visitBool(this,r)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${N(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return P(-2)}decodeValue(t,r){switch(this.checkType(r),Z(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 M{accept(t,r){return t.visitNull(this,r)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${N(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return P(-1)}decodeValue(t,r){return this.checkType(r),null}get name(){return"null"}},re=class extends M{accept(t,r){return t.visitReserved(this,r)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return P(-16)}decodeValue(t,r){return r.name!==this.name&&r.decodeValue(t,r),null}get name(){return"reserved"}},be=class extends M{accept(t,r){return t.visitText(this,r)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${N(t)}`)}encodeValue(t){let r=new TextEncoder().encode(t),n=v(r.byteLength);return d(n,r)}encodeType(){return P(-15)}decodeValue(t,r){this.checkType(r);let n=A(t),o=Y(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(o)}get name(){return"text"}valueToString(t){return'"'+t+'"'}},Ne=class extends M{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: ${N(t)}`)}encodeValue(t){return P(t)}encodeType(){return P(-4)}decodeValue(t,r){return this.checkType(r),J(t)}get name(){return"int"}valueToString(t){return t.toString()}},ve=class extends M{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: ${N(t)}`)}encodeValue(t){return v(t)}encodeType(){return P(-3)}decodeValue(t,r){return this.checkType(r),A(t)}get name(){return"nat"}valueToString(t){return t.toString()}},le=class extends M{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: ${N(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 P(t)}decodeValue(t,r){this.checkType(r);let n=Y(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()}},X=class extends M{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: ${N(t)}`)}encodeValue(t){return He(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return P(-9-t)}decodeValue(t,r){this.checkType(r);let n=wt(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}},q=class extends M{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: ${N(t)}`)}encodeValue(t){return Tt(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return P(-5-t)}decodeValue(t,r){this.checkType(r);let n=Ke(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 z{constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof q&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof q?this._type._bits:this._type instanceof X?this._type._bits:0;if(ArrayBuffer.isView(t)&&r==t.BYTES_PER_ELEMENT*8||Array.isArray(t)&&t.every((n,o)=>{try{return this._type.covariant(n)}catch(i){throw new Error(`Invalid ${this.display()} argument:
1
+ var Wr=Object.defineProperty;var Gr=(e,t)=>{for(var r in t)Wr(e,r,{get:t[r],enumerable:!0})};var me=class extends Error{constructor(){super("The Wasm code for the upgrade is identical to the code currently installed. No upgrade is necessary.")}};import{isNullish as Yr}from"@junobuild/utils";var Ie=({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({subnet_id:e.Opt(e.Principal),name:e.Opt(e.Text)}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,satellite_id:e.Principal}),o=e.Record({cycles:e.Nat,destination_id:e.Principal}),i=e.Record({e8s:e.Nat64}),s=e.Record({timestamp_nanos:e.Nat64}),c=e.Record({to:e.Vec(e.Nat8),fee:i,memo:e.Nat64,from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(s),amount:i}),u=e.Variant({TxTooOld:e.Record({allowed_window_nanos:e.Nat64}),BadFee:e.Record({expected_fee:i}),TxDuplicate:e.Record({duplicate_of:e.Nat64}),TxCreatedInFuture:e.Null,InsufficientFunds:e.Record({balance:i})}),l=e.Variant({Ok:e.Nat64,Err:u}),_=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),g=e.Record({to:_,fee:e.Opt(e.Nat),memo:e.Opt(e.Vec(e.Nat8)),from_subaccount:e.Opt(e.Vec(e.Nat8)),created_at_time:e.Opt(e.Nat64),amount:e.Nat}),m=e.Variant({GenericError:e.Record({message:e.Text,error_code:e.Nat}),TemporarilyUnavailable:e.Null,BadBurn:e.Record({min_burn_amount:e.Nat}),Duplicate:e.Record({duplicate_of:e.Nat}),BadFee:e.Record({expected_fee:e.Nat}),CreatedInFuture:e.Record({ledger_time:e.Nat64}),TooOld:e.Null,InsufficientFunds:e.Record({balance:e.Nat})}),a=e.Variant({Ok:e.Nat,Err:m}),p=e.Variant({Write:e.Null,Admin:e.Null}),f=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:p,expires_at:e.Opt(e.Nat64)}),T=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),x=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),h=e.Record({status:T,memory_size:e.Nat,cycles:e.Nat,settings:x,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),w=e.Record({id:e.Principal,status:h,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),status_at:e.Nat64}),y=e.Variant({Ok:w,Err:e.Text}),b=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:p,expires_at:e.Opt(e.Nat64)}),S=e.Record({enabled:e.Bool,cycles_threshold:e.Opt(e.Nat64)}),C=e.Record({mission_control_cycles_threshold:e.Opt(e.Nat64),orbiters:e.Vec(e.Tuple(e.Principal,S)),satellites:e.Vec(e.Tuple(e.Principal,S)),cycles_threshold:e.Opt(e.Nat64)}),R=e.Record({orbiters:e.Opt(e.Vec(y)),satellites:e.Opt(e.Vec(y)),mission_control:y});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_orbiter_with_config:e.Func([r],[t],[]),create_satellite:e.Func([e.Text],[n],[]),create_satellite_with_config:e.Func([r],[n],[]),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([o],[],[]),get_user:e.Func([],[e.Principal],["query"]),icp_transfer:e.Func([c],[l],[]),icrc_transfer:e.Func([e.Principal,g],[a],[]),list_mission_control_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,f))],["query"]),list_mission_control_statuses:e.Func([],[e.Vec(e.Tuple(e.Nat64,y))],["query"]),list_orbiter_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,y)))],["query"]),list_orbiters:e.Func([],[e.Vec(e.Tuple(e.Principal,t))],["query"]),list_satellite_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,y)))],["query"]),list_satellites:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["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),b],[],[]),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),b],[],[]),set_satellite:e.Func([e.Principal,e.Opt(e.Text)],[n],[]),set_satellite_metadata:e.Func([e.Principal,e.Vec(e.Tuple(e.Text,e.Text))],[n],[]),set_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal),b],[],[]),status:e.Func([C],[R],[]),top_up:e.Func([e.Principal,i],[],[]),unset_orbiter:e.Func([e.Principal],[],[]),unset_satellite:e.Func([e.Principal],[],[]),version:e.Func([],[e.Text],["query"])})};var De=({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}),g=e.Record({desktop:e.Float64,others:e.Float64,mobile:e.Float64}),m=e.Record({browsers:_,devices:g}),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))}),T=e.Variant({Navigate:e.Null,Restore:e.Null,Reload:e.Null,BackForward:e.Null,BackForwardCache:e.Null,Prerender:e.Null}),x=e.Record({id:e.Text,value:e.Float64,navigation_type:e.Opt(T),delta:e.Float64}),h=e.Variant({WebVitalsMetric:x}),w=e.Variant({CLS:e.Null,FCP:e.Null,INP:e.Null,LCP:e.Null,TTFB:e.Null}),y=e.Record({updated_at:e.Nat64,session_id:e.Text,data:h,href:e.Text,metric_name:w,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),b=e.Record({cls:e.Opt(e.Float64),fcp:e.Opt(e.Float64),inp:e.Opt(e.Float64),lcp:e.Opt(e.Float64),ttfb:e.Opt(e.Float64)}),S=e.Record({overall:b,pages:e.Vec(e.Tuple(e.Text,b))}),C=e.Record({updated_at:e.Nat64,session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),R=e.Record({total:e.Vec(e.Tuple(e.Text,e.Nat32))}),E=e.Record({performance_metrics:e.Bool,track_events:e.Bool,page_views:e.Bool}),F=e.Record({updated_at:e.Nat64,features:e.Opt(E),created_at:e.Nat64,version:e.Opt(e.Nat64)}),k=e.Record({stable:e.Nat64,heap:e.Nat64}),j=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:r,expires_at:e.Opt(e.Nat64)}),U=e.Record({controller:j,controllers:e.Vec(e.Principal)}),H=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)}),K=e.Variant({Ok:l,Err:e.Text}),W=e.Variant({Ok:e.Null,Err:e.Vec(e.Tuple(c,e.Text))}),$=e.Record({session_id:e.Text,data:h,href:e.Text,metric_name:w,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),Be=e.Variant({Ok:y,Err:e.Text}),Ue=e.Record({features:e.Opt(E),version:e.Opt(e.Nat64)}),de=e.Record({updated_at:e.Opt(e.Nat64),session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),$e=e.Variant({Ok:C,Err:e.Text});return e.Service({del_controllers:e.Func([t],[e.Vec(e.Tuple(e.Principal,n))],[]),del_satellite_config:e.Func([e.Principal,o],[],[]),deposit_cycles:e.Func([i],[],[]),get_page_views:e.Func([s],[e.Vec(e.Tuple(c,l))],["query"]),get_page_views_analytics_clients:e.Func([s],[m],["query"]),get_page_views_analytics_metrics:e.Func([s],[p],["query"]),get_page_views_analytics_top_10:e.Func([s],[f],["query"]),get_performance_metrics:e.Func([s],[e.Vec(e.Tuple(c,y))],["query"]),get_performance_metrics_analytics_web_vitals:e.Func([s],[S],["query"]),get_track_events:e.Func([s],[e.Vec(e.Tuple(c,C))],["query"]),get_track_events_analytics:e.Func([s],[R],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_satellite_configs:e.Func([],[e.Vec(e.Tuple(e.Principal,F))],["query"]),memory_size:e.Func([],[k],["query"]),set_controllers:e.Func([U],[e.Vec(e.Tuple(e.Principal,n))],[]),set_page_view:e.Func([c,H],[K],[]),set_page_views:e.Func([e.Vec(e.Tuple(c,H))],[W],[]),set_performance_metric:e.Func([c,$],[Be],[]),set_performance_metrics:e.Func([e.Vec(e.Tuple(c,$))],[W],[]),set_satellite_configs:e.Func([e.Vec(e.Tuple(e.Principal,Ue))],[e.Vec(e.Tuple(e.Principal,F))],[]),set_track_event:e.Func([c,de],[$e],[]),set_track_events:e.Func([e.Vec(e.Tuple(c,de))],[W],[]),version:e.Func([],[e.Text],["query"])})};var Le=({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([],[],[])})}),g=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(_),status_code:e.Nat16}),m=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}),T=e.Record({field:f,desc:e.Bool}),x=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),h=e.Record({order:e.Opt(T),owner:e.Opt(e.Principal),matcher:e.Opt(e.Text),paginate:e.Opt(x)}),w=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),y=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),b=e.Record({key:w,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,y)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),S=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,b))}),C=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),R=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,c))}),E=e.Variant({Db:e.Null,Storage:e.Null}),F=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),k=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:F,created_at:e.Nat64,write:F}),j=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),U=e.Record({controller:j,controllers:e.Vec(e.Principal)}),H=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:F,write:F}),W=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),$=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],[g],["query"]),http_request_streaming_callback:e.Func([l],[m],["query"]),init_asset_upload:e.Func([a],[p],[]),list_assets:e.Func([e.Opt(e.Text),h],[S],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,C))],["query"]),list_docs:e.Func([e.Text,h],[R],["query"]),list_rules:e.Func([E],[e.Vec(e.Tuple(e.Text,k))],["query"]),set_config:e.Func([s],[],[]),set_controllers:e.Func([U],[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,H],[c],[]),set_rule:e.Func([E,e.Text,K],[],[]),upload_asset_chunk:e.Func([W],[$],[]),version:e.Func([],[e.Text],["query"])})};var et=({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([],[],[])})}),g=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(_),status_code:e.Nat16}),m=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}),T=e.Record({field:f,desc:e.Bool}),x=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),h=e.Record({order:e.Opt(T),matcher:e.Opt(e.Text),paginate:e.Opt(x)}),w=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),y=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),b=e.Record({key:w,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,y)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),S=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,b))}),C=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),R=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,c))}),E=e.Variant({Db:e.Null,Storage:e.Null}),F=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),k=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:F,created_at:e.Nat64,write:F}),j=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),U=e.Record({controller:j,controllers:e.Vec(e.Principal)}),H=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:F,write:F}),W=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),$=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],[g],["query"]),http_request_streaming_callback:e.Func([l],[m],["query"]),init_asset_upload:e.Func([a],[p],[]),list_assets:e.Func([e.Opt(e.Text),h],[S],["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],[R],["query"]),list_rules:e.Func([E],[e.Vec(e.Tuple(e.Text,k))],["query"]),set_config:e.Func([s],[],[]),set_controllers:e.Func([U],[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,H],[c],[]),set_rule:e.Func([E,e.Text,K],[],[]),upload_asset_chunk:e.Func([W],[$],[]),version:e.Func([],[e.Text],["query"])})};var tt=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),n=e.Record({field:r,desc:e.Bool}),o=e.Variant({Equal:e.Nat64,Between:e.Tuple(e.Nat64,e.Nat64),GreaterThan:e.Nat64,LessThan:e.Nat64}),i=e.Record({key:e.Opt(e.Text),updated_at:e.Opt(o),description:e.Opt(e.Text),created_at:e.Opt(o)}),s=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),c=e.Record({order:e.Opt(n),owner:e.Opt(e.Principal),matcher:e.Opt(i),paginate:e.Opt(s)}),u=e.Record({controllers:e.Vec(e.Principal)}),l=e.Variant({Write:e.Null,Admin:e.Null}),_=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:l,expires_at:e.Opt(e.Nat64)}),g=e.Record({version:e.Opt(e.Nat64)}),m=e.Variant({Db:e.Null,Storage:e.Null}),a=e.Record({version:e.Opt(e.Nat64)}),p=e.Record({cycles:e.Nat,destination_id:e.Principal}),f=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,description:e.Opt(e.Text),full_path:e.Text}),T=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),x=e.Record({key:f,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,T)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,version:e.Opt(e.Nat64)}),h=e.Record({derivation_origin:e.Opt(e.Text)}),w=e.Record({internet_identity:e.Opt(h)}),y=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),b=e.Record({max_memory_size:e.Opt(y)}),S=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),C=e.Variant({Deny:e.Null,Allow:e.Null}),R=e.Record({status_code:e.Nat16,location:e.Text}),E=e.Record({iframe:e.Opt(S),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(y),raw_access:e.Opt(C),redirects:e.Opt(e.Vec(e.Tuple(e.Text,R)))}),F=e.Record({db:e.Opt(b),authentication:e.Opt(w),storage:E}),k=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),j=e.Variant({Heap:e.Null,Stable:e.Null}),U=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),H=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),K=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(j),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:U,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(H),write:U}),W=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)}),$=e.Record({memory:j,token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),Be=e.Variant({Callback:e.Record({token:$,callback:e.Func([],[],["query"])})}),Ue=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(Be),status_code:e.Nat16}),de=e.Record({token:e.Opt($),body:e.Vec(e.Nat8)}),$e=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}),Mr=e.Record({batch_id:e.Nat}),kr=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,x)),items_length:e.Nat64}),Br=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),Ur=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,k)),items_length:e.Nat64}),$r=e.Record({stable:e.Nat64,heap:e.Nat64}),qr=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:l,expires_at:e.Opt(e.Nat64)}),zr=e.Record({controller:qr,controllers:e.Vec(e.Principal)}),Qe=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),jr=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(j),max_size:e.Opt(e.Nat),read:U,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(H),write:U}),Hr=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),Kr=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,c],[e.Nat64],["query"]),count_collection_assets:e.Func([e.Text],[e.Nat64],["query"]),count_collection_docs:e.Func([e.Text],[e.Nat64],["query"]),count_docs:e.Func([e.Text,c],[e.Nat64],["query"]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Text],[],[]),del_controllers:e.Func([u],[e.Vec(e.Tuple(e.Principal,_))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,g],[],[]),del_docs:e.Func([e.Text],[],[]),del_filtered_assets:e.Func([e.Text,c],[],[]),del_filtered_docs:e.Func([e.Text,c],[],[]),del_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[],[]),del_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,g))],[],[]),del_rule:e.Func([m,e.Text,a],[],[]),deposit_cycles:e.Func([p],[],[]),get_asset:e.Func([e.Text,e.Text],[e.Opt(x)],["query"]),get_auth_config:e.Func([],[e.Opt(w)],["query"]),get_config:e.Func([],[F],[]),get_db_config:e.Func([],[e.Opt(b)],["query"]),get_doc:e.Func([e.Text,e.Text],[e.Opt(k)],["query"]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(x)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(k)))],["query"]),get_rule:e.Func([m,e.Text],[e.Opt(K)],["query"]),get_storage_config:e.Func([],[E],["query"]),http_request:e.Func([W],[Ue],["query"]),http_request_streaming_callback:e.Func([$],[de],["query"]),init_asset_upload:e.Func([$e],[Mr],[]),list_assets:e.Func([e.Text,c],[kr],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,_))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Br))],["query"]),list_docs:e.Func([e.Text,c],[Ur],["query"]),list_rules:e.Func([m],[e.Vec(e.Tuple(e.Text,K))],["query"]),memory_size:e.Func([],[$r],["query"]),set_auth_config:e.Func([w],[],[]),set_controllers:e.Func([zr],[e.Vec(e.Tuple(e.Principal,_))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_db_config:e.Func([b],[],[]),set_doc:e.Func([e.Text,e.Text,Qe],[k],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,Qe))],[e.Vec(e.Tuple(e.Text,k))],[]),set_rule:e.Func([m,e.Text,jr],[K],[]),set_storage_config:e.Func([E],[],[]),upload_asset_chunk:e.Func([Hr],[Kr],[]),version:e.Func([],[e.Text],["query"])})};import{Actor as Jr,HttpAgent as Xr}from"@dfinity/agent";import{nonNullish as rt}from"@junobuild/utils";var nt=async({canisterId:e,idlFactory:t,config:r,...n})=>{let o=await ie(n);return Jr.createActor(t,{agent:o,canisterId:e,...r??{}})},ie=async({agent:e,...t})=>e??await Zr(t),Zr=async({identity:e,fetch:t,container:r})=>{let n=rt(r)&&r!==!1,o=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io";return await Xr.create({identity:e,host:o,retryTimes:10,...rt(t)&&{fetch:t},shouldFetchRootKey:n})};var ot=({satelliteId:e,...t})=>se({canisterId:e,...t,idlFactory:et}),V=({satelliteId:e,...t})=>se({canisterId:e,...t,idlFactory:tt}),it=({satelliteId:e,...t})=>se({canisterId:e,...t,idlFactory:Le}),ee=({missionControlId:e,...t})=>se({canisterId:e,...t,idlFactory:Ie}),fe=({orbiterId:e,...t})=>se({canisterId:e,...t,idlFactory:De}),se=({canisterId:e,idlFactory:t,...r})=>{if(Yr(e))throw new Error("No canister ID provided.");return nt({canisterId:e,idlFactory:t,...r})};var st=async({missionControl:e})=>(await ee(e)).version(),at=async({missionControl:e})=>(await ee(e)).get_user(),ct=async({missionControl:e})=>(await ee(e)).list_mission_control_controllers(),lt=async({missionControl:e,satelliteIds:t,controllerIds:r,controller:n})=>(await ee(e)).set_satellites_controllers(t,r,n),ut=async({missionControl:e,controllerIds:t,controller:r})=>(await ee(e)).set_mission_control_controllers(t,r);import{Principal as Qr}from"@dfinity/principal";import{nonNullish as Ir,toNullable as Dr}from"@junobuild/utils";var qe=({controllerId:e,profile:t})=>({controllerIds:[Qr.fromText(e)],controller:Lr(t)}),Lr=e=>({metadata:Ir(e)&&e!==""?[["profile",e]]:[],expires_at:Dr(void 0),scope:{Admin:null}});var Yn=({controllerId:e,profile:t,...r})=>lt({...r,...qe({controllerId:e,profile:t})}),Qn=({controllerId:e,profile:t,...r})=>ut({...r,...qe({controllerId:e,profile:t})}),In=e=>ct(e);import{Principal as hn}from"@dfinity/principal";var ae={reinstall:null},D={upgrade:[{skip_pre_upgrade:[!1],wasm_memory_persistence:[{replace:null}]}]};import{fromNullable as on,isNullish as sn}from"@junobuild/utils";import{CanisterStatus as en}from"@dfinity/agent";import{ICManagementCanister as pt}from"@dfinity/ic-management";import{Principal as tn}from"@dfinity/principal";import{assertNonNullish as rn}from"@junobuild/utils";var dt=async({actor:e,code:t})=>{let r=await ie(e),{installCode:n}=pt.create({agent:r});return n(t)};var mt=async({actor:e,canisterId:t})=>{let r=await ie(e),{canisterStatus:n}=pt.create({agent:r});return n(t)},ft=async({canisterId:e,path:t,...r})=>{rn(e,"A canister ID must be provided to request its status.");let n=await ie(r);return(await en.request({canisterId:tn.from(e),agent:n,paths:[{kind:"metadata",key:t,path:t,decodeStrategy:"utf-8"}]})).get(t)};var ht=e=>(e instanceof Uint8Array||(e=Uint8Array.from(e)),e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),""));var yt=e=>crypto.subtle.digest("SHA-256",e),_t=e=>Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join(""),co=async e=>{let t=await yt(await e.arrayBuffer());return _t(t)},gt=async e=>{let t=await yt(e);return _t(t)};var L=async({wasmModule:e,...t})=>{await an({wasmModule:e,...t});let r=()=>new Blob([e]).size>2e6?"chunked":"simple";await cn({wasmModule:e,...t})},an=async({actor:e,canisterId:t,wasmModule:r})=>{let{module_hash:n}=await mt({actor:e,canisterId:t}),o=on(n);if(sn(o))return;let i=await gt(r),s=ht(o);if(i===s)throw new me},cn=async({actor:e,...t})=>{await dt({actor:e,code:t})};var O={};Gr(O,{Bool:()=>Pt,BoolClass:()=>Te,ConstructType:()=>z,Empty:()=>Nt,EmptyClass:()=>ge,FixedIntClass:()=>X,FixedNatClass:()=>q,Float32:()=>At,Float64:()=>Ot,FloatClass:()=>le,Func:()=>Xt,FuncClass:()=>pe,Int:()=>Rt,Int16:()=>Et,Int32:()=>Mt,Int64:()=>kt,Int8:()=>Ft,IntClass:()=>Ne,Nat:()=>Vt,Nat16:()=>Ut,Nat32:()=>$t,Nat64:()=>qt,Nat8:()=>Bt,NatClass:()=>ve,Null:()=>St,NullClass:()=>we,Opt:()=>Kt,OptClass:()=>ne,PrimitiveType:()=>M,Principal:()=>zt,PrincipalClass:()=>Re,Rec:()=>Jt,RecClass:()=>Q,Record:()=>Wt,RecordClass:()=>ue,Reserved:()=>vt,ReservedClass:()=>re,Service:()=>Zt,ServiceClass:()=>Ve,Text:()=>Ct,TextClass:()=>be,Tuple:()=>jt,TupleClass:()=>Se,Type:()=>te,Unknown:()=>mn,UnknownClass:()=>xe,Variant:()=>Gt,VariantClass:()=>Ce,Vec:()=>Ht,VecClass:()=>Pe,Visitor:()=>_e,decode:()=>dn,encode:()=>pn});import{Principal as un}from"@dfinity/principal";function d(...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 G=class{constructor(t,r=t?.byteLength||0){this._buffer=je(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return je(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 ze(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}function je(e){return e instanceof Uint8Array?ze(e):e instanceof ArrayBuffer?e:Array.isArray(e)?ze(new Uint8Array(e)):"buffer"in e?je(e.buffer):ze(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 xt(){throw new Error("unexpected end of buffer")}function Y(e,t){return e.byteLength<t&&xt(),e.read(t)}function Z(e){let t=e.readUint8();return t===void 0&&xt(),t}function v(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 G(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=Z(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}function P(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 G(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(Y(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 Tt(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return He(e,t)}function He(e,t){e=BigInt(e);let r=new G(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 Ke(e,t){let r=BigInt(Z(e)),n=BigInt(1),o=0;for(;++o<t;){n*=BigInt(256);let i=BigInt(Z(e));r=r+n*i}return r}function wt(e,t){let r=Ke(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 ye="DIDL",bt=400;function ce(e,t,r){return e.map((n,o)=>r(n,t[o]))}var We=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=v(this._typs.length),r=d(...this._typs);return d(t,r)}indexOf(t){if(!this._idx.has(t))throw new Error("Missing type index for "+t);return P(this._idx.get(t)||0)}},_e=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 N(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}},M=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){}},z=class extends te{checkType(t){if(t instanceof Q){let r=t.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`)}encodeType(t){return t.indexOf(this.name)}},ge=class extends M{accept(t,r){return t.visitEmpty(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${N(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return P(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},xe=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: ${N(t)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(t,r){let n=r.decodeValue(t,r);Object(n)!==n&&(n=Object(n));let o;return r instanceof Q?o=()=>r.getType():o=()=>r,Object.defineProperty(n,"type",{value:o,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}},Te=class extends M{accept(t,r){return t.visitBool(this,r)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${N(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return P(-2)}decodeValue(t,r){switch(this.checkType(r),Z(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 M{accept(t,r){return t.visitNull(this,r)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${N(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return P(-1)}decodeValue(t,r){return this.checkType(r),null}get name(){return"null"}},re=class extends M{accept(t,r){return t.visitReserved(this,r)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return P(-16)}decodeValue(t,r){return r.name!==this.name&&r.decodeValue(t,r),null}get name(){return"reserved"}},be=class extends M{accept(t,r){return t.visitText(this,r)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${N(t)}`)}encodeValue(t){let r=new TextEncoder().encode(t),n=v(r.byteLength);return d(n,r)}encodeType(){return P(-15)}decodeValue(t,r){this.checkType(r);let n=A(t),o=Y(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(o)}get name(){return"text"}valueToString(t){return'"'+t+'"'}},Ne=class extends M{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: ${N(t)}`)}encodeValue(t){return P(t)}encodeType(){return P(-4)}decodeValue(t,r){return this.checkType(r),J(t)}get name(){return"int"}valueToString(t){return t.toString()}},ve=class extends M{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: ${N(t)}`)}encodeValue(t){return v(t)}encodeType(){return P(-3)}decodeValue(t,r){return this.checkType(r),A(t)}get name(){return"nat"}valueToString(t){return t.toString()}},le=class extends M{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: ${N(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 P(t)}decodeValue(t,r){this.checkType(r);let n=Y(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()}},X=class extends M{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: ${N(t)}`)}encodeValue(t){return He(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return P(-9-t)}decodeValue(t,r){this.checkType(r);let n=wt(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}},q=class extends M{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: ${N(t)}`)}encodeValue(t){return Tt(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return P(-5-t)}decodeValue(t,r){this.checkType(r);let n=Ke(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 z{constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof q&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof q?this._type._bits:this._type instanceof X?this._type._bits:0;if(ArrayBuffer.isView(t)&&r==t.BYTES_PER_ELEMENT*8||Array.isArray(t)&&t.every((n,o)=>{try{return this._type.covariant(n)}catch(i){throw new Error(`Invalid ${this.display()} argument:
2
2
 
3
3
  index ${o} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${N(t)}`)}encodeValue(t){let r=v(t.length);if(this._blobOptimization)return d(r,new Uint8Array(t));if(ArrayBuffer.isView(t))return d(r,new Uint8Array(t.buffer));let n=new G(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=P(-19),n=this._type.encodeType(t);t.add(this,d(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 q){if(this._type._bits==8)return new Uint8Array(t.read(o));if(this._type._bits==16)return new Uint16Array(t.read(o*2));if(this._type._bits==32)return new Uint32Array(t.read(o*4));if(this._type._bits==64)return new BigUint64Array(t.read(o*8))}if(this._type instanceof X){if(this._type._bits==8)return new Int8Array(t.read(o));if(this._type._bits==16)return new Int16Array(t.read(o*2));if(this._type._bits==32)return new Int32Array(t.read(o*4));if(this._type._bits==64)return new BigInt64Array(t.read(o*8))}let i=[];for(let 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 z{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: ${N(t)}
4
4
 
@@ -8,7 +8,7 @@ field ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display
8
8
 
9
9
  index ${n} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${N(t)}`)}encodeValue(t){let r=ce(this._components,t,(n,o)=>n.encodeValue(o));return d(...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 {${ce(this._components,t,(n,o)=>n.valueToString(o)).join("; ")}}`}},Ce=class e extends z{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:
10
10
 
11
- variant ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${N(t)}`)}encodeValue(t){for(let r=0;r<this._fields.length;r++){let[n,o]=this._fields[r];if(t.hasOwnProperty(n)){let i=v(r),s=o.encodeValue(t[n]);return d(i,s)}}throw Error("Variant has no data: "+t)}_buildTypeTableImpl(t){this._fields.forEach(([,i])=>{i.buildTypeTable(t)});let r=P(-21),n=v(this._fields.length),o=this._fields.map(([i,s])=>d(v(B(i)),s.encodeType(t)));t.add(this,d(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)}},Q=class e extends z{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: ${N(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)}};Q._counter=0;function Ge(e){if(Z(e)!==1)throw new Error("Cannot decode principal");let r=Number(A(e));return ln.fromUint8Array(new Uint8Array(Y(e,r)))}var Re=class extends M{accept(t,r){return t.visitPrincipal(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${N(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=v(r.byteLength);return d(new Uint8Array([1]),n,r)}encodeType(){return P(-24)}decodeValue(t,r){return this.checkType(r),Ge(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}},pe=class extends z{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: ${N(t)}`)}encodeValue([t,r]){let n=t.toUint8Array(),o=v(n.byteLength),i=d(new Uint8Array([1]),o,n),s=new TextEncoder().encode(r),c=v(s.byteLength);return d(new Uint8Array([1]),i,c,s)}_buildTypeTableImpl(t){this.argTypes.forEach(l=>l.buildTypeTable(t)),this.retTypes.forEach(l=>l.buildTypeTable(t));let r=P(-22),n=v(this.argTypes.length),o=d(...this.argTypes.map(l=>l.encodeType(t))),i=v(this.retTypes.length),s=d(...this.retTypes.map(l=>l.encodeType(t))),c=v(this.annotations.length),u=d(...this.annotations.map(l=>this.encodeAnnotation(l)));t.add(this,d(r,n,o,i,s,c,u))}decodeValue(t){if(Z(t)!==1)throw new Error("Cannot decode function reference");let n=Ge(t),o=Number(A(t)),i=Y(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")}},Ve=class extends z{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: ${N(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=v(r.length);return d(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([i,s])=>s.buildTypeTable(t));let r=P(-23),n=v(this._fields.length),o=this._fields.map(([i,s])=>{let c=new TextEncoder().encode(i),u=v(c.length);return d(u,c,s.encodeType(t))});t.add(this,d(r,n,...o))}decodeValue(t){return Ge(t)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(t){return`service "${t.toText()}"`}};function N(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>bt?t.substring(0,bt-3)+"...":t}function un(e,t){if(t.length<e.length)throw Error("Wrong number of message arguments");let r=new We;e.forEach(u=>u.buildTypeTable(r));let n=new TextEncoder().encode(ye),o=r.encode(),i=v(t.length),s=d(...e.map(u=>u.encodeType(r))),c=d(...ce(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: ${N(t)}`)}encodeValue(t){for(let r=0;r<this._fields.length;r++){let[n,o]=this._fields[r];if(t.hasOwnProperty(n)){let i=v(r),s=o.encodeValue(t[n]);return d(i,s)}}throw Error("Variant has no data: "+t)}_buildTypeTableImpl(t){this._fields.forEach(([,i])=>{i.buildTypeTable(t)});let r=P(-21),n=v(this._fields.length),o=this._fields.map(([i,s])=>d(v(B(i)),s.encodeType(t)));t.add(this,d(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)}},Q=class e extends z{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: ${N(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)}};Q._counter=0;function Ge(e){if(Z(e)!==1)throw new Error("Cannot decode principal");let r=Number(A(e));return un.fromUint8Array(new Uint8Array(Y(e,r)))}var Re=class extends M{accept(t,r){return t.visitPrincipal(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${N(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=v(r.byteLength);return d(new Uint8Array([1]),n,r)}encodeType(){return P(-24)}decodeValue(t,r){return this.checkType(r),Ge(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}},pe=class extends z{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: ${N(t)}`)}encodeValue([t,r]){let n=t.toUint8Array(),o=v(n.byteLength),i=d(new Uint8Array([1]),o,n),s=new TextEncoder().encode(r),c=v(s.byteLength);return d(new Uint8Array([1]),i,c,s)}_buildTypeTableImpl(t){this.argTypes.forEach(l=>l.buildTypeTable(t)),this.retTypes.forEach(l=>l.buildTypeTable(t));let r=P(-22),n=v(this.argTypes.length),o=d(...this.argTypes.map(l=>l.encodeType(t))),i=v(this.retTypes.length),s=d(...this.retTypes.map(l=>l.encodeType(t))),c=v(this.annotations.length),u=d(...this.annotations.map(l=>this.encodeAnnotation(l)));t.add(this,d(r,n,o,i,s,c,u))}decodeValue(t){if(Z(t)!==1)throw new Error("Cannot decode function reference");let n=Ge(t),o=Number(A(t)),i=Y(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")}},Ve=class extends z{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: ${N(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=v(r.length);return d(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([i,s])=>s.buildTypeTable(t));let r=P(-23),n=v(this._fields.length),o=this._fields.map(([i,s])=>{let c=new TextEncoder().encode(i),u=v(c.length);return d(u,c,s.encodeType(t))});t.add(this,d(r,n,...o))}decodeValue(t){return Ge(t)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(t){return`service "${t.toText()}"`}};function N(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>bt?t.substring(0,bt-3)+"...":t}function pn(e,t){if(t.length<e.length)throw Error("Wrong number of message arguments");let r=new We;e.forEach(u=>u.buildTypeTable(r));let n=new TextEncoder().encode(ye),o=r.encode(),i=v(t.length),s=d(...e.map(u=>u.encodeType(r))),c=d(...ce(e,t,(u,l)=>{try{u.covariant(l)}catch(_){throw new Error(_.message+`
12
12
 
13
- `)}return u.encodeValue(l)}));return d(n,o,i,s,c)}function pn(e,t){let r=new G(t);if(t.byteLength<ye.length)throw new Error("Message length smaller than magic number");let n=Y(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 h=0;h<f;h++){let w=Number(J(a));switch(w){case-18:case-19:{let y=Number(J(a));p.push([w,y]);break}case-20:case-21:{let y=[],b=Number(A(a)),S;for(;b--;){let C=Number(A(a));if(C>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof S=="number"&&S>=C)throw new Error("field id collision or not sorted");S=C;let R=Number(J(a));y.push([C,R])}p.push([w,y]);break}case-22:{let y=[],b=Number(A(a));for(;b--;)y.push(Number(J(a)));let S=[],C=Number(A(a));for(;C--;)S.push(Number(J(a)));let R=[],E=Number(A(a));for(;E--;)switch(Number(A(a))){case 1:{R.push("query");break}case 2:{R.push("oneway");break}case 3:{R.push("composite_query");break}default:throw new Error("unknown annotation")}p.push([w,[y,S,R]]);break}case-23:{let y=Number(A(a)),b=[];for(;y--;){let S=Number(A(a)),C=new TextDecoder().decode(Y(a,S)),R=J(a);b.push([C,R])}p.push([w,b]);break}default:throw new Error("Illegal op_code: "+w)}}let T=[],x=Number(A(a));for(let h=0;h<x;h++)T.push(Number(J(a)));return[p,T]}let[s,c]=i(r);if(c.length<e.length)throw new Error("Wrong number of return values");let u=s.map(a=>Jt());function l(a){if(a<-24)throw new Error("future value not supported");if(a<0)switch(a){case-1:return St;case-2:return Pt;case-3:return Vt;case-4:return Rt;case-5:return Bt;case-6:return Ut;case-7:return $t;case-8:return qt;case-9:return Ft;case-10:return Et;case-11:return Mt;case-12:return kt;case-13:return At;case-14:return Ot;case-15:return Ct;case-16:return vt;case-17:return Nt;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 Ht(p)}case-18:{let p=l(a[1]);return Kt(p)}case-20:{let p={};for(let[x,h]of a[1]){let w=`_${x}_`;p[w]=l(h)}let f=Wt(p),T=f.tryAsTuple();return Array.isArray(T)?jt(...T):f}case-21:{let p={};for(let[f,T]of a[1]){let x=`_${f}_`;p[x]=l(T)}return Gt(p)}case-22:{let[p,f,T]=a[1];return Xt(p.map(x=>l(x)),f.map(x=>l(x)),T)}case-23:{let p={},f=a[1];for(let[T,x]of f){let h=l(x);if(h instanceof Q&&(h=h.getType()),!(h instanceof pe))throw new Error("Illegal service definition: services can only contain functions");p[T]=h}return Zt(p)}default:throw new Error("Illegal op_code: "+a[0])}}s.forEach((a,p)=>{if(a[0]===-22){let f=_(a);u[p].fill(f)}}),s.forEach((a,p)=>{if(a[0]!==-22){let f=_(a);u[p].fill(f)}});let g=c.map(a=>l(a)),m=e.map((a,p)=>a.decodeValue(r,g[p]));for(let a=e.length;a<g.length;a++)g[a].decodeValue(r,g[a]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return m}var Nt=new ge,vt=new re,dn=new xe,Pt=new Te,St=new we,Ct=new be,Rt=new Ne,Vt=new ve,At=new le(32),Ot=new le(64),Ft=new X(8),Et=new X(16),Mt=new X(32),kt=new X(64),Bt=new q(8),Ut=new q(16),$t=new q(32),qt=new q(64),zt=new Re;function jt(...e){return new Se(e)}function Ht(e){return new Pe(e)}function Kt(e){return new ne(e)}function Wt(e){return new ue(e)}function Gt(e){return new Ce(e)}function Jt(){return new Q}function Xt(e,t,r=[]){return new pe(e,t,r)}function Zt(e){return new Ve(e)}import{Principal as Mo}from"@dfinity/principal";var Yt=e=>O.encode([O.Record({user:O.Principal})],[{user:e}]),Ae=e=>O.encode([O.Record({controllers:O.Vec(O.Principal)})],[{controllers:e.map(([t,r])=>t)}]);var Qo=async({missionControl:e,wasmModule:t,preClearChunks:r})=>{let n=await at({missionControl:e}),{missionControlId:o,...i}=e;if(!o)throw new Error("No mission control principal defined.");let s=Yt(n);await L({actor:i,canisterId:fn.fromText(o),arg:new Uint8Array(s),wasmModule:t,mode:D,preClearChunks:r})};var Lo=e=>st(e);var Qt=async({orbiter:e})=>(await fe(e)).version(),Oe=async({orbiter:e})=>(await fe(e)).list_controllers(),It=async({orbiter:e})=>{let{memory_size:t}=await fe(e);return t()};var oi=e=>Oe(e);var ai=e=>It(e);import{Principal as hn}from"@dfinity/principal";var fi=async({orbiter:e,missionControlId:t,wasmModule:r,reset:n=!1,preClearChunks:o})=>{let{orbiterId:i,...s}=e;if(!i)throw new Error("No orbiter principal defined.");let c=await Oe({orbiter:e}),u=Ae(c);await L({actor:s,canisterId:hn.fromText(i),missionControlId:t,arg:new Uint8Array(u),wasmModule:r,mode:n?ae:D,preClearChunks:o})};var _i=e=>Qt(e);import{major as Dt,minor as Lt,patch as er}from"semver";var Ti=({currentVersion:e,selectedVersion:t})=>{let r=Dt(e),n=Dt(t),o=Lt(e),i=Lt(t),s=er(e),c=er(t);return r<n-1||o<i-1||s<c-1?{canUpgrade:!1}:{canUpgrade:!0}};import{toNullable as yn}from"@junobuild/utils";var tr=async({config:e,satellite:t})=>{let{set_storage_config:r}=await V(t);return r(e)},rr=async({config:e,satellite:t})=>{let{set_db_config:r}=await V(t);return r(e)},nr=async({config:e,satellite:t})=>{let{set_auth_config:r}=await V(t);return r(e)};var or=async({satellite:e})=>{let{get_auth_config:t}=await V(e);return t()},ir=async({satellite:e,type:t})=>(await V(e)).list_rules(t),sr=async({type:e,collection:t,rule:r,satellite:n})=>{let{set_rule:o}=await V(n);return o(e,t,r)},ar=async({satellite:e})=>{let{version:t}=await V(e);return t()},cr=async({satellite:e})=>{let{build_version:t}=await V(e);return t()},lr=async({satellite:e})=>(await ot(e)).list_controllers(),Fe=async({satellite:e})=>(await it(e)).list_controllers(),Ee=async({satellite:e})=>(await V(e)).list_controllers(),ur=async({satellite:e})=>{let{list_custom_domains:t}=await V(e);return t()},pr=async({satellite:e,domainName:t,boundaryNodesId:r})=>{let{set_custom_domain:n}=await V(e);await n(t,yn(r))},dr=async({satellite:e})=>{let{memory_size:t}=await V(e);return t()},mr=async({collection:e,satellite:t})=>{let{count_collection_docs:r}=await V(t);return r(e)},fr=async({collection:e,satellite:t})=>{let{count_collection_assets:r}=await V(t);return r(e)},hr=async({collection:e,satellite:t})=>{let{del_docs:r}=await V(t);return r(e)},yr=async({collection:e,satellite:t})=>{let{del_assets:r}=await V(t);return r(e)},_r=async({args:e,satellite:t})=>{let{set_controllers:r}=await V(t);return r(e)};var Si=e=>fr(e),Ci=e=>yr(e);import{fromNullable as Me,isNullish as xr,nonNullish as gr}from"@junobuild/utils";import{nonNullish as _n,toNullable as Je}from"@junobuild/utils";var Xe=e=>Je(_n(e)?{heap:Je(e.heap),stable:Je(e.stable)}:void 0);var Mi=async({config:{headers:e,rewrites:t,redirects:r,iframe:n,rawAccess:o,maxMemorySize:i},satellite:s})=>{let c=(e??[]).map(({source:m,headers:a})=>[m,a]),u=(t??[]).map(({source:m,destination:a})=>[m,a]),l=(r??[]).map(({source:m,location:a,code:p})=>[m,{status_code:p,location:a}]);return await tr({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:Xe(i)}})},ki=async({config:{maxMemorySize:e},...t})=>{await rr({config:{max_memory_size:Xe(e)},...t})},Bi=async({config:{internetIdentity:e},...t})=>{await nr({config:{internet_identity:xr(e?.derivationOrigin)?[]:[{derivation_origin:[e.derivationOrigin]}]},...t})},Ui=async({satellite:e})=>{let t=Me(await or({satellite:e}));if(xr(t))return;let r=Me(t.internet_identity??[]);return{...gr(r)&&{internetIdentity:{...gr(Me(r.derivation_origin))&&{derivationOrigin:Me(r.derivation_origin)}}}}};var zi=({deprecatedNoScope:e,...t})=>(e===!0?Fe:Ee)(t),ji=e=>_r(e);var Wi=e=>mr(e),Gi=e=>hr(e);import{fromNullable as Tr,nonNullish as gn}from"@junobuild/utils";var Yi=async({satellite:e})=>(await ur({satellite:e})).map(([r,n])=>{let o=Tr(n.version);return{domain:r,bn_id:Tr(n.bn_id),created_at:n.created_at,updated_at:n.updated_at,...gn(o)&&{version:o}}}),Qi=({satellite:e,domains:t})=>Promise.all(t.map(({domain:r,bn_id:n})=>pr({satellite:e,domainName:r,boundaryNodesId:n})));var Li=e=>dr(e);import{fromNullable as oe,nonNullish as I,toNullable as ke}from"@junobuild/utils";var wr={Db:null},br={Storage:null},Nr={Public:null},vr={Private:null},Pr={Managed:null},Sr={Controllers:null},Ze={Heap:null},Cr={Stable:null},Rr=600000000n;var Ye=e=>e==="storage"?br:wr,Or=({read:e,write:t,memory:r,maxSize:n,maxCapacity:o,version:i,mutablePermissions:s,maxTokens:c})=>({read:Ar(e),write:Ar(t),memory:I(r)?[xn(r)]:[],version:ke(i),max_size:ke(I(n)&&n>0?BigInt(n):void 0),max_capacity:ke(I(o)&&o>0?o:void 0),mutable_permissions:ke(s),rate_config:I(c)?[{max_tokens:BigInt(c),time_per_token_ns:Rr}]:[]}),Fr=([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:_,rate_config:g}=t,m=s?.[0]??0n>0n?Number(oe(s)):void 0,a=c?.[0]??!1?oe(c):void 0,p=oe(_),f=g?.[0]?.max_tokens??0n>0n?oe(g)?.max_tokens:void 0;return{collection:e,read:Vr(r),write:Vr(n),memory:Tn(oe(u)??Ze),updatedAt:o,createdAt:i,...I(p)&&{version:p},...I(m)&&{maxSize:m},...I(a)&&{maxCapacity:a},mutablePermissions:oe(l)??!0,...I(f)&&{maxTokens:Number(f)}}},Vr=e=>"Public"in e?"public":"Private"in e?"private":"Managed"in e?"managed":"controllers",Ar=e=>{switch(e){case"public":return Nr;case"private":return vr;case"managed":return Pr;default:return Sr}},xn=e=>{switch(e.toLowerCase()){case"heap":return Ze;default:return Cr}},Tn=e=>"Heap"in e?"heap":"stable";var as=async({type:e,satellite:t})=>(await ir({satellite:t,type:Ye(e)})).map(n=>Fr(n)),cs=async({rule:{collection:e,...t},type:r,satellite:n})=>{await sr({type:Ye(r),rule:Or(t),satellite:n,collection:e})};import{Principal as Er}from"@dfinity/principal";import{isNullish as wn}from"@junobuild/utils";var _s=async({satellite:e,missionControlId:t,wasmModule:r,deprecated:n,deprecatedNoScope:o,reset:i=!1,preClearChunks:s})=>{let{satelliteId:c,...u}=e;if(wn(c))throw new Error("No satellite principal defined.");if(n){let m=await lr({satellite:e}),a=O.encode([O.Record({controllers:O.Vec(O.Principal)})],[{controllers:m}]);await L({actor:u,canisterId:Er.fromText(c),missionControlId:t,arg:new Uint8Array(a),wasmModule:r,mode:i?ae:D,preClearChunks:s});return}let _=await(o?Fe:Ee)({satellite:e}),g=Ae(_);await L({actor:u,canisterId:Er.fromText(c),missionControlId:t,arg:new Uint8Array(g),wasmModule:r,mode:i?ae:D,preClearChunks:s})};import{nonNullish as bn}from"@junobuild/utils";var bs=e=>ar(e),Ns=e=>cr(e),vs=async({satellite:{satelliteId:e,...t}})=>{let r=await ft({...t,canisterId:e,path:"juno:build"});return bn(r)&&["stock","extended"].includes(r)?r:void 0};export{me as UpgradeCodeUnchangedError,ao as blobSha256,Ti as checkUpgradeVersion,Si as countAssets,Wi as countDocs,Ci as deleteAssets,Gi as deleteDocs,Ui as getAuthConfig,Yi as listCustomDomains,Qn as listMissionControlControllers,oi as listOrbiterControllers,as as listRules,zi as listSatelliteControllers,Lo as missionControlVersion,ai as orbiterMemorySize,_i as orbiterVersion,vs as satelliteBuildType,Ns as satelliteBuildVersion,Li as satelliteMemorySize,bs as satelliteVersion,Bi as setAuthConfig,Qi as setCustomDomains,ki as setDatastoreConfig,Yn as setMissionControlController,cs as setRule,ji as setSatelliteControllers,Zn as setSatellitesController,Mi as setStorageConfig,gt as uint8ArraySha256,Qo as upgradeMissionControl,fi as upgradeOrbiter,_s as upgradeSatellite};
13
+ `)}return u.encodeValue(l)}));return d(n,o,i,s,c)}function dn(e,t){let r=new G(t);if(t.byteLength<ye.length)throw new Error("Message length smaller than magic number");let n=Y(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 h=0;h<f;h++){let w=Number(J(a));switch(w){case-18:case-19:{let y=Number(J(a));p.push([w,y]);break}case-20:case-21:{let y=[],b=Number(A(a)),S;for(;b--;){let C=Number(A(a));if(C>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof S=="number"&&S>=C)throw new Error("field id collision or not sorted");S=C;let R=Number(J(a));y.push([C,R])}p.push([w,y]);break}case-22:{let y=[],b=Number(A(a));for(;b--;)y.push(Number(J(a)));let S=[],C=Number(A(a));for(;C--;)S.push(Number(J(a)));let R=[],E=Number(A(a));for(;E--;)switch(Number(A(a))){case 1:{R.push("query");break}case 2:{R.push("oneway");break}case 3:{R.push("composite_query");break}default:throw new Error("unknown annotation")}p.push([w,[y,S,R]]);break}case-23:{let y=Number(A(a)),b=[];for(;y--;){let S=Number(A(a)),C=new TextDecoder().decode(Y(a,S)),R=J(a);b.push([C,R])}p.push([w,b]);break}default:throw new Error("Illegal op_code: "+w)}}let T=[],x=Number(A(a));for(let h=0;h<x;h++)T.push(Number(J(a)));return[p,T]}let[s,c]=i(r);if(c.length<e.length)throw new Error("Wrong number of return values");let u=s.map(a=>Jt());function l(a){if(a<-24)throw new Error("future value not supported");if(a<0)switch(a){case-1:return St;case-2:return Pt;case-3:return Vt;case-4:return Rt;case-5:return Bt;case-6:return Ut;case-7:return $t;case-8:return qt;case-9:return Ft;case-10:return Et;case-11:return Mt;case-12:return kt;case-13:return At;case-14:return Ot;case-15:return Ct;case-16:return vt;case-17:return Nt;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 Ht(p)}case-18:{let p=l(a[1]);return Kt(p)}case-20:{let p={};for(let[x,h]of a[1]){let w=`_${x}_`;p[w]=l(h)}let f=Wt(p),T=f.tryAsTuple();return Array.isArray(T)?jt(...T):f}case-21:{let p={};for(let[f,T]of a[1]){let x=`_${f}_`;p[x]=l(T)}return Gt(p)}case-22:{let[p,f,T]=a[1];return Xt(p.map(x=>l(x)),f.map(x=>l(x)),T)}case-23:{let p={},f=a[1];for(let[T,x]of f){let h=l(x);if(h instanceof Q&&(h=h.getType()),!(h instanceof pe))throw new Error("Illegal service definition: services can only contain functions");p[T]=h}return Zt(p)}default:throw new Error("Illegal op_code: "+a[0])}}s.forEach((a,p)=>{if(a[0]===-22){let f=_(a);u[p].fill(f)}}),s.forEach((a,p)=>{if(a[0]!==-22){let f=_(a);u[p].fill(f)}});let g=c.map(a=>l(a)),m=e.map((a,p)=>a.decodeValue(r,g[p]));for(let a=e.length;a<g.length;a++)g[a].decodeValue(r,g[a]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return m}var Nt=new ge,vt=new re,mn=new xe,Pt=new Te,St=new we,Ct=new be,Rt=new Ne,Vt=new ve,At=new le(32),Ot=new le(64),Ft=new X(8),Et=new X(16),Mt=new X(32),kt=new X(64),Bt=new q(8),Ut=new q(16),$t=new q(32),qt=new q(64),zt=new Re;function jt(...e){return new Se(e)}function Ht(e){return new Pe(e)}function Kt(e){return new ne(e)}function Wt(e){return new ue(e)}function Gt(e){return new Ce(e)}function Jt(){return new Q}function Xt(e,t,r=[]){return new pe(e,t,r)}function Zt(e){return new Ve(e)}import{Principal as ko}from"@dfinity/principal";var Yt=e=>O.encode([O.Record({user:O.Principal})],[{user:e}]),Ae=e=>O.encode([O.Record({controllers:O.Vec(O.Principal)})],[{controllers:e.map(([t,r])=>t)}]);var Io=async({missionControl:e,wasmModule:t,preClearChunks:r})=>{let n=await at({missionControl:e}),{missionControlId:o,...i}=e;if(!o)throw new Error("No mission control principal defined.");let s=Yt(n);await L({actor:i,canisterId:hn.fromText(o),arg:new Uint8Array(s),wasmModule:t,mode:D,preClearChunks:r})};var ei=e=>st(e);var Qt=async({orbiter:e})=>(await fe(e)).version(),Oe=async({orbiter:e})=>(await fe(e)).list_controllers(),It=async({orbiter:e})=>{let{memory_size:t}=await fe(e);return t()};var ii=e=>Oe(e);var ci=e=>It(e);import{Principal as yn}from"@dfinity/principal";var hi=async({orbiter:e,missionControlId:t,wasmModule:r,reset:n=!1,preClearChunks:o})=>{let{orbiterId:i,...s}=e;if(!i)throw new Error("No orbiter principal defined.");let c=await Oe({orbiter:e}),u=Ae(c);await L({actor:s,canisterId:yn.fromText(i),missionControlId:t,arg:new Uint8Array(u),wasmModule:r,mode:n?ae:D,preClearChunks:o})};var gi=e=>Qt(e);import{major as Dt,minor as Lt,patch as er}from"semver";var wi=({currentVersion:e,selectedVersion:t})=>{let r=Dt(e),n=Dt(t),o=Lt(e),i=Lt(t),s=er(e),c=er(t);return r<n-1||o<i-1||s<c-1?{canUpgrade:!1}:{canUpgrade:!0}};import{toNullable as _n}from"@junobuild/utils";var tr=async({config:e,satellite:t})=>{let{set_storage_config:r}=await V(t);return r(e)},rr=async({config:e,satellite:t})=>{let{set_db_config:r}=await V(t);return r(e)},nr=async({config:e,satellite:t})=>{let{set_auth_config:r}=await V(t);return r(e)};var or=async({satellite:e})=>{let{get_auth_config:t}=await V(e);return t()},ir=async({satellite:e,type:t})=>(await V(e)).list_rules(t),sr=async({type:e,collection:t,rule:r,satellite:n})=>{let{set_rule:o}=await V(n);return o(e,t,r)},ar=async({satellite:e})=>{let{version:t}=await V(e);return t()},cr=async({satellite:e})=>{let{build_version:t}=await V(e);return t()},lr=async({satellite:e})=>(await ot(e)).list_controllers(),Fe=async({satellite:e})=>(await it(e)).list_controllers(),Ee=async({satellite:e})=>(await V(e)).list_controllers(),ur=async({satellite:e})=>{let{list_custom_domains:t}=await V(e);return t()},pr=async({satellite:e,domainName:t,boundaryNodesId:r})=>{let{set_custom_domain:n}=await V(e);await n(t,_n(r))},dr=async({satellite:e})=>{let{memory_size:t}=await V(e);return t()},mr=async({collection:e,satellite:t})=>{let{count_collection_docs:r}=await V(t);return r(e)},fr=async({collection:e,satellite:t})=>{let{count_collection_assets:r}=await V(t);return r(e)},hr=async({collection:e,satellite:t})=>{let{del_docs:r}=await V(t);return r(e)},yr=async({collection:e,satellite:t})=>{let{del_assets:r}=await V(t);return r(e)},_r=async({args:e,satellite:t})=>{let{set_controllers:r}=await V(t);return r(e)};var Ci=e=>fr(e),Ri=e=>yr(e);import{fromNullable as Me,isNullish as xr,nonNullish as gr}from"@junobuild/utils";import{nonNullish as gn,toNullable as Je}from"@junobuild/utils";var Xe=e=>Je(gn(e)?{heap:Je(e.heap),stable:Je(e.stable)}:void 0);var ki=async({config:{headers:e,rewrites:t,redirects:r,iframe:n,rawAccess:o,maxMemorySize:i},satellite:s})=>{let c=(e??[]).map(({source:m,headers:a})=>[m,a]),u=(t??[]).map(({source:m,destination:a})=>[m,a]),l=(r??[]).map(({source:m,location:a,code:p})=>[m,{status_code:p,location:a}]);return await tr({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:Xe(i)}})},Bi=async({config:{maxMemorySize:e},...t})=>{await rr({config:{max_memory_size:Xe(e)},...t})},Ui=async({config:{internetIdentity:e},...t})=>{await nr({config:{internet_identity:xr(e?.derivationOrigin)?[]:[{derivation_origin:[e.derivationOrigin]}]},...t})},$i=async({satellite:e})=>{let t=Me(await or({satellite:e}));if(xr(t))return;let r=Me(t.internet_identity??[]);return{...gr(r)&&{internetIdentity:{...gr(Me(r.derivation_origin))&&{derivationOrigin:Me(r.derivation_origin)}}}}};var ji=({deprecatedNoScope:e,...t})=>(e===!0?Fe:Ee)(t),Hi=e=>_r(e);var Gi=e=>mr(e),Ji=e=>hr(e);import{fromNullable as Tr,nonNullish as xn}from"@junobuild/utils";var Qi=async({satellite:e})=>(await ur({satellite:e})).map(([r,n])=>{let o=Tr(n.version);return{domain:r,bn_id:Tr(n.bn_id),created_at:n.created_at,updated_at:n.updated_at,...xn(o)&&{version:o}}}),Ii=({satellite:e,domains:t})=>Promise.all(t.map(({domain:r,bn_id:n})=>pr({satellite:e,domainName:r,boundaryNodesId:n})));var es=e=>dr(e);import{fromNullable as oe,nonNullish as I,toNullable as ke}from"@junobuild/utils";var wr={Db:null},br={Storage:null},Nr={Public:null},vr={Private:null},Pr={Managed:null},Sr={Controllers:null},Ze={Heap:null},Cr={Stable:null},Rr=600000000n;var Ye=e=>e==="storage"?br:wr,Or=({read:e,write:t,memory:r,maxSize:n,maxCapacity:o,version:i,mutablePermissions:s,maxTokens:c})=>({read:Ar(e),write:Ar(t),memory:I(r)?[Tn(r)]:[],version:ke(i),max_size:ke(I(n)&&n>0?BigInt(n):void 0),max_capacity:ke(I(o)&&o>0?o:void 0),mutable_permissions:ke(s),rate_config:I(c)?[{max_tokens:BigInt(c),time_per_token_ns:Rr}]:[]}),Fr=([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:_,rate_config:g}=t,m=s?.[0]??0n>0n?Number(oe(s)):void 0,a=c?.[0]??!1?oe(c):void 0,p=oe(_),f=g?.[0]?.max_tokens??0n>0n?oe(g)?.max_tokens:void 0;return{collection:e,read:Vr(r),write:Vr(n),memory:wn(oe(u)??Ze),updatedAt:o,createdAt:i,...I(p)&&{version:p},...I(m)&&{maxSize:m},...I(a)&&{maxCapacity:a},mutablePermissions:oe(l)??!0,...I(f)&&{maxTokens:Number(f)}}},Vr=e=>"Public"in e?"public":"Private"in e?"private":"Managed"in e?"managed":"controllers",Ar=e=>{switch(e){case"public":return Nr;case"private":return vr;case"managed":return Pr;default:return Sr}},Tn=e=>{switch(e.toLowerCase()){case"heap":return Ze;default:return Cr}},wn=e=>"Heap"in e?"heap":"stable";var cs=async({type:e,satellite:t})=>(await ir({satellite:t,type:Ye(e)})).map(n=>Fr(n)),ls=async({rule:{collection:e,...t},type:r,satellite:n})=>{await sr({type:Ye(r),rule:Or(t),satellite:n,collection:e})};import{Principal as Er}from"@dfinity/principal";import{isNullish as bn}from"@junobuild/utils";var gs=async({satellite:e,missionControlId:t,wasmModule:r,deprecated:n,deprecatedNoScope:o,reset:i=!1,preClearChunks:s})=>{let{satelliteId:c,...u}=e;if(bn(c))throw new Error("No satellite principal defined.");if(n){let m=await lr({satellite:e}),a=O.encode([O.Record({controllers:O.Vec(O.Principal)})],[{controllers:m}]);await L({actor:u,canisterId:Er.fromText(c),missionControlId:t,arg:new Uint8Array(a),wasmModule:r,mode:i?ae:D,preClearChunks:s});return}let _=await(o?Fe:Ee)({satellite:e}),g=Ae(_);await L({actor:u,canisterId:Er.fromText(c),missionControlId:t,arg:new Uint8Array(g),wasmModule:r,mode:i?ae:D,preClearChunks:s})};import{nonNullish as Nn}from"@junobuild/utils";var Ns=e=>ar(e),vs=e=>cr(e),Ps=async({satellite:{satelliteId:e,...t}})=>{let r=await ft({...t,canisterId:e,path:"juno:build"});return Nn(r)&&["stock","extended"].includes(r)?r:void 0};export{me as UpgradeCodeUnchangedError,co as blobSha256,wi as checkUpgradeVersion,Ci as countAssets,Gi as countDocs,Ri as deleteAssets,Ji as deleteDocs,$i as getAuthConfig,Qi as listCustomDomains,In as listMissionControlControllers,ii as listOrbiterControllers,cs as listRules,ji as listSatelliteControllers,ei as missionControlVersion,ci as orbiterMemorySize,gi as orbiterVersion,Ps as satelliteBuildType,vs as satelliteBuildVersion,es as satelliteMemorySize,Ns as satelliteVersion,Ui as setAuthConfig,Ii as setCustomDomains,Bi as setDatastoreConfig,Qn as setMissionControlController,ls as setRule,Hi as setSatelliteControllers,Yn as setSatellitesController,ki as setStorageConfig,gt as uint8ArraySha256,Io as upgradeMissionControl,hi as upgradeOrbiter,gs as upgradeSatellite};
14
14
  //# sourceMappingURL=index.js.map