@samanhappy/mcphub 1.0.35 → 1.0.37

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 (139) hide show
  1. package/README.fr.md +48 -17
  2. package/README.md +50 -39
  3. package/README.zh.md +50 -37
  4. package/dist/clients/openapi.js +32 -1
  5. package/dist/clients/openapi.js.map +1 -1
  6. package/dist/controllers/credentialBindingController.js +56 -0
  7. package/dist/controllers/credentialBindingController.js.map +1 -0
  8. package/dist/controllers/groupController.js +63 -14
  9. package/dist/controllers/groupController.js.map +1 -1
  10. package/dist/controllers/serverController.js +26 -4
  11. package/dist/controllers/serverController.js.map +1 -1
  12. package/dist/controllers/userController.js +3 -0
  13. package/dist/controllers/userController.js.map +1 -1
  14. package/dist/dao/CredentialBindingDao.js +48 -0
  15. package/dist/dao/CredentialBindingDao.js.map +1 -0
  16. package/dist/dao/CredentialBindingDaoDbImpl.js +20 -0
  17. package/dist/dao/CredentialBindingDaoDbImpl.js.map +1 -0
  18. package/dist/dao/DaoFactory.js +7 -0
  19. package/dist/dao/DaoFactory.js.map +1 -1
  20. package/dist/dao/DatabaseDaoFactory.js +4 -0
  21. package/dist/dao/DatabaseDaoFactory.js.map +1 -1
  22. package/dist/dao/GroupDaoDbImpl.js +18 -0
  23. package/dist/dao/GroupDaoDbImpl.js.map +1 -1
  24. package/dist/dao/ServerDaoDbImpl.js +3 -0
  25. package/dist/dao/ServerDaoDbImpl.js.map +1 -1
  26. package/dist/db/connection.js +3 -2
  27. package/dist/db/connection.js.map +1 -1
  28. package/dist/db/entities/CredentialBinding.js +33 -0
  29. package/dist/db/entities/CredentialBinding.js.map +1 -0
  30. package/dist/db/entities/Group.js +9 -1
  31. package/dist/db/entities/Group.js.map +1 -1
  32. package/dist/db/entities/Server.js +4 -0
  33. package/dist/db/entities/Server.js.map +1 -1
  34. package/dist/db/entities/index.js +3 -1
  35. package/dist/db/entities/index.js.map +1 -1
  36. package/dist/db/groupSchema.js +29 -0
  37. package/dist/db/groupSchema.js.map +1 -0
  38. package/dist/middlewares/auth.js +2 -0
  39. package/dist/middlewares/auth.js.map +1 -1
  40. package/dist/middlewares/i18n.js +2 -1
  41. package/dist/middlewares/i18n.js.map +1 -1
  42. package/dist/routes/index.js +19 -4
  43. package/dist/routes/index.js.map +1 -1
  44. package/dist/services/activityLoggingService.js +21 -8
  45. package/dist/services/activityLoggingService.js.map +1 -1
  46. package/dist/services/credentialBindingService.js +193 -0
  47. package/dist/services/credentialBindingService.js.map +1 -0
  48. package/dist/services/groupService.js +57 -23
  49. package/dist/services/groupService.js.map +1 -1
  50. package/dist/services/logService.js +11 -2
  51. package/dist/services/logService.js.map +1 -1
  52. package/dist/services/mcpService.js +478 -77
  53. package/dist/services/mcpService.js.map +1 -1
  54. package/dist/services/oauthClientRegistration.js +22 -7
  55. package/dist/services/oauthClientRegistration.js.map +1 -1
  56. package/dist/services/oauthSettingsStore.js +3 -0
  57. package/dist/services/oauthSettingsStore.js.map +1 -1
  58. package/dist/services/principalRuntimeService.js +109 -0
  59. package/dist/services/principalRuntimeService.js.map +1 -0
  60. package/dist/services/serverConfigPresenter.js +3 -0
  61. package/dist/services/serverConfigPresenter.js.map +1 -1
  62. package/dist/services/sseService.js +65 -16
  63. package/dist/services/sseService.js.map +1 -1
  64. package/dist/utils/credentialTemplate.js +38 -0
  65. package/dist/utils/credentialTemplate.js.map +1 -0
  66. package/dist/utils/groupAccess.js +17 -0
  67. package/dist/utils/groupAccess.js.map +1 -0
  68. package/dist/utils/migration.js +11 -0
  69. package/dist/utils/migration.js.map +1 -1
  70. package/dist/utils/rateLimit.js +85 -18
  71. package/dist/utils/rateLimit.js.map +1 -1
  72. package/dist/utils/serverConfigPersistence.js +2 -0
  73. package/dist/utils/serverConfigPersistence.js.map +1 -1
  74. package/frontend/dist/assets/{ActivityPage-B4OBJUBq.js → ActivityPage-Bx5-Jrxq.js} +2 -2
  75. package/frontend/dist/assets/{ActivityPage-B4OBJUBq.js.map → ActivityPage-Bx5-Jrxq.js.map} +1 -1
  76. package/frontend/dist/assets/{ConfirmDialog-3APts2Y9.js → ConfirmDialog-uWBwm8J1.js} +2 -2
  77. package/frontend/dist/assets/{ConfirmDialog-3APts2Y9.js.map → ConfirmDialog-uWBwm8J1.js.map} +1 -1
  78. package/frontend/dist/assets/CredentialsPage-BGbk_kBx.js +2 -0
  79. package/frontend/dist/assets/CredentialsPage-BGbk_kBx.js.map +1 -0
  80. package/frontend/dist/assets/{Dashboard-czP-DGHn.js → Dashboard-gHeXLPEn.js} +2 -2
  81. package/frontend/dist/assets/{Dashboard-czP-DGHn.js.map → Dashboard-gHeXLPEn.js.map} +1 -1
  82. package/frontend/dist/assets/{DeleteDialog-D9ycSRvn.js → DeleteDialog-BYhrMGZo.js} +2 -2
  83. package/frontend/dist/assets/{DeleteDialog-D9ycSRvn.js.map → DeleteDialog-BYhrMGZo.js.map} +1 -1
  84. package/frontend/dist/assets/{EndpointCopy-CDwtdCHE.js → EndpointCopy-BRwX7Dpv.js} +2 -2
  85. package/frontend/dist/assets/{EndpointCopy-CDwtdCHE.js.map → EndpointCopy-BRwX7Dpv.js.map} +1 -1
  86. package/frontend/dist/assets/GroupsPage-grCAx55k.js +33 -0
  87. package/frontend/dist/assets/GroupsPage-grCAx55k.js.map +1 -0
  88. package/frontend/dist/assets/{LoginPage-BBzViqLx.js → LoginPage-C7-m2jmB.js} +2 -2
  89. package/frontend/dist/assets/{LoginPage-BBzViqLx.js.map → LoginPage-C7-m2jmB.js.map} +1 -1
  90. package/frontend/dist/assets/{LogsPage-CqbaqFiQ.js → LogsPage-B00XTokA.js} +2 -2
  91. package/frontend/dist/assets/{LogsPage-CqbaqFiQ.js.map → LogsPage-B00XTokA.js.map} +1 -1
  92. package/frontend/dist/assets/{MarketPage-DinCKwrj.js → MarketPage-CVJMdSDD.js} +2 -2
  93. package/frontend/dist/assets/{MarketPage-DinCKwrj.js.map → MarketPage-CVJMdSDD.js.map} +1 -1
  94. package/frontend/dist/assets/{OAuthConsentPage-BuPcJ2zS.js → OAuthConsentPage-znW3HtpR.js} +2 -2
  95. package/frontend/dist/assets/{OAuthConsentPage-BuPcJ2zS.js.map → OAuthConsentPage-znW3HtpR.js.map} +1 -1
  96. package/frontend/dist/assets/{Pagination-Dwko3g48.js → Pagination-CLUvn47x.js} +2 -2
  97. package/frontend/dist/assets/{Pagination-Dwko3g48.js.map → Pagination-CLUvn47x.js.map} +1 -1
  98. package/frontend/dist/assets/{PromptsPage-CJ-wYRAL.js → PromptsPage-DGcNS3fO.js} +2 -2
  99. package/frontend/dist/assets/{PromptsPage-CJ-wYRAL.js.map → PromptsPage-DGcNS3fO.js.map} +1 -1
  100. package/frontend/dist/assets/{ResourcesPage-DRV8gnZV.js → ResourcesPage-CfyZoadu.js} +2 -2
  101. package/frontend/dist/assets/{ResourcesPage-DRV8gnZV.js.map → ResourcesPage-CfyZoadu.js.map} +1 -1
  102. package/frontend/dist/assets/ServersPage-BlC0RdIu.js +39 -0
  103. package/frontend/dist/assets/ServersPage-BlC0RdIu.js.map +1 -0
  104. package/frontend/dist/assets/{SettingsPage-Czv4OhtK.js → SettingsPage-CiVNDyr_.js} +2 -2
  105. package/frontend/dist/assets/{SettingsPage-Czv4OhtK.js.map → SettingsPage-CiVNDyr_.js.map} +1 -1
  106. package/frontend/dist/assets/{StatusDot-CwpmIlJi.js → StatusDot-DYO56shE.js} +2 -2
  107. package/frontend/dist/assets/{StatusDot-CwpmIlJi.js.map → StatusDot-DYO56shE.js.map} +1 -1
  108. package/frontend/dist/assets/{ToggleGroup-1qFTkDqh.js → ToggleGroup-r8yGt_Fq.js} +2 -2
  109. package/frontend/dist/assets/{ToggleGroup-1qFTkDqh.js.map → ToggleGroup-r8yGt_Fq.js.map} +1 -1
  110. package/frontend/dist/assets/{UsersPage-CAMXgywh.js → UsersPage-B3muXE90.js} +2 -2
  111. package/frontend/dist/assets/{UsersPage-CAMXgywh.js.map → UsersPage-B3muXE90.js.map} +1 -1
  112. package/frontend/dist/assets/{framework-vendor-BHAQX05P.js → framework-vendor-_YL27Pfc.js} +2 -2
  113. package/frontend/dist/assets/{framework-vendor-BHAQX05P.js.map → framework-vendor-_YL27Pfc.js.map} +1 -1
  114. package/frontend/dist/assets/{i18n-vendor-CMcB7XUR.js → i18n-vendor-BMaj5qV8.js} +2 -2
  115. package/frontend/dist/assets/{i18n-vendor-CMcB7XUR.js.map → i18n-vendor-BMaj5qV8.js.map} +1 -1
  116. package/frontend/dist/assets/{icons-vendor-HZHHWeTa.js → icons-vendor-VW-UwEhw.js} +3 -3
  117. package/frontend/dist/assets/{icons-vendor-HZHHWeTa.js.map → icons-vendor-VW-UwEhw.js.map} +1 -1
  118. package/frontend/dist/assets/index-B-aT0HW5.js +3 -0
  119. package/frontend/dist/assets/index-B-aT0HW5.js.map +1 -0
  120. package/frontend/dist/assets/{index-DtrCVU1h.css → index-B3OqAhGz.css} +1 -1
  121. package/frontend/dist/assets/{resourceService-BTVgor9F.js → resourceService-CSXOSi7M.js} +2 -2
  122. package/frontend/dist/assets/{resourceService-BTVgor9F.js.map → resourceService-CSXOSi7M.js.map} +1 -1
  123. package/frontend/dist/assets/{useCostData-CDVGUx_e.js → useCostData-BOxUFQAH.js} +2 -2
  124. package/frontend/dist/assets/{useCostData-CDVGUx_e.js.map → useCostData-BOxUFQAH.js.map} +1 -1
  125. package/frontend/dist/assets/useSettingsData-DmpLlRI6.js +2 -0
  126. package/frontend/dist/assets/{useSettingsData-92nglN_X.js.map → useSettingsData-DmpLlRI6.js.map} +1 -1
  127. package/frontend/dist/assets/variableDetection-cmwwuSWB.js +16 -0
  128. package/frontend/dist/assets/variableDetection-cmwwuSWB.js.map +1 -0
  129. package/frontend/dist/index.html +5 -5
  130. package/package.json +4 -5
  131. package/frontend/dist/assets/GroupsPage-BgUHjkGb.js +0 -33
  132. package/frontend/dist/assets/GroupsPage-BgUHjkGb.js.map +0 -1
  133. package/frontend/dist/assets/ServersPage-CbtcAcVH.js +0 -39
  134. package/frontend/dist/assets/ServersPage-CbtcAcVH.js.map +0 -1
  135. package/frontend/dist/assets/index-Cb6IBpZR.js +0 -3
  136. package/frontend/dist/assets/index-Cb6IBpZR.js.map +0 -1
  137. package/frontend/dist/assets/useSettingsData-92nglN_X.js +0 -2
  138. package/frontend/dist/assets/variableDetection-BlOwsGsz.js +0 -16
  139. package/frontend/dist/assets/variableDetection-BlOwsGsz.js.map +0 -1
