pando-ai 0.1.4 → 0.1.5

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 (150) hide show
  1. package/dist/cli.js +125 -125
  2. package/dist/watcher-process.js +334 -334
  3. package/dist/workers/chunk-Z7LW7C4Z.mjs +518 -0
  4. package/dist/workers/indexer-worker.mjs +1 -1
  5. package/dist/workers/snapshot-worker.mjs +8 -4
  6. package/package.json +5 -4
  7. package/resources/tools/{pando-tools.json → generated_pando-tools.json} +4 -4
  8. package/resources/tools/generated_tools.md +93 -0
  9. package/tools/clojure-editor/lib/pando-clojure-editor-standalone.jar +0 -0
  10. package/tools/clojure-indexer/lib/pando-clojure-indexer-standalone.jar +0 -0
  11. package/tools/csharp-indexer/CSharpIndexer.csproj +1 -1
  12. package/tools/csharp-indexer/bin/pando-csharp-indexer +81 -23
  13. package/tools/csharp-indexer/bin/pando-csharp-indexer.cmd +82 -14
  14. package/tools/csharp-indexer/src/Program.cs +1860 -0
  15. package/dist/workers/chunk-BD3AO7O3.mjs +0 -522
  16. package/tools/csharp-indexer/bin/Release/net10.0/CSharpIndexer +0 -0
  17. package/tools/csharp-indexer/bin/Release/net10.0/CSharpIndexer.deps.json +0 -383
  18. package/tools/csharp-indexer/bin/Release/net10.0/CSharpIndexer.dll +0 -0
  19. package/tools/csharp-indexer/bin/Release/net10.0/CSharpIndexer.pdb +0 -0
  20. package/tools/csharp-indexer/bin/Release/net10.0/CSharpIndexer.runtimeconfig.json +0 -13
  21. package/tools/csharp-indexer/bin/Release/net10.0/Humanizer.dll +0 -0
  22. package/tools/csharp-indexer/bin/Release/net10.0/Microsoft.CodeAnalysis.CSharp.Workspaces.dll +0 -0
  23. package/tools/csharp-indexer/bin/Release/net10.0/Microsoft.CodeAnalysis.CSharp.dll +0 -0
  24. package/tools/csharp-indexer/bin/Release/net10.0/Microsoft.CodeAnalysis.Workspaces.dll +0 -0
  25. package/tools/csharp-indexer/bin/Release/net10.0/Microsoft.CodeAnalysis.dll +0 -0
  26. package/tools/csharp-indexer/bin/Release/net10.0/System.Composition.AttributedModel.dll +0 -0
  27. package/tools/csharp-indexer/bin/Release/net10.0/System.Composition.Convention.dll +0 -0
  28. package/tools/csharp-indexer/bin/Release/net10.0/System.Composition.Hosting.dll +0 -0
  29. package/tools/csharp-indexer/bin/Release/net10.0/System.Composition.Runtime.dll +0 -0
  30. package/tools/csharp-indexer/bin/Release/net10.0/System.Composition.TypedParts.dll +0 -0
  31. package/tools/csharp-indexer/bin/Release/net10.0/cs/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  32. package/tools/csharp-indexer/bin/Release/net10.0/cs/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  33. package/tools/csharp-indexer/bin/Release/net10.0/cs/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  34. package/tools/csharp-indexer/bin/Release/net10.0/cs/Microsoft.CodeAnalysis.resources.dll +0 -0
  35. package/tools/csharp-indexer/bin/Release/net10.0/de/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  36. package/tools/csharp-indexer/bin/Release/net10.0/de/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  37. package/tools/csharp-indexer/bin/Release/net10.0/de/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  38. package/tools/csharp-indexer/bin/Release/net10.0/de/Microsoft.CodeAnalysis.resources.dll +0 -0
  39. package/tools/csharp-indexer/bin/Release/net10.0/es/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  40. package/tools/csharp-indexer/bin/Release/net10.0/es/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  41. package/tools/csharp-indexer/bin/Release/net10.0/es/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  42. package/tools/csharp-indexer/bin/Release/net10.0/es/Microsoft.CodeAnalysis.resources.dll +0 -0
  43. package/tools/csharp-indexer/bin/Release/net10.0/fr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  44. package/tools/csharp-indexer/bin/Release/net10.0/fr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  45. package/tools/csharp-indexer/bin/Release/net10.0/fr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  46. package/tools/csharp-indexer/bin/Release/net10.0/fr/Microsoft.CodeAnalysis.resources.dll +0 -0
  47. package/tools/csharp-indexer/bin/Release/net10.0/it/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  48. package/tools/csharp-indexer/bin/Release/net10.0/it/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  49. package/tools/csharp-indexer/bin/Release/net10.0/it/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  50. package/tools/csharp-indexer/bin/Release/net10.0/it/Microsoft.CodeAnalysis.resources.dll +0 -0
  51. package/tools/csharp-indexer/bin/Release/net10.0/ja/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  52. package/tools/csharp-indexer/bin/Release/net10.0/ja/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  53. package/tools/csharp-indexer/bin/Release/net10.0/ja/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  54. package/tools/csharp-indexer/bin/Release/net10.0/ja/Microsoft.CodeAnalysis.resources.dll +0 -0
  55. package/tools/csharp-indexer/bin/Release/net10.0/ko/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  56. package/tools/csharp-indexer/bin/Release/net10.0/ko/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  57. package/tools/csharp-indexer/bin/Release/net10.0/ko/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  58. package/tools/csharp-indexer/bin/Release/net10.0/ko/Microsoft.CodeAnalysis.resources.dll +0 -0
  59. package/tools/csharp-indexer/bin/Release/net10.0/pl/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  60. package/tools/csharp-indexer/bin/Release/net10.0/pl/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  61. package/tools/csharp-indexer/bin/Release/net10.0/pl/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  62. package/tools/csharp-indexer/bin/Release/net10.0/pl/Microsoft.CodeAnalysis.resources.dll +0 -0
  63. package/tools/csharp-indexer/bin/Release/net10.0/pt-BR/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  64. package/tools/csharp-indexer/bin/Release/net10.0/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  65. package/tools/csharp-indexer/bin/Release/net10.0/pt-BR/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  66. package/tools/csharp-indexer/bin/Release/net10.0/pt-BR/Microsoft.CodeAnalysis.resources.dll +0 -0
  67. package/tools/csharp-indexer/bin/Release/net10.0/ru/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  68. package/tools/csharp-indexer/bin/Release/net10.0/ru/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  69. package/tools/csharp-indexer/bin/Release/net10.0/ru/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  70. package/tools/csharp-indexer/bin/Release/net10.0/ru/Microsoft.CodeAnalysis.resources.dll +0 -0
  71. package/tools/csharp-indexer/bin/Release/net10.0/tr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  72. package/tools/csharp-indexer/bin/Release/net10.0/tr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  73. package/tools/csharp-indexer/bin/Release/net10.0/tr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  74. package/tools/csharp-indexer/bin/Release/net10.0/tr/Microsoft.CodeAnalysis.resources.dll +0 -0
  75. package/tools/csharp-indexer/bin/Release/net10.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  76. package/tools/csharp-indexer/bin/Release/net10.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  77. package/tools/csharp-indexer/bin/Release/net10.0/zh-Hans/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  78. package/tools/csharp-indexer/bin/Release/net10.0/zh-Hans/Microsoft.CodeAnalysis.resources.dll +0 -0
  79. package/tools/csharp-indexer/bin/Release/net10.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  80. package/tools/csharp-indexer/bin/Release/net10.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  81. package/tools/csharp-indexer/bin/Release/net10.0/zh-Hant/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  82. package/tools/csharp-indexer/bin/Release/net10.0/zh-Hant/Microsoft.CodeAnalysis.resources.dll +0 -0
  83. package/tools/csharp-indexer/bin/Release/net8.0/CSharpIndexer +0 -0
  84. package/tools/csharp-indexer/bin/Release/net8.0/CSharpIndexer.deps.json +0 -400
  85. package/tools/csharp-indexer/bin/Release/net8.0/CSharpIndexer.dll +0 -0
  86. package/tools/csharp-indexer/bin/Release/net8.0/CSharpIndexer.pdb +0 -0
  87. package/tools/csharp-indexer/bin/Release/net8.0/CSharpIndexer.runtimeconfig.json +0 -13
  88. package/tools/csharp-indexer/bin/Release/net8.0/Humanizer.dll +0 -0
  89. package/tools/csharp-indexer/bin/Release/net8.0/Microsoft.CodeAnalysis.CSharp.Workspaces.dll +0 -0
  90. package/tools/csharp-indexer/bin/Release/net8.0/Microsoft.CodeAnalysis.CSharp.dll +0 -0
  91. package/tools/csharp-indexer/bin/Release/net8.0/Microsoft.CodeAnalysis.Workspaces.dll +0 -0
  92. package/tools/csharp-indexer/bin/Release/net8.0/Microsoft.CodeAnalysis.dll +0 -0
  93. package/tools/csharp-indexer/bin/Release/net8.0/System.Composition.AttributedModel.dll +0 -0
  94. package/tools/csharp-indexer/bin/Release/net8.0/System.Composition.Convention.dll +0 -0
  95. package/tools/csharp-indexer/bin/Release/net8.0/System.Composition.Hosting.dll +0 -0
  96. package/tools/csharp-indexer/bin/Release/net8.0/System.Composition.Runtime.dll +0 -0
  97. package/tools/csharp-indexer/bin/Release/net8.0/System.Composition.TypedParts.dll +0 -0
  98. package/tools/csharp-indexer/bin/Release/net8.0/System.IO.Pipelines.dll +0 -0
  99. package/tools/csharp-indexer/bin/Release/net8.0/cs/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  100. package/tools/csharp-indexer/bin/Release/net8.0/cs/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  101. package/tools/csharp-indexer/bin/Release/net8.0/cs/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  102. package/tools/csharp-indexer/bin/Release/net8.0/cs/Microsoft.CodeAnalysis.resources.dll +0 -0
  103. package/tools/csharp-indexer/bin/Release/net8.0/de/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  104. package/tools/csharp-indexer/bin/Release/net8.0/de/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  105. package/tools/csharp-indexer/bin/Release/net8.0/de/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  106. package/tools/csharp-indexer/bin/Release/net8.0/de/Microsoft.CodeAnalysis.resources.dll +0 -0
  107. package/tools/csharp-indexer/bin/Release/net8.0/es/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  108. package/tools/csharp-indexer/bin/Release/net8.0/es/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  109. package/tools/csharp-indexer/bin/Release/net8.0/es/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  110. package/tools/csharp-indexer/bin/Release/net8.0/es/Microsoft.CodeAnalysis.resources.dll +0 -0
  111. package/tools/csharp-indexer/bin/Release/net8.0/fr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  112. package/tools/csharp-indexer/bin/Release/net8.0/fr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  113. package/tools/csharp-indexer/bin/Release/net8.0/fr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  114. package/tools/csharp-indexer/bin/Release/net8.0/fr/Microsoft.CodeAnalysis.resources.dll +0 -0
  115. package/tools/csharp-indexer/bin/Release/net8.0/it/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  116. package/tools/csharp-indexer/bin/Release/net8.0/it/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  117. package/tools/csharp-indexer/bin/Release/net8.0/it/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  118. package/tools/csharp-indexer/bin/Release/net8.0/it/Microsoft.CodeAnalysis.resources.dll +0 -0
  119. package/tools/csharp-indexer/bin/Release/net8.0/ja/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  120. package/tools/csharp-indexer/bin/Release/net8.0/ja/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  121. package/tools/csharp-indexer/bin/Release/net8.0/ja/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  122. package/tools/csharp-indexer/bin/Release/net8.0/ja/Microsoft.CodeAnalysis.resources.dll +0 -0
  123. package/tools/csharp-indexer/bin/Release/net8.0/ko/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  124. package/tools/csharp-indexer/bin/Release/net8.0/ko/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  125. package/tools/csharp-indexer/bin/Release/net8.0/ko/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  126. package/tools/csharp-indexer/bin/Release/net8.0/ko/Microsoft.CodeAnalysis.resources.dll +0 -0
  127. package/tools/csharp-indexer/bin/Release/net8.0/pl/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  128. package/tools/csharp-indexer/bin/Release/net8.0/pl/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  129. package/tools/csharp-indexer/bin/Release/net8.0/pl/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  130. package/tools/csharp-indexer/bin/Release/net8.0/pl/Microsoft.CodeAnalysis.resources.dll +0 -0
  131. package/tools/csharp-indexer/bin/Release/net8.0/pt-BR/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  132. package/tools/csharp-indexer/bin/Release/net8.0/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  133. package/tools/csharp-indexer/bin/Release/net8.0/pt-BR/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  134. package/tools/csharp-indexer/bin/Release/net8.0/pt-BR/Microsoft.CodeAnalysis.resources.dll +0 -0
  135. package/tools/csharp-indexer/bin/Release/net8.0/ru/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  136. package/tools/csharp-indexer/bin/Release/net8.0/ru/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  137. package/tools/csharp-indexer/bin/Release/net8.0/ru/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  138. package/tools/csharp-indexer/bin/Release/net8.0/ru/Microsoft.CodeAnalysis.resources.dll +0 -0
  139. package/tools/csharp-indexer/bin/Release/net8.0/tr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  140. package/tools/csharp-indexer/bin/Release/net8.0/tr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  141. package/tools/csharp-indexer/bin/Release/net8.0/tr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  142. package/tools/csharp-indexer/bin/Release/net8.0/tr/Microsoft.CodeAnalysis.resources.dll +0 -0
  143. package/tools/csharp-indexer/bin/Release/net8.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  144. package/tools/csharp-indexer/bin/Release/net8.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  145. package/tools/csharp-indexer/bin/Release/net8.0/zh-Hans/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  146. package/tools/csharp-indexer/bin/Release/net8.0/zh-Hans/Microsoft.CodeAnalysis.resources.dll +0 -0
  147. package/tools/csharp-indexer/bin/Release/net8.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  148. package/tools/csharp-indexer/bin/Release/net8.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  149. package/tools/csharp-indexer/bin/Release/net8.0/zh-Hant/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  150. package/tools/csharp-indexer/bin/Release/net8.0/zh-Hant/Microsoft.CodeAnalysis.resources.dll +0 -0
