@samanhappy/mcphub 1.0.38 → 1.0.39

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 (78) hide show
  1. package/dist/db/repositories/VectorEmbeddingRepository.js +35 -3
  2. package/dist/db/repositories/VectorEmbeddingRepository.js.map +1 -1
  3. package/dist/services/mcpService.js +85 -2
  4. package/dist/services/mcpService.js.map +1 -1
  5. package/dist/services/vectorSearchService.js +12 -3
  6. package/dist/services/vectorSearchService.js.map +1 -1
  7. package/dist/utils/cacheUtils.js +345 -1
  8. package/dist/utils/cacheUtils.js.map +1 -1
  9. package/dist/utils/packageUpdate.js +242 -0
  10. package/dist/utils/packageUpdate.js.map +1 -0
  11. package/dist/utils/serverConfigPersistence.js +6 -0
  12. package/dist/utils/serverConfigPersistence.js.map +1 -1
  13. package/frontend/dist/assets/{ActivityPage-BZNq-eGE.js → ActivityPage-CDKSVr2I.js} +2 -2
  14. package/frontend/dist/assets/{ActivityPage-BZNq-eGE.js.map → ActivityPage-CDKSVr2I.js.map} +1 -1
  15. package/frontend/dist/assets/CopyClientConfigDialog-DYiucK0d.js +4 -0
  16. package/frontend/dist/assets/CopyClientConfigDialog-DYiucK0d.js.map +1 -0
  17. package/frontend/dist/assets/{CredentialsPage-7kyDJLsX.js → CredentialsPage-DMJE4uT2.js} +2 -2
  18. package/frontend/dist/assets/{CredentialsPage-7kyDJLsX.js.map → CredentialsPage-DMJE4uT2.js.map} +1 -1
  19. package/frontend/dist/assets/Dashboard-Dh_39img.js +2 -0
  20. package/frontend/dist/assets/{Dashboard-CElNx820.js.map → Dashboard-Dh_39img.js.map} +1 -1
  21. package/frontend/dist/assets/EndpointCopy-CQmwGXbD.js +2 -0
  22. package/frontend/dist/assets/EndpointCopy-CQmwGXbD.js.map +1 -0
  23. package/frontend/dist/assets/GroupsPage-BqscWSfR.js +33 -0
  24. package/frontend/dist/assets/GroupsPage-BqscWSfR.js.map +1 -0
  25. package/frontend/dist/assets/{LoginPage-D23s7oM0.js → LoginPage-DcrwvgS6.js} +2 -2
  26. package/frontend/dist/assets/{LoginPage-D23s7oM0.js.map → LoginPage-DcrwvgS6.js.map} +1 -1
  27. package/frontend/dist/assets/{LogsPage-BuQMkmV-.js → LogsPage--Blkr-Ni.js} +2 -2
  28. package/frontend/dist/assets/{LogsPage-BuQMkmV-.js.map → LogsPage--Blkr-Ni.js.map} +1 -1
  29. package/frontend/dist/assets/{MarketPage-g9vEYzIq.js → MarketPage-DWv18j4V.js} +2 -2
  30. package/frontend/dist/assets/{MarketPage-g9vEYzIq.js.map → MarketPage-DWv18j4V.js.map} +1 -1
  31. package/frontend/dist/assets/{OAuthConsentPage-BiX1lpJR.js → OAuthConsentPage-DCKZIMzE.js} +2 -2
  32. package/frontend/dist/assets/{OAuthConsentPage-BiX1lpJR.js.map → OAuthConsentPage-DCKZIMzE.js.map} +1 -1
  33. package/frontend/dist/assets/{PromptsPage-g8SRFY6s.js → PromptsPage-DoVmnVnp.js} +2 -2
  34. package/frontend/dist/assets/{PromptsPage-g8SRFY6s.js.map → PromptsPage-DoVmnVnp.js.map} +1 -1
  35. package/frontend/dist/assets/{ResourcesPage-Ddhxi9Sf.js → ResourcesPage-B8udCQQR.js} +2 -2
  36. package/frontend/dist/assets/{ResourcesPage-Ddhxi9Sf.js.map → ResourcesPage-B8udCQQR.js.map} +1 -1
  37. package/frontend/dist/assets/ServersPage-OLpH1K1I.js +39 -0
  38. package/frontend/dist/assets/ServersPage-OLpH1K1I.js.map +1 -0
  39. package/frontend/dist/assets/{SettingsPage-DZXjQZXS.js → SettingsPage-DlK0Jcta.js} +3 -3
  40. package/frontend/dist/assets/{SettingsPage-DZXjQZXS.js.map → SettingsPage-DlK0Jcta.js.map} +1 -1
  41. package/frontend/dist/assets/{StatusDot-CdzMqjTi.js → StatusDot-DgDU3plH.js} +2 -2
  42. package/frontend/dist/assets/{StatusDot-CdzMqjTi.js.map → StatusDot-DgDU3plH.js.map} +1 -1
  43. package/frontend/dist/assets/{ToggleGroup-CJd8X_31.js → ToggleGroup-11yhmcwY.js} +2 -2
  44. package/frontend/dist/assets/{ToggleGroup-CJd8X_31.js.map → ToggleGroup-11yhmcwY.js.map} +1 -1
  45. package/frontend/dist/assets/{UsersPage-CkP_x9Rt.js → UsersPage-BqPEkoIX.js} +2 -2
  46. package/frontend/dist/assets/{UsersPage-CkP_x9Rt.js.map → UsersPage-BqPEkoIX.js.map} +1 -1
  47. package/frontend/dist/assets/clipboard-BukcCPLt.js +2 -0
  48. package/frontend/dist/assets/clipboard-BukcCPLt.js.map +1 -0
  49. package/frontend/dist/assets/{icons-vendor-VW-UwEhw.js → icons-vendor-Bk5sng-h.js} +66 -61
  50. package/frontend/dist/assets/icons-vendor-Bk5sng-h.js.map +1 -0
  51. package/frontend/dist/assets/index-D4Vy78bV.css +1 -0
  52. package/frontend/dist/assets/index-DhzWX9nb.js +3 -0
  53. package/frontend/dist/assets/{index-Bu4XuAH4.js.map → index-DhzWX9nb.js.map} +1 -1
  54. package/frontend/dist/assets/{resourceService-w-cZ31FD.js → resourceService-D-PRt7tB.js} +2 -2
  55. package/frontend/dist/assets/{resourceService-w-cZ31FD.js.map → resourceService-D-PRt7tB.js.map} +1 -1
  56. package/frontend/dist/assets/{useCostData-C72NC0PQ.js → useCostData-B-uSfiuA.js} +2 -2
  57. package/frontend/dist/assets/{useCostData-C72NC0PQ.js.map → useCostData-B-uSfiuA.js.map} +1 -1
  58. package/frontend/dist/assets/useSettingsData-Bk1AwN5F.js +2 -0
  59. package/frontend/dist/assets/{useSettingsData-JTEMu74D.js.map → useSettingsData-Bk1AwN5F.js.map} +1 -1
  60. package/frontend/dist/assets/variableDetection-B7Ko56CL.js +16 -0
  61. package/frontend/dist/assets/variableDetection-B7Ko56CL.js.map +1 -0
  62. package/frontend/dist/index.html +3 -3
  63. package/package.json +2 -1
  64. package/frontend/dist/assets/Dashboard-CElNx820.js +0 -2
  65. package/frontend/dist/assets/EndpointCopy-8jW5Xtka.js +0 -2
  66. package/frontend/dist/assets/EndpointCopy-8jW5Xtka.js.map +0 -1
  67. package/frontend/dist/assets/GroupsPage-dUkvX_iB.js +0 -33
  68. package/frontend/dist/assets/GroupsPage-dUkvX_iB.js.map +0 -1
  69. package/frontend/dist/assets/ServersPage-DAmKvrPV.js +0 -39
  70. package/frontend/dist/assets/ServersPage-DAmKvrPV.js.map +0 -1
  71. package/frontend/dist/assets/icons-vendor-VW-UwEhw.js.map +0 -1
  72. package/frontend/dist/assets/index-B3OqAhGz.css +0 -1
  73. package/frontend/dist/assets/index-Bu4XuAH4.js +0 -3
  74. package/frontend/dist/assets/toolDescription-Dw3sa28K.js +0 -2
  75. package/frontend/dist/assets/toolDescription-Dw3sa28K.js.map +0 -1
  76. package/frontend/dist/assets/useSettingsData-JTEMu74D.js +0 -2
  77. package/frontend/dist/assets/variableDetection-DfhNyFy-.js +0 -16
  78. package/frontend/dist/assets/variableDetection-DfhNyFy-.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Dashboard-CElNx820.js","sources":["../../src/pages/Dashboard.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useNavigate } from 'react-router-dom';\nimport { RefreshCw, Plus, ChevronRight, AlertCircle } from 'lucide-react';\nimport { useServerData } from '@/hooks/useServerData';\nimport { useGroupData } from '@/hooks/useGroupData';\nimport { useSettingsData } from '@/hooks/useSettingsData';\nimport { useCostData } from '@/hooks/useCostData';\nimport { formatTokens } from '@/utils/contextCost';\nimport { Server } from '@/types';\nimport { EndpointCopy } from '@/components/ui/EndpointCopy';\nimport { ServerStatusDot } from '@/components/ui/StatusDot';\n\nconst Stat: React.FC<{ label: string; value: React.ReactNode; tone?: 'ok' | 'warn' | 'err' | 'muted' | 'default' }> = ({\n label,\n value,\n tone = 'default',\n}) => {\n const toneColor =\n tone === 'ok'\n ? 'oklch(0.4 0.13 145)'\n : tone === 'warn'\n ? 'oklch(0.45 0.13 80)'\n : tone === 'err'\n ? 'oklch(0.45 0.18 25)'\n : tone === 'muted'\n ? 'var(--hub-ink-3)'\n : 'var(--hub-ink)';\n return (\n <div className=\"hub-card\" style={{ padding: '14px 16px' }}>\n <div className=\"text-[12px]\" style={{ color: 'var(--hub-ink-3)' }}>\n {label}\n </div>\n <div\n className=\"hub-num\"\n style={{\n fontSize: 26,\n fontWeight: 500,\n letterSpacing: '-0.02em',\n lineHeight: 1.1,\n marginTop: 8,\n color: toneColor,\n }}\n >\n {value}\n </div>\n </div>\n );\n};\n\nconst transportLabel = (t: any, type?: string) => {\n if (!type) return null;\n if (type === 'stdio') return t('server.typeStdio') || 'stdio';\n if (type === 'sse') return t('server.typeSse') || 'sse';\n if (type === 'streamable-http') return t('server.typeStreamableHttp') || 'http';\n if (type === 'openapi') return t('server.typeOpenapi') || 'openapi';\n return type;\n};\n\nconst DashboardPage: React.FC = () => {\n const { t } = useTranslation();\n const navigate = useNavigate();\n const { allServers, error, setError, isLoading, triggerRefresh } = useServerData({\n refreshOnMount: true,\n });\n const { groups } = useGroupData();\n const { installConfig } = useSettingsData();\n const { serverCosts } = useCostData();\n\n const [hasLoaded, setHasLoaded] = React.useState(false);\n const loadingStartedRef = React.useRef(false);\n React.useEffect(() => {\n if (isLoading) {\n loadingStartedRef.current = true;\n return;\n }\n if (loadingStartedRef.current) {\n setHasLoaded(true);\n return;\n }\n if (allServers.length > 0 || error) setHasLoaded(true);\n }, [isLoading, allServers.length, error]);\n\n const stats = useMemo(\n () => ({\n total: allServers.length,\n online: allServers.filter((s: Server) => s.status === 'connected').length,\n disabled: allServers.filter((s: Server) => s.enabled === false).length,\n offline: allServers.filter(\n (s: Server) => s.status === 'disconnected' && s.enabled !== false,\n ).length,\n connecting: allServers.filter(\n (s: Server) =>\n (s.status === 'connecting' || s.status === 'oauth_required') && s.enabled !== false,\n ).length,\n tools: allServers.reduce((acc, s) => acc + (s.tools?.length || 0), 0),\n }),\n [allServers],\n );\n\n const footprint = useMemo(\n () => serverCosts.filter((c) => c.connected).reduce((acc, c) => acc + c.exposed, 0),\n [serverCosts],\n );\n\n const recentServers = useMemo(() => allServers.slice(0, 6), [allServers]);\n const baseUrl = installConfig?.baseUrl?.replace(/\\/+$/, '') || '';\n const recentServerColumns =\n 'minmax(220px,1.9fr) minmax(110px,0.95fr) minmax(120px,0.95fr) 80px 80px 90px 72px';\n\n const showSkeleton = !hasLoaded;\n\n return (\n <div>\n {/* Header */}\n <div className=\"flex items-end justify-between gap-4 mb-6\">\n <div>\n <h1 className=\"hub-h1\">{t('pages.dashboard.title')}</h1>\n <p className=\"hub-sub\">\n {t('pages.dashboard.totalServers')} · <span className=\"hub-num\">{stats.total}</span>\n {' · '}\n {t('pages.dashboard.onlineServers')} · <span className=\"hub-num\">{stats.online}</span>\n </p>\n </div>\n <div className=\"flex gap-2\">\n <button className=\"hub-btn\" onClick={() => triggerRefresh()}>\n <RefreshCw size={13} /> {t('common.refresh')}\n </button>\n <button className=\"hub-btn primary\" onClick={() => navigate('/servers')}>\n <Plus size={13} /> {t('server.add')}\n </button>\n </div>\n </div>\n\n {error && (\n <div\n className=\"hub-card flex items-center justify-between gap-3 mb-5\"\n style={{\n padding: '10px 14px',\n borderColor: 'oklch(0.85 0.1 25)',\n background: 'oklch(0.97 0.03 25)',\n color: 'oklch(0.4 0.18 25)',\n }}\n >\n <div className=\"flex items-center gap-2 min-w-0\">\n <AlertCircle size={14} className=\"flex-shrink-0\" />\n <span className=\"truncate text-[13px]\">{error}</span>\n </div>\n <button\n className=\"hub-icon-btn sm\"\n onClick={() => setError(null)}\n aria-label={t('app.closeButton')}\n >\n ✕\n </button>\n </div>\n )}\n\n {/* Stat row */}\n {showSkeleton ? (\n <div className=\"grid grid-cols-2 md:grid-cols-6 gap-3 mb-6\">\n {Array.from({ length: 6 }).map((_, i) => (\n <div\n key={i}\n className=\"hub-card animate-pulse\"\n style={{ padding: '14px 16px', height: 78 }}\n />\n ))}\n </div>\n ) : (\n <div className=\"grid grid-cols-2 md:grid-cols-6 gap-3 mb-6\">\n <Stat label={t('pages.dashboard.totalServers')} value={stats.total} />\n <Stat label={t('pages.dashboard.onlineServers')} value={stats.online} tone=\"ok\" />\n <Stat label={t('pages.dashboard.connectingServers')} value={stats.connecting} tone=\"warn\" />\n <Stat label={t('pages.dashboard.offlineServers')} value={stats.offline} tone=\"err\" />\n <Stat label={t('pages.dashboard.disabledServers')} value={stats.disabled} tone=\"muted\" />\n <Stat label={t('cost.totalFootprint')} value={formatTokens(footprint)} />\n </div>\n )}\n\n {/* Recent servers */}\n {allServers.length > 0 && !showSkeleton && (\n <div className=\"hub-card overflow-hidden mb-6\">\n <div\n className=\"flex items-center justify-between px-4 py-3\"\n style={{ borderBottom: '1px solid var(--hub-line-2)' }}\n >\n <h3 className=\"hub-card-title\">{t('pages.dashboard.recentServers')}</h3>\n <button\n className=\"hub-btn ghost sm\"\n style={{ color: 'var(--hub-ink-3)' }}\n onClick={() => navigate('/servers')}\n >\n {t('common.viewAll') || 'View all'}\n <ChevronRight size={12} />\n </button>\n </div>\n <div\n className=\"hub-row head hub-mono\"\n style={{ gridTemplateColumns: recentServerColumns }}\n >\n <div>{t('server.name')}</div>\n <div>{t('server.status')}</div>\n <div>{t('common.type') || 'Transport'}</div>\n <div>{t('server.tools')}</div>\n <div>{t('server.prompts')}</div>\n <div>{t('nav.resources')}</div>\n <div>{t('server.enabled')}</div>\n </div>\n {recentServers.map((s) => (\n <div\n key={s.name}\n className=\"hub-row hover cursor-pointer\"\n style={{ gridTemplateColumns: recentServerColumns }}\n onClick={() => navigate('/servers')}\n >\n <div className=\"flex items-center gap-2 min-w-0\">\n <span\n className=\"hub-mono truncate\"\n style={{ fontSize: 13, color: s.enabled === false ? 'var(--hub-ink-3)' : 'var(--hub-ink)' }}\n >\n {s.name}\n </span>\n {s.error && <AlertCircle size={13} className=\"text-[var(--hub-err)] flex-shrink-0\" />}\n </div>\n <div className=\"min-w-0\">\n <ServerStatusDot status={s.status} enabled={s.enabled} />\n </div>\n <div className=\"min-w-0\">\n {s.config?.type ? (\n <span className=\"hub-tag\" title={transportLabel(t, s.config.type) ?? undefined}>\n {transportLabel(t, s.config.type)}\n </span>\n ) : (\n <span style={{ color: 'var(--hub-ink-3)', fontSize: 12 }}>—</span>\n )}\n </div>\n <div className=\"hub-num hub-mono\" style={{ fontSize: 12.5 }}>\n {s.tools?.length || 0}\n </div>\n <div className=\"hub-num hub-mono\" style={{ fontSize: 12.5, color: 'var(--hub-ink-2)' }}>\n {s.prompts?.length || 0}\n </div>\n <div className=\"hub-num hub-mono\" style={{ fontSize: 12.5, color: 'var(--hub-ink-2)' }}>\n {s.resources?.length || 0}\n </div>\n <div className=\"text-[12px]\" style={{ color: s.enabled !== false ? 'var(--hub-ok)' : 'var(--hub-ink-3)' }}>\n {s.enabled !== false ? '✓' : '—'}\n </div>\n </div>\n ))}\n </div>\n )}\n\n {/* Endpoint quick-access */}\n <div className=\"hub-card mb-5\" style={{ padding: 16 }}>\n <div className=\"flex justify-between items-start gap-3 mb-3\">\n <div>\n <h3 className=\"hub-card-title\">{t('pages.dashboard.endpoints') || 'MCP Endpoints'}</h3>\n <p className=\"hub-sub\" style={{ marginTop: 2 }}>\n {t('pages.dashboard.endpointsHint') ||\n 'Use these URLs in Claude Desktop, Cursor, or any MCP client'}\n </p>\n </div>\n <a\n className=\"hub-btn ghost\"\n href=\"https://docs.mcphub.app\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n style={{ color: 'var(--hub-ink-3)' }}\n >\n {t('common.docs') || 'Docs'} →\n </a>\n </div>\n <div className=\"grid grid-cols-1 md:grid-cols-2 gap-2.5\">\n <EndpointCopy label=\"ALL\" url={`${baseUrl}/mcp`} />\n <EndpointCopy label=\"SMART\" url={`${baseUrl}/mcp/$smart`} />\n {groups.slice(0, 2).map((g) => (\n <EndpointCopy key={g.id} label=\"GROUP\" url={`${baseUrl}/mcp/${g.name}`} />\n ))}\n {/* Pad with first server endpoint if there's space */}\n {groups.length < 2 && allServers[0] && (\n <EndpointCopy label=\"SERVER\" url={`${baseUrl}/mcp/${allServers[0].name}`} />\n )}\n </div>\n </div>\n </div>\n );\n};\n\nexport default DashboardPage;\n"],"names":["Stat","label","value","tone","toneColor","jsxs","jsx","transportLabel","t","type","DashboardPage","useTranslation","navigate","useNavigate","allServers","error","setError","isLoading","triggerRefresh","useServerData","groups","useGroupData","installConfig","useSettingsData","serverCosts","useCostData","hasLoaded","setHasLoaded","React","loadingStartedRef","stats","useMemo","acc","s","_a","footprint","c","recentServers","baseUrl","recentServerColumns","showSkeleton","RefreshCw","Plus","AlertCircle","_","i","formatTokens","ChevronRight","ServerStatusDot","_b","_c","_d","EndpointCopy","g"],"mappings":"kdAaA,MAAMA,EAAgH,CAAC,CACrH,MAAAC,EACA,MAAAC,EACA,KAAAC,EAAO,SACT,IAAM,CACJ,MAAMC,EACJD,IAAS,KACL,sBACAA,IAAS,OACP,sBACAA,IAAS,MACP,sBACAA,IAAS,QACP,mBACA,iBACZ,OACEE,EAAAA,KAAC,OAAI,UAAU,WAAW,MAAO,CAAE,QAAS,aAC1C,SAAA,CAAAC,EAAAA,IAAC,MAAA,CAAI,UAAU,cAAc,MAAO,CAAE,MAAO,kBAAA,EAC1C,SAAAL,CAAA,CACH,EACAK,EAAAA,IAAC,MAAA,CACC,UAAU,UACV,MAAO,CACL,SAAU,GACV,WAAY,IACZ,cAAe,UACf,WAAY,IACZ,UAAW,EACX,MAAOF,CAAA,EAGR,SAAAF,CAAA,CAAA,CACH,EACF,CAEJ,EAEMK,EAAiB,CAACC,EAAQC,IACzBA,EACDA,IAAS,QAAgBD,EAAE,kBAAkB,GAAK,QAClDC,IAAS,MAAcD,EAAE,gBAAgB,GAAK,MAC9CC,IAAS,kBAA0BD,EAAE,2BAA2B,GAAK,OACrEC,IAAS,UAAkBD,EAAE,oBAAoB,GAAK,UACnDC,EALW,KAQdC,EAA0B,IAAM,OACpC,KAAM,CAAE,EAAAF,CAAA,EAAMG,EAAA,EACRC,EAAWC,EAAA,E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AAE,EAAE,2BAA2B,GAAK,gBAAgB,EAClFF,EAAAA,IAAC,IAAA,CAAE,UAAU,UAAU,MAAO,CAAE,UAAW,CAAA,EACxC,SAAAE,EAAE,+BAA+B,GAChC,6DAAA,CACJ,CAAA,EACF,EACAH,EAAAA,KAAC,IAAA,CACC,UAAU,gBACV,KAAK,0BACL,OAAO,SACP,IAAI,sBACJ,MAAO,CAAE,MAAO,kBAAA,EAEf,SAAA,CAAAG,EAAE,aAAa,GAAK,OAAO,IAAA,CAAA,CAAA,CAC9B,EACF,EACAH,EAAAA,KAAC,MAAA,CAAI,UAAU,0CACb,SAAA,CAAAC,MAAC8C,GAAa,MAAM,MAAM,IAAK,GAAGd,CAAO,OAAQ,QAChDc,EAAA,CAAa,MAAM,QAAQ,IAAK,GAAGd,CAAO,cAAe,EACzDlB,EAAO,MAAM,EAAG,CAAC,EAAE,IAAKiC,GACvB/C,EAAAA,IAAC8C,EAAA,CAAwB,MAAM,QAAQ,IAAK,GAAGd,CAAO,QAAQe,EAAE,IAAI,EAAA,EAAjDA,EAAE,EAAmD,CACzE,EAEAjC,EAAO,OAAS,GAAKN,EAAW,CAAC,SAC/BsC,EAAA,CAAa,MAAM,SAAS,IAAK,GAAGd,CAAO,QAAQxB,EAAW,CAAC,EAAE,IAAI,EAAA,CAAI,CAAA,CAAA,CAE9E,CAAA,CAAA,CACF,CAAA,EACF,CAEJ"}
