@stacksjs/dtsx 0.9.17 → 0.9.19

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.
Files changed (44) hide show
  1. package/dist/bin/cli.js +5 -5
  2. package/dist/chunk-1z1w3s0k.js +25 -0
  3. package/dist/chunk-2n9mmg2c.js +2 -0
  4. package/dist/{chunk-bsxtpwx6.js → chunk-2qyt67jt.js} +1 -1
  5. package/dist/chunk-4jw8qvts.js +16 -0
  6. package/dist/chunk-69rnp3hs.js +19 -0
  7. package/dist/chunk-7g7axw9t.js +2 -0
  8. package/dist/{chunk-vpjw38x7.js → chunk-7pwy4m0c.js} +1 -1
  9. package/dist/{chunk-x3q42h61.js → chunk-7zsd1qqw.js} +1 -1
  10. package/dist/{chunk-3rpqh1bm.js → chunk-9qe2wx58.js} +1 -1
  11. package/dist/{chunk-xhs0tsnn.js → chunk-9ycwkhxh.js} +1 -1
  12. package/dist/{chunk-mzq58nw0.js → chunk-dv8haj2p.js} +1 -1
  13. package/dist/{chunk-a6tznyxq.js → chunk-ezrgnecm.js} +1 -1
  14. package/dist/{chunk-3zjt21t1.js → chunk-fbradttj.js} +1 -1
  15. package/dist/{chunk-83e9a4fq.js → chunk-fg4cjy7w.js} +1 -1
  16. package/dist/{chunk-xmje6xfw.js → chunk-fmhrt2ca.js} +1 -1
  17. package/dist/{chunk-6sx8ppfg.js → chunk-gg6xh82k.js} +1 -1
  18. package/dist/{chunk-8z31rkfp.js → chunk-jjwwkrfk.js} +1 -1
  19. package/dist/{chunk-4s9jv983.js → chunk-kwmhsx3n.js} +1 -1
  20. package/dist/{chunk-scrtz9j4.js → chunk-m68323h2.js} +1 -1
  21. package/dist/{chunk-8hxrwrsf.js → chunk-mr4jjsps.js} +1 -1
  22. package/dist/{chunk-jvfvxm5w.js → chunk-nwvqfthk.js} +1 -1
  23. package/dist/chunk-q0k7xs9f.js +2 -0
  24. package/dist/{chunk-f4c389mj.js → chunk-s30jnjb4.js} +1 -1
  25. package/dist/{chunk-yth8251f.js → chunk-sbmecr6t.js} +1 -1
  26. package/dist/chunk-w1k33gyv.js +2 -0
  27. package/dist/{chunk-pep9jyxn.js → chunk-x4jgc4bx.js} +1 -1
  28. package/dist/extractor/builders.d.ts +1 -1
  29. package/dist/extractor/helpers.d.ts +9 -0
  30. package/dist/src/index.js +1 -1
  31. package/dist/src/plugins/bun.js +1 -1
  32. package/dist/src/plugins/esbuild.js +1 -1
  33. package/dist/src/plugins/index.js +1 -1
  34. package/dist/src/plugins/tsup.js +1 -1
  35. package/dist/src/plugins/vite.js +1 -1
  36. package/dist/src/plugins/webpack.js +1 -1
  37. package/package.json +1 -1
  38. package/dist/chunk-285mqzvx.js +0 -16
  39. package/dist/chunk-2r21f44d.js +0 -25
  40. package/dist/chunk-8cv1t8qg.js +0 -2
  41. package/dist/chunk-bh9ey0vw.js +0 -2
  42. package/dist/chunk-sdjfh4mj.js +0 -2
  43. package/dist/chunk-w8d9jjsa.js +0 -2
  44. package/dist/chunk-y581wnfe.js +0 -19
package/dist/bin/cli.js CHANGED
@@ -1,11 +1,11 @@
1
1
  // @bun
2
- import{dd as Y}from"../chunk-mcdb3q06.js";import V from"process";var f=V.argv[2];if(f==="stdin"||f==="emit"||f==="--project"){if(f==="stdin"){let{processSource:q}=await import("../chunk-8cv1t8qg.js"),Q=[];for await(let N of V.stdin)Q.push(N);let K=Buffer.concat(Q).toString("utf-8");if(K.trim())V.stdout.write(q(K,"stdin.ts")),V.stdout.write(`
3
- `)}else if(f==="--project"){let{readdirSync:q,readFileSync:Q,writeFileSync:K,mkdirSync:N}=await import("fs"),A=typeof globalThis.Bun<"u",J=A?globalThis.Bun:null,$=V.argv.slice(3),z="",B="",G=!1;for(let X=0;X<$.length;X++)if($[X]==="--outdir"&&$[X+1])B=$[X+1],X++;else if($[X]==="--isolated-declarations")G=!0;else if(!z)z=$[X];N(B,{recursive:!0});let j=q(z).filter((X)=>X.endsWith(".ts")&&!X.endsWith(".d.ts")),Z=j.length,E=Array(Z),M=Array(Z);for(let X=0;X<Z;X++)E[X]=`${z}/${j[X]}`,M[X]=`${B}/${j[X].slice(0,-3)}.d.ts`;let T=["bun"],R=A&&Z>=64,I=!1,_=null;if(R){let X=null;try{let{createWorkerPool:F,calculateOptimalBatchSize:D}=await import("../chunk-3xqchdwd.js"),{cpus:C}=await import("os"),w=Math.max(1,C().length-1),U=Math.min(64,Math.max(8,D(Z,w)*2)),L=Z>=256,a=!0,l=Z>=256;if(!L&&Z>=256){_=Array(Z);for(let x=0;x<Z;x++)_[x]=J.file(E[x]).text()}let O=Math.ceil(Z/U),u=Math.min(O,Math.max(2,w*2));X=F({maxWorkers:w,initialWorkers:w,recycleAfter:Math.max(100,O+1)}),await X.init();let d=X,i=0,r=Date.now(),t=async()=>{for(;;){let x=i++;if(x>=O)return;let S=x*U;if(S>=Z)return;let g=Math.min(Z,S+U)-S,m;if(l){let P=Array(g),y=Array(g),b;if(L)for(let W=0;W<g;W++){let v=S+W;P[W]=E[v],y[W]=M[v]}else{let W=Array(g);for(let v=0;v<g;v++){let c=S+v;P[v]=E[c],y[v]=M[c],W[v]=_?_[c]:J.file(E[c]).text()}b=await Promise.all(W)}m=await d.submit({id:`batch-${r}-${x}`,type:"process-batch",filePath:P[0]||"",filePaths:P,sources:b,outPaths:y,writeOutput:!0,config:{keepComments:!0,importOrder:T,isolatedDeclarations:G}})}else{let P=Array(g);if(L)for(let y=0;y<g;y++){let b=S+y;P[y]={filePath:E[b],outPath:M[b]}}else{let y=Array(g);for(let W=0;W<g;W++){let v=S+W;y[W]=_?_[v]:J.file(E[v]).text()}let b=await Promise.all(y);for(let W=0;W<g;W++){let v=S+W;P[W]={filePath:E[v],sourceCode:b[W],outPath:M[v]}}}m=await d.submit({id:`batch-${r}-${x}`,type:"process-batch",filePath:E[S]||"",files:P,writeOutput:!0,config:{keepComments:!0,importOrder:T,isolatedDeclarations:G}})}if(!m.success)throw Error(m.error||`Worker batch failed for ${E[S]}`);if(m.batchResults?.length){let P=m.batchResults[0];throw Error(P?.error||m.error||`Worker failed for ${E[S]}`)}}},n=[];for(let x=0;x<u;x++)n.push(t());await Promise.all(n),I=!0}catch{I=!1}finally{if(X)await X.shutdown()}}if(!I){let{scanDeclarations:X}=await import("../chunk-bh9ey0vw.js"),{processDeclarations:F}=await import("../chunk-xmje6xfw.js"),D=Array(Z);if(A){let U=_?await Promise.all(_):await Promise.all(E.map((L)=>J.file(L).text()));for(let L=0;L<Z;L++)D[L]=U[L]}else for(let U=0;U<Z;U++)D[U]=Q(E[U],"utf-8");let C=Array(Z),w={filePath:"",sourceCode:"",declarations:[]};for(let U=0;U<Z;U++){let L=X(D[U],j[U],!0,G);w.filePath=j[U],w.sourceCode=D[U],w.declarations=L,C[U]=F(L,w,!0,T)}if(A){let U=Array(Z);for(let L=0;L<Z;L++)U[L]=J.write(M[L],C[L]);await Promise.all(U)}else for(let U=0;U<Z;U++)K(M[U],C[U])}}else{let{processSource:q}=await import("../chunk-8cv1t8qg.js"),{readFileSync:Q,writeFileSync:K,mkdirSync:N}=await import("fs"),A=typeof globalThis.Bun<"u",J=A?globalThis.Bun:null,$=V.argv[3],z=A?await J.file($).text():Q($,"utf-8"),B=V.argv[4];if(B){let{dirname:G}=await import("path");N(G(B),{recursive:!0});let j=`${q(z,$)}
2
+ import{dd as Y}from"../chunk-mcdb3q06.js";import V from"process";var f=V.argv[2];if(f==="stdin"||f==="emit"||f==="--project"){if(f==="stdin"){let{processSource:q}=await import("../chunk-w1k33gyv.js"),Q=[];for await(let N of V.stdin)Q.push(N);let K=Buffer.concat(Q).toString("utf-8");if(K.trim())V.stdout.write(q(K,"stdin.ts")),V.stdout.write(`
3
+ `)}else if(f==="--project"){let{readdirSync:q,readFileSync:Q,writeFileSync:K,mkdirSync:N}=await import("fs"),A=typeof globalThis.Bun<"u",J=A?globalThis.Bun:null,$=V.argv.slice(3),z="",B="",G=!1;for(let X=0;X<$.length;X++)if($[X]==="--outdir"&&$[X+1])B=$[X+1],X++;else if($[X]==="--isolated-declarations")G=!0;else if(!z)z=$[X];N(B,{recursive:!0});let j=q(z).filter((X)=>X.endsWith(".ts")&&!X.endsWith(".d.ts")),Z=j.length,E=Array(Z),M=Array(Z);for(let X=0;X<Z;X++)E[X]=`${z}/${j[X]}`,M[X]=`${B}/${j[X].slice(0,-3)}.d.ts`;let T=["bun"],R=A&&Z>=64,I=!1,_=null;if(R){let X=null;try{let{createWorkerPool:F,calculateOptimalBatchSize:D}=await import("../chunk-3xqchdwd.js"),{cpus:C}=await import("os"),w=Math.max(1,C().length-1),U=Math.min(64,Math.max(8,D(Z,w)*2)),L=Z>=256,a=!0,l=Z>=256;if(!L&&Z>=256){_=Array(Z);for(let x=0;x<Z;x++)_[x]=J.file(E[x]).text()}let O=Math.ceil(Z/U),u=Math.min(O,Math.max(2,w*2));X=F({maxWorkers:w,initialWorkers:w,recycleAfter:Math.max(100,O+1)}),await X.init();let d=X,i=0,r=Date.now(),t=async()=>{for(;;){let x=i++;if(x>=O)return;let S=x*U;if(S>=Z)return;let g=Math.min(Z,S+U)-S,m;if(l){let P=Array(g),y=Array(g),b;if(L)for(let W=0;W<g;W++){let v=S+W;P[W]=E[v],y[W]=M[v]}else{let W=Array(g);for(let v=0;v<g;v++){let c=S+v;P[v]=E[c],y[v]=M[c],W[v]=_?_[c]:J.file(E[c]).text()}b=await Promise.all(W)}m=await d.submit({id:`batch-${r}-${x}`,type:"process-batch",filePath:P[0]||"",filePaths:P,sources:b,outPaths:y,writeOutput:!0,config:{keepComments:!0,importOrder:T,isolatedDeclarations:G}})}else{let P=Array(g);if(L)for(let y=0;y<g;y++){let b=S+y;P[y]={filePath:E[b],outPath:M[b]}}else{let y=Array(g);for(let W=0;W<g;W++){let v=S+W;y[W]=_?_[v]:J.file(E[v]).text()}let b=await Promise.all(y);for(let W=0;W<g;W++){let v=S+W;P[W]={filePath:E[v],sourceCode:b[W],outPath:M[v]}}}m=await d.submit({id:`batch-${r}-${x}`,type:"process-batch",filePath:E[S]||"",files:P,writeOutput:!0,config:{keepComments:!0,importOrder:T,isolatedDeclarations:G}})}if(!m.success)throw Error(m.error||`Worker batch failed for ${E[S]}`);if(m.batchResults?.length){let P=m.batchResults[0];throw Error(P?.error||m.error||`Worker failed for ${E[S]}`)}}},n=[];for(let x=0;x<u;x++)n.push(t());await Promise.all(n),I=!0}catch{I=!1}finally{if(X)await X.shutdown()}}if(!I){let{scanDeclarations:X}=await import("../chunk-2n9mmg2c.js"),{processDeclarations:F}=await import("../chunk-fmhrt2ca.js"),D=Array(Z);if(A){let U=_?await Promise.all(_):await Promise.all(E.map((L)=>J.file(L).text()));for(let L=0;L<Z;L++)D[L]=U[L]}else for(let U=0;U<Z;U++)D[U]=Q(E[U],"utf-8");let C=Array(Z),w={filePath:"",sourceCode:"",declarations:[]};for(let U=0;U<Z;U++){let L=X(D[U],j[U],!0,G);w.filePath=j[U],w.sourceCode=D[U],w.declarations=L,C[U]=F(L,w,!0,T)}if(A){let U=Array(Z);for(let L=0;L<Z;L++)U[L]=J.write(M[L],C[L]);await Promise.all(U)}else for(let U=0;U<Z;U++)K(M[U],C[U])}}else{let{processSource:q}=await import("../chunk-w1k33gyv.js"),{readFileSync:Q,writeFileSync:K,mkdirSync:N}=await import("fs"),A=typeof globalThis.Bun<"u",J=A?globalThis.Bun:null,$=V.argv[3],z=A?await J.file($).text():Q($,"utf-8"),B=V.argv[4];if(B){let{dirname:G}=await import("path");N(G(B),{recursive:!0});let j=`${q(z,$)}
4
4
  `;if(A)await J.write(B,j);else K(B,j)}else V.stdout.write(q(z,$)),V.stdout.write(`
5
- `)}V.exit(0)}var{resolve:h}=await import("path"),{CLI:s}=await import("../chunk-trm0gptj.js"),{version:e}=await import("../chunk-yth8251f.js"),{getConfig:o}=await import("../chunk-w71syh0b.js"),{generate:qq,processSource:Hq,watch:Kq}=await import("../chunk-sdjfh4mj.js"),k=new s("dtsx"),H={cwd:V.cwd(),root:"./src",entrypoints:["**/*.ts"],outdir:"./dist",keepComments:!0,clean:!1,tsconfigPath:"tsconfig.json",verbose:!1,importOrder:["bun"],dryRun:!1,stats:!1,continueOnError:!1,logLevel:"info",exclude:[],outputFormat:"text",progress:!1,diff:!1,validate:!1,parallel:!1,concurrency:4};k.command("generate","Generate TypeScript declaration files").option("--cwd <path>","Current working directory",{default:H.cwd}).option("--root <path>","Root directory of the project",{default:H.root}).option("--entrypoints <files>","Entry point files (comma-separated)",{default:H.entrypoints?.join(","),type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:H.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:H.keepComments}).option("--clean","Clean output directory before generation",{default:H.clean}).option("--tsconfig <path>","Path to tsconfig.json",{default:H.tsconfigPath}).option("--verbose","Enable verbose logging",{default:H.verbose}).option("--import-order <patterns>","Import order priority patterns (comma-separated)",{default:H.importOrder?.join(","),type:[String]}).option("--dry-run","Show what would be generated without writing files",{default:H.dryRun}).option("--stats","Show statistics after generation",{default:H.stats}).option("--continue-on-error","Continue processing other files if one fails",{default:H.continueOnError}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:H.logLevel}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:H.exclude?.join(","),type:[String]}).option("--output-format <format>","Output format: text or json",{default:H.outputFormat}).option("--progress","Show progress during generation",{default:H.progress}).option("--diff","Show diff of changes compared to existing files",{default:H.diff}).option("--validate","Validate generated .d.ts files against TypeScript",{default:H.validate}).option("--parallel","Process files in parallel",{default:H.parallel}).option("--concurrency <number>","Number of concurrent workers (with --parallel)",{default:H.concurrency}).option("--declaration-map","Generate declaration map files (.d.ts.map)",{default:!1}).option("--bundle","Bundle all declarations into a single output file",{default:!1}).option("--bundle-output <file>","Output filename when bundling (relative to outdir)",{default:"index.d.ts"}).option("--config <path>","Path to config file (dtsx.config.ts)",{default:""}).option("--incremental","Enable incremental builds (only regenerate changed files)",{default:!1}).option("--clear-cache","Clear the incremental build cache before generating",{default:!1}).option("--indent-style <style>","Indentation style: spaces or tabs",{default:"spaces"}).option("--indent-size <size>","Number of spaces for indentation",{default:2}).option("--prettier","Use Prettier for output formatting if available",{default:!1}).example("dtsx generate").example("dtsx generate --entrypoints src/index.ts,src/utils.ts --outdir dist/types").example('dtsx generate --import-order "node:,bun,@myorg/"').example("dtsx generate --dry-run --stats").example('dtsx generate --exclude "**/*.test.ts,**/__tests__/**"').example("dtsx generate --stats --output-format json").example("dtsx generate --bundle --bundle-output types.d.ts").action(async(q)=>{try{let Q=h(q.cwd||H.cwd),K=await o(Q),N={entrypoints:q.entrypoints?q.entrypoints:K.entrypoints||H.entrypoints,cwd:Q,root:h(q.root||K.root||H.root),outdir:h(q.outdir||K.outdir||H.outdir),tsconfigPath:h(q.tsconfigPath||K.tsconfigPath||H.tsconfigPath),keepComments:q.keepComments??K.keepComments??H.keepComments,clean:q.clean??K.clean??H.clean,verbose:q.verbose??K.verbose??H.verbose,importOrder:q.importOrder||K.importOrder||H.importOrder,dryRun:q.dryRun??K.dryRun??H.dryRun,stats:q.stats??K.stats??H.stats,continueOnError:q.continueOnError??K.continueOnError??H.continueOnError,logLevel:q.logLevel??K.logLevel??H.logLevel,exclude:q.exclude?q.exclude.flatMap((J)=>J.split(",").map(($)=>$.trim()).filter(Boolean)):K.exclude||H.exclude,outputFormat:q.outputFormat??K.outputFormat??H.outputFormat,progress:q.progress??K.progress??H.progress,diff:q.diff??K.diff??H.diff,validate:q.validate??K.validate??H.validate,parallel:q.parallel??K.parallel??H.parallel,concurrency:Number(q.concurrency)||K.concurrency||H.concurrency,declarationMap:q.declarationMap??K.declarationMap??!1,bundle:q.bundle??K.bundle??!1,bundleOutput:q.bundleOutput??K.bundleOutput??"index.d.ts",incremental:q.incremental??K.incremental??!1,clearCache:q.clearCache??!1,indentStyle:q.indentStyle??K.indentStyle??"spaces",indentSize:Number(q.indentSize)||K.indentSize||2,prettier:q.prettier??K.prettier??!1,plugins:K.plugins},A=await qq(N);if(A.filesFailed>0&&A.filesGenerated===0)V.exit(1);else if(A.filesFailed>0)V.exit(2)}catch(Q){console.error("Error generating .d.ts files:",Q),V.exit(1)}});k.command("watch","Watch for changes and regenerate .d.ts files").option("--cwd <path>","Current working directory",{default:H.cwd}).option("--root <path>","Root directory of the project",{default:H.root}).option("--entrypoints <files>","Entry point files (comma-separated)",{default:H.entrypoints?.join(","),type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:H.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:H.keepComments}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:H.exclude?.join(","),type:[String]}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:H.logLevel}).example("dtsx watch").example("dtsx watch --root src --outdir dist/types").action(async(q)=>{try{let Q={entrypoints:q.entrypoints?q.entrypoints:H.entrypoints,cwd:h(q.cwd||H.cwd),root:h(q.root||H.root),outdir:h(q.outdir||H.outdir),keepComments:q.keepComments??H.keepComments,exclude:q.exclude?q.exclude.flatMap((K)=>K.split(",").map((N)=>N.trim()).filter(Boolean)):H.exclude,logLevel:q.logLevel??H.logLevel};await Kq(Q)}catch(Q){console.error("Error in watch mode:",Q),V.exit(1)}});k.command("stdin","Process TypeScript from stdin and output .d.ts to stdout").option("--keep-comments","Keep comments in generated .d.ts files",{default:!0}).option("--import-order <patterns>","Import order priority patterns (comma-separated)",{default:"bun",type:[String]}).example(`echo "export const foo: string = 'bar'" | dtsx stdin`).example("cat src/index.ts | dtsx stdin").action(async(q)=>{try{let Q=[];for await(let J of V.stdin)Q.push(J);let K=Buffer.concat(Q).toString("utf-8");if(!K.trim())console.error("Error: No input received from stdin"),V.exit(1);let N=["bun"];if(q.importOrder){if(Array.isArray(q.importOrder))N=q.importOrder.flatMap((J)=>J.split(",").map(($)=>$.trim()).filter(Boolean));else if(typeof q.importOrder==="string")N=q.importOrder.split(",").map((J)=>J.trim()).filter(Boolean)}let A=Hq(K,"stdin.ts",q.keepComments??!0,N);console.log(A)}catch(Q){console.error("Error processing stdin:",Q),V.exit(1)}});k.command("optimize","Optimize declaration files").option("--files <patterns>","Glob patterns for .d.ts files to optimize",{default:"**/*.d.ts",type:[String]}).option("--outdir <path>","Output directory (defaults to in-place)",{default:""}).option("--remove-unused-imports","Remove unused type imports",{default:!0}).option("--deduplicate","Remove duplicate declarations",{default:!0}).option("--merge-interfaces","Merge interface declarations with same name",{default:!0}).option("--inline-types","Inline simple type aliases",{default:!1}).option("--remove-empty","Remove empty interfaces",{default:!0}).option("--sort","Sort declarations alphabetically",{default:!1}).option("--sort-imports","Sort imports",{default:!0}).option("--minify","Minify output (remove whitespace)",{default:!1}).option("--remove-comments","Remove comments",{default:!1}).example('dtsx optimize --files "dist/**/*.d.ts"').example("dtsx optimize --minify --remove-comments").action(async(q)=>{try{let{optimizeFile:Q}=await import("../chunk-w8d9jjsa.js"),{Glob:K}=awaitPromise.resolve(globalThis.Bun),{resolve:N,join:A,relative:J,dirname:$,basename:z}=await import("path"),{mkdirSync:B,copyFileSync:G,existsSync:j}=await import("fs"),Z=V.cwd(),E=q.files||["**/*.d.ts"],M=[];for(let _ of E){let X=new K(_);for await(let F of X.scan({cwd:Z,absolute:!0,onlyFiles:!0}))if(F.endsWith(".d.ts")&&!F.includes("node_modules"))M.push(F)}if(M.length===0)console.error("No .d.ts files found"),V.exit(1);console.log(`Optimizing ${M.length} declaration files...`);let T=0,R=0;for(let _ of M){let X=_;if(q.outdir){let C=J(Z,_);X=A(N(q.outdir),C);let w=$(X);if(!j(w))B(w,{recursive:!0});G(_,X)}let F=await Q(X,{removeUnusedImports:q.removeUnusedImports??!0,deduplicateDeclarations:q.deduplicate??!0,mergeInterfaces:q.mergeInterfaces??!0,inlineSimpleTypes:q.inlineTypes??!1,removeEmptyInterfaces:q.removeEmpty??!0,sortDeclarations:q.sort??!1,sortImports:q.sortImports??!0,minify:q.minify??!1,removeComments:q.removeComments??!1});R+=F.originalSize,T+=F.savings;let D=J(Z,X);console.log(` ${D}: ${F.originalSize}B -> ${F.optimizedSize}B (-${F.savingsPercent}%)`)}let I=R>0?Math.round(T/R*100):0;console.log(`
6
- Total: ${R}B -> ${R-T}B (-${I}%)`)}catch(Q){console.error("Error optimizing files:",Q),V.exit(1)}});k.command("docs","Generate API documentation from source files").option("--root <path>","Root directory to scan for source files",{default:"./src"}).option("--outdir <path>","Output directory for documentation",{default:"./docs"}).option("--format <format>","Output format: markdown or html",{default:"markdown"}).option("--title <title>","Documentation title",{default:"API Documentation"}).option("--include-private","Include private members (prefixed with _)",{default:!1}).option("--include-internal","Include internal members (@internal)",{default:!1}).option("--group-by-category","Group entries by @category tag",{default:!1}).option("--source-url <url>","Base URL for source links").example("dtsx docs").example("dtsx docs --format html --outdir ./api-docs").example('dtsx docs --group-by-category --title "My API"').action(async(q)=>{try{let{generateDocs:Q}=await import("../chunk-bsxtpwx6.js"),{Glob:K}=awaitPromise.resolve(globalThis.Bun),{resolve:N}=await import("path"),A=N(q.root||"./src"),J=new K("**/*.ts"),$=[];for await(let z of J.scan({cwd:A,absolute:!0,onlyFiles:!0}))if(!z.endsWith(".d.ts")&&!z.includes("node_modules"))$.push(z);if($.length===0)console.error("No TypeScript files found"),V.exit(1);console.log(`Found ${$.length} source files`),await Q($,{format:q.format||"markdown",outdir:N(q.outdir||"./docs"),title:q.title||"API Documentation",includePrivate:q.includePrivate??!1,includeInternal:q.includeInternal??!1,groupByCategory:q.groupByCategory??!1,includeSourceLinks:!!q.sourceUrl,sourceBaseUrl:q.sourceUrl})}catch(Q){console.error("Error generating documentation:",Q),V.exit(1)}});k.command("workspace","Generate declarations for all projects in a monorepo/workspace").option("--cwd <path>","Workspace root directory",{default:V.cwd()}).option("--parallel","Process projects in parallel",{default:!1}).option("--continue-on-error","Continue if a project fails",{default:!0}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:"info"}).example("dtsx workspace").example("dtsx workspace --cwd /path/to/monorepo").action(async(q)=>{try{let{generateMonorepo:Q,generateFromPackageWorkspaces:K}=await import("../chunk-3rpqh1bm.js"),{existsSync:N}=await import("fs"),{join:A,resolve:J}=await import("path"),$=J(q.cwd||V.cwd()),z=A($,"tsconfig.json"),B;if(N(z))B=await Q($,{logLevel:q.logLevel||"info",continueOnError:q.continueOnError??!0});else B=await K($,{logLevel:q.logLevel||"info",continueOnError:q.continueOnError??!0});if(!B.success)V.exit(1)}catch(Q){console.error("Error generating workspace declarations:",Q),V.exit(1)}});k.command("lsp","Start the Language Server Protocol server for IDE integration").example("dtsx lsp").action(async()=>{let{startLSPServer:q}=await import("../chunk-pep9jyxn.js");q()});k.command("check","Type check TypeScript files or validate generated declarations").option("--files <patterns>","Glob patterns for files to check",{default:"**/*.ts",type:[String]}).option("--declarations-only","Only check .d.ts files",{default:!1}).option("--tsconfig <path>","Path to tsconfig.json",{default:"tsconfig.json"}).option("--strict","Enable strict type checking",{default:!1}).option("--skip-lib-check","Skip checking library definitions",{default:!0}).option("--warnings-as-errors","Treat warnings as errors",{default:!1}).option("--max-errors <number>","Maximum errors before stopping",{default:0}).option("--isolated-declarations","Check if code follows isolated declarations best practices (recommended)",{default:!1}).option("--format <format>","Output format: text or json",{default:"text"}).example("dtsx check").example('dtsx check --files "src/**/*.ts" --strict').example('dtsx check --declarations-only --files "dist/**/*.d.ts"').example("dtsx check --isolated-declarations").action(async(q)=>{try{let{typeCheck:Q,checkIsolatedDeclarations:K,formatTypeCheckResults:N}=await import("../chunk-sw3m29sw.js"),{Glob:A}=awaitPromise.resolve(globalThis.Bun),{resolve:J,relative:$}=await import("path"),z=V.cwd(),B=q.files||["**/*.ts"],G=[];for(let Z of B){let E=new A(Z);for await(let M of E.scan({cwd:z,absolute:!0,onlyFiles:!0}))if(!M.includes("node_modules"))if(q.declarationsOnly){if(M.endsWith(".d.ts"))G.push(M)}else G.push(M)}if(G.length===0)console.error("No files found to check"),V.exit(1);if(q.isolatedDeclarations){console.log(`Checking ${G.length} files for isolated declarations best practices...`);let Z=await K(G,q.tsconfig?J(q.tsconfig):void 0),E=0,M=[];for(let[T,R]of Z){let I=$(z,T);if(!R.compatible)if(E+=R.issues.length,q.format==="json")M.push({file:I,compatible:!1,issues:R.issues});else{console.log(`
5
+ `)}V.exit(0)}var{resolve:h}=await import("path"),{CLI:s}=await import("../chunk-trm0gptj.js"),{version:e}=await import("../chunk-sbmecr6t.js"),{getConfig:o}=await import("../chunk-w71syh0b.js"),{generate:qq,processSource:Hq,watch:Kq}=await import("../chunk-7g7axw9t.js"),k=new s("dtsx"),H={cwd:V.cwd(),root:"./src",entrypoints:["**/*.ts"],outdir:"./dist",keepComments:!0,clean:!1,tsconfigPath:"tsconfig.json",verbose:!1,importOrder:["bun"],dryRun:!1,stats:!1,continueOnError:!1,logLevel:"info",exclude:[],outputFormat:"text",progress:!1,diff:!1,validate:!1,parallel:!1,concurrency:4};k.command("generate","Generate TypeScript declaration files").option("--cwd <path>","Current working directory",{default:H.cwd}).option("--root <path>","Root directory of the project",{default:H.root}).option("--entrypoints <files>","Entry point files (comma-separated)",{default:H.entrypoints?.join(","),type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:H.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:H.keepComments}).option("--clean","Clean output directory before generation",{default:H.clean}).option("--tsconfig <path>","Path to tsconfig.json",{default:H.tsconfigPath}).option("--verbose","Enable verbose logging",{default:H.verbose}).option("--import-order <patterns>","Import order priority patterns (comma-separated)",{default:H.importOrder?.join(","),type:[String]}).option("--dry-run","Show what would be generated without writing files",{default:H.dryRun}).option("--stats","Show statistics after generation",{default:H.stats}).option("--continue-on-error","Continue processing other files if one fails",{default:H.continueOnError}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:H.logLevel}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:H.exclude?.join(","),type:[String]}).option("--output-format <format>","Output format: text or json",{default:H.outputFormat}).option("--progress","Show progress during generation",{default:H.progress}).option("--diff","Show diff of changes compared to existing files",{default:H.diff}).option("--validate","Validate generated .d.ts files against TypeScript",{default:H.validate}).option("--parallel","Process files in parallel",{default:H.parallel}).option("--concurrency <number>","Number of concurrent workers (with --parallel)",{default:H.concurrency}).option("--declaration-map","Generate declaration map files (.d.ts.map)",{default:!1}).option("--bundle","Bundle all declarations into a single output file",{default:!1}).option("--bundle-output <file>","Output filename when bundling (relative to outdir)",{default:"index.d.ts"}).option("--config <path>","Path to config file (dtsx.config.ts)",{default:""}).option("--incremental","Enable incremental builds (only regenerate changed files)",{default:!1}).option("--clear-cache","Clear the incremental build cache before generating",{default:!1}).option("--indent-style <style>","Indentation style: spaces or tabs",{default:"spaces"}).option("--indent-size <size>","Number of spaces for indentation",{default:2}).option("--prettier","Use Prettier for output formatting if available",{default:!1}).example("dtsx generate").example("dtsx generate --entrypoints src/index.ts,src/utils.ts --outdir dist/types").example('dtsx generate --import-order "node:,bun,@myorg/"').example("dtsx generate --dry-run --stats").example('dtsx generate --exclude "**/*.test.ts,**/__tests__/**"').example("dtsx generate --stats --output-format json").example("dtsx generate --bundle --bundle-output types.d.ts").action(async(q)=>{try{let Q=h(q.cwd||H.cwd),K=await o(Q),N={entrypoints:q.entrypoints?q.entrypoints:K.entrypoints||H.entrypoints,cwd:Q,root:h(q.root||K.root||H.root),outdir:h(q.outdir||K.outdir||H.outdir),tsconfigPath:h(q.tsconfigPath||K.tsconfigPath||H.tsconfigPath),keepComments:q.keepComments??K.keepComments??H.keepComments,clean:q.clean??K.clean??H.clean,verbose:q.verbose??K.verbose??H.verbose,importOrder:q.importOrder||K.importOrder||H.importOrder,dryRun:q.dryRun??K.dryRun??H.dryRun,stats:q.stats??K.stats??H.stats,continueOnError:q.continueOnError??K.continueOnError??H.continueOnError,logLevel:q.logLevel??K.logLevel??H.logLevel,exclude:q.exclude?q.exclude.flatMap((J)=>J.split(",").map(($)=>$.trim()).filter(Boolean)):K.exclude||H.exclude,outputFormat:q.outputFormat??K.outputFormat??H.outputFormat,progress:q.progress??K.progress??H.progress,diff:q.diff??K.diff??H.diff,validate:q.validate??K.validate??H.validate,parallel:q.parallel??K.parallel??H.parallel,concurrency:Number(q.concurrency)||K.concurrency||H.concurrency,declarationMap:q.declarationMap??K.declarationMap??!1,bundle:q.bundle??K.bundle??!1,bundleOutput:q.bundleOutput??K.bundleOutput??"index.d.ts",incremental:q.incremental??K.incremental??!1,clearCache:q.clearCache??!1,indentStyle:q.indentStyle??K.indentStyle??"spaces",indentSize:Number(q.indentSize)||K.indentSize||2,prettier:q.prettier??K.prettier??!1,plugins:K.plugins},A=await qq(N);if(A.filesFailed>0&&A.filesGenerated===0)V.exit(1);else if(A.filesFailed>0)V.exit(2)}catch(Q){console.error("Error generating .d.ts files:",Q),V.exit(1)}});k.command("watch","Watch for changes and regenerate .d.ts files").option("--cwd <path>","Current working directory",{default:H.cwd}).option("--root <path>","Root directory of the project",{default:H.root}).option("--entrypoints <files>","Entry point files (comma-separated)",{default:H.entrypoints?.join(","),type:[String]}).option("--outdir <path>","Output directory for generated .d.ts files",{default:H.outdir}).option("--keep-comments","Keep comments in generated .d.ts files",{default:H.keepComments}).option("--exclude <patterns>","Glob patterns to exclude (comma-separated)",{default:H.exclude?.join(","),type:[String]}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:H.logLevel}).example("dtsx watch").example("dtsx watch --root src --outdir dist/types").action(async(q)=>{try{let Q={entrypoints:q.entrypoints?q.entrypoints:H.entrypoints,cwd:h(q.cwd||H.cwd),root:h(q.root||H.root),outdir:h(q.outdir||H.outdir),keepComments:q.keepComments??H.keepComments,exclude:q.exclude?q.exclude.flatMap((K)=>K.split(",").map((N)=>N.trim()).filter(Boolean)):H.exclude,logLevel:q.logLevel??H.logLevel};await Kq(Q)}catch(Q){console.error("Error in watch mode:",Q),V.exit(1)}});k.command("stdin","Process TypeScript from stdin and output .d.ts to stdout").option("--keep-comments","Keep comments in generated .d.ts files",{default:!0}).option("--import-order <patterns>","Import order priority patterns (comma-separated)",{default:"bun",type:[String]}).example(`echo "export const foo: string = 'bar'" | dtsx stdin`).example("cat src/index.ts | dtsx stdin").action(async(q)=>{try{let Q=[];for await(let J of V.stdin)Q.push(J);let K=Buffer.concat(Q).toString("utf-8");if(!K.trim())console.error("Error: No input received from stdin"),V.exit(1);let N=["bun"];if(q.importOrder){if(Array.isArray(q.importOrder))N=q.importOrder.flatMap((J)=>J.split(",").map(($)=>$.trim()).filter(Boolean));else if(typeof q.importOrder==="string")N=q.importOrder.split(",").map((J)=>J.trim()).filter(Boolean)}let A=Hq(K,"stdin.ts",q.keepComments??!0,N);console.log(A)}catch(Q){console.error("Error processing stdin:",Q),V.exit(1)}});k.command("optimize","Optimize declaration files").option("--files <patterns>","Glob patterns for .d.ts files to optimize",{default:"**/*.d.ts",type:[String]}).option("--outdir <path>","Output directory (defaults to in-place)",{default:""}).option("--remove-unused-imports","Remove unused type imports",{default:!0}).option("--deduplicate","Remove duplicate declarations",{default:!0}).option("--merge-interfaces","Merge interface declarations with same name",{default:!0}).option("--inline-types","Inline simple type aliases",{default:!1}).option("--remove-empty","Remove empty interfaces",{default:!0}).option("--sort","Sort declarations alphabetically",{default:!1}).option("--sort-imports","Sort imports",{default:!0}).option("--minify","Minify output (remove whitespace)",{default:!1}).option("--remove-comments","Remove comments",{default:!1}).example('dtsx optimize --files "dist/**/*.d.ts"').example("dtsx optimize --minify --remove-comments").action(async(q)=>{try{let{optimizeFile:Q}=await import("../chunk-q0k7xs9f.js"),{Glob:K}=awaitPromise.resolve(globalThis.Bun),{resolve:N,join:A,relative:J,dirname:$,basename:z}=await import("path"),{mkdirSync:B,copyFileSync:G,existsSync:j}=await import("fs"),Z=V.cwd(),E=q.files||["**/*.d.ts"],M=[];for(let _ of E){let X=new K(_);for await(let F of X.scan({cwd:Z,absolute:!0,onlyFiles:!0}))if(F.endsWith(".d.ts")&&!F.includes("node_modules"))M.push(F)}if(M.length===0)console.error("No .d.ts files found"),V.exit(1);console.log(`Optimizing ${M.length} declaration files...`);let T=0,R=0;for(let _ of M){let X=_;if(q.outdir){let C=J(Z,_);X=A(N(q.outdir),C);let w=$(X);if(!j(w))B(w,{recursive:!0});G(_,X)}let F=await Q(X,{removeUnusedImports:q.removeUnusedImports??!0,deduplicateDeclarations:q.deduplicate??!0,mergeInterfaces:q.mergeInterfaces??!0,inlineSimpleTypes:q.inlineTypes??!1,removeEmptyInterfaces:q.removeEmpty??!0,sortDeclarations:q.sort??!1,sortImports:q.sortImports??!0,minify:q.minify??!1,removeComments:q.removeComments??!1});R+=F.originalSize,T+=F.savings;let D=J(Z,X);console.log(` ${D}: ${F.originalSize}B -> ${F.optimizedSize}B (-${F.savingsPercent}%)`)}let I=R>0?Math.round(T/R*100):0;console.log(`
6
+ Total: ${R}B -> ${R-T}B (-${I}%)`)}catch(Q){console.error("Error optimizing files:",Q),V.exit(1)}});k.command("docs","Generate API documentation from source files").option("--root <path>","Root directory to scan for source files",{default:"./src"}).option("--outdir <path>","Output directory for documentation",{default:"./docs"}).option("--format <format>","Output format: markdown or html",{default:"markdown"}).option("--title <title>","Documentation title",{default:"API Documentation"}).option("--include-private","Include private members (prefixed with _)",{default:!1}).option("--include-internal","Include internal members (@internal)",{default:!1}).option("--group-by-category","Group entries by @category tag",{default:!1}).option("--source-url <url>","Base URL for source links").example("dtsx docs").example("dtsx docs --format html --outdir ./api-docs").example('dtsx docs --group-by-category --title "My API"').action(async(q)=>{try{let{generateDocs:Q}=await import("../chunk-2qyt67jt.js"),{Glob:K}=awaitPromise.resolve(globalThis.Bun),{resolve:N}=await import("path"),A=N(q.root||"./src"),J=new K("**/*.ts"),$=[];for await(let z of J.scan({cwd:A,absolute:!0,onlyFiles:!0}))if(!z.endsWith(".d.ts")&&!z.includes("node_modules"))$.push(z);if($.length===0)console.error("No TypeScript files found"),V.exit(1);console.log(`Found ${$.length} source files`),await Q($,{format:q.format||"markdown",outdir:N(q.outdir||"./docs"),title:q.title||"API Documentation",includePrivate:q.includePrivate??!1,includeInternal:q.includeInternal??!1,groupByCategory:q.groupByCategory??!1,includeSourceLinks:!!q.sourceUrl,sourceBaseUrl:q.sourceUrl})}catch(Q){console.error("Error generating documentation:",Q),V.exit(1)}});k.command("workspace","Generate declarations for all projects in a monorepo/workspace").option("--cwd <path>","Workspace root directory",{default:V.cwd()}).option("--parallel","Process projects in parallel",{default:!1}).option("--continue-on-error","Continue if a project fails",{default:!0}).option("--log-level <level>","Log level (debug, info, warn, error, silent)",{default:"info"}).example("dtsx workspace").example("dtsx workspace --cwd /path/to/monorepo").action(async(q)=>{try{let{generateMonorepo:Q,generateFromPackageWorkspaces:K}=await import("../chunk-9qe2wx58.js"),{existsSync:N}=await import("fs"),{join:A,resolve:J}=await import("path"),$=J(q.cwd||V.cwd()),z=A($,"tsconfig.json"),B;if(N(z))B=await Q($,{logLevel:q.logLevel||"info",continueOnError:q.continueOnError??!0});else B=await K($,{logLevel:q.logLevel||"info",continueOnError:q.continueOnError??!0});if(!B.success)V.exit(1)}catch(Q){console.error("Error generating workspace declarations:",Q),V.exit(1)}});k.command("lsp","Start the Language Server Protocol server for IDE integration").example("dtsx lsp").action(async()=>{let{startLSPServer:q}=await import("../chunk-x4jgc4bx.js");q()});k.command("check","Type check TypeScript files or validate generated declarations").option("--files <patterns>","Glob patterns for files to check",{default:"**/*.ts",type:[String]}).option("--declarations-only","Only check .d.ts files",{default:!1}).option("--tsconfig <path>","Path to tsconfig.json",{default:"tsconfig.json"}).option("--strict","Enable strict type checking",{default:!1}).option("--skip-lib-check","Skip checking library definitions",{default:!0}).option("--warnings-as-errors","Treat warnings as errors",{default:!1}).option("--max-errors <number>","Maximum errors before stopping",{default:0}).option("--isolated-declarations","Check if code follows isolated declarations best practices (recommended)",{default:!1}).option("--format <format>","Output format: text or json",{default:"text"}).example("dtsx check").example('dtsx check --files "src/**/*.ts" --strict').example('dtsx check --declarations-only --files "dist/**/*.d.ts"').example("dtsx check --isolated-declarations").action(async(q)=>{try{let{typeCheck:Q,checkIsolatedDeclarations:K,formatTypeCheckResults:N}=await import("../chunk-sw3m29sw.js"),{Glob:A}=awaitPromise.resolve(globalThis.Bun),{resolve:J,relative:$}=await import("path"),z=V.cwd(),B=q.files||["**/*.ts"],G=[];for(let Z of B){let E=new A(Z);for await(let M of E.scan({cwd:z,absolute:!0,onlyFiles:!0}))if(!M.includes("node_modules"))if(q.declarationsOnly){if(M.endsWith(".d.ts"))G.push(M)}else G.push(M)}if(G.length===0)console.error("No files found to check"),V.exit(1);if(q.isolatedDeclarations){console.log(`Checking ${G.length} files for isolated declarations best practices...`);let Z=await K(G,q.tsconfig?J(q.tsconfig):void 0),E=0,M=[];for(let[T,R]of Z){let I=$(z,T);if(!R.compatible)if(E+=R.issues.length,q.format==="json")M.push({file:I,compatible:!1,issues:R.issues});else{console.log(`
7
7
  \u2717 ${I}`);for(let _ of R.issues)if(console.log(` ${_.line}:${_.column} - ${_.message}`),_.missingAnnotation)console.log(` Missing: ${_.missingAnnotation} type annotation`)}else if(q.format==="json")M.push({file:I,compatible:!0,issues:[]})}if(q.format==="json")console.log(JSON.stringify(M,null,2));else if(E>0)console.log(`
8
8
  ${G.length} files checked, ${E} recommendations found`),console.log("Tip: Adding explicit type annotations improves .d.ts accuracy");else console.log(`
9
- ${G.length} files checked, all follow isolated declarations best practices`);V.exit(E>0?1:0)}console.log(`Type checking ${G.length} files...`);let j=await Q(G,{tsconfigPath:q.tsconfig?J(q.tsconfig):void 0,strict:q.strict??!1,declarationsOnly:q.declarationsOnly??!1,skipLibCheck:q.skipLibCheck??!0,warningsAsErrors:q.warningsAsErrors??!1,maxErrors:q.maxErrors||void 0});if(q.format==="json")console.log(JSON.stringify(j,null,2));else console.log(N(j));V.exit(j.success?0:1)}catch(Q){console.error("Error during type checking:",Q),V.exit(1)}});k.command("convert","Convert TypeScript types to different schema formats").option("--files <patterns>","Glob patterns for TypeScript files",{default:"**/*.ts",type:[String]}).option("--format <format>","Output format: json-schema, zod, valibot, io-ts, yup, arktype",{default:"json-schema"}).option("--outdir <path>","Output directory for converted files",{default:"./schemas"}).option("--include-descriptions","Include JSDoc descriptions in output",{default:!0}).option("--all-optional","Make all properties optional",{default:!1}).option("--use-infer","Include inferred types (for Zod, Valibot, etc.)",{default:!0}).option("--json-schema-draft <version>","JSON Schema draft version: 2020-12, 2019-09, draft-07",{default:"2020-12"}).example("dtsx convert --format zod").example('dtsx convert --format json-schema --files "src/types/**/*.ts"').example("dtsx convert --format valibot --outdir ./validation").action(async(q)=>{try{let Q=await import("../chunk-xtee8g1a.js"),{extractDeclarations:K}=await import("../chunk-3zjt21t1.js"),{Glob:N}=awaitPromise.resolve(globalThis.Bun),{resolve:A,relative:J,join:$,dirname:z,basename:B}=await import("path"),{mkdirSync:G,existsSync:j,readFileSync:Z,writeFileSync:E}=await import("fs"),M=V.cwd(),T=q.files||["**/*.ts"],R=q.format||"json-schema",I=A(q.outdir||"./schemas"),_=[];for(let D of T){let C=new N(D);for await(let w of C.scan({cwd:M,absolute:!0,onlyFiles:!0}))if(!w.endsWith(".d.ts")&&!w.includes("node_modules"))_.push(w)}if(_.length===0)console.error("No TypeScript files found"),V.exit(1);if(console.log(`Converting ${_.length} files to ${R} format...`),!j(I))G(I,{recursive:!0});let X=0,F=0;for(let D of _){let C=Z(D,"utf-8"),U=K(C,D).filter((d)=>d.kind==="interface"||d.kind==="type");if(U.length===0)continue;let L=Q.convertToFormat(U,{format:R,includeDescriptions:q.includeDescriptions??!0,allOptional:q.allOptional??!1,useInfer:q.useInfer??!0,jsonSchemaDraft:q.jsonSchemaDraft||"2020-12"}),a=J(M,D),l=B(D,".ts"),p=Q.getFormatExtension(R),O=$(I,z(a),`${l}${p}`),u=z(O);if(!j(u))G(u,{recursive:!0});E(O,L),X+=U.length,F++,console.log(` ${J(M,O)} (${U.length} types)`)}console.log(`
9
+ ${G.length} files checked, all follow isolated declarations best practices`);V.exit(E>0?1:0)}console.log(`Type checking ${G.length} files...`);let j=await Q(G,{tsconfigPath:q.tsconfig?J(q.tsconfig):void 0,strict:q.strict??!1,declarationsOnly:q.declarationsOnly??!1,skipLibCheck:q.skipLibCheck??!0,warningsAsErrors:q.warningsAsErrors??!1,maxErrors:q.maxErrors||void 0});if(q.format==="json")console.log(JSON.stringify(j,null,2));else console.log(N(j));V.exit(j.success?0:1)}catch(Q){console.error("Error during type checking:",Q),V.exit(1)}});k.command("convert","Convert TypeScript types to different schema formats").option("--files <patterns>","Glob patterns for TypeScript files",{default:"**/*.ts",type:[String]}).option("--format <format>","Output format: json-schema, zod, valibot, io-ts, yup, arktype",{default:"json-schema"}).option("--outdir <path>","Output directory for converted files",{default:"./schemas"}).option("--include-descriptions","Include JSDoc descriptions in output",{default:!0}).option("--all-optional","Make all properties optional",{default:!1}).option("--use-infer","Include inferred types (for Zod, Valibot, etc.)",{default:!0}).option("--json-schema-draft <version>","JSON Schema draft version: 2020-12, 2019-09, draft-07",{default:"2020-12"}).example("dtsx convert --format zod").example('dtsx convert --format json-schema --files "src/types/**/*.ts"').example("dtsx convert --format valibot --outdir ./validation").action(async(q)=>{try{let Q=await import("../chunk-xtee8g1a.js"),{extractDeclarations:K}=await import("../chunk-fbradttj.js"),{Glob:N}=awaitPromise.resolve(globalThis.Bun),{resolve:A,relative:J,join:$,dirname:z,basename:B}=await import("path"),{mkdirSync:G,existsSync:j,readFileSync:Z,writeFileSync:E}=await import("fs"),M=V.cwd(),T=q.files||["**/*.ts"],R=q.format||"json-schema",I=A(q.outdir||"./schemas"),_=[];for(let D of T){let C=new N(D);for await(let w of C.scan({cwd:M,absolute:!0,onlyFiles:!0}))if(!w.endsWith(".d.ts")&&!w.includes("node_modules"))_.push(w)}if(_.length===0)console.error("No TypeScript files found"),V.exit(1);if(console.log(`Converting ${_.length} files to ${R} format...`),!j(I))G(I,{recursive:!0});let X=0,F=0;for(let D of _){let C=Z(D,"utf-8"),U=K(C,D).filter((d)=>d.kind==="interface"||d.kind==="type");if(U.length===0)continue;let L=Q.convertToFormat(U,{format:R,includeDescriptions:q.includeDescriptions??!0,allOptional:q.allOptional??!1,useInfer:q.useInfer??!0,jsonSchemaDraft:q.jsonSchemaDraft||"2020-12"}),a=J(M,D),l=B(D,".ts"),p=Q.getFormatExtension(R),O=$(I,z(a),`${l}${p}`),u=z(O);if(!j(u))G(u,{recursive:!0});E(O,L),X+=U.length,F++,console.log(` ${J(M,O)} (${U.length} types)`)}console.log(`
10
10
  Converted ${X} declarations from ${F} files`)}catch(Q){console.error("Error converting files:",Q),V.exit(1)}});k.command("circular","Detect circular dependencies in TypeScript files").option("--files <patterns>","Glob patterns for files to check",{default:"**/*.ts",type:[String]}).option("--root <path>","Root directory for resolution",{default:"."}).option("--ignore <patterns>","Glob patterns to ignore (comma-separated)",{default:"",type:[String]}).option("--types-only","Only report type-level cycles",{default:!1}).option("--max-depth <number>","Maximum depth for cycle detection",{default:100}).option("--include-node-modules","Include node_modules in analysis",{default:!1}).option("--format <format>","Output format: text, json, dot",{default:"text"}).option("--summary","Show graph summary statistics",{default:!1}).example("dtsx circular").example('dtsx circular --files "src/**/*.ts"').example('dtsx circular --ignore "**/*.test.ts,**/__tests__/**"').example("dtsx circular --format dot > deps.dot").example("dtsx circular --summary").action(async(q)=>{try{let{analyzeCircularDependencies:Q,formatCircularAnalysis:K,getGraphSummary:N,exportGraphAsDot:A,exportGraphAsJson:J}=await import("../chunk-tne5n3h1.js"),{Glob:$}=awaitPromise.resolve(globalThis.Bun),{resolve:z,relative:B}=await import("path"),G=V.cwd(),j=z(q.root||"."),Z=q.files||["**/*.ts"],E=[];for(let T of Z){let R=new $(T);for await(let I of R.scan({cwd:j,absolute:!0,onlyFiles:!0}))if(!I.endsWith(".d.ts")){if(!q.includeNodeModules&&I.includes("node_modules"))continue;E.push(I)}}if(E.length===0)console.error("No TypeScript files found"),V.exit(1);console.log(`Analyzing ${E.length} files for circular dependencies...`);let M=await Q(E,{rootDir:j,ignore:q.ignore?.filter(Boolean),typesOnly:q.typesOnly??!1,maxDepth:q.maxDepth??100,includeNodeModules:q.includeNodeModules??!1});if(q.format==="json")console.log(J(M.graph,j));else if(q.format==="dot")console.log(A(M.graph,j));else if(console.log(K(M,j)),q.summary){let T=N(M.graph);if(console.log(`
11
11
  --- Dependency Graph Summary ---`),console.log(`Total files: ${T.totalFiles}`),console.log(`Total dependencies: ${T.totalDependencies}`),console.log(`Average dependencies per file: ${T.avgDependencies.toFixed(2)}`),T.maxDependencies.count>0)console.log(`Most dependencies: ${B(j,T.maxDependencies.file)} (${T.maxDependencies.count})`);if(T.mostDepended.count>0)console.log(`Most depended on: ${B(j,T.mostDepended.file)} (${T.mostDepended.count} dependents)`);if(T.isolatedFiles.length>0)console.log(`Isolated files (no dependencies): ${T.isolatedFiles.length}`)}V.exit(M.hasCircular?1:0)}catch(Q){console.error("Error analyzing dependencies:",Q),V.exit(1)}});k.command("version","Show the version of dtsx").action(()=>{console.log(e)});k.version(e);k.help();k.parse();
@@ -0,0 +1,25 @@
1
+ // @bun
2
+ function y(D){return D===32||D===9||D===10||D===13}function Bj(D){return D>=65&&D<=90||D>=97&&D<=122||D===95||D===36||D>127}function W(D){return Bj(D)||D>=48&&D<=57}function lj(D){if(D.charCodeAt(0)===82&&D.startsWith("Record<"))return!0;if(D.charCodeAt(0)===65&&D.startsWith("Array<"))return!0;if(D.charCodeAt(0)===123&&D.includes("[")&&D.includes("]:"))return!0;if(D==="any"||D==="object"||D==="unknown")return!0;return!1}var qj=["public","protected","private","readonly","override"];function dj(D,Hj,T=!0,l=!1){let Z=D,c=T,b=l,V=Z.length,L=[],P=new Map,x=new Set,j=0;if(j<V&&Z.charCodeAt(j)===65279)j++;function v(J,H){if(J<H){let U=Z.charCodeAt(J),X=Z.charCodeAt(H-1);if(U!==32&&U!==9&&U!==10&&U!==13&&X!==32&&X!==9&&X!==10&&X!==13)return Z.slice(J,H)}while(J<H&&y(Z.charCodeAt(J)))J++;while(H>J&&y(Z.charCodeAt(H-1)))H--;return Z.slice(J,H)}function O(){if(j>=V)return;let J=Z.charCodeAt(j);if(J!==32&&J!==9&&J!==10&&J!==13&&J!==47)return;while(j<V){let H=Z.charCodeAt(j);if(H===32||H===9||H===10||H===13){j++;continue}if(H===47&&j+1<V){let U=Z.charCodeAt(j+1);if(U===47){let X=Z.indexOf(`
3
+ `,j+2);j=X===-1?V:X+1;continue}if(U===42){let X=Z.indexOf("*/",j+2);j=X===-1?V:X+2;continue}}break}}function Ij(J){let H=J.length,U=0,X=H;for(let Y=0;Y<H;Y++){let $=J.charCodeAt(Y);if(U){if($===92){Y++;continue}if($===U)U=0;continue}if($===39||$===34||$===96){U=$;continue}if($===47&&Y+1<H){let G=J.charCodeAt(Y+1);if(G===47){X=Y;while(X>0&&(J.charCodeAt(X-1)===32||J.charCodeAt(X-1)===9))X--;return J.slice(0,X)}if(G===42){let B=J.indexOf("*/",Y+2);if(B!==-1){J=`${J.slice(0,Y)} ${J.slice(B+2)}`,Y--;continue}}}}X=H;while(X>0&&(J.charCodeAt(X-1)===32||J.charCodeAt(X-1)===9||J.charCodeAt(X-1)===13))X--;return X<H?J.slice(0,X):J}function h(J){j++;let H=J===39?"'":'"';while(j<V){let U=Z.indexOf(H,j);if(U===-1){j=V;return}let X=0,Y=U-1;while(Y>=0&&Z.charCodeAt(Y)===92)X++,Y--;if(X%2===0){j=U+1;return}j=U+1}}function t(){j++;let J=[];while(j<V){let H=Z.charCodeAt(j);if(J.length===0){if(H===92){j+=2;continue}if(H===96){j++;return}if(H===36&&j+1<V&&Z.charCodeAt(j+1)===123){j+=2,J.push(0);continue}j++;continue}if(H===39||H===34){h(H);continue}if(H===96){t();continue}if(H===47&&j+1<V){let U=Z.charCodeAt(j+1);if(U===47){let X=Z.indexOf(`
4
+ `,j+2);j=X===-1?V:X+1;continue}if(U===42){let X=Z.indexOf("*/",j+2);j=X===-1?V:X+2;continue}j++;continue}if(H===123){J[J.length-1]++,j++;continue}if(H===125){let U=J[J.length-1];if(U===0){J.pop(),j++;continue}J[J.length-1]=U-1,j++;continue}j++}}function f(){let J=Z.charCodeAt(j);if(J===39||J===34)return h(J),!0;if(J===96)return t(),!0;if(J===47&&j+1<V){let H=Z.charCodeAt(j+1);if(H===47){let U=Z.indexOf(`
5
+ `,j+2);return j=U===-1?V:U+1,!0}if(H===42){let U=Z.indexOf("*/",j+2);return j=U===-1?V:U+2,!0}if(Ej())return fj(),!0}return!1}function Ej(){let J=j-1;while(J>=0&&(Z.charCodeAt(J)===32||Z.charCodeAt(J)===9||Z.charCodeAt(J)===10||Z.charCodeAt(J)===13))J--;if(J<0)return!0;let H=Z.charCodeAt(J);if(H===61||H===40||H===91||H===33||H===38||H===124||H===63||H===58||H===44||H===59||H===123||H===125||H===94||H===126||H===43||H===45||H===42||H===37||H===60||H===62)return!0;if(W(H)){let U=J;while(U>=0&&W(Z.charCodeAt(U)))U--;let X=Z.slice(U+1,J+1);if(X==="return"||X==="typeof"||X==="void"||X==="delete"||X==="throw"||X==="new"||X==="in"||X==="of"||X==="case"||X==="instanceof"||X==="yield"||X==="await")return!0}return!1}function fj(){j++;let J=!1;while(j<V){let H=Z.charCodeAt(j);if(H===92){j+=2;continue}if(J){if(H===93)J=!1;j++;continue}if(H===91){J=!0,j++;continue}if(H===47){j++;break}if(H===10||H===13)break;j++}while(j<V&&W(Z.charCodeAt(j)))j++}function E(){let J=j;while(j<V&&W(Z.charCodeAt(j)))j++;return Z.slice(J,j)}function z(J){if(j+J.length>V)return!1;for(let H=0;H<J.length;H++)if(Z.charCodeAt(j+H)!==J.charCodeAt(H))return!1;if(j+J.length<V&&W(Z.charCodeAt(j+J.length)))return!1;return!0}function Jj(J){let H=j+J;while(H<V){let U=Z.charCodeAt(H);if(U===32||U===9||U===10||U===13){H++;continue}return U!==46&&U!==61}return!1}function yj(){if(j>=V)return!1;switch(Z.charCodeAt(j)){case 101:return z("export")||z("enum");case 105:return z("import")||z("interface");case 102:return z("function");case 99:return z("class")||z("const");case 116:return z("type");case 108:return z("let");case 118:return z("var");case 100:return z("declare")||z("default");case 109:return z("module");case 110:return z("namespace");case 97:return z("abstract")||z("async");default:return!1}}function a(){let J=Z.charCodeAt(j);if(J!==10&&J!==13)return!1;let H=j;if(j++,J===13&&j<V&&Z.charCodeAt(j)===10)j++;while(j<V){let X=Z.charCodeAt(j);if(X===32||X===9||X===13||X===10){j++;continue}if(X===47&&j+1<V){let Y=Z.charCodeAt(j+1);if(Y===47){let $=Z.indexOf(`
6
+ `,j+2);j=$===-1?V:$+1;continue}if(Y===42){let $=Z.indexOf("*/",j+2);j=$===-1?V:$+2;continue}}break}let U=j>=V||yj()||Z.charCodeAt(j)===125;return j=H,U}function e(){let J=Z.charCodeAt(j);if(J!==10&&J!==13)return!1;let H=j;if(j++,J===13&&j<V&&Z.charCodeAt(j)===10)j++;while(j<V){let X=Z.charCodeAt(j);if(X===32||X===9||X===13||X===10){j++;continue}if(X===47&&j+1<V&&Z.charCodeAt(j+1)===47){let Y=Z.indexOf(`
7
+ `,j+2);j=Y===-1?V:Y+1;continue}break}if(j>=V)return j=H,!0;let U=Z.charCodeAt(j);if(U===124||U===38||U===46||U===63||U===58)return j=H,!1;if(z("extends")||z("keyof")||z("typeof")||z("infer")||z("is")||z("as")||z("in"))return j=H,!1;return j=H,!0}let Aj=/[{}'"`\/]/g,Tj=/[()'"`\/]/g,kj=/[[\]'"`\/]/g,Cj=/[<>'"`\/]/g;function A(J,H){let U=1;j++;let X=J===123?Aj:J===40?Tj:J===91?kj:Cj;X.lastIndex=j;let Y;while((Y=X.exec(Z))!==null){let $=Y.index,G=Z.charCodeAt($);if(G===39||G===34){j=$,h(G),X.lastIndex=j;continue}if(G===96){j=$,t(),X.lastIndex=j;continue}if(G===47){if(j=$,f()){X.lastIndex=j;continue}X.lastIndex=$+1;continue}if(G===J)U++;else if(G===H){if(H===62&&$>0&&Z.charCodeAt($-1)===61){X.lastIndex=$+1;continue}if(U--,U===0)return j=$+1,j}X.lastIndex=$+1}return j=V,j}function S(){return j>0&&Z.charCodeAt(j-1)===61}function Xj(){return j+1<V&&Z.charCodeAt(j+1)===62}let k=/[{};'"`\/\n\r()[\]]/g;function I(){let J=0,H=0,U=0;k.lastIndex=j;let X;while((X=k.exec(Z))!==null){let Y=X.index,$=Z.charCodeAt(Y);if($===39||$===34){j=Y,h($),k.lastIndex=j;continue}if($===96){j=Y,t(),k.lastIndex=j;continue}if($===47){if(j=Y,f()){k.lastIndex=j;continue}k.lastIndex=Y+1;continue}if($===40){H++,k.lastIndex=Y+1;continue}if($===41){H--,k.lastIndex=Y+1;continue}if($===91){U++,k.lastIndex=Y+1;continue}if($===93){U--,k.lastIndex=Y+1;continue}if($===123){J++,k.lastIndex=Y+1;continue}if($===125){if(J--,J<=0&&H<=0&&U<=0){j=Y+1;return}k.lastIndex=Y+1;continue}if($===59&&J===0&&H===0&&U===0){j=Y+1;return}if(($===10||$===13)&&J===0&&H===0&&U===0){if(j=Y,a())return}k.lastIndex=Y+1}j=V}function Nj(){A(123,125);while(j<V&&y(Z.charCodeAt(j)))j++;if(z("from")){j+=4;while(j<V&&y(Z.charCodeAt(j)))j++;if(j<V){let J=Z.charCodeAt(j);if(J===39||J===34)h(J)}}while(j<V&&(Z.charCodeAt(j)===32||Z.charCodeAt(j)===9))j++;if(j<V&&Z.charCodeAt(j)===59)j++}function Rj(){j++;while(j<V&&y(Z.charCodeAt(j)))j++;if(z("as")){j+=2;while(j<V&&y(Z.charCodeAt(j)))j++;E();while(j<V&&y(Z.charCodeAt(j)))j++}if(z("from")){j+=4;while(j<V&&y(Z.charCodeAt(j)))j++;if(j<V){let J=Z.charCodeAt(j);if(J===39||J===34)h(J)}}while(j<V&&(Z.charCodeAt(j)===32||Z.charCodeAt(j)===9))j++;if(j<V&&Z.charCodeAt(j)===59)j++}function Uj(J){let H=J.indexOf("from ");if(H===-1)return;let U=H+5;while(U<J.length&&(J.charCodeAt(U)===32||J.charCodeAt(U)===9))U++;if(U>=J.length)return;let X=J.charCodeAt(U);if(X!==39&&X!==34)return;let Y=J.indexOf(J[U],U+1);if(Y===-1)return;return J.slice(U+1,Y)}function C(J){if(!c)return;let H=J-1;while(H>=0&&y(Z.charCodeAt(H)))H--;if(H<0)return;let U=[],X=!1;while(H>=0){if(H>=1&&Z.charCodeAt(H)===47&&Z.charCodeAt(H-1)===42){let G=Z.lastIndexOf("/*",H-2);if(G>=0){U.push(Z.slice(G,H+1)),X=!0,H=G-1;while(H>=0&&y(Z.charCodeAt(H)))H--;continue}break}let Y=H;while(Y>0&&Z.charCodeAt(Y-1)!==10)Y--;let $=v(Y,H+1);if($.startsWith("//")){if(X)break;let G=[$];H=Y-1;while(H>=0&&(Z.charCodeAt(H)===10||Z.charCodeAt(H)===13))H--;while(H>=0){let B=H;while(B>0&&Z.charCodeAt(B-1)!==10)B--;let Q=v(B,H+1);if(Q.startsWith("//")){G.push(Q),H=B-1;while(H>=0&&(Z.charCodeAt(H)===10||Z.charCodeAt(H)===13))H--}else if(Q===""){H=B-1;while(H>=0&&(Z.charCodeAt(H)===10||Z.charCodeAt(H)===13))H--}else break}G.reverse(),U.push(G.join(`
8
+ `));continue}break}if(U.length===0)return;return U.reverse(),U}function Sj(J){let H=J,U=!1;while(j<V){let Q=Z.charCodeAt(j);if(Q===59){j++;break}if(Q===39||Q===34){h(Q),U=!0;while(j<V&&(Z.charCodeAt(j)===32||Z.charCodeAt(j)===9))j++;if(j<V&&Z.charCodeAt(j)===59)j++;break}if(Q===10&&U)break;j++}let X=v(H,j),Y=X.charCodeAt(7)===116&&(X.startsWith("import type ")||X.startsWith("import type{")),$=!1;{let Q=6;while(Q<X.length&&(X.charCodeAt(Q)===32||X.charCodeAt(Q)===9))Q++;if(Q<X.length&&X.charCodeAt(Q)===116&&X.startsWith("type",Q)){Q+=4;while(Q<X.length&&(X.charCodeAt(Q)===32||X.charCodeAt(Q)===9))Q++}if(Q<X.length){let K=X.charCodeAt(Q);$=K===39||K===34}}let G="";{let Q=X.indexOf("from ");if(Q!==-1){let K=Q+5;while(K<X.length&&(X.charCodeAt(K)===32||X.charCodeAt(K)===9))K++;if(K<X.length){let q=X.charCodeAt(K);if(q===39||q===34){let _=X.indexOf(String.fromCharCode(q),K+1);if(_!==-1)G=X.slice(K+1,_)}}}else if($){let K=6;while(K<X.length&&X.charCodeAt(K)!==39&&X.charCodeAt(K)!==34)K++;if(K<X.length){let q=X.charCodeAt(K),_=X.indexOf(String.fromCharCode(q),K+1);if(_!==-1)G=X.slice(K+1,_)}}}let B=C(H);return{kind:"import",name:"",text:X,isExported:!1,isTypeOnly:Y,isSideEffect:$,source:G,leadingComments:B,start:H,end:j}}function Yj(){let J=j;return A(123,125),Z.slice(J,j)}function _j(J){let H=J.indexOf("(");if(H===-1)return J;let U=J.slice(H);if(U.indexOf("=")===-1)return J;let X=!1;for(let Q=0;Q<U.length;Q++)if(U.charCodeAt(Q)===61){let q=Q>0?U.charCodeAt(Q-1):0,_=Q+1<U.length?U.charCodeAt(Q+1):0;if(q!==61&&q!==33&&q!==60&&q!==62&&_!==61&&_!==62){X=!0;break}}if(!X)return J;let Y=0,$=-1;for(let Q=H;Q<J.length;Q++){let K=J.charCodeAt(Q);if(K===40)Y++;else if(K===41){if(Y--,Y===0){$=Q;break}}}if($===-1)return J;let G=J.slice(H,$+1),B=n(G);return J.slice(0,H)+B+J.slice($+1)}function gj(J){let H=J.indexOf("//")!==-1||J.indexOf("/*")!==-1,U=J.split(`
9
+ `),X=[],Y=[],$=[],G=!1,B=1/0;for(let q=0;q<U.length;q++){let _=U[q];if(H){if(G){if(_.includes("*/"))G=!1;continue}let g=_.trim();if(g.length===0)continue;let R=g.charCodeAt(0);if(R===47){let w=g.charCodeAt(1);if(w===47)continue;if(w===42){if(!g.includes("*/"))G=!0;continue}}if(R===42)continue;let F=Ij(_);if(F.charCodeAt(F.length-1)===59)F=F.slice(0,-1);F=_j(F);let N=F.trim();if(!N)continue;X.push(F),Y.push(N);let M=0;while(M<F.length&&y(F.charCodeAt(M)))M++;if(N!=="{"&&N!=="}"){if(M<B)B=M}$.push(M)}else{let g=_.length;while(g>0&&(_.charCodeAt(g-1)===32||_.charCodeAt(g-1)===9||_.charCodeAt(g-1)===13))g--;if(g===0)continue;let R=g<_.length?_.slice(0,g):_;if(R.charCodeAt(R.length-1)===59)R=R.slice(0,-1);R=_j(R);let F=R.trim();if(!F)continue;X.push(R),Y.push(F);let N=0;while(N<R.length&&y(R.charCodeAt(N)))N++;if(F!=="{"&&F!=="}"){if(N<B)B=N}$.push(N)}}if(X.length===0)return"{}";if(B===1/0||B<=2)return X.join(`
10
+ `);let Q=B-2,K=Array(X.length);for(let q=0;q<X.length;q++){let _=Y[q];if(_==="{"){K[q]=_;continue}let g=$[q];if(g>B)K[q]=X[q];else if(g===B&&(_.charCodeAt(0)===125||_.charCodeAt(0)===93||_.charCodeAt(0)===41))K[q]=X[q];else{let R=Math.max(0,g-Q);K[q]=" ".repeat(R)+_}}return K.join(`
11
+ `)}function u(){if(j>=V||Z.charCodeAt(j)!==60)return"";let J=j;A(60,62);let H=Z.slice(J,j);if(H.includes(`
12
+ `)){let U="",X=!1;for(let Y=0;Y<H.length;Y++){let $=H.charCodeAt(Y);if($===32||$===9||$===10||$===13){if(!X&&U.length>0)U+=" ",X=!0}else U+=H[Y],X=!1}if(U.charCodeAt(1)===32)U=`<${U.slice(2)}`;if(U.charCodeAt(U.length-2)===32)U=`${U.slice(0,-2)}>`;return U}return H}function m(){if(j>=V||Z.charCodeAt(j)!==40)return"()";let J=j;return A(40,41),Z.slice(J,j)}function n(J){let H=J.slice(1,-1).trim();if(!H)return"()";if(J.indexOf(`
13
+ `)===-1&&H.indexOf(":")!==-1&&H.indexOf("{")===-1&&H.indexOf("[")===-1&&H.indexOf("=")===-1&&H.indexOf("@")===-1&&H.indexOf("...")===-1){let Q=0,K=0,q=0;for(let _=0;_<H.length;_++){let g=H.charCodeAt(_);if(g===40||g===60||g===123)q++;else if(g===41||g===62||g===125)q--;else if(q===0){if(g===58)Q++;else if(g===44)K++}}if(Q>=K+1){let _=!1;for(let g=0;g<qj.length;g++){let R=qj[g],F=H.indexOf(R);if(F!==-1){let N=F+R.length;if((F===0||!W(H.charCodeAt(F-1)))&&(N>=H.length||!W(H.charCodeAt(N)))){_=!0;break}}}if(!_)return J}}let U=[],X=0,Y=0,$=!1,G=0;for(let Q=0;Q<=H.length;Q++){if(Q===H.length){U.push(H.slice(X).trim());break}let K=H.charCodeAt(Q);if($){if(K===92){Q++;continue}if(K===G)$=!1;continue}if(K===47&&Q+1<H.length){let q=H.charCodeAt(Q+1);if(q===42){Q+=2;while(Q+1<H.length&&!(H.charCodeAt(Q)===42&&H.charCodeAt(Q+1)===47))Q++;Q++;continue}if(q===47){while(Q<H.length&&H.charCodeAt(Q)!==10)Q++;continue}}if(K===39||K===34||K===96){$=!0,G=K;continue}if(K===40||K===123||K===91||K===60)Y++;else if(K===41||K===125||K===93||K===62&&!(Q>0&&H.charCodeAt(Q-1)===61))Y--;else if(K===44&&Y===0)U.push(H.slice(X,Q).trim()),X=Q+1}let B=[];for(let Q of U){if(!Q)continue;let K=Q.trim();if(K.startsWith("//")||K.startsWith("/*"))continue;let q=Q;{let _=!1,g=0,R=0,F=0;for(let N=0;N<q.length-1;N++){let M=q.charCodeAt(N);if(M===10){F=N+1;continue}if(_){if(M===92){N++;continue}if(M===g)_=!1;continue}if(M===39||M===34||M===96){_=!0,g=M;continue}if(M===123||M===91||M===40||M===60){R++;continue}if(M===125||M===93||M===41||M===62){if(R>0)R--;continue}if(M===47&&q.charCodeAt(N+1)===47){if(R===0){q=q.slice(0,N).trimEnd();break}let w=q.indexOf(`
14
+ `,N);if(w===-1){q=q.slice(0,F).trimEnd();break}let s=q.slice(0,F),hj=q.slice(w+1);q=`${s}${hj}`,N=F-1}}}if(!q.trim())continue;B.push(Lj(q))}return`(${B.join(", ")})`}function Wj(J){if(!J.startsWith("{")&&!J.startsWith("["))return J;let H="",U=0,X=0,Y=!1,$=0;while(U<J.length){let G=J.charCodeAt(U);if(Y){if(G===92&&U+1<J.length){H+=J[U]+J[U+1],U+=2;continue}if(G===$)Y=!1;H+=J[U],U++;continue}if(G===47&&U+1<J.length){let B=J.charCodeAt(U+1);if(B===42){let Q=U;U+=2;while(U+1<J.length&&!(J.charCodeAt(U)===42&&J.charCodeAt(U+1)===47))U++;U=Math.min(U+2,J.length),H+=J.slice(Q,U);continue}if(B===47){let Q=U;while(U<J.length&&J.charCodeAt(U)!==10)U++;H+=J.slice(Q,U);continue}}if(G===39||G===34||G===96){Y=!0,$=G,H+=J[U],U++;continue}if(G===123||G===91||G===40)X++;else if(G===125||G===93||G===41)X--;if(X>=1&&G===61&&(U+1>=J.length||J.charCodeAt(U+1)!==61&&J.charCodeAt(U+1)!==62)){while(H.length>0&&(H[H.length-1]===" "||H[H.length-1]==="\t"||H[H.length-1]===`
15
+ `))H=H.slice(0,-1);U++;let B=0;while(U<J.length){let Q=J.charCodeAt(U);if(Q===39||Q===34||Q===96){let K=Q;U++;while(U<J.length){if(J.charCodeAt(U)===92){U+=2;continue}if(J.charCodeAt(U)===K){U++;break}U++}continue}if(Q===123||Q===91||Q===40)B++;else if(Q===125||Q===93||Q===41){if(B===0)break;B--}else if(Q===44&&B===0)break;U++}continue}if(X===1&&G===46&&U+2<J.length&&J.charCodeAt(U+1)===46&&J.charCodeAt(U+2)===46){U+=3;continue}H+=J[U],U++}return H}function Lj(J){let H=J.trim(),U=H.startsWith("...");if(U)H=H.slice(3).trim();while(H.startsWith("@")){let F=1;while(F<H.length&&W(H.charCodeAt(F)))F++;if(F<H.length&&H.charCodeAt(F)===40){let N=1;F++;while(F<H.length&&N>0){if(H.charCodeAt(F)===40)N++;else if(H.charCodeAt(F)===41)N--;F++}}H=H.slice(F).trim()}let X=!0;while(X){X=!1;for(let F of qj)if(H.startsWith(F)&&H.length>F.length&&!W(H.charCodeAt(F.length))){let N=H.slice(F.length).trim();if(N.charCodeAt(0)===58||N.charCodeAt(0)===63&&N.length>1&&N.charCodeAt(1)===58)break;H=N,X=!0;break}}let Y=-1,$=-1,G=0,B=!1,Q=0;for(let F=0;F<H.length;F++){let N=H.charCodeAt(F);if(B){if(N===92){F++;continue}if(N===Q)B=!1;continue}if(N===47&&F+1<H.length){let M=H.charCodeAt(F+1);if(M===42){F+=2;while(F+1<H.length&&!(H.charCodeAt(F)===42&&H.charCodeAt(F+1)===47))F++;F++;continue}if(M===47){while(F<H.length&&H.charCodeAt(F)!==10)F++;continue}}if(N===39||N===34||N===96){B=!0,Q=N;continue}if(N===40||N===123||N===91||N===60)G++;else if(N===41||N===125||N===93||N===62&&!(F>0&&H.charCodeAt(F-1)===61))G--;else if(G===0){if(N===58&&Y===-1)Y=F;else if(N===61&&$===-1&&(F===0||H.charCodeAt(F-1)!==61)&&(F+1>=H.length||H.charCodeAt(F+1)!==61&&H.charCodeAt(F+1)!==62))$=F}}let K,q,_=$!==-1;if(Y!==-1&&($===-1||Y<$))if(K=H.slice(0,Y).trim(),$!==-1)q=H.slice(Y+1,$).trim();else q=H.slice(Y+1).trim();else if($!==-1)K=H.slice(0,$).trim(),q=Zj(H.slice($+1).trim());else K=H,q="unknown";if(K=Wj(K),(K.startsWith("{")||K.startsWith("["))&&K.includes(`
16
+ `)){let F=K.replace(/\s*\n\s*/g," ").replace(/\s+/g," ");if(F.length<=40)K=F;else K=K.split(`
17
+ `).map((M)=>{let w=M.trim();if(!w)return"";if(w==="{"||w==="}"||w==="["||w==="]"||w.startsWith("}")||w.startsWith("]"))return w;return` ${w}`}).join(`
18
+ `)}let g=K.endsWith("?")||_;if(K.endsWith("?"))K=K.slice(0,-1).trim();let R=g&&!U?"?":"";if(U)return`...${K}: ${q}`;return`${K}${R}: ${q}`}function Mj(J){let H=0;if(H<J.length&&J.charCodeAt(H)===45)H++;if(H>=J.length)return!1;let U=J.charCodeAt(H);if(U<48||U>57)return!1;while(H<J.length&&J.charCodeAt(H)>=48&&J.charCodeAt(H)<=57)H++;if(H<J.length&&J.charCodeAt(H)===46){if(H++,H>=J.length||J.charCodeAt(H)<48||J.charCodeAt(H)>57)return!1;while(H<J.length&&J.charCodeAt(H)>=48&&J.charCodeAt(H)<=57)H++}return H===J.length}function Zj(J){let H=J.trim();if(H==="true"||H==="false")return"boolean";if(Mj(H))return"number";if(H.startsWith("'")&&H.endsWith("'")||H.startsWith('"')&&H.endsWith('"'))return"string";if(H.startsWith("["))return"unknown[]";if(H.startsWith("{"))return"Record<string, unknown>";return"unknown"}function $j(J){let H=J.trim();if(H==="true"||H==="false")return H;if(Mj(H))return H;if(H.startsWith("'")&&H.endsWith("'")||H.startsWith('"')&&H.endsWith('"'))return H;return"unknown"}function Qj(J){if(J.endsWith("as const"))return null;let H=0,U=-1;for(let Y=0;Y<J.length;Y++){let $=J.charCodeAt(Y);if($===123||$===91||$===40)H++;else if($===125||$===93||$===41)H--;else if(H===0&&$===32&&Y+4<=J.length&&J.substring(Y,Y+4)===" as ")U=Y}if(U===-1)return null;return J.slice(U+4).trim()||null}function jj(){if(O(),j<V&&Z.charCodeAt(j)===58){j++,O();let J=j,H=0;while(j<V){if(f())continue;let U=Z.charCodeAt(j);if(U===40||U===91||U===60)H++;else if(U===41||U===93||U===62&&!S())H--;else if(U===123)if(H>0)H++;else{let X=v(J,j),Y=($)=>{let G=X.length-$.length;return G>=0&&X.endsWith($)&&(G===0||!W(X.charCodeAt(G-1)))};if(X.length===0||X.endsWith("|")||X.endsWith("&")||Y("is")||Y("extends"))H++;else break}else if(U===125){if(H===0)break;H--}else if(H===0&&U===59)break;if(H===0&&e())break;j++}return v(J,j)}return""}function d(J,H,U,X){j+=8,O();let Y=j<V&&Z.charCodeAt(j)===42;if(Y)j++,O();let $=E();if(!$&&!X)return null;O();let G=u();O();let B=m();O();let Q=jj();if(!Q)if(U&&Y)Q="AsyncGenerator<unknown, void, unknown>";else if(Y)Q="Generator<unknown, void, unknown>";else if(U)Q="Promise<void>";else Q="void";O();let K=!1;if(j<V&&Z.charCodeAt(j)===123)K=!0,A(123,125);else if(j<V&&Z.charCodeAt(j)===59)j++;let q=n(B),g=`${H?X?"export default function ":"export declare function ":"declare function "}${$||"default"}${G}${q}: ${Q};`,R=C(J);if(K)x.add(L.length);return{kind:"function",name:$||"default",text:g,isExported:H,isDefault:X,isAsync:U,isGenerator:Y,returnType:Q,generics:G||void 0,leadingComments:R,start:J,end:j}}function r(J,H,U){j+=H.length,O();let X=[];do{if(O(),j>=V)break;let Y=Z.charCodeAt(j);if(Y===123||Y===91)return I(),X;let $=E();if(!$)return I(),X;O();let G,B,Q=!1;if(j<V&&Z.charCodeAt(j)===58){j++,O();let _=j,g=0;while(j<V){if(f())continue;let R=Z.charCodeAt(j);if(R===40||R===123||R===91||R===60)g++;else if(R===41||R===125||R===93||R===62&&!S())g--;else if(g===0&&(R===59||R===44))break;else if(g===0&&R===61&&!Xj())break;if(g===0&&a())break;j++}G=v(_,j)}if(j<V&&Z.charCodeAt(j)===61)if(b&&G&&!lj(G))I();else{j++,O();let _=j,g=0,R=0;while(j<V){if(f())continue;let F=Z.charCodeAt(j);if(F===40||F===123||F===91)g++;else if(F===41||F===125||F===93)g--;else if(F===60&&g===0){if(j+1>=V||Z.charCodeAt(j+1)!==61)R++}else if(F===62&&g===0&&!S()){if(R>0&&(j+1>=V||Z.charCodeAt(j+1)!==61))R--}else if(g===0&&R===0&&(F===59||F===44))break;if(g===0&&R===0&&a())break;j++}if(B=v(_,j),B.endsWith(" as const")||B==="const"){if(Q=!0,!G){let F=B.endsWith(" as const")?B.slice(0,-9).trim():B,N=$j(F);G=N!=="unknown"?N:void 0}}else if(!G){let F=Qj(B);if(F)G=F}}if(j<V){let _=Z.charCodeAt(j);if(_===44){j++;continue}if(_===59)j++}let K=C(J),q=`${U?"export ":""}declare ${H} ${$}: ${G||"unknown"};`;X.push({kind:"variable",name:$,text:q,isExported:U,typeAnnotation:G,value:B,modifiers:Q?[H,"const assertion"]:[H],leadingComments:K,start:J,end:j});break}while(j<V);return X}function Kj(J,H){j+=9,O();let U=E();O();let X=u();O();let Y="";if(z("extends")){j+=7,O();let K=j,q=0;while(j<V){if(f())continue;let _=Z.charCodeAt(j);if(_===60)q++;else if(_===62&&!S())q--;else if(_===123&&q===0)break;j++}Y=v(K,j)}O();let $=j<V&&Z.charCodeAt(j)===123?Yj():"{}",G=gj($),B=`${H?"export ":""}declare interface ${U}${X}${Y?` extends ${Y}`:""} ${G}`,Q=C(J);return{kind:"interface",name:U,text:B,isExported:H,extends:Y||void 0,generics:X||void 0,leadingComments:Q,start:J,end:j}}function Vj(J,H){j+=4,O();let U=E();O();let X=u();if(O(),j<V&&Z.charCodeAt(j)===61)j++;O();let Y=j,$=0;while(j<V){if(f())continue;let K=Z.charCodeAt(j);if(K===40||K===123||K===91||K===60)$++;else if(K===41||K===125||K===93||K===62&&!S())$--;else if($===0&&K===59)break;if($===0&&a())break;j++}let G=v(Y,j);if(j<V&&Z.charCodeAt(j)===59)j++;let B=`${H?"export ":""}type ${U}${X} = ${G}`,Q=C(J);return{kind:"type",name:U,text:B,isExported:H,generics:X||void 0,leadingComments:Q,start:J,end:j}}function i(J,H,U){j+=4,O();let X=E();O();let Y=j;if(j<V&&Z.charCodeAt(j)===123)A(123,125);let $=v(J,j),G=C(J);return{kind:"enum",name:X,text:$,isExported:H,modifiers:U?["const"]:void 0,leadingComments:G,start:J,end:j}}function p(J,H,U,X=!1){j+=5,O();let Y=E()||"AnonymousClass";O();let $=u();O();let G="";if(z("extends")){j+=7,O();let g=j,R=0;while(j<V){if(f())continue;let F=Z.charCodeAt(j);if(F===60)R++;else if(F===62&&!S())R--;else if(R===0&&(F===123||z("implements")))break;j++}G=v(g,j)}let B;if(z("implements")){j+=10,O();let g=j,R=0;while(j<V){if(f())continue;let N=Z.charCodeAt(j);if(N===60)R++;else if(N===62&&!S())R--;else if(R===0&&N===123)break;j++}let F=v(g,j);if(F)B=F.split(",").map((N)=>N.trim())}O();let Q=zj(),q=`${H?X?"export default ":"export declare ":"declare "}${U?"abstract ":""}class ${Y}${$}${G?` extends ${G}`:""}${B&&B.length>0?` implements ${B.join(", ")}`:""} ${Q}`,_=C(J);return{kind:"class",name:Y,text:q,isExported:H,isDefault:X,extends:G||void 0,implements:B,generics:$||void 0,modifiers:U?["abstract"]:void 0,leadingComments:_,start:J,end:j}}function zj(){if(j>=V||Z.charCodeAt(j)!==123)return"{}";j++;let J=[];while(j<V){if(O(),j>=V)break;if(Z.charCodeAt(j)===125){j++;break}if(Z.charCodeAt(j)===59){j++;continue}if(z("static")&&Dj("static")===123){j+=6,O(),A(123,125);continue}let H=!1,U=!1,X=!1,Y=!1,$=!1,G=!1,B=!1,Q=!1,K=!0;while(K){if(O(),z("private")){H=!0,j+=7;continue}if(z("protected")){U=!0,j+=9;continue}if(z("public")){j+=6;continue}if(z("static")){X=!0,j+=6;continue}if(z("abstract")){Y=!0,j+=8;continue}if(z("readonly")){$=!0,j+=8;continue}if(z("override")){G=!0,j+=8;continue}if(z("accessor")){B=!0,j+=8;continue}if(z("async")){Q=!0,j+=5;continue}if(z("declare")){j+=7;continue}break}if(O(),j>=V||Z.charCodeAt(j)===125)break;if(Z.charCodeAt(j)===35)H=!0;if(H){Fj();continue}let q=" ";if(U)q+="protected ";if(X)q+="static ";if(Y)q+="abstract ";if($)q+="readonly ";if(z("constructor")){j+=11,O();let _=m();if(O(),uj(_,J),j<V&&Z.charCodeAt(j)===123)A(123,125);else if(j<V&&Z.charCodeAt(j)===59)j++;let g=n(_);J.push(` constructor${g};`)}else if(z("get"))if(j+=3,O(),j<V&&(Bj(Z.charCodeAt(j))||Z.charCodeAt(j)===91||Z.charCodeAt(j)===35)){let _=Oj();if(_.startsWith("#")){if(O(),j<V&&Z.charCodeAt(j)===40)m();if(O(),jj(),O(),j<V&&Z.charCodeAt(j)===123)A(123,125);else if(j<V&&Z.charCodeAt(j)===59)j++;continue}O(),m(),O();let g=jj()||"unknown";if(O(),j<V&&Z.charCodeAt(j)===123)A(123,125);else if(j<V&&Z.charCodeAt(j)===59)j++;J.push(`${q}get ${_}(): ${g};`)}else Pj("get",q,X,$,Q,J);else if(z("set"))if(j+=3,O(),j<V&&(Bj(Z.charCodeAt(j))||Z.charCodeAt(j)===91||Z.charCodeAt(j)===35)){let _=Oj();if(_.startsWith("#")){if(O(),j<V&&Z.charCodeAt(j)===40)m();if(O(),j<V&&Z.charCodeAt(j)===123)A(123,125);else if(j<V&&Z.charCodeAt(j)===59)j++;continue}O();let g=m();if(O(),j<V&&Z.charCodeAt(j)===123)A(123,125);else if(j<V&&Z.charCodeAt(j)===59)j++;let R=n(g);J.push(`${q}set ${_}${R};`)}else Pj("set",q,X,$,Q,J);else{let _=Z.charCodeAt(j)===42;if(_)j++,O();let g=Oj();if(!g){Fj();continue}bj(g,q,X,$,_,Y,Q,J)}}return`{
19
+ ${J.join(`
20
+ `)}
21
+ }`}function Oj(){if(j>=V)return"";let J=Z.charCodeAt(j);if(J===91){let H=j;return A(91,93),Z.slice(H,j)}if(J===35)return j++,`#${E()}`;return E()}function Dj(J){let H=j+J.length;while(H<V&&y(Z.charCodeAt(H)))H++;return H<V?Z.charCodeAt(H):0}function Fj(){let J=0;while(j<V){if(f())continue;let H=Z.charCodeAt(j);if(H===123||H===40)J++;else if(H===125||H===41){if(J===0)return;J--}else if(H===59&&J===0){j++;return}if(J===0&&e())return;j++}}function Pj(J,H,U,X,Y,$){bj(J,H,U,X,!1,!1,Y,$)}function bj(J,H,U,X,Y,$,G,B){if(O(),j>=V)return;let Q=Z.charCodeAt(j),K=!1;if(Q===63)K=!0,j++,O();if(j<V&&Z.charCodeAt(j)===33)j++,O();let q=j<V?Z.charCodeAt(j):0;if(q===40||q===60){let _=q===60?u():"";O();let g=m();O();let R=jj();if(!R)if(G&&Y)R="AsyncGenerator<unknown, void, unknown>";else if(Y)R="Generator<unknown, void, unknown>";else if(G)R="Promise<void>";else R="void";if(O(),j<V&&Z.charCodeAt(j)===123)A(123,125);else if(j<V&&Z.charCodeAt(j)===59)j++;let F=n(g),N=K?"?":"",M=Y?"*":"";B.push(`${H}${M}${J}${N}${_}${F}: ${R};`)}else if(q===58||q===61||q===59||q===125||q===10||q===13){let _="";if(q===58){j++,O();let F=j,N=0;while(j<V){if(f())continue;let M=Z.charCodeAt(j);if(M===40||M===123||M===91||M===60)N++;else if(M===41||M===125||M===93||M===62&&!S()){if(N===0)break;N--}else if(N===0&&(M===59||M===44))break;else if(N===0&&M===61&&!Xj())break;if(N===0&&e())break;j++}_=v(F,j)}let g="";if(j<V&&Z.charCodeAt(j)===61)if(b&&_){j++;let F=0;while(j<V){if(f())continue;let N=Z.charCodeAt(j);if(N===40||N===123||N===91)F++;else if(N===41||N===125||N===93){if(F===0&&N===125)break;F--}else if(F===0&&N===59)break;if(F===0&&e())break;j++}}else{j++,O();let F=j,N=0;while(j<V){if(f())continue;let M=Z.charCodeAt(j);if(M===40||M===123||M===91)N++;else if(M===41||M===125||M===93){if(N===0&&M===125)break;N--}else if(N===0&&M===59)break;if(N===0&&e())break;j++}g=v(F,j)}if(j<V&&Z.charCodeAt(j)===59)j++;if(!_)if(g){let F=Qj(g);if(F)_=F;else _=U&&X?$j(g):Zj(g)}else _="unknown";let R=K?"?":"";B.push(`${H}${J}${R}: ${_};`)}else Fj()}function uj(J,H){let U=J.slice(1,-1).trim();if(!U)return;let X=[],Y=0,$=0,G=!1,B=0;for(let Q=0;Q<=U.length;Q++){if(Q===U.length){X.push(U.slice(Y).trim());break}let K=U.charCodeAt(Q);if(G){if(K===92){Q++;continue}if(K===B)G=!1;continue}if(K===39||K===34||K===96){G=!0,B=K;continue}if(K===40||K===123||K===91||K===60)$++;else if(K===41||K===125||K===93||K===62&&!(Q>0&&U.charCodeAt(Q-1)===61))$--;else if(K===44&&$===0)X.push(U.slice(Y,Q).trim()),Y=Q+1}for(let Q of X){let K=Q.startsWith("public ")||Q.startsWith("public\t"),q=Q.startsWith("protected ")||Q.startsWith("protected\t"),_=Q.startsWith("private ")||Q.startsWith("private\t"),g=Q.includes("readonly ");if(!K&&!q&&!_&&!g)continue;if(_)continue;let R=Q,F=[];if(K){let w=6;while(w<R.length&&y(R.charCodeAt(w)))w++;R=R.slice(w),F.push("public")}if(q){let w=9;while(w<R.length&&y(R.charCodeAt(w)))w++;R=R.slice(w),F.push("protected")}if(g){let w=R.indexOf("readonly ");if(w!==-1){let s=w+8;while(s<R.length&&y(R.charCodeAt(s)))s++;R=R.slice(0,w)+R.slice(s)}F.push("readonly")}let N=F.length>0?`${F.join(" ")} `:"",M=Lj(R);H.push(` ${N}${M};`)}}function Gj(J=" "){if(j>=V||Z.charCodeAt(j)!==123)return"{}";j++;let H=[];while(j<V){if(O(),j>=V)break;if(Z.charCodeAt(j)===125){j++;break}if(Z.charCodeAt(j)===59){j++;continue}let U=!1;if(z("export"))U=!0,j+=6,O();if(z("declare"))j+=7,O();let X=U?"export ":"";if(z("function")||z("async")&&xj("async","function")){let Y=!1;if(z("async"))Y=!0,j+=5,O();if(j+=8,O(),j<V&&Z.charCodeAt(j)===42)j++,O();let G=E();O();let B=u();O();let Q=m();O();let K=jj();if(!K)K=Y?"Promise<void>":"void";if(O(),j<V&&Z.charCodeAt(j)===123)A(123,125);else if(j<V&&Z.charCodeAt(j)===59)j++;let q=n(Q);H.push(`${J}${X}function ${G}${B}${q}: ${K};`)}else if(z("const")||z("let")||z("var")){let Y=z("const")?"const":z("let")?"let":"var";j+=Y.length,O();let $=E();if(!$){I();continue}O();let G="";if(j<V&&Z.charCodeAt(j)===58){j++,O();let Q=j,K=0;while(j<V){if(f())continue;let q=Z.charCodeAt(j);if(q===40||q===123||q===91||q===60)K++;else if(q===41||q===125||q===93||q===62&&!S())K--;else if(K===0&&(q===59||q===44))break;else if(K===0&&q===61&&!Xj())break;if(K===0&&a())break;j++}G=v(Q,j)}let B="";if(j<V&&Z.charCodeAt(j)===61){j++,O();let Q=j,K=0;while(j<V){if(f())continue;let q=Z.charCodeAt(j);if(q===40||q===123||q===91||q===60)K++;else if(q===41||q===125||q===93||q===62&&!S())K--;else if(K===0&&(q===59||q===44))break;if(K===0&&a())break;j++}B=v(Q,j)}if(j<V&&Z.charCodeAt(j)===59)j++;if(!G&&B){let Q=Qj(B);if(Q)G=Q;else if(Y==="const")G=$j(B);else G=Zj(B)}if(!G)G="unknown";H.push(`${J}${X}${Y} ${$}: ${G};`)}else if(z("interface")){j+=9,O();let Y=E();O();let $=u();O();let G="";if(z("extends")){let Q=j;while(j<V&&Z.charCodeAt(j)!==123){if(f())continue;j++}G=Z.slice(Q,j)}let B=gj(Yj());H.push(`${J}${X}interface ${Y}${$}${G} ${B}`)}else if(z("type")){j+=4,O();let Y=E();O();let $=u();if(O(),j<V&&Z.charCodeAt(j)===61){j++,O();let G=j,B=0;while(j<V){if(f())continue;let K=Z.charCodeAt(j);if(K===40||K===123||K===91||K===60)B++;else if(K===41||K===125||K===93||K===62&&!S())B--;else if(B===0&&K===59)break;if(B===0&&a())break;j++}let Q=v(G,j);if(j<V&&Z.charCodeAt(j)===59)j++;H.push(`${J}${X}type ${Y}${$} = ${Q}`)}}else if(z("class")){j+=5,O();let Y=E();O();let $=u();O();let G=j;while(j<V&&Z.charCodeAt(j)!==123){if(f())continue;j++}let B=v(G,j),Q=B?` ${B}`:"",K=zj();H.push(`${J}${X}class ${Y}${$}${Q} ${K}`)}else if(z("enum")){j+=4,O();let Y=E();O();let $=Yj();H.push(`${J}${X}enum ${Y} ${$}`)}else if(z("namespace")||z("module")){let Y=z("namespace")?"namespace":"module";j+=Y.length,O();let $=E();O();let G=Gj(J);H.push(`${J}${X}${Y} ${$} ${G}`)}else if(z("abstract"))if(j+=8,O(),z("class")){j+=5,O();let Y=E();O();let $=u();O();let G=j;while(j<V&&Z.charCodeAt(j)!==123){if(f())continue;j++}let B=v(G,j),Q=B?` ${B}`:"",K=zj();H.push(`${J}${X}abstract class ${Y}${$}${Q} ${K}`)}else I();else if(U&&z("default")){j+=7,O();let Y=j;I();let $=v(Y,j);if($.charCodeAt($.length-1)===59)$=$.slice(0,-1);if($)H.push(`${J}export default ${$};`)}else if(!U&&(Z.charCodeAt(j)===39||Z.charCodeAt(j)===34||Z.charCodeAt(j)===96))I();else I()}if(H.length===0)return"{}";return`{
22
+ ${H.join(`
23
+ `)}
24
+ }`}function xj(J,H){let U=j+J.length;while(U<V&&y(Z.charCodeAt(U)))U++;for(let X=0;X<H.length;X++)if(U+X>=V||Z.charCodeAt(U+X)!==H.charCodeAt(X))return!1;return U+H.length>=V||!W(Z.charCodeAt(U+H.length))}function o(J,H,U){j+=U.length,O();let X="",Y=Z.charCodeAt(j);if(Y===39||Y===34){let K=j;h(Y),X=Z.slice(K,j)}else{X=E();while(j<V&&Z.charCodeAt(j)===46)j++,X+=`.${E()}`}O();let $=j<V&&Z.charCodeAt(j)===123?Gj():"{}",G=`${H?"export ":""}declare ${U} ${X} ${$}`,B=C(J),Q=X.startsWith("'")||X.startsWith('"');return{kind:"module",name:X,text:G,isExported:H,source:Q?X.slice(1,-1):void 0,leadingComments:B,start:J,end:j}}while(j<V){if(O(),j>=V)break;let J=j,H=Z.charCodeAt(j);if(H===105&&z("import"))L.push(Sj(J));else if(H===101&&z("export")){j+=6,O();let U=Z.charCodeAt(j);if(U===100&&z("default")){j+=7,O();let X=Z.charCodeAt(j);if(X===102&&z("function")){let Y=d(J,!0,!1,!0);if(Y)L.push(Y)}else if(X===97&&z("async")&&Dj("async")!==59)if(j+=5,O(),z("function")){let Y=d(J,!0,!0,!0);if(Y)L.push(Y)}else{I();let Y=v(J,j);L.push({kind:"export",name:"default",text:Y,isExported:!0,isTypeOnly:!1,start:J,end:j})}else if(X===99&&z("class")){let Y=p(J,!0,!1,!0);L.push(Y)}else if(X===97&&z("abstract")){if(j+=8,O(),z("class")){let Y=p(J,!0,!0,!0);L.push(Y)}}else{I();let Y=v(J,j),$=C(J);L.push({kind:"export",name:"default",text:Y,isExported:!0,isTypeOnly:!1,leadingComments:$,start:J,end:j})}}else if(U===116&&z("type")){let X=j;if(j+=4,O(),j<V&&Z.charCodeAt(j)===123){Nj();let Y=v(J,j),$=C(J);L.push({kind:"export",name:"",text:Y,isExported:!0,isTypeOnly:!0,source:Uj(Y),leadingComments:$,start:J,end:j})}else if(j<V&&Z.charCodeAt(j)===42){Rj();let Y=v(J,j);L.push({kind:"export",name:"",text:Y,isExported:!0,isTypeOnly:!0,source:Uj(Y),start:J,end:j})}else{j=X;let Y=Vj(J,!0);L.push(Y)}}else if(U===105&&z("interface")){let X=Kj(J,!0);L.push(X)}else if(U===102&&z("function")){let X=d(J,!0,!1,!1);if(X)L.push(X)}else if(U===97&&z("async"))if(j+=5,O(),z("function")){let X=d(J,!0,!0,!1);if(X)L.push(X)}else I();else if(U===99)if(z("class")){let X=p(J,!0,!1);L.push(X)}else if(z("const")){let X=j;if(j+=5,O(),z("enum")){j=X+5,O();let Y=i(J,!0,!0);L.push(Y)}else{j=X;let Y=r(J,"const",!0);for(let $=0;$<Y.length;$++)L.push(Y[$])}}else I();else if(U===97&&z("abstract")){if(j+=8,O(),z("class")){let X=p(J,!0,!0);L.push(X)}}else if(U===108&&z("let")){let X=r(J,"let",!0);for(let Y=0;Y<X.length;Y++)L.push(X[Y])}else if(U===118&&z("var")){let X=r(J,"var",!0);for(let Y=0;Y<X.length;Y++)L.push(X[Y])}else if(U===101&&z("enum")){let X=i(J,!0,!1);L.push(X)}else if(U===100&&z("declare"))j+=7,O(),wj(J,!0);else if(U===110&&z("namespace")&&Jj(9)){let X=o(J,!0,"namespace");L.push(X)}else if(U===109&&z("module")&&Jj(6)){let X=o(J,!0,"module");L.push(X)}else if(U===123){Nj();let X=v(J,j),Y=X.includes("export type"),$=C(J);L.push({kind:"export",name:"",text:X,isExported:!0,isTypeOnly:Y,source:Uj(X),leadingComments:$,start:J,end:j})}else if(U===42){Rj();let X=v(J,j),Y=C(J);L.push({kind:"export",name:"",text:X,isExported:!0,isTypeOnly:!1,source:Uj(X),leadingComments:Y,start:J,end:j})}else{I();let X=v(J,j);if(X)L.push({kind:"export",name:"",text:X,isExported:!0,start:J,end:j})}}else if(H===100&&z("declare"))j+=7,O(),wj(J,!1);else if(H===105&&z("interface")){let U=Kj(J,!1);P.set(U.name,U)}else if(H===116&&z("type")){let U=Vj(J,!1);P.set(U.name,U),L.push(U)}else if(H===102&&z("function")){let U=d(J,!1,!1,!1);if(U)P.set(U.name,U);else I()}else if(H===97)if(z("async")){let U=j;if(j+=5,O(),z("function")){let X=d(J,!1,!0,!1);if(X)P.set(X.name,X);else j=U,I()}else j=U,I()}else if(z("abstract"))if(j+=8,O(),z("class")){let U=p(J,!1,!1);P.set(U.name,U),L.push(U)}else I();else j++,I();else if(H===99)if(z("class")){let U=p(J,!1,!1);P.set(U.name,U),L.push(U)}else if(z("const")){let U=j;if(j+=5,O(),z("enum")){j=U+5,O();let X=i(J,!1,!0);P.set(X.name,X),L.push(X)}else{j=U;let X=r(J,"const",!1);for(let Y=0;Y<X.length;Y++)P.set(X[Y].name,X[Y])}}else j++,I();else if(H===101&&z("enum")){let U=i(J,!1,!1);P.set(U.name,U),L.push(U)}else if(H===108&&z("let"))I();else if(H===118&&z("var"))I();else if(H===109&&z("module")&&Jj(6)){let U=o(J,!1,"module");L.push(U)}else if(H===110&&z("namespace")&&Jj(9)){let U=o(J,!1,"namespace");L.push(U)}else{let U=Z.charCodeAt(j);if(U===39||U===34){if(h(U),j<V&&Z.charCodeAt(j)===59)j++}else if(U===96){if(t(),j<V&&Z.charCodeAt(j)===59)j++}else if(U===64){if(j++,E(),O(),j<V&&Z.charCodeAt(j)===46)j++,E(),O();if(j<V&&Z.charCodeAt(j)===40)A(40,41)}else j++,I()}}if(P.size>0)mj(L,P);if(x.size>0){let J=new Map;for(let U of L)if(U.kind==="function")J.set(U.name,(J.get(U.name)||0)+1);let H=new Set;for(let[U,X]of J)if(X>1)H.add(U);if(H.size>0){let U=new Set;for(let X of H)for(let Y=L.length-1;Y>=0;Y--)if(L[Y].kind==="function"&&L[Y].name===X&&x.has(Y)){U.add(Y);break}if(U.size>0){let X=[...U].sort((Y,$)=>$-Y);for(let Y of X)L.splice(Y,1)}}}return L;function wj(J,H){if(z("function")){let U=d(J,H,!1,!1);if(U)L.push(U)}else if(z("async")){if(j+=5,O(),z("function")){let U=d(J,H,!0,!1);if(U)L.push(U)}}else if(z("class")){let U=p(J,H,!1);L.push(U)}else if(z("abstract")){if(j+=8,O(),z("class")){let U=p(J,H,!0);L.push(U)}}else if(z("interface")){let U=Kj(J,H);L.push(U)}else if(z("type")){let U=Vj(J,H);L.push(U)}else if(z("enum")){let U=i(J,H,!1);L.push(U)}else if(z("const")){let U=j;if(j+=5,O(),z("enum")){j=U+5,O();let X=i(J,H,!0);L.push(X)}else if(H){j=U;let X=r(J,"const",!0);for(let Y=0;Y<X.length;Y++)L.push(X[Y])}else I()}else if(z("let")||z("var"))if(H){let U=z("let")?"let":"var",X=r(J,U,!0);for(let Y=0;Y<X.length;Y++)L.push(X[Y])}else I();else if(z("module")){let U=o(J,H,"module");L.push(U)}else if(z("namespace")){let U=o(J,H,"namespace");L.push(U)}else if(z("global")){j+=6,O();let X=`declare global ${j<V&&Z.charCodeAt(j)===123?Gj():"{}"}`,Y=C(J);L.push({kind:"module",name:"global",text:X,isExported:!1,leadingComments:Y,start:J,end:j})}else I()}}function vj(D,Hj){let T=0,l=D.length;while(T<l){let Z=D.charCodeAt(T);if(Z>=65&&Z<=90||Z>=97&&Z<=122||Z===95||Z===36||Z>127){let c=T;T++;while(T<l){let b=D.charCodeAt(T);if(b>=65&&b<=90||b>=97&&b<=122||b>=48&&b<=57||b===95||b===36||b>127)T++;else break}Hj.add(D.substring(c,T))}else T++}}function mj(D,Hj){let T=new Set,l=new Set;for(let b of D)l.add(b.name);let Z=new Set,c=[];for(let b=0;b<D.length;b++)if(D[b].kind!=="import")c.push(D[b].text),vj(D[b].text,Z);for(;;){let b=[];for(let[P,x]of Hj){if(T.has(P))continue;if(Z.has(P)){if(!l.has(P))b.push(x),l.add(P);T.add(P)}}if(b.length===0)break;b.sort((P,x)=>(P.start??1/0)-(x.start??1/0));let V=[],L=0;for(let P=0;P<D.length;P++){let x=D[P].start??1/0;while(L<b.length&&(b[L].start??1/0)<=x)V.push(b[L++]);V.push(D[P])}while(L<b.length)V.push(b[L++]);D.length=0;for(let P=0;P<V.length;P++)D.push(V[P]);for(let P of b)if(P.kind!=="import")c.push(P.text),vj(P.text,Z)}}
25
+ export{dj as oc};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{oc as a}from"./chunk-1z1w3s0k.js";import"./chunk-mcdb3q06.js";export{a as scanDeclarations};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h}from"./chunk-f4c389mj.js";import"./chunk-y581wnfe.js";import"./chunk-2n1bbm2c.js";import"./chunk-8z31rkfp.js";import"./chunk-2r21f44d.js";import"./chunk-285mqzvx.js";import"./chunk-gssantc8.js";import"./chunk-mcdb3q06.js";export{a as parseJSDoc,f as generateTypeDocJSON,c as generateMarkdown,e as generateJSON,d as generateHTML,g as generateDocs,b as extractDocumentation,h as createDocsGenerator};
2
+ import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h}from"./chunk-s30jnjb4.js";import"./chunk-69rnp3hs.js";import"./chunk-2n1bbm2c.js";import"./chunk-jjwwkrfk.js";import"./chunk-1z1w3s0k.js";import"./chunk-4jw8qvts.js";import"./chunk-gssantc8.js";import"./chunk-mcdb3q06.js";export{a as parseJSDoc,f as generateTypeDocJSON,c as generateMarkdown,e as generateJSON,d as generateHTML,g as generateDocs,b as extractDocumentation,h as createDocsGenerator};
@@ -0,0 +1,16 @@
1
+ // @bun
2
+ var E=!1,M=null;function h(J){if(J.indexOf("/*")===-1)return J.trim();let X=[],Q=0,z=0,B=J.length;while(z<B)if(J.charCodeAt(z)===47&&z+1<B&&J.charCodeAt(z+1)===42){if(z>Q)X.push(J.substring(Q,z));z+=2;while(z<B-1){if(J.charCodeAt(z)===42&&J.charCodeAt(z+1)===47){z+=2;break}z++}Q=z}else z++;if(Q<B)X.push(J.substring(Q));return X.join("").trim()}function $z(){E=!0,M=null}function Qz(){E=!1;let J=M;return M=null,J}function S(J){let Y=J.length;if(Y===0)return!1;let X=0;if(J.charCodeAt(X)===45)X++;if(X>=Y)return!1;let Q=X;while(X<Y&&J.charCodeAt(X)>=48&&J.charCodeAt(X)<=57)X++;if(X===Q)return!1;if(X<Y&&J.charCodeAt(X)===46){X++;let z=X;while(X<Y&&J.charCodeAt(X)>=48&&J.charCodeAt(X)<=57)X++;if(X===z)return!1}return X===Y}function o(J){for(let Y=0,X=J.length-1;Y<X;Y++){let Q=J.charCodeAt(Y);if(Q<48||Q>57)return!1}return!0}function D(J,Y){let X=0,Q=0;while((Q=J.indexOf(Y,Q))!==-1)X++,Q+=Y.length;return X}function _(J){let Y=J.length,X=!1;for(let Z=1;Z<Y;Z++)if(J.charCodeAt(Z)<=32&&J.charCodeAt(Z-1)<=32){X=!0;break}if(!X)for(let Z=0;Z<Y;Z++){let $=J.charCodeAt(Z);if($===10||$===13||$===9){X=!0;break}}if(!X)return J;let Q=[],z=-1,B=!1;for(let Z=0;Z<Y;Z++)if(J.charCodeAt(Z)<=32){if(!B){if(z>=0)Q.push(J.substring(z,Z));Q.push(" "),B=!0,z=-1}}else{if(B||z<0)z=Z;B=!1}if(z>=0)Q.push(J.substring(z));return Q.join("")}function V(J,Y=!1,X=!1,Q=0){if(!J||typeof J!=="string")return"unknown";if(Q>=20)return"unknown";let z=J.trim();if(z.startsWith("BigInt("))return"bigint";if(z.startsWith("Symbol.for("))return"symbol";if(z.includes(".raw`")||z.includes("String.raw`"))return"string";if(z.startsWith('"')&&z.endsWith('"')||z.startsWith("'")&&z.endsWith("'")||z.startsWith("`")&&z.endsWith("`")){if(!z.includes("${")){if(!Y)return"string";return z}if(Y)return z;return"string"}if(S(z)){if(!Y)return"number";return z}if(z==="true"||z==="false"){if(!Y)return"boolean";return z}if(z==="null")return"null";if(z==="undefined")return"undefined";if(z.startsWith("[")&&z.endsWith("]"))return I(z,Y,Q+1);if(z.startsWith("{")&&z.endsWith("}"))return s(z,Y,Q+1);if(z.startsWith("class ")||z.startsWith("class{"))return c(z);if(z.startsWith("new "))return d(z);if(z.includes("=>")||z.startsWith("function")||z.startsWith("async"))return y(z,X,Q,Y);if(z.endsWith("as const")){let B=z.slice(0,-8).trim();if(B.startsWith("[")&&B.endsWith("]")){let Z=B.slice(1,-1).trim();if(!Z)return"readonly []";let $=w(Z),H=[];for(let L=0;L<$.length;L++)H.push(V($[L].trim(),!0,!1,Q+1));return`readonly [${H.join(", ")}]`}return V(B,!0,X,Q+1)}if(z.startsWith("`")&&z.endsWith("`"))return p(z,Y);if(z.startsWith("Promise."))return f(z,Y,Q);if(z.startsWith("await "))return"unknown";if(z.charCodeAt(z.length-1)===110&&z.length>1&&o(z)){if(Y)return z;return"bigint"}if(z.startsWith("Symbol(")||z==="Symbol.for")return"symbol";return"unknown"}function l(J,Y=!1,X=0){return V(J,Y,!0,X)}function p(J,Y){if(J.includes(".raw`")||J.includes("String.raw`"))return"string";if(!Y)return"string";if(!J.includes("${"))return J;return"string"}function d(J){let Y=4;while(Y<J.length&&J.charCodeAt(Y)<=32)Y++;let X=Y,Q=J.charCodeAt(Y);if(Q<65||Q>90)return"unknown";while(Y<J.length&&(P(J.charCodeAt(Y))||J.charCodeAt(Y)===46))Y++;if(Y===X)return"unknown";let z=J.slice(X,Y);{let B=J.slice(Y),Z=B;if(B.startsWith("<")){let H=0,L=-1;for(let O=0;O<B.length;O++)if(B[O]==="<")H++;else if(B[O]===">"){if(H--,H===0){L=O;break}}if(L!==-1){let O=B.slice(0,L+1);Z=B.slice(L+1);let G=Z.indexOf("(");if(G!==-1){let W=0,K=-1;for(let F=G;F<Z.length;F++)if(Z[F]==="(")W++;else if(Z[F]===")"){if(W--,W===0){K=F;break}}if(K!==-1){if(Z.slice(K+1).trimStart().startsWith("."))return"unknown"}}return`${z}${O}`}}let $=Z.indexOf("(");if($!==-1){let H=0,L=-1;for(let O=$;O<Z.length;O++)if(Z[O]==="(")H++;else if(Z[O]===")"){if(H--,H===0){L=O;break}}if(L!==-1){if(Z.slice(L+1).trimStart().startsWith("."))return"unknown"}}switch(z){case"Date":return"Date";case"Map":return"Map<any, any>";case"Set":return"Set<any>";case"WeakMap":return"WeakMap<any, any>";case"WeakSet":return"WeakSet<any>";case"RegExp":return"RegExp";case"Error":return"Error";case"Array":return"any[]";case"Object":return"object";case"Function":return"Function";case"Promise":return"Promise<any>";default:return z}}return"unknown"}function c(J){let Y=J.trimStart(),X=5;while(X<Y.length&&Y.charCodeAt(X)<=32)X++;let Q=X;if(X<Y.length&&P(Y.charCodeAt(X))){while(X<Y.length&&P(Y.charCodeAt(X)))X++;return`typeof ${Y.slice(Q,X)}`}return"{ new (...args: any[]): any }"}function f(J,Y,X=0){if(J.startsWith("Promise.resolve(")){let z=J.indexOf(")",16);if(z!==-1){let B=J.slice(16,z).trim();if(B)return`Promise<${V(B,Y,!1,X+1)}>`}return"Promise<unknown>"}if(J.startsWith("Promise.reject("))return"Promise<never>";if(J.startsWith("Promise.all(")){let Q=J.indexOf("[",12),z=J.lastIndexOf("]");if(Q!==-1&&z>Q){let B=J.slice(Q+1,z).trim(),Z=w(B),$=[];for(let H=0;H<Z.length;H++){let L=Z[H].trim();if(L.startsWith("Promise.resolve(")){let O=f(L,Y,X+1),G=O.indexOf("<"),W=O.lastIndexOf(">");$.push(G!==-1&&W>G?O.slice(G+1,W):"unknown")}else $.push(V(L,Y,!1,X+1))}return`Promise<[${$.join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function I(J,Y,X=0){let Q=J.slice(1,-1).trim();if(!Q)return"never[]";if(X>=20)return"unknown[]";let z=w(Q),B=!1;for(let W=0;W<z.length;W++){let K=z[W],F=K.length;while(F>0&&K.charCodeAt(F-1)<=32)F--;if(F>=8&&K.slice(F-8,F)==="as const"){B=!0;break}}if(B){let W=[];for(let K=0;K<z.length;K++){let F=z[K].trim();if(F.endsWith("as const")){let q=F.slice(0,-8).trim();if(q.startsWith("[")&&q.endsWith("]")){let N=q.slice(1,-1).trim(),U=w(N),R=[];for(let b=0;b<U.length;b++)R.push(V(U[b].trim(),!0,!1,X+1));W.push(`readonly [${R.join(", ")}]`)}else W.push(V(q,!0,!1,X+1))}else if(F.startsWith("[")&&F.endsWith("]"))W.push(I(F,!0,X+1));else W.push(V(F,!0,!1,X+1))}return`readonly [
3
+ ${W.join(` |
4
+ `)}
5
+ ]`}let Z=E&&!Y,$=[],H=[];for(let W of z){let K=W.trim(),F=M;if(M=null,K.startsWith("[")&&K.endsWith("]"))$.push(I(K,Y,X+1));else $.push(l(K,Y,X+1));if(Z)H.push(M);M=F}if(Z)if(g(J))M=_(J);else{let W=[];for(let K=0;K<z.length;K++){let F=z[K].trim();if(F.endsWith("as const"))continue;if(x(F)||F==="null"||F==="undefined")W.push(F);else if(F.startsWith("[")&&g(F))W.push(_(F));else if(F.startsWith("{")){if(H[K])W.push(H[K])}else{let q=V(F,!1,!1,0);if(q!=="unknown")W.push(q)}}if(W.length>0)M=`[${W.join(", ")}]`}if(Y)return`readonly [${$.join(", ")}]`;let L=new Set,O=[],G=!0;for(let W of $){if(!L.has(W))L.add(W),O.push(W);if(G){if(!(S(W)||W==="true"||W==="false"||W.charCodeAt(0)===34&&W.charCodeAt(W.length-1)===34||W.charCodeAt(0)===39&&W.charCodeAt(W.length-1)===39))G=!1}}if(G&&$.length<=10)return`readonly [${$.join(", ")}]`;if(O.length===1)return`${O[0]}[]`;return`(${O.join(" | ")})[]`}function w(J){let Y=[],X=0,Q=0,z=!1,B=0;for(let $=0;$<J.length;$++){let H=J.charCodeAt($);if(!z&&(H===34||H===39||H===96))z=!0,B=H;else if(z&&H===B&&($===0||J.charCodeAt($-1)!==92))z=!1;if(!z){if(H===91||H===123||H===40)Q++;else if(H===93||H===125||H===41)Q--;else if(H===44&&Q===0){let L=J.substring(X,$).trim();if(L)Y.push(L);X=$+1;continue}}}let Z=J.substring(X).trim();if(Z)Y.push(Z);return Y}function x(J){if(S(J))return!0;if(J==="true"||J==="false")return!0;if(J.startsWith('"')&&J.endsWith('"')||J.startsWith("'")&&J.endsWith("'"))return!0;return!1}function m(J){return J==="number"||J==="string"||J==="boolean"}function g(J){let Y=!1,X=0,Q=J.length;for(let z=0;z<Q;z++){let B=J.charCodeAt(z);if(Y){if(B===92){z++;continue}if(B===X)Y=!1;continue}if(B===34||B===39||B===96){Y=!0,X=B;continue}if(B===61&&z+1<Q&&J.charCodeAt(z+1)===62)return!1;if(B>=97&&B<=122){let Z=z;while(z<Q&&(J.charCodeAt(z)>=97&&J.charCodeAt(z)<=122||J.charCodeAt(z)>=65&&J.charCodeAt(z)<=90||J.charCodeAt(z)>=48&&J.charCodeAt(z)<=57||J.charCodeAt(z)===95||J.charCodeAt(z)===36))z++;let $=J.slice(Z,z);if($==="new"||$==="async"||$==="await"||$==="function"||$==="yield"||$==="console"||$==="process")return!1;let H=z;while(H<Q&&J.charCodeAt(H)<=32)H++;if(H<Q&&J.charCodeAt(H)===40)return!1;z--}}return!0}function s(J,Y,X=0){let Q=J.slice(1,-1).trim();if(!Q)return"{}";if(X>=20)return"Record<string, unknown>";let z=a(Q),B=[],Z=E&&!Y,$=[];for(let[H,L]of z){let O=M;M=null;let G,W=L.trim();if(e(W))G=zz(H,W);else if(G=V(L,Y,!1,X+1),G.includes("=>")||G.includes("function")||G.includes("async"))G=i(G);let K=M;M=O;let F=L.trim(),q=r(H);if(q){let N=t(q.kind,q.name,G);if(N){B.push(N);continue}}if(!Y&&m(G)&&x(F))B.push(`/** @defaultValue ${F} */
6
+ ${H}: ${G}`);else B.push(`${H}: ${G}`);if(Z){let N=h(H);if(F.endsWith("as const"));else if(x(F))$.push(`${N}: ${F}`);else if(F.startsWith("[")&&g(F))$.push(`${N}: ${_(F)}`);else if(F.startsWith("{")){if(K)$.push(`${N}: ${K}`)}else if(!F.startsWith("[")&&(F.includes("=>")||F.startsWith("function")||F.startsWith("async"))){let U=y(F,!1,0,!0);$.push(`${N}: ${U}`)}}}if(Z&&$.length>0){let H=X>0?(X-1)/2:0,L=`{ ${$.join(", ")} }`;if(L.length<=80)M=L;else{let O=" ".repeat((H+1)*2),G=" ".repeat(H*2);M=`{
7
+ ${O}${$.join(`,
8
+ ${O}`)}
9
+ ${G}}`}}return`{
10
+ ${B.join(`;
11
+ `)}
12
+ }`}function i(J){let X=J.split(`
13
+ `).map((O)=>C(O)).join(`
14
+ `),Q=X.indexOf("async");if(Q!==-1){let O=Q>0?X.charCodeAt(Q-1):32,G=Q+5<X.length?X.charCodeAt(Q+5):32;if(!P(O)&&!P(G))X=(X.slice(0,Q)+X.slice(Q+5)).trim()}let z=X.indexOf("(");if(z!==-1){let O=j(X,z,"(",")");if(O!==-1){let G=X.slice(z,O+1),W=k(G);X=X.slice(0,z)+W+X.slice(O+1)}}let B=X.length,Z="",$=[],H=!1,L=!1;for(let O=0;O<B;O++){let G=X.charCodeAt(O);if(G===123||G===40)$.push(G);else if(G===125||G===41)$.pop();if(G<=32){if(H=!0,G===10||G===13)L=!0;continue}if(H&&Z.length>0){let K=($.length>0?$[$.length-1]:0)===123;if(L&&K){let F=Z.charCodeAt(Z.length-1),q=F===59||F===44||F===123||G===125,N=Z.length>=2&&Z.charCodeAt(Z.length-1)===47&&Z.charCodeAt(Z.length-2)===42;if(!q&&!N)Z+="; ";else Z+=" "}else Z+=" "}H=!1,L=!1,Z+=X[O]}return Z.trim()}function P(J){return J>=97&&J<=122||J>=65&&J<=90||J>=48&&J<=57||J===95||J===36}function k(J){let Y=J.trim(),X,Q=!1;if(Y.startsWith("(")&&Y.endsWith(")"))X=Y.slice(1,-1),Q=!0;else X=Y;let z=X.trim();if(!z)return Q?"()":"";let B=!1;{let F=0;for(let q=0;q<z.length;q++){let N=z.charCodeAt(q);if(N===40||N===60||N===91||N===123)F++;else if(N===41||N===62||N===93||N===125)F--;else if(F===0&&N===61){let U=q>0?z.charCodeAt(q-1):0,R=q+1<z.length?z.charCodeAt(q+1):0;if(U!==61&&U!==33&&U!==60&&U!==62&&R!==61&&R!==62){B=!0;break}}}}if(!B)return Y;let Z=[],$=[],H=0,L=0,O=!1,G=0;for(let F=0;F<=z.length;F++){if(F===z.length){Z.push(z.slice(H));break}let q=z.charCodeAt(F);if(O){if(q===92){F++;continue}if(q===G)O=!1;continue}if(q===47&&F+1<z.length){let N=z.charCodeAt(F+1);if(N===42){F+=2;while(F+1<z.length&&!(z.charCodeAt(F)===42&&z.charCodeAt(F+1)===47))F++;F++;continue}if(N===47){while(F<z.length&&z.charCodeAt(F)!==10)F++;continue}}if(q===39||q===34||q===96){O=!0,G=q;continue}if(q===40||q===60||q===91||q===123)L++;else if(q===41||q===62||q===93||q===125)L--;else if(q===44&&L===0){Z.push(z.slice(H,F));let N=",",U=F+1;while(U<z.length&&z.charCodeAt(U)<=32)N+=z[U],U++;$.push(N),H=U}}let W=[];for(let F of Z){let q=F.trim();if(!q){W.push(F);continue}if(q.startsWith("//"))continue;let N=C(q),U=F.slice(0,F.length-F.trimStart().length);W.push(U+n(N))}let K=W[0]||"";for(let F=1;F<W.length;F++)K+=($[F-1]||", ")+W[F];return Q?`(${K})`:K}function C(J){let Y=!1,X=0;for(let Q=0;Q<J.length-1;Q++){let z=J.charCodeAt(Q);if(Y){if(z===92){Q++;continue}if(z===X)Y=!1;continue}if(z===39||z===34||z===96){Y=!0,X=z;continue}if(z===47&&J.charCodeAt(Q+1)===47)return J.slice(0,Q).trimEnd()}return J}function n(J){if(J.startsWith("..."))return J;let Y=-1,X=-1,Q=0,z=!1,B=0;for(let $=0;$<J.length;$++){let H=J.charCodeAt($);if(z){if(H===92){$++;continue}if(H===B)z=!1;continue}if(H===47&&$+1<J.length){let L=J.charCodeAt($+1);if(L===42){$+=2;while($+1<J.length&&!(J.charCodeAt($)===42&&J.charCodeAt($+1)===47))$++;$++;continue}if(L===47){while($<J.length&&J.charCodeAt($)!==10)$++;continue}}if(H===39||H===34||H===96){z=!0,B=H;continue}if(H===40||H===60||H===91||H===123)Q++;else if(H===41||H===62||H===93||H===125)Q--;else if(Q===0){if(H===58&&Y===-1)Y=$;else if(H===61&&X===-1&&($===0||J.charCodeAt($-1)!==61)&&($+1>=J.length||J.charCodeAt($+1)!==61&&J.charCodeAt($+1)!==62))X=$}}let Z=X!==-1;if(Y!==-1&&(X===-1||Y<X)){let $=J.slice(0,Y).trim(),H=X!==-1?J.slice(Y+1,X).trim():J.slice(Y+1).trim(),L=Z&&!$.endsWith("?")?"?":"";return`${$}${L}: ${H}`}else if(X!==-1){let $=J.slice(0,X).trim(),H=!$.endsWith("?")?"?":"",L=J.slice(X+1).trim(),O="unknown";if(L==="true"||L==="false")O="boolean";else if(/^-?\d+(\.\d+)?$/.test(L))O="number";else if(L.startsWith("'")&&L.endsWith("'")||L.startsWith('"')&&L.endsWith('"'))O="string";else if(L.startsWith("["))O="unknown[]";else if(L.startsWith("{"))O="Record<string, unknown>";return`${$}${H}: ${O}`}return J}function a(J){let Y=[],X="",Q="",z=0,B=!1,Z="",$=!0,H=!1,L=0;for(let O=0;O<J.length;O++){let G=J.charCodeAt(O),W=O>0?J.charCodeAt(O-1):0,K=O<J.length-1?J.charCodeAt(O+1):0;if(!B&&!H&&G===47&&K===47){O+=2;while(O<J.length&&J.charCodeAt(O)!==10)O++;continue}if(!B&&!H&&G===47&&K===42){H=!0,L=1,X+="/*",O++;continue}else if(H&&G===42&&K===47){if(L--,X+="*/",O++,L===0)H=!1;continue}else if(H&&G===47&&K===42){L++,X+="/*",O++;continue}let F=J[O];if(!B&&(G===34||G===39||G===96))B=!0,Z=F,X+=F;else if(B&&F===Z&&W!==92)B=!1,X+=F;else if(!B&&!H)if(G===40&&z===0&&$){Q=X.trim();let q="";if(Q.startsWith("async "))Q=Q.slice(6).trim(),q="async ";if(Q.startsWith("*"))Q=Q.slice(1).trim(),q+="*";X=q+F,$=!1,z=1}else if(G===123||G===91||G===40)z++,X+=F;else if(G===125||G===93||G===41)z--,X+=F;else if(G===58&&z===0&&$)Q=X.trim(),X="",$=!1;else if(G===44&&z===0){if(Q&&X.trim()){let q=X.trim();Y.push([Q,q])}X="",Q="",$=!0}else X+=F;else X+=F}if(Q&&X.trim()){let O=X.trim();Y.push([Q,O])}return Y}function r(J){let Y=J.trim();if(Y.startsWith("get ")&&Y.length>4){let X=Y.slice(4).trim();if(X)return{kind:"get",name:X}}if(Y.startsWith("set ")&&Y.length>4){let X=Y.slice(4).trim();if(X)return{kind:"set",name:X}}return null}function t(J,Y,X){let Q=X.trim();if(Q.charCodeAt(0)!==40)return null;let z=j(Q,0,"(",")");if(z===-1)return null;let B=Q.slice(1,z).trim(),Z=Q.slice(z+1).trimStart();if(!Z.startsWith("=>"))return null;let $=Z.slice(2).trim();if(J==="get")return`get ${Y}(): ${$||"unknown"}`;return`set ${Y}(${B})`}function e(J){let Y=J;if(Y.startsWith("async ")||Y.startsWith("async\t"))Y=Y.slice(5).trimStart();if(Y.startsWith("*"))Y=Y.slice(1).trimStart();if(!Y.startsWith("("))return!1;let X=0;for(let Q=0;Q<Y.length;Q++){let z=Y.charCodeAt(Q);if(z===40)X++;else if(z===41){if(X--,X===0){let B=Y.slice(Q+1).trimStart();if(B.startsWith("{"))return!0;if(B.startsWith(":")){let Z=0;for(let $=0;$<B.length;$++){let H=B.charCodeAt($);if(H===40||H===91)Z++;else if(H===41||H===93)Z--;else if(H===60)Z++;else if(H===62){if(Z>0)Z--}else if(Z===0&&H===61&&$+1<B.length&&B.charCodeAt($+1)===62)return!1;else if(Z===0&&H===123)return!0}}return!1}}}return!1}function zz(J,Y){let X=Y.trimStart(),Q=!1,z=!1;if(X.startsWith("async ")||X.startsWith("async\t"))Q=!0,X=X.slice(5).trimStart();if(X.startsWith("*"))z=!0,X=X.slice(1).trimStart();let B="";if(X.charCodeAt(0)===60){let W=0,K=-1;for(let F=0;F<X.length;F++)if(X.charCodeAt(F)===60)W++;else if(X.charCodeAt(F)===62){if(W--,W===0){K=F;break}}if(K!==-1)B=X.slice(0,K+1),X=X.slice(K+1).trimStart()}let Z=X.indexOf("("),$=j(X,Z,"(",")");if(Z===-1||$===-1)return"() => unknown";let H=X.slice(Z,$+1),L="unknown",O=X.slice($+1).trimStart();if(O.charCodeAt(0)===58){let W=O.slice(1),K=0,F=-1,q=!1;for(let N=0;N<W.length;N++){let U=W.charCodeAt(N);if(U===40||U===91)K++;else if(U===41||U===93)K--;else if(U===123&&K===0){F=N;break}else if(U===61&&N+1<W.length&&W.charCodeAt(N+1)===62&&K===0){F=N,q=!0;break}}if(F!==-1)L=W.slice(0,F).trim();else L=W.trim()}if(L==="unknown"){if(Q&&z)L="AsyncGenerator<unknown, void, unknown>";else if(z)L="Generator<unknown, void, unknown>";else if(Q)L="Promise<void>"}else if(Q&&!L.startsWith("Promise<")&&!L.startsWith("AsyncGenerator<"))L=`Promise<${L}>`;let G=k(H);return`${B}${G} => ${L}`}function j(J,Y,X,Q){let z=0;for(let B=Y;B<J.length;B++)if(J[B]===X)z++;else if(J[B]===Q){if(z--,z===0)return B}return-1}function Jz(J){let Y=0,X=0,Q=!1,z="";for(let B=0;B<J.length-1;B++){let Z=J[B],$=J[B+1],H=B>0?J[B-1]:"";if(!Q&&(Z==='"'||Z==="'"||Z==="`"))Q=!0,z=Z;else if(Q&&Z===z&&H!=="\\")Q=!1;if(!Q){if(Z==="(")Y++;else if(Z===")")Y--;else if(Z==="[")X++;else if(Z==="]")X--;if(Z==="="&&$===">"&&Y===0&&X===0)return B}}return-1}function y(J,Y=!1,X=0,Q=!0){let z=J.trim();if(z.length>200&&D(z,"=>")>2&&D(z,"<")>5&&!z.startsWith("function"))return Y?"((...args: any[]) => any)":"(...args: any[]) => any";if(z.startsWith("async ")&&z.includes("=>")){let Z=z.slice(5).trim(),$=Z.indexOf("=>"),H=Z.substring(0,$).trim(),L=Z.substring($+2).trim();if(H=k(H),H==="()"||H==="")H="()";else if(!H.startsWith("("))H=`(${H})`;let O="unknown";if(L.startsWith("{"))O="unknown";else O=V(L,Q,!1,X+1);let G=`${H} => Promise<${O}>`;return Y?`(${G})`:G}if(z.includes("=>")){let Z="",$=z;if(z.startsWith("<")){let q=j(z,0,"<",">");if(q!==-1)Z=z.substring(0,q+1),$=z.substring(q+1).trim()}let H=Jz($);if(H===-1)return Y?"(() => unknown)":"() => unknown";let L=$.substring(0,H).trim(),O=$.substring(H+2).trim(),G="",W=L.lastIndexOf("):");if(W!==-1){let q=L.substring(W+2).trim();if(q&&!q.includes("=>")&&!q.includes("="))G=q,L=L.substring(0,W+1)}if(L=k(L),L==="()"||L==="")L="()";else if(!L.startsWith("("))L=`(${L})`;let K="unknown";if(G)K=G;else if(O.startsWith("{"))K="unknown";else if(O.includes("=>")){let q=O.trimStart(),N=q.indexOf("("),U=N!==-1?j(q,N,"(",")"):-1,R=U!==-1?q.indexOf("=>",U):-1;if(N===0&&U!==-1&&R!==-1){let b=q.substring(N+1,U).trim(),A=k(b);if(Z.includes("T")&&A.includes("T"))K=`(${A}) => T`;else K=`(${A}) => any`}else K="any"}else if(Y)K="unknown";else K=V(O,Q,!1,X+1);let F=`${Z}${L} => ${K}`;return Y?`(${F})`:F}if(z.startsWith("function")){let Z=8,$=z.length;while(Z<$&&z.charCodeAt(Z)<=32)Z++;let H=!1;if(Z<$&&z.charCodeAt(Z)===42){H=!0,Z++;while(Z<$&&z.charCodeAt(Z)<=32)Z++}let L="";if(Z<$&&z.charCodeAt(Z)===60){let W=Z,K=1;Z++;while(Z<$&&K>0){let F=z.charCodeAt(Z);if(F===60)K++;else if(F===62)K--;Z++}L=z.substring(W,Z);while(Z<$&&z.charCodeAt(Z)<=32)Z++}let O=z.indexOf("(",Z);if(O!==-1){let W=1,K=O+1;while(K<$&&W>0){let U=z.charCodeAt(K);if(U===40)W++;else if(U===41)W--;K++}let F=z.substring(O+1,K-1).trim(),q=F?`(${F})`:"()";if(H){let U=z.substring(K).trim(),R=U.indexOf("Generator<");if(R!==-1){let A=R+10,T=U.indexOf(">",A);if(T!==-1){let u=U.substring(A,T),v=`${L}${q} => Generator<${u}>`;return Y?`(${v})`:v}}let b=`${L}${q} => Generator<any, any, any>`;return Y?`(${b})`:b}let N=`${L}${q} => unknown`;return Y?`(${N})`:N}let G="(...args: any[]) => unknown";return Y?`(${G})`:G}if(z.includes("=>")&&z.includes("(")&&z.includes(")")){if(z.length>100||D(z,"=>")>2){let Z="";if(z.charCodeAt(0)===60){let G=j(z,0,"<",">");if(G!==-1)Z=z.substring(0,G+1)}let $=z.indexOf("("),H=$!==-1?j(z,$,"(",")"):-1,L=$!==-1&&H!==-1?z.substring($,H+1):"(...args: any[])";L=k(L);let O=`${Z}${L} => any`;return Y?`(${O})`:O}return Y?`(${z})`:z}let B="() => unknown";return Y?`(${B})`:B}function Hz(J){let Y=J.trim();if(Y==="any"||Y==="object"||Y==="unknown")return!0;if(Y.startsWith("Record<")&&Y.endsWith(">"))return!0;if(Y.startsWith("Array<")&&Y.endsWith(">"))return!0;if(/^\{\s*\[[^\]]*\]:\s*(any|string|number|unknown)\s*\}$/.test(Y))return!0;return!1}function Fz(J){let Y=J.lastIndexOf(" satisfies ");if(Y===-1)return null;let X=J.slice(Y+11).trim();if(X.endsWith(";"))X=X.slice(0,-1).trim();return X||null}var Xz=/^\/\/\/\s*<reference\s+(?:path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/,Yz=/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/,Zz=/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/;function Lz(J){let Y=[],X=0;for(let Q=0;Q<=J.length;Q++)if(Q===J.length||J[Q]===`
15
+ `){let z=X,B=Q;while(z<B&&(J[z]===" "||J[z]==="\t"||J[z]==="\r"))z++;while(B>z&&(J[B-1]===" "||J[B-1]==="\t"||J[B-1]==="\r"))B--;let Z=J.slice(z,B);if(X=Q+1,Z.startsWith("///")){if(Z.indexOf("<")===-1)continue;if(Xz.test(Z)||Yz.test(Z)||Zz.test(Z))Y.push(Z)}else if(Z===""||Z.startsWith("//"))continue;else break}return Y}
16
+ export{$z as Dc,Qz as Ec,V as Fc,l as Gc,I as Hc,w as Ic,s as Jc,j as Kc,y as Lc,Hz as Mc,Fz as Nc,Lz as Oc};
@@ -0,0 +1,19 @@
1
+ // @bun
2
+ import{hc as E}from"./chunk-2n1bbm2c.js";import{lc as c,mc as Bq,nc as Oq}from"./chunk-jjwwkrfk.js";import{Fc as Rq}from"./chunk-4jw8qvts.js";import{bd as N}from"./chunk-mcdb3q06.js";var L=N(E(),1);var A=N(E(),1);var v=new Map,T=new Map,Lq=100;function _q(){while(v.size>Lq){let q=v.keys().next().value;if(q===void 0)break;v.delete(q)}}function wq(){v.clear()}function Iq(){return v.size}var Yq={asyncThreshold:1e5,chunkSize:50000,yieldInterval:0};function l(q){return new Promise(($)=>{if(q===0)if(typeof setImmediate<"u")setImmediate($);else setTimeout($,0);else setTimeout($,q)})}async function vq(q,$,Q){if($.length<Q.asyncThreshold)return A.createSourceFile(q,$,A.ScriptTarget.Latest,!0,A.ScriptKind.TS);await l(Q.yieldInterval);let W=A.createSourceFile(q,$,A.ScriptTarget.Latest,!1,A.ScriptKind.TS);return await l(Q.yieldInterval),W}async function h(q,$,Q={}){let W={...Yq,...Q},X=c($),Z=q,U=Date.now(),V=v.get(Z);if(V&&V.contentHash===X)return V.lastAccess=U,v.delete(Z),v.set(Z,V),V.sourceFile;let j=T.get(Z);if(j)return j;let w=(async()=>{try{let H=await vq(q,$,W);return v.set(Z,{sourceFile:H,contentHash:X,lastAccess:U}),_q(),H}finally{T.delete(Z)}})();return T.set(Z,w),w}async function Aq(q,$={}){let Q=$.concurrency??4,W=new Map,X=[];for(let Z=0;Z<q.length;Z+=Q){let U=q.slice(Z,Z+Q),V=await Promise.allSettled(U.map(async({filePath:j,sourceCode:w})=>{let H=await h(j,w,$);return{filePath:j,sourceFile:H}}));for(let j=0;j<V.length;j++){let w=V[j];if(w.status==="fulfilled")W.set(w.value.filePath,w.value.sourceFile);else X.push({filePath:U[j].filePath,error:w.reason})}if(Z+Q<q.length)await l(0)}if(X.length>0)console.warn(`[dtsx] ${X.length} file(s) failed to parse:`,X.map((Z)=>Z.filePath));return W}function kq(q,$={}){let Q=$.asyncThreshold??Yq.asyncThreshold;return q.length>=Q}function Kq(){return T.size}var R=N(E(),1);var Y=N(E(),1);var O=N(E(),1);function M(q,$,Q){return $.slice(Q?q.getStart(Q):q.getStart(),q.getEnd())}var Hq=/\/\*[\s\S]*?\*\//g;function I(q,$){let Q=[],W=q.getFullStart(),X=q.getStart($);if(W===X)return Q;let Z=$.text.substring(W,X);if(Z.indexOf("/*")!==-1){Hq.lastIndex=0;let U;while((U=Hq.exec(Z))!==null)Q.push(U[0])}if(Z.indexOf("//")!==-1){let U=Z.split(`
3
+ `),V=[];for(let j=U.length-1;j>=0;j--){let w=U[j].trim();if(w.startsWith("//"))V.unshift(w);else if(w==="")continue;else break}if(V.length>0)Q.push(V.join(`
4
+ `))}return Q}function k(q,$){if(O.isObjectBindingPattern(q.name)){let Q=q.name.elements.map((W)=>{if(O.isBindingElement(W)&&O.isIdentifier(W.name))return W.name.getText($);return""}).filter(Boolean);if(Q.length>3)return`{
5
+ ${Q.join(`,
6
+ `)},
7
+ }`;return`{ ${Q.join(", ")} }`}else if(O.isArrayBindingPattern(q.name))return`[${q.name.elements.map((W)=>{if(W&&O.isBindingElement(W)&&O.isIdentifier(W.name))return W.name.getText($);return""}).filter(Boolean).join(", ")}]`;else return q.name.getText($)}function B(q){if(!("modifiers"in q)||!q.modifiers)return!1;return q.modifiers.some((Q)=>Q.kind===O.SyntaxKind.ExportKeyword)}function g(q){if(!("modifiers"in q)||!q.modifiers)return!1;return q.modifiers.some((Q)=>Q.kind===O.SyntaxKind.DefaultKeyword)}function d(q){return q.modifiers?.some(($)=>$.kind===O.SyntaxKind.AsyncKeyword)||!1}function m(q,$){return!1}var S=new Map;function i(q,$){let Q=S.get(q);if(!Q){let W=q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(Q={funcPattern:new RegExp(`export\\s+[^\\n]*:\\s*[^\\n]*\\b${W}\\b`,"gm"),typePattern:new RegExp(`export\\s+[^\\n]*\\b${W}\\b`,"gm")},S.set(q,Q),S.size>200){let X=Array.from(S.keys()).slice(0,50);for(let Z of X)S.delete(Z)}}return Q.funcPattern.lastIndex=0,Q.typePattern.lastIndex=0,Q.funcPattern.test($)||Q.typePattern.test($)}var Mq=new Set(["string","number","boolean","object","any","unknown","never","void","undefined","null","Array","Promise","Record","Partial","Required","Pick","Omit","Exclude","Extract","NonNullable","ReturnType","Parameters","ConstructorParameters","InstanceType","ThisType","Function","Date","RegExp","Error","Map","Set","WeakMap","WeakSet","T","K","V","U","R","P","E","A","B","C","D","F","G","H","I","J","L","M","N","O","Q","S","W","X","Y","Z"]);function t(q){return Mq.has(q)}var Jq=/(?:export\s+)?(?:declare\s+)?(?:const\s+)?(?:interface|type|class|enum)\s+([A-Z][a-zA-Z0-9]*)/g;function a(q){let $=[];Jq.lastIndex=0;let Q;while((Q=Jq.exec(q))!==null)$.push(Q[1]);return $}var Dq=/\s+as\s+(\S+)\s*$/;function K(q,$){let Q=q.trim();if(!Q.endsWith("as const")){let X=Q.match(Dq);if(X)return X[1]}let W=Rq(Q,$);if(W==="unknown")return"unknown";if(!$){if(W==="true"||W==="false")return"boolean";if(/^-?\d+(\.\d+)?$/.test(W))return"number";if(W.startsWith('"')&&W.endsWith('"')||W.startsWith("'")&&W.endsWith("'"))return"string"}return W}function n(q,$){let Q=[],W=q.modifiers?.some((j)=>j.kind===Y.SyntaxKind.AsyncKeyword),X=!!q.asteriskToken,Z=B(q)&&g(q);if(B(q))Q.push("export ");if(Z)Q.push("default function ");else Q.push("declare function ");if(q.name)Q.push(q.name.getText($));if(q.typeParameters){let j=q.typeParameters.map((w)=>w.getText($)).join(", ");Q.push("<",j,">")}let U=q.parameters.map((j)=>{let w=k(j,$),H=j.type?.getText($)||(j.initializer?K(j.initializer.getText($),!1):"unknown"),G=j.questionToken||j.initializer?"?":"";if(!!j.dotDotDotToken)return`...${w}: ${H}`;return`${w}${G}: ${H}`}).join(", ");Q.push("(",U,")");let V=q.type?.getText($);if(!V)if(W&&X)V="AsyncGenerator<unknown, void, unknown>";else if(X)V="Generator<unknown, void, unknown>";else if(W)V="Promise<void>";else V="void";return Q.push(": ",V,";"),Q.join("")}function s(q,$,Q,W){let X=[];if(W)X.push("export ");if(X.push("declare ",Q," ",q),$)X.push(": ",$);return X.push(";"),X.join("")}function r(q,$,Q){let W=[];if($)W.push("export ");if(W.push("declare interface ",q.name.getText(Q)),q.typeParameters){let Z=q.typeParameters.map((U)=>U.getText(Q)).join(", ");W.push("<",Z,">")}if(q.heritageClauses){let Z=q.heritageClauses.find((U)=>U.token===Y.SyntaxKind.ExtendsKeyword);if(Z){let U=Z.types.map((V)=>V.getText(Q)).join(", ");W.push(" extends ",U)}}let X=o(q,Q);return W.push(" ",X),W.join("")}function Gq(q,$){if(!q.name)return"";return q.name.getText($)}function o(q,$){let Q=[];for(let W of q.members)if(Y.isPropertySignature(W)){let X=Gq(W,$),Z=W.type?.getText($)||"unknown",U=W.questionToken?"?":"",V=W.modifiers?.some((j)=>j.kind===Y.SyntaxKind.ReadonlyKeyword)?"readonly ":"";Q.push(` ${V}${X}${U}: ${Z}`)}else if(Y.isMethodSignature(W)){let X=Gq(W,$),Z="";if(W.typeParameters&&W.typeParameters.length>0)Z=`<${W.typeParameters.map((w)=>w.getText($)).join(", ")}>`;let U=W.parameters.map((w)=>{let H=w.name.getText($),G=w.type?.getText($)||"unknown",J=w.questionToken?"?":"";if(!!w.dotDotDotToken)return`...${H}: ${G}`;return`${H}${J}: ${G}`}).join(", "),V=W.type?.getText($)||"void",j=W.questionToken?"?":"";Q.push(` ${X}${j}${Z}(${U}): ${V}`)}else if(Y.isCallSignatureDeclaration(W)){let X=W.parameters.map((U)=>{let V=U.name.getText($),j=U.type?.getText($)||"unknown",w=U.questionToken?"?":"";if(!!U.dotDotDotToken)return`...${V}: ${j}`;return`${V}${w}: ${j}`}).join(", "),Z=W.type?.getText($)||"void";Q.push(` (${X}): ${Z}`)}else if(Y.isConstructSignatureDeclaration(W)){let X=W.parameters.map((U)=>{let V=U.name.getText($),j=U.type?.getText($)||"unknown",w=U.questionToken?"?":"";if(!!U.dotDotDotToken)return`...${V}: ${j}`;return`${V}${w}: ${j}`}).join(", "),Z=W.type?.getText($)||"unknown";Q.push(` new (${X}): ${Z}`)}else if(Y.isIndexSignatureDeclaration(W)){let X=W.parameters.map((U)=>{let V=U.name.getText($),j=U.type?.getText($)||"any";return`${V}: ${j}`}).join(", "),Z=W.type?.getText($)||"unknown";Q.push(` [${X}]: ${Z}`)}return`{
8
+ ${Q.join(`
9
+ `)}
10
+ }`}function e(q,$,Q){let W=[];if($)W.push("export ");if(W.push("type ",q.name.getText(Q)),q.typeParameters){let X=q.typeParameters.map((Z)=>Z.getText(Q)).join(", ");W.push("<",X,">")}return W.push(" = ",q.type.getText(Q)),W.join("")}function qq(q,$,Q,W=!1){let X=[];if($)X.push("export ");if(W)X.push("default ");else X.push("declare ");if(q.modifiers?.some((j)=>j.kind===Y.SyntaxKind.AbstractKeyword))X.push("abstract ");if(X.push("class ",q.name?.getText(Q)||"AnonymousClass"),q.typeParameters){let j=q.typeParameters.map((w)=>w.getText(Q)).join(", ");X.push("<",j,">")}let U=q.heritageClauses?.find((j)=>j.token===Y.SyntaxKind.ExtendsKeyword)?.types[0]?.getText(Q);if(U)X.push(" extends ",U);let V=q.heritageClauses?.find((j)=>j.token===Y.SyntaxKind.ImplementsKeyword)?.types.map((j)=>j.getText(Q));if(V&&V.length>0)X.push(" implements ",V.join(", "));return X.push(" ",zq(q,Q)),X.join("")}function b(q,$,Q,W,X){let Z=[" "];if(W)Z.push("private ");else if(X)Z.push("protected ");if(q)Z.push("static ");if($)Z.push("abstract ");if(Q)Z.push("readonly ");return Z.join("")}function x(q){return q.name?Y.isPrivateIdentifier(q.name):!1}function F(q,$){if(!q.name)return"";return q.name.getText($)}function zq(q,$){let Q=[];for(let W of q.members){if(W.kind===Y.SyntaxKind.ClassStaticBlockDeclaration)continue;if(Y.isConstructorDeclaration(W)){for(let Z of W.parameters)if(Z.modifiers&&Z.modifiers.length>0){if(Z.modifiers.some((J)=>J.kind===Y.SyntaxKind.PrivateKeyword))continue;let V=k(Z,$),j=Z.type?.getText($)||(Z.initializer?K(Z.initializer.getText($),!1):"unknown"),w=Z.questionToken||Z.initializer?"?":"",H=Z.modifiers.map((J)=>J.getText($)).join(" "),G=H?`${H} `:"";Q.push(` ${G}${V}${w}: ${j};`)}let X=W.parameters.map((Z)=>{let U=k(Z,$),V=Z.type?.getText($)||(Z.initializer?K(Z.initializer.getText($),!1):"unknown"),j=Z.questionToken||Z.initializer?"?":"";return`${U}${j}: ${V}`}).join(", ");Q.push(` constructor(${X});`)}else if(Y.isMethodDeclaration(W)){if(x(W))continue;if(W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.PrivateKeyword))continue;let Z=F(W,$),U=!!W.asteriskToken,j=[b(!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.StaticKeyword),!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.AbstractKeyword),!1,!1,!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.ProtectedKeyword))];if(U)j.push("*");if(j.push(Z),W.typeParameters){let J=W.typeParameters.map((z)=>z.getText($)).join(", ");j.push("<",J,">")}let w=W.parameters.map((J)=>{let z=k(J,$),_=J.type?.getText($)||(J.initializer?K(J.initializer.getText($),!1):"unknown"),D=J.questionToken||J.initializer?"?":"";return`${z}${D}: ${_}`}).join(", ");j.push("(",w,")");let H=!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.AsyncKeyword),G=W.type?.getText($);if(!G)if(H&&U)G="AsyncGenerator<unknown, void, unknown>";else if(U)G="Generator<unknown, void, unknown>";else if(H)G="Promise<void>";else G="void";j.push(": ",G,";"),Q.push(j.join(""))}else if(Y.isPropertyDeclaration(W)){if(x(W))continue;if(W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.PrivateKeyword))continue;let Z=F(W,$),U=b(!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.StaticKeyword),!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.AbstractKeyword),!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.ReadonlyKeyword),!1,!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.ProtectedKeyword)),V=W.questionToken?"?":"",j=!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.StaticKeyword),w=!!W.modifiers?.some((J)=>J.kind===Y.SyntaxKind.ReadonlyKeyword),H=j&&w,G=W.type?.getText($)||(W.initializer?K(W.initializer.getText($),H):"unknown");Q.push(`${U}${Z}${V}: ${G};`)}else if(Y.isGetAccessorDeclaration(W)){if(x(W))continue;if(W.modifiers?.some((j)=>j.kind===Y.SyntaxKind.PrivateKeyword))continue;let Z=F(W,$),U=b(!!W.modifiers?.some((j)=>j.kind===Y.SyntaxKind.StaticKeyword),!!W.modifiers?.some((j)=>j.kind===Y.SyntaxKind.AbstractKeyword),!1,!1,!!W.modifiers?.some((j)=>j.kind===Y.SyntaxKind.ProtectedKeyword)),V=W.type?.getText($)||"unknown";Q.push(`${U}get ${Z}(): ${V};`)}else if(Y.isSetAccessorDeclaration(W)){if(x(W))continue;if(W.modifiers?.some((H)=>H.kind===Y.SyntaxKind.PrivateKeyword))continue;let Z=F(W,$),U=b(!!W.modifiers?.some((H)=>H.kind===Y.SyntaxKind.StaticKeyword),!!W.modifiers?.some((H)=>H.kind===Y.SyntaxKind.AbstractKeyword),!1,!1,!!W.modifiers?.some((H)=>H.kind===Y.SyntaxKind.ProtectedKeyword)),V=W.parameters[0],j=V?.type?.getText($)||"unknown",w=V?.name?.getText($)||"value";Q.push(`${U}set ${Z}(${w}: ${j});`)}}return`{
11
+ ${Q.join(`
12
+ `)}
13
+ }`}function Qq(q,$,Q){let W=[];if(q.flags&Y.NodeFlags.GlobalAugmentation)return`declare global ${C(q,Q)}`;if($)W.push("export ");W.push("declare ");let Z=q.flags&Y.NodeFlags.Namespace;return W.push(Z?"namespace ":"module "),W.push(q.name.getText(Q)),W.push(" ",C(q,Q)),W.join("")}function C(q,$){if(!q.body)return"{}";let Q=[];function W(X){if(Y.isFunctionDeclaration(X)){let Z=B(X),U=X.name?.getText($)||"",V=[" "];if(Z)V.push("export ");if(V.push("function ",U),X.typeParameters){let H=X.typeParameters.map((G)=>G.getText($)).join(", ");V.push("<",H,">")}let j=X.parameters.map((H)=>{let G=k(H,$),J=H.type?.getText($)||(H.initializer?K(H.initializer.getText($),!1):"unknown"),z=H.questionToken||H.initializer?"?":"";return`${G}${z}: ${J}`}).join(", ");V.push("(",j,")");let w=X.type?.getText($)||"void";V.push(": ",w,";"),Q.push(V.join(""))}else if(Y.isVariableStatement(X)){let Z=B(X);for(let U of X.declarationList.declarations)if(U.name&&Y.isIdentifier(U.name)){let V=U.name.getText($),j=U.type?.getText($),w=U.initializer?.getText($),H=X.declarationList.flags&Y.NodeFlags.Const?"const":X.declarationList.flags&Y.NodeFlags.Let?"let":"var",G=[" "];if(Z)G.push("export ");if(G.push(H," ",V),j)G.push(": ",j);else if(w){let J=K(w,H==="const");G.push(": ",J)}else G.push(": unknown");G.push(";"),Q.push(G.join(""))}}else if(Y.isInterfaceDeclaration(X)){let Z=B(X),U=X.name.getText($),V=[" "];if(Z)V.push("export ");if(V.push("interface ",U),X.typeParameters){let w=X.typeParameters.map((H)=>H.getText($)).join(", ");V.push("<",w,">")}if(X.heritageClauses){let w=X.heritageClauses.find((H)=>H.token===Y.SyntaxKind.ExtendsKeyword);if(w){let H=w.types.map((G)=>G.getText($)).join(", ");V.push(" extends ",H)}}let j=o(X,$);V.push(" ",j),Q.push(V.join(""))}else if(Y.isTypeAliasDeclaration(X)){let Z=B(X),U=X.name.getText($),V=[" "];if(Z)V.push("export ");if(V.push("type ",U),X.typeParameters){let j=X.typeParameters.map((w)=>w.getText($)).join(", ");V.push("<",j,">")}V.push(" = ",X.type.getText($)),Q.push(V.join(""))}else if(Y.isEnumDeclaration(X)){let Z=B(X),U=X.name.getText($),V=X.modifiers?.some((H)=>H.kind===Y.SyntaxKind.ConstKeyword),j=[" "];if(Z)j.push("export ");if(V)j.push("const ");j.push("enum ",U);let w=[];for(let H of X.members)if(Y.isEnumMember(H)){let G=H.name.getText($);if(H.initializer){let J=H.initializer.getText($);w.push(` ${G} = ${J}`)}else w.push(` ${G}`)}j.push(` {
14
+ `,w.join(`,
15
+ `),`
16
+ }`),Q.push(j.join(""))}else if(Y.isModuleDeclaration(X)){let Z=B(X),U=X.name.getText($),V=[" "];if(Z)V.push("export ");let j=X.flags&Y.NodeFlags.Namespace;V.push(j?"namespace ":"module "),V.push(U," ",C(X,$)),Q.push(V.join(""))}else if(Y.isExportAssignment(X)){let Z=[" export default "];if(X.expression)Z.push(X.expression.getText($));Z.push(";"),Q.push(Z.join(""))}}if(Y.isModuleBlock(q.body))for(let X of q.body.statements)W(X);else if(Y.isModuleDeclaration(q.body))W(q.body);return`{
17
+ ${Q.join(`
18
+ `)}
19
+ }`}function Wq(q,$,Q){let W=M(q,$,Q),X=!!q.importClause?.isTypeOnly,Z=!q.importClause;return{kind:"import",name:"",text:W,isExported:!1,isTypeOnly:X,isSideEffect:Z,source:q.moduleSpecifier.getText(Q).slice(1,-1),start:q.getStart(Q),end:q.getEnd()}}function $q(q,$,Q,W=!1){let X=M(q,$,Q),Z=!!q.isTypeOnly,U=W?I(q,Q):void 0;return{kind:"export",name:"",text:X,isExported:!0,isTypeOnly:Z,leadingComments:U,source:q.moduleSpecifier?.getText(Q).slice(1,-1),start:q.getStart(Q),end:q.getEnd()}}function jq(q,$,Q,W=!1){let X=M(q,$,Q),Z=W?I(q,Q):void 0;return{kind:"export",name:"default",text:X,isExported:!0,isTypeOnly:!1,leadingComments:Z,start:q.getStart(Q),end:q.getEnd()}}function Xq(q,$,Q,W){if(!q.name)return null;if(q.body){let _=q.name.getText(Q),D=!1;if(R.forEachChild(Q,(P)=>{if(R.isFunctionDeclaration(P)&&P!==q&&P.name?.getText(Q)===_&&!P.body)D=!0}),D)return null}let X=q.name.getText(Q),Z=B(q),U=Z&&g(q),V=d(q),j=!!q.asteriskToken,w=n(q,Q),H=q.parameters.map((_)=>({name:_.name.getText(Q),type:_.type?.getText(Q)||"any",optional:!!_.questionToken,defaultValue:_.initializer?.getText(Q)})),G=q.type?.getText(Q);if(!G)if(V&&j)G="AsyncGenerator<unknown, void, unknown>";else if(j)G="Generator<unknown, void, unknown>";else if(V)G="Promise<void>";else G="void";let J=q.typeParameters?.map((_)=>_.getText(Q)).join(", "),z=W?I(q,Q):void 0;return{kind:"function",name:X,text:w,isExported:Z,isDefault:U,isAsync:V,isGenerator:j,parameters:H,returnType:G,generics:J?`<${J}>`:void 0,leadingComments:z,start:q.getStart(Q),end:q.getEnd()}}function Nq(q,$){let Q=q.getText($);if(q.kind===R.SyntaxKind.ObjectLiteralExpression)return`typeof ${Q} as const`;if(q.kind===R.SyntaxKind.ArrayLiteralExpression)return`readonly ${Q}`;if(q.kind===R.SyntaxKind.StringLiteral)return Q;if(q.kind===R.SyntaxKind.NumericLiteral)return Q;if(q.kind===R.SyntaxKind.TrueKeyword||q.kind===R.SyntaxKind.FalseKeyword)return Q;return`typeof ${Q}`}function Zq(q,$,Q,W){let X=[];if(!B(q))return X;for(let U of q.declarationList.declarations){if(!U.name||!R.isIdentifier(U.name))continue;let V=U.name.getText(Q),j=U.type?.getText(Q),w=U.initializer,H=w?.getText(Q),G=q.declarationList.flags&R.NodeFlags.Const?"const":q.declarationList.flags&R.NodeFlags.Let?"let":"var",J=!1;if(w&&R.isAsExpression(w)){if(w.type.getText(Q)==="const"){J=!0;let P=w.expression;if(!j)j=Nq(P,Q)}}let z=s(V,j,G,!0),_=W?I(q,Q):void 0;X.push({kind:"variable",name:V,text:z,isExported:!0,typeAnnotation:j,value:H,modifiers:J?[G,"const assertion"]:[G],leadingComments:_,start:q.getStart(Q),end:q.getEnd()})}return X}function y(q,$,Q,W){let X=q.name.getText(Q),Z=B(q),U=r(q,Z,Q),V=q.heritageClauses?.find((H)=>H.token===R.SyntaxKind.ExtendsKeyword)?.types.map((H)=>H.getText(Q)).join(", "),j=q.typeParameters?.map((H)=>H.getText(Q)).join(", "),w=W?I(q,Q):void 0;return{kind:"interface",name:X,text:U,isExported:Z,extends:V,generics:j?`<${j}>`:void 0,leadingComments:w,start:q.getStart(Q),end:q.getEnd()}}function f(q,$,Q,W){let X=q.name.getText(Q),Z=B(q),U=e(q,Z,Q),V=q.typeParameters?.map((w)=>w.getText(Q)).join(", "),j=W?I(q,Q):void 0;return{kind:"type",name:X,text:U,isExported:Z,generics:V?`<${V}>`:void 0,leadingComments:j,start:q.getStart(Q),end:q.getEnd()}}function u(q,$,Q,W){let X=q.name?.getText(Q)||"AnonymousClass",Z=B(q),U=Z&&g(q),V=qq(q,Z,Q,U),j=q.heritageClauses?.find((z)=>z.token===R.SyntaxKind.ExtendsKeyword)?.types[0]?.getText(Q),w=q.heritageClauses?.find((z)=>z.token===R.SyntaxKind.ImplementsKeyword)?.types.map((z)=>z.getText(Q)),H=q.typeParameters?.map((z)=>z.getText(Q)).join(", "),G=q.modifiers?.some((z)=>z.kind===R.SyntaxKind.AbstractKeyword),J=W?I(q,Q):void 0;return{kind:"class",name:X,text:V,isExported:Z,isDefault:U,extends:j,implements:w,generics:H?`<${H}>`:void 0,modifiers:G?["abstract"]:void 0,leadingComments:J,start:q.getStart(Q),end:q.getEnd()}}function p(q,$,Q,W){let X=q.name.getText(Q),Z=B(q),U=M(q,$,Q),V=q.modifiers?.some((w)=>w.kind===R.SyntaxKind.ConstKeyword),j=W?I(q,Q):void 0;return{kind:"enum",name:X,text:U,isExported:Z,modifiers:V?["const"]:void 0,leadingComments:j,start:q.getStart(Q),end:q.getEnd()}}function Vq(q,$,Q,W){let X=q.name.getText(Q),Z=B(q),U=Qq(q,Z,Q),V=R.isStringLiteral(q.name),j=W?I(q,Q):void 0;return{kind:"module",name:X,text:U,isExported:Z,source:V?X.slice(1,-1):void 0,leadingComments:j,start:q.getStart(Q),end:q.getEnd()}}function Uq(q,$){let Q=new Set,W=new Set,X=new Set;for(let Z of q)if(Z.kind==="import"){let U=Z.text.match(/import\s+(?:type\s+)?\{([^}]+)\}/g);if(U)for(let V of U){let j=V.replace(/import\s+(?:type\s+)?\{([^}]+)\}/,"$1").split(",");for(let w of j){let H=w.replace(/^type\s+/,"").trim();W.add(H)}}}for(let Z of q){if(["interface","type","class","enum"].includes(Z.kind))X.add(Z.name);if(Z.kind==="module")a(Z.text).forEach((V)=>X.add(V))}for(let Z of q)if(Z.kind!=="import"&&Z.kind!=="export"){let U=Z.text.match(/:\s*([A-Z][a-zA-Z0-9]*)/g)||[];for(let V of U){let j=V.replace(/:\s*/,"");if(!W.has(j)&&!X.has(j)&&!t(j))Q.add(j)}}return Q}function Eq(q,$,Q,W=!0){let X=[];if($.size===0)return X;function Z(U){switch(U.kind){case R.SyntaxKind.InterfaceDeclaration:{let V=U,j=V.name.getText(q);if($.has(j)){let w=y(V,Q,q,W);X.push(w),$.delete(j)}break}case R.SyntaxKind.TypeAliasDeclaration:{let V=U,j=V.name.getText(q);if($.has(j)){let w=f(V,Q,q,W);X.push(w),$.delete(j)}break}case R.SyntaxKind.ClassDeclaration:{let V=U;if(V.name){let j=V.name.getText(q);if($.has(j)){let w=u(V,Q,q,W);X.push(w),$.delete(j)}}break}case R.SyntaxKind.EnumDeclaration:{let V=U,j=V.name.getText(q);if($.has(j)){let w=p(V,Q,q,W);X.push(w),$.delete(j)}break}}R.forEachChild(U,Z)}return Z(q),X}function aq(){wq(),Oq()}function nq(q,$,Q=!0,W=!1){return Bq(q,$,Q,W)}function Sq(q,$,Q){let W=[],X=new Map,Z=0;function U(V){if(Z!==1){Z++,L.forEachChild(V,U),Z--;return}switch(V.kind){case L.SyntaxKind.ImportDeclaration:W.push(Wq(V,$,q));break;case L.SyntaxKind.ExportDeclaration:W.push($q(V,$,q,Q));break;case L.SyntaxKind.ExportAssignment:W.push(jq(V,$,q,Q));break;case L.SyntaxKind.FunctionDeclaration:{let j=Xq(V,$,q,Q);if(j&&(j.isExported||m(j.name,$)))W.push(j);break}case L.SyntaxKind.VariableStatement:{let j=Zq(V,$,q,Q);W.push(...j);break}case L.SyntaxKind.InterfaceDeclaration:{let j=y(V,$,q,Q);if(j.isExported||i(j.name,$))W.push(j);else X.set(j.name,j);break}case L.SyntaxKind.TypeAliasDeclaration:{let j=f(V,$,q,Q);if(W.push(j),!j.isExported)X.set(j.name,j);break}case L.SyntaxKind.ClassDeclaration:{let j=u(V,$,q,Q);if(W.push(j),!j.isExported&&j.name)X.set(j.name,j);break}case L.SyntaxKind.EnumDeclaration:{let j=p(V,$,q,Q);if(W.push(j),!j.isExported)X.set(j.name,j);break}case L.SyntaxKind.ModuleDeclaration:W.push(Vq(V,$,q,Q));break}}if(U(q),X.size>0){let V=Uq(W,$);for(let j of V){let w=X.get(j);if(w)W.push(w)}}return W}async function gq(q,$,Q=!0,W={}){let X=await h($,q,W);return Sq(X,q,Q)}async function sq(q,$={}){let Q=$.concurrency??4,W=new Map;for(let X=0;X<q.length;X+=Q){let Z=q.slice(X,X+Q),U=await Promise.all(Z.map(async({filePath:V,sourceCode:j,keepComments:w})=>{let H=await gq(j,V,w,$);return{filePath:V,declarations:H}}));for(let{filePath:V,declarations:j}of U)W.set(V,j)}return W}export{Iq as wb,h as xb,Aq as yb,kq as zb,Kq as Ab,M as Bb,I as Cb,k as Db,B as Eb,d as Fb,m as Gb,i as Hb,t as Ib,a as Jb,n as Kb,s as Lb,r as Mb,o as Nb,e as Ob,qq as Pb,zq as Qb,Qq as Rb,C as Sb,Wq as Tb,$q as Ub,jq as Vb,Xq as Wb,Zq as Xb,y as Yb,f as Zb,u as _b,p as $b,Vq as ac,Uq as bc,Eq as cc,aq as dc,nq as ec,gq as fc,sq as gc};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{tb as c,ub as d,vb as e}from"./chunk-7zsd1qqw.js";import"./chunk-69rnp3hs.js";import"./chunk-2n1bbm2c.js";import{ic as a,jc as b}from"./chunk-kwmhsx3n.js";import"./chunk-jjwwkrfk.js";import"./chunk-1z1w3s0k.js";import"./chunk-7pwy4m0c.js";import"./chunk-4jw8qvts.js";import"./chunk-a3txc27m.js";import"./chunk-gssantc8.js";import"./chunk-mcdb3q06.js";export{e as watch,a as processSource,d as processFile,c as generate,b as clearResultCache};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Dc as Uz,Ec as Yz,Fc as T,Mc as u,Nc as p,Oc as Gz}from"./chunk-285mqzvx.js";function k(z,$=!0){if(!$||!z||z.length===0)return"";if(z.length===1){let U=z[0];if(U.length>0&&U.charCodeAt(0)>32&&U.charCodeAt(U.length-1)>32)return`${U}
2
+ import{Dc as Uz,Ec as Yz,Fc as T,Mc as u,Nc as p,Oc as Gz}from"./chunk-4jw8qvts.js";function k(z,$=!0){if(!$||!z||z.length===0)return"";if(z.length===1){let U=z[0];if(U.length>0&&U.charCodeAt(0)>32&&U.charCodeAt(U.length-1)>32)return`${U}
3
3
  `;return`${U.trim()}
4
4
  `}let K="";for(let U=0;U<z.length;U++){if(U>0)K+=`
5
5
  `;K+=z[U].trim()}return`${K}
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{ec as l}from"./chunk-y581wnfe.js";import{hc as CY}from"./chunk-2n1bbm2c.js";import{lc as UJ}from"./chunk-8z31rkfp.js";import{Cc as iJ}from"./chunk-vpjw38x7.js";import{Uc as f}from"./chunk-a3txc27m.js";import{Wc as K,Yc as r}from"./chunk-gssantc8.js";import{bd as xY,dd as AY}from"./chunk-mcdb3q06.js";var{Glob:oJ}=globalThis.Bun;import{mkdir as o}from"fs/promises";import{availableParallelism as dY}from"os";import{dirname as u,relative as v,resolve as x}from"path";import{existsSync as ZJ,mkdirSync as JY,readFileSync as YY,writeFileSync as $Y}from"fs";import{dirname as ZY,relative as QY,resolve as UY}from"path";async function TJ(J,Y,$){let Z=new Map,Q=[],U=new Set,X=0,H=0,j=0,G=[];for(let q of J){let B=Y.get(q);if(!B)continue;G.push({file:q,decls:l(B,q,$.keepComments)})}for(let{file:q,decls:B}of G){X+=B.length;for(let k of B)if(k.kind==="import"){H++;let R=k.source||"";if(R.startsWith("."))continue;if(!Z.has(R))Z.set(R,{source:R,specifiers:new Map,isTypeOnly:k.isTypeOnly||!1,isSideEffect:k.isSideEffect||!1});let L=Z.get(R);if(k.specifiers)for(let w of k.specifiers){let S=w.alias||w.name;if(!L.specifiers.has(S))L.specifiers.set(S,{name:w.name,alias:w.alias,isType:w.isType||!1})}if(!k.isTypeOnly)L.isTypeOnly=!1}else if(k.isExported||k.kind==="export"){if(j++,k.kind==="export"&&k.source&&(k.source.startsWith(".")||k.source.startsWith("/")))continue;if(k.name&&U.has(k.name))continue;if(k.name)U.add(k.name);Q.push({declaration:k,file:q})}}let z=[];z.push("/**"),z.push(" * Bundled TypeScript declarations"),z.push(` * Generated from ${J.length} source files`),z.push(" */"),z.push("");let A=$.importOrder||["bun"],N=Array.from(Z.values()),_=Array(N.length);for(let q=0;q<N.length;q++){let B=N[q].source,k=A.length;for(let R=0;R<A.length;R++)if(B.startsWith(A[R])){k=R;break}_[q]=k}let T=N.map((q,B)=>B);T.sort((q,B)=>{let k=_[q],R=_[B];if(k!==R)return k-R;return N[q].source.localeCompare(N[B].source)});let V=T.map((q)=>N[q]);for(let q of V)if(q.isSideEffect)z.push(`import '${q.source}';`);else if(q.specifiers.size>0){let k=Array.from(q.specifiers.values()).map((L)=>{let w=L.isType?"type ":"";return L.alias?`${w}${L.name} as ${L.alias}`:`${w}${L.name}`}),R=q.isTypeOnly?"type ":"";z.push(`import ${R}{ ${k.join(", ")} } from '${q.source}';`)}if(V.length>0)z.push("");let W=new Map;for(let{declaration:q,file:B}of Q){if(!W.has(B))W.set(B,[]);W.get(B).push(q)}for(let[q,B]of W){let k=QY($.cwd,q);z.push(`// From: ${k}`);for(let R of B){if($.keepComments&&R.leadingComments)for(let L of R.leadingComments)z.push(L);z.push(RJ(R))}z.push("")}let O=z.join(`
2
+ import{ec as l}from"./chunk-69rnp3hs.js";import{hc as CY}from"./chunk-2n1bbm2c.js";import{lc as UJ}from"./chunk-jjwwkrfk.js";import{Cc as iJ}from"./chunk-7pwy4m0c.js";import{Uc as f}from"./chunk-a3txc27m.js";import{Wc as K,Yc as r}from"./chunk-gssantc8.js";import{bd as xY,dd as AY}from"./chunk-mcdb3q06.js";var{Glob:oJ}=globalThis.Bun;import{mkdir as o}from"fs/promises";import{availableParallelism as dY}from"os";import{dirname as u,relative as v,resolve as x}from"path";import{existsSync as ZJ,mkdirSync as JY,readFileSync as YY,writeFileSync as $Y}from"fs";import{dirname as ZY,relative as QY,resolve as UY}from"path";async function TJ(J,Y,$){let Z=new Map,Q=[],U=new Set,X=0,H=0,j=0,G=[];for(let q of J){let B=Y.get(q);if(!B)continue;G.push({file:q,decls:l(B,q,$.keepComments)})}for(let{file:q,decls:B}of G){X+=B.length;for(let k of B)if(k.kind==="import"){H++;let R=k.source||"";if(R.startsWith("."))continue;if(!Z.has(R))Z.set(R,{source:R,specifiers:new Map,isTypeOnly:k.isTypeOnly||!1,isSideEffect:k.isSideEffect||!1});let L=Z.get(R);if(k.specifiers)for(let w of k.specifiers){let S=w.alias||w.name;if(!L.specifiers.has(S))L.specifiers.set(S,{name:w.name,alias:w.alias,isType:w.isType||!1})}if(!k.isTypeOnly)L.isTypeOnly=!1}else if(k.isExported||k.kind==="export"){if(j++,k.kind==="export"&&k.source&&(k.source.startsWith(".")||k.source.startsWith("/")))continue;if(k.name&&U.has(k.name))continue;if(k.name)U.add(k.name);Q.push({declaration:k,file:q})}}let z=[];z.push("/**"),z.push(" * Bundled TypeScript declarations"),z.push(` * Generated from ${J.length} source files`),z.push(" */"),z.push("");let A=$.importOrder||["bun"],N=Array.from(Z.values()),_=Array(N.length);for(let q=0;q<N.length;q++){let B=N[q].source,k=A.length;for(let R=0;R<A.length;R++)if(B.startsWith(A[R])){k=R;break}_[q]=k}let T=N.map((q,B)=>B);T.sort((q,B)=>{let k=_[q],R=_[B];if(k!==R)return k-R;return N[q].source.localeCompare(N[B].source)});let V=T.map((q)=>N[q]);for(let q of V)if(q.isSideEffect)z.push(`import '${q.source}';`);else if(q.specifiers.size>0){let k=Array.from(q.specifiers.values()).map((L)=>{let w=L.isType?"type ":"";return L.alias?`${w}${L.name} as ${L.alias}`:`${w}${L.name}`}),R=q.isTypeOnly?"type ":"";z.push(`import ${R}{ ${k.join(", ")} } from '${q.source}';`)}if(V.length>0)z.push("");let W=new Map;for(let{declaration:q,file:B}of Q){if(!W.has(B))W.set(B,[]);W.get(B).push(q)}for(let[q,B]of W){let k=QY($.cwd,q);z.push(`// From: ${k}`);for(let R of B){if($.keepComments&&R.leadingComments)for(let L of R.leadingComments)z.push(L);z.push(RJ(R))}z.push("")}let O=z.join(`
3
3
  `);return{content:O,files:J,declarationCount:X,importCount:H,exportCount:j,size:Buffer.byteLength(O,"utf8"),warnings:[]}}function RJ(J){if(J.text){let $=J.text.trim();if(J.isExported&&!$.startsWith("export"))$=`export ${$}`;if(!$.endsWith(";")&&!$.endsWith("}"))$+=";";return $}let Y=[];if(J.isExported)Y.push("export");if(J.isDefault)Y.push("default");switch(J.kind){case"function":if(Y.push("declare function"),Y.push(J.name),J.generics)Y.push(J.generics);if(Y.push(`(${XY(J.parameters)})`),J.returnType)Y.push(`: ${J.returnType}`);break;case"variable":if(Y.push("declare const"),Y.push(J.name),J.typeAnnotation)Y.push(`: ${J.typeAnnotation}`);break;case"interface":if(Y.push("interface"),Y.push(J.name),J.generics)Y.push(J.generics);if(J.extends)Y.push(`extends ${J.extends}`);if(Y.push("{"),J.members)for(let $ of J.members)Y.push(` ${$.name}${$.typeAnnotation?`: ${$.typeAnnotation}`:""};`);Y.push("}");break;case"type":if(Y.push("type"),Y.push(J.name),J.generics)Y.push(J.generics);Y.push("="),Y.push(J.typeAnnotation||"unknown");break;case"class":if(Y.push("declare class"),Y.push(J.name),J.generics)Y.push(J.generics);if(J.extends)Y.push(`extends ${J.extends}`);if(J.implements&&J.implements.length>0)Y.push(`implements ${J.implements.join(", ")}`);if(Y.push("{"),J.members)for(let $ of J.members)Y.push(` ${RJ($)}`);Y.push("}");break;case"enum":if(Y.push("declare enum"),Y.push(J.name),Y.push("{"),J.members){let $=J.members.map((Z)=>Z.value!==void 0?`${Z.name} = ${Z.value}`:Z.name);Y.push(` ${$.join(`,
4
4
  `)}`)}Y.push("}");break;default:return J.text||""}return Y.join(" ")}function XY(J){if(!J||J.length===0)return"";return J.map((Y)=>{let $="";if(Y.rest)$+="...";if($+=Y.name,Y.optional)$+="?";if(Y.type)$+=`: ${Y.type}`;if(Y.defaultValue)$+=` = ${Y.defaultValue}`;return $}).join(", ")}async function LJ(J,Y={}){let $=[],Z=new Map,Q=[],U=[],X=new Set,H=0,j=0,G=0;for(let _ of J){if(!ZJ(_)){$.push(`File not found: ${_}`);continue}let T=YY(_,"utf-8");U.push(_);let V=T.split(`
5
5
  `),W=[],O=0,q=!1;for(let B of V){let k=B.trim();if(!k&&!q)continue;if(k.startsWith("import ")){j++;let L=k.match(/import\s+(type\s+)?(?:\{([^}]+)\}|(\w+)|\*\s+as\s+(\w+))\s+from\s+['"]([^'"]+)['"]/);if(L){let[,w,S,M,F,D]=L;if(Y.externals?.some((C)=>D.startsWith(C))){Q.push(k);continue}if(D.startsWith("."))continue;if(!Z.has(D))Z.set(D,{source:D,specifiers:new Map,isTypeOnly:!!w,isSideEffect:!1});let p=Z.get(D);if(S){let C=S.split(",").map((e)=>e.trim());for(let e of C){let[JJ,YJ]=e.split(/\s+as\s+/).map((eJ)=>eJ.trim()),NJ=JJ.startsWith("type "),$J=NJ?JJ.replace("type ",""):JJ;p.specifiers.set(YJ||$J,{name:$J,alias:YJ!==$J?YJ:void 0,isType:NJ})}}if(!w)p.isTypeOnly=!1}continue}if(/^(export\s+)?(declare\s+)?(interface|type|class|function|const|let|var|enum|namespace|module)\s/.test(k)){if(q=!0,W=[B],O=(B.match(/\{/g)||[]).length-(B.match(/\}/g)||[]).length,O===0&&(k.endsWith(";")||!k.includes("{"))){let L=c(k);if(!X.has(L)||!Y.mergeDuplicates){if(X.add(L),Q.push(B),H++,k.startsWith("export"))G++}q=!1,W=[]}}else if(q){if(W.push(B),O+=(B.match(/\{/g)||[]).length-(B.match(/\}/g)||[]).length,O<=0){let L=W.join(`
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{l as a,m as b,n as c,o as d,p as e,q as f,r as g}from"./chunk-mzq58nw0.js";import"./chunk-x3q42h61.js";import"./chunk-y581wnfe.js";import"./chunk-2n1bbm2c.js";import"./chunk-4s9jv983.js";import"./chunk-8z31rkfp.js";import"./chunk-2r21f44d.js";import"./chunk-vpjw38x7.js";import"./chunk-285mqzvx.js";import"./chunk-a3txc27m.js";import"./chunk-gssantc8.js";import"./chunk-mcdb3q06.js";export{b as sortProjectsByDependencies,f as resolveWorkspacePatterns,c as generateWorkspace,d as generateMonorepo,g as generateFromPackageWorkspaces,a as discoverWorkspaceProjects,e as discoverWorkspaceFromPackageJson};
2
+ import{l as a,m as b,n as c,o as d,p as e,q as f,r as g}from"./chunk-dv8haj2p.js";import"./chunk-7zsd1qqw.js";import"./chunk-69rnp3hs.js";import"./chunk-2n1bbm2c.js";import"./chunk-kwmhsx3n.js";import"./chunk-jjwwkrfk.js";import"./chunk-1z1w3s0k.js";import"./chunk-7pwy4m0c.js";import"./chunk-4jw8qvts.js";import"./chunk-a3txc27m.js";import"./chunk-gssantc8.js";import"./chunk-mcdb3q06.js";export{b as sortProjectsByDependencies,f as resolveWorkspacePatterns,c as generateWorkspace,d as generateMonorepo,g as generateFromPackageWorkspaces,a as discoverWorkspaceProjects,e as discoverWorkspaceFromPackageJson};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{ec as F}from"./chunk-y581wnfe.js";import{Cc as N}from"./chunk-vpjw38x7.js";import{existsSync as H,readFileSync as P,unwatchFile as T}from"fs";var k;((J)=>{J[J.Error=1]="Error";J[J.Warning=2]="Warning";J[J.Information=3]="Information";J[J.Hint=4]="Hint"})(k||={});var L;((O)=>{O[O.File=1]="File";O[O.Module=2]="Module";O[O.Namespace=3]="Namespace";O[O.Package=4]="Package";O[O.Class=5]="Class";O[O.Method=6]="Method";O[O.Property=7]="Property";O[O.Field=8]="Field";O[O.Constructor=9]="Constructor";O[O.Enum=10]="Enum";O[O.Interface=11]="Interface";O[O.Function=12]="Function";O[O.Variable=13]="Variable";O[O.Constant=14]="Constant";O[O.String=15]="String";O[O.Number=16]="Number";O[O.Boolean=17]="Boolean";O[O.Array=18]="Array";O[O.Object=19]="Object";O[O.Key=20]="Key";O[O.Null=21]="Null";O[O.EnumMember=22]="EnumMember";O[O.Struct=23]="Struct";O[O.Event=24]="Event";O[O.Operator=25]="Operator";O[O.TypeParameter=26]="TypeParameter"})(L||={});var M;((Q)=>{Q[Q.Text=1]="Text";Q[Q.Method=2]="Method";Q[Q.Function=3]="Function";Q[Q.Constructor=4]="Constructor";Q[Q.Field=5]="Field";Q[Q.Variable=6]="Variable";Q[Q.Class=7]="Class";Q[Q.Interface=8]="Interface";Q[Q.Module=9]="Module";Q[Q.Property=10]="Property";Q[Q.Unit=11]="Unit";Q[Q.Value=12]="Value";Q[Q.Enum=13]="Enum";Q[Q.Keyword=14]="Keyword";Q[Q.Snippet=15]="Snippet";Q[Q.Color=16]="Color";Q[Q.File=17]="File";Q[Q.Reference=18]="Reference";Q[Q.Folder=19]="Folder";Q[Q.EnumMember=20]="EnumMember";Q[Q.Constant=21]="Constant";Q[Q.Struct=22]="Struct";Q[Q.Event=23]="Event";Q[Q.Operator=24]="Operator";Q[Q.TypeParameter=25]="TypeParameter"})(M||={});var v;((A)=>{A[A.Text=1]="Text";A[A.Read=2]="Read";A[A.Write=3]="Write"})(v||={});class E{documents=new Map;rootUri=null;config={};messageId=0;watchers=new Map;initialize(j){return this.rootUri=j.rootUri,{capabilities:{textDocumentSync:1,hoverProvider:!0,completionProvider:{triggerCharacters:[".",":","<",'"',"'","/"],resolveProvider:!0},definitionProvider:!0,referencesProvider:!0,renameProvider:{prepareProvider:!0},documentSymbolProvider:!0,workspaceSymbolProvider:!0,codeActionProvider:{codeActionKinds:["quickfix","refactor","source"]},signatureHelpProvider:{triggerCharacters:["(",","],retriggerCharacters:[","]},documentHighlightProvider:!0,documentFormattingProvider:!0,diagnosticProvider:{interFileDependencies:!0,workspaceDiagnostics:!0}}}}didOpen(j){let{uri:z,text:G,version:A}=j.textDocument;this.updateDocument(z,G,A)}didChange(j){let{uri:z,version:G}=j.textDocument,A=j.contentChanges[0]?.text||"";this.updateDocument(z,A,G)}didClose(j){let z=j.textDocument.uri;if(this.documents.delete(z),this.watchers.get(z))T(this.uriToPath(z)),this.watchers.delete(z)}updateDocument(j,z,G){let A=this.uriToPath(j),J=F(z,A,!0);this.documents.set(j,{content:z,version:G,declarations:J})}getDiagnostics(j){let z=this.documents.get(j);if(!z)return[];let G=[];for(let A of z.declarations){if(A.isExported&&A.kind==="variable"&&!A.typeAnnotation)G.push({range:this.getDeclarationRange(A,z.content),severity:2,code:"missing-type",source:"dtsx",message:`Exported variable '${A.name}' should have an explicit type annotation for better declaration generation`});if(A.typeAnnotation==="any"||A.returnType==="any")G.push({range:this.getDeclarationRange(A,z.content),severity:3,code:"any-type",source:"dtsx",message:"Consider using a more specific type instead of 'any'"});if(A.kind==="function"&&A.isExported&&!A.returnType)G.push({range:this.getDeclarationRange(A,z.content),severity:3,code:"missing-return-type",source:"dtsx",message:`Function '${A.name}' should have an explicit return type for better declaration generation`})}return G}hover(j){let z=this.documents.get(j.textDocument.uri);if(!z)return null;let{line:G,character:A}=j.position,R=z.content.split(`
2
+ import{ec as F}from"./chunk-69rnp3hs.js";import{Cc as N}from"./chunk-7pwy4m0c.js";import{existsSync as H,readFileSync as P,unwatchFile as T}from"fs";var k;((J)=>{J[J.Error=1]="Error";J[J.Warning=2]="Warning";J[J.Information=3]="Information";J[J.Hint=4]="Hint"})(k||={});var L;((O)=>{O[O.File=1]="File";O[O.Module=2]="Module";O[O.Namespace=3]="Namespace";O[O.Package=4]="Package";O[O.Class=5]="Class";O[O.Method=6]="Method";O[O.Property=7]="Property";O[O.Field=8]="Field";O[O.Constructor=9]="Constructor";O[O.Enum=10]="Enum";O[O.Interface=11]="Interface";O[O.Function=12]="Function";O[O.Variable=13]="Variable";O[O.Constant=14]="Constant";O[O.String=15]="String";O[O.Number=16]="Number";O[O.Boolean=17]="Boolean";O[O.Array=18]="Array";O[O.Object=19]="Object";O[O.Key=20]="Key";O[O.Null=21]="Null";O[O.EnumMember=22]="EnumMember";O[O.Struct=23]="Struct";O[O.Event=24]="Event";O[O.Operator=25]="Operator";O[O.TypeParameter=26]="TypeParameter"})(L||={});var M;((Q)=>{Q[Q.Text=1]="Text";Q[Q.Method=2]="Method";Q[Q.Function=3]="Function";Q[Q.Constructor=4]="Constructor";Q[Q.Field=5]="Field";Q[Q.Variable=6]="Variable";Q[Q.Class=7]="Class";Q[Q.Interface=8]="Interface";Q[Q.Module=9]="Module";Q[Q.Property=10]="Property";Q[Q.Unit=11]="Unit";Q[Q.Value=12]="Value";Q[Q.Enum=13]="Enum";Q[Q.Keyword=14]="Keyword";Q[Q.Snippet=15]="Snippet";Q[Q.Color=16]="Color";Q[Q.File=17]="File";Q[Q.Reference=18]="Reference";Q[Q.Folder=19]="Folder";Q[Q.EnumMember=20]="EnumMember";Q[Q.Constant=21]="Constant";Q[Q.Struct=22]="Struct";Q[Q.Event=23]="Event";Q[Q.Operator=24]="Operator";Q[Q.TypeParameter=25]="TypeParameter"})(M||={});var v;((A)=>{A[A.Text=1]="Text";A[A.Read=2]="Read";A[A.Write=3]="Write"})(v||={});class E{documents=new Map;rootUri=null;config={};messageId=0;watchers=new Map;initialize(j){return this.rootUri=j.rootUri,{capabilities:{textDocumentSync:1,hoverProvider:!0,completionProvider:{triggerCharacters:[".",":","<",'"',"'","/"],resolveProvider:!0},definitionProvider:!0,referencesProvider:!0,renameProvider:{prepareProvider:!0},documentSymbolProvider:!0,workspaceSymbolProvider:!0,codeActionProvider:{codeActionKinds:["quickfix","refactor","source"]},signatureHelpProvider:{triggerCharacters:["(",","],retriggerCharacters:[","]},documentHighlightProvider:!0,documentFormattingProvider:!0,diagnosticProvider:{interFileDependencies:!0,workspaceDiagnostics:!0}}}}didOpen(j){let{uri:z,text:G,version:A}=j.textDocument;this.updateDocument(z,G,A)}didChange(j){let{uri:z,version:G}=j.textDocument,A=j.contentChanges[0]?.text||"";this.updateDocument(z,A,G)}didClose(j){let z=j.textDocument.uri;if(this.documents.delete(z),this.watchers.get(z))T(this.uriToPath(z)),this.watchers.delete(z)}updateDocument(j,z,G){let A=this.uriToPath(j),J=F(z,A,!0);this.documents.set(j,{content:z,version:G,declarations:J})}getDiagnostics(j){let z=this.documents.get(j);if(!z)return[];let G=[];for(let A of z.declarations){if(A.isExported&&A.kind==="variable"&&!A.typeAnnotation)G.push({range:this.getDeclarationRange(A,z.content),severity:2,code:"missing-type",source:"dtsx",message:`Exported variable '${A.name}' should have an explicit type annotation for better declaration generation`});if(A.typeAnnotation==="any"||A.returnType==="any")G.push({range:this.getDeclarationRange(A,z.content),severity:3,code:"any-type",source:"dtsx",message:"Consider using a more specific type instead of 'any'"});if(A.kind==="function"&&A.isExported&&!A.returnType)G.push({range:this.getDeclarationRange(A,z.content),severity:3,code:"missing-return-type",source:"dtsx",message:`Function '${A.name}' should have an explicit return type for better declaration generation`})}return G}hover(j){let z=this.documents.get(j.textDocument.uri);if(!z)return null;let{line:G,character:A}=j.position,R=z.content.split(`
3
3
  `)[G]||"",U=R.slice(0,A).match(/[\w$]+$/),V=R.slice(A).match(/^[\w$]+/);if(!U&&!V)return null;let X=(U?.[0]||"")+(V?.[0]||""),Y=z.declarations.find((W)=>W.name===X);if(!Y)return null;let B=`\`\`\`typescript
4
4
  ${this.buildSignature(Y)}
5
5
  \`\`\``;if(Y.leadingComments&&Y.leadingComments.length>0){let q=Y.leadingComments.join(`
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{tb as y}from"./chunk-x3q42h61.js";import{Wc as H,Yc as F}from"./chunk-gssantc8.js";import{dd as R}from"./chunk-mcdb3q06.js";import{existsSync as V,readFileSync as G}from"fs";import{dirname as M,join as X,resolve as x}from"path";async function S(E){let A=[],z=new Set;async function q(I,O){let w=x(I);if(z.has(w))return;if(z.add(w),!V(w)){H.warn(`tsconfig not found: ${w}`);return}try{let K=G(w,"utf-8"),Q=K.indexOf("//")!==-1||K.indexOf("/*")!==-1?K.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,""):K,L=JSON.parse(Q),U=M(w),Y=B(U,O),W=[];if(L.references)for(let D of L.references){let $=x(U,D.path),J=V(X($,"tsconfig.json"))?X($,"tsconfig.json"):$;await q(J,Y);let b=B(M(J),Y);W.push(b)}let Z="./src";if(L.compilerOptions?.rootDir)Z=L.compilerOptions.rootDir;else if(L.include&&L.include.length>0){if(L.include[0].startsWith("src/"))Z="./src"}let _="./dist";if(L.compilerOptions?.outDir)_=L.compilerOptions.outDir;else if(L.compilerOptions?.declarationDir)_=L.compilerOptions.declarationDir;A.push({name:Y,root:U,tsconfigPath:w,references:W,config:{root:Z,outdir:_}})}catch(K){let Q=K instanceof Error?K.message:String(K);H.warn(`Failed to parse ${w}: ${Q}`)}}return await q(E),A}function B(E,A){let z=X(E,"package.json");if(V(z))try{let I=G(z,"utf-8"),O=JSON.parse(I);if(O.name)return O.name}catch{}let q=E.split("/").pop()||"unknown";return A?`${A}/${q}`:q}function N(E){let A=new Map(E.map((w)=>[w.name,w])),z=[],q=new Set,I=new Set;function O(w){if(q.has(w))return;if(I.has(w)){H.warn(`Circular dependency detected involving: ${w}`);return}I.add(w);let K=A.get(w);if(K){for(let Q of K.references)O(Q);z.push(K)}I.delete(w),q.add(w)}for(let w of E)O(w.name);return z}async function T(E){let A=Date.now(),z=N(E.projects);H.info(`Generating declarations for ${z.length} projects...`);let q=[],I=!0;for(let Q of z){H.info(`
2
+ import{tb as y}from"./chunk-7zsd1qqw.js";import{Wc as H,Yc as F}from"./chunk-gssantc8.js";import{dd as R}from"./chunk-mcdb3q06.js";import{existsSync as V,readFileSync as G}from"fs";import{dirname as M,join as X,resolve as x}from"path";async function S(E){let A=[],z=new Set;async function q(I,O){let w=x(I);if(z.has(w))return;if(z.add(w),!V(w)){H.warn(`tsconfig not found: ${w}`);return}try{let K=G(w,"utf-8"),Q=K.indexOf("//")!==-1||K.indexOf("/*")!==-1?K.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,""):K,L=JSON.parse(Q),U=M(w),Y=B(U,O),W=[];if(L.references)for(let D of L.references){let $=x(U,D.path),J=V(X($,"tsconfig.json"))?X($,"tsconfig.json"):$;await q(J,Y);let b=B(M(J),Y);W.push(b)}let Z="./src";if(L.compilerOptions?.rootDir)Z=L.compilerOptions.rootDir;else if(L.include&&L.include.length>0){if(L.include[0].startsWith("src/"))Z="./src"}let _="./dist";if(L.compilerOptions?.outDir)_=L.compilerOptions.outDir;else if(L.compilerOptions?.declarationDir)_=L.compilerOptions.declarationDir;A.push({name:Y,root:U,tsconfigPath:w,references:W,config:{root:Z,outdir:_}})}catch(K){let Q=K instanceof Error?K.message:String(K);H.warn(`Failed to parse ${w}: ${Q}`)}}return await q(E),A}function B(E,A){let z=X(E,"package.json");if(V(z))try{let I=G(z,"utf-8"),O=JSON.parse(I);if(O.name)return O.name}catch{}let q=E.split("/").pop()||"unknown";return A?`${A}/${q}`:q}function N(E){let A=new Map(E.map((w)=>[w.name,w])),z=[],q=new Set,I=new Set;function O(w){if(q.has(w))return;if(I.has(w)){H.warn(`Circular dependency detected involving: ${w}`);return}I.add(w);let K=A.get(w);if(K){for(let Q of K.references)O(Q);z.push(K)}I.delete(w),q.add(w)}for(let w of E)O(w.name);return z}async function T(E){let A=Date.now(),z=N(E.projects);H.info(`Generating declarations for ${z.length} projects...`);let q=[],I=!0;for(let Q of z){H.info(`
3
3
  [${Q.name}] Generating...`);try{let L={...E.sharedConfig,...Q.config,cwd:Q.root,tsconfigPath:Q.tsconfigPath},U=await y(L),Y=U.filesFailed===0;if(!Y)I=!1;q.push({name:Q.name,stats:U,success:Y}),H.info(`[${Q.name}] Generated ${U.filesGenerated} files`)}catch(L){I=!1;let U=L instanceof Error?L.message:String(L);q.push({name:Q.name,stats:{filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},success:!1,error:U}),H.error(`[${Q.name}] Failed: ${U}`)}}let O=Date.now()-A,w=q.filter((Q)=>Q.success).length,K=q.length-w;if(H.info(`
4
4
  --- Workspace Generation Summary ---`),H.info(`Projects processed: ${q.length}`),H.info(`Successful: ${w}`),K>0)H.info(`Failed: ${K}`);return H.info(`Total duration: ${O}ms`),H.info(`------------------------------------
5
5
  `),{success:I,projects:q,durationMs:O}}async function f(E,A){if(A?.logLevel)F(A.logLevel);let z=X(E,"tsconfig.json");if(!V(z))throw Error(`Root tsconfig.json not found at: ${z}`);H.info("Discovering workspace projects...");let q=await S(z);if(q.length===0)return H.warn("No projects found in workspace"),{success:!0,projects:[],durationMs:0};return H.info(`Found ${q.length} projects`),T({root:E,projects:q,sharedConfig:A})}async function v(E){let A=X(E,"package.json");if(!V(A))return[];try{let z=G(A,"utf-8"),q=JSON.parse(z),I=[];if(Array.isArray(q.workspaces))I=q.workspaces;else if(q.workspaces?.packages)I=q.workspaces.packages;return I}catch{return[]}}async function C(E,A){let{Glob:z}=awaitPromise.resolve(globalThis.Bun),q=[];for(let I of A){let O=new z(I);for await(let w of O.scan({cwd:E,absolute:!0,onlyFiles:!1})){let K=X(w,"package.json");if(V(K))q.push(w)}}return q}async function l(E,A){if(A?.logLevel)F(A.logLevel);let z=await v(E);if(z.length===0)return H.warn("No workspace patterns found in package.json"),{success:!0,projects:[],durationMs:0};H.info(`Found workspace patterns: ${z.join(", ")}`);let q=await C(E,z);if(q.length===0)return H.warn("No projects found matching workspace patterns"),{success:!0,projects:[],durationMs:0};H.info(`Found ${q.length} workspace packages`);let I=q.map((O)=>{let w=X(O,"tsconfig.json");return{name:B(O),root:O,tsconfigPath:V(w)?w:"",references:[]}});return T({root:E,projects:I,sharedConfig:A})}
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{tb as C}from"./chunk-x3q42h61.js";function y(F={}){let{onStart:H=!1,onEnd:I=!0,onGenerated:J,onError:z,...q}=F,B=async()=>{try{let k=await C(q);J?.(k)}catch(k){let j=k instanceof Error?k:Error(String(k));if(z?.(j),!z)console.error("[dtsx] Generation failed:",j.message)}};return{name:"dtsx",setup(k){let j=k.initialOptions;if(!q.entrypoints&&j.entryPoints)if(Array.isArray(j.entryPoints))q.entrypoints=j.entryPoints;else q.entrypoints=Object.values(j.entryPoints);if(!q.outdir){if(j.outdir)q.outdir=j.outdir;else if(j.outfile){let w=j.outfile.lastIndexOf("/");if(w!==-1)q.outdir=j.outfile.substring(0,w)}}if(H)k.onStart(async()=>{await B()});if(I)k.onEnd(async(w)=>{if(w.errors.length===0)await B()})}}}var L=y,M=y,P=y;
2
+ import{tb as C}from"./chunk-7zsd1qqw.js";function y(F={}){let{onStart:H=!1,onEnd:I=!0,onGenerated:J,onError:z,...q}=F,B=async()=>{try{let k=await C(q);J?.(k)}catch(k){let j=k instanceof Error?k:Error(String(k));if(z?.(j),!z)console.error("[dtsx] Generation failed:",j.message)}};return{name:"dtsx",setup(k){let j=k.initialOptions;if(!q.entrypoints&&j.entryPoints)if(Array.isArray(j.entryPoints))q.entrypoints=j.entryPoints;else q.entrypoints=Object.values(j.entryPoints);if(!q.outdir){if(j.outdir)q.outdir=j.outdir;else if(j.outfile){let w=j.outfile.lastIndexOf("/");if(w!==-1)q.outdir=j.outfile.substring(0,w)}}if(H)k.onStart(async()=>{await B()});if(I)k.onEnd(async(w)=>{if(w.errors.length===0)await B()})}}}var L=y,M=y,P=y;
3
3
  export{y as ia,L as ja,M as ka,P as la};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{$b as G,Ab as e,Bb as g,Cb as h,Db as i,Eb as j,Fb as k,Gb as l,Hb as m,Ib as n,Jb as o,Kb as p,Lb as q,Mb as r,Nb as s,Ob as t,Pb as u,Qb as v,Rb as w,Sb as x,Tb as y,Ub as z,Vb as A,Wb as B,Xb as C,Yb as D,Zb as E,_b as F,ac as H,bc as I,cc as J,dc as K,ec as L,fc as M,gc as N,wb as a,xb as b,yb as c,zb as d}from"./chunk-y581wnfe.js";import"./chunk-2n1bbm2c.js";import"./chunk-8z31rkfp.js";import"./chunk-2r21f44d.js";import{Oc as f}from"./chunk-285mqzvx.js";import"./chunk-mcdb3q06.js";export{d as shouldUseAsyncParsing,m as shouldIncludeNonExportedInterface,l as shouldIncludeNonExportedFunction,n as isBuiltInType,j as hasExportModifier,k as hasAsyncModifier,a as getSourceFileCacheSize,b as getSourceFileAsync,e as getPendingParseCount,i as getParameterName,g as getNodeText,s as getInterfaceBody,I as findReferencedTypes,C as extractVariableStatement,o as extractTypesFromModuleText,E as extractTypeAliasDeclaration,f as extractTripleSlashDirectives,J as extractReferencedTypeDeclarations,H as extractModuleDeclaration,h as extractJSDocComments,D as extractInterfaceDeclaration,y as extractImportDeclaration,B as extractFunctionDeclaration,z as extractExportDeclaration,A as extractExportAssignment,G as extractEnumDeclaration,M as extractDeclarationsAsync,L as extractDeclarations,F as extractClassDeclaration,K as clearSourceFileCache,q as buildVariableDeclaration,t as buildTypeDeclaration,w as buildModuleDeclaration,x as buildModuleBody,r as buildInterfaceDeclaration,p as buildFunctionSignature,u as buildClassDeclaration,v as buildClassBody,c as batchParseSourceFiles,N as batchExtractDeclarations};
2
+ import{$b as G,Ab as e,Bb as g,Cb as h,Db as i,Eb as j,Fb as k,Gb as l,Hb as m,Ib as n,Jb as o,Kb as p,Lb as q,Mb as r,Nb as s,Ob as t,Pb as u,Qb as v,Rb as w,Sb as x,Tb as y,Ub as z,Vb as A,Wb as B,Xb as C,Yb as D,Zb as E,_b as F,ac as H,bc as I,cc as J,dc as K,ec as L,fc as M,gc as N,wb as a,xb as b,yb as c,zb as d}from"./chunk-69rnp3hs.js";import"./chunk-2n1bbm2c.js";import"./chunk-jjwwkrfk.js";import"./chunk-1z1w3s0k.js";import{Oc as f}from"./chunk-4jw8qvts.js";import"./chunk-mcdb3q06.js";export{d as shouldUseAsyncParsing,m as shouldIncludeNonExportedInterface,l as shouldIncludeNonExportedFunction,n as isBuiltInType,j as hasExportModifier,k as hasAsyncModifier,a as getSourceFileCacheSize,b as getSourceFileAsync,e as getPendingParseCount,i as getParameterName,g as getNodeText,s as getInterfaceBody,I as findReferencedTypes,C as extractVariableStatement,o as extractTypesFromModuleText,E as extractTypeAliasDeclaration,f as extractTripleSlashDirectives,J as extractReferencedTypeDeclarations,H as extractModuleDeclaration,h as extractJSDocComments,D as extractInterfaceDeclaration,y as extractImportDeclaration,B as extractFunctionDeclaration,z as extractExportDeclaration,A as extractExportAssignment,G as extractEnumDeclaration,M as extractDeclarationsAsync,L as extractDeclarations,F as extractClassDeclaration,K as clearSourceFileCache,q as buildVariableDeclaration,t as buildTypeDeclaration,w as buildModuleDeclaration,x as buildModuleBody,r as buildInterfaceDeclaration,p as buildFunctionSignature,u as buildClassDeclaration,v as buildClassBody,c as batchParseSourceFiles,N as batchExtractDeclarations};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{ec as _}from"./chunk-y581wnfe.js";import{existsSync as w,readFileSync as U,writeFileSync as q}from"fs";function Z(G){let j=[],J=/\b([A-Z][a-zA-Z0-9]*)\b/g,L;while((L=J.exec(G))!==null){let K=L[1];if(!N(K))j.push(K)}return[...new Set(j)]}function N(G){return new Set(["Array","Object","String","Number","Boolean","Symbol","BigInt","Function","Promise","Map","Set","WeakMap","WeakSet","Date","RegExp","Error","TypeError","RangeError","SyntaxError","Partial","Required","Readonly","Pick","Omit","Record","Exclude","Extract","NonNullable","ReturnType","Parameters","ConstructorParameters","InstanceType","ThisType","Uppercase","Lowercase","Capitalize","Uncapitalize","Awaited","NoInfer","Generator","AsyncGenerator","IterableIterator","AsyncIterableIterator","PropertyKey","Iterable","AsyncIterable","ArrayLike","PromiseLike","ArrayBuffer","SharedArrayBuffer","DataView","Int8Array","Uint8Array","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"]).has(G)}function C(G){if(G.kind!=="type")return!1;let j=G.typeAnnotation||"";if(G.generics)return!1;if(j.includes("{")||j.includes("(")||j.includes("<"))return!1;return/^[\w\s|&]+$/.test(j)}function E(G){if(G.kind!=="interface")return!1;if(!G.members||G.members.length===0){if(!G.extends)return!0}return!1}function D(G,j){let J={...G,members:[...G.members||[],...j.members||[]],leadingComments:[...G.leadingComments||[],...j.leadingComments||[]]};if(G.extends&&j.extends){let L=G.extends.split(",").map((H)=>H.trim()),K=j.extends.split(",").map((H)=>H.trim());J.extends=[...new Set([...L,...K])].join(", ")}else J.extends=G.extends||j.extends;return J}function F(G){let j={import:0,interface:1,type:2,class:3,enum:4,function:5,variable:6,export:7};return[...G].sort((J,L)=>{let K=j[J.kind]??99,H=j[L.kind]??99;if(K!==H)return K-H;return J.name.localeCompare(L.name)})}function k(G){let j=[],J=[];for(let K=0;K<G.length;K++){let H=G[K];if(H.kind==="import")j.push(H);else J.push(H)}return[...[...j].sort((K,H)=>{let M=K.source||"",O=H.source||"",Q=M.startsWith("node:")||M==="bun",V=O.startsWith("node:")||O==="bun";if(Q&&!V)return-1;if(!Q&&V)return 1;let X=!M.startsWith("."),W=!O.startsWith(".");if(X&&!W)return-1;if(!X&&W)return 1;return M.localeCompare(O)}),...J]}function R(G){let j=new Set;for(let K of G){if(K.kind==="import")continue;let H=K.text||"",M=K.typeAnnotation||"",O=K.returnType||"",Q=K.extends||"",V=K.implements?.join(" ")||"",X=`${H} ${M} ${O} ${Q} ${V}`;for(let W of Z(X))j.add(W);if(K.members)for(let W of K.members){let Y=`${W.typeAnnotation||""} ${W.returnType||""}`;for(let $ of Z(Y))j.add($)}if(K.parameters){for(let W of K.parameters)if(W.type)for(let Y of Z(W.type))j.add(Y)}}let J=0;return{declarations:G.map((K)=>{if(K.kind!=="import"||!K.specifiers)return K;let H=K.specifiers.filter((M)=>{let O=M.alias||M.name;return j.has(O)});if(H.length===0){if(!K.isSideEffect)return J++,null}if(H.length<(K.specifiers?.length||0))return J+=(K.specifiers?.length||0)-H.length,{...K,specifiers:H};return K}).filter((K)=>K!==null),removed:J}}function A(G){let j=new Map,J=0;for(let L of G){if(L.kind==="import"){let H=`import:${L.source}`;if(j.has(H)){let M=j.get(H),O=[...M.specifiers||[],...L.specifiers||[]],Q=Array.from(new Map(O.map((V)=>[V.alias||V.name,V])).values());j.set(H,{...M,specifiers:Q}),J++}else j.set(H,L);continue}let K=`${L.kind}:${L.name}`;if(j.has(K))J++;else j.set(K,L)}return{declarations:Array.from(j.values()),removed:J}}function z(G){let j=new Map,J=[];for(let H of G)if(H.kind==="interface"){let M=H.name;if(!j.has(M))j.set(M,[]);j.get(M).push(H)}else J.push(H);let L=0,K=[];for(let[H,M]of j)if(M.length>1){let O=M[0];for(let Q=1;Q<M.length;Q++)O=D(O,M[Q]),L++;K.push(O)}else K.push(M[0]);return{declarations:[...J,...K],merged:L}}function P(G){let j=new Map,J=new Set;for(let H of G)if(C(H))j.set(H.name,H.typeAnnotation||""),J.add(H.name);if(j.size===0)return{declarations:G,inlined:0};function L(H){let M=H;for(let[O,Q]of j){let V=new RegExp(`\\b${O}\\b`,"g");M=M.replace(V,Q)}return M}return{declarations:G.filter((H)=>H.kind!=="type"||!J.has(H.name)).map((H)=>{if(H.typeAnnotation)H={...H,typeAnnotation:L(H.typeAnnotation)};if(H.returnType)H={...H,returnType:L(H.returnType)};if(H.extends)H={...H,extends:L(H.extends)};return H}),inlined:j.size}}function v(G){let j=G.length,J=G.filter((L)=>!E(L));return{declarations:J,removed:j-J.length}}function B(G,j={}){let J=[...G],L={originalSize:0,optimizedSize:0,savings:0,savingsPercent:0,removedImports:0,removedDeclarations:0,mergedInterfaces:0,inlinedTypes:0};if(j.removeUnusedImports){let{declarations:K,removed:H}=R(J);J=K,L.removedImports=H}if(j.deduplicateDeclarations){let{declarations:K,removed:H}=A(J);J=K,L.removedDeclarations+=H}if(j.mergeInterfaces){let{declarations:K,merged:H}=z(J);J=K,L.mergedInterfaces=H}if(j.removeEmptyInterfaces){let{declarations:K,removed:H}=v(J);J=K,L.removedDeclarations+=H}if(j.inlineSimpleTypes){let{declarations:K,inlined:H}=P(J);J=K,L.inlinedTypes=H}if(j.sortImports)J=k(J);if(j.sortDeclarations)J=F(J);return{declarations:J,result:L}}async function g(G,j={}){if(!w(G))throw Error(`File not found: ${G}`);let J=U(G,"utf-8"),L=Buffer.byteLength(J,"utf-8"),K=_(J,G,!j.removeComments),{declarations:H,result:M}=B(K,j),O=h(H,j);if(j.minify)O=x(O);let Q=Buffer.byteLength(O,"utf-8");return M.originalSize=L,M.optimizedSize=Q,M.savings=L-Q,M.savingsPercent=Math.round(M.savings/L*100),q(G,O),M}function h(G,j){let J=[];for(let L of G){if(!j.removeComments&&L.leadingComments)for(let K of L.leadingComments)J.push(K);if(L.text)J.push(L.text);else J.push(S(L));J.push("")}return J.join(`
2
+ import{ec as _}from"./chunk-69rnp3hs.js";import{existsSync as w,readFileSync as U,writeFileSync as q}from"fs";function Z(G){let j=[],J=/\b([A-Z][a-zA-Z0-9]*)\b/g,L;while((L=J.exec(G))!==null){let K=L[1];if(!N(K))j.push(K)}return[...new Set(j)]}function N(G){return new Set(["Array","Object","String","Number","Boolean","Symbol","BigInt","Function","Promise","Map","Set","WeakMap","WeakSet","Date","RegExp","Error","TypeError","RangeError","SyntaxError","Partial","Required","Readonly","Pick","Omit","Record","Exclude","Extract","NonNullable","ReturnType","Parameters","ConstructorParameters","InstanceType","ThisType","Uppercase","Lowercase","Capitalize","Uncapitalize","Awaited","NoInfer","Generator","AsyncGenerator","IterableIterator","AsyncIterableIterator","PropertyKey","Iterable","AsyncIterable","ArrayLike","PromiseLike","ArrayBuffer","SharedArrayBuffer","DataView","Int8Array","Uint8Array","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"]).has(G)}function C(G){if(G.kind!=="type")return!1;let j=G.typeAnnotation||"";if(G.generics)return!1;if(j.includes("{")||j.includes("(")||j.includes("<"))return!1;return/^[\w\s|&]+$/.test(j)}function E(G){if(G.kind!=="interface")return!1;if(!G.members||G.members.length===0){if(!G.extends)return!0}return!1}function D(G,j){let J={...G,members:[...G.members||[],...j.members||[]],leadingComments:[...G.leadingComments||[],...j.leadingComments||[]]};if(G.extends&&j.extends){let L=G.extends.split(",").map((H)=>H.trim()),K=j.extends.split(",").map((H)=>H.trim());J.extends=[...new Set([...L,...K])].join(", ")}else J.extends=G.extends||j.extends;return J}function F(G){let j={import:0,interface:1,type:2,class:3,enum:4,function:5,variable:6,export:7};return[...G].sort((J,L)=>{let K=j[J.kind]??99,H=j[L.kind]??99;if(K!==H)return K-H;return J.name.localeCompare(L.name)})}function k(G){let j=[],J=[];for(let K=0;K<G.length;K++){let H=G[K];if(H.kind==="import")j.push(H);else J.push(H)}return[...[...j].sort((K,H)=>{let M=K.source||"",O=H.source||"",Q=M.startsWith("node:")||M==="bun",V=O.startsWith("node:")||O==="bun";if(Q&&!V)return-1;if(!Q&&V)return 1;let X=!M.startsWith("."),W=!O.startsWith(".");if(X&&!W)return-1;if(!X&&W)return 1;return M.localeCompare(O)}),...J]}function R(G){let j=new Set;for(let K of G){if(K.kind==="import")continue;let H=K.text||"",M=K.typeAnnotation||"",O=K.returnType||"",Q=K.extends||"",V=K.implements?.join(" ")||"",X=`${H} ${M} ${O} ${Q} ${V}`;for(let W of Z(X))j.add(W);if(K.members)for(let W of K.members){let Y=`${W.typeAnnotation||""} ${W.returnType||""}`;for(let $ of Z(Y))j.add($)}if(K.parameters){for(let W of K.parameters)if(W.type)for(let Y of Z(W.type))j.add(Y)}}let J=0;return{declarations:G.map((K)=>{if(K.kind!=="import"||!K.specifiers)return K;let H=K.specifiers.filter((M)=>{let O=M.alias||M.name;return j.has(O)});if(H.length===0){if(!K.isSideEffect)return J++,null}if(H.length<(K.specifiers?.length||0))return J+=(K.specifiers?.length||0)-H.length,{...K,specifiers:H};return K}).filter((K)=>K!==null),removed:J}}function A(G){let j=new Map,J=0;for(let L of G){if(L.kind==="import"){let H=`import:${L.source}`;if(j.has(H)){let M=j.get(H),O=[...M.specifiers||[],...L.specifiers||[]],Q=Array.from(new Map(O.map((V)=>[V.alias||V.name,V])).values());j.set(H,{...M,specifiers:Q}),J++}else j.set(H,L);continue}let K=`${L.kind}:${L.name}`;if(j.has(K))J++;else j.set(K,L)}return{declarations:Array.from(j.values()),removed:J}}function z(G){let j=new Map,J=[];for(let H of G)if(H.kind==="interface"){let M=H.name;if(!j.has(M))j.set(M,[]);j.get(M).push(H)}else J.push(H);let L=0,K=[];for(let[H,M]of j)if(M.length>1){let O=M[0];for(let Q=1;Q<M.length;Q++)O=D(O,M[Q]),L++;K.push(O)}else K.push(M[0]);return{declarations:[...J,...K],merged:L}}function P(G){let j=new Map,J=new Set;for(let H of G)if(C(H))j.set(H.name,H.typeAnnotation||""),J.add(H.name);if(j.size===0)return{declarations:G,inlined:0};function L(H){let M=H;for(let[O,Q]of j){let V=new RegExp(`\\b${O}\\b`,"g");M=M.replace(V,Q)}return M}return{declarations:G.filter((H)=>H.kind!=="type"||!J.has(H.name)).map((H)=>{if(H.typeAnnotation)H={...H,typeAnnotation:L(H.typeAnnotation)};if(H.returnType)H={...H,returnType:L(H.returnType)};if(H.extends)H={...H,extends:L(H.extends)};return H}),inlined:j.size}}function v(G){let j=G.length,J=G.filter((L)=>!E(L));return{declarations:J,removed:j-J.length}}function B(G,j={}){let J=[...G],L={originalSize:0,optimizedSize:0,savings:0,savingsPercent:0,removedImports:0,removedDeclarations:0,mergedInterfaces:0,inlinedTypes:0};if(j.removeUnusedImports){let{declarations:K,removed:H}=R(J);J=K,L.removedImports=H}if(j.deduplicateDeclarations){let{declarations:K,removed:H}=A(J);J=K,L.removedDeclarations+=H}if(j.mergeInterfaces){let{declarations:K,merged:H}=z(J);J=K,L.mergedInterfaces=H}if(j.removeEmptyInterfaces){let{declarations:K,removed:H}=v(J);J=K,L.removedDeclarations+=H}if(j.inlineSimpleTypes){let{declarations:K,inlined:H}=P(J);J=K,L.inlinedTypes=H}if(j.sortImports)J=k(J);if(j.sortDeclarations)J=F(J);return{declarations:J,result:L}}async function g(G,j={}){if(!w(G))throw Error(`File not found: ${G}`);let J=U(G,"utf-8"),L=Buffer.byteLength(J,"utf-8"),K=_(J,G,!j.removeComments),{declarations:H,result:M}=B(K,j),O=h(H,j);if(j.minify)O=x(O);let Q=Buffer.byteLength(O,"utf-8");return M.originalSize=L,M.optimizedSize=Q,M.savings=L-Q,M.savingsPercent=Math.round(M.savings/L*100),q(G,O),M}function h(G,j){let J=[];for(let L of G){if(!j.removeComments&&L.leadingComments)for(let K of L.leadingComments)J.push(K);if(L.text)J.push(L.text);else J.push(S(L));J.push("")}return J.join(`
3
3
  `)}function S(G){let j=[];if(G.isExported)j.push("export");if(G.isDefault)j.push("default");switch(G.kind){case"import":if(G.isTypeOnly)j.push("import type");else j.push("import");if(G.specifiers&&G.specifiers.length>0){let J=G.specifiers.map((L)=>{let K=L.isType?"type ":"";return L.alias?`${K}${L.name} as ${L.alias}`:`${K}${L.name}`}).join(", ");j.push(`{ ${J} }`)}j.push("from"),j.push(`'${G.source}'`);break;case"function":if(j.push("declare function"),j.push(G.name),G.generics)j.push(G.generics);if(j.push(`(${I(G.parameters)})`),G.returnType)j.push(`: ${G.returnType}`);break;case"variable":if(j.push("declare const"),j.push(G.name),G.typeAnnotation)j.push(`: ${G.typeAnnotation}`);break;case"interface":if(j.push("interface"),j.push(G.name),G.generics)j.push(G.generics);if(G.extends)j.push(`extends ${G.extends}`);if(j.push("{"),G.members)for(let J of G.members)j.push(` ${J.name}${J.typeAnnotation?`: ${J.typeAnnotation}`:""}`);j.push("}");break;case"type":if(j.push("type"),j.push(G.name),G.generics)j.push(G.generics);j.push("="),j.push(G.typeAnnotation||"unknown");break;case"class":if(j.push("declare class"),j.push(G.name),G.generics)j.push(G.generics);if(G.extends)j.push(`extends ${G.extends}`);if(G.implements?.length)j.push(`implements ${G.implements.join(", ")}`);j.push("{ }");break;case"enum":j.push("declare enum"),j.push(G.name),j.push("{ }");break;default:return G.text||""}return j.join(" ")}function I(G){if(!G)return"";return G.map((j)=>{let J="";if(j.rest)J+="...";if(J+=j.name,j.optional)J+="?";if(j.type)J+=`: ${j.type}`;return J}).join(", ")}function x(G){return G.replace(/(?<!\/\*\*)\/\/[^\n]*/g,"").replace(/^\s*[\r\n]/gm,"").replace(/ {2,}/g," ").replace(/\s*([{}[\]();,:])\s*/g,"$1").replace(/(\w)(\{)/g,"$1 $2").replace(/(\})([a-z])/gi,"$1 $2").replace(/(export|import|type|interface|class|function|const|let|var|extends|implements|declare)\s*/g,"$1 ").trim()}
4
4
  export{B as a,g as b,x as c};