tshy 4.1.0 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
- var Mn=(e=0)=>t=>`\x1B[${t+e}m`,$n=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Ln=(e=0)=>(t,s,i)=>`\x1B[${38+e};2;${t};${s};${i}m`,A={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},H0=Object.keys(A.modifier),$f=Object.keys(A.color),Lf=Object.keys(A.bgColor),Y0=[...$f,...Lf];function Wf(){let e=new Map;for(let[t,s]of Object.entries(A)){for(let[i,r]of Object.entries(s))A[i]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},s[i]=A[i],e.set(r[0],r[1]);Object.defineProperty(A,t,{value:s,enumerable:!1})}return Object.defineProperty(A,"codes",{value:e,enumerable:!1}),A.color.close="\x1B[39m",A.bgColor.close="\x1B[49m",A.color.ansi=Mn(),A.color.ansi256=$n(),A.color.ansi16m=Ln(),A.bgColor.ansi=Mn(10),A.bgColor.ansi256=$n(10),A.bgColor.ansi16m=Ln(10),Object.defineProperties(A,{rgbToAnsi256:{value(t,s,i){return t===s&&s===i?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(s/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let s=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!s)return[0,0,0];let[i]=s;i.length===3&&(i=[...i].map(o=>o+o).join(""));let r=Number.parseInt(i,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:t=>A.rgbToAnsi256(...A.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let s,i,r;if(t>=232)s=((t-232)*10+8)/255,i=s,r=s;else{t-=16;let a=t%36;s=Math.floor(t/36)/5,i=Math.floor(a/6)/5,r=a%6/5}let o=Math.max(s,i,r)*2;if(o===0)return 30;let n=30+(Math.round(r)<<2|Math.round(i)<<1|Math.round(s));return o===2&&(n+=60),n},enumerable:!1},rgbToAnsi:{value:(t,s,i)=>A.ansi256ToAnsi(A.rgbToAnsi256(t,s,i)),enumerable:!1},hexToAnsi:{value:t=>A.ansi256ToAnsi(A.hexToAnsi256(t)),enumerable:!1}}),A}var If=Wf(),Pt=If;import Lr from"node:process";import Uf from"node:os";import Wn from"node:tty";function vt(e,t=globalThis.Deno?globalThis.Deno.args:Lr.argv){let s=e.startsWith("-")?"":e.length===1?"-":"--",i=t.indexOf(s+e),r=t.indexOf("--");return i!==-1&&(r===-1||i<r)}var{env:C}=Lr,ai;vt("no-color")||vt("no-colors")||vt("color=false")||vt("color=never")?ai=0:(vt("color")||vt("colors")||vt("color=true")||vt("color=always"))&&(ai=1);function zf(){if("FORCE_COLOR"in C)return C.FORCE_COLOR==="true"?1:C.FORCE_COLOR==="false"?0:C.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(C.FORCE_COLOR,10),3)}function Bf(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Gf(e,{streamIsTTY:t,sniffFlags:s=!0}={}){let i=zf();i!==void 0&&(ai=i);let r=s?ai:i;if(r===0)return 0;if(s){if(vt("color=16m")||vt("color=full")||vt("color=truecolor"))return 3;if(vt("color=256"))return 2}if("TF_BUILD"in C&&"AGENT_NAME"in C)return 1;if(e&&!t&&r===void 0)return 0;let o=r||0;if(C.TERM==="dumb")return o;if(Lr.platform==="win32"){let n=Uf.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in C)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(n=>n in C)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(n=>n in C)||C.CI_NAME==="codeship"?1:o;if("TEAMCITY_VERSION"in C)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(C.TEAMCITY_VERSION)?1:0;if(C.COLORTERM==="truecolor"||C.TERM==="xterm-kitty"||C.TERM==="xterm-ghostty"||C.TERM==="wezterm")return 3;if("TERM_PROGRAM"in C){let n=Number.parseInt((C.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(C.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(C.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(C.TERM)||"COLORTERM"in C?1:o}function In(e,t={}){let s=Gf(e,{streamIsTTY:e&&e.isTTY,...t});return Bf(s)}var Hf={stdout:In({isTTY:Wn.isatty(1)}),stderr:In({isTTY:Wn.isatty(2)})},Un=Hf;function zn(e,t,s){let i=e.indexOf(t);if(i===-1)return e;let r=t.length,o=0,n="";do n+=e.slice(o,i)+t+s,o=i+r,i=e.indexOf(t,o);while(i!==-1);return n+=e.slice(o),n}function Bn(e,t,s,i){let r=0,o="";do{let n=e[i-1]==="\r";o+=e.slice(r,n?i-1:i)+t+(n?`\r
2
+ var $n=(e=0)=>t=>`\x1B[${t+e}m`,Mn=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Ln=(e=0)=>(t,s,i)=>`\x1B[${38+e};2;${t};${s};${i}m`,A={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},H0=Object.keys(A.modifier),Mf=Object.keys(A.color),Lf=Object.keys(A.bgColor),Y0=[...Mf,...Lf];function Wf(){let e=new Map;for(let[t,s]of Object.entries(A)){for(let[i,r]of Object.entries(s))A[i]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},s[i]=A[i],e.set(r[0],r[1]);Object.defineProperty(A,t,{value:s,enumerable:!1})}return Object.defineProperty(A,"codes",{value:e,enumerable:!1}),A.color.close="\x1B[39m",A.bgColor.close="\x1B[49m",A.color.ansi=$n(),A.color.ansi256=Mn(),A.color.ansi16m=Ln(),A.bgColor.ansi=$n(10),A.bgColor.ansi256=Mn(10),A.bgColor.ansi16m=Ln(10),Object.defineProperties(A,{rgbToAnsi256:{value(t,s,i){return t===s&&s===i?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(s/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let s=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!s)return[0,0,0];let[i]=s;i.length===3&&(i=[...i].map(o=>o+o).join(""));let r=Number.parseInt(i,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:t=>A.rgbToAnsi256(...A.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let s,i,r;if(t>=232)s=((t-232)*10+8)/255,i=s,r=s;else{t-=16;let a=t%36;s=Math.floor(t/36)/5,i=Math.floor(a/6)/5,r=a%6/5}let o=Math.max(s,i,r)*2;if(o===0)return 30;let n=30+(Math.round(r)<<2|Math.round(i)<<1|Math.round(s));return o===2&&(n+=60),n},enumerable:!1},rgbToAnsi:{value:(t,s,i)=>A.ansi256ToAnsi(A.rgbToAnsi256(t,s,i)),enumerable:!1},hexToAnsi:{value:t=>A.ansi256ToAnsi(A.hexToAnsi256(t)),enumerable:!1}}),A}var If=Wf(),Pt=If;import Lr from"node:process";import Uf from"node:os";import Wn from"node:tty";function vt(e,t=globalThis.Deno?globalThis.Deno.args:Lr.argv){let s=e.startsWith("-")?"":e.length===1?"-":"--",i=t.indexOf(s+e),r=t.indexOf("--");return i!==-1&&(r===-1||i<r)}var{env:j}=Lr,ai;vt("no-color")||vt("no-colors")||vt("color=false")||vt("color=never")?ai=0:(vt("color")||vt("colors")||vt("color=true")||vt("color=always"))&&(ai=1);function zf(){if("FORCE_COLOR"in j)return j.FORCE_COLOR==="true"?1:j.FORCE_COLOR==="false"?0:j.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(j.FORCE_COLOR,10),3)}function Bf(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Gf(e,{streamIsTTY:t,sniffFlags:s=!0}={}){let i=zf();i!==void 0&&(ai=i);let r=s?ai:i;if(r===0)return 0;if(s){if(vt("color=16m")||vt("color=full")||vt("color=truecolor"))return 3;if(vt("color=256"))return 2}if("TF_BUILD"in j&&"AGENT_NAME"in j)return 1;if(e&&!t&&r===void 0)return 0;let o=r||0;if(j.TERM==="dumb")return o;if(Lr.platform==="win32"){let n=Uf.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in j)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(n=>n in j)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(n=>n in j)||j.CI_NAME==="codeship"?1:o;if("TEAMCITY_VERSION"in j)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(j.TEAMCITY_VERSION)?1:0;if(j.COLORTERM==="truecolor"||j.TERM==="xterm-kitty"||j.TERM==="xterm-ghostty"||j.TERM==="wezterm")return 3;if("TERM_PROGRAM"in j){let n=Number.parseInt((j.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(j.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(j.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(j.TERM)||"COLORTERM"in j?1:o}function In(e,t={}){let s=Gf(e,{streamIsTTY:e&&e.isTTY,...t});return Bf(s)}var Hf={stdout:In({isTTY:Wn.isatty(1)}),stderr:In({isTTY:Wn.isatty(2)})},Un=Hf;function zn(e,t,s){let i=e.indexOf(t);if(i===-1)return e;let r=t.length,o=0,n="";do n+=e.slice(o,i)+t+s,o=i+r,i=e.indexOf(t,o);while(i!==-1);return n+=e.slice(o),n}function Bn(e,t,s,i){let r=0,o="";do{let n=e[i-1]==="\r";o+=e.slice(r,n?i-1:i)+t+(n?`\r
3
3
  `:`
4
4
  `)+s,r=i+1,i=e.indexOf(`
5
5
  `,r)}while(i!==-1);return o+=e.slice(r),o}var{stdout:Gn,stderr:Hn}=Un,Wr=Symbol("GENERATOR"),Fe=Symbol("STYLER"),us=Symbol("IS_EMPTY"),Yn=["ansi","ansi","ansi256","ansi16m"],De=Object.create(null),Yf=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let s=Gn?Gn.level:0;e.level=t.level===void 0?s:t.level};var qf=e=>{let t=(...s)=>s.join(" ");return Yf(t,e),Object.setPrototypeOf(t,ps.prototype),t};function ps(e){return qf(e)}Object.setPrototypeOf(ps.prototype,Function.prototype);for(let[e,t]of Object.entries(Pt))De[e]={get(){let s=li(this,Ur(t.open,t.close,this[Fe]),this[us]);return Object.defineProperty(this,e,{value:s}),s}};De.visible={get(){let e=li(this,this[Fe],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var Ir=(e,t,s,...i)=>e==="rgb"?t==="ansi16m"?Pt[s].ansi16m(...i):t==="ansi256"?Pt[s].ansi256(Pt.rgbToAnsi256(...i)):Pt[s].ansi(Pt.rgbToAnsi(...i)):e==="hex"?Ir("rgb",t,s,...Pt.hexToRgb(...i)):Pt[s][e](...i),Vf=["rgb","hex","ansi256"];for(let e of Vf){De[e]={get(){let{level:s}=this;return function(...i){let r=Ur(Ir(e,Yn[s],"color",...i),Pt.color.close,this[Fe]);return li(this,r,this[us])}}};let t="bg"+e[0].toUpperCase()+e.slice(1);De[t]={get(){let{level:s}=this;return function(...i){let r=Ur(Ir(e,Yn[s],"bgColor",...i),Pt.bgColor.close,this[Fe]);return li(this,r,this[us])}}}}var Jf=Object.defineProperties(()=>{},{...De,level:{enumerable:!0,get(){return this[Wr].level},set(e){this[Wr].level=e}}}),Ur=(e,t,s)=>{let i,r;return s===void 0?(i=e,r=t):(i=s.openAll+e,r=t+s.closeAll),{open:e,close:t,openAll:i,closeAll:r,parent:s}},li=(e,t,s)=>{let i=(...r)=>Kf(i,r.length===1?""+r[0]:r.join(" "));return Object.setPrototypeOf(i,Jf),i[Wr]=e,i[Fe]=t,i[us]=s,i},Kf=(e,t)=>{if(e.level<=0||!t)return e[us]?"":t;let s=e[Fe];if(s===void 0)return t;let{openAll:i,closeAll:r}=s;if(t.includes("\x1B"))for(;s!==void 0;)t=zn(t,s.close,s.open),s=s.parent;let o=t.indexOf(`
6
- `);return o!==-1&&(t=Bn(t,r,i,o)),i+t+r};Object.defineProperties(ps.prototype,De);var Xf=ps(),sS=ps({level:Hn?Hn.level:0});var E=Xf;var zr=(e,t,s)=>{let i=e instanceof RegExp?qn(e,s):e,r=t instanceof RegExp?qn(t,s):t,o=i!==null&&r!=null&&Zf(i,r,s);return o&&{start:o[0],end:o[1],pre:s.slice(0,o[0]),body:s.slice(o[0]+i.length,o[1]),post:s.slice(o[1]+r.length)}},qn=(e,t)=>{let s=t.match(e);return s?s[0]:null},Zf=(e,t,s)=>{let i,r,o,n,a,l=s.indexOf(e),h=s.indexOf(t,l+1),f=l;if(l>=0&&h>0){if(e===t)return[l,h];for(i=[],o=s.length;f>=0&&!a;){if(f===l)i.push(f),l=s.indexOf(e,f+1);else if(i.length===1){let c=i.pop();c!==void 0&&(a=[c,h])}else r=i.pop(),r!==void 0&&r<o&&(o=r,n=h),h=s.indexOf(t,f+1);f=l<h&&l>=0?l:h}i.length&&n!==void 0&&(a=[o,n])}return a};var Vn="\0SLASH"+Math.random()+"\0",Jn="\0OPEN"+Math.random()+"\0",Gr="\0CLOSE"+Math.random()+"\0",Kn="\0COMMA"+Math.random()+"\0",Xn="\0PERIOD"+Math.random()+"\0",Qf=new RegExp(Vn,"g"),tu=new RegExp(Jn,"g"),eu=new RegExp(Gr,"g"),su=new RegExp(Kn,"g"),iu=new RegExp(Xn,"g"),ru=/\\\\/g,ou=/\\{/g,nu=/\\}/g,au=/\\,/g,lu=/\\./g,hu=1e5;function Br(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function cu(e){return e.replace(ru,Vn).replace(ou,Jn).replace(nu,Gr).replace(au,Kn).replace(lu,Xn)}function fu(e){return e.replace(Qf,"\\").replace(tu,"{").replace(eu,"}").replace(su,",").replace(iu,".")}function Zn(e){if(!e)return[""];let t=[],s=zr("{","}",e);if(!s)return e.split(",");let{pre:i,body:r,post:o}=s,n=i.split(",");n[n.length-1]+="{"+r+"}";let a=Zn(o);return o.length&&(n[n.length-1]+=a.shift(),n.push.apply(n,a)),t.push.apply(t,n),t}function Qn(e,t={}){if(!e)return[];let{max:s=hu}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),ds(cu(e),s,!0).map(fu)}function uu(e){return"{"+e+"}"}function pu(e){return/^-?0\d/.test(e)}function du(e,t){return e<=t}function mu(e,t){return e>=t}function ds(e,t,s){let i=[],r=zr("{","}",e);if(!r)return[e];let o=r.pre,n=r.post.length?ds(r.post,t,!1):[""];if(/\$$/.test(r.pre))for(let a=0;a<n.length&&a<t;a++){let l=o+"{"+r.body+"}"+n[a];i.push(l)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(r.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(r.body),h=a||l,f=r.body.indexOf(",")>=0;if(!h&&!f)return r.post.match(/,(?!,).*\}/)?(e=r.pre+"{"+r.body+Gr+r.post,ds(e,t,!0)):[e];let c;if(h)c=r.body.split(/\.\./);else if(c=Zn(r.body),c.length===1&&c[0]!==void 0&&(c=ds(c[0],t,!1).map(uu),c.length===1))return n.map(p=>r.pre+c[0]+p);let u;if(h&&c[0]!==void 0&&c[1]!==void 0){let p=Br(c[0]),d=Br(c[1]),m=Math.max(c[0].length,c[1].length),y=c.length===3&&c[2]!==void 0?Math.abs(Br(c[2])):1,g=du;d<p&&(y*=-1,g=mu);let S=c.some(pu);u=[];for(let b=p;g(b,d);b+=y){let v;if(l)v=String.fromCharCode(b),v==="\\"&&(v="");else if(v=String(b),S){let R=m-v.length;if(R>0){let $=new Array(R+1).join("0");b<0?v="-"+$+v.slice(1):v=$+v}}u.push(v)}}else{u=[];for(let p=0;p<c.length;p++)u.push.apply(u,ds(c[p],t,!1))}for(let p=0;p<u.length;p++)for(let d=0;d<n.length&&i.length<t;d++){let m=o+u[p]+n[d];(!s||h||m)&&i.push(m)}}return i}var ms=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var gu={"[: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]},gs=e=>e.replace(/[[\]\\-]/g,"\\$&"),yu=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ta=e=>e.join(""),ea=(e,t)=>{let s=t;if(e.charAt(s)!=="[")throw new Error("not in a brace expression");let i=[],r=[],o=s+1,n=!1,a=!1,l=!1,h=!1,f=s,c="";t:for(;o<e.length;){let m=e.charAt(o);if((m==="!"||m==="^")&&o===s+1){h=!0,o++;continue}if(m==="]"&&n&&!l){f=o+1;break}if(n=!0,m==="\\"&&!l){l=!0,o++;continue}if(m==="["&&!l){for(let[y,[g,w,S]]of Object.entries(gu))if(e.startsWith(y,o)){if(c)return["$.",!1,e.length-s,!0];o+=y.length,S?r.push(g):i.push(g),a=a||w;continue t}}if(l=!1,c){m>c?i.push(gs(c)+"-"+gs(m)):m===c&&i.push(gs(m)),c="",o++;continue}if(e.startsWith("-]",o+1)){i.push(gs(m+"-")),o+=2;continue}if(e.startsWith("-",o+1)){c=m,o+=2;continue}i.push(gs(m)),o++}if(f<o)return["",!1,0,!1];if(!i.length&&!r.length)return["$.",!1,e.length-s,!0];if(r.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!h){let m=i[0].length===2?i[0].slice(-1):i[0];return[yu(m),!1,f-s,!1]}let u="["+(h?"^":"")+ta(i)+"]",p="["+(h?"":"^")+ta(r)+"]";return[i.length&&r.length?"("+u+"|"+p+")":i.length?u:p,a,f-s,!0]};var oe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!0}={})=>s?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1");var ct,wu=new Set(["!","?","+","*","@"]),Hr=e=>wu.has(e),sa=e=>Hr(e.type),bu=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Su=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),vu=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),ia=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Eu="(?!(?:^|/)\\.\\.?(?:$|/))",hi="(?!\\.)",xu=new Set(["[","."]),Tu=new Set(["..","."]),_u=new Set("().*{}+?[]^$\\!"),ku=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Yr="[^/]",ra=Yr+"*?",oa=Yr+"+?",Ou=0,be=class{type;#t;#r;#n=!1;#s=[];#o;#_;#x;#f=!1;#a;#p;#c=!1;id=++Ou;get depth(){return(this.#o?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#t.id,parent:this.#o?.id,depth:this.depth,partsLength:this.#s.length,parts:this.#s}}constructor(t,s,i={}){this.type=t,t&&(this.#r=!0),this.#o=s,this.#t=this.#o?this.#o.#t:this,this.#a=this.#t===this?i:this.#t.#a,this.#x=this.#t===this?[]:this.#t.#x,t==="!"&&!this.#t.#f&&this.#x.push(this),this.#_=this.#o?this.#o.#s.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let t of this.#s)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#p!==void 0?this.#p:this.type?this.#p=this.type+"("+this.#s.map(t=>String(t)).join("|")+")":this.#p=this.#s.map(t=>String(t)).join("")}#l(){if(this!==this.#t)throw new Error("should only call on root");if(this.#f)return this;this.toString(),this.#f=!0;let t;for(;t=this.#x.pop();){if(t.type!=="!")continue;let s=t,i=s.#o;for(;i;){for(let r=s.#_+1;!i.type&&r<i.#s.length;r++)for(let o of t.#s){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(i.#s[r])}s=i,i=s.#o}}return this}push(...t){for(let s of t)if(s!==""){if(typeof s!="string"&&!(s instanceof ct&&s.#o===this))throw new Error("invalid part: "+s);this.#s.push(s)}}toJSON(){let t=this.type===null?this.#s.slice().map(s=>typeof s=="string"?s:s.toJSON()):[this.type,...this.#s.map(s=>s.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#f&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#o?.isStart())return!1;if(this.#_===0)return!0;let t=this.#o;for(let s=0;s<this.#_;s++){let i=t.#s[s];if(!(i instanceof ct&&i.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#s.length:0;return this.#_===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let s=new ct(this.type,t);for(let i of this.#s)s.copyIn(i);return s}static#i(t,s,i,r,o){let n=r.maxExtglobRecursion??2,a=!1,l=!1,h=-1,f=!1;if(s.type===null){let m=i,y="";for(;m<t.length;){let g=t.charAt(m++);if(a||g==="\\"){a=!a,y+=g;continue}if(l){m===h+1?(g==="^"||g==="!")&&(f=!0):g==="]"&&!(m===h+2&&f)&&(l=!1),y+=g;continue}else if(g==="["){l=!0,h=m,f=!1,y+=g;continue}if(!r.noext&&Hr(g)&&t.charAt(m)==="("&&o<=n){s.push(y),y="";let S=new ct(g,s);m=ct.#i(t,S,m,r,o+1),s.push(S);continue}y+=g}return s.push(y),m}let c=i+1,u=new ct(null,s),p=[],d="";for(;c<t.length;){let m=t.charAt(c++);if(a||m==="\\"){a=!a,d+=m;continue}if(l){c===h+1?(m==="^"||m==="!")&&(f=!0):m==="]"&&!(c===h+2&&f)&&(l=!1),d+=m;continue}else if(m==="["){l=!0,h=c,f=!1,d+=m;continue}if(!r.noext&&Hr(m)&&t.charAt(c)==="("&&(o<=n||s&&s.#y(m))){let g=s&&s.#y(m)?0:1;u.push(d),d="";let w=new ct(m,u);u.push(w),c=ct.#i(t,w,c,r,o+g);continue}if(m==="|"){u.push(d),d="",p.push(u),u=new ct(null,s);continue}if(m===")")return d===""&&s.#s.length===0&&(s.#c=!0),u.push(d),d="",s.push(...p,u),c;d+=m}return s.type=null,s.#r=void 0,s.#s=[t.substring(i-1)],c}#w(t){return this.#S(t,Su)}#S(t,s=bu){if(!t||typeof t!="object"||t.type!==null||t.#s.length!==1||this.type===null)return!1;let i=t.#s[0];return!i||typeof i!="object"||i.type===null?!1:this.#y(i.type,s)}#y(t,s=vu){return!!s.get(this.type)?.includes(t)}#d(t,s){let i=t.#s[0],r=new ct(null,i,this.options);r.#s.push(""),i.push(r),this.#k(t,s)}#k(t,s){let i=t.#s[0];this.#s.splice(s,1,...i.#s);for(let r of i.#s)typeof r=="object"&&(r.#o=this);this.#p=void 0}#m(t){return!!ia.get(this.type)?.has(t)}#v(t){if(!t||typeof t!="object"||t.type!==null||t.#s.length!==1||this.type===null||this.#s.length!==1)return!1;let s=t.#s[0];return!s||typeof s!="object"||s.type===null?!1:this.#m(s.type)}#T(t){let s=ia.get(this.type),i=t.#s[0],r=s?.get(i.type);if(!r)return!1;this.#s=i.#s;for(let o of this.#s)typeof o=="object"&&(o.#o=this);this.type=r,this.#p=void 0,this.#c=!1}static fromGlob(t,s={}){let i=new ct(null,void 0,s);return ct.#i(t,i,0,s,0),i}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let t=this.toString(),[s,i,r,o]=this.toRegExpSource();if(!(r||this.#r||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let a=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${s}$`,a),{_src:s,_glob:t})}get options(){return this.#a}toRegExpSource(t){let s=t??!!this.#a.dot;if(this.#t===this&&(this.#u(),this.#l()),!sa(this)){let l=this.isStart()&&this.isEnd()&&!this.#s.some(p=>typeof p!="string"),h=this.#s.map(p=>{let[d,m,y,g]=typeof p=="string"?ct.#b(p,this.#r,l):p.toRegExpSource(t);return this.#r=this.#r||y,this.#n=this.#n||g,d}).join(""),f="";if(this.isStart()&&typeof this.#s[0]=="string"&&!(this.#s.length===1&&Tu.has(this.#s[0]))){let d=xu,m=s&&d.has(h.charAt(0))||h.startsWith("\\.")&&d.has(h.charAt(2))||h.startsWith("\\.\\.")&&d.has(h.charAt(4)),y=!s&&!t&&d.has(h.charAt(0));f=m?Eu:y?hi:""}let c="";return this.isEnd()&&this.#t.#f&&this.#o?.type==="!"&&(c="(?:$|\\/)"),[f+h+c,oe(h),this.#r=!!this.#r,this.#n]}let i=this.type==="*"||this.type==="+",r=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#g(s);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString(),h=this;return h.#s=[l],h.type=null,h.#r=void 0,[l,oe(this.toString()),!1,!1]}let n=!i||t||s||!hi?"":this.#g(!0);n===o&&(n=""),n&&(o=`(?:${o})(?:${n})*?`);let a="";if(this.type==="!"&&this.#c)a=(this.isStart()&&!s?hi:"")+oa;else{let l=this.type==="!"?"))"+(this.isStart()&&!s&&!t?hi:"")+ra+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&n?")":this.type==="*"&&n?")?":`)${this.type}`;a=r+o+l}return[a,oe(o),this.#r=!!this.#r,this.#n]}#u(){if(sa(this)){let t=0,s=!1;do{s=!0;for(let i=0;i<this.#s.length;i++){let r=this.#s[i];typeof r=="object"&&(r.#u(),this.#S(r)?(s=!1,this.#k(r,i)):this.#w(r)?(s=!1,this.#d(r,i)):this.#v(r)&&(s=!1,this.#T(r)))}}while(!s&&++t<10)}else for(let t of this.#s)typeof t=="object"&&t.#u();this.#p=void 0}#g(t){return this.#s.map(s=>{if(typeof s=="string")throw new Error("string type in extglob ast??");let[i,r,o,n]=s.toRegExpSource(t);return this.#n=this.#n||n,i}).filter(s=>!(this.isStart()&&this.isEnd())||!!s).join("|")}static#b(t,s,i=!1){let r=!1,o="",n=!1,a=!1;for(let l=0;l<t.length;l++){let h=t.charAt(l);if(r){r=!1,o+=(_u.has(h)?"\\":"")+h;continue}if(h==="*"){if(a)continue;a=!0,o+=i&&/^[*]+$/.test(t)?oa:ra,s=!0;continue}else a=!1;if(h==="\\"){l===t.length-1?o+="\\\\":r=!0;continue}if(h==="["){let[f,c,u,p]=ea(t,l);if(u){o+=f,n=n||c,l+=u-1,s=s||p;continue}}if(h==="?"){o+=Yr,s=!0;continue}o+=ku(h)}return[o,oe(t),!!s,n]}};ct=be;var qr=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!1}={})=>s?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var it=(e,t,s={})=>(ms(t),!s.nocomment&&t.charAt(0)==="#"?!1:new ne(t,s).match(e)),Ru=/^\*+([^+@!?\*\[\(]*)$/,Au=e=>t=>!t.startsWith(".")&&t.endsWith(e),Cu=e=>t=>t.endsWith(e),ju=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Pu=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Nu=/^\*+\.\*+$/,Fu=e=>!e.startsWith(".")&&e.includes("."),Du=e=>e!=="."&&e!==".."&&e.includes("."),Mu=/^\.\*+$/,$u=e=>e!=="."&&e!==".."&&e.startsWith("."),Lu=/^\*+$/,Wu=e=>e.length!==0&&!e.startsWith("."),Iu=e=>e.length!==0&&e!=="."&&e!=="..",Uu=/^\?+([^+@!?\*\[\(]*)?$/,zu=([e,t=""])=>{let s=la([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},Bu=([e,t=""])=>{let s=ha([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},Gu=([e,t=""])=>{let s=ha([e]);return t?i=>s(i)&&i.endsWith(t):s},Hu=([e,t=""])=>{let s=la([e]);return t?i=>s(i)&&i.endsWith(t):s},la=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},ha=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},ca=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",na={win32:{sep:"\\"},posix:{sep:"/"}},Yu=ca==="win32"?na.win32.sep:na.posix.sep;it.sep=Yu;var V=Symbol("globstar **");it.GLOBSTAR=V;var qu="[^/]",Vu=qu+"*?",Ju="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Ku="(?:(?!(?:\\/|^)\\.).)*?",Xu=(e,t={})=>s=>it(s,e,t);it.filter=Xu;var Et=(e,t={})=>Object.assign({},e,t),Zu=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return it;let t=it;return Object.assign((i,r,o={})=>t(i,r,Et(e,o)),{Minimatch:class extends t.Minimatch{constructor(r,o={}){super(r,Et(e,o))}static defaults(r){return t.defaults(Et(e,r)).Minimatch}},AST:class extends t.AST{constructor(r,o,n={}){super(r,o,Et(e,n))}static fromGlob(r,o={}){return t.AST.fromGlob(r,Et(e,o))}},unescape:(i,r={})=>t.unescape(i,Et(e,r)),escape:(i,r={})=>t.escape(i,Et(e,r)),filter:(i,r={})=>t.filter(i,Et(e,r)),defaults:i=>t.defaults(Et(e,i)),makeRe:(i,r={})=>t.makeRe(i,Et(e,r)),braceExpand:(i,r={})=>t.braceExpand(i,Et(e,r)),match:(i,r,o={})=>t.match(i,r,Et(e,o)),sep:t.sep,GLOBSTAR:V})};it.defaults=Zu;var fa=(e,t={})=>(ms(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Qn(e,{max:t.braceExpandMax}));it.braceExpand=fa;var Qu=(e,t={})=>new ne(e,t).makeRe();it.makeRe=Qu;var tp=(e,t,s={})=>{let i=new ne(t,s);return e=e.filter(r=>i.match(r)),i.options.nonull&&!e.length&&e.push(t),e};it.match=tp;var aa=/[?*]|[+@!]\(.*?\)|\[|\]/,ep=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ne=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,s={}){ms(t),s=s||{},this.options=s,this.maxGlobstarRecursion=s.maxGlobstarRecursion??200,this.pattern=t,this.platform=s.platform||ca,this.isWindows=this.platform==="win32";let i="allowWindowsEscape";this.windowsPathsNoEscape=!!s.windowsPathsNoEscape||s[i]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!s.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!s.nonegate,this.comment=!1,this.empty=!1,this.partial=!!s.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=s.windowsNoMagicRoot!==void 0?s.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 t of this.set)for(let s of t)if(typeof s!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,s=this.options;if(!s.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],s.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let i=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(i),this.debug(this.pattern,this.globParts);let r=this.globParts.map((o,n,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=o[0]===""&&o[1]===""&&(o[2]==="?"||!aa.test(o[2]))&&!aa.test(o[3]),h=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(f=>this.parse(f))];if(h)return[o[0],...o.slice(1).map(f=>this.parse(f))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,r),this.set=r.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let n=this.set[o];n[0]===""&&n[1]===""&&this.globParts[o][2]==="?"&&typeof n[3]=="string"&&/^[a-z]:$/i.test(n[3])&&(n[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let i=0;i<t.length;i++)for(let r=0;r<t[i].length;r++)t[i][r]==="**"&&(t[i][r]="*");let{optimizationLevel:s=1}=this.options;return s>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):s>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(s=>{let i=-1;for(;(i=s.indexOf("**",i+1))!==-1;){let r=i;for(;s[r+1]==="**";)r++;r!==i&&s.splice(i,r-i)}return s})}levelOneOptimize(t){return t.map(s=>(s=s.reduce((i,r)=>{let o=i[i.length-1];return r==="**"&&o==="**"?i:r===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(i.pop(),i):(i.push(r),i)},[]),s.length===0?[""]:s))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let s=!1;do{if(s=!1,!this.preserveMultipleSlashes){for(let r=1;r<t.length-1;r++){let o=t[r];r===1&&o===""&&t[0]===""||(o==="."||o==="")&&(s=!0,t.splice(r,1),r--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(s=!0,t.pop())}let i=0;for(;(i=t.indexOf("..",i+1))!==-1;){let r=t[i-1];r&&r!=="."&&r!==".."&&r!=="**"&&(s=!0,t.splice(i-1,2),i-=2)}}while(s);return t.length===0?[""]:t}firstPhasePreProcess(t){let s=!1;do{s=!1;for(let i of t){let r=-1;for(;(r=i.indexOf("**",r+1))!==-1;){let n=r;for(;i[n+1]==="**";)n++;n>r&&i.splice(r+1,n-r);let a=i[r+1],l=i[r+2],h=i[r+3];if(a!==".."||!l||l==="."||l===".."||!h||h==="."||h==="..")continue;s=!0,i.splice(r,1);let f=i.slice(0);f[r]="**",t.push(f),r--}if(!this.preserveMultipleSlashes){for(let n=1;n<i.length-1;n++){let a=i[n];n===1&&a===""&&i[0]===""||(a==="."||a==="")&&(s=!0,i.splice(n,1),n--)}i[0]==="."&&i.length===2&&(i[1]==="."||i[1]==="")&&(s=!0,i.pop())}let o=0;for(;(o=i.indexOf("..",o+1))!==-1;){let n=i[o-1];if(n&&n!=="."&&n!==".."&&n!=="**"){s=!0;let l=o===1&&i[o+1]==="**"?["."]:[];i.splice(o-1,2,...l),i.length===0&&i.push(""),o-=2}}}}while(s);return t}secondPhasePreProcess(t){for(let s=0;s<t.length-1;s++)for(let i=s+1;i<t.length;i++){let r=this.partsMatch(t[s],t[i],!this.preserveMultipleSlashes);if(r){t[s]=[],t[i]=r;break}}return t.filter(s=>s.length)}partsMatch(t,s,i=!1){let r=0,o=0,n=[],a="";for(;r<t.length&&o<s.length;)if(t[r]===s[o])n.push(a==="b"?s[o]:t[r]),r++,o++;else if(i&&t[r]==="**"&&s[o]===t[r+1])n.push(t[r]),r++;else if(i&&s[o]==="**"&&t[r]===s[o+1])n.push(s[o]),o++;else if(t[r]==="*"&&s[o]&&(this.options.dot||!s[o].startsWith("."))&&s[o]!=="**"){if(a==="b")return!1;a="a",n.push(t[r]),r++,o++}else if(s[o]==="*"&&t[r]&&(this.options.dot||!t[r].startsWith("."))&&t[r]!=="**"){if(a==="a")return!1;a="b",n.push(s[o]),r++,o++}else return!1;return t.length===s.length&&n}parseNegate(){if(this.nonegate)return;let t=this.pattern,s=!1,i=0;for(let r=0;r<t.length&&t.charAt(r)==="!";r++)s=!s,i++;i&&(this.pattern=t.slice(i)),this.negate=s}matchOne(t,s,i=!1){let r=0,o=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),l=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),h=typeof s[0]=="string"&&/^[a-z]:$/i.test(s[0]),f=!h&&s[0]===""&&s[1]===""&&s[2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3]),c=l?3:a?0:void 0,u=f?3:h?0:void 0;if(typeof c=="number"&&typeof u=="number"){let[p,d]=[t[c],s[u]];p.toLowerCase()===d.toLowerCase()&&(s[u]=p,o=u,r=c)}}let{optimizationLevel:n=1}=this.options;return n>=2&&(t=this.levelTwoFileOptimize(t)),s.includes(V)?this.#t(t,s,i,r,o):this.#n(t,s,i,r,o)}#t(t,s,i,r,o){let n=s.indexOf(V,o),a=s.lastIndexOf(V),[l,h,f]=i?[s.slice(o,n),s.slice(n+1),[]]:[s.slice(o,n),s.slice(n+1,a),s.slice(a+1)];if(l.length){let w=t.slice(r,r+l.length);if(!this.#n(w,l,i,0,0))return!1;r+=l.length,o+=l.length}let c=0;if(f.length){if(f.length+r>t.length)return!1;let w=t.length-f.length;if(this.#n(t,f,i,w,0))c=f.length;else{if(t[t.length-1]!==""||r+f.length===t.length||(w--,!this.#n(t,f,i,w,0)))return!1;c=f.length+1}}if(!h.length){let w=!!c;for(let S=r;S<t.length-c;S++){let b=String(t[S]);if(w=!0,b==="."||b===".."||!this.options.dot&&b.startsWith("."))return!1}return i||w}let u=[[[],0]],p=u[0],d=0,m=[0];for(let w of h)w===V?(m.push(d),p=[[],0],u.push(p)):(p[0].push(w),d++);let y=u.length-1,g=t.length-c;for(let w of u)w[1]=g-(m[y--]+w[0].length);return!!this.#r(t,u,r,0,i,0,!!c)}#r(t,s,i,r,o,n,a){let l=s[r];if(!l){for(let c=i;c<t.length;c++){a=!0;let u=t[c];if(u==="."||u===".."||!this.options.dot&&u.startsWith("."))return!1}return a}let[h,f]=l;for(;i<=f;){if(this.#n(t.slice(0,i+h.length),h,o,i,0)&&n<this.maxGlobstarRecursion){let p=this.#r(t,s,i+h.length,r+1,o,n+1,a);if(p!==!1)return p}let u=t[i];if(u==="."||u===".."||!this.options.dot&&u.startsWith("."))return!1;i++}return o||null}#n(t,s,i,r,o){let n,a,l,h;for(n=r,a=o,h=t.length,l=s.length;n<h&&a<l;n++,a++){this.debug("matchOne loop");let f=s[a],c=t[n];if(this.debug(s,f,c),f===!1||f===V)return!1;let u;if(typeof f=="string"?(u=c===f,this.debug("string match",f,c,u)):(u=f.test(c),this.debug("pattern match",f,c,u)),!u)return!1}if(n===h&&a===l)return!0;if(n===h)return i;if(a===l)return n===h-1&&t[n]==="";throw new Error("wtf?")}braceExpand(){return fa(this.pattern,this.options)}parse(t){ms(t);let s=this.options;if(t==="**")return V;if(t==="")return"";let i,r=null;(i=t.match(Lu))?r=s.dot?Iu:Wu:(i=t.match(Ru))?r=(s.nocase?s.dot?Pu:ju:s.dot?Cu:Au)(i[1]):(i=t.match(Uu))?r=(s.nocase?s.dot?Bu:zu:s.dot?Gu:Hu)(i):(i=t.match(Nu))?r=s.dot?Du:Fu:(i=t.match(Mu))&&(r=$u);let o=be.fromGlob(t,this.options).toMMPattern();return r&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:r}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let s=this.options,i=s.noglobstar?Vu:s.dot?Ju:Ku,r=new Set(s.nocase?["i"]:[]),o=t.map(l=>{let h=l.map(c=>{if(c instanceof RegExp)for(let u of c.flags.split(""))r.add(u);return typeof c=="string"?ep(c):c===V?V:c._src});h.forEach((c,u)=>{let p=h[u+1],d=h[u-1];c!==V||d===V||(d===void 0?p!==void 0&&p!==V?h[u+1]="(?:\\/|"+i+"\\/)?"+p:h[u]=i:p===void 0?h[u-1]=d+"(?:\\/|\\/"+i+")?":p!==V&&(h[u-1]=d+"(?:\\/|\\/"+i+"\\/)"+p,h[u+1]=V))});let f=h.filter(c=>c!==V);if(this.partial&&f.length>=1){let c=[];for(let u=1;u<=f.length;u++)c.push(f.slice(0,u).join("/"));return"(?:"+c.join("|")+")"}return f.join("/")}).join("|"),[n,a]=t.length>1?["(?:",")"]:["",""];o="^"+n+o+a+"$",this.partial&&(o="^(?:\\/|"+n+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...r].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,s=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&s)return!0;let i=this.options;this.isWindows&&(t=t.split("\\").join("/"));let r=this.slashSplit(t);this.debug(this.pattern,"split",r);let o=this.set;this.debug(this.pattern,"set",o);let n=r[r.length-1];if(!n)for(let a=r.length-2;!n&&a>=0;a--)n=r[a];for(let a=0;a<o.length;a++){let l=o[a],h=r;if(i.matchBase&&l.length===1&&(h=[n]),this.matchOne(h,l,s))return i.flipNegate?!0:!this.negate}return i.flipNegate?!1:this.negate}static defaults(t){return it.defaults(t).Minimatch}};it.AST=be;it.Minimatch=ne;it.escape=qr;it.unescape=oe;var Vr=parseInt(process.env.TSHY_VERBOSE||"0"),ci=[],F=(...e)=>{Vr>=1?console.error(...e):ci.push(e)},T=(...e)=>{Vr>=2?console.error(...e):ci.push(e)},ua=(...e)=>{Vr>=1&&console.log(...e)},Me=()=>{for(let e of ci)console.error(...e);ci.length=0};var _=(e,t)=>{F(E.red.bold(e)),t&&F(t.message),Me()};import{readFileSync as ap}from"fs";var sp=e=>Array.from(e).map(t=>"0x"+t.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")).join(""),ip=(e,t,s)=>{if(!t)return{message:e.message+" while parsing empty string",position:0};let i=e.message.match(/^Unexpected (?:token (.*?))?/i),r=e.message.match(/at positions? (\d+)/),o=/^Unexpected end of JSON|Unterminated string in JSON/i.test(e.message)?t.length-1:r&&r[1]?+r[1]:/is not valid JSON$/.test(e.message)?0:null,n=i&&i[1]?e.message.replace(/^Unexpected token ./,`Unexpected token ${JSON.stringify(i[1])} (${sp(i[1])})`):e.message;if(o!=null){let a=o<=s?0:o-s,l=o+s>=t.length?t.length:o+s,h=(a===0?"":"...")+t.slice(a,l)+(l===t.length?"":"...");return{message:n+` while parsing ${t===h?"":"near "}${JSON.stringify(h)}`,position:o}}else return{message:n+` while parsing '${t.slice(0,s*2)}'`,position:0}},Jr=class extends SyntaxError{code;cause;position;constructor(t,s,i=20,r){let{message:o,position:n}=ip(t,s,i);super(o),this.cause=t,this.position=n,this.code="EJSONPARSE",Error.captureStackTrace(this,r||this.constructor)}get name(){return this.constructor.name}set name(t){}get[Symbol.toStringTag](){return this.constructor.name}},pa=Symbol.for("indent"),da=Symbol.for("newline"),rp=/^\s*[{\[]((?:\r?\n)+)([\s\t]*)/,op=/^(?:\{\}|\[\])((?:\r?\n)+)?$/,Kr=(e,t,s)=>{let i=np(String(e));t||(t=void 0),s=s||20;try{let[,r=`
6
+ `);return o!==-1&&(t=Bn(t,r,i,o)),i+t+r};Object.defineProperties(ps.prototype,De);var Xf=ps(),sS=ps({level:Hn?Hn.level:0});var E=Xf;var zr=(e,t,s)=>{let i=e instanceof RegExp?qn(e,s):e,r=t instanceof RegExp?qn(t,s):t,o=i!==null&&r!=null&&Zf(i,r,s);return o&&{start:o[0],end:o[1],pre:s.slice(0,o[0]),body:s.slice(o[0]+i.length,o[1]),post:s.slice(o[1]+r.length)}},qn=(e,t)=>{let s=t.match(e);return s?s[0]:null},Zf=(e,t,s)=>{let i,r,o,n,a,l=s.indexOf(e),h=s.indexOf(t,l+1),f=l;if(l>=0&&h>0){if(e===t)return[l,h];for(i=[],o=s.length;f>=0&&!a;){if(f===l)i.push(f),l=s.indexOf(e,f+1);else if(i.length===1){let c=i.pop();c!==void 0&&(a=[c,h])}else r=i.pop(),r!==void 0&&r<o&&(o=r,n=h),h=s.indexOf(t,f+1);f=l<h&&l>=0?l:h}i.length&&n!==void 0&&(a=[o,n])}return a};var Vn="\0SLASH"+Math.random()+"\0",Jn="\0OPEN"+Math.random()+"\0",Gr="\0CLOSE"+Math.random()+"\0",Kn="\0COMMA"+Math.random()+"\0",Xn="\0PERIOD"+Math.random()+"\0",Qf=new RegExp(Vn,"g"),tu=new RegExp(Jn,"g"),eu=new RegExp(Gr,"g"),su=new RegExp(Kn,"g"),iu=new RegExp(Xn,"g"),ru=/\\\\/g,ou=/\\{/g,nu=/\\}/g,au=/\\,/g,lu=/\\./g,hu=1e5;function Br(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function cu(e){return e.replace(ru,Vn).replace(ou,Jn).replace(nu,Gr).replace(au,Kn).replace(lu,Xn)}function fu(e){return e.replace(Qf,"\\").replace(tu,"{").replace(eu,"}").replace(su,",").replace(iu,".")}function Zn(e){if(!e)return[""];let t=[],s=zr("{","}",e);if(!s)return e.split(",");let{pre:i,body:r,post:o}=s,n=i.split(",");n[n.length-1]+="{"+r+"}";let a=Zn(o);return o.length&&(n[n.length-1]+=a.shift(),n.push.apply(n,a)),t.push.apply(t,n),t}function Qn(e,t={}){if(!e)return[];let{max:s=hu}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),ds(cu(e),s,!0).map(fu)}function uu(e){return"{"+e+"}"}function pu(e){return/^-?0\d/.test(e)}function du(e,t){return e<=t}function mu(e,t){return e>=t}function ds(e,t,s){let i=[],r=zr("{","}",e);if(!r)return[e];let o=r.pre,n=r.post.length?ds(r.post,t,!1):[""];if(/\$$/.test(r.pre))for(let a=0;a<n.length&&a<t;a++){let l=o+"{"+r.body+"}"+n[a];i.push(l)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(r.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(r.body),h=a||l,f=r.body.indexOf(",")>=0;if(!h&&!f)return r.post.match(/,(?!,).*\}/)?(e=r.pre+"{"+r.body+Gr+r.post,ds(e,t,!0)):[e];let c;if(h)c=r.body.split(/\.\./);else if(c=Zn(r.body),c.length===1&&c[0]!==void 0&&(c=ds(c[0],t,!1).map(uu),c.length===1))return n.map(p=>r.pre+c[0]+p);let u;if(h&&c[0]!==void 0&&c[1]!==void 0){let p=Br(c[0]),d=Br(c[1]),m=Math.max(c[0].length,c[1].length),y=c.length===3&&c[2]!==void 0?Math.abs(Br(c[2])):1,g=du;d<p&&(y*=-1,g=mu);let S=c.some(pu);u=[];for(let b=p;g(b,d);b+=y){let v;if(l)v=String.fromCharCode(b),v==="\\"&&(v="");else if(v=String(b),S){let R=m-v.length;if(R>0){let L=new Array(R+1).join("0");b<0?v="-"+L+v.slice(1):v=L+v}}u.push(v)}}else{u=[];for(let p=0;p<c.length;p++)u.push.apply(u,ds(c[p],t,!1))}for(let p=0;p<u.length;p++)for(let d=0;d<n.length&&i.length<t;d++){let m=o+u[p]+n[d];(!s||h||m)&&i.push(m)}}return i}var ms=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var gu={"[: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]},gs=e=>e.replace(/[[\]\\-]/g,"\\$&"),yu=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ta=e=>e.join(""),ea=(e,t)=>{let s=t;if(e.charAt(s)!=="[")throw new Error("not in a brace expression");let i=[],r=[],o=s+1,n=!1,a=!1,l=!1,h=!1,f=s,c="";t:for(;o<e.length;){let m=e.charAt(o);if((m==="!"||m==="^")&&o===s+1){h=!0,o++;continue}if(m==="]"&&n&&!l){f=o+1;break}if(n=!0,m==="\\"&&!l){l=!0,o++;continue}if(m==="["&&!l){for(let[y,[g,w,S]]of Object.entries(gu))if(e.startsWith(y,o)){if(c)return["$.",!1,e.length-s,!0];o+=y.length,S?r.push(g):i.push(g),a=a||w;continue t}}if(l=!1,c){m>c?i.push(gs(c)+"-"+gs(m)):m===c&&i.push(gs(m)),c="",o++;continue}if(e.startsWith("-]",o+1)){i.push(gs(m+"-")),o+=2;continue}if(e.startsWith("-",o+1)){c=m,o+=2;continue}i.push(gs(m)),o++}if(f<o)return["",!1,0,!1];if(!i.length&&!r.length)return["$.",!1,e.length-s,!0];if(r.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!h){let m=i[0].length===2?i[0].slice(-1):i[0];return[yu(m),!1,f-s,!1]}let u="["+(h?"^":"")+ta(i)+"]",p="["+(h?"":"^")+ta(r)+"]";return[i.length&&r.length?"("+u+"|"+p+")":i.length?u:p,a,f-s,!0]};var oe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!0}={})=>s?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1");var ct,wu=new Set(["!","?","+","*","@"]),Hr=e=>wu.has(e),sa=e=>Hr(e.type),bu=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Su=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),vu=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),ia=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Eu="(?!(?:^|/)\\.\\.?(?:$|/))",hi="(?!\\.)",xu=new Set(["[","."]),Tu=new Set(["..","."]),_u=new Set("().*{}+?[]^$\\!"),ku=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Yr="[^/]",ra=Yr+"*?",oa=Yr+"+?",Ou=0,be=class{type;#t;#r;#n=!1;#s=[];#o;#_;#x;#f=!1;#a;#p;#c=!1;id=++Ou;get depth(){return(this.#o?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#t.id,parent:this.#o?.id,depth:this.depth,partsLength:this.#s.length,parts:this.#s}}constructor(t,s,i={}){this.type=t,t&&(this.#r=!0),this.#o=s,this.#t=this.#o?this.#o.#t:this,this.#a=this.#t===this?i:this.#t.#a,this.#x=this.#t===this?[]:this.#t.#x,t==="!"&&!this.#t.#f&&this.#x.push(this),this.#_=this.#o?this.#o.#s.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let t of this.#s)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#p!==void 0?this.#p:this.type?this.#p=this.type+"("+this.#s.map(t=>String(t)).join("|")+")":this.#p=this.#s.map(t=>String(t)).join("")}#l(){if(this!==this.#t)throw new Error("should only call on root");if(this.#f)return this;this.toString(),this.#f=!0;let t;for(;t=this.#x.pop();){if(t.type!=="!")continue;let s=t,i=s.#o;for(;i;){for(let r=s.#_+1;!i.type&&r<i.#s.length;r++)for(let o of t.#s){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(i.#s[r])}s=i,i=s.#o}}return this}push(...t){for(let s of t)if(s!==""){if(typeof s!="string"&&!(s instanceof ct&&s.#o===this))throw new Error("invalid part: "+s);this.#s.push(s)}}toJSON(){let t=this.type===null?this.#s.slice().map(s=>typeof s=="string"?s:s.toJSON()):[this.type,...this.#s.map(s=>s.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#f&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#o?.isStart())return!1;if(this.#_===0)return!0;let t=this.#o;for(let s=0;s<this.#_;s++){let i=t.#s[s];if(!(i instanceof ct&&i.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#s.length:0;return this.#_===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let s=new ct(this.type,t);for(let i of this.#s)s.copyIn(i);return s}static#i(t,s,i,r,o){let n=r.maxExtglobRecursion??2,a=!1,l=!1,h=-1,f=!1;if(s.type===null){let m=i,y="";for(;m<t.length;){let g=t.charAt(m++);if(a||g==="\\"){a=!a,y+=g;continue}if(l){m===h+1?(g==="^"||g==="!")&&(f=!0):g==="]"&&!(m===h+2&&f)&&(l=!1),y+=g;continue}else if(g==="["){l=!0,h=m,f=!1,y+=g;continue}if(!r.noext&&Hr(g)&&t.charAt(m)==="("&&o<=n){s.push(y),y="";let S=new ct(g,s);m=ct.#i(t,S,m,r,o+1),s.push(S);continue}y+=g}return s.push(y),m}let c=i+1,u=new ct(null,s),p=[],d="";for(;c<t.length;){let m=t.charAt(c++);if(a||m==="\\"){a=!a,d+=m;continue}if(l){c===h+1?(m==="^"||m==="!")&&(f=!0):m==="]"&&!(c===h+2&&f)&&(l=!1),d+=m;continue}else if(m==="["){l=!0,h=c,f=!1,d+=m;continue}if(!r.noext&&Hr(m)&&t.charAt(c)==="("&&(o<=n||s&&s.#y(m))){let g=s&&s.#y(m)?0:1;u.push(d),d="";let w=new ct(m,u);u.push(w),c=ct.#i(t,w,c,r,o+g);continue}if(m==="|"){u.push(d),d="",p.push(u),u=new ct(null,s);continue}if(m===")")return d===""&&s.#s.length===0&&(s.#c=!0),u.push(d),d="",s.push(...p,u),c;d+=m}return s.type=null,s.#r=void 0,s.#s=[t.substring(i-1)],c}#w(t){return this.#S(t,Su)}#S(t,s=bu){if(!t||typeof t!="object"||t.type!==null||t.#s.length!==1||this.type===null)return!1;let i=t.#s[0];return!i||typeof i!="object"||i.type===null?!1:this.#y(i.type,s)}#y(t,s=vu){return!!s.get(this.type)?.includes(t)}#d(t,s){let i=t.#s[0],r=new ct(null,i,this.options);r.#s.push(""),i.push(r),this.#k(t,s)}#k(t,s){let i=t.#s[0];this.#s.splice(s,1,...i.#s);for(let r of i.#s)typeof r=="object"&&(r.#o=this);this.#p=void 0}#m(t){return!!ia.get(this.type)?.has(t)}#v(t){if(!t||typeof t!="object"||t.type!==null||t.#s.length!==1||this.type===null||this.#s.length!==1)return!1;let s=t.#s[0];return!s||typeof s!="object"||s.type===null?!1:this.#m(s.type)}#T(t){let s=ia.get(this.type),i=t.#s[0],r=s?.get(i.type);if(!r)return!1;this.#s=i.#s;for(let o of this.#s)typeof o=="object"&&(o.#o=this);this.type=r,this.#p=void 0,this.#c=!1}static fromGlob(t,s={}){let i=new ct(null,void 0,s);return ct.#i(t,i,0,s,0),i}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let t=this.toString(),[s,i,r,o]=this.toRegExpSource();if(!(r||this.#r||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let a=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${s}$`,a),{_src:s,_glob:t})}get options(){return this.#a}toRegExpSource(t){let s=t??!!this.#a.dot;if(this.#t===this&&(this.#u(),this.#l()),!sa(this)){let l=this.isStart()&&this.isEnd()&&!this.#s.some(p=>typeof p!="string"),h=this.#s.map(p=>{let[d,m,y,g]=typeof p=="string"?ct.#b(p,this.#r,l):p.toRegExpSource(t);return this.#r=this.#r||y,this.#n=this.#n||g,d}).join(""),f="";if(this.isStart()&&typeof this.#s[0]=="string"&&!(this.#s.length===1&&Tu.has(this.#s[0]))){let d=xu,m=s&&d.has(h.charAt(0))||h.startsWith("\\.")&&d.has(h.charAt(2))||h.startsWith("\\.\\.")&&d.has(h.charAt(4)),y=!s&&!t&&d.has(h.charAt(0));f=m?Eu:y?hi:""}let c="";return this.isEnd()&&this.#t.#f&&this.#o?.type==="!"&&(c="(?:$|\\/)"),[f+h+c,oe(h),this.#r=!!this.#r,this.#n]}let i=this.type==="*"||this.type==="+",r=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#g(s);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString(),h=this;return h.#s=[l],h.type=null,h.#r=void 0,[l,oe(this.toString()),!1,!1]}let n=!i||t||s||!hi?"":this.#g(!0);n===o&&(n=""),n&&(o=`(?:${o})(?:${n})*?`);let a="";if(this.type==="!"&&this.#c)a=(this.isStart()&&!s?hi:"")+oa;else{let l=this.type==="!"?"))"+(this.isStart()&&!s&&!t?hi:"")+ra+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&n?")":this.type==="*"&&n?")?":`)${this.type}`;a=r+o+l}return[a,oe(o),this.#r=!!this.#r,this.#n]}#u(){if(sa(this)){let t=0,s=!1;do{s=!0;for(let i=0;i<this.#s.length;i++){let r=this.#s[i];typeof r=="object"&&(r.#u(),this.#S(r)?(s=!1,this.#k(r,i)):this.#w(r)?(s=!1,this.#d(r,i)):this.#v(r)&&(s=!1,this.#T(r)))}}while(!s&&++t<10)}else for(let t of this.#s)typeof t=="object"&&t.#u();this.#p=void 0}#g(t){return this.#s.map(s=>{if(typeof s=="string")throw new Error("string type in extglob ast??");let[i,r,o,n]=s.toRegExpSource(t);return this.#n=this.#n||n,i}).filter(s=>!(this.isStart()&&this.isEnd())||!!s).join("|")}static#b(t,s,i=!1){let r=!1,o="",n=!1,a=!1;for(let l=0;l<t.length;l++){let h=t.charAt(l);if(r){r=!1,o+=(_u.has(h)?"\\":"")+h;continue}if(h==="*"){if(a)continue;a=!0,o+=i&&/^[*]+$/.test(t)?oa:ra,s=!0;continue}else a=!1;if(h==="\\"){l===t.length-1?o+="\\\\":r=!0;continue}if(h==="["){let[f,c,u,p]=ea(t,l);if(u){o+=f,n=n||c,l+=u-1,s=s||p;continue}}if(h==="?"){o+=Yr,s=!0;continue}o+=ku(h)}return[o,oe(t),!!s,n]}};ct=be;var qr=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!1}={})=>s?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var it=(e,t,s={})=>(ms(t),!s.nocomment&&t.charAt(0)==="#"?!1:new ne(t,s).match(e)),Ru=/^\*+([^+@!?\*\[\(]*)$/,Au=e=>t=>!t.startsWith(".")&&t.endsWith(e),ju=e=>t=>t.endsWith(e),Cu=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Pu=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Nu=/^\*+\.\*+$/,Fu=e=>!e.startsWith(".")&&e.includes("."),Du=e=>e!=="."&&e!==".."&&e.includes("."),$u=/^\.\*+$/,Mu=e=>e!=="."&&e!==".."&&e.startsWith("."),Lu=/^\*+$/,Wu=e=>e.length!==0&&!e.startsWith("."),Iu=e=>e.length!==0&&e!=="."&&e!=="..",Uu=/^\?+([^+@!?\*\[\(]*)?$/,zu=([e,t=""])=>{let s=la([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},Bu=([e,t=""])=>{let s=ha([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},Gu=([e,t=""])=>{let s=ha([e]);return t?i=>s(i)&&i.endsWith(t):s},Hu=([e,t=""])=>{let s=la([e]);return t?i=>s(i)&&i.endsWith(t):s},la=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},ha=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},ca=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",na={win32:{sep:"\\"},posix:{sep:"/"}},Yu=ca==="win32"?na.win32.sep:na.posix.sep;it.sep=Yu;var V=Symbol("globstar **");it.GLOBSTAR=V;var qu="[^/]",Vu=qu+"*?",Ju="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Ku="(?:(?!(?:\\/|^)\\.).)*?",Xu=(e,t={})=>s=>it(s,e,t);it.filter=Xu;var Et=(e,t={})=>Object.assign({},e,t),Zu=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return it;let t=it;return Object.assign((i,r,o={})=>t(i,r,Et(e,o)),{Minimatch:class extends t.Minimatch{constructor(r,o={}){super(r,Et(e,o))}static defaults(r){return t.defaults(Et(e,r)).Minimatch}},AST:class extends t.AST{constructor(r,o,n={}){super(r,o,Et(e,n))}static fromGlob(r,o={}){return t.AST.fromGlob(r,Et(e,o))}},unescape:(i,r={})=>t.unescape(i,Et(e,r)),escape:(i,r={})=>t.escape(i,Et(e,r)),filter:(i,r={})=>t.filter(i,Et(e,r)),defaults:i=>t.defaults(Et(e,i)),makeRe:(i,r={})=>t.makeRe(i,Et(e,r)),braceExpand:(i,r={})=>t.braceExpand(i,Et(e,r)),match:(i,r,o={})=>t.match(i,r,Et(e,o)),sep:t.sep,GLOBSTAR:V})};it.defaults=Zu;var fa=(e,t={})=>(ms(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Qn(e,{max:t.braceExpandMax}));it.braceExpand=fa;var Qu=(e,t={})=>new ne(e,t).makeRe();it.makeRe=Qu;var tp=(e,t,s={})=>{let i=new ne(t,s);return e=e.filter(r=>i.match(r)),i.options.nonull&&!e.length&&e.push(t),e};it.match=tp;var aa=/[?*]|[+@!]\(.*?\)|\[|\]/,ep=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ne=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,s={}){ms(t),s=s||{},this.options=s,this.maxGlobstarRecursion=s.maxGlobstarRecursion??200,this.pattern=t,this.platform=s.platform||ca,this.isWindows=this.platform==="win32";let i="allowWindowsEscape";this.windowsPathsNoEscape=!!s.windowsPathsNoEscape||s[i]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!s.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!s.nonegate,this.comment=!1,this.empty=!1,this.partial=!!s.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=s.windowsNoMagicRoot!==void 0?s.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 t of this.set)for(let s of t)if(typeof s!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,s=this.options;if(!s.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],s.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let i=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(i),this.debug(this.pattern,this.globParts);let r=this.globParts.map((o,n,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=o[0]===""&&o[1]===""&&(o[2]==="?"||!aa.test(o[2]))&&!aa.test(o[3]),h=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(f=>this.parse(f))];if(h)return[o[0],...o.slice(1).map(f=>this.parse(f))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,r),this.set=r.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let n=this.set[o];n[0]===""&&n[1]===""&&this.globParts[o][2]==="?"&&typeof n[3]=="string"&&/^[a-z]:$/i.test(n[3])&&(n[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let i=0;i<t.length;i++)for(let r=0;r<t[i].length;r++)t[i][r]==="**"&&(t[i][r]="*");let{optimizationLevel:s=1}=this.options;return s>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):s>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(s=>{let i=-1;for(;(i=s.indexOf("**",i+1))!==-1;){let r=i;for(;s[r+1]==="**";)r++;r!==i&&s.splice(i,r-i)}return s})}levelOneOptimize(t){return t.map(s=>(s=s.reduce((i,r)=>{let o=i[i.length-1];return r==="**"&&o==="**"?i:r===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(i.pop(),i):(i.push(r),i)},[]),s.length===0?[""]:s))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let s=!1;do{if(s=!1,!this.preserveMultipleSlashes){for(let r=1;r<t.length-1;r++){let o=t[r];r===1&&o===""&&t[0]===""||(o==="."||o==="")&&(s=!0,t.splice(r,1),r--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(s=!0,t.pop())}let i=0;for(;(i=t.indexOf("..",i+1))!==-1;){let r=t[i-1];r&&r!=="."&&r!==".."&&r!=="**"&&(s=!0,t.splice(i-1,2),i-=2)}}while(s);return t.length===0?[""]:t}firstPhasePreProcess(t){let s=!1;do{s=!1;for(let i of t){let r=-1;for(;(r=i.indexOf("**",r+1))!==-1;){let n=r;for(;i[n+1]==="**";)n++;n>r&&i.splice(r+1,n-r);let a=i[r+1],l=i[r+2],h=i[r+3];if(a!==".."||!l||l==="."||l===".."||!h||h==="."||h==="..")continue;s=!0,i.splice(r,1);let f=i.slice(0);f[r]="**",t.push(f),r--}if(!this.preserveMultipleSlashes){for(let n=1;n<i.length-1;n++){let a=i[n];n===1&&a===""&&i[0]===""||(a==="."||a==="")&&(s=!0,i.splice(n,1),n--)}i[0]==="."&&i.length===2&&(i[1]==="."||i[1]==="")&&(s=!0,i.pop())}let o=0;for(;(o=i.indexOf("..",o+1))!==-1;){let n=i[o-1];if(n&&n!=="."&&n!==".."&&n!=="**"){s=!0;let l=o===1&&i[o+1]==="**"?["."]:[];i.splice(o-1,2,...l),i.length===0&&i.push(""),o-=2}}}}while(s);return t}secondPhasePreProcess(t){for(let s=0;s<t.length-1;s++)for(let i=s+1;i<t.length;i++){let r=this.partsMatch(t[s],t[i],!this.preserveMultipleSlashes);if(r){t[s]=[],t[i]=r;break}}return t.filter(s=>s.length)}partsMatch(t,s,i=!1){let r=0,o=0,n=[],a="";for(;r<t.length&&o<s.length;)if(t[r]===s[o])n.push(a==="b"?s[o]:t[r]),r++,o++;else if(i&&t[r]==="**"&&s[o]===t[r+1])n.push(t[r]),r++;else if(i&&s[o]==="**"&&t[r]===s[o+1])n.push(s[o]),o++;else if(t[r]==="*"&&s[o]&&(this.options.dot||!s[o].startsWith("."))&&s[o]!=="**"){if(a==="b")return!1;a="a",n.push(t[r]),r++,o++}else if(s[o]==="*"&&t[r]&&(this.options.dot||!t[r].startsWith("."))&&t[r]!=="**"){if(a==="a")return!1;a="b",n.push(s[o]),r++,o++}else return!1;return t.length===s.length&&n}parseNegate(){if(this.nonegate)return;let t=this.pattern,s=!1,i=0;for(let r=0;r<t.length&&t.charAt(r)==="!";r++)s=!s,i++;i&&(this.pattern=t.slice(i)),this.negate=s}matchOne(t,s,i=!1){let r=0,o=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),l=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),h=typeof s[0]=="string"&&/^[a-z]:$/i.test(s[0]),f=!h&&s[0]===""&&s[1]===""&&s[2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3]),c=l?3:a?0:void 0,u=f?3:h?0:void 0;if(typeof c=="number"&&typeof u=="number"){let[p,d]=[t[c],s[u]];p.toLowerCase()===d.toLowerCase()&&(s[u]=p,o=u,r=c)}}let{optimizationLevel:n=1}=this.options;return n>=2&&(t=this.levelTwoFileOptimize(t)),s.includes(V)?this.#t(t,s,i,r,o):this.#n(t,s,i,r,o)}#t(t,s,i,r,o){let n=s.indexOf(V,o),a=s.lastIndexOf(V),[l,h,f]=i?[s.slice(o,n),s.slice(n+1),[]]:[s.slice(o,n),s.slice(n+1,a),s.slice(a+1)];if(l.length){let w=t.slice(r,r+l.length);if(!this.#n(w,l,i,0,0))return!1;r+=l.length,o+=l.length}let c=0;if(f.length){if(f.length+r>t.length)return!1;let w=t.length-f.length;if(this.#n(t,f,i,w,0))c=f.length;else{if(t[t.length-1]!==""||r+f.length===t.length||(w--,!this.#n(t,f,i,w,0)))return!1;c=f.length+1}}if(!h.length){let w=!!c;for(let S=r;S<t.length-c;S++){let b=String(t[S]);if(w=!0,b==="."||b===".."||!this.options.dot&&b.startsWith("."))return!1}return i||w}let u=[[[],0]],p=u[0],d=0,m=[0];for(let w of h)w===V?(m.push(d),p=[[],0],u.push(p)):(p[0].push(w),d++);let y=u.length-1,g=t.length-c;for(let w of u)w[1]=g-(m[y--]+w[0].length);return!!this.#r(t,u,r,0,i,0,!!c)}#r(t,s,i,r,o,n,a){let l=s[r];if(!l){for(let c=i;c<t.length;c++){a=!0;let u=t[c];if(u==="."||u===".."||!this.options.dot&&u.startsWith("."))return!1}return a}let[h,f]=l;for(;i<=f;){if(this.#n(t.slice(0,i+h.length),h,o,i,0)&&n<this.maxGlobstarRecursion){let p=this.#r(t,s,i+h.length,r+1,o,n+1,a);if(p!==!1)return p}let u=t[i];if(u==="."||u===".."||!this.options.dot&&u.startsWith("."))return!1;i++}return o||null}#n(t,s,i,r,o){let n,a,l,h;for(n=r,a=o,h=t.length,l=s.length;n<h&&a<l;n++,a++){this.debug("matchOne loop");let f=s[a],c=t[n];if(this.debug(s,f,c),f===!1||f===V)return!1;let u;if(typeof f=="string"?(u=c===f,this.debug("string match",f,c,u)):(u=f.test(c),this.debug("pattern match",f,c,u)),!u)return!1}if(n===h&&a===l)return!0;if(n===h)return i;if(a===l)return n===h-1&&t[n]==="";throw new Error("wtf?")}braceExpand(){return fa(this.pattern,this.options)}parse(t){ms(t);let s=this.options;if(t==="**")return V;if(t==="")return"";let i,r=null;(i=t.match(Lu))?r=s.dot?Iu:Wu:(i=t.match(Ru))?r=(s.nocase?s.dot?Pu:Cu:s.dot?ju:Au)(i[1]):(i=t.match(Uu))?r=(s.nocase?s.dot?Bu:zu:s.dot?Gu:Hu)(i):(i=t.match(Nu))?r=s.dot?Du:Fu:(i=t.match($u))&&(r=Mu);let o=be.fromGlob(t,this.options).toMMPattern();return r&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:r}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let s=this.options,i=s.noglobstar?Vu:s.dot?Ju:Ku,r=new Set(s.nocase?["i"]:[]),o=t.map(l=>{let h=l.map(c=>{if(c instanceof RegExp)for(let u of c.flags.split(""))r.add(u);return typeof c=="string"?ep(c):c===V?V:c._src});h.forEach((c,u)=>{let p=h[u+1],d=h[u-1];c!==V||d===V||(d===void 0?p!==void 0&&p!==V?h[u+1]="(?:\\/|"+i+"\\/)?"+p:h[u]=i:p===void 0?h[u-1]=d+"(?:\\/|\\/"+i+")?":p!==V&&(h[u-1]=d+"(?:\\/|\\/"+i+"\\/)"+p,h[u+1]=V))});let f=h.filter(c=>c!==V);if(this.partial&&f.length>=1){let c=[];for(let u=1;u<=f.length;u++)c.push(f.slice(0,u).join("/"));return"(?:"+c.join("|")+")"}return f.join("/")}).join("|"),[n,a]=t.length>1?["(?:",")"]:["",""];o="^"+n+o+a+"$",this.partial&&(o="^(?:\\/|"+n+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...r].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,s=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&s)return!0;let i=this.options;this.isWindows&&(t=t.split("\\").join("/"));let r=this.slashSplit(t);this.debug(this.pattern,"split",r);let o=this.set;this.debug(this.pattern,"set",o);let n=r[r.length-1];if(!n)for(let a=r.length-2;!n&&a>=0;a--)n=r[a];for(let a=0;a<o.length;a++){let l=o[a],h=r;if(i.matchBase&&l.length===1&&(h=[n]),this.matchOne(h,l,s))return i.flipNegate?!0:!this.negate}return i.flipNegate?!1:this.negate}static defaults(t){return it.defaults(t).Minimatch}};it.AST=be;it.Minimatch=ne;it.escape=qr;it.unescape=oe;var Vr=parseInt(process.env.TSHY_VERBOSE||"0"),ci=[],D=(...e)=>{Vr>=1?console.error(...e):ci.push(e)},T=(...e)=>{Vr>=2?console.error(...e):ci.push(e)},ua=(...e)=>{Vr>=1&&console.log(...e)},$e=()=>{for(let e of ci)console.error(...e);ci.length=0};var _=(e,t)=>{D(E.red.bold(e)),t&&D(t.message),$e()};import{readFileSync as ap}from"fs";var sp=e=>Array.from(e).map(t=>"0x"+t.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")).join(""),ip=(e,t,s)=>{if(!t)return{message:e.message+" while parsing empty string",position:0};let i=e.message.match(/^Unexpected (?:token (.*?))?/i),r=e.message.match(/at positions? (\d+)/),o=/^Unexpected end of JSON|Unterminated string in JSON/i.test(e.message)?t.length-1:r&&r[1]?+r[1]:/is not valid JSON$/.test(e.message)?0:null,n=i&&i[1]?e.message.replace(/^Unexpected token ./,`Unexpected token ${JSON.stringify(i[1])} (${sp(i[1])})`):e.message;if(o!=null){let a=o<=s?0:o-s,l=o+s>=t.length?t.length:o+s,h=(a===0?"":"...")+t.slice(a,l)+(l===t.length?"":"...");return{message:n+` while parsing ${t===h?"":"near "}${JSON.stringify(h)}`,position:o}}else return{message:n+` while parsing '${t.slice(0,s*2)}'`,position:0}},Jr=class extends SyntaxError{code;cause;position;constructor(t,s,i=20,r){let{message:o,position:n}=ip(t,s,i);super(o),this.cause=t,this.position=n,this.code="EJSONPARSE",Error.captureStackTrace(this,r||this.constructor)}get name(){return this.constructor.name}set name(t){}get[Symbol.toStringTag](){return this.constructor.name}},pa=Symbol.for("indent"),da=Symbol.for("newline"),rp=/^\s*[{\[]((?:\r?\n)+)([\s\t]*)/,op=/^(?:\{\}|\[\])((?:\r?\n)+)?$/,Kr=(e,t,s)=>{let i=np(String(e));t||(t=void 0),s=s||20;try{let[,r=`
7
7
  `,o=" "]=i.match(op)||i.match(rp)||[,"",""],n=JSON.parse(i,t);return n&&typeof n=="object"&&(n[da]=r,n[pa]=o),n}catch(r){if(typeof e!="string"&&!Buffer.isBuffer(e)){let o=Array.isArray(e)&&e.length===0;throw Object.assign(new TypeError(`Cannot parse ${o?"an empty array":String(e)}`),{code:"EJSONPARSE",systemError:r})}throw new Jr(r,i,s,Kr)}};var np=e=>String(e).replace(/^\uFEFF/,""),fi=(e,t,s)=>{let i=s===void 0?e[pa]:s,r=JSON.stringify(e,t,i),o=e[da]||`
8
8
  `;return i?(o===`
9
9
  `?r:r.split(`
10
- `).join(o))+o:r};var lp=e=>!!e&&typeof e=="object"&&!Array.isArray(e),hp=()=>{try{let e=Kr(ap("package.json","utf8"));if(lp(e))return Object.assign(e,{type:e.type==="commonjs"?"commonjs":"module"});throw new Error("Invalid package.json contents: "+fi(e))}catch(e){_("failed to read package.json",e),process.exit(1)}},k=hp();import{readdirSync as cp}from"fs";import{join as fp}from"path/posix";var ma=(e="src")=>{let t=[],s=cp(e,{withFileTypes:!0});for(let i of s){let r=`./${fp(e,i.name)}`;i.isFile()?t.push(r):i.isDirectory()&&t.push(...ma(r))}return t},up=new Set(ma()),Jt=up;var pp=e=>e==="commonjs"||e==="esm",ga=e=>e&&Array.isArray(e)&&e.length&&!e.some(t=>!pp(t))?!0:(_(`tshy.dialects must be an array including "esm" and/or "commonjs", got: ${JSON.stringify(e)}`),process.exit(1));var ya=e=>e&&Array.isArray(e)&&e.length&&!e.some(t=>typeof t!="string")?!0:(_(`tshy.exclude must be an array of string glob patterns if defined, got: ${JSON.stringify(e)}`),process.exit(1));import{join as dp}from"node:path/posix";var wa=e=>`./${dp(e)}`;import{join as ba}from"path/posix";var zt=(e,t)=>{if(typeof e=="string")return e;if(typeof e!="object")return;if(e===null)return e;if(Array.isArray(e)){for(let i of e){let r=zt(i,t);if(r||r===null)return r}return}let s=[...t,"default"];for(let[i,r]of Object.entries(e))if(s.includes(i)){let o=zt(r,t);if(o||o===null)return o}};var ui=e=>{let t=zt(e,["import"]),s=zt(e,["require"]);return!(t&&ba(t).startsWith("src/")||s&&ba(s).startsWith("src/"))};var mp=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Xr=e=>{if(!mp(e))return!1;for(let[t,s]of Object.entries(e)){if(t!=="."&&!t.startsWith("./"))return _(`tshy.exports key must be "." or start with "./", got: ${t}`),process.exit(1);if(typeof s=="string"){e[t]=wa(s);continue}if(typeof s!="object")return _(`tshy.exports ${t} value must be valid package.json exports value, got: ${JSON.stringify(s)}`),process.exit(1);if(!ui(s))return _(`tshy.exports ${t} unbuilt exports must not be in ./src, and exports in src must be string values. got: ${JSON.stringify(s)}`),process.exit(1);e[t]=s}return!0};import{readdirSync as gp}from"node:fs";var Sa=(e,t)=>{if(!e||!t)return!1;for(let s of e)if(t.includes(s))return s;return!1},Zr=(e,t)=>{let s=gp("src");for(let i of e){if(typeof i!="string")return _(`tshy.${t}Dialects must be an array of strings, got: ${i}`),process.exit(1);if(s.includes(i))return _(`tshy.${t}Dialects contains a src entry, not allowed: '${i}'`),process.exit(1);if(i.includes("/")||i.includes("\\"))return _(`tshy.${t}Dialects entries may not contain slashes: '${i}'`),process.exit(1);if(i==="commonjs"||i==="cjs"||i==="esm"||i==="require"||i==="import"||i==="source"||i==="types"||i==="default")return _(`tshy.${t}Dialects must not contain '${i}'`),process.exit(1)}return!0},va=({commonjsDialects:e,esmDialects:t,sourceDialects:s})=>{if(e===void 0&&t===void 0&&s===void 0)return!0;if(e&&!Zr(e,"commonjs")||t&&!Zr(t,"esm")||s&&!Zr(s,"source"))return!1;let i=Sa(s,e);if(i)return _(`tshy.commonjsDialects overlap with tshy.sourceDialects: ${i}`),process.exit(1);let r=Sa(s,t);return r?(_(`tshy.esmDialects overlap with tshy.sourceDialects: ${r}`),process.exit(1)):!0};var Ea=e=>{let{imports:t}=e;if(t===void 0)return!0;if(Array.isArray(t)||typeof t!="object")return _(`invalid imports object, must be Record<string, Import>, got: ${JSON.stringify(t)}`),process.exit(1);for(let[s,i]of Object.entries(t)){if(!s.startsWith("#")||s==="#"||s.startsWith("#/"))return _("invalid imports module specifier: "+s),process.exit(1);if(typeof i!="string"&&!ui(i))return _(`unbuilt package.imports ${s} must not be in ./src, and imports in ./src must be string values. got: `+JSON.stringify(i)),process.exit(1)}return!0};import{resolve as yp}from"path";import{readFileSync as wp}from"node:fs";var xa=e=>{if(typeof e=="string")try{return wp(yp(e),"utf8"),!0}catch{}return _(`tshy.project must point to a tsconfig file on disk, got: ${JSON.stringify(e)}`),process.exit(1)};var Ta=e=>e===void 0||e==="tsc"||e==="tsgo";var Qr=(e,t)=>{let s=e[t];return s===void 0||typeof s=="boolean"?!0:(_(`tshy.${t} must be a boolean value if specified, got: `+s),process.exit(1))},bp=e=>!!e&&Array.isArray(e)&&!e.some(t=>typeof t!="string"),Sp=e=>!!e&&typeof e=="object"&&!Array.isArray(e),vp=e=>Sp(e)&&(e.exports===void 0||typeof e.exports=="string"||bp(e.exports)||Xr(e.exports))&&(e.dialects===void 0||ga(e.dialects))&&(e.project===void 0||xa(e.project))&&(e.exclude===void 0||ya(e.exclude))&&va(e)&&Ta(e.compiler)&&Qr(e,"selfLink")&&Qr(e,"main")&&Qr(e,"liveDev"),Ep=(e,t)=>t.some(s=>s.match(e)),_a=e=>Array.isArray(e)?e.map(t=>new ne(t.replace(/^\.\//,""))):_a([e]),xp=(e,t)=>{let s=vp(e.tshy)?e.tshy:{},i=s.exports;if(typeof i=="string"||Array.isArray(i)){let n={},l=_a(i);for(let h of t){if(!Ep(h.replace(/^\.\//,""),l))continue;let f=/^\.\/src\/index.([mc]?[jt]s|[jt]sx)$/.test(h)?".":"./"+h.replace(/^\.\/src\//,"").replace(/\.([mc]?[tj]s|[jt]sx)$/,"");n[f]=`./${h}`}Xr(n)?(n["./package.json"]="./package.json",s.exports=n):(F("invalid exports pattern, using default exports"),delete s.exports,i=void 0)}let r={...s},o=r;if(o.imports&&(T(E.cyan.dim("imports")+" moving from tshy config to top level"),e.imports={...e.imports,...o.imports},delete o.imports),Ea(e),!i){let n={"./package.json":"./package.json"};for(let a of t)if(/^\.\/src\/index\.[^.]+$/.test(a)){n["."]=a;break}r.exports=n,s.exports=n,i=n}return e.tshy={...s,exports:i},r},Tp=xp(k,Jt),O=Tp;import{fileURLToPath as Od}from"node:url";import{posix as jd,win32 as ho}from"node:path";import{fileURLToPath as Pd}from"node:url";import{lstatSync as Nd,readdir as Fd,readdirSync as Dd,readlinkSync as Md,realpathSync as $d}from"fs";import*as Ld from"node:fs";import{lstat as Wd,readdir as Id,readlink as Ud,realpath as zd}from"node:fs/promises";import{EventEmitter as uo}from"node:events";import hl from"node:stream";import{StringDecoder as Bd}from"node:string_decoder";var Va=(e,t,s)=>{let i=e instanceof RegExp?ka(e,s):e,r=t instanceof RegExp?ka(t,s):t,o=i!==null&&r!=null&&_p(i,r,s);return o&&{start:o[0],end:o[1],pre:s.slice(0,o[0]),body:s.slice(o[0]+i.length,o[1]),post:s.slice(o[1]+r.length)}},ka=(e,t)=>{let s=t.match(e);return s?s[0]:null},_p=(e,t,s)=>{let i,r,o,n,a,l=s.indexOf(e),h=s.indexOf(t,l+1),f=l;if(l>=0&&h>0){if(e===t)return[l,h];for(i=[],o=s.length;f>=0&&!a;){if(f===l)i.push(f),l=s.indexOf(e,f+1);else if(i.length===1){let c=i.pop();c!==void 0&&(a=[c,h])}else r=i.pop(),r!==void 0&&r<o&&(o=r,n=h),h=s.indexOf(t,f+1);f=l<h&&l>=0?l:h}i.length&&n!==void 0&&(a=[o,n])}return a},Ja="\0SLASH"+Math.random()+"\0",Ka="\0OPEN"+Math.random()+"\0",co="\0CLOSE"+Math.random()+"\0",Xa="\0COMMA"+Math.random()+"\0",Za="\0PERIOD"+Math.random()+"\0",kp=new RegExp(Ja,"g"),Op=new RegExp(Ka,"g"),Rp=new RegExp(co,"g"),Ap=new RegExp(Xa,"g"),Cp=new RegExp(Za,"g"),jp=/\\\\/g,Pp=/\\{/g,Np=/\\}/g,Fp=/\\,/g,Dp=/\\./g,Mp=1e5;function to(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function $p(e){return e.replace(jp,Ja).replace(Pp,Ka).replace(Np,co).replace(Fp,Xa).replace(Dp,Za)}function Lp(e){return e.replace(kp,"\\").replace(Op,"{").replace(Rp,"}").replace(Ap,",").replace(Cp,".")}function Qa(e){if(!e)return[""];let t=[],s=Va("{","}",e);if(!s)return e.split(",");let{pre:i,body:r,post:o}=s,n=i.split(",");n[n.length-1]+="{"+r+"}";let a=Qa(o);return o.length&&(n[n.length-1]+=a.shift(),n.push.apply(n,a)),t.push.apply(t,n),t}function Wp(e,t={}){if(!e)return[];let{max:s=Mp}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),xs($p(e),s,!0).map(Lp)}function Ip(e){return"{"+e+"}"}function Up(e){return/^-?0\d/.test(e)}function zp(e,t){return e<=t}function Bp(e,t){return e>=t}function xs(e,t,s){let i=[],r=Va("{","}",e);if(!r)return[e];let o=r.pre,n=r.post.length?xs(r.post,t,!1):[""];if(/\$$/.test(r.pre))for(let a=0;a<n.length&&a<t;a++){let l=o+"{"+r.body+"}"+n[a];i.push(l)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(r.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(r.body),h=a||l,f=r.body.indexOf(",")>=0;if(!h&&!f)return r.post.match(/,(?!,).*\}/)?(e=r.pre+"{"+r.body+co+r.post,xs(e,t,!0)):[e];let c;if(h)c=r.body.split(/\.\./);else if(c=Qa(r.body),c.length===1&&c[0]!==void 0&&(c=xs(c[0],t,!1).map(Ip),c.length===1))return n.map(p=>r.pre+c[0]+p);let u;if(h&&c[0]!==void 0&&c[1]!==void 0){let p=to(c[0]),d=to(c[1]),m=Math.max(c[0].length,c[1].length),y=c.length===3&&c[2]!==void 0?Math.abs(to(c[2])):1,g=zp;d<p&&(y*=-1,g=Bp);let w=c.some(Up);u=[];for(let S=p;g(S,d);S+=y){let b;if(l)b=String.fromCharCode(S),b==="\\"&&(b="");else if(b=String(S),w){let v=m-b.length;if(v>0){let R=new Array(v+1).join("0");S<0?b="-"+R+b.slice(1):b=R+b}}u.push(b)}}else{u=[];for(let p=0;p<c.length;p++)u.push.apply(u,xs(c[p],t,!1))}for(let p=0;p<u.length;p++)for(let d=0;d<n.length&&i.length<t;d++){let m=o+u[p]+n[d];(!s||h||m)&&i.push(m)}}return i}var xi=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},Gp={"[: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]},ys=e=>e.replace(/[[\]\\-]/g,"\\$&"),Hp=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Oa=e=>e.join(""),Yp=(e,t)=>{let s=t;if(e.charAt(s)!=="[")throw new Error("not in a brace expression");let i=[],r=[],o=s+1,n=!1,a=!1,l=!1,h=!1,f=s,c="";t:for(;o<e.length;){let d=e.charAt(o);if((d==="!"||d==="^")&&o===s+1){h=!0,o++;continue}if(d==="]"&&n&&!l){f=o+1;break}if(n=!0,d==="\\"&&!l){l=!0,o++;continue}if(d==="["&&!l){for(let[m,[y,g,w]]of Object.entries(Gp))if(e.startsWith(m,o)){if(c)return["$.",!1,e.length-s,!0];o+=m.length,w?r.push(y):i.push(y),a=a||g;continue t}}if(l=!1,c){d>c?i.push(ys(c)+"-"+ys(d)):d===c&&i.push(ys(d)),c="",o++;continue}if(e.startsWith("-]",o+1)){i.push(ys(d+"-")),o+=2;continue}if(e.startsWith("-",o+1)){c=d,o+=2;continue}i.push(ys(d)),o++}if(f<o)return["",!1,0,!1];if(!i.length&&!r.length)return["$.",!1,e.length-s,!0];if(r.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!h){let d=i[0].length===2?i[0].slice(-1):i[0];return[Hp(d),!1,f-s,!1]}let u="["+(h?"^":"")+Oa(i)+"]",p="["+(h?"":"^")+Oa(r)+"]";return[i.length&&r.length?"("+u+"|"+p+")":i.length?u:p,a,f-s,!0]},We=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!0}={})=>s?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),qp=new Set(["!","?","+","*","@"]),Ra=e=>qp.has(e),Vp="(?!(?:^|/)\\.\\.?(?:$|/))",pi="(?!\\.)",Jp=new Set(["[","."]),Kp=new Set(["..","."]),Xp=new Set("().*{}+?[]^$\\!"),Zp=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),fo="[^/]",Aa=fo+"*?",Ca=fo+"+?",tl=class yt{type;#t;#r;#n=!1;#s=[];#o;#_;#x;#f=!1;#a;#p;#c=!1;constructor(t,s,i={}){this.type=t,t&&(this.#r=!0),this.#o=s,this.#t=this.#o?this.#o.#t:this,this.#a=this.#t===this?i:this.#t.#a,this.#x=this.#t===this?[]:this.#t.#x,t==="!"&&!this.#t.#f&&this.#x.push(this),this.#_=this.#o?this.#o.#s.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let t of this.#s)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#p!==void 0?this.#p:this.type?this.#p=this.type+"("+this.#s.map(t=>String(t)).join("|")+")":this.#p=this.#s.map(t=>String(t)).join("")}#l(){if(this!==this.#t)throw new Error("should only call on root");if(this.#f)return this;this.toString(),this.#f=!0;let t;for(;t=this.#x.pop();){if(t.type!=="!")continue;let s=t,i=s.#o;for(;i;){for(let r=s.#_+1;!i.type&&r<i.#s.length;r++)for(let o of t.#s){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(i.#s[r])}s=i,i=s.#o}}return this}push(...t){for(let s of t)if(s!==""){if(typeof s!="string"&&!(s instanceof yt&&s.#o===this))throw new Error("invalid part: "+s);this.#s.push(s)}}toJSON(){let t=this.type===null?this.#s.slice().map(s=>typeof s=="string"?s:s.toJSON()):[this.type,...this.#s.map(s=>s.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#f&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#o?.isStart())return!1;if(this.#_===0)return!0;let t=this.#o;for(let s=0;s<this.#_;s++){let i=t.#s[s];if(!(i instanceof yt&&i.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#s.length:0;return this.#_===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let s=new yt(this.type,t);for(let i of this.#s)s.copyIn(i);return s}static#i(t,s,i,r){let o=!1,n=!1,a=-1,l=!1;if(s.type===null){let p=i,d="";for(;p<t.length;){let m=t.charAt(p++);if(o||m==="\\"){o=!o,d+=m;continue}if(n){p===a+1?(m==="^"||m==="!")&&(l=!0):m==="]"&&!(p===a+2&&l)&&(n=!1),d+=m;continue}else if(m==="["){n=!0,a=p,l=!1,d+=m;continue}if(!r.noext&&Ra(m)&&t.charAt(p)==="("){s.push(d),d="";let y=new yt(m,s);p=yt.#i(t,y,p,r),s.push(y);continue}d+=m}return s.push(d),p}let h=i+1,f=new yt(null,s),c=[],u="";for(;h<t.length;){let p=t.charAt(h++);if(o||p==="\\"){o=!o,u+=p;continue}if(n){h===a+1?(p==="^"||p==="!")&&(l=!0):p==="]"&&!(h===a+2&&l)&&(n=!1),u+=p;continue}else if(p==="["){n=!0,a=h,l=!1,u+=p;continue}if(Ra(p)&&t.charAt(h)==="("){f.push(u),u="";let d=new yt(p,f);f.push(d),h=yt.#i(t,d,h,r);continue}if(p==="|"){f.push(u),u="",c.push(f),f=new yt(null,s);continue}if(p===")")return u===""&&s.#s.length===0&&(s.#c=!0),f.push(u),u="",s.push(...c,f),h;u+=p}return s.type=null,s.#r=void 0,s.#s=[t.substring(i-1)],h}static fromGlob(t,s={}){let i=new yt(null,void 0,s);return yt.#i(t,i,0,s),i}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let t=this.toString(),[s,i,r,o]=this.toRegExpSource();if(!(r||this.#r||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let n=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${s}$`,n),{_src:s,_glob:t})}get options(){return this.#a}toRegExpSource(t){let s=t??!!this.#a.dot;if(this.#t===this&&this.#l(),!this.type){let l=this.isStart()&&this.isEnd()&&!this.#s.some(u=>typeof u!="string"),h=this.#s.map(u=>{let[p,d,m,y]=typeof u=="string"?yt.#S(u,this.#r,l):u.toRegExpSource(t);return this.#r=this.#r||m,this.#n=this.#n||y,p}).join(""),f="";if(this.isStart()&&typeof this.#s[0]=="string"&&!(this.#s.length===1&&Kp.has(this.#s[0]))){let u=Jp,p=s&&u.has(h.charAt(0))||h.startsWith("\\.")&&u.has(h.charAt(2))||h.startsWith("\\.\\.")&&u.has(h.charAt(4)),d=!s&&!t&&u.has(h.charAt(0));f=p?Vp:d?pi:""}let c="";return this.isEnd()&&this.#t.#f&&this.#o?.type==="!"&&(c="(?:$|\\/)"),[f+h+c,We(h),this.#r=!!this.#r,this.#n]}let i=this.type==="*"||this.type==="+",r=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#w(s);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString();return this.#s=[l],this.type=null,this.#r=void 0,[l,We(this.toString()),!1,!1]}let n=!i||t||s||!pi?"":this.#w(!0);n===o&&(n=""),n&&(o=`(?:${o})(?:${n})*?`);let a="";if(this.type==="!"&&this.#c)a=(this.isStart()&&!s?pi:"")+Ca;else{let l=this.type==="!"?"))"+(this.isStart()&&!s&&!t?pi:"")+Aa+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&n?")":this.type==="*"&&n?")?":`)${this.type}`;a=r+o+l}return[a,We(o),this.#r=!!this.#r,this.#n]}#w(t){return this.#s.map(s=>{if(typeof s=="string")throw new Error("string type in extglob ast??");let[i,r,o,n]=s.toRegExpSource(t);return this.#n=this.#n||n,i}).filter(s=>!(this.isStart()&&this.isEnd())||!!s).join("|")}static#S(t,s,i=!1){let r=!1,o="",n=!1,a=!1;for(let l=0;l<t.length;l++){let h=t.charAt(l);if(r){r=!1,o+=(Xp.has(h)?"\\":"")+h;continue}if(h==="*"){if(a)continue;a=!0,o+=i&&/^[*]+$/.test(t)?Ca:Aa,s=!0;continue}else a=!1;if(h==="\\"){l===t.length-1?o+="\\\\":r=!0;continue}if(h==="["){let[f,c,u,p]=Yp(t,l);if(u){o+=f,n=n||c,l+=u-1,s=s||p;continue}}if(h==="?"){o+=fo,s=!0;continue}o+=Zp(h)}return[o,We(t),!!s,n]}},Rs=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!1}={})=>s?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),nt=(e,t,s={})=>(xi(t),!s.nocomment&&t.charAt(0)==="#"?!1:new he(t,s).match(e)),Qp=/^\*+([^+@!?\*\[\(]*)$/,td=e=>t=>!t.startsWith(".")&&t.endsWith(e),ed=e=>t=>t.endsWith(e),sd=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),id=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),rd=/^\*+\.\*+$/,od=e=>!e.startsWith(".")&&e.includes("."),nd=e=>e!=="."&&e!==".."&&e.includes("."),ad=/^\.\*+$/,ld=e=>e!=="."&&e!==".."&&e.startsWith("."),hd=/^\*+$/,cd=e=>e.length!==0&&!e.startsWith("."),fd=e=>e.length!==0&&e!=="."&&e!=="..",ud=/^\?+([^+@!?\*\[\(]*)?$/,pd=([e,t=""])=>{let s=el([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},dd=([e,t=""])=>{let s=sl([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},md=([e,t=""])=>{let s=sl([e]);return t?i=>s(i)&&i.endsWith(t):s},gd=([e,t=""])=>{let s=el([e]);return t?i=>s(i)&&i.endsWith(t):s},el=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},sl=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},il=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",ja={win32:{sep:"\\"},posix:{sep:"/"}},yd=il==="win32"?ja.win32.sep:ja.posix.sep;nt.sep=yd;var ot=Symbol("globstar **");nt.GLOBSTAR=ot;var wd="[^/]",bd=wd+"*?",Sd="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",vd="(?:(?!(?:\\/|^)\\.).)*?",Ed=(e,t={})=>s=>nt(s,e,t);nt.filter=Ed;var xt=(e,t={})=>Object.assign({},e,t),xd=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return nt;let t=nt;return Object.assign((s,i,r={})=>t(s,i,xt(e,r)),{Minimatch:class extends t.Minimatch{constructor(s,i={}){super(s,xt(e,i))}static defaults(s){return t.defaults(xt(e,s)).Minimatch}},AST:class extends t.AST{constructor(s,i,r={}){super(s,i,xt(e,r))}static fromGlob(s,i={}){return t.AST.fromGlob(s,xt(e,i))}},unescape:(s,i={})=>t.unescape(s,xt(e,i)),escape:(s,i={})=>t.escape(s,xt(e,i)),filter:(s,i={})=>t.filter(s,xt(e,i)),defaults:s=>t.defaults(xt(e,s)),makeRe:(s,i={})=>t.makeRe(s,xt(e,i)),braceExpand:(s,i={})=>t.braceExpand(s,xt(e,i)),match:(s,i,r={})=>t.match(s,i,xt(e,r)),sep:t.sep,GLOBSTAR:ot})};nt.defaults=xd;var rl=(e,t={})=>(xi(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Wp(e,{max:t.braceExpandMax}));nt.braceExpand=rl;var Td=(e,t={})=>new he(e,t).makeRe();nt.makeRe=Td;var _d=(e,t,s={})=>{let i=new he(t,s);return e=e.filter(r=>i.match(r)),i.options.nonull&&!e.length&&e.push(t),e};nt.match=_d;var Pa=/[?*]|[+@!]\(.*?\)|\[|\]/,kd=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),he=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(e,t={}){xi(e),t=t||{},this.options=t,this.pattern=e,this.platform=t.platform||il,this.isWindows=this.platform==="win32";let s="allowWindowsEscape";this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t[s]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.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 e of this.set)for(let t of e)if(typeof t!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...r)=>console.error(...r)),this.debug(this.pattern,this.globSet);let s=this.globSet.map(r=>this.slashSplit(r));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let i=this.globParts.map((r,o,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let a=r[0]===""&&r[1]===""&&(r[2]==="?"||!Pa.test(r[2]))&&!Pa.test(r[3]),l=/^[a-z]:/i.test(r[0]);if(a)return[...r.slice(0,4),...r.slice(4).map(h=>this.parse(h))];if(l)return[r[0],...r.slice(1).map(h=>this.parse(h))]}return r.map(a=>this.parse(a))});if(this.debug(this.pattern,i),this.set=i.filter(r=>r.indexOf(!1)===-1),this.isWindows)for(let r=0;r<this.set.length;r++){let o=this.set[r];o[0]===""&&o[1]===""&&this.globParts[r][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let s=0;s<e.length;s++)for(let i=0;i<e[s].length;i++)e[s][i]==="**"&&(e[s][i]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):t>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(t=>{let s=-1;for(;(s=t.indexOf("**",s+1))!==-1;){let i=s;for(;t[i+1]==="**";)i++;i!==s&&t.splice(s,i-s)}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((s,i)=>{let r=s[s.length-1];return i==="**"&&r==="**"?s:i===".."&&r&&r!==".."&&r!=="."&&r!=="**"?(s.pop(),s):(s.push(i),s)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let r=e[i];i===1&&r===""&&e[0]===""||(r==="."||r==="")&&(t=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(t=!0,e.pop())}let s=0;for(;(s=e.indexOf("..",s+1))!==-1;){let i=e[s-1];i&&i!=="."&&i!==".."&&i!=="**"&&(t=!0,e.splice(s-1,2),s-=2)}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let s of e){let i=-1;for(;(i=s.indexOf("**",i+1))!==-1;){let o=i;for(;s[o+1]==="**";)o++;o>i&&s.splice(i+1,o-i);let n=s[i+1],a=s[i+2],l=s[i+3];if(n!==".."||!a||a==="."||a===".."||!l||l==="."||l==="..")continue;t=!0,s.splice(i,1);let h=s.slice(0);h[i]="**",e.push(h),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<s.length-1;o++){let n=s[o];o===1&&n===""&&s[0]===""||(n==="."||n==="")&&(t=!0,s.splice(o,1),o--)}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(t=!0,s.pop())}let r=0;for(;(r=s.indexOf("..",r+1))!==-1;){let o=s[r-1];if(o&&o!=="."&&o!==".."&&o!=="**"){t=!0;let n=r===1&&s[r+1]==="**"?["."]:[];s.splice(r-1,2,...n),s.length===0&&s.push(""),r-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let s=t+1;s<e.length;s++){let i=this.partsMatch(e[t],e[s],!this.preserveMultipleSlashes);if(i){e[t]=[],e[s]=i;break}}return e.filter(t=>t.length)}partsMatch(e,t,s=!1){let i=0,r=0,o=[],n="";for(;i<e.length&&r<t.length;)if(e[i]===t[r])o.push(n==="b"?t[r]:e[i]),i++,r++;else if(s&&e[i]==="**"&&t[r]===e[i+1])o.push(e[i]),i++;else if(s&&t[r]==="**"&&e[i]===t[r+1])o.push(t[r]),r++;else if(e[i]==="*"&&t[r]&&(this.options.dot||!t[r].startsWith("."))&&t[r]!=="**"){if(n==="b")return!1;n="a",o.push(e[i]),i++,r++}else if(t[r]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(n==="a")return!1;n="b",o.push(t[r]),i++,r++}else return!1;return e.length===t.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,s=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)t=!t,s++;s&&(this.pattern=e.slice(s)),this.negate=t}matchOne(e,t,s=!1){let i=this.options;if(this.isWindows){let d=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),m=!d&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),y=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),g=!y&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),w=m?3:d?0:void 0,S=g?3:y?0:void 0;if(typeof w=="number"&&typeof S=="number"){let[b,v]=[e[w],t[S]];b.toLowerCase()===v.toLowerCase()&&(t[S]=b,S>w?t=t.slice(S):w>S&&(e=e.slice(w)))}}let{optimizationLevel:r=1}=this.options;r>=2&&(e=this.levelTwoFileOptimize(e)),this.debug("matchOne",this,{file:e,pattern:t}),this.debug("matchOne",e.length,t.length);for(var o=0,n=0,a=e.length,l=t.length;o<a&&n<l;o++,n++){this.debug("matchOne loop");var h=t[n],f=e[o];if(this.debug(t,h,f),h===!1)return!1;if(h===ot){this.debug("GLOBSTAR",[t,h,f]);var c=o,u=n+1;if(u===l){for(this.debug("** at the end");o<a;o++)if(e[o]==="."||e[o]===".."||!i.dot&&e[o].charAt(0)===".")return!1;return!0}for(;c<a;){var p=e[c];if(this.debug(`
10
+ `).join(o))+o:r};var lp=e=>!!e&&typeof e=="object"&&!Array.isArray(e),hp=()=>{try{let e=Kr(ap("package.json","utf8"));if(lp(e))return Object.assign(e,{type:e.type==="commonjs"?"commonjs":"module"});throw new Error("Invalid package.json contents: "+fi(e))}catch(e){_("failed to read package.json",e),process.exit(1)}},k=hp();import{readdirSync as cp}from"fs";import{join as fp}from"path/posix";var ma=(e="src")=>{let t=[],s=cp(e,{withFileTypes:!0});for(let i of s){let r=`./${fp(e,i.name)}`;i.isFile()?t.push(r):i.isDirectory()&&t.push(...ma(r))}return t},up=new Set(ma()),Jt=up;var pp=e=>e==="commonjs"||e==="esm",ga=e=>e&&Array.isArray(e)&&e.length&&!e.some(t=>!pp(t))?!0:(_(`tshy.dialects must be an array including "esm" and/or "commonjs", got: ${JSON.stringify(e)}`),process.exit(1));var ya=e=>e&&Array.isArray(e)&&e.length&&!e.some(t=>typeof t!="string")?!0:(_(`tshy.exclude must be an array of string glob patterns if defined, got: ${JSON.stringify(e)}`),process.exit(1));import{join as dp}from"node:path/posix";var wa=e=>`./${dp(e)}`;import{join as ba}from"path/posix";var zt=(e,t)=>{if(typeof e=="string")return e;if(typeof e!="object")return;if(e===null)return e;if(Array.isArray(e)){for(let i of e){let r=zt(i,t);if(r||r===null)return r}return}let s=[...t,"default"];for(let[i,r]of Object.entries(e))if(s.includes(i)){let o=zt(r,t);if(o||o===null)return o}};var ui=e=>{let t=zt(e,["import"]),s=zt(e,["require"]);return!(t&&ba(t).startsWith("src/")||s&&ba(s).startsWith("src/"))};var mp=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Xr=e=>{if(!mp(e))return!1;for(let[t,s]of Object.entries(e)){if(t!=="."&&!t.startsWith("./"))return _(`tshy.exports key must be "." or start with "./", got: ${t}`),process.exit(1);if(typeof s=="string"){e[t]=wa(s);continue}if(typeof s!="object")return _(`tshy.exports ${t} value must be valid package.json exports value, got: ${JSON.stringify(s)}`),process.exit(1);if(!ui(s))return _(`tshy.exports ${t} unbuilt exports must not be in ./src, and exports in src must be string values. got: ${JSON.stringify(s)}`),process.exit(1);e[t]=s}return!0};import{readdirSync as gp}from"node:fs";var Sa=(e,t)=>{if(!e||!t)return!1;for(let s of e)if(t.includes(s))return s;return!1},Zr=(e,t)=>{let s=gp("src");for(let i of e){if(typeof i!="string")return _(`tshy.${t}Dialects must be an array of strings, got: ${i}`),process.exit(1);if(s.includes(i))return _(`tshy.${t}Dialects contains a src entry, not allowed: '${i}'`),process.exit(1);if(i.includes("/")||i.includes("\\"))return _(`tshy.${t}Dialects entries may not contain slashes: '${i}'`),process.exit(1);if(i==="commonjs"||i==="cjs"||i==="esm"||i==="require"||i==="import"||i==="source"||i==="types"||i==="default")return _(`tshy.${t}Dialects must not contain '${i}'`),process.exit(1)}return!0},va=({commonjsDialects:e,esmDialects:t,sourceDialects:s})=>{if(e===void 0&&t===void 0&&s===void 0)return!0;if(e&&!Zr(e,"commonjs")||t&&!Zr(t,"esm")||s&&!Zr(s,"source"))return!1;let i=Sa(s,e);if(i)return _(`tshy.commonjsDialects overlap with tshy.sourceDialects: ${i}`),process.exit(1);let r=Sa(s,t);return r?(_(`tshy.esmDialects overlap with tshy.sourceDialects: ${r}`),process.exit(1)):!0};var Ea=e=>{let{imports:t}=e;if(t===void 0)return!0;if(Array.isArray(t)||typeof t!="object")return _(`invalid imports object, must be Record<string, Import>, got: ${JSON.stringify(t)}`),process.exit(1);for(let[s,i]of Object.entries(t)){if(!s.startsWith("#")||s==="#"||s.startsWith("#/"))return _("invalid imports module specifier: "+s),process.exit(1);if(typeof i!="string"&&!ui(i))return _(`unbuilt package.imports ${s} must not be in ./src, and imports in ./src must be string values. got: `+JSON.stringify(i)),process.exit(1)}return!0};import{resolve as yp}from"path";import{readFileSync as wp}from"node:fs";var xa=e=>{if(typeof e=="string")try{return wp(yp(e),"utf8"),!0}catch{}return _(`tshy.project must point to a tsconfig file on disk, got: ${JSON.stringify(e)}`),process.exit(1)};var Ta=e=>e===void 0||e==="tsc"||e==="tsgo";var Qr=(e,t)=>{let s=e[t];return s===void 0||typeof s=="boolean"?!0:(_(`tshy.${t} must be a boolean value if specified, got: `+s),process.exit(1))},bp=e=>!!e&&Array.isArray(e)&&!e.some(t=>typeof t!="string"),Sp=e=>!!e&&typeof e=="object"&&!Array.isArray(e),vp=e=>Sp(e)&&(e.exports===void 0||typeof e.exports=="string"||bp(e.exports)||Xr(e.exports))&&(e.dialects===void 0||ga(e.dialects))&&(e.project===void 0||xa(e.project))&&(e.exclude===void 0||ya(e.exclude))&&va(e)&&Ta(e.compiler)&&Qr(e,"selfLink")&&Qr(e,"main")&&Qr(e,"liveDev"),Ep=(e,t)=>t.some(s=>s.match(e)),_a=e=>Array.isArray(e)?e.map(t=>new ne(t.replace(/^\.\//,""))):_a([e]),xp=(e,t)=>{let s=vp(e.tshy)?e.tshy:{},i=s.exports;if(typeof i=="string"||Array.isArray(i)){let n={},l=_a(i);for(let h of t){if(!Ep(h.replace(/^\.\//,""),l))continue;let f=/^\.\/src\/index.([mc]?[jt]s|[jt]sx)$/.test(h)?".":"./"+h.replace(/^\.\/src\//,"").replace(/\.([mc]?[tj]s|[jt]sx)$/,"");n[f]=`./${h}`}Xr(n)?(n["./package.json"]="./package.json",s.exports=n):(D("invalid exports pattern, using default exports"),delete s.exports,i=void 0)}let r={...s},o=r;if(o.imports&&(T(E.cyan.dim("imports")+" moving from tshy config to top level"),e.imports={...e.imports,...o.imports},delete o.imports),Ea(e),!i){let n={"./package.json":"./package.json"};for(let a of t)if(/^\.\/src\/index\.[^.]+$/.test(a)){n["."]=a;break}r.exports=n,s.exports=n,i=n}return e.tshy={...s,exports:i},r},Tp=xp(k,Jt),O=Tp;import{fileURLToPath as Od}from"node:url";import{posix as Cd,win32 as ho}from"node:path";import{fileURLToPath as Pd}from"node:url";import{lstatSync as Nd,readdir as Fd,readdirSync as Dd,readlinkSync as $d,realpathSync as Md}from"fs";import*as Ld from"node:fs";import{lstat as Wd,readdir as Id,readlink as Ud,realpath as zd}from"node:fs/promises";import{EventEmitter as uo}from"node:events";import hl from"node:stream";import{StringDecoder as Bd}from"node:string_decoder";var Va=(e,t,s)=>{let i=e instanceof RegExp?ka(e,s):e,r=t instanceof RegExp?ka(t,s):t,o=i!==null&&r!=null&&_p(i,r,s);return o&&{start:o[0],end:o[1],pre:s.slice(0,o[0]),body:s.slice(o[0]+i.length,o[1]),post:s.slice(o[1]+r.length)}},ka=(e,t)=>{let s=t.match(e);return s?s[0]:null},_p=(e,t,s)=>{let i,r,o,n,a,l=s.indexOf(e),h=s.indexOf(t,l+1),f=l;if(l>=0&&h>0){if(e===t)return[l,h];for(i=[],o=s.length;f>=0&&!a;){if(f===l)i.push(f),l=s.indexOf(e,f+1);else if(i.length===1){let c=i.pop();c!==void 0&&(a=[c,h])}else r=i.pop(),r!==void 0&&r<o&&(o=r,n=h),h=s.indexOf(t,f+1);f=l<h&&l>=0?l:h}i.length&&n!==void 0&&(a=[o,n])}return a},Ja="\0SLASH"+Math.random()+"\0",Ka="\0OPEN"+Math.random()+"\0",co="\0CLOSE"+Math.random()+"\0",Xa="\0COMMA"+Math.random()+"\0",Za="\0PERIOD"+Math.random()+"\0",kp=new RegExp(Ja,"g"),Op=new RegExp(Ka,"g"),Rp=new RegExp(co,"g"),Ap=new RegExp(Xa,"g"),jp=new RegExp(Za,"g"),Cp=/\\\\/g,Pp=/\\{/g,Np=/\\}/g,Fp=/\\,/g,Dp=/\\./g,$p=1e5;function to(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Mp(e){return e.replace(Cp,Ja).replace(Pp,Ka).replace(Np,co).replace(Fp,Xa).replace(Dp,Za)}function Lp(e){return e.replace(kp,"\\").replace(Op,"{").replace(Rp,"}").replace(Ap,",").replace(jp,".")}function Qa(e){if(!e)return[""];let t=[],s=Va("{","}",e);if(!s)return e.split(",");let{pre:i,body:r,post:o}=s,n=i.split(",");n[n.length-1]+="{"+r+"}";let a=Qa(o);return o.length&&(n[n.length-1]+=a.shift(),n.push.apply(n,a)),t.push.apply(t,n),t}function Wp(e,t={}){if(!e)return[];let{max:s=$p}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),xs(Mp(e),s,!0).map(Lp)}function Ip(e){return"{"+e+"}"}function Up(e){return/^-?0\d/.test(e)}function zp(e,t){return e<=t}function Bp(e,t){return e>=t}function xs(e,t,s){let i=[],r=Va("{","}",e);if(!r)return[e];let o=r.pre,n=r.post.length?xs(r.post,t,!1):[""];if(/\$$/.test(r.pre))for(let a=0;a<n.length&&a<t;a++){let l=o+"{"+r.body+"}"+n[a];i.push(l)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(r.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(r.body),h=a||l,f=r.body.indexOf(",")>=0;if(!h&&!f)return r.post.match(/,(?!,).*\}/)?(e=r.pre+"{"+r.body+co+r.post,xs(e,t,!0)):[e];let c;if(h)c=r.body.split(/\.\./);else if(c=Qa(r.body),c.length===1&&c[0]!==void 0&&(c=xs(c[0],t,!1).map(Ip),c.length===1))return n.map(p=>r.pre+c[0]+p);let u;if(h&&c[0]!==void 0&&c[1]!==void 0){let p=to(c[0]),d=to(c[1]),m=Math.max(c[0].length,c[1].length),y=c.length===3&&c[2]!==void 0?Math.abs(to(c[2])):1,g=zp;d<p&&(y*=-1,g=Bp);let w=c.some(Up);u=[];for(let S=p;g(S,d);S+=y){let b;if(l)b=String.fromCharCode(S),b==="\\"&&(b="");else if(b=String(S),w){let v=m-b.length;if(v>0){let R=new Array(v+1).join("0");S<0?b="-"+R+b.slice(1):b=R+b}}u.push(b)}}else{u=[];for(let p=0;p<c.length;p++)u.push.apply(u,xs(c[p],t,!1))}for(let p=0;p<u.length;p++)for(let d=0;d<n.length&&i.length<t;d++){let m=o+u[p]+n[d];(!s||h||m)&&i.push(m)}}return i}var xi=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},Gp={"[: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]},ys=e=>e.replace(/[[\]\\-]/g,"\\$&"),Hp=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Oa=e=>e.join(""),Yp=(e,t)=>{let s=t;if(e.charAt(s)!=="[")throw new Error("not in a brace expression");let i=[],r=[],o=s+1,n=!1,a=!1,l=!1,h=!1,f=s,c="";t:for(;o<e.length;){let d=e.charAt(o);if((d==="!"||d==="^")&&o===s+1){h=!0,o++;continue}if(d==="]"&&n&&!l){f=o+1;break}if(n=!0,d==="\\"&&!l){l=!0,o++;continue}if(d==="["&&!l){for(let[m,[y,g,w]]of Object.entries(Gp))if(e.startsWith(m,o)){if(c)return["$.",!1,e.length-s,!0];o+=m.length,w?r.push(y):i.push(y),a=a||g;continue t}}if(l=!1,c){d>c?i.push(ys(c)+"-"+ys(d)):d===c&&i.push(ys(d)),c="",o++;continue}if(e.startsWith("-]",o+1)){i.push(ys(d+"-")),o+=2;continue}if(e.startsWith("-",o+1)){c=d,o+=2;continue}i.push(ys(d)),o++}if(f<o)return["",!1,0,!1];if(!i.length&&!r.length)return["$.",!1,e.length-s,!0];if(r.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!h){let d=i[0].length===2?i[0].slice(-1):i[0];return[Hp(d),!1,f-s,!1]}let u="["+(h?"^":"")+Oa(i)+"]",p="["+(h?"":"^")+Oa(r)+"]";return[i.length&&r.length?"("+u+"|"+p+")":i.length?u:p,a,f-s,!0]},We=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!0}={})=>s?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),qp=new Set(["!","?","+","*","@"]),Ra=e=>qp.has(e),Vp="(?!(?:^|/)\\.\\.?(?:$|/))",pi="(?!\\.)",Jp=new Set(["[","."]),Kp=new Set(["..","."]),Xp=new Set("().*{}+?[]^$\\!"),Zp=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),fo="[^/]",Aa=fo+"*?",ja=fo+"+?",tl=class yt{type;#t;#r;#n=!1;#s=[];#o;#_;#x;#f=!1;#a;#p;#c=!1;constructor(t,s,i={}){this.type=t,t&&(this.#r=!0),this.#o=s,this.#t=this.#o?this.#o.#t:this,this.#a=this.#t===this?i:this.#t.#a,this.#x=this.#t===this?[]:this.#t.#x,t==="!"&&!this.#t.#f&&this.#x.push(this),this.#_=this.#o?this.#o.#s.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let t of this.#s)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#p!==void 0?this.#p:this.type?this.#p=this.type+"("+this.#s.map(t=>String(t)).join("|")+")":this.#p=this.#s.map(t=>String(t)).join("")}#l(){if(this!==this.#t)throw new Error("should only call on root");if(this.#f)return this;this.toString(),this.#f=!0;let t;for(;t=this.#x.pop();){if(t.type!=="!")continue;let s=t,i=s.#o;for(;i;){for(let r=s.#_+1;!i.type&&r<i.#s.length;r++)for(let o of t.#s){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(i.#s[r])}s=i,i=s.#o}}return this}push(...t){for(let s of t)if(s!==""){if(typeof s!="string"&&!(s instanceof yt&&s.#o===this))throw new Error("invalid part: "+s);this.#s.push(s)}}toJSON(){let t=this.type===null?this.#s.slice().map(s=>typeof s=="string"?s:s.toJSON()):[this.type,...this.#s.map(s=>s.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#f&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#o?.isStart())return!1;if(this.#_===0)return!0;let t=this.#o;for(let s=0;s<this.#_;s++){let i=t.#s[s];if(!(i instanceof yt&&i.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#s.length:0;return this.#_===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let s=new yt(this.type,t);for(let i of this.#s)s.copyIn(i);return s}static#i(t,s,i,r){let o=!1,n=!1,a=-1,l=!1;if(s.type===null){let p=i,d="";for(;p<t.length;){let m=t.charAt(p++);if(o||m==="\\"){o=!o,d+=m;continue}if(n){p===a+1?(m==="^"||m==="!")&&(l=!0):m==="]"&&!(p===a+2&&l)&&(n=!1),d+=m;continue}else if(m==="["){n=!0,a=p,l=!1,d+=m;continue}if(!r.noext&&Ra(m)&&t.charAt(p)==="("){s.push(d),d="";let y=new yt(m,s);p=yt.#i(t,y,p,r),s.push(y);continue}d+=m}return s.push(d),p}let h=i+1,f=new yt(null,s),c=[],u="";for(;h<t.length;){let p=t.charAt(h++);if(o||p==="\\"){o=!o,u+=p;continue}if(n){h===a+1?(p==="^"||p==="!")&&(l=!0):p==="]"&&!(h===a+2&&l)&&(n=!1),u+=p;continue}else if(p==="["){n=!0,a=h,l=!1,u+=p;continue}if(Ra(p)&&t.charAt(h)==="("){f.push(u),u="";let d=new yt(p,f);f.push(d),h=yt.#i(t,d,h,r);continue}if(p==="|"){f.push(u),u="",c.push(f),f=new yt(null,s);continue}if(p===")")return u===""&&s.#s.length===0&&(s.#c=!0),f.push(u),u="",s.push(...c,f),h;u+=p}return s.type=null,s.#r=void 0,s.#s=[t.substring(i-1)],h}static fromGlob(t,s={}){let i=new yt(null,void 0,s);return yt.#i(t,i,0,s),i}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let t=this.toString(),[s,i,r,o]=this.toRegExpSource();if(!(r||this.#r||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let n=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${s}$`,n),{_src:s,_glob:t})}get options(){return this.#a}toRegExpSource(t){let s=t??!!this.#a.dot;if(this.#t===this&&this.#l(),!this.type){let l=this.isStart()&&this.isEnd()&&!this.#s.some(u=>typeof u!="string"),h=this.#s.map(u=>{let[p,d,m,y]=typeof u=="string"?yt.#S(u,this.#r,l):u.toRegExpSource(t);return this.#r=this.#r||m,this.#n=this.#n||y,p}).join(""),f="";if(this.isStart()&&typeof this.#s[0]=="string"&&!(this.#s.length===1&&Kp.has(this.#s[0]))){let u=Jp,p=s&&u.has(h.charAt(0))||h.startsWith("\\.")&&u.has(h.charAt(2))||h.startsWith("\\.\\.")&&u.has(h.charAt(4)),d=!s&&!t&&u.has(h.charAt(0));f=p?Vp:d?pi:""}let c="";return this.isEnd()&&this.#t.#f&&this.#o?.type==="!"&&(c="(?:$|\\/)"),[f+h+c,We(h),this.#r=!!this.#r,this.#n]}let i=this.type==="*"||this.type==="+",r=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#w(s);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString();return this.#s=[l],this.type=null,this.#r=void 0,[l,We(this.toString()),!1,!1]}let n=!i||t||s||!pi?"":this.#w(!0);n===o&&(n=""),n&&(o=`(?:${o})(?:${n})*?`);let a="";if(this.type==="!"&&this.#c)a=(this.isStart()&&!s?pi:"")+ja;else{let l=this.type==="!"?"))"+(this.isStart()&&!s&&!t?pi:"")+Aa+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&n?")":this.type==="*"&&n?")?":`)${this.type}`;a=r+o+l}return[a,We(o),this.#r=!!this.#r,this.#n]}#w(t){return this.#s.map(s=>{if(typeof s=="string")throw new Error("string type in extglob ast??");let[i,r,o,n]=s.toRegExpSource(t);return this.#n=this.#n||n,i}).filter(s=>!(this.isStart()&&this.isEnd())||!!s).join("|")}static#S(t,s,i=!1){let r=!1,o="",n=!1,a=!1;for(let l=0;l<t.length;l++){let h=t.charAt(l);if(r){r=!1,o+=(Xp.has(h)?"\\":"")+h;continue}if(h==="*"){if(a)continue;a=!0,o+=i&&/^[*]+$/.test(t)?ja:Aa,s=!0;continue}else a=!1;if(h==="\\"){l===t.length-1?o+="\\\\":r=!0;continue}if(h==="["){let[f,c,u,p]=Yp(t,l);if(u){o+=f,n=n||c,l+=u-1,s=s||p;continue}}if(h==="?"){o+=fo,s=!0;continue}o+=Zp(h)}return[o,We(t),!!s,n]}},Rs=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!1}={})=>s?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),nt=(e,t,s={})=>(xi(t),!s.nocomment&&t.charAt(0)==="#"?!1:new he(t,s).match(e)),Qp=/^\*+([^+@!?\*\[\(]*)$/,td=e=>t=>!t.startsWith(".")&&t.endsWith(e),ed=e=>t=>t.endsWith(e),sd=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),id=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),rd=/^\*+\.\*+$/,od=e=>!e.startsWith(".")&&e.includes("."),nd=e=>e!=="."&&e!==".."&&e.includes("."),ad=/^\.\*+$/,ld=e=>e!=="."&&e!==".."&&e.startsWith("."),hd=/^\*+$/,cd=e=>e.length!==0&&!e.startsWith("."),fd=e=>e.length!==0&&e!=="."&&e!=="..",ud=/^\?+([^+@!?\*\[\(]*)?$/,pd=([e,t=""])=>{let s=el([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},dd=([e,t=""])=>{let s=sl([e]);return t?(t=t.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(t)):s},md=([e,t=""])=>{let s=sl([e]);return t?i=>s(i)&&i.endsWith(t):s},gd=([e,t=""])=>{let s=el([e]);return t?i=>s(i)&&i.endsWith(t):s},el=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},sl=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},il=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Ca={win32:{sep:"\\"},posix:{sep:"/"}},yd=il==="win32"?Ca.win32.sep:Ca.posix.sep;nt.sep=yd;var ot=Symbol("globstar **");nt.GLOBSTAR=ot;var wd="[^/]",bd=wd+"*?",Sd="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",vd="(?:(?!(?:\\/|^)\\.).)*?",Ed=(e,t={})=>s=>nt(s,e,t);nt.filter=Ed;var xt=(e,t={})=>Object.assign({},e,t),xd=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return nt;let t=nt;return Object.assign((s,i,r={})=>t(s,i,xt(e,r)),{Minimatch:class extends t.Minimatch{constructor(s,i={}){super(s,xt(e,i))}static defaults(s){return t.defaults(xt(e,s)).Minimatch}},AST:class extends t.AST{constructor(s,i,r={}){super(s,i,xt(e,r))}static fromGlob(s,i={}){return t.AST.fromGlob(s,xt(e,i))}},unescape:(s,i={})=>t.unescape(s,xt(e,i)),escape:(s,i={})=>t.escape(s,xt(e,i)),filter:(s,i={})=>t.filter(s,xt(e,i)),defaults:s=>t.defaults(xt(e,s)),makeRe:(s,i={})=>t.makeRe(s,xt(e,i)),braceExpand:(s,i={})=>t.braceExpand(s,xt(e,i)),match:(s,i,r={})=>t.match(s,i,xt(e,r)),sep:t.sep,GLOBSTAR:ot})};nt.defaults=xd;var rl=(e,t={})=>(xi(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Wp(e,{max:t.braceExpandMax}));nt.braceExpand=rl;var Td=(e,t={})=>new he(e,t).makeRe();nt.makeRe=Td;var _d=(e,t,s={})=>{let i=new he(t,s);return e=e.filter(r=>i.match(r)),i.options.nonull&&!e.length&&e.push(t),e};nt.match=_d;var Pa=/[?*]|[+@!]\(.*?\)|\[|\]/,kd=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),he=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(e,t={}){xi(e),t=t||{},this.options=t,this.pattern=e,this.platform=t.platform||il,this.isWindows=this.platform==="win32";let s="allowWindowsEscape";this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t[s]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.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 e of this.set)for(let t of e)if(typeof t!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...r)=>console.error(...r)),this.debug(this.pattern,this.globSet);let s=this.globSet.map(r=>this.slashSplit(r));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let i=this.globParts.map((r,o,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let a=r[0]===""&&r[1]===""&&(r[2]==="?"||!Pa.test(r[2]))&&!Pa.test(r[3]),l=/^[a-z]:/i.test(r[0]);if(a)return[...r.slice(0,4),...r.slice(4).map(h=>this.parse(h))];if(l)return[r[0],...r.slice(1).map(h=>this.parse(h))]}return r.map(a=>this.parse(a))});if(this.debug(this.pattern,i),this.set=i.filter(r=>r.indexOf(!1)===-1),this.isWindows)for(let r=0;r<this.set.length;r++){let o=this.set[r];o[0]===""&&o[1]===""&&this.globParts[r][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let s=0;s<e.length;s++)for(let i=0;i<e[s].length;i++)e[s][i]==="**"&&(e[s][i]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):t>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(t=>{let s=-1;for(;(s=t.indexOf("**",s+1))!==-1;){let i=s;for(;t[i+1]==="**";)i++;i!==s&&t.splice(s,i-s)}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((s,i)=>{let r=s[s.length-1];return i==="**"&&r==="**"?s:i===".."&&r&&r!==".."&&r!=="."&&r!=="**"?(s.pop(),s):(s.push(i),s)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let r=e[i];i===1&&r===""&&e[0]===""||(r==="."||r==="")&&(t=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(t=!0,e.pop())}let s=0;for(;(s=e.indexOf("..",s+1))!==-1;){let i=e[s-1];i&&i!=="."&&i!==".."&&i!=="**"&&(t=!0,e.splice(s-1,2),s-=2)}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let s of e){let i=-1;for(;(i=s.indexOf("**",i+1))!==-1;){let o=i;for(;s[o+1]==="**";)o++;o>i&&s.splice(i+1,o-i);let n=s[i+1],a=s[i+2],l=s[i+3];if(n!==".."||!a||a==="."||a===".."||!l||l==="."||l==="..")continue;t=!0,s.splice(i,1);let h=s.slice(0);h[i]="**",e.push(h),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<s.length-1;o++){let n=s[o];o===1&&n===""&&s[0]===""||(n==="."||n==="")&&(t=!0,s.splice(o,1),o--)}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(t=!0,s.pop())}let r=0;for(;(r=s.indexOf("..",r+1))!==-1;){let o=s[r-1];if(o&&o!=="."&&o!==".."&&o!=="**"){t=!0;let n=r===1&&s[r+1]==="**"?["."]:[];s.splice(r-1,2,...n),s.length===0&&s.push(""),r-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let s=t+1;s<e.length;s++){let i=this.partsMatch(e[t],e[s],!this.preserveMultipleSlashes);if(i){e[t]=[],e[s]=i;break}}return e.filter(t=>t.length)}partsMatch(e,t,s=!1){let i=0,r=0,o=[],n="";for(;i<e.length&&r<t.length;)if(e[i]===t[r])o.push(n==="b"?t[r]:e[i]),i++,r++;else if(s&&e[i]==="**"&&t[r]===e[i+1])o.push(e[i]),i++;else if(s&&t[r]==="**"&&e[i]===t[r+1])o.push(t[r]),r++;else if(e[i]==="*"&&t[r]&&(this.options.dot||!t[r].startsWith("."))&&t[r]!=="**"){if(n==="b")return!1;n="a",o.push(e[i]),i++,r++}else if(t[r]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(n==="a")return!1;n="b",o.push(t[r]),i++,r++}else return!1;return e.length===t.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,s=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)t=!t,s++;s&&(this.pattern=e.slice(s)),this.negate=t}matchOne(e,t,s=!1){let i=this.options;if(this.isWindows){let d=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),m=!d&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),y=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),g=!y&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),w=m?3:d?0:void 0,S=g?3:y?0:void 0;if(typeof w=="number"&&typeof S=="number"){let[b,v]=[e[w],t[S]];b.toLowerCase()===v.toLowerCase()&&(t[S]=b,S>w?t=t.slice(S):w>S&&(e=e.slice(w)))}}let{optimizationLevel:r=1}=this.options;r>=2&&(e=this.levelTwoFileOptimize(e)),this.debug("matchOne",this,{file:e,pattern:t}),this.debug("matchOne",e.length,t.length);for(var o=0,n=0,a=e.length,l=t.length;o<a&&n<l;o++,n++){this.debug("matchOne loop");var h=t[n],f=e[o];if(this.debug(t,h,f),h===!1)return!1;if(h===ot){this.debug("GLOBSTAR",[t,h,f]);var c=o,u=n+1;if(u===l){for(this.debug("** at the end");o<a;o++)if(e[o]==="."||e[o]===".."||!i.dot&&e[o].charAt(0)===".")return!1;return!0}for(;c<a;){var p=e[c];if(this.debug(`
11
11
  globstar while`,e,c,t,u,p),this.matchOne(e.slice(c),t.slice(u),s))return this.debug("globstar found match!",c,a,p),!0;if(p==="."||p===".."||!i.dot&&p.charAt(0)==="."){this.debug("dot detected!",e,c,t,u);break}this.debug("globstar swallow a segment, and continue"),c++}return!!(s&&(this.debug(`
12
- >>> no match, partial?`,e,c,t,u),c===a))}let d;if(typeof h=="string"?(d=f===h,this.debug("string match",h,f,d)):(d=h.test(f),this.debug("pattern match",h,f,d)),!d)return!1}if(o===a&&n===l)return!0;if(o===a)return s;if(n===l)return o===a-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return rl(this.pattern,this.options)}parse(e){xi(e);let t=this.options;if(e==="**")return ot;if(e==="")return"";let s,i=null;(s=e.match(hd))?i=t.dot?fd:cd:(s=e.match(Qp))?i=(t.nocase?t.dot?id:sd:t.dot?ed:td)(s[1]):(s=e.match(ud))?i=(t.nocase?t.dot?dd:pd:t.dot?md:gd)(s):(s=e.match(rd))?i=t.dot?nd:od:(s=e.match(ad))&&(i=ld);let r=tl.fromGlob(e,this.options).toMMPattern();return i&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:i}),r}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,s=t.noglobstar?bd:t.dot?Sd:vd,i=new Set(t.nocase?["i"]:[]),r=e.map(a=>{let l=a.map(f=>{if(f instanceof RegExp)for(let c of f.flags.split(""))i.add(c);return typeof f=="string"?kd(f):f===ot?ot:f._src});l.forEach((f,c)=>{let u=l[c+1],p=l[c-1];f!==ot||p===ot||(p===void 0?u!==void 0&&u!==ot?l[c+1]="(?:\\/|"+s+"\\/)?"+u:l[c]=s:u===void 0?l[c-1]=p+"(?:\\/|\\/"+s+")?":u!==ot&&(l[c-1]=p+"(?:\\/|\\/"+s+"\\/)"+u,l[c+1]=ot))});let h=l.filter(f=>f!==ot);if(this.partial&&h.length>=1){let f=[];for(let c=1;c<=h.length;c++)f.push(h.slice(0,c).join("/"));return"(?:"+f.join("|")+")"}return h.join("/")}).join("|"),[o,n]=e.length>1?["(?:",")"]:["",""];r="^"+o+r+n+"$",this.partial&&(r="^(?:\\/|"+o+r.slice(1,-1)+n+")$"),this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&t)return!0;let s=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let r=this.set;this.debug(this.pattern,"set",r);let o=i[i.length-1];if(!o)for(let n=i.length-2;!o&&n>=0;n--)o=i[n];for(let n=0;n<r.length;n++){let a=r[n],l=i;if(s.matchBase&&a.length===1&&(l=[o]),this.matchOne(l,a,t))return s.flipNegate?!0:!this.negate}return s.flipNegate?!1:this.negate}static defaults(e){return nt.defaults(e).Minimatch}};nt.AST=tl;nt.Minimatch=he;nt.escape=Rs;nt.unescape=We;var Rd=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ol=new Set,lo=typeof process=="object"&&process?process:{},nl=(e,t,s,i)=>{typeof lo.emitWarning=="function"?lo.emitWarning(e,t,s,i):console.error(`[${s}] ${t}: ${e}`)},Ti=globalThis.AbortController,Na=globalThis.AbortSignal;if(typeof Ti>"u"){Na=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,i){this._onabort.push(i)}},Ti=class{constructor(){t()}signal=new Na;abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=!0;for(let i of this.signal._onabort)i(s);this.signal.onabort?.(s)}}};let e=lo.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,nl("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",t))}}var Ad=e=>!ol.has(e),le=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),al=e=>le(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?vi:null:null,vi=class extends Array{constructor(e){super(e),this.fill(0)}},Cd=class Ts{heap;length;static#t=!1;static create(t){let s=al(t);if(!s)return[];Ts.#t=!0;let i=new Ts(t,s);return Ts.#t=!1,i}constructor(t,s){if(!Ts.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new s(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},ki=class ll{#t;#r;#n;#s;#o;#_;#x;#f;get perf(){return this.#f}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#p;#c;#l;#i;#w;#S;#y;#d;#k;#m;#v;#T;#u;#g;#b;#O;#e;#F;static unsafeExposeInternals(t){return{starts:t.#T,ttls:t.#u,autopurgeTimers:t.#g,sizes:t.#v,keyMap:t.#c,keyList:t.#l,valList:t.#i,next:t.#w,prev:t.#S,get head(){return t.#y},get tail(){return t.#d},free:t.#k,isBackgroundFetch:s=>t.#h(s),backgroundFetch:(s,i,r,o)=>t.#z(s,i,r,o),moveToTail:s=>t.#M(s),indexes:s=>t.#C(s),rindexes:s=>t.#j(s),isStale:s=>t.#E(s)}}get max(){return this.#t}get maxSize(){return this.#r}get calculatedSize(){return this.#p}get size(){return this.#a}get fetchMethod(){return this.#_}get memoMethod(){return this.#x}get dispose(){return this.#n}get onInsert(){return this.#s}get disposeAfter(){return this.#o}constructor(t){let{max:s=0,ttl:i,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:l,dispose:h,onInsert:f,disposeAfter:c,noDisposeOnSet:u,noUpdateTTL:p,maxSize:d=0,maxEntrySize:m=0,sizeCalculation:y,fetchMethod:g,memoMethod:w,noDeleteOnFetchRejection:S,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:R,ignoreFetchAbort:$,perf:q}=t;if(q!==void 0&&typeof q?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#f=q??Rd,s!==0&&!le(s))throw new TypeError("max option must be a nonnegative integer");let st=s?al(s):Array;if(!st)throw new Error("invalid max value: "+s);if(this.#t=s,this.#r=d,this.maxEntrySize=m||this.#r,this.sizeCalculation=y,this.sizeCalculation){if(!this.#r&&!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(w!==void 0&&typeof w!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#x=w,g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#_=g,this.#O=!!g,this.#c=new Map,this.#l=new Array(s).fill(void 0),this.#i=new Array(s).fill(void 0),this.#w=new st(s),this.#S=new st(s),this.#y=0,this.#d=0,this.#k=Cd.create(s),this.#a=0,this.#p=0,typeof h=="function"&&(this.#n=h),typeof f=="function"&&(this.#s=f),typeof c=="function"?(this.#o=c,this.#m=[]):(this.#o=void 0,this.#m=void 0),this.#b=!!this.#n,this.#F=!!this.#s,this.#e=!!this.#o,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!p,this.noDeleteOnFetchRejection=!!S,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!R,this.ignoreFetchAbort=!!$,this.maxEntrySize!==0){if(this.#r!==0&&!le(this.#r))throw new TypeError("maxSize must be a positive integer if specified");if(!le(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#G()}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=le(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=i||0,this.ttl){if(!le(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#P()}if(this.#t===0&&this.ttl===0&&this.#r===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#r){let Vt="LRU_CACHE_UNBOUNDED";Ad(Vt)&&(ol.add(Vt),nl("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Vt,ll))}}getRemainingTTL(t){return this.#c.has(t)?1/0:0}#P(){let t=new vi(this.#t),s=new vi(this.#t);this.#u=t,this.#T=s;let i=this.ttlAutopurge?new Array(this.#t):void 0;this.#g=i,this.#L=(n,a,l=this.#f.now())=>{if(s[n]=a!==0?l:0,t[n]=a,i?.[n]&&(clearTimeout(i[n]),i[n]=void 0),a!==0&&i){let h=setTimeout(()=>{this.#E(n)&&this.#A(this.#l[n],"expire")},a+1);h.unref&&h.unref(),i[n]=h}},this.#R=n=>{s[n]=t[n]!==0?this.#f.now():0},this.#N=(n,a)=>{if(t[a]){let l=t[a],h=s[a];if(!l||!h)return;n.ttl=l,n.start=h,n.now=r||o();let f=n.now-h;n.remainingTTL=l-f}};let r=0,o=()=>{let n=this.#f.now();if(this.ttlResolution>0){r=n;let a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref()}return n};this.getRemainingTTL=n=>{let a=this.#c.get(n);if(a===void 0)return 0;let l=t[a],h=s[a];if(!l||!h)return 1/0;let f=(r||o())-h;return l-f},this.#E=n=>{let a=s[n],l=t[n];return!!l&&!!a&&(r||o())-a>l}}#R=()=>{};#N=()=>{};#L=()=>{};#E=()=>!1;#G(){let t=new vi(this.#t);this.#p=0,this.#v=t,this.#$=s=>{this.#p-=t[s],t[s]=0},this.#W=(s,i,r,o)=>{if(this.#h(i))return 0;if(!le(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(i,s),!le(r))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 r},this.#D=(s,i,r)=>{if(t[s]=i,this.#r){let o=this.#r-t[s];for(;this.#p>o;)this.#U(!0)}this.#p+=t[s],r&&(r.entrySize=i,r.totalCalculatedSize=this.#p)}}#$=t=>{};#D=(t,s,i)=>{};#W=(t,s,i,r)=>{if(i||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#C({allowStale:t=this.allowStale}={}){if(this.#a)for(let s=this.#d;!(!this.#I(s)||((t||!this.#E(s))&&(yield s),s===this.#y));)s=this.#S[s]}*#j({allowStale:t=this.allowStale}={}){if(this.#a)for(let s=this.#y;!(!this.#I(s)||((t||!this.#E(s))&&(yield s),s===this.#d));)s=this.#w[s]}#I(t){return t!==void 0&&this.#c.get(this.#l[t])===t}*entries(){for(let t of this.#C())this.#i[t]!==void 0&&this.#l[t]!==void 0&&!this.#h(this.#i[t])&&(yield[this.#l[t],this.#i[t]])}*rentries(){for(let t of this.#j())this.#i[t]!==void 0&&this.#l[t]!==void 0&&!this.#h(this.#i[t])&&(yield[this.#l[t],this.#i[t]])}*keys(){for(let t of this.#C()){let s=this.#l[t];s!==void 0&&!this.#h(this.#i[t])&&(yield s)}}*rkeys(){for(let t of this.#j()){let s=this.#l[t];s!==void 0&&!this.#h(this.#i[t])&&(yield s)}}*values(){for(let t of this.#C())this.#i[t]!==void 0&&!this.#h(this.#i[t])&&(yield this.#i[t])}*rvalues(){for(let t of this.#j())this.#i[t]!==void 0&&!this.#h(this.#i[t])&&(yield this.#i[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,s={}){for(let i of this.#C()){let r=this.#i[i],o=this.#h(r)?r.__staleWhileFetching:r;if(o!==void 0&&t(o,this.#l[i],this))return this.get(this.#l[i],s)}}forEach(t,s=this){for(let i of this.#C()){let r=this.#i[i],o=this.#h(r)?r.__staleWhileFetching:r;o!==void 0&&t.call(s,o,this.#l[i],this)}}rforEach(t,s=this){for(let i of this.#j()){let r=this.#i[i],o=this.#h(r)?r.__staleWhileFetching:r;o!==void 0&&t.call(s,o,this.#l[i],this)}}purgeStale(){let t=!1;for(let s of this.#j({allowStale:!0}))this.#E(s)&&(this.#A(this.#l[s],"expire"),t=!0);return t}info(t){let s=this.#c.get(t);if(s===void 0)return;let i=this.#i[s],r=this.#h(i)?i.__staleWhileFetching:i;if(r===void 0)return;let o={value:r};if(this.#u&&this.#T){let n=this.#u[s],a=this.#T[s];if(n&&a){let l=n-(this.#f.now()-a);o.ttl=l,o.start=Date.now()}}return this.#v&&(o.size=this.#v[s]),o}dump(){let t=[];for(let s of this.#C({allowStale:!0})){let i=this.#l[s],r=this.#i[s],o=this.#h(r)?r.__staleWhileFetching:r;if(o===void 0||i===void 0)continue;let n={value:o};if(this.#u&&this.#T){n.ttl=this.#u[s];let a=this.#f.now()-this.#T[s];n.start=Math.floor(Date.now()-a)}this.#v&&(n.size=this.#v[s]),t.unshift([i,n])}return t}load(t){this.clear();for(let[s,i]of t){if(i.start){let r=Date.now()-i.start;i.start=this.#f.now()-r}this.set(s,i.value,i)}}set(t,s,i={}){if(s===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:l}=i,{noUpdateTTL:h=this.noUpdateTTL}=i,f=this.#W(t,s,i.size||0,a);if(this.maxEntrySize&&f>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.#A(t,"set"),this;let c=this.#a===0?void 0:this.#c.get(t);if(c===void 0)c=this.#a===0?this.#d:this.#k.length!==0?this.#k.pop():this.#a===this.#t?this.#U(!1):this.#a,this.#l[c]=t,this.#i[c]=s,this.#c.set(t,c),this.#w[this.#d]=c,this.#S[c]=this.#d,this.#d=c,this.#a++,this.#D(c,f,l),l&&(l.set="add"),h=!1,this.#F&&this.#s?.(s,t,"add");else{this.#M(c);let u=this.#i[c];if(s!==u){if(this.#O&&this.#h(u)){u.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=u;p!==void 0&&!n&&(this.#b&&this.#n?.(p,t,"set"),this.#e&&this.#m?.push([p,t,"set"]))}else n||(this.#b&&this.#n?.(u,t,"set"),this.#e&&this.#m?.push([u,t,"set"]));if(this.#$(c),this.#D(c,f,l),this.#i[c]=s,l){l.set="replace";let p=u&&this.#h(u)?u.__staleWhileFetching:u;p!==void 0&&(l.oldValue=p)}}else l&&(l.set="update");this.#F&&this.onInsert?.(s,t,s===u?"update":"replace")}if(r!==0&&!this.#u&&this.#P(),this.#u&&(h||this.#L(c,r,o),l&&this.#N(l,c)),!n&&this.#e&&this.#m){let u=this.#m,p;for(;p=u?.shift();)this.#o?.(...p)}return this}pop(){try{for(;this.#a;){let t=this.#i[this.#y];if(this.#U(!0),this.#h(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#e&&this.#m){let t=this.#m,s;for(;s=t?.shift();)this.#o?.(...s)}}}#U(t){let s=this.#y,i=this.#l[s],r=this.#i[s];return this.#O&&this.#h(r)?r.__abortController.abort(new Error("evicted")):(this.#b||this.#e)&&(this.#b&&this.#n?.(r,i,"evict"),this.#e&&this.#m?.push([r,i,"evict"])),this.#$(s),this.#g?.[s]&&(clearTimeout(this.#g[s]),this.#g[s]=void 0),t&&(this.#l[s]=void 0,this.#i[s]=void 0,this.#k.push(s)),this.#a===1?(this.#y=this.#d=0,this.#k.length=0):this.#y=this.#w[s],this.#c.delete(i),this.#a--,s}has(t,s={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:r}=s,o=this.#c.get(t);if(o!==void 0){let n=this.#i[o];if(this.#h(n)&&n.__staleWhileFetching===void 0)return!1;if(this.#E(o))r&&(r.has="stale",this.#N(r,o));else return i&&this.#R(o),r&&(r.has="hit",this.#N(r,o)),!0}else r&&(r.has="miss");return!1}peek(t,s={}){let{allowStale:i=this.allowStale}=s,r=this.#c.get(t);if(r===void 0||!i&&this.#E(r))return;let o=this.#i[r];return this.#h(o)?o.__staleWhileFetching:o}#z(t,s,i,r){let o=s===void 0?void 0:this.#i[s];if(this.#h(o))return o;let n=new Ti,{signal:a}=i;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let l={signal:n.signal,options:i,context:r},h=(m,y=!1)=>{let{aborted:g}=n.signal,w=i.ignoreFetchAbort&&m!==void 0,S=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&m!==void 0);if(i.status&&(g&&!y?(i.status.fetchAborted=!0,i.status.fetchError=n.signal.reason,w&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),g&&!w&&!y)return c(n.signal.reason,S);let b=p,v=this.#i[s];return(v===p||w&&y&&v===void 0)&&(m===void 0?b.__staleWhileFetching!==void 0?this.#i[s]=b.__staleWhileFetching:this.#A(t,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.set(t,m,l.options))),m},f=m=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=m),c(m,!1)),c=(m,y)=>{let{aborted:g}=n.signal,w=g&&i.allowStaleOnFetchAbort,S=w||i.allowStaleOnFetchRejection,b=S||i.noDeleteOnFetchRejection,v=p;if(this.#i[s]===p&&(!b||!y&&v.__staleWhileFetching===void 0?this.#A(t,"fetch"):w||(this.#i[s]=v.__staleWhileFetching)),S)return i.status&&v.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),v.__staleWhileFetching;if(v.__returned===v)throw m},u=(m,y)=>{let g=this.#_?.(t,o,l);g&&g instanceof Promise&&g.then(w=>m(w===void 0?void 0:w),y),n.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(m(void 0),i.allowStaleOnFetchAbort&&(m=w=>h(w,!0)))})};i.status&&(i.status.fetchDispatched=!0);let p=new Promise(u).then(h,f),d=Object.assign(p,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return s===void 0?(this.set(t,d,{...l.options,status:void 0}),s=this.#c.get(t)):this.#i[s]=d,d}#h(t){if(!this.#O)return!1;let s=t;return!!s&&s instanceof Promise&&s.hasOwnProperty("__staleWhileFetching")&&s.__abortController instanceof Ti}async fetch(t,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:l=0,sizeCalculation:h=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:c=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:d=this.allowStaleOnFetchAbort,context:m,forceRefresh:y=!1,status:g,signal:w}=s;if(!this.#O)return g&&(g.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:g});let S={allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:l,sizeCalculation:h,noUpdateTTL:f,noDeleteOnFetchRejection:c,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:d,ignoreFetchAbort:p,status:g,signal:w},b=this.#c.get(t);if(b===void 0){g&&(g.fetch="miss");let v=this.#z(t,b,S,m);return v.__returned=v}else{let v=this.#i[b];if(this.#h(v)){let st=i&&v.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",st&&(g.returnedStale=!0)),st?v.__staleWhileFetching:v.__returned=v}let R=this.#E(b);if(!y&&!R)return g&&(g.fetch="hit"),this.#M(b),r&&this.#R(b),g&&this.#N(g,b),v;let $=this.#z(t,b,S,m),q=$.__staleWhileFetching!==void 0&&i;return g&&(g.fetch=R?"stale":"refresh",q&&R&&(g.returnedStale=!0)),q?$.__staleWhileFetching:$.__returned=$}}async forceFetch(t,s={}){let i=await this.fetch(t,s);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,s={}){let i=this.#x;if(!i)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=s,a=this.get(t,n);if(!o&&a!==void 0)return a;let l=i(t,a,{options:n,context:r});return this.set(t,l,n),l}get(t,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=s,a=this.#c.get(t);if(a!==void 0){let l=this.#i[a],h=this.#h(l);return n&&this.#N(n,a),this.#E(a)?(n&&(n.get="stale"),h?(n&&i&&l.__staleWhileFetching!==void 0&&(n.returnedStale=!0),i?l.__staleWhileFetching:void 0):(o||this.#A(t,"expire"),n&&i&&(n.returnedStale=!0),i?l:void 0)):(n&&(n.get="hit"),h?l.__staleWhileFetching:(this.#M(a),r&&this.#R(a),l))}else n&&(n.get="miss")}#B(t,s){this.#S[s]=t,this.#w[t]=s}#M(t){t!==this.#d&&(t===this.#y?this.#y=this.#w[t]:this.#B(this.#S[t],this.#w[t]),this.#B(this.#d,t),this.#d=t)}delete(t){return this.#A(t,"delete")}#A(t,s){let i=!1;if(this.#a!==0){let r=this.#c.get(t);if(r!==void 0)if(this.#g?.[r]&&(clearTimeout(this.#g?.[r]),this.#g[r]=void 0),i=!0,this.#a===1)this.#H(s);else{this.#$(r);let o=this.#i[r];if(this.#h(o)?o.__abortController.abort(new Error("deleted")):(this.#b||this.#e)&&(this.#b&&this.#n?.(o,t,s),this.#e&&this.#m?.push([o,t,s])),this.#c.delete(t),this.#l[r]=void 0,this.#i[r]=void 0,r===this.#d)this.#d=this.#S[r];else if(r===this.#y)this.#y=this.#w[r];else{let n=this.#S[r];this.#w[n]=this.#w[r];let a=this.#w[r];this.#S[a]=this.#S[r]}this.#a--,this.#k.push(r)}}if(this.#e&&this.#m?.length){let r=this.#m,o;for(;o=r?.shift();)this.#o?.(...o)}return i}clear(){return this.#H("delete")}#H(t){for(let s of this.#j({allowStale:!0})){let i=this.#i[s];if(this.#h(i))i.__abortController.abort(new Error("deleted"));else{let r=this.#l[s];this.#b&&this.#n?.(i,r,t),this.#e&&this.#m?.push([i,r,t])}}if(this.#c.clear(),this.#i.fill(void 0),this.#l.fill(void 0),this.#u&&this.#T){this.#u.fill(0),this.#T.fill(0);for(let s of this.#g??[])s!==void 0&&clearTimeout(s);this.#g?.fill(void 0)}if(this.#v&&this.#v.fill(0),this.#y=0,this.#d=0,this.#k.length=0,this.#p=0,this.#a=0,this.#e&&this.#m){let s=this.#m,i;for(;i=s?.shift();)this.#o?.(...i)}}},Fa=typeof process=="object"&&process?process:{stdout:null,stderr:null},Gd=e=>!!e&&typeof e=="object"&&(e instanceof _i||e instanceof hl||Hd(e)||Yd(e)),Hd=e=>!!e&&typeof e=="object"&&e instanceof uo&&typeof e.pipe=="function"&&e.pipe!==hl.Writable.prototype.pipe,Yd=e=>!!e&&typeof e=="object"&&e instanceof uo&&typeof e.write=="function"&&typeof e.end=="function",Kt=Symbol("EOF"),Xt=Symbol("maybeEmitEnd"),ae=Symbol("emittedEnd"),di=Symbol("emittingEnd"),ws=Symbol("emittedError"),mi=Symbol("closed"),Da=Symbol("read"),gi=Symbol("flush"),Ma=Symbol("flushChunk"),Nt=Symbol("encoding"),$e=Symbol("decoder"),I=Symbol("flowing"),bs=Symbol("paused"),Le=Symbol("resume"),U=Symbol("buffer"),rt=Symbol("pipes"),z=Symbol("bufferLength"),eo=Symbol("bufferPush"),yi=Symbol("bufferShift"),K=Symbol("objectMode"),D=Symbol("destroyed"),so=Symbol("error"),io=Symbol("emitData"),$a=Symbol("emitEnd"),ro=Symbol("emitEnd2"),Bt=Symbol("async"),oo=Symbol("abort"),wi=Symbol("aborted"),Ss=Symbol("signal"),Se=Symbol("dataListeners"),gt=Symbol("discarded"),vs=e=>Promise.resolve().then(e),qd=e=>e(),Vd=e=>e==="end"||e==="finish"||e==="prefinish",Jd=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,Kd=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),cl=class{src;dest;opts;ondrain;constructor(e,t,s){this.src=e,this.dest=t,this.opts=s,this.ondrain=()=>e[Le](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Xd=class extends cl{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,s){super(e,t,s),this.proxyErrors=i=>t.emit("error",i),e.on("error",this.proxyErrors)}},Zd=e=>!!e.objectMode,Qd=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",_i=class extends uo{[I]=!1;[bs]=!1;[rt]=[];[U]=[];[K];[Nt];[Bt];[$e];[Kt]=!1;[ae]=!1;[di]=!1;[mi]=!1;[ws]=null;[z]=0;[D]=!1;[Ss];[wi]=!1;[Se]=0;[gt]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Zd(t)?(this[K]=!0,this[Nt]=null):Qd(t)?(this[Nt]=t.encoding,this[K]=!1):(this[K]=!1,this[Nt]=null),this[Bt]=!!t.async,this[$e]=this[Nt]?new Bd(this[Nt]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[U]}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[rt]});let{signal:s}=t;s&&(this[Ss]=s,s.aborted?this[oo]():s.addEventListener("abort",()=>this[oo]()))}get bufferLength(){return this[z]}get encoding(){return this[Nt]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[K]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Bt]}set async(e){this[Bt]=this[Bt]||!!e}[oo](){this[wi]=!0,this.emit("abort",this[Ss]?.reason),this.destroy(this[Ss]?.reason)}get aborted(){return this[wi]}set aborted(e){}write(e,t,s){if(this[wi])return!1;if(this[Kt])throw new Error("write after end");if(this[D])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof t=="function"&&(s=t,t="utf8"),t||(t="utf8");let i=this[Bt]?vs:qd;if(!this[K]&&!Buffer.isBuffer(e)){if(Kd(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(Jd(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[K]?(this[I]&&this[z]!==0&&this[gi](!0),this[I]?this.emit("data",e):this[eo](e),this[z]!==0&&this.emit("readable"),s&&i(s),this[I]):e.length?(typeof e=="string"&&!(t===this[Nt]&&!this[$e]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[Nt]&&(e=this[$e].write(e)),this[I]&&this[z]!==0&&this[gi](!0),this[I]?this.emit("data",e):this[eo](e),this[z]!==0&&this.emit("readable"),s&&i(s),this[I]):(this[z]!==0&&this.emit("readable"),s&&i(s),this[I])}read(e){if(this[D])return null;if(this[gt]=!1,this[z]===0||e===0||e&&e>this[z])return this[Xt](),null;this[K]&&(e=null),this[U].length>1&&!this[K]&&(this[U]=[this[Nt]?this[U].join(""):Buffer.concat(this[U],this[z])]);let t=this[Da](e||null,this[U][0]);return this[Xt](),t}[Da](e,t){if(this[K])this[yi]();else{let s=t;e===s.length||e===null?this[yi]():typeof s=="string"?(this[U][0]=s.slice(e),t=s.slice(0,e),this[z]-=e):(this[U][0]=s.subarray(e),t=s.subarray(0,e),this[z]-=e)}return this.emit("data",t),!this[U].length&&!this[Kt]&&this.emit("drain"),t}end(e,t,s){return typeof e=="function"&&(s=e,e=void 0),typeof t=="function"&&(s=t,t="utf8"),e!==void 0&&this.write(e,t),s&&this.once("end",s),this[Kt]=!0,this.writable=!1,(this[I]||!this[bs])&&this[Xt](),this}[Le](){this[D]||(!this[Se]&&!this[rt].length&&(this[gt]=!0),this[bs]=!1,this[I]=!0,this.emit("resume"),this[U].length?this[gi]():this[Kt]?this[Xt]():this.emit("drain"))}resume(){return this[Le]()}pause(){this[I]=!1,this[bs]=!0,this[gt]=!1}get destroyed(){return this[D]}get flowing(){return this[I]}get paused(){return this[bs]}[eo](e){this[K]?this[z]+=1:this[z]+=e.length,this[U].push(e)}[yi](){return this[K]?this[z]-=1:this[z]-=this[U][0].length,this[U].shift()}[gi](e=!1){do;while(this[Ma](this[yi]())&&this[U].length);!e&&!this[U].length&&!this[Kt]&&this.emit("drain")}[Ma](e){return this.emit("data",e),this[I]}pipe(e,t){if(this[D])return e;this[gt]=!1;let s=this[ae];return t=t||{},e===Fa.stdout||e===Fa.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,s?t.end&&e.end():(this[rt].push(t.proxyErrors?new Xd(this,e,t):new cl(this,e,t)),this[Bt]?vs(()=>this[Le]()):this[Le]()),e}unpipe(e){let t=this[rt].find(s=>s.dest===e);t&&(this[rt].length===1?(this[I]&&this[Se]===0&&(this[I]=!1),this[rt]=[]):this[rt].splice(this[rt].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let s=super.on(e,t);if(e==="data")this[gt]=!1,this[Se]++,!this[rt].length&&!this[I]&&this[Le]();else if(e==="readable"&&this[z]!==0)super.emit("readable");else if(Vd(e)&&this[ae])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[ws]){let i=t;this[Bt]?vs(()=>i.call(this,this[ws])):i.call(this,this[ws])}return s}removeListener(e,t){return this.off(e,t)}off(e,t){let s=super.off(e,t);return e==="data"&&(this[Se]=this.listeners("data").length,this[Se]===0&&!this[gt]&&!this[rt].length&&(this[I]=!1)),s}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[Se]=0,!this[gt]&&!this[rt].length&&(this[I]=!1)),t}get emittedEnd(){return this[ae]}[Xt](){!this[di]&&!this[ae]&&!this[D]&&this[U].length===0&&this[Kt]&&(this[di]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[mi]&&this.emit("close"),this[di]=!1)}emit(e,...t){let s=t[0];if(e!=="error"&&e!=="close"&&e!==D&&this[D])return!1;if(e==="data")return!this[K]&&!s?!1:this[Bt]?(vs(()=>this[io](s)),!0):this[io](s);if(e==="end")return this[$a]();if(e==="close"){if(this[mi]=!0,!this[ae]&&!this[D])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(e==="error"){this[ws]=s,super.emit(so,s);let r=!this[Ss]||this.listeners("error").length?super.emit("error",s):!1;return this[Xt](),r}else if(e==="resume"){let r=super.emit("resume");return this[Xt](),r}else if(e==="finish"||e==="prefinish"){let r=super.emit(e);return this.removeAllListeners(e),r}let i=super.emit(e,...t);return this[Xt](),i}[io](e){for(let s of this[rt])s.dest.write(e)===!1&&this.pause();let t=this[gt]?!1:super.emit("data",e);return this[Xt](),t}[$a](){return this[ae]?!1:(this[ae]=!0,this.readable=!1,this[Bt]?(vs(()=>this[ro]()),!0):this[ro]())}[ro](){if(this[$e]){let t=this[$e].end();if(t){for(let s of this[rt])s.dest.write(t);this[gt]||super.emit("data",t)}}for(let t of this[rt])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[K]||(e.dataLength=0);let t=this.promise();return this.on("data",s=>{e.push(s),this[K]||(e.dataLength+=s.length)}),await t,e}async concat(){if(this[K])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Nt]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(D,()=>t(new Error("stream destroyed"))),this.on("error",s=>t(s)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[gt]=!1;let e=!1,t=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return t();let s=this.read();if(s!==null)return Promise.resolve({done:!1,value:s});if(this[Kt])return t();let i,r,o=h=>{this.off("data",n),this.off("end",a),this.off(D,l),t(),r(h)},n=h=>{this.off("error",o),this.off("end",a),this.off(D,l),this.pause(),i({value:h,done:!!this[Kt]})},a=()=>{this.off("error",o),this.off("data",n),this.off(D,l),t(),i({done:!0,value:void 0})},l=()=>o(new Error("stream destroyed"));return new Promise((h,f)=>{r=f,i=h,this.once(D,l),this.once("error",o),this.once("end",a),this.once("data",n)})},throw:t,return:t,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[gt]=!1;let e=!1,t=()=>(this.pause(),this.off(so,t),this.off(D,t),this.off("end",t),e=!0,{done:!0,value:void 0}),s=()=>{if(e)return t();let i=this.read();return i===null?t():{done:!1,value:i}};return this.once("end",t),this.once(so,t),this.once(D,t),{next:s,throw:t,return:t,[Symbol.iterator](){return this}}}destroy(e){if(this[D])return e?this.emit("error",e):this.emit(D),this;this[D]=!0,this[gt]=!0,this[U].length=0,this[z]=0;let t=this;return typeof t.close=="function"&&!this[mi]&&t.close(),e?this.emit("error",e):this.emit(D),this}static get isStream(){return Gd}},tm=$d.native,_s={lstatSync:Nd,readdir:Fd,readdirSync:Dd,readlinkSync:Md,realpathSync:tm,promises:{lstat:Wd,readdir:Id,readlink:Ud,realpath:zd}},fl=e=>!e||e===_s||e===Ld?_s:{..._s,...e,promises:{..._s.promises,...e.promises||{}}},ul=/^\\\\\?\\([a-z]:)\\?$/i,em=e=>e.replace(/\//g,"\\").replace(ul,"$1\\"),sm=/[\\\/]/,_t=0,pl=1,dl=2,Gt=4,ml=6,gl=8,ve=10,yl=12,Tt=15,Es=~Tt,no=16,La=32,ks=64,Ft=128,bi=256,Ei=512,Wa=ks|Ft|Ei,im=1023,ao=e=>e.isFile()?gl:e.isDirectory()?Gt:e.isSymbolicLink()?ve:e.isCharacterDevice()?dl:e.isBlockDevice()?ml:e.isSocket()?yl:e.isFIFO()?pl:_t,Ia=new ki({max:2**12}),Os=e=>{let t=Ia.get(e);if(t)return t;let s=e.normalize("NFKD");return Ia.set(e,s),s},Ua=new ki({max:2**12}),Si=e=>{let t=Ua.get(e);if(t)return t;let s=Os(e.toLowerCase());return Ua.set(e,s),s},za=class extends ki{constructor(){super({max:256})}},rm=class extends ki{constructor(e=16*1024){super({maxSize:e,sizeCalculation:t=>t.length+1})}},wl=Symbol("PathScurry setAsCwd"),ft=class{name;root;roots;parent;nocase;isCWD=!1;#t;#r;get dev(){return this.#r}#n;get mode(){return this.#n}#s;get nlink(){return this.#s}#o;get uid(){return this.#o}#_;get gid(){return this.#_}#x;get rdev(){return this.#x}#f;get blksize(){return this.#f}#a;get ino(){return this.#a}#p;get size(){return this.#p}#c;get blocks(){return this.#c}#l;get atimeMs(){return this.#l}#i;get mtimeMs(){return this.#i}#w;get ctimeMs(){return this.#w}#S;get birthtimeMs(){return this.#S}#y;get atime(){return this.#y}#d;get mtime(){return this.#d}#k;get ctime(){return this.#k}#m;get birthtime(){return this.#m}#v;#T;#u;#g;#b;#O;#e;#F;#P;#R;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=_t,s,i,r,o,n){this.name=e,this.#v=r?Si(e):Os(e),this.#e=t&im,this.nocase=r,this.roots=i,this.root=s||this,this.#F=o,this.#u=n.fullpath,this.#b=n.relative,this.#O=n.relativePosix,this.parent=n.parent,this.parent?this.#t=this.parent.#t:this.#t=fl(n.fs)}depth(){return this.#T!==void 0?this.#T:this.parent?this.#T=this.parent.depth()+1:this.#T=0}childrenCache(){return this.#F}resolve(e){if(!e)return this;let t=this.getRootString(e),s=e.substring(t.length).split(this.splitSep);return t?this.getRoot(t).#N(s):this.#N(s)}#N(e){let t=this;for(let s of e)t=t.child(s);return t}children(){let e=this.#F.get(this);if(e)return e;let t=Object.assign([],{provisional:0});return this.#F.set(this,t),this.#e&=~no,t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let s=this.children(),i=this.nocase?Si(e):Os(e);for(let a of s)if(a.#v===i)return a;let r=this.parent?this.sep:"",o=this.#u?this.#u+r+e:void 0,n=this.newChild(e,_t,{...t,parent:this,fullpath:o});return this.canReaddir()||(n.#e|=Ft),s.push(n),n}relative(){if(this.isCWD)return"";if(this.#b!==void 0)return this.#b;let e=this.name,t=this.parent;if(!t)return this.#b=this.name;let s=t.relative();return s+(!s||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#O!==void 0)return this.#O;let e=this.name,t=this.parent;if(!t)return this.#O=this.fullpathPosix();let s=t.relativePosix();return s+(!s||!t.parent?"":"/")+e}fullpath(){if(this.#u!==void 0)return this.#u;let e=this.name,t=this.parent;if(!t)return this.#u=this.name;let s=t.fullpath()+(t.parent?this.sep:"")+e;return this.#u=s}fullpathPosix(){if(this.#g!==void 0)return this.#g;if(this.sep==="/")return this.#g=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#g=`//?/${i}`:this.#g=i}let e=this.parent,t=e.fullpathPosix(),s=t+(!t||!e.parent?"":"/")+this.name;return this.#g=s}isUnknown(){return(this.#e&Tt)===_t}isType(e){return this[`is${e}`]()}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.#e&Tt)===gl}isDirectory(){return(this.#e&Tt)===Gt}isCharacterDevice(){return(this.#e&Tt)===dl}isBlockDevice(){return(this.#e&Tt)===ml}isFIFO(){return(this.#e&Tt)===pl}isSocket(){return(this.#e&Tt)===yl}isSymbolicLink(){return(this.#e&ve)===ve}lstatCached(){return this.#e&La?this:void 0}readlinkCached(){return this.#P}realpathCached(){return this.#R}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#P)return!0;if(!this.parent)return!1;let e=this.#e&Tt;return!(e!==_t&&e!==ve||this.#e&bi||this.#e&Ft)}calledReaddir(){return!!(this.#e&no)}isENOENT(){return!!(this.#e&Ft)}isNamed(e){return this.nocase?this.#v===Si(e):this.#v===Os(e)}async readlink(){let e=this.#P;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await this.#t.promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(t);if(s)return this.#P=s}catch(t){this.#j(t.code);return}}readlinkSync(){let e=this.#P;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=this.#t.readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(t);if(s)return this.#P=s}catch(t){this.#j(t.code);return}}#L(e){this.#e|=no;for(let t=e.provisional;t<e.length;t++){let s=e[t];s&&s.#E()}}#E(){this.#e&Ft||(this.#e=(this.#e|Ft)&Es,this.#G())}#G(){let e=this.children();e.provisional=0;for(let t of e)t.#E()}#$(){this.#e|=Ei,this.#D()}#D(){if(this.#e&ks)return;let e=this.#e;(e&Tt)===Gt&&(e&=Es),this.#e=e|ks,this.#G()}#W(e=""){e==="ENOTDIR"||e==="EPERM"?this.#D():e==="ENOENT"?this.#E():this.children().provisional=0}#C(e=""){e==="ENOTDIR"?this.parent.#D():e==="ENOENT"&&this.#E()}#j(e=""){let t=this.#e;t|=bi,e==="ENOENT"&&(t|=Ft),(e==="EINVAL"||e==="UNKNOWN")&&(t&=Es),this.#e=t,e==="ENOTDIR"&&this.parent&&this.parent.#D()}#I(e,t){return this.#z(e,t)||this.#U(e,t)}#U(e,t){let s=ao(e),i=this.newChild(e.name,s,{parent:this}),r=i.#e&Tt;return r!==Gt&&r!==ve&&r!==_t&&(i.#e|=ks),t.unshift(i),t.provisional++,i}#z(e,t){for(let s=t.provisional;s<t.length;s++){let i=t[s];if((this.nocase?Si(e.name):Os(e.name))===i.#v)return this.#h(e,i,s,t)}}#h(e,t,s,i){let r=t.name;return t.#e=t.#e&Es|ao(e),r!==e.name&&(t.name=e.name),s!==i.provisional&&(s===i.length-1?i.pop():i.splice(s,1),i.unshift(t)),i.provisional++,t}async lstat(){if((this.#e&Ft)===0)try{return this.#B(await this.#t.promises.lstat(this.fullpath())),this}catch(e){this.#C(e.code)}}lstatSync(){if((this.#e&Ft)===0)try{return this.#B(this.#t.lstatSync(this.fullpath())),this}catch(e){this.#C(e.code)}}#B(e){let{atime:t,atimeMs:s,birthtime:i,birthtimeMs:r,blksize:o,blocks:n,ctime:a,ctimeMs:l,dev:h,gid:f,ino:c,mode:u,mtime:p,mtimeMs:d,nlink:m,rdev:y,size:g,uid:w}=e;this.#y=t,this.#l=s,this.#m=i,this.#S=r,this.#f=o,this.#c=n,this.#k=a,this.#w=l,this.#r=h,this.#_=f,this.#a=c,this.#n=u,this.#d=p,this.#i=d,this.#s=m,this.#x=y,this.#p=g,this.#o=w;let S=ao(e);this.#e=this.#e&Es|S|La,S!==_t&&S!==Gt&&S!==ve&&(this.#e|=ks)}#M=[];#A=!1;#H(e){this.#A=!1;let t=this.#M.slice();this.#M.length=0,t.forEach(s=>s(null,e))}readdirCB(e,t=!1){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let s=this.children();if(this.calledReaddir()){let r=s.slice(0,s.provisional);t?e(null,r):queueMicrotask(()=>e(null,r));return}if(this.#M.push(e),this.#A)return;this.#A=!0;let i=this.fullpath();this.#t.readdir(i,{withFileTypes:!0},(r,o)=>{if(r)this.#W(r.code),s.provisional=0;else{for(let n of o)this.#I(n,s);this.#L(s)}this.#H(s.slice(0,s.provisional))})}#Y;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(this.#Y)await this.#Y;else{let s=()=>{};this.#Y=new Promise(i=>s=i);try{for(let i of await this.#t.promises.readdir(t,{withFileTypes:!0}))this.#I(i,e);this.#L(e)}catch(i){this.#W(i.code),e.provisional=0}this.#Y=void 0,s()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();try{for(let s of this.#t.readdirSync(t,{withFileTypes:!0}))this.#I(s,e);this.#L(e)}catch(s){this.#W(s.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#e&Wa)return!1;let e=Tt&this.#e;return e===_t||e===Gt||e===ve}shouldWalk(e,t){return(this.#e&Gt)===Gt&&!(this.#e&Wa)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#R)return this.#R;if(!((Ei|bi|Ft)&this.#e))try{let e=await this.#t.promises.realpath(this.fullpath());return this.#R=this.resolve(e)}catch{this.#$()}}realpathSync(){if(this.#R)return this.#R;if(!((Ei|bi|Ft)&this.#e))try{let e=this.#t.realpathSync(this.fullpath());return this.#R=this.resolve(e)}catch{this.#$()}}[wl](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let t=new Set([]),s=[],i=this;for(;i&&i.parent;)t.add(i),i.#b=s.join(this.sep),i.#O=s.join("/"),i=i.parent,s.push("..");for(i=e;i&&i.parent&&!t.has(i);)i.#b=void 0,i.#O=void 0,i=i.parent}},bl=class Sl extends ft{sep="\\";splitSep=sm;constructor(t,s=_t,i,r,o,n,a){super(t,s,i,r,o,n,a)}newChild(t,s=_t,i={}){return new Sl(t,s,this.root,this.roots,this.nocase,this.childrenCache(),i)}getRootString(t){return ho.parse(t).root}getRoot(t){if(t=em(t.toUpperCase()),t===this.root.name)return this.root;for(let[s,i]of Object.entries(this.roots))if(this.sameRoot(t,s))return this.roots[t]=i;return this.roots[t]=new po(t,this).root}sameRoot(t,s=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(ul,"$1\\"),t===s}},vl=class El extends ft{splitSep="/";sep="/";constructor(t,s=_t,i,r,o,n,a){super(t,s,i,r,o,n,a)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,s=_t,i={}){return new El(t,s,this.root,this.roots,this.nocase,this.childrenCache(),i)}},xl=class{root;rootPath;roots;cwd;#t;#r;#n;nocase;#s;constructor(e=process.cwd(),t,s,{nocase:i,childrenCacheSize:r=16*1024,fs:o=_s}={}){this.#s=fl(o),(e instanceof URL||e.startsWith("file://"))&&(e=Pd(e));let n=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(n),this.#t=new za,this.#r=new za,this.#n=new rm(r);let a=n.substring(this.rootPath.length).split(s);if(a.length===1&&!a[0]&&a.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#s),this.roots[this.rootPath]=this.root;let l=this.root,h=a.length-1,f=t.sep,c=this.rootPath,u=!1;for(let p of a){let d=h--;l=l.child(p,{relative:new Array(d).fill("..").join(f),relativePosix:new Array(d).fill("..").join("/"),fullpath:c+=(u?"":f)+p}),u=!0}this.cwd=l}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#n}resolve(...e){let t="";for(let r=e.length-1;r>=0;r--){let o=e[r];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=this.#t.get(t);if(s!==void 0)return s;let i=this.cwd.resolve(t).fullpath();return this.#t.set(t,i),i}resolvePosix(...e){let t="";for(let r=e.length-1;r>=0;r--){let o=e[r];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=this.#r.get(t);if(s!==void 0)return s;let i=this.cwd.resolve(t).fullpathPosix();return this.#r.set(t,i),i}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e,e=this.cwd);let{withFileTypes:s}=t;if(e.canReaddir()){let i=await e.readdir();return s?i:i.map(r=>r.name)}else return[]}readdirSync(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e,e=this.cwd);let{withFileTypes:s=!0}=t;return e.canReaddir()?s?e.readdirSync():e.readdirSync().map(i=>i.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e.withFileTypes,e=this.cwd);let s=await e.readlink();return t?s:s?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e.withFileTypes,e=this.cwd);let s=e.readlinkSync();return t?s:s?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e.withFileTypes,e=this.cwd);let s=await e.realpath();return t?s:s?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e.withFileTypes,e=this.cwd);let s=e.realpathSync();return t?s:s?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=t,n=[];(!r||r(e))&&n.push(s?e:e.fullpath());let a=new Set,l=(f,c)=>{a.add(f),f.readdirCB((u,p)=>{if(u)return c(u);let d=p.length;if(!d)return c();let m=()=>{--d===0&&c()};for(let y of p)(!r||r(y))&&n.push(s?y:y.fullpath()),i&&y.isSymbolicLink()?y.realpath().then(g=>g?.isUnknown()?g.lstat():g).then(g=>g?.shouldWalk(a,o)?l(g,m):m()):y.shouldWalk(a,o)?l(y,m):m()},!0)},h=e;return new Promise((f,c)=>{l(h,u=>{if(u)return c(u);f(n)})})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=t,n=[];(!r||r(e))&&n.push(s?e:e.fullpath());let a=new Set([e]);for(let l of a){let h=l.readdirSync();for(let f of h){(!r||r(f))&&n.push(s?f:f.fullpath());let c=f;if(f.isSymbolicLink()){if(!(i&&(c=f.realpathSync())))continue;c.isUnknown()&&c.lstatSync()}c.shouldWalk(a,o)&&a.add(c)}}return n}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=t;(!r||r(e))&&(yield s?e:e.fullpath());let n=new Set([e]);for(let a of n){let l=a.readdirSync();for(let h of l){(!r||r(h))&&(yield s?h:h.fullpath());let f=h;if(h.isSymbolicLink()){if(!(i&&(f=h.realpathSync())))continue;f.isUnknown()&&f.lstatSync()}f.shouldWalk(n,o)&&n.add(f)}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=t,n=new _i({objectMode:!0});(!r||r(e))&&n.write(s?e:e.fullpath());let a=new Set,l=[e],h=0,f=()=>{let c=!1;for(;!c;){let u=l.shift();if(!u){h===0&&n.end();return}h++,a.add(u);let p=(m,y,g=!1)=>{if(m)return n.emit("error",m);if(i&&!g){let w=[];for(let S of y)S.isSymbolicLink()&&w.push(S.realpath().then(b=>b?.isUnknown()?b.lstat():b));if(w.length){Promise.all(w).then(()=>p(null,y,!0));return}}for(let w of y)w&&(!r||r(w))&&(n.write(s?w:w.fullpath())||(c=!0));h--;for(let w of y){let S=w.realpathCached()||w;S.shouldWalk(a,o)&&l.push(S)}c&&!n.flowing?n.once("drain",f):d||f()},d=!0;u.readdirCB(p,!0),d=!1}};return f(),n}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=t,n=new _i({objectMode:!0}),a=new Set;(!r||r(e))&&n.write(s?e:e.fullpath());let l=[e],h=0,f=()=>{let c=!1;for(;!c;){let u=l.shift();if(!u){h===0&&n.end();return}h++,a.add(u);let p=u.readdirSync();for(let d of p)(!r||r(d))&&(n.write(s?d:d.fullpath())||(c=!0));h--;for(let d of p){let m=d;if(d.isSymbolicLink()){if(!(i&&(m=d.realpathSync())))continue;m.isUnknown()&&m.lstatSync()}m.shouldWalk(a,o)&&l.push(m)}}c&&!n.flowing&&n.once("drain",f)};return f(),n}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[wl](t)}},po=class extends xl{sep="\\";constructor(e=process.cwd(),t={}){let{nocase:s=!0}=t;super(e,ho,"\\",{...t,nocase:s}),this.nocase=s;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(e){return ho.parse(e).root.toUpperCase()}newRoot(e){return new bl(this.rootPath,Gt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},mo=class extends xl{sep="/";constructor(e=process.cwd(),t={}){let{nocase:s=!1}=t;super(e,jd,"/",{...t,nocase:s}),this.nocase=s}parseRootPath(e){return"/"}newRoot(e){return new vl(this.rootPath,Gt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},Tl=class extends mo{constructor(e=process.cwd(),t={}){let{nocase:s=!0}=t;super(e,{...t,nocase:s})}},Ov=process.platform==="win32"?bl:vl,om=process.platform==="win32"?po:process.platform==="darwin"?Tl:mo,nm=e=>e.length>=1,am=e=>e.length>=1,lm=Symbol.for("nodejs.util.inspect.custom"),_l=class kl{#t;#r;#n;length;#s;#o;#_;#x;#f;#a;#p=!0;constructor(t,s,i,r){if(!nm(t))throw new TypeError("empty pattern list");if(!am(s))throw new TypeError("empty glob list");if(s.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,i<0||i>=this.length)throw new TypeError("index out of range");if(this.#t=t,this.#r=s,this.#n=i,this.#s=r,this.#n===0){if(this.isUNC()){let[o,n,a,l,...h]=this.#t,[f,c,u,p,...d]=this.#r;h[0]===""&&(h.shift(),d.shift());let m=[o,n,a,l,""].join("/"),y=[f,c,u,p,""].join("/");this.#t=[m,...h],this.#r=[y,...d],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[o,...n]=this.#t,[a,...l]=this.#r;n[0]===""&&(n.shift(),l.shift());let h=o+"/",f=a+"/";this.#t=[h,...n],this.#r=[f,...l],this.length=this.#t.length}}}[lm](){return"Pattern <"+this.#r.slice(this.#n).join("/")+">"}pattern(){return this.#t[this.#n]}isString(){return typeof this.#t[this.#n]=="string"}isGlobstar(){return this.#t[this.#n]===ot}isRegExp(){return this.#t[this.#n]instanceof RegExp}globString(){return this.#_=this.#_||(this.#n===0?this.isAbsolute()?this.#r[0]+this.#r.slice(1).join("/"):this.#r.join("/"):this.#r.slice(this.#n).join("/"))}hasMore(){return this.length>this.#n+1}rest(){return this.#o!==void 0?this.#o:this.hasMore()?(this.#o=new kl(this.#t,this.#r,this.#n+1,this.#s),this.#o.#a=this.#a,this.#o.#f=this.#f,this.#o.#x=this.#x,this.#o):this.#o=null}isUNC(){let t=this.#t;return this.#f!==void 0?this.#f:this.#f=this.#s==="win32"&&this.#n===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#t;return this.#x!==void 0?this.#x:this.#x=this.#s==="win32"&&this.#n===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#t;return this.#a!==void 0?this.#a:this.#a=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#t[0];return typeof t=="string"&&this.isAbsolute()&&this.#n===0?t:""}checkFollowGlobstar(){return!(this.#n===0||!this.isGlobstar()||!this.#p)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#p?!1:(this.#p=!1,!0)}},hm=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Ba=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:s,noext:i,noglobstar:r,platform:o=hm}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:t,nocase:s,noext:i,noglobstar:r,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let n of e)this.add(n)}add(e){let t=new he(e,this.mmopts);for(let s=0;s<t.set.length;s++){let i=t.set[s],r=t.globParts[s];if(!i||!r)throw new Error("invalid pattern object");for(;i[0]==="."&&r[0]===".";)i.shift(),r.shift();let o=new _l(i,r,0,this.platform),n=new he(o.globString(),this.mmopts),a=r[r.length-1]==="**",l=o.isAbsolute();l?this.absolute.push(n):this.relative.push(n),a&&(l?this.absoluteChildren.push(n):this.relativeChildren.push(n))}}ignored(e){let t=e.fullpath(),s=`${t}/`,i=e.relative()||".",r=`${i}/`;for(let o of this.relative)if(o.match(i)||o.match(r))return!0;for(let o of this.absolute)if(o.match(t)||o.match(s))return!0;return!1}childrenIgnored(e){let t=e.fullpath()+"/",s=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(s))return!0;for(let i of this.absoluteChildren)if(i.match(t))return!0;return!1}},cm=class Ol{store;constructor(t=new Map){this.store=t}copy(){return new Ol(new Map(this.store))}hasWalked(t,s){return this.store.get(t.fullpath())?.has(s.globString())}storeWalked(t,s){let i=t.fullpath(),r=this.store.get(i);r?r.add(s.globString()):this.store.set(i,new Set([s.globString()]))}},fm=class{store=new Map;add(e,t,s){let i=(t?2:0)|(s?1:0),r=this.store.get(e);this.store.set(e,r===void 0?i:i&r)}entries(){return[...this.store.entries()].map(([e,t])=>[e,!!(t&2),!!(t&1)])}},um=class{store=new Map;add(e,t){if(!e.canReaddir())return;let s=this.store.get(e);s?s.find(i=>i.globString()===t.globString())||s.push(t):this.store.set(e,[t])}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter(e=>e.canReaddir())}},Ga=class Rl{hasWalkedCache;matches=new fm;subwalks=new um;patterns;follow;dot;opts;constructor(t,s){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=s?s.copy():new cm}processPatterns(t,s){this.patterns=s;let i=s.map(r=>[t,r]);for(let[r,o]of i){this.hasWalkedCache.storeWalked(r,o);let n=o.root(),a=o.isAbsolute()&&this.opts.absolute!==!1;if(n){r=r.resolve(n==="/"&&this.opts.root!==void 0?this.opts.root:n);let c=o.rest();if(c)o=c;else{this.matches.add(r,!0,!1);continue}}if(r.isENOENT())continue;let l,h,f=!1;for(;typeof(l=o.pattern())=="string"&&(h=o.rest());)r=r.resolve(l),o=h,f=!0;if(l=o.pattern(),h=o.rest(),f){if(this.hasWalkedCache.hasWalked(r,o))continue;this.hasWalkedCache.storeWalked(r,o)}if(typeof l=="string"){let c=l===".."||l===""||l===".";this.matches.add(r.resolve(l),a,c);continue}else if(l===ot){(!r.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(r,o);let c=h?.pattern(),u=h?.rest();if(!h||(c===""||c===".")&&!u)this.matches.add(r,a,c===""||c===".");else if(c===".."){let p=r.parent||r;u?this.hasWalkedCache.hasWalked(p,u)||this.subwalks.add(p,u):this.matches.add(p,a,!0)}}else l instanceof RegExp&&this.subwalks.add(r,o)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new Rl(this.opts,this.hasWalkedCache)}filterEntries(t,s){let i=this.subwalks.get(t),r=this.child();for(let o of s)for(let n of i){let a=n.isAbsolute(),l=n.pattern(),h=n.rest();l===ot?r.testGlobstar(o,n,h,a):l instanceof RegExp?r.testRegExp(o,l,h,a):r.testString(o,l,h,a)}return r}testGlobstar(t,s,i,r){if((this.dot||!t.name.startsWith("."))&&(s.hasMore()||this.matches.add(t,r,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,s):t.isSymbolicLink()&&(i&&s.checkFollowGlobstar()?this.subwalks.add(t,i):s.markFollowGlobstar()&&this.subwalks.add(t,s)))),i){let o=i.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(t,o,i.rest(),r);else if(o===".."){let n=t.parent||t;this.subwalks.add(n,i)}else o instanceof RegExp&&this.testRegExp(t,o,i.rest(),r)}}testRegExp(t,s,i,r){s.test(t.name)&&(i?this.subwalks.add(t,i):this.matches.add(t,r,!1))}testString(t,s,i,r){t.isNamed(s)&&(i?this.subwalks.add(t,i):this.matches.add(t,r,!1))}},pm=(e,t)=>typeof e=="string"?new Ba([e],t):Array.isArray(e)?new Ba(e,t):e,Al=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#t=[];#r;#n;signal;maxDepth;includeChildMatches;constructor(e,t,s){if(this.patterns=e,this.path=t,this.opts=s,this.#n=!s.posix&&s.platform==="win32"?"\\":"/",this.includeChildMatches=s.includeChildMatches!==!1,(s.ignore||!this.includeChildMatches)&&(this.#r=pm(s.ignore??[],s),!this.includeChildMatches&&typeof this.#r.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0}))}#s(e){return this.seen.has(e)||!!this.#r?.ignored?.(e)}#o(e){return!!this.#r?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#t.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#t.push(e):e())}async matchCheck(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||await e.realpath(),!s)return;e=s}let i=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&i?.isSymbolicLink()){let r=await i.realpath();r&&(r.isUnknown()||this.opts.stat)&&await r.lstat()}return this.matchCheckTest(i,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#s(e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||e.realpathSync(),!s)return;e=s}let i=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&i?.isSymbolicLink()){let r=i.realpathSync();r&&(r?.isUnknown()||this.opts.stat)&&r.lstatSync()}return this.matchCheckTest(i,t)}matchFinish(e,t){if(this.#s(e))return;if(!this.includeChildMatches&&this.#r?.add){let r=`${e.relativePosix()}/**`;this.#r.add(r)}let s=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?this.#n:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(s){let r=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(r+i)}else{let r=this.opts.posix?e.relativePosix():e.relative(),o=this.opts.dotRelative&&!r.startsWith(".."+this.#n)?"."+this.#n:"";this.matchEmit(r?o+r+i:"."+i)}}async match(e,t,s){let i=await this.matchCheck(e,s);i&&this.matchFinish(i,t)}matchSync(e,t,s){let i=this.matchCheckSync(e,s);i&&this.matchFinish(i,t)}walkCB(e,t,s){this.signal?.aborted&&s(),this.walkCB2(e,t,new Ga(this.opts),s)}walkCB2(e,t,s,i){if(this.#o(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,t,s,i));return}s.processPatterns(e,t);let r=1,o=()=>{--r===0&&i()};for(let[n,a,l]of s.matches.entries())this.#s(n)||(r++,this.match(n,a,l).then(()=>o()));for(let n of s.subwalkTargets()){if(this.maxDepth!==1/0&&n.depth()>=this.maxDepth)continue;r++;let a=n.readdirCached();n.calledReaddir()?this.walkCB3(n,a,s,o):n.readdirCB((l,h)=>this.walkCB3(n,h,s,o),!0)}o()}walkCB3(e,t,s,i){s=s.filterEntries(e,t);let r=1,o=()=>{--r===0&&i()};for(let[n,a,l]of s.matches.entries())this.#s(n)||(r++,this.match(n,a,l).then(()=>o()));for(let[n,a]of s.subwalks.entries())r++,this.walkCB2(n,a,s.child(),o);o()}walkCBSync(e,t,s){this.signal?.aborted&&s(),this.walkCB2Sync(e,t,new Ga(this.opts),s)}walkCB2Sync(e,t,s,i){if(this.#o(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,s,i));return}s.processPatterns(e,t);let r=1,o=()=>{--r===0&&i()};for(let[n,a,l]of s.matches.entries())this.#s(n)||this.matchSync(n,a,l);for(let n of s.subwalkTargets()){if(this.maxDepth!==1/0&&n.depth()>=this.maxDepth)continue;r++;let a=n.readdirSync();this.walkCB3Sync(n,a,s,o)}o()}walkCB3Sync(e,t,s,i){s=s.filterEntries(e,t);let r=1,o=()=>{--r===0&&i()};for(let[n,a,l]of s.matches.entries())this.#s(n)||this.matchSync(n,a,l);for(let[n,a]of s.subwalks.entries())r++,this.walkCB2Sync(n,a,s.child(),o);o()}},Ha=class extends Al{matches=new Set;constructor(e,t,s){super(e,t,s)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,t)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?t(this.signal.reason):e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},Ya=class extends Al{results;constructor(e,t,s){super(e,t,s),this.results=new _i({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}},dm=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",xe=class{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(e,t){if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=Od(t.cwd)):this.cwd="",this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==!1,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(e=e.map(a=>a.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(a=>a.includes("/")?a:`./**/${a}`)}if(this.pattern=e,this.platform=t.platform||dm,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let a=t.platform==="win32"?po:t.platform==="darwin"?Tl:t.platform?mo:om;this.scurry=new a(this.cwd,{nocase:t.nocase,fs:t.fs})}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",i={braceExpandMax:1e4,...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},r=this.pattern.map(a=>new he(a,i)),[o,n]=r.reduce((a,l)=>(a[0].push(...l.set),a[1].push(...l.globParts),a),[[],[]]);this.patterns=o.map((a,l)=>{let h=n[l];if(!h)throw new Error("invalid pattern object");return new _l(a,h,0,this.platform)})}async walk(){return[...await new Ha(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 Ha(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 Ya(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 Ya(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()}},mm=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let s of e)if(new he(s,t).hasMagic())return!0;return!1};function Oi(e,t={}){return new xe(e,t).streamSync()}function Cl(e,t={}){return new xe(e,t).stream()}function ce(e,t={}){return new xe(e,t).walkSync()}async function qa(e,t={}){return new xe(e,t).walk()}function Ri(e,t={}){return new xe(e,t).iterateSync()}function jl(e,t={}){return new xe(e,t).iterate()}var gm=Oi,ym=Object.assign(Cl,{sync:Oi}),wm=Ri,bm=Object.assign(jl,{sync:Ri}),Sm=Object.assign(ce,{stream:Oi,iterate:Ri}),Ee=Object.assign(qa,{glob:qa,globSync:ce,sync:Sm,globStream:Cl,stream:ym,globStreamSync:Oi,streamSync:gm,globIterate:jl,iterate:bm,globIterateSync:Ri,iterateSync:wm,Glob:xe,hasMagic:mm,escape:Rs,unescape:We});Ee.glob=Ee;import{dirname as Pl}from"path";import{mkdir as vm,mkdirSync as Em,stat as xm,statSync as Tm}from"fs";var kt=e=>{if(!e)e={mode:511};else if(typeof e=="object")e={mode:511,...e};else if(typeof e=="number")e={mode:e};else if(typeof e=="string")e={mode:parseInt(e,8)};else throw new TypeError("invalid options argument");let t=e,s=e.fs||{};return e.mkdir=e.mkdir||s.mkdir||vm,e.mkdirAsync=e.mkdirAsync?e.mkdirAsync:async(i,r)=>new Promise((o,n)=>t.mkdir(i,r,(a,l)=>a?n(a):o(l))),e.stat=e.stat||s.stat||xm,e.statAsync=e.statAsync?e.statAsync:async i=>new Promise((r,o)=>t.stat(i,(n,a)=>n?o(n):r(a))),e.statSync=e.statSync||s.statSync||Tm,e.mkdirSync=e.mkdirSync||s.mkdirSync||Em,t};var Ht=(e,t,s)=>{let i=Pl(e),r={...kt(t),recursive:!1};if(i===e)try{return r.mkdirSync(e,r)}catch(o){let n=o;if(n&&n.code!=="EISDIR")throw o;return}try{return r.mkdirSync(e,r),s||e}catch(o){let n=o;if(n&&n.code==="ENOENT")return Ht(e,r,Ht(i,r,s));if(n&&n.code!=="EEXIST"&&n&&n.code!=="EROFS")throw o;try{if(!r.statSync(e).isDirectory())throw o}catch{throw o}}},Zt=Object.assign(async(e,t,s)=>{let i=kt(t);i.recursive=!1;let r=Pl(e);return r===e?i.mkdirAsync(e,i).catch(o=>{let n=o;if(n&&n.code!=="EISDIR")throw o}):i.mkdirAsync(e,i).then(()=>s||e,async o=>{let n=o;if(n&&n.code==="ENOENT")return Zt(r,i).then(a=>Zt(e,i,a));if(n&&n.code!=="EEXIST"&&n.code!=="EROFS")throw o;return i.statAsync(e).then(a=>{if(a.isDirectory())return s;throw o},()=>{throw o})})},{sync:Ht});import{dirname as Fl}from"path";import{dirname as Nl}from"path";var go=async(e,t,s)=>{if(s!==t)return e.statAsync(t).then(i=>i.isDirectory()?s:void 0,i=>{let r=i;return r&&r.code==="ENOENT"?go(e,Nl(t),t):void 0})},yo=(e,t,s)=>{if(s!==t)try{return e.statSync(t).isDirectory()?s:void 0}catch(i){let r=i;return r&&r.code==="ENOENT"?yo(e,Nl(t),t):void 0}};var Ie=(e,t)=>{let s=kt(t);if(s.recursive=!0,Fl(e)===e)return s.mkdirSync(e,s);let r=yo(s,e);try{return s.mkdirSync(e,s),r}catch(o){let n=o;if(n&&n.code==="ENOENT")return Ht(e,s);throw o}},As=Object.assign(async(e,t)=>{let s={...kt(t),recursive:!0};return Fl(e)===e?await s.mkdirAsync(e,s):go(s,e).then(r=>s.mkdirAsync(e,s).then(o=>r||o).catch(o=>{let n=o;if(n&&n.code==="ENOENT")return Zt(e,s);throw o}))},{sync:Ie});import{parse as km,resolve as Om}from"path";var _m=process.env.__TESTING_MKDIRP_PLATFORM__||process.platform,wo=e=>{if(/\0/.test(e))throw Object.assign(new TypeError("path must be a string without null bytes"),{path:e,code:"ERR_INVALID_ARG_VALUE"});if(e=Om(e),_m==="win32"){let t=/[*|"<>?:]/,{root:s}=km(e);if(t.test(e.substring(s.length)))throw Object.assign(new Error("Illegal characters in path."),{path:e,code:"EINVAL"})}return e};import{mkdir as Rm,mkdirSync as Am}from"fs";var Cm=process.env.__TESTING_MKDIRP_NODE_VERSION__||process.version,bo=Cm.replace(/^v/,"").split("."),Dl=+bo[0]>10||+bo[0]==10&&+bo[1]>=12,Cs=Dl?e=>kt(e).mkdirSync===Am:()=>!1,Ai=Object.assign(Dl?e=>kt(e).mkdir===Rm:()=>!1,{sync:Cs});var Qt=(e,t)=>{e=wo(e);let s=kt(t);return Cs(s)?Ie(e,s):Ht(e,s)};var So=Object.assign(async(e,t)=>{e=wo(e);let s=kt(t);return Ai(s)?As(e,s):Zt(e,s)},{mkdirpSync:Qt,mkdirpNative:As,mkdirpNativeSync:Ie,mkdirpManual:Zt,mkdirpManualSync:Ht,sync:Qt,native:As,nativeSync:Ie,manual:Zt,manualSync:Ht,useNative:Ai,useNativeSync:Cs});import Vg from"node:constants";import{createHash as zh}from"node:crypto";import{chmodSync as Bh,copyFileSync as Jg,linkSync as Kg,readFileSync as Gh,readlinkSync as Hh,symlinkSync as Xg,unlinkSync as Zg}from"node:fs";import{dirname as Hs,relative as Yh,resolve as rr,sep as Qg}from"node:path";var jm=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,$l=new Set,vo=typeof process=="object"&&process?process:{},Ll=(e,t,s,i)=>{typeof vo.emitWarning=="function"?vo.emitWarning(e,t,s,i):console.error(`[${s}] ${t}: ${e}`)},ji=globalThis.AbortController,Ml=globalThis.AbortSignal;if(typeof ji>"u"){Ml=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,i){this._onabort.push(i)}},ji=class{constructor(){t()}signal=new Ml;abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=!0;for(let i of this.signal._onabort)i(s);this.signal.onabort?.(s)}}};let e=vo.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,Ll("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",t))}}var Pm=e=>!$l.has(e);var fe=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Wl=e=>fe(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Ci:null:null,Ci=class extends Array{constructor(e){super(e),this.fill(0)}},Nm=class js{heap;length;static#t=!1;static create(t){let s=Wl(t);if(!s)return[];js.#t=!0;let i=new js(t,s);return js.#t=!1,i}constructor(t,s){if(!js.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new s(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},Ps=class Il{#t;#r;#n;#s;#o;#_;#x;#f;get perf(){return this.#f}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#p;#c;#l;#i;#w;#S;#y;#d;#k;#m;#v;#T;#u;#g;#b;#O;#e;#F;static unsafeExposeInternals(t){return{starts:t.#T,ttls:t.#u,autopurgeTimers:t.#g,sizes:t.#v,keyMap:t.#c,keyList:t.#l,valList:t.#i,next:t.#w,prev:t.#S,get head(){return t.#y},get tail(){return t.#d},free:t.#k,isBackgroundFetch:s=>t.#h(s),backgroundFetch:(s,i,r,o)=>t.#z(s,i,r,o),moveToTail:s=>t.#M(s),indexes:s=>t.#C(s),rindexes:s=>t.#j(s),isStale:s=>t.#E(s)}}get max(){return this.#t}get maxSize(){return this.#r}get calculatedSize(){return this.#p}get size(){return this.#a}get fetchMethod(){return this.#_}get memoMethod(){return this.#x}get dispose(){return this.#n}get onInsert(){return this.#s}get disposeAfter(){return this.#o}constructor(t){let{max:s=0,ttl:i,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:l,dispose:h,onInsert:f,disposeAfter:c,noDisposeOnSet:u,noUpdateTTL:p,maxSize:d=0,maxEntrySize:m=0,sizeCalculation:y,fetchMethod:g,memoMethod:w,noDeleteOnFetchRejection:S,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:R,ignoreFetchAbort:$,perf:q}=t;if(q!==void 0&&typeof q?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#f=q??jm,s!==0&&!fe(s))throw new TypeError("max option must be a nonnegative integer");let st=s?Wl(s):Array;if(!st)throw new Error("invalid max value: "+s);if(this.#t=s,this.#r=d,this.maxEntrySize=m||this.#r,this.sizeCalculation=y,this.sizeCalculation){if(!this.#r&&!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(w!==void 0&&typeof w!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#x=w,g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#_=g,this.#O=!!g,this.#c=new Map,this.#l=new Array(s).fill(void 0),this.#i=new Array(s).fill(void 0),this.#w=new st(s),this.#S=new st(s),this.#y=0,this.#d=0,this.#k=Nm.create(s),this.#a=0,this.#p=0,typeof h=="function"&&(this.#n=h),typeof f=="function"&&(this.#s=f),typeof c=="function"?(this.#o=c,this.#m=[]):(this.#o=void 0,this.#m=void 0),this.#b=!!this.#n,this.#F=!!this.#s,this.#e=!!this.#o,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!p,this.noDeleteOnFetchRejection=!!S,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!R,this.ignoreFetchAbort=!!$,this.maxEntrySize!==0){if(this.#r!==0&&!fe(this.#r))throw new TypeError("maxSize must be a positive integer if specified");if(!fe(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#G()}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=fe(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=i||0,this.ttl){if(!fe(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#P()}if(this.#t===0&&this.ttl===0&&this.#r===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#r){let Vt="LRU_CACHE_UNBOUNDED";Pm(Vt)&&($l.add(Vt),Ll("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Vt,Il))}}getRemainingTTL(t){return this.#c.has(t)?1/0:0}#P(){let t=new Ci(this.#t),s=new Ci(this.#t);this.#u=t,this.#T=s;let i=this.ttlAutopurge?new Array(this.#t):void 0;this.#g=i,this.#L=(n,a,l=this.#f.now())=>{if(s[n]=a!==0?l:0,t[n]=a,i?.[n]&&(clearTimeout(i[n]),i[n]=void 0),a!==0&&i){let h=setTimeout(()=>{this.#E(n)&&this.#A(this.#l[n],"expire")},a+1);h.unref&&h.unref(),i[n]=h}},this.#R=n=>{s[n]=t[n]!==0?this.#f.now():0},this.#N=(n,a)=>{if(t[a]){let l=t[a],h=s[a];if(!l||!h)return;n.ttl=l,n.start=h,n.now=r||o();let f=n.now-h;n.remainingTTL=l-f}};let r=0,o=()=>{let n=this.#f.now();if(this.ttlResolution>0){r=n;let a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref()}return n};this.getRemainingTTL=n=>{let a=this.#c.get(n);if(a===void 0)return 0;let l=t[a],h=s[a];if(!l||!h)return 1/0;let f=(r||o())-h;return l-f},this.#E=n=>{let a=s[n],l=t[n];return!!l&&!!a&&(r||o())-a>l}}#R=()=>{};#N=()=>{};#L=()=>{};#E=()=>!1;#G(){let t=new Ci(this.#t);this.#p=0,this.#v=t,this.#$=s=>{this.#p-=t[s],t[s]=0},this.#W=(s,i,r,o)=>{if(this.#h(i))return 0;if(!fe(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(i,s),!fe(r))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 r},this.#D=(s,i,r)=>{if(t[s]=i,this.#r){let o=this.#r-t[s];for(;this.#p>o;)this.#U(!0)}this.#p+=t[s],r&&(r.entrySize=i,r.totalCalculatedSize=this.#p)}}#$=t=>{};#D=(t,s,i)=>{};#W=(t,s,i,r)=>{if(i||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#C({allowStale:t=this.allowStale}={}){if(this.#a)for(let s=this.#d;!(!this.#I(s)||((t||!this.#E(s))&&(yield s),s===this.#y));)s=this.#S[s]}*#j({allowStale:t=this.allowStale}={}){if(this.#a)for(let s=this.#y;!(!this.#I(s)||((t||!this.#E(s))&&(yield s),s===this.#d));)s=this.#w[s]}#I(t){return t!==void 0&&this.#c.get(this.#l[t])===t}*entries(){for(let t of this.#C())this.#i[t]!==void 0&&this.#l[t]!==void 0&&!this.#h(this.#i[t])&&(yield[this.#l[t],this.#i[t]])}*rentries(){for(let t of this.#j())this.#i[t]!==void 0&&this.#l[t]!==void 0&&!this.#h(this.#i[t])&&(yield[this.#l[t],this.#i[t]])}*keys(){for(let t of this.#C()){let s=this.#l[t];s!==void 0&&!this.#h(this.#i[t])&&(yield s)}}*rkeys(){for(let t of this.#j()){let s=this.#l[t];s!==void 0&&!this.#h(this.#i[t])&&(yield s)}}*values(){for(let t of this.#C())this.#i[t]!==void 0&&!this.#h(this.#i[t])&&(yield this.#i[t])}*rvalues(){for(let t of this.#j())this.#i[t]!==void 0&&!this.#h(this.#i[t])&&(yield this.#i[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,s={}){for(let i of this.#C()){let r=this.#i[i],o=this.#h(r)?r.__staleWhileFetching:r;if(o!==void 0&&t(o,this.#l[i],this))return this.get(this.#l[i],s)}}forEach(t,s=this){for(let i of this.#C()){let r=this.#i[i],o=this.#h(r)?r.__staleWhileFetching:r;o!==void 0&&t.call(s,o,this.#l[i],this)}}rforEach(t,s=this){for(let i of this.#j()){let r=this.#i[i],o=this.#h(r)?r.__staleWhileFetching:r;o!==void 0&&t.call(s,o,this.#l[i],this)}}purgeStale(){let t=!1;for(let s of this.#j({allowStale:!0}))this.#E(s)&&(this.#A(this.#l[s],"expire"),t=!0);return t}info(t){let s=this.#c.get(t);if(s===void 0)return;let i=this.#i[s],r=this.#h(i)?i.__staleWhileFetching:i;if(r===void 0)return;let o={value:r};if(this.#u&&this.#T){let n=this.#u[s],a=this.#T[s];if(n&&a){let l=n-(this.#f.now()-a);o.ttl=l,o.start=Date.now()}}return this.#v&&(o.size=this.#v[s]),o}dump(){let t=[];for(let s of this.#C({allowStale:!0})){let i=this.#l[s],r=this.#i[s],o=this.#h(r)?r.__staleWhileFetching:r;if(o===void 0||i===void 0)continue;let n={value:o};if(this.#u&&this.#T){n.ttl=this.#u[s];let a=this.#f.now()-this.#T[s];n.start=Math.floor(Date.now()-a)}this.#v&&(n.size=this.#v[s]),t.unshift([i,n])}return t}load(t){this.clear();for(let[s,i]of t){if(i.start){let r=Date.now()-i.start;i.start=this.#f.now()-r}this.set(s,i.value,i)}}set(t,s,i={}){if(s===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:l}=i,{noUpdateTTL:h=this.noUpdateTTL}=i,f=this.#W(t,s,i.size||0,a);if(this.maxEntrySize&&f>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.#A(t,"set"),this;let c=this.#a===0?void 0:this.#c.get(t);if(c===void 0)c=this.#a===0?this.#d:this.#k.length!==0?this.#k.pop():this.#a===this.#t?this.#U(!1):this.#a,this.#l[c]=t,this.#i[c]=s,this.#c.set(t,c),this.#w[this.#d]=c,this.#S[c]=this.#d,this.#d=c,this.#a++,this.#D(c,f,l),l&&(l.set="add"),h=!1,this.#F&&this.#s?.(s,t,"add");else{this.#M(c);let u=this.#i[c];if(s!==u){if(this.#O&&this.#h(u)){u.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=u;p!==void 0&&!n&&(this.#b&&this.#n?.(p,t,"set"),this.#e&&this.#m?.push([p,t,"set"]))}else n||(this.#b&&this.#n?.(u,t,"set"),this.#e&&this.#m?.push([u,t,"set"]));if(this.#$(c),this.#D(c,f,l),this.#i[c]=s,l){l.set="replace";let p=u&&this.#h(u)?u.__staleWhileFetching:u;p!==void 0&&(l.oldValue=p)}}else l&&(l.set="update");this.#F&&this.onInsert?.(s,t,s===u?"update":"replace")}if(r!==0&&!this.#u&&this.#P(),this.#u&&(h||this.#L(c,r,o),l&&this.#N(l,c)),!n&&this.#e&&this.#m){let u=this.#m,p;for(;p=u?.shift();)this.#o?.(...p)}return this}pop(){try{for(;this.#a;){let t=this.#i[this.#y];if(this.#U(!0),this.#h(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#e&&this.#m){let t=this.#m,s;for(;s=t?.shift();)this.#o?.(...s)}}}#U(t){let s=this.#y,i=this.#l[s],r=this.#i[s];return this.#O&&this.#h(r)?r.__abortController.abort(new Error("evicted")):(this.#b||this.#e)&&(this.#b&&this.#n?.(r,i,"evict"),this.#e&&this.#m?.push([r,i,"evict"])),this.#$(s),this.#g?.[s]&&(clearTimeout(this.#g[s]),this.#g[s]=void 0),t&&(this.#l[s]=void 0,this.#i[s]=void 0,this.#k.push(s)),this.#a===1?(this.#y=this.#d=0,this.#k.length=0):this.#y=this.#w[s],this.#c.delete(i),this.#a--,s}has(t,s={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:r}=s,o=this.#c.get(t);if(o!==void 0){let n=this.#i[o];if(this.#h(n)&&n.__staleWhileFetching===void 0)return!1;if(this.#E(o))r&&(r.has="stale",this.#N(r,o));else return i&&this.#R(o),r&&(r.has="hit",this.#N(r,o)),!0}else r&&(r.has="miss");return!1}peek(t,s={}){let{allowStale:i=this.allowStale}=s,r=this.#c.get(t);if(r===void 0||!i&&this.#E(r))return;let o=this.#i[r];return this.#h(o)?o.__staleWhileFetching:o}#z(t,s,i,r){let o=s===void 0?void 0:this.#i[s];if(this.#h(o))return o;let n=new ji,{signal:a}=i;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let l={signal:n.signal,options:i,context:r},h=(m,y=!1)=>{let{aborted:g}=n.signal,w=i.ignoreFetchAbort&&m!==void 0,S=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&m!==void 0);if(i.status&&(g&&!y?(i.status.fetchAborted=!0,i.status.fetchError=n.signal.reason,w&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),g&&!w&&!y)return c(n.signal.reason,S);let b=p,v=this.#i[s];return(v===p||w&&y&&v===void 0)&&(m===void 0?b.__staleWhileFetching!==void 0?this.#i[s]=b.__staleWhileFetching:this.#A(t,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.set(t,m,l.options))),m},f=m=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=m),c(m,!1)),c=(m,y)=>{let{aborted:g}=n.signal,w=g&&i.allowStaleOnFetchAbort,S=w||i.allowStaleOnFetchRejection,b=S||i.noDeleteOnFetchRejection,v=p;if(this.#i[s]===p&&(!b||!y&&v.__staleWhileFetching===void 0?this.#A(t,"fetch"):w||(this.#i[s]=v.__staleWhileFetching)),S)return i.status&&v.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),v.__staleWhileFetching;if(v.__returned===v)throw m},u=(m,y)=>{let g=this.#_?.(t,o,l);g&&g instanceof Promise&&g.then(w=>m(w===void 0?void 0:w),y),n.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(m(void 0),i.allowStaleOnFetchAbort&&(m=w=>h(w,!0)))})};i.status&&(i.status.fetchDispatched=!0);let p=new Promise(u).then(h,f),d=Object.assign(p,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return s===void 0?(this.set(t,d,{...l.options,status:void 0}),s=this.#c.get(t)):this.#i[s]=d,d}#h(t){if(!this.#O)return!1;let s=t;return!!s&&s instanceof Promise&&s.hasOwnProperty("__staleWhileFetching")&&s.__abortController instanceof ji}async fetch(t,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:l=0,sizeCalculation:h=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:c=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:d=this.allowStaleOnFetchAbort,context:m,forceRefresh:y=!1,status:g,signal:w}=s;if(!this.#O)return g&&(g.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:g});let S={allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:l,sizeCalculation:h,noUpdateTTL:f,noDeleteOnFetchRejection:c,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:d,ignoreFetchAbort:p,status:g,signal:w},b=this.#c.get(t);if(b===void 0){g&&(g.fetch="miss");let v=this.#z(t,b,S,m);return v.__returned=v}else{let v=this.#i[b];if(this.#h(v)){let st=i&&v.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",st&&(g.returnedStale=!0)),st?v.__staleWhileFetching:v.__returned=v}let R=this.#E(b);if(!y&&!R)return g&&(g.fetch="hit"),this.#M(b),r&&this.#R(b),g&&this.#N(g,b),v;let $=this.#z(t,b,S,m),q=$.__staleWhileFetching!==void 0&&i;return g&&(g.fetch=R?"stale":"refresh",q&&R&&(g.returnedStale=!0)),q?$.__staleWhileFetching:$.__returned=$}}async forceFetch(t,s={}){let i=await this.fetch(t,s);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,s={}){let i=this.#x;if(!i)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=s,a=this.get(t,n);if(!o&&a!==void 0)return a;let l=i(t,a,{options:n,context:r});return this.set(t,l,n),l}get(t,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=s,a=this.#c.get(t);if(a!==void 0){let l=this.#i[a],h=this.#h(l);return n&&this.#N(n,a),this.#E(a)?(n&&(n.get="stale"),h?(n&&i&&l.__staleWhileFetching!==void 0&&(n.returnedStale=!0),i?l.__staleWhileFetching:void 0):(o||this.#A(t,"expire"),n&&i&&(n.returnedStale=!0),i?l:void 0)):(n&&(n.get="hit"),h?l.__staleWhileFetching:(this.#M(a),r&&this.#R(a),l))}else n&&(n.get="miss")}#B(t,s){this.#S[s]=t,this.#w[t]=s}#M(t){t!==this.#d&&(t===this.#y?this.#y=this.#w[t]:this.#B(this.#S[t],this.#w[t]),this.#B(this.#d,t),this.#d=t)}delete(t){return this.#A(t,"delete")}#A(t,s){let i=!1;if(this.#a!==0){let r=this.#c.get(t);if(r!==void 0)if(this.#g?.[r]&&(clearTimeout(this.#g?.[r]),this.#g[r]=void 0),i=!0,this.#a===1)this.#H(s);else{this.#$(r);let o=this.#i[r];if(this.#h(o)?o.__abortController.abort(new Error("deleted")):(this.#b||this.#e)&&(this.#b&&this.#n?.(o,t,s),this.#e&&this.#m?.push([o,t,s])),this.#c.delete(t),this.#l[r]=void 0,this.#i[r]=void 0,r===this.#d)this.#d=this.#S[r];else if(r===this.#y)this.#y=this.#w[r];else{let n=this.#S[r];this.#w[n]=this.#w[r];let a=this.#w[r];this.#S[a]=this.#S[r]}this.#a--,this.#k.push(r)}}if(this.#e&&this.#m?.length){let r=this.#m,o;for(;o=r?.shift();)this.#o?.(...o)}return i}clear(){return this.#H("delete")}#H(t){for(let s of this.#j({allowStale:!0})){let i=this.#i[s];if(this.#h(i))i.__abortController.abort(new Error("deleted"));else{let r=this.#l[s];this.#b&&this.#n?.(i,r,t),this.#e&&this.#m?.push([i,r,t])}}if(this.#c.clear(),this.#i.fill(void 0),this.#l.fill(void 0),this.#u&&this.#T){this.#u.fill(0),this.#T.fill(0);for(let s of this.#g??[])s!==void 0&&clearTimeout(s);this.#g?.fill(void 0)}if(this.#v&&this.#v.fill(0),this.#y=0,this.#d=0,this.#k.length=0,this.#p=0,this.#a=0,this.#e&&this.#m){let s=this.#m,i;for(;i=s?.shift();)this.#o?.(...i)}}};import{posix as Gm,win32 as jo}from"node:path";import{fileURLToPath as Hm}from"node:url";import{lstatSync as Ym,readdir as qm,readdirSync as Vm,readlinkSync as Jm,realpathSync as Km}from"fs";import*as Xm from"node:fs";import{lstat as Qm,readdir as tg,readlink as eg,realpath as sg}from"node:fs/promises";import{EventEmitter as Ro}from"node:events";import Hl from"node:stream";import{StringDecoder as Fm}from"node:string_decoder";var Ul=typeof process=="object"&&process?process:{stdout:null,stderr:null},Dm=e=>!!e&&typeof e=="object"&&(e instanceof Be||e instanceof Hl||Mm(e)||$m(e)),Mm=e=>!!e&&typeof e=="object"&&e instanceof Ro&&typeof e.pipe=="function"&&e.pipe!==Hl.Writable.prototype.pipe,$m=e=>!!e&&typeof e=="object"&&e instanceof Ro&&typeof e.write=="function"&&typeof e.end=="function",te=Symbol("EOF"),ee=Symbol("maybeEmitEnd"),ue=Symbol("emittedEnd"),Pi=Symbol("emittingEnd"),Ns=Symbol("emittedError"),Ni=Symbol("closed"),zl=Symbol("read"),Fi=Symbol("flush"),Bl=Symbol("flushChunk"),Dt=Symbol("encoding"),Ue=Symbol("decoder"),B=Symbol("flowing"),Fs=Symbol("paused"),ze=Symbol("resume"),G=Symbol("buffer"),at=Symbol("pipes"),H=Symbol("bufferLength"),Eo=Symbol("bufferPush"),Di=Symbol("bufferShift"),X=Symbol("objectMode"),M=Symbol("destroyed"),xo=Symbol("error"),To=Symbol("emitData"),Gl=Symbol("emitEnd"),_o=Symbol("emitEnd2"),Yt=Symbol("async"),ko=Symbol("abort"),Mi=Symbol("aborted"),Ds=Symbol("signal"),Te=Symbol("dataListeners"),wt=Symbol("discarded"),Ms=e=>Promise.resolve().then(e),Lm=e=>e(),Wm=e=>e==="end"||e==="finish"||e==="prefinish",Im=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,Um=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),$i=class{src;dest;opts;ondrain;constructor(t,s,i){this.src=t,this.dest=s,this.opts=i,this.ondrain=()=>t[ze](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Oo=class extends $i{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,s,i){super(t,s,i),this.proxyErrors=r=>s.emit("error",r),t.on("error",this.proxyErrors)}},zm=e=>!!e.objectMode,Bm=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",Be=class extends Ro{[B]=!1;[Fs]=!1;[at]=[];[G]=[];[X];[Dt];[Yt];[Ue];[te]=!1;[ue]=!1;[Pi]=!1;[Ni]=!1;[Ns]=null;[H]=0;[M]=!1;[Ds];[Mi]=!1;[Te]=0;[wt]=!1;writable=!0;readable=!0;constructor(...t){let s=t[0]||{};if(super(),s.objectMode&&typeof s.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");zm(s)?(this[X]=!0,this[Dt]=null):Bm(s)?(this[Dt]=s.encoding,this[X]=!1):(this[X]=!1,this[Dt]=null),this[Yt]=!!s.async,this[Ue]=this[Dt]?new Fm(this[Dt]):null,s&&s.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[G]}),s&&s.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[at]});let{signal:i}=s;i&&(this[Ds]=i,i.aborted?this[ko]():i.addEventListener("abort",()=>this[ko]()))}get bufferLength(){return this[H]}get encoding(){return this[Dt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[X]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Yt]}set async(t){this[Yt]=this[Yt]||!!t}[ko](){this[Mi]=!0,this.emit("abort",this[Ds]?.reason),this.destroy(this[Ds]?.reason)}get aborted(){return this[Mi]}set aborted(t){}write(t,s,i){if(this[Mi])return!1;if(this[te])throw new Error("write after end");if(this[M])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof s=="function"&&(i=s,s="utf8"),s||(s="utf8");let r=this[Yt]?Ms:Lm;if(!this[X]&&!Buffer.isBuffer(t)){if(Um(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Im(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[X]?(this[B]&&this[H]!==0&&this[Fi](!0),this[B]?this.emit("data",t):this[Eo](t),this[H]!==0&&this.emit("readable"),i&&r(i),this[B]):t.length?(typeof t=="string"&&!(s===this[Dt]&&!this[Ue]?.lastNeed)&&(t=Buffer.from(t,s)),Buffer.isBuffer(t)&&this[Dt]&&(t=this[Ue].write(t)),this[B]&&this[H]!==0&&this[Fi](!0),this[B]?this.emit("data",t):this[Eo](t),this[H]!==0&&this.emit("readable"),i&&r(i),this[B]):(this[H]!==0&&this.emit("readable"),i&&r(i),this[B])}read(t){if(this[M])return null;if(this[wt]=!1,this[H]===0||t===0||t&&t>this[H])return this[ee](),null;this[X]&&(t=null),this[G].length>1&&!this[X]&&(this[G]=[this[Dt]?this[G].join(""):Buffer.concat(this[G],this[H])]);let s=this[zl](t||null,this[G][0]);return this[ee](),s}[zl](t,s){if(this[X])this[Di]();else{let i=s;t===i.length||t===null?this[Di]():typeof i=="string"?(this[G][0]=i.slice(t),s=i.slice(0,t),this[H]-=t):(this[G][0]=i.subarray(t),s=i.subarray(0,t),this[H]-=t)}return this.emit("data",s),!this[G].length&&!this[te]&&this.emit("drain"),s}end(t,s,i){return typeof t=="function"&&(i=t,t=void 0),typeof s=="function"&&(i=s,s="utf8"),t!==void 0&&this.write(t,s),i&&this.once("end",i),this[te]=!0,this.writable=!1,(this[B]||!this[Fs])&&this[ee](),this}[ze](){this[M]||(!this[Te]&&!this[at].length&&(this[wt]=!0),this[Fs]=!1,this[B]=!0,this.emit("resume"),this[G].length?this[Fi]():this[te]?this[ee]():this.emit("drain"))}resume(){return this[ze]()}pause(){this[B]=!1,this[Fs]=!0,this[wt]=!1}get destroyed(){return this[M]}get flowing(){return this[B]}get paused(){return this[Fs]}[Eo](t){this[X]?this[H]+=1:this[H]+=t.length,this[G].push(t)}[Di](){return this[X]?this[H]-=1:this[H]-=this[G][0].length,this[G].shift()}[Fi](t=!1){do;while(this[Bl](this[Di]())&&this[G].length);!t&&!this[G].length&&!this[te]&&this.emit("drain")}[Bl](t){return this.emit("data",t),this[B]}pipe(t,s){if(this[M])return t;this[wt]=!1;let i=this[ue];return s=s||{},t===Ul.stdout||t===Ul.stderr?s.end=!1:s.end=s.end!==!1,s.proxyErrors=!!s.proxyErrors,i?s.end&&t.end():(this[at].push(s.proxyErrors?new Oo(this,t,s):new $i(this,t,s)),this[Yt]?Ms(()=>this[ze]()):this[ze]()),t}unpipe(t){let s=this[at].find(i=>i.dest===t);s&&(this[at].length===1?(this[B]&&this[Te]===0&&(this[B]=!1),this[at]=[]):this[at].splice(this[at].indexOf(s),1),s.unpipe())}addListener(t,s){return this.on(t,s)}on(t,s){let i=super.on(t,s);if(t==="data")this[wt]=!1,this[Te]++,!this[at].length&&!this[B]&&this[ze]();else if(t==="readable"&&this[H]!==0)super.emit("readable");else if(Wm(t)&&this[ue])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Ns]){let r=s;this[Yt]?Ms(()=>r.call(this,this[Ns])):r.call(this,this[Ns])}return i}removeListener(t,s){return this.off(t,s)}off(t,s){let i=super.off(t,s);return t==="data"&&(this[Te]=this.listeners("data").length,this[Te]===0&&!this[wt]&&!this[at].length&&(this[B]=!1)),i}removeAllListeners(t){let s=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Te]=0,!this[wt]&&!this[at].length&&(this[B]=!1)),s}get emittedEnd(){return this[ue]}[ee](){!this[Pi]&&!this[ue]&&!this[M]&&this[G].length===0&&this[te]&&(this[Pi]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ni]&&this.emit("close"),this[Pi]=!1)}emit(t,...s){let i=s[0];if(t!=="error"&&t!=="close"&&t!==M&&this[M])return!1;if(t==="data")return!this[X]&&!i?!1:this[Yt]?(Ms(()=>this[To](i)),!0):this[To](i);if(t==="end")return this[Gl]();if(t==="close"){if(this[Ni]=!0,!this[ue]&&!this[M])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Ns]=i,super.emit(xo,i);let o=!this[Ds]||this.listeners("error").length?super.emit("error",i):!1;return this[ee](),o}else if(t==="resume"){let o=super.emit("resume");return this[ee](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let r=super.emit(t,...s);return this[ee](),r}[To](t){for(let i of this[at])i.dest.write(t)===!1&&this.pause();let s=this[wt]?!1:super.emit("data",t);return this[ee](),s}[Gl](){return this[ue]?!1:(this[ue]=!0,this.readable=!1,this[Yt]?(Ms(()=>this[_o]()),!0):this[_o]())}[_o](){if(this[Ue]){let s=this[Ue].end();if(s){for(let i of this[at])i.dest.write(s);this[wt]||super.emit("data",s)}}for(let s of this[at])s.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[X]||(t.dataLength=0);let s=this.promise();return this.on("data",i=>{t.push(i),this[X]||(t.dataLength+=i.length)}),await s,t}async concat(){if(this[X])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[Dt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,s)=>{this.on(M,()=>s(new Error("stream destroyed"))),this.on("error",i=>s(i)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[wt]=!1;let t=!1,s=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return s();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[te])return s();let o,n,a=c=>{this.off("data",l),this.off("end",h),this.off(M,f),s(),n(c)},l=c=>{this.off("error",a),this.off("end",h),this.off(M,f),this.pause(),o({value:c,done:!!this[te]})},h=()=>{this.off("error",a),this.off("data",l),this.off(M,f),s(),o({done:!0,value:void 0})},f=()=>a(new Error("stream destroyed"));return new Promise((c,u)=>{n=u,o=c,this.once(M,f),this.once("error",a),this.once("end",h),this.once("data",l)})},throw:s,return:s,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[wt]=!1;let t=!1,s=()=>(this.pause(),this.off(xo,s),this.off(M,s),this.off("end",s),t=!0,{done:!0,value:void 0}),i=()=>{if(t)return s();let r=this.read();return r===null?s():{done:!1,value:r}};return this.once("end",s),this.once(xo,s),this.once(M,s),{next:i,throw:s,return:s,[Symbol.iterator](){return this}}}destroy(t){if(this[M])return t?this.emit("error",t):this.emit(M),this;this[M]=!0,this[wt]=!0,this[G].length=0,this[H]=0;let s=this;return typeof s.close=="function"&&!this[Ni]&&s.close(),t?this.emit("error",t):this.emit(M),this}static get isStream(){return Dm}};var Zm=Km.native,Ls={lstatSync:Ym,readdir:qm,readdirSync:Vm,readlinkSync:Jm,realpathSync:Zm,promises:{lstat:Qm,readdir:tg,readlink:eg,realpath:sg}},Kl=e=>!e||e===Ls||e===Xm?Ls:{...Ls,...e,promises:{...Ls.promises,...e.promises||{}}},Xl=/^\\\\\?\\([a-z]:)\\?$/i,ig=e=>e.replace(/\//g,"\\").replace(Xl,"$1\\"),rg=/[\\\/]/,Rt=0,Zl=1,Ql=2,qt=4,th=6,eh=8,_e=10,sh=12,Ot=15,$s=~Ot,Ao=16,Yl=32,Ws=64,Mt=128,Li=256,Ii=512,ql=Ws|Mt|Ii,og=1023,Co=e=>e.isFile()?eh:e.isDirectory()?qt:e.isSymbolicLink()?_e:e.isCharacterDevice()?Ql:e.isBlockDevice()?th:e.isSocket()?sh:e.isFIFO()?Zl:Rt,Vl=new Ps({max:2**12}),Is=e=>{let t=Vl.get(e);if(t)return t;let s=e.normalize("NFKD");return Vl.set(e,s),s},Jl=new Ps({max:2**12}),Wi=e=>{let t=Jl.get(e);if(t)return t;let s=Is(e.toLowerCase());return Jl.set(e,s),s},Ui=class extends Ps{constructor(){super({max:256})}},Po=class extends Ps{constructor(t=16*1024){super({maxSize:t,sizeCalculation:s=>s.length+1})}},ih=Symbol("PathScurry setAsCwd"),Z=class{name;root;roots;parent;nocase;isCWD=!1;#t;#r;get dev(){return this.#r}#n;get mode(){return this.#n}#s;get nlink(){return this.#s}#o;get uid(){return this.#o}#_;get gid(){return this.#_}#x;get rdev(){return this.#x}#f;get blksize(){return this.#f}#a;get ino(){return this.#a}#p;get size(){return this.#p}#c;get blocks(){return this.#c}#l;get atimeMs(){return this.#l}#i;get mtimeMs(){return this.#i}#w;get ctimeMs(){return this.#w}#S;get birthtimeMs(){return this.#S}#y;get atime(){return this.#y}#d;get mtime(){return this.#d}#k;get ctime(){return this.#k}#m;get birthtime(){return this.#m}#v;#T;#u;#g;#b;#O;#e;#F;#P;#R;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,s=Rt,i,r,o,n,a){this.name=t,this.#v=o?Wi(t):Is(t),this.#e=s&og,this.nocase=o,this.roots=r,this.root=i||this,this.#F=n,this.#u=a.fullpath,this.#b=a.relative,this.#O=a.relativePosix,this.parent=a.parent,this.parent?this.#t=this.parent.#t:this.#t=Kl(a.fs)}depth(){return this.#T!==void 0?this.#T:this.parent?this.#T=this.parent.depth()+1:this.#T=0}childrenCache(){return this.#F}resolve(t){if(!t)return this;let s=this.getRootString(t),r=t.substring(s.length).split(this.splitSep);return s?this.getRoot(s).#N(r):this.#N(r)}#N(t){let s=this;for(let i of t)s=s.child(i);return s}children(){let t=this.#F.get(this);if(t)return t;let s=Object.assign([],{provisional:0});return this.#F.set(this,s),this.#e&=~Ao,s}child(t,s){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let i=this.children(),r=this.nocase?Wi(t):Is(t);for(let l of i)if(l.#v===r)return l;let o=this.parent?this.sep:"",n=this.#u?this.#u+o+t:void 0,a=this.newChild(t,Rt,{...s,parent:this,fullpath:n});return this.canReaddir()||(a.#e|=Mt),i.push(a),a}relative(){if(this.isCWD)return"";if(this.#b!==void 0)return this.#b;let t=this.name,s=this.parent;if(!s)return this.#b=this.name;let i=s.relative();return i+(!i||!s.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#O!==void 0)return this.#O;let t=this.name,s=this.parent;if(!s)return this.#O=this.fullpathPosix();let i=s.relativePosix();return i+(!i||!s.parent?"":"/")+t}fullpath(){if(this.#u!==void 0)return this.#u;let t=this.name,s=this.parent;if(!s)return this.#u=this.name;let r=s.fullpath()+(s.parent?this.sep:"")+t;return this.#u=r}fullpathPosix(){if(this.#g!==void 0)return this.#g;if(this.sep==="/")return this.#g=this.fullpath();if(!this.parent){let r=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(r)?this.#g=`//?/${r}`:this.#g=r}let t=this.parent,s=t.fullpathPosix(),i=s+(!s||!t.parent?"":"/")+this.name;return this.#g=i}isUnknown(){return(this.#e&Ot)===Rt}isType(t){return this[`is${t}`]()}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.#e&Ot)===eh}isDirectory(){return(this.#e&Ot)===qt}isCharacterDevice(){return(this.#e&Ot)===Ql}isBlockDevice(){return(this.#e&Ot)===th}isFIFO(){return(this.#e&Ot)===Zl}isSocket(){return(this.#e&Ot)===sh}isSymbolicLink(){return(this.#e&_e)===_e}lstatCached(){return this.#e&Yl?this:void 0}readlinkCached(){return this.#P}realpathCached(){return this.#R}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#P)return!0;if(!this.parent)return!1;let t=this.#e&Ot;return!(t!==Rt&&t!==_e||this.#e&Li||this.#e&Mt)}calledReaddir(){return!!(this.#e&Ao)}isENOENT(){return!!(this.#e&Mt)}isNamed(t){return this.nocase?this.#v===Wi(t):this.#v===Is(t)}async readlink(){let t=this.#P;if(t)return t;if(this.canReadlink()&&this.parent)try{let s=await this.#t.promises.readlink(this.fullpath()),i=(await this.parent.realpath())?.resolve(s);if(i)return this.#P=i}catch(s){this.#j(s.code);return}}readlinkSync(){let t=this.#P;if(t)return t;if(this.canReadlink()&&this.parent)try{let s=this.#t.readlinkSync(this.fullpath()),i=this.parent.realpathSync()?.resolve(s);if(i)return this.#P=i}catch(s){this.#j(s.code);return}}#L(t){this.#e|=Ao;for(let s=t.provisional;s<t.length;s++){let i=t[s];i&&i.#E()}}#E(){this.#e&Mt||(this.#e=(this.#e|Mt)&$s,this.#G())}#G(){let t=this.children();t.provisional=0;for(let s of t)s.#E()}#$(){this.#e|=Ii,this.#D()}#D(){if(this.#e&Ws)return;let t=this.#e;(t&Ot)===qt&&(t&=$s),this.#e=t|Ws,this.#G()}#W(t=""){t==="ENOTDIR"||t==="EPERM"?this.#D():t==="ENOENT"?this.#E():this.children().provisional=0}#C(t=""){t==="ENOTDIR"?this.parent.#D():t==="ENOENT"&&this.#E()}#j(t=""){let s=this.#e;s|=Li,t==="ENOENT"&&(s|=Mt),(t==="EINVAL"||t==="UNKNOWN")&&(s&=$s),this.#e=s,t==="ENOTDIR"&&this.parent&&this.parent.#D()}#I(t,s){return this.#z(t,s)||this.#U(t,s)}#U(t,s){let i=Co(t),r=this.newChild(t.name,i,{parent:this}),o=r.#e&Ot;return o!==qt&&o!==_e&&o!==Rt&&(r.#e|=Ws),s.unshift(r),s.provisional++,r}#z(t,s){for(let i=s.provisional;i<s.length;i++){let r=s[i];if((this.nocase?Wi(t.name):Is(t.name))===r.#v)return this.#h(t,r,i,s)}}#h(t,s,i,r){let o=s.name;return s.#e=s.#e&$s|Co(t),o!==t.name&&(s.name=t.name),i!==r.provisional&&(i===r.length-1?r.pop():r.splice(i,1),r.unshift(s)),r.provisional++,s}async lstat(){if((this.#e&Mt)===0)try{return this.#B(await this.#t.promises.lstat(this.fullpath())),this}catch(t){this.#C(t.code)}}lstatSync(){if((this.#e&Mt)===0)try{return this.#B(this.#t.lstatSync(this.fullpath())),this}catch(t){this.#C(t.code)}}#B(t){let{atime:s,atimeMs:i,birthtime:r,birthtimeMs:o,blksize:n,blocks:a,ctime:l,ctimeMs:h,dev:f,gid:c,ino:u,mode:p,mtime:d,mtimeMs:m,nlink:y,rdev:g,size:w,uid:S}=t;this.#y=s,this.#l=i,this.#m=r,this.#S=o,this.#f=n,this.#c=a,this.#k=l,this.#w=h,this.#r=f,this.#_=c,this.#a=u,this.#n=p,this.#d=d,this.#i=m,this.#s=y,this.#x=g,this.#p=w,this.#o=S;let b=Co(t);this.#e=this.#e&$s|b|Yl,b!==Rt&&b!==qt&&b!==_e&&(this.#e|=Ws)}#M=[];#A=!1;#H(t){this.#A=!1;let s=this.#M.slice();this.#M.length=0,s.forEach(i=>i(null,t))}readdirCB(t,s=!1){if(!this.canReaddir()){s?t(null,[]):queueMicrotask(()=>t(null,[]));return}let i=this.children();if(this.calledReaddir()){let o=i.slice(0,i.provisional);s?t(null,o):queueMicrotask(()=>t(null,o));return}if(this.#M.push(t),this.#A)return;this.#A=!0;let r=this.fullpath();this.#t.readdir(r,{withFileTypes:!0},(o,n)=>{if(o)this.#W(o.code),i.provisional=0;else{for(let a of n)this.#I(a,i);this.#L(i)}this.#H(i.slice(0,i.provisional))})}#Y;async readdir(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let s=this.fullpath();if(this.#Y)await this.#Y;else{let i=()=>{};this.#Y=new Promise(r=>i=r);try{for(let r of await this.#t.promises.readdir(s,{withFileTypes:!0}))this.#I(r,t);this.#L(t)}catch(r){this.#W(r.code),t.provisional=0}this.#Y=void 0,i()}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let s=this.fullpath();try{for(let i of this.#t.readdirSync(s,{withFileTypes:!0}))this.#I(i,t);this.#L(t)}catch(i){this.#W(i.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#e&ql)return!1;let t=Ot&this.#e;return t===Rt||t===qt||t===_e}shouldWalk(t,s){return(this.#e&qt)===qt&&!(this.#e&ql)&&!t.has(this)&&(!s||s(this))}async realpath(){if(this.#R)return this.#R;if(!((Ii|Li|Mt)&this.#e))try{let t=await this.#t.promises.realpath(this.fullpath());return this.#R=this.resolve(t)}catch{this.#$()}}realpathSync(){if(this.#R)return this.#R;if(!((Ii|Li|Mt)&this.#e))try{let t=this.#t.realpathSync(this.fullpath());return this.#R=this.resolve(t)}catch{this.#$()}}[ih](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let s=new Set([]),i=[],r=this;for(;r&&r.parent;)s.add(r),r.#b=i.join(this.sep),r.#O=i.join("/"),r=r.parent,i.push("..");for(r=t;r&&r.parent&&!s.has(r);)r.#b=void 0,r.#O=void 0,r=r.parent}},zi=class e extends Z{sep="\\";splitSep=rg;constructor(t,s=Rt,i,r,o,n,a){super(t,s,i,r,o,n,a)}newChild(t,s=Rt,i={}){return new e(t,s,this.root,this.roots,this.nocase,this.childrenCache(),i)}getRootString(t){return jo.parse(t).root}getRoot(t){if(t=ig(t.toUpperCase()),t===this.root.name)return this.root;for(let[s,i]of Object.entries(this.roots))if(this.sameRoot(t,s))return this.roots[t]=i;return this.roots[t]=new Hi(t,this).root}sameRoot(t,s=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(Xl,"$1\\"),t===s}},Bi=class e extends Z{splitSep="/";sep="/";constructor(t,s=Rt,i,r,o,n,a){super(t,s,i,r,o,n,a)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,s=Rt,i={}){return new e(t,s,this.root,this.roots,this.nocase,this.childrenCache(),i)}},Gi=class{root;rootPath;roots;cwd;#t;#r;#n;nocase;#s;constructor(t=process.cwd(),s,i,{nocase:r,childrenCacheSize:o=16*1024,fs:n=Ls}={}){this.#s=Kl(n),(t instanceof URL||t.startsWith("file://"))&&(t=Hm(t));let a=s.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),this.#t=new Ui,this.#r=new Ui,this.#n=new Po(o);let l=a.substring(this.rootPath.length).split(i);if(l.length===1&&!l[0]&&l.pop(),r===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=r,this.root=this.newRoot(this.#s),this.roots[this.rootPath]=this.root;let h=this.root,f=l.length-1,c=s.sep,u=this.rootPath,p=!1;for(let d of l){let m=f--;h=h.child(d,{relative:new Array(m).fill("..").join(c),relativePosix:new Array(m).fill("..").join("/"),fullpath:u+=(p?"":c)+d}),p=!0}this.cwd=h}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#n}resolve(...t){let s="";for(let o=t.length-1;o>=0;o--){let n=t[o];if(!(!n||n===".")&&(s=s?`${n}/${s}`:n,this.isAbsolute(n)))break}let i=this.#t.get(s);if(i!==void 0)return i;let r=this.cwd.resolve(s).fullpath();return this.#t.set(s,r),r}resolvePosix(...t){let s="";for(let o=t.length-1;o>=0;o--){let n=t[o];if(!(!n||n===".")&&(s=s?`${n}/${s}`:n,this.isAbsolute(n)))break}let i=this.#r.get(s);if(i!==void 0)return i;let r=this.cwd.resolve(s).fullpathPosix();return this.#r.set(s,r),r}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,s={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t,t=this.cwd);let{withFileTypes:i}=s;if(t.canReaddir()){let r=await t.readdir();return i?r:r.map(o=>o.name)}else return[]}readdirSync(t=this.cwd,s={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t,t=this.cwd);let{withFileTypes:i=!0}=s;return t.canReaddir()?i?t.readdirSync():t.readdirSync().map(r=>r.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:s}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t.withFileTypes,t=this.cwd);let i=await t.readlink();return s?i:i?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:s}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t.withFileTypes,t=this.cwd);let i=t.readlinkSync();return s?i:i?.fullpath()}async realpath(t=this.cwd,{withFileTypes:s}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t.withFileTypes,t=this.cwd);let i=await t.realpath();return s?i:i?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:s}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t.withFileTypes,t=this.cwd);let i=t.realpathSync();return s?i:i?.fullpath()}async walk(t=this.cwd,s={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:o,walkFilter:n}=s,a=[];(!o||o(t))&&a.push(i?t:t.fullpath());let l=new Set,h=(c,u)=>{l.add(c),c.readdirCB((p,d)=>{if(p)return u(p);let m=d.length;if(!m)return u();let y=()=>{--m===0&&u()};for(let g of d)(!o||o(g))&&a.push(i?g:g.fullpath()),r&&g.isSymbolicLink()?g.realpath().then(w=>w?.isUnknown()?w.lstat():w).then(w=>w?.shouldWalk(l,n)?h(w,y):y()):g.shouldWalk(l,n)?h(g,y):y()},!0)},f=t;return new Promise((c,u)=>{h(f,p=>{if(p)return u(p);c(a)})})}walkSync(t=this.cwd,s={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:o,walkFilter:n}=s,a=[];(!o||o(t))&&a.push(i?t:t.fullpath());let l=new Set([t]);for(let h of l){let f=h.readdirSync();for(let c of f){(!o||o(c))&&a.push(i?c:c.fullpath());let u=c;if(c.isSymbolicLink()){if(!(r&&(u=c.realpathSync())))continue;u.isUnknown()&&u.lstatSync()}u.shouldWalk(l,n)&&l.add(u)}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,s={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t,t=this.cwd),this.stream(t,s)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,s={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:o,walkFilter:n}=s;(!o||o(t))&&(yield i?t:t.fullpath());let a=new Set([t]);for(let l of a){let h=l.readdirSync();for(let f of h){(!o||o(f))&&(yield i?f:f.fullpath());let c=f;if(f.isSymbolicLink()){if(!(r&&(c=f.realpathSync())))continue;c.isUnknown()&&c.lstatSync()}c.shouldWalk(a,n)&&a.add(c)}}}stream(t=this.cwd,s={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:o,walkFilter:n}=s,a=new Be({objectMode:!0});(!o||o(t))&&a.write(i?t:t.fullpath());let l=new Set,h=[t],f=0,c=()=>{let u=!1;for(;!u;){let p=h.shift();if(!p){f===0&&a.end();return}f++,l.add(p);let d=(y,g,w=!1)=>{if(y)return a.emit("error",y);if(r&&!w){let S=[];for(let b of g)b.isSymbolicLink()&&S.push(b.realpath().then(v=>v?.isUnknown()?v.lstat():v));if(S.length){Promise.all(S).then(()=>d(null,g,!0));return}}for(let S of g)S&&(!o||o(S))&&(a.write(i?S:S.fullpath())||(u=!0));f--;for(let S of g){let b=S.realpathCached()||S;b.shouldWalk(l,n)&&h.push(b)}u&&!a.flowing?a.once("drain",c):m||c()},m=!0;p.readdirCB(d,!0),m=!1}};return c(),a}streamSync(t=this.cwd,s={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:o,walkFilter:n}=s,a=new Be({objectMode:!0}),l=new Set;(!o||o(t))&&a.write(i?t:t.fullpath());let h=[t],f=0,c=()=>{let u=!1;for(;!u;){let p=h.shift();if(!p){f===0&&a.end();return}f++,l.add(p);let d=p.readdirSync();for(let m of d)(!o||o(m))&&(a.write(i?m:m.fullpath())||(u=!0));f--;for(let m of d){let y=m;if(m.isSymbolicLink()){if(!(r&&(y=m.realpathSync())))continue;y.isUnknown()&&y.lstatSync()}y.shouldWalk(l,n)&&h.push(y)}}u&&!a.flowing&&a.once("drain",c)};return c(),a}chdir(t=this.cwd){let s=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[ih](s)}},Hi=class extends Gi{sep="\\";constructor(t=process.cwd(),s={}){let{nocase:i=!0}=s;super(t,jo,"\\",{...s,nocase:i}),this.nocase=i;for(let r=this.cwd;r;r=r.parent)r.nocase=this.nocase}parseRootPath(t){return jo.parse(t).root.toUpperCase()}newRoot(t){return new zi(this.rootPath,qt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},Yi=class extends Gi{sep="/";constructor(t=process.cwd(),s={}){let{nocase:i=!1}=s;super(t,Gm,"/",{...s,nocase:i}),this.nocase=i}parseRootPath(t){return"/"}newRoot(t){return new Bi(this.rootPath,qt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},No=class extends Yi{constructor(t=process.cwd(),s={}){let{nocase:i=!0}=s;super(t,{...s,nocase:i})}},LE=process.platform==="win32"?zi:Bi,rh=process.platform==="win32"?Hi:process.platform==="darwin"?No:Yi;var pe=(e,t)=>typeof e>"u"||typeof e===t,oh=e=>!!e&&typeof e=="object"&&pe(e.preserveRoot,"boolean")&&pe(e.tmp,"string")&&pe(e.maxRetries,"number")&&pe(e.retryDelay,"number")&&pe(e.backoff,"number")&&pe(e.maxBackoff,"number")&&(pe(e.glob,"boolean")||e.glob&&typeof e.glob=="object")&&pe(e.filter,"function"),nh=e=>{if(!oh(e))throw new Error("invalid rimraf options")},ah=e=>{nh(e);let{glob:t,...s}=e;if(!t)return s;let i=t===!0?e.signal?{signal:e.signal}:{}:e.signal?{signal:e.signal,...t}:t;return{...s,glob:{...i,absolute:!0,withFileTypes:!1}}},lh=(e={})=>ah(e),hh=(e={})=>ah(e);import{parse as ch,resolve as ng}from"path";import{inspect as ag}from"util";var lg=(e,t={})=>{let s=typeof e;if(s!=="string"){let r=e&&s==="object"&&e.constructor,n=`The "path" argument must be of type string. Received ${r&&r.name?`an instance of ${r.name}`:s==="object"?ag(e):`type ${s} ${e}`}`;throw Object.assign(new TypeError(n),{path:e,code:"ERR_INVALID_ARG_TYPE"})}if(/\0/.test(e)){let r="path must be a string without null bytes";throw Object.assign(new TypeError(r),{path:e,code:"ERR_INVALID_ARG_VALUE"})}e=ng(e);let{root:i}=ch(e);if(e===i&&t.preserveRoot!==!1){let r="refusing to remove root directory without preserveRoot:false";throw Object.assign(new Error(r),{path:e,code:"ERR_PRESERVE_ROOT"})}if(process.platform==="win32"){let r=/[*|"<>?:]/,{root:o}=ch(e);if(r.test(e.substring(o.length)))throw Object.assign(new Error("Illegal characters in path."),{path:e,code:"EINVAL"})}return e},Us=lg;import{readdirSync as hg}from"fs";import se from"fs/promises";import{chmodSync as uh,mkdirSync as VE,renameSync as ph,rmdirSync as Ge,rmSync as dh,statSync as mh,lstatSync as He,unlinkSync as Ye}from"fs";var fh=e=>hg(e,{withFileTypes:!0}),ut={chmod:se.chmod,mkdir:se.mkdir,readdir:e=>se.readdir(e,{withFileTypes:!0}),rename:se.rename,rm:se.rm,rmdir:se.rmdir,stat:se.stat,lstat:se.lstat,unlink:se.unlink};import{parse as yh,resolve as wh}from"path";var{readdir:cg}=ut,qe=e=>cg(e).catch(t=>t),Ve=e=>{try{return fh(e)}catch(t){return t}};var gh=e=>!!e&&typeof e=="object",Fo=(e,t)=>t in e&&typeof e[t]=="string",Do=e=>gh(e)&&Fo(e,"code")&&Fo(e,"path"),P=e=>gh(e)&&Fo(e,"code")?e.code:null;var lt=async(e,t)=>e.catch(s=>{if(P(s)!=="ENOENT")throw t??s}),ht=(e,t)=>{try{return e()}catch(s){if(P(s)==="ENOENT")return;throw t??s}};var{lstat:fg,rmdir:ug,unlink:pg}=ut,qi=async(e,t)=>(t?.signal?.throwIfAborted(),await lt(fg(e).then(s=>bh(e,t,s)))??!0),Vi=(e,t)=>(t?.signal?.throwIfAborted(),ht(()=>Sh(e,t,He(e)))??!0),bh=async(e,t,s)=>{t?.signal?.throwIfAborted();let i=s.isDirectory()?await qe(e):null;if(!Array.isArray(i)){if(i){if(P(i)==="ENOENT")return!0;if(P(i)!=="ENOTDIR")throw i}return t.filter&&!await t.filter(e,s)?!1:(await lt(pg(e)),!0)}return!(await Promise.all(i.map(o=>bh(wh(e,o.name),t,o)))).every(o=>o===!0)||t.preserveRoot===!1&&e===yh(e).root||t.filter&&!await t.filter(e,s)?!1:(await lt(ug(e)),!0)},Sh=(e,t,s)=>{t?.signal?.throwIfAborted();let i=s.isDirectory()?Ve(e):null;if(!Array.isArray(i)){if(i){if(P(i)==="ENOENT")return!0;if(P(i)!=="ENOTDIR")throw i}return t.filter&&!t.filter(e,s)?!1:(ht(()=>Ye(e)),!0)}let r=!0;for(let o of i){let n=wh(e,o.name);r=Sh(n,t,o)&&r}return t.preserveRoot===!1&&e===yh(e).root||!r||t.filter&&!t.filter(e,s)?!1:(ht(()=>Ge(e)),!0)};import{parse as Ah,resolve as Ch}from"path";var{chmod:dg}=ut,zs=e=>async t=>{try{return void await lt(e(t))}catch(s){if(P(s)==="EPERM")return await lt(dg(t,438).then(()=>!0),s)?void await e(t):void 0;throw s}},Bs=e=>t=>{try{return void ht(()=>e(t))}catch(s){if(P(s)==="EPERM")return ht(()=>(uh(t,438),!0),s)?void e(t):void 0;throw s}};import{setTimeout as mg}from"timers/promises";var gg=200,yg=1.2,vh=10,Eh=new Set(["EMFILE","ENFILE","EBUSY"]),Mo=e=>{let t=async(s,i,r=1,o=0)=>{let n=i.maxBackoff||gg,a=i.backoff||yg,l=i.maxRetries||vh,h=0;for(;;)try{return await e(s)}catch(f){if(Do(f)&&f.path===s&&Eh.has(f.code)){if(r=Math.ceil(r*a),o=r+o,o<n)return await mg(r),t(s,i,r,o);if(h<l){h++;continue}}throw f}};return t},$o=e=>(s,i)=>{let r=i.maxRetries||vh,o=0;for(;;)try{return e(s)}catch(n){if(Do(n)&&n.path===s&&Eh.has(n.code)&&o<r){o++;continue}throw n}};import{basename as _g,parse as Xi,resolve as Zi}from"path";import{tmpdir as Ki}from"os";import{parse as Ji,resolve as xh}from"path";var{stat:wg}=ut,bg=e=>{try{return mh(e).isDirectory()}catch{return!1}},Sg=e=>wg(e).then(t=>t.isDirectory(),()=>!1),vg=async e=>{let{root:t}=Ji(e),s=Ki(),{root:i}=Ji(s);if(t.toLowerCase()===i.toLowerCase())return s;let r=xh(t,"/temp");return await Sg(r)?r:t},Eg=e=>{let{root:t}=Ji(e),s=Ki(),{root:i}=Ji(s);if(t.toLowerCase()===i.toLowerCase())return s;let r=xh(t,"/temp");return bg(r)?r:t},xg=async()=>Ki(),Tg=()=>Ki(),Th=process.platform==="win32"?vg:xg,_h=process.platform==="win32"?Eg:Tg;var{lstat:kg,rename:Og,unlink:Rg,rmdir:Ag}=ut,Rh=e=>`.${_g(e)}.${Math.random()}`,Cg=zs(Rg),jg=Bs(Ye),Qi=async(e,t)=>(t?.signal?.throwIfAborted(),await lt(kg(e).then(s=>Lo(e,t,s)))??!0),Lo=async(e,t,s)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return Lo(e,{...t,tmp:await Th(e)},s);if(e===t.tmp&&Xi(e).root!==e)throw new Error("cannot delete temp directory used for deletion");let i=s.isDirectory()?await qe(e):null;if(!Array.isArray(i)){if(i){if(P(i)==="ENOENT")return!0;if(P(i)!=="ENOTDIR")throw i}return t.filter&&!await t.filter(e,s)?!1:(await lt(kh(e,t.tmp,Cg)),!0)}return!(await Promise.all(i.map(o=>Lo(Zi(e,o.name),t,o)))).every(o=>o===!0)||t.preserveRoot===!1&&e===Xi(e).root||t.filter&&!await t.filter(e,s)?!1:(await lt(kh(e,t.tmp,Ag)),!0)},kh=async(e,t,s)=>{let i=Zi(t,Rh(e));return await Og(e,i),await s(i)},tr=(e,t)=>(t?.signal?.throwIfAborted(),ht(()=>Wo(e,t,He(e)))??!0),Wo=(e,t,s)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return Wo(e,{...t,tmp:_h(e)},s);let i=t.tmp;if(e===t.tmp&&Xi(e).root!==e)throw new Error("cannot delete temp directory used for deletion");let r=s.isDirectory()?Ve(e):null;if(!Array.isArray(r)){if(r){if(P(r)==="ENOENT")return!0;if(P(r)!=="ENOTDIR")throw r}return t.filter&&!t.filter(e,s)?!1:(ht(()=>Oh(e,i,jg)),!0)}let o=!0;for(let n of r){let a=Zi(e,n.name);o=Wo(a,t,n)&&o}return!o||t.preserveRoot===!1&&e===Xi(e).root||t.filter&&!t.filter(e,s)?!1:(ht(()=>Oh(e,i,Ge)),!0)},Oh=(e,t,s)=>{let i=Zi(t,Rh(e));return ph(e,i),s(i)};var{unlink:Pg,rmdir:Ng,lstat:Fg}=ut,Dg=Mo(zs(Pg)),Mg=$o(Bs(Ye)),$g=Mo(zs(Ng)),Lg=$o(Bs(Ge)),Wg=async(e,{filter:t,...s})=>{s?.signal?.throwIfAborted();try{return await $g(e,s),!0}catch(i){if(P(i)==="ENOTEMPTY")return Qi(e,s);throw i}},Ig=(e,{filter:t,...s})=>{s?.signal?.throwIfAborted();try{return Lg(e,s),!0}catch(i){if(P(i)==="ENOTEMPTY")return tr(e,s);throw i}},de=Symbol("start"),jh=Symbol("child"),er=Symbol("finish"),sr=async(e,t)=>(t?.signal?.throwIfAborted(),await lt(Fg(e).then(s=>Io(e,t,s,de)))??!0),ir=(e,t)=>(t?.signal?.throwIfAborted(),ht(()=>Uo(e,t,He(e),de))??!0),Io=async(e,t,s,i=de)=>{t?.signal?.throwIfAborted();let r=s.isDirectory()?await qe(e):null;if(!Array.isArray(r)){if(r){if(P(r)==="ENOENT")return!0;if(P(r)!=="ENOTDIR")throw r}return t.filter&&!await t.filter(e,s)?!1:(await lt(Dg(e,t)),!0)}let o=i===de?jh:i,n=(await Promise.all(r.map(a=>Io(Ch(e,a.name),t,a,o)))).every(a=>a===!0);if(i===de)return Io(e,t,s,er);if(i===er){if(t.preserveRoot===!1&&e===Ah(e).root||!n||t.filter&&!await t.filter(e,s))return!1;await lt(Wg(e,t))}return!0},Uo=(e,t,s,i=de)=>{let r=s.isDirectory()?Ve(e):null;if(!Array.isArray(r)){if(r){if(P(r)==="ENOENT")return!0;if(P(r)!=="ENOTDIR")throw r}return t.filter&&!t.filter(e,s)?!1:(ht(()=>Mg(e,t)),!0)}let o=!0;for(let n of r){let a=i===de?jh:i,l=Ch(e,n.name);o=Uo(l,t,n,a)&&o}if(i===de)return Uo(e,t,s,er);if(i===er){if(t.preserveRoot===!1&&e===Ah(e).root||!o||t.filter&&!t.filter(e,s))return!1;ht(()=>Ig(e,t))}return!0};var zo=process.platform==="win32"?sr:qi,Bo=process.platform==="win32"?ir:Vi;var{rm:Ug}=ut,Go=async(e,t)=>(await Ug(e,{...t,force:!0,recursive:!0}),!0),Ho=(e,t)=>(dh(e,{...t,force:!0,recursive:!0}),!0);var[Ph=0,zg=0]=process.version.replace(/^v/,"").split(".").map(e=>parseInt(e,10)),Nh=Ph>14||Ph===14&&zg>=14,Fh=!Nh||process.platform==="win32"?()=>!1:e=>!e?.signal&&!e?.filter,Dh=!Nh||process.platform==="win32"?()=>!1:e=>!e?.signal&&!e?.filter;var Je=e=>async(t,s)=>{let i=lh(s);return i.glob&&(t=await Ee(t,i.glob)),Array.isArray(t)?!!(await Promise.all(t.map(r=>e(Us(r,i),i)))).reduce((r,o)=>r&&o,!0):!!await e(Us(t,i),i)},Ke=e=>(t,s)=>{let i=hh(s);return i.glob&&(t=ce(t,i.glob)),Array.isArray(t)?!!t.map(r=>e(Us(r,i),i)).reduce((r,o)=>r&&o,!0):!!e(Us(t,i),i)},$h=Ke(Ho),Bg=Object.assign(Je(Go),{sync:$h}),Lh=Ke(Bo),Gg=Object.assign(Je(zo),{sync:Lh}),Wh=Ke(ir),Hg=Object.assign(Je(sr),{sync:Wh}),Ih=Ke(Vi),Yg=Object.assign(Je(qi),{sync:Ih}),Uh=Ke(tr),qg=Object.assign(Je(Qi),{sync:Uh}),pt=Ke((e,t)=>Dh(t)?Ho(e,t):Bo(e,t));var Mh=Je((e,t)=>Fh(t)?Go(e,t):zo(e,t)),At=Object.assign(Mh,{rimraf:Mh,sync:pt,rimrafSync:pt,manual:Gg,manualSync:Lh,native:Bg,nativeSync:$h,posix:Yg,posixSync:Ih,windows:Hg,windowsSync:Wh,moveRemove:qg,moveRemoveSync:Uh});At.rimraf=At;var Gs=e=>{try{return Qt(e)}catch{return Gs(Hs(e)),pt(e),Qt(e)}};var ty=(e,t)=>{if(!(e.isSymbolicLink()||e.isDirectory()||e.isFile())){t.isENOENT()||pt(t.fullpath());return}if(e.isSymbolicLink()){let i=Hh(e.fullpath());if(!t.isENOENT()){if((t.isSymbolicLink()&&Hh(t.fullpath()))===i)return;pt(t.fullpath())}if(Gs(Hs(t.fullpath())),Xg(i,t.fullpath()),Vg.O_SYMLINK&&e.mode)try{Bh(t.fullpath(),e.mode)}catch{}return}if(e.isDirectory())t.isDirectory()||Gs(t.fullpath());else{let i=!0;if(!t.isENOENT()&&!t.isFile()?pt(t.fullpath()):ey(e,t)&&(i=!1),i){Gs(Hs(t.fullpath()));try{Kg(e.fullpath(),t.fullpath())}catch{Jg(e.fullpath(),t.fullpath())}}}let s=e.mode;s&&Bh(t.fullpath(),s)};var ey=(e,t)=>{try{return zh("sha512").update(Gh(e.fullpath())).digest("hex")===zh("sha512").update(Gh(t.fullpath())).digest("hex")}catch{return!1}},qh=`..${Qg}`,sy=(e,t)=>{if(e===t)return!0;let s=Yh(e,t),i=Yh(e,t);return!s.startsWith(qh)||!i.startsWith(qh)};var Vh=(e,t)=>{let s=new rh(e),i=rr(e),r=rr(t);if(Hs(i)===i||Hs(r)===r)throw new Error("cannot sync root directory");if(sy(r,i))throw new Error("cannot copy directory into itself or its parent");let[o,n]=[ce("**",{scurry:s,withFileTypes:!0}),ce("**",{cwd:r,withFileTypes:!0})];for(let a of o){if(!a.parent)throw new Error("cannot sync root directory");let l=a.resolve(rr(r,a.relative())),h=l.parent;if(!h)throw new Error("cannot sync root directory");l.lstatSync(),Gs(h.fullpath()),ty(a,l)}for(let a of n){let l=s.cwd.resolve(rr(i,a.relative()));if(l.lstatSync(),l.isENOENT())try{pt(a.fullpath()),Zg(a.fullpath())}catch{}}};import{chmodSync as Jh}from"fs";import{resolve as Kh}from"path";var Xh=()=>{let{bin:e}=k;if(e)if(typeof e=="string")Jh(Kh(e),493);else for(let t of Object.values(e))Jh(Kh(t),493)};import{spawnSync as wb}from"node:child_process";import{relative as qc,resolve as ls}from"node:path/posix";import{writeFileSync as iy}from"fs";var Zh=e=>{let{imports:t}=e;if(t)return Object.fromEntries(Object.entries(t).map(([s,i])=>[s,typeof i=="string"&&i.startsWith("./src/")?"./"+i.substring(6).replace(/\.([cm]?)ts$/,".$1js").replace(/\.tsx$/,".js"):i]))};var ry=(e,t)=>{if(!t)return pt(`${e}/package.json`);let s={type:t==="commonjs"?"commonjs":"module",imports:Zh(k)};iy(`${e}/package.json`,JSON.stringify(s,null,2)+`
13
- `)},Q=(e,t)=>{t&&T(E.cyan.dim("set dialect"),{where:e,mode:t}),ry(e,t)};import{existsSync as My,readdirSync as $y,unlinkSync as Ly,writeFileSync as Wy}from"node:fs";import{resolve as Iy}from"node:path";import{join as gc}from"node:path/posix";var{esmDialects:oy=[],commonjsDialects:ny=[]}=O,Xe=class{type;name;map=new Map;rmap=new Map;constructor(t,s){this.type=t,this.name=s}addFile(t,s){let i=this.type==="commonjs"?"cts":"mts",r=`-${this.name}.${i}`;if(!t.endsWith(r)&&this.name!=="cjs"&&this.name!=="esm"&&(r=`-${this.name}.ts`),!t.endsWith(r))return;let o=t.substring(0,t.length-r.length)+".ts",n=o+"x",a=s.has(o)?o:s.has(n)?n:void 0;a&&(this.map.set(t,a),this.rmap.set(a,t))}[Symbol.for("nodejs.util.inspect.custom")](){return[this.name,this.type,this.map]}},me=new Map([["cjs",new Xe("commonjs","cjs")],["esm",new Xe("esm","esm")]]);for(let e of ny)me.set("commonjs-"+e,new Xe("commonjs",e));for(let e of oy)me.set("esm-"+e,new Xe("esm",e));for(let e of Jt)for(let t of me.values())t.addFile(e,Jt);for(let[e,t]of me.entries())t.map.size===0&&me.delete(e);me.size&&T(E.cyan.dim("polyfills detected"),me);var L=me;import{dirname as jy,isAbsolute as Py,resolve as ur}from"node:path";import{readFileSync as Ny,statSync as Fy}from"node:fs";import{dirname as ay,resolve as ly}from"path";var ie=function*(e){for(e=ly(e);e;){yield e;let t=ay(e);if(t===e)break;e=t}};var Qh=e=>"source"in e?e.source:e.children.map(Qh).join(""),Ze=Qh;var Yo={offset:0,offsetMax:1/0,init:(e=1/0)=>{Yo.offset=0,Yo.offsetMax=e}},Ct=Yo;function nr(e){var t={},s;for(s in e)t[s]=e[s];return t}function ke(e){return" var y"+(e+("=state.y,x"+(e+"=state.x;")))}function qo(e){return"state.y=y"+(e+(";state.x=x"+(e+";")))}function Ys(e,t,s){if(e.expression){t=!!s.capture&&!e.capture;var i=s.length&&s.abort&&"node.length=ln"+(s.length+";")||"";e=" if((x = "+(e.expression.id+"(state)) "+(t?"!=":"==")+" null)"+((t?"{node.push(x);}else ":"")+("{"+(qo(s.index)+(i+(s.abort+"}"))))))}else i=!!s.capture&&!e.capture,s=nr(s),s.capture=i,!s.length&&i?(s.length=t,e="var ln"+(t+"=node.length;")+(Vo(e.sequence,t+1,s)+"")):e=Vo(e.sequence,t+1,s);return e}function ec(e,t,s){var i=s.index,r=s.abort,o="inv_"+t,n="group_"+t;return s=nr(s),e.capture==="!"&&(s.index=t,s.abort="break "+(o+"")),e.quantifier==="+"?(n=nr(e),n.quantifier="*",s=Ys(e,t,s)+(ec(n,t,s)+"")):e.quantifier==="*"?(s.length=0,s.index=t,s.abort="break "+(n+";"),s=n+(":for(;;){"+(ke(t)+(Ys(e,t,s)+"}")))):e.quantifier==="?"&&e.expression?(s.index=t,s.abort="",s=ke(t)+(Ys(e,t,s)+"")):e.quantifier==="?"?(s.index=t,s.abort="break "+(n+""),s=n+(":{"+(ke(t)+(Ys(e,t,s)+"}")))):s=Ys(e,t,s),e.capture==="!"?o+(":{"+(ke(t)+(s+(qo(i)+(r+"}"))))):e.capture==="="?ke(t)+(s+(qo(t)+"")):s}function Vo(e,t,s){for(var i=e.alternation?"alt_"+t:"",r="";e;e=e.alternation){var o="block_"+t,n=s;e.alternation&&(n=nr(s),n.index=t,n.abort="break "+(o+";"));for(var a="",l=0;l<e.length;l++)a+=ec(e[l],t,n);r=e.alternation?r+(o+(":{"+(ke(t)+(a+(" break "+(i+";}")))))):r+a}return i?i+(":{"+(r+"}")):r}function or(e){throw new SyntaxError('Unexpected token "'+e+'"')}var tc=typeof/./g.sticky=="boolean";function hy(e){return e.length?e:function(t){return e()(t)}}function cy(e){return function(t){if(t.x<t.quasis.length){for(var s=t.quasis[t.x],i=0,r=e.length;i<r;i++)if(s.charCodeAt(t.y+i)!==e.charCodeAt(i))return null;return t.y+=e.length,e}}}function fy(e){return e=tc?new RegExp(e.source,"y"):new RegExp(e.source+"|()","g"),function(t){if(t.x<t.quasis.length){var s=t.quasis[t.x];e.lastIndex=t.y;var i;return tc?e.test(s)&&(i=s.slice(t.y,e.lastIndex)):(s=e.exec(s),s[1]==null&&(i=s[0])),t.y=e.lastIndex,i}}}function uy(e){return typeof e=="function"?hy(e):typeof e=="string"?cy(e):fy(e)}function py(e,t){return{id:"_"+t}}function dy(e,t){return"_"+t}function sc(e,t){return function(s){for(var i=[],r=arguments.length-1;0<r--;)i[r]=arguments[r+1];var o=i.map(py),n=[];r=[];for(var a=null,l,h=r,f,c,u=0;u<s.length+o.length;u++){u%2!==0&&(c=o[u++>>1],h.push({expression:c,capture:f}),f=void 0);var p=s[u>>1];for(c=0;c<p.length;){var d=p[c++];d!==" "&&d!==" "&&d!=="\r"&&d!==`
14
- `&&(d==="|"&&h.length?h=h.alternation=[]:d===")"&&h.length?(a=null,(h=n.pop())||or(d)):d==="("?(n.push(h),h.push(a={sequence:[],capture:f}),h=a.sequence,f=void 0):d===":"||d==="="||d==="!"?(f=d,p[c]&&p[c]!=="("&&or(d)):d==="?"&&!h.length&&a?(f=p[c++],f===":"||f==="="||f==="!"?(a.capture=f,f=void 0):or(d)):d!=="?"&&d!=="+"&&d!=="*"||!(l=h[h.length-1])?or(d):l.quantifier=d)}}return l=[e,t].concat(i.map(uy)),f=Function,i="_n,_t,"+i.map(dy).join(","),o=t?"_t":null,r="(function(state){"+(ke(1)+(" var node=[];var x;"+(Vo(r,2,{index:1,length:0,abort:"return;",capture:!0})+(" if(_n)node.tag=_n;return "+((o?"("+(o+")(node)"):"node")+";})"))))),new f(i,"return "+r).apply(void 0,l)}}function ar(e){return function(t){for(var s=[],i=arguments.length-1;0<i--;)s[i]=arguments[i+1];return typeof t=="string"&&(t=[t]),e({quasis:t,expressions:s,x:0,y:0})}}var Qe={tokenDelimiterTypes:new Set(["ArrayOpen","ArrayClose","ObjectOpen","ObjectClose"]),tokenIgnoredTypes:new Set(["Newline","Whitespace","CommentLine","CommentBlock","Comma","CommaTrailing","Colon"]),tokenLiteralTypes:new Set(["Null","True","False","Number","String","Array","Object"]),isEven:e=>!(e%2),isOdd:e=>!Qe.isEven(e),isString:e=>typeof e=="string",isToken:e=>!Qe.isString(e),isTokenDelimiter:e=>Qe.tokenDelimiterTypes.has(e.type),isTokenIgnored:e=>Qe.tokenIgnoredTypes.has(e.type),isTokenLiteral:e=>Qe.tokenLiteralTypes.has(e.type),tokens2matchers:e=>{let t=new Map;return Object.keys(e).reduce((s,i)=>{let r=e[i],o=r.unwrapped?r:t.get(r)||sc(i,r);return t.set(r,o),s[i]=o,s},{})}},Y=Qe;var my=e=>{let t=Y.tokens2matchers(e),s=t.EarlyReturn`${""}`,i=t.Insufficient`${/[^]?/}`,r=t.Invalid`${/[^]/}`,o=t.Newline`${/\r?\n|\r/}`,n=t.Whitespace`${/[ \t]+/}`,a=t.CommentLine`${/\/\/.*/}`,l=t.CommentBlock`${/\/\*[^]*?\*\//}`,h=t.Passthrough`${o} | ${n} | ${a} | ${l}`,f=t.Passthrough`${h}*`,c=t.Whitespace`${/(?:[ \t\r\n]|\/\/.*|\/\*[^]*?\*\/)*/}`,u=t.Newline===t.Whitespace&&t.Whitespace===t.CommentLine&&t.CommentLine===t.CommentBlock?c:f,p=t.Comma`${","}`,d=t.CommaTrailing`${","}`,m=t.Colon`${":"}`,y=t.Null`${"null"}`,g=t.True`${"true"}`,w=t.False`${"false"}`,S=t.Passthrough`${g} | ${w}`,b=t.Number`${/-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?/}`,v=t.String`${/"(?:[^\u0000-\u001F\\"]|\\["bfnrt\\/]|\\u[0-9a-fA-F]{4})*"/}`,R=t.ArrayOpen`${"["}`,$=t.ArrayClose`${"]"}`,q=t.Passthrough`${u} ${()=>$r} ${u}`,st=t.Passthrough`${q} (!${s} ${p} ${q})* ${d}?`,Vt=t.Array`${R} ${u} ${st}? ${u} (${s} | ${$})`,Nf=t.ObjectOpen`${"{"}`,Ff=t.ObjectClose`${"}"}`,Dn=t.Passthrough`${u} ${v} (${s} | ${u} ${m} ${u} ${()=>$r} ${u})`,Df=t.Passthrough`${Dn} (!${s} ${p} ${Dn})* ${d}?`,Mf=t.Object`${Nf} ${u} ${Df}? ${u} (${s} | ${Ff})`,$r=t.Passthrough`${y} | ${S} | ${b} | ${v} | ${Mf} | ${Vt}`;return t.Root`${u} (${$r} | ${i}) (${s} | ${u} ${r}?)`},lr=my;var tt=e=>t=>{let s=t[0];return Ct.offset+=s.length,{type:e,source:s}},Jo=e=>t=>{let s=t.flat();return{type:e,children:s}},ic={EarlyReturn:()=>{if(Ct.offset>Ct.offsetMax)return[]},Insufficient:e=>{throw e[0].length&&ic.Invalid(e),new SyntaxError("Unexpected end of JSONC input")},Invalid:e=>{throw new SyntaxError(`Unexpected token ${e[0]} in JSONC at position ${Ct.offset}`)},Passthrough:e=>e.flat().filter(Y.isToken),Newline:tt("Newline"),Whitespace:tt("Whitespace"),CommentLine:tt("CommentLine"),CommentBlock:tt("CommentBlock"),Comma:tt("Comma"),CommaTrailing:tt("CommaTrailing"),Colon:tt("Colon"),Null:tt("Null"),True:tt("True"),False:tt("False"),Number:tt("Number"),String:tt("String"),ArrayOpen:tt("ArrayOpen"),ArrayClose:tt("ArrayClose"),Array:Jo("Array"),ObjectOpen:tt("ObjectOpen"),ObjectClose:tt("ObjectClose"),Object:Jo("Object"),Root:Jo("Root")},hr=ic;var qs=e=>(Ct.offset+=e[0].length,""),cr=e=>{let t=e.join("");return Ct.offset+=t.length,t},jt=(e,t)=>t;jt.unwrapped=!0;var gy={...hr,Passthrough:cr,Newline:qs,Whitespace:qs,CommentLine:qs,CommentBlock:qs,Comma:jt,CommaTrailing:qs,Colon:jt,Null:jt,True:jt,False:jt,Number:jt,String:jt,ArrayOpen:jt,ArrayClose:jt,Array:cr,ObjectOpen:jt,ObjectClose:jt,Object:cr,Root:cr},rc=gy;var yy=ar(lr(rc)),oc=yy;var wy=e=>(Ct.init(),oc(e)),Vs=wy;var Ko=JSON.parse,by=(e,t)=>{if(e=`${e}`,t)return Ko(Vs(e),t);try{return Ko(e)}catch(s){let i=Vs(e);if(e===i)throw s;return Ko(i)}},ge=by;var Sy=ar(lr(hr)),nc=Sy;var vy=(e,t)=>(Ct.init(t),nc(e)),fr=vy;var Ey=(e,t)=>{let s=null,i=0,r=l=>{l.start>t||l.end<=t-1||s&&Y.isTokenLiteral(s)||s&&Y.isTokenIgnored(l)||(s=l)},o=(l,h,f,c)=>{let{type:u,source:p}=l,d=i,m=i+=p.length,y={type:u,source:p,token:l,parent:h,depth:f,index:c,start:d,end:m};return r(y),y},n=(l,h,f,c)=>{let{type:u}=l,p={type:u,children:[],token:l,parent:h,depth:f,index:c};return p.children=l.children.map((d,m)=>a(d,p,f+1,m)).filter(Y.isTokenLiteral),p.children.forEach((d,m)=>d.index=m),p},a=(l,h,f,c)=>"children"in l?n(l,h,f,c):o(l,h,f,c);return a(e,null,-1,-1),s},xy=e=>{if(!e)return[];let t=[];for(;e;){let s=e.parent;if(!s)break;Y.isTokenLiteral(e)&&(s.type==="Object"?Y.isEven(e.index)?t.unshift(JSON.parse(e.source)):t.unshift(JSON.parse(s.children[e.index-1].source)):s.type==="Array"&&t.unshift(e.index)),e=s}return t},Ty=e=>{if(!e)return!1;let t=e.parent?.type;return t==="Object"?Y.isTokenLiteral(e)?Y.isEven(e.index):e.parent?.parent?.type==="Array":t==="Array"?Y.isTokenLiteral(e)||e.parent?.parent?.type==="Array":!1},_y=e=>{if(!e)return!1;let t=!e.parent?.children.length,s=e.parent?.type;return s==="Object"?t||Y.isTokenDelimiter(e)||Y.isTokenLiteral(e)&&Y.isOdd(e.index):s==="Array"?e.depth>1:!1},ky=(e,t)=>{if(!t||!e)return;let s=e.parent?.type;if(Y.isTokenLiteral(e))return s==="Array"?e.index:ge(Ze(e));if(s==="Array")return e.parent?.index},Oy=(e,t,s)=>{if(!t||!e)return;if(Y.isTokenLiteral(e))return ge(Ze(e));if(s)return;let{parent:i}=e;if(!(!i||!i.token)&&!(i.type!=="Array"&&i.type!=="Object"))return ge(Ze(i.token))},Ry=(e,t,s=!0)=>{let r=fr(e,s?t:1/0),o=Ey(r,t),n=xy(o),a=Ty(o),l=_y(o),h=ky(o,a),f=Oy(o,l,s),c=o?{type:o.type,start:o.start,end:o.end,source:o.source}:void 0;return{path:n,property:h,value:f,token:c,isInsideProperty:a,isInsideValue:l}},ac=Ry;var lc=JSON.stringify;var Ay=e=>{try{return ge(e),!0}catch{return!1}},hc=Ay;var Cy={ast:{parse:fr,stringify:Ze},lookup:ac,parse:ge,stringify:lc,strip:Vs,validate:hc},cc=Cy;var ts=e=>{try{return Fy(e).isFile()}catch{return!1}},Dy,es=()=>{let e=O.project??"tsconfig.json";return Dy??=uc(Xo(e))},Xo=(e,t=process.cwd())=>{if(Py(e))return e;let s=ur(t,e);if(!ts(s)&&ts(s+".json")&&(s+=".json"),ts(s)||e.startsWith(".\\")||e.startsWith("./"))return s;for(let i of ie(t)){let r=ur(i,"node_modules",e);if(ts(r))return r;let o=ur(i,"node_modules",e),n=ur(o,"tsconfig.json");if(ts(n))return n;if(ts(o+".json"))return o+".json"}throw new Error("Could not resolve tsconfig file location",{cause:{target:e,from:t}})},fc=(e,t)=>{for(let[s,i]of Object.entries(t))typeof i!="object"||Array.isArray(i)?e[s]??=i:s in e?typeof e[s]=="object"&&e[s]&&!Array.isArray(e[s])&&(e[s]=fc(e[s],i)):e[s]=i;return e},uc=(e,t=new Set)=>{try{let s=cc.parse(Ny(Xo(e),"utf8"));if(!s||typeof s!="object"||Array.isArray(s))throw new Error("invalid data, expected object",{cause:s});if(s.compilerOptions||(s.compilerOptions={}),typeof s.extends=="string"){let i=Xo(s.extends,jy(e));t.has(i)||(t.add(i),fc(s,uc(i,t)))}return s}catch(s){throw new Error("Invalid tsconfig file",{cause:s})}};var pc=()=>{es().compilerOptions.verbatimModuleSyntax&&(_("verbatimModuleSyntax detected"),F(`verbatimModuleSyntax is incompatible with multi-dialect builds. Either remove
12
+ >>> no match, partial?`,e,c,t,u),c===a))}let d;if(typeof h=="string"?(d=f===h,this.debug("string match",h,f,d)):(d=h.test(f),this.debug("pattern match",h,f,d)),!d)return!1}if(o===a&&n===l)return!0;if(o===a)return s;if(n===l)return o===a-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return rl(this.pattern,this.options)}parse(e){xi(e);let t=this.options;if(e==="**")return ot;if(e==="")return"";let s,i=null;(s=e.match(hd))?i=t.dot?fd:cd:(s=e.match(Qp))?i=(t.nocase?t.dot?id:sd:t.dot?ed:td)(s[1]):(s=e.match(ud))?i=(t.nocase?t.dot?dd:pd:t.dot?md:gd)(s):(s=e.match(rd))?i=t.dot?nd:od:(s=e.match(ad))&&(i=ld);let r=tl.fromGlob(e,this.options).toMMPattern();return i&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:i}),r}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,s=t.noglobstar?bd:t.dot?Sd:vd,i=new Set(t.nocase?["i"]:[]),r=e.map(a=>{let l=a.map(f=>{if(f instanceof RegExp)for(let c of f.flags.split(""))i.add(c);return typeof f=="string"?kd(f):f===ot?ot:f._src});l.forEach((f,c)=>{let u=l[c+1],p=l[c-1];f!==ot||p===ot||(p===void 0?u!==void 0&&u!==ot?l[c+1]="(?:\\/|"+s+"\\/)?"+u:l[c]=s:u===void 0?l[c-1]=p+"(?:\\/|\\/"+s+")?":u!==ot&&(l[c-1]=p+"(?:\\/|\\/"+s+"\\/)"+u,l[c+1]=ot))});let h=l.filter(f=>f!==ot);if(this.partial&&h.length>=1){let f=[];for(let c=1;c<=h.length;c++)f.push(h.slice(0,c).join("/"));return"(?:"+f.join("|")+")"}return h.join("/")}).join("|"),[o,n]=e.length>1?["(?:",")"]:["",""];r="^"+o+r+n+"$",this.partial&&(r="^(?:\\/|"+o+r.slice(1,-1)+n+")$"),this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&t)return!0;let s=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let r=this.set;this.debug(this.pattern,"set",r);let o=i[i.length-1];if(!o)for(let n=i.length-2;!o&&n>=0;n--)o=i[n];for(let n=0;n<r.length;n++){let a=r[n],l=i;if(s.matchBase&&a.length===1&&(l=[o]),this.matchOne(l,a,t))return s.flipNegate?!0:!this.negate}return s.flipNegate?!1:this.negate}static defaults(e){return nt.defaults(e).Minimatch}};nt.AST=tl;nt.Minimatch=he;nt.escape=Rs;nt.unescape=We;var Rd=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ol=new Set,lo=typeof process=="object"&&process?process:{},nl=(e,t,s,i)=>{typeof lo.emitWarning=="function"?lo.emitWarning(e,t,s,i):console.error(`[${s}] ${t}: ${e}`)},Ti=globalThis.AbortController,Na=globalThis.AbortSignal;if(typeof Ti>"u"){Na=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,i){this._onabort.push(i)}},Ti=class{constructor(){t()}signal=new Na;abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=!0;for(let i of this.signal._onabort)i(s);this.signal.onabort?.(s)}}};let e=lo.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,nl("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",t))}}var Ad=e=>!ol.has(e),le=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),al=e=>le(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?vi:null:null,vi=class extends Array{constructor(e){super(e),this.fill(0)}},jd=class Ts{heap;length;static#t=!1;static create(t){let s=al(t);if(!s)return[];Ts.#t=!0;let i=new Ts(t,s);return Ts.#t=!1,i}constructor(t,s){if(!Ts.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new s(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},ki=class ll{#t;#r;#n;#s;#o;#_;#x;#f;get perf(){return this.#f}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#p;#c;#l;#i;#w;#S;#y;#d;#k;#m;#v;#T;#u;#g;#b;#O;#e;#F;static unsafeExposeInternals(t){return{starts:t.#T,ttls:t.#u,autopurgeTimers:t.#g,sizes:t.#v,keyMap:t.#c,keyList:t.#l,valList:t.#i,next:t.#w,prev:t.#S,get head(){return t.#y},get tail(){return t.#d},free:t.#k,isBackgroundFetch:s=>t.#h(s),backgroundFetch:(s,i,r,o)=>t.#z(s,i,r,o),moveToTail:s=>t.#$(s),indexes:s=>t.#j(s),rindexes:s=>t.#C(s),isStale:s=>t.#E(s)}}get max(){return this.#t}get maxSize(){return this.#r}get calculatedSize(){return this.#p}get size(){return this.#a}get fetchMethod(){return this.#_}get memoMethod(){return this.#x}get dispose(){return this.#n}get onInsert(){return this.#s}get disposeAfter(){return this.#o}constructor(t){let{max:s=0,ttl:i,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:l,dispose:h,onInsert:f,disposeAfter:c,noDisposeOnSet:u,noUpdateTTL:p,maxSize:d=0,maxEntrySize:m=0,sizeCalculation:y,fetchMethod:g,memoMethod:w,noDeleteOnFetchRejection:S,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:R,ignoreFetchAbort:L,perf:q}=t;if(q!==void 0&&typeof q?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#f=q??Rd,s!==0&&!le(s))throw new TypeError("max option must be a nonnegative integer");let st=s?al(s):Array;if(!st)throw new Error("invalid max value: "+s);if(this.#t=s,this.#r=d,this.maxEntrySize=m||this.#r,this.sizeCalculation=y,this.sizeCalculation){if(!this.#r&&!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(w!==void 0&&typeof w!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#x=w,g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#_=g,this.#O=!!g,this.#c=new Map,this.#l=new Array(s).fill(void 0),this.#i=new Array(s).fill(void 0),this.#w=new st(s),this.#S=new st(s),this.#y=0,this.#d=0,this.#k=jd.create(s),this.#a=0,this.#p=0,typeof h=="function"&&(this.#n=h),typeof f=="function"&&(this.#s=f),typeof c=="function"?(this.#o=c,this.#m=[]):(this.#o=void 0,this.#m=void 0),this.#b=!!this.#n,this.#F=!!this.#s,this.#e=!!this.#o,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!p,this.noDeleteOnFetchRejection=!!S,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!R,this.ignoreFetchAbort=!!L,this.maxEntrySize!==0){if(this.#r!==0&&!le(this.#r))throw new TypeError("maxSize must be a positive integer if specified");if(!le(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#G()}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=le(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=i||0,this.ttl){if(!le(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#P()}if(this.#t===0&&this.ttl===0&&this.#r===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#r){let Vt="LRU_CACHE_UNBOUNDED";Ad(Vt)&&(ol.add(Vt),nl("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Vt,ll))}}getRemainingTTL(t){return this.#c.has(t)?1/0:0}#P(){let t=new vi(this.#t),s=new vi(this.#t);this.#u=t,this.#T=s;let i=this.ttlAutopurge?new Array(this.#t):void 0;this.#g=i,this.#L=(n,a,l=this.#f.now())=>{if(s[n]=a!==0?l:0,t[n]=a,i?.[n]&&(clearTimeout(i[n]),i[n]=void 0),a!==0&&i){let h=setTimeout(()=>{this.#E(n)&&this.#A(this.#l[n],"expire")},a+1);h.unref&&h.unref(),i[n]=h}},this.#R=n=>{s[n]=t[n]!==0?this.#f.now():0},this.#N=(n,a)=>{if(t[a]){let l=t[a],h=s[a];if(!l||!h)return;n.ttl=l,n.start=h,n.now=r||o();let f=n.now-h;n.remainingTTL=l-f}};let r=0,o=()=>{let n=this.#f.now();if(this.ttlResolution>0){r=n;let a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref()}return n};this.getRemainingTTL=n=>{let a=this.#c.get(n);if(a===void 0)return 0;let l=t[a],h=s[a];if(!l||!h)return 1/0;let f=(r||o())-h;return l-f},this.#E=n=>{let a=s[n],l=t[n];return!!l&&!!a&&(r||o())-a>l}}#R=()=>{};#N=()=>{};#L=()=>{};#E=()=>!1;#G(){let t=new vi(this.#t);this.#p=0,this.#v=t,this.#M=s=>{this.#p-=t[s],t[s]=0},this.#W=(s,i,r,o)=>{if(this.#h(i))return 0;if(!le(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(i,s),!le(r))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 r},this.#D=(s,i,r)=>{if(t[s]=i,this.#r){let o=this.#r-t[s];for(;this.#p>o;)this.#U(!0)}this.#p+=t[s],r&&(r.entrySize=i,r.totalCalculatedSize=this.#p)}}#M=t=>{};#D=(t,s,i)=>{};#W=(t,s,i,r)=>{if(i||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#j({allowStale:t=this.allowStale}={}){if(this.#a)for(let s=this.#d;!(!this.#I(s)||((t||!this.#E(s))&&(yield s),s===this.#y));)s=this.#S[s]}*#C({allowStale:t=this.allowStale}={}){if(this.#a)for(let s=this.#y;!(!this.#I(s)||((t||!this.#E(s))&&(yield s),s===this.#d));)s=this.#w[s]}#I(t){return t!==void 0&&this.#c.get(this.#l[t])===t}*entries(){for(let t of this.#j())this.#i[t]!==void 0&&this.#l[t]!==void 0&&!this.#h(this.#i[t])&&(yield[this.#l[t],this.#i[t]])}*rentries(){for(let t of this.#C())this.#i[t]!==void 0&&this.#l[t]!==void 0&&!this.#h(this.#i[t])&&(yield[this.#l[t],this.#i[t]])}*keys(){for(let t of this.#j()){let s=this.#l[t];s!==void 0&&!this.#h(this.#i[t])&&(yield s)}}*rkeys(){for(let t of this.#C()){let s=this.#l[t];s!==void 0&&!this.#h(this.#i[t])&&(yield s)}}*values(){for(let t of this.#j())this.#i[t]!==void 0&&!this.#h(this.#i[t])&&(yield this.#i[t])}*rvalues(){for(let t of this.#C())this.#i[t]!==void 0&&!this.#h(this.#i[t])&&(yield this.#i[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,s={}){for(let i of this.#j()){let r=this.#i[i],o=this.#h(r)?r.__staleWhileFetching:r;if(o!==void 0&&t(o,this.#l[i],this))return this.get(this.#l[i],s)}}forEach(t,s=this){for(let i of this.#j()){let r=this.#i[i],o=this.#h(r)?r.__staleWhileFetching:r;o!==void 0&&t.call(s,o,this.#l[i],this)}}rforEach(t,s=this){for(let i of this.#C()){let r=this.#i[i],o=this.#h(r)?r.__staleWhileFetching:r;o!==void 0&&t.call(s,o,this.#l[i],this)}}purgeStale(){let t=!1;for(let s of this.#C({allowStale:!0}))this.#E(s)&&(this.#A(this.#l[s],"expire"),t=!0);return t}info(t){let s=this.#c.get(t);if(s===void 0)return;let i=this.#i[s],r=this.#h(i)?i.__staleWhileFetching:i;if(r===void 0)return;let o={value:r};if(this.#u&&this.#T){let n=this.#u[s],a=this.#T[s];if(n&&a){let l=n-(this.#f.now()-a);o.ttl=l,o.start=Date.now()}}return this.#v&&(o.size=this.#v[s]),o}dump(){let t=[];for(let s of this.#j({allowStale:!0})){let i=this.#l[s],r=this.#i[s],o=this.#h(r)?r.__staleWhileFetching:r;if(o===void 0||i===void 0)continue;let n={value:o};if(this.#u&&this.#T){n.ttl=this.#u[s];let a=this.#f.now()-this.#T[s];n.start=Math.floor(Date.now()-a)}this.#v&&(n.size=this.#v[s]),t.unshift([i,n])}return t}load(t){this.clear();for(let[s,i]of t){if(i.start){let r=Date.now()-i.start;i.start=this.#f.now()-r}this.set(s,i.value,i)}}set(t,s,i={}){if(s===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:l}=i,{noUpdateTTL:h=this.noUpdateTTL}=i,f=this.#W(t,s,i.size||0,a);if(this.maxEntrySize&&f>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.#A(t,"set"),this;let c=this.#a===0?void 0:this.#c.get(t);if(c===void 0)c=this.#a===0?this.#d:this.#k.length!==0?this.#k.pop():this.#a===this.#t?this.#U(!1):this.#a,this.#l[c]=t,this.#i[c]=s,this.#c.set(t,c),this.#w[this.#d]=c,this.#S[c]=this.#d,this.#d=c,this.#a++,this.#D(c,f,l),l&&(l.set="add"),h=!1,this.#F&&this.#s?.(s,t,"add");else{this.#$(c);let u=this.#i[c];if(s!==u){if(this.#O&&this.#h(u)){u.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=u;p!==void 0&&!n&&(this.#b&&this.#n?.(p,t,"set"),this.#e&&this.#m?.push([p,t,"set"]))}else n||(this.#b&&this.#n?.(u,t,"set"),this.#e&&this.#m?.push([u,t,"set"]));if(this.#M(c),this.#D(c,f,l),this.#i[c]=s,l){l.set="replace";let p=u&&this.#h(u)?u.__staleWhileFetching:u;p!==void 0&&(l.oldValue=p)}}else l&&(l.set="update");this.#F&&this.onInsert?.(s,t,s===u?"update":"replace")}if(r!==0&&!this.#u&&this.#P(),this.#u&&(h||this.#L(c,r,o),l&&this.#N(l,c)),!n&&this.#e&&this.#m){let u=this.#m,p;for(;p=u?.shift();)this.#o?.(...p)}return this}pop(){try{for(;this.#a;){let t=this.#i[this.#y];if(this.#U(!0),this.#h(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#e&&this.#m){let t=this.#m,s;for(;s=t?.shift();)this.#o?.(...s)}}}#U(t){let s=this.#y,i=this.#l[s],r=this.#i[s];return this.#O&&this.#h(r)?r.__abortController.abort(new Error("evicted")):(this.#b||this.#e)&&(this.#b&&this.#n?.(r,i,"evict"),this.#e&&this.#m?.push([r,i,"evict"])),this.#M(s),this.#g?.[s]&&(clearTimeout(this.#g[s]),this.#g[s]=void 0),t&&(this.#l[s]=void 0,this.#i[s]=void 0,this.#k.push(s)),this.#a===1?(this.#y=this.#d=0,this.#k.length=0):this.#y=this.#w[s],this.#c.delete(i),this.#a--,s}has(t,s={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:r}=s,o=this.#c.get(t);if(o!==void 0){let n=this.#i[o];if(this.#h(n)&&n.__staleWhileFetching===void 0)return!1;if(this.#E(o))r&&(r.has="stale",this.#N(r,o));else return i&&this.#R(o),r&&(r.has="hit",this.#N(r,o)),!0}else r&&(r.has="miss");return!1}peek(t,s={}){let{allowStale:i=this.allowStale}=s,r=this.#c.get(t);if(r===void 0||!i&&this.#E(r))return;let o=this.#i[r];return this.#h(o)?o.__staleWhileFetching:o}#z(t,s,i,r){let o=s===void 0?void 0:this.#i[s];if(this.#h(o))return o;let n=new Ti,{signal:a}=i;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let l={signal:n.signal,options:i,context:r},h=(m,y=!1)=>{let{aborted:g}=n.signal,w=i.ignoreFetchAbort&&m!==void 0,S=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&m!==void 0);if(i.status&&(g&&!y?(i.status.fetchAborted=!0,i.status.fetchError=n.signal.reason,w&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),g&&!w&&!y)return c(n.signal.reason,S);let b=p,v=this.#i[s];return(v===p||w&&y&&v===void 0)&&(m===void 0?b.__staleWhileFetching!==void 0?this.#i[s]=b.__staleWhileFetching:this.#A(t,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.set(t,m,l.options))),m},f=m=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=m),c(m,!1)),c=(m,y)=>{let{aborted:g}=n.signal,w=g&&i.allowStaleOnFetchAbort,S=w||i.allowStaleOnFetchRejection,b=S||i.noDeleteOnFetchRejection,v=p;if(this.#i[s]===p&&(!b||!y&&v.__staleWhileFetching===void 0?this.#A(t,"fetch"):w||(this.#i[s]=v.__staleWhileFetching)),S)return i.status&&v.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),v.__staleWhileFetching;if(v.__returned===v)throw m},u=(m,y)=>{let g=this.#_?.(t,o,l);g&&g instanceof Promise&&g.then(w=>m(w===void 0?void 0:w),y),n.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(m(void 0),i.allowStaleOnFetchAbort&&(m=w=>h(w,!0)))})};i.status&&(i.status.fetchDispatched=!0);let p=new Promise(u).then(h,f),d=Object.assign(p,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return s===void 0?(this.set(t,d,{...l.options,status:void 0}),s=this.#c.get(t)):this.#i[s]=d,d}#h(t){if(!this.#O)return!1;let s=t;return!!s&&s instanceof Promise&&s.hasOwnProperty("__staleWhileFetching")&&s.__abortController instanceof Ti}async fetch(t,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:l=0,sizeCalculation:h=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:c=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:d=this.allowStaleOnFetchAbort,context:m,forceRefresh:y=!1,status:g,signal:w}=s;if(!this.#O)return g&&(g.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:g});let S={allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:l,sizeCalculation:h,noUpdateTTL:f,noDeleteOnFetchRejection:c,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:d,ignoreFetchAbort:p,status:g,signal:w},b=this.#c.get(t);if(b===void 0){g&&(g.fetch="miss");let v=this.#z(t,b,S,m);return v.__returned=v}else{let v=this.#i[b];if(this.#h(v)){let st=i&&v.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",st&&(g.returnedStale=!0)),st?v.__staleWhileFetching:v.__returned=v}let R=this.#E(b);if(!y&&!R)return g&&(g.fetch="hit"),this.#$(b),r&&this.#R(b),g&&this.#N(g,b),v;let L=this.#z(t,b,S,m),q=L.__staleWhileFetching!==void 0&&i;return g&&(g.fetch=R?"stale":"refresh",q&&R&&(g.returnedStale=!0)),q?L.__staleWhileFetching:L.__returned=L}}async forceFetch(t,s={}){let i=await this.fetch(t,s);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,s={}){let i=this.#x;if(!i)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=s,a=this.get(t,n);if(!o&&a!==void 0)return a;let l=i(t,a,{options:n,context:r});return this.set(t,l,n),l}get(t,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=s,a=this.#c.get(t);if(a!==void 0){let l=this.#i[a],h=this.#h(l);return n&&this.#N(n,a),this.#E(a)?(n&&(n.get="stale"),h?(n&&i&&l.__staleWhileFetching!==void 0&&(n.returnedStale=!0),i?l.__staleWhileFetching:void 0):(o||this.#A(t,"expire"),n&&i&&(n.returnedStale=!0),i?l:void 0)):(n&&(n.get="hit"),h?l.__staleWhileFetching:(this.#$(a),r&&this.#R(a),l))}else n&&(n.get="miss")}#B(t,s){this.#S[s]=t,this.#w[t]=s}#$(t){t!==this.#d&&(t===this.#y?this.#y=this.#w[t]:this.#B(this.#S[t],this.#w[t]),this.#B(this.#d,t),this.#d=t)}delete(t){return this.#A(t,"delete")}#A(t,s){let i=!1;if(this.#a!==0){let r=this.#c.get(t);if(r!==void 0)if(this.#g?.[r]&&(clearTimeout(this.#g?.[r]),this.#g[r]=void 0),i=!0,this.#a===1)this.#H(s);else{this.#M(r);let o=this.#i[r];if(this.#h(o)?o.__abortController.abort(new Error("deleted")):(this.#b||this.#e)&&(this.#b&&this.#n?.(o,t,s),this.#e&&this.#m?.push([o,t,s])),this.#c.delete(t),this.#l[r]=void 0,this.#i[r]=void 0,r===this.#d)this.#d=this.#S[r];else if(r===this.#y)this.#y=this.#w[r];else{let n=this.#S[r];this.#w[n]=this.#w[r];let a=this.#w[r];this.#S[a]=this.#S[r]}this.#a--,this.#k.push(r)}}if(this.#e&&this.#m?.length){let r=this.#m,o;for(;o=r?.shift();)this.#o?.(...o)}return i}clear(){return this.#H("delete")}#H(t){for(let s of this.#C({allowStale:!0})){let i=this.#i[s];if(this.#h(i))i.__abortController.abort(new Error("deleted"));else{let r=this.#l[s];this.#b&&this.#n?.(i,r,t),this.#e&&this.#m?.push([i,r,t])}}if(this.#c.clear(),this.#i.fill(void 0),this.#l.fill(void 0),this.#u&&this.#T){this.#u.fill(0),this.#T.fill(0);for(let s of this.#g??[])s!==void 0&&clearTimeout(s);this.#g?.fill(void 0)}if(this.#v&&this.#v.fill(0),this.#y=0,this.#d=0,this.#k.length=0,this.#p=0,this.#a=0,this.#e&&this.#m){let s=this.#m,i;for(;i=s?.shift();)this.#o?.(...i)}}},Fa=typeof process=="object"&&process?process:{stdout:null,stderr:null},Gd=e=>!!e&&typeof e=="object"&&(e instanceof _i||e instanceof hl||Hd(e)||Yd(e)),Hd=e=>!!e&&typeof e=="object"&&e instanceof uo&&typeof e.pipe=="function"&&e.pipe!==hl.Writable.prototype.pipe,Yd=e=>!!e&&typeof e=="object"&&e instanceof uo&&typeof e.write=="function"&&typeof e.end=="function",Kt=Symbol("EOF"),Xt=Symbol("maybeEmitEnd"),ae=Symbol("emittedEnd"),di=Symbol("emittingEnd"),ws=Symbol("emittedError"),mi=Symbol("closed"),Da=Symbol("read"),gi=Symbol("flush"),$a=Symbol("flushChunk"),Nt=Symbol("encoding"),Me=Symbol("decoder"),I=Symbol("flowing"),bs=Symbol("paused"),Le=Symbol("resume"),U=Symbol("buffer"),rt=Symbol("pipes"),z=Symbol("bufferLength"),eo=Symbol("bufferPush"),yi=Symbol("bufferShift"),K=Symbol("objectMode"),$=Symbol("destroyed"),so=Symbol("error"),io=Symbol("emitData"),Ma=Symbol("emitEnd"),ro=Symbol("emitEnd2"),Bt=Symbol("async"),oo=Symbol("abort"),wi=Symbol("aborted"),Ss=Symbol("signal"),Se=Symbol("dataListeners"),gt=Symbol("discarded"),vs=e=>Promise.resolve().then(e),qd=e=>e(),Vd=e=>e==="end"||e==="finish"||e==="prefinish",Jd=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,Kd=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),cl=class{src;dest;opts;ondrain;constructor(e,t,s){this.src=e,this.dest=t,this.opts=s,this.ondrain=()=>e[Le](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Xd=class extends cl{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,s){super(e,t,s),this.proxyErrors=i=>t.emit("error",i),e.on("error",this.proxyErrors)}},Zd=e=>!!e.objectMode,Qd=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",_i=class extends uo{[I]=!1;[bs]=!1;[rt]=[];[U]=[];[K];[Nt];[Bt];[Me];[Kt]=!1;[ae]=!1;[di]=!1;[mi]=!1;[ws]=null;[z]=0;[$]=!1;[Ss];[wi]=!1;[Se]=0;[gt]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Zd(t)?(this[K]=!0,this[Nt]=null):Qd(t)?(this[Nt]=t.encoding,this[K]=!1):(this[K]=!1,this[Nt]=null),this[Bt]=!!t.async,this[Me]=this[Nt]?new Bd(this[Nt]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[U]}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[rt]});let{signal:s}=t;s&&(this[Ss]=s,s.aborted?this[oo]():s.addEventListener("abort",()=>this[oo]()))}get bufferLength(){return this[z]}get encoding(){return this[Nt]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[K]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Bt]}set async(e){this[Bt]=this[Bt]||!!e}[oo](){this[wi]=!0,this.emit("abort",this[Ss]?.reason),this.destroy(this[Ss]?.reason)}get aborted(){return this[wi]}set aborted(e){}write(e,t,s){if(this[wi])return!1;if(this[Kt])throw new Error("write after end");if(this[$])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof t=="function"&&(s=t,t="utf8"),t||(t="utf8");let i=this[Bt]?vs:qd;if(!this[K]&&!Buffer.isBuffer(e)){if(Kd(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(Jd(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[K]?(this[I]&&this[z]!==0&&this[gi](!0),this[I]?this.emit("data",e):this[eo](e),this[z]!==0&&this.emit("readable"),s&&i(s),this[I]):e.length?(typeof e=="string"&&!(t===this[Nt]&&!this[Me]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[Nt]&&(e=this[Me].write(e)),this[I]&&this[z]!==0&&this[gi](!0),this[I]?this.emit("data",e):this[eo](e),this[z]!==0&&this.emit("readable"),s&&i(s),this[I]):(this[z]!==0&&this.emit("readable"),s&&i(s),this[I])}read(e){if(this[$])return null;if(this[gt]=!1,this[z]===0||e===0||e&&e>this[z])return this[Xt](),null;this[K]&&(e=null),this[U].length>1&&!this[K]&&(this[U]=[this[Nt]?this[U].join(""):Buffer.concat(this[U],this[z])]);let t=this[Da](e||null,this[U][0]);return this[Xt](),t}[Da](e,t){if(this[K])this[yi]();else{let s=t;e===s.length||e===null?this[yi]():typeof s=="string"?(this[U][0]=s.slice(e),t=s.slice(0,e),this[z]-=e):(this[U][0]=s.subarray(e),t=s.subarray(0,e),this[z]-=e)}return this.emit("data",t),!this[U].length&&!this[Kt]&&this.emit("drain"),t}end(e,t,s){return typeof e=="function"&&(s=e,e=void 0),typeof t=="function"&&(s=t,t="utf8"),e!==void 0&&this.write(e,t),s&&this.once("end",s),this[Kt]=!0,this.writable=!1,(this[I]||!this[bs])&&this[Xt](),this}[Le](){this[$]||(!this[Se]&&!this[rt].length&&(this[gt]=!0),this[bs]=!1,this[I]=!0,this.emit("resume"),this[U].length?this[gi]():this[Kt]?this[Xt]():this.emit("drain"))}resume(){return this[Le]()}pause(){this[I]=!1,this[bs]=!0,this[gt]=!1}get destroyed(){return this[$]}get flowing(){return this[I]}get paused(){return this[bs]}[eo](e){this[K]?this[z]+=1:this[z]+=e.length,this[U].push(e)}[yi](){return this[K]?this[z]-=1:this[z]-=this[U][0].length,this[U].shift()}[gi](e=!1){do;while(this[$a](this[yi]())&&this[U].length);!e&&!this[U].length&&!this[Kt]&&this.emit("drain")}[$a](e){return this.emit("data",e),this[I]}pipe(e,t){if(this[$])return e;this[gt]=!1;let s=this[ae];return t=t||{},e===Fa.stdout||e===Fa.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,s?t.end&&e.end():(this[rt].push(t.proxyErrors?new Xd(this,e,t):new cl(this,e,t)),this[Bt]?vs(()=>this[Le]()):this[Le]()),e}unpipe(e){let t=this[rt].find(s=>s.dest===e);t&&(this[rt].length===1?(this[I]&&this[Se]===0&&(this[I]=!1),this[rt]=[]):this[rt].splice(this[rt].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let s=super.on(e,t);if(e==="data")this[gt]=!1,this[Se]++,!this[rt].length&&!this[I]&&this[Le]();else if(e==="readable"&&this[z]!==0)super.emit("readable");else if(Vd(e)&&this[ae])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[ws]){let i=t;this[Bt]?vs(()=>i.call(this,this[ws])):i.call(this,this[ws])}return s}removeListener(e,t){return this.off(e,t)}off(e,t){let s=super.off(e,t);return e==="data"&&(this[Se]=this.listeners("data").length,this[Se]===0&&!this[gt]&&!this[rt].length&&(this[I]=!1)),s}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[Se]=0,!this[gt]&&!this[rt].length&&(this[I]=!1)),t}get emittedEnd(){return this[ae]}[Xt](){!this[di]&&!this[ae]&&!this[$]&&this[U].length===0&&this[Kt]&&(this[di]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[mi]&&this.emit("close"),this[di]=!1)}emit(e,...t){let s=t[0];if(e!=="error"&&e!=="close"&&e!==$&&this[$])return!1;if(e==="data")return!this[K]&&!s?!1:this[Bt]?(vs(()=>this[io](s)),!0):this[io](s);if(e==="end")return this[Ma]();if(e==="close"){if(this[mi]=!0,!this[ae]&&!this[$])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(e==="error"){this[ws]=s,super.emit(so,s);let r=!this[Ss]||this.listeners("error").length?super.emit("error",s):!1;return this[Xt](),r}else if(e==="resume"){let r=super.emit("resume");return this[Xt](),r}else if(e==="finish"||e==="prefinish"){let r=super.emit(e);return this.removeAllListeners(e),r}let i=super.emit(e,...t);return this[Xt](),i}[io](e){for(let s of this[rt])s.dest.write(e)===!1&&this.pause();let t=this[gt]?!1:super.emit("data",e);return this[Xt](),t}[Ma](){return this[ae]?!1:(this[ae]=!0,this.readable=!1,this[Bt]?(vs(()=>this[ro]()),!0):this[ro]())}[ro](){if(this[Me]){let t=this[Me].end();if(t){for(let s of this[rt])s.dest.write(t);this[gt]||super.emit("data",t)}}for(let t of this[rt])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[K]||(e.dataLength=0);let t=this.promise();return this.on("data",s=>{e.push(s),this[K]||(e.dataLength+=s.length)}),await t,e}async concat(){if(this[K])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Nt]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on($,()=>t(new Error("stream destroyed"))),this.on("error",s=>t(s)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[gt]=!1;let e=!1,t=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return t();let s=this.read();if(s!==null)return Promise.resolve({done:!1,value:s});if(this[Kt])return t();let i,r,o=h=>{this.off("data",n),this.off("end",a),this.off($,l),t(),r(h)},n=h=>{this.off("error",o),this.off("end",a),this.off($,l),this.pause(),i({value:h,done:!!this[Kt]})},a=()=>{this.off("error",o),this.off("data",n),this.off($,l),t(),i({done:!0,value:void 0})},l=()=>o(new Error("stream destroyed"));return new Promise((h,f)=>{r=f,i=h,this.once($,l),this.once("error",o),this.once("end",a),this.once("data",n)})},throw:t,return:t,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[gt]=!1;let e=!1,t=()=>(this.pause(),this.off(so,t),this.off($,t),this.off("end",t),e=!0,{done:!0,value:void 0}),s=()=>{if(e)return t();let i=this.read();return i===null?t():{done:!1,value:i}};return this.once("end",t),this.once(so,t),this.once($,t),{next:s,throw:t,return:t,[Symbol.iterator](){return this}}}destroy(e){if(this[$])return e?this.emit("error",e):this.emit($),this;this[$]=!0,this[gt]=!0,this[U].length=0,this[z]=0;let t=this;return typeof t.close=="function"&&!this[mi]&&t.close(),e?this.emit("error",e):this.emit($),this}static get isStream(){return Gd}},tm=Md.native,_s={lstatSync:Nd,readdir:Fd,readdirSync:Dd,readlinkSync:$d,realpathSync:tm,promises:{lstat:Wd,readdir:Id,readlink:Ud,realpath:zd}},fl=e=>!e||e===_s||e===Ld?_s:{..._s,...e,promises:{..._s.promises,...e.promises||{}}},ul=/^\\\\\?\\([a-z]:)\\?$/i,em=e=>e.replace(/\//g,"\\").replace(ul,"$1\\"),sm=/[\\\/]/,_t=0,pl=1,dl=2,Gt=4,ml=6,gl=8,ve=10,yl=12,Tt=15,Es=~Tt,no=16,La=32,ks=64,Ft=128,bi=256,Ei=512,Wa=ks|Ft|Ei,im=1023,ao=e=>e.isFile()?gl:e.isDirectory()?Gt:e.isSymbolicLink()?ve:e.isCharacterDevice()?dl:e.isBlockDevice()?ml:e.isSocket()?yl:e.isFIFO()?pl:_t,Ia=new ki({max:2**12}),Os=e=>{let t=Ia.get(e);if(t)return t;let s=e.normalize("NFKD");return Ia.set(e,s),s},Ua=new ki({max:2**12}),Si=e=>{let t=Ua.get(e);if(t)return t;let s=Os(e.toLowerCase());return Ua.set(e,s),s},za=class extends ki{constructor(){super({max:256})}},rm=class extends ki{constructor(e=16*1024){super({maxSize:e,sizeCalculation:t=>t.length+1})}},wl=Symbol("PathScurry setAsCwd"),ft=class{name;root;roots;parent;nocase;isCWD=!1;#t;#r;get dev(){return this.#r}#n;get mode(){return this.#n}#s;get nlink(){return this.#s}#o;get uid(){return this.#o}#_;get gid(){return this.#_}#x;get rdev(){return this.#x}#f;get blksize(){return this.#f}#a;get ino(){return this.#a}#p;get size(){return this.#p}#c;get blocks(){return this.#c}#l;get atimeMs(){return this.#l}#i;get mtimeMs(){return this.#i}#w;get ctimeMs(){return this.#w}#S;get birthtimeMs(){return this.#S}#y;get atime(){return this.#y}#d;get mtime(){return this.#d}#k;get ctime(){return this.#k}#m;get birthtime(){return this.#m}#v;#T;#u;#g;#b;#O;#e;#F;#P;#R;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=_t,s,i,r,o,n){this.name=e,this.#v=r?Si(e):Os(e),this.#e=t&im,this.nocase=r,this.roots=i,this.root=s||this,this.#F=o,this.#u=n.fullpath,this.#b=n.relative,this.#O=n.relativePosix,this.parent=n.parent,this.parent?this.#t=this.parent.#t:this.#t=fl(n.fs)}depth(){return this.#T!==void 0?this.#T:this.parent?this.#T=this.parent.depth()+1:this.#T=0}childrenCache(){return this.#F}resolve(e){if(!e)return this;let t=this.getRootString(e),s=e.substring(t.length).split(this.splitSep);return t?this.getRoot(t).#N(s):this.#N(s)}#N(e){let t=this;for(let s of e)t=t.child(s);return t}children(){let e=this.#F.get(this);if(e)return e;let t=Object.assign([],{provisional:0});return this.#F.set(this,t),this.#e&=~no,t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let s=this.children(),i=this.nocase?Si(e):Os(e);for(let a of s)if(a.#v===i)return a;let r=this.parent?this.sep:"",o=this.#u?this.#u+r+e:void 0,n=this.newChild(e,_t,{...t,parent:this,fullpath:o});return this.canReaddir()||(n.#e|=Ft),s.push(n),n}relative(){if(this.isCWD)return"";if(this.#b!==void 0)return this.#b;let e=this.name,t=this.parent;if(!t)return this.#b=this.name;let s=t.relative();return s+(!s||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#O!==void 0)return this.#O;let e=this.name,t=this.parent;if(!t)return this.#O=this.fullpathPosix();let s=t.relativePosix();return s+(!s||!t.parent?"":"/")+e}fullpath(){if(this.#u!==void 0)return this.#u;let e=this.name,t=this.parent;if(!t)return this.#u=this.name;let s=t.fullpath()+(t.parent?this.sep:"")+e;return this.#u=s}fullpathPosix(){if(this.#g!==void 0)return this.#g;if(this.sep==="/")return this.#g=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#g=`//?/${i}`:this.#g=i}let e=this.parent,t=e.fullpathPosix(),s=t+(!t||!e.parent?"":"/")+this.name;return this.#g=s}isUnknown(){return(this.#e&Tt)===_t}isType(e){return this[`is${e}`]()}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.#e&Tt)===gl}isDirectory(){return(this.#e&Tt)===Gt}isCharacterDevice(){return(this.#e&Tt)===dl}isBlockDevice(){return(this.#e&Tt)===ml}isFIFO(){return(this.#e&Tt)===pl}isSocket(){return(this.#e&Tt)===yl}isSymbolicLink(){return(this.#e&ve)===ve}lstatCached(){return this.#e&La?this:void 0}readlinkCached(){return this.#P}realpathCached(){return this.#R}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#P)return!0;if(!this.parent)return!1;let e=this.#e&Tt;return!(e!==_t&&e!==ve||this.#e&bi||this.#e&Ft)}calledReaddir(){return!!(this.#e&no)}isENOENT(){return!!(this.#e&Ft)}isNamed(e){return this.nocase?this.#v===Si(e):this.#v===Os(e)}async readlink(){let e=this.#P;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await this.#t.promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(t);if(s)return this.#P=s}catch(t){this.#C(t.code);return}}readlinkSync(){let e=this.#P;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=this.#t.readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(t);if(s)return this.#P=s}catch(t){this.#C(t.code);return}}#L(e){this.#e|=no;for(let t=e.provisional;t<e.length;t++){let s=e[t];s&&s.#E()}}#E(){this.#e&Ft||(this.#e=(this.#e|Ft)&Es,this.#G())}#G(){let e=this.children();e.provisional=0;for(let t of e)t.#E()}#M(){this.#e|=Ei,this.#D()}#D(){if(this.#e&ks)return;let e=this.#e;(e&Tt)===Gt&&(e&=Es),this.#e=e|ks,this.#G()}#W(e=""){e==="ENOTDIR"||e==="EPERM"?this.#D():e==="ENOENT"?this.#E():this.children().provisional=0}#j(e=""){e==="ENOTDIR"?this.parent.#D():e==="ENOENT"&&this.#E()}#C(e=""){let t=this.#e;t|=bi,e==="ENOENT"&&(t|=Ft),(e==="EINVAL"||e==="UNKNOWN")&&(t&=Es),this.#e=t,e==="ENOTDIR"&&this.parent&&this.parent.#D()}#I(e,t){return this.#z(e,t)||this.#U(e,t)}#U(e,t){let s=ao(e),i=this.newChild(e.name,s,{parent:this}),r=i.#e&Tt;return r!==Gt&&r!==ve&&r!==_t&&(i.#e|=ks),t.unshift(i),t.provisional++,i}#z(e,t){for(let s=t.provisional;s<t.length;s++){let i=t[s];if((this.nocase?Si(e.name):Os(e.name))===i.#v)return this.#h(e,i,s,t)}}#h(e,t,s,i){let r=t.name;return t.#e=t.#e&Es|ao(e),r!==e.name&&(t.name=e.name),s!==i.provisional&&(s===i.length-1?i.pop():i.splice(s,1),i.unshift(t)),i.provisional++,t}async lstat(){if((this.#e&Ft)===0)try{return this.#B(await this.#t.promises.lstat(this.fullpath())),this}catch(e){this.#j(e.code)}}lstatSync(){if((this.#e&Ft)===0)try{return this.#B(this.#t.lstatSync(this.fullpath())),this}catch(e){this.#j(e.code)}}#B(e){let{atime:t,atimeMs:s,birthtime:i,birthtimeMs:r,blksize:o,blocks:n,ctime:a,ctimeMs:l,dev:h,gid:f,ino:c,mode:u,mtime:p,mtimeMs:d,nlink:m,rdev:y,size:g,uid:w}=e;this.#y=t,this.#l=s,this.#m=i,this.#S=r,this.#f=o,this.#c=n,this.#k=a,this.#w=l,this.#r=h,this.#_=f,this.#a=c,this.#n=u,this.#d=p,this.#i=d,this.#s=m,this.#x=y,this.#p=g,this.#o=w;let S=ao(e);this.#e=this.#e&Es|S|La,S!==_t&&S!==Gt&&S!==ve&&(this.#e|=ks)}#$=[];#A=!1;#H(e){this.#A=!1;let t=this.#$.slice();this.#$.length=0,t.forEach(s=>s(null,e))}readdirCB(e,t=!1){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let s=this.children();if(this.calledReaddir()){let r=s.slice(0,s.provisional);t?e(null,r):queueMicrotask(()=>e(null,r));return}if(this.#$.push(e),this.#A)return;this.#A=!0;let i=this.fullpath();this.#t.readdir(i,{withFileTypes:!0},(r,o)=>{if(r)this.#W(r.code),s.provisional=0;else{for(let n of o)this.#I(n,s);this.#L(s)}this.#H(s.slice(0,s.provisional))})}#Y;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(this.#Y)await this.#Y;else{let s=()=>{};this.#Y=new Promise(i=>s=i);try{for(let i of await this.#t.promises.readdir(t,{withFileTypes:!0}))this.#I(i,e);this.#L(e)}catch(i){this.#W(i.code),e.provisional=0}this.#Y=void 0,s()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();try{for(let s of this.#t.readdirSync(t,{withFileTypes:!0}))this.#I(s,e);this.#L(e)}catch(s){this.#W(s.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#e&Wa)return!1;let e=Tt&this.#e;return e===_t||e===Gt||e===ve}shouldWalk(e,t){return(this.#e&Gt)===Gt&&!(this.#e&Wa)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#R)return this.#R;if(!((Ei|bi|Ft)&this.#e))try{let e=await this.#t.promises.realpath(this.fullpath());return this.#R=this.resolve(e)}catch{this.#M()}}realpathSync(){if(this.#R)return this.#R;if(!((Ei|bi|Ft)&this.#e))try{let e=this.#t.realpathSync(this.fullpath());return this.#R=this.resolve(e)}catch{this.#M()}}[wl](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let t=new Set([]),s=[],i=this;for(;i&&i.parent;)t.add(i),i.#b=s.join(this.sep),i.#O=s.join("/"),i=i.parent,s.push("..");for(i=e;i&&i.parent&&!t.has(i);)i.#b=void 0,i.#O=void 0,i=i.parent}},bl=class Sl extends ft{sep="\\";splitSep=sm;constructor(t,s=_t,i,r,o,n,a){super(t,s,i,r,o,n,a)}newChild(t,s=_t,i={}){return new Sl(t,s,this.root,this.roots,this.nocase,this.childrenCache(),i)}getRootString(t){return ho.parse(t).root}getRoot(t){if(t=em(t.toUpperCase()),t===this.root.name)return this.root;for(let[s,i]of Object.entries(this.roots))if(this.sameRoot(t,s))return this.roots[t]=i;return this.roots[t]=new po(t,this).root}sameRoot(t,s=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(ul,"$1\\"),t===s}},vl=class El extends ft{splitSep="/";sep="/";constructor(t,s=_t,i,r,o,n,a){super(t,s,i,r,o,n,a)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,s=_t,i={}){return new El(t,s,this.root,this.roots,this.nocase,this.childrenCache(),i)}},xl=class{root;rootPath;roots;cwd;#t;#r;#n;nocase;#s;constructor(e=process.cwd(),t,s,{nocase:i,childrenCacheSize:r=16*1024,fs:o=_s}={}){this.#s=fl(o),(e instanceof URL||e.startsWith("file://"))&&(e=Pd(e));let n=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(n),this.#t=new za,this.#r=new za,this.#n=new rm(r);let a=n.substring(this.rootPath.length).split(s);if(a.length===1&&!a[0]&&a.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#s),this.roots[this.rootPath]=this.root;let l=this.root,h=a.length-1,f=t.sep,c=this.rootPath,u=!1;for(let p of a){let d=h--;l=l.child(p,{relative:new Array(d).fill("..").join(f),relativePosix:new Array(d).fill("..").join("/"),fullpath:c+=(u?"":f)+p}),u=!0}this.cwd=l}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#n}resolve(...e){let t="";for(let r=e.length-1;r>=0;r--){let o=e[r];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=this.#t.get(t);if(s!==void 0)return s;let i=this.cwd.resolve(t).fullpath();return this.#t.set(t,i),i}resolvePosix(...e){let t="";for(let r=e.length-1;r>=0;r--){let o=e[r];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let s=this.#r.get(t);if(s!==void 0)return s;let i=this.cwd.resolve(t).fullpathPosix();return this.#r.set(t,i),i}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e,e=this.cwd);let{withFileTypes:s}=t;if(e.canReaddir()){let i=await e.readdir();return s?i:i.map(r=>r.name)}else return[]}readdirSync(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e,e=this.cwd);let{withFileTypes:s=!0}=t;return e.canReaddir()?s?e.readdirSync():e.readdirSync().map(i=>i.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e.withFileTypes,e=this.cwd);let s=await e.readlink();return t?s:s?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e.withFileTypes,e=this.cwd);let s=e.readlinkSync();return t?s:s?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e.withFileTypes,e=this.cwd);let s=await e.realpath();return t?s:s?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e.withFileTypes,e=this.cwd);let s=e.realpathSync();return t?s:s?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=t,n=[];(!r||r(e))&&n.push(s?e:e.fullpath());let a=new Set,l=(f,c)=>{a.add(f),f.readdirCB((u,p)=>{if(u)return c(u);let d=p.length;if(!d)return c();let m=()=>{--d===0&&c()};for(let y of p)(!r||r(y))&&n.push(s?y:y.fullpath()),i&&y.isSymbolicLink()?y.realpath().then(g=>g?.isUnknown()?g.lstat():g).then(g=>g?.shouldWalk(a,o)?l(g,m):m()):y.shouldWalk(a,o)?l(y,m):m()},!0)},h=e;return new Promise((f,c)=>{l(h,u=>{if(u)return c(u);f(n)})})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=t,n=[];(!r||r(e))&&n.push(s?e:e.fullpath());let a=new Set([e]);for(let l of a){let h=l.readdirSync();for(let f of h){(!r||r(f))&&n.push(s?f:f.fullpath());let c=f;if(f.isSymbolicLink()){if(!(i&&(c=f.realpathSync())))continue;c.isUnknown()&&c.lstatSync()}c.shouldWalk(a,o)&&a.add(c)}}return n}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=t;(!r||r(e))&&(yield s?e:e.fullpath());let n=new Set([e]);for(let a of n){let l=a.readdirSync();for(let h of l){(!r||r(h))&&(yield s?h:h.fullpath());let f=h;if(h.isSymbolicLink()){if(!(i&&(f=h.realpathSync())))continue;f.isUnknown()&&f.lstatSync()}f.shouldWalk(n,o)&&n.add(f)}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=t,n=new _i({objectMode:!0});(!r||r(e))&&n.write(s?e:e.fullpath());let a=new Set,l=[e],h=0,f=()=>{let c=!1;for(;!c;){let u=l.shift();if(!u){h===0&&n.end();return}h++,a.add(u);let p=(m,y,g=!1)=>{if(m)return n.emit("error",m);if(i&&!g){let w=[];for(let S of y)S.isSymbolicLink()&&w.push(S.realpath().then(b=>b?.isUnknown()?b.lstat():b));if(w.length){Promise.all(w).then(()=>p(null,y,!0));return}}for(let w of y)w&&(!r||r(w))&&(n.write(s?w:w.fullpath())||(c=!0));h--;for(let w of y){let S=w.realpathCached()||w;S.shouldWalk(a,o)&&l.push(S)}c&&!n.flowing?n.once("drain",f):d||f()},d=!0;u.readdirCB(p,!0),d=!1}};return f(),n}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof ft||(t=e,e=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:o}=t,n=new _i({objectMode:!0}),a=new Set;(!r||r(e))&&n.write(s?e:e.fullpath());let l=[e],h=0,f=()=>{let c=!1;for(;!c;){let u=l.shift();if(!u){h===0&&n.end();return}h++,a.add(u);let p=u.readdirSync();for(let d of p)(!r||r(d))&&(n.write(s?d:d.fullpath())||(c=!0));h--;for(let d of p){let m=d;if(d.isSymbolicLink()){if(!(i&&(m=d.realpathSync())))continue;m.isUnknown()&&m.lstatSync()}m.shouldWalk(a,o)&&l.push(m)}}c&&!n.flowing&&n.once("drain",f)};return f(),n}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[wl](t)}},po=class extends xl{sep="\\";constructor(e=process.cwd(),t={}){let{nocase:s=!0}=t;super(e,ho,"\\",{...t,nocase:s}),this.nocase=s;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(e){return ho.parse(e).root.toUpperCase()}newRoot(e){return new bl(this.rootPath,Gt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},mo=class extends xl{sep="/";constructor(e=process.cwd(),t={}){let{nocase:s=!1}=t;super(e,Cd,"/",{...t,nocase:s}),this.nocase=s}parseRootPath(e){return"/"}newRoot(e){return new vl(this.rootPath,Gt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},Tl=class extends mo{constructor(e=process.cwd(),t={}){let{nocase:s=!0}=t;super(e,{...t,nocase:s})}},Ov=process.platform==="win32"?bl:vl,om=process.platform==="win32"?po:process.platform==="darwin"?Tl:mo,nm=e=>e.length>=1,am=e=>e.length>=1,lm=Symbol.for("nodejs.util.inspect.custom"),_l=class kl{#t;#r;#n;length;#s;#o;#_;#x;#f;#a;#p=!0;constructor(t,s,i,r){if(!nm(t))throw new TypeError("empty pattern list");if(!am(s))throw new TypeError("empty glob list");if(s.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,i<0||i>=this.length)throw new TypeError("index out of range");if(this.#t=t,this.#r=s,this.#n=i,this.#s=r,this.#n===0){if(this.isUNC()){let[o,n,a,l,...h]=this.#t,[f,c,u,p,...d]=this.#r;h[0]===""&&(h.shift(),d.shift());let m=[o,n,a,l,""].join("/"),y=[f,c,u,p,""].join("/");this.#t=[m,...h],this.#r=[y,...d],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[o,...n]=this.#t,[a,...l]=this.#r;n[0]===""&&(n.shift(),l.shift());let h=o+"/",f=a+"/";this.#t=[h,...n],this.#r=[f,...l],this.length=this.#t.length}}}[lm](){return"Pattern <"+this.#r.slice(this.#n).join("/")+">"}pattern(){return this.#t[this.#n]}isString(){return typeof this.#t[this.#n]=="string"}isGlobstar(){return this.#t[this.#n]===ot}isRegExp(){return this.#t[this.#n]instanceof RegExp}globString(){return this.#_=this.#_||(this.#n===0?this.isAbsolute()?this.#r[0]+this.#r.slice(1).join("/"):this.#r.join("/"):this.#r.slice(this.#n).join("/"))}hasMore(){return this.length>this.#n+1}rest(){return this.#o!==void 0?this.#o:this.hasMore()?(this.#o=new kl(this.#t,this.#r,this.#n+1,this.#s),this.#o.#a=this.#a,this.#o.#f=this.#f,this.#o.#x=this.#x,this.#o):this.#o=null}isUNC(){let t=this.#t;return this.#f!==void 0?this.#f:this.#f=this.#s==="win32"&&this.#n===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#t;return this.#x!==void 0?this.#x:this.#x=this.#s==="win32"&&this.#n===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#t;return this.#a!==void 0?this.#a:this.#a=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#t[0];return typeof t=="string"&&this.isAbsolute()&&this.#n===0?t:""}checkFollowGlobstar(){return!(this.#n===0||!this.isGlobstar()||!this.#p)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#p?!1:(this.#p=!1,!0)}},hm=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Ba=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:s,noext:i,noglobstar:r,platform:o=hm}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:t,nocase:s,noext:i,noglobstar:r,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let n of e)this.add(n)}add(e){let t=new he(e,this.mmopts);for(let s=0;s<t.set.length;s++){let i=t.set[s],r=t.globParts[s];if(!i||!r)throw new Error("invalid pattern object");for(;i[0]==="."&&r[0]===".";)i.shift(),r.shift();let o=new _l(i,r,0,this.platform),n=new he(o.globString(),this.mmopts),a=r[r.length-1]==="**",l=o.isAbsolute();l?this.absolute.push(n):this.relative.push(n),a&&(l?this.absoluteChildren.push(n):this.relativeChildren.push(n))}}ignored(e){let t=e.fullpath(),s=`${t}/`,i=e.relative()||".",r=`${i}/`;for(let o of this.relative)if(o.match(i)||o.match(r))return!0;for(let o of this.absolute)if(o.match(t)||o.match(s))return!0;return!1}childrenIgnored(e){let t=e.fullpath()+"/",s=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(s))return!0;for(let i of this.absoluteChildren)if(i.match(t))return!0;return!1}},cm=class Ol{store;constructor(t=new Map){this.store=t}copy(){return new Ol(new Map(this.store))}hasWalked(t,s){return this.store.get(t.fullpath())?.has(s.globString())}storeWalked(t,s){let i=t.fullpath(),r=this.store.get(i);r?r.add(s.globString()):this.store.set(i,new Set([s.globString()]))}},fm=class{store=new Map;add(e,t,s){let i=(t?2:0)|(s?1:0),r=this.store.get(e);this.store.set(e,r===void 0?i:i&r)}entries(){return[...this.store.entries()].map(([e,t])=>[e,!!(t&2),!!(t&1)])}},um=class{store=new Map;add(e,t){if(!e.canReaddir())return;let s=this.store.get(e);s?s.find(i=>i.globString()===t.globString())||s.push(t):this.store.set(e,[t])}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter(e=>e.canReaddir())}},Ga=class Rl{hasWalkedCache;matches=new fm;subwalks=new um;patterns;follow;dot;opts;constructor(t,s){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=s?s.copy():new cm}processPatterns(t,s){this.patterns=s;let i=s.map(r=>[t,r]);for(let[r,o]of i){this.hasWalkedCache.storeWalked(r,o);let n=o.root(),a=o.isAbsolute()&&this.opts.absolute!==!1;if(n){r=r.resolve(n==="/"&&this.opts.root!==void 0?this.opts.root:n);let c=o.rest();if(c)o=c;else{this.matches.add(r,!0,!1);continue}}if(r.isENOENT())continue;let l,h,f=!1;for(;typeof(l=o.pattern())=="string"&&(h=o.rest());)r=r.resolve(l),o=h,f=!0;if(l=o.pattern(),h=o.rest(),f){if(this.hasWalkedCache.hasWalked(r,o))continue;this.hasWalkedCache.storeWalked(r,o)}if(typeof l=="string"){let c=l===".."||l===""||l===".";this.matches.add(r.resolve(l),a,c);continue}else if(l===ot){(!r.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(r,o);let c=h?.pattern(),u=h?.rest();if(!h||(c===""||c===".")&&!u)this.matches.add(r,a,c===""||c===".");else if(c===".."){let p=r.parent||r;u?this.hasWalkedCache.hasWalked(p,u)||this.subwalks.add(p,u):this.matches.add(p,a,!0)}}else l instanceof RegExp&&this.subwalks.add(r,o)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new Rl(this.opts,this.hasWalkedCache)}filterEntries(t,s){let i=this.subwalks.get(t),r=this.child();for(let o of s)for(let n of i){let a=n.isAbsolute(),l=n.pattern(),h=n.rest();l===ot?r.testGlobstar(o,n,h,a):l instanceof RegExp?r.testRegExp(o,l,h,a):r.testString(o,l,h,a)}return r}testGlobstar(t,s,i,r){if((this.dot||!t.name.startsWith("."))&&(s.hasMore()||this.matches.add(t,r,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,s):t.isSymbolicLink()&&(i&&s.checkFollowGlobstar()?this.subwalks.add(t,i):s.markFollowGlobstar()&&this.subwalks.add(t,s)))),i){let o=i.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(t,o,i.rest(),r);else if(o===".."){let n=t.parent||t;this.subwalks.add(n,i)}else o instanceof RegExp&&this.testRegExp(t,o,i.rest(),r)}}testRegExp(t,s,i,r){s.test(t.name)&&(i?this.subwalks.add(t,i):this.matches.add(t,r,!1))}testString(t,s,i,r){t.isNamed(s)&&(i?this.subwalks.add(t,i):this.matches.add(t,r,!1))}},pm=(e,t)=>typeof e=="string"?new Ba([e],t):Array.isArray(e)?new Ba(e,t):e,Al=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#t=[];#r;#n;signal;maxDepth;includeChildMatches;constructor(e,t,s){if(this.patterns=e,this.path=t,this.opts=s,this.#n=!s.posix&&s.platform==="win32"?"\\":"/",this.includeChildMatches=s.includeChildMatches!==!1,(s.ignore||!this.includeChildMatches)&&(this.#r=pm(s.ignore??[],s),!this.includeChildMatches&&typeof this.#r.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0}))}#s(e){return this.seen.has(e)||!!this.#r?.ignored?.(e)}#o(e){return!!this.#r?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#t.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#t.push(e):e())}async matchCheck(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||await e.realpath(),!s)return;e=s}let i=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&i?.isSymbolicLink()){let r=await i.realpath();r&&(r.isUnknown()||this.opts.stat)&&await r.lstat()}return this.matchCheckTest(i,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#s(e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=e.realpathCached()||e.realpathSync(),!s)return;e=s}let i=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&i?.isSymbolicLink()){let r=i.realpathSync();r&&(r?.isUnknown()||this.opts.stat)&&r.lstatSync()}return this.matchCheckTest(i,t)}matchFinish(e,t){if(this.#s(e))return;if(!this.includeChildMatches&&this.#r?.add){let r=`${e.relativePosix()}/**`;this.#r.add(r)}let s=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?this.#n:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(s){let r=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(r+i)}else{let r=this.opts.posix?e.relativePosix():e.relative(),o=this.opts.dotRelative&&!r.startsWith(".."+this.#n)?"."+this.#n:"";this.matchEmit(r?o+r+i:"."+i)}}async match(e,t,s){let i=await this.matchCheck(e,s);i&&this.matchFinish(i,t)}matchSync(e,t,s){let i=this.matchCheckSync(e,s);i&&this.matchFinish(i,t)}walkCB(e,t,s){this.signal?.aborted&&s(),this.walkCB2(e,t,new Ga(this.opts),s)}walkCB2(e,t,s,i){if(this.#o(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,t,s,i));return}s.processPatterns(e,t);let r=1,o=()=>{--r===0&&i()};for(let[n,a,l]of s.matches.entries())this.#s(n)||(r++,this.match(n,a,l).then(()=>o()));for(let n of s.subwalkTargets()){if(this.maxDepth!==1/0&&n.depth()>=this.maxDepth)continue;r++;let a=n.readdirCached();n.calledReaddir()?this.walkCB3(n,a,s,o):n.readdirCB((l,h)=>this.walkCB3(n,h,s,o),!0)}o()}walkCB3(e,t,s,i){s=s.filterEntries(e,t);let r=1,o=()=>{--r===0&&i()};for(let[n,a,l]of s.matches.entries())this.#s(n)||(r++,this.match(n,a,l).then(()=>o()));for(let[n,a]of s.subwalks.entries())r++,this.walkCB2(n,a,s.child(),o);o()}walkCBSync(e,t,s){this.signal?.aborted&&s(),this.walkCB2Sync(e,t,new Ga(this.opts),s)}walkCB2Sync(e,t,s,i){if(this.#o(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,s,i));return}s.processPatterns(e,t);let r=1,o=()=>{--r===0&&i()};for(let[n,a,l]of s.matches.entries())this.#s(n)||this.matchSync(n,a,l);for(let n of s.subwalkTargets()){if(this.maxDepth!==1/0&&n.depth()>=this.maxDepth)continue;r++;let a=n.readdirSync();this.walkCB3Sync(n,a,s,o)}o()}walkCB3Sync(e,t,s,i){s=s.filterEntries(e,t);let r=1,o=()=>{--r===0&&i()};for(let[n,a,l]of s.matches.entries())this.#s(n)||this.matchSync(n,a,l);for(let[n,a]of s.subwalks.entries())r++,this.walkCB2Sync(n,a,s.child(),o);o()}},Ha=class extends Al{matches=new Set;constructor(e,t,s){super(e,t,s)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,t)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?t(this.signal.reason):e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},Ya=class extends Al{results;constructor(e,t,s){super(e,t,s),this.results=new _i({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}},dm=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",xe=class{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(e,t){if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=Od(t.cwd)):this.cwd="",this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==!1,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(e=e.map(a=>a.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(a=>a.includes("/")?a:`./**/${a}`)}if(this.pattern=e,this.platform=t.platform||dm,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let a=t.platform==="win32"?po:t.platform==="darwin"?Tl:t.platform?mo:om;this.scurry=new a(this.cwd,{nocase:t.nocase,fs:t.fs})}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",i={braceExpandMax:1e4,...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},r=this.pattern.map(a=>new he(a,i)),[o,n]=r.reduce((a,l)=>(a[0].push(...l.set),a[1].push(...l.globParts),a),[[],[]]);this.patterns=o.map((a,l)=>{let h=n[l];if(!h)throw new Error("invalid pattern object");return new _l(a,h,0,this.platform)})}async walk(){return[...await new Ha(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 Ha(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 Ya(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 Ya(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()}},mm=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let s of e)if(new he(s,t).hasMagic())return!0;return!1};function Oi(e,t={}){return new xe(e,t).streamSync()}function jl(e,t={}){return new xe(e,t).stream()}function ce(e,t={}){return new xe(e,t).walkSync()}async function qa(e,t={}){return new xe(e,t).walk()}function Ri(e,t={}){return new xe(e,t).iterateSync()}function Cl(e,t={}){return new xe(e,t).iterate()}var gm=Oi,ym=Object.assign(jl,{sync:Oi}),wm=Ri,bm=Object.assign(Cl,{sync:Ri}),Sm=Object.assign(ce,{stream:Oi,iterate:Ri}),Ee=Object.assign(qa,{glob:qa,globSync:ce,sync:Sm,globStream:jl,stream:ym,globStreamSync:Oi,streamSync:gm,globIterate:Cl,iterate:bm,globIterateSync:Ri,iterateSync:wm,Glob:xe,hasMagic:mm,escape:Rs,unescape:We});Ee.glob=Ee;import{dirname as Pl}from"path";import{mkdir as vm,mkdirSync as Em,stat as xm,statSync as Tm}from"fs";var kt=e=>{if(!e)e={mode:511};else if(typeof e=="object")e={mode:511,...e};else if(typeof e=="number")e={mode:e};else if(typeof e=="string")e={mode:parseInt(e,8)};else throw new TypeError("invalid options argument");let t=e,s=e.fs||{};return e.mkdir=e.mkdir||s.mkdir||vm,e.mkdirAsync=e.mkdirAsync?e.mkdirAsync:async(i,r)=>new Promise((o,n)=>t.mkdir(i,r,(a,l)=>a?n(a):o(l))),e.stat=e.stat||s.stat||xm,e.statAsync=e.statAsync?e.statAsync:async i=>new Promise((r,o)=>t.stat(i,(n,a)=>n?o(n):r(a))),e.statSync=e.statSync||s.statSync||Tm,e.mkdirSync=e.mkdirSync||s.mkdirSync||Em,t};var Ht=(e,t,s)=>{let i=Pl(e),r={...kt(t),recursive:!1};if(i===e)try{return r.mkdirSync(e,r)}catch(o){let n=o;if(n&&n.code!=="EISDIR")throw o;return}try{return r.mkdirSync(e,r),s||e}catch(o){let n=o;if(n&&n.code==="ENOENT")return Ht(e,r,Ht(i,r,s));if(n&&n.code!=="EEXIST"&&n&&n.code!=="EROFS")throw o;try{if(!r.statSync(e).isDirectory())throw o}catch{throw o}}},Zt=Object.assign(async(e,t,s)=>{let i=kt(t);i.recursive=!1;let r=Pl(e);return r===e?i.mkdirAsync(e,i).catch(o=>{let n=o;if(n&&n.code!=="EISDIR")throw o}):i.mkdirAsync(e,i).then(()=>s||e,async o=>{let n=o;if(n&&n.code==="ENOENT")return Zt(r,i).then(a=>Zt(e,i,a));if(n&&n.code!=="EEXIST"&&n.code!=="EROFS")throw o;return i.statAsync(e).then(a=>{if(a.isDirectory())return s;throw o},()=>{throw o})})},{sync:Ht});import{dirname as Fl}from"path";import{dirname as Nl}from"path";var go=async(e,t,s)=>{if(s!==t)return e.statAsync(t).then(i=>i.isDirectory()?s:void 0,i=>{let r=i;return r&&r.code==="ENOENT"?go(e,Nl(t),t):void 0})},yo=(e,t,s)=>{if(s!==t)try{return e.statSync(t).isDirectory()?s:void 0}catch(i){let r=i;return r&&r.code==="ENOENT"?yo(e,Nl(t),t):void 0}};var Ie=(e,t)=>{let s=kt(t);if(s.recursive=!0,Fl(e)===e)return s.mkdirSync(e,s);let r=yo(s,e);try{return s.mkdirSync(e,s),r}catch(o){let n=o;if(n&&n.code==="ENOENT")return Ht(e,s);throw o}},As=Object.assign(async(e,t)=>{let s={...kt(t),recursive:!0};return Fl(e)===e?await s.mkdirAsync(e,s):go(s,e).then(r=>s.mkdirAsync(e,s).then(o=>r||o).catch(o=>{let n=o;if(n&&n.code==="ENOENT")return Zt(e,s);throw o}))},{sync:Ie});import{parse as km,resolve as Om}from"path";var _m=process.env.__TESTING_MKDIRP_PLATFORM__||process.platform,wo=e=>{if(/\0/.test(e))throw Object.assign(new TypeError("path must be a string without null bytes"),{path:e,code:"ERR_INVALID_ARG_VALUE"});if(e=Om(e),_m==="win32"){let t=/[*|"<>?:]/,{root:s}=km(e);if(t.test(e.substring(s.length)))throw Object.assign(new Error("Illegal characters in path."),{path:e,code:"EINVAL"})}return e};import{mkdir as Rm,mkdirSync as Am}from"fs";var jm=process.env.__TESTING_MKDIRP_NODE_VERSION__||process.version,bo=jm.replace(/^v/,"").split("."),Dl=+bo[0]>10||+bo[0]==10&&+bo[1]>=12,js=Dl?e=>kt(e).mkdirSync===Am:()=>!1,Ai=Object.assign(Dl?e=>kt(e).mkdir===Rm:()=>!1,{sync:js});var Qt=(e,t)=>{e=wo(e);let s=kt(t);return js(s)?Ie(e,s):Ht(e,s)};var So=Object.assign(async(e,t)=>{e=wo(e);let s=kt(t);return Ai(s)?As(e,s):Zt(e,s)},{mkdirpSync:Qt,mkdirpNative:As,mkdirpNativeSync:Ie,mkdirpManual:Zt,mkdirpManualSync:Ht,sync:Qt,native:As,nativeSync:Ie,manual:Zt,manualSync:Ht,useNative:Ai,useNativeSync:js});import Vg from"node:constants";import{createHash as zh}from"node:crypto";import{chmodSync as Bh,copyFileSync as Jg,linkSync as Kg,readFileSync as Gh,readlinkSync as Hh,symlinkSync as Xg,unlinkSync as Zg}from"node:fs";import{dirname as Hs,relative as Yh,resolve as rr,sep as Qg}from"node:path";var Cm=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ml=new Set,vo=typeof process=="object"&&process?process:{},Ll=(e,t,s,i)=>{typeof vo.emitWarning=="function"?vo.emitWarning(e,t,s,i):console.error(`[${s}] ${t}: ${e}`)},Ci=globalThis.AbortController,$l=globalThis.AbortSignal;if(typeof Ci>"u"){$l=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,i){this._onabort.push(i)}},Ci=class{constructor(){t()}signal=new $l;abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=!0;for(let i of this.signal._onabort)i(s);this.signal.onabort?.(s)}}};let e=vo.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,Ll("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",t))}}var Pm=e=>!Ml.has(e);var fe=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Wl=e=>fe(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?ji:null:null,ji=class extends Array{constructor(e){super(e),this.fill(0)}},Nm=class Cs{heap;length;static#t=!1;static create(t){let s=Wl(t);if(!s)return[];Cs.#t=!0;let i=new Cs(t,s);return Cs.#t=!1,i}constructor(t,s){if(!Cs.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new s(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},Ps=class Il{#t;#r;#n;#s;#o;#_;#x;#f;get perf(){return this.#f}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#p;#c;#l;#i;#w;#S;#y;#d;#k;#m;#v;#T;#u;#g;#b;#O;#e;#F;static unsafeExposeInternals(t){return{starts:t.#T,ttls:t.#u,autopurgeTimers:t.#g,sizes:t.#v,keyMap:t.#c,keyList:t.#l,valList:t.#i,next:t.#w,prev:t.#S,get head(){return t.#y},get tail(){return t.#d},free:t.#k,isBackgroundFetch:s=>t.#h(s),backgroundFetch:(s,i,r,o)=>t.#z(s,i,r,o),moveToTail:s=>t.#$(s),indexes:s=>t.#j(s),rindexes:s=>t.#C(s),isStale:s=>t.#E(s)}}get max(){return this.#t}get maxSize(){return this.#r}get calculatedSize(){return this.#p}get size(){return this.#a}get fetchMethod(){return this.#_}get memoMethod(){return this.#x}get dispose(){return this.#n}get onInsert(){return this.#s}get disposeAfter(){return this.#o}constructor(t){let{max:s=0,ttl:i,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:l,dispose:h,onInsert:f,disposeAfter:c,noDisposeOnSet:u,noUpdateTTL:p,maxSize:d=0,maxEntrySize:m=0,sizeCalculation:y,fetchMethod:g,memoMethod:w,noDeleteOnFetchRejection:S,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:R,ignoreFetchAbort:L,perf:q}=t;if(q!==void 0&&typeof q?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#f=q??Cm,s!==0&&!fe(s))throw new TypeError("max option must be a nonnegative integer");let st=s?Wl(s):Array;if(!st)throw new Error("invalid max value: "+s);if(this.#t=s,this.#r=d,this.maxEntrySize=m||this.#r,this.sizeCalculation=y,this.sizeCalculation){if(!this.#r&&!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(w!==void 0&&typeof w!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#x=w,g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#_=g,this.#O=!!g,this.#c=new Map,this.#l=new Array(s).fill(void 0),this.#i=new Array(s).fill(void 0),this.#w=new st(s),this.#S=new st(s),this.#y=0,this.#d=0,this.#k=Nm.create(s),this.#a=0,this.#p=0,typeof h=="function"&&(this.#n=h),typeof f=="function"&&(this.#s=f),typeof c=="function"?(this.#o=c,this.#m=[]):(this.#o=void 0,this.#m=void 0),this.#b=!!this.#n,this.#F=!!this.#s,this.#e=!!this.#o,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!p,this.noDeleteOnFetchRejection=!!S,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!R,this.ignoreFetchAbort=!!L,this.maxEntrySize!==0){if(this.#r!==0&&!fe(this.#r))throw new TypeError("maxSize must be a positive integer if specified");if(!fe(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#G()}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=fe(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=i||0,this.ttl){if(!fe(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#P()}if(this.#t===0&&this.ttl===0&&this.#r===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#r){let Vt="LRU_CACHE_UNBOUNDED";Pm(Vt)&&(Ml.add(Vt),Ll("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Vt,Il))}}getRemainingTTL(t){return this.#c.has(t)?1/0:0}#P(){let t=new ji(this.#t),s=new ji(this.#t);this.#u=t,this.#T=s;let i=this.ttlAutopurge?new Array(this.#t):void 0;this.#g=i,this.#L=(n,a,l=this.#f.now())=>{if(s[n]=a!==0?l:0,t[n]=a,i?.[n]&&(clearTimeout(i[n]),i[n]=void 0),a!==0&&i){let h=setTimeout(()=>{this.#E(n)&&this.#A(this.#l[n],"expire")},a+1);h.unref&&h.unref(),i[n]=h}},this.#R=n=>{s[n]=t[n]!==0?this.#f.now():0},this.#N=(n,a)=>{if(t[a]){let l=t[a],h=s[a];if(!l||!h)return;n.ttl=l,n.start=h,n.now=r||o();let f=n.now-h;n.remainingTTL=l-f}};let r=0,o=()=>{let n=this.#f.now();if(this.ttlResolution>0){r=n;let a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref()}return n};this.getRemainingTTL=n=>{let a=this.#c.get(n);if(a===void 0)return 0;let l=t[a],h=s[a];if(!l||!h)return 1/0;let f=(r||o())-h;return l-f},this.#E=n=>{let a=s[n],l=t[n];return!!l&&!!a&&(r||o())-a>l}}#R=()=>{};#N=()=>{};#L=()=>{};#E=()=>!1;#G(){let t=new ji(this.#t);this.#p=0,this.#v=t,this.#M=s=>{this.#p-=t[s],t[s]=0},this.#W=(s,i,r,o)=>{if(this.#h(i))return 0;if(!fe(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(i,s),!fe(r))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 r},this.#D=(s,i,r)=>{if(t[s]=i,this.#r){let o=this.#r-t[s];for(;this.#p>o;)this.#U(!0)}this.#p+=t[s],r&&(r.entrySize=i,r.totalCalculatedSize=this.#p)}}#M=t=>{};#D=(t,s,i)=>{};#W=(t,s,i,r)=>{if(i||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#j({allowStale:t=this.allowStale}={}){if(this.#a)for(let s=this.#d;!(!this.#I(s)||((t||!this.#E(s))&&(yield s),s===this.#y));)s=this.#S[s]}*#C({allowStale:t=this.allowStale}={}){if(this.#a)for(let s=this.#y;!(!this.#I(s)||((t||!this.#E(s))&&(yield s),s===this.#d));)s=this.#w[s]}#I(t){return t!==void 0&&this.#c.get(this.#l[t])===t}*entries(){for(let t of this.#j())this.#i[t]!==void 0&&this.#l[t]!==void 0&&!this.#h(this.#i[t])&&(yield[this.#l[t],this.#i[t]])}*rentries(){for(let t of this.#C())this.#i[t]!==void 0&&this.#l[t]!==void 0&&!this.#h(this.#i[t])&&(yield[this.#l[t],this.#i[t]])}*keys(){for(let t of this.#j()){let s=this.#l[t];s!==void 0&&!this.#h(this.#i[t])&&(yield s)}}*rkeys(){for(let t of this.#C()){let s=this.#l[t];s!==void 0&&!this.#h(this.#i[t])&&(yield s)}}*values(){for(let t of this.#j())this.#i[t]!==void 0&&!this.#h(this.#i[t])&&(yield this.#i[t])}*rvalues(){for(let t of this.#C())this.#i[t]!==void 0&&!this.#h(this.#i[t])&&(yield this.#i[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,s={}){for(let i of this.#j()){let r=this.#i[i],o=this.#h(r)?r.__staleWhileFetching:r;if(o!==void 0&&t(o,this.#l[i],this))return this.get(this.#l[i],s)}}forEach(t,s=this){for(let i of this.#j()){let r=this.#i[i],o=this.#h(r)?r.__staleWhileFetching:r;o!==void 0&&t.call(s,o,this.#l[i],this)}}rforEach(t,s=this){for(let i of this.#C()){let r=this.#i[i],o=this.#h(r)?r.__staleWhileFetching:r;o!==void 0&&t.call(s,o,this.#l[i],this)}}purgeStale(){let t=!1;for(let s of this.#C({allowStale:!0}))this.#E(s)&&(this.#A(this.#l[s],"expire"),t=!0);return t}info(t){let s=this.#c.get(t);if(s===void 0)return;let i=this.#i[s],r=this.#h(i)?i.__staleWhileFetching:i;if(r===void 0)return;let o={value:r};if(this.#u&&this.#T){let n=this.#u[s],a=this.#T[s];if(n&&a){let l=n-(this.#f.now()-a);o.ttl=l,o.start=Date.now()}}return this.#v&&(o.size=this.#v[s]),o}dump(){let t=[];for(let s of this.#j({allowStale:!0})){let i=this.#l[s],r=this.#i[s],o=this.#h(r)?r.__staleWhileFetching:r;if(o===void 0||i===void 0)continue;let n={value:o};if(this.#u&&this.#T){n.ttl=this.#u[s];let a=this.#f.now()-this.#T[s];n.start=Math.floor(Date.now()-a)}this.#v&&(n.size=this.#v[s]),t.unshift([i,n])}return t}load(t){this.clear();for(let[s,i]of t){if(i.start){let r=Date.now()-i.start;i.start=this.#f.now()-r}this.set(s,i.value,i)}}set(t,s,i={}){if(s===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:l}=i,{noUpdateTTL:h=this.noUpdateTTL}=i,f=this.#W(t,s,i.size||0,a);if(this.maxEntrySize&&f>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.#A(t,"set"),this;let c=this.#a===0?void 0:this.#c.get(t);if(c===void 0)c=this.#a===0?this.#d:this.#k.length!==0?this.#k.pop():this.#a===this.#t?this.#U(!1):this.#a,this.#l[c]=t,this.#i[c]=s,this.#c.set(t,c),this.#w[this.#d]=c,this.#S[c]=this.#d,this.#d=c,this.#a++,this.#D(c,f,l),l&&(l.set="add"),h=!1,this.#F&&this.#s?.(s,t,"add");else{this.#$(c);let u=this.#i[c];if(s!==u){if(this.#O&&this.#h(u)){u.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=u;p!==void 0&&!n&&(this.#b&&this.#n?.(p,t,"set"),this.#e&&this.#m?.push([p,t,"set"]))}else n||(this.#b&&this.#n?.(u,t,"set"),this.#e&&this.#m?.push([u,t,"set"]));if(this.#M(c),this.#D(c,f,l),this.#i[c]=s,l){l.set="replace";let p=u&&this.#h(u)?u.__staleWhileFetching:u;p!==void 0&&(l.oldValue=p)}}else l&&(l.set="update");this.#F&&this.onInsert?.(s,t,s===u?"update":"replace")}if(r!==0&&!this.#u&&this.#P(),this.#u&&(h||this.#L(c,r,o),l&&this.#N(l,c)),!n&&this.#e&&this.#m){let u=this.#m,p;for(;p=u?.shift();)this.#o?.(...p)}return this}pop(){try{for(;this.#a;){let t=this.#i[this.#y];if(this.#U(!0),this.#h(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#e&&this.#m){let t=this.#m,s;for(;s=t?.shift();)this.#o?.(...s)}}}#U(t){let s=this.#y,i=this.#l[s],r=this.#i[s];return this.#O&&this.#h(r)?r.__abortController.abort(new Error("evicted")):(this.#b||this.#e)&&(this.#b&&this.#n?.(r,i,"evict"),this.#e&&this.#m?.push([r,i,"evict"])),this.#M(s),this.#g?.[s]&&(clearTimeout(this.#g[s]),this.#g[s]=void 0),t&&(this.#l[s]=void 0,this.#i[s]=void 0,this.#k.push(s)),this.#a===1?(this.#y=this.#d=0,this.#k.length=0):this.#y=this.#w[s],this.#c.delete(i),this.#a--,s}has(t,s={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:r}=s,o=this.#c.get(t);if(o!==void 0){let n=this.#i[o];if(this.#h(n)&&n.__staleWhileFetching===void 0)return!1;if(this.#E(o))r&&(r.has="stale",this.#N(r,o));else return i&&this.#R(o),r&&(r.has="hit",this.#N(r,o)),!0}else r&&(r.has="miss");return!1}peek(t,s={}){let{allowStale:i=this.allowStale}=s,r=this.#c.get(t);if(r===void 0||!i&&this.#E(r))return;let o=this.#i[r];return this.#h(o)?o.__staleWhileFetching:o}#z(t,s,i,r){let o=s===void 0?void 0:this.#i[s];if(this.#h(o))return o;let n=new Ci,{signal:a}=i;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let l={signal:n.signal,options:i,context:r},h=(m,y=!1)=>{let{aborted:g}=n.signal,w=i.ignoreFetchAbort&&m!==void 0,S=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&m!==void 0);if(i.status&&(g&&!y?(i.status.fetchAborted=!0,i.status.fetchError=n.signal.reason,w&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),g&&!w&&!y)return c(n.signal.reason,S);let b=p,v=this.#i[s];return(v===p||w&&y&&v===void 0)&&(m===void 0?b.__staleWhileFetching!==void 0?this.#i[s]=b.__staleWhileFetching:this.#A(t,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.set(t,m,l.options))),m},f=m=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=m),c(m,!1)),c=(m,y)=>{let{aborted:g}=n.signal,w=g&&i.allowStaleOnFetchAbort,S=w||i.allowStaleOnFetchRejection,b=S||i.noDeleteOnFetchRejection,v=p;if(this.#i[s]===p&&(!b||!y&&v.__staleWhileFetching===void 0?this.#A(t,"fetch"):w||(this.#i[s]=v.__staleWhileFetching)),S)return i.status&&v.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),v.__staleWhileFetching;if(v.__returned===v)throw m},u=(m,y)=>{let g=this.#_?.(t,o,l);g&&g instanceof Promise&&g.then(w=>m(w===void 0?void 0:w),y),n.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(m(void 0),i.allowStaleOnFetchAbort&&(m=w=>h(w,!0)))})};i.status&&(i.status.fetchDispatched=!0);let p=new Promise(u).then(h,f),d=Object.assign(p,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return s===void 0?(this.set(t,d,{...l.options,status:void 0}),s=this.#c.get(t)):this.#i[s]=d,d}#h(t){if(!this.#O)return!1;let s=t;return!!s&&s instanceof Promise&&s.hasOwnProperty("__staleWhileFetching")&&s.__abortController instanceof Ci}async fetch(t,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:l=0,sizeCalculation:h=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:c=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:d=this.allowStaleOnFetchAbort,context:m,forceRefresh:y=!1,status:g,signal:w}=s;if(!this.#O)return g&&(g.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:g});let S={allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:l,sizeCalculation:h,noUpdateTTL:f,noDeleteOnFetchRejection:c,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:d,ignoreFetchAbort:p,status:g,signal:w},b=this.#c.get(t);if(b===void 0){g&&(g.fetch="miss");let v=this.#z(t,b,S,m);return v.__returned=v}else{let v=this.#i[b];if(this.#h(v)){let st=i&&v.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",st&&(g.returnedStale=!0)),st?v.__staleWhileFetching:v.__returned=v}let R=this.#E(b);if(!y&&!R)return g&&(g.fetch="hit"),this.#$(b),r&&this.#R(b),g&&this.#N(g,b),v;let L=this.#z(t,b,S,m),q=L.__staleWhileFetching!==void 0&&i;return g&&(g.fetch=R?"stale":"refresh",q&&R&&(g.returnedStale=!0)),q?L.__staleWhileFetching:L.__returned=L}}async forceFetch(t,s={}){let i=await this.fetch(t,s);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,s={}){let i=this.#x;if(!i)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=s,a=this.get(t,n);if(!o&&a!==void 0)return a;let l=i(t,a,{options:n,context:r});return this.set(t,l,n),l}get(t,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=s,a=this.#c.get(t);if(a!==void 0){let l=this.#i[a],h=this.#h(l);return n&&this.#N(n,a),this.#E(a)?(n&&(n.get="stale"),h?(n&&i&&l.__staleWhileFetching!==void 0&&(n.returnedStale=!0),i?l.__staleWhileFetching:void 0):(o||this.#A(t,"expire"),n&&i&&(n.returnedStale=!0),i?l:void 0)):(n&&(n.get="hit"),h?l.__staleWhileFetching:(this.#$(a),r&&this.#R(a),l))}else n&&(n.get="miss")}#B(t,s){this.#S[s]=t,this.#w[t]=s}#$(t){t!==this.#d&&(t===this.#y?this.#y=this.#w[t]:this.#B(this.#S[t],this.#w[t]),this.#B(this.#d,t),this.#d=t)}delete(t){return this.#A(t,"delete")}#A(t,s){let i=!1;if(this.#a!==0){let r=this.#c.get(t);if(r!==void 0)if(this.#g?.[r]&&(clearTimeout(this.#g?.[r]),this.#g[r]=void 0),i=!0,this.#a===1)this.#H(s);else{this.#M(r);let o=this.#i[r];if(this.#h(o)?o.__abortController.abort(new Error("deleted")):(this.#b||this.#e)&&(this.#b&&this.#n?.(o,t,s),this.#e&&this.#m?.push([o,t,s])),this.#c.delete(t),this.#l[r]=void 0,this.#i[r]=void 0,r===this.#d)this.#d=this.#S[r];else if(r===this.#y)this.#y=this.#w[r];else{let n=this.#S[r];this.#w[n]=this.#w[r];let a=this.#w[r];this.#S[a]=this.#S[r]}this.#a--,this.#k.push(r)}}if(this.#e&&this.#m?.length){let r=this.#m,o;for(;o=r?.shift();)this.#o?.(...o)}return i}clear(){return this.#H("delete")}#H(t){for(let s of this.#C({allowStale:!0})){let i=this.#i[s];if(this.#h(i))i.__abortController.abort(new Error("deleted"));else{let r=this.#l[s];this.#b&&this.#n?.(i,r,t),this.#e&&this.#m?.push([i,r,t])}}if(this.#c.clear(),this.#i.fill(void 0),this.#l.fill(void 0),this.#u&&this.#T){this.#u.fill(0),this.#T.fill(0);for(let s of this.#g??[])s!==void 0&&clearTimeout(s);this.#g?.fill(void 0)}if(this.#v&&this.#v.fill(0),this.#y=0,this.#d=0,this.#k.length=0,this.#p=0,this.#a=0,this.#e&&this.#m){let s=this.#m,i;for(;i=s?.shift();)this.#o?.(...i)}}};import{posix as Gm,win32 as Co}from"node:path";import{fileURLToPath as Hm}from"node:url";import{lstatSync as Ym,readdir as qm,readdirSync as Vm,readlinkSync as Jm,realpathSync as Km}from"fs";import*as Xm from"node:fs";import{lstat as Qm,readdir as tg,readlink as eg,realpath as sg}from"node:fs/promises";import{EventEmitter as Ro}from"node:events";import Hl from"node:stream";import{StringDecoder as Fm}from"node:string_decoder";var Ul=typeof process=="object"&&process?process:{stdout:null,stderr:null},Dm=e=>!!e&&typeof e=="object"&&(e instanceof Be||e instanceof Hl||$m(e)||Mm(e)),$m=e=>!!e&&typeof e=="object"&&e instanceof Ro&&typeof e.pipe=="function"&&e.pipe!==Hl.Writable.prototype.pipe,Mm=e=>!!e&&typeof e=="object"&&e instanceof Ro&&typeof e.write=="function"&&typeof e.end=="function",te=Symbol("EOF"),ee=Symbol("maybeEmitEnd"),ue=Symbol("emittedEnd"),Pi=Symbol("emittingEnd"),Ns=Symbol("emittedError"),Ni=Symbol("closed"),zl=Symbol("read"),Fi=Symbol("flush"),Bl=Symbol("flushChunk"),Dt=Symbol("encoding"),Ue=Symbol("decoder"),B=Symbol("flowing"),Fs=Symbol("paused"),ze=Symbol("resume"),G=Symbol("buffer"),at=Symbol("pipes"),H=Symbol("bufferLength"),Eo=Symbol("bufferPush"),Di=Symbol("bufferShift"),X=Symbol("objectMode"),M=Symbol("destroyed"),xo=Symbol("error"),To=Symbol("emitData"),Gl=Symbol("emitEnd"),_o=Symbol("emitEnd2"),Yt=Symbol("async"),ko=Symbol("abort"),$i=Symbol("aborted"),Ds=Symbol("signal"),Te=Symbol("dataListeners"),wt=Symbol("discarded"),$s=e=>Promise.resolve().then(e),Lm=e=>e(),Wm=e=>e==="end"||e==="finish"||e==="prefinish",Im=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,Um=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),Mi=class{src;dest;opts;ondrain;constructor(t,s,i){this.src=t,this.dest=s,this.opts=i,this.ondrain=()=>t[ze](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Oo=class extends Mi{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,s,i){super(t,s,i),this.proxyErrors=r=>s.emit("error",r),t.on("error",this.proxyErrors)}},zm=e=>!!e.objectMode,Bm=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",Be=class extends Ro{[B]=!1;[Fs]=!1;[at]=[];[G]=[];[X];[Dt];[Yt];[Ue];[te]=!1;[ue]=!1;[Pi]=!1;[Ni]=!1;[Ns]=null;[H]=0;[M]=!1;[Ds];[$i]=!1;[Te]=0;[wt]=!1;writable=!0;readable=!0;constructor(...t){let s=t[0]||{};if(super(),s.objectMode&&typeof s.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");zm(s)?(this[X]=!0,this[Dt]=null):Bm(s)?(this[Dt]=s.encoding,this[X]=!1):(this[X]=!1,this[Dt]=null),this[Yt]=!!s.async,this[Ue]=this[Dt]?new Fm(this[Dt]):null,s&&s.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[G]}),s&&s.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[at]});let{signal:i}=s;i&&(this[Ds]=i,i.aborted?this[ko]():i.addEventListener("abort",()=>this[ko]()))}get bufferLength(){return this[H]}get encoding(){return this[Dt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[X]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Yt]}set async(t){this[Yt]=this[Yt]||!!t}[ko](){this[$i]=!0,this.emit("abort",this[Ds]?.reason),this.destroy(this[Ds]?.reason)}get aborted(){return this[$i]}set aborted(t){}write(t,s,i){if(this[$i])return!1;if(this[te])throw new Error("write after end");if(this[M])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof s=="function"&&(i=s,s="utf8"),s||(s="utf8");let r=this[Yt]?$s:Lm;if(!this[X]&&!Buffer.isBuffer(t)){if(Um(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Im(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[X]?(this[B]&&this[H]!==0&&this[Fi](!0),this[B]?this.emit("data",t):this[Eo](t),this[H]!==0&&this.emit("readable"),i&&r(i),this[B]):t.length?(typeof t=="string"&&!(s===this[Dt]&&!this[Ue]?.lastNeed)&&(t=Buffer.from(t,s)),Buffer.isBuffer(t)&&this[Dt]&&(t=this[Ue].write(t)),this[B]&&this[H]!==0&&this[Fi](!0),this[B]?this.emit("data",t):this[Eo](t),this[H]!==0&&this.emit("readable"),i&&r(i),this[B]):(this[H]!==0&&this.emit("readable"),i&&r(i),this[B])}read(t){if(this[M])return null;if(this[wt]=!1,this[H]===0||t===0||t&&t>this[H])return this[ee](),null;this[X]&&(t=null),this[G].length>1&&!this[X]&&(this[G]=[this[Dt]?this[G].join(""):Buffer.concat(this[G],this[H])]);let s=this[zl](t||null,this[G][0]);return this[ee](),s}[zl](t,s){if(this[X])this[Di]();else{let i=s;t===i.length||t===null?this[Di]():typeof i=="string"?(this[G][0]=i.slice(t),s=i.slice(0,t),this[H]-=t):(this[G][0]=i.subarray(t),s=i.subarray(0,t),this[H]-=t)}return this.emit("data",s),!this[G].length&&!this[te]&&this.emit("drain"),s}end(t,s,i){return typeof t=="function"&&(i=t,t=void 0),typeof s=="function"&&(i=s,s="utf8"),t!==void 0&&this.write(t,s),i&&this.once("end",i),this[te]=!0,this.writable=!1,(this[B]||!this[Fs])&&this[ee](),this}[ze](){this[M]||(!this[Te]&&!this[at].length&&(this[wt]=!0),this[Fs]=!1,this[B]=!0,this.emit("resume"),this[G].length?this[Fi]():this[te]?this[ee]():this.emit("drain"))}resume(){return this[ze]()}pause(){this[B]=!1,this[Fs]=!0,this[wt]=!1}get destroyed(){return this[M]}get flowing(){return this[B]}get paused(){return this[Fs]}[Eo](t){this[X]?this[H]+=1:this[H]+=t.length,this[G].push(t)}[Di](){return this[X]?this[H]-=1:this[H]-=this[G][0].length,this[G].shift()}[Fi](t=!1){do;while(this[Bl](this[Di]())&&this[G].length);!t&&!this[G].length&&!this[te]&&this.emit("drain")}[Bl](t){return this.emit("data",t),this[B]}pipe(t,s){if(this[M])return t;this[wt]=!1;let i=this[ue];return s=s||{},t===Ul.stdout||t===Ul.stderr?s.end=!1:s.end=s.end!==!1,s.proxyErrors=!!s.proxyErrors,i?s.end&&t.end():(this[at].push(s.proxyErrors?new Oo(this,t,s):new Mi(this,t,s)),this[Yt]?$s(()=>this[ze]()):this[ze]()),t}unpipe(t){let s=this[at].find(i=>i.dest===t);s&&(this[at].length===1?(this[B]&&this[Te]===0&&(this[B]=!1),this[at]=[]):this[at].splice(this[at].indexOf(s),1),s.unpipe())}addListener(t,s){return this.on(t,s)}on(t,s){let i=super.on(t,s);if(t==="data")this[wt]=!1,this[Te]++,!this[at].length&&!this[B]&&this[ze]();else if(t==="readable"&&this[H]!==0)super.emit("readable");else if(Wm(t)&&this[ue])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Ns]){let r=s;this[Yt]?$s(()=>r.call(this,this[Ns])):r.call(this,this[Ns])}return i}removeListener(t,s){return this.off(t,s)}off(t,s){let i=super.off(t,s);return t==="data"&&(this[Te]=this.listeners("data").length,this[Te]===0&&!this[wt]&&!this[at].length&&(this[B]=!1)),i}removeAllListeners(t){let s=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Te]=0,!this[wt]&&!this[at].length&&(this[B]=!1)),s}get emittedEnd(){return this[ue]}[ee](){!this[Pi]&&!this[ue]&&!this[M]&&this[G].length===0&&this[te]&&(this[Pi]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ni]&&this.emit("close"),this[Pi]=!1)}emit(t,...s){let i=s[0];if(t!=="error"&&t!=="close"&&t!==M&&this[M])return!1;if(t==="data")return!this[X]&&!i?!1:this[Yt]?($s(()=>this[To](i)),!0):this[To](i);if(t==="end")return this[Gl]();if(t==="close"){if(this[Ni]=!0,!this[ue]&&!this[M])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Ns]=i,super.emit(xo,i);let o=!this[Ds]||this.listeners("error").length?super.emit("error",i):!1;return this[ee](),o}else if(t==="resume"){let o=super.emit("resume");return this[ee](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let r=super.emit(t,...s);return this[ee](),r}[To](t){for(let i of this[at])i.dest.write(t)===!1&&this.pause();let s=this[wt]?!1:super.emit("data",t);return this[ee](),s}[Gl](){return this[ue]?!1:(this[ue]=!0,this.readable=!1,this[Yt]?($s(()=>this[_o]()),!0):this[_o]())}[_o](){if(this[Ue]){let s=this[Ue].end();if(s){for(let i of this[at])i.dest.write(s);this[wt]||super.emit("data",s)}}for(let s of this[at])s.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[X]||(t.dataLength=0);let s=this.promise();return this.on("data",i=>{t.push(i),this[X]||(t.dataLength+=i.length)}),await s,t}async concat(){if(this[X])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[Dt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,s)=>{this.on(M,()=>s(new Error("stream destroyed"))),this.on("error",i=>s(i)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[wt]=!1;let t=!1,s=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return s();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[te])return s();let o,n,a=c=>{this.off("data",l),this.off("end",h),this.off(M,f),s(),n(c)},l=c=>{this.off("error",a),this.off("end",h),this.off(M,f),this.pause(),o({value:c,done:!!this[te]})},h=()=>{this.off("error",a),this.off("data",l),this.off(M,f),s(),o({done:!0,value:void 0})},f=()=>a(new Error("stream destroyed"));return new Promise((c,u)=>{n=u,o=c,this.once(M,f),this.once("error",a),this.once("end",h),this.once("data",l)})},throw:s,return:s,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[wt]=!1;let t=!1,s=()=>(this.pause(),this.off(xo,s),this.off(M,s),this.off("end",s),t=!0,{done:!0,value:void 0}),i=()=>{if(t)return s();let r=this.read();return r===null?s():{done:!1,value:r}};return this.once("end",s),this.once(xo,s),this.once(M,s),{next:i,throw:s,return:s,[Symbol.iterator](){return this}}}destroy(t){if(this[M])return t?this.emit("error",t):this.emit(M),this;this[M]=!0,this[wt]=!0,this[G].length=0,this[H]=0;let s=this;return typeof s.close=="function"&&!this[Ni]&&s.close(),t?this.emit("error",t):this.emit(M),this}static get isStream(){return Dm}};var Zm=Km.native,Ls={lstatSync:Ym,readdir:qm,readdirSync:Vm,readlinkSync:Jm,realpathSync:Zm,promises:{lstat:Qm,readdir:tg,readlink:eg,realpath:sg}},Kl=e=>!e||e===Ls||e===Xm?Ls:{...Ls,...e,promises:{...Ls.promises,...e.promises||{}}},Xl=/^\\\\\?\\([a-z]:)\\?$/i,ig=e=>e.replace(/\//g,"\\").replace(Xl,"$1\\"),rg=/[\\\/]/,Rt=0,Zl=1,Ql=2,qt=4,th=6,eh=8,_e=10,sh=12,Ot=15,Ms=~Ot,Ao=16,Yl=32,Ws=64,$t=128,Li=256,Ii=512,ql=Ws|$t|Ii,og=1023,jo=e=>e.isFile()?eh:e.isDirectory()?qt:e.isSymbolicLink()?_e:e.isCharacterDevice()?Ql:e.isBlockDevice()?th:e.isSocket()?sh:e.isFIFO()?Zl:Rt,Vl=new Ps({max:2**12}),Is=e=>{let t=Vl.get(e);if(t)return t;let s=e.normalize("NFKD");return Vl.set(e,s),s},Jl=new Ps({max:2**12}),Wi=e=>{let t=Jl.get(e);if(t)return t;let s=Is(e.toLowerCase());return Jl.set(e,s),s},Ui=class extends Ps{constructor(){super({max:256})}},Po=class extends Ps{constructor(t=16*1024){super({maxSize:t,sizeCalculation:s=>s.length+1})}},ih=Symbol("PathScurry setAsCwd"),Z=class{name;root;roots;parent;nocase;isCWD=!1;#t;#r;get dev(){return this.#r}#n;get mode(){return this.#n}#s;get nlink(){return this.#s}#o;get uid(){return this.#o}#_;get gid(){return this.#_}#x;get rdev(){return this.#x}#f;get blksize(){return this.#f}#a;get ino(){return this.#a}#p;get size(){return this.#p}#c;get blocks(){return this.#c}#l;get atimeMs(){return this.#l}#i;get mtimeMs(){return this.#i}#w;get ctimeMs(){return this.#w}#S;get birthtimeMs(){return this.#S}#y;get atime(){return this.#y}#d;get mtime(){return this.#d}#k;get ctime(){return this.#k}#m;get birthtime(){return this.#m}#v;#T;#u;#g;#b;#O;#e;#F;#P;#R;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,s=Rt,i,r,o,n,a){this.name=t,this.#v=o?Wi(t):Is(t),this.#e=s&og,this.nocase=o,this.roots=r,this.root=i||this,this.#F=n,this.#u=a.fullpath,this.#b=a.relative,this.#O=a.relativePosix,this.parent=a.parent,this.parent?this.#t=this.parent.#t:this.#t=Kl(a.fs)}depth(){return this.#T!==void 0?this.#T:this.parent?this.#T=this.parent.depth()+1:this.#T=0}childrenCache(){return this.#F}resolve(t){if(!t)return this;let s=this.getRootString(t),r=t.substring(s.length).split(this.splitSep);return s?this.getRoot(s).#N(r):this.#N(r)}#N(t){let s=this;for(let i of t)s=s.child(i);return s}children(){let t=this.#F.get(this);if(t)return t;let s=Object.assign([],{provisional:0});return this.#F.set(this,s),this.#e&=~Ao,s}child(t,s){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let i=this.children(),r=this.nocase?Wi(t):Is(t);for(let l of i)if(l.#v===r)return l;let o=this.parent?this.sep:"",n=this.#u?this.#u+o+t:void 0,a=this.newChild(t,Rt,{...s,parent:this,fullpath:n});return this.canReaddir()||(a.#e|=$t),i.push(a),a}relative(){if(this.isCWD)return"";if(this.#b!==void 0)return this.#b;let t=this.name,s=this.parent;if(!s)return this.#b=this.name;let i=s.relative();return i+(!i||!s.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#O!==void 0)return this.#O;let t=this.name,s=this.parent;if(!s)return this.#O=this.fullpathPosix();let i=s.relativePosix();return i+(!i||!s.parent?"":"/")+t}fullpath(){if(this.#u!==void 0)return this.#u;let t=this.name,s=this.parent;if(!s)return this.#u=this.name;let r=s.fullpath()+(s.parent?this.sep:"")+t;return this.#u=r}fullpathPosix(){if(this.#g!==void 0)return this.#g;if(this.sep==="/")return this.#g=this.fullpath();if(!this.parent){let r=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(r)?this.#g=`//?/${r}`:this.#g=r}let t=this.parent,s=t.fullpathPosix(),i=s+(!s||!t.parent?"":"/")+this.name;return this.#g=i}isUnknown(){return(this.#e&Ot)===Rt}isType(t){return this[`is${t}`]()}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.#e&Ot)===eh}isDirectory(){return(this.#e&Ot)===qt}isCharacterDevice(){return(this.#e&Ot)===Ql}isBlockDevice(){return(this.#e&Ot)===th}isFIFO(){return(this.#e&Ot)===Zl}isSocket(){return(this.#e&Ot)===sh}isSymbolicLink(){return(this.#e&_e)===_e}lstatCached(){return this.#e&Yl?this:void 0}readlinkCached(){return this.#P}realpathCached(){return this.#R}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#P)return!0;if(!this.parent)return!1;let t=this.#e&Ot;return!(t!==Rt&&t!==_e||this.#e&Li||this.#e&$t)}calledReaddir(){return!!(this.#e&Ao)}isENOENT(){return!!(this.#e&$t)}isNamed(t){return this.nocase?this.#v===Wi(t):this.#v===Is(t)}async readlink(){let t=this.#P;if(t)return t;if(this.canReadlink()&&this.parent)try{let s=await this.#t.promises.readlink(this.fullpath()),i=(await this.parent.realpath())?.resolve(s);if(i)return this.#P=i}catch(s){this.#C(s.code);return}}readlinkSync(){let t=this.#P;if(t)return t;if(this.canReadlink()&&this.parent)try{let s=this.#t.readlinkSync(this.fullpath()),i=this.parent.realpathSync()?.resolve(s);if(i)return this.#P=i}catch(s){this.#C(s.code);return}}#L(t){this.#e|=Ao;for(let s=t.provisional;s<t.length;s++){let i=t[s];i&&i.#E()}}#E(){this.#e&$t||(this.#e=(this.#e|$t)&Ms,this.#G())}#G(){let t=this.children();t.provisional=0;for(let s of t)s.#E()}#M(){this.#e|=Ii,this.#D()}#D(){if(this.#e&Ws)return;let t=this.#e;(t&Ot)===qt&&(t&=Ms),this.#e=t|Ws,this.#G()}#W(t=""){t==="ENOTDIR"||t==="EPERM"?this.#D():t==="ENOENT"?this.#E():this.children().provisional=0}#j(t=""){t==="ENOTDIR"?this.parent.#D():t==="ENOENT"&&this.#E()}#C(t=""){let s=this.#e;s|=Li,t==="ENOENT"&&(s|=$t),(t==="EINVAL"||t==="UNKNOWN")&&(s&=Ms),this.#e=s,t==="ENOTDIR"&&this.parent&&this.parent.#D()}#I(t,s){return this.#z(t,s)||this.#U(t,s)}#U(t,s){let i=jo(t),r=this.newChild(t.name,i,{parent:this}),o=r.#e&Ot;return o!==qt&&o!==_e&&o!==Rt&&(r.#e|=Ws),s.unshift(r),s.provisional++,r}#z(t,s){for(let i=s.provisional;i<s.length;i++){let r=s[i];if((this.nocase?Wi(t.name):Is(t.name))===r.#v)return this.#h(t,r,i,s)}}#h(t,s,i,r){let o=s.name;return s.#e=s.#e&Ms|jo(t),o!==t.name&&(s.name=t.name),i!==r.provisional&&(i===r.length-1?r.pop():r.splice(i,1),r.unshift(s)),r.provisional++,s}async lstat(){if((this.#e&$t)===0)try{return this.#B(await this.#t.promises.lstat(this.fullpath())),this}catch(t){this.#j(t.code)}}lstatSync(){if((this.#e&$t)===0)try{return this.#B(this.#t.lstatSync(this.fullpath())),this}catch(t){this.#j(t.code)}}#B(t){let{atime:s,atimeMs:i,birthtime:r,birthtimeMs:o,blksize:n,blocks:a,ctime:l,ctimeMs:h,dev:f,gid:c,ino:u,mode:p,mtime:d,mtimeMs:m,nlink:y,rdev:g,size:w,uid:S}=t;this.#y=s,this.#l=i,this.#m=r,this.#S=o,this.#f=n,this.#c=a,this.#k=l,this.#w=h,this.#r=f,this.#_=c,this.#a=u,this.#n=p,this.#d=d,this.#i=m,this.#s=y,this.#x=g,this.#p=w,this.#o=S;let b=jo(t);this.#e=this.#e&Ms|b|Yl,b!==Rt&&b!==qt&&b!==_e&&(this.#e|=Ws)}#$=[];#A=!1;#H(t){this.#A=!1;let s=this.#$.slice();this.#$.length=0,s.forEach(i=>i(null,t))}readdirCB(t,s=!1){if(!this.canReaddir()){s?t(null,[]):queueMicrotask(()=>t(null,[]));return}let i=this.children();if(this.calledReaddir()){let o=i.slice(0,i.provisional);s?t(null,o):queueMicrotask(()=>t(null,o));return}if(this.#$.push(t),this.#A)return;this.#A=!0;let r=this.fullpath();this.#t.readdir(r,{withFileTypes:!0},(o,n)=>{if(o)this.#W(o.code),i.provisional=0;else{for(let a of n)this.#I(a,i);this.#L(i)}this.#H(i.slice(0,i.provisional))})}#Y;async readdir(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let s=this.fullpath();if(this.#Y)await this.#Y;else{let i=()=>{};this.#Y=new Promise(r=>i=r);try{for(let r of await this.#t.promises.readdir(s,{withFileTypes:!0}))this.#I(r,t);this.#L(t)}catch(r){this.#W(r.code),t.provisional=0}this.#Y=void 0,i()}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let s=this.fullpath();try{for(let i of this.#t.readdirSync(s,{withFileTypes:!0}))this.#I(i,t);this.#L(t)}catch(i){this.#W(i.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#e&ql)return!1;let t=Ot&this.#e;return t===Rt||t===qt||t===_e}shouldWalk(t,s){return(this.#e&qt)===qt&&!(this.#e&ql)&&!t.has(this)&&(!s||s(this))}async realpath(){if(this.#R)return this.#R;if(!((Ii|Li|$t)&this.#e))try{let t=await this.#t.promises.realpath(this.fullpath());return this.#R=this.resolve(t)}catch{this.#M()}}realpathSync(){if(this.#R)return this.#R;if(!((Ii|Li|$t)&this.#e))try{let t=this.#t.realpathSync(this.fullpath());return this.#R=this.resolve(t)}catch{this.#M()}}[ih](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let s=new Set([]),i=[],r=this;for(;r&&r.parent;)s.add(r),r.#b=i.join(this.sep),r.#O=i.join("/"),r=r.parent,i.push("..");for(r=t;r&&r.parent&&!s.has(r);)r.#b=void 0,r.#O=void 0,r=r.parent}},zi=class e extends Z{sep="\\";splitSep=rg;constructor(t,s=Rt,i,r,o,n,a){super(t,s,i,r,o,n,a)}newChild(t,s=Rt,i={}){return new e(t,s,this.root,this.roots,this.nocase,this.childrenCache(),i)}getRootString(t){return Co.parse(t).root}getRoot(t){if(t=ig(t.toUpperCase()),t===this.root.name)return this.root;for(let[s,i]of Object.entries(this.roots))if(this.sameRoot(t,s))return this.roots[t]=i;return this.roots[t]=new Hi(t,this).root}sameRoot(t,s=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(Xl,"$1\\"),t===s}},Bi=class e extends Z{splitSep="/";sep="/";constructor(t,s=Rt,i,r,o,n,a){super(t,s,i,r,o,n,a)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,s=Rt,i={}){return new e(t,s,this.root,this.roots,this.nocase,this.childrenCache(),i)}},Gi=class{root;rootPath;roots;cwd;#t;#r;#n;nocase;#s;constructor(t=process.cwd(),s,i,{nocase:r,childrenCacheSize:o=16*1024,fs:n=Ls}={}){this.#s=Kl(n),(t instanceof URL||t.startsWith("file://"))&&(t=Hm(t));let a=s.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),this.#t=new Ui,this.#r=new Ui,this.#n=new Po(o);let l=a.substring(this.rootPath.length).split(i);if(l.length===1&&!l[0]&&l.pop(),r===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=r,this.root=this.newRoot(this.#s),this.roots[this.rootPath]=this.root;let h=this.root,f=l.length-1,c=s.sep,u=this.rootPath,p=!1;for(let d of l){let m=f--;h=h.child(d,{relative:new Array(m).fill("..").join(c),relativePosix:new Array(m).fill("..").join("/"),fullpath:u+=(p?"":c)+d}),p=!0}this.cwd=h}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#n}resolve(...t){let s="";for(let o=t.length-1;o>=0;o--){let n=t[o];if(!(!n||n===".")&&(s=s?`${n}/${s}`:n,this.isAbsolute(n)))break}let i=this.#t.get(s);if(i!==void 0)return i;let r=this.cwd.resolve(s).fullpath();return this.#t.set(s,r),r}resolvePosix(...t){let s="";for(let o=t.length-1;o>=0;o--){let n=t[o];if(!(!n||n===".")&&(s=s?`${n}/${s}`:n,this.isAbsolute(n)))break}let i=this.#r.get(s);if(i!==void 0)return i;let r=this.cwd.resolve(s).fullpathPosix();return this.#r.set(s,r),r}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,s={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t,t=this.cwd);let{withFileTypes:i}=s;if(t.canReaddir()){let r=await t.readdir();return i?r:r.map(o=>o.name)}else return[]}readdirSync(t=this.cwd,s={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t,t=this.cwd);let{withFileTypes:i=!0}=s;return t.canReaddir()?i?t.readdirSync():t.readdirSync().map(r=>r.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:s}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t.withFileTypes,t=this.cwd);let i=await t.readlink();return s?i:i?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:s}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t.withFileTypes,t=this.cwd);let i=t.readlinkSync();return s?i:i?.fullpath()}async realpath(t=this.cwd,{withFileTypes:s}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t.withFileTypes,t=this.cwd);let i=await t.realpath();return s?i:i?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:s}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t.withFileTypes,t=this.cwd);let i=t.realpathSync();return s?i:i?.fullpath()}async walk(t=this.cwd,s={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:o,walkFilter:n}=s,a=[];(!o||o(t))&&a.push(i?t:t.fullpath());let l=new Set,h=(c,u)=>{l.add(c),c.readdirCB((p,d)=>{if(p)return u(p);let m=d.length;if(!m)return u();let y=()=>{--m===0&&u()};for(let g of d)(!o||o(g))&&a.push(i?g:g.fullpath()),r&&g.isSymbolicLink()?g.realpath().then(w=>w?.isUnknown()?w.lstat():w).then(w=>w?.shouldWalk(l,n)?h(w,y):y()):g.shouldWalk(l,n)?h(g,y):y()},!0)},f=t;return new Promise((c,u)=>{h(f,p=>{if(p)return u(p);c(a)})})}walkSync(t=this.cwd,s={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:o,walkFilter:n}=s,a=[];(!o||o(t))&&a.push(i?t:t.fullpath());let l=new Set([t]);for(let h of l){let f=h.readdirSync();for(let c of f){(!o||o(c))&&a.push(i?c:c.fullpath());let u=c;if(c.isSymbolicLink()){if(!(r&&(u=c.realpathSync())))continue;u.isUnknown()&&u.lstatSync()}u.shouldWalk(l,n)&&l.add(u)}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,s={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t,t=this.cwd),this.stream(t,s)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,s={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:o,walkFilter:n}=s;(!o||o(t))&&(yield i?t:t.fullpath());let a=new Set([t]);for(let l of a){let h=l.readdirSync();for(let f of h){(!o||o(f))&&(yield i?f:f.fullpath());let c=f;if(f.isSymbolicLink()){if(!(r&&(c=f.realpathSync())))continue;c.isUnknown()&&c.lstatSync()}c.shouldWalk(a,n)&&a.add(c)}}}stream(t=this.cwd,s={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:o,walkFilter:n}=s,a=new Be({objectMode:!0});(!o||o(t))&&a.write(i?t:t.fullpath());let l=new Set,h=[t],f=0,c=()=>{let u=!1;for(;!u;){let p=h.shift();if(!p){f===0&&a.end();return}f++,l.add(p);let d=(y,g,w=!1)=>{if(y)return a.emit("error",y);if(r&&!w){let S=[];for(let b of g)b.isSymbolicLink()&&S.push(b.realpath().then(v=>v?.isUnknown()?v.lstat():v));if(S.length){Promise.all(S).then(()=>d(null,g,!0));return}}for(let S of g)S&&(!o||o(S))&&(a.write(i?S:S.fullpath())||(u=!0));f--;for(let S of g){let b=S.realpathCached()||S;b.shouldWalk(l,n)&&h.push(b)}u&&!a.flowing?a.once("drain",c):m||c()},m=!0;p.readdirCB(d,!0),m=!1}};return c(),a}streamSync(t=this.cwd,s={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Z||(s=t,t=this.cwd);let{withFileTypes:i=!0,follow:r=!1,filter:o,walkFilter:n}=s,a=new Be({objectMode:!0}),l=new Set;(!o||o(t))&&a.write(i?t:t.fullpath());let h=[t],f=0,c=()=>{let u=!1;for(;!u;){let p=h.shift();if(!p){f===0&&a.end();return}f++,l.add(p);let d=p.readdirSync();for(let m of d)(!o||o(m))&&(a.write(i?m:m.fullpath())||(u=!0));f--;for(let m of d){let y=m;if(m.isSymbolicLink()){if(!(r&&(y=m.realpathSync())))continue;y.isUnknown()&&y.lstatSync()}y.shouldWalk(l,n)&&h.push(y)}}u&&!a.flowing&&a.once("drain",c)};return c(),a}chdir(t=this.cwd){let s=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[ih](s)}},Hi=class extends Gi{sep="\\";constructor(t=process.cwd(),s={}){let{nocase:i=!0}=s;super(t,Co,"\\",{...s,nocase:i}),this.nocase=i;for(let r=this.cwd;r;r=r.parent)r.nocase=this.nocase}parseRootPath(t){return Co.parse(t).root.toUpperCase()}newRoot(t){return new zi(this.rootPath,qt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},Yi=class extends Gi{sep="/";constructor(t=process.cwd(),s={}){let{nocase:i=!1}=s;super(t,Gm,"/",{...s,nocase:i}),this.nocase=i}parseRootPath(t){return"/"}newRoot(t){return new Bi(this.rootPath,qt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},No=class extends Yi{constructor(t=process.cwd(),s={}){let{nocase:i=!0}=s;super(t,{...s,nocase:i})}},LE=process.platform==="win32"?zi:Bi,rh=process.platform==="win32"?Hi:process.platform==="darwin"?No:Yi;var pe=(e,t)=>typeof e>"u"||typeof e===t,oh=e=>!!e&&typeof e=="object"&&pe(e.preserveRoot,"boolean")&&pe(e.tmp,"string")&&pe(e.maxRetries,"number")&&pe(e.retryDelay,"number")&&pe(e.backoff,"number")&&pe(e.maxBackoff,"number")&&(pe(e.glob,"boolean")||e.glob&&typeof e.glob=="object")&&pe(e.filter,"function"),nh=e=>{if(!oh(e))throw new Error("invalid rimraf options")},ah=e=>{nh(e);let{glob:t,...s}=e;if(!t)return s;let i=t===!0?e.signal?{signal:e.signal}:{}:e.signal?{signal:e.signal,...t}:t;return{...s,glob:{...i,absolute:!0,withFileTypes:!1}}},lh=(e={})=>ah(e),hh=(e={})=>ah(e);import{parse as ch,resolve as ng}from"path";import{inspect as ag}from"util";var lg=(e,t={})=>{let s=typeof e;if(s!=="string"){let r=e&&s==="object"&&e.constructor,n=`The "path" argument must be of type string. Received ${r&&r.name?`an instance of ${r.name}`:s==="object"?ag(e):`type ${s} ${e}`}`;throw Object.assign(new TypeError(n),{path:e,code:"ERR_INVALID_ARG_TYPE"})}if(/\0/.test(e)){let r="path must be a string without null bytes";throw Object.assign(new TypeError(r),{path:e,code:"ERR_INVALID_ARG_VALUE"})}e=ng(e);let{root:i}=ch(e);if(e===i&&t.preserveRoot!==!1){let r="refusing to remove root directory without preserveRoot:false";throw Object.assign(new Error(r),{path:e,code:"ERR_PRESERVE_ROOT"})}if(process.platform==="win32"){let r=/[*|"<>?:]/,{root:o}=ch(e);if(r.test(e.substring(o.length)))throw Object.assign(new Error("Illegal characters in path."),{path:e,code:"EINVAL"})}return e},Us=lg;import{readdirSync as hg}from"fs";import se from"fs/promises";import{chmodSync as uh,mkdirSync as VE,renameSync as ph,rmdirSync as Ge,rmSync as dh,statSync as mh,lstatSync as He,unlinkSync as Ye}from"fs";var fh=e=>hg(e,{withFileTypes:!0}),ut={chmod:se.chmod,mkdir:se.mkdir,readdir:e=>se.readdir(e,{withFileTypes:!0}),rename:se.rename,rm:se.rm,rmdir:se.rmdir,stat:se.stat,lstat:se.lstat,unlink:se.unlink};import{parse as yh,resolve as wh}from"path";var{readdir:cg}=ut,qe=e=>cg(e).catch(t=>t),Ve=e=>{try{return fh(e)}catch(t){return t}};var gh=e=>!!e&&typeof e=="object",Fo=(e,t)=>t in e&&typeof e[t]=="string",Do=e=>gh(e)&&Fo(e,"code")&&Fo(e,"path"),N=e=>gh(e)&&Fo(e,"code")?e.code:null;var lt=async(e,t)=>e.catch(s=>{if(N(s)!=="ENOENT")throw t??s}),ht=(e,t)=>{try{return e()}catch(s){if(N(s)==="ENOENT")return;throw t??s}};var{lstat:fg,rmdir:ug,unlink:pg}=ut,qi=async(e,t)=>(t?.signal?.throwIfAborted(),await lt(fg(e).then(s=>bh(e,t,s)))??!0),Vi=(e,t)=>(t?.signal?.throwIfAborted(),ht(()=>Sh(e,t,He(e)))??!0),bh=async(e,t,s)=>{t?.signal?.throwIfAborted();let i=s.isDirectory()?await qe(e):null;if(!Array.isArray(i)){if(i){if(N(i)==="ENOENT")return!0;if(N(i)!=="ENOTDIR")throw i}return t.filter&&!await t.filter(e,s)?!1:(await lt(pg(e)),!0)}return!(await Promise.all(i.map(o=>bh(wh(e,o.name),t,o)))).every(o=>o===!0)||t.preserveRoot===!1&&e===yh(e).root||t.filter&&!await t.filter(e,s)?!1:(await lt(ug(e)),!0)},Sh=(e,t,s)=>{t?.signal?.throwIfAborted();let i=s.isDirectory()?Ve(e):null;if(!Array.isArray(i)){if(i){if(N(i)==="ENOENT")return!0;if(N(i)!=="ENOTDIR")throw i}return t.filter&&!t.filter(e,s)?!1:(ht(()=>Ye(e)),!0)}let r=!0;for(let o of i){let n=wh(e,o.name);r=Sh(n,t,o)&&r}return t.preserveRoot===!1&&e===yh(e).root||!r||t.filter&&!t.filter(e,s)?!1:(ht(()=>Ge(e)),!0)};import{parse as Ah,resolve as jh}from"path";var{chmod:dg}=ut,zs=e=>async t=>{try{return void await lt(e(t))}catch(s){if(N(s)==="EPERM")return await lt(dg(t,438).then(()=>!0),s)?void await e(t):void 0;throw s}},Bs=e=>t=>{try{return void ht(()=>e(t))}catch(s){if(N(s)==="EPERM")return ht(()=>(uh(t,438),!0),s)?void e(t):void 0;throw s}};import{setTimeout as mg}from"timers/promises";var gg=200,yg=1.2,vh=10,Eh=new Set(["EMFILE","ENFILE","EBUSY"]),$o=e=>{let t=async(s,i,r=1,o=0)=>{let n=i.maxBackoff||gg,a=i.backoff||yg,l=i.maxRetries||vh,h=0;for(;;)try{return await e(s)}catch(f){if(Do(f)&&f.path===s&&Eh.has(f.code)){if(r=Math.ceil(r*a),o=r+o,o<n)return await mg(r),t(s,i,r,o);if(h<l){h++;continue}}throw f}};return t},Mo=e=>(s,i)=>{let r=i.maxRetries||vh,o=0;for(;;)try{return e(s)}catch(n){if(Do(n)&&n.path===s&&Eh.has(n.code)&&o<r){o++;continue}throw n}};import{basename as _g,parse as Xi,resolve as Zi}from"path";import{tmpdir as Ki}from"os";import{parse as Ji,resolve as xh}from"path";var{stat:wg}=ut,bg=e=>{try{return mh(e).isDirectory()}catch{return!1}},Sg=e=>wg(e).then(t=>t.isDirectory(),()=>!1),vg=async e=>{let{root:t}=Ji(e),s=Ki(),{root:i}=Ji(s);if(t.toLowerCase()===i.toLowerCase())return s;let r=xh(t,"/temp");return await Sg(r)?r:t},Eg=e=>{let{root:t}=Ji(e),s=Ki(),{root:i}=Ji(s);if(t.toLowerCase()===i.toLowerCase())return s;let r=xh(t,"/temp");return bg(r)?r:t},xg=async()=>Ki(),Tg=()=>Ki(),Th=process.platform==="win32"?vg:xg,_h=process.platform==="win32"?Eg:Tg;var{lstat:kg,rename:Og,unlink:Rg,rmdir:Ag}=ut,Rh=e=>`.${_g(e)}.${Math.random()}`,jg=zs(Rg),Cg=Bs(Ye),Qi=async(e,t)=>(t?.signal?.throwIfAborted(),await lt(kg(e).then(s=>Lo(e,t,s)))??!0),Lo=async(e,t,s)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return Lo(e,{...t,tmp:await Th(e)},s);if(e===t.tmp&&Xi(e).root!==e)throw new Error("cannot delete temp directory used for deletion");let i=s.isDirectory()?await qe(e):null;if(!Array.isArray(i)){if(i){if(N(i)==="ENOENT")return!0;if(N(i)!=="ENOTDIR")throw i}return t.filter&&!await t.filter(e,s)?!1:(await lt(kh(e,t.tmp,jg)),!0)}return!(await Promise.all(i.map(o=>Lo(Zi(e,o.name),t,o)))).every(o=>o===!0)||t.preserveRoot===!1&&e===Xi(e).root||t.filter&&!await t.filter(e,s)?!1:(await lt(kh(e,t.tmp,Ag)),!0)},kh=async(e,t,s)=>{let i=Zi(t,Rh(e));return await Og(e,i),await s(i)},tr=(e,t)=>(t?.signal?.throwIfAborted(),ht(()=>Wo(e,t,He(e)))??!0),Wo=(e,t,s)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return Wo(e,{...t,tmp:_h(e)},s);let i=t.tmp;if(e===t.tmp&&Xi(e).root!==e)throw new Error("cannot delete temp directory used for deletion");let r=s.isDirectory()?Ve(e):null;if(!Array.isArray(r)){if(r){if(N(r)==="ENOENT")return!0;if(N(r)!=="ENOTDIR")throw r}return t.filter&&!t.filter(e,s)?!1:(ht(()=>Oh(e,i,Cg)),!0)}let o=!0;for(let n of r){let a=Zi(e,n.name);o=Wo(a,t,n)&&o}return!o||t.preserveRoot===!1&&e===Xi(e).root||t.filter&&!t.filter(e,s)?!1:(ht(()=>Oh(e,i,Ge)),!0)},Oh=(e,t,s)=>{let i=Zi(t,Rh(e));return ph(e,i),s(i)};var{unlink:Pg,rmdir:Ng,lstat:Fg}=ut,Dg=$o(zs(Pg)),$g=Mo(Bs(Ye)),Mg=$o(zs(Ng)),Lg=Mo(Bs(Ge)),Wg=async(e,{filter:t,...s})=>{s?.signal?.throwIfAborted();try{return await Mg(e,s),!0}catch(i){if(N(i)==="ENOTEMPTY")return Qi(e,s);throw i}},Ig=(e,{filter:t,...s})=>{s?.signal?.throwIfAborted();try{return Lg(e,s),!0}catch(i){if(N(i)==="ENOTEMPTY")return tr(e,s);throw i}},de=Symbol("start"),Ch=Symbol("child"),er=Symbol("finish"),sr=async(e,t)=>(t?.signal?.throwIfAborted(),await lt(Fg(e).then(s=>Io(e,t,s,de)))??!0),ir=(e,t)=>(t?.signal?.throwIfAborted(),ht(()=>Uo(e,t,He(e),de))??!0),Io=async(e,t,s,i=de)=>{t?.signal?.throwIfAborted();let r=s.isDirectory()?await qe(e):null;if(!Array.isArray(r)){if(r){if(N(r)==="ENOENT")return!0;if(N(r)!=="ENOTDIR")throw r}return t.filter&&!await t.filter(e,s)?!1:(await lt(Dg(e,t)),!0)}let o=i===de?Ch:i,n=(await Promise.all(r.map(a=>Io(jh(e,a.name),t,a,o)))).every(a=>a===!0);if(i===de)return Io(e,t,s,er);if(i===er){if(t.preserveRoot===!1&&e===Ah(e).root||!n||t.filter&&!await t.filter(e,s))return!1;await lt(Wg(e,t))}return!0},Uo=(e,t,s,i=de)=>{let r=s.isDirectory()?Ve(e):null;if(!Array.isArray(r)){if(r){if(N(r)==="ENOENT")return!0;if(N(r)!=="ENOTDIR")throw r}return t.filter&&!t.filter(e,s)?!1:(ht(()=>$g(e,t)),!0)}let o=!0;for(let n of r){let a=i===de?Ch:i,l=jh(e,n.name);o=Uo(l,t,n,a)&&o}if(i===de)return Uo(e,t,s,er);if(i===er){if(t.preserveRoot===!1&&e===Ah(e).root||!o||t.filter&&!t.filter(e,s))return!1;ht(()=>Ig(e,t))}return!0};var zo=process.platform==="win32"?sr:qi,Bo=process.platform==="win32"?ir:Vi;var{rm:Ug}=ut,Go=async(e,t)=>(await Ug(e,{...t,force:!0,recursive:!0}),!0),Ho=(e,t)=>(dh(e,{...t,force:!0,recursive:!0}),!0);var[Ph=0,zg=0]=process.version.replace(/^v/,"").split(".").map(e=>parseInt(e,10)),Nh=Ph>14||Ph===14&&zg>=14,Fh=!Nh||process.platform==="win32"?()=>!1:e=>!e?.signal&&!e?.filter,Dh=!Nh||process.platform==="win32"?()=>!1:e=>!e?.signal&&!e?.filter;var Je=e=>async(t,s)=>{let i=lh(s);return i.glob&&(t=await Ee(t,i.glob)),Array.isArray(t)?!!(await Promise.all(t.map(r=>e(Us(r,i),i)))).reduce((r,o)=>r&&o,!0):!!await e(Us(t,i),i)},Ke=e=>(t,s)=>{let i=hh(s);return i.glob&&(t=ce(t,i.glob)),Array.isArray(t)?!!t.map(r=>e(Us(r,i),i)).reduce((r,o)=>r&&o,!0):!!e(Us(t,i),i)},Mh=Ke(Ho),Bg=Object.assign(Je(Go),{sync:Mh}),Lh=Ke(Bo),Gg=Object.assign(Je(zo),{sync:Lh}),Wh=Ke(ir),Hg=Object.assign(Je(sr),{sync:Wh}),Ih=Ke(Vi),Yg=Object.assign(Je(qi),{sync:Ih}),Uh=Ke(tr),qg=Object.assign(Je(Qi),{sync:Uh}),pt=Ke((e,t)=>Dh(t)?Ho(e,t):Bo(e,t));var $h=Je((e,t)=>Fh(t)?Go(e,t):zo(e,t)),At=Object.assign($h,{rimraf:$h,sync:pt,rimrafSync:pt,manual:Gg,manualSync:Lh,native:Bg,nativeSync:Mh,posix:Yg,posixSync:Ih,windows:Hg,windowsSync:Wh,moveRemove:qg,moveRemoveSync:Uh});At.rimraf=At;var Gs=e=>{try{return Qt(e)}catch{return Gs(Hs(e)),pt(e),Qt(e)}};var ty=(e,t)=>{if(!(e.isSymbolicLink()||e.isDirectory()||e.isFile())){t.isENOENT()||pt(t.fullpath());return}if(e.isSymbolicLink()){let i=Hh(e.fullpath());if(!t.isENOENT()){if((t.isSymbolicLink()&&Hh(t.fullpath()))===i)return;pt(t.fullpath())}if(Gs(Hs(t.fullpath())),Xg(i,t.fullpath()),Vg.O_SYMLINK&&e.mode)try{Bh(t.fullpath(),e.mode)}catch{}return}if(e.isDirectory())t.isDirectory()||Gs(t.fullpath());else{let i=!0;if(!t.isENOENT()&&!t.isFile()?pt(t.fullpath()):ey(e,t)&&(i=!1),i){Gs(Hs(t.fullpath()));try{Kg(e.fullpath(),t.fullpath())}catch{Jg(e.fullpath(),t.fullpath())}}}let s=e.mode;s&&Bh(t.fullpath(),s)};var ey=(e,t)=>{try{return zh("sha512").update(Gh(e.fullpath())).digest("hex")===zh("sha512").update(Gh(t.fullpath())).digest("hex")}catch{return!1}},qh=`..${Qg}`,sy=(e,t)=>{if(e===t)return!0;let s=Yh(e,t),i=Yh(e,t);return!s.startsWith(qh)||!i.startsWith(qh)};var Vh=(e,t)=>{let s=new rh(e),i=rr(e),r=rr(t);if(Hs(i)===i||Hs(r)===r)throw new Error("cannot sync root directory");if(sy(r,i))throw new Error("cannot copy directory into itself or its parent");let[o,n]=[ce("**",{scurry:s,withFileTypes:!0}),ce("**",{cwd:r,withFileTypes:!0})];for(let a of o){if(!a.parent)throw new Error("cannot sync root directory");let l=a.resolve(rr(r,a.relative())),h=l.parent;if(!h)throw new Error("cannot sync root directory");l.lstatSync(),Gs(h.fullpath()),ty(a,l)}for(let a of n){let l=s.cwd.resolve(rr(i,a.relative()));if(l.lstatSync(),l.isENOENT())try{pt(a.fullpath()),Zg(a.fullpath())}catch{}}};import{chmodSync as Jh}from"fs";import{resolve as Kh}from"path";var Xh=()=>{let{bin:e}=k;if(e)if(typeof e=="string")Jh(Kh(e),493);else for(let t of Object.values(e))Jh(Kh(t),493)};import{spawnSync as wb}from"node:child_process";import{relative as qc,resolve as ls}from"node:path/posix";import{writeFileSync as iy}from"fs";var Zh=e=>{let{imports:t}=e;if(t)return Object.fromEntries(Object.entries(t).map(([s,i])=>[s,typeof i=="string"&&i.startsWith("./src/")?"./"+i.substring(6).replace(/\.([cm]?)ts$/,".$1js").replace(/\.tsx$/,".js"):i]))};var ry=(e,t)=>{if(!t)return pt(`${e}/package.json`);let s={type:t==="commonjs"?"commonjs":"module",imports:Zh(k)};iy(`${e}/package.json`,JSON.stringify(s,null,2)+`
13
+ `)},Q=(e,t)=>{t&&T(E.cyan.dim("set dialect"),{where:e,mode:t}),ry(e,t)};import{existsSync as $y,readdirSync as My,unlinkSync as Ly,writeFileSync as Wy}from"node:fs";import{resolve as Iy}from"node:path";import{join as gc}from"node:path/posix";var{esmDialects:oy=[],commonjsDialects:ny=[]}=O,Xe=class{type;name;map=new Map;rmap=new Map;constructor(t,s){this.type=t,this.name=s}addFile(t,s){let i=this.type==="commonjs"?"cts":"mts",r=`-${this.name}.${i}`;if(!t.endsWith(r)&&this.name!=="cjs"&&this.name!=="esm"&&(r=`-${this.name}.ts`),!t.endsWith(r))return;let o=t.substring(0,t.length-r.length)+".ts",n=o+"x",a=s.has(o)?o:s.has(n)?n:void 0;a&&(this.map.set(t,a),this.rmap.set(a,t))}[Symbol.for("nodejs.util.inspect.custom")](){return[this.name,this.type,this.map]}},me=new Map([["cjs",new Xe("commonjs","cjs")],["esm",new Xe("esm","esm")]]);for(let e of ny)me.set("commonjs-"+e,new Xe("commonjs",e));for(let e of oy)me.set("esm-"+e,new Xe("esm",e));for(let e of Jt)for(let t of me.values())t.addFile(e,Jt);for(let[e,t]of me.entries())t.map.size===0&&me.delete(e);me.size&&T(E.cyan.dim("polyfills detected"),me);var W=me;import{dirname as Cy,isAbsolute as Py,resolve as ur}from"node:path";import{readFileSync as Ny,statSync as Fy}from"node:fs";import{dirname as ay,resolve as ly}from"path";var ie=function*(e){for(e=ly(e);e;){yield e;let t=ay(e);if(t===e)break;e=t}};var Qh=e=>"source"in e?e.source:e.children.map(Qh).join(""),Ze=Qh;var Yo={offset:0,offsetMax:1/0,init:(e=1/0)=>{Yo.offset=0,Yo.offsetMax=e}},jt=Yo;function nr(e){var t={},s;for(s in e)t[s]=e[s];return t}function ke(e){return" var y"+(e+("=state.y,x"+(e+"=state.x;")))}function qo(e){return"state.y=y"+(e+(";state.x=x"+(e+";")))}function Ys(e,t,s){if(e.expression){t=!!s.capture&&!e.capture;var i=s.length&&s.abort&&"node.length=ln"+(s.length+";")||"";e=" if((x = "+(e.expression.id+"(state)) "+(t?"!=":"==")+" null)"+((t?"{node.push(x);}else ":"")+("{"+(qo(s.index)+(i+(s.abort+"}"))))))}else i=!!s.capture&&!e.capture,s=nr(s),s.capture=i,!s.length&&i?(s.length=t,e="var ln"+(t+"=node.length;")+(Vo(e.sequence,t+1,s)+"")):e=Vo(e.sequence,t+1,s);return e}function ec(e,t,s){var i=s.index,r=s.abort,o="inv_"+t,n="group_"+t;return s=nr(s),e.capture==="!"&&(s.index=t,s.abort="break "+(o+"")),e.quantifier==="+"?(n=nr(e),n.quantifier="*",s=Ys(e,t,s)+(ec(n,t,s)+"")):e.quantifier==="*"?(s.length=0,s.index=t,s.abort="break "+(n+";"),s=n+(":for(;;){"+(ke(t)+(Ys(e,t,s)+"}")))):e.quantifier==="?"&&e.expression?(s.index=t,s.abort="",s=ke(t)+(Ys(e,t,s)+"")):e.quantifier==="?"?(s.index=t,s.abort="break "+(n+""),s=n+(":{"+(ke(t)+(Ys(e,t,s)+"}")))):s=Ys(e,t,s),e.capture==="!"?o+(":{"+(ke(t)+(s+(qo(i)+(r+"}"))))):e.capture==="="?ke(t)+(s+(qo(t)+"")):s}function Vo(e,t,s){for(var i=e.alternation?"alt_"+t:"",r="";e;e=e.alternation){var o="block_"+t,n=s;e.alternation&&(n=nr(s),n.index=t,n.abort="break "+(o+";"));for(var a="",l=0;l<e.length;l++)a+=ec(e[l],t,n);r=e.alternation?r+(o+(":{"+(ke(t)+(a+(" break "+(i+";}")))))):r+a}return i?i+(":{"+(r+"}")):r}function or(e){throw new SyntaxError('Unexpected token "'+e+'"')}var tc=typeof/./g.sticky=="boolean";function hy(e){return e.length?e:function(t){return e()(t)}}function cy(e){return function(t){if(t.x<t.quasis.length){for(var s=t.quasis[t.x],i=0,r=e.length;i<r;i++)if(s.charCodeAt(t.y+i)!==e.charCodeAt(i))return null;return t.y+=e.length,e}}}function fy(e){return e=tc?new RegExp(e.source,"y"):new RegExp(e.source+"|()","g"),function(t){if(t.x<t.quasis.length){var s=t.quasis[t.x];e.lastIndex=t.y;var i;return tc?e.test(s)&&(i=s.slice(t.y,e.lastIndex)):(s=e.exec(s),s[1]==null&&(i=s[0])),t.y=e.lastIndex,i}}}function uy(e){return typeof e=="function"?hy(e):typeof e=="string"?cy(e):fy(e)}function py(e,t){return{id:"_"+t}}function dy(e,t){return"_"+t}function sc(e,t){return function(s){for(var i=[],r=arguments.length-1;0<r--;)i[r]=arguments[r+1];var o=i.map(py),n=[];r=[];for(var a=null,l,h=r,f,c,u=0;u<s.length+o.length;u++){u%2!==0&&(c=o[u++>>1],h.push({expression:c,capture:f}),f=void 0);var p=s[u>>1];for(c=0;c<p.length;){var d=p[c++];d!==" "&&d!==" "&&d!=="\r"&&d!==`
14
+ `&&(d==="|"&&h.length?h=h.alternation=[]:d===")"&&h.length?(a=null,(h=n.pop())||or(d)):d==="("?(n.push(h),h.push(a={sequence:[],capture:f}),h=a.sequence,f=void 0):d===":"||d==="="||d==="!"?(f=d,p[c]&&p[c]!=="("&&or(d)):d==="?"&&!h.length&&a?(f=p[c++],f===":"||f==="="||f==="!"?(a.capture=f,f=void 0):or(d)):d!=="?"&&d!=="+"&&d!=="*"||!(l=h[h.length-1])?or(d):l.quantifier=d)}}return l=[e,t].concat(i.map(uy)),f=Function,i="_n,_t,"+i.map(dy).join(","),o=t?"_t":null,r="(function(state){"+(ke(1)+(" var node=[];var x;"+(Vo(r,2,{index:1,length:0,abort:"return;",capture:!0})+(" if(_n)node.tag=_n;return "+((o?"("+(o+")(node)"):"node")+";})"))))),new f(i,"return "+r).apply(void 0,l)}}function ar(e){return function(t){for(var s=[],i=arguments.length-1;0<i--;)s[i]=arguments[i+1];return typeof t=="string"&&(t=[t]),e({quasis:t,expressions:s,x:0,y:0})}}var Qe={tokenDelimiterTypes:new Set(["ArrayOpen","ArrayClose","ObjectOpen","ObjectClose"]),tokenIgnoredTypes:new Set(["Newline","Whitespace","CommentLine","CommentBlock","Comma","CommaTrailing","Colon"]),tokenLiteralTypes:new Set(["Null","True","False","Number","String","Array","Object"]),isEven:e=>!(e%2),isOdd:e=>!Qe.isEven(e),isString:e=>typeof e=="string",isToken:e=>!Qe.isString(e),isTokenDelimiter:e=>Qe.tokenDelimiterTypes.has(e.type),isTokenIgnored:e=>Qe.tokenIgnoredTypes.has(e.type),isTokenLiteral:e=>Qe.tokenLiteralTypes.has(e.type),tokens2matchers:e=>{let t=new Map;return Object.keys(e).reduce((s,i)=>{let r=e[i],o=r.unwrapped?r:t.get(r)||sc(i,r);return t.set(r,o),s[i]=o,s},{})}},Y=Qe;var my=e=>{let t=Y.tokens2matchers(e),s=t.EarlyReturn`${""}`,i=t.Insufficient`${/[^]?/}`,r=t.Invalid`${/[^]/}`,o=t.Newline`${/\r?\n|\r/}`,n=t.Whitespace`${/[ \t]+/}`,a=t.CommentLine`${/\/\/.*/}`,l=t.CommentBlock`${/\/\*[^]*?\*\//}`,h=t.Passthrough`${o} | ${n} | ${a} | ${l}`,f=t.Passthrough`${h}*`,c=t.Whitespace`${/(?:[ \t\r\n]|\/\/.*|\/\*[^]*?\*\/)*/}`,u=t.Newline===t.Whitespace&&t.Whitespace===t.CommentLine&&t.CommentLine===t.CommentBlock?c:f,p=t.Comma`${","}`,d=t.CommaTrailing`${","}`,m=t.Colon`${":"}`,y=t.Null`${"null"}`,g=t.True`${"true"}`,w=t.False`${"false"}`,S=t.Passthrough`${g} | ${w}`,b=t.Number`${/-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?/}`,v=t.String`${/"(?:[^\u0000-\u001F\\"]|\\["bfnrt\\/]|\\u[0-9a-fA-F]{4})*"/}`,R=t.ArrayOpen`${"["}`,L=t.ArrayClose`${"]"}`,q=t.Passthrough`${u} ${()=>Mr} ${u}`,st=t.Passthrough`${q} (!${s} ${p} ${q})* ${d}?`,Vt=t.Array`${R} ${u} ${st}? ${u} (${s} | ${L})`,Nf=t.ObjectOpen`${"{"}`,Ff=t.ObjectClose`${"}"}`,Dn=t.Passthrough`${u} ${v} (${s} | ${u} ${m} ${u} ${()=>Mr} ${u})`,Df=t.Passthrough`${Dn} (!${s} ${p} ${Dn})* ${d}?`,$f=t.Object`${Nf} ${u} ${Df}? ${u} (${s} | ${Ff})`,Mr=t.Passthrough`${y} | ${S} | ${b} | ${v} | ${$f} | ${Vt}`;return t.Root`${u} (${Mr} | ${i}) (${s} | ${u} ${r}?)`},lr=my;var tt=e=>t=>{let s=t[0];return jt.offset+=s.length,{type:e,source:s}},Jo=e=>t=>{let s=t.flat();return{type:e,children:s}},ic={EarlyReturn:()=>{if(jt.offset>jt.offsetMax)return[]},Insufficient:e=>{throw e[0].length&&ic.Invalid(e),new SyntaxError("Unexpected end of JSONC input")},Invalid:e=>{throw new SyntaxError(`Unexpected token ${e[0]} in JSONC at position ${jt.offset}`)},Passthrough:e=>e.flat().filter(Y.isToken),Newline:tt("Newline"),Whitespace:tt("Whitespace"),CommentLine:tt("CommentLine"),CommentBlock:tt("CommentBlock"),Comma:tt("Comma"),CommaTrailing:tt("CommaTrailing"),Colon:tt("Colon"),Null:tt("Null"),True:tt("True"),False:tt("False"),Number:tt("Number"),String:tt("String"),ArrayOpen:tt("ArrayOpen"),ArrayClose:tt("ArrayClose"),Array:Jo("Array"),ObjectOpen:tt("ObjectOpen"),ObjectClose:tt("ObjectClose"),Object:Jo("Object"),Root:Jo("Root")},hr=ic;var qs=e=>(jt.offset+=e[0].length,""),cr=e=>{let t=e.join("");return jt.offset+=t.length,t},Ct=(e,t)=>t;Ct.unwrapped=!0;var gy={...hr,Passthrough:cr,Newline:qs,Whitespace:qs,CommentLine:qs,CommentBlock:qs,Comma:Ct,CommaTrailing:qs,Colon:Ct,Null:Ct,True:Ct,False:Ct,Number:Ct,String:Ct,ArrayOpen:Ct,ArrayClose:Ct,Array:cr,ObjectOpen:Ct,ObjectClose:Ct,Object:cr,Root:cr},rc=gy;var yy=ar(lr(rc)),oc=yy;var wy=e=>(jt.init(),oc(e)),Vs=wy;var Ko=JSON.parse,by=(e,t)=>{if(e=`${e}`,t)return Ko(Vs(e),t);try{return Ko(e)}catch(s){let i=Vs(e);if(e===i)throw s;return Ko(i)}},ge=by;var Sy=ar(lr(hr)),nc=Sy;var vy=(e,t)=>(jt.init(t),nc(e)),fr=vy;var Ey=(e,t)=>{let s=null,i=0,r=l=>{l.start>t||l.end<=t-1||s&&Y.isTokenLiteral(s)||s&&Y.isTokenIgnored(l)||(s=l)},o=(l,h,f,c)=>{let{type:u,source:p}=l,d=i,m=i+=p.length,y={type:u,source:p,token:l,parent:h,depth:f,index:c,start:d,end:m};return r(y),y},n=(l,h,f,c)=>{let{type:u}=l,p={type:u,children:[],token:l,parent:h,depth:f,index:c};return p.children=l.children.map((d,m)=>a(d,p,f+1,m)).filter(Y.isTokenLiteral),p.children.forEach((d,m)=>d.index=m),p},a=(l,h,f,c)=>"children"in l?n(l,h,f,c):o(l,h,f,c);return a(e,null,-1,-1),s},xy=e=>{if(!e)return[];let t=[];for(;e;){let s=e.parent;if(!s)break;Y.isTokenLiteral(e)&&(s.type==="Object"?Y.isEven(e.index)?t.unshift(JSON.parse(e.source)):t.unshift(JSON.parse(s.children[e.index-1].source)):s.type==="Array"&&t.unshift(e.index)),e=s}return t},Ty=e=>{if(!e)return!1;let t=e.parent?.type;return t==="Object"?Y.isTokenLiteral(e)?Y.isEven(e.index):e.parent?.parent?.type==="Array":t==="Array"?Y.isTokenLiteral(e)||e.parent?.parent?.type==="Array":!1},_y=e=>{if(!e)return!1;let t=!e.parent?.children.length,s=e.parent?.type;return s==="Object"?t||Y.isTokenDelimiter(e)||Y.isTokenLiteral(e)&&Y.isOdd(e.index):s==="Array"?e.depth>1:!1},ky=(e,t)=>{if(!t||!e)return;let s=e.parent?.type;if(Y.isTokenLiteral(e))return s==="Array"?e.index:ge(Ze(e));if(s==="Array")return e.parent?.index},Oy=(e,t,s)=>{if(!t||!e)return;if(Y.isTokenLiteral(e))return ge(Ze(e));if(s)return;let{parent:i}=e;if(!(!i||!i.token)&&!(i.type!=="Array"&&i.type!=="Object"))return ge(Ze(i.token))},Ry=(e,t,s=!0)=>{let r=fr(e,s?t:1/0),o=Ey(r,t),n=xy(o),a=Ty(o),l=_y(o),h=ky(o,a),f=Oy(o,l,s),c=o?{type:o.type,start:o.start,end:o.end,source:o.source}:void 0;return{path:n,property:h,value:f,token:c,isInsideProperty:a,isInsideValue:l}},ac=Ry;var lc=JSON.stringify;var Ay=e=>{try{return ge(e),!0}catch{return!1}},hc=Ay;var jy={ast:{parse:fr,stringify:Ze},lookup:ac,parse:ge,stringify:lc,strip:Vs,validate:hc},cc=jy;var ts=e=>{try{return Fy(e).isFile()}catch{return!1}},Dy,es=()=>{let e=O.project??"tsconfig.json";return Dy??=uc(Xo(e))},Xo=(e,t=process.cwd())=>{if(Py(e))return e;let s=ur(t,e);if(!ts(s)&&ts(s+".json")&&(s+=".json"),ts(s)||e.startsWith(".\\")||e.startsWith("./"))return s;for(let i of ie(t)){let r=ur(i,"node_modules",e);if(ts(r))return r;let o=ur(i,"node_modules",e),n=ur(o,"tsconfig.json");if(ts(n))return n;if(ts(o+".json"))return o+".json"}throw new Error("Could not resolve tsconfig file location",{cause:{target:e,from:t}})},fc=(e,t)=>{for(let[s,i]of Object.entries(t))typeof i!="object"||Array.isArray(i)?e[s]??=i:s in e?typeof e[s]=="object"&&e[s]&&!Array.isArray(e[s])&&(e[s]=fc(e[s],i)):e[s]=i;return e},uc=(e,t=new Set)=>{try{let s=cc.parse(Ny(Xo(e),"utf8"));if(!s||typeof s!="object"||Array.isArray(s))throw new Error("invalid data, expected object",{cause:s});if(s.compilerOptions||(s.compilerOptions={}),typeof s.extends=="string"){let i=Xo(s.extends,Cy(e));t.has(i)||(t.add(i),fc(s,uc(i,t)))}return s}catch(s){throw new Error("Invalid tsconfig file",{cause:s})}};var pc=()=>{es().compilerOptions.verbatimModuleSyntax&&(_("verbatimModuleSyntax detected"),D(`verbatimModuleSyntax is incompatible with multi-dialect builds. Either remove
15
15
  this field from tsconfig.json, or set a single dialect in the "dialects"
16
16
  field in package.json, for example:
17
17
 
@@ -28,8 +28,8 @@ or
28
28
  "dialects": ["commonjs"]
29
29
  }
30
30
  }
31
- `),Me(),process.exit(1))};var{dialects:Zo=["esm","commonjs"],esmDialects:Uy=[],commonjsDialects:zy=[],exclude:By=[]}=O,yc=By.map(e=>`../${e.replace(/^\.\//,"")}`),Gy={compilerOptions:{types:["node"],rootDir:"./",declaration:!0,declarationMap:!0,esModuleInterop:!0,forceConsistentCasingInFileNames:!0,inlineSources:!0,jsx:"react",module:"nodenext",moduleResolution:"nodenext",noUncheckedIndexedAccess:!0,resolveJsonModule:!0,skipLibCheck:!0,sourceMap:!0,strict:!0,target:"es2022"}},Hy=()=>({extends:O.project===void 0?"../tsconfig.json":gc("..",O.project),compilerOptions:{target:es().compilerOptions.target===void 0?"es2022":void 0,rootDir:"../src",module:"nodenext",moduleResolution:"nodenext"}}),dc=(e,t)=>{let s=[...yc,"../src/**/*.mts","../src/package.json"];for(let i of L.values())if(!(i.name===e&&i.type==="commonjs"))for(let r of i.map.keys())s.push(`../${gc(r)}`);return F("excluded:",s),{extends:"./build.json",include:["../src/**/*.ts","../src/**/*.cts","../src/**/*.tsx","../src/**/*.json"],exclude:s,compilerOptions:{outDir:"../.tshy-build/"+t}}},mc=(e,t)=>{let s=[...yc,"../src/package.json"];for(let i of L.values())if(!(i.name===e&&i.type==="esm"))for(let r of i.map.keys())s.push(`../${r.replace(/^\.\//,"")}`);return{extends:"./build.json",include:["../src/**/*.ts","../src/**/*.mts","../src/**/*.tsx","../src/**/*.json"],exclude:s,compilerOptions:{outDir:"../.tshy-build/"+t}}};Qt(".tshy");var ss=(e,t)=>Wy(`.tshy/${e}.json`,JSON.stringify(t,null,2)+`
32
- `);T(E.cyan.dim("writing tsconfig files..."));O.project===void 0&&!My("tsconfig.json")?(T("using recommended tsconfig.json"),ss("../tsconfig",Gy)):(Zo.length>1&&pc(),T("using existing tsconfig.json"));for(let e of $y(".tshy"))Ly(Iy(".tshy",e));ss("build",Hy());if(Zo.includes("commonjs")){ss("commonjs",dc("cjs","commonjs"));for(let e of zy)ss(`commonjs-${e}`,dc(e,`commonjs/${e}`))}if(Zo.includes("esm")){ss("esm",mc("esm","esm"));for(let e of Uy)ss(`esm-${e}`,mc(e,`esm/${e}`))}import{writeFileSync as Ow}from"fs";import{symlink as Rw}from"fs/promises";import{dirname as un,relative as Oc,resolve as pn,sep as fn}from"path";var pr=e=>{if(e&&typeof e=="object"&&!Array.isArray(e)){let t,s=[];for(let[i,r]of Object.entries(e))if(i){if(t===void 0){if(!i.startsWith("#")&&i!=="."&&!i.startsWith("./"))return Js(e).map(o=>[".",...o]);t=i.charAt(0)}if(t==="#"&&(i==="#"||!i.startsWith("#"))||t==="."&&i!=="."&&!i.startsWith("./"))throw new Error(`invalid ${t==="."?"exports":"imports"} object, all keys must start with ${t}. Found ${i}.`);s.push(...Js(r).map(o=>[i,...o]))}return s}return Js(e).map(t=>[".",...t])},Yy=(e,t)=>{if(e.size>t.size)return!1;for(let s of e)if(!t.has(s))return!1;return!0},Js=(e,t=[],s=[])=>{if(e===void 0)return s;if(e===null||typeof e=="string")return s.push([new Set(t),e]),s;if(Array.isArray(e)){for(let i of e)if(Js(i,t,s),!i||typeof i=="string")break;return s}for(let[i,r]of Object.entries(e)){if(i.startsWith("#")||i==="."||i.startsWith("./"))throw new Error(`Expected valid import condition, got: ${i}`);let o=i==="default"?t:t.concat(i),n=new Set(o);if(s.some(([l])=>Yy(l,n))||Js(r,o,s),i==="default")break}return s};var wc=e=>[...new Set(pr(e).map(([t,s,i])=>i).filter(t=>!!t))];var bc=e=>{let t=pr(e),s=[];for(let[i,r]of t)s.some(o=>qy(o,r))||s.push([...r]);return s},qy=(e,t)=>{if(e.length!==t.size)return!1;for(let s of e)if(!t.has(s))return!1;return!0};import{dirname as xw,resolve as Tw}from"path";import{pathToFileURL as _w}from"url";import on from"node:module";import{stat as Vy}from"node:fs/promises";import{fileURLToPath as Jy}from"node:url";var Ky=e=>typeof e=="object"||e.startsWith("file://")?Jy(e):e,et=async e=>{try{return(await Vy(Ky(e))).isFile()}catch{return!1}};var Sc=typeof process=="object"&&process&&process.platform==="win32";var Qo=e=>/^\.\.?\//.test(e)||Sc&&/^\.\.?\\/.test(e);import{realpath as Xy,stat as Zy}from"node:fs/promises";import{dirname as Qy,resolve as vc,sep as tn}from"node:path";var tw=async e=>{try{return(await Zy(e)).isDirectory()}catch{return!1}};var dr=async(e,t)=>{for(let s of ie(Qy(t))){let i=vc(s,"node_modules")+tn,r=e===null?i:(e?vc(i,e):i)+tn;if(await tw(r))try{return await Xy(r)+tn}catch{}}};import{readFile as ew}from"node:fs/promises";var Ec=async e=>{try{return JSON.parse(await ew(e,"utf8"))}catch{return null}};var sw=e=>!!e&&(typeof e=="object"||typeof e=="string"),iw=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;for(let t in e)if(!t.startsWith("#"))return!1;return!0},rw=e=>!!e&&typeof e=="object"&&(typeof e.name=="string"||typeof e.name>"u")&&(typeof e.main=="string"||typeof e.main>"u")&&(typeof e.module=="string"||typeof e.module>"u")&&(typeof e.exports>"u"||sw(e.exports))&&(typeof e.imports>"u"||iw(e.imports)),ow=e=>rw(e)?e:null,ye=async e=>ow(await Ec(e));var Ks=(e,t)=>{let s=Object.keys(t).filter(i=>i.length<=e.length).sort((i,r)=>r.length-i.length).map(i=>[i,i.split("*")]).filter(([,i])=>i.length===2);for(let[i,[r,o]]of s)if(e.startsWith(r)&&e.endsWith(o)){let n=e.substring(r.length,e.length-o.length);return[i,n]}return null};var dt=(e,t)=>{if(e===null||typeof e=="string")return e;if(Array.isArray(e)){for(let i of e){let r=dt(i,t);if(r)return r}return null}let s=new Set(["default"]);for(let i of t.conditions??["import","node"])i.startsWith("!")?s.delete(i.slice(1)):s.add(i);for(let[i,r]of Object.entries(e))if(s.has(i))return dt(r,t);return null};var re=(e,t,s,i,r)=>{let o=e?e==="."||e.startsWith("./")?e:`./${e}`:".";if(typeof t=="string"||Array.isArray(t)){let h=o==="."&&dt(t,r);if(!h)throw Xs(o,s,i);return h}if(o==="."){let h=dt(t,r);if(h)return h}let n=t,a=n[o];if(a!==void 0){let h=dt(a,r);if(!h)throw Xs(o,s,i);return h}let l=Ks(o,n);if(l){let[h,f]=l,c=dt(n[h],r);if(!c)throw Xs(o,s,i);return c.replace(/\*/g,f)}throw Xs(o,s,i)};import{pathToFileURL as hw}from"url";var os=e=>typeof e=="object"?e:e.startsWith("file://")?new URL(e):hw(e);import{fileURLToPath as cw}from"url";var $t=e=>typeof e=="object"||e.startsWith("file://")?cw(e):e;typeof on.isBuiltin!="function"&&(on.isBuiltin=e=>(e.startsWith("node:")&&(e=e.substring(5)),on.builtinModules.includes(e)));import{realpath as Qs}from"fs/promises";import mr from"module";import{basename as pw,dirname as dw,isAbsolute as mw,resolve as _c}from"path";import{fileURLToPath as gw,pathToFileURL as an}from"url";import{resolve as Zs}from"path";import{pathToFileURL as Oe}from"url";var ns=async(e,t,s)=>{let{originalParent:i}=s,r=e?.match(/^(@[^\/]+\/[^\/]+|[^\/]+)(?:\/(.*))?$/),[,o,n]=e===null?[,null,""]:r||["","",""],a=await dr(o,t);if(!a)throw is(o,i);let l=Zs(a,"index.js"),h=Zs(a,"package.json"),f=await ye(h),c=n?Zs(a,n):!1;if(!f)if(c){if(await et(c))return Oe(c);throw bt(c,i)}else{if(await et(l))return Oe(l);throw is(a,i)}if(f.exports){let u=re(n,f.exports,h,i,s),p=Zs(a,u);if(await et(p))return Oe(p);throw bt(p,i)}else if(c){if(await et(c))return Oe(c);throw bt(c,i)}else if(f.main){let u=Zs(a,f.main);if(await et(u))return Oe(u);if(await et(l))return Oe(l);throw is(a,i)}else{if(await et(l))return Oe(l);throw is(a,i)}};import{dirname as fw,resolve as xc}from"path";import{pathToFileURL as uw}from"url";var Tc=async(e,t,s)=>{let{originalParent:i}=s,r=e.match(/^(@[^\/]+\/[^\/]+|[^\/]+)(?:\/(.*))?$/);if(!r)throw rn(e);for(let o of ie(fw(t))){let n=xc(o,"package.json"),a=await ye(n);if(a){if(a.name&&a.exports){let[,l,h]=r;if(l===a.name){let f=re(h,a.exports,n,i,s),c=xc(o,f);if(await et(c))return uw(c);throw bt(c,i)}}if(e.startsWith("#")){if(!a.imports)throw rs(e,n,i);let l=a.imports[e];if(l!==void 0){let m=dt(l,s);if(!m)throw rs(e,n,i);return m.startsWith("#")?ns(null,t,s):mt(m,n,s)}let h=Ks(e,a.imports);if(!h)throw rs(e,n,i);let[f,c]=h,u=a.imports[f],p=dt(u,s);if(!p)throw rs(e,n,i);if(p.startsWith("#"))return ns(null,t,s);let d=p.replace(/\*/g,c);return mt(d,n,s)}break}}return ns(e,t,s)};typeof mr.isBuiltin!="function"&&(mr.isBuiltin=e=>(e.startsWith("node:")&&(e=e.substring(5)),mr.builtinModules.includes(e)));var yw=async e=>(e=$t(e),_c(await Qs(dw(e)),pw(e))),mt=async(e,t=void 0,s={})=>{if(typeof e=="string"&&e.startsWith("file://")&&(e=new URL(e)),typeof e=="object"){if(!await et(e))throw bt(String(e),String(t));let n=await Qs($t(e));return n!==gw(e)?an(n):e}let i=t?os(await yw(t)):void 0;if(Qo(e)){if(!i)throw nn(e,t);let n=new URL(e,i);if(!await et(n))throw bt(e,String(t));return an(await Qs(new URL(e,i)))}if(mw(e)){if(!await et(e))throw bt(e,String(t));return an(await Qs(e))}if(mr.isBuiltin(String(e)))return String(e);let r=$t(t||_c(await Qs(process.cwd()),"x")),o={...s,originalParent:String(s.originalParent||r)};return e?Tc(e,r,o):ns(e,r,o)};var rn=(e,t=mt)=>{let s=new Error("invalid import() specifier: "+e);return Error.captureStackTrace(s,t),s},as=(e,t=mt)=>{let s=new Error(`Not a valid package: ${e}`);return Error.captureStackTrace(s,t),s},nn=(e,t,s=mt)=>{let i=Object.assign(new Error("relative import without parentURL"),{url:e,parentURL:t});return Error.captureStackTrace(i,s),i},Xs=(e,t,s,i=mt)=>{let r=e==="."?'No "exports" main defined':`Package subpath '${e}' is not defined by "exports"`,o=Object.assign(new Error(`${r} in ${t} imported from ${s}`),{code:"ERR_PACKAGE_PATH_NOT_EXPORTED"});return Error.captureStackTrace(o,i),o},is=(e,t,s=mt)=>{let i=Object.assign(new Error(`Cannot find package '${e}' imported from ${t}`),{code:"ERR_MODULE_NOT_FOUND"});return Error.captureStackTrace(i,s),i},bt=(e,t,s=mt)=>{let i=Object.assign(new Error(`Cannot find module '${e}' imported from ${t}`),{code:"ERR_MODULE_NOT_FOUND"});return Error.captureStackTrace(i,s),i},rs=(e,t,s,i=mt)=>{let r=Object.assign(new Error(`Package import specifier "${e}" is not defined in package ${t} imported from ${s}`),{code:"ERR_PACKAGE_IMPORT_NOT_DEFINED"});return Error.captureStackTrace(r,i),r};import{dirname as vw,resolve as Ew}from"path";import{pathToFileURL as kc}from"url";var ln=e=>e?ww(e)?Object.keys(e).filter(t=>t==="."||t.startsWith("./")):["."]:[],ww=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;for(let t in e)if(t!=="."&&!t.startsWith("./"))return!1;return!0};import{resolve as bw}from"node:path";var gr=async(e,t)=>{let s=Rs(e[0])+(e[0].endsWith("/")?"":"*/")+"**"+(e[1].startsWith("/")?"":"/*")+Rs(e[1]);return(await Ee(s,{posix:!0,absolute:!1,nodir:!0,cwd:t,dotRelative:!0})).map(r=>[r.substring(e[0].length,r.length-e[1].length),bw(t,r)])};var hn=async(e,t={})=>{let s=$t(e),i=vw(s),r=await ye(s);if(!r)throw as(e,hn);let o={},{exports:n}=r;for(let a of ln(n)){let l;try{l=re(a,n,s,s,t)}catch{}if(!l)continue;let h=l.split("*"),f=a.split("*");if(h.length===2&&f.length===2)for(let[c,u]of await gr(h,i))o[f[0]+c+f[1]]=kc(u);else o[a]=kc(Ew(i,l))}return o};var cn=async(e,t={})=>{let s=$t(e),i=xw(s),r=os(e),o=await ye(s);if(!o)throw as(e,cn);let n={};for(let[a,l]of kw(o,t)){let h=l.match(/^(@[^\/]+\/[^\/]+|[^\/]+)/),f=o.name;if(!h)continue;let c=a.split("*"),u=l.split("*");if(!(c.length===2&&u.length===2)){try{n[a]=await mt(l,r)}catch{}continue}let d=h[1]===".";if(d){for(let[b,v]of await gr(u,i))n[c[0]+b+c[1]]=_w(v);continue}let m=h[1]===f,y=!d&&!m?h[1]:null,g=y?await dr(y,i):i;if(!g)continue;let w=Tw(g,"package.json");if(!await et(w))continue;let S=await hn(w);for(let[b,v]of Object.entries(S)){if(b==="."||b==="./")continue;let R=y+b.substring(1);if(R.startsWith(u[0])&&R.endsWith(u[1])){let $=c[0]+R.substring(u[0].length,R.length-u[1].length)+c[1];try{n[$]=await mt(v,r)}catch{}}}}return n},kw=(e,t)=>{let s=[],{imports:i}=e;if(!i||typeof i!="object")return s;for(let[r,o]of Object.entries(i)){let n=dt(o,t);n&&!n.startsWith("#")&&s.push([r,n])}return s};import{fileURLToPath as Aw}from"url";var Rc=new Set,Ac=e=>{let t=[...jc.entries()];if(!t.length)return!1;let s=new Set(t.map(([i])=>un(i)));return T("save import linker",e),Ow(e,`import { mkdirSync } from 'node:fs'
31
+ `),$e(),process.exit(1))};var{dialects:Zo=["esm","commonjs"],esmDialects:Uy=[],commonjsDialects:zy=[],exclude:By=[]}=O,yc=By.map(e=>`../${e.replace(/^\.\//,"")}`),Gy={compilerOptions:{types:["node"],rootDir:"./",declaration:!0,declarationMap:!0,esModuleInterop:!0,forceConsistentCasingInFileNames:!0,inlineSources:!0,jsx:"react",module:"nodenext",moduleResolution:"nodenext",noUncheckedIndexedAccess:!0,resolveJsonModule:!0,skipLibCheck:!0,sourceMap:!0,strict:!0,target:"es2022"}},Hy=()=>({extends:O.project===void 0?"../tsconfig.json":gc("..",O.project),compilerOptions:{target:es().compilerOptions.target===void 0?"es2022":void 0,rootDir:"../src",module:"nodenext",moduleResolution:"nodenext"}}),dc=(e,t)=>{let s=[...yc,"../src/**/*.mts","../src/package.json"];for(let i of W.values())if(!(i.name===e&&i.type==="commonjs"))for(let r of i.map.keys())i.name===e&&r.endsWith(".ts")||s.push(`../${gc(r)}`);return D("excluded:",s),{extends:"./build.json",include:["../src/**/*.ts","../src/**/*.cts","../src/**/*.tsx","../src/**/*.json"],exclude:[...new Set(s)],compilerOptions:{outDir:"../.tshy-build/"+t}}},mc=(e,t)=>{let s=[...yc,"../src/package.json"];for(let i of W.values())if(!(i.name===e&&i.type==="esm"))for(let r of i.map.keys())i.name===e&&r.endsWith(".ts")||s.push(`../${r.replace(/^\.\//,"")}`);return{extends:"./build.json",include:["../src/**/*.ts","../src/**/*.mts","../src/**/*.tsx","../src/**/*.json"],exclude:[...new Set(s)],compilerOptions:{outDir:"../.tshy-build/"+t}}};Qt(".tshy");var ss=(e,t)=>Wy(`.tshy/${e}.json`,JSON.stringify(t,null,2)+`
32
+ `);T(E.cyan.dim("writing tsconfig files..."));O.project===void 0&&!$y("tsconfig.json")?(T("using recommended tsconfig.json"),ss("../tsconfig",Gy)):(Zo.length>1&&pc(),T("using existing tsconfig.json"));for(let e of My(".tshy"))Ly(Iy(".tshy",e));ss("build",Hy());if(Zo.includes("commonjs")){ss("commonjs",dc("cjs","commonjs"));for(let e of zy)ss(`commonjs-${e}`,dc(e,`commonjs/${e}`))}if(Zo.includes("esm")){ss("esm",mc("esm","esm"));for(let e of Uy)ss(`esm-${e}`,mc(e,`esm/${e}`))}import{writeFileSync as Ow}from"fs";import{symlink as Rw}from"fs/promises";import{dirname as un,relative as Oc,resolve as pn,sep as fn}from"path";var pr=e=>{if(e&&typeof e=="object"&&!Array.isArray(e)){let t,s=[];for(let[i,r]of Object.entries(e))if(i){if(t===void 0){if(!i.startsWith("#")&&i!=="."&&!i.startsWith("./"))return Js(e).map(o=>[".",...o]);t=i.charAt(0)}if(t==="#"&&(i==="#"||!i.startsWith("#"))||t==="."&&i!=="."&&!i.startsWith("./"))throw new Error(`invalid ${t==="."?"exports":"imports"} object, all keys must start with ${t}. Found ${i}.`);s.push(...Js(r).map(o=>[i,...o]))}return s}return Js(e).map(t=>[".",...t])},Yy=(e,t)=>{if(e.size>t.size)return!1;for(let s of e)if(!t.has(s))return!1;return!0},Js=(e,t=[],s=[])=>{if(e===void 0)return s;if(e===null||typeof e=="string")return s.push([new Set(t),e]),s;if(Array.isArray(e)){for(let i of e)if(Js(i,t,s),!i||typeof i=="string")break;return s}for(let[i,r]of Object.entries(e)){if(i.startsWith("#")||i==="."||i.startsWith("./"))throw new Error(`Expected valid import condition, got: ${i}`);let o=i==="default"?t:t.concat(i),n=new Set(o);if(s.some(([l])=>Yy(l,n))||Js(r,o,s),i==="default")break}return s};var wc=e=>[...new Set(pr(e).map(([t,s,i])=>i).filter(t=>!!t))];var bc=e=>{let t=pr(e),s=[];for(let[i,r]of t)s.some(o=>qy(o,r))||s.push([...r]);return s},qy=(e,t)=>{if(e.length!==t.size)return!1;for(let s of e)if(!t.has(s))return!1;return!0};import{dirname as xw,resolve as Tw}from"path";import{pathToFileURL as _w}from"url";import on from"node:module";import{stat as Vy}from"node:fs/promises";import{fileURLToPath as Jy}from"node:url";var Ky=e=>typeof e=="object"||e.startsWith("file://")?Jy(e):e,et=async e=>{try{return(await Vy(Ky(e))).isFile()}catch{return!1}};var Sc=typeof process=="object"&&process&&process.platform==="win32";var Qo=e=>/^\.\.?\//.test(e)||Sc&&/^\.\.?\\/.test(e);import{realpath as Xy,stat as Zy}from"node:fs/promises";import{dirname as Qy,resolve as vc,sep as tn}from"node:path";var tw=async e=>{try{return(await Zy(e)).isDirectory()}catch{return!1}};var dr=async(e,t)=>{for(let s of ie(Qy(t))){let i=vc(s,"node_modules")+tn,r=e===null?i:(e?vc(i,e):i)+tn;if(await tw(r))try{return await Xy(r)+tn}catch{}}};import{readFile as ew}from"node:fs/promises";var Ec=async e=>{try{return JSON.parse(await ew(e,"utf8"))}catch{return null}};var sw=e=>!!e&&(typeof e=="object"||typeof e=="string"),iw=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;for(let t in e)if(!t.startsWith("#"))return!1;return!0},rw=e=>!!e&&typeof e=="object"&&(typeof e.name=="string"||typeof e.name>"u")&&(typeof e.main=="string"||typeof e.main>"u")&&(typeof e.module=="string"||typeof e.module>"u")&&(typeof e.exports>"u"||sw(e.exports))&&(typeof e.imports>"u"||iw(e.imports)),ow=e=>rw(e)?e:null,ye=async e=>ow(await Ec(e));var Ks=(e,t)=>{let s=Object.keys(t).filter(i=>i.length<=e.length).sort((i,r)=>r.length-i.length).map(i=>[i,i.split("*")]).filter(([,i])=>i.length===2);for(let[i,[r,o]]of s)if(e.startsWith(r)&&e.endsWith(o)){let n=e.substring(r.length,e.length-o.length);return[i,n]}return null};var dt=(e,t)=>{if(e===null||typeof e=="string")return e;if(Array.isArray(e)){for(let i of e){let r=dt(i,t);if(r)return r}return null}let s=new Set(["default"]);for(let i of t.conditions??["import","node"])i.startsWith("!")?s.delete(i.slice(1)):s.add(i);for(let[i,r]of Object.entries(e))if(s.has(i))return dt(r,t);return null};var re=(e,t,s,i,r)=>{let o=e?e==="."||e.startsWith("./")?e:`./${e}`:".";if(typeof t=="string"||Array.isArray(t)){let h=o==="."&&dt(t,r);if(!h)throw Xs(o,s,i);return h}if(o==="."){let h=dt(t,r);if(h)return h}let n=t,a=n[o];if(a!==void 0){let h=dt(a,r);if(!h)throw Xs(o,s,i);return h}let l=Ks(o,n);if(l){let[h,f]=l,c=dt(n[h],r);if(!c)throw Xs(o,s,i);return c.replace(/\*/g,f)}throw Xs(o,s,i)};import{pathToFileURL as hw}from"url";var os=e=>typeof e=="object"?e:e.startsWith("file://")?new URL(e):hw(e);import{fileURLToPath as cw}from"url";var Mt=e=>typeof e=="object"||e.startsWith("file://")?cw(e):e;typeof on.isBuiltin!="function"&&(on.isBuiltin=e=>(e.startsWith("node:")&&(e=e.substring(5)),on.builtinModules.includes(e)));import{realpath as Qs}from"fs/promises";import mr from"module";import{basename as pw,dirname as dw,isAbsolute as mw,resolve as _c}from"path";import{fileURLToPath as gw,pathToFileURL as an}from"url";import{resolve as Zs}from"path";import{pathToFileURL as Oe}from"url";var ns=async(e,t,s)=>{let{originalParent:i}=s,r=e?.match(/^(@[^\/]+\/[^\/]+|[^\/]+)(?:\/(.*))?$/),[,o,n]=e===null?[,null,""]:r||["","",""],a=await dr(o,t);if(!a)throw is(o,i);let l=Zs(a,"index.js"),h=Zs(a,"package.json"),f=await ye(h),c=n?Zs(a,n):!1;if(!f)if(c){if(await et(c))return Oe(c);throw bt(c,i)}else{if(await et(l))return Oe(l);throw is(a,i)}if(f.exports){let u=re(n,f.exports,h,i,s),p=Zs(a,u);if(await et(p))return Oe(p);throw bt(p,i)}else if(c){if(await et(c))return Oe(c);throw bt(c,i)}else if(f.main){let u=Zs(a,f.main);if(await et(u))return Oe(u);if(await et(l))return Oe(l);throw is(a,i)}else{if(await et(l))return Oe(l);throw is(a,i)}};import{dirname as fw,resolve as xc}from"path";import{pathToFileURL as uw}from"url";var Tc=async(e,t,s)=>{let{originalParent:i}=s,r=e.match(/^(@[^\/]+\/[^\/]+|[^\/]+)(?:\/(.*))?$/);if(!r)throw rn(e);for(let o of ie(fw(t))){let n=xc(o,"package.json"),a=await ye(n);if(a){if(a.name&&a.exports){let[,l,h]=r;if(l===a.name){let f=re(h,a.exports,n,i,s),c=xc(o,f);if(await et(c))return uw(c);throw bt(c,i)}}if(e.startsWith("#")){if(!a.imports)throw rs(e,n,i);let l=a.imports[e];if(l!==void 0){let m=dt(l,s);if(!m)throw rs(e,n,i);return m.startsWith("#")?ns(null,t,s):mt(m,n,s)}let h=Ks(e,a.imports);if(!h)throw rs(e,n,i);let[f,c]=h,u=a.imports[f],p=dt(u,s);if(!p)throw rs(e,n,i);if(p.startsWith("#"))return ns(null,t,s);let d=p.replace(/\*/g,c);return mt(d,n,s)}break}}return ns(e,t,s)};typeof mr.isBuiltin!="function"&&(mr.isBuiltin=e=>(e.startsWith("node:")&&(e=e.substring(5)),mr.builtinModules.includes(e)));var yw=async e=>(e=Mt(e),_c(await Qs(dw(e)),pw(e))),mt=async(e,t=void 0,s={})=>{if(typeof e=="string"&&e.startsWith("file://")&&(e=new URL(e)),typeof e=="object"){if(!await et(e))throw bt(String(e),String(t));let n=await Qs(Mt(e));return n!==gw(e)?an(n):e}let i=t?os(await yw(t)):void 0;if(Qo(e)){if(!i)throw nn(e,t);let n=new URL(e,i);if(!await et(n))throw bt(e,String(t));return an(await Qs(new URL(e,i)))}if(mw(e)){if(!await et(e))throw bt(e,String(t));return an(await Qs(e))}if(mr.isBuiltin(String(e)))return String(e);let r=Mt(t||_c(await Qs(process.cwd()),"x")),o={...s,originalParent:String(s.originalParent||r)};return e?Tc(e,r,o):ns(e,r,o)};var rn=(e,t=mt)=>{let s=new Error("invalid import() specifier: "+e);return Error.captureStackTrace(s,t),s},as=(e,t=mt)=>{let s=new Error(`Not a valid package: ${e}`);return Error.captureStackTrace(s,t),s},nn=(e,t,s=mt)=>{let i=Object.assign(new Error("relative import without parentURL"),{url:e,parentURL:t});return Error.captureStackTrace(i,s),i},Xs=(e,t,s,i=mt)=>{let r=e==="."?'No "exports" main defined':`Package subpath '${e}' is not defined by "exports"`,o=Object.assign(new Error(`${r} in ${t} imported from ${s}`),{code:"ERR_PACKAGE_PATH_NOT_EXPORTED"});return Error.captureStackTrace(o,i),o},is=(e,t,s=mt)=>{let i=Object.assign(new Error(`Cannot find package '${e}' imported from ${t}`),{code:"ERR_MODULE_NOT_FOUND"});return Error.captureStackTrace(i,s),i},bt=(e,t,s=mt)=>{let i=Object.assign(new Error(`Cannot find module '${e}' imported from ${t}`),{code:"ERR_MODULE_NOT_FOUND"});return Error.captureStackTrace(i,s),i},rs=(e,t,s,i=mt)=>{let r=Object.assign(new Error(`Package import specifier "${e}" is not defined in package ${t} imported from ${s}`),{code:"ERR_PACKAGE_IMPORT_NOT_DEFINED"});return Error.captureStackTrace(r,i),r};import{dirname as vw,resolve as Ew}from"path";import{pathToFileURL as kc}from"url";var ln=e=>e?ww(e)?Object.keys(e).filter(t=>t==="."||t.startsWith("./")):["."]:[],ww=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;for(let t in e)if(t!=="."&&!t.startsWith("./"))return!1;return!0};import{resolve as bw}from"node:path";var gr=async(e,t)=>{let s=Rs(e[0])+(e[0].endsWith("/")?"":"*/")+"**"+(e[1].startsWith("/")?"":"/*")+Rs(e[1]);return(await Ee(s,{posix:!0,absolute:!1,nodir:!0,cwd:t,dotRelative:!0})).map(r=>[r.substring(e[0].length,r.length-e[1].length),bw(t,r)])};var hn=async(e,t={})=>{let s=Mt(e),i=vw(s),r=await ye(s);if(!r)throw as(e,hn);let o={},{exports:n}=r;for(let a of ln(n)){let l;try{l=re(a,n,s,s,t)}catch{}if(!l)continue;let h=l.split("*"),f=a.split("*");if(h.length===2&&f.length===2)for(let[c,u]of await gr(h,i))o[f[0]+c+f[1]]=kc(u);else o[a]=kc(Ew(i,l))}return o};var cn=async(e,t={})=>{let s=Mt(e),i=xw(s),r=os(e),o=await ye(s);if(!o)throw as(e,cn);let n={};for(let[a,l]of kw(o,t)){let h=l.match(/^(@[^\/]+\/[^\/]+|[^\/]+)/),f=o.name;if(!h)continue;let c=a.split("*"),u=l.split("*");if(!(c.length===2&&u.length===2)){try{n[a]=await mt(l,r)}catch{}continue}let d=h[1]===".";if(d){for(let[b,v]of await gr(u,i))n[c[0]+b+c[1]]=_w(v);continue}let m=h[1]===f,y=!d&&!m?h[1]:null,g=y?await dr(y,i):i;if(!g)continue;let w=Tw(g,"package.json");if(!await et(w))continue;let S=await hn(w);for(let[b,v]of Object.entries(S)){if(b==="."||b==="./")continue;let R=y+b.substring(1);if(R.startsWith(u[0])&&R.endsWith(u[1])){let L=c[0]+R.substring(u[0].length,R.length-u[1].length)+c[1];try{n[L]=await mt(v,r)}catch{}}}}return n},kw=(e,t)=>{let s=[],{imports:i}=e;if(!i||typeof i!="object")return s;for(let[r,o]of Object.entries(i)){let n=dt(o,t);n&&!n.startsWith("#")&&s.push([r,n])}return s};import{fileURLToPath as Aw}from"url";var Rc=new Set,Ac=e=>{let t=[...Cc.entries()];if(!t.length)return!1;let s=new Set(t.map(([i])=>un(i)));return T("save import linker",e),Ow(e,`import { mkdirSync } from 'node:fs'
33
33
  import { symlink } from 'node:fs/promises'
34
34
  const dirs = ${JSON.stringify([...s])}
35
35
  const links = [
@@ -38,13 +38,13 @@ ${t.map(i=>` ${JSON.stringify(i)},
38
38
  const e = (er) => { if (er.code !== 'EEXIST') throw er }
39
39
  for (const d of dirs) mkdirSync(d, { recursive: true })
40
40
  Promise.all(links.map(([dest, src]) => symlink(src, dest).catch(e)))
41
- `),!0},Lt,Cc=async e=>{let t=wc(e).filter(o=>!o.startsWith("./src/"));if(!t.some(o=>o.includes("*")))return Lt=t.filter(o=>o.startsWith("./"));let s=bc(e),i=new Set,r=pn("package.json");for(let o of s){let n=await cn(r,{conditions:o});for(let a of Object.values(n)){if(typeof a=="string")continue;let l=Aw(a),h=Oc(process.cwd(),l);!h||h.startsWith(".."+fn)||h.startsWith("src"+fn)||h.startsWith("node_modules"+fn)||i.add("./"+h.replace(/\\/g,"/"))}}return Lt=[...i]},jc=new Map,yr=async(e,t,s=!1)=>{let{imports:i}=e;if(!i||(Lt||(Lt=await Cc(i)),!Lt.length))return;T(`link import targets in ${t}`,Lt);let r=Oc(pn(t),process.cwd()),o=[];for(let n of Lt){let a=n.replace(/^\.\//,""),l=un(a),h=l==="."?"":l.split("/").map(()=>"../").join(""),f=t+"/"+a,c=r+"/"+h+a;s&&jc.set(f,c),o.push(So(un(f)).then(u=>(!s&&u&&Rc.add(u),At(f))).then(()=>Rw(c,f)))}await Promise.all(o)},wr=async(e,t)=>{let{imports:s}=e;if(!s)return;Lt||(Lt=await Cc(s)),T(`unlink import targets in ${t}`,Lt);let i=[];for(let r of Lt){let o=pn(t,r);i.push(At(o))}for(let r of Rc)i.push(At(r));await Promise.all(i)};import{readlinkSync as Cw,symlinkSync as Pc}from"fs";import{dirname as Fc,relative as Dc,resolve as br,sep as Nc}from"path";var Mc=new Map,ti,$c=e=>{if(ti!==void 0)return ti;let t=process.cwd(),s=`${Nc}node_modules${Nc}${e.name}`.toLowerCase();if(t.toLowerCase().endsWith(s))return ti=!0;for(let i of ie(t)){let r=br(i,"node_modules",e.name);try{let o=br(Fc(r),Cw(r));if(Dc(o,t)==="")return ti=!0}catch{}}return ti=!1},dn=(e,t)=>{let s=e?.tshy?.selfLink;if(!e.name||s===!1||$c(e))return;let i=br(t,"node_modules",e.name),r=Fc(i),o=Dc(r,process.cwd()),n=Qt(r);n&&Mc.set(i,n);try{Pc(o,i)}catch{pt(i);let a=!0;try{Pc(o,i),a=!1}finally{if(a&&s===void 0)return}}},Sr=(e,t)=>{if(!e.name||e?.tshy?.selfLink===!1||$c(e))return;let s=br(t,"node_modules",e.name);pt(s);let i=Mc.get(s);i&&pt(i)};var vr=e=>{Q("src"),wr(k,"src"),Sr(k,"src"),_("build failed"),F(e),process.exit(1)};import{existsSync as Lc,renameSync as jw,unlinkSync as Pw}from"fs";var Nw=e=>Lc(e)&&Pw(e),Fw=(e,t)=>Lc(e)&&jw(e,t),W={unlink:Nw,rename:Fw};import{realpath as si}from"fs/promises";import _r from"module";import{basename as Dw,dirname as Mw,isAbsolute as $w,resolve as Uc}from"path";import{fileURLToPath as Lw,pathToFileURL as mn}from"url";import gn from"node:module";import{stat as Ww}from"node:fs/promises";import{fileURLToPath as Iw}from"node:url";import{realpath as Gw,stat as Hw}from"node:fs/promises";import{dirname as Yw,resolve as Wc,sep as yn}from"node:path";import{dirname as qw,resolve as Vw}from"path";import{readFile as Xw}from"node:fs/promises";import{pathToFileURL as ib}from"url";import{fileURLToPath as ob}from"url";import{resolve as ei}from"path";import{pathToFileURL as Re}from"url";import{dirname as lb,resolve as Ic}from"path";import{pathToFileURL as hb}from"url";var Uw=e=>typeof e=="object"||e.startsWith("file://")?Iw(e):e,Wt=async e=>{try{return(await Ww(Uw(e))).isFile()}catch{return!1}};var zw=typeof process=="object"&&process&&process.platform==="win32",Bw=e=>/^\.\.?\//.test(e)||zw&&/^\.\.?\\/.test(e),zc=function*(e){for(e=Vw(e);e;){yield e;let t=qw(e);if(t===e)break;e=t}},Jw=async e=>{try{return(await Hw(e)).isDirectory()}catch{return!1}};var Kw=async(e,t)=>{for(let s of zc(Yw(t))){let i=Wc(s,"node_modules")+yn,r=e===null?i:(e?Wc(i,e):i)+yn;if(await Jw(r))try{return await Gw(r)+yn}catch{}}};var Zw=async e=>{try{return JSON.parse(await Xw(e,"utf8"))}catch{return null}};var Qw=e=>!!e&&(typeof e=="object"||typeof e=="string"),tb=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;for(let t in e)if(!t.startsWith("#"))return!1;return!0},eb=e=>!!e&&typeof e=="object"&&(typeof e.name=="string"||typeof e.name>"u")&&(typeof e.main=="string"||typeof e.main>"u")&&(typeof e.module=="string"||typeof e.module>"u")&&(typeof e.exports>"u"||Qw(e.exports))&&(typeof e.imports>"u"||tb(e.imports)),sb=e=>eb(e)?e:null,Bc=async e=>sb(await Zw(e));var Gc=(e,t)=>{let s=Object.keys(t).filter(i=>i.length<=e.length).sort((i,r)=>r.length-i.length).map(i=>[i,i.split("*")]).filter(([,i])=>i.length===2);for(let[i,[r,o]]of s)if(e.startsWith(r)&&e.endsWith(o)){let n=e.substring(r.length,e.length-o.length);return[i,n]}return null},we=(e,t)=>{if(e===null||typeof e=="string")return e;if(Array.isArray(e)){for(let i of e){let r=we(i,t);if(r)return r}return null}let s=new Set(["default"]);for(let i of t.conditions??["import","node"])i.startsWith("!")?s.delete(i.slice(1)):s.add(i);for(let[i,r]of Object.entries(e))if(s.has(i))return we(r,t);return null},Hc=(e,t,s,i,r)=>{let o=e?e==="."||e.startsWith("./")?e:`./${e}`:".";if(typeof t=="string"||Array.isArray(t)){let h=o==="."&&we(t,r);if(!h)throw Er(o,s,i);return h}if(o==="."){let h=we(t,r);if(h)return h}let n=t,a=n[o];if(a!==void 0){let h=we(a,r);if(!h)throw Er(o,s,i);return h}let l=Gc(o,n);if(l){let[h,f]=l,c=we(n[h],r);if(!c)throw Er(o,s,i);return c.replace(/\*/g,f)}throw Er(o,s,i)};var rb=e=>typeof e=="object"?e:e.startsWith("file://")?new URL(e):ib(e),wn=e=>typeof e=="object"||e.startsWith("file://")?ob(e):e;typeof gn.isBuiltin!="function"&&(gn.isBuiltin=e=>(e.startsWith("node:")&&(e=e.substring(5)),gn.builtinModules.includes(e)));var nb=(e,t=It)=>{let s=new Error("invalid import() specifier: "+e);return Error.captureStackTrace(s,t),s},ab=(e,t,s=It)=>{let i=Object.assign(new Error("relative import without parentURL"),{url:e,parentURL:t});return Error.captureStackTrace(i,s),i},Er=(e,t,s,i=It)=>{let r=e==="."?'No "exports" main defined':`Package subpath '${e}' is not defined by "exports"`,o=Object.assign(new Error(`${r} in ${t} imported from ${s}`),{code:"ERR_PACKAGE_PATH_NOT_EXPORTED"});return Error.captureStackTrace(o,i),o},xr=(e,t,s=It)=>{let i=Object.assign(new Error(`Cannot find package '${e}' imported from ${t}`),{code:"ERR_MODULE_NOT_FOUND"});return Error.captureStackTrace(i,s),i},Ae=(e,t,s=It)=>{let i=Object.assign(new Error(`Cannot find module '${e}' imported from ${t}`),{code:"ERR_MODULE_NOT_FOUND"});return Error.captureStackTrace(i,s),i},Tr=(e,t,s,i=It)=>{let r=Object.assign(new Error(`Package import specifier "${e}" is not defined in package ${t} imported from ${s}`),{code:"ERR_PACKAGE_IMPORT_NOT_DEFINED"});return Error.captureStackTrace(r,i),r},kr=async(e,t,s)=>{let{originalParent:i}=s,r=e?.match(/^(@[^\/]+\/[^\/]+|[^\/]+)(?:\/(.*))?$/),[,o,n]=e===null?[,null,""]:r||["","",""],a=await Kw(o,t);if(!a)throw xr(o,i);let l=ei(a,"index.js"),h=ei(a,"package.json"),f=await Bc(h),c=n?ei(a,n):!1;if(!f)if(c){if(await Wt(c))return Re(c);throw Ae(c,i)}else{if(await Wt(l))return Re(l);throw xr(a,i)}if(f.exports){let u=Hc(n,f.exports,h,i,s),p=ei(a,u);if(await Wt(p))return Re(p);throw Ae(p,i)}else if(c){if(await Wt(c))return Re(c);throw Ae(c,i)}else if(f.main){let u=ei(a,f.main);if(await Wt(u))return Re(u);if(await Wt(l))return Re(l);throw xr(a,i)}else{if(await Wt(l))return Re(l);throw xr(a,i)}},cb=async(e,t,s)=>{let{originalParent:i}=s,r=e.match(/^(@[^\/]+\/[^\/]+|[^\/]+)(?:\/(.*))?$/);if(!r)throw nb(e);for(let o of zc(lb(t))){let n=Ic(o,"package.json"),a=await Bc(n);if(a){if(a.name&&a.exports){let[,l,h]=r;if(l===a.name){let f=Hc(h,a.exports,n,i,s),c=Ic(o,f);if(await Wt(c))return hb(c);throw Ae(c,i)}}if(e.startsWith("#")){if(!a.imports)throw Tr(e,n,i);let l=a.imports[e];if(l!==void 0){let m=we(l,s);if(!m)throw Tr(e,n,i);return m.startsWith("#")?kr(null,t,s):It(m,n,s)}let h=Gc(e,a.imports);if(!h)throw Tr(e,n,i);let[f,c]=h,u=a.imports[f],p=we(u,s);if(!p)throw Tr(e,n,i);if(p.startsWith("#"))return kr(null,t,s);let d=p.replace(/\*/g,c);return It(d,n,s)}break}}return kr(e,t,s)};typeof _r.isBuiltin!="function"&&(_r.isBuiltin=e=>(e.startsWith("node:")&&(e=e.substring(5)),_r.builtinModules.includes(e)));var fb=async e=>(e=wn(e),Uc(await si(Mw(e)),Dw(e))),It=async(e,t=void 0,s={})=>{if(typeof e=="string"&&e.startsWith("file://")&&(e=new URL(e)),typeof e=="object"){if(!await Wt(e))throw Ae(String(e),String(t));let n=await si(wn(e));return n!==Lw(e)?mn(n):e}let i=t?rb(await fb(t)):void 0;if(Bw(e)){if(!i)throw ab(e,t);let n=new URL(e,i);if(!await Wt(n))throw Ae(e,String(t));return mn(await si(new URL(e,i)))}if($w(e)){if(!await Wt(e))throw Ae(e,String(t));return mn(await si(e))}if(_r.isBuiltin(String(e)))return String(e);let r=wn(t||Uc(await si(process.cwd()),"x")),o={...s,originalParent:String(s.originalParent||r)};return e?cb(e,r,o):kr(e,r,o)};import{fileURLToPath as ub}from"url";var pb={tsgo:"@typescript/native-preview",tsc:"typescript"},db={tsgo:"bin/tsgo.js",tsc:"bin/tsc"},mb=async e=>await It(e+"/package.json",process.cwd()+"/x").catch(()=>It(e+"/package.json",import.meta.url)),{compiler:Yc="tsc"}=O,gb=pb[Yc],yb=e=>e.slice(0,-12)+db[Yc],ii=yb(ub(await mb(gb)));import{mkdirSync as bb}from"node:fs";var Vc=process.execPath,{commonjsDialects:Sb=[]}=O,Jc=()=>{Q("src","commonjs");for(let e of["commonjs",...Sb]){let t=e==="commonjs"?"cjs":`commonjs-${e}`,s=L.get(t),i=e==="commonjs"?"commonjs":`commonjs-${e}`;T(E.cyan.dim("building "+i),[Vc,[ii,"-p",`.tshy/${i}.json`],{stdio:"inherit"}]);let r=wb(Vc,[ii,"-p",`.tshy/${i}.json`],{stdio:"inherit"});if(r.status||r.signal)return Q("src"),vr(r);let o=e==="commonjs"?e:`commonjs/${e}`;bb(`.tshy-build/${o}`,{recursive:!0});for(let[n,a]of s?.map.entries()??[]){let l=ls(`.tshy-build/${o}`,qc(ls("src"),ls(n))).replace(/\.cts$/,""),h=ls(`.tshy-build/${o}`,qc(ls("src"),ls(a))).replace(/\.tsx?$/,""),f=`${h}.js.map`,c=`${h}.d.ts.map`;W.unlink(f),W.unlink(c),W.rename(`${l}.cjs`,`${h}.js`),W.rename(`${l}.d.cts`,`${h}.d.ts`)}Q(".tshy-build/commonjs","commonjs"),F(E.cyan.bold("built "+o))}Q("src")};import{spawnSync as vb}from"node:child_process";import{relative as Kc,resolve as hs}from"node:path";import{mkdirSync as Eb}from"node:fs";var xb=process.execPath,{esmDialects:Tb=[]}=O,Xc=()=>{Q("src","esm");for(let e of["esm",...Tb]){let t=e==="esm"?e:`esm-${e}`,s=L.get(t);T(E.cyan.dim("building "+t));let i=vb(xb,[ii,"-p",`.tshy/${t}.json`],{stdio:"inherit"});if(i.status||i.signal)return Q("src"),vr(i);let r=e==="esm"?e:`esm/${e}`;Eb(`.tshy-build/${r}`,{recursive:!0});for(let[o,n]of s?.map.entries()??[]){let a=hs(`.tshy-build/${r}`,Kc(hs("src"),hs(o))).replace(/\.mts$/,""),l=hs(`.tshy-build/${r}`,Kc(hs("src"),hs(n))).replace(/\.tsx?$/,"");W.unlink(`${l}.js.map`),W.unlink(`${l}.d.ts.map`),W.rename(`${a}.mjs`,`${l}.js`),W.rename(`${a}.d.mts`,`${l}.d.ts`)}Q(".tshy-build/esm","esm"),F(E.cyan.bold("built "+r))}Q("src")};import{readdirSync as Or}from"fs";import{parse as _b}from"path";var Zc=async(e,t)=>{let s=Or(`${t}/${e}`,{withFileTypes:!0}),i;try{i=new Set(Or(`src/${e}`))}catch{}if(!i)return await At(`${t}/${e}`);for(let r of s){let o=`${e}/${r.name}`;if(r.isDirectory()){await Zc(o,t);continue}let{ext:n,name:a}=_b(o);if(n===".map")continue;a.endsWith(".d")&&n.endsWith("ts")&&(n=".d"+n,a=a.substring(0,a.length-2));let l=n===".js"||n===".d.ts"?[".tsx",".ts"]:n===".mjs"||n===".d.mts"?[".mts"]:n===".cjs"||n===".d.cts"?[".cts"]:[];l.push(n);let h=!0;for(let f of l)if(i.has(`${a}${f}`)){h=!1;break}h&&(T("removing output file",o),await At([`${t}/${o}`,`${t}/${o}.map`]))}},bn=async()=>{let e=es();if(e.compilerOptions.incremental!==!0&&e.compilerOptions.composite!==!0)return await At(".tshy-build");let t;try{t=Or(".tshy-build/.tshy")}catch{}if(!t?.length)return await At(".tshy-build");for(let s of Or(".tshy-build"))s!==".tshy"&&await Zc(".",`.tshy-build/${s}`)};var Ce=O.dialects||["esm","commonjs"];import{writeFileSync as kb}from"fs";var Qc=()=>kb("package.json",fi(k));import{linkSync as Ob,mkdirSync as Rb}from"node:fs";import{dirname as Ab,relative as tf,resolve as je}from"node:path";var{esmDialects:Cb=[]}=O,ef=()=>{for(let e of["esm",...Cb]){let t=e==="esm"?"esm":`esm-${e}`,s=e==="esm"?"esm":`esm/${e}`,i=L.get(t);T(E.cyan.dim("linking "+s));for(let r of Jt){let o=r.substring(6),n=je(`.tshy-build/${s}/${o}`);Rb(Ab(n),{recursive:!0}),Ob(r,n)}for(let[r,o]of i?.map.entries()??[]){let n=je(`.tshy-build/${s}`,tf(je("src"),je(r))).replace(/\.mts$/,""),a=je(`.tshy-build/${s}`,tf(je("src"),je(o))).replace(/\.tsx?$/,"");W.unlink(`${a}.js.map`),W.unlink(`${a}.d.ts.map`),W.rename(`${n}.mjs`,`${a}.js`),W.rename(`${n}.d.mts`,`${a}.d.ts`)}F(E.cyan.bold("linked "+e))}Q(".tshy-build/esm","esm")};import{linkSync as jb,mkdirSync as Pb}from"node:fs";import{dirname as Nb}from"node:path";import{relative as sf,resolve as Pe}from"node:path/posix";var{commonjsDialects:Fb=[]}=O,rf=()=>{for(let e of["commonjs",...Fb]){let t=e==="commonjs"?"cjs":`commonjs-${e}`,s=e==="commonjs"?"commonjs":`commonjs/${e}`,i=L.get(t);T(E.cyan.dim("linking "+s));for(let r of Jt){let o=r.substring(6),n=Pe(`.tshy-build/${s}/${o}`);Pb(Nb(n),{recursive:!0}),jb(r,n)}for(let[r,o]of i?.map.entries()??[]){let n=Pe(`.tshy-build/${s}`,sf(Pe("src"),Pe(r))).replace(/\.cts$/,""),a=Pe(`.tshy-build/${s}`,sf(Pe("src"),Pe(o))).replace(/\.tsx?$/,"");W.unlink(`${a}.js.map`),W.unlink(`${a}.d.ts.map`),W.rename(`${n}.cjs`,`${a}.js`),W.rename(`${n}.d.cts`,`${a}.d.ts`)}F(E.cyan.bold("linked commonjs"))}Q(".tshy-build/commonjs","commonjs")};var of=async()=>{await bn(),dn(k,"src"),await yr(k,"src");let e=O.liveDev&&process.env.npm_command!=="publish"&&process.env.npm_command!=="pack",t=e?ef:Xc,s=e?rf:Jc;if(Ce.includes("esm")&&t(),Ce.includes("commonjs")&&s(),await wr(k,"src"),Sr(k,"src"),T(E.cyan.dim("moving to ./dist")),Vh(".tshy-build","dist"),T(E.cyan.dim("cleaning build temp dir")),await bn(),dn(k,"dist"),k.imports&&(T("linking package imports",k.imports),Ce.includes("commonjs")&&await yr(k,"dist/commonjs",!0),Ce.includes("esm")&&await yr(k,"dist/esm",!0),Ac("dist/.tshy-link-imports.mjs"))){let i=k.scripts||{};i.preinstall='node -e "import(process.argv[1]).catch(()=>{})" dist/.tshy-link-imports.mjs',k.scripts=i}T(E.cyan.dim("chmod bins")),Xh(),T(E.cyan.dim("write package.json")),Qc()};import{relative as Db,resolve as nf}from"node:path/posix";var{esmDialects:Mb=[],commonjsDialects:$b=[]}=O,ri=O.liveDev&&process.env.npm_command!=="publish"&&process.env.npm_command!=="pack",Ar=(e,t,s,i,r=new Map)=>{if(e!==void 0){if(typeof e=="string"){let o=i==="commonjs"?".mts":".cts";if(e.endsWith(o))return;let n=t==="commonjs"?"cjs":t,a=Db(nf("./src"),nf(r.get(n)?.map.get(e)??e)),l=ri?a:a.replace(/\.([mc]?)tsx?$/,".$1js"),h=t==="commonjs"||t==="esm"?t:`${i}/${t}`;return!e||!e.startsWith("./src/")?e:Ce.includes(i)?`./dist/${h}/${l}`:void 0}return zt(e,[s])}},Lb=(e,t=new Map)=>Ar(e,"esm","import","esm",t),Wb=(e,t=new Map)=>Ar(e,"commonjs","require","commonjs",t),Ib=(e,t)=>{if(!e.exports)return _("no exports on tshy config (is there code in ./src?)"),process.exit(1);let s={};for(let[i,r]of Object.entries(e.exports)){if(r!==null&&(typeof r!="string"||!r.startsWith("./src/"))){s[i]=r;continue}if(r===null)continue;let o=Lb(r,L),n=Wb(r,L);if(!o&&!n)continue;let a=s[i]={};if(o)for(let l of Mb){let h=r&&(L.get("esm-"+l)?.rmap.get(r)??r),f=Ar(r,l,l,"esm",L);if(f){let c=a.import??={},u=t==="module"||h.endsWith(".mts")?Rr(h,e):void 0,p=ri?void 0:{types:f.replace(/\.js$/,".d.ts")};c[l]={...u,...p,default:f}}}if(n)for(let l of $b){let h=r&&(L.get("commonjs-"+l)?.rmap.get(r)??r),f=Ar(r,l,l,"commonjs",L);if(f){let c=a.require??={},u=t==="commonjs"||h.endsWith(".cts")?Rr(h,e):void 0,p=ri?void 0:{types:f.replace(/\.js$/,".d.ts")};c[l]={...u,...p,default:f}}}if(o){let l=r&&(L.get("esm")?.rmap.get(r)??r),h=t==="module"||l.endsWith(".mts")?Rr(l,e):void 0,f=ri?void 0:{types:o.replace(/\.(m?)js$/,".d.$1ts")};a.import={...a.import,...h,...f,default:o}}if(n){let l=r&&(L.get("cjs")?.rmap.get(r)??r),h=t==="commonjs"||l.endsWith(".cts")?Rr(l,e):void 0,f=ri?void 0:{types:n.replace(/\.(c?)js$/,".d.$1ts")};a.require={...a.require,...h,...f,default:n}}}return s},Rr=(e,t)=>{let{sourceDialects:s}=t;if(s)return Object.fromEntries(s.map(i=>[i,e]))},Ub=(e,t)=>{t.type=t.type==="commonjs"?"commonjs":"module";let s=zt(t.exports["."],["require","default"]);if(e?.main??!!s){if(!s)return _("could not resolve exports['.'] for tshy.main 'require'"),process.exit(1);let n=zt(t.exports["."],["require","types"]);t.main=s,n&&n!==s?t.types=n:delete t.types}else e&&e.main!==!1&&delete e.main,delete t.main,delete t.types;let r=zt(t.exports["."],["import","default"]);if(e?.module??!!r){if(!r)return _("could not resolve exports['.'] for tshy.module 'import'"),process.exit(1);t.module=r}else e&&e.module!==!1&&delete e.module,delete t.module};k.exports=Ib(O,k.type);Ub(O,k);var jA=k.exports;var Sn=e=>{let t="https://github.com/isaacs/tshy",s=E.level>0?`\x1B]8;;${t}\x1B\\${t}\x1B]8;;\x1B\\`:t;console[e?"error":"log"](`Usage: tshy [--help]
41
+ `),!0},Lt,jc=async e=>{let t=wc(e).filter(o=>!o.startsWith("./src/"));if(!t.some(o=>o.includes("*")))return Lt=t.filter(o=>o.startsWith("./"));let s=bc(e),i=new Set,r=pn("package.json");for(let o of s){let n=await cn(r,{conditions:o});for(let a of Object.values(n)){if(typeof a=="string")continue;let l=Aw(a),h=Oc(process.cwd(),l);!h||h.startsWith(".."+fn)||h.startsWith("src"+fn)||h.startsWith("node_modules"+fn)||i.add("./"+h.replace(/\\/g,"/"))}}return Lt=[...i]},Cc=new Map,yr=async(e,t,s=!1)=>{let{imports:i}=e;if(!i||(Lt||(Lt=await jc(i)),!Lt.length))return;T(`link import targets in ${t}`,Lt);let r=Oc(pn(t),process.cwd()),o=[];for(let n of Lt){let a=n.replace(/^\.\//,""),l=un(a),h=l==="."?"":l.split("/").map(()=>"../").join(""),f=t+"/"+a,c=r+"/"+h+a;s&&Cc.set(f,c),o.push(So(un(f)).then(u=>(!s&&u&&Rc.add(u),At(f))).then(()=>Rw(c,f)))}await Promise.all(o)},wr=async(e,t)=>{let{imports:s}=e;if(!s)return;Lt||(Lt=await jc(s)),T(`unlink import targets in ${t}`,Lt);let i=[];for(let r of Lt){let o=pn(t,r);i.push(At(o))}for(let r of Rc)i.push(At(r));await Promise.all(i)};import{readlinkSync as jw,symlinkSync as Pc}from"fs";import{dirname as Fc,relative as Dc,resolve as br,sep as Nc}from"path";var $c=new Map,ti,Mc=e=>{if(ti!==void 0)return ti;let t=process.cwd(),s=`${Nc}node_modules${Nc}${e.name}`.toLowerCase();if(t.toLowerCase().endsWith(s))return ti=!0;for(let i of ie(t)){let r=br(i,"node_modules",e.name);try{let o=br(Fc(r),jw(r));if(Dc(o,t)==="")return ti=!0}catch{}}return ti=!1},dn=(e,t)=>{let s=e?.tshy?.selfLink;if(!e.name||s===!1||Mc(e))return;let i=br(t,"node_modules",e.name),r=Fc(i),o=Dc(r,process.cwd()),n=Qt(r);n&&$c.set(i,n);try{Pc(o,i)}catch{pt(i);let a=!0;try{Pc(o,i),a=!1}finally{if(a&&s===void 0)return}}},Sr=(e,t)=>{if(!e.name||e?.tshy?.selfLink===!1||Mc(e))return;let s=br(t,"node_modules",e.name);pt(s);let i=$c.get(s);i&&pt(i)};var vr=e=>{Q("src"),wr(k,"src"),Sr(k,"src"),_("build failed"),D(e),process.exit(1)};import{existsSync as Lc,renameSync as Cw,unlinkSync as Pw}from"fs";var Nw=e=>Lc(e)&&Pw(e),Fw=(e,t)=>Lc(e)&&Cw(e,t),C={unlink:Nw,rename:Fw};import{realpath as si}from"fs/promises";import _r from"module";import{basename as Dw,dirname as $w,isAbsolute as Mw,resolve as Uc}from"path";import{fileURLToPath as Lw,pathToFileURL as mn}from"url";import gn from"node:module";import{stat as Ww}from"node:fs/promises";import{fileURLToPath as Iw}from"node:url";import{realpath as Gw,stat as Hw}from"node:fs/promises";import{dirname as Yw,resolve as Wc,sep as yn}from"node:path";import{dirname as qw,resolve as Vw}from"path";import{readFile as Xw}from"node:fs/promises";import{pathToFileURL as ib}from"url";import{fileURLToPath as ob}from"url";import{resolve as ei}from"path";import{pathToFileURL as Re}from"url";import{dirname as lb,resolve as Ic}from"path";import{pathToFileURL as hb}from"url";var Uw=e=>typeof e=="object"||e.startsWith("file://")?Iw(e):e,Wt=async e=>{try{return(await Ww(Uw(e))).isFile()}catch{return!1}};var zw=typeof process=="object"&&process&&process.platform==="win32",Bw=e=>/^\.\.?\//.test(e)||zw&&/^\.\.?\\/.test(e),zc=function*(e){for(e=Vw(e);e;){yield e;let t=qw(e);if(t===e)break;e=t}},Jw=async e=>{try{return(await Hw(e)).isDirectory()}catch{return!1}};var Kw=async(e,t)=>{for(let s of zc(Yw(t))){let i=Wc(s,"node_modules")+yn,r=e===null?i:(e?Wc(i,e):i)+yn;if(await Jw(r))try{return await Gw(r)+yn}catch{}}};var Zw=async e=>{try{return JSON.parse(await Xw(e,"utf8"))}catch{return null}};var Qw=e=>!!e&&(typeof e=="object"||typeof e=="string"),tb=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;for(let t in e)if(!t.startsWith("#"))return!1;return!0},eb=e=>!!e&&typeof e=="object"&&(typeof e.name=="string"||typeof e.name>"u")&&(typeof e.main=="string"||typeof e.main>"u")&&(typeof e.module=="string"||typeof e.module>"u")&&(typeof e.exports>"u"||Qw(e.exports))&&(typeof e.imports>"u"||tb(e.imports)),sb=e=>eb(e)?e:null,Bc=async e=>sb(await Zw(e));var Gc=(e,t)=>{let s=Object.keys(t).filter(i=>i.length<=e.length).sort((i,r)=>r.length-i.length).map(i=>[i,i.split("*")]).filter(([,i])=>i.length===2);for(let[i,[r,o]]of s)if(e.startsWith(r)&&e.endsWith(o)){let n=e.substring(r.length,e.length-o.length);return[i,n]}return null},we=(e,t)=>{if(e===null||typeof e=="string")return e;if(Array.isArray(e)){for(let i of e){let r=we(i,t);if(r)return r}return null}let s=new Set(["default"]);for(let i of t.conditions??["import","node"])i.startsWith("!")?s.delete(i.slice(1)):s.add(i);for(let[i,r]of Object.entries(e))if(s.has(i))return we(r,t);return null},Hc=(e,t,s,i,r)=>{let o=e?e==="."||e.startsWith("./")?e:`./${e}`:".";if(typeof t=="string"||Array.isArray(t)){let h=o==="."&&we(t,r);if(!h)throw Er(o,s,i);return h}if(o==="."){let h=we(t,r);if(h)return h}let n=t,a=n[o];if(a!==void 0){let h=we(a,r);if(!h)throw Er(o,s,i);return h}let l=Gc(o,n);if(l){let[h,f]=l,c=we(n[h],r);if(!c)throw Er(o,s,i);return c.replace(/\*/g,f)}throw Er(o,s,i)};var rb=e=>typeof e=="object"?e:e.startsWith("file://")?new URL(e):ib(e),wn=e=>typeof e=="object"||e.startsWith("file://")?ob(e):e;typeof gn.isBuiltin!="function"&&(gn.isBuiltin=e=>(e.startsWith("node:")&&(e=e.substring(5)),gn.builtinModules.includes(e)));var nb=(e,t=It)=>{let s=new Error("invalid import() specifier: "+e);return Error.captureStackTrace(s,t),s},ab=(e,t,s=It)=>{let i=Object.assign(new Error("relative import without parentURL"),{url:e,parentURL:t});return Error.captureStackTrace(i,s),i},Er=(e,t,s,i=It)=>{let r=e==="."?'No "exports" main defined':`Package subpath '${e}' is not defined by "exports"`,o=Object.assign(new Error(`${r} in ${t} imported from ${s}`),{code:"ERR_PACKAGE_PATH_NOT_EXPORTED"});return Error.captureStackTrace(o,i),o},xr=(e,t,s=It)=>{let i=Object.assign(new Error(`Cannot find package '${e}' imported from ${t}`),{code:"ERR_MODULE_NOT_FOUND"});return Error.captureStackTrace(i,s),i},Ae=(e,t,s=It)=>{let i=Object.assign(new Error(`Cannot find module '${e}' imported from ${t}`),{code:"ERR_MODULE_NOT_FOUND"});return Error.captureStackTrace(i,s),i},Tr=(e,t,s,i=It)=>{let r=Object.assign(new Error(`Package import specifier "${e}" is not defined in package ${t} imported from ${s}`),{code:"ERR_PACKAGE_IMPORT_NOT_DEFINED"});return Error.captureStackTrace(r,i),r},kr=async(e,t,s)=>{let{originalParent:i}=s,r=e?.match(/^(@[^\/]+\/[^\/]+|[^\/]+)(?:\/(.*))?$/),[,o,n]=e===null?[,null,""]:r||["","",""],a=await Kw(o,t);if(!a)throw xr(o,i);let l=ei(a,"index.js"),h=ei(a,"package.json"),f=await Bc(h),c=n?ei(a,n):!1;if(!f)if(c){if(await Wt(c))return Re(c);throw Ae(c,i)}else{if(await Wt(l))return Re(l);throw xr(a,i)}if(f.exports){let u=Hc(n,f.exports,h,i,s),p=ei(a,u);if(await Wt(p))return Re(p);throw Ae(p,i)}else if(c){if(await Wt(c))return Re(c);throw Ae(c,i)}else if(f.main){let u=ei(a,f.main);if(await Wt(u))return Re(u);if(await Wt(l))return Re(l);throw xr(a,i)}else{if(await Wt(l))return Re(l);throw xr(a,i)}},cb=async(e,t,s)=>{let{originalParent:i}=s,r=e.match(/^(@[^\/]+\/[^\/]+|[^\/]+)(?:\/(.*))?$/);if(!r)throw nb(e);for(let o of zc(lb(t))){let n=Ic(o,"package.json"),a=await Bc(n);if(a){if(a.name&&a.exports){let[,l,h]=r;if(l===a.name){let f=Hc(h,a.exports,n,i,s),c=Ic(o,f);if(await Wt(c))return hb(c);throw Ae(c,i)}}if(e.startsWith("#")){if(!a.imports)throw Tr(e,n,i);let l=a.imports[e];if(l!==void 0){let m=we(l,s);if(!m)throw Tr(e,n,i);return m.startsWith("#")?kr(null,t,s):It(m,n,s)}let h=Gc(e,a.imports);if(!h)throw Tr(e,n,i);let[f,c]=h,u=a.imports[f],p=we(u,s);if(!p)throw Tr(e,n,i);if(p.startsWith("#"))return kr(null,t,s);let d=p.replace(/\*/g,c);return It(d,n,s)}break}}return kr(e,t,s)};typeof _r.isBuiltin!="function"&&(_r.isBuiltin=e=>(e.startsWith("node:")&&(e=e.substring(5)),_r.builtinModules.includes(e)));var fb=async e=>(e=wn(e),Uc(await si($w(e)),Dw(e))),It=async(e,t=void 0,s={})=>{if(typeof e=="string"&&e.startsWith("file://")&&(e=new URL(e)),typeof e=="object"){if(!await Wt(e))throw Ae(String(e),String(t));let n=await si(wn(e));return n!==Lw(e)?mn(n):e}let i=t?rb(await fb(t)):void 0;if(Bw(e)){if(!i)throw ab(e,t);let n=new URL(e,i);if(!await Wt(n))throw Ae(e,String(t));return mn(await si(new URL(e,i)))}if(Mw(e)){if(!await Wt(e))throw Ae(e,String(t));return mn(await si(e))}if(_r.isBuiltin(String(e)))return String(e);let r=wn(t||Uc(await si(process.cwd()),"x")),o={...s,originalParent:String(s.originalParent||r)};return e?cb(e,r,o):kr(e,r,o)};import{fileURLToPath as ub}from"url";var pb={tsgo:"@typescript/native-preview",tsc:"typescript"},db={tsgo:"bin/tsgo.js",tsc:"bin/tsc"},mb=async e=>await It(e+"/package.json",process.cwd()+"/x").catch(()=>It(e+"/package.json",import.meta.url)),{compiler:Yc="tsc"}=O,gb=pb[Yc],yb=e=>e.slice(0,-12)+db[Yc],ii=yb(ub(await mb(gb)));import{mkdirSync as bb}from"node:fs";var Vc=process.execPath,{commonjsDialects:Sb=[]}=O,Jc=()=>{Q("src","commonjs");for(let e of["commonjs",...Sb]){let t=e==="commonjs"?"cjs":`commonjs-${e}`,s=W.get(t),i=e==="commonjs"?"commonjs":`commonjs-${e}`;T(E.cyan.dim("building "+i),[Vc,[ii,"-p",`.tshy/${i}.json`],{stdio:"inherit"}]);let r=wb(Vc,[ii,"-p",`.tshy/${i}.json`],{stdio:"inherit"});if(r.status||r.signal)return Q("src"),vr(r);let o=e==="commonjs"?e:`commonjs/${e}`;bb(`.tshy-build/${o}`,{recursive:!0});for(let[n,a]of s?.map.entries()??[]){let l=ls(`.tshy-build/${o}`,qc(ls("src"),ls(n))).replace(/\.c?ts$/,""),h=ls(`.tshy-build/${o}`,qc(ls("src"),ls(a))).replace(/\.tsx?$/,""),f=`${h}.js.map`,c=`${h}.d.ts.map`;C.unlink(f),C.unlink(c),C.rename(`${l}.js`,`${h}.js`),C.rename(`${l}.d.ts`,`${h}.d.ts`),C.rename(`${l}.cjs`,`${h}.js`),C.rename(`${l}.d.cts`,`${h}.d.ts`)}Q(".tshy-build/commonjs","commonjs"),D(E.cyan.bold("built "+o))}Q("src")};import{spawnSync as vb}from"node:child_process";import{relative as Kc,resolve as hs}from"node:path";import{mkdirSync as Eb}from"node:fs";var xb=process.execPath,{esmDialects:Tb=[]}=O,Xc=()=>{Q("src","esm");for(let e of["esm",...Tb]){let t=e==="esm"?e:`esm-${e}`,s=W.get(t);T(E.cyan.dim("building "+t));let i=vb(xb,[ii,"-p",`.tshy/${t}.json`],{stdio:"inherit"});if(i.status||i.signal)return Q("src"),vr(i);let r=e==="esm"?e:`esm/${e}`;Eb(`.tshy-build/${r}`,{recursive:!0});for(let[o,n]of s?.map.entries()??[]){D("polyfill",{override:o,orig:n});let a=hs(`.tshy-build/${r}`,Kc(hs("src"),hs(o))).replace(/\.m?ts$/,""),l=hs(`.tshy-build/${r}`,Kc(hs("src"),hs(n))).replace(/\.tsx?$/,"");C.unlink(`${l}.js.map`),C.unlink(`${l}.d.ts.map`),C.rename(`${a}.js`,`${l}.js`),C.rename(`${a}.d.ts`,`${l}.d.ts`),C.rename(`${a}.mjs`,`${l}.js`),C.rename(`${a}.d.mts`,`${l}.d.ts`)}Q(".tshy-build/esm","esm"),D(E.cyan.bold("built "+r))}Q("src")};import{readdirSync as Or}from"fs";import{parse as _b}from"path";var Zc=async(e,t)=>{let s=Or(`${t}/${e}`,{withFileTypes:!0}),i;try{i=new Set(Or(`src/${e}`))}catch{}if(!i)return await At(`${t}/${e}`);for(let r of s){let o=`${e}/${r.name}`;if(r.isDirectory()){await Zc(o,t);continue}let{ext:n,name:a}=_b(o);if(n===".map")continue;a.endsWith(".d")&&n.endsWith("ts")&&(n=".d"+n,a=a.substring(0,a.length-2));let l=n===".js"||n===".d.ts"?[".tsx",".ts"]:n===".mjs"||n===".d.mts"?[".mts"]:n===".cjs"||n===".d.cts"?[".cts"]:[];l.push(n);let h=!0;for(let f of l)if(i.has(`${a}${f}`)){h=!1;break}h&&(T("removing output file",o),await At([`${t}/${o}`,`${t}/${o}.map`]))}},bn=async()=>{let e=es();if(e.compilerOptions.incremental!==!0&&e.compilerOptions.composite!==!0)return await At(".tshy-build");let t;try{t=Or(".tshy-build/.tshy")}catch{}if(!t?.length)return await At(".tshy-build");for(let s of Or(".tshy-build"))s!==".tshy"&&await Zc(".",`.tshy-build/${s}`)};var je=O.dialects||["esm","commonjs"];import{writeFileSync as kb}from"fs";var Qc=()=>kb("package.json",fi(k));import{linkSync as Ob,mkdirSync as Rb}from"node:fs";import{dirname as Ab,relative as tf,resolve as Ce}from"node:path";var{esmDialects:jb=[]}=O,ef=()=>{for(let e of["esm",...jb]){let t=e==="esm"?"esm":`esm-${e}`,s=e==="esm"?"esm":`esm/${e}`,i=W.get(t);T(E.cyan.dim("linking "+s));for(let r of Jt){let o=r.substring(6),n=Ce(`.tshy-build/${s}/${o}`);Rb(Ab(n),{recursive:!0}),Ob(r,n)}for(let[r,o]of i?.map.entries()??[]){let n=Ce(`.tshy-build/${s}`,tf(Ce("src"),Ce(r))).replace(/\.mts$/,""),a=Ce(`.tshy-build/${s}`,tf(Ce("src"),Ce(o))).replace(/\.tsx?$/,"");C.unlink(`${a}.js.map`),C.unlink(`${a}.d.ts.map`),C.rename(`${n}.mjs`,`${a}.js`),C.rename(`${n}.d.mts`,`${a}.d.ts`)}D(E.cyan.bold("linked "+e))}Q(".tshy-build/esm","esm")};import{linkSync as Cb,mkdirSync as Pb}from"node:fs";import{dirname as Nb}from"node:path";import{relative as sf,resolve as Pe}from"node:path/posix";var{commonjsDialects:Fb=[]}=O,rf=()=>{for(let e of["commonjs",...Fb]){let t=e==="commonjs"?"cjs":`commonjs-${e}`,s=e==="commonjs"?"commonjs":`commonjs/${e}`,i=W.get(t);T(E.cyan.dim("linking "+s));for(let r of Jt){let o=r.substring(6),n=Pe(`.tshy-build/${s}/${o}`);Pb(Nb(n),{recursive:!0}),Cb(r,n)}for(let[r,o]of i?.map.entries()??[]){let n=Pe(`.tshy-build/${s}`,sf(Pe("src"),Pe(r))).replace(/\.cts$/,""),a=Pe(`.tshy-build/${s}`,sf(Pe("src"),Pe(o))).replace(/\.tsx?$/,"");C.unlink(`${a}.js.map`),C.unlink(`${a}.d.ts.map`),C.rename(`${n}.cjs`,`${a}.js`),C.rename(`${n}.d.cts`,`${a}.d.ts`)}D(E.cyan.bold("linked commonjs"))}Q(".tshy-build/commonjs","commonjs")};var of=async()=>{await bn(),dn(k,"src"),await yr(k,"src");let e=O.liveDev&&process.env.npm_command!=="publish"&&process.env.npm_command!=="pack",t=e?ef:Xc,s=e?rf:Jc;if(je.includes("esm")&&t(),je.includes("commonjs")&&s(),await wr(k,"src"),Sr(k,"src"),T(E.cyan.dim("moving to ./dist")),Vh(".tshy-build","dist"),T(E.cyan.dim("cleaning build temp dir")),await bn(),dn(k,"dist"),k.imports&&(T("linking package imports",k.imports),je.includes("commonjs")&&await yr(k,"dist/commonjs",!0),je.includes("esm")&&await yr(k,"dist/esm",!0),Ac("dist/.tshy-link-imports.mjs"))){let i=k.scripts||{};i.preinstall='node -e "import(process.argv[1]).catch(()=>{})" dist/.tshy-link-imports.mjs',k.scripts=i}T(E.cyan.dim("chmod bins")),Xh(),T(E.cyan.dim("write package.json")),Qc()};import{relative as Db,resolve as nf}from"node:path/posix";var{esmDialects:$b=[],commonjsDialects:Mb=[]}=O,ri=O.liveDev&&process.env.npm_command!=="publish"&&process.env.npm_command!=="pack",Ar=(e,t,s,i,r=new Map)=>{if(e!==void 0){if(typeof e=="string"){let o=i==="commonjs"?".mts":".cts";if(e.endsWith(o))return;let n=t==="commonjs"?"cjs":t,a=Db(nf("./src"),nf(r.get(n)?.map.get(e)??e)),l=ri?a:a.replace(/\.([mc]?)tsx?$/,".$1js"),h=t==="commonjs"||t==="esm"?t:`${i}/${t}`;return!e||!e.startsWith("./src/")?e:je.includes(i)?`./dist/${h}/${l}`:void 0}return zt(e,[s])}},Lb=(e,t=new Map)=>Ar(e,"esm","import","esm",t),Wb=(e,t=new Map)=>Ar(e,"commonjs","require","commonjs",t),Ib=(e,t)=>{if(!e.exports)return _("no exports on tshy config (is there code in ./src?)"),process.exit(1);let s={};for(let[i,r]of Object.entries(e.exports)){if(r!==null&&(typeof r!="string"||!r.startsWith("./src/"))){s[i]=r;continue}if(r===null)continue;let o=Lb(r,W),n=Wb(r,W);if(!o&&!n)continue;let a=s[i]={};if(o)for(let l of $b){let h=r&&(W.get("esm-"+l)?.rmap.get(r)??r),f=Ar(r,l,l,"esm",W);if(f){let c=a.import??={},u=t==="module"||h.endsWith(".mts")?Rr(h,e):void 0,p=ri?void 0:{types:f.replace(/\.js$/,".d.ts")};c[l]={...u,...p,default:f}}}if(n)for(let l of Mb){let h=r&&(W.get("commonjs-"+l)?.rmap.get(r)??r),f=Ar(r,l,l,"commonjs",W);if(f){let c=a.require??={},u=t==="commonjs"||h.endsWith(".cts")?Rr(h,e):void 0,p=ri?void 0:{types:f.replace(/\.js$/,".d.ts")};c[l]={...u,...p,default:f}}}if(o){let l=r&&(W.get("esm")?.rmap.get(r)??r),h=t==="module"||l.endsWith(".mts")?Rr(l,e):void 0,f=ri?void 0:{types:o.replace(/\.(m?)js$/,".d.$1ts")};a.import={...a.import,...h,...f,default:o}}if(n){let l=r&&(W.get("cjs")?.rmap.get(r)??r),h=t==="commonjs"||l.endsWith(".cts")?Rr(l,e):void 0,f=ri?void 0:{types:n.replace(/\.(c?)js$/,".d.$1ts")};a.require={...a.require,...h,...f,default:n}}}return s},Rr=(e,t)=>{let{sourceDialects:s}=t;if(s)return Object.fromEntries(s.map(i=>[i,e]))},Ub=(e,t)=>{t.type=t.type==="commonjs"?"commonjs":"module";let s=zt(t.exports["."],["require","default"]);if(e?.main??!!s){if(!s)return _("could not resolve exports['.'] for tshy.main 'require'"),process.exit(1);let n=zt(t.exports["."],["require","types"]);t.main=s,n&&n!==s?t.types=n:delete t.types}else e&&e.main!==!1&&delete e.main,delete t.main,delete t.types;let r=zt(t.exports["."],["import","default"]);if(e?.module??!!r){if(!r)return _("could not resolve exports['.'] for tshy.module 'import'"),process.exit(1);t.module=r}else e&&e.module!==!1&&delete e.module,delete t.module};k.exports=Ib(O,k.type);Ub(O,k);var CA=k.exports;var Sn=e=>{let t="https://github.com/isaacs/tshy",s=E.level>0?`\x1B]8;;${t}\x1B\\${t}\x1B]8;;\x1B\\`:t;console[e?"error":"log"](`Usage: tshy [--help]
42
42
  --help -h Print this message and exit.
43
43
  --watch -w Watch files in ./src and build when they change.
44
44
 
45
45
  Default behavior: build project according to tshy config in package.json
46
46
 
47
- See the docs for more information: ${s}`),e&&_(e),process.exit(e?1:0)};import{spawn as F0}from"child_process";import{stat as y0}from"fs";import{stat as w0,readdir as b0}from"fs/promises";import{EventEmitter as S0}from"events";import*as x from"path";import{stat as zb,lstat as af,readdir as Bb,realpath as Gb}from"node:fs/promises";import{Readable as Hb}from"node:stream";import{resolve as lf,relative as Yb,join as qb,sep as Vb}from"node:path";var St={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},vn={root:".",fileFilter:e=>!0,directoryFilter:e=>!0,type:St.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(vn);var uf="READDIRP_RECURSIVE_ERROR",Jb=new Set(["ENOENT","EPERM","EACCES","ELOOP",uf]),hf=[St.DIR_TYPE,St.EVERYTHING_TYPE,St.FILE_DIR_TYPE,St.FILE_TYPE],Kb=new Set([St.DIR_TYPE,St.EVERYTHING_TYPE,St.FILE_DIR_TYPE]),Xb=new Set([St.EVERYTHING_TYPE,St.FILE_DIR_TYPE,St.FILE_TYPE]),Zb=e=>Jb.has(e.code),Qb=process.platform==="win32",cf=e=>!0,ff=e=>{if(e===void 0)return cf;if(typeof e=="function")return e;if(typeof e=="string"){let t=e.trim();return s=>s.basename===t}if(Array.isArray(e)){let t=e.map(s=>s.trim());return s=>t.some(i=>s.basename===i)}return cf},En=class extends Hb{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let s={...vn,...t},{root:i,type:r}=s;this._fileFilter=ff(s.fileFilter),this._directoryFilter=ff(s.directoryFilter);let o=s.lstat?af:zb;Qb?this._stat=n=>o(n,{bigint:!0}):this._stat=o,this._maxDepth=s.depth??vn.depth,this._wantsDir=r?Kb.has(r):!1,this._wantsFile=r?Xb.has(r):!1,this._wantsEverything=r===St.EVERYTHING_TYPE,this._root=lf(i),this._isDirent=!s.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(i,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let s=this.parent,i=s&&s.files;if(i&&i.length>0){let{path:r,depth:o}=s,n=i.splice(0,t).map(l=>this._formatEntry(l,r)),a=await Promise.all(n);for(let l of a){if(!l)continue;if(this.destroyed)return;let h=await this._getEntryType(l);h==="directory"&&this._directoryFilter(l)?(o<=this._maxDepth&&this.parents.push(this._exploreDir(l.fullPath,o+1)),this._wantsDir&&(this.push(l),t--)):(h==="file"||this._includeAsFile(l))&&this._fileFilter(l)&&this._wantsFile&&(this.push(l),t--)}}else{let r=this.parents.pop();if(!r){this.push(null);break}if(this.parent=await r,this.destroyed)return}}}catch(s){this.destroy(s)}finally{this.reading=!1}}}async _exploreDir(t,s){let i;try{i=await Bb(t,this._rdOptions)}catch(r){this._onError(r)}return{files:i,depth:s,path:t}}async _formatEntry(t,s){let i,r=this._isDirent?t.name:t;try{let o=lf(qb(s,r));i={path:Yb(this._root,o),fullPath:o,basename:r},i[this._statsProp]=this._isDirent?t:await this._stat(o)}catch(o){this._onError(o);return}return i}_onError(t){Zb(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let s=t[this._statsProp];if(s.isFile())return"file";if(s.isDirectory())return"directory";if(s&&s.isSymbolicLink()){let i=t.fullPath;try{let r=await Gb(i),o=await af(r);if(o.isFile())return"file";if(o.isDirectory()){let n=r.length;if(i.startsWith(r)&&i.substr(n,1)===Vb){let a=new Error(`Circular symlink detected: "${i}" points to "${r}"`);return a.code=uf,this._onError(a)}return"directory"}}catch(r){return this._onError(r),""}}}_includeAsFile(t){let s=t&&t[this._statsProp];return s&&this._wantsEverything&&!s.isDirectory()}};function pf(e,t={}){let s=t.entryType||t.type;if(s==="both"&&(s=St.FILE_DIR_TYPE),s&&(t.type=s),e){if(typeof e!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(s&&!hf.includes(s))throw new Error(`readdirp: Invalid type passed. Use one of ${hf.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=e,new En(t)}import{watchFile as t0,unwatchFile as df,watch as e0}from"fs";import{open as s0,stat as gf,lstat as i0,realpath as xn}from"fs/promises";import*as j from"path";import{type as r0}from"os";var o0="data",kn="end",yf="close",Fr=()=>{};var Dr=process.platform,On=Dr==="win32",n0=Dr==="darwin",a0=Dr==="linux",l0=Dr==="freebsd",wf=r0()==="OS400",N={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},Ut=N,h0="watch",c0={lstat:i0,stat:gf},Ne="listeners",Cr="errHandlers",cs="rawEmitters",f0=[Ne,Cr,cs],u0=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),p0=e=>u0.has(j.extname(e).slice(1).toLowerCase()),_n=(e,t)=>{e instanceof Set?e.forEach(t):t(e)},oi=(e,t,s)=>{let i=e[t];i instanceof Set||(e[t]=i=new Set([i])),i.add(s)},d0=e=>t=>{let s=e[t];s instanceof Set?s.clear():delete e[t]},ni=(e,t,s)=>{let i=e[t];i instanceof Set?i.delete(s):i===s&&delete e[t]},bf=e=>e instanceof Set?e.size===0:!e,jr=new Map;function mf(e,t,s,i,r){let o=(n,a)=>{s(e),r(n,a,{watchedPath:e}),a&&e!==a&&Pr(j.resolve(e,a),Ne,j.join(e,a))};try{return e0(e,{persistent:t.persistent},o)}catch(n){i(n);return}}var Pr=(e,t,s,i,r)=>{let o=jr.get(e);o&&_n(o[t],n=>{n(s,i,r)})},m0=(e,t,s,i)=>{let{listener:r,errHandler:o,rawEmitter:n}=i,a=jr.get(t),l;if(!s.persistent)return l=mf(e,s,r,o,n),l?l.close.bind(l):void 0;if(a)oi(a,Ne,r),oi(a,Cr,o),oi(a,cs,n);else{if(l=mf(e,s,Pr.bind(null,t,Ne),o,Pr.bind(null,t,cs)),!l)return;l.on(Ut.ERROR,async h=>{let f=Pr.bind(null,t,Cr);if(a&&(a.watcherUnusable=!0),On&&h.code==="EPERM")try{await(await s0(e,"r")).close(),f(h)}catch{}else f(h)}),a={listeners:r,errHandlers:o,rawEmitters:n,watcher:l},jr.set(t,a)}return()=>{ni(a,Ne,r),ni(a,Cr,o),ni(a,cs,n),bf(a.listeners)&&(a.watcher.close(),jr.delete(t),f0.forEach(d0(a)),a.watcher=void 0,Object.freeze(a))}},Tn=new Map,g0=(e,t,s,i)=>{let{listener:r,rawEmitter:o}=i,n=Tn.get(t),a=n&&n.options;return a&&(a.persistent<s.persistent||a.interval>s.interval)&&(df(t),n=void 0),n?(oi(n,Ne,r),oi(n,cs,o)):(n={listeners:r,rawEmitters:o,options:s,watcher:t0(t,s,(l,h)=>{_n(n.rawEmitters,c=>{c(Ut.CHANGE,t,{curr:l,prev:h})});let f=l.mtimeMs;(l.size!==h.size||f>h.mtimeMs||f===0)&&_n(n.listeners,c=>c(e,l))})},Tn.set(t,n)),()=>{ni(n,Ne,r),ni(n,cs,o),bf(n.listeners)&&(Tn.delete(t),df(t),n.options=n.watcher=void 0,Object.freeze(n))}},Nr=class{constructor(t){this.fsw=t,this._boundHandleError=s=>t._handleError(s)}_watchWithNodeFs(t,s){let i=this.fsw.options,r=j.dirname(t),o=j.basename(t);this.fsw._getWatchedDir(r).add(o);let a=j.resolve(t),l={persistent:i.persistent};s||(s=Fr);let h;if(i.usePolling){let f=i.interval!==i.binaryInterval;l.interval=f&&p0(o)?i.binaryInterval:i.interval,h=g0(t,a,l,{listener:s,rawEmitter:this.fsw._emitRaw})}else h=m0(t,a,l,{listener:s,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return h}_handleFile(t,s,i){if(this.fsw.closed)return;let r=j.dirname(t),o=j.basename(t),n=this.fsw._getWatchedDir(r),a=s;if(n.has(o))return;let l=async(f,c)=>{if(this.fsw._throttle(h0,t,5)){if(!c||c.mtimeMs===0)try{let u=await gf(t);if(this.fsw.closed)return;let p=u.atimeMs,d=u.mtimeMs;if((!p||p<=d||d!==a.mtimeMs)&&this.fsw._emit(Ut.CHANGE,t,u),(n0||a0||l0)&&a.ino!==u.ino){this.fsw._closeFile(f),a=u;let m=this._watchWithNodeFs(t,l);m&&this.fsw._addPathCloser(f,m)}else a=u}catch{this.fsw._remove(r,o)}else if(n.has(o)){let u=c.atimeMs,p=c.mtimeMs;(!u||u<=p||p!==a.mtimeMs)&&this.fsw._emit(Ut.CHANGE,t,c),a=c}}},h=this._watchWithNodeFs(t,l);if(!(i&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(Ut.ADD,t,0))return;this.fsw._emit(Ut.ADD,t,s)}return h}async _handleSymlink(t,s,i,r){if(this.fsw.closed)return;let o=t.fullPath,n=this.fsw._getWatchedDir(s);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let a;try{a=await xn(i)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(n.has(r)?this.fsw._symlinkPaths.get(o)!==a&&(this.fsw._symlinkPaths.set(o,a),this.fsw._emit(Ut.CHANGE,i,t.stats)):(n.add(r),this.fsw._symlinkPaths.set(o,a),this.fsw._emit(Ut.ADD,i,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(o))return!0;this.fsw._symlinkPaths.set(o,!0)}_handleRead(t,s,i,r,o,n,a){if(t=j.join(t,""),a=this.fsw._throttle("readdir",t,1e3),!a)return;let l=this.fsw._getWatchedDir(i.path),h=new Set,f=this.fsw._readdirp(t,{fileFilter:c=>i.filterPath(c),directoryFilter:c=>i.filterDir(c)});if(f)return f.on(o0,async c=>{if(this.fsw.closed){f=void 0;return}let u=c.path,p=j.join(t,u);if(h.add(u),!(c.stats.isSymbolicLink()&&await this._handleSymlink(c,t,p,u))){if(this.fsw.closed){f=void 0;return}(u===r||!r&&!l.has(u))&&(this.fsw._incrReadyCount(),p=j.join(o,j.relative(o,p)),this._addToNodeFs(p,s,i,n+1))}}).on(Ut.ERROR,this._boundHandleError),new Promise((c,u)=>{if(!f)return u();f.once(kn,()=>{if(this.fsw.closed){f=void 0;return}let p=a?a.clear():!1;c(void 0),l.getChildren().filter(d=>d!==t&&!h.has(d)).forEach(d=>{this.fsw._remove(t,d)}),f=void 0,p&&this._handleRead(t,!1,i,r,o,n,a)})})}async _handleDir(t,s,i,r,o,n,a){let l=this.fsw._getWatchedDir(j.dirname(t)),h=l.has(j.basename(t));!(i&&this.fsw.options.ignoreInitial)&&!o&&!h&&this.fsw._emit(Ut.ADD_DIR,t,s),l.add(j.basename(t)),this.fsw._getWatchedDir(t);let f,c,u=this.fsw.options.depth;if((u==null||r<=u)&&!this.fsw._symlinkPaths.has(a)){if(!o&&(await this._handleRead(t,i,n,o,t,r,f),this.fsw.closed))return;c=this._watchWithNodeFs(t,(p,d)=>{d&&d.mtimeMs===0||this._handleRead(p,!1,n,o,t,r,f)})}return c}async _addToNodeFs(t,s,i,r,o){let n=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return n(),!1;let a=this.fsw._getWatchHelpers(t);i&&(a.filterPath=l=>i.filterPath(l),a.filterDir=l=>i.filterDir(l));try{let l=await c0[a.statMethod](a.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(a.watchPath,l))return n(),!1;let h=this.fsw.options.followSymlinks,f;if(l.isDirectory()){let c=j.resolve(t),u=h?await xn(t):t;if(this.fsw.closed||(f=await this._handleDir(a.watchPath,l,s,r,o,a,u),this.fsw.closed))return;c!==u&&u!==void 0&&this.fsw._symlinkPaths.set(c,u)}else if(l.isSymbolicLink()){let c=h?await xn(t):t;if(this.fsw.closed)return;let u=j.dirname(a.watchPath);if(this.fsw._getWatchedDir(u).add(a.watchPath),this.fsw._emit(Ut.ADD,a.watchPath,l),f=await this._handleDir(u,l,s,r,t,a,c),this.fsw.closed)return;c!==void 0&&this.fsw._symlinkPaths.set(j.resolve(t),c)}else f=this._handleFile(a.watchPath,l,s);return n(),f&&this.fsw._addPathCloser(t,f),!1}catch(l){if(this.fsw._handleError(l))return n(),t}}};var Rn="/",v0="//",_f=".",E0="..",x0="string",T0=/\\/g,Sf=/\/\//,_0=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,k0=/^\.[/\\]/;function Mr(e){return Array.isArray(e)?e:[e]}var An=e=>typeof e=="object"&&e!==null&&!(e instanceof RegExp);function O0(e){return typeof e=="function"?e:typeof e=="string"?t=>e===t:e instanceof RegExp?t=>e.test(t):typeof e=="object"&&e!==null?t=>{if(e.path===t)return!0;if(e.recursive){let s=x.relative(e.path,t);return s?!s.startsWith("..")&&!x.isAbsolute(s):!1}return!1}:()=>!1}function R0(e){if(typeof e!="string")throw new Error("string expected");e=x.normalize(e),e=e.replace(/\\/g,"/");let t=!1;e.startsWith("//")&&(t=!0);let s=/\/\//;for(;e.match(s);)e=e.replace(s,"/");return t&&(e="/"+e),e}function vf(e,t,s){let i=R0(t);for(let r=0;r<e.length;r++){let o=e[r];if(o(i,s))return!0}return!1}function A0(e,t){if(e==null)throw new TypeError("anymatch: specify first argument");let i=Mr(e).map(r=>O0(r));return t==null?(r,o)=>vf(i,r,o):vf(i,t)}var Ef=e=>{let t=Mr(e).flat();if(!t.every(s=>typeof s===x0))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(kf)},xf=e=>{let t=e.replace(T0,Rn),s=!1;for(t.startsWith(v0)&&(s=!0);t.match(Sf);)t=t.replace(Sf,Rn);return s&&(t=Rn+t),t},kf=e=>xf(x.normalize(xf(e))),Tf=(e="")=>t=>typeof t=="string"?kf(x.isAbsolute(t)?t:x.join(e,t)):t,C0=(e,t)=>x.isAbsolute(e)?e:x.join(t,e),j0=Object.freeze(new Set),Cn=class{constructor(t,s){this.path=t,this._removeWatcher=s,this.items=new Set}add(t){let{items:s}=this;s&&t!==_f&&t!==E0&&s.add(t)}async remove(t){let{items:s}=this;if(!s||(s.delete(t),s.size>0))return;let i=this.path;try{await b0(i)}catch{this._removeWatcher&&this._removeWatcher(x.dirname(i),x.basename(i))}}has(t){let{items:s}=this;if(s)return s.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=Fr,this.items=j0,Object.freeze(this)}},P0="stat",N0="lstat",jn=class{constructor(t,s,i){this.fsw=i;let r=t;this.path=t=t.replace(k0,""),this.watchPath=r,this.fullWatchPath=x.resolve(r),this.dirParts=[],this.dirParts.forEach(o=>{o.length>1&&o.pop()}),this.followSymlinks=s,this.statMethod=s?P0:N0}entryPath(t){return x.join(this.watchPath,x.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:s}=t;if(s&&s.isSymbolicLink())return this.filterDir(t);let i=this.entryPath(t);return this.fsw._isntIgnored(i,s)&&this.fsw._hasReadPermissions(s)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},Pn=class extends S0{constructor(t={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let s=t.awaitWriteFinish,i={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?Mr(t.ignored):Mr([]),awaitWriteFinish:s===!0?i:typeof s=="object"?{...i,...s}:!1};wf&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let o=process.env.CHOKIDAR_USEPOLLING;if(o!==void 0){let l=o.toLowerCase();l==="false"||l==="0"?r.usePolling=!1:l==="true"||l==="1"?r.usePolling=!0:r.usePolling=!!l}let n=process.env.CHOKIDAR_INTERVAL;n&&(r.interval=Number.parseInt(n,10));let a=0;this._emitReady=()=>{a++,a>=this._readyCount&&(this._emitReady=Fr,this._readyEmitted=!0,process.nextTick(()=>this.emit(N.READY)))},this._emitRaw=(...l)=>this.emit(N.RAW,...l),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new Nr(this),Object.freeze(r)}_addIgnoredPath(t){if(An(t)){for(let s of this._ignoredPaths)if(An(s)&&s.path===t.path&&s.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),typeof t=="string")for(let s of this._ignoredPaths)An(s)&&s.path===t&&this._ignoredPaths.delete(s)}add(t,s,i){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let o=Ef(t);return r&&(o=o.map(n=>C0(n,r))),o.forEach(n=>{this._removeIgnoredPath(n)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=o.length,Promise.all(o.map(async n=>{let a=await this._nodeFsHandler._addToNodeFs(n,!i,void 0,0,s);return a&&this._emitReady(),a})).then(n=>{this.closed||n.forEach(a=>{a&&this.add(x.dirname(a),x.basename(s||a))})}),this}unwatch(t){if(this.closed)return this;let s=Ef(t),{cwd:i}=this.options;return s.forEach(r=>{!x.isAbsolute(r)&&!this._closers.has(r)&&(i&&(r=x.join(i,r)),r=x.resolve(r)),this._closePath(r),this._addIgnoredPath(r),this._watched.has(r)&&this._addIgnoredPath({path:r,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(s=>s.forEach(i=>{let r=i();r instanceof Promise&&t.push(r)})),this._streams.forEach(s=>s.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(s=>s.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((s,i)=>{let o=(this.options.cwd?x.relative(this.options.cwd,i):i)||_f;t[o]=s.getChildren().sort()}),t}emitWithAll(t,s){this.emit(t,...s),t!==N.ERROR&&this.emit(N.ALL,t,...s)}async _emit(t,s,i){if(this.closed)return;let r=this.options;On&&(s=x.normalize(s)),r.cwd&&(s=x.relative(r.cwd,s));let o=[s];i!=null&&o.push(i);let n=r.awaitWriteFinish,a;if(n&&(a=this._pendingWrites.get(s)))return a.lastChange=new Date,this;if(r.atomic){if(t===N.UNLINK)return this._pendingUnlinks.set(s,[t,...o]),setTimeout(()=>{this._pendingUnlinks.forEach((l,h)=>{this.emit(...l),this.emit(N.ALL,...l),this._pendingUnlinks.delete(h)})},typeof r.atomic=="number"?r.atomic:100),this;t===N.ADD&&this._pendingUnlinks.has(s)&&(t=N.CHANGE,this._pendingUnlinks.delete(s))}if(n&&(t===N.ADD||t===N.CHANGE)&&this._readyEmitted){let l=(h,f)=>{h?(t=N.ERROR,o[0]=h,this.emitWithAll(t,o)):f&&(o.length>1?o[1]=f:o.push(f),this.emitWithAll(t,o))};return this._awaitWriteFinish(s,n.stabilityThreshold,t,l),this}if(t===N.CHANGE&&!this._throttle(N.CHANGE,s,50))return this;if(r.alwaysStat&&i===void 0&&(t===N.ADD||t===N.ADD_DIR||t===N.CHANGE)){let l=r.cwd?x.join(r.cwd,s):s,h;try{h=await w0(l)}catch{}if(!h||this.closed)return;o.push(h)}return this.emitWithAll(t,o),this}_handleError(t){let s=t&&t.code;return t&&s!=="ENOENT"&&s!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||s!=="EPERM"&&s!=="EACCES")&&this.emit(N.ERROR,t),t||this.closed}_throttle(t,s,i){this._throttled.has(t)||this._throttled.set(t,new Map);let r=this._throttled.get(t);if(!r)throw new Error("invalid throttle");let o=r.get(s);if(o)return o.count++,!1;let n,a=()=>{let h=r.get(s),f=h?h.count:0;return r.delete(s),clearTimeout(n),h&&clearTimeout(h.timeoutObject),f};n=setTimeout(a,i);let l={timeoutObject:n,clear:a,count:0};return r.set(s,l),l}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,s,i,r){let o=this.options.awaitWriteFinish;if(typeof o!="object")return;let n=o.pollInterval,a,l=t;this.options.cwd&&!x.isAbsolute(t)&&(l=x.join(this.options.cwd,t));let h=new Date,f=this._pendingWrites;function c(u){y0(l,(p,d)=>{if(p||!f.has(t)){p&&p.code!=="ENOENT"&&r(p);return}let m=Number(new Date);u&&d.size!==u.size&&(f.get(t).lastChange=m);let y=f.get(t);m-y.lastChange>=s?(f.delete(t),r(void 0,d)):a=setTimeout(c,n,d)})}f.has(t)||(f.set(t,{lastChange:h,cancelWait:()=>(f.delete(t),clearTimeout(a),i)}),a=setTimeout(c,n))}_isIgnored(t,s){if(this.options.atomic&&_0.test(t))return!0;if(!this._userIgnored){let{cwd:i}=this.options,o=(this.options.ignored||[]).map(Tf(i)),a=[...[...this._ignoredPaths].map(Tf(i)),...o];this._userIgnored=A0(a,void 0)}return this._userIgnored(t,s)}_isntIgnored(t,s){return!this._isIgnored(t,s)}_getWatchHelpers(t){return new jn(t,this.options.followSymlinks,this)}_getWatchedDir(t){let s=x.resolve(t);return this._watched.has(s)||this._watched.set(s,new Cn(s,this._boundRemove)),this._watched.get(s)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,s,i){let r=x.join(t,s),o=x.resolve(r);if(i=i??(this._watched.has(r)||this._watched.has(o)),!this._throttle("remove",r,100))return;!i&&this._watched.size===1&&this.add(t,s,!0),this._getWatchedDir(r).getChildren().forEach(u=>this._remove(r,u));let l=this._getWatchedDir(t),h=l.has(s);l.remove(s),this._symlinkPaths.has(o)&&this._symlinkPaths.delete(o);let f=r;if(this.options.cwd&&(f=x.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(f)&&this._pendingWrites.get(f).cancelWait()===N.ADD)return;this._watched.delete(r),this._watched.delete(o);let c=i?N.UNLINK_DIR:N.UNLINK;h&&!this._isIgnored(r)&&this._emit(c,r),this._closePath(r)}_closePath(t){this._closeFile(t);let s=x.dirname(t);this._getWatchedDir(s).remove(x.basename(t))}_closeFile(t){let s=this._closers.get(t);s&&(s.forEach(i=>i()),this._closers.delete(t))}_addPathCloser(t,s){if(!s)return;let i=this._closers.get(t);i||(i=[],this._closers.set(t,i)),i.push(s)}_readdirp(t,s){if(this.closed)return;let i={type:N.ALL,alwaysStat:!0,lstat:!0,...s,depth:0},r=pf(t,i);return this._streams.add(r),r.once(yf,()=>{r=void 0}),r.once(kn,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};function Of(e,t={}){let s=new Pn(t);return s.add(e),s}import{readFileSync as D0}from"fs";import{resolve as fs,sep as M0}from"path";import{fileURLToPath as $0}from"url";var Rf=()=>{try{return JSON.stringify(JSON.parse(D0("./package.json","utf8")))}catch{return"null"}},Nn="null",L0={persistent:!0,ignoreInitial:!0,ignorePermissionErrors:!0,ignored:e=>{let t=fs(e);return!!(t===Cf||t===Af||t.startsWith(Af+M0))}},Cf=fs("./src/package.json"),Af=fs("./src/node_modules"),jf=fs("./src"),Fn=fs("./package.json"),W0=[jf,Fn],I0=$0(new URL("./index.js",import.meta.url)),Pf=()=>{let e=!1,t=!1,s=Of(W0,L0),i=()=>{e=!0,t=!1,F0(process.execPath,[I0],{stdio:"inherit"}).on("close",(o,n)=>{o||n?(F(E.red("build failure"),{code:o,signal:n}),Me()):console.log(E.green("build success"),{code:o,signal:n}),t?i():e=!1})};s.on("all",(r,o)=>{if(r==="addDir"&&o===jf)return;let n=fs(o);if(n!==Cf){if(n===Fn){let a=Rf();if(a===Nn)return;Nn=a}if(e){n!==Fn&&(t=!0);return}T(E.cyan.dim(r),o),i()}}),Nn=Rf(),i()};var{exports:U0,tshy:z0}=k,B0=async()=>{for(let e of process.argv.slice(2))switch(e){case"--help":case"-h":return Sn();case"--watch":case"-w":return Pf();default:return Sn(`Unknown argument: ${e}`)}T(E.yellow.bold("building"),process.cwd()),T(E.cyan.dim("tshy config"),z0),T(E.cyan.dim("exports"),U0),await of(),ua(E.bold.green("success!"))};await B0();
47
+ See the docs for more information: ${s}`),e&&_(e),process.exit(e?1:0)};import{spawn as F0}from"child_process";import{stat as y0}from"fs";import{stat as w0,readdir as b0}from"fs/promises";import{EventEmitter as S0}from"events";import*as x from"path";import{stat as zb,lstat as af,readdir as Bb,realpath as Gb}from"node:fs/promises";import{Readable as Hb}from"node:stream";import{resolve as lf,relative as Yb,join as qb,sep as Vb}from"node:path";var St={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},vn={root:".",fileFilter:e=>!0,directoryFilter:e=>!0,type:St.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(vn);var uf="READDIRP_RECURSIVE_ERROR",Jb=new Set(["ENOENT","EPERM","EACCES","ELOOP",uf]),hf=[St.DIR_TYPE,St.EVERYTHING_TYPE,St.FILE_DIR_TYPE,St.FILE_TYPE],Kb=new Set([St.DIR_TYPE,St.EVERYTHING_TYPE,St.FILE_DIR_TYPE]),Xb=new Set([St.EVERYTHING_TYPE,St.FILE_DIR_TYPE,St.FILE_TYPE]),Zb=e=>Jb.has(e.code),Qb=process.platform==="win32",cf=e=>!0,ff=e=>{if(e===void 0)return cf;if(typeof e=="function")return e;if(typeof e=="string"){let t=e.trim();return s=>s.basename===t}if(Array.isArray(e)){let t=e.map(s=>s.trim());return s=>t.some(i=>s.basename===i)}return cf},En=class extends Hb{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let s={...vn,...t},{root:i,type:r}=s;this._fileFilter=ff(s.fileFilter),this._directoryFilter=ff(s.directoryFilter);let o=s.lstat?af:zb;Qb?this._stat=n=>o(n,{bigint:!0}):this._stat=o,this._maxDepth=s.depth??vn.depth,this._wantsDir=r?Kb.has(r):!1,this._wantsFile=r?Xb.has(r):!1,this._wantsEverything=r===St.EVERYTHING_TYPE,this._root=lf(i),this._isDirent=!s.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(i,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let s=this.parent,i=s&&s.files;if(i&&i.length>0){let{path:r,depth:o}=s,n=i.splice(0,t).map(l=>this._formatEntry(l,r)),a=await Promise.all(n);for(let l of a){if(!l)continue;if(this.destroyed)return;let h=await this._getEntryType(l);h==="directory"&&this._directoryFilter(l)?(o<=this._maxDepth&&this.parents.push(this._exploreDir(l.fullPath,o+1)),this._wantsDir&&(this.push(l),t--)):(h==="file"||this._includeAsFile(l))&&this._fileFilter(l)&&this._wantsFile&&(this.push(l),t--)}}else{let r=this.parents.pop();if(!r){this.push(null);break}if(this.parent=await r,this.destroyed)return}}}catch(s){this.destroy(s)}finally{this.reading=!1}}}async _exploreDir(t,s){let i;try{i=await Bb(t,this._rdOptions)}catch(r){this._onError(r)}return{files:i,depth:s,path:t}}async _formatEntry(t,s){let i,r=this._isDirent?t.name:t;try{let o=lf(qb(s,r));i={path:Yb(this._root,o),fullPath:o,basename:r},i[this._statsProp]=this._isDirent?t:await this._stat(o)}catch(o){this._onError(o);return}return i}_onError(t){Zb(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let s=t[this._statsProp];if(s.isFile())return"file";if(s.isDirectory())return"directory";if(s&&s.isSymbolicLink()){let i=t.fullPath;try{let r=await Gb(i),o=await af(r);if(o.isFile())return"file";if(o.isDirectory()){let n=r.length;if(i.startsWith(r)&&i.substr(n,1)===Vb){let a=new Error(`Circular symlink detected: "${i}" points to "${r}"`);return a.code=uf,this._onError(a)}return"directory"}}catch(r){return this._onError(r),""}}}_includeAsFile(t){let s=t&&t[this._statsProp];return s&&this._wantsEverything&&!s.isDirectory()}};function pf(e,t={}){let s=t.entryType||t.type;if(s==="both"&&(s=St.FILE_DIR_TYPE),s&&(t.type=s),e){if(typeof e!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(s&&!hf.includes(s))throw new Error(`readdirp: Invalid type passed. Use one of ${hf.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=e,new En(t)}import{watchFile as t0,unwatchFile as df,watch as e0}from"fs";import{open as s0,stat as gf,lstat as i0,realpath as xn}from"fs/promises";import*as P from"path";import{type as r0}from"os";var o0="data",kn="end",yf="close",Fr=()=>{};var Dr=process.platform,On=Dr==="win32",n0=Dr==="darwin",a0=Dr==="linux",l0=Dr==="freebsd",wf=r0()==="OS400",F={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},Ut=F,h0="watch",c0={lstat:i0,stat:gf},Ne="listeners",jr="errHandlers",cs="rawEmitters",f0=[Ne,jr,cs],u0=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),p0=e=>u0.has(P.extname(e).slice(1).toLowerCase()),_n=(e,t)=>{e instanceof Set?e.forEach(t):t(e)},oi=(e,t,s)=>{let i=e[t];i instanceof Set||(e[t]=i=new Set([i])),i.add(s)},d0=e=>t=>{let s=e[t];s instanceof Set?s.clear():delete e[t]},ni=(e,t,s)=>{let i=e[t];i instanceof Set?i.delete(s):i===s&&delete e[t]},bf=e=>e instanceof Set?e.size===0:!e,Cr=new Map;function mf(e,t,s,i,r){let o=(n,a)=>{s(e),r(n,a,{watchedPath:e}),a&&e!==a&&Pr(P.resolve(e,a),Ne,P.join(e,a))};try{return e0(e,{persistent:t.persistent},o)}catch(n){i(n);return}}var Pr=(e,t,s,i,r)=>{let o=Cr.get(e);o&&_n(o[t],n=>{n(s,i,r)})},m0=(e,t,s,i)=>{let{listener:r,errHandler:o,rawEmitter:n}=i,a=Cr.get(t),l;if(!s.persistent)return l=mf(e,s,r,o,n),l?l.close.bind(l):void 0;if(a)oi(a,Ne,r),oi(a,jr,o),oi(a,cs,n);else{if(l=mf(e,s,Pr.bind(null,t,Ne),o,Pr.bind(null,t,cs)),!l)return;l.on(Ut.ERROR,async h=>{let f=Pr.bind(null,t,jr);if(a&&(a.watcherUnusable=!0),On&&h.code==="EPERM")try{await(await s0(e,"r")).close(),f(h)}catch{}else f(h)}),a={listeners:r,errHandlers:o,rawEmitters:n,watcher:l},Cr.set(t,a)}return()=>{ni(a,Ne,r),ni(a,jr,o),ni(a,cs,n),bf(a.listeners)&&(a.watcher.close(),Cr.delete(t),f0.forEach(d0(a)),a.watcher=void 0,Object.freeze(a))}},Tn=new Map,g0=(e,t,s,i)=>{let{listener:r,rawEmitter:o}=i,n=Tn.get(t),a=n&&n.options;return a&&(a.persistent<s.persistent||a.interval>s.interval)&&(df(t),n=void 0),n?(oi(n,Ne,r),oi(n,cs,o)):(n={listeners:r,rawEmitters:o,options:s,watcher:t0(t,s,(l,h)=>{_n(n.rawEmitters,c=>{c(Ut.CHANGE,t,{curr:l,prev:h})});let f=l.mtimeMs;(l.size!==h.size||f>h.mtimeMs||f===0)&&_n(n.listeners,c=>c(e,l))})},Tn.set(t,n)),()=>{ni(n,Ne,r),ni(n,cs,o),bf(n.listeners)&&(Tn.delete(t),df(t),n.options=n.watcher=void 0,Object.freeze(n))}},Nr=class{constructor(t){this.fsw=t,this._boundHandleError=s=>t._handleError(s)}_watchWithNodeFs(t,s){let i=this.fsw.options,r=P.dirname(t),o=P.basename(t);this.fsw._getWatchedDir(r).add(o);let a=P.resolve(t),l={persistent:i.persistent};s||(s=Fr);let h;if(i.usePolling){let f=i.interval!==i.binaryInterval;l.interval=f&&p0(o)?i.binaryInterval:i.interval,h=g0(t,a,l,{listener:s,rawEmitter:this.fsw._emitRaw})}else h=m0(t,a,l,{listener:s,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return h}_handleFile(t,s,i){if(this.fsw.closed)return;let r=P.dirname(t),o=P.basename(t),n=this.fsw._getWatchedDir(r),a=s;if(n.has(o))return;let l=async(f,c)=>{if(this.fsw._throttle(h0,t,5)){if(!c||c.mtimeMs===0)try{let u=await gf(t);if(this.fsw.closed)return;let p=u.atimeMs,d=u.mtimeMs;if((!p||p<=d||d!==a.mtimeMs)&&this.fsw._emit(Ut.CHANGE,t,u),(n0||a0||l0)&&a.ino!==u.ino){this.fsw._closeFile(f),a=u;let m=this._watchWithNodeFs(t,l);m&&this.fsw._addPathCloser(f,m)}else a=u}catch{this.fsw._remove(r,o)}else if(n.has(o)){let u=c.atimeMs,p=c.mtimeMs;(!u||u<=p||p!==a.mtimeMs)&&this.fsw._emit(Ut.CHANGE,t,c),a=c}}},h=this._watchWithNodeFs(t,l);if(!(i&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(Ut.ADD,t,0))return;this.fsw._emit(Ut.ADD,t,s)}return h}async _handleSymlink(t,s,i,r){if(this.fsw.closed)return;let o=t.fullPath,n=this.fsw._getWatchedDir(s);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let a;try{a=await xn(i)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(n.has(r)?this.fsw._symlinkPaths.get(o)!==a&&(this.fsw._symlinkPaths.set(o,a),this.fsw._emit(Ut.CHANGE,i,t.stats)):(n.add(r),this.fsw._symlinkPaths.set(o,a),this.fsw._emit(Ut.ADD,i,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(o))return!0;this.fsw._symlinkPaths.set(o,!0)}_handleRead(t,s,i,r,o,n,a){if(t=P.join(t,""),a=this.fsw._throttle("readdir",t,1e3),!a)return;let l=this.fsw._getWatchedDir(i.path),h=new Set,f=this.fsw._readdirp(t,{fileFilter:c=>i.filterPath(c),directoryFilter:c=>i.filterDir(c)});if(f)return f.on(o0,async c=>{if(this.fsw.closed){f=void 0;return}let u=c.path,p=P.join(t,u);if(h.add(u),!(c.stats.isSymbolicLink()&&await this._handleSymlink(c,t,p,u))){if(this.fsw.closed){f=void 0;return}(u===r||!r&&!l.has(u))&&(this.fsw._incrReadyCount(),p=P.join(o,P.relative(o,p)),this._addToNodeFs(p,s,i,n+1))}}).on(Ut.ERROR,this._boundHandleError),new Promise((c,u)=>{if(!f)return u();f.once(kn,()=>{if(this.fsw.closed){f=void 0;return}let p=a?a.clear():!1;c(void 0),l.getChildren().filter(d=>d!==t&&!h.has(d)).forEach(d=>{this.fsw._remove(t,d)}),f=void 0,p&&this._handleRead(t,!1,i,r,o,n,a)})})}async _handleDir(t,s,i,r,o,n,a){let l=this.fsw._getWatchedDir(P.dirname(t)),h=l.has(P.basename(t));!(i&&this.fsw.options.ignoreInitial)&&!o&&!h&&this.fsw._emit(Ut.ADD_DIR,t,s),l.add(P.basename(t)),this.fsw._getWatchedDir(t);let f,c,u=this.fsw.options.depth;if((u==null||r<=u)&&!this.fsw._symlinkPaths.has(a)){if(!o&&(await this._handleRead(t,i,n,o,t,r,f),this.fsw.closed))return;c=this._watchWithNodeFs(t,(p,d)=>{d&&d.mtimeMs===0||this._handleRead(p,!1,n,o,t,r,f)})}return c}async _addToNodeFs(t,s,i,r,o){let n=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return n(),!1;let a=this.fsw._getWatchHelpers(t);i&&(a.filterPath=l=>i.filterPath(l),a.filterDir=l=>i.filterDir(l));try{let l=await c0[a.statMethod](a.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(a.watchPath,l))return n(),!1;let h=this.fsw.options.followSymlinks,f;if(l.isDirectory()){let c=P.resolve(t),u=h?await xn(t):t;if(this.fsw.closed||(f=await this._handleDir(a.watchPath,l,s,r,o,a,u),this.fsw.closed))return;c!==u&&u!==void 0&&this.fsw._symlinkPaths.set(c,u)}else if(l.isSymbolicLink()){let c=h?await xn(t):t;if(this.fsw.closed)return;let u=P.dirname(a.watchPath);if(this.fsw._getWatchedDir(u).add(a.watchPath),this.fsw._emit(Ut.ADD,a.watchPath,l),f=await this._handleDir(u,l,s,r,t,a,c),this.fsw.closed)return;c!==void 0&&this.fsw._symlinkPaths.set(P.resolve(t),c)}else f=this._handleFile(a.watchPath,l,s);return n(),f&&this.fsw._addPathCloser(t,f),!1}catch(l){if(this.fsw._handleError(l))return n(),t}}};var Rn="/",v0="//",_f=".",E0="..",x0="string",T0=/\\/g,Sf=/\/\//,_0=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,k0=/^\.[/\\]/;function $r(e){return Array.isArray(e)?e:[e]}var An=e=>typeof e=="object"&&e!==null&&!(e instanceof RegExp);function O0(e){return typeof e=="function"?e:typeof e=="string"?t=>e===t:e instanceof RegExp?t=>e.test(t):typeof e=="object"&&e!==null?t=>{if(e.path===t)return!0;if(e.recursive){let s=x.relative(e.path,t);return s?!s.startsWith("..")&&!x.isAbsolute(s):!1}return!1}:()=>!1}function R0(e){if(typeof e!="string")throw new Error("string expected");e=x.normalize(e),e=e.replace(/\\/g,"/");let t=!1;e.startsWith("//")&&(t=!0);let s=/\/\//;for(;e.match(s);)e=e.replace(s,"/");return t&&(e="/"+e),e}function vf(e,t,s){let i=R0(t);for(let r=0;r<e.length;r++){let o=e[r];if(o(i,s))return!0}return!1}function A0(e,t){if(e==null)throw new TypeError("anymatch: specify first argument");let i=$r(e).map(r=>O0(r));return t==null?(r,o)=>vf(i,r,o):vf(i,t)}var Ef=e=>{let t=$r(e).flat();if(!t.every(s=>typeof s===x0))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(kf)},xf=e=>{let t=e.replace(T0,Rn),s=!1;for(t.startsWith(v0)&&(s=!0);t.match(Sf);)t=t.replace(Sf,Rn);return s&&(t=Rn+t),t},kf=e=>xf(x.normalize(xf(e))),Tf=(e="")=>t=>typeof t=="string"?kf(x.isAbsolute(t)?t:x.join(e,t)):t,j0=(e,t)=>x.isAbsolute(e)?e:x.join(t,e),C0=Object.freeze(new Set),jn=class{constructor(t,s){this.path=t,this._removeWatcher=s,this.items=new Set}add(t){let{items:s}=this;s&&t!==_f&&t!==E0&&s.add(t)}async remove(t){let{items:s}=this;if(!s||(s.delete(t),s.size>0))return;let i=this.path;try{await b0(i)}catch{this._removeWatcher&&this._removeWatcher(x.dirname(i),x.basename(i))}}has(t){let{items:s}=this;if(s)return s.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=Fr,this.items=C0,Object.freeze(this)}},P0="stat",N0="lstat",Cn=class{constructor(t,s,i){this.fsw=i;let r=t;this.path=t=t.replace(k0,""),this.watchPath=r,this.fullWatchPath=x.resolve(r),this.dirParts=[],this.dirParts.forEach(o=>{o.length>1&&o.pop()}),this.followSymlinks=s,this.statMethod=s?P0:N0}entryPath(t){return x.join(this.watchPath,x.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:s}=t;if(s&&s.isSymbolicLink())return this.filterDir(t);let i=this.entryPath(t);return this.fsw._isntIgnored(i,s)&&this.fsw._hasReadPermissions(s)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},Pn=class extends S0{constructor(t={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let s=t.awaitWriteFinish,i={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?$r(t.ignored):$r([]),awaitWriteFinish:s===!0?i:typeof s=="object"?{...i,...s}:!1};wf&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let o=process.env.CHOKIDAR_USEPOLLING;if(o!==void 0){let l=o.toLowerCase();l==="false"||l==="0"?r.usePolling=!1:l==="true"||l==="1"?r.usePolling=!0:r.usePolling=!!l}let n=process.env.CHOKIDAR_INTERVAL;n&&(r.interval=Number.parseInt(n,10));let a=0;this._emitReady=()=>{a++,a>=this._readyCount&&(this._emitReady=Fr,this._readyEmitted=!0,process.nextTick(()=>this.emit(F.READY)))},this._emitRaw=(...l)=>this.emit(F.RAW,...l),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new Nr(this),Object.freeze(r)}_addIgnoredPath(t){if(An(t)){for(let s of this._ignoredPaths)if(An(s)&&s.path===t.path&&s.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),typeof t=="string")for(let s of this._ignoredPaths)An(s)&&s.path===t&&this._ignoredPaths.delete(s)}add(t,s,i){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let o=Ef(t);return r&&(o=o.map(n=>j0(n,r))),o.forEach(n=>{this._removeIgnoredPath(n)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=o.length,Promise.all(o.map(async n=>{let a=await this._nodeFsHandler._addToNodeFs(n,!i,void 0,0,s);return a&&this._emitReady(),a})).then(n=>{this.closed||n.forEach(a=>{a&&this.add(x.dirname(a),x.basename(s||a))})}),this}unwatch(t){if(this.closed)return this;let s=Ef(t),{cwd:i}=this.options;return s.forEach(r=>{!x.isAbsolute(r)&&!this._closers.has(r)&&(i&&(r=x.join(i,r)),r=x.resolve(r)),this._closePath(r),this._addIgnoredPath(r),this._watched.has(r)&&this._addIgnoredPath({path:r,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(s=>s.forEach(i=>{let r=i();r instanceof Promise&&t.push(r)})),this._streams.forEach(s=>s.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(s=>s.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((s,i)=>{let o=(this.options.cwd?x.relative(this.options.cwd,i):i)||_f;t[o]=s.getChildren().sort()}),t}emitWithAll(t,s){this.emit(t,...s),t!==F.ERROR&&this.emit(F.ALL,t,...s)}async _emit(t,s,i){if(this.closed)return;let r=this.options;On&&(s=x.normalize(s)),r.cwd&&(s=x.relative(r.cwd,s));let o=[s];i!=null&&o.push(i);let n=r.awaitWriteFinish,a;if(n&&(a=this._pendingWrites.get(s)))return a.lastChange=new Date,this;if(r.atomic){if(t===F.UNLINK)return this._pendingUnlinks.set(s,[t,...o]),setTimeout(()=>{this._pendingUnlinks.forEach((l,h)=>{this.emit(...l),this.emit(F.ALL,...l),this._pendingUnlinks.delete(h)})},typeof r.atomic=="number"?r.atomic:100),this;t===F.ADD&&this._pendingUnlinks.has(s)&&(t=F.CHANGE,this._pendingUnlinks.delete(s))}if(n&&(t===F.ADD||t===F.CHANGE)&&this._readyEmitted){let l=(h,f)=>{h?(t=F.ERROR,o[0]=h,this.emitWithAll(t,o)):f&&(o.length>1?o[1]=f:o.push(f),this.emitWithAll(t,o))};return this._awaitWriteFinish(s,n.stabilityThreshold,t,l),this}if(t===F.CHANGE&&!this._throttle(F.CHANGE,s,50))return this;if(r.alwaysStat&&i===void 0&&(t===F.ADD||t===F.ADD_DIR||t===F.CHANGE)){let l=r.cwd?x.join(r.cwd,s):s,h;try{h=await w0(l)}catch{}if(!h||this.closed)return;o.push(h)}return this.emitWithAll(t,o),this}_handleError(t){let s=t&&t.code;return t&&s!=="ENOENT"&&s!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||s!=="EPERM"&&s!=="EACCES")&&this.emit(F.ERROR,t),t||this.closed}_throttle(t,s,i){this._throttled.has(t)||this._throttled.set(t,new Map);let r=this._throttled.get(t);if(!r)throw new Error("invalid throttle");let o=r.get(s);if(o)return o.count++,!1;let n,a=()=>{let h=r.get(s),f=h?h.count:0;return r.delete(s),clearTimeout(n),h&&clearTimeout(h.timeoutObject),f};n=setTimeout(a,i);let l={timeoutObject:n,clear:a,count:0};return r.set(s,l),l}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,s,i,r){let o=this.options.awaitWriteFinish;if(typeof o!="object")return;let n=o.pollInterval,a,l=t;this.options.cwd&&!x.isAbsolute(t)&&(l=x.join(this.options.cwd,t));let h=new Date,f=this._pendingWrites;function c(u){y0(l,(p,d)=>{if(p||!f.has(t)){p&&p.code!=="ENOENT"&&r(p);return}let m=Number(new Date);u&&d.size!==u.size&&(f.get(t).lastChange=m);let y=f.get(t);m-y.lastChange>=s?(f.delete(t),r(void 0,d)):a=setTimeout(c,n,d)})}f.has(t)||(f.set(t,{lastChange:h,cancelWait:()=>(f.delete(t),clearTimeout(a),i)}),a=setTimeout(c,n))}_isIgnored(t,s){if(this.options.atomic&&_0.test(t))return!0;if(!this._userIgnored){let{cwd:i}=this.options,o=(this.options.ignored||[]).map(Tf(i)),a=[...[...this._ignoredPaths].map(Tf(i)),...o];this._userIgnored=A0(a,void 0)}return this._userIgnored(t,s)}_isntIgnored(t,s){return!this._isIgnored(t,s)}_getWatchHelpers(t){return new Cn(t,this.options.followSymlinks,this)}_getWatchedDir(t){let s=x.resolve(t);return this._watched.has(s)||this._watched.set(s,new jn(s,this._boundRemove)),this._watched.get(s)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,s,i){let r=x.join(t,s),o=x.resolve(r);if(i=i??(this._watched.has(r)||this._watched.has(o)),!this._throttle("remove",r,100))return;!i&&this._watched.size===1&&this.add(t,s,!0),this._getWatchedDir(r).getChildren().forEach(u=>this._remove(r,u));let l=this._getWatchedDir(t),h=l.has(s);l.remove(s),this._symlinkPaths.has(o)&&this._symlinkPaths.delete(o);let f=r;if(this.options.cwd&&(f=x.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(f)&&this._pendingWrites.get(f).cancelWait()===F.ADD)return;this._watched.delete(r),this._watched.delete(o);let c=i?F.UNLINK_DIR:F.UNLINK;h&&!this._isIgnored(r)&&this._emit(c,r),this._closePath(r)}_closePath(t){this._closeFile(t);let s=x.dirname(t);this._getWatchedDir(s).remove(x.basename(t))}_closeFile(t){let s=this._closers.get(t);s&&(s.forEach(i=>i()),this._closers.delete(t))}_addPathCloser(t,s){if(!s)return;let i=this._closers.get(t);i||(i=[],this._closers.set(t,i)),i.push(s)}_readdirp(t,s){if(this.closed)return;let i={type:F.ALL,alwaysStat:!0,lstat:!0,...s,depth:0},r=pf(t,i);return this._streams.add(r),r.once(yf,()=>{r=void 0}),r.once(kn,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};function Of(e,t={}){let s=new Pn(t);return s.add(e),s}import{readFileSync as D0}from"fs";import{resolve as fs,sep as $0}from"path";import{fileURLToPath as M0}from"url";var Rf=()=>{try{return JSON.stringify(JSON.parse(D0("./package.json","utf8")))}catch{return"null"}},Nn="null",L0={persistent:!0,ignoreInitial:!0,ignorePermissionErrors:!0,ignored:e=>{let t=fs(e);return!!(t===jf||t===Af||t.startsWith(Af+$0))}},jf=fs("./src/package.json"),Af=fs("./src/node_modules"),Cf=fs("./src"),Fn=fs("./package.json"),W0=[Cf,Fn],I0=M0(new URL("./index.js",import.meta.url)),Pf=()=>{let e=!1,t=!1,s=Of(W0,L0),i=()=>{e=!0,t=!1,F0(process.execPath,[I0],{stdio:"inherit"}).on("close",(o,n)=>{o||n?(D(E.red("build failure"),{code:o,signal:n}),$e()):console.log(E.green("build success"),{code:o,signal:n}),t?i():e=!1})};s.on("all",(r,o)=>{if(r==="addDir"&&o===Cf)return;let n=fs(o);if(n!==jf){if(n===Fn){let a=Rf();if(a===Nn)return;Nn=a}if(e){n!==Fn&&(t=!0);return}T(E.cyan.dim(r),o),i()}}),Nn=Rf(),i()};var{exports:U0,tshy:z0}=k,B0=async()=>{for(let e of process.argv.slice(2))switch(e){case"--help":case"-h":return Sn();case"--watch":case"-w":return Pf();default:return Sn(`Unknown argument: ${e}`)}T(E.yellow.bold("building"),process.cwd()),T(E.cyan.dim("tshy config"),z0),T(E.cyan.dim("exports"),U0),await of(),ua(E.bold.green("success!"))};await B0();
48
48
  /*! Bundled license information:
49
49
 
50
50
  chokidar/esm/index.js: