@fnet/cli 0.3.10 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/fnet/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as U0,b as V0}from"./index.2084z2ed.js";import{c as k,d as X5,e as E}from"./index.r19p3bpa.js";var W5=X5((E3,J5)=>{J5.exports=q5;function q5($,Q,Z){if($ instanceof RegExp)$=Z5($,Z);if(Q instanceof RegExp)Q=Z5(Q,Z);var X=Y5($,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 Z5($,Q){var Z=Q.match($);return Z?Z[0]:null}q5.range=Y5;function Y5($,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 M5=X5((y3,U5)=>{var H5=W5();U5.exports=f7;var V5="\x00SLASH"+Math.random()+"\x00",K5="\x00OPEN"+Math.random()+"\x00",v$="\x00CLOSE"+Math.random()+"\x00",_5="\x00COMMA"+Math.random()+"\x00",G5="\x00PERIOD"+Math.random()+"\x00";function k$($){return parseInt($,10)==$?parseInt($,10):$.charCodeAt(0)}function x7($){return $.split("\\\\").join(V5).split("\\{").join(K5).split("\\}").join(v$).split("\\,").join(_5).split("\\.").join(G5)}function u7($){return $.split(V5).join("\\").split(K5).join("{").split(v$).join("}").split(_5).join(",").split(G5).join(".")}function z5($){if(!$)return[""];var Q=[],Z=H5("{","}",$);if(!Z)return $.split(",");var{pre:X,body:q,post:Y}=Z,W=X.split(",");W[W.length-1]+="{"+q+"}";var J=z5(Y);if(Y.length)W[W.length-1]+=J.shift(),W.push.apply(W,J);return Q.push.apply(Q,W),Q}function f7($){if(!$)return[];if($.substr(0,2)==="{}")$="\\{\\}"+$.substr(2);return c0(x7($),!0).map(u7)}function h7($){return"{"+$+"}"}function g7($){return/^-?0\d/.test($)}function m7($,Q){return $<=Q}function c7($,Q){return $>=Q}function c0($,Q){var Z=[],X=H5("{","}",$);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(_=z5(X.body),_.length===1){if(_=c0(_[0],!1).map(h7),_.length===1)return Y.map(function(r1){return X.pre+_[0]+r1})}var O;if(K){var U=k$(_[0]),M=k$(_[1]),z=Math.max(_[0].length,_[1].length),A=_.length==3?Math.abs(k$(_[2])):1,B=m7,R=M<U;if(R)A*=-1,B=c7;var L=_.some(g7);O=[];for(var b=U;B(b,M);b+=A){var f;if(V){if(f=String.fromCharCode(b),f==="\\")f=""}else if(f=String(b),L){var Z0=z-f.length;if(Z0>0){var b0=Array(Z0+1).join("0");if(b<0)f="-"+b0+f.slice(1);else f=b0+f}}O.push(f)}}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 x2 from"yargs";import i1 from"chalk";import{promisify as s1}from"node:util";import n1 from"tree-kill";var O6=s1(n1),j0=!1;async function m8($,Q){if(j0)return;if(j0=!0,!$.killed&&$.pid)try{if(await O6($.pid,"SIGTERM").catch(()=>{}),await new Promise((X)=>setTimeout(X,500)),!$.killed)await O6($.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 A6(){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 B6}from"node:child_process";import H8 from"node:fs";import g0 from"chalk";import a1 from"@fnet/config";function p($,{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=B6(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 R6($,{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 a1({name:J,dir:W,transferEnv:!1,optional:!0,tags:Y.tags}))?.data?.env||void 0,K=q.command,G=process.argv.slice(5),_=B6(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 C6($,{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 I6($,{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",(A)=>{if(A===0)M();else z(Error(`Compilation failed with code ${A}`))}),_.on("error",(A)=>{z(A)})}),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",(A)=>{if(A===0)M();else z(Error(`Installation failed with code ${A}`))}),U.on("error",(A)=>{z(A)})})}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 o1 from"yaml";async function w($){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 t1({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 t1({tags:$}){let Q=e1(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=o1.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 e1($){return H0.resolve($,"fnet.yaml")}import $7 from"node:path";import F6 from"node:fs";import Q7 from"node:os";import Z7 from"@flownet/lib-render-templates-dir";import d8 from"@fnet/shelljs";var X7={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=$7.resolve(Q,$.name);if(!F6.existsSync(X))F6.mkdirSync(X);await Z7({dir:Z,outDir:X,context:$,copyUnmatchedAlso:!0,platform:Q7.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)}}},L6=X7;import q7 from"node:os";import Y7 from"@flownet/lib-render-templates-dir";import J7 from"@fnet/shelljs";var W7={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 w($);if($.update){if(await Y7({dir:Q,outDir:Z,context:{name:X.project.projectFileParsed.name,runtime:"node"},copyUnmatchedAlso:!0,platform:q7.platform()}),(await J7("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)}}},j6=W7;import j from"node:fs";import S from"node:path";import w1 from"yaml";import P1 from"@fnet/shelljs";import W8 from"nunjucks";import N1 from"lodash.clonedeep";import V2 from"isobject";import{randomUUID as b1}from"node:crypto";import p8 from"winston";var{combine:T6,timestamp:S6,printf:H7,colorize:V7}=p8.format,w6=H7(({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:T6(S6({format:"HH:mm:ss.SSS"}),w6),transports:[new p8.transports.Console({format:T6(V7(),S6({format:"HH:mm:ss.SSS"}),w6)})]}),N6=($)=>{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})}},D=N6("tree"),v=N6("bpmn"),P6=process.env.FNET_LOG_CATEGORIES?.split(",")||[],I=($)=>{if(P6.length===0)return!1;return P6.includes($)};import{Api as K8}from"@flownet/lib-atom-api-js";class b6{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 D0 from"lodash.merge";import _8 from"node:fs";import q0 from"node:path";import k0 from"@flownet/lib-parse-imports-js";import K7 from"lodash.merge";function P({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=K7(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;P({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 r8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;P({feature:{name:"gzip",packages:[["rollup-plugin-gzip","^4"]],explicit:!0},features:X,packageDevDependencies:Z})}function s8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;P({feature:{name:"nunjucks",packages:[["@fnet/rollup-plugin-nunjucks","0.1.8"]]},features:X,packageDevDependencies:Z})}function n8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;P({feature:{name:"polyfill",packages:[["rollup-plugin-node-polyfills","^0.2"]]},features:X,packageDevDependencies:Z})}function a8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;P({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;P({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;P({feature:{name:"string",packages:[["rollup-plugin-string","^3"]]},features:X,packageDevDependencies:Z})}function e8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;P({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;P({feature:{name:"json",packages:[["@rollup/plugin-json","^6"]]},features:X,packageDevDependencies:Z})}function Q$($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;P({feature:{name:"terser",packages:[["@rollup/plugin-terser","^0.4"]]},features:X,packageDevDependencies:Z})}function Z$($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;P({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}}P({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}});P({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((A)=>A.usesJSX===!0&&A.type==="local");q.app_uses_jsx=z,q.app_has_entry=!0,M=await k0({file:W.file}),z=M.all.some((A)=>A.usesJSX===!0&&A.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((A)=>A.usesJSX===!0&&A.type==="local");q.cli_uses_jsx=z,q.cli_has_entry=!0,M=await k0({file:J.file}),z=M.all.some((A)=>A.usesJSX===!0&&A.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}),A=z.all.some((B)=>B.usesJSX===!0&&B.type==="local");q.src_uses_jsx=A,q.src_has_entry=!0,z=await k0({file:M.file}),A=z.all.some((B)=>B.usesJSX===!0&&B.type==="local"),q.src_entry_uses_jsx=A,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=D0(G,q.babel_options||q.babel?.options),q.browsersync_options=D0(O,q.browsersync_options||q.browsersync?.options||{}),q.replace_options=D0(_,q.replace_options||q.replace?.options||{}),Reflect.has(q.browsersync_options,"proxy"))delete q.browsersync_options.server;q.rollup=q.rollup||{},q.rollup_output=D0(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=D0(q.browsersync_options,z.browsersync_options),z.replace_options=D0(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($),a8($),n8($),s8($),i8($),r8($)}import _7 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 _7({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 G7 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 G7({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 D6 from"node:fs";import k6 from"node:path";import z7 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=k6.resolve(Z.projectDir,"src/app");if(!D6.existsSync(W))D6.mkdirSync(W,{recursive:!0});let J=["index.js.njk"];if($.doc.features.app.html!==!1)J.push("index.html.njk");await z7({pattern:J,dir:k6.resolve(Y,"src/app"),outDir:W,context:q})}import E6 from"nunjucks";import M0 from"node:fs";import R0 from"node:path";import O7 from"@flownet/lib-parse-imports-js";import U7 from"@fnet/npm-pick-versions";import M7 from"object-hash";import G8 from"node:fs";import v6 from"node:path";async function v0({projectDir:$,name:Q,setProgress:Z,count:X=1}){let q,W=M7(["npm-pick-versions",Q,X]),J=v6.join($,".cache"),H=v6.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 U7({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((B)=>B.package===z.package))X.push(z);let A=Z.findIndex((B)=>B.package===z.package);Z.splice(A,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!==!1});if($.doc.features.cli.enabled===!0)H.push({file:R0.resolve(Q.projectDir,"src/cli/index.js"),dev:$.doc.features.cli.dev!==!1});for await(let z of H){let A=z.file;if(!M0.existsSync(A))throw Error(`App file not found: ${A}`);let R=(await O7({file:A,recursive:!0,verbose:!1})).all;for await(let L of R){if(L.type!=="npm")continue;if(Z.find((Z0)=>Z0.package===L.package))continue;if(X.find((Z0)=>Z0.package===L.package))continue;let b=await v0({name:L.package,projectDir:Q.projectDir,setProgress:q});(z.dev===!0?X:Z).push({package:L.package,subpath:L.subpath,version:b.minorRange,type:"npm"})}}let V={atom:$,packageDependencies:Z,packageDevDependencies:X},K=Q.templateDir,_=E6.compile(M0.readFileSync(R0.resolve(K,"package.json.njk"),"utf8"),E6.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 A=M0.readdirSync(M);for(let B of A){let R=R0.resolve(M,B);if(!M0.lstatSync(R).isFile())continue;let L=R0.resolve(z,B);M0.copyFileSync(R,L)}}}import y6 from"node:fs";import x6 from"node:path";import A7 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=x6.resolve(Z.projectDir,"src/cli");if(!y6.existsSync(W))y6.mkdirSync(W,{recursive:!0});await A7({pattern:["index.js.njk"],dir:x6.resolve(Y,"src/cli"),outDir:W,context:q})}import G$ from"node:fs";import z$ from"node:path";import u6 from"nunjucks";import B7 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 B7({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],A=H[z];if(A.browser===!0){if(J.length>0){A.globals_enabled=!0,A.globals=A.globals||[],A.globals=A.globals.concat(J.map((B)=>{return{key:B,value:B}})),A.alias_enabled=!0,A.alias=A.alias||{},A.alias.entries=A.alias.entries||{};for(let B=0;B<J.length;B++){let R=J[B];A.alias.entries[R]=`node:${R}`,A.alias.entries[`node:${R}`]=R}A.external_enabled=!0,A.external=A.external||[],A.external=A.external.concat(J)}}}let K=Z.templateDir,_=u6.compile(G$.readFileSync(z$.resolve(K,"rollup.config.mjs.njk"),"utf8"),u6.configure(K)).render(q),O=Z.projectDir,U=z$.resolve(O,"rollup.config.mjs");G$.writeFileSync(U,_,"utf8")}import M$ from"node:fs";import f6 from"node:path";import h6 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=h6.compile(M$.readFileSync(f6.resolve(Y,"build.js.njk"),"utf8"),h6.configure(Y)).render(q),H=Z.projectDir,V=f6.resolve(H,"build.js");M$.writeFileSync(V,J,"utf8"),M$.chmodSync(V,"755")}import A$ from"node:fs";import B$ from"node:path";import R7 from"nunjucks";import C7 from"ajv/dist/2020.js";import I7 from"ajv/dist/standalone/index.js";import F7 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 A=$.doc.features.cli.fargs,B={type:"string",description:"Config name to load args",hidden:!1},R={type:"array",description:"Tags to filter the config",hidden:!1};if(Reflect.has(A,"default"))B.default=A.default}let J={imports:Y,atom:$},H=Z.templateDir,K=R7.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 C7({allErrors:!0,useDefaults:!0,formats:{},strict:!1,code:{esm:!0,lines:!0,optimize:!1,source:!0}});F7(O);let U=O.compile(q),z=I7(O,U)+`
|
|
4
|
-
export { schema31 as schema };`;A$.writeFileSync(B$.resolve(G,"src/default/validate_input.js"),z,"utf8")}import g6 from"node:fs";import m6 from"node:path";import c6 from"nunjucks";async function C$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){await Q({message:"Creating .gitignore"});let q={atom:$,packageDependencies:X},Y=Z.templateDir,J=c6.compile(g6.readFileSync(m6.resolve(Y,".gitignore.njk"),"utf8"),c6.configure(Y)).render(q),H=Z.projectDir,V=m6.resolve(H,".gitignore");g6.writeFileSync(V,J,"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 tsconfig.json."});let q={atom:$,packageDependencies:X},Y=Z.templateDir,J=p6.compile(l6.readFileSync(d6.resolve(Y,"tsconfig.json.njk"),"utf8"),p6.configure(Y)).render(q),H=Z.projectDir,V=d6.resolve(H,"tsconfig.json");l6.writeFileSync(V,J,"utf8")}import z8 from"nunjucks";import C0 from"node:fs";import S0 from"node:path";import i6 from"@fnet/yaml";async function F$({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=S0.resolve(Q.project.projectDir,"fnet/how-to.md");if(C0.existsSync(H)){let M=C0.readFileSync(H,"utf8");J.howto=M}let V=S0.resolve(Q.project.projectDir,"fnet/input.yaml");if(C0.existsSync(V)){let M=await i6({file:V,tags:Q.tags});J.input=M.content}let K=S0.resolve(Q.project.projectDir,"fnet/output.yaml");if(C0.existsSync(K)){let M=await i6({file:K,tags:Q.tags});J.output=M.content}let G=Q.templateDir,O=z8.compile(C0.readFileSync(S0.resolve(G,"readme.md.njk"),"utf8"),z8.configure(G)).render(J),U=S0.resolve(W,"readme.md");C0.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(C0.readFileSync(S0.resolve(K,"readme.md.njk"),"utf8"),z8.configure(K)).render(V),O=Q.projectDir,U=S0.resolve(O,"readme.md");C0.writeFileSync(U,_,"utf8")}}import L7 from"node:path";import r6 from"@fnet/shelljs";async function L$({setProgress:$,context:Q}){let Z=Q.projectDir;await $({message:"Prettifiying source files."});let X=L7.join("src","**","*");if(V0("bun")){let q=await r6(`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 r6(`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 j7 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 j7("tsc",{cwd:X})).code!==0)throw Error("Couldnt create .d.ts files.")}import s6 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 s6(`bun install ${Q.doc.features.npm_install_flags}`,{cwd:X})).code!==0)throw Error("Couldnt install npm packages.")}else if((await s6(`npm install ${Q.doc.features.npm_install_flags}`,{cwd:X})).code!==0)throw Error("Couldnt install npm packages.")}import n6 from"node:fs";import T7 from"node:path";import{spawn as S7}from"node:child_process";async function a6($){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=T7.resolve(Q,"package.json");if(!n6.existsSync(H))throw Error(`package.json not found at ${H}`);let V=JSON.parse(n6.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,_=S7(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 w7 from"node:path";async function S$({setProgress:$,context:Q}){let Z=Q.projectDir;await $({message:"Building main project."});let X=Q.dev?"build:dev":"build",q={...process.env},Y=w7.join(Z,"node_modules");q.NODE_PATH=Y;let W=q.NODE_OPTIONS||"";q.NODE_OPTIONS=`${W} --preserve-symlinks`.trim(),await a6({projectDir:Z,scriptName:X,shell:!0,detached:!0,env:q})}var o6=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 K2 from"@flownet/lib-parse-node-url";import e6 from"bpmn-moddle";import t6 from"dagre";import N$ from"lodash.clonedeep";var w$={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 $5($){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),I("bpmn"))v.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=N7(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 N7($){let Q;if($.type==="call"){if($.context?.lib?.type==="subworkflow"||$.context?.lib?.type==="workflow"){if(Q="bpmn:CallActivity",I("bpmn"))v.info(` \uD83D\uDCE6 CALL → CallActivity (subworkflow): ${$.indexKey}`,{nodeType:$.type,bpmnType:Q,calledElement:$.context?.lib?.name||"unknown",isChip:!0})}else if(Q="bpmn:ServiceTask",I("bpmn"))v.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",I("bpmn"))v.info(` \uD83D\uDCDD FORM → UserTask: ${$.indexKey}`,{nodeType:$.type,bpmnType:Q})}else if($.type==="return"){if(Q="bpmn:EndEvent",I("bpmn"))v.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",I("bpmn"))v.info(` ⚡ RAISE → IntermediateThrowEvent (inside try): ${$.indexKey}`,{nodeType:$.type,bpmnType:Q,nodeName:$.name,parent:$.parent?.indexKey})}else if(Q="bpmn:EndEvent",I("bpmn"))v.info(` ⚠️ RAISE → EndEvent (error): ${$.indexKey}`,{nodeType:$.type,bpmnType:Q})}else if($.type==="pipeline"){if(Q="bpmn:ServiceTask",I("bpmn"))v.info(` \uD83D\uDD27 PIPELINE → ServiceTask (external binary): ${$.indexKey}`,{nodeType:$.type,bpmnType:Q,binary:$.context?.binaryName||"unknown"})}else if($.type==="assign"||$.type==="new"){if(Q="bpmn:ScriptTask",I("bpmn"))v.info(` \uD83D\uDCDC ${$.type.toUpperCase()} → ScriptTask: ${$.indexKey}`,{nodeType:$.type,bpmnType:Q})}else if(Q="bpmn:Task",I("bpmn"))v.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 b$($){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((V)=>!V.virtual).length>0,H=(Y.name==="try"||Y.name==="except")&&Y.parent?.type==="tryexcept";if(J||H){if(Y.bpmn.type="bpmn:SubProcess",Y.type==="for"){if(Y.bpmn.loopCharacteristics=!0,I("bpmn"))v.info(" \uD83D\uDD01 FOR → SubProcess + Loop Marker",{subprocess:Y.indexKey,loopType:"StandardLoopCharacteristics"})}if(Y.name==="try"&&Y.type==="raise"&&Y.parent?.type==="tryexcept"){let V=a({location:0,...$,parent:Y,bpmnType:"bpmn:IntermediateThrowEvent",type:"raise",attrs:{},definitions:[{type:"bpmn:ErrorEventDefinition"}]});if(I("bpmn"))v.info(" ⚡ Created virtual IntermediateThrowEvent for single-step try block",{tryNode:Y.indexKey,virtualNode:V.indexKey,bpmnType:V.bpmn.type})}}if(W||J){let V=Y.childs.filter((z)=>z.module!==!0&&!z.indexKey.endsWith("/_inline_end"))[0];Y.childs.filter((z)=>z.module===!0).forEach((z)=>{let A=a({...$,parent:Y,bpmnType:"bpmn:IntermediateCatchEvent",type:"inter",definitions:[{type:"bpmn:SignalEventDefinition"}]});A.bpmn.edges=[{from:A.indexKey,to:z.indexKey,type:"bpmn:SequenceFlow"}]});let G=Y.childs.find((z)=>z.name==="try"&&Y.type==="tryexcept"),_=Y.childs.filter((z)=>z.name==="except"&&Y.type==="tryexcept");if(G&&_.length)_.forEach((z)=>{let A=a({location:Y.childs.indexOf(z),...$,parent:Y,bpmnType:"bpmn:BoundaryEvent",type:"boundary",attrs:{attachedToRef:G},definitions:[{type:"bpmn:ErrorEventDefinition"}]});if(A.bpmn.edges=[{from:A.indexKey,to:z.indexKey,type:"bpmn:SequenceFlow"}],I("bpmn"))v.info(" ⚡ TRY-EXCEPT → BoundaryEvent",{subprocess:Y.indexKey,tryNode:G.indexKey,exceptNode:z.indexKey,boundaryEvent:A.indexKey})});let O=Y.childs.find((z)=>z.type==="raise");if(O){let z=a({...$,parent:Y,bpmnType:"bpmn:EndEvent",type:"end",name:"ERROR",definitions:[{type:"bpmn:ErrorEventDefinition"}]});O.bpmn.edges=[{from:O.indexKey,to:z.indexKey,type:"bpmn:SequenceFlow"}]}if(V)if(Y.type==="parallel"){let z=a({...$,parent:Y,bpmnType:"bpmn:StartEvent",type:"start"}),A=a({...$,parent:Y,bpmnType:"bpmn:ParallelGateway",type:"fork"}),B=a({...$,parent:Y,bpmnType:"bpmn:ParallelGateway",type:"join"}),R=a({...$,parent:Y,bpmnType:"bpmn:EndEvent",type:"end"});z.bpmn.edges=[{from:z.indexKey,to:A.indexKey,type:"bpmn:SequenceFlow"}];let L=Y.childs.filter((b)=>!b.virtual&&!b.module&&!b.indexKey.endsWith("/_inline_end"));if(A.bpmn.edges=L.map((b)=>{return{from:A.indexKey,to:b.indexKey,type:"bpmn:SequenceFlow"}}),L.forEach((b)=>{b.bpmn.edges=[{from:b.indexKey,to:B.indexKey,type:"bpmn:SequenceFlow"}]}),B.bpmn.edges=[{from:B.indexKey,to:R.indexKey,type:"bpmn:SequenceFlow"}],I("bpmn"))v.info(" \uD83D\uDD00 PARALLEL → Fork/Join Gateways",{subprocess:Y.indexKey,childCount:L.length,pattern:"Start → Fork → [Tasks] → Join → End"})}else if(Y.bpmn.starts.length>1){let z=a({...$,parent:Y,bpmnType:"bpmn:StartEvent",type:"start"}),A=a({...$,parent:Y,bpmnType:"bpmn:ExclusiveGateway",type:"switch"});z.bpmn.edges=[{from:z.indexKey,to:A.indexKey,type:"bpmn:SequenceFlow"}],A.bpmn.edges=Y.bpmn.starts.map((R)=>{return{...R,from:A.indexKey}});let B=A.bpmn.edges.find((R)=>R.next===!0);if(B){let R=a({...$,parent:Y,bpmnType:"bpmn:EndEvent",type:"end",name:B.to});B.to=R.indexKey}}else{let z=a({...$,parent:Y,bpmnType:"bpmn:StartEvent",type:"start"});z.bpmn.edges.push({from:z.indexKey,to:V.indexKey,type:"bpmn:SequenceFlow"})}else if(I("bpmn"))v.info(" \uD83D\uDEAB START EVENT skipped (no valid firstNode)",{subprocess:Y.indexKey,reason:"Only modules or inline end events in subprocess"});Y.childs.filter((z)=>z.virtual!==!0&&z.bpmn.outside.length&&z.bpmn.type!=="bpmn:EndEvent").forEach((z)=>{z.bpmn.outside.forEach((A)=>{let B=q.indexOf(Y),R=a({...$,parent:Y,bpmnType:"bpmn:EndEvent",type:"end",name:A.to,location:B+1});z.bpmn.edges.push({from:z.indexKey,to:R.indexKey,type:"bpmn:SequenceFlow"})})}),Y.childs.filter((z)=>z.virtual!==!0&&z.bpmn.edges.length>1).forEach((z)=>{let A=q.indexOf(z),B=a({...$,parent:Y,bpmnType:"bpmn:ExclusiveGateway",type:"switch",location:A+1});B.bpmn.edges=z.bpmn.edges.map((R)=>{return{...R,from:B.indexKey}}),z.bpmn.edges=[{from:z.indexKey,to:B.indexKey,type:"bpmn:SequenceFlow"}],z.bpmn.outside=[]})}b$({...$,targetNodes:Y.childs})})}function a($){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(I("bpmn"))v.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 D$($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:Y,nodeIndex:W,diagrams:J,nodes:H}=$;b7($),D7($),k7($),v7($)}function b7($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:Y,nodeIndex:W,nodes:J}=$,H=Z.get("flowElements");if(Z.$nodes=Z.$nodes||[],I("bpmn"))v.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,I("bpmn"))v.info(` ✨ Created: ${V.bpmn.type} (chip!)`,{id:K.id,name:K.name,calledElement:K.calledElement,nodeType:V.type,virtual:V.virtual||!1})}else if(I("bpmn"))v.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"),I("bpmn"))v.info(` \uD83D\uDD01 Added loop marker to: ${K.id}`,{nodeType:V.type,loopType:"StandardLoopCharacteristics"})}})}function D7($){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 k7($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:Y,nodeIndex:W}=$,J=120,H=80,V=160,K=160,G=new t6.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)}),t6.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 A=q.create("dc:Point",{x:160+z.x,y:160+z.y});U.get("waypoint").push(A)}),X.get("planeElement").push(U)})}function v7($){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,D$({...$,targetNode:V,targetFlowElementsContainer:K,targetPlaneElement:_})})}async function E7($){let Q=$.root,Z=Q.context.index,X=Object.keys(Z).map((V)=>Z[V]);$5({nodes:X,nodeIndex:Z,root:Q}),b$({nodes:X,nodeIndex:Z,root:Q});let q=void 0,Y=new e6({atom:w$}),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=_,D$({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 y7($){let{root:Q,flowName:Z}=$,X=N$(Q),q=X.childs.find((L)=>L.name===Z);if(!q)throw Error(`Flow "${Z}" not found`);let Y={...X,childs:[q]},W=Y.context.index,J=Object.keys(W).map((L)=>W[L]);$5({nodes:J,nodeIndex:W,root:Y}),b$({nodes:J,nodeIndex:W,root:Y});let H=new e6({atom:w$}),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,D$({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 E7(N$($))}async function Q5($={}){let Q=N$($),{root:Z}=Q,X=[];for(let q of Z.childs){let Y=await y7({root:Z,flowName:q.name});X.push(Y)}return X}import _2 from"@fnet/config";import G2 from"@flownet/lib-parse-imports-js";import D1 from"@fnet/expression";import z2 from"@fnet/yaml";import U2 from"chalk";var L5=k(M5(),1);var l0=($)=>{if(typeof $!=="string")throw TypeError("invalid pattern");if($.length>65536)throw TypeError("pattern is too long")};var l7={"[: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,"\\$&"),d7=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),O5=($)=>$.join(""),A5=($,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,[A,B,R]]of Object.entries(l7))if($.startsWith(z,Y)){if(G)return["$.",!1,$.length-Z,!0];if(Y+=z.length,R)q.push(A);else X.push(A);J=J||B;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[d7(M),!1,K-Z,!1]}let _="["+(V?"^":"")+O5(X)+"]",O="["+(V?"":"^")+O5(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 p7=new Set(["!","?","+","*","@"]),B5=($)=>p7.has($),i7="(?!(?:^|/)\\.\\.?(?:$|/))",M8="(?!\\.)",r7=new Set(["[","."]),s7=new Set(["..","."]),n7=new Set("().*{}+?[]^$\\!"),a7=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),E$="[^/]",R5=E$+"*?",C5=E$+"+?";class c{type;#Q;#$;#Z=!1;#X=[];#Y;#I;#C;#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.#C=this.#Q===this?[]:this.#Q.#C,$==="!"&&!this.#Q.#V)this.#C.push(this);this.#I=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.#C.pop()){if($.type!=="!")continue;let Q=$,Z=Q.#Y;while(Z){for(let X=Q.#I+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 c&&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.#I===0)return!0;let $=this.#Y;for(let Q=0;Q<this.#I;Q++){let Z=$.#X[Q];if(!(Z instanceof c&&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.#I===$-1}copyIn($){if(typeof $==="string")this.push($);else this.push($.clone(this))}clone($){let Q=new c(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&&B5(U)&&$.charAt(_)==="("){Q.push(O),O="";let M=new c(U,Q);_=c.#O($,M,_,X),Q.push(M);continue}O+=U}return Q.push(O),_}let H=Z+1,V=new c(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(B5(_)&&$.charAt(H)==="("){V.push(G),G="";let O=new c(_,V);V.push(O),H=c.#O($,O,H,X);continue}if(_==="|"){V.push(G),G="",K.push(V),V=new c(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 c(null,void 0,Q);return c.#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"?c.#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&&s7.has(this.#X[0]))){let O=r7,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?i7: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:"")+C5;else{let J=this.type==="!"?"))"+(this.isStart()&&!Q&&!$?M8:"")+R5+")":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+=(n7.has(J)?"\\":"")+J;continue}if(J==="\\"){if(W===$.length-1)q+="\\\\";else X=!0;continue}if(J==="["){let[H,V,K,G]=A5($,W);if(K){q+=H,Y=Y||V,W+=K-1,Q=Q||G;continue}}if(J==="*"){if(Z&&$==="*")q+=C5;else q+=R5;Q=!0;continue}if(J==="?"){q+=E$,Q=!0;continue}q+=a7(J)}return[q,Y0($),!!Q,Y]}}var E0=($,{windowsPathsNoEscape:Q=!1}={})=>{return Q?$.replace(/[?*()[\]]/g,"[$&]"):$.replace(/[?*()[\]\\]/g,"\\$&")};var r=($,Q,Z={})=>{if(l0(Q),!Z.nocomment&&Q.charAt(0)==="#")return!1;return new e(Q,Z).match($)},o7=/^\*+([^+@!?\*\[\(]*)$/,t7=($)=>(Q)=>!Q.startsWith(".")&&Q.endsWith($),e7=($)=>(Q)=>Q.endsWith($),$9=($)=>{return $=$.toLowerCase(),(Q)=>!Q.startsWith(".")&&Q.toLowerCase().endsWith($)},Q9=($)=>{return $=$.toLowerCase(),(Q)=>Q.toLowerCase().endsWith($)},Z9=/^\*+\.\*+$/,X9=($)=>!$.startsWith(".")&&$.includes("."),q9=($)=>$!=="."&&$!==".."&&$.includes("."),Y9=/^\.\*+$/,J9=($)=>$!=="."&&$!==".."&&$.startsWith("."),W9=/^\*+$/,H9=($)=>$.length!==0&&!$.startsWith("."),V9=($)=>$.length!==0&&$!=="."&&$!=="..",K9=/^\?+([^+@!?\*\[\(]*)?$/,_9=([$,Q=""])=>{let Z=j5([$]);if(!Q)return Z;return Q=Q.toLowerCase(),(X)=>Z(X)&&X.toLowerCase().endsWith(Q)},G9=([$,Q=""])=>{let Z=T5([$]);if(!Q)return Z;return Q=Q.toLowerCase(),(X)=>Z(X)&&X.toLowerCase().endsWith(Q)},z9=([$,Q=""])=>{let Z=T5([$]);return!Q?Z:(X)=>Z(X)&&X.endsWith(Q)},U9=([$,Q=""])=>{let Z=j5([$]);return!Q?Z:(X)=>Z(X)&&X.endsWith(Q)},j5=([$])=>{let Q=$.length;return(Z)=>Z.length===Q&&!Z.startsWith(".")},T5=([$])=>{let Q=$.length;return(Z)=>Z.length===Q&&Z!=="."&&Z!==".."},S5=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",I5={win32:{sep:"\\"},posix:{sep:"/"}},M9=S5==="win32"?I5.win32.sep:I5.posix.sep;r.sep=M9;var l=Symbol("globstar **");r.GLOBSTAR=l;var O9="[^/]",A9=O9+"*?",B9="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",R9="(?:(?!(?:\\/|^)\\.).)*?",C9=($,Q={})=>(Z)=>r(Z,$,Q);r.filter=C9;var t=($,Q={})=>Object.assign({},$,Q),I9=($)=>{if(!$||typeof $!=="object"||!Object.keys($).length)return r;let Q=r;return Object.assign((X,q,Y={})=>Q(X,q,t($,Y)),{Minimatch:class extends Q.Minimatch{constructor(q,Y={}){super(q,t($,Y))}static defaults(q){return Q.defaults(t($,q)).Minimatch}},AST:class extends Q.AST{constructor(q,Y,W={}){super(q,Y,t($,W))}static fromGlob(q,Y={}){return Q.AST.fromGlob(q,t($,Y))}},unescape:(X,q={})=>Q.unescape(X,t($,q)),escape:(X,q={})=>Q.escape(X,t($,q)),filter:(X,q={})=>Q.filter(X,t($,q)),defaults:(X)=>Q.defaults(t($,X)),makeRe:(X,q={})=>Q.makeRe(X,t($,q)),braceExpand:(X,q={})=>Q.braceExpand(X,t($,q)),match:(X,q,Y={})=>Q.match(X,q,t($,Y)),sep:Q.sep,GLOBSTAR:l})};r.defaults=I9;var w5=($,Q={})=>{if(l0($),Q.nobrace||!/\{(?:(?!\{).)*\}/.test($))return[$];return L5.default($)};r.braceExpand=w5;var F9=($,Q={})=>new e($,Q).makeRe();r.makeRe=F9;var L9=($,Q,Z={})=>{let X=new e(Q,Z);if($=$.filter((q)=>X.match(q)),X.options.nonull&&!$.length)$.push(Q);return $};r.match=L9;var F5=/[?*]|[+@!]\(.*?\)|\[|\]/,j9=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class e{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||S5,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]==="?"||!F5.test(q[2]))&&!F5.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]),A=!z&&Q[0]===""&&Q[1]===""&&Q[2]==="?"&&typeof Q[3]==="string"&&/^[a-z]:$/i.test(Q[3]),B=M?3:U?0:void 0,R=A?3:z?0:void 0;if(typeof B==="number"&&typeof R==="number"){let[L,b]=[$[B],Q[R]];if(L.toLowerCase()===b.toLowerCase()){if(Q[R]=L,R>B)Q=Q.slice(R);else if(B>R)$=$.slice(B)}}}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===l){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,_,
|
|
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 w5(this.pattern,this.options)}parse($){l0($);let Q=this.options;if($==="**")return l;if($==="")return"";let Z,X=null;if(Z=$.match(W9))X=Q.dot?V9:H9;else if(Z=$.match(o7))X=(Q.nocase?Q.dot?Q9:$9:Q.dot?e7:t7)(Z[1]);else if(Z=$.match(K9))X=(Q.nocase?Q.dot?G9:_9:Q.dot?z9:U9)(Z);else if(Z=$.match(Z9))X=Q.dot?q9:X9;else if(Z=$.match(Y9))X=J9;let q=c.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?A9:Q.dot?B9:R9,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"?j9(V):V===l?l:V._src});return H.forEach((V,K)=>{let G=H[K+1],_=H[K-1];if(V!==l||_===l)return;if(_===void 0)if(G!==void 0&&G!==l)H[K+1]="(?:\\/|"+Z+"\\/)?"+G;else H[K]=Z;else if(G===void 0)H[K-1]=_+"(?:\\/|"+Z+")?";else if(G!==l)H[K-1]=_+"(?:\\/|\\/"+Z+"\\/)"+G,H[K+1]=l}),H.filter((V)=>V!==l).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 r.defaults($).Minimatch}}r.AST=c;r.Minimatch=e;r.escape=E0;r.unescape=Y0;import{fileURLToPath as ZQ}from"node:url";var y0=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,N5=new Set,y$=typeof process==="object"&&!!process?process:{},b5=($,Q,Z,X)=>{typeof y$.emitWarning==="function"?y$.emitWarning($,Q,Z,X):console.error(`[${Z}] ${Q}: ${$}`)},O8=globalThis.AbortController,P5=globalThis.AbortSignal;if(typeof O8>"u"){P5=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(X,q){this._onabort.push(q)}},O8=class{constructor(){Q()}signal=new P5;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,b5("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 T9=($)=>!N5.has($),o3=Symbol("type"),I0=($)=>$&&$===Math.floor($)&&$>0&&isFinite($),D5=($)=>!I0($)?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=D5($);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;#I;#C;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;#F;#K;#T;#B;#b;static unsafeExposeInternals($){return{starts:$.#W,ttls:$.#F,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)=>$.#w(Q)}}get max(){return this.#Q}get maxSize(){return this.#$}get calculatedSize(){return this.#G}get size(){return this.#V}get fetchMethod(){return this.#I}get memoMethod(){return this.#C}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:A,noDeleteOnFetchRejection:B,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:L,allowStaleOnFetchAbort:b,ignoreFetchAbort:f}=$;if(Q!==0&&!I0(Q))throw TypeError("max option must be a nonnegative integer");let Z0=Q?D5(Q):Array;if(!Z0)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(A!==void 0&&typeof A!=="function")throw TypeError("memoMethod must be a function if defined");if(this.#C=A,z!==void 0&&typeof z!=="function")throw TypeError("fetchMethod must be a function if specified");if(this.#I=z,this.#T=!!z,this.#H=new Map,this.#_=Array(Q).fill(void 0),this.#q=Array(Q).fill(void 0),this.#O=new Z0(Q),this.#M=new Z0(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.#b=!!this.#X,this.#B=!!this.#Y,this.noDisposeOnSet=!!G,this.noUpdateTTL=!!_,this.noDeleteOnFetchRejection=!!B,this.allowStaleOnFetchRejection=!!L,this.allowStaleOnFetchAbort=!!b,this.ignoreFetchAbort=!!f,this.maxEntrySize!==0){if(this.#$!==0){if(!I0(this.#$))throw TypeError("maxSize must be a positive integer if specified")}if(!I0(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=I0(X)||X===0?X:1,this.ttlAutopurge=!!q,this.ttl=Z||0,this.ttl){if(!I0(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(T9("LRU_CACHE_UNBOUNDED"))N5.add("LRU_CACHE_UNBOUNDED"),b5("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.#F=$,this.#W=Q,this.#D=(q,Y,W=y0.now())=>{if(Q[q]=Y!==0?W:0,$[q]=Y,Y!==0&&this.ttlAutopurge){let J=setTimeout(()=>{if(this.#w(q))this.#k(this.#_[q],"expire")},Y+1);if(J.unref)J.unref()}},this.#v=(q)=>{Q[q]=$[q]!==0?y0.now():0},this.#S=(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.#w=(q)=>{let Y=Q[q],W=$[q];return!!W&&!!Y&&(Z||X())-Y>W}}#v=()=>{};#S=()=>{};#D=()=>{};#w=()=>!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(!I0(X))if(q){if(typeof q!=="function")throw TypeError("sizeCalculation must be a function");if(X=q(Z,Q),!I0(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.#w(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.#w(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.#w(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.#F&&this.#W){let Y=this.#F[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.#F&&this.#W){Y.ttl=this.#F[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.#b)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.#b)this.onInsert?.(Q,$,Q===G?"update":"replace")}if(X!==0&&!this.#F)this.#J();if(this.#F){if(!H)this.#D(K,X,q);if(J)this.#S(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.#w(q)){if(Z)this.#v(q);if(X)X.has="hit",this.#S(X,q);return!0}else if(X)X.has="stale",this.#S(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.#w(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,A=Z.ignoreFetchAbort&&U!==void 0;if(Z.status)if(z&&!M){if(Z.status.fetchAborted=!0,Z.status.fetchError=Y.signal.reason,A)Z.status.fetchAbortIgnored=!0}else Z.status.fetchResolved=!0;if(z&&!A&&!M)return K(Y.signal.reason);let B=_;if(this.#q[Q]===_)if(U===void 0)if(B.__staleWhileFetching)this.#q[Q]=B.__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,A=z||Z.allowStaleOnFetchRejection,B=A||Z.noDeleteOnFetchRejection,R=_;if(this.#q[Q]===_){if(!B||R.__staleWhileFetching===void 0)this.#k($,"fetch");else if(!z)this.#q[Q]=R.__staleWhileFetching}if(A){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.#I?.($,q,J);if(z&&z instanceof Promise)z.then((A)=>U(A===void 0?void 0:A),M);Y.signal.addEventListener("abort",()=>{if(!Z.ignoreFetchAbort||Z.allowStaleOnFetchAbort){if(U(void 0),Z.allowStaleOnFetchAbort)U=(A)=>H(A,!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:A}=Q;if(!this.#T){if(z)z.fetch="get";return this.get($,{allowStale:Z,updateAgeOnGet:X,noDeleteOnStaleGet:q,status:z})}let B={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:A},R=this.#H.get($);if(R===void 0){if(z)z.fetch="miss";let L=this.#y($,R,B,U);return L.__returned=L}else{let L=this.#q[R];if(this.#z(L)){let X0=Z&&L.__staleWhileFetching!==void 0;if(z){if(z.fetch="inflight",X0)z.returnedStale=!0}return X0?L.__staleWhileFetching:L.__returned=L}let b=this.#w(R);if(!M&&!b){if(z)z.fetch="hit";if(this.#f(R),X)this.#v(R);if(z)this.#S(z,R);return L}let f=this.#y($,R,B,U),b0=f.__staleWhileFetching!==void 0&&Z;if(z){if(z.fetch=b?"stale":"refresh",b0&&b)z.returnedStale=!0}return b0?f.__staleWhileFetching:f.__returned=f}}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.#C;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.#S(Y,W);if(this.#w(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.#F&&this.#W)this.#F.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 x9,win32 as p$}from"node:path";import{fileURLToPath as u9}from"node:url";import{lstatSync as f9,readdir as h9,readdirSync as g9,readlinkSync as m9,realpathSync as c9}from"fs";import*as l9 from"node:fs";import{lstat as p9,readdir as i9,readlink as r9,realpath as s9}from"node:fs/promises";import{EventEmitter as m$}from"node:events";import x5 from"node:stream";import{StringDecoder as S9}from"node:string_decoder";var k5=typeof process==="object"&&process?process:{stdout:null,stderr:null},w9=($)=>!!$&&typeof $==="object"&&($ instanceof P0||$ instanceof x5||P9($)||N9($)),P9=($)=>!!$&&typeof $==="object"&&$ instanceof m$&&typeof $.pipe==="function"&&$.pipe!==x5.Writable.prototype.pipe,N9=($)=>!!$&&typeof $==="object"&&$ instanceof m$&&typeof $.write==="function"&&typeof $.end==="function",O0=Symbol("EOF"),A0=Symbol("maybeEmitEnd"),F0=Symbol("emittedEnd"),A8=Symbol("emittingEnd"),r0=Symbol("emittedError"),B8=Symbol("closed"),v5=Symbol("read"),R8=Symbol("flush"),E5=Symbol("flushChunk"),J0=Symbol("encoding"),u0=Symbol("decoder"),h=Symbol("flowing"),s0=Symbol("paused"),f0=Symbol("resume"),g=Symbol("buffer"),s=Symbol("pipes"),m=Symbol("bufferLength"),x$=Symbol("bufferPush"),C8=Symbol("bufferShift"),i=Symbol("objectMode"),y=Symbol("destroyed"),u$=Symbol("error"),f$=Symbol("emitData"),y5=Symbol("emitEnd"),h$=Symbol("emitEnd2"),K0=Symbol("async"),g$=Symbol("abort"),I8=Symbol("aborted"),n0=Symbol("signal"),w0=Symbol("dataListeners"),o=Symbol("discarded"),a0=($)=>Promise.resolve().then($),b9=($)=>$(),D9=($)=>$==="end"||$==="finish"||$==="prefinish",k9=($)=>$ instanceof ArrayBuffer||!!$&&typeof $==="object"&&$.constructor&&$.constructor.name==="ArrayBuffer"&&$.byteLength>=0,v9=($)=>!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 u5 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 E9=($)=>!!$.objectMode,y9=($)=>!$.objectMode&&!!$.encoding&&$.encoding!=="buffer";class P0 extends m${[h]=!1;[s0]=!1;[s]=[];[g]=[];[i];[J0];[K0];[u0];[O0]=!1;[F0]=!1;[A8]=!1;[B8]=!1;[r0]=null;[m]=0;[y]=!1;[n0];[I8]=!1;[w0]=0;[o]=!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(E9(Q))this[i]=!0,this[J0]=null;else if(y9(Q))this[J0]=Q.encoding,this[i]=!1;else this[i]=!1,this[J0]=null;if(this[K0]=!!Q.async,this[u0]=this[J0]?new S9(this[J0]):null,Q&&Q.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[g]});if(Q&&Q.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[s]});let{signal:Z}=Q;if(Z)if(this[n0]=Z,Z.aborted)this[g$]();else Z.addEventListener("abort",()=>this[g$]())}get bufferLength(){return this[m]}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[i]}set objectMode($){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[K0]}set["async"]($){this[K0]=this[K0]||!!$}[g$](){this[I8]=!0,this.emit("abort",this[n0]?.reason),this.destroy(this[n0]?.reason)}get aborted(){return this[I8]}set aborted($){}write($,Q,Z){if(this[I8])return!1;if(this[O0])throw Error("write after end");if(this[y])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]?a0:b9;if(!this[i]&&!Buffer.isBuffer($)){if(v9($))$=Buffer.from($.buffer,$.byteOffset,$.byteLength);else if(k9($))$=Buffer.from($);else if(typeof $!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[i]){if(this[h]&&this[m]!==0)this[R8](!0);if(this[h])this.emit("data",$);else this[x$]($);if(this[m]!==0)this.emit("readable");if(Z)X(Z);return this[h]}if(!$.length){if(this[m]!==0)this.emit("readable");if(Z)X(Z);return this[h]}if(typeof $==="string"&&!(Q===this[J0]&&!this[u0]?.lastNeed))$=Buffer.from($,Q);if(Buffer.isBuffer($)&&this[J0])$=this[u0].write($);if(this[h]&&this[m]!==0)this[R8](!0);if(this[h])this.emit("data",$);else this[x$]($);if(this[m]!==0)this.emit("readable");if(Z)X(Z);return this[h]}read($){if(this[y])return null;if(this[o]=!1,this[m]===0||$===0||$&&$>this[m])return this[A0](),null;if(this[i])$=null;if(this[g].length>1&&!this[i])this[g]=[this[J0]?this[g].join(""):Buffer.concat(this[g],this[m])];let Q=this[v5]($||null,this[g][0]);return this[A0](),Q}[v5]($,Q){if(this[i])this[C8]();else{let Z=Q;if($===Z.length||$===null)this[C8]();else if(typeof Z==="string")this[g][0]=Z.slice($),Q=Z.slice(0,$),this[m]-=$;else this[g][0]=Z.subarray($),Q=Z.subarray(0,$),this[m]-=$}if(this.emit("data",Q),!this[g].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[h]||!this[s0])this[A0]();return this}[f0](){if(this[y])return;if(!this[w0]&&!this[s].length)this[o]=!0;if(this[s0]=!1,this[h]=!0,this.emit("resume"),this[g].length)this[R8]();else if(this[O0])this[A0]();else this.emit("drain")}resume(){return this[f0]()}pause(){this[h]=!1,this[s0]=!0,this[o]=!1}get destroyed(){return this[y]}get flowing(){return this[h]}get paused(){return this[s0]}[x$]($){if(this[i])this[m]+=1;else this[m]+=$.length;this[g].push($)}[C8](){if(this[i])this[m]-=1;else this[m]-=this[g][0].length;return this[g].shift()}[R8]($=!1){do;while(this[E5](this[C8]())&&this[g].length);if(!$&&!this[g].length&&!this[O0])this.emit("drain")}[E5]($){return this.emit("data",$),this[h]}pipe($,Q){if(this[y])return $;this[o]=!1;let Z=this[F0];if(Q=Q||{},$===k5.stdout||$===k5.stderr)Q.end=!1;else Q.end=Q.end!==!1;if(Q.proxyErrors=!!Q.proxyErrors,Z){if(Q.end)$.end()}else if(this[s].push(!Q.proxyErrors?new c$(this,$,Q):new u5(this,$,Q)),this[K0])a0(()=>this[f0]());else this[f0]();return $}unpipe($){let Q=this[s].find((Z)=>Z.dest===$);if(Q){if(this[s].length===1){if(this[h]&&this[w0]===0)this[h]=!1;this[s]=[]}else this[s].splice(this[s].indexOf(Q),1);Q.unpipe()}}addListener($,Q){return this.on($,Q)}on($,Q){let Z=super.on($,Q);if($==="data"){if(this[o]=!1,this[w0]++,!this[s].length&&!this[h])this[f0]()}else if($==="readable"&&this[m]!==0)super.emit("readable");else if(D9($)&&this[F0])super.emit($),this.removeAllListeners($);else if($==="error"&&this[r0]){let X=Q;if(this[K0])a0(()=>X.call(this,this[r0]));else X.call(this,this[r0])}return Z}removeListener($,Q){return this.off($,Q)}off($,Q){let Z=super.off($,Q);if($==="data"){if(this[w0]=this.listeners("data").length,this[w0]===0&&!this[o]&&!this[s].length)this[h]=!1}return Z}removeAllListeners($){let Q=super.removeAllListeners($);if($==="data"||$===void 0){if(this[w0]=0,!this[o]&&!this[s].length)this[h]=!1}return Q}get emittedEnd(){return this[F0]}[A0](){if(!this[A8]&&!this[F0]&&!this[y]&&this[g].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"&&$!==y&&this[y])return!1;else if($==="data")return!this[i]&&!Z?!1:this[K0]?(a0(()=>this[f$](Z)),!0):this[f$](Z);else if($==="end")return this[y5]();else if($==="close"){if(this[B8]=!0,!this[F0]&&!this[y])return!1;let q=super.emit("close");return this.removeAllListeners("close"),q}else if($==="error"){this[r0]=Z,super.emit(u$,Z);let q=!this[n0]||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[s])if(Z.dest.write($)===!1)this.pause();let Q=this[o]?!1:super.emit("data",$);return this[A0](),Q}[y5](){if(this[F0])return!1;return this[F0]=!0,this.readable=!1,this[K0]?(a0(()=>this[h$]()),!0):this[h$]()}[h$](){if(this[u0]){let Q=this[u0].end();if(Q){for(let Z of this[s])Z.dest.write(Q);if(!this[o])super.emit("data",Q)}}for(let Q of this[s])Q.end();let $=super.emit("end");return this.removeAllListeners("end"),$}async collect(){let $=Object.assign([],{dataLength:0});if(!this[i])$.dataLength=0;let Q=this.promise();return this.on("data",(Z)=>{if($.push(Z),!this[i])$.dataLength+=Z.length}),await Q,$}async concat(){if(this[i])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(y,()=>Q(Error("stream destroyed"))),this.on("error",(Z)=>Q(Z)),this.on("end",()=>$())})}[Symbol.asyncIterator](){this[o]=!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(y,V),Q(),Y(K)},J=(K)=>{this.off("error",W),this.off("end",H),this.off(y,V),this.pause(),q({value:K,done:!!this[O0]})},H=()=>{this.off("error",W),this.off("data",J),this.off(y,V),Q(),q({done:!0,value:void 0})},V=()=>W(Error("stream destroyed"));return new Promise((K,G)=>{Y=G,q=K,this.once(y,V),this.once("error",W),this.once("end",H),this.once("data",J)})},throw:Q,return:Q,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[o]=!1;let $=!1,Q=()=>{return this.pause(),this.off(u$,Q),this.off(y,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(y,Q),{next:Z,throw:Q,return:Q,[Symbol.iterator](){return this}}}destroy($){if(this[y]){if($)this.emit("error",$);else this.emit(y);return this}this[y]=!0,this[o]=!0,this[g].length=0,this[m]=0;let Q=this;if(typeof Q.close==="function"&&!this[B8])Q.close();if($)this.emit("error",$);else this.emit(y);return this}static get isStream(){return w9}}var d9=c9.native,t0={lstatSync:f9,readdir:h9,readdirSync:g9,readlinkSync:m9,realpathSync:d9,promises:{lstat:p9,readdir:i9,readlink:r9,realpath:s9}},c5=($)=>!$||$===t0||$===l9?t0:{...t0,...$,promises:{...t0.promises,...$.promises||{}}},l5=/^\\\\\?\\([a-z]:)\\?$/i,n9=($)=>$.replace(/\//g,"\\").replace(l5,"$1\\"),a9=/[\\\/]/,Q0=0,d5=1,p5=2,_0=4,i5=6,r5=8,N0=10,s5=12,$0=15,o0=~$0,l$=16,f5=32,e0=64,W0=128,F8=256,j8=512,h5=e0|W0|j8,o9=1023,d$=($)=>$.isFile()?r5:$.isDirectory()?_0:$.isSymbolicLink()?N0:$.isCharacterDevice()?p5:$.isBlockDevice()?i5:$.isSocket()?s5:$.isFIFO()?d5:Q0,g5=new Map,$8=($)=>{let Q=g5.get($);if(Q)return Q;let Z=$.normalize("NFKD");return g5.set($,Z),Z},m5=new Map,L8=($)=>{let Q=m5.get($);if(Q)return Q;let Z=$8($.toLowerCase());return m5.set($,Z),Z};class i$ extends i0{constructor(){super({max:256})}}class n5 extends i0{constructor($=16384){super({maxSize:$,sizeCalculation:(Q)=>Q.length+1})}}var a5=Symbol("PathScurry setAsCwd");class n{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}#I;get gid(){return this.#I}#C;get rdev(){return this.#C}#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;#F;#K;#T;#B;#b;#J;#v;#S;#D;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor($,Q=Q0,Z,X,q,Y,W){if(this.name=$,this.#W=q?L8($):$8($),this.#J=Q&o9,this.nocase=q,this.roots=X,this.root=Z||this,this.#v=Y,this.#K=W.fullpath,this.#B=W.relative,this.#b=W.relativePosix,this.parent=W.parent,this.parent)this.#Q=this.parent.#Q;else this.#Q=c5(W.fs)}depth(){if(this.#F!==void 0)return this.#F;if(!this.parent)return this.#F=0;return this.#F=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).#w(X):this.#w(X)}#w($){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($,Q0,{...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.#b!==void 0)return this.#b;let $=this.name,Q=this.parent;if(!Q)return this.#b=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&$0)===Q0}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&$0)===r5}isDirectory(){return(this.#J&$0)===_0}isCharacterDevice(){return(this.#J&$0)===p5}isBlockDevice(){return(this.#J&$0)===i5}isFIFO(){return(this.#J&$0)===d5}isSocket(){return(this.#J&$0)===s5}isSymbolicLink(){return(this.#J&N0)===N0}lstatCached(){return this.#J&f5?this:void 0}readlinkCached(){return this.#S}realpathCached(){return this.#D}readdirCached(){let $=this.children();return $.slice(0,$.provisional)}canReadlink(){if(this.#S)return!0;if(!this.parent)return!1;let $=this.#J&$0;return!($!==Q0&&$!==N0||this.#J&F8||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.#S;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.#S=Z}catch(Q){this.#u(Q.code);return}}readlinkSync(){let $=this.#S;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.#S=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(($&$0)===_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|=F8,$==="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&$0;if(q!==_0&&q!==N0&&q!==Q0)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:A,uid:B}=$;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.#I=K,this.#G=G,this.#Z=_,this.#j=O,this.#O=U,this.#X=M,this.#C=z,this.#H=A,this.#Y=B;let R=d$($);if(this.#J=this.#J&o0|R|f5,R!==Q0&&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&h5)return!1;let $=$0&this.#J;if(!($===Q0||$===_0||$===N0))return!1;return!0}shouldWalk($,Q){return(this.#J&_0)===_0&&!(this.#J&h5)&&!$.has(this)&&(!Q||Q(this))}async realpath(){if(this.#D)return this.#D;if((j8|F8|W0)&this.#J)return;try{let $=await this.#Q.promises.realpath(this.fullpath());return this.#D=this.resolve($)}catch($){this.#m()}}realpathSync(){if(this.#D)return this.#D;if((j8|F8|W0)&this.#J)return;try{let $=this.#Q.realpathSync(this.fullpath());return this.#D=this.resolve($)}catch($){this.#m()}}[a5]($){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.#b=Z.join("/"),X=X.parent,Z.push("..");X=$;while(X&&X.parent&&!Q.has(X))X.#B=void 0,X.#b=void 0,X=X.parent}}class T8 extends n{sep="\\";splitSep=a9;constructor($,Q=Q0,Z,X,q,Y,W){super($,Q,Z,X,q,Y,W)}newChild($,Q=Q0,Z={}){return new T8($,Q,this.root,this.roots,this.nocase,this.childrenCache(),Z)}getRootString($){return p$.parse($).root}getRoot($){if($=n9($.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(l5,"$1\\"),$===Q}}class S8 extends n{splitSep="/";sep="/";constructor($,Q=Q0,Z,X,q,Y,W){super($,Q,Z,X,q,Y,W)}getRootString($){return $.startsWith("/")?"/":""}getRoot($){return this.root}newChild($,Q=Q0,Z={}){return new S8($,Q,this.root,this.roots,this.nocase,this.childrenCache(),Z)}}class r${root;rootPath;roots;cwd;#Q;#$;#Z;nocase;#X;constructor($=process.cwd(),Q,Z,{nocase:X,childrenCacheSize:q=16384,fs:Y=t0}={}){if(this.#X=c5(Y),$ instanceof URL||$.startsWith("file://"))$=u9($);let W=Q.resolve($);this.roots=Object.create(null),this.rootPath=this.parseRootPath(W),this.#Q=new i$,this.#$=new i$,this.#Z=new n5(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 n))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 n))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 n))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 n))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 n))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 n))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 n))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((A)=>A?.isUnknown()?A.lstat():A).then((A)=>A?.shouldWalk(J,Y)?H(A,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 n))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 n))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 n))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 n))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,A=!1)=>{if(M)return W.emit("error",M);if(X&&!A){let B=[];for(let R of z)if(R.isSymbolicLink())B.push(R.realpath().then((L)=>L?.isUnknown()?L.lstat():L));if(B.length){Promise.all(B).then(()=>O(null,z,!0));return}}for(let B of z)if(B&&(!q||q(B))){if(!W.write(Z?B:B.fullpath()))G=!0}V--;for(let B of z){let R=B.realpathCached()||B;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 n))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[a5](Q)}}class Q8 extends r${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 r${sep="/";constructor($=process.cwd(),Q={}){let{nocase:Z=!1}=Q;super($,x9,"/",{...Q,nocase:Z});this.nocase=Z}parseRootPath($){return"/"}newRoot($){return new S8(this.rootPath,_0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")}}class w8 extends Z8{constructor($=process.cwd(),Q={}){let{nocase:Z=!0}=Q;super($,{...Q,nocase:Z})}}var VX=process.platform==="win32"?T8:S8,o5=process.platform==="win32"?Q8:process.platform==="darwin"?w8:Z8;var t9=($)=>$.length>=1,e9=($)=>$.length>=1;class h0{#Q;#$;#Z;length;#X;#Y;#I;#C;#V;#G;#H=!0;constructor($,Q,Z,X){if(!t9($))throw TypeError("empty pattern list");if(!e9(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]===l}isRegExp(){return this.#Q[this.#Z]instanceof RegExp}globString(){return this.#I=this.#I||(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.#C=this.#C,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.#C!==void 0?this.#C:this.#C=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 $Q=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=$Q}){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 e($,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 e(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 s${store;constructor($=new Map){this.store=$}copy(){return new s$(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 t5{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 e5{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 t5;subwalks=new e5;patterns;follow;dot;opts;constructor($,Q){this.opts=$,this.follow=!!$.follow,this.dot=!!$.dot,this.hasWalkedCache=Q?Q.copy():new s$}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===l){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===l)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 QQ=($,Q)=>typeof $==="string"?new X8([$],Q):Array.isArray($)?new X8($,Q):$;class n${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.#$=QQ(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 n${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 n${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 XQ=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=ZQ(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||XQ,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"?w8:Q.platform?Z8:o5;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 e(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 a$=($,Q={})=>{if(!Array.isArray($))$=[$];for(let Z of $)if(new e(Z,Q).hasMagic())return!0;return!1};function b8($,Q={}){return new G0($,Q).streamSync()}function Z1($,Q={}){return new G0($,Q).stream()}function D8($,Q={}){return new G0($,Q).walkSync()}async function $1($,Q={}){return new G0($,Q).walk()}function k8($,Q={}){return new G0($,Q).iterateSync()}function X1($,Q={}){return new G0($,Q).iterate()}var qQ=b8,YQ=Object.assign(Z1,{sync:b8}),JQ=k8,WQ=Object.assign(X1,{sync:k8}),HQ=Object.assign(D8,{stream:b8,iterate:k8}),Q1=Object.assign($1,{glob:$1,globSync:D8,sync:HQ,globStream:Z1,stream:YQ,globStreamSync:b8,streamSync:qQ,globIterate:X1,iterate:WQ,globIterateSync:k8,iterateSync:JQ,Glob:G0,hasMagic:a$,escape:E0,unescape:Y0});Q1.glob=Q1;import VQ from"node:path";var q1=({dir:$,pattern:Q="*",nodir:Z=!1,dot:X=!0,ignore:q=[],absolute:Y=!1,matchBase:W=!1,follow:J=!1})=>{if($=$||process.cwd(),$=VQ.resolve($),Q&&!Array.isArray(Q))Q=[Q];else Q=Q||["*"];if(q&&!Array.isArray(q))q=[q];else q=q||[];return D8(Q,{cwd:$,nodir:Z,dot:X,ignore:q,absolute:Y,matchBase:W,follow:J})};import W1 from"@fnet/expression";import Y1 from"lodash.clonedeep";import KQ from"@fnet/key-value-transformer";import _Q 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 KQ({data:$.definition,callback:(Y,W,J)=>{let H=_Q({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 N({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 GQ({node:$}){if(!$.definition.hasOwnProperty("switch"))return!1;return!0}async function zQ({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=J1}async function J1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||Y1($.definition);let q=$.context.transform;for(let Y of $.childs)if(Y.context.transform=Y.context.transform||Y1(Y.definition),Y.definition.hasOwnProperty("condition"))Y.context.transform.condition=await X(Y.definition.condition);await N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var Y8={hits:GQ,init:zQ,resolve:J1};async function UQ({node:$}){if(Object.keys($.definition).map((q)=>W1({expression:q})).filter((q)=>q?.processor==="if").length===1)return!0;if($.definition.if&&typeof $.definition.if==="object")return!0;return!1}async function MQ($){let{node:Q}=$,X=Object.keys(Q.definition).map((H)=>W1({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:UQ,init:MQ};import H1 from"lodash.clonedeep";async function OQ({node:$}){return $.definition.hasOwnProperty("try")&&$.definition.hasOwnProperty("except")}async function AQ({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=V1}async function V1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||H1($.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||H1(Y.definition),!Y.context.transform.hasOwnProperty("as"))Y.context.transform.as="error"}await N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var t$={hits:OQ,init:AQ,resolve:V1};import BQ from"lodash.clonedeep";async function RQ({node:$}){return $.definition.hasOwnProperty("assign")}async function CQ({node:$,initNode:Q}){$.type="assign",await u({node:$,initNode:Q}),$.resolve=K1}async function K1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||BQ($.definition);let q=$.context.transform;await N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var e$={hits:RQ,init:CQ,resolve:K1};import IQ from"lodash.clonedeep";async function FQ({node:$}){return $.definition.hasOwnProperty("for")}async function LQ({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=_1}async function _1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||IQ($.definition);let q=$.context.transform;q.for.in=await X($.definition.for.in),await N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var $6={hits:FQ,init:LQ,resolve:_1};import jQ from"lodash.clonedeep";async function TQ({node:$}){return $.definition.hasOwnProperty("parallel")}async function SQ({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=G1}async function G1({node:$,transformExpression:Q,resolveNextBlock:Z}){$.context.transform=$.context.transform||jQ($.definition),await N({node:$,transformExpression:Q}),Z({node:$})}var Q6={hits:TQ,init:SQ,resolve:G1};import wQ from"lodash.clonedeep";async function PQ({node:$}){return $.definition.hasOwnProperty("raise")}async function NQ({node:$,initNode:Q}){$.type="raise",$.resolve=z1}async function z1({node:$,resolveTypeCommon:Q,transformExpression:Z}){$.context.transform=$.context.transform||wQ($.definition);let X=$.context.transform;X.raise=await Z(X.raise),await Q({node:$})}var Z6={hits:PQ,init:NQ,resolve:z1};import bQ from"lodash.clonedeep";async function DQ({node:$}){return $.definition.hasOwnProperty("return")}async function kQ({node:$,initNode:Q}){$.type="return",$.resolve=U1}async function U1({node:$,resolveTypeCommon:Q,transformExpression:Z}){$.context.transform=$.context.transform||bQ($.definition);let X=$.context.transform;$.hasReturn=!0,X.return=await Z(X.return),await Q({node:$})}var X6={hits:DQ,init:kQ,resolve:U1};import vQ from"lodash.clonedeep";async function EQ({node:$}){return $.definition.hasOwnProperty("call")}async function yQ({node:$,initNode:Q}){$.type="call",await u({node:$,initNode:Q}),$.resolve=M1}async function M1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||vQ($.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 N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var J8={hits:EQ,init:yQ,resolve:M1};import xQ from"lodash.clonedeep";async function uQ({node:$}){return $.definition.hasOwnProperty("steps")}async function fQ({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=O1}async function O1({node:$,transformExpression:Q}){$.context.next=$.childs[0],$.context.transform=$.context.transform||xQ($.definition),await N({node:$,transformExpression:Q})}var q6={hits:uQ,init:fQ,resolve:O1};import hQ from"lodash.clonedeep";async function gQ({node:$}){return $.definition.hasOwnProperty("form")}async function mQ({node:$,initNode:Q}){$.type="form",await u({node:$,initNode:Q}),$.resolve=A1}async function A1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||hQ($.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 N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var Y6={hits:gQ,init:mQ,resolve:A1};import cQ from"lodash.clonedeep";async function lQ({node:$}){return $.definition.hasOwnProperty("signal")}async function dQ({node:$,initNode:Q}){$.type="signal",$.resolve=B1}async function B1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X,transformValue:q}){$.context.transform=$.context.transform||cQ($.definition),await Q({node:$}),Z({node:$})}var J6={hits:lQ,init:dQ,resolve:B1};import pQ from"lodash.clonedeep";async function iQ({node:$}){return $.definition.hasOwnProperty("wait")}async function rQ({node:$,initNode:Q}){$.type="wait",$.resolve=R1}async function R1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X,transformValue:q}){$.context.transform=$.context.transform||pQ($.definition),await Q({node:$}),Z({node:$})}var W6={hits:iQ,init:rQ,resolve:R1};import sQ from"lodash.clonedeep";async function nQ({node:$}){return $.definition.hasOwnProperty("next")}async function aQ({node:$,initNode:Q}){$.type="next",$.resolve=C1}async function C1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||sQ($.definition);let q=$.context.transform;q.next=await X(q.next),await N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var H6={hits:nQ,init:aQ,resolve:C1};import oQ from"lodash.clonedeep";async function tQ({node:$}){return $.definition.hasOwnProperty("modules")}async function eQ({node:$,initNode:Q}){$.type="modules",await u({node:$,initNode:Q}),$.resolve=I1}async function I1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||oQ($.definition);let q=$.context.transform;await N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var V6={hits:tQ,init:eQ,resolve:I1};function K6({node:$}){let Q=$.definition;if($.hasReturn){if(I("tree"))D.info(" └─ RETURN (no next)",{depth:$.depth+1,node:$.indexKey});return}if(Q.next==="end"){if(I("tree"))D.info(" └─ EXPLICIT END",{depth:$.depth+1,node:$.indexKey})}else if(Q.next==="stop"){if(I("tree"))D.info(" └─ EXPLICIT STOP",{depth:$.depth+1,node:$.indexKey})}else if(Q.next==="none"){if(I("tree"))D.info(" └─ EXPLICIT NONE",{depth:$.depth+1,node:$.indexKey})}else if(Q.next){if(I("tree"))D.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,I("tree"))D.info(` └─ ✅ FOUND: ${X.indexKey}`,{depth:$.depth+1,nextNode:X.indexKey});break}Z=Z.parent}if(!$.context.next&&I("tree"))D.warn(` └─ ⚠️ NOT FOUND: "${Q.next}"`,{depth:$.depth+1})}else{if($.module===!0){if(I("tree"))D.info(" └─ MODULE ROOT (no auto next)",{depth:$.depth+1,node:$.indexKey});return}if(I("tree"))D.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(I("tree"))D.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,I("tree"))D.info(` ${q}. ✅ SIBLING FOUND: ${Y.indexKey}`,{depth:$.depth+2,nextNode:Y.indexKey});break}else{if(I("tree"))D.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,I("tree"))D.info(` ${q}. ✅ SIBLING FOUND (parent jump disabled): ${Y.indexKey}`,{depth:$.depth+2,nextNode:Y.indexKey})}else if(I("tree"))D.info(` ${q}. ⛔ No sibling, parent jump disabled`,{depth:$.depth+2});break}else if(!Z.blockAutoJumpToParent){if(I("tree"))D.info(` ${q}. ⬆️ Sibling disabled, climbing to parent: ${Z.parent?.indexKey}`,{depth:$.depth+2});X=Z.index+1,Z=Z.parent;continue}if($.context.next&&I("tree"))D.info(` └─ \uD83C\uDFAF AUTO NEXT RESOLVED: ${$.context.next.indexKey}`,{depth:$.depth+1,steps:q,nextNode:$.context.next.indexKey});else if(I("tree"))D.info(" └─ ⚠️ NO NEXT FOUND (end of flow)",{depth:$.depth+1,steps:q})}}class F1{#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 d($){return new F1($)}import $2 from"lodash.clonedeep";async function Q2({node:$}){return $.definition.hasOwnProperty("new")}async function Z2({node:$,initNode:Q}){$.type="new",await u({node:$,initNode:Q}),$.resolve=L1}async function L1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||$2($.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 N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var _6={hits:Q2,init:Z2,resolve:L1};import X2 from"lodash.clonedeep";async function q2({node:$}){return $.definition.hasOwnProperty("output")}async function Y2({node:$,initNode:Q}){$.type="output",await u({node:$,initNode:Q}),$.resolve=j1}async function j1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||X2($.definition),await N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var G6={hits:q2,init:Y2,resolve:j1};import J2 from"lodash.clonedeep";async function W2({node:$}){return $.definition.hasOwnProperty("pipeline")}async function H2({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=T1}async function T1({node:$,transformExpression:Q,resolveNextBlock:Z}){$.context.transform=$.context.transform||J2($.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 N({node:$,transformExpression:Q}),Z({node:$})}var z6={hits:W2,init:H2,resolve:T1};var S1=({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 k1{#Q;#$;#Z;#X;#Y;#I;#C;#V;#G;#H;#_;#q;#O;#M;#U;#A;#j;#R;#L;#W;#F;#K=[];constructor($){this.#Q=new b6,this.#$=$,this.#I=[],this.#C=[],this.#V={},this._expire_ttl=3600,this._expire_ttl_short=300,this.#K.push(d({key:"config",npm:"@fnet/config",master:"name"})),this.#K.push(d({key:"yaml",npm:"@fnet/yaml",master:"file"})),this.#K.push(d({key:"prompt",npm:"@fnet/prompt",master:"message"})),this.#K.push(d({key:"html-link",npm:"@flownet/lib-load-browser-link-url",master:"src"})),this.#K.push(d({key:"html-script",npm:"@flownet/lib-load-browser-script-url",master:"src"})),this.#K.push(d({key:"http-server",npm:"@fnet/node-express",master:"server_port"})),this.#K.push(d({key:"shell",npm:"@fnet/shell-flow",master:"commands"})),this.#K.push(d({key:"list-files",npm:"@fnet/list-files",master:"pattern"})),this.#K.push(d({key:"up-list-files",npm:"@fnet/up-list-files",master:"pattern"})),this.#K.push(d({key:"auto-conda-env",npm:"@fnet/auto-conda-env",master:"envDir"})),this.#K.push(d({key:"ollama-chat",npm:"@fnet/ollama-chat",master:"model"})),this.#K.push(d({key:"ai",npm:"@fnet/ai",master:"prompt",extras:{subtype:"flow"}})),this.#K.push(d({key:"invoke",npm:"@fnet/invoke",master:"method",extras:{}})),this.#K.push(d({key:"fetch",npm:"@fnet/fetch",master:"url",extras:{}})),this.#K.push(d({key:"filemap",npm:"@fnet/filemap",master:"target",extras:{}})),this.#W={packageDependencies:this.#I,packageDevDependencies:this.#C,setProgress:this.setProgress.bind(this),context:this.#$,Atom:z0,registerToPackageManager:this.registerToPackageManager.bind(this)},this.#F={initNode:this.initNode.bind(this),cloneDeep:N1,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||b1(),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 _2({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.#I}),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 z2({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=q1({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(I("tree"))D.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(I("tree"))D.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(I("tree"))D.info(`\uD83D\uDD27 Initializing node: ${X.name}`,{depth:X.depth});await this.initNode({node:X})}if(I("tree"))D.info("✅ Root node tree created",{depth:0,totalFlows:Z.childs.length});return Z}async initNode({node:$}){let Q={...this.#F,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 Q6.hits(Q))Z="parallel",await Q6.init(Q);else if(await z6.hits(Q))Z="pipeline",await z6.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(I("tree"))D.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=b1();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=K2({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 G2({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=S1({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||N1($.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.#F,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":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(V2($)){let Q=Object.keys($);for(let Z=0;Z<Q.length;Z++){let X=Q[Z],q=D1({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=D1({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,w1.stringify(X),"utf8")}async createProjectMainYaml(){await this.setProgress({message:"Creating flow.main.yaml"});let Z={content:w1.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 P1("prettier --write .",{cwd:S.resolve($,"src")});if(Q.code!==0)throw Error(Q.stderr)}else{let Q=await P1("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 o6({...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(U2.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 F$(this.#W),await I$(this.#W),await C$(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 S$(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=k1;var M2={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 w($),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)}}},v1=M2;var O2={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 w($),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)}}},E1=O2;var A2={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 w({...$,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)}}},y1=A2;var B2={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 w({...$,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)}}},x1=B2;import u1 from"node:path";import v8 from"node:fs";import R2 from"@fnet/prompt";var C2={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 w($),{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 R2({type:"input",name:"inputName",message:"Input name:",initial:"dev"});$.name=G}let W=u1.resolve(X,".fnet");if(!v8.existsSync(W))v8.mkdirSync(W);let J=u1.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)}}},f1=C2;import T from"node:path";import F from"node:fs";import y8 from"node:os";import{spawn as x8}from"node:child_process";import C from"chalk";import B0 from"@fnet/prompt";import E8 from"chalk";import h1 from"@fnet/prompt";async function I2($){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 h1({type:"select",name:V,message:Z,choices:J,initial:H});if(K==="cancel")return null;return K}async function F2($){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 h1({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 U6={promptForSelection:I2,promptForMultipleSelection:F2};var x=T.join(y8.homedir(),".fnet","express");async function m1($){$.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 L2(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 j2(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 T2(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 S2(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 P2(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 N2(Q)}).demandCommand(1,"You need to specify a command").help()}async function L2($){try{if(!F.existsSync(x))F.mkdirSync(x,{recursive:!0});let Q=new Date().toISOString().slice(0,10).replace(/-/g,""),Z=T.join(x,Q);if(!F.existsSync(Z))F.mkdirSync(Z,{recursive:!0});let X=$.projectName,q,Y=$.runtime;if(!$.yes){if(!X){let _=F.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=F.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),F.existsSync(q)){let K=1;while(F.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(C.yellow("Project creation cancelled."));return}}console.log(C.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(!F.existsSync(W))F.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(C.green(`
|
|
2
|
+
import{a as U0,b as V0}from"./index.2084z2ed.js";import{c as v,d as q5,e as E}from"./index.r19p3bpa.js";var H5=q5((h3,W5)=>{W5.exports=Y5;function Y5($,Q,Z){if($ instanceof RegExp)$=X5($,Z);if(Q instanceof RegExp)Q=X5(Q,Z);var X=J5($,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 X5($,Q){var Z=Q.match($);return Z?Z[0]:null}Y5.range=J5;function J5($,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 O5=q5((g3,M5)=>{var V5=H5();M5.exports=g7;var K5="\x00SLASH"+Math.random()+"\x00",_5="\x00OPEN"+Math.random()+"\x00",v$="\x00CLOSE"+Math.random()+"\x00",G5="\x00COMMA"+Math.random()+"\x00",z5="\x00PERIOD"+Math.random()+"\x00";function k$($){return parseInt($,10)==$?parseInt($,10):$.charCodeAt(0)}function f7($){return $.split("\\\\").join(K5).split("\\{").join(_5).split("\\}").join(v$).split("\\,").join(G5).split("\\.").join(z5)}function h7($){return $.split(K5).join("\\").split(_5).join("{").split(v$).join("}").split(G5).join(",").split(z5).join(".")}function U5($){if(!$)return[""];var Q=[],Z=V5("{","}",$);if(!Z)return $.split(",");var{pre:X,body:q,post:Y}=Z,W=X.split(",");W[W.length-1]+="{"+q+"}";var J=U5(Y);if(Y.length)W[W.length-1]+=J.shift(),W.push.apply(W,J);return Q.push.apply(Q,W),Q}function g7($){if(!$)return[];if($.substr(0,2)==="{}")$="\\{\\}"+$.substr(2);return c0(f7($),!0).map(h7)}function m7($){return"{"+$+"}"}function c7($){return/^-?0\d/.test($)}function l7($,Q){return $<=Q}function d7($,Q){return $>=Q}function c0($,Q){var Z=[],X=V5("{","}",$);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(_=U5(X.body),_.length===1){if(_=c0(_[0],!1).map(m7),_.length===1)return Y.map(function(n1){return X.pre+_[0]+n1})}var A;if(K){var U=k$(_[0]),O=k$(_[1]),z=Math.max(_[0].length,_[1].length),M=_.length==3?Math.abs(k$(_[2])):1,B=l7,R=O<U;if(R)M*=-1,B=d7;var F=_.some(c7);A=[];for(var u=U;B(u,O);u+=M){var N;if(V){if(N=String.fromCharCode(u),N==="\\")N=""}else if(N=String(u),F){var Z0=z-N.length;if(Z0>0){var b0=Array(Z0+1).join("0");if(u<0)N="-"+b0+N.slice(1);else N=b0+N}}A.push(N)}}else{A=[];for(var X0=0;X0<_.length;X0++)A.push.apply(A,c0(_[X0],!1))}for(var X0=0;X0<A.length;X0++)for(var W=0;W<Y.length;W++){var J=q+A[X0]+Y[W];if(!Q||K||J)Z.push(J)}}return Z}});import m2 from"yargs";import s1 from"chalk";import{promisify as a1}from"node:util";import o1 from"tree-kill";var A6=a1(o1),j0=!1;async function m8($,Q){if(j0)return;if(j0=!0,!$.killed&&$.pid)try{if(await A6($.pid,"SIGTERM").catch(()=>{}),await new Promise((X)=>setTimeout(X,500)),!$.killed)await A6($.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 B6(){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 R6}from"node:child_process";import H8 from"node:fs";import g0 from"chalk";import t1 from"@fnet/config";function p($,{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 A=R6(Z,[...X,...V],{cwd:J,stdio:"inherit",shell:!0,detached:!0,env:K});c8(A)}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 t1({name:J,dir:W,transferEnv:!1,optional:!0,tags:Y.tags}))?.data?.env||void 0,K=q.command,G=process.argv.slice(5),_=R6(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 I6($,{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 F6($,{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((O,z)=>{_.on("close",(M)=>{if(M===0)O();else z(Error(`Compilation failed with code ${M}`))}),_.on("error",(M)=>{z(M)})}),process.platform!=="win32")H8.chmodSync(K,493);console.log(g0.green(`Binary compiled successfully: ${K}`)),console.log(g0.blue("Installing binary..."));let A=["install",K];if(X.name)A.push("--name",X.name);if(X.force)A.push("--force");if(X.yes)A.push("--yes");let U=G("fbin",A,{stdio:"inherit",shell:!0});await new Promise((O,z)=>{U.on("close",(M)=>{if(M===0)O();else z(Error(`Installation failed with code ${M}`))}),U.on("error",(M)=>{z(M)})})}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 e1 from"yaml";async function w($){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 $7({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 $7({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,A=H0.resolve(q,_);if(!T0.existsSync(A))W={main:{steps:[]}};else{let{parsed:U}=await l8({file:A,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:$}),A=e1.parseDocument(G);H.devops={filePath:V,fileContent:G,yamlDocument:A,doc:{..._},type:"workflow.deploy",save:async()=>{T0.writeFileSync(H.devops.filePath,A.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 Z7 from"node:path";import L6 from"node:fs";import X7 from"node:os";import q7 from"@flownet/lib-render-templates-dir";import d8 from"@fnet/shelljs";var Y7={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=Z7.resolve(Q,$.name);if(!L6.existsSync(X))L6.mkdirSync(X);await q7({dir:Z,outDir:X,context:$,copyUnmatchedAlso:!0,platform:X7.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)}}},j6=Y7;import J7 from"node:os";import W7 from"@flownet/lib-render-templates-dir";import H7 from"@fnet/shelljs";var V7={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 w($);if($.update){if(await W7({dir:Q,outDir:Z,context:{name:X.project.projectFileParsed.name,runtime:"node"},copyUnmatchedAlso:!0,platform:J7.platform()}),(await H7("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)}}},T6=V7;import j from"node:fs";import S from"node:path";import N1 from"yaml";import b1 from"@fnet/shelljs";import W8 from"nunjucks";import D1 from"lodash.clonedeep";import U2 from"isobject";import{randomUUID as k1}from"node:crypto";import p8 from"winston";var{combine:S6,timestamp:w6,printf:K7,colorize:_7}=p8.format,P6=K7(({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:S6(w6({format:"HH:mm:ss.SSS"}),P6),transports:[new p8.transports.Console({format:S6(_7(),w6({format:"HH:mm:ss.SSS"}),P6)})]}),b6=($)=>{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})}},D=b6("tree"),k=b6("bpmn"),N6=process.env.FNET_LOG_CATEGORIES?.split(",")||[],I=($)=>{if(N6.length===0)return!1;return N6.includes($)};import{Api as K8}from"@flownet/lib-atom-api-js";class D6{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 D0 from"lodash.merge";import _8 from"node:fs";import q0 from"node:path";import k0 from"@flownet/lib-parse-imports-js";import G7 from"lodash.merge";function b({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=G7(G,_);let A=!Q[X]||Q[X]?.enabled===!1;K.forEach((O)=>{let z=Q.rollup_output[O];if(!z)return;if(Reflect.has(z,X)){if(A||!z[X]||z[X]?.enabled===!1){delete z[X];return}if(z[X]===!0)z[X]={enabled:!0,options:G}}else if(!A&&!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((O)=>Q.rollup_output[O][X]?.enabled===!0);if(W)U=W()&&U;if(Q[H]=U,U)q.forEach((O)=>Z.push({package:O[0],version:O[1]}))}function i8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;b({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 r8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;b({feature:{name:"gzip",packages:[["rollup-plugin-gzip","^4"]],explicit:!0},features:X,packageDevDependencies:Z})}function s8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;b({feature:{name:"nunjucks",packages:[["@fnet/rollup-plugin-nunjucks","0.1.8"]]},features:X,packageDevDependencies:Z})}function n8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;b({feature:{name:"polyfill",packages:[["rollup-plugin-node-polyfills","^0.2"]]},features:X,packageDevDependencies:Z})}function a8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;b({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;b({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;b({feature:{name:"string",packages:[["rollup-plugin-string","^3"]]},features:X,packageDevDependencies:Z})}function e8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;b({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;b({feature:{name:"json",packages:[["@rollup/plugin-json","^6"]]},features:X,packageDevDependencies:Z})}function Q$($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;b({feature:{name:"terser",packages:[["@rollup/plugin-terser","^0.4"]]},features:X,packageDevDependencies:Z})}function Z$($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;b({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}}b({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}});b({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 O=await k0({file:W.file,recursive:!0}),z=O.all.some((M)=>M.usesJSX===!0&&M.type==="local");q.app_uses_jsx=z,q.app_has_entry=!0,O=await k0({file:W.file}),z=O.all.some((M)=>M.usesJSX===!0&&M.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 O=await k0({file:J.file,recursive:!0}),z=O.all.some((M)=>M.usesJSX===!0&&M.type==="local");q.cli_uses_jsx=z,q.cli_has_entry=!0,O=await k0({file:J.file}),z=O.all.some((M)=>M.usesJSX===!0&&M.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 O=Y$({dir:q0.resolve(Y,"./src")});if(O.file){X("Parsing src entry imports...");let z=await k0({file:O.file,recursive:!0}),M=z.all.some((B)=>B.usesJSX===!0&&B.type==="local");q.src_uses_jsx=M,q.src_has_entry=!0,z=await k0({file:O.file}),M=z.all.some((B)=>B.usesJSX===!0&&B.type==="local"),q.src_entry_uses_jsx=M,q.src_entry_is_ts=O.ts,q.src_entry_ext=O.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 A={server:".",startPath:`${q0.normalize(q.app.dir||".")}`,files:[q0.normalize("./dist/**/*")],cors:!0,open:!1};if(q.babel_options=D0(G,q.babel_options||q.babel?.options),q.browsersync_options=D0(A,q.browsersync_options||q.browsersync?.options||{}),q.replace_options=D0(_,q.replace_options||q.replace?.options||{}),Reflect.has(q.browsersync_options,"proxy"))delete q.browsersync_options.server;q.rollup=q.rollup||{},q.rollup_output=D0(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 O of U){let z=K[O];if(!z)continue;if(q.rollup[O]===!1){delete q.rollup_output[O];continue}if(z.babel_options=z.babel_options||q.babel_options,z.browsersync_options=D0(q.browsersync_options,z.browsersync_options),z.replace_options=D0(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((O)=>q.rollup_output[O].babel===!0),q.browser_enabled=U.some((O)=>q.rollup_output[O].babel===!0),q.browsersync_enabled=q.browsersync!==!1&&U.some((O)=>q.rollup_output[O].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($),a8($),n8($),s8($),i8($),r8($)}import z7 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 z7({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 U7 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 U7({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 k6 from"node:fs";import v6 from"node:path";import M7 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=v6.resolve(Z.projectDir,"src/app");if(!k6.existsSync(W))k6.mkdirSync(W,{recursive:!0});let J=["index.js.njk"];if($.doc.features.app.html!==!1)J.push("index.html.njk");await M7({pattern:J,dir:v6.resolve(Y,"src/app"),outDir:W,context:q})}import y6 from"nunjucks";import M0 from"node:fs";import R0 from"node:path";import B7 from"@flownet/lib-parse-imports-js";import O7 from"@fnet/npm-pick-versions";import A7 from"object-hash";import G8 from"node:fs";import E6 from"node:path";async function v0({projectDir:$,name:Q,setProgress:Z,count:X=1}){let q,W=A7(["npm-pick-versions",Q,X]),J=E6.join($,".cache"),H=E6.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 O7({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((B)=>B.package===z.package))X.push(z);let M=Z.findIndex((B)=>B.package===z.package);Z.splice(M,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 M=z.file;if(!M0.existsSync(M))throw Error(`App file not found: ${M}`);let R=(await B7({file:M,recursive:!0,verbose:!1})).all;for await(let F of R){if(F.type!=="npm")continue;if(Z.find((Z0)=>Z0.package===F.package))continue;if(X.find((Z0)=>Z0.package===F.package))continue;let u=await v0({name:F.package,projectDir:Q.projectDir,setProgress:q});(z.dev===!0?X:Z).push({package:F.package,subpath:F.subpath,version:u.minorRange,type:"npm"})}}let V={atom:$,packageDependencies:Z,packageDevDependencies:X},K=Q.templateDir,_=y6.compile(M0.readFileSync(R0.resolve(K,"package.json.njk"),"utf8"),y6.configure(K)).render(V),A=Q.projectDir,U=R0.resolve(A,"package.json");M0.writeFileSync(U,_,"utf8");let O=R0.resolve(Q.project.projectDir,"fnet");if(M0.existsSync(O)){let z=R0.resolve(Q.projectDir,"fnet");if(!M0.existsSync(z))M0.mkdirSync(z);let M=M0.readdirSync(O);for(let B of M){let R=R0.resolve(O,B);if(!M0.lstatSync(R).isFile())continue;let F=R0.resolve(z,B);M0.copyFileSync(R,F)}}}import x6 from"node:fs";import u6 from"node:path";import R7 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=u6.resolve(Z.projectDir,"src/cli");if(!x6.existsSync(W))x6.mkdirSync(W,{recursive:!0});await R7({pattern:["index.js.njk"],dir:u6.resolve(Y,"src/cli"),outDir:W,context:q})}import G$ from"node:fs";import z$ from"node:path";import f6 from"nunjucks";import C7 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 C7({file:Y,recursive:!0})).all.filter((O)=>O.type==="node").map((O)=>O.path),H=$.doc.features.rollup_output,V=Object.keys(H);for(let O=0;O<V.length;O++){let z=V[O],M=H[z];if(M.browser===!0){if(J.length>0){M.globals_enabled=!0,M.globals=M.globals||[],M.globals=M.globals.concat(J.map((B)=>{return{key:B,value:B}})),M.alias_enabled=!0,M.alias=M.alias||{},M.alias.entries=M.alias.entries||{};for(let B=0;B<J.length;B++){let R=J[B];M.alias.entries[R]=`node:${R}`,M.alias.entries[`node:${R}`]=R}M.external_enabled=!0,M.external=M.external||[],M.external=M.external.concat(J)}}}let K=Z.templateDir,_=f6.compile(G$.readFileSync(z$.resolve(K,"rollup.config.mjs.njk"),"utf8"),f6.configure(K)).render(q),A=Z.projectDir,U=z$.resolve(A,"rollup.config.mjs");G$.writeFileSync(U,_,"utf8")}import M$ from"node:fs";import h6 from"node:path";import g6 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=g6.compile(M$.readFileSync(h6.resolve(Y,"build.js.njk"),"utf8"),g6.configure(Y)).render(q),H=Z.projectDir,V=h6.resolve(H,"build.js");M$.writeFileSync(V,J,"utf8"),M$.chmodSync(V,"755")}import A$ from"node:fs";import B$ from"node:path";import I7 from"nunjucks";import F7 from"ajv/dist/2020.js";import L7 from"ajv/dist/standalone/index.js";import j7 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 M=$.doc.features.cli.fargs,B={type:"string",description:"Config name to load args",hidden:!1},R={type:"array",description:"Tags to filter the config",hidden:!1};if(Reflect.has(M,"default"))B.default=M.default}let J={imports:Y,atom:$},H=Z.templateDir,K=I7.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 A=new F7({allErrors:!0,useDefaults:!0,formats:{},strict:!1,code:{esm:!0,lines:!0,optimize:!1,source:!0}});j7(A);let U=A.compile(q),z=L7(A,U)+`
|
|
4
|
+
export { schema31 as schema };`;A$.writeFileSync(B$.resolve(G,"src/default/validate_input.js"),z,"utf8")}import m6 from"node:fs";import c6 from"node:path";import l6 from"nunjucks";async function C$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){await Q({message:"Creating .gitignore"});let q={atom:$,packageDependencies:X},Y=Z.templateDir,J=l6.compile(m6.readFileSync(c6.resolve(Y,".gitignore.njk"),"utf8"),l6.configure(Y)).render(q),H=Z.projectDir,V=c6.resolve(H,".gitignore");m6.writeFileSync(V,J,"utf8")}import d6 from"node:fs";import p6 from"node:path";import i6 from"nunjucks";async function I$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){await Q({message:"Creating tsconfig.json."});let q={atom:$,packageDependencies:X},Y=Z.templateDir,J=i6.compile(d6.readFileSync(p6.resolve(Y,"tsconfig.json.njk"),"utf8"),i6.configure(Y)).render(q),H=Z.projectDir,V=p6.resolve(H,"tsconfig.json");d6.writeFileSync(V,J,"utf8")}import z8 from"nunjucks";import C0 from"node:fs";import S0 from"node:path";import r6 from"@fnet/yaml";async function F$({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=S0.resolve(Q.project.projectDir,"fnet/how-to.md");if(C0.existsSync(H)){let O=C0.readFileSync(H,"utf8");J.howto=O}let V=S0.resolve(Q.project.projectDir,"fnet/input.yaml");if(C0.existsSync(V)){let O=await r6({file:V,tags:Q.tags});J.input=O.content}let K=S0.resolve(Q.project.projectDir,"fnet/output.yaml");if(C0.existsSync(K)){let O=await r6({file:K,tags:Q.tags});J.output=O.content}let G=Q.templateDir,A=z8.compile(C0.readFileSync(S0.resolve(G,"readme.md.njk"),"utf8"),z8.configure(G)).render(J),U=S0.resolve(W,"readme.md");C0.writeFileSync(U,A,"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(C0.readFileSync(S0.resolve(K,"readme.md.njk"),"utf8"),z8.configure(K)).render(V),A=Q.projectDir,U=S0.resolve(A,"readme.md");C0.writeFileSync(U,_,"utf8")}}import T7 from"node:path";import s6 from"@fnet/shelljs";async function L$({setProgress:$,context:Q}){let Z=Q.projectDir;await $({message:"Prettifiying source files."});let X=T7.join("src","**","*");if(V0("bun")){let q=await s6(`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 s6(`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 S7 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 S7("tsc",{cwd:X})).code!==0)throw Error("Couldnt create .d.ts files.")}import n6 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 n6(`bun install ${Q.doc.features.npm_install_flags}`,{cwd:X})).code!==0)throw Error("Couldnt install npm packages.")}else if((await n6(`npm install ${Q.doc.features.npm_install_flags}`,{cwd:X})).code!==0)throw Error("Couldnt install npm packages.")}import a6 from"node:fs";import w7 from"node:path";import{spawn as P7}from"node:child_process";async function o6($){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=w7.resolve(Q,"package.json");if(!a6.existsSync(H))throw Error(`package.json not found at ${H}`);let V=JSON.parse(a6.readFileSync(H,"utf8")),K=V.scripts?.[Z];if(!K){let A=Object.keys(V.scripts||{}).join(", ");throw Error(`Script '${Z}' not found. Available: ${A}`)}let G=X.length>0?`${K} ${X.join(" ")}`:K,_=P7(G,[],{cwd:Q,shell:Y,detached:W,env:{...q}});if(J)J(_);return new Promise((A,U)=>{_.on("error",(O)=>{U(Error(`Failed to start '${Z}': ${O.message}`))}),_.on("close",(O)=>{A({subprocess:_,exitCode:O})})})}import N7 from"node:path";async function S$({setProgress:$,context:Q}){let Z=Q.projectDir;await $({message:"Building main project."});let X=Q.dev?"build:dev":"build",q={...process.env},Y=N7.join(Z,"node_modules");q.NODE_PATH=Y;let W=q.NODE_OPTIONS||"";q.NODE_OPTIONS=`${W} --preserve-symlinks`.trim(),await o6({projectDir:Z,scriptName:X,shell:!0,detached:!0,env:q})}var t6=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 M2 from"@flownet/lib-parse-node-url";import $5 from"bpmn-moddle";import e6 from"dagre";import N$ from"lodash.clonedeep";var w$={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 Q5($){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),I("bpmn"))k.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 O=q.find((z)=>z._inlineParent===U);if(O)H.push({from:U,to:O,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}}),A=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$(A,"to"),J.bpmn.type=D7(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 D7($){let Q;if($.type==="call"){if($.context?.lib?.type==="subworkflow"||$.context?.lib?.type==="workflow"){if(Q="bpmn:CallActivity",I("bpmn"))k.info(` \uD83D\uDCE6 CALL → CallActivity (subworkflow): ${$.indexKey}`,{nodeType:$.type,bpmnType:Q,calledElement:$.context?.lib?.name||"unknown",isChip:!0})}else if(Q="bpmn:ServiceTask",I("bpmn"))k.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",I("bpmn"))k.info(` \uD83D\uDCDD FORM → UserTask: ${$.indexKey}`,{nodeType:$.type,bpmnType:Q})}else if($.type==="return"){if(Q="bpmn:EndEvent",I("bpmn"))k.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",I("bpmn"))k.info(` ⚡ RAISE → IntermediateThrowEvent (inside try): ${$.indexKey}`,{nodeType:$.type,bpmnType:Q,nodeName:$.name,parent:$.parent?.indexKey})}else if(Q="bpmn:EndEvent",I("bpmn"))k.info(` ⚠️ RAISE → EndEvent (error): ${$.indexKey}`,{nodeType:$.type,bpmnType:Q})}else if($.type==="pipeline"){if(Q="bpmn:ServiceTask",I("bpmn"))k.info(` \uD83D\uDD27 PIPELINE → ServiceTask (external binary): ${$.indexKey}`,{nodeType:$.type,bpmnType:Q,binary:$.context?.binaryName||"unknown"})}else if($.type==="assign"||$.type==="new"){if(Q="bpmn:ScriptTask",I("bpmn"))k.info(` \uD83D\uDCDC ${$.type.toUpperCase()} → ScriptTask: ${$.indexKey}`,{nodeType:$.type,bpmnType:Q})}else if(Q="bpmn:Task",I("bpmn"))k.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 b$($){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((K)=>!K.virtual).length>0,H=(Y.name==="try"||Y.name==="except")&&Y.parent?.type==="tryexcept",V=Y.type==="schedule";if(J||H||V){if(Y.bpmn.type="bpmn:SubProcess",Y.type==="for"){if(Y.bpmn.loopCharacteristics=!0,I("bpmn"))k.info(" \uD83D\uDD01 FOR → SubProcess + Loop Marker",{subprocess:Y.indexKey,loopType:"StandardLoopCharacteristics"})}if(Y.name==="try"&&Y.type==="raise"&&Y.parent?.type==="tryexcept"){let K=r({location:0,...$,parent:Y,bpmnType:"bpmn:IntermediateThrowEvent",type:"raise",attrs:{},definitions:[{type:"bpmn:ErrorEventDefinition"}]});if(I("bpmn"))k.info(" ⚡ Created virtual IntermediateThrowEvent for single-step try block",{tryNode:Y.indexKey,virtualNode:K.indexKey,bpmnType:K.bpmn.type})}}if(W||J){let K=Y.childs.filter((M)=>M.module!==!0&&!M.indexKey.endsWith("/_inline_end"))[0];Y.childs.filter((M)=>M.module===!0).forEach((M)=>{let B=r({...$,parent:Y,bpmnType:"bpmn:IntermediateCatchEvent",type:"inter",definitions:[{type:"bpmn:SignalEventDefinition"}]});B.bpmn.edges=[{from:B.indexKey,to:M.indexKey,type:"bpmn:SequenceFlow"}]});let _=Y.childs.find((M)=>M.name==="try"&&Y.type==="tryexcept"),A=Y.childs.filter((M)=>M.name==="except"&&Y.type==="tryexcept");if(_&&A.length)A.forEach((M)=>{let B=r({location:Y.childs.indexOf(M),...$,parent:Y,bpmnType:"bpmn:BoundaryEvent",type:"boundary",attrs:{attachedToRef:_},definitions:[{type:"bpmn:ErrorEventDefinition"}]});if(B.bpmn.edges=[{from:B.indexKey,to:M.indexKey,type:"bpmn:SequenceFlow"}],I("bpmn"))k.info(" ⚡ TRY-EXCEPT → BoundaryEvent",{subprocess:Y.indexKey,tryNode:_.indexKey,exceptNode:M.indexKey,boundaryEvent:B.indexKey})});let U=Y.childs.find((M)=>M.type==="raise");if(U){let M=r({...$,parent:Y,bpmnType:"bpmn:EndEvent",type:"end",name:"ERROR",definitions:[{type:"bpmn:ErrorEventDefinition"}]});U.bpmn.edges=[{from:U.indexKey,to:M.indexKey,type:"bpmn:SequenceFlow"}]}if(Y.type==="schedule"){let M=Y.childs[0];if(M){let B=r({...$,parent:Y,bpmnType:"bpmn:StartEvent",type:"timer-start",definitions:[{type:"bpmn:TimerEventDefinition",timerType:"timeCycle",expression:Y.context?.cron||"* * * * *"}]});if(B.bpmn.edges=[{from:B.indexKey,to:M.indexKey,type:"bpmn:SequenceFlow"}],I("bpmn"))k.info(" ⏰ SCHEDULE → SubProcess + TimerStartEvent",{subprocess:Y.indexKey,timerEvent:B.indexKey,child:M.indexKey,cron:Y.context?.cron})}}if(K)if(Y.type==="schedule"){if(I("bpmn"))k.info(" ⏰ SCHEDULE → Skipping normal StartEvent (using TimerStartEvent)",{subprocess:Y.indexKey,timerEvent:"already created"})}else if(Y.type==="parallel"){let M=r({...$,parent:Y,bpmnType:"bpmn:StartEvent",type:"start"}),B=r({...$,parent:Y,bpmnType:"bpmn:ParallelGateway",type:"fork"}),R=r({...$,parent:Y,bpmnType:"bpmn:ParallelGateway",type:"join"}),F=r({...$,parent:Y,bpmnType:"bpmn:EndEvent",type:"end"});M.bpmn.edges=[{from:M.indexKey,to:B.indexKey,type:"bpmn:SequenceFlow"}];let u=Y.childs.filter((N)=>!N.virtual&&!N.module&&!N.indexKey.endsWith("/_inline_end"));if(B.bpmn.edges=u.map((N)=>{return{from:B.indexKey,to:N.indexKey,type:"bpmn:SequenceFlow"}}),u.forEach((N)=>{N.bpmn.edges=[{from:N.indexKey,to:R.indexKey,type:"bpmn:SequenceFlow"}]}),R.bpmn.edges=[{from:R.indexKey,to:F.indexKey,type:"bpmn:SequenceFlow"}],I("bpmn"))k.info(" \uD83D\uDD00 PARALLEL → Fork/Join Gateways",{subprocess:Y.indexKey,childCount:u.length,pattern:"Start → Fork → [Tasks] → Join → End"})}else if(Y.bpmn.starts.length>1){let M=r({...$,parent:Y,bpmnType:"bpmn:StartEvent",type:"start"}),B=r({...$,parent:Y,bpmnType:"bpmn:ExclusiveGateway",type:"switch"});M.bpmn.edges=[{from:M.indexKey,to:B.indexKey,type:"bpmn:SequenceFlow"}],B.bpmn.edges=Y.bpmn.starts.map((F)=>{return{...F,from:B.indexKey}});let R=B.bpmn.edges.find((F)=>F.next===!0);if(R){let F=r({...$,parent:Y,bpmnType:"bpmn:EndEvent",type:"end",name:R.to});R.to=F.indexKey}}else{let M=r({...$,parent:Y,bpmnType:"bpmn:StartEvent",type:"start"});M.bpmn.edges.push({from:M.indexKey,to:K.indexKey,type:"bpmn:SequenceFlow"})}else if(I("bpmn"))k.info(" \uD83D\uDEAB START EVENT skipped (no valid firstNode)",{subprocess:Y.indexKey,reason:"Only modules or inline end events in subprocess"});Y.childs.filter((M)=>M.virtual!==!0&&M.bpmn.outside.length&&M.bpmn.type!=="bpmn:EndEvent").forEach((M)=>{M.bpmn.outside.forEach((B)=>{let R=q.indexOf(Y),F=r({...$,parent:Y,bpmnType:"bpmn:EndEvent",type:"end",name:B.to,location:R+1});M.bpmn.edges.push({from:M.indexKey,to:F.indexKey,type:"bpmn:SequenceFlow"})})}),Y.childs.filter((M)=>M.virtual!==!0&&M.bpmn.edges.length>1).forEach((M)=>{let B=q.indexOf(M),R=r({...$,parent:Y,bpmnType:"bpmn:ExclusiveGateway",type:"switch",location:B+1});R.bpmn.edges=M.bpmn.edges.map((F)=>{return{...F,from:R.indexKey}}),M.bpmn.edges=[{from:M.indexKey,to:R.indexKey,type:"bpmn:SequenceFlow"}],M.bpmn.outside=[]})}b$({...$,targetNodes:Y.childs})})}function r($){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((A)=>A.type===`v${Y}`).length;if(I("bpmn"))k.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 D$($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:Y,nodeIndex:W,diagrams:J,nodes:H}=$;k7($),v7($),E7($),y7($)}function k7($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:Y,nodeIndex:W,nodes:J}=$,H=Z.get("flowElements");if(Z.$nodes=Z.$nodes||[],I("bpmn"))k.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,I("bpmn"))k.info(` ✨ Created: ${V.bpmn.type} (chip!)`,{id:K.id,name:K.name,calledElement:K.calledElement,nodeType:V.type,virtual:V.virtual||!1})}else if(I("bpmn"))k.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 A=q.create(_.type);return Object.keys(_.attrs||{}).forEach((O)=>{A.set(O,_.attrs[O])}),A});K.eventDefinitions=G}if(V.bpmn.loopCharacteristics&&V.bpmn.type==="bpmn:SubProcess"){if(K.loopCharacteristics=q.create("bpmn:StandardLoopCharacteristics"),I("bpmn"))k.info(` \uD83D\uDD01 Added loop marker to: ${K.id}`,{nodeType:V.type,loopType:"StandardLoopCharacteristics"})}})}function v7($){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],A=`edge.${G.pathKey}_${_.pathKey}`;if(Y[A])return;let U=Y[`node.${G.pathKey}`],O=Y[`node.${_.pathKey}`],z=q.create(K.type,{id:A,sourceRef:U,targetRef:O});Y[z.id]=z,z.$is_edge=!0,U.get("outgoing").push(z),O.get("incoming").push(z),Z.$edges.push({from:U,to:O,flow:z}),J.push(z)})})}function E7($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:Y,nodeIndex:W}=$,J=120,H=80,V=160,K=160,G=new e6.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)}),e6.layout(G),Z.$nodes.forEach((_)=>{let A=G.node(_.id),U=A.width,O=A.height,z=q.create("bpmndi:BPMNShape",{id:`shape.${_.id}`,bpmnElement:_,bounds:q.create("dc:Bounds",{x:160+A.x-A.width/2,y:160+A.y-A.height/2,width:U,height:O}),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 A=G.edge(_.from.id,_.to.id),U=q.create("bpmndi:BPMNEdge",{id:`edge.${_.from.id}_${_.to.id}`,bpmnElement:_.flow,label:q.create("bpmndi:BPMNLabel")});A.points.forEach((z)=>{let M=q.create("dc:Point",{x:160+z.x,y:160+z.y});U.get("waypoint").push(M)}),X.get("planeElement").push(U)})}function y7($){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,D$({...$,targetNode:V,targetFlowElementsContainer:K,targetPlaneElement:_})})}async function x7($){let Q=$.root,Z=Q.context.index,X=Object.keys(Z).map((V)=>Z[V]);Q5({nodes:X,nodeIndex:Z,root:Q}),b$({nodes:X,nodeIndex:Z,root:Q});let q=void 0,Y=new $5({atom:w$}),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 A=Y.create("bpmndi:BPMNDiagram",{id:`diagram_${V.pathKey}`});W[A.id]=A,G.push(A);let U=Y.create("bpmndi:BPMNPlane",{id:`plane_${V.pathKey}`});W[U.id]=U,A.plane=U,U.bpmnElement=_,D$({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 u7($){let{root:Q,flowName:Z}=$,X=N$(Q),q=X.childs.find((F)=>F.name===Z);if(!q)throw Error(`Flow "${Z}" not found`);let Y={...X,childs:[q]},W=Y.context.index,J=Object.keys(W).map((F)=>W[F]);Q5({nodes:J,nodeIndex:W,root:Y}),b$({nodes:J,nodeIndex:W,root:Y});let H=new $5({atom:w$}),V={},K=H.create("bpmn:Definitions",{id:`definitions_${Z}`});V[K.id]=K;let G=K.get("rootElements"),_=K.get("diagrams"),A=H.create("bpmn:Process",{id:`process_${q.pathKey}`,name:q.name,documentation:[H.create("bpmn:Documentation",{text:`Workflow - ${q.name}`})]});V[A.id]=A,A.isExecutable=!0,G.push(A);let U=H.create("bpmndi:BPMNDiagram",{id:`diagram_${q.pathKey}`});V[U.id]=U,_.push(U);let O=H.create("bpmndi:BPMNPlane",{id:`plane_${q.pathKey}`});return V[O.id]=O,U.plane=O,O.bpmnElement=A,D$({targetNode:q,targetFlowElementsContainer:A,targetPlaneElement:O,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 x7(N$($))}async function Z5($={}){let Q=N$($),{root:Z}=Q,X=[];for(let q of Z.childs){let Y=await u7({root:Z,flowName:q.name});X.push(Y)}return X}import O2 from"@fnet/config";import A2 from"@flownet/lib-parse-imports-js";import v1 from"@fnet/expression";import B2 from"@fnet/yaml";import R2 from"chalk";var j5=v(O5(),1);var l0=($)=>{if(typeof $!=="string")throw TypeError("invalid pattern");if($.length>65536)throw TypeError("pattern is too long")};var p7={"[: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,"\\$&"),i7=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),A5=($)=>$.join(""),B5=($,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 O=$.charAt(Y);if((O==="!"||O==="^")&&Y===Z+1){V=!0,Y++;continue}if(O==="]"&&W&&!H){K=Y+1;break}if(W=!0,O==="\\"){if(!H){H=!0,Y++;continue}}if(O==="["&&!H){for(let[z,[M,B,R]]of Object.entries(p7))if($.startsWith(z,Y)){if(G)return["$.",!1,$.length-Z,!0];if(Y+=z.length,R)q.push(M);else X.push(M);J=J||B;continue $}}if(H=!1,G){if(O>G)X.push(d0(G)+"-"+d0(O));else if(O===G)X.push(d0(O));G="",Y++;continue}if($.startsWith("-]",Y+1)){X.push(d0(O+"-")),Y+=2;continue}if($.startsWith("-",Y+1)){G=O,Y+=2;continue}X.push(d0(O)),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 O=X[0].length===2?X[0].slice(-1):X[0];return[i7(O),!1,K-Z,!1]}let _="["+(V?"^":"")+A5(X)+"]",A="["+(V?"":"^")+A5(q)+"]";return[X.length&&q.length?"("+_+"|"+A+")":X.length?_:A,J,K-Z,!0]};var Y0=($,{windowsPathsNoEscape:Q=!1}={})=>{return Q?$.replace(/\[([^\/\\])\]/g,"$1"):$.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var r7=new Set(["!","?","+","*","@"]),R5=($)=>r7.has($),s7="(?!(?:^|/)\\.\\.?(?:$|/))",M8="(?!\\.)",n7=new Set(["[","."]),a7=new Set(["..","."]),o7=new Set("().*{}+?[]^$\\!"),t7=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),E$="[^/]",C5=E$+"*?",I5=E$+"+?";class c{type;#Q;#$;#Z=!1;#X=[];#Y;#I;#C;#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.#C=this.#Q===this?[]:this.#Q.#C,$==="!"&&!this.#Q.#V)this.#C.push(this);this.#I=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.#C.pop()){if($.type!=="!")continue;let Q=$,Z=Q.#Y;while(Z){for(let X=Q.#I+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 c&&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.#I===0)return!0;let $=this.#Y;for(let Q=0;Q<this.#I;Q++){let Z=$.#X[Q];if(!(Z instanceof c&&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.#I===$-1}copyIn($){if(typeof $==="string")this.push($);else this.push($.clone(this))}clone($){let Q=new c(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,A="";while(_<$.length){let U=$.charAt(_++);if(q||U==="\\"){q=!q,A+=U;continue}if(Y){if(_===W+1){if(U==="^"||U==="!")J=!0}else if(U==="]"&&!(_===W+2&&J))Y=!1;A+=U;continue}else if(U==="["){Y=!0,W=_,J=!1,A+=U;continue}if(!X.noext&&R5(U)&&$.charAt(_)==="("){Q.push(A),A="";let O=new c(U,Q);_=c.#O($,O,_,X),Q.push(O);continue}A+=U}return Q.push(A),_}let H=Z+1,V=new c(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(R5(_)&&$.charAt(H)==="("){V.push(G),G="";let A=new c(_,V);V.push(A),H=c.#O($,A,H,X);continue}if(_==="|"){V.push(G),G="",K.push(V),V=new c(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 c(null,void 0,Q);return c.#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[A,U,O,z]=typeof _==="string"?c.#U(_,this.#$,J):_.toRegExpSource($);return this.#$=this.#$||O,this.#Z=this.#Z||z,A}).join(""),V="";if(this.isStart()){if(typeof this.#X[0]==="string"){if(!(this.#X.length===1&&a7.has(this.#X[0]))){let A=n7,U=Q&&A.has(H.charAt(0))||H.startsWith("\\.")&&A.has(H.charAt(2))||H.startsWith("\\.\\.")&&A.has(H.charAt(4)),O=!Q&&!$&&A.has(H.charAt(0));V=U?s7:O?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:"")+I5;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+=(o7.has(J)?"\\":"")+J;continue}if(J==="\\"){if(W===$.length-1)q+="\\\\";else X=!0;continue}if(J==="["){let[H,V,K,G]=B5($,W);if(K){q+=H,Y=Y||V,W+=K-1,Q=Q||G;continue}}if(J==="*"){if(Z&&$==="*")q+=I5;else q+=C5;Q=!0;continue}if(J==="?"){q+=E$,Q=!0;continue}q+=t7(J)}return[q,Y0($),!!Q,Y]}}var E0=($,{windowsPathsNoEscape:Q=!1}={})=>{return Q?$.replace(/[?*()[\]]/g,"[$&]"):$.replace(/[?*()[\]\\]/g,"\\$&")};var s=($,Q,Z={})=>{if(l0(Q),!Z.nocomment&&Q.charAt(0)==="#")return!1;return new e(Q,Z).match($)},e7=/^\*+([^+@!?\*\[\(]*)$/,$9=($)=>(Q)=>!Q.startsWith(".")&&Q.endsWith($),Q9=($)=>(Q)=>Q.endsWith($),Z9=($)=>{return $=$.toLowerCase(),(Q)=>!Q.startsWith(".")&&Q.toLowerCase().endsWith($)},X9=($)=>{return $=$.toLowerCase(),(Q)=>Q.toLowerCase().endsWith($)},q9=/^\*+\.\*+$/,Y9=($)=>!$.startsWith(".")&&$.includes("."),J9=($)=>$!=="."&&$!==".."&&$.includes("."),W9=/^\.\*+$/,H9=($)=>$!=="."&&$!==".."&&$.startsWith("."),V9=/^\*+$/,K9=($)=>$.length!==0&&!$.startsWith("."),_9=($)=>$.length!==0&&$!=="."&&$!=="..",G9=/^\?+([^+@!?\*\[\(]*)?$/,z9=([$,Q=""])=>{let Z=T5([$]);if(!Q)return Z;return Q=Q.toLowerCase(),(X)=>Z(X)&&X.toLowerCase().endsWith(Q)},U9=([$,Q=""])=>{let Z=S5([$]);if(!Q)return Z;return Q=Q.toLowerCase(),(X)=>Z(X)&&X.toLowerCase().endsWith(Q)},M9=([$,Q=""])=>{let Z=S5([$]);return!Q?Z:(X)=>Z(X)&&X.endsWith(Q)},O9=([$,Q=""])=>{let Z=T5([$]);return!Q?Z:(X)=>Z(X)&&X.endsWith(Q)},T5=([$])=>{let Q=$.length;return(Z)=>Z.length===Q&&!Z.startsWith(".")},S5=([$])=>{let Q=$.length;return(Z)=>Z.length===Q&&Z!=="."&&Z!==".."},w5=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",F5={win32:{sep:"\\"},posix:{sep:"/"}},A9=w5==="win32"?F5.win32.sep:F5.posix.sep;s.sep=A9;var l=Symbol("globstar **");s.GLOBSTAR=l;var B9="[^/]",R9=B9+"*?",C9="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",I9="(?:(?!(?:\\/|^)\\.).)*?",F9=($,Q={})=>(Z)=>s(Z,$,Q);s.filter=F9;var t=($,Q={})=>Object.assign({},$,Q),L9=($)=>{if(!$||typeof $!=="object"||!Object.keys($).length)return s;let Q=s;return Object.assign((X,q,Y={})=>Q(X,q,t($,Y)),{Minimatch:class extends Q.Minimatch{constructor(q,Y={}){super(q,t($,Y))}static defaults(q){return Q.defaults(t($,q)).Minimatch}},AST:class extends Q.AST{constructor(q,Y,W={}){super(q,Y,t($,W))}static fromGlob(q,Y={}){return Q.AST.fromGlob(q,t($,Y))}},unescape:(X,q={})=>Q.unescape(X,t($,q)),escape:(X,q={})=>Q.escape(X,t($,q)),filter:(X,q={})=>Q.filter(X,t($,q)),defaults:(X)=>Q.defaults(t($,X)),makeRe:(X,q={})=>Q.makeRe(X,t($,q)),braceExpand:(X,q={})=>Q.braceExpand(X,t($,q)),match:(X,q,Y={})=>Q.match(X,q,t($,Y)),sep:Q.sep,GLOBSTAR:l})};s.defaults=L9;var P5=($,Q={})=>{if(l0($),Q.nobrace||!/\{(?:(?!\{).)*\}/.test($))return[$];return j5.default($)};s.braceExpand=P5;var j9=($,Q={})=>new e($,Q).makeRe();s.makeRe=j9;var T9=($,Q,Z={})=>{let X=new e(Q,Z);if($=$.filter((q)=>X.match(q)),X.options.nonull&&!$.length)$.push(Q);return $};s.match=T9;var L5=/[?*]|[+@!]\(.*?\)|\[|\]/,S9=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class e{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||w5,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]==="?"||!L5.test(q[2]))&&!L5.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]),O=!U&&$[0]===""&&$[1]===""&&$[2]==="?"&&/^[a-z]:$/i.test($[3]),z=typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0]),M=!z&&Q[0]===""&&Q[1]===""&&Q[2]==="?"&&typeof Q[3]==="string"&&/^[a-z]:$/i.test(Q[3]),B=O?3:U?0:void 0,R=M?3:z?0:void 0;if(typeof B==="number"&&typeof R==="number"){let[F,u]=[$[B],Q[R]];if(F.toLowerCase()===u.toLowerCase()){if(Q[R]=F,R>B)Q=Q.slice(R);else if(B>R)$=$.slice(B)}}}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===l){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 A=$[G];if(this.debug(`
|
|
5
|
+
globstar while`,$,G,Q,_,A),this.matchOne($.slice(G),Q.slice(_),Z))return this.debug("globstar found match!",G,J,A),!0;else{if(A==="."||A===".."||!X.dot&&A.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 P5(this.pattern,this.options)}parse($){l0($);let Q=this.options;if($==="**")return l;if($==="")return"";let Z,X=null;if(Z=$.match(V9))X=Q.dot?_9:K9;else if(Z=$.match(e7))X=(Q.nocase?Q.dot?X9:Z9:Q.dot?Q9:$9)(Z[1]);else if(Z=$.match(G9))X=(Q.nocase?Q.dot?U9:z9:Q.dot?M9:O9)(Z);else if(Z=$.match(q9))X=Q.dot?J9:Y9;else if(Z=$.match(W9))X=H9;let q=c.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?R9:Q.dot?C9:I9,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"?S9(V):V===l?l:V._src});return H.forEach((V,K)=>{let G=H[K+1],_=H[K-1];if(V!==l||_===l)return;if(_===void 0)if(G!==void 0&&G!==l)H[K+1]="(?:\\/|"+Z+"\\/)?"+G;else H[K]=Z;else if(G===void 0)H[K-1]=_+"(?:\\/|"+Z+")?";else if(G!==l)H[K-1]=_+"(?:\\/|\\/"+Z+"\\/)"+G,H[K+1]=l}),H.filter((V)=>V!==l).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 s.defaults($).Minimatch}}s.AST=c;s.Minimatch=e;s.escape=E0;s.unescape=Y0;import{fileURLToPath as qQ}from"node:url";var y0=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,b5=new Set,y$=typeof process==="object"&&!!process?process:{},D5=($,Q,Z,X)=>{typeof y$.emitWarning==="function"?y$.emitWarning($,Q,Z,X):console.error(`[${Z}] ${Q}: ${$}`)},O8=globalThis.AbortController,N5=globalThis.AbortSignal;if(typeof O8>"u"){N5=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(X,q){this._onabort.push(q)}},O8=class{constructor(){Q()}signal=new N5;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,D5("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 w9=($)=>!b5.has($),ZX=Symbol("type"),I0=($)=>$&&$===Math.floor($)&&$>0&&isFinite($),k5=($)=>!I0($)?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=k5($);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;#I;#C;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;#F;#K;#T;#B;#b;static unsafeExposeInternals($){return{starts:$.#W,ttls:$.#F,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)=>$.#w(Q)}}get max(){return this.#Q}get maxSize(){return this.#$}get calculatedSize(){return this.#G}get size(){return this.#V}get fetchMethod(){return this.#I}get memoMethod(){return this.#C}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:A=0,maxEntrySize:U=0,sizeCalculation:O,fetchMethod:z,memoMethod:M,noDeleteOnFetchRejection:B,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:F,allowStaleOnFetchAbort:u,ignoreFetchAbort:N}=$;if(Q!==0&&!I0(Q))throw TypeError("max option must be a nonnegative integer");let Z0=Q?k5(Q):Array;if(!Z0)throw Error("invalid max value: "+Q);if(this.#Q=Q,this.#$=A,this.maxEntrySize=U||this.#$,this.sizeCalculation=O,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(M!==void 0&&typeof M!=="function")throw TypeError("memoMethod must be a function if defined");if(this.#C=M,z!==void 0&&typeof z!=="function")throw TypeError("fetchMethod must be a function if specified");if(this.#I=z,this.#T=!!z,this.#H=new Map,this.#_=Array(Q).fill(void 0),this.#q=Array(Q).fill(void 0),this.#O=new Z0(Q),this.#M=new Z0(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.#b=!!this.#X,this.#B=!!this.#Y,this.noDisposeOnSet=!!G,this.noUpdateTTL=!!_,this.noDeleteOnFetchRejection=!!B,this.allowStaleOnFetchRejection=!!F,this.allowStaleOnFetchAbort=!!u,this.ignoreFetchAbort=!!N,this.maxEntrySize!==0){if(this.#$!==0){if(!I0(this.#$))throw TypeError("maxSize must be a positive integer if specified")}if(!I0(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=I0(X)||X===0?X:1,this.ttlAutopurge=!!q,this.ttl=Z||0,this.ttl){if(!I0(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(w9("LRU_CACHE_UNBOUNDED"))b5.add("LRU_CACHE_UNBOUNDED"),D5("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.#F=$,this.#W=Q,this.#D=(q,Y,W=y0.now())=>{if(Q[q]=Y!==0?W:0,$[q]=Y,Y!==0&&this.ttlAutopurge){let J=setTimeout(()=>{if(this.#w(q))this.#k(this.#_[q],"expire")},Y+1);if(J.unref)J.unref()}},this.#v=(q)=>{Q[q]=$[q]!==0?y0.now():0},this.#S=(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.#w=(q)=>{let Y=Q[q],W=$[q];return!!W&&!!Y&&(Z||X())-Y>W}}#v=()=>{};#S=()=>{};#D=()=>{};#w=()=>!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(!I0(X))if(q){if(typeof q!=="function")throw TypeError("sizeCalculation must be a function");if(X=q(Z,Q),!I0(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.#w(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.#w(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.#w(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.#F&&this.#W){let Y=this.#F[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.#F&&this.#W){Y.ttl=this.#F[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.#b)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.#b)this.onInsert?.(Q,$,Q===G?"update":"replace")}if(X!==0&&!this.#F)this.#J();if(this.#F){if(!H)this.#D(K,X,q);if(J)this.#S(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.#w(q)){if(Z)this.#v(q);if(X)X.has="hit",this.#S(X,q);return!0}else if(X)X.has="stale",this.#S(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.#w(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,O=!1)=>{let{aborted:z}=Y.signal,M=Z.ignoreFetchAbort&&U!==void 0;if(Z.status)if(z&&!O){if(Z.status.fetchAborted=!0,Z.status.fetchError=Y.signal.reason,M)Z.status.fetchAbortIgnored=!0}else Z.status.fetchResolved=!0;if(z&&!M&&!O)return K(Y.signal.reason);let B=_;if(this.#q[Q]===_)if(U===void 0)if(B.__staleWhileFetching)this.#q[Q]=B.__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:O}=Y.signal,z=O&&Z.allowStaleOnFetchAbort,M=z||Z.allowStaleOnFetchRejection,B=M||Z.noDeleteOnFetchRejection,R=_;if(this.#q[Q]===_){if(!B||R.__staleWhileFetching===void 0)this.#k($,"fetch");else if(!z)this.#q[Q]=R.__staleWhileFetching}if(M){if(Z.status&&R.__staleWhileFetching!==void 0)Z.status.returnedStale=!0;return R.__staleWhileFetching}else if(R.__returned===R)throw U},G=(U,O)=>{let z=this.#I?.($,q,J);if(z&&z instanceof Promise)z.then((M)=>U(M===void 0?void 0:M),O);Y.signal.addEventListener("abort",()=>{if(!Z.ignoreFetchAbort||Z.allowStaleOnFetchAbort){if(U(void 0),Z.allowStaleOnFetchAbort)U=(M)=>H(M,!0)}})};if(Z.status)Z.status.fetchDispatched=!0;let _=new Promise(G).then(H,V),A=Object.assign(_,{__abortController:Y,__staleWhileFetching:q,__returned:void 0});if(Q===void 0)this.set($,A,{...J.options,status:void 0}),Q=this.#H.get($);else this.#q[Q]=A;return A}#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:A=this.allowStaleOnFetchAbort,context:U,forceRefresh:O=!1,status:z,signal:M}=Q;if(!this.#T){if(z)z.fetch="get";return this.get($,{allowStale:Z,updateAgeOnGet:X,noDeleteOnStaleGet:q,status:z})}let B={allowStale:Z,updateAgeOnGet:X,noDeleteOnStaleGet:q,ttl:Y,noDisposeOnSet:W,size:J,sizeCalculation:H,noUpdateTTL:V,noDeleteOnFetchRejection:K,allowStaleOnFetchRejection:G,allowStaleOnFetchAbort:A,ignoreFetchAbort:_,status:z,signal:M},R=this.#H.get($);if(R===void 0){if(z)z.fetch="miss";let F=this.#y($,R,B,U);return F.__returned=F}else{let F=this.#q[R];if(this.#z(F)){let X0=Z&&F.__staleWhileFetching!==void 0;if(z){if(z.fetch="inflight",X0)z.returnedStale=!0}return X0?F.__staleWhileFetching:F.__returned=F}let u=this.#w(R);if(!O&&!u){if(z)z.fetch="hit";if(this.#f(R),X)this.#v(R);if(z)this.#S(z,R);return F}let N=this.#y($,R,B,U),b0=N.__staleWhileFetching!==void 0&&Z;if(z){if(z.fetch=u?"stale":"refresh",b0&&u)z.returnedStale=!0}return b0?N.__staleWhileFetching:N.__returned=N}}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.#C;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.#S(Y,W);if(this.#w(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.#F&&this.#W)this.#F.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 f9,win32 as p$}from"node:path";import{fileURLToPath as h9}from"node:url";import{lstatSync as g9,readdir as m9,readdirSync as c9,readlinkSync as l9,realpathSync as d9}from"fs";import*as p9 from"node:fs";import{lstat as r9,readdir as s9,readlink as n9,realpath as a9}from"node:fs/promises";import{EventEmitter as m$}from"node:events";import u5 from"node:stream";import{StringDecoder as P9}from"node:string_decoder";var v5=typeof process==="object"&&process?process:{stdout:null,stderr:null},N9=($)=>!!$&&typeof $==="object"&&($ instanceof P0||$ instanceof u5||b9($)||D9($)),b9=($)=>!!$&&typeof $==="object"&&$ instanceof m$&&typeof $.pipe==="function"&&$.pipe!==u5.Writable.prototype.pipe,D9=($)=>!!$&&typeof $==="object"&&$ instanceof m$&&typeof $.write==="function"&&typeof $.end==="function",O0=Symbol("EOF"),A0=Symbol("maybeEmitEnd"),F0=Symbol("emittedEnd"),A8=Symbol("emittingEnd"),r0=Symbol("emittedError"),B8=Symbol("closed"),E5=Symbol("read"),R8=Symbol("flush"),y5=Symbol("flushChunk"),J0=Symbol("encoding"),u0=Symbol("decoder"),h=Symbol("flowing"),s0=Symbol("paused"),f0=Symbol("resume"),g=Symbol("buffer"),n=Symbol("pipes"),m=Symbol("bufferLength"),x$=Symbol("bufferPush"),C8=Symbol("bufferShift"),i=Symbol("objectMode"),y=Symbol("destroyed"),u$=Symbol("error"),f$=Symbol("emitData"),x5=Symbol("emitEnd"),h$=Symbol("emitEnd2"),K0=Symbol("async"),g$=Symbol("abort"),I8=Symbol("aborted"),n0=Symbol("signal"),w0=Symbol("dataListeners"),o=Symbol("discarded"),a0=($)=>Promise.resolve().then($),k9=($)=>$(),v9=($)=>$==="end"||$==="finish"||$==="prefinish",E9=($)=>$ instanceof ArrayBuffer||!!$&&typeof $==="object"&&$.constructor&&$.constructor.name==="ArrayBuffer"&&$.byteLength>=0,y9=($)=>!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 f5 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 x9=($)=>!!$.objectMode,u9=($)=>!$.objectMode&&!!$.encoding&&$.encoding!=="buffer";class P0 extends m${[h]=!1;[s0]=!1;[n]=[];[g]=[];[i];[J0];[K0];[u0];[O0]=!1;[F0]=!1;[A8]=!1;[B8]=!1;[r0]=null;[m]=0;[y]=!1;[n0];[I8]=!1;[w0]=0;[o]=!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(x9(Q))this[i]=!0,this[J0]=null;else if(u9(Q))this[J0]=Q.encoding,this[i]=!1;else this[i]=!1,this[J0]=null;if(this[K0]=!!Q.async,this[u0]=this[J0]?new P9(this[J0]):null,Q&&Q.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[g]});if(Q&&Q.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[n]});let{signal:Z}=Q;if(Z)if(this[n0]=Z,Z.aborted)this[g$]();else Z.addEventListener("abort",()=>this[g$]())}get bufferLength(){return this[m]}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[i]}set objectMode($){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[K0]}set["async"]($){this[K0]=this[K0]||!!$}[g$](){this[I8]=!0,this.emit("abort",this[n0]?.reason),this.destroy(this[n0]?.reason)}get aborted(){return this[I8]}set aborted($){}write($,Q,Z){if(this[I8])return!1;if(this[O0])throw Error("write after end");if(this[y])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]?a0:k9;if(!this[i]&&!Buffer.isBuffer($)){if(y9($))$=Buffer.from($.buffer,$.byteOffset,$.byteLength);else if(E9($))$=Buffer.from($);else if(typeof $!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[i]){if(this[h]&&this[m]!==0)this[R8](!0);if(this[h])this.emit("data",$);else this[x$]($);if(this[m]!==0)this.emit("readable");if(Z)X(Z);return this[h]}if(!$.length){if(this[m]!==0)this.emit("readable");if(Z)X(Z);return this[h]}if(typeof $==="string"&&!(Q===this[J0]&&!this[u0]?.lastNeed))$=Buffer.from($,Q);if(Buffer.isBuffer($)&&this[J0])$=this[u0].write($);if(this[h]&&this[m]!==0)this[R8](!0);if(this[h])this.emit("data",$);else this[x$]($);if(this[m]!==0)this.emit("readable");if(Z)X(Z);return this[h]}read($){if(this[y])return null;if(this[o]=!1,this[m]===0||$===0||$&&$>this[m])return this[A0](),null;if(this[i])$=null;if(this[g].length>1&&!this[i])this[g]=[this[J0]?this[g].join(""):Buffer.concat(this[g],this[m])];let Q=this[E5]($||null,this[g][0]);return this[A0](),Q}[E5]($,Q){if(this[i])this[C8]();else{let Z=Q;if($===Z.length||$===null)this[C8]();else if(typeof Z==="string")this[g][0]=Z.slice($),Q=Z.slice(0,$),this[m]-=$;else this[g][0]=Z.subarray($),Q=Z.subarray(0,$),this[m]-=$}if(this.emit("data",Q),!this[g].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[h]||!this[s0])this[A0]();return this}[f0](){if(this[y])return;if(!this[w0]&&!this[n].length)this[o]=!0;if(this[s0]=!1,this[h]=!0,this.emit("resume"),this[g].length)this[R8]();else if(this[O0])this[A0]();else this.emit("drain")}resume(){return this[f0]()}pause(){this[h]=!1,this[s0]=!0,this[o]=!1}get destroyed(){return this[y]}get flowing(){return this[h]}get paused(){return this[s0]}[x$]($){if(this[i])this[m]+=1;else this[m]+=$.length;this[g].push($)}[C8](){if(this[i])this[m]-=1;else this[m]-=this[g][0].length;return this[g].shift()}[R8]($=!1){do;while(this[y5](this[C8]())&&this[g].length);if(!$&&!this[g].length&&!this[O0])this.emit("drain")}[y5]($){return this.emit("data",$),this[h]}pipe($,Q){if(this[y])return $;this[o]=!1;let Z=this[F0];if(Q=Q||{},$===v5.stdout||$===v5.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 f5(this,$,Q)),this[K0])a0(()=>this[f0]());else this[f0]();return $}unpipe($){let Q=this[n].find((Z)=>Z.dest===$);if(Q){if(this[n].length===1){if(this[h]&&this[w0]===0)this[h]=!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[o]=!1,this[w0]++,!this[n].length&&!this[h])this[f0]()}else if($==="readable"&&this[m]!==0)super.emit("readable");else if(v9($)&&this[F0])super.emit($),this.removeAllListeners($);else if($==="error"&&this[r0]){let X=Q;if(this[K0])a0(()=>X.call(this,this[r0]));else X.call(this,this[r0])}return Z}removeListener($,Q){return this.off($,Q)}off($,Q){let Z=super.off($,Q);if($==="data"){if(this[w0]=this.listeners("data").length,this[w0]===0&&!this[o]&&!this[n].length)this[h]=!1}return Z}removeAllListeners($){let Q=super.removeAllListeners($);if($==="data"||$===void 0){if(this[w0]=0,!this[o]&&!this[n].length)this[h]=!1}return Q}get emittedEnd(){return this[F0]}[A0](){if(!this[A8]&&!this[F0]&&!this[y]&&this[g].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"&&$!==y&&this[y])return!1;else if($==="data")return!this[i]&&!Z?!1:this[K0]?(a0(()=>this[f$](Z)),!0):this[f$](Z);else if($==="end")return this[x5]();else if($==="close"){if(this[B8]=!0,!this[F0]&&!this[y])return!1;let q=super.emit("close");return this.removeAllListeners("close"),q}else if($==="error"){this[r0]=Z,super.emit(u$,Z);let q=!this[n0]||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[o]?!1:super.emit("data",$);return this[A0](),Q}[x5](){if(this[F0])return!1;return this[F0]=!0,this.readable=!1,this[K0]?(a0(()=>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[o])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[i])$.dataLength=0;let Q=this.promise();return this.on("data",(Z)=>{if($.push(Z),!this[i])$.dataLength+=Z.length}),await Q,$}async concat(){if(this[i])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(y,()=>Q(Error("stream destroyed"))),this.on("error",(Z)=>Q(Z)),this.on("end",()=>$())})}[Symbol.asyncIterator](){this[o]=!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(y,V),Q(),Y(K)},J=(K)=>{this.off("error",W),this.off("end",H),this.off(y,V),this.pause(),q({value:K,done:!!this[O0]})},H=()=>{this.off("error",W),this.off("data",J),this.off(y,V),Q(),q({done:!0,value:void 0})},V=()=>W(Error("stream destroyed"));return new Promise((K,G)=>{Y=G,q=K,this.once(y,V),this.once("error",W),this.once("end",H),this.once("data",J)})},throw:Q,return:Q,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[o]=!1;let $=!1,Q=()=>{return this.pause(),this.off(u$,Q),this.off(y,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(y,Q),{next:Z,throw:Q,return:Q,[Symbol.iterator](){return this}}}destroy($){if(this[y]){if($)this.emit("error",$);else this.emit(y);return this}this[y]=!0,this[o]=!0,this[g].length=0,this[m]=0;let Q=this;if(typeof Q.close==="function"&&!this[B8])Q.close();if($)this.emit("error",$);else this.emit(y);return this}static get isStream(){return N9}}var i9=d9.native,t0={lstatSync:g9,readdir:m9,readdirSync:c9,readlinkSync:l9,realpathSync:i9,promises:{lstat:r9,readdir:s9,readlink:n9,realpath:a9}},l5=($)=>!$||$===t0||$===p9?t0:{...t0,...$,promises:{...t0.promises,...$.promises||{}}},d5=/^\\\\\?\\([a-z]:)\\?$/i,o9=($)=>$.replace(/\//g,"\\").replace(d5,"$1\\"),t9=/[\\\/]/,Q0=0,p5=1,i5=2,_0=4,r5=6,s5=8,N0=10,n5=12,$0=15,o0=~$0,l$=16,h5=32,e0=64,W0=128,F8=256,j8=512,g5=e0|W0|j8,e9=1023,d$=($)=>$.isFile()?s5:$.isDirectory()?_0:$.isSymbolicLink()?N0:$.isCharacterDevice()?i5:$.isBlockDevice()?r5:$.isSocket()?n5:$.isFIFO()?p5:Q0,m5=new Map,$8=($)=>{let Q=m5.get($);if(Q)return Q;let Z=$.normalize("NFKD");return m5.set($,Z),Z},c5=new Map,L8=($)=>{let Q=c5.get($);if(Q)return Q;let Z=$8($.toLowerCase());return c5.set($,Z),Z};class i$ extends i0{constructor(){super({max:256})}}class a5 extends i0{constructor($=16384){super({maxSize:$,sizeCalculation:(Q)=>Q.length+1})}}var o5=Symbol("PathScurry setAsCwd");class a{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}#I;get gid(){return this.#I}#C;get rdev(){return this.#C}#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;#F;#K;#T;#B;#b;#J;#v;#S;#D;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor($,Q=Q0,Z,X,q,Y,W){if(this.name=$,this.#W=q?L8($):$8($),this.#J=Q&e9,this.nocase=q,this.roots=X,this.root=Z||this,this.#v=Y,this.#K=W.fullpath,this.#B=W.relative,this.#b=W.relativePosix,this.parent=W.parent,this.parent)this.#Q=this.parent.#Q;else this.#Q=l5(W.fs)}depth(){if(this.#F!==void 0)return this.#F;if(!this.parent)return this.#F=0;return this.#F=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).#w(X):this.#w(X)}#w($){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($,Q0,{...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.#b!==void 0)return this.#b;let $=this.name,Q=this.parent;if(!Q)return this.#b=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&$0)===Q0}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&$0)===s5}isDirectory(){return(this.#J&$0)===_0}isCharacterDevice(){return(this.#J&$0)===i5}isBlockDevice(){return(this.#J&$0)===r5}isFIFO(){return(this.#J&$0)===p5}isSocket(){return(this.#J&$0)===n5}isSymbolicLink(){return(this.#J&N0)===N0}lstatCached(){return this.#J&h5?this:void 0}readlinkCached(){return this.#S}realpathCached(){return this.#D}readdirCached(){let $=this.children();return $.slice(0,$.provisional)}canReadlink(){if(this.#S)return!0;if(!this.parent)return!1;let $=this.#J&$0;return!($!==Q0&&$!==N0||this.#J&F8||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.#S;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.#S=Z}catch(Q){this.#u(Q.code);return}}readlinkSync(){let $=this.#S;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.#S=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(($&$0)===_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|=F8,$==="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&$0;if(q!==_0&&q!==N0&&q!==Q0)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:A,mtimeMs:U,nlink:O,rdev:z,size:M,uid:B}=$;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.#I=K,this.#G=G,this.#Z=_,this.#j=A,this.#O=U,this.#X=O,this.#C=z,this.#H=M,this.#Y=B;let R=d$($);if(this.#J=this.#J&o0|R|h5,R!==Q0&&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&g5)return!1;let $=$0&this.#J;if(!($===Q0||$===_0||$===N0))return!1;return!0}shouldWalk($,Q){return(this.#J&_0)===_0&&!(this.#J&g5)&&!$.has(this)&&(!Q||Q(this))}async realpath(){if(this.#D)return this.#D;if((j8|F8|W0)&this.#J)return;try{let $=await this.#Q.promises.realpath(this.fullpath());return this.#D=this.resolve($)}catch($){this.#m()}}realpathSync(){if(this.#D)return this.#D;if((j8|F8|W0)&this.#J)return;try{let $=this.#Q.realpathSync(this.fullpath());return this.#D=this.resolve($)}catch($){this.#m()}}[o5]($){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.#b=Z.join("/"),X=X.parent,Z.push("..");X=$;while(X&&X.parent&&!Q.has(X))X.#B=void 0,X.#b=void 0,X=X.parent}}class T8 extends a{sep="\\";splitSep=t9;constructor($,Q=Q0,Z,X,q,Y,W){super($,Q,Z,X,q,Y,W)}newChild($,Q=Q0,Z={}){return new T8($,Q,this.root,this.roots,this.nocase,this.childrenCache(),Z)}getRootString($){return p$.parse($).root}getRoot($){if($=o9($.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(d5,"$1\\"),$===Q}}class S8 extends a{splitSep="/";sep="/";constructor($,Q=Q0,Z,X,q,Y,W){super($,Q,Z,X,q,Y,W)}getRootString($){return $.startsWith("/")?"/":""}getRoot($){return this.root}newChild($,Q=Q0,Z={}){return new S8($,Q,this.root,this.roots,this.nocase,this.childrenCache(),Z)}}class r${root;rootPath;roots;cwd;#Q;#$;#Z;nocase;#X;constructor($=process.cwd(),Q,Z,{nocase:X,childrenCacheSize:q=16384,fs:Y=t0}={}){if(this.#X=l5(Y),$ instanceof URL||$.startsWith("file://"))$=h9($);let W=Q.resolve($);this.roots=Object.create(null),this.rootPath=this.parseRootPath(W),this.#Q=new i$,this.#$=new i$,this.#Z=new a5(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 A of J){let U=V--;H=H.child(A,{relative:Array(U).fill("..").join(K),relativePosix:Array(U).fill("..").join("/"),fullpath:G+=(_?"":K)+A}),_=!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 a))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 a))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 a))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 a))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 a))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 a))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 a))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((_,A)=>{if(_)return G(_);let U=A.length;if(!U)return G();let O=()=>{if(--U===0)G()};for(let z of A){if(!q||q(z))W.push(Z?z:z.fullpath());if(X&&z.isSymbolicLink())z.realpath().then((M)=>M?.isUnknown()?M.lstat():M).then((M)=>M?.shouldWalk(J,Y)?H(M,O):O());else if(z.shouldWalk(J,Y))H(z,O);else O()}},!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 a))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 a))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 a))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 a))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 A=(O,z,M=!1)=>{if(O)return W.emit("error",O);if(X&&!M){let B=[];for(let R of z)if(R.isSymbolicLink())B.push(R.realpath().then((F)=>F?.isUnknown()?F.lstat():F));if(B.length){Promise.all(B).then(()=>A(null,z,!0));return}}for(let B of z)if(B&&(!q||q(B))){if(!W.write(Z?B:B.fullpath()))G=!0}V--;for(let B of z){let R=B.realpathCached()||B;if(R.shouldWalk(J,Y))H.push(R)}if(G&&!W.flowing)W.once("drain",K);else if(!U)K()},U=!0;_.readdirCB(A,!0),U=!1}};return K(),W}streamSync($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof a))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 A=_.readdirSync();for(let U of A)if(!q||q(U)){if(!W.write(Z?U:U.fullpath()))G=!0}V--;for(let U of A){let O=U;if(U.isSymbolicLink()){if(!(X&&(O=U.realpathSync())))continue;if(O.isUnknown())O.lstatSync()}if(O.shouldWalk(J,Y))H.push(O)}}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[o5](Q)}}class Q8 extends r${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 r${sep="/";constructor($=process.cwd(),Q={}){let{nocase:Z=!1}=Q;super($,f9,"/",{...Q,nocase:Z});this.nocase=Z}parseRootPath($){return"/"}newRoot($){return new S8(this.rootPath,_0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")}}class w8 extends Z8{constructor($=process.cwd(),Q={}){let{nocase:Z=!0}=Q;super($,{...Q,nocase:Z})}}var UX=process.platform==="win32"?T8:S8,t5=process.platform==="win32"?Q8:process.platform==="darwin"?w8:Z8;var $Q=($)=>$.length>=1,QQ=($)=>$.length>=1;class h0{#Q;#$;#Z;length;#X;#Y;#I;#C;#V;#G;#H=!0;constructor($,Q,Z,X){if(!$Q($))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,_,...A]=this.#$;if(H[0]==="")H.shift(),A.shift();let U=[q,Y,W,J,""].join("/"),O=[V,K,G,_,""].join("/");this.#Q=[U,...H],this.#$=[O,...A],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]===l}isRegExp(){return this.#Q[this.#Z]instanceof RegExp}globString(){return this.#I=this.#I||(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.#C=this.#C,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.#C!==void 0?this.#C:this.#C=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 ZQ=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=ZQ}){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 e($,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 e(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 s${store;constructor($=new Map){this.store=$}copy(){return new s$(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 e5{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 $1{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 e5;subwalks=new $1;patterns;follow;dot;opts;constructor($,Q){this.opts=$,this.follow=!!$.follow,this.dot=!!$.dot,this.hasWalkedCache=Q?Q.copy():new s$}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===l){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===l)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 XQ=($,Q)=>typeof $==="string"?new X8([$],Q):Array.isArray($)?new X8($,Q):$;class n${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.#$=XQ(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 n${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 n${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 YQ=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=qQ(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||YQ,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"?w8:Q.platform?Z8:t5;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 e(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 a$=($,Q={})=>{if(!Array.isArray($))$=[$];for(let Z of $)if(new e(Z,Q).hasMagic())return!0;return!1};function b8($,Q={}){return new G0($,Q).streamSync()}function X1($,Q={}){return new G0($,Q).stream()}function D8($,Q={}){return new G0($,Q).walkSync()}async function Q1($,Q={}){return new G0($,Q).walk()}function k8($,Q={}){return new G0($,Q).iterateSync()}function q1($,Q={}){return new G0($,Q).iterate()}var JQ=b8,WQ=Object.assign(X1,{sync:b8}),HQ=k8,VQ=Object.assign(q1,{sync:k8}),KQ=Object.assign(D8,{stream:b8,iterate:k8}),Z1=Object.assign(Q1,{glob:Q1,globSync:D8,sync:KQ,globStream:X1,stream:WQ,globStreamSync:b8,streamSync:JQ,globIterate:q1,iterate:VQ,globIterateSync:k8,iterateSync:HQ,Glob:G0,hasMagic:a$,escape:E0,unescape:Y0});Z1.glob=Z1;import _Q from"node:path";var Y1=({dir:$,pattern:Q="*",nodir:Z=!1,dot:X=!0,ignore:q=[],absolute:Y=!1,matchBase:W=!1,follow:J=!1})=>{if($=$||process.cwd(),$=_Q.resolve($),Q&&!Array.isArray(Q))Q=[Q];else Q=Q||["*"];if(q&&!Array.isArray(q))q=[q];else q=q||[];return D8(Q,{cwd:$,nodir:Z,dot:X,ignore:q,absolute:Y,matchBase:W,follow:J})};import H1 from"@fnet/expression";import J1 from"lodash.clonedeep";import GQ from"@fnet/key-value-transformer";import zQ from"@fnet/expression";async function f({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 GQ({data:$.definition,callback:(Y,W,J)=>{let H=zQ({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 P({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 UQ({node:$}){if(!$.definition.hasOwnProperty("switch"))return!1;return!0}async function MQ({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 f({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=W1}async function W1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||J1($.definition);let q=$.context.transform;for(let Y of $.childs)if(Y.context.transform=Y.context.transform||J1(Y.definition),Y.definition.hasOwnProperty("condition"))Y.context.transform.condition=await X(Y.definition.condition);await P({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var Y8={hits:UQ,init:MQ,resolve:W1};async function OQ({node:$}){if(Object.keys($.definition).map((q)=>H1({expression:q})).filter((q)=>q?.processor==="if").length===1)return!0;if($.definition.if&&typeof $.definition.if==="object")return!0;return!1}async function AQ($){let{node:Q}=$,X=Object.keys(Q.definition).map((H)=>H1({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:OQ,init:AQ};import V1 from"lodash.clonedeep";async function BQ({node:$}){return $.definition.hasOwnProperty("try")&&$.definition.hasOwnProperty("except")}async function RQ({node:$,initNode:Q}){if($.type="tryexcept",await f({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=K1}async function K1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||V1($.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||V1(Y.definition),!Y.context.transform.hasOwnProperty("as"))Y.context.transform.as="error"}await P({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var t$={hits:BQ,init:RQ,resolve:K1};import CQ from"lodash.clonedeep";async function IQ({node:$}){return $.definition.hasOwnProperty("assign")}async function FQ({node:$,initNode:Q}){$.type="assign",await f({node:$,initNode:Q}),$.resolve=_1}async function _1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||CQ($.definition);let q=$.context.transform;await P({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var e$={hits:IQ,init:FQ,resolve:_1};import LQ from"lodash.clonedeep";async function jQ({node:$}){return $.definition.hasOwnProperty("for")}async function TQ({node:$,initNode:Q}){if($.type="for",await f({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=G1}async function G1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||LQ($.definition);let q=$.context.transform;q.for.in=await X($.definition.for.in),await P({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var $6={hits:jQ,init:TQ,resolve:G1};import SQ from"lodash.clonedeep";async function wQ({node:$}){return $.definition.hasOwnProperty("parallel")}async function PQ({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=z1}async function z1({node:$,transformExpression:Q,resolveNextBlock:Z}){$.context.transform=$.context.transform||SQ($.definition),await P({node:$,transformExpression:Q}),Z({node:$})}var Q6={hits:wQ,init:PQ,resolve:z1};import NQ from"lodash.clonedeep";async function bQ({node:$}){return $.definition.hasOwnProperty("raise")}async function DQ({node:$,initNode:Q}){$.type="raise",$.resolve=U1}async function U1({node:$,resolveTypeCommon:Q,transformExpression:Z}){$.context.transform=$.context.transform||NQ($.definition);let X=$.context.transform;X.raise=await Z(X.raise),await Q({node:$})}var Z6={hits:bQ,init:DQ,resolve:U1};import kQ from"lodash.clonedeep";async function vQ({node:$}){return $.definition.hasOwnProperty("return")}async function EQ({node:$,initNode:Q}){$.type="return",$.resolve=M1}async function M1({node:$,resolveTypeCommon:Q,transformExpression:Z}){$.context.transform=$.context.transform||kQ($.definition);let X=$.context.transform;$.hasReturn=!0,X.return=await Z(X.return),await Q({node:$})}var X6={hits:vQ,init:EQ,resolve:M1};import yQ from"lodash.clonedeep";async function xQ({node:$}){return $.definition.hasOwnProperty("call")}async function uQ({node:$,initNode:Q}){$.type="call",await f({node:$,initNode:Q}),$.resolve=O1}async function O1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||yQ($.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 P({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var J8={hits:xQ,init:uQ,resolve:O1};import fQ from"lodash.clonedeep";async function hQ({node:$}){return $.definition.hasOwnProperty("steps")}async function gQ({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=A1}async function A1({node:$,transformExpression:Q}){$.context.next=$.childs[0],$.context.transform=$.context.transform||fQ($.definition),await P({node:$,transformExpression:Q})}var q6={hits:hQ,init:gQ,resolve:A1};import mQ from"lodash.clonedeep";async function cQ({node:$}){return $.definition.hasOwnProperty("form")}async function lQ({node:$,initNode:Q}){$.type="form",await f({node:$,initNode:Q}),$.resolve=B1}async function B1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||mQ($.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 P({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var Y6={hits:cQ,init:lQ,resolve:B1};import dQ from"lodash.clonedeep";async function pQ({node:$}){return $.definition.hasOwnProperty("signal")}async function iQ({node:$,initNode:Q}){$.type="signal",$.resolve=R1}async function R1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X,transformValue:q}){$.context.transform=$.context.transform||dQ($.definition),await Q({node:$}),Z({node:$})}var J6={hits:pQ,init:iQ,resolve:R1};import rQ from"lodash.clonedeep";async function sQ({node:$}){return $.definition.hasOwnProperty("wait")}async function nQ({node:$,initNode:Q}){$.type="wait",$.resolve=C1}async function C1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X,transformValue:q}){$.context.transform=$.context.transform||rQ($.definition),await Q({node:$}),Z({node:$})}var W6={hits:sQ,init:nQ,resolve:C1};import aQ from"lodash.clonedeep";async function oQ({node:$}){return $.definition.hasOwnProperty("next")}async function tQ({node:$,initNode:Q}){$.type="next",$.resolve=I1}async function I1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||aQ($.definition);let q=$.context.transform;q.next=await X(q.next),await P({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var H6={hits:oQ,init:tQ,resolve:I1};import eQ from"lodash.clonedeep";async function $2({node:$}){return $.definition.hasOwnProperty("modules")}async function Q2({node:$,initNode:Q}){$.type="modules",await f({node:$,initNode:Q}),$.resolve=F1}async function F1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||eQ($.definition);let q=$.context.transform;await P({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var V6={hits:$2,init:Q2,resolve:F1};function K6({node:$}){let Q=$.definition;if($.hasReturn){if(I("tree"))D.info(" └─ RETURN (no next)",{depth:$.depth+1,node:$.indexKey});return}if(Q.next==="end"){if(I("tree"))D.info(" └─ EXPLICIT END",{depth:$.depth+1,node:$.indexKey})}else if(Q.next==="stop"){if(I("tree"))D.info(" └─ EXPLICIT STOP",{depth:$.depth+1,node:$.indexKey})}else if(Q.next==="none"){if(I("tree"))D.info(" └─ EXPLICIT NONE",{depth:$.depth+1,node:$.indexKey})}else if(Q.next){if(I("tree"))D.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,I("tree"))D.info(` └─ ✅ FOUND: ${X.indexKey}`,{depth:$.depth+1,nextNode:X.indexKey});break}Z=Z.parent}if(!$.context.next&&I("tree"))D.warn(` └─ ⚠️ NOT FOUND: "${Q.next}"`,{depth:$.depth+1})}else{if($.module===!0){if(I("tree"))D.info(" └─ MODULE ROOT (no auto next)",{depth:$.depth+1,node:$.indexKey});return}if(I("tree"))D.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(I("tree"))D.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,I("tree"))D.info(` ${q}. ✅ SIBLING FOUND: ${Y.indexKey}`,{depth:$.depth+2,nextNode:Y.indexKey});break}else{if(I("tree"))D.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,I("tree"))D.info(` ${q}. ✅ SIBLING FOUND (parent jump disabled): ${Y.indexKey}`,{depth:$.depth+2,nextNode:Y.indexKey})}else if(I("tree"))D.info(` ${q}. ⛔ No sibling, parent jump disabled`,{depth:$.depth+2});break}else if(!Z.blockAutoJumpToParent){if(I("tree"))D.info(` ${q}. ⬆️ Sibling disabled, climbing to parent: ${Z.parent?.indexKey}`,{depth:$.depth+2});X=Z.index+1,Z=Z.parent;continue}if($.context.next&&I("tree"))D.info(` └─ \uD83C\uDFAF AUTO NEXT RESOLVED: ${$.context.next.indexKey}`,{depth:$.depth+1,steps:q,nextNode:$.context.next.indexKey});else if(I("tree"))D.info(" └─ ⚠️ NO NEXT FOUND (end of flow)",{depth:$.depth+1,steps:q})}}class L1{#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 d($){return new L1($)}import Z2 from"lodash.clonedeep";async function X2({node:$}){return $.definition.hasOwnProperty("new")}async function q2({node:$,initNode:Q}){$.type="new",await f({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,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 P({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var _6={hits:X2,init:q2,resolve:j1};import Y2 from"lodash.clonedeep";async function J2({node:$}){return $.definition.hasOwnProperty("output")}async function W2({node:$,initNode:Q}){$.type="output",await f({node:$,initNode:Q}),$.resolve=T1}async function T1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||Y2($.definition),await P({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var G6={hits:J2,init:W2,resolve:T1};import H2 from"lodash.clonedeep";async function V2({node:$}){return $.definition.hasOwnProperty("pipeline")}async function K2({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=S1}async function S1({node:$,transformExpression:Q,resolveNextBlock:Z}){$.context.transform=$.context.transform||H2($.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 P({node:$,transformExpression:Q}),Z({node:$})}var z6={hits:V2,init:K2,resolve:S1};import _2 from"lodash.clonedeep";async function G2({node:$}){return $.definition.hasOwnProperty("schedule")}async function z2({node:$,initNode:Q}){$.type="schedule";let Z=$.definition.schedule;if(!Z||typeof Z!=="string")throw Error(`Schedule step '${$.name}' requires a cron expression string`);$.context.cron=Z;let{schedule:X,...q}=$.definition,Y={name:`${$.name}_scheduled`,childs:[],parent:$,definition:q,index:0,context:{}};$.childs.push(Y),await Q({node:Y}),$.resolve=w1}async function w1({node:$,transformExpression:Q,resolveNextBlock:Z}){$.context.transform=$.context.transform||_2($.definition);let X=$.context.transform;if(X.schedule)X.schedule=await Q(X.schedule);await P({node:$,transformExpression:Q}),Z({node:$})}var U6={hits:G2,init:z2,resolve:w1};var P1=({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 E1{#Q;#$;#Z;#X;#Y;#I;#C;#V;#G;#H;#_;#q;#O;#M;#U;#A;#j;#R;#L;#W;#F;#K=[];constructor($){this.#Q=new D6,this.#$=$,this.#I=[],this.#C=[],this.#V={},this._expire_ttl=3600,this._expire_ttl_short=300,this.#K.push(d({key:"config",npm:"@fnet/config",master:"name"})),this.#K.push(d({key:"yaml",npm:"@fnet/yaml",master:"file"})),this.#K.push(d({key:"prompt",npm:"@fnet/prompt",master:"message"})),this.#K.push(d({key:"html-link",npm:"@flownet/lib-load-browser-link-url",master:"src"})),this.#K.push(d({key:"html-script",npm:"@flownet/lib-load-browser-script-url",master:"src"})),this.#K.push(d({key:"http-server",npm:"@fnet/node-express",master:"server_port"})),this.#K.push(d({key:"shell",npm:"@fnet/shell-flow",master:"commands"})),this.#K.push(d({key:"list-files",npm:"@fnet/list-files",master:"pattern"})),this.#K.push(d({key:"up-list-files",npm:"@fnet/up-list-files",master:"pattern"})),this.#K.push(d({key:"auto-conda-env",npm:"@fnet/auto-conda-env",master:"envDir"})),this.#K.push(d({key:"ollama-chat",npm:"@fnet/ollama-chat",master:"model"})),this.#K.push(d({key:"ai",npm:"@fnet/ai",master:"prompt",extras:{subtype:"flow"}})),this.#K.push(d({key:"invoke",npm:"@fnet/invoke",master:"method",extras:{}})),this.#K.push(d({key:"fetch",npm:"@fnet/fetch",master:"url",extras:{}})),this.#K.push(d({key:"filemap",npm:"@fnet/filemap",master:"target",extras:{}})),this.#W={packageDependencies:this.#I,packageDevDependencies:this.#C,setProgress:this.setProgress.bind(this),context:this.#$,Atom:z0,registerToPackageManager:this.registerToPackageManager.bind(this)},this.#F={initNode:this.initNode.bind(this),cloneDeep:D1,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||k1(),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 O2({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.#I}),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 B2({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=Y1({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(I("tree"))D.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(I("tree"))D.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(I("tree"))D.info(`\uD83D\uDD27 Initializing node: ${X.name}`,{depth:X.depth});await this.initNode({node:X})}if(I("tree"))D.info("✅ Root node tree created",{depth:0,totalFlows:Z.childs.length});return Z}async initNode({node:$}){let Q={...this.#F,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 Q6.hits(Q))Z="parallel",await Q6.init(Q);else if(await z6.hits(Q))Z="pipeline",await z6.init(Q);else if(await U6.hits(Q))Z="schedule",await U6.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(I("tree"))D.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=k1();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=M2({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 A2({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=P1({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||D1($.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.#F,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"schedule":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(U2($)){let Q=Object.keys($);for(let Z=0;Z<Q.length;Z++){let X=Q[Z],q=v1({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=v1({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,N1.stringify(X),"utf8")}async createProjectMainYaml(){await this.setProgress({message:"Creating flow.main.yaml"});let Z={content:N1.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 b1("prettier --write .",{cwd:S.resolve($,"src")});if(Q.code!==0)throw Error(Q.stderr)}else{let Q=await b1("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 t6({...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(R2.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 Z5({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 F$(this.#W),await I$(this.#W),await C$(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 S$(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=E1;var C2={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 w($),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)}}},y1=C2;var I2={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 w($),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)}}},x1=I2;var F2={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 w({...$,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)}}},u1=F2;var L2={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 w({...$,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)}}},f1=L2;import h1 from"node:path";import v8 from"node:fs";import j2 from"@fnet/prompt";var T2={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 w($),{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 j2({type:"input",name:"inputName",message:"Input name:",initial:"dev"});$.name=G}let W=h1.resolve(X,".fnet");if(!v8.existsSync(W))v8.mkdirSync(W);let J=h1.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)}}},g1=T2;import T from"node:path";import L from"node:fs";import y8 from"node:os";import{spawn as x8}from"node:child_process";import C from"chalk";import B0 from"@fnet/prompt";import E8 from"chalk";import m1 from"@fnet/prompt";async function S2($){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 m1({type:"select",name:V,message:Z,choices:J,initial:H});if(K==="cancel")return null;return K}async function w2($){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 m1({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 M6={promptForSelection:S2,promptForMultipleSelection:w2};var x=T.join(y8.homedir(),".fnet","express");async function l1($){$.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 P2(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 N2(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 b2(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 D2(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 v2(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 E2(Q)}).demandCommand(1,"You need to specify a command").help()}async function P2($){try{if(!L.existsSync(x))L.mkdirSync(x,{recursive:!0});let Q=new Date().toISOString().slice(0,10).replace(/-/g,""),Z=T.join(x,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(C.yellow("Project creation cancelled."));return}}console.log(C.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(C.green(`
|
|
8
8
|
Express project "${X}" created successfully!`)),console.log(C.blue(`
|
|
9
|
-
Project location: ${q}`)),!$.yes)
|
|
10
|
-
Failed to create express project "${X}".`)),G(Error(`Process exited with code ${_}`))})})}catch(Q){console.error(C.red(`Error creating express project: ${Q.message}`)),process.exit(1)}}async function
|
|
9
|
+
Project location: ${q}`)),!$.yes)k2(q);else K();else console.error(C.red(`
|
|
10
|
+
Failed to create express project "${X}".`)),G(Error(`Process exited with code ${_}`))})})}catch(Q){console.error(C.red(`Error creating express project: ${Q.message}`)),process.exit(1)}}async function N2($){try{if(!L.existsSync(x)){console.log(C.yellow("No express projects found."));return}let Q=L.readdirSync(x).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(C.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(x,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 A=`${W.slice(0,4)}-${W.slice(4,6)}-${W.slice(6,8)}`;Z.push({name:V,type:_,date:A,path:K,created:G.birthtime})}}if(Z.sort((W,J)=>J.created-W.created),Z.length===0){console.log(C.yellow("No express projects found matching the criteria."));return}console.log(C.blue(`
|
|
11
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([C.white(W.name),W.type==="fnet"?C.cyan(W.type):W.type==="fnode"?C.green(W.type):W.type,W.date,J])}console.log(Y.toString()),console.log(C.blue(`
|
|
12
|
-
Total: ${Z.length} projects`))}catch(Q){console.error(C.red(`Error listing express projects: ${Q.message}`)),process.exit(1)}}async function
|
|
13
|
-
Project moved successfully to ${q}`)),(await B0({type:"confirm",name:"deleteOriginal",message:"Delete the original express project?",initial:!1})).deleteOriginal)
|
|
12
|
+
Total: ${Z.length} projects`))}catch(Q){console.error(C.red(`Error listing express projects: ${Q.message}`)),process.exit(1)}}async function b2($){try{if(!L.existsSync(x)){console.log(C.yellow("No express projects found."));return}let Q;if($.latest){if(Q=await u8(),!Q){console.log(C.yellow("No express projects found."));return}}else if($.projectName){if(Q=await f8($.projectName),!Q){console.log(C.yellow(`Project "${$.projectName}" not found.`));return}}else{let Z=await h8();if(!Z){console.log(C.yellow("No project selected."));return}Q=T.join(x,Z)}await O6(Q)}catch(Q){console.error(C.red(`Error opening express project: ${Q.message}`)),process.exit(1)}}async function D2($){try{let Q=process.cwd(),Z=Q.includes(x),X;if(Z)X=Q,console.log(C.blue(`Using current express project: ${T.basename(X)}`));else if($.latest){if(X=await u8(),!X){console.log(C.yellow("No express projects found."));return}}else if($.projectName){if(X=await f8($.projectName),!X){console.log(C.yellow(`Project "${$.projectName}" not found.`));return}}else{let W=await h8();if(!W){console.log(C.yellow("No project selected."));return}X=T.join(x,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(C.red("Destination cannot be inside the source directory."));return}if(L.existsSync(q)){if(!L.statSync(q).isDirectory()){console.log(C.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(C.yellow("Project move cancelled."));return}}}else L.mkdirSync(q,{recursive:!0});if(console.log(C.blue(`Moving project from ${X} to ${q}...`)),d1(X,q),console.log(C.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(C.green("Original project deleted."));await O6(q)}catch(Q){console.error(C.red(`Error moving express project: ${Q.message}`)),process.exit(1)}}async function u8(){let $=L.readdirSync(x).filter((W)=>/^\d{8}$/.test(W)).sort((W,J)=>J.localeCompare(W));if($.length===0)return null;let Q=$[0],Z=T.join(x,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(x).filter((Z)=>/^\d{8}$/.test(Z)).sort((Z,X)=>X.localeCompare(Z));for(let Z of Q){let X=T.join(x,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 M6.promptForSelection({items:W,message:`Multiple projects match "${$}". Please select one:`,nameField:"message",valueField:"value",allowAbort:!0});if(J===null)return console.log(C.yellow("Operation cancelled.")),null;return J}}return null}async function h8(){let $=[],Q=L.readdirSync(x).filter((X)=>/^\d{8}$/.test(X)).sort((X,q)=>q.localeCompare(X));for(let X of Q){let q=T.join(x,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 M6.promptForSelection({items:$,message:"Select a project:",nameField:"value",valueField:"value",allowAbort:!0});if(Z===null)return console.log(C.yellow("Operation cancelled.")),null;return Z}async function k2($){try{if((await B0({type:"confirm",name:"openIDE",message:"Would you like to open the project in an IDE?",initial:!0})).openIDE)await O6($)}catch(Q){console.error(C.red(`Error opening IDE: ${Q.message}`))}}async function O6($){let Q=await c1("code --version"),Z=await c1("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(C.yellow("No supported IDE found. Please open the project manually.")),console.log(C.blue(`Project path: ${$}`));return}console.log(C.blue(`Opening project in ${X}...`)),console.log(C.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(C.green(`Project opened in ${X}.`)),Y();else console.error(C.red(`Failed to open project in ${X}.`)),W(Error(`Process exited with code ${J}`))})})}async function c1($){return new Promise((Q)=>{x8($,{shell:!0,stdio:"ignore"}).on("close",(X)=>{Q(X===0)})})}function d1($,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;d1(q,Y)}else L.copyFileSync(q,Y)}}async function v2($){try{if(!L.existsSync(x)){console.log(C.yellow("No express projects found."));return}let Q;if($.latest){if(Q=await u8(),!Q){console.log(C.yellow("No express projects found."));return}}else if($.projectName){if(Q=await f8($.projectName),!Q){console.log(C.yellow(`Project "${$.projectName}" not found.`));return}}else{let X=await h8();if(!X){console.log(C.yellow("No project selected."));return}Q=T.join(x,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(C.yellow("Project removal cancelled."));return}}console.log(C.blue(`Removing project "${Z}"...`)),L.rmSync(Q,{recursive:!0,force:!0}),console.log(C.green(`Project "${Z}" removed successfully.`))}catch(Q){console.error(C.red(`Error removing express project: ${Q.message}`)),process.exit(1)}}async function E2($){try{if(!L.existsSync(x)){console.log(C.yellow("No express projects found."));return}let Q;if($.latest){if(Q=await u8(),!Q){console.log(C.yellow("No express projects found."));return}}else if($.projectName){if(Q=await f8($.projectName),!Q){console.log(C.yellow(`Project "${$.projectName}" not found.`));return}}else{let q=await h8();if(!q){console.log(C.yellow("No project selected."));return}Q=T.join(x,q)}console.log(C.blue(`Entering project directory: ${Q}`)),console.log(C.yellow(`
|
|
14
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(C.green(`
|
|
15
|
-
Returned from project directory.`)),q()})})}catch(Q){console.error(C.red(`Error entering express project directory: ${Q.message}`)),process.exit(1)}}import
|
|
15
|
+
Returned from project directory.`)),q()})})}catch(Q){console.error(C.red(`Error entering express project directory: ${Q.message}`)),process.exit(1)}}import i1 from"node:path";import{fileURLToPath as h2}from"node:url";import y2 from"node:fs";import g8 from"node:path";import{fileURLToPath as x2}from"node:url";var u2=g8.dirname(x2(import.meta.url));function f2({baseDir:$}){$=$||u2;let Q=$;while(Q!==g8.parse(Q).root){let Z=g8.join(Q,"node_modules");if(y2.existsSync(Z))return Z;Q=g8.dirname(Q)}return null}var p1=f2;var g2=i1.dirname(h2(import.meta.url));function r1(){let $=p1({baseDir:g2}),Q=process.platform==="win32"?";":":";if($)process.env.PATH=`${i1.join($,"/.bin")}${Q}${process.env.PATH}`}B6();r1();async function c2(){try{let $=m2(process.argv.slice(2)).usage("Usage: $0 <command> [options]").command(j6).command(T6).command(y1).command(x1).command(u1).command(f1).command(g1).command("express","Create and manage express projects",l1);$=p($,{bin:"npm",createContext:w}),$=p($,{bin:"node",createContext:w}),$=p($,{bin:"bun",createContext:w}),$=p($,{name:"serve",bin:"bun",preArgs:["run","serve","--"],createContext:w}),$=p($,{name:"watch",bin:"bun",preArgs:["run","watch","--"],createContext:w}),$=p($,{name:"app",bin:"bun",preArgs:["run","app","--"],createContext:w}),$=p($,{name:"cli",bin:"bun",preArgs:["run","cli","--"],createContext:w}),$=p($,{name:"cli:dev",bin:"bun",preArgs:["run","cli:dev","--"],createContext:w}),$=p($,{name:"cli:compile",bin:"bun",preArgs:["run","cli:compile","--"],createContext:w}),$=p($,{name:"cli:compile:dev",bin:"bun",preArgs:["run","cli:compile:dev","--"],createContext:w}),$=p($,{name:"cli:install",bin:"bun",preArgs:["run","cli:install","--"],createContext:w}),$=p($,{name:"compile",bin:"bun",preArgs:["run","compile","--"],createContext:w}),$=F6($,{name:"install",createContext:w}),$=p($,{bin:"npx",createContext:w}),$=p($,{bin:"cdk",createContext:w}),$=p($,{bin:"aws",createContext:w}),$=C6($,{name:"with",createContext:w}),$=I6($,{name:"run",projectType:"fnet"}),$.demandCommand(1,"You need at least one command before moving on").help().version().argv}catch($){console.error(s1.red(`Fatal error: ${$.message}`)),process.exit(1)}}c2().catch(($)=>{console.error(s1.red(`Fatal error: ${$.message}`)),process.exit(1)});
|