1
+ {"version":3,"file":"Dashboard-Dh_39img.js","sources":["../../src/pages/Dashboard.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useNavigate } from 'react-router-dom';\nimport { RefreshCw, Plus, ChevronRight, AlertCircle } from 'lucide-react';\nimport { useServerData } from '@/hooks/useServerData';\nimport { useGroupData } from '@/hooks/useGroupData';\nimport { useSettingsData } from '@/hooks/useSettingsData';\nimport { useCostData } from '@/hooks/useCostData';\nimport { formatTokens } from '@/utils/contextCost';\nimport { Server } from '@/types';\nimport { EndpointCopy } from '@/components/ui/EndpointCopy';\nimport { ServerStatusDot } from '@/components/ui/StatusDot';\n\nconst Stat: React.FC<{ label: string; value: React.ReactNode; tone?: 'ok' | 'warn' | 'err' | 'muted' | 'default' }> = ({\n label,\n value,\n tone = 'default',\n}) => {\n const toneColor =\n tone === 'ok'\n ? 'oklch(0.4 0.13 145)'\n : tone === 'warn'\n ? 'oklch(0.45 0.13 80)'\n : tone === 'err'\n ? 'oklch(0.45 0.18 25)'\n : tone === 'muted'\n ? 'var(--hub-ink-3)'\n : 'var(--hub-ink)';\n return (\n <div className=\"hub-card\" style={{ padding: '14px 16px' }}>\n <div className=\"text-[12px]\" style={{ color: 'var(--hub-ink-3)' }}>\n {label}\n </div>\n <div\n className=\"hub-num\"\n style={{\n fontSize: 26,\n fontWeight: 500,\n letterSpacing: '-0.02em',\n lineHeight: 1.1,\n marginTop: 8,\n color: toneColor,\n }}\n >\n {value}\n </div>\n </div>\n );\n};\n\nconst transportLabel = (t: any, type?: string) => {\n if (!type) return null;\n if (type === 'stdio') return t('server.typeStdio') || 'stdio';\n if (type === 'sse') return t('server.typeSse') || 'sse';\n if (type === 'streamable-http') return t('server.typeStreamableHttp') || 'http';\n if (type === 'openapi') return t('server.typeOpenapi') || 'openapi';\n return type;\n};\n\nconst DashboardPage: React.FC = () => {\n const { t } = useTranslation();\n const navigate = useNavigate();\n const { allServers, error, setError, isLoading, triggerRefresh } = useServerData({\n refreshOnMount: true,\n });\n const { groups } = useGroupData();\n const { installConfig } = useSettingsData();\n const { serverCosts } = useCostData();\n\n const [hasLoaded, setHasLoaded] = React.useState(false);\n const loadingStartedRef = React.useRef(false);\n React.useEffect(() => {\n if (isLoading) {\n loadingStartedRef.current = true;\n return;\n }\n if (loadingStartedRef.current) {\n setHasLoaded(true);\n return;\n }\n if (allServers.length > 0 || error) setHasLoaded(true);\n }, [isLoading, allServers.length, error]);\n\n const stats = useMemo(\n () => ({\n total: allServers.length,\n online: allServers.filter((s: Server) => s.status === 'connected').length,\n disabled: allServers.filter((s: Server) => s.enabled === false).length,\n offline: allServers.filter(\n (s: Server) => s.status === 'disconnected' && s.enabled !== false,\n ).length,\n connecting: allServers.filter(\n (s: Server) =>\n (s.status === 'connecting' || s.status === 'oauth_required') && s.enabled !== false,\n ).length,\n tools: allServers.reduce((acc, s) => acc + (s.tools?.length || 0), 0),\n }),\n [allServers],\n );\n\n const footprint = useMemo(\n () => serverCosts.filter((c) => c.connected).reduce((acc, c) => acc + c.exposed, 0),\n [serverCosts],\n );\n\n const recentServers = useMemo(() => allServers.slice(0, 6), [allServers]);\n const baseUrl = installConfig?.baseUrl?.replace(/\\/+$/, '') || '';\n const recentServerColumns =\n 'minmax(220px,1.9fr) minmax(110px,0.95fr) minmax(120px,0.95fr) 80px 80px 90px 72px';\n\n const showSkeleton = !hasLoaded;\n\n return (\n <div>\n {/* Header */}\n <div className=\"flex items-end justify-between gap-4 mb-6\">\n <div>\n <h1 className=\"hub-h1\">{t('pages.dashboard.title')}</h1>\n <p className=\"hub-sub\">\n {t('pages.dashboard.totalServers')} · <span className=\"hub-num\">{stats.total}</span>\n {' · '}\n {t('pages.dashboard.onlineServers')} · <span className=\"hub-num\">{stats.online}</span>\n </p>\n </div>\n <div className=\"flex gap-2\">\n <button className=\"hub-btn\" onClick={() => triggerRefresh()}>\n <RefreshCw size={13} /> {t('common.refresh')}\n </button>\n <button className=\"hub-btn primary\" onClick={() => navigate('/servers')}>\n <Plus size={13} /> {t('server.add')}\n </button>\n </div>\n </div>\n\n {error && (\n <div\n className=\"hub-card flex items-center justify-between gap-3 mb-5\"\n style={{\n padding: '10px 14px',\n borderColor: 'oklch(0.85 0.1 25)',\n background: 'oklch(0.97 0.03 25)',\n color: 'oklch(0.4 0.18 25)',\n }}\n >\n <div className=\"flex items-center gap-2 min-w-0\">\n <AlertCircle size={14} className=\"flex-shrink-0\" />\n <span className=\"truncate text-[13px]\">{error}</span>\n </div>\n <button\n className=\"hub-icon-btn sm\"\n onClick={() => setError(null)}\n aria-label={t('app.closeButton')}\n >\n ✕\n </button>\n </div>\n )}\n\n {/* Stat row */}\n {showSkeleton ? (\n <div className=\"grid grid-cols-2 md:grid-cols-6 gap-3 mb-6\">\n {Array.from({ length: 6 }).map((_, i) => (\n <div\n key={i}\n className=\"hub-card animate-pulse\"\n style={{ padding: '14px 16px', height: 78 }}\n />\n ))}\n </div>\n ) : (\n <div className=\"grid grid-cols-2 md:grid-cols-6 gap-3 mb-6\">\n <Stat label={t('pages.dashboard.totalServers')} value={stats.total} />\n <Stat label={t('pages.dashboard.onlineServers')} value={stats.online} tone=\"ok\" />\n <Stat label={t('pages.dashboard.connectingServers')} value={stats.connecting} tone=\"warn\" />\n <Stat label={t('pages.dashboard.offlineServers')} value={stats.offline} tone=\"err\" />\n <Stat label={t('pages.dashboard.disabledServers')} value={stats.disabled} tone=\"muted\" />\n <Stat label={t('cost.totalFootprint')} value={formatTokens(footprint)} />\n </div>\n )}\n\n {/* Recent servers */}\n {allServers.length > 0 && !showSkeleton && (\n <div className=\"hub-card overflow-hidden mb-6\">\n <div\n className=\"flex items-center justify-between px-4 py-3\"\n style={{ borderBottom: '1px solid var(--hub-line-2)' }}\n >\n <h3 className=\"hub-card-title\">{t('pages.dashboard.recentServers')}</h3>\n <button\n className=\"hub-btn ghost sm\"\n style={{ color: 'var(--hub-ink-3)' }}\n onClick={() => navigate('/servers')}\n >\n {t('common.viewAll') || 'View all'}\n <ChevronRight size={12} />\n </button>\n </div>\n <div\n className=\"hub-row head hub-mono\"\n style={{ gridTemplateColumns: recentServerColumns }}\n >\n <div>{t('server.name')}</div>\n <div>{t('server.status')}</div>\n <div>{t('common.type') || 'Transport'}</div>\n <div>{t('server.tools')}</div>\n <div>{t('server.prompts')}</div>\n <div>{t('nav.resources')}</div>\n <div>{t('server.enabled')}</div>\n </div>\n {recentServers.map((s) => (\n <div\n key={s.name}\n className=\"hub-row hover cursor-pointer\"\n style={{ gridTemplateColumns: recentServerColumns }}\n onClick={() => navigate('/servers')}\n >\n <div className=\"flex items-center gap-2 min-w-0\">\n <span\n className=\"hub-mono truncate\"\n style={{ fontSize: 13, color: s.enabled === false ? 'var(--hub-ink-3)' : 'var(--hub-ink)' }}\n >\n {s.name}\n </span>\n {s.error && <AlertCircle size={13} className=\"text-[var(--hub-err)] flex-shrink-0\" />}\n </div>\n <div className=\"min-w-0\">\n <ServerStatusDot status={s.status} enabled={s.enabled} />\n </div>\n <div className=\"min-w-0\">\n {s.config?.type ? (\n <span className=\"hub-tag\" title={transportLabel(t, s.config.type) ?? undefined}>\n {transportLabel(t, s.config.type)}\n </span>\n ) : (\n <span style={{ color: 'var(--hub-ink-3)', fontSize: 12 }}>—</span>\n )}\n </div>\n <div className=\"hub-num hub-mono\" style={{ fontSize: 12.5 }}>\n {s.tools?.length || 0}\n </div>\n <div className=\"hub-num hub-mono\" style={{ fontSize: 12.5, color: 'var(--hub-ink-2)' }}>\n {s.prompts?.length || 0}\n </div>\n <div className=\"hub-num hub-mono\" style={{ fontSize: 12.5, color: 'var(--hub-ink-2)' }}>\n {s.resources?.length || 0}\n </div>\n <div className=\"text-[12px]\" style={{ color: s.enabled !== false ? 'var(--hub-ok)' : 'var(--hub-ink-3)' }}>\n {s.enabled !== false ? '✓' : '—'}\n </div>\n </div>\n ))}\n </div>\n )}\n\n {/* Endpoint quick-access */}\n <div className=\"hub-card mb-5\" style={{ padding: 16 }}>\n <div className=\"flex justify-between items-start gap-3 mb-3\">\n <div>\n <h3 className=\"hub-card-title\">{t('pages.dashboard.endpoints') || 'MCP Endpoints'}</h3>\n <p className=\"hub-sub\" style={{ marginTop: 2 }}>\n {t('pages.dashboard.endpointsHint') ||\n 'Use these URLs in Claude Desktop, Cursor, or any MCP client'}\n </p>\n </div>\n <a\n className=\"hub-btn ghost\"\n href=\"https://docs.mcphub.app\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n style={{ color: 'var(--hub-ink-3)' }}\n >\n {t('common.docs') || 'Docs'} →\n </a>\n </div>\n <div className=\"grid grid-cols-1 md:grid-cols-2 gap-2.5\">\n <EndpointCopy label=\"ALL\" url={`${baseUrl}/mcp`} />\n <EndpointCopy label=\"SMART\" url={`${baseUrl}/mcp/$smart`} />\n {groups.slice(0, 2).map((g) => (\n <EndpointCopy key={g.id} label=\"GROUP\" url={`${baseUrl}/mcp/${g.name}`} />\n ))}\n {/* Pad with first server endpoint if there's space */}\n {groups.length < 2 && allServers[0] && (\n <EndpointCopy label=\"SERVER\" url={`${baseUrl}/mcp/${allServers[0].name}`} />\n )}\n </div>\n </div>\n </div>\n );\n};\n\nexport default DashboardPage;\n"],"names":["Stat","label","value","tone","toneColor","jsxs","jsx","transportLabel","t","type","DashboardPage","useTranslation","navigate","useNavigate","allServers","error","setError","isLoading","triggerRefresh","useServerData","groups","useGroupData","installConfig","useSettingsData","serverCosts","useCostData","hasLoaded","setHasLoaded","React","loadingStartedRef","stats","useMemo","acc","s","_a","footprint","c","recentServers","baseUrl","recentServerColumns","showSkeleton","RefreshCw","Plus","AlertCircle","_","i","formatTokens","ChevronRight","ServerStatusDot","_b","_c","_d","EndpointCopy","g"],"mappings":"kfAaA,MAAMA,EAAgH,CAAC,CACrH,MAAAC,EACA,MAAAC,EACA,KAAAC,EAAO,SACT,IAAM,CACJ,MAAMC,EACJD,IAAS,KACL,sBACAA,IAAS,OACP,sBACAA,IAAS,MACP,sBACAA,IAAS,QACP,mBACA,iBACZ,OACEE,EAAAA,KAAC,OAAI,UAAU,WAAW,MAAO,CAAE,QAAS,aAC1C,SAAA,CAAAC,EAAAA,IAAC,MAAA,CAAI,UAAU,cAAc,MAAO,CAAE,MAAO,kBAAA,EAC1C,SAAAL,CAAA,CACH,EACAK,EAAAA,IAAC,MAAA,CACC,UAAU,UACV,MAAO,CACL,SAAU,GACV,WAAY,IACZ,cAAe,UACf,WAAY,IACZ,UAAW,EACX,MAAOF,CAAA,EAGR,SAAAF,CAAA,CAAA,CACH,EACF,CAEJ,EAEMK,EAAiB,CAACC,EAAQC,IACzBA,EACDA,IAAS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BukcCPLt.js";import{u as C}from"./i18n-vendor-BMaj5qV8.js";import{C as b,q as j}from"./icons-vendor-Bk5sng-h.js";const g=({url:s,label:e,prefix:a,className:r,copyValue:m,ariaLabel:l})=>{const{t}=C(),{showToast:c}=h(),[n,i]=y.useState(!1),d=async u=>{if(u.stopPropagation(),!await x(m??s)){c(t("common.copyFailed")||"Copy failed","error");return}i(!0),c(t("common.copySuccess")||"Copied to clipboard","success"),setTimeout(()=>i(!1),1200)};return o.jsxs("div",{className:p("hub-endpoint",r),role:"group","aria-label":l||s,children:[e&&o.jsx("div",{className:"hub-endpoint-label",children:e}),o.jsxs("div",{className:"hub-endpoint-url",title:s,children:[a&&o.jsx("span",{style:{color:"var(--hub-ink-3)"},children:a}),s]}),o.jsx("button",{type:"button",onClick:d,className:p("hub-endpoint-copy",n?"copied":""),title:t("common.copy")||"Copy","aria-label":t("common.copy")||"Copy",children:n?o.jsx(b,{size:13}):o.jsx(j,{size:13})})]})};export{g as E};
2
+ //# sourceMappingURL=EndpointCopy-CQmwGXbD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EndpointCopy-CQmwGXbD.js","sources":["../../src/components/ui/EndpointCopy.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Copy, Check } from 'lucide-react';\nimport { useTranslation } from 'react-i18next';\nimport { useToast } from '@/contexts/ToastContext';\nimport { copyText } from '@/utils/clipboard';\nimport { cn } from '@/utils/cn';\n\ninterface EndpointCopyProps {\n url: string;\n label?: string;\n prefix?: string;\n className?: string;\n /** Optionally override the value placed on the clipboard. */\n copyValue?: string;\n ariaLabel?: string;\n}\n\nexport const EndpointCopy: React.FC<EndpointCopyProps> = ({\n url,\n label,\n prefix,\n className,\n copyValue,\n ariaLabel,\n}) => {\n const { t } = useTranslation();\n const { showToast } = useToast();\n const [copied, setCopied] = useState(false);\n\n const onCopy = async (e: React.MouseEvent) => {\n e.stopPropagation();\n const ok = await copyText(copyValue ?? url);\n if (!ok) {\n showToast(t('common.copyFailed') || 'Copy failed', 'error');\n return;\n }\n setCopied(true);\n showToast(t('common.copySuccess') || 'Copied to clipboard', 'success');\n setTimeout(() => setCopied(false), 1200);\n };\n\n return (\n <div className={cn('hub-endpoint', className)} role=\"group\" aria-label={ariaLabel || url}>\n {label && <div className=\"hub-endpoint-label\">{label}</div>}\n <div className=\"hub-endpoint-url\" title={url}>\n {prefix && <span style={{ color: 'var(--hub-ink-3)' }}>{prefix}</span>}\n {url}\n </div>\n <button\n type=\"button\"\n onClick={onCopy}\n className={cn('hub-endpoint-copy', copied ? 'copied' : '')}\n title={t('common.copy') || 'Copy'}\n aria-label={t('common.copy') || 'Copy'}\n >\n {copied ? <Check size={13} /> : <Copy size={13} />}\n </button>\n </div>\n );\n};\n\ninterface MonoCopyProps {\n text: string;\n className?: string;\n copyValue?: string;\n title?: string;\n}\n\n/** Inline monospace value with hover-to-copy icon. */\nexport const MonoCopy: React.FC<MonoCopyProps> = ({ text, className, copyValue, title }) => {\n const { t } = useTranslation();\n const { showToast } = useToast();\n const [copied, setCopied] = useState(false);\n\n const onCopy = async (e: React.MouseEvent) => {\n e.stopPropagation();\n const ok = await copyText(copyValue ?? text);\n if (!ok) {\n showToast(t('common.copyFailed') || 'Copy failed', 'error');\n return;\n }\n setCopied(true);\n showToast(t('common.copySuccess') || 'Copied to clipboard', 'success');\n setTimeout(() => setCopied(false), 1200);\n };\n\n return (\n <span\n className={cn(\n 'hub-mono inline-flex items-center gap-1.5 group cursor-pointer text-[12.5px]',\n className,\n )}\n onClick={onCopy}\n title={title || text}\n role=\"button\"\n >\n <span className=\"truncate\">{text}</span>\n {copied ? (\n <Check size={12} className=\"text-[var(--hub-ok)] flex-shrink-0\" />\n ) : (\n <Copy\n size={12}\n className=\"text-[var(--hub-ink-3)] opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0\"\n />\n )}\n </span>\n );\n};\n"],"names":["EndpointCopy","url","label","prefix","className","copyValue","ariaLabel","useTranslation","showToast","useToast","copied","setCopied","useState","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27Pfc.js";import{m as re,e as pe,d as Y,u as xe,j as he,i as Z}from"./index-DhzWX9nb.js";import{u as Q,a as ee}from"./useCostData-B-uSfiuA.js";import{u as oe}from"./useSettingsData-Bk1AwN5F.js";import{f as W,p as be}from"./contextCost-CilWqGWT.js";import{g as ge,A as fe,C as ye}from"./CopyClientConfigDialog-DYiucK0d.js";import{u as O}from"./i18n-vendor-BMaj5qV8.js";import{W as ve,g as je,F as Ne,C as ke,q as _,H as ae,z as Se,w as we,T as Ce,u as Ae,D as le,J as Ee,P as ne,l as De,X as Ie}from"./icons-vendor-Bk5sng-h.js";import{D as ze}from"./DeleteDialog-BYhrMGZo.js";import{c as Te}from"./clipboard-BukcCPLt.js";const Fe={tools:[],prompts:[],resources:[]},ie={tools:"all",prompts:"all",resources:"all"},ce=({servers:i,value:h,onChange:s,className:n,serverCosts:v=[]})=>{const{t:o}=O(),{nameSeparator:f}=oe(),[E,D]=x.useState(new Set),m=K.useMemo(()=>h.map(t=>typeof t=="string"?{name:t,...ie}:{...t,tools:t.tools||"all",prompts:t.prompts||"all",resources:t.resources||"all"}),[h]),S=K.useMemo(()=>i.filter(t=>t.enabled!==!1),[i]);K.useEffect(()=>{const t=new Set(m.map(r=>r.name)),l=new Set(S.map(r=>r.name));D(r=>{const g=new Set;return r.forEach(y=>{(t.has(y)||l.has(y))&&g.add(y)}),g})},[m,S]);const w=t=>{if(m.findIndex(r=>r.name===t)>=0){const r=m.filter(g=>g.name!==t);s(r)}else{const r=[...m,{name:t,...ie}];s(r)}},A=t=>{D(l=>{const r=new Set(l);return r.has(t)?r.delete(t):r.add(t),r})},j=t=>["tools","prompts","resources"].some(l=>{const r=t[l];return r==="all"||Array.isArray(r)&&r.length>0}),C=(t,l,r,g=!1)=>{const y=m.find(I=>I.name===t),z={...y?{...y}:{name:t,...Fe},[l]:r};if(!j(z)){const I=m.filter(k=>k.name!==t);s(I),g||D(k=>{const G=new Set(k);return G.delete(t),G});return}if(y){s(m.map(I=>I.name===t?z:I));return}s([...m,z])},d=(t,l)=>{const r=m.find(y=>y.name===t);if(!r)return;const g={...r};l?g.alias=l:delete g.alias,s(m.map(y=>y.name===t?g:y))},b=(t,l)=>{const r=`${t}${f}`;return l.startsWith(r)?l.slice(r.length):l},p=(t,l)=>l==="tools"?(t.tools||[]).filter(r=>r.enabled!==!1).map(r=>({key:r.name,value:b(t.name,r.name),description:r.description,defaultDescription:r.defaultDescription,hasDescriptionOverride:r.hasDescriptionOverride})):l==="prompts"?(t.prompts||[]).filter(r=>r.enabled!==!1).map(r=>({key:r.name,value:b(t.name,r.name),description:r.description})):(t.resources||[]).filter(r=>r.enabled!==!1).map(r=>({key:r.uri,value:r.uri,description:r.description})),a=K.useMemo(()=>{const t=new Map;return v.forEach(l=>{const r=new Map;l.items.forEach(g=>r.set(g.name,g.cost)),t.set(l.name,r)}),t},[v]),c=t=>a.get(t)??new Map,u=(t,l)=>{const r=c(t.name);return p(t,l).filter(g=>H(t.name,l,g.value)).reduce((g,y)=>g+(r.get(y.key)??0),0)},N=t=>["tools","prompts","resources"].reduce((l,r)=>l+u(t,r),0),T=(t,l,r)=>{const g=S.find(I=>I.name===t);if(!g)return;const y=p(g,l).map(I=>I.value),R=m.find(I=>I.name===t);if(!R){C(t,l,[r]);return}const z=R[l];if(z==="all"){const I=y.filter(k=>k!==r);C(t,l,I);return}if(Array.isArray(z)){if(z.includes(r)){C(t,l,z.filter(k=>k!==r));return}const I=[...z,r];C(t,l,I.length===y.length?"all":I);return}C(t,l,[r])},$=t=>{const l=m.find(r=>r.name===t);return!!(l&&j(l))},q=t=>{const l=m.find(r=>r.name===t);return l?["tools","prompts","resources"].some(r=>{const g=l[r];return Array.isArray(g)&&g.length>0}):!1},H=(t,l,r)=>{const g=m.find(R=>R.name===t);if(!g)return!1;const y=g[l];return y==="all"?!0:Array.isArray(y)?y.includes(r):!1},L=(t,l)=>{const r=m.find(R=>R.name===t.name);if(!r)return 0;const g=p(t,l),y=r[l];if(y==="all")return g.length;if(Array.isArray(y)){const R=new Set(g.map(z=>z.value));return y.filter(z=>R.has(z)).length}return 0},M=[{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"}],J=t=>M.map(({key:l})=>({key:l,count:L(t,l)})).filter(l=>l.count>0);return e.jsxs("div",{className:re("space-y-4",n),children:[e.jsx("div",{className:"space-y-3",children:S.map(t=>{const l=$(t.name),r=q(t.name),g=E.has(t.name),y=m.find(k=>k.name===t.name),R=J(t),z=M.filter(({key:k})=>p(t,k).length>0),I=c(t.name);return e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg hover:border-gray-300 hover:bg-gray-50 dark:bg-gray-800 dark:hover:bg-gray-700 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 cursor-pointer rounded-lg transition-colors",onClick:()=>A(t.name),children:[e.jsxs("div",{className:"flex items-center space-x-3",onClick:k=>{k.stopPropagation(),w(t.name)},children:[e.jsx("input",{type:"checkbox",checked:l||r,onChange:()=>w(t.name),className:"w-4 h-4 text-blue-600 bg-gray-100 dark:bg-gray-800 border-gray-300 rounded focus:ring-blue-500"}),e.jsx("span",{className:"font-medium text-gray-900 cursor-pointer select-none",children:t.name})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[N(t)>0&&e.jsxs("span",{className:"text-sm text-gray-400 hub-mono",title:o("cost.estimate"),children:["Σ ",W(N(t))]}),R.map(({key:k,count:G})=>e.jsxs("span",{className:"text-sm text-green-600 flex items-center gap-1",children:[k==="tools"?e.jsx(ve,{size:14}):k==="prompts"?e.jsx(je,{size:14}):e.jsx(Ne,{size:14})," ",G]},k)),z.length>0&&e.jsx("button",{type:"button",className:"p-1 text-gray-400 hover:text-gray-600 transition-colors",children:e.jsx("svg",{className:re("w-5 h-5 transition-transform",g&&"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"})})})]})]}),g&&z.length>0&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 p-3",children:e.jsxs("div",{className:"space-y-4",children:[y&&e.jsxs("div",{className:"space-y-1",onClick:k=>k.stopPropagation(),children:[e.jsx("label",{className:"block text-xs font-medium text-gray-600",children:o("groups.alias")}),e.jsx("input",{type:"text",value:y.alias||"",placeholder:t.name,onChange:k=>d(t.name,k.target.value),className:"w-full rounded-md border border-gray-300 bg-white px-2.5 py-1.5 text-sm text-gray-800 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-100"})]}),z.map(({key:k,titleKey:G,countKey:F,allKey:B})=>{const V=p(t,k),se=L(t,k),X=(y==null?void 0:y[k])==="all"||se===V.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-gray-700",children:o(G)}),e.jsxs("div",{className:"flex items-center gap-3",children:[y&&e.jsx("span",{className:"text-xs text-green-600",children:X?`(${o(B)} ${V.length}/${V.length})`:`(${o(F)} ${se}/${V.length})`}),y&&u(t,k)>0&&e.jsxs("span",{className:"text-xs text-gray-400 hub-mono",title:o("cost.estimate"),children:["Σ ",W(u(t,k))]}),e.jsx("button",{type:"button",onClick:()=>{C(t.name,k,X?[]:"all",!0)},className:"text-sm text-blue-600 hover:text-blue-800 transition-colors",children:o(X?"groups.selectNone":"groups.selectAll")})]})]}),e.jsx("div",{className:"grid grid-cols-1 gap-2 max-h-32 overflow-y-auto",children:V.map(P=>{const ue=H(t.name,k,P.value),U=k==="tools"?ge({description:P.description,defaultDescription:P.defaultDescription,hasDescriptionOverride:P.hasDescriptionOverride},o("tool.noDescription")):null,te=U!=null&&U.hasDescriptionOverride?o("tool.defaultDescriptionTooltip",{description:U.defaultDescription}):P.description;return e.jsxs("label",{className:"flex min-w-0 items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:ue,onChange:()=>T(t.name,k,P.value),className:"w-3 h-3 text-blue-600 bg-gray-100 dark:bg-gray-800 border-gray-300 rounded focus:ring-blue-500"}),e.jsx("span",{className:"text-gray-700 break-all whitespace-nowrap flex-shrink-0",children:P.value}),(P.description||(U==null?void 0:U.hasDescriptionOverride))&&e.jsxs("span",{className:"min-w-0 flex items-center gap-1 text-gray-400 text-xs truncate",children:[e.jsx("span",{className:"truncate",title:te||void 0,children:U?U.currentDescription:P.description}),(U==null?void 0:U.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:te||void 0,children:o("tool.descriptionModifiedBadge")})]}),I.get(P.key)!=null&&e.jsxs("span",{className:"text-xs text-gray-400 hub-mono whitespace-nowrap ml-auto flex-shrink-0",title:o("cost.estimate"),children:["Σ ",W(I.get(P.key))]})]},P.key)})})]},k)})]})})]},t.name)})}),S.length===0&&e.jsx("p",{className:"text-gray-500 text-sm",children:o("groups.noServerOptions")})]})};function de({groupId:i,value:h,onChange:s}){const{t:n}=O(),[v,o]=x.useState([]),[f,E]=x.useState(""),[D,m]=x.useState(!1),[S,w]=x.useState(!1),[A,j]=x.useState(!1);x.useEffect(()=>{if(!i||h.visibility!=="group")return;let u=!1;return m(!0),w(!1),pe(`/groups/${encodeURIComponent(i)}/share-candidates`).then(N=>{u||(N.success&&Array.isArray(N.data)?o(N.data):w(!0))}).catch(()=>{u||w(!0)}).finally(()=>{u||m(!1)}),()=>{u=!0}},[i,h.visibility]);const C=h.sharedWithUsers||[],d=[...new Set([...v,...C])].sort().filter(u=>u.toLowerCase().includes(f.toLowerCase())),b=new Set(C),p=d.length>0&&d.every(u=>b.has(u)),a=d.length===0||d.every(u=>!b.has(u)),c=u=>{const N=new Set(C);N.has(u)?N.delete(u):N.add(u),s({sharedWithUsers:Array.from(N)})};return e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 p-3 rounded border border-gray-200 dark:border-gray-700",onClick:()=>j(!A),children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--hub-ink)]",children:n("server.sectionAdvanced","Advanced Options")}),e.jsx("span",{className:"text-gray-500 text-sm",children:A?"▼":"▶"})]}),A&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-b p-4 bg-white dark:bg-gray-900 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:n("server.visibility")}),e.jsxs("select",{id:"group-visibility",className:"w-full py-2 px-3 form-input",value:h.visibility||"",onChange:u=>s({visibility:u.target.value}),children:[!h.visibility&&e.jsx("option",{value:"",disabled:!0,children:n("groups.legacyVisibility")}),e.jsx("option",{value:"private",children:n("server.visibilityPrivate")}),e.jsx("option",{value:"group",children:n("server.visibilityGroup")}),e.jsx("option",{value:"public",children:n("server.visibilityPublic")})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:n("groups.visibilityDescription")}),!h.visibility&&e.jsx("p",{className:"text-sm text-amber-600",children:n("groups.legacyVisibilityHint")}),h.visibility==="group"&&e.jsxs("div",{className:"mt-4 rounded border border-gray-200 dark:border-gray-700 p-3",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--hub-ink-2)]",children:n("server.shareWithUsers")}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 mb-3",children:n("server.shareWithUsersDescription")}),i?e.jsxs(e.Fragment,{children:[D&&e.jsx("p",{className:"text-sm text-gray-500",children:n("server.shareCandidatesLoading")}),S&&e.jsx("p",{role:"alert",className:"text-sm text-red-600 dark:text-red-400",children:n("server.shareCandidatesError")}),!D&&!S&&d.length===0&&e.jsx("p",{className:"text-sm text-gray-500",children:n(f?"server.noMatchingShareUsers":"server.noShareCandidates")}),d.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:n("server.shareUserSearchLabel")}),e.jsx("input",{id:"group-share-search",type:"search",value:f,onChange:u=>E(u.target.value),placeholder:n("server.shareUserSearchPlaceholder"),className:"w-full py-2 px-3 form-input text-sm"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>s({sharedWithUsers:[...new Set([...C,...d])]}),disabled:p,className:"hub-btn text-sm",children:n("server.selectAllShareUsers")}),e.jsx("button",{type:"button",onClick:()=>s({sharedWithUsers:C.filter(u=>!d.includes(u))}),disabled:a,className:"hub-btn text-sm",children:n("server.deselectAllShareUsers")})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:d.map(u=>e.jsxs("label",{className:"flex items-center gap-2 rounded border border-gray-200 dark:border-gray-700 px-3 py-2 text-sm text-[var(--hub-ink-2)]",children:[e.jsx("input",{type:"checkbox",checked:b.has(u),onChange:()=>c(u)}),e.jsx("span",{children:u})]},u))})]})]}):e.jsx("p",{className:"text-sm text-gray-500",children:n("groups.shareAfterCreate")})]})]})]})}const Re=({onAdd:i,onCancel:h})=>{const{t:s}=O(),{createGroup:n}=Y(),{allServers:v}=Q(),{serverCosts:o}=ee(),[f,E]=x.useState([]),[D,m]=x.useState(null),[S,w]=x.useState(!1),[A,j]=x.useState({visibility:"private",sharedWithUsers:[],name:"",description:"",servers:[]});x.useEffect(()=>{E(v.filter(b=>b.enabled!==!1))},[v]);const C=b=>{const{name:p,value:a}=b.target;j(c=>({...c,[p]:a}))},d=async b=>{b.preventDefault(),w(!0),m(null);try{if(!A.name.trim()){m(s("groups.nameRequired")),w(!1);return}const p=await n(A.name,A.description,A.servers,{visibility:A.visibility,sharedWithUsers:A.sharedWithUsers});if(!p||!p.success){m((p==null?void 0:p.message)||s("groups.createError")),w(!1);return}i()}catch(p){m(p instanceof Error?p.message:String(p)),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 rounded-lg 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-gray-800 mb-4",children:s("groups.addNew")}),D&&e.jsx("div",{className:"mb-4 p-3 bg-red-100 text-red-700 rounded-md border border-gray-200 dark:border-gray-700",children:D})]}),e.jsxs("form",{onSubmit:d,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-gray-700 text-sm font-bold mb-2",htmlFor:"name",children:[s("groups.name")," *"]}),e.jsx("input",{type:"text",id:"name",name:"name",value:A.name,onChange:C,className:"w-full border border-gray-300 rounded-md px-3 py-2 text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:s("groups.namePlaceholder"),required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",children:s("groups.configureCapabilities")}),e.jsx(ce,{servers:f,value:A.servers,onChange:b=>j(p=>({...p,servers:b})),className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4 bg-gray-50 dark:bg-gray-800",serverCosts:o})]}),e.jsx(de,{value:A,onChange:b=>j(p=>({...p,...b}))})]})}),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:h,className:"hub-btn",disabled:S,children:s("common.cancel")}),e.jsx("button",{type:"submit",className:"hub-btn primary",disabled:S,children:s(S?"common.submitting":"common.create")})]})]})]})})},Pe=({group:i,onEdit:h,onCancel:s})=>{const{t:n}=O(),{updateGroup:v}=Y(),{allServers:o}=Q(),{serverCosts:f}=ee(),[E,D]=x.useState([]),[m,S]=x.useState(null),[w,A]=x.useState(!1),[j,C]=x.useState({visibility:i.visibility,sharedWithUsers:i.sharedWithUsers||[],name:i.name,description:i.description||"",servers:i.servers||[]});x.useEffect(()=>{D(o.filter(p=>p.enabled!==!1))},[o]);const d=p=>{const{name:a,value:c}=p.target;C(u=>({...u,[a]:c}))},b=async p=>{p.preventDefault(),A(!0),S(null);try{if(!j.name.trim()){S(n("groups.nameRequired")),A(!1);return}const a=await v(i.id,{visibility:j.visibility,sharedWithUsers:j.sharedWithUsers,name:j.name,description:j.description,servers:j.servers});if(!a||!a.success){S((a==null?void 0:a.message)||n("groups.updateError")),A(!1);return}h()}catch(a){S(a instanceof Error?a.message:String(a)),A(!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 rounded-lg 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-gray-800 mb-4",children:n("groups.edit")}),m&&e.jsx("div",{className:"mb-4 p-3 bg-red-100 text-red-700 rounded-md border border-gray-200 dark:border-gray-700",children:m})]}),e.jsxs("form",{onSubmit:b,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-gray-700 text-sm font-bold mb-2",htmlFor:"name",children:[n("groups.name")," *"]}),e.jsx("input",{type:"text",id:"name",name:"name",value:j.name,onChange:d,className:"w-full border border-gray-300 rounded-md px-3 py-2 text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:n("groups.namePlaceholder"),required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",children:n("groups.configureCapabilities")}),e.jsx(ce,{servers:E,value:j.servers,onChange:p=>C(a=>({...a,servers:p})),className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4 bg-gray-50 dark:bg-gray-800",serverCosts:f})]}),e.jsx(de,{groupId:i.id,value:j,onChange:p=>C(a=>({...a,...p}))})]})}),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:w,children:n("common.cancel")}),e.jsx("button",{type:"submit",className:"hub-btn primary",disabled:w,children:n(w?"common.submitting":"common.save")})]})]})]})})},Ue=i=>i.map(h=>typeof h=="string"?h:h.name),me=(i,h)=>{const s=i.servers.find(n=>typeof n=="string"?n===h:n.name===h);return s?typeof s=="string"?{name:s,tools:"all",prompts:"all",resources:"all"}:s:{name:h,tools:"all",prompts:"all",resources:"all"}},Le=(i,h)=>{var n;return((n=me(i,h).alias)==null?void 0:n.trim())||h},Oe=({group:i,servers:h,onEdit:s,onDelete:n,cost:v})=>{var t;const{t:o}=O(),{auth:f}=xe(),E=!!f.user&&(f.user.isAdmin||f.user.username===i.owner),{showToast:D}=he(),{installConfig:m,nameSeparator:S}=oe(),w=((t=m==null?void 0:m.baseUrl)==null?void 0:t.replace(/\/+$/,""))||"",[A,j]=x.useState(!1),[C,d]=x.useState(null),[b,p]=x.useState(!1),[a,c]=x.useState(!1),u=x.useRef(null);x.useEffect(()=>{const l=r=>{u.current&&!u.current.contains(r.target)&&c(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[]);const N=async l=>{await Te(l)?(p(!0),c(!1),D(o("common.copySuccess")||"Copied","success"),setTimeout(()=>p(!1),1500)):D(o("common.copyFailed")||"Copy failed","error")},T=`${w}/mcp/${i.name}`,$=`${w}/mcp/${encodeURIComponent(i.name)}`,q=`${w}/api/${i.name}`,H=Ue(i.servers),L=h.filter(l=>H.includes(l.name)),M=l=>{const r=me(i,l.name),g=`${l.name}${S}`,y=l.tools||[],R=l.prompts||[],z=l.resources||[],I=Array.isArray(r.tools)?y.filter(F=>{if(F.enabled===!1)return!1;const B=F.name.startsWith(g)?F.name.slice(g.length):F.name;return r.tools.includes(B)}).length:y.filter(F=>F.enabled!==!1).length,k=Array.isArray(r.prompts)?R.filter(F=>{if(F.enabled===!1)return!1;const B=F.name.startsWith(g)?F.name.slice(g.length):F.name;return r.prompts.includes(B)}).length:R.filter(F=>F.enabled!==!1).length,G=Array.isArray(r.resources)?z.filter(F=>F.enabled!==!1&&r.resources.includes(F.uri)).length:z.filter(F=>F.enabled!==!1).length;return{visibleTools:I,totalTools:y.length,visiblePrompts:k,totalPrompts:R.length,visibleResources:G,totalResources:z.length}},J=L.reduce((l,r)=>l+M(r).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:i.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:i.id,children:i.id})]}),e.jsx("div",{className:"mt-1 text-xs text-[var(--hub-ink-3)]",children:i.visibility?o(`server.visibility${i.visibility==="group"?"Group":i.visibility==="public"?"Public":"Private"}`):o("groups.legacyVisibility")}),i.description&&e.jsx("div",{style:{fontSize:12.5,color:"var(--hub-ink-3)",marginTop:2},children:i.description})]}),e.jsxs("div",{className:"flex items-center gap-1",ref:u,children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>c(l=>!l),className:"hub-icon-btn sm",title:o("common.copy"),children:b?e.jsx(ke,{size:13,className:"text-[var(--hub-ok)]"}):e.jsx(_,{size:13})}),a&&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:()=>N(i.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(_,{size:12})," ",o("common.copyId")]}),e.jsxs("button",{onClick:()=>N(T),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(ae,{size:12})," ",o("common.copyUrl")]}),e.jsxs("button",{onClick:()=>N(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(ae,{size:12})," ",o("common.copyOpenApiUrl")]}),e.jsxs("button",{onClick:()=>{c(!1),d({name:i.name,url:$,headers:{Authorization:`Bearer ${fe}`}})},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(Se,{size:12})," ",o("clientConfig.menuItem")]})]})]}),E&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>s(i),className:"hub-icon-btn sm",title:o("groups.edit"),children:e.jsx(we,{size:13})}),e.jsx("button",{onClick:()=>j(!0),className:"hub-icon-btn sm",title:o("groups.delete"),style:{color:"var(--hub-ink-3)"},children:e.jsx(Ce,{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:L.length===0?e.jsx("div",{style:{fontSize:12,color:"var(--hub-ink-3)"},children:o("groups.noServers")}):L.map(l=>{const r=M(l);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:l.status==="connected"?"var(--hub-ok)":l.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:l.name,children:Le(i,l.name)})}),e.jsxs("span",{className:"hub-mono hub-num flex-shrink-0",style:{fontSize:11,color:"var(--hub-ink-3)"},children:[r.visibleTools,"/",r.totalTools," tools"]})]},l.name)})}),e.jsxs("svg",{width:"80",height:"80",viewBox:"0 0 80 80",className:"self-center",children:[L.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"}):L.map((l,r)=>{const g=12+60/Math.max(L.length,1)*(r+.5);return e.jsx("path",{d:`M0,${g} C 30,${g} 50,40 80,40`,stroke:"var(--hub-line)",strokeWidth:"1",fill:"none",strokeDasharray:"3 3"},r)}),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:i.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:i.name})]}),e.jsxs("div",{className:"flex gap-1.5 mt-2",children:[e.jsxs("button",{className:"hub-btn sm flex-1 justify-center",onClick:()=>N(T),title:o("common.copyUrl"),children:[e.jsx(_,{size:11})," MCP"]}),e.jsxs("button",{className:"hub-btn sm flex-1 justify-center",onClick:()=>N(q),title:o("common.copyOpenApiUrl"),children:[e.jsx(_,{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:L.length})," ",o("nav.servers").toLowerCase()," ·"," ",e.jsx("span",{style:{color:"var(--hub-ink-2)"},children:J})," ",o("server.tools").toLowerCase()]}),v&&e.jsxs("div",{className:"hub-mono mt-1",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:[e.jsxs("div",{title:o("cost.estimate"),children:[o("cost.totalFootprint"),": ",W(v.direct.exposed),"/",W(v.direct.gross)]}),v.smartRouting&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[o("cost.smartRouting"),": ",W(v.smartRouting.base)," (",o("cost.saved",{percent:be(v.direct.exposed,v.smartRouting.base)}),")"]}),e.jsxs("div",{title:o("cost.smartRoutingPdHint"),children:[o("cost.smartRoutingPd"),":"," ",W(v.smartRouting.progressiveDisclosure)]})]}),v.connectedCount<v.totalCount&&e.jsx("div",{children:o("cost.connectedOf",{connected:v.connectedCount,total:v.totalCount})})]})]}),E&&e.jsxs("button",{className:"hub-btn ghost sm",style:{color:"var(--hub-ink-3)"},onClick:()=>s(i),children:[o("groups.configureTools")||o("groups.edit"),e.jsx(Ae,{size:11,style:{transform:"rotate(-90deg)"}})]})]}),e.jsx(ye,{isOpen:C!==null,target:C,onClose:()=>d(null)}),e.jsx(ze,{isOpen:A,onClose:()=>j(!1),onConfirm:()=>{n(i.id),j(!1)},serverName:i.name,isGroup:!0})]})},$e=({onSuccess:i,onCancel:h})=>{const{t:s}=O(),[n,v]=x.useState(""),[o,f]=x.useState(null),[E,D]=x.useState(!1),[m,S]=x.useState(null),w=`{
2
+ "groups": [
3
+ {
4
+ "name": "AI Assistants",
5
+ "servers": ["openai-server", "anthropic-server"]
6
+ },
7
+ {
8
+ "name": "Development Tools",
9
+ "servers": [
10
+ {
11
+ "name": "github-server",
12
+ "tools": ["create_issue", "list_repos"],
13
+ "prompts": ["triage_prompt"],
14
+ "resources": ["resource://docs/repo-guide"]
15
+ },
16
+ {
17
+ "name": "gitlab-server",
18
+ "tools": "all",
19
+ "prompts": "all",
20
+ "resources": "all"
21
+ }
22
+ ]
23
+ }
24
+ ]
25
+ }
26
+
27
+ Supports:
28
+ - Simple server list: ["server1", "server2"]
29
+ - Advanced server config: [{"name": "server1", "tools": ["tool1"], "prompts": ["prompt1"], "resources": ["resource://docs/guide"]}]
30
+ - All groups will be imported in a single efficient batch operation.`,A=a=>{try{const c=JSON.parse(a.trim());if(!c.groups||!Array.isArray(c.groups))return f(s("groupImport.invalidFormat")),null;for(const u of c.groups)if(!u.name||typeof u.name!="string")return f(s("groupImport.missingName")),null;return c}catch{return f(s("groupImport.parseError")),null}},j=()=>{f(null);const a=A(n);a&&S(a.groups)},C=async()=>{if(m){D(!0),f(null);try{const a=await Z("/groups/batch",{groups:m});if(a.success){const{successCount:c,failureCount:u,results:N}=a;if(u>0){const T=N.filter($=>!$.success).map($=>`${$.name}: ${$.message||s("groupImport.addFailed")}`);f(s("groupImport.partialSuccess",{count:c,total:m.length})+`
31
+ `+T.join(`
32
+ `))}c>0&&i()}else f(a.message||s("groupImport.importFailed"))}catch(a){console.error("Import error:",a),f(s("groupImport.importFailed"))}finally{D(!1)}}},d=a=>e.jsx("span",{className:"text-gray-500 ml-2",children:s(`groups.${a}`)}),b=(a,c)=>{if(!c||c==="all")return null;const u=Array.isArray(c)?c.join(", "):c;return e.jsx("span",{className:"text-gray-500 ml-2",children:s(`groups.${a}`,{items:u})})},p=a=>!a||a.length===0?e.jsx("span",{className:"text-gray-500",children:s("groups.noServers")}):e.jsx("div",{className:"space-y-1",children:a.map((c,u)=>typeof c=="string"?e.jsxs("div",{className:"text-sm",children:["• ",c]},u):e.jsxs("div",{className:"text-sm",children:["• ",c.name,c.tools&&c.tools!=="all"&&e.jsxs("span",{className:"text-gray-500 ml-2",children:["(",Array.isArray(c.tools)?c.tools.join(", "):c.tools,")"]}),c.tools==="all"&&d("previewAllTools"),b("previewPrompts",c.prompts),c.prompts==="all"&&d("previewAllPrompts"),b("previewResources",c.resources),c.resources==="all"&&d("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:h,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),o&&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:o})}),m?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:m.map((a,c)=>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:a.name}),a.description&&e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:a.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:p(a.servers)})]})]})})},c))})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:()=>S(null),disabled:E,className:"hub-btn",children:s("common.back")}),e.jsx("button",{onClick:C,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:n,onChange:a=>v(a.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:w}),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:h,className:"hub-btn",children:s("common.cancel")}),e.jsx("button",{onClick:j,disabled:!n.trim(),className:"hub-btn primary",children:s("groupImport.preview")})]})]})]})})},Ge=({groups:i,onCancel:h})=>{const{t:s}=O(),[n,v]=x.useState(""),[o,f]=x.useState(""),[E,D]=x.useState([]),[m,S]=x.useState(!1),[w,A]=x.useState(!1),[j,C]=x.useState(null),d=a=>{D(c=>c.includes(a)?c.filter(u=>u!==a):[...c,a])},b=()=>{E.length===i.length?D([]):D(i.map(a=>a.id))},p=async()=>{if(!n.trim()){C(s("template.nameRequired"));return}A(!0),C(null);try{const a=await Z("/templates/export",{name:n.trim(),description:o.trim()||void 0,groupIds:E.length>0?E:void 0,includeDisabledServers:m});if(a.success&&a.data){const c=a.data,u=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),N=URL.createObjectURL(u),T=document.createElement("a");T.href=N,T.download=`${c.name.replace(/[^a-zA-Z0-9-_]/g,"_")}.mcphub-template.json`,document.body.appendChild(T),T.click(),document.body.removeChild(T),URL.revokeObjectURL(N),h()}else C(a.message||s("template.exportFailed"))}catch(a){console.error("Export error:",a),C(s("template.exportFailed"))}finally{A(!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:h,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-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:n,onChange:a=>v(a.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:o,onChange:a=>f(a.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:b,className:"text-sm text-blue-600 hover:text-blue-800",children:E.length===i.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:i.map(a=>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(a.id),onChange:()=>d(a.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:a.name}),a.description&&e.jsx("span",{className:"text-xs text-gray-500 ml-2",children:a.description})]})]},a.id))})]}),e.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:m,onChange:a=>S(a.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 border border-blue-200 rounded-md",children:e.jsx("p",{className:"text-sm text-blue-700",children:s("template.exportNote")})}),e.jsxs("div",{className:"flex justify-end space-x-4 mt-6",children:[e.jsx("button",{onClick:h,className:"hub-btn",children:s("common.cancel")}),e.jsx("button",{onClick:p,disabled:w||!n.trim(),className:"hub-btn primary",children:s(w?"template.exporting":"template.export")})]})]})})},We=({onSuccess:i,onCancel:h})=>{const{t:s}=O(),[n,v]=x.useState(null),[o,f]=x.useState(null),[E,D]=x.useState(!1),[m,S]=x.useState(null),w=x.useRef(null),A=d=>{var a;f(null),v(null),S(null);const b=(a=d.target.files)==null?void 0:a[0];if(!b)return;const p=new FileReader;p.onload=c=>{var u;try{const N=JSON.parse((u=c.target)==null?void 0:u.result);if(!N.version||!N.name||!N.servers||!N.groups){f(s("template.invalidFormat"));return}v(N)}catch{f(s("template.parseError"))}},p.readAsText(b)},j=d=>{if(f(null),v(null),S(null),!!d.trim())try{const b=JSON.parse(d.trim());if(!b.version||!b.name||!b.servers||!b.groups){f(s("template.invalidFormat"));return}v(b)}catch{f(s("template.parseError"))}},C=async()=>{if(n){D(!0),f(null);try{const d=await Z("/templates/import",n);d.data?(S(d.data),d.data.success&&i()):f(d.message||s("template.importFailed"))}catch(d){console.error("Import error:",d),f(s("template.importFailed"))}finally{D(!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:h,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),o&&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:o})}),m&&e.jsxs("div",{className:`mb-4 p-4 rounded border-l-4 ${m.success?"bg-green-50 border-green-500":"bg-yellow-50 border-yellow-500"}`,children:[e.jsx("p",{className:m.success?"text-green-700":"text-yellow-700",children:s("template.importResult",{serversCreated:m.serversCreated,serversSkipped:m.serversSkipped,groupsCreated:m.groupsCreated,groupsSkipped:m.groupsSkipped})}),m.requiredEnvVars.length>0&&e.jsxs("div",{className:"mt-2 p-2 bg-orange-50 border border-orange-200 rounded",children:[e.jsx("p",{className:"text-sm font-medium text-orange-800",children:s("template.envVarsNeeded")}),e.jsx("ul",{className:"mt-1 text-sm text-orange-700",children:m.requiredEnvVars.map(d=>e.jsx("li",{className:"font-mono",children:d},d))})]})]}),n?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:n.name}),n.description&&e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:n.description}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[s("template.version"),": ",n.version," | ",s("template.createdAt"),":"," ",new Date(n.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(n.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(n.servers).map(([d,b])=>e.jsxs("div",{className:"px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:d}),e.jsx("span",{className:"text-xs text-gray-500 ml-2",children:b.type||"stdio"})]},d))})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:[s("template.groups")," (",n.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:n.groups.map((d,b)=>e.jsxs("div",{className:"px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:d.name}),d.description&&e.jsx("span",{className:"text-xs text-gray-500 ml-2",children:d.description}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:[d.servers.length," ",s("template.serversInGroup")]})]},b))})]}),n.requiredEnvVars.length>0&&e.jsxs("div",{className:"p-3 bg-orange-50 border border-orange-200 rounded-md",children:[e.jsx("h4",{className:"text-sm font-medium text-orange-800",children:s("template.envVarsNeeded")}),e.jsx("ul",{className:"mt-1 text-sm text-orange-700 font-mono",children:n.requiredEnvVars.map(d=>e.jsx("li",{children:d},d))})]})]}),e.jsxs("div",{className:"flex justify-end space-x-4 mt-6",children:[e.jsx("button",{onClick:()=>{v(null),S(null),w.current&&(w.current.value="")},className:"hub-btn",children:s("common.back")}),e.jsx("button",{onClick:C,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:w,type:"file",accept:".json",onChange:A,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:d=>j(d.target.value)})]}),e.jsx("div",{className:"flex justify-end space-x-4",children:e.jsx("button",{onClick:h,className:"hub-btn",children:s("common.cancel")})})]})]})})},Ze=()=>{const{t:i}=O(),{groups:h,loading:s,error:n,setError:v,deleteGroup:o,triggerRefresh:f}=Y(),{allServers:E}=Q({refreshOnMount:!0}),{groupCosts:D,refetch:m}=ee();x.useEffect(()=>{m()},[h,E,m]);const[S,w]=x.useState(null),[A,j]=x.useState(!1),[C,d]=x.useState(!1),[b,p]=x.useState(!1),[a,c]=x.useState(!1),u=async N=>{const T=await o(N);(!T||!T.success)&&v((T==null?void 0:T.message)||i("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:i("pages.groups.title")}),e.jsxs("p",{className:"hub-sub",children:[e.jsx("span",{className:"hub-num",children:h.length})," ",i("nav.groups").toLowerCase()]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{className:"hub-btn",onClick:()=>d(!0),children:[e.jsx(le,{size:13})," ",i("groupImport.button")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>p(!0),children:[e.jsx(Ee,{size:13})," ",i("template.exportButton")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>c(!0),children:[e.jsx(le,{size:13})," ",i("template.importButton")]}),e.jsxs("button",{className:"hub-btn primary",onClick:()=>j(!0),children:[e.jsx(ne,{size:13})," ",i("groups.add")]})]})]}),n&&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(De,{size:14,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate text-[13px]",children:n})]}),e.jsx("button",{className:"hub-icon-btn sm",onClick:()=>v(null),children:e.jsx(Ie,{size:13})})]}),s?e.jsx("div",{className:"hub-card p-6 text-center",style:{color:"var(--hub-ink-3)"},children:i("app.loading")}):h.length===0?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:i("groups.noGroups")}):e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3.5",children:[h.map(N=>e.jsx(Oe,{group:N,servers:E,onEdit:w,onDelete:u,cost:D.find(T=>T.id===N.id)},N.id)),e.jsx("button",{onClick:()=>j(!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(ne,{size:16})}),e.jsx("div",{style:{fontSize:13,fontWeight:500,color:"var(--hub-ink-2)"},children:i("groups.add")}),e.jsx("div",{style:{fontSize:12,marginTop:2},children:i("groups.addNew")})]})})]}),A&&e.jsx(Re,{onAdd:()=>{j(!1),f()},onCancel:()=>j(!1)}),C&&e.jsx($e,{onSuccess:()=>{d(!1),f()},onCancel:()=>d(!1)}),S&&e.jsx(Pe,{group:S,onEdit:()=>{w(null),f()},onCancel:()=>w(null)}),b&&e.jsx(Ge,{groups:h,onCancel:()=>p(!1)}),a&&e.jsx(We,{onSuccess:()=>{c(!1),f()},onCancel:()=>c(!1)})]})};export{Ze as default};
33
+ //# sourceMappingURL=GroupsPage-BqscWSfR.js.map