@junobuild/cli 0.0.55 → 0.0.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2176,7 +2176,7 @@ can workaround this problem by explicitly adding the missing package
2176
2176
  to your top-level package.json.
2177
2177
  `,z}function P(V,re){try{return re?{error:null,value:(((ee,z)=>(ee=ee.split("."),z=z.split("."),+ee[0]>+z[0]||ee[0]==z[0]&&+ee[1]>=+z[1]))(process.versions.node,"8.9")?Lt.resolve:(ee,{paths:[z]},te=Lt("module"))=>{let ue=te._findPath(ee,te._nodeModulePaths(z).concat(z));if(ue)return ue;throw ue=new Error(`Cannot resolve module '${ee}'`),ue.code="MODULE_NOT_FOUND",ue})(V,{paths:[re]})}:{error:null,value:Lt.resolve(V)}}catch(ee){return{error:ee,value:null}}}function Q(V,re){try{return{error:null,value:(0,a.resolve)(V,re)}}catch(ee){return{error:ee,value:null}}}function $(V,re,ee){let z=D(V,re),te=z.next();for(;!te.done;)te=z.next(P(te.value,ee));return te.value}function R(V,re,ee){let z=(0,s().pathToFileURL)(r().join(ee,"./babel-virtual-resolve-base.js")).href,te=D(V,re),ue=te.next();for(;!ue.done;)ue=te.next(Q(ue.value,z));return(0,s().fileURLToPath)(ue.value)}function W(V,re,ee,z){if(!i.supportsESM||!z)return $(V,re,ee);try{let te=R(V,re,ee);if(!(0,c().existsSync)(te))throw Object.assign(new Error(`Could not resolve "${re}" in file ${ee}.`),{type:"MODULE_NOT_FOUND"});return te}catch(te){try{return $(V,re,ee)}catch(ue){throw te.type==="MODULE_NOT_FOUND"?te:ue.type==="MODULE_NOT_FOUND"?ue:te}}}Y=new Set;var Y;function*N(V,re){if(!(yield*(0,n.isAsync)())&&Y.has(re))throw new Error(`Reentrant ${V} detected trying to load "${re}". This module is not ignored and is trying to load itself while compiling itself, leading to a dependency cycle. We recommend adding it to your "ignore" list in your babelrc, or to a .babelignore.`);try{return Y.add(re),yield*(0,i.default)(re,`You appear to be using a native ECMAScript module ${V}, which is only supported when running Babel asynchronously.`,!0)}catch(ee){throw ee.message=`[BABEL]: ${ee.message} (While processing: ${re})`,ee}finally{Y.delete(re)}}}),uE=Pe(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"ROOT_CONFIG_FILENAMES",{enumerable:!0,get:function(){return r.ROOT_CONFIG_FILENAMES}}),Object.defineProperty(e,"findConfigUpwards",{enumerable:!0,get:function(){return r.findConfigUpwards}}),Object.defineProperty(e,"findPackageData",{enumerable:!0,get:function(){return t.findPackageData}}),Object.defineProperty(e,"findRelativeConfig",{enumerable:!0,get:function(){return r.findRelativeConfig}}),Object.defineProperty(e,"findRootConfig",{enumerable:!0,get:function(){return r.findRootConfig}}),Object.defineProperty(e,"loadConfig",{enumerable:!0,get:function(){return r.loadConfig}}),Object.defineProperty(e,"loadPlugin",{enumerable:!0,get:function(){return n.loadPlugin}}),Object.defineProperty(e,"loadPreset",{enumerable:!0,get:function(){return n.loadPreset}}),Object.defineProperty(e,"resolvePlugin",{enumerable:!0,get:function(){return n.resolvePlugin}}),Object.defineProperty(e,"resolvePreset",{enumerable:!0,get:function(){return n.resolvePreset}}),Object.defineProperty(e,"resolveShowConfigPath",{enumerable:!0,get:function(){return r.resolveShowConfigPath}});var t=Tye(),r=Pge(),n=Fge()}),Nge=Pe(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.transform=void 0,e.transformAsync=l,e.transformSync=c;function t(){let p=_o();return t=function(){return p},p}var r=U0(),n=uB(),i=np(),s=t()(function*(p,u){let f=yield*(0,r.default)(u);return f===null?null:yield*(0,n.run)(f,p)}),a=e.transform=function(p,u,f){let h,d;if(typeof u=="function"?(d=u,h=void 0):(h=u,d=f),d===void 0)return(0,i.beginHiddenCallStack)(s.sync)(p,h);(0,i.beginHiddenCallStack)(s.errback)(p,h,d)};function c(...p){return(0,i.beginHiddenCallStack)(s.sync)(...p)}function l(...p){return(0,i.beginHiddenCallStack)(s.async)(...p)}}),kge=Pe(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.transformFromAst=void 0,e.transformFromAstAsync=l,e.transformFromAstSync=c;function t(){let p=_o();return t=function(){return p},p}var r=U0(),n=uB(),i=np(),s=t()(function*(p,u,f){let h=yield*(0,r.default)(f);if(h===null)return null;if(!p)throw new Error("No AST given");return yield*(0,n.run)(h,u,p)}),a=e.transformFromAst=function(p,u,f,h){let d,A;if(typeof f=="function"?(A=f,d=void 0):(d=f,A=h),A===void 0)return(0,i.beginHiddenCallStack)(s.sync)(p,u,d);(0,i.beginHiddenCallStack)(s.errback)(p,u,d,A)};function c(...p){return(0,i.beginHiddenCallStack)(s.sync)(...p)}function l(...p){return(0,i.beginHiddenCallStack)(s.async)(...p)}}),Rge=Pe(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.parse=void 0,e.parseAsync=p,e.parseSync=l;function t(){let u=_o();return t=function(){return u},u}var r=U0(),n=TQ(),i=IQ(),s=np(),a=t()(function*(u,f){let h=yield*(0,r.default)(f);return h===null?null:yield*(0,n.default)(h.passes,(0,i.default)(h),u)}),c=e.parse=function(u,f,h){if(typeof f=="function"&&(h=f,f=void 0),h===void 0)return(0,s.beginHiddenCallStack)(a.sync)(u,f);(0,s.beginHiddenCallStack)(a.errback)(u,f,h)};function l(...u){return(0,s.beginHiddenCallStack)(a.sync)(...u)}function p(...u){return(0,s.beginHiddenCallStack)(a.async)(...u)}}),ai=Pe(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_EXTENSIONS=void 0,Object.defineProperty(e,"File",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(e,"buildExternalHelpers",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(e,"createConfigItem",{enumerable:!0,get:function(){return p.createConfigItem}}),Object.defineProperty(e,"createConfigItemAsync",{enumerable:!0,get:function(){return p.createConfigItemAsync}}),Object.defineProperty(e,"createConfigItemSync",{enumerable:!0,get:function(){return p.createConfigItemSync}}),Object.defineProperty(e,"getEnv",{enumerable:!0,get:function(){return i.getEnv}}),Object.defineProperty(e,"loadOptions",{enumerable:!0,get:function(){return p.loadOptions}}),Object.defineProperty(e,"loadOptionsAsync",{enumerable:!0,get:function(){return p.loadOptionsAsync}}),Object.defineProperty(e,"loadOptionsSync",{enumerable:!0,get:function(){return p.loadOptionsSync}}),Object.defineProperty(e,"loadPartialConfig",{enumerable:!0,get:function(){return p.loadPartialConfig}}),Object.defineProperty(e,"loadPartialConfigAsync",{enumerable:!0,get:function(){return p.loadPartialConfigAsync}}),Object.defineProperty(e,"loadPartialConfigSync",{enumerable:!0,get:function(){return p.loadPartialConfigSync}}),Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return d.parse}}),Object.defineProperty(e,"parseAsync",{enumerable:!0,get:function(){return d.parseAsync}}),Object.defineProperty(e,"parseSync",{enumerable:!0,get:function(){return d.parseSync}}),Object.defineProperty(e,"resolvePlugin",{enumerable:!0,get:function(){return n.resolvePlugin}}),Object.defineProperty(e,"resolvePreset",{enumerable:!0,get:function(){return n.resolvePreset}}),Object.defineProperty(e,"template",{enumerable:!0,get:function(){return l().default}}),Object.defineProperty(e,"tokTypes",{enumerable:!0,get:function(){return a().tokTypes}}),Object.defineProperty(e,"transform",{enumerable:!0,get:function(){return u.transform}}),Object.defineProperty(e,"transformAsync",{enumerable:!0,get:function(){return u.transformAsync}}),Object.defineProperty(e,"transformFile",{enumerable:!0,get:function(){return f.transformFile}}),Object.defineProperty(e,"transformFileAsync",{enumerable:!0,get:function(){return f.transformFileAsync}}),Object.defineProperty(e,"transformFileSync",{enumerable:!0,get:function(){return f.transformFileSync}}),Object.defineProperty(e,"transformFromAst",{enumerable:!0,get:function(){return h.transformFromAst}}),Object.defineProperty(e,"transformFromAstAsync",{enumerable:!0,get:function(){return h.transformFromAstAsync}}),Object.defineProperty(e,"transformFromAstSync",{enumerable:!0,get:function(){return h.transformFromAstSync}}),Object.defineProperty(e,"transformSync",{enumerable:!0,get:function(){return u.transformSync}}),Object.defineProperty(e,"traverse",{enumerable:!0,get:function(){return c().default}}),e.version=e.types=void 0;var t=ZT(),r=Sye(),n=uE(),i=wQ();function s(){let x=Yt();return s=function(){return x},x}Object.defineProperty(e,"types",{enumerable:!0,get:function(){return s()}});function a(){let x=nE();return a=function(){return x},x}function c(){let x=Jl();return c=function(){return x},x}function l(){let x=Q0();return l=function(){return x},x}var p=U0(),u=Nge(),f=BQ(),h=kge(),d=Rge(),A=ai(),E=e.version="7.23.9",b=e.DEFAULT_EXTENSIONS=Object.freeze([".js",".jsx",".es6",".es",".mjs",".cjs"]);e.OptionManager=class{init(x){return(0,p.loadOptionsSync)(x)}},e.Plugin=function(x){throw new Error(`The (${x}) Babel 5 plugin is being run with an unsupported Babel version.`)}}),Lge=UT(ai(),1),Qge=UT(jQ(),1),$ge=UT(LQ(),1),qge=e=>{delete Lt.cache[e];let t=Lt("module"),r=t._load;try{return Lt.extensions[".ts"]=(n,i)=>{let s=Uge(i,"utf8");i.endsWith(".ts")?s=(0,Lge.transformFileSync)(i,{presets:[$ge.default],plugins:[Qge.default]}).code:s=s.replace(/export\s+\w+\s+(\w+)/gm,"exports.$1"),n._compile(s,i)},t._load=function(n){return n==="@junobuild/config"?{defineConfig:i=>i,defineDevConfig:i=>i}:r.apply(this,arguments)},Lt(e)}finally{Lt.extensions[".ts"]=void 0,t._load=r}},lE=async e=>{try{let{configPath:t}=Uf(e);return await Mge(t),!0}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return!1;throw t}},Uf=({filename:e})=>{let t=Mf(process.cwd(),`${e}.ts`);if(R0(t))return{configPath:t,configType:"ts"};let r=Mf(process.cwd(),`${e}.js`);if(R0(r))return{configPath:r,configType:"js"};let n=Mf(process.cwd(),`${e}.mjs`);if(R0(n))return{configPath:n,configType:"js"};let i=Mf(process.cwd(),`${e}.cjs`);if(R0(i))return{configPath:i,configType:"js"};let s=Mf(process.cwd(),`${e.replace(".config","")}.json`);return R0(s)?{configPath:s,configType:"json"}:{configPath:Mf(process.cwd(),`${e}.json`),configType:"json"}},$Q=async({config:e,...t})=>{let{configPath:r,configType:n}=Uf({...t});switch(n){case"ts":{let{default:i}=qge(r);return e(i)}case"js":{let{default:i}=await import(r);return e(i)}default:{let i=await jge(r);return JSON.parse(i.toString("utf-8"))}}};import{writeFile as JQ}from"node:fs/promises";var UQ="../templates/init",qQ="juno.satellite.config";var cE="build",GQ=[],VQ=[],pE="**/*.+(css|js|mjs)",HQ="0.0.14",WQ=900000000n;var YQ=Bt(zt(),1);import{existsSync as Wge}from"node:fs";import{copyFile as Kge,readFile as Yge}from"node:fs/promises";import{dirname as zge,join as pB,relative as Jge}from"node:path";import{fileURLToPath as Xge}from"url";var KQ=Bt(Gc(),1),Fi=`
2178
2178
  `,Gge=()=>{process.stdout.write("\x1B[?25h")},Vge=e=>{e.aborted&&(Gge(),process.stdout.write(`
