@mcp-graph-workflow/mcp-graph 5.24.1 → 5.26.0
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.
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +2 -0
- package/dist/api/router.js.map +1 -1
- package/dist/api/routes/translation-project.d.ts +8 -0
- package/dist/api/routes/translation-project.d.ts.map +1 -0
- package/dist/api/routes/translation-project.js +338 -0
- package/dist/api/routes/translation-project.js.map +1 -0
- package/dist/api/routes/translation.d.ts.map +1 -1
- package/dist/api/routes/translation.js +105 -1
- package/dist/api/routes/translation.js.map +1 -1
- package/dist/core/code/code-indexer.d.ts +2 -0
- package/dist/core/code/code-indexer.d.ts.map +1 -1
- package/dist/core/code/code-indexer.js +9 -3
- package/dist/core/code/code-indexer.js.map +1 -1
- package/dist/core/code/code-types.d.ts +4 -0
- package/dist/core/code/code-types.d.ts.map +1 -1
- package/dist/core/code/code-types.js +1 -0
- package/dist/core/code/code-types.js.map +1 -1
- package/dist/core/code/ts-analyzer.d.ts.map +1 -1
- package/dist/core/code/ts-analyzer.js +77 -6
- package/dist/core/code/ts-analyzer.js.map +1 -1
- package/dist/core/knowledge/knowledge-packager.d.ts +44 -0
- package/dist/core/knowledge/knowledge-packager.d.ts.map +1 -0
- package/dist/core/knowledge/knowledge-packager.js +311 -0
- package/dist/core/knowledge/knowledge-packager.js.map +1 -0
- package/dist/core/store/migrations.d.ts.map +1 -1
- package/dist/core/store/migrations.js +41 -0
- package/dist/core/store/migrations.js.map +1 -1
- package/dist/core/translation/parsers/cpp-parser-adapter.d.ts +9 -0
- package/dist/core/translation/parsers/cpp-parser-adapter.d.ts.map +1 -0
- package/dist/core/translation/parsers/cpp-parser-adapter.js +45 -0
- package/dist/core/translation/parsers/cpp-parser-adapter.js.map +1 -0
- package/dist/core/translation/parsers/dart-parser-adapter.d.ts +9 -0
- package/dist/core/translation/parsers/dart-parser-adapter.d.ts.map +1 -0
- package/dist/core/translation/parsers/dart-parser-adapter.js +44 -0
- package/dist/core/translation/parsers/dart-parser-adapter.js.map +1 -0
- package/dist/core/translation/parsers/elixir-parser-adapter.d.ts +9 -0
- package/dist/core/translation/parsers/elixir-parser-adapter.d.ts.map +1 -0
- package/dist/core/translation/parsers/elixir-parser-adapter.js +45 -0
- package/dist/core/translation/parsers/elixir-parser-adapter.js.map +1 -0
- package/dist/core/translation/parsers/haskell-parser-adapter.d.ts +9 -0
- package/dist/core/translation/parsers/haskell-parser-adapter.d.ts.map +1 -0
- package/dist/core/translation/parsers/haskell-parser-adapter.js +38 -0
- package/dist/core/translation/parsers/haskell-parser-adapter.js.map +1 -0
- package/dist/core/translation/parsers/kotlin-parser-adapter.d.ts +9 -0
- package/dist/core/translation/parsers/kotlin-parser-adapter.d.ts.map +1 -0
- package/dist/core/translation/parsers/kotlin-parser-adapter.js +43 -0
- package/dist/core/translation/parsers/kotlin-parser-adapter.js.map +1 -0
- package/dist/core/translation/parsers/lua-parser-adapter.d.ts +9 -0
- package/dist/core/translation/parsers/lua-parser-adapter.d.ts.map +1 -0
- package/dist/core/translation/parsers/lua-parser-adapter.js +42 -0
- package/dist/core/translation/parsers/lua-parser-adapter.js.map +1 -0
- package/dist/core/translation/parsers/php-parser-adapter.d.ts +9 -0
- package/dist/core/translation/parsers/php-parser-adapter.d.ts.map +1 -0
- package/dist/core/translation/parsers/php-parser-adapter.js +44 -0
- package/dist/core/translation/parsers/php-parser-adapter.js.map +1 -0
- package/dist/core/translation/parsers/scala-parser-adapter.d.ts +9 -0
- package/dist/core/translation/parsers/scala-parser-adapter.d.ts.map +1 -0
- package/dist/core/translation/parsers/scala-parser-adapter.js +43 -0
- package/dist/core/translation/parsers/scala-parser-adapter.js.map +1 -0
- package/dist/core/translation/parsers/swift-parser-adapter.d.ts +9 -0
- package/dist/core/translation/parsers/swift-parser-adapter.d.ts.map +1 -0
- package/dist/core/translation/parsers/swift-parser-adapter.js +44 -0
- package/dist/core/translation/parsers/swift-parser-adapter.js.map +1 -0
- package/dist/core/translation/project-translation-orchestrator.d.ts +65 -0
- package/dist/core/translation/project-translation-orchestrator.d.ts.map +1 -0
- package/dist/core/translation/project-translation-orchestrator.js +336 -0
- package/dist/core/translation/project-translation-orchestrator.js.map +1 -0
- package/dist/core/translation/translation-orchestrator.d.ts +6 -2
- package/dist/core/translation/translation-orchestrator.d.ts.map +1 -1
- package/dist/core/translation/translation-orchestrator.js +35 -2
- package/dist/core/translation/translation-orchestrator.js.map +1 -1
- package/dist/core/translation/translation-project-store.d.ts +40 -0
- package/dist/core/translation/translation-project-store.d.ts.map +1 -0
- package/dist/core/translation/translation-project-store.js +195 -0
- package/dist/core/translation/translation-project-store.js.map +1 -0
- package/dist/core/translation/translation-project-types.d.ts +98 -0
- package/dist/core/translation/translation-project-types.d.ts.map +1 -0
- package/dist/core/translation/translation-project-types.js +84 -0
- package/dist/core/translation/translation-project-types.js.map +1 -0
- package/dist/core/translation/zip-extractor.d.ts +4 -0
- package/dist/core/translation/zip-extractor.d.ts.map +1 -0
- package/dist/core/translation/zip-extractor.js +194 -0
- package/dist/core/translation/zip-extractor.js.map +1 -0
- package/dist/mcp/tools/analyze-translation.d.ts.map +1 -1
- package/dist/mcp/tools/analyze-translation.js +5 -5
- package/dist/mcp/tools/analyze-translation.js.map +1 -1
- package/dist/mcp/tools/index.d.ts.map +1 -1
- package/dist/mcp/tools/index.js +2 -0
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/knowledge-export.d.ts +8 -0
- package/dist/mcp/tools/knowledge-export.d.ts.map +1 -0
- package/dist/mcp/tools/knowledge-export.js +100 -0
- package/dist/mcp/tools/knowledge-export.js.map +1 -0
- package/dist/mcp/tools/reindex-knowledge.js +1 -1
- package/dist/mcp/tools/reindex-knowledge.js.map +1 -1
- package/dist/mcp/tools/translate-code.d.ts.map +1 -1
- package/dist/mcp/tools/translate-code.js +7 -2
- package/dist/mcp/tools/translate-code.js.map +1 -1
- package/dist/mcp/tools/translation-jobs.d.ts.map +1 -1
- package/dist/mcp/tools/translation-jobs.js +4 -1
- package/dist/mcp/tools/translation-jobs.js.map +1 -1
- package/dist/schemas/knowledge-package.schema.d.ts +87 -0
- package/dist/schemas/knowledge-package.schema.d.ts.map +1 -0
- package/dist/schemas/knowledge-package.schema.js +48 -0
- package/dist/schemas/knowledge-package.schema.js.map +1 -0
- package/dist/web/dashboard/dist/assets/{benchmark-tab-sjsZBd-4.js → benchmark-tab-BAfHRc8R.js} +1 -1
- package/dist/web/dashboard/dist/assets/{circle-alert-DcTbCUEa.js → circle-alert-Xp4yHA83.js} +1 -1
- package/dist/web/dashboard/dist/assets/{context-tab-DNMJ2Pv-.js → context-tab-WZWpYE4Q.js} +1 -1
- package/dist/web/dashboard/dist/assets/{gitnexus-tab-CZ9LJbwz.js → gitnexus-tab-BL3gMYaZ.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-section-BdcXKKoS.js → graph-section-B-cObR6x.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-tab-CFzux3kf.js → graph-tab-DC5Iama3.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-utils-_8jpWA5z.js → graph-utils-CdV9peLO.js} +1 -1
- package/dist/web/dashboard/dist/assets/index-CTdsOcRa.css +1 -0
- package/dist/web/dashboard/dist/assets/{index-CITYTuX5.js → index-DfEJaZLA.js} +46 -46
- package/dist/web/dashboard/dist/assets/{index-DSI2SYWO.js → index-iWhfMJa8.js} +1 -1
- package/dist/web/dashboard/dist/assets/{index-Bny20bel.js → index-z9HSPrpH.js} +1 -1
- package/dist/web/dashboard/dist/assets/{insights-tab-DUA76KUY.js → insights-tab-Cu1cH-bN.js} +1 -1
- package/dist/web/dashboard/dist/assets/{journey-tab-FTd6jBta.js → journey-tab-BtqgC4Wj.js} +1 -1
- package/dist/web/dashboard/dist/assets/languages-tab-BeJF5wPH.js +128 -0
- package/dist/web/dashboard/dist/assets/{loader-circle-D1DpGd2u.js → loader-circle-MkZSJbxU.js} +1 -1
- package/dist/web/dashboard/dist/assets/{logs-tab-CzL36_Qy.js → logs-tab-CA2dPs0v.js} +1 -1
- package/dist/web/dashboard/dist/assets/{lsp-tab-DdHhJq_H.js → lsp-tab-DuF6UV_3.js} +9 -19
- package/dist/web/dashboard/dist/assets/{memories-tab-CzgCahnV.js → memories-tab-blOtravG.js} +1 -1
- package/dist/web/dashboard/dist/assets/{prd-backlog-tab-C8Cl7swI.js → prd-backlog-tab-DtwzxFyr.js} +1 -1
- package/dist/web/dashboard/dist/assets/{refresh-cw-DSYiHmbh.js → refresh-cw-VhHh0g7N.js} +1 -1
- package/dist/web/dashboard/dist/assets/{siebel-tab-B4XOaUGz.js → siebel-tab-DP6xoWD8.js} +3 -3
- package/dist/web/dashboard/dist/assets/{skills-tab-CkpnwPJY.js → skills-tab-Tspln3N1.js} +1 -1
- package/dist/web/dashboard/dist/assets/{style-BOQDk6qp.js → style-CsU39IOg.js} +1 -1
- package/dist/web/dashboard/dist/assets/triangle-alert-ZnXg11jO.js +26 -0
- package/dist/web/dashboard/dist/index.html +2 -2
- package/package.json +4 -2
- package/dist/web/dashboard/dist/assets/index-CvAguK65.css +0 -1
- package/dist/web/dashboard/dist/assets/languages-tab-B_nhFL2q.js +0 -70
- package/dist/web/dashboard/dist/assets/triangle-alert-Bf6Ly19h.js +0 -16
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import{c as y,r as u,a as C,j as e,d as K,u as ie,L as xe,G as B}from"./index-DfEJaZLA.js";import{L as A}from"./loader-circle-MkZSJbxU.js";import{T as W,C as te,a as se,S as ae,F as re}from"./triangle-alert-ZnXg11jO.js";import{R as J}from"./refresh-cw-VhHh0g7N.js";/**
|
|
2
|
+
* @license lucide-react v1.7.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const ue=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],me=y("arrow-left-right",ue);/**
|
|
7
|
+
* @license lucide-react v1.7.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const he=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],pe=y("arrow-left",he);/**
|
|
12
|
+
* @license lucide-react v1.7.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const ge=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],q=y("book-open",ge);/**
|
|
17
|
+
* @license lucide-react v1.7.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const fe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],I=y("check",fe);/**
|
|
22
|
+
* @license lucide-react v1.7.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const be=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],je=y("circle-check-big",be);/**
|
|
27
|
+
* @license lucide-react v1.7.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const Ne=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ne=y("circle-check",Ne);/**
|
|
32
|
+
* @license lucide-react v1.7.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const ye=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],ve=y("circle-x",ye);/**
|
|
37
|
+
* @license lucide-react v1.7.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/const we=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],Ce=y("clock",we);/**
|
|
42
|
+
* @license lucide-react v1.7.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const ke=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Z=y("copy",ke);/**
|
|
47
|
+
* @license lucide-react v1.7.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/const Se=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Me=y("cpu",Se);/**
|
|
52
|
+
* @license lucide-react v1.7.0 - ISC
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the ISC license.
|
|
55
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/const $e=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],U=y("download",$e);/**
|
|
57
|
+
* @license lucide-react v1.7.0 - ISC
|
|
58
|
+
*
|
|
59
|
+
* This source code is licensed under the ISC license.
|
|
60
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
+
*/const ze=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Fe=y("eye",ze);/**
|
|
62
|
+
* @license lucide-react v1.7.0 - ISC
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the ISC license.
|
|
65
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
+
*/const Le=[["path",{d:"M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5",key:"4pqfef"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 12v-1",key:"1ej8lb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M8 7V6",key:"1nbb54"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]],Te=y("file-archive",Le);/**
|
|
67
|
+
* @license lucide-react v1.7.0 - ISC
|
|
68
|
+
*
|
|
69
|
+
* This source code is licensed under the ISC license.
|
|
70
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
+
*/const Ae=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Re=y("file-code-corner",Ae);/**
|
|
72
|
+
* @license lucide-react v1.7.0 - ISC
|
|
73
|
+
*
|
|
74
|
+
* This source code is licensed under the ISC license.
|
|
75
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
+
*/const Pe=[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]],De=y("files",Pe);/**
|
|
77
|
+
* @license lucide-react v1.7.0 - ISC
|
|
78
|
+
*
|
|
79
|
+
* This source code is licensed under the ISC license.
|
|
80
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
+
*/const _e=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Ee=y("folder",_e);/**
|
|
82
|
+
* @license lucide-react v1.7.0 - ISC
|
|
83
|
+
*
|
|
84
|
+
* This source code is licensed under the ISC license.
|
|
85
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
+
*/const Ie=[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]],Ue=y("inbox",Ie);/**
|
|
87
|
+
* @license lucide-react v1.7.0 - ISC
|
|
88
|
+
*
|
|
89
|
+
* This source code is licensed under the ISC license.
|
|
90
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
+
*/const Oe=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],le=y("play",Oe);/**
|
|
92
|
+
* @license lucide-react v1.7.0 - ISC
|
|
93
|
+
*
|
|
94
|
+
* This source code is licensed under the ISC license.
|
|
95
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
+
*/const Ge=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Ve=y("rotate-ccw",Ge);/**
|
|
97
|
+
* @license lucide-react v1.7.0 - ISC
|
|
98
|
+
*
|
|
99
|
+
* This source code is licensed under the ISC license.
|
|
100
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
+
*/const He=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Be=y("shield",He);/**
|
|
102
|
+
* @license lucide-react v1.7.0 - ISC
|
|
103
|
+
*
|
|
104
|
+
* This source code is licensed under the ISC license.
|
|
105
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
+
*/const Je=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],qe=y("sparkles",Je);/**
|
|
107
|
+
* @license lucide-react v1.7.0 - ISC
|
|
108
|
+
*
|
|
109
|
+
* This source code is licensed under the ISC license.
|
|
110
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
+
*/const Ke=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],We=y("trash-2",Ke);/**
|
|
112
|
+
* @license lucide-react v1.7.0 - ISC
|
|
113
|
+
*
|
|
114
|
+
* This source code is licensed under the ISC license.
|
|
115
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
+
*/const Ze=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Qe=y("upload",Ze),Q={phase:"idle",analysis:null,prepareResult:null,finalizeResult:null,error:null,loading:!1};function Xe(){var l;const[s,t]=u.useState(Q),a=u.useCallback(async(c,m,x="snippet")=>{t(d=>({...d,phase:"analyzing",loading:!0,error:null}));try{const p=new Promise((b,r)=>setTimeout(()=>r(new Error("Analysis timed out after 30s. Please try again.")),3e4)),g=await Promise.race([C.translationCreateJob(c,m,x),p]);t({phase:"prepared",analysis:g.analysis,prepareResult:g,finalizeResult:null,error:null,loading:!1})}catch(d){t(p=>({...p,phase:"error",error:d instanceof Error?d.message:"Analysis failed",loading:!1}))}},[]),n=u.useCallback(async c=>{var x;const m=(x=s.prepareResult)==null?void 0:x.jobId;if(!m){t(d=>({...d,phase:"error",error:"No active job to finalize"}));return}t(d=>({...d,phase:"finalizing",loading:!0,error:null}));try{const d=await C.translationFinalize(m,c);t(p=>({...p,phase:"done",finalizeResult:d,loading:!1}))}catch(d){t(p=>({...p,phase:"error",error:d instanceof Error?d.message:"Finalize failed",loading:!1}))}},[(l=s.prepareResult)==null?void 0:l.jobId]),o=u.useCallback(()=>{t(Q)},[]);return[s,{analyze:a,finalize:n,reset:o}]}function Ye(){const[s,t]=u.useState([]),[a,n]=u.useState(null),[o,l]=u.useState(!0),[c,m]=u.useState(null),x=u.useCallback(async()=>{l(!0),m(null);try{const[p,g]=await Promise.all([C.translationListJobs(),C.translationStats()]);t(p.jobs),n(g)}catch(p){m(p instanceof Error?p.message:"Failed to load history")}finally{l(!1)}},[]),d=u.useCallback(async p=>{try{await C.translationDeleteJob(p),t(b=>b.filter(r=>r.id!==p));const g=await C.translationStats();n(g)}catch(g){m(g instanceof Error?g.message:"Delete failed")}},[]);return u.useEffect(()=>{x()},[x]),[{jobs:s,stats:a,loading:o,error:c},{refresh:x,deleteJob:d}]}const X={mode:"idle",project:null,files:[],summary:null,selectedFileId:null,error:null,loading:!1};function et(){var b;const[s,t]=u.useState(X),a=u.useRef(null),n=u.useCallback(async(r,i,h)=>{t(f=>({...f,mode:"uploading",loading:!0,error:null}));try{const f=await C.translationUploadProject(r,i,h);a.current=f.project.id,t({mode:"ready",project:f.project,files:f.files,summary:null,selectedFileId:null,error:null,loading:!1})}catch(f){t(w=>({...w,mode:"error",error:f instanceof Error?f.message:"Upload failed",loading:!1}))}},[]),o=u.useCallback(async r=>{t(i=>({...i,loading:!0,error:null}));try{const i=await C.translationGetProject(r);a.current=i.project.id,t({mode:"ready",project:i.project,files:i.files,summary:null,selectedFileId:null,error:null,loading:!1})}catch(i){t(h=>({...h,mode:"error",error:i instanceof Error?i.message:"Failed to load project",loading:!1}))}},[]),l=u.useCallback(r=>{t(i=>({...i,selectedFileId:r}))},[]),c=u.useCallback(async r=>{const i=a.current;if(!i){t(h=>({...h,mode:"error",error:"No active project"}));return}t(h=>({...h,loading:!0,error:null}));try{await C.translationPrepareFiles(i,r);const h=await C.translationGetProject(i);t(f=>({...f,project:h.project,files:h.files,loading:!1}))}catch(h){t(f=>({...f,error:h instanceof Error?h.message:"Prepare failed",loading:!1}))}},[]),m=u.useCallback(async(r,i)=>{const h=a.current;if(!h){t(f=>({...f,mode:"error",error:"No active project"}));return}t(f=>({...f,loading:!0,error:null}));try{await C.translationFinalizeFile(h,r,i);const f=await C.translationGetProject(h);t(w=>({...w,project:f.project,files:f.files,loading:!1}))}catch(f){t(w=>({...w,error:f instanceof Error?f.message:"Finalize failed",loading:!1}))}},[]),x=u.useCallback(async()=>{var i;const r=a.current;if(!r){t(h=>({...h,mode:"error",error:"No active project"}));return}t(h=>({...h,loading:!0,error:null}));try{const h=await C.translationDownloadProject(r),f=(i=s.project)!=null&&i.name?`${s.project.name}-translated.zip`:"translated-project.zip",w=URL.createObjectURL(h),k=document.createElement("a");k.href=w,k.download=f,k.click(),URL.revokeObjectURL(w),t(S=>({...S,loading:!1}))}catch(h){t(f=>({...f,error:h instanceof Error?h.message:"Download failed",loading:!1}))}},[(b=s.project)==null?void 0:b.name]),d=u.useCallback(async r=>{const i=a.current;if(!i){t(h=>({...h,mode:"error",error:"No active project"}));return}t(h=>({...h,loading:!0,error:null}));try{const h=await C.translationDownloadFile(i,r),f=s.files.find($=>$.id===r),w=f!=null&&f.filePath?f.filePath.split("/").pop()??"translated-file":"translated-file",k=URL.createObjectURL(h),S=document.createElement("a");S.href=k,S.download=w,S.click(),URL.revokeObjectURL(k),t($=>({...$,loading:!1}))}catch(h){t(f=>({...f,error:h instanceof Error?h.message:"File download failed",loading:!1}))}},[s.files]),p=u.useCallback(async()=>{const r=a.current;if(!r){t(i=>({...i,mode:"error",error:"No active project"}));return}t(i=>({...i,loading:!0,error:null}));try{const i=await C.translationProjectSummary(r);t(h=>({...h,summary:i,loading:!1}))}catch(i){t(h=>({...h,error:i instanceof Error?i.message:"Failed to refresh summary",loading:!1}))}},[]),g=u.useCallback(()=>{a.current=null,t(X)},[]);return[s,{upload:n,loadProject:o,selectFile:l,prepareFiles:c,finalizeFile:m,downloadProject:x,downloadFile:d,refreshSummary:p,reset:g}]}const tt=["python","javascript","typescript","java","csharp","go","rust","ruby","php","swift","kotlin","scala","cpp"],st=["snippet","function","module"];function at({sourceCode:s,setSourceCode:t,targetLanguage:a,setTargetLanguage:n,scope:o,setScope:l,generatedCode:c,setGeneratedCode:m,translation:x,onAnalyze:d,onFinalize:p,onReset:g}){var T,_,E;const{phase:b,prepareResult:r,error:i,loading:h}=x,f=b==="idle"||b==="error",w=b==="prepared",k=b==="done",[S,$]=u.useState(!1),G=()=>{r!=null&&r.prompt&&(navigator.clipboard.writeText(r.prompt),$(!0),setTimeout(()=>$(!1),2e3))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"Source Code"}),e.jsx("p",{className:"text-[10px] text-muted mt-0.5",children:"Paste the code you want to translate"})]}),e.jsxs("div",{className:"p-4 relative",children:[!f&&!w&&!k&&e.jsx("div",{className:"absolute inset-0 bg-surface/20 backdrop-blur-[1px] rounded-lg z-10 pointer-events-none"}),e.jsx("textarea",{value:s,onChange:v=>t(v.target.value),placeholder:"// Paste your code here...",rows:10,disabled:!f,className:"w-full px-3 py-2 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent font-mono disabled:opacity-60 disabled:cursor-not-allowed disabled:bg-surface/50"}),e.jsxs("div",{className:"flex items-center gap-3 mt-3",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-3 gap-3",children:[(T=x.analysis)!=null&&T.detectedLanguage?e.jsxs("div",{className:"px-3 py-1.5 text-xs rounded-md border border-edge bg-surface/50 text-muted flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-muted/70",children:"from:"}),e.jsx("span",{className:"text-foreground font-medium",children:x.analysis.detectedLanguage})]}):e.jsx("div",{className:"px-3 py-1.5 text-xs rounded-md border border-edge/50 bg-surface/30 text-muted/50 flex items-center gap-1.5",children:e.jsx("span",{className:"text-[10px]",children:"from: auto-detect"})}),e.jsx("select",{value:a,onChange:v=>n(v.target.value),disabled:!f,className:"px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-50",children:tt.map(v=>e.jsx("option",{value:v,children:v},v))}),e.jsx("div",{className:"flex gap-1",children:st.map(v=>e.jsx("button",{onClick:()=>l(v),disabled:!f,className:`flex-1 px-2 py-1.5 text-[10px] font-medium rounded-md border transition-colors disabled:opacity-50 ${o===v?"border-accent bg-accent/10 text-accent":"border-edge bg-surface text-muted hover:text-foreground"}`,children:v},v))})]}),f&&e.jsxs("button",{onClick:d,disabled:!s.trim()||h,className:"flex items-center gap-1.5 px-4 py-1.5 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 disabled:opacity-50 transition-opacity",children:[h?e.jsx(A,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(le,{className:"w-3.5 h-3.5"}),h?"Analyzing...":"Analyze"]}),(w||k)&&e.jsxs("button",{onClick:g,className:"flex items-center gap-1.5 px-4 py-1.5 text-xs font-medium rounded-md border border-edge text-muted hover:text-foreground transition-colors",children:[e.jsx(Ve,{className:"w-3.5 h-3.5"}),"New"]}),k&&((E=(_=x.finalizeResult)==null?void 0:_.job)==null?void 0:E.targetCode)&&e.jsxs("button",{onClick:()=>{var N,M;const v=(M=(N=x.finalizeResult)==null?void 0:N.job)==null?void 0:M.targetCode;if(!v)return;const j=new Blob([v],{type:"text/plain"}),F=URL.createObjectURL(j),L=document.createElement("a");L.href=F,L.download="translated.txt",L.click(),URL.revokeObjectURL(F)},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-green-500/30 text-green-500 text-xs font-medium hover:bg-green-500/5 transition-colors",children:[e.jsx(U,{className:"w-3 h-3"}),"Download"]})]})]})]}),i&&e.jsx("div",{className:"px-4 py-3 rounded-lg border border-red-500/30 bg-red-500/5 text-xs text-red-400",children:i}),w&&r&&e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"AI Prompt"}),e.jsx("p",{className:"text-[10px] text-muted mt-0.5",children:"Copy this prompt, generate the code with AI, then paste the result below"})]}),e.jsxs("button",{onClick:G,className:`flex items-center gap-1 px-2 py-1 text-[10px] rounded border transition-all duration-200 ${S?"border-green-500/30 text-green-500 bg-green-500/5":"border-edge text-muted hover:text-foreground"}`,children:[S?e.jsx(I,{className:"w-3 h-3"}):e.jsx(Z,{className:"w-3 h-3"}),S?"Copied!":"Copy"]})]}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx("pre",{className:"text-[10px] p-3 rounded-md bg-surface border border-edge max-h-48 overflow-auto whitespace-pre-wrap text-muted font-mono",children:r.prompt.length>3e3?r.prompt.slice(0,3e3)+`
|
|
117
|
+
|
|
118
|
+
... (truncated, use Copy for full prompt)`:r.prompt}),e.jsx("textarea",{value:c,onChange:v=>m(v.target.value),placeholder:"// Paste the AI-generated code here...",rows:8,className:"w-full px-3 py-2 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent font-mono"}),e.jsxs("button",{onClick:p,disabled:!c.trim()||h,className:"flex items-center gap-1.5 px-4 py-1.5 text-xs font-medium rounded-md bg-green-600 text-white hover:opacity-90 disabled:opacity-50 transition-opacity",children:[h?e.jsx(A,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(je,{className:"w-3.5 h-3.5"}),h?"Finalizing...":"Finalize Translation"]})]})]})]})}function rt(s){const t=s.totalConstructs;if(t===0)return{percentage:100,ruleCount:0,aiCount:0,total:0,aiConstructs:[]};const a=s.ambiguousConstructs??[],n=a.length,l=s.constructs.map(m=>m.canonicalName).filter(m=>!a.includes(m)).length,c=t>0?Math.round((t-n)/t*100):100;return{percentage:Math.min(100,Math.max(0,c)),ruleCount:l,aiCount:n,total:t,aiConstructs:a}}function nt(s){return s>=90?{border:"border-green-500/30",bg:"bg-green-500/5",text:"text-green-500",bar:"bg-green-500"}:s>=50?{border:"border-yellow-500/30",bg:"bg-yellow-500/5",text:"text-yellow-500",bar:"bg-yellow-500"}:{border:"border-red-500/30",bg:"bg-red-500/5",text:"text-red-500",bar:"bg-red-500"}}function O({analysis:s,deterministicPct:t,totalConstructs:a,isProjectLevel:n,onDownload:o,aiPrompt:l}){const[c,m]=u.useState(!1),x=s?rt(s):{percentage:t??0,ruleCount:Math.round((t??0)/100*(a??0)),aiCount:Math.round((100-(t??0))/100*(a??0)),total:a??0,aiConstructs:[]},d=nt(x.percentage),p=x.percentage===100,g=100-x.percentage,b=u.useCallback(()=>{l&&navigator.clipboard.writeText(l).then(()=>{m(!0),setTimeout(()=>m(!1),2e3)})},[l]);return x.total===0&&!t?null:e.jsxs("div",{className:`rounded-lg border ${d.border} ${d.bg} p-4 space-y-3`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:`text-3xl font-bold ${d.text}`,children:[x.percentage,"%"]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs font-semibold text-foreground",children:[n?"Project ":"","Deterministic Translation"]}),e.jsxs("p",{className:"text-[10px] text-muted",children:[x.ruleCount,"/",x.total," constructs by rules",x.aiCount>0&&` · ${x.aiCount} need AI`]})]})]}),p&&e.jsxs("span",{className:"flex items-center gap-1 px-2 py-1 rounded-md bg-green-500/10 text-green-500 text-[10px] font-medium",children:[e.jsx(ne,{className:"w-3 h-3"}),"No AI Required"]})]}),e.jsxs("div",{className:"h-2.5 rounded-full bg-surface overflow-hidden flex",role:"progressbar","aria-valuenow":x.percentage,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Deterministic translation: ${x.percentage}%`,children:[x.percentage>0&&e.jsx("div",{className:`h-full ${d.bar} transition-all duration-500`,style:{width:`${x.percentage}%`}}),g>0&&e.jsx("div",{className:"h-full bg-yellow-500/60 transition-all duration-500",style:{width:`${g}%`}})]}),e.jsxs("div",{className:"flex items-center gap-4 text-[10px]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${d.bar}`}),e.jsxs("span",{className:"text-muted",children:["Rule-based (",x.ruleCount,")"]})]}),x.aiCount>0&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-yellow-500/60"}),e.jsxs("span",{className:"text-muted",children:["AI-assisted (",x.aiCount,")"]})]})]}),x.aiConstructs.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:x.aiConstructs.map(r=>e.jsxs("span",{className:"flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded border border-yellow-500/30 bg-yellow-500/5 text-yellow-500",children:[e.jsx(qe,{className:"w-2.5 h-2.5"}),r]},r))}),e.jsx("div",{className:"flex items-center gap-2 pt-1",children:p&&o?e.jsxs("button",{onClick:o,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-green-600 text-white text-xs font-medium hover:bg-green-700 transition-colors w-full justify-center",children:[e.jsx(U,{className:"w-3.5 h-3.5"}),"Ready to Download"]}):e.jsxs(e.Fragment,{children:[l&&e.jsxs("button",{onClick:b,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-accent/10 text-accent text-xs font-medium hover:bg-accent/20 transition-colors",children:[c?e.jsx(I,{className:"w-3.5 h-3.5"}):e.jsx(Z,{className:"w-3.5 h-3.5"}),c?"Copied!":`Copy AI Prompt for ${x.aiCount} construct${x.aiCount!==1?"s":""}`]}),o&&e.jsxs("button",{onClick:o,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-edge text-foreground text-xs font-medium hover:bg-surface transition-colors",children:[e.jsx(U,{className:"w-3.5 h-3.5"}),"Download Partial"]})]})})]})}function Y({value:s,max:t=100,label:a}){const n=Math.min(100,Math.round(s/t*100)),o=n>=80?"bg-green-500":n>=50?"bg-yellow-500":"bg-red-500";return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-[10px]",children:[e.jsx("span",{className:"text-muted",children:a}),e.jsxs("span",{className:"text-foreground font-medium",children:[n,"%"]})]}),e.jsx("div",{className:"h-1.5 rounded-full bg-surface overflow-hidden",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${a}: ${n}%`,children:e.jsx("div",{className:`h-full rounded-full ${o} transition-all duration-500`,style:{width:`${n}%`}})})]})}function oe({analysis:s}){return s?e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-center gap-2",children:[e.jsx(Me,{className:"w-3.5 h-3.5 text-accent"}),e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"Analysis Results"})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"px-2 py-0.5 text-[10px] font-medium rounded bg-accent/10 text-accent",children:s.detectedLanguage}),s.detectedConfidence!=null&&e.jsxs("span",{className:"text-[10px] text-muted",children:[Math.round(s.detectedConfidence*100),"% confidence"]}),e.jsxs("span",{className:"text-[10px] text-muted",children:[s.totalConstructs," constructs detected"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Y,{value:s.complexityScore,label:"Complexity"}),e.jsx(Y,{value:s.estimatedTranslatability,label:"Translatability"})]}),s.constructs.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted mb-2",children:"Detected Constructs"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.constructs.map(t=>e.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-edge bg-surface text-foreground",title:`count: ${t.count}, confidence: ${Math.round(t.confidence*100)}%`,children:[t.canonicalName," ",e.jsxs("span",{className:"text-muted",children:["x",t.count]})]},t.canonicalName))})]}),e.jsx(O,{analysis:s}),s.ambiguousConstructs&&s.ambiguousConstructs.length>0&&e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md border border-yellow-500/30 bg-yellow-500/5",children:[e.jsx(W,{className:"w-3.5 h-3.5 text-yellow-500 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-medium text-yellow-500",children:"Ambiguous Constructs"}),e.jsx("p",{className:"text-[10px] text-muted mt-0.5",children:s.ambiguousConstructs.join(", ")})]})]})]})]}):null}function lt({score:s}){const t=Math.round(s*100),a=t>=80?"bg-green-500/10 text-green-500":t>=50?"bg-yellow-500/10 text-yellow-500":"bg-red-500/10 text-red-500";return e.jsxs("span",{className:`px-2 py-0.5 text-xs font-semibold rounded ${a}`,children:[t,"%"]})}const ot={high:"bg-red-500/10 text-red-500",medium:"bg-yellow-500/10 text-yellow-500",low:"bg-blue-500/10 text-blue-500"};function ct({result:s}){if(!s)return null;const{evidence:t}=s;return e.jsxs("div",{className:"rounded-lg border border-green-500/30 bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"w-3.5 h-3.5 text-green-500"}),e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"Translation Evidence"})]}),e.jsx(lt,{score:t.confidenceScore})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(O,{deterministicPct:Math.round(t.confidenceScore*100),totalConstructs:t.translatedConstructs.length+t.risks.length}),t.translatedConstructs.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(Re,{className:"w-3 h-3 text-muted"}),e.jsx("p",{className:"text-[10px] text-muted font-medium",children:"Translated Constructs"})]}),e.jsxs("table",{className:"w-full text-[10px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-edge",children:[e.jsx("th",{className:"text-left px-2 py-1 font-medium text-muted",children:"Source"}),e.jsx("th",{className:"text-left px-2 py-1 font-medium text-muted",children:"Target"}),e.jsx("th",{className:"text-left px-2 py-1 font-medium text-muted",children:"Method"})]})}),e.jsx("tbody",{children:t.translatedConstructs.map((a,n)=>e.jsxs("tr",{className:"border-b border-edge/50",children:[e.jsx("td",{className:"px-2 py-1 font-mono text-foreground",children:a.source}),e.jsx("td",{className:"px-2 py-1 font-mono text-accent",children:a.target}),e.jsx("td",{className:"px-2 py-1 text-muted",children:a.method})]},n))})]})]}),t.risks.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(W,{className:"w-3 h-3 text-yellow-500"}),e.jsxs("p",{className:"text-[10px] text-muted font-medium",children:["Risks (",t.risks.length,")"]})]}),e.jsx("div",{className:"space-y-1.5",children:t.risks.map((a,n)=>e.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5 rounded border border-edge/50 bg-surface",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-medium ${ot[a.severity]??"bg-surface text-muted"}`,children:a.severity}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-foreground",children:a.construct}),e.jsx("span",{className:"text-[10px] text-muted ml-1",children:a.message})]})]},n))})]}),t.humanReviewPoints.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(Fe,{className:"w-3 h-3 text-muted"}),e.jsx("p",{className:"text-[10px] text-muted font-medium",children:"Human Review Points"})]}),e.jsx("ul",{className:"space-y-1 text-[10px] text-muted list-disc list-inside",children:t.humanReviewPoints.map((a,n)=>e.jsx("li",{children:a},n))})]}),t.diff&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted font-medium mb-2",children:"Diff"}),e.jsx("pre",{className:"text-[10px] p-3 rounded-md bg-surface border border-edge max-h-64 overflow-auto whitespace-pre-wrap text-muted font-mono",children:t.diff})]})]})]})}const dt={pending:"bg-yellow-500/10 text-yellow-500",analyzing:"bg-blue-500/10 text-blue-500",translating:"bg-indigo-500/10 text-indigo-500",validating:"bg-purple-500/10 text-purple-500",done:"bg-green-500/10 text-green-500",failed:"bg-red-500/10 text-red-500"};function it(s){const t=Date.now(),a=new Date(s).getTime(),n=t-a,o=Math.floor(n/6e4);if(o<1)return"just now";if(o<60)return`${o}m ago`;const l=Math.floor(o/60);if(l<24)return`${l}h ago`;const c=Math.floor(l/24);return c<7?`${c}d ago`:new Date(s).toLocaleDateString()}function P({label:s,value:t,accent:a}){return e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt px-4 py-3",children:[e.jsx("p",{className:"text-[10px] text-muted",children:s}),e.jsx("p",{className:`text-lg font-semibold ${a??"text-foreground"}`,children:t})]})}function V(){return e.jsx("tr",{className:"border-b border-edge/50",children:Array.from({length:7}).map((s,t)=>e.jsx("td",{className:"px-4 py-2",children:e.jsx("div",{className:"h-3 rounded bg-surface animate-pulse",style:{width:`${40+Math.random()*40}%`}})},t))})}function xt({job:s}){return e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-3 bg-surface/50",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.sourceCode&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-medium text-muted mb-1",children:"Source Code"}),e.jsxs("pre",{className:"text-[10px] p-2 rounded-md bg-surface border border-edge max-h-40 overflow-auto whitespace-pre-wrap font-mono text-foreground",children:[s.sourceCode.slice(0,500),s.sourceCode.length>500?`
|
|
119
|
+
...`:""]})]}),s.targetCode&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-medium text-muted mb-1",children:"Translated Code"}),e.jsxs("pre",{className:"text-[10px] p-2 rounded-md bg-surface border border-green-500/20 max-h-40 overflow-auto whitespace-pre-wrap font-mono text-foreground",children:[s.targetCode.slice(0,500),s.targetCode.length>500?`
|
|
120
|
+
...`:""]})]}),!s.sourceCode&&!s.targetCode&&e.jsx("p",{className:"text-[10px] text-muted col-span-2",children:"No code details available for this job."})]})})})}function ut({state:s,actions:t,showInsights:a}){const{jobs:n,stats:o,loading:l,error:c}=s,[m,x]=u.useState(null),[d,p]=u.useState(null),g=r=>{d===r?(p(null),t.deleteJob(r)):(p(r),setTimeout(()=>p(i=>i===r?null:i),3e3))},b=r=>{x(i=>i===r?null:r)};return l&&n.length===0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3",children:Array.from({length:5}).map((r,i)=>e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt px-4 py-3 animate-pulse",children:[e.jsx("div",{className:"h-2 w-16 rounded bg-surface mb-2"}),e.jsx("div",{className:"h-5 w-10 rounded bg-surface"})]},i))}),e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsx("div",{className:"px-4 py-3 border-b border-edge",children:e.jsx("div",{className:"h-3 w-32 rounded bg-surface animate-pulse"})}),e.jsx("table",{className:"w-full",children:e.jsxs("tbody",{children:[e.jsx(V,{}),e.jsx(V,{}),e.jsx(V,{})]})})]})]}):c?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3",children:[e.jsx("p",{className:"text-xs text-red-400",children:c}),e.jsxs("button",{onClick:()=>void t.refresh(),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md border border-edge text-muted hover:text-foreground transition-colors cursor-pointer",children:[e.jsx(J,{className:"w-3 h-3"})," Retry"]})]}):e.jsxs("div",{className:"space-y-4",children:[o&&e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3",children:[e.jsx(P,{label:"Total Jobs",value:o.totalJobs}),e.jsx(P,{label:"Completed",value:o.done,accent:"text-green-500"}),e.jsx(P,{label:"Failed",value:o.failed,accent:o.failed>0?"text-red-500":"text-foreground"}),e.jsx(P,{label:"Pending",value:o.pending,accent:o.pending>0?"text-yellow-500":"text-foreground"}),e.jsx(P,{label:"Avg Confidence",value:`${Math.round(o.avgConfidence*100)}%`})]}),a&&n.length>0&&e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-center gap-2",children:[e.jsx(K,{className:"w-3.5 h-3.5 text-accent"}),e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"Translation Pairs"})]}),e.jsx("div",{className:"p-4",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(n.reduce((r,i)=>{const h=`${i.sourceLanguage} → ${i.targetLanguage}`;return r[h]=(r[h]??0)+1,r},{})).sort(([,r],[,i])=>i-r).map(([r,i])=>e.jsxs("span",{className:"px-2 py-1 text-[10px] rounded-md border border-edge bg-surface cursor-pointer hover:border-accent/50 transition-colors",children:[e.jsx("span",{className:"font-medium text-foreground",children:r}),e.jsxs("span",{className:"text-muted ml-1.5",children:["x",i]})]},r))})})]}),e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-center justify-between",children:[e.jsxs("h3",{className:"text-xs font-semibold text-foreground",children:["Translation Jobs (",n.length,")"]}),e.jsx("button",{onClick:()=>void t.refresh(),className:"p-1 rounded text-muted hover:text-foreground transition-colors cursor-pointer",title:"Refresh",children:e.jsx(J,{className:`w-3.5 h-3.5 ${l?"animate-spin":""}`})})]}),n.length===0?e.jsxs("div",{className:"px-4 py-12 flex flex-col items-center justify-center gap-3 text-center",children:[e.jsx(Ue,{className:"w-8 h-8 text-muted/40"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted",children:"No translation jobs yet"}),e.jsx("p",{className:"text-[10px] text-muted/60 mt-1",children:"Start by translating some code in the Convert tab"})]})]}):e.jsx("div",{className:"overflow-auto max-h-96",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-alt shadow-sm",children:e.jsxs("tr",{className:"border-b border-edge",children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium text-muted w-6"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium text-muted",children:"ID"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium text-muted",children:"Languages"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium text-muted",children:"Scope"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium text-muted",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium text-muted",children:"Confidence"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium text-muted",children:"Created"}),e.jsx("th",{className:"text-right px-4 py-2 font-medium text-muted"})]})}),e.jsx("tbody",{children:n.map(r=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{onClick:()=>b(r.id),className:"border-b border-edge/50 hover:bg-surface transition-colors cursor-pointer",children:[e.jsx("td",{className:"px-4 py-1.5 text-muted",children:m===r.id?e.jsx(te,{className:"w-3 h-3"}):e.jsx(se,{className:"w-3 h-3"})}),e.jsx("td",{className:"px-4 py-1.5 font-mono text-muted",title:r.id,children:r.id.slice(0,8)}),e.jsxs("td",{className:"px-4 py-1.5",children:[e.jsx("span",{className:"text-foreground",children:r.sourceLanguage}),e.jsx("span",{className:"text-muted mx-1",children:"→"}),e.jsx("span",{className:"text-accent",children:r.targetLanguage})]}),e.jsx("td",{className:"px-4 py-1.5 text-muted",children:r.scope}),e.jsx("td",{className:"px-4 py-1.5",children:e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${dt[r.status]}`,children:r.status})}),e.jsx("td",{className:"px-4 py-1.5 text-muted",children:r.confidenceScore!=null?`${Math.round(r.confidenceScore*100)}%`:"—"}),e.jsx("td",{className:"px-4 py-1.5 text-muted",title:new Date(r.createdAt).toLocaleString(),children:it(r.createdAt)}),e.jsx("td",{className:"px-4 py-1.5 text-right",onClick:i=>i.stopPropagation(),children:e.jsx("button",{onClick:()=>g(r.id),className:`px-2 py-0.5 rounded text-[10px] transition-all cursor-pointer ${d===r.id?"bg-red-500/10 text-red-400 font-medium border border-red-500/30":"text-muted hover:text-red-400"}`,title:d===r.id?"Click again to confirm":"Delete job",children:d===r.id?"Confirm?":e.jsx(We,{className:"w-3 h-3"})})})]},r.id),m===r.id&&e.jsx(xt,{job:r},`${r.id}-details`)]}))})]})})]})]})}function mt({onUpload:s,loading:t,disabled:a}){const[n,o]=u.useState(!1),l=u.useRef(null),c=u.useCallback(g=>{g.preventDefault(),g.stopPropagation(),!a&&!t&&o(!0)},[a,t]),m=u.useCallback(g=>{g.preventDefault(),g.stopPropagation(),o(!1)},[]),x=u.useCallback(g=>{if(g.preventDefault(),g.stopPropagation(),o(!1),a||t)return;const b=g.dataTransfer.files[0];b&&b.name.endsWith(".zip")&&s(b)},[a,t,s]),d=u.useCallback(()=>{var g;!a&&!t&&((g=l.current)==null||g.click())},[a,t]),p=u.useCallback(g=>{var r;const b=(r=g.target.files)==null?void 0:r[0];b&&b.name.endsWith(".zip")&&s(b),g.target.value=""},[s]);return e.jsxs("div",{role:"button",tabIndex:a?-1:0,className:`
|
|
121
|
+
flex flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed
|
|
122
|
+
px-4 py-5 text-center transition-colors cursor-pointer
|
|
123
|
+
${n?"border-accent bg-accent/5":"border-edge bg-surface"}
|
|
124
|
+
${a||t?"opacity-50 cursor-not-allowed":"hover:border-accent/60"}
|
|
125
|
+
`,onDragOver:c,onDragLeave:m,onDrop:x,onClick:d,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&d()},children:[e.jsx("input",{ref:l,type:"file",accept:".zip",className:"hidden",onChange:p,disabled:a||t}),t?e.jsxs(e.Fragment,{children:[e.jsx(A,{className:"h-6 w-6 animate-spin text-accent"}),e.jsx("span",{className:"text-sm text-muted",children:"Uploading..."})]}):e.jsxs(e.Fragment,{children:[n?e.jsx(Te,{className:"h-6 w-6 text-accent"}):e.jsx(Qe,{className:"h-6 w-6 text-muted"}),e.jsxs("span",{className:"text-sm text-muted",children:["Drop a ",e.jsx("code",{className:"text-xs",children:".zip"})," file or click to browse"]})]})]})}const ee={done:"bg-green-500",analyzed:"bg-yellow-500",translating:"bg-blue-500",analyzing:"bg-blue-500",failed:"bg-red-500",pending:"bg-gray-500"};function ht(s){const t={children:[]};for(const n of s){const o=n.filePath.split("/");let l=t;for(let c=0;c<o.length;c++){const m=o[c],x=c===o.length-1,d=o.slice(0,c+1).join("/");if(x)l.children.push({name:m,path:d,isDir:!1,children:[],file:n});else{let p=l.children.find(g=>g.isDir&&g.name===m);p||(p={name:m,path:d,isDir:!0,children:[]},l.children.push(p)),l=p}}}const a=n=>{const o=[...n].sort((l,c)=>l.isDir!==c.isDir?l.isDir?-1:1:l.name.localeCompare(c.name));for(const l of o)l.isDir&&(l.children=a(l.children));return o};return a(t.children)}function pt(s){const t={};for(const a of s)t[a.status]=(t[a.status]??0)+1;return t}function ce(s,t){const a=t.toLowerCase(),n=[];for(const o of s)if(o.isDir){const l=ce(o.children,t);l.length>0&&n.push({...o,children:l})}else o.path.toLowerCase().includes(a)&&n.push(o);return n}const gt=u.memo(function s({node:t,depth:a,selectedFileId:n,onSelectFile:o,expandedPaths:l,onToggle:c}){var r,i,h;const m=l.has(t.path),x=!t.isDir&&((r=t.file)==null?void 0:r.id)===n,d=a*16+8;if(t.isDir)return e.jsxs("div",{style:{contentVisibility:"auto"},children:[e.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 rounded px-1 py-0.5 text-sm text-muted hover:bg-surface-hover",style:{paddingLeft:d},onClick:()=>c(t.path),children:[m?e.jsx(te,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(se,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx(Ee,{className:"h-3.5 w-3.5 shrink-0 text-yellow-500/80"}),e.jsx("span",{className:"truncate",children:t.name})]}),m&&t.children.map(f=>e.jsx(s,{node:f,depth:a+1,selectedFileId:n,onSelectFile:o,expandedPaths:l,onToggle:c},f.path))]});const p=((i=t.file)==null?void 0:i.status)??"pending",g=(h=t.file)==null?void 0:h.confidenceScore,b=ee[p]??ee.pending;return e.jsxs("button",{type:"button",className:`
|
|
126
|
+
flex w-full items-center gap-1.5 rounded px-1 py-0.5 text-sm transition-colors
|
|
127
|
+
${x?"bg-accent/10 border border-accent text-foreground":"text-muted hover:bg-surface-hover border border-transparent"}
|
|
128
|
+
`,style:{paddingLeft:d,contentVisibility:"auto"},onClick:()=>t.file&&o(t.file.id),children:[e.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${b}`}),e.jsx(re,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:t.name}),g!=null&&e.jsxs("span",{className:"ml-auto shrink-0 text-xs text-muted",children:[Math.round(g*100),"%"]})]})});function ft({files:s,selectedFileId:t,onSelectFile:a}){const[n,o]=u.useState(""),[l,c]=u.useState(new Set),m=u.useMemo(()=>ht(s),[s]),x=u.useMemo(()=>n.trim()?ce(m,n.trim()):m,[m,n]),d=u.useMemo(()=>pt(s),[s]),p=u.useCallback(i=>{c(h=>{const f=new Set(h);return f.has(i)?f.delete(i):f.add(i),f})},[]),g=(d.done??0)+(d.analyzed??0),b=d.translating??0,r=d.failed??0;return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"text-xs text-muted px-1",children:[s.length," files: ",g," ready, ",b," need AI, ",r," error"]}),e.jsxs("div",{className:"relative",children:[e.jsx(ae,{className:"absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted"}),e.jsx("input",{type:"text",placeholder:"Filter files...",value:n,onChange:i=>o(i.target.value),className:"w-full rounded border border-edge bg-surface py-1 pl-7 pr-2 text-sm text-foreground placeholder:text-muted focus:border-accent focus:outline-none"})]}),e.jsxs("div",{className:"overflow-y-auto max-h-[60vh]",children:[x.map(i=>e.jsx(gt,{node:i,depth:0,selectedFileId:t,onSelectFile:a,expandedPaths:l,onToggle:p},i.path)),x.length===0&&e.jsx("div",{className:"py-4 text-center text-xs text-muted",children:"No files match your filter"})]})]})}function bt(s,t){if(t){const d=t.translatedFiles,p=t.pendingFiles+t.analyzedFiles;return{totalFiles:t.totalFiles,deterministicCount:d,needsAiCount:p,errorCount:t.failedFiles,avgConfidence:t.overallConfidence,deterministicPct:t.deterministicPct}}const a=s.length;if(a===0)return{totalFiles:0,deterministicCount:0,needsAiCount:0,errorCount:0,avgConfidence:0,deterministicPct:0};const n=s.filter(d=>d.deterministic===!0).length,o=s.filter(d=>d.status==="failed").length,l=s.filter(d=>d.deterministic===!1&&d.status!=="failed").length,c=s.filter(d=>d.confidenceScore!=null),m=c.length>0?c.reduce((d,p)=>d+(p.confidenceScore??0),0)/c.length:0,x=a>0?Math.round(n/a*100):0;return{totalFiles:a,deterministicCount:n,needsAiCount:l,errorCount:o,avgConfidence:m,deterministicPct:x}}function D({icon:s,value:t,label:a,colorClass:n="text-foreground"}){return e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s,e.jsx("span",{className:`text-xl font-bold ${n}`,children:t})]}),e.jsx("p",{className:"text-[10px] text-muted",children:a})]})}function jt({project:s,files:t,summary:a,onPrepareAll:n,onDownloadAll:o,loading:l}){const c=bt(t,a),m=c.deterministicPct===100&&c.totalFiles>0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-5 gap-3",children:[e.jsx(D,{icon:e.jsx(De,{className:"w-3.5 h-3.5 text-accent"}),value:c.totalFiles,label:"Total Files"}),e.jsx(D,{icon:e.jsx(ne,{className:"w-3.5 h-3.5 text-green-500"}),value:c.deterministicCount,label:"Deterministic",colorClass:"text-green-500"}),e.jsx(D,{icon:e.jsx(W,{className:"w-3.5 h-3.5 text-yellow-500"}),value:c.needsAiCount,label:"Needs AI",colorClass:"text-yellow-500"}),e.jsx(D,{icon:e.jsx(ve,{className:"w-3.5 h-3.5 text-red-500"}),value:c.errorCount,label:"Errors",colorClass:"text-red-500"}),e.jsx(D,{icon:e.jsx(K,{className:"w-3.5 h-3.5 text-accent"}),value:`${Math.round(c.avgConfidence*100)}%`,label:"Avg Confidence"})]}),e.jsx(O,{isProjectLevel:!0,deterministicPct:c.deterministicPct,totalConstructs:c.totalFiles}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:n,disabled:l||c.totalFiles===0,className:"flex items-center gap-1.5 px-4 py-2 rounded-md bg-accent text-white text-xs font-medium hover:bg-accent/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(le,{className:"w-3.5 h-3.5"}),"Convert All"]}),e.jsxs("button",{onClick:o,disabled:l||c.totalFiles===0,className:`flex items-center gap-1.5 px-4 py-2 rounded-md text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${m?"bg-green-600 text-white hover:bg-green-700":"border border-edge text-foreground hover:bg-surface"}`,children:[e.jsx(U,{className:"w-3.5 h-3.5"}),"Download All .zip"]})]})]})}function Nt({file:s,prompt:t,onBack:a,onFinalize:n,loading:o}){const[l,c]=u.useState(""),[m,x]=u.useState(!1),d=s.status==="done",p=u.useCallback(()=>{t&&navigator.clipboard.writeText(t).then(()=>{x(!0),setTimeout(()=>x(!1),2e3)})},[t]),g=u.useCallback(()=>{l.trim()&&n(l.trim())},[l,n]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("button",{onClick:a,className:"flex items-center gap-1.5 text-xs text-muted hover:text-foreground transition-colors",children:[e.jsx(pe,{className:"w-3.5 h-3.5"}),"Back to project"]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-edge bg-surface-alt",children:[e.jsx(re,{className:"w-4 h-4 text-accent shrink-0"}),e.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:s.filePath})]}),s.analysis&&e.jsx(oe,{analysis:s.analysis}),e.jsx(O,{analysis:s.analysis,aiPrompt:t}),t&&e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"AI Prompt"}),e.jsxs("button",{onClick:p,className:"flex items-center gap-1 px-2 py-1 rounded text-[10px] text-muted hover:text-foreground hover:bg-surface transition-colors",children:[m?e.jsx(I,{className:"w-3 h-3"}):e.jsx(Z,{className:"w-3 h-3"}),m?"Copied!":"Copy"]})]}),e.jsx("pre",{className:"p-4 text-[11px] text-foreground/80 overflow-x-auto whitespace-pre-wrap font-mono leading-relaxed max-h-60 overflow-y-auto",children:t})]}),d&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 rounded-lg border border-green-500/30 bg-green-500/5",children:[e.jsx(I,{className:"w-4 h-4 text-green-500 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-green-500",children:"Translation Complete"}),s.confidenceScore!=null&&e.jsxs("p",{className:"text-[10px] text-muted mt-0.5",children:["Confidence: ",Math.round(s.confidenceScore*100),"%"]})]})]}),!d&&e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"Generated Code"}),e.jsx("p",{className:"text-[10px] text-muted mt-0.5",children:"Paste the AI-generated translation below to finalize this file."})]}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx("textarea",{value:l,onChange:b=>c(b.target.value),placeholder:"Paste generated code here...",className:"w-full h-48 px-3 py-2 rounded-md border border-edge bg-surface text-xs font-mono text-foreground placeholder:text-muted/50 resize-y focus:outline-none focus:ring-1 focus:ring-accent/50"}),e.jsx("button",{onClick:g,disabled:o||!l.trim(),className:"flex items-center gap-1.5 px-4 py-2 rounded-md bg-accent text-white text-xs font-medium hover:bg-accent/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Finalize Translation"})]})]})]})}function yt({project:s,files:t,summary:a,selectedFileId:n,onSelectFile:o,onPrepareAll:l,onDownloadAll:c,onFinalizeFile:m,prompts:x,loading:d}){const p=n?t.find(r=>r.id===n)??null:null,g=()=>{o(null)},b=r=>{n&&m(n,r)};return e.jsxs("div",{className:"flex h-full flex-col md:flex-row",children:[e.jsx("div",{className:"w-full md:w-60 border-b md:border-b-0 md:border-r border-edge overflow-hidden flex flex-col shrink-0",children:e.jsx(ft,{files:t,selectedFileId:n,onSelectFile:o})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:p?e.jsx(Nt,{file:p,prompt:x==null?void 0:x[p.id],onBack:g,onFinalize:b,loading:d}):e.jsx(jt,{project:s,files:t,summary:a,onPrepareAll:l,onDownloadAll:c,loading:d})})]})}const vt={knowledge:null,searchResults:[],loading:!1,error:null};function wt(){const[s,t]=u.useState(vt),a=u.useCallback(async()=>{t(o=>({...o,loading:!0,error:null}));try{const o=await C.translationGetKnowledge();t(l=>({...l,knowledge:o,loading:!1}))}catch(o){t(l=>({...l,error:o instanceof Error?o.message:"Failed to load knowledge stats",loading:!1}))}},[]),n=u.useCallback(async o=>{t(l=>({...l,loading:!0,error:null}));try{const l=await C.translationSearchKnowledge(o);t(c=>({...c,searchResults:l.results,loading:!1}))}catch(l){t(c=>({...c,error:l instanceof Error?l.message:"Search failed",loading:!1}))}},[]);return u.useEffect(()=>{a()},[a]),[s,{search:n,refresh:a}]}function H({label:s,value:t}){return e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt px-4 py-3",children:[e.jsx("p",{className:"text-[10px] text-muted",children:s}),e.jsx("p",{className:"text-lg font-semibold text-foreground",children:t})]})}function Ct({entry:s}){return e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt px-4 py-3",children:[e.jsx("p",{className:"text-xs font-medium text-foreground truncate",children:s.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[s.sourceLanguage&&s.targetLanguage&&e.jsxs("span",{className:"text-[10px] text-muted",children:[s.sourceLanguage," → ",s.targetLanguage]}),s.confidence!=null&&e.jsxs("span",{className:"text-[10px] text-accent",children:[Math.round(s.confidence*100),"%"]}),e.jsx("span",{className:"text-[10px] text-muted ml-auto",children:new Date(s.createdAt).toLocaleDateString()})]})]})}function kt(){var d,p,g;const[s,{search:t,refresh:a}]=wt(),[n,o]=u.useState(""),l=b=>{b.preventDefault(),t(n)},c=()=>{a()},m=s.searchResults&&s.searchResults.length>0?s.searchResults:((d=s.knowledge)==null?void 0:d.recentEntries)??[],x=s.searchResults&&s.searchResults.length>0;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:l,className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ae,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted"}),e.jsx("input",{type:"text",value:n,onChange:b=>o(b.target.value),placeholder:"Search knowledge base...",className:"w-full pl-8 pr-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:border-accent/50"})]}),e.jsxs("button",{type:"button",onClick:c,disabled:s.loading,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md border border-edge text-muted hover:text-foreground transition-colors cursor-pointer disabled:opacity-50",title:"Reindex knowledge",children:[e.jsx(J,{className:`w-3.5 h-3.5 ${s.loading?"animate-spin":""}`}),"Reindex"]})]}),s.loading&&!s.knowledge&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(A,{className:"w-6 h-6 text-muted animate-spin"})}),!s.loading&&!s.knowledge&&m.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3 text-center",children:[e.jsx(q,{className:"w-12 h-12 text-muted/40"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted",children:"No learnings yet."}),e.jsx("p",{className:"text-[10px] text-muted/60 mt-1",children:"Complete some translations to build the knowledge base."})]})]}),s.knowledge&&e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(H,{label:"Total Entries",value:s.knowledge.totalDocuments??0}),e.jsx(H,{label:"Language Pairs",value:((p=s.knowledge.byLanguagePair)==null?void 0:p.length)??0}),e.jsx(H,{label:"Avg Confidence",value:s.knowledge.avgConfidence!=null?`${Math.round(s.knowledge.avgConfidence*100)}%`:"—"})]}),((g=s.knowledge)==null?void 0:g.byLanguagePair)&&s.knowledge.byLanguagePair.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.knowledge.byLanguagePair.map(b=>e.jsxs("span",{className:"px-2 py-0.5 text-[10px] font-medium rounded bg-accent/10 text-accent",children:[b.pair," (",b.count,")"]},b.pair))}),m.length>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{className:"w-3.5 h-3.5 text-accent"}),e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:x?"Search Results":"Recent Entries"}),e.jsxs("span",{className:"text-[10px] text-muted",children:["(",m.length,")"]})]}),m.length>0&&e.jsx("div",{className:"space-y-2 max-h-80 overflow-auto",children:m.map(b=>e.jsx(Ct,{entry:b},b.id))})]})}const St=[{id:"convert",label:"Convert",icon:e.jsx(me,{className:"w-3.5 h-3.5"})},{id:"history",label:"History",icon:e.jsx(Ce,{className:"w-3.5 h-3.5"})},{id:"insights",label:"Insights",icon:e.jsx(K,{className:"w-3.5 h-3.5"})},{id:"knowledge",label:"Knowledge",icon:e.jsx(q,{className:"w-3.5 h-3.5"})},{id:"graph",label:"Graph",icon:e.jsx(B,{className:"w-3.5 h-3.5"})}],z={sourceCode:"",targetLanguage:"python",scope:"snippet",generatedCode:""};function Lt(){const[s,t]=u.useState("convert"),[a,n]=Xe(),[o,l]=Ye(),[c,m]=et(),[x,d]=u.useState(z.sourceCode),[p,g]=u.useState(z.targetLanguage),[b,r]=u.useState(z.scope),[i,h]=u.useState(z.generatedCode),f=u.useCallback(j=>{z.sourceCode=j,d(j)},[]),w=u.useCallback(j=>{z.targetLanguage=j,g(j)},[]),k=u.useCallback(j=>{z.scope=j,r(j)},[]),S=u.useCallback(j=>{z.generatedCode=j,h(j)},[]),$=c.mode!=="idle",G=u.useCallback(j=>{m.upload(j,p)},[m,p]),T=a.phase;ie(u.useCallback(j=>{j.startsWith("translation:")&&T!=="analyzing"&&T!=="finalizing"&&l.refresh()},[l,T]));const _=()=>{n.analyze(x,p,b)},E=()=>{n.finalize(i).then(()=>l.refresh())},v=()=>{n.reset(),f(""),S(""),w("python"),k("snippet")};return e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4 max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-5 h-5 text-accent"}),e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:"Language Convert"}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-warning/10 text-warning rounded-full",children:"Beta"})]}),e.jsx("div",{className:"flex gap-1 border-b border-edge pb-1",children:St.map(j=>e.jsxs("button",{onClick:()=>t(j.id),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-t transition-colors ${s===j.id?"bg-accent text-white":"text-muted hover:text-foreground hover:bg-surface"}`,children:[j.icon,j.label]},j.id))}),s==="convert"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(mt,{onUpload:G,loading:c.loading}),$?e.jsx(yt,{project:c.project,files:c.files,summary:c.summary,selectedFileId:c.selectedFileId,onSelectFile:m.selectFile,onPrepareAll:()=>void m.prepareFiles(),onDownloadAll:()=>void m.downloadProject(),onFinalizeFile:(j,F)=>void m.finalizeFile(j,F),loading:c.loading}):e.jsxs(e.Fragment,{children:[e.jsx(at,{sourceCode:x,setSourceCode:f,targetLanguage:p,setTargetLanguage:w,scope:b,setScope:k,generatedCode:i,setGeneratedCode:S,translation:a,onAnalyze:_,onFinalize:E,onReset:v}),a.phase==="analyzing"&&e.jsxs("div",{className:"rounded-lg border-2 border-accent/40 bg-accent/5 p-5 transition-all duration-300",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-accent/20 animate-ping"}),e.jsx(A,{className:"w-5 h-5 text-accent animate-spin relative"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-semibold text-foreground",children:"Analyzing your code..."}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx("span",{className:"text-[10px] text-accent font-medium",children:"Detecting language"}),e.jsx("span",{className:"text-[10px] text-muted",children:"→"}),e.jsx("span",{className:"text-[10px] text-muted",children:"Analyzing constructs"}),e.jsx("span",{className:"text-[10px] text-muted",children:"→"}),e.jsx("span",{className:"text-[10px] text-muted",children:"Generating prompt"})]})]})]}),e.jsx("div",{className:"mt-3 h-1 rounded-full bg-surface overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/60 rounded-full animate-pulse",style:{width:"60%"}})})]}),a.phase==="finalizing"&&e.jsx("div",{className:"rounded-lg border-2 border-green-500/40 bg-green-500/5 p-5 transition-all duration-300",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(A,{className:"w-5 h-5 text-green-500 animate-spin"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-foreground",children:"Finalizing translation..."}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"Validating output and generating evidence pack"})]})]})}),a.analysis&&e.jsx("div",{className:"animate-in fade-in-0 duration-300",style:{animationFillMode:"both"},children:e.jsx(oe,{analysis:a.analysis})}),a.finalizeResult&&e.jsx("div",{className:"animate-in fade-in-0 duration-300",style:{animationFillMode:"both"},children:e.jsx(ct,{result:a.finalizeResult})})]})]}),(s==="history"||s==="insights")&&e.jsx(ut,{state:o,actions:l,showInsights:s==="insights"}),s==="knowledge"&&e.jsx(kt,{}),s==="graph"&&e.jsx("div",{className:"space-y-4",children:(()=>{const j=o.jobs.filter(N=>N.status==="done"&&N.confidenceScore!=null);if(j.length===0)return e.jsxs("div",{className:"text-center py-12",children:[e.jsx(B,{className:"w-12 h-12 text-muted mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-muted",children:"Translation graph visualization"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"Complete some translations to see the relationship graph"})]});const F=[],L=new Map;for(const N of j){const M=`${N.sourceLanguage}→${N.targetLanguage}`,R=L.get(M);R?(R.totalConf+=N.confidenceScore??0,R.count++):L.set(M,{source:N.sourceLanguage,target:N.targetLanguage,totalConf:N.confidenceScore??0,count:1})}for(const N of L.values())F.push({source:N.source,target:N.target,confidence:N.totalConf/N.count,count:N.count});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(B,{className:"w-4 h-4 text-accent"}),e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:"Translation Flow Graph"}),e.jsxs("span",{className:"text-[10px] text-muted",children:["(",j.length," completed translations)"]})]}),e.jsx("div",{className:"grid gap-3",children:F.map(N=>{const M=Math.round(N.confidence*100),R=M>=80?"border-green-500/30 bg-green-500/5":M>=50?"border-yellow-500/30 bg-yellow-500/5":"border-red-500/30 bg-red-500/5",de=M>=80?"text-green-500":M>=50?"text-yellow-500":"text-red-500";return e.jsxs("div",{className:`flex items-center gap-4 rounded-lg border ${R} px-4 py-3`,children:[e.jsx("span",{className:"px-2 py-0.5 text-[10px] font-medium rounded bg-blue-500/10 text-blue-400",children:N.source}),e.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-0.5 bg-edge rounded"}),e.jsxs("span",{className:"text-[10px] text-muted",children:["x",N.count]}),e.jsx("div",{className:"flex-1 h-0.5 bg-edge rounded"})]}),e.jsx("span",{className:"px-2 py-0.5 text-[10px] font-medium rounded bg-green-500/10 text-green-400",children:N.target}),e.jsxs("span",{className:`text-xs font-bold ${de}`,children:[M,"%"]})]},`${N.source}→${N.target}`)})})]})})()})]})})}export{Lt as LanguagesTab};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as s,a as v,j as t}from"./index-
|
|
1
|
+
import{r as s,a as v,j as t}from"./index-DfEJaZLA.js";function S(){const[r,l]=s.useState([]),[c,h]=s.useState(!0),d=s.useRef(0),p=s.useCallback(async()=>{try{const{logs:n}=await v.getLogs();l(n),n.length>0&&(d.current=n[n.length-1].id)}finally{h(!1)}},[]),x=s.useCallback(async()=>{await v.clearLogs(),l([]),d.current=0},[]);return s.useEffect(()=>{p()},[p]),s.useEffect(()=>{const n=new EventSource("/api/v1/events"),i=f=>{try{const o=JSON.parse(f.data),a={id:o.payload.id,level:o.payload.level,message:o.payload.message,context:o.payload.context,timestamp:o.timestamp};a.id>d.current&&(d.current=a.id,l(b=>[...b,a]))}catch{}};return n.addEventListener("log:entry",i),n.onerror=()=>{n.close(),setTimeout(()=>{},5e3)},()=>n.close()},[]),{logs:r,loading:c,clearLogs:x,refresh:p}}const k={info:"bg-blue-500/20 text-blue-400",warn:"bg-yellow-500/20 text-yellow-400",error:"bg-red-500/20 text-red-400",success:"bg-green-500/20 text-green-400",debug:"bg-gray-500/20 text-gray-400"},E=["info","warn","error","success","debug"];function L(r){return new Date(r).toLocaleTimeString("en-US",{hour12:!1})}function y(r){return!r||Object.keys(r).length===0?"":Object.entries(r).map(([l,c])=>`${l}="${String(c)}"`).join(" ")}function j(r){return r.map(l=>{const c=y(l.context);return`[${L(l.timestamp)}] [${l.level.toUpperCase()}] ${l.message}${c?" "+c:""}`}).join(`
|
|
2
2
|
`)}function O(){const{logs:r,loading:l,clearLogs:c,refresh:h}=S(),[d,p]=s.useState("all"),[x,n]=s.useState(""),[i,f]=s.useState(!0),o=s.useRef(null),a=s.useMemo(()=>{let e=r;if(d!=="all"&&(e=e.filter(u=>u.level===d)),x.trim()){const u=x.toLowerCase();e=e.filter(g=>g.message.toLowerCase().includes(u))}return e},[r,d,x]);s.useEffect(()=>{i&&o.current&&(o.current.scrollTop=o.current.scrollHeight)},[a,i]);const b=s.useCallback(()=>{if(!o.current)return;const{scrollTop:e,scrollHeight:u,clientHeight:g}=o.current,m=u-e-g<40;f(m)},[]),C=s.useCallback(async()=>{const e=j(a);await navigator.clipboard.writeText(e)},[a]),N=s.useCallback(()=>{const e=j(a),u=new Blob([e],{type:"text/plain"}),g=URL.createObjectURL(u),m=document.createElement("a");m.href=g,m.download=`mcp-graph-logs-${new Date().toISOString().slice(0,19).replace(/:/g,"-")}.txt`,m.click(),URL.revokeObjectURL(g)},[a]),w=s.useCallback(async()=>{await c()},[c]);return l?t.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"Loading logs..."}):t.jsxs("div",{className:"flex flex-col h-full","data-testid":"logs-tab",children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-edge bg-surface-alt",children:[t.jsxs("select",{value:d,onChange:e=>p(e.target.value),className:"px-2 py-1 text-sm rounded border border-edge bg-surface text-foreground","data-testid":"log-level-filter",children:[t.jsx("option",{value:"all",children:"All Levels"}),E.map(e=>t.jsx("option",{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))]}),t.jsx("input",{type:"text",value:x,onChange:e=>n(e.target.value),placeholder:"Search logs...",className:"flex-1 px-2 py-1 text-sm rounded border border-edge bg-surface text-foreground placeholder:text-muted","data-testid":"log-search"}),t.jsx("button",{onClick:()=>f(!i),className:`px-2 py-1 text-xs rounded border ${i?"border-accent text-accent":"border-edge text-muted"}`,title:i?"Auto-scroll enabled":"Auto-scroll paused",children:i?"Auto-scroll ON":"Auto-scroll OFF"}),t.jsx("button",{onClick:C,className:"px-2 py-1 text-xs rounded border border-edge text-muted hover:text-foreground",title:"Copy all visible logs",children:"Copy"}),t.jsx("button",{onClick:N,className:"px-2 py-1 text-xs rounded border border-edge text-muted hover:text-foreground",title:"Download logs as .txt",children:"Download"}),t.jsx("button",{onClick:w,className:"px-2 py-1 text-xs rounded border border-red-500/30 text-red-400 hover:bg-red-500/10",title:"Clear all logs",children:"Clear"}),t.jsx("button",{onClick:()=>void h(),className:"px-2 py-1 text-xs rounded border border-edge text-muted hover:text-foreground",title:"Refresh logs",children:"Refresh"}),t.jsxs("span",{className:"text-xs text-muted",children:[a.length," entries"]})]}),t.jsx("div",{ref:o,onScroll:b,className:"flex-1 overflow-y-auto font-mono text-xs p-2","data-testid":"log-list",children:a.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-muted",children:[t.jsx("p",{className:"text-xs",children:"No logs to display"}),t.jsx("p",{className:"text-[10px] text-muted/60",children:"Logs appear when mcp-graph tools are executed"})]}):a.map(e=>t.jsxs("div",{className:"flex items-start gap-2 py-0.5 hover:bg-surface-alt",children:[t.jsx("span",{className:"text-muted shrink-0",children:L(e.timestamp)}),t.jsx("span",{className:`px-1.5 py-0 rounded text-[10px] font-semibold uppercase shrink-0 ${k[e.level]}`,children:e.level}),t.jsx("span",{className:"text-foreground",children:e.message}),e.context&&Object.keys(e.context).length>0&&t.jsx("span",{className:"text-muted",children:y(e.context)})]},e.id))})]})}export{O as LogsTab};
|
|
@@ -1,49 +1,39 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import{c as I,r as n,a as L,j as e,C as X}from"./index-DfEJaZLA.js";import{C as Z}from"./circle-alert-Xp4yHA83.js";import{R as z}from"./refresh-cw-VhHh0g7N.js";import{S as K,T as A,F as ee,C as me,a as ue}from"./triangle-alert-ZnXg11jO.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const he=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],fe
|
|
6
|
+
*/const he=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],fe=I("circle",he);/**
|
|
7
7
|
* @license lucide-react v1.7.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const pe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10
|
|
11
|
+
*/const pe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ge=I("file-text",pe);/**
|
|
12
12
|
* @license lucide-react v1.7.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const be=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],te=I("info",be);/**
|
|
17
17
|
* @license lucide-react v1.7.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const je=[["
|
|
21
|
+
*/const je=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],ye=I("lightbulb",je);/**
|
|
22
22
|
* @license lucide-react v1.7.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const
|
|
26
|
+
*/const Ne=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],V=I("list",Ne);/**
|
|
27
27
|
* @license lucide-react v1.7.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const ve=[["path",{d:"
|
|
31
|
+
*/const ve=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],se=I("pencil",ve);/**
|
|
32
32
|
* @license lucide-react v1.7.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const we=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],se=$("pencil",we);/**
|
|
37
|
-
* @license lucide-react v1.7.0 - ISC
|
|
38
|
-
*
|
|
39
|
-
* This source code is licensed under the ISC license.
|
|
40
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const ke=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],K=$("search",ke);/**
|
|
42
|
-
* @license lucide-react v1.7.0 - ISC
|
|
43
|
-
*
|
|
44
|
-
* This source code is licensed under the ISC license.
|
|
45
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const Ce=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],ae=$("server",Ce),J=300*1e3;function Se(){const t=new Map;return{get(s){const a=t.get(s);if(a){if(Date.now()-a.timestamp>J){t.delete(s);return}return a.data}},set(s,a){if(t.set(s,{data:a,timestamp:Date.now()}),t.size>200){const r=Date.now();for(const[i,h]of t)r-h.timestamp>J&&t.delete(i)}}}}function $e(){const[t,s]=n.useState(null),[a,r]=n.useState(null),[i,h]=n.useState(!0),[y,o]=n.useState(null),[k,c]=n.useState([]),[E,L]=n.useState(null),[_,D]=n.useState(null),[I,S]=n.useState([]),[F,v]=n.useState([]),[p,g]=n.useState(null),[w,d]=n.useState(!1),f=n.useRef(Se()).current,H=n.useCallback(async()=>{try{const l=await R.getLspLanguages();s(l)}catch(l){o(l instanceof Error?l.message:"Failed to load LSP languages")}},[]),M=n.useCallback(async()=>{try{const l=await R.getLspStatus();r(l)}catch{r({ok:!0,bridgeInitialized:!1,servers:{}})}},[]),C=n.useCallback(async()=>{h(!0),o(null),await Promise.all([H(),M()]),h(!1)},[H,M]);n.useEffect(()=>{C()},[C]),n.useEffect(()=>{const l=setInterval(()=>{M()},1e4);return()=>clearInterval(l)},[M]);const ce=n.useCallback(async(l,b,j)=>{const m=`def:${l}:${b}:${j}`,u=f.get(m);if(u){c(u);return}d(!0);try{const N=(await R.lspDefinition(l,b,j)).definitions??[];f.set(m,N),c(N)}catch(x){o(x instanceof Error?x.message:"Definition lookup failed")}finally{d(!1)}},[f]),le=n.useCallback(async(l,b,j)=>{const m=`refs:${l}:${b}:${j}`,u=f.get(m);if(u){L(u);return}d(!0);try{const x=await R.lspReferences(l,b,j),N={total:x.totalReferences??0,refs:x.references??[],byFile:x.byFile??{}};f.set(m,N),L(N)}catch(x){o(x instanceof Error?x.message:"References lookup failed")}finally{d(!1)}},[f]),ie=n.useCallback(async(l,b,j)=>{const m=`hover:${l}:${b}:${j}`,u=f.get(m);if(u!==void 0){D(u);return}d(!0);try{const N=(await R.lspHover(l,b,j)).hover??null;f.set(m,N),D(N)}catch(x){o(x instanceof Error?x.message:"Hover lookup failed")}finally{d(!1)}},[f]),oe=n.useCallback(async l=>{const b=`diag:${l}`,j=f.get(b);if(j){S(j);return}d(!0);try{const u=(await R.lspDiagnostics(l)).diagnostics??[];f.set(b,u),S(u)}catch(m){o(m instanceof Error?m.message:"Diagnostics lookup failed")}finally{d(!1)}},[f]),de=n.useCallback(async l=>{const b=`sym:${l}`,j=f.get(b);if(j){v(j);return}d(!0);try{const u=(await R.lspSymbols(l)).symbols??[];f.set(b,u),v(u)}catch(m){o(m instanceof Error?m.message:"Symbols lookup failed")}finally{d(!1)}},[f]),xe=n.useCallback(async(l,b,j,m)=>{d(!0),g(null);try{const x=(await R.lspRename(l,b,j,m)).edit;x!=null&&x.changes?g(x.changes.map(N=>{var P,B,O,q,U,G,W,Y;return{file:N.file,startLine:(((B=(P=N.range)==null?void 0:P.start)==null?void 0:B.line)??0)+1,startCharacter:((q=(O=N.range)==null?void 0:O.start)==null?void 0:q.character)??0,endLine:(((G=(U=N.range)==null?void 0:U.end)==null?void 0:G.line)??0)+1,endCharacter:((Y=(W=N.range)==null?void 0:W.end)==null?void 0:Y.character)??0,newText:N.newText}})):g([])}catch(u){o(u instanceof Error?u.message:"Rename failed")}finally{d(!1)}},[]);return{languages:t,status:a,loading:i,error:y,operationLoading:w,definitions:k,references:E,hover:_,diagnostics:I,symbols:F,renameResult:p,refresh:C,goToDefinition:ce,findReferences:le,getHover:ie,getDiagnostics:oe,getSymbols:de,rename:xe}}const Le=[{id:"status",label:"Status",icon:ae},{id:"explorer",label:"Symbol Explorer",icon:K},{id:"diagnostics",label:"Diagnostics",icon:A},{id:"symbols",label:"Symbols",icon:V}],Q={1:{icon:Z,color:"text-danger",label:"Error"},2:{icon:A,color:"text-warning",label:"Warning"},3:{icon:te,color:"text-accent",label:"Info"},4:{icon:Ne,color:"text-muted",label:"Hint"}};function Re({status:t}){const s={ready:{bg:"bg-success/15",text:"text-success"},starting:{bg:"bg-warning/15",text:"text-warning"},stopped:{bg:"bg-muted/15",text:"text-muted"},error:{bg:"bg-danger/15",text:"text-danger"}},a=t??"not installed",r=s[a]??{bg:"bg-muted/10",text:"text-muted",border:"border-dashed"};return e.jsxs("span",{className:`inline-flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded-full ${r.bg} ${r.text} ${r.border??""} border border-current/20`,children:[e.jsx(fe,{className:"w-2 h-2 fill-current"}),a]})}function Ee({lang:t,serverStatus:s}){const a=Math.round(t.confidence*100);return e.jsxs("div",{className:"p-4 rounded-xl border border-edge bg-surface-alt shadow-sm hover:shadow-md transition-shadow space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"w-4 h-4 text-accent"}),e.jsx("span",{className:"text-sm font-semibold capitalize",children:t.languageId})]}),e.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full bg-accent/10 text-accent",children:[t.fileCount," files"]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] text-muted",children:[e.jsx("span",{children:"Confidence"}),e.jsxs("span",{children:[a,"%"]})]}),e.jsx("div",{className:"h-1 rounded-full bg-edge overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-300",style:{width:`${a}%`}})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-muted",children:"Server"}),e.jsx(Re,{status:s})]}),e.jsxs("div",{className:"text-[10px] text-muted",children:["Detected via: ",e.jsx("span",{className:"text-foreground",children:t.detectedVia})]}),t.serverCommand&&e.jsxs("div",{className:"text-[10px] text-muted truncate",title:t.serverCommand,children:["Command: ",e.jsx("code",{className:"text-foreground font-mono",children:t.serverCommand})]}),t.configFile&&e.jsxs("div",{className:"text-[10px] text-muted truncate",title:t.configFile,children:["Config: ",e.jsx("code",{className:"text-foreground font-mono",children:t.configFile})]})]})}function De({hover:t}){return e.jsxs("div",{className:"p-4 rounded-xl border border-edge bg-surface-alt space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold text-muted uppercase tracking-wider",children:"Hover Info"}),t.signature?e.jsx("pre",{className:"text-sm font-mono bg-surface p-3 rounded-lg overflow-x-auto border border-edge whitespace-pre-wrap",children:t.signature}):e.jsx("p",{className:"text-sm text-muted",children:"No signature available"}),t.documentation&&e.jsx("div",{className:"text-xs text-muted whitespace-pre-wrap",children:t.documentation}),t.language&&e.jsxs("span",{className:"text-[10px] text-muted",children:["Language: ",t.language]})]})}function ne({title:t,locations:s}){return e.jsxs("div",{className:"p-4 rounded-xl border border-edge bg-surface-alt space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-muted uppercase tracking-wider",children:[t," (",s.length,")"]}),s.length===0?e.jsx("p",{className:"text-sm text-muted",children:"No results found"}):e.jsx("ul",{className:"space-y-1",children:s.map((a,r)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs py-1.5 px-2 rounded-lg hover:bg-surface-elevated transition-colors",children:[e.jsx(be,{className:"w-3 h-3 text-muted flex-shrink-0"}),e.jsx("span",{className:"font-mono text-foreground truncate",title:a.file,children:a.file}),e.jsxs("span",{className:"text-muted flex-shrink-0",children:[":",a.startLine,":",a.startCharacter]}),a.hint&&e.jsx("span",{className:"text-accent text-[10px] ml-auto truncate",children:a.hint})]},`${a.file}-${a.startLine}-${a.startCharacter}-${r}`))})]})}function Me({references:t}){const s=Object.entries(t.byFile).sort(([,a],[,r])=>r-a);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ne,{title:"References",locations:t.refs}),s.length>0&&e.jsxs("div",{className:"p-4 rounded-xl border border-edge bg-surface-alt space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-muted uppercase tracking-wider",children:["By File (",t.total," total)"]}),e.jsx("ul",{className:"space-y-1",children:s.map(([a,r])=>e.jsxs("li",{className:"flex items-center justify-between text-xs py-1 px-2 rounded-lg hover:bg-surface-elevated transition-colors",children:[e.jsx("span",{className:"font-mono truncate text-foreground",title:a,children:a}),e.jsx("span",{className:"text-muted flex-shrink-0 ml-2",children:r})]},a))})]})]})}function _e({diagnostic:t}){const s=Q[t.severity]??Q[3],a=s.icon;return e.jsxs("div",{className:"flex items-start gap-3 py-2.5 px-3 rounded-lg border border-edge bg-surface-alt hover:shadow-sm transition-shadow",children:[e.jsx(a,{className:`w-4 h-4 flex-shrink-0 mt-0.5 ${s.color}`}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"text-xs font-mono text-muted",children:[t.file,":",t.startLine,":",t.startCharacter]}),t.source&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-surface-elevated text-muted border border-edge",children:t.source}),t.code&&e.jsxs("span",{className:"text-[10px] font-mono text-muted",children:["[",t.code,"]"]})]}),e.jsx("p",{className:"text-sm text-foreground",children:t.message})]}),e.jsx("span",{className:`text-[10px] font-medium flex-shrink-0 ${s.color}`,children:s.label})]})}const Ie={Function:"bg-accent/15 text-accent",Method:"bg-accent/15 text-accent",Class:"bg-warning/15 text-warning",Interface:"bg-success/15 text-success",Enum:"bg-danger/15 text-danger",Variable:"bg-muted/15 text-muted",Property:"bg-muted/15 text-muted",Constant:"bg-success/15 text-success",Module:"bg-warning/15 text-warning",Namespace:"bg-warning/15 text-warning"};function re({symbol:t,depth:s}){const[a,r]=n.useState(s<2),i=t.children&&t.children.length>0,h=Ie[t.kind]??"bg-muted/10 text-muted";return e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>i&&r(!a),className:`flex items-center gap-2 w-full text-left py-1.5 px-2 rounded-lg hover:bg-surface-elevated transition-colors text-xs ${i?"cursor-pointer":"cursor-default"}`,style:{paddingLeft:`${s*16+8}px`},children:[i?a?e.jsx(me,{className:"w-3 h-3 text-muted flex-shrink-0"}):e.jsx(ue,{className:"w-3 h-3 text-muted flex-shrink-0"}):e.jsx("span",{className:"w-3 flex-shrink-0"}),e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-0.5 rounded ${h} flex-shrink-0`,children:t.kind}),e.jsx("span",{className:"font-mono text-foreground truncate",children:t.name}),e.jsxs("span",{className:"text-muted ml-auto flex-shrink-0",children:[t.startLine,"-",t.endLine]})]}),a&&i&&t.children.map((y,o)=>e.jsx(re,{symbol:y,depth:s+1},`${y.name}-${y.startLine}-${o}`))]})}function Fe({symbols:t}){return t.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted",children:[e.jsx(X,{className:"w-8 h-8 mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No symbols found for this file"})]}):e.jsx("div",{className:"rounded-xl border border-edge bg-surface-alt overflow-hidden divide-y divide-edge",children:t.map((s,a)=>e.jsx(re,{symbol:s,depth:0},`${s.name}-${s.startLine}-${a}`))})}function ze({languages:t,status:s}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 pt-4",children:[e.jsx(ae,{className:"w-4 h-4 text-muted"}),e.jsx("span",{className:"text-xs text-muted",children:"Bridge:"}),e.jsx("span",{className:`text-xs font-medium ${s!=null&&s.bridgeInitialized?"text-success":"text-warning"}`,children:s!=null&&s.bridgeInitialized?"Initialized":"Not initialized"})]}),t.detected.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted",children:[e.jsx(ee,{className:"w-10 h-10 mb-3 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No languages detected in this project"}),e.jsx("p",{className:"text-xs mt-1",children:"The LSP bridge will detect languages from project configuration files"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 p-4",children:t.detected.map(a=>e.jsx(Ee,{lang:a,serverStatus:s==null?void 0:s.servers[a.languageId]},a.languageId))}),t.supportedLanguages.length>0&&e.jsxs("div",{className:"px-4 py-2 text-xs text-muted border-t border-edge",children:["Supported: ",t.supportedLanguages.join(", ")]})]})}function Te({edits:t}){return e.jsxs("div",{className:"p-4 rounded-xl border border-edge bg-surface-alt space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-muted uppercase tracking-wider",children:["Rename Edits (",t.length,")"]}),t.length===0?e.jsx("p",{className:"text-sm text-muted",children:"No edits produced — the symbol may not support rename"}):e.jsx("ul",{className:"space-y-1",children:t.map((s,a)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs py-1.5 px-2 rounded-lg hover:bg-surface-elevated transition-colors",children:[e.jsx(se,{className:"w-3 h-3 text-warning flex-shrink-0"}),e.jsx("span",{className:"font-mono text-foreground truncate",title:s.file,children:s.file}),e.jsxs("span",{className:"text-muted flex-shrink-0",children:[":",s.startLine,":",s.startCharacter]}),e.jsx("span",{className:"text-accent ml-auto text-[10px] truncate",children:s.newText})]},`${s.file}-${s.startLine}-${a}`))})]})}function He({goToDefinition:t,findReferences:s,getHover:a,rename:r,operationLoading:i,definitions:h,references:y,hover:o,renameResult:k}){const[c,E]=n.useState(""),[L,_]=n.useState(""),[D,I]=n.useState(""),[S,F]=n.useState(""),v=parseInt(L,10)||0,p=parseInt(D,10)||0,g=c.trim().length>0&&v>0,w=g&&S.trim().length>0,d=n.useCallback(()=>{g&&t(c.trim(),v,p)},[c,v,p,g,t]),T=n.useCallback(()=>{g&&s(c.trim(),v,p)},[c,v,p,g,s]),f=n.useCallback(()=>{g&&a(c.trim(),v,p)},[c,v,p,g,a]),H=n.useCallback(()=>{w&&r(c.trim(),v,p,S.trim())},[c,v,p,S,w,r]),M=o!==null||h.length>0||y!==null||k!==null;return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("input",{placeholder:"File path (e.g. src/main.ts)",value:c,onChange:C=>E(C.target.value),className:"flex-1 min-w-[200px] px-3 py-2 text-sm border border-edge rounded-lg bg-surface font-mono focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsx("input",{placeholder:"Line",type:"number",min:1,value:L,onChange:C=>_(C.target.value),className:"w-20 px-3 py-2 text-sm border border-edge rounded-lg bg-surface text-center focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsx("input",{placeholder:"Col",type:"number",min:0,value:D,onChange:C=>I(C.target.value),className:"w-20 px-3 py-2 text-sm border border-edge rounded-lg bg-surface text-center focus:outline-none focus:ring-1 focus:ring-accent"})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",onClick:d,disabled:!g||i,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-accent text-white hover:bg-accent-light disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(X,{className:"w-3.5 h-3.5"}),"Definition"]}),e.jsxs("button",{type:"button",onClick:T,disabled:!g||i,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg border border-edge hover:bg-surface-elevated disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(K,{className:"w-3.5 h-3.5"}),"References"]}),e.jsxs("button",{type:"button",onClick:f,disabled:!g||i,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg border border-edge hover:bg-surface-elevated disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(te,{className:"w-3.5 h-3.5"}),"Hover"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{placeholder:"New name",value:S,onChange:C=>F(C.target.value),className:"w-32 px-2 py-1.5 text-xs border border-edge rounded-lg bg-surface font-mono focus:outline-none focus:ring-1 focus:ring-warning"}),e.jsxs("button",{type:"button",onClick:H,disabled:!w||i,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg border border-warning text-warning hover:bg-warning/10 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(se,{className:"w-3.5 h-3.5"}),"Rename"]})]})]}),i&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted py-2",children:[e.jsx(z,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading..."})]}),!i&&M&&e.jsxs("div",{className:"space-y-3",children:[o&&e.jsx(De,{hover:o}),h.length>0&&e.jsx(ne,{title:"Definitions",locations:h}),y&&e.jsx(Me,{references:y}),k&&e.jsx(Te,{edits:k})]}),!i&&!M&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted",children:[e.jsx(K,{className:"w-10 h-10 mb-3 opacity-40"}),e.jsx("p",{className:"text-sm",children:"Enter a file path and position to explore symbols"}),e.jsx("p",{className:"text-xs mt-1",children:"Use Definition, References, Hover, or Rename to inspect code"})]})]})}function Ae({getDiagnostics:t,operationLoading:s,diagnostics:a}){const[r,i]=n.useState(""),[h,y]=n.useState(!1),o=n.useCallback(()=>{r.trim()&&(y(!0),t(r.trim()))},[r,t]),k=n.useCallback(c=>{c.key==="Enter"&&o()},[o]);return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{placeholder:"File path (e.g. src/main.ts)",value:r,onChange:c=>i(c.target.value),onKeyDown:k,className:"flex-1 px-3 py-2 text-sm border border-edge rounded-lg bg-surface font-mono focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsxs("button",{type:"button",onClick:o,disabled:!r.trim()||s,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-accent text-white hover:bg-accent-light disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(A,{className:"w-3.5 h-3.5"}),"Load"]})]}),s&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted py-2",children:[e.jsx(z,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading diagnostics..."})]}),!s&&a.length>0&&e.jsx("div",{className:"space-y-2",children:a.map((c,E)=>e.jsx(_e,{diagnostic:c},`${c.file}-${c.startLine}-${c.startCharacter}-${E}`))}),!s&&a.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted",children:[e.jsx(A,{className:"w-10 h-10 mb-3 opacity-40"}),h?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm",children:"No diagnostics found for this file"}),e.jsx("p",{className:"text-xs mt-1",children:"The file may be error-free or the language server may not support diagnostics"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm",children:"Enter a file path to load diagnostics"}),e.jsx("p",{className:"text-xs mt-1",children:"View errors, warnings, and hints from the language server"})]})]})]})}function Ve({getSymbols:t,operationLoading:s,symbols:a}){const[r,i]=n.useState(""),[h,y]=n.useState(!1),o=n.useCallback(()=>{r.trim()&&(y(!0),t(r.trim()))},[r,t]),k=n.useCallback(c=>{c.key==="Enter"&&o()},[o]);return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{placeholder:"File path (e.g. src/main.ts)",value:r,onChange:c=>i(c.target.value),onKeyDown:k,className:"flex-1 px-3 py-2 text-sm border border-edge rounded-lg bg-surface font-mono focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsxs("button",{type:"button",onClick:o,disabled:!r.trim()||s,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-accent text-white hover:bg-accent-light disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(V,{className:"w-3.5 h-3.5"}),"Load"]})]}),s&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted py-2",children:[e.jsx(z,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading symbols..."})]}),!s&&h&&e.jsx(Fe,{symbols:a}),!s&&!h&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted",children:[e.jsx(V,{className:"w-10 h-10 mb-3 opacity-40"}),e.jsx("p",{className:"text-sm",children:"Enter a file path to explore document symbols"}),e.jsx("p",{className:"text-xs mt-1",children:"View functions, classes, interfaces, and other symbols"})]})]})}function qe(){const{languages:t,status:s,loading:a,error:r,operationLoading:i,definitions:h,references:y,hover:o,diagnostics:k,symbols:c,renameResult:E,refresh:L,goToDefinition:_,findReferences:D,getHover:I,getDiagnostics:S,getSymbols:F,rename:v}=$e(),[p,g]=n.useState("status");return r&&!t?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[e.jsx(Z,{className:"w-10 h-10 text-danger"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Failed to load LSP data"}),e.jsx("p",{className:"text-xs text-muted mt-1",children:r})]}),e.jsxs("button",{type:"button",onClick:()=>void L(),className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium rounded-md border border-edge text-muted hover:text-foreground transition-colors cursor-pointer",children:[e.jsx(z,{className:"w-3 h-3"}),"Retry"]})]}):a||!t?e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-edge bg-surface-alt",children:[e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((w,d)=>e.jsx("div",{className:"h-7 w-28 rounded-lg bg-surface animate-pulse"},d))}),e.jsx("div",{className:"h-7 w-20 rounded-lg bg-surface animate-pulse"})]}),e.jsx("div",{className:"flex-1 p-4",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:3}).map((w,d)=>e.jsx("div",{className:"h-44 rounded-xl border border-edge bg-surface-alt animate-pulse"},d))})})]}):e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-edge bg-surface-alt",children:[e.jsx("div",{className:"flex items-center gap-1",children:Le.map(w=>{const d=w.icon,T=p===w.id;return e.jsxs("button",{type:"button",onClick:()=>g(w.id),className:`
|
|
36
|
+
*/const we=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],ae=I("server",we),J=300*1e3;function ke(){const t=new Map;return{get(s){const a=t.get(s);if(a){if(Date.now()-a.timestamp>J){t.delete(s);return}return a.data}},set(s,a){if(t.set(s,{data:a,timestamp:Date.now()}),t.size>200){const r=Date.now();for(const[i,h]of t)r-h.timestamp>J&&t.delete(i)}}}}function Ce(){const[t,s]=n.useState(null),[a,r]=n.useState(null),[i,h]=n.useState(!0),[y,o]=n.useState(null),[k,c]=n.useState([]),[R,$]=n.useState(null),[F,E]=n.useState(null),[M,S]=n.useState([]),[_,v]=n.useState([]),[p,g]=n.useState(null),[w,d]=n.useState(!1),f=n.useRef(ke()).current,H=n.useCallback(async()=>{try{const l=await L.getLspLanguages();s(l)}catch(l){o(l instanceof Error?l.message:"Failed to load LSP languages")}},[]),D=n.useCallback(async()=>{try{const l=await L.getLspStatus();r(l)}catch{r({ok:!0,bridgeInitialized:!1,servers:{}})}},[]),C=n.useCallback(async()=>{h(!0),o(null),await Promise.all([H(),D()]),h(!1)},[H,D]);n.useEffect(()=>{C()},[C]),n.useEffect(()=>{const l=setInterval(()=>{D()},1e4);return()=>clearInterval(l)},[D]);const ce=n.useCallback(async(l,b,j)=>{const m=`def:${l}:${b}:${j}`,u=f.get(m);if(u){c(u);return}d(!0);try{const N=(await L.lspDefinition(l,b,j)).definitions??[];f.set(m,N),c(N)}catch(x){o(x instanceof Error?x.message:"Definition lookup failed")}finally{d(!1)}},[f]),le=n.useCallback(async(l,b,j)=>{const m=`refs:${l}:${b}:${j}`,u=f.get(m);if(u){$(u);return}d(!0);try{const x=await L.lspReferences(l,b,j),N={total:x.totalReferences??0,refs:x.references??[],byFile:x.byFile??{}};f.set(m,N),$(N)}catch(x){o(x instanceof Error?x.message:"References lookup failed")}finally{d(!1)}},[f]),ie=n.useCallback(async(l,b,j)=>{const m=`hover:${l}:${b}:${j}`,u=f.get(m);if(u!==void 0){E(u);return}d(!0);try{const N=(await L.lspHover(l,b,j)).hover??null;f.set(m,N),E(N)}catch(x){o(x instanceof Error?x.message:"Hover lookup failed")}finally{d(!1)}},[f]),oe=n.useCallback(async l=>{const b=`diag:${l}`,j=f.get(b);if(j){S(j);return}d(!0);try{const u=(await L.lspDiagnostics(l)).diagnostics??[];f.set(b,u),S(u)}catch(m){o(m instanceof Error?m.message:"Diagnostics lookup failed")}finally{d(!1)}},[f]),de=n.useCallback(async l=>{const b=`sym:${l}`,j=f.get(b);if(j){v(j);return}d(!0);try{const u=(await L.lspSymbols(l)).symbols??[];f.set(b,u),v(u)}catch(m){o(m instanceof Error?m.message:"Symbols lookup failed")}finally{d(!1)}},[f]),xe=n.useCallback(async(l,b,j,m)=>{d(!0),g(null);try{const x=(await L.lspRename(l,b,j,m)).edit;x!=null&&x.changes?g(x.changes.map(N=>{var P,B,O,q,U,G,W,Y;return{file:N.file,startLine:(((B=(P=N.range)==null?void 0:P.start)==null?void 0:B.line)??0)+1,startCharacter:((q=(O=N.range)==null?void 0:O.start)==null?void 0:q.character)??0,endLine:(((G=(U=N.range)==null?void 0:U.end)==null?void 0:G.line)??0)+1,endCharacter:((Y=(W=N.range)==null?void 0:W.end)==null?void 0:Y.character)??0,newText:N.newText}})):g([])}catch(u){o(u instanceof Error?u.message:"Rename failed")}finally{d(!1)}},[]);return{languages:t,status:a,loading:i,error:y,operationLoading:w,definitions:k,references:R,hover:F,diagnostics:M,symbols:_,renameResult:p,refresh:C,goToDefinition:ce,findReferences:le,getHover:ie,getDiagnostics:oe,getSymbols:de,rename:xe}}const Se=[{id:"status",label:"Status",icon:ae},{id:"explorer",label:"Symbol Explorer",icon:K},{id:"diagnostics",label:"Diagnostics",icon:A},{id:"symbols",label:"Symbols",icon:V}],Q={1:{icon:Z,color:"text-danger",label:"Error"},2:{icon:A,color:"text-warning",label:"Warning"},3:{icon:te,color:"text-accent",label:"Info"},4:{icon:ye,color:"text-muted",label:"Hint"}};function $e({status:t}){const s={ready:{bg:"bg-success/15",text:"text-success"},starting:{bg:"bg-warning/15",text:"text-warning"},stopped:{bg:"bg-muted/15",text:"text-muted"},error:{bg:"bg-danger/15",text:"text-danger"}},a=t??"not installed",r=s[a]??{bg:"bg-muted/10",text:"text-muted",border:"border-dashed"};return e.jsxs("span",{className:`inline-flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded-full ${r.bg} ${r.text} ${r.border??""} border border-current/20`,children:[e.jsx(fe,{className:"w-2 h-2 fill-current"}),a]})}function Le({lang:t,serverStatus:s}){const a=Math.round(t.confidence*100);return e.jsxs("div",{className:"p-4 rounded-xl border border-edge bg-surface-alt shadow-sm hover:shadow-md transition-shadow space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"w-4 h-4 text-accent"}),e.jsx("span",{className:"text-sm font-semibold capitalize",children:t.languageId})]}),e.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full bg-accent/10 text-accent",children:[t.fileCount," files"]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] text-muted",children:[e.jsx("span",{children:"Confidence"}),e.jsxs("span",{children:[a,"%"]})]}),e.jsx("div",{className:"h-1 rounded-full bg-edge overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-300",style:{width:`${a}%`}})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-muted",children:"Server"}),e.jsx($e,{status:s})]}),e.jsxs("div",{className:"text-[10px] text-muted",children:["Detected via: ",e.jsx("span",{className:"text-foreground",children:t.detectedVia})]}),t.serverCommand&&e.jsxs("div",{className:"text-[10px] text-muted truncate",title:t.serverCommand,children:["Command: ",e.jsx("code",{className:"text-foreground font-mono",children:t.serverCommand})]}),t.configFile&&e.jsxs("div",{className:"text-[10px] text-muted truncate",title:t.configFile,children:["Config: ",e.jsx("code",{className:"text-foreground font-mono",children:t.configFile})]})]})}function Re({hover:t}){return e.jsxs("div",{className:"p-4 rounded-xl border border-edge bg-surface-alt space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold text-muted uppercase tracking-wider",children:"Hover Info"}),t.signature?e.jsx("pre",{className:"text-sm font-mono bg-surface p-3 rounded-lg overflow-x-auto border border-edge whitespace-pre-wrap",children:t.signature}):e.jsx("p",{className:"text-sm text-muted",children:"No signature available"}),t.documentation&&e.jsx("div",{className:"text-xs text-muted whitespace-pre-wrap",children:t.documentation}),t.language&&e.jsxs("span",{className:"text-[10px] text-muted",children:["Language: ",t.language]})]})}function ne({title:t,locations:s}){return e.jsxs("div",{className:"p-4 rounded-xl border border-edge bg-surface-alt space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-muted uppercase tracking-wider",children:[t," (",s.length,")"]}),s.length===0?e.jsx("p",{className:"text-sm text-muted",children:"No results found"}):e.jsx("ul",{className:"space-y-1",children:s.map((a,r)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs py-1.5 px-2 rounded-lg hover:bg-surface-elevated transition-colors",children:[e.jsx(ge,{className:"w-3 h-3 text-muted flex-shrink-0"}),e.jsx("span",{className:"font-mono text-foreground truncate",title:a.file,children:a.file}),e.jsxs("span",{className:"text-muted flex-shrink-0",children:[":",a.startLine,":",a.startCharacter]}),a.hint&&e.jsx("span",{className:"text-accent text-[10px] ml-auto truncate",children:a.hint})]},`${a.file}-${a.startLine}-${a.startCharacter}-${r}`))})]})}function Ee({references:t}){const s=Object.entries(t.byFile).sort(([,a],[,r])=>r-a);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ne,{title:"References",locations:t.refs}),s.length>0&&e.jsxs("div",{className:"p-4 rounded-xl border border-edge bg-surface-alt space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-muted uppercase tracking-wider",children:["By File (",t.total," total)"]}),e.jsx("ul",{className:"space-y-1",children:s.map(([a,r])=>e.jsxs("li",{className:"flex items-center justify-between text-xs py-1 px-2 rounded-lg hover:bg-surface-elevated transition-colors",children:[e.jsx("span",{className:"font-mono truncate text-foreground",title:a,children:a}),e.jsx("span",{className:"text-muted flex-shrink-0 ml-2",children:r})]},a))})]})]})}function De({diagnostic:t}){const s=Q[t.severity]??Q[3],a=s.icon;return e.jsxs("div",{className:"flex items-start gap-3 py-2.5 px-3 rounded-lg border border-edge bg-surface-alt hover:shadow-sm transition-shadow",children:[e.jsx(a,{className:`w-4 h-4 flex-shrink-0 mt-0.5 ${s.color}`}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"text-xs font-mono text-muted",children:[t.file,":",t.startLine,":",t.startCharacter]}),t.source&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-surface-elevated text-muted border border-edge",children:t.source}),t.code&&e.jsxs("span",{className:"text-[10px] font-mono text-muted",children:["[",t.code,"]"]})]}),e.jsx("p",{className:"text-sm text-foreground",children:t.message})]}),e.jsx("span",{className:`text-[10px] font-medium flex-shrink-0 ${s.color}`,children:s.label})]})}const Ie={Function:"bg-accent/15 text-accent",Method:"bg-accent/15 text-accent",Class:"bg-warning/15 text-warning",Interface:"bg-success/15 text-success",Enum:"bg-danger/15 text-danger",Variable:"bg-muted/15 text-muted",Property:"bg-muted/15 text-muted",Constant:"bg-success/15 text-success",Module:"bg-warning/15 text-warning",Namespace:"bg-warning/15 text-warning"};function re({symbol:t,depth:s}){const[a,r]=n.useState(s<2),i=t.children&&t.children.length>0,h=Ie[t.kind]??"bg-muted/10 text-muted";return e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>i&&r(!a),className:`flex items-center gap-2 w-full text-left py-1.5 px-2 rounded-lg hover:bg-surface-elevated transition-colors text-xs ${i?"cursor-pointer":"cursor-default"}`,style:{paddingLeft:`${s*16+8}px`},children:[i?a?e.jsx(me,{className:"w-3 h-3 text-muted flex-shrink-0"}):e.jsx(ue,{className:"w-3 h-3 text-muted flex-shrink-0"}):e.jsx("span",{className:"w-3 flex-shrink-0"}),e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-0.5 rounded ${h} flex-shrink-0`,children:t.kind}),e.jsx("span",{className:"font-mono text-foreground truncate",children:t.name}),e.jsxs("span",{className:"text-muted ml-auto flex-shrink-0",children:[t.startLine,"-",t.endLine]})]}),a&&i&&t.children.map((y,o)=>e.jsx(re,{symbol:y,depth:s+1},`${y.name}-${y.startLine}-${o}`))]})}function Fe({symbols:t}){return t.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted",children:[e.jsx(X,{className:"w-8 h-8 mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No symbols found for this file"})]}):e.jsx("div",{className:"rounded-xl border border-edge bg-surface-alt overflow-hidden divide-y divide-edge",children:t.map((s,a)=>e.jsx(re,{symbol:s,depth:0},`${s.name}-${s.startLine}-${a}`))})}function Me({languages:t,status:s}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 pt-4",children:[e.jsx(ae,{className:"w-4 h-4 text-muted"}),e.jsx("span",{className:"text-xs text-muted",children:"Bridge:"}),e.jsx("span",{className:`text-xs font-medium ${s!=null&&s.bridgeInitialized?"text-success":"text-warning"}`,children:s!=null&&s.bridgeInitialized?"Initialized":"Not initialized"})]}),t.detected.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted",children:[e.jsx(ee,{className:"w-10 h-10 mb-3 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No languages detected in this project"}),e.jsx("p",{className:"text-xs mt-1",children:"The LSP bridge will detect languages from project configuration files"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 p-4",children:t.detected.map(a=>e.jsx(Le,{lang:a,serverStatus:s==null?void 0:s.servers[a.languageId]},a.languageId))}),t.supportedLanguages.length>0&&e.jsxs("div",{className:"px-4 py-2 text-xs text-muted border-t border-edge",children:["Supported: ",t.supportedLanguages.join(", ")]})]})}function _e({edits:t}){return e.jsxs("div",{className:"p-4 rounded-xl border border-edge bg-surface-alt space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold text-muted uppercase tracking-wider",children:["Rename Edits (",t.length,")"]}),t.length===0?e.jsx("p",{className:"text-sm text-muted",children:"No edits produced — the symbol may not support rename"}):e.jsx("ul",{className:"space-y-1",children:t.map((s,a)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs py-1.5 px-2 rounded-lg hover:bg-surface-elevated transition-colors",children:[e.jsx(se,{className:"w-3 h-3 text-warning flex-shrink-0"}),e.jsx("span",{className:"font-mono text-foreground truncate",title:s.file,children:s.file}),e.jsxs("span",{className:"text-muted flex-shrink-0",children:[":",s.startLine,":",s.startCharacter]}),e.jsx("span",{className:"text-accent ml-auto text-[10px] truncate",children:s.newText})]},`${s.file}-${s.startLine}-${a}`))})]})}function ze({goToDefinition:t,findReferences:s,getHover:a,rename:r,operationLoading:i,definitions:h,references:y,hover:o,renameResult:k}){const[c,R]=n.useState(""),[$,F]=n.useState(""),[E,M]=n.useState(""),[S,_]=n.useState(""),v=parseInt($,10)||0,p=parseInt(E,10)||0,g=c.trim().length>0&&v>0,w=g&&S.trim().length>0,d=n.useCallback(()=>{g&&t(c.trim(),v,p)},[c,v,p,g,t]),T=n.useCallback(()=>{g&&s(c.trim(),v,p)},[c,v,p,g,s]),f=n.useCallback(()=>{g&&a(c.trim(),v,p)},[c,v,p,g,a]),H=n.useCallback(()=>{w&&r(c.trim(),v,p,S.trim())},[c,v,p,S,w,r]),D=o!==null||h.length>0||y!==null||k!==null;return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("input",{placeholder:"File path (e.g. src/main.ts)",value:c,onChange:C=>R(C.target.value),className:"flex-1 min-w-[200px] px-3 py-2 text-sm border border-edge rounded-lg bg-surface font-mono focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsx("input",{placeholder:"Line",type:"number",min:1,value:$,onChange:C=>F(C.target.value),className:"w-20 px-3 py-2 text-sm border border-edge rounded-lg bg-surface text-center focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsx("input",{placeholder:"Col",type:"number",min:0,value:E,onChange:C=>M(C.target.value),className:"w-20 px-3 py-2 text-sm border border-edge rounded-lg bg-surface text-center focus:outline-none focus:ring-1 focus:ring-accent"})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",onClick:d,disabled:!g||i,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-accent text-white hover:bg-accent-light disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(X,{className:"w-3.5 h-3.5"}),"Definition"]}),e.jsxs("button",{type:"button",onClick:T,disabled:!g||i,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg border border-edge hover:bg-surface-elevated disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(K,{className:"w-3.5 h-3.5"}),"References"]}),e.jsxs("button",{type:"button",onClick:f,disabled:!g||i,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg border border-edge hover:bg-surface-elevated disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(te,{className:"w-3.5 h-3.5"}),"Hover"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{placeholder:"New name",value:S,onChange:C=>_(C.target.value),className:"w-32 px-2 py-1.5 text-xs border border-edge rounded-lg bg-surface font-mono focus:outline-none focus:ring-1 focus:ring-warning"}),e.jsxs("button",{type:"button",onClick:H,disabled:!w||i,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg border border-warning text-warning hover:bg-warning/10 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(se,{className:"w-3.5 h-3.5"}),"Rename"]})]})]}),i&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted py-2",children:[e.jsx(z,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading..."})]}),!i&&D&&e.jsxs("div",{className:"space-y-3",children:[o&&e.jsx(Re,{hover:o}),h.length>0&&e.jsx(ne,{title:"Definitions",locations:h}),y&&e.jsx(Ee,{references:y}),k&&e.jsx(_e,{edits:k})]}),!i&&!D&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted",children:[e.jsx(K,{className:"w-10 h-10 mb-3 opacity-40"}),e.jsx("p",{className:"text-sm",children:"Enter a file path and position to explore symbols"}),e.jsx("p",{className:"text-xs mt-1",children:"Use Definition, References, Hover, or Rename to inspect code"})]})]})}function Te({getDiagnostics:t,operationLoading:s,diagnostics:a}){const[r,i]=n.useState(""),[h,y]=n.useState(!1),o=n.useCallback(()=>{r.trim()&&(y(!0),t(r.trim()))},[r,t]),k=n.useCallback(c=>{c.key==="Enter"&&o()},[o]);return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{placeholder:"File path (e.g. src/main.ts)",value:r,onChange:c=>i(c.target.value),onKeyDown:k,className:"flex-1 px-3 py-2 text-sm border border-edge rounded-lg bg-surface font-mono focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsxs("button",{type:"button",onClick:o,disabled:!r.trim()||s,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-accent text-white hover:bg-accent-light disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(A,{className:"w-3.5 h-3.5"}),"Load"]})]}),s&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted py-2",children:[e.jsx(z,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading diagnostics..."})]}),!s&&a.length>0&&e.jsx("div",{className:"space-y-2",children:a.map((c,R)=>e.jsx(De,{diagnostic:c},`${c.file}-${c.startLine}-${c.startCharacter}-${R}`))}),!s&&a.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted",children:[e.jsx(A,{className:"w-10 h-10 mb-3 opacity-40"}),h?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm",children:"No diagnostics found for this file"}),e.jsx("p",{className:"text-xs mt-1",children:"The file may be error-free or the language server may not support diagnostics"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm",children:"Enter a file path to load diagnostics"}),e.jsx("p",{className:"text-xs mt-1",children:"View errors, warnings, and hints from the language server"})]})]})]})}function He({getSymbols:t,operationLoading:s,symbols:a}){const[r,i]=n.useState(""),[h,y]=n.useState(!1),o=n.useCallback(()=>{r.trim()&&(y(!0),t(r.trim()))},[r,t]),k=n.useCallback(c=>{c.key==="Enter"&&o()},[o]);return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{placeholder:"File path (e.g. src/main.ts)",value:r,onChange:c=>i(c.target.value),onKeyDown:k,className:"flex-1 px-3 py-2 text-sm border border-edge rounded-lg bg-surface font-mono focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsxs("button",{type:"button",onClick:o,disabled:!r.trim()||s,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-accent text-white hover:bg-accent-light disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(V,{className:"w-3.5 h-3.5"}),"Load"]})]}),s&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted py-2",children:[e.jsx(z,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading symbols..."})]}),!s&&h&&e.jsx(Fe,{symbols:a}),!s&&!h&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted",children:[e.jsx(V,{className:"w-10 h-10 mb-3 opacity-40"}),e.jsx("p",{className:"text-sm",children:"Enter a file path to explore document symbols"}),e.jsx("p",{className:"text-xs mt-1",children:"View functions, classes, interfaces, and other symbols"})]})]})}function Be(){const{languages:t,status:s,loading:a,error:r,operationLoading:i,definitions:h,references:y,hover:o,diagnostics:k,symbols:c,renameResult:R,refresh:$,goToDefinition:F,findReferences:E,getHover:M,getDiagnostics:S,getSymbols:_,rename:v}=Ce(),[p,g]=n.useState("status");return r&&!t?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[e.jsx(Z,{className:"w-10 h-10 text-danger"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Failed to load LSP data"}),e.jsx("p",{className:"text-xs text-muted mt-1",children:r})]}),e.jsxs("button",{type:"button",onClick:()=>void $(),className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium rounded-md border border-edge text-muted hover:text-foreground transition-colors cursor-pointer",children:[e.jsx(z,{className:"w-3 h-3"}),"Retry"]})]}):a||!t?e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-edge bg-surface-alt",children:[e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((w,d)=>e.jsx("div",{className:"h-7 w-28 rounded-lg bg-surface animate-pulse"},d))}),e.jsx("div",{className:"h-7 w-20 rounded-lg bg-surface animate-pulse"})]}),e.jsx("div",{className:"flex-1 p-4",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:3}).map((w,d)=>e.jsx("div",{className:"h-44 rounded-xl border border-edge bg-surface-alt animate-pulse"},d))})})]}):e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-edge bg-surface-alt",children:[e.jsx("div",{className:"flex items-center gap-1",children:Se.map(w=>{const d=w.icon,T=p===w.id;return e.jsxs("button",{type:"button",onClick:()=>g(w.id),className:`
|
|
47
37
|
inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg transition-colors
|
|
48
38
|
${T?"bg-accent/10 text-accent":"text-muted hover:bg-surface-elevated hover:text-foreground"}
|
|
49
|
-
`,children:[e.jsx(d,{className:"w-3.5 h-3.5"}),w.label]},w.id)})}),e.jsxs("button",{type:"button",onClick:()=>void
|
|
39
|
+
`,children:[e.jsx(d,{className:"w-3.5 h-3.5"}),w.label]},w.id)})}),e.jsxs("button",{type:"button",onClick:()=>void $(),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-lg border border-edge hover:bg-surface-elevated transition-colors",title:"Refresh LSP data",children:[e.jsx(z,{className:`w-3 h-3 ${a?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]})]}),r&&e.jsx("div",{className:"px-4 py-2 text-xs text-danger bg-danger/5 border-b border-danger/20",children:r}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[p==="status"&&e.jsx(Me,{languages:t,status:s}),p==="explorer"&&e.jsx(ze,{goToDefinition:F,findReferences:E,getHover:M,rename:v,operationLoading:i,definitions:h,references:y,hover:o,renameResult:R}),p==="diagnostics"&&e.jsx(Te,{getDiagnostics:S,operationLoading:i,diagnostics:k}),p==="symbols"&&e.jsx(He,{getSymbols:_,operationLoading:i,symbols:c})]})]})}export{Be as LspTab};
|
package/dist/web/dashboard/dist/assets/{memories-tab-CzgCahnV.js → memories-tab-blOtravG.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,a as N,j as e}from"./index-
|
|
1
|
+
import{r as c,a as N,j as e}from"./index-DfEJaZLA.js";function w(r){const o=[];for(const n of r){const t=n.name.split("/");let i=o;for(let l=0;l<t.length;l++){const s=t[l],d=t.slice(0,l+1).join("/"),u=l===t.length-1;let x=i.find(f=>f.name===s);x||(x={name:s,path:d,children:[]},u&&(x.memory=n),i.push(x)),u&&!x.memory&&(x.memory=n),i=x.children}}return o}function k(){const[r,o]=c.useState([]),[n,t]=c.useState(null),[i,l]=c.useState(null),[s,d]=c.useState(!0),[u,x]=c.useState(!1),[f,g]=c.useState(new Map),m=c.useCallback(async()=>{try{d(!0);const a=await N.getMemories().catch(()=>[]);o(a)}catch(a){l(a instanceof Error?a.message:"Failed to load")}finally{d(!1)}},[]);c.useEffect(()=>{m()},[m]);const p=c.useCallback(async a=>{t(a);const h=f.get(a.name);if(h!==void 0){t({...a,content:h});return}try{x(!0);const j=await N.readMemory(a.name);g(y=>{const b=new Map(y);return b.set(a.name,j.content),b}),t({...a,content:j.content})}catch{t({...a,content:"[Failed to load content]"})}finally{x(!1)}},[f]);return s?e.jsxs("div",{className:"h-full flex",children:[e.jsxs("div",{className:"w-64 border-r border-edge bg-surface-alt p-2 space-y-2",children:[e.jsx("div",{className:"h-4 w-16 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"h-6 w-full rounded bg-surface animate-pulse"}),Array.from({length:6}).map((a,h)=>e.jsx("div",{className:"h-4 rounded bg-surface animate-pulse",style:{width:`${50+Math.random()*40}%`,marginLeft:`${h%3*12}px`}},h))]}),e.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-xs",children:"Loading memories..."})]}):i?e.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load: ",i]}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-edge bg-surface-alt",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Memories"}),e.jsx(C,{label:"Memories",active:r.length>0}),e.jsxs("span",{className:"text-[10px] text-muted",children:[r.length," memories"]})]}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx(S,{memories:r,selectedMemory:n,onSelect:p}),e.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:e.jsx(M,{selectedMemory:n,contentLoading:u})})]})]})}function C({label:r,active:o}){const n=o?"var(--color-success)":"var(--color-text-muted)",t=o?"Active":"No data";return e.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full",style:{background:`${n}20`,color:n},children:[r,": ",t]})}function S({memories:r,selectedMemory:o,onSelect:n}){const[t,i]=c.useState(""),[l,s]=c.useState(!1),[d,u]=c.useState(new Set),x=c.useMemo(()=>{if(!t.trim())return r;const m=t.toLowerCase();return r.filter(p=>p.name.toLowerCase().includes(m))},[r,t]),f=c.useMemo(()=>w(x),[x]),g=c.useCallback(m=>{u(p=>{const a=new Set(p);return a.has(m)?a.delete(m):a.add(m),a})},[]);return l?e.jsx("div",{className:"w-8 border-r border-edge bg-surface-alt flex flex-col items-center pt-2",children:e.jsx("button",{onClick:()=>s(!1),className:"text-[10px] text-muted hover:text-foreground rotate-90",title:"Expand file explorer",children:"Files"})}):e.jsxs("div",{className:"w-64 border-r border-edge bg-surface-alt flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-b border-edge",children:[e.jsx("span",{className:"text-[10px] font-semibold text-muted uppercase tracking-wider",children:"Files"}),e.jsx("button",{onClick:()=>s(!0),className:"text-[10px] text-muted hover:text-foreground",title:"Collapse",children:"✕"})]}),e.jsx("div",{className:"px-2 py-1.5 border-b border-edge",children:e.jsx("input",{type:"text",value:t,onChange:m=>i(m.target.value),placeholder:"Search files...",className:"w-full text-[11px] px-2 py-1 rounded bg-surface border border-edge focus:outline-none focus:border-accent"})}),e.jsx("div",{className:"flex-1 overflow-y-auto text-[11px]",children:r.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-muted",children:"No memories"}):e.jsx(v,{nodes:f,depth:0,expandedPaths:d,onToggle:g,selectedMemory:o,onSelect:n})})]})}function v({nodes:r,depth:o,expandedPaths:n,onToggle:t,selectedMemory:i,onSelect:l}){return e.jsx(e.Fragment,{children:r.map(s=>{const d=s.children.length>0,u=n.has(s.path),x=s.memory!=null&&(i==null?void 0:i.name)===s.memory.name;return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>{d&&t(s.path),s.memory&&l(s.memory)},className:`w-full text-left px-2 py-0.5 flex items-center gap-1 hover:bg-surface-elevated transition-colors cursor-pointer ${x?"bg-accent15 text-accent":"text-foreground"}`,style:{paddingLeft:`${o*12+8}px`},children:[d?e.jsx("span",{className:"w-3 text-[9px] text-muted",children:u?"▾":"▸"}):e.jsx("span",{className:"w-3 text-[9px] text-muted",children:"·"}),e.jsx("span",{className:"truncate",children:s.name})]}),d&&u&&e.jsx(v,{nodes:s.children,depth:o+1,expandedPaths:n,onToggle:t,selectedMemory:i,onSelect:l})]},s.path)})})}function M({selectedMemory:r,contentLoading:o}){const[n,t]=c.useState(!1);if(!r)return e.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm mb-1",children:"Select a memory from the explorer"}),e.jsx("p",{className:"text-xs text-muted/60",children:"Project memories appear as navigable files"})]})});const i=()=>{navigator.clipboard.writeText(r.content),t(!0),setTimeout(()=>t(!1),2e3)},l=r.name.split("/");return e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2 text-[10px] text-muted",children:[e.jsx("span",{children:"memories"}),l.map((s,d)=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{children:"/"}),e.jsx("span",{className:d===l.length-1?"text-foreground font-medium":"",children:s})]},d))]}),e.jsxs("div",{className:"flex items-center justify-between mb-3 pb-2 border-b border-edge",children:[e.jsx("span",{className:"text-sm font-semibold",children:l[l.length-1]}),e.jsx("button",{onClick:i,disabled:o,className:`text-[10px] px-2 py-0.5 rounded border transition-all cursor-pointer ${n?"border-green-500/30 text-green-500 bg-green-500/5":"border-edge text-muted hover:text-foreground"}`,children:n?"Copied!":"Copy"})]}),o?e.jsx("div",{className:"space-y-2",children:Array.from({length:8}).map((s,d)=>e.jsx("div",{className:"h-3 rounded bg-surface animate-pulse",style:{width:`${40+Math.random()*50}%`}},d))}):e.jsx("pre",{className:"text-xs whitespace-pre-wrap text-muted font-mono leading-relaxed",children:r.content})]})}export{k as MemoriesTab};
|
package/dist/web/dashboard/dist/assets/{prd-backlog-tab-C8Cl7swI.js → prd-backlog-tab-DtwzxFyr.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e}from"./index-
|
|
1
|
+
import{r as c,j as e}from"./index-DfEJaZLA.js";import{R as _,u as M,a as E,b as P,i as T,B,C as D}from"./style-CsU39IOg.js";import{S as w}from"./constants-lq4BIQN3.js";import{b as R,g as F,t as $,c as z,d as A,W as I,e as L,N as O}from"./graph-utils-CdV9peLO.js";import"./index-iWhfMJa8.js";import"./index-z9HSPrpH.js";const V=c.memo(function({graph:d,onNodeClick:N}){const{groups:m,nextTask:f,nodeMap:j}=c.useMemo(()=>{const r=d.nodes.filter(s=>s.type==="task"||s.type==="subtask"),x=new Map(d.nodes.map(s=>[s.id,s])),p=new Set(d.nodes.filter(s=>s.status==="done").map(s=>s.id)),h=r.filter(s=>s.status!=="backlog"&&s.status!=="ready"||s.blocked?!1:d.edges.filter(a=>a.from===s.id&&a.relationType==="depends_on").every(a=>p.has(a.to)));h.sort((s,t)=>s.priority-t.priority);const i=new Map;for(const s of r){const t=s.parentId||"__root__";i.has(t)||i.set(t,[]),i.get(t).push(s)}for(const s of i.values())s.sort((t,a)=>t.priority-a.priority);return{groups:i,nextTask:h[0]||null,nodeMap:x}},[d]);return d.nodes.filter(r=>r.type==="task"||r.type==="subtask").length===0?e.jsx("div",{className:"p-4 text-center text-muted",children:"No tasks in backlog."}):e.jsxs("div",{className:"p-2",children:[f&&e.jsxs("div",{className:"mb-3 px-3 py-2 bg-accent10 border border-accent rounded-lg",children:[e.jsx("span",{className:"text-xs font-medium text-accent",children:"Next:"})," ",e.jsx("span",{className:"text-sm font-semibold",children:f.title})]}),Array.from(m.entries()).map(([r,x])=>{const p=r!=="__root__"?j.get(r):null,h=p?p.title:"Ungrouped Tasks",i=x.filter(t=>t.status==="done").length,s=Math.round(i/x.length*100);return e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 py-1",children:[e.jsx("h4",{className:"text-xs font-semibold truncate",children:h}),e.jsxs("span",{className:"text-[10px] text-muted",children:[i,"/",x.length]})]}),e.jsx("div",{className:"h-1 mx-2 mb-1 bg-surface-elevated rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${s}%`,background:w.done}})}),x.map(t=>{const a=(f==null?void 0:f.id)===t.id,v=w[t.status]||"#9e9e9e",y=d.edges.filter(l=>l.from===t.id&&l.relationType==="depends_on").map(l=>{var n;return((n=j.get(l.to))==null?void 0:n.title)||l.to});return e.jsxs("div",{onClick:()=>N(t),className:`mx-1 mb-1 px-2 py-1.5 rounded cursor-pointer hover:bg-surface-elevated transition-colors ${a?"ring-1 ring-accent":""}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded font-medium shrink-0",style:{background:`${v}20`,color:v},children:t.status.replace("_"," ")}),e.jsx("span",{className:"text-xs truncate flex-1",children:t.title}),e.jsxs("span",{className:"text-[10px] text-muted",children:["P",t.priority]}),t.xpSize&&e.jsx("span",{className:"text-[10px] text-muted",children:t.xpSize})]}),y.length>0&&e.jsxs("div",{className:"text-[10px] text-muted mt-0.5 truncate pl-1",children:["Depends on: ",y.join(", ")]})]},t.id)})]},r)})]})}),W={workflowNode:L},U={workflowEdge:I},Z={hideAttribution:!0};function G({graph:o}){const[d,N,m]=M([]),[f,j,r]=E([]),[x,p]=c.useState(null),[h,i]=c.useState(new Set),s=c.useRef(!0),{fitView:t}=P(),a=c.useMemo(()=>R(o.nodes,o.edges),[o.nodes,o.edges]),v=c.useCallback(n=>{i(u=>{const b=new Set(u);return b.has(n)?b.delete(n):b.add(n),b})},[]);c.useEffect(()=>{const n=F(o.nodes,h,a),u=$(n,void 0,a,h,v),b=new Set(u.map(S=>S.id)),k=z(o.edges,b),g=A(u,k,"TB");N(g.nodes),j(g.edges),s.current?s.current=!1:setTimeout(()=>t({duration:300}),50)},[o,N,j,h,a,v,t]);const C=c.useCallback((n,u)=>{p(u.data.sourceNode)},[]),y=c.useCallback(n=>{p(n)},[]),l=c.useMemo(()=>{const n=o.nodes.length,u=o.nodes.filter(g=>g.status==="done").length,b=o.nodes.filter(g=>g.status==="in_progress").length,k=o.nodes.filter(g=>g.status==="blocked").length;return{total:n,done:u,inProgress:b,blocked:k,pctDone:n?Math.round(u/n*100):0}},[o.nodes]);return e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-3 py-1.5 bg-surface-alt border-b border-edge flex items-center gap-2 text-xs relative z-10",children:e.jsxs("span",{className:"text-muted",children:["Showing ",d.length," of ",o.nodes.length," nodes — click ▶ to expand"]})}),o.nodes.length>0?e.jsxs(T,{nodes:d,edges:f,onNodesChange:m,onEdgesChange:r,onNodeClick:C,nodeTypes:W,edgeTypes:U,nodesDraggable:!1,nodesConnectable:!1,fitView:!0,minZoom:.1,maxZoom:2,proOptions:Z,children:[e.jsx(B,{gap:16,size:1}),e.jsx(D,{showInteractive:!1})]}):e.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"Import a PRD to see the workflow"})]}),e.jsxs("div",{className:"w-96 border-l border-edge flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge bg-surface-alt",children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsxs("span",{children:[l.done,"/",l.total," done (",l.pctDone,"%)"]}),e.jsxs("span",{className:"text-muted",children:[l.inProgress," in progress, ",l.blocked," blocked"]})]}),e.jsxs("div",{className:"h-2 bg-surface-elevated rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full transition-all",style:{width:`${l.pctDone}%`,background:w.done}}),e.jsx("div",{className:"h-full transition-all",style:{width:`${l.total?Math.round(l.inProgress/l.total*100):0}%`,background:w.in_progress}})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(V,{graph:o,onNodeClick:y})})]}),x&&e.jsx(O,{node:x,onClose:()=>p(null)})]})}function Y({graph:o,loading:d,error:N,onRetry:m}){return d||!o?e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-3 py-1.5 bg-surface-alt border-b border-edge",children:e.jsx("div",{className:"h-3 w-48 rounded bg-surface animate-pulse"})}),e.jsx("div",{className:"flex-1 bg-surface-alt animate-pulse"})]}),e.jsxs("div",{className:"w-96 border-l border-edge flex flex-col",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge bg-surface-alt space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("div",{className:"h-4 w-28 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"h-4 w-40 rounded bg-surface animate-pulse"})]}),e.jsx("div",{className:"h-2 rounded-full bg-surface animate-pulse"})]}),e.jsx("div",{className:"flex-1 p-3 space-y-3",children:Array.from({length:6}).map((f,j)=>e.jsx("div",{className:"h-14 rounded-lg border border-edge bg-surface-alt animate-pulse"},j))})]})]}):N?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Failed to load PRD & Backlog"}),e.jsx("p",{className:"text-xs text-muted mt-1",children:N})]}),m&&e.jsx("button",{type:"button",onClick:m,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium rounded-md border border-edge text-muted hover:text-foreground transition-colors cursor-pointer",children:"Retry"})]}):o?e.jsx(_,{children:e.jsx(G,{graph:o})}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted",children:[e.jsx("p",{className:"text-xs",children:"No graph data available"}),m&&e.jsx("button",{type:"button",onClick:m,className:"text-xs px-3 py-1.5 rounded border border-edge hover:text-foreground transition-colors cursor-pointer",children:"Retry"})]})}export{Y as PrdBacklogTab};
|