libre-webui 0.36.0 → 0.37.1
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.md +59 -0
- package/backend/dist/cordis/contracts.d.ts +270 -0
- package/backend/dist/cordis/contracts.d.ts.map +1 -0
- package/backend/dist/cordis/contracts.js +32 -0
- package/backend/dist/cordis/contracts.js.map +1 -0
- package/backend/dist/cordis/dsh/chat-model.d.ts +16 -0
- package/backend/dist/cordis/dsh/chat-model.d.ts.map +1 -0
- package/backend/dist/cordis/dsh/chat-model.js +104 -0
- package/backend/dist/cordis/dsh/chat-model.js.map +1 -0
- package/backend/dist/cordis/dsh/engine-plugin.d.ts +186 -0
- package/backend/dist/cordis/dsh/engine-plugin.d.ts.map +1 -0
- package/backend/dist/cordis/dsh/engine-plugin.js +1116 -0
- package/backend/dist/cordis/dsh/engine-plugin.js.map +1 -0
- package/backend/dist/cordis/dsh/librewebui-llm-adapter.d.ts +175 -0
- package/backend/dist/cordis/dsh/librewebui-llm-adapter.d.ts.map +1 -0
- package/backend/dist/cordis/dsh/librewebui-llm-adapter.js +480 -0
- package/backend/dist/cordis/dsh/librewebui-llm-adapter.js.map +1 -0
- package/backend/dist/cordis/dsh/model-identity.d.ts +12 -0
- package/backend/dist/cordis/dsh/model-identity.d.ts.map +1 -0
- package/backend/dist/cordis/dsh/model-identity.js +87 -0
- package/backend/dist/cordis/dsh/model-identity.js.map +1 -0
- package/backend/dist/cordis/dsh/native-provider-client.d.ts +44 -0
- package/backend/dist/cordis/dsh/native-provider-client.d.ts.map +1 -0
- package/backend/dist/cordis/dsh/native-provider-client.js +524 -0
- package/backend/dist/cordis/dsh/native-provider-client.js.map +1 -0
- package/backend/dist/cordis/dsh/native-provider-plugin.d.ts +11 -0
- package/backend/dist/cordis/dsh/native-provider-plugin.d.ts.map +1 -0
- package/backend/dist/cordis/dsh/native-provider-plugin.js +416 -0
- package/backend/dist/cordis/dsh/native-provider-plugin.js.map +1 -0
- package/backend/dist/cordis/dsh/native-provider-protocol.d.ts +37 -0
- package/backend/dist/cordis/dsh/native-provider-protocol.d.ts.map +1 -0
- package/backend/dist/cordis/dsh/native-provider-protocol.js +325 -0
- package/backend/dist/cordis/dsh/native-provider-protocol.js.map +1 -0
- package/backend/dist/cordis/dsh/provider-handler.d.ts +36 -0
- package/backend/dist/cordis/dsh/provider-handler.d.ts.map +1 -0
- package/backend/dist/cordis/dsh/provider-handler.js +582 -0
- package/backend/dist/cordis/dsh/provider-handler.js.map +1 -0
- package/backend/dist/cordis/dsh/session-files.d.ts +9 -0
- package/backend/dist/cordis/dsh/session-files.d.ts.map +1 -0
- package/backend/dist/cordis/dsh/session-files.js +60 -0
- package/backend/dist/cordis/dsh/session-files.js.map +1 -0
- package/backend/dist/cordis/dsh/session-settings.d.ts +15 -0
- package/backend/dist/cordis/dsh/session-settings.d.ts.map +1 -0
- package/backend/dist/cordis/dsh/session-settings.js +51 -0
- package/backend/dist/cordis/dsh/session-settings.js.map +1 -0
- package/backend/dist/cordis/dsh/work-driver.d.ts +12 -0
- package/backend/dist/cordis/dsh/work-driver.d.ts.map +1 -0
- package/backend/dist/cordis/dsh/work-driver.js +402 -0
- package/backend/dist/cordis/dsh/work-driver.js.map +1 -0
- package/backend/dist/cordis/dsh/workspace-policy.d.ts +10 -0
- package/backend/dist/cordis/dsh/workspace-policy.d.ts.map +1 -0
- package/backend/dist/cordis/dsh/workspace-policy.js +44 -0
- package/backend/dist/cordis/dsh/workspace-policy.js.map +1 -0
- package/backend/dist/cordis/host/composition.d.ts +73 -0
- package/backend/dist/cordis/host/composition.d.ts.map +1 -0
- package/backend/dist/cordis/host/composition.js +205 -0
- package/backend/dist/cordis/host/composition.js.map +1 -0
- package/backend/dist/cordis/host/config.d.ts +159 -0
- package/backend/dist/cordis/host/config.d.ts.map +1 -0
- package/backend/dist/cordis/host/config.js +184 -0
- package/backend/dist/cordis/host/config.js.map +1 -0
- package/backend/dist/cordis/host/host.d.ts +74 -0
- package/backend/dist/cordis/host/host.d.ts.map +1 -0
- package/backend/dist/cordis/host/host.js +420 -0
- package/backend/dist/cordis/host/host.js.map +1 -0
- package/backend/dist/cordis/host/loader-entry.d.ts +41 -0
- package/backend/dist/cordis/host/loader-entry.d.ts.map +1 -0
- package/backend/dist/cordis/host/loader-entry.js +52 -0
- package/backend/dist/cordis/host/loader-entry.js.map +1 -0
- package/backend/dist/cordis/host/model.d.ts +45 -0
- package/backend/dist/cordis/host/model.d.ts.map +1 -0
- package/backend/dist/cordis/host/model.js +54 -0
- package/backend/dist/cordis/host/model.js.map +1 -0
- package/backend/dist/cordis/host/privacy.d.ts +8 -0
- package/backend/dist/cordis/host/privacy.d.ts.map +1 -0
- package/backend/dist/cordis/host/privacy.js +73 -0
- package/backend/dist/cordis/host/privacy.js.map +1 -0
- package/backend/dist/cordis/index.d.ts +14 -0
- package/backend/dist/cordis/index.d.ts.map +1 -0
- package/backend/dist/cordis/index.js +30 -0
- package/backend/dist/cordis/index.js.map +1 -0
- package/backend/dist/cordis/runtime.d.ts +97 -0
- package/backend/dist/cordis/runtime.d.ts.map +1 -0
- package/backend/dist/cordis/runtime.js +231 -0
- package/backend/dist/cordis/runtime.js.map +1 -0
- package/backend/dist/cordis/work-model.d.ts +7 -0
- package/backend/dist/cordis/work-model.d.ts.map +1 -0
- package/backend/dist/cordis/work-model.js +30 -0
- package/backend/dist/cordis/work-model.js.map +1 -0
- package/backend/dist/db.js +1 -1
- package/backend/dist/index.d.ts.map +1 -1
- package/backend/dist/index.js +9 -0
- package/backend/dist/index.js.map +1 -1
- package/backend/dist/main.js +12 -0
- package/backend/dist/main.js.map +1 -1
- package/backend/dist/persistence/extensionTypes.d.ts +2 -0
- package/backend/dist/persistence/extensionTypes.d.ts.map +1 -1
- package/backend/dist/persistence/extensionTypes.js.map +1 -1
- package/backend/dist/persistence/postgresExtensionRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/postgresExtensionRepositories.js +38 -0
- package/backend/dist/persistence/postgresExtensionRepositories.js.map +1 -1
- package/backend/dist/persistence/postgresResourceRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/postgresResourceRepositories.js +6 -1
- package/backend/dist/persistence/postgresResourceRepositories.js.map +1 -1
- package/backend/dist/persistence/resourceTypes.d.ts +3 -1
- package/backend/dist/persistence/resourceTypes.d.ts.map +1 -1
- package/backend/dist/persistence/resourceTypes.js.map +1 -1
- package/backend/dist/persistence/sqliteExtensionRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteExtensionRepositories.js +40 -0
- package/backend/dist/persistence/sqliteExtensionRepositories.js.map +1 -1
- package/backend/dist/persistence/sqliteResourceRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteResourceRepositories.js +7 -1
- package/backend/dist/persistence/sqliteResourceRepositories.js.map +1 -1
- package/backend/dist/routes/agentCli.d.ts.map +1 -1
- package/backend/dist/routes/agentCli.js +34 -2
- package/backend/dist/routes/agentCli.js.map +1 -1
- package/backend/dist/routes/chat.d.ts.map +1 -1
- package/backend/dist/routes/chat.js +9 -1
- package/backend/dist/routes/chat.js.map +1 -1
- package/backend/dist/routes/cordis.d.ts +3 -0
- package/backend/dist/routes/cordis.d.ts.map +1 -0
- package/backend/dist/routes/cordis.js +440 -0
- package/backend/dist/routes/cordis.js.map +1 -0
- package/backend/dist/routes/libreClaw.js +1 -1
- package/backend/dist/routes/libreClaw.js.map +1 -1
- package/backend/dist/routes/work.d.ts.map +1 -1
- package/backend/dist/routes/work.js +23 -8
- package/backend/dist/routes/work.js.map +1 -1
- package/backend/dist/services/agentAccessService.d.ts +4 -0
- package/backend/dist/services/agentAccessService.d.ts.map +1 -1
- package/backend/dist/services/agentAccessService.js +48 -16
- package/backend/dist/services/agentAccessService.js.map +1 -1
- package/backend/dist/services/agentCliService.d.ts +42 -1
- package/backend/dist/services/agentCliService.d.ts.map +1 -1
- package/backend/dist/services/agentCliService.js +206 -7
- package/backend/dist/services/agentCliService.js.map +1 -1
- package/backend/dist/services/agentCliUsage.d.ts +22 -0
- package/backend/dist/services/agentCliUsage.d.ts.map +1 -0
- package/backend/dist/services/agentCliUsage.js +192 -0
- package/backend/dist/services/agentCliUsage.js.map +1 -0
- package/backend/dist/services/authService.d.ts +3 -0
- package/backend/dist/services/authService.d.ts.map +1 -1
- package/backend/dist/services/authService.js +4 -1
- package/backend/dist/services/authService.js.map +1 -1
- package/backend/dist/services/chatGenerationService.d.ts +7 -0
- package/backend/dist/services/chatGenerationService.d.ts.map +1 -1
- package/backend/dist/services/chatGenerationService.js +32 -1
- package/backend/dist/services/chatGenerationService.js.map +1 -1
- package/backend/dist/services/cordisAccessService.d.ts +56 -0
- package/backend/dist/services/cordisAccessService.d.ts.map +1 -0
- package/backend/dist/services/cordisAccessService.js +98 -0
- package/backend/dist/services/cordisAccessService.js.map +1 -0
- package/backend/dist/services/durableChatGenerationService.d.ts.map +1 -1
- package/backend/dist/services/durableChatGenerationService.js +9 -1
- package/backend/dist/services/durableChatGenerationService.js.map +1 -1
- package/backend/dist/services/emailService.d.ts.map +1 -1
- package/backend/dist/services/emailService.js +8 -1
- package/backend/dist/services/emailService.js.map +1 -1
- package/backend/dist/services/pluginService.d.ts.map +1 -1
- package/backend/dist/services/pluginService.js +7 -26
- package/backend/dist/services/pluginService.js.map +1 -1
- package/backend/dist/services/pluginUsageService.d.ts +52 -0
- package/backend/dist/services/pluginUsageService.d.ts.map +1 -1
- package/backend/dist/services/pluginUsageService.js +89 -1
- package/backend/dist/services/pluginUsageService.js.map +1 -1
- package/backend/dist/services/systemSettingsService.d.ts +1 -1
- package/backend/dist/services/systemSettingsService.d.ts.map +1 -1
- package/backend/dist/services/systemSettingsService.js +1 -1
- package/backend/dist/services/systemSettingsService.js.map +1 -1
- package/backend/dist/services/thinkingSummaryService.d.ts +3 -0
- package/backend/dist/services/thinkingSummaryService.d.ts.map +1 -1
- package/backend/dist/services/thinkingSummaryService.js +56 -17
- package/backend/dist/services/thinkingSummaryService.js.map +1 -1
- package/backend/dist/services/titleGenerationService.d.ts +22 -2
- package/backend/dist/services/titleGenerationService.d.ts.map +1 -1
- package/backend/dist/services/titleGenerationService.js +63 -8
- package/backend/dist/services/titleGenerationService.js.map +1 -1
- package/backend/dist/services/workAgentService.d.ts +1 -1
- package/backend/dist/services/workAgentService.d.ts.map +1 -1
- package/backend/dist/services/workAgentService.js +76 -12
- package/backend/dist/services/workAgentService.js.map +1 -1
- package/backend/dist/services/workModelProviderService.d.ts +5 -0
- package/backend/dist/services/workModelProviderService.d.ts.map +1 -1
- package/backend/dist/services/workModelProviderService.js +52 -3
- package/backend/dist/services/workModelProviderService.js.map +1 -1
- package/backend/dist/services/workRuntimeService.d.ts.map +1 -1
- package/backend/dist/services/workRuntimeService.js +4 -1
- package/backend/dist/services/workRuntimeService.js.map +1 -1
- package/backend/dist/services/workTaskService.d.ts.map +1 -1
- package/backend/dist/services/workTaskService.js +6 -6
- package/backend/dist/services/workTaskService.js.map +1 -1
- package/backend/dist/types/work.d.ts +12 -1
- package/backend/dist/types/work.d.ts.map +1 -1
- package/backend/dist/utils/pluginStreamAdapter.d.ts.map +1 -1
- package/backend/dist/utils/pluginStreamAdapter.js +18 -4
- package/backend/dist/utils/pluginStreamAdapter.js.map +1 -1
- package/backend/dist/utils/pluginStreaming.d.ts +6 -0
- package/backend/dist/utils/pluginStreaming.d.ts.map +1 -1
- package/backend/dist/utils/pluginStreaming.js +10 -0
- package/backend/dist/utils/pluginStreaming.js.map +1 -1
- package/backend/dist/utils/smtpClient.d.ts +5 -1
- package/backend/dist/utils/smtpClient.d.ts.map +1 -1
- package/backend/dist/utils/smtpClient.js +29 -3
- package/backend/dist/utils/smtpClient.js.map +1 -1
- package/backend/dist/websocketServer.d.ts.map +1 -1
- package/backend/dist/websocketServer.js +4 -0
- package/backend/dist/websocketServer.js.map +1 -1
- package/backend/package.json +37 -2
- package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
- package/frontend/dist/artifact-runtime/framer-motion.js +3 -3
- package/frontend/dist/artifact-runtime/lucide-react.js +1 -1
- package/frontend/dist/artifact-runtime/react.js +5 -5
- package/frontend/dist/artifact-runtime/recharts.js +45 -45
- package/frontend/dist/assets/index-BrDSO609.js +20 -0
- package/frontend/dist/assets/index-C8_AByBq.css +1 -0
- package/frontend/dist/index.html +33 -31
- package/frontend/dist/js/{ArtifactContainer-B8tyPtWd.js → ArtifactContainer-B1-GVzVf.js} +1 -1
- package/frontend/dist/js/{ArtifactDemoPage-BwRfWoSK.js → ArtifactDemoPage-goftRHdk.js} +1 -1
- package/frontend/dist/js/{ArtifactSandboxFrame-Ctcwt_l2.js → ArtifactSandboxFrame-_8RA8_JV.js} +1 -1
- package/frontend/dist/js/ArtifactSlideOutPanel-DlkOZI5N.js +1 -0
- package/frontend/dist/js/{AutomationModal-mTYs9LrJ.js → AutomationModal-BaaxZF1M.js} +1 -1
- package/frontend/dist/js/AutomationsPage-DY2x7zVm.js +1 -0
- package/frontend/dist/js/{AvatarUpload-wWUAi3e2.js → AvatarUpload-CH_n1Ef0.js} +1 -1
- package/frontend/dist/js/{Button-ZQ6BePid.js → Button-CGMYia4g.js} +1 -1
- package/frontend/dist/js/{CalendarPage-Ch4racU2.js → CalendarPage-DLo5nm3Q.js} +1 -1
- package/frontend/dist/js/ChannelsPage-DnQI7mzq.js +1 -0
- package/frontend/dist/js/ChatPage-BaDkJnEC.js +14 -0
- package/frontend/dist/js/ConnectModels-B4dGb5yc.js +1 -0
- package/frontend/dist/js/CordisPage-CPiYn2Bx.js +1 -0
- package/frontend/dist/js/{EvaluationsPage-DHPnNBkW.js → EvaluationsPage-DpdGpd7x.js} +2 -2
- package/frontend/dist/js/{FirstTimeSetup-CoF83yY8.js → FirstTimeSetup-By8OE1JS.js} +1 -1
- package/frontend/dist/js/GalleryPage-ByZyIhZQ.js +1 -0
- package/frontend/dist/js/HomePage-Btc-Mvin.js +1 -0
- package/frontend/dist/js/{LanguageSwitcher-CogfczNm.js → LanguageSwitcher-B3CxRW6J.js} +1 -1
- package/frontend/dist/js/LibreClawPage-3Sonm1gu.js +1 -0
- package/frontend/dist/js/{Logo-C9fsEUaY.js → Logo-HZvdAk2c.js} +1 -1
- package/frontend/dist/js/{LogoMark-Cvu5CQOW.js → LogoMark-GJnfMXsk.js} +1 -1
- package/frontend/dist/js/{ModelManagerModals-Bc2Woor7.js → ModelManagerModals-Bk6OQzJI.js} +1 -1
- package/frontend/dist/js/NotesPage-lFhfjMqJ.js +3 -0
- package/frontend/dist/js/{OptimizedSyntaxHighlighter-aKWyHj_c.js → OptimizedSyntaxHighlighter-CzzV6ONG.js} +1 -1
- package/frontend/dist/js/OptimizedSyntaxHighlighter-ajqwyBQm.js +1 -0
- package/frontend/dist/js/{PasswordStrengthMeter-BJr4eBbo.js → PasswordStrengthMeter-DasfJa4P.js} +1 -1
- package/frontend/dist/js/{PersonasPage-ff5opf9B.js → PersonasPage-nOThOpXp.js} +2 -2
- package/frontend/dist/js/PluginUsagePage-BRbHeRf7.js +1 -0
- package/frontend/dist/js/{RichMessageContent-BNNylVAb.js → RichMessageContent-BZ7KKJKK.js} +2 -2
- package/frontend/dist/js/RichMessageContent-oyydJjgc.js +1 -0
- package/frontend/dist/js/SettingsModal-VpsAx2Ns.js +19 -0
- package/frontend/dist/js/{SettingsToggle-CKLHOUt-.js → SettingsToggle-oxvw7ulA.js} +1 -1
- package/frontend/dist/js/{ShareDialog-DykD70uB.js → ShareDialog-CnxPGPb_.js} +1 -1
- package/frontend/dist/js/SystemPage-D2ikvhDp.js +1 -0
- package/frontend/dist/js/{TurnstileWidget-BO2ceTt8.js → TurnstileWidget-CVepEMEQ.js} +1 -1
- package/frontend/dist/js/{UserManagementPage-Ch-PvYQ9.js → UserManagementPage-2yHv89ZA.js} +1 -1
- package/frontend/dist/js/UserManagementPanel-vxpiyiTZ.js +1 -0
- package/frontend/dist/js/{WhatsNewModal-Bu4H4MEb.js → WhatsNewModal-DAAFzY0d.js} +1 -1
- package/frontend/dist/js/WorkPage-BYpYD9mr.js +8 -0
- package/frontend/dist/js/api-C0ligMmL.js +1 -0
- package/frontend/dist/js/api-CVUaOaq4.js +14 -0
- package/frontend/dist/js/{appNavigation-CVsQuDI1.js → appNavigation-CqtrZ9bm.js} +1 -1
- package/frontend/dist/js/{appStore-Din-tTD9.js → appStore-Biw63DtJ.js} +2 -2
- package/frontend/dist/js/appVersion-D78eXAb-.js +1 -0
- package/frontend/dist/js/ar-Cq-DrSYL.js +2 -0
- package/frontend/dist/js/authStore-2DsDTcIu.js +1 -0
- package/frontend/dist/js/{authStore-Cm8P6rYs.js → authStore-C5qKrmn4.js} +3 -3
- package/frontend/dist/js/bn-BqxLh-KL.js +2 -0
- package/frontend/dist/js/chatStore-DQhEqb9F.js +3 -0
- package/frontend/dist/js/client-gf5bjBrn.js +2 -0
- package/frontend/dist/js/composerStyles-C83jssgZ.js +1 -0
- package/frontend/dist/js/{config-DHea4b8N.js → config-CNvgxwAm.js} +1 -1
- package/frontend/dist/js/cordisApi-BYjA4EOQ.js +2 -0
- package/frontend/dist/js/cs-D2DDNZf-.js +2 -0
- package/frontend/dist/js/da-BciY-TSG.js +2 -0
- package/frontend/dist/js/de-DjU_eXQ-.js +2 -0
- package/frontend/dist/js/es-ChIEs80I.js +2 -0
- package/frontend/dist/js/{estree-DCT3Jm65.js → estree-DGmLqopC.js} +17 -17
- package/frontend/dist/js/evaluationsApi-Bg12ekHo.js +1 -0
- package/frontend/dist/js/fr-Bi8BGRW4.js +2 -0
- package/frontend/dist/js/hi-BMsCnWg7.js +2 -0
- package/frontend/dist/js/{html-CBXMuS97.js → html-BryNQ_yx.js} +6 -6
- package/frontend/dist/js/id-CpcN1vhk.js +2 -0
- package/frontend/dist/js/is-DkUy2cmP.js +2 -0
- package/frontend/dist/js/it-BglK9DRZ.js +2 -0
- package/frontend/dist/js/ja-IrprzwLJ.js +2 -0
- package/frontend/dist/js/ko--wwEsMPi.js +2 -0
- package/frontend/dist/js/{markdown-Bo71X2X2.js → markdown-CZ1tYEW8.js} +17 -17
- package/frontend/dist/js/{markdown-core-BFkBYv2v.js → markdown-core-KjS96SYW.js} +1 -1
- package/frontend/dist/js/{markdown-html-CwjnwJbl.js → markdown-html-DQEwrWcf.js} +1 -1
- package/frontend/dist/js/{markdown-math-CJvHdD1l.js → markdown-math-CKi32S5d.js} +1 -1
- package/frontend/dist/js/{markdownHtml-egpK3_YY.js → markdownHtml-lrXhxBhK.js} +1 -1
- package/frontend/dist/js/markdownMath-B0BpyFBS.js +1 -0
- package/frontend/dist/js/{messageCodeStyles-euWoxwoo.js → messageCodeStyles-DJZ4QMVq.js} +2 -2
- package/frontend/dist/js/ms-BWj59y7-.js +2 -0
- package/frontend/dist/js/nl-D-QndW_A.js +2 -0
- package/frontend/dist/js/pl-Dw7d7iDV.js +2 -0
- package/frontend/dist/js/pt-BI53uHJw.js +2 -0
- package/frontend/dist/js/react-vendor-wiHys0m2.js +9 -0
- package/frontend/dist/js/router-vendor-HZm4FR0A.js +1 -0
- package/frontend/dist/js/ru-JKyTgPg9.js +2 -0
- package/frontend/dist/js/{standalone-6z5x8CWe.js → standalone-DbyFjvTU.js} +1 -1
- package/frontend/dist/js/sv-BIkBLPSQ.js +2 -0
- package/frontend/dist/js/{syntax-highlight-7t8DGG2n.js → syntax-highlight-DNc3FFCa.js} +1 -1
- package/frontend/dist/js/{teamEventStream-DGgjrVqw.js → teamEventStream-PXiwR5Kr.js} +1 -1
- package/frontend/dist/js/th-CZ_LcCU0.js +2 -0
- package/frontend/dist/js/tr-B265byx1.js +2 -0
- package/frontend/dist/js/{typescript-CslHIgIJ.js → typescript-DUM5niRM.js} +1 -1
- package/frontend/dist/js/{ui-CNcEDQ95.js → ui-DDMjO5dd.js} +2 -2
- package/frontend/dist/js/ui-vendor-BhHHyHk3.js +1 -0
- package/frontend/dist/js/uk-VTAlChwf.js +2 -0
- package/frontend/dist/js/{useChat-YRODF1y1.js → useChat-DaIZ2Dbu.js} +1 -1
- package/frontend/dist/js/{useDialogFocus-BQLdAGYH.js → useDialogFocus-BPTG_Zmy.js} +1 -1
- package/frontend/dist/js/useDictation-BXyX1U8r.js +1 -0
- package/frontend/dist/js/useQuery-hWmQjdLu.js +1 -0
- package/frontend/dist/js/{useTranslation-Kn7_iLGj.js → useTranslation-B9kflK9S.js} +1 -1
- package/frontend/dist/js/{utils-Dq1w7K0c.js → utils-p8Gt72YP.js} +1 -1
- package/frontend/dist/js/{utils-vendor-dx9vGAt3.js → utils-vendor-DISWt2y9.js} +1 -1
- package/frontend/dist/js/vi-D8rXh-53.js +2 -0
- package/frontend/dist/js/{workStatus-oU04ZrUq.js → work-DmJpVPPO.js} +1 -1
- package/frontend/dist/js/workApi-BIS9RxRi.js +1 -0
- package/frontend/dist/js/workApi-C3Td_lFD.js +5 -0
- package/frontend/dist/js/workModels-MzU2Ab7l.js +1 -0
- package/frontend/dist/js/zh-BEGd9iBD.js +2 -0
- package/package.json +43 -8
- package/scripts/prepare-dsh-provider.mjs +124 -0
- package/frontend/dist/assets/index-BXTzjRcS.js +0 -92
- package/frontend/dist/assets/index-uzzNXp5R.css +0 -1
- package/frontend/dist/js/ArtifactSlideOutPanel-DPWGjHhp.js +0 -1
- package/frontend/dist/js/AutomationsPage-DvsLZWtg.js +0 -1
- package/frontend/dist/js/ChannelsPage-D252gXwf.js +0 -1
- package/frontend/dist/js/ChatPage-D_CzOiHw.js +0 -14
- package/frontend/dist/js/ConnectModels-DYOtIOEY.js +0 -1
- package/frontend/dist/js/GalleryPage-BpK-vrvd.js +0 -1
- package/frontend/dist/js/HomePage-zJkkDNJl.js +0 -1
- package/frontend/dist/js/LibreClawPage-CAgNj9GM.js +0 -1
- package/frontend/dist/js/NotesPage-CNTqlwNc.js +0 -3
- package/frontend/dist/js/OptimizedSyntaxHighlighter-BFjOBavF.js +0 -1
- package/frontend/dist/js/PluginUsagePage-Cp4j4-VZ.js +0 -1
- package/frontend/dist/js/RichMessageContent-BOY5jqj-.js +0 -1
- package/frontend/dist/js/SettingsModal-WAdVG4-g.js +0 -19
- package/frontend/dist/js/SystemPage-Dwi8leEQ.js +0 -1
- package/frontend/dist/js/UserManagementPanel-CfG67c_k.js +0 -1
- package/frontend/dist/js/WorkPage-D_cL9wp4.js +0 -8
- package/frontend/dist/js/api-29NO19CP.js +0 -14
- package/frontend/dist/js/api-DhafOTdF.js +0 -1
- package/frontend/dist/js/appVersion-BNuquyI6.js +0 -1
- package/frontend/dist/js/ar-WHne6B0o.js +0 -2
- package/frontend/dist/js/authStore-snvjjOuX.js +0 -1
- package/frontend/dist/js/bn-BZvCjqwO.js +0 -2
- package/frontend/dist/js/chatStore-BPpcL4I5.js +0 -3
- package/frontend/dist/js/composerStyles-bNlrIugf.js +0 -1
- package/frontend/dist/js/cs-DfSqWQ9V.js +0 -2
- package/frontend/dist/js/da-BmMLW4Dl.js +0 -2
- package/frontend/dist/js/de-BQMiQwQT.js +0 -2
- package/frontend/dist/js/es-DXf6jt4Z.js +0 -2
- package/frontend/dist/js/evaluationsApi-Btc9Mg9z.js +0 -1
- package/frontend/dist/js/fr-BD6nT1oc.js +0 -2
- package/frontend/dist/js/hi-BSuNic-8.js +0 -2
- package/frontend/dist/js/id-wodbwt3B.js +0 -2
- package/frontend/dist/js/is-CEjw-OJE.js +0 -2
- package/frontend/dist/js/it-X_pq8C7q.js +0 -2
- package/frontend/dist/js/ja-DWM2HZZd.js +0 -2
- package/frontend/dist/js/ko-DFi2khBB.js +0 -2
- package/frontend/dist/js/markdownMath-mesq3ZcY.js +0 -1
- package/frontend/dist/js/ms-DNQateTR.js +0 -2
- package/frontend/dist/js/nl-DSWhi8W8.js +0 -2
- package/frontend/dist/js/pl-W9WEDpZ3.js +0 -2
- package/frontend/dist/js/pt-DCCGvdNt.js +0 -2
- package/frontend/dist/js/react-vendor-D0Ec-185.js +0 -9
- package/frontend/dist/js/router-vendor-CM0PhOMl.js +0 -1
- package/frontend/dist/js/ru-D-Ww6dXe.js +0 -2
- package/frontend/dist/js/sv-B0Iry-H3.js +0 -2
- package/frontend/dist/js/th-CEZS0WeE.js +0 -2
- package/frontend/dist/js/tr-BFJ8TeYb.js +0 -2
- package/frontend/dist/js/ui-vendor-LatG6rFF.js +0 -177
- package/frontend/dist/js/uk-BmW3yDel.js +0 -2
- package/frontend/dist/js/useQuery-C3O4CZ54.js +0 -1
- package/frontend/dist/js/vi-Cu25FXnp.js +0 -2
- package/frontend/dist/js/work-DVgm81bJ.js +0 -1
- package/frontend/dist/js/workApi-BdUNugC3.js +0 -1
- package/frontend/dist/js/workApi-OieM8qEL.js +0 -6
- package/frontend/dist/js/zh-CuCAx3oH.js +0 -2
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/ModelManagerModals-Bc2Woor7.js","js/rolldown-runtime-hePW80VL.js","js/react-vendor-D0Ec-185.js","js/useTranslation-Kn7_iLGj.js","js/utils-Dq1w7K0c.js","js/utils-vendor-dx9vGAt3.js","js/ui-vendor-LatG6rFF.js","js/goober.modern-BaHbaW3_.js","js/Button-ZQ6BePid.js","js/useDialogFocus-BQLdAGYH.js","js/UserManagementPanel-CfG67c_k.js","js/useQuery-C3O4CZ54.js","js/logger-BR4forr_.js","js/workApi-OieM8qEL.js","js/config-DHea4b8N.js","js/api-29NO19CP.js","js/authStore-Cm8P6rYs.js","js/chatStore-BPpcL4I5.js","js/i18next-DOICz7ZY.js","js/appStore-Din-tTD9.js","js/ui-CNcEDQ95.js","js/messageCodeStyles-euWoxwoo.js","js/PasswordStrengthMeter-BJr4eBbo.js","js/SettingsToggle-CKLHOUt-.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-D0Ec-185.js";import{C as r,t as i}from"./useQuery-C3O4CZ54.js";import{o as a,t as o}from"./logger-BR4forr_.js";import{t as s}from"./useTranslation-Kn7_iLGj.js";import{i as c,n as l,o as u,t as d}from"./utils-Dq1w7K0c.js";import{_ as f,b as p,c as m,l as h,m as g,p as _,s as v,t as y,u as b,v as x,x as S,y as C}from"./chatStore-BPpcL4I5.js";import{$t as w,An as T,B as E,Bt as D,Cn as O,Cr as k,D as A,Dn as j,E as M,Et as N,Ft as P,G as F,Gt as I,Hn as ee,Ht as te,In as ne,It as L,J as re,Jn as ie,Jt as ae,K as R,Ln as oe,N as se,O as ce,On as le,Q as ue,Qt as z,R as de,Rt as fe,Sn as pe,Sr as B,T as me,U as he,Un as ge,Ut as _e,V as ve,Vt as ye,Wt as be,Xn as xe,Xt as Se,Y as Ce,Yt as we,Z as Te,Zn as Ee,_n as De,_t as Oe,an as ke,bn as Ae,br as je,bt as Me,cn as Ne,cr as Pe,en as Fe,et as Ie,fr as Le,ft as Re,g as ze,gn as Be,in as Ve,jt as He,kn as Ue,kt as We,lr as Ge,n as Ke,o as qe,ot as Je,p as Ye,q as Xe,qn as Ze,r as Qe,rt as $e,s as et,sn as tt,t as nt,tn as rt,un as it,ur as at,v as V,vt as ot,wn as st,x as ct,yr as lt,z as ut,zt as dt}from"./ui-vendor-LatG6rFF.js";import{n as ft}from"./workApi-OieM8qEL.js";import{C as pt,I as mt,L as ht,M as gt,N as _t,P as vt,S as yt,T as bt,a as xt,c as St,d as H,f as U,i as Ct,l as wt,n as Tt,p as Et,r as Dt,s as W,u as Ot,w as G,y as K}from"./api-29NO19CP.js";import{a as kt,o as At,s as jt,t as Mt}from"./imageGenModels-Dx_QMLJQ.js";import{t as Nt,u as Pt}from"./authStore-Cm8P6rYs.js";import{c as Ft,d as It,l as Lt,n as Rt,r as zt,s as Bt,t as Vt,u as Ht}from"./appStore-Din-tTD9.js";import{l as Ut}from"./messageCodeStyles-euWoxwoo.js";import{t as q}from"./Button-ZQ6BePid.js";import{f as Wt,i as J,m as Gt,n as Kt,p as qt,r as Y,s as Jt,t as Yt}from"./ui-CNcEDQ95.js";import{t as Xt}from"./useDialogFocus-BQLdAGYH.js";import{t as Zt}from"./Logo-C9fsEUaY.js";import{t as Qt}from"./LogoMark-Cvu5CQOW.js";import{t as $t}from"./ShareDialog-DykD70uB.js";import{a as en,i as tn,n as X,s as nn,t as rn}from"./LanguageSwitcher-CogfczNm.js";import{s as an}from"./ttsBatching-kFVEE3Ip.js";import{t as on}from"./appVersion-BNuquyI6.js";import{t as sn}from"./SettingsToggle-CKLHOUt-.js";import{i as cn,r as ln,t as un}from"./thinking-DwlkTfPX.js";var Z=e(t(),1),Q=n();function dn(e){let t=e.match(/^v?(\d+)\.(\d+)\.(\d+)/);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}function $(e,t){for(let n=0;n<3;n++)if(e[n]!==t[n])return e[n]-t[n];return 0}function fn(e){let[t,n]=(0,Z.useState)(`checking`),[r,i]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let t=!1,r=dn(e),a=e.includes(`-dev`);return(async()=>{try{let e=await fetch(`https://api.github.com/repos/libre-webui/libre-webui/releases/latest`,{headers:{Accept:`application/vnd.github+json`}});if(!e.ok)throw Error(`HTTP ${e.status}`);let o=dn((await e.json()).tag_name??``);if(t)return;if(!r||!o){n(`error`);return}i(o.join(`.`));let s=$(r,o);n(s<0?`behind`:s>0||a?`ahead`:`latest`)}catch{t||n(`error`)}})(),()=>{t=!0}},[e]),{status:t,latestVersion:r}}var pn=[{href:`https://github.com/libre-webui/libre-webui`,icon:ke,labelKey:`settings.about.links.github`,descriptionKey:`settings.about.links.githubDescription`},{href:`https://github.com/libre-webui/libre-webui`,icon:A,labelKey:`settings.about.links.star`,descriptionKey:`settings.about.links.starDescription`},{href:`https://git.kroonen.ai/libre-webui/libre-webui`,icon:rt,labelKey:`settings.about.links.forgejo`,descriptionKey:`settings.about.links.forgejoDescription`},{href:`https://librewebui.org`,icon:st,labelKey:`settings.about.links.website`,descriptionKey:`settings.about.links.websiteDescription`},{href:`https://docs.librewebui.org`,icon:at,labelKey:`settings.about.links.documentation`,descriptionKey:`settings.about.links.documentationDescription`},{href:`https://github.com/sponsors/libre-webui`,icon:ae,labelKey:`settings.about.links.sponsor`,descriptionKey:`settings.about.links.sponsorDescription`},{href:`https://github.com/libre-webui/libre-webui/issues`,icon:N,labelKey:`settings.about.links.reportIssue`,descriptionKey:`settings.about.links.reportIssueDescription`}],mn=[`settings.about.features.privacy`,`settings.about.features.openSource`,`settings.about.features.localInference`];function hn({status:e,latestVersion:t}){let{t:n}=s();return e===`checking`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-gray-500 dark:text-dark-500`,children:[(0,Q.jsx)(L,{className:`h-3.5 w-3.5 animate-spin`}),n(`settings.about.updates.checking`)]}):e===`latest`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-success-600 dark:text-success-400`,children:[(0,Q.jsx)(ee,{className:`h-3.5 w-3.5`}),n(`settings.about.updates.upToDate`)]}):e===`ahead`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-gray-600 dark:text-dark-600`,children:[(0,Q.jsx)(Ve,{className:`h-3.5 w-3.5`}),n(`settings.about.updates.ahead`,{version:t??``})]}):e===`behind`?(0,Q.jsxs)(`a`,{href:`https://github.com/libre-webui/libre-webui/releases/latest`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 font-medium text-primary-600 transition-colors hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300`,children:[(0,Q.jsx)(ge,{className:`h-3.5 w-3.5`}),n(`settings.about.updates.updateAvailable`,{version:t??``}),(0,Q.jsx)(st,{className:`h-3 w-3`})]}):(0,Q.jsx)(`span`,{className:`text-gray-500 dark:text-dark-500`,children:n(`settings.about.updates.checkFailed`)})}function gn({appVersion:e}){let{t}=s(),{status:n,latestVersion:r}=fn(e);return(0,Q.jsx)(`div`,{className:`space-y-6`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-4 flex items-center gap-2.5 text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(Qt,{size:`md`,label:null}),(0,Q.jsx)(Zt,{})]}),(0,Q.jsx)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 mb-6`,children:(0,Q.jsx)(`span`,{children:t(`settings.about.title`)})}),(0,Q.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-100 rounded-lg p-6 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsx)(`div`,{className:`space-y-4 text-sm text-gray-700 dark:text-gray-300`,children:mn.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`w-2 h-2 bg-primary-500 rounded-full mt-2 flex-shrink-0`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-semibold text-gray-900 dark:text-gray-100 mb-1`,children:t(`${e}.title`)}),(0,Q.jsx)(`p`,{children:t(`${e}.description`)})]})]},e))})}),(0,Q.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t(`settings.about.links.title`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:pn.map(e=>{let n=e.icon;return(0,Q.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-3 p-3 bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg hover:bg-gray-50 dark:hover:bg-dark-200 hover:border-gray-300 dark:hover:border-dark-400 transition-all duration-200 group`,children:[(0,Q.jsx)(n,{className:`h-5 w-5 text-gray-600 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-gray-200`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t(e.labelKey)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(e.descriptionKey)})]}),(0,Q.jsx)(st,{className:`h-4 w-4 text-gray-400 ms-auto opacity-0 group-hover:opacity-100 transition-opacity`})]},e.labelKey)})})]}),(0,Q.jsx)(`div`,{className:`mt-6 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2 text-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5`,children:[e.includes(`-dev`)?(0,Q.jsx)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:t(`settings.about.version`,{version:e})}):(0,Q.jsx)(`a`,{href:`https://github.com/libre-webui/libre-webui/releases/tag/v${e}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-gray-500 hover:text-primary-600 dark:text-gray-400 dark:hover:text-primary-400 transition-colors`,children:t(`settings.about.version`,{version:e})}),(0,Q.jsx)(hn,{status:n,latestVersion:r}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>window.dispatchEvent(new Event(`libre:open-whats-new`)),className:`inline-flex items-center gap-1.5 text-gray-500 transition-colors hover:text-gray-900 dark:text-gray-400 dark:hover:text-dark-900`,"data-testid":`about-view-changelog`,children:[(0,Q.jsx)(R,{className:`h-3.5 w-3.5`}),t(`settings.about.updates.viewChangelog`)]})]}),(0,Q.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[t(`settings.about.openSourceBy`,{company:``}),(0,Q.jsx)(`a`,{href:`https://kroonen.ai`,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary-600 dark:text-primary-400 hover:text-primary-700 dark:hover:text-primary-300 transition-colors`,children:`Kroonen AI`})]})]})})]})})}var _n=o(`components:background-upload`),vn=e=>{let t=Nt(e=>e.user?.id);return(0,Q.jsx)(yn,{...e},t??`solo`)},yn=({className:e=``})=>{let{t,i18n:n}=s(),{preferences:r,backgroundImage:i,updateBackgroundSettings:a,uploadBackgroundImage:o,removeBackgroundImage:c}=Vt(),l=(0,Z.useId)(),u=(0,Z.useRef)(null),f=(0,Z.useRef)(0),p=(0,Z.useRef)(null),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(`idle`);(0,Z.useEffect)(()=>()=>{f.current+=1,p.current=null},[]);let b=Rt({...r.backgroundSettings,imageUrl:i||r.backgroundSettings?.imageUrl||``}),x=!!b.imageUrl,S=async e=>{let t=++f.current;p.current=e,y(`saving`);try{await e(),t===f.current&&y(`saved`)}catch(e){if(t!==f.current)return;if(e instanceof DOMException&&e.name===`AbortError`){y(`idle`);return}_n.error(`Failed to save background settings:`,e),y(`error`)}},C=e=>void S(()=>a(e)),w=async e=>{if(!e.type.startsWith(`image/`)){k.error(t(`personaBackground.invalidFile`));return}if(e.size>10485760){k.error(t(`settings.appearance.background.fileTooLarge`));return}h(!0);try{await S(()=>o(e))}finally{h(!1)}},T=l+`-enabled`,E=l+`-blur`,D=l+`-intensity`,O=new Intl.NumberFormat(n.language,{style:`percent`,maximumFractionDigits:0}).format(b.opacity);return(0,Q.jsxs)(`div`,{className:d(`space-y-4`,e),"data-testid":`background-upload`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:t(`settings.appearance.background.title`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-ink-muted`,children:t(`settings.appearance.background.enableDescription`)})]}),(0,Q.jsxs)(`label`,{htmlFor:T,className:`touch-target relative inline-flex shrink-0 cursor-pointer items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`sr-only`,children:t(`settings.appearance.background.enable`)}),(0,Q.jsx)(`input`,{id:T,type:`checkbox`,className:`peer sr-only`,checked:b.enabled,onChange:e=>C({enabled:e.target.checked}),"data-testid":`background-enabled`}),(0,Q.jsx)(`span`,{className:`relative h-6 w-11 rounded-full bg-surface-raised ring-1 ring-inset ring-line transition-colors peer-checked:bg-primary-600 peer-focus-visible:ring-2 peer-focus-visible:ring-primary-500 peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-surface motion-reduce:transition-none`,children:(0,Q.jsx)(`span`,{className:d(`absolute start-1 top-1 h-4 w-4 rounded-full bg-white shadow-subtle transition-transform motion-reduce:transition-none`,b.enabled&&`translate-x-5 rtl:-translate-x-5`)})})]})]}),(0,Q.jsxs)(`div`,{className:d(`overflow-hidden rounded-xl border border-line bg-surface-subtle`,g&&`border-primary-500 ring-2 ring-primary-500/20`),onDragOver:e=>{e.preventDefault(),_(!0)},onDragLeave:e=>{(!(e.relatedTarget instanceof Node)||!e.currentTarget.contains(e.relatedTarget))&&_(!1)},onDrop:e=>{e.preventDefault(),_(!1);let t=e.dataTransfer.files?.[0];t&&!m&&w(t)},children:[x?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{role:`img`,"aria-label":t(`settings.appearance.background.preview`),className:`relative aspect-video overflow-hidden bg-canvas`,"data-testid":`background-preview`,children:(0,Q.jsx)(nn,{settings:{...b,enabled:!0},testId:`background-preview-layer`})}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-line px-3 py-2.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-ink-muted`,children:t(`settings.appearance.background.preview`)}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>u.current?.click(),disabled:m,"data-testid":`background-change`,children:[(0,Q.jsx)(Ye,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),t(`settings.appearance.background.change`)]}),(0,Q.jsxs)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void S(async()=>{await c()}),disabled:m,className:`text-error-600 hover:text-error-700 dark:text-error-400`,"data-testid":`background-remove`,children:[(0,Q.jsx)(Ke,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),t(`common.remove`)]})]})]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 px-4 py-6 text-center`,children:[(0,Q.jsx)(I,{className:`h-7 w-7 text-ink-subtle`,"aria-hidden":`true`}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-ink-muted`,children:t(`settings.appearance.background.dragDrop`)}),(0,Q.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,disabled:m,onClick:()=>u.current?.click(),"data-testid":`background-change`,children:[(0,Q.jsx)(Ye,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),t(m?`common.loading`:`settings.appearance.background.chooseImage`)]})]}),(0,Q.jsx)(`input`,{ref:u,type:`file`,accept:`image/*`,disabled:m,className:`hidden`,"data-testid":`background-file-input`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&w(t)}})]}),x&&(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(Wt,{label:t(`settings.appearance.background.effect`),value:b.effect,onChange:e=>C({effect:e.target.value}),options:[{value:`dither`,label:t(`settings.appearance.background.dither`)},{value:`original`,label:t(`settings.appearance.background.original`)},{value:`blur`,label:t(`settings.appearance.background.blurred`)}],"data-testid":`background-effect`}),b.effect===`blur`&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{htmlFor:E,className:`mb-2 flex items-center justify-between gap-3 text-sm text-ink`,children:[(0,Q.jsx)(`span`,{children:t(`settings.appearance.background.blur`)}),(0,Q.jsxs)(`span`,{dir:`ltr`,className:`text-xs tabular-nums text-ink-muted`,children:[b.blurAmount,`px`]})]}),(0,Q.jsx)(`input`,{id:E,type:`range`,min:0,max:30,step:1,value:b.blurAmount,onChange:e=>C({blurAmount:Number(e.target.value)}),className:`h-6 w-full cursor-pointer accent-primary-600`,"data-testid":`background-blur`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{htmlFor:D,className:`mb-2 flex items-center justify-between gap-3 text-sm text-ink`,children:[(0,Q.jsx)(`span`,{children:t(`settings.appearance.background.intensity`)}),(0,Q.jsx)(`span`,{className:`text-xs tabular-nums text-ink-muted`,children:O})]}),(0,Q.jsx)(`input`,{id:D,type:`range`,min:0,max:1,step:.05,value:b.opacity,"aria-valuetext":O,onChange:e=>C({opacity:Number(e.target.value)}),className:`h-6 w-full cursor-pointer accent-primary-600`,"data-testid":`background-intensity`})]}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-ink-muted`,children:t(`settings.appearance.background.originalPreserved`)})]}),(0,Q.jsxs)(`div`,{role:v===`idle`?void 0:v===`error`?`alert`:`status`,className:d(`flex min-h-5 flex-wrap items-center gap-2 text-xs`,v===`error`?`text-error-600 dark:text-error-400`:`text-ink-muted`),"data-testid":`background-save-status`,children:[v===`saving`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L,{className:`h-3.5 w-3.5 animate-spin motion-reduce:animate-none`,"aria-hidden":`true`}),t(`common.saving`)]}),v===`saved`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ee,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),t(`settings.appearance.background.saved`)]}),v===`error`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{children:t(`settings.appearance.background.saveFailed`)}),(0,Q.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{p.current&&S(p.current)},children:t(`common.retry`)})]})]})]})};function bn({title:e,description:t,children:n}){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-4 py-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h4`,{className:`text-sm leading-[22px] text-ink`,children:e}),t&&(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-ink-subtle`,children:t})]}),n&&(0,Q.jsx)(`div`,{className:`shrink-0`,children:n})]})}function xn({checked:e,onChange:t,label:n,testId:r}){return(0,Q.jsxs)(`label`,{className:`relative inline-flex shrink-0 cursor-pointer items-center`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"data-testid":r,"aria-label":n,className:`peer sr-only`,checked:e,onChange:e=>t(e.target.checked)}),(0,Q.jsx)(`div`,{className:`peer h-6 w-11 rounded-full bg-line-strong transition-colors peer-focus:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-primary-500/40 peer-checked:bg-primary-500 after:absolute after:start-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:bg-white after:shadow-sm after:transition-all after:content-[''] peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full`})]})}function Sn({theme:e,preferences:t,onThemeChange:n,onAccentChange:r,onCustomAccentChange:i,onAdaptToAccentChange:a,onShowUsernameChange:o,onShowFollowUpsChange:c,onAutoOpenArtifactsChange:l,onHapticFeedbackChange:u}){let{t:f}=s(),p=e.accent||`blue`,m=e.customAccent||`#4176e6`,h=Bt(e),g=Ht(e=>e.location),_=Ht(e=>e.weatherEnabled),v=Ht(e=>e.weather),y=Ht(e=>e.weatherStatus),b=Ht(e=>e.setLocation),x=Ht(e=>e.requestBrowserLocation),S=Ht(e=>e.setWeatherEnabled),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(``),[k,A]=(0,Z.useState)(``),j=(0,Z.useId)(),N=async()=>{w(!0),E(!1);let e=await x();w(!1),e||E(!0)},P=()=>{if(!D.trim()||!k.trim())return;let e=Number(D),t=Number(k);It({latitude:e,longitude:t})&&(b({latitude:e,longitude:t}),E(!1),O(``),A(``))},F=e.mode===`celestial`;(0,Z.useEffect)(()=>()=>Lt(null),[]);let I=(t,r,i)=>{let a=e.mode===t;return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>n(t),"aria-pressed":a,className:d(`flex flex-1 basis-[180px] flex-col items-center justify-center gap-1 rounded-2xl border px-8 py-5 text-sm leading-[22px] text-ink transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,a?`border-line-strong bg-surface-subtle`:`border-line hover:bg-interactive-hover`),children:[(0,Q.jsx)(r,{className:`h-4 w-4`}),i]})};return(0,Q.jsxs)(`div`,{className:`divide-y divide-line`,children:[(0,Q.jsx)(rn,{}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[(0,Q.jsx)(`h4`,{className:`text-sm leading-[22px] text-ink`,children:f(`settings.appearance.title`)}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[I(`light`,M,f(`settings.appearance.theme.light`)),I(`dark`,Oe,f(`settings.appearance.theme.dark`)),I(`amoled`,ot,f(`settings.appearance.theme.amoled`)),I(`celestial`,me,f(`settings.appearance.theme.celestial`))]})]}),F&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 py-4`,"data-testid":`celestial-preview`,children:[(0,Q.jsx)(en,{}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 rounded-xl border border-line p-3`,"data-testid":`celestial-location`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-x-4 gap-y-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,Q.jsx)(`h5`,{className:`text-sm leading-[22px] text-ink`,children:f(`settings.appearance.celestial.location`)}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-ink-muted`,children:f(`settings.appearance.celestial.locationHint`)})]}),(0,Q.jsx)(`output`,{dir:g?`ltr`:`auto`,"aria-live":`polite`,className:`max-w-full break-words rounded-lg bg-surface-subtle px-2 py-1 font-mono text-xs leading-5 text-ink-muted`,"data-testid":`celestial-location-value`,children:g?`${g.latitude.toFixed(2)}°, ${g.longitude.toFixed(2)}°`:f(`settings.appearance.celestial.approximateDay`)})]}),(0,Q.jsxs)(`form`,{className:`mt-1 space-y-3`,onSubmit:e=>{e.preventDefault(),P()},children:[(0,Q.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 space-y-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`${j}-latitude`,className:`block text-xs font-medium text-ink-muted`,children:f(`settings.appearance.celestial.latitude`)}),(0,Q.jsx)(`input`,{id:`${j}-latitude`,type:`number`,step:`any`,required:!0,min:-90,max:90,dir:`ltr`,value:D,onChange:e=>O(e.target.value),className:`w-full min-w-0 rounded-lg border border-line bg-surface-subtle px-3 py-2 text-[16px] text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40 md:text-sm`,"data-testid":`celestial-latitude`})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 space-y-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`${j}-longitude`,className:`block text-xs font-medium text-ink-muted`,children:f(`settings.appearance.celestial.longitude`)}),(0,Q.jsx)(`input`,{id:`${j}-longitude`,type:`number`,step:`any`,required:!0,min:-180,max:180,dir:`ltr`,value:k,onChange:e=>A(e.target.value),className:`w-full min-w-0 rounded-lg border border-line bg-surface-subtle px-3 py-2 text-[16px] text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40 md:text-sm`,"data-testid":`celestial-longitude`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`submit`,className:`rounded-lg border border-line bg-surface-raised px-3 py-2 text-xs font-medium text-ink transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,"data-testid":`celestial-apply-location`,children:f(`settings.appearance.celestial.apply`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void N(),disabled:C,className:`rounded-lg border border-line px-3 py-2 text-xs text-ink transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40 disabled:opacity-60`,"data-testid":`celestial-use-location`,children:f(`settings.appearance.celestial.useMyLocation`)}),g&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>b(null),className:`rounded-lg px-3 py-2 text-xs text-ink-muted transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,"data-testid":`celestial-clear-location`,children:f(`settings.appearance.celestial.clear`)})]})]}),T&&(0,Q.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:f(`settings.appearance.celestial.locationDenied`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 py-1`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h5`,{className:`text-sm leading-[22px] text-ink`,children:f(`settings.appearance.celestial.weather`)}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-ink-muted`,children:f(`settings.appearance.celestial.weatherHint`)}),_&&g&&(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-ink-subtle`,"data-testid":`celestial-weather-status`,children:y===`loading`&&!v?f(`settings.appearance.celestial.weatherLoading`):y===`error`&&!v?f(`settings.appearance.celestial.weatherUnavailable`):v?`${f(`settings.appearance.celestial.kinds.${v.kind}`)} · ${f(`settings.appearance.celestial.wind`,{speed:Math.round(v.windSpeed)})}`:``})]}),(0,Q.jsx)(`div`,{"data-testid":`celestial-weather-toggle`,children:(0,Q.jsx)(sn,{checked:_,onChange:S,disabled:!g})})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 py-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsx)(`h4`,{className:`text-sm leading-[22px] text-ink`,children:f(`settings.appearance.accent.title`,{defaultValue:`Accent color`})}),(0,Q.jsx)(`div`,{className:`h-6 w-6 flex-shrink-0 rounded-full border border-line`,style:{backgroundColor:h},"aria-hidden":`true`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[zt.map(e=>{let t=p===e.id;return(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r(e.id),className:d(`relative h-9 w-9 rounded-full transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,t?`scale-105 ring-2 ring-ink ring-offset-2 ring-offset-surface`:`hover:scale-110`),style:{backgroundColor:e.color},"aria-label":f(`settings.appearance.accent.useColor`,{defaultValue:`Use ${e.label} accent`,color:e.label}),title:e.label,children:t&&(0,Q.jsx)(Ee,{className:`absolute inset-0 m-auto h-4 w-4 drop-shadow`,style:{color:e.foreground}})},e.id)}),(0,Q.jsxs)(`label`,{className:d(`relative h-9 w-9 cursor-pointer overflow-hidden rounded-full transition-all duration-200 focus-within:outline-none focus-within:ring-2 focus-within:ring-primary-500/40`,p===`custom`?`scale-105 ring-2 ring-ink ring-offset-2 ring-offset-surface`:`hover:scale-110`),title:f(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),"aria-label":f(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),children:[(0,Q.jsx)(`input`,{type:`color`,value:m,onInput:e=>i(e.currentTarget.value),onChange:e=>i(e.target.value),className:`absolute inset-0 h-full w-full cursor-pointer opacity-0`}),(0,Q.jsx)(`span`,{className:`absolute inset-0`,style:{backgroundColor:m},"aria-hidden":`true`}),(0,Q.jsx)(Re,{className:`absolute inset-0 m-auto h-4 w-4 text-white drop-shadow`})]})]}),!F&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm leading-[22px] text-ink`,children:f(`settings.appearance.accent.behaviorTitle`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-ink-subtle`,children:f(`settings.appearance.accent.behaviorDescription`)}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-stretch gap-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":!e.adaptToAccent,onClick:()=>a(!1),className:d(`flex-1 basis-[180px] rounded-2xl border p-4 text-start transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,e.adaptToAccent?`border-line hover:bg-interactive-hover`:`border-line-strong bg-surface-subtle`),children:[(0,Q.jsx)(`span`,{className:`block text-sm leading-[22px] text-ink`,children:f(`settings.appearance.accent.defaultStyle`)}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-ink-subtle`,children:f(`settings.appearance.accent.defaultStyleDescription`)})]}),(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":e.adaptToAccent===!0,onClick:()=>a(!0),className:d(`flex-1 basis-[180px] rounded-2xl border p-4 text-start transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,e.adaptToAccent?`border-line-strong bg-surface-subtle`:`border-line hover:bg-interactive-hover`),children:[(0,Q.jsx)(`span`,{className:`block text-sm leading-[22px] text-ink`,children:f(`settings.appearance.accent.adaptedStyle`)}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-ink-subtle`,children:f(`settings.appearance.accent.adaptedStyleDescription`)})]})]})]})]}),(0,Q.jsx)(bn,{title:f(`settings.appearance.chatInterface.showUsername`),description:f(`settings.appearance.chatInterface.showUsernameDescription`),children:(0,Q.jsx)(xn,{checked:t.showUsername,onChange:o,label:f(`settings.appearance.chatInterface.showUsername`)})}),(0,Q.jsx)(bn,{title:f(`settings.appearance.chatInterface.followUpSuggestions`),description:f(`settings.appearance.chatInterface.followUpSuggestionsDescription`),children:(0,Q.jsx)(xn,{checked:t.showFollowUpSuggestions!==!1,onChange:c,label:f(`settings.appearance.chatInterface.followUpSuggestions`)})}),(0,Q.jsx)(bn,{title:f(`settings.appearance.chatInterface.autoOpenArtifacts`),description:f(`settings.appearance.chatInterface.autoOpenArtifactsDescription`),children:(0,Q.jsx)(xn,{checked:t.autoOpenArtifactPanel!==!1,onChange:l,label:f(`settings.appearance.chatInterface.autoOpenArtifacts`),testId:`auto-open-artifacts-toggle`})}),(0,Q.jsx)(bn,{title:f(`settings.appearance.chatInterface.hapticFeedback`,{defaultValue:`Haptic feedback (Android)`}),description:f(`settings.appearance.chatInterface.hapticFeedbackDescription`,{defaultValue:`Use subtle vibration for important mobile actions`}),children:(0,Q.jsx)(xn,{checked:t.hapticFeedbackEnabled===!0,onChange:u,label:f(`settings.appearance.chatInterface.hapticFeedback`,{defaultValue:`Haptic feedback (Android)`}),testId:`haptic-feedback-toggle`})}),(0,Q.jsx)(`div`,{className:`py-4`,children:(0,Q.jsx)(vn,{})})]})}function Cn(){let{t:e,i18n:t}=s(),{sessions:n,setSessionArchived:r,deleteSession:i}=y(),a=n.filter(e=>e.archived);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:e(`settings.data.archivedChats.title`)}),a.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.data.archivedChats.empty`)}):(0,Q.jsx)(`div`,{className:`divide-y divide-gray-100 rounded-xl border border-gray-200 dark:divide-dark-300 dark:border-dark-300`,children:a.map(n=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:n.title}),(0,Q.jsx)(`p`,{className:`text-[11px] tabular-nums text-gray-400 dark:text-dark-500`,children:c(n.updatedAt,t.language)})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:()=>r(n.id,!1),className:`h-8 gap-1.5 px-2 text-xs`,title:e(`settings.data.archivedChats.unarchive`),children:[(0,Q.jsx)(lt,{className:`h-3.5 w-3.5`}),e(`settings.data.archivedChats.unarchive`)]}),(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>{window.confirm(e(`chat.session.deleteConfirm`))&&i(n.id)},className:`h-8 w-8 p-0 text-red-500 hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-900/20`,title:e(`chat.session.deleteChat`),children:(0,Q.jsx)(V,{className:`h-3.5 w-3.5`})})]})]},n.id))})]})}function wn({sessionCount:e,loading:t,importing:n,preflighting:r,preflight:i,showImportOptions:a,mergeStrategy:o,importResult:c,importFileInputRef:l,onExportData:u,onImportFileSelect:d,onClearAllHistory:f,onMergeStrategyChange:p,onConfirmImport:m,onCancelImport:h,onDismissImportResult:g}){let{t:_}=s();return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:_(`settings.data.title`)}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:_(`settings.data.export`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:_(`settings.data.exportDescription`)}),(0,Q.jsx)(`p`,{className:`mb-3 text-[11px] text-amber-700 dark:text-amber-300`,children:_(`settings.data.archiveScopeV3`,{defaultValue:`Includes preferences, chats, folders, Notes, knowledge collections, and extracted document text. Excludes accounts and secrets, biometric cloned voices, generated media, personas and memory, and Work data or volumes.`})}),(0,Q.jsx)(q,{onClick:u,variant:`outline`,size:`sm`,className:`w-full`,children:_(`settings.data.exportAll`)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:_(`settings.data.import`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:_(`settings.data.importDescription`)}),(0,Q.jsx)(`input`,{ref:l,type:`file`,accept:`.json`,onChange:d,className:`hidden`}),(0,Q.jsx)(q,{onClick:()=>l.current?.click(),variant:`outline`,size:`sm`,className:`w-full`,disabled:n,children:_(n?`settings.data.importing`:`settings.data.importData`)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:_(`settings.data.clearSessions`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:_(`settings.data.clearSessionsDescription`)}),(0,Q.jsx)(q,{onClick:f,variant:`outline`,size:`sm`,className:`w-full text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 border-red-200 hover:border-red-300 dark:border-red-800 dark:hover:border-red-700`,disabled:e===0||t,children:t?_(`settings.data.clearing`):_(`settings.data.clearAll`,{count:e})})]})]}),a&&(0,Q.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:[(0,Q.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-3`,children:_(`settings.data.importOptions`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:_(`settings.data.importOptionsDescription`)}),(0,Q.jsxs)(`div`,{className:`space-y-2 mb-4`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`skip`,checked:o===`skip`,onChange:e=>p(e.target.value),className:`me-2`}),(0,Q.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:_(`settings.data.skipDuplicates`)})]}),(0,Q.jsxs)(`label`,{className:`flex items-center`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`overwrite`,checked:o===`overwrite`,onChange:e=>p(e.target.value),className:`me-2`}),(0,Q.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:_(`settings.data.overwrite`)})]})]}),r&&(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-gray-600 dark:text-gray-300`,children:_(`settings.data.validatingArchive`,{defaultValue:`Validating archive and calculating changes…`})}),i&&!r&&(0,Q.jsxs)(`div`,{className:`mb-4 space-y-2 rounded-md border border-gray-200 bg-white p-3 text-xs text-gray-700 dark:border-dark-300 dark:bg-dark-200 dark:text-gray-300`,children:[(0,Q.jsx)(`p`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:_(`settings.data.preflightReport`,{defaultValue:`Import preview`})}),(0,Q.jsx)(`p`,{children:_(`settings.data.preflightIncoming`,{defaultValue:`{{folders}} folders · {{sessions}} chats · {{messages}} messages · {{notes}} Notes · {{collections}} collections · {{documents}} documents · {{chunks}} chunks`,folders:i.incoming.sessionFolders,sessions:i.incoming.sessions,messages:i.incoming.messages,notes:i.incoming.notes,collections:i.incoming.knowledgeCollections,documents:i.incoming.documents,chunks:i.incoming.documentChunks})}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:[[_(`settings.data.sessionFolders`,{defaultValue:`Session folders`}),i.result.sessionFolders],[_(`settings.data.sessions`),i.result.sessions],[_(`settings.data.notes`,{defaultValue:`Notes`}),i.result.notes],[_(`settings.data.knowledgeCollections`,{defaultValue:`Knowledge collections`}),i.result.knowledgeCollections],[_(`settings.data.documents`),i.result.documents]].map(([e,t])=>(0,Q.jsxs)(`p`,{children:[e,`: `,t.imported,` `,_(`settings.data.toCreate`,{defaultValue:`to create`}),`, `,t.overwritten,` `,_(`settings.data.toOverwrite`,{defaultValue:`to overwrite`}),`, `,t.skipped,` `,_(`settings.data.toSkip`,{defaultValue:`to skip`})]},e))}),i.result.remappedIds>0&&(0,Q.jsx)(`p`,{className:`text-amber-700 dark:text-amber-300`,children:_(`settings.data.preflightRemappedIds`,{defaultValue:`{{count}} IDs will be remapped to protect another account's data.`,count:i.result.remappedIds})}),i.warnings.map((e,t)=>(0,Q.jsxs)(`p`,{className:`text-amber-700 dark:text-amber-300`,children:[`• `,e]},`preflight-warning-${t}`))]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(q,{onClick:m,size:`sm`,disabled:n||r||!i||i.strategy!==o,children:_(n?`settings.data.importing`:`settings.data.import`)}),(0,Q.jsx)(q,{onClick:h,variant:`outline`,size:`sm`,children:_(`common.cancel`)})]})]}),c&&(0,Q.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:[(0,Q.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:_(`settings.data.importResults`)}),(0,Q.jsxs)(`div`,{className:`text-xs text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,Q.jsxs)(`div`,{children:[_(`settings.data.preferences`),`:`,` `,c.preferences.imported?_(`settings.data.imported`):_(`settings.data.failed`)]}),(0,Q.jsxs)(`div`,{children:[_(`settings.data.sessions`),`:`,` `,c.sessions.imported,` `,_(`settings.data.importedLabel`),`,`,` `,c.sessions.overwritten,` `,_(`settings.data.overwrittenLabel`,{defaultValue:`overwritten`}),`, `,c.sessions.skipped,` `,_(`settings.data.skipped`)]}),(0,Q.jsxs)(`div`,{children:[_(`settings.data.documents`),`:`,` `,c.documents.imported,` `,_(`settings.data.importedLabel`),`,`,` `,c.documents.overwritten,` `,_(`settings.data.overwrittenLabel`,{defaultValue:`overwritten`}),`, `,c.documents.skipped,` `,_(`settings.data.skipped`)]}),(0,Q.jsxs)(`div`,{children:[_(`settings.data.notes`,{defaultValue:`Notes`}),`:`,` `,c.notes.imported,` `,_(`settings.data.importedLabel`),`,`,` `,c.notes.overwritten,` `,_(`settings.data.overwrittenLabel`,{defaultValue:`overwritten`}),`, `,c.notes.skipped,` `,_(`settings.data.skipped`)]}),(0,Q.jsxs)(`div`,{children:[_(`settings.data.sessionFolders`,{defaultValue:`Session folders`}),`: `,c.sessionFolders.imported,` `,_(`settings.data.importedLabel`),`,`,` `,c.sessionFolders.overwritten,` `,_(`settings.data.overwrittenLabel`,{defaultValue:`overwritten`}),`, `,c.sessionFolders.skipped,` `,_(`settings.data.skipped`)]}),(0,Q.jsxs)(`div`,{children:[_(`settings.data.knowledgeCollections`,{defaultValue:`Knowledge collections`}),`: `,c.knowledgeCollections.imported,` `,_(`settings.data.importedLabel`),`,`,` `,c.knowledgeCollections.overwritten,` `,_(`settings.data.overwrittenLabel`,{defaultValue:`overwritten`}),`, `,c.knowledgeCollections.skipped,` `,_(`settings.data.skipped`)]}),c.warnings.length>0&&(0,Q.jsxs)(`div`,{className:`mt-2`,children:[(0,Q.jsxs)(`p`,{className:`font-medium`,children:[_(`settings.data.warnings`,{defaultValue:`Warnings`}),`:`]}),c.warnings.map((e,t)=>(0,Q.jsxs)(`p`,{className:`text-amber-700 dark:text-amber-300`,children:[`• `,e]},`warning-${t}`))]})]}),(0,Q.jsx)(q,{onClick:g,variant:`outline`,size:`sm`,className:`mt-2`,children:_(`common.close`)})]})]})]}),(0,Q.jsx)(Cn,{})]})}function Tn({settings:e,effectiveSettings:t,modelOptions:n,status:r,regenerating:i,onSettingChange:a,onReset:o,onRegenerate:c,onSave:l}){let{t:u}=s();return(0,Q.jsx)(`div`,{className:`space-y-6`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:u(`settings.documents.title`)}),(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 p-4 rounded-lg border border-gray-200 dark:border-dark-300 space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:u(`settings.documents.embeddings.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:u(`settings.documents.embeddings.enable`)})]}),(0,Q.jsx)(sn,{checked:e.enabled,onChange:e=>a(`enabled`,e)})]}),e.enabled&&(0,Q.jsxs)(`div`,{className:`space-y-4 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:u(`settings.documents.embeddings.model`)}),(0,Q.jsx)(Wt,{value:t.model,onChange:e=>a(`model`,e.target.value),options:n}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:u(`settings.documents.embeddings.modelDescription`)})]}),(0,Q.jsx)(Dn,{label:u(`settings.documents.embeddings.chunkSize`),value:e.chunkSize,min:500,max:2e3,step:100,description:u(`settings.documents.embeddings.chunkSizeDescription`),onChange:e=>a(`chunkSize`,e)}),(0,Q.jsx)(Dn,{label:u(`settings.documents.embeddings.chunkOverlap`),value:e.chunkOverlap,min:50,max:500,step:50,description:u(`settings.documents.embeddings.chunkOverlapDescription`),onChange:e=>a(`chunkOverlap`,e)}),(0,Q.jsx)(Dn,{label:u(`settings.documents.embeddings.similarityThreshold`),value:e.similarityThreshold,min:.3,max:.9,step:.05,description:u(`settings.documents.embeddings.similarityDescription`),format:e=>e.toFixed(2),onChange:e=>a(`similarityThreshold`,e)})]})]}),r&&(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-100 p-4 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:u(`settings.documents.embeddings.status`)}),(0,Q.jsxs)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,Q.jsxs)(`div`,{children:[u(`settings.documents.embeddings.statusLabel`),`:`,` `,(0,Q.jsx)(`span`,{className:r.available?`font-medium text-green-600 dark:text-green-400`:`font-medium text-red-600 dark:text-red-400`,children:r.available?u(`settings.documents.embeddings.available`):u(`settings.documents.embeddings.unavailable`)})]}),(0,Q.jsxs)(`div`,{children:[u(`settings.documents.embeddings.model`),`:`,` `,(0,Q.jsx)(`span`,{className:`font-medium`,children:r.model})]}),(0,Q.jsxs)(`div`,{children:[u(`settings.documents.embeddings.chunksWithEmbeddings`),`:`,` `,(0,Q.jsxs)(`span`,{className:`font-medium`,children:[r.chunksWithEmbeddings,` / `,r.totalChunks]})]}),r.totalChunks>0&&(0,Q.jsxs)(`div`,{children:[u(`settings.documents.embeddings.coverage`),`:`,` `,(0,Q.jsxs)(`span`,{className:`font-medium`,children:[Math.round(r.chunksWithEmbeddings/r.totalChunks*100),`%`]})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(q,{onClick:o,variant:`outline`,className:`flex items-center gap-2`,children:[(0,Q.jsx)(re,{size:16}),u(`settings.generation.resetDefaults`)]}),e.enabled&&r&&r.totalChunks>0&&(0,Q.jsxs)(q,{onClick:c,disabled:i,variant:`outline`,className:`flex items-center gap-2 text-orange-600 dark:text-orange-400 border-orange-200 dark:border-orange-600 hover:bg-orange-50 dark:hover:bg-orange-900/20`,children:[(0,Q.jsx)(le,{size:16}),u(i?`settings.documents.embeddings.regenerating`:`settings.documents.embeddings.regenerate`)]})]}),(0,Q.jsxs)(q,{onClick:l,className:`flex items-center gap-2`,children:[(0,Q.jsx)(Ee,{size:16}),u(`settings.saveSettings`)]})]}),(0,Q.jsx)(En,{})]})})}function En(){let{t:e}=s(),t=r(),[n,a]=(0,Z.useState)(``),[o,c]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),{data:m}=i({queryKey:[`knowledge-collections`],queryFn:async()=>{let[e,t]=await Promise.all([gt.getCollections(),gt.getDocuments()]);return{collections:e.success&&e.data?e.data:[],documents:t.success&&t.data?t.data:[]}}}),{collections:h=[],documents:g=[]}=m??{},_=()=>t.invalidateQueries({queryKey:[`knowledge-collections`]}),v=async()=>{let t=n.trim();if(t){a(``);try{let e=await gt.createCollection(t);if(!e.success)throw Error(e.error);await _()}catch{B.error(e(`settings.documents.collections.createFailed`))}}},y=async t=>{c(null);try{let e=await gt.deleteCollection(t);if(!e.success)throw Error(e.error);await _()}catch{B.error(e(`settings.documents.collections.deleteFailed`))}},b=async t=>{p(null);try{let e=await gt.deleteDocument(t);if(!e.success)throw Error(e.error);window.dispatchEvent(new Event(`libre:documents-updated`)),await _()}catch{B.error(e(`settings.documents.library.deleteFailed`))}},x=async(t,n)=>{try{let e=await gt.setDocumentCollection(t,n);if(!e.success)throw Error(e.error);await _()}catch{B.error(e(`settings.documents.collections.assignFailed`))}};return(0,Q.jsxs)(`div`,{className:`pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-1`,children:e(`settings.documents.collections.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:e(`settings.documents.collections.description`)}),(0,Q.jsxs)(`div`,{className:`mb-3 flex gap-2`,children:[(0,Q.jsx)(`input`,{value:n,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v()},placeholder:e(`settings.documents.collections.namePlaceholder`),className:`flex-1 rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:border-dark-300 dark:bg-dark-50 dark:text-dark-900`}),(0,Q.jsx)(q,{size:`sm`,onClick:()=>void v(),disabled:!n.trim(),children:e(`settings.documents.collections.create`)})]}),h.length>0&&(0,Q.jsx)(`div`,{className:`mb-4 flex flex-wrap gap-1.5`,children:h.map(t=>o===t.id?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-red-200 bg-red-50 px-2.5 py-1 text-xs text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300`,children:[e(`settings.documents.collections.deleteConfirm`),(0,Q.jsx)(`button`,{onClick:()=>void y(t.id),className:`font-medium underline decoration-red-400 underline-offset-2 hover:text-red-800 dark:hover:text-red-200`,children:e(`common.delete`)}),(0,Q.jsx)(`button`,{onClick:()=>c(null),className:`text-red-400 hover:text-red-600 dark:hover:text-red-300`,title:e(`common.cancel`),children:(0,Q.jsx)(Ke,{className:`h-3 w-3`})})]},t.id):(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-gray-200 bg-gray-50 px-2.5 py-1 text-xs text-gray-700 dark:border-dark-300 dark:bg-dark-200 dark:text-dark-800`,children:[(0,Q.jsx)(at,{className:`h-3 w-3`}),t.name,(0,Q.jsx)(`span`,{className:`tabular-nums text-gray-400 dark:text-dark-500`,children:t.documentCount??0}),t.shared?(0,Q.jsx)(`span`,{className:`text-[10px] uppercase text-gray-400 dark:text-dark-500`,children:e(`settings.documents.collections.shared`)}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{onClick:()=>d({id:t.id,name:t.name}),className:`text-gray-400 transition-colors hover:text-primary-500 dark:text-dark-500`,title:e(`settings.documents.collections.share`),"data-testid":`collection-share`,children:(0,Q.jsx)(E,{className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{onClick:()=>c(t.id),className:`text-gray-400 transition-colors hover:text-red-500 dark:text-dark-500`,title:e(`common.delete`),children:(0,Q.jsx)(Ke,{className:`h-3 w-3`})})]})]},t.id))}),(0,Q.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-1`,children:e(`settings.documents.library.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:e(`settings.documents.library.description`)}),g.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.documents.library.empty`)}):(0,Q.jsx)(`div`,{className:`divide-y divide-gray-100 rounded-xl border border-gray-200 dark:divide-dark-300 dark:border-dark-300`,children:g.map(t=>(0,Q.jsx)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2`,children:f===t.id?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm text-red-700 dark:text-red-300`,children:e(`settings.documents.library.deleteConfirm`,{name:t.filename})}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,className:`text-red-600 border-red-200 hover:bg-red-50 dark:text-red-400 dark:border-red-800 dark:hover:bg-red-900/20`,onClick:()=>void b(t.id),children:e(`common.delete`)}),(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>p(null),children:e(`common.cancel`)})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Be,{className:`h-4 w-4 shrink-0 text-gray-400 dark:text-dark-500`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm text-gray-900 dark:text-dark-900`,children:t.filename}),(0,Q.jsxs)(`p`,{className:`text-xs text-gray-400 dark:text-dark-500`,children:[l(t.size),` · `,t.sessionId?e(`settings.documents.library.chatScope`):e(`settings.documents.library.everyChatScope`)]})]}),t.processingStatus===`failed`&&(0,Q.jsx)(`span`,{className:`shrink-0 rounded-full bg-red-100 px-2 py-0.5 text-xs font-medium text-red-700 dark:bg-red-900/30 dark:text-red-300`,title:t.processingError||e(`settings.documents.library.extractionFailed`),children:e(`settings.documents.library.extractionFailed`)}),t.processingStatus===`queued`&&(0,Q.jsx)(`span`,{className:`shrink-0 rounded-full bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-600 dark:bg-dark-200 dark:text-dark-700`,children:e(`settings.documents.library.extractionQueued`)}),h.length>0&&(0,Q.jsxs)(`select`,{value:t.collectionId??``,onChange:e=>void x(t.id,e.target.value||null),className:`rounded-lg border border-gray-200 bg-white px-2 py-1 text-xs text-gray-700 focus:outline-none dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,Q.jsx)(`option`,{value:``,children:e(`settings.documents.collections.none`)}),h.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,Q.jsx)(`button`,{onClick:()=>p(t.id),className:`text-gray-400 transition-colors hover:text-red-500 dark:text-dark-500`,title:e(`common.delete`),children:(0,Q.jsx)(V,{className:`h-4 w-4`})})]})},t.id))}),u&&(0,Q.jsx)($t,{resourceType:`knowledge-collection`,resourceId:u.id,resourceLabel:u.name,onClose:()=>d(null)})]})}function Dn({label:e,value:t,min:n,max:r,step:i,description:a,format:o=e=>String(e),onChange:s}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,`: `,o(t)]}),(0,Q.jsx)(`input`,{type:`range`,min:n,max:r,step:i,value:t,onChange:e=>s(Number(e.target.value)),className:`w-full range-slider`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:a})]})}function On({generationOptions:e,generationScope:t,scopedModel:n,onGenerationScopeChange:r,embeddingSettings:i,effectiveEmbeddingSettings:a,embeddingModelOptions:o,embeddingStatus:c,onGenerationOptionChange:l,onEmbeddingSettingsChange:u,onResetGenerationOptions:f,onSaveGenerationOptions:p,onResetEmbeddingSettings:m,onSaveEmbeddingSettings:h}){let{t:g}=s(),[_,v]=(0,Z.useState)(!1),y=(0,Z.useId)(),b=(0,Z.useId)(),x=(0,Z.useId)(),S=[{value:`global`,label:g(`settings.generation.scopeAll`)},...n?[{value:`model`,label:g(`settings.generation.scopeModel`,{model:n})}]:[]];return(0,Q.jsx)(`div`,{className:`space-y-6`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:g(`settings.generation.title`)}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-4`,children:g(`settings.generation.description`)}),(0,Q.jsxs)(`div`,{className:`mb-6 rounded-lg border border-gray-200 bg-white p-4 dark:border-dark-300 dark:bg-dark-100`,children:[(0,Q.jsx)(`label`,{htmlFor:b,className:`mb-2 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:g(`settings.generation.scopeLabel`)}),(0,Q.jsx)(Wt,{id:b,value:t,onChange:e=>r(e.target.value),options:S}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-gray-400`,children:g(t===`model`?`settings.generation.scopeModelHint`:`settings.generation.scopeAllHint`)})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white dark:border-dark-300 dark:bg-dark-100`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":_,"aria-controls":y,onClick:()=>v(e=>!e),className:`flex w-full items-center justify-between gap-4 p-4 text-left`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-gray-100`,children:g(`settings.generation.advancedSettings`)}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs text-gray-500 dark:text-gray-400`,children:g(`settings.generation.advancedSettingsDescription`)})]}),(0,Q.jsx)(xe,{className:d(`h-4 w-4 flex-shrink-0 text-gray-500 transition-transform`,_&&`rotate-180`)})]}),_&&(0,Q.jsxs)(`div`,{id:y,className:`space-y-6 border-t border-gray-200 p-4 dark:border-dark-300`,children:[(0,Q.jsxs)(An,{title:g(`settings.generation.coreParameters`),children:[(0,Q.jsx)(jn,{label:g(`settings.generation.temperature`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.temperature,placeholder:`0.8`,description:g(`settings.generation.temperatureDescription`),onChange:e=>l(`temperature`,e)}),(0,Q.jsx)(jn,{label:g(`settings.generation.topP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.top_p,placeholder:`0.9`,description:g(`settings.generation.topPDescription`),onChange:e=>l(`top_p`,e)}),(0,Q.jsx)(jn,{label:g(`settings.generation.topK`),hint:`(1-100)`,min:1,max:100,value:e.top_k,placeholder:`40`,integer:!0,description:g(`settings.generation.topKDescription`),onChange:e=>l(`top_k`,e)}),(0,Q.jsx)(jn,{label:g(`settings.generation.minP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.min_p,placeholder:`0.0`,description:g(`settings.generation.minPDescription`),onChange:e=>l(`min_p`,e)})]}),(0,Q.jsxs)(An,{title:g(`settings.generation.generationControl`),children:[(0,Q.jsx)(jn,{label:g(`settings.generation.maxTokens`),min:-1,max:4096,value:e.num_predict,placeholder:`128`,integer:!0,description:g(`settings.generation.maxTokensDescription`),onChange:e=>l(`num_predict`,e)}),(0,Q.jsx)(jn,{label:g(`settings.generation.repeatPenalty`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.repeat_penalty,placeholder:`1.1`,description:g(`settings.generation.repeatPenaltyDescription`),onChange:e=>l(`repeat_penalty`,e)}),(0,Q.jsx)(jn,{label:g(`settings.generation.contextLength`),min:512,max:32768,step:512,value:e.num_ctx,placeholder:`2048`,integer:!0,description:g(`settings.generation.contextLengthDescription`),onChange:e=>l(`num_ctx`,e)}),(0,Q.jsx)(jn,{label:g(`settings.generation.seed`),hint:`(${g(`settings.generation.optional`)})`,value:e.seed,placeholder:g(`settings.generation.random`),integer:!0,description:g(`settings.generation.seedDescription`),onChange:e=>l(`seed`,e)}),(0,Q.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,Q.jsx)(`label`,{htmlFor:x,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:g(`settings.generation.thinking`)}),(0,Q.jsx)(Wt,{id:x,value:ln(e.think),onChange:e=>l(`think`,cn(e.target.value)),options:un.map(e=>({value:e,label:g(`settings.generation.thinkingLevels.${e}`)}))}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:g(`settings.generation.thinkingDescription`)})]})]}),(0,Q.jsxs)(An,{title:g(`settings.generation.advancedOptions`),children:[(0,Q.jsx)(jn,{label:g(`settings.generation.presencePenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.presence_penalty,placeholder:`0.0`,description:g(`settings.generation.presencePenaltyDescription`),onChange:e=>l(`presence_penalty`,e)}),(0,Q.jsx)(jn,{label:g(`settings.generation.frequencyPenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.frequency_penalty,placeholder:`0.0`,description:g(`settings.generation.frequencyPenaltyDescription`),onChange:e=>l(`frequency_penalty`,e)}),(0,Q.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,Q.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[g(`settings.generation.stopSequences`),(0,Q.jsxs)(`span`,{className:`text-xs text-gray-500 ms-1`,children:[`(`,g(`settings.generation.commaSeparated`),`)`]})]}),(0,Q.jsx)(`input`,{type:`text`,value:e.stop?.join(`, `)??``,onChange:e=>l(`stop`,e.target.value?e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean):void 0),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`,placeholder:`\\\\n, ###, STOP`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:g(`settings.generation.stopSequencesDescription`)})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(q,{onClick:f,variant:`outline`,className:`flex items-center gap-2`,children:[(0,Q.jsx)(re,{size:16}),g(`settings.generation.resetDefaults`)]}),(0,Q.jsxs)(q,{onClick:p,className:`flex items-center gap-2`,children:[(0,Q.jsx)(Ee,{size:16}),g(`settings.generation.saveOptions`)]})]})]})]}),(0,Q.jsx)(`div`,{className:`mt-6`,children:(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:g(`settings.generation.embeddingSettings`)}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:g(`settings.generation.enableEmbeddings`)}),(0,Q.jsx)(sn,{checked:i.enabled,onChange:e=>u(`enabled`,e)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:g(`settings.documents.embeddings.model`)}),(0,Q.jsx)(Wt,{value:a.model,onChange:e=>u(`model`,e.target.value),options:o,disabled:!i.enabled})]}),(0,Q.jsx)(Mn,{label:g(`settings.documents.embeddings.chunkSize`),hint:g(`settings.documents.embeddings.chunkSizeInTokens`),value:i.chunkSize,min:1,disabled:!i.enabled,onChange:e=>u(`chunkSize`,e)}),(0,Q.jsx)(Mn,{label:g(`settings.documents.embeddings.chunkOverlap`),hint:g(`settings.documents.embeddings.chunkOverlapInTokens`),value:i.chunkOverlap,min:0,disabled:!i.enabled,onChange:e=>u(`chunkOverlap`,e)}),(0,Q.jsx)(Mn,{label:g(`settings.documents.embeddings.similarityThreshold`),value:i.similarityThreshold,min:0,max:1,step:.01,disabled:!i.enabled,onChange:e=>u(`similarityThreshold`,e)})]}),c&&(0,Q.jsxs)(`div`,{className:`mt-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,Q.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[g(`settings.documents.embeddings.status`),`:`]}),(0,Q.jsx)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:c.available?g(`settings.documents.embeddings.available`):g(`settings.documents.embeddings.unavailable`)})]}),c.available&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-sm mt-1`,children:[(0,Q.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[g(`settings.documents.embeddings.chunksWithEmbeddings`),`:`]}),(0,Q.jsxs)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[c.chunksWithEmbeddings,` /`,` `,c.totalChunks]})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between items-center mt-4`,children:[(0,Q.jsxs)(q,{onClick:m,variant:`outline`,className:`flex items-center gap-2`,children:[(0,Q.jsx)(re,{size:16}),g(`settings.generation.resetDefaults`)]}),(0,Q.jsxs)(q,{onClick:h,className:`flex items-center gap-2`,children:[(0,Q.jsx)(Ee,{size:16}),g(`settings.saveSettings`)]})]})]})}),(0,Q.jsx)(kn,{})]})})}function kn(){let{t:e}=s(),t=Nt(e=>e.user),n=Nt(e=>e.systemInfo),r=t?.role===`admin`||n?.requiresAuth===!1,i=y(e=>e.models),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(`8000`),[u,d]=(0,Z.useState)(`8`),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(!1),[v,b]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{if(!r)return;let t=!1;return vt.getCompactionConfig().then(e=>{!t&&e.success&&e.data&&(o(e.data.enabled),l(String(e.data.thresholdTokens)),d(String(e.data.keepRecentMessages)),p(e.data.model),h(e.data.prompt),_(!0))}).catch(()=>{t||B.error(e(`settings.compaction.loadFailed`))}),()=>{t=!0}},[r,e]),!r)return null;let x=i.filter(e=>!e.isPersona&&!e.isAgent),S=[{value:``,label:e(`settings.compaction.sessionModelOption`)},...x.map(e=>({value:e.name,label:e.isPlugin?`${e.name} · ${e.pluginName||e.pluginId}`:`${e.name} · Ollama`})),...f&&!x.some(e=>e.name===f)?[{value:f,label:`${f} (current)`}]:[]],C=async(t=a)=>{let n=Number(c);if(!Number.isInteger(n)||n<500||n>1e6){B.error(e(`settings.compaction.thresholdInvalid`));return}let r=Number(u);if(!Number.isInteger(r)||r<2||r>200){B.error(e(`settings.compaction.keepRecentInvalid`));return}b(!0);try{let i=await vt.setCompactionConfig({enabled:t,thresholdTokens:n,keepRecentMessages:r,model:f,prompt:m});if(!i.success||!i.data)throw Error(i.error||e(`settings.compaction.saveFailed`));o(i.data.enabled),l(String(i.data.thresholdTokens)),d(String(i.data.keepRecentMessages)),p(i.data.model),h(i.data.prompt),B.success(e(`settings.compaction.saved`))}catch(t){B.error(t instanceof Error&&t.message?t.message:e(`settings.compaction.saveFailed`))}finally{b(!1)}};return(0,Q.jsx)(`div`,{className:`mt-6`,children:(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 mb-1`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300`,children:e(`settings.compaction.title`)}),(0,Q.jsx)(sn,{checked:a,onChange:e=>{C(e)},disabled:v||!g})]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-4`,children:e(`settings.compaction.description`)}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.compaction.thresholdLabel`)}),(0,Q.jsx)(`input`,{type:`number`,min:500,max:1e6,step:500,value:c,onChange:e=>l(e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:e(`settings.compaction.thresholdDescription`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.compaction.keepRecentLabel`)}),(0,Q.jsx)(`input`,{type:`number`,min:2,max:200,value:u,onChange:e=>d(e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:e(`settings.compaction.keepRecentDescription`)})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.compaction.modelLabel`)}),(0,Q.jsx)(Wt,{value:f,onChange:e=>p(e.target.value),options:S}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:e(`settings.compaction.modelDescription`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.compaction.promptLabel`)}),(0,Q.jsx)(qt,{value:m,onChange:e=>h(e.target.value),rows:5,placeholder:e(`settings.compaction.promptPlaceholder`),spellCheck:!1}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:e(`settings.compaction.promptDescription`,{previousSummaryVariable:`{{PREVIOUS_SUMMARY}}`,messagesVariable:`{{MESSAGES}}`})})]})]}),(0,Q.jsx)(`div`,{className:`flex justify-end items-center mt-4`,children:(0,Q.jsxs)(q,{onClick:()=>void C(),disabled:v||!g,className:`flex items-center gap-2`,children:[(0,Q.jsx)(Ee,{size:16}),e(`settings.saveSettings`)]})})]})})}function An({title:e,children:t}){return(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-4`,children:e}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:t})]})}function jn({label:e,value:t,placeholder:n,description:r,hint:i,min:a,max:o,step:s,integer:c=!1,onChange:l}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,i&&(0,Q.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:i})]}),(0,Q.jsx)(`input`,{type:`number`,min:a,max:o,step:s,value:t??``,placeholder:n,onChange:e=>l(e.target.value?c?parseInt(e.target.value):parseFloat(e.target.value):void 0),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:r})]})}function Mn({label:e,value:t,min:n,max:r,step:i,hint:a,disabled:o,onChange:s}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,a&&(0,Q.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:a})]}),(0,Q.jsx)(`input`,{type:`number`,min:n,max:r,step:i,value:t,onChange:e=>s(Number(e.target.value)),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`,disabled:o})]})}function Nn({loading:e,settings:t,effectiveSettings:n,models:r,plugins:i,sizes:a,qualities:o,styles:c,onSettingChange:l,onModelChange:u,onReset:d,onSave:f}){let{t:p}=s(),m=Mt(r,n.model,n.pluginId);return(0,Q.jsx)(`div`,{className:`space-y-6`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:p(`settings.imageGen.title`)}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:p(`settings.imageGen.description`)}),e?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Q.jsx)(L,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,Q.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:p(`settings.imageGen.loadingProviders`)})]}):r.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-yellow-200 bg-yellow-500/10 p-4 dark:border-yellow-800 dark:bg-yellow-900/20`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(I,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:p(`settings.imageGen.noProviders`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-ink-muted`,children:p(`settings.imageGen.noProvidersDescription`)})]})]})}):(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:p(`settings.imageGen.enable`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:p(`settings.imageGen.enableDescription`)})]}),(0,Q.jsx)(sn,{checked:t.enabled,onChange:e=>l(`enabled`,e)})]})}),(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:p(`settings.imageGen.configuration`)}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.model`)}),(0,Q.jsx)(Wt,{value:m?kt(m):``,onChange:e=>{let t=r.find(t=>kt(t)===e.target.value);t&&u(t.model,t.plugin)},disabled:!t.enabled,options:[{value:``,label:p(`settings.model.selectModel`)},...r.map(e=>({value:kt(e),label:`${e.model} (${e.plugin})`,key:`${e.plugin}:${e.model}`}))]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.modelDescription`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m?.config?.size_label||p(`settings.imageGen.size`)}),(0,Q.jsx)(Wt,{value:n.size,onChange:e=>l(`size`,e.target.value),disabled:!t.enabled||a.length===0,options:[...a.length>0?a.map(e=>({value:e,label:e})):[{value:`1024x1024`,label:`1024x1024`},{value:`1792x1024`,label:`1792x1024`},{value:`1024x1792`,label:`1024x1792`}]]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.sizeDescription`)})]}),o.length>0&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.quality`)}),(0,Q.jsx)(Wt,{value:n.quality,onChange:e=>l(`quality`,e.target.value),disabled:!t.enabled,options:o.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.qualityDescription`)})]}),c.length>0&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.style`)}),(0,Q.jsx)(Wt,{value:n.style,onChange:e=>l(`style`,e.target.value),disabled:!t.enabled,options:c.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.styleDescription`)})]})]})]}),i.length>0&&(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:p(`settings.imageGen.availableProviders`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:i.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-white dark:bg-dark-100 rounded border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,Q.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,p(`settings.imageGen.models`),`)`]})]},e.id))})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(q,{onClick:d,variant:`outline`,className:`flex items-center gap-2`,children:[(0,Q.jsx)(re,{size:16}),p(`common.reset`)]}),(0,Q.jsxs)(q,{onClick:f,className:`flex items-center gap-2`,children:[(0,Q.jsx)(Ee,{size:16}),p(`settings.saveSettings`)]})]})]})]})})}var Pn=192e3,Fn=(e,t)=>e.isPlugin&&e.pluginId?e.pluginId:t,In=()=>{let{t:e}=s(),t=y(e=>e.models),n=y(e=>e.loadModels),[r,i]=(0,Z.useState)([]),[a,o]=(0,Z.useState)([]),[c,l]=(0,Z.useState)([]),[u,f]=(0,Z.useState)({}),[p,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(`all`),[b,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),[D,k]=(0,Z.useState)(null),j=(0,Z.useRef)(null),M=(0,Z.useRef)(null),N=(0,Z.useMemo)(()=>t.filter(e=>!e.isPersona&&!e.isAgent),[t]);(0,Z.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await K.getModelVisibility();if(e||!t.success||!t.data)return;let{hidden:n,order:r,starred:a,metadata:s}=t.data;i(n??[]),o(r??[]),l(a??[]),f(s??{})}catch{}})(),()=>{e=!0}},[]);let P=(0,Z.useMemo)(()=>new Set(r),[r]),ee=(0,Z.useMemo)(()=>new Set(c),[c]),te=(0,Z.useMemo)(()=>m(N,a,c),[N,a,c]),ne=(0,Z.useMemo)(()=>{let e=p.trim().toLowerCase();return te.filter(t=>{let n=v(t);if(g===`local`&&t.isPlugin||g===`provider`&&!t.isPlugin||g===`hidden`&&!P.has(n))return!1;if(!e)return!0;let r=u[n]?.label??``;return t.name.toLowerCase().includes(e)||r.toLowerCase().includes(e)||Fn(t,`ollama`).toLowerCase().includes(e)})},[te,p,g,P,u]),L=async(e,t)=>{let n=r,a=t?n.filter(t=>t!==e):[...n,e];i(a),await le({hidden:a},()=>i(n))},re=e=>{let t=new Set(ne.map(v)),n=r,a=e?n.filter(e=>!t.has(e)):[...new Set([...n,...t])];i(a),le({hidden:a},()=>i(n))},ie=(e,t)=>{let n=c,r=t?[e,...n.filter(t=>t!==e)]:n.filter(t=>t!==e);l(r),le({starred:r},()=>l(n))},ae=(e,t,n)=>{if(e===t)return;let r=te.map(v),i=r.indexOf(e);if(i===-1)return;r.splice(i,1);let s=r.indexOf(t);if(s===-1)return;r.splice(n===`after`?s+1:s,0,e);let c=a;o(r),le({order:r},()=>o(c))},R=(e,t,n)=>{let r={...e,[t]:{...e[t],...n}};return!r[t].label&&!r[t].avatar&&delete r[t],r},oe=(e,t,n=!1)=>{let r=u,i=R(r,e,t);f(i),n&&le({metadata:i},()=>f(r))},se=e=>{M.current=e,j.current?.click()},ce=t=>{let n=t.target.files?.[0],r=M.current;if(t.target.value=``,!n||!r)return;if(!n.type.startsWith(`image/`)){B.error(e(`modelManager.catalog.pictureInvalid`));return}if(n.size>Pn){B.error(e(`modelManager.catalog.pictureTooLarge`));return}let i=new FileReader;i.onload=()=>{typeof i.result==`string`&&oe(r,{avatar:i.result},!0)},i.readAsDataURL(n)},le=async(t,r)=>{w(!0);try{let i=await K.setModelVisibility(t);if(!i.success){r(),B.error(i.error??e(`modelManager.catalog.visibilityFailed`));return}await n()}catch(t){r(),B.error(x(t,e(`modelManager.catalog.visibilityFailed`)))}finally{w(!1)}},ue=[{id:`all`,label:e(`modelManager.catalog.filterAll`)},{id:`local`,label:e(`modelManager.catalog.filterLocal`)},{id:`provider`,label:e(`modelManager.catalog.filterProviders`)},{id:`hidden`,label:e(`modelManager.catalog.filterHidden`)}];return(0,Q.jsxs)(`div`,{className:`space-y-3`,"data-testid":`model-catalog`,children:[(0,Q.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,Q.jsxs)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:[e(`modelManager.sections.catalog`),(0,Q.jsx)(`span`,{className:`ms-2 text-xs font-normal text-gray-500 dark:text-gray-400`,children:N.length})]}),C&&(0,Q.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`modelManager.catalog.saving`)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-[180px] flex-1`,children:[(0,Q.jsx)(F,{className:`pointer-events-none absolute start-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-gray-400`}),(0,Q.jsx)(Gt,{value:p,onChange:e=>h(e.target.value),placeholder:e(`modelManager.catalog.searchPlaceholder`),className:`ps-9`})]}),(0,Q.jsx)(`select`,{value:g,onChange:e=>_(e.target.value),className:`h-9 rounded-lg border border-gray-200 bg-white px-2 text-xs text-gray-700 dark:border-dark-300 dark:bg-dark-100 dark:text-gray-200`,"aria-label":e(`modelManager.catalog.filterAll`),children:ue.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.label},e.id))}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>re(!0),children:e(`modelManager.catalog.enableAll`)}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>re(!1),children:e(`modelManager.catalog.disableAll`)})]}),(0,Q.jsx)(`input`,{ref:j,type:`file`,accept:`image/*`,onChange:ce,className:`hidden`}),(0,Q.jsxs)(`div`,{className:`divide-y divide-gray-100 rounded-lg border border-gray-200 dark:divide-dark-200/60 dark:border-dark-300`,children:[ne.length===0&&(0,Q.jsx)(`p`,{className:`px-3 py-6 text-center text-xs text-gray-500 dark:text-gray-400`,children:N.length===0?e(`modelManager.catalog.noModels`):e(`modelManager.catalog.empty`)}),ne.map(t=>{let n=v(t),r=u[n]??{},i=!P.has(n),a=ee.has(n),o=b===n,s=e(a?`modelManager.catalog.unstar`:`modelManager.catalog.star`,{name:r.label||t.name});return(0,Q.jsxs)(`div`,{"data-testid":`model-catalog-row`,draggable:!0,onDragStart:()=>E(n),onDragEnd:()=>{E(null),k(null)},onDragOver:e=>{if(e.preventDefault(),!T||T===n)return;let t=e.currentTarget.getBoundingClientRect(),r=e.clientY-t.top<t.height/2?`before`:`after`;k(e=>e?.key===n&&e.edge===r?e:{key:n,edge:r})},onDrop:e=>{e.preventDefault(),T&&ae(T,n,D?.key===n?D.edge:`before`),E(null),k(null)},className:d(`relative flex flex-col gap-2 px-3 py-2`,T===n&&`opacity-50`),children:[D?.key===n&&T&&T!==n&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:d(`pointer-events-none absolute inset-x-0 h-0.5 bg-primary-500`,D.edge===`before`?`top-0`:`bottom-0`)}),(0,Q.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 pe-1`,children:[(0,Q.jsx)(z,{className:`h-4 w-4 shrink-0 cursor-grab text-gray-300 dark:text-dark-500`,"aria-hidden":`true`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>se(n),title:e(`modelManager.catalog.setPicture`),className:`flex h-7 w-7 shrink-0 items-center justify-center overflow-hidden rounded-full border border-gray-200 bg-gray-50 text-gray-400 dark:border-dark-300 dark:bg-dark-200`,children:r.avatar?(0,Q.jsx)(`img`,{src:r.avatar,alt:``,className:`h-full w-full object-cover`}):(0,Q.jsx)(I,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm text-gray-900 dark:text-gray-100`,children:r.label||t.name}),(0,Q.jsxs)(`span`,{className:`block truncate text-[11px] text-gray-500 dark:text-gray-400`,children:[r.label?`${t.name} · `:``,Fn(t,e(`modelManager.catalog.providerOllama`))]})]}),!i&&(0,Q.jsx)(`span`,{className:`shrink-0 rounded-md bg-gray-100 px-1.5 py-0.5 text-[10px] text-gray-500 dark:bg-dark-200 dark:text-gray-400`,children:e(`modelManager.catalog.hidden`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>ie(n,!a),"aria-pressed":a,title:s,"aria-label":s,className:d(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors hover:bg-gray-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-1 dark:hover:bg-dark-200 dark:focus-visible:ring-offset-dark-100`,a?`text-primary-600 dark:text-primary-400`:`text-gray-400 hover:text-gray-700 dark:hover:text-gray-200`),children:(0,Q.jsx)(A,{className:d(`h-4 w-4`,a&&`fill-current`),"aria-hidden":`true`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>S(o?null:n),title:e(`modelManager.catalog.rename`),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-gray-400 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-dark-200`,children:o?(0,Q.jsx)(Ke,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(Je,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void L(n,!i),"aria-pressed":!i,title:e(i?`modelManager.catalog.hide`:`modelManager.catalog.show`),"aria-label":e(i?`modelManager.catalog.hide`:`modelManager.catalog.show`),className:d(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors`,i?`text-gray-400 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-dark-200`:`text-warning-600 hover:bg-gray-100 dark:text-warning-500 dark:hover:bg-dark-200`),children:i?(0,Q.jsx)(pe,{className:`h-4 w-4`}):(0,Q.jsx)(O,{className:`h-4 w-4`})})]}),o&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ps-8`,children:[(0,Q.jsx)(Gt,{value:r.label??``,onChange:e=>oe(n,{label:e.target.value}),onBlur:e=>oe(n,{label:e.target.value},!0),placeholder:t.name,className:`h-8 max-w-xs text-xs`}),r.avatar&&(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>oe(n,{avatar:``},!0),children:e(`modelManager.catalog.clearPicture`)})]})]},n)})]})]})};function Ln({models:e,selectedModel:t,selectedProviderType:n,selectedProviderId:r,systemMessage:i,tempSystemMessage:a,loading:o,preferences:c,currentVisionModel:l,visionModelOptions:u,currentTaskModel:d,autoTitleTaskModelOptions:p,onModelChange:m,onSystemMessageChange:v,onSystemMessageSave:y,onAutoTitleChange:b,onAutoTitleTaskModelChange:x,onVisionModelChange:S}){let{user:C,systemInfo:w}=Nt(),T=C?.role===`admin`||w?.requiresAuth===!1,{t:E}=s(),D={model:t,providerType:n,providerId:r},O=f(e,D),k=t?_(O,D):``,A=g(O,D);return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:E(`settings.model.title`)}),(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:E(`settings.model.defaultModel`)}),(0,Q.jsx)(Wt,{value:k,onChange:m,options:[{value:``,label:E(`settings.model.selectModel`)},...O.map(e=>({value:h(e),label:e.isLegacySelection?`${e.name} (provider not recorded${e.isUnavailable?`, unavailable`:``})`:e.isPersona?`${e.personaName} (${E(`settings.model.persona`)})`:e.isPlugin?`${e.name} (${e.pluginName||e.pluginId}${e.isUnavailable?`, unavailable`:``})`:`${e.name} (Ollama${e.isUnavailable?`, unavailable`:``})`}))]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:E(`settings.model.defaultModelDescription`)})]}),t&&(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:E(`settings.model.currentModelInfo`)}),(0,Q.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,Q.jsx)(Rn,{label:`${E(`settings.model.name`)}:`,value:t,truncate:!0}),A?.details&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Rn,{label:`${E(`settings.model.size`)}:`,value:A.details.parameter_size}),(0,Q.jsx)(Rn,{label:`${E(`settings.model.family`)}:`,value:A.details.family}),(0,Q.jsx)(Rn,{label:`${E(`settings.model.format`)}:`,value:A.details.format})]})]})})]}),(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:E(`settings.systemMessage.title`)}),(0,Q.jsx)(qt,{value:a,onChange:v,placeholder:E(`settings.systemMessage.placeholder`),className:`w-full min-h-[100px] bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,rows:4}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mt-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:E(`settings.systemMessage.description`)}),(0,Q.jsx)(q,{onClick:y,size:`sm`,disabled:o||a===i,children:E(`common.save`)})]})]})]}),(0,Q.jsx)(`div`,{className:`mt-6`,children:(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:E(`settings.model.specializedModels`,{defaultValue:`Specialized Models`})}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-5 lg:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:E(`settings.model.visionModel`,{defaultValue:`Vision Model`})}),(0,Q.jsx)(Wt,{"data-testid":`vision-model-select`,value:l,onChange:e=>S(e.target.value),options:u}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:E(`settings.model.visionModelDescription`,{defaultValue:`Used automatically whenever the outgoing chat context contains images. Choose a model that supports image input.`})})]}),(0,Q.jsxs)(`div`,{className:`lg:border-s lg:border-gray-200 lg:ps-5 dark:lg:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col pe-4`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:E(`settings.model.autoTitle.enable`)}),(0,Q.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:E(`settings.model.autoTitle.enableDescription`)})]}),(0,Q.jsx)(sn,{checked:c.titleSettings?.autoTitle||!1,onChange:b})]}),c.titleSettings?.autoTitle&&(0,Q.jsxs)(`div`,{className:`mt-4`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:E(`settings.model.autoTitle.taskModel`)}),(0,Q.jsx)(Wt,{value:d,onChange:e=>x(e.target.value),options:p}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:E(`settings.model.autoTitle.taskModelDescription`)})]})]})]})]})})]}),T&&(0,Q.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Q.jsx)(In,{})})]})}function Rn({label:e,value:t,truncate:n=!1}){return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-white dark:bg-dark-100 rounded-md border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e}),(0,Q.jsx)(`span`,{className:n?`text-sm font-semibold text-gray-900 dark:text-gray-100 truncate ms-2`:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t})]})}var zn=[{titleKey:`keyboard.groups.general`,rows:[{labelKey:`keyboard.openPalette`,keys:[`mod`,`K`]},{labelKey:`keyboard.openSettings`,keys:[`mod`,`,`]},{labelKey:`keyboard.toggleDarkMode`,keys:[`mod`,`D`]},{labelKey:`keyboard.showShortcuts`,keys:[`?`]},{labelKey:`keyboard.closeModals`,keys:[`Esc`]}]},{titleKey:`keyboard.groups.navigation`,rows:[{labelKey:`keyboard.toggleSidebar`,keys:[`mod`,`B`]},{labelKey:`keyboard.newChat`,keys:[`mod`,`⇧`,`O`]},{labelKey:`keyboard.newWork`,keys:[`mod`,`⇧`,`U`]}]},{titleKey:`keyboard.groups.chat`,rows:[{labelKey:`keyboard.actions.sendMessage`,keys:[`↩`]},{labelKey:`keyboard.actions.newLine`,keys:[`⇧`,`↩`]},{labelKey:`keyboard.actions.saveEdit`,keys:[`↩`]},{labelKey:`keyboard.actions.cancelEdit`,keys:[`Esc`]}]},{titleKey:`keyboard.groups.workspace`,rows:[{labelKey:`keyboard.actions.saveFile`,keys:[`mod`,`S`]},{labelKey:`keyboard.actions.formatCode`,keys:[`⌥`,`⇧`,`F`]}]}];function Bn(){let{t:e}=s(),t=u()?`⌘`:`Ctrl`,n=u()?`⌥`:`Alt`,r=e=>e===`mod`?t:e===`⌥`?n:e;return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:e(`keyboard.title`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-600 dark:text-gray-400`,children:e(`keyboard.description`)})]}),zn.map(t=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:e(t.titleKey)}),(0,Q.jsx)(`div`,{className:`divide-y divide-gray-200 overflow-hidden rounded-lg border border-gray-200 dark:divide-dark-300 dark:border-dark-300`,children:t.rows.map(n=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 bg-white px-4 py-2.5 dark:bg-dark-100`,children:[(0,Q.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e(n.labelKey)}),(0,Q.jsx)(`span`,{className:`flex shrink-0 items-center gap-1`,children:n.keys.map((e,t)=>(0,Q.jsx)(`kbd`,{className:`rounded border border-gray-300 bg-gray-100 px-2 py-1 font-mono text-xs text-gray-700 dark:border-dark-400 dark:bg-dark-200 dark:text-gray-300`,children:r(e)},`${n.labelKey}-${e}-${t}`))})]},`${t.titleKey}-${n.labelKey}`))})]},t.titleKey))]})}var Vn=8;function Hn(e,t){let n=e.trim();if(!n)return null;let r;try{r=new URL(n)}catch{return`invalid-url`}return r.protocol!==`http:`&&r.protocol!==`https:`?`insecure-url`:t?.toLowerCase().endsWith(`base_url`)&&(r.search||r.hash)?`query-or-fragment`:null}function Un(e){try{return new URL(e.trim()).protocol===`http:`}catch{return!1}}function Wn(e){let t=e.toLowerCase();return t===`endpoint`||t===`base_url`||t===`api_url`||t===`models_endpoint`||t.endsWith(`_endpoint`)||t.endsWith(`_base_url`)}function Gn(e){let t=e.trim();if(!t.startsWith(`/`)||t.startsWith(`//`)||t.includes(`://`)||t.includes(`\\`)||t.includes(`?`)||t.includes(`#`))return!1;let n=t;for(let e=0;e<=Vn;e+=1){let t;try{t=decodeURIComponent(n)}catch{return!1}if(t===n)return!n.includes(`\\`)&&!n.includes(`?`)&&!n.includes(`#`)&&!n.split(`/`).some(e=>e===`.`||e===`..`);if(e===Vn)return!1;n=t}return!1}var Kn=new Set([`api_mode`,`api_path`,`endpoint`,`base_url`,`api_url`,`image_endpoint`,`embedding_endpoint`,`tts_endpoint`,`model`,`model_id`,`models_endpoint`]);function qn(e){let t=new Set(Kn),n=e?.capabilities;for(let e of Object.values(n||{})){let n=e?.config?.endpoint_variable??e?.endpoint_variable;typeof n==`string`&&n.trim()&&t.add(n)}return t}function Jn(e,t){return qn(t).has(e)}function Yn(e,t){if(e.default!==void 0)return e.default;if(!t)return;if(e.name===`endpoint`||e.name===`api_url`)return t.endpoint||void 0;if(e.name===`base_url`)return t.base_url;if(e.name===`api_path`)return t.api_path;if(e.name===`api_mode`){if(t.api_mode)return t.api_mode;try{return new URL(t.endpoint).pathname.replace(/\/+$/,``).endsWith(`/responses`)?`responses`:`chat_completions`}catch{return`chat_completions`}}let n=t.capabilities;for(let t of Object.values(n||{}))if((t?.config?.endpoint_variable??t?.endpoint_variable)===e.name&&typeof t.endpoint==`string`)return t.endpoint}function Xn(e,t){let n=[],r=[];for(let i of e)(Jn(i.name,t)?n:r).push(i);return{connection:n,advanced:r}}function Zn(e,t){let n={};for(let r of e){let e=t[r.name];n[r.name]=e?.has_value&&!e.is_sensitive?e.value:``}return n}function Qn(e,t,n,r,i){let a=new Set(e.map(e=>e.name)),o={},s=[];for(let c of n){if(!a.has(c))continue;let n=e.find(e=>e.name===c);if(!n)continue;let l=t[c],u=r[c],d=typeof l==`string`&&l.trim().length===0,f=Yn(n,i),p=f!==void 0&&(typeof l==`string`&&typeof f==`string`?l.trim()===f.trim():Object.is(l,f));if(d||p){if(n.sensitive&&u?.has_value)continue;u?.has_value&&s.push(c);continue}o[c]=l}return{variables:o,unset:s}}o(`components:hugging-face-model-browser`);var $n=({plugin:e})=>{let{t}=s(),n=r(),i=Nt(e=>e.user),a=Nt(e=>e.systemInfo)?.requiresAuth===!1||i?.role===`admin`,{pluginVariables:o,fetchPluginVariables:c,updatePluginVariables:l,resetPluginVariables:u,loadPlugins:f}=Pt(),[p,m]=(0,Z.useState)({}),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(new Set),[x,S]=(0,Z.useState)({}),[C,w]=(0,Z.useState)(new Set),[T,E]=(0,Z.useState)(!1),D=Z.useId(),A=Z.useId(),j=(0,Z.useMemo)(()=>e.variables||[],[e.variables]),M=(0,Z.useMemo)(()=>qn(e),[e]),N=(0,Z.useMemo)(()=>a?j:j.filter(e=>!M.has(e.name)),[a,M,j]),P=(0,Z.useMemo)(()=>o[e.id]||{},[o,e.id]),F=(0,Z.useMemo)(()=>Xn(N,e),[e,N]);(0,Z.useEffect)(()=>{c(e.id)},[c,e.id]);let I=JSON.stringify(P),ee=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let t=N.map(e=>`${e.name}:${e.type}`).join(`|`),n=`${e.id}:${t}:${I}`;if(ee.current===n)return;ee.current=n;let r=JSON.parse(I);m(e=>{let t=Zn(N,r);for(let n of C)n in e&&(t[n]=e[n]);return t})},[C,e.id,N,I]);let te=async()=>{let r={};for(let n of N){if(!C.has(n.name))continue;let i=p[n.name],a=typeof i==`string`&&i.trim().length===0,o=P[n.name],s=Yn(n,e);if(a&&n.required&&s===void 0&&!(n.sensitive&&o?.has_value)){r[n.name]=t(`pluginManager.variables.required`,`A value is required`);continue}if(Wn(n.name)&&typeof i==`string`&&!a){let e=Hn(i,n.name);e===`invalid-url`?r[n.name]=t(`pluginManager.variables.invalidUrl`,`Enter a valid full API endpoint URL, for example https://provider.example/v1/chat/completions`):e===`insecure-url`?r[n.name]=t(`pluginManager.variables.insecureUrl`,`API endpoints must use HTTP or HTTPS.`):e===`query-or-fragment`&&(r[n.name]=t(`pluginManager.variables.invalidBaseUrl`,`Base URLs cannot contain a query string or fragment.`))}if(n.name===`api_path`&&typeof i==`string`&&i.length>0&&!Gn(i)&&(r[n.name]=t(`pluginManager.variables.invalidApiPath`,`Must start with / and contain no URL, query, fragment, or .. segment`)),n.type===`number`&&!a){let e=Number(i);n.min!==void 0&&e<n.min&&(r[n.name]=`Min: ${n.min}`),n.max!==void 0&&e>n.max&&(r[n.name]=`Max: ${n.max}`)}n.type===`string`&&typeof i==`string`&&i.length>2048&&(r[n.name]=t(`pluginManager.variables.tooLong`,`Value is too long`))}if(S(r),Object.keys(r).length>0)return;let i=Qn(N,p,C,P,e),a=new Set(C),o=Object.fromEntries([...Object.keys(i.variables).map(e=>[e,!0]),...i.unset.map(e=>[e,!0])]);if(Object.keys(i.variables).length===0&&i.unset.length===0){w(e=>{let t=new Set(e);for(let e of a)t.delete(e);return t}),S(e=>{let t={...e};for(let e of a)delete t[e];return t}),k.success(t(`pluginManager.variables.saved`,`Variables saved`));return}g(!0);try{await l(e.id,i.variables,i.unset)?(Object.keys(o).some(e=>M.has(e))&&(await f(),await Promise.all([n.invalidateQueries({queryKey:[`image-gen-data`]}),n.invalidateQueries({queryKey:[`tts-data`]})])),m(e=>{let t={...e};for(let e of N)e.sensitive&&a.has(e.name)&&(t[e.name]=``);return t}),b(e=>{let t=new Set(e);for(let e of N)e.sensitive&&a.has(e.name)&&t.delete(e.name);return t}),w(e=>{let t=new Set(e);for(let e of a)t.delete(e);return t}),S(e=>{let t={...e};for(let e of a)delete t[e];return t}),k.success(t(`pluginManager.variables.saved`,`Variables saved`))):k.error(t(`pluginManager.variables.saveFailed`,`Failed to save variables`))}finally{g(!1)}},ne=async()=>{v(!0);try{if(!await u(e.id)){k.error(t(`pluginManager.variables.resetFailed`,`Failed to reset variables`));return}N.some(e=>M.has(e.name))&&(await f(),await Promise.all([n.invalidateQueries({queryKey:[`image-gen-data`]}),n.invalidateQueries({queryKey:[`tts-data`]})])),m(Zn(N,{})),w(new Set),S({}),b(new Set),k.success(t(`pluginManager.variables.reset`,`Variables reset to defaults`))}finally{v(!1)}},L=(e,t)=>{m(n=>({...n,[e]:t})),w(t=>new Set(t).add(e)),S(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},ie=e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ae=e=>{let t=N.indexOf(e),n=`${A}-${t}`;return{controlId:n,descriptionId:`${n}-description`,errorId:`${n}-error`,warningId:`${n}-http-warning`}},R=t=>{if(!Wn(t.name))return!1;let n=p[t.name],r=Yn(t,e),i=typeof n==`string`&&n.trim()?n:r;return typeof i==`string`&&Un(i)},oe=n=>{let r=p[n.name],i=n.sensitive??!1,a=y.has(n.name),o=P[n.name],{controlId:s,descriptionId:c,errorId:l,warningId:u}=ae(n),f=!!x[n.name],m=R(n),g=n.name===`endpoint`||n.name===`api_url`,v=[n.description||g?c:void 0,m?u:void 0,f?l:void 0].filter(Boolean).join(` `)||void 0,b=Yn(n,e),S=b===void 0?t(`pluginManager.variables.inherited`,`Use provider default`):t(`pluginManager.variables.inheritedValue`,{defaultValue:`Use provider default ({{value}})`,value:String(b)}),C=d(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-white dark:bg-dark-100`,`border-gray-300 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-blue-500/20`);switch(n.type){case`boolean`:return(0,Q.jsxs)(`select`,{id:s,value:r===``?``:String(!!r),onChange:e=>L(n.name,e.target.value===``?``:e.target.value===`true`),className:C,"aria-invalid":f,"aria-describedby":v,disabled:h||_,children:[(0,Q.jsx)(`option`,{value:``,children:S}),(0,Q.jsx)(`option`,{value:`true`,children:t(`pluginManager.variables.enabled`,`Enabled`)}),(0,Q.jsx)(`option`,{value:`false`,children:t(`pluginManager.variables.disabled`,`Disabled`)})]});case`select`:return(0,Q.jsxs)(`select`,{id:s,value:String(r??``),onChange:e=>L(n.name,e.target.value),className:C,"aria-invalid":f,"aria-describedby":v,disabled:h||_,children:[(0,Q.jsx)(`option`,{value:``,children:S}),(n.options||[]).map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]});case`number`:return(0,Q.jsx)(`input`,{id:s,type:`number`,value:r===``?``:Number(r),min:n.min,max:n.max,placeholder:S,onChange:e=>L(n.name,e.target.value===``?``:Number(e.target.value)),className:C,"aria-invalid":f,"aria-describedby":v,disabled:h||_});default:return(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`input`,{id:s,type:i&&!a?`password`:`text`,value:i&&o?.has_value&&r===``?``:String(r??``),placeholder:i&&o?.has_value?t(`pluginManager.variables.sensitiveSet`,`Value is set (enter new value to change)`):S,onChange:e=>L(n.name,e.target.value),className:d(C,i&&`pr-10`),"aria-invalid":f,"aria-describedby":v,disabled:h||_}),i&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>ie(n.name),"aria-controls":s,"aria-label":a?t(`pluginManager.variables.hideValue`,{defaultValue:`Hide {{label}} value`,label:n.label}):t(`pluginManager.variables.showValue`,{defaultValue:`Show {{label}} value`,label:n.label}),disabled:h||_,className:`absolute end-2 top-1/2 -translate-y-1/2 p-1 text-gray-400 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-50 dark:hover:text-gray-300`,children:a?(0,Q.jsx)(O,{className:`w-4 h-4`}):(0,Q.jsx)(pe,{className:`w-4 h-4`})})]})}},se=e=>{let{controlId:n,descriptionId:r,errorId:i,warningId:a}=ae(e),o=e.name===`endpoint`||e.name===`api_url`,s=R(e);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{htmlFor:n,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:[o?t(`pluginManager.variables.fullApiEndpoint`,`Full API endpoint URL`):e.label,e.required&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`text-red-500 ml-1`,children:`*`})]}),(e.description||o)&&(0,Q.jsxs)(`p`,{id:r,className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:[e.description,e.description&&o&&` `,o&&t(`pluginManager.variables.endpointHelp`,`Enter the complete request URL, including its operation path (for example, /v1/chat/completions), not only the provider base URL.`)]}),oe(e),s&&(0,Q.jsxs)(`p`,{id:a,role:`status`,className:`mt-1 flex items-start gap-1 text-xs text-amber-700 dark:text-amber-400`,children:[(0,Q.jsx)(ze,{"aria-hidden":`true`,className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{children:t(`pluginManager.variables.httpWarning`,`HTTP does not encrypt credentials or traffic. Use it only on a trusted network.`)})]}),x[e.name]&&(0,Q.jsx)(`p`,{id:i,role:`alert`,className:`text-xs text-red-500 mt-1`,children:x[e.name]})]},e.name)};return(0,Q.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-gray-200 dark:border-gray-700`,children:[F.connection.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:t(`pluginManager.variables.connection`,`Connection`)}),F.connection.map(se)]}),F.advanced.length>0&&(0,Q.jsxs)(`div`,{className:d(F.connection.length>0&&`mt-4 border-t pt-4`,`border-gray-200 dark:border-gray-700`),children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":T,"aria-controls":D,onClick:()=>E(e=>!e),className:`flex w-full items-center justify-between rounded-md py-1 text-left text-sm font-medium text-gray-700 hover:text-gray-950 dark:text-gray-300 dark:hover:text-white`,children:[(0,Q.jsxs)(`span`,{children:[t(`pluginManager.variables.advanced`,`Advanced parameters`),` (`,F.advanced.length,`)`]}),(0,Q.jsx)(xe,{className:d(`h-4 w-4 transition-transform`,T&&`rotate-180`)})]}),T&&(0,Q.jsx)(`div`,{id:D,className:`mt-3 space-y-3`,children:F.advanced.map(se)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-4`,children:[(0,Q.jsxs)(q,{size:`sm`,onClick:te,disabled:h||_||C.size===0,className:`gap-1.5`,children:[(0,Q.jsx)(Xe,{className:`w-3.5 h-3.5`}),h?t(`pluginManager.variables.saving`,`Saving...`):t(`pluginManager.variables.save`,`Save`)]}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:ne,disabled:h||_,className:`gap-1.5`,children:[(0,Q.jsx)(re,{className:`w-3.5 h-3.5`}),t(`pluginManager.variables.resetDefaults`,`Reset to Defaults`)]})]})]})};function er({plugins:e,loading:t,uploading:n,error:r,hasKeys:i,showUploadForm:a,showJsonForm:o,jsonInput:c,fileInputRef:l,expandedPluginId:u,pluginApiKeys:d,showApiKey:f,savingApiKey:m,refreshingPluginIds:h,onClearError:g,onShowUploadFormChange:_,onShowJsonFormChange:v,onJsonInputChange:y,onFileUpload:b,onJsonSubmit:x,onExpandedPluginChange:S,onPluginApiKeyChange:w,onShowApiKeyChange:T,onActivatePlugin:E,onDeletePlugin:D,onExportPlugin:O,onSaveApiKey:k,onDeleteApiKey:A,onRefreshModels:j}){let{t:M}=s(),N=Nt(e=>e.user),P=Nt(e=>e.systemInfo)?.requiresAuth===!1||N?.role===`admin`,[I,ee]=(0,Z.useState)(``),[te,ne]=(0,Z.useState)(null),re=(0,Z.useId)(),ie=(0,Z.useMemo)(()=>e.filter(e=>p(e,I)),[e,I]),ae=te&&e.some(e=>e.id===te)?te:e[0]?.id??null,R=e.find(e=>e.id===ae)??null,oe=e=>{e!==ae&&(S(null),ne(e))};return(0,Q.jsx)(`div`,{className:`space-y-6`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-4`,children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:M(`settings.plugins.providerConnections`,{defaultValue:`Provider connections`})}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:M(`settings.plugins.providerConnectionsDescription`,{defaultValue:`Connect, configure, and inspect model providers through plugins.`})})]}),r&&(0,Q.jsx)(`div`,{className:`p-4 bg-primary-50/80 dark:bg-primary-950/25 border border-primary-200 dark:border-primary-800/50 rounded-lg mb-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`p`,{className:`text-primary-800 dark:text-primary-200`,children:r}),(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:g,className:`text-primary-700 hover:text-primary-900 dark:text-primary-300 dark:hover:text-primary-100`,children:(0,Q.jsx)(Ke,{className:`h-4 w-4`})})]})}),P&&(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:M(`settings.plugins.addNew`)}),(0,Q.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>_(!a),disabled:t||n,children:[(0,Q.jsx)(Ye,{className:`h-4 w-4 me-2`}),M(`settings.plugins.upload`)]}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>v(!o),disabled:t,children:M(`settings.plugins.addJson`)})]})]}),a&&(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center space-x-4`,children:[(0,Q.jsx)(`input`,{ref:l,type:`file`,accept:`.json,.zip`,onChange:b,className:`flex-1 p-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 file:me-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-gray-100 file:text-gray-700 dark:file:bg-dark-200 dark:file:text-dark-700 hover:file:bg-gray-200 dark:hover:file:bg-dark-300`,disabled:n}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>_(!1),disabled:n,children:M(`common.cancel`)})]}),n&&(0,Q.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mt-2`,children:M(`settings.plugins.uploading`)})]}),o&&(0,Q.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`textarea`,{value:c,onChange:e=>y(e.target.value),placeholder:M(`settings.plugins.jsonPlaceholder`),className:`w-full h-32 p-3 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 placeholder:text-gray-400 dark:placeholder:text-dark-500 font-mono text-sm`,disabled:t}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end space-x-2`,children:[(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>{v(!1),y(``)},children:M(`common.cancel`)}),(0,Q.jsx)(q,{size:`sm`,onClick:x,disabled:!c.trim()||t,children:M(`settings.plugins.install`)})]})]})})]}),(0,Q.jsx)(`div`,{"data-testid":`provider-workspace`,className:`overflow-hidden rounded-xl border border-gray-200 bg-white dark:border-dark-300 dark:bg-dark-100`,children:(0,Q.jsxs)(`div`,{className:`grid min-h-[30rem] grid-cols-1 lg:grid-cols-[minmax(15rem,0.8fr)_minmax(0,1.6fr)]`,children:[(0,Q.jsxs)(`section`,{"data-testid":`provider-list`,"aria-label":M(`settings.plugins.providers`,{defaultValue:`Providers`}),className:`border-b border-gray-200 dark:border-dark-300 lg:flex lg:min-h-0 lg:flex-col lg:border-b-0 lg:border-e`,children:[(0,Q.jsxs)(`div`,{className:`border-b border-gray-200 p-4 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:M(`settings.plugins.providers`,{defaultValue:`Providers`})}),(0,Q.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-xs text-gray-600 dark:bg-dark-200 dark:text-gray-300`,children:e.length})]}),(0,Q.jsx)(`label`,{htmlFor:re,className:`sr-only`,children:M(`settings.plugins.searchProviders`,{defaultValue:`Search providers`})}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(F,{"aria-hidden":`true`,className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,Q.jsx)(`input`,{id:re,type:`search`,value:I,onChange:e=>ee(e.target.value),placeholder:M(`settings.plugins.searchProviders`,{defaultValue:`Search providers`}),className:`w-full rounded-lg border border-gray-300 bg-white py-2 pe-3 ps-9 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`})]})]}),(0,Q.jsx)(`div`,{className:`max-h-[32rem] space-y-2 overflow-y-auto p-3 lg:min-h-0 lg:max-h-none lg:flex-1`,children:t&&e.length===0?(0,Q.jsxs)(`div`,{className:`p-6 text-center text-sm text-gray-500 dark:text-gray-400`,children:[(0,Q.jsx)(L,{className:`mx-auto mb-2 h-5 w-5 animate-spin`}),M(`settings.plugins.loading`)]}):e.length===0?(0,Q.jsxs)(`div`,{className:`p-6 text-center`,children:[(0,Q.jsx)(ue,{className:`mx-auto mb-3 h-9 w-9 text-gray-400`}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:M(`settings.plugins.noPlugins`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-gray-400 dark:text-gray-500`,children:M(`settings.plugins.noPluginsDescription`)})]}):ie.length===0?(0,Q.jsx)(`p`,{className:`p-6 text-center text-sm text-gray-500 dark:text-gray-400`,children:M(`settings.plugins.noProvidersFound`,{defaultValue:`No providers match your search.`})}):ie.map(e=>{let t=ae===e.id,n=C(e).length;return(0,Q.jsx)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:()=>oe(e.id),className:`w-full rounded-xl border p-3 text-start transition-colors ${t?`border-blue-500 bg-blue-50/70 dark:border-blue-500 dark:bg-blue-950/20`:`border-gray-200 hover:border-gray-300 hover:bg-gray-50 dark:border-dark-300 dark:hover:border-dark-400 dark:hover:bg-dark-50`}`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 h-2.5 w-2.5 shrink-0 rounded-full ${e.active?`bg-green-500`:`bg-gray-400 dark:bg-gray-500`}`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`sr-only`,children:[e.active?M(`settings.plugins.activeLabel`):M(`settings.plugins.inactive`),`.`,` `]}),(0,Q.jsx)(`span`,{className:`block truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:e.name}),(0,Q.jsxs)(`span`,{className:`mt-0.5 block text-xs capitalize text-gray-500 dark:text-gray-400`,children:[e.type,` · `,n,` `,M(`settings.plugins.models`)]})]})]})},e.id)})})]}),(0,Q.jsx)(`section`,{"data-testid":`provider-detail`,className:`min-w-0 p-4 sm:p-5`,children:R?(0,Q.jsx)(tr,{plugin:R,loading:t,hasApiKey:i[R.id]||!1,expanded:u===R.id,apiKey:d[R.id]||``,showApiKey:f[R.id]||!1,savingApiKey:m===R.id,refreshingModels:!!h[R.id],canManagePlugin:P,onExpand:()=>S(u===R.id?null:R.id),onActivate:()=>E(R.id),onExport:()=>O(R.id),onDelete:()=>D(R.id),onRefreshModels:()=>j(R.id),onApiKeyChange:e=>w(R.id,e),onShowApiKeyChange:e=>T(R.id,e),onSaveApiKey:()=>k(R.id),onDeleteApiKey:()=>A(R.id)}):(0,Q.jsx)(`div`,{className:`flex min-h-[24rem] items-center justify-center text-center`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(ue,{className:`mx-auto mb-3 h-10 w-10 text-gray-400`}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:M(`settings.plugins.selectProvider`,{defaultValue:`Select a provider`})}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:M(`settings.plugins.selectProviderDescription`,{defaultValue:`Choose a provider to inspect its connection and model catalog.`})})]})})})]})})]})})}function tr({plugin:e,loading:t,hasApiKey:n,expanded:r,apiKey:i,showApiKey:a,savingApiKey:o,refreshingModels:c,canManagePlugin:l,onExpand:u,onActivate:d,onExport:f,onDelete:p,onRefreshModels:m,onApiKeyChange:h,onShowApiKeyChange:g,onSaveApiKey:_,onDeleteApiKey:v}){let{t:y}=s(),b=!!(e.auth?.header||e.auth?.key_env),x=qn(e),w=l?e.variables||[]:(e.variables||[]).filter(e=>!x.has(e.name)),T=w.length>0,E=b||T,D=(0,Z.useId)(),O=C(e),k=e.base_url||e.endpoint;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 border-b border-gray-200 pb-4 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full ${e.active?`bg-green-500`:`bg-gray-400 dark:bg-gray-500`}`}),(0,Q.jsx)(`h4`,{className:`truncate text-lg font-semibold text-gray-900 dark:text-gray-100`,children:e.name})]}),(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:[e.id,` · `,(0,Q.jsx)(`span`,{className:`capitalize`,children:e.type}),b&&n&&(0,Q.jsxs)(`span`,{className:`text-green-600`,children:[` `,`· `,y(`settings.plugins.apiKeySet`)]})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[E&&(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:u,"aria-expanded":r,"aria-controls":D,title:y(`settings.plugins.configure`),className:n?`text-green-600`:``,children:[b?(0,Q.jsx)(te,{className:`h-4 w-4`}):(0,Q.jsx)(se,{className:`h-4 w-4`}),y(`settings.plugins.configure`),r?(0,Q.jsx)(Ze,{className:`h-3 w-3`}):(0,Q.jsx)(xe,{className:`h-3 w-3`})]}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:d,disabled:t,className:e.active?`border-green-300 text-green-600`:``,children:e.active?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ee,{className:`h-4 w-4`}),y(`settings.plugins.deactivate`)]}):y(`settings.plugins.activate`)}),l&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:f,disabled:t,title:y(`settings.plugins.exportPlugin`,`Export plugin`),className:`px-2`,children:(0,Q.jsx)(j,{className:`h-4 w-4`})}),(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:p,disabled:t,className:`px-2 text-red-600 hover:bg-red-50 hover:text-red-700`,title:y(`settings.plugins.deletePlugin`,`Delete plugin`),children:(0,Q.jsx)(V,{className:`h-4 w-4`})})]})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:y(`settings.plugins.status`,{defaultValue:`Status`})}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-900 dark:text-gray-100`,children:e.active?y(`settings.plugins.activeLabel`):y(`settings.plugins.inactive`)})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:y(`settings.plugins.models`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-900 dark:text-gray-100`,children:O.length})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:y(`settings.plugins.defaultEndpoint`,{defaultValue:`Default endpoint`})}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-sm text-gray-900 dark:text-gray-100`,title:k,children:k})]})]})]}),r&&E&&(0,Q.jsxs)(`div`,{id:D,children:[b&&(0,Q.jsx)(rr,{plugin:e,hasApiKey:n,apiKey:i,showApiKey:a,savingApiKey:o,onApiKeyChange:h,onShowApiKeyChange:g,onSaveApiKey:_,onDeleteApiKey:v}),T&&(0,Q.jsxs)(`div`,{className:`mt-4 rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-dark-300 dark:bg-dark-50`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,Q.jsx)(se,{className:`h-4 w-4 text-gray-500`}),(0,Q.jsxs)(`h5`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:[y(`settings.plugins.providerSettings`),` (`,w.length,`)`]})]}),(0,Q.jsx)($n,{plugin:e},e.id)]})]}),(0,Q.jsx)(nr,{catalog:O,canRefresh:S(e),refreshing:c,onRefresh:m})]})}function nr({catalog:e,canRefresh:t,refreshing:n,onRefresh:r}){let{t:i}=s();return(0,Q.jsxs)(`section`,{"data-testid":`provider-model-catalog`,className:`mt-5`,children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h5`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:i(`settings.plugins.modelCatalog`,{defaultValue:`Model catalog`})}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:i(`settings.plugins.modelCatalogDescription`,{defaultValue:`Discovered and configured models for this provider and its capabilities.`})})]}),t&&(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:r,disabled:n,"aria-busy":n,children:[n?(0,Q.jsx)(L,{className:`h-4 w-4 animate-spin`}):(0,Q.jsx)(Te,{className:`h-4 w-4`}),i(`settings.plugins.refreshModels`,{defaultValue:`Refresh models`})]})]}),e.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-500 dark:border-dark-300 dark:text-gray-400`,children:i(`settings.plugins.noModelsConfigured`,{defaultValue:`No models are configured for this provider.`})}):(0,Q.jsx)(`div`,{className:`max-h-[26rem] overflow-auto rounded-lg border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`table`,{className:`w-full min-w-[24rem] text-start text-sm`,children:[(0,Q.jsx)(`thead`,{className:`sticky top-0 z-10 bg-gray-50 text-xs uppercase tracking-wide text-gray-500 dark:bg-dark-50 dark:text-gray-400`,children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 text-start font-medium`,children:i(`settings.plugins.modelId`,{defaultValue:`Model ID`})}),(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 text-start font-medium`,children:i(`settings.plugins.capabilities`,{defaultValue:`Capabilities`})})]})}),(0,Q.jsx)(`tbody`,{className:`divide-y divide-gray-200 dark:divide-dark-300`,children:e.map(e=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-xs text-gray-900 dark:text-gray-100`,children:e.id}),(0,Q.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.capabilities.map(e=>(0,Q.jsx)(`span`,{className:`rounded-md bg-blue-50 px-2 py-0.5 text-xs text-blue-700 dark:bg-blue-950/30 dark:text-blue-300`,children:i(`settings.plugins.capability.${e.toLowerCase()}`,{defaultValue:e})},e))})})]},e.id))})]})})]})}function rr({plugin:e,hasApiKey:t,apiKey:n,showApiKey:r,savingApiKey:i,onApiKeyChange:a,onShowApiKeyChange:o,onSaveApiKey:c,onDeleteApiKey:l}){let{t:u}=s(),d=(0,Z.useId)();return(0,Q.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-50 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,Q.jsx)(te,{className:`h-4 w-4 text-gray-500`}),(0,Q.jsx)(`h6`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:u(`settings.plugins.apiKeyConfiguration`)})]}),(0,Q.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:[u(`settings.plugins.apiKeyDescription`,{name:e.name,defaultValue:`Store a personal API key for {{name}}.`}),e.auth?.key_env&&(0,Q.jsxs)(`span`,{className:`block mt-1`,children:[u(`settings.plugins.apiKeyEnvAlternative`),` `,(0,Q.jsx)(`code`,{className:`bg-gray-200 dark:bg-dark-200 px-1 rounded`,children:e.auth.key_env}),` `,u(`settings.plugins.environmentVariable`),`.`]})]}),t?(0,Q.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Ee,{className:`h-4 w-4 text-green-600`}),(0,Q.jsx)(`span`,{className:`text-sm text-green-700 dark:text-green-300`,children:u(`settings.plugins.apiKeyConfigured`)})]}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:l,disabled:i,className:`text-red-600 border-red-300 hover:bg-red-50`,children:i?(0,Q.jsx)(L,{className:`h-4 w-4 animate-spin`}):u(`common.remove`)})]}):(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`label`,{htmlFor:d,className:`sr-only`,children:u(`settings.plugins.apiKey.title`)}),(0,Q.jsx)(`input`,{id:d,type:r?`text`:`password`,value:n,onChange:e=>a(e.target.value),placeholder:u(`settings.plugins.apiKeyPlaceholder`),disabled:i,className:`w-full p-2 pe-10 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 placeholder:text-gray-400 dark:placeholder:text-dark-500`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(!r),"aria-controls":d,"aria-label":u(r?`settings.plugins.hideApiKey`:`settings.plugins.showApiKey`),disabled:i,className:`absolute end-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-50`,children:r?(0,Q.jsx)(O,{className:`h-4 w-4`}):(0,Q.jsx)(pe,{className:`h-4 w-4`})})]}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(q,{size:`sm`,onClick:c,disabled:i||!n.trim(),children:i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L,{className:`h-4 w-4 me-2 animate-spin`}),u(`common.saving`)]}):u(`settings.plugins.saveApiKey`)})})]})]})}var ir=()=>{let{t:e}=s(),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(`6`),[c,l]=(0,Z.useState)(!0),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{let e=!1;return bt.getConfig().then(t=>{!e&&t.success&&t.data&&(n(t.data.enabled),i(t.data.url??``),typeof t.data.maxResults==`number`&&o(String(t.data.maxResults)),typeof t.data.safeSearch==`boolean`&&l(t.data.safeSearch),d(!0))}).catch(()=>{}),()=>{e=!0}},[]);let g=async(s=t)=>{let u=Number(a);if(!Number.isInteger(u)||u<1||u>100){B.error(e(`settings.search.maxResultsInvalid`));return}p(!0);try{let t=await bt.setConfig(s,r.trim(),{maxResults:u,safeSearch:c});if(!t.success||!t.data)throw Error(t.error||e(`settings.search.saveFailed`));n(t.data.enabled),i(t.data.url??``),typeof t.data.maxResults==`number`&&o(String(t.data.maxResults)),typeof t.data.safeSearch==`boolean`&&l(t.data.safeSearch),B.success(e(`settings.search.saved`))}catch(t){B.error(t instanceof Error&&t.message?t.message:e(`settings.search.saveFailed`))}finally{p(!1)}},_=async()=>{h(!0);try{let t=await bt.test();if(!t.success||!t.data?.ok)throw Error(t.error||e(`settings.search.testFailed`));B.success(e(`settings.search.testOk`,{results:t.data.results}))}catch(t){B.error(t instanceof Error&&t.message?t.message:e(`settings.search.testFailed`))}finally{h(!1)}};return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(Fe,{className:`h-5 w-5 text-primary-500`}),e(`settings.search.title`)]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.search.description`)})]}),(0,Q.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.search.enableLabel`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`settings.search.enableDescription`)})]}),(0,Q.jsx)(sn,{checked:t,onChange:e=>{n(e),g(e)},disabled:f||!u||!t&&!r.trim()})]})}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-3`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.search.urlLabel`)}),(0,Q.jsx)(`span`,{className:`mb-2 block text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.search.urlDescription`)}),(0,Q.jsx)(Gt,{value:r,onChange:e=>i(e.target.value),placeholder:`http://searxng:8080`,spellCheck:!1,dir:`ltr`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.search.maxResultsLabel`)}),(0,Q.jsx)(`span`,{className:`mb-2 block text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.search.maxResultsDescription`)}),(0,Q.jsx)(Gt,{type:`number`,min:1,max:100,value:a,onChange:e=>o(e.target.value),dir:`ltr`})]}),(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-4 sm:pt-1`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.search.safeSearchLabel`)}),(0,Q.jsx)(`span`,{className:`block text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.search.safeSearchDescription`)})]}),(0,Q.jsx)(sn,{checked:c,onChange:l,disabled:f||!u})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void _(),disabled:m||f||!t,children:e(m?`settings.search.testing`:`settings.search.test`)}),(0,Q.jsx)(q,{size:`sm`,onClick:()=>void g(),disabled:f||!u,children:e(`settings.search.save`)})]})]})]})},ar=e=>e.response?.data?.message,or=e=>e?new Date(e).toLocaleString():`—`,sr=()=>{let{t:e}=s(),[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(!0),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),g=(0,Z.useCallback)(async()=>{i(!0);try{let e=await ht.getMfaStatus();e.success&&e.data&&n(e.data)}catch{}finally{i(!1)}},[]);(0,Z.useEffect)(()=>{let e=setTimeout(()=>void g(),0);return()=>clearTimeout(e)},[g]);let _=async()=>{o(!0);try{let t=await ht.mfaEnroll();t.success&&t.data?(l(t.data),d(``)):B.error(t.message||e(`auth.mfa.enrollFailed`))}catch(t){B.error(ar(t)||e(`auth.mfa.enrollFailed`))}finally{o(!1)}},v=async t=>{if(t.preventDefault(),u.trim()){o(!0);try{let t=await ht.mfaActivate({code:u.trim()});t.success&&t.data?(l(null),p(t.data.recoveryCodes),B.success(e(`auth.mfa.enabled`)),await g()):B.error(t.message||e(`auth.mfa.invalidCode`))}catch(t){B.error(ar(t)||e(`auth.mfa.invalidCode`))}finally{d(``),o(!1)}}},y=async t=>{if(t.preventDefault(),u.trim()&&m){o(!0);try{if(m===`disable`){let t=await ht.mfaDisable({code:u.trim()});t.success?(B.success(e(`auth.mfa.disabled`)),p(null)):B.error(t.message||e(`auth.mfa.invalidCode`))}else{let t=await ht.mfaRegenerateRecoveryCodes({code:u.trim()});t.success&&t.data?(p(t.data.recoveryCodes),B.success(e(`auth.mfa.recoveryCodesRegenerated`))):B.error(t.message||e(`auth.mfa.invalidCode`))}h(null),await g()}catch(t){B.error(ar(t)||e(`auth.mfa.invalidCode`))}finally{d(``),o(!1)}}},b=async()=>{o(!0);try{let t=await ht.passkeyRegisterOptions();if(!t.success||!t.data){B.error(t.message||e(`auth.passkeys.registerFailed`));return}let n=await X(t.data.publicKey),r=await ht.passkeyRegister({challengeToken:t.data.challengeToken,credential:n});r.success?(B.success(e(`auth.passkeys.registered`)),await g()):B.error(r.message||e(`auth.passkeys.registerFailed`))}catch(t){let n=t;if(n.name===`NotAllowedError`||n.name===`AbortError`)return;B.error(ar(t)||e(`auth.passkeys.registerFailed`))}finally{o(!1)}},x=async t=>{o(!0);try{let n=await ht.deletePasskey(t);n.success?(B.success(e(`auth.passkeys.removed`)),await g()):B.error(n.message||e(`auth.passkeys.removeFailed`))}catch(t){B.error(ar(t)||e(`auth.passkeys.removeFailed`))}finally{o(!1)}};if(r||!t)return null;let S=`h-9 w-40 rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 px-3 text-sm text-gray-900 dark:text-gray-100 outline-none focus:ring-2 focus:ring-primary-500/35`;return(0,Q.jsxs)(`div`,{className:`space-y-6`,"data-testid":`settings-mfa-section`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(ut,{className:`h-5 w-5 text-primary-500`}),e(`auth.mfa.sectionTitle`)]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:e(`auth.mfa.sectionDescription`)})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`auth.mfa.totpTitle`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:t.totpEnabled?e(`auth.mfa.totpEnabledHint`,{count:t.recoveryCodesRemaining}):e(`auth.mfa.totpDisabledHint`)})]}),t.totpEnabled?(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(q,{size:`sm`,variant:`outline`,disabled:a,onClick:()=>{h(`regenerate`),d(``)},children:e(`auth.mfa.regenerateCodes`)}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,disabled:a,onClick:()=>{h(`disable`),d(``)},children:e(`auth.mfa.disableButton`)})]}):!c&&(0,Q.jsx)(q,{size:`sm`,disabled:a,onClick:_,children:e(`auth.mfa.enableButton`)})]}),c&&(0,Q.jsxs)(`form`,{onSubmit:v,className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`auth.mfa.secretHint`)}),(0,Q.jsx)(`code`,{dir:`ltr`,className:`block break-all rounded-lg bg-gray-50 dark:bg-dark-200 p-3 font-mono text-sm text-gray-900 dark:text-gray-100`,children:c.secret}),(0,Q.jsx)(`a`,{href:c.otpauthUrl,dir:`ltr`,className:`inline-block text-xs font-medium text-primary-600 hover:text-primary-700 dark:text-primary-400`,children:e(`auth.mfa.openAuthenticator`)}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,dir:`ltr`,value:u,onChange:e=>d(e.target.value),placeholder:e(`auth.mfa.codePlaceholder`),className:S}),(0,Q.jsx)(q,{size:`sm`,type:`submit`,disabled:a||!u.trim(),children:e(`auth.mfa.activateButton`)}),(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>l(null),children:e(`common.cancel`)})]})]}),m&&(0,Q.jsxs)(`form`,{onSubmit:y,className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`label`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`auth.mfa.confirmWithCode`)}),(0,Q.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,dir:`ltr`,value:u,onChange:e=>d(e.target.value),placeholder:e(`auth.mfa.codePlaceholder`),className:S}),(0,Q.jsx)(q,{size:`sm`,type:`submit`,disabled:a||!u.trim(),children:e(m===`disable`?`auth.mfa.disableButton`:`auth.mfa.regenerateCodes`)}),(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>h(null),children:e(`common.cancel`)})]}),f&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-gray-900 dark:text-gray-100`,children:e(`auth.mfa.recoveryCodesTitle`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`auth.mfa.recoveryCodesHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-2 rounded-lg bg-gray-50 dark:bg-dark-200 p-3 font-mono text-sm text-gray-900 dark:text-gray-100`,children:f.map(e=>(0,Q.jsx)(`span`,{dir:`ltr`,children:e},e))}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>p(null),children:e(`auth.mfa.recoveryCodesSaved`)})]})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(_e,{className:`h-4 w-4 text-primary-500`}),e(`auth.passkeys.sectionTitle`)]}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:e(`auth.passkeys.sectionDescription`)})]}),tn()&&(0,Q.jsx)(q,{size:`sm`,disabled:a,onClick:b,children:e(`auth.passkeys.addButton`)})]}),t.passkeys.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`auth.passkeys.empty`)}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:t.passkeys.map(t=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-gray-50 dark:bg-dark-200 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm text-gray-900 dark:text-gray-100`,children:t.name||e(`auth.passkeys.unnamed`)}),(0,Q.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[e(`auth.passkeys.createdAt`),`:`,` `,or(t.createdAt),` · `,e(`auth.passkeys.lastUsedAt`),`:`,` `,or(t.lastUsedAt)]})]}),(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,disabled:a,onClick:()=>void x(t.id),"aria-label":e(`auth.passkeys.removeButton`),children:(0,Q.jsx)(V,{className:`h-4 w-4`})})]},t.id))})]})]})},cr=e=>e?new Date(e).toLocaleString():`—`,lr=()=>{let{t:e}=s(),[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!0),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),f=(0,Z.useCallback)(async()=>{i(!0),o(!1);try{let e=await ht.getSessions();if(!e.success||!e.data)throw Error(e.error||`Failed to load sessions.`);n(e.data)}catch{o(!0)}finally{i(!1)}},[]);(0,Z.useEffect)(()=>{let e=setTimeout(()=>void f(),0);return()=>clearTimeout(e)},[f]);let p=async t=>{l(t.id);try{let n=await ht.revokeSession(t.id);if(!n.success)throw Error(n.error||e(`settings.sessions.revokeFailed`));B.success(e(`settings.sessions.revoked`,`Session signed out.`)),await f()}catch(t){B.error(t instanceof Error&&t.message?t.message:e(`settings.sessions.revokeFailed`,`The session could not be signed out.`))}finally{l(null)}},m=async()=>{d(!0);try{let t=await ht.revokeOtherSessions();if(!t.success||!t.data)throw Error(t.error||e(`settings.sessions.revokeFailed`));B.success(e(`settings.sessions.othersRevoked`,{count:t.data.revokedCount,defaultValue:`Other sessions signed out: {{count}}`})),await f()}catch(t){B.error(t instanceof Error&&t.message?t.message:e(`settings.sessions.revokeFailed`,`The session could not be signed out.`))}finally{d(!1)}},h=t.filter(e=>!e.current&&!e.revokedAt);return(0,Q.jsxs)(`div`,{className:`space-y-8`,children:[(0,Q.jsx)(sr,{}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(Me,{className:`h-5 w-5 text-primary-500`}),e(`settings.sessions.title`,`Sessions`)]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.sessions.description`,`Everywhere this account is signed in. Signing a session out takes effect immediately; signing in again restores access.`)})]}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void m(),disabled:u||r||h.length===0,children:u?e(`settings.sessions.signingOutOthers`,`Signing out…`):e(`settings.sessions.signOutOthers`,`Sign out other sessions`)})}),r?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):a?(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 flex items-center justify-between gap-4`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.sessions.loadFailed`,`The sessions could not be loaded.`)}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void f(),children:e(`common.retry`)})]}):t.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.sessions.empty`,`No sessions found.`)}):(0,Q.jsx)(`div`,{className:`space-y-3`,children:t.map(t=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.kind}),t.current&&(0,Q.jsx)(`span`,{className:`rounded-full bg-primary-100 dark:bg-primary-900/30 px-2 py-0.5 text-xs font-medium text-primary-700 dark:text-primary-300`,children:e(`settings.sessions.current`,`This session`)}),t.revokedAt&&(0,Q.jsx)(`span`,{className:`rounded-full bg-gray-100 dark:bg-dark-200 px-2 py-0.5 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`settings.sessions.revokedBadge`,`Signed out`)})]}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs text-gray-500 dark:text-gray-400`,children:t.userAgent||e(`settings.sessions.unknownDevice`,`Unknown device`)}),(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:[e(`settings.sessions.createdAt`,`Signed in`),`:`,` `,cr(t.createdAt),` · `,e(`settings.sessions.lastSeenAt`,`Last active`),`:`,` `,cr(t.lastSeenAt),t.expiresAt&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,e(`settings.sessions.expiresAt`,`Expires`),`:`,` `,cr(t.expiresAt)]})]})]}),!t.current&&!t.revokedAt&&(0,Q.jsx)(`div`,{className:`shrink-0`,children:(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void p(t),disabled:c===t.id||u,children:c===t.id?e(`settings.sessions.signingOut`,`Signing out…`):e(`settings.sessions.signOut`,`Sign out`)})})]},t.id))})]})},ur={getPublicKey:()=>ft.get(`/push/public-key`).then(e=>e.data),listSubscriptions:()=>ft.get(`/push/subscriptions`).then(e=>e.data),subscribe:e=>ft.post(`/push/subscriptions`,e).then(e=>e.data),unsubscribe:e=>ft.delete(`/push/subscriptions`,{data:{endpoint:e}}).then(e=>e.data)},dr=o(`components:settings-notifications`),fr=()=>typeof window<`u`&&`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window,pr=e=>{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t+`=`.repeat((4-t.length%4)%4),r=atob(n),i=new Uint8Array(new ArrayBuffer(r.length));for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i},mr=()=>{let{t:e}=s(),[t]=(0,Z.useState)(fr),[n,r]=(0,Z.useState)(typeof Notification<`u`?Notification.permission:`denied`),[i,a]=(0,Z.useState)(!1),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=Vt(e=>e.preferences.emailNotifications),f=Vt(e=>e.setPreferences),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{let e=!1;return G.getSettings().then(t=>{e||(t.success&&t.data?m(t.data):g(!0))}).catch(()=>{e||g(!0)}),()=>{e=!0}},[]);let y=async(t,n)=>{let r={channelMentions:d?.channelMentions===!0,automationRuns:d?.automationRuns===!0},i={...r,[t]:n};v(t),f({emailNotifications:i});try{let e=await W.updatePreferences({emailNotifications:i});if(!e.success)throw Error(e.error||`update failed`)}catch(t){f({emailNotifications:r}),B.error(e(`settings.preferences.updateFailed`,{error:t instanceof Error?t.message:String(t)}))}finally{v(null)}},b=(0,Z.useCallback)(async()=>{if(t)try{let e=await navigator.serviceWorker.getRegistration();if(!e){u(!1),a(!1);return}u(!0);let t=await e.pushManager.getSubscription();a(!!t)}catch(e){dr.debug(`Push state read failed`,e)}},[t]);(0,Z.useEffect)(()=>{let e=setTimeout(()=>void b(),0);return()=>clearTimeout(e)},[b]);let x=async()=>{let t=await navigator.serviceWorker.getRegistration();if(!t){B.error(e(`settings.notifications.workerMissing`));return}let n=await Notification.requestPermission();if(r(n),n!==`granted`){B.error(e(`settings.notifications.permissionDenied`));return}let i=await ur.getPublicKey();if(!i.success||!i.data){B.error(i.message||e(`settings.notifications.enableFailed`));return}let o=await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:pr(i.data.publicKey)}),s=await ur.subscribe(o.toJSON());if(!s.success){await o.unsubscribe().catch(()=>void 0),B.error(s.message||e(`settings.notifications.enableFailed`));return}a(!0),B.success(e(`settings.notifications.enabled`))},S=async()=>{let t=await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription();t&&(await ur.unsubscribe(t.endpoint).catch(()=>void 0),await t.unsubscribe().catch(()=>void 0)),a(!1),B.success(e(`settings.notifications.disabled`))},C=async t=>{c(!0);try{t?await x():await S()}catch(t){dr.error(`Push toggle failed`,t),B.error(e(`settings.notifications.enableFailed`))}finally{c(!1)}},w=h?e(`settings.notifications.emailLoadFailed`):p===null?null:p.available?p.recipient?null:e(`settings.notifications.emailNoAddress`):e(`settings.notifications.emailUnavailable`),T=p?.recipient?e(`settings.notifications.emailHint`,{address:p.recipient}):e(`settings.notifications.emailLoading`),E=t?l?n===`denied`?e(`settings.notifications.permissionDenied`):null:e(`settings.notifications.workerMissing`):e(`settings.notifications.unsupported`);return(0,Q.jsxs)(`div`,{className:`space-y-6`,"data-testid":`settings-notifications-tab`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(Le,{className:`h-5 w-5 text-primary-500`}),e(`settings.notifications.title`)]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.notifications.description`)})]}),(0,Q.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.notifications.pushTitle`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:E??e(`settings.notifications.pushHint`)})]}),(0,Q.jsx)(sn,{checked:i,disabled:o||!(!E||i),onChange:C})]})}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.notifications.deviceNote`)}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-4`,"data-testid":`settings-email-notifications`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(He,{className:`h-4 w-4 text-primary-500`}),e(`settings.notifications.emailTitle`)]}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:w??T})]}),[[`channelMentions`,`emailMentions`,`emailMentionsHint`],[`automationRuns`,`emailAutomations`,`emailAutomationsHint`]].map(([t,n,r])=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,"data-testid":`settings-email-${t}`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm text-gray-900 dark:text-gray-100`,children:e(`settings.notifications.${n}`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.notifications.${r}`)})]}),(0,Q.jsx)(sn,{checked:d?.[t]===!0,disabled:_!==null||!!w&&d?.[t]!==!0,onChange:e=>void y(t,e)})]},t))]})]})},hr=e=>e?new Date(e).toLocaleString():`—`,gr=()=>{let{t:e}=s(),t=Nt(e=>e.isAdmin)(),[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!0),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)([]),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),x=mt.filter(e=>e!==`admin`||t),S=(0,Z.useCallback)(async()=>{a(!0),c(!1);try{let e=await ht.listApiTokens();if(!e.success||!e.data)throw Error(e.error||`Failed to load API keys.`);r(e.data)}catch{c(!0)}finally{a(!1)}},[]);(0,Z.useEffect)(()=>{let e=setTimeout(()=>void S(),0);return()=>clearTimeout(e)},[S]);let C=e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},w=async t=>{if(t.preventDefault(),!d.trim()){B.error(e(`settings.apiKeys.nameRequired`,`Give the key a name.`));return}if(p.length===0){B.error(e(`settings.apiKeys.scopesRequired`,`Select at least one scope.`));return}let n;if(h.trim()){let t=Number(h);if(!Number.isInteger(t)||t<1){B.error(e(`settings.apiKeys.expiryInvalid`,`Expiry must be a whole number of days.`));return}n=t}v(!0);try{let t=await ht.createApiToken({name:d.trim(),scopes:p,expiresInDays:n});if(!t.success||!t.data)throw Error(t.error||e(`settings.apiKeys.createFailed`));b(t.data.token),f(``),m([]),g(``),B.success(e(`settings.apiKeys.created`,`API key created.`)),await S()}catch(t){B.error(t instanceof Error&&t.message?t.message:e(`settings.apiKeys.createFailed`,`The API key could not be created.`))}finally{v(!1)}},E=async()=>{if(y)try{await navigator.clipboard.writeText(y),B.success(e(`settings.apiKeys.copied`,`Copied to clipboard.`))}catch{B.error(e(`settings.apiKeys.copyFailed`,`Copy failed.`))}},D=async t=>{u(t.id);try{let n=await ht.revokeApiToken(t.id);if(!n.success)throw Error(n.error||e(`settings.apiKeys.revokeFailed`));B.success(e(`settings.apiKeys.revoked`,`API key revoked.`)),await S()}catch(t){B.error(t instanceof Error&&t.message?t.message:e(`settings.apiKeys.revokeFailed`,`The API key could not be revoked.`))}finally{u(null)}};return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(_e,{className:`h-5 w-5 text-primary-500`}),e(`settings.apiKeys.title`,`API keys`)]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.apiKeys.description`,`Scoped tokens for scripts and integrations. Each key only has access to the scopes you pick.`)})]}),y&&(0,Q.jsxs)(`div`,{className:`rounded-lg border border-primary-500/40 bg-primary-50 dark:bg-primary-900/20 p-4 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.apiKeys.newKeyTitle`,`Your new API key`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`code`,{dir:`ltr`,className:`min-w-0 flex-1 overflow-x-auto rounded-md bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300 px-3 py-2 text-xs text-gray-900 dark:text-gray-100`,"data-testid":`new-api-key`,children:y}),(0,Q.jsxs)(q,{size:`sm`,variant:`outline`,onClick:()=>void E(),className:`shrink-0 gap-1.5`,children:[(0,Q.jsx)(T,{size:14}),e(`settings.apiKeys.copy`,`Copy`)]})]}),(0,Q.jsx)(`p`,{className:`text-xs text-warning-700 dark:text-warning-400`,children:e(`settings.apiKeys.showOnceWarning`,`Copy it now — it will not be shown again.`)}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>b(null),children:e(`settings.apiKeys.dismiss`,`Done`)})})]}),(0,Q.jsxs)(`form`,{onSubmit:w,className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-3`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.apiKeys.createTitle`,`Create a key`)}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.apiKeys.nameLabel`,`Name`)}),(0,Q.jsx)(Gt,{value:d,onChange:e=>f(e.target.value),placeholder:e(`settings.apiKeys.namePlaceholder`,`e.g. CI pipeline`)})]}),(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.apiKeys.expiryLabel`,`Expires in days (optional)`)}),(0,Q.jsx)(Gt,{type:`number`,min:1,value:h,onChange:e=>g(e.target.value),placeholder:e(`settings.apiKeys.expiryPlaceholder`,`Never`),dir:`ltr`})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`mb-2 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.apiKeys.scopesLabel`,`Scopes`)}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-2`,children:x.map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:p.includes(e),onChange:()=>C(e),className:`h-4 w-4 rounded border-gray-300 dark:border-dark-300 text-primary-600 focus:ring-primary-500`}),e]},e))})]}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(q,{size:`sm`,type:`submit`,disabled:_,children:_?e(`settings.apiKeys.creating`,`Creating…`):e(`settings.apiKeys.create`,`Create key`)})})]}),i?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):o?(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 flex items-center justify-between gap-4`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.apiKeys.loadFailed`,`The API keys could not be loaded.`)}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void S(),children:e(`common.retry`)})]}):n.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.apiKeys.empty`,`No API keys yet.`)}):(0,Q.jsx)(`div`,{className:`space-y-3`,children:n.map(t=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.name}),(0,Q.jsxs)(`code`,{dir:`ltr`,className:`rounded bg-gray-100 dark:bg-dark-200 px-1.5 py-0.5 text-xs text-gray-600 dark:text-gray-300`,children:[t.tokenPrefix,`…`]}),t.revokedAt&&(0,Q.jsx)(`span`,{className:`rounded-full bg-gray-100 dark:bg-dark-200 px-2 py-0.5 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`settings.apiKeys.revokedBadge`,`Revoked`)})]}),(0,Q.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:t.scopes.map(e=>(0,Q.jsx)(`span`,{className:`rounded-full bg-primary-100 dark:bg-primary-900/30 px-2 py-0.5 text-xs text-primary-700 dark:text-primary-300`,children:e},e))}),(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:[e(`settings.apiKeys.createdAt`,`Created`),`:`,` `,hr(t.createdAt),` · `,e(`settings.apiKeys.lastUsedAt`,`Last used`),`:`,` `,hr(t.lastUsedAt),` · `,e(`settings.apiKeys.expiresAt`,`Expires`),`:`,` `,t.expiresAt?hr(t.expiresAt):e(`settings.apiKeys.neverExpires`,`Never`)]})]}),!t.revokedAt&&(0,Q.jsx)(`div`,{className:`shrink-0`,children:(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void D(t),disabled:l===t.id,children:l===t.id?e(`settings.apiKeys.revoking`,`Revoking…`):e(`settings.apiKeys.revoke`,`Revoke`)})})]},t.id))})]})};function _r({loading:e,settings:t,effectiveSettings:n,models:r,plugins:i,voices:a,voiceProfiles:o,selectableVoiceProfiles:c,loadingVoiceProfiles:l,testing:u,onSettingChange:d,onModelChange:f,onVoiceChange:p,onDeleteVoiceProfile:m,onRevokeVoiceProfile:h,onReset:g,onTest:_,onSave:v}){let{t:y}=s(),b=r.find(e=>e.model===n.model&&(!n.pluginId||e.plugin===n.pluginId));return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:y(`settings.tts.title`)}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:y(`settings.tts.description`)}),e?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Q.jsx)(L,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,Q.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:y(`settings.tts.loadingProviders`)})]}):r.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-yellow-200 bg-yellow-500/10 p-4 dark:border-yellow-800 dark:bg-yellow-900/20`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(qe,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:y(`settings.tts.noProviders`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-ink-muted`,children:y(`settings.tts.noProvidersDescription`)})]})]})}):(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:y(`settings.tts.enable`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:y(`settings.tts.enableDescription`)})]}),(0,Q.jsx)(sn,{checked:t.enabled,onChange:e=>d(`enabled`,e)})]})}),(0,Q.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:y(`settings.tts.autoPlay`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:y(`settings.tts.autoPlayDescription`)})]}),(0,Q.jsx)(sn,{checked:t.autoPlay,disabled:!t.enabled,onChange:e=>{e&&an(),d(`autoPlay`,e)}})]})}),(0,Q.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:y(`settings.tts.streamSentences`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:y(`settings.tts.streamSentencesDescription`)})]}),(0,Q.jsx)(sn,{checked:t.streamSentences!==!1,disabled:!t.enabled,onChange:e=>d(`streamSentences`,e)})]})}),(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:y(`settings.tts.voiceConfiguration`)}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:y(`settings.tts.model`)}),(0,Q.jsx)(Wt,{"aria-label":y(`settings.tts.model`),value:b?Dt(b):``,onChange:e=>{let t=r.find(t=>Dt(t)===e.target.value);t&&f(t.model,t.plugin)},disabled:!t.enabled,options:[{value:``,label:y(`settings.model.selectModel`)},...r.map(e=>({value:Dt(e),label:`${e.model} (${e.plugin})`,key:`${e.plugin}:${e.model}`}))]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:y(`settings.tts.modelDescription`)})]}),a.length>0||c.length>0?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:y(`settings.tts.voice`)}),(0,Q.jsx)(Wt,{"aria-label":y(`settings.tts.voice`),value:n.voiceProfileId?yr(n.voiceProfileId):n.voice,onChange:e=>{let t=br(e.target.value);p(t?``:e.target.value,t||``)},disabled:!t.enabled,options:[{value:``,label:y(`settings.tts.selectVoice`)},...a.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),...c.map(e=>({value:yr(e.id),label:y(`settings.tts.savedVoiceOption`,{name:e.name,defaultValue:`{{name}} (saved voice)`}),key:`saved-voice-${e.id}`}))]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:y(`settings.tts.voiceDescription`)})]}):l?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-gray-50 p-3 text-xs text-gray-600 dark:bg-dark-50 dark:text-gray-400`,children:[(0,Q.jsx)(L,{className:`h-3.5 w-3.5 animate-spin`}),y(`settings.tts.loadingSavedVoices`,{defaultValue:`Loading saved voices…`})]}):(0,Q.jsx)(`p`,{className:`rounded-lg bg-gray-50 p-3 text-xs text-gray-600 dark:bg-dark-50 dark:text-gray-400`,children:y(`settings.tts.providerDefaultVoice`)})]})]}),b?.config?.supports_voice_cloning&&(0,Q.jsxs)(`div`,{className:`rounded-lg border border-primary-500/20 bg-primary-500/[0.06] p-4`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:y(`settings.tts.voiceCloningAvailable`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-gray-600 dark:text-gray-400`,children:y(`settings.tts.voiceCloningAvailableDescription`)})]}),i.length>0&&(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:y(`settings.tts.availableProviders`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:i.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-white dark:bg-dark-100 rounded border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,Q.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,y(`settings.tts.models`),`)`]})]},e.id))})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(q,{onClick:g,variant:`outline`,className:`flex items-center gap-2`,children:[(0,Q.jsx)(re,{size:16}),y(`common.reset`)]}),(0,Q.jsx)(q,{onClick:_,variant:`outline`,disabled:!t.enabled||!n.model,className:`flex items-center gap-2`,children:u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ce,{size:16}),y(`settings.tts.stop`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($e,{size:16}),y(`settings.tts.test`)]})})]}),(0,Q.jsxs)(q,{onClick:v,className:`flex items-center gap-2`,children:[(0,Q.jsx)(Ee,{size:16}),y(`settings.saveSettings`)]})]})]})]}),(l||o.length>0)&&(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white p-4 dark:border-dark-300 dark:bg-dark-100`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:y(`settings.tts.savedVoices`,{defaultValue:`Saved voices`})}),l?(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400`,children:[(0,Q.jsx)(L,{className:`h-3.5 w-3.5 animate-spin`}),y(`settings.tts.loadingSavedVoices`,{defaultValue:`Loading saved voices…`})]}):(0,Q.jsx)(`div`,{className:`mt-3 space-y-2`,children:o.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 dark:border-dark-300 dark:bg-dark-50`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`p`,{className:`truncate text-sm text-gray-800 dark:text-gray-200`,children:[e.name,e.consentStatus===`revoked`&&(0,Q.jsx)(`span`,{className:`ml-2 rounded bg-red-100 px-1.5 py-0.5 text-[10px] font-medium text-red-700 dark:bg-red-950/40 dark:text-red-400`,children:y(`settings.tts.consentRevoked`,{defaultValue:`Consent withdrawn`})}),e.consentStatus===`expired`&&(0,Q.jsx)(`span`,{className:`ml-2 rounded bg-amber-100 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:bg-amber-950/40 dark:text-amber-400`,children:y(`settings.tts.consentExpired`,{defaultValue:`Consent expired`})})]}),(0,Q.jsxs)(`p`,{className:`truncate text-xs text-gray-500 dark:text-gray-400`,children:[e.pluginId,` · `,e.model,` · `,y(`settings.tts.transferCount`,{total:e.transferCount??0,defaultValue:`sent to provider {{total}}×`}),e.consentExpiresAt&&e.consentStatus===`active`&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,y(`settings.tts.consentExpires`,{date:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}).format(e.consentExpiresAt),defaultValue:`consent until {{date}}`})]})]})]}),(e.consentStatus??`active`)===`active`&&(0,Q.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>h(e),"aria-label":y(`settings.tts.revokeSavedVoice`,{name:e.name,defaultValue:`Withdraw consent for {{name}}`}),className:`shrink-0 px-2 text-amber-600 hover:bg-amber-50 hover:text-amber-700 dark:hover:bg-amber-950/30`,children:(0,Q.jsx)(de,{className:`h-4 w-4`})}),(0,Q.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>m(e),"aria-label":y(`settings.tts.deleteSavedVoice`,{name:e.name,defaultValue:`Delete saved voice {{name}}`}),className:`shrink-0 px-2 text-red-600 hover:bg-red-50 hover:text-red-700 dark:hover:bg-red-950/30`,children:(0,Q.jsx)(V,{className:`h-4 w-4`})})]},e.id))})]})]})}var vr=`__saved_voice__:`;function yr(e){return`${vr}${e}`}function br(e){return e.startsWith(vr)?e.slice(16):void 0}var xr=({title:e,description:t,actions:n,className:r})=>(0,Q.jsxs)(`header`,{className:d(`mb-5 flex flex-wrap items-end justify-between gap-3 border-b border-gray-200/70 pb-4 dark:border-white/[0.08]`,r),children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-[1_1_18rem] [overflow-wrap:anywhere]`,children:[(0,Q.jsx)(`h3`,{className:`text-lg font-medium text-gray-900 dark:text-dark-800`,children:e}),t&&(0,Q.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-gray-600 dark:text-dark-600`,children:t})]}),n&&(0,Q.jsx)(`div`,{className:`flex max-w-full flex-wrap items-center gap-2 [&>button]:min-h-11 [&>button]:max-w-full`,children:n})]}),Sr=[`text`,`number`,`select`,`boolean`],Cr=({variables:e,onChange:t})=>{let{t:n}=s(),r=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e));return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:J,children:n(`promptsPage.form.variables`)}),(0,Q.jsx)(`p`,{className:`mb-2 text-[11px] text-gray-400 dark:text-dark-500`,children:n(`promptsPage.form.variablesHint`)}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[e.map((i,a)=>(0,Q.jsxs)(`div`,{"data-testid":`prompt-variable-row`,className:`rounded-xl border border-black/[0.06] bg-black/[0.02] p-2.5 dark:border-white/[0.07] dark:bg-white/[0.03]`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`text`,value:i.name,onChange:e=>r(a,{name:e.target.value}),placeholder:n(`promptsPage.form.variableName`),"aria-label":n(`promptsPage.form.variableName`),className:Y,maxLength:64}),(0,Q.jsx)(`select`,{value:i.type,onChange:e=>r(a,{type:e.target.value,options:e.target.value===`select`?i.options??[]:void 0}),"aria-label":n(`promptsPage.form.variableType`),className:Y,children:Sr.map(e=>(0,Q.jsx)(`option`,{value:e,children:n(`promptsPage.variableTypes.${e}`)},e))}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(e.filter((e,t)=>t!==a)),"aria-label":n(`promptsPage.form.removeVariable`),"data-testid":`prompt-variable-remove`,className:`shrink-0 rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-500/10 hover:text-red-500`,children:(0,Q.jsx)(V,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`text`,value:i.label??``,onChange:e=>r(a,{label:e.target.value}),placeholder:n(`promptsPage.form.variableLabel`),"aria-label":n(`promptsPage.form.variableLabel`),className:Y,maxLength:120}),(0,Q.jsx)(`input`,{type:`text`,value:i.default??``,onChange:e=>r(a,{default:e.target.value}),placeholder:n(`promptsPage.form.variableDefault`),"aria-label":n(`promptsPage.form.variableDefault`),className:Y,maxLength:500}),(0,Q.jsxs)(`label`,{className:`flex shrink-0 items-center gap-1.5 whitespace-nowrap text-[12px] text-gray-600 dark:text-dark-600`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:i.required===!0,onChange:e=>r(a,{required:e.target.checked}),className:`h-3.5 w-3.5 rounded border-gray-300 dark:border-dark-400`}),n(`promptsPage.form.variableRequired`)]})]}),i.type===`select`&&(0,Q.jsx)(`input`,{type:`text`,value:(i.options??[]).join(`, `),onChange:e=>r(a,{options:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)}),placeholder:n(`promptsPage.form.variableOptionsPlaceholder`),"aria-label":n(`promptsPage.form.variableOptions`),className:`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900 mt-2`})]},a)),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>t([...e,{name:``,type:`text`}]),"data-testid":`prompt-add-variable`,className:`flex items-center gap-1.5 rounded-lg px-2 py-1 text-[12px] font-medium text-primary-600 transition-colors hover:bg-primary-500/10 dark:text-primary-400`,children:[(0,Q.jsx)(Ie,{className:`h-3.5 w-3.5`}),n(`promptsPage.form.addVariable`)]})]})]})},wr=/^[a-z0-9][a-z0-9-]{0,63}$/;function Tr({open:e,prompt:t,prefill:n=null,saving:r,onClose:i,onSave:a}){return e?(0,Q.jsx)(Er,{prompt:t,prefill:n,saving:r,onClose:i,onSave:a},t?.id??(n?`template-${n.slug}`:`new`)):null}function Er({prompt:e,prefill:t,saving:n,onClose:r,onSave:i}){let{t:a}=s(),o=e??t,[c,l]=(0,Z.useState)(o?.slug??``),[u,d]=(0,Z.useState)(o?.title??``),[f,p]=(0,Z.useState)(o?.description??``),[m,h]=(0,Z.useState)(o?.content??``),[g,_]=(0,Z.useState)(o?.variables??[]),[v,y]=(0,Z.useState)((o?.tags??[]).join(`, `)),b=wr.test(c.trim()),x=b&&u.trim().length>0&&m.trim().length>0;return(0,Q.jsxs)(Kt,{titleId:`prompt-modal-title`,title:a(e?`promptsPage.editPrompt`:`promptsPage.newPrompt`),onClose:r,widthClassName:`max-w-2xl`,testId:`prompt-modal`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:r,children:a(`common.cancel`)}),(0,Q.jsx)(q,{size:`sm`,onClick:()=>{x&&i({slug:c.trim(),title:u.trim(),description:f.trim()||void 0,content:m,variables:g.filter(e=>e.name.trim().length>0),tags:v.split(`,`).map(e=>e.trim()).filter(Boolean)})},disabled:n||!x,"data-testid":`prompt-save`,children:a(n?`common.saving`:`common.save`)})]}),children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`prompt-slug`,className:J,children:a(`promptsPage.form.slug`)}),(0,Q.jsx)(`input`,{id:`prompt-slug`,"data-testid":`prompt-slug`,type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:a(`promptsPage.form.slugPlaceholder`),className:Y,maxLength:64,autoFocus:!0}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-gray-400 dark:text-dark-500`,children:c.trim().length>0&&!b?a(`promptsPage.form.slugInvalid`):a(`promptsPage.form.slugHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`prompt-title`,className:J,children:a(`promptsPage.form.title`)}),(0,Q.jsx)(`input`,{id:`prompt-title`,"data-testid":`prompt-title`,type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:a(`promptsPage.form.titlePlaceholder`),className:Y,maxLength:200})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`prompt-description`,className:J,children:a(`promptsPage.form.description`)}),(0,Q.jsx)(`input`,{id:`prompt-description`,type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:a(`promptsPage.form.descriptionPlaceholder`),className:Y,maxLength:500})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`prompt-content`,className:J,children:a(`promptsPage.form.content`)}),(0,Q.jsx)(`textarea`,{id:`prompt-content`,"data-testid":`prompt-content`,value:m,onChange:e=>h(e.target.value),placeholder:a(`promptsPage.form.contentPlaceholder`),rows:8,className:Y,maxLength:5e4}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-gray-400 dark:text-dark-500`,children:a(`promptsPage.form.contentHint`)})]}),(0,Q.jsx)(Cr,{variables:g,onChange:_}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`prompt-tags`,className:J,children:a(`promptsPage.form.tags`)}),(0,Q.jsx)(`input`,{id:`prompt-tags`,type:`text`,value:v,onChange:e=>y(e.target.value),placeholder:a(`promptsPage.form.tagsPlaceholder`),className:Y})]})]})}var Dr=({title:e,cards:t,testId:n,onPick:r})=>t.length===0?null:(0,Q.jsxs)(`div`,{className:`mt-8`,children:[(0,Q.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500 rtl:tracking-normal`,children:e}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))] gap-2`,children:t.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),"data-testid":n,className:`min-w-0 rounded-2xl border border-black/[0.06] bg-white/40 px-4 py-3 text-start [overflow-wrap:anywhere] transition-colors hover:bg-white/80 dark:border-white/[0.07] dark:bg-dark-100/40 dark:hover:bg-dark-100/80`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:e.name}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-[12px] text-gray-500 dark:text-dark-500`,children:e.description}),e.meta&&(0,Q.jsx)(`p`,{className:`mt-1.5 font-mono text-[11px] text-gray-400 dark:text-dark-500`,dir:`ltr`,children:e.meta})]},e.id))})]}),Or=[{id:`reviewPr`,input:{slug:`review-pr`,title:`Pull request review`,description:`Structured code review with adjustable strictness.`,content:`Review the following {{language}} changes with {{strictness}} strictness. Point out bugs first, style second, and end with a one-line verdict.`,variables:[{name:`language`,type:`text`,label:`Language`,required:!0},{name:`strictness`,type:`select`,label:`Strictness`,default:`normal`,options:[`low`,`normal`,`pedantic`]}],tags:[`code`,`review`]}},{id:`summarize`,input:{slug:`summarize`,title:`Summarize for an audience`,description:`Bullet-point summary tuned to a reader.`,content:`Summarize the following in at most {{points}} bullet points for {{audience}}. Keep every bullet self-contained, lead with the most important point, and end with a one-sentence takeaway.`,variables:[{name:`points`,type:`number`,label:`Bullets`,default:`5`},{name:`audience`,type:`text`,label:`Audience`,default:`a technical reader`}],tags:[`writing`]}},{id:`translate`,input:{slug:`translate`,title:`Translate`,description:`Translation that preserves tone and formatting.`,content:`Translate the following into {{target_language}}. Preserve tone, formatting, and markup exactly; keep code, identifiers, and proper names untranslated. If a phrase is ambiguous, pick the most natural reading and note the alternative in brackets.`,variables:[{name:`target_language`,type:`text`,label:`Target language`,required:!0}],tags:[`writing`,`translation`]}},{id:`explainCode`,input:{slug:`explain-code`,title:`Explain code`,description:`Walkthrough plus edge cases and risks.`,content:`Explain what the following {{language}} code does, step by step but briefly. Then list edge cases it mishandles, hidden assumptions, and the one change you would make first.`,variables:[{name:`language`,type:`text`,label:`Language`,required:!0}],tags:[`code`]}}],kr=({title:e,entries:t,loading:n,currentVersion:r,rollingBackTo:i,onRollback:a,onClose:o,testId:l})=>{let{t:u,i18n:d}=s();return(0,Q.jsx)(Kt,{titleId:`version-history-title`,title:e,subtitle:u(`promptsPage.history.subtitle`),onClose:o,widthClassName:`max-w-2xl`,testId:l,footer:(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:o,children:u(`common.close`)}),children:n?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,Q.jsx)(L,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,Q.jsxs)(`div`,{className:`py-10 text-center`,children:[(0,Q.jsx)(Ce,{className:`mx-auto mb-2 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-dark-500`,children:u(`promptsPage.history.empty`)})]}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>(0,Q.jsxs)(`div`,{"data-testid":`version-history-entry`,className:`rounded-2xl border border-black/[0.06] bg-white/60 px-4 py-3 dark:border-white/[0.07] dark:bg-dark-100/60`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:[u(`promptsPage.versionLabel`,{version:e.version}),e.version===r&&(0,Q.jsx)(`span`,{className:`ms-2 rounded-full bg-primary-500/10 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary-600 dark:text-primary-400`,children:u(`promptsPage.history.current`)})]}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-[11px] text-gray-400 dark:text-dark-500`,children:c(e.createdAt,d.language)})]}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,disabled:e.version===r||i!==null,onClick:()=>a(e.version),"data-testid":`version-rollback`,children:i===e.version?u(`promptsPage.history.rollingBack`):u(`promptsPage.history.rollback`)})]}),(0,Q.jsx)(`pre`,{className:`mt-2 max-h-32 overflow-auto whitespace-pre-wrap break-words rounded-xl bg-black/[0.03] p-2.5 text-[11px] leading-5 text-gray-600 scrollbar-thin dark:bg-white/[0.04] dark:text-dark-600`,children:e.body})]},e.version))})})},Ar=(e,t)=>{let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)},jr=async e=>JSON.parse(await e.text()),Mr=(e,t)=>{let n=new Blob([t],{type:`text/markdown;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),URL.revokeObjectURL(r)},Nr=e=>new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error),r.onload=()=>t(String(r.result??``)),r.readAsText(e)}),Pr=o(`pages:prompts`),Fr=()=>{let{t:e,i18n:t}=s(),[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!0),[o,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)([]),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(null),E=(0,Z.useRef)(null),[D,O]=(0,Z.useState)(0),A=(0,Z.useCallback)(()=>O(e=>e+1),[]);(0,Z.useEffect)(()=>{let t=!1;return Et.list().then(n=>{t||(n.success&&n.data?r(n.data):k.error(n.error||e(`promptsPage.loadFailed`)))}).catch(n=>{t||(Pr.error(`Failed to load prompts:`,n),k.error(e(`promptsPage.loadFailed`)))}).finally(()=>{t||a(!1)}),()=>{t=!0}},[D,e]);let M=async t=>{h(!0);try{let n=u?await Et.update(u.id,t):await Et.create(t);n.success?(l(!1),p(null),k.success(e(`promptsPage.saved`)),A()):k.error(n.error||e(`promptsPage.saveFailed`))}catch(t){Pr.error(`Failed to save prompt:`,t),k.error(e(`promptsPage.saveFailed`))}finally{h(!1)}},N=async()=>{if(!g)return;let t=g;_(null);try{let n=await Et.remove(t.id);if(!n.success)throw Error(n.error);k.success(e(`promptsPage.deleted`)),A()}catch(t){Pr.error(`Failed to delete prompt:`,t),k.error(e(`promptsPage.deleteFailed`))}},P=async t=>{try{let e=await Et.export(t.id);if(!e.success||!e.data)throw Error(e.error);Ar(`${t.slug}.prompt.json`,e.data)}catch(t){Pr.error(`Failed to export prompt:`,t),k.error(e(`promptsPage.exportFailed`))}},F=async t=>{try{let n=await Et.import(await jr(t));if(!n.success)throw Error(n.error);k.success(e(`promptsPage.imported`)),A()}catch(t){Pr.error(`Failed to import prompt:`,t),k.error(e(`promptsPage.importFailed`))}},I=async t=>{y(t),C(!0),x([]);try{let n=await Et.versions(t.id);n.success&&n.data?x(n.data):k.error(n.error||e(`promptsPage.historyFailed`))}catch(t){Pr.error(`Failed to load prompt history:`,t),k.error(e(`promptsPage.historyFailed`))}finally{C(!1)}},ee=async t=>{if(v){T(t);try{let n=await Et.rollback(v.id,t);if(!n.success||!n.data)throw Error(n.error);k.success(e(`promptsPage.rolledBack`)),y(null),A()}catch(t){Pr.error(`Failed to roll the prompt back:`,t),k.error(e(`promptsPage.rollbackFailed`))}finally{T(null)}}};return(0,Q.jsxs)(`div`,{"data-testid":`prompts-page`,className:`pb-2`,children:[(0,Q.jsx)(xr,{title:e(`promptsPage.title`),description:e(`promptsPage.description`),actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`input`,{ref:E,type:`file`,accept:`application/json,.json`,className:`hidden`,"data-testid":`prompt-import-input`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&F(t)}}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>E.current?.click(),"data-testid":`prompt-import`,children:[(0,Q.jsx)(Ye,{className:`me-1.5 h-3.5 w-3.5`}),e(`common.import`)]}),(0,Q.jsxs)(q,{size:`sm`,onClick:()=>{d(null),p(null),l(!0)},"data-testid":`prompt-new`,children:[(0,Q.jsx)(Ie,{className:`me-1.5 h-3.5 w-3.5`}),e(`promptsPage.newPrompt`)]})]})}),i?null:n.length===0?(0,Q.jsxs)(`div`,{className:`px-3 py-16 text-center`,children:[(0,Q.jsx)(Ge,{className:`mx-auto mb-3 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-dark-500`,children:e(`promptsPage.empty`)}),(0,Q.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-[13px] leading-6 text-gray-400 dark:text-dark-500`,children:e(`promptsPage.emptyHint`)})]}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:n.map(n=>(0,Q.jsx)(`div`,{"data-testid":`prompt-row`,className:`rounded-2xl border border-black/[0.06] bg-white/60 px-4 py-3 dark:border-white/[0.07] dark:bg-dark-100/60`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-[1_1_16rem] [overflow-wrap:anywhere]`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`p`,{className:`max-w-full text-[14px] font-medium text-gray-900 dark:text-dark-900`,children:n.title}),(0,Q.jsxs)(`code`,{className:`max-w-full rounded-md bg-black/[0.04] px-1.5 py-0.5 text-[11px] text-gray-500 dark:bg-white/[0.06] dark:text-dark-500`,children:[`/`,n.slug]}),(0,Q.jsx)(`span`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:e(`promptsPage.versionLabel`,{version:n.version})})]}),n.description&&(0,Q.jsx)(`p`,{className:`mt-1 text-[12px] text-gray-500 dark:text-dark-500`,children:n.description}),(0,Q.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5`,children:[n.tags.map(e=>(0,Q.jsx)(`span`,{className:`max-w-full rounded-full bg-black/[0.04] px-2 py-0.5 text-[10px] text-gray-500 dark:bg-white/[0.06] dark:text-dark-500`,children:e},e)),(0,Q.jsx)(`span`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:e(`promptsPage.updated`,{when:c(n.updatedAt,t.language)})})]})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 max-w-full shrink-0 flex-wrap items-center gap-1 [&>button]:inline-flex [&>button]:min-h-11 [&>button]:min-w-11 [&>button]:items-center [&>button]:justify-center`,children:[(0,Q.jsx)(Yt,{icon:Ce,label:e(`promptsPage.history.open`),testId:`prompt-history`,onClick:()=>void I(n)}),(0,Q.jsx)(Yt,{icon:j,label:e(`common.export`),testId:`prompt-export`,onClick:()=>void P(n)}),(0,Q.jsx)(Yt,{icon:Je,label:e(`common.edit`),testId:`prompt-edit`,onClick:()=>{d(n),l(!0)}}),(0,Q.jsx)(Yt,{icon:V,label:e(`common.delete`),testId:`prompt-delete`,destructive:!0,onClick:()=>_(n)})]})]})},n.id))}),!i&&(0,Q.jsx)(Dr,{title:e(`promptsPage.templatesTitle`),testId:`prompt-template`,cards:Or.map(t=>({id:t.id,name:e(`promptsPage.templates.${t.id}.name`),description:e(`promptsPage.templates.${t.id}.description`),meta:`/${t.input.slug}`})),onPick:e=>{let t=Or.find(t=>t.id===e);t&&(d(null),p(t.input),l(!0))}}),(0,Q.jsx)(Tr,{open:o,prompt:u,prefill:f,saving:m,onClose:()=>{l(!1),p(null)},onSave:e=>void M(e)}),v&&(0,Q.jsx)(kr,{title:e(`promptsPage.history.title`,{title:v.title}),entries:b.map(e=>({version:e.version,body:e.content,createdAt:e.createdAt})),loading:S,currentVersion:v.version,rollingBackTo:w,onRollback:e=>void ee(e),onClose:()=>y(null),testId:`prompt-history-modal`}),g&&(0,Q.jsx)(Kt,{titleId:`prompt-delete-title`,title:e(`promptsPage.deleteTitle`),subtitle:e(`promptsPage.deleteConfirm`,{title:g.title}),onClose:()=>_(null),widthClassName:`max-w-sm`,testId:`prompt-delete-modal`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>_(null),children:e(`common.cancel`)}),(0,Q.jsx)(q,{variant:`danger`,size:`sm`,onClick:()=>void N(),"data-testid":`prompt-delete-confirm`,children:e(`common.delete`)})]})})]})},Ir=/^[a-z0-9][a-z0-9-]{0,63}$/,Lr=[`run_command`,`computer_act`,`delete_file`,`move_file`,`message_agent`,`write_file`];function Rr({open:e,skill:t,prefill:n=null,saving:r,onClose:i,onSave:a}){return e?(0,Q.jsx)(zr,{skill:t,prefill:n,saving:r,onClose:i,onSave:a},t?.id??(n?`template-${n.slug}`:`new`)):null}function zr({skill:e,prefill:t,saving:n,onClose:r,onSave:i}){let{t:a}=s(),o=e??t,[c,l]=(0,Z.useState)(o?.slug??``),[u,d]=(0,Z.useState)(o?.name??``),[f,p]=(0,Z.useState)(o?.description??``),[m,h]=(0,Z.useState)(o?.instructions??``),[g,_]=(0,Z.useState)(o?.enabled??!0),[v,y]=(0,Z.useState)(o?.approvalPolicy??`inherit`),[b,x]=(0,Z.useState)(o?.approvalTools??[]),S=(e,t)=>x(n=>t?[...n,e].filter((e,t,n)=>n.indexOf(e)===t):n.filter(t=>t!==e)),C=Ir.test(c.trim()),w=C&&u.trim().length>0&&f.trim().length>0&&m.trim().length>0;return(0,Q.jsxs)(Kt,{titleId:`skill-modal-title`,title:a(e?`skillsPage.editSkill`:`skillsPage.newSkill`),onClose:r,widthClassName:`max-w-2xl`,testId:`skill-modal`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:r,children:a(`common.cancel`)}),(0,Q.jsx)(q,{size:`sm`,onClick:()=>{w&&i({slug:c.trim(),name:u.trim(),description:f.trim(),instructions:m,enabled:g,approvalPolicy:v,approvalTools:v===`always`?b:[]})},disabled:n||!w,"data-testid":`skill-save`,children:a(n?`common.saving`:`common.save`)})]}),children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`skill-slug`,className:J,children:a(`skillsPage.form.slug`)}),(0,Q.jsx)(`input`,{id:`skill-slug`,"data-testid":`skill-slug`,type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:a(`skillsPage.form.slugPlaceholder`),className:Y,maxLength:64,autoFocus:!0}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-gray-400 dark:text-dark-500`,children:c.trim().length>0&&!C?a(`skillsPage.form.slugInvalid`):a(`skillsPage.form.slugHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`skill-name`,className:J,children:a(`skillsPage.form.name`)}),(0,Q.jsx)(`input`,{id:`skill-name`,"data-testid":`skill-name`,type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:a(`skillsPage.form.namePlaceholder`),className:Y,maxLength:200})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`skill-description`,className:J,children:a(`skillsPage.form.description`)}),(0,Q.jsx)(`textarea`,{id:`skill-description`,"data-testid":`skill-description`,value:f,onChange:e=>p(e.target.value),placeholder:a(`skillsPage.form.descriptionPlaceholder`),rows:2,className:Y,maxLength:1e3}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-gray-400 dark:text-dark-500`,children:a(`skillsPage.form.descriptionHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`skill-instructions`,className:J,children:a(`skillsPage.form.instructions`)}),(0,Q.jsx)(`textarea`,{id:`skill-instructions`,"data-testid":`skill-instructions`,value:m,onChange:e=>h(e.target.value),placeholder:a(`skillsPage.form.instructionsPlaceholder`),rows:10,className:`${Y} font-mono`,maxLength:5e4}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-gray-400 dark:text-dark-500`,children:a(`skillsPage.form.instructionsHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-xl border border-black/[0.06] px-3 py-2.5 dark:border-white/[0.07]`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:a(`skillsPage.form.enabled`)}),(0,Q.jsx)(`p`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:a(`skillsPage.form.enabledHint`)})]}),(0,Q.jsx)(Jt,{checked:g,onChange:_})]}),(0,Q.jsxs)(`div`,{className:`rounded-xl border border-black/[0.06] px-3 py-2.5 dark:border-white/[0.07]`,"data-testid":`skill-approval`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:a(`skillsPage.form.approval`)}),(0,Q.jsx)(`p`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:a(`skillsPage.form.approvalHint`)})]}),(0,Q.jsx)(`span`,{"data-testid":`skill-approval-always`,children:(0,Q.jsx)(Jt,{checked:v===`always`,onChange:e=>y(e?`always`:`inherit`)})})]}),v===`always`&&(0,Q.jsxs)(`div`,{className:`mt-2.5 border-t border-black/[0.06] pt-2.5 dark:border-white/[0.07]`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:a(`skillsPage.form.approvalTools`)}),(0,Q.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-x-4 gap-y-1.5`,children:Lr.map(e=>(0,Q.jsxs)(`label`,{dir:`ltr`,className:`flex cursor-pointer items-center gap-1.5 font-mono text-[12px] text-gray-700 dark:text-dark-800`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"data-testid":`skill-approval-tool-${e}`,checked:b.includes(e),onChange:t=>S(e,t.target.checked),className:`h-3.5 w-3.5 rounded border-line-strong accent-primary-600`}),e]},e))}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[11px] text-gray-400 dark:text-dark-500`,children:a(`skillsPage.form.approvalToolsHint`)})]})]}),e&&(0,Q.jsx)(Br,{skillId:e.id})]})}function Br({skillId:e}){let{t}=s(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null),[o,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),p=(0,Z.useCallback)(()=>{U.listFiles(e).then(e=>r(e.success&&e.data?e.data:[])).catch(()=>r([]))},[e]);(0,Z.useEffect)(()=>{p()},[p]);let m=async n=>{if(n===null){a(``),c(``),u(``);return}try{let t=await U.getFile(e,n);if(!t.success||!t.data)throw Error(t.error);a(n),c(n),u(t.data.content)}catch{k.error(t(`skillsPage.files.loadFailed`))}},h=async()=>{let n=o.trim();if(n){f(!0);try{let t=await U.putFile(e,n,l);if(!t.success)throw Error(t.error);i&&i!==n&&await U.deleteFile(e,i),a(null),p()}catch(e){k.error(e instanceof Error&&e.message?e.message:t(`skillsPage.files.saveFailed`))}finally{f(!1)}}},g=async n=>{try{let t=await U.deleteFile(e,n);if(!t.success)throw Error(t.error);i===n&&a(null),p()}catch{k.error(t(`skillsPage.files.deleteFailed`))}};return(0,Q.jsxs)(`div`,{className:`rounded-xl border border-black/[0.06] px-3 py-2.5 dark:border-white/[0.07]`,"data-testid":`skill-files`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:t(`skillsPage.files.title`)}),(0,Q.jsx)(`p`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:t(`skillsPage.files.hint`)})]}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>void m(null),"data-testid":`skill-file-add`,children:[(0,Q.jsx)(De,{className:`me-1.5 h-3.5 w-3.5`}),t(`skillsPage.files.add`)]})]}),n&&n.length>0&&(0,Q.jsx)(`ul`,{className:`mt-2 space-y-1`,children:n.map(e=>(0,Q.jsxs)(`li`,{"data-testid":`skill-file-row`,className:`flex items-center gap-2 rounded-lg bg-black/[0.03] px-2 py-1.5 dark:bg-white/[0.04]`,children:[(0,Q.jsx)(`code`,{className:`min-w-0 flex-1 truncate text-[12px] text-gray-700 dark:text-dark-800`,dir:`ltr`,children:e.path}),(0,Q.jsxs)(`span`,{className:`shrink-0 text-[11px] text-gray-400 dark:text-dark-500`,children:[e.size,` B`]}),(0,Q.jsx)(Yt,{icon:Je,label:t(`common.edit`),testId:`skill-file-edit`,onClick:()=>void m(e.path)}),(0,Q.jsx)(Yt,{icon:V,label:t(`common.delete`),testId:`skill-file-delete`,destructive:!0,onClick:()=>void g(e.path)})]},e.path))}),n&&n.length===0&&i===null&&(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] text-gray-400 dark:text-dark-500`,children:t(`skillsPage.files.empty`)}),i!==null&&(0,Q.jsxs)(`div`,{className:`mt-2 space-y-2`,"data-testid":`skill-file-editor`,children:[(0,Q.jsx)(`input`,{type:`text`,value:o,onChange:e=>c(e.target.value),placeholder:t(`skillsPage.files.pathPlaceholder`),dir:`ltr`,"data-testid":`skill-file-path`,className:`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900 font-mono`,maxLength:200}),(0,Q.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),placeholder:t(`skillsPage.files.contentPlaceholder`),rows:6,dir:`ltr`,"data-testid":`skill-file-content`,className:`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900 font-mono`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>a(null),children:t(`common.cancel`)}),(0,Q.jsx)(q,{size:`sm`,disabled:d||!o.trim(),onClick:()=>void h(),"data-testid":`skill-file-save`,children:t(d?`common.saving`:`common.save`)})]})]})]})}var Vr=[{id:`citeSources`,input:{slug:`cite-sources`,name:`Cite sources`,description:`How to cite evidence: numbered references with URLs, no unreferenced claims.`,instructions:`# Citing sources
|
|
3
|
-
|
|
4
|
-
- Every factual claim gets a numbered reference like [1].
|
|
5
|
-
- End with a References section: number, title, URL.
|
|
6
|
-
- If no source exists, say so instead of inventing one.
|
|
7
|
-
`}},{id:`releaseNotes`,input:{slug:`release-notes`,name:`Release notes style`,description:`How release notes are written: grouped, user-facing, no internal ticket ids.`,instructions:`# Release notes style
|
|
8
|
-
|
|
9
|
-
- Group entries under Added, Changed, and Fixed.
|
|
10
|
-
- Write for the user: what they can do now, not how it was built.
|
|
11
|
-
- One line per entry, plain language, no internal ticket ids.
|
|
12
|
-
- Call out breaking changes first, with the migration step.
|
|
13
|
-
`}},{id:`meetingNotes`,input:{slug:`meeting-notes`,name:`Meeting notes format`,description:`How to turn a transcript into decisions, actions, and open questions.`,instructions:`# Meeting notes format
|
|
14
|
-
|
|
15
|
-
- Start with a two-sentence summary of the meeting.
|
|
16
|
-
- Then three sections: Decisions, Action items (owner + due date if stated), Open questions.
|
|
17
|
-
- Keep attribution: who decided or committed to what.
|
|
18
|
-
- Drop small talk entirely; never invent owners or dates.
|
|
19
|
-
`}}],Hr=o(`pages:skills`),Ur=()=>{let{t:e,i18n:t}=s(),[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!0),[o,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)([]),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(null),A=(0,Z.useRef)(null),M=(0,Z.useRef)(null),[N,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(``),[ee,te]=(0,Z.useState)(!1),[ne,re]=(0,Z.useState)(!1),[ie,ae]=(0,Z.useState)(0),R=(0,Z.useCallback)(()=>ae(e=>e+1),[]);(0,Z.useEffect)(()=>{let t=!1;return U.list().then(n=>{t||(n.success&&n.data?r(n.data):k.error(n.error||e(`skillsPage.loadFailed`)))}).catch(n=>{t||(Hr.error(`Failed to load skills:`,n),k.error(e(`skillsPage.loadFailed`)))}).finally(()=>{t||a(!1)}),()=>{t=!0}},[ie,e]);let oe=async t=>{h(!0);try{let n=u?await U.update(u.id,t):await U.create(t);n.success?(l(!1),p(null),k.success(e(`skillsPage.saved`)),R()):k.error(n.error||e(`skillsPage.saveFailed`))}catch(t){Hr.error(`Failed to save skill:`,t),k.error(e(`skillsPage.saveFailed`))}finally{h(!1)}},se=async(t,n)=>{y(t.id),r(e=>e.map(e=>e.id===t.id?{...e,enabled:n}:e));try{let e=await U.update(t.id,{enabled:n});if(!e.success)throw Error(e.error)}catch(n){Hr.error(`Failed to toggle skill:`,n),k.error(e(`skillsPage.toggleFailed`)),r(e=>e.map(e=>e.id===t.id?{...e,enabled:t.enabled}:e))}finally{y(null)}},ce=async()=>{if(!g)return;let t=g;_(null);try{let n=await U.remove(t.id);if(!n.success)throw Error(n.error);k.success(e(`skillsPage.deleted`)),R()}catch(t){Hr.error(`Failed to delete skill:`,t),k.error(e(`skillsPage.deleteFailed`))}},le=async t=>{try{let e=await U.export(t.id);if(!e.success||!e.data)throw Error(e.error);e.data.markdown?Mr(`${t.slug}.skill.md`,e.data.markdown):Ar(`${t.slug}.skill.json`,e.data)}catch(t){Hr.error(`Failed to export skill:`,t),k.error(e(`skillsPage.exportFailed`))}},ue=async t=>{try{let n=t.name.endsWith(`.md`)?{markdown:await Nr(t)}:await jr(t),r=await U.import(n);if(!r.success)throw Error(r.error);k.success(e(`skillsPage.imported`)),R()}catch(t){Hr.error(`Failed to import skill:`,t),k.error(e(`skillsPage.importFailed`))}},z=/\.(md|markdown|txt|text|py|js|mjs|cjs|ts|tsx|jsx|sh|bash|zsh|rb|sql|json|yaml|yml|toml|ini|cfg|csv|tsv|xml|html|css|svg|j2|jinja|tmpl|template)$/i,de=async t=>{try{let n=[...t],r=e=>e.webkitRelativePath||e.name,i=n.filter(e=>e.name.toUpperCase()===`SKILL.MD`).sort((e,t)=>r(e).split(`/`).length-r(t).split(`/`).length)[0];if(!i){k.error(e(`skillsPage.folderImport.missingSkillMd`));return}let a=r(i).slice(0,r(i).length-i.name.length),o=await Nr(i),s=[];for(let e of n){if(e===i)continue;let t=r(e);if(t.startsWith(a)&&z.test(e.name)&&!(e.size>2e5)){if(s.length>=32)break;s.push({path:t.slice(a.length),content:await Nr(e)})}}let c=await U.import({markdown:o,files:s});if(!c.success)throw Error(c.error);k.success(e(`skillsPage.folderImport.done`,{count:s.length})),R()}catch(t){Hr.error(`Failed to import the skill folder:`,t),k.error(t instanceof Error&&t.message?t.message:e(`skillsPage.importFailed`))}},pe=async()=>{if(F.trim()){re(!0);try{let t=await U.importFromUrl(F.trim(),{overwriteSlug:ee});if(!t.success)throw Error(t.error);k.success(e(`skillsPage.imported`)),P(!1),I(``),te(!1),R()}catch(t){Hr.error(`Failed to import the skill from a URL:`,t),k.error(t instanceof Error&&t.message?t.message:e(`skillsPage.importFailed`))}finally{re(!1)}}},B=async t=>{x(t),E(!0),C([]);try{let n=await U.versions(t.id);n.success&&n.data?C(n.data):k.error(n.error||e(`skillsPage.historyFailed`))}catch(t){Hr.error(`Failed to load skill history:`,t),k.error(e(`skillsPage.historyFailed`))}finally{E(!1)}},me=async t=>{if(b){O(t);try{let n=await U.rollback(b.id,t);if(!n.success||!n.data)throw Error(n.error);k.success(e(`skillsPage.rolledBack`)),x(null),R()}catch(t){Hr.error(`Failed to roll the skill back:`,t),k.error(e(`skillsPage.rollbackFailed`))}finally{O(null)}}};return(0,Q.jsxs)(`div`,{"data-testid":`skills-page`,className:`pb-2`,children:[(0,Q.jsx)(xr,{title:e(`skillsPage.title`),description:e(`skillsPage.description`),actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`input`,{ref:A,type:`file`,accept:`application/json,.json,text/markdown,.md`,className:`hidden`,"data-testid":`skill-import-input`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&ue(t)}}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>A.current?.click(),"data-testid":`skill-import`,children:[(0,Q.jsx)(Ye,{className:`me-1.5 h-3.5 w-3.5`}),e(`common.import`)]}),(0,Q.jsx)(`input`,{ref:M,type:`file`,multiple:!0,className:`hidden`,"data-testid":`skill-import-folder-input`,webkitdirectory:``,directory:``,onChange:e=>{let t=e.target.files;t&&t.length>0&&de(t),e.target.value=``}}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>M.current?.click(),"data-testid":`skill-import-folder`,children:[(0,Q.jsx)(it,{className:`me-1.5 h-3.5 w-3.5`}),e(`skillsPage.folderImport.button`)]}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>P(!0),"data-testid":`skill-import-url`,children:[(0,Q.jsx)(fe,{className:`me-1.5 h-3.5 w-3.5`}),e(`skillsPage.importUrl.button`)]}),(0,Q.jsxs)(q,{size:`sm`,onClick:()=>{d(null),p(null),l(!0)},"data-testid":`skill-new`,children:[(0,Q.jsx)(Ie,{className:`me-1.5 h-3.5 w-3.5`}),e(`skillsPage.newSkill`)]})]})}),i?null:n.length===0?(0,Q.jsxs)(`div`,{className:`px-3 py-16 text-center`,children:[(0,Q.jsx)(w,{className:`mx-auto mb-3 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-dark-500`,children:e(`skillsPage.empty`)}),(0,Q.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-[13px] leading-6 text-gray-400 dark:text-dark-500`,children:e(`skillsPage.emptyHint`)})]}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:n.map(n=>(0,Q.jsx)(`div`,{"data-testid":`skill-row`,className:`rounded-2xl border border-black/[0.06] bg-white/60 px-4 py-3 dark:border-white/[0.07] dark:bg-dark-100/60`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-[1_1_16rem] [overflow-wrap:anywhere]`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`p`,{className:`max-w-full text-[14px] font-medium text-gray-900 dark:text-dark-900`,children:n.name}),(0,Q.jsxs)(`code`,{className:`max-w-full rounded-md bg-black/[0.04] px-1.5 py-0.5 text-[11px] text-gray-500 dark:bg-white/[0.06] dark:text-dark-500`,children:[`$`,n.slug]}),(0,Q.jsx)(`span`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:e(`skillsPage.versionLabel`,{version:n.version})})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-[12px] text-gray-500 dark:text-dark-500`,children:n.description}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[11px] text-gray-400 dark:text-dark-500`,children:e(`skillsPage.updated`,{when:c(n.updatedAt,t.language)})})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 max-w-full shrink-0 flex-wrap items-center gap-1 [&>button]:inline-flex [&>button]:min-h-11 [&>button]:min-w-11 [&>button]:items-center [&>button]:justify-center`,children:[(0,Q.jsx)(Jt,{checked:n.enabled,disabled:v===n.id,onChange:e=>void se(n,e)}),(0,Q.jsx)(Yt,{icon:Ce,label:e(`skillsPage.history.open`),testId:`skill-history`,onClick:()=>void B(n)}),(0,Q.jsx)(Yt,{icon:j,label:e(`common.export`),testId:`skill-export`,onClick:()=>void le(n)}),(0,Q.jsx)(Yt,{icon:Je,label:e(`common.edit`),testId:`skill-edit`,onClick:()=>{d(n),l(!0)}}),(0,Q.jsx)(Yt,{icon:V,label:e(`common.delete`),testId:`skill-delete`,destructive:!0,onClick:()=>_(n)})]})]})},n.id))}),!i&&(0,Q.jsx)(Dr,{title:e(`skillsPage.templatesTitle`),testId:`skill-template`,cards:Vr.map(t=>({id:t.id,name:e(`skillsPage.templates.${t.id}.name`),description:e(`skillsPage.templates.${t.id}.description`),meta:`$${t.input.slug}`})),onPick:e=>{let t=Vr.find(t=>t.id===e);t&&(d(null),p(t.input),l(!0))}}),N&&(0,Q.jsx)(Kt,{titleId:`skill-import-url-title`,title:e(`skillsPage.importUrl.title`),subtitle:e(`skillsPage.importUrl.hint`),onClose:()=>P(!1),widthClassName:`max-w-lg`,testId:`skill-import-url-modal`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>P(!1),children:e(`common.cancel`)}),(0,Q.jsxs)(q,{size:`sm`,disabled:ne||!F.trim(),onClick:()=>void pe(),"data-testid":`skill-import-url-submit`,children:[ne?(0,Q.jsx)(L,{className:`me-1.5 h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(j,{className:`me-1.5 h-3.5 w-3.5`}),e(`common.import`)]})]}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`input`,{type:`text`,value:F,onChange:e=>I(e.target.value),onKeyDown:e=>{e.key===`Enter`&&pe()},placeholder:e(`skillsPage.importUrl.placeholder`),dir:`ltr`,autoFocus:!0,"data-testid":`skill-import-url-source`,className:`w-full rounded-lg border border-gray-300 bg-white px-3 py-2 font-mono text-sm dark:border-dark-300 dark:bg-dark-100`}),(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-xs text-gray-500 dark:text-gray-400`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:ee,onChange:()=>te(e=>!e),className:`h-3.5 w-3.5 accent-primary-600`}),e(`skillsPage.importUrl.overwrite`)]})]})}),(0,Q.jsx)(Rr,{open:o,skill:u,prefill:f,saving:m,onClose:()=>{l(!1),p(null)},onSave:e=>void oe(e)}),b&&(0,Q.jsx)(kr,{title:e(`skillsPage.history.title`,{name:b.name}),entries:S.map(e=>({version:e.version,body:e.instructions,createdAt:e.createdAt})),loading:T,currentVersion:b.version,rollingBackTo:D,onRollback:e=>void me(e),onClose:()=>x(null),testId:`skill-history-modal`}),g&&(0,Q.jsx)(Kt,{titleId:`skill-delete-title`,title:e(`skillsPage.deleteTitle`),subtitle:e(`skillsPage.deleteConfirm`,{name:g.name}),onClose:()=>_(null),widthClassName:`max-w-sm`,testId:`skill-delete-modal`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>_(null),children:e(`common.cancel`)}),(0,Q.jsx)(q,{variant:`danger`,size:`sm`,onClick:()=>void ce(),"data-testid":`skill-delete-confirm`,children:e(`common.delete`)})]})})]})},Wr=({approvals:e,servers:t,revoking:n,onRevoke:r})=>{let{t:i,i18n:a}=s(),o=e=>t.find(t=>t.id===e)?.name??i(`toolsPage.builtinSource`);return(0,Q.jsxs)(`section`,{className:`mt-10`,children:[(0,Q.jsx)(`h2`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,children:i(`toolsPage.approvals.title`)}),(0,Q.jsx)(`p`,{className:`mb-3 text-[12px] text-gray-500 dark:text-dark-500`,children:i(`toolsPage.approvals.description`)}),e.length===0?(0,Q.jsx)(`p`,{className:`rounded-2xl border border-dashed border-black/[0.08] px-4 py-6 text-center text-[12px] text-gray-400 dark:border-white/[0.08] dark:text-dark-500`,children:i(`toolsPage.approvals.empty`)}):(0,Q.jsx)(`div`,{className:`space-y-1.5`,"data-testid":`tool-approvals`,children:e.map(e=>(0,Q.jsxs)(`div`,{"data-testid":`tool-approval-row`,className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-black/[0.05] bg-white/50 px-3 py-2 dark:border-white/[0.06] dark:bg-dark-100/50`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-[1_1_16rem]`,children:[(0,Q.jsxs)(`p`,{className:`break-words text-[13px] text-gray-900 [overflow-wrap:anywhere] dark:text-dark-900`,children:[(0,Q.jsx)(`code`,{children:e.toolName}),` · `,o(e.serverId)]}),(0,Q.jsxs)(`p`,{className:`truncate text-[11px] text-gray-400 dark:text-dark-500`,children:[i(`toolsPage.approvals.scope.${e.scope}`),` · `,c(e.createdAt,a.language)]})]}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,disabled:n===e.id,onClick:()=>r(e.id),"data-testid":`tool-approval-revoke`,children:i(`toolsPage.approvals.revoke`)})]},e.id))})]})},Gr=o(`components:tools`),Kr=e=>e.response?.data?.error||(e instanceof Error&&!(`response`in e)&&e.message?e.message:void 0),qr=({server:e,isAdmin:t,onEdit:n,onDelete:r,onChanged:i})=>{let{t:a}=s(),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)([]),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(!1),S=e.authMode===`oauth`,[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!S)return;let t=!1;return H.getOAuthStatus(e.id).then(e=>{!t&&e.success&&e.data&&w(e.data)}).catch(e=>{Gr.error(`Failed to read the OAuth status:`,e)}),()=>{t=!0}},[S,e.id]);let D=C?.connected??e.hasCredential,O=async()=>{E(!0);try{let t=await H.startOAuth(e.id);if(!t.success||!t.data?.authorizeUrl)throw Error(t.error);window.location.assign(t.data.authorizeUrl)}catch(e){Gr.error(`Failed to start the OAuth connection:`,e),k.error(Kr(e)||a(`toolsPage.oauth.connectFailed`)),E(!1)}},A=async()=>{E(!0);try{let t=await H.disconnectOAuth(e.id);if(!t.success)throw Error(t.error);w({connected:!1,configured:!0}),k.success(a(`toolsPage.oauth.disconnected`)),i()}catch(e){Gr.error(`Failed to disconnect the tool server:`,e),k.error(Kr(e)||a(`toolsPage.oauth.disconnectFailed`))}finally{E(!1)}},j=async()=>{p(!0);try{let t=await H.getServer(e.id);t.success&&t.data?u(t.data.tools):k.error(t.error||a(`toolsPage.toolsLoadFailed`))}catch(e){Gr.error(`Failed to load pinned tools:`,e),k.error(a(`toolsPage.toolsLoadFailed`))}finally{p(!1)}},M=()=>{let e=!o;c(e),e&&l.length===0&&j()},N=async()=>{h(!0);try{let t=await H.refreshServer(e.id);if(!t.success)throw Error(t.error);k.success(a(`toolsPage.refreshed`)),await j(),i()}catch(e){Gr.error(`Failed to refresh the tool server:`,e),k.error(Kr(e)||a(`toolsPage.refreshFailed`))}finally{h(!1)}},P=async(t,n)=>{u(e=>e.map(e=>e.name===t.name?{...e,...n}:e));try{let r=await H.overrideServerTool(e.id,t.name,n);if(!r.success)throw Error(r.error)}catch(e){Gr.error(`Failed to override the tool:`,e),k.error(a(`toolsPage.overrideFailed`)),u(e=>e.map(e=>e.name===t.name?t:e))}},F=async()=>{if(v.trim()){x(!0);try{let t=await H.setCredential(e.id,v);if(!t.success)throw Error(t.error);y(``),_(!1),k.success(a(`toolsPage.credentialSaved`)),i()}catch(e){Gr.error(`Failed to save the credential:`,e),k.error(a(`toolsPage.credentialSaveFailed`))}finally{x(!1)}}},I=async()=>{x(!0);try{let t=await H.deleteCredential(e.id);if(!t.success)throw Error(t.error);k.success(a(`toolsPage.credentialRemoved`)),i()}catch(e){Gr.error(`Failed to remove the credential:`,e),k.error(a(`toolsPage.credentialRemoveFailed`))}finally{x(!1)}};return(0,Q.jsxs)(`div`,{"data-testid":`tool-server-row`,className:`rounded-2xl border border-black/[0.06] bg-white/60 px-4 py-3 dark:border-white/[0.07] dark:bg-dark-100/60`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-[1_1_16rem]`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 max-w-full break-words text-[14px] font-medium text-gray-900 [overflow-wrap:anywhere] dark:text-dark-900`,children:e.name}),(0,Q.jsx)(`span`,{className:`rounded-full bg-black/[0.04] px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-gray-500 dark:bg-white/[0.06] dark:text-dark-500`,children:a(`toolsPage.kinds.${e.kind}`)}),(0,Q.jsx)(`span`,{className:d(`rounded-full px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide`,e.enabled?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:`bg-gray-500/10 text-gray-500 dark:text-dark-500`),children:e.enabled?a(`common.enabled`):a(`common.disabled`)}),e.authMode!==`none`&&(0,Q.jsx)(`span`,{className:d(`rounded-full px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide`,(S?D:e.hasCredential)?`bg-primary-500/10 text-primary-600 dark:text-primary-400`:`bg-amber-500/10 text-amber-600 dark:text-amber-400`),children:S?a(D?`toolsPage.oauth.connected`:`toolsPage.oauth.notConnected`):e.hasCredential?a(`toolsPage.credentialSet`):a(`toolsPage.credentialMissing`)})]}),e.description&&(0,Q.jsx)(`p`,{className:`mt-1 break-words text-[12px] text-gray-500 [overflow-wrap:anywhere] dark:text-dark-500`,children:e.description}),t&&e.baseUrl&&(0,Q.jsxs)(`p`,{className:`mt-1 truncate text-[11px] text-gray-400 dark:text-dark-500`,children:[e.baseUrl,` · `,a(`toolsPage.specRevision`,{revision:e.specRevision}),e.specDigest&&` · ${e.specDigest.slice(0,12)}`]})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 max-w-full shrink-0 flex-wrap items-center gap-1 [&>button]:inline-flex [&>button]:min-h-11 [&>button]:min-w-11 [&>button]:items-center [&>button]:justify-center`,children:[e.authMode!==`none`&&!S&&(0,Q.jsx)(Yt,{icon:_e,label:a(`toolsPage.credential`),testId:`tool-credential-toggle`,onClick:()=>_(e=>!e)}),S&&(0,Q.jsx)(Yt,{icon:dt,label:a(`toolsPage.oauth.title`),testId:`tool-oauth-toggle`,onClick:()=>_(e=>!e)}),t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Yt,{icon:Te,label:a(`toolsPage.refresh`),testId:`tool-server-refresh`,disabled:m,onClick:()=>void N()}),(0,Q.jsx)(Yt,{icon:Je,label:a(`common.edit`),testId:`tool-server-edit`,onClick:()=>n(e)}),(0,Q.jsx)(Yt,{icon:V,label:a(`common.delete`),testId:`tool-server-delete`,destructive:!0,onClick:()=>r(e)}),(0,Q.jsx)(Yt,{icon:o?xe:ie,label:a(`toolsPage.pinnedTools`),testId:`tool-server-expand`,onClick:M})]})]})]}),g&&S&&(0,Q.jsxs)(`div`,{"data-testid":`tool-oauth-panel`,className:`mt-3 rounded-xl border border-black/[0.06] bg-black/[0.02] p-3 dark:border-white/[0.07] dark:bg-white/[0.03]`,children:[(0,Q.jsx)(`p`,{className:`mb-2 text-[11px] text-gray-500 dark:text-dark-500`,children:a(`toolsPage.oauth.hint`)}),D&&C?.expiresAt&&(0,Q.jsx)(`p`,{className:`mb-2 text-[11px] text-gray-400 dark:text-dark-500`,children:a(`toolsPage.oauth.expiresAt`,{when:new Date(C.expiresAt).toLocaleString()})}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(q,{size:`sm`,disabled:T,onClick:()=>void O(),"data-testid":`tool-oauth-connect`,children:a(D?`toolsPage.oauth.reconnect`:`toolsPage.oauth.connect`)}),D&&(0,Q.jsx)(q,{size:`sm`,variant:`outline`,disabled:T,onClick:()=>void A(),"data-testid":`tool-oauth-disconnect`,children:a(`toolsPage.oauth.disconnect`)})]})]}),g&&e.authMode!==`none`&&!S&&(0,Q.jsxs)(`div`,{"data-testid":`tool-credential-panel`,className:`mt-3 rounded-xl border border-black/[0.06] bg-black/[0.02] p-3 dark:border-white/[0.07] dark:bg-white/[0.03]`,children:[(0,Q.jsx)(`p`,{className:`mb-2 text-[11px] text-gray-500 dark:text-dark-500`,children:a(`toolsPage.credentialHint`)}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`password`,value:v,onChange:e=>y(e.target.value),placeholder:a(`toolsPage.credentialPlaceholder`),"aria-label":a(`toolsPage.credential`),autoComplete:`off`,"data-testid":`tool-credential-secret`,className:`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900 min-w-0 max-w-full sm:w-72`}),(0,Q.jsx)(q,{size:`sm`,disabled:b||!v.trim(),onClick:()=>void F(),"data-testid":`tool-credential-save`,children:a(`common.save`)}),e.hasCredential&&(0,Q.jsx)(q,{size:`sm`,variant:`outline`,disabled:b,onClick:()=>void I(),"data-testid":`tool-credential-remove`,children:a(`toolsPage.credentialRemove`)})]})]}),t&&o&&(0,Q.jsxs)(`div`,{className:`mt-3 rounded-xl border border-black/[0.06] p-3 dark:border-white/[0.07]`,children:[(0,Q.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,children:a(`toolsPage.pinnedTools`)}),f?(0,Q.jsx)(`div`,{className:`flex justify-center py-6`,children:(0,Q.jsx)(L,{className:`h-4 w-4 animate-spin text-gray-400`})}):l.length===0?(0,Q.jsx)(`p`,{className:`py-4 text-center text-[12px] text-gray-400 dark:text-dark-500`,children:a(`toolsPage.noPinnedTools`)}):(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:l.map(e=>(0,Q.jsxs)(`div`,{"data-testid":`tool-server-tool`,className:`flex flex-wrap items-center justify-between gap-3 rounded-lg bg-black/[0.02] px-2.5 py-2 dark:bg-white/[0.03]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-[1_1_16rem]`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`code`,{className:`min-w-0 max-w-full break-words text-[12px] text-gray-900 [overflow-wrap:anywhere] dark:text-dark-900`,children:e.name}),e.sideEffect&&(0,Q.jsx)(`span`,{className:`rounded-full bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-amber-600 dark:text-amber-400`,children:a(`toolsPage.sideEffect`)})]}),e.description&&(0,Q.jsx)(`p`,{className:`mt-0.5 break-words text-[11px] text-gray-500 [overflow-wrap:anywhere] dark:text-dark-500`,children:e.description})]}),(0,Q.jsxs)(`div`,{className:`flex max-w-full flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,Q.jsxs)(`label`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:[a(`toolsPage.sideEffectOverride`),(0,Q.jsx)(Jt,{checked:e.sideEffect,onChange:t=>void P(e,{sideEffect:t})})]}),(0,Q.jsxs)(`label`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:[a(`common.enabled`),(0,Q.jsx)(Jt,{checked:e.enabled,onChange:t=>void P(e,{enabled:t})})]})]})]},e.name))})]})]})},Jr=[`openapi`,`mcp`],Yr=[`none`,`bearer`,`header`,`oauth`],Xr=[`admins-only`,`all-users`,`granted`];function Zr({open:e,server:t,prefill:n=null,saving:r,onClose:i,onSave:a}){return e?(0,Q.jsx)(Qr,{server:t,prefill:n,saving:r,onClose:i,onSave:a},t?.id??(n?`template-${n.name}`:`new`)):null}function Qr({server:e,prefill:t,saving:n,onClose:r,onSave:i}){let{t:a}=s(),o=e!==null,c=e??t,[l,u]=(0,Z.useState)(c?.name??``),[d,f]=(0,Z.useState)(c?.description??``),[p,m]=(0,Z.useState)(c?.kind??`openapi`),[h,g]=(0,Z.useState)(c?.baseUrl??``),[_,v]=(0,Z.useState)(t?.specUrl??``),[y,b]=(0,Z.useState)(c?.authMode??`none`),[x,S]=(0,Z.useState)(c?.authHeader??``),[C,w]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(``),[D,O]=(0,Z.useState)(c?.accessMode??`admins-only`),[k,A]=(0,Z.useState)(c?.enabled??!0),[j,M]=(0,Z.useState)(e?.timeoutMs?String(e.timeoutMs):``),[N,P]=(0,Z.useState)(e?.maxResponseBytes?String(e.maxResponseBytes):``),F=l.trim().length>0&&(o||h.trim().length>0)&&(y!==`header`||x.trim().length>0),I=e=>{let t=Number(e);return e.trim()&&Number.isFinite(t)&&t>0?t:void 0};return(0,Q.jsxs)(Kt,{titleId:`tool-server-modal-title`,title:a(o?`toolsPage.editServer`:`toolsPage.registerServer`),subtitle:o?void 0:a(`toolsPage.registerHint`),onClose:r,widthClassName:`max-w-2xl`,testId:`tool-server-modal`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:r,children:a(`common.cancel`)}),(0,Q.jsx)(q,{size:`sm`,onClick:()=>{if(!F)return;let e={name:l.trim(),description:d.trim()||void 0,authMode:y,authHeader:y===`header`?x.trim():void 0,accessMode:D,enabled:k,timeoutMs:I(j),maxResponseBytes:I(N)};if(o){i(e);return}i({...e,kind:p,baseUrl:h.trim(),specUrl:p===`openapi`&&_.trim()?_.trim():void 0,oauthClientId:y===`oauth`&&C.trim()?C.trim():void 0,oauthClientSecret:y===`oauth`&&T.trim()?T.trim():void 0})},disabled:n||!F,"data-testid":`tool-server-save`,children:a(n?`common.saving`:`common.save`)})]}),children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`tool-server-name`,className:J,children:a(`toolsPage.form.name`)}),(0,Q.jsx)(`input`,{id:`tool-server-name`,"data-testid":`tool-server-name`,type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:a(`toolsPage.form.namePlaceholder`),className:Y,maxLength:200,autoFocus:!0})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`tool-server-kind`,className:J,children:a(`toolsPage.form.kind`)}),(0,Q.jsx)(`select`,{id:`tool-server-kind`,value:p,disabled:o,onChange:e=>m(e.target.value),className:Y,children:Jr.map(e=>(0,Q.jsx)(`option`,{value:e,children:a(`toolsPage.kinds.${e}`)},e))})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`tool-server-description`,className:J,children:a(`toolsPage.form.description`)}),(0,Q.jsx)(`input`,{id:`tool-server-description`,type:`text`,value:d,onChange:e=>f(e.target.value),placeholder:a(`toolsPage.form.descriptionPlaceholder`),className:Y,maxLength:500})]}),!o&&(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`tool-server-base-url`,className:`mb-1 block text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,children:a(`toolsPage.form.baseUrl`)}),(0,Q.jsx)(`input`,{id:`tool-server-base-url`,"data-testid":`tool-server-base-url`,type:`url`,value:h,onChange:e=>g(e.target.value),placeholder:`https://api.example.com`,className:`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900`})]}),p===`openapi`&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`tool-server-spec-url`,className:`mb-1 block text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,children:a(`toolsPage.form.specUrl`)}),(0,Q.jsx)(`input`,{id:`tool-server-spec-url`,type:`url`,value:_,onChange:e=>v(e.target.value),placeholder:`https://api.example.com/openapi.json`,className:`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-gray-400 dark:text-dark-500`,children:a(`toolsPage.form.specUrlHint`)})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`tool-server-auth-mode`,className:J,children:a(`toolsPage.form.authMode`)}),(0,Q.jsx)(`select`,{id:`tool-server-auth-mode`,value:y,onChange:e=>b(e.target.value),className:Y,children:Yr.map(e=>(0,Q.jsx)(`option`,{value:e,children:a(`toolsPage.authModes.${e}`)},e))})]}),y===`header`&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`tool-server-auth-header`,className:`mb-1 block text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,children:a(`toolsPage.form.authHeader`)}),(0,Q.jsx)(`input`,{id:`tool-server-auth-header`,type:`text`,value:x,onChange:e=>S(e.target.value),placeholder:`X-Api-Key`,className:`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900`,maxLength:120})]}),y===`oauth`&&!o&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`tool-server-oauth-client-id`,className:`mb-1 block text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,children:a(`toolsPage.form.oauthClientId`)}),(0,Q.jsx)(`input`,{id:`tool-server-oauth-client-id`,"data-testid":`tool-server-oauth-client-id`,type:`text`,value:C,onChange:e=>w(e.target.value),className:`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900`,maxLength:200,autoComplete:`off`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-gray-400 dark:text-dark-500`,children:a(`toolsPage.form.oauthClientIdHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`tool-server-oauth-client-secret`,className:`mb-1 block text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,children:a(`toolsPage.form.oauthClientSecret`)}),(0,Q.jsx)(`input`,{id:`tool-server-oauth-client-secret`,type:`password`,value:T,onChange:e=>E(e.target.value),className:`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900`,maxLength:400,autoComplete:`off`})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`tool-server-access-mode`,className:J,children:a(`toolsPage.form.accessMode`)}),(0,Q.jsx)(`select`,{id:`tool-server-access-mode`,value:D,onChange:e=>O(e.target.value),className:Y,children:Xr.map(e=>(0,Q.jsx)(`option`,{value:e,children:a(`toolsPage.accessModes.${e}`)},e))})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`tool-server-timeout`,className:J,children:a(`toolsPage.form.timeoutMs`)}),(0,Q.jsx)(`input`,{id:`tool-server-timeout`,type:`number`,min:1,value:j,onChange:e=>M(e.target.value),placeholder:a(`toolsPage.form.serverDefault`),className:Y})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`tool-server-max-bytes`,className:J,children:a(`toolsPage.form.maxResponseBytes`)}),(0,Q.jsx)(`input`,{id:`tool-server-max-bytes`,type:`number`,min:1,value:N,onChange:e=>P(e.target.value),placeholder:a(`toolsPage.form.serverDefault`),className:Y})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-xl border border-black/[0.06] px-3 py-2.5 dark:border-white/[0.07]`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:a(`toolsPage.form.enabled`)}),(0,Q.jsx)(`p`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:a(`toolsPage.form.enabledHint`)})]}),(0,Q.jsx)(Jt,{checked:k,onChange:A})]})]})}var $r=[{id:`exa`,input:{name:`Exa`,kind:`mcp`,baseUrl:`https://mcp.exa.ai/mcp?tools=web_search_exa,web_fetch_exa`,authMode:`none`,accessMode:`admins-only`}},{id:`internalOpenApi`,input:{name:`Internal API`,description:`A starting point for your own OpenAPI 3.x JSON service. Replace the URLs; internal hostnames also need TOOLS_PRIVATE_NETWORK_ALLOWLIST on the server.`,kind:`openapi`,baseUrl:`https://api.example.internal`,specUrl:`https://api.example.internal/openapi.json`,authMode:`bearer`,accessMode:`admins-only`}},{id:`mcpServer`,input:{name:`MCP server`,description:`A starting point for an MCP server over Streamable HTTP. Replace the URL with your server’s endpoint; its tool list is fetched and pinned when you register.`,kind:`mcp`,baseUrl:`https://mcp.example.com/mcp`,authMode:`header`,authHeader:`X-Api-Key`,accessMode:`admins-only`}}],ei=o(`pages:tools`),ti=e=>e.response?.data?.error,ni=()=>{let{t:e}=s(),t=Nt(e=>e.isAdmin()),[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)([]),[o,c]=(0,Z.useState)(!0),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(0),C=(0,Z.useCallback)(()=>S(e=>e+1),[]);(0,Z.useEffect)(()=>{let t=new URLSearchParams(window.location.search),n=t.get(`mcpOAuth`);if(!n)return;n===`connected`?k.success(e(`toolsPage.oauth.callbackSuccess`)):k.error(e(`toolsPage.oauth.callbackError`)),t.delete(`mcpOAuth`),t.delete(`serverId`);let r=t.toString();window.history.replaceState({},``,`${window.location.pathname}${r?`?${r}`:``}${window.location.hash}`)},[e]),(0,Z.useEffect)(()=>{let t=!1;return Promise.all([H.listServers(),H.listApprovals()]).then(([n,i])=>{t||(n.success&&n.data?r(n.data):k.error(n.error||e(`toolsPage.loadFailed`)),i.success&&i.data&&a(i.data.standing))}).catch(n=>{t||(ei.error(`Failed to load tool servers:`,n),k.error(e(`toolsPage.loadFailed`)))}).finally(()=>{t||c(!1)}),()=>{t=!0}},[x,e]);let w=async t=>{g(!0);try{let n=d?await H.updateServer(d.id,t):await H.registerServer(t);n.success?(u(!1),m(null),k.success(e(`toolsPage.saved`)),C()):k.error(n.error||e(`toolsPage.saveFailed`))}catch(t){ei.error(`Failed to save the tool server:`,t),k.error(ti(t)||e(`toolsPage.saveFailed`))}finally{g(!1)}},T=async()=>{if(!_)return;let t=_;v(null);try{let n=await H.deleteServer(t.id);if(!n.success)throw Error(n.error);k.success(e(`toolsPage.deleted`)),C()}catch(t){ei.error(`Failed to delete the tool server:`,t),k.error(ti(t)||e(`toolsPage.deleteFailed`))}},E=async t=>{b(t);try{let n=await H.revokeApproval(t);if(!n.success)throw Error(n.error);a(e=>e.filter(e=>e.id!==t)),k.success(e(`toolsPage.approvals.revoked`))}catch(t){ei.error(`Failed to revoke the approval:`,t),k.error(e(`toolsPage.approvals.revokeFailed`))}finally{b(null)}};return(0,Q.jsxs)(`div`,{"data-testid":`tools-page`,className:`pb-2`,children:[(0,Q.jsx)(xr,{title:e(`toolsPage.title`),description:e(`toolsPage.description`),actions:t?(0,Q.jsxs)(q,{size:`sm`,onClick:()=>{f(null),m(null),u(!0)},"data-testid":`tool-server-new`,children:[(0,Q.jsx)(Ie,{className:`me-1.5 h-3.5 w-3.5`}),e(`toolsPage.registerServer`)]}):void 0}),(0,Q.jsx)(`p`,{className:`mb-5 rounded-xl border border-black/[0.06] bg-black/[0.02] px-3.5 py-2.5 text-[12px] leading-5 text-gray-500 dark:border-white/[0.07] dark:bg-white/[0.03] dark:text-dark-500`,children:e(`toolsPage.approvalNotice`)}),o?null:n.length===0?(0,Q.jsxs)(`div`,{className:`px-3 py-16 text-center`,children:[(0,Q.jsx)(Qe,{className:`mx-auto mb-3 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-dark-500`,children:e(`toolsPage.empty`)}),(0,Q.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-[13px] leading-6 text-gray-400 dark:text-dark-500`,children:e(t?`toolsPage.emptyHintAdmin`:`toolsPage.emptyHintUser`)})]}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:n.map(e=>(0,Q.jsx)(qr,{server:e,isAdmin:t,onEdit:e=>{f(e),u(!0)},onDelete:v,onChanged:C},e.id))}),(0,Q.jsx)(Wr,{approvals:i,servers:n,revoking:y,onRevoke:e=>void E(e)}),t&&!o&&(0,Q.jsx)(Dr,{title:e(`toolsPage.templatesTitle`),testId:`tool-server-template`,cards:$r.map(t=>({id:t.id,name:e(`toolsPage.templates.${t.id}.name`),description:e(`toolsPage.templates.${t.id}.description`),meta:t.input.baseUrl})),onPick:t=>{let n=$r.find(e=>e.id===t);n&&(f(null),m({...n.input,description:n.input.description??e(`toolsPage.templates.${n.id}.description`)}),u(!0))}}),(0,Q.jsx)(Zr,{open:l,server:d,prefill:p,saving:h,onClose:()=>{u(!1),m(null)},onSave:e=>void w(e)}),_&&(0,Q.jsx)(Kt,{titleId:`tool-server-delete-title`,title:e(`toolsPage.deleteTitle`),subtitle:e(`toolsPage.deleteConfirm`,{name:_.name}),onClose:()=>v(null),widthClassName:`max-w-sm`,testId:`tool-server-delete-modal`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>v(null),children:e(`common.cancel`)}),(0,Q.jsx)(q,{variant:`danger`,size:`sm`,onClick:()=>void T(),"data-testid":`tool-server-delete-confirm`,children:e(`common.delete`)})]})})]})};function ri({expanded:e,models:t,search:n,task:r,sort:i,loadingModels:a,canInstallModels:o,expandedModelId:c,loadingGgufModelId:l,ggufFiles:u,pullingModel:f,pullProgress:p,setSearch:m,setTask:h,setSort:g,onToggle:_,onToggleModel:v,onPullGguf:y,onCancelPull:b,onRefresh:x}){let{t:S}=s();return(0,Q.jsxs)(`div`,{className:d(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,Q.jsxs)(`button`,{onClick:_,"aria-expanded":e,className:d(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(nt,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:S(`modelManager.sections.huggingface`,`HuggingFace Hub`)}),t.length>0&&(0,Q.jsxs)(`span`,{className:d(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[t.length,` `,S(`modelManager.library.available`,`available`)]})]}),e?(0,Q.jsx)(Ze,{className:`h-5 w-5 text-gray-500`}):(0,Q.jsx)(xe,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,Q.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,Q.jsxs)(`div`,{className:`relative flex-1`,children:[(0,Q.jsx)(F,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,Q.jsx)(`input`,{type:`text`,value:n,onChange:e=>m(e.target.value),placeholder:S(`modelManager.huggingface.search`,`Search HuggingFace models...`),className:d(`w-full rounded-xl border py-2 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`)})]}),(0,Q.jsxs)(`select`,{value:r,onChange:e=>h(e.target.value),className:d(`px-3 py-2 rounded-lg border text-sm min-w-[160px]`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:[(0,Q.jsx)(`option`,{value:`text-generation`,children:S(`modelManager.huggingface.tasks.textGen`,`Text Generation`)}),(0,Q.jsx)(`option`,{value:`text-to-speech`,children:S(`modelManager.huggingface.tasks.tts`,`Text to Speech`)}),(0,Q.jsx)(`option`,{value:`text-to-image`,children:S(`modelManager.huggingface.tasks.image`,`Text to Image`)}),(0,Q.jsx)(`option`,{value:`automatic-speech-recognition`,children:S(`modelManager.huggingface.tasks.stt`,`Speech Recognition`)})]}),(0,Q.jsxs)(`select`,{value:i,onChange:e=>g(e.target.value),className:d(`px-3 py-2 rounded-lg border text-sm min-w-[140px]`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:[(0,Q.jsx)(`option`,{value:`downloads`,children:S(`modelManager.huggingface.sort.downloads`,`Most Downloads`)}),(0,Q.jsx)(`option`,{value:`likes`,children:S(`modelManager.huggingface.sort.likes`,`Most Liked`)}),(0,Q.jsx)(`option`,{value:`lastModified`,children:S(`modelManager.huggingface.sort.recent`,`Recently Updated`)})]})]}),!o&&(0,Q.jsx)(`p`,{className:`text-xs text-ink`,children:S(`modelManager.pull.restricted`)}),a?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Q.jsx)(P,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,Q.jsx)(`div`,{className:`text-center py-8 text-gray-500`,children:S(`modelManager.huggingface.noResults`,`No models found. Try adjusting your search or filters.`)}):(0,Q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:t.map(e=>(0,Q.jsx)(ii,{model:e,expanded:c===e.id,loadingGguf:l===e.id,ggufFiles:u[e.id]||[],pullingModel:f,pullProgress:p,canInstallModels:o,onToggle:()=>v(e.id),onPullGguf:y,onCancelPull:b},e.id))}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between pt-2`,children:[(0,Q.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,className:d(`inline-flex items-center gap-1.5 text-xs`,`text-primary-600 dark:text-primary-400`,`hover:underline`),children:[(0,Q.jsx)(st,{className:`h-3 w-3`}),S(`modelManager.huggingface.browseAll`,`Browse all on HuggingFace`)]}),(0,Q.jsxs)(q,{onClick:x,variant:`outline`,size:`sm`,disabled:a,className:d(`gap-1.5`,``,``),children:[(0,Q.jsx)(Te,{className:d(`h-3.5 w-3.5`,a&&`animate-spin`)}),S(`modelManager.library.refresh`,`Refresh`)]})]})]})]})}function ii({model:e,expanded:t,loadingGguf:n,ggufFiles:r,pullingModel:i,pullProgress:a,canInstallModels:o,onToggle:c,onPullGguf:l,onCancelPull:u}){let{t:f}=s();return(0,Q.jsxs)(`div`,{className:d(`rounded-lg border transition-all overflow-hidden`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400`),children:[(0,Q.jsxs)(`div`,{className:`p-4 cursor-pointer`,onClick:c,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800 truncate`,children:e.id}),e.gated&&(0,Q.jsx)(`span`,{className:d(`px-1.5 py-0.5 rounded text-xs`,`bg-yellow-500/20 dark:bg-yellow-900/30`,`text-ink`),children:f(`modelManager.huggingface.gated`,`Gated`)})]}),(0,Q.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-dark-600 mt-0.5`,children:[f(`modelManager.huggingface.by`,`by`),` `,e.author]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,Q.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-dark-300 transition-colors`,title:f(`modelManager.huggingface.viewOnHF`,`View on HuggingFace`),children:(0,Q.jsx)(st,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`})}),(0,Q.jsx)(xe,{className:d(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-500 dark:text-dark-600`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(j,{className:`h-3.5 w-3.5`}),si(e.downloads)]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(ae,{className:`h-3.5 w-3.5`}),si(e.likes)]}),e.pipeline_tag&&(0,Q.jsx)(`span`,{className:d(`px-1.5 py-0.5 rounded`,`bg-gray-200 dark:bg-dark-300`),children:e.pipeline_tag})]})]}),t&&(0,Q.jsx)(ai,{modelId:e.id,loading:n,files:r,pullingModel:i,pullProgress:a,canInstallModels:o,onPullGguf:l,onCancelPull:u})]})}function ai({modelId:e,loading:t,files:n,pullingModel:r,pullProgress:i,canInstallModels:a,onPullGguf:o,onCancelPull:c}){let{t:l}=s();return(0,Q.jsx)(`div`,{className:`px-4 pb-4 pt-1 border-t border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100`,children:t?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,Q.jsx)(P,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,Q.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:l(`modelManager.huggingface.checkingGguf`)})]}):n.length===0?(0,Q.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:l(`modelManager.huggingface.noGgufAvailable`)}):(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:l(`modelManager.huggingface.ggufFilesCount`,{count:n.length})}),n.map(e=>(0,Q.jsx)(oi,{file:e,pulling:r===e.ollamaCommand,pullProgress:i,canInstallModels:a,disabled:!!r||!a,onPullGguf:o,onCancelPull:c},e.filename)),r?.startsWith(`hf.co/`)&&r.includes(e)&&i?.percent!==void 0&&(0,Q.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,Q.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${i.percent}%`}})})]})})}function oi({file:e,pulling:t,disabled:n,pullProgress:r,onPullGguf:i,onCancelPull:a}){let{t:o}=s();return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-gray-50 dark:bg-dark-50 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,Q.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,Q.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400`,children:e.quantization})]})]}),t?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:r?.percent===void 0?`...`:`${r.percent}%`}),(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),a()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,Q.jsx)(Ke,{className:`h-4 w-4`})})]}):(0,Q.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),i(e.ollamaCommand,e.filename)},disabled:n,className:d(`px-3 py-1.5 rounded-lg text-xs font-medium`,`bg-primary-100 dark:bg-primary-900/30`,`text-primary-700 dark:text-primary-400`,`hover:bg-primary-200 dark:hover:bg-primary-900/50`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[(0,Q.jsx)(j,{className:`h-3 w-3 inline mr-1`}),o(`models.pull`)]})]})}function si(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e}function ci({expanded:e,models:t,onToggle:n,isModelRunning:r,formatSize:i,onShowModel:a,onCopyModel:o,onDeleteModel:c}){let{t:l}=s();return(0,Q.jsxs)(`div`,{className:d(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,Q.jsxs)(`button`,{onClick:n,"aria-expanded":e,className:d(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(Se,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:l(`modelManager.sections.local`)}),(0,Q.jsxs)(`span`,{className:d(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[t.length,` `,l(`modelManager.local.installed`)]})]}),e?(0,Q.jsx)(Ze,{className:`h-5 w-5 text-gray-500`}):(0,Q.jsx)(xe,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,Q.jsx)(`div`,{className:`p-4 pt-0`,children:t.length===0?(0,Q.jsxs)(`div`,{className:d(`text-center py-12 rounded-lg border-2 border-dashed`,`border-gray-200 dark:border-dark-300`),children:[(0,Q.jsx)(Se,{className:`h-12 w-12 mx-auto mb-3 text-gray-300 dark:text-gray-600`}),(0,Q.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mb-2`,children:l(`modelManager.local.noModels`)}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-500`,children:l(`modelManager.local.pullToStart`)})]}):(0,Q.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>(0,Q.jsx)(li,{model:e,running:r(e.name),formatSize:i,onShowModel:a,onCopyModel:o,onDeleteModel:c},e.name))})})]})}function li({model:e,running:t,formatSize:n,onShowModel:r,onCopyModel:i,onDeleteModel:a}){let{t:o}=s();return(0,Q.jsx)(`div`,{className:d(`p-4 rounded-lg border transition-colors`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`hover:bg-gray-100 dark:hover:bg-dark-200`),children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Q.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),t&&(0,Q.jsxs)(`span`,{className:d(`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[(0,Q.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse`}),o(`modelManager.local.running`)]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-sm text-gray-600 dark:text-dark-600 mt-2`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(Se,{className:`h-3.5 w-3.5`}),n(e.size)]}),e.details?.parameter_size&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(Ue,{className:`h-3.5 w-3.5`}),e.details.parameter_size]}),e.details?.quantization_level&&(0,Q.jsx)(`span`,{className:d(`px-1.5 py-0.5 rounded text-xs`,`bg-gray-200 dark:bg-dark-300`,`text-gray-600 dark:text-gray-400`),children:e.details.quantization_level}),e.details?.family&&(0,Q.jsx)(`span`,{className:`text-gray-500 dark:text-gray-500`,children:e.details.family})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-400 dark:text-dark-500 mt-2`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(oe,{className:`h-3 w-3`}),new Date(e.modified_at).toLocaleDateString()]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 font-mono truncate max-w-[200px]`,title:e.digest,children:[(0,Q.jsx)(we,{className:`h-3 w-3`}),e.digest.slice(0,12),`...`]})]})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2 flex-shrink-0`,children:[(0,Q.jsxs)(q,{onClick:()=>r(e.name),variant:`outline`,size:`sm`,className:d(`gap-1.5`,``,``),children:[(0,Q.jsx)(be,{className:`h-3.5 w-3.5`}),o(`modelManager.local.info`)]}),(0,Q.jsxs)(q,{onClick:()=>i(e.name),variant:`outline`,size:`sm`,className:d(`gap-1.5`,``,``),children:[(0,Q.jsx)(T,{className:`h-3.5 w-3.5`}),o(`modelManager.local.copy`)]}),(0,Q.jsxs)(q,{onClick:()=>a(e.name),variant:`outline`,size:`sm`,className:d(`gap-1.5`,`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,``,``),children:[(0,Q.jsx)(V,{className:`h-3.5 w-3.5`}),o(`modelManager.local.delete`)]})]})]})})}function ui({expanded:e,models:t,totalAvailable:n,categories:r,filter:i,search:a,loading:o,pulling:c,canInstallModels:l,pullSectionExpanded:u,setFilter:f,setSearch:p,isModelInstalled:m,normalizeCloudPullName:h,onToggle:g,onTogglePullSection:_,onPullModel:v,onRefresh:y}){let{t:b}=s();return(0,Q.jsxs)(`div`,{className:d(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,Q.jsxs)(`button`,{onClick:g,"aria-expanded":e,className:d(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(ne,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:b(`modelManager.sections.library`)}),(0,Q.jsxs)(`span`,{className:d(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[n,` `,b(`modelManager.library.available`)]})]}),e?(0,Q.jsx)(Ze,{className:`h-5 w-5 text-gray-500`}):(0,Q.jsx)(xe,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,Q.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,Q.jsxs)(`div`,{className:`relative flex-1`,children:[(0,Q.jsx)(F,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,Q.jsx)(`input`,{type:`text`,value:a,onChange:e=>p(e.target.value),placeholder:b(`modelManager.library.search`),className:d(`w-full rounded-xl border py-2 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Ne,{className:`h-4 w-4 text-gray-400`}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,Q.jsx)(`button`,{onClick:()=>f(e),className:d(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,i===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-dark-300`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]})]}),o?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Q.jsx)(Te,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,Q.jsx)(`div`,{className:`text-center py-8 text-gray-500`,children:b(`modelManager.library.noResults`)}):(0,Q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:t.map(e=>{let t=e.category===`cloud`?h(e.name):e.name,n=m(e.name)||m(t);return(0,Q.jsx)(di,{model:e,installed:n,pulling:c,canInstallModels:l,pullSectionExpanded:u,onTogglePullSection:_,onPullModel:v},e.name)})}),(0,Q.jsx)(`div`,{className:`flex justify-center`,children:(0,Q.jsxs)(q,{onClick:y,variant:`outline`,size:`sm`,disabled:o,className:d(`gap-1.5`,``,``),children:[(0,Q.jsx)(Te,{className:d(`h-3.5 w-3.5`,o&&`animate-spin`)}),b(`modelManager.library.refresh`)]})})]})]})}function di({model:e,installed:t,pulling:n,canInstallModels:r,pullSectionExpanded:i,onTogglePullSection:a,onPullModel:o}){let{t:c}=s();return(0,Q.jsxs)(`div`,{"data-testid":`library-model-card-${e.name}`,className:d(`p-4 rounded-lg border transition-all`,`bg-gray-50 dark:bg-dark-50`,t?`border-green-200 dark:border-green-800/50`:`border-gray-200 dark:border-dark-300`,`hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400`),children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,Q.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),t&&(0,Q.jsxs)(`span`,{className:d(`flex items-center gap-1 px-1.5 py-0.5 rounded text-xs`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[(0,Q.jsx)(Ee,{className:`h-3 w-3`}),c(`modelManager.library.installed`)]})]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-600 dark:text-dark-600 mb-3 line-clamp-2`,children:e.description}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-3`,children:[e.sizes.slice(0,4).map(e=>(0,Q.jsx)(`span`,{className:d(`px-1.5 py-0.5 rounded text-xs`,`bg-gray-200 dark:bg-dark-300`,`text-gray-600 dark:text-gray-400`),children:e},e)),e.sizes.length>4&&(0,Q.jsx)(`span`,{className:`text-xs text-gray-400`,children:c(`modelManager.library.more`,{count:e.sizes.length-4})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-gray-500`,children:[e.pulls&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(j,{className:`h-3 w-3`}),e.pulls]}),(0,Q.jsx)(`span`,{className:d(`px-1.5 py-0.5 rounded capitalize`,e.category===`cloud`?`bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400`:`bg-gray-100 dark:bg-dark-200`),children:e.category})]}),(0,Q.jsxs)(q,{"data-testid":`library-model-install-${e.name}`,onClick:()=>{i||a(),o(e.name,e.category)},variant:`outline`,size:`sm`,disabled:n||!r,className:d(`gap-1 text-xs`,``,``),children:[(0,Q.jsx)(j,{className:`h-3 w-3`}),c(`modelManager.pull.button`)]})]})]})}function fi({expanded:e,modelName:t,setModelName:n,pulling:r,progress:i,canInstallModels:a,popularModels:o,onToggle:c,onPull:l,onCancelPull:u,formatSize:f}){let{t:p}=s();return(0,Q.jsxs)(`div`,{className:d(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,Q.jsxs)(`button`,{onClick:c,"aria-expanded":e,className:d(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(j,{className:`h-4 w-4 text-primary-600 dark:text-primary-400`}),(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:p(`modelManager.sections.pull`)})]}),e?(0,Q.jsx)(Ze,{className:`h-5 w-5 text-gray-500`}):(0,Q.jsx)(xe,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,Q.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`div`,{className:`relative flex-1`,children:[(0,Q.jsx)(F,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,Q.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:p(`modelManager.pull.placeholder`),className:d(`w-full rounded-xl border py-2.5 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`),disabled:r||!a,onKeyDown:e=>{e.key===`Enter`&&!r&&a&&l()}})]}),r?(0,Q.jsxs)(q,{onClick:u,variant:`outline`,className:d(`px-4 py-2.5 gap-2`,`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,``,``),children:[(0,Q.jsx)(Ke,{className:`h-4 w-4`}),p(`modelManager.pull.cancel`)]}):(0,Q.jsxs)(q,{onClick:l,disabled:!t.trim()||!a,className:d(`px-4 py-2.5 gap-2`,``),children:[(0,Q.jsx)(j,{className:`h-4 w-4`}),p(`modelManager.pull.button`)]})]}),r&&i&&(0,Q.jsx)(pi,{progress:i,formatSize:f}),!a&&(0,Q.jsx)(`p`,{className:`text-xs text-ink-muted`,children:p(`modelManager.pull.restricted`)}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 mb-2`,children:p(`modelManager.pull.popular`)}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:o.map(e=>(0,Q.jsxs)(`button`,{onClick:()=>n(e.name),disabled:r||!a,className:d(`px-3 py-1.5 rounded-full text-xs font-medium transition-colors`,`bg-gray-100 dark:bg-dark-200`,`text-gray-700 dark:text-gray-300`,`hover:bg-gray-200 dark:hover:bg-dark-300`,`border border-gray-200 dark:border-dark-300`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[e.name,(0,Q.jsx)(`span`,{className:`ml-1 text-gray-400 dark:text-gray-500`,children:e.size})]},`${e.name}-${e.size}`))})]}),(0,Q.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,className:d(`inline-flex items-center gap-1.5 text-xs`,`text-primary-600 dark:text-primary-400`,`hover:underline`),children:[(0,Q.jsx)(st,{className:`h-3 w-3`}),p(`modelManager.pull.browseAll`)]})]})]})}function pi({progress:e,formatSize:t}){let{t:n}=s(),r=e.status===`starting`?n(`modelManager.progress.starting`):e.status.startsWith(`pulling`)?`${n(`modelManager.progress.pullingLayer`)} ${e.status.replace(`pulling `,``)}`:e.status.startsWith(`verifying sha256`)?n(`modelManager.progress.verifyingDigest`):e.status===`writing manifest`?n(`modelManager.progress.writing`):e.status===`removing any unused layers`?n(`modelManager.progress.cleaning`):e.status;return(0,Q.jsxs)(`div`,{className:d(`p-4 rounded-lg border`,`bg-gray-50 dark:bg-dark-200`,`border-gray-200 dark:border-dark-300`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-800 dark:text-dark-700`,children:r}),e.percent!==void 0&&(0,Q.jsxs)(`span`,{className:`text-sm font-mono text-gray-600 dark:text-dark-600`,children:[e.percent,`%`]})]}),e.percent!==void 0&&(0,Q.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-400 rounded-full h-2 overflow-hidden`,children:(0,Q.jsx)(`div`,{className:d(`h-2 rounded-full transition-all duration-300`,`bg-primary-500 dark:bg-primary-400`),style:{width:`${e.percent}%`}})}),e.total&&e.completed&&(0,Q.jsxs)(`div`,{className:`mt-2 text-xs text-gray-600 dark:text-dark-600`,children:[t(e.completed),` / `,t(e.total)]})]})}function mi({modelCount:e,updating:t,progress:n,onUpdateAll:r}){let{t:i}=s();return(0,Q.jsxs)(`section`,{"data-testid":`model-manager-bulk-operations`,"aria-labelledby":`model-manager-bulk-operations-title`,"aria-busy":t,className:d(`rounded-2xl border p-4`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,Q.jsx)(`h3`,{id:`model-manager-bulk-operations-title`,className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:i(`settings.model.bulkOperations`)}),(0,Q.jsxs)(`div`,{className:`mt-4`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:i(`settings.model.updateAll`)}),(0,Q.jsx)(`p`,{className:`mb-3 mt-2 text-xs text-gray-500 dark:text-gray-400`,children:i(`settings.model.updateAllDescription`)}),t&&n&&(0,Q.jsx)(hi,{progress:n}),(0,Q.jsx)(q,{onClick:r,variant:`outline`,size:`sm`,className:`w-full`,disabled:t||e===0,"aria-busy":t,children:t?i(`settings.model.updating`):i(`settings.model.updateAllButton`,{count:e})})]})]})}function hi({progress:e}){let{t}=s(),n=e.total>0?Math.round(e.current/e.total*100):0;return(0,Q.jsxs)(`div`,{className:`mb-4 space-y-3`,"aria-live":`polite`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-gray-600 dark:text-dark-600`,children:t(`settings.model.updatingModel`,{name:e.modelName,current:e.current,total:e.total})}),(0,Q.jsxs)(`span`,{className:`font-semibold text-primary-600 dark:text-primary-400`,children:[n,`%`]})]}),(0,Q.jsx)(`div`,{role:`progressbar`,"aria-label":t(`settings.model.updateAll`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n,className:`h-3 w-full rounded-full bg-gray-200 dark:bg-dark-300`,children:(0,Q.jsx)(`div`,{className:`h-3 rounded-full bg-primary-600 transition-[width] duration-150 ease-out motion-reduce:transition-none dark:bg-primary-400`,style:{width:`${n}%`}})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,Q.jsxs)(`span`,{className:`text-gray-500 dark:text-dark-500`,children:[t(`settings.model.status`),`:`,` `,e.status===`starting`?(0,Q.jsx)(`span`,{className:`text-accent-500 dark:text-accent-400`,children:t(`settings.model.statusStarting`)}):e.status===`success`?(0,Q.jsx)(`span`,{className:`text-success-600 dark:text-success-500`,children:t(`settings.model.statusComplete`)}):(0,Q.jsxs)(`span`,{className:`text-error-600 dark:text-error-500`,children:[t(`settings.model.statusError`),`: `,e.error]})]}),(0,Q.jsx)(`span`,{className:`text-[10px] text-gray-400 dark:text-dark-600`,children:t(`settings.model.modelsProgress`,{current:e.current,total:e.total})})]})]})}var gi=o(`components:model-manager`),_i=Z.lazy(()=>a(()=>import(`./ModelManagerModals-Bc2Woor7.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),vi=e=>{let t=e.split(`:`).pop()?.toLowerCase();return t===`cloud`||t?.endsWith(`-cloud`)===!0},yi=e=>{let t=e.trim();if(!t||vi(t))return t;let n=t.lastIndexOf(`:`);return n===-1?`${t}:cloud`:`${t.slice(0,n)}:${t.slice(n+1)}-cloud`},bi=({updatingAllModels:e,updateProgress:t,onUpdateAllModels:n})=>{let{t:a}=s(),{user:o,systemInfo:c}=Nt(),l=o?.role===`admin`||c?.requiresAuth===!1,{data:u}=i({queryKey:[`model-download-access`],queryFn:async()=>{let e=await K.getModelAccess();return e.success&&e.data?e.data:null},staleTime:6e4}),f=l||u?.allowed===!0,p=r(),[m,h]=(0,Z.useState)(`all`),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(null),[w,E]=(0,Z.useState)(null),[O,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(``),[N,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(!1),[ee,te]=(0,Z.useState)(!1),[ne,L]=(0,Z.useState)(``),[re,ie]=(0,Z.useState)(``),[ae,R]=(0,Z.useState)(!1),[oe,se]=(0,Z.useState)(!1),[ce,le]=(0,Z.useState)(``),[ue,z]=(0,Z.useState)(``),[de,fe]=(0,Z.useState)(!1),[pe,B]=(0,Z.useState)(!1),[me,ge]=(0,Z.useState)(``),[_e,ye]=(0,Z.useState)(``),[be,Ce]=(0,Z.useState)(null),[we,Ee]=(0,Z.useState)(!1),[De,Oe]=(0,Z.useState)(``),[ke,Me]=(0,Z.useState)(``),[Ne,Pe]=(0,Z.useState)(`text-generation`),[Fe,Ie]=(0,Z.useState)(`downloads`),[Le,Re]=(0,Z.useState)(null),[ze,Be]=(0,Z.useState)({}),[Ve,He]=(0,Z.useState)(null),[Ue,Ge]=(0,Z.useState)(null),[Ke,qe]=(0,Z.useState)(null),[Je,Ye]=(0,Z.useState)(null),[Xe,Qe]=(0,Z.useState)(new Set([`pull`,`local`])),$e=e=>{Qe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},{data:et,isLoading:rt,refetch:it}=i({queryKey:[`ollama-state`],queryFn:async()=>{let[e,t,n,r]=await Promise.all([K.getModels(),K.listRunningModels(),K.getVersion(),K.checkHealth()]);return{models:e.success&&e.data||[],runningModels:t.success&&Array.isArray(t.data)?t.data:[],ollamaVersion:n.success&&n.data?n.data.version:null,isHealthy:r.success}}}),at=et?.models??[],V=et?.runningModels??[],ot=et?.ollamaVersion??null,st=et?.isHealthy??null,lt=(0,Z.useRef)(e);(0,Z.useEffect)(()=>{let t=lt.current&&!e;lt.current=e,t&&it()},[it,e]);let ut=(0,Z.useCallback)(async()=>{await it()},[it]),{data:dt=[],isLoading:ft}=i({queryKey:[`ollama-library`],queryFn:async()=>{let e=await K.getLibraryModels();return e.success&&e.data?e.data:[]}}),{data:mt=[],isLoading:ht}=i({queryKey:[`ollama-library`,`cloud`],queryFn:async()=>{let e=await K.getLibraryModels({category:`cloud`});return e.success&&e.data?e.data:[]},enabled:m===`cloud`}),gt=()=>p.invalidateQueries({queryKey:[`ollama-library`]});(0,Z.useEffect)(()=>{let e=setTimeout(()=>{Me(De)},300);return()=>clearTimeout(e)},[De]);let _t=Xe.has(`huggingface`),{data:vt=[],isLoading:yt}=i({queryKey:[`hf-models`,Ne,ke,Fe],queryFn:async()=>{let e=await pt.getModels({task:Ne,search:ke||void 0,sort:Fe,limit:30});return e.success&&e.data?e.data:[]},enabled:_t}),bt=()=>p.invalidateQueries({queryKey:[`hf-models`,Ne,ke,Fe]}),xt=(0,Z.useCallback)(async e=>{let[t,n]=e.split(`/`);if(t&&n){He(e);try{let r=await pt.getGgufFiles(t,n);r.success&&r.data&&Be(t=>({...t,[e]:r.data}))}catch(e){gi.error(`Failed to load GGUF files:`,e)}finally{He(null)}}},[]),St=(0,Z.useCallback)(e=>{Le===e?Re(null):(Re(e),ze[e]||xt(e))},[Le,ze,xt]),H=(0,Z.useCallback)((e,t)=>{if(!f){k.error(a(`modelManager.pull.restricted`));return}if(!Ue){Ge(e),qe({status:`starting`});try{let n=K.pullModelStream(e,e=>{qe(e)},()=>{qe(null),Ge(null),Ye(null),k.success(a(`modelDownload.success`,{name:t})),ut()},e=>{qe(null),Ge(null),Ye(null),k.error(a(`modelDownload.failed`,{error:e}))});Ye(()=>n)}catch{qe(null),Ge(null),k.error(a(`modelDownload.startFailed`))}}},[f,Ue,ut,a]),U=(0,Z.useCallback)(()=>{Je&&(Je(),Ye(null),Ge(null),qe(null))},[Je]),Ct=async(e,t)=>{if(!f){k.error(a(`modelManager.pull.restricted`));return}let n=e||v.trim(),r=t===`cloud`||!e&&m===`cloud`?yi(n):n;if(!r){k.error(a(`modelManager.pull.enterName`));return}e&&y(r),x(!0),C({status:`starting`});try{let e=K.pullModelStream(r,e=>{C(e)},()=>{C(null),x(!1),E(null),k.success(a(`modelManager.pull.success`,{name:r})),y(``),ut()},e=>{C(null),x(!1),E(null),k.error(a(`modelManager.pull.failed`)+`: `+e)});E(()=>e)}catch(e){let t=e instanceof Error?e.message:String(e);k.error(a(`modelManager.pull.failed`)+`: `+t),C(null),x(!1),E(null)}},wt=()=>{w&&(w(),E(null),x(!1),C(null),k.success(a(`modelManager.pull.cancelled`)))},Tt=async e=>{if(confirm(a(`modelManager.local.deleteConfirm`,{name:e})))try{await K.deleteModel(e),k.success(a(`modelManager.local.deleteSuccess`,{name:e})),await ut()}catch(e){let t=e instanceof Error?e.message:String(e);k.error(a(`modelManager.local.deleteFailed`)+`: `+t)}},Et=async e=>{I(!0),M(e),P(!0);try{let t=await K.showModel(e,!0);t.success&&t.data?A(t.data):k.error(a(`modelManager.modals.details.noDetails`))}catch(e){let t=e instanceof Error?e.message:String(e);k.error(a(`modelManager.modals.details.noDetails`)+`: `+t)}finally{I(!1)}},Dt=async()=>{if(!ne.trim()||!re.trim()){k.error(a(`modelManager.modals.copy.enterBoth`));return}R(!0);try{await K.copyModel(ne.trim(),re.trim()),k.success(a(`modelManager.modals.copy.success`,{name:re})),te(!1),L(``),ie(``),await ut()}catch(e){let t=e instanceof Error?e.message:String(e);k.error(a(`modelManager.modals.copy.failed`)+`: `+t)}finally{R(!1)}},W=async()=>{if(!ce.trim()||!ue.trim()){k.error(a(`modelManager.modals.create.enterBoth`));return}fe(!0);try{await K.createModel({model:ce.trim(),modelfile:ue.trim()}),k.success(a(`modelManager.modals.create.success`,{name:ce})),se(!1),le(``),z(``),await ut()}catch(e){let t=e instanceof Error?e.message:String(e);k.error(a(`modelManager.modals.create.failed`)+`: `+t)}finally{fe(!1)}},Ot=async()=>{if(!me.trim()||!_e.trim()){k.error(a(`modelManager.modals.embeddings.enterBoth`));return}Ee(!0),Ce(null);try{let e=await K.generateEmbeddings({model:me.trim(),input:_e.trim()});if(e.success&&e.data){let t=e.data.embeddings?.[0]||[];Ce(t),k.success(a(`modelManager.modals.embeddings.success`,{count:t.length}))}}catch(e){let t=e instanceof Error?e.message:String(e);k.error(a(`modelManager.modals.embeddings.failed`)+`: `+t)}finally{Ee(!1)}},G=e=>{let t=e/1073741824;return t>=1?`${t.toFixed(2)} GB`:`${(e/1048576).toFixed(1)} MB`},kt=e=>Array.isArray(V)&&V.some(t=>t.name===e),At=()=>at.reduce((e,t)=>e+t.size,0),jt=()=>V.reduce((e,t)=>e+(t.size_vram||0),0),Mt=e=>at.some(t=>t.name===e||t.name.startsWith(e+`:`)),Pt=(m===`cloud`?mt:dt).filter(e=>{let t=m===`all`||m===`cloud`||e.category===m,n=!g||e.name.toLowerCase().includes(g.toLowerCase())||e.description.toLowerCase().includes(g.toLowerCase());return t&&n}),Ft=[`all`,...new Set([...dt.map(e=>e.category),`cloud`])],It=(0,Z.useMemo)(()=>dt.length>0?dt.slice(0,10).map(e=>({name:e.name,category:e.category,size:e.sizes?.[0]||``})):[{name:`gemma4`,category:`general`,size:`12B`},{name:`gemma4`,category:`general`,size:`26B`},{name:`gemma4`,category:`general`,size:`31B`},{name:`qwen3.8`,category:`reasoning`,size:`27B`},{name:`nomic-embed-text`,category:`embedding`,size:`137M`}],[dt]),Lt=N||ee||oe||pe;return rt?(0,Q.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 text-gray-600 dark:text-dark-600`,children:[(0,Q.jsx)(Te,{className:`h-5 w-5 animate-spin`}),a(`modelManager.loading`)]})}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`div`,{className:d(`rounded-2xl border px-4 py-3`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:d(`w-2.5 h-2.5 rounded-full`,st?`bg-green-500`:`bg-red-500`)}),(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:a(st?`modelManager.systemStatus.online`:`modelManager.systemStatus.offline`)})]}),ot&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,Q.jsx)(he,{className:`h-4 w-4`}),(0,Q.jsxs)(`span`,{children:[`v`,ot]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,Q.jsx)(Se,{className:`h-4 w-4`}),(0,Q.jsxs)(`span`,{children:[at.length,` `,at.length===1?a(`modelManager.systemStatus.models`):a(`modelManager.systemStatus.models_plural`)]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,Q.jsx)(D,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:G(At())})]}),V.length>0&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-green-600 dark:text-green-400`,children:[(0,Q.jsx)(je,{className:`h-4 w-4`}),(0,Q.jsxs)(`span`,{children:[V.length,` `,a(`modelManager.systemStatus.running`),` (`,G(jt()),` `,a(`modelManager.systemStatus.vram`),`)`]})]})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsxs)(q,{onClick:ut,variant:`outline`,size:`sm`,className:d(`gap-1.5`,``,``),children:[(0,Q.jsx)(Te,{className:`h-3.5 w-3.5`}),a(`common.refresh`)]})})]})}),(0,Q.jsx)(fi,{expanded:Xe.has(`pull`),modelName:v,setModelName:y,pulling:b,progress:S,canInstallModels:f,popularModels:It,onToggle:()=>$e(`pull`),onPull:()=>Ct(),onCancelPull:wt,formatSize:G}),(0,Q.jsx)(ui,{expanded:Xe.has(`library`),models:Pt,totalAvailable:dt.length,categories:Ft,filter:m,search:g,loading:ft||ht,pulling:b,canInstallModels:f,pullSectionExpanded:Xe.has(`pull`),setFilter:h,setSearch:_,isModelInstalled:Mt,normalizeCloudPullName:yi,onToggle:()=>$e(`library`),onTogglePullSection:()=>$e(`pull`),onPullModel:Ct,onRefresh:gt}),(0,Q.jsx)(ri,{expanded:Xe.has(`huggingface`),models:vt,search:De,task:Ne,sort:Fe,loadingModels:yt,canInstallModels:f,expandedModelId:Le,loadingGgufModelId:Ve,ggufFiles:ze,pullingModel:Ue,pullProgress:Ke,setSearch:Oe,setTask:Pe,setSort:Ie,onToggle:()=>$e(`huggingface`),onToggleModel:St,onPullGguf:H,onCancelPull:U,onRefresh:bt}),Array.isArray(V)&&V.length>0&&(0,Q.jsxs)(`div`,{className:d(`rounded-2xl border p-4`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,Q.jsx)(je,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:a(`modelManager.sections.running`)}),(0,Q.jsxs)(`span`,{className:d(`ms-auto rounded-full px-2 py-0.5 text-xs font-medium`,`border border-gray-200 bg-gray-50 dark:border-white/10 dark:bg-white/[0.04]`,`text-gray-600 dark:text-dark-600`),children:[V.length,` `,a(`modelManager.systemStatus.running`)]})]}),(0,Q.jsx)(`div`,{className:`space-y-2`,children:V.map(e=>(0,Q.jsxs)(`div`,{className:d(`flex items-center justify-between p-4 rounded-lg border`,`bg-white/50 dark:bg-white/[0.025]`,`border-gray-200/80 dark:border-white/[0.08]`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:d(`w-2 h-2 rounded-full animate-pulse`,`bg-green-500`)}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 text-sm text-gray-500 dark:text-dark-500`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(We,{className:`h-3 w-3`}),a(`modelManager.systemStatus.vram`),`:`,` `,G(e.size_vram||0)]}),e.size&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(Se,{className:`h-3 w-3`}),a(`models.size`),`: `,G(e.size)]})]})]})]}),(0,Q.jsxs)(`div`,{className:d(`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium`,`border border-gray-200 bg-gray-50 dark:border-white/10 dark:bg-white/[0.04]`,`text-gray-600 dark:text-dark-600`),children:[(0,Q.jsx)(nt,{className:`h-3 w-3`}),a(`modelManager.local.running`)]})]},e.name))})]}),(0,Q.jsx)(ci,{expanded:Xe.has(`local`),models:at,onToggle:()=>$e(`local`),isModelRunning:kt,formatSize:G,onShowModel:Et,onCopyModel:e=>{L(e),te(!0)},onDeleteModel:Tt}),l&&(0,Q.jsx)(mi,{modelCount:at.length,updating:e,progress:t,onUpdateAll:n}),(0,Q.jsxs)(`div`,{className:d(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,Q.jsxs)(`button`,{onClick:()=>$e(`advanced`),"aria-expanded":Xe.has(`advanced`),className:d(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(ve,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:a(`modelManager.sections.advanced`)})]}),Xe.has(`advanced`)?(0,Q.jsx)(Ze,{className:`h-5 w-5 text-gray-500`}):(0,Q.jsx)(xe,{className:`h-5 w-5 text-gray-500`})]}),Xe.has(`advanced`)&&(0,Q.jsx)(`div`,{className:`p-4 pt-0`,children:(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3`,children:[(0,Q.jsxs)(q,{onClick:()=>se(!0),variant:`outline`,className:d(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,Q.jsx)(Ae,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,Q.jsxs)(`div`,{className:`text-start`,children:[(0,Q.jsx)(`div`,{className:`font-medium`,children:a(`modelManager.advanced.createModel`)}),(0,Q.jsx)(`div`,{className:`text-xs opacity-70`,children:a(`modelManager.advanced.fromModelfile`)})]})]}),(0,Q.jsxs)(q,{onClick:()=>te(!0),variant:`outline`,className:d(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,Q.jsx)(T,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,Q.jsxs)(`div`,{className:`text-start`,children:[(0,Q.jsx)(`div`,{className:`font-medium`,children:a(`modelManager.advanced.copyModel`)}),(0,Q.jsx)(`div`,{className:`text-xs opacity-70`,children:a(`modelManager.advanced.duplicateExisting`)})]})]}),(0,Q.jsxs)(q,{onClick:()=>B(!0),variant:`outline`,className:d(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,Q.jsx)(ct,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,Q.jsxs)(`div`,{className:`text-start`,children:[(0,Q.jsx)(`div`,{className:`font-medium`,children:a(`modelManager.advanced.testEmbeddings`)}),(0,Q.jsx)(`div`,{className:`text-xs opacity-70`,children:a(`modelManager.advanced.generateVectors`)})]})]}),(0,Q.jsxs)(q,{onClick:async()=>{try{(await K.checkHealth()).success&&(await it(),k.success(a(`modelManager.advanced.healthy`)))}catch{await it(),k.error(a(`modelManager.systemStatus.offline`))}},variant:`outline`,className:d(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,Q.jsx)(tt,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,Q.jsxs)(`div`,{className:`text-start`,children:[(0,Q.jsx)(`div`,{className:`font-medium`,children:a(`modelManager.advanced.healthCheck`)}),(0,Q.jsx)(`div`,{className:`text-xs opacity-70`,children:a(`modelManager.advanced.testConnection`)})]})]})]})})]}),Lt&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(_i,{models:at,showDetailsModal:N,setShowDetailsModal:P,selectedModelName:j,selectedModelDetails:O,loadingDetails:F,showCopyModal:ee,setShowCopyModal:te,copySource:ne,setCopySource:L,copyDestination:re,setCopyDestination:ie,copying:ae,handleCopyModel:Dt,showCreateModal:oe,setShowCreateModal:se,createModelName:ce,setCreateModelName:le,createModelfile:ue,setCreateModelfile:z,creating:de,handleCreateModel:W,showEmbeddingsModal:pe,setShowEmbeddingsModal:B,embeddingsModel:me,setEmbeddingsModel:ge,embeddingsInput:_e,setEmbeddingsInput:ye,embeddingsResult:be,generatingEmbeddings:we,handleGenerateEmbeddings:Ot})})]})};function xi({loadPreferences:e,loadSessions:t,loadFolders:n}){let{t:r}=s(),[i,a]=(0,Z.useState)(!1),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(`skip`),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),y=(0,Z.useRef)(null),b=(0,Z.useRef)(0),x=e=>{switch(e.code){case`invalidJson`:return r(`settings.data.archiveErrors.invalidJson`);case`objectRequired`:return r(`settings.data.archiveErrors.objectRequired`);case`unsupportedVersion`:return r(`settings.data.archiveErrors.unsupportedVersion`,{version:String(e.version)});case`unrecognized`:return r(`settings.data.archiveErrors.unrecognized`)}},S=()=>{b.current+=1,u(null),c(!1),v(null),y.current&&(y.current.value=``)},C=async()=>{try{let e=await W.exportData();if(!e.success||!e.data)throw Error(e.error||r(`settings.data.exportFailed`));let t=new Blob([JSON.stringify(e.data,null,2)],{type:`application/json`}),n=URL.createObjectURL(t),i=document.createElement(`a`);i.href=n,i.download=`libre-webui-user-data-v3-${new Date().toISOString().split(`T`)[0]}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(n),k.success(r(`settings.data.exportSuccess`))}catch(e){k.error(e instanceof Error?e.message:r(`settings.data.exportFailed`))}},w=async(e,t)=>{let n=b.current+1;b.current=n,c(!0),u(null);try{wt(await e.text());let i=await W.preflightImport(e,t);if(!i.success||!i.data?.valid)throw Error(i.error||r(`settings.data.archiveValidationFailed`));b.current===n&&u(i.data)}catch(e){b.current===n&&k.error(e instanceof St?x(e):e instanceof Error?e.message:r(`settings.data.archiveValidationFailed`))}finally{b.current===n&&c(!1)}};return{importing:i,preflighting:o,preflight:l,showImportOptions:d,mergeStrategy:p,importResult:h,setImportResult:g,importFileInputRef:y,handleExportData:C,handleImportFileSelect:e=>{let t=e.target.files?.[0];t&&(v(t),f(!0),g(null),w(t,p))},handleMergeStrategyChange:e=>{m(e),_&&w(_,e)},handleConfirmImport:async()=>{if(_&&l&&l.strategy===p){a(!0);try{let i=await W.importData(_,p);if(i.success&&i.data)g({preferences:{imported:i.data.preferences.imported,error:null},sessionFolders:i.data.sessionFolders,sessions:i.data.sessions,notes:i.data.notes,knowledgeCollections:i.data.knowledgeCollections,documents:i.data.documents,warnings:i.data.warnings,exclusions:i.data.exclusions}),k.success(r(`settings.data.importSuccess`)),(await Promise.allSettled([e(),t(),n()])).some(e=>e.status===`rejected`)&&k.error(r(`settings.data.refreshAfterImportFailed`)),window.dispatchEvent(new Event(`libre:documents-updated`));else throw Error(i.error||r(`settings.data.importFailed`))}catch(e){k.error(e instanceof Error?e.message:r(`settings.data.importFailed`)),g(null)}finally{a(!1),f(!1),S()}}},handleCancelImport:()=>{f(!1),g(null),S()}}}var Si=Z.lazy(()=>a(()=>import(`./UserManagementPanel-CfG67c_k.js`),__vite__mapDeps([10,1,2,11,12,3,4,5,6,7,13,14,15,16,17,18,19,8,20,21,9,22,23]))),Ci=on()||`0.0.0`,wi=`__current_running_model__`,Ti={enabled:!1,model:`nomic-embed-text`,chunkSize:1e3,chunkOverlap:200,similarityThreshold:.7},Ei={enabled:!1,autoPlay:!1,model:``,voice:``,voiceProfileId:``,speed:1,pluginId:``,streamSentences:!0},Di={enabled:!1,model:``,size:`1024x1024`,quality:`standard`,style:`vivid`,pluginId:``},Oi=({isOpen:e,onClose:t,initialTab:n})=>{let{models:a,selectedModel:o,selectedProviderType:c,selectedProviderId:l,setSelectedModel:u,systemMessage:p,setSystemMessage:m,clearAllSessions:g,loading:v,sessions:S,loadModels:C,loadSessions:T,loadFolders:E}=y(),{theme:D,updateTheme:O,preferences:A,setPreferences:j,loadPreferences:M}=Vt(),{plugins:N,isLoading:P,isUploading:ee,error:te,loadPlugins:ne,uploadPlugin:L,deletePlugin:re,activatePlugin:ie,deactivatePlugin:ae,exportPlugin:R,clearError:oe,installPlugin:ce}=Pt(),{t:z}=s(),de=Z.useId(),fe=(0,Z.useRef)(null),pe=(0,Z.useRef)(null);Xt(fe,{onClose:t,enabled:e,initialFocusRef:pe});let B=`${de}-panel`,me=(0,Z.useRef)(null),[he,ge]=(0,Z.useState)(()=>window.matchMedia(`(min-width: 640px)`).matches);(0,Z.useEffect)(()=>{let e=window.matchMedia(`(min-width: 640px)`),t=()=>ge(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let ve=f(a,{model:o,providerType:c,providerId:l}),xe={model:A.titleSettings?.taskModel||``,providerType:A.titleSettings?.taskProviderType,providerId:A.titleSettings?.taskProviderId},Ce=f(a,xe),we=xe.model===wi?wi:xe.model?_(Ce,xe):``,Te={model:A.visionModel||``,providerType:A.visionProviderType,providerId:A.visionProviderId},Ee=f(a,Te),De=Te.model?_(Ee,Te):``,Oe=[{value:``,label:z(`settings.model.selectVisionModel`,{defaultValue:`Use the current chat model`})},...Ee.map(e=>({value:h(e),label:e.isLegacySelection?`${e.name} · provider not recorded${e.isUnavailable?` (unavailable)`:``}`:e.isPersona?`${e.personaName||e.name} (persona)`:e.isPlugin?`${e.name} · ${e.pluginName||e.pluginId}${e.isUnavailable?` (unavailable)`:``}`:e.isAgent?`${e.agentName||e.name} · Agent CLI${e.isUnavailable?` (unavailable)`:``}`:`${e.name} · Ollama${e.isUnavailable?` (unavailable)`:``}`}))],ke=[{value:``,label:z(`settings.model.autoTitle.selectTaskModel`)},{value:wi,label:`Use current running model`},...Ce.map(e=>({value:h(e),label:e.isLegacySelection?`${e.name} · provider not recorded${e.isUnavailable?` (unavailable)`:``}`:e.isPersona?`${e.personaName||e.name} (persona)`:e.isPlugin?`${e.name} · ${e.pluginName||e.pluginId}${e.isUnavailable?` (unavailable)`:``}`:`${e.name} · Ollama${e.isUnavailable?` (unavailable)`:``}`}))],Ae=Nt(e=>e.user),je=Nt(e=>e.systemInfo),Ne=Ae?.role===`admin`||je?.requiresAuth===!1,[Ie,ze]=(0,Z.useState)(n??`appearance`);(0,Z.useEffect)(()=>{me.current&&(me.current.scrollTop=0)},[Ie,e]);let[Be,Ve]=(0,Z.useState)(`global`),[He,Ue]=(0,Z.useState)(``),[We,Je]=(0,Z.useState)(p),[Ye,Xe]=(0,Z.useState)(!1),[Ze,$e]=(0,Z.useState)(null),[tt,nt]=(0,Z.useState)(!1),[rt,it]=(0,Z.useState)(!1),[at,V]=(0,Z.useState)(``),ot=(0,Z.useRef)(null),[st,ct]=(0,Z.useState)(null),[lt,ut]=(0,Z.useState)({}),[dt,ft]=(0,Z.useState)({}),[pt,mt]=(0,Z.useState)(null),[ht,vt]=(0,Z.useState)({}),[bt,St]=(0,Z.useState)(A.generationOptions||{}),H=(0,Z.useCallback)(async e=>{try{let t=await K.getModelDefaults(e);return t.success?t.data?.options??{}:{}}catch{return{}}},[]);(0,Z.useEffect)(()=>{if(!e)return;let t=Be===`model`&&!!o,n=!1;return(t?H(o):Promise.resolve({})).then(e=>{n||St(t?{...A.generationOptions||{},...e,...A.modelGenerationOptions?.[o]||{}}:{...A.generationOptions||{}})}),()=>{n=!0}},[e,Be,o,H,A.generationOptions,A.modelGenerationOptions]);let[U,wt]=(0,Z.useState)(A.embeddingSettings||Ti),[Et,Dt]=(0,Z.useState)(!1),[G,kt]=(0,Z.useState)(A.ttsSettings||Ei),[It,Lt]=(0,Z.useState)(!1),Rt=(0,Z.useRef)(null),zt=(0,Z.useRef)(null),[Bt,Ht]=(0,Z.useState)(A.imageGenSettings||Di),{importing:Wt,preflighting:J,preflight:Gt,showImportOptions:Kt,mergeStrategy:qt,importResult:Y,setImportResult:Jt,importFileInputRef:Yt,handleExportData:Zt,handleImportFileSelect:Qt,handleMergeStrategyChange:$t,handleConfirmImport:en,handleCancelImport:tn}=xi({loadPreferences:M,loadSessions:T,loadFolders:E}),X=r(),{data:nn={}}=i({queryKey:[`plugin-credentials`],queryFn:async()=>{let e=await Ot.getCredentials();if(!e.success||!e.data)return{};let t={};for(let n of e.data)t[n.plugin_id]=n.has_api_key;return t},enabled:e}),{data:rn=[]}=i({queryKey:[`embedding-models`],queryFn:async()=>{let e=await _t.getModels();return e.success&&e.data?e.data:[]},enabled:e}),an=(0,Z.useMemo)(()=>{let e=rn.find(e=>e.id===U.model||e.rawModel===U.model);return e&&e.id!==U.model?{...U,model:e.id}:U},[rn,U]),{data:on=null}=i({queryKey:[`embedding-status`],queryFn:async()=>{let e=await gt.getEmbeddingStatus();return e.success&&e.data?e.data:null},enabled:e}),{data:sn,isLoading:cn}=i({queryKey:[`tts-data`],queryFn:async()=>{let[e,t]=await Promise.all([xt.getModels(),xt.getPlugins()]);return{models:e.success&&Array.isArray(e.data)?e.data:[],plugins:t.success&&Array.isArray(t.data)?t.data:[]}},enabled:e}),ln=(0,Z.useMemo)(()=>sn?.models??[],[sn]),un=sn?.plugins??[],dn=(0,Z.useMemo)(()=>Ct(ln,G.model,G.pluginId),[ln,G.model,G.pluginId]),$=(0,Z.useMemo)(()=>{if(!dn)return G;let e=Tt(ln,G.model,G.pluginId);return e&&G.pluginId===e.plugin?G:{...G,model:dn.model,pluginId:dn.plugin,voice:dn.config?.default_voice??``,voiceProfileId:``}},[dn,ln,G]),fn=(0,Z.useMemo)(()=>Tt(ln,$.model,$.pluginId)?.config?.voices??[],[$,ln]),{data:pn=[],isLoading:mn,isSuccess:hn}=i({queryKey:[`tts-voice-profiles`],queryFn:async()=>{let e=await xt.getVoiceProfiles();if(!e.success)throw Error(e.message||`Failed to load saved voices`);return e.data??[]},enabled:e}),_n=(0,Z.useMemo)(()=>pn.filter(e=>e.pluginId===$.pluginId&&e.model===$.model&&(e.consentStatus??`active`)===`active`),[$,pn]),vn=(0,Z.useMemo)(()=>{let e=$.voiceProfileId,t=e?pn.find(t=>t.id===e):void 0,n=!!(e&&dn)&&!dn?.config?.supports_voice_cloning,r=hn&&!!e&&(!t||t.pluginId!==$.pluginId||t.model!==$.model||(t.consentStatus??`active`)!==`active`);return!e||!n&&!r?$:{...$,voiceProfileId:``,voice:dn?.config?.default_voice??``}},[hn,$,dn,pn]);(0,Z.useEffect)(()=>{let e=$.voiceProfileId,t=e?pn.find(t=>t.id===e):void 0;e&&(dn&&!dn?.config?.supports_voice_cloning||hn&&(!t||t.pluginId!==$.pluginId||t.model!==$.model))&&e&&zt.current!==e&&(zt.current=e,W.updatePreferences({ttsSettings:vn}).then(e=>{e.success&&e.data&&j(e.data)}).catch(e=>{zt.current=null,k.error(x(e,z(`settings.tts.savedVoiceUnavailableCleanupFailed`)))}))},[vn,hn,$.model,$.pluginId,$.voiceProfileId,dn,j,z,pn]);let{data:yn,isLoading:bn}=i({queryKey:[`image-gen-data`],queryFn:async()=>{let[e,t]=await Promise.all([yt.getModels(),yt.getPlugins()]);return{models:e.success&&e.data?e.data:[],plugins:t.success&&t.data?t.data:[]}},enabled:e}),xn=(0,Z.useMemo)(()=>yn?.models??[],[yn]),Cn=(0,Z.useMemo)(()=>yn?.plugins??[],[yn]),En=(0,Z.useMemo)(()=>At(xn,Bt.model,Bt.pluginId),[xn,Bt.model,Bt.pluginId]),Dn=(0,Z.useMemo)(()=>{if(!En)return Bt;let e=Mt(xn,Bt.model,Bt.pluginId);return e&&Bt.pluginId===e.plugin?Bt:{...Bt,model:En.model,pluginId:En.plugin,size:jt(En.config?.sizes,Bt.size,En.config?.default_size,`1024x1024`),quality:jt(En.config?.qualities,Bt.quality,En.config?.default_quality,`standard`),style:jt(En.config?.styles,Bt.style,En.config?.default_style,`vivid`)}},[xn,Bt,En]),kn=En?.config?.sizes??[],An=En?.config?.qualities??[],jn=En?.config?.styles??[],Mn=(0,Z.useRef)(!1),Pn=(0,Z.useRef)(p);(0,Z.useEffect)(()=>{if(!e){Mn.current=!1;return}Mn.current&&Pn.current===p||(Mn.current=!0,Pn.current=p,Je(p),St(A.generationOptions||{}),wt(A.embeddingSettings||Ti),kt(A.ttsSettings||Ei),Ht(A.imageGenSettings||Di))},[e,A.embeddingSettings,A.generationOptions,A.imageGenSettings,A.ttsSettings,p]);let Fn=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{if(!e){Fn.current=!1;return}Fn.current||(Fn.current=!0,ne(),C())},[e,ne,C]),(0,Z.useEffect)(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e]);let In=async e=>{let t=lt[e];if(!t?.trim()){k.error(z(`settings.plugins.apiKey.enterKey`));return}mt(e);try{let n=await Ot.setApiKey(e,t.trim());n.success?(k.success(z(`settings.plugins.apiKey.saved`)),await X.invalidateQueries({queryKey:[`plugin-credentials`]}),await ne(),await Promise.all([X.invalidateQueries({queryKey:[`image-gen-data`]}),X.invalidateQueries({queryKey:[`tts-data`]})]),ut(t=>({...t,[e]:``})),ft(t=>({...t,[e]:!1}))):k.error(n.error||z(`settings.plugins.apiKey.saveFailed`))}catch{k.error(z(`settings.plugins.apiKey.saveFailed`))}finally{mt(null)}},Rn=async e=>{mt(e);try{let t=await Ot.deleteApiKey(e);t.success?(k.success(z(`settings.plugins.apiKey.removed`)),await X.invalidateQueries({queryKey:[`plugin-credentials`]}),await ne(),await Promise.all([X.invalidateQueries({queryKey:[`image-gen-data`]}),X.invalidateQueries({queryKey:[`tts-data`]})]),ut(t=>({...t,[e]:``}))):k.error(t.error||z(`settings.plugins.apiKey.removeFailed`))}catch{k.error(z(`settings.plugins.apiKey.removeFailed`))}finally{mt(null)}},zn=(e,t)=>{let n=Tt(ln,e,t);n&&kt(r=>({...r,model:e,pluginId:t,voice:n.config?.default_voice??``,voiceProfileId:``}))},Vn=(e,t)=>{let n=Mt(xn,e,t);n&&Ht(t=>({...t,model:e,pluginId:n.plugin,size:jt(n.config?.sizes,t.size,n.config?.default_size,`1024x1024`),quality:jt(n.config?.qualities,t.quality,n.config?.default_quality,`standard`),style:jt(n.config?.styles,t.style,n.config?.default_style,`vivid`)}))},Hn=(e,t)=>{kt(n=>({...n,[e]:t}))},Un=(e,t)=>{kt(n=>({...n,voice:e,voiceProfileId:t}))},Wn=async e=>{if(window.confirm(z(`settings.tts.revokeSavedVoiceConfirm`,{name:e.name,defaultValue:`Withdraw consent for “{{name}}”? The saved voice can no longer be used, but the consent record is kept.`})))try{let t=await xt.revokeVoiceProfile(e.id);if(!t.success)throw Error(t.error||z(`settings.tts.savedVoiceRevokeFailed`));let n=t.data;X.setQueryData([`tts-voice-profiles`],t=>t?.map(t=>t.id===e.id&&n?n:t)??[]),await X.invalidateQueries({queryKey:[`tts-voice-profiles`]}),k.success(z(`settings.tts.savedVoiceRevoked`,{defaultValue:`Consent withdrawn`}))}catch(e){k.error(x(e,z(`settings.tts.savedVoiceRevokeFailed`,{defaultValue:`Failed to withdraw consent`})))}},Gn=async e=>{if(!window.confirm(z(`settings.tts.deleteSavedVoiceConfirm`,{name:e.name,defaultValue:`Delete the saved voice “{{name}}”? Its reference recording and transcript will be removed.`})))return;try{await xt.deleteVoiceProfile(e.id)}catch(e){k.error(x(e,z(`settings.tts.savedVoiceDeleteFailed`,{defaultValue:`Failed to delete saved voice`})));return}let t=dn?.config?.default_voice??``;if(G.voiceProfileId===e.id&&kt(e=>({...e,voiceProfileId:``,voice:t})),A.ttsSettings?.voiceProfileId===e.id&&j({...A,ttsSettings:{...A.ttsSettings,voiceProfileId:``,voice:t}}),X.setQueryData([`tts-voice-profiles`],t=>t?.filter(t=>t.id!==e.id)??[]),await X.invalidateQueries({queryKey:[`tts-voice-profiles`]}),k.success(z(`settings.tts.savedVoiceDeleted`,{defaultValue:`Saved voice deleted`})),A.ttsSettings?.voiceProfileId===e.id)try{let e=await W.updatePreferences({ttsSettings:{...A.ttsSettings,voiceProfileId:``,voice:t}});if(!e.success||!e.data)throw Error(e.error||`Preference update failed`);j(e.data)}catch{k.error(z(`settings.tts.savedVoicePreferenceCleanupFailed`,{defaultValue:`Saved voice deleted, but Speech settings could not be reset`}))}},Kn=async()=>{try{let e=await W.updatePreferences({ttsSettings:vn});e.success&&e.data&&(j(e.data),k.success(z(`settings.tts.saveSuccess`)))}catch(e){let t=e instanceof Error?e.message:String(e);k.error(z(`settings.tts.saveFailed`,{error:t}))}},qn=async()=>{if(It){let e=Rt.current;e&&(e.pause(),e.currentTime=0,Rt.current=null),Lt(!1);return}Lt(!0);try{let e=await xt.generateBase64({model:vn.model||`tts-1`,pluginId:vn.pluginId,input:`Hello! This is a test of the text-to-speech system.`,voice:vn.voiceProfileId?void 0:vn.voice||void 0,voiceProfileId:vn.voiceProfileId||void 0,speed:vn.speed||1,response_format:dn?.config?.default_format});if(e.success&&e.data?.audio){let t=`data:${e.data.mimeType};base64,${e.data.audio}`,n=new Audio(t);Rt.current=n,n.onended=()=>{Lt(!1),Rt.current=null},n.onerror=()=>{k.error(z(`ttsButton.playbackFailed`)),Lt(!1),Rt.current=null},await n.play()}else throw Error(e.message||z(`ttsButton.generateFailed`))}catch(e){let t=e instanceof Error?e.message:String(e);k.error(z(`settings.tts.testFailed`,{error:t})),Lt(!1)}},Jn=()=>{kt({enabled:!1,autoPlay:!1,model:ln[0]?.model||``,voice:ln[0]?.config?.default_voice??``,voiceProfileId:``,speed:1,pluginId:ln[0]?.plugin||``,streamSentences:!0})},Yn=(e,t)=>{Ht(n=>({...n,[e]:t}))},Xn=async()=>{try{let e=await W.updatePreferences({imageGenSettings:Dn});e.success&&e.data&&(j(e.data),k.success(z(`settings.imageGen.saveSuccess`)))}catch(e){let t=e instanceof Error?e.message:String(e);k.error(z(`settings.imageGen.saveFailed`,{error:t}))}},Zn=()=>{Ht({enabled:!1,model:xn[0]?.model||``,size:xn[0]?.config?.default_size||`1024x1024`,quality:xn[0]?.config?.default_quality||`standard`,style:xn[0]?.config?.default_style||`vivid`,pluginId:xn[0]?.plugin||``})},Qn=async()=>{try{Dt(!0);let e=await gt.regenerateEmbeddings();e.success&&e.data&&(k.success(e.data.documentsSkipped>0?z(`settings.documents.embeddings.regeneratePartialSuccess`,{count:e.data.documentsRegenerated,skipped:e.data.documentsSkipped}):z(`settings.documents.embeddings.regenerateSuccess`,{count:e.data.documentsRegenerated})),await X.invalidateQueries({queryKey:[`embedding-status`]}))}catch(e){let t=e instanceof Error?e.message:String(e);k.error(z(`settings.documents.embeddings.regenerateFailed`,{error:t}))}finally{Dt(!1)}},$n=async e=>{let t=e.target.files?.[0];t&&(await L(t),nt(!1),ot.current&&(ot.current.value=``),await C(),await Promise.all([X.invalidateQueries({queryKey:[`image-gen-data`]}),X.invalidateQueries({queryKey:[`tts-data`]})]))},tr=async()=>{try{let e=JSON.parse(at);await ce(e),it(!1),V(``),await C(),await Promise.all([X.invalidateQueries({queryKey:[`image-gen-data`]}),X.invalidateQueries({queryKey:[`tts-data`]})])}catch{oe(),k.error(z(`settings.plugins.invalidJson`))}},nr=async e=>{N.find(t=>t.id===e)?.active?await ae(e):await ie(e),await C(),await Promise.all([X.invalidateQueries({queryKey:[`image-gen-data`]}),X.invalidateQueries({queryKey:[`tts-data`]})])},rr=async e=>{if(!ht[e]){vt(t=>({...t,[e]:!0}));try{let t=await Ot.discoverModels(e);if(!t.success||!t.data){k.error(t.error||z(`settings.plugins.modelCatalogRefreshFailed`));return}await Promise.all([ne(),C()]);let{outcome:n,models:r,reason:i}=t.data;n===`updated`?k.success(z(`settings.plugins.modelCatalogUpdated`,{count:r.length})):n===`unchanged`?k.success(z(`settings.plugins.modelCatalogUnchanged`)):n===`missing_credentials`?k.error(i||z(`settings.plugins.modelCatalogNeedsApiKey`)):k.error(i?`${z(`settings.plugins.modelCatalogUnavailable`)} ${i}`:z(`settings.plugins.modelCatalogUnavailable`))}catch(e){k.error(x(e,z(`settings.plugins.modelCatalogRefreshFailed`)))}finally{vt(t=>{let n={...t};return delete n[e],n})}}},ar=async e=>{window.confirm(`Are you sure you want to delete this plugin?`)&&(await re(e),await C(),await Promise.all([X.invalidateQueries({queryKey:[`image-gen-data`]}),X.invalidateQueries({queryKey:[`tts-data`]})]))},or=async e=>{await R(e)};if(!e)return null;let sr=e=>{let t=Vt.getState().theme,n=Ft({...t,mode:e});O(n)},cr=e=>{let t=Vt.getState().theme,n=Ft({...t,accent:e});O(n)},ur=e=>{let t=Vt.getState().theme,n=Ft({...t,accent:`custom`,customAccent:e});O(n)},dr=e=>{let t=Vt.getState().theme,n=Ft({...t,adaptToAccent:e});O(n)},fr=e=>{j({showUsername:e}),W.updatePreferences({showUsername:e}).catch(e=>{let t=e instanceof Error?e.message:String(e);k.error(z(`settings.preferences.updateFailed`,{error:t}))})},pr=e=>{j({showFollowUpSuggestions:e}),W.updatePreferences({showFollowUpSuggestions:e}).catch(e=>{let t=e instanceof Error?e.message:String(e);k.error(z(`settings.preferences.updateFailed`,{error:t}))})},hr=e=>{j({autoOpenArtifactPanel:e}),W.updatePreferences({autoOpenArtifactPanel:e}).catch(e=>{let t=e instanceof Error?e.message:String(e);k.error(z(`settings.preferences.updateFailed`,{error:t}))})},vr=e=>{j({hapticFeedbackEnabled:e}),e&&Ut(`selection`),W.updatePreferences({hapticFeedbackEnabled:e}).catch(e=>{let t=e instanceof Error?e.message:String(e);k.error(z(`settings.preferences.updateFailed`,{error:t}))})},yr=async e=>{let t=``,n=null,r=null;if(!e.target.value)t=``;else{let i=b(ve,e.target.value);if(!i)return;t=i.model,n=i.providerType??null,r=i.providerId??null}j({defaultModel:t,defaultProviderType:n,defaultProviderId:r});let i=await u(t,n,r);i.success?k.success(z(`settings.model.defaultModelUpdated`)):k.error(z(`settings.preferences.updateFailed`,{error:i.error||z(`errors.generic`)}))},br=e=>{Je(e.target.value)},Sr=async()=>{await m(We)?k.success(z(`settings.systemMessage.saved`)):k.error(z(`settings.systemMessage.saveFailed`))},Cr=async()=>{window.confirm(`Are you sure you want to delete all chat history? This action cannot be undone.`)&&await g()},wr=()=>{Xe(!0),$e(null),K.pullAllModelsStream(e=>{$e(e)},()=>{Xe(!1),$e(null),k.success(z(`settings.model.allModelsUpdated`))},e=>{Xe(!1),$e(null),k.error(z(`settings.model.updateAllFailed`,{error:e}))})},Tr=e=>{let t={...A.titleSettings,autoTitle:e,taskModel:A.titleSettings?.taskModel||``};j({titleSettings:t}),W.updatePreferences({titleSettings:t})},Er=e=>{if(!e){let e={visionModel:``,visionProviderType:null,visionProviderId:null};j(e),W.updatePreferences(e);return}let t=b(Ee,e);if(!t?.providerType){k.error(z(`settings.model.visionModelNoProvider`));return}let n={visionModel:t.model,visionProviderType:t.providerType,visionProviderId:t.providerId||null};j(n),W.updatePreferences(n).catch(e=>{let t=e instanceof Error?e.message:String(e);k.error(z(`settings.model.visionModelUpdateFailed`,{error:t}))})},Dr=e=>{let t=e&&e!==wi?b(Ce,e):null,n={...A.titleSettings,autoTitle:A.titleSettings?.autoTitle||!1,taskModel:t?.model||e,taskProviderType:t?.providerType||null,taskProviderId:t?.providerType===`plugin`&&t.providerId||null};j({titleSettings:n}),W.updatePreferences({titleSettings:n})},Or=(e,t)=>{ut(n=>({...n,[e]:t}))},kr=(e,t)=>{ft(n=>({...n,[e]:t}))},Ar=(e,t)=>{St(n=>({...n,[e]:t}))},jr=async()=>{try{let e=Be===`model`&&o?await W.setModelGenerationOptions(o,bt):await W.setGenerationOptions(bt);e.success&&e.data&&(j(e.data),k.success(z(`settings.generation.saveSuccess`)))}catch(e){let t=e instanceof Error?e.message:String(e);k.error(z(`settings.generation.saveFailed`,{error:t}))}},Mr=async()=>{try{let e=Be===`model`&&o?await W.setModelGenerationOptions(o,{}):await W.resetGenerationOptions();if(e.success&&e.data){j(e.data);let t=Be===`model`&&o,n=t?await H(o):{};St({...e.data.generationOptions||{},...n}),k.success(t?z(`settings.generation.modelDefaultsLoaded`,{model:o}):z(`settings.generation.resetSuccess`))}}catch(e){let t=e instanceof Error?e.message:String(e);k.error(z(`settings.generation.resetFailed`,{error:t}))}},Nr=(e,t)=>{wt(n=>({...n,[e]:t}))},Pr=[...rn.map(e=>({value:e.id,label:`${e.name} (${e.pluginName||e.provider})`})),...!rn.find(e=>e.id===an.model||e.rawModel===an.model)&&an.model?[{value:an.model,label:`${an.model} (current)`}]:[]],Ir=async()=>{try{let e=await W.setEmbeddingSettings(an);e.success&&e.data&&(j(e.data),k.success(z(`settings.documents.embeddings.saveSuccess`)))}catch(e){let t=e instanceof Error?e.message:String(e);k.error(z(`settings.documents.embeddings.saveFailed`,{error:t}))}},Lr=async()=>{try{let e=await W.resetEmbeddingSettings();e.success&&e.data&&(j(e.data),wt(e.data.embeddingSettings||{}),k.success(z(`settings.documents.embeddings.resetSuccess`)))}catch(e){let t=e instanceof Error?e.message:String(e);k.error(z(`settings.documents.embeddings.resetFailed`,{error:t}))}},Rr={appearance:`theme dark light accent color language username follow-up background interface artifact panel auto open`,data:`export import backup clear history sessions`,about:`version license update`,models:`default model system prompt title vision auto`,generation:`temperature top_p top_k seed tokens context penalty embedding chunk similarity`,documents:`upload pdf rag document embedding`,tts:`voice speech audio speak read aloud`,"image-gen":`image generation size quality style`,plugins:`api key provider connection openai anthropic groq gemini deepseek`,search:`web search searxng internet browse sources`,shortcuts:`keyboard keys hotkeys shortcut command palette`,sessions:`sessions devices sign out logout revoke security login`,"api-keys":`api key token scope secret bearer security integration`,"model-manager":`models download pull update bulk refresh delete ollama library huggingface bulk operations update all models ${z(`settings.model.bulkOperations`)} ${z(`settings.model.updateAll`)}`.toLowerCase(),prompts:`prompts slash command template variables library rollback`,skills:`skills manifest instructions slug load_skill rollback`,tools:`tools mcp openapi server credential approval function calling`},zr=He.trim().toLowerCase(),Br=e=>!zr||e.label.toLowerCase().includes(zr)||(Rr[e.id]||``).includes(zr),Vr=[{id:`general`,label:z(`settings.groups.general`,`General`),tabs:[{id:`appearance`,label:z(`settings.tabs.appearance`),icon:Re},{id:`data`,label:z(`settings.tabs.data`),icon:Se},{id:`sessions`,label:z(`settings.tabs.sessions`,`Sessions`),icon:Me},{id:`notifications`,label:z(`settings.tabs.notifications`,`Notifications`),icon:Le},{id:`api-keys`,label:z(`settings.tabs.apiKeys`,`API keys`),icon:_e},{id:`shortcuts`,label:z(`settings.tabs.shortcuts`),icon:ye},{id:`about`,label:z(`settings.tabs.about`),icon:be}]},{id:`chat`,label:z(`settings.groups.chat`,`Chat`),tabs:[{id:`models`,label:z(`settings.tabs.model`),icon:Pe},{id:`model-manager`,label:z(`models.title`),icon:le,disabled:je?.ollamaEnabled===!1,disabledHint:z(`settings.tabs.ollamaDisabled`)},{id:`generation`,label:z(`settings.tabs.generation`),icon:se},{id:`documents`,label:z(`settings.tabs.documents`),icon:le},{id:`prompts`,label:z(`sidebar.navigation.prompts`),icon:Ge},{id:`skills`,label:z(`sidebar.navigation.skills`),icon:w}]},{id:`media`,label:z(`settings.groups.media`,`Speech & images`),tabs:[{id:`tts`,label:z(`settings.tabs.tts`),icon:qe},{id:`image-gen`,label:z(`settings.tabs.imageGen`),icon:I}]},{id:`connections`,label:z(`settings.groups.connections`,`Connections`),tabs:[{id:`plugins`,label:z(`settings.tabs.plugins`),icon:ue},{id:`tools`,label:z(`sidebar.navigation.tools`),icon:Qe},...Ne?[{id:`search`,label:z(`settings.tabs.search`),icon:Fe}]:[]]},...Ne?[{id:`admin`,label:z(`settings.groups.admin`,`Administration`),tabs:[{id:`users`,label:z(`userManager.title`),icon:et}]}]:[]],Hr=Vr.map(e=>({...e,tabs:e.tabs.filter(Br)})).filter(e=>e.tabs.length>0),Wr=Hr.flatMap(e=>e.tabs),Gr=Wr.filter(e=>!e.disabled),Kr=Gr.some(e=>e.id===Ie)?Ie:Gr[0]?.id,qr=Vr.flatMap(e=>e.tabs).find(e=>e.id===Ie)?.label,Jr=(e,t)=>{let n=getComputedStyle(e.currentTarget).direction===`rtl`,r=he?`ArrowDown`:n?`ArrowLeft`:`ArrowRight`;if(![r,he?`ArrowUp`:n?`ArrowRight`:`ArrowLeft`,`Home`,`End`].includes(e.key))return;e.preventDefault();let i=Gr.findIndex(e=>e.id===t),a=e.key===`Home`?0:e.key===`End`?Gr.length-1:(i+(e.key===r?1:-1)+Gr.length)%Gr.length,o=Gr[a];if(!o)return;ze(o.id);let s=document.getElementById(`${de}-tab-${o.id}`);s?.focus({preventScroll:!0}),s?.scrollIntoView({block:`nearest`,inline:`nearest`})};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`fixed inset-0 z-50 bg-[var(--overlay-mask)] backdrop-blur-[2px] transition-opacity duration-200`,onClick:t}),(0,Q.jsx)(`div`,{ref:fe,className:`fixed inset-0 z-50 flex items-center justify-center p-0 sm:p-6`,role:`dialog`,tabIndex:-1,"aria-modal":`true`,"aria-labelledby":de,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,Q.jsxs)(`div`,{"data-testid":`settings-modal-panel`,className:`flex h-full w-full flex-col overscroll-behavior-contain bg-surface shadow-lv3 animate-scale-in sm:h-[min(1000px,calc(100vh-2.5rem))] sm:max-w-[1280px] sm:rounded-[24px] sm:border sm:border-black/[0.04] sm:dark:border-white/[0.06]`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-line px-4 py-4 sm:hidden`,children:[(0,Q.jsx)(`h2`,{className:`text-xl font-medium text-ink`,children:z(`settings.title`)}),(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:t,className:`h-9 w-9 touch-manipulation rounded-full p-0 hover:bg-interactive-hover`,title:z(`common.close`,{defaultValue:`Close`}),children:(0,Q.jsx)(Ke,{className:`h-5 w-5`})})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overscroll-behavior-contain sm:flex-row`,children:[(0,Q.jsxs)(`div`,{className:`flex min-h-0 w-full shrink-0 flex-col border-b border-line p-2 sm:w-[210px] sm:border-b-0 sm:px-3 sm:pb-3 sm:pt-[22px]`,children:[(0,Q.jsx)(`h2`,{id:de,className:`hidden shrink-0 px-3 pb-4 text-base font-medium leading-6 text-ink sm:block`,children:z(`settings.title`)}),(0,Q.jsxs)(`div`,{className:`relative mb-2 hidden shrink-0 sm:block`,children:[(0,Q.jsx)(F,{className:`pointer-events-none absolute start-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-ink-subtle`}),(0,Q.jsx)(`input`,{ref:pe,type:`search`,"aria-label":z(`common.search`),value:He,onChange:e=>{let t=e.target.value;Ue(t);let n=t.trim().toLowerCase();if(!n)return;let r=Vr.flatMap(e=>e.tabs).filter(e=>!e.disabled&&(e.label.toLowerCase().includes(n)||(Rr[e.id]||``).includes(n)));r.length>0&&!r.some(e=>e.id===Ie)&&ze(r[0].id)},placeholder:z(`common.search`),className:`h-9 w-full rounded-xl border border-transparent bg-surface-subtle pe-2.5 ps-8 text-[13px] text-ink placeholder:text-ink-subtle focus:border-primary-500/40 focus:outline-none`})]}),(0,Q.jsxs)(`div`,{"data-testid":`settings-navigation-scroll-region`,className:`min-h-0 overflow-x-auto scrollbar-thin sm:overflow-x-hidden sm:overflow-y-auto`,style:{WebkitOverflowScrolling:`touch`},children:[(0,Q.jsx)(`nav`,{className:`flex gap-1 sm:flex-col sm:gap-0`,role:`tablist`,"aria-label":z(`settings.title`,`Settings`),"aria-orientation":he?`vertical`:`horizontal`,children:Hr.map(e=>(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-1 sm:flex-col sm:gap-0.5 sm:pb-2`,children:[(0,Q.jsx)(`p`,{"aria-hidden":`true`,className:`hidden px-3 pb-1 pt-2 text-[10px] font-medium uppercase tracking-[0.08em] text-ink-subtle sm:block`,children:e.label}),e.tabs.map(e=>{let t=e.icon,n=Ie===e.id,r=e.disabled===!0;return(0,Q.jsxs)(`button`,{id:`${de}-tab-${e.id}`,"data-testid":`settings-tab-${e.id}`,onClick:()=>ze(e.id),onKeyDown:t=>Jr(t,e.id),tabIndex:e.id===Kr?0:-1,disabled:r,title:r?e.disabledHint:void 0,className:d(`flex h-9 shrink-0 items-center gap-2 rounded-xl px-3 text-start transition-colors duration-150 touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40 sm:w-full`,r?`cursor-not-allowed text-ink-subtle opacity-60`:n?`bg-nav-active text-ink`:`text-ink hover:bg-hover-solid`),role:`tab`,"aria-selected":n,"aria-disabled":r||void 0,"aria-controls":B,children:[(0,Q.jsx)(t,{className:`h-4 w-4 flex-shrink-0 text-ink-muted`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`truncate whitespace-nowrap text-sm`,children:e.label})]},e.id)})]},e.id))}),Wr.length===0&&(0,Q.jsx)(`p`,{role:`status`,className:`px-3 py-4 text-sm text-ink-muted`,children:z(`common.noResults`)})]})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`div`,{className:`hidden h-[54px] shrink-0 items-center justify-end px-3.5 pb-2 pt-5 sm:flex`,children:(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:t,className:`h-7 w-7 touch-manipulation rounded-full p-0 text-ink hover:bg-interactive-hover`,title:z(`common.close`,{defaultValue:`Close`}),children:(0,Q.jsx)(Ke,{className:`h-4 w-4`})})}),(0,Q.jsx)(`div`,{"data-testid":`settings-scroll-region`,ref:me,className:`scroll-region min-h-0 flex-1 p-4 pt-2 scrollbar-thin sm:px-6 sm:pb-6 sm:pt-0`,id:B,role:`tabpanel`,"aria-labelledby":Wr.some(e=>e.id===Ie)?`${de}-tab-${Ie}`:void 0,"aria-label":qr,tabIndex:0,children:(()=>{switch(Ie){case`appearance`:return(0,Q.jsx)(Sn,{theme:D,preferences:A,onThemeChange:sr,onAccentChange:cr,onCustomAccentChange:ur,onAdaptToAccentChange:dr,onShowUsernameChange:fr,onShowFollowUpsChange:pr,onAutoOpenArtifactsChange:hr,onHapticFeedbackChange:vr});case`models`:return(0,Q.jsx)(Ln,{models:a,selectedModel:o,selectedProviderType:c,selectedProviderId:l,systemMessage:p,tempSystemMessage:We,loading:v,preferences:A,currentVisionModel:De,visionModelOptions:Oe,currentTaskModel:we,autoTitleTaskModelOptions:ke,onModelChange:yr,onSystemMessageChange:br,onSystemMessageSave:Sr,onAutoTitleChange:Tr,onAutoTitleTaskModelChange:Dr,onVisionModelChange:Er});case`tts`:return(0,Q.jsx)(_r,{loading:cn,settings:G,effectiveSettings:vn,models:ln,plugins:un,voices:fn,voiceProfiles:pn,selectableVoiceProfiles:_n,loadingVoiceProfiles:mn,testing:It,onSettingChange:Hn,onVoiceChange:Un,onDeleteVoiceProfile:Gn,onRevokeVoiceProfile:Wn,onModelChange:zn,onReset:Jn,onTest:qn,onSave:Kn});case`image-gen`:return(0,Q.jsx)(Nn,{loading:bn,settings:Bt,effectiveSettings:Dn,models:xn,plugins:Cn,sizes:kn,qualities:An,styles:jn,onSettingChange:Yn,onModelChange:Vn,onReset:Zn,onSave:Xn});case`documents`:return(0,Q.jsx)(Tn,{settings:U,effectiveSettings:an,modelOptions:Pr,status:on,regenerating:Et,onSettingChange:Nr,onReset:Lr,onRegenerate:Qn,onSave:Ir});case`search`:return(0,Q.jsx)(ir,{});case`users`:return(0,Q.jsxs)(`div`,{className:`pb-2`,children:[(0,Q.jsx)(xr,{title:z(`userManager.title`),description:z(`userManager.pageDescription`)}),(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Si,{})})]});case`model-manager`:return(0,Q.jsxs)(`div`,{className:`pb-2`,children:[(0,Q.jsx)(xr,{title:z(`models.title`),description:z(`models.subtitle`)}),(0,Q.jsx)(bi,{updatingAllModels:Ye,updateProgress:Ze,onUpdateAllModels:wr})]});case`prompts`:return(0,Q.jsx)(Fr,{});case`skills`:return(0,Q.jsx)(Ur,{});case`tools`:return(0,Q.jsx)(ni,{});case`sessions`:return(0,Q.jsx)(lr,{});case`notifications`:return(0,Q.jsx)(mr,{});case`api-keys`:return(0,Q.jsx)(gr,{});case`plugins`:return(0,Q.jsx)(er,{plugins:N,loading:P,uploading:ee,error:te,hasKeys:nn,showUploadForm:tt,showJsonForm:rt,jsonInput:at,fileInputRef:ot,expandedPluginId:st,pluginApiKeys:lt,showApiKey:dt,savingApiKey:pt,refreshingPluginIds:ht,onClearError:oe,onShowUploadFormChange:nt,onShowJsonFormChange:it,onJsonInputChange:V,onFileUpload:$n,onJsonSubmit:tr,onExpandedPluginChange:ct,onPluginApiKeyChange:Or,onShowApiKeyChange:kr,onActivatePlugin:nr,onRefreshModels:rr,onDeletePlugin:ar,onExportPlugin:or,onSaveApiKey:In,onDeleteApiKey:Rn});case`data`:return(0,Q.jsx)(wn,{sessionCount:S.length,loading:v,importing:Wt,preflighting:J,preflight:Gt,showImportOptions:Kt,mergeStrategy:qt,importResult:Y,importFileInputRef:Yt,onExportData:Zt,onImportFileSelect:Qt,onClearAllHistory:Cr,onMergeStrategyChange:$t,onConfirmImport:en,onCancelImport:tn,onDismissImportResult:()=>Jt(null)});case`shortcuts`:return(0,Q.jsx)(Bn,{});case`about`:return(0,Q.jsx)(gn,{appVersion:Ci});case`generation`:return(0,Q.jsx)(On,{generationOptions:bt,generationScope:Be,scopedModel:o||void 0,onGenerationScopeChange:Ve,embeddingSettings:U,effectiveEmbeddingSettings:an,embeddingModelOptions:Pr,embeddingStatus:on,onGenerationOptionChange:Ar,onEmbeddingSettingsChange:Nr,onResetGenerationOptions:Mr,onSaveGenerationOptions:jr,onResetEmbeddingSettings:Lr,onSaveEmbeddingSettings:Ir});default:return null}})()})]})]})]})})]})};export{Oi as SettingsModal};
|