scip-query 0.15.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (321) hide show
  1. package/CHANGELOG.md +41 -1
  2. package/README.md +148 -66
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/chunk-2EU6WVR3.js +3 -0
  5. package/dist/chunk-2HFXPIBT.js +2 -0
  6. package/dist/chunk-2LGPMYS2.js +35 -0
  7. package/dist/chunk-2Y7YX54K.js +16 -0
  8. package/dist/chunk-363TZ64I.js +2 -0
  9. package/dist/chunk-3I34FZ6R.js +2 -0
  10. package/dist/chunk-3LAKH6BV.js +2 -0
  11. package/dist/chunk-3M2UCPFS.js +3 -0
  12. package/dist/chunk-3OPIMH42.js +2 -0
  13. package/dist/{chunk-QZOAOLLZ.js → chunk-3YAZH3JU.js} +2 -2
  14. package/dist/chunk-5P26M63Y.js +2 -0
  15. package/dist/{chunk-72FR7KEZ.js → chunk-5TVNLPUM.js} +14 -12
  16. package/dist/chunk-5UKDCXVC.js +5 -0
  17. package/dist/{chunk-R7U2I55B.js → chunk-5XDNFOAH.js} +2 -2
  18. package/dist/chunk-62Y3PC27.js +4 -0
  19. package/dist/chunk-6DNE65QS.js +40 -0
  20. package/dist/{chunk-N2OTJWC2.js → chunk-6EVORGCB.js} +2 -2
  21. package/dist/chunk-6GZ7LM7S.js +2 -0
  22. package/dist/chunk-753JWTUH.js +3 -0
  23. package/dist/chunk-7II7NFRV.js +4 -0
  24. package/dist/{chunk-M7EEHYSU.js → chunk-7RAS466A.js} +2 -2
  25. package/dist/chunk-A46JTKTM.js +5 -0
  26. package/dist/{chunk-2XRXEIRK.js → chunk-AAMZRDJT.js} +2 -2
  27. package/dist/chunk-AMPN2VMF.js +3 -0
  28. package/dist/{chunk-6XA4LDHY.js → chunk-B3X6KU75.js} +2 -2
  29. package/dist/chunk-BFWVHD2P.js +16 -0
  30. package/dist/chunk-BVHP2B4D.js +61 -0
  31. package/dist/{chunk-BUNDZ6K2.js → chunk-BVUA3GZC.js} +2 -2
  32. package/dist/{chunk-EDSD3VJK.js → chunk-CKIAEVGM.js} +2 -2
  33. package/dist/chunk-CM4EZLW4.js +2 -0
  34. package/dist/chunk-CS3FXTUC.js +2 -0
  35. package/dist/chunk-CVBS2FD4.js +2 -0
  36. package/dist/chunk-D5OXYOJP.js +7 -0
  37. package/dist/chunk-DA34GNNO.js +29 -0
  38. package/dist/chunk-DKK2H4D7.js +7 -0
  39. package/dist/chunk-EBSSCVR4.js +5 -0
  40. package/dist/{chunk-OXTM2RX3.js → chunk-EVCSXWER.js} +2 -2
  41. package/dist/chunk-FFIYGYQR.js +67 -0
  42. package/dist/chunk-G4KQ7S74.js +20 -0
  43. package/dist/{chunk-44P4SJFN.js → chunk-GWWYLYD3.js} +2 -2
  44. package/dist/chunk-HGUNWXJX.js +2 -0
  45. package/dist/chunk-HLRWOFXC.js +9 -0
  46. package/dist/{chunk-YQKECTPV.js → chunk-IRIM3SUR.js} +2 -2
  47. package/dist/chunk-JHK2DMUQ.js +4 -0
  48. package/dist/chunk-JQ2PCFZW.js +3 -0
  49. package/dist/chunk-JRFCWCOD.js +16 -0
  50. package/dist/chunk-JXAJDINF.js +2 -0
  51. package/dist/chunk-K32ZOW3P.js +2 -0
  52. package/dist/{chunk-3H5OSDF7.js → chunk-KI4WPR7Q.js} +2 -2
  53. package/dist/{chunk-43GKP6LI.js → chunk-KP2DJY7D.js} +2 -2
  54. package/dist/{chunk-YTVKPJXW.js → chunk-L27UIF3E.js} +2 -2
  55. package/dist/chunk-LT6AHYVY.js +18 -0
  56. package/dist/chunk-MCNWCJYL.js +11 -0
  57. package/dist/{chunk-K6UI6EBZ.js → chunk-MZB3DTHW.js} +2 -2
  58. package/dist/chunk-NLRWGGPY.js +8 -0
  59. package/dist/chunk-NLVKD45E.js +13 -0
  60. package/dist/chunk-OO6S4ECV.js +112 -0
  61. package/dist/{chunk-QYOPMTZ6.js → chunk-OYGKBDAD.js} +2 -2
  62. package/dist/chunk-P5QZILZ4.js +2 -0
  63. package/dist/chunk-P5XHIJHI.js +2 -0
  64. package/dist/chunk-PCCMMI2M.js +3 -0
  65. package/dist/{chunk-2TPCIPYA.js → chunk-Q65QYKU7.js} +2 -2
  66. package/dist/{chunk-K7SPOJHZ.js → chunk-QB7NRST4.js} +2 -2
  67. package/dist/{chunk-7JZRFDCU.js → chunk-QSNG3NHQ.js} +2 -2
  68. package/dist/chunk-QVZSWLLZ.js +2 -0
  69. package/dist/chunk-RLB7FZKR.js +10 -0
  70. package/dist/{chunk-KYB7FPXT.js → chunk-RPMT6MTX.js} +2 -2
  71. package/dist/chunk-RQWNF2RM.js +2 -0
  72. package/dist/chunk-RYFIRFYJ.js +4 -0
  73. package/dist/{chunk-QARYU7R3.js → chunk-S2FZILCF.js} +2 -2
  74. package/dist/{chunk-HV27H2V2.js → chunk-S3IXCXW2.js} +2 -2
  75. package/dist/{chunk-TYCZ7S4I.js → chunk-S5MTSES5.js} +2 -2
  76. package/dist/chunk-S5RZQA6V.js +2 -0
  77. package/dist/{chunk-PEHDARNC.js → chunk-SEEJPIWG.js} +2 -2
  78. package/dist/chunk-SOCS3467.js +2 -0
  79. package/dist/chunk-U6BJVXWQ.js +2 -0
  80. package/dist/chunk-UO4IADXJ.js +38 -0
  81. package/dist/{chunk-ZEO4CXQR.js → chunk-VLSI5MYU.js} +2 -2
  82. package/dist/chunk-VSQRU3AP.js +2 -0
  83. package/dist/chunk-VYQY75NA.js +2 -0
  84. package/dist/{chunk-NOKUZU56.js → chunk-VZCR3VQY.js} +2 -2
  85. package/dist/chunk-W3ZVRLCH.js +2 -0
  86. package/dist/chunk-WA64GKWB.js +20 -0
  87. package/dist/chunk-WFRZGMWJ.js +71 -0
  88. package/dist/chunk-WN6XEYVX.js +2 -0
  89. package/dist/chunk-XAEU4ROB.js +101 -0
  90. package/dist/chunk-XBPAJASV.js +2 -0
  91. package/dist/{chunk-GY3HAWUA.js → chunk-XC6PUFNN.js} +2 -2
  92. package/dist/chunk-Y42DMR6F.js +6 -0
  93. package/dist/chunk-YCVYOV4A.js +7 -0
  94. package/dist/{chunk-WPZPB42I.js → chunk-YD37KSEK.js} +2 -2
  95. package/dist/{chunk-V5W7H7V4.js → chunk-YFEJIYWH.js} +2 -2
  96. package/dist/chunk-YSUD2S7T.js +3 -0
  97. package/dist/{chunk-KJCDEDQW.js → chunk-ZEKBAMCN.js} +2 -2
  98. package/dist/chunk-ZHGUZKJL.js +2 -0
  99. package/dist/cli.js +586 -312
  100. package/dist/{config-types-aCgyLrvE.d.ts → config-types-SVkUIufk.d.ts} +8 -2
  101. package/dist/{db-DwCdT3rv.d.ts → db-CS0TuVH6.d.ts} +1 -1
  102. package/dist/{git-history-Dao3_Pu9.d.ts → git-history-ChNHbfZQ.d.ts} +2 -1
  103. package/dist/{health-nJUidasZ.d.ts → health-Btal3mQi.d.ts} +4 -4
  104. package/dist/index.d.ts +7 -5
  105. package/dist/index.js +1 -19
  106. package/dist/queries/affected.d.ts +2 -2
  107. package/dist/queries/affected.js +1 -1
  108. package/dist/queries/bottlenecks.d.ts +8 -2
  109. package/dist/queries/bottlenecks.js +1 -1
  110. package/dist/queries/by-kind.d.ts +2 -2
  111. package/dist/queries/by-kind.js +1 -1
  112. package/dist/queries/call-graph.d.ts +2 -2
  113. package/dist/queries/call-graph.js +1 -1
  114. package/dist/queries/change-surface.d.ts +2 -2
  115. package/dist/queries/change-surface.js +1 -1
  116. package/dist/queries/cleanup-plan.d.ts +2 -2
  117. package/dist/queries/cleanup-plan.js +1 -1
  118. package/dist/queries/co-change.d.ts +4 -3
  119. package/dist/queries/co-change.js +1 -1
  120. package/dist/queries/code.d.ts +2 -2
  121. package/dist/queries/code.js +1 -1
  122. package/dist/queries/complexity-hotspots.d.ts +3 -3
  123. package/dist/queries/complexity-hotspots.js +1 -1
  124. package/dist/queries/complexity.d.ts +5 -4
  125. package/dist/queries/complexity.js +1 -1
  126. package/dist/queries/convergence.d.ts +2 -2
  127. package/dist/queries/convergence.js +1 -1
  128. package/dist/queries/coupling.d.ts +2 -2
  129. package/dist/queries/coupling.js +1 -1
  130. package/dist/queries/cycles.d.ts +2 -2
  131. package/dist/queries/cycles.js +1 -1
  132. package/dist/queries/dataflow.d.ts +2 -2
  133. package/dist/queries/dataflow.js +1 -1
  134. package/dist/queries/dead.d.ts +12 -3
  135. package/dist/queries/dead.js +1 -1
  136. package/dist/queries/decorative-checkers.d.ts +2 -2
  137. package/dist/queries/decorative-checkers.js +1 -1
  138. package/dist/queries/deep-chains.d.ts +8 -3
  139. package/dist/queries/deep-chains.js +1 -1
  140. package/dist/queries/deps.d.ts +2 -2
  141. package/dist/queries/deps.js +1 -1
  142. package/dist/queries/diff-gate.d.ts +5 -4
  143. package/dist/queries/diff-gate.js +1 -1
  144. package/dist/queries/diff-impact.d.ts +3 -3
  145. package/dist/queries/diff-impact.js +1 -1
  146. package/dist/queries/doc-drift.d.ts +4 -2
  147. package/dist/queries/doc-drift.js +1 -1
  148. package/dist/queries/drift.d.ts +2 -2
  149. package/dist/queries/drift.js +1 -1
  150. package/dist/queries/duplicate-bodies.d.ts +3 -3
  151. package/dist/queries/duplicate-bodies.js +1 -1
  152. package/dist/queries/extract-candidates.d.ts +2 -2
  153. package/dist/queries/extract-candidates.js +1 -1
  154. package/dist/queries/fan.d.ts +11 -5
  155. package/dist/queries/fan.js +1 -1
  156. package/dist/queries/files.d.ts +2 -2
  157. package/dist/queries/health.d.ts +3 -3
  158. package/dist/queries/health.js +1 -1
  159. package/dist/queries/hierarchy.d.ts +2 -2
  160. package/dist/queries/hierarchy.js +1 -1
  161. package/dist/queries/hotspots.d.ts +2 -2
  162. package/dist/queries/hotspots.js +1 -1
  163. package/dist/queries/imports.d.ts +2 -2
  164. package/dist/queries/imports.js +1 -1
  165. package/dist/queries/incomplete-migration.d.ts +3 -3
  166. package/dist/queries/incomplete-migration.js +1 -1
  167. package/dist/queries/index.d.ts +5 -5
  168. package/dist/queries/index.js +1 -1
  169. package/dist/queries/isolated.d.ts +2 -2
  170. package/dist/queries/isolated.js +1 -1
  171. package/dist/queries/locality-candidates.d.ts +2 -2
  172. package/dist/queries/locality-candidates.js +1 -1
  173. package/dist/queries/members.d.ts +2 -2
  174. package/dist/queries/members.js +1 -1
  175. package/dist/queries/methods.d.ts +2 -2
  176. package/dist/queries/methods.js +1 -1
  177. package/dist/queries/not-implemented.d.ts +2 -2
  178. package/dist/queries/not-implemented.js +1 -1
  179. package/dist/queries/outline.d.ts +2 -2
  180. package/dist/queries/outline.js +1 -1
  181. package/dist/queries/passthrough-candidates.d.ts +3 -3
  182. package/dist/queries/passthrough-candidates.js +1 -1
  183. package/dist/queries/plan-context.d.ts +4 -4
  184. package/dist/queries/plan-context.js +1 -1
  185. package/dist/queries/react-component-duplicates.d.ts +4 -2
  186. package/dist/queries/react-component-duplicates.js +1 -1
  187. package/dist/queries/react-hook-candidates.d.ts +4 -2
  188. package/dist/queries/react-hook-candidates.js +1 -1
  189. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  190. package/dist/queries/react-large-component-pressure.js +1 -1
  191. package/dist/queries/recent-duplicates.d.ts +4 -2
  192. package/dist/queries/recent-duplicates.js +1 -1
  193. package/dist/queries/redundant-reexports.d.ts +2 -2
  194. package/dist/queries/redundant-reexports.js +1 -1
  195. package/dist/queries/refs.d.ts +2 -2
  196. package/dist/queries/refs.js +1 -1
  197. package/dist/queries/self-audit.d.ts +2 -2
  198. package/dist/queries/self-audit.js +1 -1
  199. package/dist/queries/similar-chains.d.ts +2 -2
  200. package/dist/queries/similar-chains.js +1 -1
  201. package/dist/queries/similar-files.d.ts +2 -2
  202. package/dist/queries/similar-files.js +1 -1
  203. package/dist/queries/similar-signatures.d.ts +2 -2
  204. package/dist/queries/similar-signatures.js +1 -1
  205. package/dist/queries/similar.d.ts +2 -2
  206. package/dist/queries/similar.js +1 -1
  207. package/dist/queries/slice.d.ts +2 -2
  208. package/dist/queries/slice.js +1 -1
  209. package/dist/queries/stale-abstractions.d.ts +2 -2
  210. package/dist/queries/stale-abstractions.js +1 -1
  211. package/dist/queries/stats.d.ts +2 -2
  212. package/dist/queries/surface.d.ts +2 -2
  213. package/dist/queries/surface.js +1 -1
  214. package/dist/queries/symbols.d.ts +2 -2
  215. package/dist/queries/symbols.js +1 -1
  216. package/dist/queries/system.d.ts +2 -2
  217. package/dist/queries/system.js +1 -1
  218. package/dist/queries/test-quality.d.ts +2 -2
  219. package/dist/queries/test-quality.js +1 -1
  220. package/dist/queries/trace.d.ts +2 -2
  221. package/dist/queries/trace.js +1 -1
  222. package/dist/queries/twin-ab.d.ts +2 -2
  223. package/dist/queries/twin-ab.js +1 -1
  224. package/dist/queries/twin-drift.d.ts +2 -2
  225. package/dist/queries/twin-drift.js +1 -1
  226. package/dist/queries/unused-imports.d.ts +2 -2
  227. package/dist/queries/unused-imports.js +1 -1
  228. package/dist/queries/unused-params.d.ts +2 -2
  229. package/dist/queries/unused-params.js +1 -1
  230. package/dist/queries/vue-component-duplicates.d.ts +4 -2
  231. package/dist/queries/vue-component-duplicates.js +1 -1
  232. package/dist/queries/vue-composable-candidates.d.ts +4 -2
  233. package/dist/queries/vue-composable-candidates.js +1 -1
  234. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  235. package/dist/queries/vue-large-view-pressure.js +1 -1
  236. package/dist/queries/wrapper-candidates.d.ts +2 -2
  237. package/dist/queries/wrapper-candidates.js +1 -1
  238. package/dist/reindex-worker.js +256 -12
  239. package/dist/reindex.d.ts +29 -3
  240. package/dist/reindex.js +251 -22
  241. package/dist/runtime.d.ts +8 -4
  242. package/dist/runtime.js +2 -2
  243. package/dist/rust-semantic-session-server.js +2 -0
  244. package/dist/rust-semantic-session-worker.js +2 -0
  245. package/dist/rust-semantic-worker.js +2 -0
  246. package/dist/{scip-cli-DeAbuJ2b.d.ts → scip-cli-BKL-26TZ.d.ts} +2 -2
  247. package/dist/{symbol-types-DaoeXKUt.d.ts → symbol-types-BgWU6lhL.d.ts} +2 -0
  248. package/dist/watch-server.js +42 -0
  249. package/docs/AGENT_GUIDE.md +110 -34
  250. package/docs/AI_FAILURE_MODES.md +8 -3
  251. package/docs/COMMAND_REFERENCE.md +10 -6
  252. package/docs/REGEX_POLICY.md +3 -1
  253. package/docs/accuracy-audit-checklist.md +300 -0
  254. package/docs/accuracy-hardening-goal.md +493 -54
  255. package/docs/analyzer-inventory.md +31 -23
  256. package/docs/analyzer-validation-ledger.md +51 -21
  257. package/package.json +2 -1
  258. package/scripts/build-scip-windows.mjs +7 -7
  259. package/skills/_shared/SKILL.md +20 -19
  260. package/skills/scip-calibrate/SKILL.md +4 -2
  261. package/skills/scip-hyper-optimization/SKILL.md +5 -1
  262. package/skills/scip-query/SKILL.md +1 -1
  263. package/skills/scip-setup/SKILL.md +104 -4
  264. package/skills/scip-verify/SKILL.md +20 -14
  265. package/dist/chunk-27HMTUJE.js +0 -3
  266. package/dist/chunk-27XEGMCT.js +0 -7
  267. package/dist/chunk-3AMWF6V5.js +0 -3
  268. package/dist/chunk-4SCMYKD6.js +0 -2
  269. package/dist/chunk-5AAAEZ2Z.js +0 -2
  270. package/dist/chunk-5JRMZMLM.js +0 -2
  271. package/dist/chunk-5VY3RIEI.js +0 -38
  272. package/dist/chunk-6JUAGXR4.js +0 -4
  273. package/dist/chunk-6KDOYKCB.js +0 -40
  274. package/dist/chunk-6KMTPNZL.js +0 -3
  275. package/dist/chunk-7COVQPQQ.js +0 -9
  276. package/dist/chunk-7S5E7KWT.js +0 -2
  277. package/dist/chunk-7TVFPOD7.js +0 -102
  278. package/dist/chunk-A6KSEIRN.js +0 -61
  279. package/dist/chunk-AAMURYOK.js +0 -4
  280. package/dist/chunk-BP7S6V3M.js +0 -20
  281. package/dist/chunk-BRBF3E5X.js +0 -35
  282. package/dist/chunk-BZXE3HO4.js +0 -6
  283. package/dist/chunk-CXQQOXSI.js +0 -10
  284. package/dist/chunk-EVZSAR3S.js +0 -2
  285. package/dist/chunk-GMOEX7EV.js +0 -2
  286. package/dist/chunk-GNG622H3.js +0 -3
  287. package/dist/chunk-GUDKRIGW.js +0 -7
  288. package/dist/chunk-GULVO6NF.js +0 -43
  289. package/dist/chunk-HZZQKNVE.js +0 -2
  290. package/dist/chunk-I4R3SNMR.js +0 -2
  291. package/dist/chunk-IMQFJ53K.js +0 -2
  292. package/dist/chunk-ISLWJ4PY.js +0 -10
  293. package/dist/chunk-IUSSGHJO.js +0 -2
  294. package/dist/chunk-J5WVNZ6O.js +0 -2
  295. package/dist/chunk-JJUX2OAP.js +0 -2
  296. package/dist/chunk-JZBGTSAB.js +0 -13
  297. package/dist/chunk-K5N5RNGM.js +0 -2
  298. package/dist/chunk-KSJ544IV.js +0 -5
  299. package/dist/chunk-LY7NMOBW.js +0 -2
  300. package/dist/chunk-N23FT4EZ.js +0 -2
  301. package/dist/chunk-NCVFKOLB.js +0 -2
  302. package/dist/chunk-PESEPWZO.js +0 -2
  303. package/dist/chunk-PMY4UFGV.js +0 -2
  304. package/dist/chunk-Q7PWDXL5.js +0 -5
  305. package/dist/chunk-QVGFVRKD.js +0 -2
  306. package/dist/chunk-R5336VHZ.js +0 -2
  307. package/dist/chunk-RLB6SG25.js +0 -2
  308. package/dist/chunk-SFDVBARK.js +0 -2
  309. package/dist/chunk-TG7QSYCJ.js +0 -2
  310. package/dist/chunk-UHPWZCYQ.js +0 -3
  311. package/dist/chunk-URSSPS5H.js +0 -2
  312. package/dist/chunk-WIBFXSYB.js +0 -6
  313. package/dist/chunk-WMO2VZZK.js +0 -3
  314. package/dist/chunk-WS3Z6W3M.js +0 -65
  315. package/dist/chunk-X3DTIEMU.js +0 -18
  316. package/dist/chunk-X5C43YVI.js +0 -2
  317. package/dist/chunk-X7CHWTZ2.js +0 -72
  318. package/dist/chunk-XDESMVOL.js +0 -4
  319. package/dist/chunk-XZBLZHXL.js +0 -16
  320. package/dist/chunk-YBGC7HTY.js +0 -3
  321. package/dist/chunk-ZMGBWSFZ.js +0 -2
