"use strict";var d=require("path"),g=require("fs"),u=require("module"),f=require("get-tsconfig"),O=require("../source-map.cjs"),m=require("../index-971a6964.cjs"),P=require("../resolve-ts-path-3fca13b7.cjs"),j=require("../client-2f0df4a6.cjs");require("url"),require("esbuild"),require("crypto"),require("os"),require("../temporary-directory-2a027842.cjs"),require("net"),require("../get-pipe-path-86e97fc9.cjs");const q=s=>{if(s.includes("import")||s.includes("export"))try{return m.parseEsm(s)[3]}catch{return!0}return!1},E=/^\.{1,2}\//,M=/\.[cm]?tsx?$/,A=`${d.sep}node_modules${d.sep}`,c=process.env.TSX_TSCONFIG_PATH?{path:d.resolve(process.env.TSX_TSCONFIG_PATH),config:f.parseTsconfig(process.env.TSX_TSCONFIG_PATH)}:f.getTsconfig(),_=c&&f.createFilesMatcher(c),x=c&&f.createPathsMatcher(c),y=O.installSourceMapSupport(),v=u._extensions,N=v[".js"],R=[".cts",".mts",".ts",".tsx",".jsx"],b=[".js",".cjs",".mjs"];let T;j.connectingToServer.then(s=>{T=s},()=>{});const S=(s,e)=>{T&&T({type:"dependency",path:e});const n=R.some(r=>e.endsWith(r)),o=b.some(r=>e.endsWith(r));if(!n&&!o)return N(s,e);let t=g.readFileSync(e,"utf8");if(e.endsWith(".cjs")){const r=m.transformDynamicImport(e,t);r&&(t=y(r))}else if(n||q(t)){const r=m.transformSync(t,e,{tsconfigRaw:_==null?void 0:_(e)});t=y(r)}s._compile(t,e)};[".js",".ts",".tsx",".jsx"].forEach(s=>{v[s]=S}),Object.defineProperty(v,".mjs",{value:S,enumerable:!1});const h=u._resolveFilename.bind(u);u._resolveFilename=(s,e,n,o)=>{var t;const r=s.indexOf("?");if(r!==-1&&(s=s.slice(0,r)),x&&!E.test(s)&&!((t=e==null?void 0:e.filename)!=null&&t.includes(A))){const l=x(s);for(const i of l){const p=F(i,e,n,o);if(p)return p;try{return h(i,e,n,o)}catch{}}}const a=F(s,e,n,o);return a||h(s,e,n,o)};const F=(s,e,n,o)=>{var t;const r=P.resolveTsPath(s);if(e!=null&&e.filename&&(M.test(e.filename)||(t=c==null?void 0:c.config.compilerOptions)!=null&&t.allowJs)&&r)for(const a of r)try{return h(a,e,n,o)}catch(l){const{code:i}=l;if(i!=="MODULE_NOT_FOUND"&&i!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw l}};
