@junobuild/cli 0.0.30 → 0.0.31

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -278,7 +278,7 @@ ${U(V)}
278
278
  `)}throw new Error("unreachable")}e.pollForResponse=A}),Gse=Pt(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=({IDL:t})=>{let r=t.Principal,i=t.Record({controllers:t.Vec(t.Principal),freezing_threshold:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),n=t.Record({controllers:t.Opt(t.Vec(t.Principal)),freezing_threshold:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),s=t.Vec(t.Nat8);return t.Service({canister_status:t.Func([t.Record({canister_id:r})],[t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:i,module_hash:t.Opt(t.Vec(t.Nat8))})],[]),create_canister:t.Func([t.Record({settings:t.Opt(n)})],[t.Record({canister_id:r})],[]),delete_canister:t.Func([t.Record({canister_id:r})],[],[]),deposit_cycles:t.Func([t.Record({canister_id:r})],[],[]),install_code:t.Func([t.Record({arg:t.Vec(t.Nat8),wasm_module:s,mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),canister_id:r})],[],[]),provisional_create_canister_with_cycles:t.Func([t.Record({settings:t.Opt(n),amount:t.Opt(t.Nat)})],[t.Record({canister_id:r})],[]),provisional_top_up_canister:t.Func([t.Record({canister_id:r,amount:t.Nat})],[],[]),raw_rand:t.Func([],[t.Vec(t.Nat8)],[]),start_canister:t.Func([t.Record({canister_id:r})],[],[]),stop_canister:t.Func([t.Record({canister_id:r})],[],[]),uninstall_code:t.Func([t.Record({canister_id:r})],[],[]),update_settings:t.Func([t.Record({canister_id:t.Principal,settings:n})],[],[])})}}),Zw=Pt(e=>{"use strict";var t=e&&e.__importDefault||function(X){return X&&X.__esModule?X:{default:X}};Object.defineProperty(e,"__esModule",{value:!0}),e.getManagementCanister=e.Actor=e.CanisterInstallMode=e.UpdateCallRejectedError=e.QueryCallRejectedError=e.ActorCallError=void 0;var r=Sse(),i=Xw(),n=TE(),s=hl(),a=q4(),o=Mn(),A=ga(),u=t(Gse()),l=class extends n.AgentError{constructor(X,ne,D,U){super(["Call failed:",` Canister: ${X.toText()}`,` Method: ${ne} (${D})`,...Object.getOwnPropertyNames(U).map(re=>` "${re}": ${JSON.stringify(U[re])}`)].join(`
