@junobuild/admin 0.0.60 → 0.0.61-next-2024-12-20

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,14 +1,2 @@
1
- var rn=Object.defineProperty;var nn=(e,t)=>{for(var r in t)rn(e,r,{get:t[r],enumerable:!0})};var fe=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 cn}from"@junobuild/utils";var rt=({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}),f=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),m=e.Record({to:f,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}),d=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:d}),p=e.Variant({Write:e.Null,Admin:e.Null}),y=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}),_=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:_,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),status_at:e.Nat64}),g=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)}),v=e.Record({enabled:e.Bool,cycles_threshold:e.Opt(e.Nat64)}),S=e.Record({mission_control_cycles_threshold:e.Opt(e.Nat64),orbiters:e.Vec(e.Tuple(e.Principal,v)),satellites:e.Vec(e.Tuple(e.Principal,v)),cycles_threshold:e.Opt(e.Nat64)}),R=e.Record({orbiters:e.Opt(e.Vec(g)),satellites:e.Opt(e.Vec(g)),mission_control:g});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,m],[a],[]),list_mission_control_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,y))],["query"]),list_mission_control_statuses:e.Func([],[e.Vec(e.Tuple(e.Nat64,g))],["query"]),list_orbiter_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,g)))],["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,g)))],["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([S],[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 nt=({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)}),f=e.Record({safari:e.Float64,opera:e.Float64,others:e.Float64,firefox:e.Float64,chrome:e.Float64}),m=e.Record({desktop:e.Float64,others:e.Float64,mobile:e.Float64}),d=e.Record({browsers:f,devices:m}),a=e.Record({day:e.Nat8,month:e.Nat8,year:e.Int32}),p=e.Record({bounce_rate:e.Float64,average_page_views_per_session:e.Float64,daily_total_page_views:e.Vec(e.Tuple(a,e.Nat32)),total_page_views:e.Nat32,unique_page_views:e.Nat64,unique_sessions:e.Nat64}),y=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}),_=e.Variant({WebVitalsMetric:x}),w=e.Variant({CLS:e.Null,FCP:e.Null,INP:e.Null,LCP:e.Null,TTFB:e.Null}),g=e.Record({updated_at:e.Nat64,session_id:e.Text,data:_,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)}),v=e.Record({overall:b,pages:e.Vec(e.Tuple(e.Text,b))}),S=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)}),U=e.Record({stable:e.Nat64,heap:e.Nat64}),H=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:r,expires_at:e.Opt(e.Nat64)}),$=e.Record({controller:H,controllers:e.Vec(e.Principal)}),K=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)}),W=e.Variant({Ok:l,Err:e.Text}),G=e.Variant({Ok:e.Null,Err:e.Vec(e.Tuple(c,e.Text))}),q=e.Record({session_id:e.Text,data:_,href:e.Text,metric_name:w,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),je=e.Variant({Ok:g,Err:e.Text}),He=e.Record({features:e.Opt(E),version:e.Opt(e.Nat64)}),me=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)}),Ke=e.Variant({Ok:S,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],[d],["query"]),get_page_views_analytics_metrics:e.Func([s],[p],["query"]),get_page_views_analytics_top_10:e.Func([s],[y],["query"]),get_performance_metrics:e.Func([s],[e.Vec(e.Tuple(c,g))],["query"]),get_performance_metrics_analytics_web_vitals:e.Func([s],[v],["query"]),get_track_events:e.Func([s],[e.Vec(e.Tuple(c,S))],["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([],[U],["query"]),set_controllers:e.Func([$],[e.Vec(e.Tuple(e.Principal,n))],[]),set_page_view:e.Func([c,K],[W],[]),set_page_views:e.Func([e.Vec(e.Tuple(c,K))],[G],[]),set_performance_metric:e.Func([c,q],[je],[]),set_performance_metrics:e.Func([e.Vec(e.Tuple(c,q))],[G],[]),set_satellite_configs:e.Func([e.Vec(e.Tuple(e.Principal,He))],[e.Vec(e.Tuple(e.Principal,F))],[]),set_track_event:e.Func([c,me],[Ke],[]),set_track_events:e.Func([e.Vec(e.Tuple(c,me))],[G],[]),version:e.Func([],[e.Text],["query"])})};var ot=({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}),f=e.Variant({Callback:e.Record({token:l,callback:e.Func([],[],[])})}),m=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(f),status_code:e.Nat16}),d=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}),y=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),T=e.Record({field:y,desc:e.Bool}),x=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),_=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}),g=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,g)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),v=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,b))}),S=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}),U=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:F,created_at:e.Nat64,write:F}),H=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),$=e.Record({controller:H,controllers:e.Vec(e.Principal)}),K=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),W=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:F,write:F}),G=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),q=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_controllers:e.Func([r],[e.Vec(e.Tuple(e.Principal,n))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,o],[],[]),get_config:e.Func([],[s],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(c)],["query"]),http_request:e.Func([u],[m],["query"]),http_request_streaming_callback:e.Func([l],[d],["query"]),init_asset_upload:e.Func([a],[p],[]),list_assets:e.Func([e.Opt(e.Text),_],[v],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,S))],["query"]),list_docs:e.Func([e.Text,_],[R],["query"]),list_rules:e.Func([E],[e.Vec(e.Tuple(e.Text,U))],["query"]),set_config:e.Func([s],[],[]),set_controllers:e.Func([$],[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,K],[c],[]),set_rule:e.Func([E,e.Text,W],[],[]),upload_asset_chunk:e.Func([G],[q],[]),version:e.Func([],[e.Text],["query"])})};var it=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.Record({controllers:e.Vec(e.Principal)}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,expires_at:e.Opt(e.Nat64)}),o=e.Record({updated_at:e.Opt(e.Nat64)}),i=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),s=e.Record({storage:i}),c=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),u=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),l=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),f=e.Variant({Callback:e.Record({token:l,callback:e.Func([],[],[])})}),m=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(f),status_code:e.Nat16}),d=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}),y=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),T=e.Record({field:y,desc:e.Bool}),x=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),_=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}),g=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,g)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),v=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,b))}),S=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}),U=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:F,created_at:e.Nat64,write:F}),H=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),$=e.Record({controller:H,controllers:e.Vec(e.Principal)}),K=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),W=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:F,write:F}),G=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),q=e.Record({chunk_id:e.Nat});return e.Service({commit_asset_upload:e.Func([t],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_controllers:e.Func([r],[e.Vec(e.Tuple(e.Principal,n))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,o],[],[]),get_config:e.Func([],[s],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(c)],["query"]),http_request:e.Func([u],[m],["query"]),http_request_streaming_callback:e.Func([l],[d],["query"]),init_asset_upload:e.Func([a],[p],[]),list_assets:e.Func([e.Opt(e.Text),_],[v],["query"]),list_controllers:e.Func([],[e.Vec(e.Principal)],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,S))],["query"]),list_docs:e.Func([e.Text,_],[R],["query"]),list_rules:e.Func([E],[e.Vec(e.Tuple(e.Text,U))],["query"]),set_config:e.Func([s],[],[]),set_controllers:e.Func([$],[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,K],[c],[]),set_rule:e.Func([E,e.Text,W],[],[]),upload_asset_chunk:e.Func([G],[q],[]),version:e.Func([],[e.Text],["query"])})};var st=({IDL:e})=>{let t=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),r=e.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}),f=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)}),m=e.Record({version:e.Opt(e.Nat64)}),d=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}),y=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:y,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)}),_=e.Record({derivation_origin:e.Opt(e.Text)}),w=e.Record({internet_identity:e.Opt(_)}),g=e.Record({stable:e.Opt(e.Nat64),heap:e.Opt(e.Nat64)}),b=e.Record({max_memory_size:e.Opt(g)}),v=e.Variant({Deny:e.Null,AllowAny:e.Null,SameOrigin:e.Null}),S=e.Variant({Deny:e.Null,Allow:e.Null}),R=e.Record({status_code:e.Nat16,location:e.Text}),E=e.Record({iframe:e.Opt(v),rewrites:e.Vec(e.Tuple(e.Text,e.Text)),headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text)))),max_memory_size:e.Opt(g),raw_access:e.Opt(S),redirects:e.Opt(e.Vec(e.Tuple(e.Text,R)))}),F=e.Record({db:e.Opt(b),authentication:e.Opt(w),storage:E}),U=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64,version:e.Opt(e.Nat64)}),H=e.Variant({Heap:e.Null,Stable:e.Null}),$=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),K=e.Record({max_tokens:e.Nat64,time_per_token_ns:e.Nat64}),W=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(H),updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:$,created_at:e.Nat64,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(K),write:$}),G=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)}),q=e.Record({memory:H,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}),je=e.Variant({Callback:e.Record({token:q,callback:e.Func([],[],["query"])})}),He=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(je),status_code:e.Nat16}),me=e.Record({token:e.Opt(q),body:e.Vec(e.Nat8)}),Ke=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}),Xr=e.Record({batch_id:e.Nat}),Zr=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}),Jr=e.Record({updated_at:e.Nat64,created_at:e.Nat64,version:e.Opt(e.Nat64),bn_id:e.Opt(e.Text)}),Yr=e.Record({matches_pages:e.Opt(e.Nat64),matches_length:e.Nat64,items_page:e.Opt(e.Nat64),items:e.Vec(e.Tuple(e.Text,U)),items_length:e.Nat64}),Qr=e.Record({stable:e.Nat64,heap:e.Nat64}),Ir=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:l,expires_at:e.Opt(e.Nat64)}),Dr=e.Record({controller:Ir,controllers:e.Vec(e.Principal)}),tt=e.Record({data:e.Vec(e.Nat8),description:e.Opt(e.Text),version:e.Opt(e.Nat64)}),Lr=e.Record({max_capacity:e.Opt(e.Nat32),memory:e.Opt(H),max_size:e.Opt(e.Nat),read:$,version:e.Opt(e.Nat64),mutable_permissions:e.Opt(e.Bool),rate_config:e.Opt(K),write:$}),en=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat,order_id:e.Opt(e.Nat)}),tn=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,f))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,m],[],[]),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,m))],[],[]),del_rule:e.Func([d,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(U)],["query"]),get_many_assets:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(x)))],["query"]),get_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text))],[e.Vec(e.Tuple(e.Text,e.Opt(U)))],["query"]),get_rule:e.Func([d,e.Text],[e.Opt(W)],["query"]),get_storage_config:e.Func([],[E],["query"]),http_request:e.Func([G],[He],["query"]),http_request_streaming_callback:e.Func([q],[me],["query"]),init_asset_upload:e.Func([Ke],[Xr],[]),list_assets:e.Func([e.Text,c],[Zr],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,f))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Jr))],["query"]),list_docs:e.Func([e.Text,c],[Yr],["query"]),list_rules:e.Func([d],[e.Vec(e.Tuple(e.Text,W))],["query"]),memory_size:e.Func([],[Qr],["query"]),set_auth_config:e.Func([w],[],[]),set_controllers:e.Func([Dr],[e.Vec(e.Tuple(e.Principal,f))],[]),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,tt],[U],[]),set_many_docs:e.Func([e.Vec(e.Tuple(e.Text,e.Text,tt))],[e.Vec(e.Tuple(e.Text,U))],[]),set_rule:e.Func([d,e.Text,Lr],[W],[]),set_storage_config:e.Func([E],[],[]),upload_asset_chunk:e.Func([en],[tn],[]),version:e.Func([],[e.Text],["query"])})};import{Actor as on,HttpAgent as sn}from"@dfinity/agent";import{nonNullish as at}from"@junobuild/utils";var ct=async({canisterId:e,idlFactory:t,config:r,...n})=>{let o=await M(n);return on.createActor(t,{agent:o,canisterId:e,...r??{}})},M=async({agent:e,...t})=>e??await an(t),an=async({identity:e,fetch:t,container:r})=>{let n=at(r)&&r!==!1,o=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io";return await sn.create({identity:e,host:o,retryTimes:10,...at(t)&&{fetch:t},shouldFetchRootKey:n})};var lt=({satelliteId:e,...t})=>ae({canisterId:e,...t,idlFactory:it}),A=({satelliteId:e,...t})=>ae({canisterId:e,...t,idlFactory:st}),ut=({satelliteId:e,...t})=>ae({canisterId:e,...t,idlFactory:ot}),re=({missionControlId:e,...t})=>ae({canisterId:e,...t,idlFactory:rt}),he=({orbiterId:e,...t})=>ae({canisterId:e,...t,idlFactory:nt}),ae=({canisterId:e,idlFactory:t,...r})=>{if(cn(e))throw new Error("No canister ID provided.");return ct({canisterId:e,idlFactory:t,...r})};var pt=async({missionControl:e})=>(await re(e)).version(),dt=async({missionControl:e})=>(await re(e)).get_user(),mt=async({missionControl:e})=>(await re(e)).list_mission_control_controllers(),ft=async({missionControl:e,satelliteIds:t,controllerIds:r,controller:n})=>(await re(e)).set_satellites_controllers(t,r,n),ht=async({missionControl:e,controllerIds:t,controller:r})=>(await re(e)).set_mission_control_controllers(t,r);import{Principal as ln}from"@dfinity/principal";import{nonNullish as un,toNullable as pn}from"@junobuild/utils";var We=({controllerId:e,profile:t})=>({controllerIds:[ln.fromText(e)],controller:dn(t)}),dn=e=>({metadata:un(e)&&e!==""?[["profile",e]]:[],expires_at:pn(void 0),scope:{Admin:null}});var fo=({controllerId:e,profile:t,...r})=>ft({...r,...We({controllerId:e,profile:t})}),ho=({controllerId:e,profile:t,...r})=>ht({...r,...We({controllerId:e,profile:t})}),yo=e=>mt(e);import{Principal as En}from"@dfinity/principal";var ce={reinstall:null},te={upgrade:[{skip_pre_upgrade:[!1],wasm_memory_persistence:[{replace:null}]}]};import{fromNullable as Pn,isNullish as Cn}from"@junobuild/utils";import{CanisterStatus as mn}from"@dfinity/agent";import{ICManagementCanister as Q}from"@dfinity/ic-management";import{Principal as fn}from"@dfinity/principal";import{assertNonNullish as hn}from"@junobuild/utils";var yt=async({canisterId:e,actor:t})=>{let r=await M(t),{stopCanister:n}=Q.create({agent:r});await n(e)},_t=async({canisterId:e,actor:t})=>{let r=await M(t),{startCanister:n}=Q.create({agent:r});await n(e)},gt=async({actor:e,code:t})=>{let r=await M(e),{installCode:n}=Q.create({agent:r});return n(t)},xt=async({actor:e,canisterId:t})=>{let r=await M(e),{storedChunks:n}=Q.create({agent:r});return n({canisterId:t})},ye=async({actor:e,canisterId:t})=>{let r=await M(e),{clearChunkStore:n}=Q.create({agent:r});return n({canisterId:t})},Tt=async({actor:e,chunk:t})=>{let r=await M(e),{uploadChunk:n}=Q.create({agent:r});return n(t)},wt=async({actor:e,code:t})=>{let r=await M(e),{installChunkedCode:n}=Q.create({agent:r});return n(t)},bt=async({actor:e,canisterId:t})=>{let r=await M(e),{canisterStatus:n}=Q.create({agent:r});return n(t)},Pt=async({canisterId:e,path:t,...r})=>{hn(e,"A canister ID must be provided to request its status.");let n=await M(r);return(await mn.request({canisterId:fn.from(e),agent:n,paths:[{kind:"metadata",key:t,path:t,decodeStrategy:"utf-8"}]})).get(t)};var Ct=(o=>(o[o.AssertingExistingCode=0]="AssertingExistingCode",o[o.StoppingCanister=1]="StoppingCanister",o[o.UpgradingCode=2]="UpgradingCode",o[o.RestartingCanister=3]="RestartingCanister",o))(Ct||{});var _e=e=>(e instanceof Uint8Array||(e=Uint8Array.from(e)),e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),""));var Nt=e=>crypto.subtle.digest("SHA-256",e),vt=e=>Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join(""),St=async e=>{let t=await Nt(await e.arrayBuffer());return vt(t)},ge=async e=>{let t=await Nt(e);return vt(t)};import{isNullish as _n,nonNullish as Rt}from"@junobuild/utils";var At=async({actor:e,canisterId:t,missionControlId:r,wasmModule:n,preClearChunks:o,...i})=>{o&&await ye({actor:e,canisterId:t});let s=await gn({wasmModule:n}),{uploadChunks:c,storedChunks:u,preClearChunks:l,postClearChunks:f}=await xn({actor:e,wasmChunks:s,canisterId:t,missionControlId:r});l&&await ye({actor:e,canisterId:t});let m=[];for await(let d of Tn({uploadChunks:c,actor:e,canisterId:t,missionControlId:r}))m=[...m,...d];await wt({actor:e,code:{...i,chunkHashesList:[...m,...u].sort(({orderId:d},{orderId:a})=>d-a).map(({chunkHash:d})=>d),targetCanisterId:t,storeCanisterId:r,wasmModuleHash:await ge(n)}}),f&&await ye({actor:e,canisterId:t})},gn=async({wasmModule:e})=>{let t=new Blob([e]),r=[],n=1e6,o=0;for(let i=0;i<t.size;i+=n){let s=t.slice(i,i+n);r.push({chunk:s,orderId:o,sha256:await St(s)}),o++}return r},xn=async({canisterId:e,missionControlId:t,actor:r,wasmChunks:n})=>{let o=await xt({actor:r,canisterId:t??e}),i=o.map(({hash:u})=>({chunkHash:{hash:u},sha256:_e(u)})),{storedChunks:s,uploadChunks:c}=n.reduce(({uploadChunks:u,storedChunks:l},{sha256:f,...m})=>{let d=i.find(({sha256:a})=>a===f);return{uploadChunks:[...u,...Rt(d)?[]:[{sha256:f,...m}]],storedChunks:[...l,...Rt(d)?[{...m,...d}]:[]]}},{uploadChunks:[],storedChunks:[]});return{uploadChunks:c,storedChunks:s,preClearChunks:o.length>0&&s.length===0,postClearChunks:_n(t)}};async function*Tn({uploadChunks:e,limit:t=12,...r}){for(let n=0;n<e.length;n=n+t){let o=e.slice(n,n+t);yield await Promise.all(o.map(s=>wn({uploadChunk:s,...r})))}}var wn=async({actor:e,canisterId:t,missionControlId:r,uploadChunk:{chunk:n,...o}})=>({chunkHash:await Tt({actor:e,chunk:{canisterId:r??t,chunk:new Uint8Array(await n.arrayBuffer())}}),...o});var Vt=async({actor:e,...t})=>{await gt({actor:e,code:t})};var X=async({wasmModule:e,canisterId:t,actor:r,onProgress:n,...o})=>{await xe({fn:async()=>await Nn({wasmModule:e,canisterId:t,actor:r,...o}),onProgress:n,step:0}),await xe({fn:async()=>await yt({canisterId:t,actor:r}),onProgress:n,step:1});try{await xe({fn:async()=>await vn({wasmModule:e,canisterId:t,actor:r,...o}),onProgress:n,step:2})}finally{await xe({fn:async()=>await _t({canisterId:t,actor:r}),onProgress:n,step:3})}},xe=async({fn:e,step:t,onProgress:r})=>{r?.({step:t,state:"in_progress"});try{await e(),r?.({step:t,state:"success"})}catch(n){throw r?.({step:t,state:"error"}),n}},Nn=async({actor:e,canisterId:t,wasmModule:r,reset:n})=>{if(n===!0)return;let{module_hash:o}=await bt({actor:e,canisterId:t}),i=Pn(o);if(Cn(i))return;let s=await ge(r),c=_e(i);if(s===c)throw new fe},vn=async({wasmModule:e,canisterId:t,actor:r,...n})=>{await((new Blob([e]).size>2e6?"chunked":"single")==="chunked"?At:Vt)({wasmModule:e,canisterId:t,actor:r,...n})};var O={};nn(O,{Bool:()=>Bt,BoolClass:()=>Ne,ConstructType:()=>j,Empty:()=>Ut,EmptyClass:()=>Pe,FixedIntClass:()=>Y,FixedNatClass:()=>z,Float32:()=>Ht,Float64:()=>Kt,FloatClass:()=>ue,Func:()=>ir,FuncClass:()=>de,Int:()=>zt,Int16:()=>Gt,Int32:()=>Xt,Int64:()=>Zt,Int8:()=>Wt,IntClass:()=>Re,Nat:()=>jt,Nat16:()=>Yt,Nat32:()=>Qt,Nat64:()=>It,Nat8:()=>Jt,NatClass:()=>Ae,Null:()=>$t,NullClass:()=>ve,Opt:()=>tr,OptClass:()=>ie,PrimitiveType:()=>k,Principal:()=>Dt,PrincipalClass:()=>Ee,Rec:()=>or,RecClass:()=>L,Record:()=>rr,RecordClass:()=>pe,Reserved:()=>Mt,ReservedClass:()=>oe,Service:()=>sr,ServiceClass:()=>ke,Text:()=>qt,TextClass:()=>Se,Tuple:()=>Lt,TupleClass:()=>Oe,Type:()=>ne,Unknown:()=>On,UnknownClass:()=>Ce,Variant:()=>nr,VariantClass:()=>Fe,Vec:()=>er,VecClass:()=>Ve,Visitor:()=>be,decode:()=>Vn,encode:()=>An});import{Principal as Rn}from"@dfinity/principal";function h(...e){let t=new Uint8Array(e.reduce((n,o)=>n+o.byteLength,0)),r=0;for(let n of e)t.set(new Uint8Array(n),r),r+=n.byteLength;return t}var Z=class{constructor(t,r=t?.byteLength||0){this._buffer=Xe(t||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return Xe(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 Ge(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}function Xe(e){return e instanceof Uint8Array?Ge(e):e instanceof ArrayBuffer?e:Array.isArray(e)?Ge(new Uint8Array(e)):"buffer"in e?Xe(e.buffer):Ge(new Uint8Array(e))}function Sn(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 Sn(e)}function Ot(){throw new Error("unexpected end of buffer")}function D(e,t){return e.byteLength<t&&Ot(),e.read(t)}function I(e){let t=e.readUint8();return t===void 0&&Ot(),t}function C(e){if(typeof e=="number"&&(e=BigInt(e)),e<BigInt(0))throw new Error("Cannot leb encode negative values.");let t=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,r=new Z(new ArrayBuffer(t),0);for(;;){let n=Number(e&BigInt(127));if(e/=BigInt(128),e===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}function V(e){let t=BigInt(1),r=BigInt(0),n;do n=I(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}function N(e){typeof e=="number"&&(e=BigInt(e));let t=e<BigInt(0);t&&(e=-e-BigInt(1));let r=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,n=new Z(new ArrayBuffer(r),0);for(;;){let i=o(e);if(e/=BigInt(128),t&&e===BigInt(0)&&i&64||!t&&e===BigInt(0)&&!(i&64)){n.write(new Uint8Array([i]));break}else n.write(new Uint8Array([i|128]))}function o(i){let s=i%BigInt(128);return Number(t?BigInt(128)-s-BigInt(1):s)}return n.buffer}function J(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if(!(t[r]&64))return V(e);break}let n=new Uint8Array(D(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 Ft(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return Ze(e,t)}function Ze(e,t){e=BigInt(e);let r=new Z(new ArrayBuffer(Math.min(1,t)),0),n=0,o=BigInt(256),i=BigInt(0),s=Number(e%o);for(r.write(new Uint8Array([s]));++n<t;)e<0&&i===BigInt(0)&&s!==0&&(i=BigInt(1)),s=Number((e/o-i)%BigInt(256)),r.write(new Uint8Array([s])),o*=BigInt(256);return r.buffer}function Je(e,t){let r=BigInt(I(e)),n=BigInt(1),o=0;for(;++o<t;){n*=BigInt(256);let i=BigInt(I(e));r=r+n*i}return r}function Et(e,t){let r=Je(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}function Te(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}var we="DIDL",kt=400;function le(e,t,r){return e.map((n,o)=>r(n,t[o]))}var Ye=class{constructor(){this._typs=[],this._idx=new Map}has(t){return this._idx.has(t.name)}add(t,r){let n=this._typs.length;this._idx.set(t.name,n),this._typs.push(r)}merge(t,r){let n=this._idx.get(t.name),o=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+t);if(o===void 0)throw new Error("Missing type index for "+r);this._typs[n]=this._typs[o],this._typs.splice(o,1),this._idx.delete(r)}encode(){let t=C(this._typs.length),r=h(...this._typs);return h(t,r)}indexOf(t){if(!this._idx.has(t))throw new Error("Missing type index for "+t);return N(this._idx.get(t)||0)}},be=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)}},ne=class{display(){return this.name}valueToString(t){return P(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}},k=class extends ne{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){}},j=class extends ne{checkType(t){if(t instanceof L){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)}},Pe=class extends k{accept(t,r){return t.visitEmpty(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return N(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},Ce=class extends ne{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: ${P(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 L?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"}},Ne=class extends k{accept(t,r){return t.visitBool(this,r)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return N(-2)}decodeValue(t,r){switch(this.checkType(r),I(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},ve=class extends k{accept(t,r){return t.visitNull(this,r)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return N(-1)}decodeValue(t,r){return this.checkType(r),null}get name(){return"null"}},oe=class extends k{accept(t,r){return t.visitReserved(this,r)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return N(-16)}decodeValue(t,r){return r.name!==this.name&&r.decodeValue(t,r),null}get name(){return"reserved"}},Se=class extends k{accept(t,r){return t.visitText(this,r)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){let r=new TextEncoder().encode(t),n=C(r.byteLength);return h(n,r)}encodeType(){return N(-15)}decodeValue(t,r){this.checkType(r);let n=V(t),o=D(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(o)}get name(){return"text"}valueToString(t){return'"'+t+'"'}},Re=class extends k{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: ${P(t)}`)}encodeValue(t){return N(t)}encodeType(){return N(-4)}decodeValue(t,r){return this.checkType(r),J(t)}get name(){return"int"}valueToString(t){return t.toString()}},Ae=class extends k{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: ${P(t)}`)}encodeValue(t){return C(t)}encodeType(){return N(-3)}decodeValue(t,r){return this.checkType(r),V(t)}get name(){return"nat"}valueToString(t){return t.toString()}},ue=class extends k{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: ${P(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 N(t)}decodeValue(t,r){this.checkType(r);let n=D(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()}},Y=class extends k{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedInt(this,r)}covariant(t){let r=Te(this._bits-1)*BigInt(-1),n=Te(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: ${P(t)}`)}encodeValue(t){return Ze(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return N(-9-t)}decodeValue(t,r){this.checkType(r);let n=Et(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}},z=class extends k{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedNat(this,r)}covariant(t){let r=Te(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: ${P(t)}`)}encodeValue(t){return Ft(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return N(-5-t)}decodeValue(t,r){this.checkType(r);let n=Je(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}},Ve=class e extends j{constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof z&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof z?this._type._bits:this._type instanceof Y?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
-
3
- index ${o} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){let r=C(t.length);if(this._blobOptimization)return h(r,new Uint8Array(t));if(ArrayBuffer.isView(t))return h(r,new Uint8Array(t.buffer));let n=new Z(new ArrayBuffer(r.byteLength+t.length),0);n.write(r);for(let o of t){let i=this._type.encodeValue(o);n.write(new Uint8Array(i))}return n.buffer}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=N(-19),n=this._type.encodeType(t);t.add(this,h(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a vector type");let o=Number(V(t));if(this._type instanceof z){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 Y){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("; ")+"}"}},ie=class e extends j{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: ${P(t)}
4
-
5
- -> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){return t.length===0?new Uint8Array([0]):h(new Uint8Array([1]),this._type.encodeValue(t[0]))}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=N(-18),n=this._type.encodeType(t);t.add(this,h(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not an option type");switch(I(t)){case 0:return[];case 1:return[this._type.decodeValue(t,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(t){return t.length===0?"null":`opt ${this._type.valueToString(t[0])}`}},pe=class e extends j{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>B(r[0])-B(n[0]))}accept(t,r){return t.visitRecord(this,this._fields,r)}tryAsTuple(){let t=[];for(let r=0;r<this._fields.length;r++){let[n,o]=this._fields[r];if(n!==`_${r}_`)return null;t.push(o)}return t}covariant(t){if(typeof t=="object"&&this._fields.every(([r,n])=>{if(!t.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(t[r])}catch(o){throw new Error(`Invalid ${this.display()} argument:
6
-
7
- field ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){let r=this._fields.map(([o])=>t[o]),n=le(this._fields,r,([,o],i)=>o.encodeValue(i));return h(...n)}_buildTypeTableImpl(t){this._fields.forEach(([i,s])=>s.buildTypeTable(t));let r=N(-20),n=C(this._fields.length),o=this._fields.map(([i,s])=>h(C(B(i)),s.encodeType(t)));t.add(this,h(r,n,h(...o)))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a record type");let o={},i=0,s=0;for(;s<n._fields.length;){let[c,u]=n._fields[s];if(i>=this._fields.length){u.decodeValue(t,u),s++;continue}let[l,f]=this._fields[i],m=B(this._fields[i][0]),d=B(c);if(m===d)o[l]=f.decodeValue(t,u),i++,s++;else if(d>m)if(f instanceof ie||f instanceof oe)o[l]=[],i++;else throw new Error("Cannot find required field "+l);else u.decodeValue(t,u),s++}for(let[c,u]of this._fields.slice(i))if(u instanceof ie||u instanceof oe)o[c]=[];else throw new Error("Cannot find required field "+c);return o}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(t){let r=this._fields.map(([o])=>t[o]);return`record {${le(this._fields,r,([o,i],s)=>o+"="+i.valueToString(s)).join("; ")}}`}},Oe=class e extends pe{constructor(t){let r={};t.forEach((n,o)=>r["_"+o+"_"]=n),super(r),this._components=t}accept(t,r){return t.visitTuple(this,this._components,r)}covariant(t){if(Array.isArray(t)&&t.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(t[n])}catch(o){throw new Error(`Invalid ${this.display()} argument:
8
-
9
- index ${n} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){let r=le(this._components,t,(n,o)=>n.encodeValue(o));return h(...r)}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let o=[];for(let[i,s]of n._components.entries())i>=this._components.length?s.decodeValue(t,s):o.push(this._components[i].decodeValue(t,s));return o}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(t){return`record {${le(this._components,t,(n,o)=>n.valueToString(o)).join("; ")}}`}},Fe=class e extends j{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
-
11
- variant ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){for(let r=0;r<this._fields.length;r++){let[n,o]=this._fields[r];if(t.hasOwnProperty(n)){let i=C(r),s=o.encodeValue(t[n]);return h(i,s)}}throw Error("Variant has no data: "+t)}_buildTypeTableImpl(t){this._fields.forEach(([,i])=>{i.buildTypeTable(t)});let r=N(-21),n=C(this._fields.length),o=this._fields.map(([i,s])=>h(C(B(i)),s.encodeType(t)));t.add(this,h(r,n,...o))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a variant type");let o=Number(V(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)}},L=class e extends j{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: ${P(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)}};L._counter=0;function Qe(e){if(I(e)!==1)throw new Error("Cannot decode principal");let r=Number(V(e));return Rn.fromUint8Array(new Uint8Array(D(e,r)))}var Ee=class extends k{accept(t,r){return t.visitPrincipal(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${P(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=C(r.byteLength);return h(new Uint8Array([1]),n,r)}encodeType(){return N(-24)}decodeValue(t,r){return this.checkType(r),Qe(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}},de=class extends j{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: ${P(t)}`)}encodeValue([t,r]){let n=t.toUint8Array(),o=C(n.byteLength),i=h(new Uint8Array([1]),o,n),s=new TextEncoder().encode(r),c=C(s.byteLength);return h(new Uint8Array([1]),i,c,s)}_buildTypeTableImpl(t){this.argTypes.forEach(l=>l.buildTypeTable(t)),this.retTypes.forEach(l=>l.buildTypeTable(t));let r=N(-22),n=C(this.argTypes.length),o=h(...this.argTypes.map(l=>l.encodeType(t))),i=C(this.retTypes.length),s=h(...this.retTypes.map(l=>l.encodeType(t))),c=C(this.annotations.length),u=h(...this.annotations.map(l=>this.encodeAnnotation(l)));t.add(this,h(r,n,o,i,s,c,u))}decodeValue(t){if(I(t)!==1)throw new Error("Cannot decode function reference");let n=Qe(t),o=Number(V(t)),i=D(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")}},ke=class extends j{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: ${P(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=C(r.length);return h(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([i,s])=>s.buildTypeTable(t));let r=N(-23),n=C(this._fields.length),o=this._fields.map(([i,s])=>{let c=new TextEncoder().encode(i),u=C(c.length);return h(u,c,s.encodeType(t))});t.add(this,h(r,n,...o))}decodeValue(t){return Qe(t)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(t){return`service "${t.toText()}"`}};function P(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>kt?t.substring(0,kt-3)+"...":t}function An(e,t){if(t.length<e.length)throw Error("Wrong number of message arguments");let r=new Ye;e.forEach(u=>u.buildTypeTable(r));let n=new TextEncoder().encode(we),o=r.encode(),i=C(t.length),s=h(...e.map(u=>u.encodeType(r))),c=h(...le(e,t,(u,l)=>{try{u.covariant(l)}catch(f){throw new Error(f.message+`
12
-
13
- `)}return u.encodeValue(l)}));return h(n,o,i,s,c)}function Vn(e,t){let r=new Z(t);if(t.byteLength<we.length)throw new Error("Message length smaller than magic number");let n=D(r,we.length),o=new TextDecoder().decode(n);if(o!==we)throw new Error("Wrong magic number: "+JSON.stringify(o));function i(a){let p=[],y=Number(V(a));for(let _=0;_<y;_++){let w=Number(J(a));switch(w){case-18:case-19:{let g=Number(J(a));p.push([w,g]);break}case-20:case-21:{let g=[],b=Number(V(a)),v;for(;b--;){let S=Number(V(a));if(S>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof v=="number"&&v>=S)throw new Error("field id collision or not sorted");v=S;let R=Number(J(a));g.push([S,R])}p.push([w,g]);break}case-22:{let g=[],b=Number(V(a));for(;b--;)g.push(Number(J(a)));let v=[],S=Number(V(a));for(;S--;)v.push(Number(J(a)));let R=[],E=Number(V(a));for(;E--;)switch(Number(V(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,[g,v,R]]);break}case-23:{let g=Number(V(a)),b=[];for(;g--;){let v=Number(V(a)),S=new TextDecoder().decode(D(a,v)),R=J(a);b.push([S,R])}p.push([w,b]);break}default:throw new Error("Illegal op_code: "+w)}}let T=[],x=Number(V(a));for(let _=0;_<x;_++)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=>or());function l(a){if(a<-24)throw new Error("future value not supported");if(a<0)switch(a){case-1:return $t;case-2:return Bt;case-3:return jt;case-4:return zt;case-5:return Jt;case-6:return Yt;case-7:return Qt;case-8:return It;case-9:return Wt;case-10:return Gt;case-11:return Xt;case-12:return Zt;case-13:return Ht;case-14:return Kt;case-15:return qt;case-16:return Mt;case-17:return Ut;case-24:return Dt;default:throw new Error("Illegal op_code: "+a)}if(a>=s.length)throw new Error("type index out of range");return u[a]}function f(a){switch(a[0]){case-19:{let p=l(a[1]);return er(p)}case-18:{let p=l(a[1]);return tr(p)}case-20:{let p={};for(let[x,_]of a[1]){let w=`_${x}_`;p[w]=l(_)}let y=rr(p),T=y.tryAsTuple();return Array.isArray(T)?Lt(...T):y}case-21:{let p={};for(let[y,T]of a[1]){let x=`_${y}_`;p[x]=l(T)}return nr(p)}case-22:{let[p,y,T]=a[1];return ir(p.map(x=>l(x)),y.map(x=>l(x)),T)}case-23:{let p={},y=a[1];for(let[T,x]of y){let _=l(x);if(_ instanceof L&&(_=_.getType()),!(_ instanceof de))throw new Error("Illegal service definition: services can only contain functions");p[T]=_}return sr(p)}default:throw new Error("Illegal op_code: "+a[0])}}s.forEach((a,p)=>{if(a[0]===-22){let y=f(a);u[p].fill(y)}}),s.forEach((a,p)=>{if(a[0]!==-22){let y=f(a);u[p].fill(y)}});let m=c.map(a=>l(a)),d=e.map((a,p)=>a.decodeValue(r,m[p]));for(let a=e.length;a<m.length;a++)m[a].decodeValue(r,m[a]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return d}var Ut=new Pe,Mt=new oe,On=new Ce,Bt=new Ne,$t=new ve,qt=new Se,zt=new Re,jt=new Ae,Ht=new ue(32),Kt=new ue(64),Wt=new Y(8),Gt=new Y(16),Xt=new Y(32),Zt=new Y(64),Jt=new z(8),Yt=new z(16),Qt=new z(32),It=new z(64),Dt=new Ee;function Lt(...e){return new Oe(e)}function er(e){return new Ve(e)}function tr(e){return new ie(e)}function rr(e){return new pe(e)}function nr(e){return new Fe(e)}function or(){return new L}function ir(e,t,r=[]){return new de(e,t,r)}function sr(e){return new ke(e)}import{Principal as pi}from"@dfinity/principal";var ar=e=>O.encode([O.Record({user:O.Principal})],[{user:e}]),Ue=e=>O.encode([O.Record({controllers:O.Vec(O.Principal)})],[{controllers:e.map(([t,r])=>t)}]);var Si=async({missionControl:e,...t})=>{let r=await dt({missionControl:e}),{missionControlId:n,...o}=e;if(!n)throw new Error("No mission control principal defined.");let i=ar(r);await X({actor:o,canisterId:En.fromText(n),arg:new Uint8Array(i),mode:te,...t})};var Vi=e=>pt(e);var Ei=async e=>{await X(e)};var cr=async({orbiter:e})=>(await he(e)).version(),Me=async({orbiter:e})=>(await he(e)).list_controllers(),lr=async({orbiter:e})=>{let{memory_size:t}=await he(e);return t()};var $i=e=>Me(e);var ji=e=>lr(e);import{Principal as kn}from"@dfinity/principal";var Ji=async({orbiter:e,reset:t=!1,...r})=>{let{orbiterId:n,...o}=e;if(!n)throw new Error("No orbiter principal defined.");let i=await Me({orbiter:e}),s=Ue(i);await X({actor:o,canisterId:kn.fromText(n),arg:new Uint8Array(s),mode:t?ce:te,reset:t,...r})};var Ii=e=>cr(e);import{major as ur,minor as pr,patch as dr}from"semver";var es=({currentVersion:e,selectedVersion:t})=>{let r=ur(e),n=ur(t),o=pr(e),i=pr(t),s=dr(e),c=dr(t);return r<n-1||o<i-1||s<c-1?{canUpgrade:!1}:{canUpgrade:!0}};import{toNullable as Un}from"@junobuild/utils";var mr=async({config:e,satellite:t})=>{let{set_storage_config:r}=await A(t);return r(e)},fr=async({config:e,satellite:t})=>{let{set_db_config:r}=await A(t);return r(e)},hr=async({config:e,satellite:t})=>{let{set_auth_config:r}=await A(t);return r(e)};var yr=async({satellite:e})=>{let{get_auth_config:t}=await A(e);return t()},_r=async({satellite:e,type:t})=>(await A(e)).list_rules(t),gr=async({type:e,collection:t,rule:r,satellite:n})=>{let{set_rule:o}=await A(n);return o(e,t,r)},xr=async({satellite:e})=>{let{version:t}=await A(e);return t()},Tr=async({satellite:e})=>{let{build_version:t}=await A(e);return t()},wr=async({satellite:e})=>(await lt(e)).list_controllers(),Be=async({satellite:e})=>(await ut(e)).list_controllers(),$e=async({satellite:e})=>(await A(e)).list_controllers(),br=async({satellite:e})=>{let{list_custom_domains:t}=await A(e);return t()},Pr=async({satellite:e,domainName:t,boundaryNodesId:r})=>{let{set_custom_domain:n}=await A(e);await n(t,Un(r))},Cr=async({satellite:e})=>{let{memory_size:t}=await A(e);return t()},Nr=async({collection:e,satellite:t})=>{let{count_collection_docs:r}=await A(t);return r(e)},vr=async({collection:e,satellite:t})=>{let{count_collection_assets:r}=await A(t);return r(e)},Sr=async({collection:e,satellite:t})=>{let{del_docs:r}=await A(t);return r(e)},Rr=async({collection:e,satellite:t})=>{let{del_assets:r}=await A(t);return r(e)},Ar=async({args:e,satellite:t})=>{let{set_controllers:r}=await A(t);return r(e)};var ss=e=>vr(e),as=e=>Rr(e);import{fromNullable as qe,isNullish as Or,nonNullish as Vr}from"@junobuild/utils";import{nonNullish as Mn,toNullable as Ie}from"@junobuild/utils";var De=e=>Ie(Mn(e)?{heap:Ie(e.heap),stable:Ie(e.stable)}:void 0);var fs=async({config:{headers:e,rewrites:t,redirects:r,iframe:n,rawAccess:o,maxMemorySize:i},satellite:s})=>{let c=(e??[]).map(({source:d,headers:a})=>[d,a]),u=(t??[]).map(({source:d,destination:a})=>[d,a]),l=(r??[]).map(({source:d,location:a,code:p})=>[d,{status_code:p,location:a}]);return await mr({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:De(i)}})},hs=async({config:{maxMemorySize:e},...t})=>{await fr({config:{max_memory_size:De(e)},...t})},ys=async({config:{internetIdentity:e},...t})=>{await hr({config:{internet_identity:Or(e?.derivationOrigin)?[]:[{derivation_origin:[e.derivationOrigin]}]},...t})},_s=async({satellite:e})=>{let t=qe(await yr({satellite:e}));if(Or(t))return;let r=qe(t.internet_identity??[]);return{...Vr(r)&&{internetIdentity:{...Vr(qe(r.derivation_origin))&&{derivationOrigin:qe(r.derivation_origin)}}}}};var Ts=({deprecatedNoScope:e,...t})=>(e===!0?Be:$e)(t),ws=e=>Ar(e);var Cs=e=>Nr(e),Ns=e=>Sr(e);import{fromNullable as Fr,nonNullish as Bn}from"@junobuild/utils";var As=async({satellite:e})=>(await br({satellite:e})).map(([r,n])=>{let o=Fr(n.version);return{domain:r,bn_id:Fr(n.bn_id),created_at:n.created_at,updated_at:n.updated_at,...Bn(o)&&{version:o}}}),Vs=({satellite:e,domains:t})=>Promise.all(t.map(({domain:r,bn_id:n})=>Pr({satellite:e,domainName:r,boundaryNodesId:n})));var Es=e=>Cr(e);import{fromNullable as se,nonNullish as ee,toNullable as ze}from"@junobuild/utils";var Er={Db:null},kr={Storage:null},Ur={Public:null},Mr={Private:null},Br={Managed:null},$r={Controllers:null},Le={Heap:null},qr={Stable:null},zr=600000000n;var et=e=>e==="storage"?kr:Er,Kr=({read:e,write:t,memory:r,maxSize:n,maxCapacity:o,version:i,mutablePermissions:s,maxTokens:c})=>({read:Hr(e),write:Hr(t),memory:ee(r)?[$n(r)]:[],version:ze(i),max_size:ze(ee(n)&&n>0?BigInt(n):void 0),max_capacity:ze(ee(o)&&o>0?o:void 0),mutable_permissions:ze(s),rate_config:ee(c)?[{max_tokens:BigInt(c),time_per_token_ns:zr}]:[]}),Wr=([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:f,rate_config:m}=t,d=s?.[0]??0n>0n?Number(se(s)):void 0,a=c?.[0]??!1?se(c):void 0,p=se(f),y=m?.[0]?.max_tokens??0n>0n?se(m)?.max_tokens:void 0;return{collection:e,read:jr(r),write:jr(n),memory:qn(se(u)??Le),updatedAt:o,createdAt:i,...ee(p)&&{version:p},...ee(d)&&{maxSize:d},...ee(a)&&{maxCapacity:a},mutablePermissions:se(l)??!0,...ee(y)&&{maxTokens:Number(y)}}},jr=e=>"Public"in e?"public":"Private"in e?"private":"Managed"in e?"managed":"controllers",Hr=e=>{switch(e){case"public":return Ur;case"private":return Mr;case"managed":return Br;default:return $r}},$n=e=>{switch(e.toLowerCase()){case"heap":return Le;default:return qr}},qn=e=>"Heap"in e?"heap":"stable";var js=async({type:e,satellite:t})=>(await _r({satellite:t,type:et(e)})).map(n=>Wr(n)),Hs=async({rule:{collection:e,...t},type:r,satellite:n})=>{await gr({type:et(r),rule:Kr(t),satellite:n,collection:e})};import{Principal as Gr}from"@dfinity/principal";import{isNullish as zn}from"@junobuild/utils";var Is=async({satellite:e,deprecated:t,deprecatedNoScope:r,reset:n=!1,...o})=>{let{satelliteId:i,...s}=e;if(zn(i))throw new Error("No satellite principal defined.");if(t){let f=await wr({satellite:e}),m=O.encode([O.Record({controllers:O.Vec(O.Principal)})],[{controllers:f}]);await X({actor:s,canisterId:Gr.fromText(i),arg:new Uint8Array(m),mode:n?ce:te,reset:n,...o});return}let u=await(r?Be:$e)({satellite:e}),l=Ue(u);await X({actor:s,canisterId:Gr.fromText(i),arg:new Uint8Array(l),mode:n?ce:te,reset:n,...o})};import{nonNullish as jn}from"@junobuild/utils";var ra=e=>xr(e),na=e=>Tr(e),oa=async({satellite:{satelliteId:e,...t}})=>{let r=await Pt({...t,canisterId:e,path:"juno:build"});return jn(r)&&["stock","extended"].includes(r)?r:void 0};export{Ct as UpgradeCodeProgressStep,fe as UpgradeCodeUnchangedError,St as blobSha256,es as checkUpgradeVersion,ss as countAssets,Cs as countDocs,as as deleteAssets,Ns as deleteDocs,_s as getAuthConfig,As as listCustomDomains,yo as listMissionControlControllers,$i as listOrbiterControllers,js as listRules,Ts as listSatelliteControllers,Vi as missionControlVersion,ji as orbiterMemorySize,Ii as orbiterVersion,oa as satelliteBuildType,na as satelliteBuildVersion,Es as satelliteMemorySize,ra as satelliteVersion,ys as setAuthConfig,Vs as setCustomDomains,hs as setDatastoreConfig,ho as setMissionControlController,Hs as setRule,ws as setSatelliteControllers,fo as setSatellitesController,fs as setStorageConfig,ge as uint8ArraySha256,Si as upgradeMissionControl,Ei as upgradeModule,Ji as upgradeOrbiter,Is as upgradeSatellite};
1
+ var J=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 Ge}from"@junobuild/utils";var _t=({IDL:t})=>{let e=t.Record({updated_at:t.Nat64,orbiter_id:t.Principal,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64}),r=t.Record({subnet_id:t.Opt(t.Principal),name:t.Opt(t.Text)}),o=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,satellite_id:t.Principal}),s=t.Record({cycles:t.Nat,destination_id:t.Principal}),a=t.Record({e8s:t.Nat64}),n=t.Record({timestamp_nanos:t.Nat64}),i=t.Record({to:t.Vec(t.Nat8),fee:a,memo:t.Nat64,from_subaccount:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(n),amount:a}),p=t.Variant({TxTooOld:t.Record({allowed_window_nanos:t.Nat64}),BadFee:t.Record({expected_fee:a}),TxDuplicate:t.Record({duplicate_of:t.Nat64}),TxCreatedInFuture:t.Null,InsufficientFunds:t.Record({balance:a})}),l=t.Variant({Ok:t.Nat64,Err:p}),m=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),d=t.Record({to:m,fee:t.Opt(t.Nat),memo:t.Opt(t.Vec(t.Nat8)),from_subaccount:t.Opt(t.Vec(t.Nat8)),created_at_time:t.Opt(t.Nat64),amount:t.Nat}),c=t.Variant({GenericError:t.Record({message:t.Text,error_code:t.Nat}),TemporarilyUnavailable:t.Null,BadBurn:t.Record({min_burn_amount:t.Nat}),Duplicate:t.Record({duplicate_of:t.Nat}),BadFee:t.Record({expected_fee:t.Nat}),CreatedInFuture:t.Record({ledger_time:t.Nat64}),TooOld:t.Null,InsufficientFunds:t.Record({balance:t.Nat})}),u=t.Variant({Ok:t.Nat,Err:c}),g=t.Variant({Write:t.Null,Admin:t.Null}),P=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:g,expires_at:t.Opt(t.Nat64)}),k=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),S=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),C=t.Record({status:k,memory_size:t.Nat,cycles:t.Nat,settings:S,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))}),N=t.Record({id:t.Principal,status:C,metadata:t.Opt(t.Vec(t.Tuple(t.Text,t.Text))),status_at:t.Nat64}),y=t.Variant({Ok:N,Err:t.Text}),x=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:g,expires_at:t.Opt(t.Nat64)}),A=t.Record({enabled:t.Bool,cycles_threshold:t.Opt(t.Nat64)}),O=t.Record({mission_control_cycles_threshold:t.Opt(t.Nat64),orbiters:t.Vec(t.Tuple(t.Principal,A)),satellites:t.Vec(t.Tuple(t.Principal,A)),cycles_threshold:t.Opt(t.Nat64)}),w=t.Record({orbiters:t.Opt(t.Vec(y)),satellites:t.Opt(t.Vec(y)),mission_control:y});return t.Service({add_mission_control_controllers:t.Func([t.Vec(t.Principal)],[],[]),add_satellites_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal)],[],[]),create_orbiter:t.Func([t.Opt(t.Text)],[e],[]),create_orbiter_with_config:t.Func([r],[e],[]),create_satellite:t.Func([t.Text],[o],[]),create_satellite_with_config:t.Func([r],[o],[]),del_mission_control_controllers:t.Func([t.Vec(t.Principal)],[],[]),del_orbiter:t.Func([t.Principal,t.Nat],[],[]),del_orbiters_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal)],[],[]),del_satellite:t.Func([t.Principal,t.Nat],[],[]),del_satellites_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal)],[],[]),deposit_cycles:t.Func([s],[],[]),get_user:t.Func([],[t.Principal],["query"]),icp_transfer:t.Func([i],[l],[]),icrc_transfer:t.Func([t.Principal,d],[u],[]),list_mission_control_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,P))],["query"]),list_mission_control_statuses:t.Func([],[t.Vec(t.Tuple(t.Nat64,y))],["query"]),list_orbiter_statuses:t.Func([t.Principal],[t.Opt(t.Vec(t.Tuple(t.Nat64,y)))],["query"]),list_orbiters:t.Func([],[t.Vec(t.Tuple(t.Principal,e))],["query"]),list_satellite_statuses:t.Func([t.Principal],[t.Opt(t.Vec(t.Tuple(t.Nat64,y)))],["query"]),list_satellites:t.Func([],[t.Vec(t.Tuple(t.Principal,o))],["query"]),remove_mission_control_controllers:t.Func([t.Vec(t.Principal)],[],[]),remove_satellites_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal)],[],[]),set_metadata:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),set_mission_control_controllers:t.Func([t.Vec(t.Principal),x],[],[]),set_orbiter:t.Func([t.Principal,t.Opt(t.Text)],[e],[]),set_orbiter_metadata:t.Func([t.Principal,t.Vec(t.Tuple(t.Text,t.Text))],[e],[]),set_orbiters_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal),x],[],[]),set_satellite:t.Func([t.Principal,t.Opt(t.Text)],[o],[]),set_satellite_metadata:t.Func([t.Principal,t.Vec(t.Tuple(t.Text,t.Text))],[o],[]),set_satellites_controllers:t.Func([t.Vec(t.Principal),t.Vec(t.Principal),x],[],[]),status:t.Func([O],[w],[]),top_up:t.Func([t.Principal,a],[],[]),unset_orbiter:t.Func([t.Principal],[],[]),unset_satellite:t.Func([t.Principal],[],[]),version:t.Func([],[t.Text],["query"])})};var yt=({IDL:t})=>{let e=t.Record({controllers:t.Vec(t.Principal)}),r=t.Variant({Write:t.Null,Admin:t.Null}),o=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:r,expires_at:t.Opt(t.Nat64)}),s=t.Record({version:t.Opt(t.Nat64)}),a=t.Record({cycles:t.Nat,destination_id:t.Principal}),n=t.Record({to:t.Opt(t.Nat64),from:t.Opt(t.Nat64),satellite_id:t.Opt(t.Principal)}),i=t.Record({key:t.Text,collected_at:t.Nat64}),p=t.Record({inner_height:t.Nat16,inner_width:t.Nat16}),l=t.Record({title:t.Text,updated_at:t.Nat64,referrer:t.Opt(t.Text),time_zone:t.Text,session_id:t.Text,href:t.Text,created_at:t.Nat64,satellite_id:t.Principal,device:p,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),m=t.Record({safari:t.Float64,opera:t.Float64,others:t.Float64,firefox:t.Float64,chrome:t.Float64}),d=t.Record({desktop:t.Float64,others:t.Float64,mobile:t.Float64}),c=t.Record({browsers:m,devices:d}),u=t.Record({day:t.Nat8,month:t.Nat8,year:t.Int32}),g=t.Record({bounce_rate:t.Float64,average_page_views_per_session:t.Float64,daily_total_page_views:t.Vec(t.Tuple(u,t.Nat32)),total_page_views:t.Nat32,unique_page_views:t.Nat64,unique_sessions:t.Nat64}),P=t.Record({referrers:t.Vec(t.Tuple(t.Text,t.Nat32)),pages:t.Vec(t.Tuple(t.Text,t.Nat32))}),k=t.Variant({Navigate:t.Null,Restore:t.Null,Reload:t.Null,BackForward:t.Null,BackForwardCache:t.Null,Prerender:t.Null}),S=t.Record({id:t.Text,value:t.Float64,navigation_type:t.Opt(k),delta:t.Float64}),C=t.Variant({WebVitalsMetric:S}),N=t.Variant({CLS:t.Null,FCP:t.Null,INP:t.Null,LCP:t.Null,TTFB:t.Null}),y=t.Record({updated_at:t.Nat64,session_id:t.Text,data:C,href:t.Text,metric_name:N,created_at:t.Nat64,satellite_id:t.Principal,version:t.Opt(t.Nat64)}),x=t.Record({cls:t.Opt(t.Float64),fcp:t.Opt(t.Float64),inp:t.Opt(t.Float64),lcp:t.Opt(t.Float64),ttfb:t.Opt(t.Float64)}),A=t.Record({overall:x,pages:t.Vec(t.Tuple(t.Text,x))}),O=t.Record({updated_at:t.Nat64,session_id:t.Text,metadata:t.Opt(t.Vec(t.Tuple(t.Text,t.Text))),name:t.Text,created_at:t.Nat64,satellite_id:t.Principal,version:t.Opt(t.Nat64)}),w=t.Record({total:t.Vec(t.Tuple(t.Text,t.Nat32))}),h=t.Record({performance_metrics:t.Bool,track_events:t.Bool,page_views:t.Bool}),T=t.Record({updated_at:t.Nat64,features:t.Opt(h),created_at:t.Nat64,version:t.Opt(t.Nat64)}),R=t.Record({stable:t.Nat64,heap:t.Nat64}),v=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:r,expires_at:t.Opt(t.Nat64)}),V=t.Record({controller:v,controllers:t.Vec(t.Principal)}),M=t.Record({title:t.Text,updated_at:t.Opt(t.Nat64),referrer:t.Opt(t.Text),time_zone:t.Text,session_id:t.Text,href:t.Text,satellite_id:t.Principal,device:p,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),U=t.Variant({Ok:l,Err:t.Text}),E=t.Variant({Ok:t.Null,Err:t.Vec(t.Tuple(i,t.Text))}),F=t.Record({session_id:t.Text,data:C,href:t.Text,metric_name:N,satellite_id:t.Principal,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),st=t.Variant({Ok:y,Err:t.Text}),nt=t.Record({features:t.Opt(h),version:t.Opt(t.Nat64)}),Z=t.Record({updated_at:t.Opt(t.Nat64),session_id:t.Text,metadata:t.Opt(t.Vec(t.Tuple(t.Text,t.Text))),name:t.Text,satellite_id:t.Principal,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),it=t.Variant({Ok:O,Err:t.Text});return t.Service({del_controllers:t.Func([e],[t.Vec(t.Tuple(t.Principal,o))],[]),del_satellite_config:t.Func([t.Principal,s],[],[]),deposit_cycles:t.Func([a],[],[]),get_page_views:t.Func([n],[t.Vec(t.Tuple(i,l))],["query"]),get_page_views_analytics_clients:t.Func([n],[c],["query"]),get_page_views_analytics_metrics:t.Func([n],[g],["query"]),get_page_views_analytics_top_10:t.Func([n],[P],["query"]),get_performance_metrics:t.Func([n],[t.Vec(t.Tuple(i,y))],["query"]),get_performance_metrics_analytics_web_vitals:t.Func([n],[A],["query"]),get_track_events:t.Func([n],[t.Vec(t.Tuple(i,O))],["query"]),get_track_events_analytics:t.Func([n],[w],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,o))],["query"]),list_satellite_configs:t.Func([],[t.Vec(t.Tuple(t.Principal,T))],["query"]),memory_size:t.Func([],[R],["query"]),set_controllers:t.Func([V],[t.Vec(t.Tuple(t.Principal,o))],[]),set_page_view:t.Func([i,M],[U],[]),set_page_views:t.Func([t.Vec(t.Tuple(i,M))],[E],[]),set_performance_metric:t.Func([i,F],[st],[]),set_performance_metrics:t.Func([t.Vec(t.Tuple(i,F))],[E],[]),set_satellite_configs:t.Func([t.Vec(t.Tuple(t.Principal,nt))],[t.Vec(t.Tuple(t.Principal,T))],[]),set_track_event:t.Func([i,Z],[it],[]),set_track_events:t.Func([t.Vec(t.Tuple(i,Z))],[E],[]),version:t.Func([],[t.Text],["query"])})};var gt=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({controllers:t.Vec(t.Principal)}),o=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,expires_at:t.Opt(t.Nat64)}),s=t.Record({updated_at:t.Opt(t.Nat64)}),a=t.Record({headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text))))}),n=t.Record({storage:a}),i=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),created_at:t.Nat64}),p=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text))}),l=t.Record({token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),m=t.Variant({Callback:t.Record({token:l,callback:t.Func([],[],[])})}),d=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(m),status_code:t.Nat16}),c=t.Record({token:t.Opt(l),body:t.Vec(t.Nat8)}),u=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,encoding_type:t.Opt(t.Text),full_path:t.Text}),g=t.Record({batch_id:t.Nat}),P=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),k=t.Record({field:P,desc:t.Bool}),S=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),C=t.Record({order:t.Opt(k),owner:t.Opt(t.Principal),matcher:t.Opt(t.Text),paginate:t.Opt(S)}),N=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,full_path:t.Text}),y=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),x=t.Record({key:N,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,y)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64}),A=t.Record({matches_length:t.Nat64,length:t.Nat64,items:t.Vec(t.Tuple(t.Text,x))}),O=t.Record({updated_at:t.Nat64,created_at:t.Nat64,bn_id:t.Opt(t.Text)}),w=t.Record({matches_length:t.Nat64,length:t.Nat64,items:t.Vec(t.Tuple(t.Text,i))}),h=t.Variant({Db:t.Null,Storage:t.Null}),T=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),R=t.Record({updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:T,created_at:t.Nat64,write:T}),v=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),expires_at:t.Opt(t.Nat64)}),V=t.Record({controller:v,controllers:t.Vec(t.Principal)}),M=t.Record({updated_at:t.Opt(t.Nat64),data:t.Vec(t.Nat8)}),U=t.Record({updated_at:t.Opt(t.Nat64),max_size:t.Opt(t.Nat),read:T,write:T}),E=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat}),F=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Opt(t.Text)],[],[]),del_controllers:t.Func([r],[t.Vec(t.Tuple(t.Principal,o))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,s],[],[]),get_config:t.Func([],[n],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(i)],["query"]),http_request:t.Func([p],[d],["query"]),http_request_streaming_callback:t.Func([l],[c],["query"]),init_asset_upload:t.Func([u],[g],[]),list_assets:t.Func([t.Opt(t.Text),C],[A],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,o))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,O))],["query"]),list_docs:t.Func([t.Text,C],[w],["query"]),list_rules:t.Func([h],[t.Vec(t.Tuple(t.Text,R))],["query"]),set_config:t.Func([n],[],[]),set_controllers:t.Func([V],[t.Vec(t.Tuple(t.Principal,o))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,M],[i],[]),set_rule:t.Func([h,t.Text,U],[],[]),upload_asset_chunk:t.Func([E],[F],[]),version:t.Func([],[t.Text],["query"])})};var xt=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Record({controllers:t.Vec(t.Principal)}),o=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,expires_at:t.Opt(t.Nat64)}),s=t.Record({updated_at:t.Opt(t.Nat64)}),a=t.Record({headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text))))}),n=t.Record({storage:a}),i=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),created_at:t.Nat64}),p=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text))}),l=t.Record({token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),m=t.Variant({Callback:t.Record({token:l,callback:t.Func([],[],[])})}),d=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(m),status_code:t.Nat16}),c=t.Record({token:t.Opt(l),body:t.Vec(t.Nat8)}),u=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,encoding_type:t.Opt(t.Text),full_path:t.Text}),g=t.Record({batch_id:t.Nat}),P=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),k=t.Record({field:P,desc:t.Bool}),S=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),C=t.Record({order:t.Opt(k),matcher:t.Opt(t.Text),paginate:t.Opt(S)}),N=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,full_path:t.Text}),y=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),x=t.Record({key:N,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,y)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64}),A=t.Record({matches_length:t.Nat64,length:t.Nat64,items:t.Vec(t.Tuple(t.Text,x))}),O=t.Record({updated_at:t.Nat64,created_at:t.Nat64,bn_id:t.Opt(t.Text)}),w=t.Record({matches_length:t.Nat64,length:t.Nat64,items:t.Vec(t.Tuple(t.Text,i))}),h=t.Variant({Db:t.Null,Storage:t.Null}),T=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),R=t.Record({updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:T,created_at:t.Nat64,write:T}),v=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),expires_at:t.Opt(t.Nat64)}),V=t.Record({controller:v,controllers:t.Vec(t.Principal)}),M=t.Record({updated_at:t.Opt(t.Nat64),data:t.Vec(t.Nat8)}),U=t.Record({updated_at:t.Opt(t.Nat64),max_size:t.Opt(t.Nat),read:T,write:T}),E=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat}),F=t.Record({chunk_id:t.Nat});return t.Service({commit_asset_upload:t.Func([e],[],[]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Opt(t.Text)],[],[]),del_controllers:t.Func([r],[t.Vec(t.Tuple(t.Principal,o))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,s],[],[]),get_config:t.Func([],[n],[]),get_doc:t.Func([t.Text,t.Text],[t.Opt(i)],["query"]),http_request:t.Func([p],[d],["query"]),http_request_streaming_callback:t.Func([l],[c],["query"]),init_asset_upload:t.Func([u],[g],[]),list_assets:t.Func([t.Opt(t.Text),C],[A],["query"]),list_controllers:t.Func([],[t.Vec(t.Principal)],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,O))],["query"]),list_docs:t.Func([t.Text,C],[w],["query"]),list_rules:t.Func([h],[t.Vec(t.Tuple(t.Text,R))],["query"]),set_config:t.Func([n],[],[]),set_controllers:t.Func([V],[t.Vec(t.Tuple(t.Principal,o))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_doc:t.Func([t.Text,t.Text,M],[i],[]),set_rule:t.Func([h,t.Text,U],[],[]),upload_asset_chunk:t.Func([E],[F],[]),version:t.Func([],[t.Text],["query"])})};var Tt=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),o=t.Record({field:r,desc:t.Bool}),s=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),a=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(s),description:t.Opt(t.Text),created_at:t.Opt(s)}),n=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),i=t.Record({order:t.Opt(o),owner:t.Opt(t.Principal),matcher:t.Opt(a),paginate:t.Opt(n)}),p=t.Record({controllers:t.Vec(t.Principal)}),l=t.Variant({Write:t.Null,Admin:t.Null}),m=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:l,expires_at:t.Opt(t.Nat64)}),d=t.Record({version:t.Opt(t.Nat64)}),c=t.Variant({Db:t.Null,Storage:t.Null}),u=t.Record({version:t.Opt(t.Nat64)}),g=t.Record({cycles:t.Nat,destination_id:t.Principal}),P=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),k=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),S=t.Record({key:P,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,k)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),C=t.Record({derivation_origin:t.Opt(t.Text)}),N=t.Record({internet_identity:t.Opt(C)}),y=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),x=t.Record({max_memory_size:t.Opt(y)}),A=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),O=t.Variant({Deny:t.Null,Allow:t.Null}),w=t.Record({status_code:t.Nat16,location:t.Text}),h=t.Record({iframe:t.Opt(A),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(y),raw_access:t.Opt(O),redirects:t.Opt(t.Vec(t.Tuple(t.Text,w)))}),T=t.Record({db:t.Opt(x),authentication:t.Opt(N),storage:h}),R=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),v=t.Variant({Heap:t.Null,Stable:t.Null}),V=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),M=t.Record({max_tokens:t.Nat64,time_per_token_ns:t.Nat64}),U=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(v),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:V,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(M),write:V}),E=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),F=t.Record({memory:v,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),st=t.Variant({Callback:t.Record({token:F,callback:t.Func([],[],["query"])})}),nt=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(st),status_code:t.Nat16}),Z=t.Record({token:t.Opt(F),body:t.Vec(t.Nat8)}),it=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),be=t.Record({batch_id:t.Nat}),ke=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,S)),items_length:t.Nat64}),we=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),ve=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,R)),items_length:t.Nat64}),Me=t.Record({stable:t.Nat64,heap:t.Nat64}),Ue=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:l,expires_at:t.Opt(t.Nat64)}),Ee=t.Record({controller:Ue,controllers:t.Vec(t.Principal)}),mt=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),qe=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(v),max_size:t.Opt(t.Nat),read:V,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),rate_config:t.Opt(M),write:V}),ze=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),Be=t.Record({chunk_id:t.Nat});return t.Service({build_version:t.Func([],[t.Text],["query"]),commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,i],[t.Nat64],["query"]),count_collection_assets:t.Func([t.Text],[t.Nat64],["query"]),count_collection_docs:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text,i],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([p],[t.Vec(t.Tuple(t.Principal,m))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,d],[],[]),del_docs:t.Func([t.Text],[],[]),del_filtered_assets:t.Func([t.Text,i],[],[]),del_filtered_docs:t.Func([t.Text,i],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,d))],[],[]),del_rule:t.Func([c,t.Text,u],[],[]),deposit_cycles:t.Func([g],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(S)],["query"]),get_auth_config:t.Func([],[t.Opt(N)],["query"]),get_config:t.Func([],[T],[]),get_db_config:t.Func([],[t.Opt(x)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(R)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(S)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(R)))],["query"]),get_rule:t.Func([c,t.Text],[t.Opt(U)],["query"]),get_storage_config:t.Func([],[h],["query"]),http_request:t.Func([E],[nt],["query"]),http_request_streaming_callback:t.Func([F],[Z],["query"]),init_asset_upload:t.Func([it],[be],[]),list_assets:t.Func([t.Text,i],[ke],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,m))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,we))],["query"]),list_docs:t.Func([t.Text,i],[ve],["query"]),list_rules:t.Func([c],[t.Vec(t.Tuple(t.Text,U))],["query"]),memory_size:t.Func([],[Me],["query"]),set_auth_config:t.Func([N],[],[]),set_controllers:t.Func([Ee],[t.Vec(t.Tuple(t.Principal,m))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([x],[],[]),set_doc:t.Func([t.Text,t.Text,mt],[R],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,mt))],[t.Vec(t.Tuple(t.Text,R))],[]),set_rule:t.Func([c,t.Text,qe],[U],[]),set_storage_config:t.Func([h],[],[]),upload_asset_chunk:t.Func([ze],[Be],[]),version:t.Func([],[t.Text],["query"])})};import{Actor as He,HttpAgent as Ke}from"@dfinity/agent";import{nonNullish as ft}from"@junobuild/utils";var Pt=async({canisterId:t,idlFactory:e,config:r,...o})=>{let s=await f(o);return He.createActor(e,{agent:s,canisterId:t,...r??{}})},f=async({agent:t,...e})=>t??await We(e),We=async({identity:t,fetch:e,container:r})=>{let o=ft(r)&&r!==!1,s=o?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io";return await Ke.create({identity:t,host:s,retryTimes:10,...ft(e)&&{fetch:e},shouldFetchRootKey:o})};var Ct=({satelliteId:t,...e})=>G({canisterId:t,...e,idlFactory:xt}),_=({satelliteId:t,...e})=>G({canisterId:t,...e,idlFactory:Tt}),Nt=({satelliteId:t,...e})=>G({canisterId:t,...e,idlFactory:gt}),K=({missionControlId:t,...e})=>G({canisterId:t,...e,idlFactory:_t}),Q=({orbiterId:t,...e})=>G({canisterId:t,...e,idlFactory:yt}),G=({canisterId:t,idlFactory:e,...r})=>{if(Ge(t))throw new Error("No canister ID provided.");return Pt({canisterId:t,idlFactory:e,...r})};var ht=async({missionControl:t})=>(await K(t)).version(),St=async({missionControl:t})=>(await K(t)).get_user(),Rt=async({missionControl:t})=>(await K(t)).list_mission_control_controllers(),At=async({missionControl:t,satelliteIds:e,controllerIds:r,controller:o})=>(await K(t)).set_satellites_controllers(e,r,o),Ot=async({missionControl:t,controllerIds:e,controller:r})=>(await K(t)).set_mission_control_controllers(e,r);import{Principal as je}from"@dfinity/principal";import{nonNullish as Xe,toNullable as Ze}from"@junobuild/utils";var ct=({controllerId:t,profile:e})=>({controllerIds:[je.fromText(t)],controller:Je(e)}),Je=t=>({metadata:Xe(t)&&t!==""?[["profile",t]]:[],expires_at:Ze(void 0),scope:{Admin:null}});var Wr=({controllerId:t,profile:e,...r})=>At({...r,...ct({controllerId:t,profile:e})}),Gr=({controllerId:t,profile:e,...r})=>Ot({...r,...ct({controllerId:t,profile:e})}),jr=t=>Rt(t);import{Principal as lr}from"@dfinity/principal";var j={reinstall:null},B={upgrade:[{skip_pre_upgrade:[!1],wasm_memory_persistence:[{replace:null}]}]};import{fromNullable as ar,isNullish as sr}from"@junobuild/utils";import{CanisterStatus as Qe}from"@dfinity/agent";import{ICManagementCanister as b}from"@dfinity/ic-management";import{Principal as Ye}from"@dfinity/principal";import{assertNonNullish as $e}from"@junobuild/utils";var Vt=async({canisterId:t,actor:e})=>{let r=await f(e),{stopCanister:o}=b.create({agent:r});await o(t)},Ft=async({canisterId:t,actor:e})=>{let r=await f(e),{startCanister:o}=b.create({agent:r});await o(t)},bt=async({actor:t,code:e})=>{let r=await f(t),{installCode:o}=b.create({agent:r});return o(e)},kt=async({actor:t,canisterId:e})=>{let r=await f(t),{storedChunks:o}=b.create({agent:r});return o({canisterId:e})},Y=async({actor:t,canisterId:e})=>{let r=await f(t),{clearChunkStore:o}=b.create({agent:r});return o({canisterId:e})},wt=async({actor:t,chunk:e})=>{let r=await f(t),{uploadChunk:o}=b.create({agent:r});return o(e)},vt=async({actor:t,code:e})=>{let r=await f(t),{installChunkedCode:o}=b.create({agent:r});return o(e)},Mt=async({actor:t,canisterId:e})=>{let r=await f(t),{canisterStatus:o}=b.create({agent:r});return o(e)},Ut=async({canisterId:t,path:e,...r})=>{$e(t,"A canister ID must be provided to request its status.");let o=await f(r);return(await Qe.request({canisterId:Ye.from(t),agent:o,paths:[{kind:"metadata",key:e,path:e,decodeStrategy:"utf-8"}]})).get(e)},Et=async({actor:t,canisterId:e})=>{let r=await f(t),{listCanisterSnapshots:o}=b.create({agent:r});return o({canisterId:e})},qt=async({actor:t,...e})=>{let r=await f(t),{takeCanisterSnapshot:o}=b.create({agent:r});return o(e)};var zt=(a=>(a[a.AssertingExistingCode=0]="AssertingExistingCode",a[a.StoppingCanister=1]="StoppingCanister",a[a.TakingSnapshot=2]="TakingSnapshot",a[a.UpgradingCode=3]="UpgradingCode",a[a.RestartingCanister=4]="RestartingCanister",a))(zt||{});var $=t=>(t instanceof Uint8Array||(t=Uint8Array.from(t)),t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""));var Bt=t=>crypto.subtle.digest("SHA-256",t),Ht=t=>Array.from(new Uint8Array(t)).map(r=>r.toString(16).padStart(2,"0")).join(""),Kt=async t=>{let e=await Bt(await t.arrayBuffer());return Ht(e)},D=async t=>{let e=await Bt(t);return Ht(e)};import{isNullish as Ie,nonNullish as Wt}from"@junobuild/utils";var Gt=async({actor:t,canisterId:e,missionControlId:r,wasmModule:o,preClearChunks:s,...a})=>{s&&await Y({actor:t,canisterId:e});let n=await Le({wasmModule:o}),{uploadChunks:i,storedChunks:p,preClearChunks:l,postClearChunks:m}=await tr({actor:t,wasmChunks:n,canisterId:e,missionControlId:r});l&&await Y({actor:t,canisterId:e});let d=[];for await(let c of er({uploadChunks:i,actor:t,canisterId:e,missionControlId:r}))d=[...d,...c];await vt({actor:t,code:{...a,chunkHashesList:[...d,...p].sort(({orderId:c},{orderId:u})=>c-u).map(({chunkHash:c})=>c),targetCanisterId:e,storeCanisterId:r,wasmModuleHash:await D(o)}}),m&&await Y({actor:t,canisterId:e})},Le=async({wasmModule:t})=>{let e=new Blob([t]),r=[],o=1e6,s=0;for(let a=0;a<e.size;a+=o){let n=e.slice(a,a+o);r.push({chunk:n,orderId:s,sha256:await Kt(n)}),s++}return r},tr=async({canisterId:t,missionControlId:e,actor:r,wasmChunks:o})=>{let s=await kt({actor:r,canisterId:e??t}),a=s.map(({hash:p})=>({chunkHash:{hash:p},sha256:$(p)})),{storedChunks:n,uploadChunks:i}=o.reduce(({uploadChunks:p,storedChunks:l},{sha256:m,...d})=>{let c=a.find(({sha256:u})=>u===m);return{uploadChunks:[...p,...Wt(c)?[]:[{sha256:m,...d}]],storedChunks:[...l,...Wt(c)?[{...d,...c}]:[]]}},{uploadChunks:[],storedChunks:[]});return{uploadChunks:i,storedChunks:n,preClearChunks:s.length>0&&n.length===0,postClearChunks:Ie(e)}};async function*er({uploadChunks:t,limit:e=12,...r}){for(let o=0;o<t.length;o=o+e){let s=t.slice(o,o+e);yield await Promise.all(s.map(n=>rr({uploadChunk:n,...r})))}}var rr=async({actor:t,canisterId:e,missionControlId:r,uploadChunk:{chunk:o,...s}})=>({chunkHash:await wt({actor:t,chunk:{canisterId:r??e,chunk:new Uint8Array(await o.arrayBuffer())}}),...s});var jt=async({actor:t,...e})=>{await bt({actor:t,code:e})};var q=async({wasmModule:t,canisterId:e,actor:r,onProgress:o,takeSnapshot:s=!0,...a})=>{await X({fn:async()=>await nr({wasmModule:t,canisterId:e,actor:r,...a}),onProgress:o,step:0}),await X({fn:async()=>await Vt({canisterId:e,actor:r}),onProgress:o,step:1});try{await X({fn:async()=>s?await cr({canisterId:e,actor:r}):Promise.resolve(),onProgress:o,step:2}),await X({fn:async()=>await ir({wasmModule:t,canisterId:e,actor:r,...a}),onProgress:o,step:3})}finally{await X({fn:async()=>await Ft({canisterId:e,actor:r}),onProgress:o,step:4})}},X=async({fn:t,step:e,onProgress:r})=>{r?.({step:e,state:"in_progress"});try{await t(),r?.({step:e,state:"success"})}catch(o){throw r?.({step:e,state:"error"}),o}},nr=async({actor:t,canisterId:e,wasmModule:r,reset:o})=>{if(o===!0)return;let{module_hash:s}=await Mt({actor:t,canisterId:e}),a=ar(s);if(sr(a))return;let n=await D(r),i=$(a);if(n===i)throw new J},ir=async({wasmModule:t,canisterId:e,actor:r,...o})=>{await((new Blob([t]).size>2e6?"chunked":"single")==="chunked"?Gt:jt)({wasmModule:t,canisterId:e,actor:r,...o})},cr=async t=>{let e=await Et(t);await qt({...t,snapshotId:e?.[0]?.id})};import{IDL as H}from"@dfinity/candid";var Xt=t=>H.encode([H.Record({user:H.Principal})],[{user:t}]),I=t=>H.encode([H.Record({controllers:H.Vec(H.Principal)})],[{controllers:t.map(([e,r])=>e)}]);var wo=async({missionControl:t,...e})=>{let r=await St({missionControl:t}),{missionControlId:o,...s}=t;if(!o)throw new Error("No mission control principal defined.");let a=Xt(r);await q({actor:s,canisterId:lr.fromText(o),arg:new Uint8Array(a),mode:B,...e})};var Uo=t=>ht(t);var zo=async t=>{await q(t)};var Zt=async({orbiter:t})=>(await Q(t)).version(),L=async({orbiter:t})=>(await Q(t)).list_controllers(),Jt=async({orbiter:t})=>{let{memory_size:e}=await Q(t);return e()};var Go=t=>L(t);var Zo=t=>Jt(t);import{Principal as pr}from"@dfinity/principal";var Lo=async({orbiter:t,reset:e=!1,...r})=>{let{orbiterId:o,...s}=t;if(!o)throw new Error("No orbiter principal defined.");let a=await L({orbiter:t}),n=I(a);await q({actor:s,canisterId:pr.fromText(o),arg:new Uint8Array(n),mode:e?j:B,reset:e,...r})};var ra=t=>Zt(t);import{major as Qt,minor as Yt,patch as $t}from"semver";var sa=({currentVersion:t,selectedVersion:e})=>{let r=Qt(t),o=Qt(e),s=Yt(t),a=Yt(e),n=$t(t),i=$t(e);return r<o-1||s<a-1||n<i-1?{canUpgrade:!1}:{canUpgrade:!0}};import{toNullable as dr}from"@junobuild/utils";var Dt=async({config:t,satellite:e})=>{let{set_storage_config:r}=await _(e);return r(t)},It=async({config:t,satellite:e})=>{let{set_db_config:r}=await _(e);return r(t)},Lt=async({config:t,satellite:e})=>{let{set_auth_config:r}=await _(e);return r(t)};var te=async({satellite:t})=>{let{get_auth_config:e}=await _(t);return e()},ee=async({satellite:t,type:e})=>(await _(t)).list_rules(e),re=async({type:t,collection:e,rule:r,satellite:o})=>{let{set_rule:s}=await _(o);return s(t,e,r)},oe=async({satellite:t})=>{let{version:e}=await _(t);return e()},ae=async({satellite:t})=>{let{build_version:e}=await _(t);return e()},se=async({satellite:t})=>(await Ct(t)).list_controllers(),tt=async({satellite:t})=>(await Nt(t)).list_controllers(),et=async({satellite:t})=>(await _(t)).list_controllers(),ne=async({satellite:t})=>{let{list_custom_domains:e}=await _(t);return e()},ie=async({satellite:t,domainName:e,boundaryNodesId:r})=>{let{set_custom_domain:o}=await _(t);await o(e,dr(r))},ce=async({satellite:t})=>{let{memory_size:e}=await _(t);return e()},le=async({collection:t,satellite:e})=>{let{count_collection_docs:r}=await _(e);return r(t)},pe=async({collection:t,satellite:e})=>{let{count_collection_assets:r}=await _(e);return r(t)},de=async({collection:t,satellite:e})=>{let{del_docs:r}=await _(e);return r(t)},ue=async({collection:t,satellite:e})=>{let{del_assets:r}=await _(e);return r(t)},me=async({args:t,satellite:e})=>{let{set_controllers:r}=await _(e);return r(t)};var da=t=>pe(t),ua=t=>ue(t);import{fromNullable as rt,isNullish as ye,nonNullish as _e}from"@junobuild/utils";import{nonNullish as ur,toNullable as lt}from"@junobuild/utils";var pt=t=>lt(ur(t)?{heap:lt(t.heap),stable:lt(t.stable)}:void 0);var fa=async({config:{headers:t,rewrites:e,redirects:r,iframe:o,rawAccess:s,maxMemorySize:a},satellite:n})=>{let i=(t??[]).map(({source:c,headers:u})=>[c,u]),p=(e??[]).map(({source:c,destination:u})=>[c,u]),l=(r??[]).map(({source:c,location:u,code:g})=>[c,{status_code:g,location:u}]);return await Dt({satellite:n,config:{headers:i,rewrites:p,redirects:[l],iframe:[o==="same-origin"?{SameOrigin:null}:o==="allow-any"?{AllowAny:null}:{Deny:null}],raw_access:[s===!0?{Allow:null}:{Deny:null}],max_memory_size:pt(a)}})},Pa=async({config:{maxMemorySize:t},...e})=>{await It({config:{max_memory_size:pt(t)},...e})},Ca=async({config:{internetIdentity:t},...e})=>{await Lt({config:{internet_identity:ye(t?.derivationOrigin)?[]:[{derivation_origin:[t.derivationOrigin]}]},...e})},Na=async({satellite:t})=>{let e=rt(await te({satellite:t}));if(ye(e))return;let r=rt(e.internet_identity??[]);return{..._e(r)&&{internetIdentity:{..._e(rt(r.derivation_origin))&&{derivationOrigin:rt(r.derivation_origin)}}}}};var Ra=({deprecatedNoScope:t,...e})=>(t===!0?tt:et)(e),Aa=t=>me(t);var Fa=t=>le(t),ba=t=>de(t);import{fromNullable as ge,nonNullish as mr}from"@junobuild/utils";var Ma=async({satellite:t})=>(await ne({satellite:t})).map(([r,o])=>{let s=ge(o.version);return{domain:r,bn_id:ge(o.bn_id),created_at:o.created_at,updated_at:o.updated_at,...mr(s)&&{version:s}}}),Ua=({satellite:t,domains:e})=>Promise.all(e.map(({domain:r,bn_id:o})=>ie({satellite:t,domainName:r,boundaryNodesId:o})));var za=t=>ce(t);import{fromNullable as W,nonNullish as z,toNullable as ot}from"@junobuild/utils";var xe={Db:null},Te={Storage:null},fe={Public:null},Pe={Private:null},Ce={Managed:null},Ne={Controllers:null},dt={Heap:null},he={Stable:null},Se=600000000n;var ut=t=>t==="storage"?Te:xe,Oe=({read:t,write:e,memory:r,maxSize:o,maxCapacity:s,version:a,mutablePermissions:n,maxTokens:i})=>({read:Ae(t),write:Ae(e),memory:z(r)?[_r(r)]:[],version:ot(a),max_size:ot(z(o)&&o>0?BigInt(o):void 0),max_capacity:ot(z(s)&&s>0?s:void 0),mutable_permissions:ot(n),rate_config:z(i)?[{max_tokens:BigInt(i),time_per_token_ns:Se}]:[]}),Ve=([t,e])=>{let{read:r,write:o,updated_at:s,created_at:a,max_size:n,max_capacity:i,memory:p,mutable_permissions:l,version:m,rate_config:d}=e,c=n?.[0]??0n>0n?Number(W(n)):void 0,u=i?.[0]??!1?W(i):void 0,g=W(m),P=d?.[0]?.max_tokens??0n>0n?W(d)?.max_tokens:void 0;return{collection:t,read:Re(r),write:Re(o),memory:yr(W(p)??dt),updatedAt:s,createdAt:a,...z(g)&&{version:g},...z(c)&&{maxSize:c},...z(u)&&{maxCapacity:u},mutablePermissions:W(l)??!0,...z(P)&&{maxTokens:Number(P)}}},Re=t=>"Public"in t?"public":"Private"in t?"private":"Managed"in t?"managed":"controllers",Ae=t=>{switch(t){case"public":return fe;case"private":return Pe;case"managed":return Ce;default:return Ne}},_r=t=>{switch(t.toLowerCase()){case"heap":return dt;default:return he}},yr=t=>"Heap"in t?"heap":"stable";var Za=async({type:t,satellite:e})=>(await ee({satellite:e,type:ut(t)})).map(o=>Ve(o)),Ja=async({rule:{collection:t,...e},type:r,satellite:o})=>{await re({type:ut(r),rule:Oe(e),satellite:o,collection:t})};import{IDL as at}from"@dfinity/candid";import{Principal as Fe}from"@dfinity/principal";import{isNullish as gr}from"@junobuild/utils";var rs=async({satellite:t,deprecated:e,deprecatedNoScope:r,reset:o=!1,...s})=>{let{satelliteId:a,...n}=t;if(gr(a))throw new Error("No satellite principal defined.");if(e){let m=await se({satellite:t}),d=at.encode([at.Record({controllers:at.Vec(at.Principal)})],[{controllers:m}]);await q({actor:n,canisterId:Fe.fromText(a),arg:new Uint8Array(d),mode:o?j:B,reset:o,...s});return}let p=await(r?tt:et)({satellite:t}),l=I(p);await q({actor:n,canisterId:Fe.fromText(a),arg:new Uint8Array(l),mode:o?j:B,reset:o,...s})};import{nonNullish as xr}from"@junobuild/utils";var is=t=>oe(t),cs=t=>ae(t),ls=async({satellite:{satelliteId:t,...e}})=>{let r=await Ut({...e,canisterId:t,path:"juno:build"});return xr(r)&&["stock","extended"].includes(r)?r:void 0};export{zt as UpgradeCodeProgressStep,J as UpgradeCodeUnchangedError,Kt as blobSha256,sa as checkUpgradeVersion,da as countAssets,Fa as countDocs,ua as deleteAssets,ba as deleteDocs,Na as getAuthConfig,Ma as listCustomDomains,jr as listMissionControlControllers,Go as listOrbiterControllers,Za as listRules,Ra as listSatelliteControllers,Uo as missionControlVersion,Zo as orbiterMemorySize,ra as orbiterVersion,ls as satelliteBuildType,cs as satelliteBuildVersion,za as satelliteMemorySize,is as satelliteVersion,Ca as setAuthConfig,Ua as setCustomDomains,Pa as setDatastoreConfig,Gr as setMissionControlController,Ja as setRule,Aa as setSatelliteControllers,Wr as setSatellitesController,fa as setStorageConfig,D as uint8ArraySha256,wo as upgradeMissionControl,zo as upgradeModule,Lo as upgradeOrbiter,rs as upgradeSatellite};
14
2
  //# sourceMappingURL=index.js.map