@freik/passable
Version:
## A CMake auto formatter
7 lines • 101 kB
JavaScript
#!/usr/bin/env node
import{readFileSync as Y5,writeFileSync as q5}from"node:fs";var YX=Symbol.for("freik.typetag");function h(Q){return Q===void 0}function m1(Q){return!h(Q)}function qX(Q){return Q===void 0||Q===null}function HX(Q){return!qX(Q)}function jX(Q,X,J){return X(Q)||J(Q)}function WX(Q,X){return(J)=>jX(J,Q,X)}function UX(Q,X,J){return X(Q)&&J(Q)}function GX(Q,...X){return X.some((J)=>J(Q))}function g1(...Q){return(X)=>GX(X,...Q)}function l0(Q){return UX(Q,wX,HX)}function wX(Q){return typeof Q==="object"}function B0(Q){return Array.isArray(Q)}function k(Q){return typeof Q==="string"}function R0(Q){return typeof Q==="number"&&!isNaN(Q-0)}var w5=WX(k,R0);function p1(Q){return typeof Q==="boolean"}function O0(Q){return typeof Q==="function"}function OX(Q){return Q instanceof Map}function i1(Q,X){if(!B0(Q))return!1;for(let J of Q)if(!X(J))return!1;return!0}function W1(Q){return(X)=>i1(X,Q)}function zX(Q,...X){return B0(Q)&&Q.length===X.length&&X.every((J,_)=>J(Q[_]))}function BX(...Q){return(X)=>zX(X,...Q)}function RX(Q,X,J){if(!OX(Q))return!1;for(let[_,V]of Q){if(!X(_))return!1;if(!J(V))return!1}return!0}function d1(Q,X){return(J)=>RX(J,Q,X)}function c1(Q){return typeof Q==="symbol"}function I0(Q,X){return l0(Q)&&X in Q}function IX(Q,X,J){return I0(Q,X)&&J(Q[X])}var z0=IX;function l1(Q,X){return z0(Q,X,k)}function MX(Q,X,J,_){if(!l0(X))return!1;let V=Object.keys(J).length,$=Object.keys(X),Z=$.length;for(let K of $){if(!I0(X,K))continue;let Y=X[K];if(h(Y)||X[K]===null){delete X[K],Z--;continue}if(z0(_,K,O0)){let j=_[K];if(!j(Y))return!1;Z--}else if(z0(J,K,O0)){let j=J[K];if(!j(Y))return!1;V--,Z--}}return V===0&&(Z===0||!Q)}function AX(Q,X={}){return(J)=>MX(!1,J,Q,X)}function FX(Q,X){if(!l0(Q))return!1;let J=Object.keys(Q),_=J.length;for(let V of J){if(!I0(Q,V))continue;let $=Q[V];if(h($)||Q[V]===null){delete Q[V],_--;continue}if(z0(X,V,O0)){let Z=X[V];if(!Z($))return!1;_--}}return _===0}function U1(Q){return(X)=>FX(X,Q)}function LX(Q,X,J){if(!l0(Q))return!1;let _=Object.keys(Q),V=_.length;for(let $ of _){if(!I0(Q,$))continue;let Z=Q[$];if(!X($)||!J(Z))return!1;V--}return V===0}function o1(Q,X){return(J)=>LX(J,Q,X)}var CX=new Function("try {return this===global;}catch(e){ return false;}"),NX=new Function("try {return this===window;}catch(e){ return false;}");function DX(){return typeof globalThis!=="undefined"}var n1=Symbol.for("freik.Set"),r1=Symbol.for("freik.Map"),a1=Symbol.for("freik.Symbol"),s1=Symbol.for("freik.RegExp"),t1=Symbol.for("freik.Date"),e1=Symbol.for("freik.BigInt");function uX(Q){return[...Q.entries()]}function EX(Q){return i1(Q,BX(m1,m1))?new Map(Q):void 0}function SX(Q){return[...Q]}function PX(Q){return B0(Q)?new Set(Q):void 0}function vX(Q){let X=Symbol.keyFor(Q);if(X===void 0)throw new Error("Unable to get a key for a symbol for pickling");return X}function fX(Q){return k(Q)?Symbol.for(Q):void 0}function xX(Q){return{source:Q.source,flags:Q.flags}}function bX(Q){if(l1(Q,"source")&&l1(Q,"flags"))return new RegExp(Q.source,Q.flags)}function TX(Q){return Q.toJSON()}function yX(Q){try{return k(Q)?new Date(Q):void 0}catch{return}}function kX(Q){return Q.toString()}function hX(Q){try{return k(Q)?BigInt(Q):void 0}catch{return}}var mX=new Map([[r1,uX],[n1,SX],[a1,vX],[s1,xX],[t1,TX],[e1,kX]]),gX=new Map([[r1,EX],[n1,PX],[a1,fX],[s1,bX],[t1,yX],[e1,hX]]),dX;((Q)=>{Q[Q.Success=0]="Success",Q[Q.Already=1]="Already",Q[Q.Fail=2]="Fail",Q[Q.DetectionFailure=3]="DetectionFailure"})(dX||={});var c0=YX;function j1(Q){if(!I0(Q,c0))return Q[c0]={to:mX,from:gX},0;if(!z0(Q,c0,AX({to:d1(g1(c1,k),O0),from:d1(g1(c1,k),O0)})))return 2;return 1}function cX(){if(DX())return j1(globalThis);if(NX())return j1(window);if(CX())return j1(global);return 3}switch(cX()){case 2:throw Error(`Invalid <global>[${String(c0)}] object`);case 3:throw Error("Unable to determine environment for pickling");default:break}import*as p0 from"fs";import*as M0 from"path";var G1={useTabs:!1,tabWidth:2,endOfLine:`
`,printWidth:80,commands:{add_custom_target:{controlKeywords:["COMMAND","DEPENDS","BYPRODUCTS","WORKING_DIRECTORY","COMMENT","JOB_POOL","JOB_SERVER_AWARE","SOURCES"],options:["ALL","VERBATIM","USES_TERMINAL","COMMAND_EXPAND_LISTS"]},add_library:{controlKeywords:["STATIC","SHARED","MODULE","OBJECT","INTERFACE","UNKNOWN","ALIAS"],options:["GLOBAL","EXCLUDE_FROM_ALL","IMPORTED"]},add_executable:{options:["WIN32","MACOSX_BUNDLE","EXCLUDE_FROM_ALL","IMPORTED","ALIAS"]},block:{controlKeywords:["PROPAGATE"],options:["SCOPE_FOR","POLICIES","VARIABLES"]},execute_process:{controlKeywords:["COMMAND","WORKING_DIRECTORY","RESULT_VARIABLE","OUTPUT_VARIABLE","ERROR_VARIABLE","INPUT_FILE","OUTPUT_FILE","ERROR_FILE","TIMEOUT","ECHO_ERROR_VARIABLE","ECHO_OUTPUT_VARIABLE","ECHO_ERROR_VARIABLE","OUTPUT_STRIP_TRAILING_WHITESPACE"]},list:{controlKeywords:["APPEND","INSERT","REMOVE_AT","REMOVE_ITEM","FIND","LENGTH","GET","SUBLIST","SORT","UNIQUE"]},set_target_properties:{controlKeywords:["PROPERTIES"]},target_sources:{controlKeywords:["INTERFACE","PUBLIC","PRIVATE","FILE_SET","TYPE","BASE_DIRS","FILES"],options:["HEADERS","CXX_MODULES"]},target_precompile_headers:{controlKeywords:["INTERFACE","PUBLIC","PRIVATE","REUSE_FROM"]},target_compile_definitions:{controlKeywords:["INTERFACE","PUBLIC","PRIVATE"]},target_include_directories:{controlKeywords:["INTERFACE","PUBLIC","PRIVATE"]},target_link_libraries:{controlKeywords:["INTERFACE","PUBLIC","PRIVATE"]},if:{controlKeywords:["AND","OR"],options:["NOT"]},elseif:{controlKeywords:["AND","OR"],options:["NOT"]},while:{controlKeywords:["AND","OR"],options:["NOT"]},set:{indentAfter:0}}};var QQ=Object.freeze({controlKeywords:[],indentAfter:-1,options:[]}),Y0={controlKeywords:new Set,indentAfter:-1,options:new Set},pX=U1({controlKeywords:W1(k),indentAfter:R0,options:W1(k)}),iX=U1({useTabs:p1,tabWidth:R0,endOfLine:(Q)=>Q===`
`||Q===`\r
`,printWidth:R0,commands:o1(k,pX)}),w1=G1;function O1(Q){return Q.endOfLine??w1.endOfLine}function oX(){let Q=process.cwd();while(M0.dirname(Q)!=Q){let X=M0.join(Q,".passablerc.json");if(p0.existsSync(X))return X;Q=M0.dirname(Q)}return}function nX(Q){try{let X=p0.readFileSync(Q,"utf-8"),J=JSON.parse(X);return iX(J)?J:{}}catch(X){return console.error(`Error parsing config file at ${Q}:`,X),{}}}function JQ(){let Q=oX();if(Q)return nX(Q);return{}}function XQ(Q){return{controlKeywords:new Set(Q.controlKeywords.map((X)=>X.toUpperCase())),options:new Set(Q.options.map((X)=>X.toUpperCase())),indentAfter:Q.indentAfter??0}}function _Q(Q,X=G1.commands){let J=new Map;for(let[_,V]of Object.entries(X))J.set(_.toLowerCase(),[_,XQ({...QQ,...V})]);for(let[_,V]of Object.entries(Q))J.set(_.toLowerCase(),[_,XQ({...QQ,...V})]);return J}var z1=(Q,X,J)=>{let _=Q instanceof RegExp?VQ(Q,J):Q,V=X instanceof RegExp?VQ(X,J):X,$=_!==null&&V!=null&&rX(_,V,J);return $&&{start:$[0],end:$[1],pre:J.slice(0,$[0]),body:J.slice($[0]+_.length,$[1]),post:J.slice($[1]+V.length)}},VQ=(Q,X)=>{let J=X.match(Q);return J?J[0]:null},rX=(Q,X,J)=>{let _,V,$,Z=void 0,K,Y=J.indexOf(Q),j=J.indexOf(X,Y+1),q=Y;if(Y>=0&&j>0){if(Q===X)return[Y,j];_=[],$=J.length;while(q>=0&&!K){if(q===Y)_.push(q),Y=J.indexOf(Q,q+1);else if(_.length===1){let W=_.pop();if(W!==void 0)K=[W,j]}else{if(V=_.pop(),V!==void 0&&V<$)$=V,Z=j;j=J.indexOf(X,q+1)}q=Y<j&&Y>=0?Y:j}if(_.length&&Z!==void 0)K=[$,Z]}return K};var $Q="\x00SLASH"+Math.random()+"\x00",ZQ="\x00OPEN"+Math.random()+"\x00",R1="\x00CLOSE"+Math.random()+"\x00",KQ="\x00COMMA"+Math.random()+"\x00",YQ="\x00PERIOD"+Math.random()+"\x00",aX=new RegExp($Q,"g"),sX=new RegExp(ZQ,"g"),tX=new RegExp(R1,"g"),eX=new RegExp(KQ,"g"),Q2=new RegExp(YQ,"g"),X2=/\\\\/g,J2=/\\{/g,_2=/\\}/g,V2=/\\,/g,$2=/\\./g;function B1(Q){return!isNaN(Q)?parseInt(Q,10):Q.charCodeAt(0)}function Z2(Q){return Q.replace(X2,$Q).replace(J2,ZQ).replace(_2,R1).replace(V2,KQ).replace($2,YQ)}function K2(Q){return Q.replace(aX,"\\").replace(sX,"{").replace(tX,"}").replace(eX,",").replace(Q2,".")}function qQ(Q){if(!Q)return[""];let X=[],J=z1("{","}",Q);if(!J)return Q.split(",");let{pre:_,body:V,post:$}=J,Z=_.split(",");Z[Z.length-1]+="{"+V+"}";let K=qQ($);if($.length)Z[Z.length-1]+=K.shift(),Z.push.apply(Z,K);return X.push.apply(X,Z),X}function HQ(Q){if(!Q)return[];if(Q.slice(0,2)==="{}")Q="\\{\\}"+Q.slice(2);return A0(Z2(Q),!0).map(K2)}function Y2(Q){return"{"+Q+"}"}function q2(Q){return/^-?0\d/.test(Q)}function H2(Q,X){return Q<=X}function j2(Q,X){return Q>=X}function A0(Q,X){let J=[],_=z1("{","}",Q);if(!_)return[Q];let V=_.pre,$=_.post.length?A0(_.post,!1):[""];if(/\$$/.test(_.pre))for(let Z=0;Z<$.length;Z++){let K=V+"{"+_.body+"}"+$[Z];J.push(K)}else{let Z=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(_.body),K=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(_.body),Y=Z||K,j=_.body.indexOf(",")>=0;if(!Y&&!j){if(_.post.match(/,(?!,).*\}/))return Q=_.pre+"{"+_.body+R1+_.post,A0(Q);return[Q]}let q;if(Y)q=_.body.split(/\.\./);else if(q=qQ(_.body),q.length===1&&q[0]!==void 0){if(q=A0(q[0],!1).map(Y2),q.length===1)return $.map((U)=>_.pre+q[0]+U)}let W;if(Y&&q[0]!==void 0&&q[1]!==void 0){let U=B1(q[0]),O=B1(q[1]),w=Math.max(q[0].length,q[1].length),I=q.length===3&&q[2]!==void 0?Math.abs(B1(q[2])):1,R=H2;if(O<U)I*=-1,R=j2;let F=q.some(q2);W=[];for(let G=U;R(G,O);G+=I){let z;if(K){if(z=String.fromCharCode(G),z==="\\")z=""}else if(z=String(G),F){let A=w-z.length;if(A>0){let H=new Array(A+1).join("0");if(G<0)z="-"+H+z.slice(1);else z=H+z}}W.push(z)}}else{W=[];for(let U=0;U<q.length;U++)W.push.apply(W,A0(q[U],!1))}for(let U=0;U<W.length;U++)for(let O=0;O<$.length;O++){let w=V+W[U]+$[O];if(!X||Y||w)J.push(w)}}return J}var F0=(Q)=>{if(typeof Q!=="string")throw new TypeError("invalid pattern");if(Q.length>65536)throw new TypeError("pattern is too long")};var W2={"[: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]},L0=(Q)=>Q.replace(/[[\]\\-]/g,"\\$&"),U2=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),jQ=(Q)=>Q.join(""),WQ=(Q,X)=>{let J=X;if(Q.charAt(J)!=="[")throw new Error("not in a brace expression");let _=[],V=[],$=J+1,Z=!1,K=!1,Y=!1,j=!1,q=J,W="";Q:while($<Q.length){let I=Q.charAt($);if((I==="!"||I==="^")&&$===J+1){j=!0,$++;continue}if(I==="]"&&Z&&!Y){q=$+1;break}if(Z=!0,I==="\\"){if(!Y){Y=!0,$++;continue}}if(I==="["&&!Y){for(let[R,[M,F,G]]of Object.entries(W2))if(Q.startsWith(R,$)){if(W)return["$.",!1,Q.length-J,!0];if($+=R.length,G)V.push(M);else _.push(M);K=K||F;continue Q}}if(Y=!1,W){if(I>W)_.push(L0(W)+"-"+L0(I));else if(I===W)_.push(L0(I));W="",$++;continue}if(Q.startsWith("-]",$+1)){_.push(L0(I+"-")),$+=2;continue}if(Q.startsWith("-",$+1)){W=I,$+=2;continue}_.push(L0(I)),$++}if(q<$)return["",!1,0,!1];if(!_.length&&!V.length)return["$.",!1,Q.length-J,!0];if(V.length===0&&_.length===1&&/^\\?.$/.test(_[0])&&!j){let I=_[0].length===2?_[0].slice(-1):_[0];return[U2(I),!1,q-J,!1]}let U="["+(j?"^":"")+jQ(_)+"]",O="["+(j?"":"^")+jQ(V)+"]";return[_.length&&V.length?"("+U+"|"+O+")":_.length?U:O,K,q-J,!0]};var p=(Q,{windowsPathsNoEscape:X=!1}={})=>{return X?Q.replace(/\[([^\/\\])\]/g,"$1"):Q.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var G2=new Set(["!","?","+","*","@"]),UQ=(Q)=>G2.has(Q),w2="(?!(?:^|/)\\.\\.?(?:$|/))",i0="(?!\\.)",O2=new Set(["[","."]),z2=new Set(["..","."]),B2=new Set("().*{}+?[]^$\\!"),R2=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),I1="[^/]",GQ=I1+"*?",wQ=I1+"+?";class S{type;#Q;#X;#$=!1;#V=[];#Z;#I;#z;#K=!1;#j;#Y;#q=!1;constructor(Q,X,J={}){if(this.type=Q,Q)this.#X=!0;if(this.#Z=X,this.#Q=this.#Z?this.#Z.#Q:this,this.#j=this.#Q===this?J:this.#Q.#j,this.#z=this.#Q===this?[]:this.#Q.#z,Q==="!"&&!this.#Q.#K)this.#z.push(this);this.#I=this.#Z?this.#Z.#V.length:0}get hasMagic(){if(this.#X!==void 0)return this.#X;for(let Q of this.#V){if(typeof Q==="string")continue;if(Q.type||Q.hasMagic)return this.#X=!0}return this.#X}toString(){if(this.#Y!==void 0)return this.#Y;if(!this.type)return this.#Y=this.#V.map((Q)=>String(Q)).join("");else return this.#Y=this.type+"("+this.#V.map((Q)=>String(Q)).join("|")+")"}#J(){if(this!==this.#Q)throw new Error("should only call on root");if(this.#K)return this;this.toString(),this.#K=!0;let Q;while(Q=this.#z.pop()){if(Q.type!=="!")continue;let X=Q,J=X.#Z;while(J){for(let _=X.#I+1;!J.type&&_<J.#V.length;_++)for(let V of Q.#V){if(typeof V==="string")throw new Error("string part in extglob AST??");V.copyIn(J.#V[_])}X=J,J=X.#Z}}return this}push(...Q){for(let X of Q){if(X==="")continue;if(typeof X!=="string"&&!(X instanceof S&&X.#Z===this))throw new Error("invalid part: "+X);this.#V.push(X)}}toJSON(){let Q=this.type===null?this.#V.slice().map((X)=>typeof X==="string"?X:X.toJSON()):[this.type,...this.#V.map((X)=>X.toJSON())];if(this.isStart()&&!this.type)Q.unshift([]);if(this.isEnd()&&(this===this.#Q||this.#Q.#K&&this.#Z?.type==="!"))Q.push({});return Q}isStart(){if(this.#Q===this)return!0;if(!this.#Z?.isStart())return!1;if(this.#I===0)return!0;let Q=this.#Z;for(let X=0;X<this.#I;X++){let J=Q.#V[X];if(!(J instanceof S&&J.type==="!"))return!1}return!0}isEnd(){if(this.#Q===this)return!0;if(this.#Z?.type==="!")return!0;if(!this.#Z?.isEnd())return!1;if(!this.type)return this.#Z?.isEnd();let Q=this.#Z?this.#Z.#V.length:0;return this.#I===Q-1}copyIn(Q){if(typeof Q==="string")this.push(Q);else this.push(Q.clone(this))}clone(Q){let X=new S(this.type,Q);for(let J of this.#V)X.copyIn(J);return X}static#W(Q,X,J,_){let V=!1,$=!1,Z=-1,K=!1;if(X.type===null){let U=J,O="";while(U<Q.length){let w=Q.charAt(U++);if(V||w==="\\"){V=!V,O+=w;continue}if($){if(U===Z+1){if(w==="^"||w==="!")K=!0}else if(w==="]"&&!(U===Z+2&&K))$=!1;O+=w;continue}else if(w==="["){$=!0,Z=U,K=!1,O+=w;continue}if(!_.noext&&UQ(w)&&Q.charAt(U)==="("){X.push(O),O="";let I=new S(w,X);U=S.#W(Q,I,U,_),X.push(I);continue}O+=w}return X.push(O),U}let Y=J+1,j=new S(null,X),q=[],W="";while(Y<Q.length){let U=Q.charAt(Y++);if(V||U==="\\"){V=!V,W+=U;continue}if($){if(Y===Z+1){if(U==="^"||U==="!")K=!0}else if(U==="]"&&!(Y===Z+2&&K))$=!1;W+=U;continue}else if(U==="["){$=!0,Z=Y,K=!1,W+=U;continue}if(UQ(U)&&Q.charAt(Y)==="("){j.push(W),W="";let O=new S(U,j);j.push(O),Y=S.#W(Q,O,Y,_);continue}if(U==="|"){j.push(W),W="",q.push(j),j=new S(null,X);continue}if(U===")"){if(W===""&&X.#V.length===0)X.#q=!0;return j.push(W),W="",X.push(...q,j),Y}W+=U}return X.type=null,X.#X=void 0,X.#V=[Q.substring(J-1)],Y}static fromGlob(Q,X={}){let J=new S(null,void 0,X);return S.#W(Q,J,0,X),J}toMMPattern(){if(this!==this.#Q)return this.#Q.toMMPattern();let Q=this.toString(),[X,J,_,V]=this.toRegExpSource();if(!(_||this.#X||this.#j.nocase&&!this.#j.nocaseMagicOnly&&Q.toUpperCase()!==Q.toLowerCase()))return J;let Z=(this.#j.nocase?"i":"")+(V?"u":"");return Object.assign(new RegExp(`^${X}$`,Z),{_src:X,_glob:Q})}get options(){return this.#j}toRegExpSource(Q){let X=Q??!!this.#j.dot;if(this.#Q===this)this.#J();if(!this.type){let K=this.isStart()&&this.isEnd(),Y=this.#V.map((U)=>{let[O,w,I,R]=typeof U==="string"?S.#G(U,this.#X,K):U.toRegExpSource(Q);return this.#X=this.#X||I,this.#$=this.#$||R,O}).join(""),j="";if(this.isStart()){if(typeof this.#V[0]==="string"){if(!(this.#V.length===1&&z2.has(this.#V[0]))){let O=O2,w=X&&O.has(Y.charAt(0))||Y.startsWith("\\.")&&O.has(Y.charAt(2))||Y.startsWith("\\.\\.")&&O.has(Y.charAt(4)),I=!X&&!Q&&O.has(Y.charAt(0));j=w?w2:I?i0:""}}}let q="";if(this.isEnd()&&this.#Q.#K&&this.#Z?.type==="!")q="(?:$|\\/)";return[j+Y+q,p(Y),this.#X=!!this.#X,this.#$]}let J=this.type==="*"||this.type==="+",_=this.type==="!"?"(?:(?!(?:":"(?:",V=this.#B(X);if(this.isStart()&&this.isEnd()&&!V&&this.type!=="!"){let K=this.toString();return this.#V=[K],this.type=null,this.#X=void 0,[K,p(this.toString()),!1,!1]}let $=!J||Q||X||!i0?"":this.#B(!0);if($===V)$="";if($)V=`(?:${V})(?:${$})*?`;let Z="";if(this.type==="!"&&this.#q)Z=(this.isStart()&&!X?i0:"")+wQ;else{let K=this.type==="!"?"))"+(this.isStart()&&!X&&!Q?i0:"")+GQ+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&$?")":this.type==="*"&&$?")?":`)${this.type}`;Z=_+V+K}return[Z,p(V),this.#X=!!this.#X,this.#$]}#B(Q){return this.#V.map((X)=>{if(typeof X==="string")throw new Error("string type in extglob ast??");let[J,_,V,$]=X.toRegExpSource(Q);return this.#$=this.#$||$,J}).filter((X)=>!(this.isStart()&&this.isEnd())||!!X).join("|")}static#G(Q,X,J=!1){let _=!1,V="",$=!1;for(let Z=0;Z<Q.length;Z++){let K=Q.charAt(Z);if(_){_=!1,V+=(B2.has(K)?"\\":"")+K;continue}if(K==="\\"){if(Z===Q.length-1)V+="\\\\";else _=!0;continue}if(K==="["){let[Y,j,q,W]=WQ(Q,Z);if(q){V+=Y,$=$||j,Z+=q-1,X=X||W;continue}}if(K==="*"){if(J&&Q==="*")V+=wQ;else V+=GQ;X=!0;continue}if(K==="?"){V+=I1,X=!0;continue}V+=R2(K)}return[V,p(Q),!!X,$]}}var q0=(Q,{windowsPathsNoEscape:X=!1}={})=>{return X?Q.replace(/[?*()[\]]/g,"[$&]"):Q.replace(/[?*()[\]\\]/g,"\\$&")};var b=(Q,X,J={})=>{if(F0(X),!J.nocomment&&X.charAt(0)==="#")return!1;return new d(X,J).match(Q)},I2=/^\*+([^+@!?\*\[\(]*)$/,M2=(Q)=>(X)=>!X.startsWith(".")&&X.endsWith(Q),A2=(Q)=>(X)=>X.endsWith(Q),F2=(Q)=>{return Q=Q.toLowerCase(),(X)=>!X.startsWith(".")&&X.toLowerCase().endsWith(Q)},L2=(Q)=>{return Q=Q.toLowerCase(),(X)=>X.toLowerCase().endsWith(Q)},C2=/^\*+\.\*+$/,N2=(Q)=>!Q.startsWith(".")&&Q.includes("."),D2=(Q)=>Q!=="."&&Q!==".."&&Q.includes("."),u2=/^\.\*+$/,E2=(Q)=>Q!=="."&&Q!==".."&&Q.startsWith("."),S2=/^\*+$/,P2=(Q)=>Q.length!==0&&!Q.startsWith("."),v2=(Q)=>Q.length!==0&&Q!=="."&&Q!=="..",f2=/^\?+([^+@!?\*\[\(]*)?$/,x2=([Q,X=""])=>{let J=BQ([Q]);if(!X)return J;return X=X.toLowerCase(),(_)=>J(_)&&_.toLowerCase().endsWith(X)},b2=([Q,X=""])=>{let J=RQ([Q]);if(!X)return J;return X=X.toLowerCase(),(_)=>J(_)&&_.toLowerCase().endsWith(X)},T2=([Q,X=""])=>{let J=RQ([Q]);return!X?J:(_)=>J(_)&&_.endsWith(X)},y2=([Q,X=""])=>{let J=BQ([Q]);return!X?J:(_)=>J(_)&&_.endsWith(X)},BQ=([Q])=>{let X=Q.length;return(J)=>J.length===X&&!J.startsWith(".")},RQ=([Q])=>{let X=Q.length;return(J)=>J.length===X&&J!=="."&&J!==".."},IQ=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",OQ={win32:{sep:"\\"},posix:{sep:"/"}},k2=IQ==="win32"?OQ.win32.sep:OQ.posix.sep;b.sep=k2;var P=Symbol("globstar **");b.GLOBSTAR=P;var h2="[^/]",m2=h2+"*?",g2="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",d2="(?:(?!(?:\\/|^)\\.).)*?",c2=(Q,X={})=>(J)=>b(J,Q,X);b.filter=c2;var g=(Q,X={})=>Object.assign({},Q,X),l2=(Q)=>{if(!Q||typeof Q!=="object"||!Object.keys(Q).length)return b;let X=b;return Object.assign((_,V,$={})=>X(_,V,g(Q,$)),{Minimatch:class _ extends X.Minimatch{constructor(V,$={}){super(V,g(Q,$))}static defaults(V){return X.defaults(g(Q,V)).Minimatch}},AST:class _ extends X.AST{constructor(V,$,Z={}){super(V,$,g(Q,Z))}static fromGlob(V,$={}){return X.AST.fromGlob(V,g(Q,$))}},unescape:(_,V={})=>X.unescape(_,g(Q,V)),escape:(_,V={})=>X.escape(_,g(Q,V)),filter:(_,V={})=>X.filter(_,g(Q,V)),defaults:(_)=>X.defaults(g(Q,_)),makeRe:(_,V={})=>X.makeRe(_,g(Q,V)),braceExpand:(_,V={})=>X.braceExpand(_,g(Q,V)),match:(_,V,$={})=>X.match(_,V,g(Q,$)),sep:X.sep,GLOBSTAR:P})};b.defaults=l2;var MQ=(Q,X={})=>{if(F0(Q),X.nobrace||!/\{(?:(?!\{).)*\}/.test(Q))return[Q];return HQ(Q)};b.braceExpand=MQ;var p2=(Q,X={})=>new d(Q,X).makeRe();b.makeRe=p2;var i2=(Q,X,J={})=>{let _=new d(X,J);if(Q=Q.filter((V)=>_.match(V)),_.options.nonull&&!Q.length)Q.push(X);return Q};b.match=i2;var zQ=/[?*]|[+@!]\(.*?\)|\[|\]/,o2=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class d{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(Q,X={}){if(F0(Q),X=X||{},this.options=X,this.pattern=Q,this.platform=X.platform||IQ,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!X.windowsPathsNoEscape||X.allowWindowsEscape===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!X.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!X.nonegate,this.comment=!1,this.empty=!1,this.partial=!!X.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=X.windowsNoMagicRoot!==void 0?X.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 X of Q)if(typeof X!=="string")return!0;return!1}debug(...Q){}make(){let Q=this.pattern,X=this.options;if(!X.nocomment&&Q.charAt(0)==="#"){this.comment=!0;return}if(!Q){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],X.debug)this.debug=(...V)=>console.error(...V);this.debug(this.pattern,this.globSet);let J=this.globSet.map((V)=>this.slashSplit(V));this.globParts=this.preprocess(J),this.debug(this.pattern,this.globParts);let _=this.globParts.map((V,$,Z)=>{if(this.isWindows&&this.windowsNoMagicRoot){let K=V[0]===""&&V[1]===""&&(V[2]==="?"||!zQ.test(V[2]))&&!zQ.test(V[3]),Y=/^[a-z]:/i.test(V[0]);if(K)return[...V.slice(0,4),...V.slice(4).map((j)=>this.parse(j))];else if(Y)return[V[0],...V.slice(1).map((j)=>this.parse(j))]}return V.map((K)=>this.parse(K))});if(this.debug(this.pattern,_),this.set=_.filter((V)=>V.indexOf(!1)===-1),this.isWindows)for(let V=0;V<this.set.length;V++){let $=this.set[V];if($[0]===""&&$[1]===""&&this.globParts[V][2]==="?"&&typeof $[3]==="string"&&/^[a-z]:$/i.test($[3]))$[2]="?"}this.debug(this.pattern,this.set)}preprocess(Q){if(this.options.noglobstar){for(let J=0;J<Q.length;J++)for(let _=0;_<Q[J].length;_++)if(Q[J][_]==="**")Q[J][_]="*"}let{optimizationLevel:X=1}=this.options;if(X>=2)Q=this.firstPhasePreProcess(Q),Q=this.secondPhasePreProcess(Q);else if(X>=1)Q=this.levelOneOptimize(Q);else Q=this.adjascentGlobstarOptimize(Q);return Q}adjascentGlobstarOptimize(Q){return Q.map((X)=>{let J=-1;while((J=X.indexOf("**",J+1))!==-1){let _=J;while(X[_+1]==="**")_++;if(_!==J)X.splice(J,_-J)}return X})}levelOneOptimize(Q){return Q.map((X)=>{return X=X.reduce((J,_)=>{let V=J[J.length-1];if(_==="**"&&V==="**")return J;if(_===".."){if(V&&V!==".."&&V!=="."&&V!=="**")return J.pop(),J}return J.push(_),J},[]),X.length===0?[""]:X})}levelTwoFileOptimize(Q){if(!Array.isArray(Q))Q=this.slashSplit(Q);let X=!1;do{if(X=!1,!this.preserveMultipleSlashes){for(let _=1;_<Q.length-1;_++){let V=Q[_];if(_===1&&V===""&&Q[0]==="")continue;if(V==="."||V==="")X=!0,Q.splice(_,1),_--}if(Q[0]==="."&&Q.length===2&&(Q[1]==="."||Q[1]===""))X=!0,Q.pop()}let J=0;while((J=Q.indexOf("..",J+1))!==-1){let _=Q[J-1];if(_&&_!=="."&&_!==".."&&_!=="**")X=!0,Q.splice(J-1,2),J-=2}}while(X);return Q.length===0?[""]:Q}firstPhasePreProcess(Q){let X=!1;do{X=!1;for(let J of Q){let _=-1;while((_=J.indexOf("**",_+1))!==-1){let $=_;while(J[$+1]==="**")$++;if($>_)J.splice(_+1,$-_);let Z=J[_+1],K=J[_+2],Y=J[_+3];if(Z!=="..")continue;if(!K||K==="."||K===".."||!Y||Y==="."||Y==="..")continue;X=!0,J.splice(_,1);let j=J.slice(0);j[_]="**",Q.push(j),_--}if(!this.preserveMultipleSlashes){for(let $=1;$<J.length-1;$++){let Z=J[$];if($===1&&Z===""&&J[0]==="")continue;if(Z==="."||Z==="")X=!0,J.splice($,1),$--}if(J[0]==="."&&J.length===2&&(J[1]==="."||J[1]===""))X=!0,J.pop()}let V=0;while((V=J.indexOf("..",V+1))!==-1){let $=J[V-1];if($&&$!=="."&&$!==".."&&$!=="**"){X=!0;let K=V===1&&J[V+1]==="**"?["."]:[];if(J.splice(V-1,2,...K),J.length===0)J.push("");V-=2}}}}while(X);return Q}secondPhasePreProcess(Q){for(let X=0;X<Q.length-1;X++)for(let J=X+1;J<Q.length;J++){let _=this.partsMatch(Q[X],Q[J],!this.preserveMultipleSlashes);if(_){Q[X]=[],Q[J]=_;break}}return Q.filter((X)=>X.length)}partsMatch(Q,X,J=!1){let _=0,V=0,$=[],Z="";while(_<Q.length&&V<X.length)if(Q[_]===X[V])$.push(Z==="b"?X[V]:Q[_]),_++,V++;else if(J&&Q[_]==="**"&&X[V]===Q[_+1])$.push(Q[_]),_++;else if(J&&X[V]==="**"&&Q[_]===X[V+1])$.push(X[V]),V++;else if(Q[_]==="*"&&X[V]&&(this.options.dot||!X[V].startsWith("."))&&X[V]!=="**"){if(Z==="b")return!1;Z="a",$.push(Q[_]),_++,V++}else if(X[V]==="*"&&Q[_]&&(this.options.dot||!Q[_].startsWith("."))&&Q[_]!=="**"){if(Z==="a")return!1;Z="b",$.push(X[V]),_++,V++}else return!1;return Q.length===X.length&&$}parseNegate(){if(this.nonegate)return;let Q=this.pattern,X=!1,J=0;for(let _=0;_<Q.length&&Q.charAt(_)==="!";_++)X=!X,J++;if(J)this.pattern=Q.slice(J);this.negate=X}matchOne(Q,X,J=!1){let _=this.options;if(this.isWindows){let w=typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0]),I=!w&&Q[0]===""&&Q[1]===""&&Q[2]==="?"&&/^[a-z]:$/i.test(Q[3]),R=typeof X[0]==="string"&&/^[a-z]:$/i.test(X[0]),M=!R&&X[0]===""&&X[1]===""&&X[2]==="?"&&typeof X[3]==="string"&&/^[a-z]:$/i.test(X[3]),F=I?3:w?0:void 0,G=M?3:R?0:void 0;if(typeof F==="number"&&typeof G==="number"){let[z,A]=[Q[F],X[G]];if(z.toLowerCase()===A.toLowerCase()){if(X[G]=z,G>F)X=X.slice(G);else if(F>G)Q=Q.slice(F)}}}let{optimizationLevel:V=1}=this.options;if(V>=2)Q=this.levelTwoFileOptimize(Q);this.debug("matchOne",this,{file:Q,pattern:X}),this.debug("matchOne",Q.length,X.length);for(var $=0,Z=0,K=Q.length,Y=X.length;$<K&&Z<Y;$++,Z++){this.debug("matchOne loop");var j=X[Z],q=Q[$];if(this.debug(X,j,q),j===!1)return!1;if(j===P){this.debug("GLOBSTAR",[X,j,q]);var W=$,U=Z+1;if(U===Y){this.debug("** at the end");for(;$<K;$++)if(Q[$]==="."||Q[$]===".."||!_.dot&&Q[$].charAt(0)===".")return!1;return!0}while(W<K){var O=Q[W];if(this.debug(`
globstar while`,Q,W,X,U,O),this.matchOne(Q.slice(W),X.slice(U),J))return this.debug("globstar found match!",W,K,O),!0;else{if(O==="."||O===".."||!_.dot&&O.charAt(0)==="."){this.debug("dot detected!",Q,W,X,U);break}this.debug("globstar swallow a segment, and continue"),W++}}if(J){if(this.debug(`
>>> no match, partial?`,Q,W,X,U),W===K)return!0}return!1}let w;if(typeof j==="string")w=q===j,this.debug("string match",j,q,w);else w=j.test(q),this.debug("pattern match",j,q,w);if(!w)return!1}if($===K&&Z===Y)return!0;else if($===K)return J;else if(Z===Y)return $===K-1&&Q[$]==="";else throw new Error("wtf?")}braceExpand(){return MQ(this.pattern,this.options)}parse(Q){F0(Q);let X=this.options;if(Q==="**")return P;if(Q==="")return"";let J,_=null;if(J=Q.match(S2))_=X.dot?v2:P2;else if(J=Q.match(I2))_=(X.nocase?X.dot?L2:F2:X.dot?A2:M2)(J[1]);else if(J=Q.match(f2))_=(X.nocase?X.dot?b2:x2:X.dot?T2:y2)(J);else if(J=Q.match(C2))_=X.dot?D2:N2;else if(J=Q.match(u2))_=E2;let V=S.fromGlob(Q,this.options).toMMPattern();if(_&&typeof V==="object")Reflect.defineProperty(V,"test",{value:_});return V}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let Q=this.set;if(!Q.length)return this.regexp=!1,this.regexp;let X=this.options,J=X.noglobstar?m2:X.dot?g2:d2,_=new Set(X.nocase?["i"]:[]),V=Q.map((K)=>{let Y=K.map((j)=>{if(j instanceof RegExp)for(let q of j.flags.split(""))_.add(q);return typeof j==="string"?o2(j):j===P?P:j._src});return Y.forEach((j,q)=>{let W=Y[q+1],U=Y[q-1];if(j!==P||U===P)return;if(U===void 0)if(W!==void 0&&W!==P)Y[q+1]="(?:\\/|"+J+"\\/)?"+W;else Y[q]=J;else if(W===void 0)Y[q-1]=U+"(?:\\/|"+J+")?";else if(W!==P)Y[q-1]=U+"(?:\\/|\\/"+J+"\\/)"+W,Y[q+1]=P}),Y.filter((j)=>j!==P).join("/")}).join("|"),[$,Z]=Q.length>1?["(?:",")"]:["",""];if(V="^"+$+V+Z+"$",this.negate)V="^(?!"+V+").+$";try{this.regexp=new RegExp(V,[..._].join(""))}catch(K){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,X=this.partial){if(this.debug("match",Q,this.pattern),this.comment)return!1;if(this.empty)return Q==="";if(Q==="/"&&X)return!0;let J=this.options;if(this.isWindows)Q=Q.split("\\").join("/");let _=this.slashSplit(Q);this.debug(this.pattern,"split",_);let V=this.set;this.debug(this.pattern,"set",V);let $=_[_.length-1];if(!$)for(let Z=_.length-2;!$&&Z>=0;Z--)$=_[Z];for(let Z=0;Z<V.length;Z++){let K=V[Z],Y=_;if(J.matchBase&&K.length===1)Y=[$];if(this.matchOne(Y,K,X)){if(J.flipNegate)return!0;return!this.negate}}if(J.flipNegate)return!1;return this.negate}static defaults(Q){return b.defaults(Q).Minimatch}}b.AST=S;b.Minimatch=d;b.escape=q0;b.unescape=p;import{fileURLToPath as CJ}from"node:url";var H0=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,FQ=new Set,M1=typeof process==="object"&&!!process?process:{},LQ=(Q,X,J,_)=>{typeof M1.emitWarning==="function"?M1.emitWarning(Q,X,J,_):console.error(`[${J}] ${X}: ${Q}`)},o0=globalThis.AbortController,AQ=globalThis.AbortSignal;if(typeof o0==="undefined"){AQ=class J{onabort;_onabort=[];reason;aborted=!1;addEventListener(_,V){this._onabort.push(V)}},o0=class J{constructor(){X()}signal=new AQ;abort(_){if(this.signal.aborted)return;this.signal.reason=_,this.signal.aborted=!0;for(let V of this.signal._onabort)V(_);this.signal.onabort?.(_)}};let Q=M1.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",X=()=>{if(!Q)return;Q=!1,LQ("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",X)}}var n2=(Q)=>!FQ.has(Q),m5=Symbol("type"),X0=(Q)=>Q&&Q===Math.floor(Q)&&Q>0&&isFinite(Q),CQ=(Q)=>!X0(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?C0:null;class C0 extends Array{constructor(Q){super(Q);this.fill(0)}}class j0{heap;length;static#Q=!1;static create(Q){let X=CQ(Q);if(!X)return[];j0.#Q=!0;let J=new j0(Q,X);return j0.#Q=!1,J}constructor(Q,X){if(!j0.#Q)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new X(Q),this.length=0}push(Q){this.heap[this.length++]=Q}pop(){return this.heap[--this.length]}}class N0{#Q;#X;#$;#V;#Z;#I;#z;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#K;#j;#Y;#q;#J;#W;#B;#G;#w;#D;#O;#u;#A;#M;#R;#C;#U;#S;static unsafeExposeInternals(Q){return{starts:Q.#A,ttls:Q.#M,sizes:Q.#u,keyMap:Q.#Y,keyList:Q.#q,valList:Q.#J,next:Q.#W,prev:Q.#B,get head(){return Q.#G},get tail(){return Q.#w},free:Q.#D,isBackgroundFetch:(X)=>Q.#H(X),backgroundFetch:(X,J,_,V)=>Q.#b(X,J,_,V),moveToTail:(X)=>Q.#k(X),indexes:(X)=>Q.#N(X),rindexes:(X)=>Q.#E(X),isStale:(X)=>Q.#L(X)}}get max(){return this.#Q}get maxSize(){return this.#X}get calculatedSize(){return this.#j}get size(){return this.#K}get fetchMethod(){return this.#I}get memoMethod(){return this.#z}get dispose(){return this.#$}get onInsert(){return this.#V}get disposeAfter(){return this.#Z}constructor(Q){let{max:X=0,ttl:J,ttlResolution:_=1,ttlAutopurge:V,updateAgeOnGet:$,updateAgeOnHas:Z,allowStale:K,dispose:Y,onInsert:j,disposeAfter:q,noDisposeOnSet:W,noUpdateTTL:U,maxSize:O=0,maxEntrySize:w=0,sizeCalculation:I,fetchMethod:R,memoMethod:M,noDeleteOnFetchRejection:F,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:z,allowStaleOnFetchAbort:A,ignoreFetchAbort:H}=Q;if(X!==0&&!X0(X))throw new TypeError("max option must be a nonnegative integer");let B=X?CQ(X):Array;if(!B)throw new Error("invalid max value: "+X);if(this.#Q=X,this.#X=O,this.maxEntrySize=w||this.#X,this.sizeCalculation=I,this.sizeCalculation){if(!this.#X&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw new TypeError("sizeCalculation set to non-function")}if(M!==void 0&&typeof M!=="function")throw new TypeError("memoMethod must be a function if defined");if(this.#z=M,R!==void 0&&typeof R!=="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#I=R,this.#C=!!R,this.#Y=new Map,this.#q=new Array(X).fill(void 0),this.#J=new Array(X).fill(void 0),this.#W=new B(X),this.#B=new B(X),this.#G=0,this.#w=0,this.#D=j0.create(X),this.#K=0,this.#j=0,typeof Y==="function")this.#$=Y;if(typeof j==="function")this.#V=j;if(typeof q==="function")this.#Z=q,this.#O=[];else this.#Z=void 0,this.#O=void 0;if(this.#R=!!this.#$,this.#S=!!this.#V,this.#U=!!this.#Z,this.noDisposeOnSet=!!W,this.noUpdateTTL=!!U,this.noDeleteOnFetchRejection=!!F,this.allowStaleOnFetchRejection=!!z,this.allowStaleOnFetchAbort=!!A,this.ignoreFetchAbort=!!H,this.maxEntrySize!==0){if(this.#X!==0){if(!X0(this.#X))throw new TypeError("maxSize must be a positive integer if specified")}if(!X0(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#m()}if(this.allowStale=!!K,this.noDeleteOnStaleGet=!!G,this.updateAgeOnGet=!!$,this.updateAgeOnHas=!!Z,this.ttlResolution=X0(_)||_===0?_:1,this.ttlAutopurge=!!V,this.ttl=J||0,this.ttl){if(!X0(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#_()}if(this.#Q===0&&this.ttl===0&&this.#X===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Q&&!this.#X){if(n2("LRU_CACHE_UNBOUNDED"))FQ.add("LRU_CACHE_UNBOUNDED"),LQ("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",N0)}}getRemainingTTL(Q){return this.#Y.has(Q)?1/0:0}#_(){let Q=new C0(this.#Q),X=new C0(this.#Q);this.#M=Q,this.#A=X,this.#P=(V,$,Z=H0.now())=>{if(X[V]=$!==0?Z:0,Q[V]=$,$!==0&&this.ttlAutopurge){let K=setTimeout(()=>{if(this.#L(V))this.#v(this.#q[V],"expire")},$+1);if(K.unref)K.unref()}},this.#f=(V)=>{X[V]=Q[V]!==0?H0.now():0},this.#F=(V,$)=>{if(Q[$]){let Z=Q[$],K=X[$];if(!Z||!K)return;V.ttl=Z,V.start=K,V.now=J||_();let Y=V.now-K;V.remainingTTL=Z-Y}};let J=0,_=()=>{let V=H0.now();if(this.ttlResolution>0){J=V;let $=setTimeout(()=>J=0,this.ttlResolution);if($.unref)$.unref()}return V};this.getRemainingTTL=(V)=>{let $=this.#Y.get(V);if($===void 0)return 0;let Z=Q[$],K=X[$];if(!Z||!K)return 1/0;let Y=(J||_())-K;return Z-Y},this.#L=(V)=>{let $=X[V],Z=Q[V];return!!Z&&!!$&&(J||_())-$>Z}}#f=()=>{};#F=()=>{};#P=()=>{};#L=()=>!1;#m(){let Q=new C0(this.#Q);this.#j=0,this.#u=Q,this.#x=(X)=>{this.#j-=Q[X],Q[X]=0},this.#g=(X,J,_,V)=>{if(this.#H(J))return 0;if(!X0(_))if(V){if(typeof V!=="function")throw new TypeError("sizeCalculation must be a function");if(_=V(J,X),!X0(_))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return _},this.#T=(X,J,_)=>{if(Q[X]=J,this.#X){let V=this.#X-Q[X];while(this.#j>V)this.#y(!0)}if(this.#j+=Q[X],_)_.entrySize=J,_.totalCalculatedSize=this.#j}}#x=(Q)=>{};#T=(Q,X,J)=>{};#g=(Q,X,J,_)=>{if(J||_)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#N({allowStale:Q=this.allowStale}={}){if(this.#K)for(let X=this.#w;;){if(!this.#d(X))break;if(Q||!this.#L(X))yield X;if(X===this.#G)break;else X=this.#B[X]}}*#E({allowStale:Q=this.allowStale}={}){if(this.#K)for(let X=this.#G;;){if(!this.#d(X))break;if(Q||!this.#L(X))yield X;if(X===this.#w)break;else X=this.#W[X]}}#d(Q){return Q!==void 0&&this.#Y.get(this.#q[Q])===Q}*entries(){for(let Q of this.#N())if(this.#J[Q]!==void 0&&this.#q[Q]!==void 0&&!this.#H(this.#J[Q]))yield[this.#q[Q],this.#J[Q]]}*rentries(){for(let Q of this.#E())if(this.#J[Q]!==void 0&&this.#q[Q]!==void 0&&!this.#H(this.#J[Q]))yield[this.#q[Q],this.#J[Q]]}*keys(){for(let Q of this.#N()){let X=this.#q[Q];if(X!==void 0&&!this.#H(this.#J[Q]))yield X}}*rkeys(){for(let Q of this.#E()){let X=this.#q[Q];if(X!==void 0&&!this.#H(this.#J[Q]))yield X}}*values(){for(let Q of this.#N())if(this.#J[Q]!==void 0&&!this.#H(this.#J[Q]))yield this.#J[Q]}*rvalues(){for(let Q of this.#E())if(this.#J[Q]!==void 0&&!this.#H(this.#J[Q]))yield this.#J[Q]}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Q,X={}){for(let J of this.#N()){let _=this.#J[J],V=this.#H(_)?_.__staleWhileFetching:_;if(V===void 0)continue;if(Q(V,this.#q[J],this))return this.get(this.#q[J],X)}}forEach(Q,X=this){for(let J of this.#N()){let _=this.#J[J],V=this.#H(_)?_.__staleWhileFetching:_;if(V===void 0)continue;Q.call(X,V,this.#q[J],this)}}rforEach(Q,X=this){for(let J of this.#E()){let _=this.#J[J],V=this.#H(_)?_.__staleWhileFetching:_;if(V===void 0)continue;Q.call(X,V,this.#q[J],this)}}purgeStale(){let Q=!1;for(let X of this.#E({allowStale:!0}))if(this.#L(X))this.#v(this.#q[X],"expire"),Q=!0;return Q}info(Q){let X=this.#Y.get(Q);if(X===void 0)return;let J=this.#J[X],_=this.#H(J)?J.__staleWhileFetching:J;if(_===void 0)return;let V={value:_};if(this.#M&&this.#A){let $=this.#M[X],Z=this.#A[X];if($&&Z){let K=$-(H0.now()-Z);V.ttl=K,V.start=Date.now()}}if(this.#u)V.size=this.#u[X];return V}dump(){let Q=[];for(let X of this.#N({allowStale:!0})){let J=this.#q[X],_=this.#J[X],V=this.#H(_)?_.__staleWhileFetching:_;if(V===void 0||J===void 0)continue;let $={value:V};if(this.#M&&this.#A){$.ttl=this.#M[X];let Z=H0.now()-this.#A[X];$.start=Math.floor(Date.now()-Z)}if(this.#u)$.size=this.#u[X];Q.unshift([J,$])}return Q}load(Q){this.clear();for(let[X,J]of Q){if(J.start){let _=Date.now()-J.start;J.start=H0.now()-_}this.set(X,J.value,J)}}set(Q,X,J={}){if(X===void 0)return this.delete(Q),this;let{ttl:_=this.ttl,start:V,noDisposeOnSet:$=this.noDisposeOnSet,sizeCalculation:Z=this.sizeCalculation,status:K}=J,{noUpdateTTL:Y=this.noUpdateTTL}=J,j=this.#g(Q,X,J.size||0,Z);if(this.maxEntrySize&&j>this.maxEntrySize){if(K)K.set="miss",K.maxEntrySizeExceeded=!0;return this.#v(Q,"set"),this}let q=this.#K===0?void 0:this.#Y.get(Q);if(q===void 0){if(q=this.#K===0?this.#w:this.#D.length!==0?this.#D.pop():this.#K===this.#Q?this.#y(!1):this.#K,this.#q[q]=Q,this.#J[q]=X,this.#Y.set(Q,q),this.#W[this.#w]=q,this.#B[q]=this.#w,this.#w=q,this.#K++,this.#T(q,j,K),K)K.set="add";if(Y=!1,this.#S)this.#V?.(X,Q,"add")}else{this.#k(q);let W=this.#J[q];if(X!==W){if(this.#C&&this.#H(W)){W.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:U}=W;if(U!==void 0&&!$){if(this.#R)this.#$?.(U,Q,"set");if(this.#U)this.#O?.push([U,Q,"set"])}}else if(!$){if(this.#R)this.#$?.(W,Q,"set");if(this.#U)this.#O?.push([W,Q,"set"])}if(this.#x(q),this.#T(q,j,K),this.#J[q]=X,K){K.set="replace";let U=W&&this.#H(W)?W.__staleWhileFetching:W;if(U!==void 0)K.oldValue=U}}else if(K)K.set="update";if(this.#S)this.onInsert?.(X,Q,X===W?"update":"replace")}if(_!==0&&!this.#M)this.#_();if(this.#M){if(!Y)this.#P(q,_,V);if(K)this.#F(K,q)}if(!$&&this.#U&&this.#O){let W=this.#O,U;while(U=W?.shift())this.#Z?.(...U)}return this}pop(){try{while(this.#K){let Q=this.#J[this.#G];if(this.#y(!0),this.#H(Q)){if(Q.__staleWhileFetching)return Q.__staleWhileFetching}else if(Q!==void 0)return Q}}finally{if(this.#U&&this.#O){let Q=this.#O,X;while(X=Q?.shift())this.#Z?.(...X)}}}#y(Q){let X=this.#G,J=this.#q[X],_=this.#J[X];if(this.#C&&this.#H(_))_.__abortController.abort(new Error("evicted"));else if(this.#R||this.#U){if(this.#R)this.#$?.(_,J,"evict");if(this.#U)this.#O?.push([_,J,"evict"])}if(this.#x(X),Q)this.#q[X]=void 0,this.#J[X]=void 0,this.#D.push(X);if(this.#K===1)this.#G=this.#w=0,this.#D.length=0;else this.#G=this.#W[X];return this.#Y.delete(J),this.#K--,X}has(Q,X={}){let{updateAgeOnHas:J=this.updateAgeOnHas,status:_}=X,V=this.#Y.get(Q);if(V!==void 0){let $=this.#J[V];if(this.#H($)&&$.__staleWhileFetching===void 0)return!1;if(!this.#L(V)){if(J)this.#f(V);if(_)_.has="hit",this.#F(_,V);return!0}else if(_)_.has="stale",this.#F(_,V)}else if(_)_.has="miss";return!1}peek(Q,X={}){let{allowStale:J=this.allowStale}=X,_=this.#Y.get(Q);if(_===void 0||!J&&this.#L(_))return;let V=this.#J[_];return this.#H(V)?V.__staleWhileFetching:V}#b(Q,X,J,_){let V=X===void 0?void 0:this.#J[X];if(this.#H(V))return V;let $=new o0,{signal:Z}=J;Z?.addEventListener("abort",()=>$.abort(Z.reason),{signal:$.signal});let K={signal:$.signal,options:J,context:_},Y=(w,I=!1)=>{let{aborted:R}=$.signal,M=J.ignoreFetchAbort&&w!==void 0;if(J.status)if(R&&!I){if(J.status.fetchAborted=!0,J.status.fetchError=$.signal.reason,M)J.status.fetchAbortIgnored=!0}else J.status.fetchResolved=!0;if(R&&!M&&!I)return q($.signal.reason);let F=U;if(this.#J[X]===U)if(w===void 0)if(F.__staleWhileFetching)this.#J[X]=F.__staleWhileFetching;else this.#v(Q,"fetch");else{if(J.status)J.status.fetchUpdated=!0;this.set(Q,w,K.options)}return w},j=(w)=>{if(J.status)J.status.fetchRejected=!0,J.status.fetchError=w;return q(w)},q=(w)=>{let{aborted:I}=$.signal,R=I&&J.allowStaleOnFetchAbort,M=R||J.allowStaleOnFetchRejection,F=M||J.noDeleteOnFetchRejection,G=U;if(this.#J[X]===U){if(!F||G.__staleWhileFetching===void 0)this.#v(Q,"fetch");else if(!R)this.#J[X]=G.__staleWhileFetching}if(M){if(J.status&&G.__staleWhileFetching!==void 0)J.status.returnedStale=!0;return G.__staleWhileFetching}else if(G.__returned===G)throw w},W=(w,I)=>{let R=this.#I?.(Q,V,K);if(R&&R instanceof Promise)R.then((M)=>w(M===void 0?void 0:M),I);$.signal.addEventListener("abort",()=>{if(!J.ignoreFetchAbort||J.allowStaleOnFetchAbort){if(w(void 0),J.allowStaleOnFetchAbort)w=(M)=>Y(M,!0)}})};if(J.status)J.status.fetchDispatched=!0;let U=new Promise(W).then(Y,j),O=Object.assign(U,{__abortController:$,__staleWhileFetching:V,__returned:void 0});if(X===void 0)this.set(Q,O,{...K.options,status:void 0}),X=this.#Y.get(Q);else this.#J[X]=O;return O}#H(Q){if(!this.#C)return!1;let X=Q;return!!X&&X instanceof Promise&&X.hasOwnProperty("__staleWhileFetching")&&X.__abortController instanceof o0}async fetch(Q,X={}){let{allowStale:J=this.allowStale,updateAgeOnGet:_=this.updateAgeOnGet,noDeleteOnStaleGet:V=this.noDeleteOnStaleGet,ttl:$=this.ttl,noDisposeOnSet:Z=this.noDisposeOnSet,size:K=0,sizeCalculation:Y=this.sizeCalculation,noUpdateTTL:j=this.noUpdateTTL,noDeleteOnFetchRejection:q=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:W=this.allowStaleOnFetchRejection,ignoreFetchAbort:U=this.ignoreFetchAbort,allowStaleOnFetchAbort:O=this.allowStaleOnFetchAbort,context:w,forceRefresh:I=!1,status:R,signal:M}=X;if(!this.#C){if(R)R.fetch="get";return this.get(Q,{allowStale:J,updateAgeOnGet:_,noDeleteOnStaleGet:V,status:R})}let F={allowStale:J,updateAgeOnGet:_,noDeleteOnStaleGet:V,ttl:$,noDisposeOnSet:Z,size:K,sizeCalculation:Y,noUpdateTTL:j,noDeleteOnFetchRejection:q,allowStaleOnFetchRejection:W,allowStaleOnFetchAbort:O,ignoreFetchAbort:U,status:R,signal:M},G=this.#Y.get(Q);if(G===void 0){if(R)R.fetch="miss";let z=this.#b(Q,G,F,w);return z.__returned=z}else{let z=this.#J[G];if(this.#H(z)){let C=J&&z.__staleWhileFetching!==void 0;if(R){if(R.fetch="inflight",C)R.returnedStale=!0}return C?z.__staleWhileFetching:z.__returned=z}let A=this.#L(G);if(!I&&!A){if(R)R.fetch="hit";if(this.#k(G),_)this.#f(G);if(R)this.#F(R,G);return z}let H=this.#b(Q,G,F,w),L=H.__staleWhileFetching!==void 0&&J;if(R){if(R.fetch=A?"stale":"refresh",L&&A)R.returnedStale=!0}return L?H.__staleWhileFetching:H.__returned=H}}async forceFetch(Q,X={}){let J=await this.fetch(Q,X);if(J===void 0)throw new Error("fetch() returned undefined");return J}memo(Q,X={}){let J=this.#z;if(!J)throw new Error("no memoMethod provided to constructor");let{context:_,forceRefresh:V,...$}=X,Z=this.get(Q,$);if(!V&&Z!==void 0)return Z;let K=J(Q,Z,{options:$,context:_});return this.set(Q,K,$),K}get(Q,X={}){let{allowStale:J=this.allowStale,updateAgeOnGet:_=this.updateAgeOnGet,noDeleteOnStaleGet:V=this.noDeleteOnStaleGet,status:$}=X,Z=this.#Y.get(Q);if(Z!==void 0){let K=this.#J[Z],Y=this.#H(K);if($)this.#F($,Z);if(this.#L(Z)){if($)$.get="stale";if(!Y){if(!V)this.#v(Q,"expire");if($&&J)$.returnedStale=!0;return J?K:void 0}else{if($&&J&&K.__staleWhileFetching!==void 0)$.returnedStale=!0;return J?K.__staleWhileFetching:void 0}}else{if($)$.get="hit";if(Y)return K.__staleWhileFetching;if(this.#k(Z),_)this.#f(Z);return K}}else if($)$.get="miss"}#c(Q,X){this.#B[X]=Q,this.#W[Q]=X}#k(Q){if(Q!==this.#w){if(Q===this.#G)this.#G=this.#W[Q];else this.#c(this.#B[Q],this.#W[Q]);this.#c(this.#w,Q),this.#w=Q}}delete(Q){return this.#v(Q,"delete")}#v(Q,X){let J=!1;if(this.#K!==0){let _=this.#Y.get(Q);if(_!==void 0)if(J=!0,this.#K===1)this.#h(X);else{this.#x(_);let V=this.#J[_];if(this.#H(V))V.__abortController.abort(new Error("deleted"));else if(this.#R||this.#U){if(this.#R)this.#$?.(V,Q,X);if(this.#U)this.#O?.push([V,Q,X])}if(this.#Y.delete(Q),this.#q[_]=void 0,this.#J[_]=void 0,_===this.#w)this.#w=this.#B[_];else if(_===this.#G)this.#G=this.#W[_];else{let $=this.#B[_];this.#W[$]=this.#W[_];let Z=this.#W[_];this.#B[Z]=this.#B[_]}this.#K--,this.#D.push(_)}}if(this.#U&&this.#O?.length){let _=this.#O,V;while(V=_?.shift())this.#Z?.(...V)}return J}clear(){return this.#h("delete")}#h(Q){for(let X of this.#E({allowStale:!0})){let J=this.#J[X];if(this.#H(J))J.__abortController.abort(new Error("deleted"));else{let _=this.#q[X];if(this.#R)this.#$?.(J,_,Q);if(this.#U)this.#O?.push([J,_,Q])}}if(this.#Y.clear(),this.#J.fill(void 0),this.#q.fill(void 0),this.#M&&this.#A)this.#M.fill(0),this.#A.fill(0);if(this.#u)this.#u.fill(0);if(this.#G=0,this.#w=0,this.#D.length=0,this.#j=0,this.#K=0,this.#U&&this.#O){let X=this.#O,J;while(J=X?.shift())this.#Z?.(...J)}}}import{posix as $J,win32 as P1}from"node:path";import{fileURLToPath as ZJ}from"node:url";import{lstatSync as KJ,readdir as YJ,readdirSync as qJ,readlinkSync as HJ,realpathSync as jJ}from"fs";import*as WJ from"node:fs";import{lstat as GJ,readdir as wJ,readlink as OJ,realpath as zJ}from"node:fs/promises";import{EventEmitter as D1}from"node:events";import SQ from"node:stream";import{StringDecoder as r2}from"node:string_decoder";var NQ=typeof process==="object"&&process?process:{stdout:null,stderr:null},a2=(Q)=>!!Q&&typeof Q==="object"&&(Q instanceof $0||Q instanceof SQ||s2(Q)||t2(Q)),s2=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof D1&&typeof Q.pipe==="function"&&Q.pipe!==SQ.Writable.prototype.pipe,t2=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof D1&&typeof Q.write==="function"&&typeof Q.end==="function",s=Symbol("EOF"),t=Symbol("maybeEmitEnd"),J0=Symbol("emittedEnd"),n0=Symbol("emittingEnd"),D0=Symbol("emittedError"),r0=Symbol("closed"),DQ=Symbol("read"),a0=Symbol("flush"),uQ=Symbol("flushChunk"),i=Symbol("encoding"),W0=Symbol("decoder"),D=Symbol("flowing"),u0=Symbol("paused"),U0=Symbol("resume"),u=Symbol("buffer"),T=Symbol("pipes"),E=Symbol("bufferLength"),A1=Symbol("bufferPush"),s0=Symbol("bufferShift"),f=Symbol("objectMode"),N=Symbol("destroyed"),F1=Symbol("error"),L1=Symbol("emitData"),EQ=Symbol("emitEnd"),C1=Symbol("emitEnd2"),n=Symbol("async"),N1=Symbol("abort"),t0=Symbol("aborted"),E0=Symbol("signal"),V0=Symbol("dataListeners"),m=Symbol("discarded"),S0=(Q)=>Promise.resolve().then(Q),e2=(Q)=>Q(),QJ=(Q)=>Q==="end"||Q==="finish"||Q==="prefinish",XJ=(Q)=>Q instanceof ArrayBuffer||!!Q&&typeof Q==="object"&&Q.constructor&&Q.constructor.name==="ArrayBuffer"&&Q.byteLength>=0,JJ=(Q)=>!Buffer.isBuffer(Q)&&ArrayBuffer.isView(Q);class u1{src;dest;opts;ondrain;constructor(Q,X,J){this.src=Q,this.dest=X,this.opts=J,this.ondrain=()=>Q[U0](),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 PQ extends u1{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(Q,X,J){super(Q,X,J);this.proxyErrors=(_)=>X.emit("error",_),Q.on("error",this.proxyErrors)}}var _J=(Q)=>!!Q.objectMode,VJ=(Q)=>!Q.objectMode&&!!Q.encoding&&Q.encoding!=="buffer";class $0 extends D1{[D]=!1;[u0]=!1;[T]=[];[u]=[];[f];[i];[n];[W0];[s]=!1;[J0]=!1;[n0]=!1;[r0]=!1;[D0]=null;[E]=0;[N]=!1;[E0];[t0]=!1;[V0]=0;[m]=!1;writable=!0;readable=!0;constructor(...Q){let X=Q[0]||{};super();if(X.objectMode&&typeof X.encoding==="string")throw new TypeError("Encoding and objectMode may not be used together");if(_J(X))this[f]=!0,this[i]=null;else if(VJ(X))this[i]=X.encoding,this[f]=!1;else this[f]=!1,this[i]=null;if(this[n]=!!X.async,this[W0]=this[i]?new r2(this[i]):null,X&&X.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[u]});if(X&&X.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[T]});let{signal:J}=X;if(J)if(this[E0]=J,J.aborted)this[N1]();else J.addEventListener("abort",()=>this[N1]())}get bufferLength(){return this[E]}get encoding(){return this[i]}set encoding(Q){throw new Error("Encoding must be set at instantiation time")}setEncoding(Q){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[f]}set objectMode(Q){throw new Error("objectMode must be set at instantiation time")}get["async"](){return this[n]}set["async"](Q){this[n]=this[n]||!!Q}[N1](){this[t0]=!0,this.emit("abort",this[E0]?.reason),this.destroy(this[E0]?.reason)}get aborted(){return this[t0]}set aborted(Q){}write(Q,X,J){if(this[t0])return!1;if(this[s])throw new Error("write after end");if(this[N])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof X==="function")J=X,X="utf8";if(!X)X="utf8";let _=this[n]?S0:e2;if(!this[f]&&!Buffer.isBuffer(Q)){if(JJ(Q))Q=Buffer.from(Q.buffer,Q.byteOffset,Q.byteLength);else if(XJ(Q))Q=Buffer.from(Q);else if(typeof Q!=="string")throw new Error("Non-contiguous data written to non-objectMode stream")}if(this[f]){if(this[D]&&this[E]!==0)this[a0](!0);if(this[D])this.emit("data",Q);else this[A1](Q);if(this[E]!==0)this.emit("readable");if(J)_(J);return this[D]}if(!Q.length){if(this[E]!==0)this.emit("readable");if(J)_(J);return this[D]}if(typeof Q==="string"&&!(X===this[i]&&!this[W0]?.lastNeed))Q=Buffer.from(Q,X);if(Buffer.isBuffer(Q)&&this[i])Q=this[W0].write(Q);if(this[D]&&this[