@samanhappy/mcphub 1.0.4 → 1.0.6

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 (89) hide show
  1. package/dist/betterAuth.js +4 -4
  2. package/dist/betterAuth.js.map +1 -1
  3. package/dist/clients/openapi.js +98 -5
  4. package/dist/clients/openapi.js.map +1 -1
  5. package/dist/controllers/hostedInternalController.js +55 -0
  6. package/dist/controllers/hostedInternalController.js.map +1 -0
  7. package/dist/controllers/serverController.js +1 -1
  8. package/dist/controllers/serverController.js.map +1 -1
  9. package/dist/dao/ServerDao.js +24 -0
  10. package/dist/dao/ServerDao.js.map +1 -1
  11. package/dist/dao/ServerDaoDbImpl.js +11 -0
  12. package/dist/dao/ServerDaoDbImpl.js.map +1 -1
  13. package/dist/db/repositories/ServerRepository.js +16 -0
  14. package/dist/db/repositories/ServerRepository.js.map +1 -1
  15. package/dist/index.js +8 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/routes/index.js +5 -1
  18. package/dist/routes/index.js.map +1 -1
  19. package/dist/services/betterAuthConfig.js +144 -33
  20. package/dist/services/betterAuthConfig.js.map +1 -1
  21. package/dist/services/hostedAuthService.js +314 -0
  22. package/dist/services/hostedAuthService.js.map +1 -0
  23. package/dist/services/hostedControlPlaneClient.js +90 -0
  24. package/dist/services/hostedControlPlaneClient.js.map +1 -0
  25. package/dist/services/hostedEventSubscriber.js +206 -0
  26. package/dist/services/hostedEventSubscriber.js.map +1 -0
  27. package/dist/services/hostedInternalAuth.js +108 -0
  28. package/dist/services/hostedInternalAuth.js.map +1 -0
  29. package/dist/services/hostedMode.js +4 -0
  30. package/dist/services/hostedMode.js.map +1 -0
  31. package/dist/services/hostedNodeIdentity.js +8 -0
  32. package/dist/services/hostedNodeIdentity.js.map +1 -0
  33. package/dist/services/hostedRuntimeCatalogNames.js +7 -0
  34. package/dist/services/hostedRuntimeCatalogNames.js.map +1 -0
  35. package/dist/services/hostedRuntimeCatalogService.js +31 -0
  36. package/dist/services/hostedRuntimeCatalogService.js.map +1 -0
  37. package/dist/services/mcpService.js +84 -10
  38. package/dist/services/mcpService.js.map +1 -1
  39. package/dist/services/requestContextService.js +12 -0
  40. package/dist/services/requestContextService.js.map +1 -1
  41. package/dist/services/sseService.js +61 -10
  42. package/dist/services/sseService.js.map +1 -1
  43. package/dist/utils/rateLimit.js +4 -0
  44. package/dist/utils/rateLimit.js.map +1 -1
  45. package/frontend/dist/assets/{ActivityPage-BC5odCF8.js → ActivityPage-CLXufyzU.js} +2 -2
  46. package/frontend/dist/assets/{ActivityPage-BC5odCF8.js.map → ActivityPage-CLXufyzU.js.map} +1 -1
  47. package/frontend/dist/assets/{Dashboard-D3G8PwSI.js → Dashboard-YMaaIlIZ.js} +2 -2
  48. package/frontend/dist/assets/{Dashboard-D3G8PwSI.js.map → Dashboard-YMaaIlIZ.js.map} +1 -1
  49. package/frontend/dist/assets/{EndpointCopy-DR92FdQt.js → EndpointCopy-Cpc2WqQz.js} +2 -2
  50. package/frontend/dist/assets/{EndpointCopy-DR92FdQt.js.map → EndpointCopy-Cpc2WqQz.js.map} +1 -1
  51. package/frontend/dist/assets/{GroupsPage--XsL_jeG.js → GroupsPage-DqK5U5rY.js} +2 -2
  52. package/frontend/dist/assets/{GroupsPage--XsL_jeG.js.map → GroupsPage-DqK5U5rY.js.map} +1 -1
  53. package/frontend/dist/assets/{LoginPage-B6FzN2_o.js → LoginPage-ByV35kun.js} +2 -2
  54. package/frontend/dist/assets/{LoginPage-B6FzN2_o.js.map → LoginPage-ByV35kun.js.map} +1 -1
  55. package/frontend/dist/assets/{LogsPage-DonCddYQ.js → LogsPage-BygFVcaV.js} +2 -2
  56. package/frontend/dist/assets/{LogsPage-DonCddYQ.js.map → LogsPage-BygFVcaV.js.map} +1 -1
  57. package/frontend/dist/assets/{MarketPage-DlA2aXU9.js → MarketPage-Cc7QeqSw.js} +2 -2
  58. package/frontend/dist/assets/{MarketPage-DlA2aXU9.js.map → MarketPage-Cc7QeqSw.js.map} +1 -1
  59. package/frontend/dist/assets/{PromptsPage-DTPJHm1Y.js → PromptsPage-DvLm5TW4.js} +2 -2
  60. package/frontend/dist/assets/{PromptsPage-DTPJHm1Y.js.map → PromptsPage-DvLm5TW4.js.map} +1 -1
  61. package/frontend/dist/assets/{ResourcesPage-Dwjs_zER.js → ResourcesPage-Dnn1u2fr.js} +2 -2
  62. package/frontend/dist/assets/{ResourcesPage-Dwjs_zER.js.map → ResourcesPage-Dnn1u2fr.js.map} +1 -1
  63. package/frontend/dist/assets/ServersPage-RQCARDfE.js +37 -0
  64. package/frontend/dist/assets/ServersPage-RQCARDfE.js.map +1 -0
  65. package/frontend/dist/assets/{SettingsPage-DpM-PtFb.js → SettingsPage-CF40R-50.js} +2 -2
  66. package/frontend/dist/assets/{SettingsPage-DpM-PtFb.js.map → SettingsPage-CF40R-50.js.map} +1 -1
  67. package/frontend/dist/assets/{StatusDot-BLQQqKOH.js → StatusDot-CkF9WMhU.js} +2 -2
  68. package/frontend/dist/assets/{StatusDot-BLQQqKOH.js.map → StatusDot-CkF9WMhU.js.map} +1 -1
  69. package/frontend/dist/assets/{ToggleGroup-DoqIEGtu.js → ToggleGroup-vRqJ9DIB.js} +2 -2
  70. package/frontend/dist/assets/{ToggleGroup-DoqIEGtu.js.map → ToggleGroup-vRqJ9DIB.js.map} +1 -1
  71. package/frontend/dist/assets/{UsersPage-DzxtbiCa.js → UsersPage-DBN5qCeO.js} +2 -2
  72. package/frontend/dist/assets/{UsersPage-DzxtbiCa.js.map → UsersPage-DBN5qCeO.js.map} +1 -1
  73. package/frontend/dist/assets/{index-R7UAqPfE.js → index-C7dQApMG.js} +3 -3
  74. package/frontend/dist/assets/{index-R7UAqPfE.js.map → index-C7dQApMG.js.map} +1 -1
  75. package/frontend/dist/assets/{resourceService-BpwGqVJZ.js → resourceService-BgjWoJFK.js} +2 -2
  76. package/frontend/dist/assets/{resourceService-BpwGqVJZ.js.map → resourceService-BgjWoJFK.js.map} +1 -1
  77. package/frontend/dist/assets/{useServerData-CPGo5oC7.js → useServerData-CEGj5OU1.js} +2 -2
  78. package/frontend/dist/assets/{useServerData-CPGo5oC7.js.map → useServerData-CEGj5OU1.js.map} +1 -1
  79. package/frontend/dist/assets/useSettingsData-C2-q9Okf.js +2 -0
  80. package/frontend/dist/assets/{useSettingsData-cUOCzPSG.js.map → useSettingsData-C2-q9Okf.js.map} +1 -1
  81. package/frontend/dist/assets/variableDetection-GTKqOf1F.js +16 -0
  82. package/frontend/dist/assets/variableDetection-GTKqOf1F.js.map +1 -0
  83. package/frontend/dist/index.html +1 -1
  84. package/package.json +2 -1
  85. package/frontend/dist/assets/ServersPage-9Ku6lufR.js +0 -37
  86. package/frontend/dist/assets/ServersPage-9Ku6lufR.js.map +0 -1
  87. package/frontend/dist/assets/useSettingsData-cUOCzPSG.js +0 -2
  88. package/frontend/dist/assets/variableDetection-DsYuiOB_.js +0 -16
  89. package/frontend/dist/assets/variableDetection-DsYuiOB_.js.map +0 -1