2179
- `),process.exit(1))},Hge=async e=>{let{answer:t}=await(0,KQ.default)([{type:"toggle",name:"answer",message:e,initial:!1,active:"yes",inactive:"no",onState:Vge}]);return t},cB=async e=>await Hge(e),Yi=async e=>{await cB(e)||process.exit(1)};var Zge=Xge(import.meta.url),zQ=zge(Zge),ip=async({sourceFolder:e,destinationFolder:t,template:r,overwrite:n=!1})=>{let i=pB(t,r);!n&&Wge(i)&&!await cB(`File ${(0,YQ.yellow)(Jge(process.cwd(),i))} already exists. Do you want to overwrite it?`)||await Kge(pB(zQ,e,r),i)},qf=async({sourceFolder:e,template:t})=>await Yge(pB(zQ,e,t),"utf-8");var dB={filename:O0},zi=async()=>await lE(dB),XQ=()=>Uf(dB),ZQ=async({config:e,configType:t})=>{switch(t){case"ts":case"js":{let{orbiter:r,satellite:{satelliteId:n,source:i}}=e,a=(await qf({template:Jn(r)?`${O0}.${t}`:`${qQ}.${t}`,sourceFolder:UQ})).replace("<SATELLITE_ID>",n).replace("<SOURCE>",i??cE).replace("<ORBITER_ID>",r?.orbiterId??"");await JQ(`${O0}.${t}`,a,"utf-8");break}default:await JQ(`${O0}.json`,JSON.stringify(e,null,2),"utf-8")}},Ji=async e=>await $Q({...dB,config:r=>typeof r=="function"?r(e):r});var e9=Bt(Gc(),1);var dE=async()=>{let{configType:e}=await(0,e9.default)({type:"select",name:"configType",message:"What configuration file format do you prefer?",choices:[{title:"TypeScript",value:"ts"},{title:"JavaScript",value:"js"},{title:"JSON",value:"json"}],initial:0});return da(e),e};var Gf=async()=>{let e=tp();if(Br(e)){console.log(`No controller found. Run ${(0,ud.cyan)("login")} to get started \u{1F680}.`);return}await zi()&&await Yi("Your existing configuration will be overwritten. Are you sure you want to continue?"),await rbe()},rbe=async()=>{let e=await nbe(),t=await ibe(),r=await obe(),{configType:n,configPath:i}=await abe();await ZQ({config:{satellite:{satelliteId:e,source:r},...Jn(t)&&{orbiter:{orbiterId:t}}},configType:n}),Jn(i)&&tbe(i)==="juno.json"&&await ebe(i),n!=="json"&&console.log(`${Fi}\u{1F4A1} You can leverage your IDE's intellisense with type hints by installing the library: ${(0,ud.yellow)("npm i @junobuild/config -D")}${Fi}`)},nbe=async()=>{let e=k0(),t=await(e?.length>0?sbe(e):t9());return t==="_manual_"?await t9():t},ibe=async()=>{let e=zl();if(e===void 0||e.length===0)return;let t=await ube(e);if(t!=="_none_")return t},sbe=async e=>{let{satellite:t}=await(0,G0.default)({type:"select",name:"satellite",message:"Which satellite should be linked with this dapp?",choices:[...e.map(({p:r,n})=>({title:n,value:r})),{title:"<not listed, manual entry>",value:"_manual_"}],initial:0});return da(t),t},abe=async()=>await zi()?XQ():{configType:await dE()},t9=async()=>{let{satellite:e}=await(0,G0.default)([{type:"text",name:"satellite",message:`What's the ${(0,ud.cyan)("id")} of your satellite?`}]);return da(e,"The satellite ID is mandatory"),e},obe=async()=>{let{source:e}=await(0,G0.default)([{type:"text",name:"source",message:'What is the location of your compiled app files? They are often found in the "build" or "dist" folders.',initial:"build"}]);return da(e),e},da=(e,t)=>{(e===void 0||e===""||e===null)&&(t!==void 0&&console.log(`${(0,ud.red)(t)}`),process.exit(1))},ube=async e=>{let{orbiter:t}=await(0,G0.default)({type:"select",name:"orbiter",message:"Which orbiter do you use for the analytics in this dapp?",choices:[...e.map(({p:r,n})=>({title:n??r,value:r})),{title:"<none>",value:"_none_"}],initial:0});return da(t),t};var Vr="\x1B[",V0="\x1B]",Vf="\x07",fE=";",r9=process.env.TERM_PROGRAM==="Apple_Terminal",wr={};wr.cursorTo=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");return typeof t!="number"?Vr+(e+1)+"G":Vr+(t+1)+";"+(e+1)+"H"};wr.cursorMove=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");let r="";return e<0?r+=Vr+-e+"D":e>0&&(r+=Vr+e+"C"),t<0?r+=Vr+-t+"A":t>0&&(r+=Vr+t+"B"),r};wr.cursorUp=(e=1)=>Vr+e+"A";wr.cursorDown=(e=1)=>Vr+e+"B";wr.cursorForward=(e=1)=>Vr+e+"C";wr.cursorBackward=(e=1)=>Vr+e+"D";wr.cursorLeft=Vr+"G";wr.cursorSavePosition=r9?"\x1B7":Vr+"s";wr.cursorRestorePosition=r9?"\x1B8":Vr+"u";wr.cursorGetPosition=Vr+"6n";wr.cursorNextLine=Vr+"E";wr.cursorPrevLine=Vr+"F";wr.cursorHide=Vr+"?25l";wr.cursorShow=Vr+"?25h";wr.eraseLines=e=>{let t="";for(let r=0;r<e;r++)t+=wr.eraseLine+(r<e-1?wr.cursorUp():"");return e&&(t+=wr.cursorLeft),t};wr.eraseEndLine=Vr+"K";wr.eraseStartLine=Vr+"1K";wr.eraseLine=Vr+"2K";wr.eraseDown=Vr+"J";wr.eraseUp=Vr+"1J";wr.eraseScreen=Vr+"2J";wr.scrollUp=Vr+"S";wr.scrollDown=Vr+"T";wr.clearScreen="\x1Bc";wr.clearTerminal=process.platform==="win32"?`${wr.eraseScreen}${Vr}0f`:`${wr.eraseScreen}${Vr}3J${Vr}H`;wr.beep=Vf;wr.link=(e,t)=>[V0,"8",fE,fE,t,Vf,e,V0,"8",fE,fE,Vf].join("");wr.image=(e,t={})=>{let r=`${V0}1337;File=inline=1`;return t.width&&(r+=`;width=${t.width}`),t.height&&(r+=`;height=${t.height}`),t.preserveAspectRatio===!1&&(r+=";preserveAspectRatio=0"),r+":"+e.toString("base64")+Vf};wr.iTerm={setCwd:(e=process.cwd())=>`${V0}50;CurrentDir=${e}${Vf}`,annotation:(e,t={})=>{let r=`${V0}1337;`,n=typeof t.x<"u",i=typeof t.y<"u";if((n||i)&&!(n&&i&&typeof t.length<"u"))throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");return e=e.replace(/\|/g,""),r+=t.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",t.length>0?r+=(n?[e,t.length,t.x,t.y]:[t.length,e]).join("|"):r+=e,r+Vf}};var n9=wr;var hE=Bt(l9(),1);function ld(e,t,{target:r="stdout",...n}={}){return hE.default[r]?n9.link(e,t):n.fallback===!1?e:typeof n.fallback=="function"?n.fallback(e,t):`${e} (\u200B${t}\u200B)`}ld.isSupported=hE.default.stdout;ld.stderr=(e,t,r={})=>ld(e,t,{target:"stderr",...r});ld.stderr.isSupported=hE.default.stderr;var dbe=(e,t)=>`${t}`,Wf=e=>ld(e,e,{fallback:dbe});var c9=async e=>{let t=await Abe();console.log(`Great. Before completing the setup, you'll need to add the controller to your ${t} in Juno's console.
2179
+ `),process.exit(1))},Hge=async e=>{let{answer:t}=await(0,KQ.default)([{type:"toggle",name:"answer",message:e,initial:!1,active:"yes",inactive:"no",onState:Vge}]);return t},cB=async e=>await Hge(e),Yi=async e=>{await cB(e)||process.exit(1)};var Zge=Xge(import.meta.url),zQ=zge(Zge),ip=async({sourceFolder:e,destinationFolder:t,template:r,overwrite:n=!1})=>{let i=pB(t,r);!n&&Wge(i)&&!await cB(`File ${(0,YQ.yellow)(Jge(process.cwd(),i))} already exists. Do you want to overwrite it?`)||await Kge(pB(zQ,e,r),i)},qf=async({sourceFolder:e,template:t})=>await Yge(pB(zQ,e,t),"utf-8");var dB={filename:O0},zi=async()=>await lE(dB),XQ=()=>Uf(dB),ZQ=async({config:e,configType:t})=>{switch(t){case"ts":case"js":{let{orbiter:r,satellite:{id:n,source:i}}=e,a=(await qf({template:Jn(r)?`${O0}.${t}`:`${qQ}.${t}`,sourceFolder:UQ})).replace("<SATELLITE_ID>",n).replace("<SOURCE>",i??cE).replace("<ORBITER_ID>",r?.id??"");await JQ(`${O0}.${t}`,a,"utf-8");break}default:await JQ(`${O0}.json`,JSON.stringify(e,null,2),"utf-8")}},Ji=async e=>await $Q({...dB,config:r=>typeof r=="function"?r(e):r});var e9=Bt(Gc(),1);var dE=async()=>{let{configType:e}=await(0,e9.default)({type:"select",name:"configType",message:"What configuration file format do you prefer?",choices:[{title:"TypeScript",value:"ts"},{title:"JavaScript",value:"js"},{title:"JSON",value:"json"}],initial:0});return da(e),e};var Gf=async()=>{let e=tp();if(Br(e)){console.log(`No controller found. Run ${(0,ud.cyan)("login")} to get started \u{1F680}.`);return}await zi()&&await Yi("Your existing configuration will be overwritten. Are you sure you want to continue?"),await rbe()},rbe=async()=>{let e=await nbe(),t=await ibe(),r=await obe(),{configType:n,configPath:i}=await abe();await ZQ({config:{satellite:{id:e,source:r},...Jn(t)&&{orbiter:{id:t}}},configType:n}),Jn(i)&&tbe(i)==="juno.json"&&await ebe(i),n!=="json"&&console.log(`${Fi}\u{1F4A1} You can leverage your IDE's intellisense with type hints by installing the library: ${(0,ud.yellow)("npm i @junobuild/config -D")}${Fi}`)},nbe=async()=>{let e=k0(),t=await(e?.length>0?sbe(e):t9());return t==="_manual_"?await t9():t},ibe=async()=>{let e=zl();if(e===void 0||e.length===0)return;let t=await ube(e);if(t!=="_none_")return t},sbe=async e=>{let{satellite:t}=await(0,G0.default)({type:"select",name:"satellite",message:"Which satellite should be linked with this dapp?",choices:[...e.map(({p:r,n})=>({title:n,value:r})),{title:"<not listed, manual entry>",value:"_manual_"}],initial:0});return da(t),t},abe=async()=>await zi()?XQ():{configType:await dE()},t9=async()=>{let{satellite:e}=await(0,G0.default)([{type:"text",name:"satellite",message:`What's the ${(0,ud.cyan)("id")} of your satellite?`}]);return da(e,"The satellite ID is mandatory"),e},obe=async()=>{let{source:e}=await(0,G0.default)([{type:"text",name:"source",message:'What is the location of your compiled app files? They are often found in the "build" or "dist" folders.',initial:"build"}]);return da(e),e},da=(e,t)=>{(e===void 0||e===""||e===null)&&(t!==void 0&&console.log(`${(0,ud.red)(t)}`),process.exit(1))},ube=async e=>{let{orbiter:t}=await(0,G0.default)({type:"select",name:"orbiter",message:"Which orbiter do you use for the analytics in this dapp?",choices:[...e.map(({p:r,n})=>({title:n??r,value:r})),{title:"<none>",value:"_none_"}],initial:0});return da(t),t};var Vr="\x1B[",V0="\x1B]",Vf="\x07",fE=";",r9=process.env.TERM_PROGRAM==="Apple_Terminal",wr={};wr.cursorTo=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");return typeof t!="number"?Vr+(e+1)+"G":Vr+(t+1)+";"+(e+1)+"H"};wr.cursorMove=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");let r="";return e<0?r+=Vr+-e+"D":e>0&&(r+=Vr+e+"C"),t<0?r+=Vr+-t+"A":t>0&&(r+=Vr+t+"B"),r};wr.cursorUp=(e=1)=>Vr+e+"A";wr.cursorDown=(e=1)=>Vr+e+"B";wr.cursorForward=(e=1)=>Vr+e+"C";wr.cursorBackward=(e=1)=>Vr+e+"D";wr.cursorLeft=Vr+"G";wr.cursorSavePosition=r9?"\x1B7":Vr+"s";wr.cursorRestorePosition=r9?"\x1B8":Vr+"u";wr.cursorGetPosition=Vr+"6n";wr.cursorNextLine=Vr+"E";wr.cursorPrevLine=Vr+"F";wr.cursorHide=Vr+"?25l";wr.cursorShow=Vr+"?25h";wr.eraseLines=e=>{let t="";for(let r=0;r<e;r++)t+=wr.eraseLine+(r<e-1?wr.cursorUp():"");return e&&(t+=wr.cursorLeft),t};wr.eraseEndLine=Vr+"K";wr.eraseStartLine=Vr+"1K";wr.eraseLine=Vr+"2K";wr.eraseDown=Vr+"J";wr.eraseUp=Vr+"1J";wr.eraseScreen=Vr+"2J";wr.scrollUp=Vr+"S";wr.scrollDown=Vr+"T";wr.clearScreen="\x1Bc";wr.clearTerminal=process.platform==="win32"?`${wr.eraseScreen}${Vr}0f`:`${wr.eraseScreen}${Vr}3J${Vr}H`;wr.beep=Vf;wr.link=(e,t)=>[V0,"8",fE,fE,t,Vf,e,V0,"8",fE,fE,Vf].join("");wr.image=(e,t={})=>{let r=`${V0}1337;File=inline=1`;return t.width&&(r+=`;width=${t.width}`),t.height&&(r+=`;height=${t.height}`),t.preserveAspectRatio===!1&&(r+=";preserveAspectRatio=0"),r+":"+e.toString("base64")+Vf};wr.iTerm={setCwd:(e=process.cwd())=>`${V0}50;CurrentDir=${e}${Vf}`,annotation:(e,t={})=>{let r=`${V0}1337;`,n=typeof t.x<"u",i=typeof t.y<"u";if((n||i)&&!(n&&i&&typeof t.length<"u"))throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");return e=e.replace(/\|/g,""),r+=t.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",t.length>0?r+=(n?[e,t.length,t.x,t.y]:[t.length,e]).join("|"):r+=e,r+Vf}};var n9=wr;var hE=Bt(l9(),1);function ld(e,t,{target:r="stdout",...n}={}){return hE.default[r]?n9.link(e,t):n.fallback===!1?e:typeof n.fallback=="function"?n.fallback(e,t):`${e} (\u200B${t}\u200B)`}ld.isSupported=hE.default.stdout;ld.stderr=(e,t,r={})=>ld(e,t,{target:"stderr",...r});ld.stderr.isSupported=hE.default.stderr;var dbe=(e,t)=>`${t}`,Wf=e=>ld(e,e,{fallback:dbe});var c9=async e=>{let t=await Abe();console.log(`Great. Before completing the setup, you'll need to add the controller to your ${t} in Juno's console.
2180
2180
 
2181
2181
  Here are the steps to follow:`),await ybe({controller:e,segment:t});let{segmentId:r}=await(0,mE.default)({type:"text",name:"segmentId",message:`Good. So, what's the ${(0,al.green)(`${t} ID`)} to which you just added the controller?`});if(r===void 0){console.log(`${(0,al.red)(`The ${t} ID cannot be undefined.`)}`);return}let n=il();switch(t){case"orbiter":mbe({profile:n,segmentId:r});break;case"mission_control":hbe({profile:n,segmentId:r});break;default:await fbe({profile:n,segmentId:r})}console.log(`
2182
2182
  Done. The ${t} ${(0,al.green)(`${r}`)} has been configured for your terminal. \u2705`)},fbe=async({profile:e,segmentId:t})=>{let{name:r}=await(0,mE.default)({type:"text",name:"name",message:"Can you please provide a name for this satellite?"});if(r===void 0){console.log(`${(0,al.red)("The name is mandatory.")}`);return}AL({profile:e,satellite:{p:t,n:r}})},hbe=({profile:e,segmentId:t})=>{gL({profile:e,missionControl:t})},mbe=({profile:e,segmentId:t})=>{EL({profile:e,orbiter:{p:t}})},Abe=async()=>{let{segment:e}=await(0,mE.default)({type:"select",name:"segment",message:"Which new segment would you like to authorize with your controller?",choices:[{title:"A satellite",value:"satellite"},{title:"The orbiter for the analytics",value:"orbiter"},{title:"Your mission control",value:"mission_control"}],initial:0});return da(e),e},ybe=async({segment:e,controller:t})=>{let r=`${jT}${e==="orbiter"?"/analytics":e==="satellite"?"":"/mission-control"}`;console.log(`
@@ -2204,7 +2204,7 @@ variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.displ
2204
2204
  `),this)}stop(){return this.#o?(clearInterval(this.#l),this.#l=void 0,this.#t=0,this.clear(),this.#r.hideCursor&&y_.show(this.#s),this.#r.discardStdin&&t1.stdin.isTTY&&this.#n&&(I_.stop(),this.#n=!1),this):this}succeed(t){return this.stopAndPersist({symbol:nA.success,text:t})}fail(t){return this.stopAndPersist({symbol:nA.error,text:t})}warn(t){return this.stopAndPersist({symbol:nA.warning,text:t})}info(t){return this.stopAndPersist({symbol:nA.info,text:t})}stopAndPersist(t={}){if(this.#p)return this;let r=t.prefixText??this.#u,n=this.#A(r," "),i=t.symbol??" ",s=t.text??this.text,a=typeof s=="string"?" "+s:"",c=t.suffixText??this.#d,l=this.#y(c," "),p=n+i+a+l+`
