@mcp-graph-workflow/mcp-graph 5.26.0 → 5.28.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.
Files changed (128) hide show
  1. package/README.md +10 -9
  2. package/dist/api/router.d.ts.map +1 -1
  3. package/dist/api/router.js +2 -0
  4. package/dist/api/router.js.map +1 -1
  5. package/dist/api/routes/code-graph.js +1 -1
  6. package/dist/api/routes/code-graph.js.map +1 -1
  7. package/dist/api/routes/docs-reference.d.ts +7 -0
  8. package/dist/api/routes/docs-reference.d.ts.map +1 -0
  9. package/dist/api/routes/docs-reference.js +136 -0
  10. package/dist/api/routes/docs-reference.js.map +1 -0
  11. package/dist/api/routes/knowledge.d.ts.map +1 -1
  12. package/dist/api/routes/knowledge.js +90 -8
  13. package/dist/api/routes/knowledge.js.map +1 -1
  14. package/dist/cli/commands/update.js +1 -1
  15. package/dist/cli/commands/update.js.map +1 -1
  16. package/dist/core/code/code-indexer.d.ts.map +1 -1
  17. package/dist/core/code/code-indexer.js +11 -1
  18. package/dist/core/code/code-indexer.js.map +1 -1
  19. package/dist/core/config/ai-memory-generator.d.ts +2 -2
  20. package/dist/core/config/ai-memory-generator.d.ts.map +1 -1
  21. package/dist/core/config/ai-memory-generator.js +33 -176
  22. package/dist/core/config/ai-memory-generator.js.map +1 -1
  23. package/dist/core/config/config-schema.d.ts +10 -0
  24. package/dist/core/config/config-schema.d.ts.map +1 -1
  25. package/dist/core/config/config-schema.js +4 -1
  26. package/dist/core/config/config-schema.js.map +1 -1
  27. package/dist/core/config/ignore-templates.d.ts +20 -0
  28. package/dist/core/config/ignore-templates.d.ts.map +1 -0
  29. package/dist/core/config/ignore-templates.js +176 -0
  30. package/dist/core/config/ignore-templates.js.map +1 -0
  31. package/dist/core/config/reference-content.d.ts +35 -0
  32. package/dist/core/config/reference-content.d.ts.map +1 -0
  33. package/dist/core/config/reference-content.js +449 -0
  34. package/dist/core/config/reference-content.js.map +1 -0
  35. package/dist/core/deployer/deploy-readiness.d.ts +12 -0
  36. package/dist/core/deployer/deploy-readiness.d.ts.map +1 -0
  37. package/dist/core/deployer/deploy-readiness.js +102 -0
  38. package/dist/core/deployer/deploy-readiness.js.map +1 -0
  39. package/dist/core/docs/doc-generator.d.ts +23 -0
  40. package/dist/core/docs/doc-generator.d.ts.map +1 -0
  41. package/dist/core/docs/doc-generator.js +86 -0
  42. package/dist/core/docs/doc-generator.js.map +1 -0
  43. package/dist/core/docs/doc-updater.d.ts +10 -0
  44. package/dist/core/docs/doc-updater.d.ts.map +1 -0
  45. package/dist/core/docs/doc-updater.js +27 -0
  46. package/dist/core/docs/doc-updater.js.map +1 -0
  47. package/dist/core/docs/route-introspector.d.ts +19 -0
  48. package/dist/core/docs/route-introspector.d.ts.map +1 -0
  49. package/dist/core/docs/route-introspector.js +60 -0
  50. package/dist/core/docs/route-introspector.js.map +1 -0
  51. package/dist/core/docs/tool-introspector.d.ts +17 -0
  52. package/dist/core/docs/tool-introspector.d.ts.map +1 -0
  53. package/dist/core/docs/tool-introspector.js +82 -0
  54. package/dist/core/docs/tool-introspector.js.map +1 -0
  55. package/dist/core/planner/lifecycle-phase.d.ts +1 -1
  56. package/dist/core/planner/lifecycle-phase.d.ts.map +1 -1
  57. package/dist/core/planner/lifecycle-phase.js +52 -0
  58. package/dist/core/planner/lifecycle-phase.js.map +1 -1
  59. package/dist/core/rag/phase-metadata.d.ts.map +1 -1
  60. package/dist/core/rag/phase-metadata.js +5 -0
  61. package/dist/core/rag/phase-metadata.js.map +1 -1
  62. package/dist/core/store/knowledge-store.d.ts +7 -0
  63. package/dist/core/store/knowledge-store.d.ts.map +1 -1
  64. package/dist/core/store/knowledge-store.js +15 -0
  65. package/dist/core/store/knowledge-store.js.map +1 -1
  66. package/dist/mcp/init-project.d.ts.map +1 -1
  67. package/dist/mcp/init-project.js +68 -8
  68. package/dist/mcp/init-project.js.map +1 -1
  69. package/dist/mcp/server.js +45 -22
  70. package/dist/mcp/server.js.map +1 -1
  71. package/dist/mcp/tools/analyze.d.ts.map +1 -1
  72. package/dist/mcp/tools/analyze.js +40 -1
  73. package/dist/mcp/tools/analyze.js.map +1 -1
  74. package/dist/mcp/tools/help.d.ts +3 -0
  75. package/dist/mcp/tools/help.d.ts.map +1 -0
  76. package/dist/mcp/tools/help.js +74 -0
  77. package/dist/mcp/tools/help.js.map +1 -0
  78. package/dist/mcp/tools/index.d.ts.map +1 -1
  79. package/dist/mcp/tools/index.js +2 -0
  80. package/dist/mcp/tools/index.js.map +1 -1
  81. package/dist/mcp/tools/list-skills.js +1 -1
  82. package/dist/mcp/tools/list-skills.js.map +1 -1
  83. package/dist/mcp/tools/manage-skill.js +1 -1
  84. package/dist/mcp/tools/manage-skill.js.map +1 -1
  85. package/dist/mcp/tools/reindex-knowledge.js +1 -1
  86. package/dist/mcp/tools/reindex-knowledge.js.map +1 -1
  87. package/dist/mcp/tools/set-phase.js +1 -1
  88. package/dist/mcp/tools/set-phase.js.map +1 -1
  89. package/dist/schemas/deployer-schema.d.ts +34 -0
  90. package/dist/schemas/deployer-schema.d.ts.map +1 -0
  91. package/dist/schemas/deployer-schema.js +17 -0
  92. package/dist/schemas/deployer-schema.js.map +1 -0
  93. package/dist/schemas/skill.schema.d.ts +3 -0
  94. package/dist/schemas/skill.schema.d.ts.map +1 -1
  95. package/dist/schemas/skill.schema.js +1 -1
  96. package/dist/schemas/skill.schema.js.map +1 -1
  97. package/dist/web/dashboard/dist/assets/{benchmark-tab-BAfHRc8R.js → benchmark-tab-Dx9G7cqf.js} +1 -1
  98. package/dist/web/dashboard/dist/assets/{circle-alert-Xp4yHA83.js → circle-alert-B17sfIdw.js} +1 -1
  99. package/dist/web/dashboard/dist/assets/constants-Dd6A34aQ.js +1 -0
  100. package/dist/web/dashboard/dist/assets/{context-tab-WZWpYE4Q.js → context-tab-BX2hlI9H.js} +1 -1
  101. package/dist/web/dashboard/dist/assets/docs-tab-sxC7Gxc7.js +1 -0
  102. package/dist/web/dashboard/dist/assets/{gitnexus-tab-BL3gMYaZ.js → gitnexus-tab-DEcNhLvY.js} +1 -1
  103. package/dist/web/dashboard/dist/assets/{graph-section-B-cObR6x.js → graph-section-CsHifp70.js} +1 -1
  104. package/dist/web/dashboard/dist/assets/{graph-tab-DC5Iama3.js → graph-tab-D8ZSUyGR.js} +1 -1
  105. package/dist/web/dashboard/dist/assets/{graph-utils-CdV9peLO.js → graph-utils-D10A5HwE.js} +1 -1
  106. package/dist/web/dashboard/dist/assets/{index-iWhfMJa8.js → index-07Y4UWP1.js} +1 -1
  107. package/dist/web/dashboard/dist/assets/{index-z9HSPrpH.js → index-CVRN6scU.js} +1 -1
  108. package/dist/web/dashboard/dist/assets/index-DVIgWBT4.css +1 -0
  109. package/dist/web/dashboard/dist/assets/{index-DfEJaZLA.js → index-Dbaws8C6.js} +46 -41
  110. package/dist/web/dashboard/dist/assets/{insights-tab-Cu1cH-bN.js → insights-tab-DJAtypOr.js} +1 -1
  111. package/dist/web/dashboard/dist/assets/{journey-tab-BtqgC4Wj.js → journey-tab-CXtDFeGm.js} +1 -1
  112. package/dist/web/dashboard/dist/assets/languages-tab-03j3C58E.js +123 -0
  113. package/dist/web/dashboard/dist/assets/{loader-circle-MkZSJbxU.js → loader-circle-BNEIXs1s.js} +1 -1
  114. package/dist/web/dashboard/dist/assets/{logs-tab-CA2dPs0v.js → logs-tab-D3BE923P.js} +1 -1
  115. package/dist/web/dashboard/dist/assets/{lsp-tab-DuF6UV_3.js → lsp-tab-cac4ysh4.js} +1 -1
  116. package/dist/web/dashboard/dist/assets/memories-tab-BPJTM45d.js +1 -0
  117. package/dist/web/dashboard/dist/assets/{prd-backlog-tab-DtwzxFyr.js → prd-backlog-tab-5PCpKm0j.js} +1 -1
  118. package/dist/web/dashboard/dist/assets/{refresh-cw-VhHh0g7N.js → refresh-cw-CI2U4FGa.js} +1 -1
  119. package/dist/web/dashboard/dist/assets/{siebel-tab-DP6xoWD8.js → siebel-tab-BuhOpZO3.js} +3 -3
  120. package/dist/web/dashboard/dist/assets/{skills-tab-Tspln3N1.js → skills-tab-BHWwOBtm.js} +1 -1
  121. package/dist/web/dashboard/dist/assets/{style-CsU39IOg.js → style-BPgBTbDw.js} +1 -1
  122. package/dist/web/dashboard/dist/assets/{triangle-alert-ZnXg11jO.js → triangle-alert-aqoYdsgW.js} +1 -1
  123. package/dist/web/dashboard/dist/index.html +2 -2
  124. package/package.json +15 -2
  125. package/dist/web/dashboard/dist/assets/constants-lq4BIQN3.js +0 -1
  126. package/dist/web/dashboard/dist/assets/index-CTdsOcRa.css +0 -1
  127. package/dist/web/dashboard/dist/assets/languages-tab-BeJF5wPH.js +0 -128
  128. package/dist/web/dashboard/dist/assets/memories-tab-blOtravG.js +0 -1
