@fnet/cli 1.1.1 → 1.1.3
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 +15 -15
- package/dist/fnode/index.js +1 -1
- package/package.json +1 -1
package/dist/fnet/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as v0,b as M0}from"./index.2084z2ed.js";import{c as D5,d as N9,e as h}from"./index.r19p3bpa.js";var D9=N9((yq,k9)=>{k9.exports=P9;function P9(Q,Z,X){if(Q instanceof RegExp)Q=S9(Q,X);if(Z instanceof RegExp)Z=S9(Z,X);var q=b9(Q,Z,X);return q&&{start:q[0],end:q[1],pre:X.slice(0,q[0]),body:X.slice(q[0]+Q.length,q[1]),post:X.slice(q[1]+Z.length)}}function S9(Q,Z){var X=Z.match(Q);return X?X[0]:null}P9.range=b9;function b9(Q,Z,X){var q,Y,J,H,W,V=X.indexOf(Q),K=X.indexOf(Z,V+1),z=V;if(V>=0&&K>0){if(Q===Z)return[V,K];q=[],J=X.length;while(z>=0&&!W){if(z==V)q.push(z),V=X.indexOf(Q,z+1);else if(q.length==1)W=[q.pop(),K];else{if(Y=q.pop(),Y<J)J=Y,H=K;K=X.indexOf(Z,z+1)}z=V<K&&V>=0?V:K}if(q.length)W=[J,H]}return W}});var g9=N9((Eq,h9)=>{var v9=D9();h9.exports=R5;var y9="\x00SLASH"+Math.random()+"\x00",E9="\x00OPEN"+Math.random()+"\x00",i6="\x00CLOSE"+Math.random()+"\x00",x9="\x00COMMA"+Math.random()+"\x00",u9="\x00PERIOD"+Math.random()+"\x00";function d6(Q){return parseInt(Q,10)==Q?parseInt(Q,10):Q.charCodeAt(0)}function A5(Q){return Q.split("\\\\").join(y9).split("\\{").join(E9).split("\\}").join(i6).split("\\,").join(x9).split("\\.").join(u9)}function B5(Q){return Q.split(y9).join("\\").split(E9).join("{").split(i6).join("}").split(x9).join(",").split(u9).join(".")}function f9(Q){if(!Q)return[""];var Z=[],X=v9("{","}",Q);if(!X)return Q.split(",");var{pre:q,body:Y,post:J}=X,H=q.split(",");H[H.length-1]+="{"+Y+"}";var W=f9(J);if(J.length)H[H.length-1]+=W.shift(),H.push.apply(H,W);return Z.push.apply(Z,H),Z}function R5(Q){if(!Q)return[];if(Q.substr(0,2)==="{}")Q="\\{\\}"+Q.substr(2);return s0(A5(Q),!0).map(B5)}function I5(Q){return"{"+Q+"}"}function C5(Q){return/^-?0\d/.test(Q)}function L5(Q,Z){return Q<=Z}function F5(Q,Z){return Q>=Z}function s0(Q,Z){var X=[],q=v9("{","}",Q);if(!q)return[Q];var Y=q.pre,J=q.post.length?s0(q.post,!1):[""];if(/\$$/.test(q.pre))for(var H=0;H<J.length;H++){var W=Y+"{"+q.body+"}"+J[H];X.push(W)}else{var V=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(q.body),K=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(q.body),z=V||K,G=q.body.indexOf(",")>=0;if(!z&&!G){if(q.post.match(/,.*\}/))return Q=q.pre+"{"+q.body+i6+q.post,s0(Q);return[Q]}var _;if(z)_=q.body.split(/\.\./);else if(_=f9(q.body),_.length===1){if(_=s0(_[0],!1).map(I5),_.length===1)return J.map(function(k7){return q.pre+_[0]+k7})}var O;if(z){var $=d6(_[0]),A=d6(_[1]),U=Math.max(_[0].length,_[1].length),B=_.length==3?Math.abs(d6(_[2])):1,M=L5,R=A<$;if(R)B*=-1,M=F5;var F=_.some(C5);O=[];for(var S=$;M(S,A);S+=B){var y;if(K){if(y=String.fromCharCode(S),y==="\\")y=""}else if(y=String(S),F){var v=U-y.length;if(v>0){var Y0=Array(v+1).join("0");if(S<0)y="-"+Y0+y.slice(1);else y=Y0+y}}O.push(y)}}else{O=[];for(var J0=0;J0<_.length;J0++)O.push.apply(O,s0(_[J0],!1))}for(var J0=0;J0<O.length;J0++)for(var H=0;H<J.length;H++){var W=Y+O[J0]+J[H];if(!Z||z||W)X.push(W)}}return X}});import N2 from"yargs";import AZ from"chalk";import{promisify as NZ}from"node:util";import PZ from"tree-kill";var u7=NZ(PZ),D0=!1;async function e8(Q,Z){if(D0)return;if(D0=!0,!Q.killed&&Q.pid)try{if(await u7(Q.pid,"SIGTERM").catch(()=>{}),await new Promise((q)=>setTimeout(q,500)),!Q.killed)await u7(Q.pid,"SIGKILL").catch(()=>{})}catch(q){}await new Promise((q)=>setTimeout(q,100));let X=Z==="SIGINT"?130:Z==="SIGTERM"?143:1;process.exit(X)}function Q6(Q){["SIGINT","SIGTERM","SIGQUIT"].forEach((Z)=>{process.once(Z,async()=>{await e8(Q,Z)})}),process.on("uncaughtException",async(Z)=>{await e8(Q)}),process.on("unhandledRejection",async(Z)=>{await e8(Q)}),Q.on("close",(Z)=>{if(!D0)process.exit(Z)})}function f7(){process.on("uncaughtException",(Q)=>{if(!D0)D0=!0,setTimeout(()=>process.exit(1),500)}),process.on("unhandledRejection",(Q)=>{if(!D0)D0=!0,setTimeout(()=>process.exit(1),500)})}import r0 from"node:path";import{spawn as h7}from"node:child_process";import A8 from"node:fs";import n0 from"chalk";import bZ from"@fnet/config";function s(Q,{name:Z,bin:X,preArgs:q=[],createContext:Y}){if(typeof X==="function")X=X();return Q.command(`${Z||X} [commands..]`,`${X} ${q.join(" ")}`,(J)=>{return J.help(!1).version(!1)},async(J)=>{try{let H=await Y(J),{projectDir:W}=H,V=(O)=>{if(!O.includes(" "))return O;if(process.platform==="win32")return`"${O.replace(/(["^])/g,"^$1")}"`;else return`"${O.replace(/(["\\$`])/g,"\\$1")}"`},K=process.argv.slice(3).map(V),z={...process.env},G=r0.join(W,"node_modules");z.NODE_PATH=G,z.NODE_PRESERVE_SYMLINKS=1;let _=h7(X,[...q,...K],{cwd:W,stdio:"inherit",shell:!0,detached:!0,env:z});Q6(_)}catch(H){console.error(H.message),process.exit(1)}})}function g7(Q,{name:Z,preArgs:X=[],createContext:q}){return Q.command(`${Z} <config> <command> [options..]`,"Run a command with a config context",(Y)=>{return Y.positional("config",{type:"string"}).positional("command",{type:"string"}).help(!1).version(!1)},async(Y)=>{try{let J=await q(Y),{projectDir:H}=J,W=Y.config,K=(await bZ({name:W,dir:H,transferEnv:!1,optional:!0,tags:J.tags}))?.data?.env||void 0,z=Y.command,G=process.argv.slice(5),_=h7(z,[...X,...G],{cwd:A8.existsSync(H)?H:process.cwd(),stdio:"inherit",shell:!0,detached:!0,env:{...process.env,...K}});Q6(_)}catch(J){console.error(J.message),process.exit(1)}})}function m7(Q,{name:Z,projectType:X="auto"}){return Q.command(`${Z} group [options..]`,"Run a command group.",(q)=>{return q.positional("group",{type:"string"}).option("ftag",{type:"array"}).help(!1).version(!1)},async(q)=>{try{let{runCommandGroup:Y}=await import("./index.0jcm9pn5.js");await Y({projectType:X,group:q.group,tags:q.ftag,args:q,argv:process.argv})}catch(Y){console.error(Y.message),process.exit(1)}})}function c7(Q,{name:Z,createContext:X}){return Q.command(`${Z} [options]`,"Install the project as a binary",(q)=>{return q.option("name",{alias:"n",describe:"Name to use for the installed binary",type:"string"}).option("force",{alias:"f",describe:"Force overwrite if binary already exists",type:"boolean",default:!1}).option("yes",{alias:"y",describe:"Automatically answer yes to all prompts",type:"boolean",default:!1})},async(q)=>{try{let Y=await X(q),{projectDir:J}=Y;console.log(n0.blue("Compiling project..."));let H=r0.join(J,".bin");if(!A8.existsSync(H))A8.mkdirSync(H,{recursive:!0});let W=r0.basename(r0.dirname(J)),V=Y.project?.projectFileParsed?.features?.cli?.bin,K=q.name||V||W;console.log(n0.blue(`Using binary name: ${K}`));let z=r0.join(H,K),{spawn:G}=await import("child_process"),_=G("bun",["build","./dist/cli/esm/index.js","--compile",`--outfile=${z}`],{cwd:J,stdio:"inherit",shell:!0});if(await new Promise((A,U)=>{_.on("close",(B)=>{if(B===0)A();else U(Error(`Compilation failed with code ${B}`))}),_.on("error",(B)=>{U(B)})}),process.platform!=="win32")A8.chmodSync(z,493);console.log(n0.green(`Binary compiled successfully: ${z}`)),console.log(n0.blue("Installing binary..."));let O=["install",z];if(q.name)O.push("--name",q.name);if(q.force)O.push("--force");if(q.yes)O.push("--yes");let $=G("fbin",O,{stdio:"inherit",shell:!0});await new Promise((A,U)=>{$.on("close",(B)=>{if(B===0)A();else U(Error(`Installation failed with code ${B}`))}),$.on("error",(B)=>{U(B)})})}catch(Y){console.error(n0.red(`Failed to install binary: ${Y.message}`)),process.exit(1)}})}import o from"node:path";import $0 from"node:fs";import B8 from"@fnet/yaml";import kZ from"yaml";async function D(Q){try{let Z=await DZ({tags:Q.ftag,flowsPath:Q.flows});return{buildId:Q.buildId,mode:Q.mode,protocol:Q.protocol||"src:",templateDir:v0("./template/fnet/node"),coreDir:v0("./template/fnet/core"),projectDir:o.resolve(Z.projectDir,"./.workspace"),projectSrcDir:o.resolve(Z.projectDir,"./src"),projectSrcDirSymlink:o.resolve(Z.projectDir,"./.workspace/src-core"),projectAppDir:o.resolve(Z.projectDir,"./app"),projectAppDirSymlink:o.resolve(Z.projectDir,"./.workspace/app"),projectCliDir:o.resolve(Z.projectDir,"./cli"),projectCliDirSymlink:o.resolve(Z.projectDir,"./.workspace/cli"),project:Z,tags:Q.ftag,dev:Q.dev}}catch(Z){return console.warn(`Warning: Could not load project: ${Z.message}`),{projectDir:process.cwd(),tags:Q.ftag}}}async function DZ({tags:Q,flowsPath:Z}){let X=vZ(process.cwd());if(!$0.existsSync(X))throw Error("fnet.yaml file not found in current directory.");let{raw:q,parsed:Y}=await B8({file:X,tags:Q}),J=o.dirname(X);Y.features=Y.features||{};let H=Y.features;H.runtime=H.runtime||{},H.runtime.type=H.runtime.type||"node";let W;if(Z){let _=o.resolve(J,Z);if(!$0.existsSync(_))throw Error(`Flows file not found: ${_}`);let{parsed:O}=await B8({file:_,tags:Q});W=O}else if(typeof Y.flows==="object")W=Y.flows;else{let _="flow.main.yaml";if($0.existsSync(o.join(J,"fnet","flows.yaml")))_=o.join("fnet","flows.yaml");let O=Y.main||_,$=o.resolve(J,O);if(!$0.existsSync($))W={main:{steps:[]}};else{let{parsed:A}=await B8({file:$,tags:Q});W=A}}let K={workflowAtom:{doc:{...Y,content:W}},projectDir:J,projectFilePath:X,projectFileContent:q,projectFileParsed:Y,runtime:H.runtime},z=o.resolve(J,"fnet/targets.yaml");if($0.existsSync(z)){let{raw:_,parsed:O}=await B8({file:z,tags:Q}),$=kZ.parseDocument(_);K.devops={filePath:z,fileContent:_,yamlDocument:$,doc:{...O},type:"workflow.deploy",save:async()=>{$0.writeFileSync(K.devops.filePath,$.toString())}}}let G=o.resolve(J,"readme.md");if($0.existsSync(G)){let _=$0.readFileSync(G,"utf8");K.readme={filePath:G,fileContent:_,doc:{content:_,"content-type":"markdown"},type:"wiki"}}return K}function vZ(Q){let Z=o.resolve(Q,"fnet.yaml");if($0.existsSync(Z))return Z;let X=o.resolve(Q,"fnet.yml");if($0.existsSync(X))return X;return Z}import yZ from"node:path";import l7 from"node:fs";import EZ from"node:os";import xZ from"@flownet/lib-render-templates-dir";import Z6 from"@fnet/shelljs";var uZ={command:"create",describe:"Initialize a new fnet project",builder:(Q)=>{return Q.option("name",{type:"string",describe:"Project name"}).option("vscode",{type:"boolean",default:!0,alias:"vs",describe:"Open in VS Code after creation"}).option("runtime",{type:"string",default:"node",choices:["node"],describe:"Runtime environment"})},handler:async(Q)=>{try{let Z=process.cwd(),X=v0("./template/fnet/project"),q=yZ.resolve(Z,Q.name);if(!l7.existsSync(q))l7.mkdirSync(q);await xZ({dir:X,outDir:q,context:Q,copyUnmatchedAlso:!0,platform:EZ.platform()});let Y=await Z6("fnet build",{cwd:q});if(Y.code!==0)throw Error("Failed to build project.");if(M0("git")){if(Y=await Z6("git init --initial-branch=main",{cwd:q}),Y.code!==0)throw Error("Failed to initialize git.")}if(M0("code")&&Q.vscode){if(Y=await Z6(`cd ${q} && code .`),Y.code!==0)throw Error("Failed to open vscode.")}console.log("Creating project succeeded!"),process.exit(0)}catch(Z){console.error("Initialization failed!",Z.message),process.exit(1)}}},d7=uZ;import fZ from"node:os";import hZ from"@flownet/lib-render-templates-dir";import gZ from"@fnet/shelljs";var mZ={command:"project",describe:"Manage fnet project",builder:(Q)=>{return Q.option("update",{type:"boolean",default:!1,alias:"-u",describe:"Update project files"})},handler:async(Q)=>{try{let Z=v0("./template/fnet/project"),X=process.cwd(),q=await D(Q);if(Q.update){if(await hZ({dir:Z,outDir:X,context:{name:q.project.projectFileParsed.name,runtime:"node"},copyUnmatchedAlso:!0,platform:fZ.platform()}),(await gZ("fnet build",{cwd:X})).code!==0)throw Error("Failed to build project.");console.log("Updating project succeeded!")}process.exit(0)}catch(Z){console.error("Project failed.",Z.message),process.exit(1)}}},i7=mZ;import T from"node:fs";import k from"node:path";import eQ from"yaml";import QZ from"@fnet/shelljs";import M8 from"nunjucks";import ZZ from"lodash.clonedeep";import Q2 from"isobject";import{randomUUID as XZ}from"node:crypto";import X6 from"winston";var{combine:p7,timestamp:a7,printf:cZ,colorize:lZ}=X6.format,n7=cZ(({level:Q,message:Z,timestamp:X,category:q,depth:Y,...J})=>{let H=" ".repeat(Y||0),W=q?`[${q}]`:"",V=`${X} ${Q} ${W} ${H}${Z}`;if(Object.keys(J).length>0)V+=`
|
|
3
|
-
${H} ${JSON.stringify(J,null,2)}`;return V}),R8=X6.createLogger({level:process.env.FNET_LOG_LEVEL||"info",format:p7(a7({format:"HH:mm:ss.SSS"}),n7),transports:[new X6.transports.Console({format:p7(lZ(),a7({format:"HH:mm:ss.SSS"}),n7)})]}),s7=(Q)=>{return{debug:(Z,X={})=>R8.debug(Z,{category:Q,...X}),info:(Z,X={})=>R8.info(Z,{category:Q,...X}),warn:(Z,X={})=>R8.warn(Z,{category:Q,...X}),error:(Z,X={})=>R8.error(Z,{category:Q,...X})}},f=s7("tree"),x=s7("bpmn"),r7=process.env.FNET_LOG_CATEGORIES?.split(",")||[],j=(Q)=>{if(r7.length===0)return!1;return r7.includes(Q)};import{Api as I8}from"@flownet/lib-atom-api-js";class o7{init({config:Q,accessToken:Z}){return new Promise((X,q)=>{if(I8.set_api_url(Q.data.url),Z){I8.set_req_token(Z),X(Z);return}fetch(`${Q.data.issuer}/protocol/openid-connect/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(Q.data.grant.params)}).then(async(Y)=>{if(!Y.ok)throw Error(await Y.text());return Y.json()}).then((Y)=>{I8.set_req_token(Y.access_token),X(Y.access_token)}).catch((Y)=>{I8.set_req_token(),q(Y)})})}}import f0 from"lodash.merge";import C8 from"node:fs";import _0 from"node:path";import h0 from"@flownet/lib-parse-imports-js";import dZ from"lodash.merge";function E({feature:Q,features:Z,packageDevDependencies:X}){let{name:q,packages:Y,options:J,extraCheck:H,explicit:W}=Q,V=`${q}_enabled`,K=Z.rollup_output||{},z=Object.keys(K),G=J||{},_=Z[q]?.options;if(_)G=dZ(G,_);let O=!Z[q]||Z[q]?.enabled===!1;z.forEach((A)=>{let U=Z.rollup_output[A];if(!U)return;if(Reflect.has(U,q)){if(O||!U[q]||U[q]?.enabled===!1){delete U[q];return}if(U[q]===!0)U[q]={enabled:!0,options:G}}else if(!O&&!W&&Z[V]!==!1)U[q]={enabled:!0};else return;U[q]=U[q]||{},U[q].options={...G,...U[q].options}});let $=z.some((A)=>Z.rollup_output[A][q]?.enabled===!0);if(H)$=H()&&$;if(Z[V]=$,$)Y.forEach((A)=>X.push({package:A[0],version:A[1]}))}function q6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"workbox",packages:[["rollup-plugin-workbox","^8"]],options:{generate:{swDest:"dist/app/esm/sw.js",globDirectory:"dist/app/esm",globPatterns:["**/*.{html,js,css,png,jpg}"],skipWaiting:!0,clientsClaim:!0}},explicit:!0},features:q,packageDevDependencies:X})}function Y6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"gzip",packages:[["rollup-plugin-gzip","^4"]],explicit:!0},features:q,packageDevDependencies:X})}function J6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"nunjucks",packages:[["@fnet/rollup-plugin-nunjucks","0.1.8"]]},features:q,packageDevDependencies:X})}function W6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"polyfill",packages:[["rollup-plugin-node-polyfills","^0.2"]]},features:q,packageDevDependencies:X})}function H6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"visualizer",packages:[["rollup-plugin-visualizer","^5"]],expilicit:!0},features:q,packageDevDependencies:X})}function V6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"analyzer",packages:[["rollup-plugin-analyzer","^3"]],options:{summaryOnly:!0,limit:12},explicit:!0},features:q,packageDevDependencies:X})}function K6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"string",packages:[["rollup-plugin-string","^3"]]},features:q,packageDevDependencies:X})}function _6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"image",packages:[["@rollup/plugin-image","^3"]]},features:q,packageDevDependencies:X})}function z6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;if(q.runtime.type==="bun")return;E({feature:{name:"json",packages:[["@rollup/plugin-json","^6"]]},features:q,packageDevDependencies:X})}function G6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"terser",packages:[["@rollup/plugin-terser","^0.4"]]},features:q,packageDevDependencies:X})}function U6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"wasm",packages:[["@rollup/plugin-wasm","^6"]]},features:q,packageDevDependencies:X})}function $6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;if(q.runtime.type==="bun")return;let Y={};if(q.app?.enabled===!0){if(Y.targets=Y.targets||[],Y.targets.push({src:"./src/app/index.html",dest:q.app.dir}),!Reflect.has(q.app,"copy")){if(!Reflect.has(q,"copy"))q.copy=!0}}E({feature:{name:"copy",packages:[["rollup-plugin-copy","^3"],["chokidar","^3"]],options:Y},features:q,packageDevDependencies:X})}function M6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features,Y=q.css&&q.css.enabled!==!1,J=[];if(Y)J.push(["rollup-plugin-postcss","^4"]),J.push(["sass","^1.66"]),(q.css?.options?.plugins||[]).forEach((W)=>{switch(W.name){case"postcss-import":J.push(["postcss-import","^15"]);break;case"postcss-url":J.push(["postcss-url","^10"]);break;case"postcss-preset-env":J.push(["postcss-preset-env","^9"]);break;case"autoprefixer":J.push(["autoprefixer","^10"]);break;case"cssnano":J.push(["cssnano","^6"]);break}});E({feature:{name:"css",packages:J},features:q,packageDevDependencies:X})}function O6({dir:Q,name:Z="index"}){let X=_0.resolve(Q,`./${Z}.tsx`);if(!C8.existsSync(X))X=_0.resolve(Q,`./${Z}.ts`);if(!C8.existsSync(X))X=_0.resolve(Q,`./${Z}.jsx`);if(!C8.existsSync(X))X=_0.resolve(Q,`./${Z}.js`);if(!C8.existsSync(X))return{};let q=X,Y=_0.extname(X);return{file:q,ext:Y,ts:Y===".ts"||Y===".tsx",name:Z}}async function A6(Q){let{atom:Z,context:X,setProgress:q}=Q;q("Initializing features..."),Z.doc.features=Z.doc.features||{};let Y=Z.doc.features;Y.project=Y.project||{},Y.project.format=Y.project.format||Y.project_format||"esm",Y.project_format=Y.project.format,Y.dts_enabled=Y.dts===!0||typeof Y.dts<"u"&&Y.dts!==!1;let J=_0.resolve(X.project.projectDir),H=O6({dir:_0.resolve(J,"./app")});if(H.file){q("Parsing app entry imports...");let A=await h0({file:H.file,recursive:!0}),U=A.all.some((B)=>B.usesJSX===!0&&B.type==="local");Y.app_uses_jsx=U,Y.app_has_entry=!0,A=await h0({file:H.file}),U=A.all.some((B)=>B.usesJSX===!0&&B.type==="local"),Y.app_entry_uses_jsx=U,Y.app_entry_is_ts=H.ts,Y.app_entry_ext=H.ext}let W=O6({dir:_0.resolve(J,"./cli")});if(W.file){q("Parsing cli entry imports...");let A=await h0({file:W.file,recursive:!0}),U=A.all.some((B)=>B.usesJSX===!0&&B.type==="local");Y.cli_uses_jsx=U,Y.cli_has_entry=!0,A=await h0({file:W.file}),U=A.all.some((B)=>B.usesJSX===!0&&B.type==="local"),Y.cli_entry_uses_jsx=U,Y.cli_entry_is_ts=W.ts,Y.cli_entry_ext=W.ext}if(Z.type==="workflow.lib"){let A=O6({dir:_0.resolve(J,"./src")});if(A.file){q("Parsing src entry imports...");let U=await h0({file:A.file,recursive:!0}),B=U.all.some((M)=>M.usesJSX===!0&&M.type==="local");Y.src_uses_jsx=B,Y.src_has_entry=!0,U=await h0({file:A.file}),B=U.all.some((M)=>M.usesJSX===!0&&M.type==="local"),Y.src_entry_uses_jsx=B,Y.src_entry_is_ts=A.ts,Y.src_entry_ext=A.ext}}let V=Reflect.has(Y,"app_entry_uses_jsx")?Y.app_entry_uses_jsx===!0:Y.src_entry_uses_jsx===!0,K=Reflect.has(Y,"cli_entry_uses_jsx")?Y.cli_entry_uses_jsx===!0:Y.src_entry_uses_jsx===!0;if(Y.form_enabled=V||K||Y.form===!0||Y.form?.enabled===!0,Y.multiple_enabled=Y.multiple_enabled||Y.multiple===!0||Y.multiple?.enabled===!0,Y.app===!1)Y.app={enabled:!1};else if(Y.app===!0)Y.app={enabled:!0,extend:Y.app_has_entry===!0,export:!0,react:V};else Y.app={enabled:!0,extend:Y.app_has_entry===!0,export:!0,react:V,...Y.app||{}};if(Y.app.enabled=Y.app.enabled===!0&&(Z.doc.features.form_enabled===!0||Y.app.extend===!0||Y.app.enabled===!0),Y.app.format=Y.app.format||"esm",Y.app.folder=Y.app.folder||Y.app.format||"default",Y.cli===!1)Y.cli={enabled:!1};else if(Y.cli===!0)Y.cli={enabled:!0,extend:Y.cli_has_entry===!0,export:!0,react:K};else Y.cli={enabled:!0,extend:Y.cli_has_entry===!0,export:!0,react:K,...Y.cli||{}};if(Y.cli.enabled=Y.cli.enabled===!0&&(Z.doc.features.form_enabled===!1||Y.cli.extend===!0||Y.cli.enabled===!0),Y.cli.format=Y.cli.format||"esm",Y.cli.folder=Y.cli.folder||Y.cli.folder||"esm",Y.cli.node_options=Y.cli.node?.options||Y.cli.node_options||"",Y.cli.bin=Y.cli.bin||Z.doc.name,Y.cli.installable=Y.cli.installable===!0,Y.cli.enabled)Z.doc["npm::bin"]=Y.cli.bin;Y.json=Y.cli.enabled||Y.json;let z={cjs:{format:"cjs",context:Y.form_enabled?"window":"global",babel:Y.src_uses_jsx===!0||!1,browser:!1,replace:!0,terser:!0,enabled:Y.cjs!==!1,copy:!1},esm:{format:"esm",context:Y.form_enabled?"window":"global",babel:Y.src_uses_jsx===!0||!1,browser:!1,replace:!0,terser:!1,enabled:Y.esm!==!1,copy:!0},iife:{format:"iife",context:Y.form_enabled?"window":"global",babel:!0,browser:!0,replace:!0,enabled:Y.iife===!0,terser:!0,copy:!1}},G={targets:{browsers:"last 9 versions, not dead",node:"18"}},_={};if(Y.webos===!0)z.webos={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,input:"./src/app/index.js",output_dir:"./dist/app/webos",copy:!1,babel_options:{targets:{chrome:"79"}}};if(Y.electron===!0)z.electron={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/electron"};if(Y.nextjs===!0)z.nextjs={format:"esm",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/nextjs"};if(Y.ios===!0)z.ios={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/ios"};if(Y.macos===!0)z.macos={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/macos"};if(Y.app.enabled===!0)Y.app.dir=`./dist/app/${Y.app.folder}`,Y.app.output={file:`./dist/app/${Y.app.folder}/index.js`,dir:`./dist/app/${Y.app.folder}/`,...Y.app.output||{}},Y.app.input={file:"./src/app/index.js",dir:"./src/app/",...Y.app.input||{}},z.app={format:Y.app.format,browser:!0,babel:!0,context:"window",replace:!0,input:Y.app.input.file,output_dir:Y.app.dir,terser:!0,output_exports:Y.app.export===!1?"none":"auto",browsersync:!0};if(Y.cli.enabled===!0)Y.cli.dir=`./dist/cli/${Y.cli.folder}`,Y.cli.output={file:`./dist/cli/${Y.cli.folder}/index.js`,dir:`./dist/cli/${Y.cli.folder}/`,...Y.cli.output||{}},Y.cli.input={file:"./src/cli/index.js",dir:"./src/cli/",...Y.cli.input||{}},z.cli={format:Y.cli.format,context:"global",babel:Y.src_uses_jsx===!0||Y.cli_uses_jsx===!0||!1,browser:!1,replace:!0,enabled:!0,input:Y.cli.input.file,output_dir:Y.cli.dir,banner:"#!/usr/bin/env bun",terser:!0,output_exports:Y.cli.export===!1?"none":"auto"};let O={server:".",startPath:`${_0.normalize(Y.app.dir||".")}`,files:[_0.normalize("./dist/**/*")],cors:!0,open:!1};if(Y.babel_options=f0(G,Y.babel_options||Y.babel?.options),Y.browsersync_options=f0(O,Y.browsersync_options||Y.browsersync?.options||{}),Y.replace_options=f0(_,Y.replace_options||Y.replace?.options||{}),Reflect.has(Y.browsersync_options,"proxy"))delete Y.browsersync_options.server;Y.rollup=Y.rollup||{},Y.rollup_output=f0(z,Y.rollup_output||Y.rollup?.output||{}),Y.preact_enabled=Y.preact===!0||Y.preact&&Y.preact?.enabled!==!1;let $=Object.keys(z);for(let A of $){let U=z[A];if(!U)continue;if(Y.rollup[A]===!1){delete Y.rollup_output[A];continue}if(U.babel_options=U.babel_options||Y.babel_options,U.browsersync_options=f0(Y.browsersync_options,U.browsersync_options),U.replace_options=f0(Y.replace_options,U.replace_options),Y.preact_enabled)U.alias_enabled=!0,U.alias=U.alias||{},U.alias.entries=U.alias.entries||{},U.alias.entries.react="preact/compat",U.alias.entries["react-dom"]="preact/compat";if(Y.form_enabled||Y.babel)U.babel=!0}$=Object.keys(Y.rollup_output),Y.babel_enabled=$.some((A)=>Y.rollup_output[A].babel===!0),Y.browser_enabled=$.some((A)=>Y.rollup_output[A].babel===!0),Y.browsersync_enabled=Y.browsersync!==!1&&$.some((A)=>Y.rollup_output[A].browsersync===!0),Y.browsersync_enabled=Y.browsersync_enabled&&Y.app.enabled,Y.dependency_auto_enabled=Y.dependency_auto!==!1&&Y.dependency_auto?.enabled!==!1,Y.npm_install_flags=Y.npm_install_flags||"",Y.react_version=Y.react_version||Y.react?.version||18,Y.bpmn=Y.bpmn||{},Y.bpmn.enabled=Y.bpmn.enabled!==!1,Y.bpmn.per_flow=Y.bpmn.per_flow===!0,M6(Q),$6(Q),U6(Q),G6(Q),z6(Q),K6(Q),_6(Q),V6(Q),H6(Q),W6(Q),J6(Q),q6(Q),Y6(Q)}import iZ from"@fnet/npm-list-versions";async function B6({atom:Q,packageDependencies:Z,packageDevDependencies:X,setProgress:q}){q("Initializing dependencies");let Y=Q.doc.dependencies||[];if(Y.filter((J)=>!J.dev).forEach((J)=>Z.push(J)),Y.filter((J)=>J.dev).forEach((J)=>X.push(J)),Q.type==="workflow")Z.push({package:"dot-prop",version:"^10"});if(Q.doc.features.form_enabled){if(Q.doc.features.dependency_auto_enabled){let J="^18.2";if(q("Fetching React versions"),J=`^${(await iZ({name:"react",groupBy:{major:!0}})).find((V)=>V[0]===Q.doc.features.react_version.toString())[0]}`,Z.push({package:"react",version:J}),Z.push({package:"react-dom",version:J}),Q.type==="workflow")Z.push({package:"@fnet/react-app",version:"^0.1"}),Z.push({package:"@fnet/react-app-state",version:"^0.1"})}}if(Q.doc.features.preact_enabled)Z.push({package:"preact",version:"^10"});if(Q.doc.features.cli.enabled===!0){if(Z.push({package:"@fnet/args",version:"^0.1"}),Q.doc.features.cli.fargs&&Q.doc.features.cli.fargs?.enabled!==!1)Z.push({package:"@fnet/config",version:"0.2.21"});if(Q.doc.features.cli.mcp&&Q.doc.features.cli.mcp.enabled===!0)Z.push({package:"@modelcontextprotocol/sdk",version:"^1.10"}),Z.push({package:"express",version:"^4.18"})}if(Q.doc.features.render&&Q.doc.features.render.enabled!==!1)X.push({package:"@flownet/lib-render-templates-dir",version:"0.1.19"});if(X.push({package:"@babel/core",version:"^7"}),X.push({package:"@rollup/plugin-commonjs",version:"^28"}),X.push({package:"@rollup/plugin-node-resolve",version:"^16"}),X.push({package:"@rollup/plugin-replace",version:"^6"}),X.push({package:"rollup",version:"^4"}),Q.doc.features.dts_enabled)X.push({package:"rollup-plugin-dts",version:"^6"});if(X.push({package:"rollup-plugin-peer-deps-external",version:"^2"}),X.push({package:"@rollup/plugin-alias",version:"^5"}),X.push({package:"fs-extra",version:"^11"}),Q.doc.features.babel_enabled)X.push({package:"@rollup/plugin-babel",version:"^6"}),X.push({package:"@babel/preset-env",version:"^7"}),X.push({package:"@babel/preset-react",version:"^7"}),Q.doc.features.babel?.options?.plugins?.forEach((J)=>{switch(J[0]){case"@babel/plugin-proposal-decorators":X.push({package:"@babel/plugin-proposal-decorators",version:"^7"});break;case"@babel/plugin-proposal-class-properties":X.push({package:"@babel/plugin-proposal-class-properties",version:"^7"});break;case"@babel/plugin-proposal-private-methods":X.push({package:"@babel/plugin-proposal-private-methods",version:"^7"});break;case"@babel/plugin-proposal-private-property-in-object":X.push({package:"@babel/plugin-proposal-private-property-in-object",version:"^7"});break;case"@babel/plugin-proposal-optional-chaining":X.push({package:"@babel/plugin-proposal-optional-chaining",version:"^7"});break}});if(X.push({package:"@fnet/rollup-plugin-delete",version:"0.1.10"}),Q.doc.features.browsersync_enabled)X.push({package:"@fnet/rollup-plugin-browsersync",version:"0.1.11"})}import pZ from"@fnet/npm-list-versions";async function R6({atom:Q,packageDependencies:Z,packageDevDependencies:X,setProgress:q}){q("Initializing dependencies for Bun");let Y=Q.doc.dependencies||[];if(Y.filter((J)=>!J.dev).forEach((J)=>Z.push(J)),Y.filter((J)=>J.dev).forEach((J)=>X.push(J)),Q.type==="workflow")Z.push({package:"dot-prop",version:"^10"});if(Q.doc.features.form_enabled){if(Q.doc.features.dependency_auto_enabled){let J="^18.2";if(q("Fetching React versions"),J=`^${(await pZ({name:"react",groupBy:{major:!0}})).find((V)=>V[0]===Q.doc.features.react_version.toString())[0]}`,Z.push({package:"react",version:J}),Z.push({package:"react-dom",version:J}),Q.type==="workflow")Z.push({package:"@fnet/react-app",version:"^0.1"}),Z.push({package:"@fnet/react-app-state",version:"^0.1"})}}if(Q.doc.features.preact_enabled)Z.push({package:"preact",version:"^10"});if(Q.doc.features.cli.enabled===!0){if(Z.push({package:"@fnet/args",version:"^0.1"}),Q.doc.features.cli.fargs&&Q.doc.features.cli.fargs?.enabled!==!1)Z.push({package:"@fnet/config",version:"0.2.21"});if(Q.doc.features.cli.mcp&&Q.doc.features.cli.mcp.enabled===!0)Z.push({package:"@modelcontextprotocol/sdk",version:"^1.10"}),Z.push({package:"express",version:"^4.18"})}if(Q.doc.features.render&&Q.doc.features.render.enabled!==!1)X.push({package:"@flownet/lib-render-templates-dir",version:"0.1.19"})}import t7 from"node:fs";import e7 from"node:path";import aZ from"@flownet/lib-render-templates-dir";async function I6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){if(Q.doc.features.app.enabled!==!0)return;await Z({message:"Creating app folder"});let Y={atom:Q,packageDependencies:q,ts:Date.now()},J=X.templateDir,H=e7.resolve(X.projectDir,"src/app");if(!t7.existsSync(H))t7.mkdirSync(H,{recursive:!0});let W=["index.js.njk"];if(Q.doc.features.app.html!==!1)W.push("index.html.njk");await aZ({pattern:W,dir:e7.resolve(J,"src/app"),outDir:H,context:Y})}import Z9 from"nunjucks";import I0 from"node:fs";import w0 from"node:path";import sZ from"@flownet/lib-parse-imports-js";import nZ from"@fnet/npm-pick-versions";import rZ from"object-hash";import L8 from"node:fs";import Q9 from"node:path";async function T0({projectDir:Q,name:Z,setProgress:X,count:q=1}){let Y,H=rZ(["npm-pick-versions",Z,q]),W=Q9.join(Q,".cache"),V=Q9.join(W,H+".json");if(L8.existsSync(V)){if(X)X(`Picking npm version of ${Z} from cache ...`);Y=JSON.parse(L8.readFileSync(V,"utf8"))}else{if(X)X(`Picking npm version of ${Z} ...`);Y=await nZ({name:Z,count:q}),L8.mkdirSync(W,{recursive:!0}),L8.writeFileSync(V,JSON.stringify(Y),"utf8")}return Y}async function C6({atom:Q,context:Z,packageDependencies:X,packageDevDependencies:q,setProgress:Y}){await Y({message:"Creating package.json."}),X.filter((U)=>U.dev===!0).forEach((U)=>{if(!q.find((M)=>M.package===U.package))q.push(U);let B=X.findIndex((M)=>M.package===U.package);X.splice(B,1)});let H=X.find((U)=>U.package==="react"),W=X.find((U)=>U.package==="react-dom");if(H&&!W)X.push({package:"react-dom",version:H.version});else if(H&&W)W.version=H.version;if(H&&Q.doc.features.react_version>=17){if(!X.find((U)=>U.package==="@emotion/react"))X.push({package:"@emotion/react",version:"^11"});if(!X.find((U)=>U.package==="@emotion/styled"))X.push({package:"@emotion/styled",version:"^11"})}let V=[];if(Q.doc.features.app.enabled===!0)V.push({file:w0.resolve(Z.projectDir,"src/app/index.js"),dev:Q.doc.features.app.dev===!0});if(Q.doc.features.cli.enabled===!0)V.push({file:w0.resolve(Z.projectDir,"src/cli/index.js"),dev:Q.doc.features.cli.dev===!0});for await(let U of V){let B=U.file;if(!I0.existsSync(B))throw Error(`App file not found: ${B}`);let R=(await sZ({file:B,recursive:!0,verbose:!1})).all;for await(let F of R){if(F.type!=="npm")continue;if(X.find((v)=>v.package===F.package))continue;if(q.find((v)=>v.package===F.package))continue;let S=await T0({name:F.package,projectDir:Z.projectDir,setProgress:Y});(U.dev===!0?q:X).push({package:F.package,subpath:F.subpath,version:S.minorRange,type:"npm"})}}for await(let U of X){if(U.version!==void 0)continue;let B=await T0({name:U.package,projectDir:Z.projectDir,setProgress:Y});U.version=B.minorRange}for await(let U of q){if(U.version!==void 0)continue;let B=await T0({name:U.package,projectDir:Z.projectDir,setProgress:Y});U.version=B.minorRange}let K={atom:Q,packageDependencies:X,packageDevDependencies:q},z=Z.templateDir,_=Z9.compile(I0.readFileSync(w0.resolve(z,"package.json.njk"),"utf8"),Z9.configure(z)).render(K),O=Z.projectDir,$=w0.resolve(O,"package.json");I0.writeFileSync($,_,"utf8");let A=w0.resolve(Z.project.projectDir,"fnet");if(I0.existsSync(A)){let U=w0.resolve(Z.projectDir,"fnet");if(!I0.existsSync(U))I0.mkdirSync(U);let B=I0.readdirSync(A);for(let M of B){let R=w0.resolve(A,M);if(!I0.lstatSync(R).isFile())continue;let F=w0.resolve(U,M);I0.copyFileSync(R,F)}}}import X9 from"node:fs";import q9 from"node:path";import oZ from"@flownet/lib-render-templates-dir";async function L6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){if(Q.doc.features.cli.enabled!==!0)return;await Z({message:"Creating cli."});let Y={atom:Q,packageDependencies:q},J=X.templateDir,H=q9.resolve(X.projectDir,"src/cli");if(!X9.existsSync(H))X9.mkdirSync(H,{recursive:!0});await oZ({pattern:["index.js.njk"],dir:q9.resolve(J,"src/cli"),outDir:H,context:Y})}import F6 from"node:fs";import j6 from"node:path";import Y9 from"nunjucks";import tZ from"@flownet/lib-parse-imports-js";async function T6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){await Z({message:"Creating rollup file."});let Y={atom:Q,packageDependencies:q},J=j6.resolve(X.projectDir,"src","default/index.js");if(!F6.existsSync(J))throw Error(`Entry file not found: ${J}`);let W=(await tZ({file:J,recursive:!0})).all.filter((A)=>A.type==="node").map((A)=>A.path),V=Q.doc.features.rollup_output,K=Object.keys(V);for(let A=0;A<K.length;A++){let U=K[A],B=V[U];if(B.browser===!0){if(W.length>0){B.globals_enabled=!0,B.globals=B.globals||[],B.globals=B.globals.concat(W.map((M)=>{return{key:M,value:M}})),B.alias_enabled=!0,B.alias=B.alias||{},B.alias.entries=B.alias.entries||{};for(let M=0;M<W.length;M++){let R=W[M];B.alias.entries[R]=`node:${R}`,B.alias.entries[`node:${R}`]=R}B.external_enabled=!0,B.external=B.external||[],B.external=B.external.concat(W)}}}let z=X.templateDir,_=Y9.compile(F6.readFileSync(j6.resolve(z,"rollup.config.mjs.njk"),"utf8"),Y9.configure(z)).render(Y),O=X.projectDir,$=j6.resolve(O,"rollup.config.mjs");F6.writeFileSync($,_,"utf8")}import w6 from"node:fs";import J9 from"node:path";import W9 from"nunjucks";async function S6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){await Z({message:"Creating build.js file."});let Y={atom:Q,packageDependencies:q},J=X.templateDir,W=W9.compile(w6.readFileSync(J9.resolve(J,"build.js.njk"),"utf8"),W9.configure(J)).render(Y),V=X.projectDir,K=J9.resolve(V,"build.js");w6.writeFileSync(K,W,"utf8"),w6.chmodSync(K,"755")}import N6 from"node:fs";import P6 from"node:path";import eZ from"nunjucks";import Q5 from"ajv/dist/2020.js";import Z5 from"ajv/dist/standalone/index.js";import X5 from"ajv-formats";async function b6({atom:Q,setProgress:Z,context:X,njEnv:q}){if(Q.doc.features.cli.enabled!==!0)return;await Z({message:"Creating input args."});let Y={},J=[];if(Q.doc.input)Y=Q.doc.input;else Y={type:"object",properties:{},required:[]};if(Q.doc.features.cli.fargs&&Q.doc.features.cli.fargs?.enabled!==!1){let B=Q.doc.features.cli.fargs,M={type:"string",description:"Config name to load args",hidden:!1},R={type:"array",description:"Tags to filter the config",hidden:!1};if(Reflect.has(B,"default"))M.default=B.default}let W={imports:J,atom:Q},V=X.templateDir,z=eZ.compile(N6.readFileSync(P6.resolve(V,"src/default/input.args.js.njk"),"utf8"),q).render(W),G=X.projectDir,_=P6.resolve(G,"src/default/input.args.js");N6.writeFileSync(_,z,"utf8");let O=new Q5({allErrors:!0,useDefaults:!0,formats:{},strict:!1,code:{esm:!0,lines:!0,optimize:!1,source:!0}});X5(O);let $=O.compile(Y),U=Z5(O,$)+`
|
|
4
|
-
export { schema31 as schema };`;N6.writeFileSync(P6.resolve(G,"src/default/validate_input.js"),U,"utf8")}import H9 from"node:fs";import V9 from"node:path";import K9 from"nunjucks";async function k6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){await Z({message:"Creating .gitignore"});let Y={atom:Q,packageDependencies:q},J=X.templateDir,W=K9.compile(H9.readFileSync(V9.resolve(J,".gitignore.njk"),"utf8"),K9.configure(J)).render(Y),V=X.projectDir,K=V9.resolve(V,".gitignore");H9.writeFileSync(K,W,"utf8")}import _9 from"node:fs";import z9 from"node:path";import G9 from"nunjucks";async function D6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){await Z({message:"Creating tsconfig.json."});let Y={atom:Q,packageDependencies:q},J=X.templateDir,W=G9.compile(_9.readFileSync(z9.resolve(J,"tsconfig.json.njk"),"utf8"),G9.configure(J)).render(Y),V=X.projectDir,K=z9.resolve(V,"tsconfig.json");_9.writeFileSync(K,W,"utf8")}import F8 from"nunjucks";import S0 from"node:fs";import y0 from"node:path";import U9 from"@fnet/yaml";async function v6({atom:Q,context:Z,setProgress:X,Atom:q}){if(await X({message:"Creating readme.md"}),Z.project?.readme){let H=Z.projectDir,W={content:Z.project.readme.doc.content},V=y0.resolve(Z.project.projectDir,"fnet/how-to.md");if(S0.existsSync(V)){let A=S0.readFileSync(V,"utf8");W.howto=A}let K=y0.resolve(Z.project.projectDir,"fnet/input.yaml");if(S0.existsSync(K)){let A=await U9({file:K,tags:Z.tags});W.input=A.content}let z=y0.resolve(Z.project.projectDir,"fnet/output.yaml");if(S0.existsSync(z)){let A=await U9({file:z,tags:Z.tags});W.output=A.content}let G=Z.templateDir,O=F8.compile(S0.readFileSync(y0.resolve(G,"readme.md.njk"),"utf8"),F8.configure(G)).render(W),$=y0.resolve(H,"readme.md");S0.writeFileSync($,O,"utf8")}else if(Q.id){let H=await q.first({type:"wiki",parent_id:Q.id});if(!H||H.doc?.["content-type"]!=="markdown")return;let{content:W,...V}=H.doc,K={content:W},z=Z.templateDir,_=F8.compile(S0.readFileSync(y0.resolve(z,"readme.md.njk"),"utf8"),F8.configure(z)).render(K),O=Z.projectDir,$=y0.resolve(O,"readme.md");S0.writeFileSync($,_,"utf8")}}import q5 from"node:path";import $9 from"@fnet/shelljs";async function y6({setProgress:Q,context:Z}){let X=Z.projectDir;await Q({message:"Prettifiying source files."});let q=q5.join("src","**","*");if(M0("bun")){let Y=await $9(`prettier --write ${q} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:X});if(Y.code!==0)throw Error(Y.stderr)}else{let Y=await $9(`prettier --write ${q} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:X});if(Y.code!==0)throw Error(Y.stderr)}}import Y5 from"@fnet/shelljs";async function E6({atom:Q,setProgress:Z,context:X}){if(!Q.doc.features.dts_enabled)return;let q=X.projectDir;if(await Z({message:"Creating .d.ts"}),(await Y5("tsc",{cwd:q})).code!==0)throw Error("Couldnt create .d.ts files.")}import M9 from"@fnet/shelljs";async function x6({setProgress:Q,atom:Z,context:X}){let q=X.projectDir;if(await Q({message:"Installing npm packages."}),M0("bun")){if((await M9(`bun install ${Z.doc.features.npm_install_flags}`,{cwd:q})).code!==0)throw Error("Couldnt install npm packages.")}else if((await M9(`npm install ${Z.doc.features.npm_install_flags}`,{cwd:q})).code!==0)throw Error("Couldnt install npm packages.")}import O9 from"node:fs";import J5 from"node:path";import{spawn as W5}from"node:child_process";async function A9(Q){let{projectDir:Z,scriptName:X,args:q=[],env:Y=process.env,shell:J=!0,detached:H=!0,onSpawn:W}=Q;if(!Z||!X)throw Error("projectDir and scriptName are required");let V=J5.resolve(Z,"package.json");if(!O9.existsSync(V))throw Error(`package.json not found at ${V}`);let K=JSON.parse(O9.readFileSync(V,"utf8")),z=K.scripts?.[X];if(!z){let O=Object.keys(K.scripts||{}).join(", ");throw Error(`Script '${X}' not found. Available: ${O}`)}let G=q.length>0?`${z} ${q.join(" ")}`:z,_=W5(G,[],{cwd:Z,stdio:"inherit",shell:J,detached:H,env:{...Y}});if(W)W(_);return new Promise((O,$)=>{_.on("error",(A)=>{$(Error(`Failed to start '${X}': ${A.message}`))}),_.on("close",(A)=>{O({subprocess:_,exitCode:A})})})}import H5 from"node:path";async function u6({setProgress:Q,context:Z}){let X=Z.projectDir;await Q({message:"Building main project."});let q=Z.dev?"build:dev":"build",Y={...process.env},J=H5.join(X,"node_modules");Y.NODE_PATH=J,Y.NODE_PRESERVE_SYMLINKS=1,await A9({projectDir:X,scriptName:q,shell:!0,detached:!0,env:Y})}var B9=async(Q)=>{let{atom:Z,packageDependencies:X,context:q,deploymentProjectTarget:Y,setProgress:J,deploymentProject:H,yamlTarget:W}=Q;if(Y.enabled!==!0)return;let V=Y.type;try{if(V==="lib")await(await import("./index.p0zb7e1b.js")).default({...Q});else if(V==="red")await(await import("./index.490y87nc.js")).default({...Q});else if(V==="npm")await(await import("./index.gh75wt1m.js")).default({...Q});else if(V==="gcs")await(await import("./index.hzsfswvp.js")).default({...Q});else if(V==="gitlab")await(await import("./index.jgpc3grc.js")).default({...Q});else if(V==="fnet-package")await(await import("./index.r82rtnmz.js")).default({...Q});else if(V==="fnet-form")await(await import("./index.3exge2js.js")).default({...Q});else if(V==="fnet-node")await(await import("./index.4jkat7r4.js")).default({...Q});else if(V==="fnet-flow")await(await import("./index.s662t98v.js")).default({...Q});else if(V==="nextjs")await(await import("./index.7vw06nrn.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="webos")await(await import("./index.zm4kesg6.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="electron")await(await import("./index.9567fa9x.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="docker")await(await import("./index.w74dpnpn.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="ios")await(await import("./index.7crx8ky1.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="macos")await(await import("./index.xeaw5xa9.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="rust")await(await import("./index.3kfx538h.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="pypi")await(await import("./index.33f1ggpr.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else{console.warn(`No deployer found for type: ${V}`);return}}catch(K){throw console.error(`Error during deployment for type "${V}":`,K),K}};import{Atom as R0}from"@flownet/lib-atom-api-js";import Z2 from"@flownet/lib-parse-node-url";import I9 from"bpmn-moddle";import R9 from"dagre";import g6 from"lodash.clonedeep";var f6={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 C9(Q){let{nodes:Z,nodeIndex:X,root:q}=Q,Y=[],J=new Set,H=(W)=>{if(J.has(W.indexKey))return;if(J.add(W.indexKey),W.hasReturn&&W.type!=="return"){let V=`${W.indexKey}/_inline_end`;if(X[V])return;let K={name:"",type:"return",virtual:!0,parent:W.parent,childs:[],definition:{return:W.definition.return},index:W.parent.childs.length,indexKey:V,pathKey:`${W.pathKey}._inline_end`,codeKey:`${W.codeKey}_inline_end`,context:{next:null},hasReturn:!0,_inlineParent:W};if(Y.push(K),j("bpmn"))x.info(`[INLINE-RETURN] EndEvent: ${K.indexKey} (parent: ${W.indexKey})`)}W.childs.forEach((V)=>H(V))};Z.forEach((W)=>H(W)),Y.forEach((W)=>{W.parent.childs.push(W),X[W.indexKey]=W,Z.push(W)}),Z.forEach((W)=>{let V=[],K=[],z=($)=>{let A=Y.find((U)=>U._inlineParent===$);if(A)V.push({from:$,to:A,type:"bpmn:SequenceFlow"});else if($.context.next){if(V.push({from:$,to:$.context.next,type:"bpmn:SequenceFlow"}),$===W)K.push({to:$.context.next,type:"bpmn:SequenceFlow",next:!0})}$.childs.forEach((U)=>{if($===W){if(W.type==="switch"){if(!(U.indexKey&&U.indexKey.endsWith("/_inline_end")))K.push({to:U,type:"bpmn:SequenceFlow"})}}z(U)})};z(W);let G=V.filter(($)=>$.to.parent.indexKey===W.parent.indexKey).map(($)=>{return{...$,from:W.indexKey,to:$.to.indexKey}}),_=V.filter(($)=>$.to.parent.indexKey!==W.parent.indexKey&&!$.to.indexKey.startsWith(W.indexKey+"/")).map(($)=>{return{...$,from:W.indexKey,to:$.to.indexKey}}),O=K.map(($)=>{return{...$,to:$.to.indexKey}});if(W.bpmn=W.bpmn||{},W.bpmn.edges=h6(G,"to"),W.bpmn.outside=h6(_,"to"),W.bpmn.starts=h6(O,"to"),W.bpmn.type=K5(W),W.bpmn.width=120,W.bpmn.height=80,W.type==="return")W.bpmn.width=36,W.bpmn.height=36;if(W.bpmn.type==="bpmn:CallActivity")W.bpmn.fill="#E1F5FE",W.bpmn.stroke="#0277BD"})}function K5(Q){let Z;if(Q.type==="call"){if(Q.context?.lib?.type==="subworkflow"||Q.context?.lib?.type==="workflow"){if(Z="bpmn:CallActivity",j("bpmn"))x.info(`[CALL] CallActivity (subworkflow): ${Q.indexKey} (${Q.context?.lib?.name||"unknown"})`)}else if(Z="bpmn:ServiceTask",j("bpmn"))x.info(`[CALL] ServiceTask (external): ${Q.indexKey} (${Q.context?.lib?.name||"unknown"})`)}else if(Q.type==="form"){if(Z="bpmn:UserTask",j("bpmn"))x.info(`[FORM] UserTask: ${Q.indexKey}`)}else if(Q.type==="return"){if(Z="bpmn:EndEvent",j("bpmn"))x.info(`[RETURN] EndEvent: ${Q.indexKey}`)}else if(Q.type==="raise"){let X=!1;if(Q.name==="try"&&Q.parent?.type==="tryexcept")X=!0;else{let q=Q.parent;while(q){if(q.name==="try"&&q.parent?.type==="tryexcept"){X=!0;break}q=q.parent}}if(X){if(Z="bpmn:IntermediateThrowEvent",j("bpmn"))x.info(`[RAISE] IntermediateThrowEvent (inside try): ${Q.indexKey}`)}else if(Z="bpmn:EndEvent",j("bpmn"))x.info(`[RAISE] EndEvent (error): ${Q.indexKey}`)}else if(Q.type==="pipeline"){if(Z="bpmn:ServiceTask",j("bpmn"))x.info(`[PIPELINE] ServiceTask (external binary): ${Q.indexKey} (${Q.context?.binaryName||"unknown"})`)}else if(Q.type==="http"){if(Z="bpmn:ServiceTask",j("bpmn"))x.info(`[HTTP] ServiceTask (external API): ${Q.indexKey} (${Q.context?.http?.method||"GET"} ${Q.context?.http?.url||"unknown"})`)}else if(Q.type==="assign"||Q.type==="new"){if(Z="bpmn:ScriptTask",j("bpmn"))x.info(`[${Q.type.toUpperCase()}] ScriptTask: ${Q.indexKey}`)}else if(Z="bpmn:Task",j("bpmn"))x.info(`[${Q.type.toUpperCase()}] Task: ${Q.indexKey}`);return Z}function h6(Q,Z){return Q.filter((X,q,Y)=>{return Y.map((J)=>J[Z]).indexOf(X[Z])===q})}function m6(Q){let{nodes:Z,nodeIndex:X,root:q}=Q,Y=Q.targetNodes||q.childs;Y.forEach((J)=>{let H=J.type==="workflow"||J.type==="subworkflow",W=!H&&J.childs.filter((G)=>!G.virtual).length>0,V=(J.name==="try"||J.name==="except")&&J.parent?.type==="tryexcept",K=J.type==="schedule",z=J.type==="retry";if(W||V||K||z){if(J.bpmn.type="bpmn:SubProcess",J.type==="for"){if(J.bpmn.loopCharacteristics=!0,j("bpmn"))x.info(`[FOR] SubProcess + Loop Marker: ${J.indexKey}`)}if(J.name==="try"&&J.type==="raise"&&J.parent?.type==="tryexcept"){let G=t({location:0,...Q,parent:J,bpmnType:"bpmn:IntermediateThrowEvent",type:"raise",attrs:{},definitions:[{type:"bpmn:ErrorEventDefinition"}]});if(j("bpmn"))x.info(`[VIRTUAL] IntermediateThrowEvent for single-step try block: ${J.indexKey}`)}}if(H||W){let G=J.childs.filter((M)=>M.module!==!0&&!M.indexKey.endsWith("/_inline_end"))[0];J.childs.filter((M)=>M.module===!0).forEach((M)=>{let R=t({...Q,parent:J,bpmnType:"bpmn:IntermediateCatchEvent",type:"inter",definitions:[{type:"bpmn:SignalEventDefinition"}]});R.bpmn.edges=[{from:R.indexKey,to:M.indexKey,type:"bpmn:SequenceFlow"}]});let O=J.childs.find((M)=>M.name==="try"&&J.type==="tryexcept"),$=J.childs.filter((M)=>M.name==="except"&&J.type==="tryexcept");if(O&&$.length)$.forEach((M)=>{let R=t({location:J.childs.indexOf(M),...Q,parent:J,bpmnType:"bpmn:BoundaryEvent",type:"boundary",attrs:{attachedToRef:O},definitions:[{type:"bpmn:ErrorEventDefinition"}]});if(R.bpmn.edges=[{from:R.indexKey,to:M.indexKey,type:"bpmn:SequenceFlow"}],j("bpmn"))x.info(`[TRY-EXCEPT] BoundaryEvent: ${J.indexKey} (try: ${O.indexKey}, except: ${M.indexKey})`)});let A=J.childs.find((M)=>M.type==="raise");if(A){let M=t({...Q,parent:J,bpmnType:"bpmn:EndEvent",type:"end",name:"ERROR",definitions:[{type:"bpmn:ErrorEventDefinition"}]});A.bpmn.edges=[{from:A.indexKey,to:M.indexKey,type:"bpmn:SequenceFlow"}]}if(J.type==="schedule"){let M=J.childs[0];if(M){let R=t({...Q,parent:J,bpmnType:"bpmn:StartEvent",type:"timer-start",definitions:[{type:"bpmn:TimerEventDefinition",timerType:"timeCycle",expression:J.context?.cron||"* * * * *"}]});if(R.bpmn.edges=[{from:R.indexKey,to:M.indexKey,type:"bpmn:SequenceFlow"}],j("bpmn"))x.info(`[SCHEDULE] SubProcess + TimerStartEvent: ${J.indexKey} (cron: ${J.context?.cron})`)}}if(G)if(J.type==="schedule"){if(j("bpmn"))x.info(`[SCHEDULE] Skipping normal StartEvent (using TimerStartEvent): ${J.indexKey}`)}else if(J.type==="retry"){let M=t({...Q,parent:J,bpmnType:"bpmn:StartEvent",type:"start"});if(M.bpmn.edges.push({from:M.indexKey,to:G.indexKey,type:"bpmn:SequenceFlow"}),j("bpmn"))x.info(`[RETRY] SubProcess with loop characteristics: ${J.indexKey} (attempts: ${J.context?.attempts})`)}else if(J.type==="parallel"){let M=t({...Q,parent:J,bpmnType:"bpmn:StartEvent",type:"start"}),R=t({...Q,parent:J,bpmnType:"bpmn:ParallelGateway",type:"fork"}),F=t({...Q,parent:J,bpmnType:"bpmn:ParallelGateway",type:"join"}),S=t({...Q,parent:J,bpmnType:"bpmn:EndEvent",type:"end"});M.bpmn.edges=[{from:M.indexKey,to:R.indexKey,type:"bpmn:SequenceFlow"}];let y=J.childs.filter((v)=>!v.virtual&&!v.module&&!v.indexKey.endsWith("/_inline_end"));if(R.bpmn.edges=y.map((v)=>{return{from:R.indexKey,to:v.indexKey,type:"bpmn:SequenceFlow"}}),y.forEach((v)=>{v.bpmn.edges=[{from:v.indexKey,to:F.indexKey,type:"bpmn:SequenceFlow"}]}),F.bpmn.edges=[{from:F.indexKey,to:S.indexKey,type:"bpmn:SequenceFlow"}],j("bpmn"))x.info(`[PARALLEL] Fork/Join Gateways: ${J.indexKey} (${y.length} children)`)}else if(J.bpmn.starts.length>1){let M=t({...Q,parent:J,bpmnType:"bpmn:StartEvent",type:"start"}),R=t({...Q,parent:J,bpmnType:"bpmn:ExclusiveGateway",type:"switch"});M.bpmn.edges=[{from:M.indexKey,to:R.indexKey,type:"bpmn:SequenceFlow"}],R.bpmn.edges=J.bpmn.starts.map((S)=>{return{...S,from:R.indexKey}});let F=R.bpmn.edges.find((S)=>S.next===!0);if(F){let S=t({...Q,parent:J,bpmnType:"bpmn:EndEvent",type:"end",name:F.to});F.to=S.indexKey}}else{let M=t({...Q,parent:J,bpmnType:"bpmn:StartEvent",type:"start"});M.bpmn.edges.push({from:M.indexKey,to:G.indexKey,type:"bpmn:SequenceFlow"})}else if(j("bpmn"))x.info(`[START-EVENT] skipped (no valid firstNode): ${J.indexKey}`);J.childs.filter((M)=>M.virtual!==!0&&M.bpmn.outside.length&&M.bpmn.type!=="bpmn:EndEvent").forEach((M)=>{M.bpmn.outside.forEach((R)=>{let F=Y.indexOf(J),S=t({...Q,parent:J,bpmnType:"bpmn:EndEvent",type:"end",name:R.to,location:F+1});M.bpmn.edges.push({from:M.indexKey,to:S.indexKey,type:"bpmn:SequenceFlow"})})}),J.childs.filter((M)=>M.virtual!==!0&&M.bpmn.edges.length>1).forEach((M)=>{let R=Y.indexOf(M),F=t({...Q,parent:J,bpmnType:"bpmn:ExclusiveGateway",type:"switch",location:R+1});F.bpmn.edges=M.bpmn.edges.map((S)=>{return{...S,from:F.indexKey}}),M.bpmn.edges=[{from:M.indexKey,to:F.indexKey,type:"bpmn:SequenceFlow"}],M.bpmn.outside=[]})}m6({...Q,targetNodes:J.childs})})}function t(Q){let{parent:Z,nodes:X,nodeIndex:q,bpmnType:Y,type:J,name:H,outside:W,location:V,definitions:K,attrs:z}=Q,G=Z.childs.filter((O)=>O.type===`v${J}`).length;if(j("bpmn"))x.info(`[VIRTUAL] ${J.toUpperCase()} → ${Y}: ${Z.indexKey}/_${J}${G}`);let _={indexKey:`${Z.indexKey}/_${J}${G}`,pathKey:`${Z.pathKey}._${J}${G}`,type:`v${J}`,name:H,bpmn:{edges:[],outside:[],type:Y,width:36,height:36,fill:"#c8e6c9",stroke:"#205022",definitions:K,attrs:z},virtual:!0,childs:[]};return Z.childs.splice(V||0,0,_),X.push(_),q[_.indexKey]=_,_}function c6(Q){let{targetNode:Z,targetFlowElementsContainer:X,targetPlaneElement:q,moddle:Y,elementIndex:J,nodeIndex:H,diagrams:W,nodes:V}=Q;_5(Q),z5(Q),G5(Q),U5(Q)}function _5(Q){let{targetNode:Z,targetFlowElementsContainer:X,targetPlaneElement:q,moddle:Y,elementIndex:J,nodeIndex:H,nodes:W}=Q,V=X.get("flowElements");if(X.$nodes=X.$nodes||[],j("bpmn"))x.info(`[BPMN] Creating elements for: ${Z.indexKey} (${Z.childs.length} children)`);Z.childs.forEach((K)=>{let z=Y.create(K.bpmn.type,{id:`node.${K.pathKey}`,name:K.definition?.title||K.name});if(J[z.id]=z,z.$isNode=!0,z.$node=K,K.$flow=z,X.$nodes.push(z),V.push(z),K.bpmn.type==="bpmn:CallActivity"&&K.context?.lib){if(z.calledElement=K.context.lib.name,j("bpmn"))x.info(`[CREATED] ${K.bpmn.type} (chip!): ${z.id} → ${z.calledElement}`)}else if(j("bpmn"))x.info(`[CREATED] ${K.bpmn.type}: ${z.id}${K.virtual?" (virtual)":""}`);if(K.bpmn.attrs)Object.keys(K.bpmn.attrs).forEach((_)=>{if(_==="attachedToRef")z.set(_,K.bpmn.attrs[_].$flow)});if(K.bpmn.definitions){let G=K.bpmn.definitions.map((_)=>{let O=Y.create(_.type);return Object.keys(_.attrs||{}).forEach((A)=>{O.set(A,_.attrs[A])}),O});z.eventDefinitions=G}if(K.bpmn.loopCharacteristics&&K.bpmn.type==="bpmn:SubProcess"){if(z.loopCharacteristics=Y.create("bpmn:StandardLoopCharacteristics"),j("bpmn"))x.info(`[LOOP] Added loop marker to: ${z.id} (${K.type})`)}})}function z5(Q){let{targetNode:Z,targetFlowElementsContainer:X,targetPlaneElement:q,moddle:Y,elementIndex:J,nodeIndex:H}=Q,W=X.get("flowElements");X.$edges=X.$edges||[],Z.childs.forEach((V)=>{V.bpmn.edges.forEach((z)=>{let G=V,_=H[z.to],O=`edge.${G.pathKey}_${_.pathKey}`;if(J[O])return;let $=J[`node.${G.pathKey}`],A=J[`node.${_.pathKey}`],U=Y.create(z.type,{id:O,sourceRef:$,targetRef:A});J[U.id]=U,U.$is_edge=!0,$.get("outgoing").push(U),A.get("incoming").push(U),X.$edges.push({from:$,to:A,flow:U}),W.push(U)})})}function G5(Q){let{targetNode:Z,targetFlowElementsContainer:X,targetPlaneElement:q,moddle:Y,elementIndex:J,nodeIndex:H}=Q,W=120,V=80,K=160,z=160,G=new R9.graphlib.Graph;G.setDefaultEdgeLabel(()=>({})),G.setGraph({rankdir:"TB",nodesep:120,ranksep:80,xranker:"longest-path"}),X.$nodes.forEach((_)=>{G.setNode(_.id,{width:_.$node?.bpmn.width||120,height:_.$node?.bpmn.height||80,label:_.id})}),X.$edges.forEach((_)=>{G.setEdge(_.from.id,_.to.id)}),R9.layout(G),X.$nodes.forEach((_)=>{let O=G.node(_.id),$=O.width,A=O.height,U=Y.create("bpmndi:BPMNShape",{id:`shape.${_.id}`,bpmnElement:_,bounds:Y.create("dc:Bounds",{x:160+O.x-O.width/2,y:160+O.y-O.height/2,width:$,height:A}),label:Y.create("bpmndi:BPMNLabel")});if(_.$node.bpmn.fill)U.set("bioc:fill",_.$node.bpmn.fill);if(_.$node.bpmn.stroke)U.set("bioc:stroke",_.$node.bpmn.stroke);q.get("planeElement").push(U)}),X.$edges.forEach((_)=>{let O=G.edge(_.from.id,_.to.id),$=Y.create("bpmndi:BPMNEdge",{id:`edge.${_.from.id}_${_.to.id}`,bpmnElement:_.flow,label:Y.create("bpmndi:BPMNLabel")});O.points.forEach((U)=>{let B=Y.create("dc:Point",{x:160+U.x,y:160+U.y});$.get("waypoint").push(B)}),q.get("planeElement").push($)})}function U5(Q){let{targetNode:Z,targetFlowElementsContainer:X,targetPlaneElement:q,moddle:Y,elementIndex:J,nodeIndex:H,diagrams:W}=Q;Z.childs.filter((K)=>K.bpmn.type==="bpmn:SubProcess").forEach((K)=>{let z=J[`node.${K.pathKey}`],G=Y.create("bpmndi:BPMNDiagram",{id:`diagram_${K.pathKey}`});J[G.id]=G,W.push(G);let _=Y.create("bpmndi:BPMNPlane",{id:`plane_${K.pathKey}`});J[_.id]=_,G.plane=_,_.bpmnElement=z,c6({...Q,targetNode:K,targetFlowElementsContainer:z,targetPlaneElement:_})})}async function $5(Q){let Z=Q.root,X=Z.context.index,q=Object.keys(X).map((K)=>X[K]);C9({nodes:q,nodeIndex:X,root:Z}),m6({nodes:q,nodeIndex:X,root:Z});let Y=void 0,J=new I9({atom:f6}),H={},W=J.create("bpmn:Definitions",{id:"definitions_0"});H[W.id]=W;for await(let K of Z.childs){let z=W.get("rootElements"),G=W.get("diagrams"),_=J.create("bpmn:Process",{id:`process_${K.pathKey}`,name:K.name,documentation:[J.create("bpmn:Documentation",{text:`Workflow - ${K.name}`})]});H[_.id]=_,_.isExecutable=!0,z.push(_);let O=J.create("bpmndi:BPMNDiagram",{id:`diagram_${K.pathKey}`});H[O.id]=O,G.push(O);let $=J.create("bpmndi:BPMNPlane",{id:`plane_${K.pathKey}`});H[$.id]=$,O.plane=$,$.bpmnElement=_,c6({targetNode:K,targetFlowElementsContainer:_,targetPlaneElement:$,moddle:J,elementIndex:H,nodeIndex:X,nodes:q,diagrams:G})}let V=await J.toXML(W,{format:!0});return{diagramXML:Y||V.xml}}async function M5(Q){let{root:Z,flowName:X}=Q,q=g6(Z),Y=q.childs.find((F)=>F.name===X);if(!Y)throw Error(`Flow "${X}" not found`);let J={...q,childs:[Y]},H=J.context.index,W=Object.keys(H).map((F)=>H[F]);C9({nodes:W,nodeIndex:H,root:J}),m6({nodes:W,nodeIndex:H,root:J});let V=new I9({atom:f6}),K={},z=V.create("bpmn:Definitions",{id:`definitions_${X}`});K[z.id]=z;let G=z.get("rootElements"),_=z.get("diagrams"),O=V.create("bpmn:Process",{id:`process_${Y.pathKey}`,name:Y.name,documentation:[V.create("bpmn:Documentation",{text:`Workflow - ${Y.name}`})]});K[O.id]=O,O.isExecutable=!0,G.push(O);let $=V.create("bpmndi:BPMNDiagram",{id:`diagram_${Y.pathKey}`});K[$.id]=$,_.push($);let A=V.create("bpmndi:BPMNPlane",{id:`plane_${Y.pathKey}`});return K[A.id]=A,$.plane=A,A.bpmnElement=O,c6({targetNode:Y,targetFlowElementsContainer:O,targetPlaneElement:A,moddle:V,elementIndex:K,nodeIndex:H,nodes:W,diagrams:_}),{diagramXML:(await V.toXML(z,{format:!0})).xml,flowName:Y.name}}async function j8(Q={}){return await $5(g6(Q))}async function L9(Q={}){let Z=g6(Q),{root:X}=Z,q=[];for(let Y of X.childs){let J=await M5({root:X,flowName:Y.name});q.push(J)}return q}import X2 from"@fnet/config";import q2 from"@flownet/lib-parse-imports-js";class T8 extends SyntaxError{constructor(Q,Z,X,q){super(Q);this.expected=Z,this.found=X,this.location=q,this.name="SyntaxError"}format(Q){let Z="Error: "+this.message;if(this.location){let X=null,q=Q.find((W)=>W.source===this.location.source);if(q)X=q.text.split(/\r\n|\n|\r/g);let Y=this.location.start,J=this.location.source&&typeof this.location.source.offset==="function"?this.location.source.offset(Y):Y,H=this.location.source+":"+J.line+":"+J.column;if(X){let W=this.location.end,V="".padEnd(J.line.toString().length," "),K=X[Y.line-1],G=(Y.line===W.line?W.column:K.length+1)-Y.column||1;Z+=`
|
|
2
|
+
import{a as D0,b as M0}from"./index.2084z2ed.js";import{c as b5,d as S9,e as h}from"./index.r19p3bpa.js";var b9=S9((Pq,P9)=>{P9.exports=w9;function w9(Q,Z,X){if(Q instanceof RegExp)Q=T9(Q,X);if(Z instanceof RegExp)Z=T9(Z,X);var q=N9(Q,Z,X);return q&&{start:q[0],end:q[1],pre:X.slice(0,q[0]),body:X.slice(q[0]+Q.length,q[1]),post:X.slice(q[1]+Z.length)}}function T9(Q,Z){var X=Z.match(Q);return X?X[0]:null}w9.range=N9;function N9(Q,Z,X){var q,Y,J,H,W,V=X.indexOf(Q),K=X.indexOf(Z,V+1),G=V;if(V>=0&&K>0){if(Q===Z)return[V,K];q=[],J=X.length;while(G>=0&&!W){if(G==V)q.push(G),V=X.indexOf(Q,G+1);else if(q.length==1)W=[q.pop(),K];else{if(Y=q.pop(),Y<J)J=Y,H=K;K=X.indexOf(Z,G+1)}G=V<K&&V>=0?V:K}if(q.length)W=[J,H]}return W}});var f9=S9((bq,u9)=>{var k9=b9();u9.exports=A5;var D9="\x00SLASH"+Math.random()+"\x00",v9="\x00OPEN"+Math.random()+"\x00",d6="\x00CLOSE"+Math.random()+"\x00",y9="\x00COMMA"+Math.random()+"\x00",E9="\x00PERIOD"+Math.random()+"\x00";function l6(Q){return parseInt(Q,10)==Q?parseInt(Q,10):Q.charCodeAt(0)}function M5(Q){return Q.split("\\\\").join(D9).split("\\{").join(v9).split("\\}").join(d6).split("\\,").join(y9).split("\\.").join(E9)}function O5(Q){return Q.split(D9).join("\\").split(v9).join("{").split(d6).join("}").split(y9).join(",").split(E9).join(".")}function x9(Q){if(!Q)return[""];var Z=[],X=k9("{","}",Q);if(!X)return Q.split(",");var{pre:q,body:Y,post:J}=X,H=q.split(",");H[H.length-1]+="{"+Y+"}";var W=x9(J);if(J.length)H[H.length-1]+=W.shift(),H.push.apply(H,W);return Z.push.apply(Z,H),Z}function A5(Q){if(!Q)return[];if(Q.substr(0,2)==="{}")Q="\\{\\}"+Q.substr(2);return s0(M5(Q),!0).map(O5)}function B5(Q){return"{"+Q+"}"}function R5(Q){return/^-?0\d/.test(Q)}function I5(Q,Z){return Q<=Z}function C5(Q,Z){return Q>=Z}function s0(Q,Z){var X=[],q=k9("{","}",Q);if(!q)return[Q];var Y=q.pre,J=q.post.length?s0(q.post,!1):[""];if(/\$$/.test(q.pre))for(var H=0;H<J.length;H++){var W=Y+"{"+q.body+"}"+J[H];X.push(W)}else{var V=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(q.body),K=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(q.body),G=V||K,_=q.body.indexOf(",")>=0;if(!G&&!_){if(q.post.match(/,.*\}/))return Q=q.pre+"{"+q.body+d6+q.post,s0(Q);return[Q]}var z;if(G)z=q.body.split(/\.\./);else if(z=x9(q.body),z.length===1){if(z=s0(z[0],!1).map(B5),z.length===1)return J.map(function(b7){return q.pre+z[0]+b7})}var O;if(G){var $=l6(z[0]),A=l6(z[1]),U=Math.max(z[0].length,z[1].length),B=z.length==3?Math.abs(l6(z[2])):1,M=I5,R=A<$;if(R)B*=-1,M=C5;var F=z.some(R5);O=[];for(var w=$;M(w,A);w+=B){var y;if(K){if(y=String.fromCharCode(w),y==="\\")y=""}else if(y=String(w),F){var v=U-y.length;if(v>0){var Y0=Array(v+1).join("0");if(w<0)y="-"+Y0+y.slice(1);else y=Y0+y}}O.push(y)}}else{O=[];for(var J0=0;J0<z.length;J0++)O.push.apply(O,s0(z[J0],!1))}for(var J0=0;J0<O.length;J0++)for(var H=0;H<J.length;H++){var W=Y+O[J0]+J[H];if(!Z||G||W)X.push(W)}}return X}});import S2 from"yargs";import MZ from"chalk";import{promisify as SZ}from"node:util";import wZ from"tree-kill";var x7=SZ(wZ),k0=!1;async function t8(Q,Z){if(k0)return;if(k0=!0,!Q.killed&&Q.pid)try{if(await x7(Q.pid,"SIGTERM").catch(()=>{}),await new Promise((q)=>setTimeout(q,500)),!Q.killed)await x7(Q.pid,"SIGKILL").catch(()=>{})}catch(q){}await new Promise((q)=>setTimeout(q,100));let X=Z==="SIGINT"?130:Z==="SIGTERM"?143:1;process.exit(X)}function e8(Q){["SIGINT","SIGTERM","SIGQUIT"].forEach((Z)=>{process.once(Z,async()=>{await t8(Q,Z)})}),process.on("uncaughtException",async(Z)=>{await t8(Q)}),process.on("unhandledRejection",async(Z)=>{await t8(Q)}),Q.on("close",(Z)=>{if(!k0)process.exit(Z)})}function u7(){process.on("uncaughtException",(Q)=>{if(!k0)k0=!0,setTimeout(()=>process.exit(1),500)}),process.on("unhandledRejection",(Q)=>{if(!k0)k0=!0,setTimeout(()=>process.exit(1),500)})}import r0 from"node:path";import{spawn as f7}from"node:child_process";import A8 from"node:fs";import n0 from"chalk";import NZ from"@fnet/config";function s(Q,{name:Z,bin:X,preArgs:q=[],createContext:Y}){if(typeof X==="function")X=X();return Q.command(`${Z||X} [commands..]`,`${X} ${q.join(" ")}`,(J)=>{return J.help(!1).version(!1)},async(J)=>{try{let H=await Y(J),{projectDir:W}=H,V=(O)=>{if(!O.includes(" "))return O;if(process.platform==="win32")return`"${O.replace(/(["^])/g,"^$1")}"`;else return`"${O.replace(/(["\\$`])/g,"\\$1")}"`},K=process.argv.slice(3).map(V),G={...process.env},_=r0.join(W,"node_modules");G.NODE_PATH=_,G.NODE_PRESERVE_SYMLINKS=1;let z=f7(X,[...q,...K],{cwd:W,stdio:"inherit",shell:!0,detached:!0,env:G});e8(z)}catch(H){console.error(H.message),process.exit(1)}})}function h7(Q,{name:Z,preArgs:X=[],createContext:q}){return Q.command(`${Z} <config> <command> [options..]`,"Run a command with a config context",(Y)=>{return Y.positional("config",{type:"string"}).positional("command",{type:"string"}).help(!1).version(!1)},async(Y)=>{try{let J=await q(Y),{projectDir:H}=J,W=Y.config,K=(await NZ({name:W,dir:H,transferEnv:!1,optional:!0,tags:J.tags}))?.data?.env||void 0,G=Y.command,_=process.argv.slice(5),z=f7(G,[...X,..._],{cwd:A8.existsSync(H)?H:process.cwd(),stdio:"inherit",shell:!0,detached:!0,env:{...process.env,...K}});e8(z)}catch(J){console.error(J.message),process.exit(1)}})}function g7(Q,{name:Z,projectType:X="auto"}){return Q.command(`${Z} group [options..]`,"Run a command group.",(q)=>{return q.positional("group",{type:"string"}).option("ftag",{type:"array"}).help(!1).version(!1)},async(q)=>{try{let{runCommandGroup:Y}=await import("./index.0jcm9pn5.js");await Y({projectType:X,group:q.group,tags:q.ftag,args:q,argv:process.argv})}catch(Y){console.error(Y.message),process.exit(1)}})}function m7(Q,{name:Z,createContext:X}){return Q.command(`${Z} [options]`,"Install the project as a binary",(q)=>{return q.option("name",{alias:"n",describe:"Name to use for the installed binary",type:"string"}).option("force",{alias:"f",describe:"Force overwrite if binary already exists",type:"boolean",default:!1}).option("yes",{alias:"y",describe:"Automatically answer yes to all prompts",type:"boolean",default:!1})},async(q)=>{try{let Y=await X(q),{projectDir:J}=Y;console.log(n0.blue("Compiling project..."));let H=r0.join(J,".bin");if(!A8.existsSync(H))A8.mkdirSync(H,{recursive:!0});let W=r0.basename(r0.dirname(J)),V=Y.project?.projectFileParsed?.features?.cli?.bin,K=q.name||V||W;console.log(n0.blue(`Using binary name: ${K}`));let G=r0.join(H,K),{spawn:_}=await import("child_process"),z=_("bun",["build","./dist/cli/esm/index.js","--compile",`--outfile=${G}`],{cwd:J,stdio:"inherit",shell:!0});if(await new Promise((A,U)=>{z.on("close",(B)=>{if(B===0)A();else U(Error(`Compilation failed with code ${B}`))}),z.on("error",(B)=>{U(B)})}),process.platform!=="win32")A8.chmodSync(G,493);console.log(n0.green(`Binary compiled successfully: ${G}`)),console.log(n0.blue("Installing binary..."));let O=["install",G];if(q.name)O.push("--name",q.name);if(q.force)O.push("--force");if(q.yes)O.push("--yes");let $=_("fbin",O,{stdio:"inherit",shell:!0});await new Promise((A,U)=>{$.on("close",(B)=>{if(B===0)A();else U(Error(`Installation failed with code ${B}`))}),$.on("error",(B)=>{U(B)})})}catch(Y){console.error(n0.red(`Failed to install binary: ${Y.message}`)),process.exit(1)}})}import o from"node:path";import $0 from"node:fs";import B8 from"@fnet/yaml";import PZ from"yaml";async function D(Q){try{let Z=await bZ({tags:Q.ftag,flowsPath:Q.flows});return{buildId:Q.buildId,mode:Q.mode,protocol:Q.protocol||"src:",templateDir:D0("./template/fnet/node"),coreDir:D0("./template/fnet/core"),projectDir:o.resolve(Z.projectDir,"./.workspace"),projectSrcDir:o.resolve(Z.projectDir,"./src"),projectSrcDirSymlink:o.resolve(Z.projectDir,"./.workspace/src-core"),projectAppDir:o.resolve(Z.projectDir,"./app"),projectAppDirSymlink:o.resolve(Z.projectDir,"./.workspace/app"),projectCliDir:o.resolve(Z.projectDir,"./cli"),projectCliDirSymlink:o.resolve(Z.projectDir,"./.workspace/cli"),project:Z,tags:Q.ftag,dev:Q.dev,bpmn:Q.bpmn===!0}}catch(Z){return console.warn(`Warning: Could not load project: ${Z.message}`),{projectDir:process.cwd(),tags:Q.ftag}}}async function bZ({tags:Q,flowsPath:Z}){let X=kZ(process.cwd());if(!$0.existsSync(X))throw Error("fnet.yaml file not found in current directory.");let{raw:q,parsed:Y}=await B8({file:X,tags:Q}),J=o.dirname(X);Y.features=Y.features||{};let H=Y.features;H.runtime=H.runtime||{},H.runtime.type=H.runtime.type||"node";let W;if(Z){let z=o.resolve(J,Z);if(!$0.existsSync(z))throw Error(`Flows file not found: ${z}`);let{parsed:O}=await B8({file:z,tags:Q});W=O}else if(typeof Y.flows==="object")W=Y.flows;else{let z="flow.main.yaml";if($0.existsSync(o.join(J,"fnet","flows.yaml")))z=o.join("fnet","flows.yaml");let O=Y.main||z,$=o.resolve(J,O);if(!$0.existsSync($))W={main:{steps:[]}};else{let{parsed:A}=await B8({file:$,tags:Q});W=A}}let K={workflowAtom:{doc:{...Y,content:W}},projectDir:J,projectFilePath:X,projectFileContent:q,projectFileParsed:Y,runtime:H.runtime},G=o.resolve(J,"fnet/targets.yaml");if($0.existsSync(G)){let{raw:z,parsed:O}=await B8({file:G,tags:Q}),$=PZ.parseDocument(z);K.devops={filePath:G,fileContent:z,yamlDocument:$,doc:{...O},type:"workflow.deploy",save:async()=>{$0.writeFileSync(K.devops.filePath,$.toString())}}}let _=o.resolve(J,"readme.md");if($0.existsSync(_)){let z=$0.readFileSync(_,"utf8");K.readme={filePath:_,fileContent:z,doc:{content:z,"content-type":"markdown"},type:"wiki"}}return K}function kZ(Q){let Z=o.resolve(Q,"fnet.yaml");if($0.existsSync(Z))return Z;let X=o.resolve(Q,"fnet.yml");if($0.existsSync(X))return X;return Z}import DZ from"node:path";import c7 from"node:fs";import vZ from"node:os";import yZ from"@flownet/lib-render-templates-dir";import Q6 from"@fnet/shelljs";var EZ={command:"create",describe:"Initialize a new fnet project",builder:(Q)=>{return Q.option("name",{type:"string",describe:"Project name"}).option("vscode",{type:"boolean",default:!0,alias:"vs",describe:"Open in VS Code after creation"}).option("runtime",{type:"string",default:"node",choices:["node"],describe:"Runtime environment"})},handler:async(Q)=>{try{let Z=process.cwd(),X=D0("./template/fnet/project"),q=DZ.resolve(Z,Q.name);if(!c7.existsSync(q))c7.mkdirSync(q);await yZ({dir:X,outDir:q,context:Q,copyUnmatchedAlso:!0,platform:vZ.platform()});let Y=await Q6("fnet build",{cwd:q});if(Y.code!==0)throw Error("Failed to build project.");if(M0("git")){if(Y=await Q6("git init --initial-branch=main",{cwd:q}),Y.code!==0)throw Error("Failed to initialize git.")}if(M0("code")&&Q.vscode){if(Y=await Q6(`cd ${q} && code .`),Y.code!==0)throw Error("Failed to open vscode.")}console.log("Creating project succeeded!"),process.exit(0)}catch(Z){console.error("Initialization failed!",Z.message),process.exit(1)}}},l7=EZ;import xZ from"node:os";import uZ from"@flownet/lib-render-templates-dir";import fZ from"@fnet/shelljs";var hZ={command:"project",describe:"Manage fnet project",builder:(Q)=>{return Q.option("update",{type:"boolean",default:!1,alias:"-u",describe:"Update project files"})},handler:async(Q)=>{try{let Z=D0("./template/fnet/project"),X=process.cwd(),q=await D(Q);if(Q.update){if(await uZ({dir:Z,outDir:X,context:{name:q.project.projectFileParsed.name,runtime:"node"},copyUnmatchedAlso:!0,platform:xZ.platform()}),(await fZ("fnet build",{cwd:X})).code!==0)throw Error("Failed to build project.");console.log("Updating project succeeded!")}process.exit(0)}catch(Z){console.error("Project failed.",Z.message),process.exit(1)}}},d7=hZ;import T from"node:fs";import k from"node:path";import oQ from"yaml";import tQ from"@fnet/shelljs";import M8 from"nunjucks";import eQ from"lodash.clonedeep";import t1 from"isobject";import{randomUUID as QZ}from"node:crypto";import Z6 from"winston";var{combine:i7,timestamp:p7,printf:gZ,colorize:mZ}=Z6.format,a7=gZ(({level:Q,message:Z,timestamp:X,category:q,depth:Y,...J})=>{let H=" ".repeat(Y||0),W=q?`[${q}]`:"",V=`${X} ${Q} ${W} ${H}${Z}`;if(Object.keys(J).length>0)V+=`
|
|
3
|
+
${H} ${JSON.stringify(J,null,2)}`;return V}),R8=Z6.createLogger({level:process.env.FNET_LOG_LEVEL||"info",format:i7(p7({format:"HH:mm:ss.SSS"}),a7),transports:[new Z6.transports.Console({format:i7(mZ(),p7({format:"HH:mm:ss.SSS"}),a7)})]}),r7=(Q)=>{return{debug:(Z,X={})=>R8.debug(Z,{category:Q,...X}),info:(Z,X={})=>R8.info(Z,{category:Q,...X}),warn:(Z,X={})=>R8.warn(Z,{category:Q,...X}),error:(Z,X={})=>R8.error(Z,{category:Q,...X})}},f=r7("tree"),x=r7("bpmn"),n7=process.env.FNET_LOG_CATEGORIES?.split(",")||[],j=(Q)=>{if(n7.length===0)return!1;return n7.includes(Q)};import u0 from"lodash.merge";import I8 from"node:fs";import z0 from"node:path";import f0 from"@flownet/lib-parse-imports-js";import cZ from"lodash.merge";function E({feature:Q,features:Z,packageDevDependencies:X}){let{name:q,packages:Y,options:J,extraCheck:H,explicit:W}=Q,V=`${q}_enabled`,K=Z.rollup_output||{},G=Object.keys(K),_=J||{},z=Z[q]?.options;if(z)_=cZ(_,z);let O=!Z[q]||Z[q]?.enabled===!1;G.forEach((A)=>{let U=Z.rollup_output[A];if(!U)return;if(Reflect.has(U,q)){if(O||!U[q]||U[q]?.enabled===!1){delete U[q];return}if(U[q]===!0)U[q]={enabled:!0,options:_}}else if(!O&&!W&&Z[V]!==!1)U[q]={enabled:!0};else return;U[q]=U[q]||{},U[q].options={..._,...U[q].options}});let $=G.some((A)=>Z.rollup_output[A][q]?.enabled===!0);if(H)$=H()&&$;if(Z[V]=$,$)Y.forEach((A)=>X.push({package:A[0],version:A[1]}))}function X6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"workbox",packages:[["rollup-plugin-workbox","^8"]],options:{generate:{swDest:"dist/app/esm/sw.js",globDirectory:"dist/app/esm",globPatterns:["**/*.{html,js,css,png,jpg}"],skipWaiting:!0,clientsClaim:!0}},explicit:!0},features:q,packageDevDependencies:X})}function q6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"gzip",packages:[["rollup-plugin-gzip","^4"]],explicit:!0},features:q,packageDevDependencies:X})}function Y6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"nunjucks",packages:[["@fnet/rollup-plugin-nunjucks","0.1.8"]]},features:q,packageDevDependencies:X})}function J6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"polyfill",packages:[["rollup-plugin-node-polyfills","^0.2"]]},features:q,packageDevDependencies:X})}function W6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"visualizer",packages:[["rollup-plugin-visualizer","^5"]],expilicit:!0},features:q,packageDevDependencies:X})}function H6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"analyzer",packages:[["rollup-plugin-analyzer","^3"]],options:{summaryOnly:!0,limit:12},explicit:!0},features:q,packageDevDependencies:X})}function V6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"string",packages:[["rollup-plugin-string","^3"]]},features:q,packageDevDependencies:X})}function K6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"image",packages:[["@rollup/plugin-image","^3"]]},features:q,packageDevDependencies:X})}function z6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;if(q.runtime.type==="bun")return;E({feature:{name:"json",packages:[["@rollup/plugin-json","^6"]]},features:q,packageDevDependencies:X})}function G6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"terser",packages:[["@rollup/plugin-terser","^0.4"]]},features:q,packageDevDependencies:X})}function _6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;E({feature:{name:"wasm",packages:[["@rollup/plugin-wasm","^6"]]},features:q,packageDevDependencies:X})}function U6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features;if(q.runtime.type==="bun")return;let Y={};if(q.app?.enabled===!0){if(Y.targets=Y.targets||[],Y.targets.push({src:"./src/app/index.html",dest:q.app.dir}),!Reflect.has(q.app,"copy")){if(!Reflect.has(q,"copy"))q.copy=!0}}E({feature:{name:"copy",packages:[["rollup-plugin-copy","^3"],["chokidar","^3"]],options:Y},features:q,packageDevDependencies:X})}function $6(Q){let{atom:Z,packageDevDependencies:X}=Q,q=Z.doc.features,Y=q.css&&q.css.enabled!==!1,J=[];if(Y)J.push(["rollup-plugin-postcss","^4"]),J.push(["sass","^1.66"]),(q.css?.options?.plugins||[]).forEach((W)=>{switch(W.name){case"postcss-import":J.push(["postcss-import","^15"]);break;case"postcss-url":J.push(["postcss-url","^10"]);break;case"postcss-preset-env":J.push(["postcss-preset-env","^9"]);break;case"autoprefixer":J.push(["autoprefixer","^10"]);break;case"cssnano":J.push(["cssnano","^6"]);break}});E({feature:{name:"css",packages:J},features:q,packageDevDependencies:X})}function M6({dir:Q,name:Z="index"}){let X=z0.resolve(Q,`./${Z}.tsx`);if(!I8.existsSync(X))X=z0.resolve(Q,`./${Z}.ts`);if(!I8.existsSync(X))X=z0.resolve(Q,`./${Z}.jsx`);if(!I8.existsSync(X))X=z0.resolve(Q,`./${Z}.js`);if(!I8.existsSync(X))return{};let q=X,Y=z0.extname(X);return{file:q,ext:Y,ts:Y===".ts"||Y===".tsx",name:Z}}async function O6(Q){let{atom:Z,context:X,setProgress:q}=Q;q("Initializing features..."),Z.doc.features=Z.doc.features||{};let Y=Z.doc.features;Y.project=Y.project||{},Y.project.format=Y.project.format||Y.project_format||"esm",Y.project_format=Y.project.format,Y.dts_enabled=Y.dts===!0||typeof Y.dts<"u"&&Y.dts!==!1;let J=z0.resolve(X.project.projectDir),H=M6({dir:z0.resolve(J,"./app")});if(H.file){q("Parsing app entry imports...");let A=await f0({file:H.file,recursive:!0}),U=A.all.some((B)=>B.usesJSX===!0&&B.type==="local");Y.app_uses_jsx=U,Y.app_has_entry=!0,A=await f0({file:H.file}),U=A.all.some((B)=>B.usesJSX===!0&&B.type==="local"),Y.app_entry_uses_jsx=U,Y.app_entry_is_ts=H.ts,Y.app_entry_ext=H.ext}let W=M6({dir:z0.resolve(J,"./cli")});if(W.file){q("Parsing cli entry imports...");let A=await f0({file:W.file,recursive:!0}),U=A.all.some((B)=>B.usesJSX===!0&&B.type==="local");Y.cli_uses_jsx=U,Y.cli_has_entry=!0,A=await f0({file:W.file}),U=A.all.some((B)=>B.usesJSX===!0&&B.type==="local"),Y.cli_entry_uses_jsx=U,Y.cli_entry_is_ts=W.ts,Y.cli_entry_ext=W.ext}if(Z.type==="workflow.lib"){let A=M6({dir:z0.resolve(J,"./src")});if(A.file){q("Parsing src entry imports...");let U=await f0({file:A.file,recursive:!0}),B=U.all.some((M)=>M.usesJSX===!0&&M.type==="local");Y.src_uses_jsx=B,Y.src_has_entry=!0,U=await f0({file:A.file}),B=U.all.some((M)=>M.usesJSX===!0&&M.type==="local"),Y.src_entry_uses_jsx=B,Y.src_entry_is_ts=A.ts,Y.src_entry_ext=A.ext}}let V=Reflect.has(Y,"app_entry_uses_jsx")?Y.app_entry_uses_jsx===!0:Y.src_entry_uses_jsx===!0,K=Reflect.has(Y,"cli_entry_uses_jsx")?Y.cli_entry_uses_jsx===!0:Y.src_entry_uses_jsx===!0;if(Y.form_enabled=V||K||Y.form===!0||Y.form?.enabled===!0,Y.multiple_enabled=Y.multiple_enabled||Y.multiple===!0||Y.multiple?.enabled===!0,Y.app===!1)Y.app={enabled:!1};else if(Y.app===!0)Y.app={enabled:!0,extend:Y.app_has_entry===!0,export:!0,react:V};else Y.app={enabled:!0,extend:Y.app_has_entry===!0,export:!0,react:V,...Y.app||{}};if(Y.app.enabled=Y.app.enabled===!0&&(Z.doc.features.form_enabled===!0||Y.app.extend===!0||Y.app.enabled===!0),Y.app.format=Y.app.format||"esm",Y.app.folder=Y.app.folder||Y.app.format||"default",Y.cli===!1)Y.cli={enabled:!1};else if(Y.cli===!0)Y.cli={enabled:!0,extend:Y.cli_has_entry===!0,export:!0,react:K};else Y.cli={enabled:!0,extend:Y.cli_has_entry===!0,export:!0,react:K,...Y.cli||{}};if(Y.cli.enabled=Y.cli.enabled===!0&&(Z.doc.features.form_enabled===!1||Y.cli.extend===!0||Y.cli.enabled===!0),Y.cli.format=Y.cli.format||"esm",Y.cli.folder=Y.cli.folder||Y.cli.folder||"esm",Y.cli.node_options=Y.cli.node?.options||Y.cli.node_options||"",Y.cli.bin=Y.cli.bin||Z.doc.name,Y.cli.installable=Y.cli.installable===!0,Y.cli.enabled)Z.doc["npm::bin"]=Y.cli.bin;Y.json=Y.cli.enabled||Y.json;let G={cjs:{format:"cjs",context:Y.form_enabled?"window":"global",babel:Y.src_uses_jsx===!0||!1,browser:!1,replace:!0,terser:!0,enabled:Y.cjs!==!1,copy:!1},esm:{format:"esm",context:Y.form_enabled?"window":"global",babel:Y.src_uses_jsx===!0||!1,browser:!1,replace:!0,terser:!1,enabled:Y.esm!==!1,copy:!0},iife:{format:"iife",context:Y.form_enabled?"window":"global",babel:!0,browser:!0,replace:!0,enabled:Y.iife===!0,terser:!0,copy:!1}},_={targets:{browsers:"last 9 versions, not dead",node:"18"}},z={};if(Y.webos===!0)G.webos={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,input:"./src/app/index.js",output_dir:"./dist/app/webos",copy:!1,babel_options:{targets:{chrome:"79"}}};if(Y.electron===!0)G.electron={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/electron"};if(Y.nextjs===!0)G.nextjs={format:"esm",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/nextjs"};if(Y.ios===!0)G.ios={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/ios"};if(Y.macos===!0)G.macos={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/macos"};if(Y.app.enabled===!0)Y.app.dir=`./dist/app/${Y.app.folder}`,Y.app.output={file:`./dist/app/${Y.app.folder}/index.js`,dir:`./dist/app/${Y.app.folder}/`,...Y.app.output||{}},Y.app.input={file:"./src/app/index.js",dir:"./src/app/",...Y.app.input||{}},G.app={format:Y.app.format,browser:!0,babel:!0,context:"window",replace:!0,input:Y.app.input.file,output_dir:Y.app.dir,terser:!0,output_exports:Y.app.export===!1?"none":"auto",browsersync:!0};if(Y.cli.enabled===!0)Y.cli.dir=`./dist/cli/${Y.cli.folder}`,Y.cli.output={file:`./dist/cli/${Y.cli.folder}/index.js`,dir:`./dist/cli/${Y.cli.folder}/`,...Y.cli.output||{}},Y.cli.input={file:"./src/cli/index.js",dir:"./src/cli/",...Y.cli.input||{}},G.cli={format:Y.cli.format,context:"global",babel:Y.src_uses_jsx===!0||Y.cli_uses_jsx===!0||!1,browser:!1,replace:!0,enabled:!0,input:Y.cli.input.file,output_dir:Y.cli.dir,banner:"#!/usr/bin/env bun",terser:!0,output_exports:Y.cli.export===!1?"none":"auto"};let O={server:".",startPath:`${z0.normalize(Y.app.dir||".")}`,files:[z0.normalize("./dist/**/*")],cors:!0,open:!1};if(Y.babel_options=u0(_,Y.babel_options||Y.babel?.options),Y.browsersync_options=u0(O,Y.browsersync_options||Y.browsersync?.options||{}),Y.replace_options=u0(z,Y.replace_options||Y.replace?.options||{}),Reflect.has(Y.browsersync_options,"proxy"))delete Y.browsersync_options.server;Y.rollup=Y.rollup||{},Y.rollup_output=u0(G,Y.rollup_output||Y.rollup?.output||{}),Y.preact_enabled=Y.preact===!0||Y.preact&&Y.preact?.enabled!==!1;let $=Object.keys(G);for(let A of $){let U=G[A];if(!U)continue;if(Y.rollup[A]===!1){delete Y.rollup_output[A];continue}if(U.babel_options=U.babel_options||Y.babel_options,U.browsersync_options=u0(Y.browsersync_options,U.browsersync_options),U.replace_options=u0(Y.replace_options,U.replace_options),Y.preact_enabled)U.alias_enabled=!0,U.alias=U.alias||{},U.alias.entries=U.alias.entries||{},U.alias.entries.react="preact/compat",U.alias.entries["react-dom"]="preact/compat";if(Y.form_enabled||Y.babel)U.babel=!0}$=Object.keys(Y.rollup_output),Y.babel_enabled=$.some((A)=>Y.rollup_output[A].babel===!0),Y.browser_enabled=$.some((A)=>Y.rollup_output[A].babel===!0),Y.browsersync_enabled=Y.browsersync!==!1&&$.some((A)=>Y.rollup_output[A].browsersync===!0),Y.browsersync_enabled=Y.browsersync_enabled&&Y.app.enabled,Y.dependency_auto_enabled=Y.dependency_auto!==!1&&Y.dependency_auto?.enabled!==!1,Y.npm_install_flags=Y.npm_install_flags||"",Y.react_version=Y.react_version||Y.react?.version||18,Y.bpmn=Y.bpmn||{},Y.bpmn.enabled=Y.bpmn.enabled!==!1,Y.bpmn.per_flow=Y.bpmn.per_flow===!0,$6(Q),U6(Q),_6(Q),G6(Q),z6(Q),V6(Q),K6(Q),H6(Q),W6(Q),J6(Q),Y6(Q),X6(Q),q6(Q)}import lZ from"@fnet/npm-list-versions";async function A6({atom:Q,packageDependencies:Z,packageDevDependencies:X,setProgress:q}){q("Initializing dependencies");let Y=Q.doc.dependencies||[];if(Y.filter((J)=>!J.dev).forEach((J)=>Z.push(J)),Y.filter((J)=>J.dev).forEach((J)=>X.push(J)),Q.type==="workflow")Z.push({package:"dot-prop",version:"^10"});if(Q.doc.features.form_enabled){if(Q.doc.features.dependency_auto_enabled){let J="^18.2";if(q("Fetching React versions"),J=`^${(await lZ({name:"react",groupBy:{major:!0}})).find((V)=>V[0]===Q.doc.features.react_version.toString())[0]}`,Z.push({package:"react",version:J}),Z.push({package:"react-dom",version:J}),Q.type==="workflow")Z.push({package:"@fnet/react-app",version:"^0.1"}),Z.push({package:"@fnet/react-app-state",version:"^0.1"})}}if(Q.doc.features.preact_enabled)Z.push({package:"preact",version:"^10"});if(Q.doc.features.cli.enabled===!0){if(Z.push({package:"@fnet/args",version:"^0.1"}),Q.doc.features.cli.fargs&&Q.doc.features.cli.fargs?.enabled!==!1)Z.push({package:"@fnet/config",version:"0.2.21"});if(Q.doc.features.cli.mcp&&Q.doc.features.cli.mcp.enabled===!0)Z.push({package:"@modelcontextprotocol/sdk",version:"^1.10"}),Z.push({package:"express",version:"^4.18"})}if(Q.doc.features.render&&Q.doc.features.render.enabled!==!1)X.push({package:"@flownet/lib-render-templates-dir",version:"0.1.19"});if(X.push({package:"@babel/core",version:"^7"}),X.push({package:"@rollup/plugin-commonjs",version:"^28"}),X.push({package:"@rollup/plugin-node-resolve",version:"^16"}),X.push({package:"@rollup/plugin-replace",version:"^6"}),X.push({package:"rollup",version:"^4"}),Q.doc.features.dts_enabled)X.push({package:"rollup-plugin-dts",version:"^6"});if(X.push({package:"rollup-plugin-peer-deps-external",version:"^2"}),X.push({package:"@rollup/plugin-alias",version:"^5"}),X.push({package:"fs-extra",version:"^11"}),Q.doc.features.babel_enabled)X.push({package:"@rollup/plugin-babel",version:"^6"}),X.push({package:"@babel/preset-env",version:"^7"}),X.push({package:"@babel/preset-react",version:"^7"}),Q.doc.features.babel?.options?.plugins?.forEach((J)=>{switch(J[0]){case"@babel/plugin-proposal-decorators":X.push({package:"@babel/plugin-proposal-decorators",version:"^7"});break;case"@babel/plugin-proposal-class-properties":X.push({package:"@babel/plugin-proposal-class-properties",version:"^7"});break;case"@babel/plugin-proposal-private-methods":X.push({package:"@babel/plugin-proposal-private-methods",version:"^7"});break;case"@babel/plugin-proposal-private-property-in-object":X.push({package:"@babel/plugin-proposal-private-property-in-object",version:"^7"});break;case"@babel/plugin-proposal-optional-chaining":X.push({package:"@babel/plugin-proposal-optional-chaining",version:"^7"});break}});if(X.push({package:"@fnet/rollup-plugin-delete",version:"0.1.10"}),Q.doc.features.browsersync_enabled)X.push({package:"@fnet/rollup-plugin-browsersync",version:"0.1.11"})}import dZ from"@fnet/npm-list-versions";async function B6({atom:Q,packageDependencies:Z,packageDevDependencies:X,setProgress:q}){q("Initializing dependencies for Bun");let Y=Q.doc.dependencies||[];if(Y.filter((J)=>!J.dev).forEach((J)=>Z.push(J)),Y.filter((J)=>J.dev).forEach((J)=>X.push(J)),Q.type==="workflow")Z.push({package:"dot-prop",version:"^10"});if(Q.doc.features.form_enabled){if(Q.doc.features.dependency_auto_enabled){let J="^18.2";if(q("Fetching React versions"),J=`^${(await dZ({name:"react",groupBy:{major:!0}})).find((V)=>V[0]===Q.doc.features.react_version.toString())[0]}`,Z.push({package:"react",version:J}),Z.push({package:"react-dom",version:J}),Q.type==="workflow")Z.push({package:"@fnet/react-app",version:"^0.1"}),Z.push({package:"@fnet/react-app-state",version:"^0.1"})}}if(Q.doc.features.preact_enabled)Z.push({package:"preact",version:"^10"});if(Q.doc.features.cli.enabled===!0){if(Z.push({package:"@fnet/args",version:"^0.1"}),Q.doc.features.cli.fargs&&Q.doc.features.cli.fargs?.enabled!==!1)Z.push({package:"@fnet/config",version:"0.2.21"});if(Q.doc.features.cli.mcp&&Q.doc.features.cli.mcp.enabled===!0)Z.push({package:"@modelcontextprotocol/sdk",version:"^1.10"}),Z.push({package:"express",version:"^4.18"})}if(Q.doc.features.render&&Q.doc.features.render.enabled!==!1)X.push({package:"@flownet/lib-render-templates-dir",version:"0.1.19"})}import s7 from"node:fs";import o7 from"node:path";import iZ from"@flownet/lib-render-templates-dir";async function R6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){if(Q.doc.features.app.enabled!==!0)return;await Z({message:"Creating app folder"});let Y={atom:Q,packageDependencies:q,ts:Date.now()},J=X.templateDir,H=o7.resolve(X.projectDir,"src/app");if(!s7.existsSync(H))s7.mkdirSync(H,{recursive:!0});let W=["index.js.njk"];if(Q.doc.features.app.html!==!1)W.push("index.html.njk");await iZ({pattern:W,dir:o7.resolve(J,"src/app"),outDir:H,context:Y})}import e7 from"nunjucks";import R0 from"node:fs";import T0 from"node:path";import nZ from"@flownet/lib-parse-imports-js";import pZ from"@fnet/npm-pick-versions";import aZ from"object-hash";import C8 from"node:fs";import t7 from"node:path";async function j0({projectDir:Q,name:Z,setProgress:X,count:q=1}){let Y,H=aZ(["npm-pick-versions",Z,q]),W=t7.join(Q,".cache"),V=t7.join(W,H+".json");if(C8.existsSync(V)){if(X)X(`Picking npm version of ${Z} from cache ...`);Y=JSON.parse(C8.readFileSync(V,"utf8"))}else{if(X)X(`Picking npm version of ${Z} ...`);Y=await pZ({name:Z,count:q}),C8.mkdirSync(W,{recursive:!0}),C8.writeFileSync(V,JSON.stringify(Y),"utf8")}return Y}async function I6({atom:Q,context:Z,packageDependencies:X,packageDevDependencies:q,setProgress:Y}){await Y({message:"Creating package.json."}),X.filter((U)=>U.dev===!0).forEach((U)=>{if(!q.find((M)=>M.package===U.package))q.push(U);let B=X.findIndex((M)=>M.package===U.package);X.splice(B,1)});let H=X.find((U)=>U.package==="react"),W=X.find((U)=>U.package==="react-dom");if(H&&!W)X.push({package:"react-dom",version:H.version});else if(H&&W)W.version=H.version;if(H&&Q.doc.features.react_version>=17){if(!X.find((U)=>U.package==="@emotion/react"))X.push({package:"@emotion/react",version:"^11"});if(!X.find((U)=>U.package==="@emotion/styled"))X.push({package:"@emotion/styled",version:"^11"})}let V=[];if(Q.doc.features.app.enabled===!0)V.push({file:T0.resolve(Z.projectDir,"src/app/index.js"),dev:Q.doc.features.app.dev===!0});if(Q.doc.features.cli.enabled===!0)V.push({file:T0.resolve(Z.projectDir,"src/cli/index.js"),dev:Q.doc.features.cli.dev===!0});for await(let U of V){let B=U.file;if(!R0.existsSync(B))throw Error(`App file not found: ${B}`);let R=(await nZ({file:B,recursive:!0,verbose:!1})).all;for await(let F of R){if(F.type!=="npm")continue;if(X.find((v)=>v.package===F.package))continue;if(q.find((v)=>v.package===F.package))continue;let w=await j0({name:F.package,projectDir:Z.projectDir,setProgress:Y});(U.dev===!0?q:X).push({package:F.package,subpath:F.subpath,version:w.minorRange,type:"npm"})}}for await(let U of X){if(U.version!==void 0)continue;let B=await j0({name:U.package,projectDir:Z.projectDir,setProgress:Y});U.version=B.minorRange}for await(let U of q){if(U.version!==void 0)continue;let B=await j0({name:U.package,projectDir:Z.projectDir,setProgress:Y});U.version=B.minorRange}let K={atom:Q,packageDependencies:X,packageDevDependencies:q},G=Z.templateDir,z=e7.compile(R0.readFileSync(T0.resolve(G,"package.json.njk"),"utf8"),e7.configure(G)).render(K),O=Z.projectDir,$=T0.resolve(O,"package.json");R0.writeFileSync($,z,"utf8");let A=T0.resolve(Z.project.projectDir,"fnet");if(R0.existsSync(A)){let U=T0.resolve(Z.projectDir,"fnet");if(!R0.existsSync(U))R0.mkdirSync(U);let B=R0.readdirSync(A);for(let M of B){let R=T0.resolve(A,M);if(!R0.lstatSync(R).isFile())continue;let F=T0.resolve(U,M);R0.copyFileSync(R,F)}}}import Q9 from"node:fs";import Z9 from"node:path";import rZ from"@flownet/lib-render-templates-dir";async function C6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){if(Q.doc.features.cli.enabled!==!0)return;await Z({message:"Creating cli."});let Y={atom:Q,packageDependencies:q},J=X.templateDir,H=Z9.resolve(X.projectDir,"src/cli");if(!Q9.existsSync(H))Q9.mkdirSync(H,{recursive:!0});await rZ({pattern:["index.js.njk"],dir:Z9.resolve(J,"src/cli"),outDir:H,context:Y})}import L6 from"node:fs";import F6 from"node:path";import X9 from"nunjucks";import sZ from"@flownet/lib-parse-imports-js";async function j6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){await Z({message:"Creating rollup file."});let Y={atom:Q,packageDependencies:q},J=F6.resolve(X.projectDir,"src","default/index.js");if(!L6.existsSync(J))throw Error(`Entry file not found: ${J}`);let W=(await sZ({file:J,recursive:!0})).all.filter((A)=>A.type==="node").map((A)=>A.path),V=Q.doc.features.rollup_output,K=Object.keys(V);for(let A=0;A<K.length;A++){let U=K[A],B=V[U];if(B.browser===!0){if(W.length>0){B.globals_enabled=!0,B.globals=B.globals||[],B.globals=B.globals.concat(W.map((M)=>{return{key:M,value:M}})),B.alias_enabled=!0,B.alias=B.alias||{},B.alias.entries=B.alias.entries||{};for(let M=0;M<W.length;M++){let R=W[M];B.alias.entries[R]=`node:${R}`,B.alias.entries[`node:${R}`]=R}B.external_enabled=!0,B.external=B.external||[],B.external=B.external.concat(W)}}}let G=X.templateDir,z=X9.compile(L6.readFileSync(F6.resolve(G,"rollup.config.mjs.njk"),"utf8"),X9.configure(G)).render(Y),O=X.projectDir,$=F6.resolve(O,"rollup.config.mjs");L6.writeFileSync($,z,"utf8")}import T6 from"node:fs";import q9 from"node:path";import Y9 from"nunjucks";async function S6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){await Z({message:"Creating build.js file."});let Y={atom:Q,packageDependencies:q},J=X.templateDir,W=Y9.compile(T6.readFileSync(q9.resolve(J,"build.js.njk"),"utf8"),Y9.configure(J)).render(Y),V=X.projectDir,K=q9.resolve(V,"build.js");T6.writeFileSync(K,W,"utf8"),T6.chmodSync(K,"755")}import w6 from"node:fs";import N6 from"node:path";import oZ from"nunjucks";import tZ from"ajv/dist/2020.js";import eZ from"ajv/dist/standalone/index.js";import Q5 from"ajv-formats";async function P6({atom:Q,setProgress:Z,context:X,njEnv:q}){if(Q.doc.features.cli.enabled!==!0)return;await Z({message:"Creating input args."});let Y={},J=[];if(Q.doc.input)Y=Q.doc.input;else Y={type:"object",properties:{},required:[]};if(Q.doc.features.cli.fargs&&Q.doc.features.cli.fargs?.enabled!==!1){let B=Q.doc.features.cli.fargs,M={type:"string",description:"Config name to load args",hidden:!1},R={type:"array",description:"Tags to filter the config",hidden:!1};if(Reflect.has(B,"default"))M.default=B.default}let W={imports:J,atom:Q},V=X.templateDir,G=oZ.compile(w6.readFileSync(N6.resolve(V,"src/default/input.args.js.njk"),"utf8"),q).render(W),_=X.projectDir,z=N6.resolve(_,"src/default/input.args.js");w6.writeFileSync(z,G,"utf8");let O=new tZ({allErrors:!0,useDefaults:!0,formats:{},strict:!1,code:{esm:!0,lines:!0,optimize:!1,source:!0}});Q5(O);let $=O.compile(Y),U=eZ(O,$)+`
|
|
4
|
+
export { schema31 as schema };`;w6.writeFileSync(N6.resolve(_,"src/default/validate_input.js"),U,"utf8")}import J9 from"node:fs";import W9 from"node:path";import H9 from"nunjucks";async function b6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){await Z({message:"Creating .gitignore"});let Y={atom:Q,packageDependencies:q},J=X.templateDir,W=H9.compile(J9.readFileSync(W9.resolve(J,".gitignore.njk"),"utf8"),H9.configure(J)).render(Y),V=X.projectDir,K=W9.resolve(V,".gitignore");J9.writeFileSync(K,W,"utf8")}import V9 from"node:fs";import K9 from"node:path";import z9 from"nunjucks";async function k6({atom:Q,setProgress:Z,context:X,packageDependencies:q}){await Z({message:"Creating tsconfig.json."});let Y={atom:Q,packageDependencies:q},J=X.templateDir,W=z9.compile(V9.readFileSync(K9.resolve(J,"tsconfig.json.njk"),"utf8"),z9.configure(J)).render(Y),V=X.projectDir,K=K9.resolve(V,"tsconfig.json");V9.writeFileSync(K,W,"utf8")}import L8 from"nunjucks";import S0 from"node:fs";import v0 from"node:path";import G9 from"@fnet/yaml";async function D6({atom:Q,context:Z,setProgress:X,Atom:q}){if(await X({message:"Creating readme.md"}),Z.project?.readme){let H=Z.projectDir,W={content:Z.project.readme.doc.content},V=v0.resolve(Z.project.projectDir,"fnet/how-to.md");if(S0.existsSync(V)){let A=S0.readFileSync(V,"utf8");W.howto=A}let K=v0.resolve(Z.project.projectDir,"fnet/input.yaml");if(S0.existsSync(K)){let A=await G9({file:K,tags:Z.tags});W.input=A.content}let G=v0.resolve(Z.project.projectDir,"fnet/output.yaml");if(S0.existsSync(G)){let A=await G9({file:G,tags:Z.tags});W.output=A.content}let _=Z.templateDir,O=L8.compile(S0.readFileSync(v0.resolve(_,"readme.md.njk"),"utf8"),L8.configure(_)).render(W),$=v0.resolve(H,"readme.md");S0.writeFileSync($,O,"utf8")}else if(Q.id){let H=await q.first({type:"wiki",parent_id:Q.id});if(!H||H.doc?.["content-type"]!=="markdown")return;let{content:W,...V}=H.doc,K={content:W},G=Z.templateDir,z=L8.compile(S0.readFileSync(v0.resolve(G,"readme.md.njk"),"utf8"),L8.configure(G)).render(K),O=Z.projectDir,$=v0.resolve(O,"readme.md");S0.writeFileSync($,z,"utf8")}}import Z5 from"node:path";import _9 from"@fnet/shelljs";async function v6({setProgress:Q,context:Z}){let X=Z.projectDir;await Q({message:"Prettifiying source files."});let q=Z5.join("src","**","*");if(M0("bun")){let Y=await _9(`prettier --write ${q} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:X});if(Y.code!==0)throw Error(Y.stderr)}else{let Y=await _9(`prettier --write ${q} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:X});if(Y.code!==0)throw Error(Y.stderr)}}import X5 from"@fnet/shelljs";async function y6({atom:Q,setProgress:Z,context:X}){if(!Q.doc.features.dts_enabled)return;let q=X.projectDir;if(await Z({message:"Creating .d.ts"}),(await X5("tsc",{cwd:q})).code!==0)throw Error("Couldnt create .d.ts files.")}import U9 from"@fnet/shelljs";async function E6({setProgress:Q,atom:Z,context:X}){let q=X.projectDir;if(await Q({message:"Installing npm packages."}),M0("bun")){if((await U9(`bun install ${Z.doc.features.npm_install_flags}`,{cwd:q})).code!==0)throw Error("Couldnt install npm packages.")}else if((await U9(`npm install ${Z.doc.features.npm_install_flags}`,{cwd:q})).code!==0)throw Error("Couldnt install npm packages.")}import $9 from"node:fs";import q5 from"node:path";import{spawn as Y5}from"node:child_process";async function M9(Q){let{projectDir:Z,scriptName:X,args:q=[],env:Y=process.env,shell:J=!0,detached:H=!0,onSpawn:W}=Q;if(!Z||!X)throw Error("projectDir and scriptName are required");let V=q5.resolve(Z,"package.json");if(!$9.existsSync(V))throw Error(`package.json not found at ${V}`);let K=JSON.parse($9.readFileSync(V,"utf8")),G=K.scripts?.[X];if(!G){let O=Object.keys(K.scripts||{}).join(", ");throw Error(`Script '${X}' not found. Available: ${O}`)}let _=q.length>0?`${G} ${q.join(" ")}`:G,z=Y5(_,[],{cwd:Z,stdio:"inherit",shell:J,detached:H,env:{...Y}});if(W)W(z);return new Promise((O,$)=>{z.on("error",(A)=>{$(Error(`Failed to start '${X}': ${A.message}`))}),z.on("close",(A)=>{O({subprocess:z,exitCode:A})})})}import J5 from"node:path";async function x6({setProgress:Q,context:Z}){let X=Z.projectDir;await Q({message:"Building main project."});let q=Z.dev?"build:dev":"build",Y={...process.env},J=J5.join(X,"node_modules");Y.NODE_PATH=J,Y.NODE_PRESERVE_SYMLINKS=1,await M9({projectDir:X,scriptName:q,shell:!0,detached:!0,env:Y})}var O9=async(Q)=>{let{atom:Z,packageDependencies:X,context:q,deploymentProjectTarget:Y,setProgress:J,deploymentProject:H,yamlTarget:W}=Q;if(Y.enabled!==!0)return;let V=Y.type;try{if(V==="lib")await(await import("./index.p0zb7e1b.js")).default({...Q});else if(V==="red")await(await import("./index.490y87nc.js")).default({...Q});else if(V==="npm")await(await import("./index.gh75wt1m.js")).default({...Q});else if(V==="gcs")await(await import("./index.hzsfswvp.js")).default({...Q});else if(V==="gitlab")await(await import("./index.jgpc3grc.js")).default({...Q});else if(V==="fnet-package")await(await import("./index.r82rtnmz.js")).default({...Q});else if(V==="fnet-form")await(await import("./index.3exge2js.js")).default({...Q});else if(V==="fnet-node")await(await import("./index.4jkat7r4.js")).default({...Q});else if(V==="fnet-flow")await(await import("./index.s662t98v.js")).default({...Q});else if(V==="nextjs")await(await import("./index.7vw06nrn.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="webos")await(await import("./index.zm4kesg6.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="electron")await(await import("./index.9567fa9x.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="docker")await(await import("./index.w74dpnpn.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="ios")await(await import("./index.7crx8ky1.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="macos")await(await import("./index.xeaw5xa9.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="rust")await(await import("./index.3kfx538h.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else if(V==="pypi")await(await import("./index.33f1ggpr.js")).default({atom:Z,target:Y,onProgress:J,projectDir:q.projectDir,dependencies:X,context:q,yamlTarget:W}),H.isDirty=!0;else{console.warn(`No deployer found for type: ${V}`);return}}catch(K){throw console.error(`Error during deployment for type "${V}":`,K),K}};import{Atom as i0}from"@flownet/lib-atom-api-js";import e1 from"@flownet/lib-parse-node-url";import B9 from"bpmn-moddle";import A9 from"dagre";import h6 from"lodash.clonedeep";var u6={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 R9(Q){let{nodes:Z,nodeIndex:X,root:q}=Q,Y=[],J=new Set,H=(W)=>{if(J.has(W.indexKey))return;if(J.add(W.indexKey),W.hasReturn&&W.type!=="return"){let V=`${W.indexKey}/_inline_end`;if(X[V])return;let K={name:"",type:"return",virtual:!0,parent:W.parent,childs:[],definition:{return:W.definition.return},index:W.parent.childs.length,indexKey:V,pathKey:`${W.pathKey}._inline_end`,codeKey:`${W.codeKey}_inline_end`,context:{next:null},hasReturn:!0,_inlineParent:W};if(Y.push(K),j("bpmn"))x.info(`[INLINE-RETURN] EndEvent: ${K.indexKey} (parent: ${W.indexKey})`)}W.childs.forEach((V)=>H(V))};Z.forEach((W)=>H(W)),Y.forEach((W)=>{W.parent.childs.push(W),X[W.indexKey]=W,Z.push(W)}),Z.forEach((W)=>{let V=[],K=[],G=($)=>{let A=Y.find((U)=>U._inlineParent===$);if(A)V.push({from:$,to:A,type:"bpmn:SequenceFlow"});else if($.context.next){if(V.push({from:$,to:$.context.next,type:"bpmn:SequenceFlow"}),$===W)K.push({to:$.context.next,type:"bpmn:SequenceFlow",next:!0})}$.childs.forEach((U)=>{if($===W){if(W.type==="switch"){if(!(U.indexKey&&U.indexKey.endsWith("/_inline_end")))K.push({to:U,type:"bpmn:SequenceFlow"})}}G(U)})};G(W);let _=V.filter(($)=>$.to.parent.indexKey===W.parent.indexKey).map(($)=>{return{...$,from:W.indexKey,to:$.to.indexKey}}),z=V.filter(($)=>$.to.parent.indexKey!==W.parent.indexKey&&!$.to.indexKey.startsWith(W.indexKey+"/")).map(($)=>{return{...$,from:W.indexKey,to:$.to.indexKey}}),O=K.map(($)=>{return{...$,to:$.to.indexKey}});if(W.bpmn=W.bpmn||{},W.bpmn.edges=f6(_,"to"),W.bpmn.outside=f6(z,"to"),W.bpmn.starts=f6(O,"to"),W.bpmn.type=H5(W),W.bpmn.width=120,W.bpmn.height=80,W.type==="return")W.bpmn.width=36,W.bpmn.height=36;if(W.bpmn.type==="bpmn:CallActivity")W.bpmn.fill="#E1F5FE",W.bpmn.stroke="#0277BD"})}function H5(Q){let Z;if(Q.type==="call"){if(Q.context?.lib?.type==="subworkflow"||Q.context?.lib?.type==="workflow"){if(Z="bpmn:CallActivity",j("bpmn"))x.info(`[CALL] CallActivity (subworkflow): ${Q.indexKey} (${Q.context?.lib?.name||"unknown"})`)}else if(Z="bpmn:ServiceTask",j("bpmn"))x.info(`[CALL] ServiceTask (external): ${Q.indexKey} (${Q.context?.lib?.name||"unknown"})`)}else if(Q.type==="form"){if(Z="bpmn:UserTask",j("bpmn"))x.info(`[FORM] UserTask: ${Q.indexKey}`)}else if(Q.type==="return"){if(Z="bpmn:EndEvent",j("bpmn"))x.info(`[RETURN] EndEvent: ${Q.indexKey}`)}else if(Q.type==="raise"){let X=!1;if(Q.name==="try"&&Q.parent?.type==="tryexcept")X=!0;else{let q=Q.parent;while(q){if(q.name==="try"&&q.parent?.type==="tryexcept"){X=!0;break}q=q.parent}}if(X){if(Z="bpmn:IntermediateThrowEvent",j("bpmn"))x.info(`[RAISE] IntermediateThrowEvent (inside try): ${Q.indexKey}`)}else if(Z="bpmn:EndEvent",j("bpmn"))x.info(`[RAISE] EndEvent (error): ${Q.indexKey}`)}else if(Q.type==="pipeline"){if(Z="bpmn:ServiceTask",j("bpmn"))x.info(`[PIPELINE] ServiceTask (external binary): ${Q.indexKey} (${Q.context?.binaryName||"unknown"})`)}else if(Q.type==="http"){if(Z="bpmn:ServiceTask",j("bpmn"))x.info(`[HTTP] ServiceTask (external API): ${Q.indexKey} (${Q.context?.http?.method||"GET"} ${Q.context?.http?.url||"unknown"})`)}else if(Q.type==="assign"||Q.type==="new"){if(Z="bpmn:ScriptTask",j("bpmn"))x.info(`[${Q.type.toUpperCase()}] ScriptTask: ${Q.indexKey}`)}else if(Z="bpmn:Task",j("bpmn"))x.info(`[${Q.type.toUpperCase()}] Task: ${Q.indexKey}`);return Z}function f6(Q,Z){return Q.filter((X,q,Y)=>{return Y.map((J)=>J[Z]).indexOf(X[Z])===q})}function g6(Q){let{nodes:Z,nodeIndex:X,root:q}=Q,Y=Q.targetNodes||q.childs;Y.forEach((J)=>{let H=J.type==="workflow"||J.type==="subworkflow",W=!H&&J.childs.filter((_)=>!_.virtual).length>0,V=(J.name==="try"||J.name==="except")&&J.parent?.type==="tryexcept",K=J.type==="schedule",G=J.type==="retry";if(W||V||K||G){if(J.bpmn.type="bpmn:SubProcess",J.type==="for"){if(J.bpmn.loopCharacteristics=!0,j("bpmn"))x.info(`[FOR] SubProcess + Loop Marker: ${J.indexKey}`)}if(J.name==="try"&&J.type==="raise"&&J.parent?.type==="tryexcept"){let _=t({location:0,...Q,parent:J,bpmnType:"bpmn:IntermediateThrowEvent",type:"raise",attrs:{},definitions:[{type:"bpmn:ErrorEventDefinition"}]});if(j("bpmn"))x.info(`[VIRTUAL] IntermediateThrowEvent for single-step try block: ${J.indexKey}`)}}if(H||W){let _=J.childs.filter((M)=>M.module!==!0&&!M.indexKey.endsWith("/_inline_end"))[0];J.childs.filter((M)=>M.module===!0).forEach((M)=>{let R=t({...Q,parent:J,bpmnType:"bpmn:IntermediateCatchEvent",type:"inter",definitions:[{type:"bpmn:SignalEventDefinition"}]});R.bpmn.edges=[{from:R.indexKey,to:M.indexKey,type:"bpmn:SequenceFlow"}]});let O=J.childs.find((M)=>M.name==="try"&&J.type==="tryexcept"),$=J.childs.filter((M)=>M.name==="except"&&J.type==="tryexcept");if(O&&$.length)$.forEach((M)=>{let R=t({location:J.childs.indexOf(M),...Q,parent:J,bpmnType:"bpmn:BoundaryEvent",type:"boundary",attrs:{attachedToRef:O},definitions:[{type:"bpmn:ErrorEventDefinition"}]});if(R.bpmn.edges=[{from:R.indexKey,to:M.indexKey,type:"bpmn:SequenceFlow"}],j("bpmn"))x.info(`[TRY-EXCEPT] BoundaryEvent: ${J.indexKey} (try: ${O.indexKey}, except: ${M.indexKey})`)});let A=J.childs.find((M)=>M.type==="raise");if(A){let M=t({...Q,parent:J,bpmnType:"bpmn:EndEvent",type:"end",name:"ERROR",definitions:[{type:"bpmn:ErrorEventDefinition"}]});A.bpmn.edges=[{from:A.indexKey,to:M.indexKey,type:"bpmn:SequenceFlow"}]}if(J.type==="schedule"){let M=J.childs[0];if(M){let R=t({...Q,parent:J,bpmnType:"bpmn:StartEvent",type:"timer-start",definitions:[{type:"bpmn:TimerEventDefinition",timerType:"timeCycle",expression:J.context?.cron||"* * * * *"}]});if(R.bpmn.edges=[{from:R.indexKey,to:M.indexKey,type:"bpmn:SequenceFlow"}],j("bpmn"))x.info(`[SCHEDULE] SubProcess + TimerStartEvent: ${J.indexKey} (cron: ${J.context?.cron})`)}}if(_)if(J.type==="schedule"){if(j("bpmn"))x.info(`[SCHEDULE] Skipping normal StartEvent (using TimerStartEvent): ${J.indexKey}`)}else if(J.type==="retry"){let M=t({...Q,parent:J,bpmnType:"bpmn:StartEvent",type:"start"});if(M.bpmn.edges.push({from:M.indexKey,to:_.indexKey,type:"bpmn:SequenceFlow"}),j("bpmn"))x.info(`[RETRY] SubProcess with loop characteristics: ${J.indexKey} (attempts: ${J.context?.attempts})`)}else if(J.type==="parallel"){let M=t({...Q,parent:J,bpmnType:"bpmn:StartEvent",type:"start"}),R=t({...Q,parent:J,bpmnType:"bpmn:ParallelGateway",type:"fork"}),F=t({...Q,parent:J,bpmnType:"bpmn:ParallelGateway",type:"join"}),w=t({...Q,parent:J,bpmnType:"bpmn:EndEvent",type:"end"});M.bpmn.edges=[{from:M.indexKey,to:R.indexKey,type:"bpmn:SequenceFlow"}];let y=J.childs.filter((v)=>!v.virtual&&!v.module&&!v.indexKey.endsWith("/_inline_end"));if(R.bpmn.edges=y.map((v)=>{return{from:R.indexKey,to:v.indexKey,type:"bpmn:SequenceFlow"}}),y.forEach((v)=>{v.bpmn.edges=[{from:v.indexKey,to:F.indexKey,type:"bpmn:SequenceFlow"}]}),F.bpmn.edges=[{from:F.indexKey,to:w.indexKey,type:"bpmn:SequenceFlow"}],j("bpmn"))x.info(`[PARALLEL] Fork/Join Gateways: ${J.indexKey} (${y.length} children)`)}else if(J.bpmn.starts.length>1){let M=t({...Q,parent:J,bpmnType:"bpmn:StartEvent",type:"start"}),R=t({...Q,parent:J,bpmnType:"bpmn:ExclusiveGateway",type:"switch"});M.bpmn.edges=[{from:M.indexKey,to:R.indexKey,type:"bpmn:SequenceFlow"}],R.bpmn.edges=J.bpmn.starts.map((w)=>{return{...w,from:R.indexKey}});let F=R.bpmn.edges.find((w)=>w.next===!0);if(F){let w=t({...Q,parent:J,bpmnType:"bpmn:EndEvent",type:"end",name:F.to});F.to=w.indexKey}}else{let M=t({...Q,parent:J,bpmnType:"bpmn:StartEvent",type:"start"});M.bpmn.edges.push({from:M.indexKey,to:_.indexKey,type:"bpmn:SequenceFlow"})}else if(j("bpmn"))x.info(`[START-EVENT] skipped (no valid firstNode): ${J.indexKey}`);J.childs.filter((M)=>M.virtual!==!0&&M.bpmn.outside.length&&M.bpmn.type!=="bpmn:EndEvent").forEach((M)=>{M.bpmn.outside.forEach((R)=>{let F=Y.indexOf(J),w=t({...Q,parent:J,bpmnType:"bpmn:EndEvent",type:"end",name:R.to,location:F+1});M.bpmn.edges.push({from:M.indexKey,to:w.indexKey,type:"bpmn:SequenceFlow"})})}),J.childs.filter((M)=>M.virtual!==!0&&M.bpmn.edges.length>1).forEach((M)=>{let R=Y.indexOf(M),F=t({...Q,parent:J,bpmnType:"bpmn:ExclusiveGateway",type:"switch",location:R+1});F.bpmn.edges=M.bpmn.edges.map((w)=>{return{...w,from:F.indexKey}}),M.bpmn.edges=[{from:M.indexKey,to:F.indexKey,type:"bpmn:SequenceFlow"}],M.bpmn.outside=[]})}g6({...Q,targetNodes:J.childs})})}function t(Q){let{parent:Z,nodes:X,nodeIndex:q,bpmnType:Y,type:J,name:H,outside:W,location:V,definitions:K,attrs:G}=Q,_=Z.childs.filter((O)=>O.type===`v${J}`).length;if(j("bpmn"))x.info(`[VIRTUAL] ${J.toUpperCase()} → ${Y}: ${Z.indexKey}/_${J}${_}`);let z={indexKey:`${Z.indexKey}/_${J}${_}`,pathKey:`${Z.pathKey}._${J}${_}`,type:`v${J}`,name:H,bpmn:{edges:[],outside:[],type:Y,width:36,height:36,fill:"#c8e6c9",stroke:"#205022",definitions:K,attrs:G},virtual:!0,childs:[]};return Z.childs.splice(V||0,0,z),X.push(z),q[z.indexKey]=z,z}function m6(Q){let{targetNode:Z,targetFlowElementsContainer:X,targetPlaneElement:q,moddle:Y,elementIndex:J,nodeIndex:H,diagrams:W,nodes:V}=Q;V5(Q),K5(Q),z5(Q),G5(Q)}function V5(Q){let{targetNode:Z,targetFlowElementsContainer:X,targetPlaneElement:q,moddle:Y,elementIndex:J,nodeIndex:H,nodes:W}=Q,V=X.get("flowElements");if(X.$nodes=X.$nodes||[],j("bpmn"))x.info(`[BPMN] Creating elements for: ${Z.indexKey} (${Z.childs.length} children)`);Z.childs.forEach((K)=>{let G=Y.create(K.bpmn.type,{id:`node.${K.pathKey}`,name:K.definition?.title||K.name});if(J[G.id]=G,G.$isNode=!0,G.$node=K,K.$flow=G,X.$nodes.push(G),V.push(G),K.bpmn.type==="bpmn:CallActivity"&&K.context?.lib){if(G.calledElement=K.context.lib.name,j("bpmn"))x.info(`[CREATED] ${K.bpmn.type} (chip!): ${G.id} → ${G.calledElement}`)}else if(j("bpmn"))x.info(`[CREATED] ${K.bpmn.type}: ${G.id}${K.virtual?" (virtual)":""}`);if(K.bpmn.attrs)Object.keys(K.bpmn.attrs).forEach((z)=>{if(z==="attachedToRef")G.set(z,K.bpmn.attrs[z].$flow)});if(K.bpmn.definitions){let _=K.bpmn.definitions.map((z)=>{let O=Y.create(z.type);return Object.keys(z.attrs||{}).forEach((A)=>{O.set(A,z.attrs[A])}),O});G.eventDefinitions=_}if(K.bpmn.loopCharacteristics&&K.bpmn.type==="bpmn:SubProcess"){if(G.loopCharacteristics=Y.create("bpmn:StandardLoopCharacteristics"),j("bpmn"))x.info(`[LOOP] Added loop marker to: ${G.id} (${K.type})`)}})}function K5(Q){let{targetNode:Z,targetFlowElementsContainer:X,targetPlaneElement:q,moddle:Y,elementIndex:J,nodeIndex:H}=Q,W=X.get("flowElements");X.$edges=X.$edges||[],Z.childs.forEach((V)=>{V.bpmn.edges.forEach((G)=>{let _=V,z=H[G.to],O=`edge.${_.pathKey}_${z.pathKey}`;if(J[O])return;let $=J[`node.${_.pathKey}`],A=J[`node.${z.pathKey}`],U=Y.create(G.type,{id:O,sourceRef:$,targetRef:A});J[U.id]=U,U.$is_edge=!0,$.get("outgoing").push(U),A.get("incoming").push(U),X.$edges.push({from:$,to:A,flow:U}),W.push(U)})})}function z5(Q){let{targetNode:Z,targetFlowElementsContainer:X,targetPlaneElement:q,moddle:Y,elementIndex:J,nodeIndex:H}=Q,W=120,V=80,K=160,G=160,_=new A9.graphlib.Graph;_.setDefaultEdgeLabel(()=>({})),_.setGraph({rankdir:"TB",nodesep:120,ranksep:80,xranker:"longest-path"}),X.$nodes.forEach((z)=>{_.setNode(z.id,{width:z.$node?.bpmn.width||120,height:z.$node?.bpmn.height||80,label:z.id})}),X.$edges.forEach((z)=>{_.setEdge(z.from.id,z.to.id)}),A9.layout(_),X.$nodes.forEach((z)=>{let O=_.node(z.id),$=O.width,A=O.height,U=Y.create("bpmndi:BPMNShape",{id:`shape.${z.id}`,bpmnElement:z,bounds:Y.create("dc:Bounds",{x:160+O.x-O.width/2,y:160+O.y-O.height/2,width:$,height:A}),label:Y.create("bpmndi:BPMNLabel")});if(z.$node.bpmn.fill)U.set("bioc:fill",z.$node.bpmn.fill);if(z.$node.bpmn.stroke)U.set("bioc:stroke",z.$node.bpmn.stroke);q.get("planeElement").push(U)}),X.$edges.forEach((z)=>{let O=_.edge(z.from.id,z.to.id),$=Y.create("bpmndi:BPMNEdge",{id:`edge.${z.from.id}_${z.to.id}`,bpmnElement:z.flow,label:Y.create("bpmndi:BPMNLabel")});O.points.forEach((U)=>{let B=Y.create("dc:Point",{x:160+U.x,y:160+U.y});$.get("waypoint").push(B)}),q.get("planeElement").push($)})}function G5(Q){let{targetNode:Z,targetFlowElementsContainer:X,targetPlaneElement:q,moddle:Y,elementIndex:J,nodeIndex:H,diagrams:W}=Q;Z.childs.filter((K)=>K.bpmn.type==="bpmn:SubProcess").forEach((K)=>{let G=J[`node.${K.pathKey}`],_=Y.create("bpmndi:BPMNDiagram",{id:`diagram_${K.pathKey}`});J[_.id]=_,W.push(_);let z=Y.create("bpmndi:BPMNPlane",{id:`plane_${K.pathKey}`});J[z.id]=z,_.plane=z,z.bpmnElement=G,m6({...Q,targetNode:K,targetFlowElementsContainer:G,targetPlaneElement:z})})}async function _5(Q){let Z=Q.root,X=Z.context.index,q=Object.keys(X).map((K)=>X[K]);R9({nodes:q,nodeIndex:X,root:Z}),g6({nodes:q,nodeIndex:X,root:Z});let Y=void 0,J=new B9({atom:u6}),H={},W=J.create("bpmn:Definitions",{id:"definitions_0"});H[W.id]=W;for await(let K of Z.childs){let G=W.get("rootElements"),_=W.get("diagrams"),z=J.create("bpmn:Process",{id:`process_${K.pathKey}`,name:K.name,documentation:[J.create("bpmn:Documentation",{text:`Workflow - ${K.name}`})]});H[z.id]=z,z.isExecutable=!0,G.push(z);let O=J.create("bpmndi:BPMNDiagram",{id:`diagram_${K.pathKey}`});H[O.id]=O,_.push(O);let $=J.create("bpmndi:BPMNPlane",{id:`plane_${K.pathKey}`});H[$.id]=$,O.plane=$,$.bpmnElement=z,m6({targetNode:K,targetFlowElementsContainer:z,targetPlaneElement:$,moddle:J,elementIndex:H,nodeIndex:X,nodes:q,diagrams:_})}let V=await J.toXML(W,{format:!0});return{diagramXML:Y||V.xml}}async function U5(Q){let{root:Z,flowName:X}=Q,q=h6(Z),Y=q.childs.find((F)=>F.name===X);if(!Y)throw Error(`Flow "${X}" not found`);let J={...q,childs:[Y]},H=J.context.index,W=Object.keys(H).map((F)=>H[F]);R9({nodes:W,nodeIndex:H,root:J}),g6({nodes:W,nodeIndex:H,root:J});let V=new B9({atom:u6}),K={},G=V.create("bpmn:Definitions",{id:`definitions_${X}`});K[G.id]=G;let _=G.get("rootElements"),z=G.get("diagrams"),O=V.create("bpmn:Process",{id:`process_${Y.pathKey}`,name:Y.name,documentation:[V.create("bpmn:Documentation",{text:`Workflow - ${Y.name}`})]});K[O.id]=O,O.isExecutable=!0,_.push(O);let $=V.create("bpmndi:BPMNDiagram",{id:`diagram_${Y.pathKey}`});K[$.id]=$,z.push($);let A=V.create("bpmndi:BPMNPlane",{id:`plane_${Y.pathKey}`});return K[A.id]=A,$.plane=A,A.bpmnElement=O,m6({targetNode:Y,targetFlowElementsContainer:O,targetPlaneElement:A,moddle:V,elementIndex:K,nodeIndex:H,nodes:W,diagrams:z}),{diagramXML:(await V.toXML(G,{format:!0})).xml,flowName:Y.name}}async function F8(Q={}){return await _5(h6(Q))}async function I9(Q={}){let Z=h6(Q),{root:X}=Z,q=[];for(let Y of X.childs){let J=await U5({root:X,flowName:Y.name});q.push(J)}return q}import Q2 from"@fnet/config";import Z2 from"@flownet/lib-parse-imports-js";class j8 extends SyntaxError{constructor(Q,Z,X,q){super(Q);this.expected=Z,this.found=X,this.location=q,this.name="SyntaxError"}format(Q){let Z="Error: "+this.message;if(this.location){let X=null,q=Q.find((W)=>W.source===this.location.source);if(q)X=q.text.split(/\r\n|\n|\r/g);let Y=this.location.start,J=this.location.source&&typeof this.location.source.offset==="function"?this.location.source.offset(Y):Y,H=this.location.source+":"+J.line+":"+J.column;if(X){let W=this.location.end,V="".padEnd(J.line.toString().length," "),K=X[Y.line-1],_=(Y.line===W.line?W.column:K.length+1)-Y.column||1;Z+=`
|
|
5
5
|
--> `+H+`
|
|
6
6
|
`+V+` |
|
|
7
7
|
`+J.line+" | "+K+`
|
|
8
|
-
`+V+" | "+"".padEnd(Y.column-1," ")+"".padEnd(
|
|
9
|
-
at `+H}return Z}static buildMessage(Q,Z){function X(G){return G.codePointAt(0).toString(16).toUpperCase()}let q=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function Y(G){if(q)return G.replace(q,(_)=>"\\u{"+X(_)+"}");return G}function J(G){return Y(G.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(_)=>"\\x0"+X(_)).replace(/[\x10-\x1F\x7F-\x9F]/g,(_)=>"\\x"+X(_)))}function H(G){return Y(G.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(_)=>"\\x0"+X(_)).replace(/[\x10-\x1F\x7F-\x9F]/g,(_)=>"\\x"+X(_)))}let W={literal(G){return'"'+J(G.text)+'"'},class(G){let _=G.parts.map((O)=>Array.isArray(O)?H(O[0])+"-"+H(O[1]):H(O));return"["+(G.inverted?"^":"")+_.join("")+"]"+(G.unicode?"u":"")},any(){return"any character"},end(){return"end of input"},other(G){return G.description}};function V(G){return W[G.type](G)}function K(G){let _=G.map(V);if(_.sort(),_.length>0){let O=1;for(let $=1;$<_.length;$++)if(_[$-1]!==_[$])_[O]=_[$],O++;_.length=O}switch(_.length){case 1:return _[0];case 2:return _[0]+" or "+_[1];default:return _.slice(0,-1).join(", ")+", or "+_[_.length-1]}}function z(G){return G?'"'+J(G)+'"':"end of input"}return"Expected "+K(Q)+" but "+z(Z)+" found."}}function F9(Q,Z){Z=Z!==void 0?Z:{};let X={},q=Z.grammarSource,Y={Start:y7},J=y7,H="::",W=/^[a-z]/,V=/^[a-z0-9_\-]/,K=/^[^s]/,z=/^[sS]/,G=RZ("::",!1),_=O8([["a","z"]],!1,!1,!1),O=O8([["a","z"],["0","9"],"_","-"],!1,!1,!1),$=O8(["s"],!0,!1,!1),A=O8(["s","S"],!1,!1,!1);function U(I){return SZ(I)}function B(I,C){let w=I+"::"+C,l=wZ(I,C,w);try{let u=parse(C);if(u)l.next=u}catch(u){}return l}let M=Z.peg$currPos|0,R=M,F=[{line:1,column:1}],S=M,y=Z.peg$maxFailExpected||[],v=Z.peg$silentFails|0,Y0;if(Z.startRule){if(!(Z.startRule in Y))throw Error(`Can't start parsing from rule "`+Z.startRule+'".');J=Y[Z.startRule]}function J0(){return Q.substring(R,M)}function k7(){return R}function b2(){return{source:q,start:R,end:M}}function k2(){return p0(R,M)}function D2(I,C){throw C=C!==void 0?C:p0(R,M),v7([CZ(I)],Q.substring(R,M),C)}function v2(I,C){throw C=C!==void 0?C:p0(R,M),LZ(I,C)}function BZ(I=M){let C=Q.codePointAt(I);if(C===void 0)return"";return String.fromCodePoint(C)}function RZ(I,C){return{type:"literal",text:I,ignoreCase:C}}function O8(I,C,w,l){return{type:"class",parts:I,inverted:C,ignoreCase:w,unicode:l}}function y2(){return{type:"any"}}function IZ(){return{type:"end"}}function CZ(I){return{type:"other",description:I}}function D7(I){let C=F[I],w;if(C)return C;else{if(I>=F.length)w=F.length-1;else{w=I;while(!F[--w]);}C=F[w],C={line:C.line,column:C.column};while(w<I){if(Q.charCodeAt(w)===10)C.line++,C.column=1;else C.column++;w++}return F[I]=C,C}}function p0(I,C,w){let l=D7(I),u=D7(C),a0={source:q,start:{offset:I,line:l.line,column:l.column},end:{offset:C,line:u.line,column:u.column}};if(w&&q&&typeof q.offset==="function")a0.start=q.offset(a0.start),a0.end=q.offset(a0.end);return a0}function j0(I){if(M<S)return;if(M>S)S=M,y=[];y.push(I)}function LZ(I,C){return new T8(I,null,null,C)}function v7(I,C,w){return new T8(T8.buildMessage(I,C),I,C,w)}function y7(){let I,C;if(I=M,C=FZ(),C!==X)R=I,C=U(C);return I=C,I}function FZ(){let I,C,w,l;if(I=M,C=jZ(),C!==X){if(Q.substr(M,2)===H)w=H,M+=2;else if(w=X,v===0)j0(G);if(w!==X)if(l=TZ(),l!==X)R=I,I=B(C,l);else M=I,I=X;else M=I,I=X}else M=I,I=X;return I}function jZ(){let I,C,w,l,u;if(I=M,C=M,w=Q.charAt(M),W.test(w))M++;else if(w=X,v===0)j0(_);if(w!==X){if(l=[],u=Q.charAt(M),V.test(u))M++;else if(u=X,v===0)j0(O);while(u!==X)if(l.push(u),u=Q.charAt(M),V.test(u))M++;else if(u=X,v===0)j0(O);w=[w,l],C=w}else M=C,C=X;if(C!==X)I=Q.substring(I,M);else I=C;return I}function TZ(){let I,C,w,l,u;if(I=M,C=M,w=Q.charAt(M),K.test(w))M++;else if(w=X,v===0)j0($);if(w!==X){if(l=[],u=Q.charAt(M),z.test(u))M++;else if(u=X,v===0)j0(A);while(u!==X)if(l.push(u),u=Q.charAt(M),z.test(u))M++;else if(u=X,v===0)j0(A);w=[w,l],C=w}else M=C,C=X;if(C!==X)I=Q.substring(I,M);else I=C;return I}function wZ(I,C,w){return{processor:I,statement:C,expression:w}}function E7(I){if(!I)return[];let C=I.next?E7(I.next):[];return C.push(I.processor),C}function SZ(I){if(!I)return null;let C=I;while(C&&C.next)C=C.next;let w={processor:I.processor,statement:I.statement,expression:I.expression,process:{statement:C.statement,order:E7(I)}};if(I.next)w.next=I.next;return w}Y0=J();let t8=Y0!==X&&M===Q.length;function x7(){if(Y0!==X&&M<Q.length)j0(IZ());throw v7(y,S<Q.length?BZ(S):null,S<Q.length?p0(S,S+1):p0(S,S))}if(Z.peg$library)return{peg$result:Y0,peg$currPos:M,peg$FAILED:X,peg$maxFailExpected:y,peg$maxFailPos:S,peg$success:t8,peg$throw:t8?void 0:x7};if(t8)return Y0;else x7()}function N0(Q,Z=!1){if(typeof Q!=="string")return null;let X=Q.match(/^([a-z][a-z0-9_-]*)::/);if(!X)return null;let q=X[1];if(!Z)return q;let Y=Q.slice(Q.indexOf("::")+2);return{processor:q,statement:Y}}function T9({expression:Q,depth:Z=5}){if(Z<=0)return null;let X=/^([a-z][a-z0-9_-]*)::([^\s][\s\S]*)$/,q;if(X.test(Q))q=Q.match(X);else return null;let Y=q[1],J=q[2],H=T9({expression:J,depth:Z-1}),W={processor:Y,statement:J,expression:Q};if(H)W.next=H;return W}function w9(Q){if(!Q)return[];let Z=w9(Q.next);return Z.push(Q.processor),Z}function j9({expression:Q}){let Z=T9({expression:Q});if(!Z)return null;let X=Z;while(X&&X.next)X=X.next;let q={processor:Z.processor,statement:Z.statement,expression:Z.expression,process:{statement:X.statement,order:w9(Z)}};if(Z.next)q.next=Z.next;return q}function O5(Q,Z){let X=Q.statement,q=/([a-z][a-z0-9_-]*)::([a-zA-Z_$][a-zA-Z0-9_$]*)/g;return X=X.replace(q,(Y,J,H)=>{if(Z[J]){let W=Z[J];if(typeof W==="function")return W(H);if(typeof W==="string")return W.replace(/\{stmt\}/g,H)}return Y}),X}function l6({expression:Q,useGrammar:Z=!0,multiline:X=!0,transform:q}){if(typeof Q!=="string")Q=String(Q);if(X)Q=Q.replace(/\n+$/,"");let Y;if(Z)try{Y=F9(Q)}catch(J){Y=j9({expression:Q})}else Y=j9({expression:Q});if(!Y)return null;if(q){if(q[Y.processor]&&!Y.next){let J=q[Y.processor];if(typeof J==="function")Y.transformed=J(Y.statement);else if(typeof J==="string")Y.transformed=J.replace(/\{stmt\}/g,Y.statement)}else if(Y.statement)Y.transformed=O5(Y,q)}return Y}import Y2 from"@fnet/yaml";import J2 from"chalk";var n9=D5(g9(),1);var o0=(Q)=>{if(typeof Q!=="string")throw TypeError("invalid pattern");if(Q.length>65536)throw TypeError("pattern is too long")};var j5={"[: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]},t0=(Q)=>Q.replace(/[[\]\\-]/g,"\\$&"),T5=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),m9=(Q)=>Q.join(""),c9=(Q,Z)=>{let X=Z;if(Q.charAt(X)!=="[")throw Error("not in a brace expression");let q=[],Y=[],J=X+1,H=!1,W=!1,V=!1,K=!1,z=X,G="";Q:while(J<Q.length){let A=Q.charAt(J);if((A==="!"||A==="^")&&J===X+1){K=!0,J++;continue}if(A==="]"&&H&&!V){z=J+1;break}if(H=!0,A==="\\"){if(!V){V=!0,J++;continue}}if(A==="["&&!V){for(let[U,[B,M,R]]of Object.entries(j5))if(Q.startsWith(U,J)){if(G)return["$.",!1,Q.length-X,!0];if(J+=U.length,R)Y.push(B);else q.push(B);W=W||M;continue Q}}if(V=!1,G){if(A>G)q.push(t0(G)+"-"+t0(A));else if(A===G)q.push(t0(A));G="",J++;continue}if(Q.startsWith("-]",J+1)){q.push(t0(A+"-")),J+=2;continue}if(Q.startsWith("-",J+1)){G=A,J+=2;continue}q.push(t0(A)),J++}if(z<J)return["",!1,0,!1];if(!q.length&&!Y.length)return["$.",!1,Q.length-X,!0];if(Y.length===0&&q.length===1&&/^\\?.$/.test(q[0])&&!K){let A=q[0].length===2?q[0].slice(-1):q[0];return[T5(A),!1,z-X,!1]}let _="["+(K?"^":"")+m9(q)+"]",O="["+(K?"":"^")+m9(Y)+"]";return[q.length&&Y.length?"("+_+"|"+O+")":q.length?_:O,W,z-X,!0]};var z0=(Q,{windowsPathsNoEscape:Z=!1}={})=>{return Z?Q.replace(/\[([^\/\\])\]/g,"$1"):Q.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var w5=new Set(["!","?","+","*","@"]),l9=(Q)=>w5.has(Q),S5="(?!(?:^|/)\\.\\.?(?:$|/))",w8="(?!\\.)",N5=new Set(["[","."]),P5=new Set(["..","."]),b5=new Set("().*{}+?[]^$\\!"),k5=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),p6="[^/]",d9=p6+"*?",i9=p6+"+?";class a{type;#Z;#Q;#X=!1;#q=[];#J;#C;#I;#K=!1;#G;#V;#z=!1;constructor(Q,Z,X={}){if(this.type=Q,Q)this.#Q=!0;if(this.#J=Z,this.#Z=this.#J?this.#J.#Z:this,this.#G=this.#Z===this?X:this.#Z.#G,this.#I=this.#Z===this?[]:this.#Z.#I,Q==="!"&&!this.#Z.#K)this.#I.push(this);this.#C=this.#J?this.#J.#q.length:0}get hasMagic(){if(this.#Q!==void 0)return this.#Q;for(let Q of this.#q){if(typeof Q==="string")continue;if(Q.type||Q.hasMagic)return this.#Q=!0}return this.#Q}toString(){if(this.#V!==void 0)return this.#V;if(!this.type)return this.#V=this.#q.map((Q)=>String(Q)).join("");else return this.#V=this.type+"("+this.#q.map((Q)=>String(Q)).join("|")+")"}#Y(){if(this!==this.#Z)throw Error("should only call on root");if(this.#K)return this;this.toString(),this.#K=!0;let Q;while(Q=this.#I.pop()){if(Q.type!=="!")continue;let Z=Q,X=Z.#J;while(X){for(let q=Z.#C+1;!X.type&&q<X.#q.length;q++)for(let Y of Q.#q){if(typeof Y==="string")throw Error("string part in extglob AST??");Y.copyIn(X.#q[q])}Z=X,X=Z.#J}}return this}push(...Q){for(let Z of Q){if(Z==="")continue;if(typeof Z!=="string"&&!(Z instanceof a&&Z.#J===this))throw Error("invalid part: "+Z);this.#q.push(Z)}}toJSON(){let Q=this.type===null?this.#q.slice().map((Z)=>typeof Z==="string"?Z:Z.toJSON()):[this.type,...this.#q.map((Z)=>Z.toJSON())];if(this.isStart()&&!this.type)Q.unshift([]);if(this.isEnd()&&(this===this.#Z||this.#Z.#K&&this.#J?.type==="!"))Q.push({});return Q}isStart(){if(this.#Z===this)return!0;if(!this.#J?.isStart())return!1;if(this.#C===0)return!0;let Q=this.#J;for(let Z=0;Z<this.#C;Z++){let X=Q.#q[Z];if(!(X instanceof a&&X.type==="!"))return!1}return!0}isEnd(){if(this.#Z===this)return!0;if(this.#J?.type==="!")return!0;if(!this.#J?.isEnd())return!1;if(!this.type)return this.#J?.isEnd();let Q=this.#J?this.#J.#q.length:0;return this.#C===Q-1}copyIn(Q){if(typeof Q==="string")this.push(Q);else this.push(Q.clone(this))}clone(Q){let Z=new a(this.type,Q);for(let X of this.#q)Z.copyIn(X);return Z}static#O(Q,Z,X,q){let Y=!1,J=!1,H=-1,W=!1;if(Z.type===null){let _=X,O="";while(_<Q.length){let $=Q.charAt(_++);if(Y||$==="\\"){Y=!Y,O+=$;continue}if(J){if(_===H+1){if($==="^"||$==="!")W=!0}else if($==="]"&&!(_===H+2&&W))J=!1;O+=$;continue}else if($==="["){J=!0,H=_,W=!1,O+=$;continue}if(!q.noext&&l9($)&&Q.charAt(_)==="("){Z.push(O),O="";let A=new a($,Z);_=a.#O(Q,A,_,q),Z.push(A);continue}O+=$}return Z.push(O),_}let V=X+1,K=new a(null,Z),z=[],G="";while(V<Q.length){let _=Q.charAt(V++);if(Y||_==="\\"){Y=!Y,G+=_;continue}if(J){if(V===H+1){if(_==="^"||_==="!")W=!0}else if(_==="]"&&!(V===H+2&&W))J=!1;G+=_;continue}else if(_==="["){J=!0,H=V,W=!1,G+=_;continue}if(l9(_)&&Q.charAt(V)==="("){K.push(G),G="";let O=new a(_,K);K.push(O),V=a.#O(Q,O,V,q);continue}if(_==="|"){K.push(G),G="",z.push(K),K=new a(null,Z);continue}if(_===")"){if(G===""&&Z.#q.length===0)Z.#z=!0;return K.push(G),G="",Z.push(...z,K),V}G+=_}return Z.type=null,Z.#Q=void 0,Z.#q=[Q.substring(X-1)],V}static fromGlob(Q,Z={}){let X=new a(null,void 0,Z);return a.#O(Q,X,0,Z),X}toMMPattern(){if(this!==this.#Z)return this.#Z.toMMPattern();let Q=this.toString(),[Z,X,q,Y]=this.toRegExpSource();if(!(q||this.#Q||this.#G.nocase&&!this.#G.nocaseMagicOnly&&Q.toUpperCase()!==Q.toLowerCase()))return X;let H=(this.#G.nocase?"i":"")+(Y?"u":"");return Object.assign(new RegExp(`^${Z}$`,H),{_src:Z,_glob:Q})}get options(){return this.#G}toRegExpSource(Q){let Z=Q??!!this.#G.dot;if(this.#Z===this)this.#Y();if(!this.type){let W=this.isStart()&&this.isEnd(),V=this.#q.map((_)=>{let[O,$,A,U]=typeof _==="string"?a.#$(_,this.#Q,W):_.toRegExpSource(Q);return this.#Q=this.#Q||A,this.#X=this.#X||U,O}).join(""),K="";if(this.isStart()){if(typeof this.#q[0]==="string"){if(!(this.#q.length===1&&P5.has(this.#q[0]))){let O=N5,$=Z&&O.has(V.charAt(0))||V.startsWith("\\.")&&O.has(V.charAt(2))||V.startsWith("\\.\\.")&&O.has(V.charAt(4)),A=!Z&&!Q&&O.has(V.charAt(0));K=$?S5:A?w8:""}}}let z="";if(this.isEnd()&&this.#Z.#K&&this.#J?.type==="!")z="(?:$|\\/)";return[K+V+z,z0(V),this.#Q=!!this.#Q,this.#X]}let X=this.type==="*"||this.type==="+",q=this.type==="!"?"(?:(?!(?:":"(?:",Y=this.#M(Z);if(this.isStart()&&this.isEnd()&&!Y&&this.type!=="!"){let W=this.toString();return this.#q=[W],this.type=null,this.#Q=void 0,[W,z0(this.toString()),!1,!1]}let J=!X||Q||Z||!w8?"":this.#M(!0);if(J===Y)J="";if(J)Y=`(?:${Y})(?:${J})*?`;let H="";if(this.type==="!"&&this.#z)H=(this.isStart()&&!Z?w8:"")+i9;else{let W=this.type==="!"?"))"+(this.isStart()&&!Z&&!Q?w8:"")+d9+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&J?")":this.type==="*"&&J?")?":`)${this.type}`;H=q+Y+W}return[H,z0(Y),this.#Q=!!this.#Q,this.#X]}#M(Q){return this.#q.map((Z)=>{if(typeof Z==="string")throw Error("string type in extglob ast??");let[X,q,Y,J]=Z.toRegExpSource(Q);return this.#X=this.#X||J,X}).filter((Z)=>!(this.isStart()&&this.isEnd())||!!Z).join("|")}static#$(Q,Z,X=!1){let q=!1,Y="",J=!1;for(let H=0;H<Q.length;H++){let W=Q.charAt(H);if(q){q=!1,Y+=(b5.has(W)?"\\":"")+W;continue}if(W==="\\"){if(H===Q.length-1)Y+="\\\\";else q=!0;continue}if(W==="["){let[V,K,z,G]=c9(Q,H);if(z){Y+=V,J=J||K,H+=z-1,Z=Z||G;continue}}if(W==="*"){if(X&&Q==="*")Y+=i9;else Y+=d9;Z=!0;continue}if(W==="?"){Y+=p6,Z=!0;continue}Y+=k5(W)}return[Y,z0(Q),!!Z,J]}}var g0=(Q,{windowsPathsNoEscape:Z=!1}={})=>{return Z?Q.replace(/[?*()[\]]/g,"[$&]"):Q.replace(/[?*()[\]\\]/g,"\\$&")};var Q0=(Q,Z,X={})=>{if(o0(Z),!X.nocomment&&Z.charAt(0)==="#")return!1;return new H0(Z,X).match(Q)},v5=/^\*+([^+@!?\*\[\(]*)$/,y5=(Q)=>(Z)=>!Z.startsWith(".")&&Z.endsWith(Q),E5=(Q)=>(Z)=>Z.endsWith(Q),x5=(Q)=>{return Q=Q.toLowerCase(),(Z)=>!Z.startsWith(".")&&Z.toLowerCase().endsWith(Q)},u5=(Q)=>{return Q=Q.toLowerCase(),(Z)=>Z.toLowerCase().endsWith(Q)},f5=/^\*+\.\*+$/,h5=(Q)=>!Q.startsWith(".")&&Q.includes("."),g5=(Q)=>Q!=="."&&Q!==".."&&Q.includes("."),m5=/^\.\*+$/,c5=(Q)=>Q!=="."&&Q!==".."&&Q.startsWith("."),l5=/^\*+$/,d5=(Q)=>Q.length!==0&&!Q.startsWith("."),i5=(Q)=>Q.length!==0&&Q!=="."&&Q!=="..",p5=/^\?+([^+@!?\*\[\(]*)?$/,a5=([Q,Z=""])=>{let X=r9([Q]);if(!Z)return X;return Z=Z.toLowerCase(),(q)=>X(q)&&q.toLowerCase().endsWith(Z)},n5=([Q,Z=""])=>{let X=s9([Q]);if(!Z)return X;return Z=Z.toLowerCase(),(q)=>X(q)&&q.toLowerCase().endsWith(Z)},r5=([Q,Z=""])=>{let X=s9([Q]);return!Z?X:(q)=>X(q)&&q.endsWith(Z)},s5=([Q,Z=""])=>{let X=r9([Q]);return!Z?X:(q)=>X(q)&&q.endsWith(Z)},r9=([Q])=>{let Z=Q.length;return(X)=>X.length===Z&&!X.startsWith(".")},s9=([Q])=>{let Z=Q.length;return(X)=>X.length===Z&&X!=="."&&X!==".."},o9=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",p9={win32:{sep:"\\"},posix:{sep:"/"}},o5=o9==="win32"?p9.win32.sep:p9.posix.sep;Q0.sep=o5;var n=Symbol("globstar **");Q0.GLOBSTAR=n;var t5="[^/]",e5=t5+"*?",Q4="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Z4="(?:(?!(?:\\/|^)\\.).)*?",X4=(Q,Z={})=>(X)=>Q0(X,Q,Z);Q0.filter=X4;var W0=(Q,Z={})=>Object.assign({},Q,Z),q4=(Q)=>{if(!Q||typeof Q!=="object"||!Object.keys(Q).length)return Q0;let Z=Q0;return Object.assign((q,Y,J={})=>Z(q,Y,W0(Q,J)),{Minimatch:class extends Z.Minimatch{constructor(Y,J={}){super(Y,W0(Q,J))}static defaults(Y){return Z.defaults(W0(Q,Y)).Minimatch}},AST:class extends Z.AST{constructor(Y,J,H={}){super(Y,J,W0(Q,H))}static fromGlob(Y,J={}){return Z.AST.fromGlob(Y,W0(Q,J))}},unescape:(q,Y={})=>Z.unescape(q,W0(Q,Y)),escape:(q,Y={})=>Z.escape(q,W0(Q,Y)),filter:(q,Y={})=>Z.filter(q,W0(Q,Y)),defaults:(q)=>Z.defaults(W0(Q,q)),makeRe:(q,Y={})=>Z.makeRe(q,W0(Q,Y)),braceExpand:(q,Y={})=>Z.braceExpand(q,W0(Q,Y)),match:(q,Y,J={})=>Z.match(q,Y,W0(Q,J)),sep:Z.sep,GLOBSTAR:n})};Q0.defaults=q4;var t9=(Q,Z={})=>{if(o0(Q),Z.nobrace||!/\{(?:(?!\{).)*\}/.test(Q))return[Q];return n9.default(Q)};Q0.braceExpand=t9;var Y4=(Q,Z={})=>new H0(Q,Z).makeRe();Q0.makeRe=Y4;var J4=(Q,Z,X={})=>{let q=new H0(Z,X);if(Q=Q.filter((Y)=>q.match(Y)),q.options.nonull&&!Q.length)Q.push(Z);return Q};Q0.match=J4;var a9=/[?*]|[+@!]\(.*?\)|\[|\]/,W4=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class H0{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(Q,Z={}){if(o0(Q),Z=Z||{},this.options=Z,this.pattern=Q,this.platform=Z.platform||o9,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z.allowWindowsEscape===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!Z.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!Z.nonegate,this.comment=!1,this.empty=!1,this.partial=!!Z.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=Z.windowsNoMagicRoot!==void 0?Z.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let Q of this.set)for(let Z of Q)if(typeof Z!=="string")return!0;return!1}debug(...Q){}make(){let Q=this.pattern,Z=this.options;if(!Z.nocomment&&Q.charAt(0)==="#"){this.comment=!0;return}if(!Q){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],Z.debug)this.debug=(...Y)=>console.error(...Y);this.debug(this.pattern,this.globSet);let X=this.globSet.map((Y)=>this.slashSplit(Y));this.globParts=this.preprocess(X),this.debug(this.pattern,this.globParts);let q=this.globParts.map((Y,J,H)=>{if(this.isWindows&&this.windowsNoMagicRoot){let W=Y[0]===""&&Y[1]===""&&(Y[2]==="?"||!a9.test(Y[2]))&&!a9.test(Y[3]),V=/^[a-z]:/i.test(Y[0]);if(W)return[...Y.slice(0,4),...Y.slice(4).map((K)=>this.parse(K))];else if(V)return[Y[0],...Y.slice(1).map((K)=>this.parse(K))]}return Y.map((W)=>this.parse(W))});if(this.debug(this.pattern,q),this.set=q.filter((Y)=>Y.indexOf(!1)===-1),this.isWindows)for(let Y=0;Y<this.set.length;Y++){let J=this.set[Y];if(J[0]===""&&J[1]===""&&this.globParts[Y][2]==="?"&&typeof J[3]==="string"&&/^[a-z]:$/i.test(J[3]))J[2]="?"}this.debug(this.pattern,this.set)}preprocess(Q){if(this.options.noglobstar){for(let X=0;X<Q.length;X++)for(let q=0;q<Q[X].length;q++)if(Q[X][q]==="**")Q[X][q]="*"}let{optimizationLevel:Z=1}=this.options;if(Z>=2)Q=this.firstPhasePreProcess(Q),Q=this.secondPhasePreProcess(Q);else if(Z>=1)Q=this.levelOneOptimize(Q);else Q=this.adjascentGlobstarOptimize(Q);return Q}adjascentGlobstarOptimize(Q){return Q.map((Z)=>{let X=-1;while((X=Z.indexOf("**",X+1))!==-1){let q=X;while(Z[q+1]==="**")q++;if(q!==X)Z.splice(X,q-X)}return Z})}levelOneOptimize(Q){return Q.map((Z)=>{return Z=Z.reduce((X,q)=>{let Y=X[X.length-1];if(q==="**"&&Y==="**")return X;if(q===".."){if(Y&&Y!==".."&&Y!=="."&&Y!=="**")return X.pop(),X}return X.push(q),X},[]),Z.length===0?[""]:Z})}levelTwoFileOptimize(Q){if(!Array.isArray(Q))Q=this.slashSplit(Q);let Z=!1;do{if(Z=!1,!this.preserveMultipleSlashes){for(let q=1;q<Q.length-1;q++){let Y=Q[q];if(q===1&&Y===""&&Q[0]==="")continue;if(Y==="."||Y==="")Z=!0,Q.splice(q,1),q--}if(Q[0]==="."&&Q.length===2&&(Q[1]==="."||Q[1]===""))Z=!0,Q.pop()}let X=0;while((X=Q.indexOf("..",X+1))!==-1){let q=Q[X-1];if(q&&q!=="."&&q!==".."&&q!=="**")Z=!0,Q.splice(X-1,2),X-=2}}while(Z);return Q.length===0?[""]:Q}firstPhasePreProcess(Q){let Z=!1;do{Z=!1;for(let X of Q){let q=-1;while((q=X.indexOf("**",q+1))!==-1){let J=q;while(X[J+1]==="**")J++;if(J>q)X.splice(q+1,J-q);let H=X[q+1],W=X[q+2],V=X[q+3];if(H!=="..")continue;if(!W||W==="."||W===".."||!V||V==="."||V==="..")continue;Z=!0,X.splice(q,1);let K=X.slice(0);K[q]="**",Q.push(K),q--}if(!this.preserveMultipleSlashes){for(let J=1;J<X.length-1;J++){let H=X[J];if(J===1&&H===""&&X[0]==="")continue;if(H==="."||H==="")Z=!0,X.splice(J,1),J--}if(X[0]==="."&&X.length===2&&(X[1]==="."||X[1]===""))Z=!0,X.pop()}let Y=0;while((Y=X.indexOf("..",Y+1))!==-1){let J=X[Y-1];if(J&&J!=="."&&J!==".."&&J!=="**"){Z=!0;let W=Y===1&&X[Y+1]==="**"?["."]:[];if(X.splice(Y-1,2,...W),X.length===0)X.push("");Y-=2}}}}while(Z);return Q}secondPhasePreProcess(Q){for(let Z=0;Z<Q.length-1;Z++)for(let X=Z+1;X<Q.length;X++){let q=this.partsMatch(Q[Z],Q[X],!this.preserveMultipleSlashes);if(q){Q[Z]=[],Q[X]=q;break}}return Q.filter((Z)=>Z.length)}partsMatch(Q,Z,X=!1){let q=0,Y=0,J=[],H="";while(q<Q.length&&Y<Z.length)if(Q[q]===Z[Y])J.push(H==="b"?Z[Y]:Q[q]),q++,Y++;else if(X&&Q[q]==="**"&&Z[Y]===Q[q+1])J.push(Q[q]),q++;else if(X&&Z[Y]==="**"&&Q[q]===Z[Y+1])J.push(Z[Y]),Y++;else if(Q[q]==="*"&&Z[Y]&&(this.options.dot||!Z[Y].startsWith("."))&&Z[Y]!=="**"){if(H==="b")return!1;H="a",J.push(Q[q]),q++,Y++}else if(Z[Y]==="*"&&Q[q]&&(this.options.dot||!Q[q].startsWith("."))&&Q[q]!=="**"){if(H==="a")return!1;H="b",J.push(Z[Y]),q++,Y++}else return!1;return Q.length===Z.length&&J}parseNegate(){if(this.nonegate)return;let Q=this.pattern,Z=!1,X=0;for(let q=0;q<Q.length&&Q.charAt(q)==="!";q++)Z=!Z,X++;if(X)this.pattern=Q.slice(X);this.negate=Z}matchOne(Q,Z,X=!1){let q=this.options;if(this.isWindows){let $=typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0]),A=!$&&Q[0]===""&&Q[1]===""&&Q[2]==="?"&&/^[a-z]:$/i.test(Q[3]),U=typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0]),B=!U&&Z[0]===""&&Z[1]===""&&Z[2]==="?"&&typeof Z[3]==="string"&&/^[a-z]:$/i.test(Z[3]),M=A?3:$?0:void 0,R=B?3:U?0:void 0;if(typeof M==="number"&&typeof R==="number"){let[F,S]=[Q[M],Z[R]];if(F.toLowerCase()===S.toLowerCase()){if(Z[R]=F,R>M)Z=Z.slice(R);else if(M>R)Q=Q.slice(M)}}}let{optimizationLevel:Y=1}=this.options;if(Y>=2)Q=this.levelTwoFileOptimize(Q);this.debug("matchOne",this,{file:Q,pattern:Z}),this.debug("matchOne",Q.length,Z.length);for(var J=0,H=0,W=Q.length,V=Z.length;J<W&&H<V;J++,H++){this.debug("matchOne loop");var K=Z[H],z=Q[J];if(this.debug(Z,K,z),K===!1)return!1;if(K===n){this.debug("GLOBSTAR",[Z,K,z]);var G=J,_=H+1;if(_===V){this.debug("** at the end");for(;J<W;J++)if(Q[J]==="."||Q[J]===".."||!q.dot&&Q[J].charAt(0)===".")return!1;return!0}while(G<W){var O=Q[G];if(this.debug(`
|
|
10
|
-
globstar while`,Q,
|
|
11
|
-
>>> no match, partial?`,Q,G,Z,_),G===W)return!0}return!1}let $;if(typeof K==="string")$=z===K,this.debug("string match",K,z,$);else $=K.test(z),this.debug("pattern match",K,z,$);if(!$)return!1}if(J===W&&H===V)return!0;else if(J===W)return X;else if(H===V)return J===W-1&&Q[J]==="";else throw Error("wtf?")}braceExpand(){return t9(this.pattern,this.options)}parse(Q){o0(Q);let Z=this.options;if(Q==="**")return n;if(Q==="")return"";let X,q=null;if(X=Q.match(l5))q=Z.dot?i5:d5;else if(X=Q.match(v5))q=(Z.nocase?Z.dot?u5:x5:Z.dot?E5:y5)(X[1]);else if(X=Q.match(p5))q=(Z.nocase?Z.dot?n5:a5:Z.dot?r5:s5)(X);else if(X=Q.match(f5))q=Z.dot?g5:h5;else if(X=Q.match(m5))q=c5;let Y=a.fromGlob(Q,this.options).toMMPattern();if(q&&typeof Y==="object")Reflect.defineProperty(Y,"test",{value:q});return Y}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let Q=this.set;if(!Q.length)return this.regexp=!1,this.regexp;let Z=this.options,X=Z.noglobstar?e5:Z.dot?Q4:Z4,q=new Set(Z.nocase?["i"]:[]),Y=Q.map((W)=>{let V=W.map((K)=>{if(K instanceof RegExp)for(let z of K.flags.split(""))q.add(z);return typeof K==="string"?W4(K):K===n?n:K._src});return V.forEach((K,z)=>{let G=V[z+1],_=V[z-1];if(K!==n||_===n)return;if(_===void 0)if(G!==void 0&&G!==n)V[z+1]="(?:\\/|"+X+"\\/)?"+G;else V[z]=X;else if(G===void 0)V[z-1]=_+"(?:\\/|"+X+")?";else if(G!==n)V[z-1]=_+"(?:\\/|\\/"+X+"\\/)"+G,V[z+1]=n}),V.filter((K)=>K!==n).join("/")}).join("|"),[J,H]=Q.length>1?["(?:",")"]:["",""];if(Y="^"+J+Y+H+"$",this.negate)Y="^(?!"+Y+").+$";try{this.regexp=new RegExp(Y,[...q].join(""))}catch(W){this.regexp=!1}return this.regexp}slashSplit(Q){if(this.preserveMultipleSlashes)return Q.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(Q))return["",...Q.split(/\/+/)];else return Q.split(/\/+/)}match(Q,Z=this.partial){if(this.debug("match",Q,this.pattern),this.comment)return!1;if(this.empty)return Q==="";if(Q==="/"&&Z)return!0;let X=this.options;if(this.isWindows)Q=Q.split("\\").join("/");let q=this.slashSplit(Q);this.debug(this.pattern,"split",q);let Y=this.set;this.debug(this.pattern,"set",Y);let J=q[q.length-1];if(!J)for(let H=q.length-2;!J&&H>=0;H--)J=q[H];for(let H=0;H<Y.length;H++){let W=Y[H],V=q;if(X.matchBase&&W.length===1)V=[J];if(this.matchOne(V,W,Z)){if(X.flipNegate)return!0;return!this.negate}}if(X.flipNegate)return!1;return this.negate}static defaults(Q){return Q0.defaults(Q).Minimatch}}Q0.AST=a;Q0.Minimatch=H0;Q0.escape=g0;Q0.unescape=z0;import{fileURLToPath as f4}from"node:url";var m0=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,QQ=new Set,a6=typeof process==="object"&&!!process?process:{},ZQ=(Q,Z,X,q)=>{typeof a6.emitWarning==="function"?a6.emitWarning(Q,Z,X,q):console.error(`[${X}] ${Z}: ${Q}`)},S8=globalThis.AbortController,e9=globalThis.AbortSignal;if(typeof S8>"u"){e9=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(q,Y){this._onabort.push(Y)}},S8=class{constructor(){Z()}signal=new e9;abort(q){if(this.signal.aborted)return;this.signal.reason=q,this.signal.aborted=!0;for(let Y of this.signal._onabort)Y(q);this.signal.onabort?.(q)}};let Q=a6.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",Z=()=>{if(!Q)return;Q=!1,ZQ("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",Z)}}var H4=(Q)=>!QQ.has(Q),oq=Symbol("type"),P0=(Q)=>Q&&Q===Math.floor(Q)&&Q>0&&isFinite(Q),XQ=(Q)=>!P0(Q)?null:Q<=Math.pow(2,8)?Uint8Array:Q<=Math.pow(2,16)?Uint16Array:Q<=Math.pow(2,32)?Uint32Array:Q<=Number.MAX_SAFE_INTEGER?e0:null;class e0 extends Array{constructor(Q){super(Q);this.fill(0)}}class c0{heap;length;static#Z=!1;static create(Q){let Z=XQ(Q);if(!Z)return[];c0.#Z=!0;let X=new c0(Q,Z);return c0.#Z=!1,X}constructor(Q,Z){if(!c0.#Z)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new Z(Q),this.length=0}push(Q){this.heap[this.length++]=Q}pop(){return this.heap[--this.length]}}class Q8{#Z;#Q;#X;#q;#J;#C;#I;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#K;#G;#V;#z;#Y;#O;#M;#$;#A;#j;#R;#F;#H;#L;#_;#T;#B;#b;static unsafeExposeInternals(Q){return{starts:Q.#H,ttls:Q.#L,sizes:Q.#F,keyMap:Q.#V,keyList:Q.#z,valList:Q.#Y,next:Q.#O,prev:Q.#M,get head(){return Q.#$},get tail(){return Q.#A},free:Q.#j,isBackgroundFetch:(Z)=>Q.#U(Z),backgroundFetch:(Z,X,q,Y)=>Q.#E(Z,X,q,Y),moveToTail:(Z)=>Q.#f(Z),indexes:(Z)=>Q.#N(Z),rindexes:(Z)=>Q.#P(Z),isStale:(Z)=>Q.#S(Z)}}get max(){return this.#Z}get maxSize(){return this.#Q}get calculatedSize(){return this.#G}get size(){return this.#K}get fetchMethod(){return this.#C}get memoMethod(){return this.#I}get dispose(){return this.#X}get onInsert(){return this.#q}get disposeAfter(){return this.#J}constructor(Q){let{max:Z=0,ttl:X,ttlResolution:q=1,ttlAutopurge:Y,updateAgeOnGet:J,updateAgeOnHas:H,allowStale:W,dispose:V,onInsert:K,disposeAfter:z,noDisposeOnSet:G,noUpdateTTL:_,maxSize:O=0,maxEntrySize:$=0,sizeCalculation:A,fetchMethod:U,memoMethod:B,noDeleteOnFetchRejection:M,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:F,allowStaleOnFetchAbort:S,ignoreFetchAbort:y}=Q;if(Z!==0&&!P0(Z))throw TypeError("max option must be a nonnegative integer");let v=Z?XQ(Z):Array;if(!v)throw Error("invalid max value: "+Z);if(this.#Z=Z,this.#Q=O,this.maxEntrySize=$||this.#Q,this.sizeCalculation=A,this.sizeCalculation){if(!this.#Q&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw TypeError("sizeCalculation set to non-function")}if(B!==void 0&&typeof B!=="function")throw TypeError("memoMethod must be a function if defined");if(this.#I=B,U!==void 0&&typeof U!=="function")throw TypeError("fetchMethod must be a function if specified");if(this.#C=U,this.#T=!!U,this.#V=new Map,this.#z=Array(Z).fill(void 0),this.#Y=Array(Z).fill(void 0),this.#O=new v(Z),this.#M=new v(Z),this.#$=0,this.#A=0,this.#j=c0.create(Z),this.#K=0,this.#G=0,typeof V==="function")this.#X=V;if(typeof K==="function")this.#q=K;if(typeof z==="function")this.#J=z,this.#R=[];else this.#J=void 0,this.#R=void 0;if(this.#_=!!this.#X,this.#b=!!this.#q,this.#B=!!this.#J,this.noDisposeOnSet=!!G,this.noUpdateTTL=!!_,this.noDeleteOnFetchRejection=!!M,this.allowStaleOnFetchRejection=!!F,this.allowStaleOnFetchAbort=!!S,this.ignoreFetchAbort=!!y,this.maxEntrySize!==0){if(this.#Q!==0){if(!P0(this.#Q))throw TypeError("maxSize must be a positive integer if specified")}if(!P0(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#g()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!J,this.updateAgeOnHas=!!H,this.ttlResolution=P0(q)||q===0?q:1,this.ttlAutopurge=!!Y,this.ttl=X||0,this.ttl){if(!P0(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#W()}if(this.#Z===0&&this.ttl===0&&this.#Q===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Z&&!this.#Q){if(H4("LRU_CACHE_UNBOUNDED"))QQ.add("LRU_CACHE_UNBOUNDED"),ZQ("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",Q8)}}getRemainingTTL(Q){return this.#V.has(Q)?1/0:0}#W(){let Q=new e0(this.#Z),Z=new e0(this.#Z);this.#L=Q,this.#H=Z,this.#k=(Y,J,H=m0.now())=>{if(Z[Y]=J!==0?H:0,Q[Y]=J,J!==0&&this.ttlAutopurge){let W=setTimeout(()=>{if(this.#S(Y))this.#D(this.#z[Y],"expire")},J+1);if(W.unref)W.unref()}},this.#v=(Y)=>{Z[Y]=Q[Y]!==0?m0.now():0},this.#w=(Y,J)=>{if(Q[J]){let H=Q[J],W=Z[J];if(!H||!W)return;Y.ttl=H,Y.start=W,Y.now=X||q();let V=Y.now-W;Y.remainingTTL=H-V}};let X=0,q=()=>{let Y=m0.now();if(this.ttlResolution>0){X=Y;let J=setTimeout(()=>X=0,this.ttlResolution);if(J.unref)J.unref()}return Y};this.getRemainingTTL=(Y)=>{let J=this.#V.get(Y);if(J===void 0)return 0;let H=Q[J],W=Z[J];if(!H||!W)return 1/0;let V=(X||q())-W;return H-V},this.#S=(Y)=>{let J=Z[Y],H=Q[Y];return!!H&&!!J&&(X||q())-J>H}}#v=()=>{};#w=()=>{};#k=()=>{};#S=()=>!1;#g(){let Q=new e0(this.#Z);this.#G=0,this.#F=Q,this.#y=(Z)=>{this.#G-=Q[Z],Q[Z]=0},this.#m=(Z,X,q,Y)=>{if(this.#U(X))return 0;if(!P0(q))if(Y){if(typeof Y!=="function")throw TypeError("sizeCalculation must be a function");if(q=Y(X,Z),!P0(q))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return q},this.#x=(Z,X,q)=>{if(Q[Z]=X,this.#Q){let Y=this.#Q-Q[Z];while(this.#G>Y)this.#u(!0)}if(this.#G+=Q[Z],q)q.entrySize=X,q.totalCalculatedSize=this.#G}}#y=(Q)=>{};#x=(Q,Z,X)=>{};#m=(Q,Z,X,q)=>{if(X||q)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#N({allowStale:Q=this.allowStale}={}){if(this.#K)for(let Z=this.#A;;){if(!this.#c(Z))break;if(Q||!this.#S(Z))yield Z;if(Z===this.#$)break;else Z=this.#M[Z]}}*#P({allowStale:Q=this.allowStale}={}){if(this.#K)for(let Z=this.#$;;){if(!this.#c(Z))break;if(Q||!this.#S(Z))yield Z;if(Z===this.#A)break;else Z=this.#O[Z]}}#c(Q){return Q!==void 0&&this.#V.get(this.#z[Q])===Q}*entries(){for(let Q of this.#N())if(this.#Y[Q]!==void 0&&this.#z[Q]!==void 0&&!this.#U(this.#Y[Q]))yield[this.#z[Q],this.#Y[Q]]}*rentries(){for(let Q of this.#P())if(this.#Y[Q]!==void 0&&this.#z[Q]!==void 0&&!this.#U(this.#Y[Q]))yield[this.#z[Q],this.#Y[Q]]}*keys(){for(let Q of this.#N()){let Z=this.#z[Q];if(Z!==void 0&&!this.#U(this.#Y[Q]))yield Z}}*rkeys(){for(let Q of this.#P()){let Z=this.#z[Q];if(Z!==void 0&&!this.#U(this.#Y[Q]))yield Z}}*values(){for(let Q of this.#N())if(this.#Y[Q]!==void 0&&!this.#U(this.#Y[Q]))yield this.#Y[Q]}*rvalues(){for(let Q of this.#P())if(this.#Y[Q]!==void 0&&!this.#U(this.#Y[Q]))yield this.#Y[Q]}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Q,Z={}){for(let X of this.#N()){let q=this.#Y[X],Y=this.#U(q)?q.__staleWhileFetching:q;if(Y===void 0)continue;if(Q(Y,this.#z[X],this))return this.get(this.#z[X],Z)}}forEach(Q,Z=this){for(let X of this.#N()){let q=this.#Y[X],Y=this.#U(q)?q.__staleWhileFetching:q;if(Y===void 0)continue;Q.call(Z,Y,this.#z[X],this)}}rforEach(Q,Z=this){for(let X of this.#P()){let q=this.#Y[X],Y=this.#U(q)?q.__staleWhileFetching:q;if(Y===void 0)continue;Q.call(Z,Y,this.#z[X],this)}}purgeStale(){let Q=!1;for(let Z of this.#P({allowStale:!0}))if(this.#S(Z))this.#D(this.#z[Z],"expire"),Q=!0;return Q}info(Q){let Z=this.#V.get(Q);if(Z===void 0)return;let X=this.#Y[Z],q=this.#U(X)?X.__staleWhileFetching:X;if(q===void 0)return;let Y={value:q};if(this.#L&&this.#H){let J=this.#L[Z],H=this.#H[Z];if(J&&H){let W=J-(m0.now()-H);Y.ttl=W,Y.start=Date.now()}}if(this.#F)Y.size=this.#F[Z];return Y}dump(){let Q=[];for(let Z of this.#N({allowStale:!0})){let X=this.#z[Z],q=this.#Y[Z],Y=this.#U(q)?q.__staleWhileFetching:q;if(Y===void 0||X===void 0)continue;let J={value:Y};if(this.#L&&this.#H){J.ttl=this.#L[Z];let H=m0.now()-this.#H[Z];J.start=Math.floor(Date.now()-H)}if(this.#F)J.size=this.#F[Z];Q.unshift([X,J])}return Q}load(Q){this.clear();for(let[Z,X]of Q){if(X.start){let q=Date.now()-X.start;X.start=m0.now()-q}this.set(Z,X.value,X)}}set(Q,Z,X={}){if(Z===void 0)return this.delete(Q),this;let{ttl:q=this.ttl,start:Y,noDisposeOnSet:J=this.noDisposeOnSet,sizeCalculation:H=this.sizeCalculation,status:W}=X,{noUpdateTTL:V=this.noUpdateTTL}=X,K=this.#m(Q,Z,X.size||0,H);if(this.maxEntrySize&&K>this.maxEntrySize){if(W)W.set="miss",W.maxEntrySizeExceeded=!0;return this.#D(Q,"set"),this}let z=this.#K===0?void 0:this.#V.get(Q);if(z===void 0){if(z=this.#K===0?this.#A:this.#j.length!==0?this.#j.pop():this.#K===this.#Z?this.#u(!1):this.#K,this.#z[z]=Q,this.#Y[z]=Z,this.#V.set(Q,z),this.#O[this.#A]=z,this.#M[z]=this.#A,this.#A=z,this.#K++,this.#x(z,K,W),W)W.set="add";if(V=!1,this.#b)this.#q?.(Z,Q,"add")}else{this.#f(z);let G=this.#Y[z];if(Z!==G){if(this.#T&&this.#U(G)){G.__abortController.abort(Error("replaced"));let{__staleWhileFetching:_}=G;if(_!==void 0&&!J){if(this.#_)this.#X?.(_,Q,"set");if(this.#B)this.#R?.push([_,Q,"set"])}}else if(!J){if(this.#_)this.#X?.(G,Q,"set");if(this.#B)this.#R?.push([G,Q,"set"])}if(this.#y(z),this.#x(z,K,W),this.#Y[z]=Z,W){W.set="replace";let _=G&&this.#U(G)?G.__staleWhileFetching:G;if(_!==void 0)W.oldValue=_}}else if(W)W.set="update";if(this.#b)this.onInsert?.(Z,Q,Z===G?"update":"replace")}if(q!==0&&!this.#L)this.#W();if(this.#L){if(!V)this.#k(z,q,Y);if(W)this.#w(W,z)}if(!J&&this.#B&&this.#R){let G=this.#R,_;while(_=G?.shift())this.#J?.(..._)}return this}pop(){try{while(this.#K){let Q=this.#Y[this.#$];if(this.#u(!0),this.#U(Q)){if(Q.__staleWhileFetching)return Q.__staleWhileFetching}else if(Q!==void 0)return Q}}finally{if(this.#B&&this.#R){let Q=this.#R,Z;while(Z=Q?.shift())this.#J?.(...Z)}}}#u(Q){let Z=this.#$,X=this.#z[Z],q=this.#Y[Z];if(this.#T&&this.#U(q))q.__abortController.abort(Error("evicted"));else if(this.#_||this.#B){if(this.#_)this.#X?.(q,X,"evict");if(this.#B)this.#R?.push([q,X,"evict"])}if(this.#y(Z),Q)this.#z[Z]=void 0,this.#Y[Z]=void 0,this.#j.push(Z);if(this.#K===1)this.#$=this.#A=0,this.#j.length=0;else this.#$=this.#O[Z];return this.#V.delete(X),this.#K--,Z}has(Q,Z={}){let{updateAgeOnHas:X=this.updateAgeOnHas,status:q}=Z,Y=this.#V.get(Q);if(Y!==void 0){let J=this.#Y[Y];if(this.#U(J)&&J.__staleWhileFetching===void 0)return!1;if(!this.#S(Y)){if(X)this.#v(Y);if(q)q.has="hit",this.#w(q,Y);return!0}else if(q)q.has="stale",this.#w(q,Y)}else if(q)q.has="miss";return!1}peek(Q,Z={}){let{allowStale:X=this.allowStale}=Z,q=this.#V.get(Q);if(q===void 0||!X&&this.#S(q))return;let Y=this.#Y[q];return this.#U(Y)?Y.__staleWhileFetching:Y}#E(Q,Z,X,q){let Y=Z===void 0?void 0:this.#Y[Z];if(this.#U(Y))return Y;let J=new S8,{signal:H}=X;H?.addEventListener("abort",()=>J.abort(H.reason),{signal:J.signal});let W={signal:J.signal,options:X,context:q},V=($,A=!1)=>{let{aborted:U}=J.signal,B=X.ignoreFetchAbort&&$!==void 0;if(X.status)if(U&&!A){if(X.status.fetchAborted=!0,X.status.fetchError=J.signal.reason,B)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(U&&!B&&!A)return z(J.signal.reason);let M=_;if(this.#Y[Z]===_)if($===void 0)if(M.__staleWhileFetching)this.#Y[Z]=M.__staleWhileFetching;else this.#D(Q,"fetch");else{if(X.status)X.status.fetchUpdated=!0;this.set(Q,$,W.options)}return $},K=($)=>{if(X.status)X.status.fetchRejected=!0,X.status.fetchError=$;return z($)},z=($)=>{let{aborted:A}=J.signal,U=A&&X.allowStaleOnFetchAbort,B=U||X.allowStaleOnFetchRejection,M=B||X.noDeleteOnFetchRejection,R=_;if(this.#Y[Z]===_){if(!M||R.__staleWhileFetching===void 0)this.#D(Q,"fetch");else if(!U)this.#Y[Z]=R.__staleWhileFetching}if(B){if(X.status&&R.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return R.__staleWhileFetching}else if(R.__returned===R)throw $},G=($,A)=>{let U=this.#C?.(Q,Y,W);if(U&&U instanceof Promise)U.then((B)=>$(B===void 0?void 0:B),A);J.signal.addEventListener("abort",()=>{if(!X.ignoreFetchAbort||X.allowStaleOnFetchAbort){if($(void 0),X.allowStaleOnFetchAbort)$=(B)=>V(B,!0)}})};if(X.status)X.status.fetchDispatched=!0;let _=new Promise(G).then(V,K),O=Object.assign(_,{__abortController:J,__staleWhileFetching:Y,__returned:void 0});if(Z===void 0)this.set(Q,O,{...W.options,status:void 0}),Z=this.#V.get(Q);else this.#Y[Z]=O;return O}#U(Q){if(!this.#T)return!1;let Z=Q;return!!Z&&Z instanceof Promise&&Z.hasOwnProperty("__staleWhileFetching")&&Z.__abortController instanceof S8}async fetch(Q,Z={}){let{allowStale:X=this.allowStale,updateAgeOnGet:q=this.updateAgeOnGet,noDeleteOnStaleGet:Y=this.noDeleteOnStaleGet,ttl:J=this.ttl,noDisposeOnSet:H=this.noDisposeOnSet,size:W=0,sizeCalculation:V=this.sizeCalculation,noUpdateTTL:K=this.noUpdateTTL,noDeleteOnFetchRejection:z=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:G=this.allowStaleOnFetchRejection,ignoreFetchAbort:_=this.ignoreFetchAbort,allowStaleOnFetchAbort:O=this.allowStaleOnFetchAbort,context:$,forceRefresh:A=!1,status:U,signal:B}=Z;if(!this.#T){if(U)U.fetch="get";return this.get(Q,{allowStale:X,updateAgeOnGet:q,noDeleteOnStaleGet:Y,status:U})}let M={allowStale:X,updateAgeOnGet:q,noDeleteOnStaleGet:Y,ttl:J,noDisposeOnSet:H,size:W,sizeCalculation:V,noUpdateTTL:K,noDeleteOnFetchRejection:z,allowStaleOnFetchRejection:G,allowStaleOnFetchAbort:O,ignoreFetchAbort:_,status:U,signal:B},R=this.#V.get(Q);if(R===void 0){if(U)U.fetch="miss";let F=this.#E(Q,R,M,$);return F.__returned=F}else{let F=this.#Y[R];if(this.#U(F)){let J0=X&&F.__staleWhileFetching!==void 0;if(U){if(U.fetch="inflight",J0)U.returnedStale=!0}return J0?F.__staleWhileFetching:F.__returned=F}let S=this.#S(R);if(!A&&!S){if(U)U.fetch="hit";if(this.#f(R),q)this.#v(R);if(U)this.#w(U,R);return F}let y=this.#E(Q,R,M,$),Y0=y.__staleWhileFetching!==void 0&&X;if(U){if(U.fetch=S?"stale":"refresh",Y0&&S)U.returnedStale=!0}return Y0?y.__staleWhileFetching:y.__returned=y}}async forceFetch(Q,Z={}){let X=await this.fetch(Q,Z);if(X===void 0)throw Error("fetch() returned undefined");return X}memo(Q,Z={}){let X=this.#I;if(!X)throw Error("no memoMethod provided to constructor");let{context:q,forceRefresh:Y,...J}=Z,H=this.get(Q,J);if(!Y&&H!==void 0)return H;let W=X(Q,H,{options:J,context:q});return this.set(Q,W,J),W}get(Q,Z={}){let{allowStale:X=this.allowStale,updateAgeOnGet:q=this.updateAgeOnGet,noDeleteOnStaleGet:Y=this.noDeleteOnStaleGet,status:J}=Z,H=this.#V.get(Q);if(H!==void 0){let W=this.#Y[H],V=this.#U(W);if(J)this.#w(J,H);if(this.#S(H)){if(J)J.get="stale";if(!V){if(!Y)this.#D(Q,"expire");if(J&&X)J.returnedStale=!0;return X?W:void 0}else{if(J&&X&&W.__staleWhileFetching!==void 0)J.returnedStale=!0;return X?W.__staleWhileFetching:void 0}}else{if(J)J.get="hit";if(V)return W.__staleWhileFetching;if(this.#f(H),q)this.#v(H);return W}}else if(J)J.get="miss"}#l(Q,Z){this.#M[Z]=Q,this.#O[Q]=Z}#f(Q){if(Q!==this.#A){if(Q===this.#$)this.#$=this.#O[Q];else this.#l(this.#M[Q],this.#O[Q]);this.#l(this.#A,Q),this.#A=Q}}delete(Q){return this.#D(Q,"delete")}#D(Q,Z){let X=!1;if(this.#K!==0){let q=this.#V.get(Q);if(q!==void 0)if(X=!0,this.#K===1)this.#h(Z);else{this.#y(q);let Y=this.#Y[q];if(this.#U(Y))Y.__abortController.abort(Error("deleted"));else if(this.#_||this.#B){if(this.#_)this.#X?.(Y,Q,Z);if(this.#B)this.#R?.push([Y,Q,Z])}if(this.#V.delete(Q),this.#z[q]=void 0,this.#Y[q]=void 0,q===this.#A)this.#A=this.#M[q];else if(q===this.#$)this.#$=this.#O[q];else{let J=this.#M[q];this.#O[J]=this.#O[q];let H=this.#O[q];this.#M[H]=this.#M[q]}this.#K--,this.#j.push(q)}}if(this.#B&&this.#R?.length){let q=this.#R,Y;while(Y=q?.shift())this.#J?.(...Y)}return X}clear(){return this.#h("delete")}#h(Q){for(let Z of this.#P({allowStale:!0})){let X=this.#Y[Z];if(this.#U(X))X.__abortController.abort(Error("deleted"));else{let q=this.#z[Z];if(this.#_)this.#X?.(X,q,Q);if(this.#B)this.#R?.push([X,q,Q])}}if(this.#V.clear(),this.#Y.fill(void 0),this.#z.fill(void 0),this.#L&&this.#H)this.#L.fill(0),this.#H.fill(0);if(this.#F)this.#F.fill(0);if(this.#$=0,this.#A=0,this.#j.length=0,this.#G=0,this.#K=0,this.#B&&this.#R){let Z=this.#R,X;while(X=Z?.shift())this.#J?.(...X)}}}import{posix as B4,win32 as q7}from"node:path";import{fileURLToPath as R4}from"node:url";import{lstatSync as I4,readdir as C4,readdirSync as L4,readlinkSync as F4,realpathSync as j4}from"fs";import*as T4 from"node:fs";import{lstat as S4,readdir as N4,readlink as P4,realpath as b4}from"node:fs/promises";import{EventEmitter as e6}from"node:events";import HQ from"node:stream";import{StringDecoder as V4}from"node:string_decoder";var qQ=typeof process==="object"&&process?process:{stdout:null,stderr:null},K4=(Q)=>!!Q&&typeof Q==="object"&&(Q instanceof x0||Q instanceof HQ||_4(Q)||z4(Q)),_4=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof e6&&typeof Q.pipe==="function"&&Q.pipe!==HQ.Writable.prototype.pipe,z4=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof e6&&typeof Q.write==="function"&&typeof Q.end==="function",C0=Symbol("EOF"),L0=Symbol("maybeEmitEnd"),b0=Symbol("emittedEnd"),N8=Symbol("emittingEnd"),Z8=Symbol("emittedError"),P8=Symbol("closed"),YQ=Symbol("read"),b8=Symbol("flush"),JQ=Symbol("flushChunk"),G0=Symbol("encoding"),l0=Symbol("decoder"),d=Symbol("flowing"),X8=Symbol("paused"),d0=Symbol("resume"),i=Symbol("buffer"),Z0=Symbol("pipes"),p=Symbol("bufferLength"),n6=Symbol("bufferPush"),k8=Symbol("bufferShift"),e=Symbol("objectMode"),g=Symbol("destroyed"),r6=Symbol("error"),s6=Symbol("emitData"),WQ=Symbol("emitEnd"),o6=Symbol("emitEnd2"),O0=Symbol("async"),t6=Symbol("abort"),D8=Symbol("aborted"),q8=Symbol("signal"),E0=Symbol("dataListeners"),q0=Symbol("discarded"),Y8=(Q)=>Promise.resolve().then(Q),G4=(Q)=>Q(),U4=(Q)=>Q==="end"||Q==="finish"||Q==="prefinish",$4=(Q)=>Q instanceof ArrayBuffer||!!Q&&typeof Q==="object"&&Q.constructor&&Q.constructor.name==="ArrayBuffer"&&Q.byteLength>=0,M4=(Q)=>!Buffer.isBuffer(Q)&&ArrayBuffer.isView(Q);class Q7{src;dest;opts;ondrain;constructor(Q,Z,X){this.src=Q,this.dest=Z,this.opts=X,this.ondrain=()=>Q[d0](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(Q){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class VQ extends Q7{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(Q,Z,X){super(Q,Z,X);this.proxyErrors=(q)=>Z.emit("error",q),Q.on("error",this.proxyErrors)}}var O4=(Q)=>!!Q.objectMode,A4=(Q)=>!Q.objectMode&&!!Q.encoding&&Q.encoding!=="buffer";class x0 extends e6{[d]=!1;[X8]=!1;[Z0]=[];[i]=[];[e];[G0];[O0];[l0];[C0]=!1;[b0]=!1;[N8]=!1;[P8]=!1;[Z8]=null;[p]=0;[g]=!1;[q8];[D8]=!1;[E0]=0;[q0]=!1;writable=!0;readable=!0;constructor(...Q){let Z=Q[0]||{};super();if(Z.objectMode&&typeof Z.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if(O4(Z))this[e]=!0,this[G0]=null;else if(A4(Z))this[G0]=Z.encoding,this[e]=!1;else this[e]=!1,this[G0]=null;if(this[O0]=!!Z.async,this[l0]=this[G0]?new V4(this[G0]):null,Z&&Z.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[i]});if(Z&&Z.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[Z0]});let{signal:X}=Z;if(X)if(this[q8]=X,X.aborted)this[t6]();else X.addEventListener("abort",()=>this[t6]())}get bufferLength(){return this[p]}get encoding(){return this[G0]}set encoding(Q){throw Error("Encoding must be set at instantiation time")}setEncoding(Q){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[e]}set objectMode(Q){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[O0]}set["async"](Q){this[O0]=this[O0]||!!Q}[t6](){this[D8]=!0,this.emit("abort",this[q8]?.reason),this.destroy(this[q8]?.reason)}get aborted(){return this[D8]}set aborted(Q){}write(Q,Z,X){if(this[D8])return!1;if(this[C0])throw Error("write after end");if(this[g])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof Z==="function")X=Z,Z="utf8";if(!Z)Z="utf8";let q=this[O0]?Y8:G4;if(!this[e]&&!Buffer.isBuffer(Q)){if(M4(Q))Q=Buffer.from(Q.buffer,Q.byteOffset,Q.byteLength);else if($4(Q))Q=Buffer.from(Q);else if(typeof Q!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[e]){if(this[d]&&this[p]!==0)this[b8](!0);if(this[d])this.emit("data",Q);else this[n6](Q);if(this[p]!==0)this.emit("readable");if(X)q(X);return this[d]}if(!Q.length){if(this[p]!==0)this.emit("readable");if(X)q(X);return this[d]}if(typeof Q==="string"&&!(Z===this[G0]&&!this[l0]?.lastNeed))Q=Buffer.from(Q,Z);if(Buffer.isBuffer(Q)&&this[G0])Q=this[l0].write(Q);if(this[d]&&this[p]!==0)this[b8](!0);if(this[d])this.emit("data",Q);else this[n6](Q);if(this[p]!==0)this.emit("readable");if(X)q(X);return this[d]}read(Q){if(this[g])return null;if(this[q0]=!1,this[p]===0||Q===0||Q&&Q>this[p])return this[L0](),null;if(this[e])Q=null;if(this[i].length>1&&!this[e])this[i]=[this[G0]?this[i].join(""):Buffer.concat(this[i],this[p])];let Z=this[YQ](Q||null,this[i][0]);return this[L0](),Z}[YQ](Q,Z){if(this[e])this[k8]();else{let X=Z;if(Q===X.length||Q===null)this[k8]();else if(typeof X==="string")this[i][0]=X.slice(Q),Z=X.slice(0,Q),this[p]-=Q;else this[i][0]=X.subarray(Q),Z=X.subarray(0,Q),this[p]-=Q}if(this.emit("data",Z),!this[i].length&&!this[C0])this.emit("drain");return Z}end(Q,Z,X){if(typeof Q==="function")X=Q,Q=void 0;if(typeof Z==="function")X=Z,Z="utf8";if(Q!==void 0)this.write(Q,Z);if(X)this.once("end",X);if(this[C0]=!0,this.writable=!1,this[d]||!this[X8])this[L0]();return this}[d0](){if(this[g])return;if(!this[E0]&&!this[Z0].length)this[q0]=!0;if(this[X8]=!1,this[d]=!0,this.emit("resume"),this[i].length)this[b8]();else if(this[C0])this[L0]();else this.emit("drain")}resume(){return this[d0]()}pause(){this[d]=!1,this[X8]=!0,this[q0]=!1}get destroyed(){return this[g]}get flowing(){return this[d]}get paused(){return this[X8]}[n6](Q){if(this[e])this[p]+=1;else this[p]+=Q.length;this[i].push(Q)}[k8](){if(this[e])this[p]-=1;else this[p]-=this[i][0].length;return this[i].shift()}[b8](Q=!1){do;while(this[JQ](this[k8]())&&this[i].length);if(!Q&&!this[i].length&&!this[C0])this.emit("drain")}[JQ](Q){return this.emit("data",Q),this[d]}pipe(Q,Z){if(this[g])return Q;this[q0]=!1;let X=this[b0];if(Z=Z||{},Q===qQ.stdout||Q===qQ.stderr)Z.end=!1;else Z.end=Z.end!==!1;if(Z.proxyErrors=!!Z.proxyErrors,X){if(Z.end)Q.end()}else if(this[Z0].push(!Z.proxyErrors?new Q7(this,Q,Z):new VQ(this,Q,Z)),this[O0])Y8(()=>this[d0]());else this[d0]();return Q}unpipe(Q){let Z=this[Z0].find((X)=>X.dest===Q);if(Z){if(this[Z0].length===1){if(this[d]&&this[E0]===0)this[d]=!1;this[Z0]=[]}else this[Z0].splice(this[Z0].indexOf(Z),1);Z.unpipe()}}addListener(Q,Z){return this.on(Q,Z)}on(Q,Z){let X=super.on(Q,Z);if(Q==="data"){if(this[q0]=!1,this[E0]++,!this[Z0].length&&!this[d])this[d0]()}else if(Q==="readable"&&this[p]!==0)super.emit("readable");else if(U4(Q)&&this[b0])super.emit(Q),this.removeAllListeners(Q);else if(Q==="error"&&this[Z8]){let q=Z;if(this[O0])Y8(()=>q.call(this,this[Z8]));else q.call(this,this[Z8])}return X}removeListener(Q,Z){return this.off(Q,Z)}off(Q,Z){let X=super.off(Q,Z);if(Q==="data"){if(this[E0]=this.listeners("data").length,this[E0]===0&&!this[q0]&&!this[Z0].length)this[d]=!1}return X}removeAllListeners(Q){let Z=super.removeAllListeners(Q);if(Q==="data"||Q===void 0){if(this[E0]=0,!this[q0]&&!this[Z0].length)this[d]=!1}return Z}get emittedEnd(){return this[b0]}[L0](){if(!this[N8]&&!this[b0]&&!this[g]&&this[i].length===0&&this[C0]){if(this[N8]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[P8])this.emit("close");this[N8]=!1}}emit(Q,...Z){let X=Z[0];if(Q!=="error"&&Q!=="close"&&Q!==g&&this[g])return!1;else if(Q==="data")return!this[e]&&!X?!1:this[O0]?(Y8(()=>this[s6](X)),!0):this[s6](X);else if(Q==="end")return this[WQ]();else if(Q==="close"){if(this[P8]=!0,!this[b0]&&!this[g])return!1;let Y=super.emit("close");return this.removeAllListeners("close"),Y}else if(Q==="error"){this[Z8]=X,super.emit(r6,X);let Y=!this[q8]||this.listeners("error").length?super.emit("error",X):!1;return this[L0](),Y}else if(Q==="resume"){let Y=super.emit("resume");return this[L0](),Y}else if(Q==="finish"||Q==="prefinish"){let Y=super.emit(Q);return this.removeAllListeners(Q),Y}let q=super.emit(Q,...Z);return this[L0](),q}[s6](Q){for(let X of this[Z0])if(X.dest.write(Q)===!1)this.pause();let Z=this[q0]?!1:super.emit("data",Q);return this[L0](),Z}[WQ](){if(this[b0])return!1;return this[b0]=!0,this.readable=!1,this[O0]?(Y8(()=>this[o6]()),!0):this[o6]()}[o6](){if(this[l0]){let Z=this[l0].end();if(Z){for(let X of this[Z0])X.dest.write(Z);if(!this[q0])super.emit("data",Z)}}for(let Z of this[Z0])Z.end();let Q=super.emit("end");return this.removeAllListeners("end"),Q}async collect(){let Q=Object.assign([],{dataLength:0});if(!this[e])Q.dataLength=0;let Z=this.promise();return this.on("data",(X)=>{if(Q.push(X),!this[e])Q.dataLength+=X.length}),await Z,Q}async concat(){if(this[e])throw Error("cannot concat in objectMode");let Q=await this.collect();return this[G0]?Q.join(""):Buffer.concat(Q,Q.dataLength)}async promise(){return new Promise((Q,Z)=>{this.on(g,()=>Z(Error("stream destroyed"))),this.on("error",(X)=>Z(X)),this.on("end",()=>Q())})}[Symbol.asyncIterator](){this[q0]=!1;let Q=!1,Z=async()=>{return this.pause(),Q=!0,{value:void 0,done:!0}};return{next:()=>{if(Q)return Z();let q=this.read();if(q!==null)return Promise.resolve({done:!1,value:q});if(this[C0])return Z();let Y,J,H=(z)=>{this.off("data",W),this.off("end",V),this.off(g,K),Z(),J(z)},W=(z)=>{this.off("error",H),this.off("end",V),this.off(g,K),this.pause(),Y({value:z,done:!!this[C0]})},V=()=>{this.off("error",H),this.off("data",W),this.off(g,K),Z(),Y({done:!0,value:void 0})},K=()=>H(Error("stream destroyed"));return new Promise((z,G)=>{J=G,Y=z,this.once(g,K),this.once("error",H),this.once("end",V),this.once("data",W)})},throw:Z,return:Z,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[q0]=!1;let Q=!1,Z=()=>{return this.pause(),this.off(r6,Z),this.off(g,Z),this.off("end",Z),Q=!0,{done:!0,value:void 0}},X=()=>{if(Q)return Z();let q=this.read();return q===null?Z():{done:!1,value:q}};return this.once("end",Z),this.once(r6,Z),this.once(g,Z),{next:X,throw:Z,return:Z,[Symbol.iterator](){return this}}}destroy(Q){if(this[g]){if(Q)this.emit("error",Q);else this.emit(g);return this}this[g]=!0,this[q0]=!0,this[i].length=0,this[p]=0;let Z=this;if(typeof Z.close==="function"&&!this[P8])Z.close();if(Q)this.emit("error",Q);else this.emit(g);return this}static get isStream(){return K4}}var w4=j4.native,W8={lstatSync:I4,readdir:C4,readdirSync:L4,readlinkSync:F4,realpathSync:w4,promises:{lstat:S4,readdir:N4,readlink:P4,realpath:b4}},UQ=(Q)=>!Q||Q===W8||Q===T4?W8:{...W8,...Q,promises:{...W8.promises,...Q.promises||{}}},$Q=/^\\\\\?\\([a-z]:)\\?$/i,k4=(Q)=>Q.replace(/\//g,"\\").replace($Q,"$1\\"),D4=/[\\\/]/,K0=0,MQ=1,OQ=2,A0=4,AQ=6,BQ=8,u0=10,RQ=12,V0=15,J8=~V0,Z7=16,KQ=32,H8=64,U0=128,v8=256,E8=512,_Q=H8|U0|E8,v4=1023,X7=(Q)=>Q.isFile()?BQ:Q.isDirectory()?A0:Q.isSymbolicLink()?u0:Q.isCharacterDevice()?OQ:Q.isBlockDevice()?AQ:Q.isSocket()?RQ:Q.isFIFO()?MQ:K0,zQ=new Map,V8=(Q)=>{let Z=zQ.get(Q);if(Z)return Z;let X=Q.normalize("NFKD");return zQ.set(Q,X),X},GQ=new Map,y8=(Q)=>{let Z=GQ.get(Q);if(Z)return Z;let X=V8(Q.toLowerCase());return GQ.set(Q,X),X};class Y7 extends Q8{constructor(){super({max:256})}}class IQ extends Q8{constructor(Q=16384){super({maxSize:Q,sizeCalculation:(Z)=>Z.length+1})}}var CQ=Symbol("PathScurry setAsCwd");class X0{name;root;roots;parent;nocase;isCWD=!1;#Z;#Q;get dev(){return this.#Q}#X;get mode(){return this.#X}#q;get nlink(){return this.#q}#J;get uid(){return this.#J}#C;get gid(){return this.#C}#I;get rdev(){return this.#I}#K;get blksize(){return this.#K}#G;get ino(){return this.#G}#V;get size(){return this.#V}#z;get blocks(){return this.#z}#Y;get atimeMs(){return this.#Y}#O;get mtimeMs(){return this.#O}#M;get ctimeMs(){return this.#M}#$;get birthtimeMs(){return this.#$}#A;get atime(){return this.#A}#j;get mtime(){return this.#j}#R;get ctime(){return this.#R}#F;get birthtime(){return this.#F}#H;#L;#_;#T;#B;#b;#W;#v;#w;#k;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Q,Z=K0,X,q,Y,J,H){if(this.name=Q,this.#H=Y?y8(Q):V8(Q),this.#W=Z&v4,this.nocase=Y,this.roots=q,this.root=X||this,this.#v=J,this.#_=H.fullpath,this.#B=H.relative,this.#b=H.relativePosix,this.parent=H.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=UQ(H.fs)}depth(){if(this.#L!==void 0)return this.#L;if(!this.parent)return this.#L=0;return this.#L=this.parent.depth()+1}childrenCache(){return this.#v}resolve(Q){if(!Q)return this;let Z=this.getRootString(Q),q=Q.substring(Z.length).split(this.splitSep);return Z?this.getRoot(Z).#S(q):this.#S(q)}#S(Q){let Z=this;for(let X of Q)Z=Z.child(X);return Z}children(){let Q=this.#v.get(this);if(Q)return Q;let Z=Object.assign([],{provisional:0});return this.#v.set(this,Z),this.#W&=~Z7,Z}child(Q,Z){if(Q===""||Q===".")return this;if(Q==="..")return this.parent||this;let X=this.children(),q=this.nocase?y8(Q):V8(Q);for(let W of X)if(W.#H===q)return W;let Y=this.parent?this.sep:"",J=this.#_?this.#_+Y+Q:void 0,H=this.newChild(Q,K0,{...Z,parent:this,fullpath:J});if(!this.canReaddir())H.#W|=U0;return X.push(H),H}relative(){if(this.isCWD)return"";if(this.#B!==void 0)return this.#B;let Q=this.name,Z=this.parent;if(!Z)return this.#B=this.name;let X=Z.relative();return X+(!X||!Z.parent?"":this.sep)+Q}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#b!==void 0)return this.#b;let Q=this.name,Z=this.parent;if(!Z)return this.#b=this.fullpathPosix();let X=Z.relativePosix();return X+(!X||!Z.parent?"":"/")+Q}fullpath(){if(this.#_!==void 0)return this.#_;let Q=this.name,Z=this.parent;if(!Z)return this.#_=this.name;let q=Z.fullpath()+(!Z.parent?"":this.sep)+Q;return this.#_=q}fullpathPosix(){if(this.#T!==void 0)return this.#T;if(this.sep==="/")return this.#T=this.fullpath();if(!this.parent){let q=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(q))return this.#T=`//?/${q}`;else return this.#T=q}let Q=this.parent,Z=Q.fullpathPosix(),X=Z+(!Z||!Q.parent?"":"/")+this.name;return this.#T=X}isUnknown(){return(this.#W&V0)===K0}isType(Q){return this[`is${Q}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#W&V0)===BQ}isDirectory(){return(this.#W&V0)===A0}isCharacterDevice(){return(this.#W&V0)===OQ}isBlockDevice(){return(this.#W&V0)===AQ}isFIFO(){return(this.#W&V0)===MQ}isSocket(){return(this.#W&V0)===RQ}isSymbolicLink(){return(this.#W&u0)===u0}lstatCached(){return this.#W&KQ?this:void 0}readlinkCached(){return this.#w}realpathCached(){return this.#k}readdirCached(){let Q=this.children();return Q.slice(0,Q.provisional)}canReadlink(){if(this.#w)return!0;if(!this.parent)return!1;let Q=this.#W&V0;return!(Q!==K0&&Q!==u0||this.#W&v8||this.#W&U0)}calledReaddir(){return!!(this.#W&Z7)}isENOENT(){return!!(this.#W&U0)}isNamed(Q){return!this.nocase?this.#H===V8(Q):this.#H===y8(Q)}async readlink(){let Q=this.#w;if(Q)return Q;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=await this.#Z.promises.readlink(this.fullpath()),X=(await this.parent.realpath())?.resolve(Z);if(X)return this.#w=X}catch(Z){this.#u(Z.code);return}}readlinkSync(){let Q=this.#w;if(Q)return Q;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=this.#Z.readlinkSync(this.fullpath()),X=this.parent.realpathSync()?.resolve(Z);if(X)return this.#w=X}catch(Z){this.#u(Z.code);return}}#g(Q){this.#W|=Z7;for(let Z=Q.provisional;Z<Q.length;Z++){let X=Q[Z];if(X)X.#y()}}#y(){if(this.#W&U0)return;this.#W=(this.#W|U0)&J8,this.#x()}#x(){let Q=this.children();Q.provisional=0;for(let Z of Q)Z.#y()}#m(){this.#W|=E8,this.#N()}#N(){if(this.#W&H8)return;let Q=this.#W;if((Q&V0)===A0)Q&=J8;this.#W=Q|H8,this.#x()}#P(Q=""){if(Q==="ENOTDIR"||Q==="EPERM")this.#N();else if(Q==="ENOENT")this.#y();else this.children().provisional=0}#c(Q=""){if(Q==="ENOTDIR")this.parent.#N();else if(Q==="ENOENT")this.#y()}#u(Q=""){let Z=this.#W;if(Z|=v8,Q==="ENOENT")Z|=U0;if(Q==="EINVAL"||Q==="UNKNOWN")Z&=J8;if(this.#W=Z,Q==="ENOTDIR"&&this.parent)this.parent.#N()}#E(Q,Z){return this.#l(Q,Z)||this.#U(Q,Z)}#U(Q,Z){let X=X7(Q),q=this.newChild(Q.name,X,{parent:this}),Y=q.#W&V0;if(Y!==A0&&Y!==u0&&Y!==K0)q.#W|=H8;return Z.unshift(q),Z.provisional++,q}#l(Q,Z){for(let X=Z.provisional;X<Z.length;X++){let q=Z[X];if((this.nocase?y8(Q.name):V8(Q.name))!==q.#H)continue;return this.#f(Q,q,X,Z)}}#f(Q,Z,X,q){let Y=Z.name;if(Z.#W=Z.#W&J8|X7(Q),Y!==Q.name)Z.name=Q.name;if(X!==q.provisional){if(X===q.length-1)q.pop();else q.splice(X,1);q.unshift(Z)}return q.provisional++,Z}async lstat(){if((this.#W&U0)===0)try{return this.#D(await this.#Z.promises.lstat(this.fullpath())),this}catch(Q){this.#c(Q.code)}}lstatSync(){if((this.#W&U0)===0)try{return this.#D(this.#Z.lstatSync(this.fullpath())),this}catch(Q){this.#c(Q.code)}}#D(Q){let{atime:Z,atimeMs:X,birthtime:q,birthtimeMs:Y,blksize:J,blocks:H,ctime:W,ctimeMs:V,dev:K,gid:z,ino:G,mode:_,mtime:O,mtimeMs:$,nlink:A,rdev:U,size:B,uid:M}=Q;this.#A=Z,this.#Y=X,this.#F=q,this.#$=Y,this.#K=J,this.#z=H,this.#R=W,this.#M=V,this.#Q=K,this.#C=z,this.#G=G,this.#X=_,this.#j=O,this.#O=$,this.#q=A,this.#I=U,this.#V=B,this.#J=M;let R=X7(Q);if(this.#W=this.#W&J8|R|KQ,R!==K0&&R!==A0&&R!==u0)this.#W|=H8}#h=[];#i=!1;#p(Q){this.#i=!1;let Z=this.#h.slice();this.#h.length=0,Z.forEach((X)=>X(null,Q))}readdirCB(Q,Z=!1){if(!this.canReaddir()){if(Z)Q(null,[]);else queueMicrotask(()=>Q(null,[]));return}let X=this.children();if(this.calledReaddir()){let Y=X.slice(0,X.provisional);if(Z)Q(null,Y);else queueMicrotask(()=>Q(null,Y));return}if(this.#h.push(Q),this.#i)return;this.#i=!0;let q=this.fullpath();this.#Z.readdir(q,{withFileTypes:!0},(Y,J)=>{if(Y)this.#P(Y.code),X.provisional=0;else{for(let H of J)this.#E(H,X);this.#g(X)}this.#p(X.slice(0,X.provisional));return})}#d;async readdir(){if(!this.canReaddir())return[];let Q=this.children();if(this.calledReaddir())return Q.slice(0,Q.provisional);let Z=this.fullpath();if(this.#d)await this.#d;else{let X=()=>{};this.#d=new Promise((q)=>X=q);try{for(let q of await this.#Z.promises.readdir(Z,{withFileTypes:!0}))this.#E(q,Q);this.#g(Q)}catch(q){this.#P(q.code),Q.provisional=0}this.#d=void 0,X()}return Q.slice(0,Q.provisional)}readdirSync(){if(!this.canReaddir())return[];let Q=this.children();if(this.calledReaddir())return Q.slice(0,Q.provisional);let Z=this.fullpath();try{for(let X of this.#Z.readdirSync(Z,{withFileTypes:!0}))this.#E(X,Q);this.#g(Q)}catch(X){this.#P(X.code),Q.provisional=0}return Q.slice(0,Q.provisional)}canReaddir(){if(this.#W&_Q)return!1;let Q=V0&this.#W;if(!(Q===K0||Q===A0||Q===u0))return!1;return!0}shouldWalk(Q,Z){return(this.#W&A0)===A0&&!(this.#W&_Q)&&!Q.has(this)&&(!Z||Z(this))}async realpath(){if(this.#k)return this.#k;if((E8|v8|U0)&this.#W)return;try{let Q=await this.#Z.promises.realpath(this.fullpath());return this.#k=this.resolve(Q)}catch(Q){this.#m()}}realpathSync(){if(this.#k)return this.#k;if((E8|v8|U0)&this.#W)return;try{let Q=this.#Z.realpathSync(this.fullpath());return this.#k=this.resolve(Q)}catch(Q){this.#m()}}[CQ](Q){if(Q===this)return;Q.isCWD=!1,this.isCWD=!0;let Z=new Set([]),X=[],q=this;while(q&&q.parent)Z.add(q),q.#B=X.join(this.sep),q.#b=X.join("/"),q=q.parent,X.push("..");q=Q;while(q&&q.parent&&!Z.has(q))q.#B=void 0,q.#b=void 0,q=q.parent}}class x8 extends X0{sep="\\";splitSep=D4;constructor(Q,Z=K0,X,q,Y,J,H){super(Q,Z,X,q,Y,J,H)}newChild(Q,Z=K0,X={}){return new x8(Q,Z,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Q){return q7.parse(Q).root}getRoot(Q){if(Q=k4(Q.toUpperCase()),Q===this.root.name)return this.root;for(let[Z,X]of Object.entries(this.roots))if(this.sameRoot(Q,Z))return this.roots[Q]=X;return this.roots[Q]=new K8(Q,this).root}sameRoot(Q,Z=this.root.name){return Q=Q.toUpperCase().replace(/\//g,"\\").replace($Q,"$1\\"),Q===Z}}class u8 extends X0{splitSep="/";sep="/";constructor(Q,Z=K0,X,q,Y,J,H){super(Q,Z,X,q,Y,J,H)}getRootString(Q){return Q.startsWith("/")?"/":""}getRoot(Q){return this.root}newChild(Q,Z=K0,X={}){return new u8(Q,Z,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class J7{root;rootPath;roots;cwd;#Z;#Q;#X;nocase;#q;constructor(Q=process.cwd(),Z,X,{nocase:q,childrenCacheSize:Y=16384,fs:J=W8}={}){if(this.#q=UQ(J),Q instanceof URL||Q.startsWith("file://"))Q=R4(Q);let H=Z.resolve(Q);this.roots=Object.create(null),this.rootPath=this.parseRootPath(H),this.#Z=new Y7,this.#Q=new Y7,this.#X=new IQ(Y);let W=H.substring(this.rootPath.length).split(X);if(W.length===1&&!W[0])W.pop();if(q===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=q,this.root=this.newRoot(this.#q),this.roots[this.rootPath]=this.root;let V=this.root,K=W.length-1,z=Z.sep,G=this.rootPath,_=!1;for(let O of W){let $=K--;V=V.child(O,{relative:Array($).fill("..").join(z),relativePosix:Array($).fill("..").join("/"),fullpath:G+=(_?"":z)+O}),_=!0}this.cwd=V}depth(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.depth()}childrenCache(){return this.#X}resolve(...Q){let Z="";for(let Y=Q.length-1;Y>=0;Y--){let J=Q[Y];if(!J||J===".")continue;if(Z=Z?`${J}/${Z}`:J,this.isAbsolute(J))break}let X=this.#Z.get(Z);if(X!==void 0)return X;let q=this.cwd.resolve(Z).fullpath();return this.#Z.set(Z,q),q}resolvePosix(...Q){let Z="";for(let Y=Q.length-1;Y>=0;Y--){let J=Q[Y];if(!J||J===".")continue;if(Z=Z?`${J}/${Z}`:J,this.isAbsolute(J))break}let X=this.#Q.get(Z);if(X!==void 0)return X;let q=this.cwd.resolve(Z).fullpathPosix();return this.#Q.set(Z,q),q}relative(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.relative()}relativePosix(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.relativePosix()}basename(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.name}dirname(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return(Q.parent||Q).fullpath()}async readdir(Q=this.cwd,Z={withFileTypes:!0}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X}=Z;if(!Q.canReaddir())return[];else{let q=await Q.readdir();return X?q:q.map((Y)=>Y.name)}}readdirSync(Q=this.cwd,Z={withFileTypes:!0}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0}=Z;if(!Q.canReaddir())return[];else if(X)return Q.readdirSync();else return Q.readdirSync().map((q)=>q.name)}async lstat(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.lstat()}lstatSync(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.lstatSync()}async readlink(Q=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q.withFileTypes,Q=this.cwd;let X=await Q.readlink();return Z?X:X?.fullpath()}readlinkSync(Q=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q.withFileTypes,Q=this.cwd;let X=Q.readlinkSync();return Z?X:X?.fullpath()}async realpath(Q=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q.withFileTypes,Q=this.cwd;let X=await Q.realpath();return Z?X:X?.fullpath()}realpathSync(Q=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q.withFileTypes,Q=this.cwd;let X=Q.realpathSync();return Z?X:X?.fullpath()}async walk(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z,H=[];if(!Y||Y(Q))H.push(X?Q:Q.fullpath());let W=new Set,V=(z,G)=>{W.add(z),z.readdirCB((_,O)=>{if(_)return G(_);let $=O.length;if(!$)return G();let A=()=>{if(--$===0)G()};for(let U of O){if(!Y||Y(U))H.push(X?U:U.fullpath());if(q&&U.isSymbolicLink())U.realpath().then((B)=>B?.isUnknown()?B.lstat():B).then((B)=>B?.shouldWalk(W,J)?V(B,A):A());else if(U.shouldWalk(W,J))V(U,A);else A()}},!0)},K=Q;return new Promise((z,G)=>{V(K,(_)=>{if(_)return G(_);z(H)})})}walkSync(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z,H=[];if(!Y||Y(Q))H.push(X?Q:Q.fullpath());let W=new Set([Q]);for(let V of W){let K=V.readdirSync();for(let z of K){if(!Y||Y(z))H.push(X?z:z.fullpath());let G=z;if(z.isSymbolicLink()){if(!(q&&(G=z.realpathSync())))continue;if(G.isUnknown())G.lstatSync()}if(G.shouldWalk(W,J))W.add(G)}}return H}[Symbol.asyncIterator](){return this.iterate()}iterate(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;return this.stream(Q,Z)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z;if(!Y||Y(Q))yield X?Q:Q.fullpath();let H=new Set([Q]);for(let W of H){let V=W.readdirSync();for(let K of V){if(!Y||Y(K))yield X?K:K.fullpath();let z=K;if(K.isSymbolicLink()){if(!(q&&(z=K.realpathSync())))continue;if(z.isUnknown())z.lstatSync()}if(z.shouldWalk(H,J))H.add(z)}}}stream(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z,H=new x0({objectMode:!0});if(!Y||Y(Q))H.write(X?Q:Q.fullpath());let W=new Set,V=[Q],K=0,z=()=>{let G=!1;while(!G){let _=V.shift();if(!_){if(K===0)H.end();return}K++,W.add(_);let O=(A,U,B=!1)=>{if(A)return H.emit("error",A);if(q&&!B){let M=[];for(let R of U)if(R.isSymbolicLink())M.push(R.realpath().then((F)=>F?.isUnknown()?F.lstat():F));if(M.length){Promise.all(M).then(()=>O(null,U,!0));return}}for(let M of U)if(M&&(!Y||Y(M))){if(!H.write(X?M:M.fullpath()))G=!0}K--;for(let M of U){let R=M.realpathCached()||M;if(R.shouldWalk(W,J))V.push(R)}if(G&&!H.flowing)H.once("drain",z);else if(!$)z()},$=!0;_.readdirCB(O,!0),$=!1}};return z(),H}streamSync(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z,H=new x0({objectMode:!0}),W=new Set;if(!Y||Y(Q))H.write(X?Q:Q.fullpath());let V=[Q],K=0,z=()=>{let G=!1;while(!G){let _=V.shift();if(!_){if(K===0)H.end();return}K++,W.add(_);let O=_.readdirSync();for(let $ of O)if(!Y||Y($)){if(!H.write(X?$:$.fullpath()))G=!0}K--;for(let $ of O){let A=$;if($.isSymbolicLink()){if(!(q&&(A=$.realpathSync())))continue;if(A.isUnknown())A.lstatSync()}if(A.shouldWalk(W,J))V.push(A)}}if(G&&!H.flowing)H.once("drain",z)};return z(),H}chdir(Q=this.cwd){let Z=this.cwd;this.cwd=typeof Q==="string"?this.cwd.resolve(Q):Q,this.cwd[CQ](Z)}}class K8 extends J7{sep="\\";constructor(Q=process.cwd(),Z={}){let{nocase:X=!0}=Z;super(Q,q7,"\\",{...Z,nocase:X});this.nocase=X;for(let q=this.cwd;q;q=q.parent)q.nocase=this.nocase}parseRootPath(Q){return q7.parse(Q).root.toUpperCase()}newRoot(Q){return new x8(this.rootPath,A0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")||Q.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Q)}}class _8 extends J7{sep="/";constructor(Q=process.cwd(),Z={}){let{nocase:X=!1}=Z;super(Q,B4,"/",{...Z,nocase:X});this.nocase=X}parseRootPath(Q){return"/"}newRoot(Q){return new u8(this.rootPath,A0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")}}class f8 extends _8{constructor(Q=process.cwd(),Z={}){let{nocase:X=!0}=Z;super(Q,{...Z,nocase:X})}}var KY=process.platform==="win32"?x8:u8,LQ=process.platform==="win32"?K8:process.platform==="darwin"?f8:_8;var y4=(Q)=>Q.length>=1,E4=(Q)=>Q.length>=1;class i0{#Z;#Q;#X;length;#q;#J;#C;#I;#K;#G;#V=!0;constructor(Q,Z,X,q){if(!y4(Q))throw TypeError("empty pattern list");if(!E4(Z))throw TypeError("empty glob list");if(Z.length!==Q.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=Q.length,X<0||X>=this.length)throw TypeError("index out of range");if(this.#Z=Q,this.#Q=Z,this.#X=X,this.#q=q,this.#X===0){if(this.isUNC()){let[Y,J,H,W,...V]=this.#Z,[K,z,G,_,...O]=this.#Q;if(V[0]==="")V.shift(),O.shift();let $=[Y,J,H,W,""].join("/"),A=[K,z,G,_,""].join("/");this.#Z=[$,...V],this.#Q=[A,...O],this.length=this.#Z.length}else if(this.isDrive()||this.isAbsolute()){let[Y,...J]=this.#Z,[H,...W]=this.#Q;if(J[0]==="")J.shift(),W.shift();let V=Y+"/",K=H+"/";this.#Z=[V,...J],this.#Q=[K,...W],this.length=this.#Z.length}}}pattern(){return this.#Z[this.#X]}isString(){return typeof this.#Z[this.#X]==="string"}isGlobstar(){return this.#Z[this.#X]===n}isRegExp(){return this.#Z[this.#X]instanceof RegExp}globString(){return this.#C=this.#C||(this.#X===0?this.isAbsolute()?this.#Q[0]+this.#Q.slice(1).join("/"):this.#Q.join("/"):this.#Q.slice(this.#X).join("/"))}hasMore(){return this.length>this.#X+1}rest(){if(this.#J!==void 0)return this.#J;if(!this.hasMore())return this.#J=null;return this.#J=new i0(this.#Z,this.#Q,this.#X+1,this.#q),this.#J.#G=this.#G,this.#J.#K=this.#K,this.#J.#I=this.#I,this.#J}isUNC(){let Q=this.#Z;return this.#K!==void 0?this.#K:this.#K=this.#q==="win32"&&this.#X===0&&Q[0]===""&&Q[1]===""&&typeof Q[2]==="string"&&!!Q[2]&&typeof Q[3]==="string"&&!!Q[3]}isDrive(){let Q=this.#Z;return this.#I!==void 0?this.#I:this.#I=this.#q==="win32"&&this.#X===0&&this.length>1&&typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0])}isAbsolute(){let Q=this.#Z;return this.#G!==void 0?this.#G:this.#G=Q[0]===""&&Q.length>1||this.isDrive()||this.isUNC()}root(){let Q=this.#Z[0];return typeof Q==="string"&&this.isAbsolute()&&this.#X===0?Q:""}checkFollowGlobstar(){return!(this.#X===0||!this.isGlobstar()||!this.#V)}markFollowGlobstar(){if(this.#X===0||!this.isGlobstar()||!this.#V)return!1;return this.#V=!1,!0}}var x4=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class z8{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Q,{nobrace:Z,nocase:X,noext:q,noglobstar:Y,platform:J=x4}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=J,this.mmopts={dot:!0,nobrace:Z,nocase:X,noext:q,noglobstar:Y,optimizationLevel:2,platform:J,nocomment:!0,nonegate:!0};for(let H of Q)this.add(H)}add(Q){let Z=new H0(Q,this.mmopts);for(let X=0;X<Z.set.length;X++){let q=Z.set[X],Y=Z.globParts[X];if(!q||!Y)throw Error("invalid pattern object");while(q[0]==="."&&Y[0]===".")q.shift(),Y.shift();let J=new i0(q,Y,0,this.platform),H=new H0(J.globString(),this.mmopts),W=Y[Y.length-1]==="**",V=J.isAbsolute();if(V)this.absolute.push(H);else this.relative.push(H);if(W)if(V)this.absoluteChildren.push(H);else this.relativeChildren.push(H)}}ignored(Q){let Z=Q.fullpath(),X=`${Z}/`,q=Q.relative()||".",Y=`${q}/`;for(let J of this.relative)if(J.match(q)||J.match(Y))return!0;for(let J of this.absolute)if(J.match(Z)||J.match(X))return!0;return!1}childrenIgnored(Q){let Z=Q.fullpath()+"/",X=(Q.relative()||".")+"/";for(let q of this.relativeChildren)if(q.match(X))return!0;for(let q of this.absoluteChildren)if(q.match(Z))return!0;return!1}}class W7{store;constructor(Q=new Map){this.store=Q}copy(){return new W7(new Map(this.store))}hasWalked(Q,Z){return this.store.get(Q.fullpath())?.has(Z.globString())}storeWalked(Q,Z){let X=Q.fullpath(),q=this.store.get(X);if(q)q.add(Z.globString());else this.store.set(X,new Set([Z.globString()]))}}class FQ{store=new Map;add(Q,Z,X){let q=(Z?2:0)|(X?1:0),Y=this.store.get(Q);this.store.set(Q,Y===void 0?q:q&Y)}entries(){return[...this.store.entries()].map(([Q,Z])=>[Q,!!(Z&2),!!(Z&1)])}}class jQ{store=new Map;add(Q,Z){if(!Q.canReaddir())return;let X=this.store.get(Q);if(X){if(!X.find((q)=>q.globString()===Z.globString()))X.push(Z)}else this.store.set(Q,[Z])}get(Q){let Z=this.store.get(Q);if(!Z)throw Error("attempting to walk unknown path");return Z}entries(){return this.keys().map((Q)=>[Q,this.store.get(Q)])}keys(){return[...this.store.keys()].filter((Q)=>Q.canReaddir())}}class G8{hasWalkedCache;matches=new FQ;subwalks=new jQ;patterns;follow;dot;opts;constructor(Q,Z){this.opts=Q,this.follow=!!Q.follow,this.dot=!!Q.dot,this.hasWalkedCache=Z?Z.copy():new W7}processPatterns(Q,Z){this.patterns=Z;let X=Z.map((q)=>[Q,q]);for(let[q,Y]of X){this.hasWalkedCache.storeWalked(q,Y);let J=Y.root(),H=Y.isAbsolute()&&this.opts.absolute!==!1;if(J){q=q.resolve(J==="/"&&this.opts.root!==void 0?this.opts.root:J);let z=Y.rest();if(!z){this.matches.add(q,!0,!1);continue}else Y=z}if(q.isENOENT())continue;let W,V,K=!1;while(typeof(W=Y.pattern())==="string"&&(V=Y.rest()))q=q.resolve(W),Y=V,K=!0;if(W=Y.pattern(),V=Y.rest(),K){if(this.hasWalkedCache.hasWalked(q,Y))continue;this.hasWalkedCache.storeWalked(q,Y)}if(typeof W==="string"){let z=W===".."||W===""||W===".";this.matches.add(q.resolve(W),H,z);continue}else if(W===n){if(!q.isSymbolicLink()||this.follow||Y.checkFollowGlobstar())this.subwalks.add(q,Y);let z=V?.pattern(),G=V?.rest();if(!V||(z===""||z===".")&&!G)this.matches.add(q,H,z===""||z===".");else if(z===".."){let _=q.parent||q;if(!G)this.matches.add(_,H,!0);else if(!this.hasWalkedCache.hasWalked(_,G))this.subwalks.add(_,G)}}else if(W instanceof RegExp)this.subwalks.add(q,Y)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new G8(this.opts,this.hasWalkedCache)}filterEntries(Q,Z){let X=this.subwalks.get(Q),q=this.child();for(let Y of Z)for(let J of X){let H=J.isAbsolute(),W=J.pattern(),V=J.rest();if(W===n)q.testGlobstar(Y,J,V,H);else if(W instanceof RegExp)q.testRegExp(Y,W,V,H);else q.testString(Y,W,V,H)}return q}testGlobstar(Q,Z,X,q){if(this.dot||!Q.name.startsWith(".")){if(!Z.hasMore())this.matches.add(Q,q,!1);if(Q.canReaddir()){if(this.follow||!Q.isSymbolicLink())this.subwalks.add(Q,Z);else if(Q.isSymbolicLink()){if(X&&Z.checkFollowGlobstar())this.subwalks.add(Q,X);else if(Z.markFollowGlobstar())this.subwalks.add(Q,Z)}}}if(X){let Y=X.pattern();if(typeof Y==="string"&&Y!==".."&&Y!==""&&Y!==".")this.testString(Q,Y,X.rest(),q);else if(Y===".."){let J=Q.parent||Q;this.subwalks.add(J,X)}else if(Y instanceof RegExp)this.testRegExp(Q,Y,X.rest(),q)}}testRegExp(Q,Z,X,q){if(!Z.test(Q.name))return;if(!X)this.matches.add(Q,q,!1);else this.subwalks.add(Q,X)}testString(Q,Z,X,q){if(!Q.isNamed(Z))return;if(!X)this.matches.add(Q,q,!1);else this.subwalks.add(Q,X)}}var u4=(Q,Z)=>typeof Q==="string"?new z8([Q],Z):Array.isArray(Q)?new z8(Q,Z):Q;class H7{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Z=[];#Q;#X;signal;maxDepth;includeChildMatches;constructor(Q,Z,X){if(this.patterns=Q,this.path=Z,this.opts=X,this.#X=!X.posix&&X.platform==="win32"?"\\":"/",this.includeChildMatches=X.includeChildMatches!==!1,X.ignore||!this.includeChildMatches){if(this.#Q=u4(X.ignore??[],X),!this.includeChildMatches&&typeof this.#Q.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=X.maxDepth||1/0,X.signal)this.signal=X.signal,this.signal.addEventListener("abort",()=>{this.#Z.length=0})}#q(Q){return this.seen.has(Q)||!!this.#Q?.ignored?.(Q)}#J(Q){return!!this.#Q?.childrenIgnored?.(Q)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let Q=void 0;while(!this.paused&&(Q=this.#Z.shift()))Q()}onResume(Q){if(this.signal?.aborted)return;if(!this.paused)Q();else this.#Z.push(Q)}async matchCheck(Q,Z){if(Z&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Q.realpathCached()||await Q.realpath(),!X)return;Q=X}let Y=Q.isUnknown()||this.opts.stat?await Q.lstat():Q;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let J=await Y.realpath();if(J&&(J.isUnknown()||this.opts.stat))await J.lstat()}return this.matchCheckTest(Y,Z)}matchCheckTest(Q,Z){return Q&&(this.maxDepth===1/0||Q.depth()<=this.maxDepth)&&(!Z||Q.canReaddir())&&(!this.opts.nodir||!Q.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!Q.isSymbolicLink()||!Q.realpathCached()?.isDirectory())&&!this.#q(Q)?Q:void 0}matchCheckSync(Q,Z){if(Z&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Q.realpathCached()||Q.realpathSync(),!X)return;Q=X}let Y=Q.isUnknown()||this.opts.stat?Q.lstatSync():Q;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let J=Y.realpathSync();if(J&&(J?.isUnknown()||this.opts.stat))J.lstatSync()}return this.matchCheckTest(Y,Z)}matchFinish(Q,Z){if(this.#q(Q))return;if(!this.includeChildMatches&&this.#Q?.add){let Y=`${Q.relativePosix()}/**`;this.#Q.add(Y)}let X=this.opts.absolute===void 0?Z:this.opts.absolute;this.seen.add(Q);let q=this.opts.mark&&Q.isDirectory()?this.#X:"";if(this.opts.withFileTypes)this.matchEmit(Q);else if(X){let Y=this.opts.posix?Q.fullpathPosix():Q.fullpath();this.matchEmit(Y+q)}else{let Y=this.opts.posix?Q.relativePosix():Q.relative(),J=this.opts.dotRelative&&!Y.startsWith(".."+this.#X)?"."+this.#X:"";this.matchEmit(!Y?"."+q:J+Y+q)}}async match(Q,Z,X){let q=await this.matchCheck(Q,X);if(q)this.matchFinish(q,Z)}matchSync(Q,Z,X){let q=this.matchCheckSync(Q,X);if(q)this.matchFinish(q,Z)}walkCB(Q,Z,X){if(this.signal?.aborted)X();this.walkCB2(Q,Z,new G8(this.opts),X)}walkCB2(Q,Z,X,q){if(this.#J(Q))return q();if(this.signal?.aborted)q();if(this.paused){this.onResume(()=>this.walkCB2(Q,Z,X,q));return}X.processPatterns(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#q(H))continue;Y++,this.match(H,W,V).then(()=>J())}for(let H of X.subwalkTargets()){if(this.maxDepth!==1/0&&H.depth()>=this.maxDepth)continue;Y++;let W=H.readdirCached();if(H.calledReaddir())this.walkCB3(H,W,X,J);else H.readdirCB((V,K)=>this.walkCB3(H,K,X,J),!0)}J()}walkCB3(Q,Z,X,q){X=X.filterEntries(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#q(H))continue;Y++,this.match(H,W,V).then(()=>J())}for(let[H,W]of X.subwalks.entries())Y++,this.walkCB2(H,W,X.child(),J);J()}walkCBSync(Q,Z,X){if(this.signal?.aborted)X();this.walkCB2Sync(Q,Z,new G8(this.opts),X)}walkCB2Sync(Q,Z,X,q){if(this.#J(Q))return q();if(this.signal?.aborted)q();if(this.paused){this.onResume(()=>this.walkCB2Sync(Q,Z,X,q));return}X.processPatterns(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#q(H))continue;this.matchSync(H,W,V)}for(let H of X.subwalkTargets()){if(this.maxDepth!==1/0&&H.depth()>=this.maxDepth)continue;Y++;let W=H.readdirSync();this.walkCB3Sync(H,W,X,J)}J()}walkCB3Sync(Q,Z,X,q){X=X.filterEntries(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#q(H))continue;this.matchSync(H,W,V)}for(let[H,W]of X.subwalks.entries())Y++,this.walkCB2Sync(H,W,X.child(),J);J()}}class h8 extends H7{matches=new Set;constructor(Q,Z,X){super(Q,Z,X)}matchEmit(Q){this.matches.add(Q)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise((Q,Z)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)Z(this.signal.reason);else Q(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class g8 extends H7{results;constructor(Q,Z,X){super(Q,Z,X);this.results=new x0({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(Q){if(this.results.write(Q),!this.results.flowing)this.pause()}stream(){let Q=this.path;if(Q.isUnknown())Q.lstat().then(()=>{this.walkCB(Q,this.patterns,()=>this.results.end())});else this.walkCB(Q,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var h4=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class B0{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(Q,Z){if(!Z)throw TypeError("glob options required");if(this.withFileTypes=!!Z.withFileTypes,this.signal=Z.signal,this.follow=!!Z.follow,this.dot=!!Z.dot,this.dotRelative=!!Z.dotRelative,this.nodir=!!Z.nodir,this.mark=!!Z.mark,!Z.cwd)this.cwd="";else if(Z.cwd instanceof URL||Z.cwd.startsWith("file://"))Z.cwd=f4(Z.cwd);if(this.cwd=Z.cwd||"",this.root=Z.root,this.magicalBraces=!!Z.magicalBraces,this.nobrace=!!Z.nobrace,this.noext=!!Z.noext,this.realpath=!!Z.realpath,this.absolute=Z.absolute,this.includeChildMatches=Z.includeChildMatches!==!1,this.noglobstar=!!Z.noglobstar,this.matchBase=!!Z.matchBase,this.maxDepth=typeof Z.maxDepth==="number"?Z.maxDepth:1/0,this.stat=!!Z.stat,this.ignore=Z.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error("cannot set absolute and withFileTypes:true");if(typeof Q==="string")Q=[Q];if(this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z.allowWindowsEscape===!1,this.windowsPathsNoEscape)Q=Q.map((W)=>W.replace(/\\/g,"/"));if(this.matchBase){if(Z.noglobstar)throw TypeError("base matching requires globstar");Q=Q.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=Q,this.platform=Z.platform||h4,this.opts={...Z,platform:this.platform},Z.scurry){if(this.scurry=Z.scurry,Z.nocase!==void 0&&Z.nocase!==Z.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let W=Z.platform==="win32"?K8:Z.platform==="darwin"?f8:Z.platform?_8:LQ;this.scurry=new W(this.cwd,{nocase:Z.nocase,fs:Z.fs})}this.nocase=this.scurry.nocase;let X=this.platform==="darwin"||this.platform==="win32",q={...Z,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:X,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},Y=this.pattern.map((W)=>new H0(W,q)),[J,H]=Y.reduce((W,V)=>{return W[0].push(...V.set),W[1].push(...V.globParts),W},[[],[]]);this.patterns=J.map((W,V)=>{let K=H[V];if(!K)throw Error("invalid pattern object");return new i0(W,K,0,this.platform)})}async walk(){return[...await new h8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new h8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new g8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new g8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var V7=(Q,Z={})=>{if(!Array.isArray(Q))Q=[Q];for(let X of Q)if(new H0(X,Z).hasMagic())return!0;return!1};function m8(Q,Z={}){return new B0(Q,Z).streamSync()}function SQ(Q,Z={}){return new B0(Q,Z).stream()}function c8(Q,Z={}){return new B0(Q,Z).walkSync()}async function TQ(Q,Z={}){return new B0(Q,Z).walk()}function l8(Q,Z={}){return new B0(Q,Z).iterateSync()}function NQ(Q,Z={}){return new B0(Q,Z).iterate()}var g4=m8,m4=Object.assign(SQ,{sync:m8}),c4=l8,l4=Object.assign(NQ,{sync:l8}),d4=Object.assign(c8,{stream:m8,iterate:l8}),wQ=Object.assign(TQ,{glob:TQ,globSync:c8,sync:d4,globStream:SQ,stream:m4,globStreamSync:m8,streamSync:g4,globIterate:NQ,iterate:l4,globIterateSync:l8,iterateSync:c4,Glob:B0,hasMagic:V7,escape:g0,unescape:z0});wQ.glob=wQ;import i4 from"node:path";var PQ=({dir:Q,pattern:Z="*",nodir:X=!1,dot:q=!0,ignore:Y=[],absolute:J=!1,matchBase:H=!1,follow:W=!1})=>{if(Q=Q||process.cwd(),Q=i4.resolve(Q),Z&&!Array.isArray(Z))Z=[Z];else Z=Z||["*"];if(Y&&!Array.isArray(Y))Y=[Y];else Y=Y||[];return c8(Z,{cwd:Q,nodir:X,dot:q,ignore:Y,absolute:J,matchBase:H,follow:W})};import bQ from"lodash.clonedeep";import p4 from"@fnet/key-value-transformer";async function m({node:Q,initNode:Z,extra:X=!0}){if(Reflect.has(Q.definition,"modules")&&!Array.isArray(Q.definition.modules)){let q=Q.definition.modules;Q.definition.modules=[],Object.keys(q).forEach((Y)=>{let J={...q[Y]};if(typeof J.export==="boolean")J.export=J.export===!0?Y:!1;else if(typeof J.export==="string")J.export=J.export;else delete J.export;Q.definition.modules.push({[Y]:J})})}if(X){let q=[],Y=await p4({data:Q.definition,callback:(J,H,W)=>{let V=N0(J,!0);if(V?.processor==="m"){let K=W.slice(0,-1);K.push(V.statement);let z=K.join("_");return q.push({[z]:H}),[V.statement,`m::${z}`]}return[J,H]}});if(q.length>0)Q.definition=Y,Q.definition.modules=Q.definition.modules||[],Q.definition.modules=Q.definition.modules.concat(q)}Q.hasModules=Q.definition.modules?.length>0;for(let q=0;q<Q.definition.modules?.length;q++){let Y=Q.definition.modules[q],J=Object.keys(Y)[0],H={name:J,childs:[],parent:Q,definition:Y[J],module:!0,block_child_auto_jump_to_parent:!0,index:Q.childs.length,context:{}};Q.childs.push(H),await Z({node:H})}}async function b({node:Q,transformExpression:Z}){let X=Q.context.transform;if(Reflect.has(X,"export"))X.export=await Z(X.export);if(Reflect.has(X,"return"))Q.hasReturn=!0,X.return=await Z(X.return);if(Reflect.has(X,"output"))X.output=await Z(X.output);if(Reflect.has(X,"assign"))for(let q=0;q<X.assign?.length;q++){let Y=X.assign[q];if(Object.keys(Y).length===0){X.assign.splice(q,1),q--;continue}let J=Object.keys(Y)[0],H=Y[J],W={key:await Z(J),value:await Z(H)};X.assign[q]=W}if(Reflect.has(X,"result")){if(typeof X.result==="string")X.result=[{[X.result]:"e::result"}];for(let q=0;q<X.result?.length;q++){let Y=X.result[q],J=Object.keys(Y)[0],H=Y[J],W={key:await Z(J),value:await Z(H)};X.result[q]=W}}}async function a4({node:Q}){if(!Q.definition.hasOwnProperty("switch"))return!1;return!0}async function n4({node:Q,initNode:Z}){Q.type="switch";let X=Q.definition.switch||[];if(!X.every((H)=>H.hasOwnProperty("condition")||H.hasOwnProperty("default")))throw Error("Switch must have condition or default");if(X.filter((H)=>H.hasOwnProperty("condition")).length===0)throw Error("Switch must have at least one condition");let J=X.filter((H)=>H.hasOwnProperty("default"));if(J.length>1)throw Error("Switch must have only one default");if(J.length===1&&!X[X.length-1].hasOwnProperty("default"))throw Error("Switch default must be the last child");Q.hasDefaultCondition=J.length===1,await m({node:Q,initNode:Z,extra:!1}),Q.block_child_auto_jump_to_sibling=!0;for(let H=0;H<Q.definition.switch.length;H++){let W=Q.definition.switch[H],V=`${H}`;if(W.hasOwnProperty("default"))V="default",W=W.default;let K={name:W.condition||V,childs:[],parent:Q,definition:W,index:Q.childs.length,context:{}};Q.childs.push(K),await Z({node:K})}Q.resolve=kQ}async function kQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||bQ(Q.definition);let Y=Q.context.transform;for(let J of Q.childs)if(J.context.transform=J.context.transform||bQ(J.definition),J.definition.hasOwnProperty("condition"))J.context.transform.condition=await q(J.definition.condition);if(await b({node:Q,transformExpression:q}),await Z({node:Q}),!Q.hasDefaultCondition)X({node:Q})}var U8={hits:a4,init:n4,resolve:kQ};async function r4({node:Q}){if(Object.keys(Q.definition).filter((q)=>N0(q)==="if").length===1)return!0;if(Q.definition.if&&typeof Q.definition.if==="object")return!0;return!1}async function s4(Q){let{node:Z}=Q,X=Object.keys(Z.definition),q=[],Y=X.find((W)=>N0(W)==="if");if(Y){let W=Z.definition[Y],V=N0(Y,!0);q.push({name:`${Z.name}_if`,definition:W,processor:{expression:Y,statement:V.statement,processor:V.processor}}),delete Z.definition[Y]}else if(Z.definition.if){let{condition:W,...V}=Z.definition.if;q.push({name:`${Z.name}_if`,definition:V,processor:{expression:`if::${W}`,statement:W}}),delete Z.definition.if}let J=X.filter((W)=>N0(W)==="elseif"),H=0;for(let W of J){let V=Z.definition[W],K=N0(W,!0);q.push({name:`${Z.name}_elseif_${H++}`,definition:V,processor:{expression:W,statement:K.statement,processor:K.processor}}),delete Z.definition[W]}if(Z.definition.elseif){let{condition:W,...V}=Z.definition.elseif;q.push({name:`${Z.name}_elseif_${H++}`,definition:V,processor:{expression:`elseif::${W}`,statement:W}}),delete Z.definition.elseif}Z.definition.switch=[];for(let W of q)Z.definition.switch.push({condition:W.processor.statement,...W.definition});if(Z.definition?.else){let W=Z.definition.else;Z.definition.switch.push({default:W}),delete Z.definition.else}await U8.init(Q)}var K7={hits:r4,init:s4};import DQ from"lodash.clonedeep";async function o4({node:Q}){return Q.definition.hasOwnProperty("try")&&Q.definition.hasOwnProperty("except")}async function t4({node:Q,initNode:Z}){if(Q.type="tryexcept",await m({node:Q,initNode:Z,extra:!1}),Q.block_child_auto_jump_to_sibling=!0,Q.definition.try){let q={name:"try",childs:[],parent:Q,definition:Q.definition.try,index:Q.childs.length,context:{}};Q.childs.push(q),await Z({node:q})}if(Q.definition.except){let q={name:"except",childs:[],parent:Q,definition:Q.definition.except,index:Q.childs.length,context:{}};Q.childs.push(q),await Z({node:q})}Q.resolve=vQ}async function vQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||DQ(Q.definition);let Y=Q.context.transform;if(Q.context.try=Q.childs.find((J)=>J.name==="try"),Q.context.except=Q.childs.find((J)=>J.name==="except"),Q.context.except){let J=Q.context.except;if(J.context.transform=J.context.transform||DQ(J.definition),!J.context.transform.hasOwnProperty("as"))J.context.transform.as="error"}await b({node:Q,transformExpression:q}),await Z({node:Q})}var _7={hits:o4,init:t4,resolve:vQ};import e4 from"lodash.clonedeep";async function Q1({node:Q}){return Q.definition.hasOwnProperty("assign")}async function Z1({node:Q,initNode:Z}){Q.type="assign",await m({node:Q,initNode:Z}),Q.resolve=yQ}async function yQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||e4(Q.definition);let Y=Q.context.transform;await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var z7={hits:Q1,init:Z1,resolve:yQ};import X1 from"lodash.clonedeep";async function q1({node:Q}){return Q.definition.hasOwnProperty("for")}async function Y1({node:Q,initNode:Z}){if(Q.type="for",await m({node:Q,initNode:Z,extra:!1}),Q.block_child_auto_jump_to_parent=!0,Q.block_child_auto_jump_to_sibling=!1,!Q.definition.for.hasOwnProperty("steps")){let{as:X,in:q,...Y}=Q.definition.for,J={};if(X!==void 0)J.as=X;if(q!==void 0)J.in=q;Q.definition.for=J,Q.definition.for.steps=[{[`${Q.name}_step`]:Y}]}if(!Array.isArray(Q.definition.for.steps))Q.definition.for.steps=[{[`${Q.name}_step`]:Q.definition.for.steps}];for(let X=0;X<Q.definition.for.steps.length;X++){let q=Q.definition.for.steps[X],Y=Object.keys(q)[0],J={name:Y,childs:[],parent:Q,definition:q[Y],index:Q.childs.length,context:{}};Q.childs.push(J),await Z({node:J})}Q.resolve=EQ}async function EQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||X1(Q.definition);let Y=Q.context.transform;Y.for.in=await q(Q.definition.for.in),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var G7={hits:q1,init:Y1,resolve:EQ};import J1 from"lodash.clonedeep";async function W1({node:Q}){return Q.definition.hasOwnProperty("parallel")}async function H1({node:Q,initNode:Z}){Q.type="parallel",Q.block_child_auto_jump_to_parent=!0,Q.block_child_auto_jump_to_sibling=!0;let X=Q.definition.parallel||[];for await(let q of X){let Y=Object.keys(q)[0],J={name:Y,childs:[],parent:Q,definition:q[Y],index:Q.childs.length,context:{}};Q.childs.push(J),await Z({node:J})}Q.resolve=xQ}async function xQ({node:Q,transformExpression:Z,resolveNextBlock:X}){Q.context.transform=Q.context.transform||J1(Q.definition),await b({node:Q,transformExpression:Z}),X({node:Q})}var U7={hits:W1,init:H1,resolve:xQ};import V1 from"lodash.clonedeep";async function K1({node:Q}){return Q.definition.hasOwnProperty("raise")}async function _1({node:Q,initNode:Z}){Q.type="raise",Q.resolve=uQ}async function uQ({node:Q,resolveTypeCommon:Z,transformExpression:X}){Q.context.transform=Q.context.transform||V1(Q.definition);let q=Q.context.transform;q.raise=await X(q.raise),await Z({node:Q})}var $7={hits:K1,init:_1,resolve:uQ};import z1 from"lodash.clonedeep";async function G1({node:Q}){return Q.definition.hasOwnProperty("return")}async function U1({node:Q,initNode:Z}){Q.type="return",Q.resolve=fQ}async function fQ({node:Q,resolveTypeCommon:Z,transformExpression:X}){Q.context.transform=Q.context.transform||z1(Q.definition);let q=Q.context.transform;Q.hasReturn=!0,q.return=await X(q.return),await Z({node:Q})}var M7={hits:G1,init:U1,resolve:fQ};import $1 from"lodash.clonedeep";async function M1({node:Q}){return Q.definition.hasOwnProperty("call")}async function O1({node:Q,initNode:Z}){Q.type="call",await m({node:Q,initNode:Z}),Q.resolve=hQ}async function hQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||$1(Q.definition);let Y=Q.context.transform,J=Y.from||Y.import||Y.call;if(Q.target?.atom?.doc?.type==="function"){if(Reflect.has(Y,"from"))J=Y.from,Y.from=await q(Q.target.atom.name);else if(Reflect.has(Y,"import"))J=Y.import,Y.import=await q(Q.target.atom.name);else if(Reflect.has(Y,"call"))Y.call=await q(Q.target.atom.name),J=Y.call}else if(Reflect.has(Y,"from")||Reflect.has(Y,"import")){if(Y.call.startsWith("use:e::")){let W=Y.call.substring(7);Y.libExp=await q(`e::LIBRARY.${W}`)}}if(Y.args)Y.args=await q(Y.args);if(Y.new)Y.new=await q(Y.new);if(Y.context)Y.context=await q(Y.context);let H=Q.workflow.parent;Q.context.lib=H.context.libs.find((W)=>W.name===J),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var $8={hits:M1,init:O1,resolve:hQ};import A1 from"lodash.clonedeep";async function B1({node:Q}){return Q.definition.hasOwnProperty("steps")}async function R1({node:Q,initNode:Z}){if(!Q.type)Q.type="steps";let X=Q.definition.steps||[];for await(let q of X){let Y=Object.keys(q)[0];if(q[Y].enabled===!1)continue;let J={name:Y,childs:[],parent:Q,definition:q[Y],index:Q.childs.length,context:{}};Q.childs.push(J),await Z({node:J})}Q.resolve=gQ}async function gQ({node:Q,transformExpression:Z}){Q.context.next=Q.childs[0],Q.context.transform=Q.context.transform||A1(Q.definition),await b({node:Q,transformExpression:Z})}var O7={hits:B1,init:R1,resolve:gQ};import I1 from"lodash.clonedeep";async function C1({node:Q}){return Q.definition.hasOwnProperty("form")}async function L1({node:Q,initNode:Z}){Q.type="form",await m({node:Q,initNode:Z}),Q.resolve=mQ}async function mQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||I1(Q.definition);let Y=Q.context.transform;if(Y.props)Y.props=await q(Y.props);let J=Q.workflow.parent;Q.context.lib=J.context.libs.find((H)=>H.name===Y.form),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var A7={hits:C1,init:L1,resolve:mQ};import F1 from"lodash.clonedeep";async function j1({node:Q}){return Q.definition.hasOwnProperty("signal")}async function T1({node:Q,initNode:Z}){Q.type="signal",Q.resolve=cQ}async function cQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q,transformValue:Y}){Q.context.transform=Q.context.transform||F1(Q.definition),await Z({node:Q}),X({node:Q})}var B7={hits:j1,init:T1,resolve:cQ};import w1 from"lodash.clonedeep";async function S1({node:Q}){return Q.definition.hasOwnProperty("wait")}async function N1({node:Q,initNode:Z}){Q.type="wait",Q.resolve=lQ}async function lQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q,transformValue:Y}){Q.context.transform=Q.context.transform||w1(Q.definition),await Z({node:Q}),X({node:Q})}var R7={hits:S1,init:N1,resolve:lQ};import P1 from"lodash.clonedeep";async function b1({node:Q}){return Q.definition.hasOwnProperty("next")}async function k1({node:Q,initNode:Z}){Q.type="next",Q.resolve=dQ}async function dQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||P1(Q.definition);let Y=Q.context.transform;Y.next=await q(Y.next),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var I7={hits:b1,init:k1,resolve:dQ};import D1 from"lodash.clonedeep";async function v1({node:Q}){return Q.definition.hasOwnProperty("modules")}async function y1({node:Q,initNode:Z}){Q.type="modules",await m({node:Q,initNode:Z}),Q.resolve=iQ}async function iQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||D1(Q.definition);let Y=Q.context.transform;await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var C7={hits:v1,init:y1,resolve:iQ};function L7({node:Q}){let Z=Q.definition;if(Q.hasReturn){if(j("tree"))f.info(`[RETURN] no next: ${Q.indexKey}`);return}if(Z.next==="end"){if(j("tree"))f.info(`[EXPLICIT-END] ${Q.indexKey}`)}else if(Z.next==="stop"){if(j("tree"))f.info(`[EXPLICIT-STOP] ${Q.indexKey}`)}else if(Z.next==="none"){if(j("tree"))f.info(`[EXPLICIT-NONE] ${Q.indexKey}`)}else if(Z.next){if(j("tree"))f.info(`[EXPLICIT-NEXT] "${Z.next}" from ${Q.indexKey}`);let X=Q.parent;while(X.parent){let q=X.childs.find((Y)=>Y.name===Z.next);if(q){if(Q.context.next=q,j("tree"))f.info(`[FOUND] ${q.indexKey}`);break}X=X.parent}if(!Q.context.next&&j("tree"))f.warn(` [NOT-FOUND] "${Z.next}"`)}else{if(Q.module===!0){if(j("tree"))f.info(`[MODULE-ROOT] no auto next: ${Q.indexKey}`);return}if(j("tree"))f.info(`[AUTO-NEXT] from ${Q.indexKey}`);let X=Q.parent,q=Q.index+1,Y=0;while(X.parent)if(Y++,X.block_child_auto_jump_to_parent&&X.block_child_auto_jump_to_sibling){if(j("tree"))f.info(`${Y}. [BLOCKED] both jumps disabled at ${X.indexKey}`);break}else if(!Reflect.has(X,"block_child_auto_jump_to_parent")&&!Reflect.has(X,"block_child_auto_jump_to_sibling")){let J=X.childs.find((H)=>H.index===q);if(J){if(Q.context.next=J,j("tree"))f.info(`${Y}. [SIBLING-FOUND] ${J.indexKey}`);break}else{if(j("tree"))f.info(`${Y}. [CLIMB] no sibling, climbing to parent: ${X.parent?.indexKey}`);q=X.index+1,X=X.parent;continue}}else if(X.block_child_auto_jump_to_parent){let J=X.childs.find((H)=>H.index===q);if(J){if(Q.context.next=J,j("tree"))f.info(`${Y}. [SIBLING-FOUND] parent jump disabled: ${J.indexKey}`)}else if(j("tree"))f.info(`${Y}. [BLOCKED] no sibling, parent jump disabled`);break}else if(!X.block_child_auto_jump_to_parent){if(j("tree"))f.info(`${Y}. [CLIMB] sibling disabled, climbing to parent: ${X.parent?.indexKey}`);q=X.index+1,X=X.parent;continue}if(Q.context.next&&j("tree"))f.info(`[RESOLVED] auto next: ${Q.context.next.indexKey} (${Y} steps)`);else if(j("tree"))f.info(`[NO-NEXT] end of flow (${Y} steps)`)}}class pQ{#Z;#Q;#X;#q;constructor({key:Q,npm:Z,master:X,extras:q}){this.#Z=Q,this.#Q=Z,this.#X=X,this.#q=q}hits({node:Q}){return Q.definition.hasOwnProperty(this.#Z)}async init(Q){let{node:Z}=Q,X=this.#Z,q=Z.definition,Y=typeof q[X];if(q.call=`npm:${this.#Q}`,Y!=="object")q.args={...q.args,[`${this.#X}`]:q[X]};else q.args=q[X];if(delete q[X],this.#q)for(let J in this.#q)q[J]=this.#q[J];console.log(`[npm-block] ${this.#Z} --> ${this.#Q}`),await $8.init(Q)}}function r(Q){return new pQ(Q)}import E1 from"lodash.clonedeep";async function x1({node:Q}){return Q.definition.hasOwnProperty("new")}async function u1({node:Q,initNode:Z}){Q.type="new",await m({node:Q,initNode:Z}),Q.resolve=aQ}async function aQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||E1(Q.definition);let Y=Q.context.transform,J=Y.from||Y.import;if(Q.target?.atom?.doc?.type==="function"){if(Reflect.has(Y,"from"))J=Y.from,Y.from=await q(Q.target.atom.name);else if(Reflect.has(Y,"import"))J=Y.import,Y.import=await q(Q.target.atom.name)}if(Y.args)Y.args=await q(Y.args);if(Y.new)Y.new=await q(Y.new);let H=Q.workflow.parent;Q.context.lib=H.context.libs.find((W)=>W.name===J),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var F7={hits:x1,init:u1,resolve:aQ};import f1 from"lodash.clonedeep";async function h1({node:Q}){return Q.definition.hasOwnProperty("output")}async function g1({node:Q,initNode:Z}){Q.type="output",await m({node:Q,initNode:Z}),Q.resolve=nQ}async function nQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||f1(Q.definition),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var j7={hits:h1,init:g1,resolve:nQ};import m1 from"lodash.clonedeep";async function c1({node:Q}){return Q.definition.hasOwnProperty("pipeline")}async function l1({node:Q}){Q.type="pipeline";let Z=Q.definition.pipeline;if(!Z||typeof Z!=="string")throw Error(`Pipeline step '${Q.indexKey}' requires a binary name`);Q.definition.binaryName=Z,Q.resolve=rQ}async function rQ({node:Q,transformExpression:Z,resolveNextBlock:X}){Q.context.transform=Q.context.transform||m1(Q.definition);let q=Q.context.transform;if(q.input)q.input=await Z(q.input);if(q.args)q.args=await Z(q.args);if(q.env)q.env=await Z(q.env);if(q.cwd)q.cwd=await Z(q.cwd);await b({node:Q,transformExpression:Z}),X({node:Q})}var T7={hits:c1,init:l1,resolve:rQ};import d1 from"lodash.clonedeep";async function i1({node:Q}){return Q.definition.hasOwnProperty("retry")}async function p1({node:Q,initNode:Z}){Q.type="retry";let X=Q.definition.retry,q;if(typeof X==="number")q={attempts:X,delay:1000,backoff:"exponential",maxDelay:null};else if(typeof X==="object")q={attempts:X.attempts||3,delay:X.delay||1000,backoff:X.backoff||"exponential",maxDelay:X.maxDelay||null,on:X.on,onRetry:X.onRetry};else throw Error(`Retry step '${Q.name}' requires a number or object configuration`);if(!q.attempts||q.attempts<1)throw Error(`Retry step '${Q.name}' requires attempts >= 1`);let Y=["exponential","linear","fixed"];if(!Y.includes(q.backoff))throw Error(`Retry step '${Q.name}' has invalid backoff strategy '${q.backoff}'. Valid options: ${Y.join(", ")}`);Q.definition.retry=q;let{retry:J,...H}=Q.definition,W={name:`${Q.name}_retryable`,childs:[],parent:Q,definition:H,index:0,context:{}};Q.childs.push(W),await Z({node:W}),Q.resolve=sQ}async function sQ({node:Q,transformExpression:Z,resolveNextBlock:X}){Q.context.transform=Q.context.transform||d1(Q.definition);let q=Q.context.transform;if(q.retry.attempts&&typeof q.retry.attempts==="string")q.retry.attempts=await Z(q.retry.attempts);if(q.retry.delay&&typeof q.retry.delay==="string")q.retry.delay=await Z(q.retry.delay);if(q.retry.maxDelay&&typeof q.retry.maxDelay==="string")q.retry.maxDelay=await Z(q.retry.maxDelay);if(q.retry.onRetry)q.retry.onRetry=await Z(q.retry.onRetry);await b({node:Q,transformExpression:Z}),X({node:Q})}var w7={hits:i1,init:p1,resolve:sQ};import a1 from"lodash.clonedeep";async function n1({node:Q}){return Q.definition.hasOwnProperty("schedule")}async function r1({node:Q,initNode:Z}){Q.type="schedule";let X=Q.definition.schedule,q;if(typeof X==="string")q={cron:X,timezone:null,enabled:!0};else if(typeof X==="object")q={cron:X.cron,timezone:X.timezone||null,enabled:X.enabled!==!1};else throw Error(`Schedule step '${Q.name}' requires a cron expression string or object`);if(!q.cron||typeof q.cron!=="string")throw Error(`Schedule step '${Q.name}' requires a valid cron expression`);Q.definition.schedule=q;let{schedule:Y,...J}=Q.definition,H={name:`${Q.name}_scheduled`,childs:[],parent:Q,definition:J,index:0,context:{}};Q.childs.push(H),await Z({node:H}),Q.resolve=oQ}async function oQ({node:Q,transformExpression:Z,resolveNextBlock:X}){Q.context.transform=Q.context.transform||a1(Q.definition);let q=Q.context.transform;if(q.schedule){if(q.schedule.cron&&typeof q.schedule.cron==="string")q.schedule.cron=await Z(q.schedule.cron);if(q.schedule.timezone&&typeof q.schedule.timezone==="string")q.schedule.timezone=await Z(q.schedule.timezone)}await b({node:Q,transformExpression:Z}),X({node:Q})}var S7={hits:n1,init:r1,resolve:oQ};import s1 from"lodash.clonedeep";async function o1({node:Q}){return Q.definition.hasOwnProperty("http")}async function t1({node:Q,initNode:Z}){Q.type="http",await m({node:Q,initNode:Z});let X=Q.definition.http,q;if(typeof X==="string")q={url:X,method:"GET",headers:{},timeout:30000};else if(typeof X==="object"){if(q={url:X.url,method:X.method||"GET",headers:X.headers||{},body:X.body,params:X.params,timeout:X.timeout||30000},!q.url)throw Error(`HTTP step '${Q.name}' requires a url property`)}else throw Error(`HTTP step '${Q.name}' requires a string URL or object configuration`);let Y=["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"],J=q.method.toUpperCase();if(!Y.includes(J))throw Error(`HTTP step '${Q.name}' has invalid method '${q.method}'. Valid options: ${Y.join(", ")}`);if(q.method=J,q.timeout&&(typeof q.timeout!=="number"||q.timeout<=0))throw Error(`HTTP step '${Q.name}' timeout must be a positive number`);Q.definition.http=q,Q.resolve=e1}async function e1({node:Q,transformExpression:Z,resolveNextBlock:X}){Q.context.transform=Q.context.transform||s1(Q.definition);let q=Q.context.transform;if(q.http.url)q.http.url=await Z(q.http.url);if(q.http.headers)q.http.headers=await Z(q.http.headers);if(q.http.body)q.http.body=await Z(q.http.body);if(q.http.params)q.http.params=await Z(q.http.params);if(q.http.timeout)q.http.timeout=await Z(q.http.timeout);await b({node:Q,transformExpression:Z}),X({node:Q})}var N7={hits:o1,init:t1};var tQ=({path:Q})=>{if(!Q)throw Error("Path is required");let Z=/^@([^\/]+\/[^\/]+)(?:\/(.+))?$/,X=/^([^\/]+)(?:\/(.+))?$/,q;if(q=Q.match(Z))return{path:Q,package:"@"+q[1],subpath:q[2]||null};else if(q=Q.match(X))return{path:Q,package:q[1],subpath:q[2]||null};return null};import W2 from"node:os";class qZ{#Z;#Q;#X;#q;#J;#C;#I;#K;#G;#V;#z;#Y;#O;#M;#$;#A;#j;#R;#F;#H;#L;#_=[];constructor(Q){this.#Z=new o7,this.#Q=Q,this.#C=[],this.#I=[],this.#K={},this._expire_ttl=3600,this._expire_ttl_short=300,this.#_.push(r({key:"config",npm:"@fnet/config",master:"name"})),this.#_.push(r({key:"yaml",npm:"@fnet/yaml",master:"file"})),this.#_.push(r({key:"prompt",npm:"@fnet/prompt",master:"message"})),this.#_.push(r({key:"html-link",npm:"@flownet/lib-load-browser-link-url",master:"src"})),this.#_.push(r({key:"html-script",npm:"@flownet/lib-load-browser-script-url",master:"src"})),this.#_.push(r({key:"http-server",npm:"@fnet/node-express",master:"server_port"})),this.#_.push(r({key:"shell",npm:"@fnet/shell-flow",master:"commands"})),this.#_.push(r({key:"list-files",npm:"@fnet/list-files",master:"pattern"})),this.#_.push(r({key:"up-list-files",npm:"@fnet/up-list-files",master:"pattern"})),this.#_.push(r({key:"auto-conda-env",npm:"@fnet/auto-conda-env",master:"envDir"})),this.#_.push(r({key:"ollama-chat",npm:"@fnet/ollama-chat",master:"model"})),this.#_.push(r({key:"ai",npm:"@fnet/ai",master:"prompt",extras:{subtype:"flow"}})),this.#_.push(r({key:"invoke",npm:"@fnet/invoke",master:"method",extras:{}})),this.#_.push(r({key:"fetch",npm:"@fnet/fetch",master:"url",extras:{}})),this.#_.push(r({key:"filemap",npm:"@fnet/filemap",master:"target",extras:{}})),this.#H={packageDependencies:this.#C,packageDevDependencies:this.#I,setProgress:this.setProgress.bind(this),context:this.#Q,Atom:R0,registerToPackageManager:this.registerToPackageManager.bind(this)},this.#L={initNode:this.initNode.bind(this),cloneDeep:ZZ,resolveTypeCommon:this.resolveTypeCommon.bind(this),resolveNextBlock:L7,transformExpression:this.transformExpression.bind(this),transformValue:this.transformValue.bind(this)}}async _cache_set(Q,Z,X){}async init(){this.#z=this.#Q.buildId||XZ(),this.#H.buildId=this.#z,this.#$=this.#Q.mode,this.#A=["all","deploy","build","file"].includes(this.#$),this.#j=["all","deploy","build"].includes(this.#$),this.#R=["all","deploy"].includes(this.#$),this.#F=["all","deploy","build","file","bpmn"].includes(this.#$),this.#O=this.#Q.protocol,this.#Y="BUILD:"+this.#z,this.#M=(await X2({optional:!0,name:"atom",dir:this.#Q.projectDir,tags:this.#Q.tags}))?.data;try{await this.setProgress({message:"Initialization started."});let Q=this.#H.context.project;await this.initAuth(),await this.initWorkflow(),this.transformWorkflow({workflow:this.#q});let Z=await this.initNodeTree({workflow:this.#q});if(await this.initNodeTreeIndex({root:Z}),await this.initNodeCalls({root:Z}),await this.initNodeCallLibs({root:Z}),await this.initNodeForms({root:Z}),await this.initNodeFormLibs({root:Z}),await this.initEntryFiles({root:Z,features:this.#X.doc.features}),await this.initFeaturesFromNodes({childs:Z.childs,features:this.#X.doc.features}),await A6(this.#H),Q.runtime.type==="bun")await R6(this.#H);else await B6(this.#H);await this.initAtomLibsAndDeps({libs:Z.context.libs,packageDependencies:this.#C}),await this.resolveNodeTree({root:Z}),this.#V=Z}catch(Q){throw await this._cache_set(this.#Y,{status:"FAILED",message:Q?.message||Q}),Q}}async initAuth(){if(!this.#Q.id)return;this.#G=await this.#Z.init({config:this.#M}),this.#H.atomAccessToken=this.#G}async initWorkflow(){let Q=this.#Q.id;this.#X=this.#Q.project?.workflowAtom||await R0.get({id:Q}),this.#q=typeof this.#X.doc.content==="string"?(await Y2({content:this.#X.doc.content,tags:this.#Q.tags})).parsed:this.#X.doc.content;let Z=this.#X.doc.bundleName;Z=Z||(this.#X.doc.name||"").toUpperCase().replace(/[^A-Z0-9]/g,"_"),this.#X.doc.bundleName=Z,this.#X.type=this.#X.type||"workflow",this.#H.atom=this.#X,this.#X.doc.features=this.#X.doc.features||{}}#T(Q){if(console.log("filePath",Q),T.statSync(Q).isDirectory())T.readdirSync(Q).forEach((Z)=>{let X=k.join(Q,Z);this.#T(X)}),T.rmSync(Q);else T.unlinkSync(Q)}#B(Q,Z){let X=T.existsSync(Q),q=X&&T.statSync(Q);if(X&&q.isDirectory())T.mkdirSync(Z,{recursive:!0}),T.readdirSync(Q).forEach((J)=>{this.#B(k.join(Q,J),k.join(Z,J))});else T.copyFileSync(Q,Z)}async initWorkflowDir(){this.setProgress({message:"Initializing library directory."});let Q=this.#Q.projectDir,Z=this.#Q.projectSrcDir,X=this.#Q.coreDir;this.setProgress({message:"Cleaning project directory."});let q=PQ({dir:Q,ignore:[".cache","node_modules",".conda",".bin",".dev"],absolute:!0});for(let V of q)T.rmSync(V,{recursive:!0,force:!0});if(this.setProgress({message:"Creating project directory."}),!T.existsSync(Q))T.mkdirSync(Q,{recursive:!0});let Y=k.join(Q,"src");if(!T.existsSync(Y))T.mkdirSync(Y,{recursive:!0});let J=k.join(Y,"core");this.#B(X,J);let H=k.join(Y,"default","blocks");if(!T.existsSync(H))T.mkdirSync(H,{recursive:!0});let W=k.join(Q,".dev");if(!T.existsSync(W))T.mkdirSync(W,{recursive:!0});if(this.#X.doc.features?.symlinks===!0){if(W=this.#Q.projectSrcDirSymlink,!T.existsSync(W))try{if(W2.platform()==="win32")T.symlinkSync(Z,W,"junction");else T.symlinkSync(Z,W,"dir")}catch(V){throw Error(`Couldn't create symlink. Error: ${V.message}`)}}}async initNunjucks(){this.setProgress({message:"Initializing nunjucks."});let Q=this.#Q.templateDir;this.#J=M8.configure(Q,{watch:!1,dev:!0}),this.#H.njEnv=this.#J}transformWorkflow({workflow:Q}){for(let Z of Object.values(Q))Z.steps=Z.steps||[],Z.steps=Z.steps.filter((X)=>Object.keys(X).length>0),Z.steps=Z.steps.map((X)=>this.transformStep({step:X}))}transformStep({step:Q}){if(Array.isArray(Q))throw Error("Step must be an object.");let[Z,X]=Object.entries(Q)[0];if(X.hasOwnProperty("onerror")){let{onerror:q,...Y}=X;Q[Z]={try:Y,except:q}}if(Q[Z].hasOwnProperty("steps")){let q=Q[Z].steps;if(!Array.isArray(q))throw Error("Steps must be an array.");Q[Z].steps=q.map((Y)=>this.transformStep({step:Y}))}return Q}async initNodeTree({workflow:Q}){let Z=["$meta","$project","$features","$input","$output","$commands"],X=Object.keys(Q).filter((Y)=>!Z.includes(Y));if(j("tree"))f.info("[TREE] Creating root node");let q={definition:Q,name:void 0,type:"root",parent:void 0,childs:[],block_child_auto_jump_to_parent:!0,block_child_auto_jump_to_sibling:!0,index:0,depth:0,context:{libs:[],atom:this.#X}};X.forEach((Y)=>{if(j("tree"))f.info(`[TREE] Creating ${Y==="main"?"workflow":"subworkflow"}: ${Y}`);let J={name:Y,type:Y==="main"?"workflow":"subworkflow",enabled:Q[Y].enabled!==!1,childs:[],parent:q,definition:Q[Y],index:q.childs.length,depth:q.depth+1,context:{},block_child_auto_jump_to_parent:!0};q.childs.push(J)});for(let Y=0;Y<q.childs.length;Y++){let J=q.childs[Y];if(j("tree"))f.info(`[INIT] node: ${J.name}`);if(J.definition.enabled===!1){q.childs.splice(Y,1),Y--;continue}else await this.initNode({node:J})}if(j("tree"))f.info(`[TREE] Root node tree created (${q.childs.length} flows)`);return q}async initNode({node:Q}){let Z={...this.#L,node:Q};Q.workflow=Q.parent.workflow||Q,Q.depth=Q.parent.depth+1;let X="unknown";if(await _7.hits(Z))X="tryexcept",await _7.init(Z);else if(await U8.hits(Z))X="switch",await U8.init(Z);else if(await K7.hits(Z))X="if",await K7.init(Z);else if(await G7.hits(Z))X="for",await G7.init(Z);else if(await w7.hits(Z))X="retry",await w7.init(Z);else if(await S7.hits(Z))X="schedule",await S7.init(Z);else if(await U7.hits(Z))X="parallel",await U7.init(Z);else if(await T7.hits(Z))X="pipeline",await T7.init(Z);else if(await N7.hits(Z))X="http",await N7.init(Z);else if(await $8.hits(Z))X="call",await $8.init(Z);else if(await F7.hits(Z))X="new",await F7.init(Z);else if(await $7.hits(Z))X="raise",await $7.init(Z);else if(await A7.hits(Z))X="form",await A7.init(Z);else if(await B7.hits(Z))X="signal",await B7.init(Z);else if(await R7.hits(Z))X="wait",await R7.init(Z);else if(await O7.hits(Z))X="steps",await O7.init(Z);else if(await I7.hits(Z))X="next",await I7.init(Z);else if(await C7.hits(Z))X="modules",await C7.init(Z);else if(this.#_.find((q)=>q.hits(Z)))X="npm-block",await this.#_.find((q)=>q.hits(Z)).init(Z);else if(await z7.hits(Z))X="assign",await z7.init(Z);else if(await j7.hits(Z))X="output",await j7.init(Z);else if(await M7.hits(Z))X="return",await M7.init(Z);else throw Error("Undefined step type.");if(j("tree")){let q=Q.childs?.length>0?` (${Q.childs.length} childs)`:"";f.info(`[NODE] ${X}: ${Q.name}${q}`)}return!0}async initNodeTreeIndex({root:Q}){let Z={};Q.indexKey="/";for await(let X of Q.childs)await this.initNodeIndex({node:X,index:Z});return Q.context.index=Z,Z}async initNodeIndex({node:Q,index:Z}){let X=k.join(Q.parent.indexKey,Q.name);Q.indexKey=X,Z[X]=Q;let q=[],Y=Q;while(Y?.parent)q.push(Y.index),Y=Y.parent;q.reverse(),Q.codeKey=`B_${q.join("_")}_${Q.type}`,Q.pathKey=`${q.join(".")}`,Q.typeId=XZ();for await(let J of Q.childs)await this.initNodeIndex({node:J,index:Z})}async initNodeCalls({root:Q}){let Z=Q.context.index,X=[];for await(let q of Object.keys(Z)){let Y=Z[q];if(Y.type!=="call"&&Y.type!=="new")continue;X.push(Y)}return Q.context.calls=X,X}async initNodeCallLibs({root:Q}){let Z=[],X=Q.context.calls;for await(let q of X){let Y=q.definition.from||q.definition.import||q.definition.call,J=await this.findNodeCallTarget({refNode:q,curNode:q.parent})||{name:Y,type:"atom",definition:q.definition},H=Z.find((W)=>W.name===J.name&&W.type===J.type);if(!H)Z.push(J);q.target=H||J}return Q.context.callLibs=Z,Q.context.libs=[...Q.context.libs,...Z],Z}async findNodeCallTarget({refNode:Q,curNode:Z}){if(!Z)return;let X=Q.definition.call,q=Z.childs.find((Y)=>Y.name===X&&Y.type==="subworkflow");if(q)return q;else return await this.findNodeCallTarget({refNode:Q,curNode:Z.parent})}async initNodeForms({root:Q}){let Z=Q.context.index,X=[];for await(let q of Object.keys(Z)){let Y=Z[q];if(Y.type!=="form")continue;X.push(Y)}return Q.context.forms=X,X}async initNodeFormLibs({root:Q}){let Z=[],X=Q.context.forms;for await(let q of X){let Y=q.definition.from||q.definition.import||q.definition.form,J=await this.findNodeCallTarget({refNode:q,curNode:q.parent})||{name:Y,type:"atom"},H=Z.find((W)=>W.name===J.name&&W.type===J.type);if(!H)Z.push(J);q.target=H||J}return Q.context.formLibs=Z,Q.context.libs=[...Q.context.libs,...Z],Z}async initFeaturesFromNodes({childs:Q,features:Z}){for await(let X of Q){if(X.type==="form"&&!Reflect.has(Z,"form"))Z.form=!0;await this.initFeaturesFromNodes({childs:X.childs,features:Z})}}async initEntryFiles({root:Q,features:Z}){for await(let X of Q.childs){let q;if(X.name==="main")q="index.js";else if(X.name==="cli")q="cli.js";else if(X.name==="app")q="app.js";else if(X.name==="api")q="api.js";else continue;Z[`${X.name}_default_entry_file`]=q,X.entryFile=q}}async findNodeFormTarget({refNode:Q,curNode:Z}){if(!Z)return;let X=Q.definition.form,q=Z.childs.find((Y)=>Y.name===X&&Y.type==="subworkflow");if(q)return q;else return await this.findNodeFormTarget({refNode:Q,curNode:Z.parent})}async initAtomLibsAndDeps({libs:Q,packageDependencies:Z}){let X=Q.filter((q)=>q.type==="atom");for(let q=0;q<X.length;q++){let Y=X[q],J=await this.findAtomLibrary({url:Y.name,libRef:Y});Y.atom=J,J.doc.dependencies?.filter((W)=>typeof W.repo>"u"||W.repo==="npm")?.forEach((W)=>{let V=Z.find((K)=>K.package===W.package);if(V){if(typeof W.path==="string"){if(!(V.path||[]).some((K)=>K===W.path))V.path=V.path||[],V.path.push(W.path)}else if(Array.isArray(W.path))W.path.forEach((K)=>{if(!(V.path||[]).some((z)=>z===K))V.path=V.path||[],V.path.push(K)})}else Z.push(W)})}Z.sort((q,Y)=>q.package?.localeCompare(Y.package))}async findAtomLibrary({url:Q,libRef:Z}){let X=Z2({url:Q});if(!X)throw Error(`Invalid package name: ${Q}`);if(!X.protocol)X.protocol=this.#O;if(X.protocol==="src:"){let q=k.resolve(this.#Q.projectSrcDir,`${X.pathname}.js`),Y=[],H=(await q2({file:q,recursive:!0})).all;for await(let V of H){if(V.type!=="npm")continue;if(Y.find((z)=>z.package===V.package))continue;let K=await T0({name:V.package,projectDir:this.#Q.projectDir,setProgress:this.#H.setProgress});Y.push({package:V.package,subpath:V.subpath,version:K.minorRange,type:"npm"})}return{name:X.pathname,doc:{type:"workflow.lib","content-type":"javascript",language:"js",dependencies:Y},protocol:X.protocol}}else if(X.protocol==="npm:"){let q=tQ({path:X.pathname}),Y=await T0({name:q.package,subpath:q.subpath,projectDir:this.#Q.projectDir,setProgress:this.#H.setProgress});return{name:X.pathname,doc:{type:"workflow.lib",subtype:Z?.definition?.subtype==="flow"?"workflow":null,"content-type":"javascript",language:"js",dependencies:[{package:q.package,version:Y.minorRange,type:"npm"}]},protocol:X.protocol}}else if(X.protocol==="use:")return{name:X.pathname,doc:{type:"function",dependencies:[]},protocol:X.protocol};else if(X.protocol==="node:")return{name:X.pathname,doc:{type:"workflow.lib","content-type":"javascript",language:"js",dependencies:[]},protocol:X.protocol};else if(X.protocol==="ac:"){let q=X.pathname.split("/");if(q.length===1)return await R0.first({where:{name:Q,parent_id:this.#M.env.ATOM_LIBRARIES_ID,type:"workflow.lib"}});if(q.length===2){let Y=await R0.first({where:{name:q[0],parent_id:this.#M.env.ATOM_LIBRARIES_ID,type:"folder"}});return await R0.first({where:{name:q[1],parent_id:Y.id,type:"workflow.lib"}})}}}async resolveNodeTree({root:Q}){for await(let Z of Q.childs)await this.resolveTypeWorkflow({node:Z})}async resolveTypeWorkflow({node:Q}){Q.context.transform=Q.context.transform||ZZ(Q.definition);let Z=Q.context.transform;for(let X=0;X<Z.params?.length;X++){let q=Z.params[X];if(typeof q==="string")Z.params[X]={key:q,hasDefault:!1};else{if(Object.keys(q).length===0){Z.params.splice(X,1),X--;continue}let Y=Object.keys(q)[0];Z.params[X]={key:Y,hasDefault:!0,default:q[Y],type:typeof q[Y]}}}Q.context.next=Q.childs[0];for await(let X of Q.childs)await this.resolveType({node:X})}async resolveType({node:Q}){let Z={...this.#L,node:Q};if(typeof Q.resolve==="function")await Q.resolve(Z);for await(let X of Q.childs)await this.resolveType({node:X})}async resolveTypeCommon({node:Q}){let Z=Q.context.transform;if(Z.hasOwnProperty("page"))Z.page=await this.transformExpression(Z.page);if(Z.hasOwnProperty("print"))Z.print=await this.transformExpression(Z.print);if(Z.hasOwnProperty("sleep"))Z.sleep=await this.transformExpression(Z.sleep);if(Z.hasOwnProperty("assert"))Z.assert=await this.transformExpression(Z.assert)}async createAtomLibFiles({root:Q}){await this.setProgress({message:"Creating external lib files."}),this.#X.typesDir="./types";let X=Q.context.libs.filter((q)=>q.type==="atom");for(let q=0;q<X.length;q++){let J=X[q].atom,H=this.#Q.projectDir;if(J.protocol==="src:"){let W=this.#X.doc.features?.symlinks===!0?this.#Q.projectSrcDirSymlink:this.#Q.projectSrcDir;W=k.resolve(W,`${J.fileName||J.name}.js`);let V=k.relative(`${this.#Q.projectDir}/src/default/blocks`,W);if(!T.existsSync(W)){T.mkdirSync(k.dirname(W),{recursive:!0});let K=`export default async (input)=>{
|
|
12
|
-
`;K+="}",T.writeFileSync(W,K,"utf8")}J.relativePath=V.split(k.sep).join("/"),this.#X.typesDir=`./types/${k.basename(H)}/src`}else if(J.protocol==="npm:")J.relativePath=J.name;else if(J.protocol==="node:")J.relativePath=J.name;else if(J.protocol==="use:");else{let W=`${H}/src/libs/${J.id}.js`,V=J.doc.contents?.find((K)=>K.format==="esm")||J.doc;T.writeFileSync(k.normalize(W),V.content,"utf8")}}}async createEngine({root:Q}){await this.setProgress({message:"Creating engine file."});let Z=this.#Q.templateDir,X=M8.compile(T.readFileSync(k.resolve(Z,"src/default/engine.js.njk"),"utf8"),this.#J);for(let q=0;q<Q.childs.length;q++){let Y=Q.childs[q];if(!Y.entryFile)continue;let J=X.render({flow:Y,ui:{package:"@fnet/react-app"}}),H=this.#Q.projectDir,W=k.resolve(H,`src/default/${Y.entryFile}`);T.writeFileSync(W,J,"utf8")}}async createNodeTree({root:Q}){await this.setProgress({message:"Creating block files."});for await(let Z of Q.childs)await this.createTypeWorkflow({node:Z})}async createTypeWorkflow({node:Q}){let Z=this.#Q.templateDir,q=M8.compile(T.readFileSync(k.resolve(Z,"src/default/workflow.js.njk"),"utf8"),this.#J).render(Q),Y=this.#Q.projectDir,J=k.resolve(Y,`src/default/${Q.codeKey}.js`);T.writeFileSync(J,q,"utf8");for await(let H of Q.childs)await this.createType({node:H})}async createType({node:Q}){switch(Q.type){case"assign":case"steps":case"return":case"call":case"new":case"form":case"raise":case"switch":case"next":case"tryexcept":case"for":case"parallel":case"signal":case"wait":case"modules":case"output":case"pipeline":case"retry":case"schedule":case"http":this.createBlockFromTemplate({node:Q});break;default:break}for await(let Z of Q.childs)await this.createType({node:Z})}createBlockFromTemplate({node:Q}){let Z=this.getBlockTemplate({node:Q});Q.context.render=Z.render(Q),this.createStepFile({node:Q})}getBlockTemplate({node:Q}){let Z=this.#K[Q.type];if(Z)return Z;let X=this.#Q.templateDir;return Z=M8.compile(T.readFileSync(k.resolve(X,`src/default/blocks/${Q.type}.js.njk`),"utf8"),this.#J),this.#K[Q.type]=Z,Z}createStepFile({node:Q}){let Z=this.#Q.projectDir,X=`${Q.codeKey}.js`,q=k.resolve(Z,`src/default/blocks/${X}`);T.writeFileSync(q,Q.context.render,"utf8"),Q.context.fileName=X,Q.context.filePath=q}async transformExpression(Q){try{let Z=await this.transformValue(Q);return Z=JSON.stringify(Z),Z=this.replaceSpecialPattern(Z),Z}catch(Z){throw console.error("❌ transformExpression error:",Z.message),console.error(" Input value:",Q),console.error(" Stack:",Z.stack),Z}}async transformValue(Q){if(Array.isArray(Q))for(let Z=0;Z<Q.length;Z++)Q[Z]=await this.transformValue(Q[Z]);else if(Q2(Q)){let Z=Object.keys(Q);for(let X=0;X<Z.length;X++){let q=Z[X],Y=l6({expression:q});if(Y)if(Y.processor==="e"){let J=typeof Q[q]==="string"?Q[q]:Q[q];Q[Y.statement]=`$::${J}::`,delete Q[q]}else Q[q]=await this.transformValue(Q[q]);else Q[q]=await this.transformValue(Q[q])}}else if(typeof Q==="string"){let Z=l6({expression:Q,transform:{v:"v.{stmt}",for:"c.for.{stmt}",m:"c.module?.{stmt}||flow.module?.{stmt}",f:"c.form.{stmt}"}});if(Z){let{processor:X,transformed:q}=Z;switch(X){case"v":case"for":case"m":case"f":case"e":Q=`$::${q||Z.statement}::`;break}}}return Q}replaceSpecialPattern(Q){if(typeof Q!=="string")return console.error("❌ replaceSpecialPattern received non-string:",typeof Q,Q),Q;let Z=/"\$::(.*?)::"/g;return Q.replace(Z,"$1")}replaceExpressionLegacy(Q){let Z=/(?<outer>"\${(?<inner>[^{]*)}")/g;return Q.replaceAll(Z,"$2")}async createProjectYaml(){await this.setProgress({message:"Creating fnet.yaml"});let{content:X,...q}=this.#X.doc,Y=this.#Q.projectDir,J=k.resolve(Y,"fnet.yaml");T.writeFileSync(J,eQ.stringify(q),"utf8")}async createProjectMainYaml(){await this.setProgress({message:"Creating flow.main.yaml"});let X={content:eQ.stringify(this.#q)},q=this.#Q.templateDir,J=M8.compile(T.readFileSync(k.resolve(q,"flow.main.yaml.njk"),"utf8"),this.#J).render(X),H=this.#Q.projectDir,W=k.resolve(H,"flow.main.yaml");T.writeFileSync(W,J,"utf8")}async runPrettifier(){let Q=this.#Q.projectDir;if(M0("bun")){let Z=await QZ("prettier --write .",{cwd:k.resolve(Q,"src")});if(Z.code!==0)throw Error(Z.stderr)}else{let Z=await QZ("prettier --write .",{cwd:k.resolve(Q,"src")});if(Z.code!==0)throw Error(Z.stderr)}}async deploy(){if(await this.setProgress({message:"Deploying."}),this.#Q.project?.devops){let Q=[this.#Q.project?.devops];for(let Z=0;Z<Q.length;Z++){let X=Q[Z];if(await this.deployProject({deploymentProject:X}),X.isDirty===!0)await X.save()}}else if(this.#X.id){let Q=await R0.list({type:"workflow.deploy",parent_id:this.#X.id});for(let Z=0;Z<Q.length;Z++){let X=Q[Z];if(await this.deployProject({deploymentProject:X}),X.isDirty===!0)X=await R0.update(X,{id:X.id})}}}async deployProject(Q){let{deploymentProject:Z}=Q,{yamlDocument:X}=Z;if(Z.doc.targets&&Array.isArray(Z.doc.targets))throw Error("Deployment project targets are deprecated. Please update targets in the yaml file.");let q=Object.keys(Z.doc||{}),Y=X||{};for(let J=0;J<q.length;J++){let H=Z.doc[q[J]];H.name=q[J];let W=Y.get(q[J]);await B9({...this.#H,deploymentProject:Z,deploymentProjectTarget:H,yamlTarget:W})}}async registerToPackageManager(Q){let{target:Z,packageJSON:X}=Q;if(!this.#Q.id)return;let q=await R0.first({name:Z.params.name,parent_id:this.#M.env.ATOM_PACKAGES_ID});if(!q)q=await R0.create({parent_id:this.#M.env.ATOM_PACKAGES_ID,doc:{name:Z.params.name,type:"pm",versions:[{v:X.version}]}});else q.doc.versions.splice(0,0,{v:X.version}),await R0.update(q,{id:q.id})}async setProgress(Q){let Z=typeof Q==="string"?Q:Q?.message;console.log(J2.blue(Z)),await this._cache_set(this.#Y,{status:"IN_PROGRESS",message:Z})}async build(){if(this.#F&&!this.#A)return await this.createNetwork();try{let Q=this.#F?await j8({root:this.#V}):void 0;if(this.#A){let Z=this.#H.context.project;if(await this.initWorkflowDir(),await this.initNunjucks(),this.#F){let X=this.#Q.project?.projectDir||this.#Q.projectDir;if(X=k.resolve(X,"fnet"),T.existsSync(X)){if(T.existsSync(k.resolve(X,"flow.bpmn")))T.unlinkSync(k.resolve(X,"flow.bpmn"));if(T.writeFileSync(k.resolve(X,"flows.bpmn"),Q.diagramXML,"utf8"),((this.#X.doc.features||{}).bpmn||{}).per_flow===!0){let H=k.resolve(X,"bpmn");if(!T.existsSync(H))T.mkdirSync(H,{recursive:!0});let W=await L9({root:this.#V});for(let V of W){let K=`${V.flowName}.bpmn`,z=k.resolve(H,K);T.writeFileSync(z,V.diagramXML,"utf8")}}}}if(await this.createAtomLibFiles({root:this.#V}),await this.createEngine({root:this.#V}),await this.createNodeTree({root:this.#V}),await this.createProjectYaml(),await v6(this.#H),await D6(this.#H),await k6(this.#H),await b6(this.#H),await L6(this.#H),await I6(this.#H),Z.runtime.type==="bun")await S6(this.#H);else await T6(this.#H);if(await C6(this.#H),await y6(this.#H),await E6(this.#H),this.#j){if(await x6(this.#H),await u6(this.#H),this.#R)await this.deploy()}}await this._cache_set(this.#Y,{status:"COMPLETED",data:{network:Q}})}catch(Q){throw await this._cache_set(this.#Y,{status:"FAILED",message:Q.message||Q}),Q}}async createNetwork(){try{let Q=await j8({root:this.#V});await this._cache_set(this.#Y,{status:"COMPLETED",data:{...Q}})}catch(Q){throw await this._cache_set(this.#Y,{status:"FAILED",message:Q.message||Q}),Q}}}var k0=qZ;var H2={command:"build",describe:"Build flownet project",builder:(Q)=>{return Q.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("mode",{type:"string",default:"build",choices:["all","file","build","deploy","bpmn"],describe:"Build mode"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).option("dev",{type:"boolean",default:!1,describe:"Development mode"}).option("flows",{type:"string",alias:"flow",describe:"Path to flows file"})},handler:async(Q)=>{try{let Z=await D(Q),X=new k0(Z);await X.init(),await X.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Z){console.error("Building workflow failed!",Z.message),process.exit(1)}}},YZ=H2;var V2={command:"build:dev",describe:"Build flownet project",builder:(Q)=>{return Q.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("mode",{type:"string",default:"build",choices:["all","file","build","deploy","bpmn"],describe:"Build mode"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).option("dev",{type:"boolean",default:!1,describe:"Development mode"}).option("flows",{type:"string",describe:"Path to flows file"})},handler:async(Q)=>{try{Q.dev=!0;let Z=await D(Q),X=new k0(Z);await X.init(),await X.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Z){console.error("Building workflow failed!",Z.message),process.exit(1)}}},JZ=V2;var K2={command:"deploy",describe:"Build and deploy flownet project",builder:(Q)=>{return Q.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).option("flows",{type:"string",describe:"Path to flows file"})},handler:async(Q)=>{try{let Z=await D({...Q,mode:"all"}),X=new k0(Z);await X.init(),await X.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Z){console.error("Building workflow failed!",Z.message),process.exit(1)}}},WZ=K2;var _2={command:"file",describe:"Just create files",builder:(Q)=>{return Q.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).option("flows",{type:"string",describe:"Path to flows file"})},handler:async(Q)=>{try{let Z=await D({...Q,mode:"file"}),X=new k0(Z);await X.init(),await X.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Z){console.error("Building workflow failed!",Z.message),process.exit(1)}}},HZ=_2;import VZ from"node:path";import d8 from"node:fs";import z2 from"@fnet/prompt";var G2={command:"input [name]",describe:"Create or modify an input config file",builder:(Q)=>{return Q.positional("name",{type:"string",demandOption:!1,describe:"Input name"})},handler:async(Q)=>{try{let Z=await D(Q),{project:X}=Z,{projectDir:q,projectFileParsed:Y}=X,J=Y.input;if(!J)throw Error("Config schema not found in project file.");if(!Reflect.has(Q,"name")){let{inputName:G}=await z2({type:"input",name:"inputName",message:"Input name:",initial:"dev"});Q.name=G}let H=VZ.resolve(q,".fnet");if(!d8.existsSync(H))d8.mkdirSync(H);let W=VZ.resolve(H,`${Q.name}.fnet`),V=d8.existsSync(W),K=(await import("@fnet/object-from-schema")).default,z=await K({schema:J,format:"yaml",ref:V?W:void 0});d8.writeFileSync(W,z)}catch(Z){console.error(Z.message),process.exit(1)}}},KZ=G2;import P from"node:path";import N from"node:fs";import p8 from"node:os";import{spawn as a8}from"node:child_process";import L from"chalk";import F0 from"@fnet/prompt";import i8 from"chalk";import _Z from"@fnet/prompt";async function U2(Q){let{items:Z,message:X,nameField:q="name",valueField:Y="name",initialValue:J=null,allowAbort:H=!0}=Q;if(!Z||Z.length===0)return console.log(i8.yellow("No items available for selection.")),null;if(Z.length===1&&!H){let G=Z[0],_=typeof G==="string"?G:G[Y];return console.log(i8.blue(`Only one option available: ${typeof G==="string"?G:G[q]}`)),_}let W=Z.map((G)=>{if(typeof G==="string")return{name:G,value:G,message:G};else return{name:G[Y],value:G[Y],message:G[q]||G[Y]}});if(H)W.push({name:"cancel",value:null,message:i8.yellow("Cancel")});let V=null;if(J){let G=W.findIndex((_)=>_.name===J);if(G!==-1)V=G}let K="selectedItem",{[K]:z}=await _Z({type:"select",name:K,message:X,choices:W,initial:V});if(z==="cancel")return null;return z}async function $2(Q){let{items:Z,message:X,nameField:q="name",valueField:Y="name",initialValues:J=[],allowAbort:H=!0}=Q;if(!Z||Z.length===0)return console.log(i8.yellow("No items available for selection.")),null;let W=Z.map((G)=>{if(typeof G==="string")return{name:G,value:G,message:G};else return{name:G[Y],value:G[Y],message:G[q]||G[Y]}}),V=[];if(J&&J.length>0)V=W.map((G,_)=>J.includes(G.name)?_:-1).filter((G)=>G!==-1);let K="selectedItems",z=await _Z({type:"multiselect",name:K,message:X,choices:W,initial:V,hint:"(Use space to select, enter to confirm)",validate:(G)=>{if(G.length===0&&!H)return"Please select at least one item";return!0}});if(H&&z[K].length===0)return null;return z[K]}var P7={promptForSelection:U2,promptForMultipleSelection:$2};var c=P.join(p8.homedir(),".fnet","express");async function GZ(Q){Q.command(["$0 [project-name]","create [project-name]"],"Create a new express project",(Z)=>{return Z.positional("project-name",{describe:"Name of the project",type:"string"}).option("yes",{alias:"y",describe:"Skip all prompts and use defaults",type:"boolean",default:!1}).option("runtime",{describe:"Runtime to use (node)",type:"string",choices:["node"],default:"node"})},async(Z)=>{await M2(Z)}).command("list","List express projects",(Z)=>{return Z.option("today",{describe:"Show only projects created today",type:"boolean",default:!1}).option("type",{describe:"Filter by project type (fnode or fnet)",type:"string",choices:["fnode","fnet"]}).option("all",{describe:"Show all projects regardless of type",type:"boolean",default:!1,alias:"a"}).option("name",{describe:"Filter by project name",type:"string"})},async(Z)=>{await O2(Z)}).command("open [project-name]","Open an express project",(Z)=>{return Z.positional("project-name",{describe:"Name of the project to open",type:"string"}).option("latest",{describe:"Open the most recent project",type:"boolean",default:!1})},async(Z)=>{await A2(Z)}).command("move [project-name] [destination]","Move an express project to a real project location",(Z)=>{return Z.positional("project-name",{describe:"Name of the project to move",type:"string"}).positional("destination",{describe:"Destination directory",type:"string"}).option("latest",{describe:"Move the most recent project",type:"boolean",default:!1})},async(Z)=>{await B2(Z)}).command("remove [project-name]","Remove an express project",(Z)=>{return Z.positional("project-name",{describe:"Name of the project to remove",type:"string"}).option("latest",{describe:"Remove the most recent project",type:"boolean",default:!1}).option("yes",{alias:"y",describe:"Skip confirmation prompt",type:"boolean",default:!1})},async(Z)=>{await I2(Z)}).command("enter [project-name]","Enter the directory of an express project in the active terminal",(Z)=>{return Z.positional("project-name",{describe:"Name of the project to enter",type:"string"}).option("latest",{describe:"Enter the most recent project directory",type:"boolean",default:!1})},async(Z)=>{await C2(Z)}).demandCommand(1,"You need to specify a command").help()}async function M2(Q){try{if(!N.existsSync(c))N.mkdirSync(c,{recursive:!0});let Z=new Date().toISOString().slice(0,10).replace(/-/g,""),X=P.join(c,Z);if(!N.existsSync(X))N.mkdirSync(X,{recursive:!0});let q=Q.projectName,Y,J=Q.runtime;if(!Q.yes){if(!q){let _=N.readdirSync(X).filter((U)=>U.startsWith("fnet-")).map((U)=>parseInt(U.replace("fnet-",""),10)).filter((U)=>!isNaN(U)),$=`fnet-${_.length>0?Math.max(..._)+1:1}`;q=(await F0([{type:"input",name:"projectName",message:"Enter project name:",default:$}])).projectName}J=(await F0({type:"select",name:"runtime",message:"Select runtime:",choices:["node"],initial:J||"node"})).runtime}else{if(!q){let z=N.readdirSync(X).filter((_)=>_.startsWith("fnet-")).map((_)=>parseInt(_.replace("fnet-",""),10)).filter((_)=>!isNaN(_));q=`fnet-${z.length>0?Math.max(...z)+1:1}`}if(!J)J="node"}if(Y=P.join(X,q),N.existsSync(Y)){let z=1;while(N.existsSync(P.join(X,`${q}-${z}`)))z++;q=`${q}-${z}`,Y=P.join(X,q)}if(!Q.yes){if(!(await F0([{type:"confirm",name:"proceed",message:`Create express project "${q}" in ${Y}?`,default:!0}])).proceed){console.log(L.yellow("Project creation cancelled."));return}}console.log(L.blue(`Creating express project "${q}" in ${Y}...`));let H=P.dirname(Y),V=["create","--name",P.basename(Y)];if(V.push("--runtime",J),Q.yes)V.push("--yes");if(!N.existsSync(H))N.mkdirSync(H,{recursive:!0});let K=a8("fnet",V,{stdio:"inherit",shell:!0,cwd:H});return new Promise((z,G)=>{K.on("close",(_)=>{if(_===0)if(console.log(L.green(`
|
|
8
|
+
`+V+" | "+"".padEnd(Y.column-1," ")+"".padEnd(_,"^")}else Z+=`
|
|
9
|
+
at `+H}return Z}static buildMessage(Q,Z){function X(_){return _.codePointAt(0).toString(16).toUpperCase()}let q=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function Y(_){if(q)return _.replace(q,(z)=>"\\u{"+X(z)+"}");return _}function J(_){return Y(_.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(z)=>"\\x0"+X(z)).replace(/[\x10-\x1F\x7F-\x9F]/g,(z)=>"\\x"+X(z)))}function H(_){return Y(_.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(z)=>"\\x0"+X(z)).replace(/[\x10-\x1F\x7F-\x9F]/g,(z)=>"\\x"+X(z)))}let W={literal(_){return'"'+J(_.text)+'"'},class(_){let z=_.parts.map((O)=>Array.isArray(O)?H(O[0])+"-"+H(O[1]):H(O));return"["+(_.inverted?"^":"")+z.join("")+"]"+(_.unicode?"u":"")},any(){return"any character"},end(){return"end of input"},other(_){return _.description}};function V(_){return W[_.type](_)}function K(_){let z=_.map(V);if(z.sort(),z.length>0){let O=1;for(let $=1;$<z.length;$++)if(z[$-1]!==z[$])z[O]=z[$],O++;z.length=O}switch(z.length){case 1:return z[0];case 2:return z[0]+" or "+z[1];default:return z.slice(0,-1).join(", ")+", or "+z[z.length-1]}}function G(_){return _?'"'+J(_)+'"':"end of input"}return"Expected "+K(Q)+" but "+G(Z)+" found."}}function C9(Q,Z){Z=Z!==void 0?Z:{};let X={},q=Z.grammarSource,Y={Start:v7},J=v7,H="::",W=/^[a-z]/,V=/^[a-z0-9_\-]/,K=/^[^s]/,G=/^[sS]/,_=AZ("::",!1),z=O8([["a","z"]],!1,!1,!1),O=O8([["a","z"],["0","9"],"_","-"],!1,!1,!1),$=O8(["s"],!0,!1,!1),A=O8(["s","S"],!1,!1,!1);function U(I){return TZ(I)}function B(I,C){let S=I+"::"+C,l=jZ(I,C,S);try{let u=parse(C);if(u)l.next=u}catch(u){}return l}let M=Z.peg$currPos|0,R=M,F=[{line:1,column:1}],w=M,y=Z.peg$maxFailExpected||[],v=Z.peg$silentFails|0,Y0;if(Z.startRule){if(!(Z.startRule in Y))throw Error(`Can't start parsing from rule "`+Z.startRule+'".');J=Y[Z.startRule]}function J0(){return Q.substring(R,M)}function b7(){return R}function N2(){return{source:q,start:R,end:M}}function P2(){return p0(R,M)}function b2(I,C){throw C=C!==void 0?C:p0(R,M),D7([RZ(I)],Q.substring(R,M),C)}function k2(I,C){throw C=C!==void 0?C:p0(R,M),IZ(I,C)}function OZ(I=M){let C=Q.codePointAt(I);if(C===void 0)return"";return String.fromCodePoint(C)}function AZ(I,C){return{type:"literal",text:I,ignoreCase:C}}function O8(I,C,S,l){return{type:"class",parts:I,inverted:C,ignoreCase:S,unicode:l}}function D2(){return{type:"any"}}function BZ(){return{type:"end"}}function RZ(I){return{type:"other",description:I}}function k7(I){let C=F[I],S;if(C)return C;else{if(I>=F.length)S=F.length-1;else{S=I;while(!F[--S]);}C=F[S],C={line:C.line,column:C.column};while(S<I){if(Q.charCodeAt(S)===10)C.line++,C.column=1;else C.column++;S++}return F[I]=C,C}}function p0(I,C,S){let l=k7(I),u=k7(C),a0={source:q,start:{offset:I,line:l.line,column:l.column},end:{offset:C,line:u.line,column:u.column}};if(S&&q&&typeof q.offset==="function")a0.start=q.offset(a0.start),a0.end=q.offset(a0.end);return a0}function F0(I){if(M<w)return;if(M>w)w=M,y=[];y.push(I)}function IZ(I,C){return new j8(I,null,null,C)}function D7(I,C,S){return new j8(j8.buildMessage(I,C),I,C,S)}function v7(){let I,C;if(I=M,C=CZ(),C!==X)R=I,C=U(C);return I=C,I}function CZ(){let I,C,S,l;if(I=M,C=LZ(),C!==X){if(Q.substr(M,2)===H)S=H,M+=2;else if(S=X,v===0)F0(_);if(S!==X)if(l=FZ(),l!==X)R=I,I=B(C,l);else M=I,I=X;else M=I,I=X}else M=I,I=X;return I}function LZ(){let I,C,S,l,u;if(I=M,C=M,S=Q.charAt(M),W.test(S))M++;else if(S=X,v===0)F0(z);if(S!==X){if(l=[],u=Q.charAt(M),V.test(u))M++;else if(u=X,v===0)F0(O);while(u!==X)if(l.push(u),u=Q.charAt(M),V.test(u))M++;else if(u=X,v===0)F0(O);S=[S,l],C=S}else M=C,C=X;if(C!==X)I=Q.substring(I,M);else I=C;return I}function FZ(){let I,C,S,l,u;if(I=M,C=M,S=Q.charAt(M),K.test(S))M++;else if(S=X,v===0)F0($);if(S!==X){if(l=[],u=Q.charAt(M),G.test(u))M++;else if(u=X,v===0)F0(A);while(u!==X)if(l.push(u),u=Q.charAt(M),G.test(u))M++;else if(u=X,v===0)F0(A);S=[S,l],C=S}else M=C,C=X;if(C!==X)I=Q.substring(I,M);else I=C;return I}function jZ(I,C,S){return{processor:I,statement:C,expression:S}}function y7(I){if(!I)return[];let C=I.next?y7(I.next):[];return C.push(I.processor),C}function TZ(I){if(!I)return null;let C=I;while(C&&C.next)C=C.next;let S={processor:I.processor,statement:I.statement,expression:I.expression,process:{statement:C.statement,order:y7(I)}};if(I.next)S.next=I.next;return S}Y0=J();let o8=Y0!==X&&M===Q.length;function E7(){if(Y0!==X&&M<Q.length)F0(BZ());throw D7(y,w<Q.length?OZ(w):null,w<Q.length?p0(w,w+1):p0(w,w))}if(Z.peg$library)return{peg$result:Y0,peg$currPos:M,peg$FAILED:X,peg$maxFailExpected:y,peg$maxFailPos:w,peg$success:o8,peg$throw:o8?void 0:E7};if(o8)return Y0;else E7()}function w0(Q,Z=!1){if(typeof Q!=="string")return null;let X=Q.match(/^([a-z][a-z0-9_-]*)::/);if(!X)return null;let q=X[1];if(!Z)return q;let Y=Q.slice(Q.indexOf("::")+2);return{processor:q,statement:Y}}function F9({expression:Q,depth:Z=5}){if(Z<=0)return null;let X=/^([a-z][a-z0-9_-]*)::([^\s][\s\S]*)$/,q;if(X.test(Q))q=Q.match(X);else return null;let Y=q[1],J=q[2],H=F9({expression:J,depth:Z-1}),W={processor:Y,statement:J,expression:Q};if(H)W.next=H;return W}function j9(Q){if(!Q)return[];let Z=j9(Q.next);return Z.push(Q.processor),Z}function L9({expression:Q}){let Z=F9({expression:Q});if(!Z)return null;let X=Z;while(X&&X.next)X=X.next;let q={processor:Z.processor,statement:Z.statement,expression:Z.expression,process:{statement:X.statement,order:j9(Z)}};if(Z.next)q.next=Z.next;return q}function $5(Q,Z){let X=Q.statement,q=/([a-z][a-z0-9_-]*)::([a-zA-Z_$][a-zA-Z0-9_$]*)/g;return X=X.replace(q,(Y,J,H)=>{if(Z[J]){let W=Z[J];if(typeof W==="function")return W(H);if(typeof W==="string")return W.replace(/\{stmt\}/g,H)}return Y}),X}function c6({expression:Q,useGrammar:Z=!0,multiline:X=!0,transform:q}){if(typeof Q!=="string")Q=String(Q);if(X)Q=Q.replace(/\n+$/,"");let Y;if(Z)try{Y=C9(Q)}catch(J){Y=L9({expression:Q})}else Y=L9({expression:Q});if(!Y)return null;if(q){if(q[Y.processor]&&!Y.next){let J=q[Y.processor];if(typeof J==="function")Y.transformed=J(Y.statement);else if(typeof J==="string")Y.transformed=J.replace(/\{stmt\}/g,Y.statement)}else if(Y.statement)Y.transformed=$5(Y,q)}return Y}import X2 from"@fnet/yaml";import q2 from"chalk";var p9=b5(f9(),1);var o0=(Q)=>{if(typeof Q!=="string")throw TypeError("invalid pattern");if(Q.length>65536)throw TypeError("pattern is too long")};var L5={"[: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]},t0=(Q)=>Q.replace(/[[\]\\-]/g,"\\$&"),F5=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),h9=(Q)=>Q.join(""),g9=(Q,Z)=>{let X=Z;if(Q.charAt(X)!=="[")throw Error("not in a brace expression");let q=[],Y=[],J=X+1,H=!1,W=!1,V=!1,K=!1,G=X,_="";Q:while(J<Q.length){let A=Q.charAt(J);if((A==="!"||A==="^")&&J===X+1){K=!0,J++;continue}if(A==="]"&&H&&!V){G=J+1;break}if(H=!0,A==="\\"){if(!V){V=!0,J++;continue}}if(A==="["&&!V){for(let[U,[B,M,R]]of Object.entries(L5))if(Q.startsWith(U,J)){if(_)return["$.",!1,Q.length-X,!0];if(J+=U.length,R)Y.push(B);else q.push(B);W=W||M;continue Q}}if(V=!1,_){if(A>_)q.push(t0(_)+"-"+t0(A));else if(A===_)q.push(t0(A));_="",J++;continue}if(Q.startsWith("-]",J+1)){q.push(t0(A+"-")),J+=2;continue}if(Q.startsWith("-",J+1)){_=A,J+=2;continue}q.push(t0(A)),J++}if(G<J)return["",!1,0,!1];if(!q.length&&!Y.length)return["$.",!1,Q.length-X,!0];if(Y.length===0&&q.length===1&&/^\\?.$/.test(q[0])&&!K){let A=q[0].length===2?q[0].slice(-1):q[0];return[F5(A),!1,G-X,!1]}let z="["+(K?"^":"")+h9(q)+"]",O="["+(K?"":"^")+h9(Y)+"]";return[q.length&&Y.length?"("+z+"|"+O+")":q.length?z:O,W,G-X,!0]};var G0=(Q,{windowsPathsNoEscape:Z=!1}={})=>{return Z?Q.replace(/\[([^\/\\])\]/g,"$1"):Q.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var j5=new Set(["!","?","+","*","@"]),m9=(Q)=>j5.has(Q),T5="(?!(?:^|/)\\.\\.?(?:$|/))",T8="(?!\\.)",S5=new Set(["[","."]),w5=new Set(["..","."]),N5=new Set("().*{}+?[]^$\\!"),P5=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),i6="[^/]",c9=i6+"*?",l9=i6+"+?";class a{type;#Q;#Z;#q=!1;#X=[];#J;#C;#M;#V=!1;#_;#K;#G=!1;constructor(Q,Z,X={}){if(this.type=Q,Q)this.#Z=!0;if(this.#J=Z,this.#Q=this.#J?this.#J.#Q:this,this.#_=this.#Q===this?X:this.#Q.#_,this.#M=this.#Q===this?[]:this.#Q.#M,Q==="!"&&!this.#Q.#V)this.#M.push(this);this.#C=this.#J?this.#J.#X.length:0}get hasMagic(){if(this.#Z!==void 0)return this.#Z;for(let Q of this.#X){if(typeof Q==="string")continue;if(Q.type||Q.hasMagic)return this.#Z=!0}return this.#Z}toString(){if(this.#K!==void 0)return this.#K;if(!this.type)return this.#K=this.#X.map((Q)=>String(Q)).join("");else return this.#K=this.type+"("+this.#X.map((Q)=>String(Q)).join("|")+")"}#Y(){if(this!==this.#Q)throw Error("should only call on root");if(this.#V)return this;this.toString(),this.#V=!0;let Q;while(Q=this.#M.pop()){if(Q.type!=="!")continue;let Z=Q,X=Z.#J;while(X){for(let q=Z.#C+1;!X.type&&q<X.#X.length;q++)for(let Y of Q.#X){if(typeof Y==="string")throw Error("string part in extglob AST??");Y.copyIn(X.#X[q])}Z=X,X=Z.#J}}return this}push(...Q){for(let Z of Q){if(Z==="")continue;if(typeof Z!=="string"&&!(Z instanceof a&&Z.#J===this))throw Error("invalid part: "+Z);this.#X.push(Z)}}toJSON(){let Q=this.type===null?this.#X.slice().map((Z)=>typeof Z==="string"?Z:Z.toJSON()):[this.type,...this.#X.map((Z)=>Z.toJSON())];if(this.isStart()&&!this.type)Q.unshift([]);if(this.isEnd()&&(this===this.#Q||this.#Q.#V&&this.#J?.type==="!"))Q.push({});return Q}isStart(){if(this.#Q===this)return!0;if(!this.#J?.isStart())return!1;if(this.#C===0)return!0;let Q=this.#J;for(let Z=0;Z<this.#C;Z++){let X=Q.#X[Z];if(!(X instanceof a&&X.type==="!"))return!1}return!0}isEnd(){if(this.#Q===this)return!0;if(this.#J?.type==="!")return!0;if(!this.#J?.isEnd())return!1;if(!this.type)return this.#J?.isEnd();let Q=this.#J?this.#J.#X.length:0;return this.#C===Q-1}copyIn(Q){if(typeof Q==="string")this.push(Q);else this.push(Q.clone(this))}clone(Q){let Z=new a(this.type,Q);for(let X of this.#X)Z.copyIn(X);return Z}static#$(Q,Z,X,q){let Y=!1,J=!1,H=-1,W=!1;if(Z.type===null){let z=X,O="";while(z<Q.length){let $=Q.charAt(z++);if(Y||$==="\\"){Y=!Y,O+=$;continue}if(J){if(z===H+1){if($==="^"||$==="!")W=!0}else if($==="]"&&!(z===H+2&&W))J=!1;O+=$;continue}else if($==="["){J=!0,H=z,W=!1,O+=$;continue}if(!q.noext&&m9($)&&Q.charAt(z)==="("){Z.push(O),O="";let A=new a($,Z);z=a.#$(Q,A,z,q),Z.push(A);continue}O+=$}return Z.push(O),z}let V=X+1,K=new a(null,Z),G=[],_="";while(V<Q.length){let z=Q.charAt(V++);if(Y||z==="\\"){Y=!Y,_+=z;continue}if(J){if(V===H+1){if(z==="^"||z==="!")W=!0}else if(z==="]"&&!(V===H+2&&W))J=!1;_+=z;continue}else if(z==="["){J=!0,H=V,W=!1,_+=z;continue}if(m9(z)&&Q.charAt(V)==="("){K.push(_),_="";let O=new a(z,K);K.push(O),V=a.#$(Q,O,V,q);continue}if(z==="|"){K.push(_),_="",G.push(K),K=new a(null,Z);continue}if(z===")"){if(_===""&&Z.#X.length===0)Z.#G=!0;return K.push(_),_="",Z.push(...G,K),V}_+=z}return Z.type=null,Z.#Z=void 0,Z.#X=[Q.substring(X-1)],V}static fromGlob(Q,Z={}){let X=new a(null,void 0,Z);return a.#$(Q,X,0,Z),X}toMMPattern(){if(this!==this.#Q)return this.#Q.toMMPattern();let Q=this.toString(),[Z,X,q,Y]=this.toRegExpSource();if(!(q||this.#Z||this.#_.nocase&&!this.#_.nocaseMagicOnly&&Q.toUpperCase()!==Q.toLowerCase()))return X;let H=(this.#_.nocase?"i":"")+(Y?"u":"");return Object.assign(new RegExp(`^${Z}$`,H),{_src:Z,_glob:Q})}get options(){return this.#_}toRegExpSource(Q){let Z=Q??!!this.#_.dot;if(this.#Q===this)this.#Y();if(!this.type){let W=this.isStart()&&this.isEnd(),V=this.#X.map((z)=>{let[O,$,A,U]=typeof z==="string"?a.#O(z,this.#Z,W):z.toRegExpSource(Q);return this.#Z=this.#Z||A,this.#q=this.#q||U,O}).join(""),K="";if(this.isStart()){if(typeof this.#X[0]==="string"){if(!(this.#X.length===1&&w5.has(this.#X[0]))){let O=S5,$=Z&&O.has(V.charAt(0))||V.startsWith("\\.")&&O.has(V.charAt(2))||V.startsWith("\\.\\.")&&O.has(V.charAt(4)),A=!Z&&!Q&&O.has(V.charAt(0));K=$?T5:A?T8:""}}}let G="";if(this.isEnd()&&this.#Q.#V&&this.#J?.type==="!")G="(?:$|\\/)";return[K+V+G,G0(V),this.#Z=!!this.#Z,this.#q]}let X=this.type==="*"||this.type==="+",q=this.type==="!"?"(?:(?!(?:":"(?:",Y=this.#B(Z);if(this.isStart()&&this.isEnd()&&!Y&&this.type!=="!"){let W=this.toString();return this.#X=[W],this.type=null,this.#Z=void 0,[W,G0(this.toString()),!1,!1]}let J=!X||Q||Z||!T8?"":this.#B(!0);if(J===Y)J="";if(J)Y=`(?:${Y})(?:${J})*?`;let H="";if(this.type==="!"&&this.#G)H=(this.isStart()&&!Z?T8:"")+l9;else{let W=this.type==="!"?"))"+(this.isStart()&&!Z&&!Q?T8:"")+c9+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&J?")":this.type==="*"&&J?")?":`)${this.type}`;H=q+Y+W}return[H,G0(Y),this.#Z=!!this.#Z,this.#q]}#B(Q){return this.#X.map((Z)=>{if(typeof Z==="string")throw Error("string type in extglob ast??");let[X,q,Y,J]=Z.toRegExpSource(Q);return this.#q=this.#q||J,X}).filter((Z)=>!(this.isStart()&&this.isEnd())||!!Z).join("|")}static#O(Q,Z,X=!1){let q=!1,Y="",J=!1;for(let H=0;H<Q.length;H++){let W=Q.charAt(H);if(q){q=!1,Y+=(N5.has(W)?"\\":"")+W;continue}if(W==="\\"){if(H===Q.length-1)Y+="\\\\";else q=!0;continue}if(W==="["){let[V,K,G,_]=g9(Q,H);if(G){Y+=V,J=J||K,H+=G-1,Z=Z||_;continue}}if(W==="*"){if(X&&Q==="*")Y+=l9;else Y+=c9;Z=!0;continue}if(W==="?"){Y+=i6,Z=!0;continue}Y+=P5(W)}return[Y,G0(Q),!!Z,J]}}var h0=(Q,{windowsPathsNoEscape:Z=!1}={})=>{return Z?Q.replace(/[?*()[\]]/g,"[$&]"):Q.replace(/[?*()[\]\\]/g,"\\$&")};var Q0=(Q,Z,X={})=>{if(o0(Z),!X.nocomment&&Z.charAt(0)==="#")return!1;return new H0(Z,X).match(Q)},k5=/^\*+([^+@!?\*\[\(]*)$/,D5=(Q)=>(Z)=>!Z.startsWith(".")&&Z.endsWith(Q),v5=(Q)=>(Z)=>Z.endsWith(Q),y5=(Q)=>{return Q=Q.toLowerCase(),(Z)=>!Z.startsWith(".")&&Z.toLowerCase().endsWith(Q)},E5=(Q)=>{return Q=Q.toLowerCase(),(Z)=>Z.toLowerCase().endsWith(Q)},x5=/^\*+\.\*+$/,u5=(Q)=>!Q.startsWith(".")&&Q.includes("."),f5=(Q)=>Q!=="."&&Q!==".."&&Q.includes("."),h5=/^\.\*+$/,g5=(Q)=>Q!=="."&&Q!==".."&&Q.startsWith("."),m5=/^\*+$/,c5=(Q)=>Q.length!==0&&!Q.startsWith("."),l5=(Q)=>Q.length!==0&&Q!=="."&&Q!=="..",d5=/^\?+([^+@!?\*\[\(]*)?$/,i5=([Q,Z=""])=>{let X=a9([Q]);if(!Z)return X;return Z=Z.toLowerCase(),(q)=>X(q)&&q.toLowerCase().endsWith(Z)},p5=([Q,Z=""])=>{let X=n9([Q]);if(!Z)return X;return Z=Z.toLowerCase(),(q)=>X(q)&&q.toLowerCase().endsWith(Z)},a5=([Q,Z=""])=>{let X=n9([Q]);return!Z?X:(q)=>X(q)&&q.endsWith(Z)},n5=([Q,Z=""])=>{let X=a9([Q]);return!Z?X:(q)=>X(q)&&q.endsWith(Z)},a9=([Q])=>{let Z=Q.length;return(X)=>X.length===Z&&!X.startsWith(".")},n9=([Q])=>{let Z=Q.length;return(X)=>X.length===Z&&X!=="."&&X!==".."},r9=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",d9={win32:{sep:"\\"},posix:{sep:"/"}},r5=r9==="win32"?d9.win32.sep:d9.posix.sep;Q0.sep=r5;var n=Symbol("globstar **");Q0.GLOBSTAR=n;var s5="[^/]",o5=s5+"*?",t5="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",e5="(?:(?!(?:\\/|^)\\.).)*?",Q4=(Q,Z={})=>(X)=>Q0(X,Q,Z);Q0.filter=Q4;var W0=(Q,Z={})=>Object.assign({},Q,Z),Z4=(Q)=>{if(!Q||typeof Q!=="object"||!Object.keys(Q).length)return Q0;let Z=Q0;return Object.assign((q,Y,J={})=>Z(q,Y,W0(Q,J)),{Minimatch:class extends Z.Minimatch{constructor(Y,J={}){super(Y,W0(Q,J))}static defaults(Y){return Z.defaults(W0(Q,Y)).Minimatch}},AST:class extends Z.AST{constructor(Y,J,H={}){super(Y,J,W0(Q,H))}static fromGlob(Y,J={}){return Z.AST.fromGlob(Y,W0(Q,J))}},unescape:(q,Y={})=>Z.unescape(q,W0(Q,Y)),escape:(q,Y={})=>Z.escape(q,W0(Q,Y)),filter:(q,Y={})=>Z.filter(q,W0(Q,Y)),defaults:(q)=>Z.defaults(W0(Q,q)),makeRe:(q,Y={})=>Z.makeRe(q,W0(Q,Y)),braceExpand:(q,Y={})=>Z.braceExpand(q,W0(Q,Y)),match:(q,Y,J={})=>Z.match(q,Y,W0(Q,J)),sep:Z.sep,GLOBSTAR:n})};Q0.defaults=Z4;var s9=(Q,Z={})=>{if(o0(Q),Z.nobrace||!/\{(?:(?!\{).)*\}/.test(Q))return[Q];return p9.default(Q)};Q0.braceExpand=s9;var X4=(Q,Z={})=>new H0(Q,Z).makeRe();Q0.makeRe=X4;var q4=(Q,Z,X={})=>{let q=new H0(Z,X);if(Q=Q.filter((Y)=>q.match(Y)),q.options.nonull&&!Q.length)Q.push(Z);return Q};Q0.match=q4;var i9=/[?*]|[+@!]\(.*?\)|\[|\]/,Y4=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class H0{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(Q,Z={}){if(o0(Q),Z=Z||{},this.options=Z,this.pattern=Q,this.platform=Z.platform||r9,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z.allowWindowsEscape===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!Z.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!Z.nonegate,this.comment=!1,this.empty=!1,this.partial=!!Z.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=Z.windowsNoMagicRoot!==void 0?Z.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let Q of this.set)for(let Z of Q)if(typeof Z!=="string")return!0;return!1}debug(...Q){}make(){let Q=this.pattern,Z=this.options;if(!Z.nocomment&&Q.charAt(0)==="#"){this.comment=!0;return}if(!Q){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],Z.debug)this.debug=(...Y)=>console.error(...Y);this.debug(this.pattern,this.globSet);let X=this.globSet.map((Y)=>this.slashSplit(Y));this.globParts=this.preprocess(X),this.debug(this.pattern,this.globParts);let q=this.globParts.map((Y,J,H)=>{if(this.isWindows&&this.windowsNoMagicRoot){let W=Y[0]===""&&Y[1]===""&&(Y[2]==="?"||!i9.test(Y[2]))&&!i9.test(Y[3]),V=/^[a-z]:/i.test(Y[0]);if(W)return[...Y.slice(0,4),...Y.slice(4).map((K)=>this.parse(K))];else if(V)return[Y[0],...Y.slice(1).map((K)=>this.parse(K))]}return Y.map((W)=>this.parse(W))});if(this.debug(this.pattern,q),this.set=q.filter((Y)=>Y.indexOf(!1)===-1),this.isWindows)for(let Y=0;Y<this.set.length;Y++){let J=this.set[Y];if(J[0]===""&&J[1]===""&&this.globParts[Y][2]==="?"&&typeof J[3]==="string"&&/^[a-z]:$/i.test(J[3]))J[2]="?"}this.debug(this.pattern,this.set)}preprocess(Q){if(this.options.noglobstar){for(let X=0;X<Q.length;X++)for(let q=0;q<Q[X].length;q++)if(Q[X][q]==="**")Q[X][q]="*"}let{optimizationLevel:Z=1}=this.options;if(Z>=2)Q=this.firstPhasePreProcess(Q),Q=this.secondPhasePreProcess(Q);else if(Z>=1)Q=this.levelOneOptimize(Q);else Q=this.adjascentGlobstarOptimize(Q);return Q}adjascentGlobstarOptimize(Q){return Q.map((Z)=>{let X=-1;while((X=Z.indexOf("**",X+1))!==-1){let q=X;while(Z[q+1]==="**")q++;if(q!==X)Z.splice(X,q-X)}return Z})}levelOneOptimize(Q){return Q.map((Z)=>{return Z=Z.reduce((X,q)=>{let Y=X[X.length-1];if(q==="**"&&Y==="**")return X;if(q===".."){if(Y&&Y!==".."&&Y!=="."&&Y!=="**")return X.pop(),X}return X.push(q),X},[]),Z.length===0?[""]:Z})}levelTwoFileOptimize(Q){if(!Array.isArray(Q))Q=this.slashSplit(Q);let Z=!1;do{if(Z=!1,!this.preserveMultipleSlashes){for(let q=1;q<Q.length-1;q++){let Y=Q[q];if(q===1&&Y===""&&Q[0]==="")continue;if(Y==="."||Y==="")Z=!0,Q.splice(q,1),q--}if(Q[0]==="."&&Q.length===2&&(Q[1]==="."||Q[1]===""))Z=!0,Q.pop()}let X=0;while((X=Q.indexOf("..",X+1))!==-1){let q=Q[X-1];if(q&&q!=="."&&q!==".."&&q!=="**")Z=!0,Q.splice(X-1,2),X-=2}}while(Z);return Q.length===0?[""]:Q}firstPhasePreProcess(Q){let Z=!1;do{Z=!1;for(let X of Q){let q=-1;while((q=X.indexOf("**",q+1))!==-1){let J=q;while(X[J+1]==="**")J++;if(J>q)X.splice(q+1,J-q);let H=X[q+1],W=X[q+2],V=X[q+3];if(H!=="..")continue;if(!W||W==="."||W===".."||!V||V==="."||V==="..")continue;Z=!0,X.splice(q,1);let K=X.slice(0);K[q]="**",Q.push(K),q--}if(!this.preserveMultipleSlashes){for(let J=1;J<X.length-1;J++){let H=X[J];if(J===1&&H===""&&X[0]==="")continue;if(H==="."||H==="")Z=!0,X.splice(J,1),J--}if(X[0]==="."&&X.length===2&&(X[1]==="."||X[1]===""))Z=!0,X.pop()}let Y=0;while((Y=X.indexOf("..",Y+1))!==-1){let J=X[Y-1];if(J&&J!=="."&&J!==".."&&J!=="**"){Z=!0;let W=Y===1&&X[Y+1]==="**"?["."]:[];if(X.splice(Y-1,2,...W),X.length===0)X.push("");Y-=2}}}}while(Z);return Q}secondPhasePreProcess(Q){for(let Z=0;Z<Q.length-1;Z++)for(let X=Z+1;X<Q.length;X++){let q=this.partsMatch(Q[Z],Q[X],!this.preserveMultipleSlashes);if(q){Q[Z]=[],Q[X]=q;break}}return Q.filter((Z)=>Z.length)}partsMatch(Q,Z,X=!1){let q=0,Y=0,J=[],H="";while(q<Q.length&&Y<Z.length)if(Q[q]===Z[Y])J.push(H==="b"?Z[Y]:Q[q]),q++,Y++;else if(X&&Q[q]==="**"&&Z[Y]===Q[q+1])J.push(Q[q]),q++;else if(X&&Z[Y]==="**"&&Q[q]===Z[Y+1])J.push(Z[Y]),Y++;else if(Q[q]==="*"&&Z[Y]&&(this.options.dot||!Z[Y].startsWith("."))&&Z[Y]!=="**"){if(H==="b")return!1;H="a",J.push(Q[q]),q++,Y++}else if(Z[Y]==="*"&&Q[q]&&(this.options.dot||!Q[q].startsWith("."))&&Q[q]!=="**"){if(H==="a")return!1;H="b",J.push(Z[Y]),q++,Y++}else return!1;return Q.length===Z.length&&J}parseNegate(){if(this.nonegate)return;let Q=this.pattern,Z=!1,X=0;for(let q=0;q<Q.length&&Q.charAt(q)==="!";q++)Z=!Z,X++;if(X)this.pattern=Q.slice(X);this.negate=Z}matchOne(Q,Z,X=!1){let q=this.options;if(this.isWindows){let $=typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0]),A=!$&&Q[0]===""&&Q[1]===""&&Q[2]==="?"&&/^[a-z]:$/i.test(Q[3]),U=typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0]),B=!U&&Z[0]===""&&Z[1]===""&&Z[2]==="?"&&typeof Z[3]==="string"&&/^[a-z]:$/i.test(Z[3]),M=A?3:$?0:void 0,R=B?3:U?0:void 0;if(typeof M==="number"&&typeof R==="number"){let[F,w]=[Q[M],Z[R]];if(F.toLowerCase()===w.toLowerCase()){if(Z[R]=F,R>M)Z=Z.slice(R);else if(M>R)Q=Q.slice(M)}}}let{optimizationLevel:Y=1}=this.options;if(Y>=2)Q=this.levelTwoFileOptimize(Q);this.debug("matchOne",this,{file:Q,pattern:Z}),this.debug("matchOne",Q.length,Z.length);for(var J=0,H=0,W=Q.length,V=Z.length;J<W&&H<V;J++,H++){this.debug("matchOne loop");var K=Z[H],G=Q[J];if(this.debug(Z,K,G),K===!1)return!1;if(K===n){this.debug("GLOBSTAR",[Z,K,G]);var _=J,z=H+1;if(z===V){this.debug("** at the end");for(;J<W;J++)if(Q[J]==="."||Q[J]===".."||!q.dot&&Q[J].charAt(0)===".")return!1;return!0}while(_<W){var O=Q[_];if(this.debug(`
|
|
10
|
+
globstar while`,Q,_,Z,z,O),this.matchOne(Q.slice(_),Z.slice(z),X))return this.debug("globstar found match!",_,W,O),!0;else{if(O==="."||O===".."||!q.dot&&O.charAt(0)==="."){this.debug("dot detected!",Q,_,Z,z);break}this.debug("globstar swallow a segment, and continue"),_++}}if(X){if(this.debug(`
|
|
11
|
+
>>> no match, partial?`,Q,_,Z,z),_===W)return!0}return!1}let $;if(typeof K==="string")$=G===K,this.debug("string match",K,G,$);else $=K.test(G),this.debug("pattern match",K,G,$);if(!$)return!1}if(J===W&&H===V)return!0;else if(J===W)return X;else if(H===V)return J===W-1&&Q[J]==="";else throw Error("wtf?")}braceExpand(){return s9(this.pattern,this.options)}parse(Q){o0(Q);let Z=this.options;if(Q==="**")return n;if(Q==="")return"";let X,q=null;if(X=Q.match(m5))q=Z.dot?l5:c5;else if(X=Q.match(k5))q=(Z.nocase?Z.dot?E5:y5:Z.dot?v5:D5)(X[1]);else if(X=Q.match(d5))q=(Z.nocase?Z.dot?p5:i5:Z.dot?a5:n5)(X);else if(X=Q.match(x5))q=Z.dot?f5:u5;else if(X=Q.match(h5))q=g5;let Y=a.fromGlob(Q,this.options).toMMPattern();if(q&&typeof Y==="object")Reflect.defineProperty(Y,"test",{value:q});return Y}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let Q=this.set;if(!Q.length)return this.regexp=!1,this.regexp;let Z=this.options,X=Z.noglobstar?o5:Z.dot?t5:e5,q=new Set(Z.nocase?["i"]:[]),Y=Q.map((W)=>{let V=W.map((K)=>{if(K instanceof RegExp)for(let G of K.flags.split(""))q.add(G);return typeof K==="string"?Y4(K):K===n?n:K._src});return V.forEach((K,G)=>{let _=V[G+1],z=V[G-1];if(K!==n||z===n)return;if(z===void 0)if(_!==void 0&&_!==n)V[G+1]="(?:\\/|"+X+"\\/)?"+_;else V[G]=X;else if(_===void 0)V[G-1]=z+"(?:\\/|"+X+")?";else if(_!==n)V[G-1]=z+"(?:\\/|\\/"+X+"\\/)"+_,V[G+1]=n}),V.filter((K)=>K!==n).join("/")}).join("|"),[J,H]=Q.length>1?["(?:",")"]:["",""];if(Y="^"+J+Y+H+"$",this.negate)Y="^(?!"+Y+").+$";try{this.regexp=new RegExp(Y,[...q].join(""))}catch(W){this.regexp=!1}return this.regexp}slashSplit(Q){if(this.preserveMultipleSlashes)return Q.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(Q))return["",...Q.split(/\/+/)];else return Q.split(/\/+/)}match(Q,Z=this.partial){if(this.debug("match",Q,this.pattern),this.comment)return!1;if(this.empty)return Q==="";if(Q==="/"&&Z)return!0;let X=this.options;if(this.isWindows)Q=Q.split("\\").join("/");let q=this.slashSplit(Q);this.debug(this.pattern,"split",q);let Y=this.set;this.debug(this.pattern,"set",Y);let J=q[q.length-1];if(!J)for(let H=q.length-2;!J&&H>=0;H--)J=q[H];for(let H=0;H<Y.length;H++){let W=Y[H],V=q;if(X.matchBase&&W.length===1)V=[J];if(this.matchOne(V,W,Z)){if(X.flipNegate)return!0;return!this.negate}}if(X.flipNegate)return!1;return this.negate}static defaults(Q){return Q0.defaults(Q).Minimatch}}Q0.AST=a;Q0.Minimatch=H0;Q0.escape=h0;Q0.unescape=G0;import{fileURLToPath as x4}from"node:url";var g0=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,t9=new Set,p6=typeof process==="object"&&!!process?process:{},e9=(Q,Z,X,q)=>{typeof p6.emitWarning==="function"?p6.emitWarning(Q,Z,X,q):console.error(`[${X}] ${Z}: ${Q}`)},S8=globalThis.AbortController,o9=globalThis.AbortSignal;if(typeof S8>"u"){o9=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(q,Y){this._onabort.push(Y)}},S8=class{constructor(){Z()}signal=new o9;abort(q){if(this.signal.aborted)return;this.signal.reason=q,this.signal.aborted=!0;for(let Y of this.signal._onabort)Y(q);this.signal.onabort?.(q)}};let Q=p6.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",Z=()=>{if(!Q)return;Q=!1,e9("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",Z)}}var J4=(Q)=>!t9.has(Q),pq=Symbol("type"),N0=(Q)=>Q&&Q===Math.floor(Q)&&Q>0&&isFinite(Q),QQ=(Q)=>!N0(Q)?null:Q<=Math.pow(2,8)?Uint8Array:Q<=Math.pow(2,16)?Uint16Array:Q<=Math.pow(2,32)?Uint32Array:Q<=Number.MAX_SAFE_INTEGER?e0:null;class e0 extends Array{constructor(Q){super(Q);this.fill(0)}}class m0{heap;length;static#Q=!1;static create(Q){let Z=QQ(Q);if(!Z)return[];m0.#Q=!0;let X=new m0(Q,Z);return m0.#Q=!1,X}constructor(Q,Z){if(!m0.#Q)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new Z(Q),this.length=0}push(Q){this.heap[this.length++]=Q}pop(){return this.heap[--this.length]}}class Q8{#Q;#Z;#q;#X;#J;#C;#M;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#V;#_;#K;#G;#Y;#$;#B;#O;#A;#F;#H;#j;#z;#L;#R;#w;#I;#b;static unsafeExposeInternals(Q){return{starts:Q.#z,ttls:Q.#L,sizes:Q.#j,keyMap:Q.#K,keyList:Q.#G,valList:Q.#Y,next:Q.#$,prev:Q.#B,get head(){return Q.#O},get tail(){return Q.#A},free:Q.#F,isBackgroundFetch:(Z)=>Q.#U(Z),backgroundFetch:(Z,X,q,Y)=>Q.#E(Z,X,q,Y),moveToTail:(Z)=>Q.#f(Z),indexes:(Z)=>Q.#N(Z),rindexes:(Z)=>Q.#P(Z),isStale:(Z)=>Q.#S(Z)}}get max(){return this.#Q}get maxSize(){return this.#Z}get calculatedSize(){return this.#_}get size(){return this.#V}get fetchMethod(){return this.#C}get memoMethod(){return this.#M}get dispose(){return this.#q}get onInsert(){return this.#X}get disposeAfter(){return this.#J}constructor(Q){let{max:Z=0,ttl:X,ttlResolution:q=1,ttlAutopurge:Y,updateAgeOnGet:J,updateAgeOnHas:H,allowStale:W,dispose:V,onInsert:K,disposeAfter:G,noDisposeOnSet:_,noUpdateTTL:z,maxSize:O=0,maxEntrySize:$=0,sizeCalculation:A,fetchMethod:U,memoMethod:B,noDeleteOnFetchRejection:M,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:F,allowStaleOnFetchAbort:w,ignoreFetchAbort:y}=Q;if(Z!==0&&!N0(Z))throw TypeError("max option must be a nonnegative integer");let v=Z?QQ(Z):Array;if(!v)throw Error("invalid max value: "+Z);if(this.#Q=Z,this.#Z=O,this.maxEntrySize=$||this.#Z,this.sizeCalculation=A,this.sizeCalculation){if(!this.#Z&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw TypeError("sizeCalculation set to non-function")}if(B!==void 0&&typeof B!=="function")throw TypeError("memoMethod must be a function if defined");if(this.#M=B,U!==void 0&&typeof U!=="function")throw TypeError("fetchMethod must be a function if specified");if(this.#C=U,this.#w=!!U,this.#K=new Map,this.#G=Array(Z).fill(void 0),this.#Y=Array(Z).fill(void 0),this.#$=new v(Z),this.#B=new v(Z),this.#O=0,this.#A=0,this.#F=m0.create(Z),this.#V=0,this.#_=0,typeof V==="function")this.#q=V;if(typeof K==="function")this.#X=K;if(typeof G==="function")this.#J=G,this.#H=[];else this.#J=void 0,this.#H=void 0;if(this.#R=!!this.#q,this.#b=!!this.#X,this.#I=!!this.#J,this.noDisposeOnSet=!!_,this.noUpdateTTL=!!z,this.noDeleteOnFetchRejection=!!M,this.allowStaleOnFetchRejection=!!F,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!y,this.maxEntrySize!==0){if(this.#Z!==0){if(!N0(this.#Z))throw TypeError("maxSize must be a positive integer if specified")}if(!N0(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#g()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!J,this.updateAgeOnHas=!!H,this.ttlResolution=N0(q)||q===0?q:1,this.ttlAutopurge=!!Y,this.ttl=X||0,this.ttl){if(!N0(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#W()}if(this.#Q===0&&this.ttl===0&&this.#Z===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Q&&!this.#Z){if(J4("LRU_CACHE_UNBOUNDED"))t9.add("LRU_CACHE_UNBOUNDED"),e9("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",Q8)}}getRemainingTTL(Q){return this.#K.has(Q)?1/0:0}#W(){let Q=new e0(this.#Q),Z=new e0(this.#Q);this.#L=Q,this.#z=Z,this.#k=(Y,J,H=g0.now())=>{if(Z[Y]=J!==0?H:0,Q[Y]=J,J!==0&&this.ttlAutopurge){let W=setTimeout(()=>{if(this.#S(Y))this.#D(this.#G[Y],"expire")},J+1);if(W.unref)W.unref()}},this.#v=(Y)=>{Z[Y]=Q[Y]!==0?g0.now():0},this.#T=(Y,J)=>{if(Q[J]){let H=Q[J],W=Z[J];if(!H||!W)return;Y.ttl=H,Y.start=W,Y.now=X||q();let V=Y.now-W;Y.remainingTTL=H-V}};let X=0,q=()=>{let Y=g0.now();if(this.ttlResolution>0){X=Y;let J=setTimeout(()=>X=0,this.ttlResolution);if(J.unref)J.unref()}return Y};this.getRemainingTTL=(Y)=>{let J=this.#K.get(Y);if(J===void 0)return 0;let H=Q[J],W=Z[J];if(!H||!W)return 1/0;let V=(X||q())-W;return H-V},this.#S=(Y)=>{let J=Z[Y],H=Q[Y];return!!H&&!!J&&(X||q())-J>H}}#v=()=>{};#T=()=>{};#k=()=>{};#S=()=>!1;#g(){let Q=new e0(this.#Q);this.#_=0,this.#j=Q,this.#y=(Z)=>{this.#_-=Q[Z],Q[Z]=0},this.#m=(Z,X,q,Y)=>{if(this.#U(X))return 0;if(!N0(q))if(Y){if(typeof Y!=="function")throw TypeError("sizeCalculation must be a function");if(q=Y(X,Z),!N0(q))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return q},this.#x=(Z,X,q)=>{if(Q[Z]=X,this.#Z){let Y=this.#Z-Q[Z];while(this.#_>Y)this.#u(!0)}if(this.#_+=Q[Z],q)q.entrySize=X,q.totalCalculatedSize=this.#_}}#y=(Q)=>{};#x=(Q,Z,X)=>{};#m=(Q,Z,X,q)=>{if(X||q)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#N({allowStale:Q=this.allowStale}={}){if(this.#V)for(let Z=this.#A;;){if(!this.#c(Z))break;if(Q||!this.#S(Z))yield Z;if(Z===this.#O)break;else Z=this.#B[Z]}}*#P({allowStale:Q=this.allowStale}={}){if(this.#V)for(let Z=this.#O;;){if(!this.#c(Z))break;if(Q||!this.#S(Z))yield Z;if(Z===this.#A)break;else Z=this.#$[Z]}}#c(Q){return Q!==void 0&&this.#K.get(this.#G[Q])===Q}*entries(){for(let Q of this.#N())if(this.#Y[Q]!==void 0&&this.#G[Q]!==void 0&&!this.#U(this.#Y[Q]))yield[this.#G[Q],this.#Y[Q]]}*rentries(){for(let Q of this.#P())if(this.#Y[Q]!==void 0&&this.#G[Q]!==void 0&&!this.#U(this.#Y[Q]))yield[this.#G[Q],this.#Y[Q]]}*keys(){for(let Q of this.#N()){let Z=this.#G[Q];if(Z!==void 0&&!this.#U(this.#Y[Q]))yield Z}}*rkeys(){for(let Q of this.#P()){let Z=this.#G[Q];if(Z!==void 0&&!this.#U(this.#Y[Q]))yield Z}}*values(){for(let Q of this.#N())if(this.#Y[Q]!==void 0&&!this.#U(this.#Y[Q]))yield this.#Y[Q]}*rvalues(){for(let Q of this.#P())if(this.#Y[Q]!==void 0&&!this.#U(this.#Y[Q]))yield this.#Y[Q]}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Q,Z={}){for(let X of this.#N()){let q=this.#Y[X],Y=this.#U(q)?q.__staleWhileFetching:q;if(Y===void 0)continue;if(Q(Y,this.#G[X],this))return this.get(this.#G[X],Z)}}forEach(Q,Z=this){for(let X of this.#N()){let q=this.#Y[X],Y=this.#U(q)?q.__staleWhileFetching:q;if(Y===void 0)continue;Q.call(Z,Y,this.#G[X],this)}}rforEach(Q,Z=this){for(let X of this.#P()){let q=this.#Y[X],Y=this.#U(q)?q.__staleWhileFetching:q;if(Y===void 0)continue;Q.call(Z,Y,this.#G[X],this)}}purgeStale(){let Q=!1;for(let Z of this.#P({allowStale:!0}))if(this.#S(Z))this.#D(this.#G[Z],"expire"),Q=!0;return Q}info(Q){let Z=this.#K.get(Q);if(Z===void 0)return;let X=this.#Y[Z],q=this.#U(X)?X.__staleWhileFetching:X;if(q===void 0)return;let Y={value:q};if(this.#L&&this.#z){let J=this.#L[Z],H=this.#z[Z];if(J&&H){let W=J-(g0.now()-H);Y.ttl=W,Y.start=Date.now()}}if(this.#j)Y.size=this.#j[Z];return Y}dump(){let Q=[];for(let Z of this.#N({allowStale:!0})){let X=this.#G[Z],q=this.#Y[Z],Y=this.#U(q)?q.__staleWhileFetching:q;if(Y===void 0||X===void 0)continue;let J={value:Y};if(this.#L&&this.#z){J.ttl=this.#L[Z];let H=g0.now()-this.#z[Z];J.start=Math.floor(Date.now()-H)}if(this.#j)J.size=this.#j[Z];Q.unshift([X,J])}return Q}load(Q){this.clear();for(let[Z,X]of Q){if(X.start){let q=Date.now()-X.start;X.start=g0.now()-q}this.set(Z,X.value,X)}}set(Q,Z,X={}){if(Z===void 0)return this.delete(Q),this;let{ttl:q=this.ttl,start:Y,noDisposeOnSet:J=this.noDisposeOnSet,sizeCalculation:H=this.sizeCalculation,status:W}=X,{noUpdateTTL:V=this.noUpdateTTL}=X,K=this.#m(Q,Z,X.size||0,H);if(this.maxEntrySize&&K>this.maxEntrySize){if(W)W.set="miss",W.maxEntrySizeExceeded=!0;return this.#D(Q,"set"),this}let G=this.#V===0?void 0:this.#K.get(Q);if(G===void 0){if(G=this.#V===0?this.#A:this.#F.length!==0?this.#F.pop():this.#V===this.#Q?this.#u(!1):this.#V,this.#G[G]=Q,this.#Y[G]=Z,this.#K.set(Q,G),this.#$[this.#A]=G,this.#B[G]=this.#A,this.#A=G,this.#V++,this.#x(G,K,W),W)W.set="add";if(V=!1,this.#b)this.#X?.(Z,Q,"add")}else{this.#f(G);let _=this.#Y[G];if(Z!==_){if(this.#w&&this.#U(_)){_.__abortController.abort(Error("replaced"));let{__staleWhileFetching:z}=_;if(z!==void 0&&!J){if(this.#R)this.#q?.(z,Q,"set");if(this.#I)this.#H?.push([z,Q,"set"])}}else if(!J){if(this.#R)this.#q?.(_,Q,"set");if(this.#I)this.#H?.push([_,Q,"set"])}if(this.#y(G),this.#x(G,K,W),this.#Y[G]=Z,W){W.set="replace";let z=_&&this.#U(_)?_.__staleWhileFetching:_;if(z!==void 0)W.oldValue=z}}else if(W)W.set="update";if(this.#b)this.onInsert?.(Z,Q,Z===_?"update":"replace")}if(q!==0&&!this.#L)this.#W();if(this.#L){if(!V)this.#k(G,q,Y);if(W)this.#T(W,G)}if(!J&&this.#I&&this.#H){let _=this.#H,z;while(z=_?.shift())this.#J?.(...z)}return this}pop(){try{while(this.#V){let Q=this.#Y[this.#O];if(this.#u(!0),this.#U(Q)){if(Q.__staleWhileFetching)return Q.__staleWhileFetching}else if(Q!==void 0)return Q}}finally{if(this.#I&&this.#H){let Q=this.#H,Z;while(Z=Q?.shift())this.#J?.(...Z)}}}#u(Q){let Z=this.#O,X=this.#G[Z],q=this.#Y[Z];if(this.#w&&this.#U(q))q.__abortController.abort(Error("evicted"));else if(this.#R||this.#I){if(this.#R)this.#q?.(q,X,"evict");if(this.#I)this.#H?.push([q,X,"evict"])}if(this.#y(Z),Q)this.#G[Z]=void 0,this.#Y[Z]=void 0,this.#F.push(Z);if(this.#V===1)this.#O=this.#A=0,this.#F.length=0;else this.#O=this.#$[Z];return this.#K.delete(X),this.#V--,Z}has(Q,Z={}){let{updateAgeOnHas:X=this.updateAgeOnHas,status:q}=Z,Y=this.#K.get(Q);if(Y!==void 0){let J=this.#Y[Y];if(this.#U(J)&&J.__staleWhileFetching===void 0)return!1;if(!this.#S(Y)){if(X)this.#v(Y);if(q)q.has="hit",this.#T(q,Y);return!0}else if(q)q.has="stale",this.#T(q,Y)}else if(q)q.has="miss";return!1}peek(Q,Z={}){let{allowStale:X=this.allowStale}=Z,q=this.#K.get(Q);if(q===void 0||!X&&this.#S(q))return;let Y=this.#Y[q];return this.#U(Y)?Y.__staleWhileFetching:Y}#E(Q,Z,X,q){let Y=Z===void 0?void 0:this.#Y[Z];if(this.#U(Y))return Y;let J=new S8,{signal:H}=X;H?.addEventListener("abort",()=>J.abort(H.reason),{signal:J.signal});let W={signal:J.signal,options:X,context:q},V=($,A=!1)=>{let{aborted:U}=J.signal,B=X.ignoreFetchAbort&&$!==void 0;if(X.status)if(U&&!A){if(X.status.fetchAborted=!0,X.status.fetchError=J.signal.reason,B)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(U&&!B&&!A)return G(J.signal.reason);let M=z;if(this.#Y[Z]===z)if($===void 0)if(M.__staleWhileFetching)this.#Y[Z]=M.__staleWhileFetching;else this.#D(Q,"fetch");else{if(X.status)X.status.fetchUpdated=!0;this.set(Q,$,W.options)}return $},K=($)=>{if(X.status)X.status.fetchRejected=!0,X.status.fetchError=$;return G($)},G=($)=>{let{aborted:A}=J.signal,U=A&&X.allowStaleOnFetchAbort,B=U||X.allowStaleOnFetchRejection,M=B||X.noDeleteOnFetchRejection,R=z;if(this.#Y[Z]===z){if(!M||R.__staleWhileFetching===void 0)this.#D(Q,"fetch");else if(!U)this.#Y[Z]=R.__staleWhileFetching}if(B){if(X.status&&R.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return R.__staleWhileFetching}else if(R.__returned===R)throw $},_=($,A)=>{let U=this.#C?.(Q,Y,W);if(U&&U instanceof Promise)U.then((B)=>$(B===void 0?void 0:B),A);J.signal.addEventListener("abort",()=>{if(!X.ignoreFetchAbort||X.allowStaleOnFetchAbort){if($(void 0),X.allowStaleOnFetchAbort)$=(B)=>V(B,!0)}})};if(X.status)X.status.fetchDispatched=!0;let z=new Promise(_).then(V,K),O=Object.assign(z,{__abortController:J,__staleWhileFetching:Y,__returned:void 0});if(Z===void 0)this.set(Q,O,{...W.options,status:void 0}),Z=this.#K.get(Q);else this.#Y[Z]=O;return O}#U(Q){if(!this.#w)return!1;let Z=Q;return!!Z&&Z instanceof Promise&&Z.hasOwnProperty("__staleWhileFetching")&&Z.__abortController instanceof S8}async fetch(Q,Z={}){let{allowStale:X=this.allowStale,updateAgeOnGet:q=this.updateAgeOnGet,noDeleteOnStaleGet:Y=this.noDeleteOnStaleGet,ttl:J=this.ttl,noDisposeOnSet:H=this.noDisposeOnSet,size:W=0,sizeCalculation:V=this.sizeCalculation,noUpdateTTL:K=this.noUpdateTTL,noDeleteOnFetchRejection:G=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:_=this.allowStaleOnFetchRejection,ignoreFetchAbort:z=this.ignoreFetchAbort,allowStaleOnFetchAbort:O=this.allowStaleOnFetchAbort,context:$,forceRefresh:A=!1,status:U,signal:B}=Z;if(!this.#w){if(U)U.fetch="get";return this.get(Q,{allowStale:X,updateAgeOnGet:q,noDeleteOnStaleGet:Y,status:U})}let M={allowStale:X,updateAgeOnGet:q,noDeleteOnStaleGet:Y,ttl:J,noDisposeOnSet:H,size:W,sizeCalculation:V,noUpdateTTL:K,noDeleteOnFetchRejection:G,allowStaleOnFetchRejection:_,allowStaleOnFetchAbort:O,ignoreFetchAbort:z,status:U,signal:B},R=this.#K.get(Q);if(R===void 0){if(U)U.fetch="miss";let F=this.#E(Q,R,M,$);return F.__returned=F}else{let F=this.#Y[R];if(this.#U(F)){let J0=X&&F.__staleWhileFetching!==void 0;if(U){if(U.fetch="inflight",J0)U.returnedStale=!0}return J0?F.__staleWhileFetching:F.__returned=F}let w=this.#S(R);if(!A&&!w){if(U)U.fetch="hit";if(this.#f(R),q)this.#v(R);if(U)this.#T(U,R);return F}let y=this.#E(Q,R,M,$),Y0=y.__staleWhileFetching!==void 0&&X;if(U){if(U.fetch=w?"stale":"refresh",Y0&&w)U.returnedStale=!0}return Y0?y.__staleWhileFetching:y.__returned=y}}async forceFetch(Q,Z={}){let X=await this.fetch(Q,Z);if(X===void 0)throw Error("fetch() returned undefined");return X}memo(Q,Z={}){let X=this.#M;if(!X)throw Error("no memoMethod provided to constructor");let{context:q,forceRefresh:Y,...J}=Z,H=this.get(Q,J);if(!Y&&H!==void 0)return H;let W=X(Q,H,{options:J,context:q});return this.set(Q,W,J),W}get(Q,Z={}){let{allowStale:X=this.allowStale,updateAgeOnGet:q=this.updateAgeOnGet,noDeleteOnStaleGet:Y=this.noDeleteOnStaleGet,status:J}=Z,H=this.#K.get(Q);if(H!==void 0){let W=this.#Y[H],V=this.#U(W);if(J)this.#T(J,H);if(this.#S(H)){if(J)J.get="stale";if(!V){if(!Y)this.#D(Q,"expire");if(J&&X)J.returnedStale=!0;return X?W:void 0}else{if(J&&X&&W.__staleWhileFetching!==void 0)J.returnedStale=!0;return X?W.__staleWhileFetching:void 0}}else{if(J)J.get="hit";if(V)return W.__staleWhileFetching;if(this.#f(H),q)this.#v(H);return W}}else if(J)J.get="miss"}#l(Q,Z){this.#B[Z]=Q,this.#$[Q]=Z}#f(Q){if(Q!==this.#A){if(Q===this.#O)this.#O=this.#$[Q];else this.#l(this.#B[Q],this.#$[Q]);this.#l(this.#A,Q),this.#A=Q}}delete(Q){return this.#D(Q,"delete")}#D(Q,Z){let X=!1;if(this.#V!==0){let q=this.#K.get(Q);if(q!==void 0)if(X=!0,this.#V===1)this.#h(Z);else{this.#y(q);let Y=this.#Y[q];if(this.#U(Y))Y.__abortController.abort(Error("deleted"));else if(this.#R||this.#I){if(this.#R)this.#q?.(Y,Q,Z);if(this.#I)this.#H?.push([Y,Q,Z])}if(this.#K.delete(Q),this.#G[q]=void 0,this.#Y[q]=void 0,q===this.#A)this.#A=this.#B[q];else if(q===this.#O)this.#O=this.#$[q];else{let J=this.#B[q];this.#$[J]=this.#$[q];let H=this.#$[q];this.#B[H]=this.#B[q]}this.#V--,this.#F.push(q)}}if(this.#I&&this.#H?.length){let q=this.#H,Y;while(Y=q?.shift())this.#J?.(...Y)}return X}clear(){return this.#h("delete")}#h(Q){for(let Z of this.#P({allowStale:!0})){let X=this.#Y[Z];if(this.#U(X))X.__abortController.abort(Error("deleted"));else{let q=this.#G[Z];if(this.#R)this.#q?.(X,q,Q);if(this.#I)this.#H?.push([X,q,Q])}}if(this.#K.clear(),this.#Y.fill(void 0),this.#G.fill(void 0),this.#L&&this.#z)this.#L.fill(0),this.#z.fill(0);if(this.#j)this.#j.fill(0);if(this.#O=0,this.#A=0,this.#F.length=0,this.#_=0,this.#V=0,this.#I&&this.#H){let Z=this.#H,X;while(X=Z?.shift())this.#J?.(...X)}}}import{posix as O4,win32 as X7}from"node:path";import{fileURLToPath as A4}from"node:url";import{lstatSync as B4,readdir as R4,readdirSync as I4,readlinkSync as C4,realpathSync as L4}from"fs";import*as F4 from"node:fs";import{lstat as T4,readdir as S4,readlink as w4,realpath as N4}from"node:fs/promises";import{EventEmitter as t6}from"node:events";import JQ from"node:stream";import{StringDecoder as W4}from"node:string_decoder";var ZQ=typeof process==="object"&&process?process:{stdout:null,stderr:null},H4=(Q)=>!!Q&&typeof Q==="object"&&(Q instanceof E0||Q instanceof JQ||V4(Q)||K4(Q)),V4=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof t6&&typeof Q.pipe==="function"&&Q.pipe!==JQ.Writable.prototype.pipe,K4=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof t6&&typeof Q.write==="function"&&typeof Q.end==="function",I0=Symbol("EOF"),C0=Symbol("maybeEmitEnd"),P0=Symbol("emittedEnd"),w8=Symbol("emittingEnd"),Z8=Symbol("emittedError"),N8=Symbol("closed"),XQ=Symbol("read"),P8=Symbol("flush"),qQ=Symbol("flushChunk"),_0=Symbol("encoding"),c0=Symbol("decoder"),d=Symbol("flowing"),X8=Symbol("paused"),l0=Symbol("resume"),i=Symbol("buffer"),Z0=Symbol("pipes"),p=Symbol("bufferLength"),a6=Symbol("bufferPush"),b8=Symbol("bufferShift"),e=Symbol("objectMode"),g=Symbol("destroyed"),n6=Symbol("error"),r6=Symbol("emitData"),YQ=Symbol("emitEnd"),s6=Symbol("emitEnd2"),O0=Symbol("async"),o6=Symbol("abort"),k8=Symbol("aborted"),q8=Symbol("signal"),y0=Symbol("dataListeners"),q0=Symbol("discarded"),Y8=(Q)=>Promise.resolve().then(Q),z4=(Q)=>Q(),G4=(Q)=>Q==="end"||Q==="finish"||Q==="prefinish",_4=(Q)=>Q instanceof ArrayBuffer||!!Q&&typeof Q==="object"&&Q.constructor&&Q.constructor.name==="ArrayBuffer"&&Q.byteLength>=0,U4=(Q)=>!Buffer.isBuffer(Q)&&ArrayBuffer.isView(Q);class e6{src;dest;opts;ondrain;constructor(Q,Z,X){this.src=Q,this.dest=Z,this.opts=X,this.ondrain=()=>Q[l0](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(Q){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class WQ extends e6{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(Q,Z,X){super(Q,Z,X);this.proxyErrors=(q)=>Z.emit("error",q),Q.on("error",this.proxyErrors)}}var $4=(Q)=>!!Q.objectMode,M4=(Q)=>!Q.objectMode&&!!Q.encoding&&Q.encoding!=="buffer";class E0 extends t6{[d]=!1;[X8]=!1;[Z0]=[];[i]=[];[e];[_0];[O0];[c0];[I0]=!1;[P0]=!1;[w8]=!1;[N8]=!1;[Z8]=null;[p]=0;[g]=!1;[q8];[k8]=!1;[y0]=0;[q0]=!1;writable=!0;readable=!0;constructor(...Q){let Z=Q[0]||{};super();if(Z.objectMode&&typeof Z.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if($4(Z))this[e]=!0,this[_0]=null;else if(M4(Z))this[_0]=Z.encoding,this[e]=!1;else this[e]=!1,this[_0]=null;if(this[O0]=!!Z.async,this[c0]=this[_0]?new W4(this[_0]):null,Z&&Z.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[i]});if(Z&&Z.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[Z0]});let{signal:X}=Z;if(X)if(this[q8]=X,X.aborted)this[o6]();else X.addEventListener("abort",()=>this[o6]())}get bufferLength(){return this[p]}get encoding(){return this[_0]}set encoding(Q){throw Error("Encoding must be set at instantiation time")}setEncoding(Q){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[e]}set objectMode(Q){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[O0]}set["async"](Q){this[O0]=this[O0]||!!Q}[o6](){this[k8]=!0,this.emit("abort",this[q8]?.reason),this.destroy(this[q8]?.reason)}get aborted(){return this[k8]}set aborted(Q){}write(Q,Z,X){if(this[k8])return!1;if(this[I0])throw Error("write after end");if(this[g])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof Z==="function")X=Z,Z="utf8";if(!Z)Z="utf8";let q=this[O0]?Y8:z4;if(!this[e]&&!Buffer.isBuffer(Q)){if(U4(Q))Q=Buffer.from(Q.buffer,Q.byteOffset,Q.byteLength);else if(_4(Q))Q=Buffer.from(Q);else if(typeof Q!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[e]){if(this[d]&&this[p]!==0)this[P8](!0);if(this[d])this.emit("data",Q);else this[a6](Q);if(this[p]!==0)this.emit("readable");if(X)q(X);return this[d]}if(!Q.length){if(this[p]!==0)this.emit("readable");if(X)q(X);return this[d]}if(typeof Q==="string"&&!(Z===this[_0]&&!this[c0]?.lastNeed))Q=Buffer.from(Q,Z);if(Buffer.isBuffer(Q)&&this[_0])Q=this[c0].write(Q);if(this[d]&&this[p]!==0)this[P8](!0);if(this[d])this.emit("data",Q);else this[a6](Q);if(this[p]!==0)this.emit("readable");if(X)q(X);return this[d]}read(Q){if(this[g])return null;if(this[q0]=!1,this[p]===0||Q===0||Q&&Q>this[p])return this[C0](),null;if(this[e])Q=null;if(this[i].length>1&&!this[e])this[i]=[this[_0]?this[i].join(""):Buffer.concat(this[i],this[p])];let Z=this[XQ](Q||null,this[i][0]);return this[C0](),Z}[XQ](Q,Z){if(this[e])this[b8]();else{let X=Z;if(Q===X.length||Q===null)this[b8]();else if(typeof X==="string")this[i][0]=X.slice(Q),Z=X.slice(0,Q),this[p]-=Q;else this[i][0]=X.subarray(Q),Z=X.subarray(0,Q),this[p]-=Q}if(this.emit("data",Z),!this[i].length&&!this[I0])this.emit("drain");return Z}end(Q,Z,X){if(typeof Q==="function")X=Q,Q=void 0;if(typeof Z==="function")X=Z,Z="utf8";if(Q!==void 0)this.write(Q,Z);if(X)this.once("end",X);if(this[I0]=!0,this.writable=!1,this[d]||!this[X8])this[C0]();return this}[l0](){if(this[g])return;if(!this[y0]&&!this[Z0].length)this[q0]=!0;if(this[X8]=!1,this[d]=!0,this.emit("resume"),this[i].length)this[P8]();else if(this[I0])this[C0]();else this.emit("drain")}resume(){return this[l0]()}pause(){this[d]=!1,this[X8]=!0,this[q0]=!1}get destroyed(){return this[g]}get flowing(){return this[d]}get paused(){return this[X8]}[a6](Q){if(this[e])this[p]+=1;else this[p]+=Q.length;this[i].push(Q)}[b8](){if(this[e])this[p]-=1;else this[p]-=this[i][0].length;return this[i].shift()}[P8](Q=!1){do;while(this[qQ](this[b8]())&&this[i].length);if(!Q&&!this[i].length&&!this[I0])this.emit("drain")}[qQ](Q){return this.emit("data",Q),this[d]}pipe(Q,Z){if(this[g])return Q;this[q0]=!1;let X=this[P0];if(Z=Z||{},Q===ZQ.stdout||Q===ZQ.stderr)Z.end=!1;else Z.end=Z.end!==!1;if(Z.proxyErrors=!!Z.proxyErrors,X){if(Z.end)Q.end()}else if(this[Z0].push(!Z.proxyErrors?new e6(this,Q,Z):new WQ(this,Q,Z)),this[O0])Y8(()=>this[l0]());else this[l0]();return Q}unpipe(Q){let Z=this[Z0].find((X)=>X.dest===Q);if(Z){if(this[Z0].length===1){if(this[d]&&this[y0]===0)this[d]=!1;this[Z0]=[]}else this[Z0].splice(this[Z0].indexOf(Z),1);Z.unpipe()}}addListener(Q,Z){return this.on(Q,Z)}on(Q,Z){let X=super.on(Q,Z);if(Q==="data"){if(this[q0]=!1,this[y0]++,!this[Z0].length&&!this[d])this[l0]()}else if(Q==="readable"&&this[p]!==0)super.emit("readable");else if(G4(Q)&&this[P0])super.emit(Q),this.removeAllListeners(Q);else if(Q==="error"&&this[Z8]){let q=Z;if(this[O0])Y8(()=>q.call(this,this[Z8]));else q.call(this,this[Z8])}return X}removeListener(Q,Z){return this.off(Q,Z)}off(Q,Z){let X=super.off(Q,Z);if(Q==="data"){if(this[y0]=this.listeners("data").length,this[y0]===0&&!this[q0]&&!this[Z0].length)this[d]=!1}return X}removeAllListeners(Q){let Z=super.removeAllListeners(Q);if(Q==="data"||Q===void 0){if(this[y0]=0,!this[q0]&&!this[Z0].length)this[d]=!1}return Z}get emittedEnd(){return this[P0]}[C0](){if(!this[w8]&&!this[P0]&&!this[g]&&this[i].length===0&&this[I0]){if(this[w8]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[N8])this.emit("close");this[w8]=!1}}emit(Q,...Z){let X=Z[0];if(Q!=="error"&&Q!=="close"&&Q!==g&&this[g])return!1;else if(Q==="data")return!this[e]&&!X?!1:this[O0]?(Y8(()=>this[r6](X)),!0):this[r6](X);else if(Q==="end")return this[YQ]();else if(Q==="close"){if(this[N8]=!0,!this[P0]&&!this[g])return!1;let Y=super.emit("close");return this.removeAllListeners("close"),Y}else if(Q==="error"){this[Z8]=X,super.emit(n6,X);let Y=!this[q8]||this.listeners("error").length?super.emit("error",X):!1;return this[C0](),Y}else if(Q==="resume"){let Y=super.emit("resume");return this[C0](),Y}else if(Q==="finish"||Q==="prefinish"){let Y=super.emit(Q);return this.removeAllListeners(Q),Y}let q=super.emit(Q,...Z);return this[C0](),q}[r6](Q){for(let X of this[Z0])if(X.dest.write(Q)===!1)this.pause();let Z=this[q0]?!1:super.emit("data",Q);return this[C0](),Z}[YQ](){if(this[P0])return!1;return this[P0]=!0,this.readable=!1,this[O0]?(Y8(()=>this[s6]()),!0):this[s6]()}[s6](){if(this[c0]){let Z=this[c0].end();if(Z){for(let X of this[Z0])X.dest.write(Z);if(!this[q0])super.emit("data",Z)}}for(let Z of this[Z0])Z.end();let Q=super.emit("end");return this.removeAllListeners("end"),Q}async collect(){let Q=Object.assign([],{dataLength:0});if(!this[e])Q.dataLength=0;let Z=this.promise();return this.on("data",(X)=>{if(Q.push(X),!this[e])Q.dataLength+=X.length}),await Z,Q}async concat(){if(this[e])throw Error("cannot concat in objectMode");let Q=await this.collect();return this[_0]?Q.join(""):Buffer.concat(Q,Q.dataLength)}async promise(){return new Promise((Q,Z)=>{this.on(g,()=>Z(Error("stream destroyed"))),this.on("error",(X)=>Z(X)),this.on("end",()=>Q())})}[Symbol.asyncIterator](){this[q0]=!1;let Q=!1,Z=async()=>{return this.pause(),Q=!0,{value:void 0,done:!0}};return{next:()=>{if(Q)return Z();let q=this.read();if(q!==null)return Promise.resolve({done:!1,value:q});if(this[I0])return Z();let Y,J,H=(G)=>{this.off("data",W),this.off("end",V),this.off(g,K),Z(),J(G)},W=(G)=>{this.off("error",H),this.off("end",V),this.off(g,K),this.pause(),Y({value:G,done:!!this[I0]})},V=()=>{this.off("error",H),this.off("data",W),this.off(g,K),Z(),Y({done:!0,value:void 0})},K=()=>H(Error("stream destroyed"));return new Promise((G,_)=>{J=_,Y=G,this.once(g,K),this.once("error",H),this.once("end",V),this.once("data",W)})},throw:Z,return:Z,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[q0]=!1;let Q=!1,Z=()=>{return this.pause(),this.off(n6,Z),this.off(g,Z),this.off("end",Z),Q=!0,{done:!0,value:void 0}},X=()=>{if(Q)return Z();let q=this.read();return q===null?Z():{done:!1,value:q}};return this.once("end",Z),this.once(n6,Z),this.once(g,Z),{next:X,throw:Z,return:Z,[Symbol.iterator](){return this}}}destroy(Q){if(this[g]){if(Q)this.emit("error",Q);else this.emit(g);return this}this[g]=!0,this[q0]=!0,this[i].length=0,this[p]=0;let Z=this;if(typeof Z.close==="function"&&!this[N8])Z.close();if(Q)this.emit("error",Q);else this.emit(g);return this}static get isStream(){return H4}}var j4=L4.native,W8={lstatSync:B4,readdir:R4,readdirSync:I4,readlinkSync:C4,realpathSync:j4,promises:{lstat:T4,readdir:S4,readlink:w4,realpath:N4}},GQ=(Q)=>!Q||Q===W8||Q===F4?W8:{...W8,...Q,promises:{...W8.promises,...Q.promises||{}}},_Q=/^\\\\\?\\([a-z]:)\\?$/i,P4=(Q)=>Q.replace(/\//g,"\\").replace(_Q,"$1\\"),b4=/[\\\/]/,K0=0,UQ=1,$Q=2,A0=4,MQ=6,OQ=8,x0=10,AQ=12,V0=15,J8=~V0,Q7=16,HQ=32,H8=64,U0=128,D8=256,y8=512,VQ=H8|U0|y8,k4=1023,Z7=(Q)=>Q.isFile()?OQ:Q.isDirectory()?A0:Q.isSymbolicLink()?x0:Q.isCharacterDevice()?$Q:Q.isBlockDevice()?MQ:Q.isSocket()?AQ:Q.isFIFO()?UQ:K0,KQ=new Map,V8=(Q)=>{let Z=KQ.get(Q);if(Z)return Z;let X=Q.normalize("NFKD");return KQ.set(Q,X),X},zQ=new Map,v8=(Q)=>{let Z=zQ.get(Q);if(Z)return Z;let X=V8(Q.toLowerCase());return zQ.set(Q,X),X};class q7 extends Q8{constructor(){super({max:256})}}class BQ extends Q8{constructor(Q=16384){super({maxSize:Q,sizeCalculation:(Z)=>Z.length+1})}}var RQ=Symbol("PathScurry setAsCwd");class X0{name;root;roots;parent;nocase;isCWD=!1;#Q;#Z;get dev(){return this.#Z}#q;get mode(){return this.#q}#X;get nlink(){return this.#X}#J;get uid(){return this.#J}#C;get gid(){return this.#C}#M;get rdev(){return this.#M}#V;get blksize(){return this.#V}#_;get ino(){return this.#_}#K;get size(){return this.#K}#G;get blocks(){return this.#G}#Y;get atimeMs(){return this.#Y}#$;get mtimeMs(){return this.#$}#B;get ctimeMs(){return this.#B}#O;get birthtimeMs(){return this.#O}#A;get atime(){return this.#A}#F;get mtime(){return this.#F}#H;get ctime(){return this.#H}#j;get birthtime(){return this.#j}#z;#L;#R;#w;#I;#b;#W;#v;#T;#k;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Q,Z=K0,X,q,Y,J,H){if(this.name=Q,this.#z=Y?v8(Q):V8(Q),this.#W=Z&k4,this.nocase=Y,this.roots=q,this.root=X||this,this.#v=J,this.#R=H.fullpath,this.#I=H.relative,this.#b=H.relativePosix,this.parent=H.parent,this.parent)this.#Q=this.parent.#Q;else this.#Q=GQ(H.fs)}depth(){if(this.#L!==void 0)return this.#L;if(!this.parent)return this.#L=0;return this.#L=this.parent.depth()+1}childrenCache(){return this.#v}resolve(Q){if(!Q)return this;let Z=this.getRootString(Q),q=Q.substring(Z.length).split(this.splitSep);return Z?this.getRoot(Z).#S(q):this.#S(q)}#S(Q){let Z=this;for(let X of Q)Z=Z.child(X);return Z}children(){let Q=this.#v.get(this);if(Q)return Q;let Z=Object.assign([],{provisional:0});return this.#v.set(this,Z),this.#W&=~Q7,Z}child(Q,Z){if(Q===""||Q===".")return this;if(Q==="..")return this.parent||this;let X=this.children(),q=this.nocase?v8(Q):V8(Q);for(let W of X)if(W.#z===q)return W;let Y=this.parent?this.sep:"",J=this.#R?this.#R+Y+Q:void 0,H=this.newChild(Q,K0,{...Z,parent:this,fullpath:J});if(!this.canReaddir())H.#W|=U0;return X.push(H),H}relative(){if(this.isCWD)return"";if(this.#I!==void 0)return this.#I;let Q=this.name,Z=this.parent;if(!Z)return this.#I=this.name;let X=Z.relative();return X+(!X||!Z.parent?"":this.sep)+Q}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#b!==void 0)return this.#b;let Q=this.name,Z=this.parent;if(!Z)return this.#b=this.fullpathPosix();let X=Z.relativePosix();return X+(!X||!Z.parent?"":"/")+Q}fullpath(){if(this.#R!==void 0)return this.#R;let Q=this.name,Z=this.parent;if(!Z)return this.#R=this.name;let q=Z.fullpath()+(!Z.parent?"":this.sep)+Q;return this.#R=q}fullpathPosix(){if(this.#w!==void 0)return this.#w;if(this.sep==="/")return this.#w=this.fullpath();if(!this.parent){let q=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(q))return this.#w=`//?/${q}`;else return this.#w=q}let Q=this.parent,Z=Q.fullpathPosix(),X=Z+(!Z||!Q.parent?"":"/")+this.name;return this.#w=X}isUnknown(){return(this.#W&V0)===K0}isType(Q){return this[`is${Q}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#W&V0)===OQ}isDirectory(){return(this.#W&V0)===A0}isCharacterDevice(){return(this.#W&V0)===$Q}isBlockDevice(){return(this.#W&V0)===MQ}isFIFO(){return(this.#W&V0)===UQ}isSocket(){return(this.#W&V0)===AQ}isSymbolicLink(){return(this.#W&x0)===x0}lstatCached(){return this.#W&HQ?this:void 0}readlinkCached(){return this.#T}realpathCached(){return this.#k}readdirCached(){let Q=this.children();return Q.slice(0,Q.provisional)}canReadlink(){if(this.#T)return!0;if(!this.parent)return!1;let Q=this.#W&V0;return!(Q!==K0&&Q!==x0||this.#W&D8||this.#W&U0)}calledReaddir(){return!!(this.#W&Q7)}isENOENT(){return!!(this.#W&U0)}isNamed(Q){return!this.nocase?this.#z===V8(Q):this.#z===v8(Q)}async readlink(){let Q=this.#T;if(Q)return Q;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=await this.#Q.promises.readlink(this.fullpath()),X=(await this.parent.realpath())?.resolve(Z);if(X)return this.#T=X}catch(Z){this.#u(Z.code);return}}readlinkSync(){let Q=this.#T;if(Q)return Q;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=this.#Q.readlinkSync(this.fullpath()),X=this.parent.realpathSync()?.resolve(Z);if(X)return this.#T=X}catch(Z){this.#u(Z.code);return}}#g(Q){this.#W|=Q7;for(let Z=Q.provisional;Z<Q.length;Z++){let X=Q[Z];if(X)X.#y()}}#y(){if(this.#W&U0)return;this.#W=(this.#W|U0)&J8,this.#x()}#x(){let Q=this.children();Q.provisional=0;for(let Z of Q)Z.#y()}#m(){this.#W|=y8,this.#N()}#N(){if(this.#W&H8)return;let Q=this.#W;if((Q&V0)===A0)Q&=J8;this.#W=Q|H8,this.#x()}#P(Q=""){if(Q==="ENOTDIR"||Q==="EPERM")this.#N();else if(Q==="ENOENT")this.#y();else this.children().provisional=0}#c(Q=""){if(Q==="ENOTDIR")this.parent.#N();else if(Q==="ENOENT")this.#y()}#u(Q=""){let Z=this.#W;if(Z|=D8,Q==="ENOENT")Z|=U0;if(Q==="EINVAL"||Q==="UNKNOWN")Z&=J8;if(this.#W=Z,Q==="ENOTDIR"&&this.parent)this.parent.#N()}#E(Q,Z){return this.#l(Q,Z)||this.#U(Q,Z)}#U(Q,Z){let X=Z7(Q),q=this.newChild(Q.name,X,{parent:this}),Y=q.#W&V0;if(Y!==A0&&Y!==x0&&Y!==K0)q.#W|=H8;return Z.unshift(q),Z.provisional++,q}#l(Q,Z){for(let X=Z.provisional;X<Z.length;X++){let q=Z[X];if((this.nocase?v8(Q.name):V8(Q.name))!==q.#z)continue;return this.#f(Q,q,X,Z)}}#f(Q,Z,X,q){let Y=Z.name;if(Z.#W=Z.#W&J8|Z7(Q),Y!==Q.name)Z.name=Q.name;if(X!==q.provisional){if(X===q.length-1)q.pop();else q.splice(X,1);q.unshift(Z)}return q.provisional++,Z}async lstat(){if((this.#W&U0)===0)try{return this.#D(await this.#Q.promises.lstat(this.fullpath())),this}catch(Q){this.#c(Q.code)}}lstatSync(){if((this.#W&U0)===0)try{return this.#D(this.#Q.lstatSync(this.fullpath())),this}catch(Q){this.#c(Q.code)}}#D(Q){let{atime:Z,atimeMs:X,birthtime:q,birthtimeMs:Y,blksize:J,blocks:H,ctime:W,ctimeMs:V,dev:K,gid:G,ino:_,mode:z,mtime:O,mtimeMs:$,nlink:A,rdev:U,size:B,uid:M}=Q;this.#A=Z,this.#Y=X,this.#j=q,this.#O=Y,this.#V=J,this.#G=H,this.#H=W,this.#B=V,this.#Z=K,this.#C=G,this.#_=_,this.#q=z,this.#F=O,this.#$=$,this.#X=A,this.#M=U,this.#K=B,this.#J=M;let R=Z7(Q);if(this.#W=this.#W&J8|R|HQ,R!==K0&&R!==A0&&R!==x0)this.#W|=H8}#h=[];#i=!1;#p(Q){this.#i=!1;let Z=this.#h.slice();this.#h.length=0,Z.forEach((X)=>X(null,Q))}readdirCB(Q,Z=!1){if(!this.canReaddir()){if(Z)Q(null,[]);else queueMicrotask(()=>Q(null,[]));return}let X=this.children();if(this.calledReaddir()){let Y=X.slice(0,X.provisional);if(Z)Q(null,Y);else queueMicrotask(()=>Q(null,Y));return}if(this.#h.push(Q),this.#i)return;this.#i=!0;let q=this.fullpath();this.#Q.readdir(q,{withFileTypes:!0},(Y,J)=>{if(Y)this.#P(Y.code),X.provisional=0;else{for(let H of J)this.#E(H,X);this.#g(X)}this.#p(X.slice(0,X.provisional));return})}#d;async readdir(){if(!this.canReaddir())return[];let Q=this.children();if(this.calledReaddir())return Q.slice(0,Q.provisional);let Z=this.fullpath();if(this.#d)await this.#d;else{let X=()=>{};this.#d=new Promise((q)=>X=q);try{for(let q of await this.#Q.promises.readdir(Z,{withFileTypes:!0}))this.#E(q,Q);this.#g(Q)}catch(q){this.#P(q.code),Q.provisional=0}this.#d=void 0,X()}return Q.slice(0,Q.provisional)}readdirSync(){if(!this.canReaddir())return[];let Q=this.children();if(this.calledReaddir())return Q.slice(0,Q.provisional);let Z=this.fullpath();try{for(let X of this.#Q.readdirSync(Z,{withFileTypes:!0}))this.#E(X,Q);this.#g(Q)}catch(X){this.#P(X.code),Q.provisional=0}return Q.slice(0,Q.provisional)}canReaddir(){if(this.#W&VQ)return!1;let Q=V0&this.#W;if(!(Q===K0||Q===A0||Q===x0))return!1;return!0}shouldWalk(Q,Z){return(this.#W&A0)===A0&&!(this.#W&VQ)&&!Q.has(this)&&(!Z||Z(this))}async realpath(){if(this.#k)return this.#k;if((y8|D8|U0)&this.#W)return;try{let Q=await this.#Q.promises.realpath(this.fullpath());return this.#k=this.resolve(Q)}catch(Q){this.#m()}}realpathSync(){if(this.#k)return this.#k;if((y8|D8|U0)&this.#W)return;try{let Q=this.#Q.realpathSync(this.fullpath());return this.#k=this.resolve(Q)}catch(Q){this.#m()}}[RQ](Q){if(Q===this)return;Q.isCWD=!1,this.isCWD=!0;let Z=new Set([]),X=[],q=this;while(q&&q.parent)Z.add(q),q.#I=X.join(this.sep),q.#b=X.join("/"),q=q.parent,X.push("..");q=Q;while(q&&q.parent&&!Z.has(q))q.#I=void 0,q.#b=void 0,q=q.parent}}class E8 extends X0{sep="\\";splitSep=b4;constructor(Q,Z=K0,X,q,Y,J,H){super(Q,Z,X,q,Y,J,H)}newChild(Q,Z=K0,X={}){return new E8(Q,Z,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Q){return X7.parse(Q).root}getRoot(Q){if(Q=P4(Q.toUpperCase()),Q===this.root.name)return this.root;for(let[Z,X]of Object.entries(this.roots))if(this.sameRoot(Q,Z))return this.roots[Q]=X;return this.roots[Q]=new K8(Q,this).root}sameRoot(Q,Z=this.root.name){return Q=Q.toUpperCase().replace(/\//g,"\\").replace(_Q,"$1\\"),Q===Z}}class x8 extends X0{splitSep="/";sep="/";constructor(Q,Z=K0,X,q,Y,J,H){super(Q,Z,X,q,Y,J,H)}getRootString(Q){return Q.startsWith("/")?"/":""}getRoot(Q){return this.root}newChild(Q,Z=K0,X={}){return new x8(Q,Z,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class Y7{root;rootPath;roots;cwd;#Q;#Z;#q;nocase;#X;constructor(Q=process.cwd(),Z,X,{nocase:q,childrenCacheSize:Y=16384,fs:J=W8}={}){if(this.#X=GQ(J),Q instanceof URL||Q.startsWith("file://"))Q=A4(Q);let H=Z.resolve(Q);this.roots=Object.create(null),this.rootPath=this.parseRootPath(H),this.#Q=new q7,this.#Z=new q7,this.#q=new BQ(Y);let W=H.substring(this.rootPath.length).split(X);if(W.length===1&&!W[0])W.pop();if(q===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=q,this.root=this.newRoot(this.#X),this.roots[this.rootPath]=this.root;let V=this.root,K=W.length-1,G=Z.sep,_=this.rootPath,z=!1;for(let O of W){let $=K--;V=V.child(O,{relative:Array($).fill("..").join(G),relativePosix:Array($).fill("..").join("/"),fullpath:_+=(z?"":G)+O}),z=!0}this.cwd=V}depth(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.depth()}childrenCache(){return this.#q}resolve(...Q){let Z="";for(let Y=Q.length-1;Y>=0;Y--){let J=Q[Y];if(!J||J===".")continue;if(Z=Z?`${J}/${Z}`:J,this.isAbsolute(J))break}let X=this.#Q.get(Z);if(X!==void 0)return X;let q=this.cwd.resolve(Z).fullpath();return this.#Q.set(Z,q),q}resolvePosix(...Q){let Z="";for(let Y=Q.length-1;Y>=0;Y--){let J=Q[Y];if(!J||J===".")continue;if(Z=Z?`${J}/${Z}`:J,this.isAbsolute(J))break}let X=this.#Z.get(Z);if(X!==void 0)return X;let q=this.cwd.resolve(Z).fullpathPosix();return this.#Z.set(Z,q),q}relative(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.relative()}relativePosix(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.relativePosix()}basename(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.name}dirname(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return(Q.parent||Q).fullpath()}async readdir(Q=this.cwd,Z={withFileTypes:!0}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X}=Z;if(!Q.canReaddir())return[];else{let q=await Q.readdir();return X?q:q.map((Y)=>Y.name)}}readdirSync(Q=this.cwd,Z={withFileTypes:!0}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0}=Z;if(!Q.canReaddir())return[];else if(X)return Q.readdirSync();else return Q.readdirSync().map((q)=>q.name)}async lstat(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.lstat()}lstatSync(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.lstatSync()}async readlink(Q=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q.withFileTypes,Q=this.cwd;let X=await Q.readlink();return Z?X:X?.fullpath()}readlinkSync(Q=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q.withFileTypes,Q=this.cwd;let X=Q.readlinkSync();return Z?X:X?.fullpath()}async realpath(Q=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q.withFileTypes,Q=this.cwd;let X=await Q.realpath();return Z?X:X?.fullpath()}realpathSync(Q=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q.withFileTypes,Q=this.cwd;let X=Q.realpathSync();return Z?X:X?.fullpath()}async walk(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z,H=[];if(!Y||Y(Q))H.push(X?Q:Q.fullpath());let W=new Set,V=(G,_)=>{W.add(G),G.readdirCB((z,O)=>{if(z)return _(z);let $=O.length;if(!$)return _();let A=()=>{if(--$===0)_()};for(let U of O){if(!Y||Y(U))H.push(X?U:U.fullpath());if(q&&U.isSymbolicLink())U.realpath().then((B)=>B?.isUnknown()?B.lstat():B).then((B)=>B?.shouldWalk(W,J)?V(B,A):A());else if(U.shouldWalk(W,J))V(U,A);else A()}},!0)},K=Q;return new Promise((G,_)=>{V(K,(z)=>{if(z)return _(z);G(H)})})}walkSync(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z,H=[];if(!Y||Y(Q))H.push(X?Q:Q.fullpath());let W=new Set([Q]);for(let V of W){let K=V.readdirSync();for(let G of K){if(!Y||Y(G))H.push(X?G:G.fullpath());let _=G;if(G.isSymbolicLink()){if(!(q&&(_=G.realpathSync())))continue;if(_.isUnknown())_.lstatSync()}if(_.shouldWalk(W,J))W.add(_)}}return H}[Symbol.asyncIterator](){return this.iterate()}iterate(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;return this.stream(Q,Z)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z;if(!Y||Y(Q))yield X?Q:Q.fullpath();let H=new Set([Q]);for(let W of H){let V=W.readdirSync();for(let K of V){if(!Y||Y(K))yield X?K:K.fullpath();let G=K;if(K.isSymbolicLink()){if(!(q&&(G=K.realpathSync())))continue;if(G.isUnknown())G.lstatSync()}if(G.shouldWalk(H,J))H.add(G)}}}stream(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z,H=new E0({objectMode:!0});if(!Y||Y(Q))H.write(X?Q:Q.fullpath());let W=new Set,V=[Q],K=0,G=()=>{let _=!1;while(!_){let z=V.shift();if(!z){if(K===0)H.end();return}K++,W.add(z);let O=(A,U,B=!1)=>{if(A)return H.emit("error",A);if(q&&!B){let M=[];for(let R of U)if(R.isSymbolicLink())M.push(R.realpath().then((F)=>F?.isUnknown()?F.lstat():F));if(M.length){Promise.all(M).then(()=>O(null,U,!0));return}}for(let M of U)if(M&&(!Y||Y(M))){if(!H.write(X?M:M.fullpath()))_=!0}K--;for(let M of U){let R=M.realpathCached()||M;if(R.shouldWalk(W,J))V.push(R)}if(_&&!H.flowing)H.once("drain",G);else if(!$)G()},$=!0;z.readdirCB(O,!0),$=!1}};return G(),H}streamSync(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof X0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z,H=new E0({objectMode:!0}),W=new Set;if(!Y||Y(Q))H.write(X?Q:Q.fullpath());let V=[Q],K=0,G=()=>{let _=!1;while(!_){let z=V.shift();if(!z){if(K===0)H.end();return}K++,W.add(z);let O=z.readdirSync();for(let $ of O)if(!Y||Y($)){if(!H.write(X?$:$.fullpath()))_=!0}K--;for(let $ of O){let A=$;if($.isSymbolicLink()){if(!(q&&(A=$.realpathSync())))continue;if(A.isUnknown())A.lstatSync()}if(A.shouldWalk(W,J))V.push(A)}}if(_&&!H.flowing)H.once("drain",G)};return G(),H}chdir(Q=this.cwd){let Z=this.cwd;this.cwd=typeof Q==="string"?this.cwd.resolve(Q):Q,this.cwd[RQ](Z)}}class K8 extends Y7{sep="\\";constructor(Q=process.cwd(),Z={}){let{nocase:X=!0}=Z;super(Q,X7,"\\",{...Z,nocase:X});this.nocase=X;for(let q=this.cwd;q;q=q.parent)q.nocase=this.nocase}parseRootPath(Q){return X7.parse(Q).root.toUpperCase()}newRoot(Q){return new E8(this.rootPath,A0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")||Q.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Q)}}class z8 extends Y7{sep="/";constructor(Q=process.cwd(),Z={}){let{nocase:X=!1}=Z;super(Q,O4,"/",{...Z,nocase:X});this.nocase=X}parseRootPath(Q){return"/"}newRoot(Q){return new x8(this.rootPath,A0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")}}class u8 extends z8{constructor(Q=process.cwd(),Z={}){let{nocase:X=!0}=Z;super(Q,{...Z,nocase:X})}}var YY=process.platform==="win32"?E8:x8,IQ=process.platform==="win32"?K8:process.platform==="darwin"?u8:z8;var D4=(Q)=>Q.length>=1,v4=(Q)=>Q.length>=1;class d0{#Q;#Z;#q;length;#X;#J;#C;#M;#V;#_;#K=!0;constructor(Q,Z,X,q){if(!D4(Q))throw TypeError("empty pattern list");if(!v4(Z))throw TypeError("empty glob list");if(Z.length!==Q.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=Q.length,X<0||X>=this.length)throw TypeError("index out of range");if(this.#Q=Q,this.#Z=Z,this.#q=X,this.#X=q,this.#q===0){if(this.isUNC()){let[Y,J,H,W,...V]=this.#Q,[K,G,_,z,...O]=this.#Z;if(V[0]==="")V.shift(),O.shift();let $=[Y,J,H,W,""].join("/"),A=[K,G,_,z,""].join("/");this.#Q=[$,...V],this.#Z=[A,...O],this.length=this.#Q.length}else if(this.isDrive()||this.isAbsolute()){let[Y,...J]=this.#Q,[H,...W]=this.#Z;if(J[0]==="")J.shift(),W.shift();let V=Y+"/",K=H+"/";this.#Q=[V,...J],this.#Z=[K,...W],this.length=this.#Q.length}}}pattern(){return this.#Q[this.#q]}isString(){return typeof this.#Q[this.#q]==="string"}isGlobstar(){return this.#Q[this.#q]===n}isRegExp(){return this.#Q[this.#q]instanceof RegExp}globString(){return this.#C=this.#C||(this.#q===0?this.isAbsolute()?this.#Z[0]+this.#Z.slice(1).join("/"):this.#Z.join("/"):this.#Z.slice(this.#q).join("/"))}hasMore(){return this.length>this.#q+1}rest(){if(this.#J!==void 0)return this.#J;if(!this.hasMore())return this.#J=null;return this.#J=new d0(this.#Q,this.#Z,this.#q+1,this.#X),this.#J.#_=this.#_,this.#J.#V=this.#V,this.#J.#M=this.#M,this.#J}isUNC(){let Q=this.#Q;return this.#V!==void 0?this.#V:this.#V=this.#X==="win32"&&this.#q===0&&Q[0]===""&&Q[1]===""&&typeof Q[2]==="string"&&!!Q[2]&&typeof Q[3]==="string"&&!!Q[3]}isDrive(){let Q=this.#Q;return this.#M!==void 0?this.#M:this.#M=this.#X==="win32"&&this.#q===0&&this.length>1&&typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0])}isAbsolute(){let Q=this.#Q;return this.#_!==void 0?this.#_:this.#_=Q[0]===""&&Q.length>1||this.isDrive()||this.isUNC()}root(){let Q=this.#Q[0];return typeof Q==="string"&&this.isAbsolute()&&this.#q===0?Q:""}checkFollowGlobstar(){return!(this.#q===0||!this.isGlobstar()||!this.#K)}markFollowGlobstar(){if(this.#q===0||!this.isGlobstar()||!this.#K)return!1;return this.#K=!1,!0}}var y4=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class G8{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Q,{nobrace:Z,nocase:X,noext:q,noglobstar:Y,platform:J=y4}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=J,this.mmopts={dot:!0,nobrace:Z,nocase:X,noext:q,noglobstar:Y,optimizationLevel:2,platform:J,nocomment:!0,nonegate:!0};for(let H of Q)this.add(H)}add(Q){let Z=new H0(Q,this.mmopts);for(let X=0;X<Z.set.length;X++){let q=Z.set[X],Y=Z.globParts[X];if(!q||!Y)throw Error("invalid pattern object");while(q[0]==="."&&Y[0]===".")q.shift(),Y.shift();let J=new d0(q,Y,0,this.platform),H=new H0(J.globString(),this.mmopts),W=Y[Y.length-1]==="**",V=J.isAbsolute();if(V)this.absolute.push(H);else this.relative.push(H);if(W)if(V)this.absoluteChildren.push(H);else this.relativeChildren.push(H)}}ignored(Q){let Z=Q.fullpath(),X=`${Z}/`,q=Q.relative()||".",Y=`${q}/`;for(let J of this.relative)if(J.match(q)||J.match(Y))return!0;for(let J of this.absolute)if(J.match(Z)||J.match(X))return!0;return!1}childrenIgnored(Q){let Z=Q.fullpath()+"/",X=(Q.relative()||".")+"/";for(let q of this.relativeChildren)if(q.match(X))return!0;for(let q of this.absoluteChildren)if(q.match(Z))return!0;return!1}}class J7{store;constructor(Q=new Map){this.store=Q}copy(){return new J7(new Map(this.store))}hasWalked(Q,Z){return this.store.get(Q.fullpath())?.has(Z.globString())}storeWalked(Q,Z){let X=Q.fullpath(),q=this.store.get(X);if(q)q.add(Z.globString());else this.store.set(X,new Set([Z.globString()]))}}class CQ{store=new Map;add(Q,Z,X){let q=(Z?2:0)|(X?1:0),Y=this.store.get(Q);this.store.set(Q,Y===void 0?q:q&Y)}entries(){return[...this.store.entries()].map(([Q,Z])=>[Q,!!(Z&2),!!(Z&1)])}}class LQ{store=new Map;add(Q,Z){if(!Q.canReaddir())return;let X=this.store.get(Q);if(X){if(!X.find((q)=>q.globString()===Z.globString()))X.push(Z)}else this.store.set(Q,[Z])}get(Q){let Z=this.store.get(Q);if(!Z)throw Error("attempting to walk unknown path");return Z}entries(){return this.keys().map((Q)=>[Q,this.store.get(Q)])}keys(){return[...this.store.keys()].filter((Q)=>Q.canReaddir())}}class _8{hasWalkedCache;matches=new CQ;subwalks=new LQ;patterns;follow;dot;opts;constructor(Q,Z){this.opts=Q,this.follow=!!Q.follow,this.dot=!!Q.dot,this.hasWalkedCache=Z?Z.copy():new J7}processPatterns(Q,Z){this.patterns=Z;let X=Z.map((q)=>[Q,q]);for(let[q,Y]of X){this.hasWalkedCache.storeWalked(q,Y);let J=Y.root(),H=Y.isAbsolute()&&this.opts.absolute!==!1;if(J){q=q.resolve(J==="/"&&this.opts.root!==void 0?this.opts.root:J);let G=Y.rest();if(!G){this.matches.add(q,!0,!1);continue}else Y=G}if(q.isENOENT())continue;let W,V,K=!1;while(typeof(W=Y.pattern())==="string"&&(V=Y.rest()))q=q.resolve(W),Y=V,K=!0;if(W=Y.pattern(),V=Y.rest(),K){if(this.hasWalkedCache.hasWalked(q,Y))continue;this.hasWalkedCache.storeWalked(q,Y)}if(typeof W==="string"){let G=W===".."||W===""||W===".";this.matches.add(q.resolve(W),H,G);continue}else if(W===n){if(!q.isSymbolicLink()||this.follow||Y.checkFollowGlobstar())this.subwalks.add(q,Y);let G=V?.pattern(),_=V?.rest();if(!V||(G===""||G===".")&&!_)this.matches.add(q,H,G===""||G===".");else if(G===".."){let z=q.parent||q;if(!_)this.matches.add(z,H,!0);else if(!this.hasWalkedCache.hasWalked(z,_))this.subwalks.add(z,_)}}else if(W instanceof RegExp)this.subwalks.add(q,Y)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new _8(this.opts,this.hasWalkedCache)}filterEntries(Q,Z){let X=this.subwalks.get(Q),q=this.child();for(let Y of Z)for(let J of X){let H=J.isAbsolute(),W=J.pattern(),V=J.rest();if(W===n)q.testGlobstar(Y,J,V,H);else if(W instanceof RegExp)q.testRegExp(Y,W,V,H);else q.testString(Y,W,V,H)}return q}testGlobstar(Q,Z,X,q){if(this.dot||!Q.name.startsWith(".")){if(!Z.hasMore())this.matches.add(Q,q,!1);if(Q.canReaddir()){if(this.follow||!Q.isSymbolicLink())this.subwalks.add(Q,Z);else if(Q.isSymbolicLink()){if(X&&Z.checkFollowGlobstar())this.subwalks.add(Q,X);else if(Z.markFollowGlobstar())this.subwalks.add(Q,Z)}}}if(X){let Y=X.pattern();if(typeof Y==="string"&&Y!==".."&&Y!==""&&Y!==".")this.testString(Q,Y,X.rest(),q);else if(Y===".."){let J=Q.parent||Q;this.subwalks.add(J,X)}else if(Y instanceof RegExp)this.testRegExp(Q,Y,X.rest(),q)}}testRegExp(Q,Z,X,q){if(!Z.test(Q.name))return;if(!X)this.matches.add(Q,q,!1);else this.subwalks.add(Q,X)}testString(Q,Z,X,q){if(!Q.isNamed(Z))return;if(!X)this.matches.add(Q,q,!1);else this.subwalks.add(Q,X)}}var E4=(Q,Z)=>typeof Q==="string"?new G8([Q],Z):Array.isArray(Q)?new G8(Q,Z):Q;class W7{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Q=[];#Z;#q;signal;maxDepth;includeChildMatches;constructor(Q,Z,X){if(this.patterns=Q,this.path=Z,this.opts=X,this.#q=!X.posix&&X.platform==="win32"?"\\":"/",this.includeChildMatches=X.includeChildMatches!==!1,X.ignore||!this.includeChildMatches){if(this.#Z=E4(X.ignore??[],X),!this.includeChildMatches&&typeof this.#Z.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=X.maxDepth||1/0,X.signal)this.signal=X.signal,this.signal.addEventListener("abort",()=>{this.#Q.length=0})}#X(Q){return this.seen.has(Q)||!!this.#Z?.ignored?.(Q)}#J(Q){return!!this.#Z?.childrenIgnored?.(Q)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let Q=void 0;while(!this.paused&&(Q=this.#Q.shift()))Q()}onResume(Q){if(this.signal?.aborted)return;if(!this.paused)Q();else this.#Q.push(Q)}async matchCheck(Q,Z){if(Z&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Q.realpathCached()||await Q.realpath(),!X)return;Q=X}let Y=Q.isUnknown()||this.opts.stat?await Q.lstat():Q;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let J=await Y.realpath();if(J&&(J.isUnknown()||this.opts.stat))await J.lstat()}return this.matchCheckTest(Y,Z)}matchCheckTest(Q,Z){return Q&&(this.maxDepth===1/0||Q.depth()<=this.maxDepth)&&(!Z||Q.canReaddir())&&(!this.opts.nodir||!Q.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!Q.isSymbolicLink()||!Q.realpathCached()?.isDirectory())&&!this.#X(Q)?Q:void 0}matchCheckSync(Q,Z){if(Z&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Q.realpathCached()||Q.realpathSync(),!X)return;Q=X}let Y=Q.isUnknown()||this.opts.stat?Q.lstatSync():Q;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let J=Y.realpathSync();if(J&&(J?.isUnknown()||this.opts.stat))J.lstatSync()}return this.matchCheckTest(Y,Z)}matchFinish(Q,Z){if(this.#X(Q))return;if(!this.includeChildMatches&&this.#Z?.add){let Y=`${Q.relativePosix()}/**`;this.#Z.add(Y)}let X=this.opts.absolute===void 0?Z:this.opts.absolute;this.seen.add(Q);let q=this.opts.mark&&Q.isDirectory()?this.#q:"";if(this.opts.withFileTypes)this.matchEmit(Q);else if(X){let Y=this.opts.posix?Q.fullpathPosix():Q.fullpath();this.matchEmit(Y+q)}else{let Y=this.opts.posix?Q.relativePosix():Q.relative(),J=this.opts.dotRelative&&!Y.startsWith(".."+this.#q)?"."+this.#q:"";this.matchEmit(!Y?"."+q:J+Y+q)}}async match(Q,Z,X){let q=await this.matchCheck(Q,X);if(q)this.matchFinish(q,Z)}matchSync(Q,Z,X){let q=this.matchCheckSync(Q,X);if(q)this.matchFinish(q,Z)}walkCB(Q,Z,X){if(this.signal?.aborted)X();this.walkCB2(Q,Z,new _8(this.opts),X)}walkCB2(Q,Z,X,q){if(this.#J(Q))return q();if(this.signal?.aborted)q();if(this.paused){this.onResume(()=>this.walkCB2(Q,Z,X,q));return}X.processPatterns(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#X(H))continue;Y++,this.match(H,W,V).then(()=>J())}for(let H of X.subwalkTargets()){if(this.maxDepth!==1/0&&H.depth()>=this.maxDepth)continue;Y++;let W=H.readdirCached();if(H.calledReaddir())this.walkCB3(H,W,X,J);else H.readdirCB((V,K)=>this.walkCB3(H,K,X,J),!0)}J()}walkCB3(Q,Z,X,q){X=X.filterEntries(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#X(H))continue;Y++,this.match(H,W,V).then(()=>J())}for(let[H,W]of X.subwalks.entries())Y++,this.walkCB2(H,W,X.child(),J);J()}walkCBSync(Q,Z,X){if(this.signal?.aborted)X();this.walkCB2Sync(Q,Z,new _8(this.opts),X)}walkCB2Sync(Q,Z,X,q){if(this.#J(Q))return q();if(this.signal?.aborted)q();if(this.paused){this.onResume(()=>this.walkCB2Sync(Q,Z,X,q));return}X.processPatterns(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#X(H))continue;this.matchSync(H,W,V)}for(let H of X.subwalkTargets()){if(this.maxDepth!==1/0&&H.depth()>=this.maxDepth)continue;Y++;let W=H.readdirSync();this.walkCB3Sync(H,W,X,J)}J()}walkCB3Sync(Q,Z,X,q){X=X.filterEntries(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#X(H))continue;this.matchSync(H,W,V)}for(let[H,W]of X.subwalks.entries())Y++,this.walkCB2Sync(H,W,X.child(),J);J()}}class f8 extends W7{matches=new Set;constructor(Q,Z,X){super(Q,Z,X)}matchEmit(Q){this.matches.add(Q)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise((Q,Z)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)Z(this.signal.reason);else Q(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class h8 extends W7{results;constructor(Q,Z,X){super(Q,Z,X);this.results=new E0({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(Q){if(this.results.write(Q),!this.results.flowing)this.pause()}stream(){let Q=this.path;if(Q.isUnknown())Q.lstat().then(()=>{this.walkCB(Q,this.patterns,()=>this.results.end())});else this.walkCB(Q,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var u4=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class B0{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(Q,Z){if(!Z)throw TypeError("glob options required");if(this.withFileTypes=!!Z.withFileTypes,this.signal=Z.signal,this.follow=!!Z.follow,this.dot=!!Z.dot,this.dotRelative=!!Z.dotRelative,this.nodir=!!Z.nodir,this.mark=!!Z.mark,!Z.cwd)this.cwd="";else if(Z.cwd instanceof URL||Z.cwd.startsWith("file://"))Z.cwd=x4(Z.cwd);if(this.cwd=Z.cwd||"",this.root=Z.root,this.magicalBraces=!!Z.magicalBraces,this.nobrace=!!Z.nobrace,this.noext=!!Z.noext,this.realpath=!!Z.realpath,this.absolute=Z.absolute,this.includeChildMatches=Z.includeChildMatches!==!1,this.noglobstar=!!Z.noglobstar,this.matchBase=!!Z.matchBase,this.maxDepth=typeof Z.maxDepth==="number"?Z.maxDepth:1/0,this.stat=!!Z.stat,this.ignore=Z.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error("cannot set absolute and withFileTypes:true");if(typeof Q==="string")Q=[Q];if(this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z.allowWindowsEscape===!1,this.windowsPathsNoEscape)Q=Q.map((W)=>W.replace(/\\/g,"/"));if(this.matchBase){if(Z.noglobstar)throw TypeError("base matching requires globstar");Q=Q.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=Q,this.platform=Z.platform||u4,this.opts={...Z,platform:this.platform},Z.scurry){if(this.scurry=Z.scurry,Z.nocase!==void 0&&Z.nocase!==Z.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let W=Z.platform==="win32"?K8:Z.platform==="darwin"?u8:Z.platform?z8:IQ;this.scurry=new W(this.cwd,{nocase:Z.nocase,fs:Z.fs})}this.nocase=this.scurry.nocase;let X=this.platform==="darwin"||this.platform==="win32",q={...Z,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:X,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},Y=this.pattern.map((W)=>new H0(W,q)),[J,H]=Y.reduce((W,V)=>{return W[0].push(...V.set),W[1].push(...V.globParts),W},[[],[]]);this.patterns=J.map((W,V)=>{let K=H[V];if(!K)throw Error("invalid pattern object");return new d0(W,K,0,this.platform)})}async walk(){return[...await new f8(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 f8(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 h8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new h8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var H7=(Q,Z={})=>{if(!Array.isArray(Q))Q=[Q];for(let X of Q)if(new H0(X,Z).hasMagic())return!0;return!1};function g8(Q,Z={}){return new B0(Q,Z).streamSync()}function TQ(Q,Z={}){return new B0(Q,Z).stream()}function m8(Q,Z={}){return new B0(Q,Z).walkSync()}async function FQ(Q,Z={}){return new B0(Q,Z).walk()}function c8(Q,Z={}){return new B0(Q,Z).iterateSync()}function SQ(Q,Z={}){return new B0(Q,Z).iterate()}var f4=g8,h4=Object.assign(TQ,{sync:g8}),g4=c8,m4=Object.assign(SQ,{sync:c8}),c4=Object.assign(m8,{stream:g8,iterate:c8}),jQ=Object.assign(FQ,{glob:FQ,globSync:m8,sync:c4,globStream:TQ,stream:h4,globStreamSync:g8,streamSync:f4,globIterate:SQ,iterate:m4,globIterateSync:c8,iterateSync:g4,Glob:B0,hasMagic:H7,escape:h0,unescape:G0});jQ.glob=jQ;import l4 from"node:path";var wQ=({dir:Q,pattern:Z="*",nodir:X=!1,dot:q=!0,ignore:Y=[],absolute:J=!1,matchBase:H=!1,follow:W=!1})=>{if(Q=Q||process.cwd(),Q=l4.resolve(Q),Z&&!Array.isArray(Z))Z=[Z];else Z=Z||["*"];if(Y&&!Array.isArray(Y))Y=[Y];else Y=Y||[];return m8(Z,{cwd:Q,nodir:X,dot:q,ignore:Y,absolute:J,matchBase:H,follow:W})};import NQ from"lodash.clonedeep";import d4 from"@fnet/key-value-transformer";async function m({node:Q,initNode:Z,extra:X=!0}){if(Reflect.has(Q.definition,"modules")&&!Array.isArray(Q.definition.modules)){let q=Q.definition.modules;Q.definition.modules=[],Object.keys(q).forEach((Y)=>{let J={...q[Y]};if(typeof J.export==="boolean")J.export=J.export===!0?Y:!1;else if(typeof J.export==="string")J.export=J.export;else delete J.export;Q.definition.modules.push({[Y]:J})})}if(X){let q=[],Y=await d4({data:Q.definition,callback:(J,H,W)=>{let V=w0(J,!0);if(V?.processor==="m"){let K=W.slice(0,-1);K.push(V.statement);let G=K.join("_");return q.push({[G]:H}),[V.statement,`m::${G}`]}return[J,H]}});if(q.length>0)Q.definition=Y,Q.definition.modules=Q.definition.modules||[],Q.definition.modules=Q.definition.modules.concat(q)}Q.hasModules=Q.definition.modules?.length>0;for(let q=0;q<Q.definition.modules?.length;q++){let Y=Q.definition.modules[q],J=Object.keys(Y)[0],H={name:J,childs:[],parent:Q,definition:Y[J],module:!0,block_child_auto_jump_to_parent:!0,index:Q.childs.length,context:{}};Q.childs.push(H),await Z({node:H})}}async function b({node:Q,transformExpression:Z}){let X=Q.context.transform;if(Reflect.has(X,"export"))X.export=await Z(X.export);if(Reflect.has(X,"return"))Q.hasReturn=!0,X.return=await Z(X.return);if(Reflect.has(X,"output"))X.output=await Z(X.output);if(Reflect.has(X,"assign"))for(let q=0;q<X.assign?.length;q++){let Y=X.assign[q];if(Object.keys(Y).length===0){X.assign.splice(q,1),q--;continue}let J=Object.keys(Y)[0],H=Y[J],W={key:await Z(J),value:await Z(H)};X.assign[q]=W}if(Reflect.has(X,"result")){if(typeof X.result==="string")X.result=[{[X.result]:"e::result"}];for(let q=0;q<X.result?.length;q++){let Y=X.result[q],J=Object.keys(Y)[0],H=Y[J],W={key:await Z(J),value:await Z(H)};X.result[q]=W}}}async function i4({node:Q}){if(!Q.definition.hasOwnProperty("switch"))return!1;return!0}async function p4({node:Q,initNode:Z}){Q.type="switch";let X=Q.definition.switch||[];if(!X.every((H)=>H.hasOwnProperty("condition")||H.hasOwnProperty("default")))throw Error("Switch must have condition or default");if(X.filter((H)=>H.hasOwnProperty("condition")).length===0)throw Error("Switch must have at least one condition");let J=X.filter((H)=>H.hasOwnProperty("default"));if(J.length>1)throw Error("Switch must have only one default");if(J.length===1&&!X[X.length-1].hasOwnProperty("default"))throw Error("Switch default must be the last child");Q.hasDefaultCondition=J.length===1,await m({node:Q,initNode:Z,extra:!1}),Q.block_child_auto_jump_to_sibling=!0;for(let H=0;H<Q.definition.switch.length;H++){let W=Q.definition.switch[H],V=`${H}`;if(W.hasOwnProperty("default"))V="default",W=W.default;let K={name:W.condition||V,childs:[],parent:Q,definition:W,index:Q.childs.length,context:{}};Q.childs.push(K),await Z({node:K})}Q.resolve=PQ}async function PQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||NQ(Q.definition);let Y=Q.context.transform;for(let J of Q.childs)if(J.context.transform=J.context.transform||NQ(J.definition),J.definition.hasOwnProperty("condition"))J.context.transform.condition=await q(J.definition.condition);if(await b({node:Q,transformExpression:q}),await Z({node:Q}),!Q.hasDefaultCondition)X({node:Q})}var U8={hits:i4,init:p4,resolve:PQ};async function a4({node:Q}){if(Object.keys(Q.definition).filter((q)=>w0(q)==="if").length===1)return!0;if(Q.definition.if&&typeof Q.definition.if==="object")return!0;return!1}async function n4(Q){let{node:Z}=Q,X=Object.keys(Z.definition),q=[],Y=X.find((W)=>w0(W)==="if");if(Y){let W=Z.definition[Y],V=w0(Y,!0);q.push({name:`${Z.name}_if`,definition:W,processor:{expression:Y,statement:V.statement,processor:V.processor}}),delete Z.definition[Y]}else if(Z.definition.if){let{condition:W,...V}=Z.definition.if;q.push({name:`${Z.name}_if`,definition:V,processor:{expression:`if::${W}`,statement:W}}),delete Z.definition.if}let J=X.filter((W)=>w0(W)==="elseif"),H=0;for(let W of J){let V=Z.definition[W],K=w0(W,!0);q.push({name:`${Z.name}_elseif_${H++}`,definition:V,processor:{expression:W,statement:K.statement,processor:K.processor}}),delete Z.definition[W]}if(Z.definition.elseif){let{condition:W,...V}=Z.definition.elseif;q.push({name:`${Z.name}_elseif_${H++}`,definition:V,processor:{expression:`elseif::${W}`,statement:W}}),delete Z.definition.elseif}Z.definition.switch=[];for(let W of q)Z.definition.switch.push({condition:W.processor.statement,...W.definition});if(Z.definition?.else){let W=Z.definition.else;Z.definition.switch.push({default:W}),delete Z.definition.else}await U8.init(Q)}var V7={hits:a4,init:n4};import bQ from"lodash.clonedeep";async function r4({node:Q}){return Q.definition.hasOwnProperty("try")&&Q.definition.hasOwnProperty("except")}async function s4({node:Q,initNode:Z}){if(Q.type="tryexcept",await m({node:Q,initNode:Z,extra:!1}),Q.block_child_auto_jump_to_sibling=!0,Q.definition.try){let q={name:"try",childs:[],parent:Q,definition:Q.definition.try,index:Q.childs.length,context:{}};Q.childs.push(q),await Z({node:q})}if(Q.definition.except){let q={name:"except",childs:[],parent:Q,definition:Q.definition.except,index:Q.childs.length,context:{}};Q.childs.push(q),await Z({node:q})}Q.resolve=kQ}async function kQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||bQ(Q.definition);let Y=Q.context.transform;if(Q.context.try=Q.childs.find((J)=>J.name==="try"),Q.context.except=Q.childs.find((J)=>J.name==="except"),Q.context.except){let J=Q.context.except;if(J.context.transform=J.context.transform||bQ(J.definition),!J.context.transform.hasOwnProperty("as"))J.context.transform.as="error"}await b({node:Q,transformExpression:q}),await Z({node:Q})}var K7={hits:r4,init:s4,resolve:kQ};import o4 from"lodash.clonedeep";async function t4({node:Q}){return Q.definition.hasOwnProperty("assign")}async function e4({node:Q,initNode:Z}){Q.type="assign",await m({node:Q,initNode:Z}),Q.resolve=DQ}async function DQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||o4(Q.definition);let Y=Q.context.transform;await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var z7={hits:t4,init:e4,resolve:DQ};import Q1 from"lodash.clonedeep";async function Z1({node:Q}){return Q.definition.hasOwnProperty("for")}async function X1({node:Q,initNode:Z}){if(Q.type="for",await m({node:Q,initNode:Z,extra:!1}),Q.block_child_auto_jump_to_parent=!0,Q.block_child_auto_jump_to_sibling=!1,!Q.definition.for.hasOwnProperty("steps")){let{as:X,in:q,...Y}=Q.definition.for,J={};if(X!==void 0)J.as=X;if(q!==void 0)J.in=q;Q.definition.for=J,Q.definition.for.steps=[{[`${Q.name}_step`]:Y}]}if(!Array.isArray(Q.definition.for.steps))Q.definition.for.steps=[{[`${Q.name}_step`]:Q.definition.for.steps}];for(let X=0;X<Q.definition.for.steps.length;X++){let q=Q.definition.for.steps[X],Y=Object.keys(q)[0],J={name:Y,childs:[],parent:Q,definition:q[Y],index:Q.childs.length,context:{}};Q.childs.push(J),await Z({node:J})}Q.resolve=vQ}async function vQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||Q1(Q.definition);let Y=Q.context.transform;Y.for.in=await q(Q.definition.for.in),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var G7={hits:Z1,init:X1,resolve:vQ};import q1 from"lodash.clonedeep";async function Y1({node:Q}){return Q.definition.hasOwnProperty("parallel")}async function J1({node:Q,initNode:Z}){Q.type="parallel",Q.block_child_auto_jump_to_parent=!0,Q.block_child_auto_jump_to_sibling=!0;let X=Q.definition.parallel||[];for await(let q of X){let Y=Object.keys(q)[0],J={name:Y,childs:[],parent:Q,definition:q[Y],index:Q.childs.length,context:{}};Q.childs.push(J),await Z({node:J})}Q.resolve=yQ}async function yQ({node:Q,transformExpression:Z,resolveNextBlock:X}){Q.context.transform=Q.context.transform||q1(Q.definition),await b({node:Q,transformExpression:Z}),X({node:Q})}var _7={hits:Y1,init:J1,resolve:yQ};import W1 from"lodash.clonedeep";async function H1({node:Q}){return Q.definition.hasOwnProperty("raise")}async function V1({node:Q,initNode:Z}){Q.type="raise",Q.resolve=EQ}async function EQ({node:Q,resolveTypeCommon:Z,transformExpression:X}){Q.context.transform=Q.context.transform||W1(Q.definition);let q=Q.context.transform;q.raise=await X(q.raise),await Z({node:Q})}var U7={hits:H1,init:V1,resolve:EQ};import K1 from"lodash.clonedeep";async function z1({node:Q}){return Q.definition.hasOwnProperty("return")}async function G1({node:Q,initNode:Z}){Q.type="return",Q.resolve=xQ}async function xQ({node:Q,resolveTypeCommon:Z,transformExpression:X}){Q.context.transform=Q.context.transform||K1(Q.definition);let q=Q.context.transform;Q.hasReturn=!0,q.return=await X(q.return),await Z({node:Q})}var $7={hits:z1,init:G1,resolve:xQ};import _1 from"lodash.clonedeep";async function U1({node:Q}){return Q.definition.hasOwnProperty("call")}async function $1({node:Q,initNode:Z}){Q.type="call",await m({node:Q,initNode:Z}),Q.resolve=uQ}async function uQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||_1(Q.definition);let Y=Q.context.transform,J=Y.from||Y.import||Y.call;if(Q.target?.atom?.doc?.type==="function"){if(Reflect.has(Y,"from"))J=Y.from,Y.from=await q(Q.target.atom.name);else if(Reflect.has(Y,"import"))J=Y.import,Y.import=await q(Q.target.atom.name);else if(Reflect.has(Y,"call"))Y.call=await q(Q.target.atom.name),J=Y.call}else if(Reflect.has(Y,"from")||Reflect.has(Y,"import")){if(Y.call.startsWith("use:e::")){let W=Y.call.substring(7);Y.libExp=await q(`e::LIBRARY.${W}`)}}if(Y.args)Y.args=await q(Y.args);if(Y.new)Y.new=await q(Y.new);if(Y.context)Y.context=await q(Y.context);let H=Q.workflow.parent;Q.context.lib=H.context.libs.find((W)=>W.name===J),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var $8={hits:U1,init:$1,resolve:uQ};import M1 from"lodash.clonedeep";async function O1({node:Q}){return Q.definition.hasOwnProperty("steps")}async function A1({node:Q,initNode:Z}){if(!Q.type)Q.type="steps";let X=Q.definition.steps||[];for await(let q of X){let Y=Object.keys(q)[0];if(q[Y].enabled===!1)continue;let J={name:Y,childs:[],parent:Q,definition:q[Y],index:Q.childs.length,context:{}};Q.childs.push(J),await Z({node:J})}Q.resolve=fQ}async function fQ({node:Q,transformExpression:Z}){Q.context.next=Q.childs[0],Q.context.transform=Q.context.transform||M1(Q.definition),await b({node:Q,transformExpression:Z})}var M7={hits:O1,init:A1,resolve:fQ};import B1 from"lodash.clonedeep";async function R1({node:Q}){return Q.definition.hasOwnProperty("form")}async function I1({node:Q,initNode:Z}){Q.type="form",await m({node:Q,initNode:Z}),Q.resolve=hQ}async function hQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||B1(Q.definition);let Y=Q.context.transform;if(Y.props)Y.props=await q(Y.props);let J=Q.workflow.parent;Q.context.lib=J.context.libs.find((H)=>H.name===Y.form),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var O7={hits:R1,init:I1,resolve:hQ};import C1 from"lodash.clonedeep";async function L1({node:Q}){return Q.definition.hasOwnProperty("signal")}async function F1({node:Q,initNode:Z}){Q.type="signal",Q.resolve=gQ}async function gQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q,transformValue:Y}){Q.context.transform=Q.context.transform||C1(Q.definition),await Z({node:Q}),X({node:Q})}var A7={hits:L1,init:F1,resolve:gQ};import j1 from"lodash.clonedeep";async function T1({node:Q}){return Q.definition.hasOwnProperty("wait")}async function S1({node:Q,initNode:Z}){Q.type="wait",Q.resolve=mQ}async function mQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q,transformValue:Y}){Q.context.transform=Q.context.transform||j1(Q.definition),await Z({node:Q}),X({node:Q})}var B7={hits:T1,init:S1,resolve:mQ};import w1 from"lodash.clonedeep";async function N1({node:Q}){return Q.definition.hasOwnProperty("next")}async function P1({node:Q,initNode:Z}){Q.type="next",Q.resolve=cQ}async function cQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||w1(Q.definition);let Y=Q.context.transform;Y.next=await q(Y.next),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var R7={hits:N1,init:P1,resolve:cQ};import b1 from"lodash.clonedeep";async function k1({node:Q}){return Q.definition.hasOwnProperty("modules")}async function D1({node:Q,initNode:Z}){Q.type="modules",await m({node:Q,initNode:Z}),Q.resolve=lQ}async function lQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||b1(Q.definition);let Y=Q.context.transform;await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var I7={hits:k1,init:D1,resolve:lQ};function C7({node:Q}){let Z=Q.definition;if(Q.hasReturn){if(j("tree"))f.info(`[RETURN] no next: ${Q.indexKey}`);return}if(Z.next==="end"){if(j("tree"))f.info(`[EXPLICIT-END] ${Q.indexKey}`)}else if(Z.next==="stop"){if(j("tree"))f.info(`[EXPLICIT-STOP] ${Q.indexKey}`)}else if(Z.next==="none"){if(j("tree"))f.info(`[EXPLICIT-NONE] ${Q.indexKey}`)}else if(Z.next){if(j("tree"))f.info(`[EXPLICIT-NEXT] "${Z.next}" from ${Q.indexKey}`);let X=Q.parent;while(X.parent){let q=X.childs.find((Y)=>Y.name===Z.next);if(q){if(Q.context.next=q,j("tree"))f.info(`[FOUND] ${q.indexKey}`);break}X=X.parent}if(!Q.context.next&&j("tree"))f.warn(` [NOT-FOUND] "${Z.next}"`)}else{if(Q.module===!0){if(j("tree"))f.info(`[MODULE-ROOT] no auto next: ${Q.indexKey}`);return}if(j("tree"))f.info(`[AUTO-NEXT] from ${Q.indexKey}`);let X=Q.parent,q=Q.index+1,Y=0;while(X.parent)if(Y++,X.block_child_auto_jump_to_parent&&X.block_child_auto_jump_to_sibling){if(j("tree"))f.info(`${Y}. [BLOCKED] both jumps disabled at ${X.indexKey}`);break}else if(!Reflect.has(X,"block_child_auto_jump_to_parent")&&!Reflect.has(X,"block_child_auto_jump_to_sibling")){let J=X.childs.find((H)=>H.index===q);if(J){if(Q.context.next=J,j("tree"))f.info(`${Y}. [SIBLING-FOUND] ${J.indexKey}`);break}else{if(j("tree"))f.info(`${Y}. [CLIMB] no sibling, climbing to parent: ${X.parent?.indexKey}`);q=X.index+1,X=X.parent;continue}}else if(X.block_child_auto_jump_to_parent){let J=X.childs.find((H)=>H.index===q);if(J){if(Q.context.next=J,j("tree"))f.info(`${Y}. [SIBLING-FOUND] parent jump disabled: ${J.indexKey}`)}else if(j("tree"))f.info(`${Y}. [BLOCKED] no sibling, parent jump disabled`);break}else if(!X.block_child_auto_jump_to_parent){if(j("tree"))f.info(`${Y}. [CLIMB] sibling disabled, climbing to parent: ${X.parent?.indexKey}`);q=X.index+1,X=X.parent;continue}if(Q.context.next&&j("tree"))f.info(`[RESOLVED] auto next: ${Q.context.next.indexKey} (${Y} steps)`);else if(j("tree"))f.info(`[NO-NEXT] end of flow (${Y} steps)`)}}class dQ{#Q;#Z;#q;#X;constructor({key:Q,npm:Z,master:X,extras:q}){this.#Q=Q,this.#Z=Z,this.#q=X,this.#X=q}hits({node:Q}){return Q.definition.hasOwnProperty(this.#Q)}async init(Q){let{node:Z}=Q,X=this.#Q,q=Z.definition,Y=typeof q[X];if(q.call=`npm:${this.#Z}`,Y!=="object")q.args={...q.args,[`${this.#q}`]:q[X]};else q.args=q[X];if(delete q[X],this.#X)for(let J in this.#X)q[J]=this.#X[J];console.log(`[npm-block] ${this.#Q} --> ${this.#Z}`),await $8.init(Q)}}function r(Q){return new dQ(Q)}import v1 from"lodash.clonedeep";async function y1({node:Q}){return Q.definition.hasOwnProperty("new")}async function E1({node:Q,initNode:Z}){Q.type="new",await m({node:Q,initNode:Z}),Q.resolve=iQ}async function iQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||v1(Q.definition);let Y=Q.context.transform,J=Y.from||Y.import;if(Q.target?.atom?.doc?.type==="function"){if(Reflect.has(Y,"from"))J=Y.from,Y.from=await q(Q.target.atom.name);else if(Reflect.has(Y,"import"))J=Y.import,Y.import=await q(Q.target.atom.name)}if(Y.args)Y.args=await q(Y.args);if(Y.new)Y.new=await q(Y.new);let H=Q.workflow.parent;Q.context.lib=H.context.libs.find((W)=>W.name===J),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var L7={hits:y1,init:E1,resolve:iQ};import x1 from"lodash.clonedeep";async function u1({node:Q}){return Q.definition.hasOwnProperty("output")}async function f1({node:Q,initNode:Z}){Q.type="output",await m({node:Q,initNode:Z}),Q.resolve=pQ}async function pQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||x1(Q.definition),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var F7={hits:u1,init:f1,resolve:pQ};import h1 from"lodash.clonedeep";async function g1({node:Q}){return Q.definition.hasOwnProperty("pipeline")}async function m1({node:Q}){Q.type="pipeline";let Z=Q.definition.pipeline;if(!Z||typeof Z!=="string")throw Error(`Pipeline step '${Q.indexKey}' requires a binary name`);Q.definition.binaryName=Z,Q.resolve=aQ}async function aQ({node:Q,transformExpression:Z,resolveNextBlock:X}){Q.context.transform=Q.context.transform||h1(Q.definition);let q=Q.context.transform;if(q.input)q.input=await Z(q.input);if(q.args)q.args=await Z(q.args);if(q.env)q.env=await Z(q.env);if(q.cwd)q.cwd=await Z(q.cwd);await b({node:Q,transformExpression:Z}),X({node:Q})}var j7={hits:g1,init:m1,resolve:aQ};import c1 from"lodash.clonedeep";async function l1({node:Q}){return Q.definition.hasOwnProperty("retry")}async function d1({node:Q,initNode:Z}){Q.type="retry";let X=Q.definition.retry,q;if(typeof X==="number")q={attempts:X,delay:1000,backoff:"exponential",maxDelay:null};else if(typeof X==="object")q={attempts:X.attempts||3,delay:X.delay||1000,backoff:X.backoff||"exponential",maxDelay:X.maxDelay||null,on:X.on,onRetry:X.onRetry};else throw Error(`Retry step '${Q.name}' requires a number or object configuration`);if(!q.attempts||q.attempts<1)throw Error(`Retry step '${Q.name}' requires attempts >= 1`);let Y=["exponential","linear","fixed"];if(!Y.includes(q.backoff))throw Error(`Retry step '${Q.name}' has invalid backoff strategy '${q.backoff}'. Valid options: ${Y.join(", ")}`);Q.definition.retry=q;let{retry:J,...H}=Q.definition,W={name:`${Q.name}_retryable`,childs:[],parent:Q,definition:H,index:0,context:{}};Q.childs.push(W),await Z({node:W}),Q.resolve=nQ}async function nQ({node:Q,transformExpression:Z,resolveNextBlock:X}){Q.context.transform=Q.context.transform||c1(Q.definition);let q=Q.context.transform;if(q.retry.attempts&&typeof q.retry.attempts==="string")q.retry.attempts=await Z(q.retry.attempts);if(q.retry.delay&&typeof q.retry.delay==="string")q.retry.delay=await Z(q.retry.delay);if(q.retry.maxDelay&&typeof q.retry.maxDelay==="string")q.retry.maxDelay=await Z(q.retry.maxDelay);if(q.retry.onRetry)q.retry.onRetry=await Z(q.retry.onRetry);await b({node:Q,transformExpression:Z}),X({node:Q})}var T7={hits:l1,init:d1,resolve:nQ};import i1 from"lodash.clonedeep";async function p1({node:Q}){return Q.definition.hasOwnProperty("schedule")}async function a1({node:Q,initNode:Z}){Q.type="schedule";let X=Q.definition.schedule,q;if(typeof X==="string")q={cron:X,timezone:null,enabled:!0};else if(typeof X==="object")q={cron:X.cron,timezone:X.timezone||null,enabled:X.enabled!==!1};else throw Error(`Schedule step '${Q.name}' requires a cron expression string or object`);if(!q.cron||typeof q.cron!=="string")throw Error(`Schedule step '${Q.name}' requires a valid cron expression`);Q.definition.schedule=q;let{schedule:Y,...J}=Q.definition,H={name:`${Q.name}_scheduled`,childs:[],parent:Q,definition:J,index:0,context:{}};Q.childs.push(H),await Z({node:H}),Q.resolve=rQ}async function rQ({node:Q,transformExpression:Z,resolveNextBlock:X}){Q.context.transform=Q.context.transform||i1(Q.definition);let q=Q.context.transform;if(q.schedule){if(q.schedule.cron&&typeof q.schedule.cron==="string")q.schedule.cron=await Z(q.schedule.cron);if(q.schedule.timezone&&typeof q.schedule.timezone==="string")q.schedule.timezone=await Z(q.schedule.timezone)}await b({node:Q,transformExpression:Z}),X({node:Q})}var S7={hits:p1,init:a1,resolve:rQ};import n1 from"lodash.clonedeep";async function r1({node:Q}){return Q.definition.hasOwnProperty("http")}async function s1({node:Q,initNode:Z}){Q.type="http",await m({node:Q,initNode:Z});let X=Q.definition.http,q;if(typeof X==="string")q={url:X,method:"GET",headers:{},timeout:30000};else if(typeof X==="object"){if(q={url:X.url,method:X.method||"GET",headers:X.headers||{},body:X.body,params:X.params,timeout:X.timeout||30000},!q.url)throw Error(`HTTP step '${Q.name}' requires a url property`)}else throw Error(`HTTP step '${Q.name}' requires a string URL or object configuration`);let Y=["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"],J=q.method.toUpperCase();if(!Y.includes(J))throw Error(`HTTP step '${Q.name}' has invalid method '${q.method}'. Valid options: ${Y.join(", ")}`);if(q.method=J,q.timeout&&(typeof q.timeout!=="number"||q.timeout<=0))throw Error(`HTTP step '${Q.name}' timeout must be a positive number`);Q.definition.http=q,Q.resolve=o1}async function o1({node:Q,transformExpression:Z,resolveNextBlock:X}){Q.context.transform=Q.context.transform||n1(Q.definition);let q=Q.context.transform;if(q.http.url)q.http.url=await Z(q.http.url);if(q.http.headers)q.http.headers=await Z(q.http.headers);if(q.http.body)q.http.body=await Z(q.http.body);if(q.http.params)q.http.params=await Z(q.http.params);if(q.http.timeout)q.http.timeout=await Z(q.http.timeout);await b({node:Q,transformExpression:Z}),X({node:Q})}var w7={hits:r1,init:s1};var sQ=({path:Q})=>{if(!Q)throw Error("Path is required");let Z=/^@([^\/]+\/[^\/]+)(?:\/(.+))?$/,X=/^([^\/]+)(?:\/(.+))?$/,q;if(q=Q.match(Z))return{path:Q,package:"@"+q[1],subpath:q[2]||null};else if(q=Q.match(X))return{path:Q,package:q[1],subpath:q[2]||null};return null};import Y2 from"node:os";class ZZ{#Q;#Z;#q;#X;#J;#C;#M;#V;#_;#K;#G;#Y;#$;#B;#O;#A;#F;#H;#j;#z=[];constructor(Q){this.#Q=Q,this.#J=[],this.#C=[],this.#M={},this._expire_ttl=3600,this._expire_ttl_short=300,this.#z.push(r({key:"config",npm:"@fnet/config",master:"name"})),this.#z.push(r({key:"yaml",npm:"@fnet/yaml",master:"file"})),this.#z.push(r({key:"prompt",npm:"@fnet/prompt",master:"message"})),this.#z.push(r({key:"html-link",npm:"@flownet/lib-load-browser-link-url",master:"src"})),this.#z.push(r({key:"html-script",npm:"@flownet/lib-load-browser-script-url",master:"src"})),this.#z.push(r({key:"http-server",npm:"@fnet/node-express",master:"server_port"})),this.#z.push(r({key:"shell",npm:"@fnet/shell-flow",master:"commands"})),this.#z.push(r({key:"list-files",npm:"@fnet/list-files",master:"pattern"})),this.#z.push(r({key:"up-list-files",npm:"@fnet/up-list-files",master:"pattern"})),this.#z.push(r({key:"auto-conda-env",npm:"@fnet/auto-conda-env",master:"envDir"})),this.#z.push(r({key:"ollama-chat",npm:"@fnet/ollama-chat",master:"model"})),this.#z.push(r({key:"ai",npm:"@fnet/ai",master:"prompt",extras:{subtype:"flow"}})),this.#z.push(r({key:"invoke",npm:"@fnet/invoke",master:"method",extras:{}})),this.#z.push(r({key:"fetch",npm:"@fnet/fetch",master:"url",extras:{}})),this.#z.push(r({key:"filemap",npm:"@fnet/filemap",master:"target",extras:{}})),this.#H={packageDependencies:this.#J,packageDevDependencies:this.#C,setProgress:this.setProgress.bind(this),context:this.#Q,Atom:i0,registerToPackageManager:this.registerToPackageManager.bind(this)},this.#j={initNode:this.initNode.bind(this),cloneDeep:eQ,resolveTypeCommon:this.resolveTypeCommon.bind(this),resolveNextBlock:C7,transformExpression:this.transformExpression.bind(this),transformValue:this.transformValue.bind(this)}}async _cache_set(Q,Z,X){}async init(){this.#_=this.#Q.buildId||QZ(),this.#H.buildId=this.#_,this.#$=this.#Q.mode,this.#B=["all","deploy","build","file"].includes(this.#$),this.#O=["all","deploy","build"].includes(this.#$),this.#A=["all","deploy"].includes(this.#$),this.#F=this.#$==="bpmn"||this.#Q.bpmn===!0,this.#G=this.#Q.protocol,this.#K="BUILD:"+this.#_,this.#Y=(await Q2({optional:!0,name:"atom",dir:this.#Q.projectDir,tags:this.#Q.tags}))?.data;try{await this.setProgress({message:"Initialization started."});let Q=this.#H.context.project;await this.initWorkflow(),this.transformWorkflow({workflow:this.#q});let Z=await this.initNodeTree({workflow:this.#q});if(await this.initNodeTreeIndex({root:Z}),await this.initNodeCalls({root:Z}),await this.initNodeCallLibs({root:Z}),await this.initNodeForms({root:Z}),await this.initNodeFormLibs({root:Z}),await this.initEntryFiles({root:Z,features:this.#Z.doc.features}),await this.initFeaturesFromNodes({childs:Z.childs,features:this.#Z.doc.features}),await O6(this.#H),Q.runtime.type==="bun")await B6(this.#H);else await A6(this.#H);await this.initAtomLibsAndDeps({libs:Z.context.libs,packageDependencies:this.#J}),await this.resolveNodeTree({root:Z}),this.#V=Z}catch(Q){throw await this._cache_set(this.#K,{status:"FAILED",message:Q?.message||Q}),Q}}async initWorkflow(){this.#Z=this.#Q.project.workflowAtom,this.#q=typeof this.#Z.doc.content==="string"?(await X2({content:this.#Z.doc.content,tags:this.#Q.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.#H.atom=this.#Z,this.#Z.doc.features=this.#Z.doc.features||{}}#L(Q){if(console.log("filePath",Q),T.statSync(Q).isDirectory())T.readdirSync(Q).forEach((Z)=>{let X=k.join(Q,Z);this.#L(X)}),T.rmSync(Q);else T.unlinkSync(Q)}#R(Q,Z){let X=T.existsSync(Q),q=X&&T.statSync(Q);if(X&&q.isDirectory())T.mkdirSync(Z,{recursive:!0}),T.readdirSync(Q).forEach((J)=>{this.#R(k.join(Q,J),k.join(Z,J))});else T.copyFileSync(Q,Z)}async initWorkflowDir(){this.setProgress({message:"Initializing library directory."});let Q=this.#Q.projectDir,Z=this.#Q.projectSrcDir,X=this.#Q.coreDir;this.setProgress({message:"Cleaning project directory."});let q=wQ({dir:Q,ignore:[".cache","node_modules",".conda",".bin",".dev"],absolute:!0});for(let V of q)T.rmSync(V,{recursive:!0,force:!0});if(this.setProgress({message:"Creating project directory."}),!T.existsSync(Q))T.mkdirSync(Q,{recursive:!0});let Y=k.join(Q,"src");if(!T.existsSync(Y))T.mkdirSync(Y,{recursive:!0});let J=k.join(Y,"core");this.#R(X,J);let H=k.join(Y,"default","blocks");if(!T.existsSync(H))T.mkdirSync(H,{recursive:!0});let W=k.join(Q,".dev");if(!T.existsSync(W))T.mkdirSync(W,{recursive:!0});if(this.#Z.doc.features?.symlinks===!0){if(W=this.#Q.projectSrcDirSymlink,!T.existsSync(W))try{if(Y2.platform()==="win32")T.symlinkSync(Z,W,"junction");else T.symlinkSync(Z,W,"dir")}catch(V){throw Error(`Couldn't create symlink. Error: ${V.message}`)}}}async initNunjucks(){this.setProgress({message:"Initializing nunjucks."});let Q=this.#Q.templateDir;this.#X=M8.configure(Q,{watch:!1,dev:!0}),this.#H.njEnv=this.#X}transformWorkflow({workflow:Q}){for(let Z of Object.values(Q))Z.steps=Z.steps||[],Z.steps=Z.steps.filter((X)=>Object.keys(X).length>0),Z.steps=Z.steps.map((X)=>this.transformStep({step:X}))}transformStep({step:Q}){if(Array.isArray(Q))throw Error("Step must be an object.");let[Z,X]=Object.entries(Q)[0];if(X.hasOwnProperty("onerror")){let{onerror:q,...Y}=X;Q[Z]={try:Y,except:q}}if(Q[Z].hasOwnProperty("steps")){let q=Q[Z].steps;if(!Array.isArray(q))throw Error("Steps must be an array.");Q[Z].steps=q.map((Y)=>this.transformStep({step:Y}))}return Q}async initNodeTree({workflow:Q}){let Z=["$meta","$project","$features","$input","$output","$commands"],X=Object.keys(Q).filter((Y)=>!Z.includes(Y));if(j("tree"))f.info("[TREE] Creating root node");let q={definition:Q,name:void 0,type:"root",parent:void 0,childs:[],block_child_auto_jump_to_parent:!0,block_child_auto_jump_to_sibling:!0,index:0,depth:0,context:{libs:[],atom:this.#Z}};X.forEach((Y)=>{if(j("tree"))f.info(`[TREE] Creating ${Y==="main"?"workflow":"subworkflow"}: ${Y}`);let J={name:Y,type:Y==="main"?"workflow":"subworkflow",enabled:Q[Y].enabled!==!1,childs:[],parent:q,definition:Q[Y],index:q.childs.length,depth:q.depth+1,context:{},block_child_auto_jump_to_parent:!0};q.childs.push(J)});for(let Y=0;Y<q.childs.length;Y++){let J=q.childs[Y];if(j("tree"))f.info(`[INIT] node: ${J.name}`);if(J.definition.enabled===!1){q.childs.splice(Y,1),Y--;continue}else await this.initNode({node:J})}if(j("tree"))f.info(`[TREE] Root node tree created (${q.childs.length} flows)`);return q}async initNode({node:Q}){let Z={...this.#j,node:Q};Q.workflow=Q.parent.workflow||Q,Q.depth=Q.parent.depth+1;let X="unknown";if(await K7.hits(Z))X="tryexcept",await K7.init(Z);else if(await U8.hits(Z))X="switch",await U8.init(Z);else if(await V7.hits(Z))X="if",await V7.init(Z);else if(await G7.hits(Z))X="for",await G7.init(Z);else if(await T7.hits(Z))X="retry",await T7.init(Z);else if(await S7.hits(Z))X="schedule",await S7.init(Z);else if(await _7.hits(Z))X="parallel",await _7.init(Z);else if(await j7.hits(Z))X="pipeline",await j7.init(Z);else if(await w7.hits(Z))X="http",await w7.init(Z);else if(await $8.hits(Z))X="call",await $8.init(Z);else if(await L7.hits(Z))X="new",await L7.init(Z);else if(await U7.hits(Z))X="raise",await U7.init(Z);else if(await O7.hits(Z))X="form",await O7.init(Z);else if(await A7.hits(Z))X="signal",await A7.init(Z);else if(await B7.hits(Z))X="wait",await B7.init(Z);else if(await M7.hits(Z))X="steps",await M7.init(Z);else if(await R7.hits(Z))X="next",await R7.init(Z);else if(await I7.hits(Z))X="modules",await I7.init(Z);else if(this.#z.find((q)=>q.hits(Z)))X="npm-block",await this.#z.find((q)=>q.hits(Z)).init(Z);else if(await z7.hits(Z))X="assign",await z7.init(Z);else if(await F7.hits(Z))X="output",await F7.init(Z);else if(await $7.hits(Z))X="return",await $7.init(Z);else throw Error("Undefined step type.");if(j("tree")){let q=Q.childs?.length>0?` (${Q.childs.length} childs)`:"";f.info(`[NODE] ${X}: ${Q.name}${q}`)}return!0}async initNodeTreeIndex({root:Q}){let Z={};Q.indexKey="/";for await(let X of Q.childs)await this.initNodeIndex({node:X,index:Z});return Q.context.index=Z,Z}async initNodeIndex({node:Q,index:Z}){let X=k.join(Q.parent.indexKey,Q.name);Q.indexKey=X,Z[X]=Q;let q=[],Y=Q;while(Y?.parent)q.push(Y.index),Y=Y.parent;q.reverse(),Q.codeKey=`B_${q.join("_")}_${Q.type}`,Q.pathKey=`${q.join(".")}`,Q.typeId=QZ();for await(let J of Q.childs)await this.initNodeIndex({node:J,index:Z})}async initNodeCalls({root:Q}){let Z=Q.context.index,X=[];for await(let q of Object.keys(Z)){let Y=Z[q];if(Y.type!=="call"&&Y.type!=="new")continue;X.push(Y)}return Q.context.calls=X,X}async initNodeCallLibs({root:Q}){let Z=[],X=Q.context.calls;for await(let q of X){let Y=q.definition.from||q.definition.import||q.definition.call,J=await this.findNodeCallTarget({refNode:q,curNode:q.parent})||{name:Y,type:"atom",definition:q.definition},H=Z.find((W)=>W.name===J.name&&W.type===J.type);if(!H)Z.push(J);q.target=H||J}return Q.context.callLibs=Z,Q.context.libs=[...Q.context.libs,...Z],Z}async findNodeCallTarget({refNode:Q,curNode:Z}){if(!Z)return;let X=Q.definition.call,q=Z.childs.find((Y)=>Y.name===X&&Y.type==="subworkflow");if(q)return q;else return await this.findNodeCallTarget({refNode:Q,curNode:Z.parent})}async initNodeForms({root:Q}){let Z=Q.context.index,X=[];for await(let q of Object.keys(Z)){let Y=Z[q];if(Y.type!=="form")continue;X.push(Y)}return Q.context.forms=X,X}async initNodeFormLibs({root:Q}){let Z=[],X=Q.context.forms;for await(let q of X){let Y=q.definition.from||q.definition.import||q.definition.form,J=await this.findNodeCallTarget({refNode:q,curNode:q.parent})||{name:Y,type:"atom"},H=Z.find((W)=>W.name===J.name&&W.type===J.type);if(!H)Z.push(J);q.target=H||J}return Q.context.formLibs=Z,Q.context.libs=[...Q.context.libs,...Z],Z}async initFeaturesFromNodes({childs:Q,features:Z}){for await(let X of Q){if(X.type==="form"&&!Reflect.has(Z,"form"))Z.form=!0;await this.initFeaturesFromNodes({childs:X.childs,features:Z})}}async initEntryFiles({root:Q,features:Z}){for await(let X of Q.childs){let q;if(X.name==="main")q="index.js";else if(X.name==="cli")q="cli.js";else if(X.name==="app")q="app.js";else if(X.name==="api")q="api.js";else continue;Z[`${X.name}_default_entry_file`]=q,X.entryFile=q}}async findNodeFormTarget({refNode:Q,curNode:Z}){if(!Z)return;let X=Q.definition.form,q=Z.childs.find((Y)=>Y.name===X&&Y.type==="subworkflow");if(q)return q;else return await this.findNodeFormTarget({refNode:Q,curNode:Z.parent})}async initAtomLibsAndDeps({libs:Q,packageDependencies:Z}){let X=Q.filter((q)=>q.type==="atom");for(let q=0;q<X.length;q++){let Y=X[q],J=await this.findAtomLibrary({url:Y.name,libRef:Y});Y.atom=J,J.doc.dependencies?.filter((W)=>typeof W.repo>"u"||W.repo==="npm")?.forEach((W)=>{let V=Z.find((K)=>K.package===W.package);if(V){if(typeof W.path==="string"){if(!(V.path||[]).some((K)=>K===W.path))V.path=V.path||[],V.path.push(W.path)}else if(Array.isArray(W.path))W.path.forEach((K)=>{if(!(V.path||[]).some((G)=>G===K))V.path=V.path||[],V.path.push(K)})}else Z.push(W)})}Z.sort((q,Y)=>q.package?.localeCompare(Y.package))}async findAtomLibrary({url:Q,libRef:Z}){let X=e1({url:Q});if(!X)throw Error(`Invalid package name: ${Q}`);if(!X.protocol)X.protocol=this.#G;if(X.protocol==="src:"){let q=k.resolve(this.#Q.projectSrcDir,`${X.pathname}.js`),Y=[],H=(await Z2({file:q,recursive:!0})).all;for await(let V of H){if(V.type!=="npm")continue;if(Y.find((G)=>G.package===V.package))continue;let K=await j0({name:V.package,projectDir:this.#Q.projectDir,setProgress:this.#H.setProgress});Y.push({package:V.package,subpath:V.subpath,version:K.minorRange,type:"npm"})}return{name:X.pathname,doc:{type:"workflow.lib","content-type":"javascript",language:"js",dependencies:Y},protocol:X.protocol}}else if(X.protocol==="npm:"){let q=sQ({path:X.pathname}),Y=await j0({name:q.package,subpath:q.subpath,projectDir:this.#Q.projectDir,setProgress:this.#H.setProgress});return{name:X.pathname,doc:{type:"workflow.lib",subtype:Z?.definition?.subtype==="flow"?"workflow":null,"content-type":"javascript",language:"js",dependencies:[{package:q.package,version:Y.minorRange,type:"npm"}]},protocol:X.protocol}}else if(X.protocol==="use:")return{name:X.pathname,doc:{type:"function",dependencies:[]},protocol:X.protocol};else if(X.protocol==="node:")return{name:X.pathname,doc:{type:"workflow.lib","content-type":"javascript",language:"js",dependencies:[]},protocol:X.protocol};else if(X.protocol==="ac:"){let q=X.pathname.split("/");if(q.length===1)return await i0.first({where:{name:Q,parent_id:this.#Y.env.ATOM_LIBRARIES_ID,type:"workflow.lib"}});if(q.length===2){let Y=await i0.first({where:{name:q[0],parent_id:this.#Y.env.ATOM_LIBRARIES_ID,type:"folder"}});return await i0.first({where:{name:q[1],parent_id:Y.id,type:"workflow.lib"}})}}}async resolveNodeTree({root:Q}){for await(let Z of Q.childs)await this.resolveTypeWorkflow({node:Z})}async resolveTypeWorkflow({node:Q}){Q.context.transform=Q.context.transform||eQ(Q.definition);let Z=Q.context.transform;for(let X=0;X<Z.params?.length;X++){let q=Z.params[X];if(typeof q==="string")Z.params[X]={key:q,hasDefault:!1};else{if(Object.keys(q).length===0){Z.params.splice(X,1),X--;continue}let Y=Object.keys(q)[0];Z.params[X]={key:Y,hasDefault:!0,default:q[Y],type:typeof q[Y]}}}Q.context.next=Q.childs[0];for await(let X of Q.childs)await this.resolveType({node:X})}async resolveType({node:Q}){let Z={...this.#j,node:Q};if(typeof Q.resolve==="function")await Q.resolve(Z);for await(let X of Q.childs)await this.resolveType({node:X})}async resolveTypeCommon({node:Q}){let Z=Q.context.transform;if(Z.hasOwnProperty("page"))Z.page=await this.transformExpression(Z.page);if(Z.hasOwnProperty("print"))Z.print=await this.transformExpression(Z.print);if(Z.hasOwnProperty("sleep"))Z.sleep=await this.transformExpression(Z.sleep);if(Z.hasOwnProperty("assert"))Z.assert=await this.transformExpression(Z.assert)}async createAtomLibFiles({root:Q}){await this.setProgress({message:"Creating external lib files."}),this.#Z.typesDir="./types";let X=Q.context.libs.filter((q)=>q.type==="atom");for(let q=0;q<X.length;q++){let J=X[q].atom,H=this.#Q.projectDir;if(J.protocol==="src:"){let W=this.#Z.doc.features?.symlinks===!0?this.#Q.projectSrcDirSymlink:this.#Q.projectSrcDir;W=k.resolve(W,`${J.fileName||J.name}.js`);let V=k.relative(`${this.#Q.projectDir}/src/default/blocks`,W);if(!T.existsSync(W)){T.mkdirSync(k.dirname(W),{recursive:!0});let K=`export default async (input)=>{
|
|
12
|
+
`;K+="}",T.writeFileSync(W,K,"utf8")}J.relativePath=V.split(k.sep).join("/"),this.#Z.typesDir=`./types/${k.basename(H)}/src`}else if(J.protocol==="npm:")J.relativePath=J.name;else if(J.protocol==="node:")J.relativePath=J.name;else if(J.protocol==="use:");else{let W=`${H}/src/libs/${J.id}.js`,V=J.doc.contents?.find((K)=>K.format==="esm")||J.doc;T.writeFileSync(k.normalize(W),V.content,"utf8")}}}async createEngine({root:Q}){await this.setProgress({message:"Creating engine file."});let Z=this.#Q.templateDir,X=M8.compile(T.readFileSync(k.resolve(Z,"src/default/engine.js.njk"),"utf8"),this.#X);for(let q=0;q<Q.childs.length;q++){let Y=Q.childs[q];if(!Y.entryFile)continue;let J=X.render({flow:Y,ui:{package:"@fnet/react-app"}}),H=this.#Q.projectDir,W=k.resolve(H,`src/default/${Y.entryFile}`);T.writeFileSync(W,J,"utf8")}}async createNodeTree({root:Q}){await this.setProgress({message:"Creating block files."});for await(let Z of Q.childs)await this.createTypeWorkflow({node:Z})}async createTypeWorkflow({node:Q}){let Z=this.#Q.templateDir,q=M8.compile(T.readFileSync(k.resolve(Z,"src/default/workflow.js.njk"),"utf8"),this.#X).render(Q),Y=this.#Q.projectDir,J=k.resolve(Y,`src/default/${Q.codeKey}.js`);T.writeFileSync(J,q,"utf8");for await(let H of Q.childs)await this.createType({node:H})}async createType({node:Q}){switch(Q.type){case"assign":case"steps":case"return":case"call":case"new":case"form":case"raise":case"switch":case"next":case"tryexcept":case"for":case"parallel":case"signal":case"wait":case"modules":case"output":case"pipeline":case"retry":case"schedule":case"http":this.createBlockFromTemplate({node:Q});break;default:break}for await(let Z of Q.childs)await this.createType({node:Z})}createBlockFromTemplate({node:Q}){let Z=this.getBlockTemplate({node:Q});Q.context.render=Z.render(Q),this.createStepFile({node:Q})}getBlockTemplate({node:Q}){let Z=this.#M[Q.type];if(Z)return Z;let X=this.#Q.templateDir;return Z=M8.compile(T.readFileSync(k.resolve(X,`src/default/blocks/${Q.type}.js.njk`),"utf8"),this.#X),this.#M[Q.type]=Z,Z}createStepFile({node:Q}){let Z=this.#Q.projectDir,X=`${Q.codeKey}.js`,q=k.resolve(Z,`src/default/blocks/${X}`);T.writeFileSync(q,Q.context.render,"utf8"),Q.context.fileName=X,Q.context.filePath=q}async transformExpression(Q){try{let Z=await this.transformValue(Q);return Z=JSON.stringify(Z),Z=this.replaceSpecialPattern(Z),Z}catch(Z){throw console.error("❌ transformExpression error:",Z.message),console.error(" Input value:",Q),console.error(" Stack:",Z.stack),Z}}async transformValue(Q){if(Array.isArray(Q))for(let Z=0;Z<Q.length;Z++)Q[Z]=await this.transformValue(Q[Z]);else if(t1(Q)){let Z=Object.keys(Q);for(let X=0;X<Z.length;X++){let q=Z[X],Y=c6({expression:q});if(Y)if(Y.processor==="e"){let J=typeof Q[q]==="string"?Q[q]:Q[q];Q[Y.statement]=`$::${J}::`,delete Q[q]}else Q[q]=await this.transformValue(Q[q]);else Q[q]=await this.transformValue(Q[q])}}else if(typeof Q==="string"){let Z=c6({expression:Q,transform:{v:"v.{stmt}",for:"c.for.{stmt}",m:"c.module?.{stmt}||flow.module?.{stmt}",f:"c.form.{stmt}"}});if(Z){let{processor:X,transformed:q}=Z;switch(X){case"v":case"for":case"m":case"f":case"e":Q=`$::${q||Z.statement}::`;break}}}return Q}replaceSpecialPattern(Q){if(typeof Q!=="string")return console.error("❌ replaceSpecialPattern received non-string:",typeof Q,Q),Q;let Z=/"\$::(.*?)::"/g;return Q.replace(Z,"$1")}replaceExpressionLegacy(Q){let Z=/(?<outer>"\${(?<inner>[^{]*)}")/g;return Q.replaceAll(Z,"$2")}async createProjectYaml(){await this.setProgress({message:"Creating fnet.yaml"});let{content:X,...q}=this.#Z.doc,Y=this.#Q.projectDir,J=k.resolve(Y,"fnet.yaml");T.writeFileSync(J,oQ.stringify(q),"utf8")}async createProjectMainYaml(){await this.setProgress({message:"Creating flow.main.yaml"});let X={content:oQ.stringify(this.#q)},q=this.#Q.templateDir,J=M8.compile(T.readFileSync(k.resolve(q,"flow.main.yaml.njk"),"utf8"),this.#X).render(X),H=this.#Q.projectDir,W=k.resolve(H,"flow.main.yaml");T.writeFileSync(W,J,"utf8")}async runPrettifier(){let Q=this.#Q.projectDir;if(M0("bun")){let Z=await tQ("prettier --write .",{cwd:k.resolve(Q,"src")});if(Z.code!==0)throw Error(Z.stderr)}else{let Z=await tQ("prettier --write .",{cwd:k.resolve(Q,"src")});if(Z.code!==0)throw Error(Z.stderr)}}async deploy(){if(await this.setProgress({message:"Deploying."}),this.#Q.project?.devops){let Q=[this.#Q.project?.devops];for(let Z=0;Z<Q.length;Z++){let X=Q[Z];if(await this.deployProject({deploymentProject:X}),X.isDirty===!0)await X.save()}}else if(this.#Z.id){let Q=await i0.list({type:"workflow.deploy",parent_id:this.#Z.id});for(let Z=0;Z<Q.length;Z++){let X=Q[Z];if(await this.deployProject({deploymentProject:X}),X.isDirty===!0)X=await i0.update(X,{id:X.id})}}}async deployProject(Q){let{deploymentProject:Z}=Q,{yamlDocument:X}=Z;if(Z.doc.targets&&Array.isArray(Z.doc.targets))throw Error("Deployment project targets are deprecated. Please update targets in the yaml file.");let q=Object.keys(Z.doc||{}),Y=X||{};for(let J=0;J<q.length;J++){let H=Z.doc[q[J]];H.name=q[J];let W=Y.get(q[J]);await O9({...this.#H,deploymentProject:Z,deploymentProjectTarget:H,yamlTarget:W})}}async registerToPackageManager(Q){}async setProgress(Q){let Z=typeof Q==="string"?Q:Q?.message;console.log(q2.blue(Z)),await this._cache_set(this.#K,{status:"IN_PROGRESS",message:Z})}async build(){if(this.#F&&!this.#B)return await this.createNetwork();try{let Q=this.#F?await F8({root:this.#V}):void 0;if(this.#B){let Z=this.#H.context.project;if(await this.initWorkflowDir(),await this.initNunjucks(),this.#F){let X=this.#Q.project?.projectDir||this.#Q.projectDir;if(X=k.resolve(X,"fnet"),T.existsSync(X)){if(T.existsSync(k.resolve(X,"flow.bpmn")))T.unlinkSync(k.resolve(X,"flow.bpmn"));if(T.writeFileSync(k.resolve(X,"flows.bpmn"),Q.diagramXML,"utf8"),((this.#Z.doc.features||{}).bpmn||{}).per_flow===!0){let H=k.resolve(X,"bpmn");if(!T.existsSync(H))T.mkdirSync(H,{recursive:!0});let W=await I9({root:this.#V});for(let V of W){let K=`${V.flowName}.bpmn`,G=k.resolve(H,K);T.writeFileSync(G,V.diagramXML,"utf8")}}}}if(await this.createAtomLibFiles({root:this.#V}),await this.createEngine({root:this.#V}),await this.createNodeTree({root:this.#V}),await this.createProjectYaml(),await D6(this.#H),await k6(this.#H),await b6(this.#H),await P6(this.#H),await C6(this.#H),await R6(this.#H),Z.runtime.type==="bun")await S6(this.#H);else await j6(this.#H);if(await I6(this.#H),await v6(this.#H),await y6(this.#H),this.#O){if(await E6(this.#H),await x6(this.#H),this.#A)await this.deploy()}}await this._cache_set(this.#K,{status:"COMPLETED",data:{network:Q}})}catch(Q){throw await this._cache_set(this.#K,{status:"FAILED",message:Q.message||Q}),Q}}async createNetwork(){try{let Q=await F8({root:this.#V});await this._cache_set(this.#K,{status:"COMPLETED",data:{...Q}})}catch(Q){throw await this._cache_set(this.#K,{status:"FAILED",message:Q.message||Q}),Q}}}var b0=ZZ;var J2={command:"build",describe:"Build flownet project",builder:(Q)=>{return Q.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"}).option("flows",{type:"string",alias:"flow",describe:"Path to flows file"}).option("bpmn",{type:"boolean",default:!1,describe:"Generate BPMN diagram"})},handler:async(Q)=>{try{let Z=await D(Q),X=new b0(Z);await X.init(),await X.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Z){console.error("Building workflow failed!",Z.message),process.exit(1)}}},XZ=J2;var W2={command:"build:dev",describe:"Build flownet project",builder:(Q)=>{return Q.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"}).option("flows",{type:"string",describe:"Path to flows file"})},handler:async(Q)=>{try{Q.dev=!0;let Z=await D(Q),X=new b0(Z);await X.init(),await X.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Z){console.error("Building workflow failed!",Z.message),process.exit(1)}}},qZ=W2;var H2={command:"deploy",describe:"Build and deploy flownet project",builder:(Q)=>{return Q.option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).option("flows",{type:"string",describe:"Path to flows file"})},handler:async(Q)=>{try{let Z=await D({...Q,mode:"all"}),X=new b0(Z);await X.init(),await X.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Z){console.error("Building workflow failed!",Z.message),process.exit(1)}}},YZ=H2;var V2={command:"file",describe:"Just create files",builder:(Q)=>{return Q.option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).option("flows",{type:"string",describe:"Path to flows file"})},handler:async(Q)=>{try{let Z=await D({...Q,mode:"file"}),X=new b0(Z);await X.init(),await X.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Z){console.error("Building workflow failed!",Z.message),process.exit(1)}}},JZ=V2;import WZ from"node:path";import l8 from"node:fs";import K2 from"@fnet/prompt";var z2={command:"input [name]",describe:"Create or modify an input config file",builder:(Q)=>{return Q.positional("name",{type:"string",demandOption:!1,describe:"Input name"})},handler:async(Q)=>{try{let Z=await D(Q),{project:X}=Z,{projectDir:q,projectFileParsed:Y}=X,J=Y.input;if(!J)throw Error("Config schema not found in project file.");if(!Reflect.has(Q,"name")){let{inputName:_}=await K2({type:"input",name:"inputName",message:"Input name:",initial:"dev"});Q.name=_}let H=WZ.resolve(q,".fnet");if(!l8.existsSync(H))l8.mkdirSync(H);let W=WZ.resolve(H,`${Q.name}.fnet`),V=l8.existsSync(W),K=(await import("@fnet/object-from-schema")).default,G=await K({schema:J,format:"yaml",ref:V?W:void 0});l8.writeFileSync(W,G)}catch(Z){console.error(Z.message),process.exit(1)}}},HZ=z2;import P from"node:path";import N from"node:fs";import i8 from"node:os";import{spawn as p8}from"node:child_process";import L from"chalk";import L0 from"@fnet/prompt";import d8 from"chalk";import VZ from"@fnet/prompt";async function G2(Q){let{items:Z,message:X,nameField:q="name",valueField:Y="name",initialValue:J=null,allowAbort:H=!0}=Q;if(!Z||Z.length===0)return console.log(d8.yellow("No items available for selection.")),null;if(Z.length===1&&!H){let _=Z[0],z=typeof _==="string"?_:_[Y];return console.log(d8.blue(`Only one option available: ${typeof _==="string"?_:_[q]}`)),z}let W=Z.map((_)=>{if(typeof _==="string")return{name:_,value:_,message:_};else return{name:_[Y],value:_[Y],message:_[q]||_[Y]}});if(H)W.push({name:"cancel",value:null,message:d8.yellow("Cancel")});let V=null;if(J){let _=W.findIndex((z)=>z.name===J);if(_!==-1)V=_}let K="selectedItem",{[K]:G}=await VZ({type:"select",name:K,message:X,choices:W,initial:V});if(G==="cancel")return null;return G}async function _2(Q){let{items:Z,message:X,nameField:q="name",valueField:Y="name",initialValues:J=[],allowAbort:H=!0}=Q;if(!Z||Z.length===0)return console.log(d8.yellow("No items available for selection.")),null;let W=Z.map((_)=>{if(typeof _==="string")return{name:_,value:_,message:_};else return{name:_[Y],value:_[Y],message:_[q]||_[Y]}}),V=[];if(J&&J.length>0)V=W.map((_,z)=>J.includes(_.name)?z:-1).filter((_)=>_!==-1);let K="selectedItems",G=await VZ({type:"multiselect",name:K,message:X,choices:W,initial:V,hint:"(Use space to select, enter to confirm)",validate:(_)=>{if(_.length===0&&!H)return"Please select at least one item";return!0}});if(H&&G[K].length===0)return null;return G[K]}var N7={promptForSelection:G2,promptForMultipleSelection:_2};var c=P.join(i8.homedir(),".fnet","express");async function zZ(Q){Q.command(["$0 [project-name]","create [project-name]"],"Create a new express project",(Z)=>{return Z.positional("project-name",{describe:"Name of the project",type:"string"}).option("yes",{alias:"y",describe:"Skip all prompts and use defaults",type:"boolean",default:!1}).option("runtime",{describe:"Runtime to use (node)",type:"string",choices:["node"],default:"node"})},async(Z)=>{await U2(Z)}).command("list","List express projects",(Z)=>{return Z.option("today",{describe:"Show only projects created today",type:"boolean",default:!1}).option("type",{describe:"Filter by project type (fnode or fnet)",type:"string",choices:["fnode","fnet"]}).option("all",{describe:"Show all projects regardless of type",type:"boolean",default:!1,alias:"a"}).option("name",{describe:"Filter by project name",type:"string"})},async(Z)=>{await $2(Z)}).command("open [project-name]","Open an express project",(Z)=>{return Z.positional("project-name",{describe:"Name of the project to open",type:"string"}).option("latest",{describe:"Open the most recent project",type:"boolean",default:!1})},async(Z)=>{await M2(Z)}).command("move [project-name] [destination]","Move an express project to a real project location",(Z)=>{return Z.positional("project-name",{describe:"Name of the project to move",type:"string"}).positional("destination",{describe:"Destination directory",type:"string"}).option("latest",{describe:"Move the most recent project",type:"boolean",default:!1})},async(Z)=>{await O2(Z)}).command("remove [project-name]","Remove an express project",(Z)=>{return Z.positional("project-name",{describe:"Name of the project to remove",type:"string"}).option("latest",{describe:"Remove the most recent project",type:"boolean",default:!1}).option("yes",{alias:"y",describe:"Skip confirmation prompt",type:"boolean",default:!1})},async(Z)=>{await B2(Z)}).command("enter [project-name]","Enter the directory of an express project in the active terminal",(Z)=>{return Z.positional("project-name",{describe:"Name of the project to enter",type:"string"}).option("latest",{describe:"Enter the most recent project directory",type:"boolean",default:!1})},async(Z)=>{await R2(Z)}).demandCommand(1,"You need to specify a command").help()}async function U2(Q){try{if(!N.existsSync(c))N.mkdirSync(c,{recursive:!0});let Z=new Date().toISOString().slice(0,10).replace(/-/g,""),X=P.join(c,Z);if(!N.existsSync(X))N.mkdirSync(X,{recursive:!0});let q=Q.projectName,Y,J=Q.runtime;if(!Q.yes){if(!q){let z=N.readdirSync(X).filter((U)=>U.startsWith("fnet-")).map((U)=>parseInt(U.replace("fnet-",""),10)).filter((U)=>!isNaN(U)),$=`fnet-${z.length>0?Math.max(...z)+1:1}`;q=(await L0([{type:"input",name:"projectName",message:"Enter project name:",default:$}])).projectName}J=(await L0({type:"select",name:"runtime",message:"Select runtime:",choices:["node"],initial:J||"node"})).runtime}else{if(!q){let G=N.readdirSync(X).filter((z)=>z.startsWith("fnet-")).map((z)=>parseInt(z.replace("fnet-",""),10)).filter((z)=>!isNaN(z));q=`fnet-${G.length>0?Math.max(...G)+1:1}`}if(!J)J="node"}if(Y=P.join(X,q),N.existsSync(Y)){let G=1;while(N.existsSync(P.join(X,`${q}-${G}`)))G++;q=`${q}-${G}`,Y=P.join(X,q)}if(!Q.yes){if(!(await L0([{type:"confirm",name:"proceed",message:`Create express project "${q}" in ${Y}?`,default:!0}])).proceed){console.log(L.yellow("Project creation cancelled."));return}}console.log(L.blue(`Creating express project "${q}" in ${Y}...`));let H=P.dirname(Y),V=["create","--name",P.basename(Y)];if(V.push("--runtime",J),Q.yes)V.push("--yes");if(!N.existsSync(H))N.mkdirSync(H,{recursive:!0});let K=p8("fnet",V,{stdio:"inherit",shell:!0,cwd:H});return new Promise((G,_)=>{K.on("close",(z)=>{if(z===0)if(console.log(L.green(`
|
|
13
13
|
Express project "${q}" created successfully!`)),console.log(L.blue(`
|
|
14
|
-
Project location: ${Y}`)),!Q.yes)
|
|
15
|
-
Failed to create express project "${q}".`)),
|
|
16
|
-
Express Projects:`));let q=(await import("./index.4g9yezkq.js")).default,Y=["NAME","TYPE","DATE","PATH"],J=q.createTable(Y,{chars:{mid:"","mid-mid":"","left-mid":"","right-mid":""}});for(let H of X){let W=H.path;if(W.startsWith(
|
|
17
|
-
Total: ${X.length} projects`))}catch(Z){console.error(L.red(`Error listing express projects: ${Z.message}`)),process.exit(1)}}async function
|
|
18
|
-
Project moved successfully to ${Y}`)),(await
|
|
19
|
-
Opening a new shell in the project directory...`));let X=process.env.SHELL||"/bin/bash",q=
|
|
20
|
-
Returned from project directory.`)),Y()})})}catch(Z){console.error(L.red(`Error entering express project directory: ${Z.message}`)),process.exit(1)}}import
|
|
14
|
+
Project location: ${Y}`)),!Q.yes)A2(Y);else G();else console.error(L.red(`
|
|
15
|
+
Failed to create express project "${q}".`)),_(Error(`Process exited with code ${z}`))})})}catch(Z){console.error(L.red(`Error creating express project: ${Z.message}`)),process.exit(1)}}async function $2(Q){try{if(!N.existsSync(c)){console.log(L.yellow("No express projects found."));return}let Z=N.readdirSync(c).filter((H)=>/^\d{8}$/.test(H)).sort((H,W)=>W.localeCompare(H));if(Q.today){let H=new Date().toISOString().slice(0,10).replace(/-/g,""),W=Z.indexOf(H);if(W===-1){console.log(L.yellow("No express projects found for today."));return}Z.splice(0,W),Z.splice(1)}let X=[];if(!Q.type&&!Q.all)Q.type="fnet";for(let H of Z){let W=P.join(c,H),V=N.readdirSync(W);for(let K of V){let G=P.join(W,K),_=N.statSync(G),z="unknown";if(K.startsWith("fnode-")||N.existsSync(P.join(G,"fnode.yaml")))z="fnode";else if(K.startsWith("fnet-")||N.existsSync(P.join(G,"fnet.yaml")))z="fnet";if(Q.type&&z!==Q.type)continue;if(Q.name&&!K.includes(Q.name))continue;let O=`${H.slice(0,4)}-${H.slice(4,6)}-${H.slice(6,8)}`;X.push({name:K,type:z,date:O,path:G,created:_.birthtime})}}if(X.sort((H,W)=>W.created-H.created),X.length===0){console.log(L.yellow("No express projects found matching the criteria."));return}console.log(L.blue(`
|
|
16
|
+
Express Projects:`));let q=(await import("./index.4g9yezkq.js")).default,Y=["NAME","TYPE","DATE","PATH"],J=q.createTable(Y,{chars:{mid:"","mid-mid":"","left-mid":"","right-mid":""}});for(let H of X){let W=H.path;if(W.startsWith(i8.homedir()))W="~"+W.substring(i8.homedir().length);J.push([L.white(H.name),H.type==="fnet"?L.cyan(H.type):H.type==="fnode"?L.green(H.type):H.type,H.date,W])}console.log(J.toString()),console.log(L.blue(`
|
|
17
|
+
Total: ${X.length} projects`))}catch(Z){console.error(L.red(`Error listing express projects: ${Z.message}`)),process.exit(1)}}async function M2(Q){try{if(!N.existsSync(c)){console.log(L.yellow("No express projects found."));return}let Z;if(Q.latest){if(Z=await a8(),!Z){console.log(L.yellow("No express projects found."));return}}else if(Q.projectName){if(Z=await n8(Q.projectName),!Z){console.log(L.yellow(`Project "${Q.projectName}" not found.`));return}}else{let X=await r8();if(!X){console.log(L.yellow("No project selected."));return}Z=P.join(c,X)}await P7(Z)}catch(Z){console.error(L.red(`Error opening express project: ${Z.message}`)),process.exit(1)}}async function O2(Q){try{let Z=process.cwd(),X=Z.includes(c),q;if(X)q=Z,console.log(L.blue(`Using current express project: ${P.basename(q)}`));else if(Q.latest){if(q=await a8(),!q){console.log(L.yellow("No express projects found."));return}}else if(Q.projectName){if(q=await n8(Q.projectName),!q){console.log(L.yellow(`Project "${Q.projectName}" not found.`));return}}else{let H=await r8();if(!H){console.log(L.yellow("No project selected."));return}q=P.join(c,H)}let Y=Q.destination;if(!Y)Y=(await L0({type:"input",name:"destination",message:"Enter destination directory:",initial:P.join(process.cwd(),P.basename(q))})).destination;if(Y.startsWith("~"))Y=P.join(i8.homedir(),Y.slice(1));if(Y=P.resolve(Y),Y.startsWith(q+P.sep)||Y===q){console.log(L.red("Destination cannot be inside the source directory."));return}if(N.existsSync(Y)){if(!N.statSync(Y).isDirectory()){console.log(L.red(`Destination "${Y}" is not a directory.`));return}if(N.readdirSync(Y).length>0){if(!(await L0({type:"confirm",name:"overwrite",message:`Destination "${Y}" is not empty. Continue anyway?`,initial:!1})).overwrite){console.log(L.yellow("Project move cancelled."));return}}}else N.mkdirSync(Y,{recursive:!0});if(console.log(L.blue(`Moving project from ${q} to ${Y}...`)),GZ(q,Y),console.log(L.green(`
|
|
18
|
+
Project moved successfully to ${Y}`)),(await L0({type:"confirm",name:"deleteOriginal",message:"Delete the original express project?",initial:!1})).deleteOriginal)N.rmSync(q,{recursive:!0,force:!0}),console.log(L.green("Original project deleted."));await P7(Y)}catch(Z){console.error(L.red(`Error moving express project: ${Z.message}`)),process.exit(1)}}async function a8(){let Q=N.readdirSync(c).filter((H)=>/^\d{8}$/.test(H)).sort((H,W)=>W.localeCompare(H));if(Q.length===0)return null;let Z=Q[0],X=P.join(c,Z),q=N.readdirSync(X);if(q.length===0)return null;let Y=null,J=0;for(let H of q){let W=P.join(X,H),V=N.statSync(W);if(V.birthtimeMs>J)J=V.birthtimeMs,Y=W}return Y}async function n8(Q){let Z=N.readdirSync(c).filter((X)=>/^\d{8}$/.test(X)).sort((X,q)=>q.localeCompare(X));for(let X of Z){let q=P.join(c,X),Y=N.readdirSync(q);if(Y.includes(Q))return P.join(q,Q);let J=Y.filter((H)=>H.includes(Q));if(J.length>0)if(J.length===1)return P.join(q,J[0]);else{let H=J.map((V)=>({name:P.join(q,V),value:P.join(q,V),message:`${V} (${X})`})),W=await N7.promptForSelection({items:H,message:`Multiple projects match "${Q}". Please select one:`,nameField:"message",valueField:"value",allowAbort:!0});if(W===null)return console.log(L.yellow("Operation cancelled.")),null;return W}}return null}async function r8(){let Q=[],Z=N.readdirSync(c).filter((q)=>/^\d{8}$/.test(q)).sort((q,Y)=>Y.localeCompare(q));for(let q of Z){let Y=P.join(c,q),J=N.readdirSync(Y);for(let H of J){let W=P.join(Y,H),V=N.statSync(W),K=`${q}/${H}`;Q.push({name:K,value:K,created:V.birthtime})}}if(Q.sort((q,Y)=>Y.created-q.created),Q.length===0)return null;let X=await N7.promptForSelection({items:Q,message:"Select a project:",nameField:"value",valueField:"value",allowAbort:!0});if(X===null)return console.log(L.yellow("Operation cancelled.")),null;return X}async function A2(Q){try{if((await L0({type:"confirm",name:"openIDE",message:"Would you like to open the project in an IDE?",initial:!0})).openIDE)await P7(Q)}catch(Z){console.error(L.red(`Error opening IDE: ${Z.message}`))}}async function P7(Q){let Z=await KZ("code --version"),X=await KZ("code-insiders --version"),q=null;if(Z&&X)q=(await L0({type:"select",name:"ide",message:"Which IDE would you like to use?",choices:[{name:"Visual Studio Code",value:"code"},{name:"Visual Studio Code Insiders",value:"code-insiders"}]})).ide;else if(Z)q="code";else if(X)q="code-insiders";else{console.log(L.yellow("No supported IDE found. Please open the project manually.")),console.log(L.blue(`Project path: ${Q}`));return}console.log(L.blue(`Opening project in ${q}...`)),console.log(L.blue(`Project path: ${Q}`));let Y=p8(q,[Q],{stdio:"inherit",shell:!0});return new Promise((J,H)=>{Y.on("close",(W)=>{if(W===0)console.log(L.green(`Project opened in ${q}.`)),J();else console.error(L.red(`Failed to open project in ${q}.`)),H(Error(`Process exited with code ${W}`))})})}async function KZ(Q){return new Promise((Z)=>{p8(Q,{shell:!0,stdio:"ignore"}).on("close",(q)=>{Z(q===0)})})}function GZ(Q,Z){if(!N.existsSync(Z))N.mkdirSync(Z,{recursive:!0});let X=N.readdirSync(Q,{withFileTypes:!0});for(let q of X){let Y=P.join(Q,q.name),J=P.join(Z,q.name);if(q.isDirectory()){if(q.name===".git"||q.name===".workspace")continue;GZ(Y,J)}else N.copyFileSync(Y,J)}}async function B2(Q){try{if(!N.existsSync(c)){console.log(L.yellow("No express projects found."));return}let Z;if(Q.latest){if(Z=await a8(),!Z){console.log(L.yellow("No express projects found."));return}}else if(Q.projectName){if(Z=await n8(Q.projectName),!Z){console.log(L.yellow(`Project "${Q.projectName}" not found.`));return}}else{let q=await r8();if(!q){console.log(L.yellow("No project selected."));return}Z=P.join(c,q)}let X=P.basename(Z);if(!Q.yes){if(!(await L0({type:"confirm",name:"confirm",message:`Are you sure you want to remove project "${X}"?`,initial:!1})).confirm){console.log(L.yellow("Project removal cancelled."));return}}console.log(L.blue(`Removing project "${X}"...`)),N.rmSync(Z,{recursive:!0,force:!0}),console.log(L.green(`Project "${X}" removed successfully.`))}catch(Z){console.error(L.red(`Error removing express project: ${Z.message}`)),process.exit(1)}}async function R2(Q){try{if(!N.existsSync(c)){console.log(L.yellow("No express projects found."));return}let Z;if(Q.latest){if(Z=await a8(),!Z){console.log(L.yellow("No express projects found."));return}}else if(Q.projectName){if(Z=await n8(Q.projectName),!Z){console.log(L.yellow(`Project "${Q.projectName}" not found.`));return}}else{let Y=await r8();if(!Y){console.log(L.yellow("No project selected."));return}Z=P.join(c,Y)}console.log(L.blue(`Entering project directory: ${Z}`)),console.log(L.yellow(`
|
|
19
|
+
Opening a new shell in the project directory...`));let X=process.env.SHELL||"/bin/bash",q=p8(X,[],{stdio:"inherit",cwd:Z,shell:!0});return new Promise((Y)=>{q.on("close",()=>{console.log(L.green(`
|
|
20
|
+
Returned from project directory.`)),Y()})})}catch(Z){console.error(L.red(`Error entering express project directory: ${Z.message}`)),process.exit(1)}}import UZ from"node:path";import{fileURLToPath as j2}from"node:url";import I2 from"node:fs";import s8 from"node:path";import{fileURLToPath as C2}from"node:url";var L2=s8.dirname(C2(import.meta.url));function F2({baseDir:Q}){Q=Q||L2;let Z=Q;while(Z!==s8.parse(Z).root){let X=s8.join(Z,"node_modules");if(I2.existsSync(X))return X;Z=s8.dirname(Z)}return null}var _Z=F2;var T2=UZ.dirname(j2(import.meta.url));function $Z(){let Q=_Z({baseDir:T2}),Z=process.platform==="win32"?";":":";if(Q)process.env.PATH=`${UZ.join(Q,"/.bin")}${Z}${process.env.PATH}`}u7();$Z();async function w2(){try{let Q=S2(process.argv.slice(2)).usage("Usage: $0 <command> [options]").command(l7).command(d7).command(XZ).command(qZ).command(YZ).command(JZ).command(HZ).command("express","Create and manage express projects",zZ);Q=s(Q,{bin:"npm",createContext:D}),Q=s(Q,{bin:"node",createContext:D}),Q=s(Q,{bin:"bun",createContext:D}),Q=s(Q,{name:"serve",bin:"bun",preArgs:["run","serve","--"],createContext:D}),Q=s(Q,{name:"watch",bin:"bun",preArgs:["run","watch","--"],createContext:D}),Q=s(Q,{name:"app",bin:"bun",preArgs:["run","app","--"],createContext:D}),Q=s(Q,{name:"cli",bin:"bun",preArgs:["run","cli","--"],createContext:D}),Q=s(Q,{name:"cli:dev",bin:"bun",preArgs:["run","cli:dev","--"],createContext:D}),Q=s(Q,{name:"cli:compile",bin:"bun",preArgs:["run","cli:compile","--"],createContext:D}),Q=s(Q,{name:"cli:compile:dev",bin:"bun",preArgs:["run","cli:compile:dev","--"],createContext:D}),Q=s(Q,{name:"cli:install",bin:"bun",preArgs:["run","cli:install","--"],createContext:D}),Q=s(Q,{name:"compile",bin:"bun",preArgs:["run","compile","--"],createContext:D}),Q=m7(Q,{name:"install",createContext:D}),Q=s(Q,{bin:"npx",createContext:D}),Q=s(Q,{bin:"cdk",createContext:D}),Q=s(Q,{bin:"aws",createContext:D}),Q=h7(Q,{name:"with",createContext:D}),Q=g7(Q,{name:"run",projectType:"fnet"}),Q.demandCommand(1,"You need at least one command before moving on").help().version().argv}catch(Q){console.error(MZ.red(`Fatal error: ${Q.message}`)),process.exit(1)}}w2().catch((Q)=>{console.error(MZ.red(`Fatal error: ${Q.message}`)),process.exit(1)});
|