@samanhappy/mcphub 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.fr.md +6 -4
- package/README.md +24 -4
- package/README.zh.md +25 -4
- package/bin/cli.js +64 -50
- package/dist/betterAuth.js +21 -0
- package/dist/betterAuth.js.map +1 -1
- package/dist/cli/call-arguments.js +81 -0
- package/dist/cli/call-arguments.js.map +1 -0
- package/dist/cli/commands/call.js +75 -0
- package/dist/cli/commands/call.js.map +1 -0
- package/dist/cli/commands/config.js +132 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/discover.js +127 -0
- package/dist/cli/commands/discover.js.map +1 -0
- package/dist/cli/commands/export.js +20 -0
- package/dist/cli/commands/export.js.map +1 -0
- package/dist/cli/commands/groups.js +107 -0
- package/dist/cli/commands/groups.js.map +1 -0
- package/dist/cli/commands/install.js +173 -0
- package/dist/cli/commands/install.js.map +1 -0
- package/dist/cli/commands/keys.js +91 -0
- package/dist/cli/commands/keys.js.map +1 -0
- package/dist/cli/commands/login.js +70 -0
- package/dist/cli/commands/login.js.map +1 -0
- package/dist/cli/commands/servers.js +142 -0
- package/dist/cli/commands/servers.js.map +1 -0
- package/dist/cli/commands/tools.js +162 -0
- package/dist/cli/commands/tools.js.map +1 -0
- package/dist/cli/context.js +44 -0
- package/dist/cli/context.js.map +1 -0
- package/dist/cli/errors.js +19 -0
- package/dist/cli/errors.js.map +1 -0
- package/dist/cli/help.js +157 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/http.js +93 -0
- package/dist/cli/http.js.map +1 -0
- package/dist/cli/main.js +81 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/output.js +47 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cli/parse-args.js +103 -0
- package/dist/cli/parse-args.js.map +1 -0
- package/dist/cli/profile.js +109 -0
- package/dist/cli/profile.js.map +1 -0
- package/dist/cli/prompts.js +56 -0
- package/dist/cli/prompts.js.map +1 -0
- package/dist/controllers/oauthServerController.js +37 -1
- package/dist/controllers/oauthServerController.js.map +1 -1
- package/dist/controllers/serverController.js +3 -0
- package/dist/controllers/serverController.js.map +1 -1
- package/dist/dao/ActivityDao.js +2 -0
- package/dist/dao/ActivityDao.js.map +1 -1
- package/dist/dao/ServerDaoDbImpl.js +3 -0
- package/dist/dao/ServerDaoDbImpl.js.map +1 -1
- package/dist/db/connection.js +48 -4
- package/dist/db/connection.js.map +1 -1
- package/dist/db/entities/Activity.js +4 -0
- package/dist/db/entities/Activity.js.map +1 -1
- package/dist/db/entities/Server.js +4 -0
- package/dist/db/entities/Server.js.map +1 -1
- package/dist/db/entities/VectorEmbedding.js +2 -5
- package/dist/db/entities/VectorEmbedding.js.map +1 -1
- package/dist/db/repositories/VectorEmbeddingRepository.js +100 -34
- package/dist/db/repositories/VectorEmbeddingRepository.js.map +1 -1
- package/dist/services/activityLoggingService.js +1 -0
- package/dist/services/activityLoggingService.js.map +1 -1
- package/dist/services/betterAuthConfig.js +18 -1
- package/dist/services/betterAuthConfig.js.map +1 -1
- package/dist/services/dataService.js +10 -1
- package/dist/services/dataService.js.map +1 -1
- package/dist/services/mcpService.js +46 -12
- package/dist/services/mcpService.js.map +1 -1
- package/dist/services/vectorSearchService.js +16 -3
- package/dist/services/vectorSearchService.js.map +1 -1
- package/dist/utils/migration.js +1 -0
- package/dist/utils/migration.js.map +1 -1
- package/dist/utils/rateLimit.js +3 -3
- package/dist/utils/serverConfigPersistence.js +5 -0
- package/dist/utils/serverConfigPersistence.js.map +1 -1
- package/frontend/dist/assets/ActivityPage-B1B9ySGe.js +2 -0
- package/frontend/dist/assets/ActivityPage-B1B9ySGe.js.map +1 -0
- package/frontend/dist/assets/Dashboard-CYzpYZ1d.js +2 -0
- package/frontend/dist/assets/Dashboard-CYzpYZ1d.js.map +1 -0
- package/frontend/dist/assets/{EndpointCopy-C59moJ3Y.js → EndpointCopy-DVmlWW-s.js} +2 -2
- package/frontend/dist/assets/{EndpointCopy-C59moJ3Y.js.map → EndpointCopy-DVmlWW-s.js.map} +1 -1
- package/frontend/dist/assets/{GroupsPage-Bhg51kbu.js → GroupsPage-CsyoUc8S.js} +2 -2
- package/frontend/dist/assets/{GroupsPage-Bhg51kbu.js.map → GroupsPage-CsyoUc8S.js.map} +1 -1
- package/frontend/dist/assets/LoginPage-C3t8hbb2.js +2 -0
- package/frontend/dist/assets/LoginPage-C3t8hbb2.js.map +1 -0
- package/frontend/dist/assets/{LogsPage-HBGNLtyN.js → LogsPage-DOZeagVs.js} +2 -2
- package/frontend/dist/assets/{LogsPage-HBGNLtyN.js.map → LogsPage-DOZeagVs.js.map} +1 -1
- package/frontend/dist/assets/{MarketPage-C5ATZ4WS.js → MarketPage-kMEHUGfJ.js} +2 -2
- package/frontend/dist/assets/{MarketPage-C5ATZ4WS.js.map → MarketPage-kMEHUGfJ.js.map} +1 -1
- package/frontend/dist/assets/{PromptsPage-DUge8OO4.js → PromptsPage-D7JYoTav.js} +2 -2
- package/frontend/dist/assets/{PromptsPage-DUge8OO4.js.map → PromptsPage-D7JYoTav.js.map} +1 -1
- package/frontend/dist/assets/{ResourcesPage-5J3JYGVC.js → ResourcesPage-BlwePI9a.js} +2 -2
- package/frontend/dist/assets/{ResourcesPage-5J3JYGVC.js.map → ResourcesPage-BlwePI9a.js.map} +1 -1
- package/frontend/dist/assets/ServersPage-DrkPpCgK.js +37 -0
- package/frontend/dist/assets/ServersPage-DrkPpCgK.js.map +1 -0
- package/frontend/dist/assets/{SettingsPage-BeLZKC1d.js → SettingsPage-BWigWLml.js} +2 -2
- package/frontend/dist/assets/{SettingsPage-BeLZKC1d.js.map → SettingsPage-BWigWLml.js.map} +1 -1
- package/frontend/dist/assets/{StatusDot-DR803YdX.js → StatusDot-BDBIaafQ.js} +2 -2
- package/frontend/dist/assets/{StatusDot-DR803YdX.js.map → StatusDot-BDBIaafQ.js.map} +1 -1
- package/frontend/dist/assets/{ToggleGroup-DE8t8Ni4.js → ToggleGroup-OOcsllhw.js} +2 -2
- package/frontend/dist/assets/{ToggleGroup-DE8t8Ni4.js.map → ToggleGroup-OOcsllhw.js.map} +1 -1
- package/frontend/dist/assets/{UsersPage-CMscqAmn.js → UsersPage-DL8E7KtW.js} +2 -2
- package/frontend/dist/assets/{UsersPage-CMscqAmn.js.map → UsersPage-DL8E7KtW.js.map} +1 -1
- package/frontend/dist/assets/index-C7wNc_3N.js +3 -0
- package/frontend/dist/assets/index-C7wNc_3N.js.map +1 -0
- package/frontend/dist/assets/index-D0OIBhmN.css +1 -0
- package/frontend/dist/assets/{resourceService-BFMkDDIh.js → resourceService-B-U4FKGB.js} +2 -2
- package/frontend/dist/assets/{resourceService-BFMkDDIh.js.map → resourceService-B-U4FKGB.js.map} +1 -1
- package/frontend/dist/assets/{useServerData-BnLmpLAC.js → useServerData-DYoDryJj.js} +2 -2
- package/frontend/dist/assets/{useServerData-BnLmpLAC.js.map → useServerData-DYoDryJj.js.map} +1 -1
- package/frontend/dist/assets/useSettingsData-6utb1Z46.js +2 -0
- package/frontend/dist/assets/{useSettingsData-Cqi9d7Ug.js.map → useSettingsData-6utb1Z46.js.map} +1 -1
- package/frontend/dist/assets/{variableDetection-BigiltQM.js → variableDetection-DsYuiOB_.js} +3 -3
- package/frontend/dist/assets/variableDetection-DsYuiOB_.js.map +1 -0
- package/frontend/dist/index.html +2 -2
- package/package.json +2 -1
- package/frontend/dist/assets/ActivityPage-VwilVMvp.js +0 -2
- package/frontend/dist/assets/ActivityPage-VwilVMvp.js.map +0 -1
- package/frontend/dist/assets/Dashboard-DuBJTbbA.js +0 -2
- package/frontend/dist/assets/Dashboard-DuBJTbbA.js.map +0 -1
- package/frontend/dist/assets/LoginPage-C8RkMoJN.js +0 -2
- package/frontend/dist/assets/LoginPage-C8RkMoJN.js.map +0 -1
- package/frontend/dist/assets/ServersPage-DtnlfwJF.js +0 -37
- package/frontend/dist/assets/ServersPage-DtnlfwJF.js.map +0 -1
- package/frontend/dist/assets/index-B9cW2F0H.js +0 -3
- package/frontend/dist/assets/index-B9cW2F0H.js.map +0 -1
- package/frontend/dist/assets/index-Crcbkt8x.css +0 -1
- package/frontend/dist/assets/useSettingsData-Cqi9d7Ug.js +0 -2
- package/frontend/dist/assets/variableDetection-BigiltQM.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LoginPage-C8RkMoJN.js","sources":["../../src/components/ui/DefaultPasswordWarningModal.tsx","../../src/pages/LoginPage.tsx"],"sourcesContent":["import React from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useNavigate } from 'react-router-dom';\n\ninterface DefaultPasswordWarningModalProps {\n isOpen: boolean;\n onClose: () => void;\n}\n\nconst DefaultPasswordWarningModal: React.FC<DefaultPasswordWarningModalProps> = ({\n isOpen,\n onClose,\n}) => {\n const { t } = useTranslation();\n const navigate = useNavigate();\n\n if (!isOpen) return null;\n\n const handleGoToSettings = () => {\n onClose();\n navigate('/settings');\n // Auto-scroll to password section after a small delay to ensure page is loaded\n setTimeout(() => {\n const passwordSection = document.querySelector('[data-section=\"password\"]');\n if (passwordSection) {\n passwordSection.scrollIntoView({ behavior: 'smooth', block: 'start' });\n // If the section is collapsed, expand it\n const clickTarget = passwordSection.querySelector('[role=\"button\"]');\n if (clickTarget && !passwordSection.querySelector('.mt-4')) {\n (clickTarget as HTMLElement).click();\n }\n }\n }, 100);\n };\n\n const handleBackdropClick = (e: React.MouseEvent) => {\n if (e.target === e.currentTarget) {\n onClose();\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'Escape') {\n onClose();\n }\n };\n\n return (\n <div\n className=\"fixed inset-0 bg-black/50 z-[100] flex items-center justify-center p-4\"\n onClick={handleBackdropClick}\n onKeyDown={handleKeyDown}\n tabIndex={-1}\n >\n <div\n className=\"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full transform transition-all duration-200 ease-out\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"password-warning-title\"\n aria-describedby=\"password-warning-message\"\n >\n <div className=\"p-6\">\n <div className=\"flex items-start space-x-3\">\n <div className=\"flex-shrink-0\">\n <svg\n className=\"w-6 h-6 text-yellow-600 dark:text-yellow-400\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z\"\n />\n </svg>\n </div>\n <div className=\"flex-1\">\n <h3\n id=\"password-warning-title\"\n className=\"text-lg font-medium text-gray-900 dark:text-white mb-2\"\n >\n {t('auth.defaultPasswordWarning')}\n </h3>\n <p\n id=\"password-warning-message\"\n className=\"text-gray-600 dark:text-gray-300 leading-relaxed\"\n >\n {t('auth.defaultPasswordMessage')}\n </p>\n </div>\n </div>\n\n <div className=\"flex justify-end space-x-3 mt-6\">\n <button\n onClick={onClose}\n className=\"hub-btn\"\n >\n {t('common.cancel')}\n </button>\n <button\n onClick={handleGoToSettings}\n className=\"hub-btn primary\"\n autoFocus\n >\n {t('auth.goToSettings')}\n </button>\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nexport default DefaultPasswordWarningModal;\n","import React, { useState, useMemo, useCallback, useEffect } from 'react';\nimport { useLocation, useNavigate } from 'react-router-dom';\nimport { useTranslation } from 'react-i18next';\nimport { BookOpen, AlertCircle } from 'lucide-react';\nimport { useAuth } from '../contexts/AuthContext';\nimport { getToken } from '../services/authService';\nimport { getPublicConfig } from '../services/configService';\nimport { createBetterAuthClient } from '../services/betterAuthClient';\nimport { getBasePath } from '../utils/runtime';\nimport ThemeSwitch from '@/components/ui/ThemeSwitch';\nimport LanguageSwitch from '@/components/ui/LanguageSwitch';\nimport GitHubIcon from '@/components/icons/GitHubIcon';\nimport DefaultPasswordWarningModal from '@/components/ui/DefaultPasswordWarningModal';\n\nconst sanitizeReturnUrl = (value: string | null): string | null => {\n if (!value) return null;\n try {\n const origin = typeof window !== 'undefined' ? window.location.origin : 'http://localhost';\n const url = new URL(value, origin);\n if (url.origin !== origin) return null;\n const relativePath = `${url.pathname}${url.search}${url.hash}`;\n return relativePath || '/';\n } catch {\n if (value.startsWith('/') && !value.startsWith('//')) return value;\n return null;\n }\n};\n\nconst LoginPage: React.FC = () => {\n const { t } = useTranslation();\n const [username, setUsername] = useState('');\n const [password, setPassword] = useState('');\n const [error, setError] = useState<string | null>(null);\n const [loading, setLoading] = useState(false);\n const [socialLoading, setSocialLoading] = useState<'google' | 'github' | null>(null);\n const [socialError, setSocialError] = useState<string | null>(null);\n const [betterAuthBasePath, setBetterAuthBasePath] = useState<string | undefined>(undefined);\n const [socialProviders, setSocialProviders] = useState({ google: false, github: false });\n const [showDefaultPasswordWarning, setShowDefaultPasswordWarning] = useState(false);\n const { login, auth } = useAuth();\n const location = useLocation();\n const navigate = useNavigate();\n const returnUrl = useMemo(() => {\n const params = new URLSearchParams(location.search);\n return sanitizeReturnUrl(params.get('returnUrl'));\n }, [location.search]);\n\n const isServerUnavailableError = useCallback((message?: string) => {\n if (!message) return false;\n const normalized = message.toLowerCase();\n return (\n normalized.includes('failed to fetch') ||\n normalized.includes('networkerror') ||\n normalized.includes('network error') ||\n normalized.includes('connection refused') ||\n normalized.includes('unable to connect') ||\n normalized.includes('fetch error') ||\n normalized.includes('econnrefused') ||\n normalized.includes('http 500') ||\n normalized.includes('internal server error') ||\n normalized.includes('proxy error')\n );\n }, []);\n\n const buildRedirectTarget = useCallback(() => {\n if (!returnUrl) return '/';\n if (!returnUrl.startsWith('/oauth/authorize')) return returnUrl;\n const token = getToken();\n if (!token) return returnUrl;\n try {\n const origin = window.location.origin;\n const url = new URL(returnUrl, origin);\n url.searchParams.set('token', token);\n return `${url.pathname}${url.search}${url.hash}`;\n } catch {\n const separator = returnUrl.includes('?') ? '&' : '?';\n return `${returnUrl}${separator}token=${encodeURIComponent(token)}`;\n }\n }, [returnUrl]);\n\n const redirectAfterLogin = useCallback(() => {\n if (returnUrl) {\n window.location.assign(buildRedirectTarget());\n } else {\n navigate('/');\n }\n }, [buildRedirectTarget, navigate, returnUrl]);\n\n useEffect(() => {\n if (!auth.loading && auth.isAuthenticated) redirectAfterLogin();\n }, [auth.isAuthenticated, auth.loading, redirectAfterLogin]);\n\n useEffect(() => {\n const loadAuthProviders = async () => {\n const publicConfig = await getPublicConfig();\n const betterAuth = publicConfig.betterAuth;\n if (!betterAuth?.enabled) {\n setSocialProviders({ google: false, github: false });\n return;\n }\n setBetterAuthBasePath(betterAuth.basePath);\n setSocialProviders({\n google: betterAuth.providers?.google?.enabled === true,\n github: betterAuth.providers?.github?.enabled === true,\n });\n };\n loadAuthProviders();\n }, []);\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n setError(null);\n setSocialError(null);\n setLoading(true);\n try {\n if (!username || !password) {\n setError(t('auth.emptyFields'));\n setLoading(false);\n return;\n }\n const result = await login(username, password);\n if (result.success) {\n if (result.isUsingDefaultPassword) setShowDefaultPasswordWarning(true);\n else redirectAfterLogin();\n } else {\n const message = result.message;\n setError(isServerUnavailableError(message) ? t('auth.serverUnavailable') : t('auth.loginFailed'));\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : undefined;\n setError(isServerUnavailableError(message) ? t('auth.serverUnavailable') : t('auth.loginError'));\n } finally {\n setLoading(false);\n }\n };\n\n const handleSocialLogin = async (provider: 'google' | 'github') => {\n setSocialError(null);\n setSocialLoading(provider);\n try {\n const client = createBetterAuthClient(betterAuthBasePath);\n await client.signIn.social({\n provider,\n callbackURL: returnUrl || '/',\n errorCallbackURL: `${getBasePath()}/login`,\n });\n } catch (err) {\n console.error('Social login error:', err);\n setSocialError(t('auth.socialLoginFailed'));\n setSocialLoading(null);\n }\n };\n\n const handleCloseWarning = () => {\n setShowDefaultPasswordWarning(false);\n redirectAfterLogin();\n };\n\n return (\n <div\n className=\"relative min-h-screen w-full overflow-hidden\"\n style={{ background: 'var(--hub-bg)', color: 'var(--hub-ink)' }}\n >\n {/* Top-right controls */}\n <div className=\"absolute top-3 right-4 z-20 flex items-center gap-1\">\n <a\n href=\"https://github.com/samanhappy/mcphub\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"hub-icon-btn\"\n aria-label=\"GitHub Repository\"\n >\n <GitHubIcon className=\"h-4 w-4\" />\n </a>\n <a\n href=\"https://docs.mcphub.app\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"hub-icon-btn\"\n aria-label=\"Documentation\"\n >\n <BookOpen className=\"h-4 w-4\" />\n </a>\n <ThemeSwitch />\n <LanguageSwitch />\n </div>\n\n {/* Subtle grid pattern (kept low-key, hair-line) */}\n <div className=\"pointer-events-none absolute inset-0 -z-10\">\n <svg\n className=\"h-full w-full\"\n style={{ opacity: 0.5 }}\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <defs>\n <pattern id=\"grid\" width=\"32\" height=\"32\" patternUnits=\"userSpaceOnUse\">\n <path\n d=\"M 32 0 L 0 0 0 32\"\n fill=\"none\"\n stroke=\"var(--hub-line-2)\"\n strokeWidth=\"0.5\"\n />\n </pattern>\n </defs>\n <rect width=\"100%\" height=\"100%\" fill=\"url(#grid)\" />\n </svg>\n </div>\n\n <div className=\"relative mx-auto flex min-h-screen w-full max-w-md items-center justify-center px-6\">\n <div className=\"w-full space-y-8\">\n {/* Brand */}\n <div className=\"flex flex-col items-center gap-3\">\n <div\n className=\"relative grid place-items-center\"\n style={{\n width: 44,\n height: 44,\n borderRadius: 10,\n background: 'var(--hub-ink)',\n color: 'white',\n }}\n >\n <span className=\"hub-mono font-semibold\" style={{ fontSize: 18 }}>\n M\n </span>\n <span\n className=\"absolute\"\n style={{\n right: -2,\n bottom: -2,\n width: 8,\n height: 8,\n borderRadius: 50,\n background: 'var(--hub-ok)',\n boxShadow: '0 0 0 3px var(--hub-bg)',\n }}\n />\n </div>\n <div className=\"text-center\">\n <h1\n style={{\n fontSize: 20,\n fontWeight: 600,\n letterSpacing: '-0.02em',\n color: 'var(--hub-ink)',\n }}\n >\n {t('app.title')}\n </h1>\n <p className=\"hub-sub\" style={{ marginTop: 4 }}>\n {t('auth.slogan')}\n </p>\n </div>\n </div>\n\n {/* Login card */}\n <div\n className=\"hub-card\"\n style={{\n padding: '22px 22px 20px',\n boxShadow: '0 1px 2px rgba(0,0,0,0.02)',\n }}\n >\n <form className=\"space-y-3\" onSubmit={handleSubmit}>\n <div>\n <label\n htmlFor=\"username\"\n className=\"hub-sect block\"\n style={{ marginBottom: 6 }}\n >\n {t('auth.username')}\n </label>\n <input\n id=\"username\"\n name=\"username\"\n type=\"text\"\n autoComplete=\"username\"\n required\n className=\"hub-input\"\n placeholder={t('auth.username')}\n value={username}\n onChange={(e) => setUsername(e.target.value)}\n />\n </div>\n <div>\n <label\n htmlFor=\"password\"\n className=\"hub-sect block\"\n style={{ marginBottom: 6 }}\n >\n {t('auth.password')}\n </label>\n <input\n id=\"password\"\n name=\"password\"\n type=\"password\"\n autoComplete=\"current-password\"\n required\n className=\"hub-input\"\n placeholder={t('auth.password')}\n value={password}\n onChange={(e) => setPassword(e.target.value)}\n />\n </div>\n\n {error && (\n <div\n className=\"flex items-center gap-2\"\n style={{\n padding: '8px 10px',\n borderRadius: 7,\n border: '1px solid oklch(0.85 0.1 25)',\n background: 'oklch(0.97 0.03 25)',\n color: 'oklch(0.4 0.18 25)',\n fontSize: 12.5,\n }}\n >\n <AlertCircle size={13} className=\"flex-shrink-0\" />\n <span>{error}</span>\n </div>\n )}\n\n <button\n type=\"submit\"\n disabled={loading}\n className=\"hub-btn primary w-full justify-center\"\n style={{ height: 34 }}\n >\n {loading ? t('auth.loggingIn') : t('auth.login')}\n </button>\n </form>\n\n {(socialProviders.google || socialProviders.github) && (\n <div className=\"mt-5 space-y-3\">\n <div className=\"flex items-center gap-3\">\n <div className=\"h-px flex-1\" style={{ background: 'var(--hub-line)' }} />\n <span\n className=\"hub-sect\"\n style={{ textTransform: 'uppercase', letterSpacing: '0.08em' }}\n >\n {t('auth.orContinue')}\n </span>\n <div className=\"h-px flex-1\" style={{ background: 'var(--hub-line)' }} />\n </div>\n\n {socialError && (\n <div\n className=\"flex items-center gap-2\"\n style={{\n padding: '8px 10px',\n borderRadius: 7,\n border: '1px solid oklch(0.85 0.1 25)',\n background: 'oklch(0.97 0.03 25)',\n color: 'oklch(0.4 0.18 25)',\n fontSize: 12.5,\n }}\n >\n <AlertCircle size={13} className=\"flex-shrink-0\" />\n <span>{socialError}</span>\n </div>\n )}\n\n <div className=\"space-y-2\">\n {socialProviders.google && (\n <button\n type=\"button\"\n onClick={() => handleSocialLogin('google')}\n disabled={socialLoading !== null}\n className=\"hub-btn w-full justify-center\"\n style={{ height: 34 }}\n >\n {socialLoading === 'google'\n ? t('auth.loggingIn')\n : t('auth.loginWithGoogle')}\n </button>\n )}\n {socialProviders.github && (\n <button\n type=\"button\"\n onClick={() => handleSocialLogin('github')}\n disabled={socialLoading !== null}\n className=\"hub-btn w-full justify-center\"\n style={{\n height: 34,\n background: 'var(--hub-ink)',\n color: 'var(--hub-bg)',\n borderColor: 'var(--hub-ink)',\n }}\n >\n <GitHubIcon className=\"h-3.5 w-3.5\" />\n {socialLoading === 'github'\n ? t('auth.loggingIn')\n : t('auth.loginWithGithub')}\n </button>\n )}\n </div>\n </div>\n )}\n </div>\n\n <p\n className=\"text-center hub-mono\"\n style={{ fontSize: 11, color: 'var(--hub-ink-3)' }}\n >\n v{import.meta.env.PACKAGE_VERSION}\n </p>\n </div>\n </div>\n\n <DefaultPasswordWarningModal\n isOpen={showDefaultPasswordWarning}\n onClose={handleCloseWarning}\n />\n </div>\n );\n};\n\nexport default LoginPage;\n"],"names":["DefaultPasswordWarningModal","isOpen","onClose","t","useTranslation","navigate","useNavigate","handleGoToSettings","passwordSection","clickTarget","handleBackdropClick","e","handleKeyDown","jsx","jsxs","sanitizeReturnUrl","value","origin","url","LoginPage","username","setUsername","useState","password","setPassword","error","setError","loading","setLoading","socialLoading","setSocialLoading","socialError","setSocialError","betterAuthBasePath","setBetterAuthBasePath","socialProviders","setSocialProviders","showDefaultPasswordWarning","setShowDefaultPasswordWarning","login","auth","useAuth","location","useLocation","returnUrl","useMemo","params","isServerUnavailableError","useCallback","message","normalized","buildRedirectTarget","token","getToken","separator","redirectAfterLogin","useEffect","betterAuth","getPublicConfig","_b","_a","_d","_c","handleSubmit","result","err","handleSocialLogin","provider","createBetterAuthClient","getBasePath","handleCloseWarning","GitHubIcon","BookOpen","ThemeSwitch","LanguageSwitch","AlertCircle"],"mappings":"qQASA,MAAMA,EAA0E,CAAC,CAC/E,OAAAC,EACA,QAAAC,CACF,IAAM,CACJ,KAAM,CAAE,EAAAC,CAAA,EAAMC,EAAA,EACRC,EAAWC,EAAA,EAEjB,GAAI,CAACL,EAAQ,OAAO,KAEpB,MAAMM,EAAqB,IAAM,CAC/BL,EAAA,EACAG,EAAS,WAAW,EAEpB,WAAW,IAAM,CACf,MAAMG,EAAkB,SAAS,cAAc,2BAA2B,EAC1E,GAAIA,EAAiB,CACnBA,EAAgB,eAAe,CAAE,SAAU,SAAU,MAAO,QAAS,EAErE,MAAMC,EAAcD,EAAgB,cAAc,iBAAiB,EAC/DC,GAAe,CAACD,EAAgB,cAAc,OAAO,GACtDC,EAA4B,MAAA,CAEjC,CACF,EAAG,GAAG,CACR,EAEMC,EAAuBC,GAAwB,CAC/CA,EAAE,SAAWA,EAAE,eACjBT,EAAA,CAEJ,EAEMU,EAAiBD,GAA2B,CAC5CA,EAAE,MAAQ,UACZT,EAAA,CAEJ,EAEA,OACEW,EAAAA,IAAC,MAAA,CACC,UAAU,yEACV,QAASH,EACT,UAAWE,EACX,SAAU,GAEV,SAAAC,EAAAA,IAAC,MAAA,CACC,UAAU,gHACV,KAAK,SACL,aAAW,OACX,kBAAgB,yBAChB,mBAAiB,2BAEjB,SAAAC,EAAAA,KAAC,MA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,KAAK,SACL,QAAS,IAAMoD,EAAkB,QAAQ,EACzC,SAAUrC,IAAkB,KAC5B,UAAU,gCACV,MAAO,CACL,OAAQ,GACR,WAAY,iBACZ,MAAO,gBACP,YAAa,gBAAA,EAGf,SAAA,CAAAhB,EAAAA,IAAC0D,EAAA,CAAW,UAAU,cAAc,EAEhCpE,EADH0B,IAAkB,SACb,iBACA,sBADgB,CACM,CAAA,CAAA,CAC9B,EAEJ,CAAA,EACF,CAAA,CAAA,CAAA,EAIJf,EAAAA,KAAC,IAAA,CACC,UAAU,uBACV,MAAO,CAAE,SAAU,GAAI,MAAO,kBAAA,EAC/B,SAAA,CAAA,IACG,OAAA,CAAgB,CAAA,CACpB,CAAA,CACF,CAAA,CACF,EAEAD,EAAAA,IAACb,EAAA,CACC,OAAQqC,EACR,QAASiC,CAAA,CAAA,CACX,CAAA,CAAA,CAGN"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./resourceService-BFMkDDIh.js","./index-B9cW2F0H.js","./framework-vendor-BUhDPOUZ.js","./i18n-vendor-Kbr87Ofu.js","./icons-vendor-CKgJB3SC.js","./index-Crcbkt8x.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as m,j as e,b as He}from"./framework-vendor-BUhDPOUZ.js";import{e as ee,f as $e,h as be,i as we,_ as ge,j as Ge,k as Ke,l as Xe}from"./index-B9cW2F0H.js";import{S as Ze}from"./StatusDot-DR803YdX.js";import{u as ke}from"./useSettingsData-Cqi9d7Ug.js";import{S as Ce}from"./ToggleGroup-DE8t8Ni4.js";import{u as Q}from"./i18n-vendor-Kbr87Ofu.js";import{l as Ie,m as Fe,j as je,n as Qe,C as ce,o as fe,p as Se,q as Re,r as Oe,s as Ee,k as ye,X as ve,W as ze,f as Te,F as De,E as Ye,t as es,R as Ne,T as ss,P as ts,u as rs,v as ns,w as as}from"./icons-vendor-CKgJB3SC.js";import{D as os}from"./DeleteDialog-DRbWonMu.js";import{S as _e,d as ls}from"./variableDetection-BigiltQM.js";import{C as is}from"./ConfirmDialog-CxlizGia.js";import{P as cs}from"./Pagination-BFi-X7qY.js";import{u as ds}from"./useServerData-BnLmpLAC.js";const Ae=async(s,o)=>{try{const t=o?`/tools/${encodeURIComponent(o)}/${encodeURIComponent(s.toolName)}`:"/tools/call",r=await ee(t,s.arguments,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return r.success===!1?{success:!1,error:r.message||"Tool call failed"}:{success:!0,content:(r==null?void 0:r.content)||[]}}catch(t){return console.error("Error calling tool",{toolName:s.toolName,server:o,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},ms=async(s,o,t)=>{try{const r=await ee(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(o)}/toggle`,{enabled:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:r.success,error:r.success?void 0:r.message}}catch(r){return console.error("Error toggling tool",{serverName:s,toolName:o,enabled:t,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},Je=async(s,o,t)=>{try{const r=await be(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(o)}/description`,{description:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:r.success,error:r.success?void 0:r.message}}catch(r){return console.error("Error updating tool description",{serverName:s,toolName:o,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},Me=async(s,o)=>{var t;try{const r=await $e(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(o)}/description`,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:r.success,error:r.success?void 0:r.message,description:(t=r.data)==null?void 0:t.description}}catch(r){return console.error("Error resetting tool description",{serverName:s,toolName:o,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},us=Object.freeze(Object.defineProperty({__proto__:null,callTool:Ae,resetToolDescription:Me,toggleTool:ms,updateToolDescription:Je},Symbol.toStringTag,{value:"Module"})),Ue=({schema:s,onSubmit:o,onCancel:t,loading:r=!1,storageKey:i,title:b})=>{const{t:n}=Q(),[p,T]=m.useState({}),[P,d]=m.useState({}),[j,I]=m.useState(!1),[y,$]=m.useState(""),[v,E]=m.useState(""),g=m.useMemo(()=>(c=>{const N=a=>{if(typeof a=="object"&&a!==null){const u=a;return{type:u.type||"string",description:u.description,enum:u.enum,default:u.default,properties:u.properties?Object.fromEntries(Object.entries(u.properties).map(([l,f])=>[l,N(f)])):void 0,required:u.required,items:u.items?N(u.items):void 0}}return{type:"string"}};return{type:c.type,properties:c.properties?Object.fromEntries(Object.entries(c.properties).map(([a,u])=>[a,N(u)])):void 0,required:c.required}})(s),[s]);m.useEffect(()=>{const h=(N,a="")=>{const u={};return N.type==="object"&&N.properties&&Object.entries(N.properties).forEach(([l,f])=>{const C=a?`${a}.${l}`:l;f.default!==void 0?u[l]=f.default:f.type==="string"?u[l]="":f.type==="number"||f.type==="integer"?u[l]=0:f.type==="boolean"?u[l]=!1:f.type==="array"?u[l]=[]:f.type==="object"&&(f.properties?u[l]=h(f,C):u[l]={})}),u};let c=h(g);if(i)try{const N=localStorage.getItem(i);if(N){const a=JSON.parse(N);c={...c,...a}}}catch(N){console.warn("Failed to load saved form data:",N)}T(c)},[g,i]),m.useEffect(()=>{j&&Object.keys(p).length>0&&($(JSON.stringify(p,null,2)),E(""))},[j,p]);const O=h=>{$(h),E("");try{const c=JSON.parse(h);if(T(c),i)try{localStorage.setItem(i,JSON.stringify(c))}catch(N){console.warn("Failed to save form data to localStorage:",N)}}catch{E(n("tool.invalidJsonFormat"))}},R=()=>{$(JSON.stringify(p,null,2)),E(""),I(!0)},z=()=>{if(y.trim())try{const h=JSON.parse(y);T(h),E(""),I(!1)}catch{E(n("tool.fixJsonBeforeSwitching"));return}else I(!1)},A=(h,c)=>{T(N=>{const a={...N},u=h.split(".");let l=a;for(let f=0;f<u.length-1;f++)l[u[f]]||(l[u[f]]={}),l=l[u[f]];if(l[u[u.length-1]]=c,i)try{localStorage.setItem(i,JSON.stringify(a))}catch(f){console.warn("Failed to save form data to localStorage:",f)}return a}),P[h]&&d(N=>{const a={...N};return delete a[h],a})},W=()=>{const h={},c=(N,a,u="")=>{N.type==="object"&&N.properties&&Object.entries(N.properties).forEach(([l,f])=>{var V;const C=u?`${u}.${l}`:l,D=a==null?void 0:a[l];if((V=N.required)!=null&&V.includes(l)&&(D==null||D===""||Array.isArray(D)&&D.length===0)){h[C]=`${l} is required`;return}D!=null&&D!==""&&(f.type==="string"&&typeof D!="string"?h[C]=`${l} must be a string`:f.type==="number"&&typeof D!="number"?h[C]=`${l} must be a number`:f.type==="integer"&&(!Number.isInteger(D)||typeof D!="number")?h[C]=`${l} must be an integer`:f.type==="boolean"&&typeof D!="boolean"?h[C]=`${l} must be a boolean`:f.type==="array"&&Array.isArray(D)?f.items&&D.forEach((k,J)=>{var S;((S=f.items)==null?void 0:S.type)==="object"&&f.items.properties&&c(f.items,k,`${C}.${J}`)}):f.type==="object"&&typeof D=="object"&&c(f,D,C))})};return c(g,p),d(h),Object.keys(h).length===0},B=h=>{h.preventDefault(),W()&&o(p)},q=(h,c)=>c.split(".").reduce((N,a)=>N==null?void 0:N[a],h),K=(h,c,N,a)=>{const u=N==null?void 0:N[h];return c.type==="string"?c.enum?e.jsxs("select",{value:u||"",onChange:l=>a(l.target.value),className:"w-full border rounded-md px-2 py-1 text-sm border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:n("tool.selectOption")}),c.enum.map((l,f)=>e.jsx("option",{value:l,children:l},f))]}):e.jsx("input",{type:"text",value:u||"",onChange:l=>a(l.target.value),className:"w-full border rounded-md px-2 py-1 text-sm border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500 form-input",placeholder:c.description||n("tool.enterKey",{key:h})}):c.type==="number"||c.type==="integer"?e.jsx("input",{type:"number",step:c.type==="integer"?"1":"any",value:u??"",onChange:l=>{const f=l.target.value===""?"":c.type==="integer"?parseInt(l.target.value):parseFloat(l.target.value);a(f)},className:"w-full border rounded-md px-2 py-1 text-sm border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500 form-input"}):c.type==="boolean"?e.jsx("input",{type:"checkbox",checked:u||!1,onChange:l=>a(l.target.checked),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}):e.jsx("input",{type:"text",value:u||"",onChange:l=>a(l.target.value),className:"w-full border rounded-md px-2 py-1 text-sm border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500 form-input",placeholder:c.description||n("tool.enterKey",{key:h})})},M=(h,c,N="")=>{var f,C,D,V,k,J,S,U,se,te,de,me,ue,pe;const a=N?`${N}.${h}`:h,u=q(p,a),l=P[a];if(c.type==="array"){const _=q(p,a)||[];return e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(N?(C=(f=q(g,N))==null?void 0:f.required)==null?void 0:C.includes(h):(D=g.required)==null?void 0:D.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-md p-3 bg-gray-50 dark:bg-gray-800",children:[_.map((H,X)=>{var ne,ae,oe;return e.jsxs("div",{className:"mb-3 p-3 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-md",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-600",children:n("tool.item",{index:X+1})}),e.jsx("button",{type:"button",onClick:()=>{const L=[..._];L.splice(X,1),A(a,L)},className:"text-status-red hover:text-red-700 text-sm",children:n("common.remove")})]}),((ne=c.items)==null?void 0:ne.type)==="string"&&c.items.enum?e.jsxs("select",{value:H||"",onChange:L=>{const Z=[..._];Z[X]=L.target.value,A(a,Z)},className:"w-full border rounded-md px-3 py-2 border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:n("tool.selectOption")}),c.items.enum.map((L,Z)=>e.jsx("option",{value:L,children:L},Z))]}):((ae=c.items)==null?void 0:ae.type)==="object"&&c.items.properties?e.jsx("div",{className:"space-y-3",children:Object.entries(c.items.properties).map(([L,Z])=>{var le,ie;return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:[L,((ie=(le=c.items)==null?void 0:le.required)==null?void 0:ie.includes(L))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),K(L,Z,H,xe=>{const x=[..._];x[X]={...x[X],[L]:xe},A(a,x)})]},L)})}):e.jsx("input",{type:"text",value:H||"",onChange:L=>{const Z=[..._];Z[X]=L.target.value,A(a,Z)},className:"w-full border rounded-md px-3 py-2 border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 form-input",placeholder:n("tool.enterValue",{type:((oe=c.items)==null?void 0:oe.type)||"value"})})]},X)}),e.jsx("button",{type:"button",onClick:()=>{var X;const H=((X=c.items)==null?void 0:X.type)==="object"?{}:"";A(a,[..._,H])},className:"w-full mt-2 px-3 py-2 text-sm text-blue-600 border border-blue-300 rounded-md hover:bg-blue-50",children:n("tool.addItem",{key:h})})]}),l&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:l})]},a)}return c.type==="object"?c.properties?e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(N?(k=(V=q(g,N))==null?void 0:V.required)==null?void 0:k.includes(h):(J=g.required)==null?void 0:J.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-md p-4 bg-gray-50 dark:bg-gray-800",children:Object.entries(c.properties).map(([_,H])=>M(_,H,a))}),l&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:l})]},a):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(N?(U=(S=q(g,N))==null?void 0:S.required)==null?void 0:U.includes(h):(se=g.required)==null?void 0:se.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"}),e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(JSON object)"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsx("textarea",{value:typeof u=="object"?JSON.stringify(u,null,2):u||"{}",onChange:_=>{try{const H=JSON.parse(_.target.value);A(a,H)}catch{A(a,_.target.value)}},placeholder:`{
|
|
3
|
-
"key": "value"
|
|
4
|
-
}`,className:`w-full border rounded-md px-3 py-2 font-mono text-sm ${l?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`,rows:4}),l&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:l})]},a):c.type==="string"?c.enum?e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(N?!1:(te=g.required)==null?void 0:te.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsxs("select",{value:u||"",onChange:_=>A(a,_.target.value),className:`w-full border rounded-md px-3 py-2 ${l?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[e.jsx("option",{value:"",children:n("tool.selectOption")}),c.enum.map((_,H)=>e.jsx("option",{value:_,children:_},H))]}),l&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:l})]},a):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(N?!1:(de=g.required)==null?void 0:de.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsx("input",{type:"text",value:u||"",onChange:_=>A(a,_.target.value),className:`w-full border rounded-md px-3 py-2 ${l?"border-red":"border-gray-200"} focus:outline-none form-input`}),l&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:l})]},a):c.type==="number"||c.type==="integer"?e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(N?!1:(me=g.required)==null?void 0:me.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsx("input",{type:"number",step:c.type==="integer"?"1":"any",value:u??"",onChange:_=>{const H=_.target.value===""?"":c.type==="integer"?parseInt(_.target.value):parseFloat(_.target.value);A(a,H)},className:`w-full border rounded-md px-3 py-2 form-input ${l?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`}),l&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:l})]},a):c.type==="boolean"?e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",checked:u||!1,onChange:_=>A(a,_.target.checked),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),e.jsxs("label",{className:"ml-2 block text-sm text-gray-700",children:[h,(N?!1:(ue=g.required)==null?void 0:ue.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:c.description}),l&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:l})]},a):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[h,(N?!1:(pe=g.required)==null?void 0:pe.includes(h))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"}),e.jsxs("span",{className:"text-xs text-gray-500 ml-1",children:["(",c.type,")"]})]}),c.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.description}),e.jsx("input",{type:"text",value:u||"",onChange:_=>A(a,_.target.value),placeholder:n("tool.enterValue",{type:c.type}),className:`w-full border rounded-md px-3 py-2 ${l?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500 form-input`}),l&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:l})]},a)};return g.properties?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center pb-3",children:[e.jsx("h6",{className:"text-md font-medium text-gray-900",children:b}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("button",{type:"button",onClick:z,className:`hub-btn sm ${j?"":"primary"}`,children:n("tool.formMode")}),e.jsx("button",{type:"button",onClick:R,className:`hub-btn sm ${j?"primary":""}`,children:n("tool.jsonMode")})]})]}),j?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:n("tool.jsonConfiguration")}),e.jsx("textarea",{value:y,onChange:h=>O(h.target.value),placeholder:`{
|
|
5
|
-
"key": "value"
|
|
6
|
-
}`,className:`w-full h-64 border rounded-md px-3 py-2 font-mono text-sm resize-y form-input ${v?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`}),v&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:v})]}),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx("button",{type:"button",onClick:t,className:"hub-btn sm",children:n("tool.cancel")}),e.jsx("button",{onClick:()=>{try{const h=JSON.parse(y);o(h)}catch{E(n("tool.invalidJsonFormat"))}},disabled:r||!!v,className:"hub-btn sm primary",children:n(r?"tool.running":"tool.runTool")})]})]}):e.jsxs("form",{onSubmit:B,className:"space-y-4",children:[Object.entries(g.properties||{}).map(([h,c])=>M(h,c)),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx("button",{type:"button",onClick:t,className:"hub-btn sm",children:n("tool.cancel")}),e.jsx("button",{type:"submit",disabled:r,className:"hub-btn sm primary",children:n(r?"tool.running":"tool.runTool")})]})]})]}):e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx("p",{className:"text-sm text-gray-600",children:n("tool.noParameters")}),e.jsxs("div",{className:"flex justify-end space-x-2 mt-4",children:[e.jsx("button",{type:"button",onClick:t,className:"hub-btn",children:n("tool.cancel")}),e.jsx("button",{onClick:()=>o({}),disabled:r,className:"hub-btn primary",children:n(r?"tool.running":"tool.runTool")})]})]})},ps=({result:s,onClose:o})=>{const{t}=Q(),r=s.content,i=d=>d?d.startsWith("image/")?d:`image/${d}`:"image/png",b=d=>{if(!d)return[];if(Array.isArray(d))return d.flatMap(y=>b(y));if(typeof d!="object")return[];const j=[];d.type==="image"&&d.data&&j.push({data:String(d.data),mimeType:i(d.mimeType||d.mime_type)});const I=d.image_base64||d.imageBase64||d.image_data||d.imageData||d.base64;return I&&j.push({data:String(I),mimeType:i(d.image_mimeType||d.image_mime_type||d.mimeType||d.mime_type)}),d.image&&typeof d.image=="object"&&j.push(...b(d.image)),Array.isArray(d.images)&&j.push(...b(d.images)),Array.isArray(d.content)&&j.push(...b(d.content)),j},n=d=>{const j=[];try{const $=JSON.parse(d);if(j.push(...b($)),j.length>0)return j}catch{}const I=/data:image\/(png|jpe?g|gif|webp);base64,([A-Za-z0-9+/=]+)/g;let y;for(;(y=I.exec(d))!==null;){const $=`image/${y[1]==="jpg"?"jpeg":y[1]}`;j.push({data:y[2],mimeType:$})}return j},p=d=>{try{const j=JSON.parse(d),I=y=>{if(Array.isArray(y))return y.map(I);if(y&&typeof y=="object"){const $={};for(const[v,E]of Object.entries(y))typeof E=="string"&&v.toLowerCase().includes("base64")?$[v]="[base64 omitted]":$[v]=I(E);return $}return y};return JSON.stringify(I(j),null,2)}catch{return d.replace(/data:image\/(png|jpe?g|gif|webp);base64,[A-Za-z0-9+/=]+/g,"[image data omitted]")}},T=d=>Array.isArray(d)?d.map((j,I)=>e.jsx("div",{className:"mb-3 last:mb-0",children:P(j)},I)):P(d),P=d=>{if(typeof d=="string"){const j=n(d),I=p(d);return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[j.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:j.map((y,$)=>e.jsx("img",{src:`data:${y.mimeType||"image/png"};base64,${y.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"},$))}),e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:I})]})}if(typeof d=="object"&&d!==null){if(d.type==="text"&&d.text){const j=n(d.text),I=p(d.text);return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[j.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:j.map((y,$)=>e.jsx("img",{src:`data:${y.mimeType||"image/png"};base64,${y.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"},$))}),e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:I})]})}if(d.type==="image"&&d.data)return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("img",{src:`data:${d.mimeType||"image/png"};base64,${d.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"})});try{const j=typeof d=="string"?JSON.parse(d):d;return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-2",children:t("tool.jsonResponse")}),e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(j,null,2)})]})}catch{return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(d)})})}}return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(d)})})};return e.jsxs("div",{className:"border border-gray-300 rounded-lg bg-white dark:bg-gray-800 shadow-sm",children:[e.jsx("div",{className:"border-b border-gray-300 px-4 py-3 bg-gray-50 dark:bg-gray-800 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[s.success?e.jsx(Ie,{size:20,className:"text-status-green"}):e.jsx(Fe,{size:20,className:"text-status-red"}),e.jsx("div",{children:e.jsxs("h4",{className:"text-sm font-medium text-gray-900",children:[t("tool.execution")," ",s.success?t("tool.successful"):t("tool.failed")]})})]}),e.jsx("button",{onClick:o,className:"text-gray-400 hover:text-gray-600 text-sm",children:"✕"})]})}),e.jsx("div",{className:"p-4",children:s.success?e.jsx("div",{children:s.content&&s.content.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:t("tool.result")}),T(s.content)]}):e.jsx("div",{className:"text-sm text-gray-500 italic",children:t("tool.noContent")})}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-3",children:[e.jsx(je,{size:16,className:"text-red-500"}),e.jsx("span",{className:"text-sm font-medium text-red-700",children:t("tool.error")})]}),r&&r.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:t("tool.errorDetails")}),T(r)]}):e.jsx("div",{className:"bg-red-50 border border-red-300 rounded-md p-3",children:e.jsx("pre",{className:"text-sm text-red-800 whitespace-pre-wrap",children:s.error||s.message||t("tool.unknownError")})})]})})]})},re=({title:s,onClick:o,disabled:t=!1,loading:r=!1})=>e.jsx("button",{type:"button",className:"ml-2 p-1 text-amber-600 hover:text-amber-700 cursor-pointer transition-colors disabled:opacity-60 disabled:cursor-not-allowed",onClick:o,disabled:t,title:s,"aria-label":s,children:e.jsx(Qe,{size:14,className:r?"animate-spin":""})});function xs(s){return s==null?!0:typeof s=="string"?s.trim()==="":Array.isArray(s)?s.length===0:typeof s=="object"?Object.keys(s).length===0:!1}const hs=({tool:s,server:o,onToggle:t,onDescriptionUpdate:r})=>{const{t:i}=Q(),{showToast:b}=we(),{nameSeparator:n}=ke(),[p,T]=m.useState(!1),[P,d]=m.useState(!1),[j,I]=m.useState(!1),[y,$]=m.useState(null),[v,E]=m.useState(!1),[g,O]=m.useState(!1),[R,z]=m.useState(s.description||""),A=m.useRef(null),W=m.useRef(null),[B,q]=m.useState(0),[K,M]=m.useState(!1);m.useEffect(()=>{v&&A.current&&(A.current.focus(),B>0&&(A.current.style.width=`${B+20}px`))},[v,B]),m.useEffect(()=>{!v&&W.current&&q(W.current.offsetWidth)},[v,R]),m.useEffect(()=>{z(s.description||"")},[s.description]);const h=m.useCallback(()=>`mcphub_tool_form_${o?`${o}_`:""}${s.name}`,[s.name,o]),c=m.useCallback(()=>{localStorage.removeItem(h())},[h]),N=S=>{t&&t(s.name,S)},a=()=>{E(!0)},u=async()=>{try{const S=await Je(o,s.name,R);S.success?(E(!1),r&&r(s.name,R)):(z(s.description||""),console.error("Failed to update tool description:",S.error))}catch(S){console.error("Error updating tool description:",S),z(s.description||""),E(!1)}},l=S=>{z(S.target.value)},f=async()=>{O(!0);try{const S=await Me(o,s.name);if(S.success){const U=S.description||"";z(U),E(!1),r==null||r(s.name,U,{restored:!0})}else b(S.error||i("tool.restoreDefaultFailed"),"error")}catch(S){console.error("Error resetting tool description:",S),b(i("tool.restoreDefaultFailed"),"error")}finally{O(!1)}},C=S=>{S.key==="Enter"?u():S.key==="Escape"&&(z(s.description||""),E(!1))},D=async S=>{S.stopPropagation();try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(s.name),M(!0),b(i("common.copySuccess"),"success"),setTimeout(()=>M(!1),2e3);else{const U=document.createElement("textarea");U.value=s.name,U.style.position="fixed",U.style.left="-9999px",document.body.appendChild(U),U.focus(),U.select();try{document.execCommand("copy"),M(!0),b(i("common.copySuccess"),"success"),setTimeout(()=>M(!1),2e3)}catch(se){b(i("common.copyFailed"),"error"),console.error("Copy to clipboard failed:",se)}document.body.removeChild(U)}}catch(U){b(i("common.copyFailed"),"error"),console.error("Copy to clipboard failed:",U)}},V=async S=>{I(!0);try{S=Object.fromEntries(Object.entries(S).filter(([se,te])=>!xs(te)));const U=await Ae({toolName:s.name,arguments:S},o);$(U)}catch(U){$({success:!1,error:U instanceof Error?U.message:"Unknown error occurred"})}finally{I(!1)}},k=()=>{d(!1),c(),$(null)},J=()=>{$(null)};return e.jsxs("div",{className:"hub-card overflow-hidden",style:{marginBottom:8},children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 px-3 py-2.5 cursor-pointer hover:bg-[var(--hub-surface-hover)] transition-colors",onClick:S=>{S.stopPropagation(),T(!p)},children:[e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"hub-mono font-medium",style:{fontSize:13,color:"var(--hub-ink)"},children:s.name.replace(o+n,"")}),e.jsx("button",{className:"hub-icon-btn sm",onClick:D,title:i("common.copy"),children:K?e.jsx(ce,{size:12,style:{color:"var(--hub-ok)"}}):e.jsx(fe,{size:12})}),e.jsx("span",{className:"flex items-center gap-1",style:{fontSize:12,color:"var(--hub-ink-3)"},children:v?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:A,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:B>0?`${B+20}px`:160,minWidth:80},value:R,onChange:l,onKeyDown:C,onClick:S=>S.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:S=>{S.stopPropagation(),u()},disabled:g,children:e.jsx(ce,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(re,{title:i("tool.restoreDefault"),onClick:S=>{S.stopPropagation(),f()},disabled:g,loading:g})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:W,children:R||i("tool.noDescription")}),e.jsx("button",{className:"hub-icon-btn sm",onClick:S=>{S.stopPropagation(),a()},children:e.jsx(Se,{size:12})}),e.jsx(re,{title:i("tool.restoreDefault"),onClick:S=>{S.stopPropagation(),f()},disabled:g,loading:g})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("div",{onClick:S=>S.stopPropagation(),children:e.jsx(Ce,{checked:s.enabled??!0,onCheckedChange:N,disabled:j})}),e.jsxs("button",{onClick:S=>{S.stopPropagation(),T(!0),d(!0)},className:"hub-btn sm",style:{color:"var(--hub-accent)"},disabled:j||!s.enabled,children:[j?e.jsx(Re,{size:12,className:"animate-spin"}):e.jsx(Oe,{size:12}),e.jsx("span",{children:i(j?"tool.running":"tool.run")})]}),e.jsx("button",{className:"hub-icon-btn sm",children:p?e.jsx(Ee,{size:14}):e.jsx(ye,{size:14})})]})]}),p&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",padding:"10px 12px",display:"flex",flexDirection:"column",gap:10},children:[!P&&e.jsxs("div",{style:{background:"var(--hub-bg-2)",borderRadius:7,padding:"8px 12px",border:"1px solid var(--hub-line)"},children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:6},children:i("tool.inputSchema")}),e.jsx("pre",{className:"hub-mono overflow-auto",style:{fontSize:11.5,color:"var(--hub-ink-2)",margin:0},children:JSON.stringify(s.inputSchema,null,2)})]}),P&&e.jsxs("div",{style:{border:"1px solid var(--hub-line)",borderRadius:8,padding:14},children:[e.jsx(Ue,{schema:s.inputSchema||{type:"object"},onSubmit:V,onCancel:k,loading:j,storageKey:h(),title:i("tool.runToolWithName",{name:s.name.replace(o+n,"")})}),y&&e.jsx("div",{style:{marginTop:12},children:e.jsx(ps,{result:y,onClose:J})})]})]})]})},gs=async(s,o)=>{try{const t=o?`/prompts/call/${o}`:"/prompts/call",r=await ee(t,{promptName:s.promptName,arguments:s.arguments});return r.success?{success:!0,data:r.data}:{success:!1,error:r.message||"Prompt call failed"}}catch(t){return console.error("Error calling prompt",{promptName:s.promptName,server:o,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},Be=async(s,o)=>{try{const t=await ee(`/mcp/${encodeURIComponent(o||"")}/prompts/${encodeURIComponent(s.promptName)}`,{name:s.promptName,arguments:s.arguments});if(!t.success)throw new Error(`Failed to get prompt: ${t.message||"Unknown error"}`);return{success:!0,data:t.data}}catch(t){return console.error("Error getting prompt",{promptName:s.promptName,server:o,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},fs=async(s,o,t)=>{try{const r=await ee(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(o)}/toggle`,{enabled:t});return{success:r.success,error:r.success?void 0:r.message}}catch(r){return console.error("Error toggling prompt",{serverName:s,promptName:o,enabled:t,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},Ve=async(s,o,t)=>{try{const r=await be(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(o)}/description`,{description:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:r.success,error:r.success?void 0:r.message}}catch(r){return console.error("Error updating prompt description",{serverName:s,promptName:o,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},We=async(s,o)=>{var t;try{const r=await $e(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(o)}/description`,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:r.success,error:r.success?void 0:r.message,description:(t=r.data)==null?void 0:t.description}}catch(r){return console.error("Error resetting prompt description",{serverName:s,promptName:o,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},bs=Object.freeze(Object.defineProperty({__proto__:null,callPrompt:gs,getPrompt:Be,resetPromptDescription:We,togglePrompt:fs,updatePromptDescription:Ve},Symbol.toStringTag,{value:"Module"})),Pe=({result:s,onClose:o})=>{const{t}=Q(),r=i=>{if(typeof i=="string")return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:i})});if(typeof i=="object"&&i!==null){if(i.description||i.messages)return e.jsxs("div",{className:"space-y-4",children:[i.description&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:t("prompt.description")}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("p",{className:"text-sm text-gray-800",children:i.description})})]}),i.messages&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:t("prompt.messages")}),e.jsx("div",{className:"space-y-3",children:i.messages.map((b,n)=>e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[e.jsx("div",{className:"flex items-center mb-2",children:e.jsxs("span",{className:"inline-block w-16 text-xs font-medium text-gray-500",children:[b.role,":"]})}),typeof b.content=="string"?e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:b.content}):typeof b.content=="object"&&b.content.type==="text"?e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:b.content.text}):e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(b.content,null,2)})]},n))})]})]});try{const b=typeof i=="string"?JSON.parse(i):i;return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-2",children:t("prompt.jsonResponse")}),e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(b,null,2)})]})}catch{return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(i)})})}}return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(i)})})};return e.jsxs("div",{className:"border border-gray-300 rounded-lg bg-white dark:bg-gray-800 shadow-sm",children:[e.jsx("div",{className:"border-b border-gray-300 px-4 py-3 bg-gray-50 dark:bg-gray-800 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[s.success?e.jsx(Ie,{size:20,className:"text-status-green"}):e.jsx(Fe,{size:20,className:"text-status-red"}),e.jsx("div",{children:e.jsxs("h4",{className:"text-sm font-medium text-gray-900",children:[t("prompt.execution")," ",s.success?t("prompt.successful"):t("prompt.failed")]})})]}),e.jsx("button",{onClick:o,className:"text-gray-400 hover:text-gray-600 text-sm",children:"✕"})]})}),e.jsx("div",{className:"p-4",children:s.success?e.jsx("div",{children:s.data?e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:t("prompt.result")}),r(s.data)]}):e.jsx("div",{className:"text-sm text-gray-500 italic",children:t("prompt.noContent")})}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-3",children:[e.jsx(je,{size:16,className:"text-red-500"}),e.jsx("span",{className:"text-sm font-medium text-red-700",children:t("prompt.error")})]}),e.jsx("div",{className:"bg-red-50 border border-red-300 rounded-md p-3",children:e.jsx("pre",{className:"text-sm text-red-800 whitespace-pre-wrap",children:s.error||s.message||t("prompt.unknownError")})})]})})]})},js=({prompt:s,server:o,onToggle:t,onDescriptionUpdate:r})=>{const{t:i}=Q(),{showToast:b}=we(),{nameSeparator:n}=ke(),[p,T]=m.useState(!1),[P,d]=m.useState(!1),[j,I]=m.useState(!1),[y,$]=m.useState(null),[v,E]=m.useState(!1),[g,O]=m.useState(!1),[R,z]=m.useState(s.description||""),A=m.useRef(null),W=m.useRef(null),[B,q]=m.useState(0);m.useEffect(()=>{v&&A.current&&(A.current.focus(),B>0&&(A.current.style.width=`${B+20}px`))},[v,B]),m.useEffect(()=>{!v&&W.current&&q(W.current.offsetWidth)},[v,R]),m.useEffect(()=>{z(s.description||"")},[s.description]);const K=m.useCallback(()=>`mcphub_prompt_form_${o?`${o}_`:""}${s.name}`,[s.name,o]),M=m.useCallback(()=>{localStorage.removeItem(K())},[K]),h=k=>{t&&t(s.name,k)},c=()=>{E(!0)},N=async()=>{E(!1);try{const k=await Ve(o,s.name,R);k.success?r&&r(s.name,R):(b(k.error||i("prompt.descriptionUpdateFailed"),"error"),z(s.description||""))}catch(k){console.error("Error updating prompt description:",k),b(i("prompt.descriptionUpdateFailed"),"error"),z(s.description||"")}},a=async()=>{O(!0);try{const k=await We(o,s.name);if(k.success){const J=k.description||"";z(J),E(!1),r==null||r(s.name,J,{restored:!0})}else b(k.error||i("prompt.restoreDefaultFailed"),"error")}catch(k){console.error("Error resetting prompt description:",k),b(i("prompt.restoreDefaultFailed"),"error")}finally{O(!1)}},u=k=>{z(k.target.value)},l=k=>{k.key==="Enter"?N():k.key==="Escape"&&(z(s.description||""),E(!1))},f=async k=>{I(!0);try{const J=await Be({promptName:s.name,arguments:k},o);console.log("GetPrompt result:",J),$({success:J.success,data:J.data,error:J.error})}catch(J){$({success:!1,error:J instanceof Error?J.message:"Unknown error occurred"})}finally{I(!1)}},C=()=>{d(!1),M(),$(null)},D=()=>{$(null)},V=()=>{if(!s.arguments||s.arguments.length===0)return{type:"object",properties:{},required:[]};const k={},J=[];return s.arguments.forEach(S=>{k[S.name]={type:"string",description:S.description||""},S.required&&J.push(S.name)}),{type:"object",properties:k,required:J}};return e.jsxs("div",{className:"hub-card overflow-hidden",style:{marginBottom:8},children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 px-3 py-2.5 cursor-pointer hover:bg-[var(--hub-surface-hover)] transition-colors",onClick:()=>T(!p),children:[e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"hub-mono font-medium",style:{fontSize:13,color:"var(--hub-ink)"},children:s.name.replace(o+n,"")}),s.title&&e.jsx("span",{style:{fontSize:12,color:"var(--hub-ink-2)"},children:s.title}),e.jsx("span",{className:"flex items-center gap-1",style:{fontSize:12,color:"var(--hub-ink-3)"},children:v?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:A,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:B>0?`${B+20}px`:160,minWidth:80},value:R,onChange:u,onKeyDown:l,onClick:k=>k.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:k=>{k.stopPropagation(),N()},disabled:g,children:e.jsx(ce,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(re,{title:i("prompt.restoreDefault"),onClick:k=>{k.stopPropagation(),a()},disabled:g,loading:g})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:W,children:R||i("tool.noDescription")}),e.jsx("button",{className:"hub-icon-btn sm",onClick:k=>{k.stopPropagation(),c()},children:e.jsx(Se,{size:12})}),e.jsx(re,{title:i("prompt.restoreDefault"),onClick:k=>{k.stopPropagation(),a()},disabled:g,loading:g})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("div",{onClick:k=>k.stopPropagation(),children:s.enabled!==void 0&&e.jsx(Ce,{checked:s.enabled,onCheckedChange:h,disabled:j})}),e.jsxs("button",{onClick:k=>{k.stopPropagation(),T(!0),d(!0)},className:"hub-btn sm",style:{color:"var(--hub-accent)"},disabled:j||!s.enabled,children:[j?e.jsx(Re,{size:12,className:"animate-spin"}):e.jsx(Oe,{size:12}),e.jsx("span",{children:i(j?"tool.running":"tool.run")})]}),e.jsx("button",{className:"hub-icon-btn sm",children:p?e.jsx(Ee,{size:14}):e.jsx(ye,{size:14})})]})]}),p&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",padding:"10px 12px",display:"flex",flexDirection:"column",gap:10},children:[P&&e.jsxs("div",{style:{border:"1px solid var(--hub-line)",borderRadius:8,padding:14},children:[e.jsx(Ue,{schema:V(),onSubmit:f,onCancel:C,loading:j,storageKey:K(),title:i("prompt.runPromptWithName",{name:s.name.replace(o+n,"")})}),y&&e.jsx("div",{style:{marginTop:12},children:e.jsx(Pe,{result:y,onClose:D})})]}),!P&&s.arguments&&s.arguments.length>0&&e.jsxs("div",{style:{background:"var(--hub-bg-2)",borderRadius:7,padding:"8px 12px",border:"1px solid var(--hub-line)"},children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:6},children:i("tool.parameters")}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:s.arguments.map((k,J)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"hub-mono",style:{fontSize:12.5,color:"var(--hub-ink)"},children:k.name}),k.required&&e.jsx("span",{style:{color:"var(--hub-err)",fontSize:12},children:"*"})]}),k.description&&e.jsx("p",{style:{fontSize:12,color:"var(--hub-ink-3)",margin:"2px 0 0"},children:k.description})]}),k.title&&e.jsx("span",{style:{fontSize:11,color:"var(--hub-ink-3)"},children:k.title})]},J))})]}),!P&&y&&e.jsx("div",{children:e.jsx(Pe,{result:y,onClose:D})})]})]})},ys=({resource:s,onToggle:o,onDescriptionUpdate:t})=>{const{t:r}=Q(),[i,b]=m.useState(!1),[n,p]=m.useState(!1),[T,P]=m.useState(!1),[d,j]=m.useState(s.description||""),I=m.useRef(null),y=m.useRef(null),[$,v]=m.useState(0);m.useEffect(()=>{n&&I.current&&(I.current.focus(),$>0&&(I.current.style.width=`${$+20}px`))},[n,$]),m.useEffect(()=>{!n&&y.current&&v(y.current.offsetWidth)},[n,d]),m.useEffect(()=>{j(s.description||"")},[s.description]);const E=z=>{o&&o(s.uri,z)},g=async()=>{p(!1),t&&await t(s.uri,d)},O=async()=>{P(!0);try{await(t==null?void 0:t(s.uri,"",{restored:!0})),p(!1)}finally{P(!1)}},R=z=>{z.key==="Enter"?g():z.key==="Escape"&&(j(s.description||""),p(!1))};return e.jsxs("div",{className:"hub-card overflow-hidden",style:{marginBottom:8},children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 px-3 py-2.5 cursor-pointer hover:bg-[var(--hub-surface-hover)] transition-colors",onClick:()=>b(!i),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"hub-mono font-medium truncate",style:{fontSize:13,color:"var(--hub-ink)"},children:s.name||s.uri}),e.jsx("span",{className:"hub-mono truncate",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:s.uri})]}),e.jsx("span",{className:"flex items-center gap-1 mt-0.5",style:{fontSize:12,color:"var(--hub-ink-3)"},children:n?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:I,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:$>0?`${$+20}px`:160,minWidth:80},value:d,onChange:z=>j(z.target.value),onKeyDown:R,onClick:z=>z.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:z=>{z.stopPropagation(),g()},disabled:T,children:e.jsx(ce,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(re,{title:r("builtinResources.restoreDefault"),onClick:z=>{z.stopPropagation(),O()},disabled:T,loading:T})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:y,children:d||r("tool.noDescription")}),e.jsx("button",{className:"hub-icon-btn sm",onClick:z=>{z.stopPropagation(),p(!0)},children:e.jsx(Se,{size:12})}),e.jsx(re,{title:r("builtinResources.restoreDefault"),onClick:z=>{z.stopPropagation(),O()},disabled:T,loading:T})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("div",{onClick:z=>z.stopPropagation(),children:e.jsx(Ce,{checked:s.enabled!==!1,onCheckedChange:E})}),e.jsx("button",{className:"hub-icon-btn sm",children:i?e.jsx(Ee,{size:14}):e.jsx(ye,{size:14})})]})]}),i&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",padding:"8px 12px"},children:[e.jsxs("span",{className:"hub-sect",children:[r("builtinResources.mimeType"),":"]})," ",e.jsx("span",{style:{fontSize:12,color:"var(--hub-ink-2)"},children:s.mimeType||"text/plain"})]})]})},vs=(s,o)=>o?o==="stdio"?s("server.typeStdio")||"stdio":o==="sse"?s("server.typeSse")||"sse":o==="streamable-http"?s("server.typeStreamableHttp")||"http":o==="openapi"?s("server.typeOpenapi")||"openapi":o:null,Ns=({server:s,onRemove:o,onEdit:t,onToggle:r,onRefresh:i,onReload:b})=>{var X,ne,ae,oe,L,Z,le,ie,xe;const{t:n}=Q(),{showToast:p}=we(),{exportMCPSettings:T,installConfig:P}=ke(),d=((X=P==null?void 0:P.baseUrl)==null?void 0:X.replace(/\/+$/,""))||"",[j,I]=m.useState(!1),[y,$]=m.useState(null),[v,E]=m.useState(!1),[g,O]=m.useState(!1),[R,z]=m.useState(!1),[A,W]=m.useState(!1),[B,q]=m.useState(!1),[K,M]=m.useState(!1),h=m.useRef(null),c=m.useRef(null);m.useEffect(()=>{const x=w=>{h.current&&!h.current.contains(w.target)&&W(!1),c.current&&!c.current.contains(w.target)&&q(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[]);const N=((ne=s.tools)==null?void 0:ne.length)||0,a=((ae=s.tools)==null?void 0:ae.filter(x=>x.enabled!==!1).length)||0,u=((oe=s.prompts)==null?void 0:oe.length)||0,l=((L=s.prompts)==null?void 0:L.filter(x=>x.enabled!==!1).length)||0,f=((Z=s.resources)==null?void 0:Z.length)||0,C=((le=s.resources)==null?void 0:le.filter(x=>x.enabled!==!1).length)||0,D=async x=>{if(x.stopPropagation(),!(g||!r)){O(!0);try{await r(s,s.enabled===!1)}finally{O(!1)}}},V=async x=>{if(x.stopPropagation(),W(!1),!(R||!b)){z(!0);try{await b(s)?p(n("server.reloadSuccess")||"Server reloaded successfully","success"):p(n("server.reloadError",{serverName:s.name})||"Failed to reload","error")}finally{z(!1)}}},k=async x=>{try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(x),!0}catch{}try{const w=document.createElement("textarea");w.value=x,w.style.position="fixed",w.style.left="-9999px",document.body.appendChild(w),w.focus(),w.select();const F=document.execCommand("copy");return document.body.removeChild(w),F}catch{return!1}},J=async x=>{if(x.stopPropagation(),!s.error)return;await k(s.error)?(M(!0),p(n("common.copySuccess")||"Copied","success"),setTimeout(()=>M(!1),1500)):p(n("common.copyFailed")||"Copy failed","error")},S=async x=>{x.stopPropagation(),W(!1);try{const w=await T(s.name);if(!w||!w.success||!w.data){p((w==null?void 0:w.message)||n("common.copyFailed")||"Copy failed","error");return}const F=JSON.stringify(w.data,null,2),G=await k(F);p(G?n("common.copySuccess")||"Copied":n("common.copyFailed")||"Copy failed",G?"success":"error")}catch(w){console.error("Error copying server configuration:",w),p(n("common.copyFailed")||"Copy failed","error")}},U=x=>{var w;if(x.stopPropagation(),(w=s.oauth)!=null&&w.authorizationUrl){const Y=window.screen.width/2-300,he=window.screen.height/2-700/2;window.open(s.oauth.authorizationUrl,"OAuth Authorization",`width=600,height=700,left=${Y},top=${he}`),p(n("status.oauthWindowOpened"),"info")}},se=async(x,w)=>{try{const{toggleTool:F}=await ge(async()=>{const{toggleTool:Y}=await Promise.resolve().then(()=>us);return{toggleTool:Y}},void 0,import.meta.url),G=await F(s.name,x,w);G.success?(p(n(w?"tool.enableSuccess":"tool.disableSuccess",{name:x}),"success"),i==null||i()):p(G.error||n("tool.toggleFailed"),"error")}catch(F){console.error(F),p(n("tool.toggleFailed"),"error")}},te=async(x,w)=>{try{const{togglePrompt:F}=await ge(async()=>{const{togglePrompt:Y}=await Promise.resolve().then(()=>bs);return{togglePrompt:Y}},void 0,import.meta.url),G=await F(s.name,x,w);G.success?(p(n(w?"tool.enableSuccess":"tool.disableSuccess",{name:x}),"success"),i==null||i()):p(G.error||n("tool.toggleFailed"),"error")}catch(F){console.error(F),p(n("tool.toggleFailed"),"error")}},de=async(x,w)=>{try{const{toggleResource:F}=await ge(async()=>{const{toggleResource:Y}=await import("./resourceService-BFMkDDIh.js");return{toggleResource:Y}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),G=await F(s.name,x,w);G.success?(p(n(w?"tool.enableSuccess":"tool.disableSuccess",{name:x}),"success"),i==null||i()):p(G.error||n("tool.toggleFailed"),"error")}catch(F){console.error(F),p(n("tool.toggleFailed"),"error")}},me=(x,w,F)=>{p(F!=null&&F.restored?n("tool.restoreDefaultSuccess"):n("tool.descriptionUpdateSuccess"),"success"),i==null||i()},ue=(x,w,F)=>{p(F!=null&&F.restored?n("prompt.restoreDefaultSuccess"):n("prompt.descriptionUpdateSuccess"),"success"),i==null||i()},pe=async(x,w,F)=>{try{const{updateResourceDescription:G,resetResourceDescription:Y}=await ge(async()=>{const{updateResourceDescription:Le,resetResourceDescription:qe}=await import("./resourceService-BFMkDDIh.js");return{updateResourceDescription:Le,resetResourceDescription:qe}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),he=F!=null&&F.restored?await Y(s.name,x):await G(s.name,x,w);he.success?(p(F!=null&&F.restored?n("builtinResources.restoreDefaultSuccess"):n("builtinResources.descriptionUpdateSuccess"),"success"),i==null||i()):p(he.error||(F!=null&&F.restored?n("builtinResources.restoreDefaultFailed"):n("builtinResources.descriptionUpdateFailed")),"error")}catch(G){console.error(G),p(F!=null&&F.restored?n("builtinResources.restoreDefaultFailed"):n("builtinResources.descriptionUpdateFailed"),"error")}};(()=>{var F;const x=s.config;if(!x)return"";if(x.url)return x.url;const w=[];return x.command&&w.push(x.command),(F=x.args)!=null&&F.length&&w.push(...x.args),w.join(" ")})();const _=s.enabled!==!1,H=`${d}/mcp/${s.name}`;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hub-card overflow-visible",style:{marginBottom:10,opacity:_?1:.7},children:[e.jsxs("div",{className:"grid items-center gap-3 px-4 py-3 cursor-pointer hover:bg-[var(--hub-surface-hover)] transition-colors",style:{gridTemplateColumns:"minmax(220px,1.6fr) 130px 90px 140px 80px 36px"},onClick:()=>I(!j),children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx(ye,{size:12,style:{color:"var(--hub-ink-3)",transform:j?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0}}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"hub-mono truncate",style:{fontSize:13.5,color:_?"var(--hub-ink)":"var(--hub-ink-3)"},children:s.name}),s.error&&e.jsxs("div",{className:"relative",ref:c,children:[e.jsx("button",{onClick:x=>{x.stopPropagation(),q(w=>!w)},className:"text-[var(--hub-err)] hover:opacity-80","aria-label":n("server.viewErrorDetails"),children:e.jsx(je,{size:14})}),B&&e.jsxs("div",{className:"absolute z-20 mt-1.5 hub-card",style:{left:0,top:"100%",width:460,maxHeight:320,overflow:"hidden",boxShadow:"0 8px 24px rgba(0,0,0,0.08)"},onClick:x=>x.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",style:{borderBottom:"1px solid var(--hub-line-2)"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--hub-err)"},children:n("server.errorDetails")}),e.jsx("button",{onClick:J,className:"hub-icon-btn sm",title:n("common.copy"),children:K?e.jsx(ce,{size:12,className:"text-[var(--hub-ok)]"}):e.jsx(fe,{size:12})})]}),e.jsx("button",{onClick:()=>q(!1),className:"hub-icon-btn sm","aria-label":n("app.closeButton"),children:e.jsx(ve,{size:12})})]}),e.jsx("div",{className:"p-3 overflow-auto hub-mono",style:{maxHeight:260,fontSize:12},children:e.jsx("pre",{className:"whitespace-pre-wrap break-words m-0",style:{color:"var(--hub-ink-2)"},children:s.error})})]})]})]}),((ie=s.config)==null?void 0:ie.description)&&e.jsx("div",{className:"text-[11.5px] truncate",style:{color:"var(--hub-ink-3)",marginTop:1},title:s.config.description,children:s.config.description})]})]}),e.jsx("div",{children:e.jsx(Ze,{status:s.status,enabled:s.enabled,onAuthClick:U})}),e.jsx("div",{children:(xe=s.config)!=null&&xe.type?e.jsx("span",{className:"hub-tag",children:vs(n,s.config.type)}):e.jsx("span",{style:{color:"var(--hub-ink-3)",fontSize:12},children:"—"})}),e.jsxs("div",{className:"flex items-center gap-2.5 hub-num hub-mono",style:{color:"var(--hub-ink-2)",fontSize:12},title:`T:${a}/${N} · P:${l}/${u} · R:${C}/${f}`,children:[e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(ze,{size:11,style:{color:"var(--hub-ink-3)",flexShrink:0}}),e.jsx("span",{children:N===0?"0":`${a}/${N}`})]}),e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Te,{size:11,style:{color:"var(--hub-ink-3)",flexShrink:0}}),e.jsx("span",{children:u===0?"0":`${l}/${u}`})]}),e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(De,{size:11,style:{color:"var(--hub-ink-3)",flexShrink:0}}),e.jsx("span",{children:f===0?"0":`${C}/${f}`})]})]}),e.jsx("div",{className:"flex items-center justify-center",children:e.jsx("button",{type:"button",className:"hub-switch"+(_?" on":""),onClick:D,disabled:g,"aria-label":n(_?"server.disable":"server.enable")})}),e.jsxs("div",{className:"relative",ref:h,children:[e.jsx("button",{className:"hub-icon-btn",onClick:x=>{x.stopPropagation(),W(w=>!w)},"aria-label":"More",children:e.jsx(Ye,{size:14})}),A&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 hub-card",style:{minWidth:160,padding:4},onClick:x=>x.stopPropagation(),children:[e.jsxs("button",{onClick:x=>{x.stopPropagation(),W(!1),t(s)},className:"flex items-center gap-2 w-full px-2.5 py-1.5 text-[13px] rounded-md hover:bg-[var(--hub-surface-hover)] text-left",style:{color:"var(--hub-ink)"},children:[e.jsx(es,{size:13})," ",n("server.edit")]}),e.jsxs("button",{onClick:S,className:"flex items-center gap-2 w-full px-2.5 py-1.5 text-[13px] rounded-md hover:bg-[var(--hub-surface-hover)] text-left",style:{color:"var(--hub-ink)"},children:[e.jsx(fe,{size:13})," ",n("server.copy")]}),b&&e.jsxs("button",{onClick:V,disabled:R||g||!_,className:"flex items-center gap-2 w-full px-2.5 py-1.5 text-[13px] rounded-md hover:bg-[var(--hub-surface-hover)] text-left disabled:opacity-50 disabled:cursor-not-allowed",style:{color:"var(--hub-ink)"},children:[e.jsx(Ne,{size:13})," ",n("server.reload")]}),e.jsx("div",{style:{height:1,background:"var(--hub-line-2)",margin:"4px 0"}}),e.jsxs("button",{onClick:x=>{x.stopPropagation(),W(!1),E(!0)},className:"flex items-center gap-2 w-full px-2.5 py-1.5 text-[13px] rounded-md hover:bg-[var(--hub-surface-hover)] text-left",style:{color:"var(--hub-err)"},children:[e.jsx(ss,{size:13})," ",n("server.delete")]})]})]})]}),j&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",background:"var(--hub-bg-2)",padding:"14px 16px 16px 38px"},children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[[{key:"tools",icon:e.jsx(ze,{size:12}),label:n("server.tools"),count:N,enabled:a},{key:"prompts",icon:e.jsx(Te,{size:12}),label:n("server.prompts"),count:u,enabled:l},{key:"resources",icon:e.jsx(De,{size:12}),label:n("nav.resources"),count:f,enabled:C}].map(x=>{const w=y===x.key;return e.jsxs("button",{onClick:()=>$(w?null:x.key),className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[12px] transition-colors hover:bg-[var(--hub-surface-hover)]",style:{background:w?"var(--hub-surface)":"transparent",border:"1px solid "+(w?"var(--hub-line)":"transparent"),color:w?"var(--hub-ink)":"var(--hub-ink-2)"},children:[x.icon,e.jsx("span",{children:x.label}),e.jsx("span",{className:"hub-mono hub-num",style:{color:"var(--hub-ink-3)",fontSize:11},children:x.count===0?"0":`${x.enabled}/${x.count}`})]},x.key)}),e.jsx("div",{className:"ml-auto flex-shrink-0",children:e.jsxs("div",{className:"hub-endpoint",style:{height:26},children:[e.jsx("div",{className:"hub-endpoint-label",children:"/mcp/"}),e.jsx("div",{className:"hub-endpoint-url",title:H,style:{maxWidth:200},children:s.name}),e.jsx("button",{type:"button",className:"hub-endpoint-copy",onClick:async x=>{x.stopPropagation();const w=await k(H);p(w?n("common.copySuccess")||"Copied":n("common.copyFailed")||"Failed",w?"success":"error")},title:n("common.copy"),children:e.jsx(fe,{size:12})})]})})]}),y==="tools"&&s.tools&&e.jsx("div",{className:"space-y-3 mt-2",children:s.tools.map((x,w)=>e.jsx(hs,{server:s.name,tool:x,onToggle:se,onDescriptionUpdate:me},w))}),y==="prompts"&&s.prompts&&e.jsx("div",{className:"space-y-3 mt-2",children:s.prompts.map((x,w)=>e.jsx(js,{server:s.name,prompt:x,onToggle:te,onDescriptionUpdate:ue},w))}),y==="resources"&&s.resources&&e.jsx("div",{className:"mt-2",children:s.resources.length===0?e.jsx("div",{className:"text-sm",style:{color:"var(--hub-ink-3)"},children:n("builtinResources.noResources")}):e.jsx("div",{className:"space-y-3",children:s.resources.map((x,w)=>e.jsx(ys,{resource:x,onToggle:de,onDescriptionUpdate:pe},`${x.uri}-${w}`))})})]})]}),e.jsx(os,{isOpen:v,onClose:()=>E(!1),onConfirm:()=>{o(s.name),E(!1)},serverName:s.name})]})},ws=({onAdd:s})=>{const{t:o}=Q(),[t,r]=m.useState(!1),[i,b]=m.useState(null),[n,p]=m.useState(!1),[T,P]=m.useState(null),[d,j]=m.useState([]),I=()=>{r(!t),b(null),p(!1),P(null)},y=async()=>{T&&(await $(T),p(!1),P(null))},$=async E=>{try{b(null);const g=await ee("/servers",E);if(!g.success){g&&g.message?b(g.message):b(o("server.addError"));return}r(!1),s()}catch(g){console.error("Error adding server:",g),navigator.onLine?g instanceof TypeError&&(g.message.includes("NetworkError")||g.message.includes("Failed to fetch"))?b(o("errors.serverConnection")):b(o("errors.serverAdd")):b(o("errors.network"))}},v=async E=>{try{const g=ls(E);g.length>0?(j(g),P(E),p(!0)):await $(E)}catch(g){console.error("Error processing server submission:",g),b(o("errors.serverAdd"))}};return e.jsxs("div",{children:[e.jsxs("button",{onClick:I,className:"hub-btn primary",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})}),o("server.add")]}),t&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(_e,{onSubmit:v,onCancel:I,modalTitle:o("server.addServer"),formError:i})}),n&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-[60] flex items-center justify-center p-4",children:e.jsxs("div",{className:"hub-card p-6 w-full max-w-md",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:o("server.confirmVariables")}),e.jsx("p",{className:"text-gray-600 mb-4",children:o("server.variablesDetected")}),e.jsx("div",{className:"bg-yellow-50 border border-yellow-200 rounded p-3 mb-4",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-yellow-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"ml-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-yellow-800",children:[o("server.detectedVariables"),":"]}),e.jsx("ul",{className:"mt-1 text-sm text-yellow-700",children:d.map((E,g)=>e.jsxs("li",{className:"font-mono",children:["$",`{${E}}`]},g))})]})]})}),e.jsx("p",{className:"text-gray-600 text-sm mb-6",children:o("server.confirmVariablesMessage")}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>{p(!1),P(null)},className:"hub-btn",children:o("common.cancel")}),e.jsx("button",{onClick:y,className:"hub-btn primary",children:o("server.confirmAndAdd")})]})]})})]})},ks=({server:s,onEdit:o,onCancel:t})=>{const{t:r}=Q(),[i,b]=m.useState(null),n=async p=>{try{b(null);const T=encodeURIComponent(s.name),P=p.name&&p.name!==s.name,d={config:p.config,...P?{newName:p.name}:{}},j=await be(`/servers/${T}`,d);if(!j.success){j&&j.message?b(j.message):b(r("server.updateError",{serverName:s.name}));return}o()}catch(T){console.error("Error updating server:",T),navigator.onLine?T instanceof TypeError&&(T.message.includes("NetworkError")||T.message.includes("Failed to fetch"))?b(r("errors.serverConnection")):b(r("errors.serverUpdate",{serverName:s.name})):b(r("errors.network"))}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(_e,{onSubmit:n,onCancel:t,initialData:s,modalTitle:r("server.editTitle",{serverName:s.name}),formError:i})})},Cs=({onSuccess:s,onCancel:o})=>{const{t}=Q(),[r,i]=m.useState(!1),[b,n]=m.useState(!1),[p,T]=m.useState(null),[P,d]=m.useState(null),[j,I]=m.useState(!1),[y,$]=m.useState(null),[v,E]=m.useState(""),[g,O]=m.useState(!1),[R,z]=m.useState(""),A=a=>{a.preventDefault(),i(!0)},W=a=>{a.preventDefault(),i(!1)},B=a=>{a.preventDefault(),i(!1);const u=a.dataTransfer.files;if(u.length>0){const l=u[0];l.name.endsWith(".mcpb")?(d(l),T(null)):T(t("mcpb.invalidFileType"))}},q=a=>{const u=a.target.files;if(u&&u.length>0){const l=u[0];l.name.endsWith(".mcpb")?(d(l),T(null)):T(t("mcpb.invalidFileType"))}},K=async()=>{if(!P){T(t("mcpb.noFileSelected"));return}n(!0),T(null);try{const a=new FormData;a.append("mcpbFile",P);const u=await Ke(Xe("/mcpb/upload"),{method:"POST",body:a}),l=await u.json();if(!u.ok)throw new Error(l.message||`HTTP error! Status: ${u.status}`);if(l.success&&l.data)$(l.data.manifest),E(l.data.extractDir),I(!0);else throw new Error(l.message||t("mcpb.uploadFailed"))}catch(a){console.error("MCPB upload error:",a),T(a instanceof Error?a.message:t("mcpb.uploadFailed"))}finally{n(!1)}},M=async(a,u=!1)=>{var l;n(!0),T(null);try{const f=N(y,v,a);if(!u){const D=await Ge("/servers");if(D.success&&((l=D.data)==null?void 0:l.find(k=>k.name===a))){z(a),O(!0),n(!1);return}}let C;if(u?C=await be(`/servers/${encodeURIComponent(a)}`,{name:a,config:f}):C=await ee("/servers",{name:a,config:f}),C.success)s(f);else throw new Error(C.message||t("mcpb.installFailed"))}catch(f){console.error("MCPB install error:",f),T(f instanceof Error?f.message:t("mcpb.installFailed")),n(!1)}},h=()=>{O(!1),R&&M(R,!0)},c=()=>{O(!1),z(""),n(!1)},N=(a,u,l)=>{var D;const f=((D=a.server)==null?void 0:D.mcp_config)||{},C={type:"stdio",command:f.command||"node",args:(f.args||[]).map(V=>V.replace("${__dirname}",u))};return f.env&&Object.keys(f.env).length>0&&(C.env={...f.env},Object.keys(C.env).forEach(V=>{typeof C.env[V]=="string"&&(C.env[V]=C.env[V].replace("${__dirname}",u))})),C};return j&&y?e.jsxs(e.Fragment,{children:[e.jsx(is,{isOpen:g,onClose:c,onConfirm:h,title:t("mcpb.serverExistsTitle"),message:t("mcpb.serverExistsConfirm",{serverName:R}),confirmText:t("mcpb.override"),cancelText:t("common.cancel"),variant:"warning"}),e.jsx("div",{className:`fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4 ${g?"opacity-50 pointer-events-none":""}`,children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 w-full max-w-3xl max-h-screen overflow-y-auto",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:t("mcpb.installServer")}),e.jsx("button",{onClick:o,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),p&&e.jsx("div",{className:"mb-4 bg-red-50 border-l-4 border-red-500 p-4 rounded",children:e.jsx("p",{className:"text-red-700",children:p})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 p-4 rounded-lg",children:[e.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:t("mcpb.extensionInfo")}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.name"),":"]})," ",y.display_name||y.name]}),e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.version"),":"]})," ",y.version]}),e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.description"),":"]})," ",y.description]}),y.author&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.author"),":"]})," ",y.author.name]}),y.tools&&y.tools.length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.tools"),":"]}),e.jsx("ul",{className:"list-disc list-inside ml-4",children:y.tools.map((a,u)=>e.jsxs("li",{children:[a.name," - ",a.description]},u))})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:t("mcpb.serverName")}),e.jsx("input",{type:"text",id:"serverName",defaultValue:y.name,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 form-input",placeholder:t("mcpb.serverNamePlaceholder")})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:o,disabled:b,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:()=>{const a=document.getElementById("serverName"),u=(a==null?void 0:a.value.trim())||y.name;M(u)},disabled:b,className:"hub-btn primary",children:b?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t("mcpb.installing")]}):t("mcpb.install")})]})]})]})})]}):e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 w-full max-w-lg",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:t("mcpb.uploadTitle")}),e.jsx("button",{onClick:o,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),p&&e.jsx("div",{className:"mb-4 bg-red-50 border-l-4 border-red-500 p-4 rounded",children:e.jsx("p",{className:"text-red-700",children:p})}),e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-8 text-center transition-colors ${r?"border-blue-500 bg-blue-50":P?"border-gray-500 ":"border-gray-300 hover:border-gray-400"}`,onDragOver:A,onDragLeave:W,onDrop:B,children:[P?e.jsxs("div",{className:"space-y-2",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-green-200",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("p",{className:"text-sm text-gray-900 font-medium",children:P.name}),e.jsxs("p",{className:"text-xs text-gray-500",children:[(P.size/1024/1024).toFixed(2)," MB"]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-900",children:t("mcpb.dropFileHere")}),e.jsx("p",{className:"text-xs text-gray-500",children:t("mcpb.orClickToSelect")})]})]}),e.jsx("input",{type:"file",accept:".mcpb",onChange:q,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"})]}),e.jsxs("div",{className:"mt-6 flex justify-end space-x-4",children:[e.jsx("button",{onClick:o,disabled:b,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:K,disabled:!P||b,className:"hub-btn primary flex items-center",children:b?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t("mcpb.uploading")]}):t("mcpb.upload")})]})]})})},Ss=({onSuccess:s,onCancel:o})=>{const{t}=Q(),[r,i]=m.useState(""),[b,n]=m.useState(null),[p,T]=m.useState(!1),[P,d]=m.useState(null),j=`{
|
|
7
|
-
"mcpServers": {
|
|
8
|
-
"stdio-server-example": {
|
|
9
|
-
"command": "npx",
|
|
10
|
-
"args": ["-y", "mcp-server-example"]
|
|
11
|
-
},
|
|
12
|
-
"sse-server-example": {
|
|
13
|
-
"type": "sse",
|
|
14
|
-
"url": "http://localhost:3000"
|
|
15
|
-
},
|
|
16
|
-
"http-server-example": {
|
|
17
|
-
"type": "streamable-http",
|
|
18
|
-
"url": "http://localhost:3001",
|
|
19
|
-
"headers": {
|
|
20
|
-
"Content-Type": "application/json",
|
|
21
|
-
"Authorization": "Bearer your-token"
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"openapi-server-example": {
|
|
25
|
-
"type": "openapi",
|
|
26
|
-
"openapi": {
|
|
27
|
-
"url": "https://petstore.swagger.io/v2/swagger.json"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
Supports: STDIO, SSE, HTTP (streamable-http), OpenAPI
|
|
34
|
-
All servers will be imported in a single efficient batch operation.`,I=v=>{try{const E=JSON.parse(v.trim());return!E.mcpServers||typeof E.mcpServers!="object"?(n(t("jsonImport.invalidFormat")),null):E}catch{return n(t("jsonImport.parseError")),null}},y=()=>{n(null);const v=I(r);if(!v)return;const E=Object.entries(v.mcpServers).map(([g,O])=>{const R={};return O.type==="sse"||O.type==="streamable-http"?(R.type=O.type,R.url=O.url,O.headers&&(R.headers=O.headers)):O.type==="openapi"?(R.type="openapi",R.openapi=O.openapi):(R.type="stdio",R.command=O.command,R.args=O.args||[],O.env&&(R.env=O.env)),{name:g,config:R}});d(E)},$=async()=>{if(P){T(!0),n(null);try{const v=await ee("/servers/batch",{servers:P});if(v.success&&v.data){const{successCount:E,failureCount:g,results:O}=v.data;if(g>0){const R=O.filter(z=>!z.success).map(z=>`${z.name}: ${z.message||t("jsonImport.addFailed")}`);n(t("jsonImport.partialSuccess",{count:E,total:P.length})+`
|
|
35
|
-
`+R.join(`
|
|
36
|
-
`))}E>0&&s()}else n(v.message||t("jsonImport.importFailed"))}catch(v){console.error("Import error:",v),n(t("jsonImport.importFailed"))}finally{T(!1)}}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:t("jsonImport.title")}),e.jsx("button",{onClick:o,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),b&&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:b})}),P?e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-3",children:t("jsonImport.previewTitle")}),e.jsx("div",{className:"space-y-3",children:P.map((v,E)=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 p-4 rounded-lg border border-gray-200 dark:border-gray-700",children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-gray-900",children:v.name}),e.jsxs("div",{className:"mt-2 space-y-1 text-sm text-gray-600",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.type"),":"]})," ",v.config.type||"stdio"]}),v.config.command&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.command"),":"]})," ",v.config.command]}),v.config.args&&v.config.args.length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.arguments"),":"]})," ",v.config.args.join(" ")]}),v.config.url&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.url"),":"]})," ",v.config.url]}),v.config.env&&Object.keys(v.config.env).length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.envVars"),":"]})," ",Object.keys(v.config.env).join(", ")]}),v.config.headers&&Object.keys(v.config.headers).length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.headers"),":"]})," ",Object.keys(v.config.headers).join(", ")]})]})]})})},E))})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:()=>d(null),disabled:p,className:"hub-btn",children:t("common.back")}),e.jsx("button",{onClick:$,disabled:p,className:"hub-btn primary",children:p?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t("jsonImport.importing")]}):t("jsonImport.import")})]})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:t("jsonImport.inputLabel")}),e.jsx("textarea",{value:r,onChange:v=>i(v.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:j}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:t("jsonImport.inputHelp")})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:o,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:y,disabled:!r.trim(),className:"hub-btn primary",children:t("jsonImport.preview")})]})]})]})})},Js=()=>{const{t:s}=Q(),o=He(),{servers:t,allServers:r,error:i,setError:b,isLoading:n,pagination:p,currentPage:T,serversPerPage:P,setCurrentPage:d,setServersPerPage:j,handleServerAdd:I,handleServerEdit:y,handleServerRemove:$,handleServerToggle:v,handleServerReload:E,triggerRefresh:g}=ds({refreshOnMount:!0}),[O,R]=m.useState(null),[z,A]=m.useState(!1),[W,B]=m.useState(!1),[q,K]=m.useState(!1),[M,h]=m.useState("all"),[c,N]=m.useState(""),a=m.useMemo(()=>({all:r.length,online:r.filter(C=>C.status==="connected").length,issues:r.filter(C=>C.status!=="connected"&&C.enabled!==!1).length}),[r]),u=m.useMemo(()=>{const C=c.trim().toLowerCase();return t.filter(D=>{var k,J;return M==="online"&&D.status!=="connected"||M==="issues"&&(D.status==="connected"||D.enabled===!1)?!1:C?(D.name+" "+(((k=D.config)==null?void 0:k.description)||"")+" "+(((J=D.tools)==null?void 0:J.map(S=>S.name).join(" "))||"")).toLowerCase().includes(C):!0})},[t,M,c]),l=async C=>{const D=await y(C);D&&R(D)},f=async()=>{A(!0);try{g(),await new Promise(C=>setTimeout(C,400))}finally{A(!1)}};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-end justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"hub-h1",children:s("pages.servers.title")}),e.jsxs("p",{className:"hub-sub",children:[e.jsx("span",{className:"hub-num",children:a.all})," ",s("nav.servers").toLowerCase()," ·"," ",e.jsx("span",{className:"hub-num",children:a.online})," ",s("status.online")," ·"," ",e.jsx("span",{className:"hub-num",children:a.issues})," ",s("common.inactive")||"issues"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{className:"hub-btn",onClick:()=>o("/market"),children:[e.jsx(ts,{size:13})," ",s("nav.market")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>K(!0),children:[e.jsx(rs,{size:13})," ",s("jsonImport.button")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>B(!0),children:[e.jsx(ns,{size:13})," ",s("mcpb.upload")]}),e.jsxs("button",{className:"hub-btn",onClick:f,disabled:z,"aria-label":s("common.refresh"),children:[e.jsx(Ne,{size:13,className:z?"animate-spin":""}),s("common.refresh")]}),e.jsx(ws,{onAdd:I})]})]}),i&&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(je,{size:14,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate text-[13px]",children:i})]}),e.jsx("button",{className:"hub-icon-btn sm",onClick:()=>b(null),"aria-label":s("app.closeButton"),children:e.jsx(ve,{size:13})})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-4 flex-wrap",children:[e.jsx("div",{className:"hub-card flex items-center",style:{padding:2,borderRadius:7,background:"var(--hub-surface)"},children:[["all",s("common.all")||"All",a.all],["online",s("status.online"),a.online],["issues",s("common.inactive")||"Issues",a.issues]].map(([C,D,V])=>e.jsxs("button",{onClick:()=>h(C),className:"inline-flex items-center gap-1.5 px-3 text-[12px]",style:{height:24,borderRadius:5,background:M===C?"var(--hub-bg-2)":"transparent",color:M===C?"var(--hub-ink)":"var(--hub-ink-3)",border:"1px solid "+(M===C?"var(--hub-line)":"transparent")},children:[D,e.jsx("span",{className:"hub-mono",style:{fontSize:11,color:"var(--hub-ink-3)"},children:V})]},C))}),e.jsxs("div",{className:"hub-card flex items-center gap-2 px-2.5 flex-1",style:{height:30,background:"var(--hub-surface)",maxWidth:360},children:[e.jsx(as,{size:13,style:{color:"var(--hub-ink-3)"}}),e.jsx("input",{value:c,onChange:C=>N(C.target.value),className:"flex-1 bg-transparent outline-none text-[13px]",style:{color:"var(--hub-ink)"},placeholder:s("market.searchPlaceholder")||"Search…"}),c&&e.jsx("button",{onClick:()=>N(""),className:"hub-icon-btn sm",children:e.jsx(ve,{size:11})})]}),e.jsxs("div",{className:"ml-auto hub-mono text-[12px]",style:{color:"var(--hub-ink-3)"},children:[u.length,"/",t.length]})]}),n&&t.length===0?e.jsx("div",{className:"hub-card p-6 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(Ne,{size:20,className:"animate-spin",style:{color:"var(--hub-ink-3)"}}),e.jsx("p",{style:{color:"var(--hub-ink-3)"},children:s("app.loading")})]})}):u.length===0?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:e.jsx("p",{children:t.length===0?s("app.noServers"):s("market.noServers")})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col",children:u.map(C=>e.jsx(Ns,{server:C,onRemove:$,onEdit:l,onToggle:v,onRefresh:g,onReload:E},C.name))}),e.jsxs("div",{className:"flex items-center mt-4 text-[12px]",style:{color:"var(--hub-ink-3)"},children:[e.jsx("div",{className:"flex-[2]",children:p?s("common.showing",{start:(p.page-1)*p.limit+1,end:Math.min(p.page*p.limit,p.total),total:p.total}):s("common.showing",{start:1,end:t.length,total:t.length})}),e.jsx("div",{className:"flex-[4] flex justify-center",children:p&&p.totalPages>1&&e.jsx(cs,{currentPage:T,totalPages:p.totalPages,onPageChange:d,disabled:n})}),e.jsxs("div",{className:"flex-[2] flex items-center justify-end gap-2",children:[e.jsxs("label",{htmlFor:"perPage",children:[s("common.itemsPerPage"),":"]}),e.jsxs("select",{id:"perPage",value:P,onChange:C=>j(Number(C.target.value)),disabled:n,className:"hub-input",style:{height:26,width:70,padding:"0 6px",fontSize:12},children:[e.jsx("option",{value:5,children:"5"}),e.jsx("option",{value:10,children:"10"}),e.jsx("option",{value:20,children:"20"}),e.jsx("option",{value:50,children:"50"})]})]})]})]}),O&&e.jsx(ks,{server:O,onEdit:()=>{R(null),g()},onCancel:()=>R(null)}),W&&e.jsx(Cs,{onSuccess:()=>{B(!1),g()},onCancel:()=>B(!1)}),q&&e.jsx(Ss,{onSuccess:()=>{K(!1),g()},onCancel:()=>K(!1)})]})};export{Js as default};
|
|
37
|
-
//# sourceMappingURL=ServersPage-DtnlfwJF.js.map
|