@@ -0,0 +1,37 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./resourceService-BgjWoJFK.js","./index-C7dQApMG.js","./framework-vendor-BUhDPOUZ.js","./i18n-vendor-Kbr87Ofu.js","./icons-vendor-CKgJB3SC.js","./index-D0OIBhmN.css"])))=>i.map(i=>d[i]);
2
+ import{r as c,j as e,b as Xe}from"./framework-vendor-BUhDPOUZ.js";import{e as te,f as $e,h as je,i as ke,u as Ze,_ as fe,j as Qe,k as Ye,l as es}from"./index-C7dQApMG.js";import{S as ss}from"./StatusDot-CkF9WMhU.js";import{u as Ce}from"./useSettingsData-C2-q9Okf.js";import{S as Se}from"./ToggleGroup-vRqJ9DIB.js";import{u as Y}from"./i18n-vendor-Kbr87Ofu.js";import{l as _e,m as Oe,j as ye,n as ts,C as ue,o as be,p as Ee,q as Ae,r as Me,s as ze,k as ve,X as Ne,W as De,f as Pe,F as Fe,E as rs,t as ns,R as we,T as as,P as os,u as is,v as ls,w as cs}from"./icons-vendor-CKgJB3SC.js";import{D as ds}from"./DeleteDialog-DRbWonMu.js";import{S as Je,d as ms}from"./variableDetection-GTKqOf1F.js";import{C as us}from"./ConfirmDialog-CxlizGia.js";import{P as ps}from"./Pagination-BFi-X7qY.js";import{u as xs}from"./useServerData-CEGj5OU1.js";const Ue=async(s,a)=>{try{const t=a?`/tools/${encodeURIComponent(a)}/${encodeURIComponent(s.toolName)}`:"/tools/call",r=await te(t,s.arguments,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return r.success===!1?{success:!1,error:r.message||"Tool call failed"}:{success:!0,content:(r==null?void 0:r.content)||[]}}catch(t){return console.error("Error calling tool",{toolName:s.toolName,server:a,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},hs=async(s,a,t)=>{try{const r=await te(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(a)}/toggle`,{enabled:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:r.success,error:r.success?void 0:r.message}}catch(r){return console.error("Error toggling tool",{serverName:s,toolName:a,enabled:t,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},Be=async(s,a,t)=>{try{const r=await je(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(a)}/description`,{description:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:r.success,error:r.success?void 0:r.message}}catch(r){return console.error("Error updating tool description",{serverName:s,toolName:a,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},Ve=async(s,a)=>{var t;try{const r=await $e(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(a)}/description`,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:r.success,error:r.success?void 0:r.message,description:(t=r.data)==null?void 0:t.description}}catch(r){return console.error("Error resetting tool description",{serverName:s,toolName:a,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},gs=Object.freeze(Object.defineProperty({__proto__:null,callTool:Ue,resetToolDescription:Ve,toggleTool:hs,updateToolDescription:Be},Symbol.toStringTag,{value:"Module"})),We=({schema:s,onSubmit:a,onCancel:t,loading:r=!1,storageKey:x,title:m})=>{const{t:n}=Y(),[p,T]=c.useState({}),[F,d]=c.useState({}),[C,D]=c.useState(!1),[N,R]=c.useState(""),[f,z]=c.useState(""),y=c.useMemo(()=>(l=>{const v=o=>{if(typeof o=="object"&&o!==null){const u=o;return{type:u.type||"string",description:u.description,enum:u.enum,default:u.default,properties:u.properties?Object.fromEntries(Object.entries(u.properties).map(([i,b])=>[i,v(b)])):void 0,required:u.required,items:u.items?v(u.items):void 0}}return{type:"string"}};return{type:l.type,properties:l.properties?Object.fromEntries(Object.entries(l.properties).map(([o,u])=>[o,v(u)])):void 0,required:l.required}})(s),[s]);c.useEffect(()=>{const g=(v,o="")=>{const u={};return v.type==="object"&&v.properties&&Object.entries(v.properties).forEach(([i,b])=>{const w=o?`${o}.${i}`:i;b.default!==void 0?u[i]=b.default:b.type==="string"?u[i]="":b.type==="number"||b.type==="integer"?u[i]=0:b.type==="boolean"?u[i]=!1:b.type==="array"?u[i]=[]:b.type==="object"&&(b.properties?u[i]=g(b,w):u[i]={})}),u};let l=g(y);if(x)try{const v=localStorage.getItem(x);if(v){const o=JSON.parse(v);l={...l,...o}}}catch(v){console.warn("Failed to load saved form data:",v)}T(l)},[y,x]),c.useEffect(()=>{C&&Object.keys(p).length>0&&(R(JSON.stringify(p,null,2)),z(""))},[C,p]);const $=g=>{R(g),z("");try{const l=JSON.parse(g);if(T(l),x)try{localStorage.setItem(x,JSON.stringify(l))}catch(v){console.warn("Failed to save form data to localStorage:",v)}}catch{z(n("tool.invalidJsonFormat"))}},M=()=>{R(JSON.stringify(p,null,2)),z(""),D(!0)},_=()=>{if(N.trim())try{const g=JSON.parse(N);T(g),z(""),D(!1)}catch{z(n("tool.fixJsonBeforeSwitching"));return}else D(!1)},S=(g,l)=>{T(v=>{const o={...v},u=g.split(".");let i=o;for(let b=0;b<u.length-1;b++)i[u[b]]||(i[u[b]]={}),i=i[u[b]];if(i[u[u.length-1]]=l,x)try{localStorage.setItem(x,JSON.stringify(o))}catch(b){console.warn("Failed to save form data to localStorage:",b)}return o}),F[g]&&d(v=>{const o={...v};return delete o[g],o})},K=()=>{const g={},l=(v,o,u="")=>{v.type==="object"&&v.properties&&Object.entries(v.properties).forEach(([i,b])=>{var B;const w=u?`${u}.${i}`:i,P=o==null?void 0:o[i];if((B=v.required)!=null&&B.includes(i)&&(P==null||P===""||Array.isArray(P)&&P.length===0)){g[w]=`${i} is required`;return}P!=null&&P!==""&&(b.type==="string"&&typeof P!="string"?g[w]=`${i} must be a string`:b.type==="number"&&typeof P!="number"?g[w]=`${i} must be a number`:b.type==="integer"&&(!Number.isInteger(P)||typeof P!="number")?g[w]=`${i} must be an integer`:b.type==="boolean"&&typeof P!="boolean"?g[w]=`${i} must be a boolean`:b.type==="array"&&Array.isArray(P)?b.items&&P.forEach((Z,k)=>{var A;((A=b.items)==null?void 0:A.type)==="object"&&b.items.properties&&l(b.items,Z,`${w}.${k}`)}):b.type==="object"&&typeof P=="object"&&l(b,P,w))})};return l(y,p),d(g),Object.keys(g).length===0},U=g=>{g.preventDefault(),K()&&a(p)},J=(g,l)=>l.split(".").reduce((v,o)=>v==null?void 0:v[o],g),X=(g,l,v,o)=>{const u=v==null?void 0:v[g];return l.type==="string"?l.enum?e.jsxs("select",{value:u||"",onChange:i=>o(i.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:n("tool.selectOption")}),l.enum.map((i,b)=>e.jsx("option",{value:i,children:i},b))]}):e.jsx("input",{type:"text",value:u||"",onChange:i=>o(i.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:l.description||n("tool.enterKey",{key:g})}):l.type==="number"||l.type==="integer"?e.jsx("input",{type:"number",step:l.type==="integer"?"1":"any",value:u??"",onChange:i=>{const b=i.target.value===""?"":l.type==="integer"?parseInt(i.target.value):parseFloat(i.target.value);o(b)},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"}):l.type==="boolean"?e.jsx("input",{type:"checkbox",checked:u||!1,onChange:i=>o(i.target.checked),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}):e.jsx("input",{type:"text",value:u||"",onChange:i=>o(i.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:l.description||n("tool.enterKey",{key:g})})},W=(g,l,v="")=>{var b,w,P,B,Z,k,A,E,V,re,ne,pe,xe,he;const o=v?`${v}.${g}`:g,u=J(p,o),i=F[o];if(l.type==="array"){const O=J(p,o)||[];return e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[g,(v?(w=(b=J(y,v))==null?void 0:b.required)==null?void 0:w.includes(g):(P=y.required)==null?void 0:P.includes(g))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),l.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:l.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:[O.map((L,q)=>{var ie,le,ce;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:n("tool.item",{index:q+1})}),e.jsx("button",{type:"button",onClick:()=>{const G=[...O];G.splice(q,1),S(o,G)},className:"text-status-red hover:text-red-700 text-sm",children:n("common.remove")})]}),((ie=l.items)==null?void 0:ie.type)==="string"&&l.items.enum?e.jsxs("select",{value:L||"",onChange:G=>{const Q=[...O];Q[q]=G.target.value,S(o,Q)},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:n("tool.selectOption")}),l.items.enum.map((G,Q)=>e.jsx("option",{value:G,children:G},Q))]}):((le=l.items)==null?void 0:le.type)==="object"&&l.items.properties?e.jsx("div",{className:"space-y-3",children:Object.entries(l.items.properties).map(([G,Q])=>{var de,me;return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:[G,((me=(de=l.items)==null?void 0:de.required)==null?void 0:me.includes(G))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),X(G,Q,L,ge=>{const ae=[...O];ae[q]={...ae[q],[G]:ge},S(o,ae)})]},G)})}):e.jsx("input",{type:"text",value:L||"",onChange:G=>{const Q=[...O];Q[q]=G.target.value,S(o,Q)},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:n("tool.enterValue",{type:((ce=l.items)==null?void 0:ce.type)||"value"})})]},q)}),e.jsx("button",{type:"button",onClick:()=>{var q;const L=((q=l.items)==null?void 0:q.type)==="object"?{}:"";S(o,[...O,L])},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:n("tool.addItem",{key:g})})]}),i&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:i})]},o)}return l.type==="object"?l.properties?e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[g,(v?(Z=(B=J(y,v))==null?void 0:B.required)==null?void 0:Z.includes(g):(k=y.required)==null?void 0:k.includes(g))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),l.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:l.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(l.properties).map(([O,L])=>W(O,L,o))}),i&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:i})]},o):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[g,(v?(E=(A=J(y,v))==null?void 0:A.required)==null?void 0:E.includes(g):(V=y.required)==null?void 0:V.includes(g))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"}),e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(JSON object)"})]}),l.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:l.description}),e.jsx("textarea",{value:typeof u=="object"?JSON.stringify(u,null,2):u||"{}",onChange:O=>{try{const L=JSON.parse(O.target.value);S(o,L)}catch{S(o,O.target.value)}},placeholder:`{
3
+ "key": "value"
4
+ }`,className:`w-full border rounded-md px-3 py-2 font-mono text-sm ${i?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`,rows:4}),i&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:i})]},o):l.type==="string"?l.enum?e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[g,(v?!1:(re=y.required)==null?void 0:re.includes(g))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),l.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:l.description}),e.jsxs("select",{value:u||"",onChange:O=>S(o,O.target.value),className:`w-full border rounded-md px-3 py-2 ${i?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[e.jsx("option",{value:"",children:n("tool.selectOption")}),l.enum.map((O,L)=>e.jsx("option",{value:O,children:O},L))]}),i&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:i})]},o):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[g,(v?!1:(ne=y.required)==null?void 0:ne.includes(g))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),l.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:l.description}),e.jsx("input",{type:"text",value:u||"",onChange:O=>S(o,O.target.value),className:`w-full border rounded-md px-3 py-2 ${i?"border-red":"border-gray-200"} focus:outline-none form-input`}),i&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:i})]},o):l.type==="number"||l.type==="integer"?e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[g,(v?!1:(pe=y.required)==null?void 0:pe.includes(g))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),l.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:l.description}),e.jsx("input",{type:"number",step:l.type==="integer"?"1":"any",value:u??"",onChange:O=>{const L=O.target.value===""?"":l.type==="integer"?parseInt(O.target.value):parseFloat(O.target.value);S(o,L)},className:`w-full border rounded-md px-3 py-2 form-input ${i?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`}),i&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:i})]},o):l.type==="boolean"?e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",checked:u||!1,onChange:O=>S(o,O.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:[g,(v?!1:(xe=y.required)==null?void 0:xe.includes(g))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]})]}),l.description&&e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:l.description}),i&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:i})]},o):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[g,(v?!1:(he=y.required)==null?void 0:he.includes(g))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"}),e.jsxs("span",{className:"text-xs text-gray-500 ml-1",children:["(",l.type,")"]})]}),l.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:l.description}),e.jsx("input",{type:"text",value:u||"",onChange:O=>S(o,O.target.value),placeholder:n("tool.enterValue",{type:l.type}),className:`w-full border rounded-md px-3 py-2 ${i?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500 form-input`}),i&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:i})]},o)};return y.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:m}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("button",{type:"button",onClick:_,className:`hub-btn sm ${C?"":"primary"}`,children:n("tool.formMode")}),e.jsx("button",{type:"button",onClick:M,className:`hub-btn sm ${C?"primary":""}`,children:n("tool.jsonMode")})]})]}),C?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:n("tool.jsonConfiguration")}),e.jsx("textarea",{value:N,onChange:g=>$(g.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 ${f?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`}),f&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:f})]}),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:n("tool.cancel")}),e.jsx("button",{onClick:()=>{try{const g=JSON.parse(N);a(g)}catch{z(n("tool.invalidJsonFormat"))}},disabled:r||!!f,className:"hub-btn sm primary",children:n(r?"tool.running":"tool.runTool")})]})]}):e.jsxs("form",{onSubmit:U,className:"space-y-4",children:[Object.entries(y.properties||{}).map(([g,l])=>W(g,l)),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:n("tool.cancel")}),e.jsx("button",{type:"submit",disabled:r,className:"hub-btn sm primary",children:n(r?"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:n("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:n("tool.cancel")}),e.jsx("button",{onClick:()=>a({}),disabled:r,className:"hub-btn primary",children:n(r?"tool.running":"tool.runTool")})]})]})},fs=({result:s,onClose:a})=>{const{t}=Y(),r=s.content,x=d=>d?d.startsWith("image/")?d:`image/${d}`:"image/png",m=d=>{if(!d)return[];if(Array.isArray(d))return d.flatMap(N=>m(N));if(typeof d!="object")return[];const C=[];d.type==="image"&&d.data&&C.push({data:String(d.data),mimeType:x(d.mimeType||d.mime_type)});const D=d.image_base64||d.imageBase64||d.image_data||d.imageData||d.base64;return D&&C.push({data:String(D),mimeType:x(d.image_mimeType||d.image_mime_type||d.mimeType||d.mime_type)}),d.image&&typeof d.image=="object"&&C.push(...m(d.image)),Array.isArray(d.images)&&C.push(...m(d.images)),Array.isArray(d.content)&&C.push(...m(d.content)),C},n=d=>{const C=[];try{const R=JSON.parse(d);if(C.push(...m(R)),C.length>0)return C}catch{}const D=/data:image\/(png|jpe?g|gif|webp);base64,([A-Za-z0-9+/=]+)/g;let N;for(;(N=D.exec(d))!==null;){const R=`image/${N[1]==="jpg"?"jpeg":N[1]}`;C.push({data:N[2],mimeType:R})}return C},p=d=>{try{const C=JSON.parse(d),D=N=>{if(Array.isArray(N))return N.map(D);if(N&&typeof N=="object"){const R={};for(const[f,z]of Object.entries(N))typeof z=="string"&&f.toLowerCase().includes("base64")?R[f]="[base64 omitted]":R[f]=D(z);return R}return N};return JSON.stringify(D(C),null,2)}catch{return d.replace(/data:image\/(png|jpe?g|gif|webp);base64,[A-Za-z0-9+/=]+/g,"[image data omitted]")}},T=d=>Array.isArray(d)?d.map((C,D)=>e.jsx("div",{className:"mb-3 last:mb-0",children:F(C)},D)):F(d),F=d=>{if(typeof d=="string"){const C=n(d),D=p(d);return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[C.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:C.map((N,R)=>e.jsx("img",{src:`data:${N.mimeType||"image/png"};base64,${N.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"},R))}),e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:D})]})}if(typeof d=="object"&&d!==null){if(d.type==="text"&&d.text){const C=n(d.text),D=p(d.text);return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[C.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:C.map((N,R)=>e.jsx("img",{src:`data:${N.mimeType||"image/png"};base64,${N.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"},R))}),e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:D})]})}if(d.type==="image"&&d.data)return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("img",{src:`data:${d.mimeType||"image/png"};base64,${d.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"})});try{const C=typeof d=="string"?JSON.parse(d):d;return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-2",children:t("tool.jsonResponse")}),e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(C,null,2)})]})}catch{return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(d)})})}}return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(d)})})};return e.jsxs("div",{className:"border border-gray-300 rounded-lg bg-white dark:bg-gray-800 shadow-sm",children:[e.jsx("div",{className:"border-b border-gray-300 px-4 py-3 bg-gray-50 dark:bg-gray-800 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[s.success?e.jsx(_e,{size:20,className:"text-status-green"}):e.jsx(Oe,{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:a,className:"text-gray-400 hover:text-gray-600 text-sm",children:"✕"})]})}),e.jsx("div",{className:"p-4",children:s.success?e.jsx("div",{children:s.content&&s.content.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:t("tool.result")}),T(s.content)]}):e.jsx("div",{className:"text-sm text-gray-500 italic",children:t("tool.noContent")})}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-3",children:[e.jsx(ye,{size:16,className:"text-red-500"}),e.jsx("span",{className:"text-sm font-medium text-red-700",children:t("tool.error")})]}),r&&r.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:t("tool.errorDetails")}),T(r)]}):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")})})]})})]})},oe=({title:s,onClick:a,disabled:t=!1,loading:r=!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:a,disabled:t,title:s,"aria-label":s,children:e.jsx(ts,{size:14,className:r?"animate-spin":""})});function bs(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 js=({tool:s,server:a,readOnly:t=!1,onToggle:r,onDescriptionUpdate:x})=>{const{t:m}=Y(),{showToast:n}=ke(),{nameSeparator:p}=Ce(),[T,F]=c.useState(!1),[d,C]=c.useState(!1),[D,N]=c.useState(!1),[R,f]=c.useState(null),[z,y]=c.useState(!1),[$,M]=c.useState(!1),[_,S]=c.useState(s.description||""),K=c.useRef(null),U=c.useRef(null),[J,X]=c.useState(0),[W,g]=c.useState(!1);c.useEffect(()=>{z&&K.current&&(K.current.focus(),J>0&&(K.current.style.width=`${J+20}px`))},[z,J]),c.useEffect(()=>{!z&&U.current&&X(U.current.offsetWidth)},[z,_]),c.useEffect(()=>{S(s.description||"")},[s.description]);const l=c.useCallback(()=>`mcphub_tool_form_${a?`${a}_`:""}${s.name}`,[s.name,a]),v=c.useCallback(()=>{localStorage.removeItem(l())},[l]),o=E=>{!t&&r&&r(s.name,E)},u=()=>{t||y(!0)},i=async()=>{if(!t)try{const E=await Be(a,s.name,_);E.success?(y(!1),x&&x(s.name,_)):(S(s.description||""),console.error("Failed to update tool description:",E.error))}catch(E){console.error("Error updating tool description:",E),S(s.description||""),y(!1)}},b=E=>{S(E.target.value)},w=async()=>{if(!t){M(!0);try{const E=await Ve(a,s.name);if(E.success){const V=E.description||"";S(V),y(!1),x==null||x(s.name,V,{restored:!0})}else n(E.error||m("tool.restoreDefaultFailed"),"error")}catch(E){console.error("Error resetting tool description:",E),n(m("tool.restoreDefaultFailed"),"error")}finally{M(!1)}}},P=E=>{E.key==="Enter"?i():E.key==="Escape"&&(S(s.description||""),y(!1))},B=async E=>{E.stopPropagation();try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(s.name),g(!0),n(m("common.copySuccess"),"success"),setTimeout(()=>g(!1),2e3);else{const V=document.createElement("textarea");V.value=s.name,V.style.position="fixed",V.style.left="-9999px",document.body.appendChild(V),V.focus(),V.select();try{document.execCommand("copy"),g(!0),n(m("common.copySuccess"),"success"),setTimeout(()=>g(!1),2e3)}catch(re){n(m("common.copyFailed"),"error"),console.error("Copy to clipboard failed:",re)}document.body.removeChild(V)}}catch(V){n(m("common.copyFailed"),"error"),console.error("Copy to clipboard failed:",V)}},Z=async E=>{N(!0);try{E=Object.fromEntries(Object.entries(E).filter(([re,ne])=>!bs(ne)));const V=await Ue({toolName:s.name,arguments:E},a);f(V)}catch(V){f({success:!1,error:V instanceof Error?V.message:"Unknown error occurred"})}finally{N(!1)}},k=()=>{C(!1),v(),f(null)},A=()=>{f(null)};return e.jsxs("div",{className:"hub-card overflow-hidden",style:{marginBottom:8},children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 px-3 py-2.5 cursor-pointer hover:bg-[var(--hub-surface-hover)] transition-colors",onClick:E=>{E.stopPropagation(),F(!T)},children:[e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"hub-mono font-medium",style:{fontSize:13,color:"var(--hub-ink)"},children:s.name.replace(a+p,"")}),e.jsx("button",{className:"hub-icon-btn sm",onClick:B,title:m("common.copy"),children:W?e.jsx(ue,{size:12,style:{color:"var(--hub-ok)"}}):e.jsx(be,{size:12})}),e.jsx("span",{className:"flex items-center gap-1",style:{fontSize:12,color:"var(--hub-ink-3)"},children:z?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:K,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:J>0?`${J+20}px`:160,minWidth:80},value:_,onChange:b,onKeyDown:P,onClick:E=>E.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:E=>{E.stopPropagation(),i()},disabled:$,children:e.jsx(ue,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(oe,{title:m("tool.restoreDefault"),onClick:E=>{E.stopPropagation(),w()},disabled:$,loading:$})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:U,children:_||m("tool.noDescription")}),!t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"hub-icon-btn sm",onClick:E=>{E.stopPropagation(),u()},children:e.jsx(Ee,{size:12})}),e.jsx(oe,{title:m("tool.restoreDefault"),onClick:E=>{E.stopPropagation(),w()},disabled:$,loading:$})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("div",{onClick:E=>E.stopPropagation(),children:e.jsx(Se,{checked:s.enabled??!0,onCheckedChange:o,disabled:D||t})}),e.jsxs("button",{onClick:E=>{E.stopPropagation(),F(!0),C(!0)},className:"hub-btn sm",style:{color:"var(--hub-accent)"},disabled:D||!s.enabled,children:[D?e.jsx(Ae,{size:12,className:"animate-spin"}):e.jsx(Me,{size:12}),e.jsx("span",{children:m(D?"tool.running":"tool.run")})]}),e.jsx("button",{className:"hub-icon-btn sm",children:T?e.jsx(ze,{size:14}):e.jsx(ve,{size:14})})]})]}),T&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",padding:"10px 12px",display:"flex",flexDirection:"column",gap:10},children:[!d&&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:m("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)})]}),d&&e.jsxs("div",{style:{border:"1px solid var(--hub-line)",borderRadius:8,padding:14},children:[e.jsx(We,{schema:s.inputSchema||{type:"object"},onSubmit:Z,onCancel:k,loading:D,storageKey:l(),title:m("tool.runToolWithName",{name:s.name.replace(a+p,"")})}),R&&e.jsx("div",{style:{marginTop:12},children:e.jsx(fs,{result:R,onClose:A})})]})]})]})},ys=async(s,a)=>{try{const t=a?`/prompts/call/${a}`:"/prompts/call",r=await te(t,{promptName:s.promptName,arguments:s.arguments});return r.success?{success:!0,data:r.data}:{success:!1,error:r.message||"Prompt call failed"}}catch(t){return console.error("Error calling prompt",{promptName:s.promptName,server:a,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},Le=async(s,a)=>{try{const t=await te(`/mcp/${encodeURIComponent(a||"")}/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:a,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},vs=async(s,a,t)=>{try{const r=await te(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(a)}/toggle`,{enabled:t});return{success:r.success,error:r.success?void 0:r.message}}catch(r){return console.error("Error toggling prompt",{serverName:s,promptName:a,enabled:t,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},qe=async(s,a,t)=>{try{const r=await je(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(a)}/description`,{description:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:r.success,error:r.success?void 0:r.message}}catch(r){return console.error("Error updating prompt description",{serverName:s,promptName:a,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},He=async(s,a)=>{var t;try{const r=await $e(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(a)}/description`,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:r.success,error:r.success?void 0:r.message,description:(t=r.data)==null?void 0:t.description}}catch(r){return console.error("Error resetting prompt description",{serverName:s,promptName:a,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},Ns=Object.freeze(Object.defineProperty({__proto__:null,callPrompt:ys,getPrompt:Le,resetPromptDescription:He,togglePrompt:vs,updatePromptDescription:qe},Symbol.toStringTag,{value:"Module"})),Ie=({result:s,onClose:a})=>{const{t}=Y(),r=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((m,n)=>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:[m.role,":"]})}),typeof m.content=="string"?e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:m.content}):typeof m.content=="object"&&m.content.type==="text"?e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:m.content.text}):e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(m.content,null,2)})]},n))})]})]});try{const m=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(m,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(_e,{size:20,className:"text-status-green"}):e.jsx(Oe,{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:a,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")}),r(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(ye,{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")})})]})})]})},ws=({prompt:s,server:a,readOnly:t=!1,onToggle:r,onDescriptionUpdate:x})=>{const{t:m}=Y(),{showToast:n}=ke(),{nameSeparator:p}=Ce(),[T,F]=c.useState(!1),[d,C]=c.useState(!1),[D,N]=c.useState(!1),[R,f]=c.useState(null),[z,y]=c.useState(!1),[$,M]=c.useState(!1),[_,S]=c.useState(s.description||""),K=c.useRef(null),U=c.useRef(null),[J,X]=c.useState(0);c.useEffect(()=>{z&&K.current&&(K.current.focus(),J>0&&(K.current.style.width=`${J+20}px`))},[z,J]),c.useEffect(()=>{!z&&U.current&&X(U.current.offsetWidth)},[z,_]),c.useEffect(()=>{S(s.description||"")},[s.description]);const W=c.useCallback(()=>`mcphub_prompt_form_${a?`${a}_`:""}${s.name}`,[s.name,a]),g=c.useCallback(()=>{localStorage.removeItem(W())},[W]),l=k=>{!t&&r&&r(s.name,k)},v=()=>{t||y(!0)},o=async()=>{if(!t){y(!1);try{const k=await qe(a,s.name,_);k.success?x&&x(s.name,_):(n(k.error||m("prompt.descriptionUpdateFailed"),"error"),S(s.description||""))}catch(k){console.error("Error updating prompt description:",k),n(m("prompt.descriptionUpdateFailed"),"error"),S(s.description||"")}}},u=async()=>{if(!t){M(!0);try{const k=await He(a,s.name);if(k.success){const A=k.description||"";S(A),y(!1),x==null||x(s.name,A,{restored:!0})}else n(k.error||m("prompt.restoreDefaultFailed"),"error")}catch(k){console.error("Error resetting prompt description:",k),n(m("prompt.restoreDefaultFailed"),"error")}finally{M(!1)}}},i=k=>{S(k.target.value)},b=k=>{k.key==="Enter"?o():k.key==="Escape"&&(S(s.description||""),y(!1))},w=async k=>{N(!0);try{const A=await Le({promptName:s.name,arguments:k},a);console.log("GetPrompt result:",A),f({success:A.success,data:A.data,error:A.error})}catch(A){f({success:!1,error:A instanceof Error?A.message:"Unknown error occurred"})}finally{N(!1)}},P=()=>{C(!1),g(),f(null)},B=()=>{f(null)},Z=()=>{if(!s.arguments||s.arguments.length===0)return{type:"object",properties:{},required:[]};const k={},A=[];return s.arguments.forEach(E=>{k[E.name]={type:"string",description:E.description||""},E.required&&A.push(E.name)}),{type:"object",properties:k,required:A}};return e.jsxs("div",{className:"hub-card overflow-hidden",style:{marginBottom:8},children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 px-3 py-2.5 cursor-pointer hover:bg-[var(--hub-surface-hover)] transition-colors",onClick:()=>F(!T),children:[e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"hub-mono font-medium",style:{fontSize:13,color:"var(--hub-ink)"},children:s.name.replace(a+p,"")}),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:z?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:K,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:J>0?`${J+20}px`:160,minWidth:80},value:_,onChange:i,onKeyDown:b,onClick:k=>k.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:k=>{k.stopPropagation(),o()},disabled:$,children:e.jsx(ue,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(oe,{title:m("prompt.restoreDefault"),onClick:k=>{k.stopPropagation(),u()},disabled:$,loading:$})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:U,children:_||m("tool.noDescription")}),!t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"hub-icon-btn sm",onClick:k=>{k.stopPropagation(),v()},children:e.jsx(Ee,{size:12})}),e.jsx(oe,{title:m("prompt.restoreDefault"),onClick:k=>{k.stopPropagation(),u()},disabled:$,loading:$})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("div",{onClick:k=>k.stopPropagation(),children:s.enabled!==void 0&&e.jsx(Se,{checked:s.enabled,onCheckedChange:l,disabled:D||t})}),e.jsxs("button",{onClick:k=>{k.stopPropagation(),F(!0),C(!0)},className:"hub-btn sm",style:{color:"var(--hub-accent)"},disabled:D||!s.enabled,children:[D?e.jsx(Ae,{size:12,className:"animate-spin"}):e.jsx(Me,{size:12}),e.jsx("span",{children:m(D?"tool.running":"tool.run")})]}),e.jsx("button",{className:"hub-icon-btn sm",children:T?e.jsx(ze,{size:14}):e.jsx(ve,{size:14})})]})]}),T&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",padding:"10px 12px",display:"flex",flexDirection:"column",gap:10},children:[d&&e.jsxs("div",{style:{border:"1px solid var(--hub-line)",borderRadius:8,padding:14},children:[e.jsx(We,{schema:Z(),onSubmit:w,onCancel:P,loading:D,storageKey:W(),title:m("prompt.runPromptWithName",{name:s.name.replace(a+p,"")})}),R&&e.jsx("div",{style:{marginTop:12},children:e.jsx(Ie,{result:R,onClose:B})})]}),!d&&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:m("tool.parameters")}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:s.arguments.map((k,A)=>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:k.name}),k.required&&e.jsx("span",{style:{color:"var(--hub-err)",fontSize:12},children:"*"})]}),k.description&&e.jsx("p",{style:{fontSize:12,color:"var(--hub-ink-3)",margin:"2px 0 0"},children:k.description})]}),k.title&&e.jsx("span",{style:{fontSize:11,color:"var(--hub-ink-3)"},children:k.title})]},A))})]}),!d&&R&&e.jsx("div",{children:e.jsx(Ie,{result:R,onClose:B})})]})]})},ks=({resource:s,readOnly:a=!1,onToggle:t,onDescriptionUpdate:r})=>{const{t:x}=Y(),[m,n]=c.useState(!1),[p,T]=c.useState(!1),[F,d]=c.useState(!1),[C,D]=c.useState(s.description||""),N=c.useRef(null),R=c.useRef(null),[f,z]=c.useState(0);c.useEffect(()=>{p&&N.current&&(N.current.focus(),f>0&&(N.current.style.width=`${f+20}px`))},[p,f]),c.useEffect(()=>{!p&&R.current&&z(R.current.offsetWidth)},[p,C]),c.useEffect(()=>{D(s.description||"")},[s.description]);const y=S=>{!a&&t&&t(s.uri,S)},$=async()=>{a||(T(!1),r&&await r(s.uri,C))},M=async()=>{if(!a){d(!0);try{await(r==null?void 0:r(s.uri,"",{restored:!0})),T(!1)}finally{d(!1)}}},_=S=>{S.key==="Enter"?$():S.key==="Escape"&&(D(s.description||""),T(!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:()=>n(!m),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"hub-mono font-medium truncate",style:{fontSize:13,color:"var(--hub-ink)"},children:s.name||s.uri}),e.jsx("span",{className:"hub-mono truncate",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:s.uri})]}),e.jsx("span",{className:"flex items-center gap-1 mt-0.5",style:{fontSize:12,color:"var(--hub-ink-3)"},children:p?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:N,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:f>0?`${f+20}px`:160,minWidth:80},value:C,onChange:S=>D(S.target.value),onKeyDown:_,onClick:S=>S.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:S=>{S.stopPropagation(),$()},disabled:F,children:e.jsx(ue,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(oe,{title:x("builtinResources.restoreDefault"),onClick:S=>{S.stopPropagation(),M()},disabled:F,loading:F})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:R,children:C||x("tool.noDescription")}),!a&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"hub-icon-btn sm",onClick:S=>{S.stopPropagation(),T(!0)},children:e.jsx(Ee,{size:12})}),e.jsx(oe,{title:x("builtinResources.restoreDefault"),onClick:S=>{S.stopPropagation(),M()},disabled:F,loading:F})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("div",{onClick:S=>S.stopPropagation(),children:e.jsx(Se,{checked:s.enabled!==!1,onCheckedChange:y,disabled:a})}),e.jsx("button",{className:"hub-icon-btn sm",children:m?e.jsx(ze,{size:14}):e.jsx(ve,{size:14})})]})]}),m&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",padding:"8px 12px"},children:[e.jsxs("span",{className:"hub-sect",children:[x("builtinResources.mimeType"),":"]})," ",e.jsx("span",{style:{fontSize:12,color:"var(--hub-ink-2)"},children:s.mimeType||"text/plain"})]})]})},Cs=(s,a)=>a?a.isAdmin?!0:!!(s.owner&&s.owner===a.username):!1,Re=(s,a)=>a?a==="stdio"?s("server.typeStdio")||"stdio":a==="sse"?s("server.typeSse")||"sse":a==="streamable-http"?s("server.typeStreamableHttp")||"http":a==="openapi"?s("server.typeOpenapi")||"openapi":a:null,Ss=({server:s,onRemove:a,onEdit:t,onToggle:r,onRefresh:x,onReload:m})=>{var le,ce,G,Q,de,me,ge,ae,Te;const{t:n}=Y(),{showToast:p}=ke(),{exportMCPSettings:T,installConfig:F}=Ce(),{auth:d}=Ze(),C=((le=F==null?void 0:F.baseUrl)==null?void 0:le.replace(/\/+$/,""))||"",[D,N]=c.useState(!1),[R,f]=c.useState(null),[z,y]=c.useState(!1),[$,M]=c.useState(!1),[_,S]=c.useState(!1),[K,U]=c.useState(!1),[J,X]=c.useState(!1),[W,g]=c.useState(!1),l=c.useRef(null),v=c.useRef(null);c.useEffect(()=>{const h=j=>{l.current&&!l.current.contains(j.target)&&U(!1),v.current&&!v.current.contains(j.target)&&X(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);const o=((ce=s.tools)==null?void 0:ce.length)||0,u=((G=s.tools)==null?void 0:G.filter(h=>h.enabled!==!1).length)||0,i=((Q=s.prompts)==null?void 0:Q.length)||0,b=((de=s.prompts)==null?void 0:de.filter(h=>h.enabled!==!1).length)||0,w=((me=s.resources)==null?void 0:me.length)||0,P=((ge=s.resources)==null?void 0:ge.filter(h=>h.enabled!==!1).length)||0,B=async h=>{if(h.stopPropagation(),!(!q||$||!r)){M(!0);try{await r(s,s.enabled===!1)}finally{M(!1)}}},Z=async h=>{if(h.stopPropagation(),U(!1),!(!q||_||!m)){S(!0);try{await m(s)?p(n("server.reloadSuccess")||"Server reloaded successfully","success"):p(n("server.reloadError",{serverName:s.name})||"Failed to reload","error")}finally{S(!1)}}},k=async h=>{try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(h),!0}catch{}try{const j=document.createElement("textarea");j.value=h,j.style.position="fixed",j.style.left="-9999px",document.body.appendChild(j),j.focus(),j.select();const I=document.execCommand("copy");return document.body.removeChild(j),I}catch{return!1}},A=async h=>{if(h.stopPropagation(),!s.error)return;await k(s.error)?(g(!0),p(n("common.copySuccess")||"Copied","success"),setTimeout(()=>g(!1),1500)):p(n("common.copyFailed")||"Copy failed","error")},E=async h=>{if(h.stopPropagation(),U(!1),!!q)try{const j=await T(s.name);if(!j||!j.success||!j.data){p((j==null?void 0:j.message)||n("common.copyFailed")||"Copy failed","error");return}const I=JSON.stringify(j.data,null,2),H=await k(I);p(H?n("common.copySuccess")||"Copied":n("common.copyFailed")||"Copy failed",H?"success":"error")}catch(j){console.error("Error copying server configuration:",j),p(n("common.copyFailed")||"Copy failed","error")}},V=h=>{var j;if(h.stopPropagation(),(j=s.oauth)!=null&&j.authorizationUrl){const ee=window.screen.width/2-300,se=window.screen.height/2-700/2;window.open(s.oauth.authorizationUrl,"OAuth Authorization",`width=600,height=700,left=${ee},top=${se}`),p(n("status.oauthWindowOpened"),"info")}},re=async(h,j)=>{try{const{toggleTool:I}=await fe(async()=>{const{toggleTool:ee}=await Promise.resolve().then(()=>gs);return{toggleTool:ee}},void 0,import.meta.url),H=await I(s.name,h,j);H.success?(p(n(j?"tool.enableSuccess":"tool.disableSuccess",{name:h}),"success"),x==null||x()):p(H.error||n("tool.toggleFailed"),"error")}catch(I){console.error(I),p(n("tool.toggleFailed"),"error")}},ne=async(h,j)=>{try{const{togglePrompt:I}=await fe(async()=>{const{togglePrompt:ee}=await Promise.resolve().then(()=>Ns);return{togglePrompt:ee}},void 0,import.meta.url),H=await I(s.name,h,j);H.success?(p(n(j?"tool.enableSuccess":"tool.disableSuccess",{name:h}),"success"),x==null||x()):p(H.error||n("tool.toggleFailed"),"error")}catch(I){console.error(I),p(n("tool.toggleFailed"),"error")}},pe=async(h,j)=>{try{const{toggleResource:I}=await fe(async()=>{const{toggleResource:ee}=await import("./resourceService-BgjWoJFK.js");return{toggleResource:ee}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),H=await I(s.name,h,j);H.success?(p(n(j?"tool.enableSuccess":"tool.disableSuccess",{name:h}),"success"),x==null||x()):p(H.error||n("tool.toggleFailed"),"error")}catch(I){console.error(I),p(n("tool.toggleFailed"),"error")}},xe=(h,j,I)=>{p(I!=null&&I.restored?n("tool.restoreDefaultSuccess"):n("tool.descriptionUpdateSuccess"),"success"),x==null||x()},he=(h,j,I)=>{p(I!=null&&I.restored?n("prompt.restoreDefaultSuccess"):n("prompt.descriptionUpdateSuccess"),"success"),x==null||x()},O=async(h,j,I)=>{try{const{updateResourceDescription:H,resetResourceDescription:ee}=await fe(async()=>{const{updateResourceDescription:Ge,resetResourceDescription:Ke}=await import("./resourceService-BgjWoJFK.js");return{updateResourceDescription:Ge,resetResourceDescription:Ke}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),se=I!=null&&I.restored?await ee(s.name,h):await H(s.name,h,j);se.success?(p(I!=null&&I.restored?n("builtinResources.restoreDefaultSuccess"):n("builtinResources.descriptionUpdateSuccess"),"success"),x==null||x()):p(se.error||(I!=null&&I.restored?n("builtinResources.restoreDefaultFailed"):n("builtinResources.descriptionUpdateFailed")),"error")}catch(H){console.error(H),p(I!=null&&I.restored?n("builtinResources.restoreDefaultFailed"):n("builtinResources.descriptionUpdateFailed"),"error")}};(()=>{var I;const h=s.config;if(!h)return"";if(h.url)return h.url;const j=[];return h.command&&j.push(h.command),(I=h.args)!=null&&I.length&&j.push(...h.args),j.join(" ")})();const L=s.enabled!==!1,q=Cs(s,d.user),ie=`${C}/mcp/${s.name}`;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hub-card overflow-visible",style:{marginBottom:10,opacity:L?1:.7},children:[e.jsxs("div",{className:"grid items-center gap-3 px-4 py-3 cursor-pointer hover:bg-[var(--hub-surface-hover)] transition-colors",style:{gridTemplateColumns:"minmax(220px,1.9fr) minmax(110px,0.9fr) minmax(120px,0.95fr) minmax(180px,1.1fr) 72px 36px"},onClick:()=>N(!D),children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx(ve,{size:12,style:{color:"var(--hub-ink-3)",transform:D?"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:L?"var(--hub-ink)":"var(--hub-ink-3)"},children:s.name}),s.error&&e.jsxs("div",{className:"relative",ref:v,children:[e.jsx("button",{onClick:h=>{h.stopPropagation(),X(j=>!j)},className:"text-[var(--hub-err)] hover:opacity-80","aria-label":n("server.viewErrorDetails"),children:e.jsx(ye,{size:14})}),J&&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:h=>h.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:n("server.errorDetails")}),e.jsx("button",{onClick:A,className:"hub-icon-btn sm",title:n("common.copy"),children:W?e.jsx(ue,{size:12,className:"text-[var(--hub-ok)]"}):e.jsx(be,{size:12})})]}),e.jsx("button",{onClick:()=>X(!1),className:"hub-icon-btn sm","aria-label":n("app.closeButton"),children:e.jsx(Ne,{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})})]})]})]}),((ae=s.config)==null?void 0:ae.description)&&e.jsx("div",{className:"text-[11.5px] truncate",style:{color:"var(--hub-ink-3)",marginTop:1},title:s.config.description,children:s.config.description})]})]}),e.jsx("div",{className:"min-w-0",children:e.jsx(ss,{status:s.status,enabled:s.enabled,onAuthClick:V})}),e.jsx("div",{className:"min-w-0",children:(Te=s.config)!=null&&Te.type?e.jsx("span",{className:"hub-tag",title:Re(n,s.config.type)??void 0,children:Re(n,s.config.type)}):e.jsx("span",{style:{color:"var(--hub-ink-3)",fontSize:12},children:"—"})}),e.jsx("div",{className:"flex min-w-0 items-center gap-1.5",children:[{key:"tools",icon:De,total:o,enabled:u,label:n("server.tools")},{key:"prompts",icon:Pe,total:i,enabled:b,label:n("server.prompts")},{key:"resources",icon:Fe,total:w,enabled:P,label:n("nav.resources")}].map(({key:h,icon:j,total:I,enabled:H,label:ee})=>{const se=I===0;return e.jsxs("span",{className:"inline-flex items-center gap-1 hub-mono hub-num",title:`${ee}: ${H}/${I}`,style:{padding:"2px 7px",borderRadius:6,fontSize:11.5,lineHeight:"16px",background:se?"transparent":"var(--hub-bg-2)",border:"1px solid",borderColor:se?"transparent":"var(--hub-line-2)",color:se?"var(--hub-ink-3)":"var(--hub-ink-2)"},children:[e.jsx(j,{size:12,style:{color:"var(--hub-ink-3)",flexShrink:0}}),e.jsx("span",{children:se?"0":`${H}/${I}`})]},h)})}),e.jsx("div",{className:"flex items-center justify-center",children:e.jsx("button",{type:"button",className:"hub-switch"+(L?" on":""),onClick:B,disabled:$||!q,"aria-label":n(L?"server.disable":"server.enable")})}),e.jsxs("div",{className:"relative",ref:l,children:[q&&e.jsx("button",{className:"hub-icon-btn",onClick:h=>{h.stopPropagation(),U(j=>!j)},"aria-label":"More",children:e.jsx(rs,{size:14})}),q&&K&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 hub-card",style:{minWidth:160,padding:4},onClick:h=>h.stopPropagation(),children:[e.jsxs("button",{onClick:h=>{h.stopPropagation(),U(!1),t(s)},className:"flex items-center gap-2 w-full px-2.5 py-1.5 text-[13px] rounded-md hover:bg-[var(--hub-surface-hover)] text-left",style:{color:"var(--hub-ink)"},children:[e.jsx(ns,{size:13})," ",n("server.edit")]}),e.jsxs("button",{onClick:E,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(be,{size:13})," ",n("server.copy")]}),m&&e.jsxs("button",{onClick:Z,disabled:_||$||!L,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(we,{size:13})," ",n("server.reload")]}),e.jsx("div",{style:{height:1,background:"var(--hub-line-2)",margin:"4px 0"}}),e.jsxs("button",{onClick:h=>{h.stopPropagation(),U(!1),y(!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(as,{size:13})," ",n("server.delete")]})]})]})]}),D&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",background:"var(--hub-bg-2)",padding:"14px 16px 16px 38px"},children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2 flex-wrap",children:[[{key:"tools",icon:e.jsx(De,{size:12}),label:n("server.tools"),count:o,enabled:u},{key:"prompts",icon:e.jsx(Pe,{size:12}),label:n("server.prompts"),count:i,enabled:b},{key:"resources",icon:e.jsx(Fe,{size:12}),label:n("nav.resources"),count:w,enabled:P}].map(h=>{const j=R===h.key;return e.jsxs("button",{onClick:()=>f(j?null:h.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:j?"var(--hub-surface)":"transparent",border:"1px solid "+(j?"var(--hub-line)":"transparent"),color:j?"var(--hub-ink)":"var(--hub-ink-2)"},children:[h.icon,e.jsx("span",{children:h.label}),e.jsx("span",{className:"hub-mono hub-num",style:{color:"var(--hub-ink-3)",fontSize:11},children:h.count===0?"0":`${h.enabled}/${h.count}`})]},h.key)}),e.jsx("div",{className:"ml-auto max-w-full flex-shrink-0",children:e.jsxs("div",{className:"hub-endpoint",style:{height:26},children:[e.jsx("div",{className:"hub-endpoint-label",children:"/mcp/"}),e.jsx("div",{className:"hub-endpoint-url",title:ie,style:{maxWidth:200},children:s.name}),e.jsx("button",{type:"button",className:"hub-endpoint-copy",onClick:async h=>{h.stopPropagation();const j=await k(ie);p(j?n("common.copySuccess")||"Copied":n("common.copyFailed")||"Failed",j?"success":"error")},title:n("common.copy"),children:e.jsx(be,{size:12})})]})})]}),R==="tools"&&s.tools&&e.jsx("div",{className:"space-y-3 mt-2",children:s.tools.map((h,j)=>e.jsx(js,{server:s.name,tool:h,readOnly:!q,onToggle:re,onDescriptionUpdate:xe},j))}),R==="prompts"&&s.prompts&&e.jsx("div",{className:"space-y-3 mt-2",children:s.prompts.map((h,j)=>e.jsx(ws,{server:s.name,prompt:h,readOnly:!q,onToggle:ne,onDescriptionUpdate:he},j))}),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:n("builtinResources.noResources")}):e.jsx("div",{className:"space-y-3",children:s.resources.map((h,j)=>e.jsx(ks,{resource:h,readOnly:!q,onToggle:pe,onDescriptionUpdate:O},`${h.uri}-${j}`))})})]})]}),e.jsx(ds,{isOpen:z,onClose:()=>y(!1),onConfirm:()=>{a(s.name),y(!1)},serverName:s.name})]})},Es=({onAdd:s})=>{const{t:a}=Y(),[t,r]=c.useState(!1),[x,m]=c.useState(null),[n,p]=c.useState(!1),[T,F]=c.useState(null),[d,C]=c.useState([]),D=()=>{r(!t),m(null),p(!1),F(null)},N=async()=>{T&&(await R(T),p(!1),F(null))},R=async z=>{try{m(null);const y=await te("/servers",z);if(!y.success){y&&y.message?m(y.message):m(a("server.addError"));return}r(!1),s()}catch(y){console.error("Error adding server:",y),navigator.onLine?y instanceof TypeError&&(y.message.includes("NetworkError")||y.message.includes("Failed to fetch"))?m(a("errors.serverConnection")):m(a("errors.serverAdd")):m(a("errors.network"))}},f=async z=>{try{const y=ms(z);y.length>0?(C(y),F(z),p(!0)):await R(z)}catch(y){console.error("Error processing server submission:",y),m(a("errors.serverAdd"))}};return e.jsxs("div",{children:[e.jsxs("button",{onClick:D,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"})}),a("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(Je,{onSubmit:f,onCancel:D,modalTitle:a("server.addServer"),formError:x})}),n&&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:a("server.confirmVariables")}),e.jsx("p",{className:"text-gray-600 mb-4",children:a("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:[a("server.detectedVariables"),":"]}),e.jsx("ul",{className:"mt-1 text-sm text-yellow-700",children:d.map((z,y)=>e.jsxs("li",{className:"font-mono",children:["$",`{${z}}`]},y))})]})]})}),e.jsx("p",{className:"text-gray-600 text-sm mb-6",children:a("server.confirmVariablesMessage")}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>{p(!1),F(null)},className:"hub-btn",children:a("common.cancel")}),e.jsx("button",{onClick:N,className:"hub-btn primary",children:a("server.confirmAndAdd")})]})]})})]})},zs=({server:s,onEdit:a,onCancel:t})=>{const{t:r}=Y(),[x,m]=c.useState(null),n=async p=>{try{m(null);const T=encodeURIComponent(s.name),F=p.name&&p.name!==s.name,d={config:p.config,...F?{newName:p.name}:{}},C=await je(`/servers/${T}`,d);if(!C.success){C&&C.message?m(C.message):m(r("server.updateError",{serverName:s.name}));return}a()}catch(T){console.error("Error updating server:",T),navigator.onLine?T instanceof TypeError&&(T.message.includes("NetworkError")||T.message.includes("Failed to fetch"))?m(r("errors.serverConnection")):m(r("errors.serverUpdate",{serverName:s.name})):m(r("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(Je,{onSubmit:n,onCancel:t,initialData:s,modalTitle:r("server.editTitle",{serverName:s.name}),formError:x})})},Ts=({onSuccess:s,onCancel:a})=>{const{t}=Y(),[r,x]=c.useState(!1),[m,n]=c.useState(!1),[p,T]=c.useState(null),[F,d]=c.useState(null),[C,D]=c.useState(!1),[N,R]=c.useState(null),[f,z]=c.useState(""),[y,$]=c.useState(!1),[M,_]=c.useState(""),S=o=>{o.preventDefault(),x(!0)},K=o=>{o.preventDefault(),x(!1)},U=o=>{o.preventDefault(),x(!1);const u=o.dataTransfer.files;if(u.length>0){const i=u[0];i.name.endsWith(".mcpb")?(d(i),T(null)):T(t("mcpb.invalidFileType"))}},J=o=>{const u=o.target.files;if(u&&u.length>0){const i=u[0];i.name.endsWith(".mcpb")?(d(i),T(null)):T(t("mcpb.invalidFileType"))}},X=async()=>{if(!F){T(t("mcpb.noFileSelected"));return}n(!0),T(null);try{const o=new FormData;o.append("mcpbFile",F);const u=await Ye(es("/mcpb/upload"),{method:"POST",body:o}),i=await u.json();if(!u.ok)throw new Error(i.message||`HTTP error! Status: ${u.status}`);if(i.success&&i.data)R(i.data.manifest),z(i.data.extractDir),D(!0);else throw new Error(i.message||t("mcpb.uploadFailed"))}catch(o){console.error("MCPB upload error:",o),T(o instanceof Error?o.message:t("mcpb.uploadFailed"))}finally{n(!1)}},W=async(o,u=!1)=>{var i;n(!0),T(null);try{const b=v(N,f,o);if(!u){const P=await Qe("/servers");if(P.success&&((i=P.data)==null?void 0:i.find(Z=>Z.name===o))){_(o),$(!0),n(!1);return}}let w;if(u?w=await je(`/servers/${encodeURIComponent(o)}`,{name:o,config:b}):w=await te("/servers",{name:o,config:b}),w.success)s(b);else throw new Error(w.message||t("mcpb.installFailed"))}catch(b){console.error("MCPB install error:",b),T(b instanceof Error?b.message:t("mcpb.installFailed")),n(!1)}},g=()=>{$(!1),M&&W(M,!0)},l=()=>{$(!1),_(""),n(!1)},v=(o,u,i)=>{var P;const b=((P=o.server)==null?void 0:P.mcp_config)||{},w={type:"stdio",command:b.command||"node",args:(b.args||[]).map(B=>B.replace("${__dirname}",u))};return b.env&&Object.keys(b.env).length>0&&(w.env={...b.env},Object.keys(w.env).forEach(B=>{typeof w.env[B]=="string"&&(w.env[B]=w.env[B].replace("${__dirname}",u))})),w};return C&&N?e.jsxs(e.Fragment,{children:[e.jsx(us,{isOpen:y,onClose:l,onConfirm:g,title:t("mcpb.serverExistsTitle"),message:t("mcpb.serverExistsConfirm",{serverName:M}),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 ${y?"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:a,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),p&&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:p})}),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"),":"]})," ",N.display_name||N.name]}),e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.version"),":"]})," ",N.version]}),e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.description"),":"]})," ",N.description]}),N.author&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.author"),":"]})," ",N.author.name]}),N.tools&&N.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:N.tools.map((o,u)=>e.jsxs("li",{children:[o.name," - ",o.description]},u))})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:t("mcpb.serverName")}),e.jsx("input",{type:"text",id:"serverName",defaultValue:N.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:a,disabled:m,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:()=>{const o=document.getElementById("serverName"),u=(o==null?void 0:o.value.trim())||N.name;W(u)},disabled:m,className:"hub-btn primary",children:m?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:a,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),p&&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:p})}),e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-8 text-center transition-colors ${r?"border-blue-500 bg-blue-50":F?"border-gray-500 ":"border-gray-300 hover:border-gray-400"}`,onDragOver:S,onDragLeave:K,onDrop:U,children:[F?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:F.name}),e.jsxs("p",{className:"text-xs text-gray-500",children:[(F.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:J,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:a,disabled:m,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:X,disabled:!F||m,className:"hub-btn primary flex items-center",children:m?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")})]})]})})},Ds=s=>Object.entries(s.mcpServers).map(([a,t])=>{const r={};return t.type==="sse"||t.type==="streamable-http"?(r.type=t.type,r.url=t.url,t.headers&&(r.headers=t.headers)):t.type==="openapi"?(r.type="openapi",r.openapi=t.openapi):(r.type="stdio",r.command=t.command,r.args=t.args||[],t.env&&(r.env=t.env),t.options&&(r.options=t.options)),{name:a,config:r}}),Ps=({onSuccess:s,onCancel:a})=>{const{t}=Y(),[r,x]=c.useState(""),[m,n]=c.useState(null),[p,T]=c.useState(!1),[F,d]=c.useState(null),C=`{
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.`,D=f=>{try{const z=JSON.parse(f.trim());return!z.mcpServers||typeof z.mcpServers!="object"?(n(t("jsonImport.invalidFormat")),null):z}catch{return n(t("jsonImport.parseError")),null}},N=()=>{n(null);const f=D(r);f&&d(Ds(f))},R=async()=>{if(F){T(!0),n(null);try{const f=await te("/servers/batch",{servers:F});if(f.success&&f.data){const{successCount:z,failureCount:y,results:$}=f.data;if(y>0){const M=$.filter(_=>!_.success).map(_=>`${_.name}: ${_.message||t("jsonImport.addFailed")}`);n(t("jsonImport.partialSuccess",{count:z,total:F.length})+`
35
+ `+M.join(`
36
+ `))}z>0&&s()}else n(f.message||t("jsonImport.importFailed"))}catch(f){console.error("Import error:",f),n(t("jsonImport.importFailed"))}finally{T(!1)}}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:t("jsonImport.title")}),e.jsx("button",{onClick:a,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),m&&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:m})}),F?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:F.map((f,z)=>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:f.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"),":"]})," ",f.config.type||"stdio"]}),f.config.command&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.command"),":"]})," ",f.config.command]}),f.config.args&&f.config.args.length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.arguments"),":"]})," ",f.config.args.join(" ")]}),f.config.url&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.url"),":"]})," ",f.config.url]}),f.config.env&&Object.keys(f.config.env).length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.envVars"),":"]})," ",Object.keys(f.config.env).join(", ")]}),f.config.headers&&Object.keys(f.config.headers).length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.headers"),":"]})," ",Object.keys(f.config.headers).join(", ")]})]})]})})},z))})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:()=>d(null),disabled:p,className:"hub-btn",children:t("common.back")}),e.jsx("button",{onClick:R,disabled:p,className:"hub-btn primary",children:p?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:r,onChange:f=>x(f.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:C}),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:a,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:N,disabled:!r.trim(),className:"hub-btn primary",children:t("jsonImport.preview")})]})]})]})})},Ws=()=>{const{t:s}=Y(),a=Xe(),{servers:t,allServers:r,error:x,setError:m,isLoading:n,pagination:p,currentPage:T,serversPerPage:F,setCurrentPage:d,setServersPerPage:C,handleServerAdd:D,handleServerEdit:N,handleServerRemove:R,handleServerToggle:f,handleServerReload:z,triggerRefresh:y}=xs({refreshOnMount:!0}),[$,M]=c.useState(null),[_,S]=c.useState(!1),[K,U]=c.useState(!1),[J,X]=c.useState(!1),[W,g]=c.useState("all"),[l,v]=c.useState(""),o=c.useMemo(()=>({all:r.length,online:r.filter(w=>w.status==="connected").length,issues:r.filter(w=>w.status!=="connected"&&w.enabled!==!1).length}),[r]),u=c.useMemo(()=>{const w=l.trim().toLowerCase();return t.filter(P=>{var Z,k;return W==="online"&&P.status!=="connected"||W==="issues"&&(P.status==="connected"||P.enabled===!1)?!1:w?(P.name+" "+(((Z=P.config)==null?void 0:Z.description)||"")+" "+(((k=P.tools)==null?void 0:k.map(A=>A.name).join(" "))||"")).toLowerCase().includes(w):!0})},[t,W,l]),i=async w=>{const P=await N(w);P&&M(P)},b=async()=>{S(!0);try{y(),await new Promise(w=>setTimeout(w,400))}finally{S(!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:o.all})," ",s("nav.servers").toLowerCase()," ·"," ",e.jsx("span",{className:"hub-num",children:o.online})," ",s("status.online")," ·"," ",e.jsx("span",{className:"hub-num",children:o.issues})," ",s("common.inactive")||"issues"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{className:"hub-btn",onClick:()=>a("/market"),children:[e.jsx(os,{size:13})," ",s("nav.market")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>X(!0),children:[e.jsx(is,{size:13})," ",s("jsonImport.button")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>U(!0),children:[e.jsx(ls,{size:13})," ",s("mcpb.upload")]}),e.jsxs("button",{className:"hub-btn",onClick:b,disabled:_,"aria-label":s("common.refresh"),children:[e.jsx(we,{size:13,className:_?"animate-spin":""}),s("common.refresh")]}),e.jsx(Es,{onAdd:D})]})]}),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(ye,{size:14,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate text-[13px]",children:x})]}),e.jsx("button",{className:"hub-icon-btn sm",onClick:()=>m(null),"aria-label":s("app.closeButton"),children:e.jsx(Ne,{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",o.all],["online",s("status.online"),o.online],["issues",s("common.inactive")||"Issues",o.issues]].map(([w,P,B])=>e.jsxs("button",{onClick:()=>g(w),className:"inline-flex items-center gap-1.5 px-3 text-[12px]",style:{height:24,borderRadius:5,background:W===w?"var(--hub-bg-2)":"transparent",color:W===w?"var(--hub-ink)":"var(--hub-ink-3)",border:"1px solid "+(W===w?"var(--hub-line)":"transparent")},children:[P,e.jsx("span",{className:"hub-mono",style:{fontSize:11,color:"var(--hub-ink-3)"},children:B})]},w))}),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(cs,{size:13,style:{color:"var(--hub-ink-3)"}}),e.jsx("input",{value:l,onChange:w=>v(w.target.value),className:"flex-1 bg-transparent outline-none text-[13px]",style:{color:"var(--hub-ink)"},placeholder:s("market.searchPlaceholder")||"Search…"}),l&&e.jsx("button",{onClick:()=>v(""),className:"hub-icon-btn sm",children:e.jsx(Ne,{size:11})})]}),e.jsxs("div",{className:"ml-auto hub-mono text-[12px]",style:{color:"var(--hub-ink-3)"},children:[u.length,"/",t.length]})]}),n&&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(we,{size:20,className:"animate-spin",style:{color:"var(--hub-ink-3)"}}),e.jsx("p",{style:{color:"var(--hub-ink-3)"},children:s("app.loading")})]})}):u.length===0?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:e.jsx("p",{children:t.length===0?s("app.noServers"):s("market.noServers")})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col",children:u.map(w=>e.jsx(Ss,{server:w,onRemove:R,onEdit:i,onToggle:f,onRefresh:y,onReload:z},w.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:p?s("common.showing",{start:(p.page-1)*p.limit+1,end:Math.min(p.page*p.limit,p.total),total:p.total}):s("common.showing",{start:1,end:t.length,total:t.length})}),e.jsx("div",{className:"flex-[4] flex justify-center",children:p&&p.totalPages>1&&e.jsx(ps,{currentPage:T,totalPages:p.totalPages,onPageChange:d,disabled:n})}),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:F,onChange:w=>C(Number(w.target.value)),disabled:n,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"})]})]})]})]}),$&&e.jsx(zs,{server:$,onEdit:()=>{M(null),y()},onCancel:()=>M(null)}),K&&e.jsx(Ts,{onSuccess:()=>{U(!1),y()},onCancel:()=>U(!1)}),J&&e.jsx(Ps,{onSuccess:()=>{X(!1),y()},onCancel:()=>X(!1)})]})};export{Ws as default};
37
+ //# sourceMappingURL=ServersPage-RQCARDfE.js.map