@samanhappy/mcphub 1.0.22 → 1.0.24
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.
- package/README.fr.md +9 -0
- package/README.md +9 -0
- package/README.zh.md +9 -0
- package/dist/betterAuth.js +2 -1
- package/dist/betterAuth.js.map +1 -1
- package/dist/controllers/oauthCallbackController.js +51 -25
- package/dist/controllers/oauthCallbackController.js.map +1 -1
- package/dist/controllers/oauthDynamicRegistrationController.js +2 -1
- package/dist/controllers/oauthDynamicRegistrationController.js.map +1 -1
- package/dist/controllers/oauthServerController.js +3 -2
- package/dist/controllers/oauthServerController.js.map +1 -1
- package/dist/controllers/serverController.js +52 -2
- package/dist/controllers/serverController.js.map +1 -1
- package/dist/dao/ServerDaoDbImpl.js +3 -0
- package/dist/dao/ServerDaoDbImpl.js.map +1 -1
- package/dist/db/entities/Server.js +4 -0
- package/dist/db/entities/Server.js.map +1 -1
- package/dist/middlewares/i18n.js +11 -12
- package/dist/middlewares/i18n.js.map +1 -1
- package/dist/models/User.js +18 -8
- package/dist/models/User.js.map +1 -1
- package/dist/routes/index.js +2 -1
- package/dist/routes/index.js.map +1 -1
- package/dist/services/betterAuthConfig.js +2 -1
- package/dist/services/betterAuthConfig.js.map +1 -1
- package/dist/services/keepAliveService.js +35 -6
- package/dist/services/keepAliveService.js.map +1 -1
- package/dist/services/mcpOAuthProvider.js +2 -1
- package/dist/services/mcpOAuthProvider.js.map +1 -1
- package/dist/services/mcpService.js +297 -66
- package/dist/services/mcpService.js.map +1 -1
- package/dist/services/oauthClientRegistration.js +3 -1
- package/dist/services/oauthClientRegistration.js.map +1 -1
- package/dist/services/oauthSettingsStore.js +3 -0
- package/dist/services/oauthSettingsStore.js.map +1 -1
- package/dist/services/openApiGeneratorService.js +2 -1
- package/dist/services/openApiGeneratorService.js.map +1 -1
- package/dist/services/upstreamOAuthDisconnectService.js +160 -0
- package/dist/services/upstreamOAuthDisconnectService.js.map +1 -0
- package/dist/utils/i18n.js +48 -7
- package/dist/utils/i18n.js.map +1 -1
- package/dist/utils/installBaseUrl.js +24 -0
- package/dist/utils/installBaseUrl.js.map +1 -0
- package/dist/utils/migration.js +1 -0
- package/dist/utils/migration.js.map +1 -1
- package/dist/utils/path.js +24 -17
- package/dist/utils/path.js.map +1 -1
- package/dist/utils/serialization.js +2 -1
- package/dist/utils/serialization.js.map +1 -1
- package/dist/utils/serverConfigPersistence.js +1 -0
- package/dist/utils/serverConfigPersistence.js.map +1 -1
- package/frontend/dist/assets/{ActivityPage-a7iUIWgo.js → ActivityPage-ClYamLqW.js} +2 -2
- package/frontend/dist/assets/{ActivityPage-a7iUIWgo.js.map → ActivityPage-ClYamLqW.js.map} +1 -1
- package/frontend/dist/assets/{Dashboard-BymSNeX3.js → Dashboard-XMPV4Ypu.js} +2 -2
- package/frontend/dist/assets/{Dashboard-BymSNeX3.js.map → Dashboard-XMPV4Ypu.js.map} +1 -1
- package/frontend/dist/assets/{EndpointCopy-BpKGkoXE.js → EndpointCopy-Ch7HbIsp.js} +2 -2
- package/frontend/dist/assets/{EndpointCopy-BpKGkoXE.js.map → EndpointCopy-Ch7HbIsp.js.map} +1 -1
- package/frontend/dist/assets/{GroupsPage-CUDeiRrR.js → GroupsPage-DkUg6Xih.js} +2 -2
- package/frontend/dist/assets/GroupsPage-DkUg6Xih.js.map +1 -0
- package/frontend/dist/assets/{LoginPage-C0b1KVcS.js → LoginPage-Chm4p59K.js} +2 -2
- package/frontend/dist/assets/{LoginPage-C0b1KVcS.js.map → LoginPage-Chm4p59K.js.map} +1 -1
- package/frontend/dist/assets/{LogsPage-ndVl0S7X.js → LogsPage-D0QA2y2j.js} +2 -2
- package/frontend/dist/assets/{LogsPage-ndVl0S7X.js.map → LogsPage-D0QA2y2j.js.map} +1 -1
- package/frontend/dist/assets/{MarketPage-LS2z8vcu.js → MarketPage-CU9wn6vM.js} +2 -2
- package/frontend/dist/assets/{MarketPage-LS2z8vcu.js.map → MarketPage-CU9wn6vM.js.map} +1 -1
- package/frontend/dist/assets/{PromptsPage-0MAP2tLv.js → PromptsPage-Iht1gTW7.js} +2 -2
- package/frontend/dist/assets/{PromptsPage-0MAP2tLv.js.map → PromptsPage-Iht1gTW7.js.map} +1 -1
- package/frontend/dist/assets/{ResourcesPage-BXjmP5FT.js → ResourcesPage-DsOhIF8m.js} +2 -2
- package/frontend/dist/assets/{ResourcesPage-BXjmP5FT.js.map → ResourcesPage-DsOhIF8m.js.map} +1 -1
- package/frontend/dist/assets/ServersPage-Dq_yBsZM.js +37 -0
- package/frontend/dist/assets/ServersPage-Dq_yBsZM.js.map +1 -0
- package/frontend/dist/assets/{SettingsPage-BGHo0M9q.js → SettingsPage-DoHjlHsl.js} +2 -2
- package/frontend/dist/assets/{SettingsPage-BGHo0M9q.js.map → SettingsPage-DoHjlHsl.js.map} +1 -1
- package/frontend/dist/assets/{StatusDot-CMGPqJqj.js → StatusDot-BF-uWsCA.js} +2 -2
- package/frontend/dist/assets/{StatusDot-CMGPqJqj.js.map → StatusDot-BF-uWsCA.js.map} +1 -1
- package/frontend/dist/assets/{ToggleGroup-C2cwcIkv.js → ToggleGroup-DMC5NEP5.js} +2 -2
- package/frontend/dist/assets/{ToggleGroup-C2cwcIkv.js.map → ToggleGroup-DMC5NEP5.js.map} +1 -1
- package/frontend/dist/assets/{UsersPage-eX3oMsvb.js → UsersPage-BA9TJs2F.js} +2 -2
- package/frontend/dist/assets/{UsersPage-eX3oMsvb.js.map → UsersPage-BA9TJs2F.js.map} +1 -1
- package/frontend/dist/assets/{contextCost-BCKU_3Kc.js → contextCost-KhOeuF-d.js} +2 -2
- package/frontend/dist/assets/{contextCost-BCKU_3Kc.js.map → contextCost-KhOeuF-d.js.map} +1 -1
- package/frontend/dist/assets/{index-BlTPJflb.css → index-BfEBXfi0.css} +1 -1
- package/frontend/dist/assets/index-xwxOTCc_.js +3 -0
- package/frontend/dist/assets/index-xwxOTCc_.js.map +1 -0
- package/frontend/dist/assets/{resourceService-CVAZJPEy.js → resourceService-OokeUb4C.js} +2 -2
- package/frontend/dist/assets/{resourceService-CVAZJPEy.js.map → resourceService-OokeUb4C.js.map} +1 -1
- package/frontend/dist/assets/useSettingsData-DegWU8bg.js +2 -0
- package/frontend/dist/assets/{useSettingsData-BdEnzN5x.js.map → useSettingsData-DegWU8bg.js.map} +1 -1
- package/frontend/dist/assets/variableDetection-D6KIhNDI.js +16 -0
- package/frontend/dist/assets/variableDetection-D6KIhNDI.js.map +1 -0
- package/frontend/dist/index.html +2 -2
- package/mcp_settings.json +2 -8
- package/package.json +3 -3
- package/frontend/dist/assets/GroupsPage-CUDeiRrR.js.map +0 -1
- package/frontend/dist/assets/ServersPage-B_Ow-YRR.js +0 -37
- package/frontend/dist/assets/ServersPage-B_Ow-YRR.js.map +0 -1
- package/frontend/dist/assets/index-hse3fHTq.js +0 -3
- package/frontend/dist/assets/index-hse3fHTq.js.map +0 -1
- package/frontend/dist/assets/useSettingsData-BdEnzN5x.js +0 -2
- package/frontend/dist/assets/variableDetection-B7PPrIlN.js +0 -16
- package/frontend/dist/assets/variableDetection-B7PPrIlN.js.map +0 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./resourceService-OokeUb4C.js","./index-xwxOTCc_.js","./framework-vendor-X-WP1v0m.js","./i18n-vendor-BLr2MLKp.js","./icons-vendor-DMtsx1SI.js","./index-BfEBXfi0.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as d,j as e,d as Es}from"./framework-vendor-X-WP1v0m.js";import{e as le,f as ss,h as ve,i as Pe,u as Ds,_ as ge,j as Ps,k as zs,l as Ts}from"./index-xwxOTCc_.js";import{f as ie,u as $s,a as Fs}from"./contextCost-KhOeuF-d.js";import{S as Is}from"./StatusDot-BF-uWsCA.js";import{u as ze}from"./useSettingsData-DegWU8bg.js";import{S as Ne}from"./ToggleGroup-DMC5NEP5.js";import{u as te}from"./i18n-vendor-BLr2MLKp.js";import{n as ts,o as rs,l as we,p as Rs,C as xe,q as ye,r as Te,s as ns,t as as,u as $e,m as ke,W as Os,g as _s,F as As,X as Ee,E as Ms,v as Vs,R as je,w as Js,L as Us,T as Bs,P as Ls,x as Ws,y as qs,z as Hs}from"./icons-vendor-DMtsx1SI.js";import{g as Ks}from"./toolDescription-Dw3sa28K.js";import{D as Gs}from"./DeleteDialog-7NPk3Hro.js";import{C as De}from"./ConfirmDialog-BKNVI65J.js";import{S as os,d as Xs}from"./variableDetection-D6KIhNDI.js";import{P as Ys}from"./Pagination-DAcOi8eq.js";const is=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"}}},Zs=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"}}},ls=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"}}},cs=async(s,n)=>{var t;try{const a=await ss(`/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"}}},Qs=Object.freeze(Object.defineProperty({__proto__:null,callTool:is,resetToolDescription:cs,toggleTool:Zs,updateToolDescription:ls},Symbol.toStringTag,{value:"Module"})),ds=({schema:s,onSubmit:n,onCancel:t,loading:a=!1,storageKey:x,title:f})=>{const{t:o}=te(),[j,S]=d.useState({}),[D,r]=d.useState({}),[m,z]=d.useState(!1),[g,F]=d.useState(""),[N,E]=d.useState(""),C=d.useMemo(()=>(u=>{const v=l=>{if(typeof l=="object"&&l!==null){const p=l;return{type:p.type||"string",description:p.description,enum:p.enum,default:p.default,properties:p.properties?Object.fromEntries(Object.entries(p.properties).map(([c,y])=>[c,v(y)])):void 0,required:p.required,items:p.items?v(p.items):void 0}}return{type:"string"}};return{type:u.type,properties:u.properties?Object.fromEntries(Object.entries(u.properties).map(([l,p])=>[l,v(p)])):void 0,required:u.required}})(s),[s]);d.useEffect(()=>{const h=(v,l="")=>{const p={};return v.type==="object"&&v.properties&&Object.entries(v.properties).forEach(([c,y])=>{const $=l?`${l}.${c}`:c;y.default!==void 0?p[c]=y.default:y.type==="string"?p[c]="":y.type==="number"||y.type==="integer"?p[c]=0:y.type==="boolean"?p[c]=!1:y.type==="array"?p[c]=[]:y.type==="object"&&(y.properties?p[c]=h(y,$):p[c]={})}),p};let u=h(C);if(x)try{const v=localStorage.getItem(x);if(v){const l=JSON.parse(v);u={...u,...l}}}catch(v){console.warn("Failed to load saved form data:",v)}S(u)},[C,x]),d.useEffect(()=>{m&&Object.keys(j).length>0&&(F(JSON.stringify(j,null,2)),E(""))},[m,j]);const O=h=>{F(h),E("");try{const u=JSON.parse(h);if(S(u),x)try{localStorage.setItem(x,JSON.stringify(u))}catch(v){console.warn("Failed to save form data to localStorage:",v)}}catch{E(o("tool.invalidJsonFormat"))}},M=()=>{F(JSON.stringify(j,null,2)),E(""),z(!0)},W=()=>{if(g.trim())try{const h=JSON.parse(g);S(h),E(""),z(!1)}catch{E(o("tool.fixJsonBeforeSwitching"));return}else z(!1)},R=(h,u)=>{S(v=>{const l={...v},p=h.split(".");let c=l;for(let y=0;y<p.length-1;y++)c[p[y]]||(c[p[y]]={}),c=c[p[y]];if(c[p[p.length-1]]=u,x)try{localStorage.setItem(x,JSON.stringify(l))}catch(y){console.warn("Failed to save form data to localStorage:",y)}return l}),D[h]&&r(v=>{const l={...v};return delete l[h],l})},B=()=>{const h={},u=(v,l,p="")=>{v.type==="object"&&v.properties&&Object.entries(v.properties).forEach(([c,y])=>{var _;const $=p?`${p}.${c}`:c,I=l==null?void 0:l[c];if((_=v.required)!=null&&_.includes(c)&&(I==null||I===""||Array.isArray(I)&&I.length===0)){h[$]=`${c} is required`;return}I!=null&&I!==""&&(y.type==="string"&&typeof I!="string"?h[$]=`${c} must be a string`:y.type==="number"&&typeof I!="number"?h[$]=`${c} must be a number`:y.type==="integer"&&(!Number.isInteger(I)||typeof I!="number")?h[$]=`${c} must be an integer`:y.type==="boolean"&&typeof I!="boolean"?h[$]=`${c} must be a boolean`:y.type==="array"&&Array.isArray(I)?y.items&&I.forEach((L,Q)=>{var A;((A=y.items)==null?void 0:A.type)==="object"&&y.items.properties&&u(y.items,L,`${$}.${Q}`)}):y.type==="object"&&typeof I=="object"&&u(y,I,$))})};return u(C,j),r(h),Object.keys(h).length===0},T=h=>{h.preventDefault(),B()&&n(j)},K=(h,u)=>u.split(".").reduce((v,l)=>v==null?void 0:v[l],h),q=(h,u,v,l)=>{const p=v==null?void 0:v[h];return u.type==="string"?u.enum?e.jsxs("select",{value:p||"",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")}),u.enum.map((c,y)=>e.jsx("option",{value:c,children:c},y))]}):e.jsx("input",{type:"text",value:p||"",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:u.description||o("tool.enterKey",{key:h})}):u.type==="number"||u.type==="integer"?e.jsx("input",{type:"number",step:u.type==="integer"?"1":"any",value:p??"",onChange:c=>{const y=c.target.value===""?"":u.type==="integer"?parseInt(c.target.value):parseFloat(c.target.value);l(y)},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"}):u.type==="boolean"?e.jsx("input",{type:"checkbox",checked:p||!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:p||"",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:u.description||o("tool.enterKey",{key:h})})},X=(h,u,v="")=>{var y,$,I,_,L,Q,A,k,U,ee,oe,P,H,ce;const l=v?`${v}.${h}`:h,p=K(j,l),c=D[l];if(u.type==="array"){const V=K(j,l)||[];return e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(v?($=(y=K(C,v))==null?void 0:y.required)==null?void 0:$.includes(h):(I=C.required)==null?void 0:I.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),u.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:u.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 Y=[...V];Y.splice(se,1),R(l,Y)},className:"text-status-red hover:text-red-700 text-sm",children:o("common.remove")})]}),((he=u.items)==null?void 0:he.type)==="string"&&u.items.enum?e.jsxs("select",{value:Z||"",onChange:Y=>{const re=[...V];re[se]=Y.target.value,R(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")}),u.items.enum.map((Y,re)=>e.jsx("option",{value:Y,children:Y},re))]}):((ae=u.items)==null?void 0:ae.type)==="object"&&u.items.properties?e.jsx("div",{className:"space-y-3",children:Object.entries(u.items.properties).map(([Y,re])=>{var be,fe;return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:[Y,((fe=(be=u.items)==null?void 0:be.required)==null?void 0:fe.includes(Y))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),q(Y,re,Z,Ce=>{const pe=[...V];pe[se]={...pe[se],[Y]:Ce},R(l,pe)})]},Y)})}):e.jsx("input",{type:"text",value:Z||"",onChange:Y=>{const re=[...V];re[se]=Y.target.value,R(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=u.items)==null?void 0:G.type)||"value"})})]},se)}),e.jsx("button",{type:"button",onClick:()=>{var se;const Z=((se=u.items)==null?void 0:se.type)==="object"?{}:"";R(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:h})})]}),c&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:c})]},l)}return u.type==="object"?u.properties?e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(v?(L=(_=K(C,v))==null?void 0:_.required)==null?void 0:L.includes(h):(Q=C.required)==null?void 0:Q.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),u.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:u.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(u.properties).map(([V,Z])=>X(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:[h,(v?(k=(A=K(C,v))==null?void 0:A.required)==null?void 0:k.includes(h):(U=C.required)==null?void 0:U.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"}),e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(JSON object)"})]}),u.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:u.description}),e.jsx("textarea",{value:typeof p=="object"?JSON.stringify(p,null,2):p||"{}",onChange:V=>{try{const Z=JSON.parse(V.target.value);R(l,Z)}catch{R(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):u.type==="string"?u.enum?e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(v?!1:(ee=C.required)==null?void 0:ee.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),u.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:u.description}),e.jsxs("select",{value:p||"",onChange:V=>R(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")}),u.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:[h,(v?!1:(oe=C.required)==null?void 0:oe.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),u.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:u.description}),e.jsx("input",{type:"text",value:p||"",onChange:V=>R(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):u.type==="number"||u.type==="integer"?e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(v?!1:(P=C.required)==null?void 0:P.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),u.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:u.description}),e.jsx("input",{type:"number",step:u.type==="integer"?"1":"any",value:p??"",onChange:V=>{const Z=V.target.value===""?"":u.type==="integer"?parseInt(V.target.value):parseFloat(V.target.value);R(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):u.type==="boolean"?e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",checked:p||!1,onChange:V=>R(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:[h,(v?!1:(H=C.required)==null?void 0:H.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]})]}),u.description&&e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:u.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:[h,(v?!1:(ce=C.required)==null?void 0:ce.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"}),e.jsxs("span",{className:"text-xs text-gray-500 ml-1",children:["(",u.type,")"]})]}),u.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:u.description}),e.jsx("input",{type:"text",value:p||"",onChange:V=>R(l,V.target.value),placeholder:o("tool.enterValue",{type:u.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 C.properties?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center pb-3",children:[e.jsx("h6",{className:"text-md font-medium text-gray-900",children:f}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("button",{type:"button",onClick:W,className:`hub-btn sm ${m?"":"primary"}`,children:o("tool.formMode")}),e.jsx("button",{type:"button",onClick:M,className:`hub-btn sm ${m?"primary":""}`,children:o("tool.jsonMode")})]})]}),m?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:h=>O(h.target.value),placeholder:`{
|
|
5
|
+
"key": "value"
|
|
6
|
+
}`,className:`w-full h-64 border rounded-md px-3 py-2 font-mono text-sm resize-y form-input ${N?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`}),N&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:N})]}),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx("button",{type:"button",onClick:t,className:"hub-btn sm",children:o("tool.cancel")}),e.jsx("button",{onClick:()=>{try{const h=JSON.parse(g);n(h)}catch{E(o("tool.invalidJsonFormat"))}},disabled:a||!!N,className:"hub-btn sm primary",children:o(a?"tool.running":"tool.runTool")})]})]}):e.jsxs("form",{onSubmit:T,className:"space-y-4",children:[Object.entries(C.properties||{}).map(([h,u])=>X(h,u)),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")})]})]})},et=({result:s,onClose:n})=>{const{t}=te(),a=s.content,x=r=>r?r.startsWith("image/")?r:`image/${r}`:"image/png",f=r=>{if(!r)return[];if(Array.isArray(r))return r.flatMap(g=>f(g));if(typeof r!="object")return[];const m=[];r.type==="image"&&r.data&&m.push({data:String(r.data),mimeType:x(r.mimeType||r.mime_type)});const z=r.image_base64||r.imageBase64||r.image_data||r.imageData||r.base64;return z&&m.push({data:String(z),mimeType:x(r.image_mimeType||r.image_mime_type||r.mimeType||r.mime_type)}),r.image&&typeof r.image=="object"&&m.push(...f(r.image)),Array.isArray(r.images)&&m.push(...f(r.images)),Array.isArray(r.content)&&m.push(...f(r.content)),m},o=r=>{const m=[];try{const F=JSON.parse(r);if(m.push(...f(F)),m.length>0)return m}catch{}const z=/data:image\/(png|jpe?g|gif|webp);base64,([A-Za-z0-9+/=]+)/g;let g;for(;(g=z.exec(r))!==null;){const F=`image/${g[1]==="jpg"?"jpeg":g[1]}`;m.push({data:g[2],mimeType:F})}return m},j=r=>{try{const m=JSON.parse(r),z=g=>{if(Array.isArray(g))return g.map(z);if(g&&typeof g=="object"){const F={};for(const[N,E]of Object.entries(g))typeof E=="string"&&N.toLowerCase().includes("base64")?F[N]="[base64 omitted]":F[N]=z(E);return F}return g};return JSON.stringify(z(m),null,2)}catch{return r.replace(/data:image\/(png|jpe?g|gif|webp);base64,[A-Za-z0-9+/=]+/g,"[image data omitted]")}},S=r=>Array.isArray(r)?r.map((m,z)=>e.jsx("div",{className:"mb-3 last:mb-0",children:D(m)},z)):D(r),D=r=>{if(typeof r=="string"){const m=o(r),z=j(r);return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[m.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:m.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:z})]})}if(typeof r=="object"&&r!==null){if(r.type==="text"&&r.text){const m=o(r.text),z=j(r.text);return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[m.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:m.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:z})]})}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 m=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(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(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(ts,{size:20,className:"text-status-green"}):e.jsx(rs,{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")}),S(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")}),S(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(Rs,{size:14,className:a?"animate-spin":""})});function st(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 tt=({tool:s,server:n,readOnly:t=!1,onToggle:a,onDescriptionUpdate:x,cost:f})=>{const{t:o}=te(),{showToast:j}=Pe(),{nameSeparator:S}=ze(),[D,r]=d.useState(!1),[m,z]=d.useState(!1),[g,F]=d.useState(!1),[N,E]=d.useState(null),[C,O]=d.useState(!1),[M,W]=d.useState(!1),[R,B]=d.useState(s.description||""),T=d.useRef(null),K=d.useRef(null),[q,X]=d.useState(0),[h,u]=d.useState(!1);d.useEffect(()=>{C&&T.current&&(T.current.focus(),q>0&&(T.current.style.width=`${q+20}px`))},[C,q]),d.useEffect(()=>{!C&&K.current&&X(K.current.offsetWidth)},[C,R]),d.useEffect(()=>{B(s.description||"")},[s.description]);const v=s.name.replace(n+S,""),l=Ks(s,o("tool.noDescription")),p=l.hasDescriptionOverride?o("tool.defaultDescriptionTooltip",{description:l.defaultDescription}):void 0,c=d.useCallback(()=>`mcphub_tool_form_${n?`${n}_`:""}${s.name}`,[s.name,n]),y=d.useCallback(()=>{localStorage.removeItem(c())},[c]),$=P=>{!t&&a&&a(s.name,P)},I=()=>{t||O(!0)},_=async()=>{if(!t)try{const P=await ls(n,s.name,R);P.success?(O(!1),x&&x(s.name,R)):(B(s.description||""),console.error("Failed to update tool description:",P.error))}catch(P){console.error("Error updating tool description:",P),B(s.description||""),O(!1)}},L=P=>{B(P.target.value)},Q=async()=>{if(!t){W(!0);try{const P=await cs(n,s.name);if(P.success){const H=P.description||"";B(H),O(!1),x==null||x(s.name,H,{restored:!0})}else j(P.error||o("tool.restoreDefaultFailed"),"error")}catch(P){console.error("Error resetting tool description:",P),j(o("tool.restoreDefaultFailed"),"error")}finally{W(!1)}}},A=P=>{P.key==="Enter"?_():P.key==="Escape"&&(B(s.description||""),O(!1))},k=async P=>{P.stopPropagation();try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(s.name),u(!0),j(o("common.copySuccess"),"success"),setTimeout(()=>u(!1),2e3);else{const H=document.createElement("textarea");H.value=s.name,H.style.position="fixed",H.style.left="-9999px",document.body.appendChild(H),H.focus(),H.select();try{document.execCommand("copy"),u(!0),j(o("common.copySuccess"),"success"),setTimeout(()=>u(!1),2e3)}catch(ce){j(o("common.copyFailed"),"error"),console.error("Copy to clipboard failed:",ce)}document.body.removeChild(H)}}catch(H){j(o("common.copyFailed"),"error"),console.error("Copy to clipboard failed:",H)}},U=async P=>{F(!0);try{P=Object.fromEntries(Object.entries(P).filter(([ce,V])=>!st(V)));const H=await is({toolName:s.name,arguments:P},n);E(H)}catch(H){E({success:!1,error:H instanceof Error?H.message:"Unknown error occurred"})}finally{F(!1)}},ee=()=>{z(!1),y(),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:P=>{P.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:v}),e.jsx("button",{className:"hub-icon-btn sm",onClick:k,title:o("common.copy"),children:h?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:C?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:T,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:q>0?`${q+20}px`:160,minWidth:80},value:R,onChange:L,onKeyDown:A,onClick:P=>P.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:P=>{P.stopPropagation(),_()},disabled:M,children:e.jsx(xe,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(me,{title:o("tool.restoreDefault"),onClick:P=>{P.stopPropagation(),Q()},disabled:M,loading:M})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:K,title:p,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:p,children:o("tool.descriptionModifiedBadge")}),!t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"hub-icon-btn sm",onClick:P=>{P.stopPropagation(),I()},children:e.jsx(Te,{size:12})}),e.jsx(me,{title:o("tool.restoreDefault"),onClick:P=>{P.stopPropagation(),Q()},disabled:M,loading:M})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[f!=null&&e.jsxs("span",{className:"hub-mono flex-shrink-0",style:{fontSize:11,color:"var(--hub-ink-3)"},title:o("cost.estimate"),children:["Σ ",ie(f)]}),e.jsx("div",{className:"flex h-[26px] items-center",onClick:P=>P.stopPropagation(),children:e.jsx(Ne,{checked:s.enabled??!0,onCheckedChange:$,disabled:g||t,size:"card","aria-label":`${o(s.enabled??!0?"server.disable":"server.enable")} ${v}`})}),e.jsxs("button",{onClick:P=>{P.stopPropagation(),r(!0),z(!0)},className:"hub-btn sm",style:{color:"var(--hub-accent)"},disabled:g||!s.enabled,children:[g?e.jsx(ns,{size:12,className:"animate-spin"}):e.jsx(as,{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})]}),!m&&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)})]}),m&&e.jsxs("div",{style:{border:"1px solid var(--hub-line)",borderRadius:8,padding:14},children:[e.jsx(ds,{schema:s.inputSchema||{type:"object"},onSubmit:U,onCancel:ee,loading:g,storageKey:c(),title:o("tool.runToolWithName",{name:v})}),N&&e.jsx("div",{style:{marginTop:12},children:e.jsx(et,{result:N,onClose:oe})})]})]})]})},rt=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"}}},us=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"}}},nt=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"}}},ms=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"}}},ps=async(s,n)=>{var t;try{const a=await ss(`/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"}}},at=Object.freeze(Object.defineProperty({__proto__:null,callPrompt:rt,getPrompt:us,resetPromptDescription:ps,togglePrompt:nt,updatePromptDescription:ms},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((f,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:[f.role,":"]})}),typeof f.content=="string"?e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:f.content}):typeof f.content=="object"&&f.content.type==="text"?e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:f.content.text}):e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(f.content,null,2)})]},o))})]})]});try{const f=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(f,null,2)})]})}catch{return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(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(ts,{size:20,className:"text-status-green"}):e.jsx(rs,{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")})})]})})]})},ot=({prompt:s,server:n,readOnly:t=!1,onToggle:a,onDescriptionUpdate:x,cost:f})=>{const{t:o}=te(),{showToast:j}=Pe(),{nameSeparator:S}=ze(),[D,r]=d.useState(!1),[m,z]=d.useState(!1),[g,F]=d.useState(!1),[N,E]=d.useState(null),[C,O]=d.useState(!1),[M,W]=d.useState(!1),[R,B]=d.useState(s.description||""),T=d.useRef(null),K=d.useRef(null),[q,X]=d.useState(0);d.useEffect(()=>{C&&T.current&&(T.current.focus(),q>0&&(T.current.style.width=`${q+20}px`))},[C,q]),d.useEffect(()=>{!C&&K.current&&X(K.current.offsetWidth)},[C,R]),d.useEffect(()=>{B(s.description||"")},[s.description]);const h=d.useCallback(()=>`mcphub_prompt_form_${n?`${n}_`:""}${s.name}`,[s.name,n]),u=d.useCallback(()=>{localStorage.removeItem(h())},[h]),v=k=>{!t&&a&&a(s.name,k)},l=()=>{t||O(!0)},p=async()=>{if(!t){O(!1);try{const k=await ms(n,s.name,R);k.success?x&&x(s.name,R):(j(k.error||o("prompt.descriptionUpdateFailed"),"error"),B(s.description||""))}catch(k){console.error("Error updating prompt description:",k),j(o("prompt.descriptionUpdateFailed"),"error"),B(s.description||"")}}},c=async()=>{if(!t){W(!0);try{const k=await ps(n,s.name);if(k.success){const U=k.description||"";B(U),O(!1),x==null||x(s.name,U,{restored:!0})}else j(k.error||o("prompt.restoreDefaultFailed"),"error")}catch(k){console.error("Error resetting prompt description:",k),j(o("prompt.restoreDefaultFailed"),"error")}finally{W(!1)}}},y=k=>{B(k.target.value)},$=k=>{k.key==="Enter"?p():k.key==="Escape"&&(B(s.description||""),O(!1))},I=async k=>{F(!0);try{const U=await us({promptName:s.name,arguments:k},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)}},_=()=>{z(!1),u(),E(null)},L=()=>{E(null)},Q=s.name.replace(n+S,""),A=()=>{if(!s.arguments||s.arguments.length===0)return{type:"object",properties:{},required:[]};const k={},U=[];return s.arguments.forEach(ee=>{k[ee.name]={type:"string",description:ee.description||""},ee.required&&U.push(ee.name)}),{type:"object",properties:k,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:C?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:T,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:q>0?`${q+20}px`:160,minWidth:80},value:R,onChange:y,onKeyDown:$,onClick:k=>k.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:k=>{k.stopPropagation(),p()},disabled:M,children:e.jsx(xe,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(me,{title:o("prompt.restoreDefault"),onClick:k=>{k.stopPropagation(),c()},disabled:M,loading:M})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:K,children:R||o("tool.noDescription")}),!t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"hub-icon-btn sm",onClick:k=>{k.stopPropagation(),l()},children:e.jsx(Te,{size:12})}),e.jsx(me,{title:o("prompt.restoreDefault"),onClick:k=>{k.stopPropagation(),c()},disabled:M,loading:M})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[f!=null&&e.jsxs("span",{className:"hub-mono flex-shrink-0",style:{fontSize:11,color:"var(--hub-ink-3)"},title:o("cost.estimate"),children:["Σ ",ie(f)]}),e.jsx("div",{className:"flex h-[26px] items-center",onClick:k=>k.stopPropagation(),children:s.enabled!==void 0&&e.jsx(Ne,{checked:s.enabled,onCheckedChange:v,disabled:g||t,size:"card","aria-label":`${o(s.enabled?"server.disable":"server.enable")} ${Q}`})}),e.jsxs("button",{onClick:k=>{k.stopPropagation(),r(!0),z(!0)},className:"hub-btn sm",style:{color:"var(--hub-accent)"},disabled:g||!s.enabled,children:[g?e.jsx(ns,{size:12,className:"animate-spin"}):e.jsx(as,{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:[m&&e.jsxs("div",{style:{border:"1px solid var(--hub-line)",borderRadius:8,padding:14},children:[e.jsx(ds,{schema:A(),onSubmit:I,onCancel:_,loading:g,storageKey:h(),title:o("prompt.runPromptWithName",{name:Q})}),N&&e.jsx("div",{style:{marginTop:12},children:e.jsx(Xe,{result:N,onClose:L})})]}),!m&&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((k,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: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})]},U))})]}),!m&&N&&e.jsx("div",{children:e.jsx(Xe,{result:N,onClose:L})})]})]})},it=({resource:s,readOnly:n=!1,onToggle:t,onDescriptionUpdate:a,cost:x})=>{const{t:f}=te(),[o,j]=d.useState(!1),[S,D]=d.useState(!1),[r,m]=d.useState(!1),[z,g]=d.useState(s.description||""),F=d.useRef(null),N=d.useRef(null),[E,C]=d.useState(0);d.useEffect(()=>{S&&F.current&&(F.current.focus(),E>0&&(F.current.style.width=`${E+20}px`))},[S,E]),d.useEffect(()=>{!S&&N.current&&C(N.current.offsetWidth)},[S,z]),d.useEffect(()=>{g(s.description||"")},[s.description]);const O=s.name||s.uri,M=T=>{!n&&t&&t(s.uri,T)},W=async()=>{n||(D(!1),a&&await a(s.uri,z))},R=async()=>{if(!n){m(!0);try{await(a==null?void 0:a(s.uri,"",{restored:!0})),D(!1)}finally{m(!1)}}},B=T=>{T.key==="Enter"?W():T.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:()=>j(!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:O}),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:S?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:z,onChange:T=>g(T.target.value),onKeyDown:B,onClick:T=>T.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:T=>{T.stopPropagation(),W()},disabled:r,children:e.jsx(xe,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(me,{title:f("builtinResources.restoreDefault"),onClick:T=>{T.stopPropagation(),R()},disabled:r,loading:r})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:N,children:z||f("tool.noDescription")}),!n&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"hub-icon-btn sm",onClick:T=>{T.stopPropagation(),D(!0)},children:e.jsx(Te,{size:12})}),e.jsx(me,{title:f("builtinResources.restoreDefault"),onClick:T=>{T.stopPropagation(),R()},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:f("cost.estimate"),children:["Σ ",ie(x)]}),e.jsx("div",{className:"flex h-[26px] items-center",onClick:T=>T.stopPropagation(),children:e.jsx(Ne,{checked:s.enabled!==!1,onCheckedChange:M,disabled:n,size:"card","aria-label":`${f(s.enabled!==!1?"server.disable":"server.enable")} ${O}`})}),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:[f("builtinResources.mimeType"),":"]})," ",e.jsx("span",{style:{fontSize:12,color:"var(--hub-ink-2)"},children:s.mimeType||"text/plain"})]})]})},lt=(s,n)=>n?n.isAdmin?!0:!!(s.owner&&s.owner===n.username):!1,ct={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:"Group",longKey:"server.visibilityGroup",longFallback:"Group (reserved — not yet implemented)",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)]"}},Fe=s=>s==="public"||s==="group"?s:"private",dt=(s,n)=>{const t=Fe(n),a=ct[t];return{value:t,shortLabel:s(a.shortKey,{defaultValue:a.shortFallback}),longLabel:s(a.longKey,{defaultValue:a.longFallback}),className:a.className}},ut=(s,n)=>{const t=Fe(n),a=[{value:"private",label:s("server.visibilityPrivateShort",{defaultValue:"Private"}),disabled:!1}];return t==="group"&&a.push({value:"group",label:s("server.visibilityGroupShort",{defaultValue:"Group"}),disabled:!0}),a.push({value:"public",label:s("server.visibilityPublicShort",{defaultValue:"Public"}),disabled:!1}),a},Ye=({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)"}})})]}),Ze=({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"})}),Qe=(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,mt="text/html;profile=mcp-app",es=s=>s?!!(s.ui||s["ui/resourceUri"]):!1,pt=s=>{var n,t;return!!((n=s.tools)!=null&&n.some(a=>es(a._meta))||(t=s.resources)!=null&&t.some(a=>{var x;return((x=a.uri)==null?void 0:x.startsWith("ui://"))||a.mimeType===mt||es(a._meta)}))},xt=({server:s,cost:n,onRemove:t,onEdit:a,onToggle:x,onVisibilityChange:f,onRefresh:o,onReload:j,onReinstall:S,onOAuthDisconnect:D})=>{var _e,Ae,Me,Ve,Je,Ue,Be,Le,We,qe,He,Ke,Ge;const{t:r}=te(),{showToast:m}=Pe(),{exportMCPSettings:z,installConfig:g}=ze(),{auth:F}=Ds(),N=((_e=g==null?void 0:g.baseUrl)==null?void 0:_e.replace(/\/+$/,""))||"",[E,C]=d.useState(!1),[O,M]=d.useState(null),[W,R]=d.useState(!1),[B,T]=d.useState(!1),[K,q]=d.useState(!1),[X,h]=d.useState(!1),[u,v]=d.useState(!1),[l,p]=d.useState(!1),[c,y]=d.useState(!1),[$,I]=d.useState(!1),[_,L]=d.useState(!1),[Q,A]=d.useState(!1),[k,U]=d.useState(!1),ee=d.useRef(null),oe=d.useRef(null);d.useEffect(()=>{const i=b=>{ee.current&&!ee.current.contains(b.target)&&L(!1),oe.current&&!oe.current.contains(b.target)&&A(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[]);const P=((Ae=s.tools)==null?void 0:Ae.length)||0,H=((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=pt(s),ae=s.enabled!==!1,G=lt(s,F.user),Y=((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||X||!x)){h(!0);try{await x(s,i)}finally{h(!1)}}},fe=async i=>{if(i.stopPropagation(),L(!1),!(!G||l||!j)){p(!0);try{await j(s)?m(r("server.reloadSuccess")||"Server reloaded successfully","success"):m(r("server.reloadError",{serverName:s.name})||"Failed to reload","error")}finally{p(!1)}}},Ce=async()=>{if(L(!1),!(!G||c||!S)){y(!0);try{await S(s)?m(r("server.reinstallSuccess")||"Server reinstall initiated","success"):m(r("server.reinstallError",{serverName:s.name})||"Failed to reinstall","error")}finally{y(!1)}}},pe=async()=>{if(L(!1),!(!G||$||!D)){I(!0);try{await D(s)?m(r("server.disconnectOAuthSuccess")||"Server OAuth disconnected","success"):m(r("server.disconnectOAuthError",{serverName:s.name})||"Failed to disconnect OAuth","error")}finally{I(!1)}}},xs=async i=>{var w;if(i.stopPropagation(),!G||u||!f)return;const b=i.target.value;if(b!==Fe(s.visibility??((w=s.config)==null?void 0:w.visibility))){v(!0);try{await f(s,b)}finally{v(!1)}}},Se=async i=>{try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(i),!0}catch{}try{const b=document.createElement("textarea");b.value=i,b.style.position="fixed",b.style.left="-9999px",document.body.appendChild(b),b.focus(),b.select();const w=document.execCommand("copy");return document.body.removeChild(b),w}catch{return!1}},hs=async i=>{if(i.stopPropagation(),!s.error)return;await Se(s.error)?(U(!0),m(r("common.copySuccess")||"Copied","success"),setTimeout(()=>U(!1),1500)):m(r("common.copyFailed")||"Copy failed","error")},bs=async i=>{if(i.stopPropagation(),L(!1),!!G)try{const b=await z(s.name);if(!b||!b.success||!b.data){m((b==null?void 0:b.message)||r("common.copyFailed")||"Copy failed","error");return}const w=JSON.stringify(b.data,null,2),J=await Se(w);m(J?r("common.copySuccess")||"Copied":r("common.copyFailed")||"Copy failed",J?"success":"error")}catch(b){console.error("Error copying server configuration:",b),m(r("common.copyFailed")||"Copy failed","error")}},fs=i=>{var b;if(i.stopPropagation(),(b=s.oauth)!=null&&b.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}`),m(r("status.oauthWindowOpened"),"info")}},gs=async(i,b)=>{try{const{toggleTool:w}=await ge(async()=>{const{toggleTool:ne}=await Promise.resolve().then(()=>Qs);return{toggleTool:ne}},void 0,import.meta.url),J=await w(s.name,i,b);J.success?(m(r(b?"tool.enableSuccess":"tool.disableSuccess",{name:i}),"success"),o==null||o()):m(J.error||r("tool.toggleFailed"),"error")}catch(w){console.error(w),m(r("tool.toggleFailed"),"error")}},ys=async(i,b)=>{try{const{togglePrompt:w}=await ge(async()=>{const{togglePrompt:ne}=await Promise.resolve().then(()=>at);return{togglePrompt:ne}},void 0,import.meta.url),J=await w(s.name,i,b);J.success?(m(r(b?"tool.enableSuccess":"tool.disableSuccess",{name:i}),"success"),o==null||o()):m(J.error||r("tool.toggleFailed"),"error")}catch(w){console.error(w),m(r("tool.toggleFailed"),"error")}},js=async(i,b)=>{try{const{toggleResource:w}=await ge(async()=>{const{toggleResource:ne}=await import("./resourceService-OokeUb4C.js");return{toggleResource:ne}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),J=await w(s.name,i,b);J.success?(m(r(b?"tool.enableSuccess":"tool.disableSuccess",{name:i}),"success"),o==null||o()):m(J.error||r("tool.toggleFailed"),"error")}catch(w){console.error(w),m(r("tool.toggleFailed"),"error")}},vs=(i,b,w)=>{m(w!=null&&w.restored?r("tool.restoreDefaultSuccess"):r("tool.descriptionUpdateSuccess"),"success"),o==null||o()},Ns=(i,b,w)=>{m(w!=null&&w.restored?r("prompt.restoreDefaultSuccess"):r("prompt.descriptionUpdateSuccess"),"success"),o==null||o()},ws=async(i,b,w)=>{try{const{updateResourceDescription:J,resetResourceDescription:ne}=await ge(async()=>{const{updateResourceDescription:Cs,resetResourceDescription:Ss}=await import("./resourceService-OokeUb4C.js");return{updateResourceDescription:Cs,resetResourceDescription:Ss}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),de=w!=null&&w.restored?await ne(s.name,i):await J(s.name,i,b);de.success?(m(w!=null&&w.restored?r("builtinResources.restoreDefaultSuccess"):r("builtinResources.descriptionUpdateSuccess"),"success"),o==null||o()):m(de.error||(w!=null&&w.restored?r("builtinResources.restoreDefaultFailed"):r("builtinResources.descriptionUpdateFailed")),"error")}catch(J){console.error(J),m(w!=null&&w.restored?r("builtinResources.restoreDefaultFailed"):r("builtinResources.descriptionUpdateFailed"),"error")}};(()=>{var w;const i=s.config;if(!i)return"";if(i.url)return i.url;const b=[];return i.command&&b.push(i.command),(w=i.args)!=null&&w.length&&b.push(...i.args),b.join(" ")})();const Ie=`${N}/mcp/${s.name}`,Re=(i,b)=>r(i,b),ue=dt(Re,s.visibility??((He=s.config)==null?void 0:He.visibility)),ks=ut(Re,ue.value),Oe=[{key:"tools",icon:Os,total:P,enabled:H,label:r("server.tools")},{key:"prompts",icon:_s,total:ce,enabled:V,label:r("server.prompts")},{key:"resources",icon:As,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:()=>C(!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(),A(b=>!b)},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:hs,className:"hub-icon-btn sm",title:r("common.copy"),children:k?e.jsx(xe,{size:12,className:"text-[var(--hub-ok)]"}):e.jsx(ye,{size:12})})]}),e.jsx("button",{onClick:()=>A(!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})})]})]})]}),((Ke=s.config)==null?void 0:Ke.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,onAuthClick:fs,className:"hub-server-card-status"})}),e.jsx("div",{className:"hub-server-card-transport-cell min-w-0",children:(Ge=s.config)!=null&&Ge.type?e.jsx("span",{className:"hub-tag hub-server-card-transport-tag",title:Qe(r,s.config.type)??void 0,children:Qe(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&&f?e.jsx(Ye,{isLoading:u,className:"w-full",overlayStyle:{borderRadius:6},children:e.jsx("select",{value:ue.value,onChange:xs,disabled:u,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:ks.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:b,total:w,enabled:J,label:ne})=>{const de=w===0;return e.jsxs("span",{className:`hub-server-capability-stat hub-mono hub-num ${de?"is-empty":""}`,title:`${ne}: ${J}/${w}`,children:[e.jsx("span",{className:"text-[var(--hub-ink-3)]",children:e.jsx(Ze,{icon:b})}),e.jsx("span",{className:"hub-server-capability-value",children:de?"0":`${J}/${w}`})]},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(Ye,{isLoading:X,className:"h-[18px] w-[30px]",overlayStyle:{borderRadius:999,background:"var(--hub-bg-2)"},spinnerSize:10,children:e.jsx(Ne,{checked:ae,onCheckedChange:be,disabled:X||!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(b=>!b)},"aria-label":"More",children:e.jsx(Ms,{size:14})}),G&&_&&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(Vs,{size:13})," ",r("server.edit")]}),e.jsxs("button",{onClick:bs,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")]}),j&&e.jsxs("button",{onClick:fe,disabled:l||X||!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")]}),S&&Y&&e.jsxs("button",{onClick:i=>{i.stopPropagation(),L(!1),!(!G||c||!ae)&&T(!0)},disabled:c||X||!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(Js,{size:13})," ",r("server.reinstall")]}),re&&e.jsxs("button",{onClick:i=>{i.stopPropagation(),L(!1),!(!G||$)&&q(!0)},disabled:$,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(Us,{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),R(!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(Bs,{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 b=O===i.key,w=i.icon;return e.jsxs("button",{onClick:()=>M(b?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:b?"var(--hub-surface)":"transparent",border:"1px solid "+(b?"var(--hub-line)":"transparent"),color:b?"var(--hub-ink)":"var(--hub-ink-2)"},children:[e.jsx(Ze,{icon:w}),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:()=>M(O==="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:O==="cost"?"var(--hub-surface)":"transparent",border:"1px solid "+(O==="cost"?"var(--hub-line)":"transparent"),color:O==="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:Ie,style:{maxWidth:200},children:s.name}),e.jsx("button",{type:"button",className:"hub-endpoint-copy",onClick:async i=>{i.stopPropagation();const b=await Se(Ie);m(b?r("common.copySuccess")||"Copied":r("common.copyFailed")||"Failed",b?"success":"error")},title:r("common.copy"),children:e.jsx(ye,{size:12})})]})})]}),O==="cost"&&(n==null?void 0:n.connected)&&e.jsx("div",{className:"mt-2 space-y-1",children:[...n.items].sort((i,b)=>b.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}`))}),O==="tools"&&s.tools&&e.jsx("div",{className:"space-y-3 mt-2",children:s.tools.map((i,b)=>{var w;return e.jsx(tt,{server:s.name,tool:i,readOnly:!G,onToggle:gs,onDescriptionUpdate:vs,cost:(w=n==null?void 0:n.items.find(J=>J.kind==="tool"&&J.name===i.name))==null?void 0:w.cost},b)})}),O==="prompts"&&s.prompts&&e.jsx("div",{className:"space-y-3 mt-2",children:s.prompts.map((i,b)=>{var w;return e.jsx(ot,{server:s.name,prompt:i,readOnly:!G,onToggle:ys,onDescriptionUpdate:Ns,cost:(w=n==null?void 0:n.items.find(J=>J.kind==="prompt"&&J.name===i.name))==null?void 0:w.cost},b)})}),O==="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,b)=>{var w;return e.jsx(it,{resource:i,readOnly:!G,onToggle:js,onDescriptionUpdate:ws,cost:(w=n==null?void 0:n.items.find(J=>J.kind==="resource"&&J.name===i.uri))==null?void 0:w.cost},`${i.uri}-${b}`)})})})]})]}),e.jsx(Gs,{isOpen:W,onClose:()=>R(!1),onConfirm:()=>{t(s.name),R(!1)},serverName:s.name}),e.jsx(De,{isOpen:B,onClose:()=>T(!1),onConfirm:()=>{T(!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:K,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"})]})},ht=({onAdd:s})=>{const{t:n}=te(),[t,a]=d.useState(!1),[x,f]=d.useState(null),[o,j]=d.useState(!1),[S,D]=d.useState(null),[r,m]=d.useState([]),z=()=>{a(!t),f(null),j(!1),D(null)},g=async()=>{S&&(await F(S),j(!1),D(null))},F=async E=>{try{f(null);const C=await le("/servers",E);if(!C.success){C&&C.message?f(C.message):f(n("server.addError"));return}a(!1),s()}catch(C){console.error("Error adding server:",C),navigator.onLine?C instanceof TypeError&&(C.message.includes("NetworkError")||C.message.includes("Failed to fetch"))?f(n("errors.serverConnection")):f(n("errors.serverAdd")):f(n("errors.network"))}},N=async E=>{try{const C=Xs(E);C.length>0?(m(C),D(E),j(!0)):await F(E)}catch(C){console.error("Error processing server submission:",C),f(n("errors.serverAdd"))}};return e.jsxs("div",{children:[e.jsxs("button",{onClick:z,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(os,{onSubmit:N,onCancel:z,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,C)=>e.jsxs("li",{className:"font-mono",children:["$",`{${E}}`]},C))})]})]})}),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:()=>{j(!1),D(null)},className:"hub-btn",children:n("common.cancel")}),e.jsx("button",{onClick:g,className:"hub-btn primary",children:n("server.confirmAndAdd")})]})]})})]})},bt=({server:s,onEdit:n,onCancel:t})=>{const{t:a}=te(),[x,f]=d.useState(null),o=async j=>{try{f(null);const S=encodeURIComponent(s.name),D=j.name&&j.name!==s.name,r={config:j.config,...D?{newName:j.name}:{}},m=await ve(`/servers/${S}`,r);if(!m.success){m&&m.message?f(m.message):f(a("server.updateError",{serverName:s.name}));return}n()}catch(S){console.error("Error updating server:",S),navigator.onLine?S instanceof TypeError&&(S.message.includes("NetworkError")||S.message.includes("Failed to fetch"))?f(a("errors.serverConnection")):f(a("errors.serverUpdate",{serverName:s.name})):f(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(os,{onSubmit:o,onCancel:t,initialData:s,modalTitle:a("server.editTitle",{serverName:s.name}),formError:x})})},ft=({onSuccess:s,onCancel:n})=>{const{t}=te(),[a,x]=d.useState(!1),[f,o]=d.useState(!1),[j,S]=d.useState(null),[D,r]=d.useState(null),[m,z]=d.useState(!1),[g,F]=d.useState(null),[N,E]=d.useState(""),[C,O]=d.useState(!1),[M,W]=d.useState(""),R=l=>{l.preventDefault(),x(!0)},B=l=>{l.preventDefault(),x(!1)},T=l=>{l.preventDefault(),x(!1);const p=l.dataTransfer.files;if(p.length>0){const c=p[0];c.name.endsWith(".mcpb")?(r(c),S(null)):S(t("mcpb.invalidFileType"))}},K=l=>{const p=l.target.files;if(p&&p.length>0){const c=p[0];c.name.endsWith(".mcpb")?(r(c),S(null)):S(t("mcpb.invalidFileType"))}},q=async()=>{if(!D){S(t("mcpb.noFileSelected"));return}o(!0),S(null);try{const l=new FormData;l.append("mcpbFile",D);const p=await zs(Ts("/mcpb/upload"),{method:"POST",body:l}),c=await p.json();if(!p.ok)throw new Error(c.message||`HTTP error! Status: ${p.status}`);if(c.success&&c.data)F(c.data.manifest),E(c.data.extractDir),z(!0);else throw new Error(c.message||t("mcpb.uploadFailed"))}catch(l){console.error("MCPB upload error:",l),S(l instanceof Error?l.message:t("mcpb.uploadFailed"))}finally{o(!1)}},X=async(l,p=!1)=>{var c;o(!0),S(null);try{const y=v(g,N,l);if(!p){const I=await Ps("/servers");if(I.success&&((c=I.data)==null?void 0:c.find(L=>L.name===l))){W(l),O(!0),o(!1);return}}let $;if(p?$=await ve(`/servers/${encodeURIComponent(l)}`,{name:l,config:y}):$=await le("/servers",{name:l,config:y}),$.success)s(y);else throw new Error($.message||t("mcpb.installFailed"))}catch(y){console.error("MCPB install error:",y),S(y instanceof Error?y.message:t("mcpb.installFailed")),o(!1)}},h=()=>{O(!1),M&&X(M,!0)},u=()=>{O(!1),W(""),o(!1)},v=(l,p,c)=>{var I;const y=((I=l.server)==null?void 0:I.mcp_config)||{},$={type:"stdio",command:y.command||"node",args:(y.args||[]).map(_=>_.replace("${__dirname}",p))};return y.env&&Object.keys(y.env).length>0&&($.env={...y.env},Object.keys($.env).forEach(_=>{typeof $.env[_]=="string"&&($.env[_]=$.env[_].replace("${__dirname}",p))})),$};return m&&g?e.jsxs(e.Fragment,{children:[e.jsx(De,{isOpen:C,onClose:u,onConfirm:h,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 ${C?"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:"✕"})]}),j&&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:j})}),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,p)=>e.jsxs("li",{children:[l.name," - ",l.description]},p))})]})]})]}),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:f,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:()=>{const l=document.getElementById("serverName"),p=(l==null?void 0:l.value.trim())||g.name;X(p)},disabled:f,className:"hub-btn primary",children:f?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t("mcpb.installing")]}):t("mcpb.install")})]})]})]})})]}):e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 w-full max-w-lg",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:t("mcpb.uploadTitle")}),e.jsx("button",{onClick:n,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),j&&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:j})}),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:R,onDragLeave:B,onDrop:T,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:K,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:f,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:q,disabled:!D||f,className:"hub-btn primary flex items-center",children:f?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t("mcpb.uploading")]}):t("mcpb.upload")})]})]})})},gt=s=>Object.entries(s.mcpServers).map(([n,t])=>{const a={};return t.type==="sse"||t.type==="streamable-http"?(a.type=t.type,a.url=t.url,t.headers&&(a.headers=t.headers)):t.type==="openapi"?(a.type="openapi",a.openapi=t.openapi):(a.type="stdio",a.command=t.command,a.args=t.args||[],t.env&&(a.env=t.env),t.options&&(a.options=t.options)),{name:n,config:a}}),yt=({onSuccess:s,onCancel:n})=>{const{t}=te(),[a,x]=d.useState(""),[f,o]=d.useState(null),[j,S]=d.useState(!1),[D,r]=d.useState(null),m=`{
|
|
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.`,z=N=>{try{const E=JSON.parse(N.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 N=z(a);N&&r(gt(N))},F=async()=>{if(D){S(!0),o(null);try{const N=await le("/servers/batch",{servers:D});if(N.success&&N.data){const{successCount:E,failureCount:C,results:O}=N.data;if(C>0){const M=O.filter(W=>!W.success).map(W=>`${W.name}: ${W.message||t("jsonImport.addFailed")}`);o(t("jsonImport.partialSuccess",{count:E,total:D.length})+`
|
|
35
|
+
`+M.join(`
|
|
36
|
+
`))}E>0&&s()}else o(N.message||t("jsonImport.importFailed"))}catch(N){console.error("Import error:",N),o(t("jsonImport.importFailed"))}finally{S(!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:"✕"})]}),f&&e.jsx("div",{className:"mb-4 bg-red-50 border-l-4 border-red-500 p-4 rounded",children:e.jsx("p",{className:"text-red-700 whitespace-pre-wrap",children:f})}),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((N,E)=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 p-4 rounded-lg border border-gray-200 dark:border-gray-700",children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-gray-900",children:N.name}),e.jsxs("div",{className:"mt-2 space-y-1 text-sm text-gray-600",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.type"),":"]})," ",N.config.type||"stdio"]}),N.config.command&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.command"),":"]})," ",N.config.command]}),N.config.args&&N.config.args.length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.arguments"),":"]})," ",N.config.args.join(" ")]}),N.config.url&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.url"),":"]})," ",N.config.url]}),N.config.env&&Object.keys(N.config.env).length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.envVars"),":"]})," ",Object.keys(N.config.env).join(", ")]}),N.config.headers&&Object.keys(N.config.headers).length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.headers"),":"]})," ",Object.keys(N.config.headers).join(", ")]})]})]})})},E))})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:()=>r(null),disabled:j,className:"hub-btn",children:t("common.back")}),e.jsx("button",{onClick:F,disabled:j,className:"hub-btn primary",children:j?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:N=>x(N.target.value),className:"w-full h-96 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-sm",placeholder:m}),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")})]})]})]})})},jt=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}),vt=(s,n,t="")=>{const a=t.trim().toLowerCase();return s.filter(x=>{var o,j;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)||"")+" "+(((j=x.tools)==null?void 0:j.map(S=>S.name).join(" "))||"")).toLowerCase().includes(a):!0})},Nt=(s,n,t,a,x)=>{const f=vt(s,n,t),o=f.length,j=Math.max(1,Math.ceil(o/x)),S=Math.min(Math.max(1,a),j),D=(S-1)*x;return{servers:f.slice(D,D+x),pagination:{page:S,limit:x,total:o,totalPages:j,hasNextPage:S<j,hasPrevPage:S>1}}},Ot=()=>{const{t:s}=te(),n=Es(),{servers:t,allServers:a,error:x,setError:f,isLoading:o,currentPage:j,serversPerPage:S,setCurrentPage:D,setServersPerPage:r,handleServerAdd:m,handleServerEdit:z,handleServerRemove:g,handleServerToggle:F,handleServerVisibilityChange:N,handleServerReload:E,handleServerReinstall:C,handleServerOAuthDisconnect:O,triggerRefresh:M}=$s({refreshOnMount:!0}),{serverCosts:W,refetch:R}=Fs();d.useEffect(()=>{R()},[t,R]);const[B,T]=d.useState(null),[K,q]=d.useState(!1),[X,h]=d.useState(!1),[u,v]=d.useState(!1),[l,p]=d.useState("all"),[c,y]=d.useState(""),$=d.useMemo(()=>jt(a),[a]),{servers:I,pagination:_}=d.useMemo(()=>Nt(a,l,c,j,S),[a,l,c,j,S]);d.useEffect(()=>{_.page!==j&&D(_.page)},[_.page,j,D]);const L=async A=>{const k=await z(A);k&&T(k)},Q=async()=>{q(!0);try{M(),await new Promise(A=>setTimeout(A,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:$.all})," ",s("nav.servers").toLowerCase()," ·"," ",e.jsx("span",{className:"hub-num",children:$.online})," ",s("status.online")," ·"," ",e.jsx("span",{className:"hub-num",children:$.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(Ls,{size:13})," ",s("nav.market")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>v(!0),children:[e.jsx(Ws,{size:13})," ",s("jsonImport.button")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>h(!0),children:[e.jsx(qs,{size:13})," ",s("mcpb.upload")]}),e.jsxs("button",{className:"hub-btn",onClick:Q,disabled:K,"aria-label":s("common.refresh"),children:[e.jsx(je,{size:13,className:K?"animate-spin":""}),s("common.refresh")]}),e.jsx(ht,{onAdd:m})]})]}),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:()=>f(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",$.all],["online",s("status.online"),$.online],["issues",s("common.inactive")||"Issues",$.issues],["disabled",s("pages.dashboard.disabledServers")||"Disabled",$.disabled]].map(([A,k,U])=>e.jsxs("button",{onClick:()=>p(A),className:"inline-flex items-center gap-1.5 px-3 text-[12px]",style:{height:24,borderRadius:5,background:l===A?"var(--hub-bg-2)":"transparent",color:l===A?"var(--hub-ink)":"var(--hub-ink-3)",border:"1px solid "+(l===A?"var(--hub-line)":"transparent")},children:[k,e.jsx("span",{className:"hub-mono",style:{fontSize:11,color:"var(--hub-ink-3)"},children:U})]},A))}),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(Hs,{size:13,style:{color:"var(--hub-ink-3)"}}),e.jsx("input",{value:c,onChange:A=>y(A.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:()=>y(""),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:[_.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")})]})}):I.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:I.map(A=>e.jsx(xt,{server:A,cost:W.find(k=>k.name===A.name),onRemove:g,onEdit:L,onToggle:F,onVisibilityChange:N,onRefresh:M,onReload:E,onReinstall:C,onOAuthDisconnect:O},A.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:(_.page-1)*_.limit+1,end:Math.min(_.page*_.limit,_.total),total:_.total})}),e.jsx("div",{className:"flex-[4] flex justify-center",children:_.totalPages>1&&e.jsx(Ys,{currentPage:_.page,totalPages:_.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:S,onChange:A=>r(Number(A.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(bt,{server:B,onEdit:()=>{T(null),M()},onCancel:()=>T(null)}),X&&e.jsx(ft,{onSuccess:()=>{h(!1),M()},onCancel:()=>h(!1)}),u&&e.jsx(yt,{onSuccess:()=>{v(!1),M()},onCancel:()=>v(!1)})]})};export{Ot as default};
|
|
37
|
+
//# sourceMappingURL=ServersPage-Dq_yBsZM.js.map
|