@samanhappy/mcphub 1.1.9 → 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/services/mcpService.js +4 -1
  2. package/dist/services/mcpService.js.map +1 -1
  3. package/frontend/dist/assets/{ActivityPage-CFRX20v4.js → ActivityPage-DDa3yAck.js} +2 -2
  4. package/frontend/dist/assets/{ActivityPage-CFRX20v4.js.map → ActivityPage-DDa3yAck.js.map} +1 -1
  5. package/frontend/dist/assets/{CopyClientConfigDialog-CDEiSInj.js → CopyClientConfigDialog-DPQOggV-.js} +2 -2
  6. package/frontend/dist/assets/{CopyClientConfigDialog-CDEiSInj.js.map → CopyClientConfigDialog-DPQOggV-.js.map} +1 -1
  7. package/frontend/dist/assets/{CredentialsPage-BCLHY_fN.js → CredentialsPage-DmxY-iXb.js} +2 -2
  8. package/frontend/dist/assets/{CredentialsPage-BCLHY_fN.js.map → CredentialsPage-DmxY-iXb.js.map} +1 -1
  9. package/frontend/dist/assets/{Dashboard-B3Y6nAFL.js → Dashboard-DCvveQBj.js} +2 -2
  10. package/frontend/dist/assets/{Dashboard-B3Y6nAFL.js.map → Dashboard-DCvveQBj.js.map} +1 -1
  11. package/frontend/dist/assets/{EndpointCopy-BMxT99Ne.js → EndpointCopy-DRWz8guH.js} +2 -2
  12. package/frontend/dist/assets/{EndpointCopy-BMxT99Ne.js.map → EndpointCopy-DRWz8guH.js.map} +1 -1
  13. package/frontend/dist/assets/{GroupsPage-5iCk1LKT.js → GroupsPage-DtoTWqWU.js} +2 -2
  14. package/frontend/dist/assets/{GroupsPage-5iCk1LKT.js.map → GroupsPage-DtoTWqWU.js.map} +1 -1
  15. package/frontend/dist/assets/{LoginPage-BjYzY6RH.js → LoginPage-BVBf8nr6.js} +2 -2
  16. package/frontend/dist/assets/{LoginPage-BjYzY6RH.js.map → LoginPage-BVBf8nr6.js.map} +1 -1
  17. package/frontend/dist/assets/{LogsPage-CGcFNKJn.js → LogsPage-DbsmNJcA.js} +2 -2
  18. package/frontend/dist/assets/{LogsPage-CGcFNKJn.js.map → LogsPage-DbsmNJcA.js.map} +1 -1
  19. package/frontend/dist/assets/{MarketPage-B7JPqFw3.js → MarketPage-BOggDLJb.js} +2 -2
  20. package/frontend/dist/assets/{MarketPage-B7JPqFw3.js.map → MarketPage-BOggDLJb.js.map} +1 -1
  21. package/frontend/dist/assets/{OAuthConsentPage-BYi_kgNj.js → OAuthConsentPage-VON__2op.js} +2 -2
  22. package/frontend/dist/assets/{OAuthConsentPage-BYi_kgNj.js.map → OAuthConsentPage-VON__2op.js.map} +1 -1
  23. package/frontend/dist/assets/{PromptsPage-x6X5trLX.js → PromptsPage-BNkvIDZU.js} +2 -2
  24. package/frontend/dist/assets/{PromptsPage-x6X5trLX.js.map → PromptsPage-BNkvIDZU.js.map} +1 -1
  25. package/frontend/dist/assets/{ResourcesPage-BJZCPBs8.js → ResourcesPage-4WBvamN_.js} +2 -2
  26. package/frontend/dist/assets/{ResourcesPage-BJZCPBs8.js.map → ResourcesPage-4WBvamN_.js.map} +1 -1
  27. package/frontend/dist/assets/{ServersPage-CsyGLden.js → ServersPage-C7000Szj.js} +7 -7
  28. package/frontend/dist/assets/ServersPage-C7000Szj.js.map +1 -0
  29. package/frontend/dist/assets/{SettingsPage-C53DI0Sz.js → SettingsPage-YX6dJjrM.js} +2 -2
  30. package/frontend/dist/assets/{SettingsPage-C53DI0Sz.js.map → SettingsPage-YX6dJjrM.js.map} +1 -1
  31. package/frontend/dist/assets/{StatusDot-BDJd3Iix.js → StatusDot-mgJveZ2h.js} +2 -2
  32. package/frontend/dist/assets/{StatusDot-BDJd3Iix.js.map → StatusDot-mgJveZ2h.js.map} +1 -1
  33. package/frontend/dist/assets/{ToggleGroup-BbmRhILg.js → ToggleGroup-DXyuwPy7.js} +2 -2
  34. package/frontend/dist/assets/{ToggleGroup-BbmRhILg.js.map → ToggleGroup-DXyuwPy7.js.map} +1 -1
  35. package/frontend/dist/assets/{UsersPage-NUG6vF8C.js → UsersPage-BiUn8c0z.js} +2 -2
  36. package/frontend/dist/assets/{UsersPage-NUG6vF8C.js.map → UsersPage-BiUn8c0z.js.map} +1 -1
  37. package/frontend/dist/assets/{clipboard-7BggsilD.js → clipboard-7MOQ-4Cg.js} +2 -2
  38. package/frontend/dist/assets/{clipboard-7BggsilD.js.map → clipboard-7MOQ-4Cg.js.map} +1 -1
  39. package/frontend/dist/assets/index-B3hkLjCv.css +1 -0
  40. package/frontend/dist/assets/index-BKFFbupY.js +3 -0
  41. package/frontend/dist/assets/index-BKFFbupY.js.map +1 -0
  42. package/frontend/dist/assets/{resourceService-B674Fopr.js → resourceService-BOn21QbP.js} +2 -2
  43. package/frontend/dist/assets/{resourceService-B674Fopr.js.map → resourceService-BOn21QbP.js.map} +1 -1
  44. package/frontend/dist/assets/{useCostData-8Z1HjAL5.js → useCostData-3iIVsNH6.js} +2 -2
  45. package/frontend/dist/assets/{useCostData-8Z1HjAL5.js.map → useCostData-3iIVsNH6.js.map} +1 -1
  46. package/frontend/dist/assets/{variableDetection-C0nP3Jj2.js → variableDetection-Cpa0rIrf.js} +2 -2
  47. package/frontend/dist/assets/{variableDetection-C0nP3Jj2.js.map → variableDetection-Cpa0rIrf.js.map} +1 -1
  48. package/frontend/dist/index.html +2 -2
  49. package/package.json +1 -1
  50. package/frontend/dist/assets/ServersPage-CsyGLden.js.map +0 -1
  51. package/frontend/dist/assets/index-B_IITM9e.js +0 -3
  52. package/frontend/dist/assets/index-B_IITM9e.js.map +0 -1
  53. package/frontend/dist/assets/index-CnqLKewL.css +0 -1