@@ -0,0 +1,518 @@
1
+ import{c as pn,d as re,e as L,f as ct}from"./chunk-ODST7O2H.mjs";import{a as dn}from"./chunk-AYCBSZ56.mjs";var G={getAbbrev(n,e="ts"){return n},getKindFromAbbrev(n,e="ts"){return n}};function ye(n){let e=`${n.sourceFile}#${n.sourceStart}-${n.sourceEnd}`,t=n.refKind??"",r=n.refName??"",i=n.targetFile??"",s=n.targetStart!=null&&n.targetEnd!=null?`#${n.targetStart}-${n.targetEnd}`:"",o=n.targetNodeId??"",a=`${e}:REF:${t}:${r}|${i}${s}|${o}`;return ct(a)}function ut(n){let e=[],t=new Set,r=i=>{!i?.name||t.has(i.name)||(t.add(i.name),e.push(i))};for(let i of n.exports??[])r(i);for(let i of n.explicitExports??[])r({name:i});for(let i of n.modulePublic??[])r({name:i});return e}function ce(n,e,t){let r=new Date().toISOString();return{payload:{lang:n,fileRel:e,preDeleted:!1,exportRows:[],nodeRows:[],referenceRows:[],symbolMentionRows:[],importRows:[],importBindingRows:[],fileRow:[e,t?.mtime??null,t?.size??null,"failed",r],fts:null},fileSize:t?.size,mtime:t?.mtime}}function ue(n){let{lang:e,fileRel:t,content:r,meta:i,preDeleted:s,parsed:o,resolveNodeId:a,exportKind:c}=n,g=[];for(let l of o.nodes??[]){let x=l.rawKind??l.kind,S=l.rawKindSource??"cli",_=l.containerRawKind??l.containerKind??null,O=l.containerRawKindSource??(_?"cli":null),p=l.scopeChain??null,h=Array.isArray(p)?JSON.stringify(p):typeof p=="string"?p:null,v=`${t}#${l.start}-${l.end}:${G.getAbbrev(l.kind,e)}`,b=(e==="c"||e==="cpp"||e==="java"||e==="clojure")&&l.name?`${v}:${l.name}`:v,K=l.metadata&&Object.keys(l.metadata).length?JSON.stringify(l.metadata):null;g.push([b,l.name,l.kind,x,S,l.semanticKind??null,l.start,l.end,typeof l.isExported=="number"?l.isExported:0,l.containerKind??null,_,O,typeof l.paramCount=="number"?l.paramCount:null,l.qualifiedName??null,h,l.symbolKey??null,K])}let d=[],m=new Set;for(let l of ut(o)){if(!l.name||m.has(l.name))continue;m.add(l.name);let x=l.nodeId??(a?a(l.name):null);d.push([t,l.name,x??null,l.isReexport?1:0,l.reexportFrom??null,l.reexportName??null,l.exportKind??c??"cli",l.targetSymbolKey??null])}let y=[],P=[],C=new Map,w=new Map;for(let l of g){let x=l[0]!=null?String(l[0]):null,S=l[13]!=null?String(l[13]):null,_=l[15]!=null?String(l[15]):null;x&&(S&&!C.has(S)&&C.set(S,x),_&&!w.has(_)&&w.set(_,x))}if(re()&&e==="clojure"&&(o.references??[]).length>0){let l=Array.from(C.keys()).slice(0,10),x=Array.from(w.keys()).slice(0,10),S=(o.references??[]).slice(0,10).map(O=>O.containerQualifiedName),_={file:t,nodeCount:g.length,refCount:(o.references??[]).length,nodeQualifiedNames:l,nodeSymbolKeys:x,refContainers:S,qualifiedNameMapSize:C.size,symbolKeyMapSize:w.size};try{console.error("[CliPayload][CLOJURE-DEBUG] source_node_id lookup context",_)}catch{}}for(let l of o.references??[]){let x=l.targetNodeId??(a&&l.refName?a(l.refName):null),S=l.targetFile??(x?t:null),_=l.sourceNodeId??(l.containerQualifiedName?C.get(l.containerQualifiedName)??null:null)??(l.containerQualifiedName?w.get(l.containerQualifiedName)??null:null),O=ye({sourceFile:t,sourceStart:l.sourceStart,sourceEnd:l.sourceEnd,refKind:l.refKind,refName:l.refName,targetFile:S??null,targetStart:l.targetStart??null,targetEnd:l.targetEnd??null,targetNodeId:x??l.targetNodeId??null}),p=l.metadata&&Object.keys(l.metadata).length?JSON.stringify(l.metadata):null;y.push([O,t,_,l.refName??null,l.refKind,l.sourceStart,l.sourceEnd,x??l.targetNodeId??null,S??null,x||l.targetNodeId||l.targetFile?"resolved":"unresolved",l.receiverName??null,typeof l.arity=="number"?l.arity:null,l.containerQualifiedName??null,l.targetSymbolKey??null,l.confidence??null,p])}for(let l of o.symbolMentions??[]){let x=typeof l?.name=="string"?l.name.trim():"";if(!x)continue;let S=typeof l?.mentionKind=="string"&&l.mentionKind.trim().length>0?l.mentionKind.trim():"reference",_=typeof l?.count=="number"&&Number.isFinite(l.count)&&l.count>0?Math.floor(l.count):1;P.push([x,S,l.targetSymbolKey??null,l.containerQualifiedName??null,_])}if(re()&&e==="clojure"&&y.length>0){let l=y.reduce((S,_)=>S+(_?.[2]!=null?1:0),0),x=y.reduce((S,_)=>S+(_?.[12]!=null?1:0),0);try{console.error("[CliPayload] clojure source-node summary",{file:t,refs:y.length,sourceNodeCount:l,containerCount:x,sample:y.slice(0,5).map(S=>({sourceNodeId:S[2]==null?null:String(S[2]),refName:S[3],refKind:S[4],containerQualifiedName:S[12]}))})}catch{}}let A=[];for(let l of o.imports??[])A.push([t,l.module??null,l.isTypeOnly??0]);let R=[];for(let l of o.importBindings??[])R.push([t,l.module??null,l.kind,l.localName,l.importedName,l.isTypeOnly??0]);let u=new Date().toISOString(),N=[t,i?.mtime??null,i?.size??null,"completed",u];return{payload:{lang:e,fileRel:t,preDeleted:!!s,exportRows:d,nodeRows:g,referenceRows:y,symbolMentionRows:P,importRows:A,importBindingRows:R,fileRow:N,fts:typeof r=="string"?{blobOid:t,content:r}:null},fileSize:i?.size,mtime:i?.mtime}}var de=["ts","js","python","c","cpp","csharp","dart","java","clojure"];function Le(n){return typeof n=="string"&&de.includes(n)}pn();function dt(){let n=process.env.PANDO_ENABLED_LANGUAGES;if(n&&n.trim().length>0){let t=n.split(",").map(r=>r.trim()).filter(r=>r.length>0).filter(Le);if(t.length>0)return pt(t)}return[...de]}function pt(n){let e=new Set;for(let t of n)Le(t)&&e.add(t);return de.filter(t=>e.has(t))}function ft(n){let e=new Set(pt(n)),t={};for(let r of de){if(e.has(r)){t[r]={enabled:!0,source:"embedded"};continue}t[r]={enabled:!1,source:"none",reason:"disabled by language support config"}}return{byLanguage:t}}import ze from"path";import vn from"fs";import{Project as Sn,Node as q}from"ts-morph";import{Node as f,SyntaxKind as ie}from"ts-morph";import*as z from"typescript";import{SyntaxKind as pe}from"ts-morph";var Be={LINE_COMMENT:{kind:9001,name:"LineComment",triviaKind:pe.SingleLineCommentTrivia},BLOCK_COMMENT:{kind:9002,name:"BlockComment",triviaKind:pe.MultiLineCommentTrivia},JSDOC_COMMENT:{kind:9003,name:"JSDocComment",triviaKind:pe.MultiLineCommentTrivia}};function mt(n,e){return n===pe.SingleLineCommentTrivia?Be.LINE_COMMENT:n===pe.MultiLineCommentTrivia&&e.startsWith("/**")?Be.JSDOC_COMMENT:Be.BLOCK_COMMENT}import{Node as T}from"ts-morph";var gt={TS_MORPH:"ts-morph",PYTHON_AST:"python-ast",CLANG:"clang",ROSLYN:"roslyn",JAVA_AST:"java-ast",CLI:"cli",UNKNOWN:"unknown"},ht=(n,e)=>T.isFunctionDeclaration(n)||T.isFunctionExpression(n)||T.isArrowFunction(n)?{kind:"Function",semanticKind:"function"}:T.isGetAccessorDeclaration(n)||T.isSetAccessorDeclaration(n)?{kind:"Method",semanticKind:"property"}:T.isMethodDeclaration(n)||T.isMethodSignature(n)||T.isConstructorDeclaration(n)?{kind:"Method",semanticKind:"method"}:T.isClassDeclaration(n)||T.isClassExpression(n)?{kind:"Class",semanticKind:"class"}:T.isInterfaceDeclaration(n)?{kind:"Interface",semanticKind:"interface"}:T.isEnumDeclaration(n)?{kind:"Enum",semanticKind:"enum"}:T.isEnumMember(n)?{kind:"EnumMember",semanticKind:"enum"}:T.isTypeAliasDeclaration(n)?{kind:"TypeAlias",semanticKind:"type"}:T.isModuleDeclaration(n)?{kind:"Namespace",semanticKind:"namespace"}:T.isPropertyDeclaration(n)||T.isPropertySignature(n)?{kind:"Field",semanticKind:"property"}:T.isVariableDeclaration(n)?{kind:"Variable",semanticKind:"variable"}:{kind:e,semanticKind:null};function yt(n){try{let e=n.getKindName?.();if(typeof e=="string"&&e.trim())return e}catch{}return"Unknown"}function be(n){let e=yt(n),t=ht(n,e);return{kind:t.kind,semanticKind:t.semanticKind,rawKind:e,rawKindSource:gt.TS_MORPH}}function bt(n){let e=yt(n);return{kind:ht(n,e).kind,rawKind:e,rawKindSource:gt.TS_MORPH}}function xe(n,e){if(!n.kind||!n.kind.trim())throw new Error(`Invalid normalized kind: missing kind ${e?JSON.stringify(e):""}`);if(!n.rawKind||!n.rawKind.trim())throw new Error(`Invalid normalized kind: missing rawKind ${e?JSON.stringify(e):""}`);if(!n.rawKindSource||!String(n.rawKindSource).trim())throw new Error(`Invalid normalized kind: missing rawKindSource ${e?JSON.stringify(e):""}`)}function fn(n){if(n.kind==="local"){let r=n.isDefault?"default":n.name;return r?{name:r,priority:n.isDefault?4:3}:null}if(n.kind==="alias")return n.exported?{name:n.exported,priority:2}:null;let e=n.isNamespace??!1,t=n.alias||n.name||(e?"*":null);return t?{name:t,priority:e?0:1}:null}function mn(n){if(n.length<2)return n;let e=new Map;for(let t of n){let r=fn(t);if(!r)continue;let i=e.get(r.name);(!i||r.priority>i.priority)&&e.set(r.name,{record:t,priority:r.priority})}return Array.from(e.values()).map(t=>t.record)}function ve(n){try{if(n&&typeof n.getName=="function"){let e=n.getName();if(typeof e=="string"&&e.length>0)return e}}catch{}return null}function xt(n){let e;try{let r=n.getStart?.(!1);typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getFullStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}e===void 0&&(e=0);let t;try{let r=n.getEnd?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}if(t===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}return t===void 0&&(t=e),t<e&&(t=e),{start:e,end:t}}function gn(n){try{if(f.isFunctionDeclaration(n)||f.isMethodDeclaration(n)||f.isConstructorDeclaration(n)||f.isFunctionExpression(n)||f.isArrowFunction(n)){let e=n.getParameters?.();if(Array.isArray(e))return e.length}}catch{}return null}function hn(n){try{return f.isIdentifier(n)?n.getSymbol():f.isPropertyAccessExpression(n)?n.getNameNode().getSymbol()??n.getSymbol():n.getSymbol?.()}catch{return}}function Se(n,e){try{return typeof n?.hasModifier=="function"&&n.hasModifier(e)}catch{return!1}}function vt(n){try{return n.getModuleSpecifierValue?.()??null}catch{try{return n.getModuleSpecifier?.()?.getLiteralText?.()??null}catch{return null}}}function yn(n,e,t){if(!f.isImportDeclaration(n))return;let i={moduleSpecifier:vt(n),isTypeOnly:n.isTypeOnly(),namedImports:[]};try{let s=n.getDefaultImport();if(s){let o=s.getText();i.defaultImport=o,t(o,s)}}catch{}try{let s=n.getNamespaceImport();if(s){let o=s.getText();i.namespaceImport=o,t(o,s)}}catch{}try{n.getNamedImports().forEach(s=>{try{let o=s.getName(),a=s.getAliasNode(),c=a?a.getText():void 0;o&&(i.namedImports.push({name:o,alias:c||void 0}),t(c||o,s.getNameNode()))}catch{}})}catch{}e.push(i)}function bn(n,e){if(f.isExportDeclaration(n)){let t=vt(n);if(t){if(n.getNamedExports().length>0)try{n.getNamedExports().forEach(r=>{try{let i=r.getName(),s=r.getAliasNode(),o=s?s.getText():void 0;e.push({kind:"reexport",moduleSpecifier:t,name:i||void 0,alias:o||void 0,isNamespace:!1})}catch{}})}catch{}else if(n.isNamespaceExport())try{let i=n.getNamespaceExport()?.getName();e.push({kind:"reexport",moduleSpecifier:t,name:i||"*",alias:i||void 0,isNamespace:!0})}catch{e.push({kind:"reexport",moduleSpecifier:t,name:"*",isNamespace:!0})}else e.push({kind:"reexport",moduleSpecifier:t,name:"*",isNamespace:!0});return}try{n.getNamedExports().forEach(r=>{try{let i=r.getName();if(!i)return;let s=r.getAliasNode(),o=s?s.getText():i;e.push({kind:"alias",local:i,exported:o})}catch{}})}catch{}return}if(f.isExportAssignment(n))try{let t=n.getExpression();if(t&&f.isIdentifier(t)){let r=t.getText();e.push({kind:"alias",local:r,exported:"default"})}}catch{}}function xn(n,e,t,r){if(!Se(n,ie.ExportKeyword))return;let i=Se(n,ie.DefaultKeyword);if(f.isVariableStatement(n)){try{let s=n.getDeclarationList().getDeclarations();for(let o of s){let a=ve(o)??o.getName?.()??null;if(a){t(a,o);let c=r(o);c&&e.push({kind:"local",name:a,isDefault:i,nodeId:c})}}}catch{}return}if(f.isFunctionDeclaration(n)||f.isClassDeclaration(n)||f.isInterfaceDeclaration(n)||f.isEnumDeclaration(n)||f.isTypeAliasDeclaration(n)||f.isModuleDeclaration(n)){let s=ve(n)||(i?"default":null),o=r(n);o&&e.push({kind:"local",name:s??"default",isDefault:i,nodeId:o})}}function St(n,e,t,r){let i=[],s=[],o=[],a=new Set,c=new Map,g=[],d=[],m=[{node:n,id:null,kind:"module",rawKind:"SourceFile",rawKindSource:"ts-morph",name:null,isExported:!1}],y=u=>{if(!u)return null;try{return e(u)}catch{return null}},P=(u,N)=>{if(u&&(a.has(u)||a.add(u),N&&!c.has(u))){let E=y(N);E&&c.set(u,E)}},C=u=>f.isFunctionDeclaration(u)||f.isFunctionExpression(u)||f.isArrowFunction(u)||f.isClassDeclaration(u)||f.isClassExpression(u)||f.isInterfaceDeclaration(u)||f.isEnumDeclaration(u)||f.isEnumMember(u)||f.isTypeAliasDeclaration(u)||f.isModuleDeclaration(u)||f.isMethodDeclaration(u)||f.isMethodSignature(u)||f.isPropertyDeclaration(u)||f.isPropertySignature(u)||f.isGetAccessorDeclaration(u)||f.isSetAccessorDeclaration(u)||f.isConstructorDeclaration(u)||f.isVariableDeclaration(u),w=u=>f.isSourceFile(u)||f.isFunctionDeclaration(u)||f.isFunctionExpression(u)||f.isArrowFunction(u)||f.isMethodDeclaration(u)||f.isConstructorDeclaration(u)||f.isClassDeclaration(u)||f.isClassExpression(u)||f.isModuleDeclaration(u),A=u=>{let N=ve(u);if(N)return N;if(f.isConstructorDeclaration(u))return"constructor";if(f.isArrowFunction(u)||f.isFunctionExpression(u)){let E=u.getParent();try{if(f.isVariableDeclaration(E))return E.getName();if(f.isPropertyAssignment(E)||f.isPropertyDeclaration(E)||f.isPropertySignature(E))return E.getName?.()??null;if(f.isShorthandPropertyAssignment(E))return E.getNameNode()?.getText()??null;if(f.isExportAssignment(E))return"default"}catch{}}if(f.isEnumMember(u))try{return u.getName()}catch{return null}if(f.isVariableDeclaration(u))try{return u.getName()}catch{return null}return null},R=u=>{let N=m[m.length-1],E=N?.id??null,l=N?.kind??"module",x=N?.name??null;if(f.isImportDeclaration(u))yn(u,g,P);else if(f.isImportEqualsDeclaration(u))try{let p=u.getModuleReference();if(p&&f.isExternalModuleReference(p)){let h=p.getExpression(),v;if(h&&f.isStringLiteral(h))v=h.getLiteralText();else if(h){let b=h.getText();v=typeof b=="string"?b.replace(/^['"]|['"]$/g,""):void 0}if(v){let K=u.getNameNode()?.getText(),j={moduleSpecifier:v,isTypeOnly:!1,namedImports:[]};K&&(j.defaultImport=K,P(K,u)),g.push(j)}}}catch{}(f.isExportDeclaration(u)||f.isExportAssignment(u))&&bn(u,d),xn(u,d,P,y);let S=C(u),_=S?A(u):null;if(S){let p=e(u);s.push({nodeId:p,node:u});let h=Se(u,ie.ExportKeyword)||N?.isExported||!1,v=S?u.getNameNode?.()?.getText?.()??null:null,b=_??(S?ve(u)??v:null);_?P(_,u):b&&P(b,u);let K=xt(u),j=gn(u),D=be(u);xe(D,{source:"ts-node-collector",file:n.getFilePath(),name:b??null}),i.push({nodeId:p,nodeName:b??null,containerId:E,containerKind:l,containerRawKind:N?.rawKind??null,containerRawKindSource:N?.rawKindSource??null,containerName:x,isExported:h,kind:D.kind,rawKind:D.rawKind,rawKindSource:D.rawKindSource,semanticKind:D.semanticKind??null,start:K.start,end:K.end,paramCount:j,metadata:null})}if(f.isCallExpression(u)||f.isNewExpression(u)){let p=u.getExpression(),h=null,v,b;try{if(b=hn(p),f.isIdentifier(p))h=p.getText();else if(f.isPropertyAccessExpression(p)){h=p.getName();let D=p.getExpression();f.isIdentifier(D)&&(v=D.getText())}}catch{}let K="";try{K=p.getText()}catch{}let j=xt(u);if(o.push({name:h,kind:f.isNewExpression(u)?"new":"call",containerId:E,containerKind:l,containerName:x,expression:K,objectName:v,symbol:b,start:j.start,end:j.end}),f.isCallExpression(u))try{if(f.isIdentifier(p)&&p.getText()==="require"){let I=u.getArguments()[0],F;if(I&&(f.isStringLiteral(I)||f.isNoSubstitutionTemplateLiteral(I)))try{F=I.getLiteralText()}catch{let M=I.getText();F=typeof M=="string"?M.replace(/^['"]|['"]$/g,""):void 0}if(F){let M={moduleSpecifier:F,isTypeOnly:!1,namedImports:[]},$=u.getParent();if($&&f.isVariableDeclaration($)){let V=$.getNameNode();try{if(f.isIdentifier(V)){let U=V.getText();U&&(M.defaultImport=U,P(U,$))}}catch{}}g.push(M)}}else if(p?.getKind?.()===ie.ImportKeyword){let I=u.getArguments()[0],F;if(I&&(f.isStringLiteral(I)||f.isNoSubstitutionTemplateLiteral(I)))try{F=I.getLiteralText()}catch{let M=I.getText();F=typeof M=="string"?M.replace(/^['"]|['"]$/g,""):void 0}F&&g.push({moduleSpecifier:F,isTypeOnly:!1,namedImports:[]})}}catch{}}if(f.isCallExpression(u)){let p=u.getExpression();try{if(f.isIdentifier(p)&&p.getText()==="require"){let h=u.getParent();if(!(h&&f.isExternalModuleReference(h))){let b=u.getArguments()[0],K;if(b&&(f.isStringLiteral(b)||f.isNoSubstitutionTemplateLiteral(b)))try{K=b.getLiteralText()}catch{K=b.getText().replace(/^['"]|['"]$/g,"")}if(K){let j={moduleSpecifier:K,isTypeOnly:!1,namedImports:[]};if(h&&f.isVariableDeclaration(h)){let D=h.getNameNode();try{if(f.isIdentifier(D)){let I=D.getText();I&&(j.defaultImport=I,P(I,h))}}catch{}}g.push(j)}}}else if(p?.getKind?.()===ie.ImportKeyword){let v=u.getArguments()[0],b;if(v&&(f.isStringLiteral(v)||f.isNoSubstitutionTemplateLiteral(v)))try{b=v.getLiteralText()}catch{b=v.getText().replace(/^['"]|['"]$/g,"")}b&&g.push({moduleSpecifier:b,isTypeOnly:!1,namedImports:[]})}}catch{}}let O=!1;if(w(u)){let p=y(u)??e(u),h=bt(u);m.push({node:u,id:p,kind:h.kind,rawKind:h.rawKind,rawKindSource:h.rawKindSource,name:_??x,isExported:Se(u,ie.ExportKeyword)||N?.isExported||!1}),O=!0}u.forEachChild(R),O&&m.pop()};if(n.forEachChild(R),r?.includeComments===!0||process.env.AST_INDEX_COMMENTS==="1")try{let u=n.getFullText(),N=z.createScanner(z.ScriptTarget.Latest,!1,z.LanguageVariant.Standard,u),E=new Set;for(let l=N.scan();l!==z.SyntaxKind.EndOfFileToken;l=N.scan()){if(l!==z.SyntaxKind.SingleLineCommentTrivia&&l!==z.SyntaxKind.MultiLineCommentTrivia)continue;let x=N.getTokenPos(),S=N.getTextPos(),_=`${x}-${S}`;if(E.has(_)||(E.add(_),t.has(_)))continue;t.add(_);let O=u.substring(x,S),p=mt(l,O),v=e({getKindName:()=>p.name,getKind:()=>p.kind,getPos:()=>x,getEnd:()=>S,getStart:()=>x,getFullStart:()=>x,getText:()=>O,getSourceFile:()=>n,getParent:()=>n,__isComment:!0,__commentPosition:"standalone",__attachedTo:null},"COM");i.push({nodeId:v,nodeName:O.substring(0,100),containerId:null,containerKind:"module",containerRawKind:"SourceFile",containerRawKindSource:"ts-morph",containerName:null,isExported:!1,kind:p.name,rawKind:p.name,rawKindSource:"ts-morph",semanticKind:null,start:x,end:S,paramCount:null,metadata:null})}}catch{}return{nodes:i,symbolCandidateNodes:s,references:o,declaredNames:a,localDeclarations:c,imports:g,exports:mn(d)}}function Ct(n){let e;try{let r=n.getStart?.(!1);typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getFullStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}e===void 0&&(e=0);let t;try{let r=n.getEnd?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}if(t===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}return t===void 0&&(t=e),t<e&&(t=e),{start:e,end:t}}var Cn=100;function wn(n,e,t,r){let{start:i,end:s}=Ct(e),o=be(e);xe(o,{source:"ts-node-id",file:n,kind:o.kind});let a=r||G.getAbbrev(o.kind,t);return`${n}#${i}-${s}:${a}`}function Nn(n,e){return ze.relative(n,e).replace(/\\/g,"/")}function wt(n,e){if(!n)return null;let t=n;try{let d=n.getAliasedSymbol();d&&(t=d)}catch{}let r=[];try{r=t.getDeclarations()??[]}catch{r=[]}if(!r.length)return null;let s=r.slice().sort((d,m)=>{let y=d.getSourceFile().getFilePath(),P=m.getSourceFile().getFilePath();if(y!==P)return y.localeCompare(P);let C=d.getStart(!1),w=m.getStart(!1);return C!==w?C-w:d.getEnd()-m.getEnd()})[0],o=Nn(e,s.getSourceFile().getFilePath()),a=s.getStart(!1),c=s.getEnd(),g="";try{g=t.getEscapedName()}catch{try{g=t.getName()}catch{g=""}}return`${o}#${a}-${c}:${g}`}function Pn(n){try{return q.isVariableDeclaration(n)||q.isEnumMember(n)?n.getNameNode().getSymbol()??n.getSymbol():n.getSymbol()}catch{return}}function Rn(n,e){let t=n.getDescendantAtPos(e);if(!t)return;let r=t;if(!q.isCallExpression(r)&&!q.isNewExpression(r)&&(r=t.getFirstAncestor(s=>q.isCallExpression(s)||q.isNewExpression(s))??void 0),!r||!q.isCallExpression(r)&&!q.isNewExpression(r))return;let i=r.getExpression();try{return q.isIdentifier(i)?i.getSymbol():q.isPropertyAccessExpression(i)?i.getNameNode().getSymbol()??i.getSymbol():i.getSymbol()}catch{return}}async function En(n){let{sf:e,fileRel:t,content:r,preDeleted:i,meta:s,projectRoot:o,lang:a}=n,g=St(e,(p,h)=>wn(t,p,a,h),new Set,{includeComments:!1}),d=new Map;for(let{nodeId:p,node:h}of g.symbolCandidateNodes){let v=wt(Pn(h),o);v&&(d.has(p)||d.set(p,v))}let m=[],y=new Map,P=g.exports.filter(p=>p.kind!=="reexport"),C=g.exports.filter(p=>p.kind==="reexport");for(let p of P)if(p.kind==="local"){let h=p.isDefault?"default":p.name;if(!h||y.has(h))continue;let v=p.nodeId;m.push([t,h,v,0,null,null,p.isDefault?"default":"named"]),y.set(h,v)}else if(p.kind==="alias"){let h=p.exported;if(!h||y.has(h))continue;m.push([t,h,null,0,null,p.local,"alias"]),y.set(h,"alias")}for(let p of C){let h=p.moduleSpecifier;if(!h)continue;let v=h;if(p.isNamespace){let b=p.alias||"*";if(y.has(b))continue;m.push([t,b,null,1,v,p.name||b,"reexport_star"]),y.set(b,"reexport")}else{let b=p.alias||p.name;if(!b||y.has(b))continue;m.push([t,b,null,1,v,p.name||b,"reexport_named"]),y.set(b,"reexport")}}let w=[],A=typeof r=="string"?r:null;if(A==null)try{let p=e.getFullText();A=typeof p=="string"?p:null}catch{A=null}for(let p of g.nodes){let{nodeId:h,nodeName:v,containerKind:b,containerRawKind:K,containerRawKindSource:j,isExported:D,kind:I,rawKind:F,rawKindSource:M,semanticKind:$,start:V,end:U,paramCount:Me,metadata:Q}=p,Fe=Q&&Object.keys(Q).length?JSON.stringify(Q):null,un=d.get(h)??null;w.push([h,v??null,I,F??I,M??null,$??null,V,U,D?1:0,b??"module",K??b??"module",j??null,Me,null,null,un,Fe])}let R=[];for(let p of g.references){let{name:h,kind:v,containerId:b,containerName:K,expression:j,objectName:D,start:I,end:F}=p,M=null,$=null,V=wt(p.symbol??Rn(e,I),o),U=h?g.localDeclarations.get(h):void 0;U&&(M=U,$=t,V||(V=d.get(U)??null));let Me=ye({sourceFile:t,sourceStart:I,sourceEnd:F,refKind:v,refName:h,targetFile:$,targetNodeId:M}),Q={};j&&(Q.expression=j),D&&(Q.objectName=D),K&&(Q.containerName=K);let Fe=Object.keys(Q).length?JSON.stringify(Q):null;R.push([Me,t,b,h,v,I,F,M,$,M?"resolved":"unresolved",D??null,null,null,V,Fe])}let u=[],N=[];for(let p of g.imports){let h=p.moduleSpecifier??null;u.push([t,h,p.isTypeOnly?1:0]),p.defaultImport&&N.push([t,h,"default",p.defaultImport,"default",p.isTypeOnly?1:0]),p.namespaceImport&&N.push([t,h,"namespace",p.namespaceImport,"*",p.isTypeOnly?1:0]);for(let v of p.namedImports){let b=v.alias||v.name;N.push([t,h,"named",b,v.name,p.isTypeOnly?1:0])}}let E=ze.join(o,t),l=s?.size,x=s?.mtime;if(l===void 0||x===void 0)try{let p=vn.statSync(E);l=p.size,x=Math.floor(p.mtimeMs)}catch{}let S=new Date().toISOString(),_=[t,x??null,l??null,"completed",S],O=null;if(typeof A=="string")O={blobOid:t,content:A};else try{let p=e.getFullText?.();typeof p=="string"&&(O={blobOid:t,content:p})}catch(p){console.log(`[TypescriptIndexer] Failed to compute FTS payload for ${t}:`,p?.message??p)}return{payload:{lang:a,fileRel:t,preDeleted:i,exportRows:m,nodeRows:w,referenceRows:R,importRows:u,importBindingRows:N,fileRow:_,fts:O},fileSize:l,mtime:x}}var $e=class{constructor(e,t){this.project=null;this.filesProcessed=0;this.projectRoot=e,this.lang=t}getProject(){return this.project||(this.project=new Sn({useInMemoryFileSystem:!0,skipAddingFilesFromTsConfig:!0})),this.project}disposeProject(){if(this.project){try{let e=this.project.getLanguageService().compilerObject;typeof e?.dispose=="function"&&e.dispose()}catch{}this.project=null}}async process(e){let t=this.getProject(),r;try{let i=t.createSourceFile(ze.join(this.projectRoot,e.relPath),e.content,{overwrite:!0});r=await En({sf:i,fileRel:e.relPath,content:e.content,preDeleted:!!e.preDeleted,meta:e.meta,projectRoot:this.projectRoot,lang:e.lang})}catch(i){this.disposeProject(),this.filesProcessed=0;let s=i?.message||String(i);throw new Error(`TypeScript parser failed for ${e.relPath}: ${s}`)}return this.filesProcessed++,this.filesProcessed>=Cn&&(this.disposeProject(),this.filesProcessed=0),{payload:r.payload,fileSize:r.fileSize,mtime:r.mtime}}};function _n(n){return n==="ts"?[".ts",".tsx",".mts",".cts"]:n==="js"?[".js",".jsx",".mjs",".cjs"]:[]}function qe(n){return{id:n,extensions:_n(n),indexingMode:"worker",createIndexer:e=>new $e(e,n)}}import we from"fs";import H from"path";import{spawn as Kn,spawnSync as Et}from"child_process";import kn from"fs";var se=class{constructor(e=5e3){this.maxEntries=e;this.cache=new Map}get(e,t){let r=this.cache.get(e);if(!r)return null;let i=t?.mtime??null,s=t?.size??null;return i!=null&&s!=null&&r.mtime===i&&r.size===s?r.result:null}set(e,t,r){let i=t?.mtime??null,s=t?.size??null;this.cache.set(e,{mtime:i,size:s,result:r}),this.cache.size>this.maxEntries&&this.cache.clear()}};var Je=class{constructor(e,t,r,i){this.projectRoot=e;this.lang=t;this.parse=r;this.exportKind=i;this.cache=new se}async process(e){let t=e.meta?.mtime,r=e.meta?.size;if(t==null||r==null)try{let o=kn.statSync(e.absPath);t=Math.floor(o.mtimeMs),r=o.size}catch{}let i=this.cache.get(e.absPath,{mtime:t,size:r});if(i)return ue({lang:this.lang,fileRel:e.relPath,content:e.content,meta:{mtime:t,size:r},preDeleted:e.preDeleted,parsed:i,resolveNodeId:Nt(e.relPath,i,this.lang),exportKind:this.exportKind??"cli"});let s=null;try{s=await this.parse({absPath:e.absPath,relPath:e.relPath,content:e.content,meta:{mtime:t,size:r},projectRoot:this.projectRoot,lang:this.lang})}catch(o){try{console.log(`[CliContract:${this.lang}] parse threw for ${e.relPath}: ${o?.message||String(o)}`)}catch{}return ce(this.lang,e.relPath,{mtime:t,size:r})}return!s||s.error?ce(this.lang,e.relPath,{mtime:t,size:r}):(this.cache.set(e.absPath,{mtime:t,size:r},s),ue({lang:this.lang,fileRel:e.relPath,content:e.content,meta:{mtime:t,size:r},preDeleted:e.preDeleted,parsed:s,resolveNodeId:Nt(e.relPath,s,this.lang),exportKind:this.exportKind??"cli"}))}};function Nt(n,e,t){let r=new Map;for(let i of e.nodes??[]){if(!i.name||r.has(i.name))continue;let s=`${n}#${i.start}-${i.end}:${G.getAbbrev(i.kind,t)}`;r.set(i.name,s)}return i=>r.get(i)??null}function J(n){return{id:n.id,extensions:n.extensions,indexingMode:"worker",createIndexer:e=>new Je(e,n.id,n.parse,n.exportKind),resolveSpan:n.resolve?async(e,t,r)=>n.resolve({projectRoot:e,absPath:t,nodePath:r,lang:n.id}):void 0}}import An from"fs";import Ce from"path";var We=null;function In(n){for(let e of n)if(An.existsSync(e))return e;return null}function W(n){let e=We?.toolsRoot??process.env.PANDO_TOOLS_ROOT,t=We?.runtimeRoot??process.env.PANDO_RUNTIME_ROOT,r=We?.resourcesRoot??process.env.PANDO_RESOURCES_ROOT,i=[e?Ce.join(e,n):null,t?Ce.join(t,"tools",n):null,r?Ce.join(r,"tools",n):null,Ce.resolve(process.cwd(),"tools",n)].filter(s=>!!s);return In(i)}function B(...n){try{let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");process.stderr.write(e+`
2
+ `)}catch{}}var Ne=class{constructor(e,t){this.interpreter=e;this.scriptPath=t;this.buffer=Buffer.alloc(0);this.pending=new Map;this.seq=1;this.closed=!1;if(this.proc=Kn(this.interpreter,["-u",this.scriptPath],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw new Error("python worker stdio unavailable");this.proc.stdout.on("data",r=>this.onData(r)),this.proc.stderr.on("data",r=>{B(`[PythonWorker] ${r.toString("utf8").trim()}`)}),this.proc.stdin.on("error",r=>this.handleError(r)),this.proc.on("error",r=>this.handleError(r)),this.proc.on("exit",r=>this.handleError(new Error(`python worker exited with code ${r}`))),this.ready=this.ping()}handleError(e){if(!this.closed){this.closed=!0;for(let[,t]of this.pending)t.timeout&&clearTimeout(t.timeout),t.summary&&B("[PythonCliAdapter] worker error",{interpreter:this.interpreter,error:e.message,...t.summary}),t.reject(e);this.pending.clear()}}onData(e){for(this.buffer=Buffer.concat([this.buffer,e]);this.buffer.length>=4;){let t=this.buffer.readUInt32BE(0);if(this.buffer.length<4+t)return;let r=this.buffer.slice(4,4+t);this.buffer=this.buffer.slice(4+t);let i=null;try{i=JSON.parse(r.toString("utf8"))}catch{continue}let s=this.pending.get(i.id);s&&(this.pending.delete(i.id),s.timeout&&clearTimeout(s.timeout),i.ok?s.resolve(i):s.reject(new Error(i.error||"python worker error")))}}sendMessage(e){if(this.closed)throw new Error("python worker is closed");let t=Buffer.from(JSON.stringify(e),"utf8"),r=Buffer.alloc(4);r.writeUInt32BE(t.length,0),this.proc.stdin.write(r),this.proc.stdin.write(t)}async requestRaw(e,t,r=1e4){let i=this.seq++,s={id:i,op:e,...t},o=Date.now(),a={op:e,id:i};return typeof t?.path=="string"&&(a.path=t.path),typeof t?.nodePath=="string"&&(a.nodePath=t.nodePath),typeof t?.content_b64=="string"&&(a.contentBytes=t.content_b64.length),new Promise((c,g)=>{let d=setTimeout(()=>{this.pending.delete(i),B("[PythonCliAdapter] worker timeout",{op:e,id:i,timeoutMs:r,pending:this.pending.size,interpreter:this.interpreter,...a}),g(new Error(`python worker timeout (${e})`))},r);this.pending.set(i,{resolve:c,reject:g,timeout:d,summary:a}),this.pending.size%200===0&&B("[PythonCliAdapter] worker pending",{op:e,pending:this.pending.size,interpreter:this.interpreter});try{this.sendMessage(s)}catch(m){clearTimeout(d),this.pending.delete(i),g(m)}})}async request(e,t,r=1e4){await this.ready;let i=Date.now(),s=await this.requestRaw(e,t,r),o=Date.now()-i;return o>2e3&&B("[PythonCliAdapter] worker slow",{op:e,ms:o,pending:this.pending.size,interpreter:this.interpreter,path:t?.path}),s}async ping(){await this.requestRaw("ping",{},5e3)}async parse(e){let t=Buffer.from(e.content,"utf8").toString("base64"),r=await this.request("parse",{path:e.path,content_b64:t,encoding:e.encoding});return r.nodes?r:null}async resolve(e){let t=Buffer.from(e.content,"utf8").toString("base64"),r=await this.request("resolve",{path:e.path,nodePath:e.nodePath,content_b64:t,encoding:e.encoding});return typeof r.start=="number"&&typeof r.end=="number"?r:null}close(){if(this.closed)return;this.closed=!0;for(let[,t]of this.pending)t.timeout&&clearTimeout(t.timeout),t.reject(new Error("python worker client closed"));this.pending.clear();let e=this.proc;try{e.stdin?.end()}catch{}try{e.kill()}catch{}}},Dn=`
3
+ import ast, json, sys, os
4
+
5
+ path = sys.argv[1]
6
+ with open(path, 'r', encoding='utf-8', errors='ignore') as f:
7
+ src = f.read()
8
+
9
+ # line start offsets
10
+ line_starts = [0]
11
+ for line in src.splitlines(True):
12
+ line_starts.append(line_starts[-1] + len(line))
13
+
14
+ def offset(lineno, col):
15
+ if lineno is None:
16
+ return 0
17
+ if lineno < 1:
18
+ lineno = 1
19
+ if lineno >= len(line_starts):
20
+ return line_starts[-1]
21
+ return line_starts[lineno - 1] + (col or 0)
22
+
23
+ def node_span(n):
24
+ start = offset(getattr(n, 'lineno', None), getattr(n, 'col_offset', 0))
25
+ end = offset(getattr(n, 'end_lineno', getattr(n, 'lineno', None)), getattr(n, 'end_col_offset', 0))
26
+ if end < start:
27
+ end = start
28
+ return start, end
29
+
30
+ nodes = []
31
+ imports = []
32
+ bindings = []
33
+ references = []
34
+ class_names = set()
35
+ module_public = set()
36
+ all_exports = None
37
+
38
+ module_name = os.path.splitext(os.path.basename(path))[0] if path else "__main__"
39
+ scope_stack = [module_name]
40
+ nodes.append({
41
+ 'name': module_name,
42
+ 'kind': 'Namespace',
43
+ 'rawKind': 'Module',
44
+ 'rawKindSource': 'python-ast',
45
+ 'semanticKind': 'namespace',
46
+ 'start': 0,
47
+ 'end': len(src),
48
+ 'isExported': 1,
49
+ 'containerKind': None,
50
+ 'containerRawKind': None,
51
+ 'containerRawKindSource': None,
52
+ 'paramCount': None,
53
+ 'qualifiedName': module_name,
54
+ 'scopeChain': [module_name],
55
+ 'metadata': { 'path': path },
56
+ })
57
+
58
+ def decorator_names(node_list):
59
+ out = []
60
+ for d in node_list or []:
61
+ try:
62
+ if isinstance(d, ast.Name):
63
+ out.append(d.id)
64
+ elif isinstance(d, ast.Attribute):
65
+ out.append(d.attr)
66
+ elif hasattr(ast, 'Call') and isinstance(d, ast.Call):
67
+ if isinstance(d.func, ast.Name):
68
+ out.append(d.func.id)
69
+ elif isinstance(d.func, ast.Attribute):
70
+ out.append(d.func.attr)
71
+ except Exception:
72
+ pass
73
+ return out
74
+
75
+ def annotation_text(n):
76
+ try:
77
+ return ast.get_source_segment(src, n)
78
+ except Exception:
79
+ return None
80
+
81
+ def raw_kind(n):
82
+ try:
83
+ return n.__class__.__name__
84
+ except Exception:
85
+ return None
86
+
87
+ def base_name(txt):
88
+ try:
89
+ return txt.split('.')[-1]
90
+ except Exception:
91
+ return txt
92
+
93
+ ENUM_BASES = set(['Enum', 'IntEnum', 'StrEnum', 'Flag', 'IntFlag'])
94
+ META_BASES = set(['type', 'ABCMeta', 'EnumMeta'])
95
+
96
+ def is_enum_base(txt):
97
+ if not txt:
98
+ return False
99
+ name = base_name(txt)
100
+ return name in ENUM_BASES
101
+
102
+ def is_metaclass_base(txt):
103
+ if not txt:
104
+ return False
105
+ name = base_name(txt)
106
+ return name in META_BASES
107
+
108
+ class Visitor(ast.NodeVisitor):
109
+ def __init__(self):
110
+ self.class_name = None
111
+ self.class_is_enum = False
112
+ self.class_stack = []
113
+ self.func_name = None
114
+ self.func_stack = []
115
+ self.scope_stack = list(scope_stack)
116
+
117
+ def visit_ClassDef(self, n):
118
+ start, end = node_span(n)
119
+ name = n.name
120
+ class_names.add(name)
121
+ deco = decorator_names(getattr(n, 'decorator_list', None))
122
+ bases = []
123
+ is_enum = False
124
+ is_meta = False
125
+ meta_value = None
126
+ try:
127
+ for kw in getattr(n, 'keywords', []) or []:
128
+ if getattr(kw, 'arg', None) == 'metaclass':
129
+ meta_value = annotation_text(kw.value)
130
+ except Exception:
131
+ meta_value = None
132
+ try:
133
+ for b in getattr(n, 'bases', []) or []:
134
+ txt = annotation_text(b)
135
+ if txt:
136
+ bases.append(txt)
137
+ if is_enum_base(txt):
138
+ is_enum = True
139
+ if is_metaclass_base(txt):
140
+ is_meta = True
141
+ except Exception:
142
+ pass
143
+ is_exported = 0 if name.startswith('_') else 1
144
+ if is_exported:
145
+ module_public.add(name)
146
+ metadata = {
147
+ 'decorators': deco,
148
+ 'extends': bases if bases else None,
149
+ 'visibility': 'private' if name.startswith('_') else 'public'
150
+ }
151
+ if meta_value:
152
+ metadata['metaclass'] = meta_value
153
+ if is_meta:
154
+ metadata['isMetaclass'] = True
155
+ if is_enum:
156
+ metadata['isEnum'] = True
157
+ scope_chain = self.scope_stack + [name]
158
+ nodes.append({
159
+ 'name': name,
160
+ 'kind': 'Enum' if is_enum else 'Class',
161
+ 'rawKind': raw_kind(n),
162
+ 'rawKindSource': 'python-ast',
163
+ 'semanticKind': 'enum' if is_enum else 'class',
164
+ 'start': start,
165
+ 'end': end,
166
+ 'isExported': is_exported,
167
+ 'containerKind': None,
168
+ 'containerRawKind': None,
169
+ 'containerRawKindSource': None,
170
+ 'paramCount': None,
171
+ 'qualifiedName': '.'.join(scope_chain),
172
+ 'scopeChain': scope_chain,
173
+ 'metadata': metadata,
174
+ })
175
+ prev = self.class_name
176
+ prev_enum = self.class_is_enum
177
+ self.class_stack.append({ 'name': name, 'is_enum': is_enum })
178
+ self.class_name = name
179
+ self.class_is_enum = is_enum
180
+ self.scope_stack.append(name)
181
+ self.generic_visit(n)
182
+ self.scope_stack.pop()
183
+ self.class_stack.pop()
184
+ self.class_name = prev
185
+ self.class_is_enum = prev_enum
186
+
187
+ def visit_FunctionDef(self, n):
188
+ start, end = node_span(n)
189
+ name = n.name
190
+ param_count = len(getattr(n, 'args', {}).args) if hasattr(n, 'args') else None
191
+ is_async = isinstance(n, ast.AsyncFunctionDef)
192
+ deco = decorator_names(getattr(n, 'decorator_list', None))
193
+ ret = annotation_text(getattr(n, 'returns', None)) if hasattr(n, 'returns') else None
194
+ is_static = 'staticmethod' in deco
195
+ is_abstract = 'abstractmethod' in deco
196
+ is_readonly = 'property' in deco
197
+ visibility = 'private' if name.startswith('_') else 'public'
198
+ scope_chain = self.scope_stack + [name]
199
+ if self.class_name:
200
+ sem_kind = 'property' if is_readonly else 'method'
201
+ nodes.append({
202
+ 'name': name,
203
+ 'kind': 'Method',
204
+ 'rawKind': raw_kind(n),
205
+ 'rawKindSource': 'python-ast',
206
+ 'semanticKind': sem_kind,
207
+ 'start': start,
208
+ 'end': end,
209
+ 'isExported': 0,
210
+ 'containerKind': 'Class',
211
+ 'containerRawKind': 'ClassDef',
212
+ 'containerRawKindSource': 'python-ast',
213
+ 'paramCount': param_count,
214
+ 'qualifiedName': '.'.join(scope_chain),
215
+ 'scopeChain': scope_chain,
216
+ 'metadata': { 'isAsync': is_async, 'containerName': self.class_name, 'decorators': deco, 'returnType': ret, 'isStatic': is_static, 'isAbstract': is_abstract, 'isReadonly': is_readonly, 'visibility': visibility },
217
+ })
218
+ else:
219
+ is_exported = 0 if name.startswith('_') else 1
220
+ if is_exported:
221
+ module_public.add(name)
222
+ nodes.append({
223
+ 'name': name,
224
+ 'kind': 'Function',
225
+ 'rawKind': raw_kind(n),
226
+ 'rawKindSource': 'python-ast',
227
+ 'semanticKind': 'function',
228
+ 'start': start,
229
+ 'end': end,
230
+ 'isExported': is_exported,
231
+ 'containerKind': None,
232
+ 'containerRawKind': None,
233
+ 'containerRawKindSource': None,
234
+ 'paramCount': param_count,
235
+ 'qualifiedName': '.'.join(scope_chain),
236
+ 'scopeChain': scope_chain,
237
+ 'metadata': { 'isAsync': is_async, 'decorators': deco, 'returnType': ret, 'isAbstract': is_abstract, 'visibility': visibility },
238
+ })
239
+ prev = self.func_name
240
+ self.func_name = name
241
+ self.func_stack.append(name)
242
+ self.scope_stack.append(name)
243
+ self.generic_visit(n)
244
+ self.scope_stack.pop()
245
+ self.func_stack.pop()
246
+ self.func_name = prev
247
+
248
+ def visit_AsyncFunctionDef(self, n):
249
+ self.visit_FunctionDef(n)
250
+
251
+ def visit_Import(self, n):
252
+ for alias in n.names:
253
+ module = alias.name
254
+ imports.append({ 'module': module, 'isTypeOnly': 0 })
255
+ local = alias.asname or alias.name
256
+ if local and not local.startswith('_'):
257
+ module_public.add(local)
258
+ bindings.append({
259
+ 'module': module,
260
+ 'localName': local,
261
+ 'importedName': alias.name,
262
+ 'kind': 'named',
263
+ 'isTypeOnly': 0,
264
+ })
265
+
266
+ def visit_ImportFrom(self, n):
267
+ module = n.module
268
+ imports.append({ 'module': module, 'isTypeOnly': 0 })
269
+ for alias in n.names:
270
+ if alias.name == '*':
271
+ bindings.append({
272
+ 'module': module,
273
+ 'localName': alias.asname or '*',
274
+ 'importedName': '*',
275
+ 'kind': 'namespace',
276
+ 'isTypeOnly': 0,
277
+ })
278
+ else:
279
+ bindings.append({
280
+ 'module': module,
281
+ 'localName': alias.asname or alias.name,
282
+ 'importedName': alias.name,
283
+ 'kind': 'named',
284
+ 'isTypeOnly': 0,
285
+ })
286
+ local_name = alias.asname or alias.name
287
+ if local_name and not local_name.startswith('_'):
288
+ module_public.add(local_name)
289
+
290
+ def visit_Assign(self, n):
291
+ # module-level or class-level names
292
+ global all_exports
293
+ targets = getattr(n, 'targets', [])
294
+ for t in targets:
295
+ if isinstance(t, ast.Name):
296
+ start, end = node_span(t)
297
+ name = t.id
298
+ is_exported = 0 if name.startswith('_') else 1
299
+ scope_chain = self.scope_stack + [name]
300
+ if self.class_name:
301
+ if self.class_is_enum:
302
+ nodes.append({
303
+ 'name': name,
304
+ 'kind': 'EnumMember',
305
+ 'rawKind': raw_kind(t),
306
+ 'rawKindSource': 'python-ast',
307
+ 'semanticKind': 'enum',
308
+ 'start': start,
309
+ 'end': end,
310
+ 'isExported': 0,
311
+ 'containerKind': 'Enum',
312
+ 'containerRawKind': 'ClassDef',
313
+ 'containerRawKindSource': 'python-ast',
314
+ 'paramCount': None,
315
+ 'qualifiedName': '.'.join(scope_chain),
316
+ 'scopeChain': scope_chain,
317
+ 'metadata': { 'containerName': self.class_name, 'visibility': 'private' if name.startswith('_') else 'public' },
318
+ })
319
+ continue
320
+ nodes.append({
321
+ 'name': name,
322
+ 'kind': 'Field',
323
+ 'rawKind': raw_kind(t),
324
+ 'rawKindSource': 'python-ast',
325
+ 'semanticKind': 'field',
326
+ 'start': start,
327
+ 'end': end,
328
+ 'isExported': 0,
329
+ 'containerKind': 'Class',
330
+ 'containerRawKind': 'ClassDef',
331
+ 'containerRawKindSource': 'python-ast',
332
+ 'paramCount': None,
333
+ 'qualifiedName': '.'.join(scope_chain),
334
+ 'scopeChain': scope_chain,
335
+ 'metadata': { 'containerName': self.class_name, 'visibility': 'private' if name.startswith('_') else 'public' },
336
+ })
337
+ else:
338
+ if is_exported:
339
+ module_public.add(name)
340
+ nodes.append({
341
+ 'name': name,
342
+ 'kind': 'Variable',
343
+ 'rawKind': raw_kind(t),
344
+ 'rawKindSource': 'python-ast',
345
+ 'semanticKind': 'variable',
346
+ 'start': start,
347
+ 'end': end,
348
+ 'isExported': is_exported,
349
+ 'containerKind': None,
350
+ 'containerRawKind': None,
351
+ 'containerRawKindSource': None,
352
+ 'paramCount': None,
353
+ 'qualifiedName': '.'.join(scope_chain),
354
+ 'scopeChain': scope_chain,
355
+ 'metadata': { 'visibility': 'private' if name.startswith('_') else 'public' },
356
+ })
357
+ if (not self.class_name) and name == '__all__':
358
+ try:
359
+ if isinstance(n.value, (ast.List, ast.Tuple)):
360
+ all_list = []
361
+ for elt in n.value.elts:
362
+ if isinstance(elt, ast.Str):
363
+ all_list.append(elt.s)
364
+ elif hasattr(ast, 'Constant') and isinstance(elt, ast.Constant) and isinstance(elt.value, str):
365
+ all_list.append(elt.value)
366
+ if all_list:
367
+ all_exports = all_list
368
+ except Exception:
369
+ pass
370
+ self.generic_visit(n)
371
+
372
+ def visit_Call(self, n):
373
+ try:
374
+ func = n.func
375
+ call_name = None
376
+ object_name = None
377
+ expr_text = None
378
+ if isinstance(func, ast.Name):
379
+ call_name = func.id
380
+ elif isinstance(func, ast.Attribute):
381
+ call_name = func.attr
382
+ if isinstance(func.value, ast.Name):
383
+ object_name = func.value.id
384
+ try:
385
+ expr_text = ast.get_source_segment(src, func)
386
+ except Exception:
387
+ expr_text = None
388
+ start, end = node_span(n)
389
+ kind = 'new' if call_name in class_names else 'call'
390
+ container_name = self.class_name or self.func_name
391
+ container_kind = 'Class' if self.class_name else ('Function' if self.func_name else None)
392
+ try:
393
+ arity = len(getattr(n, 'args', []) or []) + len(getattr(n, 'keywords', []) or [])
394
+ except Exception:
395
+ arity = 0
396
+ container_qualified_name = '.'.join(self.scope_stack) if self.scope_stack else None
397
+ references.append({
398
+ 'name': call_name,
399
+ 'kind': kind,
400
+ 'start': start,
401
+ 'end': end,
402
+ 'expression': expr_text,
403
+ 'objectName': object_name,
404
+ 'containerName': container_name,
405
+ 'containerKind': container_kind,
406
+ 'receiverName': object_name,
407
+ 'arity': arity,
408
+ 'containerQualifiedName': container_qualified_name,
409
+ })
410
+ except Exception:
411
+ pass
412
+ self.generic_visit(n)
413
+
414
+ try:
415
+ tree = ast.parse(src, filename=path)
416
+ Visitor().visit(tree)
417
+ out = { 'nodes': nodes, 'imports': imports, 'importBindings': bindings, 'references': references, 'modulePublic': sorted(list(module_public)), 'explicitExports': all_exports }
418
+ print(json.dumps(out))
419
+ except Exception as e:
420
+ print(json.dumps({ 'error': str(e) }))
421
+ sys.exit(2)
422
+ `,Tn=`
423
+ import ast, json, sys
424
+
425
+ path = sys.argv[1]
426
+ node_path = sys.argv[2]
427
+ with open(path, 'r', encoding='utf-8', errors='ignore') as f:
428
+ src = f.read()
429
+
430
+ # line start offsets
431
+ line_starts = [0]
432
+ for line in src.splitlines(True):
433
+ line_starts.append(line_starts[-1] + len(line))
434
+
435
+ def offset(lineno, col):
436
+ if lineno is None:
437
+ return 0
438
+ if lineno < 1:
439
+ lineno = 1
440
+ if lineno >= len(line_starts):
441
+ return line_starts[-1]
442
+ return line_starts[lineno - 1] + (col or 0)
443
+
444
+ def node_span(n):
445
+ start = offset(getattr(n, 'lineno', None), getattr(n, 'col_offset', 0))
446
+ end = offset(getattr(n, 'end_lineno', getattr(n, 'lineno', None)), getattr(n, 'end_col_offset', 0))
447
+ if end < start:
448
+ end = start
449
+ return start, end
450
+
451
+ def parse_range(node_path):
452
+ clean = node_path
453
+ if clean.startswith('SyntaxError:') or clean.startswith('CompileError:'):
454
+ clean = clean.split(':', 1)[1]
455
+ if '#' in clean:
456
+ clean = clean.split('#', 1)[1]
457
+ if ':' in clean:
458
+ clean = clean.rsplit(':', 1)[0]
459
+ if '-' not in clean:
460
+ return None
461
+ parts = clean.split('-', 1)
462
+ try:
463
+ return int(parts[0]), int(parts[1])
464
+ except Exception:
465
+ return None
466
+
467
+ target = parse_range(node_path)
468
+ if target is None:
469
+ print(json.dumps({ 'error': 'invalid nodePath' }))
470
+ sys.exit(2)
471
+
472
+ target_start, target_end = target
473
+ resolved = None
474
+
475
+ try:
476
+ tree = ast.parse(src, filename=path)
477
+ for n in ast.walk(tree):
478
+ s, e = node_span(n)
479
+ if s == target_start and e == target_end:
480
+ body_start = None
481
+ body_end = None
482
+ if hasattr(n, 'body') and isinstance(n.body, list) and len(n.body) > 0:
483
+ try:
484
+ bs, _ = node_span(n.body[0])
485
+ _, be = node_span(n.body[-1])
486
+ body_start = bs
487
+ body_end = be
488
+ except Exception:
489
+ body_start = None
490
+ body_end = None
491
+ try:
492
+ text = src[s:e]
493
+ except Exception:
494
+ text = None
495
+ resolved = { 'start': s, 'end': e, 'bodyStart': body_start, 'bodyEnd': body_end, 'text': text }
496
+ break
497
+ if not resolved:
498
+ print(json.dumps({ 'error': 'node not found' }))
499
+ sys.exit(2)
500
+ print(json.dumps(resolved))
501
+ except Exception as e:
502
+ print(json.dumps({ 'error': str(e) }))
503
+ sys.exit(2)
504
+ `;function _t(n){let e=H.resolve(n,"tools/python-indexer/pando_python_worker.py");if(we.existsSync(e))return e;let t=W("python-indexer/pando_python_worker.py");if(t)return t;let r=H.resolve(__dirname,"../../../../../tools/python-indexer/pando_python_worker.py");return we.existsSync(r)?r:null}var ae=new Map;function oe(n){try{return we.readFileSync(n,"utf8")}catch{return null}}function fe(n){if(!n)return null;let e=n.match(/(\d+)\.(\d+)/);return e?{major:Number(e[1]),minor:Number(e[2])}:null}function On(n){let e=oe(H.join(n,"pyproject.toml"));if(e){let a=e.match(/requires-python\s*=\s*"([^"]+)"/i),c=fe(a?.[1]??null);if(c)return c}let t=oe(H.join(n,"setup.cfg"));if(t){let a=t.match(/python_requires\s*=\s*([\w\d\.<>~=\s]+)/i),c=fe(a?.[1]??null);if(c)return c}let r=oe(H.join(n,"setup.py"));if(r){let a=r.match(/python_requires\s*=\s*['\"]([^'\"]+)['\"]/i),c=fe(a?.[1]??null);if(c)return c}let i=oe(H.join(n,"tox.ini"));if(i){let a=i.match(/envlist\s*=\s*([^\n]+)/i);if(a&&a[1]){let c=a[1].split(/[,\s]+/).filter(Boolean);for(let g of c){let d=g.match(/py(\d)(\d)/i);if(d)return{major:Number(d[1]),minor:Number(d[2])}}}}let s=oe(H.join(n,".python-version"));if(s){let a=fe(s.trim());if(a)return a}let o=oe(H.join(n,"runtime.txt"));if(o){let a=o.match(/python-(\d+\.\d+)/i),c=fe(a?.[1]??null);if(c)return c}return null}function Pe(n){return On(n)?.major===2?["python2","python","python3"]:["python3","python","python2"]}async function jn(n,e,t){let r=_t(n);if(!r)return null;let i=Pe(n);for(let s of i){let o=`${s}::${r}`,a=ae.get(o);if(!a)try{a=new Ne(s,r),ae.set(o,a)}catch{continue}try{let c=await a.parse({path:e,content:t,encoding:"utf-8"});if(c)return c}catch{B("[PythonCliAdapter] worker parse error",{file:e,interpreter:s}),ae.delete(o)}}return null}async function Mn(n,e,t,r){let i=_t(n);if(!i)return null;let s=Pe(n);for(let o of s){let a=`${o}::${i}`,c=ae.get(a);if(!c)try{c=new Ne(o,i),ae.set(a,c)}catch{continue}try{let g=await c.resolve({path:e,nodePath:r,content:t,encoding:"utf-8"});if(g)return g}catch{B("[PythonCliAdapter] worker resolve error",{file:e,interpreter:o,nodePath:r}),ae.delete(a)}}return null}function Pt(n,e){let t=Et(n,["-c",Dn,e],{encoding:"utf8"});if(t.error||typeof t.stdout!="string")return null;try{let r=JSON.parse(t.stdout.trim()||"{}");return r&&r.error?null:r}catch{return null}}function Rt(n,e,t){let r=Et(n,["-c",Tn,e,t],{encoding:"utf8"});if(r.error||typeof r.stdout!="string")return null;try{let i=JSON.parse(r.stdout.trim()||"{}");return i&&i.error||typeof i.start!="number"||typeof i.end!="number"?null:i}catch{return null}}async function Fn(n){let e=Date.now(),t=!1,r=null;try{r=await jn(n.projectRoot,n.absPath,n.content),t=!!r}catch{}if(!r){let o=Pe(n.projectRoot),a=null;for(let c of o)if(r=Pt(c,n.absPath),r){a=c;break}if(!r&&o.length>1){for(let c of o.slice().reverse())if(r=Pt(c,n.absPath),r){a=c;break}}if(!r){B(`[PythonCliAdapter] parse failed for ${n.relPath} (interpreters tried: ${o.join(", ")})`);let c=Date.now()-e;return c>2e3&&B("[PythonCliAdapter] parse slow (failed)",{file:n.relPath,ms:c}),null}a&&B(`[PythonCliAdapter] parse ok for ${n.relPath} via ${a}`)}let i=[];for(let o of r.references||[]){let a={};o.expression&&(a.expression=o.expression),o.objectName&&(a.objectName=o.objectName),o.containerName&&(a.containerName=o.containerName),o.containerKind&&(a.containerKind=o.containerKind),i.push({sourceStart:o.start,sourceEnd:o.end,refKind:o.kind,refName:o.name,receiverName:o.receiverName??o.objectName??null,arity:typeof o.arity=="number"?o.arity:null,containerQualifiedName:o.containerQualifiedName??null,targetSymbolKey:o.targetSymbolKey??null,metadata:Object.keys(a).length?a:null})}let s=Date.now()-e;return s>2e3&&B("[PythonCliAdapter] parse slow",{file:n.relPath,ms:s,usedWorker:t}),{nodes:r.nodes,imports:r.imports,importBindings:r.importBindings,references:i,modulePublic:r.modulePublic??void 0,explicitExports:r.explicitExports??void 0}}function kt(){return J({id:"python",extensions:[".py",".pyw",".pyi"],exportKind:"named",parse:({absPath:n,relPath:e,projectRoot:t,content:r})=>Fn({absPath:n,relPath:e,projectRoot:t,content:r}),resolve:async({absPath:n,nodePath:e,projectRoot:t})=>{try{let i=we.readFileSync(n,"utf8"),s=await Mn(t,n,i,e);if(s)return s}catch{}let r=Pe(t);for(let i of r){let s=Rt(i,n,e);if(s)return s}for(let i of r.slice().reverse()){let s=Rt(i,n,e);if(s)return s}return null}})}import At from"fs";import It from"path";import{spawn as Ln,spawnSync as qi}from"child_process";var Bn=256e3,$n=32;function Y(...n){try{let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");process.stderr.write(e+`
505
+ `)}catch{}}var Xe=class{constructor(e){this.cmd=e;this.proc=null;this.buffer="";this.pending=new Map;this.seq=1;this.closed=!1;this.ensureProcess()}ensureProcess(){if(!(this.proc&&!this.closed)){if(this.closed=!1,this.proc=Ln(this.cmd,["--server"],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw this.closed=!0,new Error("csharp indexer stdio unavailable");this.proc.stdout.on("data",e=>this.onData(e)),this.proc.stderr.on("data",e=>{Y(`[CSharpIndexer] ${e.toString("utf8").trim()}`)}),this.proc.stdin.on("error",e=>this.handleExit(e)),this.proc.on("error",e=>this.handleExit(e)),this.proc.on("exit",e=>this.handleExit(new Error(`csharp indexer exited with code ${e}`)))}}handleExit(e){if(!this.closed){this.closed=!0;for(let[,t]of this.pending)t.reject(e);this.pending.clear()}}onData(e){for(this.buffer+=e.toString("utf8");;){let t=this.buffer.indexOf(`
506
+ `);if(t<0)break;let r=this.buffer.slice(0,t).trim();if(this.buffer=this.buffer.slice(t+1),!r)continue;let i=null;try{i=JSON.parse(r)}catch{continue}let s=this.pending.get(i.id);s&&(this.pending.delete(i.id),i.ok?s.resolve(i):s.reject(new Error(i.error||"csharp server error")))}}async request(e,t=1){this.ensureProcess();let r=this.seq++;return new Promise((i,s)=>{let o={id:r,...e};this.pending.set(r,{resolve:i,reject:s});try{this.proc.stdin.write(`${JSON.stringify(o)}
507
+ `)}catch(a){if(this.pending.delete(r),t>0){try{this.handleExit(a)}catch{}return this.request(e,t-1).then(i,s)}s(a)}})}async parseBatch(e){let t=await this.request({op:"parse",files:e});return"results"in t?t.results.map(r=>r.ok&&r.result?r.result:null):"result"in t?[t.result]:e.map(()=>null)}async resolve(e){let t=await this.request({op:"resolve",...e});return"result"in t&&t.result&&typeof t.result.start=="number"?t.result:null}async resolveReferences(e){let t=await this.request({op:"resolve-references",...e});return"result"in t&&t.result?t.result:null}close(){if(this.closed)return;this.closed=!0;for(let[,t]of this.pending)t.reject(new Error("csharp indexer client closed"));this.pending.clear();let e=this.proc;if(this.proc=null,!!e){try{e.stdin?.end()}catch{}try{e.kill()}catch{}}}},Ue=class{constructor(e){this.client=e;this.queue=[];this.scheduled=!1}enqueue(e){return new Promise((t,r)=>{this.queue.push({input:e,resolve:t,reject:r,startedAt:Date.now()}),this.scheduled||(this.scheduled=!0,setImmediate(()=>this.flush()))})}async flush(){for(this.scheduled=!1;this.queue.length;){let e=[],t=0;for(;this.queue.length&&e.length<$n;){let r=this.queue[0];if(e.length>0&&t+r.input.size>Bn)break;e.push(this.queue.shift()),t+=r.input.size}try{let r=await this.client.parseBatch(e.map(i=>({file:i.input.file,root:i.input.root,lang:i.input.lang})));for(let i=0;i<e.length;i+=1){let s=e[i],o=r[i]??null,a=Date.now()-s.startedAt;a>2e3&&Y(`[${new Date().toISOString()}] [CSharpCliAdapter] parse slow`,{file:s.input.file,ms:a,path:"custom",ok:!!o}),o||Y(`[${new Date().toISOString()}] [CSharpCliAdapter] parse failed`,{file:s.input.file,ms:a,path:"custom"}),s.resolve(o)}}catch(r){for(let i of e)i.reject(r)}}}},Kt=new Map,Dt=new Map;function zn(n){let e=process.platform==="win32"?".cmd":"",t=W(`csharp-indexer/bin/pando-csharp-indexer${e}`);if(t)return t;if(n){let i=It.resolve(n,"tools/csharp-indexer/bin/pando-csharp-indexer"+e);if(At.existsSync(i))return i}let r=It.resolve(__dirname,"../../../../../tools/csharp-indexer/bin/pando-csharp-indexer"+e);return At.existsSync(r)?r:null}function Tt(n){let e=process.env.PANDO_CSHARP_INDEXER_CMD||zn(n);if(!e)return null;let t=Kt.get(e);t||(t=new Xe(e),Kt.set(e,t));let r=Dt.get(e);return r||(r=new Ue(t),Dt.set(e,r)),{client:t,batcher:r}}async function qn(n,e,t){let r=Tt(e);if(!r)return null;try{return await r.batcher.enqueue({file:n,root:e,lang:"csharp",size:t})}catch(i){return Y(`[${new Date().toISOString()}] [CSharpCliAdapter] parse error`,{file:n,error:i?.message||i,path:"custom"}),null}}async function Jn(n,e,t){let r=await qn(n,e,t);return r||null}function Ot(){return J({id:"csharp",extensions:[".cs",".csx",".cshtml",".razor"],parse:({absPath:n,projectRoot:e,content:t,meta:r})=>{let i=r?.size??Buffer.byteLength(t,"utf8");return Jn(n,e,i)},resolve:({absPath:n,nodePath:e,projectRoot:t})=>{let r=Date.now(),i=Tt(t);return i?i.client.resolve({file:n,root:t,lang:"csharp",nodePath:e}).then(s=>{let o=Date.now()-r;return o>2e3&&Y(`[${new Date().toISOString()}] [CSharpCliAdapter] resolve slow`,{file:n,ms:o}),s||Y(`[${new Date().toISOString()}] [CSharpCliAdapter] resolve failed`,{file:n,ms:o,nodePath:e}),s}).catch(s=>{let o=Date.now()-r;return Y(`[${new Date().toISOString()}] [CSharpCliAdapter] resolve error`,{file:n,ms:o,nodePath:e,error:s?.message||s}),null}):null}})}import{spawnSync as Hn}from"child_process";import Yn from"path";import X from"fs";import k from"path";var Re=new Map,Wn=["include","src","lib","libs","third_party","third-party","deps","vendor"];function Mt(n){let e=[],t="",r=null,i=!1;for(let s=0;s<n.length;s+=1){let o=n[s];if(i){t+=o,i=!1;continue}if(o==="\\"){i=!0;continue}if(r){o===r?r=null:t+=o;continue}if(o==='"'||o==="'"){r=o;continue}if(o===" "||o===`
508
+ `||o===" "||o==="\r"){t&&(e.push(t),t="");continue}t+=o}return t&&e.push(t),e}function Xn(n,e){let t=[];for(let r=0;r<n.length;r+=1){let i=n[r];if(i!=="-c"){if(i==="-o"){r+=1;continue}i!==e&&((i.endsWith(".c")||i.endsWith(".cc")||i.endsWith(".cpp")||i.endsWith(".cxx")||i.endsWith(".c++"))&&k.isAbsolute(i)||t.push(i))}}return t}function Ft(n,e){return k.isAbsolute(n)?k.resolve(n):e?k.resolve(e,n):k.resolve(n)}function Un(n){try{let e=X.readFileSync(n,"utf8"),t=JSON.parse(e),r=new Map;for(let i of t){let s=i.directory?k.resolve(i.directory):void 0,o=i.file?Ft(i.file,s):null;if(!o)continue;let a=s??k.dirname(o),c=Array.isArray(i.arguments)?i.arguments:i.command?Mt(i.command):[];if(c.length===0)continue;let g=Xn(c.slice(1),o);r.set(o,{args:g,cwd:a})}return r}catch{return null}}function Qn(n){try{let e=X.readFileSync(n,"utf8");return Mt(e.replace(/\r/g,`
509
+ `))}catch{return null}}function Lt(n){let e=k.join(n,"compile_commands.json");if(X.existsSync(e))return e;let t=["build","out","build-debug","build-release","cmake-build-debug","cmake-build-release"];for(let a of t){let c=k.join(n,a,"compile_commands.json");if(X.existsSync(c))return c}let r=t.map(a=>k.join(n,a)).filter(a=>X.existsSync(a));r.push(n);let i=10,s=new Set,o=(a,c)=>{if(c>i)return null;let g=k.resolve(a);if(s.has(g))return null;s.add(g);try{let d=X.readdirSync(a,{withFileTypes:!0});for(let m of d)if(m.isFile()&&m.name==="compile_commands.json")return k.join(a,m.name);for(let m of d){if(!m.isDirectory()||m.name==="node_modules"||m.name.startsWith("."))continue;let y=o(k.join(a,m.name),c+1);if(y)return y}}catch{}return null};for(let a of r){let c=o(a,0);if(c)return c}return null}function Vn(n,e){let t=k.resolve(n),r=k.resolve(e);for(;;){let i=Lt(t);if(i)return i;if(t===r)break;let s=k.dirname(t);if(s===t)break;t=s}return null}function Bt(n){let e=k.join(n,"compile_flags.txt");if(X.existsSync(e))return e;let t=["build","out","build-debug","build-release","cmake-build-debug","cmake-build-release"];for(let r of t){let i=k.join(n,r,"compile_flags.txt");if(X.existsSync(i))return i}return null}function Gn(n,e){let t=k.resolve(n),r=k.resolve(e);for(;;){let i=Bt(t);if(i)return i;if(t===r)break;let s=k.dirname(t);if(s===t)break;t=s}return null}function Ee(n){if(n)try{return X.statSync(n).mtimeMs}catch{return}}function jt(n,e){let t=e?`${k.resolve(n)}::${k.resolve(e)}`:k.resolve(n),r=Re.get(t);if(r){let m=Ee(r.commandsPath);if(r.commandsPath&&m&&r.commandsMtime&&m!==r.commandsMtime)Re.delete(t);else if(r.flagsPath){let y=Ee(r.flagsPath);y&&r.flagsMtime&&y!==r.flagsMtime&&Re.delete(t)}else return r}let i=e?Vn(e,n):Lt(n),s=i?Un(i)??void 0:void 0,o=Ee(i),a=s?null:e?Gn(e,n):Bt(n),c=a?Qn(a)??void 0:void 0,g=Ee(a),d={commands:s,flags:c,commandsPath:i,commandsMtime:o,flagsPath:a,flagsMtime:g};return Re.set(t,d),d}function Qe(n,e,t){let r=k.dirname(e),i=jt(n);!i.commands&&!i.flags&&(i=jt(n,r));let s=Ft(e);if(i.commands){let o=i.commands.get(s);if(o)return{args:o.args,cwd:o.cwd,source:"compile_commands"}}return i.flags?{args:i.flags,cwd:n,source:"compile_flags"}:Ve(n,t)}function Ve(n,e){let t=["-std="+(e==="cpp"?"c++20":"c17")];t.push("-I",n);for(let r of Wn){let i=k.join(n,r);X.existsSync(i)&&t.push("-I",i)}return t.push("-ferror-limit=0"),{args:t,cwd:n,source:"fallback"}}function qt(n){let e=[0];for(let t=0;t<n.length;t+=1)n.charCodeAt(t)===10&&e.push(t+1);return e}function $t(n,e,t){if(!e||e<1)return 0;let r=Math.min(e-1,n.length-1),i=n[r]??0,s=Math.max((t??1)-1,0);return i+s}function le(n){return n?Yn.resolve(n):null}function zt(n,e,t){let r=Math.max(0,Math.min(t-1,n.length-1)),i=n[r]??0,s=r+1<n.length?n[r+1]:e;return Math.max(0,s-i)}function Z(n,e,t){let r=n.range?.begin??n.loc,i=n.range?.end??n.loc;if(!r?.line||r.line<1||r.line>e.length||r.col==null||r.col<1||i?.line&&(i.line<1||i.line>e.length)||i?.col!=null&&i.col<1)return null;let s=zt(e,t,r.line);if((r.col??1)-1>s)return null;if(i?.line){let c=zt(e,t,i.line);if((i.col??r.col??1)-1>c)return null}let o=$t(e,r.line,r.col),a=$t(e,i?.line??r.line,i?.col??r.col);return{start:o,end:Math.max(a,o)}}function Ae(n){let e=n.range?.begin?.file||n.loc?.file||n.range?.end?.file||null;if(e)return le(e);let t=n.range?.begin?.includedFrom?.file||n.range?.end?.includedFrom?.file||null;return le(t)}function Zn(n){let e=n.access;return typeof e=="string"?e:null}function er(n,e){let t={};e.containerName&&(t.containerName=e.containerName);let r=Zn(n);r&&(t.visibility=r);let i=n.storageClass;i&&(t.storageClass=i);let s=n.isInline;typeof s=="boolean"&&(t.isInline=s);let o=n.isConstexpr;typeof o=="boolean"&&(t.isConstexpr=o);let a=n.isVirtual;typeof a=="boolean"&&(t.isVirtual=a);let c=n.isStatic;typeof c=="boolean"&&(t.isStatic=c);let g=n.type;return typeof g=="string"&&(t.type=g),t}function Ge(n,e,t){switch(n){case"FunctionDecl":return{kind:"Function",semanticKind:"function"};case"CXXMethodDecl":case"CXXConstructorDecl":case"CXXDestructorDecl":case"CXXConversionDecl":return{kind:"Method",semanticKind:"method"};case"FunctionTemplateDecl":case"ClassTemplateDecl":case"TypeAliasTemplateDecl":return{kind:"Template",semanticKind:"template"};case"ConceptDecl":return{kind:"Concept",semanticKind:"type"};case"TemplateTypeParmDecl":case"NonTypeTemplateParmDecl":case"TemplateTemplateParmDecl":return{kind:"TemplateParameter",semanticKind:"template"};case"NamespaceDecl":return{kind:"Namespace",semanticKind:"namespace"};case"NamespaceAliasDecl":return{kind:"NamespaceAlias",semanticKind:"namespace"};case"RecordDecl":return e==="struct"?{kind:"Struct",semanticKind:"struct"}:e==="union"?{kind:"Union",semanticKind:"union"}:{kind:"Class",semanticKind:"class"};case"EnumDecl":return{kind:"Enum",semanticKind:"enum"};case"EnumConstantDecl":return{kind:"EnumMember",semanticKind:"enum"};case"FieldDecl":return{kind:"Field",semanticKind:"field"};case"VarDecl":return{kind:t?"Field":"Variable",semanticKind:t?"field":"variable"};case"TypedefDecl":case"TypeAliasDecl":case"UsingDecl":case"UsingDirectiveDecl":case"UsingEnumDecl":return{kind:"TypeAlias",semanticKind:"type"};case"ParmVarDecl":return{kind:"Param",semanticKind:"variable"};case"MacroDefinition":return{kind:"Macro",semanticKind:"macro"};default:return null}}function tr(n,e,t,r){let i=[],s=le(e),o=(a,c)=>{let g=Ae(a),m=g&&(!s||g===s)?Ge(a.kind,a.tagUsed,c.containerKind):null,y=a.name;if(m&&y){m.kind==="Method"&&typeof y=="string"&&y.startsWith("operator")&&(m={kind:"Operator",semanticKind:"method"});let C=Z(a,t,r);if(C){let w=er(a,c);(m.kind==="Template"||m.kind==="TemplateParameter")&&(w.isTemplate=!0),m.kind==="Operator"&&(w.isOperator=!0),i.push({name:y,kind:m.kind,rawKind:a.kind??null,rawKindSource:"clang",semanticKind:m.semanticKind??null,start:C.start,end:C.end,isExported:c.containerKind?0:1,containerKind:c.containerKind??null,containerRawKind:c.containerRawKind??null,containerRawKindSource:c.containerRawKind?"clang":null,paramCount:null,metadata:Object.keys(w).length?w:null})}}let P=c;if(a.kind==="RecordDecl"&&a.name){let C=Ge(a.kind,a.tagUsed,c.containerKind);C&&(P={containerKind:C.kind,containerName:a.name,containerRawKind:a.kind??null})}a.kind==="EnumDecl"&&a.name&&(P={containerKind:"Enum",containerName:a.name,containerRawKind:a.kind??null}),a.kind==="NamespaceDecl"&&a.name&&(P={containerKind:"Namespace",containerName:a.name,containerRawKind:a.kind??null});for(let C of a.inner??[])o(C,P)};return o(n,{}),{nodes:i}}function He(n,e,t){let r=Hn(n,e,{encoding:"utf8",cwd:t});if(r.error)return null;let i=(r.stdout||"").trim();if(!i)return null;try{return JSON.parse(i)}catch{return null}}function Jt(n){let e=`PANDO_${n.toUpperCase()}_INDEXER_CMD`;return process.env[e]||(n==="cpp"?"clang++":"clang")}function me(n){let e=n?.referencedDecl?.name||n.name;if(e)return e;for(let t of n.inner??[]){let r=me(t);if(r)return r}return null}function nr(n,e){let t=[],r=le(e),i=s=>{let o=Ae(s);if(o&&(!r||o===r)&&s.kind==="InclusionDirective"){let g=s.spelling||s.includeName||null||s.file||s.filename||s.includedFile||s.headerName||null;g&&t.push({module:String(g),isTypeOnly:0})}for(let c of s.inner??[])i(c)};return i(n),{imports:t}}function ke(n){if(n.kind==="MemberExpr"||n.kind==="ImplicitCastExpr")for(let e of n.inner??[]){if(e.kind==="DeclRefExpr"||e.kind==="MemberExpr")return e?.referencedDecl?.name||e.name||null;if(e.kind==="CXXThisExpr")return null;if(e.kind==="ImplicitCastExpr")return ke(e)}if(n.kind==="CallExpr"||n.kind==="CXXMemberCallExpr"){for(let e of n.inner??[])if(e.kind==="MemberExpr")return ke(e)}return null}function rr(n){return!n.inner||n.inner.length===0?null:n.kind==="CallExpr"?Math.max(0,n.inner.length-1):n.kind==="CXXConstructExpr"||n.kind==="CXXNewExpr"?n.inner.length:null}function ir(n){if(n.kind!=="CallExpr")return null;let e=n.inner?.[0];return e&&e.kind==="MemberExpr"?ke(e):null}function _e(n,e){return n.containerQualifiedName?`${n.containerQualifiedName}::${e}`:e}function sr(n,e,t,r){let i=[],s=le(e),o=r.length,a=(d,m,y)=>{let P=Ae(d),C=P&&(!s||P===s);if(C&&(d.kind==="CallExpr"||d.kind==="CXXConstructExpr"||d.kind==="CXXNewExpr")){let R=Z(d,t,o);if(R){let u=me(d),N=d.kind==="CallExpr"?"call":"new",E=r.slice(R.start,R.end),l=ir(d),x=rr(d);i.push({sourceStart:R.start,sourceEnd:R.end,refKind:N,refName:u,receiverName:l??void 0,arity:typeof x=="number"?x:void 0,containerQualifiedName:m.containerQualifiedName??void 0,metadata:E?{expression:E,containerName:m.containerName,containerKind:m.containerKind}:null})}}if(C&&d.kind==="TypeRef"){let R=Z(d,t,o);if(R){let u=me(d);i.push({sourceStart:R.start,sourceEnd:R.end,refKind:"type",refName:u,containerQualifiedName:m.containerQualifiedName??void 0,metadata:{containerName:m.containerName,containerKind:m.containerKind}})}}if(C&&(d.kind==="DeclRefExpr"||d.kind==="MemberExpr")&&!(y.includes("CallExpr")||y.includes("CXXConstructExpr")||y.includes("CXXNewExpr"))){let u=Z(d,t,o);if(u){let N=me(d),E=d.kind==="MemberExpr"?ke(d):void 0;i.push({sourceStart:u.start,sourceEnd:u.end,refKind:"reference",refName:N,receiverName:E??void 0,containerQualifiedName:m.containerQualifiedName??void 0,metadata:{containerName:m.containerName,containerKind:m.containerKind}})}}if(C&&(d.kind==="MacroExpansion"||d.kind==="MacroInstantiation")){let R=Z(d,t,o);if(R){let u=me(d);i.push({sourceStart:R.start,sourceEnd:R.end,refKind:"macro",refName:u,containerQualifiedName:m.containerQualifiedName??void 0,metadata:{containerName:m.containerName,containerKind:m.containerKind}})}}let w=m;if(d.kind==="RecordDecl"&&d.name){let R=Ge(d.kind,d.tagUsed,m.containerKind);R&&(w={containerKind:R.kind,containerName:d.name,containerQualifiedName:_e(m,d.name)})}d.kind==="EnumDecl"&&d.name&&(w={containerKind:"Enum",containerName:d.name,containerQualifiedName:_e(m,d.name)}),d.kind==="NamespaceDecl"&&d.name&&(w={containerKind:"Namespace",containerName:d.name,containerQualifiedName:_e(m,d.name)}),(d.kind==="FunctionDecl"||d.kind==="CXXMethodDecl"||d.kind==="CXXConstructorDecl"||d.kind==="CXXDestructorDecl")&&d.name&&(w={...w,containerQualifiedName:_e(m,d.name)});let A=y.slice();d.kind&&A.push(d.kind);for(let R of d.inner??[])a(R,w,A)};a(n,{},[]);let c=new Set,g=[];for(let d of i){let m=`${d.sourceStart}:${d.sourceEnd}:${d.refKind}:${d.refName??""}:${d.targetNodeId??""}:${d.targetFile??""}`;c.has(m)||(c.add(m),g.push(d))}return{references:g}}function or(n){if(!n)return null;let e=n;(e.startsWith("SyntaxError:")||e.startsWith("CompileError:"))&&(e=e.substring(e.indexOf(":")+1)),e.includes("#")&&(e=e.split("#")[1]);let t=e.lastIndexOf(":"),r=t>=0?e.slice(0,t):e,[i,s]=r.split("-"),o=Number(i),a=Number(s);return!Number.isFinite(o)||!Number.isFinite(a)||a<o?null:{start:o,end:a}}function ar(n,e,t,r,i){let s=or(t);if(!s)return null;let o=Jt(n),a=Qe(i,e,n),c=[...a.args,"-Xclang","-ast-dump=json","-Xclang","-detailed-preprocessing-record","-fsyntax-only","-fno-color-diagnostics","-fno-diagnostics-color",...a.source==="fallback"?["-x",n==="cpp"?"c++":"c"]:[],e],g=He(o,c,a.cwd);if(!g||g.kind!=="TranslationUnitDecl")return null;let d=qt(r),m=r.length,y=le(e),P=null,C=A=>{if(P)return;let R=Ae(A),N=R&&(!y||R===y)?Z(A,d,m):null;if(N&&N.start===s.start&&N.end===s.end){let E=null,l=null;for(let x of A.inner??[])if(x.kind==="CompoundStmt"){let S=Z(x,d,m);if(S){E=S.start,l=S.end;break}}P={start:N.start,end:N.end,bodyStart:E,bodyEnd:l};return}for(let E of A.inner??[])C(E)};if(C(g),!P)return null;let w=P;return{start:w.start,end:w.end,bodyStart:w.bodyStart??null,bodyEnd:w.bodyEnd??null,text:r.slice(w.start,w.end)}}function Ye(n){return J({id:n,extensions:[],parse:({absPath:e,relPath:t,content:r,projectRoot:i})=>{let s=Jt(n),o=Qe(i,e,n),a=C=>[...C.args,"-Xclang","-ast-dump=json","-Xclang","-detailed-preprocessing-record","-fsyntax-only","-fno-color-diagnostics","-fno-diagnostics-color",...C.source==="fallback"?["-x",n==="cpp"?"c++":"c"]:[],e],c=He(s,a(o),o.cwd);if(!c&&o.source!=="fallback"){let C=Ve(i,n);c=He(s,a(C),C.cwd)}if(!c||c.kind!=="TranslationUnitDecl")return null;let g=qt(r??""),d=(r??"").length,{nodes:m}=tr(c,e,g,d),{imports:y}=nr(c,e),{references:P}=sr(c,e,g,r??"");return{nodes:m,imports:y,importBindings:[],references:P}},resolve:({absPath:e,nodePath:t,projectRoot:r})=>{try{let i=dn("fs").readFileSync(e,"utf8");return ar(n,e,t,i,r)}catch{return null}}})}import Ze from"fs";import et from"path";import{spawn as lr,spawnSync as ss}from"child_process";var cr=256e3,ur=32;function ee(...n){try{let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");process.stderr.write(e+`
510
+ `)}catch{}}var tt=class{constructor(e){this.cmd=e;this.proc=null;this.buffer="";this.pending=new Map;this.seq=1;this.closed=!1;this.ensureProcess()}ensureProcess(){if(!(this.proc&&!this.closed)){if(this.closed=!1,this.proc=lr(this.cmd,["--server"],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw this.closed=!0,new Error("dart indexer stdio unavailable");this.proc.stdout.on("data",e=>this.onData(e)),this.proc.stderr.on("data",e=>{ee(`[DartIndexer] ${e.toString("utf8").trim()}`)}),this.proc.stdin.on("error",e=>this.handleExit(e)),this.proc.on("error",e=>this.handleExit(e)),this.proc.on("exit",e=>this.handleExit(new Error(`dart indexer exited with code ${e}`)))}}handleExit(e){if(!this.closed){this.closed=!0;for(let[,t]of this.pending)t.reject(e);this.pending.clear()}}onData(e){for(this.buffer+=e.toString("utf8");;){let t=this.buffer.indexOf(`
511
+ `);if(t<0)break;let r=this.buffer.slice(0,t).trim();if(this.buffer=this.buffer.slice(t+1),!r)continue;let i=null;try{i=JSON.parse(r)}catch{continue}let s=this.pending.get(i.id);s&&(this.pending.delete(i.id),i.ok?s.resolve(i):s.reject(new Error(i.error||"dart server error")))}}async request(e,t=1){this.ensureProcess();let r=this.seq++;return new Promise((i,s)=>{let o={id:r,...e};this.pending.set(r,{resolve:i,reject:s});try{this.proc.stdin.write(`${JSON.stringify(o)}
512
+ `)}catch(a){if(this.pending.delete(r),t>0){try{this.handleExit(a)}catch{}return this.request(e,t-1).then(i,s)}s(a)}})}async parseBatch(e){let t=await this.request({op:"parse",files:e});return"results"in t&&Array.isArray(t.results)?t.results.map(r=>r.ok&&r.result?r.result:null):"result"in t&&t.result?[t.result]:e.map(()=>null)}async resolve(e){let t=await this.request({op:"resolve",...e});return"result"in t&&t.result&&typeof t.result.start=="number"?t.result:null}close(){if(this.closed)return;this.closed=!0;for(let[,t]of this.pending)t.reject(new Error("dart indexer client closed"));this.pending.clear();let e=this.proc;if(this.proc=null,!!e){try{e.stdin?.end()}catch{}try{e.kill()}catch{}}}},nt=class{constructor(e){this.client=e;this.queue=[];this.scheduled=!1}enqueue(e){return new Promise((t,r)=>{this.queue.push({input:e,resolve:t,reject:r,startedAt:Date.now()}),this.scheduled||(this.scheduled=!0,setImmediate(()=>this.flush()))})}async flush(){for(this.scheduled=!1;this.queue.length;){let e=[],t=0;for(;this.queue.length&&e.length<ur;){let r=this.queue[0];if(e.length>0&&t+r.input.size>cr)break;e.push(this.queue.shift()),t+=r.input.size}try{let r=await this.client.parseBatch(e.map(i=>({file:i.input.file,root:i.input.root,lang:i.input.lang})));for(let i=0;i<e.length;i+=1){let s=e[i],o=r[i]??null,a=Date.now()-s.startedAt;a>2e3&&ee(`[${new Date().toISOString()}] [DartCliAdapter] parse slow`,{file:s.input.file,ms:a,ok:!!o}),o||ee(`[${new Date().toISOString()}] [DartCliAdapter] parse failed`,{file:s.input.file,ms:a}),s.resolve(o)}}catch(r){for(let i of e)i.reject(r)}}}},Wt=new Map,Xt=new Map;function dr(n){let e=process.platform==="win32"?".cmd":"",t=W(`dart-indexer/bin/pando-dart-indexer${e}`);if(t)return t;if(n){let s=et.resolve(n,"tools/dart-indexer/bin/pando-dart-indexer"+e);if(Ze.existsSync(s))return s}let r=process.env.PANDO_EXTENSION_ROOT;if(r){let s=et.resolve(r,"tools/dart-indexer/bin/pando-dart-indexer"+e);if(Ze.existsSync(s))return s}let i=et.resolve(process.cwd(),"tools/dart-indexer/bin/pando-dart-indexer"+e);return Ze.existsSync(i)?i:null}function Ut(n){let e=process.env.PANDO_DART_INDEXER_CMD||dr(n);if(!e)return null;let t=Wt.get(e);t||(t=new tt(e),Wt.set(e,t));let r=Xt.get(e);return r||(r=new nt(t),Xt.set(e,r)),{client:t,batcher:r}}async function pr(n,e,t){let r=Ut(e);if(!r)return null;try{return await r.batcher.enqueue({file:n,root:e,lang:"dart",size:t})}catch(i){return ee(`[${new Date().toISOString()}] [DartCliAdapter] parse error`,{file:n,error:i?.message||i}),null}}function Qt(){return J({id:"dart",extensions:[".dart"],parse:async({absPath:n,projectRoot:e,content:t,meta:r})=>{let i=r?.size??Buffer.byteLength(t,"utf8");return pr(n,e,i)},resolve:({absPath:n,nodePath:e,projectRoot:t})=>{let r=Date.now(),i=Ut(t);return i?i.client.resolve({file:n,root:t,lang:"dart",nodePath:e}).then(s=>{let o=Date.now()-r;return o>2e3&&ee(`[${new Date().toISOString()}] [DartCliAdapter] resolve slow`,{file:n,ms:o}),s||ee(`[${new Date().toISOString()}] [DartCliAdapter] resolve failed`,{file:n,ms:o,nodePath:e}),s}).catch(s=>{let o=Date.now()-r;return ee(`[${new Date().toISOString()}] [DartCliAdapter] resolve error`,{file:n,ms:o,nodePath:e,error:s?.message||s}),null}):null},exportKind:"dart"})}import rt from"fs";import ge from"path";import{spawn as fr,spawnSync as ps}from"child_process";var mr=256e3,gr=32;function ne(...n){try{let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");process.stderr.write(e+`
513
+ `)}catch{}}var it=class{constructor(e){this.cmd=e;this.proc=null;this.buffer="";this.pending=new Map;this.seq=1;this.closed=!1;this.ensureProcess()}ensureProcess(){if(!(this.proc&&!this.closed)){if(this.closed=!1,this.proc=fr(this.cmd,["--server"],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw this.closed=!0,new Error("java indexer stdio unavailable");this.proc.stdout.on("data",e=>this.onData(e)),this.proc.stderr.on("data",e=>{ne(`[JavaCliAdapter] ${e.toString("utf8").trim()}`)}),this.proc.stdin.on("error",e=>this.handleExit(e)),this.proc.on("error",e=>this.handleExit(e)),this.proc.on("exit",e=>this.handleExit(new Error(`java indexer exited with code ${e}`)))}}handleExit(e){if(!this.closed){this.closed=!0;for(let[,t]of this.pending)clearTimeout(t.timer),t.reject(e);this.pending.clear()}}onData(e){for(this.buffer+=e.toString("utf8");;){let t=this.buffer.indexOf(`
514
+ `);if(t<0)break;let r=this.buffer.slice(0,t).trim();if(this.buffer=this.buffer.slice(t+1),!r)continue;let i=null;try{i=JSON.parse(r)}catch{continue}let s=this.pending.get(i.id);s&&(clearTimeout(s.timer),this.pending.delete(i.id),i.ok?s.resolve(i):s.reject(new Error(i.error||"java server error")))}}async request(e,t=1){this.ensureProcess();let r=this.seq++;return new Promise((i,s)=>{let o={id:r,...e},a=setTimeout(()=>{this.pending.delete(r),s(new Error("java indexer request timed out after 30s"))},3e4);this.pending.set(r,{resolve:i,reject:s,timer:a});try{this.proc.stdin.write(`${JSON.stringify(o)}
515
+ `)}catch(c){if(clearTimeout(a),this.pending.delete(r),t>0){try{this.handleExit(c)}catch{}return this.request(e,t-1).then(i,s)}s(c)}})}async parseBatch(e){let t=await this.request({op:"parse",files:e});return"results"in t?t.results.map(r=>r.ok&&r.result?r.result:null):"result"in t?[t.result]:e.map(()=>null)}async resolve(e){let t=await this.request({op:"resolve",...e});return"result"in t&&t.result&&typeof t.result.start=="number"?t.result:null}close(){if(this.closed)return;this.closed=!0;for(let[,t]of this.pending)clearTimeout(t.timer),t.reject(new Error("java indexer client closed"));this.pending.clear();let e=this.proc;if(this.proc=null,!!e){try{e.stdin?.end()}catch{}try{e.kill()}catch{}}}},st=class{constructor(e){this.client=e;this.queue=[];this.scheduled=!1}enqueue(e){return new Promise((t,r)=>{this.queue.push({input:e,resolve:t,reject:r,startedAt:Date.now()}),this.scheduled||(this.scheduled=!0,setImmediate(()=>this.flush()))})}async flush(){for(this.scheduled=!1;this.queue.length;){let e=[],t=0;for(;this.queue.length&&e.length<gr;){let r=this.queue[0];if(e.length>0&&t+r.input.size>mr)break;e.push(this.queue.shift()),t+=r.input.size}try{let r=await this.client.parseBatch(e.map(i=>({file:i.input.file,root:i.input.root,lang:i.input.lang})));for(let i=0;i<e.length;i+=1){let s=e[i],o=r[i]??null,a=Date.now()-s.startedAt;a>2e3&&ne(`[${new Date().toISOString()}] [JavaCliAdapter] parse slow`,{file:s.input.file,ms:a,path:"custom",ok:!!o}),o||ne(`[${new Date().toISOString()}] [JavaCliAdapter] parse failed`,{file:s.input.file,ms:a,path:"custom"}),s.resolve(o)}}catch(r){for(let i of e)i.reject(r)}}}},Vt=new Map,Gt=new Map;function hr(){return typeof __dirname=="string"?__dirname:process.cwd()}var te,yr;function br(n){if(te!==void 0&&yr===n)return te;let e=process.platform==="win32"?".cmd":"",t="tools/java-indexer/bin/pando-java-indexer"+e,r=W(`java-indexer/bin/pando-java-indexer${e}`);if(r)return te=r,r;if(n){let s=ge.resolve(n,t);if(rt.existsSync(s))return te=s,s}let i=hr();for(let s=0;s<8;s++){let o=ge.join(i,t);if(rt.existsSync(o))return te=o,o;let a=ge.dirname(i);if(a===i)break;i=a}i=process.cwd();for(let s=0;s<8;s++){let o=ge.join(i,t);if(rt.existsSync(o))return te=o,o;let a=ge.dirname(i);if(a===i)break;i=a}return te=null,null}function Ht(n){let e=process.env.PANDO_JAVA_INDEXER_CMD||br(n);if(!e)return null;let t=Vt.get(e);t||(t=new it(e),Vt.set(e,t));let r=Gt.get(e);return r||(r=new st(t),Gt.set(e,r)),{client:t,batcher:r}}async function xr(n,e,t){let r=Ht(e);if(!r)return null;try{return await r.batcher.enqueue({file:n,root:e,lang:"java",size:t})}catch(i){return ne(`[${new Date().toISOString()}] [JavaCliAdapter] parse error`,{file:n,error:i?.message||i,path:"custom"}),null}}async function vr(n,e,t){let r=await xr(n,e,t);return r||null}function Yt(){return J({id:"java",extensions:[".java"],exportKind:"named",parse:({absPath:n,projectRoot:e,content:t,meta:r})=>{let i=r?.size??Buffer.byteLength(t,"utf8");return vr(n,e,i)},resolve:({absPath:n,nodePath:e,projectRoot:t})=>{let r=Date.now(),i=Ht(t);return i?i.client.resolve({file:n,root:t,lang:"java",nodePath:e}).then(s=>{let o=Date.now()-r;return o>2e3&&ne(`[${new Date().toISOString()}] [JavaCliAdapter] resolve slow`,{file:n,ms:o}),s||ne(`[${new Date().toISOString()}] [JavaCliAdapter] resolve failed`,{file:n,ms:o,nodePath:e}),s}).catch(s=>{let o=Date.now()-r;return ne(`[${new Date().toISOString()}] [JavaCliAdapter] resolve error`,{file:n,ms:o,nodePath:e,error:s?.message||s}),null}):null}})}import kr from"fs";import Rr from"os";import{spawn as Sr}from"child_process";import ot from"fs";import at from"path";function Zt(n,e){let t=process.platform==="win32"?".cmd":"",r=n==="clojure-editor"?"pando-clojure-editor":"pando-clojure-indexer",i=W(`${n}/bin/${r}${t}`);if(i)return i;if(e){let a=at.resolve(e,`tools/${n}/bin/${r}${t}`);if(ot.existsSync(a))return a}let s=process.env.PANDO_EXTENSION_ROOT;if(s){let a=at.resolve(s,`tools/${n}/bin/${r}${t}`);if(ot.existsSync(a))return a}let o=at.resolve(process.cwd(),`tools/${n}/bin/${r}${t}`);return ot.existsSync(o)?o:null}var Ke=3e4,Cr=Math.max(Ke,Number(process.env.PANDO_CLOJURE_PARSE_TIMEOUT_MS||`${300*1e3}`)),wr=Math.max(Ke,Number(process.env.PANDO_CLOJURE_CHANGE_SIGNATURE_TIMEOUT_MS||`${300*1e3}`)),en="__PANDO_CLOJURE_INDEX__";function Nr(...n){if(!re())return;let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");L("ClojureIndexer",e)}function he(n,e){re()&&L("ClojureIndex",n,e)}function Pr(n,e=0){let t=Math.max(1,n.length),r=Math.ceil(Math.max(0,e)/(32*1024))*500,i=15e3+t*2500+r;return Math.max(Ke,Math.min(Cr,i))}var Ie=class{constructor(e,t){this.cmd=e;this.projectRoot=t;this.proc=null;this.buffer="";this.stderrBuffer="";this.pending=new Map;this.seq=1;this.closed=!1;this.ensureProcess()}ensureProcess(){if(!(this.proc&&!this.closed)){if(this.closed=!1,he("node.server.spawn",{projectRoot:this.projectRoot,cmd:this.cmd}),this.proc=Sr(this.cmd,["--server"],{cwd:this.projectRoot,stdio:["pipe","pipe","pipe"],env:{...process.env,PANDO_PROJECT_ROOT:this.projectRoot}}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw this.closed=!0,new Error("clojure indexer stdio unavailable");this.proc.stdout.on("data",e=>this.onData(e)),this.proc.stderr.on("data",e=>this.onStderr(e)),this.proc.on("error",e=>this.handleExit(e)),this.proc.on("exit",e=>this.handleExit(new Error(`clojure indexer exited with code ${e}`)))}}handleExit(e){if(!this.closed){he("node.server.exit",{projectRoot:this.projectRoot,error:e?.message||String(e),pendingRequestCount:this.pending.size}),this.closed=!0;for(let[,t]of this.pending)clearTimeout(t.timer),t.reject(e);this.pending.clear(),this.proc=null}}onData(e){for(this.buffer+=e.toString("utf8");;){let t=this.buffer.indexOf(`
516
+ `);if(t<0)break;let r=this.buffer.slice(0,t).trim();if(this.buffer=this.buffer.slice(t+1),!r)continue;let i=null;try{i=JSON.parse(r)}catch{continue}let s=this.pending.get(i.id);s&&(clearTimeout(s.timer),this.pending.delete(i.id),i.ok?s.resolve(i):s.reject(new Error(i.error||"clojure server error")))}}onStderr(e){for(this.stderrBuffer+=e.toString("utf8");;){let t=this.stderrBuffer.indexOf(`
517
+ `);if(t<0)break;let r=this.stderrBuffer.slice(0,t).trim();if(this.stderrBuffer=this.stderrBuffer.slice(t+1),!!r){if(r.startsWith(en)){let i=r.slice(en.length);try{let s=JSON.parse(i);he(s.event||"jvm.trace",s)}catch(s){L("ClojureIndexer","stderr trace parse failed",{error:s?.message||String(s),line:r})}continue}Nr(r)}}}close(){if(this.closed)return;this.closed=!0;for(let[,t]of this.pending)clearTimeout(t.timer),t.reject(new Error("clojure indexer client closed"));this.pending.clear();let e=this.proc;if(this.proc=null,!!e){try{e.stdin?.end()}catch{}try{e.kill()}catch{}}}async request(e,t){this.ensureProcess();let r=this.seq++,i=t?.retry??1,s=t?.timeoutMs??Ke,o=Date.now();return new Promise((a,c)=>{let g={id:r,...e},d=setTimeout(()=>{this.pending.delete(r),c(new Error(`clojure indexer request timed out after ${s}ms`))},s);this.pending.set(r,{resolve:m=>{he("node.client.request.complete",{projectRoot:this.projectRoot,id:r,op:e.op,durationMs:Date.now()-o}),a(m)},reject:c,timer:d});try{he("node.client.request.start",{projectRoot:this.projectRoot,id:r,op:e.op,timeoutMs:s}),this.proc.stdin.write(`${JSON.stringify(g)}
518
+ `)}catch(m){if(clearTimeout(d),this.pending.delete(r),i>0){try{this.handleExit(m)}catch{}return this.request(e,{retry:i-1,timeoutMs:s}).then(a,c)}c(m)}})}async parseBatch(e,t){let r=Pr(e,t?.batchBytes??0),i=await this.request({op:"parse",files:e,analysisMode:t.purpose==="query"?"full":"index",traceBatchId:t?.batchId,traceBatchBytes:t?.batchBytes},{timeoutMs:r});return"results"in i?i.results.map(s=>s.ok&&s.result?s.result:null):[]}async resolve(e){let t=await this.request({op:"resolve",...e});if("result"in t){let r=t.result;if(r&&typeof r.start=="number"&&typeof r.end=="number")return r}return null}async changeSignature(e){let t=await this.request({op:"change-signature",...e},{timeoutMs:wr});return"result"in t&&t.result||null}},tn=new Map;function nn(n){return process.env.PANDO_CLOJURE_INDEXER_CMD||Zt("clojure-indexer",n)}function rn(n){let e=nn(n);return e?new Ie(e,n):null}function sn(n){let e=nn(n);if(!e)return null;let t=`${e}::${n}`,r=tn.get(t);return r||(r=new Ie(e,n),tn.set(t,r)),r}function Er(){let n=Number(process.env.PANDO_CLOJURE_ANALYZER_POOL_SIZE||"");if(Number.isFinite(n)&&n>=1)return Math.max(1,Math.floor(n));let e=Math.max(1,Rr.cpus()?.length||4);return Math.max(3,Math.min(8,Math.ceil(e/2)))}var _r=Er();function De(n,e){L("ClojureIndex",n,e)}function Te(n,e){L("IndexTiming",n,e)}var Oe=class{constructor(e,t,r=_r){this.projectRoot=e;this.purpose=t;this.clients=[];this.idleClients=[];this.queue=[];this.inFlight=new Set;this.drainWaiters=[];this.batchSeq=1;this.closed=!1;let i=Math.max(1,r);for(let s=0;s<i;s+=1){let o=rn(e);if(!o)break;this.clients.push(o),this.idleClients.push(o)}if(!this.clients.length)throw new Error("clojure indexer command unavailable");De("node.pool.init",{projectRoot:e,purpose:t,configuredPoolSize:i,actualClientCount:this.clients.length})}submit(e,t){return this.closed?Promise.reject(new Error("clojure analyzer pool is closed")):new Promise((r,i)=>{this.queue.push({batchId:this.batchSeq++,batchKey:e,files:t,enqueuedAt:Date.now(),resolve:r,reject:i}),this.pump()})}async flush(){for(;this.queue.length||this.inFlight.size;)await new Promise(e=>this.drainWaiters.push(e))}async close(){if(!this.closed){await this.flush(),this.closed=!0;for(let e of this.clients)try{e.close()}catch{}this.clients.length=0,this.idleClients.length=0}}pump(){for(;!this.closed&&this.queue.length&&this.idleClients.length;){let e=this.queue.shift(),t=this.idleClients.shift(),r=this.runJob(t,e).finally(()=>{this.inFlight.delete(r),this.closed||this.idleClients.push(t),this.pump(),this.notifyIfIdle()});this.inFlight.add(r)}this.notifyIfIdle()}async runJob(e,t){let r=t.files.reduce((o,a)=>o+Math.max(0,a.size||0),0),i=Date.now(),s=Math.max(0,i-t.enqueuedAt);De("node.pool-batch.start",{batchId:t.batchId,batchKey:t.batchKey,purpose:this.purpose,fileCount:t.files.length,batchBytes:r,queueWaitMs:s,queuedBatchCount:this.queue.length,inFlightCount:this.inFlight.size});try{let o=await this.parseFiles(e,t.files,t.batchId,r);Te("clojure-pool.job.complete",{projectRoot:this.projectRoot,batchId:t.batchId,batchKey:t.batchKey,purpose:this.purpose,fileCount:t.files.length,batchBytes:r,queueWaitMs:s,durationMs:Date.now()-i}),De("node.pool-batch.complete",{batchId:t.batchId,batchKey:t.batchKey,purpose:this.purpose,fileCount:t.files.length,batchBytes:r,durationMs:Date.now()-i,successCount:Array.from(o.values()).filter(a=>!("error"in a)).length,errorCount:Array.from(o.values()).filter(a=>"error"in a).length}),t.resolve(o)}catch(o){let a=o instanceof Error?o:new Error(String(o));De("node.pool-batch.error",{batchId:t.batchId,batchKey:t.batchKey,fileCount:t.files.length,batchBytes:r,durationMs:Date.now()-i,error:a.message}),t.reject(a)}}async parseFiles(e,t,r,i){let s=Date.now();try{let o=await e.parseBatch(t.map(c=>({file:c.absPath,root:this.projectRoot,lang:c.lang})),{batchId:r,batchBytes:i,purpose:this.purpose});Te("clojure-parse-batch.complete",{projectRoot:this.projectRoot,batchId:r,fileCount:t.length,batchBytes:i,purpose:this.purpose,durationMs:Date.now()-s,split:!1});let a=new Map;for(let c=0;c<t.length;c+=1){let g=t[c],d=o[c]??null;d?a.set(g.fileKey,d):(L("IndexingAudit","clojure analysis returned no result",{projectRoot:this.projectRoot,batchId:r,file:g.absPath}),a.set(g.fileKey,{error:`clojure analysis returned no result for ${g.absPath}`}))}return a}catch(o){if(t.length>1){let g=Date.now(),d=Math.ceil(t.length/2),m=t.slice(0,d),y=t.slice(d),P=await this.parseFiles(e,m,r,m.reduce((w,A)=>w+Math.max(0,A.size||0),0)),C=await this.parseFiles(e,y,r,y.reduce((w,A)=>w+Math.max(0,A.size||0),0));return Te("clojure-parse-batch.split",{projectRoot:this.projectRoot,batchId:r,fileCount:t.length,batchBytes:i,purpose:this.purpose,durationMs:Date.now()-g,leftCount:m.length,rightCount:y.length,error:o instanceof Error?o.message:String(o)}),new Map([...P,...C])}let a=o instanceof Error?o:new Error(String(o));Te("clojure-parse-batch.error",{projectRoot:this.projectRoot,batchId:r,fileCount:t.length,batchBytes:i,purpose:this.purpose,durationMs:Date.now()-s,error:a.message});let c=new Map;for(let g of t)L("IndexingAudit","clojure analysis request failed",{projectRoot:this.projectRoot,batchId:r,file:g.absPath,error:a.message}),c.set(g.fileKey,{error:a.message});return c}}notifyIfIdle(){if(this.queue.length||this.inFlight.size)return;let e=this.drainWaiters.splice(0,this.drainWaiters.length);for(let t of e)try{t()}catch{}}};function Ar(n,e){if(typeof e?.size=="number"&&typeof e?.mtime=="number")return{size:e.size,mtime:e.mtime};try{let t=kr.statSync(n);return{size:typeof e?.size=="number"?e.size:t.size,mtime:typeof e?.mtime=="number"?e.mtime:Math.floor(t.mtimeMs)}}catch{return{size:e?.size,mtime:e?.mtime}}}function Ir(n,e){let t=new Map;for(let r of e.nodes??[]){if(!r.name||r.containerKind||t.has(r.name))continue;let i=`${n}#${r.start}-${r.end}:${G.getAbbrev(r.kind,"clojure")}:${r.name}`;t.set(r.name,i)}return r=>t.get(r)??null}function Kr(n){let e=n?.error;return typeof e=="string"&&e.trim().length>0?e.trim():null}var je=class{constructor(e,t){this.projectRoot=e;this.purpose=t;this.cache=new se;this.pool=new Oe(e,t)}prepare(e){let t=Ar(e.absPath,e.meta),r=this.cache.get(e.absPath,t);return{fileKey:e.relPath,absPath:e.absPath,relPath:e.relPath,meta:t,preDeleted:e.preDeleted,lang:e.lang,cachedParsed:r??void 0}}batchKey(e){return`${this.projectRoot}::clojure::${this.purpose}`}async analyzeBatch(e){let t=new Map,r=e.filter(s=>!s.cachedParsed);for(let s of e)s.cachedParsed&&t.set(s.fileKey,s.cachedParsed);if(!r.length)return t;let i=await this.pool.submit(this.batchKey(r[0]),r.map(s=>({fileKey:s.fileKey,absPath:s.absPath,lang:s.lang,size:s.meta?.size??0})));for(let s of r){let o=i.get(s.fileKey)??{error:`missing clojure analysis result for ${s.relPath}`};"error"in o||this.cache.set(s.absPath,s.meta??{},o),t.set(s.fileKey,o)}return t}buildProcessedFile(e,t,r){let i=Kr(r);return i?(L("IndexingAudit","clojure batch analysis failed",{projectRoot:this.projectRoot,relPath:e.relPath,error:i}),ce("clojure",e.relPath,t.meta)):ue({lang:"clojure",fileRel:e.relPath,content:e.content,meta:t.meta,preDeleted:e.preDeleted,parsed:r,resolveNodeId:Ir(e.relPath,r),exportKind:"cli"})}async flush(){await this.pool.flush()}async close(){await this.pool.close()}};function Dr(){return{maxFilesPerBatch:Math.max(1,Number(process.env.PANDO_CLOJURE_BATCH_MAX_FILES||"24")),maxBatchBytes:Math.max(1,Number(process.env.PANDO_CLOJURE_BATCH_MAX_BYTES||`${4*1024*1024}`)),maxWaitMs:Math.max(1,Number(process.env.PANDO_CLOJURE_BATCH_MAX_WAIT_MS||"10")),maxPendingFiles:Math.max(1,Number(process.env.PANDO_CLOJURE_BATCH_MAX_PENDING_FILES||"512")),maxPendingBytes:Math.max(1,Number(process.env.PANDO_CLOJURE_BATCH_MAX_PENDING_BYTES||`${16*1024*1024}`))}}function Tr(...n){let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");L("ClojureCliAdapter",e)}function on(){return{id:"clojure",extensions:[".clj",".cljc",".cljs"],indexingMode:"batch",createBatchIndexer:(n,e)=>new je(n,e),getBatchSchedulerOptions:Dr,resolveSpan:(n,e,t)=>{let r=sn(n);return r?r.resolve({file:e,root:n,lang:"clojure",nodePath:t}).catch(i=>(Tr(`[${new Date().toISOString()}] [ClojureCliAdapter] resolve error`,{file:e,nodePath:t,error:i?.message||i}),null)):null}}}function eo(n){return n.indexingMode==="worker"&&typeof n.createIndexer=="function"}var lt={ts:qe("ts"),js:qe("js"),python:kt(),c:{...Ye("c"),extensions:[".c",".h",".i",".inc"]},cpp:{...Ye("cpp"),extensions:[".cc",".cpp",".cxx",".c++",".cp",".ccm",".cppm",".cxxm",".ixx",".hpp",".hh",".hxx",".h++",".ii",".inl",".ipp",".tcc",".tpp",".txx"]},csharp:Ot(),dart:Qt(),java:Yt(),clojure:on()},an=new Map;for(let n of Object.values(lt))for(let e of n.extensions)an.set(e,n.id);function Or(){return ft(dt())}function to(n){let e=n.toLowerCase().match(/\.[a-z0-9+]+$/);return e?an.get(e[0])??null:null}function no(n){return lt[n]}function ro(n){let e=n??Or(),t=new Set;for(let[i,s]of Object.entries(e.byLanguage))s.enabled&&t.add(i);let r=new Set;for(let i of Object.values(lt))if(t.has(i.id))for(let s of i.extensions)r.add(s);return r}import jr from"fs";import ln from"path";import{promises as Mr}from"fs";import co from"ignore";function cn(n,e){let t=n.split(/\r?\n/).map(s=>s.trim()).filter(Boolean);if(!t.length)return[];let r=e?`${e}/`:"";return t.map(s=>s.startsWith("\\#")||s.startsWith("\\!")?s.slice(1):s).filter(s=>!s.startsWith("#")).map(s=>{let o=s.startsWith("!"),a=o?s.slice(1):s;if(!a)return s;if((a.endsWith("/")?a.slice(0,-1):a).includes("/")){if(!r&&a.startsWith("/"))return o?`!${a}`:a;let m=a.startsWith("/")?a.slice(1):a,y=r?`${r}${m}`:m;return o?`!${y}`:y}let d=r?`${r}**/${a}`:a;return o?`!${d}`:d})}function uo(n,e){let t=ln.join(n,".gitignore");try{let r=jr.readFileSync(t,"utf8");return cn(r,e)}catch{return[]}}async function po(n,e){let t=ln.join(n,".gitignore");try{let r=await Mr.readFile(t,"utf8");return cn(r,e)}catch{return[]}}function Fr(n,e="Operation cancelled"){let t=typeof n=="string"&&n.trim()?n.trim():n instanceof Error&&n.message.trim()?n.message.trim():e,r=new Error(t);return r.name="AbortError",r.code="ABORT_ERR",r}function mo(n,e){if(n?.aborted)throw Fr(n.reason,e)}export{ce as a,eo as b,Or as c,to as d,no as e,ro as f,mo as g,uo as h,po as i};