@samanhappy/mcphub 1.0.45 → 1.0.46
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/dist/controllers/oauthCallbackController.js +2 -2
- package/dist/controllers/oauthCallbackController.js.map +1 -1
- package/dist/services/mcpService.js +41 -15
- package/dist/services/mcpService.js.map +1 -1
- package/dist/services/principalRuntimeService.js +2 -2
- package/dist/services/principalRuntimeService.js.map +1 -1
- package/dist/services/serverConfigEnvironment.js +23 -0
- package/dist/services/serverConfigEnvironment.js.map +1 -0
- package/frontend/dist/assets/{ActivityPage-DPlbWRuE.js → ActivityPage-C4vGn8kC.js} +2 -2
- package/frontend/dist/assets/{ActivityPage-DPlbWRuE.js.map → ActivityPage-C4vGn8kC.js.map} +1 -1
- package/frontend/dist/assets/{CopyClientConfigDialog-BmrvVqKm.js → CopyClientConfigDialog-gqu8M16p.js} +2 -2
- package/frontend/dist/assets/{CopyClientConfigDialog-BmrvVqKm.js.map → CopyClientConfigDialog-gqu8M16p.js.map} +1 -1
- package/frontend/dist/assets/{CredentialsPage-DUa5COar.js → CredentialsPage-EJYe8sf_.js} +2 -2
- package/frontend/dist/assets/{CredentialsPage-DUa5COar.js.map → CredentialsPage-EJYe8sf_.js.map} +1 -1
- package/frontend/dist/assets/{Dashboard-DaTYK_nx.js → Dashboard-CqqzEeM3.js} +2 -2
- package/frontend/dist/assets/{Dashboard-DaTYK_nx.js.map → Dashboard-CqqzEeM3.js.map} +1 -1
- package/frontend/dist/assets/{EndpointCopy-BCfqwDEK.js → EndpointCopy-sH8M0Zl-.js} +2 -2
- package/frontend/dist/assets/{EndpointCopy-BCfqwDEK.js.map → EndpointCopy-sH8M0Zl-.js.map} +1 -1
- package/frontend/dist/assets/{GroupsPage-Cuxz5FyS.js → GroupsPage-BAiER86x.js} +4 -4
- package/frontend/dist/assets/{GroupsPage-Cuxz5FyS.js.map → GroupsPage-BAiER86x.js.map} +1 -1
- package/frontend/dist/assets/{LoginPage-yTpHn5Tx.js → LoginPage-BPhnf62f.js} +2 -2
- package/frontend/dist/assets/{LoginPage-yTpHn5Tx.js.map → LoginPage-BPhnf62f.js.map} +1 -1
- package/frontend/dist/assets/{LogsPage-BbSlC06Q.js → LogsPage-Ci0H5Hbz.js} +2 -2
- package/frontend/dist/assets/{LogsPage-BbSlC06Q.js.map → LogsPage-Ci0H5Hbz.js.map} +1 -1
- package/frontend/dist/assets/MarketPage-B0bU64Fu.js +2 -0
- package/frontend/dist/assets/MarketPage-B0bU64Fu.js.map +1 -0
- package/frontend/dist/assets/{OAuthConsentPage-W05BBBpL.js → OAuthConsentPage-COPngtNn.js} +2 -2
- package/frontend/dist/assets/{OAuthConsentPage-W05BBBpL.js.map → OAuthConsentPage-COPngtNn.js.map} +1 -1
- package/frontend/dist/assets/{PromptsPage-Bq7xptCw.js → PromptsPage-DkRz0aOM.js} +2 -2
- package/frontend/dist/assets/{PromptsPage-Bq7xptCw.js.map → PromptsPage-DkRz0aOM.js.map} +1 -1
- package/frontend/dist/assets/{ResourcesPage-CsL39aff.js → ResourcesPage-D9UvvBJO.js} +2 -2
- package/frontend/dist/assets/{ResourcesPage-CsL39aff.js.map → ResourcesPage-D9UvvBJO.js.map} +1 -1
- package/frontend/dist/assets/ServersPage-D9DDRTwG.js +39 -0
- package/frontend/dist/assets/ServersPage-D9DDRTwG.js.map +1 -0
- package/frontend/dist/assets/SettingsPage-p0RqcQ3b.js +12 -0
- package/frontend/dist/assets/SettingsPage-p0RqcQ3b.js.map +1 -0
- package/frontend/dist/assets/{StatusDot-DnCf86-T.js → StatusDot-rU2z4UIB.js} +2 -2
- package/frontend/dist/assets/{StatusDot-DnCf86-T.js.map → StatusDot-rU2z4UIB.js.map} +1 -1
- package/frontend/dist/assets/{ToggleGroup-DFjmIz4f.js → ToggleGroup-B-m_CA-c.js} +2 -2
- package/frontend/dist/assets/{ToggleGroup-DFjmIz4f.js.map → ToggleGroup-B-m_CA-c.js.map} +1 -1
- package/frontend/dist/assets/{UsersPage-g_A6Nis1.js → UsersPage-BtCcY8iT.js} +2 -2
- package/frontend/dist/assets/{UsersPage-g_A6Nis1.js.map → UsersPage-BtCcY8iT.js.map} +1 -1
- package/frontend/dist/assets/{clipboard-C6pDz_7o.js → clipboard-ZgOiZZfc.js} +2 -2
- package/frontend/dist/assets/{clipboard-C6pDz_7o.js.map → clipboard-ZgOiZZfc.js.map} +1 -1
- package/frontend/dist/assets/index-D-J2WUmj.css +1 -0
- package/frontend/dist/assets/index-DeDkxr8P.js +3 -0
- package/frontend/dist/assets/index-DeDkxr8P.js.map +1 -0
- package/frontend/dist/assets/{resourceService-CAxgCzyV.js → resourceService-B_JEhB8X.js} +2 -2
- package/frontend/dist/assets/{resourceService-CAxgCzyV.js.map → resourceService-B_JEhB8X.js.map} +1 -1
- package/frontend/dist/assets/{useCostData-wcUc6g7_.js → useCostData-B9tFvSJs.js} +2 -2
- package/frontend/dist/assets/{useCostData-wcUc6g7_.js.map → useCostData-B9tFvSJs.js.map} +1 -1
- package/frontend/dist/assets/variableDetection-DSNGipcp.js +16 -0
- package/frontend/dist/assets/variableDetection-DSNGipcp.js.map +1 -0
- package/frontend/dist/index.html +2 -2
- package/package.json +1 -1
- package/frontend/dist/assets/MarketPage-nAF8uFkv.js +0 -2
- package/frontend/dist/assets/MarketPage-nAF8uFkv.js.map +0 -1
- package/frontend/dist/assets/ServersPage-p9LgWUzS.js +0 -39
- package/frontend/dist/assets/ServersPage-p9LgWUzS.js.map +0 -1
- package/frontend/dist/assets/SettingsPage-DobkN2nZ.js +0 -12
- package/frontend/dist/assets/SettingsPage-DobkN2nZ.js.map +0 -1
- package/frontend/dist/assets/index-BlEZfPQl.js +0 -3
- package/frontend/dist/assets/index-BlEZfPQl.js.map +0 -1
- package/frontend/dist/assets/index-Cla8rRxG.css +0 -1
- package/frontend/dist/assets/variableDetection-DxVZhKpb.js +0 -16
- package/frontend/dist/assets/variableDetection-DxVZhKpb.js.map +0 -1
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./resourceService-CAxgCzyV.js","./index-BlEZfPQl.js","./framework-vendor-CQFm9vKd.js","./i18n-vendor-DVmjrzgW.js","./icons-vendor-CEwDZ1lN.js","./index-Cla8rRxG.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as c,j as e,L as As,d as Ms}from"./framework-vendor-CQFm9vKd.js";import{i as ce,f as ls,h as Ne,j as Pe,u as Vs,_ as ve,e as Us,k as Bs,l as Js}from"./index-BlEZfPQl.js";import{f as le}from"./contextCost-CilWqGWT.js";import{S as Ls}from"./StatusDot-DnCf86-T.js";import{u as we,c as es}from"./clipboard-C6pDz_7o.js";import{S as ke}from"./ToggleGroup-DFjmIz4f.js";import{u as ae}from"./i18n-vendor-DVmjrzgW.js";import{n as cs,o as ds,l as Ce,p as Ws,C as fe,q as be,r as Te,s as us,t as ms,u as ze,m as Se,W as qs,g as Ks,F as Hs,X as Ee,R as me,v as Gs,w as Xs,x as Ys,y as Zs,L as Qs,T as et,P as st,z as tt,D as rt,G as nt}from"./icons-vendor-CEwDZ1lN.js";import{g as at,C as ot,t as it}from"./CopyClientConfigDialog-BmrvVqKm.js";import{D as lt}from"./DeleteDialog-BaCsEkJA.js";import{C as De}from"./ConfirmDialog-BYdfb115.js";import{S as ct,a as ps,d as dt}from"./variableDetection-DxVZhKpb.js";import{P as ut}from"./Pagination-BRqqU5Ct.js";import{u as mt,a as pt}from"./useCostData-wcUc6g7_.js";const hs=async(s,r)=>{try{const t=r?`/tools/${encodeURIComponent(r)}/${encodeURIComponent(s.toolName)}`:"/tools/call",n=await ce(t,s.arguments,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return n.success===!1?{success:!1,error:n.message||"Tool call failed"}:{success:!0,content:(n==null?void 0:n.content)||[]}}catch(t){return console.error("Error calling tool",{toolName:s.toolName,server:r,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},ht=async(s,r,t)=>{try{const n=await ce(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(r)}/toggle`,{enabled:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:n.success,error:n.success?void 0:n.message}}catch(n){return console.error("Error toggling tool",{serverName:s,toolName:r,enabled:t,error:n}),{success:!1,error:n instanceof Error?n.message:"Unknown error occurred"}}},xs=async(s,r,t)=>{try{const n=await Ne(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(r)}/description`,{description:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:n.success,error:n.success?void 0:n.message}}catch(n){return console.error("Error updating tool description",{serverName:s,toolName:r,error:n}),{success:!1,error:n instanceof Error?n.message:"Unknown error occurred"}}},bs=async(s,r)=>{var t;try{const n=await ls(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(r)}/description`,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:n.success,error:n.success?void 0:n.message,description:(t=n.data)==null?void 0:t.description}}catch(n){return console.error("Error resetting tool description",{serverName:s,toolName:r,error:n}),{success:!1,error:n instanceof Error?n.message:"Unknown error occurred"}}},xt=Object.freeze(Object.defineProperty({__proto__:null,callTool:hs,resetToolDescription:bs,toggleTool:ht,updateToolDescription:xs},Symbol.toStringTag,{value:"Module"})),fs=({schema:s,onSubmit:r,onCancel:t,loading:n=!1,storageKey:b,title:u})=>{const{t:a}=ae(),[j,x]=c.useState({}),[E,d]=c.useState({}),[g,o]=c.useState(!1),[p,_]=c.useState(""),[k,D]=c.useState(""),T=c.useMemo(()=>(h=>{const w=l=>{if(typeof l=="object"&&l!==null){const f=l;return{type:f.type||"string",description:f.description,enum:f.enum,default:f.default,properties:f.properties?Object.fromEntries(Object.entries(f.properties).map(([m,N])=>[m,w(N)])):void 0,required:f.required,items:f.items?w(f.items):void 0}}return{type:"string"}};return{type:h.type,properties:h.properties?Object.fromEntries(Object.entries(h.properties).map(([l,f])=>[l,w(f)])):void 0,required:h.required}})(s),[s]);c.useEffect(()=>{const y=(w,l="")=>{const f={};return w.type==="object"&&w.properties&&Object.entries(w.properties).forEach(([m,N])=>{const $=l?`${l}.${m}`:m;N.default!==void 0?f[m]=N.default:N.type==="string"?f[m]="":N.type==="number"||N.type==="integer"?f[m]=0:N.type==="boolean"?f[m]=!1:N.type==="array"?f[m]=[]:N.type==="object"&&(N.properties?f[m]=y(N,$):f[m]={})}),f};let h=y(T);if(b)try{const w=localStorage.getItem(b);if(w){const l=JSON.parse(w);h={...h,...l}}}catch(w){console.warn("Failed to load saved form data:",w)}x(h)},[T,b]),c.useEffect(()=>{g&&Object.keys(j).length>0&&(_(JSON.stringify(j,null,2)),D(""))},[g,j]);const U=y=>{_(y),D("");try{const h=JSON.parse(y);if(x(h),b)try{localStorage.setItem(b,JSON.stringify(h))}catch(w){console.warn("Failed to save form data to localStorage:",w)}}catch{D(a("tool.invalidJsonFormat"))}},V=()=>{_(JSON.stringify(j,null,2)),D(""),o(!0)},B=()=>{if(p.trim())try{const y=JSON.parse(p);x(y),D(""),o(!1)}catch{D(a("tool.fixJsonBeforeSwitching"));return}else o(!1)},R=(y,h)=>{x(w=>{const l={...w},f=y.split(".");let m=l;for(let $=0;$<f.length-1;$++){const I=f[$];if(I==="__proto__"||I==="constructor"||I==="prototype")return w;m[I]||(m[I]={}),m=m[I]}const N=f[f.length-1];if(!N||N==="__proto__"||N==="constructor"||N==="prototype")return w;if(m[N]=h,b)try{localStorage.setItem(b,JSON.stringify(l))}catch($){console.warn("Failed to save form data to localStorage:",$)}return l}),E[y]&&d(w=>{const l={...w};return delete l[y],l})},L=()=>{const y={},h=(w,l,f="")=>{w.type==="object"&&w.properties&&Object.entries(w.properties).forEach(([m,N])=>{var W;const $=f?`${f}.${m}`:m,I=l==null?void 0:l[m];if((W=w.required)!=null&&W.includes(m)&&(I==null||I===""||Array.isArray(I)&&I.length===0)){y[$]=`${m} is required`;return}I!=null&&I!==""&&(N.type==="string"&&typeof I!="string"?y[$]=`${m} must be a string`:N.type==="number"&&typeof I!="number"?y[$]=`${m} must be a number`:N.type==="integer"&&(!Number.isInteger(I)||typeof I!="number")?y[$]=`${m} must be an integer`:N.type==="boolean"&&typeof I!="boolean"?y[$]=`${m} must be a boolean`:N.type==="array"&&Array.isArray(I)?N.items&&I.forEach((Y,G)=>{var Q;((Q=N.items)==null?void 0:Q.type)==="object"&&N.items.properties&&h(N.items,Y,`${$}.${G}`)}):N.type==="object"&&typeof I=="object"&&h(N,I,$))})};return h(T,j),d(y),Object.keys(y).length===0},P=y=>{y.preventDefault(),L()&&r(j)},O=(y,h)=>h.split(".").reduce((w,l)=>w==null?void 0:w[l],y),q=(y,h,w,l)=>{const f=w==null?void 0:w[y];return h.type==="string"?h.enum?e.jsxs("select",{value:f||"",onChange:m=>l(m.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:a("tool.selectOption")}),h.enum.map((m,N)=>e.jsx("option",{value:m,children:m},N))]}):e.jsx("input",{type:"text",value:f||"",onChange:m=>l(m.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:h.description||a("tool.enterKey",{key:y})}):h.type==="number"||h.type==="integer"?e.jsx("input",{type:"number",step:h.type==="integer"?"1":"any",value:f??"",onChange:m=>{const N=m.target.value===""?"":h.type==="integer"?parseInt(m.target.value):parseFloat(m.target.value);l(N)},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"}):h.type==="boolean"?e.jsx("input",{type:"checkbox",checked:f||!1,onChange:m=>l(m.target.checked),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}):e.jsx("input",{type:"text",value:f||"",onChange:m=>l(m.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:h.description||a("tool.enterKey",{key:y})})},ee=(y,h,w="")=>{var N,$,I,W,Y,G,Q,v,M,te,re,z,K,J;const l=w?`${w}.${y}`:y,f=O(j,l),m=E[l];if(h.type==="array"){const F=O(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:[y,(w?($=(N=O(T,w))==null?void 0:N.required)==null?void 0:$.includes(y):(I=T.required)==null?void 0:I.includes(y))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),h.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:h.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:[F.map((H,ne)=>{var ge,ye,je;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:a("tool.item",{index:ne+1})}),e.jsx("button",{type:"button",onClick:()=>{const Z=[...F];Z.splice(ne,1),R(l,Z)},className:"text-status-red hover:text-red-700 text-sm",children:a("common.remove")})]}),((ge=h.items)==null?void 0:ge.type)==="string"&&h.items.enum?e.jsxs("select",{value:H||"",onChange:Z=>{const oe=[...F];oe[ne]=Z.target.value,R(l,oe)},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:a("tool.selectOption")}),h.items.enum.map((Z,oe)=>e.jsx("option",{value:Z,children:Z},oe))]}):((ye=h.items)==null?void 0:ye.type)==="object"&&h.items.properties?e.jsx("div",{className:"space-y-3",children:Object.entries(h.items.properties).map(([Z,oe])=>{var ie,X;return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:[Z,((X=(ie=h.items)==null?void 0:ie.required)==null?void 0:X.includes(Z))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),q(Z,oe,H,he=>{const xe=[...F];xe[ne]={...xe[ne],[Z]:he},R(l,xe)})]},Z)})}):e.jsx("input",{type:"text",value:H||"",onChange:Z=>{const oe=[...F];oe[ne]=Z.target.value,R(l,oe)},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:a("tool.enterValue",{type:((je=h.items)==null?void 0:je.type)||"value"})})]},ne)}),e.jsx("button",{type:"button",onClick:()=>{var ne;const H=((ne=h.items)==null?void 0:ne.type)==="object"?{}:"";R(l,[...F,H])},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:a("tool.addItem",{key:y})})]}),m&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:m})]},l)}return h.type==="object"?h.properties?e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[y,(w?(Y=(W=O(T,w))==null?void 0:W.required)==null?void 0:Y.includes(y):(G=T.required)==null?void 0:G.includes(y))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),h.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:h.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(h.properties).map(([F,H])=>ee(F,H,l))}),m&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:m})]},l):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[y,(w?(v=(Q=O(T,w))==null?void 0:Q.required)==null?void 0:v.includes(y):(M=T.required)==null?void 0:M.includes(y))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"}),e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(JSON object)"})]}),h.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:h.description}),e.jsx("textarea",{value:typeof f=="object"?JSON.stringify(f,null,2):f||"{}",onChange:F=>{try{const H=JSON.parse(F.target.value);R(l,H)}catch{R(l,F.target.value)}},placeholder:`{
|
|
3
|
-
"key": "value"
|
|
4
|
-
}`,className:`w-full border rounded-md px-3 py-2 font-mono text-sm ${m?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`,rows:4}),m&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:m})]},l):h.type==="string"?h.enum?e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[y,(w?!1:(te=T.required)==null?void 0:te.includes(y))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),h.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:h.description}),e.jsxs("select",{value:f||"",onChange:F=>R(l,F.target.value),className:`w-full border rounded-md px-3 py-2 ${m?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[e.jsx("option",{value:"",children:a("tool.selectOption")}),h.enum.map((F,H)=>e.jsx("option",{value:F,children:F},H))]}),m&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:m})]},l):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[y,(w?!1:(re=T.required)==null?void 0:re.includes(y))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),h.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:h.description}),e.jsx("input",{type:"text",value:f||"",onChange:F=>R(l,F.target.value),className:`w-full border rounded-md px-3 py-2 ${m?"border-red":"border-gray-200"} focus:outline-none form-input`}),m&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:m})]},l):h.type==="number"||h.type==="integer"?e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[y,(w?!1:(z=T.required)==null?void 0:z.includes(y))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),h.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:h.description}),e.jsx("input",{type:"number",step:h.type==="integer"?"1":"any",value:f??"",onChange:F=>{const H=F.target.value===""?"":h.type==="integer"?parseInt(F.target.value):parseFloat(F.target.value);R(l,H)},className:`w-full border rounded-md px-3 py-2 form-input ${m?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`}),m&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:m})]},l):h.type==="boolean"?e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",checked:f||!1,onChange:F=>R(l,F.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:[y,(w?!1:(K=T.required)==null?void 0:K.includes(y))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]})]}),h.description&&e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:h.description}),m&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:m})]},l):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[y,(w?!1:(J=T.required)==null?void 0:J.includes(y))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"}),e.jsxs("span",{className:"text-xs text-gray-500 ml-1",children:["(",h.type,")"]})]}),h.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:h.description}),e.jsx("input",{type:"text",value:f||"",onChange:F=>R(l,F.target.value),placeholder:a("tool.enterValue",{type:h.type}),className:`w-full border rounded-md px-3 py-2 ${m?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500 form-input`}),m&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:m})]},l)};return T.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:u}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("button",{type:"button",onClick:B,className:`hub-btn sm ${g?"":"primary"}`,children:a("tool.formMode")}),e.jsx("button",{type:"button",onClick:V,className:`hub-btn sm ${g?"primary":""}`,children:a("tool.jsonMode")})]})]}),g?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:a("tool.jsonConfiguration")}),e.jsx("textarea",{value:p,onChange:y=>U(y.target.value),placeholder:`{
|
|
5
|
-
"key": "value"
|
|
6
|
-
}`,className:`w-full h-64 border rounded-md px-3 py-2 font-mono text-sm resize-y form-input ${k?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`}),k&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:k})]}),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx("button",{type:"button",onClick:t,className:"hub-btn sm",children:a("tool.cancel")}),e.jsx("button",{onClick:()=>{try{const y=JSON.parse(p);r(y)}catch{D(a("tool.invalidJsonFormat"))}},disabled:n||!!k,className:"hub-btn sm primary",children:a(n?"tool.running":"tool.runTool")})]})]}):e.jsxs("form",{onSubmit:P,className:"space-y-4",children:[Object.entries(T.properties||{}).map(([y,h])=>ee(y,h)),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:a("tool.cancel")}),e.jsx("button",{type:"submit",disabled:n,className:"hub-btn sm primary",children:a(n?"tool.running":"tool.runTool")})]})]})]}):e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx("p",{className:"text-sm text-gray-600",children:a("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:a("tool.cancel")}),e.jsx("button",{onClick:()=>r({}),disabled:n,className:"hub-btn primary",children:a(n?"tool.running":"tool.runTool")})]})]})},bt=({result:s,onClose:r})=>{const{t}=ae(),n=s.content,b=d=>d?d.startsWith("image/")?d:`image/${d}`:"image/png",u=d=>{if(!d)return[];if(Array.isArray(d))return d.flatMap(p=>u(p));if(typeof d!="object")return[];const g=[];d.type==="image"&&d.data&&g.push({data:String(d.data),mimeType:b(d.mimeType||d.mime_type)});const o=d.image_base64||d.imageBase64||d.image_data||d.imageData||d.base64;return o&&g.push({data:String(o),mimeType:b(d.image_mimeType||d.image_mime_type||d.mimeType||d.mime_type)}),d.image&&typeof d.image=="object"&&g.push(...u(d.image)),Array.isArray(d.images)&&g.push(...u(d.images)),Array.isArray(d.content)&&g.push(...u(d.content)),g},a=d=>{const g=[];try{const _=JSON.parse(d);if(g.push(...u(_)),g.length>0)return g}catch{}const o=/data:image\/(png|jpe?g|gif|webp);base64,([A-Za-z0-9+/=]+)/g;let p;for(;(p=o.exec(d))!==null;){const _=`image/${p[1]==="jpg"?"jpeg":p[1]}`;g.push({data:p[2],mimeType:_})}return g},j=d=>{try{const g=JSON.parse(d),o=p=>{if(Array.isArray(p))return p.map(o);if(p&&typeof p=="object"){const _={};for(const[k,D]of Object.entries(p))typeof D=="string"&&k.toLowerCase().includes("base64")?_[k]="[base64 omitted]":_[k]=o(D);return _}return p};return JSON.stringify(o(g),null,2)}catch{return d.replace(/data:image\/(png|jpe?g|gif|webp);base64,[A-Za-z0-9+/=]+/g,"[image data omitted]")}},x=d=>Array.isArray(d)?d.map((g,o)=>e.jsx("div",{className:"mb-3 last:mb-0",children:E(g)},o)):E(d),E=d=>{if(typeof d=="string"){const g=a(d),o=j(d);return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[g.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:g.map((p,_)=>e.jsx("img",{src:`data:${p.mimeType||"image/png"};base64,${p.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"},_))}),e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:o})]})}if(typeof d=="object"&&d!==null){if(d.type==="text"&&d.text){const g=a(d.text),o=j(d.text);return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[g.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:g.map((p,_)=>e.jsx("img",{src:`data:${p.mimeType||"image/png"};base64,${p.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"},_))}),e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:o})]})}if(d.type==="image"&&d.data)return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("img",{src:`data:${d.mimeType||"image/png"};base64,${d.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"})});try{const g=typeof d=="string"?JSON.parse(d):d;return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-2",children:t("tool.jsonResponse")}),e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(g,null,2)})]})}catch{return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(d)})})}}return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(d)})})};return e.jsxs("div",{className:"border border-gray-300 rounded-lg bg-white dark:bg-gray-800 shadow-sm",children:[e.jsx("div",{className:"border-b border-gray-300 px-4 py-3 bg-gray-50 dark:bg-gray-800 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[s.success?e.jsx(cs,{size:20,className:"text-status-green"}):e.jsx(ds,{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:r,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")}),x(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(Ce,{size:16,className:"text-red-500"}),e.jsx("span",{className:"text-sm font-medium text-red-700",children:t("tool.error")})]}),n&&n.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:t("tool.errorDetails")}),x(n)]}):e.jsx("div",{className:"bg-red-50 border border-red-300 rounded-md p-3",children:e.jsx("pre",{className:"text-sm text-red-800 whitespace-pre-wrap",children:s.error||s.message||t("tool.unknownError")})})]})})]})},pe=({title:s,onClick:r,disabled:t=!1,loading:n=!1})=>e.jsx("button",{type:"button",className:"ml-2 p-1 text-amber-600 hover:text-amber-700 cursor-pointer transition-colors disabled:opacity-60 disabled:cursor-not-allowed",onClick:r,disabled:t,title:s,"aria-label":s,children:e.jsx(Ws,{size:14,className:n?"animate-spin":""})});function ft(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 gt=({tool:s,server:r,readOnly:t=!1,onToggle:n,onDescriptionUpdate:b,cost:u})=>{const{t:a}=ae(),{showToast:j}=Pe(),{nameSeparator:x}=we(),[E,d]=c.useState(!1),[g,o]=c.useState(!1),[p,_]=c.useState(!1),[k,D]=c.useState(null),[T,U]=c.useState(!1),[V,B]=c.useState(!1),[R,L]=c.useState(s.description||""),P=c.useRef(null),O=c.useRef(null),[q,ee]=c.useState(0),[y,h]=c.useState(!1);c.useEffect(()=>{T&&P.current&&(P.current.focus(),q>0&&(P.current.style.width=`${q+20}px`))},[T,q]),c.useEffect(()=>{!T&&O.current&&ee(O.current.offsetWidth)},[T,R]),c.useEffect(()=>{L(s.description||"")},[s.description]);const w=s.name.replace(r+x,""),l=at(s,a("tool.noDescription")),f=l.hasDescriptionOverride?a("tool.defaultDescriptionTooltip",{description:l.defaultDescription}):void 0,m=c.useCallback(()=>`mcphub_tool_form_${r?`${r}_`:""}${s.name}`,[s.name,r]),N=c.useCallback(()=>{localStorage.removeItem(m())},[m]),$=z=>{!t&&n&&n(s.name,z)},I=()=>{t||U(!0)},W=async()=>{if(!t)try{const z=await xs(r,s.name,R);z.success?(U(!1),b&&b(s.name,R)):(L(s.description||""),console.error("Failed to update tool description:",z.error))}catch(z){console.error("Error updating tool description:",z),L(s.description||""),U(!1)}},Y=z=>{L(z.target.value)},G=async()=>{if(!t){B(!0);try{const z=await bs(r,s.name);if(z.success){const K=z.description||"";L(K),U(!1),b==null||b(s.name,K,{restored:!0})}else j(z.error||a("tool.restoreDefaultFailed"),"error")}catch(z){console.error("Error resetting tool description:",z),j(a("tool.restoreDefaultFailed"),"error")}finally{B(!1)}}},Q=z=>{z.key==="Enter"?W():z.key==="Escape"&&(L(s.description||""),U(!1))},v=async z=>{z.stopPropagation();try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(s.name),h(!0),j(a("common.copySuccess"),"success"),setTimeout(()=>h(!1),2e3);else{const K=document.createElement("textarea");K.value=s.name,K.style.position="fixed",K.style.left="-9999px",document.body.appendChild(K),K.focus(),K.select();try{document.execCommand("copy"),h(!0),j(a("common.copySuccess"),"success"),setTimeout(()=>h(!1),2e3)}catch(J){j(a("common.copyFailed"),"error"),console.error("Copy to clipboard failed:",J)}document.body.removeChild(K)}}catch(K){j(a("common.copyFailed"),"error"),console.error("Copy to clipboard failed:",K)}},M=async z=>{_(!0);try{z=Object.fromEntries(Object.entries(z).filter(([J,F])=>!ft(F)));const K=await hs({toolName:s.name,arguments:z},r);D(K)}catch(K){D({success:!1,error:K instanceof Error?K.message:"Unknown error occurred"})}finally{_(!1)}},te=()=>{o(!1),N(),D(null)},re=()=>{D(null)};return e.jsxs("div",{className:"hub-card overflow-hidden",style:{marginBottom:8},children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 px-3 py-2.5 cursor-pointer hover:bg-[var(--hub-surface-hover)] transition-colors",onClick:z=>{z.stopPropagation(),d(!E)},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:w}),e.jsx("button",{className:"hub-icon-btn sm",onClick:v,title:a("common.copy"),children:y?e.jsx(fe,{size:12,style:{color:"var(--hub-ok)"}}):e.jsx(be,{size:12})}),e.jsx("span",{className:"flex items-center gap-1",style:{fontSize:12,color:"var(--hub-ink-3)"},children:T?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:P,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:q>0?`${q+20}px`:160,minWidth:80},value:R,onChange:Y,onKeyDown:Q,onClick:z=>z.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:z=>{z.stopPropagation(),W()},disabled:V,children:e.jsx(fe,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(pe,{title:a("tool.restoreDefault"),onClick:z=>{z.stopPropagation(),G()},disabled:V,loading:V})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:O,title:f,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:f,children:a("tool.descriptionModifiedBadge")}),!t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"hub-icon-btn sm",onClick:z=>{z.stopPropagation(),I()},children:e.jsx(Te,{size:12})}),e.jsx(pe,{title:a("tool.restoreDefault"),onClick:z=>{z.stopPropagation(),G()},disabled:V,loading:V})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[u!=null&&e.jsxs("span",{className:"hub-mono flex-shrink-0",style:{fontSize:11,color:"var(--hub-ink-3)"},title:a("cost.estimate"),children:["Σ ",le(u)]}),e.jsx("div",{className:"flex h-[26px] items-center",onClick:z=>z.stopPropagation(),children:e.jsx(ke,{checked:s.enabled??!0,onCheckedChange:$,disabled:p||t,size:"card","aria-label":`${a(s.enabled??!0?"server.disable":"server.enable")} ${w}`})}),e.jsxs("button",{onClick:z=>{z.stopPropagation(),d(!0),o(!0)},className:"hub-btn sm",style:{color:"var(--hub-accent)"},disabled:p||!s.enabled,children:[p?e.jsx(us,{size:12,className:"animate-spin"}):e.jsx(ms,{size:12}),e.jsx("span",{children:a(p?"tool.running":"tool.run")})]}),e.jsx("button",{className:"hub-icon-btn sm",children:E?e.jsx(ze,{size:14}):e.jsx(Se,{size:14})})]})]}),E&&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:a("tool.defaultDescriptionLabel")}),e.jsx("span",{className:"whitespace-pre-wrap break-words",children:l.defaultDescription})]}),!g&&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:a("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)})]}),g&&e.jsxs("div",{style:{border:"1px solid var(--hub-line)",borderRadius:8,padding:14},children:[e.jsx(fs,{schema:s.inputSchema||{type:"object"},onSubmit:M,onCancel:te,loading:p,storageKey:m(),title:a("tool.runToolWithName",{name:w})}),k&&e.jsx("div",{style:{marginTop:12},children:e.jsx(bt,{result:k,onClose:re})})]})]})]})},yt=async(s,r)=>{try{const t=r?`/prompts/call/${r}`:"/prompts/call",n=await ce(t,{promptName:s.promptName,arguments:s.arguments});return n.success?{success:!0,data:n.data}:{success:!1,error:n.message||"Prompt call failed"}}catch(t){return console.error("Error calling prompt",{promptName:s.promptName,server:r,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},gs=async(s,r)=>{try{const t=await ce(`/mcp/${encodeURIComponent(r||"")}/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:r,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},jt=async(s,r,t)=>{try{const n=await ce(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(r)}/toggle`,{enabled:t});return{success:n.success,error:n.success?void 0:n.message}}catch(n){return console.error("Error toggling prompt",{serverName:s,promptName:r,enabled:t,error:n}),{success:!1,error:n instanceof Error?n.message:"Unknown error occurred"}}},ys=async(s,r,t)=>{try{const n=await Ne(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(r)}/description`,{description:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:n.success,error:n.success?void 0:n.message}}catch(n){return console.error("Error updating prompt description",{serverName:s,promptName:r,error:n}),{success:!1,error:n instanceof Error?n.message:"Unknown error occurred"}}},js=async(s,r)=>{var t;try{const n=await ls(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(r)}/description`,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:n.success,error:n.success?void 0:n.message,description:(t=n.data)==null?void 0:t.description}}catch(n){return console.error("Error resetting prompt description",{serverName:s,promptName:r,error:n}),{success:!1,error:n instanceof Error?n.message:"Unknown error occurred"}}},vt=Object.freeze(Object.defineProperty({__proto__:null,callPrompt:yt,getPrompt:gs,resetPromptDescription:js,togglePrompt:jt,updatePromptDescription:ys},Symbol.toStringTag,{value:"Module"})),ss=({result:s,onClose:r})=>{const{t}=ae(),n=b=>{if(typeof b=="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:b})});if(typeof b=="object"&&b!==null){if(b.description||b.messages)return e.jsxs("div",{className:"space-y-4",children:[b.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:b.description})})]}),b.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:b.messages.map((u,a)=>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:[u.role,":"]})}),typeof u.content=="string"?e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:u.content}):typeof u.content=="object"&&u.content.type==="text"?e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:u.content.text}):e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(u.content,null,2)})]},a))})]})]});try{const u=typeof b=="string"?JSON.parse(b):b;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(u,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(b)})})}}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(b)})})};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(cs,{size:20,className:"text-status-green"}):e.jsx(ds,{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:r,className:"text-gray-400 hover:text-gray-600 text-sm",children:"✕"})]})}),e.jsx("div",{className:"p-4",children:s.success?e.jsx("div",{children:s.data?e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:t("prompt.result")}),n(s.data)]}):e.jsx("div",{className:"text-sm text-gray-500 italic",children:t("prompt.noContent")})}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-3",children:[e.jsx(Ce,{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")})})]})})]})},Nt=({prompt:s,server:r,readOnly:t=!1,onToggle:n,onDescriptionUpdate:b,cost:u})=>{const{t:a}=ae(),{showToast:j}=Pe(),{nameSeparator:x}=we(),[E,d]=c.useState(!1),[g,o]=c.useState(!1),[p,_]=c.useState(!1),[k,D]=c.useState(null),[T,U]=c.useState(!1),[V,B]=c.useState(!1),[R,L]=c.useState(s.description||""),P=c.useRef(null),O=c.useRef(null),[q,ee]=c.useState(0);c.useEffect(()=>{T&&P.current&&(P.current.focus(),q>0&&(P.current.style.width=`${q+20}px`))},[T,q]),c.useEffect(()=>{!T&&O.current&&ee(O.current.offsetWidth)},[T,R]),c.useEffect(()=>{L(s.description||"")},[s.description]);const y=c.useCallback(()=>`mcphub_prompt_form_${r?`${r}_`:""}${s.name}`,[s.name,r]),h=c.useCallback(()=>{localStorage.removeItem(y())},[y]),w=v=>{!t&&n&&n(s.name,v)},l=()=>{t||U(!0)},f=async()=>{if(!t){U(!1);try{const v=await ys(r,s.name,R);v.success?b&&b(s.name,R):(j(v.error||a("prompt.descriptionUpdateFailed"),"error"),L(s.description||""))}catch(v){console.error("Error updating prompt description:",v),j(a("prompt.descriptionUpdateFailed"),"error"),L(s.description||"")}}},m=async()=>{if(!t){B(!0);try{const v=await js(r,s.name);if(v.success){const M=v.description||"";L(M),U(!1),b==null||b(s.name,M,{restored:!0})}else j(v.error||a("prompt.restoreDefaultFailed"),"error")}catch(v){console.error("Error resetting prompt description:",v),j(a("prompt.restoreDefaultFailed"),"error")}finally{B(!1)}}},N=v=>{L(v.target.value)},$=v=>{v.key==="Enter"?f():v.key==="Escape"&&(L(s.description||""),U(!1))},I=async v=>{_(!0);try{const M=await gs({promptName:s.name,arguments:v},r);console.log("GetPrompt result:",M),D({success:M.success,data:M.data,error:M.error})}catch(M){D({success:!1,error:M instanceof Error?M.message:"Unknown error occurred"})}finally{_(!1)}},W=()=>{o(!1),h(),D(null)},Y=()=>{D(null)},G=s.name.replace(r+x,""),Q=()=>{if(!s.arguments||s.arguments.length===0)return{type:"object",properties:{},required:[]};const v={},M=[];return s.arguments.forEach(te=>{v[te.name]={type:"string",description:te.description||""},te.required&&M.push(te.name)}),{type:"object",properties:v,required:M}};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:()=>d(!E),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:G}),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:T?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:P,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:q>0?`${q+20}px`:160,minWidth:80},value:R,onChange:N,onKeyDown:$,onClick:v=>v.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:v=>{v.stopPropagation(),f()},disabled:V,children:e.jsx(fe,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(pe,{title:a("prompt.restoreDefault"),onClick:v=>{v.stopPropagation(),m()},disabled:V,loading:V})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:O,children:R||a("tool.noDescription")}),!t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"hub-icon-btn sm",onClick:v=>{v.stopPropagation(),l()},children:e.jsx(Te,{size:12})}),e.jsx(pe,{title:a("prompt.restoreDefault"),onClick:v=>{v.stopPropagation(),m()},disabled:V,loading:V})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[u!=null&&e.jsxs("span",{className:"hub-mono flex-shrink-0",style:{fontSize:11,color:"var(--hub-ink-3)"},title:a("cost.estimate"),children:["Σ ",le(u)]}),e.jsx("div",{className:"flex h-[26px] items-center",onClick:v=>v.stopPropagation(),children:s.enabled!==void 0&&e.jsx(ke,{checked:s.enabled,onCheckedChange:w,disabled:p||t,size:"card","aria-label":`${a(s.enabled?"server.disable":"server.enable")} ${G}`})}),e.jsxs("button",{onClick:v=>{v.stopPropagation(),d(!0),o(!0)},className:"hub-btn sm",style:{color:"var(--hub-accent)"},disabled:p||!s.enabled,children:[p?e.jsx(us,{size:12,className:"animate-spin"}):e.jsx(ms,{size:12}),e.jsx("span",{children:a(p?"tool.running":"tool.run")})]}),e.jsx("button",{className:"hub-icon-btn sm",children:E?e.jsx(ze,{size:14}):e.jsx(Se,{size:14})})]})]}),E&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",padding:"10px 12px",display:"flex",flexDirection:"column",gap:10},children:[g&&e.jsxs("div",{style:{border:"1px solid var(--hub-line)",borderRadius:8,padding:14},children:[e.jsx(fs,{schema:Q(),onSubmit:I,onCancel:W,loading:p,storageKey:y(),title:a("prompt.runPromptWithName",{name:G})}),k&&e.jsx("div",{style:{marginTop:12},children:e.jsx(ss,{result:k,onClose:Y})})]}),!g&&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:a("tool.parameters")}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:s.arguments.map((v,M)=>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:v.name}),v.required&&e.jsx("span",{style:{color:"var(--hub-err)",fontSize:12},children:"*"})]}),v.description&&e.jsx("p",{style:{fontSize:12,color:"var(--hub-ink-3)",margin:"2px 0 0"},children:v.description})]}),v.title&&e.jsx("span",{style:{fontSize:11,color:"var(--hub-ink-3)"},children:v.title})]},M))})]}),!g&&k&&e.jsx("div",{children:e.jsx(ss,{result:k,onClose:Y})})]})]})},wt=({resource:s,readOnly:r=!1,onToggle:t,onDescriptionUpdate:n,cost:b})=>{const{t:u}=ae(),[a,j]=c.useState(!1),[x,E]=c.useState(!1),[d,g]=c.useState(!1),[o,p]=c.useState(s.description||""),_=c.useRef(null),k=c.useRef(null),[D,T]=c.useState(0);c.useEffect(()=>{x&&_.current&&(_.current.focus(),D>0&&(_.current.style.width=`${D+20}px`))},[x,D]),c.useEffect(()=>{!x&&k.current&&T(k.current.offsetWidth)},[x,o]),c.useEffect(()=>{p(s.description||"")},[s.description]);const U=s.name||s.uri,V=P=>{!r&&t&&t(s.uri,P)},B=async()=>{r||(E(!1),n&&await n(s.uri,o))},R=async()=>{if(!r){g(!0);try{await(n==null?void 0:n(s.uri,"",{restored:!0})),E(!1)}finally{g(!1)}}},L=P=>{P.key==="Enter"?B():P.key==="Escape"&&(p(s.description||""),E(!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(!a),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:U}),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:x?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:_,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:D>0?`${D+20}px`:160,minWidth:80},value:o,onChange:P=>p(P.target.value),onKeyDown:L,onClick:P=>P.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:P=>{P.stopPropagation(),B()},disabled:d,children:e.jsx(fe,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(pe,{title:u("builtinResources.restoreDefault"),onClick:P=>{P.stopPropagation(),R()},disabled:d,loading:d})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:k,children:o||u("tool.noDescription")}),!r&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"hub-icon-btn sm",onClick:P=>{P.stopPropagation(),E(!0)},children:e.jsx(Te,{size:12})}),e.jsx(pe,{title:u("builtinResources.restoreDefault"),onClick:P=>{P.stopPropagation(),R()},disabled:d,loading:d})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[b!=null&&e.jsxs("span",{className:"hub-mono flex-shrink-0",style:{fontSize:11,color:"var(--hub-ink-3)"},title:u("cost.estimate"),children:["Σ ",le(b)]}),e.jsx("div",{className:"flex h-[26px] items-center",onClick:P=>P.stopPropagation(),children:e.jsx(ke,{checked:s.enabled!==!1,onCheckedChange:V,disabled:r,size:"card","aria-label":`${u(s.enabled!==!1?"server.disable":"server.enable")} ${U}`})}),e.jsx("button",{className:"hub-icon-btn sm",children:a?e.jsx(ze,{size:14}):e.jsx(Se,{size:14})})]})]}),a&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",padding:"8px 12px"},children:[e.jsxs("span",{className:"hub-sect",children:[u("builtinResources.mimeType"),":"]})," ",e.jsx("span",{style:{fontSize:12,color:"var(--hub-ink-2)"},children:s.mimeType||"text/plain"})]})]})},kt=(s,r)=>r?r.isAdmin?!0:!!(s.owner&&s.owner===r.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:"Shared",longKey:"server.visibilityGroup",longFallback:"Shared — selected users only",className:"bg-[oklch(0.97_0.02_85)] text-[oklch(0.45_0.07_85)] border-[oklch(0.88_0.04_85)]"},public:{shortKey:"server.visibilityPublicShort",shortFallback:"Public",longKey:"server.visibilityPublic",longFallback:"Public — every authenticated user",className:"bg-[oklch(0.97_0.03_145)] text-[oklch(0.42_0.12_145)] border-[oklch(0.88_0.04_145)]"}},$e=s=>s==="public"||s==="group"?s:"private",St=(s,r)=>{const t=$e(r),n=Ct[t];return{value:t,shortLabel:s(n.shortKey,{defaultValue:n.shortFallback}),longLabel:s(n.longKey,{defaultValue:n.longFallback}),className:n.className}},Et=(s,r)=>{const t=$e(r),n=[{value:"private",label:s("server.visibilityPrivateShort",{defaultValue:"Private"}),disabled:!1}];return t==="group"&&n.push({value:"group",label:s("server.visibilityGroupShort",{defaultValue:"Shared"}),disabled:!0}),n.push({value:"public",label:s("server.visibilityPublicShort",{defaultValue:"Public"}),disabled:!1}),n},ts=({isLoading:s,children:r,className:t,overlayStyle:n,spinnerSize:b=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:r}),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,...n},children:e.jsx(me,{size:b,className:"animate-spin",style:{color:"var(--hub-ink-3)"}})})]}),rs=({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"})}),ns=(s,r)=>r?r==="stdio"?s("server.typeStdio")||"stdio":r==="sse"?s("server.typeSse")||"sse":r==="streamable-http"?s("server.typeStreamableHttp")||"http":r==="openapi"?s("server.typeOpenapi")||"openapi":r:null,Dt="text/html;profile=mcp-app",as=s=>s?!!(s.ui||s["ui/resourceUri"]):!1,Pt=s=>{var r,t;return!!((r=s.tools)!=null&&r.some(n=>as(n._meta))||(t=s.resources)!=null&&t.some(n=>{var b;return((b=n.uri)==null?void 0:b.startsWith("ui://"))||n.mimeType===Dt||as(n._meta)}))},Tt=({server:s,cost:r,onRemove:t,onEdit:n,onDuplicate:b,isDuplicating:u=!1,onToggle:a,onVisibilityChange:j,onRefresh:x,onReload:E,onReinstall:d,onOAuthDisconnect:g})=>{var Ae,Me,Ve,Ue,Be,Je,Le,We,qe,Ke,He,Ge,Xe,Ye,Ze,Qe;const{t:o}=ae(),{showToast:p}=Pe(),{exportMCPSettings:_,installConfig:k}=we(),{auth:D}=Vs(),T=((Ae=k==null?void 0:k.baseUrl)==null?void 0:Ae.replace(/\/+$/,""))||"",[U,V]=c.useState(!1),[B,R]=c.useState(null),[L,P]=c.useState(!1),[O,q]=c.useState(!1),[ee,y]=c.useState(!1),[h,w]=c.useState(null),[l,f]=c.useState(!1),[m,N]=c.useState(!1),[$,I]=c.useState(!1),[W,Y]=c.useState(!1),[G,Q]=c.useState(!1),[v,M]=c.useState(!1),[te,re]=c.useState(!1),[z,K]=c.useState(!1),J=c.useRef(null),F=c.useRef(null);c.useEffect(()=>{const i=S=>{J.current&&!J.current.contains(S.target)&&M(!1),F.current&&!F.current.contains(S.target)&&re(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[]);const H=((Me=s.tools)==null?void 0:Me.length)||0,ne=((Ve=s.tools)==null?void 0:Ve.filter(i=>i.enabled!==!1).length)||0,ge=((Ue=s.prompts)==null?void 0:Ue.length)||0,ye=((Be=s.prompts)==null?void 0:Be.filter(i=>i.enabled!==!1).length)||0,je=((Je=s.resources)==null?void 0:Je.length)||0,Z=((Le=s.resources)==null?void 0:Le.filter(i=>i.enabled!==!1).length)||0,oe=Pt(s),ie=s.enabled!==!1,X=kt(s,D.user),he=((We=s.config)==null?void 0:We.command)==="npx"||((qe=s.config)==null?void 0:qe.command)==="uvx",xe=!!((Ke=s.oauth)!=null&&Ke.connected&&g),vs=async i=>{if(!(!X||l||!a)){f(!0);try{await a(s,i)}finally{f(!1)}}},Ns=async i=>{if(i.stopPropagation(),M(!1),!(!X||$||!E)){I(!0);try{await E(s)?p(o("server.reloadSuccess")||"Server reloaded successfully","success"):p(o("server.reloadError",{serverName:s.name})||"Failed to reload","error")}finally{I(!1)}}},ws=async()=>{if(M(!1),!(!X||W||!d)){Y(!0);try{await d(s)?p(o("server.reinstallSuccess")||"Server reinstall initiated","success"):p(o("server.reinstallError",{serverName:s.name})||"Failed to reinstall","error")}finally{Y(!1)}}},ks=async()=>{if(M(!1),!(!X||G||!g)){Q(!0);try{await g(s)?p(o("server.disconnectOAuthSuccess")||"Server OAuth disconnected","success"):p(o("server.disconnectOAuthError",{serverName:s.name})||"Failed to disconnect OAuth","error")}finally{Q(!1)}}},Cs=async i=>{var C;if(i.stopPropagation(),!X||m||!j)return;const S=i.target.value;if(S!==$e(s.visibility??((C=s.config)==null?void 0:C.visibility))){N(!0);try{await j(s,S)}finally{N(!1)}}},Ss=async i=>{if(i.stopPropagation(),!s.error)return;await es(s.error)?(K(!0),p(o("common.copySuccess")||"Copied","success"),setTimeout(()=>K(!1),1500)):p(o("common.copyFailed")||"Copy failed","error")},Es=async i=>{var S,C;if(i.stopPropagation(),M(!1),!!X)try{const A=await _(s.name),se=(C=(S=A==null?void 0:A.data)==null?void 0:S.mcpServers)==null?void 0:C[s.name];if(!A||!A.success||!se){p((A==null?void 0:A.message)||o("common.copyFailed")||"Copy failed","error");return}w(it(s.name,se))}catch(A){console.error("Error copying server configuration:",A),p(o("common.copyFailed")||"Copy failed","error")}},Ds=i=>{var S;if(i.stopPropagation(),(S=s.oauth)!=null&&S.authorizationUrl){const se=window.screen.width/2-300,de=window.screen.height/2-700/2;window.open(s.oauth.authorizationUrl,"OAuth Authorization",`width=600,height=700,left=${se},top=${de}`),p(o("status.oauthWindowOpened"),"info"),s.oauth.clientIdConfigured&&p(o("status.oauthClientIdHint"),"warning")}},Ps=async(i,S)=>{try{const{toggleTool:C}=await ve(async()=>{const{toggleTool:se}=await Promise.resolve().then(()=>xt);return{toggleTool:se}},void 0,import.meta.url),A=await C(s.name,i,S);A.success?(p(o(S?"tool.enableSuccess":"tool.disableSuccess",{name:i}),"success"),x==null||x()):p(A.error||o("tool.toggleFailed"),"error")}catch(C){console.error(C),p(o("tool.toggleFailed"),"error")}},Ts=async(i,S)=>{try{const{togglePrompt:C}=await ve(async()=>{const{togglePrompt:se}=await Promise.resolve().then(()=>vt);return{togglePrompt:se}},void 0,import.meta.url),A=await C(s.name,i,S);A.success?(p(o(S?"tool.enableSuccess":"tool.disableSuccess",{name:i}),"success"),x==null||x()):p(A.error||o("tool.toggleFailed"),"error")}catch(C){console.error(C),p(o("tool.toggleFailed"),"error")}},zs=async(i,S)=>{try{const{toggleResource:C}=await ve(async()=>{const{toggleResource:se}=await import("./resourceService-CAxgCzyV.js");return{toggleResource:se}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),A=await C(s.name,i,S);A.success?(p(o(S?"tool.enableSuccess":"tool.disableSuccess",{name:i}),"success"),x==null||x()):p(A.error||o("tool.toggleFailed"),"error")}catch(C){console.error(C),p(o("tool.toggleFailed"),"error")}},$s=(i,S,C)=>{p(C!=null&&C.restored?o("tool.restoreDefaultSuccess"):o("tool.descriptionUpdateSuccess"),"success"),x==null||x()},Is=(i,S,C)=>{p(C!=null&&C.restored?o("prompt.restoreDefaultSuccess"):o("prompt.descriptionUpdateSuccess"),"success"),x==null||x()},Fs=async(i,S,C)=>{try{const{updateResourceDescription:A,resetResourceDescription:se}=await ve(async()=>{const{updateResourceDescription:Os,resetResourceDescription:_s}=await import("./resourceService-CAxgCzyV.js");return{updateResourceDescription:Os,resetResourceDescription:_s}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),de=C!=null&&C.restored?await se(s.name,i):await A(s.name,i,S);de.success?(p(C!=null&&C.restored?o("builtinResources.restoreDefaultSuccess"):o("builtinResources.descriptionUpdateSuccess"),"success"),x==null||x()):p(de.error||(C!=null&&C.restored?o("builtinResources.restoreDefaultFailed"):o("builtinResources.descriptionUpdateFailed")),"error")}catch(A){console.error(A),p(C!=null&&C.restored?o("builtinResources.restoreDefaultFailed"):o("builtinResources.descriptionUpdateFailed"),"error")}};(()=>{var C;const i=s.config;if(!i)return"";if(i.url)return i.url;const S=[];return i.command&&S.push(i.command),(C=i.args)!=null&&C.length&&S.push(...i.args),S.join(" ")})();const Ie=`${T}/mcp/${s.name}`,Fe=`${T}/api/${s.name}`,Re=async i=>{const S=await es(i);p(S?o("common.copySuccess")||"Copied":o("common.copyFailed")||"Failed",S?"success":"error")},Oe=(i,S)=>o(i,S),ue=St(Oe,s.visibility??((He=s.config)==null?void 0:He.visibility)),Rs=Et(Oe,ue.value),_e=[{key:"tools",icon:qs,total:H,enabled:ne,label:o("server.tools")},{key:"prompts",icon:Ks,total:ge,enabled:ye,label:o("server.prompts")},{key:"resources",icon:Hs,total:je,enabled:Z,label:o("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:()=>V(!U),children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx(Se,{size:12,style:{color:"var(--hub-ink-3)",transform:U?"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:ie?"var(--hub-ink)":"var(--hub-ink-3)"},children:s.name}),he&&s.packageVersion&&e.jsxs("span",{className:"hub-tag flex-shrink-0",title:o("server.packageVersion"),style:{fontSize:11},children:["v",s.packageVersion]}),he&&s.updateAvailable&&s.latestVersion&&e.jsxs("span",{className:"hub-tag flex-shrink-0",title:o("server.updateAvailable"),style:{fontSize:11,color:"var(--hub-warn)"},children:["↑ ",s.latestVersion]}),oe&&e.jsx("span",{className:"hub-tag accent flex-shrink-0",title:o("server.mcpApp"),children:"App"}),s.error&&e.jsxs("div",{className:"relative",ref:F,children:[e.jsx("button",{onClick:i=>{i.stopPropagation(),re(S=>!S)},className:"text-[var(--hub-err)] hover:opacity-80","aria-label":o("server.viewErrorDetails"),children:e.jsx(Ce,{size:14})}),te&&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:o("server.errorDetails")}),e.jsx("button",{onClick:Ss,className:"hub-icon-btn sm",title:o("common.copy"),children:z?e.jsx(fe,{size:12,className:"text-[var(--hub-ok)]"}):e.jsx(be,{size:12})})]}),e.jsx("button",{onClick:()=>re(!1),className:"hub-icon-btn sm","aria-label":o("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})})]})]})]}),!!((Xe=(Ge=s.config)==null?void 0:Ge.credentialTemplate)!=null&&Xe.length)&&e.jsxs(As,{className:"hub-tag text-xs",to:`/credentials?server=${encodeURIComponent(s.name)}`,onClick:i=>i.stopPropagation(),children:[o("credentials.personalBadge")," · ",o("credentials.manage")]}),((Ye=s.config)==null?void 0:Ye.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(Ls,{status:s.status,enabled:s.enabled,startOnDemand:((Ze=s.config)==null?void 0:Ze.startOnDemand)===!0,onAuthClick:Ds,className:"hub-server-card-status"})}),e.jsx("div",{className:"hub-server-card-transport-cell min-w-0",children:(Qe=s.config)!=null&&Qe.type?e.jsx("span",{className:"hub-tag hub-server-card-transport-tag",title:ns(o,s.config.type)??void 0,children:ns(o,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:X&&j?e.jsx(ts,{isLoading:m,className:"w-full",overlayStyle:{borderRadius:6},children:e.jsx("select",{value:ue.value,onChange:Cs,disabled:m,className:"hub-server-card-select w-full rounded-md border px-2 py-1 text-[11.5px] bg-[var(--hub-surface)] text-[var(--hub-ink)]",style:{borderColor:"var(--hub-line-2)"},"aria-label":o("server.visibility","Visibility"),title:ue.longLabel,children:Rs.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})}),_e.map(({key:i,icon:S,total:C,enabled:A,label:se})=>{const de=C===0;return e.jsxs("span",{className:`hub-server-capability-stat hub-mono hub-num ${de?"is-empty":""}`,title:`${se}: ${A}/${C}`,children:[e.jsx("span",{className:"text-[var(--hub-ink-3)]",children:e.jsx(rs,{icon:S})}),e.jsx("span",{className:"hub-server-capability-value",children:de?"0":`${A}/${C}`})]},i)}),r&&r.connected?e.jsxs("span",{className:"hub-server-capability-stat hub-mono hub-num",title:`${o("cost.exposed")} ${r.exposed} / ${o("cost.gross")} ${r.gross} · ${o("cost.estimate")}`,children:[e.jsx("span",{className:"text-[var(--hub-ink-3)]",children:"Σ"}),e.jsxs("span",{className:"hub-server-capability-value",children:[le(r.exposed),"/",le(r.gross)]})]}):r?e.jsx("span",{className:"hub-server-capability-stat hub-mono is-empty",title:o("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(ts,{isLoading:l,className:"h-[18px] w-[30px]",overlayStyle:{borderRadius:999,background:"var(--hub-bg-2)"},spinnerSize:10,children:e.jsx(ke,{checked:ie,onCheckedChange:vs,disabled:l||!X,size:"compact","aria-label":`${o(ie?"server.disable":"server.enable")} ${s.name}`})})}),e.jsxs("div",{className:"relative",ref:J,children:[X&&e.jsx("button",{className:"hub-icon-btn",onClick:i=>{i.stopPropagation(),M(S=>!S)},"aria-label":"More","aria-busy":u,children:u?e.jsx(me,{size:14,className:"animate-spin"}):e.jsx(Gs,{size:14})}),X&&v&&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(),M(!1),n(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(Xs,{size:13})," ",o("server.edit")]}),b&&e.jsxs("button",{onClick:i=>{i.stopPropagation(),M(!1),!u&&b(s)},disabled:u,"aria-busy":u,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:[u?e.jsx(me,{size:13,className:"animate-spin"}):e.jsx(Ys,{size:13})," ",o("server.duplicate")]}),e.jsxs("button",{onClick:Es,className:"flex items-center gap-2 w-full px-2.5 py-1.5 text-[13px] rounded-md hover:bg-[var(--hub-surface-hover)] text-left",style:{color:"var(--hub-ink)"},children:[e.jsx(be,{size:13})," ",o("server.copy")]}),E&&e.jsxs("button",{onClick:Ns,disabled:$||l||!ie,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(me,{size:13})," ",o("server.reload")]}),d&&he&&e.jsxs("button",{onClick:i=>{i.stopPropagation(),M(!1),!(!X||W||!ie)&&q(!0)},disabled:W||l||!ie,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(Zs,{size:13})," ",o("server.reinstall")]}),xe&&e.jsxs("button",{onClick:i=>{i.stopPropagation(),M(!1),!(!X||G)&&y(!0)},disabled:G,className:"flex items-center gap-2 w-full px-2.5 py-1.5 text-[13px] rounded-md hover:bg-[var(--hub-surface-hover)] text-left disabled:opacity-50 disabled:cursor-not-allowed",style:{color:"var(--hub-ink)"},children:[e.jsx(Qs,{size:13})," ",o("server.disconnectOAuth")]}),e.jsx("div",{style:{height:1,background:"var(--hub-line-2)",margin:"4px 0"}}),e.jsxs("button",{onClick:i=>{i.stopPropagation(),M(!1),P(!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(et,{size:13})," ",o("server.delete")]})]})]})]}),U&&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:[_e.map(i=>{const S=B===i.key,C=i.icon;return e.jsxs("button",{onClick:()=>R(S?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:S?"var(--hub-surface)":"transparent",border:"1px solid "+(S?"var(--hub-line)":"transparent"),color:S?"var(--hub-ink)":"var(--hub-ink-2)"},children:[e.jsx(rs,{icon:C}),e.jsx("span",{children:i.label}),e.jsx("span",{className:"hub-mono hub-num",style:{color:"var(--hub-ink-3)",fontSize:11},children:i.total===0?"0":`${i.enabled}/${i.total}`})]},i.key)}),r&&r.connected&&e.jsxs("button",{onClick:()=>R(B==="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:B==="cost"?"var(--hub-surface)":"transparent",border:"1px solid "+(B==="cost"?"var(--hub-line)":"transparent"),color:B==="cost"?"var(--hub-ink)":"var(--hub-ink-2)"},title:o("cost.estimate"),children:[e.jsx("span",{style:{color:"var(--hub-ink-3)"},children:"Σ"}),e.jsx("span",{children:o("cost.totalFootprint")}),e.jsxs("span",{className:"hub-mono hub-num",style:{color:"var(--hub-ink-3)",fontSize:11},children:[le(r.exposed),"/",le(r.gross)]})]}),e.jsxs("div",{className:"ml-auto max-w-full flex-shrink-0 flex items-center justify-end gap-1.5 flex-wrap",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:i=>{i.stopPropagation(),Re(Ie)},title:o("common.copyUrl"),children:e.jsx(be,{size:12})})]}),e.jsxs("div",{className:"hub-endpoint",style:{height:26},children:[e.jsx("div",{className:"hub-endpoint-label",children:"/api/"}),e.jsx("div",{className:"hub-endpoint-url",title:Fe,style:{maxWidth:200},children:s.name}),e.jsx("button",{type:"button",className:"hub-endpoint-copy",onClick:i=>{i.stopPropagation(),Re(Fe)},title:o("common.copyOpenApiUrl"),children:e.jsx(be,{size:12})})]})]})]}),B==="cost"&&(r==null?void 0:r.connected)&&e.jsx("div",{className:"mt-2 space-y-1",children:[...r.items].sort((i,S)=>S.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:le(i.cost)})]},`${i.kind}:${i.name}`))}),B==="tools"&&s.tools&&e.jsx("div",{className:"space-y-3 mt-2",children:s.tools.map((i,S)=>{var C;return e.jsx(gt,{server:s.name,tool:i,readOnly:!X,onToggle:Ps,onDescriptionUpdate:$s,cost:(C=r==null?void 0:r.items.find(A=>A.kind==="tool"&&A.name===i.name))==null?void 0:C.cost},S)})}),B==="prompts"&&s.prompts&&e.jsx("div",{className:"space-y-3 mt-2",children:s.prompts.map((i,S)=>{var C;return e.jsx(Nt,{server:s.name,prompt:i,readOnly:!X,onToggle:Ts,onDescriptionUpdate:Is,cost:(C=r==null?void 0:r.items.find(A=>A.kind==="prompt"&&A.name===i.name))==null?void 0:C.cost},S)})}),B==="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:o("builtinResources.noResources")}):e.jsx("div",{className:"space-y-3",children:s.resources.map((i,S)=>{var C;return e.jsx(wt,{resource:i,readOnly:!X,onToggle:zs,onDescriptionUpdate:Fs,cost:(C=r==null?void 0:r.items.find(A=>A.kind==="resource"&&A.name===i.uri))==null?void 0:C.cost},`${i.uri}-${S}`)})})})]})]}),e.jsx(ot,{isOpen:h!==null,target:h,onClose:()=>w(null)}),e.jsx(lt,{isOpen:L,onClose:()=>P(!1),onConfirm:()=>{t(s.name),P(!1)},serverName:s.name}),e.jsx(De,{isOpen:O,onClose:()=>q(!1),onConfirm:()=>{q(!1),ws()},title:o("server.reinstall"),message:o("server.reinstallConfirm")||"This will clear the package cache and re-download dependencies. The server will restart.",confirmText:o("server.reinstall"),variant:"warning"}),e.jsx(De,{isOpen:ee,onClose:()=>y(!1),onConfirm:()=>{y(!1),ks()},title:o("server.disconnectOAuth"),message:o("server.disconnectOAuthConfirm")||"This will revoke stored OAuth credentials where supported and require authorization again.",confirmText:o("server.disconnectOAuth"),variant:"warning"})]})},os="-copy",zt=s=>{const r=Math.max(ct-os.length,0);return`${s.slice(0,r)}${os}`},$t=s=>{const{oauth:r,...t}=s.config??{},{accessToken:n,refreshToken:b,pendingAuthorization:u,...a}=r??{};return{name:zt(s.name),status:"disconnected",config:{...t,...Object.keys(a).length>0?{oauth:a}:{}}}},It=(s,r)=>{if(s)return Object.fromEntries(Object.entries(s).map(([t,n])=>[r(t),n]))},Ft=(s,r,t={})=>{const n=r.config;if(!n)return s;const b=t.nameSeparator||"-",u=new Set((r.tools??[]).map(g=>g.name)),a=g=>`${s.name}${g.slice(r.name.length)}`,j=`${r.name}${b}`,x=n.tools?Object.fromEntries(Object.entries(n.tools).flatMap(([g,o])=>u.has(g)?[[a(g),o]]:g.startsWith(j)&&u.has(`${j}${g}`)?[[g,o]]:g.startsWith(j)?[]:[[g,o]])):void 0,E=It(n.prompts,g=>g.startsWith(j)?a(g):g),d={};return x&&Object.keys(x).length>0&&(d.tools=x),E&&Object.keys(E).length>0&&(d.prompts=E),n.resources&&Object.keys(n.resources).length>0&&(d.resources=n.resources),{...s,config:{...s.config,...d}}},is=(s,r)=>s===r?"commit":"stale",Rt=({onAdd:s,duplicateSource:r=null,onDuplicateCancel:t})=>{const{t:n}=ae(),{nameSeparator:b}=we(),[u,a]=c.useState(!1),[j,x]=c.useState(null),[E,d]=c.useState(!1),[g,o]=c.useState(null),[p,_]=c.useState([]),k=c.useMemo(()=>r?$t(r):null,[r]),D=u||r!==null,T=()=>{x(null),d(!1),o(null)},U=()=>{a(!1),T(),r&&(t==null||t())},V=()=>{if(D){U();return}a(!0),T()},B=async()=>{g&&(await R(g),d(!1),o(null))},R=async P=>{try{x(null);const O=await ce("/servers",P);if(!O.success){O&&O.message?x(O.message):x(n("server.addError"));return}U(),s()}catch(O){console.error("Error adding server:",O),navigator.onLine?O instanceof TypeError&&(O.message.includes("NetworkError")||O.message.includes("Failed to fetch"))?x(n("errors.serverConnection")):x(n("errors.serverAdd")):x(n("errors.network"))}},L=async P=>{try{const O=r?Ft(P,r,{nameSeparator:b}):P,q=dt(O);q.length>0?(_(q),o(O),d(!0)):await R(O)}catch(O){console.error("Error processing server submission:",O),x(n("errors.serverAdd"))}};return e.jsxs("div",{children:[e.jsxs("button",{onClick:V,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")]}),D&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(ps,{onSubmit:L,onCancel:U,initialData:k,mode:"create",shareCandidatesFrom:r==null?void 0:r.name,modalTitle:r?n("server.duplicateTitle",{serverName:r.name}):n("server.addServer"),formError:j},(r==null?void 0:r.name)??"add")}),E&&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:p.map((P,O)=>e.jsxs("li",{className:"font-mono",children:["$",`{${P}}`]},O))})]})]})}),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:()=>{d(!1),o(null)},className:"hub-btn",children:n("common.cancel")}),e.jsx("button",{onClick:B,className:"hub-btn primary",children:n("server.confirmAndAdd")})]})]})})]})},Ot=({server:s,onEdit:r,onCancel:t})=>{const{t:n}=ae(),[b,u]=c.useState(null),a=async j=>{try{u(null);const x=encodeURIComponent(s.name),E=j.name&&j.name!==s.name,d={config:j.config,...E?{newName:j.name}:{}},g=await Ne(`/servers/${x}`,d);if(!g.success){g&&g.message?u(g.message):u(n("server.updateError",{serverName:s.name}));return}r()}catch(x){console.error("Error updating server:",x),navigator.onLine?x instanceof TypeError&&(x.message.includes("NetworkError")||x.message.includes("Failed to fetch"))?u(n("errors.serverConnection")):u(n("errors.serverUpdate",{serverName:s.name})):u(n("errors.network"))}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(ps,{onSubmit:a,onCancel:t,initialData:s,modalTitle:n("server.editTitle",{serverName:s.name}),formError:b},s.name)})},_t=({onSuccess:s,onCancel:r})=>{const{t}=ae(),[n,b]=c.useState(!1),[u,a]=c.useState(!1),[j,x]=c.useState(null),[E,d]=c.useState(null),[g,o]=c.useState(!1),[p,_]=c.useState(null),[k,D]=c.useState(""),[T,U]=c.useState(!1),[V,B]=c.useState(""),R=l=>{l.preventDefault(),b(!0)},L=l=>{l.preventDefault(),b(!1)},P=l=>{l.preventDefault(),b(!1);const f=l.dataTransfer.files;if(f.length>0){const m=f[0];m.name.endsWith(".mcpb")?(d(m),x(null)):x(t("mcpb.invalidFileType"))}},O=l=>{const f=l.target.files;if(f&&f.length>0){const m=f[0];m.name.endsWith(".mcpb")?(d(m),x(null)):x(t("mcpb.invalidFileType"))}},q=async()=>{if(!E){x(t("mcpb.noFileSelected"));return}a(!0),x(null);try{const l=new FormData;l.append("mcpbFile",E);const f=await Bs(Js("/mcpb/upload"),{method:"POST",body:l}),m=await f.json();if(!f.ok)throw new Error(m.message||`HTTP error! Status: ${f.status}`);if(m.success&&m.data)_(m.data.manifest),D(m.data.extractDir),o(!0);else throw new Error(m.message||t("mcpb.uploadFailed"))}catch(l){console.error("MCPB upload error:",l),x(l instanceof Error?l.message:t("mcpb.uploadFailed"))}finally{a(!1)}},ee=async(l,f=!1)=>{var m;a(!0),x(null);try{const N=w(p,k,l);if(!f){const I=await Us("/servers");if(I.success&&((m=I.data)==null?void 0:m.find(Y=>Y.name===l))){B(l),U(!0),a(!1);return}}let $;if(f?$=await Ne(`/servers/${encodeURIComponent(l)}`,{name:l,config:N}):$=await ce("/servers",{name:l,config:N}),$.success)s(N);else throw new Error($.message||t("mcpb.installFailed"))}catch(N){console.error("MCPB install error:",N),x(N instanceof Error?N.message:t("mcpb.installFailed")),a(!1)}},y=()=>{U(!1),V&&ee(V,!0)},h=()=>{U(!1),B(""),a(!1)},w=(l,f,m)=>{var I;const N=((I=l.server)==null?void 0:I.mcp_config)||{},$={type:"stdio",command:N.command||"node",args:(N.args||[]).map(W=>W.replace("${__dirname}",f))};return N.env&&Object.keys(N.env).length>0&&($.env={...N.env},Object.keys($.env).forEach(W=>{typeof $.env[W]=="string"&&($.env[W]=$.env[W].replace("${__dirname}",f))})),$};return g&&p?e.jsxs(e.Fragment,{children:[e.jsx(De,{isOpen:T,onClose:h,onConfirm:y,title:t("mcpb.serverExistsTitle"),message:t("mcpb.serverExistsConfirm",{serverName:V}),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 ${T?"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:r,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"),":"]})," ",p.display_name||p.name]}),e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.version"),":"]})," ",p.version]}),e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.description"),":"]})," ",p.description]}),p.author&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.author"),":"]})," ",p.author.name]}),p.tools&&p.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:p.tools.map((l,f)=>e.jsxs("li",{children:[l.name," - ",l.description]},f))})]})]})]}),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:p.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:r,disabled:u,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:()=>{const l=document.getElementById("serverName"),f=(l==null?void 0:l.value.trim())||p.name;ee(f)},disabled:u,className:"hub-btn primary",children:u?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:r,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 ${n?"border-blue-500 bg-blue-50":E?"border-gray-500 ":"border-gray-300 hover:border-gray-400"}`,onDragOver:R,onDragLeave:L,onDrop:P,children:[E?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:E.name}),e.jsxs("p",{className:"text-xs text-gray-500",children:[(E.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:O,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:r,disabled:u,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:q,disabled:!E||u,className:"hub-btn primary flex items-center",children:u?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")})]})]})})},At=["sse","streamable-http"],Mt=new Set(["type","url","command","args","env","headers","options","openapi","oauth","enabled","visibility","keepAliveInterval","enableKeepAlive","perSessionClient","tools","prompts","passthroughHeaders","proxy"]),Vt=s=>{const r=[],t=[];for(const[n,b]of Object.entries(s.mcpServers)){const u=b??{},a={},j=Object.keys(u).filter(x=>!Mt.has(x));if(j.length>0){t.push({name:n,message:`unknown field(s) "${j.join('", "')}" — not part of the mcphub server schema. For OAuth, use an "oauth" object (e.g. {"scopes":["email"]}).`});continue}if(u.type==="sse"||u.type==="streamable-http"){if(a.type=u.type,a.url=u.url,u.headers&&(a.headers=u.headers),u.oauth&&(a.oauth=u.oauth),!u.url){t.push({name:n,message:`"${u.type}" servers require a "url" field.`});continue}}else if(u.type==="openapi")a.type="openapi",a.openapi=u.openapi;else if(u.type===void 0||u.type==="stdio"){if(u.url&&!u.command){t.push({name:n,message:`has a "url" but type "${u.type??"stdio"}". Use "streamable-http" or "sse" for remote servers.`});continue}if(a.type="stdio",a.command=u.command,a.args=u.args||[],u.env&&(a.env=u.env),u.options&&(a.options=u.options),!u.command){t.push({name:n,message:'stdio servers require a "command" field.'});continue}}else{const x=At.includes(String(u.type))?"":' Did you mean "streamable-http"? Supported types: stdio, sse, streamable-http, openapi.';t.push({name:n,message:`unsupported type "${u.type}".${x}`});continue}r.push({name:n,config:a})}return{servers:r,issues:t}},Ut=({onSuccess:s,onCancel:r})=>{const{t}=ae(),[n,b]=c.useState(""),[u,a]=c.useState(null),[j,x]=c.useState(!1),[E,d]=c.useState(null),g=`{
|
|
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.`,o=k=>{try{const D=JSON.parse(k.trim());return!D.mcpServers||typeof D.mcpServers!="object"?(a(t("jsonImport.invalidFormat")),null):D}catch{return a(t("jsonImport.parseError")),null}},p=()=>{a(null);const k=o(n);if(!k)return;const{servers:D,issues:T}=Vt(k);if(T.length>0){const U=T.map(V=>`${V.name}: ${V.message}`).join(`
|
|
35
|
-
`);if(a(t("jsonImport.validationErrors")+`
|
|
36
|
-
`+U),D.length===0)return}d(D)},_=async()=>{if(E){x(!0),a(null);try{const k=await ce("/servers/batch",{servers:E});if(k.success&&k.data){const{successCount:D,failureCount:T,results:U}=k.data;if(T>0){const V=U.filter(B=>!B.success).map(B=>`${B.name}: ${B.message||t("jsonImport.addFailed")}`);a(t("jsonImport.partialSuccess",{count:D,total:E.length})+`
|
|
37
|
-
`+V.join(`
|
|
38
|
-
`))}D>0&&s()}else a(k.message||t("jsonImport.importFailed"))}catch(k){console.error("Import error:",k),a(t("jsonImport.importFailed"))}finally{x(!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:r,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),u&&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:u})}),E?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:E.map((k,D)=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 p-4 rounded-lg border border-gray-200 dark:border-gray-700",children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-gray-900",children:k.name}),e.jsxs("div",{className:"mt-2 space-y-1 text-sm text-gray-600",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.type"),":"]})," ",k.config.type||"stdio"]}),k.config.command&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.command"),":"]})," ",k.config.command]}),k.config.args&&k.config.args.length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.arguments"),":"]})," ",k.config.args.join(" ")]}),k.config.url&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.url"),":"]})," ",k.config.url]}),k.config.env&&Object.keys(k.config.env).length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.envVars"),":"]})," ",Object.keys(k.config.env).join(", ")]}),k.config.headers&&Object.keys(k.config.headers).length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.headers"),":"]})," ",Object.keys(k.config.headers).join(", ")]})]})]})})},D))})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:()=>d(null),disabled:j,className:"hub-btn",children:t("common.back")}),e.jsx("button",{onClick:_,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:n,onChange:k=>b(k.target.value),className:"w-full h-96 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-sm",placeholder:g}),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:r,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:p,disabled:!n.trim(),className:"hub-btn primary",children:t("jsonImport.preview")})]})]})]})})},Bt=s=>({all:s.length,online:s.filter(r=>r.status==="connected").length,issues:s.filter(r=>r.status!=="connected"&&r.enabled!==!1).length,disabled:s.filter(r=>r.enabled===!1).length}),Jt=(s,r,t="")=>{const n=t.trim().toLowerCase();return s.filter(b=>{var a,j;return r==="online"&&b.status!=="connected"||r==="issues"&&(b.status==="connected"||b.enabled===!1)||r==="disabled"&&b.enabled!==!1?!1:n?(b.name+" "+(((a=b.config)==null?void 0:a.description)||"")+" "+(((j=b.tools)==null?void 0:j.map(x=>x.name).join(" "))||"")).toLowerCase().includes(n):!0})},Lt=(s,r,t,n,b)=>{const u=Jt(s,r,t),a=u.length,j=Math.max(1,Math.ceil(a/b)),x=Math.min(Math.max(1,n),j),E=(x-1)*b;return{servers:u.slice(E,E+b),pagination:{page:x,limit:b,total:a,totalPages:j,hasNextPage:x<j,hasPrevPage:x>1}}},ar=()=>{const{t:s}=ae(),r=Ms(),{servers:t,allServers:n,error:b,setError:u,isLoading:a,currentPage:j,serversPerPage:x,setCurrentPage:E,setServersPerPage:d,handleServerAdd:g,handleServerEdit:o,handleServerRemove:p,handleServerToggle:_,handleServerVisibilityChange:k,handleServerReload:D,handleServerReinstall:T,handleServerOAuthDisconnect:U,triggerRefresh:V}=mt({refreshOnMount:!0}),{serverCosts:B,refetch:R}=pt();c.useEffect(()=>{R()},[t,R]);const[L,P]=c.useState(null),[O,q]=c.useState(null),[ee,y]=c.useState(null),[h,w]=c.useState(!1),[l,f]=c.useState(!1),[m,N]=c.useState(!1),[$,I]=c.useState("all"),[W,Y]=c.useState(""),G=c.useMemo(()=>Bt(n),[n]),{servers:Q,pagination:v}=c.useMemo(()=>Lt(n,$,W,j,x),[n,$,W,j,x]);c.useEffect(()=>{v.page!==j&&E(v.page)},[v.page,j,E]);const M=c.useRef(0),te=async J=>{const F=++M.current,H=await o(J);F===M.current&&H&&P(H)},re=c.useRef(0),z=async J=>{if(ee===J.name)return;const F=++re.current;y(J.name);try{const H=await o(J);if(is(F,re.current)==="stale")return;H&&q(H)}finally{is(F,re.current)==="commit"&&y(null)}},K=async()=>{w(!0);try{V(),await new Promise(J=>setTimeout(J,400))}finally{w(!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:G.all})," ",s("nav.servers").toLowerCase()," ·"," ",e.jsx("span",{className:"hub-num",children:G.online})," ",s("status.online")," ·"," ",e.jsx("span",{className:"hub-num",children:G.issues})," ",s("common.inactive")||"issues"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{className:"hub-btn",onClick:()=>r("/market"),children:[e.jsx(st,{size:13})," ",s("nav.market")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>N(!0),children:[e.jsx(tt,{size:13})," ",s("jsonImport.button")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>f(!0),children:[e.jsx(rt,{size:13})," ",s("mcpb.upload")]}),e.jsxs("button",{className:"hub-btn",onClick:K,disabled:h,"aria-label":s("common.refresh"),children:[e.jsx(me,{size:13,className:h?"animate-spin":""}),s("common.refresh")]}),e.jsx(Rt,{onAdd:g,duplicateSource:O,onDuplicateCancel:()=>q(null)})]})]}),b&&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(Ce,{size:14,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate text-[13px]",children:b})]}),e.jsx("button",{className:"hub-icon-btn sm",onClick:()=>u(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",G.all],["online",s("status.online"),G.online],["issues",s("common.inactive")||"Issues",G.issues],["disabled",s("pages.dashboard.disabledServers")||"Disabled",G.disabled]].map(([J,F,H])=>e.jsxs("button",{onClick:()=>I(J),className:"inline-flex items-center gap-1.5 px-3 text-[12px]",style:{height:24,borderRadius:5,background:$===J?"var(--hub-bg-2)":"transparent",color:$===J?"var(--hub-ink)":"var(--hub-ink-3)",border:"1px solid "+($===J?"var(--hub-line)":"transparent")},children:[F,e.jsx("span",{className:"hub-mono",style:{fontSize:11,color:"var(--hub-ink-3)"},children:H})]},J))}),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(nt,{size:13,style:{color:"var(--hub-ink-3)"}}),e.jsx("input",{value:W,onChange:J=>Y(J.target.value),className:"flex-1 bg-transparent outline-none text-[13px]",style:{color:"var(--hub-ink)"},placeholder:s("market.searchPlaceholder")||"Search…"}),W&&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:[v.total,"/",n.length]})]}),a&&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(me,{size:20,className:"animate-spin",style:{color:"var(--hub-ink-3)"}}),e.jsx("p",{style:{color:"var(--hub-ink-3)"},children:s("app.loading")})]})}):Q.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:Q.map(J=>e.jsx(Tt,{server:J,cost:B.find(F=>F.name===J.name),onRemove:p,onEdit:te,onDuplicate:z,isDuplicating:ee===J.name,onToggle:_,onVisibilityChange:k,onRefresh:V,onReload:D,onReinstall:T,onOAuthDisconnect:U},J.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:(v.page-1)*v.limit+1,end:Math.min(v.page*v.limit,v.total),total:v.total})}),e.jsx("div",{className:"flex-[4] flex justify-center",children:v.totalPages>1&&e.jsx(ut,{currentPage:v.page,totalPages:v.totalPages,onPageChange:E,disabled:a})}),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:x,onChange:J=>d(Number(J.target.value)),disabled:a,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"})]})]})]})]}),L&&e.jsx(Ot,{server:L,onEdit:()=>{P(null),V()},onCancel:()=>P(null)}),l&&e.jsx(_t,{onSuccess:()=>{f(!1),V()},onCancel:()=>f(!1)}),m&&e.jsx(Ut,{onSuccess:()=>{N(!1),V()},onCancel:()=>N(!1)})]})};export{ar as default};
|
|
39
|
-
//# sourceMappingURL=ServersPage-p9LgWUzS.js.map
|