@fnet/cli 0.3.12 → 0.3.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,20 @@
1
1
  #!/usr/bin/env node
2
- import{a as U0,b as V0}from"./index.2084z2ed.js";import{c as E,d as J5,e as y}from"./index.r19p3bpa.js";var K5=J5((a3,V5)=>{V5.exports=W5;function W5($,Q,Z){if($ instanceof RegExp)$=Y5($,Z);if(Q instanceof RegExp)Q=Y5(Q,Z);var X=H5($,Q,Z);return X&&{start:X[0],end:X[1],pre:Z.slice(0,X[0]),body:Z.slice(X[0]+$.length,X[1]),post:Z.slice(X[1]+Q.length)}}function Y5($,Q){var Z=Q.match($);return Z?Z[0]:null}W5.range=H5;function H5($,Q,Z){var X,q,Y,W,J,H=Z.indexOf($),V=Z.indexOf(Q,H+1),K=H;if(H>=0&&V>0){if($===Q)return[H,V];X=[],Y=Z.length;while(K>=0&&!J){if(K==H)X.push(K),H=Z.indexOf($,K+1);else if(X.length==1)J=[X.pop(),V];else{if(q=X.pop(),q<Y)Y=q,W=V;V=Z.indexOf(Q,K+1)}K=H<V&&H>=0?H:V}if(X.length)J=[Y,W]}return J}});var B5=J5((n3,A5)=>{var _5=K5();A5.exports=l7;var G5="\x00SLASH"+Math.random()+"\x00",z5="\x00OPEN"+Math.random()+"\x00",v$="\x00CLOSE"+Math.random()+"\x00",U5="\x00COMMA"+Math.random()+"\x00",M5="\x00PERIOD"+Math.random()+"\x00";function k$($){return parseInt($,10)==$?parseInt($,10):$.charCodeAt(0)}function m7($){return $.split("\\\\").join(G5).split("\\{").join(z5).split("\\}").join(v$).split("\\,").join(U5).split("\\.").join(M5)}function c7($){return $.split(G5).join("\\").split(z5).join("{").split(v$).join("}").split(U5).join(",").split(M5).join(".")}function O5($){if(!$)return[""];var Q=[],Z=_5("{","}",$);if(!Z)return $.split(",");var{pre:X,body:q,post:Y}=Z,W=X.split(",");W[W.length-1]+="{"+q+"}";var J=O5(Y);if(Y.length)W[W.length-1]+=J.shift(),W.push.apply(W,J);return Q.push.apply(Q,W),Q}function l7($){if(!$)return[];if($.substr(0,2)==="{}")$="\\{\\}"+$.substr(2);return c0(m7($),!0).map(c7)}function d7($){return"{"+$+"}"}function p7($){return/^-?0\d/.test($)}function i7($,Q){return $<=Q}function s7($,Q){return $>=Q}function c0($,Q){var Z=[],X=_5("{","}",$);if(!X)return[$];var q=X.pre,Y=X.post.length?c0(X.post,!1):[""];if(/\$$/.test(X.pre))for(var W=0;W<Y.length;W++){var J=q+"{"+X.body+"}"+Y[W];Z.push(J)}else{var H=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(X.body),V=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(X.body),K=H||V,G=X.body.indexOf(",")>=0;if(!K&&!G){if(X.post.match(/,.*\}/))return $=X.pre+"{"+X.body+v$+X.post,c0($);return[$]}var _;if(K)_=X.body.split(/\.\./);else if(_=O5(X.body),_.length===1){if(_=c0(_[0],!1).map(d7),_.length===1)return Y.map(function(t1){return X.pre+_[0]+t1})}var O;if(K){var U=k$(_[0]),M=k$(_[1]),z=Math.max(_[0].length,_[1].length),B=_.length==3?Math.abs(k$(_[2])):1,A=i7,R=M<U;if(R)B*=-1,A=s7;var C=_.some(p7);O=[];for(var N=U;A(N,M);N+=B){var v;if(V){if(v=String.fromCharCode(N),v==="\\")v=""}else if(v=String(N),C){var f=z-v.length;if(f>0){var D0=Array(f+1).join("0");if(N<0)v="-"+D0+v.slice(1);else v=D0+v}}O.push(v)}}else{O=[];for(var X0=0;X0<_.length;X0++)O.push.apply(O,c0(_[X0],!1))}for(var X0=0;X0<O.length;X0++)for(var W=0;W<Y.length;W++){var J=q+O[X0]+Y[W];if(!Q||K||J)Z.push(J)}}return Z}});import o2 from"yargs";import o1 from"chalk";import{promisify as e1}from"node:util";import $7 from"tree-kill";var R6=e1($7),j0=!1;async function m8($,Q){if(j0)return;if(j0=!0,!$.killed&&$.pid)try{if(await R6($.pid,"SIGTERM").catch(()=>{}),await new Promise((X)=>setTimeout(X,500)),!$.killed)await R6($.pid,"SIGKILL").catch(()=>{})}catch(X){}await new Promise((X)=>setTimeout(X,100));let Z=Q==="SIGINT"?130:Q==="SIGTERM"?143:1;process.exit(Z)}function c8($){["SIGINT","SIGTERM","SIGQUIT"].forEach((Q)=>{process.once(Q,async()=>{await m8($,Q)})}),process.on("uncaughtException",async(Q)=>{await m8($)}),process.on("unhandledRejection",async(Q)=>{await m8($)}),$.on("close",(Q)=>{if(!j0)process.exit(Q)})}function I6(){process.on("uncaughtException",($)=>{if(!j0)j0=!0,setTimeout(()=>process.exit(1),500)}),process.on("unhandledRejection",($)=>{if(!j0)j0=!0,setTimeout(()=>process.exit(1),500)})}import m0 from"node:path";import{spawn as F6}from"node:child_process";import H8 from"node:fs";import g0 from"chalk";import Q7 from"@fnet/config";function i($,{name:Q,bin:Z,preArgs:X=[],createContext:q}){if(typeof Z==="function")Z=Z();return $.command(`${Q||Z} [commands..]`,`${Z} ${X.join(" ")}`,(Y)=>{return Y.help(!1).version(!1)},async(Y)=>{try{let W=await q(Y),{projectDir:J}=W,H=(U)=>{if(!U.includes(" "))return U;if(process.platform==="win32")return`"${U.replace(/(["^])/g,"^$1")}"`;else return`"${U.replace(/(["\\$`])/g,"\\$1")}"`},V=process.argv.slice(3).map(H),K={...process.env},G=m0.join(J,"node_modules");K.NODE_PATH=G;let _=K.NODE_OPTIONS||"";K.NODE_OPTIONS=`${_} --preserve-symlinks`.trim();let O=F6(Z,[...X,...V],{cwd:J,stdio:"inherit",shell:!0,detached:!0,env:K});c8(O)}catch(W){console.error(W.message),process.exit(1)}})}function C6($,{name:Q,preArgs:Z=[],createContext:X}){return $.command(`${Q} <config> <command> [options..]`,"Run a command with a config context",(q)=>{return q.positional("config",{type:"string"}).positional("command",{type:"string"}).help(!1).version(!1)},async(q)=>{try{let Y=await X(q),{projectDir:W}=Y,J=q.config,V=(await Q7({name:J,dir:W,transferEnv:!1,optional:!0,tags:Y.tags}))?.data?.env||void 0,K=q.command,G=process.argv.slice(5),_=F6(K,[...Z,...G],{cwd:H8.existsSync(W)?W:process.cwd(),stdio:"inherit",shell:!0,detached:!0,env:{...process.env,...V}});c8(_)}catch(Y){console.error(Y.message),process.exit(1)}})}function L6($,{name:Q,projectType:Z="auto"}){return $.command(`${Q} group [options..]`,"Run a command group.",(X)=>{return X.positional("group",{type:"string"}).option("ftag",{type:"array"}).help(!1).version(!1)},async(X)=>{try{let{runCommandGroup:q}=await import("./index.0jcm9pn5.js");await q({projectType:Z,group:X.group,tags:X.ftag,args:X,argv:process.argv})}catch(q){console.error(q.message),process.exit(1)}})}function j6($,{name:Q,createContext:Z}){return $.command(`${Q} [options]`,"Install the project as a binary",(X)=>{return X.option("name",{alias:"n",describe:"Name to use for the installed binary",type:"string"}).option("force",{alias:"f",describe:"Force overwrite if binary already exists",type:"boolean",default:!1}).option("yes",{alias:"y",describe:"Automatically answer yes to all prompts",type:"boolean",default:!1})},async(X)=>{try{let q=await Z(X),{projectDir:Y}=q;console.log(g0.blue("Compiling project..."));let W=m0.join(Y,".bin");if(!H8.existsSync(W))H8.mkdirSync(W,{recursive:!0});let J=m0.basename(m0.dirname(Y)),H=q.project?.projectFileParsed?.features?.cli?.bin,V=X.name||H||J;console.log(g0.blue(`Using binary name: ${V}`));let K=m0.join(W,V),{spawn:G}=await import("child_process"),_=G("bun",["build","./dist/cli/esm/index.js","--compile",`--outfile=${K}`],{cwd:Y,stdio:"inherit",shell:!0});if(await new Promise((M,z)=>{_.on("close",(B)=>{if(B===0)M();else z(Error(`Compilation failed with code ${B}`))}),_.on("error",(B)=>{z(B)})}),process.platform!=="win32")H8.chmodSync(K,493);console.log(g0.green(`Binary compiled successfully: ${K}`)),console.log(g0.blue("Installing binary..."));let O=["install",K];if(X.name)O.push("--name",X.name);if(X.force)O.push("--force");if(X.yes)O.push("--yes");let U=G("fbin",O,{stdio:"inherit",shell:!0});await new Promise((M,z)=>{U.on("close",(B)=>{if(B===0)M();else z(Error(`Installation failed with code ${B}`))}),U.on("error",(B)=>{z(B)})})}catch(q){console.error(g0.red(`Failed to install binary: ${q.message}`)),process.exit(1)}})}import H0 from"node:path";import T0 from"node:fs";import l8 from"@fnet/yaml";import Z7 from"yaml";async function P($){if($.id)return{id:$.id,buildId:$.buildId,mode:$.mode,protocol:$.protocol||"ac:",templateDir:U0("./template/fnet/node"),coreDir:U0("./template/fnet/core"),projectDir:H0.resolve(process.cwd(),`./.output/${$.id}`),tags:$.ftag,dev:$.dev};else try{let Q=await X7({tags:$.ftag});return{buildId:$.buildId,mode:$.mode,protocol:$.protocol||"src:",templateDir:U0("./template/fnet/node"),coreDir:U0("./template/fnet/core"),projectDir:H0.resolve(Q.projectDir,"./.workspace"),projectSrcDir:H0.resolve(Q.projectDir,"./src"),project:Q,tags:$.ftag,dev:$.dev}}catch(Q){return console.warn(`Warning: Could not load project: ${Q.message}`),{projectDir:process.cwd(),tags:$.ftag}}}async function X7({tags:$}){let Q=q7(process.cwd());if(!T0.existsSync(Q))throw Error("fnet.yaml file not found in current directory.");let{raw:Z,parsed:X}=await l8({file:Q,tags:$}),q=H0.dirname(Q);X.features=X.features||{};let Y=X.features;Y.runtime=Y.runtime||{},Y.runtime.type=Y.runtime.type||"node";let W;if(typeof X.flows==="object")W=X.flows;else{let G="flow.main.yaml";if(T0.existsSync(H0.join(q,"fnet","flows.yaml")))G=H0.join("fnet","flows.yaml");let _=X.main||G,O=H0.resolve(q,_);if(!T0.existsSync(O))W={main:{steps:[]}};else{let{parsed:U}=await l8({file:O,tags:$});W=U}}let H={workflowAtom:{doc:{...X,content:W}},projectDir:q,projectFilePath:Q,projectFileContent:Z,projectFileParsed:X,runtime:Y.runtime},V=H0.resolve(q,"fnet/targets.yaml");if(T0.existsSync(V)){let{raw:G,parsed:_}=await l8({file:V,tags:$}),O=Z7.parseDocument(G);H.devops={filePath:V,fileContent:G,yamlDocument:O,doc:{..._},type:"workflow.deploy",save:async()=>{T0.writeFileSync(H.devops.filePath,O.toString())}}}let K=H0.resolve(q,"readme.md");if(T0.existsSync(K)){let G=T0.readFileSync(K,"utf8");H.readme={filePath:K,fileContent:G,doc:{content:G,"content-type":"markdown"},type:"wiki"}}return H}function q7($){return H0.resolve($,"fnet.yaml")}import Y7 from"node:path";import T6 from"node:fs";import J7 from"node:os";import W7 from"@flownet/lib-render-templates-dir";import d8 from"@fnet/shelljs";var H7={command:"create",describe:"Initialize a new fnet project",builder:($)=>{return $.option("name",{type:"string",describe:"Project name"}).option("vscode",{type:"boolean",default:!0,alias:"vs",describe:"Open in VS Code after creation"}).option("runtime",{type:"string",default:"node",choices:["node"],describe:"Runtime environment"})},handler:async($)=>{try{let Q=process.cwd(),Z=U0("./template/fnet/project"),X=Y7.resolve(Q,$.name);if(!T6.existsSync(X))T6.mkdirSync(X);await W7({dir:Z,outDir:X,context:$,copyUnmatchedAlso:!0,platform:J7.platform()});let q=await d8("fnet build",{cwd:X});if(q.code!==0)throw Error("Failed to build project.");if(V0("git")){if(q=await d8("git init --initial-branch=main",{cwd:X}),q.code!==0)throw Error("Failed to initialize git.")}if(V0("code")&&$.vscode){if(q=await d8(`cd ${X} && code .`),q.code!==0)throw Error("Failed to open vscode.")}console.log("Creating project succeeded!"),process.exit(0)}catch(Q){console.error("Initialization failed!",Q.message),process.exit(1)}}},w6=H7;import V7 from"node:os";import K7 from"@flownet/lib-render-templates-dir";import _7 from"@fnet/shelljs";var G7={command:"project",describe:"Manage fnet project",builder:($)=>{return $.option("update",{type:"boolean",default:!1,alias:"-u",describe:"Update project files"})},handler:async($)=>{try{let Q=U0("./template/fnet/project"),Z=process.cwd(),X=await P($);if($.update){if(await K7({dir:Q,outDir:Z,context:{name:X.project.projectFileParsed.name,runtime:"node"},copyUnmatchedAlso:!0,platform:V7.platform()}),(await _7("fnet build",{cwd:Z})).code!==0)throw Error("Failed to build project.");console.log("Updating project succeeded!")}process.exit(0)}catch(Q){console.error("Project failed.",Q.message),process.exit(1)}}},S6=G7;import j from"node:fs";import S from"node:path";import k1 from"yaml";import v1 from"@fnet/shelljs";import W8 from"nunjucks";import E1 from"lodash.clonedeep";import j2 from"isobject";import{randomUUID as y1}from"node:crypto";import p8 from"winston";var{combine:P6,timestamp:N6,printf:z7,colorize:U7}=p8.format,D6=z7(({level:$,message:Q,timestamp:Z,category:X,depth:q,...Y})=>{let W=" ".repeat(q||0),J=X?`[${X}]`:"",H=`${Z} ${$} ${J} ${W}${Q}`;if(Object.keys(Y).length>0)H+=`
3
- ${W} ${JSON.stringify(Y,null,2)}`;return H}),V8=p8.createLogger({level:process.env.FNET_LOG_LEVEL||"info",format:P6(N6({format:"HH:mm:ss.SSS"}),D6),transports:[new p8.transports.Console({format:P6(U7(),N6({format:"HH:mm:ss.SSS"}),D6)})]}),k6=($)=>{return{debug:(Q,Z={})=>V8.debug(Q,{category:$,...Z}),info:(Q,Z={})=>V8.info(Q,{category:$,...Z}),warn:(Q,Z={})=>V8.warn(Q,{category:$,...Z}),error:(Q,Z={})=>V8.error(Q,{category:$,...Z})}},k=k6("tree"),b=k6("bpmn"),b6=process.env.FNET_LOG_CATEGORIES?.split(",")||[],F=($)=>{if(b6.length===0)return!1;return b6.includes($)};import{Api as K8}from"@flownet/lib-atom-api-js";class v6{init({config:$,accessToken:Q}){return new Promise((Z,X)=>{if(K8.set_api_url($.data.url),Q){K8.set_req_token(Q),Z(Q);return}fetch(`${$.data.issuer}/protocol/openid-connect/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams($.data.grant.params)}).then(async(q)=>{if(!q.ok)throw Error(await q.text());return q.json()}).then((q)=>{K8.set_req_token(q.access_token),Z(q.access_token)}).catch((q)=>{K8.set_req_token(),X(q)})})}}import b0 from"lodash.merge";import _8 from"node:fs";import q0 from"node:path";import k0 from"@flownet/lib-parse-imports-js";import M7 from"lodash.merge";function D({feature:$,features:Q,packageDevDependencies:Z}){let{name:X,packages:q,options:Y,extraCheck:W,explicit:J}=$,H=`${X}_enabled`,V=Q.rollup_output||{},K=Object.keys(V),G=Y||{},_=Q[X]?.options;if(_)G=M7(G,_);let O=!Q[X]||Q[X]?.enabled===!1;K.forEach((M)=>{let z=Q.rollup_output[M];if(!z)return;if(Reflect.has(z,X)){if(O||!z[X]||z[X]?.enabled===!1){delete z[X];return}if(z[X]===!0)z[X]={enabled:!0,options:G}}else if(!O&&!J&&Q[H]!==!1)z[X]={enabled:!0};else return;z[X]=z[X]||{},z[X].options={...G,...z[X].options}});let U=K.some((M)=>Q.rollup_output[M][X]?.enabled===!0);if(W)U=W()&&U;if(Q[H]=U,U)q.forEach((M)=>Z.push({package:M[0],version:M[1]}))}function i8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;D({feature:{name:"workbox",packages:[["rollup-plugin-workbox","^8"]],options:{generate:{swDest:"dist/app/esm/sw.js",globDirectory:"dist/app/esm",globPatterns:["**/*.{html,js,css,png,jpg}"],skipWaiting:!0,clientsClaim:!0}},explicit:!0},features:X,packageDevDependencies:Z})}function s8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;D({feature:{name:"gzip",packages:[["rollup-plugin-gzip","^4"]],explicit:!0},features:X,packageDevDependencies:Z})}function r8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;D({feature:{name:"nunjucks",packages:[["@fnet/rollup-plugin-nunjucks","0.1.8"]]},features:X,packageDevDependencies:Z})}function a8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;D({feature:{name:"polyfill",packages:[["rollup-plugin-node-polyfills","^0.2"]]},features:X,packageDevDependencies:Z})}function n8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;D({feature:{name:"visualizer",packages:[["rollup-plugin-visualizer","^5"]],expilicit:!0},features:X,packageDevDependencies:Z})}function o8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;D({feature:{name:"analyzer",packages:[["rollup-plugin-analyzer","^3"]],options:{summaryOnly:!0,limit:12},explicit:!0},features:X,packageDevDependencies:Z})}function t8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;D({feature:{name:"string",packages:[["rollup-plugin-string","^3"]]},features:X,packageDevDependencies:Z})}function e8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;D({feature:{name:"image",packages:[["@rollup/plugin-image","^3"]]},features:X,packageDevDependencies:Z})}function $$($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;if(X.runtime.type==="bun")return;D({feature:{name:"json",packages:[["@rollup/plugin-json","^6"]]},features:X,packageDevDependencies:Z})}function Q$($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;D({feature:{name:"terser",packages:[["@rollup/plugin-terser","^0.4"]]},features:X,packageDevDependencies:Z})}function Z$($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;D({feature:{name:"wasm",packages:[["@rollup/plugin-wasm","^6"]]},features:X,packageDevDependencies:Z})}function X$($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;if(X.runtime.type==="bun")return;let q={};if(X.app?.enabled===!0){if(q.targets=q.targets||[],q.targets.push({src:"./src/app/index.html",dest:X.app.dir}),!Reflect.has(X.app,"copy")){if(!Reflect.has(X,"copy"))X.copy=!0}}D({feature:{name:"copy",packages:[["rollup-plugin-copy","^3"],["chokidar","^3"]],options:q},features:X,packageDevDependencies:Z})}function q$($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features,q=X.css&&X.css.enabled!==!1,Y=[];if(q)Y.push(["rollup-plugin-postcss","^4"]),Y.push(["sass","^1.66"]),(X.css?.options?.plugins||[]).forEach((J)=>{switch(J.name){case"postcss-import":Y.push(["postcss-import","^15"]);break;case"postcss-url":Y.push(["postcss-url","^10"]);break;case"postcss-preset-env":Y.push(["postcss-preset-env","^9"]);break;case"autoprefixer":Y.push(["autoprefixer","^10"]);break;case"cssnano":Y.push(["cssnano","^6"]);break}});D({feature:{name:"css",packages:Y},features:X,packageDevDependencies:Z})}function Y$({dir:$,name:Q="index"}){let Z=q0.resolve($,`./${Q}.tsx`);if(!_8.existsSync(Z))Z=q0.resolve($,`./${Q}.ts`);if(!_8.existsSync(Z))Z=q0.resolve($,`./${Q}.jsx`);if(!_8.existsSync(Z))Z=q0.resolve($,`./${Q}.js`);if(!_8.existsSync(Z))return{};let X=Z,q=q0.extname(Z);return{file:X,ext:q,ts:q===".ts"||q===".tsx",name:Q}}async function J$($){let{atom:Q,context:Z,setProgress:X}=$;X("Initializing features..."),Q.doc.features=Q.doc.features||{};let q=Q.doc.features;q.project=q.project||{},q.project.format=q.project.format||q.project_format||"esm",q.project_format=q.project.format,q.dts_enabled=q.dts===!0||typeof q.dts<"u"&&q.dts!==!1;let Y=q0.resolve(Z.project.projectDir),W=Y$({dir:q0.resolve(Y,"./app")});if(W.file){X("Parsing app entry imports...");let M=await k0({file:W.file,recursive:!0}),z=M.all.some((B)=>B.usesJSX===!0&&B.type==="local");q.app_uses_jsx=z,q.app_has_entry=!0,M=await k0({file:W.file}),z=M.all.some((B)=>B.usesJSX===!0&&B.type==="local"),q.app_entry_uses_jsx=z,q.app_entry_is_ts=W.ts,q.app_entry_ext=W.ext}let J=Y$({dir:q0.resolve(Y,"./cli")});if(J.file){X("Parsing cli entry imports...");let M=await k0({file:J.file,recursive:!0}),z=M.all.some((B)=>B.usesJSX===!0&&B.type==="local");q.cli_uses_jsx=z,q.cli_has_entry=!0,M=await k0({file:J.file}),z=M.all.some((B)=>B.usesJSX===!0&&B.type==="local"),q.cli_entry_uses_jsx=z,q.cli_entry_is_ts=J.ts,q.cli_entry_ext=J.ext}if(Q.type==="workflow.lib"){let M=Y$({dir:q0.resolve(Y,"./src")});if(M.file){X("Parsing src entry imports...");let z=await k0({file:M.file,recursive:!0}),B=z.all.some((A)=>A.usesJSX===!0&&A.type==="local");q.src_uses_jsx=B,q.src_has_entry=!0,z=await k0({file:M.file}),B=z.all.some((A)=>A.usesJSX===!0&&A.type==="local"),q.src_entry_uses_jsx=B,q.src_entry_is_ts=M.ts,q.src_entry_ext=M.ext}}let H=Reflect.has(q,"app_entry_uses_jsx")?q.app_entry_uses_jsx===!0:q.src_entry_uses_jsx===!0,V=Reflect.has(q,"cli_entry_uses_jsx")?q.cli_entry_uses_jsx===!0:q.src_entry_uses_jsx===!0;if(q.form_enabled=H||V||q.form===!0||q.form?.enabled===!0,q.multiple_enabled=q.multiple_enabled||q.multiple===!0||q.multiple?.enabled===!0,q.app===!1)q.app={enabled:!1};else if(q.app===!0)q.app={enabled:!0,extend:q.app_has_entry===!0,export:!0,react:H};else q.app={enabled:!0,extend:q.app_has_entry===!0,export:!0,react:H,...q.app||{}};if(q.app.enabled=q.app.enabled===!0&&(Q.doc.features.form_enabled===!0||q.app.extend===!0||q.app.enabled===!0),q.app.format=q.app.format||"esm",q.app.folder=q.app.folder||q.app.format||"default",q.cli===!1)q.cli={enabled:!1};else if(q.cli===!0)q.cli={enabled:!0,extend:q.cli_has_entry===!0,export:!0,react:V};else q.cli={enabled:!0,extend:q.cli_has_entry===!0,export:!0,react:V,...q.cli||{}};if(q.cli.enabled=q.cli.enabled===!0&&(Q.doc.features.form_enabled===!1||q.cli.extend===!0||q.cli.enabled===!0),q.cli.format=q.cli.format||"esm",q.cli.folder=q.cli.folder||q.cli.folder||"esm",q.cli.node_options=q.cli.node?.options||q.cli.node_options||"",q.cli.bin=q.cli.bin||Q.doc.name,q.cli.installable=q.cli.installable===!0,q.cli.enabled)Q.doc["npm::bin"]=q.cli.bin;q.json=q.cli.enabled||q.json;let K={cjs:{format:"cjs",context:q.form_enabled?"window":"global",babel:q.src_uses_jsx===!0||!1,browser:!1,replace:!0,terser:!0,enabled:q.cjs!==!1,copy:!1},esm:{format:"esm",context:q.form_enabled?"window":"global",babel:q.src_uses_jsx===!0||!1,browser:!1,replace:!0,terser:!1,enabled:q.esm!==!1,copy:!0},iife:{format:"iife",context:q.form_enabled?"window":"global",babel:!0,browser:!0,replace:!0,enabled:q.iife===!0,terser:!0,copy:!1}},G={targets:{browsers:"last 9 versions, not dead",node:"18"}},_={};if(q.webos===!0)K.webos={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,input:"./src/app/index.js",output_dir:"./dist/app/webos",copy:!1,babel_options:{targets:{chrome:"79"}}};if(q.electron===!0)K.electron={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/electron"};if(q.nextjs===!0)K.nextjs={format:"esm",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/nextjs"};if(q.ios===!0)K.ios={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/ios"};if(q.macos===!0)K.macos={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/macos"};if(q.app.enabled===!0)q.app.dir=`./dist/app/${q.app.folder}`,q.app.output={file:`./dist/app/${q.app.folder}/index.js`,dir:`./dist/app/${q.app.folder}/`,...q.app.output||{}},q.app.input={file:"./src/app/index.js",dir:"./src/app/",...q.app.input||{}},K.app={format:q.app.format,browser:!0,babel:!0,context:"window",replace:!0,input:q.app.input.file,output_dir:q.app.dir,terser:!0,output_exports:q.app.export===!1?"none":"auto",browsersync:!0};if(q.cli.enabled===!0)q.cli.dir=`./dist/cli/${q.cli.folder}`,q.cli.output={file:`./dist/cli/${q.cli.folder}/index.js`,dir:`./dist/cli/${q.cli.folder}/`,...q.cli.output||{}},q.cli.input={file:"./src/cli/index.js",dir:"./src/cli/",...q.cli.input||{}},K.cli={format:q.cli.format,context:"global",babel:q.src_uses_jsx===!0||q.cli_uses_jsx===!0||!1,browser:!1,replace:!0,enabled:!0,input:q.cli.input.file,output_dir:q.cli.dir,banner:"#!/usr/bin/env bun",terser:!0,output_exports:q.cli.export===!1?"none":"auto"};let O={server:".",startPath:`${q0.normalize(q.app.dir||".")}`,files:[q0.normalize("./dist/**/*")],cors:!0,open:!1};if(q.babel_options=b0(G,q.babel_options||q.babel?.options),q.browsersync_options=b0(O,q.browsersync_options||q.browsersync?.options||{}),q.replace_options=b0(_,q.replace_options||q.replace?.options||{}),Reflect.has(q.browsersync_options,"proxy"))delete q.browsersync_options.server;q.rollup=q.rollup||{},q.rollup_output=b0(K,q.rollup_output||q.rollup?.output||{}),q.preact_enabled=q.preact===!0||q.preact&&q.preact?.enabled!==!1;let U=Object.keys(K);for(let M of U){let z=K[M];if(!z)continue;if(q.rollup[M]===!1){delete q.rollup_output[M];continue}if(z.babel_options=z.babel_options||q.babel_options,z.browsersync_options=b0(q.browsersync_options,z.browsersync_options),z.replace_options=b0(q.replace_options,z.replace_options),q.preact_enabled)z.alias_enabled=!0,z.alias=z.alias||{},z.alias.entries=z.alias.entries||{},z.alias.entries.react="preact/compat",z.alias.entries["react-dom"]="preact/compat";if(q.form_enabled||q.babel)z.babel=!0}U=Object.keys(q.rollup_output),q.babel_enabled=U.some((M)=>q.rollup_output[M].babel===!0),q.browser_enabled=U.some((M)=>q.rollup_output[M].babel===!0),q.browsersync_enabled=q.browsersync!==!1&&U.some((M)=>q.rollup_output[M].browsersync===!0),q.browsersync_enabled=q.browsersync_enabled&&q.app.enabled,q.dependency_auto_enabled=q.dependency_auto!==!1&&q.dependency_auto?.enabled!==!1,q.npm_install_flags=q.npm_install_flags||"",q.react_version=q.react_version||q.react?.version||18,q.bpmn=q.bpmn||{},q.bpmn.enabled=q.bpmn.enabled!==!1,q.bpmn.per_flow=q.bpmn.per_flow===!0,q$($),X$($),Z$($),Q$($),$$($),t8($),e8($),o8($),n8($),a8($),r8($),i8($),s8($)}import O7 from"@fnet/npm-list-versions";async function W$({atom:$,packageDependencies:Q,packageDevDependencies:Z,setProgress:X}){X("Initializing dependencies");let q=$.doc.dependencies||[];if(q.filter((Y)=>!Y.dev).forEach((Y)=>Q.push(Y)),q.filter((Y)=>Y.dev).forEach((Y)=>Z.push(Y)),$.type==="workflow")Q.push({package:"get-value",version:"^3"}),Q.push({package:"set-value",version:"^4"});if($.doc.features.form_enabled){if($.doc.features.dependency_auto_enabled){let Y="^18.2";if(X("Fetching React versions"),Y=`^${(await O7({name:"react",groupBy:{major:!0}})).find((H)=>H[0]===$.doc.features.react_version.toString())[0]}`,Q.push({package:"react",version:Y}),Q.push({package:"react-dom",version:Y}),$.type==="workflow")Q.push({package:"@fnet/react-app",version:"^0.1"}),Q.push({package:"@fnet/react-app-state",version:"^0.1"})}}if($.doc.features.preact_enabled)Q.push({package:"preact",version:"^10"});if($.doc.features.cli.enabled===!0){if(Q.push({package:"@fnet/args",version:"^0.1"}),$.doc.features.cli.fargs&&$.doc.features.cli.fargs?.enabled!==!1)Q.push({package:"@fnet/config",version:"0.2.21"});if($.doc.features.cli.mcp&&$.doc.features.cli.mcp.enabled===!0)Q.push({package:"@modelcontextprotocol/sdk",version:"^1.10"}),Q.push({package:"express",version:"^4.18"})}if($.doc.features.render&&$.doc.features.render.enabled!==!1)Z.push({package:"@flownet/lib-render-templates-dir",version:"0.1.19"});if(Z.push({package:"@babel/core",version:"^7"}),Z.push({package:"@rollup/plugin-commonjs",version:"^28"}),Z.push({package:"@rollup/plugin-node-resolve",version:"^16"}),Z.push({package:"@rollup/plugin-replace",version:"^6"}),Z.push({package:"rollup",version:"^4"}),$.doc.features.dts_enabled)Z.push({package:"rollup-plugin-dts",version:"^6"});if(Z.push({package:"rollup-plugin-peer-deps-external",version:"^2"}),Z.push({package:"@rollup/plugin-alias",version:"^5"}),Z.push({package:"fs-extra",version:"^11"}),$.doc.features.babel_enabled)Z.push({package:"@rollup/plugin-babel",version:"^6"}),Z.push({package:"@babel/preset-env",version:"^7"}),Z.push({package:"@babel/preset-react",version:"^7"}),$.doc.features.babel?.options?.plugins?.forEach((Y)=>{switch(Y[0]){case"@babel/plugin-proposal-decorators":Z.push({package:"@babel/plugin-proposal-decorators",version:"^7"});break;case"@babel/plugin-proposal-class-properties":Z.push({package:"@babel/plugin-proposal-class-properties",version:"^7"});break;case"@babel/plugin-proposal-private-methods":Z.push({package:"@babel/plugin-proposal-private-methods",version:"^7"});break;case"@babel/plugin-proposal-private-property-in-object":Z.push({package:"@babel/plugin-proposal-private-property-in-object",version:"^7"});break;case"@babel/plugin-proposal-optional-chaining":Z.push({package:"@babel/plugin-proposal-optional-chaining",version:"^7"});break}});if(Z.push({package:"@fnet/rollup-plugin-delete",version:"0.1.10"}),$.doc.features.browsersync_enabled)Z.push({package:"@fnet/rollup-plugin-browsersync",version:"0.1.11"})}import A7 from"@fnet/npm-list-versions";async function H$({atom:$,packageDependencies:Q,packageDevDependencies:Z,setProgress:X}){X("Initializing dependencies for Bun");let q=$.doc.dependencies||[];if(q.filter((Y)=>!Y.dev).forEach((Y)=>Q.push(Y)),q.filter((Y)=>Y.dev).forEach((Y)=>Z.push(Y)),$.type==="workflow")Q.push({package:"get-value",version:"^3"}),Q.push({package:"set-value",version:"^4"});if($.doc.features.form_enabled){if($.doc.features.dependency_auto_enabled){let Y="^18.2";if(X("Fetching React versions"),Y=`^${(await A7({name:"react",groupBy:{major:!0}})).find((H)=>H[0]===$.doc.features.react_version.toString())[0]}`,Q.push({package:"react",version:Y}),Q.push({package:"react-dom",version:Y}),$.type==="workflow")Q.push({package:"@fnet/react-app",version:"^0.1"}),Q.push({package:"@fnet/react-app-state",version:"^0.1"})}}if($.doc.features.preact_enabled)Q.push({package:"preact",version:"^10"});if($.doc.features.cli.enabled===!0){if(Q.push({package:"@fnet/args",version:"^0.1"}),$.doc.features.cli.fargs&&$.doc.features.cli.fargs?.enabled!==!1)Q.push({package:"@fnet/config",version:"0.2.21"});if($.doc.features.cli.mcp&&$.doc.features.cli.mcp.enabled===!0)Q.push({package:"@modelcontextprotocol/sdk",version:"^1.10"}),Q.push({package:"express",version:"^4.18"})}if($.doc.features.render&&$.doc.features.render.enabled!==!1)Z.push({package:"@flownet/lib-render-templates-dir",version:"0.1.19"})}import E6 from"node:fs";import y6 from"node:path";import B7 from"@flownet/lib-render-templates-dir";async function V$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){if($.doc.features.app.enabled!==!0)return;await Q({message:"Creating app folder"});let q={atom:$,packageDependencies:X,ts:Date.now()},Y=Z.templateDir,W=y6.resolve(Z.projectDir,"src/app");if(!E6.existsSync(W))E6.mkdirSync(W,{recursive:!0});let J=["index.js.njk"];if($.doc.features.app.html!==!1)J.push("index.html.njk");await B7({pattern:J,dir:y6.resolve(Y,"src/app"),outDir:W,context:q})}import u6 from"nunjucks";import M0 from"node:fs";import R0 from"node:path";import F7 from"@flownet/lib-parse-imports-js";import R7 from"@fnet/npm-pick-versions";import I7 from"object-hash";import G8 from"node:fs";import x6 from"node:path";async function v0({projectDir:$,name:Q,setProgress:Z,count:X=1}){let q,W=I7(["npm-pick-versions",Q,X]),J=x6.join($,".cache"),H=x6.join(J,W+".json");if(G8.existsSync(H)){if(Z)Z(`Picking npm version of ${Q} from cache ...`);q=JSON.parse(G8.readFileSync(H,"utf8"))}else{if(Z)Z(`Picking npm version of ${Q} ...`);q=await R7({name:Q,count:X}),G8.mkdirSync(J,{recursive:!0}),G8.writeFileSync(H,JSON.stringify(q),"utf8")}return q}async function K$({atom:$,context:Q,packageDependencies:Z,packageDevDependencies:X,setProgress:q}){await q({message:"Creating package.json."}),Z.filter((z)=>z.dev===!0).forEach((z)=>{if(!X.find((A)=>A.package===z.package))X.push(z);let B=Z.findIndex((A)=>A.package===z.package);Z.splice(B,1)});let W=Z.find((z)=>z.package==="react"),J=Z.find((z)=>z.package==="react-dom");if(W&&!J)Z.push({package:"react-dom",version:W.version});else if(W&&J)J.version=W.version;if(W&&$.doc.features.react_version>=17){if(!Z.find((z)=>z.package==="@emotion/react"))Z.push({package:"@emotion/react",version:"^11"});if(!Z.find((z)=>z.package==="@emotion/styled"))Z.push({package:"@emotion/styled",version:"^11"})}let H=[];if($.doc.features.app.enabled===!0)H.push({file:R0.resolve(Q.projectDir,"src/app/index.js"),dev:$.doc.features.app.dev===!0});if($.doc.features.cli.enabled===!0)H.push({file:R0.resolve(Q.projectDir,"src/cli/index.js"),dev:$.doc.features.cli.dev===!0});for await(let z of H){let B=z.file;if(!M0.existsSync(B))throw Error(`App file not found: ${B}`);let R=(await F7({file:B,recursive:!0,verbose:!1})).all;for await(let C of R){if(C.type!=="npm")continue;if(Z.find((f)=>f.package===C.package))continue;if(X.find((f)=>f.package===C.package))continue;let N=await v0({name:C.package,projectDir:Q.projectDir,setProgress:q});(z.dev===!0?X:Z).push({package:C.package,subpath:C.subpath,version:N.minorRange,type:"npm"})}}let V={atom:$,packageDependencies:Z,packageDevDependencies:X},K=Q.templateDir,_=u6.compile(M0.readFileSync(R0.resolve(K,"package.json.njk"),"utf8"),u6.configure(K)).render(V),O=Q.projectDir,U=R0.resolve(O,"package.json");M0.writeFileSync(U,_,"utf8");let M=R0.resolve(Q.project.projectDir,"fnet");if(M0.existsSync(M)){let z=R0.resolve(Q.projectDir,"fnet");if(!M0.existsSync(z))M0.mkdirSync(z);let B=M0.readdirSync(M);for(let A of B){let R=R0.resolve(M,A);if(!M0.lstatSync(R).isFile())continue;let C=R0.resolve(z,A);M0.copyFileSync(R,C)}}}import f6 from"node:fs";import h6 from"node:path";import C7 from"@flownet/lib-render-templates-dir";async function _$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){if($.doc.features.cli.enabled!==!0)return;await Q({message:"Creating cli."});let q={atom:$,packageDependencies:X},Y=Z.templateDir,W=h6.resolve(Z.projectDir,"src/cli");if(!f6.existsSync(W))f6.mkdirSync(W,{recursive:!0});await C7({pattern:["index.js.njk"],dir:h6.resolve(Y,"src/cli"),outDir:W,context:q})}import G$ from"node:fs";import z$ from"node:path";import g6 from"nunjucks";import L7 from"@flownet/lib-parse-imports-js";async function U$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){await Q({message:"Creating rollup file."});let q={atom:$,packageDependencies:X},Y=z$.resolve(Z.projectDir,"src","default/index.js");if(!G$.existsSync(Y))throw Error(`Entry file not found: ${Y}`);let J=(await L7({file:Y,recursive:!0})).all.filter((M)=>M.type==="node").map((M)=>M.path),H=$.doc.features.rollup_output,V=Object.keys(H);for(let M=0;M<V.length;M++){let z=V[M],B=H[z];if(B.browser===!0){if(J.length>0){B.globals_enabled=!0,B.globals=B.globals||[],B.globals=B.globals.concat(J.map((A)=>{return{key:A,value:A}})),B.alias_enabled=!0,B.alias=B.alias||{},B.alias.entries=B.alias.entries||{};for(let A=0;A<J.length;A++){let R=J[A];B.alias.entries[R]=`node:${R}`,B.alias.entries[`node:${R}`]=R}B.external_enabled=!0,B.external=B.external||[],B.external=B.external.concat(J)}}}let K=Z.templateDir,_=g6.compile(G$.readFileSync(z$.resolve(K,"rollup.config.mjs.njk"),"utf8"),g6.configure(K)).render(q),O=Z.projectDir,U=z$.resolve(O,"rollup.config.mjs");G$.writeFileSync(U,_,"utf8")}import M$ from"node:fs";import m6 from"node:path";import c6 from"nunjucks";async function O$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){await Q({message:"Creating build.js file."});let q={atom:$,packageDependencies:X},Y=Z.templateDir,J=c6.compile(M$.readFileSync(m6.resolve(Y,"build.js.njk"),"utf8"),c6.configure(Y)).render(q),H=Z.projectDir,V=m6.resolve(H,"build.js");M$.writeFileSync(V,J,"utf8"),M$.chmodSync(V,"755")}import A$ from"node:fs";import B$ from"node:path";import j7 from"nunjucks";import T7 from"ajv/dist/2020.js";import w7 from"ajv/dist/standalone/index.js";import S7 from"ajv-formats";async function R$({atom:$,setProgress:Q,context:Z,njEnv:X}){if($.doc.features.cli.enabled!==!0)return;await Q({message:"Creating input args."});let q={},Y=[];if($.doc.input)q=$.doc.input;else q={type:"object",properties:{},required:[]};if($.doc.features.cli.fargs&&$.doc.features.cli.fargs?.enabled!==!1){let B=$.doc.features.cli.fargs,A={type:"string",description:"Config name to load args",hidden:!1},R={type:"array",description:"Tags to filter the config",hidden:!1};if(Reflect.has(B,"default"))A.default=B.default}let J={imports:Y,atom:$},H=Z.templateDir,K=j7.compile(A$.readFileSync(B$.resolve(H,"src/default/input.args.js.njk"),"utf8"),X).render(J),G=Z.projectDir,_=B$.resolve(G,"src/default/input.args.js");A$.writeFileSync(_,K,"utf8");let O=new T7({allErrors:!0,useDefaults:!0,formats:{},strict:!1,code:{esm:!0,lines:!0,optimize:!1,source:!0}});S7(O);let U=O.compile(q),z=w7(O,U)+`
4
- export { schema31 as schema };`;A$.writeFileSync(B$.resolve(G,"src/default/validate_input.js"),z,"utf8")}import l6 from"node:fs";import d6 from"node:path";import p6 from"nunjucks";async function I$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){await Q({message:"Creating .gitignore"});let q={atom:$,packageDependencies:X},Y=Z.templateDir,J=p6.compile(l6.readFileSync(d6.resolve(Y,".gitignore.njk"),"utf8"),p6.configure(Y)).render(q),H=Z.projectDir,V=d6.resolve(H,".gitignore");l6.writeFileSync(V,J,"utf8")}import i6 from"node:fs";import s6 from"node:path";import r6 from"nunjucks";async function F$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){await Q({message:"Creating tsconfig.json."});let q={atom:$,packageDependencies:X},Y=Z.templateDir,J=r6.compile(i6.readFileSync(s6.resolve(Y,"tsconfig.json.njk"),"utf8"),r6.configure(Y)).render(q),H=Z.projectDir,V=s6.resolve(H,"tsconfig.json");i6.writeFileSync(V,J,"utf8")}import z8 from"nunjucks";import I0 from"node:fs";import w0 from"node:path";import a6 from"@fnet/yaml";async function C$({atom:$,context:Q,setProgress:Z,Atom:X}){if(await Z({message:"Creating readme.md"}),Q.project?.readme){let W=Q.projectDir,J={content:Q.project.readme.doc.content},H=w0.resolve(Q.project.projectDir,"fnet/how-to.md");if(I0.existsSync(H)){let M=I0.readFileSync(H,"utf8");J.howto=M}let V=w0.resolve(Q.project.projectDir,"fnet/input.yaml");if(I0.existsSync(V)){let M=await a6({file:V,tags:Q.tags});J.input=M.content}let K=w0.resolve(Q.project.projectDir,"fnet/output.yaml");if(I0.existsSync(K)){let M=await a6({file:K,tags:Q.tags});J.output=M.content}let G=Q.templateDir,O=z8.compile(I0.readFileSync(w0.resolve(G,"readme.md.njk"),"utf8"),z8.configure(G)).render(J),U=w0.resolve(W,"readme.md");I0.writeFileSync(U,O,"utf8")}else if($.id){let W=await X.first({type:"wiki",parent_id:$.id});if(!W||W.doc?.["content-type"]!=="markdown")return;let{content:J,...H}=W.doc,V={content:J},K=Q.templateDir,_=z8.compile(I0.readFileSync(w0.resolve(K,"readme.md.njk"),"utf8"),z8.configure(K)).render(V),O=Q.projectDir,U=w0.resolve(O,"readme.md");I0.writeFileSync(U,_,"utf8")}}import P7 from"node:path";import n6 from"@fnet/shelljs";async function L$({setProgress:$,context:Q}){let Z=Q.projectDir;await $({message:"Prettifiying source files."});let X=P7.join("src","**","*");if(V0("bun")){let q=await n6(`prettier --write ${X} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:Z});if(q.code!==0)throw Error(q.stderr)}else{let q=await n6(`prettier --write ${X} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:Z});if(q.code!==0)throw Error(q.stderr)}}import N7 from"@fnet/shelljs";async function j$({atom:$,setProgress:Q,context:Z}){if(!$.doc.features.dts_enabled)return;let X=Z.projectDir;if(await Q({message:"Creating .d.ts"}),(await N7("tsc",{cwd:X})).code!==0)throw Error("Couldnt create .d.ts files.")}import o6 from"@fnet/shelljs";async function T$({setProgress:$,atom:Q,context:Z}){let X=Z.projectDir;if(await $({message:"Installing npm packages."}),V0("bun")){if((await o6(`bun install ${Q.doc.features.npm_install_flags}`,{cwd:X})).code!==0)throw Error("Couldnt install npm packages.")}else if((await o6(`npm install ${Q.doc.features.npm_install_flags}`,{cwd:X})).code!==0)throw Error("Couldnt install npm packages.")}import t6 from"node:fs";import D7 from"node:path";import{spawn as b7}from"node:child_process";async function e6($){let{projectDir:Q,scriptName:Z,args:X=[],env:q=process.env,shell:Y=!0,detached:W=!0,onSpawn:J}=$;if(!Q||!Z)throw Error("projectDir and scriptName are required");let H=D7.resolve(Q,"package.json");if(!t6.existsSync(H))throw Error(`package.json not found at ${H}`);let V=JSON.parse(t6.readFileSync(H,"utf8")),K=V.scripts?.[Z];if(!K){let O=Object.keys(V.scripts||{}).join(", ");throw Error(`Script '${Z}' not found. Available: ${O}`)}let G=X.length>0?`${K} ${X.join(" ")}`:K,_=b7(G,[],{cwd:Q,shell:Y,detached:W,env:{...q}});if(J)J(_);return new Promise((O,U)=>{_.on("error",(M)=>{U(Error(`Failed to start '${Z}': ${M.message}`))}),_.on("close",(M)=>{O({subprocess:_,exitCode:M})})})}import k7 from"node:path";async function w$({setProgress:$,context:Q}){let Z=Q.projectDir;await $({message:"Building main project."});let X=Q.dev?"build:dev":"build",q={...process.env},Y=k7.join(Z,"node_modules");q.NODE_PATH=Y;let W=q.NODE_OPTIONS||"";q.NODE_OPTIONS=`${W} --preserve-symlinks`.trim(),await e6({projectDir:Z,scriptName:X,shell:!0,detached:!0,env:q})}var $5=async($)=>{let{atom:Q,packageDependencies:Z,context:X,deploymentProjectTarget:q,setProgress:Y,deploymentProject:W,yamlTarget:J}=$;if(q.enabled!==!0)return;let H=q.type;try{if(H==="lib")await(await import("./index.p0zb7e1b.js")).default({...$});else if(H==="red")await(await import("./index.490y87nc.js")).default({...$});else if(H==="npm")await(await import("./index.gh75wt1m.js")).default({...$});else if(H==="gcs")await(await import("./index.hzsfswvp.js")).default({...$});else if(H==="gitlab")await(await import("./index.jgpc3grc.js")).default({...$});else if(H==="fnet-package")await(await import("./index.r82rtnmz.js")).default({...$});else if(H==="fnet-form")await(await import("./index.3exge2js.js")).default({...$});else if(H==="fnet-node")await(await import("./index.4jkat7r4.js")).default({...$});else if(H==="fnet-flow")await(await import("./index.s662t98v.js")).default({...$});else if(H==="nextjs")await(await import("./index.7vw06nrn.js")).default({atom:Q,target:q,onProgress:Y,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:J}),W.isDirty=!0;else if(H==="webos")await(await import("./index.zm4kesg6.js")).default({atom:Q,target:q,onProgress:Y,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:J}),W.isDirty=!0;else if(H==="electron")await(await import("./index.9567fa9x.js")).default({atom:Q,target:q,onProgress:Y,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:J}),W.isDirty=!0;else if(H==="docker")await(await import("./index.w74dpnpn.js")).default({atom:Q,target:q,onProgress:Y,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:J}),W.isDirty=!0;else if(H==="ios")await(await import("./index.7crx8ky1.js")).default({atom:Q,target:q,onProgress:Y,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:J}),W.isDirty=!0;else if(H==="macos")await(await import("./index.xeaw5xa9.js")).default({atom:Q,target:q,onProgress:Y,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:J}),W.isDirty=!0;else if(H==="rust")await(await import("./index.3kfx538h.js")).default({atom:Q,target:q,onProgress:Y,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:J}),W.isDirty=!0;else if(H==="pypi")await(await import("./index.33f1ggpr.js")).default({atom:Q,target:q,onProgress:Y,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:J}),W.isDirty=!0;else{console.warn(`No deployer found for type: ${H}`);return}}catch(V){throw console.error(`Error during deployment for type "${H}":`,V),V}};import{Atom as z0}from"@flownet/lib-atom-api-js";import T2 from"@flownet/lib-parse-node-url";import Z5 from"bpmn-moddle";import Q5 from"dagre";import N$ from"lodash.clonedeep";var S$={name:"ATOM",uri:"http://atom.org/bpmn",prefix:"atom",types:[{name:"AtomExtension",extends:["bpmn:BaseElement"],properties:[{name:"atom",type:"atom:Atom",isMany:!1}]},{name:"Atom",properties:[{name:"type",type:"String",isAttr:!0}]}]};function X5($){let{nodes:Q,nodeIndex:Z,root:X}=$,q=[],Y=new Set,W=(J)=>{if(Y.has(J.indexKey))return;if(Y.add(J.indexKey),J.hasReturn&&J.type!=="return"){let H=`${J.indexKey}/_inline_end`;if(Z[H])return;let V={name:"",type:"return",virtual:!0,parent:J.parent,childs:[],definition:{return:J.definition.return},index:J.parent.childs.length,indexKey:H,pathKey:`${J.pathKey}._inline_end`,codeKey:`${J.codeKey}_inline_end`,context:{next:null},hasReturn:!0,_inlineParent:J};if(q.push(V),F("bpmn"))b.info(` \uD83C\uDFC1 INLINE RETURN → EndEvent: ${V.indexKey}`,{parentNode:J.indexKey,nodeType:J.type,hasReturn:!0})}J.childs.forEach((H)=>W(H))};Q.forEach((J)=>W(J)),q.forEach((J)=>{J.parent.childs.push(J),Z[J.indexKey]=J,Q.push(J)}),Q.forEach((J)=>{let H=[],V=[],K=(U)=>{let M=q.find((z)=>z._inlineParent===U);if(M)H.push({from:U,to:M,type:"bpmn:SequenceFlow"});else if(U.context.next){if(H.push({from:U,to:U.context.next,type:"bpmn:SequenceFlow"}),U===J)V.push({to:U.context.next,type:"bpmn:SequenceFlow",next:!0})}U.childs.forEach((z)=>{if(U===J){if(J.type==="switch"){if(!(z.indexKey&&z.indexKey.endsWith("/_inline_end")))V.push({to:z,type:"bpmn:SequenceFlow"})}}K(z)})};K(J);let G=H.filter((U)=>U.to.parent.indexKey===J.parent.indexKey).map((U)=>{return{...U,from:J.indexKey,to:U.to.indexKey}}),_=H.filter((U)=>U.to.parent.indexKey!==J.parent.indexKey&&!U.to.indexKey.startsWith(J.indexKey+"/")).map((U)=>{return{...U,from:J.indexKey,to:U.to.indexKey}}),O=V.map((U)=>{return{...U,to:U.to.indexKey}});if(J.bpmn=J.bpmn||{},J.bpmn.edges=P$(G,"to"),J.bpmn.outside=P$(_,"to"),J.bpmn.starts=P$(O,"to"),J.bpmn.type=E7(J),J.bpmn.width=120,J.bpmn.height=80,J.type==="return")J.bpmn.width=36,J.bpmn.height=36;if(J.bpmn.type==="bpmn:CallActivity")J.bpmn.fill="#E1F5FE",J.bpmn.stroke="#0277BD"})}function E7($){let Q;if($.type==="call"){if($.context?.lib?.type==="subworkflow"||$.context?.lib?.type==="workflow"){if(Q="bpmn:CallActivity",F("bpmn"))b.info(` \uD83D\uDCE6 CALL → CallActivity (subworkflow): ${$.indexKey}`,{nodeType:$.type,bpmnType:Q,calledElement:$.context?.lib?.name||"unknown",isChip:!0})}else if(Q="bpmn:ServiceTask",F("bpmn"))b.info(` \uD83D\uDCDE CALL → ServiceTask (external): ${$.indexKey}`,{nodeType:$.type,bpmnType:Q,target:$.context?.lib?.name||"unknown",isChip:!1})}else if($.type==="form"){if(Q="bpmn:UserTask",F("bpmn"))b.info(` \uD83D\uDCDD FORM → UserTask: ${$.indexKey}`,{nodeType:$.type,bpmnType:Q})}else if($.type==="return"){if(Q="bpmn:EndEvent",F("bpmn"))b.info(` \uD83C\uDFC1 RETURN → EndEvent: ${$.indexKey}`,{nodeType:$.type,bpmnType:Q})}else if($.type==="raise"){let Z=!1;if($.name==="try"&&$.parent?.type==="tryexcept")Z=!0;else{let X=$.parent;while(X){if(X.name==="try"&&X.parent?.type==="tryexcept"){Z=!0;break}X=X.parent}}if(Z){if(Q="bpmn:IntermediateThrowEvent",F("bpmn"))b.info(` ⚡ RAISE → IntermediateThrowEvent (inside try): ${$.indexKey}`,{nodeType:$.type,bpmnType:Q,nodeName:$.name,parent:$.parent?.indexKey})}else if(Q="bpmn:EndEvent",F("bpmn"))b.info(` ⚠️ RAISE → EndEvent (error): ${$.indexKey}`,{nodeType:$.type,bpmnType:Q})}else if($.type==="pipeline"){if(Q="bpmn:ServiceTask",F("bpmn"))b.info(` \uD83D\uDD27 PIPELINE → ServiceTask (external binary): ${$.indexKey}`,{nodeType:$.type,bpmnType:Q,binary:$.context?.binaryName||"unknown"})}else if($.type==="http"){if(Q="bpmn:ServiceTask",F("bpmn"))b.info(` \uD83C\uDF10 HTTP → ServiceTask (external API): ${$.indexKey}`,{nodeType:$.type,bpmnType:Q,method:$.context?.http?.method||"GET",url:$.context?.http?.url||"unknown"})}else if($.type==="assign"||$.type==="new"){if(Q="bpmn:ScriptTask",F("bpmn"))b.info(` \uD83D\uDCDC ${$.type.toUpperCase()} → ScriptTask: ${$.indexKey}`,{nodeType:$.type,bpmnType:Q})}else if(Q="bpmn:Task",F("bpmn"))b.info(` \uD83D\uDCCB ${$.type.toUpperCase()} → Task: ${$.indexKey}`,{nodeType:$.type,bpmnType:Q});return Q}function P$($,Q){return $.filter((Z,X,q)=>{return q.map((Y)=>Y[Q]).indexOf(Z[Q])===X})}function D$($){let{nodes:Q,nodeIndex:Z,root:X}=$,q=$.targetNodes||X.childs;q.forEach((Y)=>{let W=Y.type==="workflow"||Y.type==="subworkflow",J=!W&&Y.childs.filter((G)=>!G.virtual).length>0,H=(Y.name==="try"||Y.name==="except")&&Y.parent?.type==="tryexcept",V=Y.type==="schedule",K=Y.type==="retry";if(J||H||V||K){if(Y.bpmn.type="bpmn:SubProcess",Y.type==="for"){if(Y.bpmn.loopCharacteristics=!0,F("bpmn"))b.info(" \uD83D\uDD01 FOR → SubProcess + Loop Marker",{subprocess:Y.indexKey,loopType:"StandardLoopCharacteristics"})}if(Y.name==="try"&&Y.type==="raise"&&Y.parent?.type==="tryexcept"){let G=s({location:0,...$,parent:Y,bpmnType:"bpmn:IntermediateThrowEvent",type:"raise",attrs:{},definitions:[{type:"bpmn:ErrorEventDefinition"}]});if(F("bpmn"))b.info(" ⚡ Created virtual IntermediateThrowEvent for single-step try block",{tryNode:Y.indexKey,virtualNode:G.indexKey,bpmnType:G.bpmn.type})}}if(W||J){let G=Y.childs.filter((A)=>A.module!==!0&&!A.indexKey.endsWith("/_inline_end"))[0];Y.childs.filter((A)=>A.module===!0).forEach((A)=>{let R=s({...$,parent:Y,bpmnType:"bpmn:IntermediateCatchEvent",type:"inter",definitions:[{type:"bpmn:SignalEventDefinition"}]});R.bpmn.edges=[{from:R.indexKey,to:A.indexKey,type:"bpmn:SequenceFlow"}]});let O=Y.childs.find((A)=>A.name==="try"&&Y.type==="tryexcept"),U=Y.childs.filter((A)=>A.name==="except"&&Y.type==="tryexcept");if(O&&U.length)U.forEach((A)=>{let R=s({location:Y.childs.indexOf(A),...$,parent:Y,bpmnType:"bpmn:BoundaryEvent",type:"boundary",attrs:{attachedToRef:O},definitions:[{type:"bpmn:ErrorEventDefinition"}]});if(R.bpmn.edges=[{from:R.indexKey,to:A.indexKey,type:"bpmn:SequenceFlow"}],F("bpmn"))b.info(" ⚡ TRY-EXCEPT → BoundaryEvent",{subprocess:Y.indexKey,tryNode:O.indexKey,exceptNode:A.indexKey,boundaryEvent:R.indexKey})});let M=Y.childs.find((A)=>A.type==="raise");if(M){let A=s({...$,parent:Y,bpmnType:"bpmn:EndEvent",type:"end",name:"ERROR",definitions:[{type:"bpmn:ErrorEventDefinition"}]});M.bpmn.edges=[{from:M.indexKey,to:A.indexKey,type:"bpmn:SequenceFlow"}]}if(Y.type==="schedule"){let A=Y.childs[0];if(A){let R=s({...$,parent:Y,bpmnType:"bpmn:StartEvent",type:"timer-start",definitions:[{type:"bpmn:TimerEventDefinition",timerType:"timeCycle",expression:Y.context?.cron||"* * * * *"}]});if(R.bpmn.edges=[{from:R.indexKey,to:A.indexKey,type:"bpmn:SequenceFlow"}],F("bpmn"))b.info(" ⏰ SCHEDULE → SubProcess + TimerStartEvent",{subprocess:Y.indexKey,timerEvent:R.indexKey,child:A.indexKey,cron:Y.context?.cron})}}if(G)if(Y.type==="schedule"){if(F("bpmn"))b.info(" ⏰ SCHEDULE → Skipping normal StartEvent (using TimerStartEvent)",{subprocess:Y.indexKey,timerEvent:"already created"})}else if(Y.type==="retry"){let A=s({...$,parent:Y,bpmnType:"bpmn:StartEvent",type:"start"});if(A.bpmn.edges.push({from:A.indexKey,to:G.indexKey,type:"bpmn:SequenceFlow"}),F("bpmn"))b.info(" \uD83D\uDD01 RETRY → SubProcess with loop characteristics",{subprocess:Y.indexKey,attempts:Y.context?.attempts,backoff:Y.context?.backoff})}else if(Y.type==="parallel"){let A=s({...$,parent:Y,bpmnType:"bpmn:StartEvent",type:"start"}),R=s({...$,parent:Y,bpmnType:"bpmn:ParallelGateway",type:"fork"}),C=s({...$,parent:Y,bpmnType:"bpmn:ParallelGateway",type:"join"}),N=s({...$,parent:Y,bpmnType:"bpmn:EndEvent",type:"end"});A.bpmn.edges=[{from:A.indexKey,to:R.indexKey,type:"bpmn:SequenceFlow"}];let v=Y.childs.filter((f)=>!f.virtual&&!f.module&&!f.indexKey.endsWith("/_inline_end"));if(R.bpmn.edges=v.map((f)=>{return{from:R.indexKey,to:f.indexKey,type:"bpmn:SequenceFlow"}}),v.forEach((f)=>{f.bpmn.edges=[{from:f.indexKey,to:C.indexKey,type:"bpmn:SequenceFlow"}]}),C.bpmn.edges=[{from:C.indexKey,to:N.indexKey,type:"bpmn:SequenceFlow"}],F("bpmn"))b.info(" \uD83D\uDD00 PARALLEL → Fork/Join Gateways",{subprocess:Y.indexKey,childCount:v.length,pattern:"Start → Fork → [Tasks] → Join → End"})}else if(Y.bpmn.starts.length>1){let A=s({...$,parent:Y,bpmnType:"bpmn:StartEvent",type:"start"}),R=s({...$,parent:Y,bpmnType:"bpmn:ExclusiveGateway",type:"switch"});A.bpmn.edges=[{from:A.indexKey,to:R.indexKey,type:"bpmn:SequenceFlow"}],R.bpmn.edges=Y.bpmn.starts.map((N)=>{return{...N,from:R.indexKey}});let C=R.bpmn.edges.find((N)=>N.next===!0);if(C){let N=s({...$,parent:Y,bpmnType:"bpmn:EndEvent",type:"end",name:C.to});C.to=N.indexKey}}else{let A=s({...$,parent:Y,bpmnType:"bpmn:StartEvent",type:"start"});A.bpmn.edges.push({from:A.indexKey,to:G.indexKey,type:"bpmn:SequenceFlow"})}else if(F("bpmn"))b.info(" \uD83D\uDEAB START EVENT skipped (no valid firstNode)",{subprocess:Y.indexKey,reason:"Only modules or inline end events in subprocess"});Y.childs.filter((A)=>A.virtual!==!0&&A.bpmn.outside.length&&A.bpmn.type!=="bpmn:EndEvent").forEach((A)=>{A.bpmn.outside.forEach((R)=>{let C=q.indexOf(Y),N=s({...$,parent:Y,bpmnType:"bpmn:EndEvent",type:"end",name:R.to,location:C+1});A.bpmn.edges.push({from:A.indexKey,to:N.indexKey,type:"bpmn:SequenceFlow"})})}),Y.childs.filter((A)=>A.virtual!==!0&&A.bpmn.edges.length>1).forEach((A)=>{let R=q.indexOf(A),C=s({...$,parent:Y,bpmnType:"bpmn:ExclusiveGateway",type:"switch",location:R+1});C.bpmn.edges=A.bpmn.edges.map((N)=>{return{...N,from:C.indexKey}}),A.bpmn.edges=[{from:A.indexKey,to:C.indexKey,type:"bpmn:SequenceFlow"}],A.bpmn.outside=[]})}D$({...$,targetNodes:Y.childs})})}function s($){let{parent:Q,nodes:Z,nodeIndex:X,bpmnType:q,type:Y,name:W,outside:J,location:H,definitions:V,attrs:K}=$,G=Q.childs.filter((O)=>O.type===`v${Y}`).length;if(F("bpmn"))b.info(` \uD83D\uDD37 VIRTUAL ${Y.toUpperCase()} → ${q}`,{parent:Q.indexKey,type:`v${Y}`,bpmnType:q,name:W||`${Y}${G}`});let _={indexKey:`${Q.indexKey}/_${Y}${G}`,pathKey:`${Q.pathKey}._${Y}${G}`,type:`v${Y}`,name:W,bpmn:{edges:[],outside:[],type:q,width:36,height:36,fill:"#c8e6c9",stroke:"#205022",definitions:V,attrs:K},virtual:!0,childs:[]};return Q.childs.splice(H||0,0,_),Z.push(_),X[_.indexKey]=_,_}function b$($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:Y,nodeIndex:W,diagrams:J,nodes:H}=$;y7($),x7($),u7($),f7($)}function y7($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:Y,nodeIndex:W,nodes:J}=$,H=Z.get("flowElements");if(Z.$nodes=Z.$nodes||[],F("bpmn"))b.info(`\uD83C\uDFA8 Creating BPMN elements for: ${Q.indexKey}`,{childCount:Q.childs.length});Q.childs.forEach((V)=>{let K=q.create(V.bpmn.type,{id:`node.${V.pathKey}`,name:V.definition?.title||V.name});if(Y[K.id]=K,K.$isNode=!0,K.$node=V,V.$flow=K,Z.$nodes.push(K),H.push(K),V.bpmn.type==="bpmn:CallActivity"&&V.context?.lib){if(K.calledElement=V.context.lib.name,F("bpmn"))b.info(` ✨ Created: ${V.bpmn.type} (chip!)`,{id:K.id,name:K.name,calledElement:K.calledElement,nodeType:V.type,virtual:V.virtual||!1})}else if(F("bpmn"))b.info(` ✨ Created: ${V.bpmn.type}`,{id:K.id,name:K.name,nodeType:V.type,virtual:V.virtual||!1});if(V.bpmn.attrs)Object.keys(V.bpmn.attrs).forEach((_)=>{if(_==="attachedToRef")K.set(_,V.bpmn.attrs[_].$flow)});if(V.bpmn.definitions){let G=V.bpmn.definitions.map((_)=>{let O=q.create(_.type);return Object.keys(_.attrs||{}).forEach((M)=>{O.set(M,_.attrs[M])}),O});K.eventDefinitions=G}if(V.bpmn.loopCharacteristics&&V.bpmn.type==="bpmn:SubProcess"){if(K.loopCharacteristics=q.create("bpmn:StandardLoopCharacteristics"),F("bpmn"))b.info(` \uD83D\uDD01 Added loop marker to: ${K.id}`,{nodeType:V.type,loopType:"StandardLoopCharacteristics"})}})}function x7($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:Y,nodeIndex:W}=$,J=Z.get("flowElements");Z.$edges=Z.$edges||[],Q.childs.forEach((H)=>{H.bpmn.edges.forEach((K)=>{let G=H,_=W[K.to],O=`edge.${G.pathKey}_${_.pathKey}`;if(Y[O])return;let U=Y[`node.${G.pathKey}`],M=Y[`node.${_.pathKey}`],z=q.create(K.type,{id:O,sourceRef:U,targetRef:M});Y[z.id]=z,z.$is_edge=!0,U.get("outgoing").push(z),M.get("incoming").push(z),Z.$edges.push({from:U,to:M,flow:z}),J.push(z)})})}function u7($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:Y,nodeIndex:W}=$,J=120,H=80,V=160,K=160,G=new Q5.graphlib.Graph;G.setDefaultEdgeLabel(()=>({})),G.setGraph({rankdir:"TB",nodesep:120,ranksep:80,xranker:"longest-path"}),Z.$nodes.forEach((_)=>{G.setNode(_.id,{width:_.$node?.bpmn.width||120,height:_.$node?.bpmn.height||80,label:_.id})}),Z.$edges.forEach((_)=>{G.setEdge(_.from.id,_.to.id)}),Q5.layout(G),Z.$nodes.forEach((_)=>{let O=G.node(_.id),U=O.width,M=O.height,z=q.create("bpmndi:BPMNShape",{id:`shape.${_.id}`,bpmnElement:_,bounds:q.create("dc:Bounds",{x:160+O.x-O.width/2,y:160+O.y-O.height/2,width:U,height:M}),label:q.create("bpmndi:BPMNLabel")});if(_.$node.bpmn.fill)z.set("bioc:fill",_.$node.bpmn.fill);if(_.$node.bpmn.stroke)z.set("bioc:stroke",_.$node.bpmn.stroke);X.get("planeElement").push(z)}),Z.$edges.forEach((_)=>{let O=G.edge(_.from.id,_.to.id),U=q.create("bpmndi:BPMNEdge",{id:`edge.${_.from.id}_${_.to.id}`,bpmnElement:_.flow,label:q.create("bpmndi:BPMNLabel")});O.points.forEach((z)=>{let B=q.create("dc:Point",{x:160+z.x,y:160+z.y});U.get("waypoint").push(B)}),X.get("planeElement").push(U)})}function f7($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:Y,nodeIndex:W,diagrams:J}=$;Q.childs.filter((V)=>V.bpmn.type==="bpmn:SubProcess").forEach((V)=>{let K=Y[`node.${V.pathKey}`],G=q.create("bpmndi:BPMNDiagram",{id:`diagram_${V.pathKey}`});Y[G.id]=G,J.push(G);let _=q.create("bpmndi:BPMNPlane",{id:`plane_${V.pathKey}`});Y[_.id]=_,G.plane=_,_.bpmnElement=K,b$({...$,targetNode:V,targetFlowElementsContainer:K,targetPlaneElement:_})})}async function h7($){let Q=$.root,Z=Q.context.index,X=Object.keys(Z).map((V)=>Z[V]);X5({nodes:X,nodeIndex:Z,root:Q}),D$({nodes:X,nodeIndex:Z,root:Q});let q=void 0,Y=new Z5({atom:S$}),W={},J=Y.create("bpmn:Definitions",{id:"definitions_0"});W[J.id]=J;for await(let V of Q.childs){let K=J.get("rootElements"),G=J.get("diagrams"),_=Y.create("bpmn:Process",{id:`process_${V.pathKey}`,name:V.name,documentation:[Y.create("bpmn:Documentation",{text:`Workflow - ${V.name}`})]});W[_.id]=_,_.isExecutable=!0,K.push(_);let O=Y.create("bpmndi:BPMNDiagram",{id:`diagram_${V.pathKey}`});W[O.id]=O,G.push(O);let U=Y.create("bpmndi:BPMNPlane",{id:`plane_${V.pathKey}`});W[U.id]=U,O.plane=U,U.bpmnElement=_,b$({targetNode:V,targetFlowElementsContainer:_,targetPlaneElement:U,moddle:Y,elementIndex:W,nodeIndex:Z,nodes:X,diagrams:G})}let H=await Y.toXML(J,{format:!0});return{diagramXML:q||H.xml}}async function g7($){let{root:Q,flowName:Z}=$,X=N$(Q),q=X.childs.find((C)=>C.name===Z);if(!q)throw Error(`Flow "${Z}" not found`);let Y={...X,childs:[q]},W=Y.context.index,J=Object.keys(W).map((C)=>W[C]);X5({nodes:J,nodeIndex:W,root:Y}),D$({nodes:J,nodeIndex:W,root:Y});let H=new Z5({atom:S$}),V={},K=H.create("bpmn:Definitions",{id:`definitions_${Z}`});V[K.id]=K;let G=K.get("rootElements"),_=K.get("diagrams"),O=H.create("bpmn:Process",{id:`process_${q.pathKey}`,name:q.name,documentation:[H.create("bpmn:Documentation",{text:`Workflow - ${q.name}`})]});V[O.id]=O,O.isExecutable=!0,G.push(O);let U=H.create("bpmndi:BPMNDiagram",{id:`diagram_${q.pathKey}`});V[U.id]=U,_.push(U);let M=H.create("bpmndi:BPMNPlane",{id:`plane_${q.pathKey}`});return V[M.id]=M,U.plane=M,M.bpmnElement=O,b$({targetNode:q,targetFlowElementsContainer:O,targetPlaneElement:M,moddle:H,elementIndex:V,nodeIndex:W,nodes:J,diagrams:_}),{diagramXML:(await H.toXML(K,{format:!0})).xml,flowName:q.name}}async function U8($={}){return await h7(N$($))}async function q5($={}){let Q=N$($),{root:Z}=Q,X=[];for(let q of Z.childs){let Y=await g7({root:Z,flowName:q.name});X.push(Y)}return X}import w2 from"@fnet/config";import S2 from"@flownet/lib-parse-imports-js";import x1 from"@fnet/expression";import P2 from"@fnet/yaml";import N2 from"chalk";var w5=E(B5(),1);var l0=($)=>{if(typeof $!=="string")throw TypeError("invalid pattern");if($.length>65536)throw TypeError("pattern is too long")};var r7={"[: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]},d0=($)=>$.replace(/[[\]\\-]/g,"\\$&"),a7=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),R5=($)=>$.join(""),I5=($,Q)=>{let Z=Q;if($.charAt(Z)!=="[")throw Error("not in a brace expression");let X=[],q=[],Y=Z+1,W=!1,J=!1,H=!1,V=!1,K=Z,G="";$:while(Y<$.length){let M=$.charAt(Y);if((M==="!"||M==="^")&&Y===Z+1){V=!0,Y++;continue}if(M==="]"&&W&&!H){K=Y+1;break}if(W=!0,M==="\\"){if(!H){H=!0,Y++;continue}}if(M==="["&&!H){for(let[z,[B,A,R]]of Object.entries(r7))if($.startsWith(z,Y)){if(G)return["$.",!1,$.length-Z,!0];if(Y+=z.length,R)q.push(B);else X.push(B);J=J||A;continue $}}if(H=!1,G){if(M>G)X.push(d0(G)+"-"+d0(M));else if(M===G)X.push(d0(M));G="",Y++;continue}if($.startsWith("-]",Y+1)){X.push(d0(M+"-")),Y+=2;continue}if($.startsWith("-",Y+1)){G=M,Y+=2;continue}X.push(d0(M)),Y++}if(K<Y)return["",!1,0,!1];if(!X.length&&!q.length)return["$.",!1,$.length-Z,!0];if(q.length===0&&X.length===1&&/^\\?.$/.test(X[0])&&!V){let M=X[0].length===2?X[0].slice(-1):X[0];return[a7(M),!1,K-Z,!1]}let _="["+(V?"^":"")+R5(X)+"]",O="["+(V?"":"^")+R5(q)+"]";return[X.length&&q.length?"("+_+"|"+O+")":X.length?_:O,J,K-Z,!0]};var Y0=($,{windowsPathsNoEscape:Q=!1}={})=>{return Q?$.replace(/\[([^\/\\])\]/g,"$1"):$.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var n7=new Set(["!","?","+","*","@"]),F5=($)=>n7.has($),o7="(?!(?:^|/)\\.\\.?(?:$|/))",M8="(?!\\.)",t7=new Set(["[","."]),e7=new Set(["..","."]),$9=new Set("().*{}+?[]^$\\!"),Q9=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),E$="[^/]",C5=E$+"*?",L5=E$+"+?";class l{type;#Q;#$;#Z=!1;#X=[];#Y;#F;#I;#V=!1;#G;#H;#_=!1;constructor($,Q,Z={}){if(this.type=$,$)this.#$=!0;if(this.#Y=Q,this.#Q=this.#Y?this.#Y.#Q:this,this.#G=this.#Q===this?Z:this.#Q.#G,this.#I=this.#Q===this?[]:this.#Q.#I,$==="!"&&!this.#Q.#V)this.#I.push(this);this.#F=this.#Y?this.#Y.#X.length:0}get hasMagic(){if(this.#$!==void 0)return this.#$;for(let $ of this.#X){if(typeof $==="string")continue;if($.type||$.hasMagic)return this.#$=!0}return this.#$}toString(){if(this.#H!==void 0)return this.#H;if(!this.type)return this.#H=this.#X.map(($)=>String($)).join("");else return this.#H=this.type+"("+this.#X.map(($)=>String($)).join("|")+")"}#q(){if(this!==this.#Q)throw Error("should only call on root");if(this.#V)return this;this.toString(),this.#V=!0;let $;while($=this.#I.pop()){if($.type!=="!")continue;let Q=$,Z=Q.#Y;while(Z){for(let X=Q.#F+1;!Z.type&&X<Z.#X.length;X++)for(let q of $.#X){if(typeof q==="string")throw Error("string part in extglob AST??");q.copyIn(Z.#X[X])}Q=Z,Z=Q.#Y}}return this}push(...$){for(let Q of $){if(Q==="")continue;if(typeof Q!=="string"&&!(Q instanceof l&&Q.#Y===this))throw Error("invalid part: "+Q);this.#X.push(Q)}}toJSON(){let $=this.type===null?this.#X.slice().map((Q)=>typeof Q==="string"?Q:Q.toJSON()):[this.type,...this.#X.map((Q)=>Q.toJSON())];if(this.isStart()&&!this.type)$.unshift([]);if(this.isEnd()&&(this===this.#Q||this.#Q.#V&&this.#Y?.type==="!"))$.push({});return $}isStart(){if(this.#Q===this)return!0;if(!this.#Y?.isStart())return!1;if(this.#F===0)return!0;let $=this.#Y;for(let Q=0;Q<this.#F;Q++){let Z=$.#X[Q];if(!(Z instanceof l&&Z.type==="!"))return!1}return!0}isEnd(){if(this.#Q===this)return!0;if(this.#Y?.type==="!")return!0;if(!this.#Y?.isEnd())return!1;if(!this.type)return this.#Y?.isEnd();let $=this.#Y?this.#Y.#X.length:0;return this.#F===$-1}copyIn($){if(typeof $==="string")this.push($);else this.push($.clone(this))}clone($){let Q=new l(this.type,$);for(let Z of this.#X)Q.copyIn(Z);return Q}static#O($,Q,Z,X){let q=!1,Y=!1,W=-1,J=!1;if(Q.type===null){let _=Z,O="";while(_<$.length){let U=$.charAt(_++);if(q||U==="\\"){q=!q,O+=U;continue}if(Y){if(_===W+1){if(U==="^"||U==="!")J=!0}else if(U==="]"&&!(_===W+2&&J))Y=!1;O+=U;continue}else if(U==="["){Y=!0,W=_,J=!1,O+=U;continue}if(!X.noext&&F5(U)&&$.charAt(_)==="("){Q.push(O),O="";let M=new l(U,Q);_=l.#O($,M,_,X),Q.push(M);continue}O+=U}return Q.push(O),_}let H=Z+1,V=new l(null,Q),K=[],G="";while(H<$.length){let _=$.charAt(H++);if(q||_==="\\"){q=!q,G+=_;continue}if(Y){if(H===W+1){if(_==="^"||_==="!")J=!0}else if(_==="]"&&!(H===W+2&&J))Y=!1;G+=_;continue}else if(_==="["){Y=!0,W=H,J=!1,G+=_;continue}if(F5(_)&&$.charAt(H)==="("){V.push(G),G="";let O=new l(_,V);V.push(O),H=l.#O($,O,H,X);continue}if(_==="|"){V.push(G),G="",K.push(V),V=new l(null,Q);continue}if(_===")"){if(G===""&&Q.#X.length===0)Q.#_=!0;return V.push(G),G="",Q.push(...K,V),H}G+=_}return Q.type=null,Q.#$=void 0,Q.#X=[$.substring(Z-1)],H}static fromGlob($,Q={}){let Z=new l(null,void 0,Q);return l.#O($,Z,0,Q),Z}toMMPattern(){if(this!==this.#Q)return this.#Q.toMMPattern();let $=this.toString(),[Q,Z,X,q]=this.toRegExpSource();if(!(X||this.#$||this.#G.nocase&&!this.#G.nocaseMagicOnly&&$.toUpperCase()!==$.toLowerCase()))return Z;let W=(this.#G.nocase?"i":"")+(q?"u":"");return Object.assign(new RegExp(`^${Q}$`,W),{_src:Q,_glob:$})}get options(){return this.#G}toRegExpSource($){let Q=$??!!this.#G.dot;if(this.#Q===this)this.#q();if(!this.type){let J=this.isStart()&&this.isEnd(),H=this.#X.map((_)=>{let[O,U,M,z]=typeof _==="string"?l.#U(_,this.#$,J):_.toRegExpSource($);return this.#$=this.#$||M,this.#Z=this.#Z||z,O}).join(""),V="";if(this.isStart()){if(typeof this.#X[0]==="string"){if(!(this.#X.length===1&&e7.has(this.#X[0]))){let O=t7,U=Q&&O.has(H.charAt(0))||H.startsWith("\\.")&&O.has(H.charAt(2))||H.startsWith("\\.\\.")&&O.has(H.charAt(4)),M=!Q&&!$&&O.has(H.charAt(0));V=U?o7:M?M8:""}}}let K="";if(this.isEnd()&&this.#Q.#V&&this.#Y?.type==="!")K="(?:$|\\/)";return[V+H+K,Y0(H),this.#$=!!this.#$,this.#Z]}let Z=this.type==="*"||this.type==="+",X=this.type==="!"?"(?:(?!(?:":"(?:",q=this.#M(Q);if(this.isStart()&&this.isEnd()&&!q&&this.type!=="!"){let J=this.toString();return this.#X=[J],this.type=null,this.#$=void 0,[J,Y0(this.toString()),!1,!1]}let Y=!Z||$||Q||!M8?"":this.#M(!0);if(Y===q)Y="";if(Y)q=`(?:${q})(?:${Y})*?`;let W="";if(this.type==="!"&&this.#_)W=(this.isStart()&&!Q?M8:"")+L5;else{let J=this.type==="!"?"))"+(this.isStart()&&!Q&&!$?M8:"")+C5+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&Y?")":this.type==="*"&&Y?")?":`)${this.type}`;W=X+q+J}return[W,Y0(q),this.#$=!!this.#$,this.#Z]}#M($){return this.#X.map((Q)=>{if(typeof Q==="string")throw Error("string type in extglob ast??");let[Z,X,q,Y]=Q.toRegExpSource($);return this.#Z=this.#Z||Y,Z}).filter((Q)=>!(this.isStart()&&this.isEnd())||!!Q).join("|")}static#U($,Q,Z=!1){let X=!1,q="",Y=!1;for(let W=0;W<$.length;W++){let J=$.charAt(W);if(X){X=!1,q+=($9.has(J)?"\\":"")+J;continue}if(J==="\\"){if(W===$.length-1)q+="\\\\";else X=!0;continue}if(J==="["){let[H,V,K,G]=I5($,W);if(K){q+=H,Y=Y||V,W+=K-1,Q=Q||G;continue}}if(J==="*"){if(Z&&$==="*")q+=L5;else q+=C5;Q=!0;continue}if(J==="?"){q+=E$,Q=!0;continue}q+=Q9(J)}return[q,Y0($),!!Q,Y]}}var E0=($,{windowsPathsNoEscape:Q=!1}={})=>{return Q?$.replace(/[?*()[\]]/g,"[$&]"):$.replace(/[?*()[\]\\]/g,"\\$&")};var a=($,Q,Z={})=>{if(l0(Q),!Z.nocomment&&Q.charAt(0)==="#")return!1;return new $0(Q,Z).match($)},Z9=/^\*+([^+@!?\*\[\(]*)$/,X9=($)=>(Q)=>!Q.startsWith(".")&&Q.endsWith($),q9=($)=>(Q)=>Q.endsWith($),Y9=($)=>{return $=$.toLowerCase(),(Q)=>!Q.startsWith(".")&&Q.toLowerCase().endsWith($)},J9=($)=>{return $=$.toLowerCase(),(Q)=>Q.toLowerCase().endsWith($)},W9=/^\*+\.\*+$/,H9=($)=>!$.startsWith(".")&&$.includes("."),V9=($)=>$!=="."&&$!==".."&&$.includes("."),K9=/^\.\*+$/,_9=($)=>$!=="."&&$!==".."&&$.startsWith("."),G9=/^\*+$/,z9=($)=>$.length!==0&&!$.startsWith("."),U9=($)=>$.length!==0&&$!=="."&&$!=="..",M9=/^\?+([^+@!?\*\[\(]*)?$/,O9=([$,Q=""])=>{let Z=S5([$]);if(!Q)return Z;return Q=Q.toLowerCase(),(X)=>Z(X)&&X.toLowerCase().endsWith(Q)},A9=([$,Q=""])=>{let Z=P5([$]);if(!Q)return Z;return Q=Q.toLowerCase(),(X)=>Z(X)&&X.toLowerCase().endsWith(Q)},B9=([$,Q=""])=>{let Z=P5([$]);return!Q?Z:(X)=>Z(X)&&X.endsWith(Q)},R9=([$,Q=""])=>{let Z=S5([$]);return!Q?Z:(X)=>Z(X)&&X.endsWith(Q)},S5=([$])=>{let Q=$.length;return(Z)=>Z.length===Q&&!Z.startsWith(".")},P5=([$])=>{let Q=$.length;return(Z)=>Z.length===Q&&Z!=="."&&Z!==".."},N5=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",j5={win32:{sep:"\\"},posix:{sep:"/"}},I9=N5==="win32"?j5.win32.sep:j5.posix.sep;a.sep=I9;var d=Symbol("globstar **");a.GLOBSTAR=d;var F9="[^/]",C9=F9+"*?",L9="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",j9="(?:(?!(?:\\/|^)\\.).)*?",T9=($,Q={})=>(Z)=>a(Z,$,Q);a.filter=T9;var e=($,Q={})=>Object.assign({},$,Q),w9=($)=>{if(!$||typeof $!=="object"||!Object.keys($).length)return a;let Q=a;return Object.assign((X,q,Y={})=>Q(X,q,e($,Y)),{Minimatch:class extends Q.Minimatch{constructor(q,Y={}){super(q,e($,Y))}static defaults(q){return Q.defaults(e($,q)).Minimatch}},AST:class extends Q.AST{constructor(q,Y,W={}){super(q,Y,e($,W))}static fromGlob(q,Y={}){return Q.AST.fromGlob(q,e($,Y))}},unescape:(X,q={})=>Q.unescape(X,e($,q)),escape:(X,q={})=>Q.escape(X,e($,q)),filter:(X,q={})=>Q.filter(X,e($,q)),defaults:(X)=>Q.defaults(e($,X)),makeRe:(X,q={})=>Q.makeRe(X,e($,q)),braceExpand:(X,q={})=>Q.braceExpand(X,e($,q)),match:(X,q,Y={})=>Q.match(X,q,e($,Y)),sep:Q.sep,GLOBSTAR:d})};a.defaults=w9;var D5=($,Q={})=>{if(l0($),Q.nobrace||!/\{(?:(?!\{).)*\}/.test($))return[$];return w5.default($)};a.braceExpand=D5;var S9=($,Q={})=>new $0($,Q).makeRe();a.makeRe=S9;var P9=($,Q,Z={})=>{let X=new $0(Q,Z);if($=$.filter((q)=>X.match(q)),X.options.nonull&&!$.length)$.push(Q);return $};a.match=P9;var T5=/[?*]|[+@!]\(.*?\)|\[|\]/,N9=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class $0{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor($,Q={}){if(l0($),Q=Q||{},this.options=Q,this.pattern=$,this.platform=Q.platform||N5,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!Q.windowsPathsNoEscape||Q.allowWindowsEscape===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!Q.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!Q.nonegate,this.comment=!1,this.empty=!1,this.partial=!!Q.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=Q.windowsNoMagicRoot!==void 0?Q.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 $ of this.set)for(let Q of $)if(typeof Q!=="string")return!0;return!1}debug(...$){}make(){let $=this.pattern,Q=this.options;if(!Q.nocomment&&$.charAt(0)==="#"){this.comment=!0;return}if(!$){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],Q.debug)this.debug=(...q)=>console.error(...q);this.debug(this.pattern,this.globSet);let Z=this.globSet.map((q)=>this.slashSplit(q));this.globParts=this.preprocess(Z),this.debug(this.pattern,this.globParts);let X=this.globParts.map((q,Y,W)=>{if(this.isWindows&&this.windowsNoMagicRoot){let J=q[0]===""&&q[1]===""&&(q[2]==="?"||!T5.test(q[2]))&&!T5.test(q[3]),H=/^[a-z]:/i.test(q[0]);if(J)return[...q.slice(0,4),...q.slice(4).map((V)=>this.parse(V))];else if(H)return[q[0],...q.slice(1).map((V)=>this.parse(V))]}return q.map((J)=>this.parse(J))});if(this.debug(this.pattern,X),this.set=X.filter((q)=>q.indexOf(!1)===-1),this.isWindows)for(let q=0;q<this.set.length;q++){let Y=this.set[q];if(Y[0]===""&&Y[1]===""&&this.globParts[q][2]==="?"&&typeof Y[3]==="string"&&/^[a-z]:$/i.test(Y[3]))Y[2]="?"}this.debug(this.pattern,this.set)}preprocess($){if(this.options.noglobstar){for(let Z=0;Z<$.length;Z++)for(let X=0;X<$[Z].length;X++)if($[Z][X]==="**")$[Z][X]="*"}let{optimizationLevel:Q=1}=this.options;if(Q>=2)$=this.firstPhasePreProcess($),$=this.secondPhasePreProcess($);else if(Q>=1)$=this.levelOneOptimize($);else $=this.adjascentGlobstarOptimize($);return $}adjascentGlobstarOptimize($){return $.map((Q)=>{let Z=-1;while((Z=Q.indexOf("**",Z+1))!==-1){let X=Z;while(Q[X+1]==="**")X++;if(X!==Z)Q.splice(Z,X-Z)}return Q})}levelOneOptimize($){return $.map((Q)=>{return Q=Q.reduce((Z,X)=>{let q=Z[Z.length-1];if(X==="**"&&q==="**")return Z;if(X===".."){if(q&&q!==".."&&q!=="."&&q!=="**")return Z.pop(),Z}return Z.push(X),Z},[]),Q.length===0?[""]:Q})}levelTwoFileOptimize($){if(!Array.isArray($))$=this.slashSplit($);let Q=!1;do{if(Q=!1,!this.preserveMultipleSlashes){for(let X=1;X<$.length-1;X++){let q=$[X];if(X===1&&q===""&&$[0]==="")continue;if(q==="."||q==="")Q=!0,$.splice(X,1),X--}if($[0]==="."&&$.length===2&&($[1]==="."||$[1]===""))Q=!0,$.pop()}let Z=0;while((Z=$.indexOf("..",Z+1))!==-1){let X=$[Z-1];if(X&&X!=="."&&X!==".."&&X!=="**")Q=!0,$.splice(Z-1,2),Z-=2}}while(Q);return $.length===0?[""]:$}firstPhasePreProcess($){let Q=!1;do{Q=!1;for(let Z of $){let X=-1;while((X=Z.indexOf("**",X+1))!==-1){let Y=X;while(Z[Y+1]==="**")Y++;if(Y>X)Z.splice(X+1,Y-X);let W=Z[X+1],J=Z[X+2],H=Z[X+3];if(W!=="..")continue;if(!J||J==="."||J===".."||!H||H==="."||H==="..")continue;Q=!0,Z.splice(X,1);let V=Z.slice(0);V[X]="**",$.push(V),X--}if(!this.preserveMultipleSlashes){for(let Y=1;Y<Z.length-1;Y++){let W=Z[Y];if(Y===1&&W===""&&Z[0]==="")continue;if(W==="."||W==="")Q=!0,Z.splice(Y,1),Y--}if(Z[0]==="."&&Z.length===2&&(Z[1]==="."||Z[1]===""))Q=!0,Z.pop()}let q=0;while((q=Z.indexOf("..",q+1))!==-1){let Y=Z[q-1];if(Y&&Y!=="."&&Y!==".."&&Y!=="**"){Q=!0;let J=q===1&&Z[q+1]==="**"?["."]:[];if(Z.splice(q-1,2,...J),Z.length===0)Z.push("");q-=2}}}}while(Q);return $}secondPhasePreProcess($){for(let Q=0;Q<$.length-1;Q++)for(let Z=Q+1;Z<$.length;Z++){let X=this.partsMatch($[Q],$[Z],!this.preserveMultipleSlashes);if(X){$[Q]=[],$[Z]=X;break}}return $.filter((Q)=>Q.length)}partsMatch($,Q,Z=!1){let X=0,q=0,Y=[],W="";while(X<$.length&&q<Q.length)if($[X]===Q[q])Y.push(W==="b"?Q[q]:$[X]),X++,q++;else if(Z&&$[X]==="**"&&Q[q]===$[X+1])Y.push($[X]),X++;else if(Z&&Q[q]==="**"&&$[X]===Q[q+1])Y.push(Q[q]),q++;else if($[X]==="*"&&Q[q]&&(this.options.dot||!Q[q].startsWith("."))&&Q[q]!=="**"){if(W==="b")return!1;W="a",Y.push($[X]),X++,q++}else if(Q[q]==="*"&&$[X]&&(this.options.dot||!$[X].startsWith("."))&&$[X]!=="**"){if(W==="a")return!1;W="b",Y.push(Q[q]),X++,q++}else return!1;return $.length===Q.length&&Y}parseNegate(){if(this.nonegate)return;let $=this.pattern,Q=!1,Z=0;for(let X=0;X<$.length&&$.charAt(X)==="!";X++)Q=!Q,Z++;if(Z)this.pattern=$.slice(Z);this.negate=Q}matchOne($,Q,Z=!1){let X=this.options;if(this.isWindows){let U=typeof $[0]==="string"&&/^[a-z]:$/i.test($[0]),M=!U&&$[0]===""&&$[1]===""&&$[2]==="?"&&/^[a-z]:$/i.test($[3]),z=typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0]),B=!z&&Q[0]===""&&Q[1]===""&&Q[2]==="?"&&typeof Q[3]==="string"&&/^[a-z]:$/i.test(Q[3]),A=M?3:U?0:void 0,R=B?3:z?0:void 0;if(typeof A==="number"&&typeof R==="number"){let[C,N]=[$[A],Q[R]];if(C.toLowerCase()===N.toLowerCase()){if(Q[R]=C,R>A)Q=Q.slice(R);else if(A>R)$=$.slice(A)}}}let{optimizationLevel:q=1}=this.options;if(q>=2)$=this.levelTwoFileOptimize($);this.debug("matchOne",this,{file:$,pattern:Q}),this.debug("matchOne",$.length,Q.length);for(var Y=0,W=0,J=$.length,H=Q.length;Y<J&&W<H;Y++,W++){this.debug("matchOne loop");var V=Q[W],K=$[Y];if(this.debug(Q,V,K),V===!1)return!1;if(V===d){this.debug("GLOBSTAR",[Q,V,K]);var G=Y,_=W+1;if(_===H){this.debug("** at the end");for(;Y<J;Y++)if($[Y]==="."||$[Y]===".."||!X.dot&&$[Y].charAt(0)===".")return!1;return!0}while(G<J){var O=$[G];if(this.debug(`
5
- globstar while`,$,G,Q,_,O),this.matchOne($.slice(G),Q.slice(_),Z))return this.debug("globstar found match!",G,J,O),!0;else{if(O==="."||O===".."||!X.dot&&O.charAt(0)==="."){this.debug("dot detected!",$,G,Q,_);break}this.debug("globstar swallow a segment, and continue"),G++}}if(Z){if(this.debug(`
6
- >>> no match, partial?`,$,G,Q,_),G===J)return!0}return!1}let U;if(typeof V==="string")U=K===V,this.debug("string match",V,K,U);else U=V.test(K),this.debug("pattern match",V,K,U);if(!U)return!1}if(Y===J&&W===H)return!0;else if(Y===J)return Z;else if(W===H)return Y===J-1&&$[Y]==="";else throw Error("wtf?")}braceExpand(){return D5(this.pattern,this.options)}parse($){l0($);let Q=this.options;if($==="**")return d;if($==="")return"";let Z,X=null;if(Z=$.match(G9))X=Q.dot?U9:z9;else if(Z=$.match(Z9))X=(Q.nocase?Q.dot?J9:Y9:Q.dot?q9:X9)(Z[1]);else if(Z=$.match(M9))X=(Q.nocase?Q.dot?A9:O9:Q.dot?B9:R9)(Z);else if(Z=$.match(W9))X=Q.dot?V9:H9;else if(Z=$.match(K9))X=_9;let q=l.fromGlob($,this.options).toMMPattern();if(X&&typeof q==="object")Reflect.defineProperty(q,"test",{value:X});return q}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let $=this.set;if(!$.length)return this.regexp=!1,this.regexp;let Q=this.options,Z=Q.noglobstar?C9:Q.dot?L9:j9,X=new Set(Q.nocase?["i"]:[]),q=$.map((J)=>{let H=J.map((V)=>{if(V instanceof RegExp)for(let K of V.flags.split(""))X.add(K);return typeof V==="string"?N9(V):V===d?d:V._src});return H.forEach((V,K)=>{let G=H[K+1],_=H[K-1];if(V!==d||_===d)return;if(_===void 0)if(G!==void 0&&G!==d)H[K+1]="(?:\\/|"+Z+"\\/)?"+G;else H[K]=Z;else if(G===void 0)H[K-1]=_+"(?:\\/|"+Z+")?";else if(G!==d)H[K-1]=_+"(?:\\/|\\/"+Z+"\\/)"+G,H[K+1]=d}),H.filter((V)=>V!==d).join("/")}).join("|"),[Y,W]=$.length>1?["(?:",")"]:["",""];if(q="^"+Y+q+W+"$",this.negate)q="^(?!"+q+").+$";try{this.regexp=new RegExp(q,[...X].join(""))}catch(J){this.regexp=!1}return this.regexp}slashSplit($){if(this.preserveMultipleSlashes)return $.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test($))return["",...$.split(/\/+/)];else return $.split(/\/+/)}match($,Q=this.partial){if(this.debug("match",$,this.pattern),this.comment)return!1;if(this.empty)return $==="";if($==="/"&&Q)return!0;let Z=this.options;if(this.isWindows)$=$.split("\\").join("/");let X=this.slashSplit($);this.debug(this.pattern,"split",X);let q=this.set;this.debug(this.pattern,"set",q);let Y=X[X.length-1];if(!Y)for(let W=X.length-2;!Y&&W>=0;W--)Y=X[W];for(let W=0;W<q.length;W++){let J=q[W],H=X;if(Z.matchBase&&J.length===1)H=[Y];if(this.matchOne(H,J,Q)){if(Z.flipNegate)return!0;return!this.negate}}if(Z.flipNegate)return!1;return this.negate}static defaults($){return a.defaults($).Minimatch}}a.AST=l;a.Minimatch=$0;a.escape=E0;a.unescape=Y0;import{fileURLToPath as WQ}from"node:url";var y0=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,k5=new Set,y$=typeof process==="object"&&!!process?process:{},v5=($,Q,Z,X)=>{typeof y$.emitWarning==="function"?y$.emitWarning($,Q,Z,X):console.error(`[${Z}] ${Q}: ${$}`)},O8=globalThis.AbortController,b5=globalThis.AbortSignal;if(typeof O8>"u"){b5=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(X,q){this._onabort.push(q)}},O8=class{constructor(){Q()}signal=new b5;abort(X){if(this.signal.aborted)return;this.signal.reason=X,this.signal.aborted=!0;for(let q of this.signal._onabort)q(X);this.signal.onabort?.(X)}};let $=y$.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",Q=()=>{if(!$)return;$=!1,v5("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",Q)}}var D9=($)=>!k5.has($),GX=Symbol("type"),F0=($)=>$&&$===Math.floor($)&&$>0&&isFinite($),E5=($)=>!F0($)?null:$<=Math.pow(2,8)?Uint8Array:$<=Math.pow(2,16)?Uint16Array:$<=Math.pow(2,32)?Uint32Array:$<=Number.MAX_SAFE_INTEGER?p0:null;class p0 extends Array{constructor($){super($);this.fill(0)}}class x0{heap;length;static#Q=!1;static create($){let Q=E5($);if(!Q)return[];x0.#Q=!0;let Z=new x0($,Q);return x0.#Q=!1,Z}constructor($,Q){if(!x0.#Q)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new Q($),this.length=0}push($){this.heap[this.length++]=$}pop(){return this.heap[--this.length]}}class i0{#Q;#$;#Z;#X;#Y;#F;#I;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#V;#G;#H;#_;#q;#O;#M;#U;#A;#j;#R;#L;#W;#C;#K;#T;#B;#D;static unsafeExposeInternals($){return{starts:$.#W,ttls:$.#C,sizes:$.#L,keyMap:$.#H,keyList:$.#_,valList:$.#q,next:$.#O,prev:$.#M,get head(){return $.#U},get tail(){return $.#A},free:$.#j,isBackgroundFetch:(Q)=>$.#z(Q),backgroundFetch:(Q,Z,X,q)=>$.#y(Q,Z,X,q),moveToTail:(Q)=>$.#f(Q),indexes:(Q)=>$.#P(Q),rindexes:(Q)=>$.#N(Q),isStale:(Q)=>$.#S(Q)}}get max(){return this.#Q}get maxSize(){return this.#$}get calculatedSize(){return this.#G}get size(){return this.#V}get fetchMethod(){return this.#F}get memoMethod(){return this.#I}get dispose(){return this.#Z}get onInsert(){return this.#X}get disposeAfter(){return this.#Y}constructor($){let{max:Q=0,ttl:Z,ttlResolution:X=1,ttlAutopurge:q,updateAgeOnGet:Y,updateAgeOnHas:W,allowStale:J,dispose:H,onInsert:V,disposeAfter:K,noDisposeOnSet:G,noUpdateTTL:_,maxSize:O=0,maxEntrySize:U=0,sizeCalculation:M,fetchMethod:z,memoMethod:B,noDeleteOnFetchRejection:A,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:C,allowStaleOnFetchAbort:N,ignoreFetchAbort:v}=$;if(Q!==0&&!F0(Q))throw TypeError("max option must be a nonnegative integer");let f=Q?E5(Q):Array;if(!f)throw Error("invalid max value: "+Q);if(this.#Q=Q,this.#$=O,this.maxEntrySize=U||this.#$,this.sizeCalculation=M,this.sizeCalculation){if(!this.#$&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw TypeError("sizeCalculation set to non-function")}if(B!==void 0&&typeof B!=="function")throw TypeError("memoMethod must be a function if defined");if(this.#I=B,z!==void 0&&typeof z!=="function")throw TypeError("fetchMethod must be a function if specified");if(this.#F=z,this.#T=!!z,this.#H=new Map,this.#_=Array(Q).fill(void 0),this.#q=Array(Q).fill(void 0),this.#O=new f(Q),this.#M=new f(Q),this.#U=0,this.#A=0,this.#j=x0.create(Q),this.#V=0,this.#G=0,typeof H==="function")this.#Z=H;if(typeof V==="function")this.#X=V;if(typeof K==="function")this.#Y=K,this.#R=[];else this.#Y=void 0,this.#R=void 0;if(this.#K=!!this.#Z,this.#D=!!this.#X,this.#B=!!this.#Y,this.noDisposeOnSet=!!G,this.noUpdateTTL=!!_,this.noDeleteOnFetchRejection=!!A,this.allowStaleOnFetchRejection=!!C,this.allowStaleOnFetchAbort=!!N,this.ignoreFetchAbort=!!v,this.maxEntrySize!==0){if(this.#$!==0){if(!F0(this.#$))throw TypeError("maxSize must be a positive integer if specified")}if(!F0(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#g()}if(this.allowStale=!!J,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!Y,this.updateAgeOnHas=!!W,this.ttlResolution=F0(X)||X===0?X:1,this.ttlAutopurge=!!q,this.ttl=Z||0,this.ttl){if(!F0(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#J()}if(this.#Q===0&&this.ttl===0&&this.#$===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Q&&!this.#$){if(D9("LRU_CACHE_UNBOUNDED"))k5.add("LRU_CACHE_UNBOUNDED"),v5("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",i0)}}getRemainingTTL($){return this.#H.has($)?1/0:0}#J(){let $=new p0(this.#Q),Q=new p0(this.#Q);this.#C=$,this.#W=Q,this.#b=(q,Y,W=y0.now())=>{if(Q[q]=Y!==0?W:0,$[q]=Y,Y!==0&&this.ttlAutopurge){let J=setTimeout(()=>{if(this.#S(q))this.#k(this.#_[q],"expire")},Y+1);if(J.unref)J.unref()}},this.#v=(q)=>{Q[q]=$[q]!==0?y0.now():0},this.#w=(q,Y)=>{if($[Y]){let W=$[Y],J=Q[Y];if(!W||!J)return;q.ttl=W,q.start=J,q.now=Z||X();let H=q.now-J;q.remainingTTL=W-H}};let Z=0,X=()=>{let q=y0.now();if(this.ttlResolution>0){Z=q;let Y=setTimeout(()=>Z=0,this.ttlResolution);if(Y.unref)Y.unref()}return q};this.getRemainingTTL=(q)=>{let Y=this.#H.get(q);if(Y===void 0)return 0;let W=$[Y],J=Q[Y];if(!W||!J)return 1/0;let H=(Z||X())-J;return W-H},this.#S=(q)=>{let Y=Q[q],W=$[q];return!!W&&!!Y&&(Z||X())-Y>W}}#v=()=>{};#w=()=>{};#b=()=>{};#S=()=>!1;#g(){let $=new p0(this.#Q);this.#G=0,this.#L=$,this.#E=(Q)=>{this.#G-=$[Q],$[Q]=0},this.#m=(Q,Z,X,q)=>{if(this.#z(Z))return 0;if(!F0(X))if(q){if(typeof q!=="function")throw TypeError("sizeCalculation must be a function");if(X=q(Z,Q),!F0(X))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return X},this.#x=(Q,Z,X)=>{if($[Q]=Z,this.#$){let q=this.#$-$[Q];while(this.#G>q)this.#u(!0)}if(this.#G+=$[Q],X)X.entrySize=Z,X.totalCalculatedSize=this.#G}}#E=($)=>{};#x=($,Q,Z)=>{};#m=($,Q,Z,X)=>{if(Z||X)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#P({allowStale:$=this.allowStale}={}){if(this.#V)for(let Q=this.#A;;){if(!this.#c(Q))break;if($||!this.#S(Q))yield Q;if(Q===this.#U)break;else Q=this.#M[Q]}}*#N({allowStale:$=this.allowStale}={}){if(this.#V)for(let Q=this.#U;;){if(!this.#c(Q))break;if($||!this.#S(Q))yield Q;if(Q===this.#A)break;else Q=this.#O[Q]}}#c($){return $!==void 0&&this.#H.get(this.#_[$])===$}*entries(){for(let $ of this.#P())if(this.#q[$]!==void 0&&this.#_[$]!==void 0&&!this.#z(this.#q[$]))yield[this.#_[$],this.#q[$]]}*rentries(){for(let $ of this.#N())if(this.#q[$]!==void 0&&this.#_[$]!==void 0&&!this.#z(this.#q[$]))yield[this.#_[$],this.#q[$]]}*keys(){for(let $ of this.#P()){let Q=this.#_[$];if(Q!==void 0&&!this.#z(this.#q[$]))yield Q}}*rkeys(){for(let $ of this.#N()){let Q=this.#_[$];if(Q!==void 0&&!this.#z(this.#q[$]))yield Q}}*values(){for(let $ of this.#P())if(this.#q[$]!==void 0&&!this.#z(this.#q[$]))yield this.#q[$]}*rvalues(){for(let $ of this.#N())if(this.#q[$]!==void 0&&!this.#z(this.#q[$]))yield this.#q[$]}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find($,Q={}){for(let Z of this.#P()){let X=this.#q[Z],q=this.#z(X)?X.__staleWhileFetching:X;if(q===void 0)continue;if($(q,this.#_[Z],this))return this.get(this.#_[Z],Q)}}forEach($,Q=this){for(let Z of this.#P()){let X=this.#q[Z],q=this.#z(X)?X.__staleWhileFetching:X;if(q===void 0)continue;$.call(Q,q,this.#_[Z],this)}}rforEach($,Q=this){for(let Z of this.#N()){let X=this.#q[Z],q=this.#z(X)?X.__staleWhileFetching:X;if(q===void 0)continue;$.call(Q,q,this.#_[Z],this)}}purgeStale(){let $=!1;for(let Q of this.#N({allowStale:!0}))if(this.#S(Q))this.#k(this.#_[Q],"expire"),$=!0;return $}info($){let Q=this.#H.get($);if(Q===void 0)return;let Z=this.#q[Q],X=this.#z(Z)?Z.__staleWhileFetching:Z;if(X===void 0)return;let q={value:X};if(this.#C&&this.#W){let Y=this.#C[Q],W=this.#W[Q];if(Y&&W){let J=Y-(y0.now()-W);q.ttl=J,q.start=Date.now()}}if(this.#L)q.size=this.#L[Q];return q}dump(){let $=[];for(let Q of this.#P({allowStale:!0})){let Z=this.#_[Q],X=this.#q[Q],q=this.#z(X)?X.__staleWhileFetching:X;if(q===void 0||Z===void 0)continue;let Y={value:q};if(this.#C&&this.#W){Y.ttl=this.#C[Q];let W=y0.now()-this.#W[Q];Y.start=Math.floor(Date.now()-W)}if(this.#L)Y.size=this.#L[Q];$.unshift([Z,Y])}return $}load($){this.clear();for(let[Q,Z]of $){if(Z.start){let X=Date.now()-Z.start;Z.start=y0.now()-X}this.set(Q,Z.value,Z)}}set($,Q,Z={}){if(Q===void 0)return this.delete($),this;let{ttl:X=this.ttl,start:q,noDisposeOnSet:Y=this.noDisposeOnSet,sizeCalculation:W=this.sizeCalculation,status:J}=Z,{noUpdateTTL:H=this.noUpdateTTL}=Z,V=this.#m($,Q,Z.size||0,W);if(this.maxEntrySize&&V>this.maxEntrySize){if(J)J.set="miss",J.maxEntrySizeExceeded=!0;return this.#k($,"set"),this}let K=this.#V===0?void 0:this.#H.get($);if(K===void 0){if(K=this.#V===0?this.#A:this.#j.length!==0?this.#j.pop():this.#V===this.#Q?this.#u(!1):this.#V,this.#_[K]=$,this.#q[K]=Q,this.#H.set($,K),this.#O[this.#A]=K,this.#M[K]=this.#A,this.#A=K,this.#V++,this.#x(K,V,J),J)J.set="add";if(H=!1,this.#D)this.#X?.(Q,$,"add")}else{this.#f(K);let G=this.#q[K];if(Q!==G){if(this.#T&&this.#z(G)){G.__abortController.abort(Error("replaced"));let{__staleWhileFetching:_}=G;if(_!==void 0&&!Y){if(this.#K)this.#Z?.(_,$,"set");if(this.#B)this.#R?.push([_,$,"set"])}}else if(!Y){if(this.#K)this.#Z?.(G,$,"set");if(this.#B)this.#R?.push([G,$,"set"])}if(this.#E(K),this.#x(K,V,J),this.#q[K]=Q,J){J.set="replace";let _=G&&this.#z(G)?G.__staleWhileFetching:G;if(_!==void 0)J.oldValue=_}}else if(J)J.set="update";if(this.#D)this.onInsert?.(Q,$,Q===G?"update":"replace")}if(X!==0&&!this.#C)this.#J();if(this.#C){if(!H)this.#b(K,X,q);if(J)this.#w(J,K)}if(!Y&&this.#B&&this.#R){let G=this.#R,_;while(_=G?.shift())this.#Y?.(..._)}return this}pop(){try{while(this.#V){let $=this.#q[this.#U];if(this.#u(!0),this.#z($)){if($.__staleWhileFetching)return $.__staleWhileFetching}else if($!==void 0)return $}}finally{if(this.#B&&this.#R){let $=this.#R,Q;while(Q=$?.shift())this.#Y?.(...Q)}}}#u($){let Q=this.#U,Z=this.#_[Q],X=this.#q[Q];if(this.#T&&this.#z(X))X.__abortController.abort(Error("evicted"));else if(this.#K||this.#B){if(this.#K)this.#Z?.(X,Z,"evict");if(this.#B)this.#R?.push([X,Z,"evict"])}if(this.#E(Q),$)this.#_[Q]=void 0,this.#q[Q]=void 0,this.#j.push(Q);if(this.#V===1)this.#U=this.#A=0,this.#j.length=0;else this.#U=this.#O[Q];return this.#H.delete(Z),this.#V--,Q}has($,Q={}){let{updateAgeOnHas:Z=this.updateAgeOnHas,status:X}=Q,q=this.#H.get($);if(q!==void 0){let Y=this.#q[q];if(this.#z(Y)&&Y.__staleWhileFetching===void 0)return!1;if(!this.#S(q)){if(Z)this.#v(q);if(X)X.has="hit",this.#w(X,q);return!0}else if(X)X.has="stale",this.#w(X,q)}else if(X)X.has="miss";return!1}peek($,Q={}){let{allowStale:Z=this.allowStale}=Q,X=this.#H.get($);if(X===void 0||!Z&&this.#S(X))return;let q=this.#q[X];return this.#z(q)?q.__staleWhileFetching:q}#y($,Q,Z,X){let q=Q===void 0?void 0:this.#q[Q];if(this.#z(q))return q;let Y=new O8,{signal:W}=Z;W?.addEventListener("abort",()=>Y.abort(W.reason),{signal:Y.signal});let J={signal:Y.signal,options:Z,context:X},H=(U,M=!1)=>{let{aborted:z}=Y.signal,B=Z.ignoreFetchAbort&&U!==void 0;if(Z.status)if(z&&!M){if(Z.status.fetchAborted=!0,Z.status.fetchError=Y.signal.reason,B)Z.status.fetchAbortIgnored=!0}else Z.status.fetchResolved=!0;if(z&&!B&&!M)return K(Y.signal.reason);let A=_;if(this.#q[Q]===_)if(U===void 0)if(A.__staleWhileFetching)this.#q[Q]=A.__staleWhileFetching;else this.#k($,"fetch");else{if(Z.status)Z.status.fetchUpdated=!0;this.set($,U,J.options)}return U},V=(U)=>{if(Z.status)Z.status.fetchRejected=!0,Z.status.fetchError=U;return K(U)},K=(U)=>{let{aborted:M}=Y.signal,z=M&&Z.allowStaleOnFetchAbort,B=z||Z.allowStaleOnFetchRejection,A=B||Z.noDeleteOnFetchRejection,R=_;if(this.#q[Q]===_){if(!A||R.__staleWhileFetching===void 0)this.#k($,"fetch");else if(!z)this.#q[Q]=R.__staleWhileFetching}if(B){if(Z.status&&R.__staleWhileFetching!==void 0)Z.status.returnedStale=!0;return R.__staleWhileFetching}else if(R.__returned===R)throw U},G=(U,M)=>{let z=this.#F?.($,q,J);if(z&&z instanceof Promise)z.then((B)=>U(B===void 0?void 0:B),M);Y.signal.addEventListener("abort",()=>{if(!Z.ignoreFetchAbort||Z.allowStaleOnFetchAbort){if(U(void 0),Z.allowStaleOnFetchAbort)U=(B)=>H(B,!0)}})};if(Z.status)Z.status.fetchDispatched=!0;let _=new Promise(G).then(H,V),O=Object.assign(_,{__abortController:Y,__staleWhileFetching:q,__returned:void 0});if(Q===void 0)this.set($,O,{...J.options,status:void 0}),Q=this.#H.get($);else this.#q[Q]=O;return O}#z($){if(!this.#T)return!1;let Q=$;return!!Q&&Q instanceof Promise&&Q.hasOwnProperty("__staleWhileFetching")&&Q.__abortController instanceof O8}async fetch($,Q={}){let{allowStale:Z=this.allowStale,updateAgeOnGet:X=this.updateAgeOnGet,noDeleteOnStaleGet:q=this.noDeleteOnStaleGet,ttl:Y=this.ttl,noDisposeOnSet:W=this.noDisposeOnSet,size:J=0,sizeCalculation:H=this.sizeCalculation,noUpdateTTL:V=this.noUpdateTTL,noDeleteOnFetchRejection:K=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:G=this.allowStaleOnFetchRejection,ignoreFetchAbort:_=this.ignoreFetchAbort,allowStaleOnFetchAbort:O=this.allowStaleOnFetchAbort,context:U,forceRefresh:M=!1,status:z,signal:B}=Q;if(!this.#T){if(z)z.fetch="get";return this.get($,{allowStale:Z,updateAgeOnGet:X,noDeleteOnStaleGet:q,status:z})}let A={allowStale:Z,updateAgeOnGet:X,noDeleteOnStaleGet:q,ttl:Y,noDisposeOnSet:W,size:J,sizeCalculation:H,noUpdateTTL:V,noDeleteOnFetchRejection:K,allowStaleOnFetchRejection:G,allowStaleOnFetchAbort:O,ignoreFetchAbort:_,status:z,signal:B},R=this.#H.get($);if(R===void 0){if(z)z.fetch="miss";let C=this.#y($,R,A,U);return C.__returned=C}else{let C=this.#q[R];if(this.#z(C)){let X0=Z&&C.__staleWhileFetching!==void 0;if(z){if(z.fetch="inflight",X0)z.returnedStale=!0}return X0?C.__staleWhileFetching:C.__returned=C}let N=this.#S(R);if(!M&&!N){if(z)z.fetch="hit";if(this.#f(R),X)this.#v(R);if(z)this.#w(z,R);return C}let v=this.#y($,R,A,U),D0=v.__staleWhileFetching!==void 0&&Z;if(z){if(z.fetch=N?"stale":"refresh",D0&&N)z.returnedStale=!0}return D0?v.__staleWhileFetching:v.__returned=v}}async forceFetch($,Q={}){let Z=await this.fetch($,Q);if(Z===void 0)throw Error("fetch() returned undefined");return Z}memo($,Q={}){let Z=this.#I;if(!Z)throw Error("no memoMethod provided to constructor");let{context:X,forceRefresh:q,...Y}=Q,W=this.get($,Y);if(!q&&W!==void 0)return W;let J=Z($,W,{options:Y,context:X});return this.set($,J,Y),J}get($,Q={}){let{allowStale:Z=this.allowStale,updateAgeOnGet:X=this.updateAgeOnGet,noDeleteOnStaleGet:q=this.noDeleteOnStaleGet,status:Y}=Q,W=this.#H.get($);if(W!==void 0){let J=this.#q[W],H=this.#z(J);if(Y)this.#w(Y,W);if(this.#S(W)){if(Y)Y.get="stale";if(!H){if(!q)this.#k($,"expire");if(Y&&Z)Y.returnedStale=!0;return Z?J:void 0}else{if(Y&&Z&&J.__staleWhileFetching!==void 0)Y.returnedStale=!0;return Z?J.__staleWhileFetching:void 0}}else{if(Y)Y.get="hit";if(H)return J.__staleWhileFetching;if(this.#f(W),X)this.#v(W);return J}}else if(Y)Y.get="miss"}#l($,Q){this.#M[Q]=$,this.#O[$]=Q}#f($){if($!==this.#A){if($===this.#U)this.#U=this.#O[$];else this.#l(this.#M[$],this.#O[$]);this.#l(this.#A,$),this.#A=$}}delete($){return this.#k($,"delete")}#k($,Q){let Z=!1;if(this.#V!==0){let X=this.#H.get($);if(X!==void 0)if(Z=!0,this.#V===1)this.#h(Q);else{this.#E(X);let q=this.#q[X];if(this.#z(q))q.__abortController.abort(Error("deleted"));else if(this.#K||this.#B){if(this.#K)this.#Z?.(q,$,Q);if(this.#B)this.#R?.push([q,$,Q])}if(this.#H.delete($),this.#_[X]=void 0,this.#q[X]=void 0,X===this.#A)this.#A=this.#M[X];else if(X===this.#U)this.#U=this.#O[X];else{let Y=this.#M[X];this.#O[Y]=this.#O[X];let W=this.#O[X];this.#M[W]=this.#M[X]}this.#V--,this.#j.push(X)}}if(this.#B&&this.#R?.length){let X=this.#R,q;while(q=X?.shift())this.#Y?.(...q)}return Z}clear(){return this.#h("delete")}#h($){for(let Q of this.#N({allowStale:!0})){let Z=this.#q[Q];if(this.#z(Z))Z.__abortController.abort(Error("deleted"));else{let X=this.#_[Q];if(this.#K)this.#Z?.(Z,X,$);if(this.#B)this.#R?.push([Z,X,$])}}if(this.#H.clear(),this.#q.fill(void 0),this.#_.fill(void 0),this.#C&&this.#W)this.#C.fill(0),this.#W.fill(0);if(this.#L)this.#L.fill(0);if(this.#U=0,this.#A=0,this.#j.length=0,this.#G=0,this.#V=0,this.#B&&this.#R){let Q=this.#R,Z;while(Z=Q?.shift())this.#Y?.(...Z)}}}import{posix as m9,win32 as p$}from"node:path";import{fileURLToPath as c9}from"node:url";import{lstatSync as l9,readdir as d9,readdirSync as p9,readlinkSync as i9,realpathSync as s9}from"fs";import*as r9 from"node:fs";import{lstat as n9,readdir as o9,readlink as t9,realpath as e9}from"node:fs/promises";import{EventEmitter as m$}from"node:events";import h5 from"node:stream";import{StringDecoder as b9}from"node:string_decoder";var y5=typeof process==="object"&&process?process:{stdout:null,stderr:null},k9=($)=>!!$&&typeof $==="object"&&($ instanceof P0||$ instanceof h5||v9($)||E9($)),v9=($)=>!!$&&typeof $==="object"&&$ instanceof m$&&typeof $.pipe==="function"&&$.pipe!==h5.Writable.prototype.pipe,E9=($)=>!!$&&typeof $==="object"&&$ instanceof m$&&typeof $.write==="function"&&typeof $.end==="function",O0=Symbol("EOF"),A0=Symbol("maybeEmitEnd"),C0=Symbol("emittedEnd"),A8=Symbol("emittingEnd"),s0=Symbol("emittedError"),B8=Symbol("closed"),x5=Symbol("read"),R8=Symbol("flush"),u5=Symbol("flushChunk"),J0=Symbol("encoding"),u0=Symbol("decoder"),g=Symbol("flowing"),r0=Symbol("paused"),f0=Symbol("resume"),m=Symbol("buffer"),n=Symbol("pipes"),c=Symbol("bufferLength"),x$=Symbol("bufferPush"),I8=Symbol("bufferShift"),r=Symbol("objectMode"),x=Symbol("destroyed"),u$=Symbol("error"),f$=Symbol("emitData"),f5=Symbol("emitEnd"),h$=Symbol("emitEnd2"),K0=Symbol("async"),g$=Symbol("abort"),F8=Symbol("aborted"),a0=Symbol("signal"),S0=Symbol("dataListeners"),t=Symbol("discarded"),n0=($)=>Promise.resolve().then($),y9=($)=>$(),x9=($)=>$==="end"||$==="finish"||$==="prefinish",u9=($)=>$ instanceof ArrayBuffer||!!$&&typeof $==="object"&&$.constructor&&$.constructor.name==="ArrayBuffer"&&$.byteLength>=0,f9=($)=>!Buffer.isBuffer($)&&ArrayBuffer.isView($);class c${src;dest;opts;ondrain;constructor($,Q,Z){this.src=$,this.dest=Q,this.opts=Z,this.ondrain=()=>$[f0](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors($){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class g5 extends c${unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor($,Q,Z){super($,Q,Z);this.proxyErrors=(X)=>Q.emit("error",X),$.on("error",this.proxyErrors)}}var h9=($)=>!!$.objectMode,g9=($)=>!$.objectMode&&!!$.encoding&&$.encoding!=="buffer";class P0 extends m${[g]=!1;[r0]=!1;[n]=[];[m]=[];[r];[J0];[K0];[u0];[O0]=!1;[C0]=!1;[A8]=!1;[B8]=!1;[s0]=null;[c]=0;[x]=!1;[a0];[F8]=!1;[S0]=0;[t]=!1;writable=!0;readable=!0;constructor(...$){let Q=$[0]||{};super();if(Q.objectMode&&typeof Q.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if(h9(Q))this[r]=!0,this[J0]=null;else if(g9(Q))this[J0]=Q.encoding,this[r]=!1;else this[r]=!1,this[J0]=null;if(this[K0]=!!Q.async,this[u0]=this[J0]?new b9(this[J0]):null,Q&&Q.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[m]});if(Q&&Q.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[n]});let{signal:Z}=Q;if(Z)if(this[a0]=Z,Z.aborted)this[g$]();else Z.addEventListener("abort",()=>this[g$]())}get bufferLength(){return this[c]}get encoding(){return this[J0]}set encoding($){throw Error("Encoding must be set at instantiation time")}setEncoding($){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[r]}set objectMode($){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[K0]}set["async"]($){this[K0]=this[K0]||!!$}[g$](){this[F8]=!0,this.emit("abort",this[a0]?.reason),this.destroy(this[a0]?.reason)}get aborted(){return this[F8]}set aborted($){}write($,Q,Z){if(this[F8])return!1;if(this[O0])throw Error("write after end");if(this[x])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof Q==="function")Z=Q,Q="utf8";if(!Q)Q="utf8";let X=this[K0]?n0:y9;if(!this[r]&&!Buffer.isBuffer($)){if(f9($))$=Buffer.from($.buffer,$.byteOffset,$.byteLength);else if(u9($))$=Buffer.from($);else if(typeof $!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[r]){if(this[g]&&this[c]!==0)this[R8](!0);if(this[g])this.emit("data",$);else this[x$]($);if(this[c]!==0)this.emit("readable");if(Z)X(Z);return this[g]}if(!$.length){if(this[c]!==0)this.emit("readable");if(Z)X(Z);return this[g]}if(typeof $==="string"&&!(Q===this[J0]&&!this[u0]?.lastNeed))$=Buffer.from($,Q);if(Buffer.isBuffer($)&&this[J0])$=this[u0].write($);if(this[g]&&this[c]!==0)this[R8](!0);if(this[g])this.emit("data",$);else this[x$]($);if(this[c]!==0)this.emit("readable");if(Z)X(Z);return this[g]}read($){if(this[x])return null;if(this[t]=!1,this[c]===0||$===0||$&&$>this[c])return this[A0](),null;if(this[r])$=null;if(this[m].length>1&&!this[r])this[m]=[this[J0]?this[m].join(""):Buffer.concat(this[m],this[c])];let Q=this[x5]($||null,this[m][0]);return this[A0](),Q}[x5]($,Q){if(this[r])this[I8]();else{let Z=Q;if($===Z.length||$===null)this[I8]();else if(typeof Z==="string")this[m][0]=Z.slice($),Q=Z.slice(0,$),this[c]-=$;else this[m][0]=Z.subarray($),Q=Z.subarray(0,$),this[c]-=$}if(this.emit("data",Q),!this[m].length&&!this[O0])this.emit("drain");return Q}end($,Q,Z){if(typeof $==="function")Z=$,$=void 0;if(typeof Q==="function")Z=Q,Q="utf8";if($!==void 0)this.write($,Q);if(Z)this.once("end",Z);if(this[O0]=!0,this.writable=!1,this[g]||!this[r0])this[A0]();return this}[f0](){if(this[x])return;if(!this[S0]&&!this[n].length)this[t]=!0;if(this[r0]=!1,this[g]=!0,this.emit("resume"),this[m].length)this[R8]();else if(this[O0])this[A0]();else this.emit("drain")}resume(){return this[f0]()}pause(){this[g]=!1,this[r0]=!0,this[t]=!1}get destroyed(){return this[x]}get flowing(){return this[g]}get paused(){return this[r0]}[x$]($){if(this[r])this[c]+=1;else this[c]+=$.length;this[m].push($)}[I8](){if(this[r])this[c]-=1;else this[c]-=this[m][0].length;return this[m].shift()}[R8]($=!1){do;while(this[u5](this[I8]())&&this[m].length);if(!$&&!this[m].length&&!this[O0])this.emit("drain")}[u5]($){return this.emit("data",$),this[g]}pipe($,Q){if(this[x])return $;this[t]=!1;let Z=this[C0];if(Q=Q||{},$===y5.stdout||$===y5.stderr)Q.end=!1;else Q.end=Q.end!==!1;if(Q.proxyErrors=!!Q.proxyErrors,Z){if(Q.end)$.end()}else if(this[n].push(!Q.proxyErrors?new c$(this,$,Q):new g5(this,$,Q)),this[K0])n0(()=>this[f0]());else this[f0]();return $}unpipe($){let Q=this[n].find((Z)=>Z.dest===$);if(Q){if(this[n].length===1){if(this[g]&&this[S0]===0)this[g]=!1;this[n]=[]}else this[n].splice(this[n].indexOf(Q),1);Q.unpipe()}}addListener($,Q){return this.on($,Q)}on($,Q){let Z=super.on($,Q);if($==="data"){if(this[t]=!1,this[S0]++,!this[n].length&&!this[g])this[f0]()}else if($==="readable"&&this[c]!==0)super.emit("readable");else if(x9($)&&this[C0])super.emit($),this.removeAllListeners($);else if($==="error"&&this[s0]){let X=Q;if(this[K0])n0(()=>X.call(this,this[s0]));else X.call(this,this[s0])}return Z}removeListener($,Q){return this.off($,Q)}off($,Q){let Z=super.off($,Q);if($==="data"){if(this[S0]=this.listeners("data").length,this[S0]===0&&!this[t]&&!this[n].length)this[g]=!1}return Z}removeAllListeners($){let Q=super.removeAllListeners($);if($==="data"||$===void 0){if(this[S0]=0,!this[t]&&!this[n].length)this[g]=!1}return Q}get emittedEnd(){return this[C0]}[A0](){if(!this[A8]&&!this[C0]&&!this[x]&&this[m].length===0&&this[O0]){if(this[A8]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[B8])this.emit("close");this[A8]=!1}}emit($,...Q){let Z=Q[0];if($!=="error"&&$!=="close"&&$!==x&&this[x])return!1;else if($==="data")return!this[r]&&!Z?!1:this[K0]?(n0(()=>this[f$](Z)),!0):this[f$](Z);else if($==="end")return this[f5]();else if($==="close"){if(this[B8]=!0,!this[C0]&&!this[x])return!1;let q=super.emit("close");return this.removeAllListeners("close"),q}else if($==="error"){this[s0]=Z,super.emit(u$,Z);let q=!this[a0]||this.listeners("error").length?super.emit("error",Z):!1;return this[A0](),q}else if($==="resume"){let q=super.emit("resume");return this[A0](),q}else if($==="finish"||$==="prefinish"){let q=super.emit($);return this.removeAllListeners($),q}let X=super.emit($,...Q);return this[A0](),X}[f$]($){for(let Z of this[n])if(Z.dest.write($)===!1)this.pause();let Q=this[t]?!1:super.emit("data",$);return this[A0](),Q}[f5](){if(this[C0])return!1;return this[C0]=!0,this.readable=!1,this[K0]?(n0(()=>this[h$]()),!0):this[h$]()}[h$](){if(this[u0]){let Q=this[u0].end();if(Q){for(let Z of this[n])Z.dest.write(Q);if(!this[t])super.emit("data",Q)}}for(let Q of this[n])Q.end();let $=super.emit("end");return this.removeAllListeners("end"),$}async collect(){let $=Object.assign([],{dataLength:0});if(!this[r])$.dataLength=0;let Q=this.promise();return this.on("data",(Z)=>{if($.push(Z),!this[r])$.dataLength+=Z.length}),await Q,$}async concat(){if(this[r])throw Error("cannot concat in objectMode");let $=await this.collect();return this[J0]?$.join(""):Buffer.concat($,$.dataLength)}async promise(){return new Promise(($,Q)=>{this.on(x,()=>Q(Error("stream destroyed"))),this.on("error",(Z)=>Q(Z)),this.on("end",()=>$())})}[Symbol.asyncIterator](){this[t]=!1;let $=!1,Q=async()=>{return this.pause(),$=!0,{value:void 0,done:!0}};return{next:()=>{if($)return Q();let X=this.read();if(X!==null)return Promise.resolve({done:!1,value:X});if(this[O0])return Q();let q,Y,W=(K)=>{this.off("data",J),this.off("end",H),this.off(x,V),Q(),Y(K)},J=(K)=>{this.off("error",W),this.off("end",H),this.off(x,V),this.pause(),q({value:K,done:!!this[O0]})},H=()=>{this.off("error",W),this.off("data",J),this.off(x,V),Q(),q({done:!0,value:void 0})},V=()=>W(Error("stream destroyed"));return new Promise((K,G)=>{Y=G,q=K,this.once(x,V),this.once("error",W),this.once("end",H),this.once("data",J)})},throw:Q,return:Q,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[t]=!1;let $=!1,Q=()=>{return this.pause(),this.off(u$,Q),this.off(x,Q),this.off("end",Q),$=!0,{done:!0,value:void 0}},Z=()=>{if($)return Q();let X=this.read();return X===null?Q():{done:!1,value:X}};return this.once("end",Q),this.once(u$,Q),this.once(x,Q),{next:Z,throw:Q,return:Q,[Symbol.iterator](){return this}}}destroy($){if(this[x]){if($)this.emit("error",$);else this.emit(x);return this}this[x]=!0,this[t]=!0,this[m].length=0,this[c]=0;let Q=this;if(typeof Q.close==="function"&&!this[B8])Q.close();if($)this.emit("error",$);else this.emit(x);return this}static get isStream(){return k9}}var a9=s9.native,t0={lstatSync:l9,readdir:d9,readdirSync:p9,readlinkSync:i9,realpathSync:a9,promises:{lstat:n9,readdir:o9,readlink:t9,realpath:e9}},p5=($)=>!$||$===t0||$===r9?t0:{...t0,...$,promises:{...t0.promises,...$.promises||{}}},i5=/^\\\\\?\\([a-z]:)\\?$/i,$Q=($)=>$.replace(/\//g,"\\").replace(i5,"$1\\"),QQ=/[\\\/]/,Z0=0,s5=1,r5=2,_0=4,a5=6,n5=8,N0=10,o5=12,Q0=15,o0=~Q0,l$=16,m5=32,e0=64,W0=128,C8=256,j8=512,c5=e0|W0|j8,ZQ=1023,d$=($)=>$.isFile()?n5:$.isDirectory()?_0:$.isSymbolicLink()?N0:$.isCharacterDevice()?r5:$.isBlockDevice()?a5:$.isSocket()?o5:$.isFIFO()?s5:Z0,l5=new Map,$8=($)=>{let Q=l5.get($);if(Q)return Q;let Z=$.normalize("NFKD");return l5.set($,Z),Z},d5=new Map,L8=($)=>{let Q=d5.get($);if(Q)return Q;let Z=$8($.toLowerCase());return d5.set($,Z),Z};class i$ extends i0{constructor(){super({max:256})}}class t5 extends i0{constructor($=16384){super({maxSize:$,sizeCalculation:(Q)=>Q.length+1})}}var e5=Symbol("PathScurry setAsCwd");class o{name;root;roots;parent;nocase;isCWD=!1;#Q;#$;get dev(){return this.#$}#Z;get mode(){return this.#Z}#X;get nlink(){return this.#X}#Y;get uid(){return this.#Y}#F;get gid(){return this.#F}#I;get rdev(){return this.#I}#V;get blksize(){return this.#V}#G;get ino(){return this.#G}#H;get size(){return this.#H}#_;get blocks(){return this.#_}#q;get atimeMs(){return this.#q}#O;get mtimeMs(){return this.#O}#M;get ctimeMs(){return this.#M}#U;get birthtimeMs(){return this.#U}#A;get atime(){return this.#A}#j;get mtime(){return this.#j}#R;get ctime(){return this.#R}#L;get birthtime(){return this.#L}#W;#C;#K;#T;#B;#D;#J;#v;#w;#b;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor($,Q=Z0,Z,X,q,Y,W){if(this.name=$,this.#W=q?L8($):$8($),this.#J=Q&ZQ,this.nocase=q,this.roots=X,this.root=Z||this,this.#v=Y,this.#K=W.fullpath,this.#B=W.relative,this.#D=W.relativePosix,this.parent=W.parent,this.parent)this.#Q=this.parent.#Q;else this.#Q=p5(W.fs)}depth(){if(this.#C!==void 0)return this.#C;if(!this.parent)return this.#C=0;return this.#C=this.parent.depth()+1}childrenCache(){return this.#v}resolve($){if(!$)return this;let Q=this.getRootString($),X=$.substring(Q.length).split(this.splitSep);return Q?this.getRoot(Q).#S(X):this.#S(X)}#S($){let Q=this;for(let Z of $)Q=Q.child(Z);return Q}children(){let $=this.#v.get(this);if($)return $;let Q=Object.assign([],{provisional:0});return this.#v.set(this,Q),this.#J&=~l$,Q}child($,Q){if($===""||$===".")return this;if($==="..")return this.parent||this;let Z=this.children(),X=this.nocase?L8($):$8($);for(let J of Z)if(J.#W===X)return J;let q=this.parent?this.sep:"",Y=this.#K?this.#K+q+$:void 0,W=this.newChild($,Z0,{...Q,parent:this,fullpath:Y});if(!this.canReaddir())W.#J|=W0;return Z.push(W),W}relative(){if(this.isCWD)return"";if(this.#B!==void 0)return this.#B;let $=this.name,Q=this.parent;if(!Q)return this.#B=this.name;let Z=Q.relative();return Z+(!Z||!Q.parent?"":this.sep)+$}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#D!==void 0)return this.#D;let $=this.name,Q=this.parent;if(!Q)return this.#D=this.fullpathPosix();let Z=Q.relativePosix();return Z+(!Z||!Q.parent?"":"/")+$}fullpath(){if(this.#K!==void 0)return this.#K;let $=this.name,Q=this.parent;if(!Q)return this.#K=this.name;let X=Q.fullpath()+(!Q.parent?"":this.sep)+$;return this.#K=X}fullpathPosix(){if(this.#T!==void 0)return this.#T;if(this.sep==="/")return this.#T=this.fullpath();if(!this.parent){let X=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(X))return this.#T=`//?/${X}`;else return this.#T=X}let $=this.parent,Q=$.fullpathPosix(),Z=Q+(!Q||!$.parent?"":"/")+this.name;return this.#T=Z}isUnknown(){return(this.#J&Q0)===Z0}isType($){return this[`is${$}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#J&Q0)===n5}isDirectory(){return(this.#J&Q0)===_0}isCharacterDevice(){return(this.#J&Q0)===r5}isBlockDevice(){return(this.#J&Q0)===a5}isFIFO(){return(this.#J&Q0)===s5}isSocket(){return(this.#J&Q0)===o5}isSymbolicLink(){return(this.#J&N0)===N0}lstatCached(){return this.#J&m5?this:void 0}readlinkCached(){return this.#w}realpathCached(){return this.#b}readdirCached(){let $=this.children();return $.slice(0,$.provisional)}canReadlink(){if(this.#w)return!0;if(!this.parent)return!1;let $=this.#J&Q0;return!($!==Z0&&$!==N0||this.#J&C8||this.#J&W0)}calledReaddir(){return!!(this.#J&l$)}isENOENT(){return!!(this.#J&W0)}isNamed($){return!this.nocase?this.#W===$8($):this.#W===L8($)}async readlink(){let $=this.#w;if($)return $;if(!this.canReadlink())return;if(!this.parent)return;try{let Q=await this.#Q.promises.readlink(this.fullpath()),Z=(await this.parent.realpath())?.resolve(Q);if(Z)return this.#w=Z}catch(Q){this.#u(Q.code);return}}readlinkSync(){let $=this.#w;if($)return $;if(!this.canReadlink())return;if(!this.parent)return;try{let Q=this.#Q.readlinkSync(this.fullpath()),Z=this.parent.realpathSync()?.resolve(Q);if(Z)return this.#w=Z}catch(Q){this.#u(Q.code);return}}#g($){this.#J|=l$;for(let Q=$.provisional;Q<$.length;Q++){let Z=$[Q];if(Z)Z.#E()}}#E(){if(this.#J&W0)return;this.#J=(this.#J|W0)&o0,this.#x()}#x(){let $=this.children();$.provisional=0;for(let Q of $)Q.#E()}#m(){this.#J|=j8,this.#P()}#P(){if(this.#J&e0)return;let $=this.#J;if(($&Q0)===_0)$&=o0;this.#J=$|e0,this.#x()}#N($=""){if($==="ENOTDIR"||$==="EPERM")this.#P();else if($==="ENOENT")this.#E();else this.children().provisional=0}#c($=""){if($==="ENOTDIR")this.parent.#P();else if($==="ENOENT")this.#E()}#u($=""){let Q=this.#J;if(Q|=C8,$==="ENOENT")Q|=W0;if($==="EINVAL"||$==="UNKNOWN")Q&=o0;if(this.#J=Q,$==="ENOTDIR"&&this.parent)this.parent.#P()}#y($,Q){return this.#l($,Q)||this.#z($,Q)}#z($,Q){let Z=d$($),X=this.newChild($.name,Z,{parent:this}),q=X.#J&Q0;if(q!==_0&&q!==N0&&q!==Z0)X.#J|=e0;return Q.unshift(X),Q.provisional++,X}#l($,Q){for(let Z=Q.provisional;Z<Q.length;Z++){let X=Q[Z];if((this.nocase?L8($.name):$8($.name))!==X.#W)continue;return this.#f($,X,Z,Q)}}#f($,Q,Z,X){let q=Q.name;if(Q.#J=Q.#J&o0|d$($),q!==$.name)Q.name=$.name;if(Z!==X.provisional){if(Z===X.length-1)X.pop();else X.splice(Z,1);X.unshift(Q)}return X.provisional++,Q}async lstat(){if((this.#J&W0)===0)try{return this.#k(await this.#Q.promises.lstat(this.fullpath())),this}catch($){this.#c($.code)}}lstatSync(){if((this.#J&W0)===0)try{return this.#k(this.#Q.lstatSync(this.fullpath())),this}catch($){this.#c($.code)}}#k($){let{atime:Q,atimeMs:Z,birthtime:X,birthtimeMs:q,blksize:Y,blocks:W,ctime:J,ctimeMs:H,dev:V,gid:K,ino:G,mode:_,mtime:O,mtimeMs:U,nlink:M,rdev:z,size:B,uid:A}=$;this.#A=Q,this.#q=Z,this.#L=X,this.#U=q,this.#V=Y,this.#_=W,this.#R=J,this.#M=H,this.#$=V,this.#F=K,this.#G=G,this.#Z=_,this.#j=O,this.#O=U,this.#X=M,this.#I=z,this.#H=B,this.#Y=A;let R=d$($);if(this.#J=this.#J&o0|R|m5,R!==Z0&&R!==_0&&R!==N0)this.#J|=e0}#h=[];#p=!1;#i($){this.#p=!1;let Q=this.#h.slice();this.#h.length=0,Q.forEach((Z)=>Z(null,$))}readdirCB($,Q=!1){if(!this.canReaddir()){if(Q)$(null,[]);else queueMicrotask(()=>$(null,[]));return}let Z=this.children();if(this.calledReaddir()){let q=Z.slice(0,Z.provisional);if(Q)$(null,q);else queueMicrotask(()=>$(null,q));return}if(this.#h.push($),this.#p)return;this.#p=!0;let X=this.fullpath();this.#Q.readdir(X,{withFileTypes:!0},(q,Y)=>{if(q)this.#N(q.code),Z.provisional=0;else{for(let W of Y)this.#y(W,Z);this.#g(Z)}this.#i(Z.slice(0,Z.provisional));return})}#d;async readdir(){if(!this.canReaddir())return[];let $=this.children();if(this.calledReaddir())return $.slice(0,$.provisional);let Q=this.fullpath();if(this.#d)await this.#d;else{let Z=()=>{};this.#d=new Promise((X)=>Z=X);try{for(let X of await this.#Q.promises.readdir(Q,{withFileTypes:!0}))this.#y(X,$);this.#g($)}catch(X){this.#N(X.code),$.provisional=0}this.#d=void 0,Z()}return $.slice(0,$.provisional)}readdirSync(){if(!this.canReaddir())return[];let $=this.children();if(this.calledReaddir())return $.slice(0,$.provisional);let Q=this.fullpath();try{for(let Z of this.#Q.readdirSync(Q,{withFileTypes:!0}))this.#y(Z,$);this.#g($)}catch(Z){this.#N(Z.code),$.provisional=0}return $.slice(0,$.provisional)}canReaddir(){if(this.#J&c5)return!1;let $=Q0&this.#J;if(!($===Z0||$===_0||$===N0))return!1;return!0}shouldWalk($,Q){return(this.#J&_0)===_0&&!(this.#J&c5)&&!$.has(this)&&(!Q||Q(this))}async realpath(){if(this.#b)return this.#b;if((j8|C8|W0)&this.#J)return;try{let $=await this.#Q.promises.realpath(this.fullpath());return this.#b=this.resolve($)}catch($){this.#m()}}realpathSync(){if(this.#b)return this.#b;if((j8|C8|W0)&this.#J)return;try{let $=this.#Q.realpathSync(this.fullpath());return this.#b=this.resolve($)}catch($){this.#m()}}[e5]($){if($===this)return;$.isCWD=!1,this.isCWD=!0;let Q=new Set([]),Z=[],X=this;while(X&&X.parent)Q.add(X),X.#B=Z.join(this.sep),X.#D=Z.join("/"),X=X.parent,Z.push("..");X=$;while(X&&X.parent&&!Q.has(X))X.#B=void 0,X.#D=void 0,X=X.parent}}class T8 extends o{sep="\\";splitSep=QQ;constructor($,Q=Z0,Z,X,q,Y,W){super($,Q,Z,X,q,Y,W)}newChild($,Q=Z0,Z={}){return new T8($,Q,this.root,this.roots,this.nocase,this.childrenCache(),Z)}getRootString($){return p$.parse($).root}getRoot($){if($=$Q($.toUpperCase()),$===this.root.name)return this.root;for(let[Q,Z]of Object.entries(this.roots))if(this.sameRoot($,Q))return this.roots[$]=Z;return this.roots[$]=new Q8($,this).root}sameRoot($,Q=this.root.name){return $=$.toUpperCase().replace(/\//g,"\\").replace(i5,"$1\\"),$===Q}}class w8 extends o{splitSep="/";sep="/";constructor($,Q=Z0,Z,X,q,Y,W){super($,Q,Z,X,q,Y,W)}getRootString($){return $.startsWith("/")?"/":""}getRoot($){return this.root}newChild($,Q=Z0,Z={}){return new w8($,Q,this.root,this.roots,this.nocase,this.childrenCache(),Z)}}class s${root;rootPath;roots;cwd;#Q;#$;#Z;nocase;#X;constructor($=process.cwd(),Q,Z,{nocase:X,childrenCacheSize:q=16384,fs:Y=t0}={}){if(this.#X=p5(Y),$ instanceof URL||$.startsWith("file://"))$=c9($);let W=Q.resolve($);this.roots=Object.create(null),this.rootPath=this.parseRootPath(W),this.#Q=new i$,this.#$=new i$,this.#Z=new t5(q);let J=W.substring(this.rootPath.length).split(Z);if(J.length===1&&!J[0])J.pop();if(X===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=X,this.root=this.newRoot(this.#X),this.roots[this.rootPath]=this.root;let H=this.root,V=J.length-1,K=Q.sep,G=this.rootPath,_=!1;for(let O of J){let U=V--;H=H.child(O,{relative:Array(U).fill("..").join(K),relativePosix:Array(U).fill("..").join("/"),fullpath:G+=(_?"":K)+O}),_=!0}this.cwd=H}depth($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.depth()}childrenCache(){return this.#Z}resolve(...$){let Q="";for(let q=$.length-1;q>=0;q--){let Y=$[q];if(!Y||Y===".")continue;if(Q=Q?`${Y}/${Q}`:Y,this.isAbsolute(Y))break}let Z=this.#Q.get(Q);if(Z!==void 0)return Z;let X=this.cwd.resolve(Q).fullpath();return this.#Q.set(Q,X),X}resolvePosix(...$){let Q="";for(let q=$.length-1;q>=0;q--){let Y=$[q];if(!Y||Y===".")continue;if(Q=Q?`${Y}/${Q}`:Y,this.isAbsolute(Y))break}let Z=this.#$.get(Q);if(Z!==void 0)return Z;let X=this.cwd.resolve(Q).fullpathPosix();return this.#$.set(Q,X),X}relative($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.relative()}relativePosix($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.relativePosix()}basename($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.name}dirname($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return($.parent||$).fullpath()}async readdir($=this.cwd,Q={withFileTypes:!0}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof o))Q=$,$=this.cwd;let{withFileTypes:Z}=Q;if(!$.canReaddir())return[];else{let X=await $.readdir();return Z?X:X.map((q)=>q.name)}}readdirSync($=this.cwd,Q={withFileTypes:!0}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof o))Q=$,$=this.cwd;let{withFileTypes:Z=!0}=Q;if(!$.canReaddir())return[];else if(Z)return $.readdirSync();else return $.readdirSync().map((X)=>X.name)}async lstat($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.lstat()}lstatSync($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.lstatSync()}async readlink($=this.cwd,{withFileTypes:Q}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof o))Q=$.withFileTypes,$=this.cwd;let Z=await $.readlink();return Q?Z:Z?.fullpath()}readlinkSync($=this.cwd,{withFileTypes:Q}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof o))Q=$.withFileTypes,$=this.cwd;let Z=$.readlinkSync();return Q?Z:Z?.fullpath()}async realpath($=this.cwd,{withFileTypes:Q}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof o))Q=$.withFileTypes,$=this.cwd;let Z=await $.realpath();return Q?Z:Z?.fullpath()}realpathSync($=this.cwd,{withFileTypes:Q}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof o))Q=$.withFileTypes,$=this.cwd;let Z=$.realpathSync();return Q?Z:Z?.fullpath()}async walk($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof o))Q=$,$=this.cwd;let{withFileTypes:Z=!0,follow:X=!1,filter:q,walkFilter:Y}=Q,W=[];if(!q||q($))W.push(Z?$:$.fullpath());let J=new Set,H=(K,G)=>{J.add(K),K.readdirCB((_,O)=>{if(_)return G(_);let U=O.length;if(!U)return G();let M=()=>{if(--U===0)G()};for(let z of O){if(!q||q(z))W.push(Z?z:z.fullpath());if(X&&z.isSymbolicLink())z.realpath().then((B)=>B?.isUnknown()?B.lstat():B).then((B)=>B?.shouldWalk(J,Y)?H(B,M):M());else if(z.shouldWalk(J,Y))H(z,M);else M()}},!0)},V=$;return new Promise((K,G)=>{H(V,(_)=>{if(_)return G(_);K(W)})})}walkSync($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof o))Q=$,$=this.cwd;let{withFileTypes:Z=!0,follow:X=!1,filter:q,walkFilter:Y}=Q,W=[];if(!q||q($))W.push(Z?$:$.fullpath());let J=new Set([$]);for(let H of J){let V=H.readdirSync();for(let K of V){if(!q||q(K))W.push(Z?K:K.fullpath());let G=K;if(K.isSymbolicLink()){if(!(X&&(G=K.realpathSync())))continue;if(G.isUnknown())G.lstatSync()}if(G.shouldWalk(J,Y))J.add(G)}}return W}[Symbol.asyncIterator](){return this.iterate()}iterate($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof o))Q=$,$=this.cwd;return this.stream($,Q)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof o))Q=$,$=this.cwd;let{withFileTypes:Z=!0,follow:X=!1,filter:q,walkFilter:Y}=Q;if(!q||q($))yield Z?$:$.fullpath();let W=new Set([$]);for(let J of W){let H=J.readdirSync();for(let V of H){if(!q||q(V))yield Z?V:V.fullpath();let K=V;if(V.isSymbolicLink()){if(!(X&&(K=V.realpathSync())))continue;if(K.isUnknown())K.lstatSync()}if(K.shouldWalk(W,Y))W.add(K)}}}stream($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof o))Q=$,$=this.cwd;let{withFileTypes:Z=!0,follow:X=!1,filter:q,walkFilter:Y}=Q,W=new P0({objectMode:!0});if(!q||q($))W.write(Z?$:$.fullpath());let J=new Set,H=[$],V=0,K=()=>{let G=!1;while(!G){let _=H.shift();if(!_){if(V===0)W.end();return}V++,J.add(_);let O=(M,z,B=!1)=>{if(M)return W.emit("error",M);if(X&&!B){let A=[];for(let R of z)if(R.isSymbolicLink())A.push(R.realpath().then((C)=>C?.isUnknown()?C.lstat():C));if(A.length){Promise.all(A).then(()=>O(null,z,!0));return}}for(let A of z)if(A&&(!q||q(A))){if(!W.write(Z?A:A.fullpath()))G=!0}V--;for(let A of z){let R=A.realpathCached()||A;if(R.shouldWalk(J,Y))H.push(R)}if(G&&!W.flowing)W.once("drain",K);else if(!U)K()},U=!0;_.readdirCB(O,!0),U=!1}};return K(),W}streamSync($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof o))Q=$,$=this.cwd;let{withFileTypes:Z=!0,follow:X=!1,filter:q,walkFilter:Y}=Q,W=new P0({objectMode:!0}),J=new Set;if(!q||q($))W.write(Z?$:$.fullpath());let H=[$],V=0,K=()=>{let G=!1;while(!G){let _=H.shift();if(!_){if(V===0)W.end();return}V++,J.add(_);let O=_.readdirSync();for(let U of O)if(!q||q(U)){if(!W.write(Z?U:U.fullpath()))G=!0}V--;for(let U of O){let M=U;if(U.isSymbolicLink()){if(!(X&&(M=U.realpathSync())))continue;if(M.isUnknown())M.lstatSync()}if(M.shouldWalk(J,Y))H.push(M)}}if(G&&!W.flowing)W.once("drain",K)};return K(),W}chdir($=this.cwd){let Q=this.cwd;this.cwd=typeof $==="string"?this.cwd.resolve($):$,this.cwd[e5](Q)}}class Q8 extends s${sep="\\";constructor($=process.cwd(),Q={}){let{nocase:Z=!0}=Q;super($,p$,"\\",{...Q,nocase:Z});this.nocase=Z;for(let X=this.cwd;X;X=X.parent)X.nocase=this.nocase}parseRootPath($){return p$.parse($).root.toUpperCase()}newRoot($){return new T8(this.rootPath,_0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")||$.startsWith("\\")||/^[a-z]:(\/|\\)/i.test($)}}class Z8 extends s${sep="/";constructor($=process.cwd(),Q={}){let{nocase:Z=!1}=Q;super($,m9,"/",{...Q,nocase:Z});this.nocase=Z}parseRootPath($){return"/"}newRoot($){return new w8(this.rootPath,_0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")}}class S8 extends Z8{constructor($=process.cwd(),Q={}){let{nocase:Z=!0}=Q;super($,{...Q,nocase:Z})}}var jX=process.platform==="win32"?T8:w8,$1=process.platform==="win32"?Q8:process.platform==="darwin"?S8:Z8;var XQ=($)=>$.length>=1,qQ=($)=>$.length>=1;class h0{#Q;#$;#Z;length;#X;#Y;#F;#I;#V;#G;#H=!0;constructor($,Q,Z,X){if(!XQ($))throw TypeError("empty pattern list");if(!qQ(Q))throw TypeError("empty glob list");if(Q.length!==$.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=$.length,Z<0||Z>=this.length)throw TypeError("index out of range");if(this.#Q=$,this.#$=Q,this.#Z=Z,this.#X=X,this.#Z===0){if(this.isUNC()){let[q,Y,W,J,...H]=this.#Q,[V,K,G,_,...O]=this.#$;if(H[0]==="")H.shift(),O.shift();let U=[q,Y,W,J,""].join("/"),M=[V,K,G,_,""].join("/");this.#Q=[U,...H],this.#$=[M,...O],this.length=this.#Q.length}else if(this.isDrive()||this.isAbsolute()){let[q,...Y]=this.#Q,[W,...J]=this.#$;if(Y[0]==="")Y.shift(),J.shift();let H=q+"/",V=W+"/";this.#Q=[H,...Y],this.#$=[V,...J],this.length=this.#Q.length}}}pattern(){return this.#Q[this.#Z]}isString(){return typeof this.#Q[this.#Z]==="string"}isGlobstar(){return this.#Q[this.#Z]===d}isRegExp(){return this.#Q[this.#Z]instanceof RegExp}globString(){return this.#F=this.#F||(this.#Z===0?this.isAbsolute()?this.#$[0]+this.#$.slice(1).join("/"):this.#$.join("/"):this.#$.slice(this.#Z).join("/"))}hasMore(){return this.length>this.#Z+1}rest(){if(this.#Y!==void 0)return this.#Y;if(!this.hasMore())return this.#Y=null;return this.#Y=new h0(this.#Q,this.#$,this.#Z+1,this.#X),this.#Y.#G=this.#G,this.#Y.#V=this.#V,this.#Y.#I=this.#I,this.#Y}isUNC(){let $=this.#Q;return this.#V!==void 0?this.#V:this.#V=this.#X==="win32"&&this.#Z===0&&$[0]===""&&$[1]===""&&typeof $[2]==="string"&&!!$[2]&&typeof $[3]==="string"&&!!$[3]}isDrive(){let $=this.#Q;return this.#I!==void 0?this.#I:this.#I=this.#X==="win32"&&this.#Z===0&&this.length>1&&typeof $[0]==="string"&&/^[a-z]:$/i.test($[0])}isAbsolute(){let $=this.#Q;return this.#G!==void 0?this.#G:this.#G=$[0]===""&&$.length>1||this.isDrive()||this.isUNC()}root(){let $=this.#Q[0];return typeof $==="string"&&this.isAbsolute()&&this.#Z===0?$:""}checkFollowGlobstar(){return!(this.#Z===0||!this.isGlobstar()||!this.#H)}markFollowGlobstar(){if(this.#Z===0||!this.isGlobstar()||!this.#H)return!1;return this.#H=!1,!0}}var YQ=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class X8{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor($,{nobrace:Q,nocase:Z,noext:X,noglobstar:q,platform:Y=YQ}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=Y,this.mmopts={dot:!0,nobrace:Q,nocase:Z,noext:X,noglobstar:q,optimizationLevel:2,platform:Y,nocomment:!0,nonegate:!0};for(let W of $)this.add(W)}add($){let Q=new $0($,this.mmopts);for(let Z=0;Z<Q.set.length;Z++){let X=Q.set[Z],q=Q.globParts[Z];if(!X||!q)throw Error("invalid pattern object");while(X[0]==="."&&q[0]===".")X.shift(),q.shift();let Y=new h0(X,q,0,this.platform),W=new $0(Y.globString(),this.mmopts),J=q[q.length-1]==="**",H=Y.isAbsolute();if(H)this.absolute.push(W);else this.relative.push(W);if(J)if(H)this.absoluteChildren.push(W);else this.relativeChildren.push(W)}}ignored($){let Q=$.fullpath(),Z=`${Q}/`,X=$.relative()||".",q=`${X}/`;for(let Y of this.relative)if(Y.match(X)||Y.match(q))return!0;for(let Y of this.absolute)if(Y.match(Q)||Y.match(Z))return!0;return!1}childrenIgnored($){let Q=$.fullpath()+"/",Z=($.relative()||".")+"/";for(let X of this.relativeChildren)if(X.match(Z))return!0;for(let X of this.absoluteChildren)if(X.match(Q))return!0;return!1}}class r${store;constructor($=new Map){this.store=$}copy(){return new r$(new Map(this.store))}hasWalked($,Q){return this.store.get($.fullpath())?.has(Q.globString())}storeWalked($,Q){let Z=$.fullpath(),X=this.store.get(Z);if(X)X.add(Q.globString());else this.store.set(Z,new Set([Q.globString()]))}}class Q1{store=new Map;add($,Q,Z){let X=(Q?2:0)|(Z?1:0),q=this.store.get($);this.store.set($,q===void 0?X:X&q)}entries(){return[...this.store.entries()].map(([$,Q])=>[$,!!(Q&2),!!(Q&1)])}}class Z1{store=new Map;add($,Q){if(!$.canReaddir())return;let Z=this.store.get($);if(Z){if(!Z.find((X)=>X.globString()===Q.globString()))Z.push(Q)}else this.store.set($,[Q])}get($){let Q=this.store.get($);if(!Q)throw Error("attempting to walk unknown path");return Q}entries(){return this.keys().map(($)=>[$,this.store.get($)])}keys(){return[...this.store.keys()].filter(($)=>$.canReaddir())}}class q8{hasWalkedCache;matches=new Q1;subwalks=new Z1;patterns;follow;dot;opts;constructor($,Q){this.opts=$,this.follow=!!$.follow,this.dot=!!$.dot,this.hasWalkedCache=Q?Q.copy():new r$}processPatterns($,Q){this.patterns=Q;let Z=Q.map((X)=>[$,X]);for(let[X,q]of Z){this.hasWalkedCache.storeWalked(X,q);let Y=q.root(),W=q.isAbsolute()&&this.opts.absolute!==!1;if(Y){X=X.resolve(Y==="/"&&this.opts.root!==void 0?this.opts.root:Y);let K=q.rest();if(!K){this.matches.add(X,!0,!1);continue}else q=K}if(X.isENOENT())continue;let J,H,V=!1;while(typeof(J=q.pattern())==="string"&&(H=q.rest()))X=X.resolve(J),q=H,V=!0;if(J=q.pattern(),H=q.rest(),V){if(this.hasWalkedCache.hasWalked(X,q))continue;this.hasWalkedCache.storeWalked(X,q)}if(typeof J==="string"){let K=J===".."||J===""||J===".";this.matches.add(X.resolve(J),W,K);continue}else if(J===d){if(!X.isSymbolicLink()||this.follow||q.checkFollowGlobstar())this.subwalks.add(X,q);let K=H?.pattern(),G=H?.rest();if(!H||(K===""||K===".")&&!G)this.matches.add(X,W,K===""||K===".");else if(K===".."){let _=X.parent||X;if(!G)this.matches.add(_,W,!0);else if(!this.hasWalkedCache.hasWalked(_,G))this.subwalks.add(_,G)}}else if(J instanceof RegExp)this.subwalks.add(X,q)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new q8(this.opts,this.hasWalkedCache)}filterEntries($,Q){let Z=this.subwalks.get($),X=this.child();for(let q of Q)for(let Y of Z){let W=Y.isAbsolute(),J=Y.pattern(),H=Y.rest();if(J===d)X.testGlobstar(q,Y,H,W);else if(J instanceof RegExp)X.testRegExp(q,J,H,W);else X.testString(q,J,H,W)}return X}testGlobstar($,Q,Z,X){if(this.dot||!$.name.startsWith(".")){if(!Q.hasMore())this.matches.add($,X,!1);if($.canReaddir()){if(this.follow||!$.isSymbolicLink())this.subwalks.add($,Q);else if($.isSymbolicLink()){if(Z&&Q.checkFollowGlobstar())this.subwalks.add($,Z);else if(Q.markFollowGlobstar())this.subwalks.add($,Q)}}}if(Z){let q=Z.pattern();if(typeof q==="string"&&q!==".."&&q!==""&&q!==".")this.testString($,q,Z.rest(),X);else if(q===".."){let Y=$.parent||$;this.subwalks.add(Y,Z)}else if(q instanceof RegExp)this.testRegExp($,q,Z.rest(),X)}}testRegExp($,Q,Z,X){if(!Q.test($.name))return;if(!Z)this.matches.add($,X,!1);else this.subwalks.add($,Z)}testString($,Q,Z,X){if(!$.isNamed(Q))return;if(!Z)this.matches.add($,X,!1);else this.subwalks.add($,Z)}}var JQ=($,Q)=>typeof $==="string"?new X8([$],Q):Array.isArray($)?new X8($,Q):$;class a${path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Q=[];#$;#Z;signal;maxDepth;includeChildMatches;constructor($,Q,Z){if(this.patterns=$,this.path=Q,this.opts=Z,this.#Z=!Z.posix&&Z.platform==="win32"?"\\":"/",this.includeChildMatches=Z.includeChildMatches!==!1,Z.ignore||!this.includeChildMatches){if(this.#$=JQ(Z.ignore??[],Z),!this.includeChildMatches&&typeof this.#$.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=Z.maxDepth||1/0,Z.signal)this.signal=Z.signal,this.signal.addEventListener("abort",()=>{this.#Q.length=0})}#X($){return this.seen.has($)||!!this.#$?.ignored?.($)}#Y($){return!!this.#$?.childrenIgnored?.($)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let $=void 0;while(!this.paused&&($=this.#Q.shift()))$()}onResume($){if(this.signal?.aborted)return;if(!this.paused)$();else this.#Q.push($)}async matchCheck($,Q){if(Q&&this.opts.nodir)return;let Z;if(this.opts.realpath){if(Z=$.realpathCached()||await $.realpath(),!Z)return;$=Z}let q=$.isUnknown()||this.opts.stat?await $.lstat():$;if(this.opts.follow&&this.opts.nodir&&q?.isSymbolicLink()){let Y=await q.realpath();if(Y&&(Y.isUnknown()||this.opts.stat))await Y.lstat()}return this.matchCheckTest(q,Q)}matchCheckTest($,Q){return $&&(this.maxDepth===1/0||$.depth()<=this.maxDepth)&&(!Q||$.canReaddir())&&(!this.opts.nodir||!$.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!$.isSymbolicLink()||!$.realpathCached()?.isDirectory())&&!this.#X($)?$:void 0}matchCheckSync($,Q){if(Q&&this.opts.nodir)return;let Z;if(this.opts.realpath){if(Z=$.realpathCached()||$.realpathSync(),!Z)return;$=Z}let q=$.isUnknown()||this.opts.stat?$.lstatSync():$;if(this.opts.follow&&this.opts.nodir&&q?.isSymbolicLink()){let Y=q.realpathSync();if(Y&&(Y?.isUnknown()||this.opts.stat))Y.lstatSync()}return this.matchCheckTest(q,Q)}matchFinish($,Q){if(this.#X($))return;if(!this.includeChildMatches&&this.#$?.add){let q=`${$.relativePosix()}/**`;this.#$.add(q)}let Z=this.opts.absolute===void 0?Q:this.opts.absolute;this.seen.add($);let X=this.opts.mark&&$.isDirectory()?this.#Z:"";if(this.opts.withFileTypes)this.matchEmit($);else if(Z){let q=this.opts.posix?$.fullpathPosix():$.fullpath();this.matchEmit(q+X)}else{let q=this.opts.posix?$.relativePosix():$.relative(),Y=this.opts.dotRelative&&!q.startsWith(".."+this.#Z)?"."+this.#Z:"";this.matchEmit(!q?"."+X:Y+q+X)}}async match($,Q,Z){let X=await this.matchCheck($,Z);if(X)this.matchFinish(X,Q)}matchSync($,Q,Z){let X=this.matchCheckSync($,Z);if(X)this.matchFinish(X,Q)}walkCB($,Q,Z){if(this.signal?.aborted)Z();this.walkCB2($,Q,new q8(this.opts),Z)}walkCB2($,Q,Z,X){if(this.#Y($))return X();if(this.signal?.aborted)X();if(this.paused){this.onResume(()=>this.walkCB2($,Q,Z,X));return}Z.processPatterns($,Q);let q=1,Y=()=>{if(--q===0)X()};for(let[W,J,H]of Z.matches.entries()){if(this.#X(W))continue;q++,this.match(W,J,H).then(()=>Y())}for(let W of Z.subwalkTargets()){if(this.maxDepth!==1/0&&W.depth()>=this.maxDepth)continue;q++;let J=W.readdirCached();if(W.calledReaddir())this.walkCB3(W,J,Z,Y);else W.readdirCB((H,V)=>this.walkCB3(W,V,Z,Y),!0)}Y()}walkCB3($,Q,Z,X){Z=Z.filterEntries($,Q);let q=1,Y=()=>{if(--q===0)X()};for(let[W,J,H]of Z.matches.entries()){if(this.#X(W))continue;q++,this.match(W,J,H).then(()=>Y())}for(let[W,J]of Z.subwalks.entries())q++,this.walkCB2(W,J,Z.child(),Y);Y()}walkCBSync($,Q,Z){if(this.signal?.aborted)Z();this.walkCB2Sync($,Q,new q8(this.opts),Z)}walkCB2Sync($,Q,Z,X){if(this.#Y($))return X();if(this.signal?.aborted)X();if(this.paused){this.onResume(()=>this.walkCB2Sync($,Q,Z,X));return}Z.processPatterns($,Q);let q=1,Y=()=>{if(--q===0)X()};for(let[W,J,H]of Z.matches.entries()){if(this.#X(W))continue;this.matchSync(W,J,H)}for(let W of Z.subwalkTargets()){if(this.maxDepth!==1/0&&W.depth()>=this.maxDepth)continue;q++;let J=W.readdirSync();this.walkCB3Sync(W,J,Z,Y)}Y()}walkCB3Sync($,Q,Z,X){Z=Z.filterEntries($,Q);let q=1,Y=()=>{if(--q===0)X()};for(let[W,J,H]of Z.matches.entries()){if(this.#X(W))continue;this.matchSync(W,J,H)}for(let[W,J]of Z.subwalks.entries())q++,this.walkCB2Sync(W,J,Z.child(),Y);Y()}}class P8 extends a${matches=new Set;constructor($,Q,Z){super($,Q,Z)}matchEmit($){this.matches.add($)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise(($,Q)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)Q(this.signal.reason);else $(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class N8 extends a${results;constructor($,Q,Z){super($,Q,Z);this.results=new P0({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit($){if(this.results.write($),!this.results.flowing)this.pause()}stream(){let $=this.path;if($.isUnknown())$.lstat().then(()=>{this.walkCB($,this.patterns,()=>this.results.end())});else this.walkCB($,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var HQ=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class G0{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor($,Q){if(!Q)throw TypeError("glob options required");if(this.withFileTypes=!!Q.withFileTypes,this.signal=Q.signal,this.follow=!!Q.follow,this.dot=!!Q.dot,this.dotRelative=!!Q.dotRelative,this.nodir=!!Q.nodir,this.mark=!!Q.mark,!Q.cwd)this.cwd="";else if(Q.cwd instanceof URL||Q.cwd.startsWith("file://"))Q.cwd=WQ(Q.cwd);if(this.cwd=Q.cwd||"",this.root=Q.root,this.magicalBraces=!!Q.magicalBraces,this.nobrace=!!Q.nobrace,this.noext=!!Q.noext,this.realpath=!!Q.realpath,this.absolute=Q.absolute,this.includeChildMatches=Q.includeChildMatches!==!1,this.noglobstar=!!Q.noglobstar,this.matchBase=!!Q.matchBase,this.maxDepth=typeof Q.maxDepth==="number"?Q.maxDepth:1/0,this.stat=!!Q.stat,this.ignore=Q.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error("cannot set absolute and withFileTypes:true");if(typeof $==="string")$=[$];if(this.windowsPathsNoEscape=!!Q.windowsPathsNoEscape||Q.allowWindowsEscape===!1,this.windowsPathsNoEscape)$=$.map((J)=>J.replace(/\\/g,"/"));if(this.matchBase){if(Q.noglobstar)throw TypeError("base matching requires globstar");$=$.map((J)=>J.includes("/")?J:`./**/${J}`)}if(this.pattern=$,this.platform=Q.platform||HQ,this.opts={...Q,platform:this.platform},Q.scurry){if(this.scurry=Q.scurry,Q.nocase!==void 0&&Q.nocase!==Q.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let J=Q.platform==="win32"?Q8:Q.platform==="darwin"?S8:Q.platform?Z8:$1;this.scurry=new J(this.cwd,{nocase:Q.nocase,fs:Q.fs})}this.nocase=this.scurry.nocase;let Z=this.platform==="darwin"||this.platform==="win32",X={...Q,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:Z,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},q=this.pattern.map((J)=>new $0(J,X)),[Y,W]=q.reduce((J,H)=>{return J[0].push(...H.set),J[1].push(...H.globParts),J},[[],[]]);this.patterns=Y.map((J,H)=>{let V=W[H];if(!V)throw Error("invalid pattern object");return new h0(J,V,0,this.platform)})}async walk(){return[...await new P8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new P8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new N8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new N8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var n$=($,Q={})=>{if(!Array.isArray($))$=[$];for(let Z of $)if(new $0(Z,Q).hasMagic())return!0;return!1};function D8($,Q={}){return new G0($,Q).streamSync()}function Y1($,Q={}){return new G0($,Q).stream()}function b8($,Q={}){return new G0($,Q).walkSync()}async function X1($,Q={}){return new G0($,Q).walk()}function k8($,Q={}){return new G0($,Q).iterateSync()}function J1($,Q={}){return new G0($,Q).iterate()}var VQ=D8,KQ=Object.assign(Y1,{sync:D8}),_Q=k8,GQ=Object.assign(J1,{sync:k8}),zQ=Object.assign(b8,{stream:D8,iterate:k8}),q1=Object.assign(X1,{glob:X1,globSync:b8,sync:zQ,globStream:Y1,stream:KQ,globStreamSync:D8,streamSync:VQ,globIterate:J1,iterate:GQ,globIterateSync:k8,iterateSync:_Q,Glob:G0,hasMagic:n$,escape:E0,unescape:Y0});q1.glob=q1;import UQ from"node:path";var W1=({dir:$,pattern:Q="*",nodir:Z=!1,dot:X=!0,ignore:q=[],absolute:Y=!1,matchBase:W=!1,follow:J=!1})=>{if($=$||process.cwd(),$=UQ.resolve($),Q&&!Array.isArray(Q))Q=[Q];else Q=Q||["*"];if(q&&!Array.isArray(q))q=[q];else q=q||[];return b8(Q,{cwd:$,nodir:Z,dot:X,ignore:q,absolute:Y,matchBase:W,follow:J})};import K1 from"@fnet/expression";import H1 from"lodash.clonedeep";import MQ from"@fnet/key-value-transformer";import OQ from"@fnet/expression";async function u({node:$,initNode:Q,extra:Z=!0}){if(Reflect.has($.definition,"modules")&&!Array.isArray($.definition.modules)){let X=$.definition.modules;$.definition.modules=[],Object.keys(X).forEach((q)=>{let Y={...X[q]};if(typeof Y.export==="boolean")Y.export=Y.export===!0?q:!1;else if(typeof Y.export==="string")Y.export=Y.export;else delete Y.export;$.definition.modules.push({[q]:Y})})}if(Z){let X=[],q=await MQ({data:$.definition,callback:(Y,W,J)=>{let H=OQ({expression:Y});if(H?.processor==="m"){let V=J.slice(0,-1);V.push(H.statement);let K=V.join("_");return X.push({[K]:W}),[H.statement,`m::${K}`]}return[Y,W]}});if(X.length>0)$.definition=q,$.definition.modules=$.definition.modules||[],$.definition.modules=$.definition.modules.concat(X)}$.hasModules=$.definition.modules?.length>0;for(let X=0;X<$.definition.modules?.length;X++){let q=$.definition.modules[X],Y=Object.keys(q)[0],W={name:Y,childs:[],parent:$,definition:q[Y],module:!0,blockAutoJumpToParent:!0,blockAutoJumpToSibling:!1,index:$.childs.length,context:{}};$.childs.push(W),await Q({node:W})}}async function w({node:$,transformExpression:Q}){let Z=$.context.transform;if(Reflect.has(Z,"export"))Z.export=await Q(Z.export);if(Reflect.has(Z,"return"))$.hasReturn=!0,Z.return=await Q(Z.return);if(Reflect.has(Z,"output"))Z.output=await Q(Z.output);if(Reflect.has(Z,"assign"))for(let X=0;X<Z.assign?.length;X++){let q=Z.assign[X],Y=Object.keys(q)[0],W=q[Y],J={key:await Q(Y),value:await Q(W)};Z.assign[X]=J}}async function AQ({node:$}){if(!$.definition.hasOwnProperty("switch"))return!1;return!0}async function BQ({node:$,initNode:Q}){$.type="switch";let Z=$.definition.switch||[];if(!Z.every((W)=>W.hasOwnProperty("condition")||W.hasOwnProperty("default")))throw Error("Switch must have condition or default");if(Z.filter((W)=>W.hasOwnProperty("condition")).length===0)throw Error("Switch must have at least one condition");let Y=Z.filter((W)=>W.hasOwnProperty("default"));if(Y.length>1)throw Error("Switch must have only one default");if(Y.length===1&&!Z[Z.length-1].hasOwnProperty("default"))throw Error("Switch default must be the last child");$.hasDefaultCondition=Y.length===1,await u({node:$,initNode:Q,extra:!1}),$.blockAutoJumpToParent=!1,$.blockAutoJumpToSibling=!0;for(let W=0;W<$.definition.switch.length;W++){let J=$.definition.switch[W],H=`${W}`;if(J.hasOwnProperty("default"))H="default",J=J.default;let V={name:J.condition||H,childs:[],parent:$,definition:J,index:$.childs.length,context:{}};$.childs.push(V),await Q({node:V})}$.resolve=V1}async function V1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||H1($.definition);let q=$.context.transform;for(let Y of $.childs)if(Y.context.transform=Y.context.transform||H1(Y.definition),Y.definition.hasOwnProperty("condition"))Y.context.transform.condition=await X(Y.definition.condition);await w({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var Y8={hits:AQ,init:BQ,resolve:V1};async function RQ({node:$}){if(Object.keys($.definition).map((q)=>K1({expression:q})).filter((q)=>q?.processor==="if").length===1)return!0;if($.definition.if&&typeof $.definition.if==="object")return!0;return!1}async function IQ($){let{node:Q}=$,X=Object.keys(Q.definition).map((H)=>K1({expression:H})),q=[],Y=X.find((H)=>H?.processor==="if");if(Y){let H=Q.definition[Y.expression];q.push({name:`${Q.name}_if`,definition:H,processor:Y}),delete Q.definition[Y.expression]}else if(Q.definition.if){let{condition:H,...V}=Q.definition.if;q.push({name:`${Q.name}_if`,definition:V,processor:{expression:`if::${H}`,statement:H}}),delete Q.definition.if}let W=X.filter((H)=>H?.processor==="elseif"),J=0;for(let H of W){let V=Q.definition[H.expression];q.push({name:`${Q.name}_elseif_${J++}`,definition:V,processor:H}),delete Q.definition[H.expression]}if(Q.definition.elseif){let{condition:H,...V}=Q.definition.elseif;q.push({name:`${Q.name}_elseif_${J++}`,definition:V,processor:{expression:`elseif::${H}`,statement:H}}),delete Q.definition.elseif}Q.definition.switch=[];for(let H of q)Q.definition.switch.push({condition:H.processor.statement,...H.definition});if(Q.definition?.else){let H=Q.definition.else;Q.definition.switch.push({default:H}),delete Q.definition.else}await Y8.init($)}var o$={hits:RQ,init:IQ};import _1 from"lodash.clonedeep";async function FQ({node:$}){return $.definition.hasOwnProperty("try")&&$.definition.hasOwnProperty("except")}async function CQ({node:$,initNode:Q}){if($.type="tryexcept",await u({node:$,initNode:Q,extra:!1}),$.blockAutoJumpToParent=!1,$.blockAutoJumpToSibling=!0,$.definition.try){let X={name:"try",childs:[],parent:$,definition:$.definition.try,index:$.childs.length,context:{}};$.childs.push(X),await Q({node:X})}if($.definition.except){let X={name:"except",childs:[],parent:$,definition:$.definition.except,index:$.childs.length,context:{}};$.childs.push(X),await Q({node:X})}$.resolve=G1}async function G1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||_1($.definition);let q=$.context.transform;if($.context.try=$.childs.find((Y)=>Y.name==="try"),$.context.except=$.childs.find((Y)=>Y.name==="except"),$.context.except){let Y=$.context.except;if(Y.context.transform=Y.context.transform||_1(Y.definition),!Y.context.transform.hasOwnProperty("as"))Y.context.transform.as="error"}await w({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var t$={hits:FQ,init:CQ,resolve:G1};import LQ from"lodash.clonedeep";async function jQ({node:$}){return $.definition.hasOwnProperty("assign")}async function TQ({node:$,initNode:Q}){$.type="assign",await u({node:$,initNode:Q}),$.resolve=z1}async function z1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||LQ($.definition);let q=$.context.transform;await w({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var e$={hits:jQ,init:TQ,resolve:z1};import wQ from"lodash.clonedeep";async function SQ({node:$}){return $.definition.hasOwnProperty("for")}async function PQ({node:$,initNode:Q}){if($.type="for",await u({node:$,initNode:Q,extra:!1}),$.blockAutoJumpToParent=!0,$.blockAutoJumpToSibling=!1,!$.definition.for.hasOwnProperty("steps")){let{value:Z,in:X,...q}=$.definition.for,Y={};if(Z!==void 0)Y.value=Z;if(X!==void 0)Y.in=X;$.definition.for=Y,$.definition.for.steps=[{[`${$.name}_step`]:q}]}if(!Array.isArray($.definition.for.steps))$.definition.for.steps=[{[`${$.name}_step`]:$.definition.for.steps}];for(let Z=0;Z<$.definition.for.steps.length;Z++){let X=$.definition.for.steps[Z],q=Object.keys(X)[0],Y={name:q,childs:[],parent:$,definition:X[q],index:$.childs.length,context:{}};$.childs.push(Y),await Q({node:Y})}$.resolve=U1}async function U1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||wQ($.definition);let q=$.context.transform;q.for.in=await X($.definition.for.in),await w({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var $6={hits:SQ,init:PQ,resolve:U1};import NQ from"lodash.clonedeep";async function DQ({node:$}){return $.definition.hasOwnProperty("parallel")}async function bQ({node:$,initNode:Q}){$.type="parallel",$.blockAutoJumpToParent=!0,$.blockAutoJumpToSibling=!0;let Z=$.definition.parallel||[];for await(let X of Z){let q=Object.keys(X)[0],Y={name:q,childs:[],parent:$,definition:X[q],index:$.childs.length,context:{}};$.childs.push(Y),await Q({node:Y})}$.resolve=M1}async function M1({node:$,transformExpression:Q,resolveNextBlock:Z}){$.context.transform=$.context.transform||NQ($.definition),await w({node:$,transformExpression:Q}),Z({node:$})}var Q6={hits:DQ,init:bQ,resolve:M1};import kQ from"lodash.clonedeep";async function vQ({node:$}){return $.definition.hasOwnProperty("raise")}async function EQ({node:$,initNode:Q}){$.type="raise",$.resolve=O1}async function O1({node:$,resolveTypeCommon:Q,transformExpression:Z}){$.context.transform=$.context.transform||kQ($.definition);let X=$.context.transform;X.raise=await Z(X.raise),await Q({node:$})}var Z6={hits:vQ,init:EQ,resolve:O1};import yQ from"lodash.clonedeep";async function xQ({node:$}){return $.definition.hasOwnProperty("return")}async function uQ({node:$,initNode:Q}){$.type="return",$.resolve=A1}async function A1({node:$,resolveTypeCommon:Q,transformExpression:Z}){$.context.transform=$.context.transform||yQ($.definition);let X=$.context.transform;$.hasReturn=!0,X.return=await Z(X.return),await Q({node:$})}var X6={hits:xQ,init:uQ,resolve:A1};import fQ from"lodash.clonedeep";async function hQ({node:$}){return $.definition.hasOwnProperty("call")}async function gQ({node:$,initNode:Q}){$.type="call",await u({node:$,initNode:Q}),$.resolve=B1}async function B1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||fQ($.definition);let q=$.context.transform,Y=q.from||q.import||q.call;if($.target?.atom?.doc?.type==="function"){if(Reflect.has(q,"from"))Y=q.from,q.from=await X($.target.atom.name);else if(Reflect.has(q,"import"))Y=q.import,q.import=await X($.target.atom.name);else if(Reflect.has(q,"call"))q.call=await X($.target.atom.name),Y=q.call}else if(Reflect.has(q,"from")||Reflect.has(q,"import")){if(q.call.startsWith("use:e::")){let J=q.call.substring(7);q.libExp=await X(`e::LIBRARY.${J}`)}}if(q.args)q.args=await X(q.args);if(q.new)q.new=await X(q.new);if(q.context)q.context=await X(q.context);if(q.result){if(typeof q.result==="string")q.result=[{[q.result]:"e::result"}];for(let J=0;J<q.result?.length;J++){let H=q.result[J],V=Object.keys(H)[0],K=H[V],G={key:await X(V),value:await X(K)};q.result[J]=G}}let W=$.workflow.parent;$.context.lib=W.context.libs.find((J)=>J.name===Y),await w({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var J8={hits:hQ,init:gQ,resolve:B1};import mQ from"lodash.clonedeep";async function cQ({node:$}){return $.definition.hasOwnProperty("steps")}async function lQ({node:$,initNode:Q}){if(!$.type)$.type="steps";let Z=$.definition.steps||[];for await(let X of Z){let q=Object.keys(X)[0],Y={name:q,childs:[],parent:$,definition:X[q],index:$.childs.length,context:{}};$.childs.push(Y),await Q({node:Y})}$.resolve=R1}async function R1({node:$,transformExpression:Q}){$.context.next=$.childs[0],$.context.transform=$.context.transform||mQ($.definition),await w({node:$,transformExpression:Q})}var q6={hits:cQ,init:lQ,resolve:R1};import dQ from"lodash.clonedeep";async function pQ({node:$}){return $.definition.hasOwnProperty("form")}async function iQ({node:$,initNode:Q}){$.type="form",await u({node:$,initNode:Q}),$.resolve=I1}async function I1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||dQ($.definition);let q=$.context.transform;if(q.props)q.props=await X(q.props);let Y=$.workflow.parent;$.context.lib=Y.context.libs.find((W)=>W.name===q.form),await w({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var Y6={hits:pQ,init:iQ,resolve:I1};import sQ from"lodash.clonedeep";async function rQ({node:$}){return $.definition.hasOwnProperty("signal")}async function aQ({node:$,initNode:Q}){$.type="signal",$.resolve=F1}async function F1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X,transformValue:q}){$.context.transform=$.context.transform||sQ($.definition),await Q({node:$}),Z({node:$})}var J6={hits:rQ,init:aQ,resolve:F1};import nQ from"lodash.clonedeep";async function oQ({node:$}){return $.definition.hasOwnProperty("wait")}async function tQ({node:$,initNode:Q}){$.type="wait",$.resolve=C1}async function C1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X,transformValue:q}){$.context.transform=$.context.transform||nQ($.definition),await Q({node:$}),Z({node:$})}var W6={hits:oQ,init:tQ,resolve:C1};import eQ from"lodash.clonedeep";async function $2({node:$}){return $.definition.hasOwnProperty("next")}async function Q2({node:$,initNode:Q}){$.type="next",$.resolve=L1}async function L1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||eQ($.definition);let q=$.context.transform;q.next=await X(q.next),await w({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var H6={hits:$2,init:Q2,resolve:L1};import Z2 from"lodash.clonedeep";async function X2({node:$}){return $.definition.hasOwnProperty("modules")}async function q2({node:$,initNode:Q}){$.type="modules",await u({node:$,initNode:Q}),$.resolve=j1}async function j1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||Z2($.definition);let q=$.context.transform;await w({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var V6={hits:X2,init:q2,resolve:j1};function K6({node:$}){let Q=$.definition;if($.hasReturn){if(F("tree"))k.info(" └─ RETURN (no next)",{depth:$.depth+1,node:$.indexKey});return}if(Q.next==="end"){if(F("tree"))k.info(" └─ EXPLICIT END",{depth:$.depth+1,node:$.indexKey})}else if(Q.next==="stop"){if(F("tree"))k.info(" └─ EXPLICIT STOP",{depth:$.depth+1,node:$.indexKey})}else if(Q.next==="none"){if(F("tree"))k.info(" └─ EXPLICIT NONE",{depth:$.depth+1,node:$.indexKey})}else if(Q.next){if(F("tree"))k.info(` \uD83D\uDD0D EXPLICIT NEXT: "${Q.next}" (searching...)`,{depth:$.depth+1,from:$.indexKey});let Z=$.parent;while(Z.parent){let X=Z.childs.find((q)=>q.name===Q.next);if(X){if($.context.next=X,F("tree"))k.info(` └─ ✅ FOUND: ${X.indexKey}`,{depth:$.depth+1,nextNode:X.indexKey});break}Z=Z.parent}if(!$.context.next&&F("tree"))k.warn(` └─ ⚠️ NOT FOUND: "${Q.next}"`,{depth:$.depth+1})}else{if($.module===!0){if(F("tree"))k.info(" └─ MODULE ROOT (no auto next)",{depth:$.depth+1,node:$.indexKey});return}if(F("tree"))k.info(" \uD83D\uDC1C AUTO NEXT (karınca yürüyüşü başlıyor...)",{depth:$.depth+1,from:$.indexKey});let Z=$.parent,X=$.index+1,q=0;while(Z.parent)if(q++,Z.blockAutoJumpToParent&&Z.blockAutoJumpToSibling){if(F("tree"))k.info(` ${q}. ⛔ Both jumps disabled at ${Z.indexKey}`,{depth:$.depth+2});break}else if(!Reflect.has(Z,"blockAutoJumpToParent")&&!Reflect.has(Z,"blockAutoJumpToSibling")){let Y=Z.childs.find((W)=>W.index===X);if(Y){if($.context.next=Y,F("tree"))k.info(` ${q}. ✅ SIBLING FOUND: ${Y.indexKey}`,{depth:$.depth+2,nextNode:Y.indexKey});break}else{if(F("tree"))k.info(` ${q}. ⬆️ No sibling, climbing to parent: ${Z.parent?.indexKey}`,{depth:$.depth+2,targetIndex:X});X=Z.index+1,Z=Z.parent;continue}}else if(Z.blockAutoJumpToParent){let Y=Z.childs.find((W)=>W.index===X);if(Y){if($.context.next=Y,F("tree"))k.info(` ${q}. ✅ SIBLING FOUND (parent jump disabled): ${Y.indexKey}`,{depth:$.depth+2,nextNode:Y.indexKey})}else if(F("tree"))k.info(` ${q}. ⛔ No sibling, parent jump disabled`,{depth:$.depth+2});break}else if(!Z.blockAutoJumpToParent){if(F("tree"))k.info(` ${q}. ⬆️ Sibling disabled, climbing to parent: ${Z.parent?.indexKey}`,{depth:$.depth+2});X=Z.index+1,Z=Z.parent;continue}if($.context.next&&F("tree"))k.info(` └─ \uD83C\uDFAF AUTO NEXT RESOLVED: ${$.context.next.indexKey}`,{depth:$.depth+1,steps:q,nextNode:$.context.next.indexKey});else if(F("tree"))k.info(" └─ ⚠️ NO NEXT FOUND (end of flow)",{depth:$.depth+1,steps:q})}}class T1{#Q;#$;#Z;#X;constructor({key:$,npm:Q,master:Z,extras:X}){this.#Q=$,this.#$=Q,this.#Z=Z,this.#X=X}hits({node:$}){return $.definition.hasOwnProperty(this.#Q)}async init($){let{node:Q}=$,Z=this.#Q,X=Q.definition,q=typeof X[Z];if(X.call=`npm:${this.#$}`,q!=="object")X.args={...X.args,[`${this.#Z}`]:X[Z]};else X.args=X[Z];if(delete X[Z],this.#X)for(let Y in this.#X)X[Y]=this.#X[Y];console.log(`[npm-block] ${this.#Q} --> ${this.#$}`),await J8.init($)}}function p($){return new T1($)}import Y2 from"lodash.clonedeep";async function J2({node:$}){return $.definition.hasOwnProperty("new")}async function W2({node:$,initNode:Q}){$.type="new",await u({node:$,initNode:Q}),$.resolve=w1}async function w1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||Y2($.definition);let q=$.context.transform,Y=q.from||q.import;if($.target?.atom?.doc?.type==="function"){if(Reflect.has(q,"from"))Y=q.from,q.from=await X($.target.atom.name);else if(Reflect.has(q,"import"))Y=q.import,q.import=await X($.target.atom.name)}if(q.args)q.args=await X(q.args);if(q.new)q.new=await X(q.new);if(q.result){if(typeof q.result==="string")q.result=[{[q.result]:"e::result"}];for(let J=0;J<q.result?.length;J++){let H=q.result[J],V=Object.keys(H)[0],K=H[V],G={key:await X(V),value:await X(K)};q.result[J]=G}}let W=$.workflow.parent;$.context.lib=W.context.libs.find((J)=>J.name===Y),await w({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var _6={hits:J2,init:W2,resolve:w1};import H2 from"lodash.clonedeep";async function V2({node:$}){return $.definition.hasOwnProperty("output")}async function K2({node:$,initNode:Q}){$.type="output",await u({node:$,initNode:Q}),$.resolve=S1}async function S1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||H2($.definition),await w({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var G6={hits:V2,init:K2,resolve:S1};import _2 from"lodash.clonedeep";async function G2({node:$}){return $.definition.hasOwnProperty("pipeline")}async function z2({node:$}){$.type="pipeline";let Q=$.definition.pipeline;if(!Q||typeof Q!=="string")throw Error(`Pipeline step '${$.indexKey}' requires a binary name`);if($.context.binaryName=Q,$.definition.input)$.context.input=$.definition.input;if($.definition.result)$.context.result=$.definition.result;if($.definition.args)$.context.args=$.definition.args;if($.context.format=$.definition.format||"json",$.definition.env)$.context.env=$.definition.env;if($.definition.cwd)$.context.cwd=$.definition.cwd;$.resolve=P1}async function P1({node:$,transformExpression:Q,resolveNextBlock:Z}){$.context.transform=$.context.transform||_2($.definition);let X=$.context.transform;if(X.input)X.input=await Q(X.input);if(X.args)X.args=await Q(X.args);if(X.env)X.env=await Q(X.env);if(X.cwd)X.cwd=await Q(X.cwd);await w({node:$,transformExpression:Q}),Z({node:$})}var z6={hits:G2,init:z2,resolve:P1};import U2 from"lodash.clonedeep";async function M2({node:$}){return $.definition.hasOwnProperty("retry")}async function O2({node:$,initNode:Q}){$.type="retry";let Z=$.definition.retry,X;if(typeof Z==="number")X={attempts:Z,delay:1000,backoff:"exponential",maxDelay:null};else if(typeof Z==="object")X={attempts:Z.attempts||3,delay:Z.delay||1000,backoff:Z.backoff||"exponential",maxDelay:Z.maxDelay||null,on:Z.on,onRetry:Z.onRetry};else throw Error(`Retry step '${$.name}' requires a number or object configuration`);if(!X.attempts||X.attempts<1)throw Error(`Retry step '${$.name}' requires attempts >= 1`);let q=["exponential","linear","fixed"];if(!q.includes(X.backoff))throw Error(`Retry step '${$.name}' has invalid backoff strategy '${X.backoff}'. Valid options: ${q.join(", ")}`);$.definition.retry=X;let{retry:Y,...W}=$.definition,J={name:`${$.name}_retryable`,childs:[],parent:$,definition:W,index:0,context:{}};$.childs.push(J),await Q({node:J}),$.resolve=N1}async function N1({node:$,transformExpression:Q,resolveNextBlock:Z}){$.context.transform=$.context.transform||U2($.definition);let X=$.context.transform;if(X.retry.attempts&&typeof X.retry.attempts==="string")X.retry.attempts=await Q(X.retry.attempts);if(X.retry.delay&&typeof X.retry.delay==="string")X.retry.delay=await Q(X.retry.delay);if(X.retry.maxDelay&&typeof X.retry.maxDelay==="string")X.retry.maxDelay=await Q(X.retry.maxDelay);if(X.retry.onRetry)X.retry.onRetry=await Q(X.retry.onRetry);await w({node:$,transformExpression:Q}),Z({node:$})}var U6={hits:M2,init:O2,resolve:N1};import A2 from"lodash.clonedeep";async function B2({node:$}){return $.definition.hasOwnProperty("schedule")}async function R2({node:$,initNode:Q}){$.type="schedule";let Z=$.definition.schedule,X;if(typeof Z==="string")X={cron:Z,timezone:null,enabled:!0};else if(typeof Z==="object")X={cron:Z.cron,timezone:Z.timezone||null,enabled:Z.enabled!==!1};else throw Error(`Schedule step '${$.name}' requires a cron expression string or object`);if(!X.cron||typeof X.cron!=="string")throw Error(`Schedule step '${$.name}' requires a valid cron expression`);$.definition.schedule=X;let{schedule:q,...Y}=$.definition,W={name:`${$.name}_scheduled`,childs:[],parent:$,definition:Y,index:0,context:{}};$.childs.push(W),await Q({node:W}),$.resolve=D1}async function D1({node:$,transformExpression:Q,resolveNextBlock:Z}){$.context.transform=$.context.transform||A2($.definition);let X=$.context.transform;if(X.schedule){if(X.schedule.cron&&typeof X.schedule.cron==="string")X.schedule.cron=await Q(X.schedule.cron);if(X.schedule.timezone&&typeof X.schedule.timezone==="string")X.schedule.timezone=await Q(X.schedule.timezone)}await w({node:$,transformExpression:Q}),Z({node:$})}var M6={hits:B2,init:R2,resolve:D1};import I2 from"lodash.clonedeep";async function F2({node:$}){return $.definition.hasOwnProperty("http")}async function C2({node:$,initNode:Q}){$.type="http",await u({node:$,initNode:Q});let Z=$.definition.http,X;if(typeof Z==="string")X={url:Z,method:"GET",headers:{},timeout:30000};else if(typeof Z==="object"){if(X={url:Z.url,method:Z.method||"GET",headers:Z.headers||{},body:Z.body,params:Z.params,timeout:Z.timeout||30000},!X.url)throw Error(`HTTP step '${$.name}' requires a url property`)}else throw Error(`HTTP step '${$.name}' requires a string URL or object configuration`);let q=["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"],Y=X.method.toUpperCase();if(!q.includes(Y))throw Error(`HTTP step '${$.name}' has invalid method '${X.method}'. Valid options: ${q.join(", ")}`);if(X.method=Y,X.timeout&&(typeof X.timeout!=="number"||X.timeout<=0))throw Error(`HTTP step '${$.name}' timeout must be a positive number`);$.definition.http=X,$.resolve=L2}async function L2({node:$,transformExpression:Q,resolveNextBlock:Z}){$.context.transform=$.context.transform||I2($.definition);let X=$.context.transform;if(X.http.url&&typeof X.http.url==="string")X.http.url=await Q(X.http.url);if(X.http.headers){for(let q in X.http.headers)if(typeof X.http.headers[q]==="string")X.http.headers[q]=await Q(X.http.headers[q])}if(X.http.body)X.http.body=await Q(X.http.body);if(X.http.params){for(let q in X.http.params)if(typeof X.http.params[q]==="string")X.http.params[q]=await Q(X.http.params[q])}if(X.http.timeout&&typeof X.http.timeout==="string")X.http.timeout=await Q(X.http.timeout);await w({node:$,transformExpression:Q}),Z({node:$})}var O6={hits:F2,init:C2};var b1=({path:$})=>{if(!$)throw Error("Path is required");let Q=/^@([^\/]+\/[^\/]+)(?:\/(.+))?$/,Z=/^([^\/]+)(?:\/(.+))?$/,X;if(X=$.match(Q))return{path:$,package:"@"+X[1],subpath:X[2]||null};else if(X=$.match(Z))return{path:$,package:X[1],subpath:X[2]||null};return null};class u1{#Q;#$;#Z;#X;#Y;#F;#I;#V;#G;#H;#_;#q;#O;#M;#U;#A;#j;#R;#L;#W;#C;#K=[];constructor($){this.#Q=new v6,this.#$=$,this.#F=[],this.#I=[],this.#V={},this._expire_ttl=3600,this._expire_ttl_short=300,this.#K.push(p({key:"config",npm:"@fnet/config",master:"name"})),this.#K.push(p({key:"yaml",npm:"@fnet/yaml",master:"file"})),this.#K.push(p({key:"prompt",npm:"@fnet/prompt",master:"message"})),this.#K.push(p({key:"html-link",npm:"@flownet/lib-load-browser-link-url",master:"src"})),this.#K.push(p({key:"html-script",npm:"@flownet/lib-load-browser-script-url",master:"src"})),this.#K.push(p({key:"http-server",npm:"@fnet/node-express",master:"server_port"})),this.#K.push(p({key:"shell",npm:"@fnet/shell-flow",master:"commands"})),this.#K.push(p({key:"list-files",npm:"@fnet/list-files",master:"pattern"})),this.#K.push(p({key:"up-list-files",npm:"@fnet/up-list-files",master:"pattern"})),this.#K.push(p({key:"auto-conda-env",npm:"@fnet/auto-conda-env",master:"envDir"})),this.#K.push(p({key:"ollama-chat",npm:"@fnet/ollama-chat",master:"model"})),this.#K.push(p({key:"ai",npm:"@fnet/ai",master:"prompt",extras:{subtype:"flow"}})),this.#K.push(p({key:"invoke",npm:"@fnet/invoke",master:"method",extras:{}})),this.#K.push(p({key:"fetch",npm:"@fnet/fetch",master:"url",extras:{}})),this.#K.push(p({key:"filemap",npm:"@fnet/filemap",master:"target",extras:{}})),this.#W={packageDependencies:this.#F,packageDevDependencies:this.#I,setProgress:this.setProgress.bind(this),context:this.#$,Atom:z0,registerToPackageManager:this.registerToPackageManager.bind(this)},this.#C={initNode:this.initNode.bind(this),cloneDeep:E1,resolveTypeCommon:this.resolveTypeCommon.bind(this),resolveNextBlock:K6,transformExpression:this.transformExpression.bind(this),transformValue:this.transformValue.bind(this)}}async _cache_set($,Q,Z){}async init(){this.#_=this.#$.buildId||y1(),this.#W.buildId=this.#_,this.#U=this.#$.mode,this.#A=["all","deploy","build","file"].includes(this.#U),this.#j=["all","deploy","build"].includes(this.#U),this.#R=["all","deploy"].includes(this.#U),this.#L=["all","deploy","build","file","bpmn"].includes(this.#U),this.#O=this.#$.protocol,this.#q="BUILD:"+this.#_,this.#M=(await w2({optional:!0,name:"atom",dir:this.#$.projectDir,tags:this.#$.tags}))?.data;try{await this.setProgress({message:"Initialization started."});let $=this.#W.context.project;await this.initAuth(),await this.initWorkflow(),this.transformWorkflow({workflow:this.#X});let Q=await this.initNodeTree({workflow:this.#X});if(await this.initNodeTreeIndex({root:Q}),await this.initNodeCalls({root:Q}),await this.initNodeCallLibs({root:Q}),await this.initNodeForms({root:Q}),await this.initNodeFormLibs({root:Q}),await this.initEntryFiles({root:Q,features:this.#Z.doc.features}),await this.initFeaturesFromNodes({childs:Q.childs,features:this.#Z.doc.features}),await J$(this.#W),$.runtime.type==="bun")await H$(this.#W);else await W$(this.#W);await this.initAtomLibsAndDeps({libs:Q.context.libs,packageDependencies:this.#F}),await this.resolveNodeTree({root:Q}),this.#H=Q}catch($){throw await this._cache_set(this.#q,{status:"FAILED",message:$?.message||$}),$}}async initAuth(){if(!this.#$.id)return;this.#G=await this.#Q.init({config:this.#M}),this.#W.atomAccessToken=this.#G}async initWorkflow(){let $=this.#$.id;this.#Z=this.#$.project?.workflowAtom||await z0.get({id:$}),this.#X=typeof this.#Z.doc.content==="string"?(await P2({content:this.#Z.doc.content,tags:this.#$.tags})).parsed:this.#Z.doc.content;let Q=this.#Z.doc.bundleName;Q=Q||(this.#Z.doc.name||"").toUpperCase().replace(/[^A-Z0-9]/g,"_"),this.#Z.doc.bundleName=Q,this.#Z.type=this.#Z.type||"workflow",this.#W.atom=this.#Z,this.#Z.doc.features=this.#Z.doc.features||{}}#T($){if(console.log("filePath",$),j.statSync($).isDirectory())j.readdirSync($).forEach((Q)=>{let Z=S.join($,Q);this.#T(Z)}),j.rmSync($);else j.unlinkSync($)}#B($,Q){let Z=j.existsSync($),X=Z&&j.statSync($);if(Z&&X.isDirectory())j.mkdirSync(Q,{recursive:!0}),j.readdirSync($).forEach((Y)=>{this.#B(S.join($,Y),S.join(Q,Y))});else j.copyFileSync($,Q)}async initWorkflowDir(){this.setProgress({message:"Initializing library directory."});let $=this.#$.projectDir,Q=this.#$.coreDir;this.setProgress({message:"Cleaning project directory."});let Z=W1({dir:$,ignore:[".cache","node_modules",".conda",".bin",".dev"],absolute:!0});for(let J of Z)j.rmSync(J,{recursive:!0,force:!0});if(this.setProgress({message:"Creating project directory."}),!j.existsSync($))j.mkdirSync($,{recursive:!0});let X=S.join($,"src");if(!j.existsSync(X))j.mkdirSync(X,{recursive:!0});let q=S.join(X,"core");this.#B(Q,q);let Y=S.join(X,"default","blocks");if(!j.existsSync(Y))j.mkdirSync(Y,{recursive:!0});let W=S.join($,".dev");if(!j.existsSync(W))j.mkdirSync(W,{recursive:!0})}async initNunjucks(){this.setProgress({message:"Initializing nunjucks."});let $=this.#$.templateDir;this.#Y=W8.configure($,{watch:!1,dev:!0}),this.#W.njEnv=this.#Y}transformWorkflow({workflow:$}){for(let Q of Object.values($))Q.steps=Q.steps||[],Q.steps=Q.steps.filter((Z)=>Object.keys(Z).length>0),Q.steps=Q.steps.map((Z)=>this.transformStep({step:Z}))}transformStep({step:$}){if(Array.isArray($))throw Error("Step must be an object.");let[Q,Z]=Object.entries($)[0];if(Z.hasOwnProperty("onerror")){let{onerror:X,...q}=Z;$[Q]={try:q,except:X}}if($[Q].hasOwnProperty("steps")){let X=$[Q].steps;if(!Array.isArray(X))throw Error("Steps must be an array.");$[Q].steps=X.map((q)=>this.transformStep({step:q}))}return $}async initNodeTree({workflow:$}){let Q=Object.keys($);if(F("tree"))k.info("\uD83C\uDF33 Creating root node",{depth:0});let Z={definition:$,name:void 0,type:"root",parent:void 0,childs:[],blockAutoJumpToParent:!0,blockAutoJumpToSibling:!0,index:0,depth:0,context:{libs:[],atom:this.#Z}};Q.forEach((X)=>{if(F("tree"))k.info(`\uD83D\uDCE6 Creating ${X==="main"?"workflow":"subworkflow"}: ${X}`,{depth:1,index:Z.childs.length,type:X==="main"?"workflow":"subworkflow"});let q={name:X,type:X==="main"?"workflow":"subworkflow",childs:[],parent:Z,definition:$[X],index:Z.childs.length,depth:Z.depth+1,context:{},blockAutoJumpToParent:!0,blockAutoJumpToSibling:!1};Z.childs.push(q)});for await(let X of Z.childs){if(F("tree"))k.info(`\uD83D\uDD27 Initializing node: ${X.name}`,{depth:X.depth});await this.initNode({node:X})}if(F("tree"))k.info("✅ Root node tree created",{depth:0,totalFlows:Z.childs.length});return Z}async initNode({node:$}){let Q={...this.#C,node:$};$.workflow=$.parent.workflow||$,$.depth=$.parent.depth+1;let Z="unknown";if(await t$.hits(Q))Z="tryexcept",await t$.init(Q);else if(await $6.hits(Q))Z="for",await $6.init(Q);else if(await Y8.hits(Q))Z="switch",await Y8.init(Q);else if(await o$.hits(Q))Z="if",await o$.init(Q);else if(await U6.hits(Q))Z="retry",await U6.init(Q);else if(await M6.hits(Q))Z="schedule",await M6.init(Q);else if(await Q6.hits(Q))Z="parallel",await Q6.init(Q);else if(await z6.hits(Q))Z="pipeline",await z6.init(Q);else if(await O6.hits(Q))Z="http",await O6.init(Q);else if(await J8.hits(Q))Z="call",await J8.init(Q);else if(await _6.hits(Q))Z="new",await _6.init(Q);else if(await Z6.hits(Q))Z="raise",await Z6.init(Q);else if(await Y6.hits(Q))Z="form",await Y6.init(Q);else if(await J6.hits(Q))Z="signal",await J6.init(Q);else if(await W6.hits(Q))Z="wait",await W6.init(Q);else if(await q6.hits(Q))Z="steps",await q6.init(Q);else if(await H6.hits(Q))Z="next",await H6.init(Q);else if(await V6.hits(Q))Z="modules",await V6.init(Q);else if(await X6.hits(Q))Z="return",await X6.init(Q);else if(this.#K.find((X)=>X.hits(Q)))Z="npm-block",await this.#K.find((X)=>X.hits(Q)).init(Q);else if(await e$.hits(Q))Z="assign",await e$.init(Q);else if(await G6.hits(Q))Z="output",await G6.init(Q);else throw Error("Undefined step type.");if(F("tree"))k.info(` ├─ ${Z}: ${$.name}`,{depth:$.depth,index:$.index,type:Z,hasChilds:$.childs?.length>0,childCount:$.childs?.length||0})}async initNodeTreeIndex({root:$}){let Q={};$.indexKey="/";for await(let Z of $.childs)await this.initNodeIndex({node:Z,index:Q});return $.context.index=Q,Q}async initNodeIndex({node:$,index:Q}){let Z=S.join($.parent.indexKey,$.name);$.indexKey=Z,Q[Z]=$;let X=[],q=$;while(q?.parent)X.push(q.index),q=q.parent;X.reverse(),$.codeKey=`B_${X.join("_")}_${$.type}`,$.pathKey=`${X.join(".")}`,$.typeId=y1();for await(let Y of $.childs)await this.initNodeIndex({node:Y,index:Q})}async initNodeCalls({root:$}){let Q=$.context.index,Z=[];for await(let X of Object.keys(Q)){let q=Q[X];if(q.type!=="call"&&q.type!=="new")continue;Z.push(q)}return $.context.calls=Z,Z}async initNodeCallLibs({root:$}){let Q=[],Z=$.context.calls;for await(let X of Z){let q=X.definition.from||X.definition.import||X.definition.call,Y=await this.findNodeCallTarget({refNode:X,curNode:X.parent})||{name:q,type:"atom",definition:X.definition},W=Q.find((J)=>J.name===Y.name&&J.type===Y.type);if(!W)Q.push(Y);X.target=W||Y}return $.context.callLibs=Q,$.context.libs=[...$.context.libs,...Q],Q}async findNodeCallTarget({refNode:$,curNode:Q}){if(!Q)return;let Z=$.definition.call,X=Q.childs.find((q)=>q.name===Z&&q.type==="subworkflow");if(X)return X;else return await this.findNodeCallTarget({refNode:$,curNode:Q.parent})}async initNodeForms({root:$}){let Q=$.context.index,Z=[];for await(let X of Object.keys(Q)){let q=Q[X];if(q.type!=="form")continue;Z.push(q)}return $.context.forms=Z,Z}async initNodeFormLibs({root:$}){let Q=[],Z=$.context.forms;for await(let X of Z){let q=X.definition.from||X.definition.import||X.definition.form,Y=await this.findNodeCallTarget({refNode:X,curNode:X.parent})||{name:q,type:"atom"},W=Q.find((J)=>J.name===Y.name&&J.type===Y.type);if(!W)Q.push(Y);X.target=W||Y}return $.context.formLibs=Q,$.context.libs=[...$.context.libs,...Q],Q}async initFeaturesFromNodes({childs:$,features:Q}){for await(let Z of $){if(Z.type==="form"&&!Reflect.has(Q,"form"))Q.form=!0;await this.initFeaturesFromNodes({childs:Z.childs,features:Q})}}async initEntryFiles({root:$,features:Q}){for await(let Z of $.childs){let X;if(Z.name==="main")X="index.js";else if(Z.name==="cli")X="cli.js";else if(Z.name==="app")X="app.js";else if(Z.name==="api")X="api.js";else continue;Q[`${Z.name}_default_entry_file`]=X,Z.entryFile=X}}async findNodeFormTarget({refNode:$,curNode:Q}){if(!Q)return;let Z=$.definition.form,X=Q.childs.find((q)=>q.name===Z&&q.type==="subworkflow");if(X)return X;else return await this.findNodeFormTarget({refNode:$,curNode:Q.parent})}async initAtomLibsAndDeps({libs:$,packageDependencies:Q}){let Z=$.filter((X)=>X.type==="atom");for(let X=0;X<Z.length;X++){let q=Z[X],Y=await this.findAtomLibrary({url:q.name,libRef:q});q.atom=Y,Y.doc.dependencies?.filter((J)=>typeof J.repo>"u"||J.repo==="npm")?.forEach((J)=>{let H=Q.find((V)=>V.package===J.package);if(H){if(typeof J.path==="string"){if(!(H.path||[]).some((V)=>V===J.path))H.path=H.path||[],H.path.push(J.path)}else if(Array.isArray(J.path))J.path.forEach((V)=>{if(!(H.path||[]).some((K)=>K===V))H.path=H.path||[],H.path.push(V)})}else Q.push(J)})}Q.sort((X,q)=>X.package?.localeCompare(q.package))}async findAtomLibrary({url:$,libRef:Q}){let Z=T2({url:$});if(!Z)throw Error(`Invalid package name: ${$}`);if(!Z.protocol)Z.protocol=this.#O;if(Z.protocol==="src:"){let X=S.resolve(this.#$.projectSrcDir,`${Z.pathname}.js`),q=[],W=(await S2({file:X,recursive:!0})).all;for await(let H of W){if(H.type!=="npm")continue;if(q.find((K)=>K.package===H.package))continue;let V=await v0({name:H.package,projectDir:this.#$.projectDir,setProgress:this.#W.setProgress});q.push({package:H.package,subpath:H.subpath,version:V.minorRange,type:"npm"})}return{name:Z.pathname,doc:{type:"workflow.lib","content-type":"javascript",language:"js",dependencies:q},protocol:Z.protocol}}else if(Z.protocol==="npm:"){let X=b1({path:Z.pathname}),q=await v0({name:X.package,subpath:X.subpath,projectDir:this.#$.projectDir,setProgress:this.#W.setProgress});return{name:Z.pathname,doc:{type:"workflow.lib",subtype:Q?.definition?.subtype==="flow"?"workflow":null,"content-type":"javascript",language:"js",dependencies:[{package:X.package,version:q.minorRange,type:"npm"}]},protocol:Z.protocol}}else if(Z.protocol==="use:")return{name:Z.pathname,doc:{type:"function",dependencies:[]},protocol:Z.protocol};else if(Z.protocol==="node:")return{name:Z.pathname,doc:{type:"workflow.lib","content-type":"javascript",language:"js",dependencies:[]},protocol:Z.protocol};else if(Z.protocol==="ac:"){let X=Z.pathname.split("/");if(X.length===1)return await z0.first({where:{name:$,parent_id:this.#M.env.ATOM_LIBRARIES_ID,type:"workflow.lib"}});if(X.length===2){let q=await z0.first({where:{name:X[0],parent_id:this.#M.env.ATOM_LIBRARIES_ID,type:"folder"}});return await z0.first({where:{name:X[1],parent_id:q.id,type:"workflow.lib"}})}}}async resolveNodeTree({root:$}){for await(let Q of $.childs)await this.resolveTypeWorkflow({node:Q})}async resolveTypeWorkflow({node:$}){$.context.transform=$.context.transform||E1($.definition);let Q=$.context.transform;for(let Z=0;Z<Q.params?.length;Z++){let X=Q.params[Z];if(typeof X==="string")Q.params[Z]={key:X,hasDefault:!1};else{let q=Object.keys(X)[0];Q.params[Z]={key:q,hasDefault:!0,default:X[q],type:typeof X[q]}}}$.context.next=$.childs[0];for await(let Z of $.childs)await this.resolveType({node:Z})}async resolveType({node:$}){let Q={...this.#C,node:$};if(typeof $.resolve==="function")await $.resolve(Q);for await(let Z of $.childs)await this.resolveType({node:Z})}async resolveTypeCommon({node:$}){let Q=$.context.transform;if(Q.hasOwnProperty("page"))Q.page=await this.transformExpression(Q.page);if(Q.hasOwnProperty("print"))Q.print=await this.transformExpression(Q.print);if(Q.hasOwnProperty("sleep"))Q.sleep=await this.transformExpression(Q.sleep);if(Q.hasOwnProperty("assert"))Q.assert=await this.transformExpression(Q.assert)}async createAtomLibFiles({root:$}){await this.setProgress({message:"Creating external lib files."}),this.#Z.typesDir="./types";let Z=$.context.libs.filter((X)=>X.type==="atom");for(let X=0;X<Z.length;X++){let Y=Z[X].atom,W=this.#$.projectDir;if(Y.protocol==="src:"){let J=S.resolve(this.#$.projectSrcDir,`${Y.fileName||Y.name}.js`),H=S.relative(`${this.#$.projectDir}/src/default/blocks`,J);if(!j.existsSync(J)){j.mkdirSync(S.dirname(J),{recursive:!0});let V=`export default async (input)=>{
7
- `;V+="}",j.writeFileSync(J,V,"utf8")}Y.relativePath=H.split(S.sep).join("/"),this.#Z.typesDir=`./types/${S.basename(W)}/src`}else if(Y.protocol==="npm:")Y.relativePath=Y.name;else if(Y.protocol==="node:")Y.relativePath=Y.name;else if(Y.protocol==="use:");else{let J=`${W}/src/libs/${Y.id}.js`,H=Y.doc.contents?.find((V)=>V.format==="esm")||Y.doc;j.writeFileSync(S.normalize(J),H.content,"utf8")}}}async createEngine({root:$}){await this.setProgress({message:"Creating engine file."});let Q=this.#$.templateDir,Z=W8.compile(j.readFileSync(S.resolve(Q,"src/default/engine.js.njk"),"utf8"),this.#Y);for(let X=0;X<$.childs.length;X++){let q=$.childs[X];if(!q.entryFile)continue;let Y=Z.render({flow:q,ui:{package:"@fnet/react-app"}}),W=this.#$.projectDir,J=S.resolve(W,`src/default/${q.entryFile}`);j.writeFileSync(J,Y,"utf8")}}async createNodeTree({root:$}){await this.setProgress({message:"Creating block files."});for await(let Q of $.childs)await this.createTypeWorkflow({node:Q})}async createTypeWorkflow({node:$}){let Q=this.#$.templateDir,X=W8.compile(j.readFileSync(S.resolve(Q,"src/default/workflow.js.njk"),"utf8"),this.#Y).render($),q=this.#$.projectDir,Y=S.resolve(q,`src/default/${$.codeKey}.js`);j.writeFileSync(Y,X,"utf8");for await(let W of $.childs)await this.createType({node:W})}async createType({node:$}){switch($.type){case"assign":case"steps":case"return":case"call":case"new":case"form":case"raise":case"switch":case"next":case"tryexcept":case"for":case"parallel":case"signal":case"wait":case"modules":case"output":case"pipeline":case"retry":case"schedule":case"http":this.createBlockFromTemplate({node:$});break;default:break}for await(let Q of $.childs)await this.createType({node:Q})}createBlockFromTemplate({node:$}){let Q=this.getBlockTemplate({node:$});$.context.render=Q.render($),this.createStepFile({node:$})}getBlockTemplate({node:$}){let Q=this.#V[$.type];if(Q)return Q;let Z=this.#$.templateDir;return Q=W8.compile(j.readFileSync(S.resolve(Z,`src/default/blocks/${$.type}.js.njk`),"utf8"),this.#Y),this.#V[$.type]=Q,Q}createStepFile({node:$}){let Q=this.#$.projectDir,Z=`${$.codeKey}.js`,X=S.resolve(Q,`src/default/blocks/${Z}`);j.writeFileSync(X,$.context.render,"utf8"),$.context.fileName=Z,$.context.filePath=X}async transformExpression($){let Q=await this.transformValue($);return Q=JSON.stringify(Q),Q=this.replaceSpecialPattern(Q),Q}async transformValue($){if(Array.isArray($))for(let Q=0;Q<$.length;Q++)$[Q]=await this.transformValue($[Q]);else if(j2($)){let Q=Object.keys($);for(let Z=0;Z<Q.length;Z++){let X=Q[Z],q=x1({expression:X});if(q)if(q.processor==="e"){let Y=$[X].replace(/(\r\n|\n|\r)/g,"");$[q.statement]=`$::${Y}::`,delete $[X]}else $[X]=await this.transformValue($[X]);else $[X]=await this.transformValue($[X])}}else if(typeof $==="string"){let Q=x1({expression:$});if(Q){let{processor:Z,statement:X}=Q;switch(Z){case"v":$=`$::v.${X}::`;break;case"e":$=`$::${X}::`;break;case"m":$=`$::c.module?.${X}||flow.module?.${X}::`;break;case"f":$=`$::c.form.${X}::`;break;case"for":$=`$::caller.for.${X}::`;break}}}return $}replaceSpecialPattern($){let Q=/"\$::(.*?)::"/g;return $.replace(Q,"$1")}replaceExpressionLegacy($){let Q=/(?<outer>"\${(?<inner>[^{]*)}")/g;return $.replaceAll(Q,"$2")}async createProjectYaml(){await this.setProgress({message:"Creating fnet.yaml"});let{content:Z,...X}=this.#Z.doc,q=this.#$.projectDir,Y=S.resolve(q,"fnet.yaml");j.writeFileSync(Y,k1.stringify(X),"utf8")}async createProjectMainYaml(){await this.setProgress({message:"Creating flow.main.yaml"});let Z={content:k1.stringify(this.#X)},X=this.#$.templateDir,Y=W8.compile(j.readFileSync(S.resolve(X,"flow.main.yaml.njk"),"utf8"),this.#Y).render(Z),W=this.#$.projectDir,J=S.resolve(W,"flow.main.yaml");j.writeFileSync(J,Y,"utf8")}async runPrettifier(){let $=this.#$.projectDir;if(V0("bun")){let Q=await v1("prettier --write .",{cwd:S.resolve($,"src")});if(Q.code!==0)throw Error(Q.stderr)}else{let Q=await v1("prettier --write .",{cwd:S.resolve($,"src")});if(Q.code!==0)throw Error(Q.stderr)}}async deploy(){if(await this.setProgress({message:"Deploying."}),this.#$.project?.devops){let $=[this.#$.project?.devops];for(let Q=0;Q<$.length;Q++){let Z=$[Q];if(await this.deployProject({deploymentProject:Z}),Z.isDirty===!0)await Z.save()}}else if(this.#Z.id){let $=await z0.list({type:"workflow.deploy",parent_id:this.#Z.id});for(let Q=0;Q<$.length;Q++){let Z=$[Q];if(await this.deployProject({deploymentProject:Z}),Z.isDirty===!0)Z=await z0.update(Z,{id:Z.id})}}}async deployProject($){let{deploymentProject:Q}=$,{yamlDocument:Z}=Q;if(Q.doc.targets&&Array.isArray(Q.doc.targets))throw Error("Deployment project targets are deprecated. Please update targets in the yaml file.");let X=Object.keys(Q.doc||{}),q=Z||{};for(let Y=0;Y<X.length;Y++){let W=Q.doc[X[Y]];W.name=X[Y];let J=q.get(X[Y]);await $5({...this.#W,deploymentProject:Q,deploymentProjectTarget:W,yamlTarget:J})}}async registerToPackageManager($){let{target:Q,packageJSON:Z}=$;if(!this.#$.id)return;let X=await z0.first({name:Q.params.name,parent_id:this.#M.env.ATOM_PACKAGES_ID});if(!X)X=await z0.create({parent_id:this.#M.env.ATOM_PACKAGES_ID,doc:{name:Q.params.name,type:"pm",versions:[{v:Z.version}]}});else X.doc.versions.splice(0,0,{v:Z.version}),await z0.update(X,{id:X.id})}async setProgress($){let Q=typeof $==="string"?$:$?.message;console.log(N2.blue(Q)),await this._cache_set(this.#q,{status:"IN_PROGRESS",message:Q})}async build(){if(this.#L&&!this.#A)return await this.createNetwork();try{let $=this.#L?await U8({root:this.#H}):void 0;if(this.#A){let Q=this.#W.context.project;if(await this.initWorkflowDir(),await this.initNunjucks(),this.#L){let Z=this.#$.project?.projectDir||this.#$.projectDir;if(Z=S.resolve(Z,"fnet"),j.existsSync(Z)){if(j.existsSync(S.resolve(Z,"flow.bpmn")))j.unlinkSync(S.resolve(Z,"flow.bpmn"));if(j.writeFileSync(S.resolve(Z,"flows.bpmn"),$.diagramXML,"utf8"),((this.#Z.doc.features||{}).bpmn||{}).per_flow===!0){let W=S.resolve(Z,"bpmn");if(!j.existsSync(W))j.mkdirSync(W,{recursive:!0});let J=await q5({root:this.#H});for(let H of J){let V=`${H.flowName}.bpmn`,K=S.resolve(W,V);j.writeFileSync(K,H.diagramXML,"utf8")}}}}if(await this.createAtomLibFiles({root:this.#H}),await this.createEngine({root:this.#H}),await this.createNodeTree({root:this.#H}),await this.createProjectYaml(),await C$(this.#W),await F$(this.#W),await I$(this.#W),await R$(this.#W),await _$(this.#W),await V$(this.#W),Q.runtime.type==="bun")await O$(this.#W);else await U$(this.#W);if(await K$(this.#W),await L$(this.#W),await j$(this.#W),this.#j){if(await T$(this.#W),await w$(this.#W),this.#R)await this.deploy()}}await this._cache_set(this.#q,{status:"COMPLETED",data:{network:$}})}catch($){throw await this._cache_set(this.#q,{status:"FAILED",message:$.message||$}),$}}async createNetwork(){try{let $=await U8({root:this.#H});await this._cache_set(this.#q,{status:"COMPLETED",data:{...$}})}catch($){throw await this._cache_set(this.#q,{status:"FAILED",message:$.message||$}),$}}}var L0=u1;var D2={command:"build",describe:"Build flownet project",builder:($)=>{return $.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("mode",{type:"string",default:"build",choices:["all","file","build","deploy","bpmn"],describe:"Build mode"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).option("dev",{type:"boolean",default:!1,describe:"Development mode"})},handler:async($)=>{try{let Q=await P($),Z=new L0(Q);await Z.init(),await Z.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Q){console.error("Building workflow failed!",Q.message),process.exit(1)}}},f1=D2;var b2={command:"build:dev",describe:"Build flownet project",builder:($)=>{return $.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("mode",{type:"string",default:"build",choices:["all","file","build","deploy","bpmn"],describe:"Build mode"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).option("dev",{type:"boolean",default:!1,describe:"Development mode"})},handler:async($)=>{try{$.dev=!0;let Q=await P($),Z=new L0(Q);await Z.init(),await Z.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Q){console.error("Building workflow failed!",Q.message),process.exit(1)}}},h1=b2;var k2={command:"deploy",describe:"Build and deploy flownet project",builder:($)=>{return $.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"})},handler:async($)=>{try{let Q=await P({...$,mode:"all"}),Z=new L0(Q);await Z.init(),await Z.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Q){console.error("Building workflow failed!",Q.message),process.exit(1)}}},g1=k2;var v2={command:"file",describe:"Just create files",builder:($)=>{return $.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"})},handler:async($)=>{try{let Q=await P({...$,mode:"file"}),Z=new L0(Q);await Z.init(),await Z.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Q){console.error("Building workflow failed!",Q.message),process.exit(1)}}},m1=v2;import c1 from"node:path";import v8 from"node:fs";import E2 from"@fnet/prompt";var y2={command:"input [name]",describe:"Create or modify an input config file",builder:($)=>{return $.positional("name",{type:"string",demandOption:!1,describe:"Input name"})},handler:async($)=>{try{let Q=await P($),{project:Z}=Q,{projectDir:X,projectFileParsed:q}=Z,Y=q.input;if(!Y)throw Error("Config schema not found in project file.");if(!Reflect.has($,"name")){let{inputName:G}=await E2({type:"input",name:"inputName",message:"Input name:",initial:"dev"});$.name=G}let W=c1.resolve(X,".fnet");if(!v8.existsSync(W))v8.mkdirSync(W);let J=c1.resolve(W,`${$.name}.fnet`),H=v8.existsSync(J),V=(await import("@fnet/object-from-schema")).default,K=await V({schema:Y,format:"yaml",ref:H?J:void 0});v8.writeFileSync(J,K)}catch(Q){console.error(Q.message),process.exit(1)}}},l1=y2;import T from"node:path";import L from"node:fs";import y8 from"node:os";import{spawn as x8}from"node:child_process";import I from"chalk";import B0 from"@fnet/prompt";import E8 from"chalk";import d1 from"@fnet/prompt";async function x2($){let{items:Q,message:Z,nameField:X="name",valueField:q="name",initialValue:Y=null,allowAbort:W=!0}=$;if(!Q||Q.length===0)return console.log(E8.yellow("No items available for selection.")),null;if(Q.length===1&&!W){let G=Q[0],_=typeof G==="string"?G:G[q];return console.log(E8.blue(`Only one option available: ${typeof G==="string"?G:G[X]}`)),_}let J=Q.map((G)=>{if(typeof G==="string")return{name:G,value:G,message:G};else return{name:G[q],value:G[q],message:G[X]||G[q]}});if(W)J.push({name:"cancel",value:null,message:E8.yellow("Cancel")});let H=null;if(Y){let G=J.findIndex((_)=>_.name===Y);if(G!==-1)H=G}let V="selectedItem",{[V]:K}=await d1({type:"select",name:V,message:Z,choices:J,initial:H});if(K==="cancel")return null;return K}async function u2($){let{items:Q,message:Z,nameField:X="name",valueField:q="name",initialValues:Y=[],allowAbort:W=!0}=$;if(!Q||Q.length===0)return console.log(E8.yellow("No items available for selection.")),null;let J=Q.map((G)=>{if(typeof G==="string")return{name:G,value:G,message:G};else return{name:G[q],value:G[q],message:G[X]||G[q]}}),H=[];if(Y&&Y.length>0)H=J.map((G,_)=>Y.includes(G.name)?_:-1).filter((G)=>G!==-1);let V="selectedItems",K=await d1({type:"multiselect",name:V,message:Z,choices:J,initial:H,hint:"(Use space to select, enter to confirm)",validate:(G)=>{if(G.length===0&&!W)return"Please select at least one item";return!0}});if(W&&K[V].length===0)return null;return K[V]}var A6={promptForSelection:x2,promptForMultipleSelection:u2};var h=T.join(y8.homedir(),".fnet","express");async function i1($){$.command(["$0 [project-name]","create [project-name]"],"Create a new express project",(Q)=>{return Q.positional("project-name",{describe:"Name of the project",type:"string"}).option("yes",{alias:"y",describe:"Skip all prompts and use defaults",type:"boolean",default:!1}).option("runtime",{describe:"Runtime to use (node)",type:"string",choices:["node"],default:"node"})},async(Q)=>{await f2(Q)}).command("list","List express projects",(Q)=>{return Q.option("today",{describe:"Show only projects created today",type:"boolean",default:!1}).option("type",{describe:"Filter by project type (fnode or fnet)",type:"string",choices:["fnode","fnet"]}).option("all",{describe:"Show all projects regardless of type",type:"boolean",default:!1,alias:"a"}).option("name",{describe:"Filter by project name",type:"string"})},async(Q)=>{await h2(Q)}).command("open [project-name]","Open an express project",(Q)=>{return Q.positional("project-name",{describe:"Name of the project to open",type:"string"}).option("latest",{describe:"Open the most recent project",type:"boolean",default:!1})},async(Q)=>{await g2(Q)}).command("move [project-name] [destination]","Move an express project to a real project location",(Q)=>{return Q.positional("project-name",{describe:"Name of the project to move",type:"string"}).positional("destination",{describe:"Destination directory",type:"string"}).option("latest",{describe:"Move the most recent project",type:"boolean",default:!1})},async(Q)=>{await m2(Q)}).command("remove [project-name]","Remove an express project",(Q)=>{return Q.positional("project-name",{describe:"Name of the project to remove",type:"string"}).option("latest",{describe:"Remove the most recent project",type:"boolean",default:!1}).option("yes",{alias:"y",describe:"Skip confirmation prompt",type:"boolean",default:!1})},async(Q)=>{await l2(Q)}).command("enter [project-name]","Enter the directory of an express project in the active terminal",(Q)=>{return Q.positional("project-name",{describe:"Name of the project to enter",type:"string"}).option("latest",{describe:"Enter the most recent project directory",type:"boolean",default:!1})},async(Q)=>{await d2(Q)}).demandCommand(1,"You need to specify a command").help()}async function f2($){try{if(!L.existsSync(h))L.mkdirSync(h,{recursive:!0});let Q=new Date().toISOString().slice(0,10).replace(/-/g,""),Z=T.join(h,Q);if(!L.existsSync(Z))L.mkdirSync(Z,{recursive:!0});let X=$.projectName,q,Y=$.runtime;if(!$.yes){if(!X){let _=L.readdirSync(Z).filter((z)=>z.startsWith("fnet-")).map((z)=>parseInt(z.replace("fnet-",""),10)).filter((z)=>!isNaN(z)),U=`fnet-${_.length>0?Math.max(..._)+1:1}`;X=(await B0([{type:"input",name:"projectName",message:"Enter project name:",default:U}])).projectName}Y=(await B0({type:"select",name:"runtime",message:"Select runtime:",choices:["node"],initial:Y||"node"})).runtime}else{if(!X){let K=L.readdirSync(Z).filter((_)=>_.startsWith("fnet-")).map((_)=>parseInt(_.replace("fnet-",""),10)).filter((_)=>!isNaN(_));X=`fnet-${K.length>0?Math.max(...K)+1:1}`}if(!Y)Y="node"}if(q=T.join(Z,X),L.existsSync(q)){let K=1;while(L.existsSync(T.join(Z,`${X}-${K}`)))K++;X=`${X}-${K}`,q=T.join(Z,X)}if(!$.yes){if(!(await B0([{type:"confirm",name:"proceed",message:`Create express project "${X}" in ${q}?`,default:!0}])).proceed){console.log(I.yellow("Project creation cancelled."));return}}console.log(I.blue(`Creating express project "${X}" in ${q}...`));let W=T.dirname(q),H=["create","--name",T.basename(q)];if(H.push("--runtime",Y),$.yes)H.push("--yes");if(!L.existsSync(W))L.mkdirSync(W,{recursive:!0});let V=x8("fnet",H,{stdio:"inherit",shell:!0,cwd:W});return new Promise((K,G)=>{V.on("close",(_)=>{if(_===0)if(console.log(I.green(`
8
- Express project "${X}" created successfully!`)),console.log(I.blue(`
9
- Project location: ${q}`)),!$.yes)c2(q);else K();else console.error(I.red(`
10
- Failed to create express project "${X}".`)),G(Error(`Process exited with code ${_}`))})})}catch(Q){console.error(I.red(`Error creating express project: ${Q.message}`)),process.exit(1)}}async function h2($){try{if(!L.existsSync(h)){console.log(I.yellow("No express projects found."));return}let Q=L.readdirSync(h).filter((W)=>/^\d{8}$/.test(W)).sort((W,J)=>J.localeCompare(W));if($.today){let W=new Date().toISOString().slice(0,10).replace(/-/g,""),J=Q.indexOf(W);if(J===-1){console.log(I.yellow("No express projects found for today."));return}Q.splice(0,J),Q.splice(1)}let Z=[];if(!$.type&&!$.all)$.type="fnet";for(let W of Q){let J=T.join(h,W),H=L.readdirSync(J);for(let V of H){let K=T.join(J,V),G=L.statSync(K),_="unknown";if(V.startsWith("fnode-")||L.existsSync(T.join(K,"fnode.yaml")))_="fnode";else if(V.startsWith("fnet-")||L.existsSync(T.join(K,"fnet.yaml")))_="fnet";if($.type&&_!==$.type)continue;if($.name&&!V.includes($.name))continue;let O=`${W.slice(0,4)}-${W.slice(4,6)}-${W.slice(6,8)}`;Z.push({name:V,type:_,date:O,path:K,created:G.birthtime})}}if(Z.sort((W,J)=>J.created-W.created),Z.length===0){console.log(I.yellow("No express projects found matching the criteria."));return}console.log(I.blue(`
11
- Express Projects:`));let X=(await import("./index.4g9yezkq.js")).default,q=["NAME","TYPE","DATE","PATH"],Y=X.createTable(q,{chars:{mid:"","mid-mid":"","left-mid":"","right-mid":""}});for(let W of Z){let J=W.path;if(J.startsWith(y8.homedir()))J="~"+J.substring(y8.homedir().length);Y.push([I.white(W.name),W.type==="fnet"?I.cyan(W.type):W.type==="fnode"?I.green(W.type):W.type,W.date,J])}console.log(Y.toString()),console.log(I.blue(`
12
- Total: ${Z.length} projects`))}catch(Q){console.error(I.red(`Error listing express projects: ${Q.message}`)),process.exit(1)}}async function g2($){try{if(!L.existsSync(h)){console.log(I.yellow("No express projects found."));return}let Q;if($.latest){if(Q=await u8(),!Q){console.log(I.yellow("No express projects found."));return}}else if($.projectName){if(Q=await f8($.projectName),!Q){console.log(I.yellow(`Project "${$.projectName}" not found.`));return}}else{let Z=await h8();if(!Z){console.log(I.yellow("No project selected."));return}Q=T.join(h,Z)}await B6(Q)}catch(Q){console.error(I.red(`Error opening express project: ${Q.message}`)),process.exit(1)}}async function m2($){try{let Q=process.cwd(),Z=Q.includes(h),X;if(Z)X=Q,console.log(I.blue(`Using current express project: ${T.basename(X)}`));else if($.latest){if(X=await u8(),!X){console.log(I.yellow("No express projects found."));return}}else if($.projectName){if(X=await f8($.projectName),!X){console.log(I.yellow(`Project "${$.projectName}" not found.`));return}}else{let W=await h8();if(!W){console.log(I.yellow("No project selected."));return}X=T.join(h,W)}let q=$.destination;if(!q)q=(await B0({type:"input",name:"destination",message:"Enter destination directory:",initial:T.join(process.cwd(),T.basename(X))})).destination;if(q.startsWith("~"))q=T.join(y8.homedir(),q.slice(1));if(q=T.resolve(q),q.startsWith(X+T.sep)||q===X){console.log(I.red("Destination cannot be inside the source directory."));return}if(L.existsSync(q)){if(!L.statSync(q).isDirectory()){console.log(I.red(`Destination "${q}" is not a directory.`));return}if(L.readdirSync(q).length>0){if(!(await B0({type:"confirm",name:"overwrite",message:`Destination "${q}" is not empty. Continue anyway?`,initial:!1})).overwrite){console.log(I.yellow("Project move cancelled."));return}}}else L.mkdirSync(q,{recursive:!0});if(console.log(I.blue(`Moving project from ${X} to ${q}...`)),s1(X,q),console.log(I.green(`
13
- Project moved successfully to ${q}`)),(await B0({type:"confirm",name:"deleteOriginal",message:"Delete the original express project?",initial:!1})).deleteOriginal)L.rmSync(X,{recursive:!0,force:!0}),console.log(I.green("Original project deleted."));await B6(q)}catch(Q){console.error(I.red(`Error moving express project: ${Q.message}`)),process.exit(1)}}async function u8(){let $=L.readdirSync(h).filter((W)=>/^\d{8}$/.test(W)).sort((W,J)=>J.localeCompare(W));if($.length===0)return null;let Q=$[0],Z=T.join(h,Q),X=L.readdirSync(Z);if(X.length===0)return null;let q=null,Y=0;for(let W of X){let J=T.join(Z,W),H=L.statSync(J);if(H.birthtimeMs>Y)Y=H.birthtimeMs,q=J}return q}async function f8($){let Q=L.readdirSync(h).filter((Z)=>/^\d{8}$/.test(Z)).sort((Z,X)=>X.localeCompare(Z));for(let Z of Q){let X=T.join(h,Z),q=L.readdirSync(X);if(q.includes($))return T.join(X,$);let Y=q.filter((W)=>W.includes($));if(Y.length>0)if(Y.length===1)return T.join(X,Y[0]);else{let W=Y.map((H)=>({name:T.join(X,H),value:T.join(X,H),message:`${H} (${Z})`})),J=await A6.promptForSelection({items:W,message:`Multiple projects match "${$}". Please select one:`,nameField:"message",valueField:"value",allowAbort:!0});if(J===null)return console.log(I.yellow("Operation cancelled.")),null;return J}}return null}async function h8(){let $=[],Q=L.readdirSync(h).filter((X)=>/^\d{8}$/.test(X)).sort((X,q)=>q.localeCompare(X));for(let X of Q){let q=T.join(h,X),Y=L.readdirSync(q);for(let W of Y){let J=T.join(q,W),H=L.statSync(J),V=`${X}/${W}`;$.push({name:V,value:V,created:H.birthtime})}}if($.sort((X,q)=>q.created-X.created),$.length===0)return null;let Z=await A6.promptForSelection({items:$,message:"Select a project:",nameField:"value",valueField:"value",allowAbort:!0});if(Z===null)return console.log(I.yellow("Operation cancelled.")),null;return Z}async function c2($){try{if((await B0({type:"confirm",name:"openIDE",message:"Would you like to open the project in an IDE?",initial:!0})).openIDE)await B6($)}catch(Q){console.error(I.red(`Error opening IDE: ${Q.message}`))}}async function B6($){let Q=await p1("code --version"),Z=await p1("code-insiders --version"),X=null;if(Q&&Z)X=(await B0({type:"select",name:"ide",message:"Which IDE would you like to use?",choices:[{name:"Visual Studio Code",value:"code"},{name:"Visual Studio Code Insiders",value:"code-insiders"}]})).ide;else if(Q)X="code";else if(Z)X="code-insiders";else{console.log(I.yellow("No supported IDE found. Please open the project manually.")),console.log(I.blue(`Project path: ${$}`));return}console.log(I.blue(`Opening project in ${X}...`)),console.log(I.blue(`Project path: ${$}`));let q=x8(X,[$],{stdio:"inherit",shell:!0});return new Promise((Y,W)=>{q.on("close",(J)=>{if(J===0)console.log(I.green(`Project opened in ${X}.`)),Y();else console.error(I.red(`Failed to open project in ${X}.`)),W(Error(`Process exited with code ${J}`))})})}async function p1($){return new Promise((Q)=>{x8($,{shell:!0,stdio:"ignore"}).on("close",(X)=>{Q(X===0)})})}function s1($,Q){if(!L.existsSync(Q))L.mkdirSync(Q,{recursive:!0});let Z=L.readdirSync($,{withFileTypes:!0});for(let X of Z){let q=T.join($,X.name),Y=T.join(Q,X.name);if(X.isDirectory()){if(X.name===".git"||X.name===".workspace")continue;s1(q,Y)}else L.copyFileSync(q,Y)}}async function l2($){try{if(!L.existsSync(h)){console.log(I.yellow("No express projects found."));return}let Q;if($.latest){if(Q=await u8(),!Q){console.log(I.yellow("No express projects found."));return}}else if($.projectName){if(Q=await f8($.projectName),!Q){console.log(I.yellow(`Project "${$.projectName}" not found.`));return}}else{let X=await h8();if(!X){console.log(I.yellow("No project selected."));return}Q=T.join(h,X)}let Z=T.basename(Q);if(!$.yes){if(!(await B0({type:"confirm",name:"confirm",message:`Are you sure you want to remove project "${Z}"?`,initial:!1})).confirm){console.log(I.yellow("Project removal cancelled."));return}}console.log(I.blue(`Removing project "${Z}"...`)),L.rmSync(Q,{recursive:!0,force:!0}),console.log(I.green(`Project "${Z}" removed successfully.`))}catch(Q){console.error(I.red(`Error removing express project: ${Q.message}`)),process.exit(1)}}async function d2($){try{if(!L.existsSync(h)){console.log(I.yellow("No express projects found."));return}let Q;if($.latest){if(Q=await u8(),!Q){console.log(I.yellow("No express projects found."));return}}else if($.projectName){if(Q=await f8($.projectName),!Q){console.log(I.yellow(`Project "${$.projectName}" not found.`));return}}else{let q=await h8();if(!q){console.log(I.yellow("No project selected."));return}Q=T.join(h,q)}console.log(I.blue(`Entering project directory: ${Q}`)),console.log(I.yellow(`
14
- Opening a new shell in the project directory...`));let Z=process.env.SHELL||"/bin/bash",X=x8(Z,[],{stdio:"inherit",cwd:Q,shell:!0});return new Promise((q)=>{X.on("close",()=>{console.log(I.green(`
15
- Returned from project directory.`)),q()})})}catch(Q){console.error(I.red(`Error entering express project directory: ${Q.message}`)),process.exit(1)}}import a1 from"node:path";import{fileURLToPath as a2}from"node:url";import p2 from"node:fs";import g8 from"node:path";import{fileURLToPath as i2}from"node:url";var s2=g8.dirname(i2(import.meta.url));function r2({baseDir:$}){$=$||s2;let Q=$;while(Q!==g8.parse(Q).root){let Z=g8.join(Q,"node_modules");if(p2.existsSync(Z))return Z;Q=g8.dirname(Q)}return null}var r1=r2;var n2=a1.dirname(a2(import.meta.url));function n1(){let $=r1({baseDir:n2}),Q=process.platform==="win32"?";":":";if($)process.env.PATH=`${a1.join($,"/.bin")}${Q}${process.env.PATH}`}I6();n1();async function t2(){try{let $=o2(process.argv.slice(2)).usage("Usage: $0 <command> [options]").command(w6).command(S6).command(f1).command(h1).command(g1).command(m1).command(l1).command("express","Create and manage express projects",i1);$=i($,{bin:"npm",createContext:P}),$=i($,{bin:"node",createContext:P}),$=i($,{bin:"bun",createContext:P}),$=i($,{name:"serve",bin:"bun",preArgs:["run","serve","--"],createContext:P}),$=i($,{name:"watch",bin:"bun",preArgs:["run","watch","--"],createContext:P}),$=i($,{name:"app",bin:"bun",preArgs:["run","app","--"],createContext:P}),$=i($,{name:"cli",bin:"bun",preArgs:["run","cli","--"],createContext:P}),$=i($,{name:"cli:dev",bin:"bun",preArgs:["run","cli:dev","--"],createContext:P}),$=i($,{name:"cli:compile",bin:"bun",preArgs:["run","cli:compile","--"],createContext:P}),$=i($,{name:"cli:compile:dev",bin:"bun",preArgs:["run","cli:compile:dev","--"],createContext:P}),$=i($,{name:"cli:install",bin:"bun",preArgs:["run","cli:install","--"],createContext:P}),$=i($,{name:"compile",bin:"bun",preArgs:["run","compile","--"],createContext:P}),$=j6($,{name:"install",createContext:P}),$=i($,{bin:"npx",createContext:P}),$=i($,{bin:"cdk",createContext:P}),$=i($,{bin:"aws",createContext:P}),$=C6($,{name:"with",createContext:P}),$=L6($,{name:"run",projectType:"fnet"}),$.demandCommand(1,"You need at least one command before moving on").help().version().argv}catch($){console.error(o1.red(`Fatal error: ${$.message}`)),process.exit(1)}}t2().catch(($)=>{console.error(o1.red(`Fatal error: ${$.message}`)),process.exit(1)});
2
+ import{a as I0,b as M0}from"./index.2084z2ed.js";import{c as h,d as P9,e as g}from"./index.r19p3bpa.js";var v9=P9((vq,k9)=>{k9.exports=b9;function b9(Q,Z,X){if(Q instanceof RegExp)Q=N9(Q,X);if(Z instanceof RegExp)Z=N9(Z,X);var q=D9(Q,Z,X);return q&&{start:q[0],end:q[1],pre:X.slice(0,q[0]),body:X.slice(q[0]+Q.length,q[1]),post:X.slice(q[1]+Z.length)}}function N9(Q,Z){var X=Z.match(Q);return X?X[0]:null}b9.range=D9;function D9(Q,Z,X){var q,Y,J,H,W,V=X.indexOf(Q),K=X.indexOf(Z,V+1),_=V;if(V>=0&&K>0){if(Q===Z)return[V,K];q=[],J=X.length;while(_>=0&&!W){if(_==V)q.push(_),V=X.indexOf(Q,_+1);else if(q.length==1)W=[q.pop(),K];else{if(Y=q.pop(),Y<J)J=Y,H=K;K=X.indexOf(Z,_+1)}_=V<K&&V>=0?V:K}if(q.length)W=[J,H]}return W}});var m9=P9((yq,g9)=>{var y9=v9();g9.exports=I5;var E9="\x00SLASH"+Math.random()+"\x00",x9="\x00OPEN"+Math.random()+"\x00",i6="\x00CLOSE"+Math.random()+"\x00",u9="\x00COMMA"+Math.random()+"\x00",f9="\x00PERIOD"+Math.random()+"\x00";function p6(Q){return parseInt(Q,10)==Q?parseInt(Q,10):Q.charCodeAt(0)}function B5(Q){return Q.split("\\\\").join(E9).split("\\{").join(x9).split("\\}").join(i6).split("\\,").join(u9).split("\\.").join(f9)}function R5(Q){return Q.split(E9).join("\\").split(x9).join("{").split(i6).join("}").split(u9).join(",").split(f9).join(".")}function h9(Q){if(!Q)return[""];var Z=[],X=y9("{","}",Q);if(!X)return Q.split(",");var{pre:q,body:Y,post:J}=X,H=q.split(",");H[H.length-1]+="{"+Y+"}";var W=h9(J);if(J.length)H[H.length-1]+=W.shift(),H.push.apply(H,W);return Z.push.apply(Z,H),Z}function I5(Q){if(!Q)return[];if(Q.substr(0,2)==="{}")Q="\\{\\}"+Q.substr(2);return o0(B5(Q),!0).map(R5)}function C5(Q){return"{"+Q+"}"}function L5(Q){return/^-?0\d/.test(Q)}function F5(Q,Z){return Q<=Z}function j5(Q,Z){return Q>=Z}function o0(Q,Z){var X=[],q=y9("{","}",Q);if(!q)return[Q];var Y=q.pre,J=q.post.length?o0(q.post,!1):[""];if(/\$$/.test(q.pre))for(var H=0;H<J.length;H++){var W=Y+"{"+q.body+"}"+J[H];X.push(W)}else{var V=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(q.body),K=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(q.body),_=V||K,G=q.body.indexOf(",")>=0;if(!_&&!G){if(q.post.match(/,.*\}/))return Q=q.pre+"{"+q.body+i6+q.post,o0(Q);return[Q]}var z;if(_)z=q.body.split(/\.\./);else if(z=h9(q.body),z.length===1){if(z=o0(z[0],!1).map(C5),z.length===1)return J.map(function(k7){return q.pre+z[0]+k7})}var O;if(_){var $=p6(z[0]),A=p6(z[1]),U=Math.max(z[0].length,z[1].length),B=z.length==3?Math.abs(p6(z[2])):1,M=F5,R=A<$;if(R)B*=-1,M=j5;var F=z.some(L5);O=[];for(var w=$;M(w,A);w+=B){var y;if(K){if(y=String.fromCharCode(w),y==="\\")y=""}else if(y=String(w),F){var v=U-y.length;if(v>0){var Y0=Array(v+1).join("0");if(w<0)y="-"+Y0+y.slice(1);else y=Y0+y}}O.push(y)}}else{O=[];for(var J0=0;J0<z.length;J0++)O.push.apply(O,o0(z[J0],!1))}for(var J0=0;J0<O.length;J0++)for(var H=0;H<J.length;H++){var W=Y+O[J0]+J[H];if(!Z||_||W)X.push(W)}}return X}});import S1 from"yargs";import BZ from"chalk";import{promisify as PZ}from"node:util";import bZ from"tree-kill";var f7=PZ(bZ),k0=!1;async function e8(Q,Z){if(k0)return;if(k0=!0,!Q.killed&&Q.pid)try{if(await f7(Q.pid,"SIGTERM").catch(()=>{}),await new Promise((q)=>setTimeout(q,500)),!Q.killed)await f7(Q.pid,"SIGKILL").catch(()=>{})}catch(q){}await new Promise((q)=>setTimeout(q,100));let X=Z==="SIGINT"?130:Z==="SIGTERM"?143:1;process.exit(X)}function Q6(Q){["SIGINT","SIGTERM","SIGQUIT"].forEach((Z)=>{process.once(Z,async()=>{await e8(Q,Z)})}),process.on("uncaughtException",async(Z)=>{await e8(Q)}),process.on("unhandledRejection",async(Z)=>{await e8(Q)}),Q.on("close",(Z)=>{if(!k0)process.exit(Z)})}function h7(){process.on("uncaughtException",(Q)=>{if(!k0)k0=!0,setTimeout(()=>process.exit(1),500)}),process.on("unhandledRejection",(Q)=>{if(!k0)k0=!0,setTimeout(()=>process.exit(1),500)})}import s0 from"node:path";import{spawn as g7}from"node:child_process";import B8 from"node:fs";import n0 from"chalk";import DZ from"@fnet/config";function o(Q,{name:Z,bin:X,preArgs:q=[],createContext:Y}){if(typeof X==="function")X=X();return Q.command(`${Z||X} [commands..]`,`${X} ${q.join(" ")}`,(J)=>{return J.help(!1).version(!1)},async(J)=>{try{let H=await Y(J),{projectDir:W}=H,V=($)=>{if(!$.includes(" "))return $;if(process.platform==="win32")return`"${$.replace(/(["^])/g,"^$1")}"`;else return`"${$.replace(/(["\\$`])/g,"\\$1")}"`},K=process.argv.slice(3).map(V),_={...process.env},G=s0.join(W,"node_modules");_.NODE_PATH=G;let z=_.NODE_OPTIONS||"";_.NODE_OPTIONS=`${z} --preserve-symlinks`.trim();let O=g7(X,[...q,...K],{cwd:W,stdio:"inherit",shell:!0,detached:!0,env:_});Q6(O)}catch(H){console.error(H.message),process.exit(1)}})}function m7(Q,{name:Z,preArgs:X=[],createContext:q}){return Q.command(`${Z} <config> <command> [options..]`,"Run a command with a config context",(Y)=>{return Y.positional("config",{type:"string"}).positional("command",{type:"string"}).help(!1).version(!1)},async(Y)=>{try{let J=await q(Y),{projectDir:H}=J,W=Y.config,K=(await DZ({name:W,dir:H,transferEnv:!1,optional:!0,tags:J.tags}))?.data?.env||void 0,_=Y.command,G=process.argv.slice(5),z=g7(_,[...X,...G],{cwd:B8.existsSync(H)?H:process.cwd(),stdio:"inherit",shell:!0,detached:!0,env:{...process.env,...K}});Q6(z)}catch(J){console.error(J.message),process.exit(1)}})}function c7(Q,{name:Z,projectType:X="auto"}){return Q.command(`${Z} group [options..]`,"Run a command group.",(q)=>{return q.positional("group",{type:"string"}).option("ftag",{type:"array"}).help(!1).version(!1)},async(q)=>{try{let{runCommandGroup:Y}=await import("./index.0jcm9pn5.js");await Y({projectType:X,group:q.group,tags:q.ftag,args:q,argv:process.argv})}catch(Y){console.error(Y.message),process.exit(1)}})}function l7(Q,{name:Z,createContext:X}){return Q.command(`${Z} [options]`,"Install the project as a binary",(q)=>{return q.option("name",{alias:"n",describe:"Name to use for the installed binary",type:"string"}).option("force",{alias:"f",describe:"Force overwrite if binary already exists",type:"boolean",default:!1}).option("yes",{alias:"y",describe:"Automatically answer yes to all prompts",type:"boolean",default:!1})},async(q)=>{try{let Y=await X(q),{projectDir:J}=Y;console.log(n0.blue("Compiling project..."));let H=s0.join(J,".bin");if(!B8.existsSync(H))B8.mkdirSync(H,{recursive:!0});let W=s0.basename(s0.dirname(J)),V=Y.project?.projectFileParsed?.features?.cli?.bin,K=q.name||V||W;console.log(n0.blue(`Using binary name: ${K}`));let _=s0.join(H,K),{spawn:G}=await import("child_process"),z=G("bun",["build","./dist/cli/esm/index.js","--compile",`--outfile=${_}`],{cwd:J,stdio:"inherit",shell:!0});if(await new Promise((A,U)=>{z.on("close",(B)=>{if(B===0)A();else U(Error(`Compilation failed with code ${B}`))}),z.on("error",(B)=>{U(B)})}),process.platform!=="win32")B8.chmodSync(_,493);console.log(n0.green(`Binary compiled successfully: ${_}`)),console.log(n0.blue("Installing binary..."));let O=["install",_];if(q.name)O.push("--name",q.name);if(q.force)O.push("--force");if(q.yes)O.push("--yes");let $=G("fbin",O,{stdio:"inherit",shell:!0});await new Promise((A,U)=>{$.on("close",(B)=>{if(B===0)A();else U(Error(`Installation failed with code ${B}`))}),$.on("error",(B)=>{U(B)})})}catch(Y){console.error(n0.red(`Failed to install binary: ${Y.message}`)),process.exit(1)}})}import $0 from"node:path";import v0 from"node:fs";import Z6 from"@fnet/yaml";import kZ from"yaml";async function k(Q){if(Q.id)return{id:Q.id,buildId:Q.buildId,mode:Q.mode,protocol:Q.protocol||"ac:",templateDir:I0("./template/fnet/node"),coreDir:I0("./template/fnet/core"),projectDir:$0.resolve(process.cwd(),`./.output/${Q.id}`),tags:Q.ftag,dev:Q.dev};else try{let Z=await vZ({tags:Q.ftag});return{buildId:Q.buildId,mode:Q.mode,protocol:Q.protocol||"src:",templateDir:I0("./template/fnet/node"),coreDir:I0("./template/fnet/core"),projectDir:$0.resolve(Z.projectDir,"./.workspace"),projectSrcDir:$0.resolve(Z.projectDir,"./src"),project:Z,tags:Q.ftag,dev:Q.dev}}catch(Z){return console.warn(`Warning: Could not load project: ${Z.message}`),{projectDir:process.cwd(),tags:Q.ftag}}}async function vZ({tags:Q}){let Z=yZ(process.cwd());if(!v0.existsSync(Z))throw Error("fnet.yaml file not found in current directory.");let{raw:X,parsed:q}=await Z6({file:Z,tags:Q}),Y=$0.dirname(Z);q.features=q.features||{};let J=q.features;J.runtime=J.runtime||{},J.runtime.type=J.runtime.type||"node";let H;if(typeof q.flows==="object")H=q.flows;else{let G="flow.main.yaml";if(v0.existsSync($0.join(Y,"fnet","flows.yaml")))G=$0.join("fnet","flows.yaml");let z=q.main||G,O=$0.resolve(Y,z);if(!v0.existsSync(O))H={main:{steps:[]}};else{let{parsed:$}=await Z6({file:O,tags:Q});H=$}}let V={workflowAtom:{doc:{...q,content:H}},projectDir:Y,projectFilePath:Z,projectFileContent:X,projectFileParsed:q,runtime:J.runtime},K=$0.resolve(Y,"fnet/targets.yaml");if(v0.existsSync(K)){let{raw:G,parsed:z}=await Z6({file:K,tags:Q}),O=kZ.parseDocument(G);V.devops={filePath:K,fileContent:G,yamlDocument:O,doc:{...z},type:"workflow.deploy",save:async()=>{v0.writeFileSync(V.devops.filePath,O.toString())}}}let _=$0.resolve(Y,"readme.md");if(v0.existsSync(_)){let G=v0.readFileSync(_,"utf8");V.readme={filePath:_,fileContent:G,doc:{content:G,"content-type":"markdown"},type:"wiki"}}return V}function yZ(Q){return $0.resolve(Q,"fnet.yaml")}import EZ from"node:path";import d7 from"node:fs";import xZ from"node:os";import uZ from"@flownet/lib-render-templates-dir";import X6 from"@fnet/shelljs";var fZ={command:"create",describe:"Initialize a new fnet project",builder:(Q)=>{return Q.option("name",{type:"string",describe:"Project name"}).option("vscode",{type:"boolean",default:!0,alias:"vs",describe:"Open in VS Code after creation"}).option("runtime",{type:"string",default:"node",choices:["node"],describe:"Runtime environment"})},handler:async(Q)=>{try{let Z=process.cwd(),X=I0("./template/fnet/project"),q=EZ.resolve(Z,Q.name);if(!d7.existsSync(q))d7.mkdirSync(q);await uZ({dir:X,outDir:q,context:Q,copyUnmatchedAlso:!0,platform:xZ.platform()});let Y=await X6("fnet build",{cwd:q});if(Y.code!==0)throw Error("Failed to build project.");if(M0("git")){if(Y=await X6("git init --initial-branch=main",{cwd:q}),Y.code!==0)throw Error("Failed to initialize git.")}if(M0("code")&&Q.vscode){if(Y=await X6(`cd ${q} && code .`),Y.code!==0)throw Error("Failed to open vscode.")}console.log("Creating project succeeded!"),process.exit(0)}catch(Z){console.error("Initialization failed!",Z.message),process.exit(1)}}},p7=fZ;import hZ from"node:os";import gZ from"@flownet/lib-render-templates-dir";import mZ from"@fnet/shelljs";var cZ={command:"project",describe:"Manage fnet project",builder:(Q)=>{return Q.option("update",{type:"boolean",default:!1,alias:"-u",describe:"Update project files"})},handler:async(Q)=>{try{let Z=I0("./template/fnet/project"),X=process.cwd(),q=await k(Q);if(Q.update){if(await gZ({dir:Z,outDir:X,context:{name:q.project.projectFileParsed.name,runtime:"node"},copyUnmatchedAlso:!0,platform:hZ.platform()}),(await mZ("fnet build",{cwd:X})).code!==0)throw Error("Failed to build project.");console.log("Updating project succeeded!")}process.exit(0)}catch(Z){console.error("Project failed.",Z.message),process.exit(1)}}},i7=cZ;import N from"node:fs";import D from"node:path";import QZ from"yaml";import ZZ from"@fnet/shelljs";import O8 from"nunjucks";import XZ from"lodash.clonedeep";import Q1 from"isobject";import{randomUUID as qZ}from"node:crypto";import q6 from"winston";var{combine:a7,timestamp:r7,printf:lZ,colorize:dZ}=q6.format,n7=lZ(({level:Q,message:Z,timestamp:X,category:q,depth:Y,...J})=>{let H=" ".repeat(Y||0),W=q?`[${q}]`:"",V=`${X} ${Q} ${W} ${H}${Z}`;if(Object.keys(J).length>0)V+=`
3
+ ${H} ${JSON.stringify(J,null,2)}`;return V}),R8=q6.createLogger({level:process.env.FNET_LOG_LEVEL||"info",format:a7(r7({format:"HH:mm:ss.SSS"}),n7),transports:[new q6.transports.Console({format:a7(dZ(),r7({format:"HH:mm:ss.SSS"}),n7)})]}),o7=(Q)=>{return{debug:(Z,X={})=>R8.debug(Z,{category:Q,...X}),info:(Z,X={})=>R8.info(Z,{category:Q,...X}),warn:(Z,X={})=>R8.warn(Z,{category:Q,...X}),error:(Z,X={})=>R8.error(Z,{category:Q,...X})}},f=o7("tree"),x=o7("bpmn"),s7=process.env.FNET_LOG_CATEGORIES?.split(",")||[],j=(Q)=>{if(s7.length===0)return!1;return s7.includes(Q)};import{Api as I8}from"@flownet/lib-atom-api-js";class t7{init({config:Q,accessToken:Z}){return new Promise((X,q)=>{if(I8.set_api_url(Q.data.url),Z){I8.set_req_token(Z),X(Z);return}fetch(`${Q.data.issuer}/protocol/openid-connect/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(Q.data.grant.params)}).then(async(Y)=>{if(!Y.ok)throw Error(await Y.text());return Y.json()}).then((Y)=>{I8.set_req_token(Y.access_token),X(Y.access_token)}).catch((Y)=>{I8.set_req_token(),q(Y)})})}}import f0 from"lodash.merge";import C8 from"node:fs";import _0 from"node:path";import h0 from"@flownet/lib-parse-imports-js";import pZ from"lodash.merge";function E({feature:Q,features:Z,packageDevDependencies:X}){let{name:q,packages:Y,options:J,extraCheck:H,explicit:W}=Q,V=`${q}_enabled`,K=Z.rollup_output||{},_=Object.keys(K),G=J||{},z=Z[q]?.options;if(z)G=pZ(G,z);let O=!Z[q]||Z[q]?.enabled===!1;_.forEach((A)=>{let U=Z.rollup_output[A];if(!U)return;if(Reflect.has(U,q)){if(O||!U[q]||U[q]?.enabled===!1){delete U[q];return}if(U[q]===!0)U[q]={enabled:!0,options:G}}else if(!O&&!W&&Z[V]!==!1)U[q]={enabled:!0};else return;U[q]=U[q]||{},U[q].options={...G,...U[q].options}});let $=_.some((A)=>Z.rollup_output[A][q]?.enabled===!0);if(H)$=H()&&$;if(Z[V]=$,$)Y.forEach((A)=>X.push({package:A[0],version:A[1]}))}function Y6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"workbox",packages:[["rollup-plugin-workbox","^8"]],options:{generate:{swDest:"dist/app/esm/sw.js",globDirectory:"dist/app/esm",globPatterns:["**/*.{html,js,css,png,jpg}"],skipWaiting:!0,clientsClaim:!0}},explicit:!0},features:q,packageDevDependencies:X})}function J6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"gzip",packages:[["rollup-plugin-gzip","^4"]],explicit:!0},features:q,packageDevDependencies:X})}function W6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"nunjucks",packages:[["@fnet/rollup-plugin-nunjucks","0.1.8"]]},features:q,packageDevDependencies:X})}function H6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"polyfill",packages:[["rollup-plugin-node-polyfills","^0.2"]]},features:q,packageDevDependencies:X})}function V6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"visualizer",packages:[["rollup-plugin-visualizer","^5"]],expilicit:!0},features:q,packageDevDependencies:X})}function K6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"analyzer",packages:[["rollup-plugin-analyzer","^3"]],options:{summaryOnly:!0,limit:12},explicit:!0},features:q,packageDevDependencies:X})}function _6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"string",packages:[["rollup-plugin-string","^3"]]},features:q,packageDevDependencies:X})}function z6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"image",packages:[["@rollup/plugin-image","^3"]]},features:q,packageDevDependencies:X})}function G6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;if(q.runtime.type==="bun")return;E({feature:{name:"json",packages:[["@rollup/plugin-json","^6"]]},features:q,packageDevDependencies:X})}function U6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"terser",packages:[["@rollup/plugin-terser","^0.4"]]},features:q,packageDevDependencies:X})}function $6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"wasm",packages:[["@rollup/plugin-wasm","^6"]]},features:q,packageDevDependencies:X})}function M6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;if(q.runtime.type==="bun")return;let Y={};if(q.app?.enabled===!0){if(Y.targets=Y.targets||[],Y.targets.push({src:"./src/app/index.html",dest:q.app.dir}),!Reflect.has(q.app,"copy")){if(!Reflect.has(q,"copy"))q.copy=!0}}E({feature:{name:"copy",packages:[["rollup-plugin-copy","^3"],["chokidar","^3"]],options:Y},features:q,packageDevDependencies:X})}function O6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features,Y=q.css&&q.css.enabled!==!1,J=[];if(Y)J.push(["rollup-plugin-postcss","^4"]),J.push(["sass","^1.66"]),(q.css?.options?.plugins||[]).forEach((W)=>{switch(W.name){case"postcss-import":J.push(["postcss-import","^15"]);break;case"postcss-url":J.push(["postcss-url","^10"]);break;case"postcss-preset-env":J.push(["postcss-preset-env","^9"]);break;case"autoprefixer":J.push(["autoprefixer","^10"]);break;case"cssnano":J.push(["cssnano","^6"]);break}});E({feature:{name:"css",packages:J},features:q,packageDevDependencies:X})}function A6({dir:Q,name:Z="index"}){let X=_0.resolve(Q,`./${Z}.tsx`);if(!C8.existsSync(X))X=_0.resolve(Q,`./${Z}.ts`);if(!C8.existsSync(X))X=_0.resolve(Q,`./${Z}.jsx`);if(!C8.existsSync(X))X=_0.resolve(Q,`./${Z}.js`);if(!C8.existsSync(X))return{};let q=X,Y=_0.extname(X);return{file:q,ext:Y,ts:Y===".ts"||Y===".tsx",name:Z}}async function B6(Q){let{atom:Z,context:X,setProgress:q}=Q;q("Initializing features..."),Z.doc.features=Z.doc.features||{};let Y=Z.doc.features;Y.project=Y.project||{},Y.project.format=Y.project.format||Y.project_format||"esm",Y.project_format=Y.project.format,Y.dts_enabled=Y.dts===!0||typeof Y.dts<"u"&&Y.dts!==!1;let J=_0.resolve(X.project.projectDir),H=A6({dir:_0.resolve(J,"./app")});if(H.file){q("Parsing app entry imports...");let A=await h0({file:H.file,recursive:!0}),U=A.all.some((B)=>B.usesJSX===!0&&B.type==="local");Y.app_uses_jsx=U,Y.app_has_entry=!0,A=await h0({file:H.file}),U=A.all.some((B)=>B.usesJSX===!0&&B.type==="local"),Y.app_entry_uses_jsx=U,Y.app_entry_is_ts=H.ts,Y.app_entry_ext=H.ext}let W=A6({dir:_0.resolve(J,"./cli")});if(W.file){q("Parsing cli entry imports...");let A=await h0({file:W.file,recursive:!0}),U=A.all.some((B)=>B.usesJSX===!0&&B.type==="local");Y.cli_uses_jsx=U,Y.cli_has_entry=!0,A=await h0({file:W.file}),U=A.all.some((B)=>B.usesJSX===!0&&B.type==="local"),Y.cli_entry_uses_jsx=U,Y.cli_entry_is_ts=W.ts,Y.cli_entry_ext=W.ext}if(Z.type==="workflow.lib"){let A=A6({dir:_0.resolve(J,"./src")});if(A.file){q("Parsing src entry imports...");let U=await h0({file:A.file,recursive:!0}),B=U.all.some((M)=>M.usesJSX===!0&&M.type==="local");Y.src_uses_jsx=B,Y.src_has_entry=!0,U=await h0({file:A.file}),B=U.all.some((M)=>M.usesJSX===!0&&M.type==="local"),Y.src_entry_uses_jsx=B,Y.src_entry_is_ts=A.ts,Y.src_entry_ext=A.ext}}let V=Reflect.has(Y,"app_entry_uses_jsx")?Y.app_entry_uses_jsx===!0:Y.src_entry_uses_jsx===!0,K=Reflect.has(Y,"cli_entry_uses_jsx")?Y.cli_entry_uses_jsx===!0:Y.src_entry_uses_jsx===!0;if(Y.form_enabled=V||K||Y.form===!0||Y.form?.enabled===!0,Y.multiple_enabled=Y.multiple_enabled||Y.multiple===!0||Y.multiple?.enabled===!0,Y.app===!1)Y.app={enabled:!1};else if(Y.app===!0)Y.app={enabled:!0,extend:Y.app_has_entry===!0,export:!0,react:V};else Y.app={enabled:!0,extend:Y.app_has_entry===!0,export:!0,react:V,...Y.app||{}};if(Y.app.enabled=Y.app.enabled===!0&&(Z.doc.features.form_enabled===!0||Y.app.extend===!0||Y.app.enabled===!0),Y.app.format=Y.app.format||"esm",Y.app.folder=Y.app.folder||Y.app.format||"default",Y.cli===!1)Y.cli={enabled:!1};else if(Y.cli===!0)Y.cli={enabled:!0,extend:Y.cli_has_entry===!0,export:!0,react:K};else Y.cli={enabled:!0,extend:Y.cli_has_entry===!0,export:!0,react:K,...Y.cli||{}};if(Y.cli.enabled=Y.cli.enabled===!0&&(Z.doc.features.form_enabled===!1||Y.cli.extend===!0||Y.cli.enabled===!0),Y.cli.format=Y.cli.format||"esm",Y.cli.folder=Y.cli.folder||Y.cli.folder||"esm",Y.cli.node_options=Y.cli.node?.options||Y.cli.node_options||"",Y.cli.bin=Y.cli.bin||Z.doc.name,Y.cli.installable=Y.cli.installable===!0,Y.cli.enabled)Z.doc["npm::bin"]=Y.cli.bin;Y.json=Y.cli.enabled||Y.json;let _={cjs:{format:"cjs",context:Y.form_enabled?"window":"global",babel:Y.src_uses_jsx===!0||!1,browser:!1,replace:!0,terser:!0,enabled:Y.cjs!==!1,copy:!1},esm:{format:"esm",context:Y.form_enabled?"window":"global",babel:Y.src_uses_jsx===!0||!1,browser:!1,replace:!0,terser:!1,enabled:Y.esm!==!1,copy:!0},iife:{format:"iife",context:Y.form_enabled?"window":"global",babel:!0,browser:!0,replace:!0,enabled:Y.iife===!0,terser:!0,copy:!1}},G={targets:{browsers:"last 9 versions, not dead",node:"18"}},z={};if(Y.webos===!0)_.webos={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,input:"./src/app/index.js",output_dir:"./dist/app/webos",copy:!1,babel_options:{targets:{chrome:"79"}}};if(Y.electron===!0)_.electron={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/electron"};if(Y.nextjs===!0)_.nextjs={format:"esm",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/nextjs"};if(Y.ios===!0)_.ios={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/ios"};if(Y.macos===!0)_.macos={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/macos"};if(Y.app.enabled===!0)Y.app.dir=`./dist/app/${Y.app.folder}`,Y.app.output={file:`./dist/app/${Y.app.folder}/index.js`,dir:`./dist/app/${Y.app.folder}/`,...Y.app.output||{}},Y.app.input={file:"./src/app/index.js",dir:"./src/app/",...Y.app.input||{}},_.app={format:Y.app.format,browser:!0,babel:!0,context:"window",replace:!0,input:Y.app.input.file,output_dir:Y.app.dir,terser:!0,output_exports:Y.app.export===!1?"none":"auto",browsersync:!0};if(Y.cli.enabled===!0)Y.cli.dir=`./dist/cli/${Y.cli.folder}`,Y.cli.output={file:`./dist/cli/${Y.cli.folder}/index.js`,dir:`./dist/cli/${Y.cli.folder}/`,...Y.cli.output||{}},Y.cli.input={file:"./src/cli/index.js",dir:"./src/cli/",...Y.cli.input||{}},_.cli={format:Y.cli.format,context:"global",babel:Y.src_uses_jsx===!0||Y.cli_uses_jsx===!0||!1,browser:!1,replace:!0,enabled:!0,input:Y.cli.input.file,output_dir:Y.cli.dir,banner:"#!/usr/bin/env bun",terser:!0,output_exports:Y.cli.export===!1?"none":"auto"};let O={server:".",startPath:`${_0.normalize(Y.app.dir||".")}`,files:[_0.normalize("./dist/**/*")],cors:!0,open:!1};if(Y.babel_options=f0(G,Y.babel_options||Y.babel?.options),Y.browsersync_options=f0(O,Y.browsersync_options||Y.browsersync?.options||{}),Y.replace_options=f0(z,Y.replace_options||Y.replace?.options||{}),Reflect.has(Y.browsersync_options,"proxy"))delete Y.browsersync_options.server;Y.rollup=Y.rollup||{},Y.rollup_output=f0(_,Y.rollup_output||Y.rollup?.output||{}),Y.preact_enabled=Y.preact===!0||Y.preact&&Y.preact?.enabled!==!1;let $=Object.keys(_);for(let A of $){let U=_[A];if(!U)continue;if(Y.rollup[A]===!1){delete Y.rollup_output[A];continue}if(U.babel_options=U.babel_options||Y.babel_options,U.browsersync_options=f0(Y.browsersync_options,U.browsersync_options),U.replace_options=f0(Y.replace_options,U.replace_options),Y.preact_enabled)U.alias_enabled=!0,U.alias=U.alias||{},U.alias.entries=U.alias.entries||{},U.alias.entries.react="preact/compat",U.alias.entries["react-dom"]="preact/compat";if(Y.form_enabled||Y.babel)U.babel=!0}$=Object.keys(Y.rollup_output),Y.babel_enabled=$.some((A)=>Y.rollup_output[A].babel===!0),Y.browser_enabled=$.some((A)=>Y.rollup_output[A].babel===!0),Y.browsersync_enabled=Y.browsersync!==!1&&$.some((A)=>Y.rollup_output[A].browsersync===!0),Y.browsersync_enabled=Y.browsersync_enabled&&Y.app.enabled,Y.dependency_auto_enabled=Y.dependency_auto!==!1&&Y.dependency_auto?.enabled!==!1,Y.npm_install_flags=Y.npm_install_flags||"",Y.react_version=Y.react_version||Y.react?.version||18,Y.bpmn=Y.bpmn||{},Y.bpmn.enabled=Y.bpmn.enabled!==!1,Y.bpmn.per_flow=Y.bpmn.per_flow===!0,O6(Q),M6(Q),$6(Q),U6(Q),G6(Q),_6(Q),z6(Q),K6(Q),V6(Q),H6(Q),W6(Q),Y6(Q),J6(Q)}import iZ from"@fnet/npm-list-versions";async function R6({atom:Q,packageDependencies:Z,packageDevDependencies:X,setProgress:q}){q("Initializing dependencies");let Y=Q.doc.dependencies||[];if(Y.filter((J)=>!J.dev).forEach((J)=>Z.push(J)),Y.filter((J)=>J.dev).forEach((J)=>X.push(J)),Q.type==="workflow")Z.push({package:"get-value",version:"^3"}),Z.push({package:"set-value",version:"^4"});if(Q.doc.features.form_enabled){if(Q.doc.features.dependency_auto_enabled){let J="^18.2";if(q("Fetching React versions"),J=`^${(await iZ({name:"react",groupBy:{major:!0}})).find((V)=>V[0]===Q.doc.features.react_version.toString())[0]}`,Z.push({package:"react",version:J}),Z.push({package:"react-dom",version:J}),Q.type==="workflow")Z.push({package:"@fnet/react-app",version:"^0.1"}),Z.push({package:"@fnet/react-app-state",version:"^0.1"})}}if(Q.doc.features.preact_enabled)Z.push({package:"preact",version:"^10"});if(Q.doc.features.cli.enabled===!0){if(Z.push({package:"@fnet/args",version:"^0.1"}),Q.doc.features.cli.fargs&&Q.doc.features.cli.fargs?.enabled!==!1)Z.push({package:"@fnet/config",version:"0.2.21"});if(Q.doc.features.cli.mcp&&Q.doc.features.cli.mcp.enabled===!0)Z.push({package:"@modelcontextprotocol/sdk",version:"^1.10"}),Z.push({package:"express",version:"^4.18"})}if(Q.doc.features.render&&Q.doc.features.render.enabled!==!1)X.push({package:"@flownet/lib-render-templates-dir",version:"0.1.19"});if(X.push({package:"@babel/core",version:"^7"}),X.push({package:"@rollup/plugin-commonjs",version:"^28"}),X.push({package:"@rollup/plugin-node-resolve",version:"^16"}),X.push({package:"@rollup/plugin-replace",version:"^6"}),X.push({package:"rollup",version:"^4"}),Q.doc.features.dts_enabled)X.push({package:"rollup-plugin-dts",version:"^6"});if(X.push({package:"rollup-plugin-peer-deps-external",version:"^2"}),X.push({package:"@rollup/plugin-alias",version:"^5"}),X.push({package:"fs-extra",version:"^11"}),Q.doc.features.babel_enabled)X.push({package:"@rollup/plugin-babel",version:"^6"}),X.push({package:"@babel/preset-env",version:"^7"}),X.push({package:"@babel/preset-react",version:"^7"}),Q.doc.features.babel?.options?.plugins?.forEach((J)=>{switch(J[0]){case"@babel/plugin-proposal-decorators":X.push({package:"@babel/plugin-proposal-decorators",version:"^7"});break;case"@babel/plugin-proposal-class-properties":X.push({package:"@babel/plugin-proposal-class-properties",version:"^7"});break;case"@babel/plugin-proposal-private-methods":X.push({package:"@babel/plugin-proposal-private-methods",version:"^7"});break;case"@babel/plugin-proposal-private-property-in-object":X.push({package:"@babel/plugin-proposal-private-property-in-object",version:"^7"});break;case"@babel/plugin-proposal-optional-chaining":X.push({package:"@babel/plugin-proposal-optional-chaining",version:"^7"});break}});if(X.push({package:"@fnet/rollup-plugin-delete",version:"0.1.10"}),Q.doc.features.browsersync_enabled)X.push({package:"@fnet/rollup-plugin-browsersync",version:"0.1.11"})}import aZ from"@fnet/npm-list-versions";async function I6({atom:Q,packageDependencies:Z,packageDevDependencies:X,setProgress:q}){q("Initializing dependencies for Bun");let Y=Q.doc.dependencies||[];if(Y.filter((J)=>!J.dev).forEach((J)=>Z.push(J)),Y.filter((J)=>J.dev).forEach((J)=>X.push(J)),Q.type==="workflow")Z.push({package:"get-value",version:"^3"}),Z.push({package:"set-value",version:"^4"});if(Q.doc.features.form_enabled){if(Q.doc.features.dependency_auto_enabled){let J="^18.2";if(q("Fetching React versions"),J=`^${(await aZ({name:"react",groupBy:{major:!0}})).find((V)=>V[0]===Q.doc.features.react_version.toString())[0]}`,Z.push({package:"react",version:J}),Z.push({package:"react-dom",version:J}),Q.type==="workflow")Z.push({package:"@fnet/react-app",version:"^0.1"}),Z.push({package:"@fnet/react-app-state",version:"^0.1"})}}if(Q.doc.features.preact_enabled)Z.push({package:"preact",version:"^10"});if(Q.doc.features.cli.enabled===!0){if(Z.push({package:"@fnet/args",version:"^0.1"}),Q.doc.features.cli.fargs&&Q.doc.features.cli.fargs?.enabled!==!1)Z.push({package:"@fnet/config",version:"0.2.21"});if(Q.doc.features.cli.mcp&&Q.doc.features.cli.mcp.enabled===!0)Z.push({package:"@modelcontextprotocol/sdk",version:"^1.10"}),Z.push({package:"express",version:"^4.18"})}if(Q.doc.features.render&&Q.doc.features.render.enabled!==!1)X.push({package:"@flownet/lib-render-templates-dir",version:"0.1.19"})}import e7 from"node:fs";import Q9 from"node:path";import rZ from"@flownet/lib-render-templates-dir";async function C6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){if(Q.doc.features.app.enabled!==!0)return;await Z({message:"Creating app folder"});let Y={atom:Q,packageDependencies:q,ts:Date.now()},J=X.templateDir,H=Q9.resolve(X.projectDir,"src/app");if(!e7.existsSync(H))e7.mkdirSync(H,{recursive:!0});let W=["index.js.njk"];if(Q.doc.features.app.html!==!1)W.push("index.html.njk");await rZ({pattern:W,dir:Q9.resolve(J,"src/app"),outDir:H,context:Y})}import X9 from"nunjucks";import C0 from"node:fs";import w0 from"node:path";import oZ from"@flownet/lib-parse-imports-js";import nZ from"@fnet/npm-pick-versions";import sZ from"object-hash";import L8 from"node:fs";import Z9 from"node:path";async function g0({projectDir:Q,name:Z,setProgress:X,count:q=1}){let Y,H=sZ(["npm-pick-versions",Z,q]),W=Z9.join(Q,".cache"),V=Z9.join(W,H+".json");if(L8.existsSync(V)){if(X)X(`Picking npm version of ${Z} from cache ...`);Y=JSON.parse(L8.readFileSync(V,"utf8"))}else{if(X)X(`Picking npm version of ${Z} ...`);Y=await nZ({name:Z,count:q}),L8.mkdirSync(W,{recursive:!0}),L8.writeFileSync(V,JSON.stringify(Y),"utf8")}return Y}async function L6({atom:Q,context:Z,packageDependencies:X,packageDevDependencies:q,setProgress:Y}){await Y({message:"Creating package.json."}),X.filter((U)=>U.dev===!0).forEach((U)=>{if(!q.find((M)=>M.package===U.package))q.push(U);let B=X.findIndex((M)=>M.package===U.package);X.splice(B,1)});let H=X.find((U)=>U.package==="react"),W=X.find((U)=>U.package==="react-dom");if(H&&!W)X.push({package:"react-dom",version:H.version});else if(H&&W)W.version=H.version;if(H&&Q.doc.features.react_version>=17){if(!X.find((U)=>U.package==="@emotion/react"))X.push({package:"@emotion/react",version:"^11"});if(!X.find((U)=>U.package==="@emotion/styled"))X.push({package:"@emotion/styled",version:"^11"})}let V=[];if(Q.doc.features.app.enabled===!0)V.push({file:w0.resolve(Z.projectDir,"src/app/index.js"),dev:Q.doc.features.app.dev===!0});if(Q.doc.features.cli.enabled===!0)V.push({file:w0.resolve(Z.projectDir,"src/cli/index.js"),dev:Q.doc.features.cli.dev===!0});for await(let U of V){let B=U.file;if(!C0.existsSync(B))throw Error(`App file not found: ${B}`);let R=(await oZ({file:B,recursive:!0,verbose:!1})).all;for await(let F of R){if(F.type!=="npm")continue;if(X.find((v)=>v.package===F.package))continue;if(q.find((v)=>v.package===F.package))continue;let w=await g0({name:F.package,projectDir:Z.projectDir,setProgress:Y});(U.dev===!0?q:X).push({package:F.package,subpath:F.subpath,version:w.minorRange,type:"npm"})}}let K={atom:Q,packageDependencies:X,packageDevDependencies:q},_=Z.templateDir,z=X9.compile(C0.readFileSync(w0.resolve(_,"package.json.njk"),"utf8"),X9.configure(_)).render(K),O=Z.projectDir,$=w0.resolve(O,"package.json");C0.writeFileSync($,z,"utf8");let A=w0.resolve(Z.project.projectDir,"fnet");if(C0.existsSync(A)){let U=w0.resolve(Z.projectDir,"fnet");if(!C0.existsSync(U))C0.mkdirSync(U);let B=C0.readdirSync(A);for(let M of B){let R=w0.resolve(A,M);if(!C0.lstatSync(R).isFile())continue;let F=w0.resolve(U,M);C0.copyFileSync(R,F)}}}import q9 from"node:fs";import Y9 from"node:path";import tZ from"@flownet/lib-render-templates-dir";async function F6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){if(Q.doc.features.cli.enabled!==!0)return;await Z({message:"Creating cli."});let Y={atom:Q,packageDependencies:q},J=X.templateDir,H=Y9.resolve(X.projectDir,"src/cli");if(!q9.existsSync(H))q9.mkdirSync(H,{recursive:!0});await tZ({pattern:["index.js.njk"],dir:Y9.resolve(J,"src/cli"),outDir:H,context:Y})}import j6 from"node:fs";import T6 from"node:path";import J9 from"nunjucks";import eZ from"@flownet/lib-parse-imports-js";async function w6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){await Z({message:"Creating rollup file."});let Y={atom:Q,packageDependencies:q},J=T6.resolve(X.projectDir,"src","default/index.js");if(!j6.existsSync(J))throw Error(`Entry file not found: ${J}`);let W=(await eZ({file:J,recursive:!0})).all.filter((A)=>A.type==="node").map((A)=>A.path),V=Q.doc.features.rollup_output,K=Object.keys(V);for(let A=0;A<K.length;A++){let U=K[A],B=V[U];if(B.browser===!0){if(W.length>0){B.globals_enabled=!0,B.globals=B.globals||[],B.globals=B.globals.concat(W.map((M)=>{return{key:M,value:M}})),B.alias_enabled=!0,B.alias=B.alias||{},B.alias.entries=B.alias.entries||{};for(let M=0;M<W.length;M++){let R=W[M];B.alias.entries[R]=`node:${R}`,B.alias.entries[`node:${R}`]=R}B.external_enabled=!0,B.external=B.external||[],B.external=B.external.concat(W)}}}let _=X.templateDir,z=J9.compile(j6.readFileSync(T6.resolve(_,"rollup.config.mjs.njk"),"utf8"),J9.configure(_)).render(Y),O=X.projectDir,$=T6.resolve(O,"rollup.config.mjs");j6.writeFileSync($,z,"utf8")}import S6 from"node:fs";import W9 from"node:path";import H9 from"nunjucks";async function N6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){await Z({message:"Creating build.js file."});let Y={atom:Q,packageDependencies:q},J=X.templateDir,W=H9.compile(S6.readFileSync(W9.resolve(J,"build.js.njk"),"utf8"),H9.configure(J)).render(Y),V=X.projectDir,K=W9.resolve(V,"build.js");S6.writeFileSync(K,W,"utf8"),S6.chmodSync(K,"755")}import P6 from"node:fs";import b6 from"node:path";import Q5 from"nunjucks";import Z5 from"ajv/dist/2020.js";import X5 from"ajv/dist/standalone/index.js";import q5 from"ajv-formats";async function D6({atom:Q,setProgress:Z,context:X,njEnv:q}){if(Q.doc.features.cli.enabled!==!0)return;await Z({message:"Creating input args."});let Y={},J=[];if(Q.doc.input)Y=Q.doc.input;else Y={type:"object",properties:{},required:[]};if(Q.doc.features.cli.fargs&&Q.doc.features.cli.fargs?.enabled!==!1){let B=Q.doc.features.cli.fargs,M={type:"string",description:"Config name to load args",hidden:!1},R={type:"array",description:"Tags to filter the config",hidden:!1};if(Reflect.has(B,"default"))M.default=B.default}let W={imports:J,atom:Q},V=X.templateDir,_=Q5.compile(P6.readFileSync(b6.resolve(V,"src/default/input.args.js.njk"),"utf8"),q).render(W),G=X.projectDir,z=b6.resolve(G,"src/default/input.args.js");P6.writeFileSync(z,_,"utf8");let O=new Z5({allErrors:!0,useDefaults:!0,formats:{},strict:!1,code:{esm:!0,lines:!0,optimize:!1,source:!0}});q5(O);let $=O.compile(Y),U=X5(O,$)+`
4
+ export { schema31 as schema };`;P6.writeFileSync(b6.resolve(G,"src/default/validate_input.js"),U,"utf8")}import V9 from"node:fs";import K9 from"node:path";import _9 from"nunjucks";async function k6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){await Z({message:"Creating .gitignore"});let Y={atom:Q,packageDependencies:q},J=X.templateDir,W=_9.compile(V9.readFileSync(K9.resolve(J,".gitignore.njk"),"utf8"),_9.configure(J)).render(Y),V=X.projectDir,K=K9.resolve(V,".gitignore");V9.writeFileSync(K,W,"utf8")}import z9 from"node:fs";import G9 from"node:path";import U9 from"nunjucks";async function v6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){await Z({message:"Creating tsconfig.json."});let Y={atom:Q,packageDependencies:q},J=X.templateDir,W=U9.compile(z9.readFileSync(G9.resolve(J,"tsconfig.json.njk"),"utf8"),U9.configure(J)).render(Y),V=X.projectDir,K=G9.resolve(V,"tsconfig.json");z9.writeFileSync(K,W,"utf8")}import F8 from"nunjucks";import S0 from"node:fs";import y0 from"node:path";import $9 from"@fnet/yaml";async function y6({atom:Q,context:Z,setProgress:X,Atom:q}){if(await X({message:"Creating readme.md"}),Z.project?.readme){let H=Z.projectDir,W={content:Z.project.readme.doc.content},V=y0.resolve(Z.project.projectDir,"fnet/how-to.md");if(S0.existsSync(V)){let A=S0.readFileSync(V,"utf8");W.howto=A}let K=y0.resolve(Z.project.projectDir,"fnet/input.yaml");if(S0.existsSync(K)){let A=await $9({file:K,tags:Z.tags});W.input=A.content}let _=y0.resolve(Z.project.projectDir,"fnet/output.yaml");if(S0.existsSync(_)){let A=await $9({file:_,tags:Z.tags});W.output=A.content}let G=Z.templateDir,O=F8.compile(S0.readFileSync(y0.resolve(G,"readme.md.njk"),"utf8"),F8.configure(G)).render(W),$=y0.resolve(H,"readme.md");S0.writeFileSync($,O,"utf8")}else if(Q.id){let H=await q.first({type:"wiki",parent_id:Q.id});if(!H||H.doc?.["content-type"]!=="markdown")return;let{content:W,...V}=H.doc,K={content:W},_=Z.templateDir,z=F8.compile(S0.readFileSync(y0.resolve(_,"readme.md.njk"),"utf8"),F8.configure(_)).render(K),O=Z.projectDir,$=y0.resolve(O,"readme.md");S0.writeFileSync($,z,"utf8")}}import Y5 from"node:path";import M9 from"@fnet/shelljs";async function E6({setProgress:Q,context:Z}){let X=Z.projectDir;await Q({message:"Prettifiying source files."});let q=Y5.join("src","**","*");if(M0("bun")){let Y=await M9(`prettier --write ${q} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:X});if(Y.code!==0)throw Error(Y.stderr)}else{let Y=await M9(`prettier --write ${q} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:X});if(Y.code!==0)throw Error(Y.stderr)}}import J5 from"@fnet/shelljs";async function x6({atom:Q,setProgress:Z,context:X}){if(!Q.doc.features.dts_enabled)return;let q=X.projectDir;if(await Z({message:"Creating .d.ts"}),(await J5("tsc",{cwd:q})).code!==0)throw Error("Couldnt create .d.ts files.")}import O9 from"@fnet/shelljs";async function u6({setProgress:Q,atom:Z,context:X}){let q=X.projectDir;if(await Q({message:"Installing npm packages."}),M0("bun")){if((await O9(`bun install ${Z.doc.features.npm_install_flags}`,{cwd:q})).code!==0)throw Error("Couldnt install npm packages.")}else if((await O9(`npm install ${Z.doc.features.npm_install_flags}`,{cwd:q})).code!==0)throw Error("Couldnt install npm packages.")}import A9 from"node:fs";import W5 from"node:path";import{spawn as H5}from"node:child_process";async function B9(Q){let{projectDir:Z,scriptName:X,args:q=[],env:Y=process.env,shell:J=!0,detached:H=!0,onSpawn:W}=Q;if(!Z||!X)throw Error("projectDir and scriptName are required");let V=W5.resolve(Z,"package.json");if(!A9.existsSync(V))throw Error(`package.json not found at ${V}`);let K=JSON.parse(A9.readFileSync(V,"utf8")),_=K.scripts?.[X];if(!_){let O=Object.keys(K.scripts||{}).join(", ");throw Error(`Script '${X}' not found. Available: ${O}`)}let G=q.length>0?`${_} ${q.join(" ")}`:_,z=H5(G,[],{cwd:Z,shell:J,detached:H,env:{...Y}});if(W)W(z);return new Promise((O,$)=>{z.on("error",(A)=>{$(Error(`Failed to start '${X}': ${A.message}`))}),z.on("close",(A)=>{O({subprocess:z,exitCode:A})})})}import V5 from"node:path";async function f6({setProgress:Q,context:Z}){let X=Z.projectDir;await Q({message:"Building main project."});let q=Z.dev?"build:dev":"build",Y={...process.env},J=V5.join(X,"node_modules");Y.NODE_PATH=J;let H=Y.NODE_OPTIONS||"";Y.NODE_OPTIONS=`${H} --preserve-symlinks`.trim(),await B9({projectDir:X,scriptName:q,shell:!0,detached:!0,env:Y})}var R9=async(Q)=>{let{atom:Z,packageDependencies:X,context:q,deploymentProjectTarget:Y,setProgress:J,deploymentProject:H,yamlTarget:W}=Q;if(Y.enabled!==!0)return;let V=Y.type;try{if(V==="lib")await(await import("./index.p0zb7e1b.js")).default({...Q});else if(V==="red")await(await import("./index.490y87nc.js")).default({...Q});else if(V==="npm")await(await import("./index.gh75wt1m.js")).default({...Q});else if(V==="gcs")await(await import("./index.hzsfswvp.js")).default({...Q});else if(V==="gitlab")await(await import("./index.jgpc3grc.js")).default({...Q});else if(V==="fnet-package")await(await import("./index.r82rtnmz.js")).default({...Q});else if(V==="fnet-form")await(await import("./index.3exge2js.js")).default({...Q});else if(V==="fnet-node")await(await import("./index.4jkat7r4.js")).default({...Q});else if(V==="fnet-flow")await(await import("./index.s662t98v.js")).default({...Q});else if(V==="nextjs")await(await import("./index.7vw06nrn.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="webos")await(await import("./index.zm4kesg6.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="electron")await(await import("./index.9567fa9x.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="docker")await(await import("./index.w74dpnpn.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="ios")await(await import("./index.7crx8ky1.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="macos")await(await import("./index.xeaw5xa9.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="rust")await(await import("./index.3kfx538h.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="pypi")await(await import("./index.33f1ggpr.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else{console.warn(`No deployer found for type: ${V}`);return}}catch(K){throw console.error(`Error during deployment for type "${V}":`,K),K}};import{Atom as R0}from"@flownet/lib-atom-api-js";import Z1 from"@flownet/lib-parse-node-url";import C9 from"bpmn-moddle";import I9 from"dagre";import m6 from"lodash.clonedeep";var h6={name:"ATOM",uri:"http://atom.org/bpmn",prefix:"atom",types:[{name:"AtomExtension",extends:["bpmn:BaseElement"],properties:[{name:"atom",type:"atom:Atom",isMany:!1}]},{name:"Atom",properties:[{name:"type",type:"String",isAttr:!0}]}]};function L9(Q){let{nodes:Z,nodeIndex:X,root:q}=Q,Y=[],J=new Set,H=(W)=>{if(J.has(W.indexKey))return;if(J.add(W.indexKey),W.hasReturn&&W.type!=="return"){let V=`${W.indexKey}/_inline_end`;if(X[V])return;let K={name:"",type:"return",virtual:!0,parent:W.parent,childs:[],definition:{return:W.definition.return},index:W.parent.childs.length,indexKey:V,pathKey:`${W.pathKey}._inline_end`,codeKey:`${W.codeKey}_inline_end`,context:{next:null},hasReturn:!0,_inlineParent:W};if(Y.push(K),j("bpmn"))x.info(` \uD83C\uDFC1 INLINE RETURN → EndEvent: ${K.indexKey}`,{parentNode:W.indexKey,nodeType:W.type,hasReturn:!0})}W.childs.forEach((V)=>H(V))};Z.forEach((W)=>H(W)),Y.forEach((W)=>{W.parent.childs.push(W),X[W.indexKey]=W,Z.push(W)}),Z.forEach((W)=>{let V=[],K=[],_=($)=>{let A=Y.find((U)=>U._inlineParent===$);if(A)V.push({from:$,to:A,type:"bpmn:SequenceFlow"});else if($.context.next){if(V.push({from:$,to:$.context.next,type:"bpmn:SequenceFlow"}),$===W)K.push({to:$.context.next,type:"bpmn:SequenceFlow",next:!0})}$.childs.forEach((U)=>{if($===W){if(W.type==="switch"){if(!(U.indexKey&&U.indexKey.endsWith("/_inline_end")))K.push({to:U,type:"bpmn:SequenceFlow"})}}_(U)})};_(W);let G=V.filter(($)=>$.to.parent.indexKey===W.parent.indexKey).map(($)=>{return{...$,from:W.indexKey,to:$.to.indexKey}}),z=V.filter(($)=>$.to.parent.indexKey!==W.parent.indexKey&&!$.to.indexKey.startsWith(W.indexKey+"/")).map(($)=>{return{...$,from:W.indexKey,to:$.to.indexKey}}),O=K.map(($)=>{return{...$,to:$.to.indexKey}});if(W.bpmn=W.bpmn||{},W.bpmn.edges=g6(G,"to"),W.bpmn.outside=g6(z,"to"),W.bpmn.starts=g6(O,"to"),W.bpmn.type=_5(W),W.bpmn.width=120,W.bpmn.height=80,W.type==="return")W.bpmn.width=36,W.bpmn.height=36;if(W.bpmn.type==="bpmn:CallActivity")W.bpmn.fill="#E1F5FE",W.bpmn.stroke="#0277BD"})}function _5(Q){let Z;if(Q.type==="call"){if(Q.context?.lib?.type==="subworkflow"||Q.context?.lib?.type==="workflow"){if(Z="bpmn:CallActivity",j("bpmn"))x.info(` \uD83D\uDCE6 CALL → CallActivity (subworkflow): ${Q.indexKey}`,{nodeType:Q.type,bpmnType:Z,calledElement:Q.context?.lib?.name||"unknown",isChip:!0})}else if(Z="bpmn:ServiceTask",j("bpmn"))x.info(` \uD83D\uDCDE CALL → ServiceTask (external): ${Q.indexKey}`,{nodeType:Q.type,bpmnType:Z,target:Q.context?.lib?.name||"unknown",isChip:!1})}else if(Q.type==="form"){if(Z="bpmn:UserTask",j("bpmn"))x.info(` \uD83D\uDCDD FORM → UserTask: ${Q.indexKey}`,{nodeType:Q.type,bpmnType:Z})}else if(Q.type==="return"){if(Z="bpmn:EndEvent",j("bpmn"))x.info(` \uD83C\uDFC1 RETURN → EndEvent: ${Q.indexKey}`,{nodeType:Q.type,bpmnType:Z})}else if(Q.type==="raise"){let X=!1;if(Q.name==="try"&&Q.parent?.type==="tryexcept")X=!0;else{let q=Q.parent;while(q){if(q.name==="try"&&q.parent?.type==="tryexcept"){X=!0;break}q=q.parent}}if(X){if(Z="bpmn:IntermediateThrowEvent",j("bpmn"))x.info(` ⚡ RAISE → IntermediateThrowEvent (inside try): ${Q.indexKey}`,{nodeType:Q.type,bpmnType:Z,nodeName:Q.name,parent:Q.parent?.indexKey})}else if(Z="bpmn:EndEvent",j("bpmn"))x.info(` ⚠️ RAISE → EndEvent (error): ${Q.indexKey}`,{nodeType:Q.type,bpmnType:Z})}else if(Q.type==="pipeline"){if(Z="bpmn:ServiceTask",j("bpmn"))x.info(` \uD83D\uDD27 PIPELINE → ServiceTask (external binary): ${Q.indexKey}`,{nodeType:Q.type,bpmnType:Z,binary:Q.context?.binaryName||"unknown"})}else if(Q.type==="http"){if(Z="bpmn:ServiceTask",j("bpmn"))x.info(` \uD83C\uDF10 HTTP → ServiceTask (external API): ${Q.indexKey}`,{nodeType:Q.type,bpmnType:Z,method:Q.context?.http?.method||"GET",url:Q.context?.http?.url||"unknown"})}else if(Q.type==="assign"||Q.type==="new"){if(Z="bpmn:ScriptTask",j("bpmn"))x.info(` \uD83D\uDCDC ${Q.type.toUpperCase()} → ScriptTask: ${Q.indexKey}`,{nodeType:Q.type,bpmnType:Z})}else if(Z="bpmn:Task",j("bpmn"))x.info(` \uD83D\uDCCB ${Q.type.toUpperCase()} → Task: ${Q.indexKey}`,{nodeType:Q.type,bpmnType:Z});return Z}function g6(Q,Z){return Q.filter((X,q,Y)=>{return Y.map((J)=>J[Z]).indexOf(X[Z])===q})}function c6(Q){let{nodes:Z,nodeIndex:X,root:q}=Q,Y=Q.targetNodes||q.childs;Y.forEach((J)=>{let H=J.type==="workflow"||J.type==="subworkflow",W=!H&&J.childs.filter((G)=>!G.virtual).length>0,V=(J.name==="try"||J.name==="except")&&J.parent?.type==="tryexcept",K=J.type==="schedule",_=J.type==="retry";if(W||V||K||_){if(J.bpmn.type="bpmn:SubProcess",J.type==="for"){if(J.bpmn.loopCharacteristics=!0,j("bpmn"))x.info(" \uD83D\uDD01 FOR → SubProcess + Loop Marker",{subprocess:J.indexKey,loopType:"StandardLoopCharacteristics"})}if(J.name==="try"&&J.type==="raise"&&J.parent?.type==="tryexcept"){let G=t({location:0,...Q,parent:J,bpmnType:"bpmn:IntermediateThrowEvent",type:"raise",attrs:{},definitions:[{type:"bpmn:ErrorEventDefinition"}]});if(j("bpmn"))x.info(" ⚡ Created virtual IntermediateThrowEvent for single-step try block",{tryNode:J.indexKey,virtualNode:G.indexKey,bpmnType:G.bpmn.type})}}if(H||W){let G=J.childs.filter((M)=>M.module!==!0&&!M.indexKey.endsWith("/_inline_end"))[0];J.childs.filter((M)=>M.module===!0).forEach((M)=>{let R=t({...Q,parent:J,bpmnType:"bpmn:IntermediateCatchEvent",type:"inter",definitions:[{type:"bpmn:SignalEventDefinition"}]});R.bpmn.edges=[{from:R.indexKey,to:M.indexKey,type:"bpmn:SequenceFlow"}]});let O=J.childs.find((M)=>M.name==="try"&&J.type==="tryexcept"),$=J.childs.filter((M)=>M.name==="except"&&J.type==="tryexcept");if(O&&$.length)$.forEach((M)=>{let R=t({location:J.childs.indexOf(M),...Q,parent:J,bpmnType:"bpmn:BoundaryEvent",type:"boundary",attrs:{attachedToRef:O},definitions:[{type:"bpmn:ErrorEventDefinition"}]});if(R.bpmn.edges=[{from:R.indexKey,to:M.indexKey,type:"bpmn:SequenceFlow"}],j("bpmn"))x.info(" ⚡ TRY-EXCEPT → BoundaryEvent",{subprocess:J.indexKey,tryNode:O.indexKey,exceptNode:M.indexKey,boundaryEvent:R.indexKey})});let A=J.childs.find((M)=>M.type==="raise");if(A){let M=t({...Q,parent:J,bpmnType:"bpmn:EndEvent",type:"end",name:"ERROR",definitions:[{type:"bpmn:ErrorEventDefinition"}]});A.bpmn.edges=[{from:A.indexKey,to:M.indexKey,type:"bpmn:SequenceFlow"}]}if(J.type==="schedule"){let M=J.childs[0];if(M){let R=t({...Q,parent:J,bpmnType:"bpmn:StartEvent",type:"timer-start",definitions:[{type:"bpmn:TimerEventDefinition",timerType:"timeCycle",expression:J.context?.cron||"* * * * *"}]});if(R.bpmn.edges=[{from:R.indexKey,to:M.indexKey,type:"bpmn:SequenceFlow"}],j("bpmn"))x.info(" ⏰ SCHEDULE → SubProcess + TimerStartEvent",{subprocess:J.indexKey,timerEvent:R.indexKey,child:M.indexKey,cron:J.context?.cron})}}if(G)if(J.type==="schedule"){if(j("bpmn"))x.info(" ⏰ SCHEDULE → Skipping normal StartEvent (using TimerStartEvent)",{subprocess:J.indexKey,timerEvent:"already created"})}else if(J.type==="retry"){let M=t({...Q,parent:J,bpmnType:"bpmn:StartEvent",type:"start"});if(M.bpmn.edges.push({from:M.indexKey,to:G.indexKey,type:"bpmn:SequenceFlow"}),j("bpmn"))x.info(" \uD83D\uDD01 RETRY → SubProcess with loop characteristics",{subprocess:J.indexKey,attempts:J.context?.attempts,backoff:J.context?.backoff})}else if(J.type==="parallel"){let M=t({...Q,parent:J,bpmnType:"bpmn:StartEvent",type:"start"}),R=t({...Q,parent:J,bpmnType:"bpmn:ParallelGateway",type:"fork"}),F=t({...Q,parent:J,bpmnType:"bpmn:ParallelGateway",type:"join"}),w=t({...Q,parent:J,bpmnType:"bpmn:EndEvent",type:"end"});M.bpmn.edges=[{from:M.indexKey,to:R.indexKey,type:"bpmn:SequenceFlow"}];let y=J.childs.filter((v)=>!v.virtual&&!v.module&&!v.indexKey.endsWith("/_inline_end"));if(R.bpmn.edges=y.map((v)=>{return{from:R.indexKey,to:v.indexKey,type:"bpmn:SequenceFlow"}}),y.forEach((v)=>{v.bpmn.edges=[{from:v.indexKey,to:F.indexKey,type:"bpmn:SequenceFlow"}]}),F.bpmn.edges=[{from:F.indexKey,to:w.indexKey,type:"bpmn:SequenceFlow"}],j("bpmn"))x.info(" \uD83D\uDD00 PARALLEL → Fork/Join Gateways",{subprocess:J.indexKey,childCount:y.length,pattern:"Start → Fork → [Tasks] → Join → End"})}else if(J.bpmn.starts.length>1){let M=t({...Q,parent:J,bpmnType:"bpmn:StartEvent",type:"start"}),R=t({...Q,parent:J,bpmnType:"bpmn:ExclusiveGateway",type:"switch"});M.bpmn.edges=[{from:M.indexKey,to:R.indexKey,type:"bpmn:SequenceFlow"}],R.bpmn.edges=J.bpmn.starts.map((w)=>{return{...w,from:R.indexKey}});let F=R.bpmn.edges.find((w)=>w.next===!0);if(F){let w=t({...Q,parent:J,bpmnType:"bpmn:EndEvent",type:"end",name:F.to});F.to=w.indexKey}}else{let M=t({...Q,parent:J,bpmnType:"bpmn:StartEvent",type:"start"});M.bpmn.edges.push({from:M.indexKey,to:G.indexKey,type:"bpmn:SequenceFlow"})}else if(j("bpmn"))x.info(" \uD83D\uDEAB START EVENT skipped (no valid firstNode)",{subprocess:J.indexKey,reason:"Only modules or inline end events in subprocess"});J.childs.filter((M)=>M.virtual!==!0&&M.bpmn.outside.length&&M.bpmn.type!=="bpmn:EndEvent").forEach((M)=>{M.bpmn.outside.forEach((R)=>{let F=Y.indexOf(J),w=t({...Q,parent:J,bpmnType:"bpmn:EndEvent",type:"end",name:R.to,location:F+1});M.bpmn.edges.push({from:M.indexKey,to:w.indexKey,type:"bpmn:SequenceFlow"})})}),J.childs.filter((M)=>M.virtual!==!0&&M.bpmn.edges.length>1).forEach((M)=>{let R=Y.indexOf(M),F=t({...Q,parent:J,bpmnType:"bpmn:ExclusiveGateway",type:"switch",location:R+1});F.bpmn.edges=M.bpmn.edges.map((w)=>{return{...w,from:F.indexKey}}),M.bpmn.edges=[{from:M.indexKey,to:F.indexKey,type:"bpmn:SequenceFlow"}],M.bpmn.outside=[]})}c6({...Q,targetNodes:J.childs})})}function t(Q){let{parent:Z,nodes:X,nodeIndex:q,bpmnType:Y,type:J,name:H,outside:W,location:V,definitions:K,attrs:_}=Q,G=Z.childs.filter((O)=>O.type===`v${J}`).length;if(j("bpmn"))x.info(` \uD83D\uDD37 VIRTUAL ${J.toUpperCase()} → ${Y}`,{parent:Z.indexKey,type:`v${J}`,bpmnType:Y,name:H||`${J}${G}`});let z={indexKey:`${Z.indexKey}/_${J}${G}`,pathKey:`${Z.pathKey}._${J}${G}`,type:`v${J}`,name:H,bpmn:{edges:[],outside:[],type:Y,width:36,height:36,fill:"#c8e6c9",stroke:"#205022",definitions:K,attrs:_},virtual:!0,childs:[]};return Z.childs.splice(V||0,0,z),X.push(z),q[z.indexKey]=z,z}function l6(Q){let{targetNode:Z,targetFlowElementsContainer:X,targetPlaneElement:q,moddle:Y,elementIndex:J,nodeIndex:H,diagrams:W,nodes:V}=Q;z5(Q),G5(Q),U5(Q),$5(Q)}function z5(Q){let{targetNode:Z,targetFlowElementsContainer:X,targetPlaneElement:q,moddle:Y,elementIndex:J,nodeIndex:H,nodes:W}=Q,V=X.get("flowElements");if(X.$nodes=X.$nodes||[],j("bpmn"))x.info(`\uD83C\uDFA8 Creating BPMN elements for: ${Z.indexKey}`,{childCount:Z.childs.length});Z.childs.forEach((K)=>{let _=Y.create(K.bpmn.type,{id:`node.${K.pathKey}`,name:K.definition?.title||K.name});if(J[_.id]=_,_.$isNode=!0,_.$node=K,K.$flow=_,X.$nodes.push(_),V.push(_),K.bpmn.type==="bpmn:CallActivity"&&K.context?.lib){if(_.calledElement=K.context.lib.name,j("bpmn"))x.info(` ✨ Created: ${K.bpmn.type} (chip!)`,{id:_.id,name:_.name,calledElement:_.calledElement,nodeType:K.type,virtual:K.virtual||!1})}else if(j("bpmn"))x.info(` ✨ Created: ${K.bpmn.type}`,{id:_.id,name:_.name,nodeType:K.type,virtual:K.virtual||!1});if(K.bpmn.attrs)Object.keys(K.bpmn.attrs).forEach((z)=>{if(z==="attachedToRef")_.set(z,K.bpmn.attrs[z].$flow)});if(K.bpmn.definitions){let G=K.bpmn.definitions.map((z)=>{let O=Y.create(z.type);return Object.keys(z.attrs||{}).forEach((A)=>{O.set(A,z.attrs[A])}),O});_.eventDefinitions=G}if(K.bpmn.loopCharacteristics&&K.bpmn.type==="bpmn:SubProcess"){if(_.loopCharacteristics=Y.create("bpmn:StandardLoopCharacteristics"),j("bpmn"))x.info(` \uD83D\uDD01 Added loop marker to: ${_.id}`,{nodeType:K.type,loopType:"StandardLoopCharacteristics"})}})}function G5(Q){let{targetNode:Z,targetFlowElementsContainer:X,targetPlaneElement:q,moddle:Y,elementIndex:J,nodeIndex:H}=Q,W=X.get("flowElements");X.$edges=X.$edges||[],Z.childs.forEach((V)=>{V.bpmn.edges.forEach((_)=>{let G=V,z=H[_.to],O=`edge.${G.pathKey}_${z.pathKey}`;if(J[O])return;let $=J[`node.${G.pathKey}`],A=J[`node.${z.pathKey}`],U=Y.create(_.type,{id:O,sourceRef:$,targetRef:A});J[U.id]=U,U.$is_edge=!0,$.get("outgoing").push(U),A.get("incoming").push(U),X.$edges.push({from:$,to:A,flow:U}),W.push(U)})})}function U5(Q){let{targetNode:Z,targetFlowElementsContainer:X,targetPlaneElement:q,moddle:Y,elementIndex:J,nodeIndex:H}=Q,W=120,V=80,K=160,_=160,G=new I9.graphlib.Graph;G.setDefaultEdgeLabel(()=>({})),G.setGraph({rankdir:"TB",nodesep:120,ranksep:80,xranker:"longest-path"}),X.$nodes.forEach((z)=>{G.setNode(z.id,{width:z.$node?.bpmn.width||120,height:z.$node?.bpmn.height||80,label:z.id})}),X.$edges.forEach((z)=>{G.setEdge(z.from.id,z.to.id)}),I9.layout(G),X.$nodes.forEach((z)=>{let O=G.node(z.id),$=O.width,A=O.height,U=Y.create("bpmndi:BPMNShape",{id:`shape.${z.id}`,bpmnElement:z,bounds:Y.create("dc:Bounds",{x:160+O.x-O.width/2,y:160+O.y-O.height/2,width:$,height:A}),label:Y.create("bpmndi:BPMNLabel")});if(z.$node.bpmn.fill)U.set("bioc:fill",z.$node.bpmn.fill);if(z.$node.bpmn.stroke)U.set("bioc:stroke",z.$node.bpmn.stroke);q.get("planeElement").push(U)}),X.$edges.forEach((z)=>{let O=G.edge(z.from.id,z.to.id),$=Y.create("bpmndi:BPMNEdge",{id:`edge.${z.from.id}_${z.to.id}`,bpmnElement:z.flow,label:Y.create("bpmndi:BPMNLabel")});O.points.forEach((U)=>{let B=Y.create("dc:Point",{x:160+U.x,y:160+U.y});$.get("waypoint").push(B)}),q.get("planeElement").push($)})}function $5(Q){let{targetNode:Z,targetFlowElementsContainer:X,targetPlaneElement:q,moddle:Y,elementIndex:J,nodeIndex:H,diagrams:W}=Q;Z.childs.filter((K)=>K.bpmn.type==="bpmn:SubProcess").forEach((K)=>{let _=J[`node.${K.pathKey}`],G=Y.create("bpmndi:BPMNDiagram",{id:`diagram_${K.pathKey}`});J[G.id]=G,W.push(G);let z=Y.create("bpmndi:BPMNPlane",{id:`plane_${K.pathKey}`});J[z.id]=z,G.plane=z,z.bpmnElement=_,l6({...Q,targetNode:K,targetFlowElementsContainer:_,targetPlaneElement:z})})}async function M5(Q){let Z=Q.root,X=Z.context.index,q=Object.keys(X).map((K)=>X[K]);L9({nodes:q,nodeIndex:X,root:Z}),c6({nodes:q,nodeIndex:X,root:Z});let Y=void 0,J=new C9({atom:h6}),H={},W=J.create("bpmn:Definitions",{id:"definitions_0"});H[W.id]=W;for await(let K of Z.childs){let _=W.get("rootElements"),G=W.get("diagrams"),z=J.create("bpmn:Process",{id:`process_${K.pathKey}`,name:K.name,documentation:[J.create("bpmn:Documentation",{text:`Workflow - ${K.name}`})]});H[z.id]=z,z.isExecutable=!0,_.push(z);let O=J.create("bpmndi:BPMNDiagram",{id:`diagram_${K.pathKey}`});H[O.id]=O,G.push(O);let $=J.create("bpmndi:BPMNPlane",{id:`plane_${K.pathKey}`});H[$.id]=$,O.plane=$,$.bpmnElement=z,l6({targetNode:K,targetFlowElementsContainer:z,targetPlaneElement:$,moddle:J,elementIndex:H,nodeIndex:X,nodes:q,diagrams:G})}let V=await J.toXML(W,{format:!0});return{diagramXML:Y||V.xml}}async function O5(Q){let{root:Z,flowName:X}=Q,q=m6(Z),Y=q.childs.find((F)=>F.name===X);if(!Y)throw Error(`Flow "${X}" not found`);let J={...q,childs:[Y]},H=J.context.index,W=Object.keys(H).map((F)=>H[F]);L9({nodes:W,nodeIndex:H,root:J}),c6({nodes:W,nodeIndex:H,root:J});let V=new C9({atom:h6}),K={},_=V.create("bpmn:Definitions",{id:`definitions_${X}`});K[_.id]=_;let G=_.get("rootElements"),z=_.get("diagrams"),O=V.create("bpmn:Process",{id:`process_${Y.pathKey}`,name:Y.name,documentation:[V.create("bpmn:Documentation",{text:`Workflow - ${Y.name}`})]});K[O.id]=O,O.isExecutable=!0,G.push(O);let $=V.create("bpmndi:BPMNDiagram",{id:`diagram_${Y.pathKey}`});K[$.id]=$,z.push($);let A=V.create("bpmndi:BPMNPlane",{id:`plane_${Y.pathKey}`});return K[A.id]=A,$.plane=A,A.bpmnElement=O,l6({targetNode:Y,targetFlowElementsContainer:O,targetPlaneElement:A,moddle:V,elementIndex:K,nodeIndex:H,nodes:W,diagrams:z}),{diagramXML:(await V.toXML(_,{format:!0})).xml,flowName:Y.name}}async function j8(Q={}){return await M5(m6(Q))}async function F9(Q={}){let Z=m6(Q),{root:X}=Z,q=[];for(let Y of X.childs){let J=await O5({root:X,flowName:Y.name});q.push(J)}return q}import X1 from"@fnet/config";import q1 from"@flownet/lib-parse-imports-js";class T8 extends SyntaxError{constructor(Q,Z,X,q){super(Q);this.expected=Z,this.found=X,this.location=q,this.name="SyntaxError"}format(Q){let Z="Error: "+this.message;if(this.location){let X=null,q=Q.find((W)=>W.source===this.location.source);if(q)X=q.text.split(/\r\n|\n|\r/g);let Y=this.location.start,J=this.location.source&&typeof this.location.source.offset==="function"?this.location.source.offset(Y):Y,H=this.location.source+":"+J.line+":"+J.column;if(X){let W=this.location.end,V="".padEnd(J.line.toString().length," "),K=X[Y.line-1],G=(Y.line===W.line?W.column:K.length+1)-Y.column||1;Z+=`
5
+ --> `+H+`
6
+ `+V+` |
7
+ `+J.line+" | "+K+`
8
+ `+V+" | "+"".padEnd(Y.column-1," ")+"".padEnd(G,"^")}else Z+=`
9
+ at `+H}return Z}static buildMessage(Q,Z){function X(G){return G.codePointAt(0).toString(16).toUpperCase()}let q=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function Y(G){if(q)return G.replace(q,(z)=>"\\u{"+X(z)+"}");return G}function J(G){return Y(G.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(z)=>"\\x0"+X(z)).replace(/[\x10-\x1F\x7F-\x9F]/g,(z)=>"\\x"+X(z)))}function H(G){return Y(G.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(z)=>"\\x0"+X(z)).replace(/[\x10-\x1F\x7F-\x9F]/g,(z)=>"\\x"+X(z)))}let W={literal(G){return'"'+J(G.text)+'"'},class(G){let z=G.parts.map((O)=>Array.isArray(O)?H(O[0])+"-"+H(O[1]):H(O));return"["+(G.inverted?"^":"")+z.join("")+"]"+(G.unicode?"u":"")},any(){return"any character"},end(){return"end of input"},other(G){return G.description}};function V(G){return W[G.type](G)}function K(G){let z=G.map(V);if(z.sort(),z.length>0){let O=1;for(let $=1;$<z.length;$++)if(z[$-1]!==z[$])z[O]=z[$],O++;z.length=O}switch(z.length){case 1:return z[0];case 2:return z[0]+" or "+z[1];default:return z.slice(0,-1).join(", ")+", or "+z[z.length-1]}}function _(G){return G?'"'+J(G)+'"':"end of input"}return"Expected "+K(Q)+" but "+_(Z)+" found."}}function j9(Q,Z){Z=Z!==void 0?Z:{};let X={},q=Z.grammarSource,Y={Start:E7},J=E7,H="::",W=/^[a-z]/,V=/^[a-z0-9_\-]/,K=/^[^s]/,_=/^[sS]/,G=IZ("::",!1),z=A8([["a","z"]],!1,!1,!1),O=A8([["a","z"],["0","9"],"_","-"],!1,!1,!1),$=A8(["s"],!0,!1,!1),A=A8(["s","S"],!1,!1,!1);function U(I){return NZ(I)}function B(I,C){let T=I+"::"+C,d=SZ(I,C,T);try{let u=parse(C);if(u)d.next=u}catch(u){}return d}let M=Z.peg$currPos|0,R=M,F=[{line:1,column:1}],w=M,y=Z.peg$maxFailExpected||[],v=Z.peg$silentFails|0,Y0;if(Z.startRule){if(!(Z.startRule in Y))throw Error(`Can't start parsing from rule "`+Z.startRule+'".');J=Y[Z.startRule]}function J0(){return Q.substring(R,M)}function k7(){return R}function P1(){return{source:q,start:R,end:M}}function b1(){return a0(R,M)}function D1(I,C){throw C=C!==void 0?C:a0(R,M),y7([LZ(I)],Q.substring(R,M),C)}function k1(I,C){throw C=C!==void 0?C:a0(R,M),FZ(I,C)}function RZ(I=M){let C=Q.codePointAt(I);if(C===void 0)return"";return String.fromCodePoint(C)}function IZ(I,C){return{type:"literal",text:I,ignoreCase:C}}function A8(I,C,T,d){return{type:"class",parts:I,inverted:C,ignoreCase:T,unicode:d}}function v1(){return{type:"any"}}function CZ(){return{type:"end"}}function LZ(I){return{type:"other",description:I}}function v7(I){let C=F[I],T;if(C)return C;else{if(I>=F.length)T=F.length-1;else{T=I;while(!F[--T]);}C=F[T],C={line:C.line,column:C.column};while(T<I){if(Q.charCodeAt(T)===10)C.line++,C.column=1;else C.column++;T++}return F[I]=C,C}}function a0(I,C,T){let d=v7(I),u=v7(C),r0={source:q,start:{offset:I,line:d.line,column:d.column},end:{offset:C,line:u.line,column:u.column}};if(T&&q&&typeof q.offset==="function")r0.start=q.offset(r0.start),r0.end=q.offset(r0.end);return r0}function T0(I){if(M<w)return;if(M>w)w=M,y=[];y.push(I)}function FZ(I,C){return new T8(I,null,null,C)}function y7(I,C,T){return new T8(T8.buildMessage(I,C),I,C,T)}function E7(){let I,C;if(I=M,C=jZ(),C!==X)R=I,C=U(C);return I=C,I}function jZ(){let I,C,T,d;if(I=M,C=TZ(),C!==X){if(Q.substr(M,2)===H)T=H,M+=2;else if(T=X,v===0)T0(G);if(T!==X)if(d=wZ(),d!==X)R=I,I=B(C,d);else M=I,I=X;else M=I,I=X}else M=I,I=X;return I}function TZ(){let I,C,T,d,u;if(I=M,C=M,T=Q.charAt(M),W.test(T))M++;else if(T=X,v===0)T0(z);if(T!==X){if(d=[],u=Q.charAt(M),V.test(u))M++;else if(u=X,v===0)T0(O);while(u!==X)if(d.push(u),u=Q.charAt(M),V.test(u))M++;else if(u=X,v===0)T0(O);T=[T,d],C=T}else M=C,C=X;if(C!==X)I=Q.substring(I,M);else I=C;return I}function wZ(){let I,C,T,d,u;if(I=M,C=M,T=Q.charAt(M),K.test(T))M++;else if(T=X,v===0)T0($);if(T!==X){if(d=[],u=Q.charAt(M),_.test(u))M++;else if(u=X,v===0)T0(A);while(u!==X)if(d.push(u),u=Q.charAt(M),_.test(u))M++;else if(u=X,v===0)T0(A);T=[T,d],C=T}else M=C,C=X;if(C!==X)I=Q.substring(I,M);else I=C;return I}function SZ(I,C,T){return{processor:I,statement:C,expression:T}}function x7(I){if(!I)return[];let C=I.next?x7(I.next):[];return C.push(I.processor),C}function NZ(I){if(!I)return null;let C=I;while(C&&C.next)C=C.next;let T={processor:I.processor,statement:I.statement,expression:I.expression,process:{statement:C.statement,order:x7(I)}};if(I.next)T.next=I.next;return T}Y0=J();let t8=Y0!==X&&M===Q.length;function u7(){if(Y0!==X&&M<Q.length)T0(CZ());throw y7(y,w<Q.length?RZ(w):null,w<Q.length?a0(w,w+1):a0(w,w))}if(Z.peg$library)return{peg$result:Y0,peg$currPos:M,peg$FAILED:X,peg$maxFailExpected:y,peg$maxFailPos:w,peg$success:t8,peg$throw:t8?void 0:u7};if(t8)return Y0;else u7()}function N0(Q,Z=!1){if(typeof Q!=="string")return null;let X=Q.match(/^([a-z][a-z0-9_-]*)::/);if(!X)return null;let q=X[1];if(!Z)return q;let Y=Q.slice(Q.indexOf("::")+2);return{processor:q,statement:Y}}function w9({expression:Q,depth:Z=5}){if(Z<=0)return null;let X=/^([a-z][a-z0-9_-]*)::([^\s][\s\S]*)$/,q;if(X.test(Q))q=Q.match(X);else return null;let Y=q[1],J=q[2],H=w9({expression:J,depth:Z-1}),W={processor:Y,statement:J,expression:Q};if(H)W.next=H;return W}function S9(Q){if(!Q)return[];let Z=S9(Q.next);return Z.push(Q.processor),Z}function T9({expression:Q}){let Z=w9({expression:Q});if(!Z)return null;let X=Z;while(X&&X.next)X=X.next;let q={processor:Z.processor,statement:Z.statement,expression:Z.expression,process:{statement:X.statement,order:S9(Z)}};if(Z.next)q.next=Z.next;return q}function A5(Q,Z){let X=Q.statement,q=/([a-z][a-z0-9_-]*)::([a-zA-Z_$][a-zA-Z0-9_$]*)/g;return X=X.replace(q,(Y,J,H)=>{if(Z[J]){let W=Z[J];if(typeof W==="function")return W(H);if(typeof W==="string")return W.replace(/\{stmt\}/g,H)}return Y}),X}function d6({expression:Q,useGrammar:Z=!0,multiline:X=!0,transform:q}){if(typeof Q!=="string")Q=String(Q);if(X)Q=Q.replace(/\s+/g," ").trim();let Y;if(Z)try{Y=j9(Q)}catch(J){Y=T9({expression:Q})}else Y=T9({expression:Q});if(!Y)return null;if(q){if(q[Y.processor]&&!Y.next){let J=q[Y.processor];if(typeof J==="function")Y.transformed=J(Y.statement);else if(typeof J==="string")Y.transformed=J.replace(/\{stmt\}/g,Y.statement)}else if(Y.statement)Y.transformed=A5(Y,q)}return Y}import Y1 from"@fnet/yaml";import J1 from"chalk";var n9=h(m9(),1);var t0=(Q)=>{if(typeof Q!=="string")throw TypeError("invalid pattern");if(Q.length>65536)throw TypeError("pattern is too long")};var T5={"[: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]},e0=(Q)=>Q.replace(/[[\]\\-]/g,"\\$&"),w5=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),c9=(Q)=>Q.join(""),l9=(Q,Z)=>{let X=Z;if(Q.charAt(X)!=="[")throw Error("not in a brace expression");let q=[],Y=[],J=X+1,H=!1,W=!1,V=!1,K=!1,_=X,G="";Q:while(J<Q.length){let A=Q.charAt(J);if((A==="!"||A==="^")&&J===X+1){K=!0,J++;continue}if(A==="]"&&H&&!V){_=J+1;break}if(H=!0,A==="\\"){if(!V){V=!0,J++;continue}}if(A==="["&&!V){for(let[U,[B,M,R]]of Object.entries(T5))if(Q.startsWith(U,J)){if(G)return["$.",!1,Q.length-X,!0];if(J+=U.length,R)Y.push(B);else q.push(B);W=W||M;continue Q}}if(V=!1,G){if(A>G)q.push(e0(G)+"-"+e0(A));else if(A===G)q.push(e0(A));G="",J++;continue}if(Q.startsWith("-]",J+1)){q.push(e0(A+"-")),J+=2;continue}if(Q.startsWith("-",J+1)){G=A,J+=2;continue}q.push(e0(A)),J++}if(_<J)return["",!1,0,!1];if(!q.length&&!Y.length)return["$.",!1,Q.length-X,!0];if(Y.length===0&&q.length===1&&/^\\?.$/.test(q[0])&&!K){let A=q[0].length===2?q[0].slice(-1):q[0];return[w5(A),!1,_-X,!1]}let z="["+(K?"^":"")+c9(q)+"]",O="["+(K?"":"^")+c9(Y)+"]";return[q.length&&Y.length?"("+z+"|"+O+")":q.length?z:O,W,_-X,!0]};var z0=(Q,{windowsPathsNoEscape:Z=!1}={})=>{return Z?Q.replace(/\[([^\/\\])\]/g,"$1"):Q.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var S5=new Set(["!","?","+","*","@"]),d9=(Q)=>S5.has(Q),N5="(?!(?:^|/)\\.\\.?(?:$|/))",w8="(?!\\.)",P5=new Set(["[","."]),b5=new Set(["..","."]),D5=new Set("().*{}+?[]^$\\!"),k5=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),a6="[^/]",p9=a6+"*?",i9=a6+"+?";class r{type;#Z;#Q;#X=!1;#q=[];#J;#C;#I;#K=!1;#G;#V;#z=!1;constructor(Q,Z,X={}){if(this.type=Q,Q)this.#Q=!0;if(this.#J=Z,this.#Z=this.#J?this.#J.#Z:this,this.#G=this.#Z===this?X:this.#Z.#G,this.#I=this.#Z===this?[]:this.#Z.#I,Q==="!"&&!this.#Z.#K)this.#I.push(this);this.#C=this.#J?this.#J.#q.length:0}get hasMagic(){if(this.#Q!==void 0)return this.#Q;for(let Q of this.#q){if(typeof Q==="string")continue;if(Q.type||Q.hasMagic)return this.#Q=!0}return this.#Q}toString(){if(this.#V!==void 0)return this.#V;if(!this.type)return this.#V=this.#q.map((Q)=>String(Q)).join("");else return this.#V=this.type+"("+this.#q.map((Q)=>String(Q)).join("|")+")"}#Y(){if(this!==this.#Z)throw Error("should only call on root");if(this.#K)return this;this.toString(),this.#K=!0;let Q;while(Q=this.#I.pop()){if(Q.type!=="!")continue;let Z=Q,X=Z.#J;while(X){for(let q=Z.#C+1;!X.type&&q<X.#q.length;q++)for(let Y of Q.#q){if(typeof Y==="string")throw Error("string part in extglob AST??");Y.copyIn(X.#q[q])}Z=X,X=Z.#J}}return this}push(...Q){for(let Z of Q){if(Z==="")continue;if(typeof Z!=="string"&&!(Z instanceof r&&Z.#J===this))throw Error("invalid part: "+Z);this.#q.push(Z)}}toJSON(){let Q=this.type===null?this.#q.slice().map((Z)=>typeof Z==="string"?Z:Z.toJSON()):[this.type,...this.#q.map((Z)=>Z.toJSON())];if(this.isStart()&&!this.type)Q.unshift([]);if(this.isEnd()&&(this===this.#Z||this.#Z.#K&&this.#J?.type==="!"))Q.push({});return Q}isStart(){if(this.#Z===this)return!0;if(!this.#J?.isStart())return!1;if(this.#C===0)return!0;let Q=this.#J;for(let Z=0;Z<this.#C;Z++){let X=Q.#q[Z];if(!(X instanceof r&&X.type==="!"))return!1}return!0}isEnd(){if(this.#Z===this)return!0;if(this.#J?.type==="!")return!0;if(!this.#J?.isEnd())return!1;if(!this.type)return this.#J?.isEnd();let Q=this.#J?this.#J.#q.length:0;return this.#C===Q-1}copyIn(Q){if(typeof Q==="string")this.push(Q);else this.push(Q.clone(this))}clone(Q){let Z=new r(this.type,Q);for(let X of this.#q)Z.copyIn(X);return Z}static#O(Q,Z,X,q){let Y=!1,J=!1,H=-1,W=!1;if(Z.type===null){let z=X,O="";while(z<Q.length){let $=Q.charAt(z++);if(Y||$==="\\"){Y=!Y,O+=$;continue}if(J){if(z===H+1){if($==="^"||$==="!")W=!0}else if($==="]"&&!(z===H+2&&W))J=!1;O+=$;continue}else if($==="["){J=!0,H=z,W=!1,O+=$;continue}if(!q.noext&&d9($)&&Q.charAt(z)==="("){Z.push(O),O="";let A=new r($,Z);z=r.#O(Q,A,z,q),Z.push(A);continue}O+=$}return Z.push(O),z}let V=X+1,K=new r(null,Z),_=[],G="";while(V<Q.length){let z=Q.charAt(V++);if(Y||z==="\\"){Y=!Y,G+=z;continue}if(J){if(V===H+1){if(z==="^"||z==="!")W=!0}else if(z==="]"&&!(V===H+2&&W))J=!1;G+=z;continue}else if(z==="["){J=!0,H=V,W=!1,G+=z;continue}if(d9(z)&&Q.charAt(V)==="("){K.push(G),G="";let O=new r(z,K);K.push(O),V=r.#O(Q,O,V,q);continue}if(z==="|"){K.push(G),G="",_.push(K),K=new r(null,Z);continue}if(z===")"){if(G===""&&Z.#q.length===0)Z.#z=!0;return K.push(G),G="",Z.push(..._,K),V}G+=z}return Z.type=null,Z.#Q=void 0,Z.#q=[Q.substring(X-1)],V}static fromGlob(Q,Z={}){let X=new r(null,void 0,Z);return r.#O(Q,X,0,Z),X}toMMPattern(){if(this!==this.#Z)return this.#Z.toMMPattern();let Q=this.toString(),[Z,X,q,Y]=this.toRegExpSource();if(!(q||this.#Q||this.#G.nocase&&!this.#G.nocaseMagicOnly&&Q.toUpperCase()!==Q.toLowerCase()))return X;let H=(this.#G.nocase?"i":"")+(Y?"u":"");return Object.assign(new RegExp(`^${Z}$`,H),{_src:Z,_glob:Q})}get options(){return this.#G}toRegExpSource(Q){let Z=Q??!!this.#G.dot;if(this.#Z===this)this.#Y();if(!this.type){let W=this.isStart()&&this.isEnd(),V=this.#q.map((z)=>{let[O,$,A,U]=typeof z==="string"?r.#$(z,this.#Q,W):z.toRegExpSource(Q);return this.#Q=this.#Q||A,this.#X=this.#X||U,O}).join(""),K="";if(this.isStart()){if(typeof this.#q[0]==="string"){if(!(this.#q.length===1&&b5.has(this.#q[0]))){let O=P5,$=Z&&O.has(V.charAt(0))||V.startsWith("\\.")&&O.has(V.charAt(2))||V.startsWith("\\.\\.")&&O.has(V.charAt(4)),A=!Z&&!Q&&O.has(V.charAt(0));K=$?N5:A?w8:""}}}let _="";if(this.isEnd()&&this.#Z.#K&&this.#J?.type==="!")_="(?:$|\\/)";return[K+V+_,z0(V),this.#Q=!!this.#Q,this.#X]}let X=this.type==="*"||this.type==="+",q=this.type==="!"?"(?:(?!(?:":"(?:",Y=this.#M(Z);if(this.isStart()&&this.isEnd()&&!Y&&this.type!=="!"){let W=this.toString();return this.#q=[W],this.type=null,this.#Q=void 0,[W,z0(this.toString()),!1,!1]}let J=!X||Q||Z||!w8?"":this.#M(!0);if(J===Y)J="";if(J)Y=`(?:${Y})(?:${J})*?`;let H="";if(this.type==="!"&&this.#z)H=(this.isStart()&&!Z?w8:"")+i9;else{let W=this.type==="!"?"))"+(this.isStart()&&!Z&&!Q?w8:"")+p9+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&J?")":this.type==="*"&&J?")?":`)${this.type}`;H=q+Y+W}return[H,z0(Y),this.#Q=!!this.#Q,this.#X]}#M(Q){return this.#q.map((Z)=>{if(typeof Z==="string")throw Error("string type in extglob ast??");let[X,q,Y,J]=Z.toRegExpSource(Q);return this.#X=this.#X||J,X}).filter((Z)=>!(this.isStart()&&this.isEnd())||!!Z).join("|")}static#$(Q,Z,X=!1){let q=!1,Y="",J=!1;for(let H=0;H<Q.length;H++){let W=Q.charAt(H);if(q){q=!1,Y+=(D5.has(W)?"\\":"")+W;continue}if(W==="\\"){if(H===Q.length-1)Y+="\\\\";else q=!0;continue}if(W==="["){let[V,K,_,G]=l9(Q,H);if(_){Y+=V,J=J||K,H+=_-1,Z=Z||G;continue}}if(W==="*"){if(X&&Q==="*")Y+=i9;else Y+=p9;Z=!0;continue}if(W==="?"){Y+=a6,Z=!0;continue}Y+=k5(W)}return[Y,z0(Q),!!Z,J]}}var m0=(Q,{windowsPathsNoEscape:Z=!1}={})=>{return Z?Q.replace(/[?*()[\]]/g,"[$&]"):Q.replace(/[?*()[\]\\]/g,"\\$&")};var Q0=(Q,Z,X={})=>{if(t0(Z),!X.nocomment&&Z.charAt(0)==="#")return!1;return new H0(Z,X).match(Q)},v5=/^\*+([^+@!?\*\[\(]*)$/,y5=(Q)=>(Z)=>!Z.startsWith(".")&&Z.endsWith(Q),E5=(Q)=>(Z)=>Z.endsWith(Q),x5=(Q)=>{return Q=Q.toLowerCase(),(Z)=>!Z.startsWith(".")&&Z.toLowerCase().endsWith(Q)},u5=(Q)=>{return Q=Q.toLowerCase(),(Z)=>Z.toLowerCase().endsWith(Q)},f5=/^\*+\.\*+$/,h5=(Q)=>!Q.startsWith(".")&&Q.includes("."),g5=(Q)=>Q!=="."&&Q!==".."&&Q.includes("."),m5=/^\.\*+$/,c5=(Q)=>Q!=="."&&Q!==".."&&Q.startsWith("."),l5=/^\*+$/,d5=(Q)=>Q.length!==0&&!Q.startsWith("."),p5=(Q)=>Q.length!==0&&Q!=="."&&Q!=="..",i5=/^\?+([^+@!?\*\[\(]*)?$/,a5=([Q,Z=""])=>{let X=s9([Q]);if(!Z)return X;return Z=Z.toLowerCase(),(q)=>X(q)&&q.toLowerCase().endsWith(Z)},r5=([Q,Z=""])=>{let X=o9([Q]);if(!Z)return X;return Z=Z.toLowerCase(),(q)=>X(q)&&q.toLowerCase().endsWith(Z)},n5=([Q,Z=""])=>{let X=o9([Q]);return!Z?X:(q)=>X(q)&&q.endsWith(Z)},s5=([Q,Z=""])=>{let X=s9([Q]);return!Z?X:(q)=>X(q)&&q.endsWith(Z)},s9=([Q])=>{let Z=Q.length;return(X)=>X.length===Z&&!X.startsWith(".")},o9=([Q])=>{let Z=Q.length;return(X)=>X.length===Z&&X!=="."&&X!==".."},t9=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",a9={win32:{sep:"\\"},posix:{sep:"/"}},o5=t9==="win32"?a9.win32.sep:a9.posix.sep;Q0.sep=o5;var n=Symbol("globstar **");Q0.GLOBSTAR=n;var t5="[^/]",e5=t5+"*?",Q4="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Z4="(?:(?!(?:\\/|^)\\.).)*?",X4=(Q,Z={})=>(X)=>Q0(X,Q,Z);Q0.filter=X4;var W0=(Q,Z={})=>Object.assign({},Q,Z),q4=(Q)=>{if(!Q||typeof Q!=="object"||!Object.keys(Q).length)return Q0;let Z=Q0;return Object.assign((q,Y,J={})=>Z(q,Y,W0(Q,J)),{Minimatch:class extends Z.Minimatch{constructor(Y,J={}){super(Y,W0(Q,J))}static defaults(Y){return Z.defaults(W0(Q,Y)).Minimatch}},AST:class extends Z.AST{constructor(Y,J,H={}){super(Y,J,W0(Q,H))}static fromGlob(Y,J={}){return Z.AST.fromGlob(Y,W0(Q,J))}},unescape:(q,Y={})=>Z.unescape(q,W0(Q,Y)),escape:(q,Y={})=>Z.escape(q,W0(Q,Y)),filter:(q,Y={})=>Z.filter(q,W0(Q,Y)),defaults:(q)=>Z.defaults(W0(Q,q)),makeRe:(q,Y={})=>Z.makeRe(q,W0(Q,Y)),braceExpand:(q,Y={})=>Z.braceExpand(q,W0(Q,Y)),match:(q,Y,J={})=>Z.match(q,Y,W0(Q,J)),sep:Z.sep,GLOBSTAR:n})};Q0.defaults=q4;var e9=(Q,Z={})=>{if(t0(Q),Z.nobrace||!/\{(?:(?!\{).)*\}/.test(Q))return[Q];return n9.default(Q)};Q0.braceExpand=e9;var Y4=(Q,Z={})=>new H0(Q,Z).makeRe();Q0.makeRe=Y4;var J4=(Q,Z,X={})=>{let q=new H0(Z,X);if(Q=Q.filter((Y)=>q.match(Y)),q.options.nonull&&!Q.length)Q.push(Z);return Q};Q0.match=J4;var r9=/[?*]|[+@!]\(.*?\)|\[|\]/,W4=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class H0{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(Q,Z={}){if(t0(Q),Z=Z||{},this.options=Z,this.pattern=Q,this.platform=Z.platform||t9,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z.allowWindowsEscape===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!Z.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!Z.nonegate,this.comment=!1,this.empty=!1,this.partial=!!Z.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=Z.windowsNoMagicRoot!==void 0?Z.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 Q of this.set)for(let Z of Q)if(typeof Z!=="string")return!0;return!1}debug(...Q){}make(){let Q=this.pattern,Z=this.options;if(!Z.nocomment&&Q.charAt(0)==="#"){this.comment=!0;return}if(!Q){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],Z.debug)this.debug=(...Y)=>console.error(...Y);this.debug(this.pattern,this.globSet);let X=this.globSet.map((Y)=>this.slashSplit(Y));this.globParts=this.preprocess(X),this.debug(this.pattern,this.globParts);let q=this.globParts.map((Y,J,H)=>{if(this.isWindows&&this.windowsNoMagicRoot){let W=Y[0]===""&&Y[1]===""&&(Y[2]==="?"||!r9.test(Y[2]))&&!r9.test(Y[3]),V=/^[a-z]:/i.test(Y[0]);if(W)return[...Y.slice(0,4),...Y.slice(4).map((K)=>this.parse(K))];else if(V)return[Y[0],...Y.slice(1).map((K)=>this.parse(K))]}return Y.map((W)=>this.parse(W))});if(this.debug(this.pattern,q),this.set=q.filter((Y)=>Y.indexOf(!1)===-1),this.isWindows)for(let Y=0;Y<this.set.length;Y++){let J=this.set[Y];if(J[0]===""&&J[1]===""&&this.globParts[Y][2]==="?"&&typeof J[3]==="string"&&/^[a-z]:$/i.test(J[3]))J[2]="?"}this.debug(this.pattern,this.set)}preprocess(Q){if(this.options.noglobstar){for(let X=0;X<Q.length;X++)for(let q=0;q<Q[X].length;q++)if(Q[X][q]==="**")Q[X][q]="*"}let{optimizationLevel:Z=1}=this.options;if(Z>=2)Q=this.firstPhasePreProcess(Q),Q=this.secondPhasePreProcess(Q);else if(Z>=1)Q=this.levelOneOptimize(Q);else Q=this.adjascentGlobstarOptimize(Q);return Q}adjascentGlobstarOptimize(Q){return Q.map((Z)=>{let X=-1;while((X=Z.indexOf("**",X+1))!==-1){let q=X;while(Z[q+1]==="**")q++;if(q!==X)Z.splice(X,q-X)}return Z})}levelOneOptimize(Q){return Q.map((Z)=>{return Z=Z.reduce((X,q)=>{let Y=X[X.length-1];if(q==="**"&&Y==="**")return X;if(q===".."){if(Y&&Y!==".."&&Y!=="."&&Y!=="**")return X.pop(),X}return X.push(q),X},[]),Z.length===0?[""]:Z})}levelTwoFileOptimize(Q){if(!Array.isArray(Q))Q=this.slashSplit(Q);let Z=!1;do{if(Z=!1,!this.preserveMultipleSlashes){for(let q=1;q<Q.length-1;q++){let Y=Q[q];if(q===1&&Y===""&&Q[0]==="")continue;if(Y==="."||Y==="")Z=!0,Q.splice(q,1),q--}if(Q[0]==="."&&Q.length===2&&(Q[1]==="."||Q[1]===""))Z=!0,Q.pop()}let X=0;while((X=Q.indexOf("..",X+1))!==-1){let q=Q[X-1];if(q&&q!=="."&&q!==".."&&q!=="**")Z=!0,Q.splice(X-1,2),X-=2}}while(Z);return Q.length===0?[""]:Q}firstPhasePreProcess(Q){let Z=!1;do{Z=!1;for(let X of Q){let q=-1;while((q=X.indexOf("**",q+1))!==-1){let J=q;while(X[J+1]==="**")J++;if(J>q)X.splice(q+1,J-q);let H=X[q+1],W=X[q+2],V=X[q+3];if(H!=="..")continue;if(!W||W==="."||W===".."||!V||V==="."||V==="..")continue;Z=!0,X.splice(q,1);let K=X.slice(0);K[q]="**",Q.push(K),q--}if(!this.preserveMultipleSlashes){for(let J=1;J<X.length-1;J++){let H=X[J];if(J===1&&H===""&&X[0]==="")continue;if(H==="."||H==="")Z=!0,X.splice(J,1),J--}if(X[0]==="."&&X.length===2&&(X[1]==="."||X[1]===""))Z=!0,X.pop()}let Y=0;while((Y=X.indexOf("..",Y+1))!==-1){let J=X[Y-1];if(J&&J!=="."&&J!==".."&&J!=="**"){Z=!0;let W=Y===1&&X[Y+1]==="**"?["."]:[];if(X.splice(Y-1,2,...W),X.length===0)X.push("");Y-=2}}}}while(Z);return Q}secondPhasePreProcess(Q){for(let Z=0;Z<Q.length-1;Z++)for(let X=Z+1;X<Q.length;X++){let q=this.partsMatch(Q[Z],Q[X],!this.preserveMultipleSlashes);if(q){Q[Z]=[],Q[X]=q;break}}return Q.filter((Z)=>Z.length)}partsMatch(Q,Z,X=!1){let q=0,Y=0,J=[],H="";while(q<Q.length&&Y<Z.length)if(Q[q]===Z[Y])J.push(H==="b"?Z[Y]:Q[q]),q++,Y++;else if(X&&Q[q]==="**"&&Z[Y]===Q[q+1])J.push(Q[q]),q++;else if(X&&Z[Y]==="**"&&Q[q]===Z[Y+1])J.push(Z[Y]),Y++;else if(Q[q]==="*"&&Z[Y]&&(this.options.dot||!Z[Y].startsWith("."))&&Z[Y]!=="**"){if(H==="b")return!1;H="a",J.push(Q[q]),q++,Y++}else if(Z[Y]==="*"&&Q[q]&&(this.options.dot||!Q[q].startsWith("."))&&Q[q]!=="**"){if(H==="a")return!1;H="b",J.push(Z[Y]),q++,Y++}else return!1;return Q.length===Z.length&&J}parseNegate(){if(this.nonegate)return;let Q=this.pattern,Z=!1,X=0;for(let q=0;q<Q.length&&Q.charAt(q)==="!";q++)Z=!Z,X++;if(X)this.pattern=Q.slice(X);this.negate=Z}matchOne(Q,Z,X=!1){let q=this.options;if(this.isWindows){let $=typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0]),A=!$&&Q[0]===""&&Q[1]===""&&Q[2]==="?"&&/^[a-z]:$/i.test(Q[3]),U=typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0]),B=!U&&Z[0]===""&&Z[1]===""&&Z[2]==="?"&&typeof Z[3]==="string"&&/^[a-z]:$/i.test(Z[3]),M=A?3:$?0:void 0,R=B?3:U?0:void 0;if(typeof M==="number"&&typeof R==="number"){let[F,w]=[Q[M],Z[R]];if(F.toLowerCase()===w.toLowerCase()){if(Z[R]=F,R>M)Z=Z.slice(R);else if(M>R)Q=Q.slice(M)}}}let{optimizationLevel:Y=1}=this.options;if(Y>=2)Q=this.levelTwoFileOptimize(Q);this.debug("matchOne",this,{file:Q,pattern:Z}),this.debug("matchOne",Q.length,Z.length);for(var J=0,H=0,W=Q.length,V=Z.length;J<W&&H<V;J++,H++){this.debug("matchOne loop");var K=Z[H],_=Q[J];if(this.debug(Z,K,_),K===!1)return!1;if(K===n){this.debug("GLOBSTAR",[Z,K,_]);var G=J,z=H+1;if(z===V){this.debug("** at the end");for(;J<W;J++)if(Q[J]==="."||Q[J]===".."||!q.dot&&Q[J].charAt(0)===".")return!1;return!0}while(G<W){var O=Q[G];if(this.debug(`
10
+ globstar while`,Q,G,Z,z,O),this.matchOne(Q.slice(G),Z.slice(z),X))return this.debug("globstar found match!",G,W,O),!0;else{if(O==="."||O===".."||!q.dot&&O.charAt(0)==="."){this.debug("dot detected!",Q,G,Z,z);break}this.debug("globstar swallow a segment, and continue"),G++}}if(X){if(this.debug(`
11
+ >>> no match, partial?`,Q,G,Z,z),G===W)return!0}return!1}let $;if(typeof K==="string")$=_===K,this.debug("string match",K,_,$);else $=K.test(_),this.debug("pattern match",K,_,$);if(!$)return!1}if(J===W&&H===V)return!0;else if(J===W)return X;else if(H===V)return J===W-1&&Q[J]==="";else throw Error("wtf?")}braceExpand(){return e9(this.pattern,this.options)}parse(Q){t0(Q);let Z=this.options;if(Q==="**")return n;if(Q==="")return"";let X,q=null;if(X=Q.match(l5))q=Z.dot?p5:d5;else if(X=Q.match(v5))q=(Z.nocase?Z.dot?u5:x5:Z.dot?E5:y5)(X[1]);else if(X=Q.match(i5))q=(Z.nocase?Z.dot?r5:a5:Z.dot?n5:s5)(X);else if(X=Q.match(f5))q=Z.dot?g5:h5;else if(X=Q.match(m5))q=c5;let Y=r.fromGlob(Q,this.options).toMMPattern();if(q&&typeof Y==="object")Reflect.defineProperty(Y,"test",{value:q});return Y}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let Q=this.set;if(!Q.length)return this.regexp=!1,this.regexp;let Z=this.options,X=Z.noglobstar?e5:Z.dot?Q4:Z4,q=new Set(Z.nocase?["i"]:[]),Y=Q.map((W)=>{let V=W.map((K)=>{if(K instanceof RegExp)for(let _ of K.flags.split(""))q.add(_);return typeof K==="string"?W4(K):K===n?n:K._src});return V.forEach((K,_)=>{let G=V[_+1],z=V[_-1];if(K!==n||z===n)return;if(z===void 0)if(G!==void 0&&G!==n)V[_+1]="(?:\\/|"+X+"\\/)?"+G;else V[_]=X;else if(G===void 0)V[_-1]=z+"(?:\\/|"+X+")?";else if(G!==n)V[_-1]=z+"(?:\\/|\\/"+X+"\\/)"+G,V[_+1]=n}),V.filter((K)=>K!==n).join("/")}).join("|"),[J,H]=Q.length>1?["(?:",")"]:["",""];if(Y="^"+J+Y+H+"$",this.negate)Y="^(?!"+Y+").+$";try{this.regexp=new RegExp(Y,[...q].join(""))}catch(W){this.regexp=!1}return this.regexp}slashSplit(Q){if(this.preserveMultipleSlashes)return Q.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(Q))return["",...Q.split(/\/+/)];else return Q.split(/\/+/)}match(Q,Z=this.partial){if(this.debug("match",Q,this.pattern),this.comment)return!1;if(this.empty)return Q==="";if(Q==="/"&&Z)return!0;let X=this.options;if(this.isWindows)Q=Q.split("\\").join("/");let q=this.slashSplit(Q);this.debug(this.pattern,"split",q);let Y=this.set;this.debug(this.pattern,"set",Y);let J=q[q.length-1];if(!J)for(let H=q.length-2;!J&&H>=0;H--)J=q[H];for(let H=0;H<Y.length;H++){let W=Y[H],V=q;if(X.matchBase&&W.length===1)V=[J];if(this.matchOne(V,W,Z)){if(X.flipNegate)return!0;return!this.negate}}if(X.flipNegate)return!1;return this.negate}static defaults(Q){return Q0.defaults(Q).Minimatch}}Q0.AST=r;Q0.Minimatch=H0;Q0.escape=m0;Q0.unescape=z0;import{fileURLToPath as f4}from"node:url";var c0=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,ZQ=new Set,r6=typeof process==="object"&&!!process?process:{},XQ=(Q,Z,X,q)=>{typeof r6.emitWarning==="function"?r6.emitWarning(Q,Z,X,q):console.error(`[${X}] ${Z}: ${Q}`)},S8=globalThis.AbortController,QQ=globalThis.AbortSignal;if(typeof S8>"u"){QQ=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(q,Y){this._onabort.push(Y)}},S8=class{constructor(){Z()}signal=new QQ;abort(q){if(this.signal.aborted)return;this.signal.reason=q,this.signal.aborted=!0;for(let Y of this.signal._onabort)Y(q);this.signal.onabort?.(q)}};let Q=r6.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",Z=()=>{if(!Q)return;Q=!1,XQ("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",Z)}}var H4=(Q)=>!ZQ.has(Q),sq=Symbol("type"),P0=(Q)=>Q&&Q===Math.floor(Q)&&Q>0&&isFinite(Q),qQ=(Q)=>!P0(Q)?null:Q<=Math.pow(2,8)?Uint8Array:Q<=Math.pow(2,16)?Uint16Array:Q<=Math.pow(2,32)?Uint32Array:Q<=Number.MAX_SAFE_INTEGER?Q8:null;class Q8 extends Array{constructor(Q){super(Q);this.fill(0)}}class l0{heap;length;static#Z=!1;static create(Q){let Z=qQ(Q);if(!Z)return[];l0.#Z=!0;let X=new l0(Q,Z);return l0.#Z=!1,X}constructor(Q,Z){if(!l0.#Z)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new Z(Q),this.length=0}push(Q){this.heap[this.length++]=Q}pop(){return this.heap[--this.length]}}class Z8{#Z;#Q;#X;#q;#J;#C;#I;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#K;#G;#V;#z;#Y;#O;#M;#$;#A;#j;#R;#F;#H;#L;#_;#T;#B;#b;static unsafeExposeInternals(Q){return{starts:Q.#H,ttls:Q.#L,sizes:Q.#F,keyMap:Q.#V,keyList:Q.#z,valList:Q.#Y,next:Q.#O,prev:Q.#M,get head(){return Q.#$},get tail(){return Q.#A},free:Q.#j,isBackgroundFetch:(Z)=>Q.#U(Z),backgroundFetch:(Z,X,q,Y)=>Q.#E(Z,X,q,Y),moveToTail:(Z)=>Q.#f(Z),indexes:(Z)=>Q.#N(Z),rindexes:(Z)=>Q.#P(Z),isStale:(Z)=>Q.#S(Z)}}get max(){return this.#Z}get maxSize(){return this.#Q}get calculatedSize(){return this.#G}get size(){return this.#K}get fetchMethod(){return this.#C}get memoMethod(){return this.#I}get dispose(){return this.#X}get onInsert(){return this.#q}get disposeAfter(){return this.#J}constructor(Q){let{max:Z=0,ttl:X,ttlResolution:q=1,ttlAutopurge:Y,updateAgeOnGet:J,updateAgeOnHas:H,allowStale:W,dispose:V,onInsert:K,disposeAfter:_,noDisposeOnSet:G,noUpdateTTL:z,maxSize:O=0,maxEntrySize:$=0,sizeCalculation:A,fetchMethod:U,memoMethod:B,noDeleteOnFetchRejection:M,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:F,allowStaleOnFetchAbort:w,ignoreFetchAbort:y}=Q;if(Z!==0&&!P0(Z))throw TypeError("max option must be a nonnegative integer");let v=Z?qQ(Z):Array;if(!v)throw Error("invalid max value: "+Z);if(this.#Z=Z,this.#Q=O,this.maxEntrySize=$||this.#Q,this.sizeCalculation=A,this.sizeCalculation){if(!this.#Q&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw TypeError("sizeCalculation set to non-function")}if(B!==void 0&&typeof B!=="function")throw TypeError("memoMethod must be a function if defined");if(this.#I=B,U!==void 0&&typeof U!=="function")throw TypeError("fetchMethod must be a function if specified");if(this.#C=U,this.#T=!!U,this.#V=new Map,this.#z=Array(Z).fill(void 0),this.#Y=Array(Z).fill(void 0),this.#O=new v(Z),this.#M=new v(Z),this.#$=0,this.#A=0,this.#j=l0.create(Z),this.#K=0,this.#G=0,typeof V==="function")this.#X=V;if(typeof K==="function")this.#q=K;if(typeof _==="function")this.#J=_,this.#R=[];else this.#J=void 0,this.#R=void 0;if(this.#_=!!this.#X,this.#b=!!this.#q,this.#B=!!this.#J,this.noDisposeOnSet=!!G,this.noUpdateTTL=!!z,this.noDeleteOnFetchRejection=!!M,this.allowStaleOnFetchRejection=!!F,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!y,this.maxEntrySize!==0){if(this.#Q!==0){if(!P0(this.#Q))throw TypeError("maxSize must be a positive integer if specified")}if(!P0(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#g()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!J,this.updateAgeOnHas=!!H,this.ttlResolution=P0(q)||q===0?q:1,this.ttlAutopurge=!!Y,this.ttl=X||0,this.ttl){if(!P0(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#W()}if(this.#Z===0&&this.ttl===0&&this.#Q===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Z&&!this.#Q){if(H4("LRU_CACHE_UNBOUNDED"))ZQ.add("LRU_CACHE_UNBOUNDED"),XQ("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",Z8)}}getRemainingTTL(Q){return this.#V.has(Q)?1/0:0}#W(){let Q=new Q8(this.#Z),Z=new Q8(this.#Z);this.#L=Q,this.#H=Z,this.#D=(Y,J,H=c0.now())=>{if(Z[Y]=J!==0?H:0,Q[Y]=J,J!==0&&this.ttlAutopurge){let W=setTimeout(()=>{if(this.#S(Y))this.#k(this.#z[Y],"expire")},J+1);if(W.unref)W.unref()}},this.#v=(Y)=>{Z[Y]=Q[Y]!==0?c0.now():0},this.#w=(Y,J)=>{if(Q[J]){let H=Q[J],W=Z[J];if(!H||!W)return;Y.ttl=H,Y.start=W,Y.now=X||q();let V=Y.now-W;Y.remainingTTL=H-V}};let X=0,q=()=>{let Y=c0.now();if(this.ttlResolution>0){X=Y;let J=setTimeout(()=>X=0,this.ttlResolution);if(J.unref)J.unref()}return Y};this.getRemainingTTL=(Y)=>{let J=this.#V.get(Y);if(J===void 0)return 0;let H=Q[J],W=Z[J];if(!H||!W)return 1/0;let V=(X||q())-W;return H-V},this.#S=(Y)=>{let J=Z[Y],H=Q[Y];return!!H&&!!J&&(X||q())-J>H}}#v=()=>{};#w=()=>{};#D=()=>{};#S=()=>!1;#g(){let Q=new Q8(this.#Z);this.#G=0,this.#F=Q,this.#y=(Z)=>{this.#G-=Q[Z],Q[Z]=0},this.#m=(Z,X,q,Y)=>{if(this.#U(X))return 0;if(!P0(q))if(Y){if(typeof Y!=="function")throw TypeError("sizeCalculation must be a function");if(q=Y(X,Z),!P0(q))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return q},this.#x=(Z,X,q)=>{if(Q[Z]=X,this.#Q){let Y=this.#Q-Q[Z];while(this.#G>Y)this.#u(!0)}if(this.#G+=Q[Z],q)q.entrySize=X,q.totalCalculatedSize=this.#G}}#y=(Q)=>{};#x=(Q,Z,X)=>{};#m=(Q,Z,X,q)=>{if(X||q)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#N({allowStale:Q=this.allowStale}={}){if(this.#K)for(let Z=this.#A;;){if(!this.#c(Z))break;if(Q||!this.#S(Z))yield Z;if(Z===this.#$)break;else Z=this.#M[Z]}}*#P({allowStale:Q=this.allowStale}={}){if(this.#K)for(let Z=this.#$;;){if(!this.#c(Z))break;if(Q||!this.#S(Z))yield Z;if(Z===this.#A)break;else Z=this.#O[Z]}}#c(Q){return Q!==void 0&&this.#V.get(this.#z[Q])===Q}*entries(){for(let Q of this.#N())if(this.#Y[Q]!==void 0&&this.#z[Q]!==void 0&&!this.#U(this.#Y[Q]))yield[this.#z[Q],this.#Y[Q]]}*rentries(){for(let Q of this.#P())if(this.#Y[Q]!==void 0&&this.#z[Q]!==void 0&&!this.#U(this.#Y[Q]))yield[this.#z[Q],this.#Y[Q]]}*keys(){for(let Q of this.#N()){let Z=this.#z[Q];if(Z!==void 0&&!this.#U(this.#Y[Q]))yield Z}}*rkeys(){for(let Q of this.#P()){let Z=this.#z[Q];if(Z!==void 0&&!this.#U(this.#Y[Q]))yield Z}}*values(){for(let Q of this.#N())if(this.#Y[Q]!==void 0&&!this.#U(this.#Y[Q]))yield this.#Y[Q]}*rvalues(){for(let Q of this.#P())if(this.#Y[Q]!==void 0&&!this.#U(this.#Y[Q]))yield this.#Y[Q]}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Q,Z={}){for(let X of this.#N()){let q=this.#Y[X],Y=this.#U(q)?q.__staleWhileFetching:q;if(Y===void 0)continue;if(Q(Y,this.#z[X],this))return this.get(this.#z[X],Z)}}forEach(Q,Z=this){for(let X of this.#N()){let q=this.#Y[X],Y=this.#U(q)?q.__staleWhileFetching:q;if(Y===void 0)continue;Q.call(Z,Y,this.#z[X],this)}}rforEach(Q,Z=this){for(let X of this.#P()){let q=this.#Y[X],Y=this.#U(q)?q.__staleWhileFetching:q;if(Y===void 0)continue;Q.call(Z,Y,this.#z[X],this)}}purgeStale(){let Q=!1;for(let Z of this.#P({allowStale:!0}))if(this.#S(Z))this.#k(this.#z[Z],"expire"),Q=!0;return Q}info(Q){let Z=this.#V.get(Q);if(Z===void 0)return;let X=this.#Y[Z],q=this.#U(X)?X.__staleWhileFetching:X;if(q===void 0)return;let Y={value:q};if(this.#L&&this.#H){let J=this.#L[Z],H=this.#H[Z];if(J&&H){let W=J-(c0.now()-H);Y.ttl=W,Y.start=Date.now()}}if(this.#F)Y.size=this.#F[Z];return Y}dump(){let Q=[];for(let Z of this.#N({allowStale:!0})){let X=this.#z[Z],q=this.#Y[Z],Y=this.#U(q)?q.__staleWhileFetching:q;if(Y===void 0||X===void 0)continue;let J={value:Y};if(this.#L&&this.#H){J.ttl=this.#L[Z];let H=c0.now()-this.#H[Z];J.start=Math.floor(Date.now()-H)}if(this.#F)J.size=this.#F[Z];Q.unshift([X,J])}return Q}load(Q){this.clear();for(let[Z,X]of Q){if(X.start){let q=Date.now()-X.start;X.start=c0.now()-q}this.set(Z,X.value,X)}}set(Q,Z,X={}){if(Z===void 0)return this.delete(Q),this;let{ttl:q=this.ttl,start:Y,noDisposeOnSet:J=this.noDisposeOnSet,sizeCalculation:H=this.sizeCalculation,status:W}=X,{noUpdateTTL:V=this.noUpdateTTL}=X,K=this.#m(Q,Z,X.size||0,H);if(this.maxEntrySize&&K>this.maxEntrySize){if(W)W.set="miss",W.maxEntrySizeExceeded=!0;return this.#k(Q,"set"),this}let _=this.#K===0?void 0:this.#V.get(Q);if(_===void 0){if(_=this.#K===0?this.#A:this.#j.length!==0?this.#j.pop():this.#K===this.#Z?this.#u(!1):this.#K,this.#z[_]=Q,this.#Y[_]=Z,this.#V.set(Q,_),this.#O[this.#A]=_,this.#M[_]=this.#A,this.#A=_,this.#K++,this.#x(_,K,W),W)W.set="add";if(V=!1,this.#b)this.#q?.(Z,Q,"add")}else{this.#f(_);let G=this.#Y[_];if(Z!==G){if(this.#T&&this.#U(G)){G.__abortController.abort(Error("replaced"));let{__staleWhileFetching:z}=G;if(z!==void 0&&!J){if(this.#_)this.#X?.(z,Q,"set");if(this.#B)this.#R?.push([z,Q,"set"])}}else if(!J){if(this.#_)this.#X?.(G,Q,"set");if(this.#B)this.#R?.push([G,Q,"set"])}if(this.#y(_),this.#x(_,K,W),this.#Y[_]=Z,W){W.set="replace";let z=G&&this.#U(G)?G.__staleWhileFetching:G;if(z!==void 0)W.oldValue=z}}else if(W)W.set="update";if(this.#b)this.onInsert?.(Z,Q,Z===G?"update":"replace")}if(q!==0&&!this.#L)this.#W();if(this.#L){if(!V)this.#D(_,q,Y);if(W)this.#w(W,_)}if(!J&&this.#B&&this.#R){let G=this.#R,z;while(z=G?.shift())this.#J?.(...z)}return this}pop(){try{while(this.#K){let Q=this.#Y[this.#$];if(this.#u(!0),this.#U(Q)){if(Q.__staleWhileFetching)return Q.__staleWhileFetching}else if(Q!==void 0)return Q}}finally{if(this.#B&&this.#R){let Q=this.#R,Z;while(Z=Q?.shift())this.#J?.(...Z)}}}#u(Q){let Z=this.#$,X=this.#z[Z],q=this.#Y[Z];if(this.#T&&this.#U(q))q.__abortController.abort(Error("evicted"));else if(this.#_||this.#B){if(this.#_)this.#X?.(q,X,"evict");if(this.#B)this.#R?.push([q,X,"evict"])}if(this.#y(Z),Q)this.#z[Z]=void 0,this.#Y[Z]=void 0,this.#j.push(Z);if(this.#K===1)this.#$=this.#A=0,this.#j.length=0;else this.#$=this.#O[Z];return this.#V.delete(X),this.#K--,Z}has(Q,Z={}){let{updateAgeOnHas:X=this.updateAgeOnHas,status:q}=Z,Y=this.#V.get(Q);if(Y!==void 0){let J=this.#Y[Y];if(this.#U(J)&&J.__staleWhileFetching===void 0)return!1;if(!this.#S(Y)){if(X)this.#v(Y);if(q)q.has="hit",this.#w(q,Y);return!0}else if(q)q.has="stale",this.#w(q,Y)}else if(q)q.has="miss";return!1}peek(Q,Z={}){let{allowStale:X=this.allowStale}=Z,q=this.#V.get(Q);if(q===void 0||!X&&this.#S(q))return;let Y=this.#Y[q];return this.#U(Y)?Y.__staleWhileFetching:Y}#E(Q,Z,X,q){let Y=Z===void 0?void 0:this.#Y[Z];if(this.#U(Y))return Y;let J=new S8,{signal:H}=X;H?.addEventListener("abort",()=>J.abort(H.reason),{signal:J.signal});let W={signal:J.signal,options:X,context:q},V=($,A=!1)=>{let{aborted:U}=J.signal,B=X.ignoreFetchAbort&&$!==void 0;if(X.status)if(U&&!A){if(X.status.fetchAborted=!0,X.status.fetchError=J.signal.reason,B)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(U&&!B&&!A)return _(J.signal.reason);let M=z;if(this.#Y[Z]===z)if($===void 0)if(M.__staleWhileFetching)this.#Y[Z]=M.__staleWhileFetching;else this.#k(Q,"fetch");else{if(X.status)X.status.fetchUpdated=!0;this.set(Q,$,W.options)}return $},K=($)=>{if(X.status)X.status.fetchRejected=!0,X.status.fetchError=$;return _($)},_=($)=>{let{aborted:A}=J.signal,U=A&&X.allowStaleOnFetchAbort,B=U||X.allowStaleOnFetchRejection,M=B||X.noDeleteOnFetchRejection,R=z;if(this.#Y[Z]===z){if(!M||R.__staleWhileFetching===void 0)this.#k(Q,"fetch");else if(!U)this.#Y[Z]=R.__staleWhileFetching}if(B){if(X.status&&R.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return R.__staleWhileFetching}else if(R.__returned===R)throw $},G=($,A)=>{let U=this.#C?.(Q,Y,W);if(U&&U instanceof Promise)U.then((B)=>$(B===void 0?void 0:B),A);J.signal.addEventListener("abort",()=>{if(!X.ignoreFetchAbort||X.allowStaleOnFetchAbort){if($(void 0),X.allowStaleOnFetchAbort)$=(B)=>V(B,!0)}})};if(X.status)X.status.fetchDispatched=!0;let z=new Promise(G).then(V,K),O=Object.assign(z,{__abortController:J,__staleWhileFetching:Y,__returned:void 0});if(Z===void 0)this.set(Q,O,{...W.options,status:void 0}),Z=this.#V.get(Q);else this.#Y[Z]=O;return O}#U(Q){if(!this.#T)return!1;let Z=Q;return!!Z&&Z instanceof Promise&&Z.hasOwnProperty("__staleWhileFetching")&&Z.__abortController instanceof S8}async fetch(Q,Z={}){let{allowStale:X=this.allowStale,updateAgeOnGet:q=this.updateAgeOnGet,noDeleteOnStaleGet:Y=this.noDeleteOnStaleGet,ttl:J=this.ttl,noDisposeOnSet:H=this.noDisposeOnSet,size:W=0,sizeCalculation:V=this.sizeCalculation,noUpdateTTL:K=this.noUpdateTTL,noDeleteOnFetchRejection:_=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:G=this.allowStaleOnFetchRejection,ignoreFetchAbort:z=this.ignoreFetchAbort,allowStaleOnFetchAbort:O=this.allowStaleOnFetchAbort,context:$,forceRefresh:A=!1,status:U,signal:B}=Z;if(!this.#T){if(U)U.fetch="get";return this.get(Q,{allowStale:X,updateAgeOnGet:q,noDeleteOnStaleGet:Y,status:U})}let M={allowStale:X,updateAgeOnGet:q,noDeleteOnStaleGet:Y,ttl:J,noDisposeOnSet:H,size:W,sizeCalculation:V,noUpdateTTL:K,noDeleteOnFetchRejection:_,allowStaleOnFetchRejection:G,allowStaleOnFetchAbort:O,ignoreFetchAbort:z,status:U,signal:B},R=this.#V.get(Q);if(R===void 0){if(U)U.fetch="miss";let F=this.#E(Q,R,M,$);return F.__returned=F}else{let F=this.#Y[R];if(this.#U(F)){let J0=X&&F.__staleWhileFetching!==void 0;if(U){if(U.fetch="inflight",J0)U.returnedStale=!0}return J0?F.__staleWhileFetching:F.__returned=F}let w=this.#S(R);if(!A&&!w){if(U)U.fetch="hit";if(this.#f(R),q)this.#v(R);if(U)this.#w(U,R);return F}let y=this.#E(Q,R,M,$),Y0=y.__staleWhileFetching!==void 0&&X;if(U){if(U.fetch=w?"stale":"refresh",Y0&&w)U.returnedStale=!0}return Y0?y.__staleWhileFetching:y.__returned=y}}async forceFetch(Q,Z={}){let X=await this.fetch(Q,Z);if(X===void 0)throw Error("fetch() returned undefined");return X}memo(Q,Z={}){let X=this.#I;if(!X)throw Error("no memoMethod provided to constructor");let{context:q,forceRefresh:Y,...J}=Z,H=this.get(Q,J);if(!Y&&H!==void 0)return H;let W=X(Q,H,{options:J,context:q});return this.set(Q,W,J),W}get(Q,Z={}){let{allowStale:X=this.allowStale,updateAgeOnGet:q=this.updateAgeOnGet,noDeleteOnStaleGet:Y=this.noDeleteOnStaleGet,status:J}=Z,H=this.#V.get(Q);if(H!==void 0){let W=this.#Y[H],V=this.#U(W);if(J)this.#w(J,H);if(this.#S(H)){if(J)J.get="stale";if(!V){if(!Y)this.#k(Q,"expire");if(J&&X)J.returnedStale=!0;return X?W:void 0}else{if(J&&X&&W.__staleWhileFetching!==void 0)J.returnedStale=!0;return X?W.__staleWhileFetching:void 0}}else{if(J)J.get="hit";if(V)return W.__staleWhileFetching;if(this.#f(H),q)this.#v(H);return W}}else if(J)J.get="miss"}#l(Q,Z){this.#M[Z]=Q,this.#O[Q]=Z}#f(Q){if(Q!==this.#A){if(Q===this.#$)this.#$=this.#O[Q];else this.#l(this.#M[Q],this.#O[Q]);this.#l(this.#A,Q),this.#A=Q}}delete(Q){return this.#k(Q,"delete")}#k(Q,Z){let X=!1;if(this.#K!==0){let q=this.#V.get(Q);if(q!==void 0)if(X=!0,this.#K===1)this.#h(Z);else{this.#y(q);let Y=this.#Y[q];if(this.#U(Y))Y.__abortController.abort(Error("deleted"));else if(this.#_||this.#B){if(this.#_)this.#X?.(Y,Q,Z);if(this.#B)this.#R?.push([Y,Q,Z])}if(this.#V.delete(Q),this.#z[q]=void 0,this.#Y[q]=void 0,q===this.#A)this.#A=this.#M[q];else if(q===this.#$)this.#$=this.#O[q];else{let J=this.#M[q];this.#O[J]=this.#O[q];let H=this.#O[q];this.#M[H]=this.#M[q]}this.#K--,this.#j.push(q)}}if(this.#B&&this.#R?.length){let q=this.#R,Y;while(Y=q?.shift())this.#J?.(...Y)}return X}clear(){return this.#h("delete")}#h(Q){for(let Z of this.#P({allowStale:!0})){let X=this.#Y[Z];if(this.#U(X))X.__abortController.abort(Error("deleted"));else{let q=this.#z[Z];if(this.#_)this.#X?.(X,q,Q);if(this.#B)this.#R?.push([X,q,Q])}}if(this.#V.clear(),this.#Y.fill(void 0),this.#z.fill(void 0),this.#L&&this.#H)this.#L.fill(0),this.#H.fill(0);if(this.#F)this.#F.fill(0);if(this.#$=0,this.#A=0,this.#j.length=0,this.#G=0,this.#K=0,this.#B&&this.#R){let Z=this.#R,X;while(X=Z?.shift())this.#J?.(...X)}}}import{posix as B4,win32 as Y7}from"node:path";import{fileURLToPath as R4}from"node:url";import{lstatSync as I4,readdir as C4,readdirSync as L4,readlinkSync as F4,realpathSync as j4}from"fs";import*as T4 from"node:fs";import{lstat as S4,readdir as N4,readlink as P4,realpath as b4}from"node:fs/promises";import{EventEmitter as Q7}from"node:events";import VQ from"node:stream";import{StringDecoder as V4}from"node:string_decoder";var YQ=typeof process==="object"&&process?process:{stdout:null,stderr:null},K4=(Q)=>!!Q&&typeof Q==="object"&&(Q instanceof x0||Q instanceof VQ||_4(Q)||z4(Q)),_4=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof Q7&&typeof Q.pipe==="function"&&Q.pipe!==VQ.Writable.prototype.pipe,z4=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof Q7&&typeof Q.write==="function"&&typeof Q.end==="function",L0=Symbol("EOF"),F0=Symbol("maybeEmitEnd"),b0=Symbol("emittedEnd"),N8=Symbol("emittingEnd"),X8=Symbol("emittedError"),P8=Symbol("closed"),JQ=Symbol("read"),b8=Symbol("flush"),WQ=Symbol("flushChunk"),G0=Symbol("encoding"),d0=Symbol("decoder"),p=Symbol("flowing"),q8=Symbol("paused"),p0=Symbol("resume"),i=Symbol("buffer"),Z0=Symbol("pipes"),a=Symbol("bufferLength"),n6=Symbol("bufferPush"),D8=Symbol("bufferShift"),e=Symbol("objectMode"),m=Symbol("destroyed"),s6=Symbol("error"),o6=Symbol("emitData"),HQ=Symbol("emitEnd"),t6=Symbol("emitEnd2"),O0=Symbol("async"),e6=Symbol("abort"),k8=Symbol("aborted"),Y8=Symbol("signal"),E0=Symbol("dataListeners"),q0=Symbol("discarded"),J8=(Q)=>Promise.resolve().then(Q),G4=(Q)=>Q(),U4=(Q)=>Q==="end"||Q==="finish"||Q==="prefinish",$4=(Q)=>Q instanceof ArrayBuffer||!!Q&&typeof Q==="object"&&Q.constructor&&Q.constructor.name==="ArrayBuffer"&&Q.byteLength>=0,M4=(Q)=>!Buffer.isBuffer(Q)&&ArrayBuffer.isView(Q);class Z7{src;dest;opts;ondrain;constructor(Q,Z,X){this.src=Q,this.dest=Z,this.opts=X,this.ondrain=()=>Q[p0](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(Q){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class KQ extends Z7{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(Q,Z,X){super(Q,Z,X);this.proxyErrors=(q)=>Z.emit("error",q),Q.on("error",this.proxyErrors)}}var O4=(Q)=>!!Q.objectMode,A4=(Q)=>!Q.objectMode&&!!Q.encoding&&Q.encoding!=="buffer";class x0 extends Q7{[p]=!1;[q8]=!1;[Z0]=[];[i]=[];[e];[G0];[O0];[d0];[L0]=!1;[b0]=!1;[N8]=!1;[P8]=!1;[X8]=null;[a]=0;[m]=!1;[Y8];[k8]=!1;[E0]=0;[q0]=!1;writable=!0;readable=!0;constructor(...Q){let Z=Q[0]||{};super();if(Z.objectMode&&typeof Z.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if(O4(Z))this[e]=!0,this[G0]=null;else if(A4(Z))this[G0]=Z.encoding,this[e]=!1;else this[e]=!1,this[G0]=null;if(this[O0]=!!Z.async,this[d0]=this[G0]?new V4(this[G0]):null,Z&&Z.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[i]});if(Z&&Z.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[Z0]});let{signal:X}=Z;if(X)if(this[Y8]=X,X.aborted)this[e6]();else X.addEventListener("abort",()=>this[e6]())}get bufferLength(){return this[a]}get encoding(){return this[G0]}set encoding(Q){throw Error("Encoding must be set at instantiation time")}setEncoding(Q){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[e]}set objectMode(Q){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[O0]}set["async"](Q){this[O0]=this[O0]||!!Q}[e6](){this[k8]=!0,this.emit("abort",this[Y8]?.reason),this.destroy(this[Y8]?.reason)}get aborted(){return this[k8]}set aborted(Q){}write(Q,Z,X){if(this[k8])return!1;if(this[L0])throw Error("write after end");if(this[m])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof Z==="function")X=Z,Z="utf8";if(!Z)Z="utf8";let q=this[O0]?J8:G4;if(!this[e]&&!Buffer.isBuffer(Q)){if(M4(Q))Q=Buffer.from(Q.buffer,Q.byteOffset,Q.byteLength);else if($4(Q))Q=Buffer.from(Q);else if(typeof Q!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[e]){if(this[p]&&this[a]!==0)this[b8](!0);if(this[p])this.emit("data",Q);else this[n6](Q);if(this[a]!==0)this.emit("readable");if(X)q(X);return this[p]}if(!Q.length){if(this[a]!==0)this.emit("readable");if(X)q(X);return this[p]}if(typeof Q==="string"&&!(Z===this[G0]&&!this[d0]?.lastNeed))Q=Buffer.from(Q,Z);if(Buffer.isBuffer(Q)&&this[G0])Q=this[d0].write(Q);if(this[p]&&this[a]!==0)this[b8](!0);if(this[p])this.emit("data",Q);else this[n6](Q);if(this[a]!==0)this.emit("readable");if(X)q(X);return this[p]}read(Q){if(this[m])return null;if(this[q0]=!1,this[a]===0||Q===0||Q&&Q>this[a])return this[F0](),null;if(this[e])Q=null;if(this[i].length>1&&!this[e])this[i]=[this[G0]?this[i].join(""):Buffer.concat(this[i],this[a])];let Z=this[JQ](Q||null,this[i][0]);return this[F0](),Z}[JQ](Q,Z){if(this[e])this[D8]();else{let X=Z;if(Q===X.length||Q===null)this[D8]();else if(typeof X==="string")this[i][0]=X.slice(Q),Z=X.slice(0,Q),this[a]-=Q;else this[i][0]=X.subarray(Q),Z=X.subarray(0,Q),this[a]-=Q}if(this.emit("data",Z),!this[i].length&&!this[L0])this.emit("drain");return Z}end(Q,Z,X){if(typeof Q==="function")X=Q,Q=void 0;if(typeof Z==="function")X=Z,Z="utf8";if(Q!==void 0)this.write(Q,Z);if(X)this.once("end",X);if(this[L0]=!0,this.writable=!1,this[p]||!this[q8])this[F0]();return this}[p0](){if(this[m])return;if(!this[E0]&&!this[Z0].length)this[q0]=!0;if(this[q8]=!1,this[p]=!0,this.emit("resume"),this[i].length)this[b8]();else if(this[L0])this[F0]();else this.emit("drain")}resume(){return this[p0]()}pause(){this[p]=!1,this[q8]=!0,this[q0]=!1}get destroyed(){return this[m]}get flowing(){return this[p]}get paused(){return this[q8]}[n6](Q){if(this[e])this[a]+=1;else this[a]+=Q.length;this[i].push(Q)}[D8](){if(this[e])this[a]-=1;else this[a]-=this[i][0].length;return this[i].shift()}[b8](Q=!1){do;while(this[WQ](this[D8]())&&this[i].length);if(!Q&&!this[i].length&&!this[L0])this.emit("drain")}[WQ](Q){return this.emit("data",Q),this[p]}pipe(Q,Z){if(this[m])return Q;this[q0]=!1;let X=this[b0];if(Z=Z||{},Q===YQ.stdout||Q===YQ.stderr)Z.end=!1;else Z.end=Z.end!==!1;if(Z.proxyErrors=!!Z.proxyErrors,X){if(Z.end)Q.end()}else if(this[Z0].push(!Z.proxyErrors?new Z7(this,Q,Z):new KQ(this,Q,Z)),this[O0])J8(()=>this[p0]());else this[p0]();return Q}unpipe(Q){let Z=this[Z0].find((X)=>X.dest===Q);if(Z){if(this[Z0].length===1){if(this[p]&&this[E0]===0)this[p]=!1;this[Z0]=[]}else this[Z0].splice(this[Z0].indexOf(Z),1);Z.unpipe()}}addListener(Q,Z){return this.on(Q,Z)}on(Q,Z){let X=super.on(Q,Z);if(Q==="data"){if(this[q0]=!1,this[E0]++,!this[Z0].length&&!this[p])this[p0]()}else if(Q==="readable"&&this[a]!==0)super.emit("readable");else if(U4(Q)&&this[b0])super.emit(Q),this.removeAllListeners(Q);else if(Q==="error"&&this[X8]){let q=Z;if(this[O0])J8(()=>q.call(this,this[X8]));else q.call(this,this[X8])}return X}removeListener(Q,Z){return this.off(Q,Z)}off(Q,Z){let X=super.off(Q,Z);if(Q==="data"){if(this[E0]=this.listeners("data").length,this[E0]===0&&!this[q0]&&!this[Z0].length)this[p]=!1}return X}removeAllListeners(Q){let Z=super.removeAllListeners(Q);if(Q==="data"||Q===void 0){if(this[E0]=0,!this[q0]&&!this[Z0].length)this[p]=!1}return Z}get emittedEnd(){return this[b0]}[F0](){if(!this[N8]&&!this[b0]&&!this[m]&&this[i].length===0&&this[L0]){if(this[N8]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[P8])this.emit("close");this[N8]=!1}}emit(Q,...Z){let X=Z[0];if(Q!=="error"&&Q!=="close"&&Q!==m&&this[m])return!1;else if(Q==="data")return!this[e]&&!X?!1:this[O0]?(J8(()=>this[o6](X)),!0):this[o6](X);else if(Q==="end")return this[HQ]();else if(Q==="close"){if(this[P8]=!0,!this[b0]&&!this[m])return!1;let Y=super.emit("close");return this.removeAllListeners("close"),Y}else if(Q==="error"){this[X8]=X,super.emit(s6,X);let Y=!this[Y8]||this.listeners("error").length?super.emit("error",X):!1;return this[F0](),Y}else if(Q==="resume"){let Y=super.emit("resume");return this[F0](),Y}else if(Q==="finish"||Q==="prefinish"){let Y=super.emit(Q);return this.removeAllListeners(Q),Y}let q=super.emit(Q,...Z);return this[F0](),q}[o6](Q){for(let X of this[Z0])if(X.dest.write(Q)===!1)this.pause();let Z=this[q0]?!1:super.emit("data",Q);return this[F0](),Z}[HQ](){if(this[b0])return!1;return this[b0]=!0,this.readable=!1,this[O0]?(J8(()=>this[t6]()),!0):this[t6]()}[t6](){if(this[d0]){let Z=this[d0].end();if(Z){for(let X of this[Z0])X.dest.write(Z);if(!this[q0])super.emit("data",Z)}}for(let Z of this[Z0])Z.end();let Q=super.emit("end");return this.removeAllListeners("end"),Q}async collect(){let Q=Object.assign([],{dataLength:0});if(!this[e])Q.dataLength=0;let Z=this.promise();return this.on("data",(X)=>{if(Q.push(X),!this[e])Q.dataLength+=X.length}),await Z,Q}async concat(){if(this[e])throw Error("cannot concat in objectMode");let Q=await this.collect();return this[G0]?Q.join(""):Buffer.concat(Q,Q.dataLength)}async promise(){return new Promise((Q,Z)=>{this.on(m,()=>Z(Error("stream destroyed"))),this.on("error",(X)=>Z(X)),this.on("end",()=>Q())})}[Symbol.asyncIterator](){this[q0]=!1;let Q=!1,Z=async()=>{return this.pause(),Q=!0,{value:void 0,done:!0}};return{next:()=>{if(Q)return Z();let q=this.read();if(q!==null)return Promise.resolve({done:!1,value:q});if(this[L0])return Z();let Y,J,H=(_)=>{this.off("data",W),this.off("end",V),this.off(m,K),Z(),J(_)},W=(_)=>{this.off("error",H),this.off("end",V),this.off(m,K),this.pause(),Y({value:_,done:!!this[L0]})},V=()=>{this.off("error",H),this.off("data",W),this.off(m,K),Z(),Y({done:!0,value:void 0})},K=()=>H(Error("stream destroyed"));return new Promise((_,G)=>{J=G,Y=_,this.once(m,K),this.once("error",H),this.once("end",V),this.once("data",W)})},throw:Z,return:Z,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[q0]=!1;let Q=!1,Z=()=>{return this.pause(),this.off(s6,Z),this.off(m,Z),this.off("end",Z),Q=!0,{done:!0,value:void 0}},X=()=>{if(Q)return Z();let q=this.read();return q===null?Z():{done:!1,value:q}};return this.once("end",Z),this.once(s6,Z),this.once(m,Z),{next:X,throw:Z,return:Z,[Symbol.iterator](){return this}}}destroy(Q){if(this[m]){if(Q)this.emit("error",Q);else this.emit(m);return this}this[m]=!0,this[q0]=!0,this[i].length=0,this[a]=0;let Z=this;if(typeof Z.close==="function"&&!this[P8])Z.close();if(Q)this.emit("error",Q);else this.emit(m);return this}static get isStream(){return K4}}var w4=j4.native,H8={lstatSync:I4,readdir:C4,readdirSync:L4,readlinkSync:F4,realpathSync:w4,promises:{lstat:S4,readdir:N4,readlink:P4,realpath:b4}},$Q=(Q)=>!Q||Q===H8||Q===T4?H8:{...H8,...Q,promises:{...H8.promises,...Q.promises||{}}},MQ=/^\\\\\?\\([a-z]:)\\?$/i,D4=(Q)=>Q.replace(/\//g,"\\").replace(MQ,"$1\\"),k4=/[\\\/]/,K0=0,OQ=1,AQ=2,A0=4,BQ=6,RQ=8,u0=10,IQ=12,V0=15,W8=~V0,X7=16,_Q=32,V8=64,U0=128,v8=256,E8=512,zQ=V8|U0|E8,v4=1023,q7=(Q)=>Q.isFile()?RQ:Q.isDirectory()?A0:Q.isSymbolicLink()?u0:Q.isCharacterDevice()?AQ:Q.isBlockDevice()?BQ:Q.isSocket()?IQ:Q.isFIFO()?OQ:K0,GQ=new Map,K8=(Q)=>{let Z=GQ.get(Q);if(Z)return Z;let X=Q.normalize("NFKD");return GQ.set(Q,X),X},UQ=new Map,y8=(Q)=>{let Z=UQ.get(Q);if(Z)return Z;let X=K8(Q.toLowerCase());return UQ.set(Q,X),X};class J7 extends Z8{constructor(){super({max:256})}}class CQ extends Z8{constructor(Q=16384){super({maxSize:Q,sizeCalculation:(Z)=>Z.length+1})}}var LQ=Symbol("PathScurry setAsCwd");class X0{name;root;roots;parent;nocase;isCWD=!1;#Z;#Q;get dev(){return this.#Q}#X;get mode(){return this.#X}#q;get nlink(){return this.#q}#J;get uid(){return this.#J}#C;get gid(){return this.#C}#I;get rdev(){return this.#I}#K;get blksize(){return this.#K}#G;get ino(){return this.#G}#V;get size(){return this.#V}#z;get blocks(){return this.#z}#Y;get atimeMs(){return this.#Y}#O;get mtimeMs(){return this.#O}#M;get ctimeMs(){return this.#M}#$;get birthtimeMs(){return this.#$}#A;get atime(){return this.#A}#j;get mtime(){return this.#j}#R;get ctime(){return this.#R}#F;get birthtime(){return this.#F}#H;#L;#_;#T;#B;#b;#W;#v;#w;#D;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Q,Z=K0,X,q,Y,J,H){if(this.name=Q,this.#H=Y?y8(Q):K8(Q),this.#W=Z&v4,this.nocase=Y,this.roots=q,this.root=X||this,this.#v=J,this.#_=H.fullpath,this.#B=H.relative,this.#b=H.relativePosix,this.parent=H.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=$Q(H.fs)}depth(){if(this.#L!==void 0)return this.#L;if(!this.parent)return this.#L=0;return this.#L=this.parent.depth()+1}childrenCache(){return this.#v}resolve(Q){if(!Q)return this;let Z=this.getRootString(Q),q=Q.substring(Z.length).split(this.splitSep);return Z?this.getRoot(Z).#S(q):this.#S(q)}#S(Q){let Z=this;for(let X of Q)Z=Z.child(X);return Z}children(){let Q=this.#v.get(this);if(Q)return Q;let Z=Object.assign([],{provisional:0});return this.#v.set(this,Z),this.#W&=~X7,Z}child(Q,Z){if(Q===""||Q===".")return this;if(Q==="..")return this.parent||this;let X=this.children(),q=this.nocase?y8(Q):K8(Q);for(let W of X)if(W.#H===q)return W;let Y=this.parent?this.sep:"",J=this.#_?this.#_+Y+Q:void 0,H=this.newChild(Q,K0,{...Z,parent:this,fullpath:J});if(!this.canReaddir())H.#W|=U0;return X.push(H),H}relative(){if(this.isCWD)return"";if(this.#B!==void 0)return this.#B;let Q=this.name,Z=this.parent;if(!Z)return this.#B=this.name;let X=Z.relative();return X+(!X||!Z.parent?"":this.sep)+Q}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#b!==void 0)return this.#b;let Q=this.name,Z=this.parent;if(!Z)return this.#b=this.fullpathPosix();let X=Z.relativePosix();return X+(!X||!Z.parent?"":"/")+Q}fullpath(){if(this.#_!==void 0)return this.#_;let Q=this.name,Z=this.parent;if(!Z)return this.#_=this.name;let q=Z.fullpath()+(!Z.parent?"":this.sep)+Q;return this.#_=q}fullpathPosix(){if(this.#T!==void 0)return this.#T;if(this.sep==="/")return this.#T=this.fullpath();if(!this.parent){let q=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(q))return this.#T=`//?/${q}`;else return this.#T=q}let Q=this.parent,Z=Q.fullpathPosix(),X=Z+(!Z||!Q.parent?"":"/")+this.name;return this.#T=X}isUnknown(){return(this.#W&V0)===K0}isType(Q){return this[`is${Q}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#W&V0)===RQ}isDirectory(){return(this.#W&V0)===A0}isCharacterDevice(){return(this.#W&V0)===AQ}isBlockDevice(){return(this.#W&V0)===BQ}isFIFO(){return(this.#W&V0)===OQ}isSocket(){return(this.#W&V0)===IQ}isSymbolicLink(){return(this.#W&u0)===u0}lstatCached(){return this.#W&_Q?this:void 0}readlinkCached(){return this.#w}realpathCached(){return this.#D}readdirCached(){let Q=this.children();return Q.slice(0,Q.provisional)}canReadlink(){if(this.#w)return!0;if(!this.parent)return!1;let Q=this.#W&V0;return!(Q!==K0&&Q!==u0||this.#W&v8||this.#W&U0)}calledReaddir(){return!!(this.#W&X7)}isENOENT(){return!!(this.#W&U0)}isNamed(Q){return!this.nocase?this.#H===K8(Q):this.#H===y8(Q)}async readlink(){let Q=this.#w;if(Q)return Q;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=await this.#Z.promises.readlink(this.fullpath()),X=(await this.parent.realpath())?.resolve(Z);if(X)return this.#w=X}catch(Z){this.#u(Z.code);return}}readlinkSync(){let Q=this.#w;if(Q)return Q;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=this.#Z.readlinkSync(this.fullpath()),X=this.parent.realpathSync()?.resolve(Z);if(X)return this.#w=X}catch(Z){this.#u(Z.code);return}}#g(Q){this.#W|=X7;for(let Z=Q.provisional;Z<Q.length;Z++){let X=Q[Z];if(X)X.#y()}}#y(){if(this.#W&U0)return;this.#W=(this.#W|U0)&W8,this.#x()}#x(){let Q=this.children();Q.provisional=0;for(let Z of Q)Z.#y()}#m(){this.#W|=E8,this.#N()}#N(){if(this.#W&V8)return;let Q=this.#W;if((Q&V0)===A0)Q&=W8;this.#W=Q|V8,this.#x()}#P(Q=""){if(Q==="ENOTDIR"||Q==="EPERM")this.#N();else if(Q==="ENOENT")this.#y();else this.children().provisional=0}#c(Q=""){if(Q==="ENOTDIR")this.parent.#N();else if(Q==="ENOENT")this.#y()}#u(Q=""){let Z=this.#W;if(Z|=v8,Q==="ENOENT")Z|=U0;if(Q==="EINVAL"||Q==="UNKNOWN")Z&=W8;if(this.#W=Z,Q==="ENOTDIR"&&this.parent)this.parent.#N()}#E(Q,Z){return this.#l(Q,Z)||this.#U(Q,Z)}#U(Q,Z){let X=q7(Q),q=this.newChild(Q.name,X,{parent:this}),Y=q.#W&V0;if(Y!==A0&&Y!==u0&&Y!==K0)q.#W|=V8;return Z.unshift(q),Z.provisional++,q}#l(Q,Z){for(let X=Z.provisional;X<Z.length;X++){let q=Z[X];if((this.nocase?y8(Q.name):K8(Q.name))!==q.#H)continue;return this.#f(Q,q,X,Z)}}#f(Q,Z,X,q){let Y=Z.name;if(Z.#W=Z.#W&W8|q7(Q),Y!==Q.name)Z.name=Q.name;if(X!==q.provisional){if(X===q.length-1)q.pop();else q.splice(X,1);q.unshift(Z)}return q.provisional++,Z}async lstat(){if((this.#W&U0)===0)try{return this.#k(await this.#Z.promises.lstat(this.fullpath())),this}catch(Q){this.#c(Q.code)}}lstatSync(){if((this.#W&U0)===0)try{return this.#k(this.#Z.lstatSync(this.fullpath())),this}catch(Q){this.#c(Q.code)}}#k(Q){let{atime:Z,atimeMs:X,birthtime:q,birthtimeMs:Y,blksize:J,blocks:H,ctime:W,ctimeMs:V,dev:K,gid:_,ino:G,mode:z,mtime:O,mtimeMs:$,nlink:A,rdev:U,size:B,uid:M}=Q;this.#A=Z,this.#Y=X,this.#F=q,this.#$=Y,this.#K=J,this.#z=H,this.#R=W,this.#M=V,this.#Q=K,this.#C=_,this.#G=G,this.#X=z,this.#j=O,this.#O=$,this.#q=A,this.#I=U,this.#V=B,this.#J=M;let R=q7(Q);if(this.#W=this.#W&W8|R|_Q,R!==K0&&R!==A0&&R!==u0)this.#W|=V8}#h=[];#p=!1;#i(Q){this.#p=!1;let Z=this.#h.slice();this.#h.length=0,Z.forEach((X)=>X(null,Q))}readdirCB(Q,Z=!1){if(!this.canReaddir()){if(Z)Q(null,[]);else queueMicrotask(()=>Q(null,[]));return}let X=this.children();if(this.calledReaddir()){let Y=X.slice(0,X.provisional);if(Z)Q(null,Y);else queueMicrotask(()=>Q(null,Y));return}if(this.#h.push(Q),this.#p)return;this.#p=!0;let q=this.fullpath();this.#Z.readdir(q,{withFileTypes:!0},(Y,J)=>{if(Y)this.#P(Y.code),X.provisional=0;else{for(let H of J)this.#E(H,X);this.#g(X)}this.#i(X.slice(0,X.provisional));return})}#d;async readdir(){if(!this.canReaddir())return[];let Q=this.children();if(this.calledReaddir())return Q.slice(0,Q.provisional);let Z=this.fullpath();if(this.#d)await this.#d;else{let X=()=>{};this.#d=new Promise((q)=>X=q);try{for(let q of await this.#Z.promises.readdir(Z,{withFileTypes:!0}))this.#E(q,Q);this.#g(Q)}catch(q){this.#P(q.code),Q.provisional=0}this.#d=void 0,X()}return Q.slice(0,Q.provisional)}readdirSync(){if(!this.canReaddir())return[];let Q=this.children();if(this.calledReaddir())return Q.slice(0,Q.provisional);let Z=this.fullpath();try{for(let X of this.#Z.readdirSync(Z,{withFileTypes:!0}))this.#E(X,Q);this.#g(Q)}catch(X){this.#P(X.code),Q.provisional=0}return Q.slice(0,Q.provisional)}canReaddir(){if(this.#W&zQ)return!1;let Q=V0&this.#W;if(!(Q===K0||Q===A0||Q===u0))return!1;return!0}shouldWalk(Q,Z){return(this.#W&A0)===A0&&!(this.#W&zQ)&&!Q.has(this)&&(!Z||Z(this))}async realpath(){if(this.#D)return this.#D;if((E8|v8|U0)&this.#W)return;try{let Q=await this.#Z.promises.realpath(this.fullpath());return this.#D=this.resolve(Q)}catch(Q){this.#m()}}realpathSync(){if(this.#D)return this.#D;if((E8|v8|U0)&this.#W)return;try{let Q=this.#Z.realpathSync(this.fullpath());return this.#D=this.resolve(Q)}catch(Q){this.#m()}}[LQ](Q){if(Q===this)return;Q.isCWD=!1,this.isCWD=!0;let Z=new Set([]),X=[],q=this;while(q&&q.parent)Z.add(q),q.#B=X.join(this.sep),q.#b=X.join("/"),q=q.parent,X.push("..");q=Q;while(q&&q.parent&&!Z.has(q))q.#B=void 0,q.#b=void 0,q=q.parent}}class x8 extends X0{sep="\\";splitSep=k4;constructor(Q,Z=K0,X,q,Y,J,H){super(Q,Z,X,q,Y,J,H)}newChild(Q,Z=K0,X={}){return new x8(Q,Z,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Q){return Y7.parse(Q).root}getRoot(Q){if(Q=D4(Q.toUpperCase()),Q===this.root.name)return this.root;for(let[Z,X]of Object.entries(this.roots))if(this.sameRoot(Q,Z))return this.roots[Q]=X;return this.roots[Q]=new _8(Q,this).root}sameRoot(Q,Z=this.root.name){return Q=Q.toUpperCase().replace(/\//g,"\\").replace(MQ,"$1\\"),Q===Z}}class u8 extends X0{splitSep="/";sep="/";constructor(Q,Z=K0,X,q,Y,J,H){super(Q,Z,X,q,Y,J,H)}getRootString(Q){return Q.startsWith("/")?"/":""}getRoot(Q){return this.root}newChild(Q,Z=K0,X={}){return new u8(Q,Z,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class W7{root;rootPath;roots;cwd;#Z;#Q;#X;nocase;#q;constructor(Q=process.cwd(),Z,X,{nocase:q,childrenCacheSize:Y=16384,fs:J=H8}={}){if(this.#q=$Q(J),Q instanceof URL||Q.startsWith("file://"))Q=R4(Q);let H=Z.resolve(Q);this.roots=Object.create(null),this.rootPath=this.parseRootPath(H),this.#Z=new J7,this.#Q=new J7,this.#X=new CQ(Y);let W=H.substring(this.rootPath.length).split(X);if(W.length===1&&!W[0])W.pop();if(q===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=q,this.root=this.newRoot(this.#q),this.roots[this.rootPath]=this.root;let V=this.root,K=W.length-1,_=Z.sep,G=this.rootPath,z=!1;for(let O of W){let $=K--;V=V.child(O,{relative:Array($).fill("..").join(_),relativePosix:Array($).fill("..").join("/"),fullpath:G+=(z?"":_)+O}),z=!0}this.cwd=V}depth(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.depth()}childrenCache(){return this.#X}resolve(...Q){let Z="";for(let Y=Q.length-1;Y>=0;Y--){let J=Q[Y];if(!J||J===".")continue;if(Z=Z?`${J}/${Z}`:J,this.isAbsolute(J))break}let X=this.#Z.get(Z);if(X!==void 0)return X;let q=this.cwd.resolve(Z).fullpath();return this.#Z.set(Z,q),q}resolvePosix(...Q){let Z="";for(let Y=Q.length-1;Y>=0;Y--){let J=Q[Y];if(!J||J===".")continue;if(Z=Z?`${J}/${Z}`:J,this.isAbsolute(J))break}let X=this.#Q.get(Z);if(X!==void 0)return X;let q=this.cwd.resolve(Z).fullpathPosix();return this.#Q.set(Z,q),q}relative(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.relative()}relativePosix(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.relativePosix()}basename(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.name}dirname(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return(Q.parent||Q).fullpath()}async readdir(Q=this.cwd,Z={withFileTypes:!0}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X}=Z;if(!Q.canReaddir())return[];else{let q=await Q.readdir();return X?q:q.map((Y)=>Y.name)}}readdirSync(Q=this.cwd,Z={withFileTypes:!0}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0}=Z;if(!Q.canReaddir())return[];else if(X)return Q.readdirSync();else return Q.readdirSync().map((q)=>q.name)}async lstat(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.lstat()}lstatSync(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.lstatSync()}async readlink(Q=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q.withFileTypes,Q=this.cwd;let X=await Q.readlink();return Z?X:X?.fullpath()}readlinkSync(Q=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q.withFileTypes,Q=this.cwd;let X=Q.readlinkSync();return Z?X:X?.fullpath()}async realpath(Q=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q.withFileTypes,Q=this.cwd;let X=await Q.realpath();return Z?X:X?.fullpath()}realpathSync(Q=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q.withFileTypes,Q=this.cwd;let X=Q.realpathSync();return Z?X:X?.fullpath()}async walk(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z,H=[];if(!Y||Y(Q))H.push(X?Q:Q.fullpath());let W=new Set,V=(_,G)=>{W.add(_),_.readdirCB((z,O)=>{if(z)return G(z);let $=O.length;if(!$)return G();let A=()=>{if(--$===0)G()};for(let U of O){if(!Y||Y(U))H.push(X?U:U.fullpath());if(q&&U.isSymbolicLink())U.realpath().then((B)=>B?.isUnknown()?B.lstat():B).then((B)=>B?.shouldWalk(W,J)?V(B,A):A());else if(U.shouldWalk(W,J))V(U,A);else A()}},!0)},K=Q;return new Promise((_,G)=>{V(K,(z)=>{if(z)return G(z);_(H)})})}walkSync(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z,H=[];if(!Y||Y(Q))H.push(X?Q:Q.fullpath());let W=new Set([Q]);for(let V of W){let K=V.readdirSync();for(let _ of K){if(!Y||Y(_))H.push(X?_:_.fullpath());let G=_;if(_.isSymbolicLink()){if(!(q&&(G=_.realpathSync())))continue;if(G.isUnknown())G.lstatSync()}if(G.shouldWalk(W,J))W.add(G)}}return H}[Symbol.asyncIterator](){return this.iterate()}iterate(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;return this.stream(Q,Z)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z;if(!Y||Y(Q))yield X?Q:Q.fullpath();let H=new Set([Q]);for(let W of H){let V=W.readdirSync();for(let K of V){if(!Y||Y(K))yield X?K:K.fullpath();let _=K;if(K.isSymbolicLink()){if(!(q&&(_=K.realpathSync())))continue;if(_.isUnknown())_.lstatSync()}if(_.shouldWalk(H,J))H.add(_)}}}stream(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z,H=new x0({objectMode:!0});if(!Y||Y(Q))H.write(X?Q:Q.fullpath());let W=new Set,V=[Q],K=0,_=()=>{let G=!1;while(!G){let z=V.shift();if(!z){if(K===0)H.end();return}K++,W.add(z);let O=(A,U,B=!1)=>{if(A)return H.emit("error",A);if(q&&!B){let M=[];for(let R of U)if(R.isSymbolicLink())M.push(R.realpath().then((F)=>F?.isUnknown()?F.lstat():F));if(M.length){Promise.all(M).then(()=>O(null,U,!0));return}}for(let M of U)if(M&&(!Y||Y(M))){if(!H.write(X?M:M.fullpath()))G=!0}K--;for(let M of U){let R=M.realpathCached()||M;if(R.shouldWalk(W,J))V.push(R)}if(G&&!H.flowing)H.once("drain",_);else if(!$)_()},$=!0;z.readdirCB(O,!0),$=!1}};return _(),H}streamSync(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z,H=new x0({objectMode:!0}),W=new Set;if(!Y||Y(Q))H.write(X?Q:Q.fullpath());let V=[Q],K=0,_=()=>{let G=!1;while(!G){let z=V.shift();if(!z){if(K===0)H.end();return}K++,W.add(z);let O=z.readdirSync();for(let $ of O)if(!Y||Y($)){if(!H.write(X?$:$.fullpath()))G=!0}K--;for(let $ of O){let A=$;if($.isSymbolicLink()){if(!(q&&(A=$.realpathSync())))continue;if(A.isUnknown())A.lstatSync()}if(A.shouldWalk(W,J))V.push(A)}}if(G&&!H.flowing)H.once("drain",_)};return _(),H}chdir(Q=this.cwd){let Z=this.cwd;this.cwd=typeof Q==="string"?this.cwd.resolve(Q):Q,this.cwd[LQ](Z)}}class _8 extends W7{sep="\\";constructor(Q=process.cwd(),Z={}){let{nocase:X=!0}=Z;super(Q,Y7,"\\",{...Z,nocase:X});this.nocase=X;for(let q=this.cwd;q;q=q.parent)q.nocase=this.nocase}parseRootPath(Q){return Y7.parse(Q).root.toUpperCase()}newRoot(Q){return new x8(this.rootPath,A0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")||Q.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Q)}}class z8 extends W7{sep="/";constructor(Q=process.cwd(),Z={}){let{nocase:X=!1}=Z;super(Q,B4,"/",{...Z,nocase:X});this.nocase=X}parseRootPath(Q){return"/"}newRoot(Q){return new u8(this.rootPath,A0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")}}class f8 extends z8{constructor(Q=process.cwd(),Z={}){let{nocase:X=!0}=Z;super(Q,{...Z,nocase:X})}}var VY=process.platform==="win32"?x8:u8,FQ=process.platform==="win32"?_8:process.platform==="darwin"?f8:z8;var y4=(Q)=>Q.length>=1,E4=(Q)=>Q.length>=1;class i0{#Z;#Q;#X;length;#q;#J;#C;#I;#K;#G;#V=!0;constructor(Q,Z,X,q){if(!y4(Q))throw TypeError("empty pattern list");if(!E4(Z))throw TypeError("empty glob list");if(Z.length!==Q.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=Q.length,X<0||X>=this.length)throw TypeError("index out of range");if(this.#Z=Q,this.#Q=Z,this.#X=X,this.#q=q,this.#X===0){if(this.isUNC()){let[Y,J,H,W,...V]=this.#Z,[K,_,G,z,...O]=this.#Q;if(V[0]==="")V.shift(),O.shift();let $=[Y,J,H,W,""].join("/"),A=[K,_,G,z,""].join("/");this.#Z=[$,...V],this.#Q=[A,...O],this.length=this.#Z.length}else if(this.isDrive()||this.isAbsolute()){let[Y,...J]=this.#Z,[H,...W]=this.#Q;if(J[0]==="")J.shift(),W.shift();let V=Y+"/",K=H+"/";this.#Z=[V,...J],this.#Q=[K,...W],this.length=this.#Z.length}}}pattern(){return this.#Z[this.#X]}isString(){return typeof this.#Z[this.#X]==="string"}isGlobstar(){return this.#Z[this.#X]===n}isRegExp(){return this.#Z[this.#X]instanceof RegExp}globString(){return this.#C=this.#C||(this.#X===0?this.isAbsolute()?this.#Q[0]+this.#Q.slice(1).join("/"):this.#Q.join("/"):this.#Q.slice(this.#X).join("/"))}hasMore(){return this.length>this.#X+1}rest(){if(this.#J!==void 0)return this.#J;if(!this.hasMore())return this.#J=null;return this.#J=new i0(this.#Z,this.#Q,this.#X+1,this.#q),this.#J.#G=this.#G,this.#J.#K=this.#K,this.#J.#I=this.#I,this.#J}isUNC(){let Q=this.#Z;return this.#K!==void 0?this.#K:this.#K=this.#q==="win32"&&this.#X===0&&Q[0]===""&&Q[1]===""&&typeof Q[2]==="string"&&!!Q[2]&&typeof Q[3]==="string"&&!!Q[3]}isDrive(){let Q=this.#Z;return this.#I!==void 0?this.#I:this.#I=this.#q==="win32"&&this.#X===0&&this.length>1&&typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0])}isAbsolute(){let Q=this.#Z;return this.#G!==void 0?this.#G:this.#G=Q[0]===""&&Q.length>1||this.isDrive()||this.isUNC()}root(){let Q=this.#Z[0];return typeof Q==="string"&&this.isAbsolute()&&this.#X===0?Q:""}checkFollowGlobstar(){return!(this.#X===0||!this.isGlobstar()||!this.#V)}markFollowGlobstar(){if(this.#X===0||!this.isGlobstar()||!this.#V)return!1;return this.#V=!1,!0}}var x4=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class G8{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Q,{nobrace:Z,nocase:X,noext:q,noglobstar:Y,platform:J=x4}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=J,this.mmopts={dot:!0,nobrace:Z,nocase:X,noext:q,noglobstar:Y,optimizationLevel:2,platform:J,nocomment:!0,nonegate:!0};for(let H of Q)this.add(H)}add(Q){let Z=new H0(Q,this.mmopts);for(let X=0;X<Z.set.length;X++){let q=Z.set[X],Y=Z.globParts[X];if(!q||!Y)throw Error("invalid pattern object");while(q[0]==="."&&Y[0]===".")q.shift(),Y.shift();let J=new i0(q,Y,0,this.platform),H=new H0(J.globString(),this.mmopts),W=Y[Y.length-1]==="**",V=J.isAbsolute();if(V)this.absolute.push(H);else this.relative.push(H);if(W)if(V)this.absoluteChildren.push(H);else this.relativeChildren.push(H)}}ignored(Q){let Z=Q.fullpath(),X=`${Z}/`,q=Q.relative()||".",Y=`${q}/`;for(let J of this.relative)if(J.match(q)||J.match(Y))return!0;for(let J of this.absolute)if(J.match(Z)||J.match(X))return!0;return!1}childrenIgnored(Q){let Z=Q.fullpath()+"/",X=(Q.relative()||".")+"/";for(let q of this.relativeChildren)if(q.match(X))return!0;for(let q of this.absoluteChildren)if(q.match(Z))return!0;return!1}}class H7{store;constructor(Q=new Map){this.store=Q}copy(){return new H7(new Map(this.store))}hasWalked(Q,Z){return this.store.get(Q.fullpath())?.has(Z.globString())}storeWalked(Q,Z){let X=Q.fullpath(),q=this.store.get(X);if(q)q.add(Z.globString());else this.store.set(X,new Set([Z.globString()]))}}class jQ{store=new Map;add(Q,Z,X){let q=(Z?2:0)|(X?1:0),Y=this.store.get(Q);this.store.set(Q,Y===void 0?q:q&Y)}entries(){return[...this.store.entries()].map(([Q,Z])=>[Q,!!(Z&2),!!(Z&1)])}}class TQ{store=new Map;add(Q,Z){if(!Q.canReaddir())return;let X=this.store.get(Q);if(X){if(!X.find((q)=>q.globString()===Z.globString()))X.push(Z)}else this.store.set(Q,[Z])}get(Q){let Z=this.store.get(Q);if(!Z)throw Error("attempting to walk unknown path");return Z}entries(){return this.keys().map((Q)=>[Q,this.store.get(Q)])}keys(){return[...this.store.keys()].filter((Q)=>Q.canReaddir())}}class U8{hasWalkedCache;matches=new jQ;subwalks=new TQ;patterns;follow;dot;opts;constructor(Q,Z){this.opts=Q,this.follow=!!Q.follow,this.dot=!!Q.dot,this.hasWalkedCache=Z?Z.copy():new H7}processPatterns(Q,Z){this.patterns=Z;let X=Z.map((q)=>[Q,q]);for(let[q,Y]of X){this.hasWalkedCache.storeWalked(q,Y);let J=Y.root(),H=Y.isAbsolute()&&this.opts.absolute!==!1;if(J){q=q.resolve(J==="/"&&this.opts.root!==void 0?this.opts.root:J);let _=Y.rest();if(!_){this.matches.add(q,!0,!1);continue}else Y=_}if(q.isENOENT())continue;let W,V,K=!1;while(typeof(W=Y.pattern())==="string"&&(V=Y.rest()))q=q.resolve(W),Y=V,K=!0;if(W=Y.pattern(),V=Y.rest(),K){if(this.hasWalkedCache.hasWalked(q,Y))continue;this.hasWalkedCache.storeWalked(q,Y)}if(typeof W==="string"){let _=W===".."||W===""||W===".";this.matches.add(q.resolve(W),H,_);continue}else if(W===n){if(!q.isSymbolicLink()||this.follow||Y.checkFollowGlobstar())this.subwalks.add(q,Y);let _=V?.pattern(),G=V?.rest();if(!V||(_===""||_===".")&&!G)this.matches.add(q,H,_===""||_===".");else if(_===".."){let z=q.parent||q;if(!G)this.matches.add(z,H,!0);else if(!this.hasWalkedCache.hasWalked(z,G))this.subwalks.add(z,G)}}else if(W instanceof RegExp)this.subwalks.add(q,Y)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new U8(this.opts,this.hasWalkedCache)}filterEntries(Q,Z){let X=this.subwalks.get(Q),q=this.child();for(let Y of Z)for(let J of X){let H=J.isAbsolute(),W=J.pattern(),V=J.rest();if(W===n)q.testGlobstar(Y,J,V,H);else if(W instanceof RegExp)q.testRegExp(Y,W,V,H);else q.testString(Y,W,V,H)}return q}testGlobstar(Q,Z,X,q){if(this.dot||!Q.name.startsWith(".")){if(!Z.hasMore())this.matches.add(Q,q,!1);if(Q.canReaddir()){if(this.follow||!Q.isSymbolicLink())this.subwalks.add(Q,Z);else if(Q.isSymbolicLink()){if(X&&Z.checkFollowGlobstar())this.subwalks.add(Q,X);else if(Z.markFollowGlobstar())this.subwalks.add(Q,Z)}}}if(X){let Y=X.pattern();if(typeof Y==="string"&&Y!==".."&&Y!==""&&Y!==".")this.testString(Q,Y,X.rest(),q);else if(Y===".."){let J=Q.parent||Q;this.subwalks.add(J,X)}else if(Y instanceof RegExp)this.testRegExp(Q,Y,X.rest(),q)}}testRegExp(Q,Z,X,q){if(!Z.test(Q.name))return;if(!X)this.matches.add(Q,q,!1);else this.subwalks.add(Q,X)}testString(Q,Z,X,q){if(!Q.isNamed(Z))return;if(!X)this.matches.add(Q,q,!1);else this.subwalks.add(Q,X)}}var u4=(Q,Z)=>typeof Q==="string"?new G8([Q],Z):Array.isArray(Q)?new G8(Q,Z):Q;class V7{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Z=[];#Q;#X;signal;maxDepth;includeChildMatches;constructor(Q,Z,X){if(this.patterns=Q,this.path=Z,this.opts=X,this.#X=!X.posix&&X.platform==="win32"?"\\":"/",this.includeChildMatches=X.includeChildMatches!==!1,X.ignore||!this.includeChildMatches){if(this.#Q=u4(X.ignore??[],X),!this.includeChildMatches&&typeof this.#Q.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=X.maxDepth||1/0,X.signal)this.signal=X.signal,this.signal.addEventListener("abort",()=>{this.#Z.length=0})}#q(Q){return this.seen.has(Q)||!!this.#Q?.ignored?.(Q)}#J(Q){return!!this.#Q?.childrenIgnored?.(Q)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let Q=void 0;while(!this.paused&&(Q=this.#Z.shift()))Q()}onResume(Q){if(this.signal?.aborted)return;if(!this.paused)Q();else this.#Z.push(Q)}async matchCheck(Q,Z){if(Z&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Q.realpathCached()||await Q.realpath(),!X)return;Q=X}let Y=Q.isUnknown()||this.opts.stat?await Q.lstat():Q;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let J=await Y.realpath();if(J&&(J.isUnknown()||this.opts.stat))await J.lstat()}return this.matchCheckTest(Y,Z)}matchCheckTest(Q,Z){return Q&&(this.maxDepth===1/0||Q.depth()<=this.maxDepth)&&(!Z||Q.canReaddir())&&(!this.opts.nodir||!Q.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!Q.isSymbolicLink()||!Q.realpathCached()?.isDirectory())&&!this.#q(Q)?Q:void 0}matchCheckSync(Q,Z){if(Z&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Q.realpathCached()||Q.realpathSync(),!X)return;Q=X}let Y=Q.isUnknown()||this.opts.stat?Q.lstatSync():Q;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let J=Y.realpathSync();if(J&&(J?.isUnknown()||this.opts.stat))J.lstatSync()}return this.matchCheckTest(Y,Z)}matchFinish(Q,Z){if(this.#q(Q))return;if(!this.includeChildMatches&&this.#Q?.add){let Y=`${Q.relativePosix()}/**`;this.#Q.add(Y)}let X=this.opts.absolute===void 0?Z:this.opts.absolute;this.seen.add(Q);let q=this.opts.mark&&Q.isDirectory()?this.#X:"";if(this.opts.withFileTypes)this.matchEmit(Q);else if(X){let Y=this.opts.posix?Q.fullpathPosix():Q.fullpath();this.matchEmit(Y+q)}else{let Y=this.opts.posix?Q.relativePosix():Q.relative(),J=this.opts.dotRelative&&!Y.startsWith(".."+this.#X)?"."+this.#X:"";this.matchEmit(!Y?"."+q:J+Y+q)}}async match(Q,Z,X){let q=await this.matchCheck(Q,X);if(q)this.matchFinish(q,Z)}matchSync(Q,Z,X){let q=this.matchCheckSync(Q,X);if(q)this.matchFinish(q,Z)}walkCB(Q,Z,X){if(this.signal?.aborted)X();this.walkCB2(Q,Z,new U8(this.opts),X)}walkCB2(Q,Z,X,q){if(this.#J(Q))return q();if(this.signal?.aborted)q();if(this.paused){this.onResume(()=>this.walkCB2(Q,Z,X,q));return}X.processPatterns(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#q(H))continue;Y++,this.match(H,W,V).then(()=>J())}for(let H of X.subwalkTargets()){if(this.maxDepth!==1/0&&H.depth()>=this.maxDepth)continue;Y++;let W=H.readdirCached();if(H.calledReaddir())this.walkCB3(H,W,X,J);else H.readdirCB((V,K)=>this.walkCB3(H,K,X,J),!0)}J()}walkCB3(Q,Z,X,q){X=X.filterEntries(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#q(H))continue;Y++,this.match(H,W,V).then(()=>J())}for(let[H,W]of X.subwalks.entries())Y++,this.walkCB2(H,W,X.child(),J);J()}walkCBSync(Q,Z,X){if(this.signal?.aborted)X();this.walkCB2Sync(Q,Z,new U8(this.opts),X)}walkCB2Sync(Q,Z,X,q){if(this.#J(Q))return q();if(this.signal?.aborted)q();if(this.paused){this.onResume(()=>this.walkCB2Sync(Q,Z,X,q));return}X.processPatterns(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#q(H))continue;this.matchSync(H,W,V)}for(let H of X.subwalkTargets()){if(this.maxDepth!==1/0&&H.depth()>=this.maxDepth)continue;Y++;let W=H.readdirSync();this.walkCB3Sync(H,W,X,J)}J()}walkCB3Sync(Q,Z,X,q){X=X.filterEntries(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#q(H))continue;this.matchSync(H,W,V)}for(let[H,W]of X.subwalks.entries())Y++,this.walkCB2Sync(H,W,X.child(),J);J()}}class h8 extends V7{matches=new Set;constructor(Q,Z,X){super(Q,Z,X)}matchEmit(Q){this.matches.add(Q)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise((Q,Z)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)Z(this.signal.reason);else Q(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class g8 extends V7{results;constructor(Q,Z,X){super(Q,Z,X);this.results=new x0({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(Q){if(this.results.write(Q),!this.results.flowing)this.pause()}stream(){let Q=this.path;if(Q.isUnknown())Q.lstat().then(()=>{this.walkCB(Q,this.patterns,()=>this.results.end())});else this.walkCB(Q,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var h4=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class B0{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(Q,Z){if(!Z)throw TypeError("glob options required");if(this.withFileTypes=!!Z.withFileTypes,this.signal=Z.signal,this.follow=!!Z.follow,this.dot=!!Z.dot,this.dotRelative=!!Z.dotRelative,this.nodir=!!Z.nodir,this.mark=!!Z.mark,!Z.cwd)this.cwd="";else if(Z.cwd instanceof URL||Z.cwd.startsWith("file://"))Z.cwd=f4(Z.cwd);if(this.cwd=Z.cwd||"",this.root=Z.root,this.magicalBraces=!!Z.magicalBraces,this.nobrace=!!Z.nobrace,this.noext=!!Z.noext,this.realpath=!!Z.realpath,this.absolute=Z.absolute,this.includeChildMatches=Z.includeChildMatches!==!1,this.noglobstar=!!Z.noglobstar,this.matchBase=!!Z.matchBase,this.maxDepth=typeof Z.maxDepth==="number"?Z.maxDepth:1/0,this.stat=!!Z.stat,this.ignore=Z.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error("cannot set absolute and withFileTypes:true");if(typeof Q==="string")Q=[Q];if(this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z.allowWindowsEscape===!1,this.windowsPathsNoEscape)Q=Q.map((W)=>W.replace(/\\/g,"/"));if(this.matchBase){if(Z.noglobstar)throw TypeError("base matching requires globstar");Q=Q.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=Q,this.platform=Z.platform||h4,this.opts={...Z,platform:this.platform},Z.scurry){if(this.scurry=Z.scurry,Z.nocase!==void 0&&Z.nocase!==Z.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let W=Z.platform==="win32"?_8:Z.platform==="darwin"?f8:Z.platform?z8:FQ;this.scurry=new W(this.cwd,{nocase:Z.nocase,fs:Z.fs})}this.nocase=this.scurry.nocase;let X=this.platform==="darwin"||this.platform==="win32",q={...Z,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:X,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},Y=this.pattern.map((W)=>new H0(W,q)),[J,H]=Y.reduce((W,V)=>{return W[0].push(...V.set),W[1].push(...V.globParts),W},[[],[]]);this.patterns=J.map((W,V)=>{let K=H[V];if(!K)throw Error("invalid pattern object");return new i0(W,K,0,this.platform)})}async walk(){return[...await new h8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new h8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new g8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new g8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var K7=(Q,Z={})=>{if(!Array.isArray(Q))Q=[Q];for(let X of Q)if(new H0(X,Z).hasMagic())return!0;return!1};function m8(Q,Z={}){return new B0(Q,Z).streamSync()}function NQ(Q,Z={}){return new B0(Q,Z).stream()}function c8(Q,Z={}){return new B0(Q,Z).walkSync()}async function wQ(Q,Z={}){return new B0(Q,Z).walk()}function l8(Q,Z={}){return new B0(Q,Z).iterateSync()}function PQ(Q,Z={}){return new B0(Q,Z).iterate()}var g4=m8,m4=Object.assign(NQ,{sync:m8}),c4=l8,l4=Object.assign(PQ,{sync:l8}),d4=Object.assign(c8,{stream:m8,iterate:l8}),SQ=Object.assign(wQ,{glob:wQ,globSync:c8,sync:d4,globStream:NQ,stream:m4,globStreamSync:m8,streamSync:g4,globIterate:PQ,iterate:l4,globIterateSync:l8,iterateSync:c4,Glob:B0,hasMagic:K7,escape:m0,unescape:z0});SQ.glob=SQ;import p4 from"node:path";var bQ=({dir:Q,pattern:Z="*",nodir:X=!1,dot:q=!0,ignore:Y=[],absolute:J=!1,matchBase:H=!1,follow:W=!1})=>{if(Q=Q||process.cwd(),Q=p4.resolve(Q),Z&&!Array.isArray(Z))Z=[Z];else Z=Z||["*"];if(Y&&!Array.isArray(Y))Y=[Y];else Y=Y||[];return c8(Z,{cwd:Q,nodir:X,dot:q,ignore:Y,absolute:J,matchBase:H,follow:W})};import DQ from"lodash.clonedeep";import i4 from"@fnet/key-value-transformer";async function c({node:Q,initNode:Z,extra:X=!0}){if(Reflect.has(Q.definition,"modules")&&!Array.isArray(Q.definition.modules)){let q=Q.definition.modules;Q.definition.modules=[],Object.keys(q).forEach((Y)=>{let J={...q[Y]};if(typeof J.export==="boolean")J.export=J.export===!0?Y:!1;else if(typeof J.export==="string")J.export=J.export;else delete J.export;Q.definition.modules.push({[Y]:J})})}if(X){let q=[],Y=await i4({data:Q.definition,callback:(J,H,W)=>{let V=N0(J,!0);if(V?.processor==="m"){let K=W.slice(0,-1);K.push(V.statement);let _=K.join("_");return q.push({[_]:H}),[V.statement,`m::${_}`]}return[J,H]}});if(q.length>0)Q.definition=Y,Q.definition.modules=Q.definition.modules||[],Q.definition.modules=Q.definition.modules.concat(q)}Q.hasModules=Q.definition.modules?.length>0;for(let q=0;q<Q.definition.modules?.length;q++){let Y=Q.definition.modules[q],J=Object.keys(Y)[0],H={name:J,childs:[],parent:Q,definition:Y[J],module:!0,blockAutoJumpToParent:!0,blockAutoJumpToSibling:!1,index:Q.childs.length,context:{}};Q.childs.push(H),await Z({node:H})}}async function b({node:Q,transformExpression:Z}){let X=Q.context.transform;if(Reflect.has(X,"export"))X.export=await Z(X.export);if(Reflect.has(X,"return"))Q.hasReturn=!0,X.return=await Z(X.return);if(Reflect.has(X,"output"))X.output=await Z(X.output);if(Reflect.has(X,"assign"))for(let q=0;q<X.assign?.length;q++){let Y=X.assign[q],J=Object.keys(Y)[0],H=Y[J],W={key:await Z(J),value:await Z(H)};X.assign[q]=W}}async function a4({node:Q}){if(!Q.definition.hasOwnProperty("switch"))return!1;return!0}async function r4({node:Q,initNode:Z}){Q.type="switch";let X=Q.definition.switch||[];if(!X.every((H)=>H.hasOwnProperty("condition")||H.hasOwnProperty("default")))throw Error("Switch must have condition or default");if(X.filter((H)=>H.hasOwnProperty("condition")).length===0)throw Error("Switch must have at least one condition");let J=X.filter((H)=>H.hasOwnProperty("default"));if(J.length>1)throw Error("Switch must have only one default");if(J.length===1&&!X[X.length-1].hasOwnProperty("default"))throw Error("Switch default must be the last child");Q.hasDefaultCondition=J.length===1,await c({node:Q,initNode:Z,extra:!1}),Q.blockAutoJumpToParent=!1,Q.blockAutoJumpToSibling=!0;for(let H=0;H<Q.definition.switch.length;H++){let W=Q.definition.switch[H],V=`${H}`;if(W.hasOwnProperty("default"))V="default",W=W.default;let K={name:W.condition||V,childs:[],parent:Q,definition:W,index:Q.childs.length,context:{}};Q.childs.push(K),await Z({node:K})}Q.resolve=kQ}async function kQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||DQ(Q.definition);let Y=Q.context.transform;for(let J of Q.childs)if(J.context.transform=J.context.transform||DQ(J.definition),J.definition.hasOwnProperty("condition"))J.context.transform.condition=await q(J.definition.condition);await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var $8={hits:a4,init:r4,resolve:kQ};async function n4({node:Q}){if(Object.keys(Q.definition).filter((q)=>N0(q)==="if").length===1)return!0;if(Q.definition.if&&typeof Q.definition.if==="object")return!0;return!1}async function s4(Q){let{node:Z}=Q,X=Object.keys(Z.definition),q=[],Y=X.find((W)=>N0(W)==="if");if(Y){let W=Z.definition[Y],V=N0(Y,!0);q.push({name:`${Z.name}_if`,definition:W,processor:{expression:Y,statement:V.statement,processor:V.processor}}),delete Z.definition[Y]}else if(Z.definition.if){let{condition:W,...V}=Z.definition.if;q.push({name:`${Z.name}_if`,definition:V,processor:{expression:`if::${W}`,statement:W}}),delete Z.definition.if}let J=X.filter((W)=>N0(W)==="elseif"),H=0;for(let W of J){let V=Z.definition[W],K=N0(W,!0);q.push({name:`${Z.name}_elseif_${H++}`,definition:V,processor:{expression:W,statement:K.statement,processor:K.processor}}),delete Z.definition[W]}if(Z.definition.elseif){let{condition:W,...V}=Z.definition.elseif;q.push({name:`${Z.name}_elseif_${H++}`,definition:V,processor:{expression:`elseif::${W}`,statement:W}}),delete Z.definition.elseif}Z.definition.switch=[];for(let W of q)Z.definition.switch.push({condition:W.processor.statement,...W.definition});if(Z.definition?.else){let W=Z.definition.else;Z.definition.switch.push({default:W}),delete Z.definition.else}await $8.init(Q)}var _7={hits:n4,init:s4};import vQ from"lodash.clonedeep";async function o4({node:Q}){return Q.definition.hasOwnProperty("try")&&Q.definition.hasOwnProperty("except")}async function t4({node:Q,initNode:Z}){if(Q.type="tryexcept",await c({node:Q,initNode:Z,extra:!1}),Q.blockAutoJumpToParent=!1,Q.blockAutoJumpToSibling=!0,Q.definition.try){let q={name:"try",childs:[],parent:Q,definition:Q.definition.try,index:Q.childs.length,context:{}};Q.childs.push(q),await Z({node:q})}if(Q.definition.except){let q={name:"except",childs:[],parent:Q,definition:Q.definition.except,index:Q.childs.length,context:{}};Q.childs.push(q),await Z({node:q})}Q.resolve=yQ}async function yQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||vQ(Q.definition);let Y=Q.context.transform;if(Q.context.try=Q.childs.find((J)=>J.name==="try"),Q.context.except=Q.childs.find((J)=>J.name==="except"),Q.context.except){let J=Q.context.except;if(J.context.transform=J.context.transform||vQ(J.definition),!J.context.transform.hasOwnProperty("as"))J.context.transform.as="error"}await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var z7={hits:o4,init:t4,resolve:yQ};import e4 from"lodash.clonedeep";async function Q2({node:Q}){return Q.definition.hasOwnProperty("assign")}async function Z2({node:Q,initNode:Z}){Q.type="assign",await c({node:Q,initNode:Z}),Q.resolve=EQ}async function EQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||e4(Q.definition);let Y=Q.context.transform;await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var G7={hits:Q2,init:Z2,resolve:EQ};import X2 from"lodash.clonedeep";async function q2({node:Q}){return Q.definition.hasOwnProperty("for")}async function Y2({node:Q,initNode:Z}){if(Q.type="for",await c({node:Q,initNode:Z,extra:!1}),Q.blockAutoJumpToParent=!0,Q.blockAutoJumpToSibling=!1,!Q.definition.for.hasOwnProperty("steps")){let{as:X,in:q,...Y}=Q.definition.for,J={};if(X!==void 0)J.as=X;if(q!==void 0)J.in=q;Q.definition.for=J,Q.definition.for.steps=[{[`${Q.name}_step`]:Y}]}if(!Array.isArray(Q.definition.for.steps))Q.definition.for.steps=[{[`${Q.name}_step`]:Q.definition.for.steps}];for(let X=0;X<Q.definition.for.steps.length;X++){let q=Q.definition.for.steps[X],Y=Object.keys(q)[0],J={name:Y,childs:[],parent:Q,definition:q[Y],index:Q.childs.length,context:{}};Q.childs.push(J),await Z({node:J})}Q.resolve=xQ}async function xQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||X2(Q.definition);let Y=Q.context.transform;Y.for.in=await q(Q.definition.for.in),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var U7={hits:q2,init:Y2,resolve:xQ};import J2 from"lodash.clonedeep";async function W2({node:Q}){return Q.definition.hasOwnProperty("parallel")}async function H2({node:Q,initNode:Z}){Q.type="parallel",Q.blockAutoJumpToParent=!0,Q.blockAutoJumpToSibling=!0;let X=Q.definition.parallel||[];for await(let q of X){let Y=Object.keys(q)[0],J={name:Y,childs:[],parent:Q,definition:q[Y],index:Q.childs.length,context:{}};Q.childs.push(J),await Z({node:J})}Q.resolve=uQ}async function uQ({node:Q,transformExpression:Z,resolveNextBlock:X}){Q.context.transform=Q.context.transform||J2(Q.definition),await b({node:Q,transformExpression:Z}),X({node:Q})}var $7={hits:W2,init:H2,resolve:uQ};import V2 from"lodash.clonedeep";async function K2({node:Q}){return Q.definition.hasOwnProperty("raise")}async function _2({node:Q,initNode:Z}){Q.type="raise",Q.resolve=fQ}async function fQ({node:Q,resolveTypeCommon:Z,transformExpression:X}){Q.context.transform=Q.context.transform||V2(Q.definition);let q=Q.context.transform;q.raise=await X(q.raise),await Z({node:Q})}var M7={hits:K2,init:_2,resolve:fQ};import z2 from"lodash.clonedeep";async function G2({node:Q}){return Q.definition.hasOwnProperty("return")}async function U2({node:Q,initNode:Z}){Q.type="return",Q.resolve=hQ}async function hQ({node:Q,resolveTypeCommon:Z,transformExpression:X}){Q.context.transform=Q.context.transform||z2(Q.definition);let q=Q.context.transform;Q.hasReturn=!0,q.return=await X(q.return),await Z({node:Q})}var O7={hits:G2,init:U2,resolve:hQ};import $2 from"lodash.clonedeep";async function M2({node:Q}){return Q.definition.hasOwnProperty("call")}async function O2({node:Q,initNode:Z}){Q.type="call",await c({node:Q,initNode:Z}),Q.resolve=gQ}async function gQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||$2(Q.definition);let Y=Q.context.transform,J=Y.from||Y.import||Y.call;if(Q.target?.atom?.doc?.type==="function"){if(Reflect.has(Y,"from"))J=Y.from,Y.from=await q(Q.target.atom.name);else if(Reflect.has(Y,"import"))J=Y.import,Y.import=await q(Q.target.atom.name);else if(Reflect.has(Y,"call"))Y.call=await q(Q.target.atom.name),J=Y.call}else if(Reflect.has(Y,"from")||Reflect.has(Y,"import")){if(Y.call.startsWith("use:e::")){let W=Y.call.substring(7);Y.libExp=await q(`e::LIBRARY.${W}`)}}if(Y.args)Y.args=await q(Y.args);if(Y.new)Y.new=await q(Y.new);if(Y.context)Y.context=await q(Y.context);if(Y.result){if(typeof Y.result==="string")Y.result=[{[Y.result]:"e::result"}];for(let W=0;W<Y.result?.length;W++){let V=Y.result[W],K=Object.keys(V)[0],_=V[K],G={key:await q(K),value:await q(_)};Y.result[W]=G}}let H=Q.workflow.parent;Q.context.lib=H.context.libs.find((W)=>W.name===J),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var M8={hits:M2,init:O2,resolve:gQ};import A2 from"lodash.clonedeep";async function B2({node:Q}){return Q.definition.hasOwnProperty("steps")}async function R2({node:Q,initNode:Z}){if(!Q.type)Q.type="steps";let X=Q.definition.steps||[];for await(let q of X){let Y=Object.keys(q)[0],J={name:Y,childs:[],parent:Q,definition:q[Y],index:Q.childs.length,context:{}};Q.childs.push(J),await Z({node:J})}Q.resolve=mQ}async function mQ({node:Q,transformExpression:Z}){Q.context.next=Q.childs[0],Q.context.transform=Q.context.transform||A2(Q.definition),await b({node:Q,transformExpression:Z})}var A7={hits:B2,init:R2,resolve:mQ};import I2 from"lodash.clonedeep";async function C2({node:Q}){return Q.definition.hasOwnProperty("form")}async function L2({node:Q,initNode:Z}){Q.type="form",await c({node:Q,initNode:Z}),Q.resolve=cQ}async function cQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||I2(Q.definition);let Y=Q.context.transform;if(Y.props)Y.props=await q(Y.props);let J=Q.workflow.parent;Q.context.lib=J.context.libs.find((H)=>H.name===Y.form),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var B7={hits:C2,init:L2,resolve:cQ};import F2 from"lodash.clonedeep";async function j2({node:Q}){return Q.definition.hasOwnProperty("signal")}async function T2({node:Q,initNode:Z}){Q.type="signal",Q.resolve=lQ}async function lQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q,transformValue:Y}){Q.context.transform=Q.context.transform||F2(Q.definition),await Z({node:Q}),X({node:Q})}var R7={hits:j2,init:T2,resolve:lQ};import w2 from"lodash.clonedeep";async function S2({node:Q}){return Q.definition.hasOwnProperty("wait")}async function N2({node:Q,initNode:Z}){Q.type="wait",Q.resolve=dQ}async function dQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q,transformValue:Y}){Q.context.transform=Q.context.transform||w2(Q.definition),await Z({node:Q}),X({node:Q})}var I7={hits:S2,init:N2,resolve:dQ};import P2 from"lodash.clonedeep";async function b2({node:Q}){return Q.definition.hasOwnProperty("next")}async function D2({node:Q,initNode:Z}){Q.type="next",Q.resolve=pQ}async function pQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||P2(Q.definition);let Y=Q.context.transform;Y.next=await q(Y.next),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var C7={hits:b2,init:D2,resolve:pQ};import k2 from"lodash.clonedeep";async function v2({node:Q}){return Q.definition.hasOwnProperty("modules")}async function y2({node:Q,initNode:Z}){Q.type="modules",await c({node:Q,initNode:Z}),Q.resolve=iQ}async function iQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||k2(Q.definition);let Y=Q.context.transform;await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var L7={hits:v2,init:y2,resolve:iQ};function F7({node:Q}){let Z=Q.definition;if(Q.hasReturn){if(j("tree"))f.info(" └─ RETURN (no next)",{depth:Q.depth+1,node:Q.indexKey});return}if(Z.next==="end"){if(j("tree"))f.info(" └─ EXPLICIT END",{depth:Q.depth+1,node:Q.indexKey})}else if(Z.next==="stop"){if(j("tree"))f.info(" └─ EXPLICIT STOP",{depth:Q.depth+1,node:Q.indexKey})}else if(Z.next==="none"){if(j("tree"))f.info(" └─ EXPLICIT NONE",{depth:Q.depth+1,node:Q.indexKey})}else if(Z.next){if(j("tree"))f.info(` \uD83D\uDD0D EXPLICIT NEXT: "${Z.next}" (searching...)`,{depth:Q.depth+1,from:Q.indexKey});let X=Q.parent;while(X.parent){let q=X.childs.find((Y)=>Y.name===Z.next);if(q){if(Q.context.next=q,j("tree"))f.info(` └─ ✅ FOUND: ${q.indexKey}`,{depth:Q.depth+1,nextNode:q.indexKey});break}X=X.parent}if(!Q.context.next&&j("tree"))f.warn(` └─ ⚠️ NOT FOUND: "${Z.next}"`,{depth:Q.depth+1})}else{if(Q.module===!0){if(j("tree"))f.info(" └─ MODULE ROOT (no auto next)",{depth:Q.depth+1,node:Q.indexKey});return}if(j("tree"))f.info(" \uD83D\uDC1C AUTO NEXT (karınca yürüyüşü başlıyor...)",{depth:Q.depth+1,from:Q.indexKey});let X=Q.parent,q=Q.index+1,Y=0;while(X.parent)if(Y++,X.blockAutoJumpToParent&&X.blockAutoJumpToSibling){if(j("tree"))f.info(` ${Y}. ⛔ Both jumps disabled at ${X.indexKey}`,{depth:Q.depth+2});break}else if(!Reflect.has(X,"blockAutoJumpToParent")&&!Reflect.has(X,"blockAutoJumpToSibling")){let J=X.childs.find((H)=>H.index===q);if(J){if(Q.context.next=J,j("tree"))f.info(` ${Y}. ✅ SIBLING FOUND: ${J.indexKey}`,{depth:Q.depth+2,nextNode:J.indexKey});break}else{if(j("tree"))f.info(` ${Y}. ⬆️ No sibling, climbing to parent: ${X.parent?.indexKey}`,{depth:Q.depth+2,targetIndex:q});q=X.index+1,X=X.parent;continue}}else if(X.blockAutoJumpToParent){let J=X.childs.find((H)=>H.index===q);if(J){if(Q.context.next=J,j("tree"))f.info(` ${Y}. ✅ SIBLING FOUND (parent jump disabled): ${J.indexKey}`,{depth:Q.depth+2,nextNode:J.indexKey})}else if(j("tree"))f.info(` ${Y}. ⛔ No sibling, parent jump disabled`,{depth:Q.depth+2});break}else if(!X.blockAutoJumpToParent){if(j("tree"))f.info(` ${Y}. ⬆️ Sibling disabled, climbing to parent: ${X.parent?.indexKey}`,{depth:Q.depth+2});q=X.index+1,X=X.parent;continue}if(Q.context.next&&j("tree"))f.info(` └─ \uD83C\uDFAF AUTO NEXT RESOLVED: ${Q.context.next.indexKey}`,{depth:Q.depth+1,steps:Y,nextNode:Q.context.next.indexKey});else if(j("tree"))f.info(" └─ ⚠️ NO NEXT FOUND (end of flow)",{depth:Q.depth+1,steps:Y})}}class aQ{#Z;#Q;#X;#q;constructor({key:Q,npm:Z,master:X,extras:q}){this.#Z=Q,this.#Q=Z,this.#X=X,this.#q=q}hits({node:Q}){return Q.definition.hasOwnProperty(this.#Z)}async init(Q){let{node:Z}=Q,X=this.#Z,q=Z.definition,Y=typeof q[X];if(q.call=`npm:${this.#Q}`,Y!=="object")q.args={...q.args,[`${this.#X}`]:q[X]};else q.args=q[X];if(delete q[X],this.#q)for(let J in this.#q)q[J]=this.#q[J];console.log(`[npm-block] ${this.#Z} --> ${this.#Q}`),await M8.init(Q)}}function s(Q){return new aQ(Q)}import E2 from"lodash.clonedeep";async function x2({node:Q}){return Q.definition.hasOwnProperty("new")}async function u2({node:Q,initNode:Z}){Q.type="new",await c({node:Q,initNode:Z}),Q.resolve=rQ}async function rQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||E2(Q.definition);let Y=Q.context.transform,J=Y.from||Y.import;if(Q.target?.atom?.doc?.type==="function"){if(Reflect.has(Y,"from"))J=Y.from,Y.from=await q(Q.target.atom.name);else if(Reflect.has(Y,"import"))J=Y.import,Y.import=await q(Q.target.atom.name)}if(Y.args)Y.args=await q(Y.args);if(Y.new)Y.new=await q(Y.new);if(Y.result){if(typeof Y.result==="string")Y.result=[{[Y.result]:"e::result"}];for(let W=0;W<Y.result?.length;W++){let V=Y.result[W],K=Object.keys(V)[0],_=V[K],G={key:await q(K),value:await q(_)};Y.result[W]=G}}let H=Q.workflow.parent;Q.context.lib=H.context.libs.find((W)=>W.name===J),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var j7={hits:x2,init:u2,resolve:rQ};import f2 from"lodash.clonedeep";async function h2({node:Q}){return Q.definition.hasOwnProperty("output")}async function g2({node:Q,initNode:Z}){Q.type="output",await c({node:Q,initNode:Z}),Q.resolve=nQ}async function nQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||f2(Q.definition),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var T7={hits:h2,init:g2,resolve:nQ};import m2 from"lodash.clonedeep";async function c2({node:Q}){return Q.definition.hasOwnProperty("pipeline")}async function l2({node:Q}){Q.type="pipeline";let Z=Q.definition.pipeline;if(!Z||typeof Z!=="string")throw Error(`Pipeline step '${Q.indexKey}' requires a binary name`);if(Q.context.binaryName=Z,Q.definition.input)Q.context.input=Q.definition.input;if(Q.definition.result)Q.context.result=Q.definition.result;if(Q.definition.args)Q.context.args=Q.definition.args;if(Q.context.format=Q.definition.format||"json",Q.definition.env)Q.context.env=Q.definition.env;if(Q.definition.cwd)Q.context.cwd=Q.definition.cwd;Q.resolve=sQ}async function sQ({node:Q,transformExpression:Z,resolveNextBlock:X}){Q.context.transform=Q.context.transform||m2(Q.definition);let q=Q.context.transform;if(q.input)q.input=await Z(q.input);if(q.args)q.args=await Z(q.args);if(q.env)q.env=await Z(q.env);if(q.cwd)q.cwd=await Z(q.cwd);await b({node:Q,transformExpression:Z}),X({node:Q})}var w7={hits:c2,init:l2,resolve:sQ};import d2 from"lodash.clonedeep";async function p2({node:Q}){return Q.definition.hasOwnProperty("retry")}async function i2({node:Q,initNode:Z}){Q.type="retry";let X=Q.definition.retry,q;if(typeof X==="number")q={attempts:X,delay:1000,backoff:"exponential",maxDelay:null};else if(typeof X==="object")q={attempts:X.attempts||3,delay:X.delay||1000,backoff:X.backoff||"exponential",maxDelay:X.maxDelay||null,on:X.on,onRetry:X.onRetry};else throw Error(`Retry step '${Q.name}' requires a number or object configuration`);if(!q.attempts||q.attempts<1)throw Error(`Retry step '${Q.name}' requires attempts >= 1`);let Y=["exponential","linear","fixed"];if(!Y.includes(q.backoff))throw Error(`Retry step '${Q.name}' has invalid backoff strategy '${q.backoff}'. Valid options: ${Y.join(", ")}`);Q.definition.retry=q;let{retry:J,...H}=Q.definition,W={name:`${Q.name}_retryable`,childs:[],parent:Q,definition:H,index:0,context:{}};Q.childs.push(W),await Z({node:W}),Q.resolve=oQ}async function oQ({node:Q,transformExpression:Z,resolveNextBlock:X}){Q.context.transform=Q.context.transform||d2(Q.definition);let q=Q.context.transform;if(q.retry.attempts&&typeof q.retry.attempts==="string")q.retry.attempts=await Z(q.retry.attempts);if(q.retry.delay&&typeof q.retry.delay==="string")q.retry.delay=await Z(q.retry.delay);if(q.retry.maxDelay&&typeof q.retry.maxDelay==="string")q.retry.maxDelay=await Z(q.retry.maxDelay);if(q.retry.onRetry)q.retry.onRetry=await Z(q.retry.onRetry);await b({node:Q,transformExpression:Z}),X({node:Q})}var S7={hits:p2,init:i2,resolve:oQ};import a2 from"lodash.clonedeep";async function r2({node:Q}){return Q.definition.hasOwnProperty("schedule")}async function n2({node:Q,initNode:Z}){Q.type="schedule";let X=Q.definition.schedule,q;if(typeof X==="string")q={cron:X,timezone:null,enabled:!0};else if(typeof X==="object")q={cron:X.cron,timezone:X.timezone||null,enabled:X.enabled!==!1};else throw Error(`Schedule step '${Q.name}' requires a cron expression string or object`);if(!q.cron||typeof q.cron!=="string")throw Error(`Schedule step '${Q.name}' requires a valid cron expression`);Q.definition.schedule=q;let{schedule:Y,...J}=Q.definition,H={name:`${Q.name}_scheduled`,childs:[],parent:Q,definition:J,index:0,context:{}};Q.childs.push(H),await Z({node:H}),Q.resolve=tQ}async function tQ({node:Q,transformExpression:Z,resolveNextBlock:X}){Q.context.transform=Q.context.transform||a2(Q.definition);let q=Q.context.transform;if(q.schedule){if(q.schedule.cron&&typeof q.schedule.cron==="string")q.schedule.cron=await Z(q.schedule.cron);if(q.schedule.timezone&&typeof q.schedule.timezone==="string")q.schedule.timezone=await Z(q.schedule.timezone)}await b({node:Q,transformExpression:Z}),X({node:Q})}var N7={hits:r2,init:n2,resolve:tQ};import s2 from"lodash.clonedeep";async function o2({node:Q}){return Q.definition.hasOwnProperty("http")}async function t2({node:Q,initNode:Z}){Q.type="http",await c({node:Q,initNode:Z});let X=Q.definition.http,q;if(typeof X==="string")q={url:X,method:"GET",headers:{},timeout:30000};else if(typeof X==="object"){if(q={url:X.url,method:X.method||"GET",headers:X.headers||{},body:X.body,params:X.params,timeout:X.timeout||30000},!q.url)throw Error(`HTTP step '${Q.name}' requires a url property`)}else throw Error(`HTTP step '${Q.name}' requires a string URL or object configuration`);let Y=["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"],J=q.method.toUpperCase();if(!Y.includes(J))throw Error(`HTTP step '${Q.name}' has invalid method '${q.method}'. Valid options: ${Y.join(", ")}`);if(q.method=J,q.timeout&&(typeof q.timeout!=="number"||q.timeout<=0))throw Error(`HTTP step '${Q.name}' timeout must be a positive number`);Q.definition.http=q,Q.resolve=e2}async function e2({node:Q,transformExpression:Z,resolveNextBlock:X}){Q.context.transform=Q.context.transform||s2(Q.definition);let q=Q.context.transform;if(q.http.url&&typeof q.http.url==="string")q.http.url=await Z(q.http.url);if(q.http.headers){for(let Y in q.http.headers)if(typeof q.http.headers[Y]==="string")q.http.headers[Y]=await Z(q.http.headers[Y])}if(q.http.body)q.http.body=await Z(q.http.body);if(q.http.params){for(let Y in q.http.params)if(typeof q.http.params[Y]==="string")q.http.params[Y]=await Z(q.http.params[Y])}if(q.http.timeout&&typeof q.http.timeout==="string")q.http.timeout=await Z(q.http.timeout);await b({node:Q,transformExpression:Z}),X({node:Q})}var P7={hits:o2,init:t2};var eQ=({path:Q})=>{if(!Q)throw Error("Path is required");let Z=/^@([^\/]+\/[^\/]+)(?:\/(.+))?$/,X=/^([^\/]+)(?:\/(.+))?$/,q;if(q=Q.match(Z))return{path:Q,package:"@"+q[1],subpath:q[2]||null};else if(q=Q.match(X))return{path:Q,package:q[1],subpath:q[2]||null};return null};class YZ{#Z;#Q;#X;#q;#J;#C;#I;#K;#G;#V;#z;#Y;#O;#M;#$;#A;#j;#R;#F;#H;#L;#_=[];constructor(Q){this.#Z=new t7,this.#Q=Q,this.#C=[],this.#I=[],this.#K={},this._expire_ttl=3600,this._expire_ttl_short=300,this.#_.push(s({key:"config",npm:"@fnet/config",master:"name"})),this.#_.push(s({key:"yaml",npm:"@fnet/yaml",master:"file"})),this.#_.push(s({key:"prompt",npm:"@fnet/prompt",master:"message"})),this.#_.push(s({key:"html-link",npm:"@flownet/lib-load-browser-link-url",master:"src"})),this.#_.push(s({key:"html-script",npm:"@flownet/lib-load-browser-script-url",master:"src"})),this.#_.push(s({key:"http-server",npm:"@fnet/node-express",master:"server_port"})),this.#_.push(s({key:"shell",npm:"@fnet/shell-flow",master:"commands"})),this.#_.push(s({key:"list-files",npm:"@fnet/list-files",master:"pattern"})),this.#_.push(s({key:"up-list-files",npm:"@fnet/up-list-files",master:"pattern"})),this.#_.push(s({key:"auto-conda-env",npm:"@fnet/auto-conda-env",master:"envDir"})),this.#_.push(s({key:"ollama-chat",npm:"@fnet/ollama-chat",master:"model"})),this.#_.push(s({key:"ai",npm:"@fnet/ai",master:"prompt",extras:{subtype:"flow"}})),this.#_.push(s({key:"invoke",npm:"@fnet/invoke",master:"method",extras:{}})),this.#_.push(s({key:"fetch",npm:"@fnet/fetch",master:"url",extras:{}})),this.#_.push(s({key:"filemap",npm:"@fnet/filemap",master:"target",extras:{}})),this.#H={packageDependencies:this.#C,packageDevDependencies:this.#I,setProgress:this.setProgress.bind(this),context:this.#Q,Atom:R0,registerToPackageManager:this.registerToPackageManager.bind(this)},this.#L={initNode:this.initNode.bind(this),cloneDeep:XZ,resolveTypeCommon:this.resolveTypeCommon.bind(this),resolveNextBlock:F7,transformExpression:this.transformExpression.bind(this),transformValue:this.transformValue.bind(this)}}async _cache_set(Q,Z,X){}async init(){this.#z=this.#Q.buildId||qZ(),this.#H.buildId=this.#z,this.#$=this.#Q.mode,this.#A=["all","deploy","build","file"].includes(this.#$),this.#j=["all","deploy","build"].includes(this.#$),this.#R=["all","deploy"].includes(this.#$),this.#F=["all","deploy","build","file","bpmn"].includes(this.#$),this.#O=this.#Q.protocol,this.#Y="BUILD:"+this.#z,this.#M=(await X1({optional:!0,name:"atom",dir:this.#Q.projectDir,tags:this.#Q.tags}))?.data;try{await this.setProgress({message:"Initialization started."});let Q=this.#H.context.project;await this.initAuth(),await this.initWorkflow(),this.transformWorkflow({workflow:this.#q});let Z=await this.initNodeTree({workflow:this.#q});if(await this.initNodeTreeIndex({root:Z}),await this.initNodeCalls({root:Z}),await this.initNodeCallLibs({root:Z}),await this.initNodeForms({root:Z}),await this.initNodeFormLibs({root:Z}),await this.initEntryFiles({root:Z,features:this.#X.doc.features}),await this.initFeaturesFromNodes({childs:Z.childs,features:this.#X.doc.features}),await B6(this.#H),Q.runtime.type==="bun")await I6(this.#H);else await R6(this.#H);await this.initAtomLibsAndDeps({libs:Z.context.libs,packageDependencies:this.#C}),await this.resolveNodeTree({root:Z}),this.#V=Z}catch(Q){throw await this._cache_set(this.#Y,{status:"FAILED",message:Q?.message||Q}),Q}}async initAuth(){if(!this.#Q.id)return;this.#G=await this.#Z.init({config:this.#M}),this.#H.atomAccessToken=this.#G}async initWorkflow(){let Q=this.#Q.id;this.#X=this.#Q.project?.workflowAtom||await R0.get({id:Q}),this.#q=typeof this.#X.doc.content==="string"?(await Y1({content:this.#X.doc.content,tags:this.#Q.tags})).parsed:this.#X.doc.content;let Z=this.#X.doc.bundleName;Z=Z||(this.#X.doc.name||"").toUpperCase().replace(/[^A-Z0-9]/g,"_"),this.#X.doc.bundleName=Z,this.#X.type=this.#X.type||"workflow",this.#H.atom=this.#X,this.#X.doc.features=this.#X.doc.features||{}}#T(Q){if(console.log("filePath",Q),N.statSync(Q).isDirectory())N.readdirSync(Q).forEach((Z)=>{let X=D.join(Q,Z);this.#T(X)}),N.rmSync(Q);else N.unlinkSync(Q)}#B(Q,Z){let X=N.existsSync(Q),q=X&&N.statSync(Q);if(X&&q.isDirectory())N.mkdirSync(Z,{recursive:!0}),N.readdirSync(Q).forEach((J)=>{this.#B(D.join(Q,J),D.join(Z,J))});else N.copyFileSync(Q,Z)}async initWorkflowDir(){this.setProgress({message:"Initializing library directory."});let Q=this.#Q.projectDir,Z=this.#Q.coreDir;this.setProgress({message:"Cleaning project directory."});let X=bQ({dir:Q,ignore:[".cache","node_modules",".conda",".bin",".dev"],absolute:!0});for(let W of X)N.rmSync(W,{recursive:!0,force:!0});if(this.setProgress({message:"Creating project directory."}),!N.existsSync(Q))N.mkdirSync(Q,{recursive:!0});let q=D.join(Q,"src");if(!N.existsSync(q))N.mkdirSync(q,{recursive:!0});let Y=D.join(q,"core");this.#B(Z,Y);let J=D.join(q,"default","blocks");if(!N.existsSync(J))N.mkdirSync(J,{recursive:!0});let H=D.join(Q,".dev");if(!N.existsSync(H))N.mkdirSync(H,{recursive:!0})}async initNunjucks(){this.setProgress({message:"Initializing nunjucks."});let Q=this.#Q.templateDir;this.#J=O8.configure(Q,{watch:!1,dev:!0}),this.#H.njEnv=this.#J}transformWorkflow({workflow:Q}){for(let Z of Object.values(Q))Z.steps=Z.steps||[],Z.steps=Z.steps.filter((X)=>Object.keys(X).length>0),Z.steps=Z.steps.map((X)=>this.transformStep({step:X}))}transformStep({step:Q}){if(Array.isArray(Q))throw Error("Step must be an object.");let[Z,X]=Object.entries(Q)[0];if(X.hasOwnProperty("onerror")){let{onerror:q,...Y}=X;Q[Z]={try:Y,except:q}}if(Q[Z].hasOwnProperty("steps")){let q=Q[Z].steps;if(!Array.isArray(q))throw Error("Steps must be an array.");Q[Z].steps=q.map((Y)=>this.transformStep({step:Y}))}return Q}async initNodeTree({workflow:Q}){let Z=Object.keys(Q);if(j("tree"))f.info("\uD83C\uDF33 Creating root node",{depth:0});let X={definition:Q,name:void 0,type:"root",parent:void 0,childs:[],blockAutoJumpToParent:!0,blockAutoJumpToSibling:!0,index:0,depth:0,context:{libs:[],atom:this.#X}};Z.forEach((q)=>{if(j("tree"))f.info(`\uD83D\uDCE6 Creating ${q==="main"?"workflow":"subworkflow"}: ${q}`,{depth:1,index:X.childs.length,type:q==="main"?"workflow":"subworkflow"});let Y={name:q,type:q==="main"?"workflow":"subworkflow",childs:[],parent:X,definition:Q[q],index:X.childs.length,depth:X.depth+1,context:{},blockAutoJumpToParent:!0,blockAutoJumpToSibling:!1};X.childs.push(Y)});for await(let q of X.childs){if(j("tree"))f.info(`\uD83D\uDD27 Initializing node: ${q.name}`,{depth:q.depth});await this.initNode({node:q})}if(j("tree"))f.info("✅ Root node tree created",{depth:0,totalFlows:X.childs.length});return X}async initNode({node:Q}){let Z={...this.#L,node:Q};Q.workflow=Q.parent.workflow||Q,Q.depth=Q.parent.depth+1;let X="unknown";if(await z7.hits(Z))X="tryexcept",await z7.init(Z);else if(await $8.hits(Z))X="switch",await $8.init(Z);else if(await _7.hits(Z))X="if",await _7.init(Z);else if(await U7.hits(Z))X="for",await U7.init(Z);else if(await S7.hits(Z))X="retry",await S7.init(Z);else if(await N7.hits(Z))X="schedule",await N7.init(Z);else if(await $7.hits(Z))X="parallel",await $7.init(Z);else if(await w7.hits(Z))X="pipeline",await w7.init(Z);else if(await P7.hits(Z))X="http",await P7.init(Z);else if(await M8.hits(Z))X="call",await M8.init(Z);else if(await j7.hits(Z))X="new",await j7.init(Z);else if(await M7.hits(Z))X="raise",await M7.init(Z);else if(await B7.hits(Z))X="form",await B7.init(Z);else if(await R7.hits(Z))X="signal",await R7.init(Z);else if(await I7.hits(Z))X="wait",await I7.init(Z);else if(await A7.hits(Z))X="steps",await A7.init(Z);else if(await C7.hits(Z))X="next",await C7.init(Z);else if(await L7.hits(Z))X="modules",await L7.init(Z);else if(await O7.hits(Z))X="return",await O7.init(Z);else if(this.#_.find((q)=>q.hits(Z)))X="npm-block",await this.#_.find((q)=>q.hits(Z)).init(Z);else if(await G7.hits(Z))X="assign",await G7.init(Z);else if(await T7.hits(Z))X="output",await T7.init(Z);else throw Error("Undefined step type.");if(j("tree"))f.info(` ├─ ${X}: ${Q.name}`,{depth:Q.depth,index:Q.index,type:X,hasChilds:Q.childs?.length>0,childCount:Q.childs?.length||0})}async initNodeTreeIndex({root:Q}){let Z={};Q.indexKey="/";for await(let X of Q.childs)await this.initNodeIndex({node:X,index:Z});return Q.context.index=Z,Z}async initNodeIndex({node:Q,index:Z}){let X=D.join(Q.parent.indexKey,Q.name);Q.indexKey=X,Z[X]=Q;let q=[],Y=Q;while(Y?.parent)q.push(Y.index),Y=Y.parent;q.reverse(),Q.codeKey=`B_${q.join("_")}_${Q.type}`,Q.pathKey=`${q.join(".")}`,Q.typeId=qZ();for await(let J of Q.childs)await this.initNodeIndex({node:J,index:Z})}async initNodeCalls({root:Q}){let Z=Q.context.index,X=[];for await(let q of Object.keys(Z)){let Y=Z[q];if(Y.type!=="call"&&Y.type!=="new")continue;X.push(Y)}return Q.context.calls=X,X}async initNodeCallLibs({root:Q}){let Z=[],X=Q.context.calls;for await(let q of X){let Y=q.definition.from||q.definition.import||q.definition.call,J=await this.findNodeCallTarget({refNode:q,curNode:q.parent})||{name:Y,type:"atom",definition:q.definition},H=Z.find((W)=>W.name===J.name&&W.type===J.type);if(!H)Z.push(J);q.target=H||J}return Q.context.callLibs=Z,Q.context.libs=[...Q.context.libs,...Z],Z}async findNodeCallTarget({refNode:Q,curNode:Z}){if(!Z)return;let X=Q.definition.call,q=Z.childs.find((Y)=>Y.name===X&&Y.type==="subworkflow");if(q)return q;else return await this.findNodeCallTarget({refNode:Q,curNode:Z.parent})}async initNodeForms({root:Q}){let Z=Q.context.index,X=[];for await(let q of Object.keys(Z)){let Y=Z[q];if(Y.type!=="form")continue;X.push(Y)}return Q.context.forms=X,X}async initNodeFormLibs({root:Q}){let Z=[],X=Q.context.forms;for await(let q of X){let Y=q.definition.from||q.definition.import||q.definition.form,J=await this.findNodeCallTarget({refNode:q,curNode:q.parent})||{name:Y,type:"atom"},H=Z.find((W)=>W.name===J.name&&W.type===J.type);if(!H)Z.push(J);q.target=H||J}return Q.context.formLibs=Z,Q.context.libs=[...Q.context.libs,...Z],Z}async initFeaturesFromNodes({childs:Q,features:Z}){for await(let X of Q){if(X.type==="form"&&!Reflect.has(Z,"form"))Z.form=!0;await this.initFeaturesFromNodes({childs:X.childs,features:Z})}}async initEntryFiles({root:Q,features:Z}){for await(let X of Q.childs){let q;if(X.name==="main")q="index.js";else if(X.name==="cli")q="cli.js";else if(X.name==="app")q="app.js";else if(X.name==="api")q="api.js";else continue;Z[`${X.name}_default_entry_file`]=q,X.entryFile=q}}async findNodeFormTarget({refNode:Q,curNode:Z}){if(!Z)return;let X=Q.definition.form,q=Z.childs.find((Y)=>Y.name===X&&Y.type==="subworkflow");if(q)return q;else return await this.findNodeFormTarget({refNode:Q,curNode:Z.parent})}async initAtomLibsAndDeps({libs:Q,packageDependencies:Z}){let X=Q.filter((q)=>q.type==="atom");for(let q=0;q<X.length;q++){let Y=X[q],J=await this.findAtomLibrary({url:Y.name,libRef:Y});Y.atom=J,J.doc.dependencies?.filter((W)=>typeof W.repo>"u"||W.repo==="npm")?.forEach((W)=>{let V=Z.find((K)=>K.package===W.package);if(V){if(typeof W.path==="string"){if(!(V.path||[]).some((K)=>K===W.path))V.path=V.path||[],V.path.push(W.path)}else if(Array.isArray(W.path))W.path.forEach((K)=>{if(!(V.path||[]).some((_)=>_===K))V.path=V.path||[],V.path.push(K)})}else Z.push(W)})}Z.sort((q,Y)=>q.package?.localeCompare(Y.package))}async findAtomLibrary({url:Q,libRef:Z}){let X=Z1({url:Q});if(!X)throw Error(`Invalid package name: ${Q}`);if(!X.protocol)X.protocol=this.#O;if(X.protocol==="src:"){let q=D.resolve(this.#Q.projectSrcDir,`${X.pathname}.js`),Y=[],H=(await q1({file:q,recursive:!0})).all;for await(let V of H){if(V.type!=="npm")continue;if(Y.find((_)=>_.package===V.package))continue;let K=await g0({name:V.package,projectDir:this.#Q.projectDir,setProgress:this.#H.setProgress});Y.push({package:V.package,subpath:V.subpath,version:K.minorRange,type:"npm"})}return{name:X.pathname,doc:{type:"workflow.lib","content-type":"javascript",language:"js",dependencies:Y},protocol:X.protocol}}else if(X.protocol==="npm:"){let q=eQ({path:X.pathname}),Y=await g0({name:q.package,subpath:q.subpath,projectDir:this.#Q.projectDir,setProgress:this.#H.setProgress});return{name:X.pathname,doc:{type:"workflow.lib",subtype:Z?.definition?.subtype==="flow"?"workflow":null,"content-type":"javascript",language:"js",dependencies:[{package:q.package,version:Y.minorRange,type:"npm"}]},protocol:X.protocol}}else if(X.protocol==="use:")return{name:X.pathname,doc:{type:"function",dependencies:[]},protocol:X.protocol};else if(X.protocol==="node:")return{name:X.pathname,doc:{type:"workflow.lib","content-type":"javascript",language:"js",dependencies:[]},protocol:X.protocol};else if(X.protocol==="ac:"){let q=X.pathname.split("/");if(q.length===1)return await R0.first({where:{name:Q,parent_id:this.#M.env.ATOM_LIBRARIES_ID,type:"workflow.lib"}});if(q.length===2){let Y=await R0.first({where:{name:q[0],parent_id:this.#M.env.ATOM_LIBRARIES_ID,type:"folder"}});return await R0.first({where:{name:q[1],parent_id:Y.id,type:"workflow.lib"}})}}}async resolveNodeTree({root:Q}){for await(let Z of Q.childs)await this.resolveTypeWorkflow({node:Z})}async resolveTypeWorkflow({node:Q}){Q.context.transform=Q.context.transform||XZ(Q.definition);let Z=Q.context.transform;for(let X=0;X<Z.params?.length;X++){let q=Z.params[X];if(typeof q==="string")Z.params[X]={key:q,hasDefault:!1};else{let Y=Object.keys(q)[0];Z.params[X]={key:Y,hasDefault:!0,default:q[Y],type:typeof q[Y]}}}Q.context.next=Q.childs[0];for await(let X of Q.childs)await this.resolveType({node:X})}async resolveType({node:Q}){let Z={...this.#L,node:Q};if(typeof Q.resolve==="function")await Q.resolve(Z);for await(let X of Q.childs)await this.resolveType({node:X})}async resolveTypeCommon({node:Q}){let Z=Q.context.transform;if(Z.hasOwnProperty("page"))Z.page=await this.transformExpression(Z.page);if(Z.hasOwnProperty("print"))Z.print=await this.transformExpression(Z.print);if(Z.hasOwnProperty("sleep"))Z.sleep=await this.transformExpression(Z.sleep);if(Z.hasOwnProperty("assert"))Z.assert=await this.transformExpression(Z.assert)}async createAtomLibFiles({root:Q}){await this.setProgress({message:"Creating external lib files."}),this.#X.typesDir="./types";let X=Q.context.libs.filter((q)=>q.type==="atom");for(let q=0;q<X.length;q++){let J=X[q].atom,H=this.#Q.projectDir;if(J.protocol==="src:"){let W=D.resolve(this.#Q.projectSrcDir,`${J.fileName||J.name}.js`),V=D.relative(`${this.#Q.projectDir}/src/default/blocks`,W);if(!N.existsSync(W)){N.mkdirSync(D.dirname(W),{recursive:!0});let K=`export default async (input)=>{
12
+ `;K+="}",N.writeFileSync(W,K,"utf8")}J.relativePath=V.split(D.sep).join("/"),this.#X.typesDir=`./types/${D.basename(H)}/src`}else if(J.protocol==="npm:")J.relativePath=J.name;else if(J.protocol==="node:")J.relativePath=J.name;else if(J.protocol==="use:");else{let W=`${H}/src/libs/${J.id}.js`,V=J.doc.contents?.find((K)=>K.format==="esm")||J.doc;N.writeFileSync(D.normalize(W),V.content,"utf8")}}}async createEngine({root:Q}){await this.setProgress({message:"Creating engine file."});let Z=this.#Q.templateDir,X=O8.compile(N.readFileSync(D.resolve(Z,"src/default/engine.js.njk"),"utf8"),this.#J);for(let q=0;q<Q.childs.length;q++){let Y=Q.childs[q];if(!Y.entryFile)continue;let J=X.render({flow:Y,ui:{package:"@fnet/react-app"}}),H=this.#Q.projectDir,W=D.resolve(H,`src/default/${Y.entryFile}`);N.writeFileSync(W,J,"utf8")}}async createNodeTree({root:Q}){await this.setProgress({message:"Creating block files."});for await(let Z of Q.childs)await this.createTypeWorkflow({node:Z})}async createTypeWorkflow({node:Q}){let Z=this.#Q.templateDir,q=O8.compile(N.readFileSync(D.resolve(Z,"src/default/workflow.js.njk"),"utf8"),this.#J).render(Q),Y=this.#Q.projectDir,J=D.resolve(Y,`src/default/${Q.codeKey}.js`);N.writeFileSync(J,q,"utf8");for await(let H of Q.childs)await this.createType({node:H})}async createType({node:Q}){switch(Q.type){case"assign":case"steps":case"return":case"call":case"new":case"form":case"raise":case"switch":case"next":case"tryexcept":case"for":case"parallel":case"signal":case"wait":case"modules":case"output":case"pipeline":case"retry":case"schedule":case"http":this.createBlockFromTemplate({node:Q});break;default:break}for await(let Z of Q.childs)await this.createType({node:Z})}createBlockFromTemplate({node:Q}){let Z=this.getBlockTemplate({node:Q});Q.context.render=Z.render(Q),this.createStepFile({node:Q})}getBlockTemplate({node:Q}){let Z=this.#K[Q.type];if(Z)return Z;let X=this.#Q.templateDir;return Z=O8.compile(N.readFileSync(D.resolve(X,`src/default/blocks/${Q.type}.js.njk`),"utf8"),this.#J),this.#K[Q.type]=Z,Z}createStepFile({node:Q}){let Z=this.#Q.projectDir,X=`${Q.codeKey}.js`,q=D.resolve(Z,`src/default/blocks/${X}`);N.writeFileSync(q,Q.context.render,"utf8"),Q.context.fileName=X,Q.context.filePath=q}async transformExpression(Q){try{let Z=await this.transformValue(Q);return Z=JSON.stringify(Z),Z=this.replaceSpecialPattern(Z),Z}catch(Z){throw console.error("❌ transformExpression error:",Z.message),console.error(" Input value:",Q),console.error(" Stack:",Z.stack),Z}}async transformValue(Q){if(Array.isArray(Q))for(let Z=0;Z<Q.length;Z++)Q[Z]=await this.transformValue(Q[Z]);else if(Q1(Q)){let Z=Object.keys(Q);for(let X=0;X<Z.length;X++){let q=Z[X],Y=d6({expression:q});if(Y)if(Y.processor==="e"){let J=typeof Q[q]==="string"?Q[q]:Q[q];Q[Y.statement]=`$::${J}::`,delete Q[q]}else Q[q]=await this.transformValue(Q[q]);else Q[q]=await this.transformValue(Q[q])}}else if(typeof Q==="string"){let Z=d6({expression:Q,transform:{v:"v.{stmt}",for:"c.for.{stmt}",m:"c.module?.{stmt}||flow.module?.{stmt}",f:"c.form.{stmt}"}});if(Z){let{processor:X,transformed:q}=Z;switch(X){case"v":case"for":case"m":case"f":case"e":Q=`$::${q||Z.statement}::`;break}}}return Q}replaceSpecialPattern(Q){if(typeof Q!=="string")return console.error("❌ replaceSpecialPattern received non-string:",typeof Q,Q),Q;let Z=/"\$::(.*?)::"/g;return Q.replace(Z,"$1")}replaceExpressionLegacy(Q){let Z=/(?<outer>"\${(?<inner>[^{]*)}")/g;return Q.replaceAll(Z,"$2")}async createProjectYaml(){await this.setProgress({message:"Creating fnet.yaml"});let{content:X,...q}=this.#X.doc,Y=this.#Q.projectDir,J=D.resolve(Y,"fnet.yaml");N.writeFileSync(J,QZ.stringify(q),"utf8")}async createProjectMainYaml(){await this.setProgress({message:"Creating flow.main.yaml"});let X={content:QZ.stringify(this.#q)},q=this.#Q.templateDir,J=O8.compile(N.readFileSync(D.resolve(q,"flow.main.yaml.njk"),"utf8"),this.#J).render(X),H=this.#Q.projectDir,W=D.resolve(H,"flow.main.yaml");N.writeFileSync(W,J,"utf8")}async runPrettifier(){let Q=this.#Q.projectDir;if(M0("bun")){let Z=await ZZ("prettier --write .",{cwd:D.resolve(Q,"src")});if(Z.code!==0)throw Error(Z.stderr)}else{let Z=await ZZ("prettier --write .",{cwd:D.resolve(Q,"src")});if(Z.code!==0)throw Error(Z.stderr)}}async deploy(){if(await this.setProgress({message:"Deploying."}),this.#Q.project?.devops){let Q=[this.#Q.project?.devops];for(let Z=0;Z<Q.length;Z++){let X=Q[Z];if(await this.deployProject({deploymentProject:X}),X.isDirty===!0)await X.save()}}else if(this.#X.id){let Q=await R0.list({type:"workflow.deploy",parent_id:this.#X.id});for(let Z=0;Z<Q.length;Z++){let X=Q[Z];if(await this.deployProject({deploymentProject:X}),X.isDirty===!0)X=await R0.update(X,{id:X.id})}}}async deployProject(Q){let{deploymentProject:Z}=Q,{yamlDocument:X}=Z;if(Z.doc.targets&&Array.isArray(Z.doc.targets))throw Error("Deployment project targets are deprecated. Please update targets in the yaml file.");let q=Object.keys(Z.doc||{}),Y=X||{};for(let J=0;J<q.length;J++){let H=Z.doc[q[J]];H.name=q[J];let W=Y.get(q[J]);await R9({...this.#H,deploymentProject:Z,deploymentProjectTarget:H,yamlTarget:W})}}async registerToPackageManager(Q){let{target:Z,packageJSON:X}=Q;if(!this.#Q.id)return;let q=await R0.first({name:Z.params.name,parent_id:this.#M.env.ATOM_PACKAGES_ID});if(!q)q=await R0.create({parent_id:this.#M.env.ATOM_PACKAGES_ID,doc:{name:Z.params.name,type:"pm",versions:[{v:X.version}]}});else q.doc.versions.splice(0,0,{v:X.version}),await R0.update(q,{id:q.id})}async setProgress(Q){let Z=typeof Q==="string"?Q:Q?.message;console.log(J1.blue(Z)),await this._cache_set(this.#Y,{status:"IN_PROGRESS",message:Z})}async build(){if(this.#F&&!this.#A)return await this.createNetwork();try{let Q=this.#F?await j8({root:this.#V}):void 0;if(this.#A){let Z=this.#H.context.project;if(await this.initWorkflowDir(),await this.initNunjucks(),this.#F){let X=this.#Q.project?.projectDir||this.#Q.projectDir;if(X=D.resolve(X,"fnet"),N.existsSync(X)){if(N.existsSync(D.resolve(X,"flow.bpmn")))N.unlinkSync(D.resolve(X,"flow.bpmn"));if(N.writeFileSync(D.resolve(X,"flows.bpmn"),Q.diagramXML,"utf8"),((this.#X.doc.features||{}).bpmn||{}).per_flow===!0){let H=D.resolve(X,"bpmn");if(!N.existsSync(H))N.mkdirSync(H,{recursive:!0});let W=await F9({root:this.#V});for(let V of W){let K=`${V.flowName}.bpmn`,_=D.resolve(H,K);N.writeFileSync(_,V.diagramXML,"utf8")}}}}if(await this.createAtomLibFiles({root:this.#V}),await this.createEngine({root:this.#V}),await this.createNodeTree({root:this.#V}),await this.createProjectYaml(),await y6(this.#H),await v6(this.#H),await k6(this.#H),await D6(this.#H),await F6(this.#H),await C6(this.#H),Z.runtime.type==="bun")await N6(this.#H);else await w6(this.#H);if(await L6(this.#H),await E6(this.#H),await x6(this.#H),this.#j){if(await u6(this.#H),await f6(this.#H),this.#R)await this.deploy()}}await this._cache_set(this.#Y,{status:"COMPLETED",data:{network:Q}})}catch(Q){throw await this._cache_set(this.#Y,{status:"FAILED",message:Q.message||Q}),Q}}async createNetwork(){try{let Q=await j8({root:this.#V});await this._cache_set(this.#Y,{status:"COMPLETED",data:{...Q}})}catch(Q){throw await this._cache_set(this.#Y,{status:"FAILED",message:Q.message||Q}),Q}}}var D0=YZ;var W1={command:"build",describe:"Build flownet project",builder:(Q)=>{return Q.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("mode",{type:"string",default:"build",choices:["all","file","build","deploy","bpmn"],describe:"Build mode"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).option("dev",{type:"boolean",default:!1,describe:"Development mode"})},handler:async(Q)=>{try{let Z=await k(Q),X=new D0(Z);await X.init(),await X.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Z){console.error("Building workflow failed!",Z.message),process.exit(1)}}},JZ=W1;var H1={command:"build:dev",describe:"Build flownet project",builder:(Q)=>{return Q.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("mode",{type:"string",default:"build",choices:["all","file","build","deploy","bpmn"],describe:"Build mode"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).option("dev",{type:"boolean",default:!1,describe:"Development mode"})},handler:async(Q)=>{try{Q.dev=!0;let Z=await k(Q),X=new D0(Z);await X.init(),await X.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Z){console.error("Building workflow failed!",Z.message),process.exit(1)}}},WZ=H1;var V1={command:"deploy",describe:"Build and deploy flownet project",builder:(Q)=>{return Q.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"})},handler:async(Q)=>{try{let Z=await k({...Q,mode:"all"}),X=new D0(Z);await X.init(),await X.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Z){console.error("Building workflow failed!",Z.message),process.exit(1)}}},HZ=V1;var K1={command:"file",describe:"Just create files",builder:(Q)=>{return Q.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"})},handler:async(Q)=>{try{let Z=await k({...Q,mode:"file"}),X=new D0(Z);await X.init(),await X.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Z){console.error("Building workflow failed!",Z.message),process.exit(1)}}},VZ=K1;import KZ from"node:path";import d8 from"node:fs";import _1 from"@fnet/prompt";var z1={command:"input [name]",describe:"Create or modify an input config file",builder:(Q)=>{return Q.positional("name",{type:"string",demandOption:!1,describe:"Input name"})},handler:async(Q)=>{try{let Z=await k(Q),{project:X}=Z,{projectDir:q,projectFileParsed:Y}=X,J=Y.input;if(!J)throw Error("Config schema not found in project file.");if(!Reflect.has(Q,"name")){let{inputName:G}=await _1({type:"input",name:"inputName",message:"Input name:",initial:"dev"});Q.name=G}let H=KZ.resolve(q,".fnet");if(!d8.existsSync(H))d8.mkdirSync(H);let W=KZ.resolve(H,`${Q.name}.fnet`),V=d8.existsSync(W),K=(await import("@fnet/object-from-schema")).default,_=await K({schema:J,format:"yaml",ref:V?W:void 0});d8.writeFileSync(W,_)}catch(Z){console.error(Z.message),process.exit(1)}}},_Z=z1;import P from"node:path";import S from"node:fs";import i8 from"node:os";import{spawn as a8}from"node:child_process";import L from"chalk";import j0 from"@fnet/prompt";import p8 from"chalk";import zZ from"@fnet/prompt";async function G1(Q){let{items:Z,message:X,nameField:q="name",valueField:Y="name",initialValue:J=null,allowAbort:H=!0}=Q;if(!Z||Z.length===0)return console.log(p8.yellow("No items available for selection.")),null;if(Z.length===1&&!H){let G=Z[0],z=typeof G==="string"?G:G[Y];return console.log(p8.blue(`Only one option available: ${typeof G==="string"?G:G[q]}`)),z}let W=Z.map((G)=>{if(typeof G==="string")return{name:G,value:G,message:G};else return{name:G[Y],value:G[Y],message:G[q]||G[Y]}});if(H)W.push({name:"cancel",value:null,message:p8.yellow("Cancel")});let V=null;if(J){let G=W.findIndex((z)=>z.name===J);if(G!==-1)V=G}let K="selectedItem",{[K]:_}=await zZ({type:"select",name:K,message:X,choices:W,initial:V});if(_==="cancel")return null;return _}async function U1(Q){let{items:Z,message:X,nameField:q="name",valueField:Y="name",initialValues:J=[],allowAbort:H=!0}=Q;if(!Z||Z.length===0)return console.log(p8.yellow("No items available for selection.")),null;let W=Z.map((G)=>{if(typeof G==="string")return{name:G,value:G,message:G};else return{name:G[Y],value:G[Y],message:G[q]||G[Y]}}),V=[];if(J&&J.length>0)V=W.map((G,z)=>J.includes(G.name)?z:-1).filter((G)=>G!==-1);let K="selectedItems",_=await zZ({type:"multiselect",name:K,message:X,choices:W,initial:V,hint:"(Use space to select, enter to confirm)",validate:(G)=>{if(G.length===0&&!H)return"Please select at least one item";return!0}});if(H&&_[K].length===0)return null;return _[K]}var b7={promptForSelection:G1,promptForMultipleSelection:U1};var l=P.join(i8.homedir(),".fnet","express");async function UZ(Q){Q.command(["$0 [project-name]","create [project-name]"],"Create a new express project",(Z)=>{return Z.positional("project-name",{describe:"Name of the project",type:"string"}).option("yes",{alias:"y",describe:"Skip all prompts and use defaults",type:"boolean",default:!1}).option("runtime",{describe:"Runtime to use (node)",type:"string",choices:["node"],default:"node"})},async(Z)=>{await $1(Z)}).command("list","List express projects",(Z)=>{return Z.option("today",{describe:"Show only projects created today",type:"boolean",default:!1}).option("type",{describe:"Filter by project type (fnode or fnet)",type:"string",choices:["fnode","fnet"]}).option("all",{describe:"Show all projects regardless of type",type:"boolean",default:!1,alias:"a"}).option("name",{describe:"Filter by project name",type:"string"})},async(Z)=>{await M1(Z)}).command("open [project-name]","Open an express project",(Z)=>{return Z.positional("project-name",{describe:"Name of the project to open",type:"string"}).option("latest",{describe:"Open the most recent project",type:"boolean",default:!1})},async(Z)=>{await O1(Z)}).command("move [project-name] [destination]","Move an express project to a real project location",(Z)=>{return Z.positional("project-name",{describe:"Name of the project to move",type:"string"}).positional("destination",{describe:"Destination directory",type:"string"}).option("latest",{describe:"Move the most recent project",type:"boolean",default:!1})},async(Z)=>{await A1(Z)}).command("remove [project-name]","Remove an express project",(Z)=>{return Z.positional("project-name",{describe:"Name of the project to remove",type:"string"}).option("latest",{describe:"Remove the most recent project",type:"boolean",default:!1}).option("yes",{alias:"y",describe:"Skip confirmation prompt",type:"boolean",default:!1})},async(Z)=>{await R1(Z)}).command("enter [project-name]","Enter the directory of an express project in the active terminal",(Z)=>{return Z.positional("project-name",{describe:"Name of the project to enter",type:"string"}).option("latest",{describe:"Enter the most recent project directory",type:"boolean",default:!1})},async(Z)=>{await I1(Z)}).demandCommand(1,"You need to specify a command").help()}async function $1(Q){try{if(!S.existsSync(l))S.mkdirSync(l,{recursive:!0});let Z=new Date().toISOString().slice(0,10).replace(/-/g,""),X=P.join(l,Z);if(!S.existsSync(X))S.mkdirSync(X,{recursive:!0});let q=Q.projectName,Y,J=Q.runtime;if(!Q.yes){if(!q){let z=S.readdirSync(X).filter((U)=>U.startsWith("fnet-")).map((U)=>parseInt(U.replace("fnet-",""),10)).filter((U)=>!isNaN(U)),$=`fnet-${z.length>0?Math.max(...z)+1:1}`;q=(await j0([{type:"input",name:"projectName",message:"Enter project name:",default:$}])).projectName}J=(await j0({type:"select",name:"runtime",message:"Select runtime:",choices:["node"],initial:J||"node"})).runtime}else{if(!q){let _=S.readdirSync(X).filter((z)=>z.startsWith("fnet-")).map((z)=>parseInt(z.replace("fnet-",""),10)).filter((z)=>!isNaN(z));q=`fnet-${_.length>0?Math.max(..._)+1:1}`}if(!J)J="node"}if(Y=P.join(X,q),S.existsSync(Y)){let _=1;while(S.existsSync(P.join(X,`${q}-${_}`)))_++;q=`${q}-${_}`,Y=P.join(X,q)}if(!Q.yes){if(!(await j0([{type:"confirm",name:"proceed",message:`Create express project "${q}" in ${Y}?`,default:!0}])).proceed){console.log(L.yellow("Project creation cancelled."));return}}console.log(L.blue(`Creating express project "${q}" in ${Y}...`));let H=P.dirname(Y),V=["create","--name",P.basename(Y)];if(V.push("--runtime",J),Q.yes)V.push("--yes");if(!S.existsSync(H))S.mkdirSync(H,{recursive:!0});let K=a8("fnet",V,{stdio:"inherit",shell:!0,cwd:H});return new Promise((_,G)=>{K.on("close",(z)=>{if(z===0)if(console.log(L.green(`
13
+ Express project "${q}" created successfully!`)),console.log(L.blue(`
14
+ Project location: ${Y}`)),!Q.yes)B1(Y);else _();else console.error(L.red(`
15
+ Failed to create express project "${q}".`)),G(Error(`Process exited with code ${z}`))})})}catch(Z){console.error(L.red(`Error creating express project: ${Z.message}`)),process.exit(1)}}async function M1(Q){try{if(!S.existsSync(l)){console.log(L.yellow("No express projects found."));return}let Z=S.readdirSync(l).filter((H)=>/^\d{8}$/.test(H)).sort((H,W)=>W.localeCompare(H));if(Q.today){let H=new Date().toISOString().slice(0,10).replace(/-/g,""),W=Z.indexOf(H);if(W===-1){console.log(L.yellow("No express projects found for today."));return}Z.splice(0,W),Z.splice(1)}let X=[];if(!Q.type&&!Q.all)Q.type="fnet";for(let H of Z){let W=P.join(l,H),V=S.readdirSync(W);for(let K of V){let _=P.join(W,K),G=S.statSync(_),z="unknown";if(K.startsWith("fnode-")||S.existsSync(P.join(_,"fnode.yaml")))z="fnode";else if(K.startsWith("fnet-")||S.existsSync(P.join(_,"fnet.yaml")))z="fnet";if(Q.type&&z!==Q.type)continue;if(Q.name&&!K.includes(Q.name))continue;let O=`${H.slice(0,4)}-${H.slice(4,6)}-${H.slice(6,8)}`;X.push({name:K,type:z,date:O,path:_,created:G.birthtime})}}if(X.sort((H,W)=>W.created-H.created),X.length===0){console.log(L.yellow("No express projects found matching the criteria."));return}console.log(L.blue(`
16
+ Express Projects:`));let q=(await import("./index.4g9yezkq.js")).default,Y=["NAME","TYPE","DATE","PATH"],J=q.createTable(Y,{chars:{mid:"","mid-mid":"","left-mid":"","right-mid":""}});for(let H of X){let W=H.path;if(W.startsWith(i8.homedir()))W="~"+W.substring(i8.homedir().length);J.push([L.white(H.name),H.type==="fnet"?L.cyan(H.type):H.type==="fnode"?L.green(H.type):H.type,H.date,W])}console.log(J.toString()),console.log(L.blue(`
17
+ Total: ${X.length} projects`))}catch(Z){console.error(L.red(`Error listing express projects: ${Z.message}`)),process.exit(1)}}async function O1(Q){try{if(!S.existsSync(l)){console.log(L.yellow("No express projects found."));return}let Z;if(Q.latest){if(Z=await r8(),!Z){console.log(L.yellow("No express projects found."));return}}else if(Q.projectName){if(Z=await n8(Q.projectName),!Z){console.log(L.yellow(`Project "${Q.projectName}" not found.`));return}}else{let X=await s8();if(!X){console.log(L.yellow("No project selected."));return}Z=P.join(l,X)}await D7(Z)}catch(Z){console.error(L.red(`Error opening express project: ${Z.message}`)),process.exit(1)}}async function A1(Q){try{let Z=process.cwd(),X=Z.includes(l),q;if(X)q=Z,console.log(L.blue(`Using current express project: ${P.basename(q)}`));else if(Q.latest){if(q=await r8(),!q){console.log(L.yellow("No express projects found."));return}}else if(Q.projectName){if(q=await n8(Q.projectName),!q){console.log(L.yellow(`Project "${Q.projectName}" not found.`));return}}else{let H=await s8();if(!H){console.log(L.yellow("No project selected."));return}q=P.join(l,H)}let Y=Q.destination;if(!Y)Y=(await j0({type:"input",name:"destination",message:"Enter destination directory:",initial:P.join(process.cwd(),P.basename(q))})).destination;if(Y.startsWith("~"))Y=P.join(i8.homedir(),Y.slice(1));if(Y=P.resolve(Y),Y.startsWith(q+P.sep)||Y===q){console.log(L.red("Destination cannot be inside the source directory."));return}if(S.existsSync(Y)){if(!S.statSync(Y).isDirectory()){console.log(L.red(`Destination "${Y}" is not a directory.`));return}if(S.readdirSync(Y).length>0){if(!(await j0({type:"confirm",name:"overwrite",message:`Destination "${Y}" is not empty. Continue anyway?`,initial:!1})).overwrite){console.log(L.yellow("Project move cancelled."));return}}}else S.mkdirSync(Y,{recursive:!0});if(console.log(L.blue(`Moving project from ${q} to ${Y}...`)),$Z(q,Y),console.log(L.green(`
18
+ Project moved successfully to ${Y}`)),(await j0({type:"confirm",name:"deleteOriginal",message:"Delete the original express project?",initial:!1})).deleteOriginal)S.rmSync(q,{recursive:!0,force:!0}),console.log(L.green("Original project deleted."));await D7(Y)}catch(Z){console.error(L.red(`Error moving express project: ${Z.message}`)),process.exit(1)}}async function r8(){let Q=S.readdirSync(l).filter((H)=>/^\d{8}$/.test(H)).sort((H,W)=>W.localeCompare(H));if(Q.length===0)return null;let Z=Q[0],X=P.join(l,Z),q=S.readdirSync(X);if(q.length===0)return null;let Y=null,J=0;for(let H of q){let W=P.join(X,H),V=S.statSync(W);if(V.birthtimeMs>J)J=V.birthtimeMs,Y=W}return Y}async function n8(Q){let Z=S.readdirSync(l).filter((X)=>/^\d{8}$/.test(X)).sort((X,q)=>q.localeCompare(X));for(let X of Z){let q=P.join(l,X),Y=S.readdirSync(q);if(Y.includes(Q))return P.join(q,Q);let J=Y.filter((H)=>H.includes(Q));if(J.length>0)if(J.length===1)return P.join(q,J[0]);else{let H=J.map((V)=>({name:P.join(q,V),value:P.join(q,V),message:`${V} (${X})`})),W=await b7.promptForSelection({items:H,message:`Multiple projects match "${Q}". Please select one:`,nameField:"message",valueField:"value",allowAbort:!0});if(W===null)return console.log(L.yellow("Operation cancelled.")),null;return W}}return null}async function s8(){let Q=[],Z=S.readdirSync(l).filter((q)=>/^\d{8}$/.test(q)).sort((q,Y)=>Y.localeCompare(q));for(let q of Z){let Y=P.join(l,q),J=S.readdirSync(Y);for(let H of J){let W=P.join(Y,H),V=S.statSync(W),K=`${q}/${H}`;Q.push({name:K,value:K,created:V.birthtime})}}if(Q.sort((q,Y)=>Y.created-q.created),Q.length===0)return null;let X=await b7.promptForSelection({items:Q,message:"Select a project:",nameField:"value",valueField:"value",allowAbort:!0});if(X===null)return console.log(L.yellow("Operation cancelled.")),null;return X}async function B1(Q){try{if((await j0({type:"confirm",name:"openIDE",message:"Would you like to open the project in an IDE?",initial:!0})).openIDE)await D7(Q)}catch(Z){console.error(L.red(`Error opening IDE: ${Z.message}`))}}async function D7(Q){let Z=await GZ("code --version"),X=await GZ("code-insiders --version"),q=null;if(Z&&X)q=(await j0({type:"select",name:"ide",message:"Which IDE would you like to use?",choices:[{name:"Visual Studio Code",value:"code"},{name:"Visual Studio Code Insiders",value:"code-insiders"}]})).ide;else if(Z)q="code";else if(X)q="code-insiders";else{console.log(L.yellow("No supported IDE found. Please open the project manually.")),console.log(L.blue(`Project path: ${Q}`));return}console.log(L.blue(`Opening project in ${q}...`)),console.log(L.blue(`Project path: ${Q}`));let Y=a8(q,[Q],{stdio:"inherit",shell:!0});return new Promise((J,H)=>{Y.on("close",(W)=>{if(W===0)console.log(L.green(`Project opened in ${q}.`)),J();else console.error(L.red(`Failed to open project in ${q}.`)),H(Error(`Process exited with code ${W}`))})})}async function GZ(Q){return new Promise((Z)=>{a8(Q,{shell:!0,stdio:"ignore"}).on("close",(q)=>{Z(q===0)})})}function $Z(Q,Z){if(!S.existsSync(Z))S.mkdirSync(Z,{recursive:!0});let X=S.readdirSync(Q,{withFileTypes:!0});for(let q of X){let Y=P.join(Q,q.name),J=P.join(Z,q.name);if(q.isDirectory()){if(q.name===".git"||q.name===".workspace")continue;$Z(Y,J)}else S.copyFileSync(Y,J)}}async function R1(Q){try{if(!S.existsSync(l)){console.log(L.yellow("No express projects found."));return}let Z;if(Q.latest){if(Z=await r8(),!Z){console.log(L.yellow("No express projects found."));return}}else if(Q.projectName){if(Z=await n8(Q.projectName),!Z){console.log(L.yellow(`Project "${Q.projectName}" not found.`));return}}else{let q=await s8();if(!q){console.log(L.yellow("No project selected."));return}Z=P.join(l,q)}let X=P.basename(Z);if(!Q.yes){if(!(await j0({type:"confirm",name:"confirm",message:`Are you sure you want to remove project "${X}"?`,initial:!1})).confirm){console.log(L.yellow("Project removal cancelled."));return}}console.log(L.blue(`Removing project "${X}"...`)),S.rmSync(Z,{recursive:!0,force:!0}),console.log(L.green(`Project "${X}" removed successfully.`))}catch(Z){console.error(L.red(`Error removing express project: ${Z.message}`)),process.exit(1)}}async function I1(Q){try{if(!S.existsSync(l)){console.log(L.yellow("No express projects found."));return}let Z;if(Q.latest){if(Z=await r8(),!Z){console.log(L.yellow("No express projects found."));return}}else if(Q.projectName){if(Z=await n8(Q.projectName),!Z){console.log(L.yellow(`Project "${Q.projectName}" not found.`));return}}else{let Y=await s8();if(!Y){console.log(L.yellow("No project selected."));return}Z=P.join(l,Y)}console.log(L.blue(`Entering project directory: ${Z}`)),console.log(L.yellow(`
19
+ Opening a new shell in the project directory...`));let X=process.env.SHELL||"/bin/bash",q=a8(X,[],{stdio:"inherit",cwd:Z,shell:!0});return new Promise((Y)=>{q.on("close",()=>{console.log(L.green(`
20
+ Returned from project directory.`)),Y()})})}catch(Z){console.error(L.red(`Error entering express project directory: ${Z.message}`)),process.exit(1)}}import OZ from"node:path";import{fileURLToPath as T1}from"node:url";import C1 from"node:fs";import o8 from"node:path";import{fileURLToPath as L1}from"node:url";var F1=o8.dirname(L1(import.meta.url));function j1({baseDir:Q}){Q=Q||F1;let Z=Q;while(Z!==o8.parse(Z).root){let X=o8.join(Z,"node_modules");if(C1.existsSync(X))return X;Z=o8.dirname(Z)}return null}var MZ=j1;var w1=OZ.dirname(T1(import.meta.url));function AZ(){let Q=MZ({baseDir:w1}),Z=process.platform==="win32"?";":":";if(Q)process.env.PATH=`${OZ.join(Q,"/.bin")}${Z}${process.env.PATH}`}h7();AZ();async function N1(){try{let Q=S1(process.argv.slice(2)).usage("Usage: $0 <command> [options]").command(p7).command(i7).command(JZ).command(WZ).command(HZ).command(VZ).command(_Z).command("express","Create and manage express projects",UZ);Q=o(Q,{bin:"npm",createContext:k}),Q=o(Q,{bin:"node",createContext:k}),Q=o(Q,{bin:"bun",createContext:k}),Q=o(Q,{name:"serve",bin:"bun",preArgs:["run","serve","--"],createContext:k}),Q=o(Q,{name:"watch",bin:"bun",preArgs:["run","watch","--"],createContext:k}),Q=o(Q,{name:"app",bin:"bun",preArgs:["run","app","--"],createContext:k}),Q=o(Q,{name:"cli",bin:"bun",preArgs:["run","cli","--"],createContext:k}),Q=o(Q,{name:"cli:dev",bin:"bun",preArgs:["run","cli:dev","--"],createContext:k}),Q=o(Q,{name:"cli:compile",bin:"bun",preArgs:["run","cli:compile","--"],createContext:k}),Q=o(Q,{name:"cli:compile:dev",bin:"bun",preArgs:["run","cli:compile:dev","--"],createContext:k}),Q=o(Q,{name:"cli:install",bin:"bun",preArgs:["run","cli:install","--"],createContext:k}),Q=o(Q,{name:"compile",bin:"bun",preArgs:["run","compile","--"],createContext:k}),Q=l7(Q,{name:"install",createContext:k}),Q=o(Q,{bin:"npx",createContext:k}),Q=o(Q,{bin:"cdk",createContext:k}),Q=o(Q,{bin:"aws",createContext:k}),Q=m7(Q,{name:"with",createContext:k}),Q=c7(Q,{name:"run",projectType:"fnet"}),Q.demandCommand(1,"You need at least one command before moving on").help().version().argv}catch(Q){console.error(BZ.red(`Fatal error: ${Q.message}`)),process.exit(1)}}N1().catch((Q)=>{console.error(BZ.red(`Fatal error: ${Q.message}`)),process.exit(1)});