2205
2205
  `;return this.stop(),this.#s.write(p),this}};function Ua(e){return new S_(e)}var ts=e=>({mode:en({args:e,option:"-m"})??en({args:e,option:"--mode"})??"production"});var UU=Bt(zt(),1);var QU=Bt($w(),1);var $U=Bt(zt(),1);import Vve from"node:http";import Hve from"node:https";import mh from"node:zlib";import MU,{PassThrough as jU,pipeline as Ah}from"node:stream";import{Buffer as d1}from"node:buffer";function Eve(e){if(!/^data:/i.test(e))throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")');e=e.replace(/\r?\n/g,"");let t=e.indexOf(",");if(t===-1||t<=4)throw new TypeError("malformed data: URI");let r=e.substring(5,t).split(";"),n="",i=!1,s=r[0]||"text/plain",a=s;for(let u=1;u<r.length;u++)r[u]==="base64"?i=!0:r[u]&&(a+=`;${r[u]}`,r[u].indexOf("charset=")===0&&(n=r[u].substring(8)));!r[0]&&!n.length&&(a+=";charset=US-ASCII",n="US-ASCII");let c=i?"base64":"ascii",l=unescape(e.substring(t+1)),p=Buffer.from(l,c);return p.type=s,p.typeFull=a,p.charset=n,p}var aU=Eve;aA();n1();import pp,{PassThrough as wU}from"node:stream";import{types as CU,deprecate as k_,promisify as Rve}from"node:util";import{Buffer as Ro}from"node:buffer";var ec=class extends Error{constructor(t,r){super(t),Error.captureStackTrace(this,this.constructor),this.type=r}get name(){return this.constructor.name}get[Symbol.toStringTag](){return this.constructor.name}};var fa=class extends ec{constructor(t,r,n){super(t,r),n&&(this.code=this.errno=n.code,this.erroredSysCall=n.syscall)}};var i1=Symbol.toStringTag,P_=e=>typeof e=="object"&&typeof e.append=="function"&&typeof e.delete=="function"&&typeof e.get=="function"&&typeof e.getAll=="function"&&typeof e.has=="function"&&typeof e.set=="function"&&typeof e.sort=="function"&&e[i1]==="URLSearchParams",uA=e=>e&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&typeof e.constructor=="function"&&/^(Blob|File)$/.test(e[i1]),mU=e=>typeof e=="object"&&(e[i1]==="AbortSignal"||e[i1]==="EventTarget"),AU=(e,t)=>{let r=new URL(t).hostname,n=new URL(e).hostname;return r===n||r.endsWith(`.${n}`)},yU=(e,t)=>{let r=new URL(t).protocol,n=new URL(e).protocol;return r===n};var Mve=Rve(pp.pipeline),ha=Symbol("Body internals"),dl=class{constructor(t,{size:r=0}={}){let n=null;t===null?t=null:P_(t)?t=Ro.from(t.toString()):uA(t)||Ro.isBuffer(t)||(CU.isAnyArrayBuffer(t)?t=Ro.from(t):ArrayBuffer.isView(t)?t=Ro.from(t.buffer,t.byteOffset,t.byteLength):t instanceof pp||(t instanceof Ed?(t=hU(t),n=t.type.split("=")[1]):t=Ro.from(String(t))));let i=t;Ro.isBuffer(t)?i=pp.Readable.from(t):uA(t)&&(i=pp.Readable.from(t.stream())),this[ha]={body:t,stream:i,boundary:n,disturbed:!1,error:null},this.size=r,t instanceof pp&&t.on("error",s=>{let a=s instanceof ec?s:new fa(`Invalid response body while trying to fetch ${this.url}: ${s.message}`,"system",s);this[ha].error=a})}get body(){return this[ha].stream}get bodyUsed(){return this[ha].disturbed}async arrayBuffer(){let{buffer:t,byteOffset:r,byteLength:n}=await N_(this);return t.slice(r,r+n)}async formData(){let t=this.headers.get("content-type");if(t.startsWith("application/x-www-form-urlencoded")){let n=new Ed,i=new URLSearchParams(await this.text());for(let[s,a]of i)n.append(s,a);return n}let{toFormData:r}=await Promise.resolve().then(()=>(xU(),vU));return r(this.body,t)}async blob(){let t=this.headers&&this.headers.get("content-type")||this[ha].body&&this[ha].body.type||"",r=await this.arrayBuffer();return new Zl([r],{type:t})}async json(){let t=await this.text();return JSON.parse(t)}async text(){let t=await N_(this);return new TextDecoder().decode(t)}buffer(){return N_(this)}};dl.prototype.buffer=k_(dl.prototype.buffer,"Please use 'response.arrayBuffer()' instead of 'response.buffer()'","node-fetch#buffer");Object.defineProperties(dl.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0},data:{get:k_(()=>{},"data doesn't exist, use json(), text(), arrayBuffer(), or body instead","https://github.com/node-fetch/node-fetch/issues/1000 (response)")}});async function N_(e){if(e[ha].disturbed)throw new TypeError(`body used already for: ${e.url}`);if(e[ha].disturbed=!0,e[ha].error)throw e[ha].error;let{body:t}=e;if(t===null)return Ro.alloc(0);if(!(t instanceof pp))return Ro.alloc(0);let r=[],n=0;try{for await(let i of t){if(e.size>0&&n+i.length>e.size){let s=new fa(`content size at ${e.url} over limit: ${e.size}`,"max-size");throw t.destroy(s),s}n+=i.length,r.push(i)}}catch(i){throw i instanceof ec?i:new fa(`Invalid response body while trying to fetch ${e.url}: ${i.message}`,"system",i)}if(t.readableEnded===!0||t._readableState.ended===!0)try{return r.every(i=>typeof i=="string")?Ro.from(r.join("")):Ro.concat(r,n)}catch(i){throw new fa(`Could not create Buffer from response body for ${e.url}: ${i.message}`,"system",i)}else throw new fa(`Premature close of server response while trying to fetch ${e.url}`)}var fh=(e,t)=>{let r,n,{body:i}=e[ha];if(e.bodyUsed)throw new Error("cannot clone body after it is used");return i instanceof pp&&typeof i.getBoundary!="function"&&(r=new wU({highWaterMark:t}),n=new wU({highWaterMark:t}),i.pipe(r),i.pipe(n),e[ha].stream=r,i=n),i},jve=k_(e=>e.getBoundary(),"form-data doesn't follow the spec and requires special treatment. Use alternative package","https://github.com/node-fetch/node-fetch/issues/1167"),o1=(e,t)=>e===null?null:typeof e=="string"?"text/plain;charset=UTF-8":P_(e)?"application/x-www-form-urlencoded;charset=UTF-8":uA(e)?e.type||null:Ro.isBuffer(e)||CU.isAnyArrayBuffer(e)||ArrayBuffer.isView(e)?null:e instanceof Ed?`multipart/form-data; boundary=${t[ha].boundary}`:e&&typeof e.getBoundary=="function"?`multipart/form-data;boundary=${jve(e)}`:e instanceof pp?null:"text/plain;charset=UTF-8",IU=e=>{let{body:t}=e[ha];return t===null?0:uA(t)?t.size:Ro.isBuffer(t)?t.length:t&&typeof t.getLengthSync=="function"&&t.hasKnownLength&&t.hasKnownLength()?t.getLengthSync():null},SU=async(e,{body:t})=>{t===null?e.end():await Mve(t,e)};import{types as TU}from"node:util";import l1 from"node:http";var u1=typeof l1.validateHeaderName=="function"?l1.validateHeaderName:e=>{if(!/^[\^`\-\w!#$%&'*+.|~]+$/.test(e)){let t=new TypeError(`Header name must be a valid HTTP token [${e}]`);throw Object.defineProperty(t,"code",{value:"ERR_INVALID_HTTP_TOKEN"}),t}},R_=typeof l1.validateHeaderValue=="function"?l1.validateHeaderValue:(e,t)=>{if(/[^\t\u0020-\u007E\u0080-\u00FF]/.test(t)){let r=new TypeError(`Invalid character in header content ["${e}"]`);throw Object.defineProperty(r,"code",{value:"ERR_INVALID_CHAR"}),r}},qa=class e extends URLSearchParams{constructor(t){let r=[];if(t instanceof e){let n=t.raw();for(let[i,s]of Object.entries(n))r.push(...s.map(a=>[i,a]))}else if(t!=null)if(typeof t=="object"&&!TU.isBoxedPrimitive(t)){let n=t[Symbol.iterator];if(n==null)r.push(...Object.entries(t));else{if(typeof n!="function")throw new TypeError("Header pairs must be iterable");r=[...t].map(i=>{if(typeof i!="object"||TU.isBoxedPrimitive(i))throw new TypeError("Each header pair must be an iterable object");return[...i]}).map(i=>{if(i.length!==2)throw new TypeError("Each header pair must be a name/value tuple");return[...i]})}}else throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)");return r=r.length>0?r.map(([n,i])=>(u1(n),R_(n,String(i)),[String(n).toLowerCase(),String(i)])):void 0,super(r),new Proxy(this,{get(n,i,s){switch(i){case"append":case"set":return(a,c)=>(u1(a),R_(a,String(c)),URLSearchParams.prototype[i].call(n,String(a).toLowerCase(),String(c)));case"delete":case"has":case"getAll":return a=>(u1(a),URLSearchParams.prototype[i].call(n,String(a).toLowerCase()));case"keys":return()=>(n.sort(),new Set(URLSearchParams.prototype.keys.call(n)).keys());default:return Reflect.get(n,i,s)}}})}get[Symbol.toStringTag](){return this.constructor.name}toString(){return Object.prototype.toString.call(this)}get(t){let r=this.getAll(t);if(r.length===0)return null;let n=r.join(", ");return/^content-encoding$/i.test(t)&&(n=n.toLowerCase()),n}forEach(t,r=void 0){for(let n of this.keys())Reflect.apply(t,r,[this.get(n),n,this])}*values(){for(let t of this.keys())yield this.get(t)}*entries(){for(let t of this.keys())yield[t,this.get(t)]}[Symbol.iterator](){return this.entries()}raw(){return[...this.keys()].reduce((t,r)=>(t[r]=this.getAll(r),t),{})}[Symbol.for("nodejs.util.inspect.custom")](){return[...this.keys()].reduce((t,r)=>{let n=this.getAll(r);return r==="host"?t[r]=n[0]:t[r]=n.length>1?n:n[0],t},{})}};Object.defineProperties(qa.prototype,["get","entries","forEach","values"].reduce((e,t)=>(e[t]={enumerable:!0},e),{}));function BU(e=[]){return new qa(e.reduce((t,r,n,i)=>(n%2===0&&t.push(i.slice(n,n+2)),t),[]).filter(([t,r])=>{try{return u1(t),R_(t,String(r)),!0}catch{return!1}}))}var Lve=new Set([301,302,303,307,308]),c1=e=>Lve.has(e);var wu=Symbol("Response internals"),Mo=class e extends dl{constructor(t=null,r={}){super(t,r);let n=r.status!=null?r.status:200,i=new qa(r.headers);if(t!==null&&!i.has("Content-Type")){let s=o1(t,this);s&&i.append("Content-Type",s)}this[wu]={type:"default",url:r.url,status:n,statusText:r.statusText||"",headers:i,counter:r.counter,highWaterMark:r.highWaterMark}}get type(){return this[wu].type}get url(){return this[wu].url||""}get status(){return this[wu].status}get ok(){return this[wu].status>=200&&this[wu].status<300}get redirected(){return this[wu].counter>0}get statusText(){return this[wu].statusText}get headers(){return this[wu].headers}get highWaterMark(){return this[wu].highWaterMark}clone(){return new e(fh(this,this.highWaterMark),{type:this.type,url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected,size:this.size,highWaterMark:this.highWaterMark})}static redirect(t,r=302){if(!c1(r))throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');return new e(null,{headers:{location:new URL(t).toString()},status:r})}static error(){let t=new e(null,{status:0,statusText:""});return t[wu].type="error",t}static json(t=void 0,r={}){let n=JSON.stringify(t);if(n===void 0)throw new TypeError("data is not JSON serializable");let i=new qa(r&&r.headers);return i.has("content-type")||i.set("content-type","application/json"),new e(n,{...r,headers:i})}get[Symbol.toStringTag](){return"Response"}};Object.defineProperties(Mo.prototype,{type:{enumerable:!0},url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}});import{format as Uve}from"node:url";import{deprecate as qve}from"node:util";var _U=e=>{if(e.search)return e.search;let t=e.href.length-1,r=e.hash||(e.href[t]==="#"?"#":"");return e.href[t-r.length]==="?"?"?":""};import{isIP as Qve}from"node:net";function DU(e,t=!1){return e==null||(e=new URL(e),/^(about|blob|data):$/.test(e.protocol))?"no-referrer":(e.username="",e.password="",e.hash="",t&&(e.pathname="",e.search=""),e)}var PU=new Set(["","no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"]),OU="strict-origin-when-cross-origin";function FU(e){if(!PU.has(e))throw new TypeError(`Invalid referrerPolicy: ${e}`);return e}function $ve(e){if(/^(http|ws)s:$/.test(e.protocol))return!0;let t=e.host.replace(/(^\[)|(]$)/g,""),r=Qve(t);return r===4&&/^127\./.test(t)||r===6&&/^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(t)?!0:e.host==="localhost"||e.host.endsWith(".localhost")?!1:e.protocol==="file:"}function hh(e){return/^about:(blank|srcdoc)$/.test(e)||e.protocol==="data:"||/^(blob|filesystem):$/.test(e.protocol)?!0:$ve(e)}function NU(e,{referrerURLCallback:t,referrerOriginCallback:r}={}){if(e.referrer==="no-referrer"||e.referrerPolicy==="")return null;let n=e.referrerPolicy;if(e.referrer==="about:client")return"no-referrer";let i=e.referrer,s=DU(i),a=DU(i,!0);s.toString().length>4096&&(s=a),t&&(s=t(s)),r&&(a=r(a));let c=new URL(e.url);switch(n){case"no-referrer":return"no-referrer";case"origin":return a;case"unsafe-url":return s;case"strict-origin":return hh(s)&&!hh(c)?"no-referrer":a.toString();case"strict-origin-when-cross-origin":return s.origin===c.origin?s:hh(s)&&!hh(c)?"no-referrer":a;case"same-origin":return s.origin===c.origin?s:"no-referrer";case"origin-when-cross-origin":return s.origin===c.origin?s:a;case"no-referrer-when-downgrade":return hh(s)&&!hh(c)?"no-referrer":s;default:throw new TypeError(`Invalid referrerPolicy: ${n}`)}}function kU(e){let t=(e.get("referrer-policy")||"").split(/[,\s]+/),r="";for(let n of t)n&&PU.has(n)&&(r=n);return r}var Ri=Symbol("Request internals"),cA=e=>typeof e=="object"&&typeof e[Ri]=="object",Gve=qve(()=>{},".data is not a valid RequestInit property, use .body instead","https://github.com/node-fetch/node-fetch/issues/1000 (request)"),xd=class e extends dl{constructor(t,r={}){let n;if(cA(t)?n=new URL(t.url):(n=new URL(t),t={}),n.username!==""||n.password!=="")throw new TypeError(`${n} is an url with embedded credentials.`);let i=r.method||t.method||"GET";if(/^(delete|get|head|options|post|put)$/i.test(i)&&(i=i.toUpperCase()),!cA(r)&&"data"in r&&Gve(),(r.body!=null||cA(t)&&t.body!==null)&&(i==="GET"||i==="HEAD"))throw new TypeError("Request with GET/HEAD method cannot have body");let s=r.body?r.body:cA(t)&&t.body!==null?fh(t):null;super(s,{size:r.size||t.size||0});let a=new qa(r.headers||t.headers||{});if(s!==null&&!a.has("Content-Type")){let p=o1(s,this);p&&a.set("Content-Type",p)}let c=cA(t)?t.signal:null;if("signal"in r&&(c=r.signal),c!=null&&!mU(c))throw new TypeError("Expected signal to be an instanceof AbortSignal or EventTarget");let l=r.referrer==null?t.referrer:r.referrer;if(l==="")l="no-referrer";else if(l){let p=new URL(l);l=/^about:(\/\/)?client$/.test(p)?"client":p}else l=void 0;this[Ri]={method:i,redirect:r.redirect||t.redirect||"follow",headers:a,parsedURL:n,signal:c,referrer:l},this.follow=r.follow===void 0?t.follow===void 0?20:t.follow:r.follow,this.compress=r.compress===void 0?t.compress===void 0?!0:t.compress:r.compress,this.counter=r.counter||t.counter||0,this.agent=r.agent||t.agent,this.highWaterMark=r.highWaterMark||t.highWaterMark||16384,this.insecureHTTPParser=r.insecureHTTPParser||t.insecureHTTPParser||!1,this.referrerPolicy=r.referrerPolicy||t.referrerPolicy||""}get method(){return this[Ri].method}get url(){return Uve(this[Ri].parsedURL)}get headers(){return this[Ri].headers}get redirect(){return this[Ri].redirect}get signal(){return this[Ri].signal}get referrer(){if(this[Ri].referrer==="no-referrer")return"";if(this[Ri].referrer==="client")return"about:client";if(this[Ri].referrer)return this[Ri].referrer.toString()}get referrerPolicy(){return this[Ri].referrerPolicy}set referrerPolicy(t){this[Ri].referrerPolicy=FU(t)}clone(){return new e(this)}get[Symbol.toStringTag](){return"Request"}};Object.defineProperties(xd.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0},referrer:{enumerable:!0},referrerPolicy:{enumerable:!0}});var RU=e=>{let{parsedURL:t}=e[Ri],r=new qa(e[Ri].headers);r.has("Accept")||r.set("Accept","*/*");let n=null;if(e.body===null&&/^(post|put)$/i.test(e.method)&&(n="0"),e.body!==null){let c=IU(e);typeof c=="number"&&!Number.isNaN(c)&&(n=String(c))}n&&r.set("Content-Length",n),e.referrerPolicy===""&&(e.referrerPolicy=OU),e.referrer&&e.referrer!=="no-referrer"?e[Ri].referrer=NU(e):e[Ri].referrer="no-referrer",e[Ri].referrer instanceof URL&&r.set("Referer",e.referrer),r.has("User-Agent")||r.set("User-Agent","node-fetch"),e.compress&&!r.has("Accept-Encoding")&&r.set("Accept-Encoding","gzip, deflate, br");let{agent:i}=e;typeof i=="function"&&(i=i(t));let s=_U(t),a={path:t.pathname+s,method:e.method,headers:r[Symbol.for("nodejs.util.inspect.custom")](),insecureHTTPParser:e.insecureHTTPParser,agent:i};return{parsedURL:t,options:a}};var p1=class extends ec{constructor(t,r="aborted"){super(t,r)}};n1();O_();var Wve=new Set(["data:","http:","https:"]);async function f1(e,t){return new Promise((r,n)=>{let i=new xd(e,t),{parsedURL:s,options:a}=RU(i);if(!Wve.has(s.protocol))throw new TypeError(`node-fetch cannot load ${e}. URL scheme "${s.protocol.replace(/:$/,"")}" is not supported.`);if(s.protocol==="data:"){let A=aU(i.url),E=new Mo(A,{headers:{"Content-Type":A.typeFull}});r(E);return}let c=(s.protocol==="https:"?Hve:Vve).request,{signal:l}=i,p=null,u=()=>{let A=new p1("The operation was aborted.");n(A),i.body&&i.body instanceof MU.Readable&&i.body.destroy(A),!(!p||!p.body)&&p.body.emit("error",A)};if(l&&l.aborted){u();return}let f=()=>{u(),d()},h=c(s.toString(),a);l&&l.addEventListener("abort",f);let d=()=>{h.abort(),l&&l.removeEventListener("abort",f)};h.on("error",A=>{n(new fa(`request to ${i.url} failed, reason: ${A.message}`,"system",A)),d()}),Kve(h,A=>{p&&p.body&&p.body.destroy(A)}),process.version<"v14"&&h.on("socket",A=>{let E;A.prependListener("end",()=>{E=A._eventsCount}),A.prependListener("close",b=>{if(p&&E<A._eventsCount&&!b){let x=new Error("Premature close");x.code="ERR_STREAM_PREMATURE_CLOSE",p.body.emit("error",x)}})}),h.on("response",A=>{h.setTimeout(0);let E=BU(A.rawHeaders);if(c1(A.statusCode)){let B=E.get("Location"),w=null;try{w=B===null?null:new URL(B,i.url)}catch{if(i.redirect!=="manual"){n(new fa(`uri requested responds with an invalid redirect URL: ${B}`,"invalid-redirect")),d();return}}switch(i.redirect){case"error":n(new fa(`uri requested responds with a redirect, redirect mode is set to error: ${i.url}`,"no-redirect")),d();return;case"manual":break;case"follow":{if(w===null)break;if(i.counter>=i.follow){n(new fa(`maximum redirect reached at: ${i.url}`,"max-redirect")),d();return}let D={headers:new qa(i.headers),follow:i.follow,counter:i.counter+1,agent:i.agent,compress:i.compress,method:i.method,body:fh(i),signal:i.signal,size:i.size,referrer:i.referrer,referrerPolicy:i.referrerPolicy};if(!AU(i.url,w)||!yU(i.url,w))for(let Q of["authorization","www-authenticate","cookie","cookie2"])D.headers.delete(Q);if(A.statusCode!==303&&i.body&&t.body instanceof MU.Readable){n(new fa("Cannot follow redirect with body being a readable stream","unsupported-redirect")),d();return}(A.statusCode===303||(A.statusCode===301||A.statusCode===302)&&i.method==="POST")&&(D.method="GET",D.body=void 0,D.headers.delete("content-length"));let P=kU(E);P&&(D.referrerPolicy=P),r(f1(new xd(w,D))),d();return}default:return n(new TypeError(`Redirect option '${i.redirect}' is not a valid value of RequestRedirect`))}}l&&A.once("end",()=>{l.removeEventListener("abort",f)});let b=Ah(A,new jU,B=>{B&&n(B)});process.version<"v12.10"&&A.on("aborted",f);let x={url:i.url,status:A.statusCode,statusText:A.statusMessage,headers:E,size:i.size,counter:i.counter,highWaterMark:i.highWaterMark},v=E.get("Content-Encoding");if(!i.compress||i.method==="HEAD"||v===null||A.statusCode===204||A.statusCode===304){p=new Mo(b,x),r(p);return}let I={flush:mh.Z_SYNC_FLUSH,finishFlush:mh.Z_SYNC_FLUSH};if(v==="gzip"||v==="x-gzip"){b=Ah(b,mh.createGunzip(I),B=>{B&&n(B)}),p=new Mo(b,x),r(p);return}if(v==="deflate"||v==="x-deflate"){let B=Ah(A,new jU,w=>{w&&n(w)});B.once("data",w=>{(w[0]&15)===8?b=Ah(b,mh.createInflate(),D=>{D&&n(D)}):b=Ah(b,mh.createInflateRaw(),D=>{D&&n(D)}),p=new Mo(b,x),r(p)}),B.once("end",()=>{p||(p=new Mo(b,x),r(p))});return}if(v==="br"){b=Ah(b,mh.createBrotliDecompress(),B=>{B&&n(B)}),p=new Mo(b,x),r(p);return}p=new Mo(b,x),r(p)}),SU(h,i).catch(n)})}function Kve(e,t){let r=d1.from(`0\r
