@fnet/cli 1.0.8 → 1.0.9
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 +1 -1
- package/package.json +1 -1
package/dist/fnet/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export { schema31 as schema };`;P6.writeFileSync(b6.resolve(G,"src/default/valid
|
|
|
8
8
|
`+V+" | "+"".padEnd(Y.column-1," ")+"".padEnd(G,"^")}else Z+=`
|
|
9
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 j9(Q,Z){Z=Z!==void 0?Z:{};let X={},q=Z.grammarSource,Y={Start:E7},J=E7,H="::",W=/^[a-z]/,V=/^[a-z0-9_\-]/,K=/^[^s]/,z=/^[sS]/,G=IZ("::",!1),_=A8([["a","z"]],!1,!1,!1),O=A8([["a","z"],["0","9"],"_","-"],!1,!1,!1),$=A8(["s"],!0,!1,!1),A=A8(["s","S"],!1,!1,!1);function U(I){return NZ(I)}function B(I,C){let w=I+"::"+C,d=SZ(I,C,w);try{let u=parse(C);if(u)d.next=u}catch(u){}return d}let M=Z.peg$currPos|0,R=M,F=[{line:1,column:1}],S=M,y=Z.peg$maxFailExpected||[],v=Z.peg$silentFails|0,J0;if(Z.startRule){if(!(Z.startRule in Y))throw Error(`Can't start parsing from rule "`+Z.startRule+'".');J=Y[Z.startRule]}function W0(){return Q.substring(R,M)}function D7(){return R}function b2(){return{source:q,start:R,end:M}}function k2(){return a0(R,M)}function D2(I,C){throw C=C!==void 0?C:a0(R,M),y7([LZ(I)],Q.substring(R,M),C)}function v2(I,C){throw C=C!==void 0?C:a0(R,M),FZ(I,C)}function RZ(I=M){let C=Q.codePointAt(I);if(C===void 0)return"";return String.fromCodePoint(C)}function IZ(I,C){return{type:"literal",text:I,ignoreCase:C}}function A8(I,C,w,d){return{type:"class",parts:I,inverted:C,ignoreCase:w,unicode:d}}function y2(){return{type:"any"}}function CZ(){return{type:"end"}}function LZ(I){return{type:"other",description:I}}function v7(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 a0(I,C,w){let d=v7(I),u=v7(C),n0={source:q,start:{offset:I,line:d.line,column:d.column},end:{offset:C,line:u.line,column:u.column}};if(w&&q&&typeof q.offset==="function")n0.start=q.offset(n0.start),n0.end=q.offset(n0.end);return n0}function T0(I){if(M<S)return;if(M>S)S=M,y=[];y.push(I)}function FZ(I,C){return new T8(I,null,null,C)}function y7(I,C,w){return new T8(T8.buildMessage(I,C),I,C,w)}function E7(){let I,C;if(I=M,C=jZ(),C!==X)R=I,C=U(C);return I=C,I}function jZ(){let I,C,w,d;if(I=M,C=TZ(),C!==X){if(Q.substr(M,2)===H)w=H,M+=2;else if(w=X,v===0)T0(G);if(w!==X)if(d=wZ(),d!==X)R=I,I=B(C,d);else M=I,I=X;else M=I,I=X}else M=I,I=X;return I}function TZ(){let I,C,w,d,u;if(I=M,C=M,w=Q.charAt(M),W.test(w))M++;else if(w=X,v===0)T0(_);if(w!==X){if(d=[],u=Q.charAt(M),V.test(u))M++;else if(u=X,v===0)T0(O);while(u!==X)if(d.push(u),u=Q.charAt(M),V.test(u))M++;else if(u=X,v===0)T0(O);w=[w,d],C=w}else M=C,C=X;if(C!==X)I=Q.substring(I,M);else I=C;return I}function wZ(){let I,C,w,d,u;if(I=M,C=M,w=Q.charAt(M),K.test(w))M++;else if(w=X,v===0)T0($);if(w!==X){if(d=[],u=Q.charAt(M),z.test(u))M++;else if(u=X,v===0)T0(A);while(u!==X)if(d.push(u),u=Q.charAt(M),z.test(u))M++;else if(u=X,v===0)T0(A);w=[w,d],C=w}else M=C,C=X;if(C!==X)I=Q.substring(I,M);else I=C;return I}function SZ(I,C,w){return{processor:I,statement:C,expression:w}}function x7(I){if(!I)return[];let C=I.next?x7(I.next):[];return C.push(I.processor),C}function NZ(I){if(!I)return null;let C=I;while(C&&C.next)C=C.next;let w={processor:I.processor,statement:I.statement,expression:I.expression,process:{statement:C.statement,order:x7(I)}};if(I.next)w.next=I.next;return w}J0=J();let t8=J0!==X&&M===Q.length;function u7(){if(J0!==X&&M<Q.length)T0(CZ());throw y7(y,S<Q.length?RZ(S):null,S<Q.length?a0(S,S+1):a0(S,S))}if(Z.peg$library)return{peg$result:J0,peg$currPos:M,peg$FAILED:X,peg$maxFailExpected:y,peg$maxFailPos:S,peg$success:t8,peg$throw:t8?void 0:u7};if(t8)return J0;else u7()}function P0(Q,Z=!1){if(typeof Q!=="string")return null;let X=Q.match(/^([a-z][a-z0-9_-]*)::/);if(!X)return null;let q=X[1];if(!Z)return q;let Y=Q.slice(Q.indexOf("::")+2);return{processor:q,statement:Y}}function w9({expression:Q,depth:Z=5}){if(Z<=0)return null;let X=/^([a-z][a-z0-9_-]*)::([^\s][\s\S]*)$/,q;if(X.test(Q))q=Q.match(X);else return null;let Y=q[1],J=q[2],H=w9({expression:J,depth:Z-1}),W={processor:Y,statement:J,expression:Q};if(H)W.next=H;return W}function S9(Q){if(!Q)return[];let Z=S9(Q.next);return Z.push(Q.processor),Z}function T9({expression:Q}){let Z=w9({expression:Q});if(!Z)return null;let X=Z;while(X&&X.next)X=X.next;let q={processor:Z.processor,statement:Z.statement,expression:Z.expression,process:{statement:X.statement,order:S9(Z)}};if(Z.next)q.next=Z.next;return q}function A5(Q,Z){let X=Q.statement,q=/([a-z][a-z0-9_-]*)::([a-zA-Z_$][a-zA-Z0-9_$]*)/g;return X=X.replace(q,(Y,J,H)=>{if(Z[J]){let W=Z[J];if(typeof W==="function")return W(H);if(typeof W==="string")return W.replace(/\{stmt\}/g,H)}return Y}),X}function d6({expression:Q,useGrammar:Z=!0,multiline:X=!0,transform:q}){if(typeof Q!=="string")Q=String(Q);if(X)Q=Q.replace(/\s+/g," ").trim();let Y;if(Z)try{Y=j9(Q)}catch(J){Y=T9({expression:Q})}else Y=T9({expression:Q});if(!Y)return null;if(q){if(q[Y.processor]&&!Y.next){let J=q[Y.processor];if(typeof J==="function")Y.transformed=J(Y.statement);else if(typeof J==="string")Y.transformed=J.replace(/\{stmt\}/g,Y.statement)}else if(Y.statement)Y.transformed=A5(Y,q)}return Y}import Y2 from"@fnet/yaml";import J2 from"chalk";var r9=h(m9(),1);var t0=(Q)=>{if(typeof Q!=="string")throw TypeError("invalid pattern");if(Q.length>65536)throw TypeError("pattern is too long")};var T5={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},e0=(Q)=>Q.replace(/[[\]\\-]/g,"\\$&"),w5=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),c9=(Q)=>Q.join(""),l9=(Q,Z)=>{let X=Z;if(Q.charAt(X)!=="[")throw Error("not in a brace expression");let q=[],Y=[],J=X+1,H=!1,W=!1,V=!1,K=!1,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(T5))if(Q.startsWith(U,J)){if(G)return["$.",!1,Q.length-X,!0];if(J+=U.length,R)Y.push(B);else q.push(B);W=W||M;continue Q}}if(V=!1,G){if(A>G)q.push(e0(G)+"-"+e0(A));else if(A===G)q.push(e0(A));G="",J++;continue}if(Q.startsWith("-]",J+1)){q.push(e0(A+"-")),J+=2;continue}if(Q.startsWith("-",J+1)){G=A,J+=2;continue}q.push(e0(A)),J++}if(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[w5(A),!1,z-X,!1]}let _="["+(K?"^":"")+c9(q)+"]",O="["+(K?"":"^")+c9(Y)+"]";return[q.length&&Y.length?"("+_+"|"+O+")":q.length?_:O,W,z-X,!0]};var G0=(Q,{windowsPathsNoEscape:Z=!1}={})=>{return Z?Q.replace(/\[([^\/\\])\]/g,"$1"):Q.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var S5=new Set(["!","?","+","*","@"]),d9=(Q)=>S5.has(Q),N5="(?!(?:^|/)\\.\\.?(?:$|/))",w8="(?!\\.)",P5=new Set(["[","."]),b5=new Set(["..","."]),k5=new Set("().*{}+?[]^$\\!"),D5=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),a6="[^/]",i9=a6+"*?",p9=a6+"+?";class n{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 n&&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 n&&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 n(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&&d9($)&&Q.charAt(_)==="("){Z.push(O),O="";let A=new n($,Z);_=n.#O(Q,A,_,q),Z.push(A);continue}O+=$}return Z.push(O),_}let V=X+1,K=new n(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(d9(_)&&Q.charAt(V)==="("){K.push(G),G="";let O=new n(_,K);K.push(O),V=n.#O(Q,O,V,q);continue}if(_==="|"){K.push(G),G="",z.push(K),K=new n(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 n(null,void 0,Z);return n.#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"?n.#$(_,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&&b5.has(this.#q[0]))){let O=P5,$=Z&&O.has(V.charAt(0))||V.startsWith("\\.")&&O.has(V.charAt(2))||V.startsWith("\\.\\.")&&O.has(V.charAt(4)),A=!Z&&!Q&&O.has(V.charAt(0));K=$?N5:A?w8:""}}}let z="";if(this.isEnd()&&this.#Z.#K&&this.#J?.type==="!")z="(?:$|\\/)";return[K+V+z,G0(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,G0(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:"")+p9;else{let W=this.type==="!"?"))"+(this.isStart()&&!Z&&!Q?w8:"")+i9+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&J?")":this.type==="*"&&J?")?":`)${this.type}`;H=q+Y+W}return[H,G0(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+=(k5.has(W)?"\\":"")+W;continue}if(W==="\\"){if(H===Q.length-1)Y+="\\\\";else q=!0;continue}if(W==="["){let[V,K,z,G]=l9(Q,H);if(z){Y+=V,J=J||K,H+=z-1,Z=Z||G;continue}}if(W==="*"){if(X&&Q==="*")Y+=p9;else Y+=i9;Z=!0;continue}if(W==="?"){Y+=a6,Z=!0;continue}Y+=D5(W)}return[Y,G0(Q),!!Z,J]}}var m0=(Q,{windowsPathsNoEscape:Z=!1}={})=>{return Z?Q.replace(/[?*()[\]]/g,"[$&]"):Q.replace(/[?*()[\]\\]/g,"\\$&")};var Z0=(Q,Z,X={})=>{if(t0(Z),!X.nocomment&&Z.charAt(0)==="#")return!1;return new V0(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=s9([Q]);if(!Z)return X;return Z=Z.toLowerCase(),(q)=>X(q)&&q.toLowerCase().endsWith(Z)},n5=([Q,Z=""])=>{let X=o9([Q]);if(!Z)return X;return Z=Z.toLowerCase(),(q)=>X(q)&&q.toLowerCase().endsWith(Z)},r5=([Q,Z=""])=>{let X=o9([Q]);return!Z?X:(q)=>X(q)&&q.endsWith(Z)},s5=([Q,Z=""])=>{let X=s9([Q]);return!Z?X:(q)=>X(q)&&q.endsWith(Z)},s9=([Q])=>{let Z=Q.length;return(X)=>X.length===Z&&!X.startsWith(".")},o9=([Q])=>{let Z=Q.length;return(X)=>X.length===Z&&X!=="."&&X!==".."},t9=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",a9={win32:{sep:"\\"},posix:{sep:"/"}},o5=t9==="win32"?a9.win32.sep:a9.posix.sep;Z0.sep=o5;var r=Symbol("globstar **");Z0.GLOBSTAR=r;var t5="[^/]",e5=t5+"*?",Q4="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Z4="(?:(?!(?:\\/|^)\\.).)*?",X4=(Q,Z={})=>(X)=>Z0(X,Q,Z);Z0.filter=X4;var H0=(Q,Z={})=>Object.assign({},Q,Z),q4=(Q)=>{if(!Q||typeof Q!=="object"||!Object.keys(Q).length)return Z0;let Z=Z0;return Object.assign((q,Y,J={})=>Z(q,Y,H0(Q,J)),{Minimatch:class extends Z.Minimatch{constructor(Y,J={}){super(Y,H0(Q,J))}static defaults(Y){return Z.defaults(H0(Q,Y)).Minimatch}},AST:class extends Z.AST{constructor(Y,J,H={}){super(Y,J,H0(Q,H))}static fromGlob(Y,J={}){return Z.AST.fromGlob(Y,H0(Q,J))}},unescape:(q,Y={})=>Z.unescape(q,H0(Q,Y)),escape:(q,Y={})=>Z.escape(q,H0(Q,Y)),filter:(q,Y={})=>Z.filter(q,H0(Q,Y)),defaults:(q)=>Z.defaults(H0(Q,q)),makeRe:(q,Y={})=>Z.makeRe(q,H0(Q,Y)),braceExpand:(q,Y={})=>Z.braceExpand(q,H0(Q,Y)),match:(q,Y,J={})=>Z.match(q,Y,H0(Q,J)),sep:Z.sep,GLOBSTAR:r})};Z0.defaults=q4;var e9=(Q,Z={})=>{if(t0(Q),Z.nobrace||!/\{(?:(?!\{).)*\}/.test(Q))return[Q];return r9.default(Q)};Z0.braceExpand=e9;var Y4=(Q,Z={})=>new V0(Q,Z).makeRe();Z0.makeRe=Y4;var J4=(Q,Z,X={})=>{let q=new V0(Z,X);if(Q=Q.filter((Y)=>q.match(Y)),q.options.nonull&&!Q.length)Q.push(Z);return Q};Z0.match=J4;var n9=/[?*]|[+@!]\(.*?\)|\[|\]/,W4=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class V0{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(Q,Z={}){if(t0(Q),Z=Z||{},this.options=Z,this.pattern=Q,this.platform=Z.platform||t9,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z.allowWindowsEscape===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!Z.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!Z.nonegate,this.comment=!1,this.empty=!1,this.partial=!!Z.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=Z.windowsNoMagicRoot!==void 0?Z.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let Q of this.set)for(let Z of Q)if(typeof Z!=="string")return!0;return!1}debug(...Q){}make(){let Q=this.pattern,Z=this.options;if(!Z.nocomment&&Q.charAt(0)==="#"){this.comment=!0;return}if(!Q){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],Z.debug)this.debug=(...Y)=>console.error(...Y);this.debug(this.pattern,this.globSet);let X=this.globSet.map((Y)=>this.slashSplit(Y));this.globParts=this.preprocess(X),this.debug(this.pattern,this.globParts);let q=this.globParts.map((Y,J,H)=>{if(this.isWindows&&this.windowsNoMagicRoot){let W=Y[0]===""&&Y[1]===""&&(Y[2]==="?"||!n9.test(Y[2]))&&!n9.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===r){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
10
|
globstar while`,Q,G,Z,_,O),this.matchOne(Q.slice(G),Z.slice(_),X))return this.debug("globstar found match!",G,W,O),!0;else{if(O==="."||O===".."||!q.dot&&O.charAt(0)==="."){this.debug("dot detected!",Q,G,Z,_);break}this.debug("globstar swallow a segment, and continue"),G++}}if(X){if(this.debug(`
|
|
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 e9(this.pattern,this.options)}parse(Q){t0(Q);let Z=this.options;if(Q==="**")return r;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=n.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===r?r:K._src});return V.forEach((K,z)=>{let G=V[z+1],_=V[z-1];if(K!==r||_===r)return;if(_===void 0)if(G!==void 0&&G!==r)V[z+1]="(?:\\/|"+X+"\\/)?"+G;else V[z]=X;else if(G===void 0)V[z-1]=_+"(?:\\/|"+X+")?";else if(G!==r)V[z-1]=_+"(?:\\/|\\/"+X+"\\/)"+G,V[z+1]=r}),V.filter((K)=>K!==r).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 Z0.defaults(Q).Minimatch}}Z0.AST=n;Z0.Minimatch=V0;Z0.escape=m0;Z0.unescape=G0;import{fileURLToPath as f4}from"node:url";var c0=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,ZQ=new Set,n6=typeof process==="object"&&!!process?process:{},XQ=(Q,Z,X,q)=>{typeof n6.emitWarning==="function"?n6.emitWarning(Q,Z,X,q):console.error(`[${X}] ${Z}: ${Q}`)},S8=globalThis.AbortController,QQ=globalThis.AbortSignal;if(typeof S8>"u"){QQ=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(q,Y){this._onabort.push(Y)}},S8=class{constructor(){Z()}signal=new QQ;abort(q){if(this.signal.aborted)return;this.signal.reason=q,this.signal.aborted=!0;for(let Y of this.signal._onabort)Y(q);this.signal.onabort?.(q)}};let Q=n6.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",Z=()=>{if(!Q)return;Q=!1,XQ("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",Z)}}var H4=(Q)=>!ZQ.has(Q),oq=Symbol("type"),b0=(Q)=>Q&&Q===Math.floor(Q)&&Q>0&&isFinite(Q),qQ=(Q)=>!b0(Q)?null:Q<=Math.pow(2,8)?Uint8Array:Q<=Math.pow(2,16)?Uint16Array:Q<=Math.pow(2,32)?Uint32Array:Q<=Number.MAX_SAFE_INTEGER?Q8:null;class Q8 extends Array{constructor(Q){super(Q);this.fill(0)}}class l0{heap;length;static#Z=!1;static create(Q){let Z=qQ(Q);if(!Z)return[];l0.#Z=!0;let X=new l0(Q,Z);return l0.#Z=!1,X}constructor(Q,Z){if(!l0.#Z)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new Z(Q),this.length=0}push(Q){this.heap[this.length++]=Q}pop(){return this.heap[--this.length]}}class Z8{#Z;#Q;#X;#q;#J;#C;#I;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#K;#G;#V;#z;#Y;#O;#M;#$;#A;#j;#R;#F;#H;#L;#_;#T;#B;#b;static unsafeExposeInternals(Q){return{starts:Q.#H,ttls:Q.#L,sizes:Q.#F,keyMap:Q.#V,keyList:Q.#z,valList:Q.#Y,next:Q.#O,prev:Q.#M,get head(){return Q.#$},get tail(){return Q.#A},free:Q.#j,isBackgroundFetch:(Z)=>Q.#U(Z),backgroundFetch:(Z,X,q,Y)=>Q.#E(Z,X,q,Y),moveToTail:(Z)=>Q.#f(Z),indexes:(Z)=>Q.#N(Z),rindexes:(Z)=>Q.#P(Z),isStale:(Z)=>Q.#S(Z)}}get max(){return this.#Z}get maxSize(){return this.#Q}get calculatedSize(){return this.#G}get size(){return this.#K}get fetchMethod(){return this.#C}get memoMethod(){return this.#I}get dispose(){return this.#X}get onInsert(){return this.#q}get disposeAfter(){return this.#J}constructor(Q){let{max:Z=0,ttl:X,ttlResolution:q=1,ttlAutopurge:Y,updateAgeOnGet:J,updateAgeOnHas:H,allowStale:W,dispose:V,onInsert:K,disposeAfter: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&&!b0(Z))throw TypeError("max option must be a nonnegative integer");let v=Z?qQ(Z):Array;if(!v)throw Error("invalid max value: "+Z);if(this.#Z=Z,this.#Q=O,this.maxEntrySize=$||this.#Q,this.sizeCalculation=A,this.sizeCalculation){if(!this.#Q&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw TypeError("sizeCalculation set to non-function")}if(B!==void 0&&typeof B!=="function")throw TypeError("memoMethod must be a function if defined");if(this.#I=B,U!==void 0&&typeof U!=="function")throw TypeError("fetchMethod must be a function if specified");if(this.#C=U,this.#T=!!U,this.#V=new Map,this.#z=Array(Z).fill(void 0),this.#Y=Array(Z).fill(void 0),this.#O=new v(Z),this.#M=new v(Z),this.#$=0,this.#A=0,this.#j=l0.create(Z),this.#K=0,this.#G=0,typeof V==="function")this.#X=V;if(typeof K==="function")this.#q=K;if(typeof 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(!b0(this.#Q))throw TypeError("maxSize must be a positive integer if specified")}if(!b0(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=b0(q)||q===0?q:1,this.ttlAutopurge=!!Y,this.ttl=X||0,this.ttl){if(!b0(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#W()}if(this.#Z===0&&this.ttl===0&&this.#Q===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Z&&!this.#Q){if(H4("LRU_CACHE_UNBOUNDED"))ZQ.add("LRU_CACHE_UNBOUNDED"),XQ("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",Z8)}}getRemainingTTL(Q){return this.#V.has(Q)?1/0:0}#W(){let Q=new Q8(this.#Z),Z=new Q8(this.#Z);this.#L=Q,this.#H=Z,this.#k=(Y,J,H=c0.now())=>{if(Z[Y]=J!==0?H:0,Q[Y]=J,J!==0&&this.ttlAutopurge){let W=setTimeout(()=>{if(this.#S(Y))this.#D(this.#z[Y],"expire")},J+1);if(W.unref)W.unref()}},this.#v=(Y)=>{Z[Y]=Q[Y]!==0?c0.now():0},this.#w=(Y,J)=>{if(Q[J]){let H=Q[J],W=Z[J];if(!H||!W)return;Y.ttl=H,Y.start=W,Y.now=X||q();let V=Y.now-W;Y.remainingTTL=H-V}};let X=0,q=()=>{let Y=c0.now();if(this.ttlResolution>0){X=Y;let J=setTimeout(()=>X=0,this.ttlResolution);if(J.unref)J.unref()}return Y};this.getRemainingTTL=(Y)=>{let J=this.#V.get(Y);if(J===void 0)return 0;let H=Q[J],W=Z[J];if(!H||!W)return 1/0;let V=(X||q())-W;return H-V},this.#S=(Y)=>{let J=Z[Y],H=Q[Y];return!!H&&!!J&&(X||q())-J>H}}#v=()=>{};#w=()=>{};#k=()=>{};#S=()=>!1;#g(){let Q=new Q8(this.#Z);this.#G=0,this.#F=Q,this.#y=(Z)=>{this.#G-=Q[Z],Q[Z]=0},this.#m=(Z,X,q,Y)=>{if(this.#U(X))return 0;if(!b0(q))if(Y){if(typeof Y!=="function")throw TypeError("sizeCalculation must be a function");if(q=Y(X,Z),!b0(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-(c0.now()-H);Y.ttl=W,Y.start=Date.now()}}if(this.#F)Y.size=this.#F[Z];return Y}dump(){let Q=[];for(let Z of this.#N({allowStale:!0})){let X=this.#z[Z],q=this.#Y[Z],Y=this.#U(q)?q.__staleWhileFetching:q;if(Y===void 0||X===void 0)continue;let J={value:Y};if(this.#L&&this.#H){J.ttl=this.#L[Z];let H=c0.now()-this.#H[Z];J.start=Math.floor(Date.now()-H)}if(this.#F)J.size=this.#F[Z];Q.unshift([X,J])}return Q}load(Q){this.clear();for(let[Z,X]of Q){if(X.start){let q=Date.now()-X.start;X.start=c0.now()-q}this.set(Z,X.value,X)}}set(Q,Z,X={}){if(Z===void 0)return this.delete(Q),this;let{ttl:q=this.ttl,start:Y,noDisposeOnSet:J=this.noDisposeOnSet,sizeCalculation:H=this.sizeCalculation,status:W}=X,{noUpdateTTL:V=this.noUpdateTTL}=X,K=this.#m(Q,Z,X.size||0,H);if(this.maxEntrySize&&K>this.maxEntrySize){if(W)W.set="miss",W.maxEntrySizeExceeded=!0;return this.#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 W0=X&&F.__staleWhileFetching!==void 0;if(U){if(U.fetch="inflight",W0)U.returnedStale=!0}return W0?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,$),J0=y.__staleWhileFetching!==void 0&&X;if(U){if(U.fetch=S?"stale":"refresh",J0&&S)U.returnedStale=!0}return J0?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 Y7}from"node:path";import{fileURLToPath as R4}from"node:url";import{lstatSync as I4,readdir as C4,readdirSync as L4,readlinkSync as F4,realpathSync as j4}from"fs";import*as T4 from"node:fs";import{lstat as S4,readdir as N4,readlink as P4,realpath as b4}from"node:fs/promises";import{EventEmitter as Q7}from"node:events";import VQ from"node:stream";import{StringDecoder as V4}from"node:string_decoder";var YQ=typeof process==="object"&&process?process:{stdout:null,stderr:null},K4=(Q)=>!!Q&&typeof Q==="object"&&(Q instanceof u0||Q instanceof VQ||_4(Q)||z4(Q)),_4=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof Q7&&typeof Q.pipe==="function"&&Q.pipe!==VQ.Writable.prototype.pipe,z4=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof Q7&&typeof Q.write==="function"&&typeof Q.end==="function",L0=Symbol("EOF"),F0=Symbol("maybeEmitEnd"),k0=Symbol("emittedEnd"),N8=Symbol("emittingEnd"),X8=Symbol("emittedError"),P8=Symbol("closed"),JQ=Symbol("read"),b8=Symbol("flush"),WQ=Symbol("flushChunk"),U0=Symbol("encoding"),d0=Symbol("decoder"),i=Symbol("flowing"),q8=Symbol("paused"),i0=Symbol("resume"),p=Symbol("buffer"),X0=Symbol("pipes"),a=Symbol("bufferLength"),r6=Symbol("bufferPush"),k8=Symbol("bufferShift"),e=Symbol("objectMode"),m=Symbol("destroyed"),s6=Symbol("error"),o6=Symbol("emitData"),HQ=Symbol("emitEnd"),t6=Symbol("emitEnd2"),O0=Symbol("async"),e6=Symbol("abort"),D8=Symbol("aborted"),Y8=Symbol("signal"),x0=Symbol("dataListeners"),Y0=Symbol("discarded"),J8=(Q)=>Promise.resolve().then(Q),G4=(Q)=>Q(),U4=(Q)=>Q==="end"||Q==="finish"||Q==="prefinish",$4=(Q)=>Q instanceof ArrayBuffer||!!Q&&typeof Q==="object"&&Q.constructor&&Q.constructor.name==="ArrayBuffer"&&Q.byteLength>=0,M4=(Q)=>!Buffer.isBuffer(Q)&&ArrayBuffer.isView(Q);class Z7{src;dest;opts;ondrain;constructor(Q,Z,X){this.src=Q,this.dest=Z,this.opts=X,this.ondrain=()=>Q[i0](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(Q){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class KQ extends Z7{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(Q,Z,X){super(Q,Z,X);this.proxyErrors=(q)=>Z.emit("error",q),Q.on("error",this.proxyErrors)}}var O4=(Q)=>!!Q.objectMode,A4=(Q)=>!Q.objectMode&&!!Q.encoding&&Q.encoding!=="buffer";class u0 extends Q7{[i]=!1;[q8]=!1;[X0]=[];[p]=[];[e];[U0];[O0];[d0];[L0]=!1;[k0]=!1;[N8]=!1;[P8]=!1;[X8]=null;[a]=0;[m]=!1;[Y8];[D8]=!1;[x0]=0;[Y0]=!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[U0]=null;else if(A4(Z))this[U0]=Z.encoding,this[e]=!1;else this[e]=!1,this[U0]=null;if(this[O0]=!!Z.async,this[d0]=this[U0]?new V4(this[U0]):null,Z&&Z.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[p]});if(Z&&Z.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[X0]});let{signal:X}=Z;if(X)if(this[Y8]=X,X.aborted)this[e6]();else X.addEventListener("abort",()=>this[e6]())}get bufferLength(){return this[a]}get encoding(){return this[U0]}set encoding(Q){throw Error("Encoding must be set at instantiation time")}setEncoding(Q){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[e]}set objectMode(Q){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[O0]}set["async"](Q){this[O0]=this[O0]||!!Q}[e6](){this[D8]=!0,this.emit("abort",this[Y8]?.reason),this.destroy(this[Y8]?.reason)}get aborted(){return this[D8]}set aborted(Q){}write(Q,Z,X){if(this[D8])return!1;if(this[L0])throw Error("write after end");if(this[m])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof Z==="function")X=Z,Z="utf8";if(!Z)Z="utf8";let q=this[O0]?J8:G4;if(!this[e]&&!Buffer.isBuffer(Q)){if(M4(Q))Q=Buffer.from(Q.buffer,Q.byteOffset,Q.byteLength);else if($4(Q))Q=Buffer.from(Q);else if(typeof Q!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[e]){if(this[i]&&this[a]!==0)this[b8](!0);if(this[i])this.emit("data",Q);else this[r6](Q);if(this[a]!==0)this.emit("readable");if(X)q(X);return this[i]}if(!Q.length){if(this[a]!==0)this.emit("readable");if(X)q(X);return this[i]}if(typeof Q==="string"&&!(Z===this[U0]&&!this[d0]?.lastNeed))Q=Buffer.from(Q,Z);if(Buffer.isBuffer(Q)&&this[U0])Q=this[d0].write(Q);if(this[i]&&this[a]!==0)this[b8](!0);if(this[i])this.emit("data",Q);else this[r6](Q);if(this[a]!==0)this.emit("readable");if(X)q(X);return this[i]}read(Q){if(this[m])return null;if(this[Y0]=!1,this[a]===0||Q===0||Q&&Q>this[a])return this[F0](),null;if(this[e])Q=null;if(this[p].length>1&&!this[e])this[p]=[this[U0]?this[p].join(""):Buffer.concat(this[p],this[a])];let Z=this[JQ](Q||null,this[p][0]);return this[F0](),Z}[JQ](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[p][0]=X.slice(Q),Z=X.slice(0,Q),this[a]-=Q;else this[p][0]=X.subarray(Q),Z=X.subarray(0,Q),this[a]-=Q}if(this.emit("data",Z),!this[p].length&&!this[L0])this.emit("drain");return Z}end(Q,Z,X){if(typeof Q==="function")X=Q,Q=void 0;if(typeof Z==="function")X=Z,Z="utf8";if(Q!==void 0)this.write(Q,Z);if(X)this.once("end",X);if(this[L0]=!0,this.writable=!1,this[i]||!this[q8])this[F0]();return this}[i0](){if(this[m])return;if(!this[x0]&&!this[X0].length)this[Y0]=!0;if(this[q8]=!1,this[i]=!0,this.emit("resume"),this[p].length)this[b8]();else if(this[L0])this[F0]();else this.emit("drain")}resume(){return this[i0]()}pause(){this[i]=!1,this[q8]=!0,this[Y0]=!1}get destroyed(){return this[m]}get flowing(){return this[i]}get paused(){return this[q8]}[r6](Q){if(this[e])this[a]+=1;else this[a]+=Q.length;this[p].push(Q)}[k8](){if(this[e])this[a]-=1;else this[a]-=this[p][0].length;return this[p].shift()}[b8](Q=!1){do;while(this[WQ](this[k8]())&&this[p].length);if(!Q&&!this[p].length&&!this[L0])this.emit("drain")}[WQ](Q){return this.emit("data",Q),this[i]}pipe(Q,Z){if(this[m])return Q;this[Y0]=!1;let X=this[k0];if(Z=Z||{},Q===YQ.stdout||Q===YQ.stderr)Z.end=!1;else Z.end=Z.end!==!1;if(Z.proxyErrors=!!Z.proxyErrors,X){if(Z.end)Q.end()}else if(this[X0].push(!Z.proxyErrors?new Z7(this,Q,Z):new KQ(this,Q,Z)),this[O0])J8(()=>this[i0]());else this[i0]();return Q}unpipe(Q){let Z=this[X0].find((X)=>X.dest===Q);if(Z){if(this[X0].length===1){if(this[i]&&this[x0]===0)this[i]=!1;this[X0]=[]}else this[X0].splice(this[X0].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[Y0]=!1,this[x0]++,!this[X0].length&&!this[i])this[i0]()}else if(Q==="readable"&&this[a]!==0)super.emit("readable");else if(U4(Q)&&this[k0])super.emit(Q),this.removeAllListeners(Q);else if(Q==="error"&&this[X8]){let q=Z;if(this[O0])J8(()=>q.call(this,this[X8]));else q.call(this,this[X8])}return X}removeListener(Q,Z){return this.off(Q,Z)}off(Q,Z){let X=super.off(Q,Z);if(Q==="data"){if(this[x0]=this.listeners("data").length,this[x0]===0&&!this[Y0]&&!this[X0].length)this[i]=!1}return X}removeAllListeners(Q){let Z=super.removeAllListeners(Q);if(Q==="data"||Q===void 0){if(this[x0]=0,!this[Y0]&&!this[X0].length)this[i]=!1}return Z}get emittedEnd(){return this[k0]}[F0](){if(!this[N8]&&!this[k0]&&!this[m]&&this[p].length===0&&this[L0]){if(this[N8]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[P8])this.emit("close");this[N8]=!1}}emit(Q,...Z){let X=Z[0];if(Q!=="error"&&Q!=="close"&&Q!==m&&this[m])return!1;else if(Q==="data")return!this[e]&&!X?!1:this[O0]?(J8(()=>this[o6](X)),!0):this[o6](X);else if(Q==="end")return this[HQ]();else if(Q==="close"){if(this[P8]=!0,!this[k0]&&!this[m])return!1;let Y=super.emit("close");return this.removeAllListeners("close"),Y}else if(Q==="error"){this[X8]=X,super.emit(s6,X);let Y=!this[Y8]||this.listeners("error").length?super.emit("error",X):!1;return this[F0](),Y}else if(Q==="resume"){let Y=super.emit("resume");return this[F0](),Y}else if(Q==="finish"||Q==="prefinish"){let Y=super.emit(Q);return this.removeAllListeners(Q),Y}let q=super.emit(Q,...Z);return this[F0](),q}[o6](Q){for(let X of this[X0])if(X.dest.write(Q)===!1)this.pause();let Z=this[Y0]?!1:super.emit("data",Q);return this[F0](),Z}[HQ](){if(this[k0])return!1;return this[k0]=!0,this.readable=!1,this[O0]?(J8(()=>this[t6]()),!0):this[t6]()}[t6](){if(this[d0]){let Z=this[d0].end();if(Z){for(let X of this[X0])X.dest.write(Z);if(!this[Y0])super.emit("data",Z)}}for(let Z of this[X0])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[U0]?Q.join(""):Buffer.concat(Q,Q.dataLength)}async promise(){return new Promise((Q,Z)=>{this.on(m,()=>Z(Error("stream destroyed"))),this.on("error",(X)=>Z(X)),this.on("end",()=>Q())})}[Symbol.asyncIterator](){this[Y0]=!1;let Q=!1,Z=async()=>{return this.pause(),Q=!0,{value:void 0,done:!0}};return{next:()=>{if(Q)return Z();let q=this.read();if(q!==null)return Promise.resolve({done:!1,value:q});if(this[L0])return Z();let Y,J,H=(z)=>{this.off("data",W),this.off("end",V),this.off(m,K),Z(),J(z)},W=(z)=>{this.off("error",H),this.off("end",V),this.off(m,K),this.pause(),Y({value:z,done:!!this[L0]})},V=()=>{this.off("error",H),this.off("data",W),this.off(m,K),Z(),Y({done:!0,value:void 0})},K=()=>H(Error("stream destroyed"));return new Promise((z,G)=>{J=G,Y=z,this.once(m,K),this.once("error",H),this.once("end",V),this.once("data",W)})},throw:Z,return:Z,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[Y0]=!1;let Q=!1,Z=()=>{return this.pause(),this.off(s6,Z),this.off(m,Z),this.off("end",Z),Q=!0,{done:!0,value:void 0}},X=()=>{if(Q)return Z();let q=this.read();return q===null?Z():{done:!1,value:q}};return this.once("end",Z),this.once(s6,Z),this.once(m,Z),{next:X,throw:Z,return:Z,[Symbol.iterator](){return this}}}destroy(Q){if(this[m]){if(Q)this.emit("error",Q);else this.emit(m);return this}this[m]=!0,this[Y0]=!0,this[p].length=0,this[a]=0;let Z=this;if(typeof Z.close==="function"&&!this[P8])Z.close();if(Q)this.emit("error",Q);else this.emit(m);return this}static get isStream(){return K4}}var w4=j4.native,H8={lstatSync:I4,readdir:C4,readdirSync:L4,readlinkSync:F4,realpathSync:w4,promises:{lstat:S4,readdir:N4,readlink:P4,realpath:b4}},$Q=(Q)=>!Q||Q===H8||Q===T4?H8:{...H8,...Q,promises:{...H8.promises,...Q.promises||{}}},MQ=/^\\\\\?\\([a-z]:)\\?$/i,k4=(Q)=>Q.replace(/\//g,"\\").replace(MQ,"$1\\"),D4=/[\\\/]/,_0=0,OQ=1,AQ=2,A0=4,BQ=6,RQ=8,f0=10,IQ=12,K0=15,W8=~K0,X7=16,_Q=32,V8=64,$0=128,v8=256,E8=512,zQ=V8|$0|E8,v4=1023,q7=(Q)=>Q.isFile()?RQ:Q.isDirectory()?A0:Q.isSymbolicLink()?f0:Q.isCharacterDevice()?AQ:Q.isBlockDevice()?BQ:Q.isSocket()?IQ:Q.isFIFO()?OQ:_0,GQ=new Map,K8=(Q)=>{let Z=GQ.get(Q);if(Z)return Z;let X=Q.normalize("NFKD");return GQ.set(Q,X),X},UQ=new Map,y8=(Q)=>{let Z=UQ.get(Q);if(Z)return Z;let X=K8(Q.toLowerCase());return UQ.set(Q,X),X};class J7 extends Z8{constructor(){super({max:256})}}class CQ extends Z8{constructor(Q=16384){super({maxSize:Q,sizeCalculation:(Z)=>Z.length+1})}}var LQ=Symbol("PathScurry setAsCwd");class q0{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=_0,X,q,Y,J,H){if(this.name=Q,this.#H=Y?y8(Q):K8(Q),this.#W=Z&v4,this.nocase=Y,this.roots=q,this.root=X||this,this.#v=J,this.#_=H.fullpath,this.#B=H.relative,this.#b=H.relativePosix,this.parent=H.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=$Q(H.fs)}depth(){if(this.#L!==void 0)return this.#L;if(!this.parent)return this.#L=0;return this.#L=this.parent.depth()+1}childrenCache(){return this.#v}resolve(Q){if(!Q)return this;let Z=this.getRootString(Q),q=Q.substring(Z.length).split(this.splitSep);return Z?this.getRoot(Z).#S(q):this.#S(q)}#S(Q){let Z=this;for(let X of Q)Z=Z.child(X);return Z}children(){let Q=this.#v.get(this);if(Q)return Q;let Z=Object.assign([],{provisional:0});return this.#v.set(this,Z),this.#W&=~X7,Z}child(Q,Z){if(Q===""||Q===".")return this;if(Q==="..")return this.parent||this;let X=this.children(),q=this.nocase?y8(Q):K8(Q);for(let W of X)if(W.#H===q)return W;let Y=this.parent?this.sep:"",J=this.#_?this.#_+Y+Q:void 0,H=this.newChild(Q,_0,{...Z,parent:this,fullpath:J});if(!this.canReaddir())H.#W|=$0;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&K0)===_0}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&K0)===RQ}isDirectory(){return(this.#W&K0)===A0}isCharacterDevice(){return(this.#W&K0)===AQ}isBlockDevice(){return(this.#W&K0)===BQ}isFIFO(){return(this.#W&K0)===OQ}isSocket(){return(this.#W&K0)===IQ}isSymbolicLink(){return(this.#W&f0)===f0}lstatCached(){return this.#W&_Q?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&K0;return!(Q!==_0&&Q!==f0||this.#W&v8||this.#W&$0)}calledReaddir(){return!!(this.#W&X7)}isENOENT(){return!!(this.#W&$0)}isNamed(Q){return!this.nocase?this.#H===K8(Q):this.#H===y8(Q)}async readlink(){let Q=this.#w;if(Q)return Q;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=await this.#Z.promises.readlink(this.fullpath()),X=(await this.parent.realpath())?.resolve(Z);if(X)return this.#w=X}catch(Z){this.#u(Z.code);return}}readlinkSync(){let Q=this.#w;if(Q)return Q;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=this.#Z.readlinkSync(this.fullpath()),X=this.parent.realpathSync()?.resolve(Z);if(X)return this.#w=X}catch(Z){this.#u(Z.code);return}}#g(Q){this.#W|=X7;for(let Z=Q.provisional;Z<Q.length;Z++){let X=Q[Z];if(X)X.#y()}}#y(){if(this.#W&$0)return;this.#W=(this.#W|$0)&W8,this.#x()}#x(){let Q=this.children();Q.provisional=0;for(let Z of Q)Z.#y()}#m(){this.#W|=E8,this.#N()}#N(){if(this.#W&V8)return;let Q=this.#W;if((Q&K0)===A0)Q&=W8;this.#W=Q|V8,this.#x()}#P(Q=""){if(Q==="ENOTDIR"||Q==="EPERM")this.#N();else if(Q==="ENOENT")this.#y();else this.children().provisional=0}#c(Q=""){if(Q==="ENOTDIR")this.parent.#N();else if(Q==="ENOENT")this.#y()}#u(Q=""){let Z=this.#W;if(Z|=v8,Q==="ENOENT")Z|=$0;if(Q==="EINVAL"||Q==="UNKNOWN")Z&=W8;if(this.#W=Z,Q==="ENOTDIR"&&this.parent)this.parent.#N()}#E(Q,Z){return this.#l(Q,Z)||this.#U(Q,Z)}#U(Q,Z){let X=q7(Q),q=this.newChild(Q.name,X,{parent:this}),Y=q.#W&K0;if(Y!==A0&&Y!==f0&&Y!==_0)q.#W|=V8;return Z.unshift(q),Z.provisional++,q}#l(Q,Z){for(let X=Z.provisional;X<Z.length;X++){let q=Z[X];if((this.nocase?y8(Q.name):K8(Q.name))!==q.#H)continue;return this.#f(Q,q,X,Z)}}#f(Q,Z,X,q){let Y=Z.name;if(Z.#W=Z.#W&W8|q7(Q),Y!==Q.name)Z.name=Q.name;if(X!==q.provisional){if(X===q.length-1)q.pop();else q.splice(X,1);q.unshift(Z)}return q.provisional++,Z}async lstat(){if((this.#W&$0)===0)try{return this.#D(await this.#Z.promises.lstat(this.fullpath())),this}catch(Q){this.#c(Q.code)}}lstatSync(){if((this.#W&$0)===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=q7(Q);if(this.#W=this.#W&W8|R|_Q,R!==_0&&R!==A0&&R!==f0)this.#W|=V8}#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&zQ)return!1;let Q=K0&this.#W;if(!(Q===_0||Q===A0||Q===f0))return!1;return!0}shouldWalk(Q,Z){return(this.#W&A0)===A0&&!(this.#W&zQ)&&!Q.has(this)&&(!Z||Z(this))}async realpath(){if(this.#k)return this.#k;if((E8|v8|$0)&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|$0)&this.#W)return;try{let Q=this.#Z.realpathSync(this.fullpath());return this.#k=this.resolve(Q)}catch(Q){this.#m()}}[LQ](Q){if(Q===this)return;Q.isCWD=!1,this.isCWD=!0;let Z=new Set([]),X=[],q=this;while(q&&q.parent)Z.add(q),q.#B=X.join(this.sep),q.#b=X.join("/"),q=q.parent,X.push("..");q=Q;while(q&&q.parent&&!Z.has(q))q.#B=void 0,q.#b=void 0,q=q.parent}}class x8 extends q0{sep="\\";splitSep=D4;constructor(Q,Z=_0,X,q,Y,J,H){super(Q,Z,X,q,Y,J,H)}newChild(Q,Z=_0,X={}){return new x8(Q,Z,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Q){return Y7.parse(Q).root}getRoot(Q){if(Q=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 _8(Q,this).root}sameRoot(Q,Z=this.root.name){return Q=Q.toUpperCase().replace(/\//g,"\\").replace(MQ,"$1\\"),Q===Z}}class u8 extends q0{splitSep="/";sep="/";constructor(Q,Z=_0,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=_0,X={}){return new u8(Q,Z,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class W7{root;rootPath;roots;cwd;#Z;#Q;#X;nocase;#q;constructor(Q=process.cwd(),Z,X,{nocase:q,childrenCacheSize:Y=16384,fs:J=H8}={}){if(this.#q=$Q(J),Q instanceof URL||Q.startsWith("file://"))Q=R4(Q);let H=Z.resolve(Q);this.roots=Object.create(null),this.rootPath=this.parseRootPath(H),this.#Z=new J7,this.#Q=new J7,this.#X=new CQ(Y);let W=H.substring(this.rootPath.length).split(X);if(W.length===1&&!W[0])W.pop();if(q===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=q,this.root=this.newRoot(this.#q),this.roots[this.rootPath]=this.root;let V=this.root,K=W.length-1,z=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 q0))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 q0))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 q0))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 q0))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 q0))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 q0))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 q0))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 q0))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 q0))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 q0))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 q0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z,H=new u0({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 q0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z,H=new u0({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[LQ](Z)}}class _8 extends W7{sep="\\";constructor(Q=process.cwd(),Z={}){let{nocase:X=!0}=Z;super(Q,Y7,"\\",{...Z,nocase:X});this.nocase=X;for(let q=this.cwd;q;q=q.parent)q.nocase=this.nocase}parseRootPath(Q){return Y7.parse(Q).root.toUpperCase()}newRoot(Q){return new x8(this.rootPath,A0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")||Q.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Q)}}class z8 extends W7{sep="/";constructor(Q=process.cwd(),Z={}){let{nocase:X=!1}=Z;super(Q,B4,"/",{...Z,nocase:X});this.nocase=X}parseRootPath(Q){return"/"}newRoot(Q){return new u8(this.rootPath,A0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")}}class f8 extends z8{constructor(Q=process.cwd(),Z={}){let{nocase:X=!0}=Z;super(Q,{...Z,nocase:X})}}var KY=process.platform==="win32"?x8:u8,FQ=process.platform==="win32"?_8:process.platform==="darwin"?f8:z8;var y4=(Q)=>Q.length>=1,E4=(Q)=>Q.length>=1;class p0{#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]===r}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 p0(this.#Z,this.#Q,this.#X+1,this.#q),this.#J.#G=this.#G,this.#J.#K=this.#K,this.#J.#I=this.#I,this.#J}isUNC(){let Q=this.#Z;return this.#K!==void 0?this.#K:this.#K=this.#q==="win32"&&this.#X===0&&Q[0]===""&&Q[1]===""&&typeof Q[2]==="string"&&!!Q[2]&&typeof Q[3]==="string"&&!!Q[3]}isDrive(){let Q=this.#Z;return this.#I!==void 0?this.#I:this.#I=this.#q==="win32"&&this.#X===0&&this.length>1&&typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0])}isAbsolute(){let Q=this.#Z;return this.#G!==void 0?this.#G:this.#G=Q[0]===""&&Q.length>1||this.isDrive()||this.isUNC()}root(){let Q=this.#Z[0];return typeof Q==="string"&&this.isAbsolute()&&this.#X===0?Q:""}checkFollowGlobstar(){return!(this.#X===0||!this.isGlobstar()||!this.#V)}markFollowGlobstar(){if(this.#X===0||!this.isGlobstar()||!this.#V)return!1;return this.#V=!1,!0}}var x4=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class G8{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Q,{nobrace:Z,nocase:X,noext:q,noglobstar:Y,platform:J=x4}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=J,this.mmopts={dot:!0,nobrace:Z,nocase:X,noext:q,noglobstar:Y,optimizationLevel:2,platform:J,nocomment:!0,nonegate:!0};for(let H of Q)this.add(H)}add(Q){let Z=new V0(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 p0(q,Y,0,this.platform),H=new V0(J.globString(),this.mmopts),W=Y[Y.length-1]==="**",V=J.isAbsolute();if(V)this.absolute.push(H);else this.relative.push(H);if(W)if(V)this.absoluteChildren.push(H);else this.relativeChildren.push(H)}}ignored(Q){let Z=Q.fullpath(),X=`${Z}/`,q=Q.relative()||".",Y=`${q}/`;for(let J of this.relative)if(J.match(q)||J.match(Y))return!0;for(let J of this.absolute)if(J.match(Z)||J.match(X))return!0;return!1}childrenIgnored(Q){let Z=Q.fullpath()+"/",X=(Q.relative()||".")+"/";for(let q of this.relativeChildren)if(q.match(X))return!0;for(let q of this.absoluteChildren)if(q.match(Z))return!0;return!1}}class H7{store;constructor(Q=new Map){this.store=Q}copy(){return new H7(new Map(this.store))}hasWalked(Q,Z){return this.store.get(Q.fullpath())?.has(Z.globString())}storeWalked(Q,Z){let X=Q.fullpath(),q=this.store.get(X);if(q)q.add(Z.globString());else this.store.set(X,new Set([Z.globString()]))}}class jQ{store=new Map;add(Q,Z,X){let q=(Z?2:0)|(X?1:0),Y=this.store.get(Q);this.store.set(Q,Y===void 0?q:q&Y)}entries(){return[...this.store.entries()].map(([Q,Z])=>[Q,!!(Z&2),!!(Z&1)])}}class TQ{store=new Map;add(Q,Z){if(!Q.canReaddir())return;let X=this.store.get(Q);if(X){if(!X.find((q)=>q.globString()===Z.globString()))X.push(Z)}else this.store.set(Q,[Z])}get(Q){let Z=this.store.get(Q);if(!Z)throw Error("attempting to walk unknown path");return Z}entries(){return this.keys().map((Q)=>[Q,this.store.get(Q)])}keys(){return[...this.store.keys()].filter((Q)=>Q.canReaddir())}}class U8{hasWalkedCache;matches=new jQ;subwalks=new TQ;patterns;follow;dot;opts;constructor(Q,Z){this.opts=Q,this.follow=!!Q.follow,this.dot=!!Q.dot,this.hasWalkedCache=Z?Z.copy():new H7}processPatterns(Q,Z){this.patterns=Z;let X=Z.map((q)=>[Q,q]);for(let[q,Y]of X){this.hasWalkedCache.storeWalked(q,Y);let J=Y.root(),H=Y.isAbsolute()&&this.opts.absolute!==!1;if(J){q=q.resolve(J==="/"&&this.opts.root!==void 0?this.opts.root:J);let 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===r){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 U8(this.opts,this.hasWalkedCache)}filterEntries(Q,Z){let X=this.subwalks.get(Q),q=this.child();for(let Y of Z)for(let J of X){let H=J.isAbsolute(),W=J.pattern(),V=J.rest();if(W===r)q.testGlobstar(Y,J,V,H);else if(W instanceof RegExp)q.testRegExp(Y,W,V,H);else q.testString(Y,W,V,H)}return q}testGlobstar(Q,Z,X,q){if(this.dot||!Q.name.startsWith(".")){if(!Z.hasMore())this.matches.add(Q,q,!1);if(Q.canReaddir()){if(this.follow||!Q.isSymbolicLink())this.subwalks.add(Q,Z);else if(Q.isSymbolicLink()){if(X&&Z.checkFollowGlobstar())this.subwalks.add(Q,X);else if(Z.markFollowGlobstar())this.subwalks.add(Q,Z)}}}if(X){let Y=X.pattern();if(typeof Y==="string"&&Y!==".."&&Y!==""&&Y!==".")this.testString(Q,Y,X.rest(),q);else if(Y===".."){let J=Q.parent||Q;this.subwalks.add(J,X)}else if(Y instanceof RegExp)this.testRegExp(Q,Y,X.rest(),q)}}testRegExp(Q,Z,X,q){if(!Z.test(Q.name))return;if(!X)this.matches.add(Q,q,!1);else this.subwalks.add(Q,X)}testString(Q,Z,X,q){if(!Q.isNamed(Z))return;if(!X)this.matches.add(Q,q,!1);else this.subwalks.add(Q,X)}}var u4=(Q,Z)=>typeof Q==="string"?new G8([Q],Z):Array.isArray(Q)?new G8(Q,Z):Q;class V7{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Z=[];#Q;#X;signal;maxDepth;includeChildMatches;constructor(Q,Z,X){if(this.patterns=Q,this.path=Z,this.opts=X,this.#X=!X.posix&&X.platform==="win32"?"\\":"/",this.includeChildMatches=X.includeChildMatches!==!1,X.ignore||!this.includeChildMatches){if(this.#Q=u4(X.ignore??[],X),!this.includeChildMatches&&typeof this.#Q.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=X.maxDepth||1/0,X.signal)this.signal=X.signal,this.signal.addEventListener("abort",()=>{this.#Z.length=0})}#q(Q){return this.seen.has(Q)||!!this.#Q?.ignored?.(Q)}#J(Q){return!!this.#Q?.childrenIgnored?.(Q)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let Q=void 0;while(!this.paused&&(Q=this.#Z.shift()))Q()}onResume(Q){if(this.signal?.aborted)return;if(!this.paused)Q();else this.#Z.push(Q)}async matchCheck(Q,Z){if(Z&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Q.realpathCached()||await Q.realpath(),!X)return;Q=X}let Y=Q.isUnknown()||this.opts.stat?await Q.lstat():Q;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let J=await Y.realpath();if(J&&(J.isUnknown()||this.opts.stat))await J.lstat()}return this.matchCheckTest(Y,Z)}matchCheckTest(Q,Z){return Q&&(this.maxDepth===1/0||Q.depth()<=this.maxDepth)&&(!Z||Q.canReaddir())&&(!this.opts.nodir||!Q.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!Q.isSymbolicLink()||!Q.realpathCached()?.isDirectory())&&!this.#q(Q)?Q:void 0}matchCheckSync(Q,Z){if(Z&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Q.realpathCached()||Q.realpathSync(),!X)return;Q=X}let Y=Q.isUnknown()||this.opts.stat?Q.lstatSync():Q;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let J=Y.realpathSync();if(J&&(J?.isUnknown()||this.opts.stat))J.lstatSync()}return this.matchCheckTest(Y,Z)}matchFinish(Q,Z){if(this.#q(Q))return;if(!this.includeChildMatches&&this.#Q?.add){let Y=`${Q.relativePosix()}/**`;this.#Q.add(Y)}let X=this.opts.absolute===void 0?Z:this.opts.absolute;this.seen.add(Q);let q=this.opts.mark&&Q.isDirectory()?this.#X:"";if(this.opts.withFileTypes)this.matchEmit(Q);else if(X){let Y=this.opts.posix?Q.fullpathPosix():Q.fullpath();this.matchEmit(Y+q)}else{let Y=this.opts.posix?Q.relativePosix():Q.relative(),J=this.opts.dotRelative&&!Y.startsWith(".."+this.#X)?"."+this.#X:"";this.matchEmit(!Y?"."+q:J+Y+q)}}async match(Q,Z,X){let q=await this.matchCheck(Q,X);if(q)this.matchFinish(q,Z)}matchSync(Q,Z,X){let q=this.matchCheckSync(Q,X);if(q)this.matchFinish(q,Z)}walkCB(Q,Z,X){if(this.signal?.aborted)X();this.walkCB2(Q,Z,new U8(this.opts),X)}walkCB2(Q,Z,X,q){if(this.#J(Q))return q();if(this.signal?.aborted)q();if(this.paused){this.onResume(()=>this.walkCB2(Q,Z,X,q));return}X.processPatterns(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#q(H))continue;Y++,this.match(H,W,V).then(()=>J())}for(let H of X.subwalkTargets()){if(this.maxDepth!==1/0&&H.depth()>=this.maxDepth)continue;Y++;let W=H.readdirCached();if(H.calledReaddir())this.walkCB3(H,W,X,J);else H.readdirCB((V,K)=>this.walkCB3(H,K,X,J),!0)}J()}walkCB3(Q,Z,X,q){X=X.filterEntries(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#q(H))continue;Y++,this.match(H,W,V).then(()=>J())}for(let[H,W]of X.subwalks.entries())Y++,this.walkCB2(H,W,X.child(),J);J()}walkCBSync(Q,Z,X){if(this.signal?.aborted)X();this.walkCB2Sync(Q,Z,new U8(this.opts),X)}walkCB2Sync(Q,Z,X,q){if(this.#J(Q))return q();if(this.signal?.aborted)q();if(this.paused){this.onResume(()=>this.walkCB2Sync(Q,Z,X,q));return}X.processPatterns(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#q(H))continue;this.matchSync(H,W,V)}for(let H of X.subwalkTargets()){if(this.maxDepth!==1/0&&H.depth()>=this.maxDepth)continue;Y++;let W=H.readdirSync();this.walkCB3Sync(H,W,X,J)}J()}walkCB3Sync(Q,Z,X,q){X=X.filterEntries(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#q(H))continue;this.matchSync(H,W,V)}for(let[H,W]of X.subwalks.entries())Y++,this.walkCB2Sync(H,W,X.child(),J);J()}}class h8 extends V7{matches=new Set;constructor(Q,Z,X){super(Q,Z,X)}matchEmit(Q){this.matches.add(Q)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise((Q,Z)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)Z(this.signal.reason);else Q(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class g8 extends V7{results;constructor(Q,Z,X){super(Q,Z,X);this.results=new u0({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(Q){if(this.results.write(Q),!this.results.flowing)this.pause()}stream(){let Q=this.path;if(Q.isUnknown())Q.lstat().then(()=>{this.walkCB(Q,this.patterns,()=>this.results.end())});else this.walkCB(Q,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var h4=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class B0{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(Q,Z){if(!Z)throw TypeError("glob options required");if(this.withFileTypes=!!Z.withFileTypes,this.signal=Z.signal,this.follow=!!Z.follow,this.dot=!!Z.dot,this.dotRelative=!!Z.dotRelative,this.nodir=!!Z.nodir,this.mark=!!Z.mark,!Z.cwd)this.cwd="";else if(Z.cwd instanceof URL||Z.cwd.startsWith("file://"))Z.cwd=f4(Z.cwd);if(this.cwd=Z.cwd||"",this.root=Z.root,this.magicalBraces=!!Z.magicalBraces,this.nobrace=!!Z.nobrace,this.noext=!!Z.noext,this.realpath=!!Z.realpath,this.absolute=Z.absolute,this.includeChildMatches=Z.includeChildMatches!==!1,this.noglobstar=!!Z.noglobstar,this.matchBase=!!Z.matchBase,this.maxDepth=typeof Z.maxDepth==="number"?Z.maxDepth:1/0,this.stat=!!Z.stat,this.ignore=Z.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error("cannot set absolute and withFileTypes:true");if(typeof Q==="string")Q=[Q];if(this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z.allowWindowsEscape===!1,this.windowsPathsNoEscape)Q=Q.map((W)=>W.replace(/\\/g,"/"));if(this.matchBase){if(Z.noglobstar)throw TypeError("base matching requires globstar");Q=Q.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=Q,this.platform=Z.platform||h4,this.opts={...Z,platform:this.platform},Z.scurry){if(this.scurry=Z.scurry,Z.nocase!==void 0&&Z.nocase!==Z.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let W=Z.platform==="win32"?_8:Z.platform==="darwin"?f8:Z.platform?z8:FQ;this.scurry=new W(this.cwd,{nocase:Z.nocase,fs:Z.fs})}this.nocase=this.scurry.nocase;let X=this.platform==="darwin"||this.platform==="win32",q={...Z,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:X,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},Y=this.pattern.map((W)=>new V0(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 p0(W,K,0,this.platform)})}async walk(){return[...await new h8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new h8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new g8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new g8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var K7=(Q,Z={})=>{if(!Array.isArray(Q))Q=[Q];for(let X of Q)if(new V0(X,Z).hasMagic())return!0;return!1};function m8(Q,Z={}){return new B0(Q,Z).streamSync()}function NQ(Q,Z={}){return new B0(Q,Z).stream()}function c8(Q,Z={}){return new B0(Q,Z).walkSync()}async function wQ(Q,Z={}){return new B0(Q,Z).walk()}function l8(Q,Z={}){return new B0(Q,Z).iterateSync()}function PQ(Q,Z={}){return new B0(Q,Z).iterate()}var g4=m8,m4=Object.assign(NQ,{sync:m8}),c4=l8,l4=Object.assign(PQ,{sync:l8}),d4=Object.assign(c8,{stream:m8,iterate:l8}),SQ=Object.assign(wQ,{glob:wQ,globSync:c8,sync:d4,globStream:NQ,stream:m4,globStreamSync:m8,streamSync:g4,globIterate:PQ,iterate:l4,globIterateSync:l8,iterateSync:c4,Glob:B0,hasMagic:K7,escape:m0,unescape:G0});SQ.glob=SQ;import i4 from"node:path";var bQ=({dir:Q,pattern:Z="*",nodir:X=!1,dot:q=!0,ignore:Y=[],absolute:J=!1,matchBase:H=!1,follow:W=!1})=>{if(Q=Q||process.cwd(),Q=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 kQ from"lodash.clonedeep";import p4 from"@fnet/key-value-transformer";async function c({node:Q,initNode:Z,extra:X=!0}){if(Reflect.has(Q.definition,"modules")&&!Array.isArray(Q.definition.modules)){let q=Q.definition.modules;Q.definition.modules=[],Object.keys(q).forEach((Y)=>{let J={...q[Y]};if(typeof J.export==="boolean")J.export=J.export===!0?Y:!1;else if(typeof J.export==="string")J.export=J.export;else delete J.export;Q.definition.modules.push({[Y]:J})})}if(X){let q=[],Y=await p4({data:Q.definition,callback:(J,H,W)=>{let V=P0(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 c({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=DQ}async function DQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||kQ(Q.definition);let Y=Q.context.transform;for(let J of Q.childs)if(J.context.transform=J.context.transform||kQ(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 $8={hits:a4,init:n4,resolve:DQ};async function r4({node:Q}){if(Object.keys(Q.definition).filter((q)=>P0(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)=>P0(W)==="if");if(Y){let W=Z.definition[Y],V=P0(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)=>P0(W)==="elseif"),H=0;for(let W of J){let V=Z.definition[W],K=P0(W,!0);q.push({name:`${Z.name}_elseif_${H++}`,definition:V,processor:{expression:W,statement:K.statement,processor:K.processor}}),delete Z.definition[W]}if(Z.definition.elseif){let{condition:W,...V}=Z.definition.elseif;q.push({name:`${Z.name}_elseif_${H++}`,definition:V,processor:{expression:`elseif::${W}`,statement:W}}),delete Z.definition.elseif}Z.definition.switch=[];for(let W of q)Z.definition.switch.push({condition:W.processor.statement,...W.definition});if(Z.definition?.else){let W=Z.definition.else;Z.definition.switch.push({default:W}),delete Z.definition.else}await $8.init(Q)}var _7={hits:r4,init:s4};import vQ from"lodash.clonedeep";async function o4({node:Q}){return Q.definition.hasOwnProperty("try")&&Q.definition.hasOwnProperty("except")}async function t4({node:Q,initNode:Z}){if(Q.type="tryexcept",await c({node:Q,initNode:Z,extra:!1}),Q.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=yQ}async function yQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||vQ(Q.definition);let Y=Q.context.transform;if(Q.context.try=Q.childs.find((J)=>J.name==="try"),Q.context.except=Q.childs.find((J)=>J.name==="except"),Q.context.except){let J=Q.context.except;if(J.context.transform=J.context.transform||vQ(J.definition),!J.context.transform.hasOwnProperty("as"))J.context.transform.as="error"}await b({node:Q,transformExpression:q}),await Z({node:Q})}var z7={hits:o4,init:t4,resolve:yQ};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 c({node:Q,initNode:Z}),Q.resolve=EQ}async function EQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||e4(Q.definition);let Y=Q.context.transform;await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var G7={hits:Q1,init:Z1,resolve:EQ};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 c({node:Q,initNode:Z,extra:!1}),Q.block_child_auto_jump_to_parent=!0,Q.block_child_auto_jump_to_sibling=!0,!Q.definition.for.hasOwnProperty("steps")){let{as:X,in:q,...Y}=Q.definition.for,J={};if(X!==void 0)J.as=X;if(q!==void 0)J.in=q;Q.definition.for=J,Q.definition.for.steps=[{[`${Q.name}_step`]:Y}]}if(!Array.isArray(Q.definition.for.steps))Q.definition.for.steps=[{[`${Q.name}_step`]:Q.definition.for.steps}];for(let X=0;X<Q.definition.for.steps.length;X++){let q=Q.definition.for.steps[X],Y=Object.keys(q)[0],J={name:Y,childs:[],parent:Q,definition:q[Y],index:Q.childs.length,context:{}};Q.childs.push(J),await Z({node:J})}Q.resolve=xQ}async function xQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||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 U7={hits:q1,init:Y1,resolve:xQ};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=uQ}async function uQ({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 $7={hits:W1,init:H1,resolve:uQ};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=fQ}async function fQ({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 M7={hits:K1,init:_1,resolve:fQ};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=hQ}async function hQ({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 O7={hits:G1,init:U1,resolve:hQ};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 c({node:Q,initNode:Z}),Q.resolve=gQ}async function gQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||$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 M8={hits:M1,init:O1,resolve:gQ};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=mQ}async function mQ({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 A7={hits:B1,init:R1,resolve:mQ};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 c({node:Q,initNode:Z}),Q.resolve=cQ}async function cQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||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 B7={hits:C1,init:L1,resolve:cQ};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=lQ}async function lQ({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 R7={hits:j1,init:T1,resolve:lQ};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=dQ}async function dQ({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 I7={hits:S1,init:N1,resolve:dQ};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=iQ}async function iQ({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 C7={hits:b1,init:k1,resolve:iQ};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 c({node:Q,initNode:Z}),Q.resolve=pQ}async function pQ({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 L7={hits:v1,init:y1,resolve:pQ};function F7({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 aQ{#Z;#Q;#X;#q;constructor({key:Q,npm:Z,master:X,extras:q}){this.#Z=Q,this.#Q=Z,this.#X=X,this.#q=q}hits({node:Q}){return Q.definition.hasOwnProperty(this.#Z)}async init(Q){let{node:Z}=Q,X=this.#Z,q=Z.definition,Y=typeof q[X];if(q.call=`npm:${this.#Q}`,Y!=="object")q.args={...q.args,[`${this.#X}`]:q[X]};else q.args=q[X];if(delete q[X],this.#q)for(let J in this.#q)q[J]=this.#q[J];console.log(`[npm-block] ${this.#Z} --> ${this.#Q}`),await M8.init(Q)}}function s(Q){return new aQ(Q)}import 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 c({node:Q,initNode:Z}),Q.resolve=nQ}async function nQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||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 j7={hits:x1,init:u1,resolve:nQ};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 c({node:Q,initNode:Z}),Q.resolve=rQ}async function rQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||f1(Q.definition),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var T7={hits:h1,init:g1,resolve:rQ};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=sQ}async function sQ({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 w7={hits:c1,init:l1,resolve:sQ};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=oQ}async function oQ({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 S7={hits:i1,init:p1,resolve:oQ};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=tQ}async function tQ({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 N7={hits:n1,init:r1,resolve:tQ};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 c({node:Q,initNode:Z});let X=Q.definition.http,q;if(typeof X==="string")q={url:X,method:"GET",headers:{},timeout:30000};else if(typeof X==="object"){if(q={url:X.url,method:X.method||"GET",headers:X.headers||{},body:X.body,params:X.params,timeout:X.timeout||30000},!q.url)throw Error(`HTTP step '${Q.name}' requires a url property`)}else throw Error(`HTTP step '${Q.name}' requires a string URL or object configuration`);let Y=["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"],J=q.method.toUpperCase();if(!Y.includes(J))throw Error(`HTTP step '${Q.name}' has invalid method '${q.method}'. Valid options: ${Y.join(", ")}`);if(q.method=J,q.timeout&&(typeof q.timeout!=="number"||q.timeout<=0))throw Error(`HTTP step '${Q.name}' timeout must be a positive number`);Q.definition.http=q,Q.resolve=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 P7={hits:o1,init:t1};var eQ=({path:Q})=>{if(!Q)throw Error("Path is required");let Z=/^@([^\/]+\/[^\/]+)(?:\/(.+))?$/,X=/^([^\/]+)(?:\/(.+))?$/,q;if(q=Q.match(Z))return{path:Q,package:"@"+q[1],subpath:q[2]||null};else if(q=Q.match(X))return{path:Q,package:q[1],subpath:q[2]||null};return null};import W2 from"node:os";class YZ{#Z;#Q;#X;#q;#J;#C;#I;#K;#G;#V;#z;#Y;#O;#M;#$;#A;#j;#R;#F;#H;#L;#_=[];constructor(Q){this.#Z=new t7,this.#Q=Q,this.#C=[],this.#I=[],this.#K={},this._expire_ttl=3600,this._expire_ttl_short=300,this.#_.push(s({key:"config",npm:"@fnet/config",master:"name"})),this.#_.push(s({key:"yaml",npm:"@fnet/yaml",master:"file"})),this.#_.push(s({key:"prompt",npm:"@fnet/prompt",master:"message"})),this.#_.push(s({key:"html-link",npm:"@flownet/lib-load-browser-link-url",master:"src"})),this.#_.push(s({key:"html-script",npm:"@flownet/lib-load-browser-script-url",master:"src"})),this.#_.push(s({key:"http-server",npm:"@fnet/node-express",master:"server_port"})),this.#_.push(s({key:"shell",npm:"@fnet/shell-flow",master:"commands"})),this.#_.push(s({key:"list-files",npm:"@fnet/list-files",master:"pattern"})),this.#_.push(s({key:"up-list-files",npm:"@fnet/up-list-files",master:"pattern"})),this.#_.push(s({key:"auto-conda-env",npm:"@fnet/auto-conda-env",master:"envDir"})),this.#_.push(s({key:"ollama-chat",npm:"@fnet/ollama-chat",master:"model"})),this.#_.push(s({key:"ai",npm:"@fnet/ai",master:"prompt",extras:{subtype:"flow"}})),this.#_.push(s({key:"invoke",npm:"@fnet/invoke",master:"method",extras:{}})),this.#_.push(s({key:"fetch",npm:"@fnet/fetch",master:"url",extras:{}})),this.#_.push(s({key:"filemap",npm:"@fnet/filemap",master:"target",extras:{}})),this.#H={packageDependencies:this.#C,packageDevDependencies:this.#I,setProgress:this.setProgress.bind(this),context:this.#Q,Atom:R0,registerToPackageManager:this.registerToPackageManager.bind(this)},this.#L={initNode:this.initNode.bind(this),cloneDeep:XZ,resolveTypeCommon:this.resolveTypeCommon.bind(this),resolveNextBlock:F7,transformExpression:this.transformExpression.bind(this),transformValue:this.transformValue.bind(this)}}async _cache_set(Q,Z,X){}async init(){this.#z=this.#Q.buildId||qZ(),this.#H.buildId=this.#z,this.#$=this.#Q.mode,this.#A=["all","deploy","build","file"].includes(this.#$),this.#j=["all","deploy","build"].includes(this.#$),this.#R=["all","deploy"].includes(this.#$),this.#F=["all","deploy","build","file","bpmn"].includes(this.#$),this.#O=this.#Q.protocol,this.#Y="BUILD:"+this.#z,this.#M=(await 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 B6(this.#H),Q.runtime.type==="bun")await I6(this.#H);else await R6(this.#H);await this.initAtomLibsAndDeps({libs:Z.context.libs,packageDependencies:this.#C}),await this.resolveNodeTree({root:Z}),this.#V=Z}catch(Q){throw await this._cache_set(this.#Y,{status:"FAILED",message:Q?.message||Q}),Q}}async initAuth(){if(!this.#Q.id)return;this.#G=await this.#Z.init({config:this.#M}),this.#H.atomAccessToken=this.#G}async initWorkflow(){let Q=this.#Q.id;this.#X=this.#Q.project?.workflowAtom||await R0.get({id:Q}),this.#q=typeof this.#X.doc.content==="string"?(await 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=bQ({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=O8.configure(Q,{watch:!1,dev:!0}),this.#H.njEnv=this.#J}transformWorkflow({workflow:Q}){for(let Z of Object.values(Q))Z.steps=Z.steps||[],Z.steps=Z.steps.filter((X)=>Object.keys(X).length>0),Z.steps=Z.steps.map((X)=>this.transformStep({step:X}))}transformStep({step:Q}){if(Array.isArray(Q))throw Error("Step must be an object.");let[Z,X]=Object.entries(Q)[0];if(X.hasOwnProperty("onerror")){let{onerror:q,...Y}=X;Q[Z]={try:Y,except:q}}if(Q[Z].hasOwnProperty("steps")){let q=Q[Z].steps;if(!Array.isArray(q))throw Error("Steps must be an array.");Q[Z].steps=q.map((Y)=>this.transformStep({step:Y}))}return Q}async initNodeTree({workflow:Q}){let Z=["$meta","$project"],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 z7.hits(Z))X="tryexcept",await z7.init(Z);else if(await $8.hits(Z))X="switch",await $8.init(Z);else if(await _7.hits(Z))X="if",await _7.init(Z);else if(await U7.hits(Z))X="for",await U7.init(Z);else if(await S7.hits(Z))X="retry",await S7.init(Z);else if(await N7.hits(Z))X="schedule",await N7.init(Z);else if(await $7.hits(Z))X="parallel",await $7.init(Z);else if(await w7.hits(Z))X="pipeline",await w7.init(Z);else if(await P7.hits(Z))X="http",await P7.init(Z);else if(await M8.hits(Z))X="call",await M8.init(Z);else if(await j7.hits(Z))X="new",await j7.init(Z);else if(await M7.hits(Z))X="raise",await M7.init(Z);else if(await B7.hits(Z))X="form",await B7.init(Z);else if(await R7.hits(Z))X="signal",await R7.init(Z);else if(await I7.hits(Z))X="wait",await I7.init(Z);else if(await A7.hits(Z))X="steps",await A7.init(Z);else if(await C7.hits(Z))X="next",await C7.init(Z);else if(await L7.hits(Z))X="modules",await L7.init(Z);else if(this.#_.find((q)=>q.hits(Z)))X="npm-block",await this.#_.find((q)=>q.hits(Z)).init(Z);else if(await G7.hits(Z))X="assign",await G7.init(Z);else if(await T7.hits(Z))X="output",await T7.init(Z);else if(await O7.hits(Z))X="return",await O7.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((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 w0({name:V.package,projectDir:this.#Q.projectDir,setProgress:this.#H.setProgress});Y.push({package:V.package,subpath:V.subpath,version:K.minorRange,type:"npm"})}return{name:X.pathname,doc:{type:"workflow.lib","content-type":"javascript",language:"js",dependencies:Y},protocol:X.protocol}}else if(X.protocol==="npm:"){let q=eQ({path:X.pathname}),Y=await w0({name:q.package,subpath:q.subpath,projectDir:this.#Q.projectDir,setProgress:this.#H.setProgress});return{name:X.pathname,doc:{type:"workflow.lib",subtype:Z?.definition?.subtype==="flow"?"workflow":null,"content-type":"javascript",language:"js",dependencies:[{package:q.package,version:Y.minorRange,type:"npm"}]},protocol:X.protocol}}else if(X.protocol==="use:")return{name:X.pathname,doc:{type:"function",dependencies:[]},protocol:X.protocol};else if(X.protocol==="node:")return{name:X.pathname,doc:{type:"workflow.lib","content-type":"javascript",language:"js",dependencies:[]},protocol:X.protocol};else if(X.protocol==="ac:"){let q=X.pathname.split("/");if(q.length===1)return await R0.first({where:{name:Q,parent_id:this.#M.env.ATOM_LIBRARIES_ID,type:"workflow.lib"}});if(q.length===2){let Y=await R0.first({where:{name:q[0],parent_id:this.#M.env.ATOM_LIBRARIES_ID,type:"folder"}});return await R0.first({where:{name:q[1],parent_id:Y.id,type:"workflow.lib"}})}}}async resolveNodeTree({root:Q}){for await(let Z of Q.childs)await this.resolveTypeWorkflow({node:Z})}async resolveTypeWorkflow({node:Q}){Q.context.transform=Q.context.transform||XZ(Q.definition);let Z=Q.context.transform;for(let X=0;X<Z.params?.length;X++){let q=Z.params[X];if(typeof q==="string")Z.params[X]={key:q,hasDefault:!1};else{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)=>{
|
|
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 e9(this.pattern,this.options)}parse(Q){t0(Q);let Z=this.options;if(Q==="**")return r;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=n.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===r?r:K._src});return V.forEach((K,z)=>{let G=V[z+1],_=V[z-1];if(K!==r||_===r)return;if(_===void 0)if(G!==void 0&&G!==r)V[z+1]="(?:\\/|"+X+"\\/)?"+G;else V[z]=X;else if(G===void 0)V[z-1]=_+"(?:\\/|"+X+")?";else if(G!==r)V[z-1]=_+"(?:\\/|\\/"+X+"\\/)"+G,V[z+1]=r}),V.filter((K)=>K!==r).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 Z0.defaults(Q).Minimatch}}Z0.AST=n;Z0.Minimatch=V0;Z0.escape=m0;Z0.unescape=G0;import{fileURLToPath as f4}from"node:url";var c0=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,ZQ=new Set,n6=typeof process==="object"&&!!process?process:{},XQ=(Q,Z,X,q)=>{typeof n6.emitWarning==="function"?n6.emitWarning(Q,Z,X,q):console.error(`[${X}] ${Z}: ${Q}`)},S8=globalThis.AbortController,QQ=globalThis.AbortSignal;if(typeof S8>"u"){QQ=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(q,Y){this._onabort.push(Y)}},S8=class{constructor(){Z()}signal=new QQ;abort(q){if(this.signal.aborted)return;this.signal.reason=q,this.signal.aborted=!0;for(let Y of this.signal._onabort)Y(q);this.signal.onabort?.(q)}};let Q=n6.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",Z=()=>{if(!Q)return;Q=!1,XQ("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",Z)}}var H4=(Q)=>!ZQ.has(Q),oq=Symbol("type"),b0=(Q)=>Q&&Q===Math.floor(Q)&&Q>0&&isFinite(Q),qQ=(Q)=>!b0(Q)?null:Q<=Math.pow(2,8)?Uint8Array:Q<=Math.pow(2,16)?Uint16Array:Q<=Math.pow(2,32)?Uint32Array:Q<=Number.MAX_SAFE_INTEGER?Q8:null;class Q8 extends Array{constructor(Q){super(Q);this.fill(0)}}class l0{heap;length;static#Z=!1;static create(Q){let Z=qQ(Q);if(!Z)return[];l0.#Z=!0;let X=new l0(Q,Z);return l0.#Z=!1,X}constructor(Q,Z){if(!l0.#Z)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new Z(Q),this.length=0}push(Q){this.heap[this.length++]=Q}pop(){return this.heap[--this.length]}}class Z8{#Z;#Q;#X;#q;#J;#C;#I;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#K;#G;#V;#z;#Y;#O;#M;#$;#A;#j;#R;#F;#H;#L;#_;#T;#B;#b;static unsafeExposeInternals(Q){return{starts:Q.#H,ttls:Q.#L,sizes:Q.#F,keyMap:Q.#V,keyList:Q.#z,valList:Q.#Y,next:Q.#O,prev:Q.#M,get head(){return Q.#$},get tail(){return Q.#A},free:Q.#j,isBackgroundFetch:(Z)=>Q.#U(Z),backgroundFetch:(Z,X,q,Y)=>Q.#E(Z,X,q,Y),moveToTail:(Z)=>Q.#f(Z),indexes:(Z)=>Q.#N(Z),rindexes:(Z)=>Q.#P(Z),isStale:(Z)=>Q.#S(Z)}}get max(){return this.#Z}get maxSize(){return this.#Q}get calculatedSize(){return this.#G}get size(){return this.#K}get fetchMethod(){return this.#C}get memoMethod(){return this.#I}get dispose(){return this.#X}get onInsert(){return this.#q}get disposeAfter(){return this.#J}constructor(Q){let{max:Z=0,ttl:X,ttlResolution:q=1,ttlAutopurge:Y,updateAgeOnGet:J,updateAgeOnHas:H,allowStale:W,dispose:V,onInsert:K,disposeAfter: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&&!b0(Z))throw TypeError("max option must be a nonnegative integer");let v=Z?qQ(Z):Array;if(!v)throw Error("invalid max value: "+Z);if(this.#Z=Z,this.#Q=O,this.maxEntrySize=$||this.#Q,this.sizeCalculation=A,this.sizeCalculation){if(!this.#Q&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw TypeError("sizeCalculation set to non-function")}if(B!==void 0&&typeof B!=="function")throw TypeError("memoMethod must be a function if defined");if(this.#I=B,U!==void 0&&typeof U!=="function")throw TypeError("fetchMethod must be a function if specified");if(this.#C=U,this.#T=!!U,this.#V=new Map,this.#z=Array(Z).fill(void 0),this.#Y=Array(Z).fill(void 0),this.#O=new v(Z),this.#M=new v(Z),this.#$=0,this.#A=0,this.#j=l0.create(Z),this.#K=0,this.#G=0,typeof V==="function")this.#X=V;if(typeof K==="function")this.#q=K;if(typeof 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(!b0(this.#Q))throw TypeError("maxSize must be a positive integer if specified")}if(!b0(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=b0(q)||q===0?q:1,this.ttlAutopurge=!!Y,this.ttl=X||0,this.ttl){if(!b0(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#W()}if(this.#Z===0&&this.ttl===0&&this.#Q===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Z&&!this.#Q){if(H4("LRU_CACHE_UNBOUNDED"))ZQ.add("LRU_CACHE_UNBOUNDED"),XQ("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",Z8)}}getRemainingTTL(Q){return this.#V.has(Q)?1/0:0}#W(){let Q=new Q8(this.#Z),Z=new Q8(this.#Z);this.#L=Q,this.#H=Z,this.#k=(Y,J,H=c0.now())=>{if(Z[Y]=J!==0?H:0,Q[Y]=J,J!==0&&this.ttlAutopurge){let W=setTimeout(()=>{if(this.#S(Y))this.#D(this.#z[Y],"expire")},J+1);if(W.unref)W.unref()}},this.#v=(Y)=>{Z[Y]=Q[Y]!==0?c0.now():0},this.#w=(Y,J)=>{if(Q[J]){let H=Q[J],W=Z[J];if(!H||!W)return;Y.ttl=H,Y.start=W,Y.now=X||q();let V=Y.now-W;Y.remainingTTL=H-V}};let X=0,q=()=>{let Y=c0.now();if(this.ttlResolution>0){X=Y;let J=setTimeout(()=>X=0,this.ttlResolution);if(J.unref)J.unref()}return Y};this.getRemainingTTL=(Y)=>{let J=this.#V.get(Y);if(J===void 0)return 0;let H=Q[J],W=Z[J];if(!H||!W)return 1/0;let V=(X||q())-W;return H-V},this.#S=(Y)=>{let J=Z[Y],H=Q[Y];return!!H&&!!J&&(X||q())-J>H}}#v=()=>{};#w=()=>{};#k=()=>{};#S=()=>!1;#g(){let Q=new Q8(this.#Z);this.#G=0,this.#F=Q,this.#y=(Z)=>{this.#G-=Q[Z],Q[Z]=0},this.#m=(Z,X,q,Y)=>{if(this.#U(X))return 0;if(!b0(q))if(Y){if(typeof Y!=="function")throw TypeError("sizeCalculation must be a function");if(q=Y(X,Z),!b0(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-(c0.now()-H);Y.ttl=W,Y.start=Date.now()}}if(this.#F)Y.size=this.#F[Z];return Y}dump(){let Q=[];for(let Z of this.#N({allowStale:!0})){let X=this.#z[Z],q=this.#Y[Z],Y=this.#U(q)?q.__staleWhileFetching:q;if(Y===void 0||X===void 0)continue;let J={value:Y};if(this.#L&&this.#H){J.ttl=this.#L[Z];let H=c0.now()-this.#H[Z];J.start=Math.floor(Date.now()-H)}if(this.#F)J.size=this.#F[Z];Q.unshift([X,J])}return Q}load(Q){this.clear();for(let[Z,X]of Q){if(X.start){let q=Date.now()-X.start;X.start=c0.now()-q}this.set(Z,X.value,X)}}set(Q,Z,X={}){if(Z===void 0)return this.delete(Q),this;let{ttl:q=this.ttl,start:Y,noDisposeOnSet:J=this.noDisposeOnSet,sizeCalculation:H=this.sizeCalculation,status:W}=X,{noUpdateTTL:V=this.noUpdateTTL}=X,K=this.#m(Q,Z,X.size||0,H);if(this.maxEntrySize&&K>this.maxEntrySize){if(W)W.set="miss",W.maxEntrySizeExceeded=!0;return this.#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 W0=X&&F.__staleWhileFetching!==void 0;if(U){if(U.fetch="inflight",W0)U.returnedStale=!0}return W0?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,$),J0=y.__staleWhileFetching!==void 0&&X;if(U){if(U.fetch=S?"stale":"refresh",J0&&S)U.returnedStale=!0}return J0?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 Y7}from"node:path";import{fileURLToPath as R4}from"node:url";import{lstatSync as I4,readdir as C4,readdirSync as L4,readlinkSync as F4,realpathSync as j4}from"fs";import*as T4 from"node:fs";import{lstat as S4,readdir as N4,readlink as P4,realpath as b4}from"node:fs/promises";import{EventEmitter as Q7}from"node:events";import VQ from"node:stream";import{StringDecoder as V4}from"node:string_decoder";var YQ=typeof process==="object"&&process?process:{stdout:null,stderr:null},K4=(Q)=>!!Q&&typeof Q==="object"&&(Q instanceof u0||Q instanceof VQ||_4(Q)||z4(Q)),_4=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof Q7&&typeof Q.pipe==="function"&&Q.pipe!==VQ.Writable.prototype.pipe,z4=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof Q7&&typeof Q.write==="function"&&typeof Q.end==="function",L0=Symbol("EOF"),F0=Symbol("maybeEmitEnd"),k0=Symbol("emittedEnd"),N8=Symbol("emittingEnd"),X8=Symbol("emittedError"),P8=Symbol("closed"),JQ=Symbol("read"),b8=Symbol("flush"),WQ=Symbol("flushChunk"),U0=Symbol("encoding"),d0=Symbol("decoder"),i=Symbol("flowing"),q8=Symbol("paused"),i0=Symbol("resume"),p=Symbol("buffer"),X0=Symbol("pipes"),a=Symbol("bufferLength"),r6=Symbol("bufferPush"),k8=Symbol("bufferShift"),e=Symbol("objectMode"),m=Symbol("destroyed"),s6=Symbol("error"),o6=Symbol("emitData"),HQ=Symbol("emitEnd"),t6=Symbol("emitEnd2"),O0=Symbol("async"),e6=Symbol("abort"),D8=Symbol("aborted"),Y8=Symbol("signal"),x0=Symbol("dataListeners"),Y0=Symbol("discarded"),J8=(Q)=>Promise.resolve().then(Q),G4=(Q)=>Q(),U4=(Q)=>Q==="end"||Q==="finish"||Q==="prefinish",$4=(Q)=>Q instanceof ArrayBuffer||!!Q&&typeof Q==="object"&&Q.constructor&&Q.constructor.name==="ArrayBuffer"&&Q.byteLength>=0,M4=(Q)=>!Buffer.isBuffer(Q)&&ArrayBuffer.isView(Q);class Z7{src;dest;opts;ondrain;constructor(Q,Z,X){this.src=Q,this.dest=Z,this.opts=X,this.ondrain=()=>Q[i0](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(Q){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class KQ extends Z7{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(Q,Z,X){super(Q,Z,X);this.proxyErrors=(q)=>Z.emit("error",q),Q.on("error",this.proxyErrors)}}var O4=(Q)=>!!Q.objectMode,A4=(Q)=>!Q.objectMode&&!!Q.encoding&&Q.encoding!=="buffer";class u0 extends Q7{[i]=!1;[q8]=!1;[X0]=[];[p]=[];[e];[U0];[O0];[d0];[L0]=!1;[k0]=!1;[N8]=!1;[P8]=!1;[X8]=null;[a]=0;[m]=!1;[Y8];[D8]=!1;[x0]=0;[Y0]=!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[U0]=null;else if(A4(Z))this[U0]=Z.encoding,this[e]=!1;else this[e]=!1,this[U0]=null;if(this[O0]=!!Z.async,this[d0]=this[U0]?new V4(this[U0]):null,Z&&Z.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[p]});if(Z&&Z.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[X0]});let{signal:X}=Z;if(X)if(this[Y8]=X,X.aborted)this[e6]();else X.addEventListener("abort",()=>this[e6]())}get bufferLength(){return this[a]}get encoding(){return this[U0]}set encoding(Q){throw Error("Encoding must be set at instantiation time")}setEncoding(Q){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[e]}set objectMode(Q){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[O0]}set["async"](Q){this[O0]=this[O0]||!!Q}[e6](){this[D8]=!0,this.emit("abort",this[Y8]?.reason),this.destroy(this[Y8]?.reason)}get aborted(){return this[D8]}set aborted(Q){}write(Q,Z,X){if(this[D8])return!1;if(this[L0])throw Error("write after end");if(this[m])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof Z==="function")X=Z,Z="utf8";if(!Z)Z="utf8";let q=this[O0]?J8:G4;if(!this[e]&&!Buffer.isBuffer(Q)){if(M4(Q))Q=Buffer.from(Q.buffer,Q.byteOffset,Q.byteLength);else if($4(Q))Q=Buffer.from(Q);else if(typeof Q!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[e]){if(this[i]&&this[a]!==0)this[b8](!0);if(this[i])this.emit("data",Q);else this[r6](Q);if(this[a]!==0)this.emit("readable");if(X)q(X);return this[i]}if(!Q.length){if(this[a]!==0)this.emit("readable");if(X)q(X);return this[i]}if(typeof Q==="string"&&!(Z===this[U0]&&!this[d0]?.lastNeed))Q=Buffer.from(Q,Z);if(Buffer.isBuffer(Q)&&this[U0])Q=this[d0].write(Q);if(this[i]&&this[a]!==0)this[b8](!0);if(this[i])this.emit("data",Q);else this[r6](Q);if(this[a]!==0)this.emit("readable");if(X)q(X);return this[i]}read(Q){if(this[m])return null;if(this[Y0]=!1,this[a]===0||Q===0||Q&&Q>this[a])return this[F0](),null;if(this[e])Q=null;if(this[p].length>1&&!this[e])this[p]=[this[U0]?this[p].join(""):Buffer.concat(this[p],this[a])];let Z=this[JQ](Q||null,this[p][0]);return this[F0](),Z}[JQ](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[p][0]=X.slice(Q),Z=X.slice(0,Q),this[a]-=Q;else this[p][0]=X.subarray(Q),Z=X.subarray(0,Q),this[a]-=Q}if(this.emit("data",Z),!this[p].length&&!this[L0])this.emit("drain");return Z}end(Q,Z,X){if(typeof Q==="function")X=Q,Q=void 0;if(typeof Z==="function")X=Z,Z="utf8";if(Q!==void 0)this.write(Q,Z);if(X)this.once("end",X);if(this[L0]=!0,this.writable=!1,this[i]||!this[q8])this[F0]();return this}[i0](){if(this[m])return;if(!this[x0]&&!this[X0].length)this[Y0]=!0;if(this[q8]=!1,this[i]=!0,this.emit("resume"),this[p].length)this[b8]();else if(this[L0])this[F0]();else this.emit("drain")}resume(){return this[i0]()}pause(){this[i]=!1,this[q8]=!0,this[Y0]=!1}get destroyed(){return this[m]}get flowing(){return this[i]}get paused(){return this[q8]}[r6](Q){if(this[e])this[a]+=1;else this[a]+=Q.length;this[p].push(Q)}[k8](){if(this[e])this[a]-=1;else this[a]-=this[p][0].length;return this[p].shift()}[b8](Q=!1){do;while(this[WQ](this[k8]())&&this[p].length);if(!Q&&!this[p].length&&!this[L0])this.emit("drain")}[WQ](Q){return this.emit("data",Q),this[i]}pipe(Q,Z){if(this[m])return Q;this[Y0]=!1;let X=this[k0];if(Z=Z||{},Q===YQ.stdout||Q===YQ.stderr)Z.end=!1;else Z.end=Z.end!==!1;if(Z.proxyErrors=!!Z.proxyErrors,X){if(Z.end)Q.end()}else if(this[X0].push(!Z.proxyErrors?new Z7(this,Q,Z):new KQ(this,Q,Z)),this[O0])J8(()=>this[i0]());else this[i0]();return Q}unpipe(Q){let Z=this[X0].find((X)=>X.dest===Q);if(Z){if(this[X0].length===1){if(this[i]&&this[x0]===0)this[i]=!1;this[X0]=[]}else this[X0].splice(this[X0].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[Y0]=!1,this[x0]++,!this[X0].length&&!this[i])this[i0]()}else if(Q==="readable"&&this[a]!==0)super.emit("readable");else if(U4(Q)&&this[k0])super.emit(Q),this.removeAllListeners(Q);else if(Q==="error"&&this[X8]){let q=Z;if(this[O0])J8(()=>q.call(this,this[X8]));else q.call(this,this[X8])}return X}removeListener(Q,Z){return this.off(Q,Z)}off(Q,Z){let X=super.off(Q,Z);if(Q==="data"){if(this[x0]=this.listeners("data").length,this[x0]===0&&!this[Y0]&&!this[X0].length)this[i]=!1}return X}removeAllListeners(Q){let Z=super.removeAllListeners(Q);if(Q==="data"||Q===void 0){if(this[x0]=0,!this[Y0]&&!this[X0].length)this[i]=!1}return Z}get emittedEnd(){return this[k0]}[F0](){if(!this[N8]&&!this[k0]&&!this[m]&&this[p].length===0&&this[L0]){if(this[N8]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[P8])this.emit("close");this[N8]=!1}}emit(Q,...Z){let X=Z[0];if(Q!=="error"&&Q!=="close"&&Q!==m&&this[m])return!1;else if(Q==="data")return!this[e]&&!X?!1:this[O0]?(J8(()=>this[o6](X)),!0):this[o6](X);else if(Q==="end")return this[HQ]();else if(Q==="close"){if(this[P8]=!0,!this[k0]&&!this[m])return!1;let Y=super.emit("close");return this.removeAllListeners("close"),Y}else if(Q==="error"){this[X8]=X,super.emit(s6,X);let Y=!this[Y8]||this.listeners("error").length?super.emit("error",X):!1;return this[F0](),Y}else if(Q==="resume"){let Y=super.emit("resume");return this[F0](),Y}else if(Q==="finish"||Q==="prefinish"){let Y=super.emit(Q);return this.removeAllListeners(Q),Y}let q=super.emit(Q,...Z);return this[F0](),q}[o6](Q){for(let X of this[X0])if(X.dest.write(Q)===!1)this.pause();let Z=this[Y0]?!1:super.emit("data",Q);return this[F0](),Z}[HQ](){if(this[k0])return!1;return this[k0]=!0,this.readable=!1,this[O0]?(J8(()=>this[t6]()),!0):this[t6]()}[t6](){if(this[d0]){let Z=this[d0].end();if(Z){for(let X of this[X0])X.dest.write(Z);if(!this[Y0])super.emit("data",Z)}}for(let Z of this[X0])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[U0]?Q.join(""):Buffer.concat(Q,Q.dataLength)}async promise(){return new Promise((Q,Z)=>{this.on(m,()=>Z(Error("stream destroyed"))),this.on("error",(X)=>Z(X)),this.on("end",()=>Q())})}[Symbol.asyncIterator](){this[Y0]=!1;let Q=!1,Z=async()=>{return this.pause(),Q=!0,{value:void 0,done:!0}};return{next:()=>{if(Q)return Z();let q=this.read();if(q!==null)return Promise.resolve({done:!1,value:q});if(this[L0])return Z();let Y,J,H=(z)=>{this.off("data",W),this.off("end",V),this.off(m,K),Z(),J(z)},W=(z)=>{this.off("error",H),this.off("end",V),this.off(m,K),this.pause(),Y({value:z,done:!!this[L0]})},V=()=>{this.off("error",H),this.off("data",W),this.off(m,K),Z(),Y({done:!0,value:void 0})},K=()=>H(Error("stream destroyed"));return new Promise((z,G)=>{J=G,Y=z,this.once(m,K),this.once("error",H),this.once("end",V),this.once("data",W)})},throw:Z,return:Z,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[Y0]=!1;let Q=!1,Z=()=>{return this.pause(),this.off(s6,Z),this.off(m,Z),this.off("end",Z),Q=!0,{done:!0,value:void 0}},X=()=>{if(Q)return Z();let q=this.read();return q===null?Z():{done:!1,value:q}};return this.once("end",Z),this.once(s6,Z),this.once(m,Z),{next:X,throw:Z,return:Z,[Symbol.iterator](){return this}}}destroy(Q){if(this[m]){if(Q)this.emit("error",Q);else this.emit(m);return this}this[m]=!0,this[Y0]=!0,this[p].length=0,this[a]=0;let Z=this;if(typeof Z.close==="function"&&!this[P8])Z.close();if(Q)this.emit("error",Q);else this.emit(m);return this}static get isStream(){return K4}}var w4=j4.native,H8={lstatSync:I4,readdir:C4,readdirSync:L4,readlinkSync:F4,realpathSync:w4,promises:{lstat:S4,readdir:N4,readlink:P4,realpath:b4}},$Q=(Q)=>!Q||Q===H8||Q===T4?H8:{...H8,...Q,promises:{...H8.promises,...Q.promises||{}}},MQ=/^\\\\\?\\([a-z]:)\\?$/i,k4=(Q)=>Q.replace(/\//g,"\\").replace(MQ,"$1\\"),D4=/[\\\/]/,_0=0,OQ=1,AQ=2,A0=4,BQ=6,RQ=8,f0=10,IQ=12,K0=15,W8=~K0,X7=16,_Q=32,V8=64,$0=128,v8=256,E8=512,zQ=V8|$0|E8,v4=1023,q7=(Q)=>Q.isFile()?RQ:Q.isDirectory()?A0:Q.isSymbolicLink()?f0:Q.isCharacterDevice()?AQ:Q.isBlockDevice()?BQ:Q.isSocket()?IQ:Q.isFIFO()?OQ:_0,GQ=new Map,K8=(Q)=>{let Z=GQ.get(Q);if(Z)return Z;let X=Q.normalize("NFKD");return GQ.set(Q,X),X},UQ=new Map,y8=(Q)=>{let Z=UQ.get(Q);if(Z)return Z;let X=K8(Q.toLowerCase());return UQ.set(Q,X),X};class J7 extends Z8{constructor(){super({max:256})}}class CQ extends Z8{constructor(Q=16384){super({maxSize:Q,sizeCalculation:(Z)=>Z.length+1})}}var LQ=Symbol("PathScurry setAsCwd");class q0{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=_0,X,q,Y,J,H){if(this.name=Q,this.#H=Y?y8(Q):K8(Q),this.#W=Z&v4,this.nocase=Y,this.roots=q,this.root=X||this,this.#v=J,this.#_=H.fullpath,this.#B=H.relative,this.#b=H.relativePosix,this.parent=H.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=$Q(H.fs)}depth(){if(this.#L!==void 0)return this.#L;if(!this.parent)return this.#L=0;return this.#L=this.parent.depth()+1}childrenCache(){return this.#v}resolve(Q){if(!Q)return this;let Z=this.getRootString(Q),q=Q.substring(Z.length).split(this.splitSep);return Z?this.getRoot(Z).#S(q):this.#S(q)}#S(Q){let Z=this;for(let X of Q)Z=Z.child(X);return Z}children(){let Q=this.#v.get(this);if(Q)return Q;let Z=Object.assign([],{provisional:0});return this.#v.set(this,Z),this.#W&=~X7,Z}child(Q,Z){if(Q===""||Q===".")return this;if(Q==="..")return this.parent||this;let X=this.children(),q=this.nocase?y8(Q):K8(Q);for(let W of X)if(W.#H===q)return W;let Y=this.parent?this.sep:"",J=this.#_?this.#_+Y+Q:void 0,H=this.newChild(Q,_0,{...Z,parent:this,fullpath:J});if(!this.canReaddir())H.#W|=$0;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&K0)===_0}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&K0)===RQ}isDirectory(){return(this.#W&K0)===A0}isCharacterDevice(){return(this.#W&K0)===AQ}isBlockDevice(){return(this.#W&K0)===BQ}isFIFO(){return(this.#W&K0)===OQ}isSocket(){return(this.#W&K0)===IQ}isSymbolicLink(){return(this.#W&f0)===f0}lstatCached(){return this.#W&_Q?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&K0;return!(Q!==_0&&Q!==f0||this.#W&v8||this.#W&$0)}calledReaddir(){return!!(this.#W&X7)}isENOENT(){return!!(this.#W&$0)}isNamed(Q){return!this.nocase?this.#H===K8(Q):this.#H===y8(Q)}async readlink(){let Q=this.#w;if(Q)return Q;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=await this.#Z.promises.readlink(this.fullpath()),X=(await this.parent.realpath())?.resolve(Z);if(X)return this.#w=X}catch(Z){this.#u(Z.code);return}}readlinkSync(){let Q=this.#w;if(Q)return Q;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=this.#Z.readlinkSync(this.fullpath()),X=this.parent.realpathSync()?.resolve(Z);if(X)return this.#w=X}catch(Z){this.#u(Z.code);return}}#g(Q){this.#W|=X7;for(let Z=Q.provisional;Z<Q.length;Z++){let X=Q[Z];if(X)X.#y()}}#y(){if(this.#W&$0)return;this.#W=(this.#W|$0)&W8,this.#x()}#x(){let Q=this.children();Q.provisional=0;for(let Z of Q)Z.#y()}#m(){this.#W|=E8,this.#N()}#N(){if(this.#W&V8)return;let Q=this.#W;if((Q&K0)===A0)Q&=W8;this.#W=Q|V8,this.#x()}#P(Q=""){if(Q==="ENOTDIR"||Q==="EPERM")this.#N();else if(Q==="ENOENT")this.#y();else this.children().provisional=0}#c(Q=""){if(Q==="ENOTDIR")this.parent.#N();else if(Q==="ENOENT")this.#y()}#u(Q=""){let Z=this.#W;if(Z|=v8,Q==="ENOENT")Z|=$0;if(Q==="EINVAL"||Q==="UNKNOWN")Z&=W8;if(this.#W=Z,Q==="ENOTDIR"&&this.parent)this.parent.#N()}#E(Q,Z){return this.#l(Q,Z)||this.#U(Q,Z)}#U(Q,Z){let X=q7(Q),q=this.newChild(Q.name,X,{parent:this}),Y=q.#W&K0;if(Y!==A0&&Y!==f0&&Y!==_0)q.#W|=V8;return Z.unshift(q),Z.provisional++,q}#l(Q,Z){for(let X=Z.provisional;X<Z.length;X++){let q=Z[X];if((this.nocase?y8(Q.name):K8(Q.name))!==q.#H)continue;return this.#f(Q,q,X,Z)}}#f(Q,Z,X,q){let Y=Z.name;if(Z.#W=Z.#W&W8|q7(Q),Y!==Q.name)Z.name=Q.name;if(X!==q.provisional){if(X===q.length-1)q.pop();else q.splice(X,1);q.unshift(Z)}return q.provisional++,Z}async lstat(){if((this.#W&$0)===0)try{return this.#D(await this.#Z.promises.lstat(this.fullpath())),this}catch(Q){this.#c(Q.code)}}lstatSync(){if((this.#W&$0)===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=q7(Q);if(this.#W=this.#W&W8|R|_Q,R!==_0&&R!==A0&&R!==f0)this.#W|=V8}#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&zQ)return!1;let Q=K0&this.#W;if(!(Q===_0||Q===A0||Q===f0))return!1;return!0}shouldWalk(Q,Z){return(this.#W&A0)===A0&&!(this.#W&zQ)&&!Q.has(this)&&(!Z||Z(this))}async realpath(){if(this.#k)return this.#k;if((E8|v8|$0)&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|$0)&this.#W)return;try{let Q=this.#Z.realpathSync(this.fullpath());return this.#k=this.resolve(Q)}catch(Q){this.#m()}}[LQ](Q){if(Q===this)return;Q.isCWD=!1,this.isCWD=!0;let Z=new Set([]),X=[],q=this;while(q&&q.parent)Z.add(q),q.#B=X.join(this.sep),q.#b=X.join("/"),q=q.parent,X.push("..");q=Q;while(q&&q.parent&&!Z.has(q))q.#B=void 0,q.#b=void 0,q=q.parent}}class x8 extends q0{sep="\\";splitSep=D4;constructor(Q,Z=_0,X,q,Y,J,H){super(Q,Z,X,q,Y,J,H)}newChild(Q,Z=_0,X={}){return new x8(Q,Z,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Q){return Y7.parse(Q).root}getRoot(Q){if(Q=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 _8(Q,this).root}sameRoot(Q,Z=this.root.name){return Q=Q.toUpperCase().replace(/\//g,"\\").replace(MQ,"$1\\"),Q===Z}}class u8 extends q0{splitSep="/";sep="/";constructor(Q,Z=_0,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=_0,X={}){return new u8(Q,Z,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class W7{root;rootPath;roots;cwd;#Z;#Q;#X;nocase;#q;constructor(Q=process.cwd(),Z,X,{nocase:q,childrenCacheSize:Y=16384,fs:J=H8}={}){if(this.#q=$Q(J),Q instanceof URL||Q.startsWith("file://"))Q=R4(Q);let H=Z.resolve(Q);this.roots=Object.create(null),this.rootPath=this.parseRootPath(H),this.#Z=new J7,this.#Q=new J7,this.#X=new CQ(Y);let W=H.substring(this.rootPath.length).split(X);if(W.length===1&&!W[0])W.pop();if(q===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=q,this.root=this.newRoot(this.#q),this.roots[this.rootPath]=this.root;let V=this.root,K=W.length-1,z=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 q0))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 q0))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 q0))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 q0))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 q0))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 q0))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 q0))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 q0))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 q0))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 q0))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 q0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z,H=new u0({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 q0))Z=Q,Q=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Y,walkFilter:J}=Z,H=new u0({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[LQ](Z)}}class _8 extends W7{sep="\\";constructor(Q=process.cwd(),Z={}){let{nocase:X=!0}=Z;super(Q,Y7,"\\",{...Z,nocase:X});this.nocase=X;for(let q=this.cwd;q;q=q.parent)q.nocase=this.nocase}parseRootPath(Q){return Y7.parse(Q).root.toUpperCase()}newRoot(Q){return new x8(this.rootPath,A0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")||Q.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Q)}}class z8 extends W7{sep="/";constructor(Q=process.cwd(),Z={}){let{nocase:X=!1}=Z;super(Q,B4,"/",{...Z,nocase:X});this.nocase=X}parseRootPath(Q){return"/"}newRoot(Q){return new u8(this.rootPath,A0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")}}class f8 extends z8{constructor(Q=process.cwd(),Z={}){let{nocase:X=!0}=Z;super(Q,{...Z,nocase:X})}}var KY=process.platform==="win32"?x8:u8,FQ=process.platform==="win32"?_8:process.platform==="darwin"?f8:z8;var y4=(Q)=>Q.length>=1,E4=(Q)=>Q.length>=1;class p0{#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]===r}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 p0(this.#Z,this.#Q,this.#X+1,this.#q),this.#J.#G=this.#G,this.#J.#K=this.#K,this.#J.#I=this.#I,this.#J}isUNC(){let Q=this.#Z;return this.#K!==void 0?this.#K:this.#K=this.#q==="win32"&&this.#X===0&&Q[0]===""&&Q[1]===""&&typeof Q[2]==="string"&&!!Q[2]&&typeof Q[3]==="string"&&!!Q[3]}isDrive(){let Q=this.#Z;return this.#I!==void 0?this.#I:this.#I=this.#q==="win32"&&this.#X===0&&this.length>1&&typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0])}isAbsolute(){let Q=this.#Z;return this.#G!==void 0?this.#G:this.#G=Q[0]===""&&Q.length>1||this.isDrive()||this.isUNC()}root(){let Q=this.#Z[0];return typeof Q==="string"&&this.isAbsolute()&&this.#X===0?Q:""}checkFollowGlobstar(){return!(this.#X===0||!this.isGlobstar()||!this.#V)}markFollowGlobstar(){if(this.#X===0||!this.isGlobstar()||!this.#V)return!1;return this.#V=!1,!0}}var x4=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class G8{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Q,{nobrace:Z,nocase:X,noext:q,noglobstar:Y,platform:J=x4}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=J,this.mmopts={dot:!0,nobrace:Z,nocase:X,noext:q,noglobstar:Y,optimizationLevel:2,platform:J,nocomment:!0,nonegate:!0};for(let H of Q)this.add(H)}add(Q){let Z=new V0(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 p0(q,Y,0,this.platform),H=new V0(J.globString(),this.mmopts),W=Y[Y.length-1]==="**",V=J.isAbsolute();if(V)this.absolute.push(H);else this.relative.push(H);if(W)if(V)this.absoluteChildren.push(H);else this.relativeChildren.push(H)}}ignored(Q){let Z=Q.fullpath(),X=`${Z}/`,q=Q.relative()||".",Y=`${q}/`;for(let J of this.relative)if(J.match(q)||J.match(Y))return!0;for(let J of this.absolute)if(J.match(Z)||J.match(X))return!0;return!1}childrenIgnored(Q){let Z=Q.fullpath()+"/",X=(Q.relative()||".")+"/";for(let q of this.relativeChildren)if(q.match(X))return!0;for(let q of this.absoluteChildren)if(q.match(Z))return!0;return!1}}class H7{store;constructor(Q=new Map){this.store=Q}copy(){return new H7(new Map(this.store))}hasWalked(Q,Z){return this.store.get(Q.fullpath())?.has(Z.globString())}storeWalked(Q,Z){let X=Q.fullpath(),q=this.store.get(X);if(q)q.add(Z.globString());else this.store.set(X,new Set([Z.globString()]))}}class jQ{store=new Map;add(Q,Z,X){let q=(Z?2:0)|(X?1:0),Y=this.store.get(Q);this.store.set(Q,Y===void 0?q:q&Y)}entries(){return[...this.store.entries()].map(([Q,Z])=>[Q,!!(Z&2),!!(Z&1)])}}class TQ{store=new Map;add(Q,Z){if(!Q.canReaddir())return;let X=this.store.get(Q);if(X){if(!X.find((q)=>q.globString()===Z.globString()))X.push(Z)}else this.store.set(Q,[Z])}get(Q){let Z=this.store.get(Q);if(!Z)throw Error("attempting to walk unknown path");return Z}entries(){return this.keys().map((Q)=>[Q,this.store.get(Q)])}keys(){return[...this.store.keys()].filter((Q)=>Q.canReaddir())}}class U8{hasWalkedCache;matches=new jQ;subwalks=new TQ;patterns;follow;dot;opts;constructor(Q,Z){this.opts=Q,this.follow=!!Q.follow,this.dot=!!Q.dot,this.hasWalkedCache=Z?Z.copy():new H7}processPatterns(Q,Z){this.patterns=Z;let X=Z.map((q)=>[Q,q]);for(let[q,Y]of X){this.hasWalkedCache.storeWalked(q,Y);let J=Y.root(),H=Y.isAbsolute()&&this.opts.absolute!==!1;if(J){q=q.resolve(J==="/"&&this.opts.root!==void 0?this.opts.root:J);let 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===r){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 U8(this.opts,this.hasWalkedCache)}filterEntries(Q,Z){let X=this.subwalks.get(Q),q=this.child();for(let Y of Z)for(let J of X){let H=J.isAbsolute(),W=J.pattern(),V=J.rest();if(W===r)q.testGlobstar(Y,J,V,H);else if(W instanceof RegExp)q.testRegExp(Y,W,V,H);else q.testString(Y,W,V,H)}return q}testGlobstar(Q,Z,X,q){if(this.dot||!Q.name.startsWith(".")){if(!Z.hasMore())this.matches.add(Q,q,!1);if(Q.canReaddir()){if(this.follow||!Q.isSymbolicLink())this.subwalks.add(Q,Z);else if(Q.isSymbolicLink()){if(X&&Z.checkFollowGlobstar())this.subwalks.add(Q,X);else if(Z.markFollowGlobstar())this.subwalks.add(Q,Z)}}}if(X){let Y=X.pattern();if(typeof Y==="string"&&Y!==".."&&Y!==""&&Y!==".")this.testString(Q,Y,X.rest(),q);else if(Y===".."){let J=Q.parent||Q;this.subwalks.add(J,X)}else if(Y instanceof RegExp)this.testRegExp(Q,Y,X.rest(),q)}}testRegExp(Q,Z,X,q){if(!Z.test(Q.name))return;if(!X)this.matches.add(Q,q,!1);else this.subwalks.add(Q,X)}testString(Q,Z,X,q){if(!Q.isNamed(Z))return;if(!X)this.matches.add(Q,q,!1);else this.subwalks.add(Q,X)}}var u4=(Q,Z)=>typeof Q==="string"?new G8([Q],Z):Array.isArray(Q)?new G8(Q,Z):Q;class V7{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Z=[];#Q;#X;signal;maxDepth;includeChildMatches;constructor(Q,Z,X){if(this.patterns=Q,this.path=Z,this.opts=X,this.#X=!X.posix&&X.platform==="win32"?"\\":"/",this.includeChildMatches=X.includeChildMatches!==!1,X.ignore||!this.includeChildMatches){if(this.#Q=u4(X.ignore??[],X),!this.includeChildMatches&&typeof this.#Q.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=X.maxDepth||1/0,X.signal)this.signal=X.signal,this.signal.addEventListener("abort",()=>{this.#Z.length=0})}#q(Q){return this.seen.has(Q)||!!this.#Q?.ignored?.(Q)}#J(Q){return!!this.#Q?.childrenIgnored?.(Q)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let Q=void 0;while(!this.paused&&(Q=this.#Z.shift()))Q()}onResume(Q){if(this.signal?.aborted)return;if(!this.paused)Q();else this.#Z.push(Q)}async matchCheck(Q,Z){if(Z&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Q.realpathCached()||await Q.realpath(),!X)return;Q=X}let Y=Q.isUnknown()||this.opts.stat?await Q.lstat():Q;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let J=await Y.realpath();if(J&&(J.isUnknown()||this.opts.stat))await J.lstat()}return this.matchCheckTest(Y,Z)}matchCheckTest(Q,Z){return Q&&(this.maxDepth===1/0||Q.depth()<=this.maxDepth)&&(!Z||Q.canReaddir())&&(!this.opts.nodir||!Q.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!Q.isSymbolicLink()||!Q.realpathCached()?.isDirectory())&&!this.#q(Q)?Q:void 0}matchCheckSync(Q,Z){if(Z&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Q.realpathCached()||Q.realpathSync(),!X)return;Q=X}let Y=Q.isUnknown()||this.opts.stat?Q.lstatSync():Q;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let J=Y.realpathSync();if(J&&(J?.isUnknown()||this.opts.stat))J.lstatSync()}return this.matchCheckTest(Y,Z)}matchFinish(Q,Z){if(this.#q(Q))return;if(!this.includeChildMatches&&this.#Q?.add){let Y=`${Q.relativePosix()}/**`;this.#Q.add(Y)}let X=this.opts.absolute===void 0?Z:this.opts.absolute;this.seen.add(Q);let q=this.opts.mark&&Q.isDirectory()?this.#X:"";if(this.opts.withFileTypes)this.matchEmit(Q);else if(X){let Y=this.opts.posix?Q.fullpathPosix():Q.fullpath();this.matchEmit(Y+q)}else{let Y=this.opts.posix?Q.relativePosix():Q.relative(),J=this.opts.dotRelative&&!Y.startsWith(".."+this.#X)?"."+this.#X:"";this.matchEmit(!Y?"."+q:J+Y+q)}}async match(Q,Z,X){let q=await this.matchCheck(Q,X);if(q)this.matchFinish(q,Z)}matchSync(Q,Z,X){let q=this.matchCheckSync(Q,X);if(q)this.matchFinish(q,Z)}walkCB(Q,Z,X){if(this.signal?.aborted)X();this.walkCB2(Q,Z,new U8(this.opts),X)}walkCB2(Q,Z,X,q){if(this.#J(Q))return q();if(this.signal?.aborted)q();if(this.paused){this.onResume(()=>this.walkCB2(Q,Z,X,q));return}X.processPatterns(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#q(H))continue;Y++,this.match(H,W,V).then(()=>J())}for(let H of X.subwalkTargets()){if(this.maxDepth!==1/0&&H.depth()>=this.maxDepth)continue;Y++;let W=H.readdirCached();if(H.calledReaddir())this.walkCB3(H,W,X,J);else H.readdirCB((V,K)=>this.walkCB3(H,K,X,J),!0)}J()}walkCB3(Q,Z,X,q){X=X.filterEntries(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#q(H))continue;Y++,this.match(H,W,V).then(()=>J())}for(let[H,W]of X.subwalks.entries())Y++,this.walkCB2(H,W,X.child(),J);J()}walkCBSync(Q,Z,X){if(this.signal?.aborted)X();this.walkCB2Sync(Q,Z,new U8(this.opts),X)}walkCB2Sync(Q,Z,X,q){if(this.#J(Q))return q();if(this.signal?.aborted)q();if(this.paused){this.onResume(()=>this.walkCB2Sync(Q,Z,X,q));return}X.processPatterns(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#q(H))continue;this.matchSync(H,W,V)}for(let H of X.subwalkTargets()){if(this.maxDepth!==1/0&&H.depth()>=this.maxDepth)continue;Y++;let W=H.readdirSync();this.walkCB3Sync(H,W,X,J)}J()}walkCB3Sync(Q,Z,X,q){X=X.filterEntries(Q,Z);let Y=1,J=()=>{if(--Y===0)q()};for(let[H,W,V]of X.matches.entries()){if(this.#q(H))continue;this.matchSync(H,W,V)}for(let[H,W]of X.subwalks.entries())Y++,this.walkCB2Sync(H,W,X.child(),J);J()}}class h8 extends V7{matches=new Set;constructor(Q,Z,X){super(Q,Z,X)}matchEmit(Q){this.matches.add(Q)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise((Q,Z)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)Z(this.signal.reason);else Q(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class g8 extends V7{results;constructor(Q,Z,X){super(Q,Z,X);this.results=new u0({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(Q){if(this.results.write(Q),!this.results.flowing)this.pause()}stream(){let Q=this.path;if(Q.isUnknown())Q.lstat().then(()=>{this.walkCB(Q,this.patterns,()=>this.results.end())});else this.walkCB(Q,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var h4=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class B0{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(Q,Z){if(!Z)throw TypeError("glob options required");if(this.withFileTypes=!!Z.withFileTypes,this.signal=Z.signal,this.follow=!!Z.follow,this.dot=!!Z.dot,this.dotRelative=!!Z.dotRelative,this.nodir=!!Z.nodir,this.mark=!!Z.mark,!Z.cwd)this.cwd="";else if(Z.cwd instanceof URL||Z.cwd.startsWith("file://"))Z.cwd=f4(Z.cwd);if(this.cwd=Z.cwd||"",this.root=Z.root,this.magicalBraces=!!Z.magicalBraces,this.nobrace=!!Z.nobrace,this.noext=!!Z.noext,this.realpath=!!Z.realpath,this.absolute=Z.absolute,this.includeChildMatches=Z.includeChildMatches!==!1,this.noglobstar=!!Z.noglobstar,this.matchBase=!!Z.matchBase,this.maxDepth=typeof Z.maxDepth==="number"?Z.maxDepth:1/0,this.stat=!!Z.stat,this.ignore=Z.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error("cannot set absolute and withFileTypes:true");if(typeof Q==="string")Q=[Q];if(this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z.allowWindowsEscape===!1,this.windowsPathsNoEscape)Q=Q.map((W)=>W.replace(/\\/g,"/"));if(this.matchBase){if(Z.noglobstar)throw TypeError("base matching requires globstar");Q=Q.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=Q,this.platform=Z.platform||h4,this.opts={...Z,platform:this.platform},Z.scurry){if(this.scurry=Z.scurry,Z.nocase!==void 0&&Z.nocase!==Z.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let W=Z.platform==="win32"?_8:Z.platform==="darwin"?f8:Z.platform?z8:FQ;this.scurry=new W(this.cwd,{nocase:Z.nocase,fs:Z.fs})}this.nocase=this.scurry.nocase;let X=this.platform==="darwin"||this.platform==="win32",q={...Z,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:X,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},Y=this.pattern.map((W)=>new V0(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 p0(W,K,0,this.platform)})}async walk(){return[...await new h8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new h8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new g8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new g8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var K7=(Q,Z={})=>{if(!Array.isArray(Q))Q=[Q];for(let X of Q)if(new V0(X,Z).hasMagic())return!0;return!1};function m8(Q,Z={}){return new B0(Q,Z).streamSync()}function NQ(Q,Z={}){return new B0(Q,Z).stream()}function c8(Q,Z={}){return new B0(Q,Z).walkSync()}async function wQ(Q,Z={}){return new B0(Q,Z).walk()}function l8(Q,Z={}){return new B0(Q,Z).iterateSync()}function PQ(Q,Z={}){return new B0(Q,Z).iterate()}var g4=m8,m4=Object.assign(NQ,{sync:m8}),c4=l8,l4=Object.assign(PQ,{sync:l8}),d4=Object.assign(c8,{stream:m8,iterate:l8}),SQ=Object.assign(wQ,{glob:wQ,globSync:c8,sync:d4,globStream:NQ,stream:m4,globStreamSync:m8,streamSync:g4,globIterate:PQ,iterate:l4,globIterateSync:l8,iterateSync:c4,Glob:B0,hasMagic:K7,escape:m0,unescape:G0});SQ.glob=SQ;import i4 from"node:path";var bQ=({dir:Q,pattern:Z="*",nodir:X=!1,dot:q=!0,ignore:Y=[],absolute:J=!1,matchBase:H=!1,follow:W=!1})=>{if(Q=Q||process.cwd(),Q=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 kQ from"lodash.clonedeep";import p4 from"@fnet/key-value-transformer";async function c({node:Q,initNode:Z,extra:X=!0}){if(Reflect.has(Q.definition,"modules")&&!Array.isArray(Q.definition.modules)){let q=Q.definition.modules;Q.definition.modules=[],Object.keys(q).forEach((Y)=>{let J={...q[Y]};if(typeof J.export==="boolean")J.export=J.export===!0?Y:!1;else if(typeof J.export==="string")J.export=J.export;else delete J.export;Q.definition.modules.push({[Y]:J})})}if(X){let q=[],Y=await p4({data:Q.definition,callback:(J,H,W)=>{let V=P0(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 c({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=DQ}async function DQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||kQ(Q.definition);let Y=Q.context.transform;for(let J of Q.childs)if(J.context.transform=J.context.transform||kQ(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 $8={hits:a4,init:n4,resolve:DQ};async function r4({node:Q}){if(Object.keys(Q.definition).filter((q)=>P0(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)=>P0(W)==="if");if(Y){let W=Z.definition[Y],V=P0(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)=>P0(W)==="elseif"),H=0;for(let W of J){let V=Z.definition[W],K=P0(W,!0);q.push({name:`${Z.name}_elseif_${H++}`,definition:V,processor:{expression:W,statement:K.statement,processor:K.processor}}),delete Z.definition[W]}if(Z.definition.elseif){let{condition:W,...V}=Z.definition.elseif;q.push({name:`${Z.name}_elseif_${H++}`,definition:V,processor:{expression:`elseif::${W}`,statement:W}}),delete Z.definition.elseif}Z.definition.switch=[];for(let W of q)Z.definition.switch.push({condition:W.processor.statement,...W.definition});if(Z.definition?.else){let W=Z.definition.else;Z.definition.switch.push({default:W}),delete Z.definition.else}await $8.init(Q)}var _7={hits:r4,init:s4};import vQ from"lodash.clonedeep";async function o4({node:Q}){return Q.definition.hasOwnProperty("try")&&Q.definition.hasOwnProperty("except")}async function t4({node:Q,initNode:Z}){if(Q.type="tryexcept",await c({node:Q,initNode:Z,extra:!1}),Q.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=yQ}async function yQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||vQ(Q.definition);let Y=Q.context.transform;if(Q.context.try=Q.childs.find((J)=>J.name==="try"),Q.context.except=Q.childs.find((J)=>J.name==="except"),Q.context.except){let J=Q.context.except;if(J.context.transform=J.context.transform||vQ(J.definition),!J.context.transform.hasOwnProperty("as"))J.context.transform.as="error"}await b({node:Q,transformExpression:q}),await Z({node:Q})}var z7={hits:o4,init:t4,resolve:yQ};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 c({node:Q,initNode:Z}),Q.resolve=EQ}async function EQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||e4(Q.definition);let Y=Q.context.transform;await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var G7={hits:Q1,init:Z1,resolve:EQ};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 c({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=xQ}async function xQ({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 U7={hits:q1,init:Y1,resolve:xQ};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=uQ}async function uQ({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 $7={hits:W1,init:H1,resolve:uQ};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=fQ}async function fQ({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 M7={hits:K1,init:_1,resolve:fQ};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=hQ}async function hQ({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 O7={hits:G1,init:U1,resolve:hQ};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 c({node:Q,initNode:Z}),Q.resolve=gQ}async function gQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||$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 M8={hits:M1,init:O1,resolve:gQ};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=mQ}async function mQ({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 A7={hits:B1,init:R1,resolve:mQ};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 c({node:Q,initNode:Z}),Q.resolve=cQ}async function cQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||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 B7={hits:C1,init:L1,resolve:cQ};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=lQ}async function lQ({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 R7={hits:j1,init:T1,resolve:lQ};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=dQ}async function dQ({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 I7={hits:S1,init:N1,resolve:dQ};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=iQ}async function iQ({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 C7={hits:b1,init:k1,resolve:iQ};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 c({node:Q,initNode:Z}),Q.resolve=pQ}async function pQ({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 L7={hits:v1,init:y1,resolve:pQ};function F7({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 aQ{#Z;#Q;#X;#q;constructor({key:Q,npm:Z,master:X,extras:q}){this.#Z=Q,this.#Q=Z,this.#X=X,this.#q=q}hits({node:Q}){return Q.definition.hasOwnProperty(this.#Z)}async init(Q){let{node:Z}=Q,X=this.#Z,q=Z.definition,Y=typeof q[X];if(q.call=`npm:${this.#Q}`,Y!=="object")q.args={...q.args,[`${this.#X}`]:q[X]};else q.args=q[X];if(delete q[X],this.#q)for(let J in this.#q)q[J]=this.#q[J];console.log(`[npm-block] ${this.#Z} --> ${this.#Q}`),await M8.init(Q)}}function s(Q){return new aQ(Q)}import 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 c({node:Q,initNode:Z}),Q.resolve=nQ}async function nQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||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 j7={hits:x1,init:u1,resolve:nQ};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 c({node:Q,initNode:Z}),Q.resolve=rQ}async function rQ({node:Q,resolveTypeCommon:Z,resolveNextBlock:X,transformExpression:q}){Q.context.transform=Q.context.transform||f1(Q.definition),await b({node:Q,transformExpression:q}),await Z({node:Q}),X({node:Q})}var T7={hits:h1,init:g1,resolve:rQ};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=sQ}async function sQ({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 w7={hits:c1,init:l1,resolve:sQ};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=oQ}async function oQ({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 S7={hits:i1,init:p1,resolve:oQ};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=tQ}async function tQ({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 N7={hits:n1,init:r1,resolve:tQ};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 c({node:Q,initNode:Z});let X=Q.definition.http,q;if(typeof X==="string")q={url:X,method:"GET",headers:{},timeout:30000};else if(typeof X==="object"){if(q={url:X.url,method:X.method||"GET",headers:X.headers||{},body:X.body,params:X.params,timeout:X.timeout||30000},!q.url)throw Error(`HTTP step '${Q.name}' requires a url property`)}else throw Error(`HTTP step '${Q.name}' requires a string URL or object configuration`);let Y=["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"],J=q.method.toUpperCase();if(!Y.includes(J))throw Error(`HTTP step '${Q.name}' has invalid method '${q.method}'. Valid options: ${Y.join(", ")}`);if(q.method=J,q.timeout&&(typeof q.timeout!=="number"||q.timeout<=0))throw Error(`HTTP step '${Q.name}' timeout must be a positive number`);Q.definition.http=q,Q.resolve=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 P7={hits:o1,init:t1};var eQ=({path:Q})=>{if(!Q)throw Error("Path is required");let Z=/^@([^\/]+\/[^\/]+)(?:\/(.+))?$/,X=/^([^\/]+)(?:\/(.+))?$/,q;if(q=Q.match(Z))return{path:Q,package:"@"+q[1],subpath:q[2]||null};else if(q=Q.match(X))return{path:Q,package:q[1],subpath:q[2]||null};return null};import W2 from"node:os";class YZ{#Z;#Q;#X;#q;#J;#C;#I;#K;#G;#V;#z;#Y;#O;#M;#$;#A;#j;#R;#F;#H;#L;#_=[];constructor(Q){this.#Z=new t7,this.#Q=Q,this.#C=[],this.#I=[],this.#K={},this._expire_ttl=3600,this._expire_ttl_short=300,this.#_.push(s({key:"config",npm:"@fnet/config",master:"name"})),this.#_.push(s({key:"yaml",npm:"@fnet/yaml",master:"file"})),this.#_.push(s({key:"prompt",npm:"@fnet/prompt",master:"message"})),this.#_.push(s({key:"html-link",npm:"@flownet/lib-load-browser-link-url",master:"src"})),this.#_.push(s({key:"html-script",npm:"@flownet/lib-load-browser-script-url",master:"src"})),this.#_.push(s({key:"http-server",npm:"@fnet/node-express",master:"server_port"})),this.#_.push(s({key:"shell",npm:"@fnet/shell-flow",master:"commands"})),this.#_.push(s({key:"list-files",npm:"@fnet/list-files",master:"pattern"})),this.#_.push(s({key:"up-list-files",npm:"@fnet/up-list-files",master:"pattern"})),this.#_.push(s({key:"auto-conda-env",npm:"@fnet/auto-conda-env",master:"envDir"})),this.#_.push(s({key:"ollama-chat",npm:"@fnet/ollama-chat",master:"model"})),this.#_.push(s({key:"ai",npm:"@fnet/ai",master:"prompt",extras:{subtype:"flow"}})),this.#_.push(s({key:"invoke",npm:"@fnet/invoke",master:"method",extras:{}})),this.#_.push(s({key:"fetch",npm:"@fnet/fetch",master:"url",extras:{}})),this.#_.push(s({key:"filemap",npm:"@fnet/filemap",master:"target",extras:{}})),this.#H={packageDependencies:this.#C,packageDevDependencies:this.#I,setProgress:this.setProgress.bind(this),context:this.#Q,Atom:R0,registerToPackageManager:this.registerToPackageManager.bind(this)},this.#L={initNode:this.initNode.bind(this),cloneDeep:XZ,resolveTypeCommon:this.resolveTypeCommon.bind(this),resolveNextBlock:F7,transformExpression:this.transformExpression.bind(this),transformValue:this.transformValue.bind(this)}}async _cache_set(Q,Z,X){}async init(){this.#z=this.#Q.buildId||qZ(),this.#H.buildId=this.#z,this.#$=this.#Q.mode,this.#A=["all","deploy","build","file"].includes(this.#$),this.#j=["all","deploy","build"].includes(this.#$),this.#R=["all","deploy"].includes(this.#$),this.#F=["all","deploy","build","file","bpmn"].includes(this.#$),this.#O=this.#Q.protocol,this.#Y="BUILD:"+this.#z,this.#M=(await 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 B6(this.#H),Q.runtime.type==="bun")await I6(this.#H);else await R6(this.#H);await this.initAtomLibsAndDeps({libs:Z.context.libs,packageDependencies:this.#C}),await this.resolveNodeTree({root:Z}),this.#V=Z}catch(Q){throw await this._cache_set(this.#Y,{status:"FAILED",message:Q?.message||Q}),Q}}async initAuth(){if(!this.#Q.id)return;this.#G=await this.#Z.init({config:this.#M}),this.#H.atomAccessToken=this.#G}async initWorkflow(){let Q=this.#Q.id;this.#X=this.#Q.project?.workflowAtom||await R0.get({id:Q}),this.#q=typeof this.#X.doc.content==="string"?(await 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=bQ({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=O8.configure(Q,{watch:!1,dev:!0}),this.#H.njEnv=this.#J}transformWorkflow({workflow:Q}){for(let Z of Object.values(Q))Z.steps=Z.steps||[],Z.steps=Z.steps.filter((X)=>Object.keys(X).length>0),Z.steps=Z.steps.map((X)=>this.transformStep({step:X}))}transformStep({step:Q}){if(Array.isArray(Q))throw Error("Step must be an object.");let[Z,X]=Object.entries(Q)[0];if(X.hasOwnProperty("onerror")){let{onerror:q,...Y}=X;Q[Z]={try:Y,except:q}}if(Q[Z].hasOwnProperty("steps")){let q=Q[Z].steps;if(!Array.isArray(q))throw Error("Steps must be an array.");Q[Z].steps=q.map((Y)=>this.transformStep({step:Y}))}return Q}async initNodeTree({workflow:Q}){let Z=["$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 z7.hits(Z))X="tryexcept",await z7.init(Z);else if(await $8.hits(Z))X="switch",await $8.init(Z);else if(await _7.hits(Z))X="if",await _7.init(Z);else if(await U7.hits(Z))X="for",await U7.init(Z);else if(await S7.hits(Z))X="retry",await S7.init(Z);else if(await N7.hits(Z))X="schedule",await N7.init(Z);else if(await $7.hits(Z))X="parallel",await $7.init(Z);else if(await w7.hits(Z))X="pipeline",await w7.init(Z);else if(await P7.hits(Z))X="http",await P7.init(Z);else if(await M8.hits(Z))X="call",await M8.init(Z);else if(await j7.hits(Z))X="new",await j7.init(Z);else if(await M7.hits(Z))X="raise",await M7.init(Z);else if(await B7.hits(Z))X="form",await B7.init(Z);else if(await R7.hits(Z))X="signal",await R7.init(Z);else if(await I7.hits(Z))X="wait",await I7.init(Z);else if(await A7.hits(Z))X="steps",await A7.init(Z);else if(await C7.hits(Z))X="next",await C7.init(Z);else if(await L7.hits(Z))X="modules",await L7.init(Z);else if(this.#_.find((q)=>q.hits(Z)))X="npm-block",await this.#_.find((q)=>q.hits(Z)).init(Z);else if(await G7.hits(Z))X="assign",await G7.init(Z);else if(await T7.hits(Z))X="output",await T7.init(Z);else if(await O7.hits(Z))X="return",await O7.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((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 w0({name:V.package,projectDir:this.#Q.projectDir,setProgress:this.#H.setProgress});Y.push({package:V.package,subpath:V.subpath,version:K.minorRange,type:"npm"})}return{name:X.pathname,doc:{type:"workflow.lib","content-type":"javascript",language:"js",dependencies:Y},protocol:X.protocol}}else if(X.protocol==="npm:"){let q=eQ({path:X.pathname}),Y=await w0({name:q.package,subpath:q.subpath,projectDir:this.#Q.projectDir,setProgress:this.#H.setProgress});return{name:X.pathname,doc:{type:"workflow.lib",subtype:Z?.definition?.subtype==="flow"?"workflow":null,"content-type":"javascript",language:"js",dependencies:[{package:q.package,version:Y.minorRange,type:"npm"}]},protocol:X.protocol}}else if(X.protocol==="use:")return{name:X.pathname,doc:{type:"function",dependencies:[]},protocol:X.protocol};else if(X.protocol==="node:")return{name:X.pathname,doc:{type:"workflow.lib","content-type":"javascript",language:"js",dependencies:[]},protocol:X.protocol};else if(X.protocol==="ac:"){let q=X.pathname.split("/");if(q.length===1)return await R0.first({where:{name:Q,parent_id:this.#M.env.ATOM_LIBRARIES_ID,type:"workflow.lib"}});if(q.length===2){let Y=await R0.first({where:{name:q[0],parent_id:this.#M.env.ATOM_LIBRARIES_ID,type:"folder"}});return await R0.first({where:{name:q[1],parent_id:Y.id,type:"workflow.lib"}})}}}async resolveNodeTree({root:Q}){for await(let Z of Q.childs)await this.resolveTypeWorkflow({node:Z})}async resolveTypeWorkflow({node:Q}){Q.context.transform=Q.context.transform||XZ(Q.definition);let Z=Q.context.transform;for(let X=0;X<Z.params?.length;X++){let q=Z.params[X];if(typeof q==="string")Z.params[X]={key:q,hasDefault:!1};else{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
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=O8.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=O8.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=O8.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=d6({expression:q});if(Y)if(Y.processor==="e"){let J=typeof Q[q]==="string"?Q[q]:Q[q];Q[Y.statement]=`$::${J}::`,delete Q[q]}else Q[q]=await this.transformValue(Q[q]);else Q[q]=await this.transformValue(Q[q])}}else if(typeof Q==="string"){let Z=d6({expression:Q,transform:{v:"v.{stmt}",for:"c.for.{stmt}",m:"c.module?.{stmt}||flow.module?.{stmt}",f:"c.form.{stmt}"}});if(Z){let{processor:X,transformed:q}=Z;switch(X){case"v":case"for":case"m":case"f":case"e":Q=`$::${q||Z.statement}::`;break}}}return Q}replaceSpecialPattern(Q){if(typeof Q!=="string")return console.error("❌ replaceSpecialPattern received non-string:",typeof Q,Q),Q;let Z=/"\$::(.*?)::"/g;return Q.replace(Z,"$1")}replaceExpressionLegacy(Q){let Z=/(?<outer>"\${(?<inner>[^{]*)}")/g;return Q.replaceAll(Z,"$2")}async createProjectYaml(){await this.setProgress({message:"Creating fnet.yaml"});let{content:X,...q}=this.#X.doc,Y=this.#Q.projectDir,J=k.resolve(Y,"fnet.yaml");T.writeFileSync(J,QZ.stringify(q),"utf8")}async createProjectMainYaml(){await this.setProgress({message:"Creating flow.main.yaml"});let X={content:QZ.stringify(this.#q)},q=this.#Q.templateDir,J=O8.compile(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 ZZ("prettier --write .",{cwd:k.resolve(Q,"src")});if(Z.code!==0)throw Error(Z.stderr)}else{let Z=await ZZ("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 R9({...this.#H,deploymentProject:Z,deploymentProjectTarget:H,yamlTarget:W})}}async registerToPackageManager(Q){let{target:Z,packageJSON:X}=Q;if(!this.#Q.id)return;let q=await R0.first({name:Z.params.name,parent_id:this.#M.env.ATOM_PACKAGES_ID});if(!q)q=await R0.create({parent_id:this.#M.env.ATOM_PACKAGES_ID,doc:{name:Z.params.name,type:"pm",versions:[{v:X.version}]}});else q.doc.versions.splice(0,0,{v:X.version}),await R0.update(q,{id:q.id})}async setProgress(Q){let Z=typeof Q==="string"?Q:Q?.message;console.log(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 F9({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 y6(this.#H),await v6(this.#H),await D6(this.#H),await k6(this.#H),await F6(this.#H),await C6(this.#H),Z.runtime.type==="bun")await N6(this.#H);else await w6(this.#H);if(await L6(this.#H),await E6(this.#H),await x6(this.#H),this.#j){if(await u6(this.#H),await f6(this.#H),this.#R)await this.deploy()}}await this._cache_set(this.#Y,{status:"COMPLETED",data:{network:Q}})}catch(Q){throw await this._cache_set(this.#Y,{status:"FAILED",message:Q.message||Q}),Q}}async createNetwork(){try{let Q=await j8({root:this.#V});await this._cache_set(this.#Y,{status:"COMPLETED",data:{...Q}})}catch(Q){throw await this._cache_set(this.#Y,{status:"FAILED",message:Q.message||Q}),Q}}}var D0=YZ;var 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"})},handler:async(Q)=>{try{let Z=await D(Q),X=new D0(Z);await X.init(),await X.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Z){console.error("Building workflow failed!",Z.message),process.exit(1)}}},JZ=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"})},handler:async(Q)=>{try{Q.dev=!0;let Z=await D(Q),X=new D0(Z);await X.init(),await X.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Z){console.error("Building workflow failed!",Z.message),process.exit(1)}}},WZ=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"})},handler:async(Q)=>{try{let Z=await D({...Q,mode:"all"}),X=new D0(Z);await X.init(),await X.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Z){console.error("Building workflow failed!",Z.message),process.exit(1)}}},HZ=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"})},handler:async(Q)=>{try{let Z=await D({...Q,mode:"file"}),X=new D0(Z);await X.init(),await X.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Z){console.error("Building workflow failed!",Z.message),process.exit(1)}}},VZ=_2;import KZ 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=KZ.resolve(q,".fnet");if(!d8.existsSync(H))d8.mkdirSync(H);let W=KZ.resolve(H,`${Q.name}.fnet`),V=d8.existsSync(W),K=(await import("@fnet/object-from-schema")).default,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)}}},_Z=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 j0 from"@fnet/prompt";import i8 from"chalk";import zZ 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 zZ({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 zZ({type:"multiselect",name:K,message:X,choices:W,initial:V,hint:"(Use space to select, enter to confirm)",validate:(G)=>{if(G.length===0&&!H)return"Please select at least one item";return!0}});if(H&&z[K].length===0)return null;return z[K]}var b7={promptForSelection:U2,promptForMultipleSelection:$2};var l=P.join(p8.homedir(),".fnet","express");async function UZ(Q){Q.command(["$0 [project-name]","create [project-name]"],"Create a new express project",(Z)=>{return Z.positional("project-name",{describe:"Name of the project",type:"string"}).option("yes",{alias:"y",describe:"Skip all prompts and use defaults",type:"boolean",default:!1}).option("runtime",{describe:"Runtime to use (node)",type:"string",choices:["node"],default:"node"})},async(Z)=>{await 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(l))N.mkdirSync(l,{recursive:!0});let Z=new Date().toISOString().slice(0,10).replace(/-/g,""),X=P.join(l,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 j0([{type:"input",name:"projectName",message:"Enter project name:",default:$}])).projectName}J=(await j0({type:"select",name:"runtime",message:"Select runtime:",choices:["node"],initial:J||"node"})).runtime}else{if(!q){let 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 j0([{type:"confirm",name:"proceed",message:`Create express project "${q}" in ${Y}?`,default:!0}])).proceed){console.log(L.yellow("Project creation cancelled."));return}}console.log(L.blue(`Creating express project "${q}" in ${Y}...`));let H=P.dirname(Y),V=["create","--name",P.basename(Y)];if(V.push("--runtime",J),Q.yes)V.push("--yes");if(!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(`
|
|
13
13
|
Express project "${q}" created successfully!`)),console.log(L.blue(`
|
|
14
14
|
Project location: ${Y}`)),!Q.yes)R2(Y);else z();else console.error(L.red(`
|