@@ -0,0 +1,123 @@
1
+ import{c as N,r as m,a as w,j as e,d as H,B as G,u as de,L as ie,G as B}from"./index-Dbaws8C6.js";import{i as xe,B as ue,C as me}from"./style-BPgBTbDw.js";import{d as X}from"./index-CVRN6scU.js";import{L as $}from"./loader-circle-BNEIXs1s.js";import{T as J,C as q,a as K,S as ae,F as re}from"./triangle-alert-aqoYdsgW.js";import{R as V}from"./refresh-cw-CI2U4FGa.js";import"./index-07Y4UWP1.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 pe=[["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"}]],he=N("arrow-left-right",pe);/**
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 ge=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],fe=N("arrow-left",ge);/**
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 be=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],P=N("check",be);/**
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 je=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ne=N("circle-check-big",je);/**
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 ye=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ne=N("circle-check",ye);/**
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 ve=[["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"}]],we=N("circle-x",ve);/**
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 Ce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],ke=N("clock",Ce);/**
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 Se=[["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"}]],W=N("copy",Se);/**
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 Me=[["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"}]],Le=N("cpu",Me);/**
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 $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"}]],D=N("download",$e);/**
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 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=N("eye",ze);/**
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 Re=[["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=N("file-archive",Re);/**
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 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"}]],Pe=N("file-code-corner",Ae);/**
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 De=[["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"}]],_e=N("files",De);/**
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 Ee=[["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"}]],Ie=N("folder",Ee);/**
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 Oe=[["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=N("inbox",Oe);/**
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 Ge=[["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=N("play",Ge);/**
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 Be=[["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=N("rotate-ccw",Be);/**
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 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"}]],Je=N("shield",He);/**
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 qe=[["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"}]],Ke=N("sparkles",qe);/**
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 We=[["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"}]],Ze=N("trash-2",We);/**
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 Qe=[["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"}]],Xe=N("upload",Qe),Y={phase:"idle",analysis:null,prepareResult:null,finalizeResult:null,error:null,loading:!1};function Ye(){var o;const[s,t]=m.useState(Y),r=m.useCallback(async(i,h,x="snippet")=>{t(l=>({...l,phase:"analyzing",loading:!0,error:null}));try{const u=new Promise((b,n)=>setTimeout(()=>n(new Error("Analysis timed out after 30s. Please try again.")),3e4)),p=await Promise.race([w.translationCreateJob(i,h,x),u]);t({phase:"prepared",analysis:p.analysis,prepareResult:p,finalizeResult:null,error:null,loading:!1})}catch(l){t(u=>({...u,phase:"error",error:l instanceof Error?l.message:"Analysis failed",loading:!1}))}},[]),c=m.useCallback(async i=>{var x;const h=(x=s.prepareResult)==null?void 0:x.jobId;if(!h){t(l=>({...l,phase:"error",error:"No active job to finalize"}));return}t(l=>({...l,phase:"finalizing",loading:!0,error:null}));try{const l=await w.translationFinalize(h,i);t(u=>({...u,phase:"done",finalizeResult:l,loading:!1}))}catch(l){t(u=>({...u,phase:"error",error:l instanceof Error?l.message:"Finalize failed",loading:!1}))}},[(o=s.prepareResult)==null?void 0:o.jobId]),a=m.useCallback(()=>{t(Y)},[]);return[s,{analyze:r,finalize:c,reset:a}]}function et(){const[s,t]=m.useState([]),[r,c]=m.useState(null),[a,o]=m.useState(!0),[i,h]=m.useState(null),x=m.useCallback(async()=>{o(!0),h(null);try{const[u,p]=await Promise.all([w.translationListJobs(),w.translationStats()]);t(u.jobs),c(p)}catch(u){h(u instanceof Error?u.message:"Failed to load history")}finally{o(!1)}},[]),l=m.useCallback(async u=>{try{await w.translationDeleteJob(u),t(b=>b.filter(n=>n.id!==u));const p=await w.translationStats();c(p)}catch(p){h(p instanceof Error?p.message:"Delete failed")}},[]);return m.useEffect(()=>{x()},[x]),[{jobs:s,stats:r,loading:a,error:i},{refresh:x,deleteJob:l}]}const ee={mode:"idle",project:null,files:[],summary:null,selectedFileId:null,error:null,loading:!1};function tt(){var b;const[s,t]=m.useState(ee),r=m.useRef(null),c=m.useCallback(async(n,d,g)=>{t(f=>({...f,mode:"uploading",loading:!0,error:null}));try{const f=await w.translationUploadProject(n,d,g);r.current=f.project.id,t({mode:"ready",project:f.project,files:f.files,summary:null,selectedFileId:null,error:null,loading:!1})}catch(f){t(v=>({...v,mode:"error",error:f instanceof Error?f.message:"Upload failed",loading:!1}))}},[]),a=m.useCallback(async n=>{t(d=>({...d,loading:!0,error:null}));try{const d=await w.translationGetProject(n);r.current=d.project.id,t({mode:"ready",project:d.project,files:d.files,summary:null,selectedFileId:null,error:null,loading:!1})}catch(d){t(g=>({...g,mode:"error",error:d instanceof Error?d.message:"Failed to load project",loading:!1}))}},[]),o=m.useCallback(n=>{t(d=>({...d,selectedFileId:n}))},[]),i=m.useCallback(async n=>{const d=r.current;if(!d){t(g=>({...g,mode:"error",error:"No active project"}));return}t(g=>({...g,loading:!0,error:null}));try{await w.translationPrepareFiles(d,n);const g=await w.translationGetProject(d);t(f=>({...f,project:g.project,files:g.files,loading:!1}))}catch(g){t(f=>({...f,error:g instanceof Error?g.message:"Prepare failed",loading:!1}))}},[]),h=m.useCallback(async(n,d)=>{const g=r.current;if(!g){t(f=>({...f,mode:"error",error:"No active project"}));return}t(f=>({...f,loading:!0,error:null}));try{await w.translationFinalizeFile(g,n,d);const f=await w.translationGetProject(g);t(v=>({...v,project:f.project,files:f.files,loading:!1}))}catch(f){t(v=>({...v,error:f instanceof Error?f.message:"Finalize failed",loading:!1}))}},[]),x=m.useCallback(async()=>{var d;const n=r.current;if(!n){t(g=>({...g,mode:"error",error:"No active project"}));return}t(g=>({...g,loading:!0,error:null}));try{const g=await w.translationDownloadProject(n),f=(d=s.project)!=null&&d.name?`${s.project.name}-translated.zip`:"translated-project.zip",v=URL.createObjectURL(g),C=document.createElement("a");C.href=v,C.download=f,C.click(),URL.revokeObjectURL(v),t(k=>({...k,loading:!1}))}catch(g){t(f=>({...f,error:g instanceof Error?g.message:"Download failed",loading:!1}))}},[(b=s.project)==null?void 0:b.name]),l=m.useCallback(async n=>{const d=r.current;if(!d){t(g=>({...g,mode:"error",error:"No active project"}));return}t(g=>({...g,loading:!0,error:null}));try{const g=await w.translationDownloadFile(d,n),f=s.files.find(S=>S.id===n),v=f!=null&&f.filePath?f.filePath.split("/").pop()??"translated-file":"translated-file",C=URL.createObjectURL(g),k=document.createElement("a");k.href=C,k.download=v,k.click(),URL.revokeObjectURL(C),t(S=>({...S,loading:!1}))}catch(g){t(f=>({...f,error:g instanceof Error?g.message:"File download failed",loading:!1}))}},[s.files]),u=m.useCallback(async()=>{const n=r.current;if(!n){t(d=>({...d,mode:"error",error:"No active project"}));return}t(d=>({...d,loading:!0,error:null}));try{const d=await w.translationProjectSummary(n);t(g=>({...g,summary:d,loading:!1}))}catch(d){t(g=>({...g,error:d instanceof Error?d.message:"Failed to refresh summary",loading:!1}))}},[]),p=m.useCallback(()=>{r.current=null,t(ee)},[]);return[s,{upload:c,loadProject:a,selectFile:o,prepareFiles:i,finalizeFile:h,downloadProject:x,downloadFile:l,refreshSummary:u,reset:p}]}const st=["python","javascript","typescript","java","csharp","go","rust","ruby","php","swift","kotlin","scala","cpp"],at=["snippet","function","module"];function rt({sourceCode:s,setSourceCode:t,targetLanguage:r,setTargetLanguage:c,scope:a,setScope:o,generatedCode:i,setGeneratedCode:h,translation:x,onAnalyze:l,onFinalize:u,onReset:p}){var L,R,T;const{phase:b,prepareResult:n,error:d,loading:g}=x,f=b==="idle"||b==="error",v=b==="prepared",C=b==="done",[k,S]=m.useState(!1),E=()=>{n!=null&&n.prompt&&(navigator.clipboard.writeText(n.prompt),S(!0),setTimeout(()=>S(!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&&!v&&!C&&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:y=>t(y.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:[(L=x.analysis)!=null&&L.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:r,onChange:y=>c(y.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:st.map(y=>e.jsx("option",{value:y,children:y},y))}),e.jsx("div",{className:"flex gap-1",children:at.map(y=>e.jsx("button",{onClick:()=>o(y),disabled:!f,className:`flex-1 px-2 py-1.5 text-[10px] font-medium rounded-md border transition-colors disabled:opacity-50 ${a===y?"border-accent bg-accent/10 text-accent":"border-edge bg-surface text-muted hover:text-foreground"}`,children:y},y))})]}),f&&e.jsxs("button",{onClick:l,disabled:!s.trim()||g,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:[g?e.jsx($,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(le,{className:"w-3.5 h-3.5"}),g?"Analyzing...":"Analyze"]}),(v||C)&&e.jsxs("button",{onClick:p,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"]}),C&&((T=(R=x.finalizeResult)==null?void 0:R.job)==null?void 0:T.targetCode)&&e.jsxs("button",{onClick:()=>{var Z,Q;const y=(Q=(Z=x.finalizeResult)==null?void 0:Z.job)==null?void 0:Q.targetCode;if(!y)return;const j=new Blob([y],{type:"text/plain"}),A=URL.createObjectURL(j),I=document.createElement("a");I.href=A,I.download="translated.txt",I.click(),URL.revokeObjectURL(A)},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(D,{className:"w-3 h-3"}),"Download"]})]})]})]}),d&&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:d}),v&&n&&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:E,className:`flex items-center gap-1 px-2 py-1 text-[10px] rounded border transition-all duration-200 ${k?"border-green-500/30 text-green-500 bg-green-500/5":"border-edge text-muted hover:text-foreground"}`,children:[k?e.jsx(P,{className:"w-3 h-3"}):e.jsx(W,{className:"w-3 h-3"}),k?"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:n.prompt.length>3e3?n.prompt.slice(0,3e3)+`
112
+
113
+ ... (truncated, use Copy for full prompt)`:n.prompt}),e.jsx("textarea",{value:i,onChange:y=>h(y.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:u,disabled:!i.trim()||g,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:[g?e.jsx($,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Ne,{className:"w-3.5 h-3.5"}),g?"Finalizing...":"Finalize Translation"]})]})]})]})}function nt(s){const t=s.totalConstructs;if(t===0)return{percentage:100,ruleCount:0,aiCount:0,total:0,aiConstructs:[]};const r=s.ambiguousConstructs??[],c=r.length,o=s.constructs.map(h=>h.canonicalName).filter(h=>!r.includes(h)).length,i=t>0?Math.round((t-c)/t*100):100;return{percentage:Math.min(100,Math.max(0,i)),ruleCount:o,aiCount:c,total:t,aiConstructs:r}}function lt(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 _({analysis:s,deterministicPct:t,totalConstructs:r,isProjectLevel:c,onDownload:a,aiPrompt:o}){const[i,h]=m.useState(!1),x=s?nt(s):{percentage:t??0,ruleCount:Math.round((t??0)/100*(r??0)),aiCount:Math.round((100-(t??0))/100*(r??0)),total:r??0,aiConstructs:[]},l=lt(x.percentage),u=x.percentage===100,p=100-x.percentage,b=m.useCallback(()=>{o&&navigator.clipboard.writeText(o).then(()=>{h(!0),setTimeout(()=>h(!1),2e3)})},[o]);return x.total===0&&!t?null:e.jsxs("div",{className:`rounded-lg border ${l.border} ${l.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 ${l.text}`,children:[x.percentage,"%"]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs font-semibold text-foreground",children:[c?"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`]})]})]}),u&&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 ${l.bar} transition-all duration-500`,style:{width:`${x.percentage}%`}}),p>0&&e.jsx("div",{className:"h-full bg-yellow-500/60 transition-all duration-500",style:{width:`${p}%`}})]}),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 ${l.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(n=>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(Ke,{className:"w-2.5 h-2.5"}),n]},n))}),e.jsx("div",{className:"flex items-center gap-2 pt-1",children:u&&a?e.jsxs("button",{onClick:a,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(D,{className:"w-3.5 h-3.5"}),"Ready to Download"]}):e.jsxs(e.Fragment,{children:[o&&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:[i?e.jsx(P,{className:"w-3.5 h-3.5"}):e.jsx(W,{className:"w-3.5 h-3.5"}),i?"Copied!":`Copy AI Prompt for ${x.aiCount} construct${x.aiCount!==1?"s":""}`]}),a&&e.jsxs("button",{onClick:a,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(D,{className:"w-3.5 h-3.5"}),"Download Partial"]})]})})]})}function te({value:s,max:t=100,label:r}){const c=Math.min(100,Math.round(s/t*100)),a=c>=80?"bg-green-500":c>=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:r}),e.jsxs("span",{className:"text-foreground font-medium",children:[c,"%"]})]}),e.jsx("div",{className:"h-1.5 rounded-full bg-surface overflow-hidden",role:"progressbar","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${r}: ${c}%`,children:e.jsx("div",{className:`h-full rounded-full ${a} transition-all duration-500`,style:{width:`${c}%`}})})]})}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(Le,{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(te,{value:s.complexityScore,label:"Complexity"}),e.jsx(te,{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(_,{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(J,{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 ot({score:s}){const t=Math.round(s*100),r=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 ${r}`,children:[t,"%"]})}const ct={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 dt({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(Je,{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(ot,{score:t.confidenceScore})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(_,{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(Pe,{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((r,c)=>e.jsxs("tr",{className:"border-b border-edge/50",children:[e.jsx("td",{className:"px-2 py-1 font-mono text-foreground",children:r.source}),e.jsx("td",{className:"px-2 py-1 font-mono text-accent",children:r.target}),e.jsx("td",{className:"px-2 py-1 text-muted",children:r.method})]},c))})]})]}),t.risks.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(J,{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((r,c)=>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 ${ct[r.severity]??"bg-surface text-muted"}`,children:r.severity}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-foreground",children:r.construct}),e.jsx("span",{className:"text-[10px] text-muted ml-1",children:r.message})]})]},c))})]}),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((r,c)=>e.jsx("li",{children:r},c))})]}),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 it={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 xt(s){const t=Date.now(),r=new Date(s).getTime(),c=t-r,a=Math.floor(c/6e4);if(a<1)return"just now";if(a<60)return`${a}m ago`;const o=Math.floor(a/60);if(o<24)return`${o}h ago`;const i=Math.floor(o/24);return i<7?`${i}d ago`:new Date(s).toLocaleDateString()}function z({label:s,value:t,accent:r}){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 ${r??"text-foreground"}`,children:t})]})}function O(){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 ut({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?`
114
+ ...`:""]})]}),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?`
115
+ ...`:""]})]}),!s.sourceCode&&!s.targetCode&&e.jsx("p",{className:"text-[10px] text-muted col-span-2",children:"No code details available for this job."})]})})})}function mt({state:s,actions:t,showInsights:r}){const{jobs:c,stats:a,loading:o,error:i}=s,[h,x]=m.useState(null),[l,u]=m.useState(null),p=n=>{l===n?(u(null),t.deleteJob(n)):(u(n),setTimeout(()=>u(d=>d===n?null:d),3e3))},b=n=>{x(d=>d===n?null:n)};return o&&c.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((n,d)=>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"})]},d))}),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(O,{}),e.jsx(O,{}),e.jsx(O,{})]})})]})]}):i?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:i}),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(V,{className:"w-3 h-3"})," Retry"]})]}):e.jsxs("div",{className:"space-y-4",children:[a&&e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3",children:[e.jsx(z,{label:"Total Jobs",value:a.totalJobs}),e.jsx(z,{label:"Completed",value:a.done,accent:"text-green-500"}),e.jsx(z,{label:"Failed",value:a.failed,accent:a.failed>0?"text-red-500":"text-foreground"}),e.jsx(z,{label:"Pending",value:a.pending,accent:a.pending>0?"text-yellow-500":"text-foreground"}),e.jsx(z,{label:"Avg Confidence",value:`${Math.round(a.avgConfidence*100)}%`})]}),r&&c.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(H,{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(c.reduce((n,d)=>{const g=`${d.sourceLanguage} → ${d.targetLanguage}`;return n[g]=(n[g]??0)+1,n},{})).sort(([,n],[,d])=>d-n).map(([n,d])=>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:n}),e.jsxs("span",{className:"text-muted ml-1.5",children:["x",d]})]},n))})})]}),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 (",c.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(V,{className:`w-3.5 h-3.5 ${o?"animate-spin":""}`})})]}),c.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:c.map(n=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{onClick:()=>b(n.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:h===n.id?e.jsx(q,{className:"w-3 h-3"}):e.jsx(K,{className:"w-3 h-3"})}),e.jsx("td",{className:"px-4 py-1.5 font-mono text-muted",title:n.id,children:n.id.slice(0,8)}),e.jsxs("td",{className:"px-4 py-1.5",children:[e.jsx("span",{className:"text-foreground",children:n.sourceLanguage}),e.jsx("span",{className:"text-muted mx-1",children:"→"}),e.jsx("span",{className:"text-accent",children:n.targetLanguage})]}),e.jsx("td",{className:"px-4 py-1.5 text-muted",children:n.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 ${it[n.status]}`,children:n.status})}),e.jsx("td",{className:"px-4 py-1.5 text-muted",children:n.confidenceScore!=null?`${Math.round(n.confidenceScore*100)}%`:"—"}),e.jsx("td",{className:"px-4 py-1.5 text-muted",title:new Date(n.createdAt).toLocaleString(),children:xt(n.createdAt)}),e.jsx("td",{className:"px-4 py-1.5 text-right",onClick:d=>d.stopPropagation(),children:e.jsx("button",{onClick:()=>p(n.id),className:`px-2 py-0.5 rounded text-[10px] transition-all cursor-pointer ${l===n.id?"bg-red-500/10 text-red-400 font-medium border border-red-500/30":"text-muted hover:text-red-400"}`,title:l===n.id?"Click again to confirm":"Delete job",children:l===n.id?"Confirm?":e.jsx(Ze,{className:"w-3 h-3"})})})]},n.id),h===n.id&&e.jsx(ut,{job:n},`${n.id}-details`)]}))})]})})]})]})}function pt({onUpload:s,loading:t,disabled:r}){const[c,a]=m.useState(!1),o=m.useRef(null),i=m.useCallback(p=>{p.preventDefault(),p.stopPropagation(),!r&&!t&&a(!0)},[r,t]),h=m.useCallback(p=>{p.preventDefault(),p.stopPropagation(),a(!1)},[]),x=m.useCallback(p=>{if(p.preventDefault(),p.stopPropagation(),a(!1),r||t)return;const b=p.dataTransfer.files[0];b&&b.name.endsWith(".zip")&&s(b)},[r,t,s]),l=m.useCallback(()=>{var p;!r&&!t&&((p=o.current)==null||p.click())},[r,t]),u=m.useCallback(p=>{var n;const b=(n=p.target.files)==null?void 0:n[0];b&&b.name.endsWith(".zip")&&s(b),p.target.value=""},[s]);return e.jsxs("div",{role:"button",tabIndex:r?-1:0,className:`
116
+ flex flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed
117
+ px-4 py-5 text-center transition-colors cursor-pointer
118
+ ${c?"border-accent bg-accent/5":"border-edge bg-surface"}
119
+ ${r||t?"opacity-50 cursor-not-allowed":"hover:border-accent/60"}
120
+ `,onDragOver:i,onDragLeave:h,onDrop:x,onClick:l,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&l()},children:[e.jsx("input",{ref:o,type:"file",accept:".zip",className:"hidden",onChange:u,disabled:r||t}),t?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"h-6 w-6 animate-spin text-accent"}),e.jsx("span",{className:"text-sm text-muted",children:"Uploading..."})]}):e.jsxs(e.Fragment,{children:[c?e.jsx(Te,{className:"h-6 w-6 text-accent"}):e.jsx(Xe,{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 se={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 c of s){const a=c.filePath.split("/");let o=t;for(let i=0;i<a.length;i++){const h=a[i],x=i===a.length-1,l=a.slice(0,i+1).join("/");if(x)o.children.push({name:h,path:l,isDir:!1,children:[],file:c});else{let u=o.children.find(p=>p.isDir&&p.name===h);u||(u={name:h,path:l,isDir:!0,children:[]},o.children.push(u)),o=u}}}const r=c=>{const a=[...c].sort((o,i)=>o.isDir!==i.isDir?o.isDir?-1:1:o.name.localeCompare(i.name));for(const o of a)o.isDir&&(o.children=r(o.children));return a};return r(t.children)}function gt(s){const t={};for(const r of s)t[r.status]=(t[r.status]??0)+1;return t}function ce(s,t){const r=t.toLowerCase(),c=[];for(const a of s)if(a.isDir){const o=ce(a.children,t);o.length>0&&c.push({...a,children:o})}else a.path.toLowerCase().includes(r)&&c.push(a);return c}const ft=m.memo(function s({node:t,depth:r,selectedFileId:c,onSelectFile:a,expandedPaths:o,onToggle:i}){var n,d,g;const h=o.has(t.path),x=!t.isDir&&((n=t.file)==null?void 0:n.id)===c,l=r*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:l},onClick:()=>i(t.path),children:[h?e.jsx(q,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(K,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx(Ie,{className:"h-3.5 w-3.5 shrink-0 text-yellow-500/80"}),e.jsx("span",{className:"truncate",children:t.name})]}),h&&t.children.map(f=>e.jsx(s,{node:f,depth:r+1,selectedFileId:c,onSelectFile:a,expandedPaths:o,onToggle:i},f.path))]});const u=((d=t.file)==null?void 0:d.status)??"pending",p=(g=t.file)==null?void 0:g.confidenceScore,b=se[u]??se.pending;return e.jsxs("button",{type:"button",className:`
121
+ flex w-full items-center gap-1.5 rounded px-1 py-0.5 text-sm transition-colors
122
+ ${x?"bg-accent/10 border border-accent text-foreground":"text-muted hover:bg-surface-hover border border-transparent"}
123
+ `,style:{paddingLeft:l,contentVisibility:"auto"},onClick:()=>t.file&&a(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}),p!=null&&e.jsxs("span",{className:"ml-auto shrink-0 text-xs text-muted",children:[Math.round(p*100),"%"]})]})});function bt({files:s,selectedFileId:t,onSelectFile:r}){const[c,a]=m.useState(""),[o,i]=m.useState(new Set),h=m.useMemo(()=>ht(s),[s]),x=m.useMemo(()=>c.trim()?ce(h,c.trim()):h,[h,c]),l=m.useMemo(()=>gt(s),[s]),u=m.useCallback(d=>{i(g=>{const f=new Set(g);return f.has(d)?f.delete(d):f.add(d),f})},[]),p=(l.done??0)+(l.analyzed??0),b=l.translating??0,n=l.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: ",p," ready, ",b," need AI, ",n," 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:c,onChange:d=>a(d.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(d=>e.jsx(ft,{node:d,depth:0,selectedFileId:t,onSelectFile:r,expandedPaths:o,onToggle:u},d.path)),x.length===0&&e.jsx("div",{className:"py-4 text-center text-xs text-muted",children:"No files match your filter"})]})]})}function jt(s,t){if(t){const l=t.translatedFiles,u=t.pendingFiles+t.analyzedFiles;return{totalFiles:t.totalFiles,deterministicCount:l,needsAiCount:u,errorCount:t.failedFiles,avgConfidence:t.overallConfidence,deterministicPct:t.deterministicPct}}const r=s.length;if(r===0)return{totalFiles:0,deterministicCount:0,needsAiCount:0,errorCount:0,avgConfidence:0,deterministicPct:0};const c=s.filter(l=>l.deterministic===!0).length,a=s.filter(l=>l.status==="failed").length,o=s.filter(l=>l.deterministic===!1&&l.status!=="failed").length,i=s.filter(l=>l.confidenceScore!=null),h=i.length>0?i.reduce((l,u)=>l+(u.confidenceScore??0),0)/i.length:0,x=r>0?Math.round(c/r*100):0;return{totalFiles:r,deterministicCount:c,needsAiCount:o,errorCount:a,avgConfidence:h,deterministicPct:x}}function F({icon:s,value:t,label:r,colorClass:c="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 ${c}`,children:t})]}),e.jsx("p",{className:"text-[10px] text-muted",children:r})]})}function Nt({project:s,files:t,summary:r,onPrepareAll:c,onDownloadAll:a,loading:o}){const i=jt(t,r),h=i.deterministicPct===100&&i.totalFiles>0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-5 gap-3",children:[e.jsx(F,{icon:e.jsx(_e,{className:"w-3.5 h-3.5 text-accent"}),value:i.totalFiles,label:"Total Files"}),e.jsx(F,{icon:e.jsx(ne,{className:"w-3.5 h-3.5 text-green-500"}),value:i.deterministicCount,label:"Deterministic",colorClass:"text-green-500"}),e.jsx(F,{icon:e.jsx(J,{className:"w-3.5 h-3.5 text-yellow-500"}),value:i.needsAiCount,label:"Needs AI",colorClass:"text-yellow-500"}),e.jsx(F,{icon:e.jsx(we,{className:"w-3.5 h-3.5 text-red-500"}),value:i.errorCount,label:"Errors",colorClass:"text-red-500"}),e.jsx(F,{icon:e.jsx(H,{className:"w-3.5 h-3.5 text-accent"}),value:`${Math.round(i.avgConfidence*100)}%`,label:"Avg Confidence"})]}),e.jsx(_,{isProjectLevel:!0,deterministicPct:i.deterministicPct,totalConstructs:i.totalFiles}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:c,disabled:o||i.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:a,disabled:o||i.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 ${h?"bg-green-600 text-white hover:bg-green-700":"border border-edge text-foreground hover:bg-surface"}`,children:[e.jsx(D,{className:"w-3.5 h-3.5"}),"Download All .zip"]})]})]})}function yt({file:s,prompt:t,onBack:r,onFinalize:c,loading:a}){const[o,i]=m.useState(""),[h,x]=m.useState(!1),l=s.status==="done",u=m.useCallback(()=>{t&&navigator.clipboard.writeText(t).then(()=>{x(!0),setTimeout(()=>x(!1),2e3)})},[t]),p=m.useCallback(()=>{o.trim()&&c(o.trim())},[o,c]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("button",{onClick:r,className:"flex items-center gap-1.5 text-xs text-muted hover:text-foreground transition-colors",children:[e.jsx(fe,{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(_,{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:u,className:"flex items-center gap-1 px-2 py-1 rounded text-[10px] text-muted hover:text-foreground hover:bg-surface transition-colors",children:[h?e.jsx(P,{className:"w-3 h-3"}):e.jsx(W,{className:"w-3 h-3"}),h?"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})]}),l&&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(P,{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),"%"]})]})]}),!l&&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:o,onChange:b=>i(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:p,disabled:a||!o.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 vt({project:s,files:t,summary:r,selectedFileId:c,onSelectFile:a,onPrepareAll:o,onDownloadAll:i,onFinalizeFile:h,prompts:x,loading:l}){const u=c?t.find(n=>n.id===c)??null:null,p=()=>{a(null)},b=n=>{c&&h(c,n)};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(bt,{files:t,selectedFileId:c,onSelectFile:a})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:u?e.jsx(yt,{file:u,prompt:x==null?void 0:x[u.id],onBack:p,onFinalize:b,loading:l}):e.jsx(Nt,{project:s,files:t,summary:r,onPrepareAll:o,onDownloadAll:i,loading:l})})]})}const wt={knowledge:null,searchResults:[],loading:!1,error:null};function Ct(){const[s,t]=m.useState(wt),r=m.useCallback(async()=>{t(a=>({...a,loading:!0,error:null}));try{const a=await w.translationGetKnowledge();t(o=>({...o,knowledge:a,loading:!1}))}catch(a){t(o=>({...o,error:a instanceof Error?a.message:"Failed to load knowledge stats",loading:!1}))}},[]),c=m.useCallback(async a=>{t(o=>({...o,loading:!0,error:null}));try{const o=await w.translationSearchKnowledge(a);t(i=>({...i,searchResults:o.results,loading:!1}))}catch(o){t(i=>({...i,error:o instanceof Error?o.message:"Search failed",loading:!1}))}},[]);return m.useEffect(()=>{r()},[r]),[s,{search:c,refresh:r}]}function U({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 kt({entry:s,expanded:t,onToggle:r,onSearch:c}){const a=s.metadata,o=s.confidence!=null?Math.round(s.confidence*100):null,i=o!=null?o>=80?"text-green-500":o>=50?"text-yellow-500":"text-red-500":"text-muted",h=(a==null?void 0:a.riskCount)??0;return e.jsxs("div",{className:"rounded-lg border border-edge bg-surface-alt px-4 py-3 cursor-pointer transition-colors hover:border-accent/30",onClick:r,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[t?e.jsx(q,{className:"w-3.5 h-3.5 text-muted flex-shrink-0"}):e.jsx(K,{className:"w-3.5 h-3.5 text-muted flex-shrink-0"}),e.jsx("p",{className:"text-xs font-medium text-foreground truncate flex-1",children:s.title}),e.jsx("span",{className:"text-[10px] text-muted flex-shrink-0",children:new Date(s.createdAt).toLocaleDateString()})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5 ml-5",children:[s.sourceLanguage&&s.targetLanguage&&e.jsxs("span",{className:"text-[10px] text-muted",children:[s.sourceLanguage," → ",s.targetLanguage]}),o!=null&&e.jsxs("span",{className:`text-[10px] ${i}`,children:[o,"%"]})]}),t&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-edge space-y-2 ml-5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a!=null&&a.sourceLanguage?e.jsx("span",{className:"px-2 py-0.5 text-[10px] rounded bg-blue-500/10 text-blue-400",children:String(a.sourceLanguage)}):null,e.jsx("span",{className:"text-[10px] text-muted",children:"→"}),a!=null&&a.targetLanguage?e.jsx("span",{className:"px-2 py-0.5 text-[10px] rounded bg-green-500/10 text-green-400",children:String(a.targetLanguage)}):null,a!=null&&a.scope?e.jsx("span",{className:"px-2 py-0.5 text-[10px] rounded bg-accent/10 text-accent",children:String(a.scope)}):null]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-[10px]",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted",children:"Confidence: "}),e.jsxs("span",{className:i,children:[o??"—","%"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted",children:"Constructs: "}),e.jsx("span",{className:"text-foreground",children:(a==null?void 0:a.constructCount)??"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted",children:"Risks: "}),e.jsx("span",{className:h>0?"text-yellow-500":"text-green-500",children:h})]})]}),e.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),c(s.title)},className:"text-[10px] text-accent hover:text-accent/80 transition-colors",children:"View in Search"})]})]})}function St(){var p,b,n;const[s,{search:t,refresh:r}]=Ct(),[c,a]=m.useState(""),[o,i]=m.useState(null),h=d=>{d.preventDefault(),t(c)},x=()=>{r()},l=s.searchResults&&s.searchResults.length>0?s.searchResults:((p=s.knowledge)==null?void 0:p.recentEntries)??[],u=s.searchResults&&s.searchResults.length>0;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:h,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:c,onChange:d=>a(d.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:x,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(V,{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($,{className:"w-6 h-6 text-muted animate-spin"})}),!s.loading&&!s.knowledge&&l.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3 text-center",children:[e.jsx(G,{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(U,{label:"Total Entries",value:s.knowledge.totalDocuments??0}),e.jsx(U,{label:"Language Pairs",value:((b=s.knowledge.byLanguagePair)==null?void 0:b.length)??0}),e.jsx(U,{label:"Avg Confidence",value:s.knowledge.avgConfidence!=null?`${Math.round(s.knowledge.avgConfidence*100)}%`:"—"})]}),((n=s.knowledge)==null?void 0:n.byLanguagePair)&&s.knowledge.byLanguagePair.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.knowledge.byLanguagePair.map(d=>e.jsxs("span",{className:"px-2 py-0.5 text-[10px] font-medium rounded bg-accent/10 text-accent",children:[d.pair," (",d.count,")"]},d.pair))}),l.length>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"w-3.5 h-3.5 text-accent"}),e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:u?"Search Results":"Recent Entries"}),e.jsxs("span",{className:"text-[10px] text-muted",children:["(",l.length,")"]})]}),l.length>0&&e.jsx("div",{className:"space-y-2 max-h-80 overflow-auto",children:l.map(d=>e.jsx(kt,{entry:d,expanded:o===d.id,onToggle:()=>i(o===d.id?null:d.id),onSearch:g=>{a(g),t(g)}},d.id))})]})}const Mt=[{id:"convert",label:"Convert",icon:e.jsx(he,{className:"w-3.5 h-3.5"})},{id:"history",label:"History",icon:e.jsx(ke,{className:"w-3.5 h-3.5"})},{id:"insights",label:"Insights",icon:e.jsx(H,{className:"w-3.5 h-3.5"})},{id:"knowledge",label:"Knowledge",icon:e.jsx(G,{className:"w-3.5 h-3.5"})},{id:"graph",label:"Graph",icon:e.jsx(B,{className:"w-3.5 h-3.5"})}],M={sourceCode:"",targetLanguage:"python",scope:"snippet",generatedCode:""};function Lt({jobs:s}){const t=m.useMemo(()=>s.filter(a=>a.status==="done"&&a.confidenceScore!=null),[s]),{flowNodes:r,flowEdges:c}=m.useMemo(()=>{if(t.length===0)return{flowNodes:[],flowEdges:[]};const a=new Set,o=new Map;for(const l of t){a.add(l.sourceLanguage),a.add(l.targetLanguage);const u=`${l.sourceLanguage}->${l.targetLanguage}`,p=o.get(u)??{count:0,totalConf:0};p.count++,p.totalConf+=l.confidenceScore??0,o.set(u,p)}const i=[...a].map(l=>({id:l,data:{label:l},position:{x:0,y:0},style:{background:"rgba(99, 102, 241, 0.1)",border:"1px solid rgba(99, 102, 241, 0.3)",borderRadius:"8px",padding:"8px 16px",color:"#a5b4fc",fontSize:"12px",fontWeight:600}})),h=[...o.entries()].map(([l,u])=>{const[p,b]=l.split("->"),n=Math.round(u.totalConf/u.count*100),d=n>=80?"#22c55e":n>=50?"#eab308":"#ef4444";return{id:l,source:p,target:b,label:`x${u.count} · ${n}%`,style:{stroke:d,strokeWidth:2},labelStyle:{fill:"#9ca3af",fontSize:10},labelBgStyle:{fill:"#1e1e2e",fillOpacity:.9},animated:!0}}),x=new X.graphlib.Graph().setDefaultEdgeLabel(()=>({}));return x.setGraph({rankdir:"LR",nodesep:80,ranksep:150}),i.forEach(l=>x.setNode(l.id,{width:120,height:40})),h.forEach(l=>x.setEdge(l.source,l.target)),X.layout(x),i.forEach(l=>{const u=x.node(l.id);l.position={x:u.x-60,y:u.y-20}}),{flowNodes:i,flowEdges:h}},[t]);return t.length===0?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"})]}):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:["(",t.length," completed translations)"]})]}),e.jsx("div",{style:{height:400},className:"rounded-lg border border-edge bg-surface-alt",children:e.jsxs(xe,{nodes:r,edges:c,fitView:!0,proOptions:{hideAttribution:!0},style:{background:"transparent"},children:[e.jsx(ue,{color:"#333",gap:20}),e.jsx(me,{showInteractive:!1})]})})]})}function Dt(){const[s,t]=m.useState("convert"),[r,c]=Ye(),[a,o]=et(),[i,h]=tt(),[x,l]=m.useState(M.sourceCode),[u,p]=m.useState(M.targetLanguage),[b,n]=m.useState(M.scope),[d,g]=m.useState(M.generatedCode),f=m.useCallback(j=>{M.sourceCode=j,l(j)},[]),v=m.useCallback(j=>{M.targetLanguage=j,p(j)},[]),C=m.useCallback(j=>{M.scope=j,n(j)},[]),k=m.useCallback(j=>{M.generatedCode=j,g(j)},[]),S=i.mode!=="idle",E=m.useCallback(j=>{h.upload(j,u)},[h,u]),L=r.phase;de(m.useCallback(j=>{j.startsWith("translation:")&&L!=="analyzing"&&L!=="finalizing"&&o.refresh()},[o,L]));const R=()=>{c.analyze(x,u,b)},T=()=>{c.finalize(d).then(()=>o.refresh())},y=()=>{c.reset(),f(""),k(""),v("python"),C("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(ie,{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:Mt.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(pt,{onUpload:E,loading:i.loading}),S?e.jsx(vt,{project:i.project,files:i.files,summary:i.summary,selectedFileId:i.selectedFileId,onSelectFile:h.selectFile,onPrepareAll:()=>void h.prepareFiles(),onDownloadAll:()=>void h.downloadProject(),onFinalizeFile:(j,A)=>void h.finalizeFile(j,A),loading:i.loading}):e.jsxs(e.Fragment,{children:[e.jsx(rt,{sourceCode:x,setSourceCode:f,targetLanguage:u,setTargetLanguage:v,scope:b,setScope:C,generatedCode:d,setGeneratedCode:k,translation:r,onAnalyze:R,onFinalize:T,onReset:y}),r.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($,{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%"}})})]}),r.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($,{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"})]})]})}),r.analysis&&e.jsx("div",{className:"animate-in fade-in-0 duration-300",style:{animationFillMode:"both"},children:e.jsx(oe,{analysis:r.analysis})}),r.finalizeResult&&e.jsx("div",{className:"animate-in fade-in-0 duration-300",style:{animationFillMode:"both"},children:e.jsx(dt,{result:r.finalizeResult})})]})]}),(s==="history"||s==="insights")&&e.jsx(mt,{state:a,actions:o,showInsights:s==="insights"}),s==="knowledge"&&e.jsx(St,{}),s==="graph"&&e.jsx(Lt,{jobs:a.jobs})]})})}export{Dt as LanguagesTab};
@@ -1,4 +1,4 @@
1
- import{c}from"./index-DfEJaZLA.js";/**
1
+ import{c}from"./index-Dbaws8C6.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,2 +1,2 @@
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(`
1
+ import{r as s,a as v,j as t}from"./index-Dbaws8C6.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,4 +1,4 @@
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";/**
1
+ import{c as I,r as n,a as L,j as e,C as X}from"./index-Dbaws8C6.js";import{C as Z}from"./circle-alert-B17sfIdw.js";import{R as z}from"./refresh-cw-CI2U4FGa.js";import{S as K,T as A,F as ee,C as me,a as ue}from"./triangle-alert-aqoYdsgW.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1 @@
1
+ import{r as t,a as b,j as e}from"./index-Dbaws8C6.js";function z(l){const m=[];for(const r of l){const i=r.name.split("/");let o=m;for(let x=0;x<i.length;x++){const n=i[x],d=i.slice(0,x+1).join("/"),a=x===i.length-1;let c=o.find(h=>h.name===n);c||(c={name:n,path:d,children:[]},a&&(c.memory=r),o.push(c)),a&&!c.memory&&(c.memory=r),o=c.children}}return m}function C(){const[l,m]=t.useState([]),[r,i]=t.useState(null),[o,x]=t.useState(""),[n,d]=t.useState(null),[a,c]=t.useState(!0),[h,g]=t.useState(null),p=t.useCallback(async()=>{try{c(!0);const[s,N]=await Promise.all([b.knowledgeList(50),b.knowledgeGetStats()]);m(s.documents),i(N)}catch(s){g(s instanceof Error?s.message:"Failed to load")}finally{c(!1)}},[]);t.useEffect(()=>{p()},[p]);const j=t.useCallback(async()=>{if(!o.trim()){d(null);return}try{const s=await b.knowledgeSearch(o,20);d(s.results)}catch{d([])}},[o]),u=t.useCallback(async s=>{if(confirm("Delete this knowledge document?"))try{await b.knowledgeDelete(s),await p()}catch{}},[p]),f=n??l;return a?e.jsx("div",{className:"text-zinc-400 p-4",children:"Loading knowledge store..."}):h?e.jsxs("div",{className:"text-red-400 p-4",children:["Error: ",h]}):e.jsxs("div",{className:"space-y-4",children:[r&&e.jsxs("div",{className:"flex gap-3 flex-wrap",children:[e.jsxs("div",{className:"bg-zinc-800 rounded-lg px-4 py-2 border border-zinc-700",children:[e.jsx("span",{className:"text-lg font-bold text-zinc-100",children:r.total}),e.jsx("span",{className:"text-xs text-zinc-500 ml-2",children:"total docs"})]}),Object.entries(r.bySource).map(([s,N])=>e.jsxs("div",{className:"bg-zinc-800 rounded-lg px-3 py-2 border border-zinc-700",children:[e.jsx("span",{className:"text-sm font-medium text-zinc-200",children:N}),e.jsx("span",{className:"text-xs text-zinc-500 ml-1",children:s})]},s))]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"Search knowledge store...",value:o,onChange:s=>x(s.target.value),onKeyDown:s=>s.key==="Enter"&&j(),className:"flex-1 px-3 py-2 bg-zinc-800 border border-zinc-600 rounded-md text-zinc-200 placeholder-zinc-500 focus:outline-none focus:ring-1 focus:ring-blue-500"}),e.jsx("button",{onClick:j,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-500 text-sm",children:"Search"}),n&&e.jsx("button",{onClick:()=>{d(null),x("")},className:"px-3 py-2 bg-zinc-700 text-zinc-300 rounded-md hover:bg-zinc-600 text-sm",children:"Clear"})]}),e.jsxs("div",{className:"text-xs text-zinc-500",children:[f.length," documents",n?" (search results)":""]}),e.jsxs("div",{className:"space-y-1",children:[f.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-md hover:bg-zinc-800/50 group",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-zinc-200 truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-zinc-500",children:[s.sourceType,s.createdAt?` - ${new Date(s.createdAt).toLocaleDateString()}`:""]})]}),e.jsx("button",{onClick:()=>u(s.id),className:"text-xs text-red-400 opacity-0 group-hover:opacity-100 transition-opacity px-2 py-1 rounded hover:bg-red-900/30",children:"Delete"})]},s.id)),f.length===0&&e.jsx("div",{className:"text-zinc-500 text-sm p-4 text-center",children:"No documents found"})]})]})}function E(){const[l,m]=t.useState(!1),[r,i]=t.useState(!1),[o,x]=t.useState(null),[n,d]=t.useState(null),[a,c]=t.useState(null),[h,g]=t.useState(null),p=t.useCallback(async()=>{try{m(!0),g(null);const s=await b.knowledgeExport(),N=new Blob([JSON.stringify(s.package,null,2)],{type:"application/json"}),v=URL.createObjectURL(N),y=document.createElement("a");y.href=v,y.download=`knowledge-export-${new Date().toISOString().slice(0,10)}.json`,y.click(),URL.revokeObjectURL(v)}catch(s){g(s instanceof Error?s.message:"Export failed")}finally{m(!1)}},[]),j=t.useCallback(async s=>{var v;const N=(v=s.target.files)==null?void 0:v[0];if(N)try{g(null),d(null);const y=await N.text(),w=JSON.parse(y);c(w);const S=await b.knowledgePreview(w);x(S.preview)}catch(y){g(y instanceof Error?y.message:"Invalid package file"),c(null),x(null)}},[]),u=t.useCallback(async()=>{if(a)try{i(!0),g(null);const s=await b.knowledgeImport(a);d(s.result),x(null),c(null)}catch(s){g(s instanceof Error?s.message:"Import failed")}finally{i(!1)}},[a]),f=t.useCallback(()=>{c(null),x(null),d(null)},[]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4 border border-zinc-700",children:[e.jsx("h3",{className:"text-sm font-semibold text-zinc-200 mb-2",children:"Export Knowledge Package"}),e.jsx("p",{className:"text-xs text-zinc-400 mb-3",children:"Download all knowledge documents, memories, and relations as a portable JSON package."}),e.jsx("button",{onClick:p,disabled:l,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-500 text-sm disabled:opacity-50",children:l?"Exporting...":"Export Package"})]}),e.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4 border border-zinc-700",children:[e.jsx("h3",{className:"text-sm font-semibold text-zinc-200 mb-2",children:"Import Knowledge Package"}),e.jsx("p",{className:"text-xs text-zinc-400 mb-3",children:"Upload a knowledge package JSON to import documents and memories."}),e.jsx("input",{type:"file",accept:".json",onChange:j,className:"block w-full text-sm text-zinc-400 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:bg-zinc-700 file:text-zinc-200 hover:file:bg-zinc-600"}),o&&e.jsxs("div",{className:"mt-4 p-3 bg-zinc-900 rounded-md border border-zinc-600",children:[e.jsx("h4",{className:"text-xs font-semibold text-zinc-300 mb-2",children:"Import Preview"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-green-400",children:o.newDocuments})," new documents"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-yellow-400",children:o.existingDocuments})," existing (skip)"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-green-400",children:o.newMemories})," new memories"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-yellow-400",children:o.existingMemories})," existing (skip)"]})]}),e.jsxs("div",{className:"text-xs text-zinc-500 mt-2",children:["Sources: ",o.sourceTypes.join(", ")]}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsx("button",{onClick:u,disabled:r,className:"px-3 py-1.5 bg-green-600 text-white rounded-md hover:bg-green-500 text-xs disabled:opacity-50",children:r?"Importing...":"Confirm Import"}),e.jsx("button",{onClick:f,className:"px-3 py-1.5 bg-zinc-700 text-zinc-300 rounded-md hover:bg-zinc-600 text-xs",children:"Cancel"})]})]}),n&&e.jsxs("div",{className:"mt-4 p-3 bg-green-900/20 rounded-md border border-green-700/50",children:[e.jsx("h4",{className:"text-xs font-semibold text-green-400 mb-1",children:"Import Complete"}),e.jsxs("div",{className:"text-xs text-zinc-300",children:[n.documentsImported," docs imported, ",n.documentsSkipped," skipped, ",n.memoriesImported," memories imported"]})]})]}),h&&e.jsx("div",{className:"text-red-400 text-sm p-2",children:h})]})}function L(){const[l,m]=t.useState([]),[r,i]=t.useState(!0),[o,x]=t.useState({}),n=t.useCallback(async()=>{try{i(!0);const a=await b.knowledgeList(30);m(a.documents)}finally{i(!1)}},[]);t.useEffect(()=>{n()},[n]);const d=t.useCallback(async(a,c)=>{try{await b.knowledgeFeedback(a,c),x(h=>({...h,[a]:c}))}catch{}},[]);return r?e.jsx("div",{className:"text-zinc-400 p-4",children:"Loading..."}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-3",children:"Rate knowledge documents to improve RAG quality. Your feedback adjusts quality scores."}),l.map(a=>{const c=o[a.id];return e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-md hover:bg-zinc-800/50",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-zinc-200 truncate",children:a.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-zinc-500",children:[e.jsx("span",{children:a.sourceType}),a.qualityScore!==void 0&&e.jsxs("span",{className:`px-1.5 py-0.5 rounded ${a.qualityScore>.7?"bg-green-900/30 text-green-400":a.qualityScore>.3?"bg-yellow-900/30 text-yellow-400":"bg-red-900/30 text-red-400"}`,children:["q:",(a.qualityScore*100).toFixed(0),"%"]})]})]}),e.jsx("div",{className:"flex gap-1",children:c?e.jsx("span",{className:`text-xs px-2 py-1 rounded ${c==="helpful"?"bg-green-900/30 text-green-400":c==="unhelpful"?"bg-red-900/30 text-red-400":"bg-yellow-900/30 text-yellow-400"}`,children:c}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>d(a.id,"helpful"),className:"text-xs px-2 py-1 rounded bg-green-900/20 text-green-400 hover:bg-green-900/40",children:"Helpful"}),e.jsx("button",{onClick:()=>d(a.id,"unhelpful"),className:"text-xs px-2 py-1 rounded bg-red-900/20 text-red-400 hover:bg-red-900/40",children:"Unhelpful"}),e.jsx("button",{onClick:()=>d(a.id,"outdated"),className:"text-xs px-2 py-1 rounded bg-yellow-900/20 text-yellow-400 hover:bg-yellow-900/40",children:"Outdated"})]})})]},a.id)}),l.length===0&&e.jsx("div",{className:"text-zinc-500 text-sm p-4 text-center",children:"No knowledge documents yet"})]})}function R(){const[l,m]=t.useState("memories");return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex gap-1 p-2 border-b border-zinc-700 shrink-0",children:[{id:"memories",label:"Memories"},{id:"knowledge",label:"Knowledge Store"},{id:"export",label:"Export / Import"}].map(r=>e.jsx("button",{onClick:()=>m(r.id),className:`px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${l===r.id?"bg-blue-600/20 text-blue-400":"text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200"}`,children:r.label},r.id))}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[l==="knowledge"&&e.jsx("div",{className:"p-4",children:e.jsx(C,{})}),l==="export"&&e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(E,{}),e.jsxs("div",{className:"border-t border-zinc-700 pt-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-zinc-200 mb-3",children:"Knowledge Feedback"}),e.jsx(L,{})]})]}),l==="memories"&&e.jsx(D,{})]})]})}function D(){const[l,m]=t.useState([]),[r,i]=t.useState(null),[o,x]=t.useState(null),[n,d]=t.useState(!0),[a,c]=t.useState(!1),[h,g]=t.useState(new Map),p=t.useCallback(async()=>{try{d(!0);const u=await b.getMemories().catch(()=>[]);m(u)}catch(u){x(u instanceof Error?u.message:"Failed to load")}finally{d(!1)}},[]);t.useEffect(()=>{p()},[p]);const j=t.useCallback(async u=>{i(u);const f=h.get(u.name);if(f!==void 0){i({...u,content:f});return}try{c(!0);const s=await b.readMemory(u.name);g(N=>{const v=new Map(N);return v.set(u.name,s.content),v}),i({...u,content:s.content})}catch{i({...u,content:"[Failed to load content]"})}finally{c(!1)}},[h]);return n?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((u,f)=>e.jsx("div",{className:"h-4 rounded bg-surface animate-pulse",style:{width:`${50+Math.random()*40}%`,marginLeft:`${f%3*12}px`}},f))]}),e.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-xs",children:"Loading memories..."})]}):o?e.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load: ",o]}):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(F,{label:"Memories",active:l.length>0}),e.jsxs("span",{className:"text-[10px] text-muted",children:[l.length," memories"]})]}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx(P,{memories:l,selectedMemory:r,onSelect:j}),e.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:e.jsx(M,{selectedMemory:r,contentLoading:a})})]})]})}function F({label:l,active:m}){const r=m?"var(--color-success)":"var(--color-text-muted)",i=m?"Active":"No data";return e.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full",style:{background:`${r}20`,color:r},children:[l,": ",i]})}function P({memories:l,selectedMemory:m,onSelect:r}){const[i,o]=t.useState(""),[x,n]=t.useState(!1),[d,a]=t.useState(new Set),c=t.useMemo(()=>{if(!i.trim())return l;const p=i.toLowerCase();return l.filter(j=>j.name.toLowerCase().includes(p))},[l,i]),h=t.useMemo(()=>z(c),[c]),g=t.useCallback(p=>{a(j=>{const u=new Set(j);return u.has(p)?u.delete(p):u.add(p),u})},[]);return x?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:()=>n(!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:()=>n(!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:i,onChange:p=>o(p.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:l.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-muted",children:"No memories"}):e.jsx(k,{nodes:h,depth:0,expandedPaths:d,onToggle:g,selectedMemory:m,onSelect:r})})]})}function k({nodes:l,depth:m,expandedPaths:r,onToggle:i,selectedMemory:o,onSelect:x}){return e.jsx(e.Fragment,{children:l.map(n=>{const d=n.children.length>0,a=r.has(n.path),c=n.memory!=null&&(o==null?void 0:o.name)===n.memory.name;return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>{d&&i(n.path),n.memory&&x(n.memory)},className:`w-full text-left px-2 py-0.5 flex items-center gap-1 hover:bg-surface-elevated transition-colors cursor-pointer ${c?"bg-accent15 text-accent":"text-foreground"}`,style:{paddingLeft:`${m*12+8}px`},children:[d?e.jsx("span",{className:"w-3 text-[9px] text-muted",children:a?"▾":"▸"}):e.jsx("span",{className:"w-3 text-[9px] text-muted",children:"·"}),e.jsx("span",{className:"truncate",children:n.name})]}),d&&a&&e.jsx(k,{nodes:n.children,depth:m+1,expandedPaths:r,onToggle:i,selectedMemory:o,onSelect:x})]},n.path)})})}function M({selectedMemory:l,contentLoading:m}){const[r,i]=t.useState(!1);if(!l)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 o=()=>{navigator.clipboard.writeText(l.content),i(!0),setTimeout(()=>i(!1),2e3)},x=l.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"}),x.map((n,d)=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{children:"/"}),e.jsx("span",{className:d===x.length-1?"text-foreground font-medium":"",children:n})]},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:x[x.length-1]}),e.jsx("button",{onClick:o,disabled:m,className:`text-[10px] px-2 py-0.5 rounded border transition-all cursor-pointer ${r?"border-green-500/30 text-green-500 bg-green-500/5":"border-edge text-muted hover:text-foreground"}`,children:r?"Copied!":"Copy"})]}),m?e.jsx("div",{className:"space-y-2",children:Array.from({length:8}).map((n,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:l.content})]})}export{R as MemoriesTab};
@@ -1 +1 @@
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};
1
+ import{r as c,j as e}from"./index-Dbaws8C6.js";import{R as _,u as M,a as E,b as P,i as T,B,C as D}from"./style-BPgBTbDw.js";import{S as w}from"./constants-Dd6A34aQ.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-D10A5HwE.js";import"./index-07Y4UWP1.js";import"./index-CVRN6scU.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};
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-DfEJaZLA.js";/**
1
+ import{c as e}from"./index-Dbaws8C6.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-section-B-cObR6x.js","assets/index-DfEJaZLA.js","assets/index-CTdsOcRa.css","assets/style-CsU39IOg.js","assets/index-iWhfMJa8.js","assets/style-BZV40eAE.css","assets/constants-lq4BIQN3.js","assets/index-z9HSPrpH.js"])))=>i.map(i=>d[i]);
2
- import{r as s,j as e,a as S,_ as L}from"./index-DfEJaZLA.js";import{e as k}from"./constants-lq4BIQN3.js";const D=[{id:"upload",label:"Upload",icon:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"},{id:"objects",label:"Objects",icon:"M3.75 12h16.5m-16.5 3.75h16.5M3.75 19.5h16.5M5.625 4.5h12.75a1.875 1.875 0 010 3.75H5.625a1.875 1.875 0 010-3.75z"},{id:"graph",label:"Graph",icon:"M7.5 14.25v2.25m3-4.5v4.5m3-6.75v6.75m3-9v9M6 20.25h12A2.25 2.25 0 0020.25 18V6A2.25 2.25 0 0018 3.75H6A2.25 2.25 0 003.75 6v12A2.25 2.25 0 006 20.25z"},{id:"generation",label:"Generation",icon:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456z"}],T=s.memo(function({activeSection:t,onSectionChange:a,objectCount:d}){return e.jsxs("nav",{className:"w-48 flex-shrink-0 border-r border-edge bg-surface-alt flex flex-col","aria-label":"Siebel sections",children:[e.jsx("div",{className:"px-3 py-3 border-b border-edge",children:e.jsx("h2",{className:"text-xs font-semibold uppercase text-muted tracking-wider",children:"Siebel"})}),e.jsx("div",{className:"flex-1 py-1",children:D.map(u=>e.jsxs("button",{onClick:()=>a(u.id),"aria-label":`Navigate to ${u.label}`,className:`w-full flex items-center gap-2.5 px-3 py-2 text-xs font-medium transition-colors cursor-pointer ${t===u.id?"bg-accent/10 text-accent border-r-2 border-accent":"text-muted hover:text-foreground hover:bg-surface"}`,children:[e.jsx("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:u.icon})}),e.jsx("span",{children:u.label}),u.id==="objects"&&d>0&&e.jsx("span",{className:"ml-auto text-[10px] px-1.5 py-0.5 rounded-full bg-surface text-muted",children:d})]},u.id))})]})});function E(){const[o,t]=s.useState([]),[a,d]=s.useState([]),[u,x]=s.useState(!0),[b,h]=s.useState(null),c=s.useCallback(async()=>{try{x(!0),h(null);const[m,l]=await Promise.all([S.siebelGetObjects({limit:100}).catch(()=>({objects:[],total:0})),S.siebelGetTemplates().catch(()=>({templates:[]}))]);t(m.objects),d(l.templates)}catch(m){h(m instanceof Error?m.message:"Failed to load Siebel data")}finally{x(!1)}},[]);return s.useEffect(()=>{c()},[c]),{objects:o,templates:a,loading:u,error:b,refresh:c}}function P(o){const[t,a]=s.useState(""),[d,u]=s.useState(["business_component"]),[x,b]=s.useState(""),[h,c]=s.useState(null),[m,l]=s.useState(""),[n,i]=s.useState(null),[g,v]=s.useState(!1),N=s.useCallback(f=>{u(y=>y.includes(f)?y.filter(w=>w!==f):[...y,f])},[]),j=s.useCallback(async()=>{if(t.trim()){v(!0),i(null);try{const f=await S.siebelPrepareGeneration({description:t,objectTypes:d,basedOnProject:x||void 0});c(f.prompt)}catch(f){c(`Error: ${f instanceof Error?f.message:String(f)}`)}finally{v(!1)}}},[t,d,x]),r=s.useCallback(async()=>{if(m.trim()){v(!0);try{const f=await S.siebelFinalizeGeneration({generatedXml:m,description:t,objectTypes:d});i(f),o==null||o()}catch(f){i({sifContent:"",objects:[],validation:{status:"invalid",messages:[{level:"error",message:f instanceof Error?f.message:String(f)}],score:0},metadata:{generatedAt:new Date().toISOString(),requestDescription:t,objectCount:0}})}finally{v(!1)}}},[m,t,d,o]),p=s.useCallback(()=>{if(!(n!=null&&n.sifContent))return;const f=new Blob([n.sifContent],{type:"application/xml"}),y=URL.createObjectURL(f),w=document.createElement("a");w.href=y,w.download="generated.sif",w.click(),URL.revokeObjectURL(y)},[n]);return{description:t,setDescription:a,selectedTypes:d,toggleType:N,project:x,setProject:b,prompt:h,xml:m,setXml:l,result:n,loading:g,prepare:j,finalize:r,download:p}}function I(){const[o,t]=s.useState(null),[a,d]=s.useState(0),[u,x]=s.useState("idle"),[b,h]=s.useState(null),c=s.useRef(null);s.useEffect(()=>()=>{var n;(n=c.current)==null||n.terminate()},[]);const m=s.useCallback(n=>{t(null),h(null),d(0),x("reading"),n.text().then(i=>{var v;d(10),x("parsing"),(v=c.current)==null||v.terminate();const g=new Worker(new URL("/assets/sif-parse.worker-DZrybOHz.js",import.meta.url),{type:"module"});c.current=g,g.onmessage=N=>{const j=N.data;j.type==="progress"?(d(j.progress),x(j.status)):j.type==="result"?(t(j.data),x("done"),d(100),g.terminate(),c.current=null):j.type==="error"&&(h(j.message),x("error"),g.terminate(),c.current=null)},g.onerror=N=>{h(N.message||"Worker error"),x("error"),g.terminate(),c.current=null},g.postMessage({type:"parse",content:i,fileName:n.name})}).catch(i=>{h(i instanceof Error?i.message:"Failed to read file"),x("error")})},[]),l=s.useCallback(()=>{var n;(n=c.current)==null||n.terminate(),c.current=null,t(null),d(0),x("idle"),h(null)},[]);return{parse:m,result:o,progress:a,status:u,error:b,reset:l}}const F={idle:"",reading:"Reading file...",parsing:"Parsing XML...",extracting:"Extracting objects...",inferring:"Inferring dependencies...",done:"Done!",error:"Error"},R=s.memo(function({status:t,progress:a,error:d}){if(t==="idle")return null;const u=t==="error",x=t==="done";return e.jsxs("div",{className:"space-y-1.5",role:"status","aria-live":"polite",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:u?"text-red-500":x?"text-green-500":"text-muted",children:u?d:F[t]}),!u&&e.jsxs("span",{className:"text-[10px] text-muted",children:[a,"%"]})]}),!u&&e.jsx("div",{className:"h-1.5 rounded-full bg-surface overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-300 ${x?"bg-green-500":"bg-accent"}`,style:{width:`${a}%`}})})]})});function $({onUploaded:o}){const[t,a]=s.useState(null),[d,u]=s.useState(!1),[x,b]=s.useState(!1),h=s.useRef(null),c=s.useRef(null),m=I();s.useEffect(()=>{if(m.status!=="done"||!m.result)return;const r=m.result.metadata.fileName;(async()=>{try{l.current&&(await S.siebelImportSif(l.current,r,!0),l.current=null,o())}catch{}})()},[m.status,m.result,o]);const l=s.useRef(null),n=s.useCallback(r=>{r.text().then(p=>{l.current=p,m.parse(r)}).catch(()=>{(async()=>{try{const p=await r.text();await S.siebelImportSif(p,r.name,!0),o()}catch{}})()})},[m,o]),i=s.useCallback(async r=>{try{a("Uploading documentation...");const p=await S.siebelUploadDocs(r);a(`Indexed: ${p.fileName} (${p.chunksIndexed} chunks)`),o()}catch(p){a(`Error: ${p instanceof Error?p.message:String(p)}`)}},[o]),g=s.useCallback(r=>{var f;const p=(f=r.target.files)==null?void 0:f[0];p&&n(p),h.current&&(h.current.value="")},[n]),v=s.useCallback(r=>{var f;const p=(f=r.target.files)==null?void 0:f[0];p&&i(p),c.current&&(c.current.value="")},[i]),N=s.useCallback((r,p,f)=>{r.preventDefault(),f(!1);const y=r.dataTransfer.files[0];y&&p(y)},[]),j=s.useCallback(r=>{r.preventDefault(),r.stopPropagation()},[]);return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",children:"Upload & Context"}),e.jsx("p",{className:"text-xs text-muted",children:"Upload SIF files and documentation to build RAG context for generation"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer ${d?"border-accent bg-accent/5":"border-edge hover:border-accent/50"}`,onDragEnter:r=>{j(r),u(!0)},onDragOver:r=>{j(r),u(!0)},onDragLeave:r=>{j(r),u(!1)},onDrop:r=>N(r,n,u),onClick:()=>{var r;return(r=h.current)==null?void 0:r.click()},role:"button",tabIndex:0,onKeyDown:r=>{var p;(r.key==="Enter"||r.key===" ")&&((p=h.current)==null||p.click())},"aria-label":"Upload SIF file",children:[e.jsx("input",{ref:h,type:"file",accept:".sif,.xml",onChange:g,className:"hidden",tabIndex:-1}),e.jsx("svg",{className:"w-8 h-8 mx-auto mb-2 text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m6.75 12l-3-3m0 0l-3 3m3-3v6m-1.5-15H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),e.jsx("p",{className:"text-xs font-medium",children:"SIF File (.sif, .xml)"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"Drop here or click to browse"})]}),e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer ${x?"border-accent bg-accent/5":"border-edge hover:border-accent/50"}`,onDragEnter:r=>{j(r),b(!0)},onDragOver:r=>{j(r),b(!0)},onDragLeave:r=>{j(r),b(!1)},onDrop:r=>N(r,i,b),onClick:()=>{var r;return(r=c.current)==null?void 0:r.click()},role:"button",tabIndex:0,onKeyDown:r=>{var p;(r.key==="Enter"||r.key===" ")&&((p=c.current)==null||p.click())},"aria-label":"Upload documentation file",children:[e.jsx("input",{ref:c,type:"file",accept:".pdf,.html,.htm,.txt,.md,.doc,.docx",onChange:v,className:"hidden",tabIndex:-1}),e.jsx("svg",{className:"w-8 h-8 mx-auto mb-2 text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25"})}),e.jsx("p",{className:"text-xs font-medium",children:"Documentation"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"PDF, HTML, DOC, DOCX, TXT, MD"})]})]}),m.status!=="idle"&&e.jsx(R,{status:m.status,progress:m.progress,error:m.error}),t&&e.jsx("div",{className:`px-3 py-2 rounded-md text-xs ${t.startsWith("Error")?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-500"}`,role:"status","aria-live":"polite",children:t})]})}const C=36;function M({objects:o}){const[t,a]=s.useState(""),[d,u]=s.useState(new Set),x=s.useDeferredValue(t),b=s.useDeferredValue(d),h=s.useMemo(()=>{const l=new Set;for(const n of o)n.siebelType&&l.add(n.siebelType);return[...l].sort()},[o]),c=s.useMemo(()=>{let l=o;if(x){const n=x.toLowerCase();l=l.filter(i=>{var g;return i.title.toLowerCase().includes(n)||((g=i.siebelProject)==null?void 0:g.toLowerCase().includes(n))||i.contentPreview.toLowerCase().includes(n)})}return b.size>0&&(l=l.filter(n=>n.siebelType&&b.has(n.siebelType))),l},[o,x,b]),m=l=>{u(n=>{const i=new Set(n);return i.has(l)?i.delete(l):i.add(l),i})};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"p-4 space-y-3 border-b border-edge",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h3",{className:"text-sm font-semibold",children:["Indexed Siebel Objects",e.jsxs("span",{className:"ml-2 text-xs font-normal text-muted",children:[c.length,c.length!==o.length?` / ${o.length}`:""," objects"]})]})}),e.jsx("input",{type:"text",value:t,onChange:l=>a(l.target.value),placeholder:"Search objects...","aria-label":"Search Siebel objects",className:"w-full px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"}),h.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:h.map(l=>{const n=k[l]||"#6b7280",i=d.has(l);return e.jsx("button",{onClick:()=>m(l),"aria-label":`Filter by ${l}`,"aria-pressed":i,className:"px-2 py-0.5 text-[10px] rounded-md border transition-colors cursor-pointer",style:{borderColor:i?n:"var(--color-border)",backgroundColor:i?`${n}15`:"transparent",color:i?n:"var(--color-text-muted)"},children:l.replace(/_/g," ")},l)})})]}),c.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-muted",children:o.length===0?"No Siebel objects indexed yet. Upload a .sif file.":"No objects match the current filters."}):e.jsx("div",{className:"flex-1 overflow-auto",style:{contentVisibility:"auto",containIntrinsicSize:`0 ${c.length*C}px`},children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-alt z-10",children:e.jsxs("tr",{className:"border-b border-edge",children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Name"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Type"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Project"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Preview"})]})}),e.jsx("tbody",{children:c.map((l,n)=>{const i=k[l.siebelType??""]||"#6b7280";return e.jsxs("tr",{className:"border-b border-edge hover:bg-surface transition-colors",style:{height:C},children:[e.jsx("td",{className:"px-4 py-1.5 font-mono",children:l.title}),e.jsx("td",{className:"px-4 py-1.5",children:e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{backgroundColor:`${i}15`,color:i},children:l.siebelType??l.sourceType})}),e.jsx("td",{className:"px-4 py-1.5 text-muted",children:l.siebelProject??"-"}),e.jsx("td",{className:"px-4 py-1.5 text-muted truncate max-w-xs",children:l.contentPreview})]},n)})})]})})]})}function O({templates:o,gen:t}){return e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",children:"SIF Generation"}),e.jsx("p",{className:"text-xs text-muted",children:"Describe what you need, generate context for the LLM, then validate the output"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-description",children:"Description"}),e.jsx("textarea",{id:"gen-description",value:t.description,onChange:a=>t.setDescription(a.target.value),placeholder:"e.g., Create a Business Component for Service Requests with fields: SR Number, Status, Priority",rows:3,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"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1.5",children:"Object Types"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:o.map(a=>e.jsx("button",{onClick:()=>t.toggleType(a.type),"aria-label":`Toggle ${a.type}`,"aria-pressed":t.selectedTypes.includes(a.type),className:`px-2 py-1 text-[10px] rounded-md border transition-colors cursor-pointer ${t.selectedTypes.includes(a.type)?"bg-accent text-white border-accent":"bg-transparent text-muted border-edge hover:border-accent"}`,children:a.type.replace(/_/g," ")},a.type))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-project",children:"Base Project (optional)"}),e.jsx("input",{id:"gen-project",value:t.project,onChange:a=>t.setProject(a.target.value),placeholder:"e.g., Account (SSE)",className:"w-full px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"})]}),e.jsx("button",{onClick:t.prepare,disabled:!t.description.trim()||t.loading,className:"px-4 py-1.5 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 disabled:opacity-50 transition-opacity cursor-pointer disabled:cursor-not-allowed",children:t.loading&&!t.prompt?"Generating Context...":"Generate Context & Prompt"}),t.prompt&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"text-xs font-medium",children:"Generated Prompt (copy to LLM)"}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(t.prompt??""),"aria-label":"Copy prompt to clipboard",className:"text-[10px] px-2 py-0.5 rounded bg-surface text-muted hover:text-foreground border border-edge cursor-pointer transition-colors",children:"Copy"})]}),e.jsxs("pre",{className:"text-[10px] p-3 rounded-md bg-surface border border-edge max-h-48 overflow-auto whitespace-pre-wrap text-muted",children:[t.prompt.slice(0,3e3),t.prompt.length>3e3&&`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-section-CsHifp70.js","assets/index-Dbaws8C6.js","assets/index-DVIgWBT4.css","assets/style-BPgBTbDw.js","assets/index-07Y4UWP1.js","assets/style-BZV40eAE.css","assets/constants-Dd6A34aQ.js","assets/index-CVRN6scU.js"])))=>i.map(i=>d[i]);
2
+ import{r as s,j as e,a as S,_ as L}from"./index-Dbaws8C6.js";import{e as k}from"./constants-Dd6A34aQ.js";const D=[{id:"upload",label:"Upload",icon:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"},{id:"objects",label:"Objects",icon:"M3.75 12h16.5m-16.5 3.75h16.5M3.75 19.5h16.5M5.625 4.5h12.75a1.875 1.875 0 010 3.75H5.625a1.875 1.875 0 010-3.75z"},{id:"graph",label:"Graph",icon:"M7.5 14.25v2.25m3-4.5v4.5m3-6.75v6.75m3-9v9M6 20.25h12A2.25 2.25 0 0020.25 18V6A2.25 2.25 0 0018 3.75H6A2.25 2.25 0 003.75 6v12A2.25 2.25 0 006 20.25z"},{id:"generation",label:"Generation",icon:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456z"}],T=s.memo(function({activeSection:t,onSectionChange:a,objectCount:d}){return e.jsxs("nav",{className:"w-48 flex-shrink-0 border-r border-edge bg-surface-alt flex flex-col","aria-label":"Siebel sections",children:[e.jsx("div",{className:"px-3 py-3 border-b border-edge",children:e.jsx("h2",{className:"text-xs font-semibold uppercase text-muted tracking-wider",children:"Siebel"})}),e.jsx("div",{className:"flex-1 py-1",children:D.map(u=>e.jsxs("button",{onClick:()=>a(u.id),"aria-label":`Navigate to ${u.label}`,className:`w-full flex items-center gap-2.5 px-3 py-2 text-xs font-medium transition-colors cursor-pointer ${t===u.id?"bg-accent/10 text-accent border-r-2 border-accent":"text-muted hover:text-foreground hover:bg-surface"}`,children:[e.jsx("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:u.icon})}),e.jsx("span",{children:u.label}),u.id==="objects"&&d>0&&e.jsx("span",{className:"ml-auto text-[10px] px-1.5 py-0.5 rounded-full bg-surface text-muted",children:d})]},u.id))})]})});function E(){const[o,t]=s.useState([]),[a,d]=s.useState([]),[u,x]=s.useState(!0),[b,h]=s.useState(null),c=s.useCallback(async()=>{try{x(!0),h(null);const[m,l]=await Promise.all([S.siebelGetObjects({limit:100}).catch(()=>({objects:[],total:0})),S.siebelGetTemplates().catch(()=>({templates:[]}))]);t(m.objects),d(l.templates)}catch(m){h(m instanceof Error?m.message:"Failed to load Siebel data")}finally{x(!1)}},[]);return s.useEffect(()=>{c()},[c]),{objects:o,templates:a,loading:u,error:b,refresh:c}}function P(o){const[t,a]=s.useState(""),[d,u]=s.useState(["business_component"]),[x,b]=s.useState(""),[h,c]=s.useState(null),[m,l]=s.useState(""),[n,i]=s.useState(null),[g,v]=s.useState(!1),N=s.useCallback(f=>{u(y=>y.includes(f)?y.filter(w=>w!==f):[...y,f])},[]),j=s.useCallback(async()=>{if(t.trim()){v(!0),i(null);try{const f=await S.siebelPrepareGeneration({description:t,objectTypes:d,basedOnProject:x||void 0});c(f.prompt)}catch(f){c(`Error: ${f instanceof Error?f.message:String(f)}`)}finally{v(!1)}}},[t,d,x]),r=s.useCallback(async()=>{if(m.trim()){v(!0);try{const f=await S.siebelFinalizeGeneration({generatedXml:m,description:t,objectTypes:d});i(f),o==null||o()}catch(f){i({sifContent:"",objects:[],validation:{status:"invalid",messages:[{level:"error",message:f instanceof Error?f.message:String(f)}],score:0},metadata:{generatedAt:new Date().toISOString(),requestDescription:t,objectCount:0}})}finally{v(!1)}}},[m,t,d,o]),p=s.useCallback(()=>{if(!(n!=null&&n.sifContent))return;const f=new Blob([n.sifContent],{type:"application/xml"}),y=URL.createObjectURL(f),w=document.createElement("a");w.href=y,w.download="generated.sif",w.click(),URL.revokeObjectURL(y)},[n]);return{description:t,setDescription:a,selectedTypes:d,toggleType:N,project:x,setProject:b,prompt:h,xml:m,setXml:l,result:n,loading:g,prepare:j,finalize:r,download:p}}function I(){const[o,t]=s.useState(null),[a,d]=s.useState(0),[u,x]=s.useState("idle"),[b,h]=s.useState(null),c=s.useRef(null);s.useEffect(()=>()=>{var n;(n=c.current)==null||n.terminate()},[]);const m=s.useCallback(n=>{t(null),h(null),d(0),x("reading"),n.text().then(i=>{var v;d(10),x("parsing"),(v=c.current)==null||v.terminate();const g=new Worker(new URL("/assets/sif-parse.worker-DZrybOHz.js",import.meta.url),{type:"module"});c.current=g,g.onmessage=N=>{const j=N.data;j.type==="progress"?(d(j.progress),x(j.status)):j.type==="result"?(t(j.data),x("done"),d(100),g.terminate(),c.current=null):j.type==="error"&&(h(j.message),x("error"),g.terminate(),c.current=null)},g.onerror=N=>{h(N.message||"Worker error"),x("error"),g.terminate(),c.current=null},g.postMessage({type:"parse",content:i,fileName:n.name})}).catch(i=>{h(i instanceof Error?i.message:"Failed to read file"),x("error")})},[]),l=s.useCallback(()=>{var n;(n=c.current)==null||n.terminate(),c.current=null,t(null),d(0),x("idle"),h(null)},[]);return{parse:m,result:o,progress:a,status:u,error:b,reset:l}}const F={idle:"",reading:"Reading file...",parsing:"Parsing XML...",extracting:"Extracting objects...",inferring:"Inferring dependencies...",done:"Done!",error:"Error"},R=s.memo(function({status:t,progress:a,error:d}){if(t==="idle")return null;const u=t==="error",x=t==="done";return e.jsxs("div",{className:"space-y-1.5",role:"status","aria-live":"polite",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:u?"text-red-500":x?"text-green-500":"text-muted",children:u?d:F[t]}),!u&&e.jsxs("span",{className:"text-[10px] text-muted",children:[a,"%"]})]}),!u&&e.jsx("div",{className:"h-1.5 rounded-full bg-surface overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-300 ${x?"bg-green-500":"bg-accent"}`,style:{width:`${a}%`}})})]})});function $({onUploaded:o}){const[t,a]=s.useState(null),[d,u]=s.useState(!1),[x,b]=s.useState(!1),h=s.useRef(null),c=s.useRef(null),m=I();s.useEffect(()=>{if(m.status!=="done"||!m.result)return;const r=m.result.metadata.fileName;(async()=>{try{l.current&&(await S.siebelImportSif(l.current,r,!0),l.current=null,o())}catch{}})()},[m.status,m.result,o]);const l=s.useRef(null),n=s.useCallback(r=>{r.text().then(p=>{l.current=p,m.parse(r)}).catch(()=>{(async()=>{try{const p=await r.text();await S.siebelImportSif(p,r.name,!0),o()}catch{}})()})},[m,o]),i=s.useCallback(async r=>{try{a("Uploading documentation...");const p=await S.siebelUploadDocs(r);a(`Indexed: ${p.fileName} (${p.chunksIndexed} chunks)`),o()}catch(p){a(`Error: ${p instanceof Error?p.message:String(p)}`)}},[o]),g=s.useCallback(r=>{var f;const p=(f=r.target.files)==null?void 0:f[0];p&&n(p),h.current&&(h.current.value="")},[n]),v=s.useCallback(r=>{var f;const p=(f=r.target.files)==null?void 0:f[0];p&&i(p),c.current&&(c.current.value="")},[i]),N=s.useCallback((r,p,f)=>{r.preventDefault(),f(!1);const y=r.dataTransfer.files[0];y&&p(y)},[]),j=s.useCallback(r=>{r.preventDefault(),r.stopPropagation()},[]);return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",children:"Upload & Context"}),e.jsx("p",{className:"text-xs text-muted",children:"Upload SIF files and documentation to build RAG context for generation"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer ${d?"border-accent bg-accent/5":"border-edge hover:border-accent/50"}`,onDragEnter:r=>{j(r),u(!0)},onDragOver:r=>{j(r),u(!0)},onDragLeave:r=>{j(r),u(!1)},onDrop:r=>N(r,n,u),onClick:()=>{var r;return(r=h.current)==null?void 0:r.click()},role:"button",tabIndex:0,onKeyDown:r=>{var p;(r.key==="Enter"||r.key===" ")&&((p=h.current)==null||p.click())},"aria-label":"Upload SIF file",children:[e.jsx("input",{ref:h,type:"file",accept:".sif,.xml",onChange:g,className:"hidden",tabIndex:-1}),e.jsx("svg",{className:"w-8 h-8 mx-auto mb-2 text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m6.75 12l-3-3m0 0l-3 3m3-3v6m-1.5-15H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),e.jsx("p",{className:"text-xs font-medium",children:"SIF File (.sif, .xml)"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"Drop here or click to browse"})]}),e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer ${x?"border-accent bg-accent/5":"border-edge hover:border-accent/50"}`,onDragEnter:r=>{j(r),b(!0)},onDragOver:r=>{j(r),b(!0)},onDragLeave:r=>{j(r),b(!1)},onDrop:r=>N(r,i,b),onClick:()=>{var r;return(r=c.current)==null?void 0:r.click()},role:"button",tabIndex:0,onKeyDown:r=>{var p;(r.key==="Enter"||r.key===" ")&&((p=c.current)==null||p.click())},"aria-label":"Upload documentation file",children:[e.jsx("input",{ref:c,type:"file",accept:".pdf,.html,.htm,.txt,.md,.doc,.docx",onChange:v,className:"hidden",tabIndex:-1}),e.jsx("svg",{className:"w-8 h-8 mx-auto mb-2 text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25"})}),e.jsx("p",{className:"text-xs font-medium",children:"Documentation"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"PDF, HTML, DOC, DOCX, TXT, MD"})]})]}),m.status!=="idle"&&e.jsx(R,{status:m.status,progress:m.progress,error:m.error}),t&&e.jsx("div",{className:`px-3 py-2 rounded-md text-xs ${t.startsWith("Error")?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-500"}`,role:"status","aria-live":"polite",children:t})]})}const C=36;function M({objects:o}){const[t,a]=s.useState(""),[d,u]=s.useState(new Set),x=s.useDeferredValue(t),b=s.useDeferredValue(d),h=s.useMemo(()=>{const l=new Set;for(const n of o)n.siebelType&&l.add(n.siebelType);return[...l].sort()},[o]),c=s.useMemo(()=>{let l=o;if(x){const n=x.toLowerCase();l=l.filter(i=>{var g;return i.title.toLowerCase().includes(n)||((g=i.siebelProject)==null?void 0:g.toLowerCase().includes(n))||i.contentPreview.toLowerCase().includes(n)})}return b.size>0&&(l=l.filter(n=>n.siebelType&&b.has(n.siebelType))),l},[o,x,b]),m=l=>{u(n=>{const i=new Set(n);return i.has(l)?i.delete(l):i.add(l),i})};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"p-4 space-y-3 border-b border-edge",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h3",{className:"text-sm font-semibold",children:["Indexed Siebel Objects",e.jsxs("span",{className:"ml-2 text-xs font-normal text-muted",children:[c.length,c.length!==o.length?` / ${o.length}`:""," objects"]})]})}),e.jsx("input",{type:"text",value:t,onChange:l=>a(l.target.value),placeholder:"Search objects...","aria-label":"Search Siebel objects",className:"w-full px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"}),h.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:h.map(l=>{const n=k[l]||"#6b7280",i=d.has(l);return e.jsx("button",{onClick:()=>m(l),"aria-label":`Filter by ${l}`,"aria-pressed":i,className:"px-2 py-0.5 text-[10px] rounded-md border transition-colors cursor-pointer",style:{borderColor:i?n:"var(--color-border)",backgroundColor:i?`${n}15`:"transparent",color:i?n:"var(--color-text-muted)"},children:l.replace(/_/g," ")},l)})})]}),c.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-muted",children:o.length===0?"No Siebel objects indexed yet. Upload a .sif file.":"No objects match the current filters."}):e.jsx("div",{className:"flex-1 overflow-auto",style:{contentVisibility:"auto",containIntrinsicSize:`0 ${c.length*C}px`},children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-alt z-10",children:e.jsxs("tr",{className:"border-b border-edge",children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Name"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Type"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Project"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Preview"})]})}),e.jsx("tbody",{children:c.map((l,n)=>{const i=k[l.siebelType??""]||"#6b7280";return e.jsxs("tr",{className:"border-b border-edge hover:bg-surface transition-colors",style:{height:C},children:[e.jsx("td",{className:"px-4 py-1.5 font-mono",children:l.title}),e.jsx("td",{className:"px-4 py-1.5",children:e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{backgroundColor:`${i}15`,color:i},children:l.siebelType??l.sourceType})}),e.jsx("td",{className:"px-4 py-1.5 text-muted",children:l.siebelProject??"-"}),e.jsx("td",{className:"px-4 py-1.5 text-muted truncate max-w-xs",children:l.contentPreview})]},n)})})]})})]})}function O({templates:o,gen:t}){return e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",children:"SIF Generation"}),e.jsx("p",{className:"text-xs text-muted",children:"Describe what you need, generate context for the LLM, then validate the output"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-description",children:"Description"}),e.jsx("textarea",{id:"gen-description",value:t.description,onChange:a=>t.setDescription(a.target.value),placeholder:"e.g., Create a Business Component for Service Requests with fields: SR Number, Status, Priority",rows:3,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"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1.5",children:"Object Types"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:o.map(a=>e.jsx("button",{onClick:()=>t.toggleType(a.type),"aria-label":`Toggle ${a.type}`,"aria-pressed":t.selectedTypes.includes(a.type),className:`px-2 py-1 text-[10px] rounded-md border transition-colors cursor-pointer ${t.selectedTypes.includes(a.type)?"bg-accent text-white border-accent":"bg-transparent text-muted border-edge hover:border-accent"}`,children:a.type.replace(/_/g," ")},a.type))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-project",children:"Base Project (optional)"}),e.jsx("input",{id:"gen-project",value:t.project,onChange:a=>t.setProject(a.target.value),placeholder:"e.g., Account (SSE)",className:"w-full px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"})]}),e.jsx("button",{onClick:t.prepare,disabled:!t.description.trim()||t.loading,className:"px-4 py-1.5 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 disabled:opacity-50 transition-opacity cursor-pointer disabled:cursor-not-allowed",children:t.loading&&!t.prompt?"Generating Context...":"Generate Context & Prompt"}),t.prompt&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"text-xs font-medium",children:"Generated Prompt (copy to LLM)"}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(t.prompt??""),"aria-label":"Copy prompt to clipboard",className:"text-[10px] px-2 py-0.5 rounded bg-surface text-muted hover:text-foreground border border-edge cursor-pointer transition-colors",children:"Copy"})]}),e.jsxs("pre",{className:"text-[10px] p-3 rounded-md bg-surface border border-edge max-h-48 overflow-auto whitespace-pre-wrap text-muted",children:[t.prompt.slice(0,3e3),t.prompt.length>3e3&&`
3
3
 
4
- ... (truncated for display)`]})]}),t.prompt&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-xml",children:"Paste LLM-generated SIF XML"}),e.jsx("textarea",{id:"gen-xml",value:t.xml,onChange:a=>t.setXml(a.target.value),placeholder:'Paste the XML output from the LLM here (starting with <?xml version="1.0"...)',rows:8,className:"w-full px-3 py-2 text-xs font-mono rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsx("button",{onClick:t.finalize,disabled:!t.xml.trim()||t.loading,className:"mt-2 px-4 py-1.5 text-xs font-medium rounded-md bg-green-600 text-white hover:opacity-90 disabled:opacity-50 transition-opacity cursor-pointer disabled:cursor-not-allowed",children:t.loading?"Validating...":"Validate & Finalize"})]}),t.result&&e.jsxs("div",{className:`rounded-md border p-4 space-y-2 ${t.result.validation.status==="valid"?"border-green-500/30 bg-green-500/5":t.result.validation.status==="warnings"?"border-yellow-500/30 bg-yellow-500/5":"border-red-500/30 bg-red-500/5"}`,role:"status",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-sm font-bold ${t.result.validation.status==="valid"?"text-green-500":t.result.validation.status==="warnings"?"text-yellow-500":"text-red-500"}`,children:t.result.validation.status==="valid"?"Valid":t.result.validation.status==="warnings"?"Warnings":"Invalid"}),e.jsxs("span",{className:"text-xs text-muted",children:["Score: ",t.result.validation.score,"/100"]}),e.jsxs("span",{className:"text-xs text-muted",children:[t.result.metadata.objectCount," objects"]})]}),t.result.validation.status!=="invalid"&&e.jsx("button",{onClick:t.download,"aria-label":"Download generated SIF file",className:"px-3 py-1 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 cursor-pointer transition-opacity",children:"Download SIF"})]}),t.result.objects.length>0&&e.jsxs("div",{className:"text-xs text-muted",children:["Objects: ",t.result.objects.map(a=>`${a.type}:${a.name}`).join(", ")]}),t.result.validation.messages.length>0&&e.jsx("ul",{className:"space-y-0.5",children:t.result.validation.messages.map((a,d)=>e.jsxs("li",{className:`text-[10px] ${a.level==="error"?"text-red-500":a.level==="warning"?"text-yellow-600":"text-muted"}`,children:["[",a.level,"] ",a.message,a.objectName&&` (${a.objectName})`]},d))})]})]})})}const G=s.lazy(()=>L(()=>import("./graph-section-B-cObR6x.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])).then(o=>({default:o.GraphSection})));function A(){return e.jsx("div",{className:"flex items-center justify-center h-full text-muted text-xs",children:"Loading..."})}function U(){const[o,t]=s.useState("upload"),{objects:a,templates:d,loading:u,error:x,refresh:b}=E(),h=P(b),[c,m]=s.useState([]),[l,n]=s.useState([]),i=s.useCallback(async()=>{try{const v=await S.siebelGetGraph();m(v.objects),n(v.dependencies)}catch{}},[]);s.useEffect(()=>{i()},[i]);const g=s.useCallback(()=>{b(),i()},[b,i]);return u?e.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"Loading Siebel..."}):x?e.jsx("div",{className:"flex items-center justify-center h-full text-danger",children:x}):e.jsxs("div",{className:"h-full flex",children:[e.jsx(T,{activeSection:o,onSectionChange:t,objectCount:a.length}),e.jsxs("main",{className:"flex-1 min-w-0 overflow-hidden",children:[o==="upload"&&e.jsx($,{onUploaded:g}),o==="objects"&&e.jsx(M,{objects:a}),o==="graph"&&e.jsx(s.Suspense,{fallback:e.jsx(A,{}),children:e.jsx(G,{objects:c,dependencies:l})}),o==="generation"&&e.jsx(O,{templates:d,gen:h})]})]})}export{U as SiebelTab};
4
+ ... (truncated for display)`]})]}),t.prompt&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-xml",children:"Paste LLM-generated SIF XML"}),e.jsx("textarea",{id:"gen-xml",value:t.xml,onChange:a=>t.setXml(a.target.value),placeholder:'Paste the XML output from the LLM here (starting with <?xml version="1.0"...)',rows:8,className:"w-full px-3 py-2 text-xs font-mono rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsx("button",{onClick:t.finalize,disabled:!t.xml.trim()||t.loading,className:"mt-2 px-4 py-1.5 text-xs font-medium rounded-md bg-green-600 text-white hover:opacity-90 disabled:opacity-50 transition-opacity cursor-pointer disabled:cursor-not-allowed",children:t.loading?"Validating...":"Validate & Finalize"})]}),t.result&&e.jsxs("div",{className:`rounded-md border p-4 space-y-2 ${t.result.validation.status==="valid"?"border-green-500/30 bg-green-500/5":t.result.validation.status==="warnings"?"border-yellow-500/30 bg-yellow-500/5":"border-red-500/30 bg-red-500/5"}`,role:"status",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-sm font-bold ${t.result.validation.status==="valid"?"text-green-500":t.result.validation.status==="warnings"?"text-yellow-500":"text-red-500"}`,children:t.result.validation.status==="valid"?"Valid":t.result.validation.status==="warnings"?"Warnings":"Invalid"}),e.jsxs("span",{className:"text-xs text-muted",children:["Score: ",t.result.validation.score,"/100"]}),e.jsxs("span",{className:"text-xs text-muted",children:[t.result.metadata.objectCount," objects"]})]}),t.result.validation.status!=="invalid"&&e.jsx("button",{onClick:t.download,"aria-label":"Download generated SIF file",className:"px-3 py-1 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 cursor-pointer transition-opacity",children:"Download SIF"})]}),t.result.objects.length>0&&e.jsxs("div",{className:"text-xs text-muted",children:["Objects: ",t.result.objects.map(a=>`${a.type}:${a.name}`).join(", ")]}),t.result.validation.messages.length>0&&e.jsx("ul",{className:"space-y-0.5",children:t.result.validation.messages.map((a,d)=>e.jsxs("li",{className:`text-[10px] ${a.level==="error"?"text-red-500":a.level==="warning"?"text-yellow-600":"text-muted"}`,children:["[",a.level,"] ",a.message,a.objectName&&` (${a.objectName})`]},d))})]})]})})}const G=s.lazy(()=>L(()=>import("./graph-section-CsHifp70.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])).then(o=>({default:o.GraphSection})));function A(){return e.jsx("div",{className:"flex items-center justify-center h-full text-muted text-xs",children:"Loading..."})}function U(){const[o,t]=s.useState("upload"),{objects:a,templates:d,loading:u,error:x,refresh:b}=E(),h=P(b),[c,m]=s.useState([]),[l,n]=s.useState([]),i=s.useCallback(async()=>{try{const v=await S.siebelGetGraph();m(v.objects),n(v.dependencies)}catch{}},[]);s.useEffect(()=>{i()},[i]);const g=s.useCallback(()=>{b(),i()},[b,i]);return u?e.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"Loading Siebel..."}):x?e.jsx("div",{className:"flex items-center justify-center h-full text-danger",children:x}):e.jsxs("div",{className:"h-full flex",children:[e.jsx(T,{activeSection:o,onSectionChange:t,objectCount:a.length}),e.jsxs("main",{className:"flex-1 min-w-0 overflow-hidden",children:[o==="upload"&&e.jsx($,{onUploaded:g}),o==="objects"&&e.jsx(M,{objects:a}),o==="graph"&&e.jsx(s.Suspense,{fallback:e.jsx(A,{}),children:e.jsx(G,{objects:c,dependencies:l})}),o==="generation"&&e.jsx(O,{templates:d,gen:h})]})]})}export{U as SiebelTab};