@@ -1,4 +1,4 @@
1
- import{r as f,j as e,R as M}from"./framework-vendor-CQFm9vKd.js";import{n as Y,f as ge,d as Z,u as fe,j as ve,k as ee}from"./index-B_IITM9e.js";import{u as se,a as te}from"./useCostData-8Z1HjAL5.js";import{u as O}from"./i18n-vendor-DVmjrzgW.js";import{u as ue,c as je}from"./clipboard-7BggsilD.js";import{f as W,p as ye}from"./contextCost-CilWqGWT.js";import{g as Ne,A as ke,C as Se}from"./CopyClientConfigDialog-CDEiSInj.js";import{W as we,g as Ce,F as Ae,H as Ee,C as Te,r as J,J as ie,z as De,w as Ie,T as ze,n as Fe,D as oe,N as Pe,P as ce,l as Re,X as Le}from"./icons-vendor-CkcU1LMA.js";import{D as Ue}from"./DeleteDialog-BaCsEkJA.js";const Oe=["read","create","update","delete","other"],$e=a=>{var s,l,h;if(((s=a.annotations)==null?void 0:s.readOnlyHint)===!0)return"read";const m=a.value.toLowerCase();return/^(delete|remove)[_-]/.test(m)?"delete":((l=a.annotations)==null?void 0:l.destructiveHint)===!0?"other":/^(create|add)[_-]/.test(m)?"create":/^(update|set)[_-]/.test(m)?"update":((h=a.annotations)==null?void 0:h.readOnlyHint)!==!1&&/^(get|list|read|search)[_-]/.test(m)?"read":"other"},Ge=(a,m,s)=>{const l=m.trim().toLowerCase();return a.filter(h=>{var i,p;return(h.value.toLowerCase().includes(l)||((i=h.description)==null?void 0:i.toLowerCase().includes(l)))&&(s==="all"||((p=h.annotations)==null?void 0:p[s])===!0)})},We=(a,m,s,l)=>{if(s.length===0||a==="all"&&l==="select")return a;const h=new Set(a==="all"?m:a);for(const i of s)l==="deselect"||l==="invert"&&h.has(i)?h.delete(i):h.add(i);return[...h]},Me=({items:a,selection:m,tools:s,label:l,onChange:h,children:i})=>{const{t:p}=O(),[E,T]=f.useState(""),[j,b]=f.useState("all"),[N,w]=f.useState(!1),y=Ge(a,E,j),A=new Set(m==="all"?a.map(r=>r.value):m),c=(r,o)=>h(We(m,a.map(u=>u.value),r.map(u=>u.value),o)),k=s&&N?Oe.map(r=>({risk:r,items:y.filter(o=>$e(o)===r)})):[{risk:null,items:y}],v="text-xs text-blue-600 hover:text-blue-800 disabled:opacity-40 disabled:cursor-not-allowed";return e.jsxs("section",{"aria-label":l,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("input",{type:"search","aria-label":p("groups.bulkSearchLabel",{capability:l}),placeholder:p("groups.bulkSearch"),value:E,onChange:r=>T(r.target.value),className:"min-w-0 flex-1 basis-48 rounded border border-gray-300 bg-white dark:bg-gray-800 px-2 py-1 text-sm"}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{"aria-label":p("groups.annotationFilter"),value:j,onChange:r=>b(r.target.value),className:"max-w-full rounded border border-gray-300 bg-white dark:bg-gray-800 px-2 py-1 text-sm",children:[e.jsx("option",{value:"all",children:p("groups.allAnnotations")}),["readOnlyHint","destructiveHint","idempotentHint"].map(r=>e.jsx("option",{value:r,children:p(`groups.${r}`)},r))]}),e.jsx("button",{type:"button","aria-pressed":N,onClick:()=>w(!N),className:v,children:p(N?"groups.flatList":"groups.riskGroups")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mb-2",children:[e.jsx("span",{className:"text-xs text-gray-500",role:"status",children:p("groups.visibleCount",{count:y.length,total:a.length})}),["select","deselect","invert"].map(r=>e.jsx("button",{type:"button",disabled:!y.length,onClick:()=>c(y,r),className:v,children:p(`groups.${r}Visible`)},r))]}),s&&N&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:p("groups.riskHint")}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 max-h-96 overflow-y-auto",children:[y.length===0&&e.jsx("p",{className:"text-sm text-gray-500",children:p("groups.noMatchingItems")}),k.filter(r=>r.items.length>0).map(r=>{const o=r.items.filter(u=>A.has(u.value)).length;return e.jsxs(M.Fragment,{children:[r.risk&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-gray-200 py-1",children:[e.jsxs("span",{className:"text-xs font-medium",children:[p(`groups.risk_${r.risk}`)," (",o,"/",r.items.length,")"]}),e.jsx("button",{type:"button",className:v,onClick:()=>c(r.items,o===r.items.length?"deselect":"select"),children:p(o===r.items.length?"groups.selectNone":"groups.selectAll")})]}),r.items.map(u=>e.jsx(M.Fragment,{children:i(u)},u.value))]},r.risk??"flat")})]})]})},He={tools:[],prompts:[],resources:[]},de={tools:"all",prompts:"all",resources:"all"},me=({servers:a,value:m,onChange:s,className:l,serverCosts:h=[]})=>{const{t:i}=O(),{nameSeparator:p,smartRoutingConfig:E}=ue(),[T,j]=f.useState(new Set),b=M.useMemo(()=>m.map(t=>typeof t=="string"?{name:t,...de}:{...t,tools:t.tools||"all",prompts:t.prompts||"all",resources:t.resources||"all"}),[m]),N=M.useMemo(()=>a.filter(t=>t.enabled!==!1),[a]);M.useEffect(()=>{const t=new Set(b.map(n=>n.name)),d=new Set(N.map(n=>n.name));j(n=>{const S=new Set;return n.forEach(g=>{(t.has(g)||d.has(g))&&S.add(g)}),S})},[b,N]);const w=t=>{if(b.findIndex(n=>n.name===t)>=0){const n=b.filter(S=>S.name!==t);s(n)}else{const n=[...b,{name:t,...de}];s(n)}},y=t=>{j(d=>{const n=new Set(d);return n.has(t)?n.delete(t):n.add(t),n})},A=t=>["tools","prompts","resources"].some(d=>{const n=t[d];return n==="all"||Array.isArray(n)&&n.length>0}),c=(t,d,n,S=!1)=>{const g=b.find(z=>z.name===t),I={...g?{...g}:{name:t,...He},[d]:n};if(d==="tools"&&Array.isArray(n)&&I.pinnedTools&&(I.pinnedTools=I.pinnedTools.filter(z=>n.includes(z)),I.pinnedTools.length===0&&delete I.pinnedTools),!A(I)){const z=b.filter(x=>x.name!==t);s(z),S||j(x=>{const U=new Set(x);return U.delete(t),U});return}if(g){s(b.map(z=>z.name===t?I:z));return}s([...b,I])},k=(t,d)=>{const n=b.find(g=>g.name===t);if(!n)return;const S={...n};d?S.alias=d:delete S.alias,s(b.map(g=>g.name===t?S:g))},v=(t,d)=>{const n=b.find(P=>P.name===t);if(!n)return;const S=n.pinnedTools??[],g={...n,pinnedTools:S.includes(d)?S.filter(P=>P!==d):[...S,d]};g.pinnedTools.length===0&&delete g.pinnedTools,s(b.map(P=>P.name===t?g:P))},r=(t,d)=>{const n=`${t}${p}`;return d.startsWith(n)?d.slice(n.length):d},o=(t,d)=>d==="tools"?(t.tools||[]).filter(n=>n.enabled!==!1).map(n=>({key:n.name,value:r(t.name,n.name),description:n.description,annotations:n.annotations,defaultDescription:n.defaultDescription,hasDescriptionOverride:n.hasDescriptionOverride})):d==="prompts"?(t.prompts||[]).filter(n=>n.enabled!==!1).map(n=>({key:n.name,value:r(t.name,n.name),description:n.description})):(t.resources||[]).filter(n=>n.enabled!==!1).map(n=>({key:n.uri,value:n.uri,description:n.description})),u=M.useMemo(()=>{const t=new Map;return h.forEach(d=>{const n=new Map;d.items.forEach(S=>n.set(S.name,S.cost)),t.set(d.name,n)}),t},[h]),C=t=>u.get(t)??new Map,F=(t,d)=>{const n=C(t.name);return o(t,d).filter(S=>H(t.name,d,S.value)).reduce((S,g)=>S+(n.get(g.key)??0),0)},$=t=>["tools","prompts","resources"].reduce((d,n)=>d+F(t,n),0),q=(t,d,n)=>{const S=N.find(z=>z.name===t);if(!S)return;const g=o(S,d).map(z=>z.value),P=b.find(z=>z.name===t);if(!P){c(t,d,[n]);return}const I=P[d];if(I==="all"){const z=g.filter(x=>x!==n);c(t,d,z);return}if(Array.isArray(I)){if(I.includes(n)){c(t,d,I.filter(x=>x!==n));return}const z=[...I,n];c(t,d,z.length===g.length?"all":z);return}c(t,d,[n])},Q=t=>{const d=b.find(n=>n.name===t);return!!(d&&A(d))},G=t=>{const d=b.find(n=>n.name===t);return d?["tools","prompts","resources"].some(n=>{const S=d[n];return Array.isArray(S)&&S.length>0}):!1},H=(t,d,n)=>{const S=b.find(P=>P.name===t);if(!S)return!1;const g=S[d];return g==="all"?!0:Array.isArray(g)?g.includes(n):!1},K=(t,d)=>{const n=b.find(P=>P.name===t.name);if(!n)return 0;const S=o(t,d),g=n[d];if(g==="all")return S.length;if(Array.isArray(g)){const P=new Set(S.map(I=>I.value));return g.filter(I=>P.has(I)).length}return 0},_=[{key:"tools",titleKey:"groups.toolSelection",countKey:"groups.toolsSelected",allKey:"groups.allTools"},{key:"prompts",titleKey:"groups.promptSelection",countKey:"groups.promptsSelected",allKey:"groups.allPrompts"},{key:"resources",titleKey:"groups.resourceSelection",countKey:"groups.resourcesSelected",allKey:"groups.allResources"}],D=t=>_.map(({key:d})=>({key:d,count:K(t,d)})).filter(d=>d.count>0);return e.jsxs("div",{className:Y("space-y-4",l),children:[e.jsx("div",{className:"space-y-3",children:N.map(t=>{const d=Q(t.name),n=G(t.name),S=T.has(t.name),g=b.find(x=>x.name===t.name),P=D(t),I=_.filter(({key:x})=>o(t,x).length>0),z=C(t.name);return e.jsxs("div",{className:"border border-[var(--hub-line)] rounded-lg bg-[var(--hub-surface)] hover:border-[var(--hub-ink-3)] hover:bg-[var(--hub-surface-hover)] transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 cursor-pointer rounded-lg transition-colors",onClick:()=>y(t.name),children:[e.jsxs("div",{className:"flex items-center space-x-3",onClick:x=>{x.stopPropagation(),w(t.name)},children:[e.jsx("input",{type:"checkbox",checked:d||n,onChange:()=>w(t.name),className:"w-4 h-4 text-blue-600 accent-[var(--hub-accent)] rounded focus:ring-blue-500"}),e.jsx("span",{className:"font-medium text-[var(--hub-ink)] cursor-pointer select-none",children:t.name})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[$(t)>0&&e.jsxs("span",{className:"text-sm text-[var(--hub-ink-3)] hub-mono",title:i("cost.estimate"),children:["Σ ",W($(t))]}),P.map(({key:x,count:U})=>e.jsxs("span",{className:"text-sm text-green-600 flex items-center gap-1",children:[x==="tools"?e.jsx(we,{size:14}):x==="prompts"?e.jsx(Ce,{size:14}):e.jsx(Ae,{size:14})," ",U]},x)),I.length>0&&e.jsx("button",{type:"button",className:"p-1 text-[var(--hub-ink-3)] hover:text-[var(--hub-ink-2)] transition-colors",children:e.jsx("svg",{className:Y("w-5 h-5 transition-transform",S&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})]}),S&&I.length>0&&e.jsx("div",{className:"border-t border-[var(--hub-line)] bg-[var(--hub-bg-2)] p-3",children:e.jsxs("div",{className:"space-y-4",children:[g&&e.jsxs("div",{className:"space-y-1",onClick:x=>x.stopPropagation(),children:[e.jsx("label",{className:"block text-xs font-medium text-[var(--hub-ink-2)]",children:i("groups.alias")}),e.jsx("input",{type:"text",value:g.alias||"",placeholder:t.name,onChange:x=>k(t.name,x.target.value),className:"hub-input"})]}),I.map(({key:x,titleKey:U,countKey:he,allKey:be})=>{const B=o(t,x),re=K(t,x),X=(g==null?void 0:g[x])==="all"||re===B.length;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--hub-ink-2)]",children:i(U)}),e.jsxs("div",{className:"flex items-center gap-3",children:[g&&e.jsx("span",{className:"text-xs text-green-600",children:X?`(${i(be)} ${B.length}/${B.length})`:`(${i(he)} ${re}/${B.length})`}),g&&F(t,x)>0&&e.jsxs("span",{className:"text-xs text-[var(--hub-ink-3)] hub-mono",title:i("cost.estimate"),children:["Σ ",W(F(t,x))]}),e.jsx("button",{type:"button",onClick:()=>{c(t.name,x,X?[]:"all",!0)},className:"text-sm text-blue-600 hover:text-blue-800 transition-colors",children:i(X?"groups.selectNone":"groups.selectAll")})]})]}),e.jsx(Me,{items:B,selection:(g==null?void 0:g[x])??[],tools:x==="tools",label:i(U),onChange:R=>c(t.name,x,R,!0),children:R=>{var le;const ae=H(t.name,x,R.value),V=!!((le=g==null?void 0:g.pinnedTools)!=null&&le.includes(R.value)),L=x==="tools"?Ne({description:R.description,defaultDescription:R.defaultDescription,hasDescriptionOverride:R.hasDescriptionOverride},i("tool.noDescription")):null,ne=L!=null&&L.hasDescriptionOverride?i("tool.defaultDescriptionTooltip",{description:L.defaultDescription}):R.description;return e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsxs("label",{className:"flex min-w-0 flex-1 items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:ae,onChange:()=>q(t.name,x,R.value),className:"w-3 h-3 text-blue-600 accent-[var(--hub-accent)] rounded focus:ring-blue-500"}),e.jsx("span",{className:"text-[var(--hub-ink-2)] break-all whitespace-nowrap flex-shrink-0",children:R.value}),(R.description||(L==null?void 0:L.hasDescriptionOverride))&&e.jsxs("span",{className:"min-w-0 flex items-center gap-1 text-[var(--hub-ink-3)] text-xs truncate",children:[e.jsx("span",{className:"truncate",title:ne||void 0,children:L?L.currentDescription:R.description}),(L==null?void 0:L.hasDescriptionOverride)&&e.jsx("span",{className:"inline-flex flex-shrink-0 items-center rounded-full border border-amber-200 bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:border-amber-700/60 dark:bg-amber-900/20 dark:text-amber-300",title:ne||void 0,children:i("tool.descriptionModifiedBadge")})]}),z.get(R.key)!=null&&e.jsxs("span",{className:"text-xs text-[var(--hub-ink-3)] hub-mono whitespace-nowrap ml-auto flex-shrink-0",title:i("cost.estimate"),children:["Σ ",W(z.get(R.key))]})]}),x==="tools"&&ae&&(E.enabled||V)&&e.jsx("button",{type:"button",onClick:()=>v(t.name,R.value),title:i(V?"groups.unpinTool":"groups.pinTool"),"aria-label":i("groups.pinToolLabel"),"aria-pressed":V,className:Y("flex-shrink-0 transition-colors",V?"text-blue-600":"text-[var(--hub-ink-3)] hover:text-[var(--hub-ink-2)]"),children:e.jsx(Ee,{size:12,fill:V?"currentColor":"none"})})]},R.key)}})]},x)})]})})]},t.name)})}),N.length===0&&e.jsx("p",{className:"text-[var(--hub-ink-3)] text-sm",children:i("groups.noServerOptions")})]})};function pe({groupId:a,value:m,onChange:s}){const{t:l}=O(),[h,i]=f.useState([]),[p,E]=f.useState(""),[T,j]=f.useState(!1),[b,N]=f.useState(!1),[w,y]=f.useState(!1);f.useEffect(()=>{if(!a||m.visibility!=="group")return;let u=!1;return j(!0),N(!1),ge(`/groups/${encodeURIComponent(a)}/share-candidates`).then(C=>{u||(C.success&&Array.isArray(C.data)?i(C.data):N(!0))}).catch(()=>{u||N(!0)}).finally(()=>{u||j(!1)}),()=>{u=!0}},[a,m.visibility]);const A=m.sharedWithUsers||[],c=[...new Set([...h,...A])].sort().filter(u=>u.toLowerCase().includes(p.toLowerCase())),k=new Set(A),v=c.length>0&&c.every(u=>k.has(u)),r=c.length===0||c.every(u=>!k.has(u)),o=u=>{const C=new Set(A);C.has(u)?C.delete(u):C.add(u),s({sharedWithUsers:Array.from(C)})};return e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer bg-[var(--hub-bg-2)] hover:bg-[var(--hub-surface-hover)] p-3 rounded border border-[var(--hub-line)]",onClick:()=>y(!w),children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--hub-ink)]",children:l("server.sectionAdvanced","Advanced Options")}),e.jsx("span",{className:"text-[var(--hub-ink-3)] text-sm",children:w?"▼":"▶"})]}),w&&e.jsxs("div",{className:"border border-[var(--hub-line)] rounded-b p-4 bg-[var(--hub-surface)] border-t-0",children:[e.jsx("label",{htmlFor:"group-visibility",className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",children:l("server.visibility")}),e.jsxs("select",{id:"group-visibility",className:"hub-input",value:m.visibility||"",onChange:u=>s({visibility:u.target.value}),children:[!m.visibility&&e.jsx("option",{value:"",disabled:!0,children:l("groups.legacyVisibility")}),e.jsx("option",{value:"private",children:l("server.visibilityPrivate")}),e.jsx("option",{value:"group",children:l("server.visibilityGroup")}),e.jsx("option",{value:"public",children:l("server.visibilityPublic")})]}),e.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1",children:l("groups.visibilityDescription")}),!m.visibility&&e.jsx("p",{className:"text-sm text-amber-600",children:l("groups.legacyVisibilityHint")}),m.visibility==="group"&&e.jsxs("div",{className:"mt-4 rounded border border-[var(--hub-line)] p-3",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--hub-ink-2)]",children:l("server.shareWithUsers")}),e.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1 mb-3",children:l("server.shareWithUsersDescription")}),a?e.jsxs(e.Fragment,{children:[T&&e.jsx("p",{className:"text-sm text-[var(--hub-ink-3)]",children:l("server.shareCandidatesLoading")}),b&&e.jsx("p",{role:"alert",className:"text-sm text-red-600 dark:text-red-400",children:l("server.shareCandidatesError")}),!T&&!b&&c.length===0&&e.jsx("p",{className:"text-sm text-[var(--hub-ink-3)]",children:l(p?"server.noMatchingShareUsers":"server.noShareCandidates")}),c.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-3 space-y-2",children:[e.jsx("label",{htmlFor:"group-share-search",className:"block text-xs font-medium text-[var(--hub-ink-2)]",children:l("server.shareUserSearchLabel")}),e.jsx("input",{id:"group-share-search",type:"search",value:p,onChange:u=>E(u.target.value),placeholder:l("server.shareUserSearchPlaceholder"),className:"hub-input text-sm"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>s({sharedWithUsers:[...new Set([...A,...c])]}),disabled:v,className:"hub-btn text-sm",children:l("server.selectAllShareUsers")}),e.jsx("button",{type:"button",onClick:()=>s({sharedWithUsers:A.filter(u=>!c.includes(u))}),disabled:r,className:"hub-btn text-sm",children:l("server.deselectAllShareUsers")})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:c.map(u=>e.jsxs("label",{className:"flex items-center gap-2 rounded border border-[var(--hub-line)] px-3 py-2 text-sm text-[var(--hub-ink-2)]",children:[e.jsx("input",{type:"checkbox",checked:k.has(u),onChange:()=>o(u)}),e.jsx("span",{children:u})]},u))})]})]}):e.jsx("p",{className:"text-sm text-[var(--hub-ink-3)]",children:l("groups.shareAfterCreate")})]})]})]})}const _e=({onAdd:a,onCancel:m})=>{const{t:s}=O(),{createGroup:l}=Z(),{allServers:h}=se(),{serverCosts:i}=te(),[p,E]=f.useState([]),[T,j]=f.useState(null),[b,N]=f.useState(!1),[w,y]=f.useState({visibility:"private",sharedWithUsers:[],name:"",description:"",instructions:"",servers:[]});f.useEffect(()=>{E(h.filter(k=>k.enabled!==!1))},[h]);const A=k=>{const{name:v,value:r}=k.target;y(o=>({...o,[v]:r}))},c=async k=>{k.preventDefault(),N(!0),j(null);try{if(!w.name.trim()){j(s("groups.nameRequired")),N(!1);return}const v=await l(w.name,w.description,w.servers,{visibility:w.visibility,sharedWithUsers:w.sharedWithUsers,instructions:w.instructions});if(!v||!v.success){j((v==null?void 0:v.message)||s("groups.createError")),N(!1);return}a()}catch(v){j(v instanceof Error?v.message:String(v)),N(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"hub-card shadow-lg max-w-3xl w-full max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"p-6 flex-shrink-0",children:[e.jsx("h2",{className:"text-xl font-semibold text-[var(--hub-ink)] mb-4",children:s("groups.addNew")}),T&&e.jsx("div",{className:"mb-4 p-3 bg-red-100 text-red-700 rounded-md border border-[var(--hub-line)]",children:T})]}),e.jsxs("form",{onSubmit:c,className:"flex flex-col flex-1 min-h-0",children:[e.jsx("div",{className:"flex-1 overflow-y-auto px-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",htmlFor:"name",children:[s("groups.name")," *"]}),e.jsx("input",{type:"text",id:"name",name:"name",value:w.name,onChange:A,className:"w-full border border-[var(--hub-line)] bg-[var(--hub-surface)] rounded-md px-3 py-2 text-[var(--hub-ink)] placeholder:text-[var(--hub-ink-3)] focus:outline-none focus:border-[var(--hub-ink-2)]",placeholder:s("groups.namePlaceholder"),required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",htmlFor:"instructions",children:s("groups.instructions")}),e.jsx("textarea",{id:"instructions",name:"instructions",value:w.instructions,onChange:A,rows:3,className:"w-full border border-[var(--hub-line)] bg-[var(--hub-surface)] rounded-md px-3 py-2 text-[var(--hub-ink)] placeholder:text-[var(--hub-ink-3)] focus:outline-none focus:border-[var(--hub-ink-2)]",placeholder:s("groups.instructionsPlaceholder")}),e.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1",children:s("groups.instructionsHelp")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",children:s("groups.configureCapabilities")}),e.jsx(me,{servers:p,value:w.servers,onChange:k=>y(v=>({...v,servers:k})),className:"border border-[var(--hub-line)] rounded-lg p-4 bg-[var(--hub-bg-2)]",serverCosts:i})]}),e.jsx(pe,{value:w,onChange:k=>y(v=>({...v,...k}))})]})}),e.jsxs("div",{className:"flex justify-end space-x-2 p-5 pt-3 border-t border-[var(--hub-line-2)] flex-shrink-0",children:[e.jsx("button",{type:"button",onClick:m,className:"hub-btn",disabled:b,children:s("common.cancel")}),e.jsx("button",{type:"submit",className:"hub-btn primary",disabled:b,children:s(b?"common.submitting":"common.create")})]})]})]})})},Be=({group:a,onEdit:m,onCancel:s})=>{const{t:l}=O(),{updateGroup:h}=Z(),{allServers:i}=se(),{serverCosts:p}=te(),[E,T]=f.useState([]),[j,b]=f.useState(null),[N,w]=f.useState(!1),[y,A]=f.useState({visibility:a.visibility,sharedWithUsers:a.sharedWithUsers||[],name:a.name,description:a.description||"",instructions:a.instructions||"",servers:a.servers||[]});f.useEffect(()=>{T(i.filter(v=>v.enabled!==!1))},[i]);const c=v=>{const{name:r,value:o}=v.target;A(u=>({...u,[r]:o}))},k=async v=>{v.preventDefault(),w(!0),b(null);try{if(!y.name.trim()){b(l("groups.nameRequired")),w(!1);return}const r=await h(a.id,{visibility:y.visibility,sharedWithUsers:y.sharedWithUsers,name:y.name,description:y.description,instructions:y.instructions,servers:y.servers});if(!r||!r.success){b((r==null?void 0:r.message)||l("groups.updateError")),w(!1);return}m()}catch(r){b(r instanceof Error?r.message:String(r)),w(!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:"hub-card shadow-lg max-w-3xl w-full max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"p-6 flex-shrink-0",children:[e.jsx("h2",{className:"text-xl font-semibold text-[var(--hub-ink)] mb-4",children:l("groups.edit")}),j&&e.jsx("div",{className:"mb-4 p-3 bg-red-100 text-red-700 rounded-md border border-[var(--hub-line)]",children:j})]}),e.jsxs("form",{onSubmit:k,className:"flex flex-col flex-1 min-h-0",children:[e.jsx("div",{className:"flex-1 overflow-y-auto px-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",htmlFor:"name",children:[l("groups.name")," *"]}),e.jsx("input",{type:"text",id:"name",name:"name",value:y.name,onChange:c,className:"w-full border border-[var(--hub-line)] bg-[var(--hub-surface)] rounded-md px-3 py-2 text-[var(--hub-ink)] placeholder:text-[var(--hub-ink-3)] focus:outline-none focus:border-[var(--hub-ink-2)]",placeholder:l("groups.namePlaceholder"),required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",htmlFor:"instructions",children:l("groups.instructions")}),e.jsx("textarea",{id:"instructions",name:"instructions",value:y.instructions,onChange:c,rows:3,className:"w-full border border-[var(--hub-line)] bg-[var(--hub-surface)] rounded-md px-3 py-2 text-[var(--hub-ink)] placeholder:text-[var(--hub-ink-3)] focus:outline-none focus:border-[var(--hub-ink-2)]",placeholder:l("groups.instructionsPlaceholder")}),e.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1",children:l("groups.instructionsHelp")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",children:l("groups.configureCapabilities")}),e.jsx(me,{servers:E,value:y.servers,onChange:v=>A(r=>({...r,servers:v})),className:"border border-[var(--hub-line)] rounded-lg p-4 bg-[var(--hub-bg-2)]",serverCosts:p})]}),e.jsx(pe,{groupId:a.id,value:y,onChange:v=>A(r=>({...r,...v}))})]})}),e.jsxs("div",{className:"flex justify-end space-x-2 p-5 pt-3 border-t border-[var(--hub-line-2)] flex-shrink-0",children:[e.jsx("button",{type:"button",onClick:s,className:"hub-btn",disabled:N,children:l("common.cancel")}),e.jsx("button",{type:"submit",className:"hub-btn primary",disabled:N,children:l(N?"common.submitting":"common.save")})]})]})]})})},Ve=a=>a.map(m=>typeof m=="string"?m:m.name),xe=(a,m)=>{const s=a.servers.find(l=>typeof l=="string"?l===m:l.name===m);return s?typeof s=="string"?{name:s,tools:"all",prompts:"all",resources:"all"}:s:{name:m,tools:"all",prompts:"all",resources:"all"}},qe=(a,m)=>{var l;return((l=xe(a,m).alias)==null?void 0:l.trim())||m},Ke=({group:a,servers:m,onEdit:s,onDelete:l,cost:h})=>{var _;const{t:i}=O(),{auth:p}=fe(),E=!!p.user&&(p.user.isAdmin||p.user.username===a.owner),{showToast:T}=ve(),{installConfig:j,nameSeparator:b}=ue(),N=((_=j==null?void 0:j.baseUrl)==null?void 0:_.replace(/\/+$/,""))||"",[w,y]=f.useState(!1),[A,c]=f.useState(null),[k,v]=f.useState(!1),[r,o]=f.useState(!1),u=f.useRef(null);f.useEffect(()=>{const D=t=>{u.current&&!u.current.contains(t.target)&&o(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);const C=async D=>{await je(D)?(v(!0),o(!1),T(i("common.copySuccess")||"Copied","success"),setTimeout(()=>v(!1),1500)):T(i("common.copyFailed")||"Copy failed","error")},F=`${N}/mcp/${a.name}`,$=`${N}/mcp/${encodeURIComponent(a.name)}`,q=`${N}/api/${a.name}`,Q=Ve(a.servers),G=m.filter(D=>Q.includes(D.name)),H=D=>{const t=xe(a,D.name),d=`${D.name}${b}`,n=D.tools||[],S=D.prompts||[],g=D.resources||[],P=Array.isArray(t.tools)?n.filter(x=>{if(x.enabled===!1)return!1;const U=x.name.startsWith(d)?x.name.slice(d.length):x.name;return t.tools.includes(U)}).length:n.filter(x=>x.enabled!==!1).length,I=Array.isArray(t.prompts)?S.filter(x=>{if(x.enabled===!1)return!1;const U=x.name.startsWith(d)?x.name.slice(d.length):x.name;return t.prompts.includes(U)}).length:S.filter(x=>x.enabled!==!1).length,z=Array.isArray(t.resources)?g.filter(x=>x.enabled!==!1&&t.resources.includes(x.uri)).length:g.filter(x=>x.enabled!==!1).length;return{visibleTools:P,totalTools:n.length,visiblePrompts:I,totalPrompts:S.length,visibleResources:z,totalResources:g.length}},K=G.reduce((D,t)=>D+H(t).visibleTools,0);return e.jsxs("div",{className:"hub-card flex h-full flex-col overflow-visible",children:[e.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",style:{borderBottom:"1px solid var(--hub-line-2)"},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{style:{fontSize:15,fontWeight:600,letterSpacing:"-0.015em"},children:a.name}),e.jsx("span",{className:"hub-mono",style:{fontSize:11,color:"var(--hub-ink-3)",padding:"0 6px",border:"1px solid var(--hub-line)",borderRadius:4,height:18,display:"inline-flex",alignItems:"center"},title:a.id,children:a.id})]}),e.jsx("div",{className:"mt-1 text-xs text-[var(--hub-ink-3)]",children:a.visibility?i(`server.visibility${a.visibility==="group"?"Group":a.visibility==="public"?"Public":"Private"}`):i("groups.legacyVisibility")}),a.description&&e.jsx("div",{style:{fontSize:12.5,color:"var(--hub-ink-3)",marginTop:2},children:a.description})]}),e.jsxs("div",{className:"flex items-center gap-1",ref:u,children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>o(D=>!D),className:"hub-icon-btn sm",title:i("common.copy"),children:k?e.jsx(Te,{size:13,className:"text-[var(--hub-ok)]"}):e.jsx(J,{size:13})}),r&&e.jsxs("div",{className:"absolute top-full right-0 mt-1 z-20 hub-card",style:{minWidth:160,padding:4},children:[e.jsxs("button",{onClick:()=>C(a.id),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",children:[e.jsx(J,{size:12})," ",i("common.copyId")]}),e.jsxs("button",{onClick:()=>C(F),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",children:[e.jsx(ie,{size:12})," ",i("common.copyUrl")]}),e.jsxs("button",{onClick:()=>C(q),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",children:[e.jsx(ie,{size:12})," ",i("common.copyOpenApiUrl")]}),e.jsxs("button",{onClick:()=>{o(!1),c({name:a.name,url:$,headers:{Authorization:`Bearer ${ke}`}})},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",children:[e.jsx(De,{size:12})," ",i("clientConfig.menuItem")]})]})]}),E&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>s(a),className:"hub-icon-btn sm",title:i("groups.edit"),children:e.jsx(Ie,{size:13})}),e.jsx("button",{onClick:()=>y(!0),className:"hub-icon-btn sm",title:i("groups.delete"),style:{color:"var(--hub-ink-3)"},children:e.jsx(ze,{size:13})})]})]})]}),e.jsxs("div",{className:"grid flex-1 items-center gap-3 px-4 py-3",style:{gridTemplateColumns:"1fr 80px 1fr",minHeight:180},children:[e.jsx("div",{className:"flex flex-col gap-1.5",children:G.length===0?e.jsx("div",{style:{fontSize:12,color:"var(--hub-ink-3)"},children:i("groups.noServers")}):G.map(D=>{const t=H(D);return e.jsxs("div",{className:"flex items-center gap-2.5 px-2.5 py-1.5 rounded-md",style:{background:"var(--hub-bg-2)",border:"1px solid var(--hub-line-2)"},children:[e.jsx("span",{className:"inline-block flex-shrink-0",style:{width:6,height:6,borderRadius:50,background:D.status==="connected"?"var(--hub-ok)":D.status==="connecting"?"var(--hub-warn)":"var(--hub-err)"}}),e.jsx("span",{className:"hub-mono truncate flex-1",style:{fontSize:12.5},children:e.jsx("span",{title:D.name,children:qe(a,D.name)})}),e.jsxs("span",{className:"hub-mono hub-num flex-shrink-0",style:{fontSize:11,color:"var(--hub-ink-3)"},children:[t.visibleTools,"/",t.totalTools," tools"]})]},D.name)})}),e.jsxs("svg",{width:"80",height:"80",viewBox:"0 0 80 80",className:"self-center",children:[G.length===0?e.jsx("path",{d:"M0,40 C30,40 50,40 80,40",stroke:"var(--hub-line)",strokeWidth:"1",fill:"none",strokeDasharray:"3 3"}):G.map((D,t)=>{const d=12+60/Math.max(G.length,1)*(t+.5);return e.jsx("path",{d:`M0,${d} C 30,${d} 50,40 80,40`,stroke:"var(--hub-line)",strokeWidth:"1",fill:"none",strokeDasharray:"3 3"},t)}),e.jsx("circle",{cx:"80",cy:"40",r:"4",fill:"var(--hub-ink)"})]}),e.jsxs("div",{className:"px-3 py-2.5 rounded-md",style:{border:"1px solid var(--hub-line)",background:"var(--hub-bg-2)"},children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:4},children:"endpoint"}),e.jsxs("div",{className:"hub-mono break-all",style:{fontSize:12,color:"var(--hub-ink-2)",lineHeight:1.4},children:[e.jsx("span",{style:{color:"var(--hub-ink-3)"},children:"/mcp/"}),e.jsx("b",{style:{color:"var(--hub-ink)",fontWeight:600},children:a.name})]}),e.jsxs("div",{className:"hub-mono break-all",style:{fontSize:12,color:"var(--hub-ink-2)",lineHeight:1.4},children:[e.jsx("span",{style:{color:"var(--hub-ink-3)"},children:"/api/"}),e.jsx("b",{style:{color:"var(--hub-ink)",fontWeight:600},children:a.name})]}),e.jsxs("div",{className:"flex gap-1.5 mt-2",children:[e.jsxs("button",{className:"hub-btn sm flex-1 justify-center",onClick:()=>C(F),title:i("common.copyUrl"),children:[e.jsx(J,{size:11})," MCP"]}),e.jsxs("button",{className:"hub-btn sm flex-1 justify-center",onClick:()=>C(q),title:i("common.copyOpenApiUrl"),children:[e.jsx(J,{size:11})," OpenAPI"]})]})]})]}),e.jsxs("div",{className:"flex justify-between items-center px-4 py-2",style:{borderTop:"1px solid var(--hub-line-2)",background:"var(--hub-bg-2)",fontSize:12,color:"var(--hub-ink-3)"},children:[e.jsxs("div",{children:[e.jsxs("div",{className:"hub-mono",children:[e.jsx("span",{style:{color:"var(--hub-ink-2)"},children:G.length})," ",i("nav.servers").toLowerCase()," ·"," ",e.jsx("span",{style:{color:"var(--hub-ink-2)"},children:K})," ",i("server.tools").toLowerCase()]}),h&&e.jsxs("div",{className:"hub-mono mt-1",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:[e.jsxs("div",{title:i("cost.estimate"),children:[i("cost.totalFootprint"),": ",W(h.direct.exposed),"/",W(h.direct.gross)]}),h.smartRouting&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[i("cost.smartRouting"),": ",W(h.smartRouting.base)," (",i("cost.saved",{percent:ye(h.direct.exposed,h.smartRouting.base)}),")"]}),e.jsxs("div",{title:i("cost.smartRoutingPdHint"),children:[i("cost.smartRoutingPd"),":"," ",W(h.smartRouting.progressiveDisclosure)]})]}),h.connectedCount<h.totalCount&&e.jsx("div",{children:i("cost.connectedOf",{connected:h.connectedCount,total:h.totalCount})})]})]}),E&&e.jsxs("button",{className:"hub-btn ghost sm",style:{color:"var(--hub-ink-3)"},onClick:()=>s(a),children:[i("groups.configureTools")||i("groups.edit"),e.jsx(Fe,{size:11,style:{transform:"rotate(-90deg)"}})]})]}),e.jsx(Se,{isOpen:A!==null,target:A,onClose:()=>c(null)}),e.jsx(Ue,{isOpen:w,onClose:()=>y(!1),onConfirm:()=>{l(a.id),y(!1)},serverName:a.name,isGroup:!0})]})},Je=({onSuccess:a,onCancel:m})=>{const{t:s}=O(),[l,h]=f.useState(""),[i,p]=f.useState(null),[E,T]=f.useState(!1),[j,b]=f.useState(null),N=`{
1
+ import{r as f,j as e,R as M}from"./framework-vendor-CQFm9vKd.js";import{n as Y,f as ge,d as Z,u as fe,j as ve,k as ee}from"./index-BKFFbupY.js";import{u as se,a as te}from"./useCostData-3iIVsNH6.js";import{u as O}from"./i18n-vendor-DVmjrzgW.js";import{u as ue,c as je}from"./clipboard-7MOQ-4Cg.js";import{f as W,p as ye}from"./contextCost-CilWqGWT.js";import{g as Ne,A as ke,C as Se}from"./CopyClientConfigDialog-DPQOggV-.js";import{W as we,g as Ce,F as Ae,H as Ee,C as Te,r as J,J as ie,z as De,w as Ie,T as ze,n as Fe,D as oe,N as Pe,P as ce,l as Re,X as Le}from"./icons-vendor-CkcU1LMA.js";import{D as Ue}from"./DeleteDialog-BaCsEkJA.js";const Oe=["read","create","update","delete","other"],$e=a=>{var s,l,h;if(((s=a.annotations)==null?void 0:s.readOnlyHint)===!0)return"read";const m=a.value.toLowerCase();return/^(delete|remove)[_-]/.test(m)?"delete":((l=a.annotations)==null?void 0:l.destructiveHint)===!0?"other":/^(create|add)[_-]/.test(m)?"create":/^(update|set)[_-]/.test(m)?"update":((h=a.annotations)==null?void 0:h.readOnlyHint)!==!1&&/^(get|list|read|search)[_-]/.test(m)?"read":"other"},Ge=(a,m,s)=>{const l=m.trim().toLowerCase();return a.filter(h=>{var i,p;return(h.value.toLowerCase().includes(l)||((i=h.description)==null?void 0:i.toLowerCase().includes(l)))&&(s==="all"||((p=h.annotations)==null?void 0:p[s])===!0)})},We=(a,m,s,l)=>{if(s.length===0||a==="all"&&l==="select")return a;const h=new Set(a==="all"?m:a);for(const i of s)l==="deselect"||l==="invert"&&h.has(i)?h.delete(i):h.add(i);return[...h]},Me=({items:a,selection:m,tools:s,label:l,onChange:h,children:i})=>{const{t:p}=O(),[E,T]=f.useState(""),[j,b]=f.useState("all"),[N,w]=f.useState(!1),y=Ge(a,E,j),A=new Set(m==="all"?a.map(r=>r.value):m),c=(r,o)=>h(We(m,a.map(u=>u.value),r.map(u=>u.value),o)),k=s&&N?Oe.map(r=>({risk:r,items:y.filter(o=>$e(o)===r)})):[{risk:null,items:y}],v="text-xs text-blue-600 hover:text-blue-800 disabled:opacity-40 disabled:cursor-not-allowed";return e.jsxs("section",{"aria-label":l,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("input",{type:"search","aria-label":p("groups.bulkSearchLabel",{capability:l}),placeholder:p("groups.bulkSearch"),value:E,onChange:r=>T(r.target.value),className:"min-w-0 flex-1 basis-48 rounded border border-gray-300 bg-white dark:bg-gray-800 px-2 py-1 text-sm"}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{"aria-label":p("groups.annotationFilter"),value:j,onChange:r=>b(r.target.value),className:"max-w-full rounded border border-gray-300 bg-white dark:bg-gray-800 px-2 py-1 text-sm",children:[e.jsx("option",{value:"all",children:p("groups.allAnnotations")}),["readOnlyHint","destructiveHint","idempotentHint"].map(r=>e.jsx("option",{value:r,children:p(`groups.${r}`)},r))]}),e.jsx("button",{type:"button","aria-pressed":N,onClick:()=>w(!N),className:v,children:p(N?"groups.flatList":"groups.riskGroups")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mb-2",children:[e.jsx("span",{className:"text-xs text-gray-500",role:"status",children:p("groups.visibleCount",{count:y.length,total:a.length})}),["select","deselect","invert"].map(r=>e.jsx("button",{type:"button",disabled:!y.length,onClick:()=>c(y,r),className:v,children:p(`groups.${r}Visible`)},r))]}),s&&N&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:p("groups.riskHint")}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 max-h-96 overflow-y-auto",children:[y.length===0&&e.jsx("p",{className:"text-sm text-gray-500",children:p("groups.noMatchingItems")}),k.filter(r=>r.items.length>0).map(r=>{const o=r.items.filter(u=>A.has(u.value)).length;return e.jsxs(M.Fragment,{children:[r.risk&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-gray-200 py-1",children:[e.jsxs("span",{className:"text-xs font-medium",children:[p(`groups.risk_${r.risk}`)," (",o,"/",r.items.length,")"]}),e.jsx("button",{type:"button",className:v,onClick:()=>c(r.items,o===r.items.length?"deselect":"select"),children:p(o===r.items.length?"groups.selectNone":"groups.selectAll")})]}),r.items.map(u=>e.jsx(M.Fragment,{children:i(u)},u.value))]},r.risk??"flat")})]})]})},He={tools:[],prompts:[],resources:[]},de={tools:"all",prompts:"all",resources:"all"},me=({servers:a,value:m,onChange:s,className:l,serverCosts:h=[]})=>{const{t:i}=O(),{nameSeparator:p,smartRoutingConfig:E}=ue(),[T,j]=f.useState(new Set),b=M.useMemo(()=>m.map(t=>typeof t=="string"?{name:t,...de}:{...t,tools:t.tools||"all",prompts:t.prompts||"all",resources:t.resources||"all"}),[m]),N=M.useMemo(()=>a.filter(t=>t.enabled!==!1),[a]);M.useEffect(()=>{const t=new Set(b.map(n=>n.name)),d=new Set(N.map(n=>n.name));j(n=>{const S=new Set;return n.forEach(g=>{(t.has(g)||d.has(g))&&S.add(g)}),S})},[b,N]);const w=t=>{if(b.findIndex(n=>n.name===t)>=0){const n=b.filter(S=>S.name!==t);s(n)}else{const n=[...b,{name:t,...de}];s(n)}},y=t=>{j(d=>{const n=new Set(d);return n.has(t)?n.delete(t):n.add(t),n})},A=t=>["tools","prompts","resources"].some(d=>{const n=t[d];return n==="all"||Array.isArray(n)&&n.length>0}),c=(t,d,n,S=!1)=>{const g=b.find(z=>z.name===t),I={...g?{...g}:{name:t,...He},[d]:n};if(d==="tools"&&Array.isArray(n)&&I.pinnedTools&&(I.pinnedTools=I.pinnedTools.filter(z=>n.includes(z)),I.pinnedTools.length===0&&delete I.pinnedTools),!A(I)){const z=b.filter(x=>x.name!==t);s(z),S||j(x=>{const U=new Set(x);return U.delete(t),U});return}if(g){s(b.map(z=>z.name===t?I:z));return}s([...b,I])},k=(t,d)=>{const n=b.find(g=>g.name===t);if(!n)return;const S={...n};d?S.alias=d:delete S.alias,s(b.map(g=>g.name===t?S:g))},v=(t,d)=>{const n=b.find(P=>P.name===t);if(!n)return;const S=n.pinnedTools??[],g={...n,pinnedTools:S.includes(d)?S.filter(P=>P!==d):[...S,d]};g.pinnedTools.length===0&&delete g.pinnedTools,s(b.map(P=>P.name===t?g:P))},r=(t,d)=>{const n=`${t}${p}`;return d.startsWith(n)?d.slice(n.length):d},o=(t,d)=>d==="tools"?(t.tools||[]).filter(n=>n.enabled!==!1).map(n=>({key:n.name,value:r(t.name,n.name),description:n.description,annotations:n.annotations,defaultDescription:n.defaultDescription,hasDescriptionOverride:n.hasDescriptionOverride})):d==="prompts"?(t.prompts||[]).filter(n=>n.enabled!==!1).map(n=>({key:n.name,value:r(t.name,n.name),description:n.description})):(t.resources||[]).filter(n=>n.enabled!==!1).map(n=>({key:n.uri,value:n.uri,description:n.description})),u=M.useMemo(()=>{const t=new Map;return h.forEach(d=>{const n=new Map;d.items.forEach(S=>n.set(S.name,S.cost)),t.set(d.name,n)}),t},[h]),C=t=>u.get(t)??new Map,F=(t,d)=>{const n=C(t.name);return o(t,d).filter(S=>H(t.name,d,S.value)).reduce((S,g)=>S+(n.get(g.key)??0),0)},$=t=>["tools","prompts","resources"].reduce((d,n)=>d+F(t,n),0),q=(t,d,n)=>{const S=N.find(z=>z.name===t);if(!S)return;const g=o(S,d).map(z=>z.value),P=b.find(z=>z.name===t);if(!P){c(t,d,[n]);return}const I=P[d];if(I==="all"){const z=g.filter(x=>x!==n);c(t,d,z);return}if(Array.isArray(I)){if(I.includes(n)){c(t,d,I.filter(x=>x!==n));return}const z=[...I,n];c(t,d,z.length===g.length?"all":z);return}c(t,d,[n])},Q=t=>{const d=b.find(n=>n.name===t);return!!(d&&A(d))},G=t=>{const d=b.find(n=>n.name===t);return d?["tools","prompts","resources"].some(n=>{const S=d[n];return Array.isArray(S)&&S.length>0}):!1},H=(t,d,n)=>{const S=b.find(P=>P.name===t);if(!S)return!1;const g=S[d];return g==="all"?!0:Array.isArray(g)?g.includes(n):!1},K=(t,d)=>{const n=b.find(P=>P.name===t.name);if(!n)return 0;const S=o(t,d),g=n[d];if(g==="all")return S.length;if(Array.isArray(g)){const P=new Set(S.map(I=>I.value));return g.filter(I=>P.has(I)).length}return 0},_=[{key:"tools",titleKey:"groups.toolSelection",countKey:"groups.toolsSelected",allKey:"groups.allTools"},{key:"prompts",titleKey:"groups.promptSelection",countKey:"groups.promptsSelected",allKey:"groups.allPrompts"},{key:"resources",titleKey:"groups.resourceSelection",countKey:"groups.resourcesSelected",allKey:"groups.allResources"}],D=t=>_.map(({key:d})=>({key:d,count:K(t,d)})).filter(d=>d.count>0);return e.jsxs("div",{className:Y("space-y-4",l),children:[e.jsx("div",{className:"space-y-3",children:N.map(t=>{const d=Q(t.name),n=G(t.name),S=T.has(t.name),g=b.find(x=>x.name===t.name),P=D(t),I=_.filter(({key:x})=>o(t,x).length>0),z=C(t.name);return e.jsxs("div",{className:"border border-[var(--hub-line)] rounded-lg bg-[var(--hub-surface)] hover:border-[var(--hub-ink-3)] hover:bg-[var(--hub-surface-hover)] transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 cursor-pointer rounded-lg transition-colors",onClick:()=>y(t.name),children:[e.jsxs("div",{className:"flex items-center space-x-3",onClick:x=>{x.stopPropagation(),w(t.name)},children:[e.jsx("input",{type:"checkbox",checked:d||n,onChange:()=>w(t.name),className:"w-4 h-4 text-blue-600 accent-[var(--hub-accent)] rounded focus:ring-blue-500"}),e.jsx("span",{className:"font-medium text-[var(--hub-ink)] cursor-pointer select-none",children:t.name})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[$(t)>0&&e.jsxs("span",{className:"text-sm text-[var(--hub-ink-3)] hub-mono",title:i("cost.estimate"),children:["Σ ",W($(t))]}),P.map(({key:x,count:U})=>e.jsxs("span",{className:"text-sm text-green-600 flex items-center gap-1",children:[x==="tools"?e.jsx(we,{size:14}):x==="prompts"?e.jsx(Ce,{size:14}):e.jsx(Ae,{size:14})," ",U]},x)),I.length>0&&e.jsx("button",{type:"button",className:"p-1 text-[var(--hub-ink-3)] hover:text-[var(--hub-ink-2)] transition-colors",children:e.jsx("svg",{className:Y("w-5 h-5 transition-transform",S&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})]}),S&&I.length>0&&e.jsx("div",{className:"border-t border-[var(--hub-line)] bg-[var(--hub-bg-2)] p-3",children:e.jsxs("div",{className:"space-y-4",children:[g&&e.jsxs("div",{className:"space-y-1",onClick:x=>x.stopPropagation(),children:[e.jsx("label",{className:"block text-xs font-medium text-[var(--hub-ink-2)]",children:i("groups.alias")}),e.jsx("input",{type:"text",value:g.alias||"",placeholder:t.name,onChange:x=>k(t.name,x.target.value),className:"hub-input"})]}),I.map(({key:x,titleKey:U,countKey:he,allKey:be})=>{const B=o(t,x),re=K(t,x),X=(g==null?void 0:g[x])==="all"||re===B.length;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--hub-ink-2)]",children:i(U)}),e.jsxs("div",{className:"flex items-center gap-3",children:[g&&e.jsx("span",{className:"text-xs text-green-600",children:X?`(${i(be)} ${B.length}/${B.length})`:`(${i(he)} ${re}/${B.length})`}),g&&F(t,x)>0&&e.jsxs("span",{className:"text-xs text-[var(--hub-ink-3)] hub-mono",title:i("cost.estimate"),children:["Σ ",W(F(t,x))]}),e.jsx("button",{type:"button",onClick:()=>{c(t.name,x,X?[]:"all",!0)},className:"text-sm text-blue-600 hover:text-blue-800 transition-colors",children:i(X?"groups.selectNone":"groups.selectAll")})]})]}),e.jsx(Me,{items:B,selection:(g==null?void 0:g[x])??[],tools:x==="tools",label:i(U),onChange:R=>c(t.name,x,R,!0),children:R=>{var le;const ae=H(t.name,x,R.value),V=!!((le=g==null?void 0:g.pinnedTools)!=null&&le.includes(R.value)),L=x==="tools"?Ne({description:R.description,defaultDescription:R.defaultDescription,hasDescriptionOverride:R.hasDescriptionOverride},i("tool.noDescription")):null,ne=L!=null&&L.hasDescriptionOverride?i("tool.defaultDescriptionTooltip",{description:L.defaultDescription}):R.description;return e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsxs("label",{className:"flex min-w-0 flex-1 items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:ae,onChange:()=>q(t.name,x,R.value),className:"w-3 h-3 text-blue-600 accent-[var(--hub-accent)] rounded focus:ring-blue-500"}),e.jsx("span",{className:"text-[var(--hub-ink-2)] break-all whitespace-nowrap flex-shrink-0",children:R.value}),(R.description||(L==null?void 0:L.hasDescriptionOverride))&&e.jsxs("span",{className:"min-w-0 flex items-center gap-1 text-[var(--hub-ink-3)] text-xs truncate",children:[e.jsx("span",{className:"truncate",title:ne||void 0,children:L?L.currentDescription:R.description}),(L==null?void 0:L.hasDescriptionOverride)&&e.jsx("span",{className:"inline-flex flex-shrink-0 items-center rounded-full border border-amber-200 bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:border-amber-700/60 dark:bg-amber-900/20 dark:text-amber-300",title:ne||void 0,children:i("tool.descriptionModifiedBadge")})]}),z.get(R.key)!=null&&e.jsxs("span",{className:"text-xs text-[var(--hub-ink-3)] hub-mono whitespace-nowrap ml-auto flex-shrink-0",title:i("cost.estimate"),children:["Σ ",W(z.get(R.key))]})]}),x==="tools"&&ae&&(E.enabled||V)&&e.jsx("button",{type:"button",onClick:()=>v(t.name,R.value),title:i(V?"groups.unpinTool":"groups.pinTool"),"aria-label":i("groups.pinToolLabel"),"aria-pressed":V,className:Y("flex-shrink-0 transition-colors",V?"text-blue-600":"text-[var(--hub-ink-3)] hover:text-[var(--hub-ink-2)]"),children:e.jsx(Ee,{size:12,fill:V?"currentColor":"none"})})]},R.key)}})]},x)})]})})]},t.name)})}),N.length===0&&e.jsx("p",{className:"text-[var(--hub-ink-3)] text-sm",children:i("groups.noServerOptions")})]})};function pe({groupId:a,value:m,onChange:s}){const{t:l}=O(),[h,i]=f.useState([]),[p,E]=f.useState(""),[T,j]=f.useState(!1),[b,N]=f.useState(!1),[w,y]=f.useState(!1);f.useEffect(()=>{if(!a||m.visibility!=="group")return;let u=!1;return j(!0),N(!1),ge(`/groups/${encodeURIComponent(a)}/share-candidates`).then(C=>{u||(C.success&&Array.isArray(C.data)?i(C.data):N(!0))}).catch(()=>{u||N(!0)}).finally(()=>{u||j(!1)}),()=>{u=!0}},[a,m.visibility]);const A=m.sharedWithUsers||[],c=[...new Set([...h,...A])].sort().filter(u=>u.toLowerCase().includes(p.toLowerCase())),k=new Set(A),v=c.length>0&&c.every(u=>k.has(u)),r=c.length===0||c.every(u=>!k.has(u)),o=u=>{const C=new Set(A);C.has(u)?C.delete(u):C.add(u),s({sharedWithUsers:Array.from(C)})};return e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer bg-[var(--hub-bg-2)] hover:bg-[var(--hub-surface-hover)] p-3 rounded border border-[var(--hub-line)]",onClick:()=>y(!w),children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--hub-ink)]",children:l("server.sectionAdvanced","Advanced Options")}),e.jsx("span",{className:"text-[var(--hub-ink-3)] text-sm",children:w?"▼":"▶"})]}),w&&e.jsxs("div",{className:"border border-[var(--hub-line)] rounded-b p-4 bg-[var(--hub-surface)] border-t-0",children:[e.jsx("label",{htmlFor:"group-visibility",className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",children:l("server.visibility")}),e.jsxs("select",{id:"group-visibility",className:"hub-input",value:m.visibility||"",onChange:u=>s({visibility:u.target.value}),children:[!m.visibility&&e.jsx("option",{value:"",disabled:!0,children:l("groups.legacyVisibility")}),e.jsx("option",{value:"private",children:l("server.visibilityPrivate")}),e.jsx("option",{value:"group",children:l("server.visibilityGroup")}),e.jsx("option",{value:"public",children:l("server.visibilityPublic")})]}),e.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1",children:l("groups.visibilityDescription")}),!m.visibility&&e.jsx("p",{className:"text-sm text-amber-600",children:l("groups.legacyVisibilityHint")}),m.visibility==="group"&&e.jsxs("div",{className:"mt-4 rounded border border-[var(--hub-line)] p-3",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--hub-ink-2)]",children:l("server.shareWithUsers")}),e.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1 mb-3",children:l("server.shareWithUsersDescription")}),a?e.jsxs(e.Fragment,{children:[T&&e.jsx("p",{className:"text-sm text-[var(--hub-ink-3)]",children:l("server.shareCandidatesLoading")}),b&&e.jsx("p",{role:"alert",className:"text-sm text-red-600 dark:text-red-400",children:l("server.shareCandidatesError")}),!T&&!b&&c.length===0&&e.jsx("p",{className:"text-sm text-[var(--hub-ink-3)]",children:l(p?"server.noMatchingShareUsers":"server.noShareCandidates")}),c.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-3 space-y-2",children:[e.jsx("label",{htmlFor:"group-share-search",className:"block text-xs font-medium text-[var(--hub-ink-2)]",children:l("server.shareUserSearchLabel")}),e.jsx("input",{id:"group-share-search",type:"search",value:p,onChange:u=>E(u.target.value),placeholder:l("server.shareUserSearchPlaceholder"),className:"hub-input text-sm"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>s({sharedWithUsers:[...new Set([...A,...c])]}),disabled:v,className:"hub-btn text-sm",children:l("server.selectAllShareUsers")}),e.jsx("button",{type:"button",onClick:()=>s({sharedWithUsers:A.filter(u=>!c.includes(u))}),disabled:r,className:"hub-btn text-sm",children:l("server.deselectAllShareUsers")})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:c.map(u=>e.jsxs("label",{className:"flex items-center gap-2 rounded border border-[var(--hub-line)] px-3 py-2 text-sm text-[var(--hub-ink-2)]",children:[e.jsx("input",{type:"checkbox",checked:k.has(u),onChange:()=>o(u)}),e.jsx("span",{children:u})]},u))})]})]}):e.jsx("p",{className:"text-sm text-[var(--hub-ink-3)]",children:l("groups.shareAfterCreate")})]})]})]})}const _e=({onAdd:a,onCancel:m})=>{const{t:s}=O(),{createGroup:l}=Z(),{allServers:h}=se(),{serverCosts:i}=te(),[p,E]=f.useState([]),[T,j]=f.useState(null),[b,N]=f.useState(!1),[w,y]=f.useState({visibility:"private",sharedWithUsers:[],name:"",description:"",instructions:"",servers:[]});f.useEffect(()=>{E(h.filter(k=>k.enabled!==!1))},[h]);const A=k=>{const{name:v,value:r}=k.target;y(o=>({...o,[v]:r}))},c=async k=>{k.preventDefault(),N(!0),j(null);try{if(!w.name.trim()){j(s("groups.nameRequired")),N(!1);return}const v=await l(w.name,w.description,w.servers,{visibility:w.visibility,sharedWithUsers:w.sharedWithUsers,instructions:w.instructions});if(!v||!v.success){j((v==null?void 0:v.message)||s("groups.createError")),N(!1);return}a()}catch(v){j(v instanceof Error?v.message:String(v)),N(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"hub-card shadow-lg max-w-3xl w-full max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"p-6 flex-shrink-0",children:[e.jsx("h2",{className:"text-xl font-semibold text-[var(--hub-ink)] mb-4",children:s("groups.addNew")}),T&&e.jsx("div",{className:"mb-4 p-3 bg-red-100 text-red-700 rounded-md border border-[var(--hub-line)]",children:T})]}),e.jsxs("form",{onSubmit:c,className:"flex flex-col flex-1 min-h-0",children:[e.jsx("div",{className:"flex-1 overflow-y-auto px-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",htmlFor:"name",children:[s("groups.name")," *"]}),e.jsx("input",{type:"text",id:"name",name:"name",value:w.name,onChange:A,className:"w-full border border-[var(--hub-line)] bg-[var(--hub-surface)] rounded-md px-3 py-2 text-[var(--hub-ink)] placeholder:text-[var(--hub-ink-3)] focus:outline-none focus:border-[var(--hub-ink-2)]",placeholder:s("groups.namePlaceholder"),required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",htmlFor:"instructions",children:s("groups.instructions")}),e.jsx("textarea",{id:"instructions",name:"instructions",value:w.instructions,onChange:A,rows:3,className:"w-full border border-[var(--hub-line)] bg-[var(--hub-surface)] rounded-md px-3 py-2 text-[var(--hub-ink)] placeholder:text-[var(--hub-ink-3)] focus:outline-none focus:border-[var(--hub-ink-2)]",placeholder:s("groups.instructionsPlaceholder")}),e.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1",children:s("groups.instructionsHelp")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",children:s("groups.configureCapabilities")}),e.jsx(me,{servers:p,value:w.servers,onChange:k=>y(v=>({...v,servers:k})),className:"border border-[var(--hub-line)] rounded-lg p-4 bg-[var(--hub-bg-2)]",serverCosts:i})]}),e.jsx(pe,{value:w,onChange:k=>y(v=>({...v,...k}))})]})}),e.jsxs("div",{className:"flex justify-end space-x-2 p-5 pt-3 border-t border-[var(--hub-line-2)] flex-shrink-0",children:[e.jsx("button",{type:"button",onClick:m,className:"hub-btn",disabled:b,children:s("common.cancel")}),e.jsx("button",{type:"submit",className:"hub-btn primary",disabled:b,children:s(b?"common.submitting":"common.create")})]})]})]})})},Be=({group:a,onEdit:m,onCancel:s})=>{const{t:l}=O(),{updateGroup:h}=Z(),{allServers:i}=se(),{serverCosts:p}=te(),[E,T]=f.useState([]),[j,b]=f.useState(null),[N,w]=f.useState(!1),[y,A]=f.useState({visibility:a.visibility,sharedWithUsers:a.sharedWithUsers||[],name:a.name,description:a.description||"",instructions:a.instructions||"",servers:a.servers||[]});f.useEffect(()=>{T(i.filter(v=>v.enabled!==!1))},[i]);const c=v=>{const{name:r,value:o}=v.target;A(u=>({...u,[r]:o}))},k=async v=>{v.preventDefault(),w(!0),b(null);try{if(!y.name.trim()){b(l("groups.nameRequired")),w(!1);return}const r=await h(a.id,{visibility:y.visibility,sharedWithUsers:y.sharedWithUsers,name:y.name,description:y.description,instructions:y.instructions,servers:y.servers});if(!r||!r.success){b((r==null?void 0:r.message)||l("groups.updateError")),w(!1);return}m()}catch(r){b(r instanceof Error?r.message:String(r)),w(!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:"hub-card shadow-lg max-w-3xl w-full max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"p-6 flex-shrink-0",children:[e.jsx("h2",{className:"text-xl font-semibold text-[var(--hub-ink)] mb-4",children:l("groups.edit")}),j&&e.jsx("div",{className:"mb-4 p-3 bg-red-100 text-red-700 rounded-md border border-[var(--hub-line)]",children:j})]}),e.jsxs("form",{onSubmit:k,className:"flex flex-col flex-1 min-h-0",children:[e.jsx("div",{className:"flex-1 overflow-y-auto px-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",htmlFor:"name",children:[l("groups.name")," *"]}),e.jsx("input",{type:"text",id:"name",name:"name",value:y.name,onChange:c,className:"w-full border border-[var(--hub-line)] bg-[var(--hub-surface)] rounded-md px-3 py-2 text-[var(--hub-ink)] placeholder:text-[var(--hub-ink-3)] focus:outline-none focus:border-[var(--hub-ink-2)]",placeholder:l("groups.namePlaceholder"),required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",htmlFor:"instructions",children:l("groups.instructions")}),e.jsx("textarea",{id:"instructions",name:"instructions",value:y.instructions,onChange:c,rows:3,className:"w-full border border-[var(--hub-line)] bg-[var(--hub-surface)] rounded-md px-3 py-2 text-[var(--hub-ink)] placeholder:text-[var(--hub-ink-3)] focus:outline-none focus:border-[var(--hub-ink-2)]",placeholder:l("groups.instructionsPlaceholder")}),e.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1",children:l("groups.instructionsHelp")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",children:l("groups.configureCapabilities")}),e.jsx(me,{servers:E,value:y.servers,onChange:v=>A(r=>({...r,servers:v})),className:"border border-[var(--hub-line)] rounded-lg p-4 bg-[var(--hub-bg-2)]",serverCosts:p})]}),e.jsx(pe,{groupId:a.id,value:y,onChange:v=>A(r=>({...r,...v}))})]})}),e.jsxs("div",{className:"flex justify-end space-x-2 p-5 pt-3 border-t border-[var(--hub-line-2)] flex-shrink-0",children:[e.jsx("button",{type:"button",onClick:s,className:"hub-btn",disabled:N,children:l("common.cancel")}),e.jsx("button",{type:"submit",className:"hub-btn primary",disabled:N,children:l(N?"common.submitting":"common.save")})]})]})]})})},Ve=a=>a.map(m=>typeof m=="string"?m:m.name),xe=(a,m)=>{const s=a.servers.find(l=>typeof l=="string"?l===m:l.name===m);return s?typeof s=="string"?{name:s,tools:"all",prompts:"all",resources:"all"}:s:{name:m,tools:"all",prompts:"all",resources:"all"}},qe=(a,m)=>{var l;return((l=xe(a,m).alias)==null?void 0:l.trim())||m},Ke=({group:a,servers:m,onEdit:s,onDelete:l,cost:h})=>{var _;const{t:i}=O(),{auth:p}=fe(),E=!!p.user&&(p.user.isAdmin||p.user.username===a.owner),{showToast:T}=ve(),{installConfig:j,nameSeparator:b}=ue(),N=((_=j==null?void 0:j.baseUrl)==null?void 0:_.replace(/\/+$/,""))||"",[w,y]=f.useState(!1),[A,c]=f.useState(null),[k,v]=f.useState(!1),[r,o]=f.useState(!1),u=f.useRef(null);f.useEffect(()=>{const D=t=>{u.current&&!u.current.contains(t.target)&&o(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);const C=async D=>{await je(D)?(v(!0),o(!1),T(i("common.copySuccess")||"Copied","success"),setTimeout(()=>v(!1),1500)):T(i("common.copyFailed")||"Copy failed","error")},F=`${N}/mcp/${a.name}`,$=`${N}/mcp/${encodeURIComponent(a.name)}`,q=`${N}/api/${a.name}`,Q=Ve(a.servers),G=m.filter(D=>Q.includes(D.name)),H=D=>{const t=xe(a,D.name),d=`${D.name}${b}`,n=D.tools||[],S=D.prompts||[],g=D.resources||[],P=Array.isArray(t.tools)?n.filter(x=>{if(x.enabled===!1)return!1;const U=x.name.startsWith(d)?x.name.slice(d.length):x.name;return t.tools.includes(U)}).length:n.filter(x=>x.enabled!==!1).length,I=Array.isArray(t.prompts)?S.filter(x=>{if(x.enabled===!1)return!1;const U=x.name.startsWith(d)?x.name.slice(d.length):x.name;return t.prompts.includes(U)}).length:S.filter(x=>x.enabled!==!1).length,z=Array.isArray(t.resources)?g.filter(x=>x.enabled!==!1&&t.resources.includes(x.uri)).length:g.filter(x=>x.enabled!==!1).length;return{visibleTools:P,totalTools:n.length,visiblePrompts:I,totalPrompts:S.length,visibleResources:z,totalResources:g.length}},K=G.reduce((D,t)=>D+H(t).visibleTools,0);return e.jsxs("div",{className:"hub-card flex h-full flex-col overflow-visible",children:[e.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",style:{borderBottom:"1px solid var(--hub-line-2)"},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{style:{fontSize:15,fontWeight:600,letterSpacing:"-0.015em"},children:a.name}),e.jsx("span",{className:"hub-mono",style:{fontSize:11,color:"var(--hub-ink-3)",padding:"0 6px",border:"1px solid var(--hub-line)",borderRadius:4,height:18,display:"inline-flex",alignItems:"center"},title:a.id,children:a.id})]}),e.jsx("div",{className:"mt-1 text-xs text-[var(--hub-ink-3)]",children:a.visibility?i(`server.visibility${a.visibility==="group"?"Group":a.visibility==="public"?"Public":"Private"}`):i("groups.legacyVisibility")}),a.description&&e.jsx("div",{style:{fontSize:12.5,color:"var(--hub-ink-3)",marginTop:2},children:a.description})]}),e.jsxs("div",{className:"flex items-center gap-1",ref:u,children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>o(D=>!D),className:"hub-icon-btn sm",title:i("common.copy"),children:k?e.jsx(Te,{size:13,className:"text-[var(--hub-ok)]"}):e.jsx(J,{size:13})}),r&&e.jsxs("div",{className:"absolute top-full right-0 mt-1 z-20 hub-card",style:{minWidth:160,padding:4},children:[e.jsxs("button",{onClick:()=>C(a.id),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",children:[e.jsx(J,{size:12})," ",i("common.copyId")]}),e.jsxs("button",{onClick:()=>C(F),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",children:[e.jsx(ie,{size:12})," ",i("common.copyUrl")]}),e.jsxs("button",{onClick:()=>C(q),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",children:[e.jsx(ie,{size:12})," ",i("common.copyOpenApiUrl")]}),e.jsxs("button",{onClick:()=>{o(!1),c({name:a.name,url:$,headers:{Authorization:`Bearer ${ke}`}})},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",children:[e.jsx(De,{size:12})," ",i("clientConfig.menuItem")]})]})]}),E&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>s(a),className:"hub-icon-btn sm",title:i("groups.edit"),children:e.jsx(Ie,{size:13})}),e.jsx("button",{onClick:()=>y(!0),className:"hub-icon-btn sm",title:i("groups.delete"),style:{color:"var(--hub-ink-3)"},children:e.jsx(ze,{size:13})})]})]})]}),e.jsxs("div",{className:"grid flex-1 items-center gap-3 px-4 py-3",style:{gridTemplateColumns:"1fr 80px 1fr",minHeight:180},children:[e.jsx("div",{className:"flex flex-col gap-1.5",children:G.length===0?e.jsx("div",{style:{fontSize:12,color:"var(--hub-ink-3)"},children:i("groups.noServers")}):G.map(D=>{const t=H(D);return e.jsxs("div",{className:"flex items-center gap-2.5 px-2.5 py-1.5 rounded-md",style:{background:"var(--hub-bg-2)",border:"1px solid var(--hub-line-2)"},children:[e.jsx("span",{className:"inline-block flex-shrink-0",style:{width:6,height:6,borderRadius:50,background:D.status==="connected"?"var(--hub-ok)":D.status==="connecting"?"var(--hub-warn)":"var(--hub-err)"}}),e.jsx("span",{className:"hub-mono truncate flex-1",style:{fontSize:12.5},children:e.jsx("span",{title:D.name,children:qe(a,D.name)})}),e.jsxs("span",{className:"hub-mono hub-num flex-shrink-0",style:{fontSize:11,color:"var(--hub-ink-3)"},children:[t.visibleTools,"/",t.totalTools," tools"]})]},D.name)})}),e.jsxs("svg",{width:"80",height:"80",viewBox:"0 0 80 80",className:"self-center",children:[G.length===0?e.jsx("path",{d:"M0,40 C30,40 50,40 80,40",stroke:"var(--hub-line)",strokeWidth:"1",fill:"none",strokeDasharray:"3 3"}):G.map((D,t)=>{const d=12+60/Math.max(G.length,1)*(t+.5);return e.jsx("path",{d:`M0,${d} C 30,${d} 50,40 80,40`,stroke:"var(--hub-line)",strokeWidth:"1",fill:"none",strokeDasharray:"3 3"},t)}),e.jsx("circle",{cx:"80",cy:"40",r:"4",fill:"var(--hub-ink)"})]}),e.jsxs("div",{className:"px-3 py-2.5 rounded-md",style:{border:"1px solid var(--hub-line)",background:"var(--hub-bg-2)"},children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:4},children:"endpoint"}),e.jsxs("div",{className:"hub-mono break-all",style:{fontSize:12,color:"var(--hub-ink-2)",lineHeight:1.4},children:[e.jsx("span",{style:{color:"var(--hub-ink-3)"},children:"/mcp/"}),e.jsx("b",{style:{color:"var(--hub-ink)",fontWeight:600},children:a.name})]}),e.jsxs("div",{className:"hub-mono break-all",style:{fontSize:12,color:"var(--hub-ink-2)",lineHeight:1.4},children:[e.jsx("span",{style:{color:"var(--hub-ink-3)"},children:"/api/"}),e.jsx("b",{style:{color:"var(--hub-ink)",fontWeight:600},children:a.name})]}),e.jsxs("div",{className:"flex gap-1.5 mt-2",children:[e.jsxs("button",{className:"hub-btn sm flex-1 justify-center",onClick:()=>C(F),title:i("common.copyUrl"),children:[e.jsx(J,{size:11})," MCP"]}),e.jsxs("button",{className:"hub-btn sm flex-1 justify-center",onClick:()=>C(q),title:i("common.copyOpenApiUrl"),children:[e.jsx(J,{size:11})," OpenAPI"]})]})]})]}),e.jsxs("div",{className:"flex justify-between items-center px-4 py-2",style:{borderTop:"1px solid var(--hub-line-2)",background:"var(--hub-bg-2)",fontSize:12,color:"var(--hub-ink-3)"},children:[e.jsxs("div",{children:[e.jsxs("div",{className:"hub-mono",children:[e.jsx("span",{style:{color:"var(--hub-ink-2)"},children:G.length})," ",i("nav.servers").toLowerCase()," ·"," ",e.jsx("span",{style:{color:"var(--hub-ink-2)"},children:K})," ",i("server.tools").toLowerCase()]}),h&&e.jsxs("div",{className:"hub-mono mt-1",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:[e.jsxs("div",{title:i("cost.estimate"),children:[i("cost.totalFootprint"),": ",W(h.direct.exposed),"/",W(h.direct.gross)]}),h.smartRouting&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[i("cost.smartRouting"),": ",W(h.smartRouting.base)," (",i("cost.saved",{percent:ye(h.direct.exposed,h.smartRouting.base)}),")"]}),e.jsxs("div",{title:i("cost.smartRoutingPdHint"),children:[i("cost.smartRoutingPd"),":"," ",W(h.smartRouting.progressiveDisclosure)]})]}),h.connectedCount<h.totalCount&&e.jsx("div",{children:i("cost.connectedOf",{connected:h.connectedCount,total:h.totalCount})})]})]}),E&&e.jsxs("button",{className:"hub-btn ghost sm",style:{color:"var(--hub-ink-3)"},onClick:()=>s(a),children:[i("groups.configureTools")||i("groups.edit"),e.jsx(Fe,{size:11,style:{transform:"rotate(-90deg)"}})]})]}),e.jsx(Se,{isOpen:A!==null,target:A,onClose:()=>c(null)}),e.jsx(Ue,{isOpen:w,onClose:()=>y(!1),onConfirm:()=>{l(a.id),y(!1)},serverName:a.name,isGroup:!0})]})},Je=({onSuccess:a,onCancel:m})=>{const{t:s}=O(),[l,h]=f.useState(""),[i,p]=f.useState(null),[E,T]=f.useState(!1),[j,b]=f.useState(null),N=`{
2
2
  "groups": [
3
3
  {
4
4
  "name": "AI Assistants",
@@ -30,4 +30,4 @@ Supports:
30
30
  - All groups will be imported in a single efficient batch operation.`,w=r=>{try{const o=JSON.parse(r.trim());if(!o.groups||!Array.isArray(o.groups))return p(s("groupImport.invalidFormat")),null;for(const u of o.groups)if(!u.name||typeof u.name!="string")return p(s("groupImport.missingName")),null;return o}catch{return p(s("groupImport.parseError")),null}},y=()=>{p(null);const r=w(l);r&&b(r.groups)},A=async()=>{if(j){T(!0),p(null);try{const r=await ee("/groups/batch",{groups:j});if(r.success){const{successCount:o,failureCount:u,results:C}=r;if(u>0){const F=C.filter($=>!$.success).map($=>`${$.name}: ${$.message||s("groupImport.addFailed")}`);p(s("groupImport.partialSuccess",{count:o,total:j.length})+`
31
31
  `+F.join(`
32
32
  `))}o>0&&a()}else p(r.message||s("groupImport.importFailed"))}catch(r){console.error("Import error:",r),p(s("groupImport.importFailed"))}finally{T(!1)}}},c=r=>e.jsx("span",{className:"text-gray-500 ml-2",children:s(`groups.${r}`)}),k=(r,o)=>{if(!o||o==="all")return null;const u=Array.isArray(o)?o.join(", "):o;return e.jsx("span",{className:"text-gray-500 ml-2",children:s(`groups.${r}`,{items:u})})},v=r=>!r||r.length===0?e.jsx("span",{className:"text-gray-500",children:s("groups.noServers")}):e.jsx("div",{className:"space-y-1",children:r.map((o,u)=>typeof o=="string"?e.jsxs("div",{className:"text-sm",children:["• ",o]},u):e.jsxs("div",{className:"text-sm",children:["• ",o.name,o.tools&&o.tools!=="all"&&e.jsxs("span",{className:"text-gray-500 ml-2",children:["(",Array.isArray(o.tools)?o.tools.join(", "):o.tools,")"]}),o.tools==="all"&&c("previewAllTools"),k("previewPrompts",o.prompts),o.prompts==="all"&&c("previewAllPrompts"),k("previewResources",o.resources),o.resources==="all"&&c("previewAllResources")]},u))});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:s("groupImport.title")}),e.jsx("button",{onClick:m,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),i&&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:i})}),j?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:s("groupImport.previewTitle")}),e.jsx("div",{className:"space-y-3",children:j.map((r,o)=>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:r.name}),r.description&&e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:r.description}),e.jsxs("div",{className:"mt-2 text-sm text-gray-600",children:[e.jsxs("strong",{children:[s("groups.servers"),":"]}),e.jsx("div",{className:"mt-1",children:v(r.servers)})]})]})})},o))})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:()=>b(null),disabled:E,className:"hub-btn",children:s("common.back")}),e.jsx("button",{onClick:A,disabled:E,className:"hub-btn primary",children:E?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"})]}),s("groupImport.importing")]}):s("groupImport.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:s("groupImport.inputLabel")}),e.jsx("textarea",{value:l,onChange:r=>h(r.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:N}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:s("groupImport.inputHelp")})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:m,className:"hub-btn",children:s("common.cancel")}),e.jsx("button",{onClick:y,disabled:!l.trim(),className:"hub-btn primary",children:s("groupImport.preview")})]})]})]})})},Qe=({groups:a,onCancel:m})=>{const{t:s}=O(),[l,h]=f.useState(""),[i,p]=f.useState(""),[E,T]=f.useState([]),[j,b]=f.useState(!1),[N,w]=f.useState(!1),[y,A]=f.useState(null),c=r=>{T(o=>o.includes(r)?o.filter(u=>u!==r):[...o,r])},k=()=>{E.length===a.length?T([]):T(a.map(r=>r.id))},v=async()=>{if(!l.trim()){A(s("template.nameRequired"));return}w(!0),A(null);try{const r=await ee("/templates/export",{name:l.trim(),description:i.trim()||void 0,groupIds:E.length>0?E:void 0,includeDisabledServers:j});if(r.success&&r.data){const o=r.data,u=new Blob([JSON.stringify(o,null,2)],{type:"application/json"}),C=URL.createObjectURL(u),F=document.createElement("a");F.href=C,F.download=`${o.name.replace(/[^a-zA-Z0-9-_]/g,"_")}.mcphub-template.json`,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(C),m()}else A(r.message||s("template.exportFailed"))}catch(r){console.error("Export error:",r),A(s("template.exportFailed"))}finally{w(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 w-full max-w-3xl 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:s("template.exportTitle")}),e.jsx("button",{onClick:m,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),y&&e.jsx("div",{className:"mb-4 bg-red-50 dark:bg-red-900/20 border-l-4 border-red-500 p-4 rounded",children:e.jsx("p",{className:"text-red-700 dark:text-red-300",children:y})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[s("template.name")," *"]}),e.jsx("input",{type:"text",value:l,onChange:r=>h(r.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:s("template.namePlaceholder")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("template.description")}),e.jsx("input",{type:"text",value:i,onChange:r=>p(r.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:s("template.descriptionPlaceholder")})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700",children:s("template.selectGroups")}),e.jsx("button",{onClick:k,className:"text-sm text-blue-600 hover:text-blue-800 dark:text-blue-300",children:E.length===a.length?s("template.deselectAll"):s("template.selectAll")})]}),e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:s("template.selectGroupsHelp")}),e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-md max-h-48 overflow-y-auto",children:a.map(r=>e.jsxs("label",{className:"flex items-center px-3 py-2 hover:bg-gray-50 dark:bg-gray-800 dark:hover:bg-gray-700 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:E.includes(r.id),onChange:()=>c(r.id),className:"mr-3 h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:r.name}),r.description&&e.jsx("span",{className:"text-xs text-gray-500 ml-2",children:r.description})]})]},r.id))})]}),e.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:j,onChange:r=>b(r.target.checked),className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),e.jsx("span",{className:"text-sm text-gray-700",children:s("template.includeDisabled")})]})]}),e.jsx("div",{className:"mt-4 p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-700/60 rounded-md",children:e.jsx("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:s("template.exportNote")})}),e.jsxs("div",{className:"flex justify-end space-x-4 mt-6",children:[e.jsx("button",{onClick:m,className:"hub-btn",children:s("common.cancel")}),e.jsx("button",{onClick:v,disabled:N||!l.trim(),className:"hub-btn primary",children:s(N?"template.exporting":"template.export")})]})]})})},Xe=({onSuccess:a,onCancel:m})=>{const{t:s}=O(),[l,h]=f.useState(null),[i,p]=f.useState(null),[E,T]=f.useState(!1),[j,b]=f.useState(null),N=f.useRef(null),w=c=>{var r;p(null),h(null),b(null);const k=(r=c.target.files)==null?void 0:r[0];if(!k)return;const v=new FileReader;v.onload=o=>{var u;try{const C=JSON.parse((u=o.target)==null?void 0:u.result);if(!C.version||!C.name||!C.servers||!C.groups){p(s("template.invalidFormat"));return}h(C)}catch{p(s("template.parseError"))}},v.readAsText(k)},y=c=>{if(p(null),h(null),b(null),!!c.trim())try{const k=JSON.parse(c.trim());if(!k.version||!k.name||!k.servers||!k.groups){p(s("template.invalidFormat"));return}h(k)}catch{p(s("template.parseError"))}},A=async()=>{if(l){T(!0),p(null);try{const c=await ee("/templates/import",l);c.data?(b(c.data),c.data.success&&a()):p(c.message||s("template.importFailed"))}catch(c){console.error("Import error:",c),p(s("template.importFailed"))}finally{T(!1)}}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:s("template.importTitle")}),e.jsx("button",{onClick:m,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),i&&e.jsx("div",{className:"mb-4 bg-red-50 dark:bg-red-900/20 border-l-4 border-red-500 p-4 rounded",children:e.jsx("p",{className:"text-red-700 dark:text-red-300",children:i})}),j&&e.jsxs("div",{className:`mb-4 p-4 rounded border-l-4 ${j.success?"bg-green-50 dark:bg-green-900/20 border-green-500":"bg-yellow-50 dark:bg-yellow-900/20 border-yellow-500"}`,children:[e.jsx("p",{className:j.success?"text-green-700 dark:text-green-300":"text-yellow-700 dark:text-yellow-300",children:s("template.importResult",{serversCreated:j.serversCreated,serversSkipped:j.serversSkipped,groupsCreated:j.groupsCreated,groupsSkipped:j.groupsSkipped})}),j.requiredEnvVars.length>0&&e.jsxs("div",{className:"mt-2 p-2 bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-700/60 rounded",children:[e.jsx("p",{className:"text-sm font-medium text-orange-800 dark:text-orange-300",children:s("template.envVarsNeeded")}),e.jsx("ul",{className:"mt-1 text-sm text-orange-700 dark:text-orange-300",children:j.requiredEnvVars.map(c=>e.jsx("li",{className:"font-mono",children:c},c))})]})]}),l?e.jsxs("div",{children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx("h3",{className:"font-medium text-gray-900",children:l.name}),l.description&&e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:l.description}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[s("template.version"),": ",l.version," | ",s("template.createdAt"),":"," ",new Date(l.createdAt).toLocaleDateString()]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:[s("template.servers")," (",Object.keys(l.servers).length,")"]}),e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-md divide-y divide-gray-200 dark:divide-gray-700 max-h-40 overflow-y-auto",children:Object.entries(l.servers).map(([c,k])=>e.jsxs("div",{className:"px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:c}),e.jsx("span",{className:"text-xs text-gray-500 ml-2",children:k.type||"stdio"})]},c))})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:[s("template.groups")," (",l.groups.length,")"]}),e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-md divide-y divide-gray-200 dark:divide-gray-700 max-h-40 overflow-y-auto",children:l.groups.map((c,k)=>e.jsxs("div",{className:"px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:c.name}),c.description&&e.jsx("span",{className:"text-xs text-gray-500 ml-2",children:c.description}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:[c.servers.length," ",s("template.serversInGroup")]})]},k))})]}),l.requiredEnvVars.length>0&&e.jsxs("div",{className:"p-3 bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-700/60 rounded-md",children:[e.jsx("h4",{className:"text-sm font-medium text-orange-800 dark:text-orange-300",children:s("template.envVarsNeeded")}),e.jsx("ul",{className:"mt-1 text-sm text-orange-700 dark:text-orange-300 font-mono",children:l.requiredEnvVars.map(c=>e.jsx("li",{children:c},c))})]})]}),e.jsxs("div",{className:"flex justify-end space-x-4 mt-6",children:[e.jsx("button",{onClick:()=>{h(null),b(null),N.current&&(N.current.value="")},className:"hub-btn",children:s("common.back")}),e.jsx("button",{onClick:A,disabled:E,className:"hub-btn primary",children:s(E?"template.importing":"template.import")})]})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsx("label",{className:"block text-sm font-medium text-gray-700",children:s("template.uploadFile")})}),e.jsx("div",{className:"flex items-center space-x-4",children:e.jsx("input",{ref:N,type:"file",accept:".json",onChange:w,className:"block text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-semibold file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100"})})]}),e.jsxs("div",{className:"relative my-4",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-gray-300"})}),e.jsx("div",{className:"relative flex justify-center text-sm",children:e.jsx("span",{className:"bg-white dark:bg-gray-800 px-2 text-gray-500",children:s("template.or")})})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:s("template.pasteJson")}),e.jsx("textarea",{className:"w-full h-64 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:s("template.pastePlaceholder"),onChange:c=>y(c.target.value)})]}),e.jsx("div",{className:"flex justify-end space-x-4",children:e.jsx("button",{onClick:m,className:"hub-btn",children:s("common.cancel")})})]})]})})},is=()=>{const{t:a}=O(),{groups:m,loading:s,error:l,setError:h,deleteGroup:i,triggerRefresh:p}=Z(),{allServers:E}=se({refreshOnMount:!0}),{groupCosts:T,refetch:j}=te();f.useEffect(()=>{j()},[m,E,j]);const[b,N]=f.useState(null),[w,y]=f.useState(!1),[A,c]=f.useState(!1),[k,v]=f.useState(!1),[r,o]=f.useState(!1),u=async C=>{const F=await i(C);(!F||!F.success)&&h((F==null?void 0:F.message)||a("groups.deleteError"))};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:a("pages.groups.title")}),e.jsxs("p",{className:"hub-sub",children:[e.jsx("span",{className:"hub-num",children:m.length})," ",a("nav.groups").toLowerCase()]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{className:"hub-btn",onClick:()=>c(!0),children:[e.jsx(oe,{size:13})," ",a("groupImport.button")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>v(!0),children:[e.jsx(Pe,{size:13})," ",a("template.exportButton")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>o(!0),children:[e.jsx(oe,{size:13})," ",a("template.importButton")]}),e.jsxs("button",{className:"hub-btn primary",onClick:()=>y(!0),children:[e.jsx(ce,{size:13})," ",a("groups.add")]})]})]}),l&&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(Re,{size:14,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate text-[13px]",children:l})]}),e.jsx("button",{className:"hub-icon-btn sm",onClick:()=>h(null),children:e.jsx(Le,{size:13})})]}),s?e.jsx("div",{className:"hub-card p-6 text-center",style:{color:"var(--hub-ink-3)"},children:a("app.loading")}):m.length===0?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:a("groups.noGroups")}):e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3.5",children:[m.map(C=>e.jsx(Ke,{group:C,servers:E,onEdit:N,onDelete:u,cost:T.find(F=>F.id===C.id)},C.id)),e.jsx("button",{onClick:()=>y(!0),className:"flex items-center justify-center text-[var(--hub-ink-3)] hover:text-[var(--hub-ink-2)] transition-colors",style:{border:"1px dashed var(--hub-line)",borderRadius:10,minHeight:200,background:"transparent",cursor:"pointer"},children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"grid place-items-center mx-auto mb-2",style:{width:36,height:36,borderRadius:10,border:"1px solid var(--hub-line)"},children:e.jsx(ce,{size:16})}),e.jsx("div",{style:{fontSize:13,fontWeight:500,color:"var(--hub-ink-2)"},children:a("groups.add")}),e.jsx("div",{style:{fontSize:12,marginTop:2},children:a("groups.addNew")})]})})]}),w&&e.jsx(_e,{onAdd:()=>{y(!1),p()},onCancel:()=>y(!1)}),A&&e.jsx(Je,{onSuccess:()=>{c(!1),p()},onCancel:()=>c(!1)}),b&&e.jsx(Be,{group:b,onEdit:()=>{N(null),p()},onCancel:()=>N(null)}),k&&e.jsx(Qe,{groups:m,onCancel:()=>v(!1)}),r&&e.jsx(Xe,{onSuccess:()=>{o(!1),p()},onCancel:()=>o(!1)})]})};export{is as default};
33
- //# sourceMappingURL=GroupsPage-5iCk1LKT.js.map
33
+ //# sourceMappingURL=GroupsPage-DtoTWqWU.js.map