2206
2206
  \r
2207
- `),n=!1,i=!1,s;e.on("response",a=>{let{headers:c}=a;n=c["transfer-encoding"]==="chunked"&&!c["content-length"]}),e.on("socket",a=>{let c=()=>{if(n&&!i){let p=new Error("Premature close");p.code="ERR_STREAM_PREMATURE_CLOSE",t(p)}},l=p=>{i=d1.compare(p.slice(-5),r)===0,!i&&s&&(i=d1.compare(s.slice(-3),r.slice(0,3))===0&&d1.compare(p.slice(-2),r.slice(3))===0),s=p};a.prependListener("close",c),a.on("data",l),e.on("close",()=>{a.removeListener("close",c),a.removeListener("data",l)})})}var M_=()=>{let e=process.env.JUNO_TOKEN;if(e!==void 0)try{let{token:t}=JSON.parse(atob(e));return t}catch{throw new Error("Cannot parse token provided as an environment variable.")}},LU=()=>M_()!==void 0;var tc=()=>{let e=M_()??tp();Br(e)&&(console.log(`${(0,$U.red)("No controller found.")} Are you logged in?`),process.exit(1));let t=QU.Ed25519KeyIdentity.fromParsedJson(e);if(fL.includes(t.getPrincipal().toText()))throw new Error("The controller has been revoked for security reason!");return{identity:t,fetch:f1,...Jn(process.env.CONTAINER_URL)&&{container:process.env.CONTAINER_URL}}};var Mi=({satellite:{satelliteId:e,satellitesIds:t},env:{mode:r}})=>{let n=t?.[r]??e;return Br(n)&&(console.log(`${(0,UU.red)(`A satellite ID for ${r} must be set in your configuration.`)}`),process.exit(1)),{satelliteId:n,...tc()}},h1=e=>k0().find(({p:n})=>n===e)?.n??e,m1=e=>{let r=zl()?.find(({p:n})=>n===e);return r?.n!==void 0&&r?.n!==""?r.n:e};var A1=async e=>{let t=ts(e),{satellite:r}=await Ji(t),n=Ua("Clearing dapp assets...").start();try{await i$({collection:N0,satellite:Mi({satellite:r,env:t})})}finally{n.stop()}},Yve=e=>{let t=e.replace(/\\/g,"/");return`${t.startsWith("/")?"":"/"}${t}`},qU=async({fullPath:e,args:t})=>{let r=ts(t),{satellite:n}=await Ji(r),i=Ua(`Clearing ${e}...`).start();try{await I$({collection:N0,satellite:Mi({satellite:n,env:r}),fullPath:Yve(e)})}finally{i.stop()}};var GU=Bt(zt(),1),yh=()=>{console.log(`Oops! ${(0,GU.red)("No config file found.")} Try to run the command from your project root.`)};var HU=async e=>{if(!await zi()){yh();return}if(Cn({args:e,options:["-f","--fullpath","--fullPath"]})){let t=en({args:e,option:"-f"})??en({args:e,option:"--fullpath"})??en({args:e,option:"--fullPath"});if(Br(t)){console.log(`You did not provide a ${(0,VU.yellow)("fullPath")} to delete.`);return}await qU({fullPath:t,args:e});return}await A1(e)};var WU=async e=>{await zi()||await Gf();let t=ts(e),{satellite:r}=await Ji(t),{storage:n}=r,i=Ua("Configuring...").start();try{await Z7({config:{storage:{headers:n?.headers??[],rewrites:n?.rewrites,redirects:n?.redirects,iframe:n?.iframe}},satellite:Mi({satellite:r,env:t})})}finally{i.stop()}};import{Blob as GPe}from"buffer";import VPe from"crypto";import gh from"node:fs";var A9e=gh.existsSync,y9e=gh.createReadStream;async function j_(e){return new Promise((t,r)=>{gh.stat(e,(n,i)=>{n?r(n):t(i)})})}async function KU(e){return new Promise((t,r)=>{gh.close(e,n=>{n?r(n):t()})})}async function YU(e,t){return new Promise((r,n)=>{gh.open(e,t,(i,s)=>{i?n(i):r(s)})})}async function L_(e,t,r,n,i){return new Promise((s,a)=>{gh.read(e,t,r,n,i,(c,l,p)=>{c?a(c):s({bytesRead:l,buffer:p})})})}var zve="End-Of-Stream",an=class extends Error{constructor(){super(zve)}};var y1=class{constructor(){this.resolve=()=>null,this.reject=()=>null,this.promise=new Promise((t,r)=>{this.reject=r,this.resolve=t})}};var Jve=1*1024*1024,pA=class{constructor(t){if(this.s=t,this.deferred=null,this.endOfStream=!1,this.peekQueue=[],!t.read||!t.once)throw new Error("Expected an instance of stream.Readable");this.s.once("end",()=>this.reject(new an)),this.s.once("error",r=>this.reject(r)),this.s.once("close",()=>this.reject(new Error("Stream closed")))}async peek(t,r,n){let i=await this.read(t,r,n);return this.peekQueue.push(t.subarray(r,r+i)),i}async read(t,r,n){if(n===0)return 0;if(this.peekQueue.length===0&&this.endOfStream)throw new an;let i=n,s=0;for(;this.peekQueue.length>0&&i>0;){let a=this.peekQueue.pop();if(!a)throw new Error("peekData should be defined");let c=Math.min(a.length,i);t.set(a.subarray(0,c),r+s),s+=c,i-=c,c<a.length&&this.peekQueue.push(a.subarray(c))}for(;i>0&&!this.endOfStream;){let a=Math.min(i,Jve),c=await this.readFromStream(t,r+s,a);if(s+=c,c<a)break;i-=c}return s}async readFromStream(t,r,n){let i=this.s.read(n);if(i)return t.set(i,r),i.length;{let s={buffer:t,offset:r,length:n,deferred:new y1};return this.deferred=s.deferred,this.s.once("readable",()=>{this.readDeferred(s)}),s.deferred.promise}}readDeferred(t){let r=this.s.read(t.length);r?(t.buffer.set(r,t.offset),t.deferred.resolve(r.length),this.deferred=null):this.s.once("readable",()=>{this.readDeferred(t)})}reject(t){this.endOfStream=!0,this.deferred&&(this.deferred.reject(t),this.deferred=null)}};import{Buffer as JU}from"node:buffer";var dp=class{constructor(t){this.position=0,this.numBuffer=new Uint8Array(8),this.fileInfo=t||{}}async readToken(t,r=this.position){let n=JU.alloc(t.len);if(await this.readBuffer(n,{position:r})<t.len)throw new an;return t.get(n,0)}async peekToken(t,r=this.position){let n=JU.alloc(t.len);if(await this.peekBuffer(n,{position:r})<t.len)throw new an;return t.get(n,0)}async readNumber(t){if(await this.readBuffer(this.numBuffer,{length:t.len})<t.len)throw new an;return t.get(this.numBuffer,0)}async peekNumber(t){if(await this.peekBuffer(this.numBuffer,{length:t.len})<t.len)throw new an;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 Xve=256e3,g1=class extends dp{constructor(t,r){super(r),this.streamReader=new pA(t)}async getFileInfo(){return this.fileInfo}async readBuffer(t,r){let n=this.normalizeOptions(t,r),i=n.position-this.position;if(i>0)return await this.ignore(i),this.readBuffer(t,r);if(i<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let s=await this.streamReader.read(t,n.offset,n.length);if(this.position+=s,(!r||!r.mayBeLess)&&s<n.length)throw new an;return s}async peekBuffer(t,r){let n=this.normalizeOptions(t,r),i=0;if(n.position){let s=n.position-this.position;if(s>0){let a=new Uint8Array(n.length+s);return i=await this.peekBuffer(a,{mayBeLess:n.mayBeLess}),t.set(a.subarray(s),n.offset),i-s}else if(s<0)throw new Error("Cannot peek from a negative offset in a stream")}if(n.length>0){try{i=await this.streamReader.peek(t,n.offset,n.length)}catch(s){if(r&&r.mayBeLess&&s instanceof an)return 0;throw s}if(!n.mayBeLess&&i<n.length)throw new an}return i}async ignore(t){let r=Math.min(Xve,t),n=new Uint8Array(r),i=0;for(;i<t;){let s=t-i,a=await this.readBuffer(n,{length:Math.min(r,s)});if(a<0)return a;i+=a}return i}};var b1=class extends dp{constructor(t,r){super(r),this.uint8Array=t,this.fileInfo.size=this.fileInfo.size?this.fileInfo.size:t.length}async readBuffer(t,r){if(r&&r.position){if(r.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");this.position=r.position}let n=await this.peekBuffer(t,r);return this.position+=n,n}async peekBuffer(t,r){let n=this.normalizeOptions(t,r),i=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&i<n.length)throw new an;return t.set(this.uint8Array.subarray(n.position,n.position+i),n.offset),i}async close(){}};function Q_(e,t){return t=t||{},new g1(e,t)}function $_(e,t){return new b1(e,t)}var U_=class extends dp{constructor(t,r){super(r),this.fd=t}async readBuffer(t,r){let n=this.normalizeOptions(t,r);this.position=n.position;let i=await L_(this.fd,t,n.offset,n.length,n.position);if(this.position+=i.bytesRead,i.bytesRead<n.length&&(!r||!r.mayBeLess))throw new an;return i.bytesRead}async peekBuffer(t,r){let n=this.normalizeOptions(t,r),i=await L_(this.fd,t,n.offset,n.length,n.position);if(!n.mayBeLess&&i.bytesRead<n.length)throw new an;return i.bytesRead}async close(){return KU(this.fd)}};async function q_(e){let t=await j_(e);if(!t.isFile)throw new Error(`File not a file: ${e}`);let r=await YU(e,"r");return new U_(r,{path:e,size:t.size})}import{Buffer as fp}from"node:buffer";var ZU=Bt(ey(),1);import{Buffer as exe}from"node:buffer";function ma(e){return new DataView(e.buffer,e.byteOffset)}var eq={len:1,get(e,t){return ma(e).getUint8(t)},put(e,t,r){return ma(e).setUint8(t,r),t+1}},E1={len:2,get(e,t){return ma(e).getUint16(t,!0)},put(e,t,r){return ma(e).setUint16(t,r,!0),t+2}},v1={len:2,get(e,t){return ma(e).getUint16(t)},put(e,t,r){return ma(e).setUint16(t,r),t+2}};var tq={len:4,get(e,t){return ma(e).getUint32(t,!0)},put(e,t,r){return ma(e).setUint32(t,r,!0),t+4}},rq={len:4,get(e,t){return ma(e).getUint32(t)},put(e,t,r){return ma(e).setUint32(t,r),t+4}};var nq={len:4,get(e,t){return ma(e).getInt32(t)},put(e,t,r){return ma(e).setInt32(t,r),t+4}};var iq={len:8,get(e,t){return ma(e).getBigUint64(t,!0)},put(e,t,r){return ma(e).setBigUint64(t,r,!0),t+8}};var rc=class{constructor(t,r){this.len=t,this.encoding=r}get(t,r){return exe.from(t).toString(this.encoding,r,r+this.len)}},G_=class e{constructor(t){this.len=t}static decode(t,r,n){let i="";for(let s=r;s<n;++s)i+=e.codePointToString(e.singleByteDecoder(t[s]));return i}static inRange(t,r,n){return r<=t&&t<=n}static codePointToString(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}static singleByteDecoder(t){if(e.inRange(t,0,127))return t;let r=e.windows1252[t-128];if(r===null)throw Error("invaliding encoding");return r}get(t,r=0){return e.decode(t,r,r+this.len)}};G_.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 sq(e){return[...e].map(t=>t.charCodeAt(0))}function aq(e,t=0){let r=Number.parseInt(e.toString("utf8",148,154).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(r))return!1;let n=8*32;for(let i=t;i<t+148;i++)n+=e[i];for(let i=t+156;i<t+512;i++)n+=e[i];return r===n}var oq={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4};var uq=["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","macho","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","j2c","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","class","arj","cpio","ace","avro","icc","fbx"],lq=["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/wav","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-mach-binary","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/j2c","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","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx"];var cq=4100;function fl(e,t,r){r={offset:0,...r};for(let[n,i]of t.entries())if(r.mask){if(i!==(r.mask[n]&e[n+r.offset]))return!1}else if(i!==e[n+r.offset])return!1;return!0}var x1=class{constructor(t){this.detectors=t?.customDetectors,this.fromTokenizer=this.fromTokenizer.bind(this),this.fromBuffer=this.fromBuffer.bind(this),this.parse=this.parse.bind(this)}async fromTokenizer(t){let r=t.position;for(let n of this.detectors||[]){let i=await n(t);if(i)return i;if(r!==t.position)return}return this.parse(t)}async fromBuffer(t){if(!(t instanceof Uint8Array||t instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`Buffer\` or \`ArrayBuffer\`, got \`${typeof t}\``);let r=t instanceof Uint8Array?t:new Uint8Array(t);if(r?.length>1)return this.fromTokenizer($_(r))}async fromBlob(t){let r=await t.arrayBuffer();return this.fromBuffer(new Uint8Array(r))}async fromStream(t){let r=await Q_(t);try{return await this.fromTokenizer(r)}finally{await r.close()}}async toDetectionStream(t,r={}){let{default:n}=await import("node:stream"),{sampleSize:i=cq}=r;return new Promise((s,a)=>{t.on("error",a),t.once("readable",()=>{(async()=>{try{let c=new n.PassThrough,l=n.pipeline?n.pipeline(t,c,()=>{}):t.pipe(c),p=t.read(i)??t.read()??fp.alloc(0);try{c.fileType=await this.fromBuffer(p)}catch(u){u instanceof an?c.fileType=void 0:a(u)}s(l)}catch(c){a(c)}})()})})}check(t,r){return fl(this.buffer,t,r)}checkString(t,r){return this.check(sq(t),r)}async parse(t){if(this.buffer=fp.alloc(cq),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([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};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(oq);return t.position+r>t.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await t.ignore(r),this.fromTokenizer(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.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};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 rc(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 n=await t.readToken(new rc(r.compressedSize,"utf-8"));switch(n=n.trim(),n){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 n=-1;for(;n<0&&t.position<t.fileInfo.size;)await t.peekBuffer(this.buffer,{mayBeLess:!0}),n=this.buffer.indexOf("504B0304",0,"hex"),await t.ignore(n>=0?n:this.buffer.length)}else await t.ignore(r.compressedSize)}}catch(r){if(!(r instanceof an))throw r}return{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await t.ignore(28);let r=fp.alloc(8);return await t.readBuffer(r),fl(r,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/opus"}:fl(r,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:fl(r,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:fl(r,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:fl(r,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:fl(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,n=fp.alloc(Math.min(r,t.fileInfo.size));if(await t.readBuffer(n,{mayBeLess:!0}),n.includes(fp.from("AIPrivateData")))return{ext:"ai",mime:"application/postscript"}}catch(r){if(!(r instanceof an))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 c=await t.peekNumber(eq),l=128,p=0;for(;!(c&l)&&l!==0;)++p,l>>=1;let u=fp.alloc(p+1);return await t.readBuffer(u),u}async function n(){let c=await r(),l=await r();l[0]^=128>>l.length-1;let p=Math.min(6,l.length);return{id:c.readUIntBE(0,c.length),len:l.readUIntBE(l.length-p,p)}}async function i(c){for(;c>0;){let l=await n();if(l.id===17026)return(await t.readToken(new rc(l.len,"utf-8"))).replaceAll(/\00.*$/g,"");await t.ignore(l.len),--c}}let s=await n();switch(await i(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/wav"};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([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};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([202,254,186,190]))return{ext:"class",mime:"application/java-vm"};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("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await t.ignore(8),await t.readToken(new rc(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("**ACE",{offset:7})&&(await t.peekBuffer(this.buffer,{length:14,mayBeLess:!0}),this.checkString("**",{offset:12})))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.check([137,80,78,71,13,10,26,10])){await t.ignore(8);async function r(){return{length:await t.readToken(nq),type:await t.readToken(new rc(4,"binary"))}}do{let n=await r();if(n.length<0)return;switch(n.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await t.ignore(n.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 n=fp.alloc(16);return await t.readBuffer(n),{id:n,size:Number(await t.readToken(iq))}}for(await t.ignore(30);t.position+24<t.fileInfo.size;){let n=await r(),i=n.size-24;if(fl(n.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let s=fp.alloc(16);if(i-=await t.readBuffer(s),fl(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(fl(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(i)}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([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await t.ignore(20),await t.readToken(new rc(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.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(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 n=this.buffer.slice(16,r+16).toString();if(JSON.parse(n).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.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};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}),aq(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?v1:E1);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?v1:E1);for(let n=0;n<r;++n){let i=await this.readTiffTag(t);if(i)return i}}async readTiffHeader(t){let r=(t?v1:E1).get(this.buffer,2),n=(t?rq:tq).get(this.buffer,4);if(r===42){if(n>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(n>=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(n),await this.readTiffIFD(t)??{ext:"tif",mime:"image/tiff"}}if(r===43)return{ext:"tif",mime:"image/tiff"}}};var z9e=new Set(uq),J9e=new Set(lq);async function pq(e,t){let r=await q_(e);try{return await new x1(t).fromTokenizer(r)}finally{await r.close()}}var sz=Bt(zt(),1),az=Bt(mY(),1),oz=Bt(vY(),1);var UY=Bt(NY(),1);var WA=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Z2e={"[: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]},KA=e=>e.replace(/[[\]\\-]/g,"\\$&"),ePe=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),kY=e=>e.join(""),RY=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],s=r+1,a=!1,c=!1,l=!1,p=!1,u=r,f="";e:for(;s<e.length;){let E=e.charAt(s);if((E==="!"||E==="^")&&s===r+1){p=!0,s++;continue}if(E==="]"&&a&&!l){u=s+1;break}if(a=!0,E==="\\"&&!l){l=!0,s++;continue}if(E==="["&&!l){for(let[b,[x,v,I]]of Object.entries(Z2e))if(e.startsWith(b,s)){if(f)return["$.",!1,e.length-r,!0];s+=b.length,I?i.push(x):n.push(x),c=c||v;continue e}}if(l=!1,f){E>f?n.push(KA(f)+"-"+KA(E)):E===f&&n.push(KA(E)),f="",s++;continue}if(e.startsWith("-]",s+1)){n.push(KA(E+"-")),s+=2;continue}if(e.startsWith("-",s+1)){f=E,s+=2;continue}n.push(KA(E)),s++}if(u<s)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!p){let E=n[0].length===2?n[0].slice(-1):n[0];return[ePe(E),!1,u-r,!1]}let h="["+(p?"^":"")+kY(n)+"]",d="["+(p?"":"^")+kY(i)+"]";return[n.length&&i.length?"("+h+"|"+d+")":n.length?h:d,c,u-r,!0]};var Ep=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var tPe=new Set(["!","?","+","*","@"]),MY=e=>tPe.has(e),rPe="(?!(?:^|/)\\.\\.?(?:$|/))",pv="(?!\\.)",nPe=new Set(["[","."]),iPe=new Set(["..","."]),sPe=new Set("().*{}+?[]^$\\!"),aPe=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),bP="[^/]",jY=bP+"*?",LY=bP+"+?",Lh=class e{type;#e;#n;#i=!1;#t=[];#r;#a;#s;#l=!1;#c;#o;#p=!1;constructor(t,r,n={}){this.type=t,t&&(this.#n=!0),this.#r=r,this.#e=this.#r?this.#r.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#s=this.#e===this?[]:this.#e.#s,t==="!"&&!this.#e.#l&&this.#s.push(this),this.#a=this.#r?this.#r.#t.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(let t of this.#t)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#n=!0;return this.#n}toString(){return this.#o!==void 0?this.#o:this.type?this.#o=this.type+"("+this.#t.map(t=>String(t)).join("|")+")":this.#o=this.#t.map(t=>String(t)).join("")}#f(){if(this!==this.#e)throw new Error("should only call on root");if(this.#l)return this;this.toString(),this.#l=!0;let t;for(;t=this.#s.pop();){if(t.type!=="!")continue;let r=t,n=r.#r;for(;n;){for(let i=r.#a+1;!n.type&&i<n.#t.length;i++)for(let s of t.#t){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(n.#t[i])}r=n,n=r.#r}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof e&&r.#r===this))throw new Error("invalid part: "+r);this.#t.push(r)}}toJSON(){let t=this.type===null?this.#t.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#t.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#l&&this.#r?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#r?.isStart())return!1;if(this.#a===0)return!0;let t=this.#r;for(let r=0;r<this.#a;r++){let n=t.#t[r];if(!(n instanceof e&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#r?.type==="!")return!0;if(!this.#r?.isEnd())return!1;if(!this.type)return this.#r?.isEnd();let t=this.#r?this.#r.#t.length:0;return this.#a===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new e(this.type,t);for(let n of this.#t)r.copyIn(n);return r}static#h(t,r,n,i){let s=!1,a=!1,c=-1,l=!1;if(r.type===null){let d=n,A="";for(;d<t.length;){let E=t.charAt(d++);if(s||E==="\\"){s=!s,A+=E;continue}if(a){d===c+1?(E==="^"||E==="!")&&(l=!0):E==="]"&&!(d===c+2&&l)&&(a=!1),A+=E;continue}else if(E==="["){a=!0,c=d,l=!1,A+=E;continue}if(!i.noext&&MY(E)&&t.charAt(d)==="("){r.push(A),A="";let b=new e(E,r);d=e.#h(t,b,d,i),r.push(b);continue}A+=E}return r.push(A),d}let p=n+1,u=new e(null,r),f=[],h="";for(;p<t.length;){let d=t.charAt(p++);if(s||d==="\\"){s=!s,h+=d;continue}if(a){p===c+1?(d==="^"||d==="!")&&(l=!0):d==="]"&&!(p===c+2&&l)&&(a=!1),h+=d;continue}else if(d==="["){a=!0,c=p,l=!1,h+=d;continue}if(MY(d)&&t.charAt(p)==="("){u.push(h),h="";let A=new e(d,u);u.push(A),p=e.#h(t,A,p,i);continue}if(d==="|"){u.push(h),h="",f.push(u),u=new e(null,r);continue}if(d===")")return h===""&&r.#t.length===0&&(r.#p=!0),u.push(h),h="",r.push(...f,u),p;h+=d}return r.type=null,r.#n=void 0,r.#t=[t.substring(n-1)],p}static fromGlob(t,r={}){let n=new e(null,void 0,r);return e.#h(t,n,0,r),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,i,s]=this.toRegExpSource();if(!(i||this.#n||this.#c.nocase&&!this.#c.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let c=(this.#c.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${r}$`,c),{_src:r,_glob:t})}toRegExpSource(t){let r=t??!!this.#c.dot;if(this.#e===this&&this.#f(),!this.type){let l=this.isStart()&&this.isEnd(),p=this.#t.map(d=>{let[A,E,b,x]=typeof d=="string"?e.#d(d,this.#n,l):d.toRegExpSource(t);return this.#n=this.#n||b,this.#i=this.#i||x,A}).join(""),u="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&iPe.has(this.#t[0]))){let A=nPe,E=r&&A.has(p.charAt(0))||p.startsWith("\\.")&&A.has(p.charAt(2))||p.startsWith("\\.\\.")&&A.has(p.charAt(4)),b=!r&&!t&&A.has(p.charAt(0));u=E?rPe:b?pv:""}let f="";return this.isEnd()&&this.#e.#l&&this.#r?.type==="!"&&(f="(?:$|\\/)"),[u+p+f,Ep(p),this.#n=!!this.#n,this.#i]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#u(r);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let l=this.toString();return this.#t=[l],this.type=null,this.#n=void 0,[l,Ep(this.toString()),!1,!1]}let a=!n||t||r||!pv?"":this.#u(!0);a===s&&(a=""),a&&(s=`(?:${s})(?:${a})*?`);let c="";if(this.type==="!"&&this.#p)c=(this.isStart()&&!r?pv:"")+LY;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?pv:"")+jY+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;c=i+s+l}return[c,Ep(s),this.#n=!!this.#n,this.#i]}#u(t){return this.#t.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,s,a]=r.toRegExpSource(t);return this.#i=this.#i||a,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#d(t,r,n=!1){let i=!1,s="",a=!1;for(let c=0;c<t.length;c++){let l=t.charAt(c);if(i){i=!1,s+=(sPe.has(l)?"\\":"")+l;continue}if(l==="\\"){c===t.length-1?s+="\\\\":i=!0;continue}if(l==="["){let[p,u,f,h]=RY(t,c);if(f){s+=p,a=a||u,c+=f-1,r=r||h;continue}}if(l==="*"){n&&t==="*"?s+=LY:s+=jY,r=!0;continue}if(l==="?"){s+=bP,r=!0;continue}s+=aPe(l)}return[s,Ep(t),!!r,a]}};var EP=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var ti=(e,t,r={})=>(WA(t),!r.nocomment&&t.charAt(0)==="#"?!1:new Qh(t,r).match(e)),oPe=/^\*+([^+@!?\*\[\(]*)$/,uPe=e=>t=>!t.startsWith(".")&&t.endsWith(e),lPe=e=>t=>t.endsWith(e),cPe=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),pPe=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),dPe=/^\*+\.\*+$/,fPe=e=>!e.startsWith(".")&&e.includes("."),hPe=e=>e!=="."&&e!==".."&&e.includes("."),mPe=/^\.\*+$/,APe=e=>e!=="."&&e!==".."&&e.startsWith("."),yPe=/^\*+$/,gPe=e=>e.length!==0&&!e.startsWith("."),bPe=e=>e.length!==0&&e!=="."&&e!=="..",EPe=/^\?+([^+@!?\*\[\(]*)?$/,vPe=([e,t=""])=>{let r=qY([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},xPe=([e,t=""])=>{let r=GY([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},wPe=([e,t=""])=>{let r=GY([e]);return t?n=>r(n)&&n.endsWith(t):r},CPe=([e,t=""])=>{let r=qY([e]);return t?n=>r(n)&&n.endsWith(t):r},qY=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},GY=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},VY=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",QY={win32:{sep:"\\"},posix:{sep:"/"}},IPe=VY==="win32"?QY.win32.sep:QY.posix.sep;ti.sep=IPe;var Qo=Symbol("globstar **");ti.GLOBSTAR=Qo;var SPe="[^/]",TPe=SPe+"*?",BPe="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",_Pe="(?:(?!(?:\\/|^)\\.).)*?",DPe=(e,t={})=>r=>ti(r,e,t);ti.filter=DPe;var Lo=(e,t={})=>Object.assign({},e,t),PPe=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return ti;let t=ti;return Object.assign((n,i,s={})=>t(n,i,Lo(e,s)),{Minimatch:class extends t.Minimatch{constructor(i,s={}){super(i,Lo(e,s))}static defaults(i){return t.defaults(Lo(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,s,a={}){super(i,s,Lo(e,a))}static fromGlob(i,s={}){return t.AST.fromGlob(i,Lo(e,s))}},unescape:(n,i={})=>t.unescape(n,Lo(e,i)),escape:(n,i={})=>t.escape(n,Lo(e,i)),filter:(n,i={})=>t.filter(n,Lo(e,i)),defaults:n=>t.defaults(Lo(e,n)),makeRe:(n,i={})=>t.makeRe(n,Lo(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,Lo(e,i)),match:(n,i,s={})=>t.match(n,i,Lo(e,s)),sep:t.sep,GLOBSTAR:Qo})};ti.defaults=PPe;var HY=(e,t={})=>(WA(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:(0,UY.default)(e));ti.braceExpand=HY;var OPe=(e,t={})=>new Qh(e,t).makeRe();ti.makeRe=OPe;var FPe=(e,t,r={})=>{let n=new Qh(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};ti.match=FPe;var $Y=/[?*]|[+@!]\(.*?\)|\[|\]/,NPe=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Qh=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,r={}){WA(t),r=r||{},this.options=r,this.pattern=t,this.platform=r.platform||VY,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 n=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,a,c)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=s[0]===""&&s[1]===""&&(s[2]==="?"||!$Y.test(s[2]))&&!$Y.test(s[3]),p=/^[a-z]:/i.test(s[0]);if(l)return[...s.slice(0,4),...s.slice(4).map(u=>this.parse(u))];if(p)return[s[0],...s.slice(1).map(u=>this.parse(u))]}return s.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.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 n=0;n<t.length;n++)for(let i=0;i<t[n].length;i++)t[n][i]==="**"&&(t[n][i]="*");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 n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let s=n[n.length-1];return i==="**"&&s==="**"?n:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let s=t[i];i===1&&s===""&&t[0]===""||(s==="."||s==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let a=i;for(;n[a+1]==="**";)a++;a>i&&n.splice(i+1,a-i);let c=n[i+1],l=n[i+2],p=n[i+3];if(c!==".."||!l||l==="."||l===".."||!p||p==="."||p==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let a=1;a<n.length-1;a++){let c=n[a];a===1&&c===""&&n[0]===""||(c==="."||c==="")&&(r=!0,n.splice(a,1),a--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let s=0;for(;(s=n.indexOf("..",s+1))!==-1;){let a=n[s-1];if(a&&a!=="."&&a!==".."&&a!=="**"){r=!0;let l=s===1&&n[s+1]==="**"?["."]:[];n.splice(s-1,2,...l),n.length===0&&n.push(""),s-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);i&&(t[r]=i,t[n]=[])}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,s=0,a=[],c="";for(;i<t.length&&s<r.length;)if(t[i]===r[s])a.push(c==="b"?r[s]:t[i]),i++,s++;else if(n&&t[i]==="**"&&r[s]===t[i+1])a.push(t[i]),i++;else if(n&&r[s]==="**"&&t[i]===r[s+1])a.push(r[s]),s++;else if(t[i]==="*"&&r[s]&&(this.options.dot||!r[s].startsWith("."))&&r[s]!=="**"){if(c==="b")return!1;c="a",a.push(t[i]),i++,s++}else if(r[s]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(c==="a")return!1;c="b",a.push(r[s]),i++,s++}else return!1;return t.length===r.length&&a}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=this.options;if(this.isWindows){let E=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),b=!E&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),x=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),v=!x&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),I=b?3:E?0:void 0,B=v?3:x?0:void 0;if(typeof I=="number"&&typeof B=="number"){let[w,D]=[t[I],r[B]];w.toLowerCase()===D.toLowerCase()&&(r[B]=w,B>I?r=r.slice(B):I>B&&(t=t.slice(I)))}}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,c=0,l=t.length,p=r.length;a<l&&c<p;a++,c++){this.debug("matchOne loop");var u=r[c],f=t[a];if(this.debug(r,u,f),u===!1)return!1;if(u===Qo){this.debug("GLOBSTAR",[r,u,f]);var h=a,d=c+1;if(d===p){for(this.debug("** at the end");a<l;a++)if(t[a]==="."||t[a]===".."||!i.dot&&t[a].charAt(0)===".")return!1;return!0}for(;h<l;){var A=t[h];if(this.debug(`
2207
+ `),n=!1,i=!1,s;e.on("response",a=>{let{headers:c}=a;n=c["transfer-encoding"]==="chunked"&&!c["content-length"]}),e.on("socket",a=>{let c=()=>{if(n&&!i){let p=new Error("Premature close");p.code="ERR_STREAM_PREMATURE_CLOSE",t(p)}},l=p=>{i=d1.compare(p.slice(-5),r)===0,!i&&s&&(i=d1.compare(s.slice(-3),r.slice(0,3))===0&&d1.compare(p.slice(-2),r.slice(3))===0),s=p};a.prependListener("close",c),a.on("data",l),e.on("close",()=>{a.removeListener("close",c),a.removeListener("data",l)})})}var M_=()=>{let e=process.env.JUNO_TOKEN;if(e!==void 0)try{let{token:t}=JSON.parse(atob(e));return t}catch{throw new Error("Cannot parse token provided as an environment variable.")}},LU=()=>M_()!==void 0;var tc=()=>{let e=M_()??tp();Br(e)&&(console.log(`${(0,$U.red)("No controller found.")} Are you logged in?`),process.exit(1));let t=QU.Ed25519KeyIdentity.fromParsedJson(e);if(fL.includes(t.getPrincipal().toText()))throw new Error("The controller has been revoked for security reason!");return{identity:t,fetch:f1,...Jn(process.env.CONTAINER_URL)&&{container:process.env.CONTAINER_URL}}};var Mi=({satellite:{satelliteId:e,id:t,ids:r},env:{mode:n}})=>{let i=r?.[n]??t??e;return Br(i)&&(console.log(`${(0,UU.red)(`A satellite ID for ${n} must be set in your configuration.`)}`),process.exit(1)),{satelliteId:i,...tc()}},h1=e=>k0().find(({p:n})=>n===e)?.n??e,m1=e=>{let r=zl()?.find(({p:n})=>n===e);return r?.n!==void 0&&r?.n!==""?r.n:e};var A1=async e=>{let t=ts(e),{satellite:r}=await Ji(t),n=Ua("Clearing dapp assets...").start();try{await i$({collection:N0,satellite:Mi({satellite:r,env:t})})}finally{n.stop()}},Yve=e=>{let t=e.replace(/\\/g,"/");return`${t.startsWith("/")?"":"/"}${t}`},qU=async({fullPath:e,args:t})=>{let r=ts(t),{satellite:n}=await Ji(r),i=Ua(`Clearing ${e}...`).start();try{await I$({collection:N0,satellite:Mi({satellite:n,env:r}),fullPath:Yve(e)})}finally{i.stop()}};var GU=Bt(zt(),1),yh=()=>{console.log(`Oops! ${(0,GU.red)("No config file found.")} Try to run the command from your project root.`)};var HU=async e=>{if(!await zi()){yh();return}if(Cn({args:e,options:["-f","--fullpath","--fullPath"]})){let t=en({args:e,option:"-f"})??en({args:e,option:"--fullpath"})??en({args:e,option:"--fullPath"});if(Br(t)){console.log(`You did not provide a ${(0,VU.yellow)("fullPath")} to delete.`);return}await qU({fullPath:t,args:e});return}await A1(e)};var WU=async e=>{await zi()||await Gf();let t=ts(e),{satellite:r}=await Ji(t),{storage:n}=r,i=Ua("Configuring...").start();try{await Z7({config:{storage:{headers:n?.headers??[],rewrites:n?.rewrites,redirects:n?.redirects,iframe:n?.iframe}},satellite:Mi({satellite:r,env:t})})}finally{i.stop()}};import{Blob as GPe}from"buffer";import VPe from"crypto";import gh from"node:fs";var A9e=gh.existsSync,y9e=gh.createReadStream;async function j_(e){return new Promise((t,r)=>{gh.stat(e,(n,i)=>{n?r(n):t(i)})})}async function KU(e){return new Promise((t,r)=>{gh.close(e,n=>{n?r(n):t()})})}async function YU(e,t){return new Promise((r,n)=>{gh.open(e,t,(i,s)=>{i?n(i):r(s)})})}async function L_(e,t,r,n,i){return new Promise((s,a)=>{gh.read(e,t,r,n,i,(c,l,p)=>{c?a(c):s({bytesRead:l,buffer:p})})})}var zve="End-Of-Stream",an=class extends Error{constructor(){super(zve)}};var y1=class{constructor(){this.resolve=()=>null,this.reject=()=>null,this.promise=new Promise((t,r)=>{this.reject=r,this.resolve=t})}};var Jve=1*1024*1024,pA=class{constructor(t){if(this.s=t,this.deferred=null,this.endOfStream=!1,this.peekQueue=[],!t.read||!t.once)throw new Error("Expected an instance of stream.Readable");this.s.once("end",()=>this.reject(new an)),this.s.once("error",r=>this.reject(r)),this.s.once("close",()=>this.reject(new Error("Stream closed")))}async peek(t,r,n){let i=await this.read(t,r,n);return this.peekQueue.push(t.subarray(r,r+i)),i}async read(t,r,n){if(n===0)return 0;if(this.peekQueue.length===0&&this.endOfStream)throw new an;let i=n,s=0;for(;this.peekQueue.length>0&&i>0;){let a=this.peekQueue.pop();if(!a)throw new Error("peekData should be defined");let c=Math.min(a.length,i);t.set(a.subarray(0,c),r+s),s+=c,i-=c,c<a.length&&this.peekQueue.push(a.subarray(c))}for(;i>0&&!this.endOfStream;){let a=Math.min(i,Jve),c=await this.readFromStream(t,r+s,a);if(s+=c,c<a)break;i-=c}return s}async readFromStream(t,r,n){let i=this.s.read(n);if(i)return t.set(i,r),i.length;{let s={buffer:t,offset:r,length:n,deferred:new y1};return this.deferred=s.deferred,this.s.once("readable",()=>{this.readDeferred(s)}),s.deferred.promise}}readDeferred(t){let r=this.s.read(t.length);r?(t.buffer.set(r,t.offset),t.deferred.resolve(r.length),this.deferred=null):this.s.once("readable",()=>{this.readDeferred(t)})}reject(t){this.endOfStream=!0,this.deferred&&(this.deferred.reject(t),this.deferred=null)}};import{Buffer as JU}from"node:buffer";var dp=class{constructor(t){this.position=0,this.numBuffer=new Uint8Array(8),this.fileInfo=t||{}}async readToken(t,r=this.position){let n=JU.alloc(t.len);if(await this.readBuffer(n,{position:r})<t.len)throw new an;return t.get(n,0)}async peekToken(t,r=this.position){let n=JU.alloc(t.len);if(await this.peekBuffer(n,{position:r})<t.len)throw new an;return t.get(n,0)}async readNumber(t){if(await this.readBuffer(this.numBuffer,{length:t.len})<t.len)throw new an;return t.get(this.numBuffer,0)}async peekNumber(t){if(await this.peekBuffer(this.numBuffer,{length:t.len})<t.len)throw new an;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 Xve=256e3,g1=class extends dp{constructor(t,r){super(r),this.streamReader=new pA(t)}async getFileInfo(){return this.fileInfo}async readBuffer(t,r){let n=this.normalizeOptions(t,r),i=n.position-this.position;if(i>0)return await this.ignore(i),this.readBuffer(t,r);if(i<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let s=await this.streamReader.read(t,n.offset,n.length);if(this.position+=s,(!r||!r.mayBeLess)&&s<n.length)throw new an;return s}async peekBuffer(t,r){let n=this.normalizeOptions(t,r),i=0;if(n.position){let s=n.position-this.position;if(s>0){let a=new Uint8Array(n.length+s);return i=await this.peekBuffer(a,{mayBeLess:n.mayBeLess}),t.set(a.subarray(s),n.offset),i-s}else if(s<0)throw new Error("Cannot peek from a negative offset in a stream")}if(n.length>0){try{i=await this.streamReader.peek(t,n.offset,n.length)}catch(s){if(r&&r.mayBeLess&&s instanceof an)return 0;throw s}if(!n.mayBeLess&&i<n.length)throw new an}return i}async ignore(t){let r=Math.min(Xve,t),n=new Uint8Array(r),i=0;for(;i<t;){let s=t-i,a=await this.readBuffer(n,{length:Math.min(r,s)});if(a<0)return a;i+=a}return i}};var b1=class extends dp{constructor(t,r){super(r),this.uint8Array=t,this.fileInfo.size=this.fileInfo.size?this.fileInfo.size:t.length}async readBuffer(t,r){if(r&&r.position){if(r.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");this.position=r.position}let n=await this.peekBuffer(t,r);return this.position+=n,n}async peekBuffer(t,r){let n=this.normalizeOptions(t,r),i=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&i<n.length)throw new an;return t.set(this.uint8Array.subarray(n.position,n.position+i),n.offset),i}async close(){}};function Q_(e,t){return t=t||{},new g1(e,t)}function $_(e,t){return new b1(e,t)}var U_=class extends dp{constructor(t,r){super(r),this.fd=t}async readBuffer(t,r){let n=this.normalizeOptions(t,r);this.position=n.position;let i=await L_(this.fd,t,n.offset,n.length,n.position);if(this.position+=i.bytesRead,i.bytesRead<n.length&&(!r||!r.mayBeLess))throw new an;return i.bytesRead}async peekBuffer(t,r){let n=this.normalizeOptions(t,r),i=await L_(this.fd,t,n.offset,n.length,n.position);if(!n.mayBeLess&&i.bytesRead<n.length)throw new an;return i.bytesRead}async close(){return KU(this.fd)}};async function q_(e){let t=await j_(e);if(!t.isFile)throw new Error(`File not a file: ${e}`);let r=await YU(e,"r");return new U_(r,{path:e,size:t.size})}import{Buffer as fp}from"node:buffer";var ZU=Bt(ey(),1);import{Buffer as exe}from"node:buffer";function ma(e){return new DataView(e.buffer,e.byteOffset)}var eq={len:1,get(e,t){return ma(e).getUint8(t)},put(e,t,r){return ma(e).setUint8(t,r),t+1}},E1={len:2,get(e,t){return ma(e).getUint16(t,!0)},put(e,t,r){return ma(e).setUint16(t,r,!0),t+2}},v1={len:2,get(e,t){return ma(e).getUint16(t)},put(e,t,r){return ma(e).setUint16(t,r),t+2}};var tq={len:4,get(e,t){return ma(e).getUint32(t,!0)},put(e,t,r){return ma(e).setUint32(t,r,!0),t+4}},rq={len:4,get(e,t){return ma(e).getUint32(t)},put(e,t,r){return ma(e).setUint32(t,r),t+4}};var nq={len:4,get(e,t){return ma(e).getInt32(t)},put(e,t,r){return ma(e).setInt32(t,r),t+4}};var iq={len:8,get(e,t){return ma(e).getBigUint64(t,!0)},put(e,t,r){return ma(e).setBigUint64(t,r,!0),t+8}};var rc=class{constructor(t,r){this.len=t,this.encoding=r}get(t,r){return exe.from(t).toString(this.encoding,r,r+this.len)}},G_=class e{constructor(t){this.len=t}static decode(t,r,n){let i="";for(let s=r;s<n;++s)i+=e.codePointToString(e.singleByteDecoder(t[s]));return i}static inRange(t,r,n){return r<=t&&t<=n}static codePointToString(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}static singleByteDecoder(t){if(e.inRange(t,0,127))return t;let r=e.windows1252[t-128];if(r===null)throw Error("invaliding encoding");return r}get(t,r=0){return e.decode(t,r,r+this.len)}};G_.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 sq(e){return[...e].map(t=>t.charCodeAt(0))}function aq(e,t=0){let r=Number.parseInt(e.toString("utf8",148,154).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(r))return!1;let n=8*32;for(let i=t;i<t+148;i++)n+=e[i];for(let i=t+156;i<t+512;i++)n+=e[i];return r===n}var oq={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4};var uq=["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","macho","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","j2c","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","class","arj","cpio","ace","avro","icc","fbx"],lq=["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/wav","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-mach-binary","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/j2c","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","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx"];var cq=4100;function fl(e,t,r){r={offset:0,...r};for(let[n,i]of t.entries())if(r.mask){if(i!==(r.mask[n]&e[n+r.offset]))return!1}else if(i!==e[n+r.offset])return!1;return!0}var x1=class{constructor(t){this.detectors=t?.customDetectors,this.fromTokenizer=this.fromTokenizer.bind(this),this.fromBuffer=this.fromBuffer.bind(this),this.parse=this.parse.bind(this)}async fromTokenizer(t){let r=t.position;for(let n of this.detectors||[]){let i=await n(t);if(i)return i;if(r!==t.position)return}return this.parse(t)}async fromBuffer(t){if(!(t instanceof Uint8Array||t instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`Buffer\` or \`ArrayBuffer\`, got \`${typeof t}\``);let r=t instanceof Uint8Array?t:new Uint8Array(t);if(r?.length>1)return this.fromTokenizer($_(r))}async fromBlob(t){let r=await t.arrayBuffer();return this.fromBuffer(new Uint8Array(r))}async fromStream(t){let r=await Q_(t);try{return await this.fromTokenizer(r)}finally{await r.close()}}async toDetectionStream(t,r={}){let{default:n}=await import("node:stream"),{sampleSize:i=cq}=r;return new Promise((s,a)=>{t.on("error",a),t.once("readable",()=>{(async()=>{try{let c=new n.PassThrough,l=n.pipeline?n.pipeline(t,c,()=>{}):t.pipe(c),p=t.read(i)??t.read()??fp.alloc(0);try{c.fileType=await this.fromBuffer(p)}catch(u){u instanceof an?c.fileType=void 0:a(u)}s(l)}catch(c){a(c)}})()})})}check(t,r){return fl(this.buffer,t,r)}checkString(t,r){return this.check(sq(t),r)}async parse(t){if(this.buffer=fp.alloc(cq),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([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};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(oq);return t.position+r>t.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await t.ignore(r),this.fromTokenizer(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.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};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 rc(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 n=await t.readToken(new rc(r.compressedSize,"utf-8"));switch(n=n.trim(),n){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 n=-1;for(;n<0&&t.position<t.fileInfo.size;)await t.peekBuffer(this.buffer,{mayBeLess:!0}),n=this.buffer.indexOf("504B0304",0,"hex"),await t.ignore(n>=0?n:this.buffer.length)}else await t.ignore(r.compressedSize)}}catch(r){if(!(r instanceof an))throw r}return{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await t.ignore(28);let r=fp.alloc(8);return await t.readBuffer(r),fl(r,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/opus"}:fl(r,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:fl(r,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:fl(r,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:fl(r,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:fl(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,n=fp.alloc(Math.min(r,t.fileInfo.size));if(await t.readBuffer(n,{mayBeLess:!0}),n.includes(fp.from("AIPrivateData")))return{ext:"ai",mime:"application/postscript"}}catch(r){if(!(r instanceof an))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 c=await t.peekNumber(eq),l=128,p=0;for(;!(c&l)&&l!==0;)++p,l>>=1;let u=fp.alloc(p+1);return await t.readBuffer(u),u}async function n(){let c=await r(),l=await r();l[0]^=128>>l.length-1;let p=Math.min(6,l.length);return{id:c.readUIntBE(0,c.length),len:l.readUIntBE(l.length-p,p)}}async function i(c){for(;c>0;){let l=await n();if(l.id===17026)return(await t.readToken(new rc(l.len,"utf-8"))).replaceAll(/\00.*$/g,"");await t.ignore(l.len),--c}}let s=await n();switch(await i(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/wav"};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([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};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([202,254,186,190]))return{ext:"class",mime:"application/java-vm"};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("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await t.ignore(8),await t.readToken(new rc(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("**ACE",{offset:7})&&(await t.peekBuffer(this.buffer,{length:14,mayBeLess:!0}),this.checkString("**",{offset:12})))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.check([137,80,78,71,13,10,26,10])){await t.ignore(8);async function r(){return{length:await t.readToken(nq),type:await t.readToken(new rc(4,"binary"))}}do{let n=await r();if(n.length<0)return;switch(n.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await t.ignore(n.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 n=fp.alloc(16);return await t.readBuffer(n),{id:n,size:Number(await t.readToken(iq))}}for(await t.ignore(30);t.position+24<t.fileInfo.size;){let n=await r(),i=n.size-24;if(fl(n.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let s=fp.alloc(16);if(i-=await t.readBuffer(s),fl(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(fl(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(i)}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([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await t.ignore(20),await t.readToken(new rc(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.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(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 n=this.buffer.slice(16,r+16).toString();if(JSON.parse(n).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.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};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}),aq(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?v1:E1);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?v1:E1);for(let n=0;n<r;++n){let i=await this.readTiffTag(t);if(i)return i}}async readTiffHeader(t){let r=(t?v1:E1).get(this.buffer,2),n=(t?rq:tq).get(this.buffer,4);if(r===42){if(n>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(n>=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(n),await this.readTiffIFD(t)??{ext:"tif",mime:"image/tiff"}}if(r===43)return{ext:"tif",mime:"image/tiff"}}};var z9e=new Set(uq),J9e=new Set(lq);async function pq(e,t){let r=await q_(e);try{return await new x1(t).fromTokenizer(r)}finally{await r.close()}}var sz=Bt(zt(),1),az=Bt(mY(),1),oz=Bt(vY(),1);var UY=Bt(NY(),1);var WA=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Z2e={"[: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]},KA=e=>e.replace(/[[\]\\-]/g,"\\$&"),ePe=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),kY=e=>e.join(""),RY=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],s=r+1,a=!1,c=!1,l=!1,p=!1,u=r,f="";e:for(;s<e.length;){let E=e.charAt(s);if((E==="!"||E==="^")&&s===r+1){p=!0,s++;continue}if(E==="]"&&a&&!l){u=s+1;break}if(a=!0,E==="\\"&&!l){l=!0,s++;continue}if(E==="["&&!l){for(let[b,[x,v,I]]of Object.entries(Z2e))if(e.startsWith(b,s)){if(f)return["$.",!1,e.length-r,!0];s+=b.length,I?i.push(x):n.push(x),c=c||v;continue e}}if(l=!1,f){E>f?n.push(KA(f)+"-"+KA(E)):E===f&&n.push(KA(E)),f="",s++;continue}if(e.startsWith("-]",s+1)){n.push(KA(E+"-")),s+=2;continue}if(e.startsWith("-",s+1)){f=E,s+=2;continue}n.push(KA(E)),s++}if(u<s)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!p){let E=n[0].length===2?n[0].slice(-1):n[0];return[ePe(E),!1,u-r,!1]}let h="["+(p?"^":"")+kY(n)+"]",d="["+(p?"":"^")+kY(i)+"]";return[n.length&&i.length?"("+h+"|"+d+")":n.length?h:d,c,u-r,!0]};var Ep=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var tPe=new Set(["!","?","+","*","@"]),MY=e=>tPe.has(e),rPe="(?!(?:^|/)\\.\\.?(?:$|/))",pv="(?!\\.)",nPe=new Set(["[","."]),iPe=new Set(["..","."]),sPe=new Set("().*{}+?[]^$\\!"),aPe=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),bP="[^/]",jY=bP+"*?",LY=bP+"+?",Lh=class e{type;#e;#n;#i=!1;#t=[];#r;#a;#s;#l=!1;#c;#o;#p=!1;constructor(t,r,n={}){this.type=t,t&&(this.#n=!0),this.#r=r,this.#e=this.#r?this.#r.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#s=this.#e===this?[]:this.#e.#s,t==="!"&&!this.#e.#l&&this.#s.push(this),this.#a=this.#r?this.#r.#t.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(let t of this.#t)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#n=!0;return this.#n}toString(){return this.#o!==void 0?this.#o:this.type?this.#o=this.type+"("+this.#t.map(t=>String(t)).join("|")+")":this.#o=this.#t.map(t=>String(t)).join("")}#f(){if(this!==this.#e)throw new Error("should only call on root");if(this.#l)return this;this.toString(),this.#l=!0;let t;for(;t=this.#s.pop();){if(t.type!=="!")continue;let r=t,n=r.#r;for(;n;){for(let i=r.#a+1;!n.type&&i<n.#t.length;i++)for(let s of t.#t){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(n.#t[i])}r=n,n=r.#r}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof e&&r.#r===this))throw new Error("invalid part: "+r);this.#t.push(r)}}toJSON(){let t=this.type===null?this.#t.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#t.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#l&&this.#r?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#r?.isStart())return!1;if(this.#a===0)return!0;let t=this.#r;for(let r=0;r<this.#a;r++){let n=t.#t[r];if(!(n instanceof e&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#r?.type==="!")return!0;if(!this.#r?.isEnd())return!1;if(!this.type)return this.#r?.isEnd();let t=this.#r?this.#r.#t.length:0;return this.#a===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new e(this.type,t);for(let n of this.#t)r.copyIn(n);return r}static#h(t,r,n,i){let s=!1,a=!1,c=-1,l=!1;if(r.type===null){let d=n,A="";for(;d<t.length;){let E=t.charAt(d++);if(s||E==="\\"){s=!s,A+=E;continue}if(a){d===c+1?(E==="^"||E==="!")&&(l=!0):E==="]"&&!(d===c+2&&l)&&(a=!1),A+=E;continue}else if(E==="["){a=!0,c=d,l=!1,A+=E;continue}if(!i.noext&&MY(E)&&t.charAt(d)==="("){r.push(A),A="";let b=new e(E,r);d=e.#h(t,b,d,i),r.push(b);continue}A+=E}return r.push(A),d}let p=n+1,u=new e(null,r),f=[],h="";for(;p<t.length;){let d=t.charAt(p++);if(s||d==="\\"){s=!s,h+=d;continue}if(a){p===c+1?(d==="^"||d==="!")&&(l=!0):d==="]"&&!(p===c+2&&l)&&(a=!1),h+=d;continue}else if(d==="["){a=!0,c=p,l=!1,h+=d;continue}if(MY(d)&&t.charAt(p)==="("){u.push(h),h="";let A=new e(d,u);u.push(A),p=e.#h(t,A,p,i);continue}if(d==="|"){u.push(h),h="",f.push(u),u=new e(null,r);continue}if(d===")")return h===""&&r.#t.length===0&&(r.#p=!0),u.push(h),h="",r.push(...f,u),p;h+=d}return r.type=null,r.#n=void 0,r.#t=[t.substring(n-1)],p}static fromGlob(t,r={}){let n=new e(null,void 0,r);return e.#h(t,n,0,r),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,i,s]=this.toRegExpSource();if(!(i||this.#n||this.#c.nocase&&!this.#c.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let c=(this.#c.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${r}$`,c),{_src:r,_glob:t})}toRegExpSource(t){let r=t??!!this.#c.dot;if(this.#e===this&&this.#f(),!this.type){let l=this.isStart()&&this.isEnd(),p=this.#t.map(d=>{let[A,E,b,x]=typeof d=="string"?e.#d(d,this.#n,l):d.toRegExpSource(t);return this.#n=this.#n||b,this.#i=this.#i||x,A}).join(""),u="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&iPe.has(this.#t[0]))){let A=nPe,E=r&&A.has(p.charAt(0))||p.startsWith("\\.")&&A.has(p.charAt(2))||p.startsWith("\\.\\.")&&A.has(p.charAt(4)),b=!r&&!t&&A.has(p.charAt(0));u=E?rPe:b?pv:""}let f="";return this.isEnd()&&this.#e.#l&&this.#r?.type==="!"&&(f="(?:$|\\/)"),[u+p+f,Ep(p),this.#n=!!this.#n,this.#i]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#u(r);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let l=this.toString();return this.#t=[l],this.type=null,this.#n=void 0,[l,Ep(this.toString()),!1,!1]}let a=!n||t||r||!pv?"":this.#u(!0);a===s&&(a=""),a&&(s=`(?:${s})(?:${a})*?`);let c="";if(this.type==="!"&&this.#p)c=(this.isStart()&&!r?pv:"")+LY;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?pv:"")+jY+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;c=i+s+l}return[c,Ep(s),this.#n=!!this.#n,this.#i]}#u(t){return this.#t.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,s,a]=r.toRegExpSource(t);return this.#i=this.#i||a,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#d(t,r,n=!1){let i=!1,s="",a=!1;for(let c=0;c<t.length;c++){let l=t.charAt(c);if(i){i=!1,s+=(sPe.has(l)?"\\":"")+l;continue}if(l==="\\"){c===t.length-1?s+="\\\\":i=!0;continue}if(l==="["){let[p,u,f,h]=RY(t,c);if(f){s+=p,a=a||u,c+=f-1,r=r||h;continue}}if(l==="*"){n&&t==="*"?s+=LY:s+=jY,r=!0;continue}if(l==="?"){s+=bP,r=!0;continue}s+=aPe(l)}return[s,Ep(t),!!r,a]}};var EP=(e,{windowsPathsNoEscape:t=!1}={})=>t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var ti=(e,t,r={})=>(WA(t),!r.nocomment&&t.charAt(0)==="#"?!1:new Qh(t,r).match(e)),oPe=/^\*+([^+@!?\*\[\(]*)$/,uPe=e=>t=>!t.startsWith(".")&&t.endsWith(e),lPe=e=>t=>t.endsWith(e),cPe=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),pPe=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),dPe=/^\*+\.\*+$/,fPe=e=>!e.startsWith(".")&&e.includes("."),hPe=e=>e!=="."&&e!==".."&&e.includes("."),mPe=/^\.\*+$/,APe=e=>e!=="."&&e!==".."&&e.startsWith("."),yPe=/^\*+$/,gPe=e=>e.length!==0&&!e.startsWith("."),bPe=e=>e.length!==0&&e!=="."&&e!=="..",EPe=/^\?+([^+@!?\*\[\(]*)?$/,vPe=([e,t=""])=>{let r=qY([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},xPe=([e,t=""])=>{let r=GY([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},wPe=([e,t=""])=>{let r=GY([e]);return t?n=>r(n)&&n.endsWith(t):r},CPe=([e,t=""])=>{let r=qY([e]);return t?n=>r(n)&&n.endsWith(t):r},qY=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},GY=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},VY=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",QY={win32:{sep:"\\"},posix:{sep:"/"}},IPe=VY==="win32"?QY.win32.sep:QY.posix.sep;ti.sep=IPe;var Qo=Symbol("globstar **");ti.GLOBSTAR=Qo;var SPe="[^/]",TPe=SPe+"*?",BPe="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",_Pe="(?:(?!(?:\\/|^)\\.).)*?",DPe=(e,t={})=>r=>ti(r,e,t);ti.filter=DPe;var Lo=(e,t={})=>Object.assign({},e,t),PPe=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return ti;let t=ti;return Object.assign((n,i,s={})=>t(n,i,Lo(e,s)),{Minimatch:class extends t.Minimatch{constructor(i,s={}){super(i,Lo(e,s))}static defaults(i){return t.defaults(Lo(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,s,a={}){super(i,s,Lo(e,a))}static fromGlob(i,s={}){return t.AST.fromGlob(i,Lo(e,s))}},unescape:(n,i={})=>t.unescape(n,Lo(e,i)),escape:(n,i={})=>t.escape(n,Lo(e,i)),filter:(n,i={})=>t.filter(n,Lo(e,i)),defaults:n=>t.defaults(Lo(e,n)),makeRe:(n,i={})=>t.makeRe(n,Lo(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,Lo(e,i)),match:(n,i,s={})=>t.match(n,i,Lo(e,s)),sep:t.sep,GLOBSTAR:Qo})};ti.defaults=PPe;var HY=(e,t={})=>(WA(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:(0,UY.default)(e));ti.braceExpand=HY;var OPe=(e,t={})=>new Qh(e,t).makeRe();ti.makeRe=OPe;var FPe=(e,t,r={})=>{let n=new Qh(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};ti.match=FPe;var $Y=/[?*]|[+@!]\(.*?\)|\[|\]/,NPe=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Qh=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,r={}){WA(t),r=r||{},this.options=r,this.pattern=t,this.platform=r.platform||VY,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 n=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,a,c)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=s[0]===""&&s[1]===""&&(s[2]==="?"||!$Y.test(s[2]))&&!$Y.test(s[3]),p=/^[a-z]:/i.test(s[0]);if(l)return[...s.slice(0,4),...s.slice(4).map(u=>this.parse(u))];if(p)return[s[0],...s.slice(1).map(u=>this.parse(u))]}return s.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.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 n=0;n<t.length;n++)for(let i=0;i<t[n].length;i++)t[n][i]==="**"&&(t[n][i]="*");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 n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let s=n[n.length-1];return i==="**"&&s==="**"?n:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let s=t[i];i===1&&s===""&&t[0]===""||(s==="."||s==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let a=i;for(;n[a+1]==="**";)a++;a>i&&n.splice(i+1,a-i);let c=n[i+1],l=n[i+2],p=n[i+3];if(c!==".."||!l||l==="."||l===".."||!p||p==="."||p==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let a=1;a<n.length-1;a++){let c=n[a];a===1&&c===""&&n[0]===""||(c==="."||c==="")&&(r=!0,n.splice(a,1),a--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let s=0;for(;(s=n.indexOf("..",s+1))!==-1;){let a=n[s-1];if(a&&a!=="."&&a!==".."&&a!=="**"){r=!0;let l=s===1&&n[s+1]==="**"?["."]:[];n.splice(s-1,2,...l),n.length===0&&n.push(""),s-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);i&&(t[r]=i,t[n]=[])}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,s=0,a=[],c="";for(;i<t.length&&s<r.length;)if(t[i]===r[s])a.push(c==="b"?r[s]:t[i]),i++,s++;else if(n&&t[i]==="**"&&r[s]===t[i+1])a.push(t[i]),i++;else if(n&&r[s]==="**"&&t[i]===r[s+1])a.push(r[s]),s++;else if(t[i]==="*"&&r[s]&&(this.options.dot||!r[s].startsWith("."))&&r[s]!=="**"){if(c==="b")return!1;c="a",a.push(t[i]),i++,s++}else if(r[s]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(c==="a")return!1;c="b",a.push(r[s]),i++,s++}else return!1;return t.length===r.length&&a}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=this.options;if(this.isWindows){let E=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),b=!E&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),x=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),v=!x&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),I=b?3:E?0:void 0,B=v?3:x?0:void 0;if(typeof I=="number"&&typeof B=="number"){let[w,D]=[t[I],r[B]];w.toLowerCase()===D.toLowerCase()&&(r[B]=w,B>I?r=r.slice(B):I>B&&(t=t.slice(I)))}}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,c=0,l=t.length,p=r.length;a<l&&c<p;a++,c++){this.debug("matchOne loop");var u=r[c],f=t[a];if(this.debug(r,u,f),u===!1)return!1;if(u===Qo){this.debug("GLOBSTAR",[r,u,f]);var h=a,d=c+1;if(d===p){for(this.debug("** at the end");a<l;a++)if(t[a]==="."||t[a]===".."||!i.dot&&t[a].charAt(0)===".")return!1;return!0}for(;h<l;){var A=t[h];if(this.debug(`
2208
2208
  globstar while`,t,h,r,d,A),this.matchOne(t.slice(h),r.slice(d),n))return this.debug("globstar found match!",h,l,A),!0;if(A==="."||A===".."||!i.dot&&A.charAt(0)==="."){this.debug("dot detected!",t,h,r,d);break}this.debug("globstar swallow a segment, and continue"),h++}return!!(n&&(this.debug(`
2209
2209
  >>> no match, partial?`,t,h,r,d),h===l))}let E;if(typeof u=="string"?(E=f===u,this.debug("string match",u,f,E)):(E=u.test(f),this.debug("pattern match",u,f,E)),!E)return!1}if(a===l&&c===p)return!0;if(a===l)return n;if(c===p)return a===l-1&&t[a]==="";throw new Error("wtf?")}braceExpand(){return HY(this.pattern,this.options)}parse(t){WA(t);let r=this.options;if(t==="**")return Qo;if(t==="")return"";let n,i=null;(n=t.match(yPe))?i=r.dot?bPe:gPe:(n=t.match(oPe))?i=(r.nocase?r.dot?pPe:cPe:r.dot?lPe:uPe)(n[1]):(n=t.match(EPe))?i=(r.nocase?r.dot?xPe:vPe:r.dot?wPe:CPe)(n):(n=t.match(dPe))?i=r.dot?hPe:fPe:(n=t.match(mPe))&&(i=APe);let s=Lh.fromGlob(t,this.options).toMMPattern();return i?Object.assign(s,{test:i}):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,n=r.noglobstar?TPe:r.dot?BPe:_Pe,i=new Set(r.nocase?["i"]:[]),s=t.map(l=>{let p=l.map(u=>{if(u instanceof RegExp)for(let f of u.flags.split(""))i.add(f);return typeof u=="string"?NPe(u):u===Qo?Qo:u._src});return p.forEach((u,f)=>{let h=p[f+1],d=p[f-1];u!==Qo||d===Qo||(d===void 0?h!==void 0&&h!==Qo?p[f+1]="(?:\\/|"+n+"\\/)?"+h:p[f]=n:h===void 0?p[f-1]=d+"(?:\\/|"+n+")?":h!==Qo&&(p[f-1]=d+"(?:\\/|\\/"+n+"\\/)"+h,p[f+1]=Qo))}),p.filter(u=>u!==Qo).join("/")}).join("|"),[a,c]=t.length>1?["(?:",")"]:["",""];s="^"+a+s+c+"$",this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].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 n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let a=i[i.length-1];if(!a)for(let c=i.length-2;!a&&c>=0;c--)a=i[c];for(let c=0;c<s.length;c++){let l=s[c],p=i;if(n.matchBase&&l.length===1&&(p=[a]),this.matchOne(p,l,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return ti.defaults(t).Minimatch}};ti.AST=Lh;ti.Minimatch=Qh;ti.escape=EP;ti.unescape=Ep;import{lstatSync as HPe}from"node:fs";import{readFile as uz}from"node:fs/promises";import{basename as WPe,extname as wP,join as KPe,relative as YPe}from"node:path";var WY=Bt(zt(),1),KY=Bt(ep(),1);var YY=async e=>{let t=ts(e),{satellite:r}=await Ji(t),{assertions:n}=r;if(n?.heapMemory===!1)return;let i=Mi({satellite:r,env:t}),s=await Ad({satellite:i});if((0,KY.compare)(s,HQ)<0){console.log(`Your satellite (${(0,WY.yellow)(`v${s}`)}) is not up-to-date, and the memory size cannot be verified.${Fi}`);return}let a=n?.heapMemory!==void 0&&typeof n?.heapMemory!="boolean"?BigInt(n?.heapMemory):WQ,{heap:c}=await n$({satellite:i});if(c<a)return;let l=p=>Intl.NumberFormat("en-US",{maximumSignificantDigits:3}).format(Number(p)/1e6);await Yi(`\u26A0\uFE0F Your satellite's heap memory is ${l(c)} MB, which exceeds the recommended limit of ${l(a)} MB. Are you sure you want to proceed with the deployment?`)},vP=async({startAfter:e,env:t})=>{let{assets:r,items_page:n,matches_pages:i}=await C$({collection:N0,satellite:Mi(t),filter:{order:{desc:!0,field:"keys"},paginate:{startAfter:e,limit:500}}}),s=a=>{let{length:c,[c-1]:l}=a;return l};if((n??0n)<(i??0n)){let a=await vP({startAfter:s(r)?.fullPath,env:t});return[...r,...a]}return r};var zY=Bt(zt(),1);var $h=e=>`https://${e}.icp0.io`,dv=e=>`${cL}${e}`;var fv=async e=>{if(LU()||!await zi())return;let t=ts(e),{satellite:r}=await Ji(t),n=Mi({satellite:r,env:t}),{satelliteId:i}=n,s=$h(i),a=dv(i);try{let c=await nh({satellite:n});if(console.log(`
2210
2210
  \u{1F6E0}\uFE0F ${Wf(a)}`),c.length===0){console.log(`\u{1F6F0}\uFE0F ${Wf(s)}`);return}c.forEach(({domain:l})=>{console.log(`\u{1F30D} ${Wf(`https://${l}`)}`)})}catch{console.log(`${(0,zY.red)("Cannot list the custom domains.")}`)}};import{createReadStream as RPe,createWriteStream as MPe}from"node:fs";import{Readable as jPe}from"node:stream";import{createGzip as LPe}from"node:zlib";import{createGunzip as QPe}from"zlib";var JY=async({sourceFiles:e,gzip:t})=>{if(t===!1)return[];let r=t===!0?pE:t,n=e.filter(i=>ti(i,r));return await Promise.all(n.map(async i=>await xP({source:i})))},xP=async({source:e,destination:t})=>await new Promise((r,n)=>{let i=RPe(e),s=t??`${e}.gz`,a=MPe(s),c=LPe();i.pipe(c).pipe(a),a.on("close",()=>{r(s)}),a.on("error",n)}),XY=async({source:e})=>await new Promise((t,r)=>{let n=jPe.from(e),i=[],s=QPe();n.pipe(s),s.on("data",a=>i.push(a)),s.on("end",()=>{t(Buffer.concat(i))}),s.on("error",r)}),ZY=e=>e.length>2&&e[0]===31&&e[1]===139;import{lstatSync as tz,readdirSync as $Pe}from"node:fs";import{basename as UPe,join as ez}from"node:path";var rz=({sourceAbsolutePath:e,ignore:t})=>nz(e).filter(n=>qPe({file:n,ignore:t})),qPe=({file:e,ignore:t})=>tz(e).size<=0||dL.includes(UPe(e).toLowerCase())?!1:t.find(r=>ti(e,r))===void 0,nz=e=>$Pe(e).flatMap(t=>{let r=ez(e,t);return tz(r).isDirectory()?nz(r):ez(r)});var lz=async e=>{await zi()||await Gf(),Cn({args:e,options:["-c","--clear"]})&&await A1(e),await zPe(e),await fv(e)},zPe=async e=>{let t=ts(e),{satellite:r}=await Ji(t),{source:n=cE,ignore:i=GQ,encoding:s=VQ,gzip:a=pE}=r,c=KPe(process.cwd(),n),l=await tOe({sourceAbsolutePath:c,ignore:i,encoding:s,gzip:a,satellite:r,env:t});if(l.length===0){console.log("No new files to upload.");return}await YY(e);let p=Mi({satellite:r,env:t}),u=d=>d.alternateFile??d.file,f=async d=>{let A=u(d);return await w$({satellite:p,filename:WPe(A),fullPath:cz({file:A,sourceAbsolutePath:c}),data:new GPe([await uz(d.file)]),collection:lL,headers:[...d.mime===void 0?[]:[["Content-Type",d.mime]]],encoding:d.encoding})},h=async d=>{for(let A=0;A<d.length;A+=20){let E=d.slice(A,A+20);await new az.default(E.map(x=>({title:`Uploading ${YPe(c,x.file)}`,task:async()=>await f(x)})),{concurrent:!0}).run()}};await h(l.filter(({alternateFile:d})=>Jn(d))),await h(l.filter(({alternateFile:d})=>Br(d))),console.log(`
@@ -2214,7 +2214,7 @@ Are you sure the folder containing your built app (the "source" tag in the confi
2214
2214
  ${r}`,"utf-8")},lOe=async()=>{await iOe(Ez,{recursive:!0}),await Tu({command:"ic-wasm",args:[Fd(bz,"satellite.wasm"),"-o",$o,"shrink"]}),await Tu({command:"ic-wasm",args:[$o,"-o",$o,"metadata","candid:service","-f",xz,"-v","public"]}),await Tu({command:"ic-wasm",args:[$o,"-o",$o,"metadata","juno:build","-d","extended","-v","public"]}),await Tu({command:"ic-wasm",args:[$o,"-o",$o,"metadata","supported_certificate_versions","-d",'"1,2"',"-v","public"]})},cOe=async e=>{let t=`${$o}.gz`,{size:r}=await nOe(t),n=i=>Intl.NumberFormat("en-US",{maximumSignificantDigits:2}).format(i/(1024*1024));e.succeed(`${(0,Al.green)("Success!")}
2215
2215
 
2216
2216
  The satellite has been compiled.
2217
- Output file: ${(0,Al.yellow)(`${aOe(process.cwd(),t)}`)} ${(0,Al.grey)(`(${n(r)}MB)`)}`)},pOe=async()=>{let{valid:e}=await Az();return e===!1?{valid:e}:(e==="error"&&(await Yi(`The ${(0,Al.magenta)("ic-wasm")} ${(0,Al.yellow)(`v${qh}`)} tool is required to build a satellite but appears to be not available. Would you like to install it on your machine?`),await uc({command:"cargo",args:["install",`ic-wasm@${qh}`]})),{valid:!0})},dOe=async()=>{let{valid:e}=await yz();return e===!1?{valid:e}:(e==="error"&&(await Yi(`The ${(0,Al.magenta)("candid-extractor")} tool is required to generate the API ("did file") of your custom satellite but appears to be not available. Would you like to install it on your machine?`),await uc({command:"cargo",args:["install","candid-extractor"]})),{valid:!0})};var Tz=Bt(zt(),1);import{existsSync as fOe}from"node:fs";import{writeFile as hOe}from"node:fs/promises";import{join as mOe}from"node:path";var Cz={filename:F0},Iz=async()=>await lE(Cz),Sz=()=>Uf(Cz);var Bz="../templates/docker",_z=process.cwd(),Dz=async()=>{let{valid:e}=await TP();e==="error"||!e||(await BP(),await AOe(),await yOe(),await uc({command:"docker",args:["compose","up"]}))},Pz=async()=>{let{valid:e}=await TP();e==="error"||!e||(await BP(),await uc({command:"docker",args:["compose","stop"]}))},AOe=async()=>{if(await Iz())return;await Yi("A config file is required for development. Would you like the CLI to create one for you?");let e=await dE();await ip({template:`${F0}.${e}`,sourceFolder:Bz,destinationFolder:_z})},yOe=async()=>{if(fOe("docker-compose.yml"))return;await Yi(`The CLI utilizes Docker Compose, which is handy for customizing configurations. Would you like the CLI to generate a default ${(0,Tz.magenta)("docker-compose.yml")} file for you?`);let{configType:e}=Sz(),t=await qf({template:"docker-compose.yml",sourceFolder:Bz}),r=`${F0}.${e}`,n=t.replaceAll("<JUNO_DEV_CONFIG>",r);await hOe(mOe(_z,"docker-compose.yml"),n,"utf-8")};var vp=Bt(zt(),1);import{mkdir as EOe}from"node:fs/promises";import{join as Uz}from"node:path";var Tt=Bt(zt(),1);var Av="0.0.55";var bOe=` __ __ __ __ _ ____
2217
+ Output file: ${(0,Al.yellow)(`${aOe(process.cwd(),t)}`)} ${(0,Al.grey)(`(${n(r)}MB)`)}`)},pOe=async()=>{let{valid:e}=await Az();return e===!1?{valid:e}:(e==="error"&&(await Yi(`The ${(0,Al.magenta)("ic-wasm")} ${(0,Al.yellow)(`v${qh}`)} tool is required to build a satellite but appears to be not available. Would you like to install it on your machine?`),await uc({command:"cargo",args:["install",`ic-wasm@${qh}`]})),{valid:!0})},dOe=async()=>{let{valid:e}=await yz();return e===!1?{valid:e}:(e==="error"&&(await Yi(`The ${(0,Al.magenta)("candid-extractor")} tool is required to generate the API ("did file") of your custom satellite but appears to be not available. Would you like to install it on your machine?`),await uc({command:"cargo",args:["install","candid-extractor"]})),{valid:!0})};var Tz=Bt(zt(),1);import{existsSync as fOe}from"node:fs";import{writeFile as hOe}from"node:fs/promises";import{join as mOe}from"node:path";var Cz={filename:F0},Iz=async()=>await lE(Cz),Sz=()=>Uf(Cz);var Bz="../templates/docker",_z=process.cwd(),Dz=async()=>{let{valid:e}=await TP();e==="error"||!e||(await BP(),await AOe(),await yOe(),await uc({command:"docker",args:["compose","up"]}))},Pz=async()=>{let{valid:e}=await TP();e==="error"||!e||(await BP(),await uc({command:"docker",args:["compose","stop"]}))},AOe=async()=>{if(await Iz())return;await Yi("A config file is required for development. Would you like the CLI to create one for you?");let e=await dE();await ip({template:`${F0}.${e}`,sourceFolder:Bz,destinationFolder:_z})},yOe=async()=>{if(fOe("docker-compose.yml"))return;await Yi(`The CLI utilizes Docker Compose, which is handy for customizing configurations. Would you like the CLI to generate a default ${(0,Tz.magenta)("docker-compose.yml")} file for you?`);let{configType:e}=Sz(),t=await qf({template:"docker-compose.yml",sourceFolder:Bz}),r=`${F0}.${e}`,n=t.replaceAll("<JUNO_DEV_CONFIG>",r);await hOe(mOe(_z,"docker-compose.yml"),n,"utf-8")};var vp=Bt(zt(),1);import{mkdir as EOe}from"node:fs/promises";import{join as Uz}from"node:path";var Tt=Bt(zt(),1);var Av="0.0.57";var bOe=` __ __ __ __ _ ____
2218
2218
  __) || | || \\| |/ \\
2219
2219
  \\___/ \\___/ |_|\\__|\\____/`,yl=`${bOe} CLI ${(0,Tt.grey)(`v${Av}`)}`,yv=`
2220
2220
  ${yl}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junobuild/cli",
3
- "version": "0.0.55",
3
+ "version": "0.0.57",
4
4
  "description": "The Juno command-line interface",
5
5
  "author": "David Dal Busco (https://daviddalbusco.com)",
6
6
  "license": "MIT",
@@ -31,8 +31,8 @@
31
31
  "@dfinity/identity": "^1.0.1",
32
32
  "@dfinity/principal": "^1.0.1",
33
33
  "@junobuild/admin": "^0.0.46",
34
- "@junobuild/cli-tools": "^0.0.3",
35
- "@junobuild/config": "^0.0.2",
34
+ "@junobuild/cli-tools": "^0.0.5",
35
+ "@junobuild/config": "^0.0.4",
36
36
  "@junobuild/core-peer": "^0.0.11",
37
37
  "@junobuild/utils": "^0.0.19",
38
38
  "conf": "^12.0.0",
@@ -12,7 +12,7 @@ ic-cdk = "0.12.1"
12
12
  ic-cdk-macros = "0.8.1"
13
13
  serde = "1.0.190"
14
14
  serde_cbor = "0.11.2"
15
- junobuild-satellite = "0.0.15-patch.1"
15
+ junobuild-satellite = "0.0.15-patch.2"
16
16
  junobuild-macros = "0.0.1"
17
17
  junobuild-utils = "0.0.1"
18
18
 
@@ -3,10 +3,10 @@ import {defineConfig} from '@junobuild/config';
3
3
  /** @type {import('@junobuild/config').JunoConfig} */
4
4
  export default defineConfig({
5
5
  satellite: {
6
- satelliteId: '<SATELLITE_ID>',
6
+ id: '<SATELLITE_ID>',
7
7
  source: '<SOURCE>'
8
8
  },
9
9
  orbiter: {
10
- orbiterId: '<ORBITER_ID>'
10
+ id: '<ORBITER_ID>'
11
11
  }
12
12
  });
@@ -2,10 +2,10 @@ import {defineConfig} from '@junobuild/config';
2
2
 
3
3
  export default defineConfig({
4
4
  satellite: {
5
- satelliteId: '<SATELLITE_ID>',
5
+ id: '<SATELLITE_ID>',
6
6
  source: '<SOURCE>'
7
7
  },
8
8
  orbiter: {
9
- orbiterId: '<ORBITER_ID>'
9
+ id: '<ORBITER_ID>'
10
10
  }
11
11
  });
@@ -3,7 +3,7 @@ import {defineConfig} from '@junobuild/config';
3
3
  /** @type {import('@junobuild/config').JunoConfig} */
4
4
  export default defineConfig({
5
5
  satellite: {
6
- satelliteId: '<SATELLITE_ID>',
6
+ id: '<SATELLITE_ID>',
7
7
  source: '<SOURCE>'
8
8
  }
9
9
  });
@@ -2,7 +2,7 @@ import {defineConfig} from '@junobuild/config';
2
2
 
3
3
  export default defineConfig({
4
4
  satellite: {
5
- satelliteId: '<SATELLITE_ID>',
5
+ id: '<SATELLITE_ID>',
6
6
  source: '<SOURCE>'
7
7
  }
8
8
  });