279
279
  `)),this.canisterId=X,this.methodName=ne,this.type=D,this.props=U}};e.ActorCallError=l;var m=class extends l{constructor(X,ne,D){var U;super(X,ne,"query",{Status:D.status,Code:(U=i.ReplicaRejectCode[D.reject_code])!==null&&U!==void 0?U:`Unknown Code "${D.reject_code}"`,Message:D.reject_message}),this.result=D}};e.QueryCallRejectedError=m;var I=class extends l{constructor(X,ne,D,U){super(X,ne,"update",{"Request ID":(0,A.toHex)(D),"HTTP status code":U.status.toString(),"HTTP status text":U.statusText}),this.requestId=D,this.response=U}};e.UpdateCallRejectedError=I;var E;(function(X){X.Install="install",X.Reinstall="reinstall",X.Upgrade="upgrade"})(E=e.CanisterInstallMode||(e.CanisterInstallMode={}));var v=Symbol.for("ic-agent-metadata"),N=class{constructor(X){this[v]=Object.freeze(X)}static agentOf(X){return X[v].config.agent}static interfaceOf(X){return X[v].service}static canisterIdOf(X){return o.Principal.from(X[v].config.canisterId)}static async install(X,ne){let D=X.mode===void 0?E.Install:X.mode,U=X.arg?[...new Uint8Array(X.arg)]:[],re=[...new Uint8Array(X.module)],_=typeof ne.canisterId=="string"?o.Principal.fromText(ne.canisterId):ne.canisterId;await z(ne).install_code({mode:{[D]:null},arg:U,wasm_module:re,canister_id:_})}static async createCanister(X){let{canister_id:ne}=await z(X||{}).provisional_create_canister_with_cycles({amount:[],settings:[]});return ne}static async createAndInstallCanister(X,ne,D){let U=await this.createCanister(D);return await this.install(Object.assign({},ne),Object.assign(Object.assign({},D),{canisterId:U})),this.createActor(X,Object.assign(Object.assign({},D),{canisterId:U}))}static createActorClass(X){let ne=X({IDL:s.IDL});class D extends N{constructor(re){let _=typeof re.canisterId=="string"?o.Principal.fromText(re.canisterId):re.canisterId;super({config:Object.assign(Object.assign(Object.assign({},q),re),{canisterId:_}),service:ne});for(let[V,G]of ne._fields)this[V]=M(this,V,G,re.blsVerify)}}return D}static createActor(X,ne){return new(this.createActorClass(X))(ne)}};e.Actor=N;function L(X,ne){let D=s.IDL.decode(X,r.Buffer.from(ne));switch(D.length){case 0:return;case 1:return D[0];default:return D}}var q={pollingStrategyFactory:a.strategy.defaultStrategy};function M(X,ne,D,U){let re;D.annotations.includes("query")?re=async(V,...G)=>{var Ae,Be;V=Object.assign(Object.assign({},V),(Be=(Ae=X[v].config).queryTransform)===null||Be===void 0?void 0:Be.call(Ae,ne,G,Object.assign(Object.assign({},X[v].config),V)));let H=V.agent||X[v].config.agent||(0,i.getDefaultAgent)(),Ie=o.Principal.from(V.canisterId||X[v].config.canisterId),Me=s.IDL.encode(D.argTypes,G),Oe=await H.query(Ie,{methodName:ne,arg:Me});switch(Oe.status){case"rejected":throw new m(Ie,ne,Oe);case"replied":return L(D.retTypes,Oe.reply.arg)}}:re=async(V,...G)=>{var Ae,Be;V=Object.assign(Object.assign({},V),(Be=(Ae=X[v].config).callTransform)===null||Be===void 0?void 0:Be.call(Ae,ne,G,Object.assign(Object.assign({},X[v].config),V)));let H=V.agent||X[v].config.agent||(0,i.getDefaultAgent)(),{canisterId:Ie,effectiveCanisterId:Me,pollingStrategyFactory:Oe}=Object.assign(Object.assign(Object.assign({},q),X[v].config),V),He=o.Principal.from(Ie),Ve=Me!==void 0?o.Principal.from(Me):He,bt=s.IDL.encode(D.argTypes,G),{requestId:ut,response:It}=await H.call(He,{methodName:ne,arg:bt,effectiveCanisterId:Ve});if(!It.ok)throw new I(He,ne,ut,It);let je=Oe(),Ee=await(0,a.pollForResponse)(H,Ve,ut,je,U);if(Ee!==void 0)return L(D.retTypes,Ee);if(D.retTypes.length!==0)throw new Error(`Call was returned undefined, but type [${D.retTypes.join(",")}].`)};let _=(...V)=>re({},...V);return _.withOptions=V=>(...G)=>re(V,...G),_}function z(X){function ne(D,U,re){let _=U[0],V=o.Principal.fromHex("");return _&&typeof _=="object"&&_.canister_id&&(V=o.Principal.from(_.canister_id)),{effectiveCanisterId:V}}return N.createActor(u.default,Object.assign(Object.assign(Object.assign({},X),{canisterId:o.Principal.fromHex("")}),{callTransform:ne,queryTransform:ne}))}e.getManagementCanister=z}),Lse=Pt(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=({IDL:t})=>t.Service({retrieve:t.Func([t.Text],[t.Vec(t.Nat8)],["query"]),store:t.Func([t.Text,t.Vec(t.Nat8)],[],[])})}),qse=Pt(e=>{"use strict";var t=e&&e.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(e,"__esModule",{value:!0}),e.createAssetCanisterActor=void 0;var r=Zw(),i=t(Lse());function n(s){return r.Actor.createActor(i.default,s)}e.createAssetCanisterActor=n}),Pse=Pt(e=>{"use strict";var t=e&&e.__createBinding||(Object.create?function(u,l,m,I){I===void 0&&(I=m);var E=Object.getOwnPropertyDescriptor(l,m);(!E||("get"in E?!l.__esModule:E.writable||E.configurable))&&(E={enumerable:!0,get:function(){return l[m]}}),Object.defineProperty(u,I,E)}:function(u,l,m,I){I===void 0&&(I=m),u[I]=l[m]}),r=e&&e.__setModuleDefault||(Object.create?function(u,l){Object.defineProperty(u,"default",{enumerable:!0,value:l})}:function(u,l){u.default=l}),i=e&&e.__importStar||function(u){if(u&&u.__esModule)return u;var l={};if(u!=null)for(var m in u)m!=="default"&&Object.prototype.hasOwnProperty.call(u,m)&&t(l,u,m);return r(l,u),l};Object.defineProperty(e,"__esModule",{value:!0}),e.fetchCandid=void 0;var n=Mn(),s=i(zw()),a=L4(),o=Zw();async function A(u,l){l||(l=new a.HttpAgent,l.isLocal()&&l.fetchRootKey());let m=(await s.request({agent:l,canisterId:n.Principal.fromText(u),paths:["candid"]})).get("candid");if(m)return m;let I=({IDL:E})=>E.Service({__get_candid_interface_tmp_hack:E.Func([],[E.Text],["query"])});return await o.Actor.createActor(I,{agent:l,canisterId:u}).__get_candid_interface_tmp_hack()}e.fetchCandid=A}),Hse=Pt(e=>{"use strict";var t=e&&e.__createBinding||(Object.create?function(s,a,o,A){A===void 0&&(A=o);var u=Object.getOwnPropertyDescriptor(a,o);(!u||("get"in u?!a.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return a[o]}}),Object.defineProperty(s,A,u)}:function(s,a,o,A){A===void 0&&(A=o),s[A]=a[o]}),r=e&&e.__setModuleDefault||(Object.create?function(s,a){Object.defineProperty(s,"default",{enumerable:!0,value:a})}:function(s,a){s.default=a}),i=e&&e.__exportStar||function(s,a){for(var o in s)o!=="default"&&!Object.prototype.hasOwnProperty.call(a,o)&&t(a,s,o)},n=e&&e.__importStar||function(s){if(s&&s.__esModule)return s;var a={};if(s!=null)for(var o in s)o!=="default"&&Object.prototype.hasOwnProperty.call(s,o)&&t(a,s,o);return r(a,s),a};Object.defineProperty(e,"__esModule",{value:!0}),e.Cbor=e.CanisterStatus=e.polling=void 0,i(Zw(),e),i(Xw(),e),i(O4(),e),i(Ww(),e),i(Jw(),e),i(NE(),e),i(qse(),e),i(Pse(),e),i(kE(),e),i(G4(),e),i(ga(),e),e.polling=n(q4()),e.CanisterStatus=n(zw()),e.Cbor=n(OE())}),jw=fc(hl(),1),jse=fc(Mn(),1),P4=fc(Mn(),1),Yse=({IDL:e})=>{let t=e.Principal,r=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),i=e.Record({freezing_threshold:e.Opt(e.Nat),controllers:e.Opt(e.Vec(e.Principal)),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),n=e.Record({value:e.Text,name:e.Text}),s=e.Record({status:e.Nat,body:e.Vec(e.Nat8),headers:e.Vec(n)}),a=e.Variant({dns_error:e.Null,no_consensus:e.Null,transform_error:e.Null,unreachable:e.Null,bad_tls:e.Null,conn_timeout:e.Null,invalid_url:e.Null,timeout:e.Null}),o=e.Vec(e.Nat8);return e.Service({canister_status:e.Func([e.Record({canister_id:t})],[e.Record({status:e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),memory_size:e.Nat,cycles:e.Nat,settings:r,module_hash:e.Opt(e.Vec(e.Nat8))})],[]),create_canister:e.Func([e.Record({settings:e.Opt(i)})],[e.Record({canister_id:t})],[]),delete_canister:e.Func([e.Record({canister_id:t})],[],[]),deposit_cycles:e.Func([e.Record({canister_id:t})],[],[]),http_request:e.Func([e.Record({url:e.Text,method:e.Variant({get:e.Null}),body:e.Opt(e.Vec(e.Nat8)),transform:e.Opt(e.Variant({function:e.Func([s],[s],["query"])})),headers:e.Vec(n)})],[e.Variant({Ok:s,Err:e.Opt(a)})],[]),install_code:e.Func([e.Record({arg:e.Vec(e.Nat8),wasm_module:o,mode:e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),canister_id:t})],[],[]),provisional_create_canister_with_cycles:e.Func([e.Record({settings:e.Opt(i),amount:e.Opt(e.Nat)})],[e.Record({canister_id:t})],[]),provisional_top_up_canister:e.Func([e.Record({canister_id:t,amount:e.Nat})],[],[]),raw_rand:e.Func([],[e.Vec(e.Nat8)],[]),start_canister:e.Func([e.Record({canister_id:t})],[],[]),stop_canister:e.Func([e.Record({canister_id:t})],[],[]),uninstall_code:e.Func([e.Record({canister_id:t})],[],[]),update_settings:e.Func([e.Record({canister_id:e.Principal,settings:i})],[],[])})},Jse=({IDL:e})=>{let t=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,satellite_id:e.Principal}),r=e.Variant({Write:e.Null,Admin:e.Null}),i=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:r,expires_at:e.Opt(e.Nat64)}),n=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),s=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),a=e.Record({status:n,memory_size:e.Nat,cycles:e.Nat,settings:s,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),o=e.Record({id:e.Principal,status:a,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),status_at:e.Nat64}),A=e.Variant({Ok:o,Err:e.Text}),u=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:r,expires_at:e.Opt(e.Nat64)}),l=e.Record({enabled:e.Bool,cycles_threshold:e.Opt(e.Nat64)}),m=e.Record({mission_control_cycles_threshold:e.Opt(e.Nat64),satellites:e.Vec(e.Tuple(e.Principal,l)),cycles_threshold:e.Opt(e.Nat64)}),I=e.Record({satellites:e.Opt(e.Vec(A)),mission_control:A}),E=e.Record({e8s:e.Nat64});return e.Service({add_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),add_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),create_satellite:e.Func([e.Text],[t],[]),del_mission_control_controllers:e.Func([e.Vec(e.Principal)],[],[]),del_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal)],[],[]),get_user:e.Func([],[e.Principal],["query"]),list_mission_control_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,i))],["query"]),list_mission_control_statuses:e.Func([],[e.Vec(e.Tuple(e.Nat64,A))],["query"]),list_satellite_statuses:e.Func([e.Principal],[e.Opt(e.Vec(e.Tuple(e.Nat64,A)))],["query"]),list_satellites:e.Func([],[e.Vec(e.Tuple(e.Principal,t))],["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),u],[],[]),set_satellites_controllers:e.Func([e.Vec(e.Principal),e.Vec(e.Principal),u],[],[]),status:e.Func([m],[I],[]),top_up:e.Func([e.Principal,E],[],[]),version:e.Func([],[e.Text],["query"])})},$se=({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)}),i=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)}),n=e.Record({updated_at:e.Opt(e.Nat64)}),s=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),a=e.Record({storage:s}),o=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),A=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),u=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),l=e.Variant({Callback:e.Record({token:u,callback:e.Func([],[],[])})}),m=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(l),status_code:e.Nat16}),I=e.Record({token:e.Opt(u),body:e.Vec(e.Nat8)}),E=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),v=e.Record({batch_id:e.Nat}),N=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),L=e.Record({field:N,desc:e.Bool}),q=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),M=e.Record({order:e.Opt(L),owner:e.Opt(e.Principal),matcher:e.Opt(e.Text),paginate:e.Opt(q)}),z=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),X=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),ne=e.Record({key:z,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,X)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),D=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,ne))}),U=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),re=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,o))}),_=e.Variant({Db:e.Null,Storage:e.Null}),V=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),G=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:V,created_at:e.Nat64,write:V}),Ae=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),Be=e.Record({controller:Ae,controllers:e.Vec(e.Principal)}),H=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),Ie=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:V,write:V}),Me=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),Oe=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,i))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,n],[],[]),get_config:e.Func([],[a],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(o)],["query"]),http_request:e.Func([A],[m],["query"]),http_request_streaming_callback:e.Func([u],[I],["query"]),init_asset_upload:e.Func([E],[v],[]),list_assets:e.Func([e.Opt(e.Text),M],[D],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,i))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,U))],["query"]),list_docs:e.Func([e.Text,M],[re],["query"]),list_rules:e.Func([_],[e.Vec(e.Tuple(e.Text,G))],["query"]),set_config:e.Func([a],[],[]),set_controllers:e.Func([Be],[e.Vec(e.Tuple(e.Principal,i))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,H],[o],[]),set_rule:e.Func([_,e.Text,Ie],[],[]),upload_asset_chunk:e.Func([Me],[Oe],[]),version:e.Func([],[e.Text],["query"])})},Kse=({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)}),i=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)}),n=e.Record({updated_at:e.Opt(e.Nat64)}),s=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),a=e.Record({storage:s}),o=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),A=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),u=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),l=e.Variant({Callback:e.Record({token:u,callback:e.Func([],[],[])})}),m=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(l),status_code:e.Nat16}),I=e.Record({token:e.Opt(u),body:e.Vec(e.Nat8)}),E=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),v=e.Record({batch_id:e.Nat}),N=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),L=e.Record({field:N,desc:e.Bool}),q=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),M=e.Record({order:e.Opt(L),matcher:e.Opt(e.Text),paginate:e.Opt(q)}),z=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),X=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),ne=e.Record({key:z,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,X)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),D=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,ne))}),U=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),re=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,o))}),_=e.Variant({Db:e.Null,Storage:e.Null}),V=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),G=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:V,created_at:e.Nat64,write:V}),Ae=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),expires_at:e.Opt(e.Nat64)}),Be=e.Record({controller:Ae,controllers:e.Vec(e.Principal)}),H=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),Ie=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:V,write:V}),Me=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),Oe=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,i))],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,n],[],[]),get_config:e.Func([],[a],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(o)],["query"]),http_request:e.Func([A],[m],["query"]),http_request_streaming_callback:e.Func([u],[I],["query"]),init_asset_upload:e.Func([E],[v],[]),list_assets:e.Func([e.Opt(e.Text),M],[D],["query"]),list_controllers:e.Func([],[e.Vec(e.Principal)],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,U))],["query"]),list_docs:e.Func([e.Text,M],[re],["query"]),list_rules:e.Func([_],[e.Vec(e.Tuple(e.Text,G))],["query"]),set_config:e.Func([a],[],[]),set_controllers:e.Func([Be],[e.Vec(e.Tuple(e.Principal,i))],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,H],[o],[]),set_rule:e.Func([_,e.Text,Ie],[],[]),upload_asset_chunk:e.Func([Me],[Oe],[]),version:e.Func([],[e.Text],["query"])})},Vse=({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)}),i=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:i,expires_at:e.Opt(e.Nat64)}),s=e.Record({updated_at:e.Opt(e.Nat64)}),a=e.Variant({Db:e.Null,Storage:e.Null}),o=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),A=e.Record({storage:o}),u=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),description:e.Opt(e.Text),created_at:e.Nat64}),l=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),m=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}),I=e.Variant({Callback:e.Record({token:m,callback:e.Func([],[],[])})}),E=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(I),status_code:e.Nat16}),v=e.Record({token:e.Opt(m),body:e.Vec(e.Nat8)}),N=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}),L=e.Record({batch_id:e.Nat}),q=e.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),M=e.Record({field:q,desc:e.Bool}),z=e.Record({key:e.Opt(e.Text),description:e.Opt(e.Text)}),X=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),ne=e.Record({order:e.Opt(M),owner:e.Opt(e.Principal),matcher:e.Opt(z),paginate:e.Opt(X)}),D=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}),U=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),re=e.Record({key:D,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,U)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),_=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,re)),items_length:e.Nat64}),V=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),G=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}),Ae=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),Be=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:Ae,created_at:e.Nat64,write:Ae}),H=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:i,expires_at:e.Opt(e.Nat64)}),Ie=e.Record({controller:H,controllers:e.Vec(e.Principal)}),Me=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8),description:e.Opt(e.Text)}),Oe=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:Ae,write:Ae}),He=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),Ve=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,s],[],[]),del_rule:e.Func([a,e.Text,s],[],[]),get_config:e.Func([],[A],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(u)],["query"]),http_request:e.Func([l],[E],["query"]),http_request_streaming_callback:e.Func([m],[v],["query"]),init_asset_upload:e.Func([N],[L],[]),list_assets:e.Func([e.Opt(e.Text),ne],[_],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,V))],["query"]),list_docs:e.Func([e.Text,ne],[G],["query"]),list_rules:e.Func([a],[e.Vec(e.Tuple(e.Text,Be))],["query"]),set_config:e.Func([A],[],[]),set_controllers:e.Func([Ie],[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,Me],[u],[]),set_rule:e.Func([a,e.Text,Oe],[],[]),upload_asset_chunk:e.Func([He],[Ve],[]),version:e.Func([],[e.Text],["query"])})},B4=fc(Hse(),1),H4=async({canisterId:e,idlFactory:t,identity:r,fetch:i,env:n="prod",config:s})=>{let a=n==="dev"?"http://127.0.0.1:8000/":"https://icp0.io",o=new B4.HttpAgent({identity:r,...a&&{host:a},...i&&{fetch:i}});return n==="dev"&&await o.fetchRootKey(),B4.Actor.createActor(t,{agent:o,canisterId:e,...s!==void 0?s:{}})},Wse=async({satelliteId:e,...t})=>GE({canisterId:e,...t,idlFactory:Kse}),pl=async({satelliteId:e,...t})=>GE({canisterId:e,...t,idlFactory:Vse}),zse=async({satelliteId:e,...t})=>GE({canisterId:e,...t,idlFactory:$se}),UE=async({missionControlId:e,...t})=>GE({canisterId:e,...t,idlFactory:Jse}),GE=async({canisterId:e,idlFactory:t,...r})=>{if(!e)throw new Error("No canister ID provided.");return H4({canisterId:e,idlFactory:t,...r})},j4=P4.Principal.fromText("aaaaa-aa"),m4=(e,t,r)=>{let i=t[0],n=j4;return i&&typeof i=="object"&&i.canister_id&&(n=P4.Principal.from(i.canister_id)),{effectiveCanisterId:n}},Xse=e=>H4({canisterId:j4.toText(),config:{callTransform:m4,queryTransform:m4},idlFactory:Yse,...e}),$w=async({actor:e,code:t})=>{let{install_code:r}=await Xse(e);return r({...t,mode:{upgrade:null}})},Zse=async({missionControl:e})=>(await UE(e)).version(),eae=async({missionControl:e})=>(await UE(e)).get_user(),tae=async({missionControl:e,satelliteIds:t,controllerIds:r,controller:i})=>(await UE(e)).set_satellites_controllers(t,r,i),rae=async({missionControl:e,controllerIds:t,controller:r})=>(await UE(e)).set_mission_control_controllers(t,r),iae=fc(Mn(),1),Y4=e=>e?[e]:[],J4=e=>e?.[0],$4=e=>e==null,eb=e=>!$4(e),K4=({controllerId:e,profile:t})=>({controllerIds:[iae.Principal.fromText(e)],controller:nae(t)}),nae=e=>({metadata:eb(e)&&e!==""?[["profile",e]]:[],expires_at:Y4(void 0),scope:{Admin:null}}),LE=async e=>Zse(e),tb=async({missionControl:e,wasm_module:t})=>{let r=await eae({missionControl:e}),{missionControlId:i,...n}=e;if(!i)throw new Error("No mission control principal defined.");let s=jw.IDL.encode([jw.IDL.Record({user:jw.IDL.Principal})],[{user:r}]);await $w({actor:n,code:{canister_id:jse.Principal.fromText(i),arg:[...new Uint8Array(s)],wasm_module:t}})},dCe=async({controllerId:e,profile:t,...r})=>tae({...r,...K4({controllerId:e,profile:t})}),ECe=async({controllerId:e,profile:t,...r})=>rae({...r,...K4({controllerId:e,profile:t})}),Yo=fc(hl(),1),y4=fc(Mn(),1),sae=async({config:e,satellite:t})=>(await pl(t)).set_config(e),aae=async({satellite:e,type:t})=>(await pl(e)).list_rules(t),oae=async({type:e,collection:t,rule:r,satellite:i})=>(await pl(i)).set_rule(e,t,r),Aae=async({satellite:e})=>(await pl(e)).version(),cae=async({satellite:e})=>(await Wse(e)).list_controllers(),uae=async({satellite:e})=>(await zse(e)).list_controllers(),lae=async({satellite:e})=>(await pl(e)).list_controllers(),fae=async({satellite:e})=>(await pl(e)).list_custom_domains(),hae={Db:null},pae={Storage:null},gae={Public:null},dae={Private:null},Eae={Managed:null},Iae={Controllers:null},V4=e=>e==="storage"?pae:hae,Bae=({read:e,write:t,max_size:r,updated_at:i})=>({read:Q4(e),write:Q4(t),updated_at:$4(i)?[]:[i],max_size:Y4(eb(r)&&r>0?BigInt(r):void 0)}),mae=([e,t])=>{let{read:r,write:i,updated_at:n,created_at:s,max_size:a}=t,o=a?.[0]??0n>0n?Number(J4(a)):void 0;return{collection:e,read:C4(r),write:C4(i),updated_at:n,created_at:s,...eb(o)&&{max_size:o}}},C4=e=>"Public"in e?"public":"Private"in e?"private":"Managed"in e?"managed":"controllers",Q4=e=>{switch(e){case"public":return gae;case"private":return dae;case"managed":return Eae;default:return Iae}},W4=async({config:{storage:{headers:e}},satellite:t})=>{let r=e.map(({source:i,headers:n})=>[i,n]);return sae({satellite:t,config:{storage:{headers:r}}})},ICe=async({type:e,satellite:t})=>(await aae({satellite:t,type:V4(e)})).map(r=>mae(r)),BCe=async({rule:{collection:e,...t},type:r,satellite:i})=>oae({type:V4(r),rule:Bae(t),satellite:i,collection:e}),tp=async e=>Aae(e),rb=async({satellite:e,wasm_module:t,deprecated:r,deprecatedNoScope:i})=>{let{satelliteId:n,...s}=e;if(!n)throw new Error("No satellite principal defined.");if(r){let A=await cae({satellite:e}),u=Yo.IDL.encode([Yo.IDL.Record({controllers:Yo.IDL.Vec(Yo.IDL.Principal)})],[{controllers:A}]);await $w({actor:s,code:{canister_id:y4.Principal.fromText(n),arg:[...new Uint8Array(u)],wasm_module:t}});return}let a=await(i?uae:lae)({satellite:e}),o=Yo.IDL.encode([Yo.IDL.Record({controllers:Yo.IDL.Vec(Yo.IDL.Principal)})],[{controllers:a.map(([A,u])=>A)}]);await $w({actor:s,code:{canister_id:y4.Principal.fromText(n),arg:[...new Uint8Array(o)],wasm_module:t}})},z4=async({satellite:e})=>(await fae({satellite:e})).map(([t,r])=>({domain:t,bn_id:J4(r.bn_id),created_at:r.created_at,updated_at:r.updated_at}));var yl=zt(cr(),1),iI=zt(hp(),1);var Cl=async()=>{if(!Ou()){console.log(`No controller found. Run ${(0,yl.cyan)("login")} to get started \u{1F680}.`);return}let t=t0(),r=await(t?.length>0?yce(t):bO());r==="_manual_"&&(r=await bO());let i=await Cce();await T8({satelliteId:r,source:i})},yce=async e=>{let{satellite:t}=await(0,iI.default)({type:"select",name:"satellite",message:"Which satellite should be linked with this dapp?",choices:[...e.map(({p:r,n:i})=>({title:i,value:r})),{title:"<not listed, manual entry>",value:"_manual_"}],initial:0});return(t===void 0||t==="")&&process.exit(1),t},bO=async()=>{let{satellite:e}=await(0,iI.default)([{type:"text",name:"satellite",message:`What's the ${(0,yl.cyan)("id")} of your satellite?`}]);return(e===void 0||e==="")&&(console.log(`${(0,yl.red)("The satellite ID is mandatory")}`),process.exit(1)),e},Cce=async()=>{let{source:e}=await(0,iI.default)([{type:"text",name:"source",message:`What's the name or path of the build ${(0,yl.cyan)("source")} folder of your dapp?`,initial:"build"}]);return(e===void 0||e==="")&&process.exit(1),e};var vO=async()=>{await Tn()||await Cl();let{satelliteId:e,storage:t}=await ts(),r=Ts("Configuring...").start();try{await W4({config:{storage:{headers:t?.headers??[]}},satellite:Fn(e)})}finally{r.stop()}};import{Blob as xue}from"buffer";import Sue from"crypto";import Ql from"node:fs";var ibe=Ql.existsSync,nbe=Ql.createReadStream;async function fv(e){return new Promise((t,r)=>{Ql.stat(e,(i,n)=>{i?r(i):t(n)})})}async function xO(e){return new Promise((t,r)=>{Ql.close(e,i=>{i?r(i):t()})})}async function SO(e,t){return new Promise((r,i)=>{Ql.open(e,t,(n,s)=>{n?i(n):r(s)})})}async function hv(e,t,r,i,n){return new Promise((s,a)=>{Ql.read(e,t,r,i,n,(o,A,u)=>{o?a(o):s({bytesRead:A,buffer:u})})})}var Qce="End-Of-Stream",oi=class extends Error{constructor(){super(Qce)}};var ube=1*1024*1024;import{Buffer as DO}from"node:buffer";var wl=class{constructor(t){this.position=0,this.numBuffer=new Uint8Array(8),this.fileInfo=t||{}}async readToken(t,r=this.position){let i=DO.alloc(t.len);if(await this.readBuffer(i,{position:r})<t.len)throw new oi;return t.get(i,0)}async peekToken(t,r=this.position){let i=DO.alloc(t.len);if(await this.peekBuffer(i,{position:r})<t.len)throw new oi;return t.get(i,0)}async readNumber(t){if(await this.readBuffer(this.numBuffer,{length:t.len})<t.len)throw new oi;return t.get(this.numBuffer,0)}async peekNumber(t){if(await this.peekBuffer(this.numBuffer,{length:t.len})<t.len)throw new oi;return t.get(this.numBuffer,0)}async ignore(t){if(this.fileInfo.size!==void 0){let r=this.fileInfo.size-this.position;if(t>r)return this.position+=r,r}return this.position+=t,t}async close(){}normalizeOptions(t,r){if(r&&r.position!==void 0&&r.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return r?{mayBeLess:r.mayBeLess===!0,offset:r.offset?r.offset:0,length:r.length?r.length:t.length-(r.offset?r.offset:0),position:r.position?r.position:this.position}:{mayBeLess:!1,offset:0,length:t.length,position:this.position}}};var pv=class extends wl{constructor(t,r){super(r),this.fd=t}async readBuffer(t,r){let i=this.normalizeOptions(t,r);this.position=i.position;let n=await hv(this.fd,t,i.offset,i.length,i.position);if(this.position+=n.bytesRead,n.bytesRead<i.length&&(!r||!r.mayBeLess))throw new oi;return n.bytesRead}async peekBuffer(t,r){let i=this.normalizeOptions(t,r),n=await hv(this.fd,t,i.offset,i.length,i.position);if(!i.mayBeLess&&n.bytesRead<i.length)throw new oi;return n.bytesRead}async close(){return xO(this.fd)}};async function gv(e){let t=await fv(e);if(!t.isFile)throw new Error(`File not a file: ${e}`);let r=await SO(e,"r");return new pv(r,{path:e,size:t.size})}import{Buffer as gc}from"node:buffer";var NO=zt(Zp(),1);import{Buffer as Sce}from"node:buffer";function mn(e){return new DataView(e.buffer,e.byteOffset)}var TO={len:1,get(e,t){return mn(e).getUint8(t)},put(e,t,r){return mn(e).setUint8(t,r),t+1}},nI={len:2,get(e,t){return mn(e).getUint16(t,!0)},put(e,t,r){return mn(e).setUint16(t,r,!0),t+2}},sI={len:2,get(e,t){return mn(e).getUint16(t)},put(e,t,r){return mn(e).setUint16(t,r),t+2}};var FO={len:4,get(e,t){return mn(e).getUint32(t,!0)},put(e,t,r){return mn(e).setUint32(t,r,!0),t+4}},MO={len:4,get(e,t){return mn(e).getUint32(t)},put(e,t,r){return mn(e).setUint32(t,r),t+4}};var kO={len:4,get(e,t){return mn(e).getInt32(t)},put(e,t,r){return mn(e).setInt32(t,r),t+4}};var OO={len:8,get(e,t){return mn(e).getBigUint64(t,!0)},put(e,t,r){return mn(e).setBigUint64(t,r,!0),t+8}};var so=class{constructor(t,r){this.len=t,this.encoding=r}get(t,r){return Sce.from(t).toString(this.encoding,r,r+this.len)}},no=class{constructor(t){this.len=t}static decode(t,r,i){let n="";for(let s=r;s<i;++s)n+=no.codePointToString(no.singleByteDecoder(t[s]));return n}static inRange(t,r,i){return r<=t&&t<=i}static codePointToString(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}static singleByteDecoder(t){if(no.inRange(t,0,127))return t;let r=no.windows1252[t-128];if(r===null)throw Error("invaliding encoding");return r}get(t,r=0){return no.decode(t,r,r+this.len)}};no.windows1252=[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255];function UO(e){return[...e].map(t=>t.charCodeAt(0))}function GO(e,t=0){let r=Number.parseInt(e.toString("utf8",148,154).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(r))return!1;let i=8*32;for(let n=t;n<t+148;n++)i+=e[n];for(let n=t+156;n<t+512;n++)i+=e[n];return r===i}var LO={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4};var qO=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","ai","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet"],PO=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/x-apache-arrow","video/mp4","audio/midi","video/x-matroska","video/webm","video/quicktime","video/vnd.avi","audio/vnd.wave","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","audio/opus","video/ogg","audio/ogg","application/ogg","audio/x-flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/x-parquet"];var Dce=4100;function Ca(e,t,r){r={offset:0,...r};for(let[i,n]of t.entries())if(r.mask){if(n!==(r.mask[i]&e[i+r.offset]))return!1}else if(n!==e[i+r.offset])return!1;return!0}async function Ev(e){try{return new dv().parse(e)}catch(t){if(!(t instanceof oi))throw t}}var dv=class{check(t,r){return Ca(this.buffer,t,r)}checkString(t,r){return this.check(UO(t),r)}async parse(t){if(this.buffer=gc.alloc(Dce),t.fileInfo.size===void 0&&(t.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=t,await t.peekBuffer(this.buffer,{length:12,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await t.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([239,187,191]))return this.tokenizer.ignore(3),this.parse(t);if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return{ext:"gz",mime:"application/gzip"};if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await t.ignore(6);let r=await t.readToken(LO);return t.position+r>t.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await t.ignore(r),Ev(t))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){try{for(;t.position+30<t.fileInfo.size;){await t.readBuffer(this.buffer,{length:30});let r={compressedSize:this.buffer.readUInt32LE(18),uncompressedSize:this.buffer.readUInt32LE(22),filenameLength:this.buffer.readUInt16LE(26),extraFieldLength:this.buffer.readUInt16LE(28)};if(r.filename=await t.readToken(new so(r.filenameLength,"utf-8")),await t.ignore(r.extraFieldLength),r.filename==="META-INF/mozilla.rsa")return{ext:"xpi",mime:"application/x-xpinstall"};if(r.filename.endsWith(".rels")||r.filename.endsWith(".xml"))switch(r.filename.split("/")[0]){case"_rels":break;case"word":return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};case"ppt":return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};case"xl":return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};default:break}if(r.filename.startsWith("xl/"))return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};if(r.filename.startsWith("3D/")&&r.filename.endsWith(".model"))return{ext:"3mf",mime:"model/3mf"};if(r.filename==="mimetype"&&r.compressedSize===r.uncompressedSize){let i=await t.readToken(new so(r.compressedSize,"utf-8"));switch(i=i.trim(),i){case"application/epub+zip":return{ext:"epub",mime:"application/epub+zip"};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:"application/vnd.oasis.opendocument.text"};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:"application/vnd.oasis.opendocument.spreadsheet"};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:"application/vnd.oasis.opendocument.presentation"};default:}}if(r.compressedSize===0){let i=-1;for(;i<0&&t.position<t.fileInfo.size;)await t.peekBuffer(this.buffer,{mayBeLess:!0}),i=this.buffer.indexOf("504B0304",0,"hex"),await t.ignore(i>=0?i:this.buffer.length)}else await t.ignore(r.compressedSize)}}catch(r){if(!(r instanceof oi))throw r}return{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await t.ignore(28);let r=gc.alloc(8);return await t.readBuffer(r),Ca(r,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/opus"}:Ca(r,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:Ca(r,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:Ca(r,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:Ca(r,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:Ca(r,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("ftyp",{offset:4})&&this.buffer[8]&96){let r=this.buffer.toString("binary",8,12).replace("\0"," ").trim();switch(r){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return r.startsWith("3g")?r.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/x-flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF")){try{await t.ignore(1350);let r=10*1024*1024,i=gc.alloc(Math.min(r,t.fileInfo.size));if(await t.readBuffer(i,{mayBeLess:!0}),i.includes(gc.from("AIPrivateData")))return{ext:"ai",mime:"application/postscript"}}catch(r){if(!(r instanceof oi))throw r}return{ext:"pdf",mime:"application/pdf"}}if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){let r=await this.readTiffHeader(!1);if(r)return r}if(this.check([77,77])){let r=await this.readTiffHeader(!0);if(r)return r}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function r(){let o=await t.peekNumber(TO),A=128,u=0;for(;!(o&A)&&A!==0;)++u,A>>=1;let l=gc.alloc(u+1);return await t.readBuffer(l),l}async function i(){let o=await r(),A=await r();A[0]^=128>>A.length-1;let u=Math.min(6,A.length);return{id:o.readUIntBE(0,o.length),len:A.readUIntBE(A.length-u,u)}}async function n(o){for(;o>0;){let A=await i();if(A.id===17026)return(await t.readToken(new so(A.len,"utf-8"))).replace(/\00.*$/g,"");await t.ignore(A.len),--o}}let s=await i();switch(await n(s.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/x-matroska"};default:return}}if(this.check([82,73,70,70])){if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/vnd.wave"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1"))return{ext:"parquet",mime:"application/x-parquet"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){let r=this.buffer.toString("binary",2,6);if(r.match("^d*")&&r>=1e3&&r<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await t.ignore(8),await t.readToken(new so(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.check([137,80,78,71,13,10,26,10])){await t.ignore(8);async function r(){return{length:await t.readToken(kO),type:await t.readToken(new so(4,"binary"))}}do{let i=await r();if(i.length<0)return;switch(i.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await t.ignore(i.length+4)}}while(t.position+8<t.fileInfo.size);return{ext:"png",mime:"image/png"}}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/x-apache-arrow"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){async function r(){let i=gc.alloc(16);return await t.readBuffer(i),{id:i,size:Number(await t.readToken(OO))}}for(await t.ignore(30);t.position+24<t.fileInfo.size;){let i=await r(),n=i.size-24;if(Ca(i.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let s=gc.alloc(16);if(n-=await t.readBuffer(s),Ca(s,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(Ca(s,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}await t.ignore(n)}return{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await t.ignore(20),await t.readToken(new so(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.check([0,60,0,63,0,120,0,109,0,108],{offset:2})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await t.peekBuffer(this.buffer,{length:Math.min(256,t.fileInfo.size),mayBeLess:!0}),this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){let r=this.buffer.readUInt32LE(12);if(r>12&&this.buffer.length>=r+16)try{let i=this.buffer.slice(16,r+16).toString();if(JSON.parse(i).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(await t.peekBuffer(this.buffer,{length:Math.min(512,t.fileInfo.size),mayBeLess:!0}),GO(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254]))return this.check([60,0,63,0,120,0,109,0,108,0],{offset:2})?{ext:"xml",mime:"application/xml"}:this.check([255,14,83,0,107,0,101,0,116,0,99,0,104,0,85,0,112,0,32,0,77,0,111,0,100,0,101,0,108,0],{offset:2})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:void 0;if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"};if(this.buffer.length>=2&&this.check([255,224],{offset:0,mask:[255,224]})){if(this.check([16],{offset:1,mask:[22]}))return this.check([8],{offset:1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}async readTiffTag(t){let r=await this.tokenizer.readToken(t?sI:nI);switch(this.tokenizer.ignore(10),r){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(t){let r=await this.tokenizer.readToken(t?sI:nI);for(let i=0;i<r;++i){let n=await this.readTiffTag(t);if(n)return n}}async readTiffHeader(t){let r=(t?sI:nI).get(this.buffer,2),i=(t?MO:FO).get(this.buffer,4);if(r===42){if(i>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(i>=8&&(this.check([28,0,254,0],{offset:8})||this.check([31,0,11,0],{offset:8})))return{ext:"nef",mime:"image/x-nikon-nef"}}return await this.tokenizer.ignore(i),await this.readTiffIFD(t)??{ext:"tif",mime:"image/tiff"}}if(r===43)return{ext:"tif",mime:"image/tiff"}}};var qbe=new Set(qO),Pbe=new Set(PO);async function HO(e){let t=await gv(e);try{return await Ev(t)}finally{await t.close()}}var uI=zt(cr(),1),bU=zt(VO(),1);import{lstatSync as _ue,readdirSync as Due}from"fs";import{readFile as wU}from"fs/promises";var IU=zt(AU(),1);var gp=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Yce={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},dp=e=>e.replace(/[[\]\\-]/g,"\\$&"),Jce=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),cU=e=>e.join(""),uU=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let i=[],n=[],s=r+1,a=!1,o=!1,A=!1,u=!1,l=r,m="";e:for(;s<e.length;){let N=e.charAt(s);if((N==="!"||N==="^")&&s===r+1){u=!0,s++;continue}if(N==="]"&&a&&!A){l=s+1;break}if(a=!0,N==="\\"&&!A){A=!0,s++;continue}if(N==="["&&!A){for(let[L,[q,M,z]]of Object.entries(Yce))if(e.startsWith(L,s)){if(m)return["$.",!1,e.length-r,!0];s+=L.length,z?n.push(q):i.push(q),o=o||M;continue e}}if(A=!1,m){N>m?i.push(dp(m)+"-"+dp(N)):N===m&&i.push(dp(N)),m="",s++;continue}if(e.startsWith("-]",s+1)){i.push(dp(N+"-")),s+=2;continue}if(e.startsWith("-",s+1)){m=N,s+=2;continue}i.push(dp(N)),s++}if(l<s)return["",!1,0,!1];if(!i.length&&!n.length)return["$.",!1,e.length-r,!0];if(n.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!u){let N=i[0].length===2?i[0].slice(-1):i[0];return[Jce(N),!1,l-r,!1]}let I="["+(u?"^":"")+cU(i)+"]",E="["+(u?"":"^")+cU(n)+"]";return[i.length&&n.length?"("+I+"|"+E+")":i.length?I:E,o,l-r,!0]};var Wo=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var $ce=new Set(["!","?","+","*","@"]),lU=e=>$ce.has(e),Kce="(?!\\.\\.?(?:$|/))",mv="(?!\\.)",Vce=new Set(["[","."]),Wce=new Set(["..","."]),zce=new Set("().*{}+?[]^$\\!"),Xce=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),yv="[^/]",fU=yv+"*?",hU=yv+"+?",di,vi,ao,Hr,ui,zo,dc,Xo,is,Ec,Ep,AI,pU,bl,oI,cI,gU,Cn=class{constructor(t,r,i={}){ji(this,AI);Nv(this,"type");ji(this,di,void 0);ji(this,vi,void 0);ji(this,ao,!1);ji(this,Hr,[]);ji(this,ui,void 0);ji(this,zo,void 0);ji(this,dc,void 0);ji(this,Xo,!1);ji(this,is,void 0);ji(this,Ec,void 0);ji(this,Ep,!1);this.type=t,t&&ii(this,vi,!0),ii(this,ui,r),ii(this,di,Qt(this,ui)?Qt(Qt(this,ui),di):this),ii(this,is,Qt(this,di)===this?i:Qt(Qt(this,di),is)),ii(this,dc,Qt(this,di)===this?[]:Qt(Qt(this,di),dc)),t==="!"&&!Qt(Qt(this,di),Xo)&&Qt(this,dc).push(this),ii(this,zo,Qt(this,ui)?Qt(Qt(this,ui),Hr).length:0)}get hasMagic(){if(Qt(this,vi)!==void 0)return Qt(this,vi);for(let t of Qt(this,Hr))if(typeof t!="string"&&(t.type||t.hasMagic))return ii(this,vi,!0);return Qt(this,vi)}toString(){return Qt(this,Ec)!==void 0?Qt(this,Ec):this.type?ii(this,Ec,this.type+"("+Qt(this,Hr).map(t=>String(t)).join("|")+")"):ii(this,Ec,Qt(this,Hr).map(t=>String(t)).join(""))}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof Cn&&Qt(r,ui)===this))throw new Error("invalid part: "+r);Qt(this,Hr).push(r)}}toJSON(){let t=this.type===null?Qt(this,Hr).slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...Qt(this,Hr).map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===Qt(this,di)||Qt(Qt(this,di),Xo)&&Qt(this,ui)?.type==="!")&&t.push({}),t}isStart(){if(Qt(this,di)===this)return!0;if(!Qt(this,ui)?.isStart())return!1;if(Qt(this,zo)===0)return!0;let t=Qt(this,ui);for(let r=0;r<Qt(this,zo);r++){let i=Qt(t,Hr)[r];if(!(i instanceof Cn&&i.type==="!"))return!1}return!0}isEnd(){if(Qt(this,di)===this||Qt(this,ui)?.type==="!")return!0;if(!Qt(this,ui)?.isEnd())return!1;if(!this.type)return Qt(this,ui)?.isEnd();let t=Qt(this,ui)?Qt(Qt(this,ui),Hr).length:0;return Qt(this,zo)===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new Cn(this.type,t);for(let i of Qt(this,Hr))r.copyIn(i);return r}static fromGlob(t,r={}){var n;let i=new Cn(null,void 0,r);return Lc(n=Cn,bl,oI).call(n,t,i,0,r),i}toMMPattern(){if(this!==Qt(this,di))return Qt(this,di).toMMPattern();let t=this.toString(),[r,i,n,s]=this.toRegExpSource();if(!(n||Qt(this,vi)||Qt(this,is).nocase&&!Qt(this,is).nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let o=(Qt(this,is).nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${r}$`,o),{_src:r,_glob:t})}toRegExpSource(){if(Qt(this,di)===this&&Lc(this,AI,pU).call(this),!this.type){let n=this.isStart()&&this.isEnd(),s=Qt(this,Hr).map(u=>{var v;let[l,m,I,E]=typeof u=="string"?Lc(v=Cn,cI,gU).call(v,u,Qt(this,vi),n):u.toRegExpSource();return ii(this,vi,Qt(this,vi)||I),ii(this,ao,Qt(this,ao)||E),l}).join(""),a="";if(this.isStart()&&typeof Qt(this,Hr)[0]=="string"&&!(Qt(this,Hr).length===1&&Wce.has(Qt(this,Hr)[0]))){let l=Vce,m=Qt(this,is).dot&&l.has(s.charAt(0))||s.startsWith("\\.")&&l.has(s.charAt(2))||s.startsWith("\\.\\.")&&l.has(s.charAt(4)),I=!Qt(this,is).dot&&l.has(s.charAt(0));a=m?Kce:I?mv:""}let o="";return this.isEnd()&&Qt(Qt(this,di),Xo)&&Qt(this,ui)?.type==="!"&&(o="(?:$|\\/)"),[a+s+o,Wo(s),ii(this,vi,!!Qt(this,vi)),Qt(this,ao)]}let t=this.type==="!"?"(?:(?!(?:":"(?:",r=Qt(this,Hr).map(n=>{if(typeof n=="string")throw new Error("string type in extglob ast??");let[s,a,o,A]=n.toRegExpSource();return ii(this,ao,Qt(this,ao)||A),s}).filter(n=>!(this.isStart()&&this.isEnd())||!!n).join("|");if(this.isStart()&&this.isEnd()&&!r&&this.type!=="!"){let n=this.toString();return ii(this,Hr,[n]),this.type=null,ii(this,vi,void 0),[n,Wo(this.toString()),!1,!1]}let i="";if(this.type==="!"&&Qt(this,Ep))i=(this.isStart()&&!Qt(this,is).dot?mv:"")+hU;else{let n=this.type==="!"?"))"+(this.isStart()&&!Qt(this,is).dot?mv:"")+fU+")":this.type==="@"?")":`)${this.type}`;i=t+r+n}return[i,Wo(r),ii(this,vi,!!Qt(this,vi)),Qt(this,ao)]}},Zo=Cn;di=new WeakMap,vi=new WeakMap,ao=new WeakMap,Hr=new WeakMap,ui=new WeakMap,zo=new WeakMap,dc=new WeakMap,Xo=new WeakMap,is=new WeakMap,Ec=new WeakMap,Ep=new WeakMap,AI=new WeakSet,pU=function(){if(this!==Qt(this,di))throw new Error("should only call on root");if(Qt(this,Xo))return this;this.toString(),ii(this,Xo,!0);let t;for(;t=Qt(this,dc).pop();){if(t.type!=="!")continue;let r=t,i=Qt(r,ui);for(;i;){for(let n=Qt(r,zo)+1;!i.type&&n<Qt(i,Hr).length;n++)for(let s of Qt(t,Hr)){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(Qt(i,Hr)[n])}r=i,i=Qt(r,ui)}}return this},bl=new WeakSet,oI=function(t,r,i,n){var E,v;let s=!1,a=!1,o=-1,A=!1;if(r.type===null){let N=i,L="";for(;N<t.length;){let q=t.charAt(N++);if(s||q==="\\"){s=!s,L+=q;continue}if(a){N===o+1?(q==="^"||q==="!")&&(A=!0):q==="]"&&!(N===o+2&&A)&&(a=!1),L+=q;continue}else if(q==="["){a=!0,o=N,A=!1,L+=q;continue}if(!n.noext&&lU(q)&&t.charAt(N)==="("){r.push(L),L="";let M=new Cn(q,r);N=Lc(E=Cn,bl,oI).call(E,t,M,N,n),r.push(M);continue}L+=q}return r.push(L),N}let u=i+1,l=new Cn(null,r),m=[],I="";for(;u<t.length;){let N=t.charAt(u++);if(s||N==="\\"){s=!s,I+=N;continue}if(a){u===o+1?(N==="^"||N==="!")&&(A=!0):N==="]"&&!(u===o+2&&A)&&(a=!1),I+=N;continue}else if(N==="["){a=!0,o=u,A=!1,I+=N;continue}if(lU(N)&&t.charAt(u)==="("){l.push(I),I="";let L=new Cn(N,l);l.push(L),u=Lc(v=Cn,bl,oI).call(v,t,L,u,n);continue}if(N==="|"){l.push(I),I="",m.push(l),l=new Cn(null,r);continue}if(N===")")return I===""&&Qt(r,Hr).length===0&&ii(r,Ep,!0),l.push(I),I="",r.push(...m,l),u;I+=N}return r.type=null,ii(r,vi,void 0),ii(r,Hr,[t.substring(i-1)]),u},cI=new WeakSet,gU=function(t,r,i=!1){let n=!1,s="",a=!1;for(let o=0;o<t.length;o++){let A=t.charAt(o);if(n){n=!1,s+=(zce.has(A)?"\\":"")+A;continue}if(A==="\\"){o===t.length-1?s+="\\\\":n=!0;continue}if(A==="["){let[u,l,m,I]=uU(t,o);if(m){s+=u,a=a||l,o+=m-1,r=r||I;continue}}if(A==="*"){i&&t==="*"?s+=hU:s+=fU,r=!0;continue}if(A==="?"){s+=yv,r=!0;continue}s+=Xce(A)}return[s,Wo(t),!!r,a]},ji(Zo,bl),ji(Zo,cI);var Cv=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var Ti=(e,t,r={})=>(gp(t),!r.nocomment&&t.charAt(0)==="#"?!1:new vl(t,r).match(e)),Zce=/^\*+([^+@!?\*\[\(]*)$/,eue=e=>t=>!t.startsWith(".")&&t.endsWith(e),tue=e=>t=>t.endsWith(e),rue=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),iue=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),nue=/^\*+\.\*+$/,sue=e=>!e.startsWith(".")&&e.includes("."),aue=e=>e!=="."&&e!==".."&&e.includes("."),oue=/^\.\*+$/,Aue=e=>e!=="."&&e!==".."&&e.startsWith("."),cue=/^\*+$/,uue=e=>e.length!==0&&!e.startsWith("."),lue=e=>e.length!==0&&e!=="."&&e!=="..",fue=/^\?+([^+@!?\*\[\(]*)?$/,hue=([e,t=""])=>{let r=BU([e]);return t?(t=t.toLowerCase(),i=>r(i)&&i.toLowerCase().endsWith(t)):r},pue=([e,t=""])=>{let r=mU([e]);return t?(t=t.toLowerCase(),i=>r(i)&&i.toLowerCase().endsWith(t)):r},gue=([e,t=""])=>{let r=mU([e]);return t?i=>r(i)&&i.endsWith(t):r},due=([e,t=""])=>{let r=BU([e]);return t?i=>r(i)&&i.endsWith(t):r},BU=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},mU=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},yU=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",dU={win32:{sep:"\\"},posix:{sep:"/"}},Eue=yU==="win32"?dU.win32.sep:dU.posix.sep;Ti.sep=Eue;var ss=Symbol("globstar **");Ti.GLOBSTAR=ss;var Iue="[^/]",Bue=Iue+"*?",mue="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",yue="(?:(?!(?:\\/|^)\\.).)*?",Cue=(e,t={})=>r=>Ti(r,e,t);Ti.filter=Cue;var ns=(e,t={})=>Object.assign({},e,t),Que=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return Ti;let t=Ti;return Object.assign((i,n,s={})=>t(i,n,ns(e,s)),{Minimatch:class extends t.Minimatch{constructor(n,s={}){super(n,ns(e,s))}static defaults(n){return t.defaults(ns(e,n)).Minimatch}},AST:class extends t.AST{constructor(n,s,a={}){super(n,s,ns(e,a))}static fromGlob(n,s={}){return t.AST.fromGlob(n,ns(e,s))}},unescape:(i,n={})=>t.unescape(i,ns(e,n)),escape:(i,n={})=>t.escape(i,ns(e,n)),filter:(i,n={})=>t.filter(i,ns(e,n)),defaults:i=>t.defaults(ns(e,i)),makeRe:(i,n={})=>t.makeRe(i,ns(e,n)),braceExpand:(i,n={})=>t.braceExpand(i,ns(e,n)),match:(i,n,s={})=>t.match(i,n,ns(e,s)),sep:t.sep,GLOBSTAR:ss})};Ti.defaults=Que;var CU=(e,t={})=>(gp(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:(0,IU.default)(e));Ti.braceExpand=CU;var wue=(e,t={})=>new vl(e,t).makeRe();Ti.makeRe=wue;var bue=(e,t,r={})=>{let i=new vl(t,r);return e=e.filter(n=>i.match(n)),i.options.nonull&&!e.length&&e.push(t),e};Ti.match=bue;var EU=/[?*]|[+@!]\(.*?\)|\[|\]/,vue=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),vl=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,r={}){gp(t),r=r||{},this.options=r,this.pattern=t,this.platform=r.platform||yU,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let i=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(i),this.debug(this.pattern,this.globParts);let n=this.globParts.map((s,a,o)=>{if(this.isWindows&&this.windowsNoMagicRoot){let A=s[0]===""&&s[1]===""&&(s[2]==="?"||!EU.test(s[2]))&&!EU.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(A)return[...s.slice(0,4),...s.slice(4).map(l=>this.parse(l))];if(u)return[s[0],...s.slice(1).map(l=>this.parse(l))]}return s.map(A=>this.parse(A))});if(this.debug(this.pattern,n),this.set=n.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let a=this.set[s];a[0]===""&&a[1]===""&&this.globParts[s][2]==="?"&&typeof a[3]=="string"&&/^[a-z]:$/i.test(a[3])&&(a[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let i=0;i<t.length;i++)for(let n=0;n<t[i].length;n++)t[i][n]==="**"&&(t[i][n]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let i=-1;for(;(i=r.indexOf("**",i+1))!==-1;){let n=i;for(;r[n+1]==="**";)n++;n!==i&&r.splice(i,n-i)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((i,n)=>{let s=i[i.length-1];return n==="**"&&s==="**"?i:n===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(i.pop(),i):(i.push(n),i)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let n=1;n<t.length-1;n++){let s=t[n];n===1&&s===""&&t[0]===""||(s==="."||s==="")&&(r=!0,t.splice(n,1),n--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let i=0;for(;(i=t.indexOf("..",i+1))!==-1;){let n=t[i-1];n&&n!=="."&&n!==".."&&n!=="**"&&(r=!0,t.splice(i-1,2),i-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let i of t){let n=-1;for(;(n=i.indexOf("**",n+1))!==-1;){let a=n;for(;i[a+1]==="**";)a++;a>n&&i.splice(n+1,a-n);let o=i[n+1],A=i[n+2],u=i[n+3];if(o!==".."||!A||A==="."||A===".."||!u||u==="."||u==="..")continue;r=!0,i.splice(n,1);let l=i.slice(0);l[n]="**",t.push(l),n--}if(!this.preserveMultipleSlashes){for(let a=1;a<i.length-1;a++){let o=i[a];a===1&&o===""&&i[0]===""||(o==="."||o==="")&&(r=!0,i.splice(a,1),a--)}i[0]==="."&&i.length===2&&(i[1]==="."||i[1]==="")&&(r=!0,i.pop())}let s=0;for(;(s=i.indexOf("..",s+1))!==-1;){let a=i[s-1];if(a&&a!=="."&&a!==".."&&a!=="**"){r=!0;let A=s===1&&i[s+1]==="**"?["."]:[];i.splice(s-1,2,...A),i.length===0&&i.push(""),s-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let i=r+1;i<t.length;i++){let n=this.partsMatch(t[r],t[i],!this.preserveMultipleSlashes);n&&(t[r]=n,t[i]=[])}return t.filter(r=>r.length)}partsMatch(t,r,i=!1){let n=0,s=0,a=[],o="";for(;n<t.length&&s<r.length;)if(t[n]===r[s])a.push(o==="b"?r[s]:t[n]),n++,s++;else if(i&&t[n]==="**"&&r[s]===t[n+1])a.push(t[n]),n++;else if(i&&r[s]==="**"&&t[n]===r[s+1])a.push(r[s]),s++;else if(t[n]==="*"&&r[s]&&(this.options.dot||!r[s].startsWith("."))&&r[s]!=="**"){if(o==="b")return!1;o="a",a.push(t[n]),n++,s++}else if(r[s]==="*"&&t[n]&&(this.options.dot||!t[n].startsWith("."))&&t[n]!=="**"){if(o==="a")return!1;o="b",a.push(r[s]),n++,s++}else return!1;return t.length===r.length&&a}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,i=0;for(let n=0;n<t.length&&t.charAt(n)==="!";n++)r=!r,i++;i&&(this.pattern=t.slice(i)),this.negate=r}matchOne(t,r,i=!1){let n=this.options;if(this.isWindows){let N=t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),L=r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]);if(N&&L){let q=t[3],M=r[3];q.toLowerCase()===M.toLowerCase()&&(t[3]=M)}else if(L&&typeof t[0]=="string"){let q=r[3],M=t[0];q.toLowerCase()===M.toLowerCase()&&(r[3]=M,r=r.slice(3))}else if(N&&typeof r[0]=="string"){let q=t[3];q.toLowerCase()===r[0].toLowerCase()&&(r[0]=q,t=t.slice(3))}}let{optimizationLevel:s=1}=this.options;s>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:r}),this.debug("matchOne",t.length,r.length);for(var a=0,o=0,A=t.length,u=r.length;a<A&&o<u;a++,o++){this.debug("matchOne loop");var l=r[o],m=t[a];if(this.debug(r,l,m),l===!1)return!1;if(l===ss){this.debug("GLOBSTAR",[r,l,m]);var I=a,E=o+1;if(E===u){for(this.debug("** at the end");a<A;a++)if(t[a]==="."||t[a]===".."||!n.dot&&t[a].charAt(0)===".")return!1;return!0}for(;I<A;){var v=t[I];if(this.debug(`
