claude-code-workflow 7.2.5 → 7.2.7

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 (235) hide show
  1. package/.claude/commands/workflow/analyze-with-file.md +11 -10
  2. package/.claude/skills/ccw-help/command.json +3 -3
  3. package/.claude/skills/ccw-help/index/all-commands.json +3 -3
  4. package/.claude/skills/ccw-help/index/by-category.json +3 -3
  5. package/.claude/skills/ccw-help/index/by-use-case.json +3 -3
  6. package/.claude/skills/skill-iter-tune/SKILL.md +382 -0
  7. package/.claude/skills/skill-iter-tune/phases/01-setup.md +144 -0
  8. package/.claude/skills/skill-iter-tune/phases/02-execute.md +292 -0
  9. package/.claude/skills/skill-iter-tune/phases/03-evaluate.md +312 -0
  10. package/.claude/skills/skill-iter-tune/phases/04-improve.md +186 -0
  11. package/.claude/skills/skill-iter-tune/phases/05-report.md +166 -0
  12. package/.claude/skills/skill-iter-tune/specs/evaluation-criteria.md +63 -0
  13. package/.claude/skills/skill-iter-tune/templates/eval-prompt.md +134 -0
  14. package/.claude/skills/skill-iter-tune/templates/execute-prompt.md +97 -0
  15. package/.claude/skills/team-roadmap-dev/SKILL.md +1 -1
  16. package/.claude/skills/team-roadmap-dev/roles/coordinator/role.md +1 -1
  17. package/.claude/skills/team-roadmap-dev/specs/team-config.json +1 -1
  18. package/ccw/dist/commands/install.d.ts.map +1 -1
  19. package/ccw/dist/commands/install.js +11 -9
  20. package/ccw/dist/commands/install.js.map +1 -1
  21. package/ccw/dist/core/routes/codexlens/config-handlers.d.ts.map +1 -1
  22. package/ccw/dist/core/routes/codexlens/config-handlers.js +4 -0
  23. package/ccw/dist/core/routes/codexlens/config-handlers.js.map +1 -1
  24. package/ccw/dist/mcp-server/index.js +85 -8
  25. package/ccw/dist/mcp-server/index.js.map +1 -1
  26. package/ccw/dist/tools/cli-executor-core.d.ts.map +1 -1
  27. package/ccw/dist/tools/cli-executor-core.js +0 -25
  28. package/ccw/dist/tools/cli-executor-core.js.map +1 -1
  29. package/ccw/dist/tools/cli-executor-state.d.ts.map +1 -1
  30. package/ccw/dist/tools/cli-executor-state.js +0 -31
  31. package/ccw/dist/tools/cli-executor-state.js.map +1 -1
  32. package/ccw/dist/tools/cli-history-store.d.ts.map +1 -1
  33. package/ccw/dist/tools/cli-history-store.js +1 -30
  34. package/ccw/dist/tools/cli-history-store.js.map +1 -1
  35. package/ccw/dist/tools/smart-search.d.ts +72 -1
  36. package/ccw/dist/tools/smart-search.d.ts.map +1 -1
  37. package/ccw/dist/tools/smart-search.js +726 -117
  38. package/ccw/dist/tools/smart-search.js.map +1 -1
  39. package/ccw/frontend/dist/assets/{AlertDialog-CFGtc76Y.js → AlertDialog-CSZq4WHZ.js} +2 -2
  40. package/ccw/frontend/dist/assets/{AlertDialog-CFGtc76Y.js.map → AlertDialog-CSZq4WHZ.js.map} +1 -1
  41. package/ccw/frontend/dist/assets/{AnalysisPage-Duxia_dG.js → AnalysisPage-DVDvLHqI.js} +2 -2
  42. package/ccw/frontend/dist/assets/{AnalysisPage-Duxia_dG.js.map → AnalysisPage-DVDvLHqI.js.map} +1 -1
  43. package/ccw/frontend/dist/assets/{ApiSettingsPage-CU9hesAE.js → ApiSettingsPage-D69j8mI6.js} +2 -2
  44. package/ccw/frontend/dist/assets/{ApiSettingsPage-CU9hesAE.js.map → ApiSettingsPage-D69j8mI6.js.map} +1 -1
  45. package/ccw/frontend/dist/assets/{CliModeToggle-DcdOFSvM.js → CliModeToggle-fF9xHeGR.js} +2 -2
  46. package/ccw/frontend/dist/assets/{CliModeToggle-DcdOFSvM.js.map → CliModeToggle-fF9xHeGR.js.map} +1 -1
  47. package/ccw/frontend/dist/assets/{CliSessionSharePage-oKN-GRIT.js → CliSessionSharePage-Ce8tOQNx.js} +2 -2
  48. package/ccw/frontend/dist/assets/{CliSessionSharePage-oKN-GRIT.js.map → CliSessionSharePage-Ce8tOQNx.js.map} +1 -1
  49. package/ccw/frontend/dist/assets/{CliViewerPage-_wUoHaY-.js → CliViewerPage-Bsp1zmfD.js} +2 -2
  50. package/ccw/frontend/dist/assets/{CliViewerPage-_wUoHaY-.js.map → CliViewerPage-Bsp1zmfD.js.map} +1 -1
  51. package/ccw/frontend/dist/assets/{CodexLensManagerPage-ClPNashJ.js → CodexLensManagerPage-DUMzbrr9.js} +9 -9
  52. package/ccw/frontend/dist/assets/CodexLensManagerPage-DUMzbrr9.js.map +1 -0
  53. package/ccw/frontend/dist/assets/{Collapsible-Dladh9Eu.js → Collapsible-I5pixbHb.js} +2 -2
  54. package/ccw/frontend/dist/assets/{Collapsible-Dladh9Eu.js.map → Collapsible-I5pixbHb.js.map} +1 -1
  55. package/ccw/frontend/dist/assets/{CommandsManagerPage-B6DBb_Ew.js → CommandsManagerPage-BH2xukdx.js} +2 -2
  56. package/ccw/frontend/dist/assets/{CommandsManagerPage-B6DBb_Ew.js.map → CommandsManagerPage-BH2xukdx.js.map} +1 -1
  57. package/ccw/frontend/dist/assets/{DeepWikiPage-CDA3xm3R.js → DeepWikiPage-D41ccWzY.js} +2 -2
  58. package/ccw/frontend/dist/assets/{DeepWikiPage-CDA3xm3R.js.map → DeepWikiPage-D41ccWzY.js.map} +1 -1
  59. package/ccw/frontend/dist/assets/{EndpointsPage-Bu7iU0Wy.js → EndpointsPage-5a8jfEWN.js} +2 -2
  60. package/ccw/frontend/dist/assets/{EndpointsPage-Bu7iU0Wy.js.map → EndpointsPage-5a8jfEWN.js.map} +1 -1
  61. package/ccw/frontend/dist/assets/{ExplorerPage-xim2cboZ.js → ExplorerPage-YCqIOu1v.js} +2 -2
  62. package/ccw/frontend/dist/assets/{ExplorerPage-xim2cboZ.js.map → ExplorerPage-YCqIOu1v.js.map} +1 -1
  63. package/ccw/frontend/dist/assets/{FixSessionPage-BTFYoFQF.js → FixSessionPage-wK1s4kbo.js} +2 -2
  64. package/ccw/frontend/dist/assets/{FixSessionPage-BTFYoFQF.js.map → FixSessionPage-wK1s4kbo.js.map} +1 -1
  65. package/ccw/frontend/dist/assets/{FloatingFileBrowser-B30ANzTJ.js → FloatingFileBrowser-B1U6uk_5.js} +2 -2
  66. package/ccw/frontend/dist/assets/{FloatingFileBrowser-B30ANzTJ.js.map → FloatingFileBrowser-B1U6uk_5.js.map} +1 -1
  67. package/ccw/frontend/dist/assets/{FloatingPanel-Ds84B7Ob.js → FloatingPanel-D51p5jNy.js} +2 -2
  68. package/ccw/frontend/dist/assets/{FloatingPanel-Ds84B7Ob.js.map → FloatingPanel-D51p5jNy.js.map} +1 -1
  69. package/ccw/frontend/dist/assets/{GraphExplorerPage-DJ4YnFOQ.js → GraphExplorerPage-DpIWrpWH.js} +2 -2
  70. package/ccw/frontend/dist/assets/{GraphExplorerPage-DJ4YnFOQ.js.map → GraphExplorerPage-DpIWrpWH.js.map} +1 -1
  71. package/ccw/frontend/dist/assets/{HistoryPage-rzLVsw11.js → HistoryPage-C09lyJGN.js} +2 -2
  72. package/ccw/frontend/dist/assets/{HistoryPage-rzLVsw11.js.map → HistoryPage-C09lyJGN.js.map} +1 -1
  73. package/ccw/frontend/dist/assets/{HookManagerPage-DizO_dCP.js → HookManagerPage-CFBe8F_G.js} +2 -2
  74. package/ccw/frontend/dist/assets/{HookManagerPage-DizO_dCP.js.map → HookManagerPage-CFBe8F_G.js.map} +1 -1
  75. package/ccw/frontend/dist/assets/{InstallationsPage-BFamuE4y.js → InstallationsPage-qt7NxnsB.js} +2 -2
  76. package/ccw/frontend/dist/assets/{InstallationsPage-BFamuE4y.js.map → InstallationsPage-qt7NxnsB.js.map} +1 -1
  77. package/ccw/frontend/dist/assets/{IssueHubPage-DHwQWuUc.js → IssueHubPage-CHol1-Ap.js} +2 -2
  78. package/ccw/frontend/dist/assets/{IssueHubPage-DHwQWuUc.js.map → IssueHubPage-CHol1-Ap.js.map} +1 -1
  79. package/ccw/frontend/dist/assets/{LiteTasksPage-DMDkG7pi.js → LiteTasksPage-jH00SLnZ.js} +2 -2
  80. package/ccw/frontend/dist/assets/{LiteTasksPage-DMDkG7pi.js.map → LiteTasksPage-jH00SLnZ.js.map} +1 -1
  81. package/ccw/frontend/dist/assets/{McpManagerPage-CS2v_1OG.js → McpManagerPage-BS-HgeQJ.js} +11 -11
  82. package/ccw/frontend/dist/assets/McpManagerPage-BS-HgeQJ.js.map +1 -0
  83. package/ccw/frontend/dist/assets/{MemoryPage-DhYPE-VC.js → MemoryPage-1UahrmRX.js} +2 -2
  84. package/ccw/frontend/dist/assets/{MemoryPage-DhYPE-VC.js.map → MemoryPage-1UahrmRX.js.map} +1 -1
  85. package/ccw/frontend/dist/assets/{NotFoundPage-BLmC7-ot.js → NotFoundPage-5FVm_IkS.js} +2 -2
  86. package/ccw/frontend/dist/assets/{NotFoundPage-BLmC7-ot.js.map → NotFoundPage-5FVm_IkS.js.map} +1 -1
  87. package/ccw/frontend/dist/assets/{OrchestratorPage-1jzSUFZW.js → OrchestratorPage-ThBG24Gg.js} +2 -2
  88. package/ccw/frontend/dist/assets/{OrchestratorPage-1jzSUFZW.js.map → OrchestratorPage-ThBG24Gg.js.map} +1 -1
  89. package/ccw/frontend/dist/assets/{ProjectOverviewPage-gWuAj-Cn.js → ProjectOverviewPage-CrmW0IxI.js} +2 -2
  90. package/ccw/frontend/dist/assets/{ProjectOverviewPage-gWuAj-Cn.js.map → ProjectOverviewPage-CrmW0IxI.js.map} +1 -1
  91. package/ccw/frontend/dist/assets/{PromptHistoryPage-q7ySVNHM.js → PromptHistoryPage-1cCGwS3s.js} +2 -2
  92. package/ccw/frontend/dist/assets/{PromptHistoryPage-q7ySVNHM.js.map → PromptHistoryPage-1cCGwS3s.js.map} +1 -1
  93. package/ccw/frontend/dist/assets/{ReviewSessionPage-DX1uT_nH.js → ReviewSessionPage-DxiEc9HK.js} +2 -2
  94. package/ccw/frontend/dist/assets/{ReviewSessionPage-DX1uT_nH.js.map → ReviewSessionPage-DxiEc9HK.js.map} +1 -1
  95. package/ccw/frontend/dist/assets/{RulesManagerPage-Bg6T5W-W.js → RulesManagerPage-BpplliZF.js} +2 -2
  96. package/ccw/frontend/dist/assets/{RulesManagerPage-Bg6T5W-W.js.map → RulesManagerPage-BpplliZF.js.map} +1 -1
  97. package/ccw/frontend/dist/assets/{SessionDetailPage-C_ig6JSh.js → SessionDetailPage-crDIiysh.js} +2 -2
  98. package/ccw/frontend/dist/assets/{SessionDetailPage-C_ig6JSh.js.map → SessionDetailPage-crDIiysh.js.map} +1 -1
  99. package/ccw/frontend/dist/assets/{SessionsPage-BENFqFDn.js → SessionsPage-DThweYY8.js} +2 -2
  100. package/ccw/frontend/dist/assets/{SessionsPage-BENFqFDn.js.map → SessionsPage-DThweYY8.js.map} +1 -1
  101. package/ccw/frontend/dist/assets/{SettingsPage-2c-oTxfz.js → SettingsPage-OCdOz5-z.js} +4 -4
  102. package/ccw/frontend/dist/assets/{SettingsPage-2c-oTxfz.js.map → SettingsPage-OCdOz5-z.js.map} +1 -1
  103. package/ccw/frontend/dist/assets/{SkillsManagerPage-GLo6DXnt.js → SkillsManagerPage-BJd3bK1G.js} +2 -2
  104. package/ccw/frontend/dist/assets/{SkillsManagerPage-GLo6DXnt.js.map → SkillsManagerPage-BJd3bK1G.js.map} +1 -1
  105. package/ccw/frontend/dist/assets/{SpecsSettingsPage-CRqMV90p.js → SpecsSettingsPage-BAWL2cpO.js} +2 -2
  106. package/ccw/frontend/dist/assets/{SpecsSettingsPage-CRqMV90p.js.map → SpecsSettingsPage-BAWL2cpO.js.map} +1 -1
  107. package/ccw/frontend/dist/assets/{Switch-vlMavMRD.js → Switch-w0I3JCcC.js} +2 -2
  108. package/ccw/frontend/dist/assets/{Switch-vlMavMRD.js.map → Switch-w0I3JCcC.js.map} +1 -1
  109. package/ccw/frontend/dist/assets/{TabsNavigation-CLKz7pWP.js → TabsNavigation-jhUge9YV.js} +2 -2
  110. package/ccw/frontend/dist/assets/{TabsNavigation-CLKz7pWP.js.map → TabsNavigation-jhUge9YV.js.map} +1 -1
  111. package/ccw/frontend/dist/assets/{TaskDrawer-BAFvNqF8.js → TaskDrawer-APWpZulm.js} +2 -2
  112. package/ccw/frontend/dist/assets/{TaskDrawer-BAFvNqF8.js.map → TaskDrawer-APWpZulm.js.map} +1 -1
  113. package/ccw/frontend/dist/assets/{TeamPage-C2IsDkAv.js → TeamPage-8OnLsAfJ.js} +2 -2
  114. package/ccw/frontend/dist/assets/{TeamPage-C2IsDkAv.js.map → TeamPage-8OnLsAfJ.js.map} +1 -1
  115. package/ccw/frontend/dist/assets/{TerminalDashboardPage-mgS-iKDm.js → TerminalDashboardPage-Be1hcN4p.js} +2 -2
  116. package/ccw/frontend/dist/assets/{TerminalDashboardPage-mgS-iKDm.js.map → TerminalDashboardPage-Be1hcN4p.js.map} +1 -1
  117. package/ccw/frontend/dist/assets/{archive-CxxK_YIp.js → archive-Bo1tC9yo.js} +2 -2
  118. package/ccw/frontend/dist/assets/{archive-CxxK_YIp.js.map → archive-Bo1tC9yo.js.map} +1 -1
  119. package/ccw/frontend/dist/assets/{archive-restore-DZsrBaeG.js → archive-restore-DYx41yLJ.js} +2 -2
  120. package/ccw/frontend/dist/assets/{archive-restore-DZsrBaeG.js.map → archive-restore-DYx41yLJ.js.map} +1 -1
  121. package/ccw/frontend/dist/assets/{arrow-right-BotRHOhr.js → arrow-right-C6pOqWF1.js} +2 -2
  122. package/ccw/frontend/dist/assets/{arrow-right-BotRHOhr.js.map → arrow-right-C6pOqWF1.js.map} +1 -1
  123. package/ccw/frontend/dist/assets/{bookmark-plus-C0MWZ3S9.js → bookmark-plus-4Qpa6hMJ.js} +2 -2
  124. package/ccw/frontend/dist/assets/{bookmark-plus-C0MWZ3S9.js.map → bookmark-plus-4Qpa6hMJ.js.map} +1 -1
  125. package/ccw/frontend/dist/assets/{bot-BcHFJXqD.js → bot-HXJTmx8r.js} +2 -2
  126. package/ccw/frontend/dist/assets/{bot-BcHFJXqD.js.map → bot-HXJTmx8r.js.map} +1 -1
  127. package/ccw/frontend/dist/assets/{braces-D_p0IZhP.js → braces-Dj2IdY7I.js} +2 -2
  128. package/ccw/frontend/dist/assets/{braces-D_p0IZhP.js.map → braces-Dj2IdY7I.js.map} +1 -1
  129. package/ccw/frontend/dist/assets/{circle-stop-Bt634NUt.js → circle-stop-M29TJKHc.js} +2 -2
  130. package/ccw/frontend/dist/assets/{circle-stop-Bt634NUt.js.map → circle-stop-M29TJKHc.js.map} +1 -1
  131. package/ccw/frontend/dist/assets/{cpu-DjeGKtvT.js → cpu-DX15mzMT.js} +2 -2
  132. package/ccw/frontend/dist/assets/{cpu-DjeGKtvT.js.map → cpu-DX15mzMT.js.map} +1 -1
  133. package/ccw/frontend/dist/assets/{ellipsis-vertical-BmNPuatq.js → ellipsis-vertical-Fs6bysWx.js} +2 -2
  134. package/ccw/frontend/dist/assets/{ellipsis-vertical-BmNPuatq.js.map → ellipsis-vertical-Fs6bysWx.js.map} +1 -1
  135. package/ccw/frontend/dist/assets/{eye-B0-xkP67.js → eye-D6BRlJ1r.js} +2 -2
  136. package/ccw/frontend/dist/assets/{eye-B0-xkP67.js.map → eye-D6BRlJ1r.js.map} +1 -1
  137. package/ccw/frontend/dist/assets/{eye-off-Bz0Fkli3.js → eye-off-DjbIj5iN.js} +2 -2
  138. package/ccw/frontend/dist/assets/{eye-off-Bz0Fkli3.js.map → eye-off-DjbIj5iN.js.map} +1 -1
  139. package/ccw/frontend/dist/assets/{file-json-PUAS4vBm.js → file-json-kg4Lid-H.js} +2 -2
  140. package/ccw/frontend/dist/assets/{file-json-PUAS4vBm.js.map → file-json-kg4Lid-H.js.map} +1 -1
  141. package/ccw/frontend/dist/assets/{file-text-BMeW5-Sb.js → file-text-BMy5pXNV.js} +2 -2
  142. package/ccw/frontend/dist/assets/{file-text-BMeW5-Sb.js.map → file-text-BMy5pXNV.js.map} +1 -1
  143. package/ccw/frontend/dist/assets/{filter-B4wgMvwi.js → filter-BTN-lUUb.js} +2 -2
  144. package/ccw/frontend/dist/assets/{filter-B4wgMvwi.js.map → filter-BTN-lUUb.js.map} +1 -1
  145. package/ccw/frontend/dist/assets/{folder-BSHjjjND.js → folder-ChYtty7V.js} +2 -2
  146. package/ccw/frontend/dist/assets/{folder-BSHjjjND.js.map → folder-ChYtty7V.js.map} +1 -1
  147. package/ccw/frontend/dist/assets/{gauge-7VRNEl22.js → gauge-C0VJbjRb.js} +2 -2
  148. package/ccw/frontend/dist/assets/{gauge-7VRNEl22.js.map → gauge-C0VJbjRb.js.map} +1 -1
  149. package/ccw/frontend/dist/assets/{globe-PvVHBjbW.js → globe-DbNfDXnv.js} +2 -2
  150. package/ccw/frontend/dist/assets/{globe-PvVHBjbW.js.map → globe-DbNfDXnv.js.map} +1 -1
  151. package/ccw/frontend/dist/assets/{grid-3x3-CsmmDlhN.js → grid-3x3-xWcpBNxo.js} +2 -2
  152. package/ccw/frontend/dist/assets/{grid-3x3-CsmmDlhN.js.map → grid-3x3-xWcpBNxo.js.map} +1 -1
  153. package/ccw/frontend/dist/assets/{hard-drive-D88EZgTY.js → hard-drive-BTACzgUO.js} +2 -2
  154. package/ccw/frontend/dist/assets/{hard-drive-D88EZgTY.js.map → hard-drive-BTACzgUO.js.map} +1 -1
  155. package/ccw/frontend/dist/assets/{hash-CZpNRWqt.js → hash-B0dYlmyB.js} +2 -2
  156. package/ccw/frontend/dist/assets/{hash-CZpNRWqt.js.map → hash-B0dYlmyB.js.map} +1 -1
  157. package/ccw/frontend/dist/assets/{history-DxN1mopa.js → history-CRRLu6ck.js} +2 -2
  158. package/ccw/frontend/dist/assets/{history-DxN1mopa.js.map → history-CRRLu6ck.js.map} +1 -1
  159. package/ccw/frontend/dist/assets/{index-BzGEkwIf.js → index-BJIIo0B3.js} +2 -2
  160. package/ccw/frontend/dist/assets/{index-BzGEkwIf.js.map → index-BJIIo0B3.js.map} +1 -1
  161. package/ccw/frontend/dist/assets/{index-DlcRFzFq.js → index-BP-D3Wv6.js} +2 -2
  162. package/ccw/frontend/dist/assets/{index-DlcRFzFq.js.map → index-BP-D3Wv6.js.map} +1 -1
  163. package/ccw/frontend/dist/assets/{index-BUiq2PUK.js → index-B_QzEioU.js} +2 -2
  164. package/ccw/frontend/dist/assets/{index-BUiq2PUK.js.map → index-B_QzEioU.js.map} +1 -1
  165. package/ccw/frontend/dist/assets/{index-C04xeBGC.js → index-BpoRYgiq.js} +3 -3
  166. package/ccw/frontend/dist/assets/{index-C04xeBGC.js.map → index-BpoRYgiq.js.map} +1 -1
  167. package/ccw/frontend/dist/assets/{index-CIoWWkDn.js → index-CeESlrZb.js} +8 -8
  168. package/ccw/frontend/dist/assets/{index-CIoWWkDn.js.map → index-CeESlrZb.js.map} +1 -1
  169. package/ccw/frontend/dist/assets/{index-bSgtHHOF.js → index-DzTbMyaS.js} +4 -4
  170. package/ccw/frontend/dist/assets/{index-bSgtHHOF.js.map → index-DzTbMyaS.js.map} +1 -1
  171. package/ccw/frontend/dist/assets/{layout-grid-BZqfuNG0.js → layout-grid-ZN26YcTM.js} +2 -2
  172. package/ccw/frontend/dist/assets/{layout-grid-BZqfuNG0.js.map → layout-grid-ZN26YcTM.js.map} +1 -1
  173. package/ccw/frontend/dist/assets/{lightbulb-DqJ4OHRL.js → lightbulb-BHrwx9j6.js} +2 -2
  174. package/ccw/frontend/dist/assets/{lightbulb-DqJ4OHRL.js.map → lightbulb-BHrwx9j6.js.map} +1 -1
  175. package/ccw/frontend/dist/assets/{link-2-Bq7fLkC9.js → link-2-zZRu2j4G.js} +2 -2
  176. package/ccw/frontend/dist/assets/{link-2-Bq7fLkC9.js.map → link-2-zZRu2j4G.js.map} +1 -1
  177. package/ccw/frontend/dist/assets/{link-dSLYjCIG.js → link-8lz-HgnZ.js} +2 -2
  178. package/ccw/frontend/dist/assets/{link-dSLYjCIG.js.map → link-8lz-HgnZ.js.map} +1 -1
  179. package/ccw/frontend/dist/assets/{list-Bm_CnR56.js → list-DlablIjt.js} +2 -2
  180. package/ccw/frontend/dist/assets/{list-Bm_CnR56.js.map → list-DlablIjt.js.map} +1 -1
  181. package/ccw/frontend/dist/assets/{map-pin-B5TELa0z.js → map-pin-JAsCUplr.js} +2 -2
  182. package/ccw/frontend/dist/assets/{map-pin-B5TELa0z.js.map → map-pin-JAsCUplr.js.map} +1 -1
  183. package/ccw/frontend/dist/assets/{messages-square-B9sWItdK.js → messages-square-D0iSFb2Y.js} +2 -2
  184. package/ccw/frontend/dist/assets/{messages-square-B9sWItdK.js.map → messages-square-D0iSFb2Y.js.map} +1 -1
  185. package/ccw/frontend/dist/assets/{minimize-2-Z1MYs_Tp.js → minimize-2-BJmkU9CE.js} +2 -2
  186. package/ccw/frontend/dist/assets/{minimize-2-Z1MYs_Tp.js.map → minimize-2-BJmkU9CE.js.map} +1 -1
  187. package/ccw/frontend/dist/assets/{package-EEv4N_Qk.js → package-DYrbBCxk.js} +2 -2
  188. package/ccw/frontend/dist/assets/{package-EEv4N_Qk.js.map → package-DYrbBCxk.js.map} +1 -1
  189. package/ccw/frontend/dist/assets/{plug-CEkvvYXh.js → plug-VG7-23M-.js} +2 -2
  190. package/ccw/frontend/dist/assets/{plug-CEkvvYXh.js.map → plug-VG7-23M-.js.map} +1 -1
  191. package/ccw/frontend/dist/assets/{power-B6Rod0u_.js → power-zPFYNx7u.js} +2 -2
  192. package/ccw/frontend/dist/assets/{power-B6Rod0u_.js.map → power-zPFYNx7u.js.map} +1 -1
  193. package/ccw/frontend/dist/assets/{save-DULWrB2g.js → save-D4XQY9i9.js} +2 -2
  194. package/ccw/frontend/dist/assets/{save-DULWrB2g.js.map → save-D4XQY9i9.js.map} +1 -1
  195. package/ccw/frontend/dist/assets/{send-C4z974WG.js → send-ClSnDjj-.js} +2 -2
  196. package/ccw/frontend/dist/assets/{send-C4z974WG.js.map → send-ClSnDjj-.js.map} +1 -1
  197. package/ccw/frontend/dist/assets/{square-check-big-CqEEw-V0.js → square-check-big-Bffh_MFc.js} +2 -2
  198. package/ccw/frontend/dist/assets/{square-check-big-CqEEw-V0.js.map → square-check-big-Bffh_MFc.js.map} +1 -1
  199. package/ccw/frontend/dist/assets/{square-pen-D-4BrMtQ.js → square-pen-DsOvAvME.js} +2 -2
  200. package/ccw/frontend/dist/assets/{square-pen-D-4BrMtQ.js.map → square-pen-DsOvAvME.js.map} +1 -1
  201. package/ccw/frontend/dist/assets/{star-CDVVM69o.js → star-TLJjvoy2.js} +2 -2
  202. package/ccw/frontend/dist/assets/{star-CDVVM69o.js.map → star-TLJjvoy2.js.map} +1 -1
  203. package/ccw/frontend/dist/assets/{style-CumJ7XC8.js → style-BXKXgpOY.js} +2 -2
  204. package/ccw/frontend/dist/assets/{style-CumJ7XC8.js.map → style-BXKXgpOY.js.map} +1 -1
  205. package/ccw/frontend/dist/assets/{target-Dr9SuV1Y.js → target-FDuAB6SF.js} +2 -2
  206. package/ccw/frontend/dist/assets/{target-Dr9SuV1Y.js.map → target-FDuAB6SF.js.map} +1 -1
  207. package/ccw/frontend/dist/assets/{test-tube-DzDRKk8F.js → test-tube-B9vj-Im8.js} +2 -2
  208. package/ccw/frontend/dist/assets/{test-tube-DzDRKk8F.js.map → test-tube-B9vj-Im8.js.map} +1 -1
  209. package/ccw/frontend/dist/assets/{upload-CihSmIM7.js → upload-CHgTrVN5.js} +2 -2
  210. package/ccw/frontend/dist/assets/{upload-CihSmIM7.js.map → upload-CHgTrVN5.js.map} +1 -1
  211. package/ccw/frontend/dist/assets/{useApiSettings-CevxWX2z.js → useApiSettings-XsHrqf-L.js} +2 -2
  212. package/ccw/frontend/dist/assets/{useApiSettings-CevxWX2z.js.map → useApiSettings-XsHrqf-L.js.map} +1 -1
  213. package/ccw/frontend/dist/assets/{useCli-jVaF89uU.js → useCli-DOlWtux5.js} +2 -2
  214. package/ccw/frontend/dist/assets/{useCli-jVaF89uU.js.map → useCli-DOlWtux5.js.map} +1 -1
  215. package/ccw/frontend/dist/assets/{useCommands-D4uGmNpF.js → useCommands-DazCajiX.js} +2 -2
  216. package/ccw/frontend/dist/assets/{useCommands-D4uGmNpF.js.map → useCommands-DazCajiX.js.map} +1 -1
  217. package/ccw/frontend/dist/assets/{useDebounce-BEYmuZYP.js → useDebounce-Cah-bua6.js} +2 -2
  218. package/ccw/frontend/dist/assets/{useDebounce-BEYmuZYP.js.map → useDebounce-Cah-bua6.js.map} +1 -1
  219. package/ccw/frontend/dist/assets/{useFileExplorer-DEv0DVy7.js → useFileExplorer-B9SCPhhl.js} +2 -2
  220. package/ccw/frontend/dist/assets/{useFileExplorer-DEv0DVy7.js.map → useFileExplorer-B9SCPhhl.js.map} +1 -1
  221. package/ccw/frontend/dist/assets/{useLocale-BRJreqvl.js → useLocale-CmG6pxZe.js} +2 -2
  222. package/ccw/frontend/dist/assets/{useLocale-BRJreqvl.js.map → useLocale-CmG6pxZe.js.map} +1 -1
  223. package/ccw/frontend/dist/assets/{useSkills-lnfeXe9l.js → useSkills-DvEJ0JOv.js} +3 -3
  224. package/ccw/frontend/dist/assets/{useSkills-lnfeXe9l.js.map → useSkills-DvEJ0JOv.js.map} +1 -1
  225. package/ccw/frontend/dist/assets/{useSystemSettings-PlxVdbXI.js → useSystemSettings-BDpwSa04.js} +2 -2
  226. package/ccw/frontend/dist/assets/{useSystemSettings-PlxVdbXI.js.map → useSystemSettings-BDpwSa04.js.map} +1 -1
  227. package/ccw/frontend/dist/assets/{wand-sparkles-BbqUxeEg.js → wand-sparkles-T2KGCRiy.js} +2 -2
  228. package/ccw/frontend/dist/assets/{wand-sparkles-BbqUxeEg.js.map → wand-sparkles-T2KGCRiy.js.map} +1 -1
  229. package/ccw/frontend/dist/index.html +1 -1
  230. package/codex-lens/src/codexlens/cli/commands.py +12 -1
  231. package/codex-lens/src/codexlens/config.py +12 -0
  232. package/codex-lens/src/codexlens/env_config.py +1 -0
  233. package/package.json +1 -1
  234. package/ccw/frontend/dist/assets/CodexLensManagerPage-ClPNashJ.js.map +0 -1
  235. package/ccw/frontend/dist/assets/McpManagerPage-CS2v_1OG.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import{O as Pe,aF as te,a9 as xe,aa as ue,ab as ge,aH as se,cU as Os,cV as As,cW as dt,cX as mt,cY as xt,cZ as ut,c_ as Je,c$ as Ye,d0 as Ks,d1 as pt,d2 as ht,u as G,r as h,j as e,c as H,al as Ve,d3 as de,d4 as me,x as ts,y as as,z as ns,A as rs,e as D,aq as He,ar as _e,as as $e,at as Re,au as pe,I as X,aP as gt,B as I,G as cs,T as Me,a7 as Ie,d5 as zs,C as Z,d6 as qe,cy as Is,ap as os,S as be,aw as Qe,ao as Qs,bq as Ls,aU as Le,an as Ke,d7 as ft,d8 as Vs,d9 as jt,da as vt,db as Ze,dc as Xe,ck as Hs,b as Ae,am as ls,af as yt,dd as Nt,de as bt,df as ks,dg as wt,dh as Ct,U as _s,bu as Ts,N as Te,di as St,a0 as kt,Z as Tt,M as $s,K as Mt,k as Pt,m as Ft,bf as Ms,J as Et,dj as Rs,l as Dt,b5 as qt,R as es,dk as Ot,dl as At,dm as Kt,dn as zt,dp as It}from"./index-bSgtHHOF.js";import{A as is,a as ds,b as ms,c as xs,d as us,e as ps,f as hs,g as gs,h as Qt}from"./AlertDialog-CFGtc76Y.js";import{G as fe}from"./globe-PvVHBjbW.js";import{E as fs}from"./eye-off-Bz0Fkli3.js";import{E as js}from"./eye-B0-xkP67.js";import{L as Ps,C as Lt}from"./CliModeToggle-DcdOFSvM.js";import{L as Ws}from"./link-dSLYjCIG.js";import{P as ke,a as ss}from"./power-B6Rod0u_.js";import{F as Vt}from"./FloatingFileBrowser-B30ANzTJ.js";import{F as ye}from"./folder-BSHjjjND.js";import{H as Ht}from"./hard-drive-D88EZgTY.js";import{S as _t}from"./save-DULWrB2g.js";import{M as $t}from"./messages-square-B9sWItdK.js";import{F as Rt}from"./file-text-BMeW5-Sb.js";import{F as Wt}from"./filter-B4wgMvwi.js";import{A as Ut}from"./arrow-right-BotRHOhr.js";import{f as Bt}from"./formatDistanceToNow-DXTjigy3.js";import{T as Gt}from"./TabsNavigation-CLKz7pWP.js";import{B as Jt}from"./bookmark-plus-C0MWZ3S9.js";import{S as Yt}from"./square-pen-D-4BrMtQ.js";import"./cpu-DjeGKtvT.js";import"./FloatingPanel-Ds84B7Ob.js";import"./useFileExplorer-DEv0DVy7.js";/**
1
+ import{O as Pe,aF as ae,a9 as xe,aa as pe,ab as fe,aH as te,cU as Os,cV as As,cW as dt,cX as mt,cY as xt,cZ as pt,c_ as Je,c$ as Ye,d0 as Ks,d1 as ut,d2 as ht,u as G,r as h,j as e,c as _,al as Ve,d3 as de,d4 as me,x as ts,y as as,z as ns,A as rs,e as D,aq as He,ar as _e,as as $e,at as Re,au as he,I as X,aP as gt,B as I,G as cs,T as Me,a7 as Ie,d5 as zs,C as Z,d6 as qe,cy as Is,ap as os,S as we,aw as Qe,ao as Qs,bq as Ls,aU as Le,an as Ke,d7 as ft,d8 as Vs,d9 as jt,da as vt,db as Ze,dc as Xe,ck as Hs,b as Ae,am as ls,af as yt,dd as Nt,de as bt,df as ks,dg as wt,dh as Ct,U as _s,bu as Ts,N as Te,di as St,a0 as kt,Z as Tt,M as $s,K as Mt,k as Pt,m as Ft,bf as Ms,J as Et,dj as Rs,l as Dt,b5 as qt,R as es,dk as Ot,dl as At,dm as Kt,dn as zt,dp as It}from"./index-DzTbMyaS.js";import{A as is,a as ds,b as ms,c as xs,d as ps,e as us,f as hs,g as gs,h as Qt}from"./AlertDialog-CSZq4WHZ.js";import{G as je}from"./globe-DbNfDXnv.js";import{E as fs}from"./eye-off-DjbIj5iN.js";import{E as js}from"./eye-D6BRlJ1r.js";import{L as Ps,C as Lt}from"./CliModeToggle-fF9xHeGR.js";import{L as Ws}from"./link-8lz-HgnZ.js";import{P as ke,a as ss}from"./power-zPFYNx7u.js";import{F as Vt}from"./FloatingFileBrowser-B1U6uk_5.js";import{F as Ne}from"./folder-ChYtty7V.js";import{H as Ht}from"./hard-drive-BTACzgUO.js";import{S as _t}from"./save-D4XQY9i9.js";import{M as $t}from"./messages-square-D0iSFb2Y.js";import{F as Rt}from"./file-text-BMy5pXNV.js";import{F as Wt}from"./filter-BTN-lUUb.js";import{A as Ut}from"./arrow-right-C6pOqWF1.js";import{f as Bt}from"./formatDistanceToNow-DXTjigy3.js";import{T as Gt}from"./TabsNavigation-jhUge9YV.js";import{B as Jt}from"./bookmark-plus-4Qpa6hMJ.js";import{S as Yt}from"./square-pen-DsOvAvME.js";import"./cpu-DX15mzMT.js";import"./FloatingPanel-D51p5jNy.js";import"./useFileExplorer-B9SCPhhl.js";/**
2
2
  * @license lucide-react v0.460.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -28,11 +28,11 @@ import{O as Pe,aF as te,a9 as xe,aa as ue,ab as ge,aH as se,cU as Os,cV as As,cW
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const ta=Pe("SearchCode",[["path",{d:"m13 13.5 2-2.5-2-2.5",key:"1rvxrh"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}],["path",{d:"M9 8.5 7 11l2 2.5",key:"6ffwbx"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),B={all:["mcpServers"],lists:()=>[...B.all,"list"],list:s=>[...B.lists(),s]},he={all:["mcpTemplates"],lists:()=>[...he.all,"list"],list:s=>[...he.lists(),s],search:s=>[...he.all,"search",s],categories:()=>[...he.all,"categories"]},Oe={all:["projects"],list:()=>[...Oe.all,"list"],servers:s=>[...Oe.all,"servers",...s??[]]},ze=120*1e3;function Us(s={}){var b,v,k;const{scope:t,staleTime:a=ze,enabled:o=!0}=s,c=te(),n=xe(ue),w=o&&!!n,p=ge({queryKey:B.list(t),queryFn:()=>Ks(n),staleTime:a,enabled:w,retry:2}),f=((b=p.data)==null?void 0:b.project)??[],d=((v=p.data)==null?void 0:v.global)??[],S=((k=p.data)==null?void 0:k.conflicts)??[],m=t==="project"?f:t==="global"?d:[...f,...d],g=m.filter(j=>j.enabled),y=async()=>{await p.refetch()},u=async()=>{await c.invalidateQueries({queryKey:B.all})};return{servers:m,projectServers:f,globalServers:d,conflicts:S,totalCount:m.length,enabledCount:g.length,isLoading:p.isLoading,isFetching:p.isFetching,error:p.error,refetch:y,invalidate:u}}function aa(){const s=te(),t=xe(ue),a=se({mutationFn:({serverName:o,config:c,configType:n})=>Os(o,c,{projectPath:t??void 0,configType:n}),onSettled:()=>{s.invalidateQueries({queryKey:B.all})}});return{updateServer:(o,c,n)=>a.mutateAsync({serverName:o,config:c,configType:n}),isUpdating:a.isPending,error:a.error}}function na(){const s=te(),t=xe(ue),a=se({mutationFn:({server:o,configType:c})=>As(o,{projectPath:t??void 0,configType:c}),onSettled:()=>{s.invalidateQueries({queryKey:B.all})}});return{createServer:(o,c)=>a.mutateAsync({server:o,configType:c}),isCreating:a.isPending,error:a.error}}function ra(){const s=te(),t=xe(ue),a=se({mutationFn:({serverName:o,scope:c})=>dt(o,c,{projectPath:t??void 0}),onSettled:()=>{s.invalidateQueries({queryKey:B.all}),s.invalidateQueries({queryKey:["ccwMcpConfig"]})}});return{deleteServer:(o,c)=>a.mutateAsync({serverName:o,scope:c}),isDeleting:a.isPending,error:a.error}}function ca(){const s=te(),t=xe(ue),a=se({mutationFn:({serverName:o,enabled:c})=>mt(o,c,{projectPath:t??void 0}),onMutate:async({serverName:o,enabled:c})=>{await s.cancelQueries({queryKey:B.all});const n=s.getQueryData(B.list());return s.setQueryData(B.list(),w=>{if(!w)return w;const p=f=>f.map(d=>d.name===o?{...d,enabled:c}:d);return{project:p(w.project),global:p(w.global),conflicts:w.conflicts??[]}}),{previousServers:n}},onError:(o,c,n)=>{n!=null&&n.previousServers&&s.setQueryData(B.list(),n.previousServers)},onSettled:()=>{s.invalidateQueries({queryKey:B.all})}});return{toggleServer:(o,c)=>a.mutateAsync({serverName:o,enabled:c}),isToggling:a.isPending,error:a.error}}function Bs(){const s=aa(),t=na(),a=ra(),o=ca();return{updateServer:s.updateServer,isUpdating:s.isUpdating,createServer:t.createServer,isCreating:t.isCreating,deleteServer:a.deleteServer,isDeleting:a.isDeleting,toggleServer:o.toggleServer,isToggling:o.isToggling,isMutating:s.isUpdating||t.isCreating||a.isDeleting||o.isToggling}}const oa=300*1e3;function la(s={}){var f;const{category:t,staleTime:a=oa,enabled:o=!0}=s,c=te(),n=ge({queryKey:he.list(t),queryFn:()=>pt(),staleTime:a,enabled:o,retry:2}),w=async()=>{await n.refetch()},p=async()=>{await c.invalidateQueries({queryKey:he.all})};return{templates:t?((f=n.data)==null?void 0:f.filter(d=>d.category===t))??[]:n.data??[],isLoading:n.isLoading,isFetching:n.isFetching,error:n.error,refetch:w,invalidate:p}}function ia(){const s=te(),t=se({mutationFn:a=>xt(a),onSettled:()=>{s.invalidateQueries({queryKey:he.all})}});return{deleteTemplate:t.mutateAsync,isDeleting:t.isPending,error:t.error}}function da(){const s=te(),t=se({mutationFn:a=>ut(a),onSettled:()=>{s.invalidateQueries({queryKey:he.all}),s.invalidateQueries({queryKey:B.all})}});return{installTemplate:t.mutateAsync,isInstalling:t.isPending,error:t.error}}const ma=[];function Gs(){var p,f;const s=te(),t=xe(ue),a=ge({queryKey:Oe.list(),queryFn:()=>ht(),staleTime:ze,enabled:!0,retry:2}),o=se({mutationFn:d=>Je(d),onSettled:()=>{s.invalidateQueries({queryKey:B.all})}}),c=ge({queryKey:Oe.servers(),queryFn:()=>Ye(),staleTime:ze,enabled:!1,retry:1}),n=async()=>{await a.refetch()},w=async d=>await s.fetchQuery({queryKey:Oe.servers(d),queryFn:()=>Ye(d),staleTime:ze});return{projects:((p=a.data)==null?void 0:p.projects)??ma,currentProject:((f=a.data)==null?void 0:f.currentProject)??t??void 0,isLoading:a.isLoading,error:a.error,refetch:n,copyToCodex:d=>o.mutateAsync({...d,source:"claude",target:"codex",projectPath:d.projectPath??t??void 0}),copyFromCodex:d=>o.mutateAsync({...d,source:"codex",target:"claude",projectPath:d.projectPath??t??void 0}),isCopying:o.isPending,fetchOtherServers:w,isFetchingServers:c.isFetching}}const Js="mcp-config-type",Ys="mcp-json";function xa(){try{const s=localStorage.getItem(Js);if(s==="mcp-json"||s==="claude-json")return s}catch{}return Ys}function ua(s){try{localStorage.setItem(Js,s)}catch{}}function pa({currentType:s,onTypeChange:t,showWarning:a=!0,existingServersCount:o=0}){const{formatMessage:c}=G(),[n,w]=h.useState(s),[p,f]=h.useState(!1),[d,S]=h.useState(null);h.useEffect(()=>{w(s)},[s]),h.useEffect(()=>{if(!s||s===Ys){const b=xa();b!==s&&(w(b),t(b))}},[]);const m=b=>{b!==n&&(a&&o>0?(S(b),f(!0)):g(b))},g=b=>{w(b),ua(b),t(b),f(!1),S(null)},y=()=>{d&&g(d)},u=()=>{f(!1),S(null)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 p-0.5 bg-muted rounded-md h-9",children:[e.jsx("button",{type:"button",onClick:()=>m("mcp-json"),className:H("px-2.5 py-1 text-xs font-medium rounded transition-all",n==="mcp-json"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:".mcp.json"}),e.jsx("button",{type:"button",onClick:()=>m("claude-json"),className:H("px-2.5 py-1 text-xs font-medium rounded transition-all",n==="claude-json"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:".claude.json"})]}),e.jsx(is,{open:p,onOpenChange:f,children:e.jsxs(ds,{children:[e.jsxs(ms,{children:[e.jsx(xs,{children:c({id:"mcp.configType.switchConfirm"})}),e.jsxs(us,{children:[c({id:"mcp.configType.switchWarning"}),o>0&&e.jsxs("span",{className:"block mt-2 text-amber-600 dark:text-amber-400",children:[o," ",c({id:"mcp.stats.total"}).toLowerCase()]})]})]}),e.jsxs(ps,{children:[e.jsx(hs,{onClick:u,children:c({id:"mcp.configType.switchCancel"})}),e.jsx(gs,{onClick:y,children:c({id:"mcp.configType.switchConfirm"})})]})]})})]})}function ha({headers:s,onChange:t,disabled:a}){const{formatMessage:o}=G(),[c,n]=h.useState(new Set),w=()=>`header-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,p=()=>{t([...s,{id:w(),name:"",value:"",isEnvVar:!1}])},f=m=>{t(s.filter(g=>g.id!==m))},d=(m,g,y)=>{t(s.map(u=>u.id===m?{...u,[g]:y}:u))},S=m=>{n(g=>{const y=new Set(g);return y.has(m)?y.delete(m):y.add(m),y})};return e.jsxs("div",{className:"space-y-2",children:[s.map(m=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{value:m.name,onChange:g=>d(m.id,"name",g.target.value),placeholder:o({id:"mcp.dialog.form.http.headerName"}),className:"flex-1",disabled:a}),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(X,{type:c.has(m.id)?"text":"password",value:m.value,onChange:g=>d(m.id,"value",g.target.value),placeholder:o({id:"mcp.dialog.form.http.headerValue"}),className:"pr-8",disabled:a}),e.jsx(D,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-2",onClick:()=>S(m.id),disabled:a,children:c.has(m.id)?e.jsx(fs,{className:"w-4 h-4"}):e.jsx(js,{className:"w-4 h-4"})})]}),e.jsxs("label",{className:"flex items-center gap-1 text-xs text-muted-foreground whitespace-nowrap",children:[e.jsx("input",{type:"checkbox",checked:m.isEnvVar,onChange:g=>d(m.id,"isEnvVar",g.target.checked),className:"w-3 h-3",disabled:a}),o({id:"mcp.dialog.form.http.isEnvVar"})]}),e.jsx(D,{type:"button",variant:"ghost",size:"icon",onClick:()=>f(m.id),disabled:a,className:"text-destructive",children:e.jsx(Me,{className:"w-4 h-4"})})]},m.id)),e.jsxs(D,{type:"button",variant:"outline",size:"sm",onClick:p,disabled:a,className:"w-full",children:[e.jsx(Ie,{className:"w-4 h-4 mr-1"}),o({id:"mcp.dialog.form.http.addHeader"})]})]})}function ga({mode:s,server:t,open:a,onClose:o,onSave:c}){const{formatMessage:n}=G(),w=te(),p=xe(ue),{error:f,success:d}=Ve(),{templates:S,isLoading:m}=la(),[g,y]=h.useState("stdio"),[u,b]=h.useState({name:"",command:"",args:[],env:{},url:"",headers:[],bearerTokenEnvVar:"",scope:"project",enabled:!0}),[v,k]=h.useState(""),[j,M]=h.useState({}),[T,F]=h.useState(""),[r,x]=h.useState(""),[E,O]=h.useState("mcp-json"),[V,$]=h.useState(!1),W=E==="claude-json"?"claude":"mcp",[J,U]=h.useState("form"),[N,L]=h.useState(""),A=h.useCallback(l=>l&&de(l)?"http":"stdio",[]),re=h.useCallback(()=>{try{const l=JSON.parse(N);if(l.url){y("http");const P=[];l.headers&&typeof l.headers=="object"&&Object.entries(l.headers).forEach(([K,_],ce)=>{P.push({id:`header-${Date.now()}-${ce}`,name:K,value:String(_),isEnvVar:!1})}),b(K=>({...K,url:l.url||"",headers:P,bearerTokenEnvVar:l.bearer_token_env_var||l.bearerTokenEnvVar||""}))}else{y("stdio");const P=Array.isArray(l.args)?l.args:[],K=l.env&&typeof l.env=="object"?l.env:{};b(_=>({..._,command:l.command||"",args:P,env:K})),F(P.join(", ")),x(Object.entries(K).map(([_,ce])=>`${_}=${ce}`).join(`
32
- `))}U("form"),M({}),d(n({id:"mcp.dialog.json.parseSuccess"}),n({id:"mcp.dialog.json.parseSuccessDesc"}))}catch(l){M({name:n({id:"mcp.dialog.json.parseError"},{error:l instanceof Error?l.message:"Invalid JSON"})})}},[N,n,d]);h.useEffect(()=>{if(t&&s==="edit"){const l=A(t);y(l);const P=[];de(t)&&(t.httpHeaders&&Object.entries(t.httpHeaders).forEach(([ee,Ne],Be)=>{P.push({id:`header-http-${Be}`,name:ee,value:Ne,isEnvVar:!1})}),t.envHttpHeaders&&t.envHttpHeaders.forEach((ee,Ne)=>{P.push({id:`header-env-${Ne}`,name:ee,value:"",isEnvVar:!0})}));const K=me(t)?t.command:"",_=me(t)?t.args||[]:[],ce=me(t)?t.env||{}:{},Se=de(t)?t.url:"",De=de(t)&&t.bearerTokenEnvVar||"";b({name:t.name,command:K,args:_,env:ce,url:Se,headers:P,bearerTokenEnvVar:De,scope:t.scope,enabled:t.enabled}),F(_.join(", ")),x(Object.entries(ce).map(([ee,Ne])=>`${ee}=${Ne}`).join(`
33
- `))}else y("stdio"),b({name:"",command:"",args:[],env:{},url:"",headers:[],bearerTokenEnvVar:"",scope:"project",enabled:!0}),F(""),x("");k(""),$(!1),M({})},[t,s,a,A]);const oe=se({mutationFn:({server:l,configType:P})=>As(l,{projectPath:p??void 0,configType:P}),onSuccess:()=>{w.invalidateQueries({queryKey:B.all}),je(),c==null||c()}}),we=se({mutationFn:({serverName:l,config:P,configType:K})=>Os(l,P,{projectPath:p??void 0,configType:K}),onSuccess:()=>{w.invalidateQueries({queryKey:B.all}),je(),c==null||c()}}),je=()=>{M({}),o()},Fe=l=>{const P=S.find(K=>K.name===l);P&&(b(K=>({...K,command:P.serverConfig.command,args:P.serverConfig.args||[],env:P.serverConfig.env||{}})),F((P.serverConfig.args||[]).join(", ")),x(Object.entries(P.serverConfig.env||{}).map(([K,_])=>`${K}=${_}`).join(`
34
- `)),k(l))},le=(l,P)=>{b(K=>({...K,[l]:P})),j[l]&&M(K=>({...K,[l]:void 0}))},ve=l=>{F(l);const P=l.split(",").map(K=>K.trim()).filter(K=>K.length>0);b(K=>({...K,args:P})),j.args&&M(K=>({...K,args:void 0}))},q=l=>{x(l);const P={},K=l.split(`
35
- `);for(const _ of K){const ce=_.trim();if(ce&&ce.includes("=")){const[Se,...De]=ce.split("="),ee=De.join("=");Se&&(P[Se.trim()]=ee.trim())}}b(_=>({..._,env:P})),j.env&&M(_=>({..._,env:void 0}))},ae=l=>{b(P=>({...P,headers:l})),j.headers&&M(P=>({...P,headers:void 0}))},Ce=l=>{y(l),M(P=>({...P,command:void 0,url:void 0}))},Ee=()=>{const l={};if(u.name.trim()||(l.name=n({id:"mcp.dialog.validation.nameRequired"})),g==="stdio")u.command.trim()||(l.command=n({id:"mcp.dialog.validation.commandRequired"}));else{u.url.trim()||(l.url=n({id:"mcp.dialog.validation.urlRequired"}));try{new URL(u.url)}catch{l.url=n({id:"mcp.dialog.validation.urlInvalid"})}}return M(l),Object.keys(l).length===0},We=async l=>{try{const P=await Ks(p??void 0);return[...P.project,...P.global].some(_=>_.name===l&&(s==="edit"?_.name!==(t==null?void 0:t.name):!0))}catch{return!1}},Ue=async()=>{if(!Ee())return;if(await We(u.name)){M({name:n({id:"mcp.dialog.validation.nameExists"})});return}let l;if(g==="stdio")l={name:u.name,transport:"stdio",command:u.command,args:u.args.length>0?u.args:void 0,env:Object.keys(u.env).length>0?u.env:void 0,scope:u.scope,enabled:u.enabled};else{const P={},K=[];u.headers.forEach(_=>{_.name.trim()&&(_.isEnvVar?K.push(_.name.trim()):P[_.name.trim()]=_.value.trim())}),l={name:u.name,transport:"http",url:u.url,headers:Object.keys(P).length>0?P:void 0,httpHeaders:Object.keys(P).length>0?P:void 0,envHttpHeaders:K.length>0?K:void 0,bearerTokenEnvVar:u.bearerTokenEnvVar.trim()||void 0,scope:u.scope,enabled:u.enabled}}if(V&&g==="stdio")try{await zs({name:u.name,category:"custom",serverConfig:{command:u.command,args:u.args.length>0?u.args:void 0,env:Object.keys(u.env).length>0?u.env:void 0}})}catch(P){f(n({id:"mcp.templates.feedback.saveError"}),P instanceof Error?P.message:String(P))}s==="add"?oe.mutate({server:l,configType:u.scope==="project"?W:void 0}):we.mutate({serverName:t.name,config:l,configType:u.scope==="project"?W:void 0})},ne=oe.isPending||we.isPending;return e.jsx(ts,{open:a,onOpenChange:je,children:e.jsxs(as,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ns,{children:e.jsx(rs,{children:s==="add"?n({id:"mcp.dialog.addTitle"}):n({id:"mcp.dialog.editTitle"},{name:t==null?void 0:t.name})})}),s==="add"&&e.jsxs("div",{className:"flex gap-2 border-b pb-3",children:[e.jsx(D,{type:"button",variant:J==="form"?"default":"outline",size:"sm",onClick:()=>U("form"),className:"flex-1",children:n({id:"mcp.dialog.mode.form"})}),e.jsx(D,{type:"button",variant:J==="json"?"default":"outline",size:"sm",onClick:()=>U("json"),className:"flex-1",children:n({id:"mcp.dialog.mode.json"})})]}),e.jsx("div",{className:"space-y-4",children:J==="json"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.json.label"})}),e.jsx("textarea",{value:N,onChange:l=>L(l.target.value),placeholder:n({id:"mcp.dialog.json.placeholder"}),className:H("flex min-h-[300px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 font-mono",j.name&&"border-destructive focus-visible:ring-destructive")}),j.name&&e.jsx("p",{className:"text-sm text-destructive",children:j.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n({id:"mcp.dialog.json.hint"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.json.example"})}),e.jsxs("div",{className:"bg-muted p-3 rounded-md",children:[e.jsx("p",{className:"text-xs font-medium mb-2",children:"STDIO:"}),e.jsx("pre",{className:"text-xs overflow-x-auto",children:`{
31
+ */const ta=Pe("SearchCode",[["path",{d:"m13 13.5 2-2.5-2-2.5",key:"1rvxrh"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}],["path",{d:"M9 8.5 7 11l2 2.5",key:"6ffwbx"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),B={all:["mcpServers"],lists:()=>[...B.all,"list"],list:s=>[...B.lists(),s]},ge={all:["mcpTemplates"],lists:()=>[...ge.all,"list"],list:s=>[...ge.lists(),s],search:s=>[...ge.all,"search",s],categories:()=>[...ge.all,"categories"]},Oe={all:["projects"],list:()=>[...Oe.all,"list"],servers:s=>[...Oe.all,"servers",...s??[]]},ze=120*1e3;function Us(s={}){var b,v,k;const{scope:t,staleTime:a=ze,enabled:l=!0}=s,c=ae(),n=xe(pe),w=l&&!!n,u=fe({queryKey:B.list(t),queryFn:()=>Ks(n),staleTime:a,enabled:w,retry:2}),f=((b=u.data)==null?void 0:b.project)??[],d=((v=u.data)==null?void 0:v.global)??[],S=((k=u.data)==null?void 0:k.conflicts)??[],m=t==="project"?f:t==="global"?d:[...f,...d],g=m.filter(j=>j.enabled),y=async()=>{await u.refetch()},p=async()=>{await c.invalidateQueries({queryKey:B.all})};return{servers:m,projectServers:f,globalServers:d,conflicts:S,totalCount:m.length,enabledCount:g.length,isLoading:u.isLoading,isFetching:u.isFetching,error:u.error,refetch:y,invalidate:p}}function aa(){const s=ae(),t=xe(pe),a=te({mutationFn:({serverName:l,config:c,configType:n})=>Os(l,c,{projectPath:t??void 0,configType:n}),onSettled:()=>{s.invalidateQueries({queryKey:B.all})}});return{updateServer:(l,c,n)=>a.mutateAsync({serverName:l,config:c,configType:n}),isUpdating:a.isPending,error:a.error}}function na(){const s=ae(),t=xe(pe),a=te({mutationFn:({server:l,configType:c})=>As(l,{projectPath:t??void 0,configType:c}),onSettled:()=>{s.invalidateQueries({queryKey:B.all})}});return{createServer:(l,c)=>a.mutateAsync({server:l,configType:c}),isCreating:a.isPending,error:a.error}}function ra(){const s=ae(),t=xe(pe),a=te({mutationFn:({serverName:l,scope:c})=>dt(l,c,{projectPath:t??void 0}),onSettled:()=>{s.invalidateQueries({queryKey:B.all}),s.invalidateQueries({queryKey:["ccwMcpConfig"]})}});return{deleteServer:(l,c)=>a.mutateAsync({serverName:l,scope:c}),isDeleting:a.isPending,error:a.error}}function ca(){const s=ae(),t=xe(pe),a=te({mutationFn:({serverName:l,enabled:c})=>mt(l,c,{projectPath:t??void 0}),onMutate:async({serverName:l,enabled:c})=>{await s.cancelQueries({queryKey:B.all});const n=s.getQueryData(B.list());return s.setQueryData(B.list(),w=>{if(!w)return w;const u=f=>f.map(d=>d.name===l?{...d,enabled:c}:d);return{project:u(w.project),global:u(w.global),conflicts:w.conflicts??[]}}),{previousServers:n}},onError:(l,c,n)=>{n!=null&&n.previousServers&&s.setQueryData(B.list(),n.previousServers)},onSettled:()=>{s.invalidateQueries({queryKey:B.all})}});return{toggleServer:(l,c)=>a.mutateAsync({serverName:l,enabled:c}),isToggling:a.isPending,error:a.error}}function Bs(){const s=aa(),t=na(),a=ra(),l=ca();return{updateServer:s.updateServer,isUpdating:s.isUpdating,createServer:t.createServer,isCreating:t.isCreating,deleteServer:a.deleteServer,isDeleting:a.isDeleting,toggleServer:l.toggleServer,isToggling:l.isToggling,isMutating:s.isUpdating||t.isCreating||a.isDeleting||l.isToggling}}const oa=300*1e3;function la(s={}){var f;const{category:t,staleTime:a=oa,enabled:l=!0}=s,c=ae(),n=fe({queryKey:ge.list(t),queryFn:()=>ut(),staleTime:a,enabled:l,retry:2}),w=async()=>{await n.refetch()},u=async()=>{await c.invalidateQueries({queryKey:ge.all})};return{templates:t?((f=n.data)==null?void 0:f.filter(d=>d.category===t))??[]:n.data??[],isLoading:n.isLoading,isFetching:n.isFetching,error:n.error,refetch:w,invalidate:u}}function ia(){const s=ae(),t=te({mutationFn:a=>xt(a),onSettled:()=>{s.invalidateQueries({queryKey:ge.all})}});return{deleteTemplate:t.mutateAsync,isDeleting:t.isPending,error:t.error}}function da(){const s=ae(),t=te({mutationFn:a=>pt(a),onSettled:()=>{s.invalidateQueries({queryKey:ge.all}),s.invalidateQueries({queryKey:B.all})}});return{installTemplate:t.mutateAsync,isInstalling:t.isPending,error:t.error}}const ma=[];function Gs(){var u,f;const s=ae(),t=xe(pe),a=fe({queryKey:Oe.list(),queryFn:()=>ht(),staleTime:ze,enabled:!0,retry:2}),l=te({mutationFn:d=>Je(d),onSettled:()=>{s.invalidateQueries({queryKey:B.all})}}),c=fe({queryKey:Oe.servers(),queryFn:()=>Ye(),staleTime:ze,enabled:!1,retry:1}),n=async()=>{await a.refetch()},w=async d=>await s.fetchQuery({queryKey:Oe.servers(d),queryFn:()=>Ye(d),staleTime:ze});return{projects:((u=a.data)==null?void 0:u.projects)??ma,currentProject:((f=a.data)==null?void 0:f.currentProject)??t??void 0,isLoading:a.isLoading,error:a.error,refetch:n,copyToCodex:d=>l.mutateAsync({...d,source:"claude",target:"codex",projectPath:d.projectPath??t??void 0}),copyFromCodex:d=>l.mutateAsync({...d,source:"codex",target:"claude",projectPath:d.projectPath??t??void 0}),isCopying:l.isPending,fetchOtherServers:w,isFetchingServers:c.isFetching}}const Js="mcp-config-type",Ys="mcp-json";function xa(){try{const s=localStorage.getItem(Js);if(s==="mcp-json"||s==="claude-json")return s}catch{}return Ys}function pa(s){try{localStorage.setItem(Js,s)}catch{}}function ua({currentType:s,onTypeChange:t,showWarning:a=!0,existingServersCount:l=0}){const{formatMessage:c}=G(),[n,w]=h.useState(s),[u,f]=h.useState(!1),[d,S]=h.useState(null);h.useEffect(()=>{w(s)},[s]),h.useEffect(()=>{if(!s||s===Ys){const b=xa();b!==s&&(w(b),t(b))}},[]);const m=b=>{b!==n&&(a&&l>0?(S(b),f(!0)):g(b))},g=b=>{w(b),pa(b),t(b),f(!1),S(null)},y=()=>{d&&g(d)},p=()=>{f(!1),S(null)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 p-0.5 bg-muted rounded-md h-9",children:[e.jsx("button",{type:"button",onClick:()=>m("mcp-json"),className:_("px-2.5 py-1 text-xs font-medium rounded transition-all",n==="mcp-json"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:".mcp.json"}),e.jsx("button",{type:"button",onClick:()=>m("claude-json"),className:_("px-2.5 py-1 text-xs font-medium rounded transition-all",n==="claude-json"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:".claude.json"})]}),e.jsx(is,{open:u,onOpenChange:f,children:e.jsxs(ds,{children:[e.jsxs(ms,{children:[e.jsx(xs,{children:c({id:"mcp.configType.switchConfirm"})}),e.jsxs(ps,{children:[c({id:"mcp.configType.switchWarning"}),l>0&&e.jsxs("span",{className:"block mt-2 text-amber-600 dark:text-amber-400",children:[l," ",c({id:"mcp.stats.total"}).toLowerCase()]})]})]}),e.jsxs(us,{children:[e.jsx(hs,{onClick:p,children:c({id:"mcp.configType.switchCancel"})}),e.jsx(gs,{onClick:y,children:c({id:"mcp.configType.switchConfirm"})})]})]})})]})}function ha({headers:s,onChange:t,disabled:a}){const{formatMessage:l}=G(),[c,n]=h.useState(new Set),w=()=>`header-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,u=()=>{t([...s,{id:w(),name:"",value:"",isEnvVar:!1}])},f=m=>{t(s.filter(g=>g.id!==m))},d=(m,g,y)=>{t(s.map(p=>p.id===m?{...p,[g]:y}:p))},S=m=>{n(g=>{const y=new Set(g);return y.has(m)?y.delete(m):y.add(m),y})};return e.jsxs("div",{className:"space-y-2",children:[s.map(m=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{value:m.name,onChange:g=>d(m.id,"name",g.target.value),placeholder:l({id:"mcp.dialog.form.http.headerName"}),className:"flex-1",disabled:a}),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(X,{type:c.has(m.id)?"text":"password",value:m.value,onChange:g=>d(m.id,"value",g.target.value),placeholder:l({id:"mcp.dialog.form.http.headerValue"}),className:"pr-8",disabled:a}),e.jsx(D,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-2",onClick:()=>S(m.id),disabled:a,children:c.has(m.id)?e.jsx(fs,{className:"w-4 h-4"}):e.jsx(js,{className:"w-4 h-4"})})]}),e.jsxs("label",{className:"flex items-center gap-1 text-xs text-muted-foreground whitespace-nowrap",children:[e.jsx("input",{type:"checkbox",checked:m.isEnvVar,onChange:g=>d(m.id,"isEnvVar",g.target.checked),className:"w-3 h-3",disabled:a}),l({id:"mcp.dialog.form.http.isEnvVar"})]}),e.jsx(D,{type:"button",variant:"ghost",size:"icon",onClick:()=>f(m.id),disabled:a,className:"text-destructive",children:e.jsx(Me,{className:"w-4 h-4"})})]},m.id)),e.jsxs(D,{type:"button",variant:"outline",size:"sm",onClick:u,disabled:a,className:"w-full",children:[e.jsx(Ie,{className:"w-4 h-4 mr-1"}),l({id:"mcp.dialog.form.http.addHeader"})]})]})}function ga({mode:s,server:t,open:a,onClose:l,onSave:c}){const{formatMessage:n}=G(),w=ae(),u=xe(pe),{error:f,success:d}=Ve(),{templates:S,isLoading:m}=la(),[g,y]=h.useState("stdio"),[p,b]=h.useState({name:"",command:"",args:[],env:{},url:"",headers:[],bearerTokenEnvVar:"",scope:"project",enabled:!0}),[v,k]=h.useState(""),[j,M]=h.useState({}),[T,P]=h.useState(""),[r,x]=h.useState(""),[E,O]=h.useState("mcp-json"),[H,$]=h.useState(!1),W=E==="claude-json"?"claude":"mcp",[J,U]=h.useState("form"),[N,L]=h.useState(""),A=h.useCallback(o=>o&&de(o)?"http":"stdio",[]),ce=h.useCallback(()=>{try{let o=JSON.parse(N),F="";if(o.mcpServers&&typeof o.mcpServers=="object"&&!Array.isArray(o.mcpServers)){const K=Object.keys(o.mcpServers);if(K.length>0){F=K[0];const V=o.mcpServers[F];V&&typeof V=="object"&&(o=V)}}if(o.url){y("http");const K=[];o.headers&&typeof o.headers=="object"&&Object.entries(o.headers).forEach(([V,ee],ue)=>{K.push({id:`header-${Date.now()}-${ue}`,name:V,value:String(ee),isEnvVar:!1})}),b(V=>({...V,name:F||V.name,url:o.url||"",headers:K,bearerTokenEnvVar:o.bearer_token_env_var||o.bearerTokenEnvVar||""}))}else{y("stdio");const K=Array.isArray(o.args)?o.args:[],V=o.env&&typeof o.env=="object"?o.env:{};b(ee=>({...ee,name:F||ee.name,command:o.command||"",args:K,env:V})),P(K.join(", ")),x(Object.entries(V).map(([ee,ue])=>`${ee}=${ue}`).join(`
32
+ `))}U("form"),M({}),d(n({id:"mcp.dialog.json.parseSuccess"}),n({id:"mcp.dialog.json.parseSuccessDesc"}))}catch(o){M({name:n({id:"mcp.dialog.json.parseError"},{error:o instanceof Error?o.message:"Invalid JSON"})})}},[N,n,d]);h.useEffect(()=>{if(t&&s==="edit"){const o=A(t);y(o);const F=[];de(t)&&(t.httpHeaders&&Object.entries(t.httpHeaders).forEach(([se,be],Be)=>{F.push({id:`header-http-${Be}`,name:se,value:be,isEnvVar:!1})}),t.envHttpHeaders&&t.envHttpHeaders.forEach((se,be)=>{F.push({id:`header-env-${be}`,name:se,value:"",isEnvVar:!0})}));const K=me(t)?t.command:"",V=me(t)?t.args||[]:[],ee=me(t)?t.env||{}:{},ue=de(t)?t.url:"",De=de(t)&&t.bearerTokenEnvVar||"";b({name:t.name,command:K,args:V,env:ee,url:ue,headers:F,bearerTokenEnvVar:De,scope:t.scope,enabled:t.enabled}),P(V.join(", ")),x(Object.entries(ee).map(([se,be])=>`${se}=${be}`).join(`
33
+ `))}else y("stdio"),b({name:"",command:"",args:[],env:{},url:"",headers:[],bearerTokenEnvVar:"",scope:"project",enabled:!0}),P(""),x("");k(""),$(!1),M({})},[t,s,a,A]);const oe=te({mutationFn:({server:o,configType:F})=>As(o,{projectPath:u??void 0,configType:F}),onSuccess:()=>{w.invalidateQueries({queryKey:B.all}),ve(),c==null||c()}}),Ce=te({mutationFn:({serverName:o,config:F,configType:K})=>Os(o,F,{projectPath:u??void 0,configType:K}),onSuccess:()=>{w.invalidateQueries({queryKey:B.all}),ve(),c==null||c()}}),ve=()=>{M({}),l()},Fe=o=>{const F=S.find(K=>K.name===o);F&&(b(K=>({...K,command:F.serverConfig.command,args:F.serverConfig.args||[],env:F.serverConfig.env||{}})),P((F.serverConfig.args||[]).join(", ")),x(Object.entries(F.serverConfig.env||{}).map(([K,V])=>`${K}=${V}`).join(`
34
+ `)),k(o))},le=(o,F)=>{b(K=>({...K,[o]:F})),j[o]&&M(K=>({...K,[o]:void 0}))},ye=o=>{P(o);const F=o.split(",").map(K=>K.trim()).filter(K=>K.length>0);b(K=>({...K,args:F})),j.args&&M(K=>({...K,args:void 0}))},q=o=>{x(o);const F={},K=o.split(`
35
+ `);for(const V of K){const ee=V.trim();if(ee&&ee.includes("=")){const[ue,...De]=ee.split("="),se=De.join("=");ue&&(F[ue.trim()]=se.trim())}}b(V=>({...V,env:F})),j.env&&M(V=>({...V,env:void 0}))},ne=o=>{b(F=>({...F,headers:o})),j.headers&&M(F=>({...F,headers:void 0}))},Se=o=>{y(o),M(F=>({...F,command:void 0,url:void 0}))},Ee=()=>{const o={};if(p.name.trim()||(o.name=n({id:"mcp.dialog.validation.nameRequired"})),g==="stdio")p.command.trim()||(o.command=n({id:"mcp.dialog.validation.commandRequired"}));else{p.url.trim()||(o.url=n({id:"mcp.dialog.validation.urlRequired"}));try{new URL(p.url)}catch{o.url=n({id:"mcp.dialog.validation.urlInvalid"})}}return M(o),Object.keys(o).length===0},We=async o=>{try{const F=await Ks(u??void 0);return[...F.project,...F.global].some(V=>V.name===o&&(s==="edit"?V.name!==(t==null?void 0:t.name):!0))}catch{return!1}},Ue=async()=>{if(!Ee())return;if(await We(p.name)){M({name:n({id:"mcp.dialog.validation.nameExists"})});return}let o;if(g==="stdio")o={name:p.name,transport:"stdio",command:p.command,args:p.args.length>0?p.args:void 0,env:Object.keys(p.env).length>0?p.env:void 0,scope:p.scope,enabled:p.enabled};else{const F={},K=[];p.headers.forEach(V=>{V.name.trim()&&(V.isEnvVar?K.push(V.name.trim()):F[V.name.trim()]=V.value.trim())}),o={name:p.name,transport:"http",url:p.url,headers:Object.keys(F).length>0?F:void 0,httpHeaders:Object.keys(F).length>0?F:void 0,envHttpHeaders:K.length>0?K:void 0,bearerTokenEnvVar:p.bearerTokenEnvVar.trim()||void 0,scope:p.scope,enabled:p.enabled}}if(H&&g==="stdio")try{await zs({name:p.name,category:"custom",serverConfig:{command:p.command,args:p.args.length>0?p.args:void 0,env:Object.keys(p.env).length>0?p.env:void 0}})}catch(F){f(n({id:"mcp.templates.feedback.saveError"}),F instanceof Error?F.message:String(F))}s==="add"?oe.mutate({server:o,configType:p.scope==="project"?W:void 0}):Ce.mutate({serverName:t.name,config:o,configType:p.scope==="project"?W:void 0})},re=oe.isPending||Ce.isPending;return e.jsx(ts,{open:a,onOpenChange:ve,children:e.jsxs(as,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ns,{children:e.jsx(rs,{children:s==="add"?n({id:"mcp.dialog.addTitle"}):n({id:"mcp.dialog.editTitle"},{name:t==null?void 0:t.name})})}),s==="add"&&e.jsxs("div",{className:"flex gap-2 border-b pb-3",children:[e.jsx(D,{type:"button",variant:J==="form"?"default":"outline",size:"sm",onClick:()=>U("form"),className:"flex-1",children:n({id:"mcp.dialog.mode.form"})}),e.jsx(D,{type:"button",variant:J==="json"?"default":"outline",size:"sm",onClick:()=>U("json"),className:"flex-1",children:n({id:"mcp.dialog.mode.json"})})]}),e.jsx("div",{className:"space-y-4",children:J==="json"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.json.label"})}),e.jsx("textarea",{value:N,onChange:o=>L(o.target.value),placeholder:n({id:"mcp.dialog.json.placeholder"}),className:_("flex min-h-[300px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 font-mono",j.name&&"border-destructive focus-visible:ring-destructive")}),j.name&&e.jsx("p",{className:"text-sm text-destructive",children:j.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n({id:"mcp.dialog.json.hint"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.json.example"})}),e.jsxs("div",{className:"bg-muted p-3 rounded-md",children:[e.jsx("p",{className:"text-xs font-medium mb-2",children:"STDIO:"}),e.jsx("pre",{className:"text-xs overflow-x-auto",children:`{
36
36
  "command": "npx",
37
37
  "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path"],
38
38
  "env": {
@@ -43,8 +43,8 @@ import{O as Pe,aF as te,a9 as xe,aa as ue,ab as ge,aH as se,cU as Os,cV as As,cW
43
43
  "headers": {
44
44
  "Authorization": "Bearer token"
45
45
  }
46
- }`})]})]}),e.jsx(D,{type:"button",onClick:re,disabled:!N.trim(),className:"w-full",children:n({id:"mcp.dialog.json.parse"})})]}):e.jsxs(e.Fragment,{children:[g==="stdio"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.form.template"})}),e.jsxs(He,{value:v,onValueChange:Fe,disabled:m,children:[e.jsx(_e,{className:"w-full",children:e.jsx($e,{placeholder:n(m?{id:"mcp.templates.loading"}:{id:"mcp.dialog.form.templatePlaceholder"})})}),e.jsx(Re,{children:S.length===0?e.jsx(pe,{value:"__empty__",disabled:!0,children:n({id:"mcp.templates.empty.title"})}):S.map(l=>e.jsx(pe,{value:l.name,children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:l.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:l.description||n({id:"mcp.dialog.form.templatePlaceholder"})})]})},l.name))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-sm font-medium text-foreground",children:[n({id:"mcp.dialog.form.name"}),e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(X,{value:u.name,onChange:l=>le("name",l.target.value),placeholder:n({id:"mcp.dialog.form.namePlaceholder"}),error:!!j.name,disabled:s==="edit"}),j.name&&e.jsx("p",{className:"text-sm text-destructive",children:j.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.form.transportType"})}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"transportType",value:"stdio",checked:g==="stdio",onChange:()=>Ce("stdio"),className:"w-4 h-4",disabled:s==="edit"}),e.jsx(gt,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:n({id:"mcp.dialog.form.transportStdio"})})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"transportType",value:"http",checked:g==="http",onChange:()=>Ce("http"),className:"w-4 h-4",disabled:s==="edit"}),e.jsx(fe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:n({id:"mcp.dialog.form.transportHttp"})})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n({id:"mcp.dialog.form.transportHint"})})]}),g==="stdio"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-sm font-medium text-foreground",children:[n({id:"mcp.dialog.form.command"}),e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(X,{value:u.command,onChange:l=>le("command",l.target.value),placeholder:n({id:"mcp.dialog.form.commandPlaceholder"}),error:!!j.command}),j.command&&e.jsx("p",{className:"text-sm text-destructive",children:j.command})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.form.args"})}),e.jsx(X,{value:T,onChange:l=>ve(l.target.value),placeholder:n({id:"mcp.dialog.form.argsPlaceholder"}),error:!!j.args}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n({id:"mcp.dialog.form.argsHint"})}),u.args.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:u.args.map((l,P)=>e.jsx(I,{variant:"secondary",className:"font-mono text-xs",children:l},P))}),j.args&&e.jsx("p",{className:"text-sm text-destructive",children:j.args})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.form.env"})}),e.jsx("textarea",{value:r,onChange:l=>q(l.target.value),placeholder:n({id:"mcp.dialog.form.envPlaceholder"}),className:H("flex min-h-[100px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",j.env&&"border-destructive focus-visible:ring-destructive")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n({id:"mcp.dialog.form.envHint"})}),Object.keys(u.env).length>0&&e.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(u.env).map(([l,P])=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(I,{variant:"outline",className:"font-mono",children:l}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"text-xs bg-muted px-2 py-1 rounded flex-1 overflow-x-auto",children:P})]},l))}),j.env&&e.jsx("p",{className:"text-sm text-destructive",children:j.env})]})]}),g==="http"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-sm font-medium text-foreground",children:[n({id:"mcp.dialog.form.http.url"}),e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(X,{value:u.url,onChange:l=>le("url",l.target.value),placeholder:n({id:"mcp.dialog.form.http.urlPlaceholder"}),error:!!j.url}),j.url&&e.jsx("p",{className:"text-sm text-destructive",children:j.url}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n({id:"mcp.dialog.form.http.urlHint"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.form.http.bearerToken"})}),e.jsx(X,{value:u.bearerTokenEnvVar,onChange:l=>le("bearerTokenEnvVar",l.target.value),placeholder:n({id:"mcp.dialog.form.http.bearerTokenPlaceholder"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n({id:"mcp.dialog.form.http.bearerTokenHint"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.form.http.headers"})}),e.jsx(ha,{headers:u.headers,onChange:ae,disabled:ne}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n({id:"mcp.dialog.form.http.headersHint"})}),j.headers&&e.jsx("p",{className:"text-sm text-destructive",children:j.headers})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.form.scope"})}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"scope",value:"project",checked:u.scope==="project",onChange:l=>le("scope",l.target.value),className:"w-4 h-4",disabled:s==="edit"}),e.jsx("span",{className:"text-sm",children:n({id:"mcp.scope.project"})})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"scope",value:"global",checked:u.scope==="global",onChange:l=>le("scope",l.target.value),className:"w-4 h-4",disabled:s==="edit"}),e.jsx("span",{className:"text-sm",children:n({id:"mcp.scope.global"})})]})]}),u.scope==="project"&&e.jsxs("div",{className:"flex items-center gap-2 mt-2 pl-6",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[n({id:"mcp.configType.format"}),":"]}),e.jsx(pa,{currentType:E,onTypeChange:O,showWarning:!1})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"enabled",checked:u.enabled,onChange:l=>le("enabled",l.target.checked),className:"w-4 h-4"}),e.jsx("label",{htmlFor:"enabled",className:"text-sm font-medium text-foreground cursor-pointer",children:n({id:"mcp.dialog.form.enabled"})})]}),g==="stdio"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"save-as-template",checked:V,onChange:l=>$(l.target.checked),className:"w-4 h-4"}),e.jsx("label",{htmlFor:"save-as-template",className:"text-sm font-medium text-foreground cursor-pointer",children:n({id:"mcp.templates.actions.saveAsTemplate"})})]})]})}),e.jsxs(cs,{children:[e.jsx(D,{variant:"outline",onClick:je,disabled:ne,children:n({id:"mcp.dialog.actions.cancel"})}),e.jsx(D,{onClick:Ue,disabled:ne,children:n(ne?{id:"mcp.dialog.actions.saving"}:{id:"mcp.dialog.actions.save"})})]})]})})}function fa(s){return!s||s.length<=4?"****":s.substring(0,4)+"****"}function ja({server:s,enabled:t,isExpanded:a,onToggleExpand:o,isEditable:c=!1,onRemove:n,onToggle:w,isRemoving:p=!1,isToggling:f=!1}){const{formatMessage:d}=G(),[S,m]=h.useState(!1),[g,y]=h.useState({}),u=de(s),b=me(s),v=()=>{var r;return u?s.url:`${s.command||""} ${((r=s.args)==null?void 0:r.join(" "))||""}`.trim()},k=()=>{if(!u)return[];const r=[];return s.httpHeaders&&Object.entries(s.httpHeaders).forEach(([x,E])=>{r.push({name:x,value:E})}),s.bearerTokenEnvVar&&r.push({name:"Authorization",value:`Bearer $${s.bearerTokenEnvVar}`,isEnvVar:!0}),s.headers&&Object.entries(s.headers).forEach(([x,E])=>{r.push({name:x,value:E})}),r},j=r=>{y(x=>({...x,[r]:!x[r]}))},M=async()=>{w&&await w(s.name,!t)},T=async()=>{n&&(await n(s.name),m(!1))},F=r=>{r.stopPropagation()};return e.jsxs(Z,{className:H("overflow-hidden",!t&&"opacity-60"),children:[e.jsx("div",{className:"p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:o,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:H("p-2 rounded-lg",t?"bg-primary/10":"bg-muted"),children:e.jsx(qe,{className:H("w-5 h-5",t?"text-primary":"text-muted-foreground")})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:s.name}),u&&e.jsxs(I,{variant:"outline",className:"text-xs text-blue-600 border-blue-300",children:[e.jsx(Ws,{className:"w-3 h-3 mr-1"}),d({id:"mcp.transport.http"})]}),c?e.jsxs(e.Fragment,{children:[e.jsxs(I,{variant:"secondary",className:"text-xs flex items-center gap-1",children:[e.jsx(Fs,{className:"w-3 h-3"}),d({id:"mcp.codex.editable"})]}),t&&e.jsxs(I,{variant:"outline",className:"text-xs text-green-600",children:[e.jsx(ke,{className:"w-3 h-3 mr-1"}),d({id:"mcp.status.enabled"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(I,{variant:"secondary",className:"text-xs flex items-center gap-1",children:[e.jsx(Ps,{className:"w-3 h-3"}),d({id:"mcp.codex.readOnly"})]}),t&&e.jsxs(I,{variant:"outline",className:"text-xs text-green-600",children:[e.jsx(ke,{className:"w-3 h-3 mr-1"}),d({id:"mcp.status.enabled"})]})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 font-mono truncate max-w-md",title:v(),children:v()})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[c?e.jsxs(e.Fragment,{children:[e.jsx(D,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:r=>{F(r),M()},disabled:f,children:t?e.jsx(ke,{className:"w-4 h-4 text-green-600"}):e.jsx(ss,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs(is,{open:S,onOpenChange:m,children:[e.jsx(Qt,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:F,disabled:p,children:e.jsx(Me,{className:"w-4 h-4 text-destructive"})})}),e.jsxs(ds,{children:[e.jsxs(ms,{children:[e.jsx(xs,{children:d({id:"mcp.codex.deleteConfirm.title"},{name:s.name})}),e.jsx(us,{children:d({id:"mcp.codex.deleteConfirm.description"},{name:s.name})})]}),e.jsxs(ps,{children:[e.jsx(hs,{disabled:p,children:d({id:"mcp.codex.deleteConfirm.cancel"})}),e.jsx(gs,{onClick:T,disabled:p,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"animate-spin mr-2",children:"◌"}),d({id:"mcp.codex.deleteConfirm.deleting"})]}):d({id:"mcp.codex.deleteConfirm.confirm"})})]})]})]})]}):e.jsx(e.Fragment,{children:e.jsx("div",{className:H("w-8 h-8 rounded-md flex items-center justify-center",t?"bg-green-100 text-green-600":"bg-muted text-muted-foreground"),children:t?e.jsx(ke,{className:"w-4 h-4"}):e.jsx(ss,{className:"w-4 h-4"})})}),a?e.jsx(Is,{className:"w-5 h-5 text-muted-foreground"}):e.jsx(os,{className:"w-5 h-5 text-muted-foreground"})]})]})}),a&&e.jsxs("div",{className:"border-t border-border p-4 space-y-3 bg-muted/30",children:[u&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:d({id:"mcp.http.url"})}),e.jsx("code",{className:"text-sm bg-background px-2 py-1 rounded block overflow-x-auto break-all",children:s.url})]}),k().length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:d({id:"mcp.http.headers"})}),e.jsx("div",{className:"space-y-1",children:k().map(r=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(I,{variant:"secondary",className:"font-mono",children:r.name}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"text-xs bg-background px-2 py-1 rounded flex-1 overflow-x-auto",children:g[r.name]?r.value:fa(r.value)}),e.jsx(D,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>j(r.name),title:g[r.name]?d({id:"mcp.http.hideValue"}):d({id:"mcp.http.showValue"}),children:g[r.name]?e.jsx(fs,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(js,{className:"w-3 h-3 text-muted-foreground"})}),r.isEnvVar&&e.jsx(I,{variant:"outline",className:"text-xs text-blue-500",children:d({id:"mcp.http.envVar"})})]},r.name))})]})]}),b&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:d({id:"mcp.command"})}),e.jsx("code",{className:"text-sm bg-background px-2 py-1 rounded block overflow-x-auto",children:s.command})]}),s.args&&s.args.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:d({id:"mcp.args"})}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.args.map((r,x)=>e.jsx(I,{variant:"outline",className:"font-mono text-xs",children:r},x))})]}),s.env&&Object.keys(s.env).length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:d({id:"mcp.env"})}),e.jsx("div",{className:"space-y-1",children:Object.entries(s.env).map(([r,x])=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(I,{variant:"secondary",className:"font-mono",children:r}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"text-xs bg-background px-2 py-1 rounded flex-1 overflow-x-auto",children:x})]},r))})]})]}),e.jsx("div",{className:H("flex items-center gap-2 px-3 py-2 rounded-md border",c?"bg-info/10 border-info/20":"bg-muted/50 border-border"),children:c?e.jsxs(e.Fragment,{children:[e.jsx(Fs,{className:"w-4 h-4 text-info"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d({id:"mcp.codex.editableNotice"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ps,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d({id:"mcp.codex.readOnlyNotice"})})]})})]})]})}const Es=[{name:"write_file",desc:"Write/create files",core:!0},{name:"edit_file",desc:"Edit/replace content",core:!0},{name:"read_file",desc:"Read single file",core:!0},{name:"read_many_files",desc:"Read multiple files/dirs",core:!0},{name:"core_memory",desc:"Core memory management",core:!0},{name:"ask_question",desc:"Interactive questions (A2UI)",core:!1},{name:"smart_search",desc:"Intelligent code search",core:!0},{name:"team_msg",desc:"Agent team message bus",core:!1}];function Ds({isInstalled:s,enabledTools:t,projectRoot:a,allowedDirs:o,enableSandbox:c,onToggleTool:n,onUpdateConfig:w,onInstall:p,target:f="claude",installedScopes:d=[],onUninstallScope:S}){const{formatMessage:m}=G(),g=te(),{success:y,error:u}=Ve(),b=xe(ue),[v,k]=h.useState(a||""),[j,M]=h.useState(o||""),[T,F]=h.useState(c||!1),[r,x]=h.useState(!1),[E,O]=h.useState("global"),[V,$]=h.useState(!1),[W,J]=h.useState(null),U=f==="codex",N=se({mutationFn:U?()=>ft():q=>Vs(q.scope,q.projectPath),onSuccess:()=>{U?(g.invalidateQueries({queryKey:["codexMcpServers"]}),g.invalidateQueries({queryKey:["ccwMcpConfigCodex"]})):(g.invalidateQueries({queryKey:B.all}),g.invalidateQueries({queryKey:["ccwMcpConfig"]})),p()}}),L=se({mutationFn:U?jt:vt,onSuccess:()=>{U?(g.invalidateQueries({queryKey:["codexMcpServers"]}),g.invalidateQueries({queryKey:["ccwMcpConfigCodex"]})):(g.invalidateQueries({queryKey:B.all}),g.invalidateQueries({queryKey:["ccwMcpConfig"]})),p()},onError:q=>{console.error("Failed to uninstall CCW MCP:",q)}}),A=se({mutationFn:U?Ze:Xe,onSuccess:()=>{U?(g.invalidateQueries({queryKey:["codexMcpServers"]}),g.invalidateQueries({queryKey:["ccwMcpConfigCodex"]})):(g.invalidateQueries({queryKey:B.all}),g.invalidateQueries({queryKey:["ccwMcpConfig"]})),y(m({id:"mcp.ccw.feedback.saveSuccess"}))},onError:q=>{console.error("Failed to update CCW config:",q),u(m({id:"mcp.ccw.feedback.saveError"}),q instanceof Error?q.message:String(q))}}),re=(q,ae)=>{n(q,ae)},oe=()=>{const q=Es.map(ae=>ae.name);w({enabledTools:q})},we=()=>{w({enabledTools:[]})},je=()=>{A.mutate({enabledTools:t,projectRoot:v||void 0,allowedDirs:j||void 0,enableSandbox:T})},Fe=()=>{U?N.mutate(void 0):N.mutate({scope:E,projectPath:E==="project"?b:void 0})},le=()=>{confirm(m({id:"mcp.ccw.actions.uninstallConfirm"}))&&L.mutate()},ve=N.isPending||L.isPending||A.isPending;return e.jsxs(Z,{className:H("overflow-hidden border-2",s?"border-primary/50 bg-primary/5":"border-dashed"),children:[e.jsx("div",{className:"p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>x(!r),children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:H("p-2 rounded-lg",s?"bg-primary/20":"bg-muted"),children:e.jsx(be,{className:H("w-5 h-5",s?"text-primary":"text-muted-foreground")})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:m({id:"mcp.ccw.title"})}),s&&d.length>0?e.jsxs(e.Fragment,{children:[d.map(q=>e.jsxs(I,{variant:"default",className:"text-xs",children:[q==="global"?e.jsx(fe,{className:"w-3 h-3 mr-1"}):e.jsx(ye,{className:"w-3 h-3 mr-1"}),m({id:`mcp.ccw.scope.${q}`})]},q)),d.length>=2&&e.jsxs(I,{variant:"outline",className:"text-xs text-orange-500 border-orange-300",children:[e.jsx(Qe,{className:"w-3 h-3 mr-1"}),m({id:"mcp.conflict.badge"})]})]}):e.jsx(I,{variant:s?"default":"secondary",className:"text-xs",children:m(s?{id:"mcp.ccw.status.installed"}:{id:"mcp.ccw.status.notInstalled"})}),U&&e.jsx(I,{variant:"outline",className:"text-xs text-blue-500",children:"Codex"}),s&&e.jsx(I,{variant:"outline",className:"text-xs text-info",children:m({id:"mcp.ccw.status.special"})})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:m({id:"mcp.ccw.description"})})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:r?e.jsx(os,{className:"w-5 h-5 text-muted-foreground"}):e.jsx(Qs,{className:"w-5 h-5 text-muted-foreground"})})]})}),r&&e.jsxs("div",{className:"border-t border-border p-4 space-y-4 bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:oe,disabled:!s,children:[e.jsx(Ls,{className:"w-4 h-4 mr-1"}),m({id:"mcp.ccw.actions.enableAll"})]}),e.jsx(D,{variant:"outline",size:"sm",onClick:we,disabled:!s,children:m({id:"mcp.ccw.actions.disableAll"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase",children:m({id:"mcp.ccw.tools.label"})}),!s&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-500",children:m({id:"mcp.ccw.tools.hint"})})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Es.map(q=>{const ae=t.includes(q.name),Ce=va(q.name);return e.jsxs("div",{className:H("flex items-center gap-3 p-2 rounded-lg transition-colors border",ae?"bg-background border-primary/40":"bg-background border-border"),children:[e.jsx("input",{type:"checkbox",id:`ccw-tool-${q.name}`,checked:ae,onChange:Ee=>re(q.name,Ee.target.checked),disabled:!s,className:"w-4 h-4"}),e.jsxs("label",{htmlFor:`ccw-tool-${q.name}`,className:"flex items-center gap-2 flex-1 cursor-pointer",children:[Ce,e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:m({id:`mcp.ccw.tools.${q.name}.name`})}),q.core&&e.jsx(I,{variant:"secondary",className:"text-xs",children:m({id:"mcp.ccw.tools.core"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m({id:`mcp.ccw.tools.${q.name}.desc`})})]})]})]},q.name)})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-foreground flex items-center gap-1",children:[e.jsx(Xt,{className:"w-4 h-4"}),m({id:"mcp.ccw.paths.projectRoot"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{value:v,onChange:q=>k(q.target.value),placeholder:m({id:"mcp.ccw.paths.projectRootPlaceholder"}),disabled:!s,className:"font-mono text-sm"}),e.jsx(D,{variant:"outline",size:"icon",onClick:()=>{J("projectRoot"),$(!0)},disabled:!s,title:"Browse for project root",children:e.jsx(Le,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-foreground flex items-center gap-1",children:[e.jsx(Ht,{className:"w-4 h-4"}),m({id:"mcp.ccw.paths.allowedDirs"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{value:j,onChange:q=>M(q.target.value),placeholder:m({id:"mcp.ccw.paths.allowedDirsPlaceholder"}),disabled:!s,className:"font-mono text-sm"}),e.jsx(D,{variant:"outline",size:"icon",onClick:()=>{J("allowedDirs"),$(!0)},disabled:!s,title:"Browse for allowed directories",children:e.jsx(Le,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m({id:"mcp.ccw.paths.allowedDirsHint"})})]}),s&&e.jsx("div",{className:"flex justify-end",children:e.jsxs(D,{variant:"default",size:"sm",onClick:je,disabled:ve,children:[e.jsx(_t,{className:"w-4 h-4 mr-1"}),m({id:"mcp.ccw.actions.saveConfig"})]})}),e.jsx("div",{className:"border-t border-border pt-4 space-y-2",children:s?e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:d.length>0&&S?d.map(q=>e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>S(q),disabled:ve,className:"text-destructive border-destructive/50 hover:bg-destructive/10",children:[e.jsx(Me,{className:"w-4 h-4 mr-1"}),m({id:"mcp.ccw.actions.uninstallScope"},{scope:q})]},q)):e.jsxs(D,{variant:"outline",size:"sm",onClick:le,disabled:ve,className:"text-destructive border-destructive/50 hover:bg-destructive/10",children:[e.jsx(Me,{className:"w-4 h-4 mr-1"}),m({id:"mcp.ccw.actions.uninstall"})]})}):e.jsxs("div",{className:"flex items-center gap-2",children:[!U&&e.jsxs("select",{value:E,onChange:q=>O(q.target.value),className:"text-sm border border-border rounded px-2 py-1 bg-background text-foreground",children:[e.jsx("option",{value:"global",children:m({id:"mcp.ccw.scope.global"})}),e.jsx("option",{value:"project",children:m({id:"mcp.ccw.scope.project"})})]}),e.jsxs(D,{variant:"default",size:"sm",onClick:Fe,disabled:ve,children:[e.jsx(Ke,{className:"w-4 h-4 mr-1"}),m({id:"mcp.ccw.actions.install"})]})]})})]}),e.jsx(Vt,{isOpen:V,onClose:()=>$(!1),rootPath:b||"/",onInsertPath:q=>{W==="projectRoot"?k(q):W==="allowedDirs"&&M(ae=>ae?`${ae},${q}`:q),$(!1)}})]})}function va(s){const t={className:"w-4 h-4 text-muted-foreground"};switch(s){case"write_file":return e.jsx(Rt,{...t});case"edit_file":return e.jsx(Ls,{...t});case"read_file":return e.jsx(Hs,{...t});case"read_many_files":return e.jsx(Zt,{...t});case"core_memory":return e.jsx(be,{...t});case"ask_question":return e.jsx(sa,{...t});case"smart_search":return e.jsx(ta,{...t});case"team_msg":return e.jsx($t,{...t});default:return e.jsx(be,{...t})}}const ya=300;function Na({template:s,onInstall:t,onDelete:a,isInstalling:o,isDeleting:c}){const{formatMessage:n}=G(),w=()=>{t(s)},p=()=>{a(s.name)},f=()=>{var S;const d={className:"w-4 h-4"};switch((S=s.category)==null?void 0:S.toLowerCase()){case"stdio":case"transport":return e.jsx(yt,{...d});case"language":case"python":case"node":return e.jsx(ye,{...d});case"official":case"builtin":return e.jsx(fe,{...d});default:return e.jsx(ls,{...d})}};return e.jsx(Z,{className:"p-4 hover:border-primary/50 transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"p-2 rounded-lg bg-muted flex-shrink-0",children:f()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:s.name}),s.category&&e.jsx(I,{variant:"secondary",className:"text-xs",children:s.category})]}),s.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:s.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("code",{className:"text-xs bg-muted px-2 py-1 rounded font-mono truncate max-w-[150px]",children:s.serverConfig.command}),s.serverConfig.args&&s.serverConfig.args.length>0&&e.jsxs(I,{variant:"outline",className:"text-xs",children:[s.serverConfig.args.length," args"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(D,{variant:"ghost",size:"sm",onClick:w,disabled:o,title:n({id:"mcp.templates.actions.install"}),children:e.jsx(Ke,{className:"w-4 h-4"})}),e.jsx(D,{variant:"ghost",size:"sm",onClick:p,disabled:c,title:n({id:"mcp.templates.actions.delete"}),children:e.jsx(Me,{className:"w-4 h-4"})})]})]})})}function Zs({open:s,onClose:t,onSave:a,defaultName:o="",defaultCommand:c="",defaultArgs:n=[],defaultEnv:w={}}){const{formatMessage:p}=G(),[f,d]=h.useState(o),[S,m]=h.useState(""),[g,y]=h.useState(""),[u,b]=h.useState(c),[v,k]=h.useState(n.join(", ")),[j,M]=h.useState(Object.entries(w).map(([x,E])=>`${x}=${E}`).join(`
47
- `)),[T,F]=h.useState({});h.useEffect(()=>{s&&(d(o||""),m(""),y(""),b(c||""),k((n||[]).join(", ")),M(Object.entries(w||{}).map(([x,E])=>`${x}=${E}`).join(`
48
- `)),F({}))},[s,o,c,n,w]);const r=()=>{const x={};if(f.trim()||(x.name=p({id:"mcp.templates.saveDialog.validation.nameRequired"})),u.trim()||(x.command=p({id:"mcp.dialog.validation.commandRequired"})),Object.keys(x).length>0){F(x);return}const E=v.split(",").map(V=>V.trim()).filter(V=>V.length>0),O={};for(const V of j.split(`
49
- `)){const $=V.trim();if($&&$.includes("=")){const[W,...J]=$.split("=");W&&(O[W.trim()]=J.join("=").trim())}}a(f.trim(),S.trim(),g.trim(),{command:u.trim(),args:E,env:O})};return e.jsx(ts,{open:s,onOpenChange:t,children:e.jsxs(as,{className:"max-w-md max-h-[85vh] overflow-y-auto",children:[e.jsx(ns,{children:e.jsx(rs,{children:p({id:"mcp.templates.saveDialog.title"})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-sm font-medium text-foreground",children:[p({id:"mcp.templates.saveDialog.name"}),e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(X,{value:f,onChange:x=>{d(x.target.value),T.name&&F(E=>({...E,name:void 0}))},placeholder:p({id:"mcp.templates.saveDialog.namePlaceholder"}),error:!!T.name}),T.name&&e.jsx("p",{className:"text-sm text-destructive",children:T.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-sm font-medium text-foreground",children:[p({id:"mcp.dialog.form.command"}),e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(X,{value:u,onChange:x=>{b(x.target.value),T.command&&F(E=>({...E,command:void 0}))},placeholder:p({id:"mcp.dialog.form.commandPlaceholder"}),error:!!T.command}),T.command&&e.jsx("p",{className:"text-sm text-destructive",children:T.command})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:p({id:"mcp.dialog.form.args"})}),e.jsx(X,{value:v,onChange:x=>k(x.target.value),placeholder:p({id:"mcp.dialog.form.argsPlaceholder"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p({id:"mcp.dialog.form.argsHint"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:p({id:"mcp.dialog.form.env"})}),e.jsx("textarea",{value:j,onChange:x=>M(x.target.value),placeholder:p({id:"mcp.dialog.form.envPlaceholder"}),className:"flex min-h-[60px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm font-mono ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:p({id:"mcp.templates.saveDialog.category"})}),e.jsxs(He,{value:S,onValueChange:m,children:[e.jsx(_e,{className:"w-full",children:e.jsx($e,{placeholder:p({id:"mcp.templates.saveDialog.categoryPlaceholder"})})}),e.jsxs(Re,{children:[e.jsx(pe,{value:"stdio",children:"STDIO"}),e.jsx(pe,{value:"sse",children:"SSE"}),e.jsx(pe,{value:"language",children:"Language"}),e.jsx(pe,{value:"official",children:"Official"}),e.jsx(pe,{value:"custom",children:"Custom"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:p({id:"mcp.templates.saveDialog.description"})}),e.jsx("textarea",{value:g,onChange:x=>y(x.target.value),placeholder:p({id:"mcp.templates.saveDialog.descriptionPlaceholder"}),className:"flex min-h-[60px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]})]}),e.jsxs(cs,{children:[e.jsx(D,{variant:"outline",onClick:t,children:p({id:"mcp.templates.saveDialog.cancel"})}),e.jsx(D,{onClick:r,children:p({id:"mcp.templates.saveDialog.save"})})]})]})})}function ba({onInstallTemplate:s,onSaveAsTemplate:t}){const{formatMessage:a}=G(),[o,c]=h.useState(""),[n,w]=h.useState(""),[p,f]=h.useState("all"),[d,S]=h.useState(!1),[m,g]=h.useState(!1),[y,u]=h.useState(null),{data:b=[],isLoading:v}=ge({queryKey:he.categories(),queryFn:Nt,staleTime:600*1e3}),k=ia(),j=da();h.useEffect(()=>{const O=setTimeout(()=>{w(o)},ya);return()=>clearTimeout(O)},[o]);const{data:M=[],isLoading:T}=ge({queryKey:he.list(p==="all"?void 0:p),queryFn:async()=>{if(n.trim())return bt(n.trim());if(p==="all"){const O=[];for(const V of b){const $=await ks(V);O.push(...$)}return O}else return ks(p)},staleTime:300*1e3,enabled:!v}),F=h.useCallback(O=>{s==null||s(O)},[s]),r=h.useCallback(O=>{u(O),g(!0)},[]),x=h.useCallback(async()=>{if(!y)return;(await k.deleteTemplate(y)).success&&(g(!1),u(null))},[y,k]),E=h.useCallback((O,V,$,W)=>{t==null||t(O,V,$,W),S(!1)},[t]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(Ae,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(X,{value:o,onChange:O=>c(O.target.value),placeholder:a({id:"mcp.templates.searchPlaceholder"}),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Wt,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs(He,{value:p,onValueChange:f,children:[e.jsx(_e,{className:"w-[150px]",children:e.jsx($e,{})}),e.jsxs(Re,{children:[e.jsx(pe,{value:"all",children:a({id:"mcp.templates.filter.allCategories"})}),b.map(O=>e.jsx(pe,{value:O,children:O},O))]})]})]})]}),e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>S(!0),children:[e.jsx(Ie,{className:"w-4 h-4 mr-1"}),a({id:"mcp.templates.actions.saveAsTemplate"})]})]}),T?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:a({id:"mcp.templates.loading"})})}):M.length===0?e.jsxs(Z,{className:"p-12 text-center",children:[e.jsx(ls,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-foreground mb-2",children:a({id:"mcp.templates.empty.title"})}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:a({id:"mcp.templates.empty.message"})}),e.jsxs(D,{onClick:()=>S(!0),children:[e.jsx(Ie,{className:"w-4 h-4 mr-1"}),a({id:"mcp.templates.empty.createFirst"})]})]}):e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:M.map(O=>e.jsx(Na,{template:O,onInstall:F,onDelete:r,isInstalling:j.isInstalling,isDeleting:k.isDeleting},O.name))}),e.jsx(Zs,{open:d,onClose:()=>S(!1),onSave:E}),e.jsx(is,{open:m,onOpenChange:g,children:e.jsxs(ds,{children:[e.jsxs(ms,{children:[e.jsx(xs,{children:a({id:"mcp.templates.deleteDialog.title"})}),e.jsx(us,{children:a({id:"mcp.templates.deleteDialog.message"},{name:y})})]}),e.jsxs(ps,{children:[e.jsx(hs,{children:a({id:"mcp.templates.deleteDialog.cancel"})}),e.jsx(gs,{onClick:x,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:k.isDeleting?a({id:"mcp.templates.deleteDialog.deleting"}):a({id:"mcp.templates.deleteDialog.delete"})})]})]})})]})}const wa={"search-code":Ae,chrome:fe,"globe-2":_s,"code-2":be};function Ca({open:s,onClose:t,mcpDefinition:a,onInstallComplete:o}){const{formatMessage:c}=G(),n=te(),{success:w,error:p}=Ve(),f=xe(ue),[d,S]=h.useState({}),[m,g]=h.useState("global"),y=()=>{if(!a)return;const r={};for(const x of a.fields)x.default!==void 0?r[x.key]=x.default:x.type==="multi-select"?r[x.key]=[]:r[x.key]="";S(r)},u=r=>{r&&a?y():(S({}),t())},b=se({mutationFn:async()=>{if(!a)throw new Error("No MCP definition");const r=a.buildConfig(d);if(m==="global")return wt(a.id,r);if(!f)throw new Error("Project path is required to install to project scope");return Ct(a.id,r,f)},onSuccess:r=>{r.success?(n.invalidateQueries({queryKey:B.all}),w(c({id:"mcp.wizard.installSuccess"}),c({id:a.nameKey})),u(!1),o==null||o()):p(c({id:"mcp.wizard.installError"}),r.error||"Unknown error")},onError:r=>{p(c({id:"mcp.wizard.installError"}),r.message)}}),v=(r,x)=>{S(E=>({...E,[r]:x}))},k=(r,x)=>{const E=d[r]||[],O=E.includes(x)?E.filter(V=>V!==x):[...E,x];v(r,O)},j=()=>{if(!a)return!1;for(const r of a.fields)if(r.required){const x=d[r.key];if(r.type==="multi-select"){if(!x||x.length===0)return!1}else if(!x||x.trim()==="")return!1}return!0},M=()=>{if(!j()){p(c({id:"mcp.wizard.validation"}),c({id:"mcp.wizard.requiredFields"}));return}b.mutate()};if(!a)return null;const T=a.fields.length>0,F=wa[a.icon]||be;return e.jsx(ts,{open:s,onOpenChange:u,children:e.jsxs(as,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(ns,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-primary/10 rounded-lg flex items-center justify-center",children:e.jsx(F,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsxs(rs,{children:[c({id:"mcp.wizard.install"})," ",c({id:a.nameKey})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c({id:a.descKey})})]})]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[T&&e.jsx("div",{className:"space-y-3",children:a.fields.map(r=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(Ts,{className:"flex items-center gap-1.5 text-sm font-medium",children:[c({id:r.labelKey}),r.required&&e.jsx("span",{className:"text-destructive",children:"*"})]}),r.descKey&&e.jsx("p",{className:"text-xs text-muted-foreground",children:c({id:r.descKey})}),(r.type==="text"||r.type==="password")&&e.jsx(X,{type:r.type,value:d[r.key]||"",onChange:x=>v(r.key,x.target.value),placeholder:r.placeholder,className:"font-mono text-sm"}),r.type==="multi-select"&&r.options&&e.jsx("div",{className:"space-y-2 p-2 bg-muted/30 border border-border rounded-lg max-h-48 overflow-y-auto",children:r.options.map(x=>{const E=(d[r.key]||[]).includes(x.value);return e.jsxs("div",{className:H("flex items-start gap-2 p-2 rounded transition-colors cursor-pointer",E?"bg-primary/10":"hover:bg-muted/50"),onClick:()=>k(r.key,x.value),children:[e.jsx("input",{type:"checkbox",checked:E,onChange:()=>{},className:"mt-0.5 w-4 h-4"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:x.label}),x.desc&&e.jsx("div",{className:"text-xs text-muted-foreground",children:x.desc})]})]},x.value)})})]},r.key))}),e.jsxs("div",{className:"space-y-2 pt-3 border-t border-border",children:[e.jsx(Ts,{className:"text-sm font-medium",children:c({id:"mcp.wizard.scope"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{variant:m==="global"?"default":"outline",size:"sm",onClick:()=>g("global"),className:"flex-1",children:c({id:"mcp.wizard.scope.global"})}),e.jsx(D,{variant:m==="project"?"default":"outline",size:"sm",onClick:()=>g("project"),className:"flex-1",children:c({id:"mcp.wizard.scope.project"})})]})]}),!T&&e.jsx("div",{className:"p-3 bg-success/10 border border-success/20 rounded-lg text-sm text-success",children:c({id:"mcp.noConfigNeeded"})})]}),e.jsxs(cs,{children:[e.jsx(D,{variant:"outline",onClick:()=>u(!1),disabled:b.isPending,children:c({id:"mcp.dialog.actions.cancel"})}),e.jsx(D,{onClick:M,disabled:b.isPending,children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"w-4 h-4 mr-1 animate-spin"}),c({id:"mcp.wizard.installing"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"w-4 h-4 mr-1"}),c({id:"mcp.wizard.install"})]})})]})]})})}var qs;const Sa=typeof navigator<"u"&&((qs=navigator.platform)==null?void 0:qs.toLowerCase().includes("win"));function Ge(s,t=[],a={}){const{env:o,type:c}=a,p=Sa&&["npx","npm","node","python","python3","pip","pip3","pnpm","yarn","bun"].includes(s.toLowerCase())?{command:"cmd",args:["/c",s,...t]}:{command:s,args:t};return c&&(p.type=c),o&&Object.keys(o).length>0&&(p.env=o),p}const ka=[{id:"ace-tool",nameKey:"mcp.ace-tool.name",descKey:"mcp.ace-tool.desc",icon:"search-code",category:"search",fields:[{key:"baseUrl",labelKey:"mcp.ace-tool.field.baseUrl",type:"text",default:"https://acemcp.heroman.wtf/relay/",placeholder:"https://acemcp.heroman.wtf/relay/",required:!0,descKey:"mcp.ace-tool.field.baseUrl.desc"},{key:"token",labelKey:"mcp.ace-tool.field.token",type:"password",default:"",placeholder:"ace_xxxxxxxxxxxxxxxx",required:!0,descKey:"mcp.ace-tool.field.token.desc"}],buildConfig:s=>Ge("npx",["ace-tool","--base-url",s.baseUrl||"https://acemcp.heroman.wtf/relay/","--token",s.token])},{id:"chrome-devtools",nameKey:"mcp.chrome-devtools.name",descKey:"mcp.chrome-devtools.desc",icon:"chrome",category:"browser",fields:[],buildConfig:()=>Ge("npx",["chrome-devtools-mcp@latest"],{type:"stdio"})},{id:"exa",nameKey:"mcp.exa.name",descKey:"mcp.exa.desc",icon:"globe-2",category:"search",fields:[{key:"apiKey",labelKey:"mcp.exa.field.apiKey",type:"password",default:"",placeholder:"your-exa-api-key",required:!1,descKey:"mcp.exa.field.apiKey.desc"}],buildConfig:s=>{const t=s.apiKey?{EXA_API_KEY:s.apiKey}:void 0;return Ge("npx",["-y","exa-mcp-server"],{env:t})}}],Ta={"search-code":Ae,chrome:fe,"globe-2":_s,"code-2":kt};function Ma({definition:s,isInstalled:t,onInstall:a}){const{formatMessage:o}=G(),c=Ta[s.icon]||be,n=s.fields.length>0;return e.jsx(Z,{className:"p-4 hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:H("p-2.5 rounded-lg",t?"bg-primary/20":"bg-muted"),children:e.jsx(c,{className:H("w-5 h-5",t?"text-primary":"text-muted-foreground")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground truncate",children:o({id:s.nameKey})}),t&&e.jsx(I,{variant:"default",className:"text-xs",children:o({id:"mcp.recommended.actions.installed"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mb-3",children:o({id:s.descKey})}),e.jsxs("div",{className:"flex items-center justify-between",children:[n?e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(ea,{className:"w-3 h-3"}),s.fields.length," ",o({id:"mcp.configRequired"})]}):e.jsxs("span",{className:"text-xs text-green-600 dark:text-green-400 flex items-center gap-1",children:[e.jsx(Tt,{className:"w-3 h-3"}),o({id:"mcp.noConfigNeeded"})]}),e.jsx(D,{variant:t?"outline":"default",size:"sm",onClick:()=>a(s),children:t?e.jsxs(e.Fragment,{children:[e.jsx(be,{className:"w-3.5 h-3.5 mr-1"}),o({id:"mcp.reconfigure"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"w-3.5 h-3.5 mr-1"}),o({id:"mcp.recommended.actions.install"})]})})]})]})]})})}function Pa({onInstallComplete:s}){const{formatMessage:t}=G(),[a,o]=h.useState(!1),[c,n]=h.useState(null),[w,p]=h.useState(new Set),f=async()=>{var g;try{const y=await St(),u=new Set,b=y.globalServers||{},v=y.userServers||{};for(const j of Object.keys(b))u.add(j);for(const j of Object.keys(v))u.add(j);const k=y.projects||{};for(const j of Object.values(k)){const M=j.mcpServers||{};for(const T of Object.keys(M))u.add(T)}if((g=y.codex)!=null&&g.servers)for(const j of Object.keys(y.codex.servers))u.add(j);p(u)}catch{}};h.useEffect(()=>{f()},[]);const d=g=>{n(g),o(!0)},S=()=>{o(!1),n(null)},m=()=>{f(),s==null||s()};return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:t({id:"mcp.recommended.title"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t({id:"mcp.recommended.description"})})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:ka.map(g=>e.jsx(Ma,{definition:g,isInstalled:w.has(g.id),onInstall:d},g.id))})]}),e.jsx(Ca,{open:a,onClose:S,mcpDefinition:c,onInstallComplete:m})]})}const Fa=[{name:"npm",installUrl:"https://docs.npmjs.com/downloading-and-installing-node-js-and-npm"},{name:"node",installUrl:"https://nodejs.org/"},{name:"python",installUrl:"https://www.python.org/downloads/"},{name:"npx",installUrl:"https://docs.npmjs.com/downloading-and-installing-node-js-and-npm"}];function Ea(s){return Fa.some(t=>t.name===s)}async function Da(s){const t=await fetch("/api/mcp/detect-commands",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:s})});if(!t.ok)throw new Error("Failed to detect commands");return t.json()}async function qa(s){const t=await fetch("/api/mcp/apply-windows-fix",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:s})});if(!t.ok)throw new Error("Failed to apply Windows fix");return t.json()}function Oa({commands:s}){const{formatMessage:t}=G();return e.jsx("div",{className:"space-y-2 mt-3",children:s.map(a=>e.jsxs("div",{className:H("flex items-center gap-2 text-sm p-2 rounded-md",a.available?"bg-success/10":"bg-destructive/10"),children:[a.available?e.jsx($s,{className:"w-4 h-4 text-success"}):e.jsx(Mt,{className:"w-4 h-4 text-destructive"}),e.jsx("code",{className:"font-mono flex-1",children:a.command}),!a.available&&a.installUrl&&e.jsxs("a",{href:a.installUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline flex items-center gap-1",children:[e.jsx(Ke,{className:"w-3 h-3"}),t({id:"mcp.windows.install"})]})]},a.command))})}function Aa({projectPath:s,onComplete:t}){const{formatMessage:a}=G(),o=te(),[c,n]=h.useState(null),[w,p]=h.useState(!1),[f,d]=h.useState(!1),S=typeof window<"u"&&window.navigator.platform.toLowerCase().includes("win"),m=se({mutationFn:()=>qa(s),onSuccess:()=>{o.invalidateQueries({queryKey:["mcpServers"]}),t&&c&&t({...c,canAutoFix:!1})}});if(h.useEffect(()=>{if(!S||f)return;(async()=>{p(!0);try{const b=await Da(s),v=b.filter(M=>!M.available).map(M=>M.command),k=v.length>0&&v.every(Ea),j={isWindows:!0,missingCommands:v,commands:b,canAutoFix:k};n(j),t&&t(j)}catch(b){console.error("Failed to check Windows compatibility:",b)}finally{p(!1)}})()},[S,f,s,t]),!S||f||w&&!c||c&&c.missingCommands.length===0)return null;const g=async()=>{m.mutate()},y=()=>{d(!0)};return e.jsx("div",{className:"border border-warning/50 bg-warning/5 rounded-lg p-4 mb-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Qe,{className:"w-5 h-5 text-warning flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold text-foreground",children:a({id:"mcp.windows.title"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:a({id:"mcp.windows.description"})})]}),e.jsx(D,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:y,children:"×"})]}),c&&e.jsxs(e.Fragment,{children:[c.missingCommands.length>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(I,{variant:"warning",className:"text-xs",children:a({id:"mcp.windows.missingCount"},{count:c.missingCommands.length})})}),e.jsx(Oa,{commands:c.commands}),c.canAutoFix&&e.jsxs("div",{className:"flex items-center gap-2 pt-2 border-t border-warning/20",children:[e.jsx(D,{variant:"outline",size:"sm",onClick:g,disabled:m.isPending,className:"text-xs",children:m.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"w-3 h-3 mr-1 animate-spin"}),a({id:"mcp.windows.fixing"})]}):e.jsxs(e.Fragment,{children:[e.jsx($s,{className:"w-3 h-3 mr-1"}),a({id:"mcp.windows.autoFix"})]})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:a({id:"mcp.windows.autoFixHint"})})]})]}),w&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Te,{className:"w-4 h-4 animate-spin"}),a({id:"mcp.windows.checking"})]})]})]})})}function Ka({onSuccess:s,className:t}){const{formatMessage:a}=G(),o=xe(ue),{servers:c}=Us(),[n,w]=h.useState(new Set),[p,f]=h.useState([]),[d,S]=h.useState(new Set),[m,g]=h.useState(!1),[y,u]=h.useState(null),[b,v]=h.useState(!1),[k,j]=h.useState({type:null,copied:0,failed:0});h.useEffect(()=>{(async()=>{g(!0),u(null);try{const L=await Rs();f((L.servers??[]).map(A=>({name:A.name,displayText:de(A)?A.url:me(A)?A.command:"",enabled:A.enabled,selected:!1})))}catch(L){console.error("Failed to load Codex MCP servers:",L),u(a({id:"mcp.sync.codexLoadError"})),f([])}finally{g(!1)}})()},[a]);const M=N=>{w(L=>{const A=new Set(L);return A.has(N)?A.delete(N):A.add(N),A})},T=()=>{w(new Set(c.map(N=>N.name)))},F=()=>{w(new Set)},r=N=>{S(L=>{const A=new Set(L);return A.has(N)?A.delete(N):A.add(N),A}),f(L=>L.map(A=>A.name===N?{...A,selected:!A.selected}:A))},x=()=>{const N=p.map(L=>L.name);S(new Set(N)),f(L=>L.map(A=>({...A,selected:!0})))},E=()=>{S(new Set),f(N=>N.map(L=>({...L,selected:!1})))},O=async()=>{if(n.size!==0){v(!0),j({type:null,copied:0,failed:0});try{const N=await Je({source:"claude",target:"codex",serverNames:Array.from(n),projectPath:o??void 0});if(N.success){const L=N.failed.length,A=N.copied.length;j({type:L>0?"partial":"success",copied:A,failed:L}),s==null||s(A,"to-codex"),w(new Set),setTimeout(()=>{j({type:null,copied:0,failed:0})},3e3)}}catch(N){console.error("Failed to copy to Codex:",N),j({type:"partial",copied:0,failed:n.size})}finally{v(!1)}}},V=async()=>{if(!(d.size===0||!o)){v(!0),j({type:null,copied:0,failed:0});try{const N=await Je({source:"codex",target:"claude",serverNames:Array.from(d),projectPath:o});if(N.success){const L=N.failed.length,A=N.copied.length;j({type:L>0?"partial":"success",copied:A,failed:L}),s==null||s(A,"from-codex"),S(new Set),f(re=>re.map(oe=>({...oe,selected:!1}))),setTimeout(()=>{j({type:null,copied:0,failed:0})},3e3)}}catch(N){console.error("Failed to copy from Codex:",N),j({type:"partial",copied:0,failed:d.size})}finally{v(!1)}}},$=c.length,W=n.size,J=p.length,U=d.size;return e.jsxs("div",{className:H("space-y-4",t),children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:a({id:"mcp.sync.title"})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a({id:"mcp.sync.description"})})]}),k.type!==null&&e.jsxs("div",{className:H("flex items-center gap-2 p-3 rounded-lg border",k.type==="success"?"bg-success/10 border-success/30 text-success":"bg-warning/10 border-warning/30 text-warning"),children:[k.type==="success"?e.jsx(Pt,{className:"w-4 h-4 flex-shrink-0"}):e.jsx(Ft,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm",children:k.type==="success"?a({id:"mcp.sync.copySuccess"},{count:k.copied}):a({id:"mcp.sync.copyPartial"},{copied:k.copied,failed:k.failed})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[e.jsx("div",{className:"bg-muted/50 px-4 py-3 border-b border-border",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground",children:a({id:"mcp.sync.claudeColumn"})}),e.jsx(I,{variant:"outline",className:"text-xs",children:a({id:"mcp.sync.selectedCount"},{count:W,total:$})})]})}),e.jsx("div",{className:"p-2 max-h-64 overflow-y-auto",children:$===0?e.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:a({id:"mcp.sync.noServers"})}):e.jsx("div",{className:"space-y-1",children:c.map(N=>e.jsxs("div",{className:H("flex items-start gap-2 p-2 rounded cursor-pointer transition-colors",n.has(N.name)?"bg-primary/10":"hover:bg-muted/50"),onClick:()=>M(N.name),children:[e.jsx(Ms,{id:`claude-${N.name}`,checked:n.has(N.name),onChange:()=>M(N.name),className:"w-4 h-4 mt-0.5"}),e.jsxs("label",{htmlFor:`claude-${N.name}`,className:"flex-1 min-w-0 cursor-pointer",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:N.name}),N.enabled&&e.jsx(I,{variant:"success",className:"text-xs",children:a({id:"mcp.status.enabled"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono truncate",children:de(N)?N.url:me(N)?N.command:""})]})]},N.name))})}),$>0&&e.jsxs("div",{className:"px-2 py-2 bg-muted/30 border-t border-border flex gap-1",children:[e.jsx(D,{variant:"ghost",size:"sm",onClick:T,className:"flex-1 text-xs",children:a({id:"mcp.sync.selectAll"})}),e.jsx(D,{variant:"ghost",size:"sm",onClick:F,className:"flex-1 text-xs",disabled:W===0,children:a({id:"mcp.sync.clearAll"})})]})]}),e.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[e.jsx("div",{className:"bg-muted/50 px-4 py-3 border-b border-border",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground",children:a({id:"mcp.sync.codexColumn"})}),e.jsx(I,{variant:"outline",className:"text-xs",children:a({id:"mcp.sync.selectedCount"},{count:U,total:J})})]})}),e.jsx("div",{className:"p-2 max-h-64 overflow-y-auto",children:m?e.jsx("div",{className:"py-8 flex items-center justify-center",children:e.jsx(Te,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):y?e.jsx("div",{className:"py-8 text-center text-sm text-destructive",children:y}):J===0?e.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:a({id:"mcp.sync.noServers"})}):e.jsx("div",{className:"space-y-1",children:p.map(N=>e.jsxs("div",{className:H("flex items-start gap-2 p-2 rounded cursor-pointer transition-colors",N.selected?"bg-primary/10":"hover:bg-muted/50"),onClick:()=>r(N.name),children:[e.jsx(Ms,{id:`codex-${N.name}`,checked:N.selected,onChange:()=>r(N.name),className:"w-4 h-4 mt-0.5"}),e.jsxs("label",{htmlFor:`codex-${N.name}`,className:"flex-1 min-w-0 cursor-pointer",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:N.name}),N.enabled&&e.jsx(I,{variant:"success",className:"text-xs",children:a({id:"mcp.status.enabled"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono truncate",children:N.displayText})]})]},N.name))})}),J>0&&e.jsxs("div",{className:"px-2 py-2 bg-muted/30 border-t border-border flex gap-1",children:[e.jsx(D,{variant:"ghost",size:"sm",onClick:x,className:"flex-1 text-xs",children:a({id:"mcp.sync.selectAll"})}),e.jsx(D,{variant:"ghost",size:"sm",onClick:E,className:"flex-1 text-xs",disabled:U===0,children:a({id:"mcp.sync.clearAll"})})]})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx(D,{onClick:O,disabled:W===0||b,variant:"default",className:"min-w-40",children:b?e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"w-4 h-4 mr-2 animate-spin"}),a({id:"mcp.sync.syncInProgress"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ut,{className:"w-4 h-4 mr-2"}),a({id:"mcp.sync.copyToCodex"},{count:W})]})}),e.jsx(D,{onClick:V,disabled:U===0||b||!o,variant:"default",className:"min-w-40",children:b?e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"w-4 h-4 mr-2 animate-spin"}),a({id:"mcp.sync.syncInProgress"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Et,{className:"w-4 h-4 mr-2"}),a({id:"mcp.sync.copyFromCodex"},{count:U})]})})]})]})}function za({onProjectClick:s,onOpenNewWindow:t,className:a,maxProjects:o,projectPaths:c}){const{formatMessage:n}=G(),[w,p]=h.useState("lastModified"),[f,d]=h.useState("desc"),[S,m]=h.useState([]),[g,y]=h.useState(!1),{projects:u,currentProject:b,isLoading:v}=Gs(),k=h.useMemo(()=>{const r=c??u;return o?r.slice(0,o):r},[c,u,o]);h.useEffect(()=>{(async()=>{if(k.length===0){m([]);return}y(!0);try{const x=await Ye(k),E=k.map(O=>{const V=O===b,$=O.split(/[/\\]/).filter(Boolean).pop()||O,W=x.servers[O]??[];return{name:$,path:O,serverCount:W.length,enabledCount:W.filter(J=>J.enabled).length,lastModified:void 0,isCurrent:V}});m(E)}catch(x){console.error("Failed to fetch project server stats:",x),m(k.map(E=>({name:E.split(/[/\\]/).filter(Boolean).pop()||E,path:E,serverCount:0,enabledCount:0,isCurrent:E===b})))}finally{y(!1)}})()},[k,b]);const j=[...S].sort((r,x)=>{let E=0;switch(w){case"name":E=r.name.localeCompare(x.name);break;case"serverCount":E=r.serverCount-x.serverCount;break;case"lastModified":E=r.lastModified&&x.lastModified?new Date(r.lastModified).getTime()-new Date(x.lastModified).getTime():0;break}return f==="asc"?E:-E}),M=r=>{w===r?d(x=>x==="asc"?"desc":"asc"):(p(r),d("desc"))},T=r=>{s==null||s(r)},F=(r,x)=>{r.stopPropagation(),t==null||t(x)};return v||g?e.jsx(Z,{className:H("p-8",a),children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx("div",{className:"animate-spin text-muted-foreground",children:"-"}),e.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:n({id:"common.actions.loading"})})]})}):j.length===0?e.jsx(Z,{className:H("p-8",a),children:e.jsxs("div",{className:"text-center",children:[e.jsx(ye,{className:"w-12 h-12 mx-auto text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n({id:"mcp.allProjects.empty"})})]})}):e.jsxs(Z,{className:H("overflow-hidden",a),children:[e.jsxs("div",{className:"grid grid-cols-12 gap-2 px-4 py-3 bg-muted/50 border-b border-border text-xs font-medium text-muted-foreground uppercase",children:[e.jsx("div",{className:"col-span-4",children:e.jsxs("button",{onClick:()=>M("name"),className:"flex items-center gap-1 hover:text-foreground transition-colors",children:[n({id:"mcp.allProjects.name"}),w==="name"&&e.jsx("span",{className:"text-foreground",children:f==="asc"?"↑":"↓"})]})}),e.jsx("div",{className:"col-span-3",children:e.jsxs("button",{onClick:()=>M("serverCount"),className:"flex items-center gap-1 hover:text-foreground transition-colors",children:[n({id:"mcp.allProjects.servers"}),w==="serverCount"&&e.jsx("span",{className:"text-foreground",children:f==="asc"?"↑":"↓"})]})}),e.jsx("div",{className:"col-span-3",children:e.jsxs("button",{onClick:()=>M("lastModified"),className:"flex items-center gap-1 hover:text-foreground transition-colors",children:[n({id:"mcp.allProjects.lastModified"}),w==="lastModified"&&e.jsx("span",{className:"text-foreground",children:f==="asc"?"↑":"↓"})]})}),e.jsx("div",{className:"col-span-2 text-right",children:n({id:"mcp.allProjects.actions"})})]}),e.jsx("div",{className:"divide-y divide-border",children:j.map(r=>e.jsxs("div",{onClick:()=>T(r.path),className:H("grid grid-cols-12 gap-2 px-4 py-3 items-center transition-colors cursor-pointer hover:bg-muted/50",r.isCurrent&&"bg-primary/5 hover:bg-primary/10"),children:[e.jsx("div",{className:"col-span-4 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:r.name}),r.isCurrent&&e.jsx(I,{variant:"default",className:"text-xs",children:n({id:"mcp.allProjects.current"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono truncate",children:r.path})]})]})}),e.jsx("div",{className:"col-span-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hs,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm text-foreground",children:[r.serverCount," ",n({id:"mcp.allProjects.servers"})]}),e.jsxs(I,{variant:"outline",className:H("text-xs",r.enabledCount>0?"text-success border-success/30":"text-muted-foreground"),children:[r.enabledCount," ",n({id:"mcp.status.enabled"})]})]})}),e.jsx("div",{className:"col-span-3",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Dt,{className:"w-4 h-4"}),e.jsx("span",{children:r.lastModified?Bt(new Date(r.lastModified),{addSuffix:!0}):"-"})]})}),e.jsx("div",{className:"col-span-2 flex justify-end gap-1",children:e.jsx("button",{onClick:x=>F(x,r.path),className:"p-1.5 rounded hover:bg-muted transition-colors",title:n({id:"mcp.allProjects.openNewWindow"}),children:e.jsx(qt,{className:"w-4 h-4 text-muted-foreground"})})})]},r.path))}),e.jsx("div",{className:"px-4 py-2 bg-muted/30 border-t border-border text-xs text-muted-foreground",children:n({id:"mcp.allProjects.summary"},{count:j.length})})]})}function Ia({onImportSuccess:s,className:t}){const{formatMessage:a}=G(),[o,c]=h.useState(null),[n,w]=h.useState([]),[p,f]=h.useState(!1),{projects:d,currentProject:S,fetchOtherServers:m,isFetchingServers:g}=Gs(),{createServer:y,isCreating:u}=Bs(),b=d.filter(T=>T!==S),v=async T=>{c(T),f(!0);try{const F=await m([T]),r=[];for(const[x,E]of Object.entries(F.servers)){const O=x.split(/[/\\]/).filter(Boolean).pop()||x;for(const V of E)r.push({name:V.name,enabled:V.enabled,displayText:de(V)?V.url:me(V)?V.command:"",transport:V.transport,projectPath:x,projectName:O,originalServer:V})}w(r)}catch(F){console.error("Failed to fetch other projects servers:",F),w([])}finally{f(!1)}},k=async T=>{try{const F=`${T.projectName}-${T.name}`.toLowerCase().replace(/\s+/g,"-"),r={...T.originalServer,name:F,scope:"project"};await y(r),s==null||s(F,T.projectPath)}catch(F){console.error("Failed to import server:",F)}},j=p||g||u,M=o?o.split(/[/\\]/).filter(Boolean).pop():null;return e.jsxs(Z,{className:H("p-4",t),children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{className:"w-5 h-5 text-primary"}),e.jsx("h3",{className:"text-sm font-medium text-foreground",children:a({id:"mcp.otherProjects.title"})})]}),e.jsx(D,{variant:"ghost",size:"sm",onClick:()=>o&&v(o),disabled:!o||j,className:"h-8",children:e.jsx(es,{className:H("w-4 h-4",j&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:a({id:"mcp.otherProjects.description"})}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"text-sm font-medium text-foreground mb-2 block",children:a({id:"mcp.otherProjects.selectProject"})}),e.jsxs(He,{value:o??"",onValueChange:v,children:[e.jsx(_e,{className:"w-full",children:e.jsx($e,{placeholder:a({id:"mcp.otherProjects.selectProjectPlaceholder"})})}),e.jsx(Re,{children:b.length===0?e.jsx("div",{className:"p-2 text-sm text-muted-foreground text-center",children:a({id:"mcp.otherProjects.noProjects"})}):b.map(T=>{const F=T.split(/[/\\]/).filter(Boolean).pop()||T;return e.jsx(pe,{value:T,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:F})]})},T)})})]})]}),o&&e.jsx("div",{className:"space-y-2",children:p?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx("div",{className:"animate-spin text-muted-foreground",children:"-"}),e.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:a({id:"common.actions.loading"})})]}):n.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground border border-dashed rounded-lg",children:a({id:"mcp.otherProjects.noServers"},{project:M})}):e.jsx("div",{className:"space-y-2 max-h-60 overflow-y-auto",children:n.map(T=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:T.name}),T.enabled&&e.jsx(I,{variant:"success",className:"text-xs",children:a({id:"mcp.status.enabled"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono truncate",children:T.displayText}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[e.jsx("span",{className:"font-medium",children:T.projectName}),e.jsx(Qs,{className:"inline w-3 h-3 mx-1"}),e.jsx("span",{className:"font-mono",children:T.projectPath})]})]}),e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>k(T),disabled:u,className:"flex-shrink-0",children:[e.jsx(ls,{className:"w-4 h-4 mr-1"}),a({id:"mcp.otherProjects.import"})]})]},`${T.projectPath}-${T.name}`))})}),o&&n.length>0&&e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:a({id:"mcp.otherProjects.hint"})})]})}function Qa(s){return!s||s.length<=4?"****":s.substring(0,4)+"****"}function La({server:s,isExpanded:t,onToggleExpand:a,onToggle:o,onEdit:c,onDelete:n,onSaveAsTemplate:w,conflictInfo:p}){const{formatMessage:f}=G(),[d,S]=h.useState({}),m=de(s),g=me(s),y=()=>{var v;return m?s.url:`${s.command} ${((v=s.args)==null?void 0:v.join(" "))||""}`.trim()},u=()=>{if(!m)return[];const v=[];return s.headers&&Object.entries(s.headers).forEach(([k,j])=>{v.push({name:k,value:j})}),s.httpHeaders&&Object.entries(s.httpHeaders).forEach(([k,j])=>{v.push({name:k,value:j})}),s.bearerTokenEnvVar&&v.push({name:"Authorization",value:`Bearer $${s.bearerTokenEnvVar}`,isEnvVar:!0}),v},b=v=>{S(k=>({...k,[v]:!k[v]}))};return e.jsxs(Z,{className:H("overflow-hidden",!s.enabled&&"opacity-60"),children:[e.jsx("div",{className:"p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:a,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:H("p-2 rounded-lg",s.enabled?"bg-primary/10":"bg-muted"),children:e.jsx(qe,{className:H("w-5 h-5",s.enabled?"text-primary":"text-muted-foreground")})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:s.name}),m&&e.jsxs(I,{variant:"outline",className:"text-xs text-blue-600 border-blue-300",children:[e.jsx(Ws,{className:"w-3 h-3 mr-1"}),f({id:"mcp.transport.http"})]}),e.jsx(I,{variant:s.scope==="global"?"default":"secondary",className:"text-xs",children:s.scope==="global"?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-3 h-3 mr-1"}),f({id:"mcp.scope.global"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"w-3 h-3 mr-1"}),f({id:"mcp.scope.project"})]})}),p&&e.jsxs(I,{variant:"outline",className:"text-xs text-orange-500 border-orange-300",children:[e.jsx(Qe,{className:"w-3 h-3 mr-1"}),f({id:"mcp.conflict.badge"})]}),s.enabled&&e.jsx(I,{variant:"outline",className:"text-xs text-green-600",children:f({id:"mcp.status.enabled"})})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 font-mono truncate max-w-md",title:y(),children:y()})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:v=>{v.stopPropagation(),o(s.name,!s.enabled)},children:s.enabled?e.jsx(ke,{className:"w-4 h-4 text-green-600"}):e.jsx(ss,{className:"w-4 h-4"})}),e.jsx(D,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:v=>{v.stopPropagation(),w(s)},title:f({id:"mcp.templates.actions.saveAsTemplate"}),children:e.jsx(Jt,{className:"w-4 h-4 text-primary"})}),e.jsx(D,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:v=>{v.stopPropagation(),c(s)},children:e.jsx(Yt,{className:"w-4 h-4"})}),e.jsx(D,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:v=>{v.stopPropagation(),n(s)},children:e.jsx(Me,{className:"w-4 h-4 text-destructive"})}),t?e.jsx(Is,{className:"w-5 h-5 text-muted-foreground"}):e.jsx(os,{className:"w-5 h-5 text-muted-foreground"})]})]})}),t&&e.jsxs("div",{className:"border-t border-border p-4 space-y-3 bg-muted/30",children:[m&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:f({id:"mcp.http.url"})}),e.jsx("code",{className:"text-sm bg-background px-2 py-1 rounded block overflow-x-auto break-all",children:s.url})]}),u().length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:f({id:"mcp.http.headers"})}),e.jsx("div",{className:"space-y-1",children:u().map(v=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(I,{variant:"secondary",className:"font-mono",children:v.name}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"text-xs bg-background px-2 py-1 rounded flex-1 overflow-x-auto",children:d[v.name]?v.value:Qa(v.value)}),e.jsx(D,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>b(v.name),title:d[v.name]?f({id:"mcp.http.hideValue"}):f({id:"mcp.http.showValue"}),children:d[v.name]?e.jsx(fs,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(js,{className:"w-3 h-3 text-muted-foreground"})}),v.isEnvVar&&e.jsx(I,{variant:"outline",className:"text-xs text-blue-500",children:f({id:"mcp.http.envVar"})})]},v.name))})]})]}),g&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:f({id:"mcp.command"})}),e.jsx("code",{className:"text-sm bg-background px-2 py-1 rounded block overflow-x-auto",children:s.command})]}),s.args&&s.args.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:f({id:"mcp.args"})}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.args.map((v,k)=>e.jsx(I,{variant:"outline",className:"font-mono text-xs",children:v},k))})]}),s.env&&Object.keys(s.env).length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:f({id:"mcp.env"})}),e.jsx("div",{className:"space-y-1",children:Object.entries(s.env).map(([v,k])=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(I,{variant:"secondary",className:"font-mono",children:v}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"text-xs bg-background px-2 py-1 rounded flex-1 overflow-x-auto",children:k})]},v))})]})]}),p&&e.jsxs("div",{className:"p-3 bg-orange-50 dark:bg-orange-950/30 border border-orange-200 dark:border-orange-800 rounded-lg space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-orange-700 dark:text-orange-400",children:[e.jsx(Qe,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:f({id:"mcp.conflict.title"})})]}),e.jsx("p",{className:"text-xs text-orange-600 dark:text-orange-400/80",children:f({id:"mcp.conflict.description"},{scope:f({id:`mcp.scope.${p.effectiveScope}`})})}),e.jsx("p",{className:"text-xs text-orange-600 dark:text-orange-400/80",children:f({id:"mcp.conflict.resolution"})})]})]})]})}function mn(){var Cs,Ss;const{formatMessage:s}=G(),[t,a]=h.useState("servers"),[o,c]=h.useState(""),[n,w]=h.useState("all"),[p,f]=h.useState(new Set),[d,S]=h.useState(!1),[m,g]=h.useState(void 0),[y,u]=h.useState("claude"),[b,v]=h.useState(new Set),[k,j]=h.useState(!1),[M,T]=h.useState(void 0),F=te(),r=Ve(),{servers:x,projectServers:E,globalServers:O,conflicts:V,totalCount:$,enabledCount:W,isLoading:J,isFetching:U,refetch:N}=Us({scope:n==="all"?void 0:n}),L=ge({queryKey:["codexMcpServers"],queryFn:Rs,enabled:y==="codex",staleTime:120*1e3}),A=xe(ue),re=ge({queryKey:["ccwMcpConfig",A],queryFn:()=>zt(A??void 0),enabled:y==="claude",staleTime:300*1e3}),oe=ge({queryKey:["ccwMcpConfigCodex"],queryFn:It,enabled:y==="codex",staleTime:300*1e3}),{toggleServer:we,deleteServer:je}=Bs(),Fe=i=>{f(C=>{const Q=new Set(C);return Q.has(i)?Q.delete(i):Q.add(i),Q})},le=i=>{v(C=>{const Q=new Set(C);return Q.has(i)?Q.delete(i):Q.add(i),Q})},ve=(i,C)=>{we(i,C)},q=async i=>{if(confirm(s({id:"mcp.deleteConfirm"},{name:i.name})))try{await je(i.name,i.scope),r.success(s({id:"mcp.actions.delete"}),i.name),N()}catch(C){console.error("Failed to delete MCP server:",C),r.error(s({id:"mcp.actions.delete"}),C instanceof Error?C.message:String(C))}},ae=i=>{g(i),S(!0)},Ce=()=>{g(void 0),S(!0)},Ee=()=>{S(!1),g(void 0)},We=()=>{S(!1),g(void 0),N()},Ue=i=>{u(i)},ne=re.data??{isInstalled:!1,enabledTools:[],projectRoot:void 0,allowedDirs:void 0,enableSandbox:void 0,installedScopes:[]},l=["ccwMcpConfig",A],P=async(i,C)=>{const Q=F.getQueryData(l)??ne,z=Q.enabledTools,Y=F.getQueryData(l),ie=C?z.includes(i)?z:[...z,i]:z.filter(R=>R!==i);F.setQueryData(l,R=>R&&{...R,enabledTools:ie});try{await Xe({...Q,enabledTools:ie})}catch(R){r.error(s({id:"mcp.actions.toggle.error"}),R instanceof Error?R.message:String(R)),console.error("Failed to toggle CCW tool:",R),F.setQueryData(l,Y)}re.refetch()},K=async i=>{const C=F.getQueryData(l);F.setQueryData(l,z=>z&&{...z,...i});const Q=F.getQueryData(l)??ne;try{await Xe({enabledTools:Q.enabledTools,projectRoot:Q.projectRoot,allowedDirs:Q.allowedDirs,enableSandbox:Q.enableSandbox})}catch(z){r.error(s({id:"mcp.actions.update.error"}),z instanceof Error?z.message:String(z)),console.error("Failed to update CCW config:",z),F.setQueryData(l,C)}re.refetch()},_=()=>{re.refetch()},ce=h.useMemo(()=>{const i=new Map;for(const C of V)i.set(C.name,C);return i},[V]),Se=async i=>{try{await Vs(i,i==="project"?A??void 0:void 0),re.refetch()}catch(C){r.error(s({id:"mcp.actions.install.error"}),C instanceof Error?C.message:String(C)),console.error("Failed to install CCW MCP to scope:",C)}},De=async i=>{try{await Ot(i,i==="project"?A??void 0:void 0),re.refetch(),F.invalidateQueries({queryKey:["mcpServers"]})}catch(C){r.error(s({id:"mcp.actions.uninstall.error"}),C instanceof Error?C.message:String(C)),console.error("Failed to uninstall CCW MCP from scope:",C)}},ee=oe.data??{isInstalled:!1,enabledTools:[],projectRoot:void 0,allowedDirs:void 0,enableSandbox:void 0,installedScopes:[]},Ne=async(i,C)=>{const Q=F.getQueryData(["ccwMcpConfigCodex"])??ee,z=Q.enabledTools,Y=F.getQueryData(["ccwMcpConfigCodex"]),ie=C?z.includes(i)?z:[...z,i]:z.filter(R=>R!==i);F.setQueryData(["ccwMcpConfigCodex"],R=>R&&{...R,enabledTools:ie});try{await Ze({...Q,enabledTools:ie})}catch(R){r.error(s({id:"mcp.actions.toggle.error"}),R instanceof Error?R.message:String(R)),console.error("Failed to toggle CCW tool (Codex):",R),F.setQueryData(["ccwMcpConfigCodex"],Y)}oe.refetch()},Be=async i=>{const C=F.getQueryData(["ccwMcpConfigCodex"])??ee,Q=F.getQueryData(["ccwMcpConfigCodex"]);F.setQueryData(["ccwMcpConfigCodex"],z=>z&&{...z,...i});try{await Ze({...C,...i})}catch(z){r.error(s({id:"mcp.actions.update.error"}),z instanceof Error?z.message:String(z)),console.error("Failed to update CCW config (Codex):",z),F.setQueryData(["ccwMcpConfigCodex"],Q)}oe.refetch()},Xs=()=>{oe.refetch()},et=i=>{const C=(i==null?void 0:i.serverConfig)??{},Q=C.type==="http"||C.transport==="http"||typeof C.url=="string";g(Q?{name:i.name,transport:"http",url:C.url??"",scope:"project",enabled:!0}:{name:i.name,transport:"stdio",command:C.command,args:C.args||[],env:C.env,scope:"project",enabled:!0}),S(!0)},st=i=>{T(i),j(!0)},vs=async(i,C,Q,z)=>{try{const Y=await zs({name:i,description:Q||void 0,category:C||"custom",serverConfig:{command:z.command,args:z.args.length>0?z.args:void 0,env:Object.keys(z.env).length>0?z.env:void 0}});Y.success?(r.success(s({id:"mcp.templates.feedback.saveSuccess"}),i),j(!1),T(void 0)):r.error(s({id:"mcp.templates.feedback.saveError"}),Y.error||"")}catch(Y){r.error(s({id:"mcp.templates.feedback.saveError"}),Y instanceof Error?Y.message:String(Y))}},tt=async i=>{try{await Kt(i),r.success(s({id:"mcp.actions.delete"}),i),L.refetch()}catch(C){console.error("Failed to remove Codex MCP server:",C),r.error(s({id:"mcp.actions.delete"}),C instanceof Error?C.message:String(C))}},at=async(i,C)=>{try{await At(i,C),L.refetch()}catch(Q){r.error(s({id:"mcp.actions.toggle.error"}),Q instanceof Error?Q.message:String(Q)),console.error("Failed to toggle Codex MCP server:",Q)}},nt=x.filter(i=>{var Y,ie;const C=o.toLowerCase(),Q=i.name.toLowerCase().includes(C),z=de(i)?(Y=i.url)==null?void 0:Y.toLowerCase().includes(C):(ie=i.command)==null?void 0:ie.toLowerCase().includes(C);return Q||z}),rt=((Cs=L.data)==null?void 0:Cs.servers)??[],ct=((Ss=L.data)==null?void 0:Ss.configPath)??"",ot=rt.filter(i=>{var Y,ie;const C=o.toLowerCase(),Q=i.name.toLowerCase().includes(C),z=de(i)?(Y=i.url)==null?void 0:Y.toLowerCase().includes(C):(ie=i.command)==null?void 0:ie.toLowerCase().includes(C);return Q||z}),ys=y==="codex"?ot:nt,Ns=y==="codex"?b:p,bs=y==="codex"?le:Fe,lt=y==="codex"?L.isLoading:J,ws=y==="codex"?L.isFetching:U,it=y==="codex"?(()=>L.refetch()):N;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(qe,{className:"w-6 h-6 text-primary"}),s({id:"mcp.title"})]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:s({id:"mcp.description"})})]}),e.jsx("div",{className:"ml-3 flex-shrink-0",children:e.jsx(Lt,{currentMode:y,onModeChange:Ue,codexConfigPath:ct})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(D,{variant:"outline",onClick:()=>it(),disabled:ws,children:[e.jsx(es,{className:H("w-4 h-4 mr-2",ws&&"animate-spin")}),s({id:"common.actions.refresh"})]}),y==="claude"&&e.jsxs(D,{onClick:Ce,children:[e.jsx(Ie,{className:"w-4 h-4 mr-2"}),s({id:"mcp.actions.add"})]})]})]}),e.jsx(Gt,{value:t,onValueChange:i=>a(i),tabs:[{value:"templates",label:s({id:"mcp.tabs.templates"})},{value:"servers",label:s({id:"mcp.tabs.servers"})},{value:"cross-cli",label:s({id:"mcp.tabs.crossCli"})}]}),t==="templates"&&e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsx(Pa,{onInstallComplete:()=>N()}),e.jsx(ba,{onInstallTemplate:et,onSaveAsTemplate:vs})]}),t==="servers"&&e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsx(Aa,{}),y==="claude"&&e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs(Z,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qe,{className:"w-5 h-5 text-primary"}),e.jsx("span",{className:"text-2xl font-bold",children:$})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s({id:"mcp.stats.total"})})]}),e.jsxs(Z,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"w-5 h-5 text-green-600"}),e.jsx("span",{className:"text-2xl font-bold",children:W})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s({id:"mcp.stats.enabled"})})]}),e.jsxs(Z,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{className:"w-5 h-5 text-info"}),e.jsx("span",{className:"text-2xl font-bold",children:O.length})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s({id:"mcp.stats.global"})})]}),e.jsxs(Z,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{className:"w-5 h-5 text-warning"}),e.jsx("span",{className:"text-2xl font-bold",children:E.length})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s({id:"mcp.stats.project"})})]})]}),y==="claude"&&e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ae,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(X,{placeholder:s({id:"mcp.filters.searchPlaceholder"}),value:o,onChange:i=>c(i.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{variant:n==="all"?"default":"outline",size:"sm",onClick:()=>w("all"),children:s({id:"mcp.filters.all"})}),e.jsxs(D,{variant:n==="global"?"default":"outline",size:"sm",onClick:()=>w("global"),children:[e.jsx(fe,{className:"w-4 h-4 mr-1"}),s({id:"mcp.scope.global"})]}),e.jsxs(D,{variant:n==="project"?"default":"outline",size:"sm",onClick:()=>w("project"),children:[e.jsx(ye,{className:"w-4 h-4 mr-1"}),s({id:"mcp.scope.project"})]})]})]}),y==="codex"&&e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ae,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(X,{placeholder:s({id:"mcp.filters.searchPlaceholder"}),value:o,onChange:i=>c(i.target.value),className:"pl-9"})]}),y==="claude"&&e.jsx(Ds,{isInstalled:ne.isInstalled,enabledTools:ne.enabledTools,projectRoot:ne.projectRoot,allowedDirs:ne.allowedDirs,enableSandbox:ne.enableSandbox,onToggleTool:P,onUpdateConfig:K,onInstall:_,installedScopes:ne.installedScopes,onInstallToScope:Se,onUninstallScope:De}),y==="codex"&&e.jsx(Ds,{target:"codex",isInstalled:ee.isInstalled,enabledTools:ee.enabledTools,projectRoot:ee.projectRoot,allowedDirs:ee.allowedDirs,enableSandbox:ee.enableSandbox,onToggleTool:Ne,onUpdateConfig:Be,onInstall:Xs}),lt?e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(i=>e.jsx("div",{className:"h-24 bg-muted animate-pulse rounded-lg"},i))}):ys.length===0?e.jsxs(Z,{className:"p-8 text-center",children:[e.jsx(qe,{className:"w-12 h-12 mx-auto text-muted-foreground/50"}),e.jsx("h3",{className:"mt-4 text-lg font-medium text-foreground",children:s({id:"mcp.emptyState.title"})}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s({id:"mcp.emptyState.message"})})]}):e.jsx("div",{className:"space-y-3",children:ys.map(i=>y==="codex"?e.jsx(ja,{server:i,enabled:i.enabled,isExpanded:Ns.has(i.name),onToggleExpand:()=>bs(i.name),isEditable:!0,onRemove:tt,onToggle:at},`${i.name}-${i.scope}`):e.jsx(La,{server:i,isExpanded:Ns.has(`${i.name}-${i.scope}`),onToggleExpand:()=>bs(`${i.name}-${i.scope}`),onToggle:ve,onEdit:ae,onDelete:q,onSaveAsTemplate:st,conflictInfo:ce.get(i.name)},`${i.name}-${i.scope}`))})]}),t==="cross-cli"&&e.jsxs("div",{className:"mt-4 space-y-6",children:[e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(es,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("h3",{className:"text-sm font-medium text-foreground",children:s({id:"mcp.sync.title"})})]}),e.jsx(Z,{className:"p-4",children:e.jsx(Ka,{onSuccess:()=>N()})})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ye,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("h3",{className:"text-sm font-medium text-foreground",children:s({id:"mcp.projects.title"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s({id:"mcp.projects.description"})}),e.jsx(za,{maxProjects:10,onProjectClick:i=>console.log("Open project:",i),onOpenNewWindow:i=>window.open(`/?project=${encodeURIComponent(i)}`,"_blank")})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(fe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("h3",{className:"text-sm font-medium text-foreground",children:s({id:"mcp.crossProject.title"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s({id:"mcp.crossProject.description"})}),e.jsx(Ia,{onImportSuccess:(i,C)=>{console.log("Imported server:",i,"from:",C),N()}})]})]}),y==="claude"&&e.jsx(ga,{mode:m?"edit":"add",server:m,open:d,onClose:Ee,onSave:We}),e.jsx(Zs,{open:k,onClose:()=>{j(!1),T(void 0)},onSave:vs,defaultName:M==null?void 0:M.name,defaultCommand:M&&me(M)?M.command:void 0,defaultArgs:M&&me(M)?M.args:void 0,defaultEnv:M&&me(M)?M.env:void 0})]})}export{mn as McpManagerPage,mn as default};
50
- //# sourceMappingURL=McpManagerPage-CS2v_1OG.js.map
46
+ }`})]})]}),e.jsx(D,{type:"button",onClick:ce,disabled:!N.trim(),className:"w-full",children:n({id:"mcp.dialog.json.parse"})})]}):e.jsxs(e.Fragment,{children:[g==="stdio"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.form.template"})}),e.jsxs(He,{value:v,onValueChange:Fe,disabled:m,children:[e.jsx(_e,{className:"w-full",children:e.jsx($e,{placeholder:n(m?{id:"mcp.templates.loading"}:{id:"mcp.dialog.form.templatePlaceholder"})})}),e.jsx(Re,{children:S.length===0?e.jsx(he,{value:"__empty__",disabled:!0,children:n({id:"mcp.templates.empty.title"})}):S.map(o=>e.jsx(he,{value:o.name,children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:o.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:o.description||n({id:"mcp.dialog.form.templatePlaceholder"})})]})},o.name))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-sm font-medium text-foreground",children:[n({id:"mcp.dialog.form.name"}),e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(X,{value:p.name,onChange:o=>le("name",o.target.value),placeholder:n({id:"mcp.dialog.form.namePlaceholder"}),error:!!j.name,disabled:s==="edit"}),j.name&&e.jsx("p",{className:"text-sm text-destructive",children:j.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.form.transportType"})}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"transportType",value:"stdio",checked:g==="stdio",onChange:()=>Se("stdio"),className:"w-4 h-4",disabled:s==="edit"}),e.jsx(gt,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:n({id:"mcp.dialog.form.transportStdio"})})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"transportType",value:"http",checked:g==="http",onChange:()=>Se("http"),className:"w-4 h-4",disabled:s==="edit"}),e.jsx(je,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:n({id:"mcp.dialog.form.transportHttp"})})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n({id:"mcp.dialog.form.transportHint"})})]}),g==="stdio"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-sm font-medium text-foreground",children:[n({id:"mcp.dialog.form.command"}),e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(X,{value:p.command,onChange:o=>le("command",o.target.value),placeholder:n({id:"mcp.dialog.form.commandPlaceholder"}),error:!!j.command}),j.command&&e.jsx("p",{className:"text-sm text-destructive",children:j.command})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.form.args"})}),e.jsx(X,{value:T,onChange:o=>ye(o.target.value),placeholder:n({id:"mcp.dialog.form.argsPlaceholder"}),error:!!j.args}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n({id:"mcp.dialog.form.argsHint"})}),p.args.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:p.args.map((o,F)=>e.jsx(I,{variant:"secondary",className:"font-mono text-xs",children:o},F))}),j.args&&e.jsx("p",{className:"text-sm text-destructive",children:j.args})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.form.env"})}),e.jsx("textarea",{value:r,onChange:o=>q(o.target.value),placeholder:n({id:"mcp.dialog.form.envPlaceholder"}),className:_("flex min-h-[100px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",j.env&&"border-destructive focus-visible:ring-destructive")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n({id:"mcp.dialog.form.envHint"})}),Object.keys(p.env).length>0&&e.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(p.env).map(([o,F])=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(I,{variant:"outline",className:"font-mono",children:o}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"text-xs bg-muted px-2 py-1 rounded flex-1 overflow-x-auto",children:F})]},o))}),j.env&&e.jsx("p",{className:"text-sm text-destructive",children:j.env})]})]}),g==="http"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-sm font-medium text-foreground",children:[n({id:"mcp.dialog.form.http.url"}),e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(X,{value:p.url,onChange:o=>le("url",o.target.value),placeholder:n({id:"mcp.dialog.form.http.urlPlaceholder"}),error:!!j.url}),j.url&&e.jsx("p",{className:"text-sm text-destructive",children:j.url}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n({id:"mcp.dialog.form.http.urlHint"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.form.http.bearerToken"})}),e.jsx(X,{value:p.bearerTokenEnvVar,onChange:o=>le("bearerTokenEnvVar",o.target.value),placeholder:n({id:"mcp.dialog.form.http.bearerTokenPlaceholder"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n({id:"mcp.dialog.form.http.bearerTokenHint"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.form.http.headers"})}),e.jsx(ha,{headers:p.headers,onChange:ne,disabled:re}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n({id:"mcp.dialog.form.http.headersHint"})}),j.headers&&e.jsx("p",{className:"text-sm text-destructive",children:j.headers})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:n({id:"mcp.dialog.form.scope"})}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"scope",value:"project",checked:p.scope==="project",onChange:o=>le("scope",o.target.value),className:"w-4 h-4",disabled:s==="edit"}),e.jsx("span",{className:"text-sm",children:n({id:"mcp.scope.project"})})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"scope",value:"global",checked:p.scope==="global",onChange:o=>le("scope",o.target.value),className:"w-4 h-4",disabled:s==="edit"}),e.jsx("span",{className:"text-sm",children:n({id:"mcp.scope.global"})})]})]}),p.scope==="project"&&e.jsxs("div",{className:"flex items-center gap-2 mt-2 pl-6",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[n({id:"mcp.configType.format"}),":"]}),e.jsx(ua,{currentType:E,onTypeChange:O,showWarning:!1})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"enabled",checked:p.enabled,onChange:o=>le("enabled",o.target.checked),className:"w-4 h-4"}),e.jsx("label",{htmlFor:"enabled",className:"text-sm font-medium text-foreground cursor-pointer",children:n({id:"mcp.dialog.form.enabled"})})]}),g==="stdio"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"save-as-template",checked:H,onChange:o=>$(o.target.checked),className:"w-4 h-4"}),e.jsx("label",{htmlFor:"save-as-template",className:"text-sm font-medium text-foreground cursor-pointer",children:n({id:"mcp.templates.actions.saveAsTemplate"})})]})]})}),e.jsxs(cs,{children:[e.jsx(D,{variant:"outline",onClick:ve,disabled:re,children:n({id:"mcp.dialog.actions.cancel"})}),e.jsx(D,{onClick:Ue,disabled:re,children:n(re?{id:"mcp.dialog.actions.saving"}:{id:"mcp.dialog.actions.save"})})]})]})})}function fa(s){return!s||s.length<=4?"****":s.substring(0,4)+"****"}function ja({server:s,enabled:t,isExpanded:a,onToggleExpand:l,isEditable:c=!1,onRemove:n,onToggle:w,isRemoving:u=!1,isToggling:f=!1}){const{formatMessage:d}=G(),[S,m]=h.useState(!1),[g,y]=h.useState({}),p=de(s),b=me(s),v=()=>{var r;return p?s.url:`${s.command||""} ${((r=s.args)==null?void 0:r.join(" "))||""}`.trim()},k=()=>{if(!p)return[];const r=[];return s.httpHeaders&&Object.entries(s.httpHeaders).forEach(([x,E])=>{r.push({name:x,value:E})}),s.bearerTokenEnvVar&&r.push({name:"Authorization",value:`Bearer $${s.bearerTokenEnvVar}`,isEnvVar:!0}),s.headers&&Object.entries(s.headers).forEach(([x,E])=>{r.push({name:x,value:E})}),r},j=r=>{y(x=>({...x,[r]:!x[r]}))},M=async()=>{w&&await w(s.name,!t)},T=async()=>{n&&(await n(s.name),m(!1))},P=r=>{r.stopPropagation()};return e.jsxs(Z,{className:_("overflow-hidden",!t&&"opacity-60"),children:[e.jsx("div",{className:"p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:l,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:_("p-2 rounded-lg",t?"bg-primary/10":"bg-muted"),children:e.jsx(qe,{className:_("w-5 h-5",t?"text-primary":"text-muted-foreground")})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:s.name}),p&&e.jsxs(I,{variant:"outline",className:"text-xs text-blue-600 border-blue-300",children:[e.jsx(Ws,{className:"w-3 h-3 mr-1"}),d({id:"mcp.transport.http"})]}),c?e.jsxs(e.Fragment,{children:[e.jsxs(I,{variant:"secondary",className:"text-xs flex items-center gap-1",children:[e.jsx(Fs,{className:"w-3 h-3"}),d({id:"mcp.codex.editable"})]}),t&&e.jsxs(I,{variant:"outline",className:"text-xs text-green-600",children:[e.jsx(ke,{className:"w-3 h-3 mr-1"}),d({id:"mcp.status.enabled"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(I,{variant:"secondary",className:"text-xs flex items-center gap-1",children:[e.jsx(Ps,{className:"w-3 h-3"}),d({id:"mcp.codex.readOnly"})]}),t&&e.jsxs(I,{variant:"outline",className:"text-xs text-green-600",children:[e.jsx(ke,{className:"w-3 h-3 mr-1"}),d({id:"mcp.status.enabled"})]})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 font-mono truncate max-w-md",title:v(),children:v()})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[c?e.jsxs(e.Fragment,{children:[e.jsx(D,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:r=>{P(r),M()},disabled:f,children:t?e.jsx(ke,{className:"w-4 h-4 text-green-600"}):e.jsx(ss,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs(is,{open:S,onOpenChange:m,children:[e.jsx(Qt,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:P,disabled:u,children:e.jsx(Me,{className:"w-4 h-4 text-destructive"})})}),e.jsxs(ds,{children:[e.jsxs(ms,{children:[e.jsx(xs,{children:d({id:"mcp.codex.deleteConfirm.title"},{name:s.name})}),e.jsx(ps,{children:d({id:"mcp.codex.deleteConfirm.description"},{name:s.name})})]}),e.jsxs(us,{children:[e.jsx(hs,{disabled:u,children:d({id:"mcp.codex.deleteConfirm.cancel"})}),e.jsx(gs,{onClick:T,disabled:u,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"animate-spin mr-2",children:"◌"}),d({id:"mcp.codex.deleteConfirm.deleting"})]}):d({id:"mcp.codex.deleteConfirm.confirm"})})]})]})]})]}):e.jsx(e.Fragment,{children:e.jsx("div",{className:_("w-8 h-8 rounded-md flex items-center justify-center",t?"bg-green-100 text-green-600":"bg-muted text-muted-foreground"),children:t?e.jsx(ke,{className:"w-4 h-4"}):e.jsx(ss,{className:"w-4 h-4"})})}),a?e.jsx(Is,{className:"w-5 h-5 text-muted-foreground"}):e.jsx(os,{className:"w-5 h-5 text-muted-foreground"})]})]})}),a&&e.jsxs("div",{className:"border-t border-border p-4 space-y-3 bg-muted/30",children:[p&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:d({id:"mcp.http.url"})}),e.jsx("code",{className:"text-sm bg-background px-2 py-1 rounded block overflow-x-auto break-all",children:s.url})]}),k().length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:d({id:"mcp.http.headers"})}),e.jsx("div",{className:"space-y-1",children:k().map(r=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(I,{variant:"secondary",className:"font-mono",children:r.name}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"text-xs bg-background px-2 py-1 rounded flex-1 overflow-x-auto",children:g[r.name]?r.value:fa(r.value)}),e.jsx(D,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>j(r.name),title:g[r.name]?d({id:"mcp.http.hideValue"}):d({id:"mcp.http.showValue"}),children:g[r.name]?e.jsx(fs,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(js,{className:"w-3 h-3 text-muted-foreground"})}),r.isEnvVar&&e.jsx(I,{variant:"outline",className:"text-xs text-blue-500",children:d({id:"mcp.http.envVar"})})]},r.name))})]})]}),b&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:d({id:"mcp.command"})}),e.jsx("code",{className:"text-sm bg-background px-2 py-1 rounded block overflow-x-auto",children:s.command})]}),s.args&&s.args.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:d({id:"mcp.args"})}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.args.map((r,x)=>e.jsx(I,{variant:"outline",className:"font-mono text-xs",children:r},x))})]}),s.env&&Object.keys(s.env).length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:d({id:"mcp.env"})}),e.jsx("div",{className:"space-y-1",children:Object.entries(s.env).map(([r,x])=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(I,{variant:"secondary",className:"font-mono",children:r}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"text-xs bg-background px-2 py-1 rounded flex-1 overflow-x-auto",children:x})]},r))})]})]}),e.jsx("div",{className:_("flex items-center gap-2 px-3 py-2 rounded-md border",c?"bg-info/10 border-info/20":"bg-muted/50 border-border"),children:c?e.jsxs(e.Fragment,{children:[e.jsx(Fs,{className:"w-4 h-4 text-info"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d({id:"mcp.codex.editableNotice"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ps,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d({id:"mcp.codex.readOnlyNotice"})})]})})]})]})}const Es=[{name:"write_file",desc:"Write/create files",core:!0},{name:"edit_file",desc:"Edit/replace content",core:!0},{name:"read_file",desc:"Read single file",core:!0},{name:"read_many_files",desc:"Read multiple files/dirs",core:!0},{name:"core_memory",desc:"Core memory management",core:!0},{name:"ask_question",desc:"Interactive questions (A2UI)",core:!1},{name:"smart_search",desc:"Intelligent code search",core:!0},{name:"team_msg",desc:"Agent team message bus",core:!1}];function Ds({isInstalled:s,enabledTools:t,projectRoot:a,allowedDirs:l,enableSandbox:c,onToggleTool:n,onUpdateConfig:w,onInstall:u,target:f="claude",installedScopes:d=[],onUninstallScope:S}){const{formatMessage:m}=G(),g=ae(),{success:y,error:p}=Ve(),b=xe(pe),[v,k]=h.useState(a||""),[j,M]=h.useState(l||""),[T,P]=h.useState(c||!1),[r,x]=h.useState(!1),[E,O]=h.useState("global"),[H,$]=h.useState(!1),[W,J]=h.useState(null),U=f==="codex",N=te({mutationFn:U?()=>ft():q=>Vs(q.scope,q.projectPath),onSuccess:()=>{U?(g.invalidateQueries({queryKey:["codexMcpServers"]}),g.invalidateQueries({queryKey:["ccwMcpConfigCodex"]})):(g.invalidateQueries({queryKey:B.all}),g.invalidateQueries({queryKey:["ccwMcpConfig"]})),u()}}),L=te({mutationFn:U?jt:vt,onSuccess:()=>{U?(g.invalidateQueries({queryKey:["codexMcpServers"]}),g.invalidateQueries({queryKey:["ccwMcpConfigCodex"]})):(g.invalidateQueries({queryKey:B.all}),g.invalidateQueries({queryKey:["ccwMcpConfig"]})),u()},onError:q=>{console.error("Failed to uninstall CCW MCP:",q)}}),A=te({mutationFn:U?Ze:Xe,onSuccess:()=>{U?(g.invalidateQueries({queryKey:["codexMcpServers"]}),g.invalidateQueries({queryKey:["ccwMcpConfigCodex"]})):(g.invalidateQueries({queryKey:B.all}),g.invalidateQueries({queryKey:["ccwMcpConfig"]})),y(m({id:"mcp.ccw.feedback.saveSuccess"}))},onError:q=>{console.error("Failed to update CCW config:",q),p(m({id:"mcp.ccw.feedback.saveError"}),q instanceof Error?q.message:String(q))}}),ce=(q,ne)=>{n(q,ne)},oe=()=>{const q=Es.map(ne=>ne.name);w({enabledTools:q})},Ce=()=>{w({enabledTools:[]})},ve=()=>{A.mutate({enabledTools:t,projectRoot:v||void 0,allowedDirs:j||void 0,enableSandbox:T})},Fe=()=>{U?N.mutate(void 0):N.mutate({scope:E,projectPath:E==="project"?b:void 0})},le=()=>{confirm(m({id:"mcp.ccw.actions.uninstallConfirm"}))&&L.mutate()},ye=N.isPending||L.isPending||A.isPending;return e.jsxs(Z,{className:_("overflow-hidden border-2",s?"border-primary/50 bg-primary/5":"border-dashed"),children:[e.jsx("div",{className:"p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>x(!r),children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:_("p-2 rounded-lg",s?"bg-primary/20":"bg-muted"),children:e.jsx(we,{className:_("w-5 h-5",s?"text-primary":"text-muted-foreground")})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:m({id:"mcp.ccw.title"})}),s&&d.length>0?e.jsxs(e.Fragment,{children:[d.map(q=>e.jsxs(I,{variant:"default",className:"text-xs",children:[q==="global"?e.jsx(je,{className:"w-3 h-3 mr-1"}):e.jsx(Ne,{className:"w-3 h-3 mr-1"}),m({id:`mcp.ccw.scope.${q}`})]},q)),d.length>=2&&e.jsxs(I,{variant:"outline",className:"text-xs text-orange-500 border-orange-300",children:[e.jsx(Qe,{className:"w-3 h-3 mr-1"}),m({id:"mcp.conflict.badge"})]})]}):e.jsx(I,{variant:s?"default":"secondary",className:"text-xs",children:m(s?{id:"mcp.ccw.status.installed"}:{id:"mcp.ccw.status.notInstalled"})}),U&&e.jsx(I,{variant:"outline",className:"text-xs text-blue-500",children:"Codex"}),s&&e.jsx(I,{variant:"outline",className:"text-xs text-info",children:m({id:"mcp.ccw.status.special"})})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:m({id:"mcp.ccw.description"})})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:r?e.jsx(os,{className:"w-5 h-5 text-muted-foreground"}):e.jsx(Qs,{className:"w-5 h-5 text-muted-foreground"})})]})}),r&&e.jsxs("div",{className:"border-t border-border p-4 space-y-4 bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:oe,disabled:!s,children:[e.jsx(Ls,{className:"w-4 h-4 mr-1"}),m({id:"mcp.ccw.actions.enableAll"})]}),e.jsx(D,{variant:"outline",size:"sm",onClick:Ce,disabled:!s,children:m({id:"mcp.ccw.actions.disableAll"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase",children:m({id:"mcp.ccw.tools.label"})}),!s&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-500",children:m({id:"mcp.ccw.tools.hint"})})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Es.map(q=>{const ne=t.includes(q.name),Se=va(q.name);return e.jsxs("div",{className:_("flex items-center gap-3 p-2 rounded-lg transition-colors border",ne?"bg-background border-primary/40":"bg-background border-border"),children:[e.jsx("input",{type:"checkbox",id:`ccw-tool-${q.name}`,checked:ne,onChange:Ee=>ce(q.name,Ee.target.checked),disabled:!s,className:"w-4 h-4"}),e.jsxs("label",{htmlFor:`ccw-tool-${q.name}`,className:"flex items-center gap-2 flex-1 cursor-pointer",children:[Se,e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:m({id:`mcp.ccw.tools.${q.name}.name`})}),q.core&&e.jsx(I,{variant:"secondary",className:"text-xs",children:m({id:"mcp.ccw.tools.core"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m({id:`mcp.ccw.tools.${q.name}.desc`})})]})]})]},q.name)})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-foreground flex items-center gap-1",children:[e.jsx(Xt,{className:"w-4 h-4"}),m({id:"mcp.ccw.paths.projectRoot"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{value:v,onChange:q=>k(q.target.value),placeholder:m({id:"mcp.ccw.paths.projectRootPlaceholder"}),disabled:!s,className:"font-mono text-sm"}),e.jsx(D,{variant:"outline",size:"icon",onClick:()=>{J("projectRoot"),$(!0)},disabled:!s,title:"Browse for project root",children:e.jsx(Le,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-foreground flex items-center gap-1",children:[e.jsx(Ht,{className:"w-4 h-4"}),m({id:"mcp.ccw.paths.allowedDirs"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{value:j,onChange:q=>M(q.target.value),placeholder:m({id:"mcp.ccw.paths.allowedDirsPlaceholder"}),disabled:!s,className:"font-mono text-sm"}),e.jsx(D,{variant:"outline",size:"icon",onClick:()=>{J("allowedDirs"),$(!0)},disabled:!s,title:"Browse for allowed directories",children:e.jsx(Le,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m({id:"mcp.ccw.paths.allowedDirsHint"})})]}),s&&e.jsx("div",{className:"flex justify-end",children:e.jsxs(D,{variant:"default",size:"sm",onClick:ve,disabled:ye,children:[e.jsx(_t,{className:"w-4 h-4 mr-1"}),m({id:"mcp.ccw.actions.saveConfig"})]})}),e.jsx("div",{className:"border-t border-border pt-4 space-y-2",children:s?e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:d.length>0&&S?d.map(q=>e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>S(q),disabled:ye,className:"text-destructive border-destructive/50 hover:bg-destructive/10",children:[e.jsx(Me,{className:"w-4 h-4 mr-1"}),m({id:"mcp.ccw.actions.uninstallScope"},{scope:q})]},q)):e.jsxs(D,{variant:"outline",size:"sm",onClick:le,disabled:ye,className:"text-destructive border-destructive/50 hover:bg-destructive/10",children:[e.jsx(Me,{className:"w-4 h-4 mr-1"}),m({id:"mcp.ccw.actions.uninstall"})]})}):e.jsxs("div",{className:"flex items-center gap-2",children:[!U&&e.jsxs("select",{value:E,onChange:q=>O(q.target.value),className:"text-sm border border-border rounded px-2 py-1 bg-background text-foreground",children:[e.jsx("option",{value:"global",children:m({id:"mcp.ccw.scope.global"})}),e.jsx("option",{value:"project",children:m({id:"mcp.ccw.scope.project"})})]}),e.jsxs(D,{variant:"default",size:"sm",onClick:Fe,disabled:ye,children:[e.jsx(Ke,{className:"w-4 h-4 mr-1"}),m({id:"mcp.ccw.actions.install"})]})]})})]}),e.jsx(Vt,{isOpen:H,onClose:()=>$(!1),rootPath:b||"/",onInsertPath:q=>{W==="projectRoot"?k(q):W==="allowedDirs"&&M(ne=>ne?`${ne},${q}`:q),$(!1)}})]})}function va(s){const t={className:"w-4 h-4 text-muted-foreground"};switch(s){case"write_file":return e.jsx(Rt,{...t});case"edit_file":return e.jsx(Ls,{...t});case"read_file":return e.jsx(Hs,{...t});case"read_many_files":return e.jsx(Zt,{...t});case"core_memory":return e.jsx(we,{...t});case"ask_question":return e.jsx(sa,{...t});case"smart_search":return e.jsx(ta,{...t});case"team_msg":return e.jsx($t,{...t});default:return e.jsx(we,{...t})}}const ya=300;function Na({template:s,onInstall:t,onDelete:a,isInstalling:l,isDeleting:c}){const{formatMessage:n}=G(),w=()=>{t(s)},u=()=>{a(s.name)},f=()=>{var S;const d={className:"w-4 h-4"};switch((S=s.category)==null?void 0:S.toLowerCase()){case"stdio":case"transport":return e.jsx(yt,{...d});case"language":case"python":case"node":return e.jsx(Ne,{...d});case"official":case"builtin":return e.jsx(je,{...d});default:return e.jsx(ls,{...d})}};return e.jsx(Z,{className:"p-4 hover:border-primary/50 transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"p-2 rounded-lg bg-muted flex-shrink-0",children:f()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:s.name}),s.category&&e.jsx(I,{variant:"secondary",className:"text-xs",children:s.category})]}),s.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:s.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("code",{className:"text-xs bg-muted px-2 py-1 rounded font-mono truncate max-w-[150px]",children:s.serverConfig.command}),s.serverConfig.args&&s.serverConfig.args.length>0&&e.jsxs(I,{variant:"outline",className:"text-xs",children:[s.serverConfig.args.length," args"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(D,{variant:"ghost",size:"sm",onClick:w,disabled:l,title:n({id:"mcp.templates.actions.install"}),children:e.jsx(Ke,{className:"w-4 h-4"})}),e.jsx(D,{variant:"ghost",size:"sm",onClick:u,disabled:c,title:n({id:"mcp.templates.actions.delete"}),children:e.jsx(Me,{className:"w-4 h-4"})})]})]})})}function Zs({open:s,onClose:t,onSave:a,defaultName:l="",defaultCommand:c="",defaultArgs:n=[],defaultEnv:w={}}){const{formatMessage:u}=G(),[f,d]=h.useState(l),[S,m]=h.useState(""),[g,y]=h.useState(""),[p,b]=h.useState(c),[v,k]=h.useState(n.join(", ")),[j,M]=h.useState(Object.entries(w).map(([x,E])=>`${x}=${E}`).join(`
47
+ `)),[T,P]=h.useState({});h.useEffect(()=>{s&&(d(l||""),m(""),y(""),b(c||""),k((n||[]).join(", ")),M(Object.entries(w||{}).map(([x,E])=>`${x}=${E}`).join(`
48
+ `)),P({}))},[s,l,c,n,w]);const r=()=>{const x={};if(f.trim()||(x.name=u({id:"mcp.templates.saveDialog.validation.nameRequired"})),p.trim()||(x.command=u({id:"mcp.dialog.validation.commandRequired"})),Object.keys(x).length>0){P(x);return}const E=v.split(",").map(H=>H.trim()).filter(H=>H.length>0),O={};for(const H of j.split(`
49
+ `)){const $=H.trim();if($&&$.includes("=")){const[W,...J]=$.split("=");W&&(O[W.trim()]=J.join("=").trim())}}a(f.trim(),S.trim(),g.trim(),{command:p.trim(),args:E,env:O})};return e.jsx(ts,{open:s,onOpenChange:t,children:e.jsxs(as,{className:"max-w-md max-h-[85vh] overflow-y-auto",children:[e.jsx(ns,{children:e.jsx(rs,{children:u({id:"mcp.templates.saveDialog.title"})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-sm font-medium text-foreground",children:[u({id:"mcp.templates.saveDialog.name"}),e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(X,{value:f,onChange:x=>{d(x.target.value),T.name&&P(E=>({...E,name:void 0}))},placeholder:u({id:"mcp.templates.saveDialog.namePlaceholder"}),error:!!T.name}),T.name&&e.jsx("p",{className:"text-sm text-destructive",children:T.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-sm font-medium text-foreground",children:[u({id:"mcp.dialog.form.command"}),e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsx(X,{value:p,onChange:x=>{b(x.target.value),T.command&&P(E=>({...E,command:void 0}))},placeholder:u({id:"mcp.dialog.form.commandPlaceholder"}),error:!!T.command}),T.command&&e.jsx("p",{className:"text-sm text-destructive",children:T.command})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:u({id:"mcp.dialog.form.args"})}),e.jsx(X,{value:v,onChange:x=>k(x.target.value),placeholder:u({id:"mcp.dialog.form.argsPlaceholder"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u({id:"mcp.dialog.form.argsHint"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:u({id:"mcp.dialog.form.env"})}),e.jsx("textarea",{value:j,onChange:x=>M(x.target.value),placeholder:u({id:"mcp.dialog.form.envPlaceholder"}),className:"flex min-h-[60px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm font-mono ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:u({id:"mcp.templates.saveDialog.category"})}),e.jsxs(He,{value:S,onValueChange:m,children:[e.jsx(_e,{className:"w-full",children:e.jsx($e,{placeholder:u({id:"mcp.templates.saveDialog.categoryPlaceholder"})})}),e.jsxs(Re,{children:[e.jsx(he,{value:"stdio",children:"STDIO"}),e.jsx(he,{value:"sse",children:"SSE"}),e.jsx(he,{value:"language",children:"Language"}),e.jsx(he,{value:"official",children:"Official"}),e.jsx(he,{value:"custom",children:"Custom"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:u({id:"mcp.templates.saveDialog.description"})}),e.jsx("textarea",{value:g,onChange:x=>y(x.target.value),placeholder:u({id:"mcp.templates.saveDialog.descriptionPlaceholder"}),className:"flex min-h-[60px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]})]}),e.jsxs(cs,{children:[e.jsx(D,{variant:"outline",onClick:t,children:u({id:"mcp.templates.saveDialog.cancel"})}),e.jsx(D,{onClick:r,children:u({id:"mcp.templates.saveDialog.save"})})]})]})})}function ba({onInstallTemplate:s,onSaveAsTemplate:t}){const{formatMessage:a}=G(),[l,c]=h.useState(""),[n,w]=h.useState(""),[u,f]=h.useState("all"),[d,S]=h.useState(!1),[m,g]=h.useState(!1),[y,p]=h.useState(null),{data:b=[],isLoading:v}=fe({queryKey:ge.categories(),queryFn:Nt,staleTime:600*1e3}),k=ia(),j=da();h.useEffect(()=>{const O=setTimeout(()=>{w(l)},ya);return()=>clearTimeout(O)},[l]);const{data:M=[],isLoading:T}=fe({queryKey:ge.list(u==="all"?void 0:u),queryFn:async()=>{if(n.trim())return bt(n.trim());if(u==="all"){const O=[];for(const H of b){const $=await ks(H);O.push(...$)}return O}else return ks(u)},staleTime:300*1e3,enabled:!v}),P=h.useCallback(O=>{s==null||s(O)},[s]),r=h.useCallback(O=>{p(O),g(!0)},[]),x=h.useCallback(async()=>{if(!y)return;(await k.deleteTemplate(y)).success&&(g(!1),p(null))},[y,k]),E=h.useCallback((O,H,$,W)=>{t==null||t(O,H,$,W),S(!1)},[t]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(Ae,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(X,{value:l,onChange:O=>c(O.target.value),placeholder:a({id:"mcp.templates.searchPlaceholder"}),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Wt,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs(He,{value:u,onValueChange:f,children:[e.jsx(_e,{className:"w-[150px]",children:e.jsx($e,{})}),e.jsxs(Re,{children:[e.jsx(he,{value:"all",children:a({id:"mcp.templates.filter.allCategories"})}),b.map(O=>e.jsx(he,{value:O,children:O},O))]})]})]})]}),e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>S(!0),children:[e.jsx(Ie,{className:"w-4 h-4 mr-1"}),a({id:"mcp.templates.actions.saveAsTemplate"})]})]}),T?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:a({id:"mcp.templates.loading"})})}):M.length===0?e.jsxs(Z,{className:"p-12 text-center",children:[e.jsx(ls,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-foreground mb-2",children:a({id:"mcp.templates.empty.title"})}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:a({id:"mcp.templates.empty.message"})}),e.jsxs(D,{onClick:()=>S(!0),children:[e.jsx(Ie,{className:"w-4 h-4 mr-1"}),a({id:"mcp.templates.empty.createFirst"})]})]}):e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:M.map(O=>e.jsx(Na,{template:O,onInstall:P,onDelete:r,isInstalling:j.isInstalling,isDeleting:k.isDeleting},O.name))}),e.jsx(Zs,{open:d,onClose:()=>S(!1),onSave:E}),e.jsx(is,{open:m,onOpenChange:g,children:e.jsxs(ds,{children:[e.jsxs(ms,{children:[e.jsx(xs,{children:a({id:"mcp.templates.deleteDialog.title"})}),e.jsx(ps,{children:a({id:"mcp.templates.deleteDialog.message"},{name:y})})]}),e.jsxs(us,{children:[e.jsx(hs,{children:a({id:"mcp.templates.deleteDialog.cancel"})}),e.jsx(gs,{onClick:x,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:k.isDeleting?a({id:"mcp.templates.deleteDialog.deleting"}):a({id:"mcp.templates.deleteDialog.delete"})})]})]})})]})}const wa={"search-code":Ae,chrome:je,"globe-2":_s,"code-2":we};function Ca({open:s,onClose:t,mcpDefinition:a,onInstallComplete:l}){const{formatMessage:c}=G(),n=ae(),{success:w,error:u}=Ve(),f=xe(pe),[d,S]=h.useState({}),[m,g]=h.useState("global"),y=()=>{if(!a)return;const r={};for(const x of a.fields)x.default!==void 0?r[x.key]=x.default:x.type==="multi-select"?r[x.key]=[]:r[x.key]="";S(r)},p=r=>{r&&a?y():(S({}),t())},b=te({mutationFn:async()=>{if(!a)throw new Error("No MCP definition");const r=a.buildConfig(d);if(m==="global")return wt(a.id,r);if(!f)throw new Error("Project path is required to install to project scope");return Ct(a.id,r,f)},onSuccess:r=>{r.success?(n.invalidateQueries({queryKey:B.all}),w(c({id:"mcp.wizard.installSuccess"}),c({id:a.nameKey})),p(!1),l==null||l()):u(c({id:"mcp.wizard.installError"}),r.error||"Unknown error")},onError:r=>{u(c({id:"mcp.wizard.installError"}),r.message)}}),v=(r,x)=>{S(E=>({...E,[r]:x}))},k=(r,x)=>{const E=d[r]||[],O=E.includes(x)?E.filter(H=>H!==x):[...E,x];v(r,O)},j=()=>{if(!a)return!1;for(const r of a.fields)if(r.required){const x=d[r.key];if(r.type==="multi-select"){if(!x||x.length===0)return!1}else if(!x||x.trim()==="")return!1}return!0},M=()=>{if(!j()){u(c({id:"mcp.wizard.validation"}),c({id:"mcp.wizard.requiredFields"}));return}b.mutate()};if(!a)return null;const T=a.fields.length>0,P=wa[a.icon]||we;return e.jsx(ts,{open:s,onOpenChange:p,children:e.jsxs(as,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(ns,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-primary/10 rounded-lg flex items-center justify-center",children:e.jsx(P,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsxs(rs,{children:[c({id:"mcp.wizard.install"})," ",c({id:a.nameKey})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c({id:a.descKey})})]})]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[T&&e.jsx("div",{className:"space-y-3",children:a.fields.map(r=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(Ts,{className:"flex items-center gap-1.5 text-sm font-medium",children:[c({id:r.labelKey}),r.required&&e.jsx("span",{className:"text-destructive",children:"*"})]}),r.descKey&&e.jsx("p",{className:"text-xs text-muted-foreground",children:c({id:r.descKey})}),(r.type==="text"||r.type==="password")&&e.jsx(X,{type:r.type,value:d[r.key]||"",onChange:x=>v(r.key,x.target.value),placeholder:r.placeholder,className:"font-mono text-sm"}),r.type==="multi-select"&&r.options&&e.jsx("div",{className:"space-y-2 p-2 bg-muted/30 border border-border rounded-lg max-h-48 overflow-y-auto",children:r.options.map(x=>{const E=(d[r.key]||[]).includes(x.value);return e.jsxs("div",{className:_("flex items-start gap-2 p-2 rounded transition-colors cursor-pointer",E?"bg-primary/10":"hover:bg-muted/50"),onClick:()=>k(r.key,x.value),children:[e.jsx("input",{type:"checkbox",checked:E,onChange:()=>{},className:"mt-0.5 w-4 h-4"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:x.label}),x.desc&&e.jsx("div",{className:"text-xs text-muted-foreground",children:x.desc})]})]},x.value)})})]},r.key))}),e.jsxs("div",{className:"space-y-2 pt-3 border-t border-border",children:[e.jsx(Ts,{className:"text-sm font-medium",children:c({id:"mcp.wizard.scope"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{variant:m==="global"?"default":"outline",size:"sm",onClick:()=>g("global"),className:"flex-1",children:c({id:"mcp.wizard.scope.global"})}),e.jsx(D,{variant:m==="project"?"default":"outline",size:"sm",onClick:()=>g("project"),className:"flex-1",children:c({id:"mcp.wizard.scope.project"})})]})]}),!T&&e.jsx("div",{className:"p-3 bg-success/10 border border-success/20 rounded-lg text-sm text-success",children:c({id:"mcp.noConfigNeeded"})})]}),e.jsxs(cs,{children:[e.jsx(D,{variant:"outline",onClick:()=>p(!1),disabled:b.isPending,children:c({id:"mcp.dialog.actions.cancel"})}),e.jsx(D,{onClick:M,disabled:b.isPending,children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"w-4 h-4 mr-1 animate-spin"}),c({id:"mcp.wizard.installing"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"w-4 h-4 mr-1"}),c({id:"mcp.wizard.install"})]})})]})]})})}var qs;const Sa=typeof navigator<"u"&&((qs=navigator.platform)==null?void 0:qs.toLowerCase().includes("win"));function Ge(s,t=[],a={}){const{env:l,type:c}=a,u=Sa&&["npx","npm","node","python","python3","pip","pip3","pnpm","yarn","bun"].includes(s.toLowerCase())?{command:"cmd",args:["/c",s,...t]}:{command:s,args:t};return c&&(u.type=c),l&&Object.keys(l).length>0&&(u.env=l),u}const ka=[{id:"ace-tool",nameKey:"mcp.ace-tool.name",descKey:"mcp.ace-tool.desc",icon:"search-code",category:"search",fields:[{key:"baseUrl",labelKey:"mcp.ace-tool.field.baseUrl",type:"text",default:"https://acemcp.heroman.wtf/relay/",placeholder:"https://acemcp.heroman.wtf/relay/",required:!0,descKey:"mcp.ace-tool.field.baseUrl.desc"},{key:"token",labelKey:"mcp.ace-tool.field.token",type:"password",default:"",placeholder:"ace_xxxxxxxxxxxxxxxx",required:!0,descKey:"mcp.ace-tool.field.token.desc"}],buildConfig:s=>Ge("npx",["ace-tool","--base-url",s.baseUrl||"https://acemcp.heroman.wtf/relay/","--token",s.token])},{id:"chrome-devtools",nameKey:"mcp.chrome-devtools.name",descKey:"mcp.chrome-devtools.desc",icon:"chrome",category:"browser",fields:[],buildConfig:()=>Ge("npx",["chrome-devtools-mcp@latest"],{type:"stdio"})},{id:"exa",nameKey:"mcp.exa.name",descKey:"mcp.exa.desc",icon:"globe-2",category:"search",fields:[{key:"apiKey",labelKey:"mcp.exa.field.apiKey",type:"password",default:"",placeholder:"your-exa-api-key",required:!1,descKey:"mcp.exa.field.apiKey.desc"}],buildConfig:s=>{const t=s.apiKey?{EXA_API_KEY:s.apiKey}:void 0;return Ge("npx",["-y","exa-mcp-server"],{env:t})}}],Ta={"search-code":Ae,chrome:je,"globe-2":_s,"code-2":kt};function Ma({definition:s,isInstalled:t,onInstall:a}){const{formatMessage:l}=G(),c=Ta[s.icon]||we,n=s.fields.length>0;return e.jsx(Z,{className:"p-4 hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:_("p-2.5 rounded-lg",t?"bg-primary/20":"bg-muted"),children:e.jsx(c,{className:_("w-5 h-5",t?"text-primary":"text-muted-foreground")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground truncate",children:l({id:s.nameKey})}),t&&e.jsx(I,{variant:"default",className:"text-xs",children:l({id:"mcp.recommended.actions.installed"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mb-3",children:l({id:s.descKey})}),e.jsxs("div",{className:"flex items-center justify-between",children:[n?e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(ea,{className:"w-3 h-3"}),s.fields.length," ",l({id:"mcp.configRequired"})]}):e.jsxs("span",{className:"text-xs text-green-600 dark:text-green-400 flex items-center gap-1",children:[e.jsx(Tt,{className:"w-3 h-3"}),l({id:"mcp.noConfigNeeded"})]}),e.jsx(D,{variant:t?"outline":"default",size:"sm",onClick:()=>a(s),children:t?e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-3.5 h-3.5 mr-1"}),l({id:"mcp.reconfigure"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"w-3.5 h-3.5 mr-1"}),l({id:"mcp.recommended.actions.install"})]})})]})]})]})})}function Pa({onInstallComplete:s}){const{formatMessage:t}=G(),[a,l]=h.useState(!1),[c,n]=h.useState(null),[w,u]=h.useState(new Set),f=async()=>{var g;try{const y=await St(),p=new Set,b=y.globalServers||{},v=y.userServers||{};for(const j of Object.keys(b))p.add(j);for(const j of Object.keys(v))p.add(j);const k=y.projects||{};for(const j of Object.values(k)){const M=j.mcpServers||{};for(const T of Object.keys(M))p.add(T)}if((g=y.codex)!=null&&g.servers)for(const j of Object.keys(y.codex.servers))p.add(j);u(p)}catch{}};h.useEffect(()=>{f()},[]);const d=g=>{n(g),l(!0)},S=()=>{l(!1),n(null)},m=()=>{f(),s==null||s()};return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:t({id:"mcp.recommended.title"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t({id:"mcp.recommended.description"})})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:ka.map(g=>e.jsx(Ma,{definition:g,isInstalled:w.has(g.id),onInstall:d},g.id))})]}),e.jsx(Ca,{open:a,onClose:S,mcpDefinition:c,onInstallComplete:m})]})}const Fa=[{name:"npm",installUrl:"https://docs.npmjs.com/downloading-and-installing-node-js-and-npm"},{name:"node",installUrl:"https://nodejs.org/"},{name:"python",installUrl:"https://www.python.org/downloads/"},{name:"npx",installUrl:"https://docs.npmjs.com/downloading-and-installing-node-js-and-npm"}];function Ea(s){return Fa.some(t=>t.name===s)}async function Da(s){const t=await fetch("/api/mcp/detect-commands",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:s})});if(!t.ok)throw new Error("Failed to detect commands");return t.json()}async function qa(s){const t=await fetch("/api/mcp/apply-windows-fix",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:s})});if(!t.ok)throw new Error("Failed to apply Windows fix");return t.json()}function Oa({commands:s}){const{formatMessage:t}=G();return e.jsx("div",{className:"space-y-2 mt-3",children:s.map(a=>e.jsxs("div",{className:_("flex items-center gap-2 text-sm p-2 rounded-md",a.available?"bg-success/10":"bg-destructive/10"),children:[a.available?e.jsx($s,{className:"w-4 h-4 text-success"}):e.jsx(Mt,{className:"w-4 h-4 text-destructive"}),e.jsx("code",{className:"font-mono flex-1",children:a.command}),!a.available&&a.installUrl&&e.jsxs("a",{href:a.installUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline flex items-center gap-1",children:[e.jsx(Ke,{className:"w-3 h-3"}),t({id:"mcp.windows.install"})]})]},a.command))})}function Aa({projectPath:s,onComplete:t}){const{formatMessage:a}=G(),l=ae(),[c,n]=h.useState(null),[w,u]=h.useState(!1),[f,d]=h.useState(!1),S=typeof window<"u"&&window.navigator.platform.toLowerCase().includes("win"),m=te({mutationFn:()=>qa(s),onSuccess:()=>{l.invalidateQueries({queryKey:["mcpServers"]}),t&&c&&t({...c,canAutoFix:!1})}});if(h.useEffect(()=>{if(!S||f)return;(async()=>{u(!0);try{const b=await Da(s),v=b.filter(M=>!M.available).map(M=>M.command),k=v.length>0&&v.every(Ea),j={isWindows:!0,missingCommands:v,commands:b,canAutoFix:k};n(j),t&&t(j)}catch(b){console.error("Failed to check Windows compatibility:",b)}finally{u(!1)}})()},[S,f,s,t]),!S||f||w&&!c||c&&c.missingCommands.length===0)return null;const g=async()=>{m.mutate()},y=()=>{d(!0)};return e.jsx("div",{className:"border border-warning/50 bg-warning/5 rounded-lg p-4 mb-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Qe,{className:"w-5 h-5 text-warning flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold text-foreground",children:a({id:"mcp.windows.title"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:a({id:"mcp.windows.description"})})]}),e.jsx(D,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:y,children:"×"})]}),c&&e.jsxs(e.Fragment,{children:[c.missingCommands.length>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(I,{variant:"warning",className:"text-xs",children:a({id:"mcp.windows.missingCount"},{count:c.missingCommands.length})})}),e.jsx(Oa,{commands:c.commands}),c.canAutoFix&&e.jsxs("div",{className:"flex items-center gap-2 pt-2 border-t border-warning/20",children:[e.jsx(D,{variant:"outline",size:"sm",onClick:g,disabled:m.isPending,className:"text-xs",children:m.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"w-3 h-3 mr-1 animate-spin"}),a({id:"mcp.windows.fixing"})]}):e.jsxs(e.Fragment,{children:[e.jsx($s,{className:"w-3 h-3 mr-1"}),a({id:"mcp.windows.autoFix"})]})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:a({id:"mcp.windows.autoFixHint"})})]})]}),w&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Te,{className:"w-4 h-4 animate-spin"}),a({id:"mcp.windows.checking"})]})]})]})})}function Ka({onSuccess:s,className:t}){const{formatMessage:a}=G(),l=xe(pe),{servers:c}=Us(),[n,w]=h.useState(new Set),[u,f]=h.useState([]),[d,S]=h.useState(new Set),[m,g]=h.useState(!1),[y,p]=h.useState(null),[b,v]=h.useState(!1),[k,j]=h.useState({type:null,copied:0,failed:0});h.useEffect(()=>{(async()=>{g(!0),p(null);try{const L=await Rs();f((L.servers??[]).map(A=>({name:A.name,displayText:de(A)?A.url:me(A)?A.command:"",enabled:A.enabled,selected:!1})))}catch(L){console.error("Failed to load Codex MCP servers:",L),p(a({id:"mcp.sync.codexLoadError"})),f([])}finally{g(!1)}})()},[a]);const M=N=>{w(L=>{const A=new Set(L);return A.has(N)?A.delete(N):A.add(N),A})},T=()=>{w(new Set(c.map(N=>N.name)))},P=()=>{w(new Set)},r=N=>{S(L=>{const A=new Set(L);return A.has(N)?A.delete(N):A.add(N),A}),f(L=>L.map(A=>A.name===N?{...A,selected:!A.selected}:A))},x=()=>{const N=u.map(L=>L.name);S(new Set(N)),f(L=>L.map(A=>({...A,selected:!0})))},E=()=>{S(new Set),f(N=>N.map(L=>({...L,selected:!1})))},O=async()=>{if(n.size!==0){v(!0),j({type:null,copied:0,failed:0});try{const N=await Je({source:"claude",target:"codex",serverNames:Array.from(n),projectPath:l??void 0});if(N.success){const L=N.failed.length,A=N.copied.length;j({type:L>0?"partial":"success",copied:A,failed:L}),s==null||s(A,"to-codex"),w(new Set),setTimeout(()=>{j({type:null,copied:0,failed:0})},3e3)}}catch(N){console.error("Failed to copy to Codex:",N),j({type:"partial",copied:0,failed:n.size})}finally{v(!1)}}},H=async()=>{if(!(d.size===0||!l)){v(!0),j({type:null,copied:0,failed:0});try{const N=await Je({source:"codex",target:"claude",serverNames:Array.from(d),projectPath:l});if(N.success){const L=N.failed.length,A=N.copied.length;j({type:L>0?"partial":"success",copied:A,failed:L}),s==null||s(A,"from-codex"),S(new Set),f(ce=>ce.map(oe=>({...oe,selected:!1}))),setTimeout(()=>{j({type:null,copied:0,failed:0})},3e3)}}catch(N){console.error("Failed to copy from Codex:",N),j({type:"partial",copied:0,failed:d.size})}finally{v(!1)}}},$=c.length,W=n.size,J=u.length,U=d.size;return e.jsxs("div",{className:_("space-y-4",t),children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:a({id:"mcp.sync.title"})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a({id:"mcp.sync.description"})})]}),k.type!==null&&e.jsxs("div",{className:_("flex items-center gap-2 p-3 rounded-lg border",k.type==="success"?"bg-success/10 border-success/30 text-success":"bg-warning/10 border-warning/30 text-warning"),children:[k.type==="success"?e.jsx(Pt,{className:"w-4 h-4 flex-shrink-0"}):e.jsx(Ft,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm",children:k.type==="success"?a({id:"mcp.sync.copySuccess"},{count:k.copied}):a({id:"mcp.sync.copyPartial"},{copied:k.copied,failed:k.failed})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[e.jsx("div",{className:"bg-muted/50 px-4 py-3 border-b border-border",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground",children:a({id:"mcp.sync.claudeColumn"})}),e.jsx(I,{variant:"outline",className:"text-xs",children:a({id:"mcp.sync.selectedCount"},{count:W,total:$})})]})}),e.jsx("div",{className:"p-2 max-h-64 overflow-y-auto",children:$===0?e.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:a({id:"mcp.sync.noServers"})}):e.jsx("div",{className:"space-y-1",children:c.map(N=>e.jsxs("div",{className:_("flex items-start gap-2 p-2 rounded cursor-pointer transition-colors",n.has(N.name)?"bg-primary/10":"hover:bg-muted/50"),onClick:()=>M(N.name),children:[e.jsx(Ms,{id:`claude-${N.name}`,checked:n.has(N.name),onChange:()=>M(N.name),className:"w-4 h-4 mt-0.5"}),e.jsxs("label",{htmlFor:`claude-${N.name}`,className:"flex-1 min-w-0 cursor-pointer",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:N.name}),N.enabled&&e.jsx(I,{variant:"success",className:"text-xs",children:a({id:"mcp.status.enabled"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono truncate",children:de(N)?N.url:me(N)?N.command:""})]})]},N.name))})}),$>0&&e.jsxs("div",{className:"px-2 py-2 bg-muted/30 border-t border-border flex gap-1",children:[e.jsx(D,{variant:"ghost",size:"sm",onClick:T,className:"flex-1 text-xs",children:a({id:"mcp.sync.selectAll"})}),e.jsx(D,{variant:"ghost",size:"sm",onClick:P,className:"flex-1 text-xs",disabled:W===0,children:a({id:"mcp.sync.clearAll"})})]})]}),e.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[e.jsx("div",{className:"bg-muted/50 px-4 py-3 border-b border-border",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground",children:a({id:"mcp.sync.codexColumn"})}),e.jsx(I,{variant:"outline",className:"text-xs",children:a({id:"mcp.sync.selectedCount"},{count:U,total:J})})]})}),e.jsx("div",{className:"p-2 max-h-64 overflow-y-auto",children:m?e.jsx("div",{className:"py-8 flex items-center justify-center",children:e.jsx(Te,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):y?e.jsx("div",{className:"py-8 text-center text-sm text-destructive",children:y}):J===0?e.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:a({id:"mcp.sync.noServers"})}):e.jsx("div",{className:"space-y-1",children:u.map(N=>e.jsxs("div",{className:_("flex items-start gap-2 p-2 rounded cursor-pointer transition-colors",N.selected?"bg-primary/10":"hover:bg-muted/50"),onClick:()=>r(N.name),children:[e.jsx(Ms,{id:`codex-${N.name}`,checked:N.selected,onChange:()=>r(N.name),className:"w-4 h-4 mt-0.5"}),e.jsxs("label",{htmlFor:`codex-${N.name}`,className:"flex-1 min-w-0 cursor-pointer",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:N.name}),N.enabled&&e.jsx(I,{variant:"success",className:"text-xs",children:a({id:"mcp.status.enabled"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono truncate",children:N.displayText})]})]},N.name))})}),J>0&&e.jsxs("div",{className:"px-2 py-2 bg-muted/30 border-t border-border flex gap-1",children:[e.jsx(D,{variant:"ghost",size:"sm",onClick:x,className:"flex-1 text-xs",children:a({id:"mcp.sync.selectAll"})}),e.jsx(D,{variant:"ghost",size:"sm",onClick:E,className:"flex-1 text-xs",disabled:U===0,children:a({id:"mcp.sync.clearAll"})})]})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx(D,{onClick:O,disabled:W===0||b,variant:"default",className:"min-w-40",children:b?e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"w-4 h-4 mr-2 animate-spin"}),a({id:"mcp.sync.syncInProgress"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ut,{className:"w-4 h-4 mr-2"}),a({id:"mcp.sync.copyToCodex"},{count:W})]})}),e.jsx(D,{onClick:H,disabled:U===0||b||!l,variant:"default",className:"min-w-40",children:b?e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"w-4 h-4 mr-2 animate-spin"}),a({id:"mcp.sync.syncInProgress"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Et,{className:"w-4 h-4 mr-2"}),a({id:"mcp.sync.copyFromCodex"},{count:U})]})})]})]})}function za({onProjectClick:s,onOpenNewWindow:t,className:a,maxProjects:l,projectPaths:c}){const{formatMessage:n}=G(),[w,u]=h.useState("lastModified"),[f,d]=h.useState("desc"),[S,m]=h.useState([]),[g,y]=h.useState(!1),{projects:p,currentProject:b,isLoading:v}=Gs(),k=h.useMemo(()=>{const r=c??p;return l?r.slice(0,l):r},[c,p,l]);h.useEffect(()=>{(async()=>{if(k.length===0){m([]);return}y(!0);try{const x=await Ye(k),E=k.map(O=>{const H=O===b,$=O.split(/[/\\]/).filter(Boolean).pop()||O,W=x.servers[O]??[];return{name:$,path:O,serverCount:W.length,enabledCount:W.filter(J=>J.enabled).length,lastModified:void 0,isCurrent:H}});m(E)}catch(x){console.error("Failed to fetch project server stats:",x),m(k.map(E=>({name:E.split(/[/\\]/).filter(Boolean).pop()||E,path:E,serverCount:0,enabledCount:0,isCurrent:E===b})))}finally{y(!1)}})()},[k,b]);const j=[...S].sort((r,x)=>{let E=0;switch(w){case"name":E=r.name.localeCompare(x.name);break;case"serverCount":E=r.serverCount-x.serverCount;break;case"lastModified":E=r.lastModified&&x.lastModified?new Date(r.lastModified).getTime()-new Date(x.lastModified).getTime():0;break}return f==="asc"?E:-E}),M=r=>{w===r?d(x=>x==="asc"?"desc":"asc"):(u(r),d("desc"))},T=r=>{s==null||s(r)},P=(r,x)=>{r.stopPropagation(),t==null||t(x)};return v||g?e.jsx(Z,{className:_("p-8",a),children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx("div",{className:"animate-spin text-muted-foreground",children:"-"}),e.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:n({id:"common.actions.loading"})})]})}):j.length===0?e.jsx(Z,{className:_("p-8",a),children:e.jsxs("div",{className:"text-center",children:[e.jsx(Ne,{className:"w-12 h-12 mx-auto text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n({id:"mcp.allProjects.empty"})})]})}):e.jsxs(Z,{className:_("overflow-hidden",a),children:[e.jsxs("div",{className:"grid grid-cols-12 gap-2 px-4 py-3 bg-muted/50 border-b border-border text-xs font-medium text-muted-foreground uppercase",children:[e.jsx("div",{className:"col-span-4",children:e.jsxs("button",{onClick:()=>M("name"),className:"flex items-center gap-1 hover:text-foreground transition-colors",children:[n({id:"mcp.allProjects.name"}),w==="name"&&e.jsx("span",{className:"text-foreground",children:f==="asc"?"↑":"↓"})]})}),e.jsx("div",{className:"col-span-3",children:e.jsxs("button",{onClick:()=>M("serverCount"),className:"flex items-center gap-1 hover:text-foreground transition-colors",children:[n({id:"mcp.allProjects.servers"}),w==="serverCount"&&e.jsx("span",{className:"text-foreground",children:f==="asc"?"↑":"↓"})]})}),e.jsx("div",{className:"col-span-3",children:e.jsxs("button",{onClick:()=>M("lastModified"),className:"flex items-center gap-1 hover:text-foreground transition-colors",children:[n({id:"mcp.allProjects.lastModified"}),w==="lastModified"&&e.jsx("span",{className:"text-foreground",children:f==="asc"?"↑":"↓"})]})}),e.jsx("div",{className:"col-span-2 text-right",children:n({id:"mcp.allProjects.actions"})})]}),e.jsx("div",{className:"divide-y divide-border",children:j.map(r=>e.jsxs("div",{onClick:()=>T(r.path),className:_("grid grid-cols-12 gap-2 px-4 py-3 items-center transition-colors cursor-pointer hover:bg-muted/50",r.isCurrent&&"bg-primary/5 hover:bg-primary/10"),children:[e.jsx("div",{className:"col-span-4 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:r.name}),r.isCurrent&&e.jsx(I,{variant:"default",className:"text-xs",children:n({id:"mcp.allProjects.current"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono truncate",children:r.path})]})]})}),e.jsx("div",{className:"col-span-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hs,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm text-foreground",children:[r.serverCount," ",n({id:"mcp.allProjects.servers"})]}),e.jsxs(I,{variant:"outline",className:_("text-xs",r.enabledCount>0?"text-success border-success/30":"text-muted-foreground"),children:[r.enabledCount," ",n({id:"mcp.status.enabled"})]})]})}),e.jsx("div",{className:"col-span-3",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Dt,{className:"w-4 h-4"}),e.jsx("span",{children:r.lastModified?Bt(new Date(r.lastModified),{addSuffix:!0}):"-"})]})}),e.jsx("div",{className:"col-span-2 flex justify-end gap-1",children:e.jsx("button",{onClick:x=>P(x,r.path),className:"p-1.5 rounded hover:bg-muted transition-colors",title:n({id:"mcp.allProjects.openNewWindow"}),children:e.jsx(qt,{className:"w-4 h-4 text-muted-foreground"})})})]},r.path))}),e.jsx("div",{className:"px-4 py-2 bg-muted/30 border-t border-border text-xs text-muted-foreground",children:n({id:"mcp.allProjects.summary"},{count:j.length})})]})}function Ia({onImportSuccess:s,className:t}){const{formatMessage:a}=G(),[l,c]=h.useState(null),[n,w]=h.useState([]),[u,f]=h.useState(!1),{projects:d,currentProject:S,fetchOtherServers:m,isFetchingServers:g}=Gs(),{createServer:y,isCreating:p}=Bs(),b=d.filter(T=>T!==S),v=async T=>{c(T),f(!0);try{const P=await m([T]),r=[];for(const[x,E]of Object.entries(P.servers)){const O=x.split(/[/\\]/).filter(Boolean).pop()||x;for(const H of E)r.push({name:H.name,enabled:H.enabled,displayText:de(H)?H.url:me(H)?H.command:"",transport:H.transport,projectPath:x,projectName:O,originalServer:H})}w(r)}catch(P){console.error("Failed to fetch other projects servers:",P),w([])}finally{f(!1)}},k=async T=>{try{const P=`${T.projectName}-${T.name}`.toLowerCase().replace(/\s+/g,"-"),r={...T.originalServer,name:P,scope:"project"};await y(r),s==null||s(P,T.projectPath)}catch(P){console.error("Failed to import server:",P)}},j=u||g||p,M=l?l.split(/[/\\]/).filter(Boolean).pop():null;return e.jsxs(Z,{className:_("p-4",t),children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{className:"w-5 h-5 text-primary"}),e.jsx("h3",{className:"text-sm font-medium text-foreground",children:a({id:"mcp.otherProjects.title"})})]}),e.jsx(D,{variant:"ghost",size:"sm",onClick:()=>l&&v(l),disabled:!l||j,className:"h-8",children:e.jsx(es,{className:_("w-4 h-4",j&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:a({id:"mcp.otherProjects.description"})}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"text-sm font-medium text-foreground mb-2 block",children:a({id:"mcp.otherProjects.selectProject"})}),e.jsxs(He,{value:l??"",onValueChange:v,children:[e.jsx(_e,{className:"w-full",children:e.jsx($e,{placeholder:a({id:"mcp.otherProjects.selectProjectPlaceholder"})})}),e.jsx(Re,{children:b.length===0?e.jsx("div",{className:"p-2 text-sm text-muted-foreground text-center",children:a({id:"mcp.otherProjects.noProjects"})}):b.map(T=>{const P=T.split(/[/\\]/).filter(Boolean).pop()||T;return e.jsx(he,{value:T,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:P})]})},T)})})]})]}),l&&e.jsx("div",{className:"space-y-2",children:u?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx("div",{className:"animate-spin text-muted-foreground",children:"-"}),e.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:a({id:"common.actions.loading"})})]}):n.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground border border-dashed rounded-lg",children:a({id:"mcp.otherProjects.noServers"},{project:M})}):e.jsx("div",{className:"space-y-2 max-h-60 overflow-y-auto",children:n.map(T=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:T.name}),T.enabled&&e.jsx(I,{variant:"success",className:"text-xs",children:a({id:"mcp.status.enabled"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono truncate",children:T.displayText}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[e.jsx("span",{className:"font-medium",children:T.projectName}),e.jsx(Qs,{className:"inline w-3 h-3 mx-1"}),e.jsx("span",{className:"font-mono",children:T.projectPath})]})]}),e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>k(T),disabled:p,className:"flex-shrink-0",children:[e.jsx(ls,{className:"w-4 h-4 mr-1"}),a({id:"mcp.otherProjects.import"})]})]},`${T.projectPath}-${T.name}`))})}),l&&n.length>0&&e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:a({id:"mcp.otherProjects.hint"})})]})}function Qa(s){return!s||s.length<=4?"****":s.substring(0,4)+"****"}function La({server:s,isExpanded:t,onToggleExpand:a,onToggle:l,onEdit:c,onDelete:n,onSaveAsTemplate:w,conflictInfo:u}){const{formatMessage:f}=G(),[d,S]=h.useState({}),m=de(s),g=me(s),y=()=>{var v;return m?s.url:`${s.command} ${((v=s.args)==null?void 0:v.join(" "))||""}`.trim()},p=()=>{if(!m)return[];const v=[];return s.headers&&Object.entries(s.headers).forEach(([k,j])=>{v.push({name:k,value:j})}),s.httpHeaders&&Object.entries(s.httpHeaders).forEach(([k,j])=>{v.push({name:k,value:j})}),s.bearerTokenEnvVar&&v.push({name:"Authorization",value:`Bearer $${s.bearerTokenEnvVar}`,isEnvVar:!0}),v},b=v=>{S(k=>({...k,[v]:!k[v]}))};return e.jsxs(Z,{className:_("overflow-hidden",!s.enabled&&"opacity-60"),children:[e.jsx("div",{className:"p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:a,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:_("p-2 rounded-lg",s.enabled?"bg-primary/10":"bg-muted"),children:e.jsx(qe,{className:_("w-5 h-5",s.enabled?"text-primary":"text-muted-foreground")})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:s.name}),m&&e.jsxs(I,{variant:"outline",className:"text-xs text-blue-600 border-blue-300",children:[e.jsx(Ws,{className:"w-3 h-3 mr-1"}),f({id:"mcp.transport.http"})]}),e.jsx(I,{variant:s.scope==="global"?"default":"secondary",className:"text-xs",children:s.scope==="global"?e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-3 h-3 mr-1"}),f({id:"mcp.scope.global"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"w-3 h-3 mr-1"}),f({id:"mcp.scope.project"})]})}),u&&e.jsxs(I,{variant:"outline",className:"text-xs text-orange-500 border-orange-300",children:[e.jsx(Qe,{className:"w-3 h-3 mr-1"}),f({id:"mcp.conflict.badge"})]}),s.enabled&&e.jsx(I,{variant:"outline",className:"text-xs text-green-600",children:f({id:"mcp.status.enabled"})})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 font-mono truncate max-w-md",title:y(),children:y()})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:v=>{v.stopPropagation(),l(s.name,!s.enabled)},children:s.enabled?e.jsx(ke,{className:"w-4 h-4 text-green-600"}):e.jsx(ss,{className:"w-4 h-4"})}),e.jsx(D,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:v=>{v.stopPropagation(),w(s)},title:f({id:"mcp.templates.actions.saveAsTemplate"}),children:e.jsx(Jt,{className:"w-4 h-4 text-primary"})}),e.jsx(D,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:v=>{v.stopPropagation(),c(s)},children:e.jsx(Yt,{className:"w-4 h-4"})}),e.jsx(D,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:v=>{v.stopPropagation(),n(s)},children:e.jsx(Me,{className:"w-4 h-4 text-destructive"})}),t?e.jsx(Is,{className:"w-5 h-5 text-muted-foreground"}):e.jsx(os,{className:"w-5 h-5 text-muted-foreground"})]})]})}),t&&e.jsxs("div",{className:"border-t border-border p-4 space-y-3 bg-muted/30",children:[m&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:f({id:"mcp.http.url"})}),e.jsx("code",{className:"text-sm bg-background px-2 py-1 rounded block overflow-x-auto break-all",children:s.url})]}),p().length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:f({id:"mcp.http.headers"})}),e.jsx("div",{className:"space-y-1",children:p().map(v=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(I,{variant:"secondary",className:"font-mono",children:v.name}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"text-xs bg-background px-2 py-1 rounded flex-1 overflow-x-auto",children:d[v.name]?v.value:Qa(v.value)}),e.jsx(D,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>b(v.name),title:d[v.name]?f({id:"mcp.http.hideValue"}):f({id:"mcp.http.showValue"}),children:d[v.name]?e.jsx(fs,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(js,{className:"w-3 h-3 text-muted-foreground"})}),v.isEnvVar&&e.jsx(I,{variant:"outline",className:"text-xs text-blue-500",children:f({id:"mcp.http.envVar"})})]},v.name))})]})]}),g&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:f({id:"mcp.command"})}),e.jsx("code",{className:"text-sm bg-background px-2 py-1 rounded block overflow-x-auto",children:s.command})]}),s.args&&s.args.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:f({id:"mcp.args"})}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.args.map((v,k)=>e.jsx(I,{variant:"outline",className:"font-mono text-xs",children:v},k))})]}),s.env&&Object.keys(s.env).length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:f({id:"mcp.env"})}),e.jsx("div",{className:"space-y-1",children:Object.entries(s.env).map(([v,k])=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(I,{variant:"secondary",className:"font-mono",children:v}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"text-xs bg-background px-2 py-1 rounded flex-1 overflow-x-auto",children:k})]},v))})]})]}),u&&e.jsxs("div",{className:"p-3 bg-orange-50 dark:bg-orange-950/30 border border-orange-200 dark:border-orange-800 rounded-lg space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-orange-700 dark:text-orange-400",children:[e.jsx(Qe,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:f({id:"mcp.conflict.title"})})]}),e.jsx("p",{className:"text-xs text-orange-600 dark:text-orange-400/80",children:f({id:"mcp.conflict.description"},{scope:f({id:`mcp.scope.${u.effectiveScope}`})})}),e.jsx("p",{className:"text-xs text-orange-600 dark:text-orange-400/80",children:f({id:"mcp.conflict.resolution"})})]})]})]})}function mn(){var Cs,Ss;const{formatMessage:s}=G(),[t,a]=h.useState("servers"),[l,c]=h.useState(""),[n,w]=h.useState("all"),[u,f]=h.useState(new Set),[d,S]=h.useState(!1),[m,g]=h.useState(void 0),[y,p]=h.useState("claude"),[b,v]=h.useState(new Set),[k,j]=h.useState(!1),[M,T]=h.useState(void 0),P=ae(),r=Ve(),{servers:x,projectServers:E,globalServers:O,conflicts:H,totalCount:$,enabledCount:W,isLoading:J,isFetching:U,refetch:N}=Us({scope:n==="all"?void 0:n}),L=fe({queryKey:["codexMcpServers"],queryFn:Rs,enabled:y==="codex",staleTime:120*1e3}),A=xe(pe),ce=fe({queryKey:["ccwMcpConfig",A],queryFn:()=>zt(A??void 0),enabled:y==="claude",staleTime:300*1e3}),oe=fe({queryKey:["ccwMcpConfigCodex"],queryFn:It,enabled:y==="codex",staleTime:300*1e3}),{toggleServer:Ce,deleteServer:ve}=Bs(),Fe=i=>{f(C=>{const Q=new Set(C);return Q.has(i)?Q.delete(i):Q.add(i),Q})},le=i=>{v(C=>{const Q=new Set(C);return Q.has(i)?Q.delete(i):Q.add(i),Q})},ye=(i,C)=>{Ce(i,C)},q=async i=>{if(confirm(s({id:"mcp.deleteConfirm"},{name:i.name})))try{await ve(i.name,i.scope),r.success(s({id:"mcp.actions.delete"}),i.name),N()}catch(C){console.error("Failed to delete MCP server:",C),r.error(s({id:"mcp.actions.delete"}),C instanceof Error?C.message:String(C))}},ne=i=>{g(i),S(!0)},Se=()=>{g(void 0),S(!0)},Ee=()=>{S(!1),g(void 0)},We=()=>{S(!1),g(void 0),N()},Ue=i=>{p(i)},re=ce.data??{isInstalled:!1,enabledTools:[],projectRoot:void 0,allowedDirs:void 0,enableSandbox:void 0,installedScopes:[]},o=["ccwMcpConfig",A],F=async(i,C)=>{const Q=P.getQueryData(o)??re,z=Q.enabledTools,Y=P.getQueryData(o),ie=C?z.includes(i)?z:[...z,i]:z.filter(R=>R!==i);P.setQueryData(o,R=>R&&{...R,enabledTools:ie});try{await Xe({...Q,enabledTools:ie})}catch(R){r.error(s({id:"mcp.actions.toggle.error"}),R instanceof Error?R.message:String(R)),console.error("Failed to toggle CCW tool:",R),P.setQueryData(o,Y)}ce.refetch()},K=async i=>{const C=P.getQueryData(o);P.setQueryData(o,z=>z&&{...z,...i});const Q=P.getQueryData(o)??re;try{await Xe({enabledTools:Q.enabledTools,projectRoot:Q.projectRoot,allowedDirs:Q.allowedDirs,enableSandbox:Q.enableSandbox})}catch(z){r.error(s({id:"mcp.actions.update.error"}),z instanceof Error?z.message:String(z)),console.error("Failed to update CCW config:",z),P.setQueryData(o,C)}ce.refetch()},V=()=>{ce.refetch()},ee=h.useMemo(()=>{const i=new Map;for(const C of H)i.set(C.name,C);return i},[H]),ue=async i=>{try{await Vs(i,i==="project"?A??void 0:void 0),ce.refetch()}catch(C){r.error(s({id:"mcp.actions.install.error"}),C instanceof Error?C.message:String(C)),console.error("Failed to install CCW MCP to scope:",C)}},De=async i=>{try{await Ot(i,i==="project"?A??void 0:void 0),ce.refetch(),P.invalidateQueries({queryKey:["mcpServers"]})}catch(C){r.error(s({id:"mcp.actions.uninstall.error"}),C instanceof Error?C.message:String(C)),console.error("Failed to uninstall CCW MCP from scope:",C)}},se=oe.data??{isInstalled:!1,enabledTools:[],projectRoot:void 0,allowedDirs:void 0,enableSandbox:void 0,installedScopes:[]},be=async(i,C)=>{const Q=P.getQueryData(["ccwMcpConfigCodex"])??se,z=Q.enabledTools,Y=P.getQueryData(["ccwMcpConfigCodex"]),ie=C?z.includes(i)?z:[...z,i]:z.filter(R=>R!==i);P.setQueryData(["ccwMcpConfigCodex"],R=>R&&{...R,enabledTools:ie});try{await Ze({...Q,enabledTools:ie})}catch(R){r.error(s({id:"mcp.actions.toggle.error"}),R instanceof Error?R.message:String(R)),console.error("Failed to toggle CCW tool (Codex):",R),P.setQueryData(["ccwMcpConfigCodex"],Y)}oe.refetch()},Be=async i=>{const C=P.getQueryData(["ccwMcpConfigCodex"])??se,Q=P.getQueryData(["ccwMcpConfigCodex"]);P.setQueryData(["ccwMcpConfigCodex"],z=>z&&{...z,...i});try{await Ze({...C,...i})}catch(z){r.error(s({id:"mcp.actions.update.error"}),z instanceof Error?z.message:String(z)),console.error("Failed to update CCW config (Codex):",z),P.setQueryData(["ccwMcpConfigCodex"],Q)}oe.refetch()},Xs=()=>{oe.refetch()},et=i=>{const C=(i==null?void 0:i.serverConfig)??{},Q=C.type==="http"||C.transport==="http"||typeof C.url=="string";g(Q?{name:i.name,transport:"http",url:C.url??"",scope:"project",enabled:!0}:{name:i.name,transport:"stdio",command:C.command,args:C.args||[],env:C.env,scope:"project",enabled:!0}),S(!0)},st=i=>{T(i),j(!0)},vs=async(i,C,Q,z)=>{try{const Y=await zs({name:i,description:Q||void 0,category:C||"custom",serverConfig:{command:z.command,args:z.args.length>0?z.args:void 0,env:Object.keys(z.env).length>0?z.env:void 0}});Y.success?(r.success(s({id:"mcp.templates.feedback.saveSuccess"}),i),j(!1),T(void 0)):r.error(s({id:"mcp.templates.feedback.saveError"}),Y.error||"")}catch(Y){r.error(s({id:"mcp.templates.feedback.saveError"}),Y instanceof Error?Y.message:String(Y))}},tt=async i=>{try{await Kt(i),r.success(s({id:"mcp.actions.delete"}),i),L.refetch()}catch(C){console.error("Failed to remove Codex MCP server:",C),r.error(s({id:"mcp.actions.delete"}),C instanceof Error?C.message:String(C))}},at=async(i,C)=>{try{await At(i,C),L.refetch()}catch(Q){r.error(s({id:"mcp.actions.toggle.error"}),Q instanceof Error?Q.message:String(Q)),console.error("Failed to toggle Codex MCP server:",Q)}},nt=x.filter(i=>{var Y,ie;const C=l.toLowerCase(),Q=i.name.toLowerCase().includes(C),z=de(i)?(Y=i.url)==null?void 0:Y.toLowerCase().includes(C):(ie=i.command)==null?void 0:ie.toLowerCase().includes(C);return Q||z}),rt=((Cs=L.data)==null?void 0:Cs.servers)??[],ct=((Ss=L.data)==null?void 0:Ss.configPath)??"",ot=rt.filter(i=>{var Y,ie;const C=l.toLowerCase(),Q=i.name.toLowerCase().includes(C),z=de(i)?(Y=i.url)==null?void 0:Y.toLowerCase().includes(C):(ie=i.command)==null?void 0:ie.toLowerCase().includes(C);return Q||z}),ys=y==="codex"?ot:nt,Ns=y==="codex"?b:u,bs=y==="codex"?le:Fe,lt=y==="codex"?L.isLoading:J,ws=y==="codex"?L.isFetching:U,it=y==="codex"?(()=>L.refetch()):N;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(qe,{className:"w-6 h-6 text-primary"}),s({id:"mcp.title"})]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:s({id:"mcp.description"})})]}),e.jsx("div",{className:"ml-3 flex-shrink-0",children:e.jsx(Lt,{currentMode:y,onModeChange:Ue,codexConfigPath:ct})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(D,{variant:"outline",onClick:()=>it(),disabled:ws,children:[e.jsx(es,{className:_("w-4 h-4 mr-2",ws&&"animate-spin")}),s({id:"common.actions.refresh"})]}),y==="claude"&&e.jsxs(D,{onClick:Se,children:[e.jsx(Ie,{className:"w-4 h-4 mr-2"}),s({id:"mcp.actions.add"})]})]})]}),e.jsx(Gt,{value:t,onValueChange:i=>a(i),tabs:[{value:"templates",label:s({id:"mcp.tabs.templates"})},{value:"servers",label:s({id:"mcp.tabs.servers"})},{value:"cross-cli",label:s({id:"mcp.tabs.crossCli"})}]}),t==="templates"&&e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsx(Pa,{onInstallComplete:()=>N()}),e.jsx(ba,{onInstallTemplate:et,onSaveAsTemplate:vs})]}),t==="servers"&&e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsx(Aa,{}),y==="claude"&&e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs(Z,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qe,{className:"w-5 h-5 text-primary"}),e.jsx("span",{className:"text-2xl font-bold",children:$})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s({id:"mcp.stats.total"})})]}),e.jsxs(Z,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"w-5 h-5 text-green-600"}),e.jsx("span",{className:"text-2xl font-bold",children:W})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s({id:"mcp.stats.enabled"})})]}),e.jsxs(Z,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"w-5 h-5 text-info"}),e.jsx("span",{className:"text-2xl font-bold",children:O.length})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s({id:"mcp.stats.global"})})]}),e.jsxs(Z,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"w-5 h-5 text-warning"}),e.jsx("span",{className:"text-2xl font-bold",children:E.length})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s({id:"mcp.stats.project"})})]})]}),y==="claude"&&e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ae,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(X,{placeholder:s({id:"mcp.filters.searchPlaceholder"}),value:l,onChange:i=>c(i.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{variant:n==="all"?"default":"outline",size:"sm",onClick:()=>w("all"),children:s({id:"mcp.filters.all"})}),e.jsxs(D,{variant:n==="global"?"default":"outline",size:"sm",onClick:()=>w("global"),children:[e.jsx(je,{className:"w-4 h-4 mr-1"}),s({id:"mcp.scope.global"})]}),e.jsxs(D,{variant:n==="project"?"default":"outline",size:"sm",onClick:()=>w("project"),children:[e.jsx(Ne,{className:"w-4 h-4 mr-1"}),s({id:"mcp.scope.project"})]})]})]}),y==="codex"&&e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ae,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(X,{placeholder:s({id:"mcp.filters.searchPlaceholder"}),value:l,onChange:i=>c(i.target.value),className:"pl-9"})]}),y==="claude"&&e.jsx(Ds,{isInstalled:re.isInstalled,enabledTools:re.enabledTools,projectRoot:re.projectRoot,allowedDirs:re.allowedDirs,enableSandbox:re.enableSandbox,onToggleTool:F,onUpdateConfig:K,onInstall:V,installedScopes:re.installedScopes,onInstallToScope:ue,onUninstallScope:De}),y==="codex"&&e.jsx(Ds,{target:"codex",isInstalled:se.isInstalled,enabledTools:se.enabledTools,projectRoot:se.projectRoot,allowedDirs:se.allowedDirs,enableSandbox:se.enableSandbox,onToggleTool:be,onUpdateConfig:Be,onInstall:Xs}),lt?e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(i=>e.jsx("div",{className:"h-24 bg-muted animate-pulse rounded-lg"},i))}):ys.length===0?e.jsxs(Z,{className:"p-8 text-center",children:[e.jsx(qe,{className:"w-12 h-12 mx-auto text-muted-foreground/50"}),e.jsx("h3",{className:"mt-4 text-lg font-medium text-foreground",children:s({id:"mcp.emptyState.title"})}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s({id:"mcp.emptyState.message"})})]}):e.jsx("div",{className:"space-y-3",children:ys.map(i=>y==="codex"?e.jsx(ja,{server:i,enabled:i.enabled,isExpanded:Ns.has(i.name),onToggleExpand:()=>bs(i.name),isEditable:!0,onRemove:tt,onToggle:at},`${i.name}-${i.scope}`):e.jsx(La,{server:i,isExpanded:Ns.has(`${i.name}-${i.scope}`),onToggleExpand:()=>bs(`${i.name}-${i.scope}`),onToggle:ye,onEdit:ne,onDelete:q,onSaveAsTemplate:st,conflictInfo:ee.get(i.name)},`${i.name}-${i.scope}`))})]}),t==="cross-cli"&&e.jsxs("div",{className:"mt-4 space-y-6",children:[e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(es,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("h3",{className:"text-sm font-medium text-foreground",children:s({id:"mcp.sync.title"})})]}),e.jsx(Z,{className:"p-4",children:e.jsx(Ka,{onSuccess:()=>N()})})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Ne,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("h3",{className:"text-sm font-medium text-foreground",children:s({id:"mcp.projects.title"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s({id:"mcp.projects.description"})}),e.jsx(za,{maxProjects:10,onProjectClick:i=>console.log("Open project:",i),onOpenNewWindow:i=>window.open(`/?project=${encodeURIComponent(i)}`,"_blank")})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(je,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("h3",{className:"text-sm font-medium text-foreground",children:s({id:"mcp.crossProject.title"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s({id:"mcp.crossProject.description"})}),e.jsx(Ia,{onImportSuccess:(i,C)=>{console.log("Imported server:",i,"from:",C),N()}})]})]}),y==="claude"&&e.jsx(ga,{mode:m?"edit":"add",server:m,open:d,onClose:Ee,onSave:We}),e.jsx(Zs,{open:k,onClose:()=>{j(!1),T(void 0)},onSave:vs,defaultName:M==null?void 0:M.name,defaultCommand:M&&me(M)?M.command:void 0,defaultArgs:M&&me(M)?M.args:void 0,defaultEnv:M&&me(M)?M.env:void 0})]})}export{mn as McpManagerPage,mn as default};
50
+ //# sourceMappingURL=McpManagerPage-BS-HgeQJ.js.map