@samanhappy/mcphub 0.12.17 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.fr.md +7 -5
  2. package/README.md +24 -4
  3. package/README.zh.md +25 -4
  4. package/bin/cli.js +64 -50
  5. package/dist/cli/call-arguments.js +81 -0
  6. package/dist/cli/call-arguments.js.map +1 -0
  7. package/dist/cli/commands/call.js +75 -0
  8. package/dist/cli/commands/call.js.map +1 -0
  9. package/dist/cli/commands/config.js +132 -0
  10. package/dist/cli/commands/config.js.map +1 -0
  11. package/dist/cli/commands/discover.js +127 -0
  12. package/dist/cli/commands/discover.js.map +1 -0
  13. package/dist/cli/commands/export.js +20 -0
  14. package/dist/cli/commands/export.js.map +1 -0
  15. package/dist/cli/commands/groups.js +107 -0
  16. package/dist/cli/commands/groups.js.map +1 -0
  17. package/dist/cli/commands/install.js +173 -0
  18. package/dist/cli/commands/install.js.map +1 -0
  19. package/dist/cli/commands/keys.js +91 -0
  20. package/dist/cli/commands/keys.js.map +1 -0
  21. package/dist/cli/commands/login.js +70 -0
  22. package/dist/cli/commands/login.js.map +1 -0
  23. package/dist/cli/commands/servers.js +142 -0
  24. package/dist/cli/commands/servers.js.map +1 -0
  25. package/dist/cli/commands/tools.js +162 -0
  26. package/dist/cli/commands/tools.js.map +1 -0
  27. package/dist/cli/context.js +44 -0
  28. package/dist/cli/context.js.map +1 -0
  29. package/dist/cli/errors.js +19 -0
  30. package/dist/cli/errors.js.map +1 -0
  31. package/dist/cli/help.js +157 -0
  32. package/dist/cli/help.js.map +1 -0
  33. package/dist/cli/http.js +93 -0
  34. package/dist/cli/http.js.map +1 -0
  35. package/dist/cli/main.js +81 -0
  36. package/dist/cli/main.js.map +1 -0
  37. package/dist/cli/output.js +47 -0
  38. package/dist/cli/output.js.map +1 -0
  39. package/dist/cli/parse-args.js +103 -0
  40. package/dist/cli/parse-args.js.map +1 -0
  41. package/dist/cli/profile.js +109 -0
  42. package/dist/cli/profile.js.map +1 -0
  43. package/dist/cli/prompts.js +56 -0
  44. package/dist/cli/prompts.js.map +1 -0
  45. package/dist/controllers/oauthServerController.js +37 -1
  46. package/dist/controllers/oauthServerController.js.map +1 -1
  47. package/dist/dao/ServerDaoDbImpl.js +3 -0
  48. package/dist/dao/ServerDaoDbImpl.js.map +1 -1
  49. package/dist/db/connection.js +48 -4
  50. package/dist/db/connection.js.map +1 -1
  51. package/dist/db/entities/Server.js +4 -0
  52. package/dist/db/entities/Server.js.map +1 -1
  53. package/dist/db/entities/VectorEmbedding.js +2 -5
  54. package/dist/db/entities/VectorEmbedding.js.map +1 -1
  55. package/dist/db/repositories/VectorEmbeddingRepository.js +100 -34
  56. package/dist/db/repositories/VectorEmbeddingRepository.js.map +1 -1
  57. package/dist/services/dataService.js +10 -1
  58. package/dist/services/dataService.js.map +1 -1
  59. package/dist/services/mcpService.js +47 -10
  60. package/dist/services/mcpService.js.map +1 -1
  61. package/dist/services/sseService.js +5 -3
  62. package/dist/services/sseService.js.map +1 -1
  63. package/dist/services/vectorSearchService.js +16 -3
  64. package/dist/services/vectorSearchService.js.map +1 -1
  65. package/dist/utils/migration.js +1 -0
  66. package/dist/utils/migration.js.map +1 -1
  67. package/dist/utils/serverConfigPersistence.js +5 -0
  68. package/dist/utils/serverConfigPersistence.js.map +1 -1
  69. package/frontend/dist/assets/ActivityPage-DwzGiMh_.js +2 -0
  70. package/frontend/dist/assets/ActivityPage-DwzGiMh_.js.map +1 -0
  71. package/frontend/dist/assets/ConfirmDialog-CxlizGia.js +2 -0
  72. package/frontend/dist/assets/ConfirmDialog-CxlizGia.js.map +1 -0
  73. package/frontend/dist/assets/Dashboard-BUCJcvk-.js +2 -0
  74. package/frontend/dist/assets/Dashboard-BUCJcvk-.js.map +1 -0
  75. package/frontend/dist/assets/DeleteDialog-DRbWonMu.js +2 -0
  76. package/frontend/dist/assets/DeleteDialog-DRbWonMu.js.map +1 -0
  77. package/frontend/dist/assets/EndpointCopy-D5NjDdYi.js +2 -0
  78. package/frontend/dist/assets/EndpointCopy-D5NjDdYi.js.map +1 -0
  79. package/frontend/dist/assets/GroupsPage-DfLlww4U.js +33 -0
  80. package/frontend/dist/assets/GroupsPage-DfLlww4U.js.map +1 -0
  81. package/frontend/dist/assets/LoginPage-DCjqYw_8.js +2 -0
  82. package/frontend/dist/assets/LoginPage-DCjqYw_8.js.map +1 -0
  83. package/frontend/dist/assets/LogsPage-CTa8kuDf.js +2 -0
  84. package/frontend/dist/assets/LogsPage-CTa8kuDf.js.map +1 -0
  85. package/frontend/dist/assets/MarketPage-C2Rh4WJB.js +3 -0
  86. package/frontend/dist/assets/MarketPage-C2Rh4WJB.js.map +1 -0
  87. package/frontend/dist/assets/{Pagination-y-gVO8ms.js → Pagination-BFi-X7qY.js} +2 -2
  88. package/frontend/dist/assets/{Pagination-y-gVO8ms.js.map → Pagination-BFi-X7qY.js.map} +1 -1
  89. package/frontend/dist/assets/PromptsPage-Dh3qjX3x.js +2 -0
  90. package/frontend/dist/assets/PromptsPage-Dh3qjX3x.js.map +1 -0
  91. package/frontend/dist/assets/ResourcesPage-Bc5ZpCIh.js +2 -0
  92. package/frontend/dist/assets/ResourcesPage-Bc5ZpCIh.js.map +1 -0
  93. package/frontend/dist/assets/ServersPage-hgCbCglG.js +37 -0
  94. package/frontend/dist/assets/ServersPage-hgCbCglG.js.map +1 -0
  95. package/frontend/dist/assets/SettingsPage-BzNX8mXv.js +12 -0
  96. package/frontend/dist/assets/SettingsPage-BzNX8mXv.js.map +1 -0
  97. package/frontend/dist/assets/StatusDot-CQzailBQ.js +2 -0
  98. package/frontend/dist/assets/StatusDot-CQzailBQ.js.map +1 -0
  99. package/frontend/dist/assets/{ToggleGroup-HfxdlkGi.js → ToggleGroup-CNBBvo3C.js} +2 -2
  100. package/frontend/dist/assets/{ToggleGroup-HfxdlkGi.js.map → ToggleGroup-CNBBvo3C.js.map} +1 -1
  101. package/frontend/dist/assets/UsersPage-C33b7LCM.js +2 -0
  102. package/frontend/dist/assets/UsersPage-C33b7LCM.js.map +1 -0
  103. package/frontend/dist/assets/{framework-vendor-_OBebcuv.js → framework-vendor-BUhDPOUZ.js} +2 -2
  104. package/frontend/dist/assets/{framework-vendor-_OBebcuv.js.map → framework-vendor-BUhDPOUZ.js.map} +1 -1
  105. package/frontend/dist/assets/{i18n-vendor-MQ921plD.js → i18n-vendor-Kbr87Ofu.js} +2 -2
  106. package/frontend/dist/assets/{i18n-vendor-MQ921plD.js.map → i18n-vendor-Kbr87Ofu.js.map} +1 -1
  107. package/frontend/dist/assets/icons-vendor-CKgJB3SC.js +292 -0
  108. package/frontend/dist/assets/icons-vendor-CKgJB3SC.js.map +1 -0
  109. package/frontend/dist/assets/index-BGiKkKzj.js +3 -0
  110. package/frontend/dist/assets/index-BGiKkKzj.js.map +1 -0
  111. package/frontend/dist/assets/index-D0OIBhmN.css +1 -0
  112. package/frontend/dist/assets/{resourceService-BfCTSBsr.js → resourceService-C6umWRgq.js} +2 -2
  113. package/frontend/dist/assets/{resourceService-BfCTSBsr.js.map → resourceService-C6umWRgq.js.map} +1 -1
  114. package/frontend/dist/assets/useServerData-P5In98R4.js +2 -0
  115. package/frontend/dist/assets/{useServerData-QZqQTYcv.js.map → useServerData-P5In98R4.js.map} +1 -1
  116. package/frontend/dist/assets/useSettingsData-Cz7vKGLE.js +2 -0
  117. package/frontend/dist/assets/{useSettingsData-D3VROqS7.js.map → useSettingsData-Cz7vKGLE.js.map} +1 -1
  118. package/frontend/dist/assets/variableDetection-DsYuiOB_.js +16 -0
  119. package/frontend/dist/assets/variableDetection-DsYuiOB_.js.map +1 -0
  120. package/frontend/dist/index.html +5 -5
  121. package/package.json +2 -1
  122. package/frontend/dist/assets/ActivityPage-ClgKeihP.js +0 -2
  123. package/frontend/dist/assets/ActivityPage-ClgKeihP.js.map +0 -1
  124. package/frontend/dist/assets/Badge-Ck2fhRdl.js +0 -2
  125. package/frontend/dist/assets/Badge-Ck2fhRdl.js.map +0 -1
  126. package/frontend/dist/assets/ConfirmDialog-uYjffH4V.js +0 -2
  127. package/frontend/dist/assets/ConfirmDialog-uYjffH4V.js.map +0 -1
  128. package/frontend/dist/assets/Dashboard-BIXrLobn.js +0 -2
  129. package/frontend/dist/assets/Dashboard-BIXrLobn.js.map +0 -1
  130. package/frontend/dist/assets/DeleteDialog-BAfrV8EB.js +0 -2
  131. package/frontend/dist/assets/DeleteDialog-BAfrV8EB.js.map +0 -1
  132. package/frontend/dist/assets/GroupsPage-BjrvyHwu.js +0 -33
  133. package/frontend/dist/assets/GroupsPage-BjrvyHwu.js.map +0 -1
  134. package/frontend/dist/assets/LoginPage-BBHt_TfF.js +0 -2
  135. package/frontend/dist/assets/LoginPage-BBHt_TfF.js.map +0 -1
  136. package/frontend/dist/assets/LogsPage-D8Znq5NB.js +0 -2
  137. package/frontend/dist/assets/LogsPage-D8Znq5NB.js.map +0 -1
  138. package/frontend/dist/assets/MarketPage-haRuzjCw.js +0 -3
  139. package/frontend/dist/assets/MarketPage-haRuzjCw.js.map +0 -1
  140. package/frontend/dist/assets/PromptsPage-ByHWPyGe.js +0 -2
  141. package/frontend/dist/assets/PromptsPage-ByHWPyGe.js.map +0 -1
  142. package/frontend/dist/assets/ResourcesPage-Bodw5OY9.js +0 -2
  143. package/frontend/dist/assets/ResourcesPage-Bodw5OY9.js.map +0 -1
  144. package/frontend/dist/assets/ServersPage-CtS1I4yS.js +0 -37
  145. package/frontend/dist/assets/ServersPage-CtS1I4yS.js.map +0 -1
  146. package/frontend/dist/assets/SettingsPage-DxVigf7p.js +0 -12
  147. package/frontend/dist/assets/SettingsPage-DxVigf7p.js.map +0 -1
  148. package/frontend/dist/assets/UsersPage-Bipw33cS.js +0 -2
  149. package/frontend/dist/assets/UsersPage-Bipw33cS.js.map +0 -1
  150. package/frontend/dist/assets/icons-vendor-B67NtVuR.js +0 -172
  151. package/frontend/dist/assets/icons-vendor-B67NtVuR.js.map +0 -1
  152. package/frontend/dist/assets/index-CmnA4an8.js +0 -5
  153. package/frontend/dist/assets/index-CmnA4an8.js.map +0 -1
  154. package/frontend/dist/assets/index-DfFHVARX.css +0 -1
  155. package/frontend/dist/assets/useGroupData-DLhbP6zd.js +0 -2
  156. package/frontend/dist/assets/useGroupData-DLhbP6zd.js.map +0 -1
  157. package/frontend/dist/assets/useServerData-QZqQTYcv.js +0 -2
  158. package/frontend/dist/assets/useSettingsData-D3VROqS7.js +0 -2
  159. package/frontend/dist/assets/variableDetection-C3Xi21av.js +0 -16
  160. package/frontend/dist/assets/variableDetection-C3Xi21av.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Pagination-y-gVO8ms.js","sources":["../../src/components/ui/Pagination.tsx"],"sourcesContent":["import React from 'react';\nimport { useTranslation } from 'react-i18next';\n\ninterface PaginationProps {\n currentPage: number;\n totalPages: number;\n onPageChange: (page: number) => void;\n disabled?: boolean;\n}\n\nconst Pagination: React.FC<PaginationProps> = ({\n currentPage,\n totalPages,\n onPageChange,\n disabled = false\n}) => {\n const { t } = useTranslation();\n // Generate page buttons\n const getPageButtons = () => {\n const buttons = [];\n const maxDisplayedPages = 5; // Maximum number of page buttons to display\n\n // Always display first page\n buttons.push(\n <button\n key=\"first\"\n onClick={() => onPageChange(1)}\n className={`px-3 py-1 mx-1 rounded ${currentPage === 1\n ? 'bg-blue-500 text-white btn-primary'\n : 'bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary'\n }`}\n >\n 1\n </button>\n );\n\n // Start range\n const startPage = Math.max(2, currentPage - Math.floor(maxDisplayedPages / 2));\n\n // If we're showing ellipsis after first page\n if (startPage > 2) {\n buttons.push(\n <span key=\"ellipsis1\" className=\"px-3 py-1\">\n ...\n </span>\n );\n }\n\n // Middle pages\n for (let i = startPage; i <= Math.min(totalPages - 1, startPage + maxDisplayedPages - 3); i++) {\n buttons.push(\n <button\n key={i}\n onClick={() => onPageChange(i)}\n className={`px-3 py-1 mx-1 rounded ${currentPage === i\n ? 'bg-blue-500 text-white btn-primary'\n : 'bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary'\n }`}\n >\n {i}\n </button>\n );\n }\n\n // If we're showing ellipsis before last page\n if (startPage + maxDisplayedPages - 3 < totalPages - 1) {\n buttons.push(\n <span key=\"ellipsis2\" className=\"px-3 py-1\">\n ...\n </span>\n );\n }\n\n // Always display last page if there's more than one page\n if (totalPages > 1) {\n buttons.push(\n <button\n key=\"last\"\n onClick={() => onPageChange(totalPages)}\n className={`px-3 py-1 mx-1 rounded ${currentPage === totalPages\n ? 'bg-blue-500 text-white btn-primary'\n : 'bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary'\n }`}\n >\n {totalPages}\n </button>\n );\n }\n\n return buttons;\n };\n\n // If there's only one page, don't render pagination\n if (totalPages <= 1) {\n return null;\n }\n\n return (\n <div className=\"flex justify-center items-center my-6\">\n <button\n onClick={() => onPageChange(Math.max(1, currentPage - 1))}\n disabled={disabled || currentPage === 1}\n className={`px-3 py-1 rounded mr-2 ${disabled || currentPage === 1\n ? 'bg-gray-100 text-gray-400 cursor-not-allowed'\n : 'bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary'\n }`}\n >\n &laquo; {t('common.previous')}\n </button>\n\n <div className=\"flex\">{getPageButtons()}</div>\n\n <button\n onClick={() => onPageChange(Math.min(totalPages, currentPage + 1))}\n disabled={disabled || currentPage === totalPages}\n className={`px-3 py-1 rounded ml-2 ${disabled || currentPage === totalPages\n ? 'bg-gray-100 text-gray-400 cursor-not-allowed'\n : 'bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary'\n }`}\n >\n {t('common.next')} &raquo;\n </button>\n </div>\n );\n};\n\nexport default Pagination;"],"names":["Pagination","currentPage","totalPages","onPageChange","disabled","t","useTranslation","getPageButtons","buttons","jsx","startPage","jsxs"],"mappings":"iGAUA,MAAMA,EAAwC,CAAC,CAC7C,YAAAC,EACA,WAAAC,EACA,aAAAC,EACA,SAAAC,EAAW,EACb,IAAM,CACJ,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A,CAAA,CAAA,EAG9BI,EAAAA,IAAC,MAAA,CAAI,UAAU,OAAQ,aAAiB,EAExCE,EAAAA,KAAC,SAAA,CACC,QAAS,IAAMR,EAAa,KAAK,IAAID,EAAYD,EAAc,CAAC,CAAC,EACjE,SAAUG,GAAYH,IAAgBC,EACtC,UAAW,0BAA0BE,GAAYH,IAAgBC,EAC7D,+CACA,2DACF,GAED,SAAA,CAAAG,EAAE,aAAa,EAAE,IAAA,CAAA,CAAA,CACpB,EACF,CAEJ"}
1
+ {"version":3,"file":"Pagination-BFi-X7qY.js","sources":["../../src/components/ui/Pagination.tsx"],"sourcesContent":["import React from 'react';\nimport { useTranslation } from 'react-i18next';\n\ninterface PaginationProps {\n currentPage: number;\n totalPages: number;\n onPageChange: (page: number) => void;\n disabled?: boolean;\n}\n\nconst Pagination: React.FC<PaginationProps> = ({\n currentPage,\n totalPages,\n onPageChange,\n disabled = false\n}) => {\n const { t } = useTranslation();\n // Generate page buttons\n const getPageButtons = () => {\n const buttons = [];\n const maxDisplayedPages = 5; // Maximum number of page buttons to display\n\n // Always display first page\n buttons.push(\n <button\n key=\"first\"\n onClick={() => onPageChange(1)}\n className={`px-3 py-1 mx-1 rounded ${currentPage === 1\n ? 'bg-blue-500 text-white btn-primary'\n : 'bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary'\n }`}\n >\n 1\n </button>\n );\n\n // Start range\n const startPage = Math.max(2, currentPage - Math.floor(maxDisplayedPages / 2));\n\n // If we're showing ellipsis after first page\n if (startPage > 2) {\n buttons.push(\n <span key=\"ellipsis1\" className=\"px-3 py-1\">\n ...\n </span>\n );\n }\n\n // Middle pages\n for (let i = startPage; i <= Math.min(totalPages - 1, startPage + maxDisplayedPages - 3); i++) {\n buttons.push(\n <button\n key={i}\n onClick={() => onPageChange(i)}\n className={`px-3 py-1 mx-1 rounded ${currentPage === i\n ? 'bg-blue-500 text-white btn-primary'\n : 'bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary'\n }`}\n >\n {i}\n </button>\n );\n }\n\n // If we're showing ellipsis before last page\n if (startPage + maxDisplayedPages - 3 < totalPages - 1) {\n buttons.push(\n <span key=\"ellipsis2\" className=\"px-3 py-1\">\n ...\n </span>\n );\n }\n\n // Always display last page if there's more than one page\n if (totalPages > 1) {\n buttons.push(\n <button\n key=\"last\"\n onClick={() => onPageChange(totalPages)}\n className={`px-3 py-1 mx-1 rounded ${currentPage === totalPages\n ? 'bg-blue-500 text-white btn-primary'\n : 'bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary'\n }`}\n >\n {totalPages}\n </button>\n );\n }\n\n return buttons;\n };\n\n // If there's only one page, don't render pagination\n if (totalPages <= 1) {\n return null;\n }\n\n return (\n <div className=\"flex justify-center items-center my-6\">\n <button\n onClick={() => onPageChange(Math.max(1, currentPage - 1))}\n disabled={disabled || currentPage === 1}\n className={`px-3 py-1 rounded mr-2 ${disabled || currentPage === 1\n ? 'bg-gray-100 text-gray-400 cursor-not-allowed'\n : 'bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary'\n }`}\n >\n &laquo; {t('common.previous')}\n </button>\n\n <div className=\"flex\">{getPageButtons()}</div>\n\n <button\n onClick={() => onPageChange(Math.min(totalPages, currentPage + 1))}\n disabled={disabled || currentPage === totalPages}\n className={`px-3 py-1 rounded ml-2 ${disabled || currentPage === totalPages\n ? 'bg-gray-100 text-gray-400 cursor-not-allowed'\n : 'bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary'\n }`}\n >\n {t('common.next')} &raquo;\n </button>\n </div>\n );\n};\n\nexport default Pagination;"],"names":["Pagination","currentPage","totalPages","onPageChange","disabled","t","useTranslation","getPageButtons","buttons","jsx","startPage","jsxs"],"mappings":"iGAUA,MAAMA,EAAwC,CAAC,CAC7C,YAAAC,EACA,WAAAC,EACA,aAAAC,EACA,SAAAC,EAAW,EACb,IAAM,CACJ,KAAM,CAAE,EAAAC,CAAA,EAAMC,EAAA,EAERC,EAAiB,IAAM,CAC3B,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iB,EAExCE,EAAAA,KAAC,SAAA,CACC,QAAS,IAAMR,EAAa,KAAK,IAAID,EAAYD,EAAc,CAAC,CAAC,EACjE,SAAUG,GAAYH,IAAgBC,EACtC,UAAW,0BAA0BE,GAAYH,IAAgBC,EAC7D,+CACA,2DACF,GAED,SAAA,CAAAG,EAAE,aAAa,EAAE,IAAA,CAAA,CAAA,CACpB,EACF,CAEJ"}
@@ -0,0 +1,2 @@
1
+ import{r as o,j as e}from"./framework-vendor-BUhDPOUZ.js";import{j as B,f as T,h as I,e as $,u as K}from"./index-BGiKkKzj.js";import{u as A}from"./i18n-vendor-Kbr87Ofu.js";import{C as L}from"./ConfirmDialog-CxlizGia.js";import{a as X}from"./StatusDot-CQzailBQ.js";import{P as R,X as D,f as G,s as H,p as M,$ as O}from"./icons-vendor-CKgJB3SC.js";const W=async()=>{const t=await B("/prompts");if(!t.success)throw new Error(t.message||"Failed to fetch built-in prompts");return t.data||[]},_=async t=>{const u=await $("/prompts",t);if(!u.success)throw new Error(u.message||"Failed to create built-in prompt");return u.data},J=async(t,u)=>{const b=await I(`/prompts/${t}`,u);if(!b.success)throw new Error(b.message||"Failed to update built-in prompt");return b.data},Q=async t=>{const u=await T(`/prompts/${t}`);if(!u.success)throw new Error(u.message||"Failed to delete built-in prompt")},U=()=>{const{t}=A(),[u,b]=o.useState([]),[r,f]=o.useState(!0),[p,n]=o.useState(null),[P,N]=o.useState(0),w=o.useCallback(async()=>{try{f(!0);const l=await W();b(l),n(null)}catch(l){console.error("Error fetching built-in prompts:",l),n(l instanceof Error?l.message:t("builtinPrompts.fetchError")),b([])}finally{f(!1)}},[t]),x=o.useCallback(()=>{N(l=>l+1)},[]),y=async l=>{try{const m=await _(l);return x(),{success:!0,data:m}}catch(m){const c=m instanceof Error?m.message:t("builtinPrompts.createError");return n(c),{success:!1,message:c}}},j=async(l,m)=>{try{const c=await J(l,m);return x(),{success:!0,data:c}}catch(c){const v=c instanceof Error?c.message:t("builtinPrompts.updateError");return n(v),{success:!1,message:v}}},g=async l=>{try{return await Q(l),x(),{success:!0}}catch(m){const c=m instanceof Error?m.message:t("builtinPrompts.deleteError");return n(c),{success:!1,message:c}}};return o.useEffect(()=>{w()},[w,P]),{prompts:u,loading:r,error:p,setError:n,triggerRefresh:x,addPrompt:y,editPrompt:j,removePrompt:g}},F=({prompt:t,onSave:u,onCancel:b})=>{const{t:r}=A(),[f,p]=o.useState(null),[n,P]=o.useState(!1),[N,w]=o.useState((t==null?void 0:t.name)||""),[x,y]=o.useState((t==null?void 0:t.title)||""),[j,g]=o.useState((t==null?void 0:t.description)||""),[l,m]=o.useState((t==null?void 0:t.template)||""),[c,v]=o.useState((t==null?void 0:t.enabled)!==!1),[k,C]=o.useState((t==null?void 0:t.arguments)||[]),E=()=>{C([...k,{name:"",description:"",required:!1}])},z=s=>{C(k.filter((i,d)=>d!==s))},S=(s,i,d)=>{C(k.map((h,q)=>q===s?{...h,[i]:d}:h))},a=async s=>{if(s.preventDefault(),p(null),!N.trim()){p(r("builtinPrompts.nameRequired"));return}if(!l.trim()){p(r("builtinPrompts.templateRequired"));return}P(!0);try{const i=await u({name:N.trim(),title:x.trim()||void 0,description:j.trim()||void 0,template:l,arguments:k.length>0?k.filter(d=>d.name.trim()):void 0,enabled:c});i.success||p(i.message||r("builtinPrompts.saveError"))}catch(i){p(i instanceof Error?i.message:r("builtinPrompts.saveError"))}finally{P(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 p-8 rounded-xl shadow-2xl max-w-3xl w-full mx-4 border border-gray-100 dark:border-gray-700 max-h-[90vh] overflow-y-auto",children:e.jsxs("form",{onSubmit:a,children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-gray-100 mb-6",children:r(t?"builtinPrompts.edit":"builtinPrompts.addNew")}),f&&e.jsx("div",{className:"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded-md",children:e.jsx("p",{className:"text-sm font-medium",children:f})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[r("builtinPrompts.name")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:N,onChange:s=>w(s.target.value),placeholder:r("builtinPrompts.namePlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",required:!0,disabled:n})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:r("builtinPrompts.title")}),e.jsx("input",{type:"text",value:x,onChange:s=>y(s.target.value),placeholder:r("builtinPrompts.titlePlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:n})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:r("builtinPrompts.description")}),e.jsx("input",{type:"text",value:j,onChange:s=>g(s.target.value),placeholder:r("builtinPrompts.descriptionPlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:n})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[r("builtinPrompts.template")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("textarea",{value:l,onChange:s=>m(s.target.value),placeholder:r("builtinPrompts.templatePlaceholder"),rows:6,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200",required:!0,disabled:n}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r("builtinPrompts.templateHint")})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:r("builtinPrompts.arguments")}),e.jsxs("button",{type:"button",onClick:E,className:"text-blue-600 hover:text-blue-800 text-sm flex items-center",disabled:n,children:[e.jsx(R,{size:14,className:"mr-1"}),r("builtinPrompts.addArgument")]})]}),k.map((s,i)=>e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx("input",{type:"text",value:s.name,onChange:d=>S(i,"name",d.target.value),placeholder:r("builtinPrompts.argName"),className:"flex-1 px-3 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500",disabled:n}),e.jsx("input",{type:"text",value:s.description||"",onChange:d=>S(i,"description",d.target.value),placeholder:r("builtinPrompts.argDescription"),className:"flex-1 px-3 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500",disabled:n}),e.jsxs("label",{className:"flex items-center text-sm text-gray-600 dark:text-gray-400 whitespace-nowrap",children:[e.jsx("input",{type:"checkbox",checked:s.required||!1,onChange:d=>S(i,"required",d.target.checked),className:"mr-1",disabled:n}),r("builtinPrompts.argRequired")]}),e.jsx("button",{type:"button",onClick:()=>z(i),className:"text-red-500 hover:text-red-700 p-1",disabled:n,children:e.jsx(D,{size:16})})]},i))]}),e.jsxs("div",{className:"flex items-center pt-2",children:[e.jsx("input",{type:"checkbox",id:"enabled",checked:c,onChange:s=>v(s.target.checked),className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500",disabled:n}),e.jsx("label",{htmlFor:"enabled",className:"ml-2 block text-sm text-gray-700 dark:text-gray-300",children:r("builtinPrompts.enabled")})]})]}),e.jsxs("div",{className:"flex justify-end space-x-2 mt-6",children:[e.jsx("button",{type:"button",onClick:b,className:"hub-btn",disabled:n,children:r("common.cancel")}),e.jsx("button",{type:"submit",disabled:n,className:"hub-btn primary",children:r(n?"common.saving":"common.save")})]})]})})})},re=()=>{var S;const{t}=A(),{auth:u}=K(),{prompts:b,loading:r,error:f,setError:p,addPrompt:n,editPrompt:P,removePrompt:N}=U(),[w,x]=o.useState(!1),[y,j]=o.useState(null),[g,l]=o.useState(null),[m,c]=o.useState(new Set),v=(S=u.user)==null?void 0:S.isAdmin,k=a=>{c(s=>{const i=new Set(s);return i.has(a)?i.delete(a):i.add(a),i})},C=async a=>{const s=await n(a);return s.success&&x(!1),s},E=async a=>{if(!y)return{success:!1,message:"No prompt selected"};const s=await P(y.id,a);return s.success&&j(null),s},z=async()=>{g&&(await N(g.id),l(null))};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-end justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"hub-h1",children:t("pages.prompts.title")}),e.jsxs("p",{className:"hub-sub",children:[e.jsx("span",{className:"hub-num",children:b.length})," ",t("nav.prompts").toLowerCase()]})]}),v&&e.jsxs("button",{onClick:()=>x(!0),className:"hub-btn primary",children:[e.jsx(R,{size:13})," ",t("builtinPrompts.add")]})]}),f&&e.jsxs("div",{className:"hub-card flex items-center justify-between gap-3 mb-4",style:{padding:"10px 14px",borderColor:"oklch(0.85 0.1 25)",background:"oklch(0.97 0.03 25)",color:"oklch(0.4 0.18 25)"},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(D,{size:14,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate text-[13px]",children:f})]}),e.jsx("button",{className:"hub-icon-btn sm",onClick:()=>p(null),children:e.jsx(D,{size:13})})]}),r?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:t("app.loading")}):b.length===0?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"grid place-items-center",style:{width:40,height:40,borderRadius:10,border:"1px solid var(--hub-line)",background:"var(--hub-bg-2)"},children:e.jsx(G,{size:18})}),e.jsx("div",{className:"font-medium",style:{color:"var(--hub-ink-2)",fontSize:13},children:t("builtinPrompts.noPrompts")}),v&&e.jsx("button",{onClick:()=>x(!0),className:"hub-btn ghost sm",style:{color:"var(--hub-accent)"},children:t("builtinPrompts.addFirst")})]})}):e.jsx("div",{className:"hub-card overflow-hidden",children:b.map((a,s)=>{const i=m.has(a.id),d=a.enabled!==!1;return e.jsxs("div",{style:{borderTop:s===0?0:"1px solid var(--hub-line-2)"},children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer transition-colors hover:bg-[var(--hub-surface-hover)]",style:{padding:"12px 16px"},onClick:()=>k(a.id),children:[e.jsxs("div",{className:"flex items-center gap-2.5 flex-1 min-w-0",children:[e.jsx(H,{size:12,style:{color:"var(--hub-ink-3)",transform:i?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.15s",flexShrink:0}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",style:{fontSize:13.5,color:d?"var(--hub-ink)":"var(--hub-ink-3)"},children:a.title||a.name}),e.jsx("span",{className:"hub-mono",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:a.name}),e.jsx(X,{kind:d?"ok":"muted",label:t(d?"builtinPrompts.active":"builtinPrompts.inactive")})]}),a.description&&e.jsx("div",{className:"truncate mt-0.5",style:{fontSize:12,color:"var(--hub-ink-3)"},children:a.description})]})]}),v&&e.jsxs("div",{className:"flex items-center gap-1 ml-3",children:[e.jsx("button",{onClick:h=>{h.stopPropagation(),j(a)},className:"hub-icon-btn sm",title:t("builtinPrompts.edit"),children:e.jsx(M,{size:13})}),e.jsx("button",{onClick:h=>{h.stopPropagation(),l(a)},className:"hub-icon-btn sm",title:t("builtinPrompts.delete"),style:{color:"var(--hub-err)"},children:e.jsx(O,{size:13})})]})]}),i&&e.jsxs("div",{style:{padding:"12px 16px 14px 38px",background:"var(--hub-bg-2)",borderTop:"1px solid var(--hub-line-2)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:5},children:t("builtinPrompts.template")}),e.jsx("pre",{className:"hub-mono",style:{fontSize:12,color:"var(--hub-ink-2)",background:"var(--hub-surface)",border:"1px solid var(--hub-line)",borderRadius:7,padding:10,overflowX:"auto",whiteSpace:"pre-wrap",margin:0},children:a.template})]}),a.arguments&&a.arguments.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:5},children:t("builtinPrompts.arguments")}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.arguments.map((h,q)=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px]",children:[e.jsx("code",{className:"hub-mono hub-tag accent",style:{fontSize:11},children:"{{"+h.name+"}}"}),h.required&&e.jsx("span",{style:{color:"var(--hub-err)",fontSize:11},children:"*"}),h.description&&e.jsxs("span",{style:{color:"var(--hub-ink-3)"},children:["— ",h.description]})]},q))})]})]})]},a.id)})}),w&&e.jsx(F,{onSave:C,onCancel:()=>x(!1)}),y&&e.jsx(F,{prompt:y,onSave:E,onCancel:()=>j(null)}),e.jsx(L,{isOpen:!!g,onClose:()=>l(null),onConfirm:z,title:t("builtinPrompts.confirmDelete"),message:t("builtinPrompts.deleteWarning",{name:(g==null?void 0:g.name)||""}),variant:"danger"})]})};export{re as default};
2
+ //# sourceMappingURL=PromptsPage-Dh3qjX3x.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PromptsPage-Dh3qjX3x.js","sources":["../../src/services/builtinPromptService.ts","../../src/hooks/useBuiltinPromptData.ts","../../src/pages/PromptsPage.tsx"],"sourcesContent":["import { BuiltinPrompt, ApiResponse } from '@/types';\nimport { apiGet, apiPost, apiPut, apiDelete } from '../utils/fetchInterceptor';\n\n/**\n * Get all built-in prompts\n */\nexport const getBuiltinPrompts = async (): Promise<BuiltinPrompt[]> => {\n const response: ApiResponse<BuiltinPrompt[]> = await apiGet('/prompts');\n if (!response.success) {\n throw new Error(response.message || 'Failed to fetch built-in prompts');\n }\n return response.data || [];\n};\n\n/**\n * Get a single built-in prompt by ID\n */\nexport const getBuiltinPromptById = async (id: string): Promise<BuiltinPrompt> => {\n const response: ApiResponse<BuiltinPrompt> = await apiGet(`/prompts/${id}`);\n if (!response.success) {\n throw new Error(response.message || 'Failed to fetch built-in prompt');\n }\n return response.data!;\n};\n\n/**\n * Create a new built-in prompt\n */\nexport const createBuiltinPrompt = async (\n prompt: Omit<BuiltinPrompt, 'id'>,\n): Promise<BuiltinPrompt> => {\n const response: ApiResponse<BuiltinPrompt> = await apiPost('/prompts', prompt);\n if (!response.success) {\n throw new Error(response.message || 'Failed to create built-in prompt');\n }\n return response.data!;\n};\n\n/**\n * Update an existing built-in prompt\n */\nexport const updateBuiltinPrompt = async (\n id: string,\n prompt: Partial<BuiltinPrompt>,\n): Promise<BuiltinPrompt> => {\n const response: ApiResponse<BuiltinPrompt> = await apiPut(`/prompts/${id}`, prompt);\n if (!response.success) {\n throw new Error(response.message || 'Failed to update built-in prompt');\n }\n return response.data!;\n};\n\n/**\n * Delete a built-in prompt\n */\nexport const deleteBuiltinPrompt = async (id: string): Promise<void> => {\n const response: ApiResponse = await apiDelete(`/prompts/${id}`);\n if (!response.success) {\n throw new Error(response.message || 'Failed to delete built-in prompt');\n }\n};\n","import { useState, useEffect, useCallback } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { BuiltinPrompt } from '@/types';\nimport {\n getBuiltinPrompts,\n createBuiltinPrompt,\n updateBuiltinPrompt,\n deleteBuiltinPrompt,\n} from '@/services/builtinPromptService';\n\nexport const useBuiltinPromptData = () => {\n const { t } = useTranslation();\n const [prompts, setPrompts] = useState<BuiltinPrompt[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n const [refreshKey, setRefreshKey] = useState(0);\n\n const fetchPrompts = useCallback(async () => {\n try {\n setLoading(true);\n const data = await getBuiltinPrompts();\n setPrompts(data);\n setError(null);\n } catch (err) {\n console.error('Error fetching built-in prompts:', err);\n setError(err instanceof Error ? err.message : t('builtinPrompts.fetchError'));\n setPrompts([]);\n } finally {\n setLoading(false);\n }\n }, [t]);\n\n const triggerRefresh = useCallback(() => {\n setRefreshKey((prev) => prev + 1);\n }, []);\n\n const addPrompt = async (prompt: Omit<BuiltinPrompt, 'id'>) => {\n try {\n const result = await createBuiltinPrompt(prompt);\n triggerRefresh();\n return { success: true, data: result };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinPrompts.createError');\n setError(message);\n return { success: false, message };\n }\n };\n\n const editPrompt = async (id: string, prompt: Partial<BuiltinPrompt>) => {\n try {\n const result = await updateBuiltinPrompt(id, prompt);\n triggerRefresh();\n return { success: true, data: result };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinPrompts.updateError');\n setError(message);\n return { success: false, message };\n }\n };\n\n const removePrompt = async (id: string) => {\n try {\n await deleteBuiltinPrompt(id);\n triggerRefresh();\n return { success: true };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinPrompts.deleteError');\n setError(message);\n return { success: false, message };\n }\n };\n\n useEffect(() => {\n fetchPrompts();\n }, [fetchPrompts, refreshKey]);\n\n return {\n prompts,\n loading,\n error,\n setError,\n triggerRefresh,\n addPrompt,\n editPrompt,\n removePrompt,\n };\n};\n","import React, { useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { BuiltinPrompt, PromptArgument } from '@/types';\nimport { useBuiltinPromptData } from '@/hooks/useBuiltinPromptData';\nimport { useAuth } from '@/contexts/AuthContext';\nimport { Edit, Trash, Plus, MessageSquare, X, ChevronDown } from 'lucide-react';\nimport ConfirmDialog from '@/components/ui/ConfirmDialog';\nimport { StatusDot } from '@/components/ui/StatusDot';\n\n// Form dialog for creating/editing a built-in prompt\ninterface PromptFormDialogProps {\n prompt?: BuiltinPrompt | null;\n onSave: (data: Omit<BuiltinPrompt, 'id'>) => Promise<{ success: boolean; message?: string }>;\n onCancel: () => void;\n}\n\nconst PromptFormDialog: React.FC<PromptFormDialogProps> = ({ prompt, onSave, onCancel }) => {\n const { t } = useTranslation();\n const [error, setError] = useState<string | null>(null);\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const [name, setName] = useState(prompt?.name || '');\n const [title, setTitle] = useState(prompt?.title || '');\n const [description, setDescription] = useState(prompt?.description || '');\n const [template, setTemplate] = useState(prompt?.template || '');\n const [enabled, setEnabled] = useState(prompt?.enabled !== false);\n const [args, setArgs] = useState<PromptArgument[]>(prompt?.arguments || []);\n\n const handleAddArg = () => {\n setArgs([...args, { name: '', description: '', required: false }]);\n };\n\n const handleRemoveArg = (index: number) => {\n setArgs(args.filter((_, i) => i !== index));\n };\n\n const handleArgChange = (index: number, field: keyof PromptArgument, value: string | boolean) => {\n setArgs(args.map((a, i) => (i === index ? { ...a, [field]: value } : a)));\n };\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n setError(null);\n\n if (!name.trim()) {\n setError(t('builtinPrompts.nameRequired'));\n return;\n }\n if (!template.trim()) {\n setError(t('builtinPrompts.templateRequired'));\n return;\n }\n\n setIsSubmitting(true);\n try {\n const result = await onSave({\n name: name.trim(),\n title: title.trim() || undefined,\n description: description.trim() || undefined,\n template,\n arguments: args.length > 0 ? args.filter((a) => a.name.trim()) : undefined,\n enabled,\n });\n if (!result.success) {\n setError(result.message || t('builtinPrompts.saveError'));\n }\n } catch (err) {\n setError(err instanceof Error ? err.message : t('builtinPrompts.saveError'));\n } finally {\n setIsSubmitting(false);\n }\n };\n\n return (\n <div className=\"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4\">\n <div className=\"bg-white dark:bg-gray-800 p-8 rounded-xl shadow-2xl max-w-3xl w-full mx-4 border border-gray-100 dark:border-gray-700 max-h-[90vh] overflow-y-auto\">\n <form onSubmit={handleSubmit}>\n <h2 className=\"text-xl font-bold text-gray-900 dark:text-gray-100 mb-6\">\n {prompt ? t('builtinPrompts.edit') : t('builtinPrompts.addNew')}\n </h2>\n\n {error && (\n <div className=\"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded-md\">\n <p className=\"text-sm font-medium\">{error}</p>\n </div>\n )}\n\n <div className=\"space-y-5\">\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinPrompts.name')} <span className=\"text-red-500\">*</span>\n </label>\n <input\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder={t('builtinPrompts.namePlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n required\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinPrompts.title')}\n </label>\n <input\n type=\"text\"\n value={title}\n onChange={(e) => setTitle(e.target.value)}\n placeholder={t('builtinPrompts.titlePlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinPrompts.description')}\n </label>\n <input\n type=\"text\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n placeholder={t('builtinPrompts.descriptionPlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinPrompts.template')} <span className=\"text-red-500\">*</span>\n </label>\n <textarea\n value={template}\n onChange={(e) => setTemplate(e.target.value)}\n placeholder={t('builtinPrompts.templatePlaceholder')}\n rows={6}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200\"\n required\n disabled={isSubmitting}\n />\n <p className=\"mt-1 text-xs text-gray-500 dark:text-gray-400\">\n {t('builtinPrompts.templateHint')}\n </p>\n </div>\n\n {/* Arguments */}\n <div>\n <div className=\"flex items-center justify-between mb-2\">\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300\">\n {t('builtinPrompts.arguments')}\n </label>\n <button\n type=\"button\"\n onClick={handleAddArg}\n className=\"text-blue-600 hover:text-blue-800 text-sm flex items-center\"\n disabled={isSubmitting}\n >\n <Plus size={14} className=\"mr-1\" />\n {t('builtinPrompts.addArgument')}\n </button>\n </div>\n {args.map((arg, index) => (\n <div key={index} className=\"flex items-start gap-2 mb-2\">\n <input\n type=\"text\"\n value={arg.name}\n onChange={(e) => handleArgChange(index, 'name', e.target.value)}\n placeholder={t('builtinPrompts.argName')}\n className=\"flex-1 px-3 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500\"\n disabled={isSubmitting}\n />\n <input\n type=\"text\"\n value={arg.description || ''}\n onChange={(e) => handleArgChange(index, 'description', e.target.value)}\n placeholder={t('builtinPrompts.argDescription')}\n className=\"flex-1 px-3 py-1.5 border border-gray-300 dark:border-gray-600 rounded-lg text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500\"\n disabled={isSubmitting}\n />\n <label className=\"flex items-center text-sm text-gray-600 dark:text-gray-400 whitespace-nowrap\">\n <input\n type=\"checkbox\"\n checked={arg.required || false}\n onChange={(e) => handleArgChange(index, 'required', e.target.checked)}\n className=\"mr-1\"\n disabled={isSubmitting}\n />\n {t('builtinPrompts.argRequired')}\n </label>\n <button\n type=\"button\"\n onClick={() => handleRemoveArg(index)}\n className=\"text-red-500 hover:text-red-700 p-1\"\n disabled={isSubmitting}\n >\n <X size={16} />\n </button>\n </div>\n ))}\n </div>\n\n <div className=\"flex items-center pt-2\">\n <input\n type=\"checkbox\"\n id=\"enabled\"\n checked={enabled}\n onChange={(e) => setEnabled(e.target.checked)}\n className=\"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500\"\n disabled={isSubmitting}\n />\n <label htmlFor=\"enabled\" className=\"ml-2 block text-sm text-gray-700 dark:text-gray-300\">\n {t('builtinPrompts.enabled')}\n </label>\n </div>\n </div>\n\n <div className=\"flex justify-end space-x-2 mt-6\">\n <button\n type=\"button\"\n onClick={onCancel}\n className=\"hub-btn\"\n disabled={isSubmitting}\n >\n {t('common.cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={isSubmitting}\n className=\"hub-btn primary\"\n >\n {isSubmitting ? t('common.saving') : t('common.save')}\n </button>\n </div>\n </form>\n </div>\n </div>\n );\n};\n\nconst PromptsPage: React.FC = () => {\n const { t } = useTranslation();\n const { auth } = useAuth();\n const {\n prompts,\n loading,\n error,\n setError,\n addPrompt,\n editPrompt,\n removePrompt,\n } = useBuiltinPromptData();\n\n const [showForm, setShowForm] = useState(false);\n const [editingPrompt, setEditingPrompt] = useState<BuiltinPrompt | null>(null);\n const [promptToDelete, setPromptToDelete] = useState<BuiltinPrompt | null>(null);\n const [expandedIds, setExpandedIds] = useState<Set<string>>(new Set());\n\n const isAdmin = auth.user?.isAdmin;\n\n const toggleExpand = (id: string) => {\n setExpandedIds((prev) => {\n const next = new Set(prev);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n return next;\n });\n };\n\n const handleCreate = async (data: Omit<BuiltinPrompt, 'id'>) => {\n const result = await addPrompt(data);\n if (result.success) {\n setShowForm(false);\n }\n return result;\n };\n\n const handleEdit = async (data: Omit<BuiltinPrompt, 'id'>) => {\n if (!editingPrompt) return { success: false, message: 'No prompt selected' };\n const result = await editPrompt(editingPrompt.id, data);\n if (result.success) {\n setEditingPrompt(null);\n }\n return result;\n };\n\n const handleConfirmDelete = async () => {\n if (promptToDelete) {\n await removePrompt(promptToDelete.id);\n setPromptToDelete(null);\n }\n };\n\n return (\n <div>\n <div className=\"flex items-end justify-between gap-4 mb-6\">\n <div>\n <h1 className=\"hub-h1\">{t('pages.prompts.title')}</h1>\n <p className=\"hub-sub\">\n <span className=\"hub-num\">{prompts.length}</span> {t('nav.prompts').toLowerCase()}\n </p>\n </div>\n {isAdmin && (\n <button onClick={() => setShowForm(true)} className=\"hub-btn primary\">\n <Plus size={13} /> {t('builtinPrompts.add')}\n </button>\n )}\n </div>\n\n {error && (\n <div\n className=\"hub-card flex items-center justify-between gap-3 mb-4\"\n style={{\n padding: '10px 14px',\n borderColor: 'oklch(0.85 0.1 25)',\n background: 'oklch(0.97 0.03 25)',\n color: 'oklch(0.4 0.18 25)',\n }}\n >\n <div className=\"flex items-center gap-2 min-w-0\">\n <X size={14} className=\"flex-shrink-0\" />\n <span className=\"truncate text-[13px]\">{error}</span>\n </div>\n <button className=\"hub-icon-btn sm\" onClick={() => setError(null)}>\n <X size={13} />\n </button>\n </div>\n )}\n\n {loading ? (\n <div className=\"hub-card p-10 text-center\" style={{ color: 'var(--hub-ink-3)' }}>\n {t('app.loading')}\n </div>\n ) : prompts.length === 0 ? (\n <div className=\"hub-card p-10 text-center\" style={{ color: 'var(--hub-ink-3)' }}>\n <div className=\"flex flex-col items-center gap-3\">\n <div\n className=\"grid place-items-center\"\n style={{\n width: 40,\n height: 40,\n borderRadius: 10,\n border: '1px solid var(--hub-line)',\n background: 'var(--hub-bg-2)',\n }}\n >\n <MessageSquare size={18} />\n </div>\n <div className=\"font-medium\" style={{ color: 'var(--hub-ink-2)', fontSize: 13 }}>\n {t('builtinPrompts.noPrompts')}\n </div>\n {isAdmin && (\n <button\n onClick={() => setShowForm(true)}\n className=\"hub-btn ghost sm\"\n style={{ color: 'var(--hub-accent)' }}\n >\n {t('builtinPrompts.addFirst')}\n </button>\n )}\n </div>\n </div>\n ) : (\n <div className=\"hub-card overflow-hidden\">\n {prompts.map((prompt, idx) => {\n const isExpanded = expandedIds.has(prompt.id);\n const enabled = prompt.enabled !== false;\n return (\n <div\n key={prompt.id}\n style={{ borderTop: idx === 0 ? 0 : '1px solid var(--hub-line-2)' }}\n >\n <div\n className=\"flex items-center justify-between cursor-pointer transition-colors hover:bg-[var(--hub-surface-hover)]\"\n style={{ padding: '12px 16px' }}\n onClick={() => toggleExpand(prompt.id)}\n >\n <div className=\"flex items-center gap-2.5 flex-1 min-w-0\">\n <ChevronDown\n size={12}\n style={{\n color: 'var(--hub-ink-3)',\n transform: isExpanded ? 'rotate(0deg)' : 'rotate(-90deg)',\n transition: 'transform 0.15s',\n flexShrink: 0,\n }}\n />\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-center gap-2 flex-wrap\">\n <span\n className=\"font-medium truncate\"\n style={{\n fontSize: 13.5,\n color: enabled ? 'var(--hub-ink)' : 'var(--hub-ink-3)',\n }}\n >\n {prompt.title || prompt.name}\n </span>\n <span\n className=\"hub-mono\"\n style={{ fontSize: 11.5, color: 'var(--hub-ink-3)' }}\n >\n {prompt.name}\n </span>\n <StatusDot\n kind={enabled ? 'ok' : 'muted'}\n label={\n enabled\n ? t('builtinPrompts.active')\n : t('builtinPrompts.inactive')\n }\n />\n </div>\n {prompt.description && (\n <div\n className=\"truncate mt-0.5\"\n style={{ fontSize: 12, color: 'var(--hub-ink-3)' }}\n >\n {prompt.description}\n </div>\n )}\n </div>\n </div>\n {isAdmin && (\n <div className=\"flex items-center gap-1 ml-3\">\n <button\n onClick={(e) => {\n e.stopPropagation();\n setEditingPrompt(prompt);\n }}\n className=\"hub-icon-btn sm\"\n title={t('builtinPrompts.edit')}\n >\n <Edit size={13} />\n </button>\n <button\n onClick={(e) => {\n e.stopPropagation();\n setPromptToDelete(prompt);\n }}\n className=\"hub-icon-btn sm\"\n title={t('builtinPrompts.delete')}\n style={{ color: 'var(--hub-err)' }}\n >\n <Trash size={13} />\n </button>\n </div>\n )}\n </div>\n {isExpanded && (\n <div\n style={{\n padding: '12px 16px 14px 38px',\n background: 'var(--hub-bg-2)',\n borderTop: '1px solid var(--hub-line-2)',\n }}\n >\n <div>\n <div className=\"hub-sect\" style={{ marginBottom: 5 }}>\n {t('builtinPrompts.template')}\n </div>\n <pre\n className=\"hub-mono\"\n style={{\n fontSize: 12,\n color: 'var(--hub-ink-2)',\n background: 'var(--hub-surface)',\n border: '1px solid var(--hub-line)',\n borderRadius: 7,\n padding: 10,\n overflowX: 'auto',\n whiteSpace: 'pre-wrap',\n margin: 0,\n }}\n >\n {prompt.template}\n </pre>\n </div>\n {prompt.arguments && prompt.arguments.length > 0 && (\n <div className=\"mt-3\">\n <div className=\"hub-sect\" style={{ marginBottom: 5 }}>\n {t('builtinPrompts.arguments')}\n </div>\n <div className=\"flex flex-wrap gap-1.5\">\n {prompt.arguments.map((arg, i) => (\n <div key={i} className=\"flex items-center gap-1.5 text-[12px]\">\n <code className=\"hub-mono hub-tag accent\" style={{ fontSize: 11 }}>\n {'{{' + arg.name + '}}'}\n </code>\n {arg.required && (\n <span style={{ color: 'var(--hub-err)', fontSize: 11 }}>*</span>\n )}\n {arg.description && (\n <span style={{ color: 'var(--hub-ink-3)' }}>\n — {arg.description}\n </span>\n )}\n </div>\n ))}\n </div>\n </div>\n )}\n </div>\n )}\n </div>\n );\n })}\n </div>\n )}\n\n {/* Add form dialog */}\n {showForm && (\n <PromptFormDialog onSave={handleCreate} onCancel={() => setShowForm(false)} />\n )}\n\n {/* Edit form dialog */}\n {editingPrompt && (\n <PromptFormDialog\n prompt={editingPrompt}\n onSave={handleEdit}\n onCancel={() => setEditingPrompt(null)}\n />\n )}\n\n {/* Delete confirmation */}\n <ConfirmDialog\n isOpen={!!promptToDelete}\n onClose={() => setPromptToDelete(null)}\n onConfirm={handleConfirmDelete}\n title={t('builtinPrompts.confirmDelete')}\n message={t('builtinPrompts.deleteWarning', { name: promptToDelete?.name || '' })}\n variant=\"danger\"\n />\n </div>\n );\n};\n\nexport default PromptsPage;\n"],"names":["getBuiltinPrompts","response","apiGet","createBuiltinPrompt","prompt","apiPost","updateBuiltinPrompt","id","apiPut","deleteBuiltinPrompt","apiDelete","useBuiltinPromptData","useTranslation","prompts","setPrompts","useState","loading","setLoading","error","setError","refreshKey","setRefreshKey","fetchPrompts","useCallback","data","err","triggerRefresh","prev","addPrompt","result","message","editPrompt","removePrompt","useEffect","PromptFormDialog","onSave","onCancel","t","isSubmitting","setIsSubmitting","name","setName","title","setTitle","description","setDescription","template","setTemplate","enabled","setEnabled","args","setArgs","handleAddArg","handleRemoveArg","index","_","i","handleArgChange","field","value","a","handleSubmit","e","jsx","jsxs","Plus","arg","X","PromptsPage","auth","useAuth","showForm","setShowForm","editingPrompt","setEditingPrompt","promptToDelete","setPromptToDelete","expandedIds","setExpandedIds","isAdmin","_a","toggleExpand","next","handleCreate","handleEdit","handleConfirmDelete","MessageSquare","idx","isExpanded","ChevronDown","StatusDot","Edit","Trash","ConfirmDialog"],"mappings":"0VAMO,MAAMA,EAAoB,SAAsC,CACrE,MAAMC,EAAyC,MAAMC,EAAO,UAAU,EACtE,GAAI,CAACD,EAAS,QACZ,MAAM,IAAI,MAAMA,EAAS,SAAW,kCAA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DmE,SACErC,EAAA,CAAiB,OAAQiD,EAAc,SAAU,IAAMX,EAAY,EAAK,EAAG,EAI7EC,GACCV,EAAAA,IAAC7B,EAAA,CACC,OAAQuC,EACR,OAAQW,EACR,SAAU,IAAMV,EAAiB,IAAI,CAAA,CAAA,EAKzCX,EAAAA,IAAC8B,EAAA,CACC,OAAQ,CAAC,CAAClB,EACV,QAAS,IAAMC,EAAkB,IAAI,EACrC,UAAWS,EACX,MAAO,EAAE,8BAA8B,EACvC,QAAS,EAAE,+BAAgC,CAAE,MAAMV,GAAA,YAAAA,EAAgB,OAAQ,GAAI,EAC/E,QAAQ,QAAA,CAAA,CACV,EACF,CAEJ"}
@@ -0,0 +1,2 @@
1
+ import{r as n,j as e}from"./framework-vendor-BUhDPOUZ.js";import{j as D,f as B,h as q,e as A,u as I}from"./index-BGiKkKzj.js";import{u as P}from"./i18n-vendor-Kbr87Ofu.js";import{C as $}from"./ConfirmDialog-CxlizGia.js";import{a as K}from"./StatusDot-CQzailBQ.js";import{P as L,X as F,F as X,s as G,p as H,$ as M}from"./icons-vendor-CKgJB3SC.js";const O=async()=>{const s=await D("/resources");if(!s.success)throw new Error(s.message||"Failed to fetch built-in resources");return s.data||[]},U=async s=>{const c=await A("/resources",s);if(!c.success)throw new Error(c.message||"Failed to create built-in resource");return c.data},W=async(s,c)=>{const m=await q(`/resources/${s}`,c);if(!m.success)throw new Error(m.message||"Failed to update built-in resource");return m.data},Y=async s=>{const c=await B(`/resources/${s}`);if(!c.success)throw new Error(c.message||"Failed to delete built-in resource")},J=()=>{const{t:s}=P(),[c,m]=n.useState([]),[t,g]=n.useState(!0),[x,i]=n.useState(null),[w,j]=n.useState(0),N=n.useCallback(async()=>{try{g(!0);const a=await O();m(a),i(null)}catch(a){console.error("Error fetching built-in resources:",a),i(a instanceof Error?a.message:s("builtinResources.fetchError")),m([])}finally{g(!1)}},[s]),b=n.useCallback(()=>{j(a=>a+1)},[]),p=async a=>{try{const u=await U(a);return b(),{success:!0,data:u}}catch(u){const l=u instanceof Error?u.message:s("builtinResources.createError");return i(l),{success:!1,message:l}}},f=async(a,u)=>{try{const l=await W(a,u);return b(),{success:!0,data:l}}catch(l){const y=l instanceof Error?l.message:s("builtinResources.updateError");return i(y),{success:!1,message:y}}},d=async a=>{try{return await Y(a),b(),{success:!0}}catch(u){const l=u instanceof Error?u.message:s("builtinResources.deleteError");return i(l),{success:!1,message:l}}};return n.useEffect(()=>{N()},[N,w]),{resources:c,loading:t,error:x,setError:i,triggerRefresh:b,addResource:p,editResource:f,removeResource:d}},T=({resource:s,onSave:c,onCancel:m})=>{const{t}=P(),[g,x]=n.useState(null),[i,w]=n.useState(!1),[j,N]=n.useState((s==null?void 0:s.uri)||""),[b,p]=n.useState((s==null?void 0:s.name)||""),[f,d]=n.useState((s==null?void 0:s.description)||""),[a,u]=n.useState((s==null?void 0:s.mimeType)||"text/plain"),[l,y]=n.useState((s==null?void 0:s.content)||""),[R,S]=n.useState((s==null?void 0:s.enabled)!==!1),E=async o=>{if(o.preventDefault(),x(null),!j.trim()){x(t("builtinResources.uriRequired"));return}if(!l.trim()){x(t("builtinResources.contentRequired"));return}w(!0);try{const v=await c({uri:j.trim(),name:b.trim()||void 0,description:f.trim()||void 0,mimeType:a.trim()||"text/plain",content:l,enabled:R});v.success||x(v.message||t("builtinResources.saveError"))}catch(v){x(v instanceof Error?v.message:t("builtinResources.saveError"))}finally{w(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 p-8 rounded-xl shadow-2xl max-w-3xl w-full mx-4 border border-gray-100 dark:border-gray-700 max-h-[90vh] overflow-y-auto",children:e.jsxs("form",{onSubmit:E,children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-gray-100 mb-6",children:t(s?"builtinResources.edit":"builtinResources.addNew")}),g&&e.jsx("div",{className:"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded-md",children:e.jsx("p",{className:"text-sm font-medium",children:g})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t("builtinResources.uri")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:j,onChange:o=>N(o.target.value),placeholder:t("builtinResources.uriPlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200",required:!0,disabled:i})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("builtinResources.name")}),e.jsx("input",{type:"text",value:b,onChange:o=>p(o.target.value),placeholder:t("builtinResources.namePlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:i})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("builtinResources.description")}),e.jsx("input",{type:"text",value:f,onChange:o=>d(o.target.value),placeholder:t("builtinResources.descriptionPlaceholder"),className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:i})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("builtinResources.mimeType")}),e.jsx("input",{type:"text",value:a,onChange:o=>u(o.target.value),placeholder:"text/plain",className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200",disabled:i})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t("builtinResources.content")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("textarea",{value:l,onChange:o=>y(o.target.value),placeholder:t("builtinResources.contentPlaceholder"),rows:8,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200",required:!0,disabled:i})]}),e.jsxs("div",{className:"flex items-center pt-2",children:[e.jsx("input",{type:"checkbox",id:"enabled",checked:R,onChange:o=>S(o.target.checked),className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500",disabled:i}),e.jsx("label",{htmlFor:"enabled",className:"ml-2 block text-sm text-gray-700 dark:text-gray-300",children:t("builtinResources.enabled")})]})]}),e.jsxs("div",{className:"flex justify-end space-x-2 mt-6",children:[e.jsx("button",{type:"button",onClick:m,className:"hub-btn",disabled:i,children:t("common.cancel")}),e.jsx("button",{type:"submit",disabled:i,className:"hub-btn primary",children:t(i?"common.saving":"common.save")})]})]})})})},te=()=>{var v;const{t:s}=P(),{auth:c}=I(),{resources:m,loading:t,error:g,setError:x,addResource:i,editResource:w,removeResource:j}=J(),[N,b]=n.useState(!1),[p,f]=n.useState(null),[d,a]=n.useState(null),[u,l]=n.useState(new Set),y=(v=c.user)==null?void 0:v.isAdmin,R=r=>{l(h=>{const k=new Set(h);return k.has(r)?k.delete(r):k.add(r),k})},S=async r=>{const h=await i(r);return h.success&&b(!1),h},E=async r=>{if(!p)return{success:!1,message:"No resource selected"};const h=await w(p.id,r);return h.success&&f(null),h},o=async()=>{d&&(await j(d.id),a(null))};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-end justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"hub-h1",children:s("pages.resources.title")}),e.jsxs("p",{className:"hub-sub",children:[e.jsx("span",{className:"hub-num",children:m.length})," ",s("nav.resources").toLowerCase()]})]}),y&&e.jsxs("button",{onClick:()=>b(!0),className:"hub-btn primary",children:[e.jsx(L,{size:13})," ",s("builtinResources.add")]})]}),g&&e.jsxs("div",{className:"hub-card flex items-center justify-between gap-3 mb-4",style:{padding:"10px 14px",borderColor:"oklch(0.85 0.1 25)",background:"oklch(0.97 0.03 25)",color:"oklch(0.4 0.18 25)"},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(F,{size:14,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate text-[13px]",children:g})]}),e.jsx("button",{className:"hub-icon-btn sm",onClick:()=>x(null),children:e.jsx(F,{size:13})})]}),t?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:s("app.loading")}):m.length===0?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"grid place-items-center",style:{width:40,height:40,borderRadius:10,border:"1px solid var(--hub-line)",background:"var(--hub-bg-2)"},children:e.jsx(X,{size:18})}),e.jsx("div",{className:"font-medium",style:{color:"var(--hub-ink-2)",fontSize:13},children:s("builtinResources.noResources")}),y&&e.jsx("button",{onClick:()=>b(!0),className:"hub-btn ghost sm",style:{color:"var(--hub-accent)"},children:s("builtinResources.addFirst")})]})}):e.jsx("div",{className:"hub-card overflow-hidden",children:m.map((r,h)=>{const k=u.has(r.id),C=r.enabled!==!1;return e.jsxs("div",{style:{borderTop:h===0?0:"1px solid var(--hub-line-2)"},children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer transition-colors hover:bg-[var(--hub-surface-hover)]",style:{padding:"12px 16px"},onClick:()=>R(r.id),children:[e.jsxs("div",{className:"flex items-center gap-2.5 flex-1 min-w-0",children:[e.jsx(G,{size:12,style:{color:"var(--hub-ink-3)",transform:k?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.15s",flexShrink:0}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",style:{fontSize:13.5,color:C?"var(--hub-ink)":"var(--hub-ink-3)"},children:r.name||r.uri}),r.name&&e.jsx("span",{className:"hub-mono truncate",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:r.uri}),e.jsx(K,{kind:C?"ok":"muted",label:s(C?"builtinResources.active":"builtinResources.inactive")}),r.mimeType&&e.jsx("span",{className:"hub-tag accent",style:{fontSize:10},children:r.mimeType})]}),r.description&&e.jsx("div",{className:"truncate mt-0.5",style:{fontSize:12,color:"var(--hub-ink-3)"},children:r.description})]})]}),y&&e.jsxs("div",{className:"flex items-center gap-1 ml-3",children:[e.jsx("button",{onClick:z=>{z.stopPropagation(),f(r)},className:"hub-icon-btn sm",title:s("builtinResources.edit"),children:e.jsx(H,{size:13})}),e.jsx("button",{onClick:z=>{z.stopPropagation(),a(r)},className:"hub-icon-btn sm",title:s("builtinResources.delete"),style:{color:"var(--hub-err)"},children:e.jsx(M,{size:13})})]})]}),k&&e.jsxs("div",{style:{padding:"12px 16px 14px 38px",background:"var(--hub-bg-2)",borderTop:"1px solid var(--hub-line-2)"},children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:5},children:s("builtinResources.content")}),e.jsx("pre",{className:"hub-mono",style:{fontSize:12,color:"var(--hub-ink-2)",background:"var(--hub-surface)",border:"1px solid var(--hub-line)",borderRadius:7,padding:10,overflowX:"auto",overflowY:"auto",whiteSpace:"pre-wrap",maxHeight:260,margin:0},children:r.content})]})]},r.id)})}),N&&e.jsx(T,{onSave:S,onCancel:()=>b(!1)}),p&&e.jsx(T,{resource:p,onSave:E,onCancel:()=>f(null)}),e.jsx($,{isOpen:!!d,onClose:()=>a(null),onConfirm:o,title:s("builtinResources.confirmDelete"),message:s("builtinResources.deleteWarning",{name:(d==null?void 0:d.name)||(d==null?void 0:d.uri)||""}),variant:"danger"})]})};export{te as default};
2
+ //# sourceMappingURL=ResourcesPage-Bc5ZpCIh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResourcesPage-Bc5ZpCIh.js","sources":["../../src/services/builtinResourceService.ts","../../src/hooks/useBuiltinResourceData.ts","../../src/pages/ResourcesPage.tsx"],"sourcesContent":["import { BuiltinResource, ApiResponse } from '@/types';\nimport { apiGet, apiPost, apiPut, apiDelete } from '../utils/fetchInterceptor';\n\n/**\n * Get all built-in resources\n */\nexport const getBuiltinResources = async (): Promise<BuiltinResource[]> => {\n const response: ApiResponse<BuiltinResource[]> = await apiGet('/resources');\n if (!response.success) {\n throw new Error(response.message || 'Failed to fetch built-in resources');\n }\n return response.data || [];\n};\n\n/**\n * Get a single built-in resource by ID\n */\nexport const getBuiltinResourceById = async (id: string): Promise<BuiltinResource> => {\n const response: ApiResponse<BuiltinResource> = await apiGet(`/resources/${id}`);\n if (!response.success) {\n throw new Error(response.message || 'Failed to fetch built-in resource');\n }\n return response.data!;\n};\n\n/**\n * Create a new built-in resource\n */\nexport const createBuiltinResource = async (\n resource: Omit<BuiltinResource, 'id'>,\n): Promise<BuiltinResource> => {\n const response: ApiResponse<BuiltinResource> = await apiPost('/resources', resource);\n if (!response.success) {\n throw new Error(response.message || 'Failed to create built-in resource');\n }\n return response.data!;\n};\n\n/**\n * Update an existing built-in resource\n */\nexport const updateBuiltinResource = async (\n id: string,\n resource: Partial<BuiltinResource>,\n): Promise<BuiltinResource> => {\n const response: ApiResponse<BuiltinResource> = await apiPut(`/resources/${id}`, resource);\n if (!response.success) {\n throw new Error(response.message || 'Failed to update built-in resource');\n }\n return response.data!;\n};\n\n/**\n * Delete a built-in resource\n */\nexport const deleteBuiltinResource = async (id: string): Promise<void> => {\n const response: ApiResponse = await apiDelete(`/resources/${id}`);\n if (!response.success) {\n throw new Error(response.message || 'Failed to delete built-in resource');\n }\n};\n","import { useState, useEffect, useCallback } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { BuiltinResource } from '@/types';\nimport {\n getBuiltinResources,\n createBuiltinResource,\n updateBuiltinResource,\n deleteBuiltinResource,\n} from '@/services/builtinResourceService';\n\nexport const useBuiltinResourceData = () => {\n const { t } = useTranslation();\n const [resources, setResources] = useState<BuiltinResource[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n const [refreshKey, setRefreshKey] = useState(0);\n\n const fetchResources = useCallback(async () => {\n try {\n setLoading(true);\n const data = await getBuiltinResources();\n setResources(data);\n setError(null);\n } catch (err) {\n console.error('Error fetching built-in resources:', err);\n setError(err instanceof Error ? err.message : t('builtinResources.fetchError'));\n setResources([]);\n } finally {\n setLoading(false);\n }\n }, [t]);\n\n const triggerRefresh = useCallback(() => {\n setRefreshKey((prev) => prev + 1);\n }, []);\n\n const addResource = async (resource: Omit<BuiltinResource, 'id'>) => {\n try {\n const result = await createBuiltinResource(resource);\n triggerRefresh();\n return { success: true, data: result };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinResources.createError');\n setError(message);\n return { success: false, message };\n }\n };\n\n const editResource = async (id: string, resource: Partial<BuiltinResource>) => {\n try {\n const result = await updateBuiltinResource(id, resource);\n triggerRefresh();\n return { success: true, data: result };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinResources.updateError');\n setError(message);\n return { success: false, message };\n }\n };\n\n const removeResource = async (id: string) => {\n try {\n await deleteBuiltinResource(id);\n triggerRefresh();\n return { success: true };\n } catch (err) {\n const message = err instanceof Error ? err.message : t('builtinResources.deleteError');\n setError(message);\n return { success: false, message };\n }\n };\n\n useEffect(() => {\n fetchResources();\n }, [fetchResources, refreshKey]);\n\n return {\n resources,\n loading,\n error,\n setError,\n triggerRefresh,\n addResource,\n editResource,\n removeResource,\n };\n};\n","import React, { useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { BuiltinResource } from '@/types';\nimport { useBuiltinResourceData } from '@/hooks/useBuiltinResourceData';\nimport { useAuth } from '@/contexts/AuthContext';\nimport { Edit, Trash, Plus, FileText, X, ChevronDown } from 'lucide-react';\nimport ConfirmDialog from '@/components/ui/ConfirmDialog';\nimport { StatusDot } from '@/components/ui/StatusDot';\n\n// Form dialog for creating/editing a built-in resource\ninterface ResourceFormDialogProps {\n resource?: BuiltinResource | null;\n onSave: (data: Omit<BuiltinResource, 'id'>) => Promise<{ success: boolean; message?: string }>;\n onCancel: () => void;\n}\n\nconst ResourceFormDialog: React.FC<ResourceFormDialogProps> = ({ resource, onSave, onCancel }) => {\n const { t } = useTranslation();\n const [error, setError] = useState<string | null>(null);\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const [uri, setUri] = useState(resource?.uri || '');\n const [name, setName] = useState(resource?.name || '');\n const [description, setDescription] = useState(resource?.description || '');\n const [mimeType, setMimeType] = useState(resource?.mimeType || 'text/plain');\n const [content, setContent] = useState(resource?.content || '');\n const [enabled, setEnabled] = useState(resource?.enabled !== false);\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n setError(null);\n\n if (!uri.trim()) {\n setError(t('builtinResources.uriRequired'));\n return;\n }\n if (!content.trim()) {\n setError(t('builtinResources.contentRequired'));\n return;\n }\n\n setIsSubmitting(true);\n try {\n const result = await onSave({\n uri: uri.trim(),\n name: name.trim() || undefined,\n description: description.trim() || undefined,\n mimeType: mimeType.trim() || 'text/plain',\n content,\n enabled,\n });\n if (!result.success) {\n setError(result.message || t('builtinResources.saveError'));\n }\n } catch (err) {\n setError(err instanceof Error ? err.message : t('builtinResources.saveError'));\n } finally {\n setIsSubmitting(false);\n }\n };\n\n return (\n <div className=\"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4\">\n <div className=\"bg-white dark:bg-gray-800 p-8 rounded-xl shadow-2xl max-w-3xl w-full mx-4 border border-gray-100 dark:border-gray-700 max-h-[90vh] overflow-y-auto\">\n <form onSubmit={handleSubmit}>\n <h2 className=\"text-xl font-bold text-gray-900 dark:text-gray-100 mb-6\">\n {resource ? t('builtinResources.edit') : t('builtinResources.addNew')}\n </h2>\n\n {error && (\n <div className=\"bg-red-50 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded-md\">\n <p className=\"text-sm font-medium\">{error}</p>\n </div>\n )}\n\n <div className=\"space-y-5\">\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinResources.uri')} <span className=\"text-red-500\">*</span>\n </label>\n <input\n type=\"text\"\n value={uri}\n onChange={(e) => setUri(e.target.value)}\n placeholder={t('builtinResources.uriPlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200\"\n required\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinResources.name')}\n </label>\n <input\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder={t('builtinResources.namePlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinResources.description')}\n </label>\n <input\n type=\"text\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n placeholder={t('builtinResources.descriptionPlaceholder')}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinResources.mimeType')}\n </label>\n <input\n type=\"text\"\n value={mimeType}\n onChange={(e) => setMimeType(e.target.value)}\n placeholder=\"text/plain\"\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 transition-all duration-200\"\n disabled={isSubmitting}\n />\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1\">\n {t('builtinResources.content')} <span className=\"text-red-500\">*</span>\n </label>\n <textarea\n value={content}\n onChange={(e) => setContent(e.target.value)}\n placeholder={t('builtinResources.contentPlaceholder')}\n rows={8}\n className=\"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 font-mono text-sm transition-all duration-200\"\n required\n disabled={isSubmitting}\n />\n </div>\n\n <div className=\"flex items-center pt-2\">\n <input\n type=\"checkbox\"\n id=\"enabled\"\n checked={enabled}\n onChange={(e) => setEnabled(e.target.checked)}\n className=\"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500\"\n disabled={isSubmitting}\n />\n <label htmlFor=\"enabled\" className=\"ml-2 block text-sm text-gray-700 dark:text-gray-300\">\n {t('builtinResources.enabled')}\n </label>\n </div>\n </div>\n\n <div className=\"flex justify-end space-x-2 mt-6\">\n <button\n type=\"button\"\n onClick={onCancel}\n className=\"hub-btn\"\n disabled={isSubmitting}\n >\n {t('common.cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={isSubmitting}\n className=\"hub-btn primary\"\n >\n {isSubmitting ? t('common.saving') : t('common.save')}\n </button>\n </div>\n </form>\n </div>\n </div>\n );\n};\n\nconst ResourcesPage: React.FC = () => {\n const { t } = useTranslation();\n const { auth } = useAuth();\n const {\n resources,\n loading,\n error,\n setError,\n addResource,\n editResource,\n removeResource,\n } = useBuiltinResourceData();\n\n const [showForm, setShowForm] = useState(false);\n const [editingResource, setEditingResource] = useState<BuiltinResource | null>(null);\n const [resourceToDelete, setResourceToDelete] = useState<BuiltinResource | null>(null);\n const [expandedIds, setExpandedIds] = useState<Set<string>>(new Set());\n\n const isAdmin = auth.user?.isAdmin;\n\n const toggleExpand = (id: string) => {\n setExpandedIds((prev) => {\n const next = new Set(prev);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n return next;\n });\n };\n\n const handleCreate = async (data: Omit<BuiltinResource, 'id'>) => {\n const result = await addResource(data);\n if (result.success) {\n setShowForm(false);\n }\n return result;\n };\n\n const handleEdit = async (data: Omit<BuiltinResource, 'id'>) => {\n if (!editingResource) return { success: false, message: 'No resource selected' };\n const result = await editResource(editingResource.id, data);\n if (result.success) {\n setEditingResource(null);\n }\n return result;\n };\n\n const handleConfirmDelete = async () => {\n if (resourceToDelete) {\n await removeResource(resourceToDelete.id);\n setResourceToDelete(null);\n }\n };\n\n return (\n <div>\n <div className=\"flex items-end justify-between gap-4 mb-6\">\n <div>\n <h1 className=\"hub-h1\">{t('pages.resources.title')}</h1>\n <p className=\"hub-sub\">\n <span className=\"hub-num\">{resources.length}</span> {t('nav.resources').toLowerCase()}\n </p>\n </div>\n {isAdmin && (\n <button onClick={() => setShowForm(true)} className=\"hub-btn primary\">\n <Plus size={13} /> {t('builtinResources.add')}\n </button>\n )}\n </div>\n\n {error && (\n <div\n className=\"hub-card flex items-center justify-between gap-3 mb-4\"\n style={{\n padding: '10px 14px',\n borderColor: 'oklch(0.85 0.1 25)',\n background: 'oklch(0.97 0.03 25)',\n color: 'oklch(0.4 0.18 25)',\n }}\n >\n <div className=\"flex items-center gap-2 min-w-0\">\n <X size={14} className=\"flex-shrink-0\" />\n <span className=\"truncate text-[13px]\">{error}</span>\n </div>\n <button className=\"hub-icon-btn sm\" onClick={() => setError(null)}>\n <X size={13} />\n </button>\n </div>\n )}\n\n {loading ? (\n <div className=\"hub-card p-10 text-center\" style={{ color: 'var(--hub-ink-3)' }}>\n {t('app.loading')}\n </div>\n ) : resources.length === 0 ? (\n <div className=\"hub-card p-10 text-center\" style={{ color: 'var(--hub-ink-3)' }}>\n <div className=\"flex flex-col items-center gap-3\">\n <div\n className=\"grid place-items-center\"\n style={{\n width: 40,\n height: 40,\n borderRadius: 10,\n border: '1px solid var(--hub-line)',\n background: 'var(--hub-bg-2)',\n }}\n >\n <FileText size={18} />\n </div>\n <div className=\"font-medium\" style={{ color: 'var(--hub-ink-2)', fontSize: 13 }}>\n {t('builtinResources.noResources')}\n </div>\n {isAdmin && (\n <button\n onClick={() => setShowForm(true)}\n className=\"hub-btn ghost sm\"\n style={{ color: 'var(--hub-accent)' }}\n >\n {t('builtinResources.addFirst')}\n </button>\n )}\n </div>\n </div>\n ) : (\n <div className=\"hub-card overflow-hidden\">\n {resources.map((resource, idx) => {\n const isExpanded = expandedIds.has(resource.id);\n const enabled = resource.enabled !== false;\n return (\n <div\n key={resource.id}\n style={{ borderTop: idx === 0 ? 0 : '1px solid var(--hub-line-2)' }}\n >\n <div\n className=\"flex items-center justify-between cursor-pointer transition-colors hover:bg-[var(--hub-surface-hover)]\"\n style={{ padding: '12px 16px' }}\n onClick={() => toggleExpand(resource.id)}\n >\n <div className=\"flex items-center gap-2.5 flex-1 min-w-0\">\n <ChevronDown\n size={12}\n style={{\n color: 'var(--hub-ink-3)',\n transform: isExpanded ? 'rotate(0deg)' : 'rotate(-90deg)',\n transition: 'transform 0.15s',\n flexShrink: 0,\n }}\n />\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-center gap-2 flex-wrap\">\n <span\n className=\"font-medium truncate\"\n style={{\n fontSize: 13.5,\n color: enabled ? 'var(--hub-ink)' : 'var(--hub-ink-3)',\n }}\n >\n {resource.name || resource.uri}\n </span>\n {resource.name && (\n <span\n className=\"hub-mono truncate\"\n style={{ fontSize: 11.5, color: 'var(--hub-ink-3)' }}\n >\n {resource.uri}\n </span>\n )}\n <StatusDot\n kind={enabled ? 'ok' : 'muted'}\n label={\n enabled\n ? t('builtinResources.active')\n : t('builtinResources.inactive')\n }\n />\n {resource.mimeType && (\n <span className=\"hub-tag accent\" style={{ fontSize: 10 }}>\n {resource.mimeType}\n </span>\n )}\n </div>\n {resource.description && (\n <div\n className=\"truncate mt-0.5\"\n style={{ fontSize: 12, color: 'var(--hub-ink-3)' }}\n >\n {resource.description}\n </div>\n )}\n </div>\n </div>\n {isAdmin && (\n <div className=\"flex items-center gap-1 ml-3\">\n <button\n onClick={(e) => {\n e.stopPropagation();\n setEditingResource(resource);\n }}\n className=\"hub-icon-btn sm\"\n title={t('builtinResources.edit')}\n >\n <Edit size={13} />\n </button>\n <button\n onClick={(e) => {\n e.stopPropagation();\n setResourceToDelete(resource);\n }}\n className=\"hub-icon-btn sm\"\n title={t('builtinResources.delete')}\n style={{ color: 'var(--hub-err)' }}\n >\n <Trash size={13} />\n </button>\n </div>\n )}\n </div>\n {isExpanded && (\n <div\n style={{\n padding: '12px 16px 14px 38px',\n background: 'var(--hub-bg-2)',\n borderTop: '1px solid var(--hub-line-2)',\n }}\n >\n <div className=\"hub-sect\" style={{ marginBottom: 5 }}>\n {t('builtinResources.content')}\n </div>\n <pre\n className=\"hub-mono\"\n style={{\n fontSize: 12,\n color: 'var(--hub-ink-2)',\n background: 'var(--hub-surface)',\n border: '1px solid var(--hub-line)',\n borderRadius: 7,\n padding: 10,\n overflowX: 'auto',\n overflowY: 'auto',\n whiteSpace: 'pre-wrap',\n maxHeight: 260,\n margin: 0,\n }}\n >\n {resource.content}\n </pre>\n </div>\n )}\n </div>\n );\n })}\n </div>\n )}\n\n {/* Add form dialog */}\n {showForm && (\n <ResourceFormDialog onSave={handleCreate} onCancel={() => setShowForm(false)} />\n )}\n\n {/* Edit form dialog */}\n {editingResource && (\n <ResourceFormDialog\n resource={editingResource}\n onSave={handleEdit}\n onCancel={() => setEditingResource(null)}\n />\n )}\n\n {/* Delete confirmation */}\n <ConfirmDialog\n isOpen={!!resourceToDelete}\n onClose={() => setResourceToDelete(null)}\n onConfirm={handleConfirmDelete}\n title={t('builtinResources.confirmDelete')}\n message={t('builtinResources.deleteWarning', { name: resourceToDelete?.name || resourceToDelete?.uri || '' })}\n variant=\"danger\"\n />\n </div>\n );\n};\n\nexport default ResourcesPage;\n"],"names":["getBuiltinResources","response","apiGet","createBuiltinResource","resource","apiPost","updateBuiltinResource","id","apiPut","deleteBuiltinResource","apiDelete","useBuiltinResourceData","t","useTranslation","resources","setResources","useState","loading","setLoading","error","setError","refreshKey","setRefreshKey","fetchResources","useCallback","data","err","triggerRefresh","prev","addResource","result","message","editResource","removeResource","useEffect","ResourceFormDialog","onSave","onCancel","isSubmitting","setIsSubmitting","uri","setUri","name","setName","description","setDescription","mimeType","setMimeType","content","setContent","enabled","setEnabled","handleSubmit","e","jsx","jsxs","ResourcesPage","auth","useAuth","showForm","setShowForm","editingResource","setEditingResource","resourceToDelete","setResourceToDelete","expandedIds","setExpandedIds","isAdmin","_a","toggleExpand","next","handleCreate","handleEdit","handleConfirmDelete","Plus","X","FileText","idx","isExpanded","ChevronDown","StatusDot","Edit","Trash","ConfirmDialog"],"mappings":"0VAMO,MAAMA,EAAsB,SAAwC,CACzE,MAAMC,EAA2C,MAAMC,EAAO,YAAY,EAC1E,GAAI,CAACD,EAAS,QACZ,MAAM,IAAI,MAAMA,EAAS,SAAW,oCAAoC,EAE1E,OAAOA,EAAS,MAAQ,CAAA,CAC1B,EAgBaE,EAAwB,MACnCC,GAC6B,CAC7B,MAAMH,EAAyC,MAAMI,EAAQ,aAAcD,CAAQ,EACnF,GAAI,CAACH,EAAS,QACZ,MAAM,IAAI,MAAMA,EAAS,SAAW,oCAAoC,EAE1E,OAAOA,EAAS,IAClB,EAKaK,EAAwB,MACnCC,EACAH,IAC6B,CAC7B,MAAMH,EAAyC,MAAMO,EAAO,cAAcD,CAAE,GAAIH,CAAQ,EACxF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CAwHpB,CAAC,CAAA,CACH,EAIDuD,SACExB,EAAA,CAAmB,OAAQoC,EAAc,SAAU,IAAMX,EAAY,EAAK,EAAG,EAI/EC,GACCP,EAAAA,IAACnB,EAAA,CACC,SAAU0B,EACV,OAAQW,EACR,SAAU,IAAMV,EAAmB,IAAI,CAAA,CAAA,EAK3CR,EAAAA,IAAC6B,EAAA,CACC,OAAQ,CAAC,CAACpB,EACV,QAAS,IAAMC,EAAoB,IAAI,EACvC,UAAWS,EACX,MAAO7D,EAAE,gCAAgC,EACzC,QAASA,EAAE,iCAAkC,CAAE,MAAMmD,GAAA,YAAAA,EAAkB,QAAQA,GAAA,YAAAA,EAAkB,MAAO,GAAI,EAC5G,QAAQ,QAAA,CAAA,CACV,EACF,CAEJ"}
@@ -0,0 +1,37 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./resourceService-C6umWRgq.js","./index-BGiKkKzj.js","./framework-vendor-BUhDPOUZ.js","./i18n-vendor-Kbr87Ofu.js","./icons-vendor-CKgJB3SC.js","./index-D0OIBhmN.css"])))=>i.map(i=>d[i]);
2
+ import{r as m,j as e,b as Ge}from"./framework-vendor-BUhDPOUZ.js";import{e as se,f as Fe,h as be,i as we,_ as ge,j as Ke,k as Xe,l as Ze}from"./index-BGiKkKzj.js";import{S as Qe}from"./StatusDot-CQzailBQ.js";import{u as ke}from"./useSettingsData-Cz7vKGLE.js";import{S as Ce}from"./ToggleGroup-CNBBvo3C.js";import{u as Q}from"./i18n-vendor-Kbr87Ofu.js";import{l as Re,m as $e,j as je,n as Ye,C as de,o as fe,p as Se,q as Oe,r as _e,s as Ee,k as ye,X as ve,W as ze,f as Te,F as De,E as es,t as ss,R as Ne,T as ts,P as rs,u as ns,v as as,w as os}from"./icons-vendor-CKgJB3SC.js";import{D as ls}from"./DeleteDialog-DRbWonMu.js";import{S as Ae,d as is}from"./variableDetection-DsYuiOB_.js";import{C as cs}from"./ConfirmDialog-CxlizGia.js";import{P as ds}from"./Pagination-BFi-X7qY.js";import{u as ms}from"./useServerData-P5In98R4.js";const Je=async(s,o)=>{try{const t=o?`/tools/${encodeURIComponent(o)}/${encodeURIComponent(s.toolName)}`:"/tools/call",n=await se(t,s.arguments,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return n.success===!1?{success:!1,error:n.message||"Tool call failed"}:{success:!0,content:(n==null?void 0:n.content)||[]}}catch(t){return console.error("Error calling tool",{toolName:s.toolName,server:o,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},us=async(s,o,t)=>{try{const n=await se(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(o)}/toggle`,{enabled:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:n.success,error:n.success?void 0:n.message}}catch(n){return console.error("Error toggling tool",{serverName:s,toolName:o,enabled:t,error:n}),{success:!1,error:n instanceof Error?n.message:"Unknown error occurred"}}},Me=async(s,o,t)=>{try{const n=await be(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(o)}/description`,{description:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:n.success,error:n.success?void 0:n.message}}catch(n){return console.error("Error updating tool description",{serverName:s,toolName:o,error:n}),{success:!1,error:n instanceof Error?n.message:"Unknown error occurred"}}},Ue=async(s,o)=>{var t;try{const n=await Fe(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(o)}/description`,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:n.success,error:n.success?void 0:n.message,description:(t=n.data)==null?void 0:t.description}}catch(n){return console.error("Error resetting tool description",{serverName:s,toolName:o,error:n}),{success:!1,error:n instanceof Error?n.message:"Unknown error occurred"}}},ps=Object.freeze(Object.defineProperty({__proto__:null,callTool:Je,resetToolDescription:Ue,toggleTool:us,updateToolDescription:Me},Symbol.toStringTag,{value:"Module"})),Be=({schema:s,onSubmit:o,onCancel:t,loading:n=!1,storageKey:i,title:f})=>{const{t:r}=Q(),[x,T]=m.useState({}),[I,d]=m.useState({}),[b,R]=m.useState(!1),[v,F]=m.useState(""),[N,E]=m.useState(""),g=m.useMemo(()=>(c=>{const k=a=>{if(typeof a=="object"&&a!==null){const u=a;return{type:u.type||"string",description:u.description,enum:u.enum,default:u.default,properties:u.properties?Object.fromEntries(Object.entries(u.properties).map(([l,j])=>[l,k(j)])):void 0,required:u.required,items:u.items?k(u.items):void 0}}return{type:"string"}};return{type:c.type,properties:c.properties?Object.fromEntries(Object.entries(c.properties).map(([a,u])=>[a,k(u)])):void 0,required:c.required}})(s),[s]);m.useEffect(()=>{const h=(k,a="")=>{const u={};return k.type==="object"&&k.properties&&Object.entries(k.properties).forEach(([l,j])=>{const C=a?`${a}.${l}`:l;j.default!==void 0?u[l]=j.default:j.type==="string"?u[l]="":j.type==="number"||j.type==="integer"?u[l]=0:j.type==="boolean"?u[l]=!1:j.type==="array"?u[l]=[]:j.type==="object"&&(j.properties?u[l]=h(j,C):u[l]={})}),u};let c=h(g);if(i)try{const k=localStorage.getItem(i);if(k){const a=JSON.parse(k);c={...c,...a}}}catch(k){console.warn("Failed to load saved form data:",k)}T(c)},[g,i]),m.useEffect(()=>{b&&Object.keys(x).length>0&&(F(JSON.stringify(x,null,2)),E(""))},[b,x]);const O=h=>{F(h),E("");try{const c=JSON.parse(h);if(T(c),i)try{localStorage.setItem(i,JSON.stringify(c))}catch(k){console.warn("Failed to save form data to localStorage:",k)}}catch{E(r("tool.invalidJsonFormat"))}},$=()=>{F(JSON.stringify(x,null,2)),E(""),R(!0)},z=()=>{if(v.trim())try{const h=JSON.parse(v);T(h),E(""),R(!1)}catch{E(r("tool.fixJsonBeforeSwitching"));return}else R(!1)},A=(h,c)=>{T(k=>{const a={...k},u=h.split(".");let l=a;for(let j=0;j<u.length-1;j++)l[u[j]]||(l[u[j]]={}),l=l[u[j]];if(l[u[u.length-1]]=c,i)try{localStorage.setItem(i,JSON.stringify(a))}catch(j){console.warn("Failed to save form data to localStorage:",j)}return a}),I[h]&&d(k=>{const a={...k};return delete a[h],a})},W=()=>{const h={},c=(k,a,u="")=>{k.type==="object"&&k.properties&&Object.entries(k.properties).forEach(([l,j])=>{var V;const C=u?`${u}.${l}`:l,D=a==null?void 0:a[l];if((V=k.required)!=null&&V.includes(l)&&(D==null||D===""||Array.isArray(D)&&D.length===0)){h[C]=`${l} is required`;return}D!=null&&D!==""&&(j.type==="string"&&typeof D!="string"?h[C]=`${l} must be a string`:j.type==="number"&&typeof D!="number"?h[C]=`${l} must be a number`:j.type==="integer"&&(!Number.isInteger(D)||typeof D!="number")?h[C]=`${l} must be an integer`:j.type==="boolean"&&typeof D!="boolean"?h[C]=`${l} must be a boolean`:j.type==="array"&&Array.isArray(D)?j.items&&D.forEach((w,J)=>{var S;((S=j.items)==null?void 0:S.type)==="object"&&j.items.properties&&c(j.items,w,`${C}.${J}`)}):j.type==="object"&&typeof D=="object"&&c(j,D,C))})};return c(g,x),d(h),Object.keys(h).length===0},B=h=>{h.preventDefault(),W()&&o(x)},H=(h,c)=>c.split(".").reduce((k,a)=>k==null?void 0:k[a],h),K=(h,c,k,a)=>{const u=k==null?void 0:k[h];return c.type==="string"?c.enum?e.jsxs("select",{value:u||"",onChange:l=>a(l.target.value),className:"w-full border rounded-md px-2 py-1 text-sm border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:r("tool.selectOption")}),c.enum.map((l,j)=>e.jsx("option",{value:l,children:l},j))]}):e.jsx("input",{type:"text",value:u||"",onChange:l=>a(l.target.value),className:"w-full border rounded-md px-2 py-1 text-sm border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500 form-input",placeholder:c.description||r("tool.enterKey",{key:h})}):c.type==="number"||c.type==="integer"?e.jsx("input",{type:"number",step:c.type==="integer"?"1":"any",value:u??"",onChange:l=>{const j=l.target.value===""?"":c.type==="integer"?parseInt(l.target.value):parseFloat(l.target.value);a(j)},className:"w-full border rounded-md px-2 py-1 text-sm border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500 form-input"}):c.type==="boolean"?e.jsx("input",{type:"checkbox",checked:u||!1,onChange:l=>a(l.target.checked),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}):e.jsx("input",{type:"text",value:u||"",onChange:l=>a(l.target.value),className:"w-full border rounded-md px-2 py-1 text-sm border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500 form-input",placeholder:c.description||r("tool.enterKey",{key:h})})},M=(h,c,k="")=>{var j,C,D,V,w,J,S,U,te,re,me,ue,pe,xe;const a=k?`${k}.${h}`:h,u=H(x,a),l=I[a];if(c.type==="array"){const _=H(x,a)||[];return e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(k?(C=(j=H(g,k))==null?void 0:j.required)==null?void 0:C.includes(h):(D=g.required)==null?void 0:D.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-md p-3 bg-gray-50 dark:bg-gray-800",children:[_.map((G,X)=>{var ae,oe,le;return e.jsxs("div",{className:"mb-3 p-3 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-md",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-600",children:r("tool.item",{index:X+1})}),e.jsx("button",{type:"button",onClick:()=>{const q=[..._];q.splice(X,1),A(a,q)},className:"text-status-red hover:text-red-700 text-sm",children:r("common.remove")})]}),((ae=c.items)==null?void 0:ae.type)==="string"&&c.items.enum?e.jsxs("select",{value:G||"",onChange:q=>{const Z=[..._];Z[X]=q.target.value,A(a,Z)},className:"w-full border rounded-md px-3 py-2 border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:r("tool.selectOption")}),c.items.enum.map((q,Z)=>e.jsx("option",{value:q,children:q},Z))]}):((oe=c.items)==null?void 0:oe.type)==="object"&&c.items.properties?e.jsx("div",{className:"space-y-3",children:Object.entries(c.items.properties).map(([q,Z])=>{var ie,ce;return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:[q,((ce=(ie=c.items)==null?void 0:ie.required)==null?void 0:ce.includes(q))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),K(q,Z,G,he=>{const p=[..._];p[X]={...p[X],[q]:he},A(a,p)})]},q)})}):e.jsx("input",{type:"text",value:G||"",onChange:q=>{const Z=[..._];Z[X]=q.target.value,A(a,Z)},className:"w-full border rounded-md px-3 py-2 border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 form-input",placeholder:r("tool.enterValue",{type:((le=c.items)==null?void 0:le.type)||"value"})})]},X)}),e.jsx("button",{type:"button",onClick:()=>{var X;const G=((X=c.items)==null?void 0:X.type)==="object"?{}:"";A(a,[..._,G])},className:"w-full mt-2 px-3 py-2 text-sm text-blue-600 border border-blue-300 rounded-md hover:bg-blue-50",children:r("tool.addItem",{key:h})})]}),l&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:l})]},a)}return c.type==="object"?c.properties?e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(k?(w=(V=H(g,k))==null?void 0:V.required)==null?void 0:w.includes(h):(J=g.required)==null?void 0:J.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-md p-4 bg-gray-50 dark:bg-gray-800",children:Object.entries(c.properties).map(([_,G])=>M(_,G,a))}),l&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:l})]},a):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(k?(U=(S=H(g,k))==null?void 0:S.required)==null?void 0:U.includes(h):(te=g.required)==null?void 0:te.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"}),e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(JSON object)"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsx("textarea",{value:typeof u=="object"?JSON.stringify(u,null,2):u||"{}",onChange:_=>{try{const G=JSON.parse(_.target.value);A(a,G)}catch{A(a,_.target.value)}},placeholder:`{
3
+ "key": "value"
4
+ }`,className:`w-full border rounded-md px-3 py-2 font-mono text-sm ${l?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`,rows:4}),l&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:l})]},a):c.type==="string"?c.enum?e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(k?!1:(re=g.required)==null?void 0:re.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsxs("select",{value:u||"",onChange:_=>A(a,_.target.value),className:`w-full border rounded-md px-3 py-2 ${l?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[e.jsx("option",{value:"",children:r("tool.selectOption")}),c.enum.map((_,G)=>e.jsx("option",{value:_,children:_},G))]}),l&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:l})]},a):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(k?!1:(me=g.required)==null?void 0:me.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsx("input",{type:"text",value:u||"",onChange:_=>A(a,_.target.value),className:`w-full border rounded-md px-3 py-2 ${l?"border-red":"border-gray-200"} focus:outline-none form-input`}),l&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:l})]},a):c.type==="number"||c.type==="integer"?e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(k?!1:(ue=g.required)==null?void 0:ue.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsx("input",{type:"number",step:c.type==="integer"?"1":"any",value:u??"",onChange:_=>{const G=_.target.value===""?"":c.type==="integer"?parseInt(_.target.value):parseFloat(_.target.value);A(a,G)},className:`w-full border rounded-md px-3 py-2 form-input ${l?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`}),l&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:l})]},a):c.type==="boolean"?e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",checked:u||!1,onChange:_=>A(a,_.target.checked),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),e.jsxs("label",{className:"ml-2 block text-sm text-gray-700",children:[h,(k?!1:(pe=g.required)==null?void 0:pe.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:c.description}),l&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:l})]},a):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(k?!1:(xe=g.required)==null?void 0:xe.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"}),e.jsxs("span",{className:"text-xs text-gray-500 ml-1",children:["(",c.type,")"]})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsx("input",{type:"text",value:u||"",onChange:_=>A(a,_.target.value),placeholder:r("tool.enterValue",{type:c.type}),className:`w-full border rounded-md px-3 py-2 ${l?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500 form-input`}),l&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:l})]},a)};return g.properties?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center pb-3",children:[e.jsx("h6",{className:"text-md font-medium text-gray-900",children:f}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("button",{type:"button",onClick:z,className:`hub-btn sm ${b?"":"primary"}`,children:r("tool.formMode")}),e.jsx("button",{type:"button",onClick:$,className:`hub-btn sm ${b?"primary":""}`,children:r("tool.jsonMode")})]})]}),b?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:r("tool.jsonConfiguration")}),e.jsx("textarea",{value:v,onChange:h=>O(h.target.value),placeholder:`{
5
+ "key": "value"
6
+ }`,className:`w-full h-64 border rounded-md px-3 py-2 font-mono text-sm resize-y form-input ${N?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`}),N&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:N})]}),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx("button",{type:"button",onClick:t,className:"hub-btn sm",children:r("tool.cancel")}),e.jsx("button",{onClick:()=>{try{const h=JSON.parse(v);o(h)}catch{E(r("tool.invalidJsonFormat"))}},disabled:n||!!N,className:"hub-btn sm primary",children:r(n?"tool.running":"tool.runTool")})]})]}):e.jsxs("form",{onSubmit:B,className:"space-y-4",children:[Object.entries(g.properties||{}).map(([h,c])=>M(h,c)),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx("button",{type:"button",onClick:t,className:"hub-btn sm",children:r("tool.cancel")}),e.jsx("button",{type:"submit",disabled:n,className:"hub-btn sm primary",children:r(n?"tool.running":"tool.runTool")})]})]})]}):e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx("p",{className:"text-sm text-gray-600",children:r("tool.noParameters")}),e.jsxs("div",{className:"flex justify-end space-x-2 mt-4",children:[e.jsx("button",{type:"button",onClick:t,className:"hub-btn",children:r("tool.cancel")}),e.jsx("button",{onClick:()=>o({}),disabled:n,className:"hub-btn primary",children:r(n?"tool.running":"tool.runTool")})]})]})},xs=({result:s,onClose:o})=>{const{t}=Q(),n=s.content,i=d=>d?d.startsWith("image/")?d:`image/${d}`:"image/png",f=d=>{if(!d)return[];if(Array.isArray(d))return d.flatMap(v=>f(v));if(typeof d!="object")return[];const b=[];d.type==="image"&&d.data&&b.push({data:String(d.data),mimeType:i(d.mimeType||d.mime_type)});const R=d.image_base64||d.imageBase64||d.image_data||d.imageData||d.base64;return R&&b.push({data:String(R),mimeType:i(d.image_mimeType||d.image_mime_type||d.mimeType||d.mime_type)}),d.image&&typeof d.image=="object"&&b.push(...f(d.image)),Array.isArray(d.images)&&b.push(...f(d.images)),Array.isArray(d.content)&&b.push(...f(d.content)),b},r=d=>{const b=[];try{const F=JSON.parse(d);if(b.push(...f(F)),b.length>0)return b}catch{}const R=/data:image\/(png|jpe?g|gif|webp);base64,([A-Za-z0-9+/=]+)/g;let v;for(;(v=R.exec(d))!==null;){const F=`image/${v[1]==="jpg"?"jpeg":v[1]}`;b.push({data:v[2],mimeType:F})}return b},x=d=>{try{const b=JSON.parse(d),R=v=>{if(Array.isArray(v))return v.map(R);if(v&&typeof v=="object"){const F={};for(const[N,E]of Object.entries(v))typeof E=="string"&&N.toLowerCase().includes("base64")?F[N]="[base64 omitted]":F[N]=R(E);return F}return v};return JSON.stringify(R(b),null,2)}catch{return d.replace(/data:image\/(png|jpe?g|gif|webp);base64,[A-Za-z0-9+/=]+/g,"[image data omitted]")}},T=d=>Array.isArray(d)?d.map((b,R)=>e.jsx("div",{className:"mb-3 last:mb-0",children:I(b)},R)):I(d),I=d=>{if(typeof d=="string"){const b=r(d),R=x(d);return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[b.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:b.map((v,F)=>e.jsx("img",{src:`data:${v.mimeType||"image/png"};base64,${v.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"},F))}),e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:R})]})}if(typeof d=="object"&&d!==null){if(d.type==="text"&&d.text){const b=r(d.text),R=x(d.text);return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[b.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:b.map((v,F)=>e.jsx("img",{src:`data:${v.mimeType||"image/png"};base64,${v.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"},F))}),e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:R})]})}if(d.type==="image"&&d.data)return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("img",{src:`data:${d.mimeType||"image/png"};base64,${d.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"})});try{const b=typeof d=="string"?JSON.parse(d):d;return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-2",children:t("tool.jsonResponse")}),e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(b,null,2)})]})}catch{return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(d)})})}}return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(d)})})};return e.jsxs("div",{className:"border border-gray-300 rounded-lg bg-white dark:bg-gray-800 shadow-sm",children:[e.jsx("div",{className:"border-b border-gray-300 px-4 py-3 bg-gray-50 dark:bg-gray-800 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[s.success?e.jsx(Re,{size:20,className:"text-status-green"}):e.jsx($e,{size:20,className:"text-status-red"}),e.jsx("div",{children:e.jsxs("h4",{className:"text-sm font-medium text-gray-900",children:[t("tool.execution")," ",s.success?t("tool.successful"):t("tool.failed")]})})]}),e.jsx("button",{onClick:o,className:"text-gray-400 hover:text-gray-600 text-sm",children:"✕"})]})}),e.jsx("div",{className:"p-4",children:s.success?e.jsx("div",{children:s.content&&s.content.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:t("tool.result")}),T(s.content)]}):e.jsx("div",{className:"text-sm text-gray-500 italic",children:t("tool.noContent")})}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-3",children:[e.jsx(je,{size:16,className:"text-red-500"}),e.jsx("span",{className:"text-sm font-medium text-red-700",children:t("tool.error")})]}),n&&n.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:t("tool.errorDetails")}),T(n)]}):e.jsx("div",{className:"bg-red-50 border border-red-300 rounded-md p-3",children:e.jsx("pre",{className:"text-sm text-red-800 whitespace-pre-wrap",children:s.error||s.message||t("tool.unknownError")})})]})})]})},ne=({title:s,onClick:o,disabled:t=!1,loading:n=!1})=>e.jsx("button",{type:"button",className:"ml-2 p-1 text-amber-600 hover:text-amber-700 cursor-pointer transition-colors disabled:opacity-60 disabled:cursor-not-allowed",onClick:o,disabled:t,title:s,"aria-label":s,children:e.jsx(Ye,{size:14,className:n?"animate-spin":""})});function hs(s){return s==null?!0:typeof s=="string"?s.trim()==="":Array.isArray(s)?s.length===0:typeof s=="object"?Object.keys(s).length===0:!1}const gs=({tool:s,server:o,onToggle:t,onDescriptionUpdate:n})=>{const{t:i}=Q(),{showToast:f}=we(),{nameSeparator:r}=ke(),[x,T]=m.useState(!1),[I,d]=m.useState(!1),[b,R]=m.useState(!1),[v,F]=m.useState(null),[N,E]=m.useState(!1),[g,O]=m.useState(!1),[$,z]=m.useState(s.description||""),A=m.useRef(null),W=m.useRef(null),[B,H]=m.useState(0),[K,M]=m.useState(!1);m.useEffect(()=>{N&&A.current&&(A.current.focus(),B>0&&(A.current.style.width=`${B+20}px`))},[N,B]),m.useEffect(()=>{!N&&W.current&&H(W.current.offsetWidth)},[N,$]),m.useEffect(()=>{z(s.description||"")},[s.description]);const h=m.useCallback(()=>`mcphub_tool_form_${o?`${o}_`:""}${s.name}`,[s.name,o]),c=m.useCallback(()=>{localStorage.removeItem(h())},[h]),k=S=>{t&&t(s.name,S)},a=()=>{E(!0)},u=async()=>{try{const S=await Me(o,s.name,$);S.success?(E(!1),n&&n(s.name,$)):(z(s.description||""),console.error("Failed to update tool description:",S.error))}catch(S){console.error("Error updating tool description:",S),z(s.description||""),E(!1)}},l=S=>{z(S.target.value)},j=async()=>{O(!0);try{const S=await Ue(o,s.name);if(S.success){const U=S.description||"";z(U),E(!1),n==null||n(s.name,U,{restored:!0})}else f(S.error||i("tool.restoreDefaultFailed"),"error")}catch(S){console.error("Error resetting tool description:",S),f(i("tool.restoreDefaultFailed"),"error")}finally{O(!1)}},C=S=>{S.key==="Enter"?u():S.key==="Escape"&&(z(s.description||""),E(!1))},D=async S=>{S.stopPropagation();try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(s.name),M(!0),f(i("common.copySuccess"),"success"),setTimeout(()=>M(!1),2e3);else{const U=document.createElement("textarea");U.value=s.name,U.style.position="fixed",U.style.left="-9999px",document.body.appendChild(U),U.focus(),U.select();try{document.execCommand("copy"),M(!0),f(i("common.copySuccess"),"success"),setTimeout(()=>M(!1),2e3)}catch(te){f(i("common.copyFailed"),"error"),console.error("Copy to clipboard failed:",te)}document.body.removeChild(U)}}catch(U){f(i("common.copyFailed"),"error"),console.error("Copy to clipboard failed:",U)}},V=async S=>{R(!0);try{S=Object.fromEntries(Object.entries(S).filter(([te,re])=>!hs(re)));const U=await Je({toolName:s.name,arguments:S},o);F(U)}catch(U){F({success:!1,error:U instanceof Error?U.message:"Unknown error occurred"})}finally{R(!1)}},w=()=>{d(!1),c(),F(null)},J=()=>{F(null)};return e.jsxs("div",{className:"hub-card overflow-hidden",style:{marginBottom:8},children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 px-3 py-2.5 cursor-pointer hover:bg-[var(--hub-surface-hover)] transition-colors",onClick:S=>{S.stopPropagation(),T(!x)},children:[e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"hub-mono font-medium",style:{fontSize:13,color:"var(--hub-ink)"},children:s.name.replace(o+r,"")}),e.jsx("button",{className:"hub-icon-btn sm",onClick:D,title:i("common.copy"),children:K?e.jsx(de,{size:12,style:{color:"var(--hub-ok)"}}):e.jsx(fe,{size:12})}),e.jsx("span",{className:"flex items-center gap-1",style:{fontSize:12,color:"var(--hub-ink-3)"},children:N?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:A,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:B>0?`${B+20}px`:160,minWidth:80},value:$,onChange:l,onKeyDown:C,onClick:S=>S.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:S=>{S.stopPropagation(),u()},disabled:g,children:e.jsx(de,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(ne,{title:i("tool.restoreDefault"),onClick:S=>{S.stopPropagation(),j()},disabled:g,loading:g})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:W,children:$||i("tool.noDescription")}),e.jsx("button",{className:"hub-icon-btn sm",onClick:S=>{S.stopPropagation(),a()},children:e.jsx(Se,{size:12})}),e.jsx(ne,{title:i("tool.restoreDefault"),onClick:S=>{S.stopPropagation(),j()},disabled:g,loading:g})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("div",{onClick:S=>S.stopPropagation(),children:e.jsx(Ce,{checked:s.enabled??!0,onCheckedChange:k,disabled:b})}),e.jsxs("button",{onClick:S=>{S.stopPropagation(),T(!0),d(!0)},className:"hub-btn sm",style:{color:"var(--hub-accent)"},disabled:b||!s.enabled,children:[b?e.jsx(Oe,{size:12,className:"animate-spin"}):e.jsx(_e,{size:12}),e.jsx("span",{children:i(b?"tool.running":"tool.run")})]}),e.jsx("button",{className:"hub-icon-btn sm",children:x?e.jsx(Ee,{size:14}):e.jsx(ye,{size:14})})]})]}),x&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",padding:"10px 12px",display:"flex",flexDirection:"column",gap:10},children:[!I&&e.jsxs("div",{style:{background:"var(--hub-bg-2)",borderRadius:7,padding:"8px 12px",border:"1px solid var(--hub-line)"},children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:6},children:i("tool.inputSchema")}),e.jsx("pre",{className:"hub-mono overflow-auto",style:{fontSize:11.5,color:"var(--hub-ink-2)",margin:0},children:JSON.stringify(s.inputSchema,null,2)})]}),I&&e.jsxs("div",{style:{border:"1px solid var(--hub-line)",borderRadius:8,padding:14},children:[e.jsx(Be,{schema:s.inputSchema||{type:"object"},onSubmit:V,onCancel:w,loading:b,storageKey:h(),title:i("tool.runToolWithName",{name:s.name.replace(o+r,"")})}),v&&e.jsx("div",{style:{marginTop:12},children:e.jsx(xs,{result:v,onClose:J})})]})]})]})},fs=async(s,o)=>{try{const t=o?`/prompts/call/${o}`:"/prompts/call",n=await se(t,{promptName:s.promptName,arguments:s.arguments});return n.success?{success:!0,data:n.data}:{success:!1,error:n.message||"Prompt call failed"}}catch(t){return console.error("Error calling prompt",{promptName:s.promptName,server:o,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},Ve=async(s,o)=>{try{const t=await se(`/mcp/${encodeURIComponent(o||"")}/prompts/${encodeURIComponent(s.promptName)}`,{name:s.promptName,arguments:s.arguments});if(!t.success)throw new Error(`Failed to get prompt: ${t.message||"Unknown error"}`);return{success:!0,data:t.data}}catch(t){return console.error("Error getting prompt",{promptName:s.promptName,server:o,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},bs=async(s,o,t)=>{try{const n=await se(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(o)}/toggle`,{enabled:t});return{success:n.success,error:n.success?void 0:n.message}}catch(n){return console.error("Error toggling prompt",{serverName:s,promptName:o,enabled:t,error:n}),{success:!1,error:n instanceof Error?n.message:"Unknown error occurred"}}},We=async(s,o,t)=>{try{const n=await be(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(o)}/description`,{description:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:n.success,error:n.success?void 0:n.message}}catch(n){return console.error("Error updating prompt description",{serverName:s,promptName:o,error:n}),{success:!1,error:n instanceof Error?n.message:"Unknown error occurred"}}},Le=async(s,o)=>{var t;try{const n=await Fe(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(o)}/description`,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:n.success,error:n.success?void 0:n.message,description:(t=n.data)==null?void 0:t.description}}catch(n){return console.error("Error resetting prompt description",{serverName:s,promptName:o,error:n}),{success:!1,error:n instanceof Error?n.message:"Unknown error occurred"}}},js=Object.freeze(Object.defineProperty({__proto__:null,callPrompt:fs,getPrompt:Ve,resetPromptDescription:Le,togglePrompt:bs,updatePromptDescription:We},Symbol.toStringTag,{value:"Module"})),Pe=({result:s,onClose:o})=>{const{t}=Q(),n=i=>{if(typeof i=="string")return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:i})});if(typeof i=="object"&&i!==null){if(i.description||i.messages)return e.jsxs("div",{className:"space-y-4",children:[i.description&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:t("prompt.description")}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("p",{className:"text-sm text-gray-800",children:i.description})})]}),i.messages&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:t("prompt.messages")}),e.jsx("div",{className:"space-y-3",children:i.messages.map((f,r)=>e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[e.jsx("div",{className:"flex items-center mb-2",children:e.jsxs("span",{className:"inline-block w-16 text-xs font-medium text-gray-500",children:[f.role,":"]})}),typeof f.content=="string"?e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:f.content}):typeof f.content=="object"&&f.content.type==="text"?e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:f.content.text}):e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(f.content,null,2)})]},r))})]})]});try{const f=typeof i=="string"?JSON.parse(i):i;return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-2",children:t("prompt.jsonResponse")}),e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(f,null,2)})]})}catch{return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(i)})})}}return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(i)})})};return e.jsxs("div",{className:"border border-gray-300 rounded-lg bg-white dark:bg-gray-800 shadow-sm",children:[e.jsx("div",{className:"border-b border-gray-300 px-4 py-3 bg-gray-50 dark:bg-gray-800 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[s.success?e.jsx(Re,{size:20,className:"text-status-green"}):e.jsx($e,{size:20,className:"text-status-red"}),e.jsx("div",{children:e.jsxs("h4",{className:"text-sm font-medium text-gray-900",children:[t("prompt.execution")," ",s.success?t("prompt.successful"):t("prompt.failed")]})})]}),e.jsx("button",{onClick:o,className:"text-gray-400 hover:text-gray-600 text-sm",children:"✕"})]})}),e.jsx("div",{className:"p-4",children:s.success?e.jsx("div",{children:s.data?e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:t("prompt.result")}),n(s.data)]}):e.jsx("div",{className:"text-sm text-gray-500 italic",children:t("prompt.noContent")})}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-3",children:[e.jsx(je,{size:16,className:"text-red-500"}),e.jsx("span",{className:"text-sm font-medium text-red-700",children:t("prompt.error")})]}),e.jsx("div",{className:"bg-red-50 border border-red-300 rounded-md p-3",children:e.jsx("pre",{className:"text-sm text-red-800 whitespace-pre-wrap",children:s.error||s.message||t("prompt.unknownError")})})]})})]})},ys=({prompt:s,server:o,onToggle:t,onDescriptionUpdate:n})=>{const{t:i}=Q(),{showToast:f}=we(),{nameSeparator:r}=ke(),[x,T]=m.useState(!1),[I,d]=m.useState(!1),[b,R]=m.useState(!1),[v,F]=m.useState(null),[N,E]=m.useState(!1),[g,O]=m.useState(!1),[$,z]=m.useState(s.description||""),A=m.useRef(null),W=m.useRef(null),[B,H]=m.useState(0);m.useEffect(()=>{N&&A.current&&(A.current.focus(),B>0&&(A.current.style.width=`${B+20}px`))},[N,B]),m.useEffect(()=>{!N&&W.current&&H(W.current.offsetWidth)},[N,$]),m.useEffect(()=>{z(s.description||"")},[s.description]);const K=m.useCallback(()=>`mcphub_prompt_form_${o?`${o}_`:""}${s.name}`,[s.name,o]),M=m.useCallback(()=>{localStorage.removeItem(K())},[K]),h=w=>{t&&t(s.name,w)},c=()=>{E(!0)},k=async()=>{E(!1);try{const w=await We(o,s.name,$);w.success?n&&n(s.name,$):(f(w.error||i("prompt.descriptionUpdateFailed"),"error"),z(s.description||""))}catch(w){console.error("Error updating prompt description:",w),f(i("prompt.descriptionUpdateFailed"),"error"),z(s.description||"")}},a=async()=>{O(!0);try{const w=await Le(o,s.name);if(w.success){const J=w.description||"";z(J),E(!1),n==null||n(s.name,J,{restored:!0})}else f(w.error||i("prompt.restoreDefaultFailed"),"error")}catch(w){console.error("Error resetting prompt description:",w),f(i("prompt.restoreDefaultFailed"),"error")}finally{O(!1)}},u=w=>{z(w.target.value)},l=w=>{w.key==="Enter"?k():w.key==="Escape"&&(z(s.description||""),E(!1))},j=async w=>{R(!0);try{const J=await Ve({promptName:s.name,arguments:w},o);console.log("GetPrompt result:",J),F({success:J.success,data:J.data,error:J.error})}catch(J){F({success:!1,error:J instanceof Error?J.message:"Unknown error occurred"})}finally{R(!1)}},C=()=>{d(!1),M(),F(null)},D=()=>{F(null)},V=()=>{if(!s.arguments||s.arguments.length===0)return{type:"object",properties:{},required:[]};const w={},J=[];return s.arguments.forEach(S=>{w[S.name]={type:"string",description:S.description||""},S.required&&J.push(S.name)}),{type:"object",properties:w,required:J}};return e.jsxs("div",{className:"hub-card overflow-hidden",style:{marginBottom:8},children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 px-3 py-2.5 cursor-pointer hover:bg-[var(--hub-surface-hover)] transition-colors",onClick:()=>T(!x),children:[e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"hub-mono font-medium",style:{fontSize:13,color:"var(--hub-ink)"},children:s.name.replace(o+r,"")}),s.title&&e.jsx("span",{style:{fontSize:12,color:"var(--hub-ink-2)"},children:s.title}),e.jsx("span",{className:"flex items-center gap-1",style:{fontSize:12,color:"var(--hub-ink-3)"},children:N?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:A,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:B>0?`${B+20}px`:160,minWidth:80},value:$,onChange:u,onKeyDown:l,onClick:w=>w.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:w=>{w.stopPropagation(),k()},disabled:g,children:e.jsx(de,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(ne,{title:i("prompt.restoreDefault"),onClick:w=>{w.stopPropagation(),a()},disabled:g,loading:g})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:W,children:$||i("tool.noDescription")}),e.jsx("button",{className:"hub-icon-btn sm",onClick:w=>{w.stopPropagation(),c()},children:e.jsx(Se,{size:12})}),e.jsx(ne,{title:i("prompt.restoreDefault"),onClick:w=>{w.stopPropagation(),a()},disabled:g,loading:g})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("div",{onClick:w=>w.stopPropagation(),children:s.enabled!==void 0&&e.jsx(Ce,{checked:s.enabled,onCheckedChange:h,disabled:b})}),e.jsxs("button",{onClick:w=>{w.stopPropagation(),T(!0),d(!0)},className:"hub-btn sm",style:{color:"var(--hub-accent)"},disabled:b||!s.enabled,children:[b?e.jsx(Oe,{size:12,className:"animate-spin"}):e.jsx(_e,{size:12}),e.jsx("span",{children:i(b?"tool.running":"tool.run")})]}),e.jsx("button",{className:"hub-icon-btn sm",children:x?e.jsx(Ee,{size:14}):e.jsx(ye,{size:14})})]})]}),x&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",padding:"10px 12px",display:"flex",flexDirection:"column",gap:10},children:[I&&e.jsxs("div",{style:{border:"1px solid var(--hub-line)",borderRadius:8,padding:14},children:[e.jsx(Be,{schema:V(),onSubmit:j,onCancel:C,loading:b,storageKey:K(),title:i("prompt.runPromptWithName",{name:s.name.replace(o+r,"")})}),v&&e.jsx("div",{style:{marginTop:12},children:e.jsx(Pe,{result:v,onClose:D})})]}),!I&&s.arguments&&s.arguments.length>0&&e.jsxs("div",{style:{background:"var(--hub-bg-2)",borderRadius:7,padding:"8px 12px",border:"1px solid var(--hub-line)"},children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:6},children:i("tool.parameters")}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:s.arguments.map((w,J)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"hub-mono",style:{fontSize:12.5,color:"var(--hub-ink)"},children:w.name}),w.required&&e.jsx("span",{style:{color:"var(--hub-err)",fontSize:12},children:"*"})]}),w.description&&e.jsx("p",{style:{fontSize:12,color:"var(--hub-ink-3)",margin:"2px 0 0"},children:w.description})]}),w.title&&e.jsx("span",{style:{fontSize:11,color:"var(--hub-ink-3)"},children:w.title})]},J))})]}),!I&&v&&e.jsx("div",{children:e.jsx(Pe,{result:v,onClose:D})})]})]})},vs=({resource:s,onToggle:o,onDescriptionUpdate:t})=>{const{t:n}=Q(),[i,f]=m.useState(!1),[r,x]=m.useState(!1),[T,I]=m.useState(!1),[d,b]=m.useState(s.description||""),R=m.useRef(null),v=m.useRef(null),[F,N]=m.useState(0);m.useEffect(()=>{r&&R.current&&(R.current.focus(),F>0&&(R.current.style.width=`${F+20}px`))},[r,F]),m.useEffect(()=>{!r&&v.current&&N(v.current.offsetWidth)},[r,d]),m.useEffect(()=>{b(s.description||"")},[s.description]);const E=z=>{o&&o(s.uri,z)},g=async()=>{x(!1),t&&await t(s.uri,d)},O=async()=>{I(!0);try{await(t==null?void 0:t(s.uri,"",{restored:!0})),x(!1)}finally{I(!1)}},$=z=>{z.key==="Enter"?g():z.key==="Escape"&&(b(s.description||""),x(!1))};return e.jsxs("div",{className:"hub-card overflow-hidden",style:{marginBottom:8},children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 px-3 py-2.5 cursor-pointer hover:bg-[var(--hub-surface-hover)] transition-colors",onClick:()=>f(!i),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"hub-mono font-medium truncate",style:{fontSize:13,color:"var(--hub-ink)"},children:s.name||s.uri}),e.jsx("span",{className:"hub-mono truncate",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:s.uri})]}),e.jsx("span",{className:"flex items-center gap-1 mt-0.5",style:{fontSize:12,color:"var(--hub-ink-3)"},children:r?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:R,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:F>0?`${F+20}px`:160,minWidth:80},value:d,onChange:z=>b(z.target.value),onKeyDown:$,onClick:z=>z.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:z=>{z.stopPropagation(),g()},disabled:T,children:e.jsx(de,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(ne,{title:n("builtinResources.restoreDefault"),onClick:z=>{z.stopPropagation(),O()},disabled:T,loading:T})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:v,children:d||n("tool.noDescription")}),e.jsx("button",{className:"hub-icon-btn sm",onClick:z=>{z.stopPropagation(),x(!0)},children:e.jsx(Se,{size:12})}),e.jsx(ne,{title:n("builtinResources.restoreDefault"),onClick:z=>{z.stopPropagation(),O()},disabled:T,loading:T})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("div",{onClick:z=>z.stopPropagation(),children:e.jsx(Ce,{checked:s.enabled!==!1,onCheckedChange:E})}),e.jsx("button",{className:"hub-icon-btn sm",children:i?e.jsx(Ee,{size:14}):e.jsx(ye,{size:14})})]})]}),i&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",padding:"8px 12px"},children:[e.jsxs("span",{className:"hub-sect",children:[n("builtinResources.mimeType"),":"]})," ",e.jsx("span",{style:{fontSize:12,color:"var(--hub-ink-2)"},children:s.mimeType||"text/plain"})]})]})},Ie=(s,o)=>o?o==="stdio"?s("server.typeStdio")||"stdio":o==="sse"?s("server.typeSse")||"sse":o==="streamable-http"?s("server.typeStreamableHttp")||"http":o==="openapi"?s("server.typeOpenapi")||"openapi":o:null,Ns=({server:s,onRemove:o,onEdit:t,onToggle:n,onRefresh:i,onReload:f})=>{var X,ae,oe,le,q,Z,ie,ce,he;const{t:r}=Q(),{showToast:x}=we(),{exportMCPSettings:T,installConfig:I}=ke(),d=((X=I==null?void 0:I.baseUrl)==null?void 0:X.replace(/\/+$/,""))||"",[b,R]=m.useState(!1),[v,F]=m.useState(null),[N,E]=m.useState(!1),[g,O]=m.useState(!1),[$,z]=m.useState(!1),[A,W]=m.useState(!1),[B,H]=m.useState(!1),[K,M]=m.useState(!1),h=m.useRef(null),c=m.useRef(null);m.useEffect(()=>{const p=y=>{h.current&&!h.current.contains(y.target)&&W(!1),c.current&&!c.current.contains(y.target)&&H(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[]);const k=((ae=s.tools)==null?void 0:ae.length)||0,a=((oe=s.tools)==null?void 0:oe.filter(p=>p.enabled!==!1).length)||0,u=((le=s.prompts)==null?void 0:le.length)||0,l=((q=s.prompts)==null?void 0:q.filter(p=>p.enabled!==!1).length)||0,j=((Z=s.resources)==null?void 0:Z.length)||0,C=((ie=s.resources)==null?void 0:ie.filter(p=>p.enabled!==!1).length)||0,D=async p=>{if(p.stopPropagation(),!(g||!n)){O(!0);try{await n(s,s.enabled===!1)}finally{O(!1)}}},V=async p=>{if(p.stopPropagation(),W(!1),!($||!f)){z(!0);try{await f(s)?x(r("server.reloadSuccess")||"Server reloaded successfully","success"):x(r("server.reloadError",{serverName:s.name})||"Failed to reload","error")}finally{z(!1)}}},w=async p=>{try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(p),!0}catch{}try{const y=document.createElement("textarea");y.value=p,y.style.position="fixed",y.style.left="-9999px",document.body.appendChild(y),y.focus(),y.select();const P=document.execCommand("copy");return document.body.removeChild(y),P}catch{return!1}},J=async p=>{if(p.stopPropagation(),!s.error)return;await w(s.error)?(M(!0),x(r("common.copySuccess")||"Copied","success"),setTimeout(()=>M(!1),1500)):x(r("common.copyFailed")||"Copy failed","error")},S=async p=>{p.stopPropagation(),W(!1);try{const y=await T(s.name);if(!y||!y.success||!y.data){x((y==null?void 0:y.message)||r("common.copyFailed")||"Copy failed","error");return}const P=JSON.stringify(y.data,null,2),L=await w(P);x(L?r("common.copySuccess")||"Copied":r("common.copyFailed")||"Copy failed",L?"success":"error")}catch(y){console.error("Error copying server configuration:",y),x(r("common.copyFailed")||"Copy failed","error")}},U=p=>{var y;if(p.stopPropagation(),(y=s.oauth)!=null&&y.authorizationUrl){const Y=window.screen.width/2-300,ee=window.screen.height/2-700/2;window.open(s.oauth.authorizationUrl,"OAuth Authorization",`width=600,height=700,left=${Y},top=${ee}`),x(r("status.oauthWindowOpened"),"info")}},te=async(p,y)=>{try{const{toggleTool:P}=await ge(async()=>{const{toggleTool:Y}=await Promise.resolve().then(()=>ps);return{toggleTool:Y}},void 0,import.meta.url),L=await P(s.name,p,y);L.success?(x(r(y?"tool.enableSuccess":"tool.disableSuccess",{name:p}),"success"),i==null||i()):x(L.error||r("tool.toggleFailed"),"error")}catch(P){console.error(P),x(r("tool.toggleFailed"),"error")}},re=async(p,y)=>{try{const{togglePrompt:P}=await ge(async()=>{const{togglePrompt:Y}=await Promise.resolve().then(()=>js);return{togglePrompt:Y}},void 0,import.meta.url),L=await P(s.name,p,y);L.success?(x(r(y?"tool.enableSuccess":"tool.disableSuccess",{name:p}),"success"),i==null||i()):x(L.error||r("tool.toggleFailed"),"error")}catch(P){console.error(P),x(r("tool.toggleFailed"),"error")}},me=async(p,y)=>{try{const{toggleResource:P}=await ge(async()=>{const{toggleResource:Y}=await import("./resourceService-C6umWRgq.js");return{toggleResource:Y}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),L=await P(s.name,p,y);L.success?(x(r(y?"tool.enableSuccess":"tool.disableSuccess",{name:p}),"success"),i==null||i()):x(L.error||r("tool.toggleFailed"),"error")}catch(P){console.error(P),x(r("tool.toggleFailed"),"error")}},ue=(p,y,P)=>{x(P!=null&&P.restored?r("tool.restoreDefaultSuccess"):r("tool.descriptionUpdateSuccess"),"success"),i==null||i()},pe=(p,y,P)=>{x(P!=null&&P.restored?r("prompt.restoreDefaultSuccess"):r("prompt.descriptionUpdateSuccess"),"success"),i==null||i()},xe=async(p,y,P)=>{try{const{updateResourceDescription:L,resetResourceDescription:Y}=await ge(async()=>{const{updateResourceDescription:qe,resetResourceDescription:He}=await import("./resourceService-C6umWRgq.js");return{updateResourceDescription:qe,resetResourceDescription:He}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),ee=P!=null&&P.restored?await Y(s.name,p):await L(s.name,p,y);ee.success?(x(P!=null&&P.restored?r("builtinResources.restoreDefaultSuccess"):r("builtinResources.descriptionUpdateSuccess"),"success"),i==null||i()):x(ee.error||(P!=null&&P.restored?r("builtinResources.restoreDefaultFailed"):r("builtinResources.descriptionUpdateFailed")),"error")}catch(L){console.error(L),x(P!=null&&P.restored?r("builtinResources.restoreDefaultFailed"):r("builtinResources.descriptionUpdateFailed"),"error")}};(()=>{var P;const p=s.config;if(!p)return"";if(p.url)return p.url;const y=[];return p.command&&y.push(p.command),(P=p.args)!=null&&P.length&&y.push(...p.args),y.join(" ")})();const _=s.enabled!==!1,G=`${d}/mcp/${s.name}`;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hub-card overflow-visible",style:{marginBottom:10,opacity:_?1:.7},children:[e.jsxs("div",{className:"grid items-center gap-3 px-4 py-3 cursor-pointer hover:bg-[var(--hub-surface-hover)] transition-colors",style:{gridTemplateColumns:"minmax(220px,1.9fr) minmax(110px,0.9fr) minmax(120px,0.95fr) minmax(180px,1.1fr) 72px 36px"},onClick:()=>R(!b),children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx(ye,{size:12,style:{color:"var(--hub-ink-3)",transform:b?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0}}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"hub-mono truncate",style:{fontSize:13.5,color:_?"var(--hub-ink)":"var(--hub-ink-3)"},children:s.name}),s.error&&e.jsxs("div",{className:"relative",ref:c,children:[e.jsx("button",{onClick:p=>{p.stopPropagation(),H(y=>!y)},className:"text-[var(--hub-err)] hover:opacity-80","aria-label":r("server.viewErrorDetails"),children:e.jsx(je,{size:14})}),B&&e.jsxs("div",{className:"absolute z-20 mt-1.5 hub-card",style:{left:0,top:"100%",width:460,maxHeight:320,overflow:"hidden",boxShadow:"0 8px 24px rgba(0,0,0,0.08)"},onClick:p=>p.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",style:{borderBottom:"1px solid var(--hub-line-2)"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--hub-err)"},children:r("server.errorDetails")}),e.jsx("button",{onClick:J,className:"hub-icon-btn sm",title:r("common.copy"),children:K?e.jsx(de,{size:12,className:"text-[var(--hub-ok)]"}):e.jsx(fe,{size:12})})]}),e.jsx("button",{onClick:()=>H(!1),className:"hub-icon-btn sm","aria-label":r("app.closeButton"),children:e.jsx(ve,{size:12})})]}),e.jsx("div",{className:"p-3 overflow-auto hub-mono",style:{maxHeight:260,fontSize:12},children:e.jsx("pre",{className:"whitespace-pre-wrap break-words m-0",style:{color:"var(--hub-ink-2)"},children:s.error})})]})]})]}),((ce=s.config)==null?void 0:ce.description)&&e.jsx("div",{className:"text-[11.5px] truncate",style:{color:"var(--hub-ink-3)",marginTop:1},title:s.config.description,children:s.config.description})]})]}),e.jsx("div",{className:"min-w-0",children:e.jsx(Qe,{status:s.status,enabled:s.enabled,onAuthClick:U})}),e.jsx("div",{className:"min-w-0",children:(he=s.config)!=null&&he.type?e.jsx("span",{className:"hub-tag",title:Ie(r,s.config.type)??void 0,children:Ie(r,s.config.type)}):e.jsx("span",{style:{color:"var(--hub-ink-3)",fontSize:12},children:"—"})}),e.jsx("div",{className:"flex min-w-0 items-center gap-1.5",children:[{key:"tools",icon:ze,total:k,enabled:a,label:r("server.tools")},{key:"prompts",icon:Te,total:u,enabled:l,label:r("server.prompts")},{key:"resources",icon:De,total:j,enabled:C,label:r("nav.resources")}].map(({key:p,icon:y,total:P,enabled:L,label:Y})=>{const ee=P===0;return e.jsxs("span",{className:"inline-flex items-center gap-1 hub-mono hub-num",title:`${Y}: ${L}/${P}`,style:{padding:"2px 7px",borderRadius:6,fontSize:11.5,lineHeight:"16px",background:ee?"transparent":"var(--hub-bg-2)",border:"1px solid",borderColor:ee?"transparent":"var(--hub-line-2)",color:ee?"var(--hub-ink-3)":"var(--hub-ink-2)"},children:[e.jsx(y,{size:12,style:{color:"var(--hub-ink-3)",flexShrink:0}}),e.jsx("span",{children:ee?"0":`${L}/${P}`})]},p)})}),e.jsx("div",{className:"flex items-center justify-center",children:e.jsx("button",{type:"button",className:"hub-switch"+(_?" on":""),onClick:D,disabled:g,"aria-label":r(_?"server.disable":"server.enable")})}),e.jsxs("div",{className:"relative",ref:h,children:[e.jsx("button",{className:"hub-icon-btn",onClick:p=>{p.stopPropagation(),W(y=>!y)},"aria-label":"More",children:e.jsx(es,{size:14})}),A&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 hub-card",style:{minWidth:160,padding:4},onClick:p=>p.stopPropagation(),children:[e.jsxs("button",{onClick:p=>{p.stopPropagation(),W(!1),t(s)},className:"flex items-center gap-2 w-full px-2.5 py-1.5 text-[13px] rounded-md hover:bg-[var(--hub-surface-hover)] text-left",style:{color:"var(--hub-ink)"},children:[e.jsx(ss,{size:13})," ",r("server.edit")]}),e.jsxs("button",{onClick:S,className:"flex items-center gap-2 w-full px-2.5 py-1.5 text-[13px] rounded-md hover:bg-[var(--hub-surface-hover)] text-left",style:{color:"var(--hub-ink)"},children:[e.jsx(fe,{size:13})," ",r("server.copy")]}),f&&e.jsxs("button",{onClick:V,disabled:$||g||!_,className:"flex items-center gap-2 w-full px-2.5 py-1.5 text-[13px] rounded-md hover:bg-[var(--hub-surface-hover)] text-left disabled:opacity-50 disabled:cursor-not-allowed",style:{color:"var(--hub-ink)"},children:[e.jsx(Ne,{size:13})," ",r("server.reload")]}),e.jsx("div",{style:{height:1,background:"var(--hub-line-2)",margin:"4px 0"}}),e.jsxs("button",{onClick:p=>{p.stopPropagation(),W(!1),E(!0)},className:"flex items-center gap-2 w-full px-2.5 py-1.5 text-[13px] rounded-md hover:bg-[var(--hub-surface-hover)] text-left",style:{color:"var(--hub-err)"},children:[e.jsx(ts,{size:13})," ",r("server.delete")]})]})]})]}),b&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",background:"var(--hub-bg-2)",padding:"14px 16px 16px 38px"},children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2 flex-wrap",children:[[{key:"tools",icon:e.jsx(ze,{size:12}),label:r("server.tools"),count:k,enabled:a},{key:"prompts",icon:e.jsx(Te,{size:12}),label:r("server.prompts"),count:u,enabled:l},{key:"resources",icon:e.jsx(De,{size:12}),label:r("nav.resources"),count:j,enabled:C}].map(p=>{const y=v===p.key;return e.jsxs("button",{onClick:()=>F(y?null:p.key),className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[12px] transition-colors hover:bg-[var(--hub-surface-hover)]",style:{background:y?"var(--hub-surface)":"transparent",border:"1px solid "+(y?"var(--hub-line)":"transparent"),color:y?"var(--hub-ink)":"var(--hub-ink-2)"},children:[p.icon,e.jsx("span",{children:p.label}),e.jsx("span",{className:"hub-mono hub-num",style:{color:"var(--hub-ink-3)",fontSize:11},children:p.count===0?"0":`${p.enabled}/${p.count}`})]},p.key)}),e.jsx("div",{className:"ml-auto max-w-full flex-shrink-0",children:e.jsxs("div",{className:"hub-endpoint",style:{height:26},children:[e.jsx("div",{className:"hub-endpoint-label",children:"/mcp/"}),e.jsx("div",{className:"hub-endpoint-url",title:G,style:{maxWidth:200},children:s.name}),e.jsx("button",{type:"button",className:"hub-endpoint-copy",onClick:async p=>{p.stopPropagation();const y=await w(G);x(y?r("common.copySuccess")||"Copied":r("common.copyFailed")||"Failed",y?"success":"error")},title:r("common.copy"),children:e.jsx(fe,{size:12})})]})})]}),v==="tools"&&s.tools&&e.jsx("div",{className:"space-y-3 mt-2",children:s.tools.map((p,y)=>e.jsx(gs,{server:s.name,tool:p,onToggle:te,onDescriptionUpdate:ue},y))}),v==="prompts"&&s.prompts&&e.jsx("div",{className:"space-y-3 mt-2",children:s.prompts.map((p,y)=>e.jsx(ys,{server:s.name,prompt:p,onToggle:re,onDescriptionUpdate:pe},y))}),v==="resources"&&s.resources&&e.jsx("div",{className:"mt-2",children:s.resources.length===0?e.jsx("div",{className:"text-sm",style:{color:"var(--hub-ink-3)"},children:r("builtinResources.noResources")}):e.jsx("div",{className:"space-y-3",children:s.resources.map((p,y)=>e.jsx(vs,{resource:p,onToggle:me,onDescriptionUpdate:xe},`${p.uri}-${y}`))})})]})]}),e.jsx(ls,{isOpen:N,onClose:()=>E(!1),onConfirm:()=>{o(s.name),E(!1)},serverName:s.name})]})},ws=({onAdd:s})=>{const{t:o}=Q(),[t,n]=m.useState(!1),[i,f]=m.useState(null),[r,x]=m.useState(!1),[T,I]=m.useState(null),[d,b]=m.useState([]),R=()=>{n(!t),f(null),x(!1),I(null)},v=async()=>{T&&(await F(T),x(!1),I(null))},F=async E=>{try{f(null);const g=await se("/servers",E);if(!g.success){g&&g.message?f(g.message):f(o("server.addError"));return}n(!1),s()}catch(g){console.error("Error adding server:",g),navigator.onLine?g instanceof TypeError&&(g.message.includes("NetworkError")||g.message.includes("Failed to fetch"))?f(o("errors.serverConnection")):f(o("errors.serverAdd")):f(o("errors.network"))}},N=async E=>{try{const g=is(E);g.length>0?(b(g),I(E),x(!0)):await F(E)}catch(g){console.error("Error processing server submission:",g),f(o("errors.serverAdd"))}};return e.jsxs("div",{children:[e.jsxs("button",{onClick:R,className:"hub-btn primary",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})}),o("server.add")]}),t&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(Ae,{onSubmit:N,onCancel:R,modalTitle:o("server.addServer"),formError:i})}),r&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-[60] flex items-center justify-center p-4",children:e.jsxs("div",{className:"hub-card p-6 w-full max-w-md",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:o("server.confirmVariables")}),e.jsx("p",{className:"text-gray-600 mb-4",children:o("server.variablesDetected")}),e.jsx("div",{className:"bg-yellow-50 border border-yellow-200 rounded p-3 mb-4",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-yellow-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"ml-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-yellow-800",children:[o("server.detectedVariables"),":"]}),e.jsx("ul",{className:"mt-1 text-sm text-yellow-700",children:d.map((E,g)=>e.jsxs("li",{className:"font-mono",children:["$",`{${E}}`]},g))})]})]})}),e.jsx("p",{className:"text-gray-600 text-sm mb-6",children:o("server.confirmVariablesMessage")}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>{x(!1),I(null)},className:"hub-btn",children:o("common.cancel")}),e.jsx("button",{onClick:v,className:"hub-btn primary",children:o("server.confirmAndAdd")})]})]})})]})},ks=({server:s,onEdit:o,onCancel:t})=>{const{t:n}=Q(),[i,f]=m.useState(null),r=async x=>{try{f(null);const T=encodeURIComponent(s.name),I=x.name&&x.name!==s.name,d={config:x.config,...I?{newName:x.name}:{}},b=await be(`/servers/${T}`,d);if(!b.success){b&&b.message?f(b.message):f(n("server.updateError",{serverName:s.name}));return}o()}catch(T){console.error("Error updating server:",T),navigator.onLine?T instanceof TypeError&&(T.message.includes("NetworkError")||T.message.includes("Failed to fetch"))?f(n("errors.serverConnection")):f(n("errors.serverUpdate",{serverName:s.name})):f(n("errors.network"))}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(Ae,{onSubmit:r,onCancel:t,initialData:s,modalTitle:n("server.editTitle",{serverName:s.name}),formError:i})})},Cs=({onSuccess:s,onCancel:o})=>{const{t}=Q(),[n,i]=m.useState(!1),[f,r]=m.useState(!1),[x,T]=m.useState(null),[I,d]=m.useState(null),[b,R]=m.useState(!1),[v,F]=m.useState(null),[N,E]=m.useState(""),[g,O]=m.useState(!1),[$,z]=m.useState(""),A=a=>{a.preventDefault(),i(!0)},W=a=>{a.preventDefault(),i(!1)},B=a=>{a.preventDefault(),i(!1);const u=a.dataTransfer.files;if(u.length>0){const l=u[0];l.name.endsWith(".mcpb")?(d(l),T(null)):T(t("mcpb.invalidFileType"))}},H=a=>{const u=a.target.files;if(u&&u.length>0){const l=u[0];l.name.endsWith(".mcpb")?(d(l),T(null)):T(t("mcpb.invalidFileType"))}},K=async()=>{if(!I){T(t("mcpb.noFileSelected"));return}r(!0),T(null);try{const a=new FormData;a.append("mcpbFile",I);const u=await Xe(Ze("/mcpb/upload"),{method:"POST",body:a}),l=await u.json();if(!u.ok)throw new Error(l.message||`HTTP error! Status: ${u.status}`);if(l.success&&l.data)F(l.data.manifest),E(l.data.extractDir),R(!0);else throw new Error(l.message||t("mcpb.uploadFailed"))}catch(a){console.error("MCPB upload error:",a),T(a instanceof Error?a.message:t("mcpb.uploadFailed"))}finally{r(!1)}},M=async(a,u=!1)=>{var l;r(!0),T(null);try{const j=k(v,N,a);if(!u){const D=await Ke("/servers");if(D.success&&((l=D.data)==null?void 0:l.find(w=>w.name===a))){z(a),O(!0),r(!1);return}}let C;if(u?C=await be(`/servers/${encodeURIComponent(a)}`,{name:a,config:j}):C=await se("/servers",{name:a,config:j}),C.success)s(j);else throw new Error(C.message||t("mcpb.installFailed"))}catch(j){console.error("MCPB install error:",j),T(j instanceof Error?j.message:t("mcpb.installFailed")),r(!1)}},h=()=>{O(!1),$&&M($,!0)},c=()=>{O(!1),z(""),r(!1)},k=(a,u,l)=>{var D;const j=((D=a.server)==null?void 0:D.mcp_config)||{},C={type:"stdio",command:j.command||"node",args:(j.args||[]).map(V=>V.replace("${__dirname}",u))};return j.env&&Object.keys(j.env).length>0&&(C.env={...j.env},Object.keys(C.env).forEach(V=>{typeof C.env[V]=="string"&&(C.env[V]=C.env[V].replace("${__dirname}",u))})),C};return b&&v?e.jsxs(e.Fragment,{children:[e.jsx(cs,{isOpen:g,onClose:c,onConfirm:h,title:t("mcpb.serverExistsTitle"),message:t("mcpb.serverExistsConfirm",{serverName:$}),confirmText:t("mcpb.override"),cancelText:t("common.cancel"),variant:"warning"}),e.jsx("div",{className:`fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4 ${g?"opacity-50 pointer-events-none":""}`,children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 w-full max-w-3xl max-h-screen overflow-y-auto",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:t("mcpb.installServer")}),e.jsx("button",{onClick:o,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),x&&e.jsx("div",{className:"mb-4 bg-red-50 border-l-4 border-red-500 p-4 rounded",children:e.jsx("p",{className:"text-red-700",children:x})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 p-4 rounded-lg",children:[e.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:t("mcpb.extensionInfo")}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.name"),":"]})," ",v.display_name||v.name]}),e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.version"),":"]})," ",v.version]}),e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.description"),":"]})," ",v.description]}),v.author&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.author"),":"]})," ",v.author.name]}),v.tools&&v.tools.length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.tools"),":"]}),e.jsx("ul",{className:"list-disc list-inside ml-4",children:v.tools.map((a,u)=>e.jsxs("li",{children:[a.name," - ",a.description]},u))})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:t("mcpb.serverName")}),e.jsx("input",{type:"text",id:"serverName",defaultValue:v.name,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 form-input",placeholder:t("mcpb.serverNamePlaceholder")})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:o,disabled:f,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:()=>{const a=document.getElementById("serverName"),u=(a==null?void 0:a.value.trim())||v.name;M(u)},disabled:f,className:"hub-btn primary",children:f?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t("mcpb.installing")]}):t("mcpb.install")})]})]})]})})]}):e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 w-full max-w-lg",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:t("mcpb.uploadTitle")}),e.jsx("button",{onClick:o,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),x&&e.jsx("div",{className:"mb-4 bg-red-50 border-l-4 border-red-500 p-4 rounded",children:e.jsx("p",{className:"text-red-700",children:x})}),e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-8 text-center transition-colors ${n?"border-blue-500 bg-blue-50":I?"border-gray-500 ":"border-gray-300 hover:border-gray-400"}`,onDragOver:A,onDragLeave:W,onDrop:B,children:[I?e.jsxs("div",{className:"space-y-2",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-green-200",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("p",{className:"text-sm text-gray-900 font-medium",children:I.name}),e.jsxs("p",{className:"text-xs text-gray-500",children:[(I.size/1024/1024).toFixed(2)," MB"]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-900",children:t("mcpb.dropFileHere")}),e.jsx("p",{className:"text-xs text-gray-500",children:t("mcpb.orClickToSelect")})]})]}),e.jsx("input",{type:"file",accept:".mcpb",onChange:H,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"})]}),e.jsxs("div",{className:"mt-6 flex justify-end space-x-4",children:[e.jsx("button",{onClick:o,disabled:f,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:K,disabled:!I||f,className:"hub-btn primary flex items-center",children:f?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t("mcpb.uploading")]}):t("mcpb.upload")})]})]})})},Ss=({onSuccess:s,onCancel:o})=>{const{t}=Q(),[n,i]=m.useState(""),[f,r]=m.useState(null),[x,T]=m.useState(!1),[I,d]=m.useState(null),b=`{
7
+ "mcpServers": {
8
+ "stdio-server-example": {
9
+ "command": "npx",
10
+ "args": ["-y", "mcp-server-example"]
11
+ },
12
+ "sse-server-example": {
13
+ "type": "sse",
14
+ "url": "http://localhost:3000"
15
+ },
16
+ "http-server-example": {
17
+ "type": "streamable-http",
18
+ "url": "http://localhost:3001",
19
+ "headers": {
20
+ "Content-Type": "application/json",
21
+ "Authorization": "Bearer your-token"
22
+ }
23
+ },
24
+ "openapi-server-example": {
25
+ "type": "openapi",
26
+ "openapi": {
27
+ "url": "https://petstore.swagger.io/v2/swagger.json"
28
+ }
29
+ }
30
+ }
31
+ }
32
+
33
+ Supports: STDIO, SSE, HTTP (streamable-http), OpenAPI
34
+ All servers will be imported in a single efficient batch operation.`,R=N=>{try{const E=JSON.parse(N.trim());return!E.mcpServers||typeof E.mcpServers!="object"?(r(t("jsonImport.invalidFormat")),null):E}catch{return r(t("jsonImport.parseError")),null}},v=()=>{r(null);const N=R(n);if(!N)return;const E=Object.entries(N.mcpServers).map(([g,O])=>{const $={};return O.type==="sse"||O.type==="streamable-http"?($.type=O.type,$.url=O.url,O.headers&&($.headers=O.headers)):O.type==="openapi"?($.type="openapi",$.openapi=O.openapi):($.type="stdio",$.command=O.command,$.args=O.args||[],O.env&&($.env=O.env)),{name:g,config:$}});d(E)},F=async()=>{if(I){T(!0),r(null);try{const N=await se("/servers/batch",{servers:I});if(N.success&&N.data){const{successCount:E,failureCount:g,results:O}=N.data;if(g>0){const $=O.filter(z=>!z.success).map(z=>`${z.name}: ${z.message||t("jsonImport.addFailed")}`);r(t("jsonImport.partialSuccess",{count:E,total:I.length})+`
35
+ `+$.join(`
36
+ `))}E>0&&s()}else r(N.message||t("jsonImport.importFailed"))}catch(N){console.error("Import error:",N),r(t("jsonImport.importFailed"))}finally{T(!1)}}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:t("jsonImport.title")}),e.jsx("button",{onClick:o,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),f&&e.jsx("div",{className:"mb-4 bg-red-50 border-l-4 border-red-500 p-4 rounded",children:e.jsx("p",{className:"text-red-700 whitespace-pre-wrap",children:f})}),I?e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-3",children:t("jsonImport.previewTitle")}),e.jsx("div",{className:"space-y-3",children:I.map((N,E)=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 p-4 rounded-lg border border-gray-200 dark:border-gray-700",children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-gray-900",children:N.name}),e.jsxs("div",{className:"mt-2 space-y-1 text-sm text-gray-600",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.type"),":"]})," ",N.config.type||"stdio"]}),N.config.command&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.command"),":"]})," ",N.config.command]}),N.config.args&&N.config.args.length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.arguments"),":"]})," ",N.config.args.join(" ")]}),N.config.url&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.url"),":"]})," ",N.config.url]}),N.config.env&&Object.keys(N.config.env).length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.envVars"),":"]})," ",Object.keys(N.config.env).join(", ")]}),N.config.headers&&Object.keys(N.config.headers).length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.headers"),":"]})," ",Object.keys(N.config.headers).join(", ")]})]})]})})},E))})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:()=>d(null),disabled:x,className:"hub-btn",children:t("common.back")}),e.jsx("button",{onClick:F,disabled:x,className:"hub-btn primary",children:x?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t("jsonImport.importing")]}):t("jsonImport.import")})]})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:t("jsonImport.inputLabel")}),e.jsx("textarea",{value:n,onChange:N=>i(N.target.value),className:"w-full h-96 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-sm",placeholder:b}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:t("jsonImport.inputHelp")})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:o,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:v,disabled:!n.trim(),className:"hub-btn primary",children:t("jsonImport.preview")})]})]})]})})},Js=()=>{const{t:s}=Q(),o=Ge(),{servers:t,allServers:n,error:i,setError:f,isLoading:r,pagination:x,currentPage:T,serversPerPage:I,setCurrentPage:d,setServersPerPage:b,handleServerAdd:R,handleServerEdit:v,handleServerRemove:F,handleServerToggle:N,handleServerReload:E,triggerRefresh:g}=ms({refreshOnMount:!0}),[O,$]=m.useState(null),[z,A]=m.useState(!1),[W,B]=m.useState(!1),[H,K]=m.useState(!1),[M,h]=m.useState("all"),[c,k]=m.useState(""),a=m.useMemo(()=>({all:n.length,online:n.filter(C=>C.status==="connected").length,issues:n.filter(C=>C.status!=="connected"&&C.enabled!==!1).length}),[n]),u=m.useMemo(()=>{const C=c.trim().toLowerCase();return t.filter(D=>{var w,J;return M==="online"&&D.status!=="connected"||M==="issues"&&(D.status==="connected"||D.enabled===!1)?!1:C?(D.name+" "+(((w=D.config)==null?void 0:w.description)||"")+" "+(((J=D.tools)==null?void 0:J.map(S=>S.name).join(" "))||"")).toLowerCase().includes(C):!0})},[t,M,c]),l=async C=>{const D=await v(C);D&&$(D)},j=async()=>{A(!0);try{g(),await new Promise(C=>setTimeout(C,400))}finally{A(!1)}};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-end justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"hub-h1",children:s("pages.servers.title")}),e.jsxs("p",{className:"hub-sub",children:[e.jsx("span",{className:"hub-num",children:a.all})," ",s("nav.servers").toLowerCase()," ·"," ",e.jsx("span",{className:"hub-num",children:a.online})," ",s("status.online")," ·"," ",e.jsx("span",{className:"hub-num",children:a.issues})," ",s("common.inactive")||"issues"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{className:"hub-btn",onClick:()=>o("/market"),children:[e.jsx(rs,{size:13})," ",s("nav.market")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>K(!0),children:[e.jsx(ns,{size:13})," ",s("jsonImport.button")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>B(!0),children:[e.jsx(as,{size:13})," ",s("mcpb.upload")]}),e.jsxs("button",{className:"hub-btn",onClick:j,disabled:z,"aria-label":s("common.refresh"),children:[e.jsx(Ne,{size:13,className:z?"animate-spin":""}),s("common.refresh")]}),e.jsx(ws,{onAdd:R})]})]}),i&&e.jsxs("div",{className:"hub-card flex items-center justify-between gap-3 mb-4",style:{padding:"10px 14px",borderColor:"oklch(0.85 0.1 25)",background:"oklch(0.97 0.03 25)",color:"oklch(0.4 0.18 25)"},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(je,{size:14,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate text-[13px]",children:i})]}),e.jsx("button",{className:"hub-icon-btn sm",onClick:()=>f(null),"aria-label":s("app.closeButton"),children:e.jsx(ve,{size:13})})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-4 flex-wrap",children:[e.jsx("div",{className:"hub-card flex items-center",style:{padding:2,borderRadius:7,background:"var(--hub-surface)"},children:[["all",s("common.all")||"All",a.all],["online",s("status.online"),a.online],["issues",s("common.inactive")||"Issues",a.issues]].map(([C,D,V])=>e.jsxs("button",{onClick:()=>h(C),className:"inline-flex items-center gap-1.5 px-3 text-[12px]",style:{height:24,borderRadius:5,background:M===C?"var(--hub-bg-2)":"transparent",color:M===C?"var(--hub-ink)":"var(--hub-ink-3)",border:"1px solid "+(M===C?"var(--hub-line)":"transparent")},children:[D,e.jsx("span",{className:"hub-mono",style:{fontSize:11,color:"var(--hub-ink-3)"},children:V})]},C))}),e.jsxs("div",{className:"hub-card flex items-center gap-2 px-2.5 flex-1",style:{height:30,background:"var(--hub-surface)",maxWidth:360},children:[e.jsx(os,{size:13,style:{color:"var(--hub-ink-3)"}}),e.jsx("input",{value:c,onChange:C=>k(C.target.value),className:"flex-1 bg-transparent outline-none text-[13px]",style:{color:"var(--hub-ink)"},placeholder:s("market.searchPlaceholder")||"Search…"}),c&&e.jsx("button",{onClick:()=>k(""),className:"hub-icon-btn sm",children:e.jsx(ve,{size:11})})]}),e.jsxs("div",{className:"ml-auto hub-mono text-[12px]",style:{color:"var(--hub-ink-3)"},children:[u.length,"/",t.length]})]}),r&&t.length===0?e.jsx("div",{className:"hub-card p-6 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(Ne,{size:20,className:"animate-spin",style:{color:"var(--hub-ink-3)"}}),e.jsx("p",{style:{color:"var(--hub-ink-3)"},children:s("app.loading")})]})}):u.length===0?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:e.jsx("p",{children:t.length===0?s("app.noServers"):s("market.noServers")})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col",children:u.map(C=>e.jsx(Ns,{server:C,onRemove:F,onEdit:l,onToggle:N,onRefresh:g,onReload:E},C.name))}),e.jsxs("div",{className:"flex items-center mt-4 text-[12px]",style:{color:"var(--hub-ink-3)"},children:[e.jsx("div",{className:"flex-[2]",children:x?s("common.showing",{start:(x.page-1)*x.limit+1,end:Math.min(x.page*x.limit,x.total),total:x.total}):s("common.showing",{start:1,end:t.length,total:t.length})}),e.jsx("div",{className:"flex-[4] flex justify-center",children:x&&x.totalPages>1&&e.jsx(ds,{currentPage:T,totalPages:x.totalPages,onPageChange:d,disabled:r})}),e.jsxs("div",{className:"flex-[2] flex items-center justify-end gap-2",children:[e.jsxs("label",{htmlFor:"perPage",children:[s("common.itemsPerPage"),":"]}),e.jsxs("select",{id:"perPage",value:I,onChange:C=>b(Number(C.target.value)),disabled:r,className:"hub-input",style:{height:26,width:70,padding:"0 6px",fontSize:12},children:[e.jsx("option",{value:5,children:"5"}),e.jsx("option",{value:10,children:"10"}),e.jsx("option",{value:20,children:"20"}),e.jsx("option",{value:50,children:"50"})]})]})]})]}),O&&e.jsx(ks,{server:O,onEdit:()=>{$(null),g()},onCancel:()=>$(null)}),W&&e.jsx(Cs,{onSuccess:()=>{B(!1),g()},onCancel:()=>B(!1)}),H&&e.jsx(Ss,{onSuccess:()=>{K(!1),g()},onCancel:()=>K(!1)})]})};export{Js as default};
37
+ //# sourceMappingURL=ServersPage-hgCbCglG.js.map