@@ -1,39 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./resourceService-BTVgor9F.js","./index-Cb6IBpZR.js","./framework-vendor-BHAQX05P.js","./i18n-vendor-CMcB7XUR.js","./icons-vendor-HZHHWeTa.js","./index-DtrCVU1h.css"])))=>i.map(i=>d[i]);
2
- import{r as u,j as e,d as Ds}from"./framework-vendor-BHAQX05P.js";import{e as le,f as ts,h as ve,i as Pe,u as Ps,_ as ge,j as zs,k as Ts,l as $s}from"./index-Cb6IBpZR.js";import{f as ie}from"./contextCost-CilWqGWT.js";import{S as Is}from"./StatusDot-CwpmIlJi.js";import{u as ze}from"./useSettingsData-92nglN_X.js";import{S as Ne}from"./ToggleGroup-1qFTkDqh.js";import{u as te}from"./i18n-vendor-CMcB7XUR.js";import{n as rs,o as ns,l as we,p as Fs,C as xe,q as ye,r as Te,s as as,t as os,u as $e,m as ke,W as Rs,g as Os,F as _s,X as Ee,v as As,w as Ms,R as je,x as Vs,L as Js,T as Us,P as Bs,y as Ls,z as Ws,D as qs}from"./icons-vendor-HZHHWeTa.js";import{g as Ks}from"./toolDescription-Dw3sa28K.js";import{D as Hs}from"./DeleteDialog-D9ycSRvn.js";import{C as De}from"./ConfirmDialog-3APts2Y9.js";import{S as is,d as Gs}from"./variableDetection-BlOwsGsz.js";import{P as Ys}from"./Pagination-Dwko3g48.js";import{u as Xs,a as Zs}from"./useCostData-CDVGUx_e.js";const ls=async(s,n)=>{try{const t=n?`/tools/${encodeURIComponent(n)}/${encodeURIComponent(s.toolName)}`:"/tools/call",a=await le(t,s.arguments,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return a.success===!1?{success:!1,error:a.message||"Tool call failed"}:{success:!0,content:(a==null?void 0:a.content)||[]}}catch(t){return console.error("Error calling tool",{toolName:s.toolName,server:n,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},Qs=async(s,n,t)=>{try{const a=await le(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(n)}/toggle`,{enabled:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:a.success,error:a.success?void 0:a.message}}catch(a){return console.error("Error toggling tool",{serverName:s,toolName:n,enabled:t,error:a}),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}},cs=async(s,n,t)=>{try{const a=await ve(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(n)}/description`,{description:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:a.success,error:a.success?void 0:a.message}}catch(a){return console.error("Error updating tool description",{serverName:s,toolName:n,error:a}),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}},ds=async(s,n)=>{var t;try{const a=await ts(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(n)}/description`,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:a.success,error:a.success?void 0:a.message,description:(t=a.data)==null?void 0:t.description}}catch(a){return console.error("Error resetting tool description",{serverName:s,toolName:n,error:a}),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}},et=Object.freeze(Object.defineProperty({__proto__:null,callTool:ls,resetToolDescription:ds,toggleTool:Qs,updateToolDescription:cs},Symbol.toStringTag,{value:"Module"})),us=({schema:s,onSubmit:n,onCancel:t,loading:a=!1,storageKey:x,title:d})=>{const{t:o}=te(),[y,N]=u.useState({}),[D,r]=u.useState({}),[p,$]=u.useState(!1),[g,F]=u.useState(""),[k,E]=u.useState(""),w=u.useMemo(()=>(m=>{const j=l=>{if(typeof l=="object"&&l!==null){const h=l;return{type:h.type||"string",description:h.description,enum:h.enum,default:h.default,properties:h.properties?Object.fromEntries(Object.entries(h.properties).map(([c,v])=>[c,j(v)])):void 0,required:h.required,items:h.items?j(h.items):void 0}}return{type:"string"}};return{type:m.type,properties:m.properties?Object.fromEntries(Object.entries(m.properties).map(([l,h])=>[l,j(h)])):void 0,required:m.required}})(s),[s]);u.useEffect(()=>{const b=(j,l="")=>{const h={};return j.type==="object"&&j.properties&&Object.entries(j.properties).forEach(([c,v])=>{const P=l?`${l}.${c}`:c;v.default!==void 0?h[c]=v.default:v.type==="string"?h[c]="":v.type==="number"||v.type==="integer"?h[c]=0:v.type==="boolean"?h[c]=!1:v.type==="array"?h[c]=[]:v.type==="object"&&(v.properties?h[c]=b(v,P):h[c]={})}),h};let m=b(w);if(x)try{const j=localStorage.getItem(x);if(j){const l=JSON.parse(j);m={...m,...l}}}catch(j){console.warn("Failed to load saved form data:",j)}N(m)},[w,x]),u.useEffect(()=>{p&&Object.keys(y).length>0&&(F(JSON.stringify(y,null,2)),E(""))},[p,y]);const R=b=>{F(b),E("");try{const m=JSON.parse(b);if(N(m),x)try{localStorage.setItem(x,JSON.stringify(m))}catch(j){console.warn("Failed to save form data to localStorage:",j)}}catch{E(o("tool.invalidJsonFormat"))}},_=()=>{F(JSON.stringify(y,null,2)),E(""),$(!0)},W=()=>{if(g.trim())try{const b=JSON.parse(g);N(b),E(""),$(!1)}catch{E(o("tool.fixJsonBeforeSwitching"));return}else $(!1)},O=(b,m)=>{N(j=>{const l={...j},h=b.split(".");let c=l;for(let P=0;P<h.length-1;P++){const T=h[P];if(T==="__proto__"||T==="constructor"||T==="prototype")return j;c[T]||(c[T]={}),c=c[T]}const v=h[h.length-1];if(!v||v==="__proto__"||v==="constructor"||v==="prototype")return j;if(c[v]=m,x)try{localStorage.setItem(x,JSON.stringify(l))}catch(P){console.warn("Failed to save form data to localStorage:",P)}return l}),D[b]&&r(j=>{const l={...j};return delete l[b],l})},B=()=>{const b={},m=(j,l,h="")=>{j.type==="object"&&j.properties&&Object.entries(j.properties).forEach(([c,v])=>{var A;const P=h?`${h}.${c}`:c,T=l==null?void 0:l[c];if((A=j.required)!=null&&A.includes(c)&&(T==null||T===""||Array.isArray(T)&&T.length===0)){b[P]=`${c} is required`;return}T!=null&&T!==""&&(v.type==="string"&&typeof T!="string"?b[P]=`${c} must be a string`:v.type==="number"&&typeof T!="number"?b[P]=`${c} must be a number`:v.type==="integer"&&(!Number.isInteger(T)||typeof T!="number")?b[P]=`${c} must be an integer`:v.type==="boolean"&&typeof T!="boolean"?b[P]=`${c} must be a boolean`:v.type==="array"&&Array.isArray(T)?v.items&&T.forEach((L,Q)=>{var M;((M=v.items)==null?void 0:M.type)==="object"&&v.items.properties&&m(v.items,L,`${P}.${Q}`)}):v.type==="object"&&typeof T=="object"&&m(v,T,P))})};return m(w,y),r(b),Object.keys(b).length===0},I=b=>{b.preventDefault(),B()&&n(y)},H=(b,m)=>m.split(".").reduce((j,l)=>j==null?void 0:j[l],b),q=(b,m,j,l)=>{const h=j==null?void 0:j[b];return m.type==="string"?m.enum?e.jsxs("select",{value:h||"",onChange:c=>l(c.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:o("tool.selectOption")}),m.enum.map((c,v)=>e.jsx("option",{value:c,children:c},v))]}):e.jsx("input",{type:"text",value:h||"",onChange:c=>l(c.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:m.description||o("tool.enterKey",{key:b})}):m.type==="number"||m.type==="integer"?e.jsx("input",{type:"number",step:m.type==="integer"?"1":"any",value:h??"",onChange:c=>{const v=c.target.value===""?"":m.type==="integer"?parseInt(c.target.value):parseFloat(c.target.value);l(v)},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"}):m.type==="boolean"?e.jsx("input",{type:"checkbox",checked:h||!1,onChange:c=>l(c.target.checked),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}):e.jsx("input",{type:"text",value:h||"",onChange:c=>l(c.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:m.description||o("tool.enterKey",{key:b})})},Y=(b,m,j="")=>{var v,P,T,A,L,Q,M,S,U,ee,oe,z,K,ce;const l=j?`${j}.${b}`:b,h=H(y,l),c=D[l];if(m.type==="array"){const V=H(y,l)||[];return e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[b,(j?(P=(v=H(w,j))==null?void 0:v.required)==null?void 0:P.includes(b):(T=w.required)==null?void 0:T.includes(b))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),m.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:m.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:[V.map((Z,se)=>{var he,ae,G;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:o("tool.item",{index:se+1})}),e.jsx("button",{type:"button",onClick:()=>{const X=[...V];X.splice(se,1),O(l,X)},className:"text-status-red hover:text-red-700 text-sm",children:o("common.remove")})]}),((he=m.items)==null?void 0:he.type)==="string"&&m.items.enum?e.jsxs("select",{value:Z||"",onChange:X=>{const re=[...V];re[se]=X.target.value,O(l,re)},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:o("tool.selectOption")}),m.items.enum.map((X,re)=>e.jsx("option",{value:X,children:X},re))]}):((ae=m.items)==null?void 0:ae.type)==="object"&&m.items.properties?e.jsx("div",{className:"space-y-3",children:Object.entries(m.items.properties).map(([X,re])=>{var be,fe;return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:[X,((fe=(be=m.items)==null?void 0:be.required)==null?void 0:fe.includes(X))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),q(X,re,Z,Ce=>{const pe=[...V];pe[se]={...pe[se],[X]:Ce},O(l,pe)})]},X)})}):e.jsx("input",{type:"text",value:Z||"",onChange:X=>{const re=[...V];re[se]=X.target.value,O(l,re)},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:o("tool.enterValue",{type:((G=m.items)==null?void 0:G.type)||"value"})})]},se)}),e.jsx("button",{type:"button",onClick:()=>{var se;const Z=((se=m.items)==null?void 0:se.type)==="object"?{}:"";O(l,[...V,Z])},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:o("tool.addItem",{key:b})})]}),c&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:c})]},l)}return m.type==="object"?m.properties?e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[b,(j?(L=(A=H(w,j))==null?void 0:A.required)==null?void 0:L.includes(b):(Q=w.required)==null?void 0:Q.includes(b))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),m.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:m.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(m.properties).map(([V,Z])=>Y(V,Z,l))}),c&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:c})]},l):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[b,(j?(S=(M=H(w,j))==null?void 0:M.required)==null?void 0:S.includes(b):(U=w.required)==null?void 0:U.includes(b))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"}),e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(JSON object)"})]}),m.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:m.description}),e.jsx("textarea",{value:typeof h=="object"?JSON.stringify(h,null,2):h||"{}",onChange:V=>{try{const Z=JSON.parse(V.target.value);O(l,Z)}catch{O(l,V.target.value)}},placeholder:`{
3
- "key": "value"
4
- }`,className:`w-full border rounded-md px-3 py-2 font-mono text-sm ${c?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`,rows:4}),c&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:c})]},l):m.type==="string"?m.enum?e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[b,(j?!1:(ee=w.required)==null?void 0:ee.includes(b))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),m.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:m.description}),e.jsxs("select",{value:h||"",onChange:V=>O(l,V.target.value),className:`w-full border rounded-md px-3 py-2 ${c?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[e.jsx("option",{value:"",children:o("tool.selectOption")}),m.enum.map((V,Z)=>e.jsx("option",{value:V,children:V},Z))]}),c&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:c})]},l):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[b,(j?!1:(oe=w.required)==null?void 0:oe.includes(b))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),m.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:m.description}),e.jsx("input",{type:"text",value:h||"",onChange:V=>O(l,V.target.value),className:`w-full border rounded-md px-3 py-2 ${c?"border-red":"border-gray-200"} focus:outline-none form-input`}),c&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:c})]},l):m.type==="number"||m.type==="integer"?e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[b,(j?!1:(z=w.required)==null?void 0:z.includes(b))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),m.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:m.description}),e.jsx("input",{type:"number",step:m.type==="integer"?"1":"any",value:h??"",onChange:V=>{const Z=V.target.value===""?"":m.type==="integer"?parseInt(V.target.value):parseFloat(V.target.value);O(l,Z)},className:`w-full border rounded-md px-3 py-2 form-input ${c?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`}),c&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:c})]},l):m.type==="boolean"?e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",checked:h||!1,onChange:V=>O(l,V.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:[b,(j?!1:(K=w.required)==null?void 0:K.includes(b))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]})]}),m.description&&e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:m.description}),c&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:c})]},l):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[b,(j?!1:(ce=w.required)==null?void 0:ce.includes(b))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"}),e.jsxs("span",{className:"text-xs text-gray-500 ml-1",children:["(",m.type,")"]})]}),m.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:m.description}),e.jsx("input",{type:"text",value:h||"",onChange:V=>O(l,V.target.value),placeholder:o("tool.enterValue",{type:m.type}),className:`w-full border rounded-md px-3 py-2 ${c?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500 form-input`}),c&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:c})]},l)};return w.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:d}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("button",{type:"button",onClick:W,className:`hub-btn sm ${p?"":"primary"}`,children:o("tool.formMode")}),e.jsx("button",{type:"button",onClick:_,className:`hub-btn sm ${p?"primary":""}`,children:o("tool.jsonMode")})]})]}),p?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:o("tool.jsonConfiguration")}),e.jsx("textarea",{value:g,onChange:b=>R(b.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 ${k?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`}),k&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:k})]}),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:o("tool.cancel")}),e.jsx("button",{onClick:()=>{try{const b=JSON.parse(g);n(b)}catch{E(o("tool.invalidJsonFormat"))}},disabled:a||!!k,className:"hub-btn sm primary",children:o(a?"tool.running":"tool.runTool")})]})]}):e.jsxs("form",{onSubmit:I,className:"space-y-4",children:[Object.entries(w.properties||{}).map(([b,m])=>Y(b,m)),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:o("tool.cancel")}),e.jsx("button",{type:"submit",disabled:a,className:"hub-btn sm primary",children:o(a?"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:o("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:o("tool.cancel")}),e.jsx("button",{onClick:()=>n({}),disabled:a,className:"hub-btn primary",children:o(a?"tool.running":"tool.runTool")})]})]})},st=({result:s,onClose:n})=>{const{t}=te(),a=s.content,x=r=>r?r.startsWith("image/")?r:`image/${r}`:"image/png",d=r=>{if(!r)return[];if(Array.isArray(r))return r.flatMap(g=>d(g));if(typeof r!="object")return[];const p=[];r.type==="image"&&r.data&&p.push({data:String(r.data),mimeType:x(r.mimeType||r.mime_type)});const $=r.image_base64||r.imageBase64||r.image_data||r.imageData||r.base64;return $&&p.push({data:String($),mimeType:x(r.image_mimeType||r.image_mime_type||r.mimeType||r.mime_type)}),r.image&&typeof r.image=="object"&&p.push(...d(r.image)),Array.isArray(r.images)&&p.push(...d(r.images)),Array.isArray(r.content)&&p.push(...d(r.content)),p},o=r=>{const p=[];try{const F=JSON.parse(r);if(p.push(...d(F)),p.length>0)return p}catch{}const $=/data:image\/(png|jpe?g|gif|webp);base64,([A-Za-z0-9+/=]+)/g;let g;for(;(g=$.exec(r))!==null;){const F=`image/${g[1]==="jpg"?"jpeg":g[1]}`;p.push({data:g[2],mimeType:F})}return p},y=r=>{try{const p=JSON.parse(r),$=g=>{if(Array.isArray(g))return g.map($);if(g&&typeof g=="object"){const F={};for(const[k,E]of Object.entries(g))typeof E=="string"&&k.toLowerCase().includes("base64")?F[k]="[base64 omitted]":F[k]=$(E);return F}return g};return JSON.stringify($(p),null,2)}catch{return r.replace(/data:image\/(png|jpe?g|gif|webp);base64,[A-Za-z0-9+/=]+/g,"[image data omitted]")}},N=r=>Array.isArray(r)?r.map((p,$)=>e.jsx("div",{className:"mb-3 last:mb-0",children:D(p)},$)):D(r),D=r=>{if(typeof r=="string"){const p=o(r),$=y(r);return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[p.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:p.map((g,F)=>e.jsx("img",{src:`data:${g.mimeType||"image/png"};base64,${g.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:$})]})}if(typeof r=="object"&&r!==null){if(r.type==="text"&&r.text){const p=o(r.text),$=y(r.text);return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[p.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:p.map((g,F)=>e.jsx("img",{src:`data:${g.mimeType||"image/png"};base64,${g.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:$})]})}if(r.type==="image"&&r.data)return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("img",{src:`data:${r.mimeType||"image/png"};base64,${r.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"})});try{const p=typeof r=="string"?JSON.parse(r):r;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(p,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(r)})})}}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(r)})})};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(rs,{size:20,className:"text-status-green"}):e.jsx(ns,{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:n,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")}),N(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(we,{size:16,className:"text-red-500"}),e.jsx("span",{className:"text-sm font-medium text-red-700",children:t("tool.error")})]}),a&&a.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:t("tool.errorDetails")}),N(a)]}):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")})})]})})]})},me=({title:s,onClick:n,disabled:t=!1,loading:a=!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:n,disabled:t,title:s,"aria-label":s,children:e.jsx(Fs,{size:14,className:a?"animate-spin":""})});function tt(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 rt=({tool:s,server:n,readOnly:t=!1,onToggle:a,onDescriptionUpdate:x,cost:d})=>{const{t:o}=te(),{showToast:y}=Pe(),{nameSeparator:N}=ze(),[D,r]=u.useState(!1),[p,$]=u.useState(!1),[g,F]=u.useState(!1),[k,E]=u.useState(null),[w,R]=u.useState(!1),[_,W]=u.useState(!1),[O,B]=u.useState(s.description||""),I=u.useRef(null),H=u.useRef(null),[q,Y]=u.useState(0),[b,m]=u.useState(!1);u.useEffect(()=>{w&&I.current&&(I.current.focus(),q>0&&(I.current.style.width=`${q+20}px`))},[w,q]),u.useEffect(()=>{!w&&H.current&&Y(H.current.offsetWidth)},[w,O]),u.useEffect(()=>{B(s.description||"")},[s.description]);const j=s.name.replace(n+N,""),l=Ks(s,o("tool.noDescription")),h=l.hasDescriptionOverride?o("tool.defaultDescriptionTooltip",{description:l.defaultDescription}):void 0,c=u.useCallback(()=>`mcphub_tool_form_${n?`${n}_`:""}${s.name}`,[s.name,n]),v=u.useCallback(()=>{localStorage.removeItem(c())},[c]),P=z=>{!t&&a&&a(s.name,z)},T=()=>{t||R(!0)},A=async()=>{if(!t)try{const z=await cs(n,s.name,O);z.success?(R(!1),x&&x(s.name,O)):(B(s.description||""),console.error("Failed to update tool description:",z.error))}catch(z){console.error("Error updating tool description:",z),B(s.description||""),R(!1)}},L=z=>{B(z.target.value)},Q=async()=>{if(!t){W(!0);try{const z=await ds(n,s.name);if(z.success){const K=z.description||"";B(K),R(!1),x==null||x(s.name,K,{restored:!0})}else y(z.error||o("tool.restoreDefaultFailed"),"error")}catch(z){console.error("Error resetting tool description:",z),y(o("tool.restoreDefaultFailed"),"error")}finally{W(!1)}}},M=z=>{z.key==="Enter"?A():z.key==="Escape"&&(B(s.description||""),R(!1))},S=async z=>{z.stopPropagation();try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(s.name),m(!0),y(o("common.copySuccess"),"success"),setTimeout(()=>m(!1),2e3);else{const K=document.createElement("textarea");K.value=s.name,K.style.position="fixed",K.style.left="-9999px",document.body.appendChild(K),K.focus(),K.select();try{document.execCommand("copy"),m(!0),y(o("common.copySuccess"),"success"),setTimeout(()=>m(!1),2e3)}catch(ce){y(o("common.copyFailed"),"error"),console.error("Copy to clipboard failed:",ce)}document.body.removeChild(K)}}catch(K){y(o("common.copyFailed"),"error"),console.error("Copy to clipboard failed:",K)}},U=async z=>{F(!0);try{z=Object.fromEntries(Object.entries(z).filter(([ce,V])=>!tt(V)));const K=await ls({toolName:s.name,arguments:z},n);E(K)}catch(K){E({success:!1,error:K instanceof Error?K.message:"Unknown error occurred"})}finally{F(!1)}},ee=()=>{$(!1),v(),E(null)},oe=()=>{E(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:z=>{z.stopPropagation(),r(!D)},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:j}),e.jsx("button",{className:"hub-icon-btn sm",onClick:S,title:o("common.copy"),children:b?e.jsx(xe,{size:12,style:{color:"var(--hub-ok)"}}):e.jsx(ye,{size:12})}),e.jsx("span",{className:"flex items-center gap-1",style:{fontSize:12,color:"var(--hub-ink-3)"},children:w?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:I,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:q>0?`${q+20}px`:160,minWidth:80},value:O,onChange:L,onKeyDown:M,onClick:z=>z.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:z=>{z.stopPropagation(),A()},disabled:_,children:e.jsx(xe,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(me,{title:o("tool.restoreDefault"),onClick:z=>{z.stopPropagation(),Q()},disabled:_,loading:_})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:H,title:h,children:l.currentDescription}),l.hasDescriptionOverride&&e.jsx("span",{className:"inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium",style:{color:"var(--hub-accent)",borderColor:"var(--hub-line)",background:"var(--hub-bg-2)"},title:h,children:o("tool.descriptionModifiedBadge")}),!t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"hub-icon-btn sm",onClick:z=>{z.stopPropagation(),T()},children:e.jsx(Te,{size:12})}),e.jsx(me,{title:o("tool.restoreDefault"),onClick:z=>{z.stopPropagation(),Q()},disabled:_,loading:_})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[d!=null&&e.jsxs("span",{className:"hub-mono flex-shrink-0",style:{fontSize:11,color:"var(--hub-ink-3)"},title:o("cost.estimate"),children:["Σ ",ie(d)]}),e.jsx("div",{className:"flex h-[26px] items-center",onClick:z=>z.stopPropagation(),children:e.jsx(Ne,{checked:s.enabled??!0,onCheckedChange:P,disabled:g||t,size:"card","aria-label":`${o(s.enabled??!0?"server.disable":"server.enable")} ${j}`})}),e.jsxs("button",{onClick:z=>{z.stopPropagation(),r(!0),$(!0)},className:"hub-btn sm",style:{color:"var(--hub-accent)"},disabled:g||!s.enabled,children:[g?e.jsx(as,{size:12,className:"animate-spin"}):e.jsx(os,{size:12}),e.jsx("span",{children:o(g?"tool.running":"tool.run")})]}),e.jsx("button",{className:"hub-icon-btn sm",children:D?e.jsx($e,{size:14}):e.jsx(ke,{size:14})})]})]}),D&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",padding:"10px 12px",display:"flex",flexDirection:"column",gap:10},children:[l.hasDescriptionOverride&&l.defaultDescription&&e.jsxs("div",{style:{background:"var(--hub-bg-2)",borderRadius:7,padding:"8px 12px",border:"1px dashed var(--hub-line)",fontSize:11.5,color:"var(--hub-ink-3)"},children:[e.jsx("span",{className:"hub-sect",style:{marginRight:6},children:o("tool.defaultDescriptionLabel")}),e.jsx("span",{className:"whitespace-pre-wrap break-words",children:l.defaultDescription})]}),!p&&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:o("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)})]}),p&&e.jsxs("div",{style:{border:"1px solid var(--hub-line)",borderRadius:8,padding:14},children:[e.jsx(us,{schema:s.inputSchema||{type:"object"},onSubmit:U,onCancel:ee,loading:g,storageKey:c(),title:o("tool.runToolWithName",{name:j})}),k&&e.jsx("div",{style:{marginTop:12},children:e.jsx(st,{result:k,onClose:oe})})]})]})]})},nt=async(s,n)=>{try{const t=n?`/prompts/call/${n}`:"/prompts/call",a=await le(t,{promptName:s.promptName,arguments:s.arguments});return a.success?{success:!0,data:a.data}:{success:!1,error:a.message||"Prompt call failed"}}catch(t){return console.error("Error calling prompt",{promptName:s.promptName,server:n,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},ms=async(s,n)=>{try{const t=await le(`/mcp/${encodeURIComponent(n||"")}/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:n,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},at=async(s,n,t)=>{try{const a=await le(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(n)}/toggle`,{enabled:t});return{success:a.success,error:a.success?void 0:a.message}}catch(a){return console.error("Error toggling prompt",{serverName:s,promptName:n,enabled:t,error:a}),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}},ps=async(s,n,t)=>{try{const a=await ve(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(n)}/description`,{description:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:a.success,error:a.success?void 0:a.message}}catch(a){return console.error("Error updating prompt description",{serverName:s,promptName:n,error:a}),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}},xs=async(s,n)=>{var t;try{const a=await ts(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(n)}/description`,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:a.success,error:a.success?void 0:a.message,description:(t=a.data)==null?void 0:t.description}}catch(a){return console.error("Error resetting prompt description",{serverName:s,promptName:n,error:a}),{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}},ot=Object.freeze(Object.defineProperty({__proto__:null,callPrompt:nt,getPrompt:ms,resetPromptDescription:xs,togglePrompt:at,updatePromptDescription:ps},Symbol.toStringTag,{value:"Module"})),Xe=({result:s,onClose:n})=>{const{t}=te(),a=x=>{if(typeof x=="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:x})});if(typeof x=="object"&&x!==null){if(x.description||x.messages)return e.jsxs("div",{className:"space-y-4",children:[x.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:x.description})})]}),x.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:x.messages.map((d,o)=>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:[d.role,":"]})}),typeof d.content=="string"?e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:d.content}):typeof d.content=="object"&&d.content.type==="text"?e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:d.content.text}):e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(d.content,null,2)})]},o))})]})]});try{const d=typeof x=="string"?JSON.parse(x):x;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(d,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(x)})})}}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(x)})})};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(rs,{size:20,className:"text-status-green"}):e.jsx(ns,{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:n,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")}),a(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(we,{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")})})]})})]})},it=({prompt:s,server:n,readOnly:t=!1,onToggle:a,onDescriptionUpdate:x,cost:d})=>{const{t:o}=te(),{showToast:y}=Pe(),{nameSeparator:N}=ze(),[D,r]=u.useState(!1),[p,$]=u.useState(!1),[g,F]=u.useState(!1),[k,E]=u.useState(null),[w,R]=u.useState(!1),[_,W]=u.useState(!1),[O,B]=u.useState(s.description||""),I=u.useRef(null),H=u.useRef(null),[q,Y]=u.useState(0);u.useEffect(()=>{w&&I.current&&(I.current.focus(),q>0&&(I.current.style.width=`${q+20}px`))},[w,q]),u.useEffect(()=>{!w&&H.current&&Y(H.current.offsetWidth)},[w,O]),u.useEffect(()=>{B(s.description||"")},[s.description]);const b=u.useCallback(()=>`mcphub_prompt_form_${n?`${n}_`:""}${s.name}`,[s.name,n]),m=u.useCallback(()=>{localStorage.removeItem(b())},[b]),j=S=>{!t&&a&&a(s.name,S)},l=()=>{t||R(!0)},h=async()=>{if(!t){R(!1);try{const S=await ps(n,s.name,O);S.success?x&&x(s.name,O):(y(S.error||o("prompt.descriptionUpdateFailed"),"error"),B(s.description||""))}catch(S){console.error("Error updating prompt description:",S),y(o("prompt.descriptionUpdateFailed"),"error"),B(s.description||"")}}},c=async()=>{if(!t){W(!0);try{const S=await xs(n,s.name);if(S.success){const U=S.description||"";B(U),R(!1),x==null||x(s.name,U,{restored:!0})}else y(S.error||o("prompt.restoreDefaultFailed"),"error")}catch(S){console.error("Error resetting prompt description:",S),y(o("prompt.restoreDefaultFailed"),"error")}finally{W(!1)}}},v=S=>{B(S.target.value)},P=S=>{S.key==="Enter"?h():S.key==="Escape"&&(B(s.description||""),R(!1))},T=async S=>{F(!0);try{const U=await ms({promptName:s.name,arguments:S},n);console.log("GetPrompt result:",U),E({success:U.success,data:U.data,error:U.error})}catch(U){E({success:!1,error:U instanceof Error?U.message:"Unknown error occurred"})}finally{F(!1)}},A=()=>{$(!1),m(),E(null)},L=()=>{E(null)},Q=s.name.replace(n+N,""),M=()=>{if(!s.arguments||s.arguments.length===0)return{type:"object",properties:{},required:[]};const S={},U=[];return s.arguments.forEach(ee=>{S[ee.name]={type:"string",description:ee.description||""},ee.required&&U.push(ee.name)}),{type:"object",properties:S,required:U}};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:()=>r(!D),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:Q}),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:w?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:I,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:q>0?`${q+20}px`:160,minWidth:80},value:O,onChange:v,onKeyDown:P,onClick:S=>S.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:S=>{S.stopPropagation(),h()},disabled:_,children:e.jsx(xe,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(me,{title:o("prompt.restoreDefault"),onClick:S=>{S.stopPropagation(),c()},disabled:_,loading:_})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:H,children:O||o("tool.noDescription")}),!t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"hub-icon-btn sm",onClick:S=>{S.stopPropagation(),l()},children:e.jsx(Te,{size:12})}),e.jsx(me,{title:o("prompt.restoreDefault"),onClick:S=>{S.stopPropagation(),c()},disabled:_,loading:_})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[d!=null&&e.jsxs("span",{className:"hub-mono flex-shrink-0",style:{fontSize:11,color:"var(--hub-ink-3)"},title:o("cost.estimate"),children:["Σ ",ie(d)]}),e.jsx("div",{className:"flex h-[26px] items-center",onClick:S=>S.stopPropagation(),children:s.enabled!==void 0&&e.jsx(Ne,{checked:s.enabled,onCheckedChange:j,disabled:g||t,size:"card","aria-label":`${o(s.enabled?"server.disable":"server.enable")} ${Q}`})}),e.jsxs("button",{onClick:S=>{S.stopPropagation(),r(!0),$(!0)},className:"hub-btn sm",style:{color:"var(--hub-accent)"},disabled:g||!s.enabled,children:[g?e.jsx(as,{size:12,className:"animate-spin"}):e.jsx(os,{size:12}),e.jsx("span",{children:o(g?"tool.running":"tool.run")})]}),e.jsx("button",{className:"hub-icon-btn sm",children:D?e.jsx($e,{size:14}):e.jsx(ke,{size:14})})]})]}),D&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",padding:"10px 12px",display:"flex",flexDirection:"column",gap:10},children:[p&&e.jsxs("div",{style:{border:"1px solid var(--hub-line)",borderRadius:8,padding:14},children:[e.jsx(us,{schema:M(),onSubmit:T,onCancel:A,loading:g,storageKey:b(),title:o("prompt.runPromptWithName",{name:Q})}),k&&e.jsx("div",{style:{marginTop:12},children:e.jsx(Xe,{result:k,onClose:L})})]}),!p&&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:o("tool.parameters")}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:s.arguments.map((S,U)=>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:S.name}),S.required&&e.jsx("span",{style:{color:"var(--hub-err)",fontSize:12},children:"*"})]}),S.description&&e.jsx("p",{style:{fontSize:12,color:"var(--hub-ink-3)",margin:"2px 0 0"},children:S.description})]}),S.title&&e.jsx("span",{style:{fontSize:11,color:"var(--hub-ink-3)"},children:S.title})]},U))})]}),!p&&k&&e.jsx("div",{children:e.jsx(Xe,{result:k,onClose:L})})]})]})},lt=({resource:s,readOnly:n=!1,onToggle:t,onDescriptionUpdate:a,cost:x})=>{const{t:d}=te(),[o,y]=u.useState(!1),[N,D]=u.useState(!1),[r,p]=u.useState(!1),[$,g]=u.useState(s.description||""),F=u.useRef(null),k=u.useRef(null),[E,w]=u.useState(0);u.useEffect(()=>{N&&F.current&&(F.current.focus(),E>0&&(F.current.style.width=`${E+20}px`))},[N,E]),u.useEffect(()=>{!N&&k.current&&w(k.current.offsetWidth)},[N,$]),u.useEffect(()=>{g(s.description||"")},[s.description]);const R=s.name||s.uri,_=I=>{!n&&t&&t(s.uri,I)},W=async()=>{n||(D(!1),a&&await a(s.uri,$))},O=async()=>{if(!n){p(!0);try{await(a==null?void 0:a(s.uri,"",{restored:!0})),D(!1)}finally{p(!1)}}},B=I=>{I.key==="Enter"?W():I.key==="Escape"&&(g(s.description||""),D(!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:()=>y(!o),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:R}),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:N?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:F,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:E>0?`${E+20}px`:160,minWidth:80},value:$,onChange:I=>g(I.target.value),onKeyDown:B,onClick:I=>I.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:I=>{I.stopPropagation(),W()},disabled:r,children:e.jsx(xe,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(me,{title:d("builtinResources.restoreDefault"),onClick:I=>{I.stopPropagation(),O()},disabled:r,loading:r})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:k,children:$||d("tool.noDescription")}),!n&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"hub-icon-btn sm",onClick:I=>{I.stopPropagation(),D(!0)},children:e.jsx(Te,{size:12})}),e.jsx(me,{title:d("builtinResources.restoreDefault"),onClick:I=>{I.stopPropagation(),O()},disabled:r,loading:r})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[x!=null&&e.jsxs("span",{className:"hub-mono flex-shrink-0",style:{fontSize:11,color:"var(--hub-ink-3)"},title:d("cost.estimate"),children:["Σ ",ie(x)]}),e.jsx("div",{className:"flex h-[26px] items-center",onClick:I=>I.stopPropagation(),children:e.jsx(Ne,{checked:s.enabled!==!1,onCheckedChange:_,disabled:n,size:"card","aria-label":`${d(s.enabled!==!1?"server.disable":"server.enable")} ${R}`})}),e.jsx("button",{className:"hub-icon-btn sm",children:o?e.jsx($e,{size:14}):e.jsx(ke,{size:14})})]})]}),o&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",padding:"8px 12px"},children:[e.jsxs("span",{className:"hub-sect",children:[d("builtinResources.mimeType"),":"]})," ",e.jsx("span",{style:{fontSize:12,color:"var(--hub-ink-2)"},children:s.mimeType||"text/plain"})]})]})},ct=(s,n)=>n?n.isAdmin?!0:!!(s.owner&&s.owner===n.username):!1,dt={private:{shortKey:"server.visibilityPrivateShort",shortFallback:"Private",longKey:"server.visibilityPrivate",longFallback:"Private — only the owner and admins",className:"bg-[var(--hub-bg-2)] text-[var(--hub-ink-2)] border-[var(--hub-line-2)]"},group:{shortKey:"server.visibilityGroupShort",shortFallback:"Shared",longKey:"server.visibilityGroup",longFallback:"Shared — selected users only",className:"bg-[oklch(0.97_0.02_85)] text-[oklch(0.45_0.07_85)] border-[oklch(0.88_0.04_85)]"},public:{shortKey:"server.visibilityPublicShort",shortFallback:"Public",longKey:"server.visibilityPublic",longFallback:"Public — every authenticated user",className:"bg-[oklch(0.97_0.03_145)] text-[oklch(0.42_0.12_145)] border-[oklch(0.88_0.04_145)]"}},Ie=s=>s==="public"||s==="group"?s:"private",ut=(s,n)=>{const t=Ie(n),a=dt[t];return{value:t,shortLabel:s(a.shortKey,{defaultValue:a.shortFallback}),longLabel:s(a.longKey,{defaultValue:a.longFallback}),className:a.className}},mt=(s,n)=>{const t=Ie(n),a=[{value:"private",label:s("server.visibilityPrivateShort",{defaultValue:"Private"}),disabled:!1}];return t==="group"&&a.push({value:"group",label:s("server.visibilityGroupShort",{defaultValue:"Shared"}),disabled:!0}),a.push({value:"public",label:s("server.visibilityPublicShort",{defaultValue:"Public"}),disabled:!1}),a},Ze=({isLoading:s,children:n,className:t,overlayStyle:a,spinnerSize:x=12})=>e.jsxs("div",{className:t?`relative flex items-center ${t}`:"relative flex items-center","aria-busy":s,children:[e.jsx("div",{className:"flex w-full items-center justify-center",style:{visibility:s?"hidden":"visible",pointerEvents:s?"none":"auto"},children:n}),s&&e.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",style:{background:"var(--hub-surface)",border:"1px solid var(--hub-line-2)",borderRadius:8,...a},children:e.jsx(je,{size:x,className:"animate-spin",style:{color:"var(--hub-ink-3)"}})})]}),Qe=({icon:s})=>e.jsx("span",{className:"hub-server-capability-icon","aria-hidden":"true",children:e.jsx(s,{size:11.5,strokeWidth:1.9,className:"block"})}),es=(s,n)=>n?n==="stdio"?s("server.typeStdio")||"stdio":n==="sse"?s("server.typeSse")||"sse":n==="streamable-http"?s("server.typeStreamableHttp")||"http":n==="openapi"?s("server.typeOpenapi")||"openapi":n:null,pt="text/html;profile=mcp-app",ss=s=>s?!!(s.ui||s["ui/resourceUri"]):!1,xt=s=>{var n,t;return!!((n=s.tools)!=null&&n.some(a=>ss(a._meta))||(t=s.resources)!=null&&t.some(a=>{var x;return((x=a.uri)==null?void 0:x.startsWith("ui://"))||a.mimeType===pt||ss(a._meta)}))},ht=({server:s,cost:n,onRemove:t,onEdit:a,onToggle:x,onVisibilityChange:d,onRefresh:o,onReload:y,onReinstall:N,onOAuthDisconnect:D})=>{var _e,Ae,Me,Ve,Je,Ue,Be,Le,We,qe,Ke,He,Ge,Ye;const{t:r}=te(),{showToast:p}=Pe(),{exportMCPSettings:$,installConfig:g}=ze(),{auth:F}=Ps(),k=((_e=g==null?void 0:g.baseUrl)==null?void 0:_e.replace(/\/+$/,""))||"",[E,w]=u.useState(!1),[R,_]=u.useState(null),[W,O]=u.useState(!1),[B,I]=u.useState(!1),[H,q]=u.useState(!1),[Y,b]=u.useState(!1),[m,j]=u.useState(!1),[l,h]=u.useState(!1),[c,v]=u.useState(!1),[P,T]=u.useState(!1),[A,L]=u.useState(!1),[Q,M]=u.useState(!1),[S,U]=u.useState(!1),ee=u.useRef(null),oe=u.useRef(null);u.useEffect(()=>{const i=f=>{ee.current&&!ee.current.contains(f.target)&&L(!1),oe.current&&!oe.current.contains(f.target)&&M(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[]);const z=((Ae=s.tools)==null?void 0:Ae.length)||0,K=((Me=s.tools)==null?void 0:Me.filter(i=>i.enabled!==!1).length)||0,ce=((Ve=s.prompts)==null?void 0:Ve.length)||0,V=((Je=s.prompts)==null?void 0:Je.filter(i=>i.enabled!==!1).length)||0,Z=((Ue=s.resources)==null?void 0:Ue.length)||0,se=((Be=s.resources)==null?void 0:Be.filter(i=>i.enabled!==!1).length)||0,he=xt(s),ae=s.enabled!==!1,G=ct(s,F.user),X=((Le=s.config)==null?void 0:Le.command)==="npx"||((We=s.config)==null?void 0:We.command)==="uvx",re=!!((qe=s.oauth)!=null&&qe.connected&&D),be=async i=>{if(!(!G||Y||!x)){b(!0);try{await x(s,i)}finally{b(!1)}}},fe=async i=>{if(i.stopPropagation(),L(!1),!(!G||l||!y)){h(!0);try{await y(s)?p(r("server.reloadSuccess")||"Server reloaded successfully","success"):p(r("server.reloadError",{serverName:s.name})||"Failed to reload","error")}finally{h(!1)}}},Ce=async()=>{if(L(!1),!(!G||c||!N)){v(!0);try{await N(s)?p(r("server.reinstallSuccess")||"Server reinstall initiated","success"):p(r("server.reinstallError",{serverName:s.name})||"Failed to reinstall","error")}finally{v(!1)}}},pe=async()=>{if(L(!1),!(!G||P||!D)){T(!0);try{await D(s)?p(r("server.disconnectOAuthSuccess")||"Server OAuth disconnected","success"):p(r("server.disconnectOAuthError",{serverName:s.name})||"Failed to disconnect OAuth","error")}finally{T(!1)}}},hs=async i=>{var C;if(i.stopPropagation(),!G||m||!d)return;const f=i.target.value;if(f!==Ie(s.visibility??((C=s.config)==null?void 0:C.visibility))){j(!0);try{await d(s,f)}finally{j(!1)}}},Se=async i=>{try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(i),!0}catch{}try{const f=document.createElement("textarea");f.value=i,f.style.position="fixed",f.style.left="-9999px",document.body.appendChild(f),f.focus(),f.select();const C=document.execCommand("copy");return document.body.removeChild(f),C}catch{return!1}},bs=async i=>{if(i.stopPropagation(),!s.error)return;await Se(s.error)?(U(!0),p(r("common.copySuccess")||"Copied","success"),setTimeout(()=>U(!1),1500)):p(r("common.copyFailed")||"Copy failed","error")},fs=async i=>{if(i.stopPropagation(),L(!1),!!G)try{const f=await $(s.name);if(!f||!f.success||!f.data){p((f==null?void 0:f.message)||r("common.copyFailed")||"Copy failed","error");return}const C=JSON.stringify(f.data,null,2),J=await Se(C);p(J?r("common.copySuccess")||"Copied":r("common.copyFailed")||"Copy failed",J?"success":"error")}catch(f){console.error("Error copying server configuration:",f),p(r("common.copyFailed")||"Copy failed","error")}},gs=i=>{var f;if(i.stopPropagation(),(f=s.oauth)!=null&&f.authorizationUrl){const ne=window.screen.width/2-300,de=window.screen.height/2-700/2;window.open(s.oauth.authorizationUrl,"OAuth Authorization",`width=600,height=700,left=${ne},top=${de}`),p(r("status.oauthWindowOpened"),"info"),s.oauth.clientIdConfigured&&p(r("status.oauthClientIdHint"),"warning")}},ys=async(i,f)=>{try{const{toggleTool:C}=await ge(async()=>{const{toggleTool:ne}=await Promise.resolve().then(()=>et);return{toggleTool:ne}},void 0,import.meta.url),J=await C(s.name,i,f);J.success?(p(r(f?"tool.enableSuccess":"tool.disableSuccess",{name:i}),"success"),o==null||o()):p(J.error||r("tool.toggleFailed"),"error")}catch(C){console.error(C),p(r("tool.toggleFailed"),"error")}},js=async(i,f)=>{try{const{togglePrompt:C}=await ge(async()=>{const{togglePrompt:ne}=await Promise.resolve().then(()=>ot);return{togglePrompt:ne}},void 0,import.meta.url),J=await C(s.name,i,f);J.success?(p(r(f?"tool.enableSuccess":"tool.disableSuccess",{name:i}),"success"),o==null||o()):p(J.error||r("tool.toggleFailed"),"error")}catch(C){console.error(C),p(r("tool.toggleFailed"),"error")}},vs=async(i,f)=>{try{const{toggleResource:C}=await ge(async()=>{const{toggleResource:ne}=await import("./resourceService-BTVgor9F.js");return{toggleResource:ne}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),J=await C(s.name,i,f);J.success?(p(r(f?"tool.enableSuccess":"tool.disableSuccess",{name:i}),"success"),o==null||o()):p(J.error||r("tool.toggleFailed"),"error")}catch(C){console.error(C),p(r("tool.toggleFailed"),"error")}},Ns=(i,f,C)=>{p(C!=null&&C.restored?r("tool.restoreDefaultSuccess"):r("tool.descriptionUpdateSuccess"),"success"),o==null||o()},ws=(i,f,C)=>{p(C!=null&&C.restored?r("prompt.restoreDefaultSuccess"):r("prompt.descriptionUpdateSuccess"),"success"),o==null||o()},ks=async(i,f,C)=>{try{const{updateResourceDescription:J,resetResourceDescription:ne}=await ge(async()=>{const{updateResourceDescription:Ss,resetResourceDescription:Es}=await import("./resourceService-BTVgor9F.js");return{updateResourceDescription:Ss,resetResourceDescription:Es}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),de=C!=null&&C.restored?await ne(s.name,i):await J(s.name,i,f);de.success?(p(C!=null&&C.restored?r("builtinResources.restoreDefaultSuccess"):r("builtinResources.descriptionUpdateSuccess"),"success"),o==null||o()):p(de.error||(C!=null&&C.restored?r("builtinResources.restoreDefaultFailed"):r("builtinResources.descriptionUpdateFailed")),"error")}catch(J){console.error(J),p(C!=null&&C.restored?r("builtinResources.restoreDefaultFailed"):r("builtinResources.descriptionUpdateFailed"),"error")}};(()=>{var C;const i=s.config;if(!i)return"";if(i.url)return i.url;const f=[];return i.command&&f.push(i.command),(C=i.args)!=null&&C.length&&f.push(...i.args),f.join(" ")})();const Fe=`${k}/mcp/${s.name}`,Re=(i,f)=>r(i,f),ue=ut(Re,s.visibility??((Ke=s.config)==null?void 0:Ke.visibility)),Cs=mt(Re,ue.value),Oe=[{key:"tools",icon:Rs,total:z,enabled:K,label:r("server.tools")},{key:"prompts",icon:Os,total:ce,enabled:V,label:r("server.prompts")},{key:"resources",icon:_s,total:Z,enabled:se,label:r("nav.resources")}];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hub-card overflow-visible",style:{marginBottom:10},children:[e.jsxs("div",{className:"hub-server-card-row cursor-pointer px-4 py-3 transition-colors hover:bg-[var(--hub-surface-hover)]",onClick:()=>w(!E),children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx(ke,{size:12,style:{color:"var(--hub-ink-3)",transform:E?"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:ae?"var(--hub-ink)":"var(--hub-ink-3)"},children:s.name}),he&&e.jsx("span",{className:"hub-tag accent flex-shrink-0",title:r("server.mcpApp"),children:"App"}),s.error&&e.jsxs("div",{className:"relative",ref:oe,children:[e.jsx("button",{onClick:i=>{i.stopPropagation(),M(f=>!f)},className:"text-[var(--hub-err)] hover:opacity-80","aria-label":r("server.viewErrorDetails"),children:e.jsx(we,{size:14})}),Q&&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:i=>i.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:bs,className:"hub-icon-btn sm",title:r("common.copy"),children:S?e.jsx(xe,{size:12,className:"text-[var(--hub-ok)]"}):e.jsx(ye,{size:12})})]}),e.jsx("button",{onClick:()=>M(!1),className:"hub-icon-btn sm","aria-label":r("app.closeButton"),children:e.jsx(Ee,{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})})]})]})]}),((He=s.config)==null?void 0:He.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:"hub-server-card-status-cell min-w-0",children:e.jsx(Is,{status:s.status,enabled:s.enabled,startOnDemand:((Ge=s.config)==null?void 0:Ge.startOnDemand)===!0,onAuthClick:gs,className:"hub-server-card-status"})}),e.jsx("div",{className:"hub-server-card-transport-cell min-w-0",children:(Ye=s.config)!=null&&Ye.type?e.jsx("span",{className:"hub-tag hub-server-card-transport-tag",title:es(r,s.config.type)??void 0,children:es(r,s.config.type)}):e.jsx("span",{style:{color:"var(--hub-ink-3)",fontSize:12},children:"—"})}),e.jsx("div",{className:"hub-server-card-visibility min-w-0",onClick:i=>i.stopPropagation(),children:G&&d?e.jsx(Ze,{isLoading:m,className:"w-full",overlayStyle:{borderRadius:6},children:e.jsx("select",{value:ue.value,onChange:hs,disabled:m,className:"hub-server-card-select w-full rounded-md border px-2 py-1 text-[11.5px] bg-[var(--hub-surface)] text-[var(--hub-ink)]",style:{borderColor:"var(--hub-line-2)"},"aria-label":r("server.visibility","Visibility"),title:ue.longLabel,children:Cs.map(i=>e.jsx("option",{value:i.value,disabled:i.disabled,children:i.label},i.value))})}):e.jsx("span",{className:`hub-server-card-visibility-badge inline-flex items-center rounded-md border px-2 py-0.5 text-[11.5px] ${ue.className}`,title:ue.longLabel,children:ue.shortLabel})}),Oe.map(({key:i,icon:f,total:C,enabled:J,label:ne})=>{const de=C===0;return e.jsxs("span",{className:`hub-server-capability-stat hub-mono hub-num ${de?"is-empty":""}`,title:`${ne}: ${J}/${C}`,children:[e.jsx("span",{className:"text-[var(--hub-ink-3)]",children:e.jsx(Qe,{icon:f})}),e.jsx("span",{className:"hub-server-capability-value",children:de?"0":`${J}/${C}`})]},i)}),n&&n.connected?e.jsxs("span",{className:"hub-server-capability-stat hub-mono hub-num",title:`${r("cost.exposed")} ${n.exposed} / ${r("cost.gross")} ${n.gross} · ${r("cost.estimate")}`,children:[e.jsx("span",{className:"text-[var(--hub-ink-3)]",children:"Σ"}),e.jsxs("span",{className:"hub-server-capability-value",children:[ie(n.exposed),"/",ie(n.gross)]})]}):n?e.jsx("span",{className:"hub-server-capability-stat hub-mono is-empty",title:r("cost.notConnected"),children:e.jsx("span",{className:"hub-server-capability-value",children:"—"})}):null,e.jsx("div",{className:"flex items-center justify-center",onClick:i=>i.stopPropagation(),children:e.jsx(Ze,{isLoading:Y,className:"h-[18px] w-[30px]",overlayStyle:{borderRadius:999,background:"var(--hub-bg-2)"},spinnerSize:10,children:e.jsx(Ne,{checked:ae,onCheckedChange:be,disabled:Y||!G,size:"compact","aria-label":`${r(ae?"server.disable":"server.enable")} ${s.name}`})})}),e.jsxs("div",{className:"relative",ref:ee,children:[G&&e.jsx("button",{className:"hub-icon-btn",onClick:i=>{i.stopPropagation(),L(f=>!f)},"aria-label":"More",children:e.jsx(As,{size:14})}),G&&A&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 hub-card",style:{minWidth:160,padding:4},onClick:i=>i.stopPropagation(),children:[e.jsxs("button",{onClick:i=>{i.stopPropagation(),L(!1),a(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(Ms,{size:13})," ",r("server.edit")]}),e.jsxs("button",{onClick:fs,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(ye,{size:13})," ",r("server.copy")]}),y&&e.jsxs("button",{onClick:fe,disabled:l||Y||!ae,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(je,{size:13})," ",r("server.reload")]}),N&&X&&e.jsxs("button",{onClick:i=>{i.stopPropagation(),L(!1),!(!G||c||!ae)&&I(!0)},disabled:c||Y||!ae,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(Vs,{size:13})," ",r("server.reinstall")]}),re&&e.jsxs("button",{onClick:i=>{i.stopPropagation(),L(!1),!(!G||P)&&q(!0)},disabled:P,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(Js,{size:13})," ",r("server.disconnectOAuth")]}),e.jsx("div",{style:{height:1,background:"var(--hub-line-2)",margin:"4px 0"}}),e.jsxs("button",{onClick:i=>{i.stopPropagation(),L(!1),O(!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(Us,{size:13})," ",r("server.delete")]})]})]})]}),E&&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:[Oe.map(i=>{const f=R===i.key,C=i.icon;return e.jsxs("button",{onClick:()=>_(f?null:i.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:f?"var(--hub-surface)":"transparent",border:"1px solid "+(f?"var(--hub-line)":"transparent"),color:f?"var(--hub-ink)":"var(--hub-ink-2)"},children:[e.jsx(Qe,{icon:C}),e.jsx("span",{children:i.label}),e.jsx("span",{className:"hub-mono hub-num",style:{color:"var(--hub-ink-3)",fontSize:11},children:i.total===0?"0":`${i.enabled}/${i.total}`})]},i.key)}),n&&n.connected&&e.jsxs("button",{onClick:()=>_(R==="cost"?null:"cost"),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:R==="cost"?"var(--hub-surface)":"transparent",border:"1px solid "+(R==="cost"?"var(--hub-line)":"transparent"),color:R==="cost"?"var(--hub-ink)":"var(--hub-ink-2)"},title:r("cost.estimate"),children:[e.jsx("span",{style:{color:"var(--hub-ink-3)"},children:"Σ"}),e.jsx("span",{children:r("cost.totalFootprint")}),e.jsxs("span",{className:"hub-mono hub-num",style:{color:"var(--hub-ink-3)",fontSize:11},children:[ie(n.exposed),"/",ie(n.gross)]})]}),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:Fe,style:{maxWidth:200},children:s.name}),e.jsx("button",{type:"button",className:"hub-endpoint-copy",onClick:async i=>{i.stopPropagation();const f=await Se(Fe);p(f?r("common.copySuccess")||"Copied":r("common.copyFailed")||"Failed",f?"success":"error")},title:r("common.copy"),children:e.jsx(ye,{size:12})})]})})]}),R==="cost"&&(n==null?void 0:n.connected)&&e.jsx("div",{className:"mt-2 space-y-1",children:[...n.items].sort((i,f)=>f.cost-i.cost).map(i=>e.jsxs("div",{className:"flex items-center justify-between hub-mono",style:{fontSize:11.5,color:i.enabled?"var(--hub-ink-2)":"var(--hub-ink-3)"},children:[e.jsx("span",{className:"truncate",children:i.name}),e.jsx("span",{className:"hub-num flex-shrink-0",children:ie(i.cost)})]},`${i.kind}:${i.name}`))}),R==="tools"&&s.tools&&e.jsx("div",{className:"space-y-3 mt-2",children:s.tools.map((i,f)=>{var C;return e.jsx(rt,{server:s.name,tool:i,readOnly:!G,onToggle:ys,onDescriptionUpdate:Ns,cost:(C=n==null?void 0:n.items.find(J=>J.kind==="tool"&&J.name===i.name))==null?void 0:C.cost},f)})}),R==="prompts"&&s.prompts&&e.jsx("div",{className:"space-y-3 mt-2",children:s.prompts.map((i,f)=>{var C;return e.jsx(it,{server:s.name,prompt:i,readOnly:!G,onToggle:js,onDescriptionUpdate:ws,cost:(C=n==null?void 0:n.items.find(J=>J.kind==="prompt"&&J.name===i.name))==null?void 0:C.cost},f)})}),R==="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((i,f)=>{var C;return e.jsx(lt,{resource:i,readOnly:!G,onToggle:vs,onDescriptionUpdate:ks,cost:(C=n==null?void 0:n.items.find(J=>J.kind==="resource"&&J.name===i.uri))==null?void 0:C.cost},`${i.uri}-${f}`)})})})]})]}),e.jsx(Hs,{isOpen:W,onClose:()=>O(!1),onConfirm:()=>{t(s.name),O(!1)},serverName:s.name}),e.jsx(De,{isOpen:B,onClose:()=>I(!1),onConfirm:()=>{I(!1),Ce()},title:r("server.reinstall"),message:r("server.reinstallConfirm")||"This will clear the package cache and re-download dependencies. The server will restart.",confirmText:r("server.reinstall"),variant:"warning"}),e.jsx(De,{isOpen:H,onClose:()=>q(!1),onConfirm:()=>{q(!1),pe()},title:r("server.disconnectOAuth"),message:r("server.disconnectOAuthConfirm")||"This will revoke stored OAuth credentials where supported and require authorization again.",confirmText:r("server.disconnectOAuth"),variant:"warning"})]})},bt=({onAdd:s})=>{const{t:n}=te(),[t,a]=u.useState(!1),[x,d]=u.useState(null),[o,y]=u.useState(!1),[N,D]=u.useState(null),[r,p]=u.useState([]),$=()=>{a(!t),d(null),y(!1),D(null)},g=async()=>{N&&(await F(N),y(!1),D(null))},F=async E=>{try{d(null);const w=await le("/servers",E);if(!w.success){w&&w.message?d(w.message):d(n("server.addError"));return}a(!1),s()}catch(w){console.error("Error adding server:",w),navigator.onLine?w instanceof TypeError&&(w.message.includes("NetworkError")||w.message.includes("Failed to fetch"))?d(n("errors.serverConnection")):d(n("errors.serverAdd")):d(n("errors.network"))}},k=async E=>{try{const w=Gs(E);w.length>0?(p(w),D(E),y(!0)):await F(E)}catch(w){console.error("Error processing server submission:",w),d(n("errors.serverAdd"))}};return e.jsxs("div",{children:[e.jsxs("button",{onClick:$,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"})}),n("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(is,{onSubmit:k,onCancel:$,modalTitle:n("server.addServer"),formError:x})}),o&&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:n("server.confirmVariables")}),e.jsx("p",{className:"text-gray-600 mb-4",children:n("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:[n("server.detectedVariables"),":"]}),e.jsx("ul",{className:"mt-1 text-sm text-yellow-700",children:r.map((E,w)=>e.jsxs("li",{className:"font-mono",children:["$",`{${E}}`]},w))})]})]})}),e.jsx("p",{className:"text-gray-600 text-sm mb-6",children:n("server.confirmVariablesMessage")}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>{y(!1),D(null)},className:"hub-btn",children:n("common.cancel")}),e.jsx("button",{onClick:g,className:"hub-btn primary",children:n("server.confirmAndAdd")})]})]})})]})},ft=({server:s,onEdit:n,onCancel:t})=>{const{t:a}=te(),[x,d]=u.useState(null),o=async y=>{try{d(null);const N=encodeURIComponent(s.name),D=y.name&&y.name!==s.name,r={config:y.config,...D?{newName:y.name}:{}},p=await ve(`/servers/${N}`,r);if(!p.success){p&&p.message?d(p.message):d(a("server.updateError",{serverName:s.name}));return}n()}catch(N){console.error("Error updating server:",N),navigator.onLine?N instanceof TypeError&&(N.message.includes("NetworkError")||N.message.includes("Failed to fetch"))?d(a("errors.serverConnection")):d(a("errors.serverUpdate",{serverName:s.name})):d(a("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(is,{onSubmit:o,onCancel:t,initialData:s,modalTitle:a("server.editTitle",{serverName:s.name}),formError:x})})},gt=({onSuccess:s,onCancel:n})=>{const{t}=te(),[a,x]=u.useState(!1),[d,o]=u.useState(!1),[y,N]=u.useState(null),[D,r]=u.useState(null),[p,$]=u.useState(!1),[g,F]=u.useState(null),[k,E]=u.useState(""),[w,R]=u.useState(!1),[_,W]=u.useState(""),O=l=>{l.preventDefault(),x(!0)},B=l=>{l.preventDefault(),x(!1)},I=l=>{l.preventDefault(),x(!1);const h=l.dataTransfer.files;if(h.length>0){const c=h[0];c.name.endsWith(".mcpb")?(r(c),N(null)):N(t("mcpb.invalidFileType"))}},H=l=>{const h=l.target.files;if(h&&h.length>0){const c=h[0];c.name.endsWith(".mcpb")?(r(c),N(null)):N(t("mcpb.invalidFileType"))}},q=async()=>{if(!D){N(t("mcpb.noFileSelected"));return}o(!0),N(null);try{const l=new FormData;l.append("mcpbFile",D);const h=await Ts($s("/mcpb/upload"),{method:"POST",body:l}),c=await h.json();if(!h.ok)throw new Error(c.message||`HTTP error! Status: ${h.status}`);if(c.success&&c.data)F(c.data.manifest),E(c.data.extractDir),$(!0);else throw new Error(c.message||t("mcpb.uploadFailed"))}catch(l){console.error("MCPB upload error:",l),N(l instanceof Error?l.message:t("mcpb.uploadFailed"))}finally{o(!1)}},Y=async(l,h=!1)=>{var c;o(!0),N(null);try{const v=j(g,k,l);if(!h){const T=await zs("/servers");if(T.success&&((c=T.data)==null?void 0:c.find(L=>L.name===l))){W(l),R(!0),o(!1);return}}let P;if(h?P=await ve(`/servers/${encodeURIComponent(l)}`,{name:l,config:v}):P=await le("/servers",{name:l,config:v}),P.success)s(v);else throw new Error(P.message||t("mcpb.installFailed"))}catch(v){console.error("MCPB install error:",v),N(v instanceof Error?v.message:t("mcpb.installFailed")),o(!1)}},b=()=>{R(!1),_&&Y(_,!0)},m=()=>{R(!1),W(""),o(!1)},j=(l,h,c)=>{var T;const v=((T=l.server)==null?void 0:T.mcp_config)||{},P={type:"stdio",command:v.command||"node",args:(v.args||[]).map(A=>A.replace("${__dirname}",h))};return v.env&&Object.keys(v.env).length>0&&(P.env={...v.env},Object.keys(P.env).forEach(A=>{typeof P.env[A]=="string"&&(P.env[A]=P.env[A].replace("${__dirname}",h))})),P};return p&&g?e.jsxs(e.Fragment,{children:[e.jsx(De,{isOpen:w,onClose:m,onConfirm:b,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 ${w?"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:n,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),y&&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:y})}),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"),":"]})," ",g.display_name||g.name]}),e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.version"),":"]})," ",g.version]}),e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.description"),":"]})," ",g.description]}),g.author&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.author"),":"]})," ",g.author.name]}),g.tools&&g.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:g.tools.map((l,h)=>e.jsxs("li",{children:[l.name," - ",l.description]},h))})]})]})]}),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:g.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:n,disabled:d,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:()=>{const l=document.getElementById("serverName"),h=(l==null?void 0:l.value.trim())||g.name;Y(h)},disabled:d,className:"hub-btn primary",children:d?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:n,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),y&&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:y})}),e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-8 text-center transition-colors ${a?"border-blue-500 bg-blue-50":D?"border-gray-500 ":"border-gray-300 hover:border-gray-400"}`,onDragOver:O,onDragLeave:B,onDrop:I,children:[D?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:D.name}),e.jsxs("p",{className:"text-xs text-gray-500",children:[(D.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:n,disabled:d,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:q,disabled:!D||d,className:"hub-btn primary flex items-center",children:d?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")})]})]})})},yt=["sse","streamable-http"],jt=new Set(["type","url","command","args","env","headers","options","openapi","oauth","enabled","visibility","keepAliveInterval","enableKeepAlive","perSessionClient","tools","prompts","passthroughHeaders","proxy"]),vt=s=>{const n=[],t=[];for(const[a,x]of Object.entries(s.mcpServers)){const d=x??{},o={},y=Object.keys(d).filter(N=>!jt.has(N));if(y.length>0){t.push({name:a,message:`unknown field(s) "${y.join('", "')}" — not part of the mcphub server schema. For OAuth, use an "oauth" object (e.g. {"scopes":["email"]}).`});continue}if(d.type==="sse"||d.type==="streamable-http"){if(o.type=d.type,o.url=d.url,d.headers&&(o.headers=d.headers),d.oauth&&(o.oauth=d.oauth),!d.url){t.push({name:a,message:`"${d.type}" servers require a "url" field.`});continue}}else if(d.type==="openapi")o.type="openapi",o.openapi=d.openapi;else if(d.type===void 0||d.type==="stdio"){if(d.url&&!d.command){t.push({name:a,message:`has a "url" but type "${d.type??"stdio"}". Use "streamable-http" or "sse" for remote servers.`});continue}if(o.type="stdio",o.command=d.command,o.args=d.args||[],d.env&&(o.env=d.env),d.options&&(o.options=d.options),!d.command){t.push({name:a,message:'stdio servers require a "command" field.'});continue}}else{const N=yt.includes(String(d.type))?"":' Did you mean "streamable-http"? Supported types: stdio, sse, streamable-http, openapi.';t.push({name:a,message:`unsupported type "${d.type}".${N}`});continue}n.push({name:a,config:o})}return{servers:n,issues:t}},Nt=({onSuccess:s,onCancel:n})=>{const{t}=te(),[a,x]=u.useState(""),[d,o]=u.useState(null),[y,N]=u.useState(!1),[D,r]=u.useState(null),p=`{
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.`,$=k=>{try{const E=JSON.parse(k.trim());return!E.mcpServers||typeof E.mcpServers!="object"?(o(t("jsonImport.invalidFormat")),null):E}catch{return o(t("jsonImport.parseError")),null}},g=()=>{o(null);const k=$(a);if(!k)return;const{servers:E,issues:w}=vt(k);if(w.length>0){const R=w.map(_=>`${_.name}: ${_.message}`).join(`
35
- `);if(o(t("jsonImport.validationErrors")+`
36
- `+R),E.length===0)return}r(E)},F=async()=>{if(D){N(!0),o(null);try{const k=await le("/servers/batch",{servers:D});if(k.success&&k.data){const{successCount:E,failureCount:w,results:R}=k.data;if(w>0){const _=R.filter(W=>!W.success).map(W=>`${W.name}: ${W.message||t("jsonImport.addFailed")}`);o(t("jsonImport.partialSuccess",{count:E,total:D.length})+`
37
- `+_.join(`
38
- `))}E>0&&s()}else o(k.message||t("jsonImport.importFailed"))}catch(k){console.error("Import error:",k),o(t("jsonImport.importFailed"))}finally{N(!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:n,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),d&&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:d})}),D?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:D.map((k,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:k.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"),":"]})," ",k.config.type||"stdio"]}),k.config.command&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.command"),":"]})," ",k.config.command]}),k.config.args&&k.config.args.length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.arguments"),":"]})," ",k.config.args.join(" ")]}),k.config.url&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.url"),":"]})," ",k.config.url]}),k.config.env&&Object.keys(k.config.env).length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.envVars"),":"]})," ",Object.keys(k.config.env).join(", ")]}),k.config.headers&&Object.keys(k.config.headers).length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.headers"),":"]})," ",Object.keys(k.config.headers).join(", ")]})]})]})})},E))})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:()=>r(null),disabled:y,className:"hub-btn",children:t("common.back")}),e.jsx("button",{onClick:F,disabled:y,className:"hub-btn primary",children:y?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:a,onChange:k=>x(k.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:p}),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:n,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:g,disabled:!a.trim(),className:"hub-btn primary",children:t("jsonImport.preview")})]})]})]})})},wt=s=>({all:s.length,online:s.filter(n=>n.status==="connected").length,issues:s.filter(n=>n.status!=="connected"&&n.enabled!==!1).length,disabled:s.filter(n=>n.enabled===!1).length}),kt=(s,n,t="")=>{const a=t.trim().toLowerCase();return s.filter(x=>{var o,y;return n==="online"&&x.status!=="connected"||n==="issues"&&(x.status==="connected"||x.enabled===!1)||n==="disabled"&&x.enabled!==!1?!1:a?(x.name+" "+(((o=x.config)==null?void 0:o.description)||"")+" "+(((y=x.tools)==null?void 0:y.map(N=>N.name).join(" "))||"")).toLowerCase().includes(a):!0})},Ct=(s,n,t,a,x)=>{const d=kt(s,n,t),o=d.length,y=Math.max(1,Math.ceil(o/x)),N=Math.min(Math.max(1,a),y),D=(N-1)*x;return{servers:d.slice(D,D+x),pagination:{page:N,limit:x,total:o,totalPages:y,hasNextPage:N<y,hasPrevPage:N>1}}},Vt=()=>{const{t:s}=te(),n=Ds(),{servers:t,allServers:a,error:x,setError:d,isLoading:o,currentPage:y,serversPerPage:N,setCurrentPage:D,setServersPerPage:r,handleServerAdd:p,handleServerEdit:$,handleServerRemove:g,handleServerToggle:F,handleServerVisibilityChange:k,handleServerReload:E,handleServerReinstall:w,handleServerOAuthDisconnect:R,triggerRefresh:_}=Xs({refreshOnMount:!0}),{serverCosts:W,refetch:O}=Zs();u.useEffect(()=>{O()},[t,O]);const[B,I]=u.useState(null),[H,q]=u.useState(!1),[Y,b]=u.useState(!1),[m,j]=u.useState(!1),[l,h]=u.useState("all"),[c,v]=u.useState(""),P=u.useMemo(()=>wt(a),[a]),{servers:T,pagination:A}=u.useMemo(()=>Ct(a,l,c,y,N),[a,l,c,y,N]);u.useEffect(()=>{A.page!==y&&D(A.page)},[A.page,y,D]);const L=async M=>{const S=await $(M);S&&I(S)},Q=async()=>{q(!0);try{_(),await new Promise(M=>setTimeout(M,400))}finally{q(!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:P.all})," ",s("nav.servers").toLowerCase()," ·"," ",e.jsx("span",{className:"hub-num",children:P.online})," ",s("status.online")," ·"," ",e.jsx("span",{className:"hub-num",children:P.issues})," ",s("common.inactive")||"issues"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{className:"hub-btn",onClick:()=>n("/market"),children:[e.jsx(Bs,{size:13})," ",s("nav.market")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>j(!0),children:[e.jsx(Ls,{size:13})," ",s("jsonImport.button")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>b(!0),children:[e.jsx(Ws,{size:13})," ",s("mcpb.upload")]}),e.jsxs("button",{className:"hub-btn",onClick:Q,disabled:H,"aria-label":s("common.refresh"),children:[e.jsx(je,{size:13,className:H?"animate-spin":""}),s("common.refresh")]}),e.jsx(bt,{onAdd:p})]})]}),x&&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(we,{size:14,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate text-[13px]",children:x})]}),e.jsx("button",{className:"hub-icon-btn sm",onClick:()=>d(null),"aria-label":s("app.closeButton"),children:e.jsx(Ee,{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",P.all],["online",s("status.online"),P.online],["issues",s("common.inactive")||"Issues",P.issues],["disabled",s("pages.dashboard.disabledServers")||"Disabled",P.disabled]].map(([M,S,U])=>e.jsxs("button",{onClick:()=>h(M),className:"inline-flex items-center gap-1.5 px-3 text-[12px]",style:{height:24,borderRadius:5,background:l===M?"var(--hub-bg-2)":"transparent",color:l===M?"var(--hub-ink)":"var(--hub-ink-3)",border:"1px solid "+(l===M?"var(--hub-line)":"transparent")},children:[S,e.jsx("span",{className:"hub-mono",style:{fontSize:11,color:"var(--hub-ink-3)"},children:U})]},M))}),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(qs,{size:13,style:{color:"var(--hub-ink-3)"}}),e.jsx("input",{value:c,onChange:M=>v(M.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:()=>v(""),className:"hub-icon-btn sm",children:e.jsx(Ee,{size:11})})]}),e.jsxs("div",{className:"ml-auto hub-mono text-[12px]",style:{color:"var(--hub-ink-3)"},children:[A.total,"/",a.length]})]}),o&&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(je,{size:20,className:"animate-spin",style:{color:"var(--hub-ink-3)"}}),e.jsx("p",{style:{color:"var(--hub-ink-3)"},children:s("app.loading")})]})}):T.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:T.map(M=>e.jsx(ht,{server:M,cost:W.find(S=>S.name===M.name),onRemove:g,onEdit:L,onToggle:F,onVisibilityChange:k,onRefresh:_,onReload:E,onReinstall:w,onOAuthDisconnect:R},M.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:s("common.showing",{start:(A.page-1)*A.limit+1,end:Math.min(A.page*A.limit,A.total),total:A.total})}),e.jsx("div",{className:"flex-[4] flex justify-center",children:A.totalPages>1&&e.jsx(Ys,{currentPage:A.page,totalPages:A.totalPages,onPageChange:D,disabled:o})}),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:N,onChange:M=>r(Number(M.target.value)),disabled:o,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"})]})]})]})]}),B&&e.jsx(ft,{server:B,onEdit:()=>{I(null),_()},onCancel:()=>I(null)}),Y&&e.jsx(gt,{onSuccess:()=>{b(!1),_()},onCancel:()=>b(!1)}),m&&e.jsx(Nt,{onSuccess:()=>{j(!1),_()},onCancel:()=>j(!1)})]})};export{Vt as default};
39
- //# sourceMappingURL=ServersPage-CbtcAcVH.js.map