"use strict";var p=require("path"),d=require("fs"),ge=require("module"),me=require("resolve-pkg-maps");function B(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}const h=e=>{const t=d[e];return(i,...n)=>{const s=`${e}:${n.join(":")}`;let o=i==null?void 0:i.get(s);return o===void 0&&(o=Reflect.apply(t,d,n),i==null||i.set(s,o)),o}},_=h("existsSync"),ke=h("readFileSync"),P=h("statSync"),Z=(e,t,i)=>{for(;;){const n=p.posix.join(e,t);if(_(i,n))return n;const s=p.dirname(e);if(s===e)return;e=s}},M=/^\.{1,2}(\/.*)?$/,W=e=>{const t=B(e);return M.test(t)?t:`./${t}`};function be(e,t=!1){const i=e.length;let n=0,s="",o=0,l=16,a=0,u=0,w=0,T=0,c=0;function E(r,g){let f=0,$=0;for(;f=48&&A<=57)$=$*16+A-48;else if(A>=65&&A<=70)$=$*16+A-65+10;else if(A>=97&&A<=102)$=$*16+A-97+10;else break;n++,f++}return f=i){r+=e.substring(g,n),c=2;break}const f=e.charCodeAt(n);if(f===34){r+=e.substring(g,n),n++;break}if(f===92){if(r+=e.substring(g,n),n++,n>=i){c=2;break}switch(e.charCodeAt(n++)){case 34:r+='"';break;case 92:r+="\\";break;case 47:r+="/";break;case 98:r+="\b";break;case 102:r+="\f";break;case 110:r+=` `;break;case 114:r+="\r";break;case 116:r+=" ";break;case 117:const A=E(4,!0);A>=0?r+=String.fromCharCode(A):c=4;break;default:c=5}g=n;continue}if(f>=0&&f<=31)if(N(f)){r+=e.substring(g,n),c=2;break}else c=6;n++}return r}function j(){if(s="",c=0,o=n,u=a,T=w,n>=i)return o=i,l=17;let r=e.charCodeAt(n);if(J(r)){do n++,s+=String.fromCharCode(r),r=e.charCodeAt(n);while(J(r));return l=15}if(N(r))return n++,s+=String.fromCharCode(r),r===13&&e.charCodeAt(n)===10&&(n++,s+=` `),a++,w=n,l=14;switch(r){case 123:return n++,l=1;case 125:return n++,l=2;case 91:return n++,l=3;case 93:return n++,l=4;case 58:return n++,l=6;case 44:return n++,l=5;case 34:return n++,s=k(),l=10;case 47:const g=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n=12&&r<=15);return r}return{setPosition:b,getPosition:()=>n,scan:t?U:j,getToken:()=>l,getTokenValue:()=>s,getTokenOffset:()=>o,getTokenLength:()=>n-o,getTokenStartLine:()=>u,getTokenStartCharacter:()=>o-T,getTokenError:()=>c}}function J(e){return e===32||e===9}function N(e){return e===10||e===13}function y(e){return e>=48&&e<=57}var K;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(K||(K={})),new Array(20).fill(0).map((e,t)=>" ".repeat(t));const F=200;new Array(F).fill(0).map((e,t)=>` `+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>`\r `+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>` `+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(F).fill(0).map((e,t)=>`\r `+" ".repeat(t));var I;(function(e){e.DEFAULT={allowTrailingComma:!1}})(I||(I={}));function we(e,t=[],i=I.DEFAULT){let n=null,s=[];const o=[];function l(u){Array.isArray(s)?s.push(u):n!==null&&(s[n]=u)}return ve(e,{onObjectBegin:()=>{const u={};l(u),o.push(s),s=u,n=null},onObjectProperty:u=>{n=u},onObjectEnd:()=>{s=o.pop()},onArrayBegin:()=>{const u=[];l(u),o.push(s),s=u,n=null},onArrayEnd:()=>{s=o.pop()},onLiteralValue:l,onError:(u,w,T)=>{t.push({error:u,offset:w,length:T})}},i),s[0]}function ve(e,t,i=I.DEFAULT){const n=be(e,!1),s=[];function o(m){return m?()=>m(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function l(m){return m?()=>m(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>s.slice()):()=>!0}function a(m){return m?O=>m(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function u(m){return m?O=>m(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>s.slice()):()=>!0}const w=l(t.onObjectBegin),T=u(t.onObjectProperty),c=o(t.onObjectEnd),E=l(t.onArrayBegin),b=o(t.onArrayEnd),v=u(t.onLiteralValue),k=a(t.onSeparator),j=o(t.onComment),L=a(t.onError),U=i&&i.disallowComments,r=i&&i.allowTrailingComma;function g(){for(;;){const m=n.scan();switch(n.getTokenError()){case 4:f(14);break;case 5:f(15);break;case 3:f(13);break;case 1:U||f(11);break;case 2:f(12);break;case 6:f(16);break}switch(m){case 12:case 13:U?f(10):j();break;case 16:f(1);break;case 15:case 14:break;default:return m}}}function f(m,O=[],Y=[]){if(L(m),O.length+Y.length>0){let x=n.getToken();for(;x!==17;){if(O.indexOf(x)!==-1){g();break}else if(Y.indexOf(x)!==-1)break;x=g()}}}function $(m){const O=n.getTokenValue();return m?v(O):(T(O),s.push(O)),g(),!0}function A(){switch(n.getToken()){case 11:const m=n.getTokenValue();let O=Number(m);isNaN(O)&&(f(2),O=0),v(O);break;case 7:v(null);break;case 8:v(!0);break;case 9:v(!1);break;default:return!1}return g(),!0}function fe(){return n.getToken()!==10?(f(3,[],[2,5]),!1):($(!1),n.getToken()===6?(k(":"),g(),S()||f(4,[],[2,5])):f(5,[],[2,5]),s.pop(),!0)}function pe(){w(),g();let m=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(m||f(4,[],[]),k(","),g(),n.getToken()===2&&r)break}else m&&f(6,[],[]);fe()||f(4,[],[2,5]),m=!0}return c(),n.getToken()!==2?f(7,[2],[]):g(),!0}function ae(){E(),g();let m=!0,O=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(O||f(4,[],[]),k(","),g(),n.getToken()===4&&r)break}else O&&f(6,[],[]);m?(s.push(0),m=!1):s[s.length-1]++,S()||f(4,[],[4,5]),O=!0}return b(),m||s.pop(),n.getToken()!==4?f(8,[4],[]):g(),!0}function S(){switch(n.getToken()){case 3:return ae();case 1:return pe();case 10:return $(!0);default:return A()}}return g(),n.getToken()===17?i.allowEmptyContent?!0:(f(4,[],[]),!1):S()?(n.getToken()!==17&&f(9,[],[]),!0):(f(4,[],[]),!1)}var C;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(C||(C={}));var ee;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(ee||(ee={}));const Te=we;var ne;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(ne||(ne={}));const te=(e,t)=>Te(ke(t,e,"utf8")),R=Symbol("implicitBaseUrl"),Ae=()=>{const{findPnpApi:e}=ge;return e&&e(process.cwd())},G=(e,t,i,n)=>{const s=`resolveFromPackageJsonPath:${e}:${t}:${i}`;if(n!=null&&n.has(s))return n.get(s);const o=te(e,n);if(!o)return;let l=t||"tsconfig.json";if(!i&&o.exports)try{const[a]=me.resolveExports(o.exports,t,["require","types"]);l=a}catch{return!1}else!t&&o.tsconfig&&(l=o.tsconfig);return l=p.join(e,"..",l),n==null||n.set(s,l),l},z="package.json",Q="tsconfig.json",Oe=(e,t,i)=>{let n=e;if(e===".."&&(n=p.join(n,Q)),e[0]==="."&&(n=p.resolve(t,n)),p.isAbsolute(n)){if(_(i,n)){if(P(i,n).isFile())return n}else if(!n.endsWith(".json")){const b=`${n}.json`;if(_(i,b))return b}return}const[s,...o]=e.split("/"),l=s[0]==="@"?`${s}/${o.shift()}`:s,a=o.join("/"),u=Ae();if(u){const{resolveRequest:b}=u;try{if(l===e){const v=b(p.join(l,z),t);if(v){const k=G(v,a,!1,i);if(k&&_(i,k))return k}}else{let v;try{v=b(e,t,{extensions:[".json"]})}catch{v=b(p.join(e,Q),t)}if(v)return v}}catch{}}const w=Z(p.resolve(t),p.join("node_modules",l),i);if(!w||!P(i,w).isDirectory())return;const T=p.join(w,z);if(_(i,T)){const b=G(T,a,!1,i);if(b===!1)return;if(b&&_(i,b)&&P(i,b).isFile())return b}const c=p.join(w,a),E=c.endsWith(".json");if(!E){const b=`${c}.json`;if(_(i,b))return b}if(_(i,c)){if(P(i,c).isDirectory()){const b=p.join(c,z);if(_(i,b)){const k=G(b,"",!0,i);if(k&&_(i,k))return k}const v=p.join(c,Q);if(_(i,v))return v}else if(E)return c}},je=(e,t,i,n)=>{const s=Oe(e,t,n);if(!s)throw new Error(`File '${e}' not found.`);if(i.has(s))throw new Error(`Circularity detected while resolving configuration: ${s}`);i.add(s);const o=p.dirname(s),l=ie(s,n,i);delete l.references;const{compilerOptions:a}=l;if(a){const u=["baseUrl","outDir"];for(const w of u){const T=a[w];T&&(a[w]=B(p.relative(t,p.join(o,T)))||"./")}}return l.files&&(l.files=l.files.map(u=>B(p.relative(t,p.join(o,u))))),l.include&&(l.include=l.include.map(u=>B(p.relative(t,p.join(o,u))))),l.exclude&&(l.exclude=l.exclude.map(u=>B(p.relative(t,p.join(o,u))))),l},ie=(e,t,i=new Set)=>{let n;try{n=te(e,t)||{}}catch{throw new Error(`Cannot resolve tsconfig at path: ${e}`)}if(typeof n!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${e}`);const s=p.dirname(e);if(n.compilerOptions){const{compilerOptions:o}=n;o.paths&&!o.baseUrl&&(o[R]=s)}if(n.extends){const o=Array.isArray(n.extends)?n.extends:[n.extends];delete n.extends;for(const l of o.reverse()){const a=je(l,s,new Set(i),t),u={...a,...n,compilerOptions:{...a.compilerOptions,...n.compilerOptions}};a.watchOptions&&(u.watchOptions={...a.watchOptions,...n.watchOptions}),n=u}}if(n.compilerOptions){const{compilerOptions:o}=n,l=["baseUrl","rootDir"];for(const u of l){const w=o[u];if(w){const T=p.resolve(s,w),c=W(p.relative(s,T));o[u]=c}}const{outDir:a}=o;a&&(Array.isArray(n.exclude)||(n.exclude=[]),n.exclude.includes(a)||n.exclude.push(a),o.outDir=W(a))}else n.compilerOptions={};if(n.files&&(n.files=n.files.map(W)),n.include&&(n.include=n.include.map(B)),n.watchOptions){const{watchOptions:o}=n;o.excludeDirectories&&(o.excludeDirectories=o.excludeDirectories.map(l=>B(p.resolve(s,l))))}return n},se=(e,t=new Map)=>ie(e,t),$e=(e=process.cwd(),t="tsconfig.json",i=new Map)=>{const n=Z(B(e),t,i);if(!n)return null;const s=se(n,i);return{path:n,config:s}},Be=/\*/g,le=(e,t)=>{const i=e.match(Be);if(i&&i.length>1)throw new Error(t)},_e=e=>{if(e.includes("*")){const[t,i]=e.split("*");return{prefix:t,suffix:i}}return e},Ee=({prefix:e,suffix:t},i)=>i.startsWith(e)&&i.endsWith(t),Le=(e,t,i)=>Object.entries(e).map(([n,s])=>(le(n,`Pattern '${n}' can have at most one '*' character.`),{pattern:_e(n),substitutions:s.map(o=>{if(le(o,`Substitution '${o}' in pattern '${n}' can have at most one '*' character.`),!t&&!M.test(o))throw new Error("Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?");return p.resolve(i,o)})})),Ue=e=>{if(!e.config.compilerOptions)return null;const{baseUrl:t,paths:i}=e.config.compilerOptions,n=R in e.config.compilerOptions&&e.config.compilerOptions[R];if(!t&&!i)return null;const s=p.resolve(p.dirname(e.path),t||n||"."),o=i?Le(i,t,s):[];return l=>{if(M.test(l))return[];const a=[];for(const c of o){if(c.pattern===l)return c.substitutions.map(B);typeof c.pattern!="string"&&a.push(c)}let u,w=-1;for(const c of a)Ee(c.pattern,l)&&c.pattern.prefix.length>w&&(w=c.pattern.prefix.length,u=c);if(!u)return t?[B(p.join(s,l))]:[];const T=l.slice(u.pattern.prefix.length,l.length-u.pattern.suffix.length);return u.substitutions.map(c=>B(c.replace("*",T)))}},oe=e=>{let t="";for(let i=0;iMath.floor(Math.random()*26),xe=e=>Array.from({length:e},()=>String.fromCodePoint(Ne()+(Math.random()>.5?ye:Fe))).join(""),Pe=(e=d)=>{const t=process.execPath;if(e.existsSync(t))return!e.existsSync(oe(t));const i=`/${xe(10)}`;e.writeFileSync(i,"");const n=!e.existsSync(oe(i));return e.unlinkSync(i),n},{join:D}=p.posix,H={ts:[".ts",".tsx",".d.ts"],cts:[".cts",".d.cts"],mts:[".mts",".d.mts"]},Ie=e=>{const t=[...H.ts],i=[...H.cts],n=[...H.mts];return e!=null&&e.allowJs&&(t.push(".js",".jsx"),i.push(".cjs"),n.push(".mjs")),[...t,...i,...n]},De=e=>{const t=[];if(!e)return t;const{outDir:i,declarationDir:n}=e;return i&&t.push(i),n&&t.push(n),t},re=e=>e.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),Ve=["node_modules","bower_components","jspm_packages"],q=`(?!(${Ve.join("|")})(/|$))`,Se=/(?:^|\/)[^.*?]+$/,ue="**/*",V="[^/]",X="[^./]",ce=process.platform==="win32",de=({config:e,path:t},i=Pe())=>{if("extends"in e)throw new Error("tsconfig#extends must be resolved. Use getTsconfig or parseTsconfig to resolve it.");if(!p.isAbsolute(t))throw new Error("The tsconfig path must be absolute");ce&&(t=B(t));const n=p.dirname(t),{files:s,include:o,exclude:l,compilerOptions:a}=e,u=s==null?void 0:s.map(k=>D(n,k)),w=Ie(a),T=i?"":"i",E=(l||De(a)).map(k=>{const j=D(n,k),L=re(j).replaceAll("\\*\\*/","(.+/)?").replaceAll("\\*",`${V}*`).replaceAll("\\?",V);return new RegExp(`^${L}($|/)`,T)}),b=s||o?o:[ue],v=b?b.map(k=>{let j=D(n,k);Se.test(j)&&(j=D(j,ue));const L=re(j).replaceAll("/\\*\\*",`(/${q}${X}${V}*)*?`).replaceAll(/(\/)?\\\*/g,(U,r)=>{const g=`(${X}|(\\.(?!min\\.js$))?)*`;return r?`/${q}${X}${g}`:g}).replaceAll(/(\/)?\\\?/g,(U,r)=>{const g=V;return r?`/${q}${g}`:g});return new RegExp(`^${L}$`,T)}):void 0;return k=>{if(!p.isAbsolute(k))throw new Error("filePath must be absolute");if(ce&&(k=B(k)),u!=null&&u.includes(k))return e;if(!(!w.some(j=>k.endsWith(j))||E.some(j=>j.test(k)))&&v&&v.some(j=>j.test(k)))return e}};exports.createFilesMatcher=de,exports.createPathsMatcher=Ue,exports.getTsconfig=$e,exports.parseTsconfig=se;