280
280
  globstar while`,t,I,r,E,v),this.matchOne(t.slice(I),r.slice(E),i))return this.debug("globstar found match!",I,A,v),!0;if(v==="."||v===".."||!n.dot&&v.charAt(0)==="."){this.debug("dot detected!",t,I,r,E);break}this.debug("globstar swallow a segment, and continue"),I++}return!!(i&&(this.debug(`
281
- >>> no match, partial?`,t,I,r,E),I===A))}let N;if(typeof l=="string"?(N=m===l,this.debug("string match",l,m,N)):(N=l.test(m),this.debug("pattern match",l,m,N)),!N)return!1}if(a===A&&o===u)return!0;if(a===A)return i;if(o===u)return a===A-1&&t[a]==="";throw new Error("wtf?")}braceExpand(){return CU(this.pattern,this.options)}parse(t){gp(t);let r=this.options;if(t==="**")return ss;if(t==="")return"";let i,n=null;(i=t.match(cue))?n=r.dot?lue:uue:(i=t.match(Zce))?n=(r.nocase?r.dot?iue:rue:r.dot?tue:eue)(i[1]):(i=t.match(fue))?n=(r.nocase?r.dot?pue:hue:r.dot?gue:due)(i):(i=t.match(nue))?n=r.dot?aue:sue:(i=t.match(oue))&&(n=Aue);let s=Zo.fromGlob(t,this.options).toMMPattern();return n?Object.assign(s,{test:n}):s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,i=r.noglobstar?Bue:r.dot?mue:yue,n=new Set(r.nocase?["i"]:[]),s=t.map(A=>{let u=A.map(l=>{if(l instanceof RegExp)for(let m of l.flags.split(""))n.add(m);return typeof l=="string"?vue(l):l===ss?ss:l._src});return u.forEach((l,m)=>{let I=u[m+1],E=u[m-1];l!==ss||E===ss||(E===void 0?I!==void 0&&I!==ss?u[m+1]="(?:\\/|"+i+"\\/)?"+I:u[m]=i:I===void 0?u[m-1]=E+"(?:\\/|"+i+")?":I!==ss&&(u[m-1]=E+"(?:\\/|\\/"+i+"\\/)"+I,u[m+1]=ss))}),u.filter(l=>l!==ss).join("/")}).join("|"),[a,o]=t.length>1?["(?:",")"]:["",""];s="^"+a+s+o+"$",this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...n].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let i=this.options;this.isWindows&&(t=t.split("\\").join("/"));let n=this.slashSplit(t);this.debug(this.pattern,"split",n);let s=this.set;this.debug(this.pattern,"set",s);let a=n[n.length-1];if(!a)for(let o=n.length-2;!a&&o>=0;o--)a=n[o];for(let o=0;o<s.length;o++){let A=s[o],u=n;if(i.matchBase&&A.length===1&&(u=[a]),this.matchOne(u,A,r))return i.flipNegate?!0:!this.negate}return i.flipNegate?!1:this.negate}static defaults(t){return Ti.defaults(t).Minimatch}};Ti.AST=Zo;Ti.Minimatch=vl;Ti.escape=Cv;Ti.unescape=Wo;import{basename as Rue,extname as Qv,join as wv}from"path";var vU=async()=>{await Tn()||await Cl();let{satelliteId:e,source:t=Zx,ignore:r=[]}=await ts(),i=wv(process.cwd(),t),n=await Mue({sourceAbsolutePath:i,satelliteId:e,ignore:r});if(n.length===0){console.log("No new files to upload.");return}let s=Fn(e),a=A=>A.alternateFile??A.file,o=async A=>{let u=a(A);return jF({satellite:s,filename:Rue(u),fullPath:xU({file:u,sourceAbsolutePath:i}),data:new xue([await wU(A.file)]),collection:eS,headers:[...A.mime===void 0?[]:[["Content-Type",A.mime]]],encoding:A.encoding})};for(let A=0;A<n.length;A+=20){let u=n.slice(A,A+20);u.forEach(m=>console.log(`\u2197\uFE0F ${(0,uI.grey)(a(m))}`));let l=Ts("Uploading...").start();try{let m=u.map(o);await Promise.all(m),l.stop(),u.forEach(I=>console.log(`\u2705 ${(0,uI.green)(a(I))}`))}catch(m){throw l.stop(),m}}},xU=({file:e,sourceAbsolutePath:t})=>e.replace(t,"").replace(/\\/g,"/"),SU=e=>Due(e).flatMap(t=>{let r=wv(e,t);return _ue(r).isDirectory()?SU(r):wv(r)}),Nue=async({files:e,sourceAbsolutePath:t,satelliteId:r})=>{let i=await JF({collection:nd,satellite:Fn(r)}),n=e.map(a=>Fue({file:a,sourceAbsolutePath:t,existingAssets:i}));return(await Promise.all(n)).filter(({upload:a})=>a).map(({file:a})=>a)},Tue=async e=>{let t=await wU(e);return Sue.createHash("sha256").update(t).digest("base64")},Fue=async({file:e,existingAssets:t,sourceAbsolutePath:r})=>{let i=e.alternateFile??e.file,n=t.assets.find(({fullPath:a})=>a===xU({file:i,sourceAbsolutePath:r}));if(!n)return{file:e,upload:!0};let s=await Tue(i);return{file:e,upload:s!==n.encodings.identity?.sha256}},Mue=async({sourceAbsolutePath:e,satelliteId:t,ignore:r})=>{let n=SU(e).filter(u=>r.find(l=>Ti(u,l))===void 0),s=({file:u,ext:l})=>{if(l==="Z")return"compress";if(l==="gz")return"gzip";if(Qv(u)===".br")return"br";if(Qv(u)===".zlib")return"deflate"},a=({file:u,encodingType:l})=>{if(l)return n.find(m=>m===u.replace(Qv(u),""))},o=async u=>{let l=await HO(u),m=s({file:u,ext:l?.ext}),I=a({file:u,encodingType:m}),E=bU.default.lookup(I??u);return{file:u,alternateFile:I,mime:typeof E=="string"?E:void 0,encoding:m}},A=await Promise.all(n.map(o));return Nue({files:A,sourceAbsolutePath:e,satelliteId:t})};var Er=zt(cr(),1);var lI="0.0.30";var Oue=` __ __ __ __ _ ____
281
+ >>> no match, partial?`,t,I,r,E),I===A))}let N;if(typeof l=="string"?(N=m===l,this.debug("string match",l,m,N)):(N=l.test(m),this.debug("pattern match",l,m,N)),!N)return!1}if(a===A&&o===u)return!0;if(a===A)return i;if(o===u)return a===A-1&&t[a]==="";throw new Error("wtf?")}braceExpand(){return CU(this.pattern,this.options)}parse(t){gp(t);let r=this.options;if(t==="**")return ss;if(t==="")return"";let i,n=null;(i=t.match(cue))?n=r.dot?lue:uue:(i=t.match(Zce))?n=(r.nocase?r.dot?iue:rue:r.dot?tue:eue)(i[1]):(i=t.match(fue))?n=(r.nocase?r.dot?pue:hue:r.dot?gue:due)(i):(i=t.match(nue))?n=r.dot?aue:sue:(i=t.match(oue))&&(n=Aue);let s=Zo.fromGlob(t,this.options).toMMPattern();return n?Object.assign(s,{test:n}):s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,i=r.noglobstar?Bue:r.dot?mue:yue,n=new Set(r.nocase?["i"]:[]),s=t.map(A=>{let u=A.map(l=>{if(l instanceof RegExp)for(let m of l.flags.split(""))n.add(m);return typeof l=="string"?vue(l):l===ss?ss:l._src});return u.forEach((l,m)=>{let I=u[m+1],E=u[m-1];l!==ss||E===ss||(E===void 0?I!==void 0&&I!==ss?u[m+1]="(?:\\/|"+i+"\\/)?"+I:u[m]=i:I===void 0?u[m-1]=E+"(?:\\/|"+i+")?":I!==ss&&(u[m-1]=E+"(?:\\/|\\/"+i+"\\/)"+I,u[m+1]=ss))}),u.filter(l=>l!==ss).join("/")}).join("|"),[a,o]=t.length>1?["(?:",")"]:["",""];s="^"+a+s+o+"$",this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...n].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let i=this.options;this.isWindows&&(t=t.split("\\").join("/"));let n=this.slashSplit(t);this.debug(this.pattern,"split",n);let s=this.set;this.debug(this.pattern,"set",s);let a=n[n.length-1];if(!a)for(let o=n.length-2;!a&&o>=0;o--)a=n[o];for(let o=0;o<s.length;o++){let A=s[o],u=n;if(i.matchBase&&A.length===1&&(u=[a]),this.matchOne(u,A,r))return i.flipNegate?!0:!this.negate}return i.flipNegate?!1:this.negate}static defaults(t){return Ti.defaults(t).Minimatch}};Ti.AST=Zo;Ti.Minimatch=vl;Ti.escape=Cv;Ti.unescape=Wo;import{basename as Rue,extname as Qv,join as wv}from"path";var vU=async()=>{await Tn()||await Cl();let{satelliteId:e,source:t=Zx,ignore:r=[]}=await ts(),i=wv(process.cwd(),t),n=await Mue({sourceAbsolutePath:i,satelliteId:e,ignore:r});if(n.length===0){console.log("No new files to upload.");return}let s=Fn(e),a=A=>A.alternateFile??A.file,o=async A=>{let u=a(A);return jF({satellite:s,filename:Rue(u),fullPath:xU({file:u,sourceAbsolutePath:i}),data:new xue([await wU(A.file)]),collection:eS,headers:[...A.mime===void 0?[]:[["Content-Type",A.mime]]],encoding:A.encoding})};for(let A=0;A<n.length;A+=20){let u=n.slice(A,A+20);u.forEach(m=>console.log(`\u2197\uFE0F ${(0,uI.grey)(a(m))}`));let l=Ts("Uploading...").start();try{let m=u.map(o);await Promise.all(m),l.stop(),u.forEach(I=>console.log(`\u2705 ${(0,uI.green)(a(I))}`))}catch(m){throw l.stop(),m}}},xU=({file:e,sourceAbsolutePath:t})=>encodeURI(e.replace(t,"").replace(/\\/g,"/")),SU=e=>Due(e).flatMap(t=>{let r=wv(e,t);return _ue(r).isDirectory()?SU(r):wv(r)}),Nue=async({files:e,sourceAbsolutePath:t,satelliteId:r})=>{let i=await JF({collection:nd,satellite:Fn(r)}),n=e.map(a=>Fue({file:a,sourceAbsolutePath:t,existingAssets:i}));return(await Promise.all(n)).filter(({upload:a})=>a).map(({file:a})=>a)},Tue=async e=>{let t=await wU(e);return Sue.createHash("sha256").update(t).digest("base64")},Fue=async({file:e,existingAssets:t,sourceAbsolutePath:r})=>{let i=e.alternateFile??e.file,n=t.assets.find(({fullPath:a})=>a===xU({file:i,sourceAbsolutePath:r}));if(!n)return{file:e,upload:!0};let s=await Tue(i);return{file:e,upload:s!==n.encodings.identity?.sha256}},Mue=async({sourceAbsolutePath:e,satelliteId:t,ignore:r})=>{let n=SU(e).filter(u=>r.find(l=>Ti(u,l))===void 0),s=({file:u,ext:l})=>{if(l==="Z")return"compress";if(l==="gz")return"gzip";if(Qv(u)===".br")return"br";if(Qv(u)===".zlib")return"deflate"},a=({file:u,encodingType:l})=>{if(l)return n.find(m=>m===u.replace(Qv(u),""))},o=async u=>{let l=await HO(u),m=s({file:u,ext:l?.ext}),I=a({file:u,encodingType:m}),E=bU.default.lookup(I??u);return{file:u,alternateFile:I,mime:typeof E=="string"?E:void 0,encoding:m}},A=await Promise.all(n.map(o));return Nue({files:A,sourceAbsolutePath:e,satelliteId:t})};var Er=zt(cr(),1);var lI="0.0.31";var Oue=` __ __ __ __ _ ____
282
282
  __) || | || \\| |/ \\
283
283
  \\___/ \\___/ |_|\\__|\\____/`,xl=`${Oue} CLI ${(0,Er.grey)(`v${lI}`)}`,bv=`
284
284
  ${xl}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junobuild/cli",
3
- "version": "0.0.30",
3
+ "version": "0.0.31",
4
4
  "description": "The Juno command-line interface",
5
5
  "author": "David Dal Busco (https://daviddalbusco.com)",
6
6
  "license": "MIT",