@@ -1,4 +1,4 @@
1
- import{a as b,b as y,c as m}from"./chunk-MTDBHTSF.js";import{g as p}from"./chunk-7TVFPOD7.js";import{b as f,d as g,f as d}from"./chunk-X5C43YVI.js";import{a as c}from"./chunk-64MNV6AB.js";import{SymbolInformation_Kind as o}from"@c4312/scip";var _=500;function K(n){let s=parseInt(n,10);if(!isNaN(s))return s;let t=n.toLowerCase(),e=y.get(t);if(e!==void 0)return e;for(let[i,l]of b)if(l.toLowerCase().includes(t))return i;return null}function v(n,s,t={}){let{scope:e,limit:i=100}=t,l=K(s);return l===null?[]:h(n,e).map(r=>({row:r,resolvedKind:k(r)})).filter(r=>r.resolvedKind===l).slice(0,i).map(({row:r,resolvedKind:a})=>({symbol:r.symbol,shortName:g(r.symbol),kind:a,kindName:m(a),relativePath:r.relative_path,startLine:r.start_line,endLine:r.end_line}))}function T(n,s={}){let t=I(n,s.scope);for(let e of S(n,s.scope)){let i=k(e);i===null||i===0||t.set(i,(t.get(i)??0)+1)}return[...t.entries()].sort((e,i)=>i[1]-e[1]||e[0]-i[0]).map(([e,i])=>({kind:e,kindName:m(e),count:i}))}function h(n,s){return p(n,{scope:s}).map(R)}function I(n,s){let t=new Map;for(let e of N(c(n,{scope:s,includeIgnored:!1}))){let i=e.map(()=>"?").join(", "),l=n.all(`SELECT gs.kind AS kind, COUNT(*) AS count
1
+ import{a as b,b as y,c as m}from"./chunk-MTDBHTSF.js";import{b as f,d as g,f as d,t as p}from"./chunk-OO6S4ECV.js";import{a as c}from"./chunk-64MNV6AB.js";import{SymbolInformation_Kind as o}from"@c4312/scip";var _=500;function K(n){let s=parseInt(n,10);if(!isNaN(s))return s;let t=n.toLowerCase(),e=y.get(t);if(e!==void 0)return e;for(let[i,l]of b)if(l.toLowerCase().includes(t))return i;return null}function v(n,s,t={}){let{scope:e,limit:i=100}=t,l=K(s);return l===null?[]:h(n,e).map(r=>({row:r,resolvedKind:k(r)})).filter(r=>r.resolvedKind===l).slice(0,i).map(({row:r,resolvedKind:a})=>({symbol:r.symbol,shortName:g(r.symbol),kind:a,kindName:m(a),relativePath:r.relative_path,startLine:r.start_line,endLine:r.end_line}))}function T(n,s={}){let t=I(n,s.scope);for(let e of S(n,s.scope)){let i=k(e);i===null||i===0||t.set(i,(t.get(i)??0)+1)}return[...t.entries()].sort((e,i)=>i[1]-e[1]||e[0]-i[0]).map(([e,i])=>({kind:e,kindName:m(e),count:i}))}function h(n,s){return p(n,{scope:s}).map(R)}function I(n,s){let t=new Map;for(let e of N(c(n,{scope:s,includeIgnored:!1}))){let i=e.map(()=>"?").join(", "),l=n.all(`SELECT gs.kind AS kind, COUNT(*) AS count
2
2
  FROM defn_enclosing_ranges der
3
3
  JOIN global_symbols gs ON der.symbol_id = gs.id
4
4
  JOIN documents d ON der.document_id = d.id
@@ -20,4 +20,4 @@ import{a as b,b as y,c as m}from"./chunk-MTDBHTSF.js";import{g as p}from"./chunk
20
20
  ${n.symbolNoiseFor("gs")}
21
21
  AND d.relative_path IN (${i})
22
22
  ORDER BY d.relative_path, der.start_line, der.end_line, gs.symbol`,...e))}return t}function N(n){let s=[];for(let t=0;t<n.length;t+=_)s.push(n.slice(t,t+_));return s}function R(n){return{symbol:n.symbol,kind:n.kind,documentation:n.documentation,enclosing_symbol:n.enclosingSymbol,relative_path:n.relativePath,start_line:n.startLine,end_line:n.endLine}}function k(n){return n.kind!==null&&n.kind!==0?D(n.kind,n.symbol,n.documentation):C(n.symbol,n.documentation,n.enclosing_symbol)}function D(n,s,t){let e=(t??"").toLowerCase();if(d(s)==="type"){if(e.includes("type "))return o.TypeAlias;if(e.includes("interface "))return o.Interface;if(e.includes("struct "))return o.Struct;if(e.includes("trait "))return o.Trait;if(e.includes("class "))return o.Class}return n}function C(n,s,t){let e=f(n);if("kind"in e)return null;let i=e.descriptors,l=i[i.length-2]??null,u=d(n),r=(s??"").toLowerCase();return u==="type"?r.includes("type ")?o.TypeAlias:r.includes("interface ")?o.Interface:r.includes("struct ")?o.Struct:r.includes("trait ")?o.Trait:r.includes("class ")?o.Class:o.Class:u==="method"?l?.suffix==="type"?o.Method:o.Function:u==="namespace"?o.Module:u!=="term"?null:r.includes("async def ")||r.includes("def ")?o.Function:(t?d(t):l?.suffix??null)==="type"?o.Field:o.Variable}export{v as a,T as b};
23
- //# sourceMappingURL=chunk-BUNDZ6K2.js.map
23
+ //# sourceMappingURL=chunk-BVUA3GZC.js.map
@@ -1,4 +1,4 @@
1
- import{a as s}from"./chunk-K7SPOJHZ.js";function m(e,d){let i=s(e,d);return i?e.all(`SELECT DISTINCT d2.relative_path
1
+ import{a as s}from"./chunk-QB7NRST4.js";function m(e,d){let i=s(e,d);return i?e.all(`SELECT DISTINCT d2.relative_path
2
2
  FROM mentions m
3
3
  JOIN chunks c ON m.chunk_id = c.id
4
4
  JOIN documents d1 ON c.document_id = d1.id
@@ -30,4 +30,4 @@ import{a as s}from"./chunk-K7SPOJHZ.js";function m(e,d){let i=s(e,d);return i?e.
30
30
  WHERE d2.relative_path = ?
31
31
  AND d1.relative_path != ?
32
32
  ORDER BY d1.relative_path`,i,i).filter(t=>!e.isIgnored(t.relative_path)).map(t=>({relativePath:t.relative_path})):[]}export{m as a,o as b};
33
- //# sourceMappingURL=chunk-EDSD3VJK.js.map
33
+ //# sourceMappingURL=chunk-CKIAEVGM.js.map
@@ -0,0 +1,2 @@
1
+ import{d as f}from"./chunk-B3X6KU75.js";import{N as d}from"./chunk-MCNWCJYL.js";function S(n,e={}){let{minComponentLines:o=300,minFileLines:i=800,minJsxTokens:u=80,minBehaviorTokens:s=40,limit:a=20,scope:m,scanLimit:c,filePattern:p}=e;return d(n).reactProfiles({scope:m,scanLimit:c}).filter(t=>t.kind==="component").filter(t=>!p||t.file.includes(p)||t.name.includes(p)).map(t=>C(t,{minComponentLines:o,minFileLines:i,minJsxTokens:u,minBehaviorTokens:s})).filter(t=>t!==null).sort((t,r)=>r.componentLines-t.componentLines||r.fileLines-t.fileLines||t.file.localeCompare(r.file)).slice(0,a)}function C(n,e){let o=Math.max(80,Math.floor(e.minComponentLines/2)),i=f(n,x({minComponentLines:e.minComponentLines,minFileLines:e.minFileLines,minJsxTokens:e.minJsxTokens,minBehaviorTokens:e.minBehaviorTokens,substantialComponentLines:o}),"component"),{reasons:u}=i;if(u.length===0)return null;let s=i.dominantPressure,a=i.pressureKinds,m=b(n),c=R(s,a,m);return{file:n.file,component:n.name,componentLines:n.loc,fileLines:n.fileLines,jsxTokens:n.jsxTokens.size,behaviorTokens:n.behaviorTokens.size,dominantPressure:s,pressureKinds:a,contextKind:m,recommendationKind:c,recommendation:v(c,m),reasons:u,loc:n.loc}}function x(n){return[{axis:"component",value:e=>e.loc,qualifies:(e,o)=>o>=n.minComponentLines,reason:(e,o)=>`${o} component line(s)`},{axis:"file",value:e=>e.fileLines,qualifies:(e,o)=>o>=n.minFileLines&&e.loc>=n.substantialComponentLines,reason:(e,o)=>`${o} file line(s)`},{axis:"jsx-structure",value:e=>e.jsxTokens.size,weightedValue:(e,o)=>o*3,qualifies:(e,o)=>o>=n.minJsxTokens,reason:(e,o)=>`${o} JSX structure token(s)`},{axis:"hook-behavior",value:e=>e.behaviorTokens.size,weightedValue:(e,o)=>o*4,qualifies:(e,o)=>o>=n.minBehaviorTokens,reason:(e,o)=>`${o} behavior token(s)`}]}function b(n){let e=n.file.split(/[\\/]+/).filter(Boolean),o=e.slice(0,-1).map(r=>r.toLowerCase()),i=(e.at(-1)??n.name).replace(/\.[^.]+$/,""),s=o.findIndex(r=>k.has(r))>=0,a=o.some(r=>h.has(r));if(L(i)||L(n.name))return"component";let c=T.has(i.toLowerCase()),p=/(?:Page|Route|Screen)$/.test(n.name),l=s&&/View$/.test(n.name),t=!a&&i.replace(/[^A-Za-z0-9]+/g,"").toLowerCase()===n.name.replace(/[^A-Za-z0-9]+/g,"").toLowerCase()&&/(?:Page|Route|Screen|View)$/.test(i);return c||p||l||t?"route-page":"component"}function L(n){let e=n.split(/[^A-Za-z0-9]+/).filter(Boolean).map(o=>o.toLowerCase());return e.at(-1)&&g.has(e.at(-1))?!0:[...g].some(o=>n.endsWith(P(o)))}function R(n,e,o){return n==="hook-behavior"?"behavior-extraction":o==="route-page"?"route-page-decomposition":e.includes("hook-behavior")?"behavior-extraction":e.includes("jsx-structure")?"jsx-decomposition":e.includes("file")?"file-decomposition":n==="jsx-structure"?"jsx-decomposition":n==="file"&&!e.includes("component")?"file-decomposition":"component-decomposition"}function v(n,e){switch(n){case"behavior-extraction":return"Extract independent state, effects, requests, or handlers into hooks, controllers, or feature modules.";case"route-page-decomposition":return"Split route/page orchestration from reusable panels and feature controllers.";case"jsx-decomposition":return e==="route-page"?"Split page JSX into named layout sections before extracting behavior.":"Split repeated JSX sections into named presentational components.";case"file-decomposition":return"Review file-level decomposition; split colocated panels or helpers before changing behavior.";case"component-decomposition":return"Review component boundaries around props, state ownership, and independently changing UI sections."}}var h=new Set(["component","components","panel","panels","partial","partials"]),g=new Set(["banner","button","card","dialog","drawer","filter","form","grid","header","item","list","menu","modal","nav","panel","picker","rail","row","section","selector","shell","sidebar","table","toolbar"]),k=new Set(["landing","page","pages","route","routes","screen","screens","view","views"]),T=new Set(["page","route","screen"]);function P(n){return n.charAt(0).toUpperCase()+n.slice(1)}export{S as a};
2
+ //# sourceMappingURL=chunk-CM4EZLW4.js.map
@@ -0,0 +1,2 @@
1
+ import{a as x}from"./chunk-2HFXPIBT.js";import{b as g}from"./chunk-B75HZHUP.js";import{a as k}from"./chunk-3I34FZ6R.js";import{b as L}from"./chunk-NLRWGGPY.js";import{a as n}from"./chunk-BGBBVSH4.js";import{j as v}from"./chunk-DA34GNNO.js";import{d as S}from"./chunk-OO6S4ECV.js";import{s as a}from"./chunk-WFRZGMWJ.js";function E(c,f={}){let{scope:P,minLoc:F=3,scanLimit:d}=f,l=new k(c),b=f.semantic!==!1,y=0,m=a("isolated.candidates",()=>{let s=g(l.productionCallableDefinitions({scope:P,minLoc:F,excludeEntrySurfaces:!0,excludeRootedSymbols:!0,excludeRustTraitImplMembers:!0,includeSuppressed:!0,requireFunctionLikeSymbol:!0,sortByLocDesc:typeof d=="number"&&d>0}),d).filter(R=>!x(c,R));return y=s.length,s},()=>({definitions:y})),p=0,i=a("isolated.strict-callees",()=>{let e=l.symbolsWithNonSelfCallees(m,{additive:!1,semantic:!1});return p=e.size,e},()=>({definitions:m.length,symbols:p})),r=m.filter(e=>!i.has(e.symbolId)),C=0,N=a("isolated.scip-callers",()=>{let e=l.crossFileCallerMap(r,{semantic:!1});return C=e.size,e},()=>({definitions:r.length,symbols:C})),o=new Set(N.keys());for(let e of l.frameworkReferencedSymbolIds(r))o.add(e);let t=r.filter(e=>!o.has(e.symbolId));if(b&&t.length>0){for(let e of v(c,t).keys())o.add(e);for(let e of l.symbolsWithNonSelfCallees(t,{additive:!1,semantic:!0}))i.add(e);t=t.filter(e=>!o.has(e.symbolId)).filter(e=>!i.has(e.symbolId))}let h=0,W=a("isolated.source-fallback-callers",()=>{let e=l.sourceFallbackCallerFiles(t,{skipPath:s=>L(s)==="test"});return h=e.size,e},()=>({definitions:t.length,symbols:h}));for(let e of W.keys())o.add(e);let u=t.filter(e=>!o.has(e.symbolId)),I=0,M=a("isolated.additive-callees",()=>{let e=l.symbolsWithNonSelfCallees(u,{additive:!0,semantic:b});return I=e.size,e},()=>({definitions:u.length,symbols:I}));for(let e of M)i.add(e);return u.filter(e=>!i.has(e.symbolId)).sort((e,s)=>n(s)-n(e)||e.relativePath.localeCompare(s.relativePath)||e.startLine-s.startLine).map(e=>({symbol:e.symbol,shortName:S(e.symbol),relativePath:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:n(e)}))}export{E as a};
2
+ //# sourceMappingURL=chunk-CS3FXTUC.js.map
@@ -0,0 +1,2 @@
1
+ import{j as I}from"./chunk-DA34GNNO.js";import{a as y,e as g}from"./chunk-OO6S4ECV.js";import{B as v}from"./chunk-MCNWCJYL.js";import{c as b,h as D,i as _,q as F,s as p,v as E,x}from"./chunk-WFRZGMWJ.js";import{spawnSync as O}from"child_process";import{createHash as U}from"crypto";import{existsSync as k}from"fs";import{dirname as L,join as T}from"path";import{fileURLToPath as j}from"url";var N=b("definition-consumer-file-usage",{clearGroups:["whole-project","source-file"]}),M=E({kind:"consumer-file-usage",invalidation:x("consumer-file-usage"),serialize:Q,deserialize:W});function Le(e,n){return{forDefinitions(r,i){return V(e,n,r,i)}}}function Me(e){let n=new Map;for(let[r,i]of e)n.set(r,new Set(i.files.map(t=>t.file)));return n}function Re(e,n,r){return w(e,n,r).partition}function V(e,n,r,i){let t=h(r.length),s=F()?_(e):null,a=s?B(r,i,s):void 0,o=a?{workIdentity:a,workOutcome:"computed"}:{};return p("consumer-evidence.product",()=>{let l=p("consumer-evidence.provenance",()=>z(e,n,r,i),()=>({...o,definitions:r.length,semantic:i.semantic,sourceFallback:i.sourceFallback!==!1})),u=new Map;t={...t,...l.counters};let c=Y(r,l.sources);return p("consumer-evidence.classify",()=>{let f=q(e,r,l.sources,c);for(let d of r){let m=f.get(d.symbolId)??H();t.realFiles+=m.partition.realConsumers.length,t.reexportOnlyFiles+=m.partition.barrelConsumers,t.importOnlyFiles+=m.partition.importOnlyConsumers,u.set(d.symbolId,{definition:d,files:m.files,...m.partition})}},()=>({...o,...c,realFiles:t.realFiles,reexportOnlyFiles:t.reexportOnlyFiles,importOnlyFiles:t.importOnlyFiles})),u},()=>({...o,...t}))}function B(e,n,r){let i=U("sha256").update("consumer-evidence-v1\0").update(r).update("\0").update(n.semantic?"semantic\0":"indexed\0").update(n.sourceFallback===!1?"no-source-fallback":"source-fallback");for(let t of e.map(s=>s.symbol).sort())i.update("\0").update(t);return i.digest("hex").slice(0,24)}function h(e){return{definitions:e,indexedFiles:0,semanticFiles:0,fallbackFiles:0,totalFiles:0,realFiles:0,reexportOnlyFiles:0,importOnlyFiles:0}}function z(e,n,r,i){let t=h(r.length),s=new Map;return S(s,t,"indexed",n.crossFileCallerMap(r,{semantic:!1})),i.semantic&&S(s,t,"semantic",I(e,r)),i.sourceFallback!==!1&&S(s,t,"source-fallback",n.sourceFallbackCallerFiles(r)),t.totalFiles=[...s.values()].reduce((a,o)=>a+o.size,0),{sources:s,counters:t}}function Y(e,n){return{definitions:e.length,consumerFiles:[...n.values()].reduce((r,i)=>r+i.size,0),nativeAttempted:!1,nativeUsed:!1,nativeReason:"not-attempted"}}function S(e,n,r,i){let t=0;for(let[s,a]of i){let o=e.get(s);o||(o=new Map,e.set(s,o));for(let l of a){t++;let u=o.get(l)??new Set;u.add(r),o.set(l,u)}}r==="indexed"?n.indexedFiles+=t:r==="semantic"?n.semanticFiles+=t:n.fallbackFiles+=t}function q(e,n,r,i){let t=re(e,n,r,i);return t||$(e,n,r)}function $(e,n,r){let i=new Map;for(let t of n){let s=r.get(t.symbolId)??new Map;i.set(t.symbolId,w(e,t,[...s.keys()],s))}return i}function w(e,n,r,i=new Map){let t=[],s=0,a=0,o=g(n.symbol),l=[];for(let u of r){let c;X(e,u,n.relativePath,o)?(s++,c="reexport-only"):J(e,u,o)?(a++,c="import-only"):(t.push(u),c="real"),l.push({file:u,sources:[...i.get(u)??[]],classification:c})}return{partition:{realConsumers:t,barrelConsumers:s,importOnlyConsumers:a},files:l}}function H(){return{partition:{realConsumers:[],barrelConsumers:0,importOnlyConsumers:0},files:[]}}function J(e,n,r){if(!r)return!1;let i=v(n);if(!i)return!1;let t=N.get(e,n,()=>A(e,n,i));return t.importedLeaves.has(r)&&!t.usedLeaves.has(r)}function A(e,n,r){let i=y(e).forFile(n,{text:!0,ast:!0}),t=i.text;if(!t)return G();let s=D(e,n,t),a=M.read(e,n,s);if(a)return a;let o=K(i.ast,r);return M.write(e,n,s,o),o}function K(e,n){let r=new Set,i=new Set;if(!e)return{importedLeaves:r,usedLeaves:i};let t=n==="rust"?new Set(["use_declaration"]):n==="python"?new Set(["import_statement","import_from_statement"]):new Set(["import_statement"]),s=(a,o)=>{let l=o||t.has(a.type);(a.type==="identifier"||a.type==="type_identifier"||a.type==="property_identifier"||a.type==="field_identifier")&&(l?r.add(a.text):i.add(a.text));for(let u of a.children)s(u,l)};return s(e.rootNode,!1),{importedLeaves:r,usedLeaves:i}}function G(){return{importedLeaves:new Set,usedLeaves:new Set}}function Q(e){return JSON.stringify({importedLeaves:[...e.importedLeaves],usedLeaves:[...e.usedLeaves]})}function W(e){try{let n=JSON.parse(e);return!Array.isArray(n.importedLeaves)||!Array.isArray(n.usedLeaves)?null:{importedLeaves:new Set(n.importedLeaves.filter(r=>typeof r=="string")),usedLeaves:new Set(n.usedLeaves.filter(r=>typeof r=="string"))}}catch{return null}}function X(e,n,r,i){if(!i)return!1;let t=y(e).forFile(n,{lines:!0,reexports:!0}),s=t.lines??[];if(s.length===0)return!1;let a=t.reexports??[];return P(s,a,i)}function P(e,n,r){if(e.length===0||n.length===0)return!1;let i=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),t=new RegExp(`\\b${i}\\b`),s=0;for(let a=0;a<e.length;a++){if(!t.test(e[a]??""))continue;if(s++,!n.find(l=>l.startLine<=a&&a<=l.endLine))return!1}return s>0}var Z="SCIP_QUERY_NATIVE_CONSUMER_CLASSIFY",ee="SCIP_QUERY_NATIVE_KERNELS_BIN",ne="SCIP_QUERY_NATIVE_CONSUMER_CLASSIFY_MIN_FILES",R=1e3,ie=5e3,te=64*1024*1024,C;function re(e,n,r,i){let t=process.env[Z]?.toLowerCase();if(t!=="1"&&t!=="true")return i.nativeReason=t==="0"||t==="false"?"disabled":"opt-in-required",null;if(i.consumerFiles<fe())return i.nativeReason="below-threshold",null;let s=me();if(!s)return i.nativeReason="binary-missing",null;i.nativeAttempted=!0;let a=se(e,n,r),o=O(s,["consumer-classify"],{input:JSON.stringify(a),encoding:"utf8",timeout:ie,maxBuffer:te});if(o.status!==0||o.error)return i.nativeReason=o.error?`spawn-error:${o.error.message}`:`exit-${o.status??"null"}`,null;try{let l=JSON.parse(o.stdout),u=ae(l,n);return u?(i.nativeUsed=!0,i.nativeReason="used",u):(i.nativeReason="invalid-response",null)}catch{return i.nativeReason="invalid-json",null}}function se(e,n,r){let i=new Map,t=[];for(let o of n){let l=g(o.symbol),c=[...(r.get(o.symbolId)??new Map).entries()].map(([f,d])=>{let m=i.get(f)??new Set;return l&&m.add(l),i.set(f,m),{file:f,sources:[...d]}});t.push({symbol_id:o.symbolId,leaf:l,consumer_files:c})}let s={},a={};for(let[o,l]of i){let u=v(o);if(u){let f=N.get(e,o,()=>A(e,o,u));s[o]={imported_leaves:[...f.importedLeaves],used_leaves:[...f.usedLeaves]}}let c=oe(e,o,l);c.length>0&&(a[o]=c)}return{definitions:t,file_usages:s,reexport_only_leaves:a}}function oe(e,n,r){if(r.size===0)return[];let i=y(e).forFile(n,{lines:!0,reexports:!0}),t=i.lines??[],s=i.reexports??[];return t.length===0||s.length===0?[]:[...r].filter(a=>P(t,s,a))}function ae(e,n){if(!Array.isArray(e.entries)||e.entries.length!==n.length)return null;let r=new Set(n.map(t=>t.symbolId)),i=new Map;for(let t of e.entries){let s=le(t);if(!s||!r.has(s.symbol_id))return null;i.set(s.symbol_id,{partition:{realConsumers:s.real_consumers,barrelConsumers:s.barrel_consumers,importOnlyConsumers:s.import_only_consumers},files:s.files})}for(let t of r)if(!i.has(t))return null;return i}function le(e){if(!e||typeof e!="object")return null;let n=e;if(typeof n.symbol_id!="number"||!Array.isArray(n.real_consumers)||typeof n.barrel_consumers!="number"||typeof n.import_only_consumers!="number"||!Array.isArray(n.files)||!n.real_consumers.every(i=>typeof i=="string"))return null;let r=[];for(let i of n.files){if(!i||typeof i!="object")return null;let t=i;if(typeof t.file!="string"||!Array.isArray(t.sources)||!t.sources.every(ue)||!ce(t.classification))return null;r.push({file:t.file,sources:t.sources,classification:t.classification})}return{symbol_id:n.symbol_id,real_consumers:n.real_consumers,barrel_consumers:n.barrel_consumers,import_only_consumers:n.import_only_consumers,files:r}}function ue(e){return e==="indexed"||e==="semantic"||e==="source-fallback"}function ce(e){return e==="real"||e==="reexport-only"||e==="import-only"}function fe(){let e=process.env[ne];if(!e)return R;let n=Number(e);return Number.isFinite(n)&&n>=0?n:R}function me(){if(C!==void 0)return C;let e=process.env[ee],n=process.platform==="win32"?"scip-query-kernels.exe":"scip-query-kernels";return C=[...e?[e]:[],...de().map(i=>T(i,"target","release",n))].find(i=>k(i))??null,C}function de(){let e=new Set,n=L(j(import.meta.url));for(let r=0;r<5;r++)e.add(n),n=L(n);return[...e]}export{Le as a,Me as b,Re as c,J as d};
2
+ //# sourceMappingURL=chunk-CVBS2FD4.js.map
@@ -0,0 +1,7 @@
1
+ import d from"process";import{existsSync as J,readFileSync as Re}from"fs";import{dirname as D,join as we,resolve as v,sep as be}from"path";import{fileURLToPath as Se}from"url";import{spawn as Z}from"child_process";var l=class extends Error{},h=class extends Error{constructor(r,n,i){super(`rust-analyzer LSP request ${n} failed: ${i}`);this.code=r}code},ee=3e4,g=class{constructor(e,r={}){this.transport=e;this.requestTimeoutMs=r.requestTimeoutMs??ee,this.configuration=r.configuration??{},this.transport.onData(n=>this.handleData(n)),this.transport.onClose((n,i)=>this.rejectPending(new Error(ae(n,i)))),this.transport.onError(n=>this.rejectPending(n))}transport;nextId=1;buffer=Buffer.alloc(0);pending=new Map;diagnosedUris=new Set;diagnosticWaiters=new Map;readinessWaiters=new Set;requestTimeoutMs;configuration;currentServerStatusGeneration=0;latestServerStatus=null;shutdownStarted=!1;async initialize(e,r={}){let n=e.capabilities??{},i=n.experimental&&typeof n.experimental=="object"&&!Array.isArray(n.experimental)?n.experimental:{},s=await this.request("initialize",{...e,capabilities:{...n,experimental:{...i,serverStatusNotification:!0}}},r);return this.notify("initialized",{}),s}async references(e,r={}){let n=await this.request("textDocument/references",e,r);return Array.isArray(n)?n:[]}async definition(e,r={}){let n=await this.request("textDocument/definition",e,r);return ne(n)}async prepareCallHierarchy(e,r={}){let n=await this.request("textDocument/prepareCallHierarchy",e,r);return Array.isArray(n)?n:[]}async outgoingCalls(e,r={}){let n=await this.request("callHierarchy/outgoingCalls",{item:e},r);return Array.isArray(n)?n:[]}async hover(e,r={}){let n=await this.request("textDocument/hover",e,r);return n&&typeof n=="object"?n:null}async readinessBarrier(e={}){try{await this.request("scip-query/readinessBarrier",null,e)}catch(r){if(r instanceof h&&r.code===-32601)return;throw r}}serverStatusGeneration(){return this.currentServerStatusGeneration}serverStatusSnapshot(){let e=this.latestServerStatus;return e?{generation:e.generation,status:{...e.status}}:null}waitForQuiescence(e,r){let n=this.latestServerStatus;if(n&&n.generation>e){if(n.status.health==="error")return Promise.reject(q());if(n.status.quiescent)return Promise.resolve(n.status)}return new Promise((i,s)=>{let u={afterGeneration:e,resolve:i,reject:s,timeout:setTimeout(()=>{this.readinessWaiters.delete(u),s(new Error(`rust-analyzer readiness timed out after ${r}ms`))},r)};this.readinessWaiters.add(u)})}didOpenTextDocument(e){this.notify("textDocument/didOpen",{textDocument:e})}waitForDiagnostics(e,r){return this.diagnosedUris.has(e)?Promise.resolve(!0):new Promise(n=>{let i=a=>{clearTimeout(s),n(a)},s=setTimeout(()=>{let a=this.diagnosticWaiters.get(e)?.filter(c=>c!==i);a&&a.length>0?this.diagnosticWaiters.set(e,a):this.diagnosticWaiters.delete(e),n(!1)},r),u=this.diagnosticWaiters.get(e)??[];u.push(i),this.diagnosticWaiters.set(e,u)})}async shutdown(e={}){if(!this.shutdownStarted){this.shutdownStarted=!0;try{await this.request("shutdown",null,e),this.notify("exit",null)}catch(r){throw this.notify("exit",null),this.transport.kill(),r}}}request(e,r,n={}){let i=R(n.timeoutMs??this.requestTimeoutMs,n.deadlineMs),s=this.nextId++,u={jsonrpc:"2.0",id:s,method:e,params:r};return new Promise((a,c)=>{let f=setTimeout(()=>{this.pending.delete(s),c(i.deadlineLimited?new l(`rust-analyzer readiness deadline expired during LSP request ${e}`):new Error(`rust-analyzer LSP request ${e} timed out after ${i.timeoutMs}ms`))},i.timeoutMs);this.pending.set(s,{method:e,deadlineMs:n.deadlineMs,resolve:y=>a(y),reject:c,timeout:f}),this.transport.write(z(u))})}notify(e,r){this.transport.write(z({jsonrpc:"2.0",method:e,params:r}))}handleData(e){for(this.buffer=Buffer.concat([this.buffer,e]);;){let r=this.buffer.indexOf(`\r
2
+ \r
3
+ `);if(r<0)return;let n=this.buffer.subarray(0,r).toString("ascii"),i=/(?:^|\r\n)Content-Length:\s*(\d+)/i.exec(n);if(!i){this.rejectPending(new Error("rust-analyzer LSP response missing Content-Length header"));return}let s=Number(i[1]),u=r+4,a=u+s;if(this.buffer.length<a)return;let c=this.buffer.subarray(u,a).toString("utf8");this.buffer=this.buffer.subarray(a),this.dispatchMessage(oe(c))}}dispatchMessage(e){if(this.recordDiagnosticNotification(e),this.recordServerStatusNotification(e),e.id!==void 0&&e.id!==null&&e.method){this.respondToServerRequest(e);return}if(e.id===void 0||e.id===null)return;let r=this.pending.get(e.id);if(r){if(clearTimeout(r.timeout),this.pending.delete(e.id),e.error){r.reject(new h(e.error.code,r.method,e.error.message));return}if(r.deadlineMs!==void 0&&Date.now()>=r.deadlineMs){r.reject(new l(`rust-analyzer readiness deadline expired during LSP request ${r.method}`));return}r.resolve(e.result)}}recordDiagnosticNotification(e){if(e.method!=="textDocument/publishDiagnostics")return;let r=e.params,n=r&&typeof r=="object"&&typeof r.uri=="string"?r.uri:null;if(!n)return;this.diagnosedUris.add(n);let i=this.diagnosticWaiters.get(n)??[];this.diagnosticWaiters.delete(n),i.forEach(s=>s(!0))}recordServerStatusNotification(e){if(e.method!=="experimental/serverStatus"||e.id!==void 0||!te(e.params))return;let r=e.params,n={health:r.health,quiescent:r.quiescent,...typeof r.message=="string"?{message:r.message}:{}},i=++this.currentServerStatusGeneration;if(this.latestServerStatus={generation:i,status:n},n.health==="error"){this.rejectReadinessWaiters(q());return}if(n.quiescent)for(let s of this.readinessWaiters)i<=s.afterGeneration||(clearTimeout(s.timeout),this.readinessWaiters.delete(s),s.resolve(n))}respondToServerRequest(e){if(e.id===void 0||e.id===null||!e.method)return;let r=e.method==="workspace/configuration"?this.workspaceConfiguration(e.params):null;this.transport.write(z({jsonrpc:"2.0",id:e.id,result:r}))}workspaceConfiguration(e){return(e&&typeof e=="object"&&Array.isArray(e.items)?e.items:[]).map(n=>typeof n.section=="string"?re(this.configuration,n.section):this.configuration)}rejectPending(e){for(let[r,n]of this.pending)clearTimeout(n.timeout),n.reject(e),this.pending.delete(r);this.rejectReadinessWaiters(e)}rejectReadinessWaiters(e){for(let r of this.readinessWaiters)clearTimeout(r.timeout),r.reject(e),this.readinessWaiters.delete(r)}};function R(t,e,r=Date.now){if(e===void 0)return{timeoutMs:t,deadlineLimited:!1};let n=e-r();if(n<=0)throw new l("rust-analyzer readiness deadline expired before LSP operation");return{timeoutMs:Math.min(t,n),deadlineLimited:n<=t}}function te(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return(e.health==="ok"||e.health==="warning"||e.health==="error")&&typeof e.quiescent=="boolean"&&(e.message===void 0||e.message===null||typeof e.message=="string")}function q(){return new l("rust-analyzer reported error health before reaching readiness")}function re(t,e){let r=e.startsWith("rust-analyzer.")?e.slice(14):e;if(r===""||r==="rust-analyzer")return t;let n=t;for(let i of r.split(".")){if(!n||typeof n!="object")return null;n=n[i]}return n??null}function ne(t){return t?(Array.isArray(t)?t:[t]).flatMap(r=>ie(r)?[r]:se(r)?[{uri:r.targetUri,range:r.targetSelectionRange}]:[]):[]}function ie(t){return!!(t&&typeof t=="object"&&typeof t.uri=="string")}function se(t){return!!(t&&typeof t=="object"&&typeof t.targetUri=="string")}function W(t,e,r=process.env){let n=Z(t,[],{cwd:e,env:r,stdio:["pipe","pipe","pipe"]});return{write(i){n.stdin.write(i)},onData(i){n.stdout.on("data",i)},onClose(i){n.on("close",i)},onError(i){n.on("error",i)},kill(){n.kill()}}}function z(t){let e=JSON.stringify(t);return`Content-Length: ${Buffer.byteLength(e,"utf8")}\r
4
+ \r
5
+ ${e}`}function oe(t){let e=JSON.parse(t);if(!e||typeof e!="object")throw new Error("rust-analyzer LSP response was not a JSON object");return e}function ae(t,e){return`rust-analyzer LSP transport closed${e?` by ${e}`:t===null?"":` with code ${t}`}`}async function j(t,e,r,n=Date.now){let i=r-n();if(i<=0)throw new l("rust-analyzer readiness deadline expired before quiescence");try{let s=await t.waitForQuiescence(e,i);if(w(r,n,"during quiescence"),s.health==="error")throw new l("rust-analyzer reported error health before reaching readiness");if(!s.quiescent)throw new l("rust-analyzer did not report quiescence before reaching readiness");return s}catch(s){throw s instanceof l?s:new l(s instanceof Error?s.message:String(s))}}async function Ge(t,e,r,n,i,s=Date.now,u=x){let a=await j(t,e,n,s);if(r===0)return a;let c=t.serverStatusSnapshot();if(!c)throw new l("rust-analyzer status is unavailable after initial document open");return await ue(t,c,r,n,i,s,u)??a}async function ue(t,e,r,n,i,s=Date.now,u=x){if(r===0)return null;if(!e)throw new l("rust-analyzer status is unavailable before document open");E(e.status,"before document open");try{await t.readinessBarrier({deadlineMs:n}),w(n,s,"during post-open synchronization")}catch(f){throw f instanceof l?f:new l(f instanceof Error?f.message:String(f))}let a=t.serverStatusSnapshot();if(!a||a.generation<e.generation)throw new l("rust-analyzer status is unavailable after document open");let c;return a.generation===e.generation?(E(a.status,"after document open"),c=a.status):c=await j(t,e.generation,n,s),await P(i,n,s,u),c}async function Qe(t,e,r,n=Date.now){let i=R(e,r,n);await t(i.timeoutMs),w(r,n,"during diagnostics")}async function P(t,e,r=Date.now,n=x){if(t<=0)return;if(R(t,e,r).deadlineLimited)throw new l("rust-analyzer readiness deadline cannot accommodate delay");await n(t),w(e,r,"during delay")}async function Ke(t,e){try{return await t()}catch(r){throw r instanceof l&&await e(),r}}function Ve(t){return t instanceof l?{ok:!1,error:t.message}:null}function w(t,e,r){if(t-e()<=0)throw new l(`rust-analyzer readiness deadline expired ${r}`)}function E(t,e){if(t.health==="error")throw new l(`rust-analyzer reported error health ${e}`);if(!t.quiescent)throw new l(`rust-analyzer did not report quiescence ${e}`)}function x(t){return new Promise(e=>setTimeout(e,t))}import{existsSync as le,readFileSync as ce}from"fs";import{relative as fe,resolve as H,sep as de}from"path";import{fileURLToPath as pe,pathToFileURL as me}from"url";function b(t,e){return me(H(t,e)).href}function C(t,e){let r=pe(e);return fe(t,r).split(de).join("/")}function S(t,e,r){return{textDocument:{uri:b(t,e.relativePath)},position:ye(t,e),context:{includeDeclaration:r}}}function ye(t,e){let r={line:e.startLine,character:e.startChar??0},n=H(t,e.relativePath);if(!le(n))return r;try{return he(ce(n,"utf8"),e,r)}catch{return r}}function he(t,e,r={line:e.startLine,character:e.startChar??0}){let n=t.split(/\r?\n/),i=n[e.startLine];if(i===void 0||e.leaf.length===0)return r;let s=Math.max(0,Math.min(r.character,i.length)),u=i.indexOf(e.leaf,s);if(u>=0)return{line:e.startLine,character:A(u,e.leaf)};let a=i.indexOf(e.leaf);if(a>=0)return{line:e.startLine,character:A(a,e.leaf)};let c=ge(n,e.startLine,e.leaf);return c||r}function A(t,e){return t+Math.max(0,e.length-2)}function ge(t,e,r){for(let n of[-1,1,-2,2]){let i=e+n;if(i<0||i>=t.length)continue;let s=t[i].indexOf(r);if(s>=0)return{line:i,character:A(s,r)}}return null}function F(t,e){return e.map(r=>({file:C(t,r.uri),line:r.range.start.line,column:r.range.start.character}))}function $(t){let e=new Map;for(let r of t)e.set(`${r.file}\0${r.line}\0${r.column}`,r);return[...e.values()].sort((r,n)=>{let i=r.file.localeCompare(n.file);return i!==0?i:r.line!==n.line?r.line-n.line:r.column-n.column})}async function ve(t){let e=t.includeReferences!==!1,r=t.includeCallees===!0,n=t.includeSignatures===!0,i={timeoutMs:t.requestTimeoutMs},s=Le(t),u=B(t),a=U(t),c=N(t),f=ke(t.projectRoot,s),y=Me(t.projectRoot,f),k=De(f),p=new g(W(t.rustAnalyzerBinary,y),{requestTimeoutMs:t.requestTimeoutMs,configuration:k});try{let L=await p.initialize({processId:d.pid,rootUri:b(y,"."),capabilities:{textDocument:{references:{dynamicRegistration:!1},callHierarchy:{dynamicRegistration:!1},hover:{dynamicRegistration:!1}}},initializationOptions:k});if(e&&!L.capabilities.referencesProvider)return{available:!1,reason:"rust-analyzer initialized without textDocument/references support.",references:u.map(o=>[o.symbolId,[]]),...r?{callees:a.map(o=>[o.symbolId,[]])}:{}};if(r&&!L.capabilities.callHierarchyProvider)return{available:!1,reason:"rust-analyzer initialized without call hierarchy support.",references:u.map(o=>[o.symbolId,[]]),callees:a.map(o=>[o.symbolId,[]]),...n?{signatures:c.map(o=>[o.symbolId,null])}:{}};if(n&&!L.capabilities.hoverProvider)return{available:!1,reason:"rust-analyzer initialized without hover support.",references:u.map(o=>[o.symbolId,[]]),...r?{callees:a.map(o=>[o.symbolId,[]])}:{},signatures:c.map(o=>[o.symbolId,null])};let V=Ie(p,t.projectRoot,s);await Oe(p,V,t.diagnosticsTimeoutMs??1e4),await K(t.settleDelayMs??5e3);let I=e?await T(u,t.concurrency??8,async o=>{let O=await _(p,S(t.projectRoot,o,!1),{requestTimeoutMs:t.requestTimeoutMs,retryTimeoutMs:t.referenceRetryTimeoutMs});return{symbolId:o.symbolId,references:$(F(t.projectRoot,O.locations)),complete:O.complete}}):u.map(o=>({symbolId:o.symbolId,references:[],complete:!0})),X=r?await T(a,t.concurrency??8,async o=>({symbolId:o.symbolId,callees:await We(p,t.projectRoot,o,i)})):[],Y=n?await T(c,t.concurrency??8,async o=>({symbolId:o.symbolId,signature:await ze(p,t.projectRoot,o,i)})):[];return{available:!0,references:I.filter(o=>o.complete).map(o=>[o.symbolId,o.references]),incompleteReferenceSymbolIds:I.filter(o=>!o.complete).map(o=>o.symbolId),...r?{callees:X.map(o=>[o.symbolId,o.callees])}:{},...n?{signatures:Y.map(o=>[o.symbolId,o.signature])}:{}}}finally{await p.shutdown().catch(()=>{})}}function B(t){return t.referenceDefinitions??t.definitions}function U(t){return t.calleeDefinitions??t.definitions}function N(t){return t.signatureDefinitions??t.definitions}function Le(t){return[...t.includeReferences!==!1?B(t):[],...t.includeCallees===!0?U(t):[],...t.includeSignatures===!0?N(t):[]]}async function ze(t,e,r,n={}){let i=S(e,r,!1),s=await Pe(t,{textDocument:i.textDocument,position:i.position},n);return xe(s)}async function Pe(t,e,r={}){try{return await t.hover(e,r)}catch(n){if(m(n),!(n instanceof Error?n.message:String(n)).includes("content modified"))return null;await Q(r.deadlineMs);try{return await t.hover(e,r)}catch(s){return m(s),null}}}function xe(t){if(!t)return null;let e=Ae(t.contents),r=/```(?:rust)?\s*([\s\S]*?)```/i.exec(e),n=r?r[1]:e;for(let i of n.split(/\r?\n/)){let s=i.replace(/^`+|`+$/g,"").trim();if(s&&Te(s))return s}return null}function Ae(t){return typeof t=="string"?t:Array.isArray(t)?t.map(Ce).join(`
6
+ `):"value"in t?t.value:""}function Ce(t){return typeof t=="string"?t:t.value}function Te(t){return/^(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?(?:const\s+)?(?:unsafe\s+)?(?:extern\s+(?:"[^"]+"\s+)?)?(?:fn|struct|enum|trait|type|const|static|mod)\b/.test(t)}function De(t){return{...t.length>0?{linkedProjects:t}:{},references:{excludeImports:!1,excludeTests:!1}}}function Me(t,e){return e.length===1?D(e[0]):v(t)}function ke(t,e){let r=v(t),n=[],i=new Set;for(let s of e){let u=D(v(r,s.relativePath));for(;$e(r,u);){let a=we(u,"Cargo.toml");if(J(a)){i.has(a)||(i.add(a),n.push(a));break}let c=D(u);if(c===u)break;u=c}}return n}function Ie(t,e,r){let n=new Set,i=[];for(let s of r){if(n.has(s.relativePath))continue;n.add(s.relativePath);let u=v(e,s.relativePath);if(!J(u))continue;let a=b(e,s.relativePath);t.didOpenTextDocument({uri:a,languageId:"rust",version:1,text:Re(u,"utf8")}),i.push(a)}return i}async function Oe(t,e,r){await Promise.all(e.map(n=>t.waitForDiagnostics(n,r).catch(()=>!1)))}async function lt(t,e){return(await _(t,e)).locations}async function _(t,e,r={}){try{return{locations:await t.references(e,{timeoutMs:r.requestTimeoutMs,deadlineMs:r.deadlineMs}),complete:!0}}catch(n){m(n);let i=n instanceof Error?n.message:String(n);if(M(n))return qe(t,e,r);if(!i.includes("content modified"))return{locations:[],complete:!0};await Q(r.deadlineMs);try{return{locations:await t.references(e,G(r)),complete:!0}}catch(s){return m(s),{locations:[],complete:!M(s)}}}}async function qe(t,e,r){if(!r.retryTimeoutMs||r.retryTimeoutMs<=0)return{locations:[],complete:!1};let n=G(r);try{return{locations:await t.references(e,n),complete:!0}}catch(i){return m(i),{locations:[],complete:!M(i)}}}function G(t){return{...t.retryTimeoutMs&&t.retryTimeoutMs>0?{timeoutMs:t.retryTimeoutMs}:{},...t.deadlineMs!==void 0?{deadlineMs:t.deadlineMs}:{}}}function M(t){let e=t instanceof Error?t.message:String(t);return e.includes("rust-analyzer LSP request")&&e.includes("timed out after")}async function We(t,e,r,n={}){let i=S(e,r,!1),s=await Ee(t,{textDocument:i.textDocument,position:i.position},n),u=(await Promise.all(s.map(a=>je(t,a,n)))).flat();return Fe(He(e,u))}async function Ee(t,e,r={}){try{return await t.prepareCallHierarchy(e,r)}catch(n){return m(n),[]}}async function je(t,e,r={}){try{return await t.outgoingCalls(e,r)}catch(n){return m(n),[]}}async function Q(t){if(t===void 0){await K(1e3);return}await P(1e3,t)}function m(t){if(t instanceof l)throw t}function He(t,e){return e.map(r=>({symbol:r.to.name,file:C(t,r.to.uri),line:r.to.selectionRange.start.line}))}function Fe(t){let e=new Set,r=[];for(let n of t){let i=`${n.symbol}\0${n.file}\0${n.line}`;e.has(i)||(e.add(i),r.push(n))}return r.sort((n,i)=>n.file.localeCompare(i.file)||n.line-i.line||n.symbol.localeCompare(i.symbol))}function K(t){return t<=0?Promise.resolve():new Promise(e=>setTimeout(e,t))}function $e(t,e){return e===t||e.startsWith(`${t}${be}`)}async function T(t,e,r){let n=new Array(t.length),i=0,s=Math.max(1,Math.min(t.length,Math.floor(e)));return await Promise.all(Array.from({length:s},async()=>{for(;i<t.length;){let u=i++;n[u]=await r(t[u])}})),n}async function Je(){return new Promise((t,e)=>{let r=[];d.stdin.on("data",n=>r.push(n)),d.stdin.on("error",e),d.stdin.on("end",()=>t(Buffer.concat(r).toString("utf8")))})}async function Be(){try{let t=JSON.parse(await Je()),e=await ve(t);d.stdout.write(JSON.stringify(e))}catch(t){let e={available:!1,reason:t instanceof Error?t.message:String(t),references:[]};d.stdout.write(JSON.stringify(e)),d.exitCode=1}}d.argv[1]&&Se(import.meta.url)===d.argv[1]&&Be();export{b as a,C as b,S as c,F as d,$ as e,g as f,W as g,Ge as h,ue as i,Qe as j,Ke as k,Ve as l,ve as m,B as n,U as o,N as p,Le as q,ze as r,Pe as s,xe as t,De as u,Me as v,ke as w,Ie as x,Oe as y,lt as z,_ as A,We as B,K as C,T as D};
7
+ //# sourceMappingURL=chunk-D5OXYOJP.js.map
@@ -0,0 +1,29 @@
1
+ import{C as G,E as W,F as Z,k as te,l as ie,m as re,n as $,v as B,w as x}from"./chunk-EBSSCVR4.js";import{a as J}from"./chunk-NLVKD45E.js";import{d as X,g as U,i as z,k as ee,m as ne,q as O,s as P,v as L,w as j,x as F}from"./chunk-WFRZGMWJ.js";import{existsSync as Re,readFileSync as Ie}from"fs";import{resolve as De}from"path";function Je(n,e){return N(n,e,t=>{let i=t?`AND m.symbol_id IN (${t.map(()=>"?").join(",")})`:"";return n.all(`SELECT
2
+ m.symbol_id,
3
+ d.relative_path,
4
+ COUNT(*) AS ref_count
5
+ FROM mentions m
6
+ JOIN chunks c ON m.chunk_id = c.id
7
+ JOIN documents d ON c.document_id = d.id
8
+ WHERE m.role != 1
9
+ ${i}
10
+ ${n.pathExclusionsFor("d")}
11
+ GROUP BY m.symbol_id, d.relative_path`,...t??[])})}function $e(n,e){return N(n,e,t=>{let i=t?`AND m.symbol_id IN (${t.map(()=>"?").join(",")})`:"";return n.all(`SELECT DISTINCT m.symbol_id, d.relative_path
12
+ FROM mentions m
13
+ JOIN chunks c ON m.chunk_id = c.id
14
+ JOIN documents d ON c.document_id = d.id
15
+ WHERE m.role != 1
16
+ ${i}
17
+ ${n.pathExclusionsFor("d")}`,...t??[])}).filter(t=>t.symbol_id!==null)}function Be(n,e){return N(n,e,t=>{let i=t?`AND m.symbol_id IN (${t.map(()=>"?").join(",")})`:"";return n.all(`SELECT DISTINCT m.symbol_id
18
+ FROM mentions m
19
+ WHERE m.role != 1
20
+ ${i}`,...t??[])}).filter(t=>t.symbol_id!==null)}function ae(n,e){return N(n,e,t=>{let i=t?`AND m.symbol_id IN (${t.map(()=>"?").join(",")})`:"";return n.all(`SELECT DISTINCT m.symbol_id, d.relative_path, c.document_id,
21
+ c.start_line AS chunk_start, c.end_line AS chunk_end
22
+ FROM mentions m
23
+ JOIN chunks c ON m.chunk_id = c.id
24
+ JOIN documents d ON c.document_id = d.id
25
+ WHERE m.role != 1
26
+ ${i}
27
+ ${n.pathExclusionsFor("d")}
28
+ ORDER BY d.relative_path, c.start_line`,...t??[])})}function N(n,e,t){if(!e)return t();if(e.length===0)return[];let i=[];for(let r=0;r<e.length;r+=750)i.push(...t(e.slice(r,r+750)));return i}var ve=/^[A-Za-z_][A-Za-z0-9_]*$/,oe=/\bDefault::default\b/g,Me=/^\.\.\s*Default::default\b/;function se(n,e){let t=new Map,i=new Map;for(let r of e){let a=Y(n,r,i);a!==null&&t.set(r.symbolId,a)}return t}function Y(n,e,t=new Map){let i=xe(e.symbol);if(!i)return null;let r=ae(n,[e.symbolId]);if(r.length===0)return null;let a=new RegExp(`(^|[^A-Za-z0-9_])${J(i)}::default\\b`,"g"),o=new RegExp(`(^|[^A-Za-z0-9_])${J(i)}\\s*$`),f=Ce(n,e.symbolId),m=[];for(let S of r){let d=Ee(n,S.relative_path,t);if(d===null)return null;let l=d.split(/\r?\n/),u=0,p=[],b=0;for(let R=S.chunk_start;R<=S.chunk_end&&R<l.length;R+=1){let D=l[R]??"",w=new Set;a.lastIndex=0;let M;for(;M=a.exec(D);)m.push({file:S.relative_path,line:R,column:M.index+M[1].length+i.length+2}),b+=1;for(let c=0;c<D.length;c+=1){let y=Me.exec(D.slice(c));if(y){if(f&&p.includes(u)){let g=c+y[0].lastIndexOf("default");m.push({file:S.relative_path,line:R,column:g}),w.add(g),b+=1}c+=y[0].length-1;continue}let h=D[c];if(h==="{"){let g=o.test(D.slice(0,c));u+=1,g&&p.push(u);continue}if(h==="}")for(u=Math.max(0,u-1);p.length>0&&p[p.length-1]>u;)p.pop()}for(oe.lastIndex=0;M=oe.exec(D);){let c=M.index+9;if(!w.has(c))return null}}if(b===0)return null}return te(m)}function Ce(n,e){return n.get("SELECT 1 AS present FROM mentions WHERE symbol_id = ? AND role = 1 LIMIT 1",e)?.present===1}function xe(n){let e=/impl#\[([^\]]+)\]\[Default\]default\(\)\./.exec(n)?.[1]??null;return!e||!ve.test(e)?null:e}function Ee(n,e,t){if(t.has(e))return t.get(e)??null;let i=n.get("SELECT text FROM documents WHERE relative_path = ?",e),r=typeof i?.text=="string"?i.text:_e(n,e);return t.set(e,r),r}function _e(n,e){let t=De(n.config.projectRoot,e);if(!Re(t))return null;try{return Ie(t,"utf8")}catch{return null}}function ce(n){let e=new Map;for(let t of n){let i=e.get(t.relativePath)??[];i.push(t),e.set(t.relativePath,i)}return e}var Pe="typescript-import-usage-v1",we="typescript-signatures-v1",Q=X("semantic-prefetched-callees",{clearGroups:["whole-project","source-file","semantic-provider"]}),le=j({kind:"semantic-import-usage",invalidation:F("semantic-import-usage"),serialize:n=>JSON.stringify(n),deserialize:he}),ue=j({kind:"semantic-signatures",invalidation:F("semantic-signatures"),serialize:n=>JSON.stringify(n),deserialize:Le}),fe=L({kind:"typescript-import-usage",invalidation:F("typescript-import-usage"),serialize:n=>JSON.stringify(n),deserialize:he}),me=L({kind:"typescript-signatures",invalidation:F("typescript-signatures"),serialize:n=>JSON.stringify(n),deserialize:je});function k(n){let e=new Map,t=new Set;return{capability:(i,r)=>ye(n,i,r),importUsage:i=>Fe(n,i),references:i=>de(n,i),materializeReferences:(i,r)=>ge(n,i,e,t,r),callerMap:i=>Ae(n,i,e,t),calleeMap:i=>He(n,i),signature:i=>Ue(n,i)}}function Te(n,e){if(e.size===0)return;let t=Q.get(n,()=>new Map);for(let[i,r]of e)t.set(i,[...r])}function fn(n,e){if(!Q.has(n))return{hits:[],misses:[...e]};let t=Q.get(n,()=>new Map),i=[],r=[];for(let a of e)t.has(a.symbolId)?i.push({definition:a,callees:t.get(a.symbolId)??[]}):r.push(a);return{hits:i,misses:r}}function mn(n,e){return k(n).importUsage(e)}function Fe(n,e){if(x(e)==="typescript"){let a="fallback",o=0,f=0,m=0,S=0;return P("typescript.import-usage.materialize",()=>{let d=G(n,e,Pe);if(d?.key){o=1;let u=fe.read(n,e,d.key);if(u)return a="hit",f=1,u;m=1;let p=E(n,e);if(!p)return a="unavailable",[];let b=p.importUsage(e);return fe.write(n,e,d.key,b),a="computed",b}S=1;let l=E(n,e);return l?(a="direct-fallback",l.importUsage(e)):(a="unavailable",[])},()=>({state:a,eligible:o,cacheHits:f,cacheMisses:m,fallbacks:S}))}let t=Se(n,"semantic-import-usage",e);if(t){let a=le.read(n,e,t);if(a)return a}let i=E(n,e);if(!i)return[];let r=i.importUsage(e);return t&&le.write(n,e,t,r),r}function pn(n,e){return k(n).references(e)}function de(n,e){let t=Y(n,e);if(t)return t;let i=re(n,e);if(i)return i;let r=E(n,e.relativePath);return r?r.referencesFor(e):[]}function dn(n,e){return k(n).callerMap(e)}function gn(n,e){let t=new Map,i=new Map;for(let r of e){if(x(r.relativePath)==="typescript"){let a=E(n,r.relativePath);if(!a)continue;let o=i.get(a)??[];o.push(r),i.set(a,o);continue}K(n,t,r,de(n,r))}for(let[r,a]of i){let o=Z(n,a),f=o?.references??(r.referencesForDefinitions?r.referencesForDefinitions(a,{exact:!0}):new Map(a.map(m=>[m.symbolId,r.referencesFor(m)])));!o&&O()&&W(n,a,f);for(let m of a)K(n,t,m,f.get(m.symbolId)??[])}return t}function Ae(n,e,t=new Map,i=new Set){let r=new Map,a=ge(n,e,t,i),o=0;return P("semantic.callers.from-references",()=>{for(let f of e)o+=K(n,r,f,t.get(f.symbolId)??[])},()=>({definitions:e.length,materialized:a.definitions,inMemoryHits:a.inMemoryHits,incompleteInMemoryHits:a.incompleteInMemoryHits,resultRows:r.size,callerFiles:o})),r}function ge(n,e,t,i,r={}){let a=z(n),o=[],f=[],m=[],S=0,d=0,l=0,u=0,p=0,b=0,R=0,_=0,D=0,w=0,M=0,c=0,y=[],h=new Map,g=e.filter(s=>x(s.relativePath)==="typescript"&&!t.has(s.symbolId)&&!i.has(s.symbolId)),v=Z(n,g);if(v){D=g.length,w=v.cacheHits,M=v.cacheMisses,c=v.computedFiles;for(let s of g)t.set(s.symbolId,v.references.get(s.symbolId)??[])}if(P("semantic.references.cache-scan",()=>{for(let[s,I]of ce(e)){let T=[];for(let C of I)t.has(C.symbolId)?d+=1:i.has(C.symbolId)?_+=1:T.push(C);if(T.length===0){R+=1;continue}let H=ke(n,a,s);if(!H){for(let C of T)x(C.relativePath)||(S+=1),m.push(C);continue}b+=1;let be=ee(n,s,H);for(let C of T){let V=be.get(C.symbol)??null;if(V!==null){let q=Ne(V);if(q){l+=1,t.set(C.symbolId,q);continue}u+=1}f.push({definition:C,cacheFingerprint:H})}}},()=>({definitions:e.length,skippedUnsupportedLanguage:S,cacheHits:l,parseFailures:u,misses:f.length,unkeyed:m.length,inMemoryHits:d,incompleteInMemoryHits:_,fullyInMemoryFiles:R,cacheReadFiles:b})),f.length>0||m.length>0){y=[...m,...f.map(s=>s.definition)],h=P("semantic.references.compute-misses",()=>{let s=Oe(n,y,r);return p=s.size,s},()=>({definitions:y.length,misses:f.length,unkeyed:m.length,rows:p}));for(let s of y)h.has(s.symbolId)?(t.set(s.symbolId,h.get(s.symbolId)??[]),i.delete(s.symbolId)):i.add(s.symbolId);for(let{definition:s,cacheFingerprint:I}of f)h.has(s.symbolId)&&ye(n,"semantic-references",s.relativePath).available&&o.push({relativePath:s.relativePath,symbol:s.symbol,projectFingerprint:I,payload:JSON.stringify(h.get(s.symbolId)??[])})}return o.length>0&&P("semantic.references.cache-write",()=>ne(n,o),()=>({entries:o.length})),h.size>0&&W(n,y,h),{definitions:e.length,inMemoryHits:d,incompleteInMemoryHits:_,cacheHits:l,misses:f.length,unkeyed:m.length,skippedUnsupportedLanguage:S,parseFailures:u,computed:p,incomplete:i.size,cacheWrites:o.length,fragmentDefinitions:D,fragmentCacheHits:w,fragmentCacheMisses:M,fragmentComputedFiles:c}}function ke(n,e,t){if(!e)return null;let i=x(t);return i==="typescript"?e:i==="rust"?U(JSON.stringify({kind:"semantic-references",language:i,engine:$(n.config.projectRoot),projectFingerprint:e})):null}function Oe(n,e,t={}){let i=O(),r=new Map,a=0,o=0,f=0,m=0,S=0,d=0,l=0,u=0,p=0;return P("semantic.references.provider-loop",()=>{let b=se(n,e),R=ie(n,e),_=new Map,D=t.prefetchCallees?new Map:null,w=[];for(let c of e){let y,h=()=>(y??=E(n,c.relativePath),y);if(D){let I=h();if(I?.referencesAndCalleesForDefinitions){let T=D.get(I);T?T.push(c):D.set(I,[c]),p+=1}}let g=b.get(c.symbolId);if(g){f+=1,m+=g.length,A(r,c.symbolId,g,i,I=>{l+=1,u+=I});continue}let v=R.get(c.symbolId);if(v){S+=1,d+=v.length,A(r,c.symbolId,v,i,I=>{l+=1,u+=I});continue}let s=h();if(!s){i&&(o+=1);continue}if(i&&(a+=1),s.referencesForDefinitions){let I=_.get(s);I?I.push(c):_.set(s,[c])}else w.push({provider:s,definition:c})}let M=new Set;if(D)for(let[c,y]of D){if(!c.referencesAndCalleesForDefinitions)continue;let h=_.get(c)??[],g=c.referencesAndCalleesForDefinitions(h,y);M.add(c),Te(n,g.callees);for(let v of h){if(!g.references.has(v.symbolId))continue;let s=g.references.get(v.symbolId)??[];A(r,v.symbolId,s,i,I=>{l+=1,u+=I})}}for(let[c,y]of _){if(M.has(c))continue;let h=c.referencesForDefinitions(y);for(let g of y){if(!h.has(g.symbolId))continue;let v=h.get(g.symbolId)??[];A(r,g.symbolId,v,i,s=>{l+=1,u+=s})}}for(let{provider:c,definition:y}of w){let h=c.referencesFor(y);A(r,y.symbolId,h,i,g=>{l+=1,u+=g})}return r},()=>({definitions:e.length,providerHits:a,providerMisses:o,rustDefaultFastPathRows:f,rustDefaultFastPathReferences:m,rustScipOccurrenceFastPathRows:S,rustScipOccurrenceFastPathReferences:d,prefetchCalleeDefinitions:p,definitionsWithReferences:l,referenceCount:u,rows:r.size}))}function A(n,e,t,i,r){n.set(e,t),i&&t.length>0&&r(t.length)}function K(n,e,t,i){let r=0;for(let a of i){if(a.file===t.relativePath||n.isIgnored(a.file))continue;let o=e.get(t.symbolId);o||(o=new Set,e.set(t.symbolId,o));let f=o.size;o.add(a.file),o.size!==f&&(r+=1)}return r}function Ne(n){try{return JSON.parse(n)}catch{return null}}function Sn(n,e){return k(n).calleeMap(e)}function He(n,e){let t=O(),i=new Map,r=0,a=0,o=0,f=0;return P("semantic.callees.provider-loop",()=>{let m=new Map,S=[];for(let d of e){let l=E(n,d.relativePath);if(!l){t&&(a+=1);continue}t&&(r+=1);let u=d;if(l.calleesForDefinitions){let p=m.get(l);p?p.push(u):m.set(l,[u])}else S.push({provider:l,definition:u})}for(let[d,l]of m){let u=d.calleesForDefinitions(l);for(let p of l){let b=u.get(p.symbolId)??[];pe(i,p.symbolId,b,t,R=>{o+=1,f+=R})}}for(let{provider:d,definition:l}of S){let u=d.calleesFor(l);pe(i,l.symbolId,u,t,p=>{o+=1,f+=p})}return i},()=>({definitions:e.length,providerHits:r,providerMisses:a,definitionsWithCallees:o,calleeCount:f,rows:i.size}))}function pe(n,e,t,i,r){t.length>0&&(n.set(e,t),i&&r(t.length))}function hn(n,e){return k(n).signature(e)}function Ue(n,e){if(x(e.relativePath)==="typescript"){let o="fallback",f=0,m=0,S=0,d=0;return P("typescript.signature.materialize",()=>{let l=G(n,e.relativePath,we);if(l?.key){f=1;let p=me.read(n,e.relativePath,l.key)??{};if(Object.prototype.hasOwnProperty.call(p,e.symbol))return o="hit",m=1,p[e.symbol]??null;S=1;let b=E(n,e.relativePath);if(!b)return o="unavailable",null;let R=b.signatureFor(e);return me.write(n,e.relativePath,l.key,{...p,[e.symbol]:R}),o="computed",R}d=1;let u=E(n,e.relativePath);return u?(o="direct-fallback",u.signatureFor(e)):(o="unavailable",null)},()=>({state:o,eligible:f,cacheHits:m,cacheMisses:S,fallbacks:d}))}let t=Se(n,"semantic-signatures",e.relativePath),i=ze(e);if(t){let o=ue.read(n,i,t);if(o)return o.signature}let r=E(n,e.relativePath);if(!r)return null;let a=r.signatureFor(e);return t&&ue.write(n,i,t,{signature:a}),a}function Se(n,e,t){let i=z(n);if(!i)return null;let r=x(t);return r!=="rust"?null:U(JSON.stringify({kind:e,language:r,engine:$(n.config.projectRoot),projectFingerprint:i}))}function ze(n){return`${n.relativePath}\0${n.symbol}`}function he(n){try{let e=JSON.parse(n);return Array.isArray(e)?e:null}catch{return null}}function Le(n){try{let e=JSON.parse(n);if(!e||typeof e!="object")return null;let t=e.signature;return t!==null&&typeof t!="string"?null:{signature:t}}catch{return null}}function je(n){try{let e=JSON.parse(n);if(!e||typeof e!="object"||Array.isArray(e))return null;for(let t of Object.values(e))if(t!==null&&typeof t!="string")return null;return e}catch{return null}}function ye(n,e,t){let i=x(t);if(!i)return{slot:e,language:"typescript",available:!1,reason:"semantic evidence is only available for TypeScript or Rust files"};try{return{slot:e,language:i,...B(n,t).availability()}}catch(r){return{slot:e,language:i,available:!1,reason:r instanceof Error?r.message:String(r)}}}function E(n,e){if(!x(e))return null;let t=B(n,e);return t.availability().available?t:null}export{Je as a,$e as b,Be as c,ae as d,ce as e,k as f,fn as g,mn as h,pn as i,dn as j,gn as k,Sn as l,hn as m};
29
+ //# sourceMappingURL=chunk-DA34GNNO.js.map
@@ -0,0 +1,7 @@
1
+ import{b as k}from"./chunk-JQ2PCFZW.js";import{a as D}from"./chunk-3I34FZ6R.js";import{f as v,g as L}from"./chunk-NLRWGGPY.js";import{l as S}from"./chunk-2Y7YX54K.js";import{d as h,s as y}from"./chunk-OO6S4ECV.js";function z(e,n={}){let{scope:s,minLoc:c=1,maxDepth:a=5,scanLimit:f}=n,t=new D(e),i=_(e,s,c,f),o=new P;for(let r of i)o.add(r);let m=[],I=[];i.length>0&&m.push(C(e,0,i,o));let b=i.map(r=>r.definition).filter(r=>r!==null),x=new Set(i.map(r=>r.symbol));for(let r=1;r<=a&&b.length>0;r++){let u=t.calleeMap(b,{semantic:!1}),E=new Set;for(let d of b)for(let l of u.get(d.symbolId)??[])x.has(l.symbol)||E.add(l.symbol);let p=[];for(let d of E){x.add(d);let l=F(e,d);if(!l||e.isIgnored(l.relativePath)||v(e,l.relativePath)||L(e,l.symbol,l.relativePath)||t.fileKind(l.relativePath)==="test"||t.hasSuppressionComment(l))continue;let g=B(e,l,o);g.removable?p.push(w(l,"cascade")):g.blockingFiles.length>0&&I.push({shortName:h(l.symbol),file:l.relativePath,blockingFiles:g.blockingFiles.slice(0,3)})}if(p.length===0)break;for(let d of p)o.add(d);m.push(C(e,r,p,o)),b=p.map(d=>d.definition).filter(d=>d!==null)}let N=m.reduce((r,u)=>r+u.loc,0),R=m.reduce((r,u)=>r+u.entries.length,0);return{batches:m,totalSymbols:R,totalLoc:N,blocked:I}}function _(e,n,s,c){let a=k(e,{scope:n,minLoc:s,skipBarrels:!0,deadCodeOnly:!0,scanLimit:c,semantic:!1}),f=[];for(let t of a.symbols)t.kind==="dead-code"&&(v(e,t.relativePath)||L(e,t.symbol,t.relativePath)||f.push({symbol:t.symbol,shortName:t.shortName,file:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:t.loc,evidence:"graph-fact",definition:F(e,t.symbol)}));return f}function w(e,n){return{symbol:e.symbol,shortName:h(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:e.endLine-e.startLine+1,evidence:n,definition:e}}function F(e,n){let s=e.get(`SELECT d.relative_path
2
+ FROM global_symbols gs
3
+ JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
4
+ JOIN documents d ON d.id = der.document_id
5
+ WHERE gs.symbol = ?
6
+ LIMIT 1`,n);return s?y(e,s.relative_path).find(c=>c.symbol===n)??null:null}function B(e,n,s){let c=S(e,n);if(c.length===0)return{removable:!1,blockingFiles:[]};let a=new Set;for(let f of c)f.file===n.relativePath&&f.line>=n.startLine&&f.line<=n.endLine||s.contains(f.file,f.line)||a.add(f.file);return{removable:a.size===0,blockingFiles:[...a]}}function C(e,n,s,c){let a=[...s].sort((i,o)=>i.file.localeCompare(o.file)||i.startLine-o.startLine),f=new Set(a.map(i=>i.file)),t=[];for(let i of f){let o=y(e,i);o.length>0&&o.every(m=>c.contains(i,m.startLine))&&t.push(i)}return{depth:n,entries:a.map(({definition:i,...o})=>o),loc:a.reduce((i,o)=>i+o.loc,0),filesEmptied:t.sort()}}var P=class{ranges=new Map;add(n){let s=this.ranges.get(n.file)??[];s.push({start:n.startLine,end:n.endLine}),this.ranges.set(n.file,s)}contains(n,s){let c=this.ranges.get(n);return c?c.some(a=>s>=a.start&&s<=a.end):!1}};export{z as a,P as b};
7
+ //# sourceMappingURL=chunk-DKK2H4D7.js.map
@@ -0,0 +1,5 @@
1
+ import{a as G}from"./chunk-P5XHIJHI.js";import{a as ye}from"./chunk-G4KQ7S74.js";import{a as be}from"./chunk-QVZSWLLZ.js";import{b as sn,e as $,f as Se,h as on,j as ie,s as B,t as he}from"./chunk-OO6S4ECV.js";import{a as Zt,f as ge,n as nn,p as rn}from"./chunk-NLVKD45E.js";import{B as en,E as tn,e as Jt,f as Yt,s as Ze}from"./chunk-MCNWCJYL.js";import{a as Y}from"./chunk-64MNV6AB.js";import{a as Ht,c as Vt,d as Kt,g as Xe,o as et,p as tt,q as W,r as Gt,s as C,u as me,v as Qt,x as Xt}from"./chunk-WFRZGMWJ.js";import{existsSync as an,readdirSync as Kr}from"fs";import{isAbsolute as Jr,join as nt,resolve as Yr}from"path";var Gr={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:t,pnpmWorkspaces:e,indexerBinary:n,projectPath:r})=>{let i=r?["index","--output",t,"--no-progress-bar",r]:["index","--infer-tsconfig","--output",t,"--no-progress-bar"];return e&&!r&&i.splice(1,0,"--pnpm-workspaces"),{binary:n,args:i}},markerFiles:["tsconfig.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:t,indexerBinary:e})=>({binary:e,args:["index","--infer-tsconfig","--output",t,"--no-progress-bar"]}),markerFiles:["package.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:t})=>({binary:"scip-java",args:["index","--output",t]}),markerFiles:["pom.xml","build.gradle"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:t})=>({binary:"scip-java",args:["index","--output",t]}),markerFiles:["build.sbt"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:t})=>({binary:"scip-java",args:["index","--output",t]}),markerFiles:["build.gradle.kts"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:"rust",indexerBinary:"rust-analyzer",checkCommand:"rust-analyzer --version",indexArgs:({outputPath:t})=>({binary:"rust-analyzer",args:["scip",".","--output",t]}),markerFiles:["Cargo.toml"],installMethods:[{label:"rustup",prerequisite:"rustup",binary:"rustup",args:["component","add","rust-analyzer"]}],installUrl:"https://github.com/rust-lang/rust-analyzer"},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:t,indexerBinary:e})=>({binary:e,args:["index","--output",t,"--project-name","project"]}),markerFiles:["pyproject.toml","setup.py"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","scip-python-plus"]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:t,outputPath:e,indexerBinary:n,configPath:r})=>{let i=["-root",t,"-output",e];return r&&i.push("-config",Jr(r)?r:Yr(t,r)),{binary:n,args:i}},markerFiles:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:t})=>({binary:t,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:["Gemfile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:t})=>({binary:"scip-go",args:["--output",t]}),markerFiles:["go.mod"],installMethods:[{label:"go install",prerequisite:"go",binary:"go",args:["install","github.com/sourcegraph/scip-go@latest"]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:t})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",t]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:t})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",t]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:t,outputPath:e})=>({binary:"scip-dotnet",args:["index",cn(t,[".sln",".csproj"])??t,"--output",e,"--working-directory",t]}),markerFiles:["*.csproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:t,outputPath:e})=>({binary:"scip-dotnet",args:["index",cn(t,[".sln",".vbproj"])??t,"--output",e,"--working-directory",t]}),markerFiles:["*.vbproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:t,outputPath:e})=>({binary:t,args:["--output",e]}),markerFiles:["pubspec.yaml"],installMethods:[{label:"dart pub",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({projectRoot:t,indexerBinary:e})=>{let n=nt(t,"vendor","bin","scip-php"),r=nt(t,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",an(r)?r:an(n)?n:e]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function ln(t){return Gr[t]}function cn(t,e){let n;try{n=Kr(t)}catch{return null}for(let r of e)for(let i of n)if(i.endsWith(r))return nt(t,i);return null}import{execFileSync as it}from"child_process";import{existsSync as rt,readFileSync as Qr}from"fs";import{createRequire as Xr}from"module";import{platform as Zr}from"os";import{dirname as un,join as Re}from"path";var ei=Xr(import.meta.url);function st(t){return[t.indexerBinary,...t.binaryAliases??[]]}function pn(t){let e=st(t);return e.length===1?e[0]:e.join(" or ")}function ve(t){for(let e of st(t))if(be(e))return e;return ni(t)}function Sa(t){return ve(t)!==null||ti(t)}function ti(t){return fn(t)!==null}function ni(t){let e=fn(t);if(!e)return null;let r=JSON.parse(Qr(e,"utf8")).bin;if(!r)return null;if(typeof r=="string")return Re(un(e),r);for(let i of st(t)){let s=r[i];if(s)return Re(un(e),s)}return null}function fn(t){if(!t.bundledNpmPackage)return null;try{return ei.resolve(`${t.bundledNpmPackage}/package.json`)}catch{return null}}function ri(t,e){for(let n of t.projectLocalBinaries??[]){let r=Re(e,n);if(rt(r))return r}return null}function ii(t,e){return ri(t,e)??ve(t)}function ha(t,e=process.env,n=t.indexerBinary){if(t.indexerBinary!=="scip-dotnet"||ot(n,e))return e;let r=mn(n,e);return r?{...e,DOTNET_ROOT:r}:e}function dn(t,e){let n=pn(t),r=e?ii(t,e):ve(t);if(!r)return{language:t.language,binaryLabel:n,installed:!1,runnable:!1,resolvedBinary:null,installUrl:t.installUrl};if(t.indexerBinary!=="scip-dotnet")return{language:t.language,binaryLabel:n,installed:!0,runnable:!0,resolvedBinary:r};let i=si(r);return{language:t.language,binaryLabel:n,installed:!0,runnable:i.runnable,resolvedBinary:r,installUrl:t.installUrl,note:i.note}}function ba(t,e){let n=t.installMethods,r=pn(t);if(!n?.length)return e(`No auto-install method available for ${r}.`),t.installUrl&&e(`Install manually from: ${t.installUrl}`),!1;for(let i of n)if(be(i.prerequisite)){e(`Installing ${r} via ${i.label}...`);try{it(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env});let s=ve(t);if(s){let o=s===t.indexerBinary?"":` (using ${s})`;return e(`Successfully installed ${r} via ${i.label}${o}`),!0}e(`${i.label} command completed but ${r} was not found on PATH`)}catch(s){let o=s instanceof Error?s.message:String(s);e(`${i.label} install failed: ${o}`)}}return e(`Could not auto-install ${r}.`),t.installUrl&&e(`Install manually from: ${t.installUrl}`),!1}function si(t){if(ot(t,process.env))return{runnable:!0};let e=mn(t,process.env);if(e)return{runnable:!0,note:`using .NET 9 runtime from ${e}`};let n=gn(process.env);return{runnable:!1,note:n.length>0?`.NET 9 runtime still unavailable after checking ${n.join(", ")}`:"binary is present, but scip-dotnet still needs a .NET 9 runtime"}}function mn(t,e){for(let n of gn(e))if(ot(t,{...e,DOTNET_ROOT:n}))return n;return null}function gn(t){let e=[],n=t.DOTNET_ROOT;if(n&&rt(n)&&e.push(n),Zr()==="darwin"&&be("brew"))try{let r=it("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:t}).toString().trim(),i=Re(r,"libexec");rt(i)&&!e.includes(i)&&e.push(i)}catch{}return e}function ot(t,e){try{return it(t,["--version"],{stdio:"pipe",env:e}),!0}catch{return!1}}function Q(t){try{return process.kill(t,0),!0}catch(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EPERM"}}import{mkdirSync as oi,renameSync as ai,writeFileSync as ci}from"fs";import{dirname as li}from"path";function Ie(t,e,n={}){oi(li(t),{recursive:!0});let r=`${t}.${process.pid}.${Date.now()}.tmp`,i=JSON.stringify(e,null,n.spacing);ci(r,n.trailingNewline?`${i}
2
+ `:i),ai(r,t)}import{execFileSync as ui}from"child_process";import{createHash as yn}from"crypto";import{lstatSync as pi,readdirSync as fi,readFileSync as di,readlinkSync as mi,realpathSync as Sn}from"fs";import{isAbsolute as gi,join as hn,relative as yi,sep as Si}from"path";function xe(t,e){let n=t.split("/").at(-1)??t;if(vn.has(n)||n===".scipquery.json"||/^tsconfig(?:\..+)?\.json$/.test(n))return"config";if(/\.d\.(?:ts|mts|cts)$/.test(t.toLowerCase()))return"ambient";let r=t.includes(".")?`.${t.split(".").at(-1).toLowerCase()}`:"";return e.some(i=>(In[i]??[]).includes(r))?"source":"other"}function wa(t){return[...new Set((t??[]).map(e=>e.trim()).filter(Boolean))].sort((e,n)=>e.localeCompare(n))}function hi(t){return(Ri(t)??vi(t)).filter(e=>e&&!Rn(e)).sort()}function bn(t,e={}){let n=hi(t).filter(i=>!e.language||bi(i,e.language,e.markerFiles)).filter(i=>!e.includePath||e.includePath(i)),r=Sn(t);return n.map(i=>{let s=hn(t,i);try{if(pi(s).isSymbolicLink()){let a=Sn(s),c=yi(r,a);if(c===".."||c.startsWith(`..${Si}`)||gi(c))throw new Error("external symlink");let l=mi(s);return{path:i,size:Buffer.byteLength(l),hash:yn("sha256").update("symlink\0").update(l).digest("hex")}}let o=di(s);return{path:i,size:o.byteLength,hash:yn("sha256").update(o).digest("hex")}}catch{return{path:i,size:-1,hash:"unreadable"}}})}function bi(t,e,n){let r=t.split("/").at(-1)??t;if(n?.includes(t)||n?.includes(r)||vn.has(r))return!0;let i=t.includes(".")?`.${t.split(".").at(-1).toLowerCase()}`:"";return(In[e]??[]).includes(i)}function Ri(t){try{return ui("git",["-C",t,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"]}).split(`
3
+ `).filter(Boolean)}catch{return null}}function vi(t){let e=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?hn(t,r):t,s;try{s=fi(i,{withFileTypes:!0})}catch{continue}for(let o of s){let a=r?`${r}/${o.name}`:o.name;if(o.isDirectory()){Rn(a)||n.push(a);continue}e.push(a)}}return e}function Rn(t){let e=t.split("/");return t==="meta.json"||e.some(n=>Ii.has(n))||t.endsWith(".db")||t.endsWith(".db-wal")||t.endsWith(".db-shm")||t.endsWith(".scip")}var Ii=new Set([".git","node_modules",".scipquery-cache",".scipquery-generations",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]),vn=new Set(["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lockb","tsconfig.json","tsconfig.base.json","pyproject.toml","setup.py","setup.cfg","Cargo.toml","Cargo.lock","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","build.sbt","compile_commands.json","CMakeLists.txt","Makefile","Gemfile","Gemfile.lock","composer.json","composer.lock","pubspec.yaml","pubspec.lock","deps.edn","project.clj","bb.edn","shadow-cljs.edn"]),In={typescript:[".ts",".tsx",".mts",".cts"],javascript:[".js",".jsx",".mjs",".cjs"],java:[".java"],scala:[".scala"],kotlin:[".kt",".kts"],rust:[".rs"],python:[".py",".pyi"],ruby:[".rb"],go:[".go"],cpp:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"],c:[".c",".h"],csharp:[".cs"],vb:[".vb"],dart:[".dart"],php:[".php"],clojure:[".clj",".cljs",".cljc"]};function kn(t){return!et(t)||typeof t.version!="number"||tt(t.languages)===null||typeof t.pnpmWorkspaces!="boolean"||typeof t.typescriptProjectMode!="string"||tt(t.typescriptProjects)===null||t.clojureConfigPath!==void 0&&typeof t.clojureConfigPath!="string"||!Array.isArray(t.files)||!t.files.every(xi)?null:t}function Aa(t,e){let n=new Map((t?.files??[]).map(a=>[a.path,a])),r=new Map(e.files.map(a=>[a.path,a])),i=new Set([...n.keys(),...r.keys()]),s=[];for(let a of[...i].sort()){let c=n.get(a),l=r.get(a),p=xe(a,e.languages);!c&&l?s.push({kind:"added",path:a,inputKind:p,after:l}):c&&!l?s.push({kind:"deleted",path:a,inputKind:p,before:c}):c&&l&&(c.hash!==l.hash||c.size!==l.size)&&s.push({kind:"modified",path:a,inputKind:p,before:c,after:l})}let o=new Set;return t||o.add("prior-snapshot-unavailable"),t&&t.version!==e.version&&o.add("snapshot-version-changed"),(xn(t?.files??[])||xn(e.files))&&o.add("duplicate-input-path"),[...t?.files??[],...e.files].some(Mi)&&o.add("unreadable-input"),{version:1,changes:s,projectIdentityChanged:t?!Di(t,e):!0,uncertainty:[...o].sort()}}function xn(t){return new Set(t.map(e=>e.path)).size!==t.length}function xi(t){return et(t)&&typeof t.path=="string"&&typeof t.size=="number"&&typeof t.hash=="string"}function Mi(t){return t.hash==="unreadable"||t.size<0}function Ci(t){let e=new Set;for(let n of t.uncertainty)e.add(n);t.projectIdentityChanged&&e.add("project-identity-changed");for(let n of t.changes)n.kind==="added"&&e.add("file-added"),n.kind==="deleted"&&e.add("file-deleted"),n.inputKind==="config"&&e.add("configuration-changed"),n.inputKind==="ambient"&&e.add("ambient-declaration-changed"),n.inputKind==="other"&&e.add("unclassified-input");return{fullProject:e.size>0,reasons:[...e].sort()}}function Na(t,e,n){let r=t.changes.map(a=>a.path).sort();if(r.length===0&&!t.projectIdentityChanged&&t.uncertainty.length===0)return{mode:"none",changedFiles:r,affectedFiles:[],reasons:[]};let i=new Set(n),s=Ci(t),o=new Set(s.reasons);return r.some(a=>!i.has(a))&&o.add("changed-file-outside-project"),e===null?(o.add("dependency-graph-unavailable"),Mn(r,i,o)):o.size>0?Mn(r,i,o):{mode:"closure",changedFiles:r,affectedFiles:ki(r,e,i),reasons:[]}}function Mn(t,e,n){return{mode:"full-project",changedFiles:t,affectedFiles:[...e].sort(),reasons:[...n].sort()}}function ki(t,e,n){let r=new Map;for(let[o,a]of e)if(n.has(o))for(let c of a){if(!n.has(c))continue;let l=r.get(c)??new Set;l.add(o),r.set(c,l)}let i=new Set(t),s=[...t];for(let o=0;o<s.length;o+=1){let a=s[o];if(a!==void 0)for(let c of r.get(a)??[])i.has(c)||(i.add(c),s.push(c))}return[...i].sort()}function Di(t,e){return Cn(t.languages,e.languages)&&t.pnpmWorkspaces===e.pnpmWorkspaces&&t.typescriptProjectMode===e.typescriptProjectMode&&Cn(t.typescriptProjects,e.typescriptProjects)&&t.clojureConfigPath===e.clojureConfigPath}function Cn(t,e){if(t.length!==e.length)return!1;let n=[...t].sort(),r=[...e].sort();return n.every((i,s)=>i===r[s])}function Dn(t){let e=new Map,n=wi(t),r=new Map;return i=>{let s=Ti(i),o=r.get(s);if(o!==void 0)return o;if(!n.has(i.file))return r.set(s,i.symbol),i.symbol;let a=e.get(i.file);a||(a=Pi(B(t,i.file)),e.set(i.file,a));let c=Fi(a,i);return r.set(s,c),c}}function Ti(t){return`${t.file}\0${t.symbol}\0${t.line}`}function wi(t){return new Set(t.all("SELECT relative_path FROM documents").map(e=>e.relative_path))}function Pi(t){let e=new Map,n=new Map;for(let r of t){let i=e.get(r.leaf);i?i.push(r):e.set(r.leaf,[r]);let s=n.get(r.startLine);s?s.push(r):n.set(r.startLine,[r])}return{definitions:t,byLeaf:e,byStartLine:n}}function Fi(t,e){if(t.definitions.length===0)return e.symbol;let n=Ni(e.symbol),r=Ei(t.byLeaf,n),i=Ai(r,e.line);if(i)return i.symbol;let s=t.byStartLine.get(e.line)??[];return s.length===1?s[0].symbol:e.symbol}function Ei(t,e){let n=[],r=new Set;for(let i of e)for(let s of t.get(i)??[])r.has(s.symbolId)||(r.add(s.symbolId),n.push(s));return n}function Ai(t,e){let n=null;for(let r of t)if(!(r.startLine>e||r.endLine<e)){if(r.startLine===e)return r;(!n||r.endLine-r.startLine<n.endLine-n.startLine)&&(n=r)}return n}function Ni(t){let e=new Set([t]),r=t.split(/::|\.|#/).filter(Boolean).at(-1);return r&&e.add(r),e}function Tn(t,e){let r=rn(t,e).map(i=>ji(e,i));return{usage:r,positions:Li(t,e,r)}}function wn(t,e){return{importUsage(n){let r=t.importUsageFacts(n);if(!e||r.positions.length===0)return r.usage;let i=e.importDefinitionsForFile(n,r.positions);return i.available?_i(r.usage,i.sourcePaths):r.usage}}}function _i(t,e){return t.map((n,r)=>{let i=e.get(String(r));return i?{...n,sourcePath:i}:n})}function ji(t,e){let n=e.isTypeOnly===!0,r=e.kind==="side-effect"||n||e.used;return{importer:t,sourcePath:e.sourcePath,importedName:e.importedName,localName:e.localName,kind:e.kind,isTypeOnly:n,isUsed:r,isTypeUsed:n,isValueUsed:e.kind==="side-effect"||!n&&e.used,references:[]}}function Li(t,e,n){let r=tn(t,e);if(!r)return[];let i=Oi(r.rootNode),s=new Map;for(let a of i){let c=s.get(ct(a.importedName,a.localName));c?c.push(a.position):s.set(ct(a.importedName,a.localName),[a.position])}let o=[];return n.forEach((a,c)=>{let l=s.get(ct(a.importedName,a.localName??a.importedName))?.shift();l&&o.push({...l,id:String(c),file:e})}),o}function Oi(t){let e=[];for(let n of t.descendantsOfType("use_declaration")){let r=n.namedChildren.find(i=>i.type!=="visibility_modifier");r&&e.push(...Me(r,""))}return e.filter(n=>n.importedName!=="*")}function Me(t,e){switch(t.type){case"identifier":case"super":case"self":case"crate":return[{importedName:t.text,localName:t.text,position:at(t,t.text)}];case"scoped_identifier":{let n=t.text.split("::").pop()??t.text;return[{importedName:n,localName:n,position:at(t,n)}]}case"scoped_use_list":{let n=t.namedChild(0),r=t.namedChild(1);if(!n||!r)return[];let i=nn(e,n.text);return r.namedChildren.flatMap(s=>Me(s,i))}case"use_list":return t.namedChildren.flatMap(n=>Me(n,e));case"use_as_clause":{let n=t.namedChild(0),r=t.namedChild(1);return!n||!r?[]:Me(n,e).map(i=>({...i,localName:r.text}))}case"use_wildcard":{let n=t.namedChild(0),r="*";return[{importedName:r,localName:r,position:at(n??t,r)}]}default:return[]}}function at(t,e){let n=Math.max(0,t.text.lastIndexOf(e));return{id:"",file:"",line:t.startPosition.row,column:t.startPosition.column+n+Ui(e)}}function Ui(t){return Math.max(0,Math.min(t.length-1,1))}function ct(t,e){return`${t}\0${e}`}import{spawnSync as St}from"child_process";import{existsSync as ht}from"fs";import{fileURLToPath as ws}from"url";function Ce(t){let e=dn(ln("rust"),t),n=e.runnable;return{available:n,dependencyAvailable:n,resolvedBinary:e.resolvedBinary??void 0,reason:n?"rust-analyzer semantic reference queries are enabled.":"rust-analyzer is not runnable; Rust semantic checks will use SCIP/source evidence only."}}import{existsSync as fs,mkdtempSync as Yn,readFileSync as Gn,rmSync as ft}from"fs";import{tmpdir as Qn}from"os";import{join as dt}from"path";import{fileURLToPath as Ne,pathToFileURL as ds}from"url";import{SHARE_ENV as ms,Worker as gs}from"worker_threads";function q(t,e,n=new Set){let r=new Map;for(let i of t)n.has(i.symbolId)||r.set(i.symbolId,e.get(i.symbolId)??[]);return r}function z(t,e,n){let r=G(process.env.SCIP_RUST_SEMANTIC_BATCH_TIMEOUT_MS)??0;if(r>0)return r;let i=Math.max(1,Math.ceil(t/Math.max(1,n)));return Math.max(12e4,3e4+i*e)}import{spawn as Zi}from"child_process";import{createHash as es,randomUUID as ts}from"crypto";import{existsSync as Bn,mkdirSync as jn,readFileSync as Fe,realpathSync as ns,rmSync as pt}from"fs";import{tmpdir as rs}from"os";import{resolve as N}from"path";import{execFileSync as Ji}from"child_process";import{existsSync as Wi,readFileSync as Bi}from"fs";import{deserializeSCIP as qi,SymbolRole as $i}from"@c4312/scip";import{existsSync as Ja,readFileSync as Ya}from"fs";import{relative as Qa,resolve as Xa,sep as Za}from"path";import{fileURLToPath as tc,pathToFileURL as nc}from"url";function Pn(t){let e=new Map;for(let n of t)e.set(`${n.file}\0${n.line}\0${n.column}`,n);return[...e.values()].sort((n,r)=>{let i=n.file.localeCompare(r.file);return i!==0?i:n.line!==r.line?n.line-r.line:n.column-r.column})}var lt=new WeakMap,zi="SCIP_RUST_SCIP_OCCURRENCE_REFERENCE_MODE";function cc(t,e){let n=new Map,r=ke(),i=e.filter(o=>En(o,r));if(i.length===0)return n;let s=An(t);if(!s)return n;for(let o of i){let a=Fn(s,o);a!==null&&n.set(o.symbolId,a)}return n}function lc(t,e){if(!En(e,ke()))return null;let n=An(t);return n?Fn(n,e):null}function Fn(t,e){return t.referencesBySymbol.get(e.symbol)??[]}function En(t,e="safe"){if(!t.symbol.startsWith("rust-analyzer ")||!t.relativePath.endsWith(".rs")||ie(t.symbol)||/impl#\[[^\]]+\]\[Default\]default\(\)\.$/.test(t.symbol))return!1;if(e==="all")return!0;let n=Se(t.symbol);if(n==="method")return!0;if(n!=="term")return!1;let r=sn(t.symbol);return"kind"in r?!1:!Hi(r)}function Hi(t){for(let e=0;e<t.descriptors.length-1;e+=1)if(t.descriptors[e]?.suffix==="type")return!0;return!1}function An(t){if(lt.has(t))return lt.get(t)??null;let e=Vi(t);return lt.set(t,e),e}function Vi(t){if(!Wi(t.config.indexPath))return null;try{let e=qi(Bi(t.config.indexPath)),n=new Map;for(let r of e.documents??[]){let i=r.relativePath;if(!(!i||t.isIgnored(i)))for(let s of r.occurrences??[]){if(!s.symbol||(s.symbolRoles&$i.Definition)!==0)continue;let o=Ki(i,s.range);if(!o)continue;let a=n.get(s.symbol)??[];a.push(o),n.set(s.symbol,a)}}for(let[r,i]of n)n.set(r,Pn(i));return{referencesBySymbol:n}}catch{return null}}function Ki(t,e){if(e.length<3)return null;let n=e[0],r=e[1];return!Number.isInteger(n)||!Number.isInteger(r)?null:{file:t,line:n,column:r}}function ke(){return process.env[zi]==="all"?"all":"safe"}var Nn=new Map;function ut(t){let n=Ce(t).resolvedBinary??null;return{engine:"rust-analyzer",resolvedBinary:n,version:n?Yi(t,n):"unavailable"}}function mc(t){return{...ut(t),scipOccurrenceReferenceMode:ke()}}function Yi(t,e){let n=`${t}\0${e}`,r=Nn.get(n);if(r)return r;let i;try{i=Ji(e,["--version"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3}).trim()}catch{i="unknown"}return Nn.set(n,i),i}import{createHash as Gi}from"crypto";var Qi=new Set(["Cargo.lock","Cargo.toml","rust-project.json","rust-toolchain","rust-toolchain.toml"]);function _n(t){let e=bn(t,{includePath:Xi});return Gi("sha256").update(JSON.stringify(e)).digest("hex")}function Xi(t){let e=t.replaceAll("\\","/"),n=e.split("/").at(-1)??e;return e.endsWith(".rs")||Qi.has(n)?!0:e===".cargo/config"||e===".cargo/config.toml"||e.endsWith("/.cargo/config")||e.endsWith("/.cargo/config.toml")}var qn=2,is=5e3,ss=5e3,$n=10,os=3e4;function Ln(t,e,n,r=Jn){let i=r.engineIdentity(t),s={protocolVersion:qn,projectRoot:r.canonicalProjectRoot(t),projectFingerprint:r.projectFingerprint(t),engine:{engine:i.engine,resolvedBinary:i.resolvedBinary,version:i.version},workerFingerprint:r.fileFingerprint(e),environment:Hn(r.environment())};return{key:Pe(we(s)),...s}}function De(t,e,n){return t.protocolVersion===qn&&(e-t.heartbeatAtMs<=is||t.busyUntilMs!==void 0&&e<=t.busyUntilMs)&&n(t.pid)}function zn(t,e,n){let r;try{r=Pe(Fe(e))}catch{r="missing"}let i=Pe(we({projectRoot:N(t),serverPath:N(e),serverFingerprint:r})).slice(0,20);return N(n,`scip-query-rust-session-${i}`)}function On(t){let e=t===void 0?Number.NaN:Number(t);return Number.isInteger(e)&&e>=0?e:0}function Hn(t){return Object.fromEntries(Object.entries(t).filter(([e])=>Kn(e)).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>[e,n??null]))}function Vn(t,e){let n=e.runtime??ps,r=e.identityRuntime??Jn,i=zn(t,e.serverPath,e.tempRoot??rs()),s=!1,o=(a,c)=>{if(s)throw new Error("Durable Rust semantic session was already disposed.");return cs(i,e.serverPath,e.semanticWorkerPath,a,c,n)};return{requestSemantic(a,c){let l=Ln(t,e.semanticWorkerPath,a,r),p=n.now()+Math.max(1,c-1e3);return o({kind:"semantic",identityKey:l.key,workerEnvironment:Wn(),request:{...a,readinessDeadlineMs:p,referenceRetryTimeoutMs:as(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,a.referenceRetryTimeoutMs),settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:On(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},requestImportDefinitions(a,c){let l=Ln(t,e.semanticWorkerPath,a,r),p=n.now()+Math.max(1,c-1e3);return o({kind:"import-definitions",identityKey:l.key,workerEnvironment:Wn(),request:{...a,readinessDeadlineMs:p,settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:On(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},shutdown(){s=!0}}}function as(t,e){return e!==void 0?e:t===void 0?os:void 0}function cs(t,e,n,r,i,s){let o=s.randomId(),a=s.now(),c=N(t,"requests"),l=N(t,"responses"),p=N(c,`${o}.json`),u=N(l,`${o}.json`);jn(c,{recursive:!0}),jn(l,{recursive:!0}),Ie(p,{id:o,request:r});let f=s.now()+i;try{for(Un(t,e,n,f,s);s.now()<=f;){if(Bn(u)){let m=ls(Fe(u,"utf8"));if(!m.ok)throw new Error(m.error);return W()&&me({type:"span",name:"rust.semantic.durable-session.request",durationMs:s.now()-a,ok:!0,session:m.session,kind:r.kind}),m.response}let d=Te(t);(!d||!De(d,s.now(),s.isProcessAlive))&&Un(t,e,n,f,s),s.sleep($n)}throw new Error(`Durable Rust semantic session timed out after ${(i/1e3).toFixed(0)}s.`)}finally{pt(p,{force:!0}),pt(u,{force:!0})}}function Un(t,e,n,r,i){let s=Te(t);if(s&&De(s,i.now(),i.isProcessAlive))return;pt(N(t,"server.json"),{force:!0}),i.spawnServer(e,t,n);let o=Math.min(r,i.now()+ss);for(;i.now()<=o;){let a=Te(t);if(a&&De(a,i.now(),i.isProcessAlive))return;i.sleep($n)}throw new Error("Durable Rust semantic session helper did not become ready within 5s.")}function Te(t){try{let e=JSON.parse(Fe(N(t,"server.json"),"utf8"));return typeof e.protocolVersion!="number"||typeof e.pid!="number"||typeof e.heartbeatAtMs!="number"||e.busyUntilMs!==void 0&&typeof e.busyUntilMs!="number"?null:{protocolVersion:e.protocolVersion,pid:e.pid,heartbeatAtMs:e.heartbeatAtMs,...e.busyUntilMs===void 0?{}:{busyUntilMs:e.busyUntilMs}}}catch{return null}}function ls(t){try{let e=JSON.parse(t);return e.ok===!0&&(e.session==="created"||e.session==="reused"||e.session==="invalidated")&&e.response&&typeof e.response=="object"?{ok:!0,session:e.session,response:e.response}:{ok:!1,error:typeof e.error=="string"?e.error:"helper wrote an invalid response"}}catch(e){return{ok:!1,error:`helper wrote malformed JSON: ${e instanceof Error?e.message:String(e)}`}}}function Wn(){return Object.fromEntries(Object.entries(process.env).filter(([t])=>us(t)).sort(([t],[e])=>t.localeCompare(e)).map(([t,e])=>[t,e??null]))}function Kn(t){return t==="HOME"||t==="PATH"||t.startsWith("CARGO_")||t.startsWith("RA_")||t.startsWith("RUST")}function us(t){return Kn(t)||t.startsWith("SCIP_RUST_")||t==="SCIP_QUERY_PROFILE"||t==="SCIP_QUERY_PROFILE_CACHE_STATE"||t==="SCIP_QUERY_PROFILE_COMMAND"||t==="SCIP_QUERY_PROFILE_OUT"||t==="SCIP_QUERY_PROFILE_RUN_ID"||t==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY"||t==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND"||t==="SCIP_QUERY_PROFILE_MIN_MS"}var Jn={canonicalProjectRoot(t){try{return ns(t)}catch{return N(t)}},projectFingerprint(t){return _n(t)},engineIdentity:ut,fileFingerprint(t){return Pe(Fe(t))},environment(){return Hn(process.env)}},ps={now:Date.now,randomId:ts,isProcessAlive:Q,spawnServer(t,e,n){if(!Bn(t))throw new Error(`Durable Rust semantic session helper was not found at ${t}. Run npm run build first.`);Zi(process.execPath,[t,e,n],{detached:!0,stdio:"ignore"}).unref()},sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)}};function we(t){return Array.isArray(t)?`[${t.map(we).join(",")}]`:t&&typeof t=="object"?`{${Object.entries(t).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>`${JSON.stringify(e)}:${we(n)}`).join(",")}}`:JSON.stringify(t)}function Pe(t){return es("sha256").update(t).digest("hex")}var Xn=15e3,Zn=8,tr=5e3,ys=64,Ss=96,gt=class{constructor(e,n,r={}){this.projectRoot=e;this.status=n;this.opts=r;this.requester=r.requester??vs(e,process.env.SCIP_RUST_SEMANTIC_DURABLE_SESSION)}projectRoot;status;opts;requester;referencesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:n.reason,references:se(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!0});return{available:r.available,resolvedBinary:n.resolvedBinary,reason:r.reason,references:q(e,new Map(r.references),new Set(r.incompleteReferenceSymbolIds??[]))}}catch(r){return this.opts.fallbackReferenceResolver?.referencesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),references:se(e)}}}calleesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:n.reason,callees:oe(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!1,includeCallees:!0});return{available:r.available,resolvedBinary:n.resolvedBinary,reason:r.reason,callees:mt(e,new Map(r.callees??[]))}}catch(r){return this.opts.fallbackCalleeResolver?.calleesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),callees:oe(e)}}}referencesAndCalleesForDefinitions(e,n){let r=this.status(this.projectRoot);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,references:se(e),callees:oe(n)};let i=[...e,...n];try{let s=this.requestSession(r.resolvedBinary,i,{includeReferences:e.length>0,includeCallees:n.length>0,referenceDefinitions:e,calleeDefinitions:n});return{available:s.available,resolvedBinary:r.resolvedBinary,reason:s.reason,references:q(e,new Map(s.references),new Set(s.incompleteReferenceSymbolIds??[])),callees:mt(n,new Map(s.callees??[]))}}catch(s){return this.fallbackReferencesAndCallees(r,e,n,s)}}signaturesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:n.reason,signatures:er(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!1,includeCallees:!1,includeSignatures:!0});return{available:r.available,resolvedBinary:n.resolvedBinary,reason:r.reason,signatures:ks(e,new Map(r.signatures??[]))}}catch(r){return this.opts.fallbackSignatureResolver?.signaturesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),signatures:er(e)}}}importDefinitionsForFile(e,n){let r=this.status(this.projectRoot);if(n.length===0)return{available:r.available,resolvedBinary:r.resolvedBinary,reason:r.reason,sourcePaths:new Map};if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,sourcePaths:new Map(n.map(i=>[i.id,null]))};try{let i=this.requestImportDefinitions(r.resolvedBinary,e,n);return{available:i.available,resolvedBinary:r.resolvedBinary,reason:i.reason,sourcePaths:new Map(i.sourcePaths)}}catch(i){return{available:!1,resolvedBinary:r.resolvedBinary,reason:i instanceof Error?i.message:String(i),sourcePaths:new Map(n.map(s=>[s.id,null]))}}}dispose(){this.requester.shutdown()}requestSession(e,n,r){let i=Ee(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Xn),s=Ae(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),o=Ee(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Zn),a=Ae(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),c=r.referenceDefinitions?[...r.referenceDefinitions]:void 0,l=r.calleeDefinitions?[...r.calleeDefinitions]:void 0,p=r.signatureDefinitions?[...r.signatureDefinitions]:void 0,u=ae(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,...r}),f={projectRoot:this.projectRoot,rustAnalyzerBinary:e,definitions:[...n],...c?{referenceDefinitions:c}:{},...l?{calleeDefinitions:l}:{},...p?{signatureDefinitions:p}:{},requestTimeoutMs:i,...r.includeReferences!==!1&&s>0?{referenceRetryTimeoutMs:s}:{},diagnosticsTimeoutMs:a,settleDelayMs:u,concurrency:o,includeReferences:r.includeReferences,includeCallees:r.includeCallees,includeSignatures:r.includeSignatures},d=Ds(f);return C("rust.semantic.session.request",()=>this.requester.requestSemantic(f,z(d,yt(i,f.referenceRetryTimeoutMs),o)),()=>({definitions:n.length,operationDefinitions:d,referenceDefinitions:f.referenceDefinitions?.length,calleeDefinitions:f.calleeDefinitions?.length,signatureDefinitions:f.signatureDefinitions?.length,references:f.includeReferences!==!1,callees:f.includeCallees===!0,signatures:f.includeSignatures===!0,referenceRetryTimeoutMs:f.referenceRetryTimeoutMs}))}fallbackReferencesAndCallees(e,n,r,i){let s=n.length===0?{available:!0,references:se(n)}:this.opts.fallbackReferenceResolver?.referencesForDefinitions(n),o=r.length===0?{available:!0,callees:oe(r)}:this.opts.fallbackCalleeResolver?.calleesForDefinitions(r);return s&&o?{available:s.available&&o.available,resolvedBinary:s.resolvedBinary??o.resolvedBinary??e.resolvedBinary,reason:s.reason??o.reason,references:q(n,s.references),callees:mt(r,o.callees)}:{available:!1,resolvedBinary:e.resolvedBinary,reason:i instanceof Error?i.message:String(i),references:se(n),callees:oe(r)}}requestImportDefinitions(e,n,r){let i=Ee(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Xn),s=Ee(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Zn),o=Ae(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),a=Ae(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,tr),c={projectRoot:this.projectRoot,rustAnalyzerBinary:e,file:n,positions:[...r],requestTimeoutMs:i,diagnosticsTimeoutMs:o,settleDelayMs:a,concurrency:s};return C("rust.semantic.import-definitions.session.request",()=>this.requester.requestImportDefinitions(c,z(r.length,i,s)),()=>({file:n,positions:r.length}))}};function nr(t,e,n={}){return new gt(t,e,n)}function ae(t,e){let n=ir(t);if(n!==null)return n;let r=e.includeReferences!==!1;return r&&e.includeCallees!==!0&&e.includeSignatures!==!0&&e.definitionCount<=ys||r&&e.includeCallees===!0&&e.includeSignatures!==!0&&e.definitionCount<=Ss?0:tr}function hs(t){let e=t?.trim().toLowerCase(),n=e==="0"||e==="false"||e==="off"||e==="worker",r=e==="1"||e==="true"||e==="on"||e==="durable",i=e===void 0||e==="";return{transport:n||!i&&!r?"worker":"durable",source:i?"default":"environment",fallback:"worker",valid:i||n||r,optOut:"SCIP_RUST_SEMANTIC_DURABLE_SESSION=0"}}function bs(t){return hs(t).transport}function Rs(t,e){let n=null,r=!1,i=!1,s=!1,o=()=>n??=e(),a=()=>{i||(t.shutdown(),i=!0)},c=(p,u,f)=>{let d=Cs(p);r=!0;try{a()}catch{}W()&&me({type:"span",name:"rust.semantic.durable-session.request",durationMs:f,ok:!1,kind:u,session:"worker-fallback",reason:d})},l=(p,u,f)=>{if(s)throw new Error("Rust semantic failover session was already disposed.");if(r)return f(o());let d=Date.now();try{return u(t)}catch(m){c(m,p,Date.now()-d)}return f(o())};return{requestSemantic(p,u){return l("semantic",f=>f.requestSemantic(p,u),f=>f.requestSemantic(p,u))},requestImportDefinitions(p,u){return l("import-definitions",f=>f.requestImportDefinitions(p,u),f=>f.requestImportDefinitions(p,u))},shutdown(){if(s)return;s=!0;let p=[];try{a()}catch(u){p.push(u)}try{n?.shutdown()}catch(u){p.push(u)}if(p.length>0)throw p[0]}}}function vs(t,e,n={worker:()=>Is(),durable:()=>Vn(t,{serverPath:Ne(Ts()),semanticWorkerPath:Ne(rr())})}){return bs(e)==="durable"?Rs(n.durable(),n.worker):n.worker()}function Is(t={}){let e=null,n=null,r=1,i=!1,s=()=>{n&&(ft(n,{recursive:!0,force:!0}),n=null)},o=()=>{let l=e;e=null,l&&l.terminate(),s()},a=()=>{if(e)return e;let l=t.semanticWorkerPath?ds(t.semanticWorkerPath):rr();if(!fs(Ne(l)))throw new Error(`Rust semantic session worker was not found at ${Ne(l)}. Run npm run build before using built semantic Rust queries.`);return n=Yn(dt(Qn(),"scip-query-rust-session-")),e=new gs(l,t.shareEnvironment?{env:ms}:void 0),e.unref(),e},c=()=>{let l=n??Yn(dt(Qn(),"scip-query-rust-session-"));return n=l,dt(l,`${r++}.json`)};return{requestSemantic(l,p){if(i)throw new Error("Rust semantic session was already disposed.");let u=a(),f=c(),d=new SharedArrayBuffer(4),m=new Int32Array(d);if(u.postMessage({kind:"semantic",request:l,responsePath:f,sharedBuffer:d}),Atomics.wait(m,0,0,p)==="timed-out")throw o(),new Error(`Rust semantic session worker timed out after ${(p/1e3).toFixed(0)}s`);try{let g=xs(Gn(f,"utf8"));if(!g.ok)throw new Error(g.error);return g.response}finally{ft(f,{force:!0})}},requestImportDefinitions(l,p){if(i)throw new Error("Rust semantic session was already disposed.");let u=a(),f=c(),d=new SharedArrayBuffer(4),m=new Int32Array(d);if(u.postMessage({kind:"import-definitions",request:l,responsePath:f,sharedBuffer:d}),Atomics.wait(m,0,0,p)==="timed-out")throw o(),new Error(`Rust semantic import-definition session worker timed out after ${(p/1e3).toFixed(0)}s`);try{let g=Ms(Gn(f,"utf8"));if(!g.ok)throw new Error(g.error);return g.response}finally{ft(f,{force:!0})}},shutdown(){if(i)return;if(i=!0,!e){s();return}let l=c(),p=new SharedArrayBuffer(4),u=new Int32Array(p);e.postMessage({kind:"shutdown",responsePath:l,sharedBuffer:p}),Atomics.wait(u,0,0,5e3),o()}}}function xs(t){let e=JSON.parse(t);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let n=e;return n.ok===!0&&"response"in n?{ok:!0,response:n.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function Ms(t){let e=JSON.parse(t);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let n=e;return n.ok===!0&&"response"in n?{ok:!0,response:n.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function Cs(t){let e=t instanceof Error?`${t.name} ${t.message}`.toLowerCase():String(t).toLowerCase();return e.includes("readiness")?"readiness":e.includes("timeout")||e.includes("timed out")?"timeout":e.includes("helper")?"helper":"request"}function se(t){return new Map(t.map(e=>[e.symbolId,[]]))}function oe(t){return new Map(t.map(e=>[e.symbolId,[]]))}function er(t){return new Map(t.map(e=>[e.symbolId,null]))}function mt(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??[]]))}function ks(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??null]))}function Ds(t){let e=0;return t.includeReferences!==!1&&(e+=(t.referenceDefinitions??t.definitions).length),t.includeCallees===!0&&(e+=(t.calleeDefinitions??t.definitions).length),t.includeSignatures===!0&&(e+=(t.signatureDefinitions??t.definitions).length),Math.max(1,e)}function yt(t,e){return e&&e>0?Math.max(t,e):t}function rr(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}function Ts(){return new URL("./rust-semantic-session-server.js",import.meta.url)}function Ee(t,e){return G(t)??e}function Ae(t,e){return ir(t)??e}function ir(t){if(!t)return null;let e=Number(t);return Number.isInteger(e)&&e>=0?e:null}var bt=15e3,Rt=8;function cr(t,e={}){let n=e.status??Ce,r=Es(t,n),i=As(t,n),s=Ns(t,n),o=e.referenceResolver||e.calleeResolver||e.signatureResolver||!Ps(e)?null:nr(t,n,{fallbackReferenceResolver:r,fallbackCalleeResolver:i,fallbackSignatureResolver:s}),a=e.referenceResolver??o??r,c=e.calleeResolver??o??i,l=e.signatureResolver??o??s,p=e.importUsageResolver??wn(e.sourceImportUsageResolver??Fs(),e.importDefinitionResolver??o),u=e.calleeSymbolResolver,f=e.sourceZeroCalleeOracle,d=e.scipOccurrenceCalleeOracle,m=new Map,b=new Map,g=null,S=null,I=()=>(g??=n(t),g),j=()=>{let y=I();return y.dependencyAvailable?S??y:y},T=y=>{if(y.length===0)return new Map;let v=ce(y);try{let h=a.referencesForDefinitions(v),x=I();return S={...x,available:h.available,resolvedBinary:h.resolvedBinary??x.resolvedBinary,reason:h.reason??x.reason},h.available?new Map(h.references):q(v,h.references)}catch(h){return S={...I(),available:!1,reason:h instanceof Error?h.message:String(h)},H(v)}},L=y=>{if(y.length===0)return new Map;let v=ce(y),h=v.filter(sr);if(h.length===0)return V(v);let x=new Map,re=ar(h,d),A=[];for(let M of h)b.has(M.symbolId)?x.set(M.symbolId,b.get(M.symbolId)??[]):re.has(M.symbolId)?x.set(M.symbolId,re.get(M.symbolId)??[]):or(M,f)?x.set(M.symbolId,[]):A.push(M);if(A.length===0)return X(v,x,void 0);try{let M=c.calleesForDefinitions(A),U=I();S={...U,available:M.available,resolvedBinary:M.resolvedBinary??U.resolvedBinary,reason:M.reason??U.reason};let k=X(A,M.callees,u);for(let[J,Ye]of k)x.set(J,Ye);return X(v,x,void 0)}catch(M){return S={...I(),available:!1,reason:M instanceof Error?M.message:String(M)},V(v)}},O=(y,v)=>{let h=ce(y),x=ce(v),re=x.filter(sr),A=new Map,M=ar(re,d),U=[];for(let k of re)M.has(k.symbolId)?A.set(k.symbolId,M.get(k.symbolId)??[]):or(k,f)?A.set(k.symbolId,[]):U.push(k);if(h.length===0&&U.length===0)return{references:H(h),callees:X(x,A,void 0)};try{let k=o?o.referencesAndCalleesForDefinitions(h,U):Os(a,c,{referenceDefinitions:h,calleeDefinitions:U}),J=I();S={...J,available:k.available,resolvedBinary:k.resolvedBinary??J.resolvedBinary,reason:k.reason??J.reason};let Ye=k.available?new Map(k.references):q(h,k.references);for(let[Ge,Qe]of k.callees)A.set(Ge,Qe);let zt=X(x,A,u);for(let[Ge,Qe]of zt)b.set(Ge,Qe);return{references:Ye,callees:zt}}catch(k){return S={...I(),available:!1,reason:k instanceof Error?k.message:String(k)},{references:H(h),callees:V(x)}}},E=y=>{if(y.length===0)return new Map;let v=ce(y);try{let h=l.signaturesForDefinitions(v),x=I();return S={...x,available:h.available,resolvedBinary:h.resolvedBinary??x.resolvedBinary,reason:h.reason??x.reason},lr(v,h.signatures)}catch(h){return S={...I(),available:!1,reason:h instanceof Error?h.message:String(h)},_e(v)}};return{language:"rust",availability:j,dispose:()=>{o?.dispose()},importUsage:y=>{let v=m.get(y);if(v)return v;try{let h=p.importUsage(y);return m.set(y,h),h}catch(h){return S={...I(),available:!1,reason:h instanceof Error?h.message:String(h)},[]}},referencesFor:y=>T([y]).get(y.symbolId)??[],referencesForDefinitions:T,referencesAndCalleesForDefinitions:O,calleesFor:y=>L([y]).get(y.symbolId)??[],calleesForDefinitions:L,signatureFor:y=>E([y]).get(y.symbolId)??null}}function Ps(t){if(t.usePersistentSession!==void 0)return t.usePersistentSession;let e=process.env.SCIP_RUST_SEMANTIC_SESSION;return e!=="0"&&e!=="false"}function Fs(){return{importUsageFacts:()=>({usage:[],positions:[]})}}function ce(t){return t.map(e=>{let n=e;return{...e,leaf:typeof n.leaf=="string"?n.leaf:$(e.symbol),parentTypeName:n.parentTypeName??null,isFunctionLike:typeof n.isFunctionLike=="boolean"?n.isFunctionLike:on(e.symbol),isTypeLike:n.isTypeLike??!1,kind:n.kind??null,documentation:n.documentation??null,enclosingSymbol:n.enclosingSymbol??null}})}function sr(t){return t.isFunctionLike}function or(t,e){if(!e)return!1;try{return e(t)}catch{return!1}}function ar(t,e){if(!e||t.length===0)return new Map;try{return e(t)}catch{return new Map}}function Es(t,e){return{referencesForDefinitions:n=>_s(t,e,n)}}function As(t,e){return{calleesForDefinitions:n=>js(t,e,n)}}function Ns(t,e){return{signaturesForDefinitions:n=>Ls(t,e,n)}}function _s(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,references:H(n)};let i=vt();if(!ht(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,references:H(n)};let s=Z(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,bt),o=je(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),a=Z(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Rt),c=je(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),l=ae(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!0}),p={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,...o>0?{referenceRetryTimeoutMs:o}:{},diagnosticsTimeoutMs:c,settleDelayMs:l,concurrency:a},u=St(process.execPath,[i],{cwd:t,input:JSON.stringify(p),encoding:"utf8",maxBuffer:50*1024*1024,timeout:z(n.length,yt(s,p.referenceRetryTimeoutMs),a)}),f=It(u.stdout);if(f)return{available:f.available,resolvedBinary:r.resolvedBinary,reason:f.reason,references:q(n,new Map(f.references),new Set(f.incompleteReferenceSymbolIds??[]))};let d=u.error instanceof Error?u.error.message:u.stderr.trim()||`Rust semantic worker exited with status ${u.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:d,references:H(n)}}function js(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,callees:V(n)};let i=vt();if(!ht(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,callees:V(n)};let s=Z(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,bt),o=Z(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Rt),a=je(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),c=ae(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!1,includeCallees:!0}),l={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,diagnosticsTimeoutMs:a,settleDelayMs:c,concurrency:o,includeReferences:!1,includeCallees:!0},p=St(process.execPath,[i],{cwd:t,input:JSON.stringify(l),encoding:"utf8",maxBuffer:50*1024*1024,timeout:z(n.length,s,o)}),u=It(p.stdout);if(u)return{available:u.available,resolvedBinary:r.resolvedBinary,reason:u.reason,callees:X(n,new Map(u.callees??[]),void 0)};let f=p.error instanceof Error?p.error.message:p.stderr.trim()||`Rust semantic worker exited with status ${p.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:f,callees:V(n)}}function Ls(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,signatures:_e(n)};let i=vt();if(!ht(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,signatures:_e(n)};let s=Z(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,bt),o=Z(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Rt),a=je(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),c=ae(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!1,includeCallees:!1,includeSignatures:!0}),l={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,diagnosticsTimeoutMs:a,settleDelayMs:c,concurrency:o,includeReferences:!1,includeCallees:!1,includeSignatures:!0},p=St(process.execPath,[i],{cwd:t,input:JSON.stringify(l),encoding:"utf8",maxBuffer:50*1024*1024,timeout:z(n.length,s,o)}),u=It(p.stdout);if(u)return{available:u.available,resolvedBinary:r.resolvedBinary,reason:u.reason,signatures:lr(n,new Map(u.signatures??[]))};let f=p.error instanceof Error?p.error.message:p.stderr.trim()||`Rust semantic worker exited with status ${p.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:f,signatures:_e(n)}}function Os(t,e,n){let r=n.referenceDefinitions.length>0?t.referencesForDefinitions(n.referenceDefinitions):{available:!0,references:H(n.referenceDefinitions)},i=n.calleeDefinitions.length>0?e.calleesForDefinitions(n.calleeDefinitions):{available:!0,callees:V(n.calleeDefinitions)};return{available:r.available&&i.available,resolvedBinary:r.resolvedBinary??i.resolvedBinary,reason:r.reason??i.reason,references:r.references,callees:i.callees}}function H(t){return new Map(t.map(e=>[e.symbolId,[]]))}function V(t){return new Map(t.map(e=>[e.symbolId,[]]))}function _e(t){return new Map(t.map(e=>[e.symbolId,null]))}function X(t,e,n){let r=0,i=0;return C("rust.semantic.callees.complete-map",()=>{let s=new Map;for(let o of t){let a=e.get(o.symbolId)??[];a.length>0&&(r+=1),i+=a.length,s.set(o.symbolId,a.map(c=>({...c,symbol:n?n(c):c.symbol})))}return s},()=>({definitions:t.length,rows:r,callees:i,resolveSymbols:!!n}))}function lr(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??null]))}function vt(){return ws(new URL("./rust-semantic-worker.js",import.meta.url))}function It(t){try{let e=JSON.parse(t);if(!e||typeof e!="object")return null;let n=e;return typeof n.available!="boolean"||!Array.isArray(n.references)?null:{available:n.available,reason:typeof n.reason=="string"?n.reason:void 0,references:n.references,incompleteReferenceSymbolIds:Array.isArray(n.incompleteReferenceSymbolIds)?n.incompleteReferenceSymbolIds.filter(r=>typeof r=="number"):void 0,callees:Array.isArray(n.callees)?n.callees:void 0,signatures:Array.isArray(n.signatures)?n.signatures:void 0}}catch{return null}}function Z(t,e){return G(t)??e}function je(t,e){if(!t)return e;let n=Number(t);return Number.isInteger(n)&&n>=0?n:e}import{existsSync as Us,readFileSync as Ws}from"fs";import{deserializeSCIP as Bs,SymbolRole as qs}from"@c4312/scip";var xt=new WeakMap;function pr(t,e){let n=e.filter($s);if(n.length===0)return new Map;let r=!1,i=0,s=0;return C("rust.scip-occurrence.callees",()=>{let o=Vs(t);if(r=!!o,!o)return new Map;let a=new Map;for(let c of n){let l=zs(t,o,c);l!==null&&(a.set(c.symbolId,l),i+=1,s+=l.length)}return a},()=>({definitions:e.length,candidates:n.length,indexAvailable:r,resolvedDefinitions:i,resolvedCallees:s}))}function $s(t){return!(!t.symbol.startsWith("rust-analyzer ")||!t.relativePath.endsWith(".rs")||!t.isFunctionLike||t.leaf==="main"||ie(t.symbol))}function zs(t,e,n){let r=ge(t,n.relativePath);if(!r||r.language!=="rust")return null;let i=r.callables.find(l=>l.startLine!==n.startLine||l.endLine!==n.endLine?!1:l.name===n.leaf||n.leaf.endsWith(l.name)||l.name.endsWith(n.leaf));if(!i)return null;let s=r.callSites.filter(l=>l.line>=i.startLine&&l.line<=i.endLine);if(s.length===0)return null;let o=(e.occurrencesByFile.get(n.relativePath)??[]).filter(l=>l.line>=i.startLine&&l.line<=i.endLine&&l.callee.symbol!==n.symbol);if(o.some(l=>l.traitImplMember)||!Hs(s,o))return null;let a=[],c=new Set;for(let l of o){let p=`${l.callee.symbol}\0${l.callee.file}\0${l.callee.line}`;c.has(p)||(c.add(p),a.push(l.callee))}return a}function Hs(t,e){let n=ur(t),r=ur(e);if(n.size!==r.size)return!1;for(let[i,s]of n)if(r.get(i)!==s)return!1;return!0}function ur(t){let e=new Map;for(let n of t){let r=n.calleeLeaf??n.leaf;if(!r)continue;let i=`${n.line}\0${r}`;e.set(i,(e.get(i)??0)+1)}return e}function Vs(t){if(xt.has(t))return xt.get(t)??null;let e=Ks(t);return xt.set(t,e),e}function Ks(t){if(!Us(t.config.indexPath))return null;try{let e=he(t).filter(s=>s.symbol.startsWith("rust-analyzer ")&&s.relativePath.endsWith(".rs")&&s.isFunctionLike),n=new Map(e.map(s=>[s.symbol,s])),r=Bs(Ws(t.config.indexPath)),i=new Map;for(let s of r.documents??[]){let o=s.relativePath;if(!o||!o.endsWith(".rs")||t.isIgnored(o))continue;let a=[];for(let c of s.occurrences??[]){if(!c.symbol||(c.symbolRoles&qs.Definition)!==0)continue;let l=n.get(c.symbol);if(!l)continue;let p=c.range?.[0];Number.isInteger(p)&&a.push({line:p,leaf:l.leaf,traitImplMember:ie(l.symbol),callee:{symbol:l.symbol,file:l.relativePath,line:l.startLine}})}i.set(o,a)}return{occurrencesByFile:i}}catch{return null}}var Le=class{sessions=new WeakMap;getOrCreate(e,n,r){let i=Js(e,n),s=this.sessions.get(e);s||(s=new Map,this.sessions.set(e,s));let o=s.get(i);if(o)return o.hits+=1,o.lastUsedAtMs=Date.now(),o.provider;let a=Date.now(),c=r();return s.set(i,{key:i,language:n,projectRoot:e.config.projectRoot,provider:c,createdAtMs:a,lastUsedAtMs:a,hits:1}),c}sessionsFor(e){return[...this.sessions.get(e)?.values()??[]]}clear(e){let n=this.sessions.get(e);if(n)for(let r of n.values())r.provider.dispose?.();this.sessions.delete(e)}};function Js(t,e){return`${t.config.projectRoot}:${e}-workspace`}import{randomUUID as Lo}from"crypto";import{existsSync as Oo,mkdirSync as Wr,readFileSync as Uo,rmSync as Br}from"fs";import{dirname as Wo,resolve as Ut}from"path";import{spawn as Ys}from"child_process";import{closeSync as al,existsSync as Gs,mkdirSync as cl,openSync as ll,readFileSync as Qs,rmSync as ul,writeFileSync as pl}from"fs";import{dirname as dl,join as Mt,resolve as ml}from"path";import{fileURLToPath as yl}from"url";var fr=5e3,Xs="watch.lock",Zs="watch-state.json",eo="watch-activity.json";function dr(t){return{lockPath:Mt(t,Xs),statePath:Mt(t,Zs),activityPath:Mt(t,eo)}}function Ct(t){try{return to(JSON.parse(Qs(t,"utf8")))}catch{return null}}function to(t){if(!t||typeof t!="object")return null;let e=t;return e.version!==1||typeof e.protocolVersion!="number"||typeof e.pid!="number"||!Number.isInteger(e.pid)||e.pid<=0||typeof e.projectRoot!="string"||typeof e.cliVersion!="string"||!F(e.startedAt)||!F(e.heartbeatAt)||!F(e.lastActivityAt)||!no(e.watcher)||e.idleDeadlineAt!==void 0&&!F(e.idleDeadlineAt)||e.lastError!==void 0&&!ro(e.lastError)||e.lastRefresh!==void 0&&!io(e.lastRefresh)||e.typescriptSemantic!==void 0&&!so(e.typescriptSemantic)||e.typescriptIndex!==void 0&&!oo(e.typescriptIndex)?null:e}var hl={now:Date.now,isProcessAlive:Q,spawnServer(t,e,n,r){if(!Gs(t))throw new Error(`Watch service helper was not found at ${t}. Run npm run build first.`);Ys(process.execPath,[t,e,n,JSON.stringify(r)],{detached:!0,stdio:"ignore",env:{...process.env,SCIP_QUERY_SKIP_WATCH_SERVICE:"1"}}).unref()},signalProcess(t){process.kill(t,"SIGTERM")},sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)}};function F(t){return typeof t=="string"&&Number.isFinite(Date.parse(t))}function no(t){if(!t||typeof t!="object"||!("state"in t))return!1;let e=t;switch(e.state){case"idle":return!0;case"waiting":return w(e.changedFiles)&&w(e.reindexAt);case"indexing":return w(e.startedAt);case"cooldown":return w(e.until)&&typeof e.dirty=="boolean";default:return!1}}function ro(t){if(!t||typeof t!="object")return!1;let e=t;return F(e.at)&&typeof e.message=="string"}function io(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.trigger?.kind=="string"&&typeof e.result=="string"&&F(e.startedAt)&&F(e.completedAt)&&w(e.durationMs)}function so(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.protocolVersion=="number"&&(e.state==="idle"||e.state==="ready"||e.state==="unavailable"||e.state==="error")&&w(e.requests)&&w(e.sessionsCreated)&&w(e.sessionsReused)&&w(e.sessionsRefreshed)&&w(e.sessionsReplaced)&&w(e.projectsCreated)&&(e.lastRequestAt===void 0||F(e.lastRequestAt))&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||F(e.busyUntil))}function oo(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.protocolVersion=="number"&&(e.state==="idle"||e.state==="ready"||e.state==="unavailable"||e.state==="error")&&K(e.requests)&&K(e.sessionsCreated)&&K(e.sessionsReplaced)&&K(e.initializations)&&K(e.programUpdates)&&K(e.documentsEmitted)&&K(e.documentsRemoved)&&(e.lastRequestAt===void 0||F(e.lastRequestAt))&&(e.lastDurationMs===void 0||w(e.lastDurationMs)&&e.lastDurationMs>=0)&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||F(e.busyUntil))}function w(t){return typeof t=="number"&&Number.isFinite(t)}function K(t){return typeof t=="number"&&Number.isInteger(t)&&t>=0}import{performance as R}from"perf_hooks";function P(t,e,n){if(t.has(e))return t.get(e);let r=n();return t.set(e,r),r}import mr from"path";function ao(t,e){return t.getReferences().map(n=>{let r=n.getNode();return Oe(r,e)})}function co(t){let e=t;return typeof e.findReferences=="function"?e.findReferences():[]}function gr(t,e,n,r){let i=[];for(let s of co(t))for(let o of ao(s,r))o.file===e.relativePath&&o.line>=e.startLine&&o.line<=e.endLine||i.push(o);for(let s of n)i.push(s);return ee(i)}function yr(t,e,n,r){let i=[],s=n?.getStart();for(let o of t.getReferences()){let a=o.getNode();te(r,a.getSourceFile().getFilePath())===e&&(s!==void 0&&a.getStart()===s||i.push({location:Oe(a,r),node:a}))}return i}function Oe(t,e){let n=t.getSourceFile(),r=n.getLineAndColumnAtPos(t.getStart());return{file:te(e,n.getFilePath())??n.getBaseName(),line:r.line-1,column:r.column-1}}function Sr(t,e,n){let r=t.getSourceFile(),i=Dt(r,t),s=t.getText(),o=new RegExp(`\\b${Zt(s)}\\b`,"g"),a=r.getFullText().split(`
4
+ `),c=[];for(let l=0;l<a.length;l++){if(l===i)continue;let p=a[l]??"";o.lastIndex=0;let u;for(;(u=o.exec(p))!==null;)c.push({file:e,line:l,column:u.index})}return ee(c.filter(l=>te(n,mr.join(n,l.file))===e))}function kt(t){for(let e=t;e;e=e.getParent()){let n=e.getKindName();if(n.includes("Type")||n==="InterfaceDeclaration"||n==="TypeAliasDeclaration")return!0;if(n==="CallExpression"||n==="NewExpression"||n==="ExpressionStatement")return!1}return!1}function Dt(t,e){return t.getLineAndColumnAtPos(e.getStart()).line-1}function ee(t){let e=new Set,n=[];for(let r of t){let i=`${r.file}:${r.line}:${r.column}`;e.has(i)||(e.add(i),n.push(r))}return n}function te(t,e){let n=mr.relative(t||process.cwd(),e).replace(/\\/g,"/");return!n||n.startsWith("..")?null:n}function hr(t,e,n,r){let i=lo(e,r);return i.size===0?new Map:uo(t,n,i)}function lo(t,e){let n=new Map;for(let r of B(t,e)){let i=$(r.symbol)??r.leaf;if(!i)continue;let s=n.get(i);s||(s=[],n.set(i,s)),s.push(r)}return n}function uo(t,e,n){let r=new Map,i=new Map;return e.forEachDescendant(s=>{for(let o of po(t,s)){let a=n.get(o);if(!a)continue;let c=Dt(e,s);for(let l of a){if(c<l.startLine-1||c>l.endLine+1)continue;let p=Math.abs(c-l.startLine),u=i.get(l.symbolId);u!==void 0&&u<=p||(i.set(l.symbolId,p),r.set(l.symbolId,s))}}}),r}function po(t,e){let n=[],r=i=>{i&&!n.includes(i)&&n.push(i)};if("getNameNode"in e&&typeof e.getNameNode=="function"){let i=e.getNameNode();r(i?.getText())}if("getName"in e&&typeof e.getName=="function"){let i=e.getName();r(i)}return t.Node.isIdentifier(e)&&r(e.getText()),n}var fo=Vt("ts-definition-leaf-candidates",{clearGroups:["definition-catalog"]});function br(t,e,n,r){let i=Pt(t,e),s=Tt(i.get(r)??[],n);if(s)return s;let o=[];for(let a of i.values())for(let c of a)((c.leaf||$(c.symbol)||"").includes(r)||c.symbol.includes(r))&&o.push(c);return Tt(o,n)}function wt(t,e,n,r){return Tt(Pt(t,e).get(r)??[],n)}function Rr(t,e){let n=new Map;for(let[r,i]of Pt(t,e)){let s=i[0];s&&n.set(r,s)}return n}function Pt(t,e){return fo.get(t,e,()=>{let n=new Map;for(let r of B(t,e)){let i=r.leaf||$(r.symbol);if(!i)continue;let s=n.get(i);s||(s=[],n.set(i,s)),s.push({...r,leaf:i})}for(let r of n.values())r.sort((i,s)=>i.startLine-s.startLine||i.endLine-s.endLine||i.symbolId-s.symbolId);return n})}function Tt(t,e){let n=null,r=Number.POSITIVE_INFINITY;for(let i of t){let s=Math.abs(i.startLine-e);(s<r||s===r&&n&&i.startLine<n.startLine)&&(n=i,r=s)}return n}import Ft from"path";var le=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function _(t){let e=t.toLowerCase();return le.some(n=>e.endsWith(n))}function vr(t,e){let n=new Map,r=null,i=null,s=()=>(i??=Y(t,{extensions:le}),i),o=()=>(r??=C("typescript.source-file-index",()=>mo(t.config.projectRoot,e,s()),()=>({projects:e.length,indexedDocuments:s().length})),r),a=c=>_(c)?P(n,c,()=>{let l=ue(Ft.resolve(t.config.projectRoot,c));for(let{project:p,sourceFiles:u}of o()){let f=u.get(l)??null;if(f||(f=p.addSourceFileAtPathIfExists(l)??null,f&&u.set(ue(f.getFilePath()),f)),f)return{project:p,sourceFile:f}}return null}):null;return{sourceFile:c=>a(c)?.sourceFile??null,sourceFileMatch:a,indexedTypeScriptLikeDocuments:s}}function mo(t,e,n){let r=e.map(({project:i})=>({project:i,sourceFiles:new Map(i.getSourceFiles().map(s=>[ue(s.getFilePath()),s]))}));for(let i of n){let s=ue(Ft.resolve(t,i));for(let o of r){if(o.sourceFiles.has(s))break;let a=o.project.addSourceFileAtPathIfExists(s)??null;if(a){o.sourceFiles.set(ue(a.getFilePath()),a);break}}}return r}function ue(t){return Ft.resolve(t)}function Et(t,e){for(let n of t)if(e===n.name||e.startsWith(`${n.name}/`))return n.name;return null}function Ir(t){let e=`${t.relativeDir}/src`;return[`${e}/index.ts`,`${e}/index.tsx`,`${e}/index.mts`,`${e}/index.cts`]}import{existsSync as pe,readFileSync as go}from"fs";import D from"path";var At=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"];function Nt(t,e){let r=e?D.dirname(D.join(t,e)):t,i=D.resolve(t);for(;r.startsWith(i);){for(let o of At){let a=D.join(r,o);if(pe(a))return a}let s=D.dirname(r);if(s===r)break;r=s}for(let s of At){let o=D.join(t,s);if(pe(o))return o}return null}function xr(t){let e=t.config.projectRoot,n=new Set(yo(e,t.config.semantic?.typescript?.tsconfigs)),r=Y(t,{includeIgnored:!1,extensions:le});for(let i of r){let s=Nt(e,i);s&&n.add(D.resolve(s))}if(n.size===0){let i=Nt(e);i&&n.add(D.resolve(i))}return[...n].filter(i=>!Mr(e,i)).sort((i,s)=>i.localeCompare(s))}function yo(t,e=[]){let n=new Set;for(let r of e){let i=D.isAbsolute(r)?r:D.join(t,r);pe(i)&&n.add(D.resolve(i))}for(let r of So(t))for(let i of At){let s=D.join(r,i);pe(s)&&n.add(D.resolve(s))}if(n.size===0){let r=Nt(t);r&&n.add(D.resolve(r))}return[...n].filter(r=>!Mr(t,r)).sort((r,i)=>r.localeCompare(i))}function So(t){let e=D.join(t,"package.json");if(!pe(e))return[];let n;try{n=JSON.parse(go(e,"utf8"))}catch{return[]}return(Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages??[]).flatMap(i=>Yt(t,i))}function Mr(t,e){let n=D.relative(t,e).replace(/\\/g,"/");return n.startsWith("..")||n.includes("/node_modules/")||n.startsWith("node_modules/")||n.includes("/dist/")||n.startsWith("dist/")}import{createRequire as ho}from"module";var Cr=ho(import.meta.url),fe,Ue;function _t(){if(fe!==void 0)return fe;try{fe=Cr("ts-morph")}catch{fe=null}return fe}function We(){if(Ue)return Ue;let t=_t();if(!t)return"ts-morph:unavailable";let e="unknown";try{e=Cr("ts-morph/package.json").version??"unknown"}catch{}return Ue=`ts-morph:${e}:typescript:${t.ts.version}`,Ue}function kr(t,e){return e.map(n=>({tsconfigPath:n,project:new t.Project({tsConfigFilePath:n,skipFileDependencyResolution:!0})}))}function Be(t,e,n){return{language:"typescript",availability:()=>({available:!1,reason:t,tsconfigPath:e,tsconfigPaths:n}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}function qe(t,e){let n=new Map(t.map(i=>[i.symbol,i])),r=new Map(t.map(i=>[i.symbolId,[]]));for(let i of e.values())for(let s of i){let o=n.get(s.targetSymbol);o&&r.get(o.symbolId).push(s.location)}for(let[i,s]of r)r.set(i,bo(s));return r}function wr(t,e,n){let r=Tr(t,e),i=Tr(t,n),s=[...r].filter(u=>!i.has(u)).sort(),o=[...i].filter(u=>!r.has(u)).sort(),a=Dr(t,e),c=Dr(t,n),l=[...a].filter(u=>!c.has(u)).sort(),p=[...c].filter(u=>!a.has(u)).sort();return{passed:s.length===0&&o.length===0,expectedCount:r.size,actualCount:i.size,missing:s,extra:o,callerFiles:{passed:l.length===0&&p.length===0,expectedCount:a.size,actualCount:c.size,missing:l,extra:p}}}function Dr(t,e){let n=new Set;for(let r of t)for(let i of e.get(r.symbolId)??[])i.file!==r.relativePath&&n.add(`${r.symbol}\0${i.file}`);return n}function Pr(t,e,n){let r=new Set(n),i=new Map(n.map(s=>[s,[]]));for(let s of t)for(let o of e.get(s.symbolId)??[])r.has(o.file)&&i.get(o.file).push({targetSymbol:s.symbol,location:o});for(let[s,o]of i)i.set(s,Ro(o));return i}function Tr(t,e){let n=new Set;for(let r of t)for(let i of e.get(r.symbolId)??[])n.add(`${r.symbol}\0${i.file}\0${i.line}\0${i.column}`);return n}function bo(t){let e=new Map;for(let n of t)e.set(`${n.file}\0${n.line}\0${n.column}`,n);return[...e.values()].sort(Fr)}function Ro(t){let e=new Map;for(let n of t){let{location:r}=n;e.set(`${n.targetSymbol}\0${r.file}\0${r.line}\0${r.column}`,n)}return[...e.values()].sort((n,r)=>n.targetSymbol.localeCompare(r.targetSymbol)||Fr(n.location,r.location))}function Fr(t,e){return t.file.localeCompare(e.file)||t.line-e.line||t.column-e.column}var vo=32;function Lr(t,e){let n=C("typescript.provider.load",()=>_t());if(!n)return Be("ts-morph is not installed");let r=C("typescript.provider.tsconfig-discovery",()=>xr(t));if(r.length===0)return Be("no tsconfig found");try{let i=C("typescript.provider.project-bundles",()=>kr(n,r),()=>({tsconfigs:r.length}));return Io(t,n,i)}catch(i){return Be(i instanceof Error?i.message:String(i),r[0],r)}}function Io(t,e,n,r={}){return C("typescript.provider.construct",()=>new Lt(t,e,n),()=>({tsconfigs:n.length,reusedProjects:r.reusedProjects===!0}))}var Lt=class{constructor(e,n,r){this.db=e;this.tsMorph=n;this.projects=r;this.workspacePackages=Jt(e.config.projectRoot),this.sourceFiles=vr(e,r)}db;tsMorph;projects;language="typescript";importUsageCache=new Map;referencesCache=new Map;calleesCache=new Map;fileCalleesCache=new Map;signatureCache=new Map;definitionNodeCache=new Map;fileDefinitionNodeCache=new Map;indexedDefinitionLeafCache=new Map;compilerCheckerCache=new WeakMap;packageImportReferenceIndex=null;packageExportIndex=null;workspacePackages;sourceFiles;availability(){return{available:!0,tsconfigPath:this.projects[0]?.tsconfigPath,tsconfigPaths:this.projects.map(e=>e.tsconfigPath)}}importUsage(e){return P(this.importUsageCache,e,()=>{let n=this.sourceFiles.sourceFile(e);if(!n)return[];let r=Mo();return C("typescript.import-usage.file",()=>this.importUsageForSourceFile(e,n,r),()=>({file:e,...r}))})}referencesFor(e){return P(this.referencesCache,e.symbolId,()=>{let n=this.nodeForDefinition(e);return this.referencesForDefinitionNode(e,n)})}referencesForDefinitions(e,n={}){let r=new Map,i=W(),s=[];for(let p of e){let u=this.referencesCache.get(p.symbolId);u?r.set(p.symbolId,u):s.push(p)}if(s.length===0)return r;let o=s,a=n.exact?[]:s.filter(p=>!Ar(p));if(a.length>=vo){let p=this.referencesForDefinitionsBySymbolScan(a);for(let u of a){let f=p.get(u.symbolId)??[];this.referencesCache.set(u.symbolId,f),r.set(u.symbolId,f)}if(o=s.filter(u=>Ar(u)),o.length===0)return r}let c=new Map;for(let p of o){let u=c.get(p.relativePath);u?u.push(p):c.set(p.relativePath,[p])}let l=[];for(let[p,u]of c){let f=Nr();C("typescript.references-map.file",()=>{let d=this.definitionNodesForFile(p);for(let m of u){i&&(f.cacheMisses+=1);let b=d.get(m.symbolId)??null;i&&(b?f.nodeHits+=1:f.nodeMisses+=1);try{let g=this.referencesForDefinitionNode(m,b,i?f:void 0);this.referencesCache.set(m.symbolId,g),r.set(m.symbolId,g)}catch{f.preciseSearchFailures+=1,l.push(m)}}},()=>({relativePath:p,definitions:u.length,..._r(f)}))}if(l.length>0){let p=this.referencesForDefinitionsBySymbolScan(l);for(let u of l){let f=p.get(u.symbolId)??[];this.referencesCache.set(u.symbolId,f),r.set(u.symbolId,f)}}return r}referenceFragmentsForFiles(e){let n=he(this.db).filter(s=>_(s.relativePath)),r=e.filter(s=>this.sourceFiles.sourceFile(s)!==null),i=this.referencesForDefinitionsBySymbolScan(n,r);return Pr(n,i,r)}referencesForDefinitionsBySymbolScan(e,n){let r=W(),i=Nr(),s=new Map,o=new Set(e.map(c=>c.symbolId)),a=new Map(e.map(c=>[c.symbolId,c]));for(let c of e)s.set(c.symbolId,[]);return C("typescript.references-map.inverted-scan",()=>{let c=r?R.now():0,l=n?this.packageImportReferencesForFiles(n):this.packageImportReferences();for(let g of e){let S=l.get(g.symbolId)??[];if(S.length>0){let I=s.get(g.symbolId)??[];I.push(...S),s.set(g.symbolId,I)}r&&(i.packageReferenceCount+=S.length)}r&&(i.packageRefsMs+=R.now()-c);let p=new Map,u=new Map,f=this.hierarchyTargetsForDefinitions(e),d=new Set(e.map(g=>g.leaf).filter(Boolean)),m=r?R.now():0;for(let g of n??this.sourceFiles.indexedTypeScriptLikeDocuments()){if(this.db.isIgnored(g))continue;let S=this.sourceFiles.sourceFile(g);S&&(r&&(i.scanFiles+=1),this.addReferencesFromSourceFileScan(S,g,o,a,f,d,p,u,s,r?i:void 0))}r&&(i.scanMs+=R.now()-m);let b=r?R.now():0;this.addHierarchyMemberReferences(e,s,r?i:void 0),r&&(i.hierarchyMs+=R.now()-b);for(let[g,S]of s){let I=ee(S);s.set(g,I),r&&(i.referenceCount+=I.length)}},()=>({definitions:e.length,..._r(i)})),s}addReferencesFromSourceFileScan(e,n,r,i,s,o,a,c,l,p){let u=this.compilerCheckerForSourceFile(e),f=e.compilerNode,d=Do(e),m=b=>{if(this.tsMorph.ts.isIdentifier(b)){if(p&&(p.identifiers+=1),!o.has(b.text)&&!d.has(b.text)){this.tsMorph.ts.forEachChild(b,m);return}let g=this.compilerReferenceSymbol(u,b,p);if(g){let S;a.has(g)?S=a.get(g)??null:(S=this.referenceDefinitionFromCompilerSymbol(g),a.set(g,S)),p&&(S?p.targetHits+=1:p.targetMisses+=1);let I=P(c,g,()=>this.compilerSymbolKeys(g)),j=null,T=null,L=S&&r.has(S.symbolId)?i.get(S.symbolId):void 0;if(L&&(j=jt(f,b),!Er(L,n,j))){let O=f.getLineAndCharacterOfPosition(b.getStart(f));T={file:n,line:O.line,column:O.character};let E=l.get(L.symbolId)??[];E.push(T),l.set(L.symbolId,E),p&&(p.requestedHits+=1)}for(let O of I)for(let E of s.get(O)?.values()??[]){if(j??=jt(f,b),Er(E,n,j))continue;if(!T){let v=f.getLineAndCharacterOfPosition(b.getStart(f));T={file:n,line:v.line,column:v.character}}let y=l.get(E.symbolId)??[];y.push(T),l.set(E.symbolId,y),p&&(p.requestedHits+=1)}}}this.tsMorph.ts.forEachChild(b,m)};m(f)}hierarchyTargetsForDefinitions(e){let n=new Map;for(let r of e){let i=this.nodeForDefinition(r),s=i?.compilerNode;if(!s||!this.isHierarchyMethod(s))continue;let o=s.parent;if(!this.isHierarchyContainer(o))continue;let a=this.compilerCheckerForSourceFile(i.getSourceFile()),c=a.getSymbolAtLocation(s.name);if(c)for(let l of this.hierarchyMemberSymbols(a,o,c))for(let p of this.compilerSymbolKeys(l)){let u=n.get(p)??new Map;u.set(r.symbolId,r),n.set(p,u)}}return n}hierarchyMemberSymbols(e,n,r){let i=new Set,s=new Set,o=(a,c,l)=>{if(!s.has(a)){s.add(a),i.add(c);for(let p of l){let u=p.getProperty(r.name);u&&o(p,u,this.hierarchyAncestorTypesForType(e,p))}}};return o(e.getTypeAtLocation(n),r,this.hierarchyAncestorTypes(e,n)),i}addHierarchyMemberReferences(e,n,r){let i=new Map;for(let s of e){let o=this.nodeForDefinition(s),a=o?.compilerNode;if(!a||!this.isHierarchyMethod(a))continue;let c=a.parent;if(!this.isHierarchyContainer(c))continue;let l=this.compilerCheckerForSourceFile(o.getSourceFile()),p=l.getSymbolAtLocation(a.name);if(!p)continue;let u=a.getSourceFile(),f=u.getLineAndCharacterOfPosition(a.name.getStart(u)),d={definition:s,location:{file:s.relativePath,line:f.line,column:f.character}},m=n.get(s.symbolId)??[];for(let g of this.hierarchyMemberSymbols(l,c,p))if(g!==p)for(let S of this.compilerSymbolLocations(g))m.push(S),r&&(r.hierarchyReferences+=1);n.set(s.symbolId,m);let b=this.hierarchyRootMemberSymbols(l,c,p);for(let g of b){let S=i.get(g)??new Map;S.set(s.symbolId,d),i.set(g,S)}r&&(r.hierarchyDefinitions+=1)}for(let s of i.values())if(!(s.size<2)){r&&(r.hierarchyFamilies+=1);for(let{definition:o}of s.values()){let a=n.get(o.symbolId)??[];for(let c of s.values())c.definition.symbolId!==o.symbolId&&(a.push(c.location),r&&(r.hierarchyReferences+=1));n.set(o.symbolId,a)}}}hierarchyRootMemberSymbols(e,n,r){let i=new Set,s=new Set,o=(a,c,l)=>{if(s.has(a))return;s.add(a);let p=!1;for(let u of l){let f=u.getProperty(r.name);f&&(p=!0,o(u,f,this.hierarchyAncestorTypesForType(e,u)))}if(!p)for(let u of this.compilerSymbolKeys(c))i.add(u)};return o(e.getTypeAtLocation(n),r,this.hierarchyAncestorTypes(e,n)),i}compilerSymbolKeys(e){return(e.declarations??[]).map(n=>{let r=n.getSourceFile();return`${r.fileName}\0${n.getStart(r)}\0${e.name}`})}compilerSymbolLocations(e){let n=[];for(let r of e.declarations??[]){let i=r.getSourceFile(),s=te(this.db.config.projectRoot,i.fileName);if(!s)continue;let o=r.name,a=i.getLineAndCharacterOfPosition((o??r).getStart(i));n.push({file:s,line:a.line,column:a.character})}return n}baseTypes(e,n){try{return e.getBaseTypes(n)??[]}catch{return[]}}hierarchyAncestorTypes(e,n){let r=new Set(this.hierarchyAncestorTypesForType(e,e.getTypeAtLocation(n)));for(let i of n.heritageClauses??[])for(let s of i.types)r.add(e.getTypeAtLocation(s));return[...r]}hierarchyAncestorTypesForType(e,n){let r=new Set(this.baseTypes(e,n));for(let i of n.getSymbol()?.declarations??[])if(this.isHierarchyContainer(i))for(let s of i.heritageClauses??[])for(let o of s.types)r.add(e.getTypeAtLocation(o));return[...r]}isHierarchyMethod(e){return this.tsMorph.ts.isMethodDeclaration(e)||this.tsMorph.ts.isMethodSignature(e)}isHierarchyContainer(e){return this.tsMorph.ts.isClassDeclaration(e)||this.tsMorph.ts.isClassExpression(e)||this.tsMorph.ts.isInterfaceDeclaration(e)}compilerReferenceSymbol(e,n,r){r&&(r.symbolLookups+=1);let i=e.getSymbolAtLocation(n);if(i){if((i.flags&this.tsMorph.ts.SymbolFlags.Alias)===0)return i;try{return r&&(r.aliasResolutions+=1),e.getAliasedSymbol(i)}catch{return i}}}calleesFor(e){return P(this.calleesCache,e.symbolId,()=>P(this.fileCalleesCache,e.relativePath,()=>this.calleeMapForFile(e.relativePath)).get(e.symbolId)??[])}calleesForDefinitions(e){let n=new Map,r=new Map;for(let i of e){let s=r.get(i.relativePath);s?s.push(i):r.set(i.relativePath,[i])}for(let[i,s]of r){let o=this.fileCalleesCache.get(i),a=new Set(s.map(l=>l.symbolId)),c=o??this.calleeMapForFile(i,a);for(let l of s){let p=c.get(l.symbolId)??[];this.calleesCache.set(l.symbolId,p),n.set(l.symbolId,p)}}return n}referencesForDefinitionNode(e,n,r){let i=r?R.now():0,s=this.packageImportReferencesForDefinition(e);if(r&&(r.packageRefsMs+=R.now()-i,r.packageReferenceCount+=s.length),!n)return s;let o=r?R.now():0,a=gr(n,e,s,this.db.config.projectRoot);return r&&(r.semanticRefsMs+=R.now()-o,r.referenceCount+=a.length),a}signatureFor(e){return P(this.signatureCache,e.symbolId,()=>{let n=this.nodeForDefinition(e);if(!n||!this.tsMorph.Node.isFunctionDeclaration(n)&&!this.tsMorph.Node.isMethodDeclaration(n)&&!this.tsMorph.Node.isArrowFunction(n)&&!this.tsMorph.Node.isFunctionExpression(n)&&!this.tsMorph.Node.isConstructorDeclaration(n))return null;let r=n.getType().getCallSignatures()[0];if(!r)return null;let i=r.getParameters().map(o=>{let a=o.getDeclarations()[0],c=a?o.getTypeAtLocation(a).getText(a):o.getValueDeclaration()?.getType().getText()??"unknown";return jr(c)}),s=r.getReturnType().getText(n);return`(${i.join(",")})=>${jr(s)}`})}importUsageForSourceFile(e,n,r){let i=[],s=new Map;for(let o of n.getImportDeclarations()){r.declarations+=1;let a=Ze(this.db,e,o.getModuleSpecifierValue()),c=o.getImportClause()?.isTypeOnly()??!1;for(let l of Ot(o)){r.entries+=1;let p=c?null:l.identifier?.getSymbol()?.compilerSymbol??null;!c&&l.identifier&&(p?r.bindingSymbols+=1:r.missingBindingSymbols+=1);let u={sourcePath:a,entry:l,typeOnlyDeclaration:c,bindingSymbol:p,references:[]};if(i.push(u),c||!l.localName||!p)continue;let f=s.get(l.localName);f?f.push(u):s.set(l.localName,[u])}}return s.size>0&&n.forEachDescendant(o=>{if(o.getKindName()!=="Identifier")return;let a=s.get(o.getText());if(!a||Co(o))return;r.scannedIdentifiers+=1;let c=o.getSymbol()?.compilerSymbol;if(r.symbolLookups+=1,!!c){for(let l of a)if(l.bindingSymbol===c){l.references.push({location:Oe(o,this.db.config.projectRoot),node:o}),r.matchedReferences+=1;break}}}),i.map(o=>o.typeOnlyDeclaration?xo(e,o.sourcePath,o.entry):o.entry.identifier&&!o.bindingSymbol?(r.fallbackEntries+=1,this.valueImportUsageForEntry(e,o.sourcePath,o.entry)):this.valueImportUsageFromLocations(e,o.sourcePath,o.entry,o.references))}valueImportUsageForEntry(e,n,r){let i=r.identifier?r.identifier.findReferences():[],s=[];for(let o of i)for(let a of yr(o,e,r.identifier,this.db.config.projectRoot))s.push(a);return this.valueImportUsageFromLocations(e,n,r,s)}valueImportUsageFromLocations(e,n,r,i){let s=i.some(c=>!kt(c.node)),o=i.some(c=>kt(c.node)),a=r.isTypeOnly;return{importer:e,sourcePath:n,importedName:r.importedName,localName:r.localName,kind:r.kind,isTypeOnly:a,isUsed:a||i.length>0,isTypeUsed:a||o,isValueUsed:s,references:i.map(c=>c.location)}}packageImportReferencesForDefinition(e){return this.packageImportReferences().get(e.symbolId)??[]}packageImportReferencesForFiles(e){let n=new Map,r=new Set;for(let s of e){let o=this.sourceFiles.sourceFile(s);if(o)for(let a of o.getImportDeclarations()){let c=Et(this.workspacePackages,a.getModuleSpecifierValue());c&&r.add(c)}}if(r.size===0)return n;let i=this.packageExportsForNames(r);for(let s of e)this.addPackageImportReferencesForDocument(n,i,s);for(let[s,o]of n)n.set(s,ee(o));return n}packageImportReferences(){if(this.packageImportReferenceIndex)return this.packageImportReferenceIndex;let e=new Map,n=this.packageExports();for(let r of this.sourceFiles.indexedTypeScriptLikeDocuments())this.addPackageImportReferencesForDocument(e,n,r);for(let[r,i]of e)e.set(r,ee(i));return this.packageImportReferenceIndex=e,e}addPackageImportReferencesForDocument(e,n,r){if(this.db.isIgnored(r))return;let i=this.sourceFiles.sourceFileMatch(r);if(i)for(let s of i.sourceFile.getImportDeclarations())this.addPackageImportReferencesForDeclaration(e,n,r,s)}addPackageImportReferencesForDeclaration(e,n,r,i){let s=Et(this.workspacePackages,i.getModuleSpecifierValue());if(!s)return;let o=n.get(s);if(o)for(let a of Ot(i)){if(a.kind!=="named"||!a.identifier)continue;let c=o.get(a.importedName);if(!c||c.size===0)continue;let l=Sr(a.identifier,r,this.db.config.projectRoot);l.length>0&&Fo(e,c,l)}}packageExports(){return this.packageExportIndex?this.packageExportIndex:(this.packageExportIndex=this.packageExportsForNames(new Set(this.workspacePackages.map(e=>e.name))),this.packageExportIndex)}packageExportsForNames(e){let n=new Map;for(let r of this.workspacePackages){if(!e.has(r.name))continue;let i=new Map;for(let s of Ir(r))this.collectPackageExports(r,s,i,new Set);i.size>0&&n.set(r.name,i)}return n}collectPackageExports(e,n,r,i){if(i.has(n))return;i.add(n);let s=this.sourceFiles.sourceFile(n);if(s)for(let o of s.getExportDeclarations()){let a=o.getModuleSpecifierValue(),c=a?Ze(this.db,n,a):n;if(!c||!c.startsWith(`${e.relativeDir}/src/`))continue;let l=o.getNamedExports();if(l.length===0){if(o.isNamespaceExport())continue;this.collectPackageExports(e,c,r,i);continue}for(let p of l){let u=p.getNameNode().getText(),f=p.getAliasNode()?.getText()??u,d=this.indexedDefinitionByLeaf(c,u);if(!d)continue;let m=r.get(f);m||(m=new Set,r.set(f,m)),m.add(d.symbolId)}}}indexedDefinitionByLeaf(e,n){return P(this.indexedDefinitionLeafCache,e,()=>Rr(this.db,e)).get(n)??null}nodeForDefinition(e){return P(this.definitionNodeCache,e.symbolId,()=>this.definitionNodesForFile(e.relativePath).get(e.symbolId)??null)}definitionNodesForFile(e){return P(this.fileDefinitionNodeCache,e,()=>{let n=this.sourceFiles.sourceFile(e);return n?hr(this.tsMorph,this.db,n,e):new Map})}referenceDefinitionFromCompilerSymbol(e){return this.definitionFromCompilerSymbol(e,void 0,!0)}definitionFromCompilerSymbol(e,n,r=!1){let i=e.name,s=n?R.now():0,o=e.declarations??[];n&&(n.declarationsMs+=R.now()-s,n.declarationChecks+=o.length);for(let a of o){let c=n?R.now():0,l=a.getSourceFile(),p=te(this.db.config.projectRoot,l.fileName),u=l.getLineAndCharacterOfPosition(a.getStart(l)).line;if(n&&(n.declarationLocationMs+=R.now()-c),!p||this.db.isIgnored(p))continue;let f=n?R.now():0,d=this.compilerDeclarationName(a),m=r?wt(this.db,p,u,i)??(d&&d!==i?wt(this.db,p,u,d):null):br(this.db,p,u,i);if(n&&(n.indexedLookupMs+=R.now()-f),m)return{symbolId:m.symbolId,symbol:m.symbol,file:m.relativePath,line:m.startLine}}return null}compilerDeclarationName(e){let n=e.name;return n&&this.tsMorph.ts.isIdentifier(n)?n.text:null}calleeMapForFile(e,n){let r=W(),i=0,s=0,o=0,a=0,c=0,l=0,p=0,u=0,f=r?wo():void 0;return C("typescript.callee-map.file",()=>{let d=r?R.now():0,m=this.sourceFiles.sourceFile(e);if(r&&(c=Math.round(R.now()-d)),!m)return new Map;let b=r?R.now():0,g=B(this.db,e).sort((y,v)=>y.startLine-v.startLine||v.endLine-y.endLine);if(r&&(l=Math.round(R.now()-b)),i=g.length,g.length===0)return new Map;let S=new Map,I=r?R.now():0,j=this.compilerCheckerForSourceFile(m),T=m.compilerNode;r&&(p=Math.round(R.now()-I));let L=new Map,O=y=>{if(this.tsMorph.ts.isCallExpression(y)||this.tsMorph.ts.isNewExpression(y)){r&&(s+=1);let v=this.semanticCalleeForCallNode(j,T,g,y,L,n,f);v&&(r&&(o+=1),ko(S,v.callerId,v.target))}this.tsMorph.ts.forEachChild(y,O)},E=r?R.now():0;O(T),r&&(u=Math.round(R.now()-E));for(let[y,v]of S)S.set(y,Eo(v));return a=S.size,S},()=>({relativePath:e,definitions:i,callNodes:s,resolvedCallees:o,outputRows:a,requestedDefinitions:n?.size??i,sourceFileLookupMs:c,definitionsLoadMs:l,checkerLookupMs:p,traversalMs:u,...f?Po(f):{}}))}semanticCalleeForCallNode(e,n,r,i,s,o,a){let c=a?R.now():0,l=To(r,jt(n,i));if(a&&(a.callerLookupMs+=R.now()-c),!l)return null;if(o&&!o.has(l.symbolId))return a&&(a.skippedUnrequestedCallers+=1),null;let p=i.expression,u=this.compilerSymbolForExpression(e,p,a),f=null;if(u)if(a&&(a.targetSymbolHits+=1),s.has(u))a&&(a.compilerSymbolCacheHits+=1),f=s.get(u)??null;else{a&&(a.compilerSymbolCacheMisses+=1);let d=a?R.now():0;f=this.definitionFromCompilerSymbol(u,a),a&&(a.targetLookupMs+=R.now()-d),s.set(u,f)}else a&&(a.targetMisses+=1);return f?{callerId:l.symbolId,target:{symbol:f.symbol,file:f.file,line:f.line}}:null}compilerSymbolForExpression(e,n,r){let i=r?R.now():0,s=e.getSymbolAtLocation(n);if(r&&(r.expressionSymbolMs+=R.now()-i),s)return s;r&&(r.typeFallbacks+=1);let o=r?R.now():0,a=e.getTypeAtLocation(n).getSymbol();return r&&(r.typeSymbolMs+=R.now()-o),a}compilerCheckerForSourceFile(e){let n=e.getProject(),r=this.compilerCheckerCache.get(n);return r||(r=n.getTypeChecker().compilerObject,this.compilerCheckerCache.set(n,r)),r}};function Ot(t){let e=[],n=t.getDefaultImport();n&&e.push({identifier:n,importedName:"default",localName:n.getText(),kind:"default",isTypeOnly:t.getImportClause()?.isTypeOnly()??!1});let r=t.getNamespaceImport();r&&e.push({identifier:r,importedName:"*",localName:r.getText(),kind:"namespace",isTypeOnly:t.getImportClause()?.isTypeOnly()??!1});for(let i of t.getNamedImports()){let s=i.getNameNode(),a=i.getAliasNode()??(s.getKindName()==="Identifier"?s:null);e.push({identifier:a,importedName:s.getText(),localName:a?.getText()??s.getText(),kind:"named",isTypeOnly:i.isTypeOnly()||(t.getImportClause()?.isTypeOnly()??!1)})}return e.length===0&&e.push({identifier:null,importedName:"*",localName:null,kind:"side-effect",isTypeOnly:!1}),e}function xo(t,e,n){return{importer:t,sourcePath:e,importedName:n.importedName,localName:n.localName,kind:n.kind,isTypeOnly:!0,isUsed:!0,isTypeUsed:!0,isValueUsed:!1,references:[]}}function Mo(){return{declarations:0,entries:0,bindingSymbols:0,missingBindingSymbols:0,scannedIdentifiers:0,symbolLookups:0,matchedReferences:0,fallbackEntries:0}}function Co(t){for(let e=t;e;e=e.getParent())if(e.getKindName()==="ImportDeclaration")return!0;return!1}function ko(t,e,n){let r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}function Do(t){let e=new Set;for(let n of t.getImportDeclarations())for(let r of Ot(n))r.localName&&e.add(r.localName);return e}function To(t,e){let n=null;for(let r of t)e<r.startLine||e>r.endLine||(!n||r.startLine>=n.startLine)&&(n=r);return n}function jt(t,e){return t.getLineAndCharacterOfPosition(e.getStart(t)).line}function Er(t,e,n){return e===t.relativePath&&n>=t.startLine&&n<=t.endLine}function Ar(t){return t.symbol.includes("#")?Se(t.symbol)==="type"&&t.relativePath.endsWith(".d.ts"):!1}function wo(){return{callerLookupMs:0,expressionSymbolMs:0,typeSymbolMs:0,targetLookupMs:0,declarationsMs:0,declarationLocationMs:0,indexedLookupMs:0,compilerSymbolCacheHits:0,compilerSymbolCacheMisses:0,targetSymbolHits:0,targetMisses:0,typeFallbacks:0,declarationChecks:0,skippedUnrequestedCallers:0}}function Po(t){return{...t,callerLookupMs:Math.round(t.callerLookupMs),expressionSymbolMs:Math.round(t.expressionSymbolMs),typeSymbolMs:Math.round(t.typeSymbolMs),targetLookupMs:Math.round(t.targetLookupMs),declarationsMs:Math.round(t.declarationsMs),declarationLocationMs:Math.round(t.declarationLocationMs),indexedLookupMs:Math.round(t.indexedLookupMs)}}function Nr(){return{cacheHits:0,cacheMisses:0,nodeHits:0,nodeMisses:0,scanFiles:0,identifiers:0,symbolLookups:0,aliasResolutions:0,targetHits:0,targetMisses:0,requestedHits:0,scanMs:0,packageRefsMs:0,semanticRefsMs:0,packageReferenceCount:0,referenceCount:0,preciseSearchFailures:0,hierarchyDefinitions:0,hierarchyFamilies:0,hierarchyReferences:0,hierarchyMs:0}}function _r(t){return{...t,scanMs:Math.round(t.scanMs),packageRefsMs:Math.round(t.packageRefsMs),semanticRefsMs:Math.round(t.semanticRefsMs),hierarchyMs:Math.round(t.hierarchyMs)}}function Fo(t,e,n){for(let r of e){let i=t.get(r)??[];i.push(...n),t.set(r,i)}}function Eo(t){let e=new Set,n=[];for(let r of t){let i=`${r.symbol}|${r.file}|${r.line}`;e.has(i)||(e.add(i),n.push(r))}return n}function jr(t){return t.replace(/\s+/g," ").replace(/\bimport\("[^"]+"\)\./g,"").trim()}import{createHash as Ao}from"crypto";import{readFileSync as No}from"fs";import{dirname as _o,join as $e}from"path";var ze=2,jo="typescript-semantic";function Or(t){let e=$e(t,jo);return{rootDir:e,requestDir:$e(e,"requests"),responseDir:$e(e,"responses")}}function Ur(t){try{let e=JSON.parse(No($e(_o(t),"meta.json"),"utf8"));return e.version!==2&&e.version!==3||typeof e.status!="string"||typeof e.updatedAt!="string"||e.fingerprint===void 0?null:Ao("sha256").update(JSON.stringify({version:e.version,status:e.status,updatedAt:e.updatedAt,fingerprint:e.fingerprint,indexedLanguages:e.indexedLanguages})).digest("hex")}catch{return null}}var Bo=12e4,qo=5;function zr(t,e,n={}){let r=new Wt(t,n),i=null,s=null,o=process.env.SCIP_QUERY_SKIP_WATCH_SERVICE==="1",a=()=>(i??=Lr(t,e),i),c=(u,f,d)=>{if(o)return d();try{return f(r.request(u))}catch{return o=!0,d()}},l=(u,f)=>c({kind:"references",definitions:[...u],...f?.exact?{exact:!0}:{}},d=>$r(d),()=>a().referencesForDefinitions?.(u,f)??new Map(u.map(d=>[d.symbolId,a().referencesFor(d)]))),p=u=>c({kind:"callees",definitions:[...u]},f=>$r(f),()=>a().calleesForDefinitions?.(u)??new Map(u.map(f=>[f.symbolId,a().calleesFor(f)])));return{language:"typescript",availability:()=>(s??=c({kind:"availability"},Ho,()=>a().availability()),s),importUsage:u=>c({kind:"import-usage",file:u},f=>f,()=>a().importUsage(u)),referencesFor:u=>l([u]).get(u.symbolId)??[],referencesForDefinitions:l,referenceFragmentsForFiles:u=>c({kind:"reference-fragments",files:[...u]},f=>zo(f),()=>a().referenceFragmentsForFiles?.(u)??new Map),calleesFor:u=>p([u]).get(u.symbolId)??[],calleesForDefinitions:p,signatureFor:u=>c({kind:"signature",definition:u},Vo,()=>a().signatureFor(u)),dispose:()=>i?.dispose?.()}}var Wt=class{constructor(e,n={}){this.db=e;this.runtime=n.runtime??Jo,this.timeoutMs=n.timeoutMs??Ko(),this.cacheDir=Wo(e.config.dbPath)}db;runtime;timeoutMs;cacheDir;request(e){let n=dr(this.cacheDir),r=Or(this.cacheDir),i=Ct(n.statePath);if(!qr(i,this.db.config.projectRoot,this.runtime))throw new Error("Compatible TypeScript semantic service is not running.");let s=Ur(this.db.config.dbPath);if(!s)throw new Error("Published TypeScript generation identity is unavailable.");let o=this.runtime.randomId(),a=Ut(r.requestDir,`${o}.json`),c=Ut(r.responseDir,`${o}.json`),l=this.runtime.now()+this.timeoutMs;Wr(r.requestDir,{recursive:!0}),Wr(r.responseDir,{recursive:!0}),Ie(a,{protocolVersion:ze,id:o,generation:s,deadlineAtMs:l,profileEnvironment:Gt(),request:e});try{for(;this.runtime.now()<=l;){if(Oo(c))return $o(Uo(c,"utf8"),o,s);let p=Ct(n.statePath);if(!qr(p,this.db.config.projectRoot,this.runtime))throw new Error("TypeScript semantic service stopped while processing a request.");this.runtime.sleep(qo)}throw new Error(`TypeScript semantic service timed out after ${this.timeoutMs}ms.`)}finally{Br(a,{force:!0}),Br(c,{force:!0})}}};function qr(t,e,n){let r=t!==null&&n.now()-Date.parse(t.heartbeatAt)<=fr,i=t?.typescriptSemantic?.busyUntil!==void 0&&n.now()<=Date.parse(t.typescriptSemantic.busyUntil);return t!==null&&t.projectRoot===Ut(e)&&t.typescriptSemantic?.protocolVersion===ze&&n.isProcessAlive(t.pid)&&(r||i)}function $o(t,e,n){let r=JSON.parse(t);if(r.protocolVersion!==ze||r.id!==e||r.ok===!0&&r.generation!==n)throw new Error("TypeScript semantic service wrote an incompatible response.");if(r.ok===!0)return r.response;throw new Error(typeof r.error=="string"?r.error:"TypeScript semantic service request failed.")}function $r(t){if(!Array.isArray(t))throw new Error("TypeScript semantic service wrote an invalid numeric map.");return new Map(t)}function zo(t){if(!Array.isArray(t))throw new Error("TypeScript semantic service wrote an invalid string map.");return new Map(t)}function Ho(t){if(!t||typeof t!="object"||typeof t.available!="boolean")throw new Error("TypeScript semantic service wrote invalid availability.");return t}function Vo(t){if(t!==null&&typeof t!="string")throw new Error("TypeScript semantic service wrote an invalid signature.");return t}function Ko(){let t=Number(process.env.SCIP_TYPESCRIPT_SEMANTIC_TIMEOUT_MS);return Number.isInteger(t)&&t>0?t:Bo}var Jo={now:Date.now,randomId:Lo,sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)},isProcessAlive:Q};var Hr=new Le;Ht({name:"semantic-provider",groups:["semantic-provider"],clearAll:t=>Hr.clear(t)});function Bt(t,e){let n=Yo(e)??"typescript";return Hr.getOrCreate(t,n,()=>n==="rust"?cr(t.config.projectRoot,{sourceImportUsageResolver:{importUsageFacts:r=>Tn(t,r)},calleeSymbolResolver:Dn(t),sourceZeroCalleeOracle:r=>Go(t,r),scipOccurrenceCalleeOracle:r=>pr(t,r)}):zr(t,e))}function Yo(t){return t?en(t)==="rust"?"rust":_(t)?"typescript":null:"typescript"}function Go(t,e){let n=ge(t,e.relativePath);if(!n||n.language!=="rust")return!1;let r=n.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine&&i.name===e.leaf)??n.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine);return r?!n.callSites.some(i=>i.line>=r.startLine&&i.line<=r.endLine):!1}import{readFileSync as ea}from"fs";import{dirname as ta,join as na}from"path";function Ve(t){let e=He(t.projectFiles),n=new Set(e),r=new Map(t.snapshot.files.map(u=>[u.path,u])),i=t.snapshot.files.filter(u=>{let f=xe(u.path,["typescript"]);return f==="config"||f==="ambient"}).map(u=>u.path),s=He([...e,...i]),o=s.find(u=>!r.has(u)),a=new Set(t.snapshot.files.map(u=>u.path)).size!==t.snapshot.files.length,c=!o&&s.some(u=>Vr(r.get(u))),l=Xe(JSON.stringify({pnpmWorkspaces:t.snapshot.pnpmWorkspaces,typescriptProjectMode:t.snapshot.typescriptProjectMode,typescriptProjects:He(t.snapshot.typescriptProjects),membership:e})),p=new Map;return{identityFor(u,f){if(!n.has(u))return ne("target-outside-project");if(a)return ne("duplicate-input-path");if(o)return ne("missing-input-fingerprint");if(c)return ne("unreadable-input");let d=[],m,b;if(t.graph===null)d.push("dependency-graph-unavailable"),b="whole-project",m=s;else{let I=Xo(u,t.graph,p);if(I.find(T=>!r.has(T)))return ne("missing-input-fingerprint");if(m=He([...I,...i]),m.some(T=>Vr(r.get(T))))return ne("unreadable-input");b="dependency-closure"}let g=m.map(I=>Zo(r.get(I)));return{version:1,key:Xe(JSON.stringify({version:1,engineIdentity:t.engineIdentity,schemaVersion:f,projectIdentity:l,inputs:g})),mode:b,inputFiles:m,reasons:d}}}}function Qo(t,e){let n=new Set,r=[t];for(let i=0;i<r.length;i+=1){let s=r[i];if(!(s===void 0||n.has(s))){n.add(s);for(let o of[...e.get(s)??[]].sort())n.has(o)||r.push(o)}}return[...n].sort()}function Xo(t,e,n){let r=n.get(t);if(r)return r;let i=Qo(t,e);return n.set(t,i),i}function Zo(t){return{path:t.path,size:t.size,hash:t.hash}}function Vr(t){return t.size<0||t.hash==="unreadable"}function ne(t){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[t]}}function He(t){return[...new Set(t)].sort()}var ra=Kt("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function qt(t,e,n){let r=ra.get(t,()=>ia(t));if(!r)return null;let i=`${n}\0${e}`,s=r.identities.get(i);if(s)return s;let o=r.builder.identityFor(e,n);return r.identities.set(i,o),o}function de(t){return Y(t,{includeIgnored:!1}).filter(_).sort()}function ia(t){try{let e=JSON.parse(ea(na(ta(t.config.dbPath),"meta.json"),"utf8")),n=kn(e.fingerprint);return n?{builder:Ve({projectFiles:de(t),snapshot:n,graph:ye(t),engineIdentity:We()}),identities:new Map}:null}catch{return null}}var $t="typescript-reference-fragment-v2",Je=Qt({kind:"typescript-reference-fragments",invalidation:Xt("typescript-reference-fragments"),serialize:t=>JSON.stringify(t),deserialize:oa});function sp(t,e,n,r=t){let i=de(t),s=Ve({projectFiles:i,snapshot:e,graph:ye(t),engineIdentity:We()}),o=[...n].map(([a,c])=>({relativePath:a,contentHash:s.identityFor(a,$t).key,value:[...c]}));if(o.some(a=>a.contentHash===null))throw new Error("TypeScript reference fragment identity is unavailable for an affected document.");return Je.writeBatch(r,o.map(a=>({...a,contentHash:a.contentHash}))),o.length}function op(t,e,n){let r=e.filter(s=>_(s.relativePath));if(r.length===0)return Ke("no TypeScript definitions");let i=Ke("shadow did not run");return C("typescript.reference-fragments.shadow",()=>{try{let s=Bt(t,r[0].relativePath);if(!s.availability().available||!s.referenceFragmentsForFiles)return i=Ke("TypeScript reference fragment provider is unavailable"),i;let o=de(t),a=new Set(o),c=s.referenceFragmentsForFiles(o),l=qe(r,c),p=wr(r,sa(n,a),l);if(!p.passed)return i={state:"failing",files:o.length,keyedFiles:0,writtenFiles:0,...p},i;let u=[];for(let f of o){let d=qt(t,f,$t);d?.key&&u.push({relativePath:f,contentHash:d.key,value:c.get(f)??[]})}return Je.writeBatch(t,u),i={state:"passing",files:o.length,keyedFiles:u.length,writtenFiles:u.length,...p},i}catch(s){return i=Ke(s instanceof Error?s.message:String(s)),i}},()=>({...i}))}function sa(t,e){return new Map([...t].map(([n,r])=>[n,r.filter(i=>e.has(i.file))]))}function ap(t,e){if(e.length===0)return{references:new Map,files:0,cacheHits:0,cacheMisses:0,computedFiles:0};let n="fallback",r=0,i=0,s=0,o=0;return C("typescript.reference-fragments.materialize",()=>{try{let a=de(t);r=a.length;let c=new Map,l=new Map,p=[];for(let d of a){let m=qt(t,d,$t);if(!m?.key)return null;c.set(d,m.key);let b=Je.read(t,d,m.key);b===null?(s+=1,p.push(d)):(i+=1,l.set(d,b))}if(s===0)return n="hit",{references:qe(e,l),files:r,cacheHits:i,cacheMisses:s,computedFiles:o};let u=Bt(t,e[0].relativePath);if(!u.availability().available||!u.referenceFragmentsForFiles)return null;let f=u.referenceFragmentsForFiles(p);if(p.some(d=>!f.has(d)))return null;o=f.size,Je.writeBatch(t,p.map(d=>({relativePath:d,contentHash:c.get(d),value:f.get(d)??[]})));for(let[d,m]of f)l.set(d,m);return n="computed",{references:qe(e,l),files:r,cacheHits:i,cacheMisses:s,computedFiles:o}}catch{return null}},()=>({state:n,files:r,cacheHits:i,cacheMisses:s,computedFiles:o}))}function Ke(t){return{state:"unavailable",files:0,keyedFiles:0,writtenFiles:0,expectedCount:0,actualCount:0,missing:[],extra:[],reason:t}}function oa(t){try{let e=JSON.parse(t);return!Array.isArray(e)||!e.every(aa)?null:e}catch{return null}}function aa(t){if(!t||typeof t!="object")return!1;let e=t,n=e.location;return typeof e.targetSymbol=="string"&&!!n&&typeof n.file=="string"&&typeof n.line=="number"&&typeof n.column=="number"}export{Gr as a,ln as b,pn as c,ve as d,Sa as e,ri as f,ha as g,ba as h,Q as i,Ie as j,Pn as k,cc as l,lc as m,mc as n,xe as o,wa as p,bn as q,fr as r,dr as s,Ct as t,_ as u,Bt as v,Yo as w,kn as x,Aa as y,Ci as z,Na as A,Ve as B,qt as C,sp as D,op as E,ap as F};
5
+ //# sourceMappingURL=chunk-EBSSCVR4.js.map
@@ -1,2 +1,2 @@
1
- import{a as C}from"./chunk-IMQFJ53K.js";import{q as v}from"./chunk-GULVO6NF.js";import{b as O,d as x,f as T}from"./chunk-WMO2VZZK.js";import{d as A}from"./chunk-X5C43YVI.js";import{f as b}from"./chunk-JZBGTSAB.js";import{x as g}from"./chunk-ISLWJ4PY.js";function H(e,n={}){let{samples:o=50,scope:r,maxDisagreements:u=5}=n,l=new C(e),a=B(l.productionCallableDefinitions({scope:r,minLoc:2,requireFunctionLikeSymbol:!0}),o),c=K(e,a);if(a.length===0||!c)return{available:!1,sampleSize:a.length,oracleCoverage:0,scores:[],topDisagreements:[]};let t={references:P(),callees:P()},i=[],f=0,m=c==="semantic"?T(e,a):new Map,I=c==="source"?E(e,l,a):null;for(let s of a){let p=S(s,c==="semantic"?x(e,s).map(d=>d.file):[...I?.referencesBySymbolId.get(s.symbolId)??[]]),j=S(s,c==="semantic"?(m.get(s.symbolId)??[]).map(d=>d.file):[...I?.calleesBySymbolId.get(s.symbolId)??[]]);f+=1;let L=S(s,v(e,s).map(d=>d.file)),k=S(s,(l.calleeMap([s],{semantic:!1}).get(s.symbolId)??[]).map(d=>d.file)),w=y(c,"references"),R=y(c,"callees");Q(t.references,s,"references",L,p,w,i),Q(t.callees,s,"callees",k,j,R,i)}return i.sort((s,p)=>p.cheapOnly.length+p.oracleOnly.length-(s.cheapOnly.length+s.oracleOnly.length)),{available:!0,sampleSize:a.length,oracleCoverage:a.length>0?D(f/a.length):0,oracleKind:c,scores:["references","callees"].map(s=>F(s,t[s],c)),topDisagreements:i.slice(0,u)}}function P(){return{comparedSymbols:0,agreed:0,cheapTotal:0,oracleTotal:0,skippedOraclePartial:0}}function B(e,n){let o=[...e].sort((l,a)=>l.symbolId-a.symbolId);if(o.length<=n)return o;let r=o.length/n,u=[];for(let l=0;l<n;l++)u.push(o[Math.floor(l*r)]);return u}function K(e,n){let o=n[0];if(!o)return null;if(h(e,o))return"source";try{if(O(e).capability("semantic-references",o.relativePath).available)return"semantic"}catch{}return n.some(r=>h(e,r))?"source":null}function S(e,n){let o=new Set;for(let r of n)r!==e.relativePath&&o.add(r);return o}function Q(e,n,o,r,u,l,a){if(!l&&u.size===0){e.skippedOraclePartial+=1;return}e.comparedSymbols+=1,e.cheapTotal+=r.size,e.oracleTotal+=u.size;let c=[],t=[];for(let i of r)u.has(i)?e.agreed+=1:c.push(i);for(let i of u)r.has(i)||t.push(i);(c.length>0||t.length>0)&&a.push({symbol:A(n.symbol),question:o,cheapOnly:c,oracleOnly:t})}var z={references:!0,callees:!1};function F(e,n,o){let r=n.oracleTotal>0?n.agreed/n.oracleTotal:1,u=n.cheapTotal-n.agreed,l=y(o,e);return{question:e,comparedSymbols:n.comparedSymbols,precision:l&&n.cheapTotal>0?D(n.agreed/n.cheapTotal):null,recall:D(r),unverified:u,skippedOraclePartial:n.skippedOraclePartial}}function y(e,n){return e==="semantic"?z[n]:!1}function h(e,n){return g(n.relativePath)==="clojure"&&b(e,n.relativePath)!==null}function E(e,n,o){let r=new Map,u=new Map,l=o.filter(t=>h(e,t)),a=new Map;for(let t of l){let i=a.get(t.leaf)??[];i.push(t),a.set(t.leaf,i)}for(let t of n.sourceFiles()){if(g(t)!=="clojure")continue;let i=b(e,t);if(i)for(let f of i.fileIdentifiers)for(let m of a.get(f)??[])M(r,m.symbolId,t)}let c=new Map;for(let t of n.scopedDefinitions()){if(g(t.relativePath)!=="clojure")continue;let i=c.get(t.leaf)??[];i.push(t),c.set(t.leaf,i)}for(let t of l){let i=b(e,t.relativePath);if(i){for(let f of i.callSites)if(!(f.line<t.startLine||f.line>t.endLine))for(let m of c.get(f.calleeLeaf)??[])M(u,t.symbolId,m.relativePath)}}return{referencesBySymbolId:r,calleesBySymbolId:u}}function M(e,n,o){let r=e.get(n);if(r){r.add(o);return}e.set(n,new Set([o]))}function D(e){return Math.round(e*1e3)/1e3}export{H as a};
2
- //# sourceMappingURL=chunk-OXTM2RX3.js.map
1
+ import{a as C}from"./chunk-3I34FZ6R.js";import{m as v}from"./chunk-2Y7YX54K.js";import{f as O,i as x,l as T}from"./chunk-DA34GNNO.js";import{d as A}from"./chunk-OO6S4ECV.js";import{f as b}from"./chunk-NLVKD45E.js";import{B as g}from"./chunk-MCNWCJYL.js";function H(e,n={}){let{samples:o=50,scope:r,maxDisagreements:u=5}=n,l=new C(e),a=B(l.productionCallableDefinitions({scope:r,minLoc:2,requireFunctionLikeSymbol:!0}),o),c=K(e,a);if(a.length===0||!c)return{available:!1,sampleSize:a.length,oracleCoverage:0,scores:[],topDisagreements:[]};let t={references:P(),callees:P()},i=[],f=0,m=c==="semantic"?T(e,a):new Map,I=c==="source"?E(e,l,a):null;for(let s of a){let p=S(s,c==="semantic"?x(e,s).map(d=>d.file):[...I?.referencesBySymbolId.get(s.symbolId)??[]]),j=S(s,c==="semantic"?(m.get(s.symbolId)??[]).map(d=>d.file):[...I?.calleesBySymbolId.get(s.symbolId)??[]]);f+=1;let L=S(s,v(e,s).map(d=>d.file)),k=S(s,(l.calleeMap([s],{semantic:!1}).get(s.symbolId)??[]).map(d=>d.file)),w=y(c,"references"),R=y(c,"callees");Q(t.references,s,"references",L,p,w,i),Q(t.callees,s,"callees",k,j,R,i)}return i.sort((s,p)=>p.cheapOnly.length+p.oracleOnly.length-(s.cheapOnly.length+s.oracleOnly.length)),{available:!0,sampleSize:a.length,oracleCoverage:a.length>0?D(f/a.length):0,oracleKind:c,scores:["references","callees"].map(s=>F(s,t[s],c)),topDisagreements:i.slice(0,u)}}function P(){return{comparedSymbols:0,agreed:0,cheapTotal:0,oracleTotal:0,skippedOraclePartial:0}}function B(e,n){let o=[...e].sort((l,a)=>l.symbolId-a.symbolId);if(o.length<=n)return o;let r=o.length/n,u=[];for(let l=0;l<n;l++)u.push(o[Math.floor(l*r)]);return u}function K(e,n){let o=n[0];if(!o)return null;if(h(e,o))return"source";try{if(O(e).capability("semantic-references",o.relativePath).available)return"semantic"}catch{}return n.some(r=>h(e,r))?"source":null}function S(e,n){let o=new Set;for(let r of n)r!==e.relativePath&&o.add(r);return o}function Q(e,n,o,r,u,l,a){if(!l&&u.size===0){e.skippedOraclePartial+=1;return}e.comparedSymbols+=1,e.cheapTotal+=r.size,e.oracleTotal+=u.size;let c=[],t=[];for(let i of r)u.has(i)?e.agreed+=1:c.push(i);for(let i of u)r.has(i)||t.push(i);(c.length>0||t.length>0)&&a.push({symbol:A(n.symbol),question:o,cheapOnly:c,oracleOnly:t})}var z={references:!0,callees:!1};function F(e,n,o){let r=n.oracleTotal>0?n.agreed/n.oracleTotal:1,u=n.cheapTotal-n.agreed,l=y(o,e);return{question:e,comparedSymbols:n.comparedSymbols,precision:l&&n.cheapTotal>0?D(n.agreed/n.cheapTotal):null,recall:D(r),unverified:u,skippedOraclePartial:n.skippedOraclePartial}}function y(e,n){return e==="semantic"?z[n]:!1}function h(e,n){return g(n.relativePath)==="clojure"&&b(e,n.relativePath)!==null}function E(e,n,o){let r=new Map,u=new Map,l=o.filter(t=>h(e,t)),a=new Map;for(let t of l){let i=a.get(t.leaf)??[];i.push(t),a.set(t.leaf,i)}for(let t of n.sourceFiles()){if(g(t)!=="clojure")continue;let i=b(e,t);if(i)for(let f of i.fileIdentifiers)for(let m of a.get(f)??[])M(r,m.symbolId,t)}let c=new Map;for(let t of n.scopedDefinitions()){if(g(t.relativePath)!=="clojure")continue;let i=c.get(t.leaf)??[];i.push(t),c.set(t.leaf,i)}for(let t of l){let i=b(e,t.relativePath);if(i){for(let f of i.callSites)if(!(f.line<t.startLine||f.line>t.endLine))for(let m of c.get(f.calleeLeaf)??[])M(u,t.symbolId,m.relativePath)}}return{referencesBySymbolId:r,calleesBySymbolId:u}}function M(e,n,o){let r=e.get(n);if(r){r.add(o);return}e.set(n,new Set([o]))}function D(e){return Math.round(e*1e3)/1e3}export{H as a};
2
+ //# sourceMappingURL=chunk-EVCSXWER.js.map
@@ -0,0 +1,67 @@
1
+ import{execFileSync as k}from"child_process";import{createHash as b}from"crypto";import{lstatSync as F,readdirSync as V,readFileSync as w,readlinkSync as A,realpathSync as m}from"fs";import{isAbsolute as _,join as y,relative as I,sep as E}from"path";function ne(e,t){let n=e.split("/").at(-1)??e;if(C.has(n)||n===".scipquery.json"||/^tsconfig(?:\..+)?\.json$/.test(n))return"config";if(/\.d\.(?:ts|mts|cts)$/.test(e.toLowerCase()))return"ambient";let s=e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:"";return t.some(r=>(D[r]??[]).includes(s))?"source":"other"}function re(e){return[...new Set((e??[]).map(t=>t.trim()).filter(Boolean))].sort((t,n)=>t.localeCompare(n))}function G(e){return($(e)??O(e)).filter(t=>t&&!S(t)).sort()}function ie(e,t={}){let n=G(e).filter(r=>!t.language||L(r,t.language,t.markerFiles)).filter(r=>!t.includePath||t.includePath(r)),s=m(e);return n.map(r=>{let i=y(e,r);try{if(F(i).isSymbolicLink()){let o=m(i),c=I(s,o);if(c===".."||c.startsWith(`..${E}`)||_(c))throw new Error("external symlink");let l=A(i);return{path:r,size:Buffer.byteLength(l),hash:b("sha256").update("symlink\0").update(l).digest("hex")}}let a=w(i);return{path:r,size:a.byteLength,hash:b("sha256").update(a).digest("hex")}}catch{return{path:r,size:-1,hash:"unreadable"}}})}function L(e,t,n){let s=e.split("/").at(-1)??e;if(n?.includes(e)||n?.includes(s)||C.has(s))return!0;let r=e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:"";return(D[t]??[]).includes(r)}function $(e){try{return k("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"]}).split(`
2
+ `).filter(Boolean)}catch{return null}}function O(e){let t=[],n=[""];for(;n.length>0;){let s=n.pop(),r=s?y(e,s):e,i;try{i=V(r,{withFileTypes:!0})}catch{continue}for(let a of i){let o=s?`${s}/${a.name}`:a.name;if(a.isDirectory()){S(o)||n.push(o);continue}t.push(o)}}return t}function S(e){let t=e.split("/");return e==="meta.json"||t.some(n=>K.has(n))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var K=new Set([".git","node_modules",".scipquery-cache",".scipquery-generations",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]),C=new Set(["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lockb","tsconfig.json","tsconfig.base.json","pyproject.toml","setup.py","setup.cfg","Cargo.toml","Cargo.lock","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","build.sbt","compile_commands.json","CMakeLists.txt","Makefile","Gemfile","Gemfile.lock","composer.json","composer.lock","pubspec.yaml","pubspec.lock","deps.edn","project.clj","bb.edn","shadow-cljs.edn"]),D={typescript:[".ts",".tsx",".mts",".cts"],javascript:[".js",".jsx",".mjs",".cjs"],java:[".java"],scala:[".scala"],kotlin:[".kt",".kts"],rust:[".rs"],python:[".py",".pyi"],ruby:[".rb"],go:[".go"],cpp:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"],c:[".c",".h"],csharp:[".cs"],vb:[".vb"],dart:[".dart"],php:[".php"],clojure:[".clj",".cljs",".cljc"]};import T from"ignore";import{readFileSync as W,existsSync as x,readdirSync as M}from"fs";import{dirname as g,isAbsolute as v,join as p,relative as N,resolve as R}from"path";function le(e){let t=T();return z(e,t)||t.add(U),{isIgnored:s=>f(t,e,s),filter:s=>s.filter(r=>!f(t,e,r))}}function z(e,t){let n=new Set,s=(a,o)=>{if(!(n.has(a)||!x(a)))try{let c=W(a,"utf-8");t.add(o?B(c,o):c),n.add(a)}catch{}},r=g(e),i=0;for(;r!==g(r)&&i<5&&(s(p(r,".gitignore"),""),!x(p(r,".git")));)r=g(r),i++;return j(e,"",t,s),n.size>0}function j(e,t,n,s){let r=t?p(e,t):e;s(p(r,".gitignore"),t);let i;try{i=M(r,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory()||a.name===".git")continue;let o=t?`${t}/${a.name}`:a.name;f(n,e,`${o}/`)||j(e,o,n,s)}}function B(e,t){let n=t.replaceAll("\\","/").replace(/\/+$/,"");return e.split(/\r?\n/).map(s=>q(s,n)).join(`
3
+ `)}function q(e,t){let n=e.trimStart();if(!n||n.startsWith("#"))return e;let s=e.slice(0,e.length-n.length),r=n.startsWith("!"),i=r?n.slice(1):n;if(!i||i.startsWith("#"))return e;let a=i.startsWith("/"),o=a?i.slice(1):i,u=(o.endsWith("/")?o.slice(0,-1):o).includes("/")||a?`${t}/${o}`:`${t}/**/${o}`;return`${s}${r?"!":""}${u}`}var U=`
4
+ # Dependencies
5
+ node_modules/
6
+ vendor/
7
+ .bundle/
8
+
9
+ # Build output
10
+ dist/
11
+ build/
12
+ out/
13
+ target/
14
+ bin/
15
+ obj/
16
+
17
+ # Python
18
+ __pycache__/
19
+ *.pyc
20
+ *.pyo
21
+ .venv/
22
+ venv/
23
+ .env/
24
+ env/
25
+ *.egg-info/
26
+
27
+ # Rust
28
+ target/
29
+
30
+ # Java / Kotlin / Scala
31
+ *.class
32
+ .gradle/
33
+ .mvn/
34
+
35
+ # C# / .NET
36
+ bin/
37
+ obj/
38
+ packages/
39
+
40
+ # Go
41
+ vendor/
42
+
43
+ # Dart
44
+ .dart_tool/
45
+ build/
46
+
47
+ # PHP
48
+ vendor/
49
+
50
+ # IDE / OS
51
+ .idea/
52
+ .vscode/
53
+ *.swp
54
+ *.swo
55
+ .DS_Store
56
+ Thumbs.db
57
+
58
+ # Type definitions (often noise in queries)
59
+ *.d.ts
60
+ `;function f(e,t,n){let s=H(t,n);if(!s)return!1;try{return e.ignores(s)}catch{return!1}}function H(e,t){if(!t||t===".")return null;if(!v(t)&&!t.startsWith(".."))return t.replaceAll("\\","/");let n=v(t)?t:R(e,t),s=N(e,n).replaceAll("\\","/");return!s||s==="."||s.startsWith("..")?null:s}function pe(e,t={}){let n=t.scope?"AND relative_path LIKE ?":"",s=t.like?"AND relative_path LIKE ?":"",r=[...t.scope?[`%${t.scope}%`]:[],...t.like?[t.like]:[]],i=e.all(`SELECT relative_path
61
+ FROM documents
62
+ WHERE 1 = 1
63
+ ${e.pathExclusionsFor("documents")}
64
+ ${n}
65
+ ${s}
66
+ ORDER BY relative_path`,...r).map(o=>o.relative_path),a=t.extensions?i.filter(o=>t.extensions.some(c=>o.toLowerCase().endsWith(c.toLowerCase()))):i;return t.includeIgnored===!1?a.filter(o=>!e.isIgnored(o)):a}var J=[];function d(e){e.groups.length>0&&J.push(e)}function P(){let e=new WeakMap;return{cache:e,ensure(t){let n=e.get(t);return n||(n=new Map,e.set(t,n)),n}}}function he(e,t){let{cache:n,ensure:s}=P(),r={get(i,a,o){let c=s(i);if(c.has(a))return c.get(a);let l=o();return c.set(a,l),l},invalidate(i,a){n.get(i)?.delete(a)},invalidateAll(i){n.delete(i)},size(i){return n.get(i)?.size??0}};return d({name:e,groups:t.clearGroups,clearAll:i=>r.invalidateAll(i),clearFile:(i,a)=>r.invalidate(i,a)}),r}function be(e,t){let n=new WeakMap,s={get(r,i){let a=n.get(r);if(a)return a.value;let o=i();return n.set(r,{value:o}),o},invalidate(r){n.delete(r)},has(r){return n.has(r)}};return d({name:e,groups:t.clearGroups,clearAll:r=>s.invalidate(r)}),s}var X={clearGroups:["whole-project","source-file"]};function me(e){return Y(e,X)}function Y(e,t){let{cache:n,ensure:s}=P(),r={get(i,a,o,c){let l=s(i),u=l.get(a);if(u&&u.source===o)return u.value;let h=c();return l.set(a,{source:o,value:h}),h},invalidate(i,a){n.get(i)?.delete(a)},invalidateAll(i){n.delete(i)}};return d({name:e,groups:t.clearGroups,clearAll:i=>r.invalidateAll(i),clearFile:(i,a)=>r.invalidate(i,a)}),r}export{d as a,he as b,be as c,me as d,Y as e,pe as f,ne as g,re as h,ie as i,le as j};
67
+ //# sourceMappingURL=chunk-FFIYGYQR.js.map
@@ -0,0 +1,20 @@
1
+ import{p as C}from"./chunk-NLVKD45E.js";import{a as _}from"./chunk-64MNV6AB.js";import{c as F,g as S,i as I,s as f,w as D,x as P}from"./chunk-WFRZGMWJ.js";var N=D({kind:"file-dependency-graph",invalidation:P("file-dependency-graph"),serialize:e=>JSON.stringify(e),deserialize:R}),O=F("file-dep-graph",{clearGroups:["whole-project"]});function K(e,r,o={}){let t=o.scipEdges??"all-references";return O.get(e,`${t}:${r??""}`,()=>{let s=new Set(_(e,{includeIgnored:!1})),i=I(e),a=b(r,t),d=0,l=0,m=null,h=!1,c=0,y=0;return f("file-dep-graph.product",()=>{if(i){let n=N.read(e,a,i);if(n){h=!0;let u=w(n);return d=n.sourceFileCount,l=n.sourceEdgeCount,c=n.scipEdgeCount,y=u.size,m=n.sourceImportFingerprint,u}}let p=f("file-dep-graph.source-imports",()=>{let n=A(e,s,r);return d=n.files.length,l=n.edges.length,m=n.fingerprint,n},()=>({scope:r??null,files:d,edges:l})),g=new Map,E=(n,u)=>M(e,g,s,n,u);f("file-dep-graph.scip-edges",()=>{for(let n of J(e,r,t))c+=1,E(n.from_file,n.to_file)},()=>({scope:r??null,edges:c}));for(let n of p.edges)E(n.fromFile,n.toFile);return y=g.size,i&&N.write(e,a,i,{sourceImportFingerprint:p.fingerprint,sourceFileCount:p.files.length,sourceEdgeCount:p.edges.length,scipEdgeCount:c,graph:v(g)}),g},()=>({scope:r??null,available:i!==null,hit:h,files:d,sourceEdges:l,scipEdges:c,graphFiles:y,sourceImportFingerprint:m}))})}function A(e,r,o){let t=[],s=[];for(let i of r)if(!(o&&!i.includes(o))){t.push(i);for(let a of C(e,i))a.sourcePath&&s.push({fromFile:i,toFile:a.sourcePath})}return{files:t,edges:s,fingerprint:G(t,s)}}function G(e,r){let o=r.map(t=>`${t.fromFile}\0${t.toFile}`).sort();return S(JSON.stringify({files:e,edges:o}))}function b(e,r){return`edge-mode-v2:${r}:${e??"<all>"}`}function v(e){return[...e].map(([r,o])=>[r,[...o]])}function w(e){return new Map(e.graph.map(([r,o])=>[r,new Set(o)]))}function R(e){let r=JSON.parse(e);return $(r)?r:null}function $(e){if(!e||typeof e!="object")return!1;let r=e;return typeof r.sourceImportFingerprint=="string"&&typeof r.sourceFileCount=="number"&&typeof r.sourceEdgeCount=="number"&&typeof r.scipEdgeCount=="number"&&Array.isArray(r.graph)&&r.graph.every(k)}function k(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&Array.isArray(e[1])&&e[1].every(r=>typeof r=="string")}function J(e,r,o){let t=r?"AND d1.relative_path LIKE ?":"",s=r?[`%${r}%`]:[],i=o==="imports-only"?"AND m.role = 2":"AND m.role != 1";return e.all(`SELECT DISTINCT
2
+ d1.relative_path AS from_file,
3
+ d2.relative_path AS to_file
4
+ FROM mentions m
5
+ JOIN chunks c ON m.chunk_id = c.id
6
+ JOIN documents d1 ON c.document_id = d1.id
7
+ JOIN global_symbols gs ON m.symbol_id = gs.id
8
+ JOIN (
9
+ SELECT m2.symbol_id, c2.document_id
10
+ FROM mentions m2
11
+ JOIN chunks c2 ON m2.chunk_id = c2.id
12
+ WHERE m2.role = 1
13
+ GROUP BY m2.symbol_id
14
+ ) sym_def ON sym_def.symbol_id = gs.id
15
+ JOIN documents d2 ON sym_def.document_id = d2.id
16
+ WHERE d1.id != d2.id
17
+ ${i}
18
+ ${e.pathExclusionsFor("d1","d2")}
19
+ ${t}`,...s)}function M(e,r,o,t,s){if(t===s||e.isIgnored(t)||e.isIgnored(s)||!o.has(s))return;let i=r.get(t);i||(i=new Set,r.set(t,i)),i.add(s)}export{K as a};
20
+ //# sourceMappingURL=chunk-G4KQ7S74.js.map